@adhd/agent-mcp 1.1.4 → 2.0.1

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 (119) hide show
  1. package/drizzle/0006_composed_prompts_cache.sql +24 -0
  2. package/drizzle/meta/0006_snapshot.json +651 -0
  3. package/drizzle/meta/_journal.json +8 -1
  4. package/package.json +8 -2
  5. package/src/__tests__/integration/harness.d.ts.map +1 -1
  6. package/src/__tests__/integration/harness.js +10 -8
  7. package/src/__tests__/integration/harness.js.map +1 -1
  8. package/src/clients/stdio-client.d.ts.map +1 -1
  9. package/src/clients/stdio-client.js +2 -1
  10. package/src/clients/stdio-client.js.map +1 -1
  11. package/src/config.d.ts +114 -0
  12. package/src/config.d.ts.map +1 -0
  13. package/src/config.js +287 -0
  14. package/src/config.js.map +1 -0
  15. package/src/db/client.d.ts.map +1 -1
  16. package/src/db/client.js +2 -3
  17. package/src/db/client.js.map +1 -1
  18. package/src/db/schema.d.ts +242 -0
  19. package/src/db/schema.d.ts.map +1 -1
  20. package/src/db/schema.js +38 -1
  21. package/src/db/schema.js.map +1 -1
  22. package/src/engine/orchestrator.d.ts.map +1 -1
  23. package/src/engine/orchestrator.js +3 -2
  24. package/src/engine/orchestrator.js.map +1 -1
  25. package/src/engine/policy.d.ts +24 -0
  26. package/src/engine/policy.d.ts.map +1 -1
  27. package/src/engine/policy.js +73 -6
  28. package/src/engine/policy.js.map +1 -1
  29. package/src/engine/prompt-resolver.d.ts +89 -0
  30. package/src/engine/prompt-resolver.d.ts.map +1 -0
  31. package/src/engine/prompt-resolver.js +96 -0
  32. package/src/engine/prompt-resolver.js.map +1 -0
  33. package/src/engine/queue.d.ts.map +1 -1
  34. package/src/engine/queue.js +2 -2
  35. package/src/engine/queue.js.map +1 -1
  36. package/src/index.d.ts +47 -3
  37. package/src/index.d.ts.map +1 -1
  38. package/src/index.js +151 -20
  39. package/src/index.js.map +1 -1
  40. package/src/logger.d.ts.map +1 -1
  41. package/src/logger.js +2 -1
  42. package/src/logger.js.map +1 -1
  43. package/src/plugins/loader.d.ts +19 -6
  44. package/src/plugins/loader.d.ts.map +1 -1
  45. package/src/plugins/loader.js +23 -13
  46. package/src/plugins/loader.js.map +1 -1
  47. package/src/providers/anthropic.d.ts +5 -5
  48. package/src/providers/anthropic.d.ts.map +1 -1
  49. package/src/providers/anthropic.js +53 -188
  50. package/src/providers/anthropic.js.map +1 -1
  51. package/src/providers/claudecli.d.ts +92 -5
  52. package/src/providers/claudecli.d.ts.map +1 -1
  53. package/src/providers/claudecli.js +224 -47
  54. package/src/providers/claudecli.js.map +1 -1
  55. package/src/providers/factory.d.ts +1 -1
  56. package/src/providers/factory.d.ts.map +1 -1
  57. package/src/providers/factory.js +6 -9
  58. package/src/providers/factory.js.map +1 -1
  59. package/src/providers/index.d.ts +1 -1
  60. package/src/providers/index.d.ts.map +1 -1
  61. package/src/providers/index.js +1 -1
  62. package/src/providers/index.js.map +1 -1
  63. package/src/providers/openai.d.ts +4 -2
  64. package/src/providers/openai.d.ts.map +1 -1
  65. package/src/providers/openai.js +29 -18
  66. package/src/providers/openai.js.map +1 -1
  67. package/src/providers/types.d.ts +1 -1
  68. package/src/server.d.ts +8 -0
  69. package/src/server.d.ts.map +1 -1
  70. package/src/server.js +19 -12
  71. package/src/server.js.map +1 -1
  72. package/src/store/agent-store.d.ts +13 -0
  73. package/src/store/agent-store.d.ts.map +1 -1
  74. package/src/store/agent-store.js +16 -3
  75. package/src/store/agent-store.js.map +1 -1
  76. package/src/store/composed-prompt-store.d.ts +24 -0
  77. package/src/store/composed-prompt-store.d.ts.map +1 -0
  78. package/src/store/composed-prompt-store.js +75 -0
  79. package/src/store/composed-prompt-store.js.map +1 -0
  80. package/src/store/index.d.ts +1 -0
  81. package/src/store/index.d.ts.map +1 -1
  82. package/src/store/index.js +1 -0
  83. package/src/store/index.js.map +1 -1
  84. package/src/store/session-store.d.ts +8 -0
  85. package/src/store/session-store.d.ts.map +1 -1
  86. package/src/store/session-store.js +3 -2
  87. package/src/store/session-store.js.map +1 -1
  88. package/src/streaming/sse-server.d.ts +2 -2
  89. package/src/streaming/sse-server.d.ts.map +1 -1
  90. package/src/streaming/sse-server.js +4 -4
  91. package/src/streaming/sse-server.js.map +1 -1
  92. package/src/tools/session.d.ts +12 -0
  93. package/src/tools/session.d.ts.map +1 -1
  94. package/src/tools/session.js +33 -1
  95. package/src/tools/session.js.map +1 -1
  96. package/src/tools/task.d.ts.map +1 -1
  97. package/src/tools/task.js +2 -2
  98. package/src/tools/task.js.map +1 -1
  99. package/src/tools/usage.d.ts.map +1 -1
  100. package/src/tools/usage.js +10 -3
  101. package/src/tools/usage.js.map +1 -1
  102. package/src/utils/load-env.d.ts +16 -0
  103. package/src/utils/load-env.d.ts.map +1 -0
  104. package/src/utils/load-env.js +27 -0
  105. package/src/utils/load-env.js.map +1 -0
  106. package/src/validation/agent.d.ts +150 -62
  107. package/src/validation/agent.d.ts.map +1 -1
  108. package/src/validation/agent.js +152 -37
  109. package/src/validation/agent.js.map +1 -1
  110. package/src/validation/errors.d.ts +1 -0
  111. package/src/validation/errors.d.ts.map +1 -1
  112. package/src/validation/errors.js +2 -0
  113. package/src/validation/errors.js.map +1 -1
  114. package/src/validation/execution.d.ts +13 -20
  115. package/src/validation/execution.d.ts.map +1 -1
  116. package/src/providers/lmstudio.d.ts +0 -8
  117. package/src/providers/lmstudio.d.ts.map +0 -1
  118. package/src/providers/lmstudio.js +0 -15
  119. package/src/providers/lmstudio.js.map +0 -1
