Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
// source: skill.sql
package store
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const createSkillManifest = `-- name: CreateSkillManifest :exec
INSERT INTO skill_manifests(
manifest_id,skill_id,manifest_version,description,config_schema,
frontmatter_extra,content_hash,file_count,size_bytes,created_by_actor_id,files
)
VALUES(
$1,$2,$3,
$4,$5,$6::jsonb,
$7,$8,$9,
$10,$11::jsonb
)
`
type CreateSkillManifestParams struct {
ManifestID string `json:"manifest_id"`
SkillID string `json:"skill_id"`
ManifestVersion string `json:"manifest_version"`
Description string `json:"description"`
ConfigSchema []byte `json:"config_schema"`
FrontmatterExtra []byte `json:"frontmatter_extra"`
ContentHash []byte `json:"content_hash"`
FileCount int32 `json:"file_count"`
SizeBytes int64 `json:"size_bytes"`
CreatedByActorID pgtype.Text `json:"created_by_actor_id"`
Files []byte `json:"files"`
}
// files is the validated list from skill.EncodeManifestFiles.
func (q *Queries) CreateSkillManifest(ctx context.Context, arg CreateSkillManifestParams) error {
_, err := q.db.Exec(ctx, createSkillManifest,
arg.ManifestID,
arg.SkillID,
arg.ManifestVersion,
arg.Description,
arg.ConfigSchema,
arg.FrontmatterExtra,
arg.ContentHash,
arg.FileCount,
arg.SizeBytes,
arg.CreatedByActorID,
arg.Files,
)
return err
}
const createTenantSkill = `-- name: CreateTenantSkill :exec
INSERT INTO skills(
skill_id,owner_kind,tenant_id,name,access_scope,owner_actor_id,created_by_actor_id
)
VALUES(
$1,'tenant',$2,$3,$4,
$5,$6
)
`
type CreateTenantSkillParams struct {
SkillID string `json:"skill_id"`
TenantID pgtype.Text `json:"tenant_id"`
Name string `json:"name"`
AccessScope string `json:"access_scope"`
OwnerActorID pgtype.Text `json:"owner_actor_id"`
CreatedByActorID pgtype.Text `json:"created_by_actor_id"`
}
func (q *Queries) CreateTenantSkill(ctx context.Context, arg CreateTenantSkillParams) error {
_, err := q.db.Exec(ctx, createTenantSkill,
arg.SkillID,
arg.TenantID,
arg.Name,
arg.AccessScope,
arg.OwnerActorID,
arg.CreatedByActorID,
)
return err
}
const listBindableSkillManifests = `-- name: ListBindableSkillManifests :many
SELECT skill.skill_id,
manifest.manifest_version,
skill.name,
manifest.description,
manifest.config_schema,
manifest.content_hash,
manifest.file_count,
manifest.size_bytes,
CASE WHEN manifest.state='active' THEN 'active' ELSE 'disabled' END AS availability,
skill.access_scope,
skill.owner_actor_id,
COALESCE(manifest.created_by_actor_id,$1::text) AS created_by_actor_id,
manifest.created_at,
manifest.sealed_at
FROM skills skill
JOIN skill_manifests manifest
ON manifest.skill_id=skill.skill_id
AND manifest.package_state='sealed'
AND manifest.state IN ('active','disabled')
WHERE cardinality(skill.default_agent_types)=0
AND (
(skill.owner_kind='tenant' AND skill.tenant_id=$2::text
AND (skill.access_scope='tenant'
OR skill.owner_actor_id=$1::text))
OR (skill.owner_kind='platform' AND skill.tenant_id IS NULL
AND manifest.manifest_id=skill.latest_manifest_id)
)
AND ($3::text=''
OR (skill.skill_id COLLATE "C",manifest.manifest_version COLLATE "C")
> ($3::text COLLATE "C",
$4::text COLLATE "C"))
ORDER BY skill.skill_id COLLATE "C",manifest.manifest_version COLLATE "C"
LIMIT $5
`
type ListBindableSkillManifestsParams struct {
CallerActorID string `json:"caller_actor_id"`
TenantID string `json:"tenant_id"`
CursorSkillID string `json:"cursor_skill_id"`
CursorManifestVersion string `json:"cursor_manifest_version"`
PageLimit int32 `json:"page_limit"`
}
type ListBindableSkillManifestsRow struct {
SkillID string `json:"skill_id"`
ManifestVersion string `json:"manifest_version"`
Name string `json:"name"`
Description string `json:"description"`
ConfigSchema []byte `json:"config_schema"`
ContentHash []byte `json:"content_hash"`
FileCount int32 `json:"file_count"`
SizeBytes int64 `json:"size_bytes"`
Availability string `json:"availability"`
AccessScope string `json:"access_scope"`
OwnerActorID pgtype.Text `json:"owner_actor_id"`
CreatedByActorID pgtype.Text `json:"created_by_actor_id"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
SealedAt pgtype.Timestamptz `json:"sealed_at"`
}
// One keyset page of every Tenant Skill version the caller can see and the
// current version of every Platform Skill that is not an Agent Type default.
func (q *Queries) ListBindableSkillManifests(ctx context.Context, arg ListBindableSkillManifestsParams) ([]ListBindableSkillManifestsRow, error) {
rows, err := q.db.Query(ctx, listBindableSkillManifests,
arg.CallerActorID,
arg.TenantID,
arg.CursorSkillID,
arg.CursorManifestVersion,
arg.PageLimit,
)
if err != nil {
return nil, err
}
defer rows.Close()
items := []ListBindableSkillManifestsRow{}
for rows.Next() {
var i ListBindableSkillManifestsRow
if err := rows.Scan(
&i.SkillID,
&i.ManifestVersion,
&i.Name,
&i.Description,
&i.ConfigSchema,
&i.ContentHash,
&i.FileCount,
&i.SizeBytes,
&i.Availability,
&i.AccessScope,
&i.OwnerActorID,
&i.CreatedByActorID,
&i.CreatedAt,
&i.SealedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const sealSkillManifest = `-- name: SealSkillManifest :exec
UPDATE skill_manifests
SET package_state='sealed',sealed_at=now()
WHERE manifest_id=$1 AND package_state='uploading'
`
func (q *Queries) SealSkillManifest(ctx context.Context, manifestID string) error {
_, err := q.db.Exec(ctx, sealSkillManifest, manifestID)
return err
}
const skillManifestVersionExists = `-- name: SkillManifestVersionExists :one
SELECT EXISTS(
SELECT 1 FROM skill_manifests
WHERE skill_id=$1 AND manifest_version=$2
)
`
type SkillManifestVersionExistsParams struct {
SkillID string `json:"skill_id"`
ManifestVersion string `json:"manifest_version"`
}
func (q *Queries) SkillManifestVersionExists(ctx context.Context, arg SkillManifestVersionExistsParams) (bool, error) {
row := q.db.QueryRow(ctx, skillManifestVersionExists, arg.SkillID, arg.ManifestVersion)
var exists bool
err := row.Scan(&exists)
return exists, err
}