@adhd/agent-mcp 0.0.9 → 1.0.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/0004_brief_shocker.sql +4 -0
- package/drizzle/0005_clear_lenny_balinger.sql +25 -0
- package/drizzle/meta/0004_snapshot.json +551 -0
- package/drizzle/meta/0005_snapshot.json +545 -0
- package/drizzle/meta/_journal.json +14 -0
- package/package.json +1 -1
- package/src/__tests__/integration/harness.d.ts +195 -0
- package/src/__tests__/integration/harness.d.ts.map +1 -0
- package/src/__tests__/integration/harness.js +396 -0
- package/src/__tests__/integration/harness.js.map +1 -0
- package/src/__tests__/integration/scripted-provider.d.ts +44 -0
- package/src/__tests__/integration/scripted-provider.d.ts.map +1 -0
- package/src/__tests__/integration/scripted-provider.js +82 -0
- package/src/__tests__/integration/scripted-provider.js.map +1 -0
- package/src/clients/registry.d.ts +17 -0
- package/src/clients/registry.d.ts.map +1 -1
- package/src/clients/registry.js +45 -6
- package/src/clients/registry.js.map +1 -1
- package/src/clients/tool-naming.d.ts +20 -0
- package/src/clients/tool-naming.d.ts.map +1 -0
- package/src/clients/tool-naming.js +22 -0
- package/src/clients/tool-naming.js.map +1 -0
- package/src/db/client.d.ts +1 -0
- package/src/db/client.d.ts.map +1 -1
- package/src/db/client.js +1 -1
- package/src/db/client.js.map +1 -1
- package/src/db/migrate-runner.d.ts +38 -0
- package/src/db/migrate-runner.d.ts.map +1 -0
- package/src/db/migrate-runner.js +41 -0
- package/src/db/migrate-runner.js.map +1 -0
- package/src/db/migrate.d.ts +3 -0
- package/src/db/migrate.d.ts.map +1 -1
- package/src/db/migrate.js +6 -5
- package/src/db/migrate.js.map +1 -1
- package/src/db/schema.d.ts +96 -3
- package/src/db/schema.d.ts.map +1 -1
- package/src/db/schema.js +16 -6
- package/src/db/schema.js.map +1 -1
- package/src/engine/dag-engine.d.ts +62 -0
- package/src/engine/dag-engine.d.ts.map +1 -0
- package/src/engine/dag-engine.js +158 -0
- package/src/engine/dag-engine.js.map +1 -0
- package/src/engine/orchestrator.d.ts +14 -0
- package/src/engine/orchestrator.d.ts.map +1 -1
- package/src/engine/orchestrator.js +202 -57
- package/src/engine/orchestrator.js.map +1 -1
- package/src/engine/queue.d.ts +6 -0
- package/src/engine/queue.d.ts.map +1 -1
- package/src/engine/queue.js +8 -0
- package/src/engine/queue.js.map +1 -1
- package/src/index.js +75 -0
- package/src/index.js.map +1 -1
- package/src/providers/anthropic.d.ts.map +1 -1
- package/src/providers/anthropic.js +22 -3
- package/src/providers/anthropic.js.map +1 -1
- package/src/server.d.ts +18 -0
- package/src/server.d.ts.map +1 -1
- package/src/server.js +25 -2
- package/src/server.js.map +1 -1
- package/src/store/task-store.d.ts +7 -1
- package/src/store/task-store.d.ts.map +1 -1
- package/src/store/task-store.js +37 -5
- package/src/store/task-store.js.map +1 -1
- package/src/streaming/event-bus.d.ts +28 -0
- package/src/streaming/event-bus.d.ts.map +1 -0
- package/src/streaming/event-bus.js +12 -0
- package/src/streaming/event-bus.js.map +1 -0
- package/src/streaming/sse-server.d.ts +4 -0
- package/src/streaming/sse-server.d.ts.map +1 -0
- package/src/streaming/sse-server.js +95 -0
- package/src/streaming/sse-server.js.map +1 -0
- package/src/tools/task.d.ts +35 -0
- package/src/tools/task.d.ts.map +1 -1
- package/src/tools/task.js +200 -36
- package/src/tools/task.js.map +1 -1
- package/src/validation/agent.d.ts +3 -0
- package/src/validation/agent.d.ts.map +1 -1
- package/src/validation/agent.js +7 -0
- package/src/validation/agent.js.map +1 -1
- package/src/validation/errors.d.ts +1 -0
- package/src/validation/errors.d.ts.map +1 -1
- package/src/validation/errors.js +1 -0
- package/src/validation/errors.js.map +1 -1
- package/src/validation/execution.d.ts +2 -0
- package/src/validation/execution.d.ts.map +1 -1
- package/src/validation/execution.js +5 -0
- package/src/validation/execution.js.map +1 -1
- package/src/validation/task.d.ts +31 -1
- package/src/validation/task.d.ts.map +1 -1
- package/src/validation/task.js +24 -1
- package/src/validation/task.js.map +1 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ScriptedProvider — deterministic LLM provider for integration tests.
|
|
3
|
+
*
|
|
4
|
+
* Implements the real LLMProvider interface.
|
|
5
|
+
* Returns programmable responses per chat() call in sequence.
|
|
6
|
+
* After all scripted turns are exhausted, defaults to a "completed" response.
|
|
7
|
+
*
|
|
8
|
+
* Supported turn types:
|
|
9
|
+
* - "completed" → returns stopReason "completed" with given content
|
|
10
|
+
* - "tool_calls" → returns stopReason "tool_calls" with given tool calls
|
|
11
|
+
* - "hitl" → returns a single request_human_input tool call
|
|
12
|
+
*
|
|
13
|
+
* Supports a beforeCall hook so tool stubs can coordinate with Latches.
|
|
14
|
+
*/
|
|
15
|
+
import { generateId } from "../../utils/ids.js";
|
|
16
|
+
import { nowIso } from "../../utils/timestamps.js";
|
|
17
|
+
export class ScriptedProvider {
|
|
18
|
+
turns;
|
|
19
|
+
callIndex = 0;
|
|
20
|
+
/**
|
|
21
|
+
* Optional hook invoked at the START of each chat() call (before returning).
|
|
22
|
+
* Receives the call index (0-based) so tests can key on specific turns.
|
|
23
|
+
*/
|
|
24
|
+
beforeCall;
|
|
25
|
+
constructor(turns) {
|
|
26
|
+
this.turns = turns;
|
|
27
|
+
}
|
|
28
|
+
async chat() {
|
|
29
|
+
const idx = this.callIndex++;
|
|
30
|
+
if (this.beforeCall) {
|
|
31
|
+
await this.beforeCall(idx);
|
|
32
|
+
}
|
|
33
|
+
const turn = this.turns[idx] ?? { type: "completed", content: "done" };
|
|
34
|
+
const sessionId = generateId();
|
|
35
|
+
if (turn.type === "completed") {
|
|
36
|
+
const msg = {
|
|
37
|
+
id: generateId(),
|
|
38
|
+
sessionId,
|
|
39
|
+
role: "assistant",
|
|
40
|
+
content: turn.content,
|
|
41
|
+
createdAt: nowIso(),
|
|
42
|
+
};
|
|
43
|
+
return { message: msg, stopReason: "completed" };
|
|
44
|
+
}
|
|
45
|
+
if (turn.type === "hitl") {
|
|
46
|
+
const callId = generateId();
|
|
47
|
+
const msg = {
|
|
48
|
+
id: generateId(),
|
|
49
|
+
sessionId,
|
|
50
|
+
role: "assistant",
|
|
51
|
+
content: undefined,
|
|
52
|
+
toolCalls: [
|
|
53
|
+
{
|
|
54
|
+
id: callId,
|
|
55
|
+
server: "builtin",
|
|
56
|
+
tool: "request_human_input",
|
|
57
|
+
arguments: { prompt: turn.prompt },
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
createdAt: nowIso(),
|
|
61
|
+
};
|
|
62
|
+
return { message: msg, stopReason: "tool_calls" };
|
|
63
|
+
}
|
|
64
|
+
// type === "tool_calls"
|
|
65
|
+
const calls = turn.toolCalls.map((spec) => ({
|
|
66
|
+
id: spec.id ?? generateId(),
|
|
67
|
+
server: spec.server,
|
|
68
|
+
tool: spec.tool,
|
|
69
|
+
arguments: spec.arguments,
|
|
70
|
+
}));
|
|
71
|
+
const msg = {
|
|
72
|
+
id: generateId(),
|
|
73
|
+
sessionId,
|
|
74
|
+
role: "assistant",
|
|
75
|
+
content: undefined,
|
|
76
|
+
toolCalls: calls,
|
|
77
|
+
createdAt: nowIso(),
|
|
78
|
+
};
|
|
79
|
+
return { message: msg, stopReason: "tool_calls" };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=scripted-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scripted-provider.js","sourceRoot":"","sources":["../../../../../../../packages/ai/agent-mcp/src/__tests__/integration/scripted-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAenD,MAAM,OAAO,gBAAgB;IACR,KAAK,CAAiB;IAC/B,SAAS,GAAG,CAAC,CAAC;IAEtB;;;OAGG;IACH,UAAU,CAAwC;IAElD,YAAY,KAAqB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tD,CAAC;QAED,wBAAwB;QACxB,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACxC,EAAE,EAAE,IAAI,CAAC,EAAE,IAAI,UAAU,EAAE;YAC3B,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,SAAS;SAC5B,CAAC,CAAC,CAAC;QAEJ,MAAM,GAAG,GAAY;YACjB,EAAE,EAAE,UAAU,EAAE;YAChB,SAAS;YACT,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,SAAS;YAClB,SAAS,EAAE,KAAK;YAChB,SAAS,EAAE,MAAM,EAAE;SACtB,CAAC;QAEF,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC;IACtD,CAAC;CACJ"}
|
|
@@ -21,8 +21,15 @@ export declare class McpClientRegistry {
|
|
|
21
21
|
private readonly context;
|
|
22
22
|
private readonly clients;
|
|
23
23
|
private readonly connectPromises;
|
|
24
|
+
private readonly toolTargets;
|
|
24
25
|
constructor(mcpServers: Record<string, McpServerConfig>, selfUrl: string | undefined, inProcessDescriptors: InProcessToolDescriptor[], inProcessHandler: InProcessToolHandler, context: ExecutionContext);
|
|
25
26
|
private isSelfReferential;
|
|
27
|
+
/**
|
|
28
|
+
* Map a (possibly model-normalized) server name back to a configured key.
|
|
29
|
+
* OpenAI-compatible/local models rewrite '-' → '_', so a tool call to
|
|
30
|
+
* 'agent_mcp__…' must still resolve to the configured 'agent-mcp' server.
|
|
31
|
+
*/
|
|
32
|
+
private resolveServerName;
|
|
26
33
|
private getOrCreateClient;
|
|
27
34
|
/** Get a client for a specific server, connecting lazily if needed */
|
|
28
35
|
getClient(name: string): Promise<IMcpClient>;
|
|
@@ -31,6 +38,16 @@ export declare class McpClientRegistry {
|
|
|
31
38
|
* Prefixes each tool name with "<server>__<tool>" for disambiguation.
|
|
32
39
|
*/
|
|
33
40
|
listAllTools(): Promise<ToolDefinition[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Resolve a tool name AS RETURNED BY A MODEL back to its real { server, tool }.
|
|
43
|
+
* Tries the exact advertised name, then the normalized form (handles models
|
|
44
|
+
* that rewrite '-' → '_'), then falls back to a literal `__` split for names
|
|
45
|
+
* the registry never advertised (preserves prior behavior).
|
|
46
|
+
*/
|
|
47
|
+
resolveToolName(advertised: string): {
|
|
48
|
+
server: string;
|
|
49
|
+
tool: string;
|
|
50
|
+
};
|
|
34
51
|
/** Tear down all clients — called from Orchestrator's finally block */
|
|
35
52
|
closeAll(): Promise<void>;
|
|
36
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/clients/registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAIrF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/clients/registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAIrF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C;;;;;;;;;;GAUG;AACH,qBAAa,iBAAiB;IAStB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IACrC,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAZ5B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;IACzD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAoC;IAIpE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAuD;gBAG9D,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EAC3C,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,oBAAoB,EAAE,uBAAuB,EAAE,EAC/C,gBAAgB,EAAE,oBAAoB,EACtC,OAAO,EAAE,gBAAgB;IAG9C,OAAO,CAAC,iBAAiB;IAczB;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;YAMX,iBAAiB;IAkD/B,sEAAsE;IAChE,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAIlD;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IA4B/C;;;;;OAKG;IACH,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE;IAcrE,uEAAuE;IACjE,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAgBlC"}
|
package/src/clients/registry.js
CHANGED
|
@@ -2,6 +2,7 @@ import { logger } from "../logger.js";
|
|
|
2
2
|
import { InProcessMcpClient } from "./in-process.js";
|
|
3
3
|
import { HttpMcpClient, SseMcpClient } from "./http-client.js";
|
|
4
4
|
import { StdioMcpClient } from "./stdio-client.js";
|
|
5
|
+
import { TOOL_NAME_SEPARATOR, normalizeToolName } from "./tool-naming.js";
|
|
5
6
|
/**
|
|
6
7
|
* McpClientRegistry — per-task lifetime.
|
|
7
8
|
*
|
|
@@ -21,6 +22,10 @@ export class McpClientRegistry {
|
|
|
21
22
|
context;
|
|
22
23
|
clients = new Map();
|
|
23
24
|
connectPromises = new Map();
|
|
25
|
+
// advertised tool name (and its normalized form) → real { server, tool }.
|
|
26
|
+
// Populated by listAllTools(); lets resolveToolName() recover the real target
|
|
27
|
+
// even when a model rewrites '-' → '_' in the name it calls back with.
|
|
28
|
+
toolTargets = new Map();
|
|
24
29
|
constructor(mcpServers, selfUrl, inProcessDescriptors, inProcessHandler, context) {
|
|
25
30
|
this.mcpServers = mcpServers;
|
|
26
31
|
this.selfUrl = selfUrl;
|
|
@@ -38,13 +43,25 @@ export class McpClientRegistry {
|
|
|
38
43
|
}
|
|
39
44
|
return false;
|
|
40
45
|
}
|
|
41
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Map a (possibly model-normalized) server name back to a configured key.
|
|
48
|
+
* OpenAI-compatible/local models rewrite '-' → '_', so a tool call to
|
|
49
|
+
* 'agent_mcp__…' must still resolve to the configured 'agent-mcp' server.
|
|
50
|
+
*/
|
|
51
|
+
resolveServerName(name) {
|
|
52
|
+
if (this.mcpServers[name])
|
|
53
|
+
return name;
|
|
54
|
+
const norm = normalizeToolName(name);
|
|
55
|
+
return Object.keys(this.mcpServers).find((k) => normalizeToolName(k) === norm) ?? name;
|
|
56
|
+
}
|
|
57
|
+
async getOrCreateClient(rawName) {
|
|
58
|
+
const name = this.resolveServerName(rawName);
|
|
42
59
|
const existing = this.clients.get(name);
|
|
43
60
|
if (existing)
|
|
44
61
|
return existing;
|
|
45
62
|
const config = this.mcpServers[name];
|
|
46
63
|
if (!config) {
|
|
47
|
-
throw new Error(`No MCP server config found for server: '${
|
|
64
|
+
throw new Error(`No MCP server config found for server: '${rawName}'`);
|
|
48
65
|
}
|
|
49
66
|
if (this.isSelfReferential(name, config)) {
|
|
50
67
|
const client = new InProcessMcpClient(this.inProcessDescriptors, this.inProcessHandler, this.context);
|
|
@@ -94,10 +111,13 @@ export class McpClientRegistry {
|
|
|
94
111
|
const client = await this.getOrCreateClient(serverName);
|
|
95
112
|
const tools = await client.listTools();
|
|
96
113
|
for (const tool of tools) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
114
|
+
const advertised = `${serverName}${TOOL_NAME_SEPARATOR}${tool.name}`;
|
|
115
|
+
const target = { server: serverName, tool: tool.name };
|
|
116
|
+
// Index both the advertised name and its normalized form so a
|
|
117
|
+
// model that rewrites '-' → '_' still resolves to the real target.
|
|
118
|
+
this.toolTargets.set(advertised, target);
|
|
119
|
+
this.toolTargets.set(normalizeToolName(advertised), target);
|
|
120
|
+
allTools.push({ ...tool, name: advertised });
|
|
101
121
|
}
|
|
102
122
|
}
|
|
103
123
|
catch (error) {
|
|
@@ -106,6 +126,25 @@ export class McpClientRegistry {
|
|
|
106
126
|
}
|
|
107
127
|
return allTools;
|
|
108
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Resolve a tool name AS RETURNED BY A MODEL back to its real { server, tool }.
|
|
131
|
+
* Tries the exact advertised name, then the normalized form (handles models
|
|
132
|
+
* that rewrite '-' → '_'), then falls back to a literal `__` split for names
|
|
133
|
+
* the registry never advertised (preserves prior behavior).
|
|
134
|
+
*/
|
|
135
|
+
resolveToolName(advertised) {
|
|
136
|
+
const hit = this.toolTargets.get(advertised) ??
|
|
137
|
+
this.toolTargets.get(normalizeToolName(advertised));
|
|
138
|
+
if (hit)
|
|
139
|
+
return hit;
|
|
140
|
+
const i = advertised.indexOf(TOOL_NAME_SEPARATOR);
|
|
141
|
+
return i === -1
|
|
142
|
+
? { server: advertised, tool: advertised }
|
|
143
|
+
: {
|
|
144
|
+
server: advertised.slice(0, i),
|
|
145
|
+
tool: advertised.slice(i + TOOL_NAME_SEPARATOR.length),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
109
148
|
/** Tear down all clients — called from Orchestrator's finally block */
|
|
110
149
|
async closeAll() {
|
|
111
150
|
const closePromises = Array.from(this.clients.entries()).map(async ([name, client]) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/clients/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAItC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/clients/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAItC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1E;;;;;;;;;;GAUG;AACH,MAAM,OAAO,iBAAiB;IASL;IACA;IACA;IACA;IACA;IAZJ,OAAO,GAAG,IAAI,GAAG,EAAsB,CAAC;IACxC,eAAe,GAAG,IAAI,GAAG,EAAyB,CAAC;IACpE,0EAA0E;IAC1E,8EAA8E;IAC9E,uEAAuE;IACtD,WAAW,GAAG,IAAI,GAAG,EAA4C,CAAC;IAEnF,YACqB,UAA2C,EAC3C,OAA2B,EAC3B,oBAA+C,EAC/C,gBAAsC,EACtC,OAAyB;QAJzB,eAAU,GAAV,UAAU,CAAiC;QAC3C,YAAO,GAAP,OAAO,CAAoB;QAC3B,yBAAoB,GAApB,oBAAoB,CAA2B;QAC/C,qBAAgB,GAAhB,gBAAgB,CAAsB;QACtC,YAAO,GAAP,OAAO,CA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C;QACL,CAAC,CACJ,CAAC;QAEF,MAAM,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;QACxC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IACjC,CAAC;CACJ"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool-name encoding shared across the registry and the orchestrator.
|
|
3
|
+
*
|
|
4
|
+
* Tools are advertised to the model as `<server>__<tool>`. Many OpenAI-compatible
|
|
5
|
+
* and local models (e.g. LM Studio / qwen) restrict function names to
|
|
6
|
+
* `[A-Za-z0-9_]` and silently rewrite other characters — notably `-` → `_` — so
|
|
7
|
+
* an advertised `agent-mcp__agent` comes back from the model as
|
|
8
|
+
* `agent_mcp__agent`. A literal lookup then fails ("No MCP server config found
|
|
9
|
+
* for server: 'agent_mcp'"), which breaks recursion (the `agent-mcp` key) and any
|
|
10
|
+
* MCP server whose name contains a hyphen. Anthropic preserves the name, so this
|
|
11
|
+
* only bites the OpenAI-compatible providers — but the round-trip must be robust
|
|
12
|
+
* for ALL of them.
|
|
13
|
+
*
|
|
14
|
+
* The fix: index both the advertised name and its normalized form, and normalize
|
|
15
|
+
* the model's returned name the same way before resolving.
|
|
16
|
+
*/
|
|
17
|
+
export declare const TOOL_NAME_SEPARATOR = "__";
|
|
18
|
+
/** Normalize a tool name to the charset models restrict function names to. */
|
|
19
|
+
export declare function normalizeToolName(name: string): string;
|
|
20
|
+
//# sourceMappingURL=tool-naming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-naming.d.ts","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/clients/tool-naming.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC,8EAA8E;AAC9E,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool-name encoding shared across the registry and the orchestrator.
|
|
3
|
+
*
|
|
4
|
+
* Tools are advertised to the model as `<server>__<tool>`. Many OpenAI-compatible
|
|
5
|
+
* and local models (e.g. LM Studio / qwen) restrict function names to
|
|
6
|
+
* `[A-Za-z0-9_]` and silently rewrite other characters — notably `-` → `_` — so
|
|
7
|
+
* an advertised `agent-mcp__agent` comes back from the model as
|
|
8
|
+
* `agent_mcp__agent`. A literal lookup then fails ("No MCP server config found
|
|
9
|
+
* for server: 'agent_mcp'"), which breaks recursion (the `agent-mcp` key) and any
|
|
10
|
+
* MCP server whose name contains a hyphen. Anthropic preserves the name, so this
|
|
11
|
+
* only bites the OpenAI-compatible providers — but the round-trip must be robust
|
|
12
|
+
* for ALL of them.
|
|
13
|
+
*
|
|
14
|
+
* The fix: index both the advertised name and its normalized form, and normalize
|
|
15
|
+
* the model's returned name the same way before resolving.
|
|
16
|
+
*/
|
|
17
|
+
export const TOOL_NAME_SEPARATOR = "__";
|
|
18
|
+
/** Normalize a tool name to the charset models restrict function names to. */
|
|
19
|
+
export function normalizeToolName(name) {
|
|
20
|
+
return name.replace(/[^A-Za-z0-9_]/g, "_");
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=tool-naming.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-naming.js","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/clients/tool-naming.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAExC,8EAA8E;AAC9E,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC1C,OAAO,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;AAC/C,CAAC"}
|
package/src/db/client.d.ts
CHANGED
package/src/db/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/db/client.ts"],"names":[],"mappings":"AAGA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAGtC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/db/client.ts"],"names":[],"mappings":"AAGA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAGtC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAkBtC,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,QACA,CAAC;AAK/B,eAAO,MAAM,EAAE;;CAA8B,CAAC"}
|
package/src/db/client.js
CHANGED
|
@@ -12,7 +12,7 @@ if (!fs.existsSync(directory)) {
|
|
|
12
12
|
recursive: true
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
-
const sqlite = new Database(resolvedPath);
|
|
15
|
+
export const sqlite = new Database(resolvedPath);
|
|
16
16
|
sqlite.pragma("journal_mode = WAL");
|
|
17
17
|
sqlite.pragma("foreign_keys = ON");
|
|
18
18
|
export const db = drizzle(sqlite, { schema });
|
package/src/db/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/db/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,MAAM,YAAY,GACd,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IAC5B,kBAAkB,CAAC;AAEvB,MAAM,YAAY,GACd,IAA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|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { migrate } from "drizzle-orm/better-sqlite3/migrator";
|
|
2
|
+
/**
|
|
3
|
+
* Folder holding the drizzle-kit generated migrations (../../drizzle relative
|
|
4
|
+
* to this compiled module). Kept here — with no `client.js` import — so test
|
|
5
|
+
* harnesses can reuse the FK-safe runner without dragging in the production
|
|
6
|
+
* singleton connection (which opens a DB file at import time).
|
|
7
|
+
*/
|
|
8
|
+
export declare const MIGRATIONS_FOLDER: string;
|
|
9
|
+
/**
|
|
10
|
+
* Minimal structural type for the bits of a better-sqlite3 connection we need.
|
|
11
|
+
* Avoids importing the better-sqlite3 type just to call `pragma`.
|
|
12
|
+
*/
|
|
13
|
+
interface PragmaConn {
|
|
14
|
+
pragma(source: string, options?: {
|
|
15
|
+
simple: boolean;
|
|
16
|
+
}): unknown;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Run Drizzle migrations against an explicit connection with foreign-key
|
|
20
|
+
* enforcement disabled for the duration of the run.
|
|
21
|
+
*
|
|
22
|
+
* WHY THIS WRAPPER EXISTS: SQLite silently ignores `PRAGMA foreign_keys`
|
|
23
|
+
* **inside a transaction**, and drizzle's migrator wraps each migration file in
|
|
24
|
+
* one. SQLite's only way to alter table constraints is the table-recreate dance
|
|
25
|
+
* (CREATE `__new_x` → INSERT-SELECT → DROP `x` → RENAME). When such a migration
|
|
26
|
+
* runs with FK enforcement ON (which both production `client.ts` and the test
|
|
27
|
+
* harness set), the `DROP TABLE` cascade-deletes every child row — e.g. all of
|
|
28
|
+
* `task_events`, which has `task_id … ON DELETE CASCADE` — even though
|
|
29
|
+
* drizzle-kit emits `PRAGMA foreign_keys=OFF` as the migration's first
|
|
30
|
+
* statement (that statement is the no-op described above). The 0005 migration
|
|
31
|
+
* recreates `tasks`, so without this wrapper a real upgrade wipes a user's
|
|
32
|
+
* entire task-event history. Disabling enforcement on the connection *before*
|
|
33
|
+
* migrate() — while no transaction is open — is the only way to make it hold
|
|
34
|
+
* for the whole run; we restore the prior setting afterwards.
|
|
35
|
+
*/
|
|
36
|
+
export declare function runMigrationsOn(conn: PragmaConn, drizzleDb: Parameters<typeof migrate>[0], migrationsFolder?: string): void;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=migrate-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-runner.d.ts","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/db/migrate-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAE9D;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,QAGpB,CAAC;AAEX;;;GAGG;AACH,UAAU,UAAU;IAChB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC;CAClE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAC3B,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC,EACxC,gBAAgB,GAAE,MAA0B,GAC7C,IAAI,CAeN"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { migrate } from "drizzle-orm/better-sqlite3/migrator";
|
|
2
|
+
/**
|
|
3
|
+
* Folder holding the drizzle-kit generated migrations (../../drizzle relative
|
|
4
|
+
* to this compiled module). Kept here — with no `client.js` import — so test
|
|
5
|
+
* harnesses can reuse the FK-safe runner without dragging in the production
|
|
6
|
+
* singleton connection (which opens a DB file at import time).
|
|
7
|
+
*/
|
|
8
|
+
export const MIGRATIONS_FOLDER = new URL("../../drizzle", import.meta.url).pathname;
|
|
9
|
+
/**
|
|
10
|
+
* Run Drizzle migrations against an explicit connection with foreign-key
|
|
11
|
+
* enforcement disabled for the duration of the run.
|
|
12
|
+
*
|
|
13
|
+
* WHY THIS WRAPPER EXISTS: SQLite silently ignores `PRAGMA foreign_keys`
|
|
14
|
+
* **inside a transaction**, and drizzle's migrator wraps each migration file in
|
|
15
|
+
* one. SQLite's only way to alter table constraints is the table-recreate dance
|
|
16
|
+
* (CREATE `__new_x` → INSERT-SELECT → DROP `x` → RENAME). When such a migration
|
|
17
|
+
* runs with FK enforcement ON (which both production `client.ts` and the test
|
|
18
|
+
* harness set), the `DROP TABLE` cascade-deletes every child row — e.g. all of
|
|
19
|
+
* `task_events`, which has `task_id … ON DELETE CASCADE` — even though
|
|
20
|
+
* drizzle-kit emits `PRAGMA foreign_keys=OFF` as the migration's first
|
|
21
|
+
* statement (that statement is the no-op described above). The 0005 migration
|
|
22
|
+
* recreates `tasks`, so without this wrapper a real upgrade wipes a user's
|
|
23
|
+
* entire task-event history. Disabling enforcement on the connection *before*
|
|
24
|
+
* migrate() — while no transaction is open — is the only way to make it hold
|
|
25
|
+
* for the whole run; we restore the prior setting afterwards.
|
|
26
|
+
*/
|
|
27
|
+
export function runMigrationsOn(conn, drizzleDb, migrationsFolder = MIGRATIONS_FOLDER) {
|
|
28
|
+
const fkWasOn = conn.pragma("foreign_keys", { simple: true }) === 1;
|
|
29
|
+
if (fkWasOn) {
|
|
30
|
+
conn.pragma("foreign_keys = OFF");
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
migrate(drizzleDb, { migrationsFolder });
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
if (fkWasOn) {
|
|
37
|
+
conn.pragma("foreign_keys = ON");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=migrate-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-runner.js","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/db/migrate-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,GAAG,CACpC,eAAe,EACf,MAAM,CAAC,IAAI,CAAC,GAAG,CAClB,CAAC,QAAQ,CAAC;AAUX;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,eAAe,CAC3B,IAAgB,EAChB,SAAwC,EACxC,mBAA2B,iBAAiB;IAE5C,MAAM,OAAO,GACT,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;IAExD,IAAI,OAAO,EAAE,CAAC;QACV,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;IACtC,CAAC;IAED,IAAI,CAAC;QACD,OAAO,CAAC,SAAS,EAAE,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAC7C,CAAC;YAAS,CAAC;QACP,IAAI,OAAO,EAAE,CAAC;YACV,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;QACrC,CAAC;IACL,CAAC;AACL,CAAC"}
|
package/src/db/migrate.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Runs pending Drizzle migrations synchronously before the server starts.
|
|
3
3
|
* Migrations are read from the ./drizzle folder (generated by drizzle-kit).
|
|
4
|
+
*
|
|
5
|
+
* Delegates to the FK-safe {@link runMigrationsOn} runner (see that module for
|
|
6
|
+
* why foreign-key enforcement must be toggled around the migration run).
|
|
4
7
|
*/
|
|
5
8
|
export declare function runMigrations(): void;
|
|
6
9
|
//# sourceMappingURL=migrate.d.ts.map
|
package/src/db/migrate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/db/migrate.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/db/migrate.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAgB,aAAa,IAAI,IAAI,CAEpC"}
|
package/src/db/migrate.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { db, sqlite } from "./client.js";
|
|
2
|
+
import { runMigrationsOn } from "./migrate-runner.js";
|
|
3
3
|
/**
|
|
4
4
|
* Runs pending Drizzle migrations synchronously before the server starts.
|
|
5
5
|
* Migrations are read from the ./drizzle folder (generated by drizzle-kit).
|
|
6
|
+
*
|
|
7
|
+
* Delegates to the FK-safe {@link runMigrationsOn} runner (see that module for
|
|
8
|
+
* why foreign-key enforcement must be toggled around the migration run).
|
|
6
9
|
*/
|
|
7
10
|
export function runMigrations() {
|
|
8
|
-
|
|
9
|
-
migrationsFolder: new URL("../../drizzle", import.meta.url).pathname
|
|
10
|
-
});
|
|
11
|
+
runMigrationsOn(sqlite, db);
|
|
11
12
|
}
|
|
12
13
|
//# sourceMappingURL=migrate.js.map
|
package/src/db/migrate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/db/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/db/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,UAAU,aAAa;IACzB,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAChC,CAAC"}
|
package/src/db/schema.d.ts
CHANGED
|
@@ -425,7 +425,7 @@ export declare const tasksTable: import("drizzle-orm/sqlite-core").SQLiteTableWi
|
|
|
425
425
|
columnType: "SQLiteText";
|
|
426
426
|
data: string;
|
|
427
427
|
driverParam: string;
|
|
428
|
-
notNull:
|
|
428
|
+
notNull: false;
|
|
429
429
|
hasDefault: false;
|
|
430
430
|
isPrimaryKey: false;
|
|
431
431
|
isAutoincrement: false;
|
|
@@ -456,6 +456,23 @@ export declare const tasksTable: import("drizzle-orm/sqlite-core").SQLiteTableWi
|
|
|
456
456
|
}, {}, {
|
|
457
457
|
length: number | undefined;
|
|
458
458
|
}>;
|
|
459
|
+
isEphemeral: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
460
|
+
name: "is_ephemeral";
|
|
461
|
+
tableName: "tasks";
|
|
462
|
+
dataType: "number";
|
|
463
|
+
columnType: "SQLiteInteger";
|
|
464
|
+
data: number;
|
|
465
|
+
driverParam: number;
|
|
466
|
+
notNull: true;
|
|
467
|
+
hasDefault: true;
|
|
468
|
+
isPrimaryKey: false;
|
|
469
|
+
isAutoincrement: false;
|
|
470
|
+
hasRuntimeDefault: false;
|
|
471
|
+
enumValues: undefined;
|
|
472
|
+
baseColumn: never;
|
|
473
|
+
identity: undefined;
|
|
474
|
+
generated: undefined;
|
|
475
|
+
}, {}, {}>;
|
|
459
476
|
recursionDepth: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
460
477
|
name: "recursion_depth";
|
|
461
478
|
tableName: "tasks";
|
|
@@ -478,14 +495,14 @@ export declare const tasksTable: import("drizzle-orm/sqlite-core").SQLiteTableWi
|
|
|
478
495
|
tableName: "tasks";
|
|
479
496
|
dataType: "string";
|
|
480
497
|
columnType: "SQLiteText";
|
|
481
|
-
data: "pending" | "running" | "completed" | "failed" | "cancelled";
|
|
498
|
+
data: "pending" | "running" | "completed" | "failed" | "cancelled" | "waiting" | "awaiting_input";
|
|
482
499
|
driverParam: string;
|
|
483
500
|
notNull: true;
|
|
484
501
|
hasDefault: true;
|
|
485
502
|
isPrimaryKey: false;
|
|
486
503
|
isAutoincrement: false;
|
|
487
504
|
hasRuntimeDefault: false;
|
|
488
|
-
enumValues: ["pending", "running", "completed", "failed", "cancelled"];
|
|
505
|
+
enumValues: ["pending", "running", "completed", "failed", "cancelled", "waiting", "awaiting_input"];
|
|
489
506
|
baseColumn: never;
|
|
490
507
|
identity: undefined;
|
|
491
508
|
generated: undefined;
|
|
@@ -625,6 +642,82 @@ export declare const tasksTable: import("drizzle-orm/sqlite-core").SQLiteTableWi
|
|
|
625
642
|
}, {}, {
|
|
626
643
|
length: number | undefined;
|
|
627
644
|
}>;
|
|
645
|
+
depends_on: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
646
|
+
name: "depends_on";
|
|
647
|
+
tableName: "tasks";
|
|
648
|
+
dataType: "string";
|
|
649
|
+
columnType: "SQLiteText";
|
|
650
|
+
data: string;
|
|
651
|
+
driverParam: string;
|
|
652
|
+
notNull: false;
|
|
653
|
+
hasDefault: false;
|
|
654
|
+
isPrimaryKey: false;
|
|
655
|
+
isAutoincrement: false;
|
|
656
|
+
hasRuntimeDefault: false;
|
|
657
|
+
enumValues: [string, ...string[]];
|
|
658
|
+
baseColumn: never;
|
|
659
|
+
identity: undefined;
|
|
660
|
+
generated: undefined;
|
|
661
|
+
}, {}, {
|
|
662
|
+
length: number | undefined;
|
|
663
|
+
}>;
|
|
664
|
+
on_upstream_failure: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
665
|
+
name: "on_upstream_failure";
|
|
666
|
+
tableName: "tasks";
|
|
667
|
+
dataType: "string";
|
|
668
|
+
columnType: "SQLiteText";
|
|
669
|
+
data: string;
|
|
670
|
+
driverParam: string;
|
|
671
|
+
notNull: false;
|
|
672
|
+
hasDefault: false;
|
|
673
|
+
isPrimaryKey: false;
|
|
674
|
+
isAutoincrement: false;
|
|
675
|
+
hasRuntimeDefault: false;
|
|
676
|
+
enumValues: [string, ...string[]];
|
|
677
|
+
baseColumn: never;
|
|
678
|
+
identity: undefined;
|
|
679
|
+
generated: undefined;
|
|
680
|
+
}, {}, {
|
|
681
|
+
length: number | undefined;
|
|
682
|
+
}>;
|
|
683
|
+
inputs: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
684
|
+
name: "inputs";
|
|
685
|
+
tableName: "tasks";
|
|
686
|
+
dataType: "string";
|
|
687
|
+
columnType: "SQLiteText";
|
|
688
|
+
data: string;
|
|
689
|
+
driverParam: string;
|
|
690
|
+
notNull: false;
|
|
691
|
+
hasDefault: false;
|
|
692
|
+
isPrimaryKey: false;
|
|
693
|
+
isAutoincrement: false;
|
|
694
|
+
hasRuntimeDefault: false;
|
|
695
|
+
enumValues: [string, ...string[]];
|
|
696
|
+
baseColumn: never;
|
|
697
|
+
identity: undefined;
|
|
698
|
+
generated: undefined;
|
|
699
|
+
}, {}, {
|
|
700
|
+
length: number | undefined;
|
|
701
|
+
}>;
|
|
702
|
+
resume_token: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
703
|
+
name: "resume_token";
|
|
704
|
+
tableName: "tasks";
|
|
705
|
+
dataType: "string";
|
|
706
|
+
columnType: "SQLiteText";
|
|
707
|
+
data: string;
|
|
708
|
+
driverParam: string;
|
|
709
|
+
notNull: false;
|
|
710
|
+
hasDefault: false;
|
|
711
|
+
isPrimaryKey: false;
|
|
712
|
+
isAutoincrement: false;
|
|
713
|
+
hasRuntimeDefault: false;
|
|
714
|
+
enumValues: [string, ...string[]];
|
|
715
|
+
baseColumn: never;
|
|
716
|
+
identity: undefined;
|
|
717
|
+
generated: undefined;
|
|
718
|
+
}, {}, {
|
|
719
|
+
length: number | undefined;
|
|
720
|
+
}>;
|
|
628
721
|
};
|
|
629
722
|
dialect: "sqlite";
|
|
630
723
|
}>;
|
package/src/db/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../../../packages/ai/agent-mcp/src/db/schema.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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