@@ -0,0 +1,89 @@
1
+ /**
2
+ * prompt-resolver — resolves a compiled system-prompt for a session start.
3
+ *
4
+ * Flow:
5
+ * 1. Compute context_hash from (agentSlug, platform, context).
6
+ * 2. Look up agent-mcp's own composed_prompts cache via ComposedPromptStore.
7
+ * 3. HIT → return {content, id} WITHOUT calling compileAgent.
8
+ * 4. MISS → call compileAgent(…), upsert the row, return {content, id}.
9
+ *
10
+ * compileAgent is injected as a parameter (compileAgentFn) so tests can stub it
11
+ * without modifying production code. Production callers pass the real
12
+ * `compileAgent` from @adhd/agent-compiler.
13
+ *
14
+ * [compiler-integration.1] — imports compileAgent from @adhd/agent-compiler
15
+ * [compiler-integration.2] — caches/looks up the composed prompt and writes composed_prompt_id
16
+ */
17
+ import type { BetterSQLite3Database } from "drizzle-orm/better-sqlite3";
18
+ import type { CompileInput, CompiledAgent } from "@adhd/agent-compiler";
19
+ import type { ComposedPromptStore } from "../store/composed-prompt-store.js";
20
+ export interface ResolveInput {
21
+ /** Slug (name) of the agent to resolve. */
22
+ agentSlug: string;
23
+ /** Target platform id (e.g. "claude_code", "claude_api"). */
24
+ platform: string;
25
+ /** Runtime context key/value map (e.g. `{ ticket_type: "security" }`). */
26
+ context?: Record<string, string>;
27
+ }
28
+ export interface ResolveResult {
29
+ /** Flat system-prompt string produced by compileAgent() or served from cache. */
30
+ content: string;
31
+ /** Row id in agent-mcp's composed_prompts table — written to sessions.composed_prompt_id. */
32
+ id: string;
33
+ }
34
+ /**
35
+ * Injectable compile function — matches the signature of
36
+ * `compileAgent` from @adhd/agent-compiler so tests can stub it.
37
+ */
38
+ export type CompileAgentFn = (input: CompileInput) => CompiledAgent;
39
+ export interface PromptResolverDeps {
40
+ /** Agent-mcp's own composed_prompts cache store. */
41
+ composedPromptStore: ComposedPromptStore;
42
+ /**
43
+ * The compileAgent function from @adhd/agent-compiler.
44
+ * Injectable so tests can stub without touching production code.
45
+ */
46
+ compileAgentFn: CompileAgentFn;
47
+ /**
48
+ * Registry DB handle passed through to compileAgent on cache MISS.
49
+ * Must point at the agent-registry SQLite file (all four table prefixes).
50
+ * Unused on a cache HIT.
51
+ */
52
+ registryDb: BetterSQLite3Database<any>;
53
+ }
54
+ /**
55
+ * Compute a deterministic SHA-256 cache key from (agentSlug, platform, context).
56
+ *
57
+ * The key encodes every runtime dimension that could produce a different compiled
58
+ * artifact: the agent identity, the target platform, and any runtime context
59
+ * key/value pairs. Keys in `context` are sorted before serialisation so that
60
+ * insertion order cannot produce different hashes for identical logical inputs.
61
+ *
62
+ * @returns 64-character lowercase hex SHA-256 string.
63
+ */
64
+ export declare function computeContextHash(agentSlug: string, platform: string, context: Record<string, string>): string;
65
+ /**
66
+ * Resolve the compiled system-prompt for a session start.
67
+ *
68
+ * On a cache HIT (agent-mcp's `composed_prompts` already has a row for this
69
+ * agent + context hash) the cached `{content, id}` is returned WITHOUT calling
70
+ * compileAgent — the registry round-trip is skipped entirely.
71
+ *
72
+ * On a cache MISS, compileAgent is called with the supplied `registryDb` handle.
73
+ * The result is upserted into agent-mcp's `composed_prompts` table and the
74
+ * returned `id` is suitable for writing to `sessions.composed_prompt_id`.
75
+ *
76
+ * **Flat-prompt fallback (backward compatibility):** when `compileAgentFn`
77
+ * throws (e.g. the agent has no registry composition — `AgentError` with code
78
+ * `AGENT_NOT_FOUND`, or a `CompositionError`) this function returns `null`
79
+ * instead of propagating. The caller (`agentTool`) then falls back to the
80
+ * stored `agentDefinition.systemPrompt`, so a legacy flat-`systemPrompt` agent
81
+ * continues to work even when a live registry DB is wired.
82
+ *
83
+ * @param input - Agent slug, target platform, and optional runtime context.
84
+ * @param deps - Injected ComposedPromptStore, compileAgentFn, and registry DB.
85
+ * @returns {content, id} on success, or `null` when no registry composition
86
+ * exists for the agent (caller must fall back to the flat systemPrompt).
87
+ */
88
+ export declare function resolveComposedPrompt(input: ResolveInput, deps: PromptResolverDeps): ResolveResult | null;
89
+ //# sourceMappingURL=prompt-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-resolver.d.ts","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/engine/prompt-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAK7E,MAAM,WAAW,YAAY;IACzB,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;IACjB,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,aAAa;IAC1B,iFAAiF;IACjF,OAAO,EAAE,MAAM,CAAC;IAChB,6FAA6F;IAC7F,EAAE,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,aAAa,CAAC;AAEpE,MAAM,WAAW,kBAAkB;IAC/B,oDAAoD;IACpD,mBAAmB,EAAE,mBAAmB,CAAC;IACzC;;;OAGG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B;;;;OAIG;IAEH,UAAU,EAAE,qBAAqB,CAAC,GAAG,CAAC,CAAC;CAC1C;AAID;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAC9B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,MAAM,CAMR;AAID;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,qBAAqB,CACjC,KAAK,EAAE,YAAY,EACnB,IAAI,EAAE,kBAAkB,GACzB,aAAa,GAAG,IAAI,CAmDtB"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * prompt-resolver — resolves a compiled system-prompt for a session start.
3
+ *
4
+ * Flow:
5
+ * 1. Compute context_hash from (agentSlug, platform, context).
6
+ * 2. Look up agent-mcp's own composed_prompts cache via ComposedPromptStore.
7
+ * 3. HIT → return {content, id} WITHOUT calling compileAgent.
8
+ * 4. MISS → call compileAgent(…), upsert the row, return {content, id}.
9
+ *
10
+ * compileAgent is injected as a parameter (compileAgentFn) so tests can stub it
11
+ * without modifying production code. Production callers pass the real
12
+ * `compileAgent` from @adhd/agent-compiler.
13
+ *
14
+ * [compiler-integration.1] — imports compileAgent from @adhd/agent-compiler
15
+ * [compiler-integration.2] — caches/looks up the composed prompt and writes composed_prompt_id
16
+ */
17
+ import { createHash } from "node:crypto";
18
+ import { logger } from "../logger.js";
19
+ // ── Context hash ─────────────────────────────────────────────────────────────
20
+ /**
21
+ * Compute a deterministic SHA-256 cache key from (agentSlug, platform, context).
22
+ *
23
+ * The key encodes every runtime dimension that could produce a different compiled
24
+ * artifact: the agent identity, the target platform, and any runtime context
25
+ * key/value pairs. Keys in `context` are sorted before serialisation so that
26
+ * insertion order cannot produce different hashes for identical logical inputs.
27
+ *
28
+ * @returns 64-character lowercase hex SHA-256 string.
29
+ */
30
+ export function computeContextHash(agentSlug, platform, context) {
31
+ const sortedContext = Object.fromEntries(Object.keys(context).sort().map(k => [k, context[k]]));
32
+ const payload = `${agentSlug}|${platform}|${JSON.stringify(sortedContext)}`;
33
+ return createHash("sha256").update(payload, "utf8").digest("hex");
34
+ }
35
+ // ── Public resolver ──────────────────────────────────────────────────────────
36
+ /**
37
+ * Resolve the compiled system-prompt for a session start.
38
+ *
39
+ * On a cache HIT (agent-mcp's `composed_prompts` already has a row for this
40
+ * agent + context hash) the cached `{content, id}` is returned WITHOUT calling
41
+ * compileAgent — the registry round-trip is skipped entirely.
42
+ *
43
+ * On a cache MISS, compileAgent is called with the supplied `registryDb` handle.
44
+ * The result is upserted into agent-mcp's `composed_prompts` table and the
45
+ * returned `id` is suitable for writing to `sessions.composed_prompt_id`.
46
+ *
47
+ * **Flat-prompt fallback (backward compatibility):** when `compileAgentFn`
48
+ * throws (e.g. the agent has no registry composition — `AgentError` with code
49
+ * `AGENT_NOT_FOUND`, or a `CompositionError`) this function returns `null`
50
+ * instead of propagating. The caller (`agentTool`) then falls back to the
51
+ * stored `agentDefinition.systemPrompt`, so a legacy flat-`systemPrompt` agent
52
+ * continues to work even when a live registry DB is wired.
53
+ *
54
+ * @param input - Agent slug, target platform, and optional runtime context.
55
+ * @param deps - Injected ComposedPromptStore, compileAgentFn, and registry DB.
56
+ * @returns {content, id} on success, or `null` when no registry composition
57
+ * exists for the agent (caller must fall back to the flat systemPrompt).
58
+ */
59
+ export function resolveComposedPrompt(input, deps) {
60
+ const { agentSlug, platform, context = {} } = input;
61
+ const { composedPromptStore, compileAgentFn, registryDb } = deps;
62
+ const contextHash = computeContextHash(agentSlug, platform, context);
63
+ // ── Cache HIT ────────────────────────────────────────────────────────────
64
+ const cached = composedPromptStore.findByAgentContext(agentSlug, contextHash);
65
+ if (cached) {
66
+ logger.debug({ agentSlug, composedPromptId: cached.id }, "Composed prompt cache hit — skipping compileAgent");
67
+ return { content: cached.content, id: cached.id };
68
+ }
69
+ // ── Cache MISS — compile and upsert ──────────────────────────────────────
70
+ logger.debug({ agentSlug, platform }, "Composed prompt cache miss — calling compileAgent");
71
+ let compiled;
72
+ try {
73
+ compiled = compileAgentFn({
74
+ agentSlug,
75
+ platform,
76
+ context,
77
+ db: registryDb,
78
+ });
79
+ }
80
+ catch (err) {
81
+ // No registry composition for this agent — fall back to the stored
82
+ // flat systemPrompt. Log at debug level: this is expected for agents
83
+ // that were created via agent_create without registry backing.
84
+ logger.debug({ agentSlug, err }, "compileAgent threw — no registry composition; falling back to flat systemPrompt");
85
+ return null;
86
+ }
87
+ const row = composedPromptStore.upsert({
88
+ agentSlug,
89
+ contextHash,
90
+ content: compiled.content,
91
+ componentVersions: JSON.stringify(compiled.componentVersions ?? {}),
92
+ });
93
+ logger.info({ agentSlug, composedPromptId: row.id }, "Composed prompt compiled and cached");
94
+ return { content: row.content, id: row.id };
95
+ }
96
+ //# sourceMappingURL=prompt-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-resolver.js","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/engine/prompt-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAA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CAAS;gBAEnB,WAAW,CAAC,EAAE,MAAM;IAQhC;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG,IAAI;IAkBtD,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;OAIG;IACH,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAG1B"}
1
+ {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/engine/queue.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnD;;;;;;GAMG;AACH,qBAAa,eAAe;IACxB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;gBAEnB,WAAW,CAAC,EAAE,MAAM;IAMhC;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG,IAAI;IAkBtD,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;OAIG;IACH,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAG1B"}
@@ -1,5 +1,6 @@
1
1
  import PQueue from "p-queue";
2
2
  import { logger } from "../logger.js";
3
+ import { config } from "../config.js";
3
4
  /**
4
5
  * BackgroundQueue wraps p-queue to run async tasks with concurrency limiting.
5
6
  *
@@ -10,8 +11,7 @@ import { logger } from "../logger.js";
10
11
  export class BackgroundQueue {
11
12
  queue;
12
13
  constructor(concurrency) {
13
- const resolvedConcurrency = concurrency ??
14
- parseInt(process.env["QUEUE_CONCURRENCY"] ?? "5", 10);
14
+ const resolvedConcurrency = concurrency ?? config.queue.concurrency;
15
15
  this.queue = new PQueue({ concurrency: resolvedConcurrency });
16
16
  }
17
17
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"queue.js","sourceRoot":"","sources":["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AAI,EAAE,EAAE,0BAA0B,CAAC,CAAC;IAC7G,CAAC;IAED,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;IAC9B,CAAC;IAED,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACH,MAAM;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;IAC/B,CAAC;CACJ"}
package/src/index.d.ts CHANGED
@@ -1,6 +1,50 @@
1
1
  #!/usr/bin/env node
2
- import "dotenv/config";
3
- /** Default max_tokens for providers that do not set maxTokens in their config. */
4
- export declare const AGENT_MCP_DEFAULT_MAX_TOKENS: number;
5
2
  export { HookRegistry } from "./engine/hooks.js";
3
+ export { ComposedPromptStore } from "./store/composed-prompt-store.js";
4
+ export { resolveComposedPrompt, computeContextHash } from "./engine/prompt-resolver.js";
5
+ export type { ResolveInput, ResolveResult, ResolveResult as PromptResolveResult, CompileAgentFn, PromptResolverDeps } from "./engine/prompt-resolver.js";
6
+ import type { CompileAgentFn, PromptResolverDeps } from "./engine/prompt-resolver.js";
7
+ export interface BuildPromptResolverOpts {
8
+ /** Path to the agent-registry SQLite file. Absent → resolver is undefined. */
9
+ registryDbPath?: string;
10
+ /**
11
+ * The agent-mcp Drizzle DB handle, used to construct ComposedPromptStore.
12
+ * Must already have agent-mcp migrations applied.
13
+ */
14
+ agentMcpDb: any;
15
+ /**
16
+ * The compileAgent function from @adhd/agent-compiler. When absent (the
17
+ * package is not installed), the resolver returns undefined and every agent
18
+ * falls back to its flat systemPrompt — the same graceful path used when the
19
+ * registry DB itself is absent.
20
+ *
21
+ * In production, main() performs a dynamic optional import and passes the
22
+ * resolved function here. Tests that exercise compiler integration inject a
23
+ * real or stubbed compileAgentFn directly.
24
+ */
25
+ compileAgentFn?: CompileAgentFn;
26
+ }
27
+ /**
28
+ * Build a {@link PromptResolverDeps} from a registry DB path, an optional
29
+ * compile function, and the agent-mcp DB handle.
30
+ *
31
+ * Returns `undefined` (flat-systemPrompt fallback) when ANY of the following is
32
+ * true:
33
+ * - `registryDbPath` is absent (undefined / empty string).
34
+ * - `compileAgentFn` is absent — @adhd/agent-compiler is not installed.
35
+ * - The registry SQLite file cannot be opened (file missing, directory absent).
36
+ *
37
+ * When all three prerequisites are satisfied, opens the SQLite file in WAL mode,
38
+ * wraps it with Drizzle, and returns a fully-wired {@link PromptResolverDeps}.
39
+ *
40
+ * This function has no observable side-effects beyond opening the SQLite file
41
+ * when a path is supplied, so it is safe to call in tests with a real on-disk
42
+ * DB path.
43
+ *
44
+ * @param opts.registryDbPath - Path to the agent-registry SQLite file.
45
+ * @param opts.agentMcpDb - Drizzle handle for the agent-mcp DB.
46
+ * @param opts.compileAgentFn - Compile function from @adhd/agent-compiler (optional).
47
+ * @returns Wired {@link PromptResolverDeps} or `undefined`.
48
+ */
49
+ export declare function buildPromptResolver(opts: BuildPromptResolverOpts): PromptResolverDeps | undefined;
6
50
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/ai/agent-mcp/src/index.ts"],"names":[],"mappings":";AACA,OAAO,eAAe,CAAC;AAEvB,kFAAkF;AAClF,eAAO,MAAM,4BAA4B,QAGxC,CAAC;AAGF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/ai/agent-mcp/src/index.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACxF,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,IAAI,mBAAmB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAWzJ,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAyBtF,MAAM,WAAW,uBAAuB;IACpC,+EAA+E;IAC/E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IAEH,UAAU,EAAE,GAAG,CAAC;IAChB;;;;;;;;;OASG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,uBAAuB,GAAG,kBAAkB,GAAG,SAAS,CA+CjG"}
package/src/index.js CHANGED
@@ -1,13 +1,18 @@
1
1
  #!/usr/bin/env node
2
- import "dotenv/config";
3
- /** Default max_tokens for providers that do not set maxTokens in their config. */
4
- export const AGENT_MCP_DEFAULT_MAX_TOKENS = parseInt(process.env["AGENT_MCP_DEFAULT_MAX_TOKENS"] ?? "8192", 10);
5
2
  // Re-export HookRegistry so plugins can import it for testing without deep internal paths
6
3
  export { HookRegistry } from "./engine/hooks.js";
4
+ // Re-export stores so consumers (tests, plugins) can import from the package root
5
+ export { ComposedPromptStore } from "./store/composed-prompt-store.js";
6
+ // Re-export prompt resolver for consumers that wire the compiler integration
7
+ export { resolveComposedPrompt, computeContextHash } from "./engine/prompt-resolver.js";
8
+ import Database from "better-sqlite3";
9
+ import { drizzle } from "drizzle-orm/better-sqlite3";
7
10
  import { db } from "./db/client.js";
8
11
  import { runMigrations } from "./db/migrate.js";
9
12
  import { logger } from "./logger.js";
13
+ import { config } from "./config.js";
10
14
  import { AgentStore, SessionStore, TaskStore } from "./store/index.js";
15
+ import { ComposedPromptStore } from "./store/composed-prompt-store.js";
11
16
  import { BackgroundQueue } from "./engine/queue.js";
12
17
  import { DagEngine } from "./engine/dag-engine.js";
13
18
  import { Orchestrator } from "./engine/orchestrator.js";
@@ -21,6 +26,66 @@ import { enqueueExistingTask } from "./tools/task.js";
21
26
  import { tasksTable } from "./db/schema.js";
22
27
  import { eq } from "drizzle-orm";
23
28
  import { ToolError } from "./validation/errors.js";
29
+ /**
30
+ * Build a {@link PromptResolverDeps} from a registry DB path, an optional
31
+ * compile function, and the agent-mcp DB handle.
32
+ *
33
+ * Returns `undefined` (flat-systemPrompt fallback) when ANY of the following is
34
+ * true:
35
+ * - `registryDbPath` is absent (undefined / empty string).
36
+ * - `compileAgentFn` is absent — @adhd/agent-compiler is not installed.
37
+ * - The registry SQLite file cannot be opened (file missing, directory absent).
38
+ *
39
+ * When all three prerequisites are satisfied, opens the SQLite file in WAL mode,
40
+ * wraps it with Drizzle, and returns a fully-wired {@link PromptResolverDeps}.
41
+ *
42
+ * This function has no observable side-effects beyond opening the SQLite file
43
+ * when a path is supplied, so it is safe to call in tests with a real on-disk
44
+ * DB path.
45
+ *
46
+ * @param opts.registryDbPath - Path to the agent-registry SQLite file.
47
+ * @param opts.agentMcpDb - Drizzle handle for the agent-mcp DB.
48
+ * @param opts.compileAgentFn - Compile function from @adhd/agent-compiler (optional).
49
+ * @returns Wired {@link PromptResolverDeps} or `undefined`.
50
+ */
51
+ export function buildPromptResolver(opts) {
52
+ const { registryDbPath, agentMcpDb, compileAgentFn } = opts;
53
+ if (!registryDbPath) {
54
+ return undefined;
55
+ }
56
+ // When the compiler package is not installed (optional dependency), degrade
57
+ // gracefully to the flat-systemPrompt path — same as when the registry DB is absent.
58
+ if (!compileAgentFn) {
59
+ logger.info("@adhd/agent-compiler not available — registry/compiler integration disabled; using flat system-prompts");
60
+ return undefined;
61
+ }
62
+ // Graceful degradation: the registry DB at the default path
63
+ // (~/.adhd/agent-mcp/registry.db) will be absent or unmigrated until Plan 7
64
+ // imports the corpus. Opening a nonexistent directory throws; an empty /
65
+ // unmigrated DB produces empty tables that cause compileAgent to throw, which
66
+ // resolveComposedPrompt already catches and converts to a null (flat-prompt
67
+ // fallback). We catch the open failure here so the server still starts and
68
+ // every flat-systemPrompt agent continues to work unchanged.
69
+ let registrySqlite;
70
+ try {
71
+ logger.info({ registryDbPath }, "Opening registry DB for compiler integration");
72
+ registrySqlite = new Database(registryDbPath, { fileMustExist: true });
73
+ registrySqlite.pragma("journal_mode = WAL");
74
+ registrySqlite.pragma("foreign_keys = ON");
75
+ }
76
+ catch (err) {
77
+ logger.info({ registryDbPath, err }, "Registry DB not available — falling back to flat systemPrompt for all agents");
78
+ return undefined;
79
+ }
80
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
81
+ const registryDb = drizzle(registrySqlite);
82
+ const composedPromptStore = new ComposedPromptStore(agentMcpDb);
83
+ return {
84
+ composedPromptStore,
85
+ compileAgentFn,
86
+ registryDb,
87
+ };
88
+ }
24
89
  // DEBT-001: top-level safety net for anything that escapes the per-component
25
90
  // handlers (SSE 'error' event: BUG-001; queue catch: BackgroundQueue.enqueue;
26
91
  // orchestrator try/catch; provider pRetry). An unhandled error here means a
@@ -34,6 +99,38 @@ process.on("unhandledRejection", (reason) => {
34
99
  logger.fatal({ reason }, "Unhandled promise rejection — exiting");
35
100
  process.exit(1);
36
101
  });
102
+ // ── Startup env-ref verification (§4) ────────────────────────────────────────
103
+ // Harvest every ADHD_AGENT_* env-var name referenced across all agent env blocks,
104
+ // then call config.verifyEnvRefs to surface missing / disallowed names as
105
+ // structured warnings. Never crashes — one misconfigured agent must not block the
106
+ // rest of a mixed deployment.
107
+ function verifyAgentEnvRefs(agents) {
108
+ const names = [];
109
+ for (const agent of agents) {
110
+ const p = agent.provider;
111
+ if (p.type === "openai" || p.type === "anthropic") {
112
+ const env = p.env;
113
+ if (env?.secret)
114
+ names.push(env.secret);
115
+ if (env?.base_url)
116
+ names.push(env.base_url);
117
+ if (env?.model)
118
+ names.push(env.model);
119
+ }
120
+ }
121
+ if (names.length === 0)
122
+ return;
123
+ const { missing, disallowed } = config.verifyEnvRefs(names);
124
+ if (missing.length > 0) {
125
+ logger.warn({ missingEnvVars: missing }, "Startup warning: the following env vars are referenced in agent configs but are not set. " +
126
+ "Tasks using those agents will fail at credential resolution. " +
127
+ "Set them in ~/.adhd/.env.");
128
+ }
129
+ if (disallowed.length > 0) {
130
+ logger.warn({ disallowedEnvVars: disallowed }, "Startup warning: the following env-var names in agent configs violate the ADHD_AGENT_- prefix guard. " +
131
+ "Add them to ADHD_AGENT_ENV_ALLOWLIST if they are intentional.");
132
+ }
133
+ }
37
134
  async function main() {
38
135
  // Run DB migrations synchronously before advertising tools
39
136
  runMigrations();
@@ -50,7 +147,7 @@ async function main() {
50
147
  // Must never throw — handlers are internally guarded.
51
148
  const usagePlugin = new UsagePlugin(dbAny);
52
149
  await usagePlugin.install(hooks);
53
- // External plugins: loaded from AGENT_MCP_PLUGINS env var.
150
+ // External plugins: loaded from config.plugins.entries (ADHD_AGENT_PLUGINS env var).
54
151
  // Each entry is a module specifier (absolute path or npm package name) that
55
152
  // exports a createPlugin(ctx) factory. Failures are logged and skipped.
56
153
  await loadExternalPlugins(hooks, dbAny);
@@ -58,31 +155,64 @@ async function main() {
58
155
  const queue = new BackgroundQueue();
59
156
  const orchestrator = new Orchestrator();
60
157
  const policy = new PolicyEngine({
61
- serverMaxDepth: parseInt(process.env["AGENT_MCP_MAX_DEPTH"] ?? "5", 10),
62
- serverMaxToolLoops: parseInt(process.env["AGENT_MCP_MAX_TOOL_LOOPS"] ?? "50", 10),
63
- serverAllowedAgents: process.env["ALLOWED_AGENTS"]
64
- ?.split(",")
65
- .map(s => s.trim())
66
- .filter(Boolean),
158
+ serverMaxDepth: config.server.maxDepth,
159
+ serverMaxToolLoops: config.server.maxToolLoops,
160
+ serverAllowedAgents: config.server.allowedAgents,
67
161
  });
68
162
  // Build DagEngine with an injected dispatchFn closure.
69
163
  //
70
164
  // The closure avoids a circular import between dag-engine.ts and tools/task.ts:
71
165
  // DagEngine dispatches waiting→pending tasks by calling dispatchFn(taskId) rather
72
- // than importing enqueueExistingTask directly. The closure captures `taskDeps`
73
- // which is populated after startServer resolves (below).
166
+ // than importing enqueueExistingTask directly. The closure captures `taskDepsRef`
167
+ // whose value is populated after startServer resolves (below).
74
168
  //
75
169
  // dispatchFn is only invoked when DagEngine.dispatchReady() finds a ready task,
76
- // which always happens AFTER server startup, so `taskDeps` is guaranteed to be
77
- // set by the time the closure executes.
78
- let taskDeps;
170
+ // which always happens AFTER server startup, so `taskDepsRef.value` is guaranteed
171
+ // to be set by the time the closure executes.
172
+ const taskDepsRef = { value: undefined };
79
173
  const dispatchFn = async (taskId) => {
80
- if (!taskDeps) {
174
+ if (!taskDepsRef.value) {
81
175
  throw new Error(`DagEngine.dispatchFn called before server initialised (taskId=${taskId})`);
82
176
  }
83
- await enqueueExistingTask(taskId, taskDeps);
177
+ await enqueueExistingTask(taskId, taskDepsRef.value);
84
178
  };
85
179
  const dagEngine = new DagEngine(dbAny, queue, taskStore, dispatchFn);
180
+ // ── Prompt resolver (compiler integration) ────────────────────────────
181
+ //
182
+ // Delegates to buildPromptResolver() — the exported factory that is also
183
+ // exercised directly by index-wiring.test.ts (Plan 6 gap F-P6-8b).
184
+ //
185
+ // @adhd/agent-compiler is an OPTIONAL dependency: the dynamic import below
186
+ // succeeds only when the package is installed. On failure (standalone install
187
+ // without the compiler), the catch logs an info message and leaves
188
+ // compileAgentFn undefined — buildPromptResolver then returns undefined and
189
+ // every agent falls back to its flat systemPrompt.
190
+ //
191
+ // When ADHD_AGENT_REGISTRY_DB_PATH is set AND the compiler is installed,
192
+ // buildPromptResolver opens the SQLite file and wires compileAgentFn. Every
193
+ // `agent` tool call then resolves the system-prompt via the compiler (with
194
+ // a composed_prompts cache look-up) before creating the session.
195
+ let compileAgentFn;
196
+ try {
197
+ ({ compileAgent: compileAgentFn } = await import("@adhd/agent-compiler"));
198
+ }
199
+ catch {
200
+ logger.info("@adhd/agent-compiler not installed — registry/compiler integration disabled; using flat system-prompts");
201
+ }
202
+ const promptResolver = buildPromptResolver({
203
+ registryDbPath: config.server.registryDbPath,
204
+ agentMcpDb: dbAny,
205
+ compileAgentFn,
206
+ });
207
+ // ── Startup env-ref verification (§4) ─────────────────────────────────
208
+ // Must run after store init so we can list all agents.
209
+ try {
210
+ const allAgents = agentStore.list();
211
+ verifyAgentEnvRefs(allAgents);
212
+ }
213
+ catch (err) {
214
+ logger.warn({ err }, "Startup env-ref verification failed — continuing");
215
+ }
86
216
  // Start SSE server alongside MCP server — shares taskStore for terminal-on-connect checks.
87
217
  const sseServer = startSseServer(taskStore);
88
218
  const { close } = await startServer({
@@ -95,13 +225,14 @@ async function main() {
95
225
  hooks,
96
226
  db: dbAny,
97
227
  dagEngine,
228
+ promptResolver,
98
229
  });
99
230
  // Startup re-enqueue scan: recover tasks that were transitioned to "pending"
100
231
  // by DagEngine.dispatchReady() but lost their queue slot due to a process
101
232
  // crash between the DB UPDATE and queue.enqueue(). Safe to run every startup
102
233
  // because the queue is idempotent — already-running tasks are just re-queued.
103
234
  //
104
- // taskDeps must be set before the orphan scan so dispatchFn can call
235
+ // taskDepsRef.value must be set before the orphan scan so dispatchFn can call
105
236
  // enqueueExistingTask.
106
237
  //
107
238
  // NOTE: inProcessDescriptors and inProcessHandler are not available here
@@ -109,7 +240,7 @@ async function main() {
109
240
  // in-process recursive calls at the dispatch level — they can use in-process
110
241
  // tools once running via the normal orchestrator path through server.ts.
111
242
  // Pass empty stubs: the orchestrator builds its own registry per task.
112
- taskDeps = {
243
+ taskDepsRef.value = {
113
244
  agentStore,
114
245
  sessionStore,
115
246
  taskStore,
@@ -134,7 +265,7 @@ async function main() {
134
265
  logger.info({ count: orphanedPending.length }, "Re-enqueueing orphaned pending tasks");
135
266
  for (const row of orphanedPending) {
136
267
  try {
137
- await enqueueExistingTask(row.id, taskDeps);
268
+ await enqueueExistingTask(row.id, taskDepsRef.value);
138
269
  }
139
270
  catch (err) {
140
271
  logger.warn({ taskId: row.id, err }, "Failed to re-enqueue orphaned task");
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/ai/agent-mcp/src/index.ts"],"names":[],"mappings":";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E,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,oCAAoC,CAAC,CAAC;YAC/E,CAAC;QACL,CAAC;IACL,CAAC;IAED,MAAM,QAAQ,GAAG,KAAK,EAAE,MAAc,EAAE,EAAE;QACtC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,iBAAiB,CAAC,CAAC;QAC3C,MAAM,KAAK,EAAE,CAAC;QACd,yEAAyE;QACzE,sDAAsD;QACtD,MAAM,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACrE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC,CAAC;IAEF,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,KAAK,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;IACtD,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;AACxD,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;IACf,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,qBAAqB,CAAC,CAAC;IAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../../packages/ai/agent-mcp/src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,6BAQlB,CAAC"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../../packages/ai/agent-mcp/src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,6BAQlB,CAAC"}
package/src/logger.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import pino from "pino";
2
+ import { config } from "./config.js";
2
3
  /**
3
4
  * Application logger.
4
5
  *
@@ -8,7 +9,7 @@ import pino from "pino";
8
9
  * default stdout destination.
9
10
  */
10
11
  export const logger = pino({
11
- level: process.env["LOG_LEVEL"] ?? "info",
12
+ level: config.logging.level,
12
13
  // Remove default `pid` and `hostname` fields for cleaner structured logs.
13
14
  base: undefined,
14
15
  },
package/src/logger.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../../../packages/ai/agent-mcp/src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CACtB;IACI,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,MAAM;IACzC,0EAA0E;IAC1E,IAAI,EAAE,SAAS;CAClB;AACD,oCAAoC;AACpC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CACtB,CAAC"}
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../../../packages/ai/agent-mcp/src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CACtB;IACI,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK;IAC3B,0EAA0E;IAC1E,IAAI,EAAE,SAAS;CAClB;AACD,oCAAoC;AACpC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CACtB,CAAC"}