@adhd/agent-mcp 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +236 -0
- package/CHANGELOG.md +115 -0
- package/LICENSE +21 -0
- package/README.md +201 -0
- package/docs/architecture-and-security.md +405 -0
- package/docs/marketing/.catalog/capabilities.md +143 -0
- package/docs/marketing/.catalog/consumer.md +111 -0
- package/docs/marketing/.catalog/distribution.md +223 -0
- package/docs/marketing/.catalog/doc-conformance.md +237 -0
- package/docs/marketing/.catalog/doc-ops.md +98 -0
- package/docs/marketing/.catalog/metrics.md +119 -0
- package/docs/marketing/.catalog/required-tooling.md +224 -0
- package/docs/marketing/.catalog/review.md +164 -0
- package/docs/provider-call-audit.md +254 -0
- package/llms.txt +133 -0
- package/package.json +31 -50
- package/src/__tests__/integration/harness.d.ts +871 -39
- package/src/__tests__/integration/harness.d.ts.map +1 -1
- package/src/__tests__/integration/harness.js +93 -87
- package/src/__tests__/integration/harness.js.map +1 -1
- package/src/__tests__/integration/scripted-provider.d.ts +1 -2
- package/src/__tests__/integration/scripted-provider.d.ts.map +1 -1
- package/src/__tests__/integration/scripted-provider.js +1 -3
- package/src/__tests__/integration/scripted-provider.js.map +1 -1
- package/src/config.d.ts +6 -69
- package/src/config.d.ts.map +1 -1
- package/src/config.js +1 -50
- package/src/config.js.map +1 -1
- package/src/db/client.d.ts +1516 -2
- package/src/db/client.d.ts.map +1 -1
- package/src/db/client.js +4 -2
- package/src/db/client.js.map +1 -1
- package/src/db/migrate-runner.d.ts +0 -28
- package/src/db/migrate-runner.d.ts.map +1 -1
- package/src/db/migrate-runner.js +0 -24
- package/src/db/migrate-runner.js.map +1 -1
- package/src/db/migrate.d.ts +0 -7
- package/src/db/migrate.d.ts.map +1 -1
- package/src/db/migrate.js +0 -7
- package/src/db/migrate.js.map +1 -1
- package/src/db/schema.d.ts +0 -1260
- package/src/db/schema.d.ts.map +1 -1
- package/src/db/schema.js +2 -179
- package/src/db/schema.js.map +1 -1
- package/src/index.d.ts +4 -27
- package/src/index.d.ts.map +1 -1
- package/src/index.js +43 -114
- package/src/index.js.map +1 -1
- package/src/logger.d.ts +0 -8
- package/src/logger.d.ts.map +1 -1
- package/src/logger.js +1 -12
- package/src/logger.js.map +1 -1
- package/src/scripts/agent-mcp-tail.d.ts +3 -0
- package/src/scripts/agent-mcp-tail.d.ts.map +1 -0
- package/src/scripts/agent-mcp-tail.js +227 -0
- package/src/scripts/agent-mcp-tail.js.map +1 -0
- package/src/server.d.ts +13 -34
- package/src/server.d.ts.map +1 -1
- package/src/server.js +234 -326
- package/src/server.js.map +1 -1
- package/src/store/agent-store.d.ts +3 -16
- package/src/store/agent-store.d.ts.map +1 -1
- package/src/store/agent-store.js +38 -41
- package/src/store/agent-store.js.map +1 -1
- package/src/streaming/chat-gateway.d.ts +17 -0
- package/src/streaming/chat-gateway.d.ts.map +1 -0
- package/src/streaming/chat-gateway.js +336 -0
- package/src/streaming/chat-gateway.js.map +1 -0
- package/src/streaming/event-bus.d.ts +4 -0
- package/src/streaming/event-bus.d.ts.map +1 -1
- package/src/streaming/event-bus.js +14 -1
- package/src/streaming/event-bus.js.map +1 -1
- package/src/streaming/sse-server.d.ts +3 -14
- package/src/streaming/sse-server.d.ts.map +1 -1
- package/src/streaming/sse-server.js +37 -37
- package/src/streaming/sse-server.js.map +1 -1
- package/src/utils/load-env.d.ts +0 -14
- package/src/utils/load-env.d.ts.map +1 -1
- package/src/utils/load-env.js +0 -18
- package/src/utils/load-env.js.map +1 -1
- package/drizzle/0000_nifty_sasquatch.sql +0 -55
- package/drizzle/0001_task_usage.sql +0 -16
- package/drizzle/0002_lumpy_silver_centurion.sql +0 -2
- package/drizzle/0003_nifty_shriek.sql +0 -2
- package/drizzle/0004_brief_shocker.sql +0 -4
- package/drizzle/0005_clear_lenny_balinger.sql +0 -25
- package/drizzle/0006_composed_prompts_cache.sql +0 -24
- package/drizzle/meta/0000_snapshot.json +0 -387
- package/drizzle/meta/0001_snapshot.json +0 -495
- package/drizzle/meta/0002_snapshot.json +0 -509
- package/drizzle/meta/0003_snapshot.json +0 -523
- package/drizzle/meta/0004_snapshot.json +0 -551
- package/drizzle/meta/0005_snapshot.json +0 -545
- package/drizzle/meta/0006_snapshot.json +0 -651
- package/drizzle/meta/_journal.json +0 -55
- package/src/clients/http-client.d.ts +0 -24
- package/src/clients/http-client.d.ts.map +0 -1
- package/src/clients/http-client.js +0 -98
- package/src/clients/http-client.js.map +0 -1
- package/src/clients/in-process.d.ts +0 -27
- package/src/clients/in-process.d.ts.map +0 -1
- package/src/clients/in-process.js +0 -37
- package/src/clients/in-process.js.map +0 -1
- package/src/clients/index.d.ts +0 -7
- package/src/clients/index.d.ts.map +0 -1
- package/src/clients/index.js +0 -5
- package/src/clients/index.js.map +0 -1
- package/src/clients/registry.d.ts +0 -54
- package/src/clients/registry.d.ts.map +0 -1
- package/src/clients/registry.js +0 -164
- package/src/clients/registry.js.map +0 -1
- package/src/clients/stdio-client.d.ts +0 -16
- package/src/clients/stdio-client.d.ts.map +0 -1
- package/src/clients/stdio-client.js +0 -97
- package/src/clients/stdio-client.js.map +0 -1
- package/src/clients/tool-naming.d.ts +0 -44
- package/src/clients/tool-naming.d.ts.map +0 -1
- package/src/clients/tool-naming.js +0 -65
- package/src/clients/tool-naming.js.map +0 -1
- package/src/clients/types.d.ts +0 -18
- package/src/clients/types.d.ts.map +0 -1
- package/src/clients/types.js +0 -2
- package/src/clients/types.js.map +0 -1
- package/src/engine/dag-engine.d.ts +0 -62
- package/src/engine/dag-engine.d.ts.map +0 -1
- package/src/engine/dag-engine.js +0 -158
- package/src/engine/dag-engine.js.map +0 -1
- package/src/engine/hooks.d.ts +0 -24
- package/src/engine/hooks.d.ts.map +0 -1
- package/src/engine/hooks.js +0 -50
- package/src/engine/hooks.js.map +0 -1
- package/src/engine/orchestrator.d.ts +0 -40
- package/src/engine/orchestrator.d.ts.map +0 -1
- package/src/engine/orchestrator.js +0 -507
- package/src/engine/orchestrator.js.map +0 -1
- package/src/engine/policy.d.ts +0 -66
- package/src/engine/policy.d.ts.map +0 -1
- package/src/engine/policy.js +0 -112
- package/src/engine/policy.js.map +0 -1
- package/src/engine/prompt-resolver.d.ts +0 -89
- package/src/engine/prompt-resolver.d.ts.map +0 -1
- package/src/engine/prompt-resolver.js +0 -96
- package/src/engine/prompt-resolver.js.map +0 -1
- package/src/engine/queue.d.ts +0 -29
- package/src/engine/queue.d.ts.map +0 -1
- package/src/engine/queue.js +0 -56
- package/src/engine/queue.js.map +0 -1
- package/src/plugins/index.d.ts +0 -2
- package/src/plugins/index.d.ts.map +0 -1
- package/src/plugins/index.js +0 -2
- package/src/plugins/index.js.map +0 -1
- package/src/plugins/loader.d.ts +0 -65
- package/src/plugins/loader.d.ts.map +0 -1
- package/src/plugins/loader.js +0 -222
- package/src/plugins/loader.js.map +0 -1
- package/src/plugins/usage-plugin.d.ts +0 -27
- package/src/plugins/usage-plugin.d.ts.map +0 -1
- package/src/plugins/usage-plugin.js +0 -148
- package/src/plugins/usage-plugin.js.map +0 -1
- package/src/providers/anthropic.d.ts +0 -13
- package/src/providers/anthropic.d.ts.map +0 -1
- package/src/providers/anthropic.js +0 -260
- package/src/providers/anthropic.js.map +0 -1
- package/src/providers/claudecli.d.ts +0 -153
- package/src/providers/claudecli.d.ts.map +0 -1
- package/src/providers/claudecli.js +0 -510
- package/src/providers/claudecli.js.map +0 -1
- package/src/providers/factory.d.ts +0 -10
- package/src/providers/factory.d.ts.map +0 -1
- package/src/providers/factory.js +0 -24
- package/src/providers/factory.js.map +0 -1
- package/src/providers/index.d.ts +0 -6
- package/src/providers/index.d.ts.map +0 -1
- package/src/providers/index.js +0 -5
- package/src/providers/index.js.map +0 -1
- package/src/providers/openai.d.ts +0 -14
- package/src/providers/openai.d.ts.map +0 -1
- package/src/providers/openai.js +0 -162
- package/src/providers/openai.js.map +0 -1
- package/src/providers/types.d.ts +0 -36
- package/src/providers/types.d.ts.map +0 -1
- package/src/providers/types.js +0 -2
- package/src/providers/types.js.map +0 -1
- package/src/store/composed-prompt-store.d.ts +0 -24
- package/src/store/composed-prompt-store.d.ts.map +0 -1
- package/src/store/composed-prompt-store.js +0 -75
- package/src/store/composed-prompt-store.js.map +0 -1
- package/src/store/index.d.ts +0 -5
- package/src/store/index.d.ts.map +0 -1
- package/src/store/index.js +0 -5
- package/src/store/index.js.map +0 -1
- package/src/store/session-store.d.ts +0 -45
- package/src/store/session-store.d.ts.map +0 -1
- package/src/store/session-store.js +0 -197
- package/src/store/session-store.js.map +0 -1
- package/src/store/task-store.d.ts +0 -55
- package/src/store/task-store.d.ts.map +0 -1
- package/src/store/task-store.js +0 -186
- package/src/store/task-store.js.map +0 -1
- package/src/tools/agent-crud.d.ts +0 -15
- package/src/tools/agent-crud.d.ts.map +0 -1
- package/src/tools/agent-crud.js +0 -32
- package/src/tools/agent-crud.js.map +0 -1
- package/src/tools/session.d.ts +0 -33
- package/src/tools/session.d.ts.map +0 -1
- package/src/tools/session.js +0 -73
- package/src/tools/session.js.map +0 -1
- package/src/tools/task.d.ts +0 -86
- package/src/tools/task.d.ts.map +0 -1
- package/src/tools/task.js +0 -406
- package/src/tools/task.js.map +0 -1
- package/src/tools/usage.d.ts +0 -60
- package/src/tools/usage.d.ts.map +0 -1
- package/src/tools/usage.js +0 -174
- package/src/tools/usage.js.map +0 -1
- package/src/types/agent.d.ts +0 -2
- package/src/types/agent.d.ts.map +0 -1
- package/src/types/agent.js +0 -3
- package/src/types/agent.js.map +0 -1
- package/src/types/execution.d.ts +0 -2
- package/src/types/execution.d.ts.map +0 -1
- package/src/types/execution.js +0 -3
- package/src/types/execution.js.map +0 -1
- package/src/types/index.d.ts +0 -2
- package/src/types/index.d.ts.map +0 -1
- package/src/types/index.js +0 -2
- package/src/types/index.js.map +0 -1
- package/src/types/mcp.d.ts +0 -2
- package/src/types/mcp.d.ts.map +0 -1
- package/src/types/mcp.js +0 -3
- package/src/types/mcp.js.map +0 -1
- package/src/types/message.d.ts +0 -2
- package/src/types/message.d.ts.map +0 -1
- package/src/types/message.js +0 -3
- package/src/types/message.js.map +0 -1
- package/src/types/session.d.ts +0 -2
- package/src/types/session.d.ts.map +0 -1
- package/src/types/session.js +0 -3
- package/src/types/session.js.map +0 -1
- package/src/types/task.d.ts +0 -2
- package/src/types/task.d.ts.map +0 -1
- package/src/types/task.js +0 -3
- package/src/types/task.js.map +0 -1
- package/src/utils/ids.d.ts +0 -2
- package/src/utils/ids.d.ts.map +0 -1
- package/src/utils/ids.js +0 -5
- package/src/utils/ids.js.map +0 -1
- package/src/utils/logger.d.ts +0 -2
- package/src/utils/logger.d.ts.map +0 -1
- package/src/utils/logger.js +0 -5
- package/src/utils/logger.js.map +0 -1
- package/src/utils/timestamps.d.ts +0 -2
- package/src/utils/timestamps.d.ts.map +0 -1
- package/src/utils/timestamps.js +0 -4
- package/src/utils/timestamps.js.map +0 -1
- package/src/validation/agent.d.ts +0 -400
- package/src/validation/agent.d.ts.map +0 -1
- package/src/validation/agent.js +0 -251
- package/src/validation/agent.js.map +0 -1
- package/src/validation/agents.d.ts +0 -2
- package/src/validation/agents.d.ts.map +0 -1
- package/src/validation/agents.js +0 -3
- package/src/validation/agents.js.map +0 -1
- package/src/validation/errors.d.ts +0 -32
- package/src/validation/errors.d.ts.map +0 -1
- package/src/validation/errors.js +0 -42
- package/src/validation/errors.js.map +0 -1
- package/src/validation/execution.d.ts +0 -86
- package/src/validation/execution.d.ts.map +0 -1
- package/src/validation/execution.js +0 -28
- package/src/validation/execution.js.map +0 -1
- package/src/validation/index.d.ts +0 -9
- package/src/validation/index.d.ts.map +0 -1
- package/src/validation/index.js +0 -9
- package/src/validation/index.js.map +0 -1
- package/src/validation/mcp.d.ts +0 -42
- package/src/validation/mcp.d.ts.map +0 -1
- package/src/validation/mcp.js +0 -28
- package/src/validation/mcp.js.map +0 -1
- package/src/validation/message.d.ts +0 -43
- package/src/validation/message.d.ts.map +0 -1
- package/src/validation/message.js +0 -23
- package/src/validation/message.js.map +0 -1
- package/src/validation/session.d.ts +0 -49
- package/src/validation/session.d.ts.map +0 -1
- package/src/validation/session.js +0 -34
- package/src/validation/session.js.map +0 -1
- package/src/validation/task.d.ts +0 -146
- package/src/validation/task.d.ts.map +0 -1
- package/src/validation/task.js +0 -95
- package/src/validation/task.js.map +0 -1
- package/src/validation/tasks.d.ts +0 -2
- package/src/validation/tasks.d.ts.map +0 -1
- package/src/validation/tasks.js +0 -3
- package/src/validation/tasks.js.map +0 -1
- package/src/validation/usage.d.ts +0 -89
- package/src/validation/usage.d.ts.map +0 -1
- package/src/validation/usage.js +0 -98
- package/src/validation/usage.js.map +0 -1
package/src/db/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../../entrypoint/agent-mcp/src/db/schema.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMtB,CAAC"}
|
package/src/db/schema.js
CHANGED
|
@@ -1,186 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
// ──────────────────────────────────────────────
|
|
3
|
-
// agents
|
|
4
|
-
// ──────────────────────────────────────────────
|
|
1
|
+
import { sqliteTable, integer, text } from "drizzle-orm/sqlite-core";
|
|
5
2
|
export const agentsTable = sqliteTable("agents", {
|
|
6
3
|
name: text("name").primaryKey(),
|
|
7
4
|
version: integer("version").notNull().default(1),
|
|
8
|
-
data: text("data").notNull(),
|
|
5
|
+
data: text("data").notNull(),
|
|
9
6
|
createdAt: text("created_at").notNull(),
|
|
10
7
|
updatedAt: text("updated_at").notNull(),
|
|
11
8
|
});
|
|
12
|
-
// ──────────────────────────────────────────────
|
|
13
|
-
// sessions
|
|
14
|
-
// ──────────────────────────────────────────────
|
|
15
|
-
export const sessionsTable = sqliteTable("sessions", {
|
|
16
|
-
id: text("id").primaryKey(),
|
|
17
|
-
agentName: text("agent_name")
|
|
18
|
-
.notNull()
|
|
19
|
-
.references(() => agentsTable.name, {
|
|
20
|
-
onDelete: "cascade"
|
|
21
|
-
}),
|
|
22
|
-
agentVersion: integer("agent_version").notNull(),
|
|
23
|
-
// Full JSON snapshot of AgentDefinition at session creation time.
|
|
24
|
-
// Not exposed in the public Session type — accessed only via
|
|
25
|
-
// SessionStore.getAgentDefinition(sessionId).
|
|
26
|
-
agentData: text("agent_data").notNull(),
|
|
27
|
-
status: text("status", {
|
|
28
|
-
enum: ["active", "closed"]
|
|
29
|
-
}).notNull().default("active"),
|
|
30
|
-
createdAt: text("created_at").notNull(),
|
|
31
|
-
updatedAt: text("updated_at").notNull(),
|
|
32
|
-
closedAt: text("closed_at"),
|
|
33
|
-
// Nullable FK → composed_prompts.id; set at session start when the compiler
|
|
34
|
-
// produces or finds a cached compiled prompt. Null for sessions created before
|
|
35
|
-
// the registry integration (backward-compatible additive column).
|
|
36
|
-
composedPromptId: text("composed_prompt_id"),
|
|
37
|
-
});
|
|
38
|
-
// ──────────────────────────────────────────────
|
|
39
|
-
// messages
|
|
40
|
-
// ──────────────────────────────────────────────
|
|
41
|
-
export const messagesTable = sqliteTable("messages", {
|
|
42
|
-
id: text("id").primaryKey(),
|
|
43
|
-
sessionId: text("session_id")
|
|
44
|
-
.notNull()
|
|
45
|
-
.references(() => sessionsTable.id, {
|
|
46
|
-
onDelete: "cascade"
|
|
47
|
-
}),
|
|
48
|
-
role: text("role", {
|
|
49
|
-
enum: ["system", "user", "assistant", "tool"]
|
|
50
|
-
}).notNull(),
|
|
51
|
-
content: text("content"),
|
|
52
|
-
// JSON blobs for tool call / result payloads
|
|
53
|
-
toolCalls: text("tool_calls"),
|
|
54
|
-
toolResults: text("tool_results"),
|
|
55
|
-
createdAt: text("created_at").notNull(),
|
|
56
|
-
});
|
|
57
|
-
// ──────────────────────────────────────────────
|
|
58
|
-
// tasks
|
|
59
|
-
// ──────────────────────────────────────────────
|
|
60
|
-
export const tasksTable = sqliteTable("tasks", {
|
|
61
|
-
id: text("id").primaryKey(),
|
|
62
|
-
// Nullable: ephemeral tasks (agent_name one-shot mode) have no session row.
|
|
63
|
-
// No FK reference: the session may not exist (ephemeral) or may have been
|
|
64
|
-
// deleted; we never want a cascade-delete triggered by session cleanup to
|
|
65
|
-
// destroy task history.
|
|
66
|
-
sessionId: text("session_id"),
|
|
67
|
-
parentTaskId: text("parent_task_id"),
|
|
68
|
-
// SQLite boolean: 0 = session-backed task, 1 = ephemeral one-shot task.
|
|
69
|
-
// Ephemeral tasks persist a tasks row + task_events + task_usage but
|
|
70
|
-
// have no sessions row and no messages rows.
|
|
71
|
-
isEphemeral: integer("is_ephemeral").notNull().default(0),
|
|
72
|
-
recursionDepth: integer("recursion_depth").notNull().default(0),
|
|
73
|
-
status: text("status", {
|
|
74
|
-
enum: ["pending", "running", "completed", "failed", "cancelled", "waiting", "awaiting_input"]
|
|
75
|
-
}).notNull().default("pending"),
|
|
76
|
-
prompt: text("prompt").notNull(),
|
|
77
|
-
result: text("result"),
|
|
78
|
-
error: text("error"),
|
|
79
|
-
createdAt: text("created_at").notNull(),
|
|
80
|
-
updatedAt: text("updated_at").notNull(),
|
|
81
|
-
completedAt: text("completed_at"),
|
|
82
|
-
cancelledAt: text("cancelled_at"),
|
|
83
|
-
// Dependency DAG fields (consumed by task-dependency-dag plan)
|
|
84
|
-
depends_on: text("depends_on"), // nullable JSON array of upstream task IDs
|
|
85
|
-
on_upstream_failure: text("on_upstream_failure"), // nullable: 'fail'|'skip' (default: 'fail')
|
|
86
|
-
inputs: text("inputs"), // nullable JSON blob: upstream taskId→result map
|
|
87
|
-
// HITL suspension field (consumed by hitl-interrupts plan)
|
|
88
|
-
resume_token: text("resume_token"), // nullable UUID written before await
|
|
89
|
-
});
|
|
90
|
-
// ──────────────────────────────────────────────
|
|
91
|
-
// task_events
|
|
92
|
-
// ──────────────────────────────────────────────
|
|
93
|
-
export const taskEventsTable = sqliteTable("task_events", {
|
|
94
|
-
id: text("id").primaryKey(),
|
|
95
|
-
taskId: text("task_id")
|
|
96
|
-
.notNull()
|
|
97
|
-
.references(() => tasksTable.id, {
|
|
98
|
-
onDelete: "cascade"
|
|
99
|
-
}),
|
|
100
|
-
type: text("type", {
|
|
101
|
-
enum: [
|
|
102
|
-
"MODEL_REQUEST",
|
|
103
|
-
"MODEL_RESPONSE",
|
|
104
|
-
"TOOL_CALL",
|
|
105
|
-
"TOOL_RESULT",
|
|
106
|
-
"TASK_COMPLETED",
|
|
107
|
-
"TASK_FAILED",
|
|
108
|
-
"TASK_CANCELLED"
|
|
109
|
-
]
|
|
110
|
-
}).notNull(),
|
|
111
|
-
payload: text("payload"), // JSON
|
|
112
|
-
createdAt: text("created_at").notNull(),
|
|
113
|
-
});
|
|
114
|
-
// ──────────────────────────────────────────────
|
|
115
|
-
// composed_prompts (runtime-sink-schema, Domain 5)
|
|
116
|
-
// ──────────────────────────────────────────────
|
|
117
|
-
// Runtime cache of compiler-output rows keyed by (agent_slug, context_hash).
|
|
118
|
-
// Written on cache-miss at session start; consumed by compiler-integration.
|
|
119
|
-
export const composedPromptsTable = sqliteTable("composed_prompts", {
|
|
120
|
-
id: text("id").primaryKey(),
|
|
121
|
-
agentSlug: text("agent_slug").notNull(),
|
|
122
|
-
// Opaque hash of the compilation context (component versions, etc.).
|
|
123
|
-
// Together with agent_slug this is the cache lookup key.
|
|
124
|
-
contextHash: text("context_hash").notNull(),
|
|
125
|
-
// Flat, fully-resolved system-prompt string produced by compileAgent().
|
|
126
|
-
content: text("content").notNull(),
|
|
127
|
-
// JSON blob: record of component-version ids used during compilation.
|
|
128
|
-
componentVersions: text("component_versions").notNull(),
|
|
129
|
-
createdAt: text("created_at").notNull(),
|
|
130
|
-
}, (table) => [
|
|
131
|
-
// Cache lookup: WHERE agent_slug = ? AND context_hash = ?
|
|
132
|
-
uniqueIndex("idx_composed_prompts_agent_ctx").on(table.agentSlug, table.contextHash),
|
|
133
|
-
]);
|
|
134
|
-
// ──────────────────────────────────────────────
|
|
135
|
-
// experiment_assignments (runtime-sink-schema, Domain 5)
|
|
136
|
-
// ──────────────────────────────────────────────
|
|
137
|
-
// Records which A/B variant a session was assigned to for each experiment slug.
|
|
138
|
-
export const experimentAssignmentsTable = sqliteTable("experiment_assignments", {
|
|
139
|
-
id: text("id").primaryKey(),
|
|
140
|
-
sessionId: text("session_id")
|
|
141
|
-
.notNull()
|
|
142
|
-
.references(() => sessionsTable.id, { onDelete: "cascade" }),
|
|
143
|
-
experimentSlug: text("experiment_slug").notNull(),
|
|
144
|
-
variant: text("variant").notNull(),
|
|
145
|
-
createdAt: text("created_at").notNull(),
|
|
146
|
-
});
|
|
147
|
-
// ──────────────────────────────────────────────
|
|
148
|
-
// task_usage
|
|
149
|
-
// ──────────────────────────────────────────────
|
|
150
|
-
// No FK on task_id → tasks.id: ephemeral tasks never write a tasks row,
|
|
151
|
-
// and cleanup scenarios make the constraint unreliable.
|
|
152
|
-
export const taskUsageTable = sqliteTable("task_usage", {
|
|
153
|
-
taskId: text("task_id").primaryKey(),
|
|
154
|
-
// null = this task IS the root of its delegation tree.
|
|
155
|
-
// non-null = task_id of the topmost ancestor.
|
|
156
|
-
rootTaskId: text("root_task_id"),
|
|
157
|
-
agentName: text("agent_name").notNull(),
|
|
158
|
-
// "openai" | "anthropic" | "lmstudio" | "claudecli" — kept as plain
|
|
159
|
-
// text rather than an enum so new providers don't require a migration.
|
|
160
|
-
providerType: text("provider_type").notNull(),
|
|
161
|
-
model: text("model").notNull(),
|
|
162
|
-
// Accumulated across all post:model_response events for this task.
|
|
163
|
-
inputTokens: integer("input_tokens").notNull().default(0),
|
|
164
|
-
outputTokens: integer("output_tokens").notNull().default(0),
|
|
165
|
-
toolCallCount: integer("tool_call_count").notNull().default(0),
|
|
166
|
-
modelCalls: integer("model_calls").notNull().default(0),
|
|
167
|
-
// Wall-clock ms from task start to terminal event; 0 until terminal.
|
|
168
|
-
latencyMs: integer("latency_ms").notNull().default(0),
|
|
169
|
-
// 0 = in-progress or crashed before terminal; 1 = terminal event fired.
|
|
170
|
-
isComplete: integer("is_complete").notNull().default(0),
|
|
171
|
-
// null until first post:model_response — most-severe stop reason across all
|
|
172
|
-
// model calls for this task. See [ref:normalised-stop-reason].
|
|
173
|
-
stopReason: text("stop_reason"),
|
|
174
|
-
// null for claudecli (no maxTokens in config) and for tasks started before
|
|
175
|
-
// this migration. Written once at task-start from provider.maxTokens.
|
|
176
|
-
maxTokens: integer("max_tokens"),
|
|
177
|
-
// Anthropic prompt-caching tokens — null for other providers and non-caching tiers
|
|
178
|
-
cacheReadTokens: integer("cache_read_input_tokens"),
|
|
179
|
-
cacheCreationTokens: integer("cache_creation_input_tokens"),
|
|
180
|
-
createdAt: text("created_at").notNull(),
|
|
181
|
-
}, (table) => [
|
|
182
|
-
// Critical for O(1) subtree aggregation:
|
|
183
|
-
// WHERE task_id = ? OR root_task_id = ?
|
|
184
|
-
index("idx_task_usage_root_task_id").on(table.rootTaskId),
|
|
185
|
-
]);
|
|
186
9
|
//# sourceMappingURL=schema.js.map
|
package/src/db/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../entrypoint/agent-mcp/src/db/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAErE,MAAM,CAAC,MAAM,WAAW,GAAG,WAAW,CAAC,QAAQ,EAAE;IAC7C,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE;IAC/B,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAChD,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE;IAC5B,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;IACvC,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;CAC1C,CAAC,CAAC"}
|
package/src/index.d.ts
CHANGED
|
@@ -1,34 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export type { ResolveInput, ResolveResult, ResolveResult as PromptResolveResult, CompileAgentFn, PromptResolverDeps } from "./engine/prompt-resolver.js";
|
|
6
|
-
import type { PromptResolverDeps } from "./engine/prompt-resolver.js";
|
|
2
|
+
import type { CompileAgentFn, PromptResolverDeps } from "@adhd/agent-engine-orchestrator";
|
|
3
|
+
export { HookRegistry } from "@adhd/agent-engine-orchestrator";
|
|
4
|
+
export { ComposedPromptStore } from "@adhd/agent-store-prompts";
|
|
7
5
|
export interface BuildPromptResolverOpts {
|
|
8
|
-
/** Path to the agent-registry SQLite file. Absent → resolver is undefined. */
|
|
9
6
|
registryDbPath?: string;
|
|
10
|
-
/**
|
|
11
|
-
* The agent-mcp Drizzle DB handle, used to construct ComposedPromptStore.
|
|
12
|
-
* Must already have agent-mcp migrations applied.
|
|
13
|
-
*/
|
|
14
7
|
agentMcpDb: any;
|
|
8
|
+
compileAgentFn?: CompileAgentFn;
|
|
15
9
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Build a {@link PromptResolverDeps} from a registry DB path and the agent-mcp
|
|
18
|
-
* DB handle.
|
|
19
|
-
*
|
|
20
|
-
* - When `registryDbPath` is provided, opens the SQLite file in WAL mode, wraps
|
|
21
|
-
* it with Drizzle, and wires {@link compileAgent} from @adhd/agent-compiler.
|
|
22
|
-
* - When `registryDbPath` is absent (undefined / empty string), returns
|
|
23
|
-
* `undefined` — the legacy flat-systemPrompt path is used unchanged.
|
|
24
|
-
*
|
|
25
|
-
* This function has no observable side-effects beyond opening the SQLite file
|
|
26
|
-
* when a path is supplied, so it is safe to call in tests with a real on-disk
|
|
27
|
-
* DB path.
|
|
28
|
-
*
|
|
29
|
-
* @param opts.registryDbPath - Path to the agent-registry SQLite file.
|
|
30
|
-
* @param opts.agentMcpDb - Drizzle handle for the agent-mcp DB.
|
|
31
|
-
* @returns Wired {@link PromptResolverDeps} or `undefined`.
|
|
32
|
-
*/
|
|
33
10
|
export declare function buildPromptResolver(opts: BuildPromptResolverOpts): PromptResolverDeps | undefined;
|
|
34
11
|
//# sourceMappingURL=index.d.ts.map
|
package/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../entrypoint/agent-mcp/src/index.ts"],"names":[],"mappings":";AAWA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAwB1F,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,MAAM,WAAW,uBAAuB;IACpC,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,UAAU,EAAE,GAAG,CAAC;IAChB,cAAc,CAAC,EAAE,cAAc,CAAC;CACnC;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,uBAAuB,GAAG,kBAAkB,GAAG,SAAS,CAsCjG"}
|
package/src/index.js
CHANGED
|
@@ -1,61 +1,31 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Re-export HookRegistry so plugins can import it for testing without deep internal paths
|
|
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";
|
|
10
|
-
import { compileAgent } from "@adhd/agent-compiler";
|
|
11
2
|
import { db } from "./db/client.js";
|
|
12
3
|
import { runMigrations } from "./db/migrate.js";
|
|
13
4
|
import { logger } from "./logger.js";
|
|
14
5
|
import { config } from "./config.js";
|
|
15
|
-
import { AgentStore
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { DagEngine } from "
|
|
19
|
-
import { Orchestrator } from "./engine/orchestrator.js";
|
|
20
|
-
import { HookRegistry } from "./engine/hooks.js";
|
|
21
|
-
import { PolicyEngine } from "./engine/policy.js";
|
|
22
|
-
import { UsagePlugin } from "./plugins/index.js";
|
|
23
|
-
import { loadExternalPlugins } from "./plugins/loader.js";
|
|
6
|
+
import { AgentStore } from "./store/agent-store.js";
|
|
7
|
+
import { SessionStore, TaskStore } from "@adhd/agent-store-runtime";
|
|
8
|
+
import { ComposedPromptStore } from "@adhd/agent-store-prompts";
|
|
9
|
+
import { BackgroundQueue, DagEngine, Orchestrator, HookRegistry, PolicyEngine, UsagePlugin, loadExternalPlugins, enqueueExistingTask, } from "@adhd/agent-engine-orchestrator";
|
|
24
10
|
import { startServer } from "./server.js";
|
|
25
11
|
import { startSseServer } from "./streaming/sse-server.js";
|
|
26
|
-
import {
|
|
27
|
-
import { tasksTable } from "
|
|
12
|
+
import { emitTaskEvent } from "./streaming/event-bus.js";
|
|
13
|
+
import { tasksTable } from "@adhd/agent-store-runtime";
|
|
28
14
|
import { eq } from "drizzle-orm";
|
|
29
|
-
import { ToolError } from "
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
* - When `registryDbPath` is provided, opens the SQLite file in WAL mode, wraps
|
|
35
|
-
* it with Drizzle, and wires {@link compileAgent} from @adhd/agent-compiler.
|
|
36
|
-
* - When `registryDbPath` is absent (undefined / empty string), returns
|
|
37
|
-
* `undefined` — the legacy flat-systemPrompt path is used unchanged.
|
|
38
|
-
*
|
|
39
|
-
* This function has no observable side-effects beyond opening the SQLite file
|
|
40
|
-
* when a path is supplied, so it is safe to call in tests with a real on-disk
|
|
41
|
-
* DB path.
|
|
42
|
-
*
|
|
43
|
-
* @param opts.registryDbPath - Path to the agent-registry SQLite file.
|
|
44
|
-
* @param opts.agentMcpDb - Drizzle handle for the agent-mcp DB.
|
|
45
|
-
* @returns Wired {@link PromptResolverDeps} or `undefined`.
|
|
46
|
-
*/
|
|
15
|
+
import { ToolError } from "@adhd/agent-engine-orchestrator";
|
|
16
|
+
import Database from "better-sqlite3";
|
|
17
|
+
import { drizzle } from "drizzle-orm/better-sqlite3";
|
|
18
|
+
export { HookRegistry } from "@adhd/agent-engine-orchestrator";
|
|
19
|
+
export { ComposedPromptStore } from "@adhd/agent-store-prompts";
|
|
47
20
|
export function buildPromptResolver(opts) {
|
|
48
|
-
const { registryDbPath, agentMcpDb } = opts;
|
|
21
|
+
const { registryDbPath, agentMcpDb, compileAgentFn } = opts;
|
|
49
22
|
if (!registryDbPath) {
|
|
50
23
|
return undefined;
|
|
51
24
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
// resolveComposedPrompt already catches and converts to a null (flat-prompt
|
|
57
|
-
// fallback). We catch the open failure here so the server still starts and
|
|
58
|
-
// every flat-systemPrompt agent continues to work unchanged.
|
|
25
|
+
if (!compileAgentFn) {
|
|
26
|
+
logger.info("@adhd/agent-engine-compiler not available — registry/compiler integration disabled; using flat system-prompts");
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
59
29
|
let registrySqlite;
|
|
60
30
|
try {
|
|
61
31
|
logger.info({ registryDbPath }, "Opening registry DB for compiler integration");
|
|
@@ -72,15 +42,10 @@ export function buildPromptResolver(opts) {
|
|
|
72
42
|
const composedPromptStore = new ComposedPromptStore(agentMcpDb);
|
|
73
43
|
return {
|
|
74
44
|
composedPromptStore,
|
|
75
|
-
compileAgentFn
|
|
45
|
+
compileAgentFn,
|
|
76
46
|
registryDb,
|
|
77
47
|
};
|
|
78
48
|
}
|
|
79
|
-
// DEBT-001: top-level safety net for anything that escapes the per-component
|
|
80
|
-
// handlers (SSE 'error' event: BUG-001; queue catch: BackgroundQueue.enqueue;
|
|
81
|
-
// orchestrator try/catch; provider pRetry). An unhandled error here means a
|
|
82
|
-
// structural bug — log structured context and exit so the process doesn't
|
|
83
|
-
// silently hang or produce opaque output.
|
|
84
49
|
process.on("uncaughtException", (err) => {
|
|
85
50
|
logger.fatal({ err }, "Uncaught exception — exiting");
|
|
86
51
|
process.exit(1);
|
|
@@ -89,11 +54,6 @@ process.on("unhandledRejection", (reason) => {
|
|
|
89
54
|
logger.fatal({ reason }, "Unhandled promise rejection — exiting");
|
|
90
55
|
process.exit(1);
|
|
91
56
|
});
|
|
92
|
-
// ── Startup env-ref verification (§4) ────────────────────────────────────────
|
|
93
|
-
// Harvest every ADHD_AGENT_* env-var name referenced across all agent env blocks,
|
|
94
|
-
// then call config.verifyEnvRefs to surface missing / disallowed names as
|
|
95
|
-
// structured warnings. Never crashes — one misconfigured agent must not block the
|
|
96
|
-
// rest of a mixed deployment.
|
|
97
57
|
function verifyAgentEnvRefs(agents) {
|
|
98
58
|
const names = [];
|
|
99
59
|
for (const agent of agents) {
|
|
@@ -110,7 +70,8 @@ function verifyAgentEnvRefs(agents) {
|
|
|
110
70
|
}
|
|
111
71
|
if (names.length === 0)
|
|
112
72
|
return;
|
|
113
|
-
const
|
|
73
|
+
const uniqueNames = [...new Set(names)];
|
|
74
|
+
const { missing, disallowed } = config.verifyEnvRefs(uniqueNames);
|
|
114
75
|
if (missing.length > 0) {
|
|
115
76
|
logger.warn({ missingEnvVars: missing }, "Startup warning: the following env vars are referenced in agent configs but are not set. " +
|
|
116
77
|
"Tasks using those agents will fail at credential resolution. " +
|
|
@@ -122,43 +83,23 @@ function verifyAgentEnvRefs(agents) {
|
|
|
122
83
|
}
|
|
123
84
|
}
|
|
124
85
|
async function main() {
|
|
125
|
-
// Run DB migrations synchronously before advertising tools
|
|
126
86
|
runMigrations();
|
|
127
|
-
// Instantiate hooks registry
|
|
128
87
|
const hooks = new HookRegistry();
|
|
129
|
-
// Instantiate stores
|
|
130
88
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
131
89
|
const dbAny = db;
|
|
132
90
|
const agentStore = new AgentStore(dbAny, hooks);
|
|
133
91
|
const sessionStore = new SessionStore(dbAny, hooks);
|
|
134
92
|
const taskStore = new TaskStore(dbAny);
|
|
135
|
-
// Observational usage tracking: accumulates per-task token usage into
|
|
136
|
-
// task_usage on every post:model_response and finalises on terminal events.
|
|
137
|
-
// Must never throw — handlers are internally guarded.
|
|
138
93
|
const usagePlugin = new UsagePlugin(dbAny);
|
|
139
94
|
await usagePlugin.install(hooks);
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
// exports a createPlugin(ctx) factory. Failures are logged and skipped.
|
|
143
|
-
await loadExternalPlugins(hooks, dbAny);
|
|
144
|
-
// Instantiate engine components
|
|
145
|
-
const queue = new BackgroundQueue();
|
|
95
|
+
await loadExternalPlugins(hooks, dbAny, undefined, config.plugins.configPath, config.plugins.entries, logger);
|
|
96
|
+
const queue = new BackgroundQueue(config.queue.concurrency, logger);
|
|
146
97
|
const orchestrator = new Orchestrator();
|
|
147
98
|
const policy = new PolicyEngine({
|
|
148
99
|
serverMaxDepth: config.server.maxDepth,
|
|
149
100
|
serverMaxToolLoops: config.server.maxToolLoops,
|
|
150
101
|
serverAllowedAgents: config.server.allowedAgents,
|
|
151
102
|
});
|
|
152
|
-
// Build DagEngine with an injected dispatchFn closure.
|
|
153
|
-
//
|
|
154
|
-
// The closure avoids a circular import between dag-engine.ts and tools/task.ts:
|
|
155
|
-
// DagEngine dispatches waiting→pending tasks by calling dispatchFn(taskId) rather
|
|
156
|
-
// than importing enqueueExistingTask directly. The closure captures `taskDepsRef`
|
|
157
|
-
// whose value is populated after startServer resolves (below).
|
|
158
|
-
//
|
|
159
|
-
// dispatchFn is only invoked when DagEngine.dispatchReady() finds a ready task,
|
|
160
|
-
// which always happens AFTER server startup, so `taskDepsRef.value` is guaranteed
|
|
161
|
-
// to be set by the time the closure executes.
|
|
162
103
|
const taskDepsRef = { value: undefined };
|
|
163
104
|
const dispatchFn = async (taskId) => {
|
|
164
105
|
if (!taskDepsRef.value) {
|
|
@@ -166,26 +107,19 @@ async function main() {
|
|
|
166
107
|
}
|
|
167
108
|
await enqueueExistingTask(taskId, taskDepsRef.value);
|
|
168
109
|
};
|
|
169
|
-
const dagEngine = new DagEngine(dbAny, queue, taskStore, dispatchFn);
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
// `agent` tool call then resolves the system-prompt via the compiler (with
|
|
178
|
-
// a composed_prompts cache look-up) before creating the session.
|
|
179
|
-
//
|
|
180
|
-
// When absent, buildPromptResolver returns undefined and the server falls
|
|
181
|
-
// back to the stored flat systemPrompt — existing callers and all legacy-agent
|
|
182
|
-
// tests continue to work unchanged.
|
|
110
|
+
const dagEngine = new DagEngine(dbAny, queue, taskStore, dispatchFn, logger);
|
|
111
|
+
let compileAgentFn;
|
|
112
|
+
try {
|
|
113
|
+
({ compileAgent: compileAgentFn } = await import("@adhd/agent-engine-compiler"));
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
logger.info("@adhd/agent-engine-compiler not installed — registry/compiler integration disabled; using flat system-prompts");
|
|
117
|
+
}
|
|
183
118
|
const promptResolver = buildPromptResolver({
|
|
184
119
|
registryDbPath: config.server.registryDbPath,
|
|
185
120
|
agentMcpDb: dbAny,
|
|
121
|
+
compileAgentFn,
|
|
186
122
|
});
|
|
187
|
-
// ── Startup env-ref verification (§4) ─────────────────────────────────
|
|
188
|
-
// Must run after store init so we can list all agents.
|
|
189
123
|
try {
|
|
190
124
|
const allAgents = agentStore.list();
|
|
191
125
|
verifyAgentEnvRefs(allAgents);
|
|
@@ -193,8 +127,8 @@ async function main() {
|
|
|
193
127
|
catch (err) {
|
|
194
128
|
logger.warn({ err }, "Startup env-ref verification failed — continuing");
|
|
195
129
|
}
|
|
196
|
-
|
|
197
|
-
const sseServer = startSseServer(taskStore);
|
|
130
|
+
const gatewayDepsRef = { value: undefined };
|
|
131
|
+
const sseServer = startSseServer(taskStore, config.sse.port, config.sse.host, gatewayDepsRef);
|
|
198
132
|
const { close } = await startServer({
|
|
199
133
|
agentStore,
|
|
200
134
|
sessionStore,
|
|
@@ -207,19 +141,6 @@ async function main() {
|
|
|
207
141
|
dagEngine,
|
|
208
142
|
promptResolver,
|
|
209
143
|
});
|
|
210
|
-
// Startup re-enqueue scan: recover tasks that were transitioned to "pending"
|
|
211
|
-
// by DagEngine.dispatchReady() but lost their queue slot due to a process
|
|
212
|
-
// crash between the DB UPDATE and queue.enqueue(). Safe to run every startup
|
|
213
|
-
// because the queue is idempotent — already-running tasks are just re-queued.
|
|
214
|
-
//
|
|
215
|
-
// taskDepsRef.value must be set before the orphan scan so dispatchFn can call
|
|
216
|
-
// enqueueExistingTask.
|
|
217
|
-
//
|
|
218
|
-
// NOTE: inProcessDescriptors and inProcessHandler are not available here
|
|
219
|
-
// (they are local to server.ts). Dag-dispatched tasks do NOT support
|
|
220
|
-
// in-process recursive calls at the dispatch level — they can use in-process
|
|
221
|
-
// tools once running via the normal orchestrator path through server.ts.
|
|
222
|
-
// Pass empty stubs: the orchestrator builds its own registry per task.
|
|
223
144
|
taskDepsRef.value = {
|
|
224
145
|
agentStore,
|
|
225
146
|
sessionStore,
|
|
@@ -235,6 +156,16 @@ async function main() {
|
|
|
235
156
|
},
|
|
236
157
|
db: dbAny,
|
|
237
158
|
dagEngine,
|
|
159
|
+
config,
|
|
160
|
+
logger,
|
|
161
|
+
emitTaskEvent: emitTaskEvent,
|
|
162
|
+
};
|
|
163
|
+
const taskDeps = taskDepsRef.value;
|
|
164
|
+
gatewayDepsRef.value = {
|
|
165
|
+
agentStore,
|
|
166
|
+
sessionStore,
|
|
167
|
+
taskStore,
|
|
168
|
+
taskDeps,
|
|
238
169
|
};
|
|
239
170
|
const orphanedPending = dbAny
|
|
240
171
|
.select()
|
|
@@ -245,7 +176,7 @@ async function main() {
|
|
|
245
176
|
logger.info({ count: orphanedPending.length }, "Re-enqueueing orphaned pending tasks");
|
|
246
177
|
for (const row of orphanedPending) {
|
|
247
178
|
try {
|
|
248
|
-
await enqueueExistingTask(row.id,
|
|
179
|
+
await enqueueExistingTask(row.id, taskDeps);
|
|
249
180
|
}
|
|
250
181
|
catch (err) {
|
|
251
182
|
logger.warn({ taskId: row.id, err }, "Failed to re-enqueue orphaned task");
|
|
@@ -255,8 +186,6 @@ async function main() {
|
|
|
255
186
|
const shutdown = async (signal) => {
|
|
256
187
|
logger.info({ signal }, "Server shutdown");
|
|
257
188
|
await close();
|
|
258
|
-
// Await SSE drain before exiting — close() is callback-based, so calling
|
|
259
|
-
// process.exit on the next line would race the drain.
|
|
260
189
|
await new Promise(resolve => sseServer.close(() => resolve()));
|
|
261
190
|
process.exit(0);
|
|
262
191
|
};
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../entrypoint/agent-mcp/src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAA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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"}
|
package/src/logger.d.ts
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
1
|
import pino from "pino";
|
|
2
|
-
/**
|
|
3
|
-
* Application logger.
|
|
4
|
-
*
|
|
5
|
-
* CRITICAL: All output goes to fd 2 (stderr).
|
|
6
|
-
* When TRANSPORT=stdio, stdout is the MCP JSON-RPC stream — any write
|
|
7
|
-
* to stdout would corrupt the framing. Never use console.log or pino's
|
|
8
|
-
* default stdout destination.
|
|
9
|
-
*/
|
|
10
2
|
export declare const logger: pino.Logger<never, boolean>;
|
|
11
3
|
//# sourceMappingURL=logger.d.ts.map
|
package/src/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../entrypoint/agent-mcp/src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,eAAO,MAAM,MAAM,6BAMlB,CAAC"}
|
package/src/logger.js
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
import pino from "pino";
|
|
2
2
|
import { config } from "./config.js";
|
|
3
|
-
/**
|
|
4
|
-
* Application logger.
|
|
5
|
-
*
|
|
6
|
-
* CRITICAL: All output goes to fd 2 (stderr).
|
|
7
|
-
* When TRANSPORT=stdio, stdout is the MCP JSON-RPC stream — any write
|
|
8
|
-
* to stdout would corrupt the framing. Never use console.log or pino's
|
|
9
|
-
* default stdout destination.
|
|
10
|
-
*/
|
|
11
3
|
export const logger = pino({
|
|
12
4
|
level: config.logging.level,
|
|
13
|
-
// Remove default `pid` and `hostname` fields for cleaner structured logs.
|
|
14
5
|
base: undefined,
|
|
15
|
-
},
|
|
16
|
-
// Bind explicitly to fd 2 (stderr).
|
|
17
|
-
pino.destination(2));
|
|
6
|
+
}, pino.destination(2));
|
|
18
7
|
//# sourceMappingURL=logger.js.map
|
package/src/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../../entrypoint/agent-mcp/src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CACtB;IACI,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK;IAC3B,IAAI,EAAE,SAAS;CAClB,EACD,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-mcp-tail.d.ts","sourceRoot":"","sources":["../../../../../entrypoint/agent-mcp/src/scripts/agent-mcp-tail.ts"],"names":[],"mappings":""}
|