@adhd/agent-store-tools 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.
Files changed (66) hide show
  1. package/drizzle/0000_dry_roulette.sql +18 -0
  2. package/drizzle/0001_gray_talkback.sql +20 -0
  3. package/drizzle/0002_aberrant_blink.sql +7 -0
  4. package/drizzle/0003_foamy_otto_octavius.sql +10 -0
  5. package/drizzle/meta/0000_snapshot.json +129 -0
  6. package/drizzle/meta/0001_snapshot.json +251 -0
  7. package/drizzle/meta/0002_snapshot.json +298 -0
  8. package/drizzle/meta/0003_snapshot.json +358 -0
  9. package/drizzle/meta/_journal.json +34 -0
  10. package/package.json +50 -0
  11. package/src/db/client.d.ts +7 -0
  12. package/src/db/client.d.ts.map +1 -0
  13. package/src/db/client.js +18 -0
  14. package/src/db/client.js.map +1 -0
  15. package/src/db/migrate-runner.d.ts +30 -0
  16. package/src/db/migrate-runner.d.ts.map +1 -0
  17. package/src/db/migrate-runner.js +34 -0
  18. package/src/db/migrate-runner.js.map +1 -0
  19. package/src/db/migrate.d.ts +9 -0
  20. package/src/db/migrate.d.ts.map +1 -0
  21. package/src/db/migrate.js +13 -0
  22. package/src/db/migrate.js.map +1 -0
  23. package/src/db/schema.d.ts +584 -0
  24. package/src/db/schema.d.ts.map +1 -0
  25. package/src/db/schema.js +150 -0
  26. package/src/db/schema.js.map +1 -0
  27. package/src/index.d.ts +13 -0
  28. package/src/index.d.ts.map +1 -0
  29. package/src/index.js +11 -0
  30. package/src/index.js.map +1 -0
  31. package/src/seed/bindings.d.ts +21 -0
  32. package/src/seed/bindings.d.ts.map +1 -0
  33. package/src/seed/bindings.js +167 -0
  34. package/src/seed/bindings.js.map +1 -0
  35. package/src/seed/index.d.ts +29 -0
  36. package/src/seed/index.d.ts.map +1 -0
  37. package/src/seed/index.js +80 -0
  38. package/src/seed/index.js.map +1 -0
  39. package/src/seed/platforms.d.ts +17 -0
  40. package/src/seed/platforms.d.ts.map +1 -0
  41. package/src/seed/platforms.js +48 -0
  42. package/src/seed/platforms.js.map +1 -0
  43. package/src/seed/tool-types.d.ts +15 -0
  44. package/src/seed/tool-types.d.ts.map +1 -0
  45. package/src/seed/tool-types.js +35 -0
  46. package/src/seed/tool-types.js.map +1 -0
  47. package/src/seed/tools.d.ts +18 -0
  48. package/src/seed/tools.d.ts.map +1 -0
  49. package/src/seed/tools.js +117 -0
  50. package/src/seed/tools.js.map +1 -0
  51. package/src/store/agent-tool-store.d.ts +63 -0
  52. package/src/store/agent-tool-store.d.ts.map +1 -0
  53. package/src/store/agent-tool-store.js +100 -0
  54. package/src/store/agent-tool-store.js.map +1 -0
  55. package/src/store/binding-store.d.ts +75 -0
  56. package/src/store/binding-store.d.ts.map +1 -0
  57. package/src/store/binding-store.js +144 -0
  58. package/src/store/binding-store.js.map +1 -0
  59. package/src/store/mcp-server-store.d.ts +46 -0
  60. package/src/store/mcp-server-store.d.ts.map +1 -0
  61. package/src/store/mcp-server-store.js +89 -0
  62. package/src/store/mcp-server-store.js.map +1 -0
  63. package/src/store/tool-store.d.ts +55 -0
  64. package/src/store/tool-store.d.ts.map +1 -0
  65. package/src/store/tool-store.js +115 -0
  66. package/src/store/tool-store.js.map +1 -0
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Canonical tool seed data.
3
+ *
4
+ * Source of truth: docs/plan/agent-registry/SEED_DATA.md §6 — Tool Registry table.
5
+ *
6
+ * Each row is a canonical, platform-independent agent capability.
7
+ * The type FK references tool_types.slug — all types must be seeded first.
8
+ */
9
+ export interface ToolSeedRow {
10
+ name: string;
11
+ type: string;
12
+ description: string;
13
+ requiresApproval: boolean;
14
+ isDestructive: boolean;
15
+ }
16
+ /** All 15 canonical tools shipped with the registry. */
17
+ export declare const TOOL_SEEDS: ToolSeedRow[];
18
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../../../../packages/agent/agent-store-tools/src/seed/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,wDAAwD;AACxD,eAAO,MAAM,UAAU,EAAE,WAAW,EA0GnC,CAAC"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Canonical tool seed data.
3
+ *
4
+ * Source of truth: docs/plan/agent-registry/SEED_DATA.md §6 — Tool Registry table.
5
+ *
6
+ * Each row is a canonical, platform-independent agent capability.
7
+ * The type FK references tool_types.slug — all types must be seeded first.
8
+ */
9
+ /** All 15 canonical tools shipped with the registry. */
10
+ export const TOOL_SEEDS = [
11
+ {
12
+ name: 'file_read',
13
+ type: 'io',
14
+ description: 'Read file contents from the filesystem',
15
+ requiresApproval: false,
16
+ isDestructive: false,
17
+ },
18
+ {
19
+ name: 'file_write',
20
+ type: 'io',
21
+ description: 'Write or overwrite a file',
22
+ requiresApproval: false,
23
+ isDestructive: true,
24
+ },
25
+ {
26
+ name: 'file_edit',
27
+ type: 'io',
28
+ description: 'Apply targeted string replacements to a file',
29
+ requiresApproval: false,
30
+ isDestructive: true,
31
+ },
32
+ {
33
+ name: 'file_glob',
34
+ type: 'io',
35
+ description: 'Find files matching a glob pattern',
36
+ requiresApproval: false,
37
+ isDestructive: false,
38
+ },
39
+ {
40
+ name: 'file_grep',
41
+ type: 'io',
42
+ description: 'Search file contents with regex',
43
+ requiresApproval: false,
44
+ isDestructive: false,
45
+ },
46
+ {
47
+ name: 'shell_exec',
48
+ type: 'compute',
49
+ description: 'Execute a shell command',
50
+ requiresApproval: true,
51
+ isDestructive: true,
52
+ },
53
+ {
54
+ name: 'web_fetch',
55
+ type: 'network',
56
+ description: 'Fetch content from a URL',
57
+ requiresApproval: false,
58
+ isDestructive: false,
59
+ },
60
+ {
61
+ name: 'web_search',
62
+ type: 'network',
63
+ description: 'Run a web search query',
64
+ requiresApproval: false,
65
+ isDestructive: false,
66
+ },
67
+ {
68
+ name: 'mcp_list_resources',
69
+ type: 'memory',
70
+ description: 'List available MCP server resources',
71
+ requiresApproval: false,
72
+ isDestructive: false,
73
+ },
74
+ {
75
+ name: 'mcp_read_resource',
76
+ type: 'memory',
77
+ description: 'Read a specific MCP resource by URI',
78
+ requiresApproval: false,
79
+ isDestructive: false,
80
+ },
81
+ {
82
+ name: 'mcp_wait',
83
+ type: 'meta',
84
+ description: 'Block until MCP servers are ready',
85
+ requiresApproval: false,
86
+ isDestructive: false,
87
+ },
88
+ {
89
+ name: 'human_input',
90
+ type: 'ui',
91
+ description: 'Request input from the human operator',
92
+ requiresApproval: false,
93
+ isDestructive: false,
94
+ },
95
+ {
96
+ name: 'process_monitor',
97
+ type: 'compute',
98
+ description: 'Monitor a background process for output',
99
+ requiresApproval: false,
100
+ isDestructive: false,
101
+ },
102
+ {
103
+ name: 'code_analysis',
104
+ type: 'lsp',
105
+ description: 'LSP diagnostics, definitions, hover info',
106
+ requiresApproval: false,
107
+ isDestructive: false,
108
+ },
109
+ {
110
+ name: 'notebook_edit',
111
+ type: 'notebook',
112
+ description: 'Edit a Jupyter notebook cell',
113
+ requiresApproval: false,
114
+ isDestructive: true,
115
+ },
116
+ ];
117
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../../../../packages/agent/agent-store-tools/src/seed/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH,wDAAwD;AACxD,MAAM,CAAC,MAAM,UAAU,GAAkB;IACvC;QACE,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,IAAI;QACV,WAAW,EAAE,wCAAwC;QACrD,gBAAgB,EAAE,KAAK;QACvB,aAAa,EAAE,KAAK;KACrB;IACD;QACE,IAAI,EAAE,YAAY;QAClB,IA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,WAAW,EAAE,mCAAmC;QAChD,gBAAgB,EAAE,KAAK;QACvB,aAAa,EAAE,KAAK;KACrB;IACD;QACE,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,IAAI;QACV,WAAW,EAAE,uCAAuC;QACpD,gBAAgB,EAAE,KAAK;QACvB,aAAa,EAAE,KAAK;KACrB;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,yCAAyC;QACtD,gBAAgB,EAAE,KAAK;QACvB,aAAa,EAAE,KAAK;KACrB;IACD;QACE,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,0CAA0C;QACvD,gBAAgB,EAAE,KAAK;QACvB,aAAa,EAAE,KAAK;KACrB;IACD;QACE,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,8BAA8B;QAC3C,gBAAgB,EAAE,KAAK;QACvB,aAAa,EAAE,IAAI;KACpB;CACF,CAAC"}
@@ -0,0 +1,63 @@
1
+ import type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
2
+ /**
3
+ * The permission level granted to an agent for a canonical tool.
4
+ *
5
+ * Plain text value — NOT a SQL enum ([inv:lookup-not-enum]).
6
+ * Allowed values: full | read_only | restricted.
7
+ */
8
+ export type PermissionLevel = 'full' | 'read_only' | 'restricted';
9
+ /**
10
+ * One agent_tools junction row: an agent_slug granted access to a tool_name
11
+ * at a typed permission level, with an optional context_condition.
12
+ *
13
+ * agent_slug is a LOGICAL key into agent-registry's `agents` table — it is
14
+ * NOT a SQLite FK ([inv:no-cross-pkg-fk]). The linkage is resolved at compile
15
+ * time by @adhd/agent-engine-compiler. Accepts any string slug, even one with no
16
+ * matching row in the agents table (there is no such table in this package).
17
+ */
18
+ export interface AgentToolGrant {
19
+ agentSlug: string;
20
+ toolName: string;
21
+ permission: PermissionLevel;
22
+ /** null means the grant always applies. */
23
+ contextCondition: Record<string, unknown> | null;
24
+ }
25
+ /** Input for granting a tool to an agent. */
26
+ export interface AgentToolGrantInput {
27
+ agentSlug: string;
28
+ toolName: string;
29
+ permission: PermissionLevel;
30
+ /** Omit or pass null to mean "always applies". */
31
+ contextCondition?: Record<string, unknown> | null;
32
+ }
33
+ export type AgentToolStoreErrorCode = 'GRANT_ALREADY_EXISTS' | 'GRANT_NOT_FOUND';
34
+ export declare class AgentToolStoreError extends Error {
35
+ readonly code: AgentToolStoreErrorCode;
36
+ constructor(code: AgentToolStoreErrorCode, message: string);
37
+ }
38
+ export declare class AgentToolStore {
39
+ private readonly db;
40
+ constructor(db: BetterSQLite3Database<Record<string, never>>);
41
+ /**
42
+ * Grant a canonical tool to an agent at a typed permission level.
43
+ *
44
+ * agent_slug is a LOGICAL reference — no FK check is performed against any
45
+ * agents table ([inv:no-cross-pkg-fk]). Any string is accepted.
46
+ *
47
+ * Throws GRANT_ALREADY_EXISTS if the (agent_slug, tool_name) pair exists.
48
+ */
49
+ grant(input: AgentToolGrantInput): AgentToolGrant;
50
+ /**
51
+ * Return all grants for a given agent slug.
52
+ *
53
+ * Returns an empty array if no grants exist (or if the slug has never
54
+ * been granted any tool — agent_slug carries no FK constraint).
55
+ */
56
+ listForAgent(agentSlug: string): AgentToolGrant[];
57
+ /**
58
+ * Revoke a tool grant from an agent.
59
+ * Throws GRANT_NOT_FOUND if the (agent_slug, tool_name) pair does not exist.
60
+ */
61
+ revoke(agentSlug: string, toolName: string): void;
62
+ }
63
+ //# sourceMappingURL=agent-tool-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-tool-store.d.ts","sourceRoot":"","sources":["../../../../../../packages/agent/agent-store-tools/src/store/agent-tool-store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAQxE;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,WAAW,GAAG,YAAY,CAAC;AAElE;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,eAAe,CAAC;IAC5B,2CAA2C;IAC3C,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAClD;AAED,6CAA6C;AAC7C,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,eAAe,CAAC;IAC5B,kDAAkD;IAClD,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACnD;AAMD,MAAM,MAAM,uBAAuB,GAC/B,sBAAsB,GACtB,iBAAiB,CAAC;AAEtB,qBAAa,mBAAoB,SAAQ,KAAK;aAChB,IAAI,EAAE,uBAAuB;gBAA7B,IAAI,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM;CAI3E;AAcD,qBAAa,cAAc;IAEvB,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,qBAAqB,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAGnE;;;;;;;OAOG;IACH,KAAK,CAAC,KAAK,EAAE,mBAAmB,GAAG,cAAc;IAwCjD;;;;;OAKG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,EAAE;IAejD;;;OAGG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;CA6BlD"}
@@ -0,0 +1,100 @@
1
+ import { and, eq } from 'drizzle-orm';
2
+ import { agentToolsTable } from '../db/schema.js';
3
+ export class AgentToolStoreError extends Error {
4
+ code;
5
+ constructor(code, message) {
6
+ super(message);
7
+ this.code = code;
8
+ this.name = 'AgentToolStoreError';
9
+ }
10
+ }
11
+ // ──────────────────────────────────────────────
12
+ // AgentToolStore
13
+ //
14
+ // Thin Drizzle queries over agent_tools.
15
+ // Mirrors the pattern in entrypoint/agent-mcp's AgentStore (agent-cache-store pattern).
16
+ // Constructor accepts a BetterSQLite3Database so tests can inject their own
17
+ // connection without touching the production singleton in client.ts.
18
+ //
19
+ // CRITICAL: grant() persists the `permission` argument verbatim. Do not
20
+ // hardcode a default — the [dod.3] negative-control breaks on exactly this.
21
+ // ──────────────────────────────────────────────
22
+ export class AgentToolStore {
23
+ db;
24
+ constructor(db) {
25
+ this.db = db;
26
+ }
27
+ /**
28
+ * Grant a canonical tool to an agent at a typed permission level.
29
+ *
30
+ * agent_slug is a LOGICAL reference — no FK check is performed against any
31
+ * agents table ([inv:no-cross-pkg-fk]). Any string is accepted.
32
+ *
33
+ * Throws GRANT_ALREADY_EXISTS if the (agent_slug, tool_name) pair exists.
34
+ */
35
+ grant(input) {
36
+ const existing = this.db
37
+ .select()
38
+ .from(agentToolsTable)
39
+ .where(and(eq(agentToolsTable.agentSlug, input.agentSlug), eq(agentToolsTable.toolName, input.toolName)))
40
+ .get();
41
+ if (existing) {
42
+ throw new AgentToolStoreError('GRANT_ALREADY_EXISTS', `Grant for agent '${input.agentSlug}' on tool '${input.toolName}' already exists`);
43
+ }
44
+ const grant = {
45
+ agentSlug: input.agentSlug,
46
+ toolName: input.toolName,
47
+ // Persist verbatim — CRITICAL for [dod.3] negative-control
48
+ permission: input.permission,
49
+ contextCondition: input.contextCondition ?? null,
50
+ };
51
+ this.db
52
+ .insert(agentToolsTable)
53
+ .values({
54
+ agentSlug: grant.agentSlug,
55
+ toolName: grant.toolName,
56
+ permission: grant.permission,
57
+ contextCondition: grant.contextCondition,
58
+ })
59
+ .run();
60
+ return grant;
61
+ }
62
+ /**
63
+ * Return all grants for a given agent slug.
64
+ *
65
+ * Returns an empty array if no grants exist (or if the slug has never
66
+ * been granted any tool — agent_slug carries no FK constraint).
67
+ */
68
+ listForAgent(agentSlug) {
69
+ const rows = this.db
70
+ .select()
71
+ .from(agentToolsTable)
72
+ .where(eq(agentToolsTable.agentSlug, agentSlug))
73
+ .all();
74
+ return rows.map((row) => ({
75
+ agentSlug: row.agentSlug,
76
+ toolName: row.toolName,
77
+ permission: row.permission,
78
+ contextCondition: row.contextCondition,
79
+ }));
80
+ }
81
+ /**
82
+ * Revoke a tool grant from an agent.
83
+ * Throws GRANT_NOT_FOUND if the (agent_slug, tool_name) pair does not exist.
84
+ */
85
+ revoke(agentSlug, toolName) {
86
+ const existing = this.db
87
+ .select()
88
+ .from(agentToolsTable)
89
+ .where(and(eq(agentToolsTable.agentSlug, agentSlug), eq(agentToolsTable.toolName, toolName)))
90
+ .get();
91
+ if (!existing) {
92
+ throw new AgentToolStoreError('GRANT_NOT_FOUND', `Grant for agent '${agentSlug}' on tool '${toolName}' not found`);
93
+ }
94
+ this.db
95
+ .delete(agentToolsTable)
96
+ .where(and(eq(agentToolsTable.agentSlug, agentSlug), eq(agentToolsTable.toolName, toolName)))
97
+ .run();
98
+ }
99
+ }
100
+ //# sourceMappingURL=agent-tool-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-tool-store.js","sourceRoot":"","sources":["../../../../../../packages/agent/agent-store-tools/src/store/agent-tool-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAItC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAgDlD,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAChB;IAA5B,YAA4B,IAA6B,EAAE,OAAe;QACxE,KAAK,CAAC,OAAO,CAAC,CAAC;QADW,SAAI,GAAJ,IAAI,CAAyB;QAEvD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED,iDAAiD;AACjD,iBAAiB;AACjB,EAAE;AACF,yCAAyC;AACzC,wFAAwF;AACxF,4EAA4E;AAC5E,qEAAqE;AACrE,EAAE;AACF,wEAAwE;AACxE,4EAA4E;AAC5E,iD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C;aACrB,KAAK,CAAC,EAAE,CAAC,eAAe,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;aAC/C,GAAG,EAAE,CAAC;QAET,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YACxB,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,UAAU,EAAE,GAAG,CAAC,UAA6B;YAC7C,gBAAgB,EAAE,GAAG,CAAC,gBAAkD;SACzE,CAAC,CAAC,CAAC;IACN,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,SAAiB,EAAE,QAAgB;QACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,EAAE;aACrB,MAAM,EAAE;aACR,IAAI,CAAC,eAAe,CAAC;aACrB,KAAK,CACJ,GAAG,CACD,EAAE,CAAC,eAAe,CAAC,SAAS,EAAE,SAAS,CAAC,EACxC,EAAE,CAAC,eAAe,CAAC,QAAQ,EAAE,QAAQ,CAAC,CACvC,CACF;aACA,GAAG,EAAE,CAAC;QAET,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,mBAAmB,CAC3B,iBAAiB,EACjB,oBAAoB,SAAS,cAAc,QAAQ,aAAa,CACjE,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,EAAE;aACJ,MAAM,CAAC,eAAe,CAAC;aACvB,KAAK,CACJ,GAAG,CACD,EAAE,CAAC,eAAe,CAAC,SAAS,EAAE,SAAS,CAAC,EACxC,EAAE,CAAC,eAAe,CAAC,QAAQ,EAAE,QAAQ,CAAC,CACvC,CACF;aACA,GAAG,EAAE,CAAC;IACX,CAAC;CACF"}
@@ -0,0 +1,75 @@
1
+ import type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
2
+ /** A runtime environment a canonical tool can be deployed to. */
3
+ export interface Platform {
4
+ id: string;
5
+ name: string;
6
+ /** One of: yaml_frontmatter | json_object | none */
7
+ headerFormat: string;
8
+ supportsToolSelection: boolean;
9
+ }
10
+ /** Input for seeding a platform row. */
11
+ export interface PlatformSeedInput {
12
+ id: string;
13
+ name: string;
14
+ headerFormat: string;
15
+ supportsToolSelection?: boolean;
16
+ }
17
+ /**
18
+ * The per-platform alias for a canonical tool.
19
+ *
20
+ * availability is one of: available | restricted | unavailable | requires_permission
21
+ */
22
+ export interface ToolPlatformBinding {
23
+ toolName: string;
24
+ platformId: string;
25
+ platformToolName: string;
26
+ availability: string;
27
+ requiresMcp: boolean;
28
+ invocationNote: string | null;
29
+ }
30
+ /** Input for inserting a tool-platform binding row. */
31
+ export interface BindingCreateInput {
32
+ toolName: string;
33
+ platformId: string;
34
+ platformToolName: string;
35
+ availability: string;
36
+ requiresMcp?: boolean;
37
+ invocationNote?: string | null;
38
+ }
39
+ export type BindingStoreErrorCode = 'BINDING_NOT_FOUND' | 'PLATFORM_NOT_FOUND' | 'BINDING_ALREADY_EXISTS';
40
+ export declare class BindingStoreError extends Error {
41
+ readonly code: BindingStoreErrorCode;
42
+ constructor(code: BindingStoreErrorCode, message: string);
43
+ }
44
+ export declare class BindingStore {
45
+ private readonly db;
46
+ constructor(db: BetterSQLite3Database<Record<string, never>>);
47
+ /** Seed or upsert a platform row. Idempotent via onConflictDoNothing. */
48
+ seedPlatform(input: PlatformSeedInput): void;
49
+ /** Read a platform by id. Throws PLATFORM_NOT_FOUND if absent. */
50
+ readPlatform(id: string): Platform;
51
+ /** List all seeded platforms. */
52
+ listPlatforms(): Platform[];
53
+ /**
54
+ * Insert a tool-platform binding.
55
+ * Throws BINDING_ALREADY_EXISTS if the (toolName, platformId) PK is taken.
56
+ */
57
+ createBinding(input: BindingCreateInput): ToolPlatformBinding;
58
+ /**
59
+ * [def:resolve] — The keystone primitive.
60
+ *
61
+ * Returns the platform_tool_name for (canonicalToolName, platformId),
62
+ * or throws BINDING_NOT_FOUND if no binding exists for that exact pair.
63
+ *
64
+ * MUST filter on BOTH tool_name AND platform_id — the [dod.1] negative-
65
+ * control breaks this function by ignoring the platform argument, which
66
+ * would return the wrong alias when multiple bindings exist for a tool.
67
+ */
68
+ resolve(canonicalToolName: string, platformId: string): string;
69
+ /**
70
+ * List all bindings for a given platform.
71
+ * Used by @adhd/agent-engine-compiler to build the platform's tools: header.
72
+ */
73
+ listForPlatform(platformId: string): ToolPlatformBinding[];
74
+ }
75
+ //# sourceMappingURL=binding-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binding-store.d.ts","sourceRoot":"","sources":["../../../../../../packages/agent/agent-store-tools/src/store/binding-store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAQxE,iEAAiE;AACjE,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,YAAY,EAAE,MAAM,CAAC;IACrB,qBAAqB,EAAE,OAAO,CAAC;CAChC;AAED,wCAAwC;AACxC,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,uDAAuD;AACvD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAMD,MAAM,MAAM,qBAAqB,GAC7B,mBAAmB,GACnB,oBAAoB,GACpB,wBAAwB,CAAC;AAE7B,qBAAa,iBAAkB,SAAQ,KAAK;aACd,IAAI,EAAE,qBAAqB;gBAA3B,IAAI,EAAE,qBAAqB,EAAE,OAAO,EAAE,MAAM;CAIzE;AAWD,qBAAa,YAAY;IAErB,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,qBAAqB,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAKnE,yEAAyE;IACzE,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;IAa5C,kEAAkE;IAClE,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,QAAQ;IAsBlC,iCAAiC;IACjC,aAAa,IAAI,QAAQ,EAAE;IAe3B;;;OAGG;IACH,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,mBAAmB;IA2C7D;;;;;;;;;OASG;IACH,OAAO,CAAC,iBAAiB,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;IAsB9D;;;OAGG;IACH,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,mBAAmB,EAAE;CAe3D"}
@@ -0,0 +1,144 @@
1
+ import { and, eq } from 'drizzle-orm';
2
+ import { platformsTable, toolPlatformBindingsTable } from '../db/schema.js';
3
+ export class BindingStoreError extends Error {
4
+ code;
5
+ constructor(code, message) {
6
+ super(message);
7
+ this.code = code;
8
+ this.name = 'BindingStoreError';
9
+ }
10
+ }
11
+ // ──────────────────────────────────────────────
12
+ // BindingStore
13
+ //
14
+ // Thin Drizzle queries over platforms and tool_platform_bindings.
15
+ // Mirrors the pattern in entrypoint/agent-mcp's AgentStore (agent-cache-store pattern).
16
+ // Constructor accepts a BetterSQLite3Database so tests can inject their own
17
+ // connection without touching the production singleton in client.ts.
18
+ // ──────────────────────────────────────────────
19
+ export class BindingStore {
20
+ db;
21
+ constructor(db) {
22
+ this.db = db;
23
+ }
24
+ // ── platforms ─────────────────────────────
25
+ /** Seed or upsert a platform row. Idempotent via onConflictDoNothing. */
26
+ seedPlatform(input) {
27
+ this.db
28
+ .insert(platformsTable)
29
+ .values({
30
+ id: input.id,
31
+ name: input.name,
32
+ headerFormat: input.headerFormat,
33
+ supportsToolSelection: input.supportsToolSelection ?? false,
34
+ })
35
+ .onConflictDoNothing()
36
+ .run();
37
+ }
38
+ /** Read a platform by id. Throws PLATFORM_NOT_FOUND if absent. */
39
+ readPlatform(id) {
40
+ const row = this.db
41
+ .select()
42
+ .from(platformsTable)
43
+ .where(eq(platformsTable.id, id))
44
+ .get();
45
+ if (!row) {
46
+ throw new BindingStoreError('PLATFORM_NOT_FOUND', `Platform '${id}' not found`);
47
+ }
48
+ return {
49
+ id: row.id,
50
+ name: row.name,
51
+ headerFormat: row.headerFormat,
52
+ supportsToolSelection: row.supportsToolSelection,
53
+ };
54
+ }
55
+ /** List all seeded platforms. */
56
+ listPlatforms() {
57
+ return this.db
58
+ .select()
59
+ .from(platformsTable)
60
+ .all()
61
+ .map((row) => ({
62
+ id: row.id,
63
+ name: row.name,
64
+ headerFormat: row.headerFormat,
65
+ supportsToolSelection: row.supportsToolSelection,
66
+ }));
67
+ }
68
+ // ── tool_platform_bindings ────────────────
69
+ /**
70
+ * Insert a tool-platform binding.
71
+ * Throws BINDING_ALREADY_EXISTS if the (toolName, platformId) PK is taken.
72
+ */
73
+ createBinding(input) {
74
+ const existing = this.db
75
+ .select()
76
+ .from(toolPlatformBindingsTable)
77
+ .where(and(eq(toolPlatformBindingsTable.toolName, input.toolName), eq(toolPlatformBindingsTable.platformId, input.platformId)))
78
+ .get();
79
+ if (existing) {
80
+ throw new BindingStoreError('BINDING_ALREADY_EXISTS', `Binding for ('${input.toolName}', '${input.platformId}') already exists`);
81
+ }
82
+ const binding = {
83
+ toolName: input.toolName,
84
+ platformId: input.platformId,
85
+ platformToolName: input.platformToolName,
86
+ availability: input.availability,
87
+ requiresMcp: input.requiresMcp ?? false,
88
+ invocationNote: input.invocationNote ?? null,
89
+ };
90
+ this.db
91
+ .insert(toolPlatformBindingsTable)
92
+ .values({
93
+ toolName: binding.toolName,
94
+ platformId: binding.platformId,
95
+ platformToolName: binding.platformToolName,
96
+ availability: binding.availability,
97
+ requiresMcp: binding.requiresMcp,
98
+ invocationNote: binding.invocationNote,
99
+ })
100
+ .run();
101
+ return binding;
102
+ }
103
+ /**
104
+ * [def:resolve] — The keystone primitive.
105
+ *
106
+ * Returns the platform_tool_name for (canonicalToolName, platformId),
107
+ * or throws BINDING_NOT_FOUND if no binding exists for that exact pair.
108
+ *
109
+ * MUST filter on BOTH tool_name AND platform_id — the [dod.1] negative-
110
+ * control breaks this function by ignoring the platform argument, which
111
+ * would return the wrong alias when multiple bindings exist for a tool.
112
+ */
113
+ resolve(canonicalToolName, platformId) {
114
+ const row = this.db
115
+ .select()
116
+ .from(toolPlatformBindingsTable)
117
+ .where(and(eq(toolPlatformBindingsTable.toolName, canonicalToolName), eq(toolPlatformBindingsTable.platformId, platformId)))
118
+ .get();
119
+ if (!row) {
120
+ throw new BindingStoreError('BINDING_NOT_FOUND', `No binding found for tool '${canonicalToolName}' on platform '${platformId}'`);
121
+ }
122
+ return row.platformToolName;
123
+ }
124
+ /**
125
+ * List all bindings for a given platform.
126
+ * Used by @adhd/agent-engine-compiler to build the platform's tools: header.
127
+ */
128
+ listForPlatform(platformId) {
129
+ return this.db
130
+ .select()
131
+ .from(toolPlatformBindingsTable)
132
+ .where(eq(toolPlatformBindingsTable.platformId, platformId))
133
+ .all()
134
+ .map((row) => ({
135
+ toolName: row.toolName,
136
+ platformId: row.platformId,
137
+ platformToolName: row.platformToolName,
138
+ availability: row.availability,
139
+ requiresMcp: row.requiresMcp,
140
+ invocationNote: row.invocationNote,
141
+ }));
142
+ }
143
+ }
144
+ //# sourceMappingURL=binding-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binding-store.js","sourceRoot":"","sources":["../../../../../../packages/agent/agent-store-tools/src/store/binding-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAItC,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAwD5E,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IACd;IAA5B,YAA4B,IAA2B,EAAE,OAAe;QACtE,KAAK,CAAC,OAAO,CAAC,CAAC;QADW,SAAI,GAAJ,IAAI,CAAuB;QAErD,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED,iDAAiD;AACjD,eAAe;AACf,EAAE;AACF,kEAAkE;AAClE,wFAAwF;AACxF,4EAA4E;AAC5E,qEAAqE;AACrE,iDAAiD;AAEjD,MAAM,OAAO,YAAY;IAEJ;IADnB,YACmB,EAAgD;QAAhD,OAAE,GAAF,EAAE,CAA8C;IAChE,CAAC;IAEJ,6CAA6C;IAE7C,yEAAyE;IACzE,YAAY,CAAC,KAAwB;QACnC,IAAI,CAAC,EAAE;aACJ,MAAM,CAAC,cAAc,CAAC;aACtB,MAAM,CAAC;YACN,EAAE,EAAE,KAAK,CAAC,EAAE;YACZ,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,IAAI,KAAK;SAC5D,CAAC;aACD,mBAAmB,EAAE;aACrB,GAAG,EAAE,CAAC;IACX,CAAC;IAED,kEAAkE;IAClE,YAAY,CAAC,EAAU;QACrB,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE;aAChB,MAAM,EAAE;aACR,IAAI,CAAC,cAAc,CAAC;aACpB,KAAK,CAAC,EAAE,CAAC,cAAc,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;aAChC,GAAG,EAAE,CAAC;QAET,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,M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EAAE,UAAU,CAAC,CAAC;aAC3D,GAAG,EAAE;aACL,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YACb,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,UAAU,EAAE,GAAG,CAAC,UAAU;YAC1B,gBAAgB,EAAE,GAAG,CAAC,gBAAgB;YACtC,YAAY,EAAE,GAAG,CAAC,YAAY;YAC9B,WAAW,EAAE,GAAG,CAAC,WAAW;YAC5B,cAAc,EAAE,GAAG,CAAC,cAAc;SACnC,CAAC,CAAC,CAAC;IACR,CAAC;CACF"}
@@ -0,0 +1,46 @@
1
+ import type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
2
+ /**
3
+ * An MCP server registration row.
4
+ *
5
+ * transport is one of: stdio | SSE | HTTP (plain text, not an enum).
6
+ * providedToolIds is a JSON array of canonical tool names — logical references
7
+ * resolved at compile time; no SQLite FK ([inv:no-cross-pkg-fk]).
8
+ * configSchema is a JSON-Schema object for this server's configuration.
9
+ */
10
+ export interface McpServer {
11
+ id: string;
12
+ transport: string;
13
+ name: string;
14
+ providedToolIds: string[];
15
+ configSchema: Record<string, unknown>;
16
+ }
17
+ /** Input for registering an MCP server. */
18
+ export interface McpServerCreateInput {
19
+ id: string;
20
+ transport: string;
21
+ name: string;
22
+ providedToolIds?: string[];
23
+ configSchema?: Record<string, unknown>;
24
+ }
25
+ export type McpServerStoreErrorCode = 'MCP_SERVER_ALREADY_EXISTS' | 'MCP_SERVER_NOT_FOUND';
26
+ export declare class McpServerStoreError extends Error {
27
+ readonly code: McpServerStoreErrorCode;
28
+ constructor(code: McpServerStoreErrorCode, message: string);
29
+ }
30
+ export declare class McpServerStore {
31
+ private readonly db;
32
+ constructor(db: BetterSQLite3Database<Record<string, never>>);
33
+ /**
34
+ * Register an MCP server.
35
+ * Throws MCP_SERVER_ALREADY_EXISTS if the id PK already exists.
36
+ */
37
+ create(input: McpServerCreateInput): McpServer;
38
+ /**
39
+ * Read an MCP server by id.
40
+ * Throws MCP_SERVER_NOT_FOUND if absent.
41
+ */
42
+ read(id: string): McpServer;
43
+ /** List all registered MCP servers. */
44
+ list(): McpServer[];
45
+ }
46
+ //# sourceMappingURL=mcp-server-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server-store.d.ts","sourceRoot":"","sources":["../../../../../../packages/agent/agent-store-tools/src/store/mcp-server-store.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAQxE;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED,2CAA2C;AAC3C,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC;AAMD,MAAM,MAAM,uBAAuB,GAC/B,2BAA2B,GAC3B,sBAAsB,CAAC;AAE3B,qBAAa,mBAAoB,SAAQ,KAAK;aAChB,IAAI,EAAE,uBAAuB;gBAA7B,IAAI,EAAE,uBAAuB,EAAE,OAAO,EAAE,MAAM;CAI3E;AAWD,qBAAa,cAAc;IAEvB,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAAF,EAAE,EAAE,qBAAqB,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAGnE;;;OAGG;IACH,MAAM,CAAC,KAAK,EAAE,oBAAoB,GAAG,SAAS;IAoC9C;;;OAGG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;IAuB3B,uCAAuC;IACvC,IAAI,IAAI,SAAS,EAAE;CAUpB"}