@adhd/agent-store-prompts 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/drizzle/0000_third_nitro.sql +19 -0
- package/drizzle/0001_agents_and_taxonomy.sql +26 -0
- package/drizzle/0002_agent_components_junction.sql +13 -0
- package/drizzle/0003_usecase_context_rules.sql +31 -0
- package/drizzle/0004_composed_prompts.sql +10 -0
- package/drizzle/0005_warm_norman_osborn.sql +48 -0
- package/drizzle/0006_component_head_version_split.sql +78 -0
- package/drizzle/meta/0000_snapshot.json +137 -0
- package/drizzle/meta/0001_snapshot.json +302 -0
- package/drizzle/meta/0002_snapshot.json +381 -0
- package/drizzle/meta/0004_snapshot.json +594 -0
- package/drizzle/meta/0005_snapshot.json +594 -0
- package/drizzle/meta/0006_snapshot.json +672 -0
- package/drizzle/meta/_journal.json +55 -0
- package/package.json +51 -0
- package/src/db/client.d.ts +7 -0
- package/src/db/client.d.ts.map +1 -0
- package/src/db/client.js +24 -0
- package/src/db/client.js.map +1 -0
- package/src/db/migrate-runner.d.ts +31 -0
- package/src/db/migrate-runner.d.ts.map +1 -0
- package/src/db/migrate-runner.js +35 -0
- package/src/db/migrate-runner.js.map +1 -0
- package/src/db/migrate.d.ts +9 -0
- package/src/db/migrate.d.ts.map +1 -0
- package/src/db/migrate.js +13 -0
- package/src/db/migrate.js.map +1 -0
- package/src/db/schema.d.ts +997 -0
- package/src/db/schema.d.ts.map +1 -0
- package/src/db/schema.js +323 -0
- package/src/db/schema.js.map +1 -0
- package/src/index.d.ts +21 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +23 -0
- package/src/index.js.map +1 -0
- package/src/seed/components.d.ts +23 -0
- package/src/seed/components.d.ts.map +1 -0
- package/src/seed/components.js +399 -0
- package/src/seed/components.js.map +1 -0
- package/src/seed/index.d.ts +30 -0
- package/src/seed/index.d.ts.map +1 -0
- package/src/seed/index.js +95 -0
- package/src/seed/index.js.map +1 -0
- package/src/seed/prompt-types.d.ts +17 -0
- package/src/seed/prompt-types.d.ts.map +1 -0
- package/src/seed/prompt-types.js +107 -0
- package/src/seed/prompt-types.js.map +1 -0
- package/src/store/agent-store.d.ts +113 -0
- package/src/store/agent-store.d.ts.map +1 -0
- package/src/store/agent-store.js +211 -0
- package/src/store/agent-store.js.map +1 -0
- package/src/store/component-store.d.ts +87 -0
- package/src/store/component-store.d.ts.map +1 -0
- package/src/store/component-store.js +305 -0
- package/src/store/component-store.js.map +1 -0
- package/src/store/composed-prompt-store.d.ts +72 -0
- package/src/store/composed-prompt-store.d.ts.map +1 -0
- package/src/store/composed-prompt-store.js +147 -0
- package/src/store/composed-prompt-store.js.map +1 -0
- package/src/store/composition-store.d.ts +117 -0
- package/src/store/composition-store.d.ts.map +1 -0
- package/src/store/composition-store.js +270 -0
- package/src/store/composition-store.js.map +1 -0
- package/src/store/usecase-store.d.ts +104 -0
- package/src/store/usecase-store.d.ts.map +1 -0
- package/src/store/usecase-store.js +158 -0
- package/src/store/usecase-store.js.map +1 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* seed/prompt-types.ts
|
|
3
|
+
*
|
|
4
|
+
* Every system prompt type that ships with @adhd/agent-registry.
|
|
5
|
+
* These map 1:1 to rows in registry_prompt_types (is_system = true).
|
|
6
|
+
*
|
|
7
|
+
* Source: docs/plan/agent-registry/SEED_DATA.md §1
|
|
8
|
+
* [inv:lookup-not-enum] — types are rows, not SQL enums. Adding a new type
|
|
9
|
+
* is a seed operation, not a migration.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* All system prompt types for the registry.
|
|
13
|
+
* Array ordering is cosmetic — types are keyed by slug in the DB.
|
|
14
|
+
*/
|
|
15
|
+
export const PROMPT_TYPES = [
|
|
16
|
+
{
|
|
17
|
+
slug: 'role',
|
|
18
|
+
description: 'Fundamental agent identity — what the agent is',
|
|
19
|
+
isSystem: true,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
slug: 'identity',
|
|
23
|
+
description: 'Mission, refusal boundaries, communication style, learning posture',
|
|
24
|
+
isSystem: true,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
slug: 'capability',
|
|
28
|
+
description: 'Domain knowledge and specialization claims',
|
|
29
|
+
isSystem: true,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
slug: 'rule',
|
|
33
|
+
description: 'Hard invariants and constraints that must always apply',
|
|
34
|
+
isSystem: true,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
slug: 'style',
|
|
38
|
+
description: 'Tone, formatting conventions, output structure preferences',
|
|
39
|
+
isSystem: true,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
slug: 'personality',
|
|
43
|
+
description: 'Behavioral characteristics that persist across interaction types',
|
|
44
|
+
isSystem: true,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
slug: 'process',
|
|
48
|
+
description: 'Step-by-step workflow the agent follows when invoked',
|
|
49
|
+
isSystem: true,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
slug: 'invocation',
|
|
53
|
+
description: 'Activation card: trigger phrase, required inputs, expected outputs, deliverable',
|
|
54
|
+
isSystem: true,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
slug: 'success_criteria',
|
|
58
|
+
description: 'Typed criteria for evaluating agent output — gate-readable',
|
|
59
|
+
isSystem: true,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
slug: 'handoff',
|
|
63
|
+
description: 'Section template for inter-agent state transfer',
|
|
64
|
+
isSystem: true,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
slug: 'escalation',
|
|
68
|
+
description: 'Structured report template for escalation events',
|
|
69
|
+
isSystem: true,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
slug: 'posture',
|
|
73
|
+
description: 'Default verdict stance for reviewers (NEEDS-WORK vs. APPROVE)',
|
|
74
|
+
isSystem: true,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
slug: 'boundary',
|
|
78
|
+
description: 'Explicit declarations of what the agent will not do',
|
|
79
|
+
isSystem: true,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
slug: 'convergence',
|
|
83
|
+
description: 'N-agent synthesis pattern: fan-out → synthesizer → decision',
|
|
84
|
+
isSystem: true,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
slug: 'deliverable',
|
|
88
|
+
description: 'Concrete output format template with annotated example',
|
|
89
|
+
isSystem: true,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
slug: 'evidence',
|
|
93
|
+
description: 'Typed evidence fields required before a verdict is accepted',
|
|
94
|
+
isSystem: true,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
slug: 'context_pull',
|
|
98
|
+
description: 'Pull-loop pattern: claim ticket → read context → work → finish with handoff',
|
|
99
|
+
isSystem: true,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
slug: 'risk_posture',
|
|
103
|
+
description: 'Risk category awareness and escalation trigger conditions',
|
|
104
|
+
isSystem: true,
|
|
105
|
+
},
|
|
106
|
+
];
|
|
107
|
+
//# sourceMappingURL=prompt-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-types.js","sourceRoot":"","sources":["../../../../../../packages/agent/agent-store-prompts/src/seed/prompt-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAiB;IACxC;QACE,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,gDAAgD;QAC7D,QAAQ,EAAE,IAAI;KACf;IACD;QACE,IAAI,EAAE,UAAU;QAChB,WAAW,EACT,oEAAoE;QACtE,QAAQ,EAAE,IAAI;KACf;IACD;QACE,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,4CAA4C;QACzD,QAAQ,EAAE,IAAI;KACf;IACD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E,QAAQ,EAAE,IAAI;KACf;CACF,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
|
|
2
|
+
export declare class AgentError extends Error {
|
|
3
|
+
readonly code: 'AGENT_NOT_FOUND' | 'CATEGORY_NOT_FOUND';
|
|
4
|
+
constructor(code: 'AGENT_NOT_FOUND' | 'CATEGORY_NOT_FOUND', message: string);
|
|
5
|
+
}
|
|
6
|
+
/** Agent status values. Plain text — not a SQL enum. [inv:lookup-not-enum] */
|
|
7
|
+
export type AgentStatus = 'draft' | 'active' | 'deprecated';
|
|
8
|
+
/** Default posture for human-in-the-loop decisions. */
|
|
9
|
+
export type AgentPosture = 'approve' | 'needs_work';
|
|
10
|
+
export interface TaxonomyCategory {
|
|
11
|
+
slug: string;
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
/** Integer ordering key, replaces the `01-`/`02-` directory-prefix convention. */
|
|
15
|
+
position: number;
|
|
16
|
+
/** Nullable parent slug for subcategory nesting. */
|
|
17
|
+
parentSlug: string | null;
|
|
18
|
+
}
|
|
19
|
+
export interface TaxonomyCategoryCreateInput {
|
|
20
|
+
slug: string;
|
|
21
|
+
name: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
position?: number;
|
|
24
|
+
parentSlug?: string | null;
|
|
25
|
+
}
|
|
26
|
+
export interface Agent {
|
|
27
|
+
slug: string;
|
|
28
|
+
displayName: string;
|
|
29
|
+
description: string;
|
|
30
|
+
/** 'draft' | 'active' | 'deprecated' */
|
|
31
|
+
status: AgentStatus;
|
|
32
|
+
/**
|
|
33
|
+
* Canonical model id — a string, NOT an FK.
|
|
34
|
+
* Resolved at compile time by @adhd/agent-provider (Decision 1: no cross-package FK).
|
|
35
|
+
*/
|
|
36
|
+
modelHint: string | null;
|
|
37
|
+
/** In-package FK → registry_taxonomy_categories.slug (nullable). */
|
|
38
|
+
taxonomyCategory: string | null;
|
|
39
|
+
/** 'approve' | 'needs_work' */
|
|
40
|
+
defaultPosture: AgentPosture;
|
|
41
|
+
createdAt: string;
|
|
42
|
+
updatedAt: string;
|
|
43
|
+
}
|
|
44
|
+
export interface AgentCreateInput {
|
|
45
|
+
slug: string;
|
|
46
|
+
displayName: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
status?: AgentStatus;
|
|
49
|
+
modelHint?: string | null;
|
|
50
|
+
taxonomyCategory?: string | null;
|
|
51
|
+
defaultPosture?: AgentPosture;
|
|
52
|
+
}
|
|
53
|
+
export interface AgentUpdateInput {
|
|
54
|
+
displayName?: string;
|
|
55
|
+
description?: string;
|
|
56
|
+
status?: AgentStatus;
|
|
57
|
+
modelHint?: string | null;
|
|
58
|
+
taxonomyCategory?: string | null;
|
|
59
|
+
defaultPosture?: AgentPosture;
|
|
60
|
+
}
|
|
61
|
+
export interface AgentListFilter {
|
|
62
|
+
/** Filter to agents in this taxonomy category slug. */
|
|
63
|
+
category?: string;
|
|
64
|
+
/** Filter to agents with this status. */
|
|
65
|
+
status?: AgentStatus;
|
|
66
|
+
}
|
|
67
|
+
export declare class TaxonomyStore {
|
|
68
|
+
private readonly db;
|
|
69
|
+
constructor(db: BetterSQLite3Database<any>);
|
|
70
|
+
/**
|
|
71
|
+
* Insert a new taxonomy category.
|
|
72
|
+
* Throws if the slug already exists (use the returned row for idempotent seeding).
|
|
73
|
+
*/
|
|
74
|
+
createCategory(input: TaxonomyCategoryCreateInput): TaxonomyCategory;
|
|
75
|
+
/**
|
|
76
|
+
* List all categories ordered by position ASC, then slug ASC for stability.
|
|
77
|
+
* This ordering replaces the `01-`/`02-` directory-prefix convention.
|
|
78
|
+
*/
|
|
79
|
+
listCategories(): TaxonomyCategory[];
|
|
80
|
+
}
|
|
81
|
+
export declare class AgentStore {
|
|
82
|
+
private readonly db;
|
|
83
|
+
constructor(db: BetterSQLite3Database<any>);
|
|
84
|
+
/**
|
|
85
|
+
* Create a new agent metadata row.
|
|
86
|
+
* Does not associate prompt components — that is handled by the
|
|
87
|
+
* composition-junction state.
|
|
88
|
+
*/
|
|
89
|
+
create(input: AgentCreateInput): Agent;
|
|
90
|
+
/**
|
|
91
|
+
* Read an agent by slug.
|
|
92
|
+
* Throws AGENT_NOT_FOUND if the slug does not exist.
|
|
93
|
+
*/
|
|
94
|
+
read(slug: string): Agent;
|
|
95
|
+
/**
|
|
96
|
+
* Update mutable fields of an agent by slug.
|
|
97
|
+
* Throws AGENT_NOT_FOUND if the slug does not exist.
|
|
98
|
+
* Returns the updated agent.
|
|
99
|
+
*/
|
|
100
|
+
update(slug: string, input: AgentUpdateInput): Agent;
|
|
101
|
+
/**
|
|
102
|
+
* Delete an agent by slug.
|
|
103
|
+
* Throws AGENT_NOT_FOUND if the slug does not exist.
|
|
104
|
+
*/
|
|
105
|
+
delete(slug: string): void;
|
|
106
|
+
/**
|
|
107
|
+
* List agents, optionally filtered by category and/or status.
|
|
108
|
+
* Results are ordered by slug ASC for stable output.
|
|
109
|
+
*/
|
|
110
|
+
list(filter?: AgentListFilter): Agent[];
|
|
111
|
+
private _rowToAgent;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=agent-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-store.d.ts","sourceRoot":"","sources":["../../../../../../packages/agent/agent-store-prompts/src/store/agent-store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAQxE,qBAAa,UAAW,SAAQ,KAAK;aAEjB,IAAI,EAAE,iBAAiB,GAAG,oBAAoB;gBAA9C,IAAI,EAAE,iBAAiB,GAAG,oBAAoB,EAC9D,OAAO,EAAE,MAAM;CAKlB;AAMD,8EAA8E;AAC9E,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,YAAY,CAAC;AAE5D,uDAAuD;AACvD,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,YAAY,CAAC;AAEpD,MAAM,W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WAAW,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,cAAc,CAAC,EAAE,YAAY,CAAC;CAC/B;AAED,MAAM,WAAW,eAAe;IAC9B,uDAAuD;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAUD,qBAAa,aAAa;IAGtB,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,qBAAqB,CAAC,GAAG,CAAC;IAGjD;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,2BAA2B,GAAG,gBAAgB;IAuBpE;;;OAGG;IACH,cAAc,IAAI,gBAAgB,EAAE;CAkBrC;AASD,qBAAa,UAAU;IAGnB,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,qBAAqB,CAAC,GAAG,CAAC;IAGjD;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK;IAgCtC;;;OAGG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK;IAczB;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG,KAAK;IA+BpD;;;OAGG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAM1B;;;OAGG;IACH,IAAI,CAAC,MAAM,GAAE,eAAoB,GAAG,KAAK,EAAE;IA2B3C,OAAO,CAAC,WAAW;CAuBpB"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { asc, eq, and } from 'drizzle-orm';
|
|
2
|
+
import { agentsTable, taxonomyCategoriesTable } from '../db/schema.js';
|
|
3
|
+
// ──────────────────────────────────────────────
|
|
4
|
+
// Error codes
|
|
5
|
+
// ──────────────────────────────────────────────
|
|
6
|
+
export class AgentError extends Error {
|
|
7
|
+
code;
|
|
8
|
+
constructor(code, message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.name = 'AgentError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
// ──────────────────────────────────────────────
|
|
15
|
+
// TaxonomyStore
|
|
16
|
+
//
|
|
17
|
+
// Thin Drizzle wrapper for registry_taxonomy_categories.
|
|
18
|
+
// Mirrors the store-class pattern in entrypoint/agent-mcp's AgentStore (agent-cache-store pattern)
|
|
19
|
+
// [ref:store-class] (contexts/_shared.md)
|
|
20
|
+
// ──────────────────────────────────────────────
|
|
21
|
+
export class TaxonomyStore {
|
|
22
|
+
db;
|
|
23
|
+
constructor(
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
+
db) {
|
|
26
|
+
this.db = db;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Insert a new taxonomy category.
|
|
30
|
+
* Throws if the slug already exists (use the returned row for idempotent seeding).
|
|
31
|
+
*/
|
|
32
|
+
createCategory(input) {
|
|
33
|
+
const row = {
|
|
34
|
+
slug: input.slug,
|
|
35
|
+
name: input.name,
|
|
36
|
+
description: input.description ?? '',
|
|
37
|
+
position: input.position ?? 0,
|
|
38
|
+
parentSlug: input.parentSlug ?? null,
|
|
39
|
+
};
|
|
40
|
+
this.db
|
|
41
|
+
.insert(taxonomyCategoriesTable)
|
|
42
|
+
.values({
|
|
43
|
+
slug: row.slug,
|
|
44
|
+
name: row.name,
|
|
45
|
+
description: row.description,
|
|
46
|
+
position: row.position,
|
|
47
|
+
parentSlug: row.parentSlug,
|
|
48
|
+
})
|
|
49
|
+
.run();
|
|
50
|
+
return row;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* List all categories ordered by position ASC, then slug ASC for stability.
|
|
54
|
+
* This ordering replaces the `01-`/`02-` directory-prefix convention.
|
|
55
|
+
*/
|
|
56
|
+
listCategories() {
|
|
57
|
+
const rows = this.db
|
|
58
|
+
.select()
|
|
59
|
+
.from(taxonomyCategoriesTable)
|
|
60
|
+
.orderBy(asc(taxonomyCategoriesTable.position), asc(taxonomyCategoriesTable.slug))
|
|
61
|
+
.all();
|
|
62
|
+
return rows.map((r) => ({
|
|
63
|
+
slug: r.slug,
|
|
64
|
+
name: r.name,
|
|
65
|
+
description: r.description,
|
|
66
|
+
position: r.position,
|
|
67
|
+
parentSlug: r.parentSlug ?? null,
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// ──────────────────────────────────────────────
|
|
72
|
+
// AgentStore
|
|
73
|
+
//
|
|
74
|
+
// Thin Drizzle wrapper for registry_agents.
|
|
75
|
+
// [ref:store-class] (contexts/_shared.md)
|
|
76
|
+
// ──────────────────────────────────────────────
|
|
77
|
+
export class AgentStore {
|
|
78
|
+
db;
|
|
79
|
+
constructor(
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
+
db) {
|
|
82
|
+
this.db = db;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Create a new agent metadata row.
|
|
86
|
+
* Does not associate prompt components — that is handled by the
|
|
87
|
+
* composition-junction state.
|
|
88
|
+
*/
|
|
89
|
+
create(input) {
|
|
90
|
+
const now = new Date().toISOString();
|
|
91
|
+
const row = {
|
|
92
|
+
slug: input.slug,
|
|
93
|
+
displayName: input.displayName,
|
|
94
|
+
description: input.description ?? '',
|
|
95
|
+
status: input.status ?? 'draft',
|
|
96
|
+
modelHint: input.modelHint ?? null,
|
|
97
|
+
taxonomyCategory: input.taxonomyCategory ?? null,
|
|
98
|
+
defaultPosture: input.defaultPosture ?? 'needs_work',
|
|
99
|
+
createdAt: now,
|
|
100
|
+
updatedAt: now,
|
|
101
|
+
};
|
|
102
|
+
this.db
|
|
103
|
+
.insert(agentsTable)
|
|
104
|
+
.values({
|
|
105
|
+
slug: row.slug,
|
|
106
|
+
displayName: row.displayName,
|
|
107
|
+
description: row.description,
|
|
108
|
+
status: row.status,
|
|
109
|
+
modelHint: row.modelHint,
|
|
110
|
+
taxonomyCategory: row.taxonomyCategory,
|
|
111
|
+
defaultPosture: row.defaultPosture,
|
|
112
|
+
createdAt: row.createdAt,
|
|
113
|
+
updatedAt: row.updatedAt,
|
|
114
|
+
})
|
|
115
|
+
.run();
|
|
116
|
+
return row;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Read an agent by slug.
|
|
120
|
+
* Throws AGENT_NOT_FOUND if the slug does not exist.
|
|
121
|
+
*/
|
|
122
|
+
read(slug) {
|
|
123
|
+
const row = this.db
|
|
124
|
+
.select()
|
|
125
|
+
.from(agentsTable)
|
|
126
|
+
.where(eq(agentsTable.slug, slug))
|
|
127
|
+
.get();
|
|
128
|
+
if (!row) {
|
|
129
|
+
throw new AgentError('AGENT_NOT_FOUND', `Agent '${slug}' not found`);
|
|
130
|
+
}
|
|
131
|
+
return this._rowToAgent(row);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Update mutable fields of an agent by slug.
|
|
135
|
+
* Throws AGENT_NOT_FOUND if the slug does not exist.
|
|
136
|
+
* Returns the updated agent.
|
|
137
|
+
*/
|
|
138
|
+
update(slug, input) {
|
|
139
|
+
// Verify existence first
|
|
140
|
+
this.read(slug); // throws AGENT_NOT_FOUND if missing
|
|
141
|
+
const now = new Date().toISOString();
|
|
142
|
+
this.db
|
|
143
|
+
.update(agentsTable)
|
|
144
|
+
.set({
|
|
145
|
+
...(input.displayName !== undefined && {
|
|
146
|
+
displayName: input.displayName,
|
|
147
|
+
}),
|
|
148
|
+
...(input.description !== undefined && {
|
|
149
|
+
description: input.description,
|
|
150
|
+
}),
|
|
151
|
+
...(input.status !== undefined && { status: input.status }),
|
|
152
|
+
...(input.modelHint !== undefined && { modelHint: input.modelHint }),
|
|
153
|
+
...(input.taxonomyCategory !== undefined && {
|
|
154
|
+
taxonomyCategory: input.taxonomyCategory,
|
|
155
|
+
}),
|
|
156
|
+
...(input.defaultPosture !== undefined && {
|
|
157
|
+
defaultPosture: input.defaultPosture,
|
|
158
|
+
}),
|
|
159
|
+
updatedAt: now,
|
|
160
|
+
})
|
|
161
|
+
.where(eq(agentsTable.slug, slug))
|
|
162
|
+
.run();
|
|
163
|
+
return this.read(slug);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Delete an agent by slug.
|
|
167
|
+
* Throws AGENT_NOT_FOUND if the slug does not exist.
|
|
168
|
+
*/
|
|
169
|
+
delete(slug) {
|
|
170
|
+
this.read(slug); // throws AGENT_NOT_FOUND if missing
|
|
171
|
+
this.db.delete(agentsTable).where(eq(agentsTable.slug, slug)).run();
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* List agents, optionally filtered by category and/or status.
|
|
175
|
+
* Results are ordered by slug ASC for stable output.
|
|
176
|
+
*/
|
|
177
|
+
list(filter = {}) {
|
|
178
|
+
const conditions = [];
|
|
179
|
+
if (filter.category !== undefined) {
|
|
180
|
+
conditions.push(eq(agentsTable.taxonomyCategory, filter.category));
|
|
181
|
+
}
|
|
182
|
+
if (filter.status !== undefined) {
|
|
183
|
+
conditions.push(eq(agentsTable.status, filter.status));
|
|
184
|
+
}
|
|
185
|
+
let query = this.db
|
|
186
|
+
.select()
|
|
187
|
+
.from(agentsTable)
|
|
188
|
+
.orderBy(asc(agentsTable.slug));
|
|
189
|
+
if (conditions.length > 0) {
|
|
190
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
191
|
+
query = query.where(and(...conditions));
|
|
192
|
+
}
|
|
193
|
+
const rows = query.all();
|
|
194
|
+
return rows.map((r) => this._rowToAgent(r));
|
|
195
|
+
}
|
|
196
|
+
// ── Private helpers ───────────────────────
|
|
197
|
+
_rowToAgent(row) {
|
|
198
|
+
return {
|
|
199
|
+
slug: row.slug,
|
|
200
|
+
displayName: row.displayName,
|
|
201
|
+
description: row.description,
|
|
202
|
+
status: row.status,
|
|
203
|
+
modelHint: row.modelHint ?? null,
|
|
204
|
+
taxonomyCategory: row.taxonomyCategory ?? null,
|
|
205
|
+
defaultPosture: row.defaultPosture,
|
|
206
|
+
createdAt: row.createdAt,
|
|
207
|
+
updatedAt: row.updatedAt,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
//# sourceMappingURL=agent-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-store.js","sourceRoot":"","sources":["../../../../../../packages/agent/agent-store-prompts/src/store/agent-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAI3C,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAEvE,iDAAiD;AACjD,cAAc;AACd,iDAAiD;AAEjD,MAAM,OAAO,UAAW,SAAQ,KAAK;IAEjB;IADlB,YACkB,IAA8C,EAC9D,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAA0C;QAI9D,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AA2ED,iDAAiD;AACjD,gBAAgB;AAChB,EAAE;AACF,yDAAyD;AACzD,mGAAmG;AACnG,0CAA0C;AAC1C,iDAAiD;AAEjD,MAAM,OAAO,aAAa;IAGL;IAFnB;IACE,8DAA8D;IAC7C,EAA8B;QAA9B,OAAE,GAAF,EAAE,CAA4B;IAC9C,CAAC;IAEJ;;;OAGG;IACH,cAAc,CAAC,KAAkC;QAC/C,MAAM,GAAG,GAAqB;YAC5B,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,EAAE;YACpC,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,CAAC;YAC7B,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,IAAI;SACrC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AqB;YACjC,SAAS,EAAE,GAAG,CAAC,SAAS,IAAI,IAAI;YAChC,gBAAgB,EAAE,GAAG,CAAC,gBAAgB,IAAI,IAAI;YAC9C,cAAc,EAAE,GAAG,CAAC,cAA8B;YAClD,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,SAAS,EAAE,GAAG,CAAC,SAAS;SACzB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
|
|
2
|
+
export declare class ComponentError extends Error {
|
|
3
|
+
readonly code: 'COMPONENT_NOT_FOUND' | 'COMPONENT_TYPE_NOT_FOUND' | 'COMPONENT_VERSION_NOT_FOUND';
|
|
4
|
+
constructor(code: 'COMPONENT_NOT_FOUND' | 'COMPONENT_TYPE_NOT_FOUND' | 'COMPONENT_VERSION_NOT_FOUND', message: string);
|
|
5
|
+
}
|
|
6
|
+
export interface PromptType {
|
|
7
|
+
slug: string;
|
|
8
|
+
description: string;
|
|
9
|
+
isSystem: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface PromptComponent {
|
|
12
|
+
slug: string;
|
|
13
|
+
type: string;
|
|
14
|
+
version: number;
|
|
15
|
+
/**
|
|
16
|
+
* The registry_component_versions.version_id surrogate for THIS version row.
|
|
17
|
+
* Stable, single-column — this is what a junction `version_pin` stores when an
|
|
18
|
+
* exact version is pinned (Decision 5). Resolve a `(slug, version)` pair to it
|
|
19
|
+
* with {@link ComponentStore.resolveVersionId}.
|
|
20
|
+
*/
|
|
21
|
+
versionId: number;
|
|
22
|
+
content: string;
|
|
23
|
+
isShared: boolean;
|
|
24
|
+
createdAt: string;
|
|
25
|
+
updatedAt: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ComponentCreateInput {
|
|
28
|
+
slug: string;
|
|
29
|
+
type: string;
|
|
30
|
+
content: string;
|
|
31
|
+
isShared?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface ComponentListFilter {
|
|
34
|
+
type?: string;
|
|
35
|
+
shared?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare class ComponentStore {
|
|
38
|
+
private readonly db;
|
|
39
|
+
constructor(db: BetterSQLite3Database<any>);
|
|
40
|
+
/** Insert a prompt type. No-op if the slug already exists. */
|
|
41
|
+
upsertType(input: PromptType): PromptType;
|
|
42
|
+
/** Read a prompt type by slug. Throws COMPONENT_TYPE_NOT_FOUND if absent. */
|
|
43
|
+
readType(slug: string): PromptType;
|
|
44
|
+
/**
|
|
45
|
+
* Create a new component: insert the head identity row plus its version-1
|
|
46
|
+
* history row, in ONE transaction (Decision 5).
|
|
47
|
+
*
|
|
48
|
+
* [inv:version-retained]: each later call to version() appends a NEW version
|
|
49
|
+
* row at version+1; it never overwrites a prior version.
|
|
50
|
+
*/
|
|
51
|
+
create(input: ComponentCreateInput): PromptComponent;
|
|
52
|
+
/**
|
|
53
|
+
* Read the latest version of a component by slug (head joined to its highest
|
|
54
|
+
* version row).
|
|
55
|
+
* Throws COMPONENT_NOT_FOUND if no head row exists for the slug.
|
|
56
|
+
*/
|
|
57
|
+
read(slug: string): PromptComponent;
|
|
58
|
+
/**
|
|
59
|
+
* Read a specific version of a component.
|
|
60
|
+
* Throws COMPONENT_VERSION_NOT_FOUND if that exact (slug, version) row is absent,
|
|
61
|
+
* or COMPONENT_NOT_FOUND if the head identity row is absent.
|
|
62
|
+
*/
|
|
63
|
+
readVersion(slug: string, version: number): PromptComponent;
|
|
64
|
+
/**
|
|
65
|
+
* Resolve a `(slug, version)` pair to its stable registry_component_versions
|
|
66
|
+
* .version_id surrogate — the value a junction `version_pin` stores when an
|
|
67
|
+
* exact version is pinned (Decision 5).
|
|
68
|
+
*
|
|
69
|
+
* Throws COMPONENT_VERSION_NOT_FOUND if that exact version row is absent.
|
|
70
|
+
*/
|
|
71
|
+
resolveVersionId(slug: string, version: number): number;
|
|
72
|
+
/**
|
|
73
|
+
* Bump a component to a new version with updated content.
|
|
74
|
+
* Appends a NEW version row at max(existing version) + 1 for the slug — the head
|
|
75
|
+
* identity row is unchanged and old version rows are NEVER deleted.
|
|
76
|
+
* [inv:version-retained]
|
|
77
|
+
*/
|
|
78
|
+
version(slug: string, newContent: string): PromptComponent;
|
|
79
|
+
/**
|
|
80
|
+
* List the latest version of each component, optionally filtered by type
|
|
81
|
+
* and/or shared flag. Joins each head to its highest version row.
|
|
82
|
+
*/
|
|
83
|
+
list(filter?: ComponentListFilter): PromptComponent[];
|
|
84
|
+
/** Join a head identity row to one version row into a PromptComponent. */
|
|
85
|
+
private _join;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=component-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-store.d.ts","sourceRoot":"","sources":["../../../../../../packages/agent/agent-store-prompts/src/store/component-store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAYxE,qBAAa,cAAe,SAAQ,KAAK;aAErB,IAAI,EAChB,qBAAqB,GACrB,0BAA0B,GAC1B,6BAA6B;gBAHjB,IAAI,EAChB,qBAAqB,GACrB,0BAA0B,GAC1B,6BAA6B,EACjC,OAAO,EAAE,MAAM;CAKlB;AAMD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;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