@concord-ai/concord-mcp 0.5.0 → 0.6.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.
- package/README.md +148 -61
- package/dist/artifacts/handoff-md.js +5 -1
- package/dist/artifacts/handoff-md.js.map +1 -1
- package/dist/artifacts/work-state-json.js +4 -0
- package/dist/artifacts/work-state-json.js.map +1 -1
- package/dist/artifacts/work-state-view.d.ts +12 -0
- package/dist/artifacts/work-state-view.js +26 -2
- package/dist/artifacts/work-state-view.js.map +1 -1
- package/dist/cli/commands/check.js +2 -1
- package/dist/cli/commands/check.js.map +1 -1
- package/dist/cli/commands/doctor.js +42 -4
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/hook.d.ts +3 -3
- package/dist/cli/commands/hook.js +4 -4
- package/dist/cli/commands/hook.js.map +1 -1
- package/dist/cli/commands/setup.d.ts +21 -0
- package/dist/cli/commands/setup.js +117 -0
- package/dist/cli/commands/setup.js.map +1 -0
- package/dist/cli/commands/status.js +5 -1
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/tasks.js +8 -4
- package/dist/cli/commands/tasks.js.map +1 -1
- package/dist/cli/commands/who.js +7 -2
- package/dist/cli/commands/who.js.map +1 -1
- package/dist/cli/context.d.ts +3 -2
- package/dist/cli/context.js +5 -4
- package/dist/cli/context.js.map +1 -1
- package/dist/cli/dashboard/app.js +2 -2
- package/dist/cli/dashboard/app.js.map +1 -1
- package/dist/cli/index.js +18 -7
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/workspace-options.d.ts +21 -0
- package/dist/cli/workspace-options.js +36 -0
- package/dist/cli/workspace-options.js.map +1 -0
- package/dist/config/paths.d.ts +17 -3
- package/dist/config/paths.js +80 -10
- package/dist/config/paths.js.map +1 -1
- package/dist/db/index.d.ts +10 -1
- package/dist/db/index.js +6 -0
- package/dist/db/index.js.map +1 -1
- package/dist/db/repositories/agent-endpoints.d.ts +22 -0
- package/dist/db/repositories/agent-endpoints.js +87 -0
- package/dist/db/repositories/agent-endpoints.js.map +1 -0
- package/dist/db/repositories/agent-messages.d.ts +25 -0
- package/dist/db/repositories/agent-messages.js +151 -0
- package/dist/db/repositories/agent-messages.js.map +1 -0
- package/dist/db/repositories/handoffs.d.ts +9 -1
- package/dist/db/repositories/handoffs.js +38 -3
- package/dist/db/repositories/handoffs.js.map +1 -1
- package/dist/db/repositories/ownership-events.d.ts +19 -0
- package/dist/db/repositories/ownership-events.js +43 -0
- package/dist/db/repositories/ownership-events.js.map +1 -0
- package/dist/db/repositories/tasks.d.ts +12 -0
- package/dist/db/repositories/tasks.js +33 -5
- package/dist/db/repositories/tasks.js.map +1 -1
- package/dist/db/rows.d.ts +84 -3
- package/dist/db/rows.js +191 -2
- package/dist/db/rows.js.map +1 -1
- package/dist/db/schema.js +100 -0
- package/dist/db/schema.js.map +1 -1
- package/dist/domain/adoption.d.ts +3 -3
- package/dist/domain/adoption.js +2 -2
- package/dist/domain/adoption.js.map +1 -1
- package/dist/domain/operations.d.ts +42 -0
- package/dist/domain/operations.js +2 -0
- package/dist/domain/operations.js.map +1 -0
- package/dist/domain/presence.js +1 -1
- package/dist/domain/presence.js.map +1 -1
- package/dist/domain/schemas.d.ts +42 -251
- package/dist/domain/schemas.js +128 -98
- package/dist/domain/schemas.js.map +1 -1
- package/dist/index.js +12 -8
- package/dist/index.js.map +1 -1
- package/dist/install/agent-communications.d.ts +28 -0
- package/dist/install/agent-communications.js +61 -0
- package/dist/install/agent-communications.js.map +1 -0
- package/dist/install/codex-config.d.ts +21 -0
- package/dist/install/codex-config.js +68 -0
- package/dist/install/codex-config.js.map +1 -0
- package/dist/install/instructions.d.ts +6 -2
- package/dist/install/instructions.js +28 -34
- package/dist/install/instructions.js.map +1 -1
- package/dist/install/mcp-config.d.ts +24 -0
- package/dist/install/mcp-config.js +66 -0
- package/dist/install/mcp-config.js.map +1 -0
- package/dist/relay/adapters.d.ts +33 -0
- package/dist/relay/adapters.js +70 -0
- package/dist/relay/adapters.js.map +1 -0
- package/dist/relay/index.d.ts +4 -0
- package/dist/relay/index.js +5 -0
- package/dist/relay/index.js.map +1 -0
- package/dist/relay/protocol.d.ts +64 -0
- package/dist/relay/protocol.js +38 -0
- package/dist/relay/protocol.js.map +1 -0
- package/dist/relay/server.d.ts +40 -0
- package/dist/relay/server.js +196 -0
- package/dist/relay/server.js.map +1 -0
- package/dist/relay/socket-dispatcher.d.ts +9 -0
- package/dist/relay/socket-dispatcher.js +74 -0
- package/dist/relay/socket-dispatcher.js.map +1 -0
- package/dist/server.d.ts +9 -3
- package/dist/server.js +12 -15
- package/dist/server.js.map +1 -1
- package/dist/tools/agent-messages.d.ts +45 -0
- package/dist/tools/agent-messages.js +158 -0
- package/dist/tools/agent-messages.js.map +1 -0
- package/dist/tools/claim-work.d.ts +1 -19
- package/dist/tools/claim-work.js +8 -63
- package/dist/tools/claim-work.js.map +1 -1
- package/dist/tools/get-task-context.d.ts +5 -4
- package/dist/tools/get-task-context.js +4 -51
- package/dist/tools/get-task-context.js.map +1 -1
- package/dist/tools/get-work-state.d.ts +5 -6
- package/dist/tools/get-work-state.js +18 -36
- package/dist/tools/get-work-state.js.map +1 -1
- package/dist/tools/handoff-lifecycle.d.ts +10 -0
- package/dist/tools/handoff-lifecycle.js +151 -0
- package/dist/tools/handoff-lifecycle.js.map +1 -0
- package/dist/tools/handoff.d.ts +5 -9
- package/dist/tools/handoff.js +56 -93
- package/dist/tools/handoff.js.map +1 -1
- package/dist/tools/register-agent.d.ts +1 -4
- package/dist/tools/register-agent.js +0 -52
- package/dist/tools/register-agent.js.map +1 -1
- package/dist/tools/review-ready.d.ts +2 -4
- package/dist/tools/review-ready.js +36 -45
- package/dist/tools/review-ready.js.map +1 -1
- package/dist/tools/task-lifecycle.d.ts +12 -0
- package/dist/tools/task-lifecycle.js +200 -0
- package/dist/tools/task-lifecycle.js.map +1 -0
- package/dist/tools/update-task.d.ts +1 -4
- package/dist/tools/update-task.js +14 -29
- package/dist/tools/update-task.js.map +1 -1
- package/dist/tools/workflow.d.ts +47 -0
- package/dist/tools/workflow.js +566 -0
- package/dist/tools/workflow.js.map +1 -0
- package/dist/tools/workspace-routing.d.ts +8 -0
- package/dist/tools/workspace-routing.js +15 -0
- package/dist/tools/workspace-routing.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/workspaces/manager.d.ts +43 -0
- package/dist/workspaces/manager.js +124 -0
- package/dist/workspaces/manager.js.map +1 -0
- package/package.json +9 -3
- package/dist/cli/commands/init.d.ts +0 -6
- package/dist/cli/commands/init.js +0 -33
- package/dist/cli/commands/init.js.map +0 -1
- package/dist/cli/commands/install.d.ts +0 -2
- package/dist/cli/commands/install.js +0 -24
- package/dist/cli/commands/install.js.map +0 -1
package/dist/config/paths.js
CHANGED
|
@@ -1,23 +1,57 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
2
|
-
import { dirname, join, resolve } from 'node:path';
|
|
1
|
+
import { existsSync, readFileSync, realpathSync, statSync } from 'node:fs';
|
|
2
|
+
import { basename, dirname, isAbsolute, join, resolve } from 'node:path';
|
|
3
3
|
/** Directory name that holds all Concord state within a repo. */
|
|
4
4
|
export const CONCORD_DIR = '.concord';
|
|
5
5
|
/** Filename of the SQLite source-of-truth database. */
|
|
6
6
|
export const DB_FILENAME = 'concord.db';
|
|
7
|
+
/** Prefix for path-backed workspace ids returned by the MCP surface. */
|
|
8
|
+
export const WORKSPACE_ID_PREFIX = 'ws_';
|
|
9
|
+
function canonicalPath(input) {
|
|
10
|
+
const absolute = resolve(input);
|
|
11
|
+
return existsSync(absolute) ? realpathSync(absolute) : absolute;
|
|
12
|
+
}
|
|
13
|
+
function linkedWorktreePrimaryRoot(checkoutRoot) {
|
|
14
|
+
const gitEntry = join(checkoutRoot, '.git');
|
|
15
|
+
if (!statSync(gitEntry).isFile()) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const pointer = /^gitdir:\s*(.+)$/iu.exec(readFileSync(gitEntry, 'utf8').trim());
|
|
19
|
+
const gitDirValue = pointer?.[1]?.trim();
|
|
20
|
+
if (gitDirValue === undefined || gitDirValue === '') {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
const gitDir = resolve(checkoutRoot, gitDirValue);
|
|
24
|
+
const commonDirFile = join(gitDir, 'commondir');
|
|
25
|
+
if (!existsSync(commonDirFile)) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
const commonDirValue = readFileSync(commonDirFile, 'utf8').trim();
|
|
29
|
+
if (commonDirValue === '') {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
const commonDir = resolve(gitDir, commonDirValue);
|
|
33
|
+
if (basename(commonDir) === '.git') {
|
|
34
|
+
return canonicalPath(dirname(commonDir));
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
7
38
|
/**
|
|
8
|
-
* Walk upward from `startDir` looking for a `.git`
|
|
9
|
-
* repository root.
|
|
10
|
-
*
|
|
39
|
+
* Walk upward from `startDir` looking for a `.git` entry and return the
|
|
40
|
+
* canonical repository root. Linked worktrees follow their `gitdir` and
|
|
41
|
+
* `commondir` metadata to the primary checkout so every worktree shares one
|
|
42
|
+
* `.concord/` store. Falls back to `startDir` when no `.git` is found so
|
|
43
|
+
* Concord still works outside a git repo.
|
|
11
44
|
*/
|
|
12
45
|
export function findRepoRoot(startDir) {
|
|
13
|
-
|
|
46
|
+
const start = canonicalPath(startDir);
|
|
47
|
+
let dir = start;
|
|
14
48
|
for (;;) {
|
|
15
49
|
if (existsSync(join(dir, '.git'))) {
|
|
16
|
-
return dir;
|
|
50
|
+
return linkedWorktreePrimaryRoot(dir) ?? dir;
|
|
17
51
|
}
|
|
18
52
|
const parent = dirname(dir);
|
|
19
53
|
if (parent === dir) {
|
|
20
|
-
return
|
|
54
|
+
return start;
|
|
21
55
|
}
|
|
22
56
|
dir = parent;
|
|
23
57
|
}
|
|
@@ -35,14 +69,50 @@ export function findRepoRoot(startDir) {
|
|
|
35
69
|
export function resolveRepoRoot(cwd, env) {
|
|
36
70
|
const override = env['CONCORD_REPO_ROOT'];
|
|
37
71
|
if (override !== undefined && override.trim() !== '') {
|
|
38
|
-
return
|
|
72
|
+
return resolveExplicitRepoRoot(override);
|
|
39
73
|
}
|
|
40
74
|
const projectDir = env['CLAUDE_PROJECT_DIR'];
|
|
41
75
|
if (projectDir !== undefined && projectDir.trim() !== '') {
|
|
42
|
-
return
|
|
76
|
+
return resolveExplicitRepoRoot(projectDir);
|
|
43
77
|
}
|
|
44
78
|
return findRepoRoot(cwd);
|
|
45
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Resolve and validate a root supplied explicitly by a caller. Unlike the
|
|
82
|
+
* backward-compatible cwd fallback, explicit roots must exist and be
|
|
83
|
+
* directories so a typo cannot silently create a new Concord workspace.
|
|
84
|
+
*/
|
|
85
|
+
export function resolveExplicitRepoRoot(input) {
|
|
86
|
+
if (input.trim() === '') {
|
|
87
|
+
throw new Error('Workspace root must not be blank.');
|
|
88
|
+
}
|
|
89
|
+
const candidate = resolve(input);
|
|
90
|
+
if (!existsSync(candidate)) {
|
|
91
|
+
throw new Error(`Workspace root does not exist: ${candidate}`);
|
|
92
|
+
}
|
|
93
|
+
if (!statSync(candidate).isDirectory()) {
|
|
94
|
+
throw new Error(`Workspace root is not a directory: ${candidate}`);
|
|
95
|
+
}
|
|
96
|
+
return findRepoRoot(candidate);
|
|
97
|
+
}
|
|
98
|
+
/** Return the stable, reversible id for a canonical workspace root. */
|
|
99
|
+
export function workspaceIdForRoot(repoRoot) {
|
|
100
|
+
return `${WORKSPACE_ID_PREFIX}${Buffer.from(canonicalPath(repoRoot), 'utf8').toString('base64url')}`;
|
|
101
|
+
}
|
|
102
|
+
/** Decode and validate a workspace id returned by `workspaceIdForRoot`. */
|
|
103
|
+
export function workspaceRootFromId(workspaceId) {
|
|
104
|
+
if (!workspaceId.startsWith(WORKSPACE_ID_PREFIX)) {
|
|
105
|
+
throw new Error(`Invalid workspace id: ${workspaceId}`);
|
|
106
|
+
}
|
|
107
|
+
const encoded = workspaceId.slice(WORKSPACE_ID_PREFIX.length);
|
|
108
|
+
const decoded = Buffer.from(encoded, 'base64url').toString('utf8');
|
|
109
|
+
if (encoded === '' ||
|
|
110
|
+
!isAbsolute(decoded) ||
|
|
111
|
+
Buffer.from(decoded, 'utf8').toString('base64url') !== encoded) {
|
|
112
|
+
throw new Error(`Invalid workspace id: ${workspaceId}`);
|
|
113
|
+
}
|
|
114
|
+
return resolveExplicitRepoRoot(decoded);
|
|
115
|
+
}
|
|
46
116
|
/** Absolute path to the `.concord/` directory for a given repo root. */
|
|
47
117
|
export function concordDir(repoRoot) {
|
|
48
118
|
return join(repoRoot, CONCORD_DIR);
|
package/dist/config/paths.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/config/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/config/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzE,iEAAiE;AACjE,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAC;AAEtC,uDAAuD;AACvD,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC;AAExC,wEAAwE;AACxE,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAEzC,SAAS,aAAa,CAAC,KAAa;IAClC,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAChC,OAAO,UAAU,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;AAC1C,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,UAAU,CAAC,QAAgB;IACzC,OAAO,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AACrC,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC3C,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,CAAC;AACjD,CAAC"}
|
package/dist/db/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { type ConcordDatabase } from './connection.js';
|
|
2
|
+
import { type AgentEndpointRepository } from './repositories/agent-endpoints.js';
|
|
3
|
+
import { type AgentMessageRepository } from './repositories/agent-messages.js';
|
|
2
4
|
import { type AgentRepository } from './repositories/agents.js';
|
|
3
5
|
import { type EventRepository } from './repositories/events.js';
|
|
4
6
|
import { type HandoffRepository } from './repositories/handoffs.js';
|
|
7
|
+
import { type OwnershipEventRepository } from './repositories/ownership-events.js';
|
|
5
8
|
import { type ReviewRepository } from './repositories/reviews.js';
|
|
6
9
|
import { type TaskUpdateRepository } from './repositories/task-updates.js';
|
|
7
10
|
import { type TaskRepository } from './repositories/tasks.js';
|
|
@@ -12,8 +15,11 @@ export type { NewHandoff, HandoffRepository } from './repositories/handoffs.js';
|
|
|
12
15
|
export type { NewReview, ReviewRepository } from './repositories/reviews.js';
|
|
13
16
|
export type { NewTaskUpdate, TaskUpdateRepository } from './repositories/task-updates.js';
|
|
14
17
|
export type { NewEvent, EventRepository } from './repositories/events.js';
|
|
18
|
+
export type { NewOwnershipEvent, OwnershipEventRepository, } from './repositories/ownership-events.js';
|
|
15
19
|
export type { NewAgent, AgentRepository } from './repositories/agents.js';
|
|
16
|
-
export type {
|
|
20
|
+
export type { NewAgentEndpoint, AgentEndpointRepository } from './repositories/agent-endpoints.js';
|
|
21
|
+
export type { NewAgentMessage, AgentMessageRepository } from './repositories/agent-messages.js';
|
|
22
|
+
export type { TaskRecord, TaskStatus, HandoffRecord, ReviewRecord, ProvenanceEntry, EventRecord, EventStatus, ToolName, TaskUpdateKind, TaskUpdateRecord, AgentRecord, AgentStatus, OwnershipEventRecord, HandoffDeliveryStatus, AgentEndpointRecord, AgentEndpointStatus, AgentMessageRecord, AgentMessageStatus, AgentMessageErrorCode, AgentMessageEventRecord, } from './rows.js';
|
|
17
23
|
/** The full set of Concord repositories bound to one database. */
|
|
18
24
|
export interface Repositories {
|
|
19
25
|
db: ConcordDatabase;
|
|
@@ -23,6 +29,9 @@ export interface Repositories {
|
|
|
23
29
|
taskUpdates: TaskUpdateRepository;
|
|
24
30
|
events: EventRepository;
|
|
25
31
|
agents: AgentRepository;
|
|
32
|
+
agentEndpoints: AgentEndpointRepository;
|
|
33
|
+
agentMessages: AgentMessageRepository;
|
|
34
|
+
ownershipEvents: OwnershipEventRepository;
|
|
26
35
|
}
|
|
27
36
|
/** Bind all repositories to an already-open database. */
|
|
28
37
|
export declare function createRepositories(db: ConcordDatabase): Repositories;
|
package/dist/db/index.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { openDatabase } from './connection.js';
|
|
2
|
+
import { createAgentEndpointRepository, } from './repositories/agent-endpoints.js';
|
|
3
|
+
import { createAgentMessageRepository, } from './repositories/agent-messages.js';
|
|
2
4
|
import { createAgentRepository } from './repositories/agents.js';
|
|
3
5
|
import { createEventRepository } from './repositories/events.js';
|
|
4
6
|
import { createHandoffRepository } from './repositories/handoffs.js';
|
|
7
|
+
import { createOwnershipEventRepository, } from './repositories/ownership-events.js';
|
|
5
8
|
import { createReviewRepository } from './repositories/reviews.js';
|
|
6
9
|
import { createTaskUpdateRepository, } from './repositories/task-updates.js';
|
|
7
10
|
import { createTaskRepository } from './repositories/tasks.js';
|
|
@@ -16,6 +19,9 @@ export function createRepositories(db) {
|
|
|
16
19
|
taskUpdates: createTaskUpdateRepository(db),
|
|
17
20
|
events: createEventRepository(db),
|
|
18
21
|
agents: createAgentRepository(db),
|
|
22
|
+
agentEndpoints: createAgentEndpointRepository(db),
|
|
23
|
+
agentMessages: createAgentMessageRepository(db),
|
|
24
|
+
ownershipEvents: createOwnershipEventRepository(db),
|
|
19
25
|
};
|
|
20
26
|
}
|
|
21
27
|
/** Open the database at `filename` and bind all repositories. */
|
package/dist/db/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/db/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwB,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAwB,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,qBAAqB,EAAwB,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAA0B,MAAM,4BAA4B,CAAC;AAC7F,OAAO,EAAE,sBAAsB,EAAyB,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EACL,0BAA0B,GAE3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAuB,MAAM,yBAAyB,CAAC;AAGpF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/db/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwB,MAAM,iBAAiB,CAAC;AACrE,OAAO,EACL,6BAA6B,GAE9B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,4BAA4B,GAE7B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAwB,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,qBAAqB,EAAwB,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAA0B,MAAM,4BAA4B,CAAC;AAC7F,OAAO,EACL,8BAA8B,GAE/B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAyB,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EACL,0BAA0B,GAE3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAuB,MAAM,yBAAyB,CAAC;AAGpF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAkD/C,yDAAyD;AACzD,MAAM,UAAU,kBAAkB,CAAC,EAAmB;IACpD,OAAO;QACL,EAAE;QACF,KAAK,EAAE,oBAAoB,CAAC,EAAE,CAAC;QAC/B,QAAQ,EAAE,uBAAuB,CAAC,EAAE,CAAC;QACrC,OAAO,EAAE,sBAAsB,CAAC,EAAE,CAAC;QACnC,WAAW,EAAE,0BAA0B,CAAC,EAAE,CAAC;QAC3C,MAAM,EAAE,qBAAqB,CAAC,EAAE,CAAC;QACjC,MAAM,EAAE,qBAAqB,CAAC,EAAE,CAAC;QACjC,cAAc,EAAE,6BAA6B,CAAC,EAAE,CAAC;QACjD,aAAa,EAAE,4BAA4B,CAAC,EAAE,CAAC;QAC/C,eAAe,EAAE,8BAA8B,CAAC,EAAE,CAAC;KACpD,CAAC;AACJ,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,OAAO,kBAAkB,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ConcordDatabase } from '../connection.js';
|
|
2
|
+
import { type AgentEndpointRecord, type AgentEndpointStatus } from '../rows.js';
|
|
3
|
+
export interface NewAgentEndpoint {
|
|
4
|
+
endpointId: string;
|
|
5
|
+
agentId: string;
|
|
6
|
+
provider: string;
|
|
7
|
+
transport: string;
|
|
8
|
+
capabilities: readonly string[];
|
|
9
|
+
address: string;
|
|
10
|
+
credentialHash: string;
|
|
11
|
+
status?: AgentEndpointStatus;
|
|
12
|
+
expiresAt?: string | null;
|
|
13
|
+
}
|
|
14
|
+
export interface AgentEndpointRepository {
|
|
15
|
+
upsert(endpoint: NewAgentEndpoint): AgentEndpointRecord;
|
|
16
|
+
get(endpointId: string): AgentEndpointRecord | undefined;
|
|
17
|
+
getByAgent(agentId: string): AgentEndpointRecord | undefined;
|
|
18
|
+
list(): AgentEndpointRecord[];
|
|
19
|
+
heartbeat(endpointId: string, expiresAt?: string | null): AgentEndpointRecord | undefined;
|
|
20
|
+
disconnect(endpointId: string): AgentEndpointRecord | undefined;
|
|
21
|
+
}
|
|
22
|
+
export declare function createAgentEndpointRepository(db: ConcordDatabase): AgentEndpointRepository;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { parseAgentEndpointRow, serializeStringArray, } from '../rows.js';
|
|
3
|
+
const rawListSchema = z.array(z.unknown());
|
|
4
|
+
export function createAgentEndpointRepository(db) {
|
|
5
|
+
const upsertStmt = db.prepare(`
|
|
6
|
+
INSERT INTO agent_endpoints (
|
|
7
|
+
endpoint_id, agent_id, provider, transport, capabilities, address,
|
|
8
|
+
credential_hash, status, last_seen, expires_at, created_at, updated_at
|
|
9
|
+
) VALUES (
|
|
10
|
+
@endpoint_id, @agent_id, @provider, @transport, @capabilities, @address,
|
|
11
|
+
@credential_hash, @status, @now, @expires_at, @now, @now
|
|
12
|
+
)
|
|
13
|
+
ON CONFLICT(agent_id) DO UPDATE SET
|
|
14
|
+
endpoint_id = excluded.endpoint_id,
|
|
15
|
+
provider = excluded.provider,
|
|
16
|
+
transport = excluded.transport,
|
|
17
|
+
capabilities = excluded.capabilities,
|
|
18
|
+
address = excluded.address,
|
|
19
|
+
credential_hash = excluded.credential_hash,
|
|
20
|
+
status = excluded.status,
|
|
21
|
+
last_seen = excluded.last_seen,
|
|
22
|
+
expires_at = excluded.expires_at,
|
|
23
|
+
updated_at = excluded.updated_at
|
|
24
|
+
`);
|
|
25
|
+
const getStmt = db.prepare('SELECT * FROM agent_endpoints WHERE endpoint_id = ?');
|
|
26
|
+
const getByAgentStmt = db.prepare('SELECT * FROM agent_endpoints WHERE agent_id = ?');
|
|
27
|
+
const listStmt = db.prepare('SELECT * FROM agent_endpoints ORDER BY created_at, endpoint_id');
|
|
28
|
+
const heartbeatStmt = db.prepare(`
|
|
29
|
+
UPDATE agent_endpoints
|
|
30
|
+
SET status = 'connected', last_seen = @now, expires_at = @expires_at, updated_at = @now
|
|
31
|
+
WHERE endpoint_id = @endpoint_id
|
|
32
|
+
`);
|
|
33
|
+
const disconnectStmt = db.prepare(`
|
|
34
|
+
UPDATE agent_endpoints
|
|
35
|
+
SET status = 'disconnected', updated_at = @now
|
|
36
|
+
WHERE endpoint_id = @endpoint_id
|
|
37
|
+
`);
|
|
38
|
+
function get(endpointId) {
|
|
39
|
+
const raw = getStmt.get(endpointId);
|
|
40
|
+
return raw === undefined ? undefined : parseAgentEndpointRow(raw);
|
|
41
|
+
}
|
|
42
|
+
function getByAgent(agentId) {
|
|
43
|
+
const raw = getByAgentStmt.get(agentId);
|
|
44
|
+
return raw === undefined ? undefined : parseAgentEndpointRow(raw);
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
upsert(endpoint) {
|
|
48
|
+
const now = new Date().toISOString();
|
|
49
|
+
upsertStmt.run({
|
|
50
|
+
endpoint_id: endpoint.endpointId,
|
|
51
|
+
agent_id: endpoint.agentId,
|
|
52
|
+
provider: endpoint.provider,
|
|
53
|
+
transport: endpoint.transport,
|
|
54
|
+
capabilities: serializeStringArray(endpoint.capabilities),
|
|
55
|
+
address: endpoint.address,
|
|
56
|
+
credential_hash: endpoint.credentialHash,
|
|
57
|
+
status: endpoint.status ?? 'connected',
|
|
58
|
+
expires_at: endpoint.expiresAt ?? null,
|
|
59
|
+
now,
|
|
60
|
+
});
|
|
61
|
+
const stored = getByAgent(endpoint.agentId);
|
|
62
|
+
if (stored === undefined) {
|
|
63
|
+
throw new Error(`Agent endpoint ${endpoint.endpointId} could not be read back`);
|
|
64
|
+
}
|
|
65
|
+
return stored;
|
|
66
|
+
},
|
|
67
|
+
get,
|
|
68
|
+
getByAgent,
|
|
69
|
+
list() {
|
|
70
|
+
const raw = listStmt.all();
|
|
71
|
+
return rawListSchema.parse(raw).map(parseAgentEndpointRow);
|
|
72
|
+
},
|
|
73
|
+
heartbeat(endpointId, expiresAt = null) {
|
|
74
|
+
heartbeatStmt.run({
|
|
75
|
+
endpoint_id: endpointId,
|
|
76
|
+
expires_at: expiresAt,
|
|
77
|
+
now: new Date().toISOString(),
|
|
78
|
+
});
|
|
79
|
+
return get(endpointId);
|
|
80
|
+
},
|
|
81
|
+
disconnect(endpointId) {
|
|
82
|
+
disconnectStmt.run({ endpoint_id: endpointId, now: new Date().toISOString() });
|
|
83
|
+
return get(endpointId);
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=agent-endpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-endpoints.js","sourceRoot":"","sources":["../../../src/db/repositories/agent-endpoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GAGrB,MAAM,YAAY,CAAC;AAuBpB,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;AAE3C,MAAM,UAAU,6BAA6B,CAAC,EAAmB;IAC/D,MAAM,UAAU,GAAG,EAAE,CAAC,OAAO,CAAC;;;;;;;;;;;;;;;;;;;GAmB7B,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,qDAAqD,CAAC,CAAC;IAClF,MAAM,cAAc,GAAG,EAAE,CAAC,OAAO,CAAC,kDAAkD,CAAC,CAAC;IACtF,MAAM,QAAQ,GAAG,EAAE,CAAC,OAAO,CAAC,gEAAgE,CAAC,CAAC;IAC9F,MAAM,aAAa,GAAG,EAAE,CAAC,OAAO,CAAC;;;;GAIhC,CAAC,CAAC;IACH,MAAM,cAAc,GAAG,EAAE,CAAC,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,MAAM,CAAC;QAChB,CAAC;QACD,GAAG;QACH,UAAU;QACV,IAAI;YACF,MAAM,GAAG,GAAY,QAAQ,CAAC,GAAG,EAAE,CAAC;YACpC,OAAO,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;QAC7D,CAAC;QACD,SAAS,CAAC,UAAU,EAAE,SAAS,GAAG,IAAI;YACpC,aAAa,CAAC,GAAG,CAAC;gBAChB,WAAW,EAAE,UAAU;gBACvB,UAAU,EAAE,SAAS;gBACrB,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aAC9B,CAAC,CAAC;YACH,OAAO,GAAG,CAAC,UAAU,CAAC,CAAC;QACzB,CAAC;QACD,UAAU,CAAC,UAAU;YACnB,cAAc,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YAC/E,OAAO,GAAG,CAAC,UAAU,CAAC,CAAC;QACzB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ConcordDatabase } from '../connection.js';
|
|
2
|
+
import { type AgentMessageErrorCode, type AgentMessageEvent, type AgentMessageEventRecord, type AgentMessageRecord } from '../rows.js';
|
|
3
|
+
export interface NewAgentMessage {
|
|
4
|
+
messageId: string;
|
|
5
|
+
taskId: string | null;
|
|
6
|
+
senderAgentId: string;
|
|
7
|
+
recipientAgentId: string;
|
|
8
|
+
replyToMessageId: string | null;
|
|
9
|
+
content: string;
|
|
10
|
+
idempotencyKey: string;
|
|
11
|
+
}
|
|
12
|
+
export interface AgentMessageRepository {
|
|
13
|
+
create(message: NewAgentMessage): AgentMessageRecord;
|
|
14
|
+
get(messageId: string): AgentMessageRecord | undefined;
|
|
15
|
+
getByIdempotency(senderAgentId: string, idempotencyKey: string): AgentMessageRecord | undefined;
|
|
16
|
+
listByAgent(agentId: string): AgentMessageRecord[];
|
|
17
|
+
listByTask(taskId: string): AgentMessageRecord[];
|
|
18
|
+
listThread(messageId: string): AgentMessageRecord[];
|
|
19
|
+
markDelivered(messageId: string, provider: string, receipt: string | null): AgentMessageRecord;
|
|
20
|
+
markFailed(messageId: string, code: AgentMessageErrorCode, detail: string | null): AgentMessageRecord;
|
|
21
|
+
markReplied(messageId: string): AgentMessageRecord;
|
|
22
|
+
recordEvent(messageId: string, event: AgentMessageEvent, detail?: string | null): void;
|
|
23
|
+
listEvents(messageId: string): AgentMessageEventRecord[];
|
|
24
|
+
}
|
|
25
|
+
export declare function createAgentMessageRepository(db: ConcordDatabase): AgentMessageRepository;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { parseAgentMessageEventRow, parseAgentMessageRow, } from '../rows.js';
|
|
3
|
+
const rawListSchema = z.array(z.unknown());
|
|
4
|
+
export function createAgentMessageRepository(db) {
|
|
5
|
+
const insertStmt = db.prepare(`
|
|
6
|
+
INSERT INTO agent_messages (
|
|
7
|
+
message_id, task_id, sender_agent_id, recipient_agent_id, reply_to_message_id,
|
|
8
|
+
content, delivery_mode, status, idempotency_key, created_at
|
|
9
|
+
) VALUES (
|
|
10
|
+
@message_id, @task_id, @sender_agent_id, @recipient_agent_id, @reply_to_message_id,
|
|
11
|
+
@content, 'steer', 'pending', @idempotency_key, @created_at
|
|
12
|
+
)
|
|
13
|
+
`);
|
|
14
|
+
const getStmt = db.prepare('SELECT * FROM agent_messages WHERE message_id = ?');
|
|
15
|
+
const idempotencyStmt = db.prepare(`
|
|
16
|
+
SELECT * FROM agent_messages WHERE sender_agent_id = ? AND idempotency_key = ?
|
|
17
|
+
`);
|
|
18
|
+
const listByAgentStmt = db.prepare(`
|
|
19
|
+
SELECT * FROM agent_messages
|
|
20
|
+
WHERE sender_agent_id = ? OR recipient_agent_id = ?
|
|
21
|
+
ORDER BY created_at, message_id
|
|
22
|
+
`);
|
|
23
|
+
const listByTaskStmt = db.prepare(`
|
|
24
|
+
SELECT * FROM agent_messages WHERE task_id = ? ORDER BY created_at, message_id
|
|
25
|
+
`);
|
|
26
|
+
const markDeliveredStmt = db.prepare(`
|
|
27
|
+
UPDATE agent_messages
|
|
28
|
+
SET status = 'delivered', provider = @provider, provider_receipt = @receipt,
|
|
29
|
+
delivered_at = @now, error_code = NULL, error_detail = NULL, failed_at = NULL
|
|
30
|
+
WHERE message_id = @message_id AND status = 'pending'
|
|
31
|
+
`);
|
|
32
|
+
const markFailedStmt = db.prepare(`
|
|
33
|
+
UPDATE agent_messages
|
|
34
|
+
SET status = 'failed', error_code = @code, error_detail = @detail, failed_at = @now
|
|
35
|
+
WHERE message_id = @message_id AND status = 'pending'
|
|
36
|
+
`);
|
|
37
|
+
const markRepliedStmt = db.prepare(`
|
|
38
|
+
UPDATE agent_messages SET status = 'replied', replied_at = @now
|
|
39
|
+
WHERE message_id = @message_id AND status = 'delivered'
|
|
40
|
+
`);
|
|
41
|
+
const eventStmt = db.prepare(`
|
|
42
|
+
INSERT INTO agent_message_events (message_id, event, detail, created_at)
|
|
43
|
+
VALUES (@message_id, @event, @detail, @created_at)
|
|
44
|
+
`);
|
|
45
|
+
const listEventsStmt = db.prepare(`
|
|
46
|
+
SELECT * FROM agent_message_events WHERE message_id = ? ORDER BY id
|
|
47
|
+
`);
|
|
48
|
+
function get(messageId) {
|
|
49
|
+
const raw = getStmt.get(messageId);
|
|
50
|
+
return raw === undefined ? undefined : parseAgentMessageRow(raw);
|
|
51
|
+
}
|
|
52
|
+
function requireMessage(messageId) {
|
|
53
|
+
const message = get(messageId);
|
|
54
|
+
if (message === undefined) {
|
|
55
|
+
throw new Error(`Agent message ${messageId} could not be read back`);
|
|
56
|
+
}
|
|
57
|
+
return message;
|
|
58
|
+
}
|
|
59
|
+
function recordEvent(messageId, event, detail = null) {
|
|
60
|
+
eventStmt.run({ message_id: messageId, event, detail, created_at: new Date().toISOString() });
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
create(message) {
|
|
64
|
+
insertStmt.run({
|
|
65
|
+
message_id: message.messageId,
|
|
66
|
+
task_id: message.taskId,
|
|
67
|
+
sender_agent_id: message.senderAgentId,
|
|
68
|
+
recipient_agent_id: message.recipientAgentId,
|
|
69
|
+
reply_to_message_id: message.replyToMessageId,
|
|
70
|
+
content: message.content,
|
|
71
|
+
idempotency_key: message.idempotencyKey,
|
|
72
|
+
created_at: new Date().toISOString(),
|
|
73
|
+
});
|
|
74
|
+
const stored = requireMessage(message.messageId);
|
|
75
|
+
recordEvent(stored.messageId, 'accepted');
|
|
76
|
+
return stored;
|
|
77
|
+
},
|
|
78
|
+
get,
|
|
79
|
+
getByIdempotency(senderAgentId, idempotencyKey) {
|
|
80
|
+
const raw = idempotencyStmt.get(senderAgentId, idempotencyKey);
|
|
81
|
+
return raw === undefined ? undefined : parseAgentMessageRow(raw);
|
|
82
|
+
},
|
|
83
|
+
listByAgent(agentId) {
|
|
84
|
+
const raw = listByAgentStmt.all(agentId, agentId);
|
|
85
|
+
return rawListSchema.parse(raw).map(parseAgentMessageRow);
|
|
86
|
+
},
|
|
87
|
+
listByTask(taskId) {
|
|
88
|
+
const raw = listByTaskStmt.all(taskId);
|
|
89
|
+
return rawListSchema.parse(raw).map(parseAgentMessageRow);
|
|
90
|
+
},
|
|
91
|
+
listThread(messageId) {
|
|
92
|
+
const messages = [];
|
|
93
|
+
let root = requireMessage(messageId);
|
|
94
|
+
while (root.replyToMessageId !== null) {
|
|
95
|
+
root = requireMessage(root.replyToMessageId);
|
|
96
|
+
}
|
|
97
|
+
messages.push(root);
|
|
98
|
+
let frontier = [root.messageId];
|
|
99
|
+
while (frontier.length > 0) {
|
|
100
|
+
const placeholders = frontier.map(() => '?').join(', ');
|
|
101
|
+
const raw = db
|
|
102
|
+
.prepare(`SELECT * FROM agent_messages WHERE reply_to_message_id IN (${placeholders}) ORDER BY created_at, message_id`)
|
|
103
|
+
.all(...frontier);
|
|
104
|
+
const children = rawListSchema.parse(raw).map(parseAgentMessageRow);
|
|
105
|
+
messages.push(...children);
|
|
106
|
+
frontier = children.map((message) => message.messageId);
|
|
107
|
+
}
|
|
108
|
+
return messages;
|
|
109
|
+
},
|
|
110
|
+
markDelivered(messageId, provider, receipt) {
|
|
111
|
+
const result = markDeliveredStmt.run({
|
|
112
|
+
message_id: messageId,
|
|
113
|
+
provider,
|
|
114
|
+
receipt,
|
|
115
|
+
now: new Date().toISOString(),
|
|
116
|
+
});
|
|
117
|
+
const stored = requireMessage(messageId);
|
|
118
|
+
if (result.changes > 0)
|
|
119
|
+
recordEvent(messageId, 'delivered', provider);
|
|
120
|
+
return stored;
|
|
121
|
+
},
|
|
122
|
+
markFailed(messageId, code, detail) {
|
|
123
|
+
const result = markFailedStmt.run({
|
|
124
|
+
message_id: messageId,
|
|
125
|
+
code,
|
|
126
|
+
detail,
|
|
127
|
+
now: new Date().toISOString(),
|
|
128
|
+
});
|
|
129
|
+
const stored = requireMessage(messageId);
|
|
130
|
+
if (result.changes > 0)
|
|
131
|
+
recordEvent(messageId, 'failed', code);
|
|
132
|
+
return stored;
|
|
133
|
+
},
|
|
134
|
+
markReplied(messageId) {
|
|
135
|
+
const result = markRepliedStmt.run({
|
|
136
|
+
message_id: messageId,
|
|
137
|
+
now: new Date().toISOString(),
|
|
138
|
+
});
|
|
139
|
+
const stored = requireMessage(messageId);
|
|
140
|
+
if (result.changes > 0)
|
|
141
|
+
recordEvent(messageId, 'replied');
|
|
142
|
+
return stored;
|
|
143
|
+
},
|
|
144
|
+
recordEvent,
|
|
145
|
+
listEvents(messageId) {
|
|
146
|
+
const raw = listEventsStmt.all(messageId);
|
|
147
|
+
return rawListSchema.parse(raw).map(parseAgentMessageEventRow);
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=agent-messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-messages.js","sourceRoot":"","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O,GAAG,CAAC;gBAAE,WAAW,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YAC1D,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,WAAW;QACX,UAAU,CAAC,SAAS;YAClB,MAAM,GAAG,GAAY,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YACnD,OAAO,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;QACjE,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConcordDatabase } from '../connection.js';
|
|
2
|
-
import { type HandoffRecord } from '../rows.js';
|
|
2
|
+
import { type HandoffDeliveryStatus, type HandoffRecord } from '../rows.js';
|
|
3
3
|
/** Input for recording a handoff. Array fields default to `[]` at the caller. */
|
|
4
4
|
export interface NewHandoff {
|
|
5
5
|
taskId: string;
|
|
@@ -13,10 +13,18 @@ export interface NewHandoff {
|
|
|
13
13
|
guardrailsChecked: readonly string[];
|
|
14
14
|
needsReviewFrom: readonly string[];
|
|
15
15
|
nextSteps: readonly string[];
|
|
16
|
+
fromAgentId?: string | null;
|
|
17
|
+
toAgentId?: string | null;
|
|
18
|
+
deliveryStatus?: HandoffDeliveryStatus;
|
|
19
|
+
expiresAt?: string | null;
|
|
20
|
+
taskVersion?: number | null;
|
|
16
21
|
}
|
|
17
22
|
export interface HandoffRepository {
|
|
18
23
|
create(handoff: NewHandoff): HandoffRecord;
|
|
19
24
|
listByTask(taskId: string): HandoffRecord[];
|
|
20
25
|
latestForTask(taskId: string): HandoffRecord | undefined;
|
|
26
|
+
get(id: number): HandoffRecord | undefined;
|
|
27
|
+
pendingForTask(taskId: string): HandoffRecord | undefined;
|
|
28
|
+
resolve(id: number, status: Exclude<HandoffDeliveryStatus, 'recorded' | 'pending'>, reason: string | null): HandoffRecord | undefined;
|
|
21
29
|
}
|
|
22
30
|
export declare function createHandoffRepository(db: ConcordDatabase): HandoffRepository;
|
|
@@ -1,21 +1,35 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { parseHandoffRow, serializeStringArray } from '../rows.js';
|
|
2
|
+
import { parseHandoffRow, serializeStringArray, } from '../rows.js';
|
|
3
3
|
const rawListSchema = z.array(z.unknown());
|
|
4
4
|
export function createHandoffRepository(db) {
|
|
5
5
|
const insertStmt = db.prepare(`
|
|
6
6
|
INSERT INTO handoffs (
|
|
7
7
|
task_id, status, changed_files, what_changed, tests_run, known_risks,
|
|
8
8
|
assumptions, decisions, guardrails_checked, needs_review_from, next_steps,
|
|
9
|
-
|
|
9
|
+
from_agent_id, to_agent_id, delivery_status, expires_at, resolved_at,
|
|
10
|
+
task_version, resolution_reason, created_at
|
|
10
11
|
) VALUES (
|
|
11
12
|
@task_id, @status, @changed_files, @what_changed, @tests_run, @known_risks,
|
|
12
13
|
@assumptions, @decisions, @guardrails_checked, @needs_review_from, @next_steps,
|
|
13
|
-
@
|
|
14
|
+
@from_agent_id, @to_agent_id, @delivery_status, @expires_at, @resolved_at,
|
|
15
|
+
@task_version, @resolution_reason, @created_at
|
|
14
16
|
)
|
|
15
17
|
`);
|
|
16
18
|
const getByIdStmt = db.prepare('SELECT * FROM handoffs WHERE id = ?');
|
|
17
19
|
const listByTaskStmt = db.prepare('SELECT * FROM handoffs WHERE task_id = ? ORDER BY created_at ASC, id ASC');
|
|
18
20
|
const latestStmt = db.prepare('SELECT * FROM handoffs WHERE task_id = ? ORDER BY created_at DESC, id DESC LIMIT 1');
|
|
21
|
+
const pendingStmt = db.prepare(`SELECT * FROM handoffs
|
|
22
|
+
WHERE task_id = ? AND delivery_status = 'pending'
|
|
23
|
+
ORDER BY id DESC LIMIT 1`);
|
|
24
|
+
const resolveStmt = db.prepare(`UPDATE handoffs
|
|
25
|
+
SET delivery_status = @delivery_status,
|
|
26
|
+
resolved_at = @resolved_at,
|
|
27
|
+
resolution_reason = @resolution_reason
|
|
28
|
+
WHERE id = @id AND delivery_status = 'pending'`);
|
|
29
|
+
function get(id) {
|
|
30
|
+
const raw = getByIdStmt.get(id);
|
|
31
|
+
return raw === undefined ? undefined : parseHandoffRow(raw);
|
|
32
|
+
}
|
|
19
33
|
return {
|
|
20
34
|
create(handoff) {
|
|
21
35
|
const info = insertStmt.run({
|
|
@@ -30,6 +44,13 @@ export function createHandoffRepository(db) {
|
|
|
30
44
|
guardrails_checked: serializeStringArray(handoff.guardrailsChecked),
|
|
31
45
|
needs_review_from: serializeStringArray(handoff.needsReviewFrom),
|
|
32
46
|
next_steps: serializeStringArray(handoff.nextSteps),
|
|
47
|
+
from_agent_id: handoff.fromAgentId ?? null,
|
|
48
|
+
to_agent_id: handoff.toAgentId ?? null,
|
|
49
|
+
delivery_status: handoff.deliveryStatus ?? 'recorded',
|
|
50
|
+
expires_at: handoff.expiresAt ?? null,
|
|
51
|
+
resolved_at: null,
|
|
52
|
+
task_version: handoff.taskVersion ?? null,
|
|
53
|
+
resolution_reason: null,
|
|
33
54
|
created_at: new Date().toISOString(),
|
|
34
55
|
});
|
|
35
56
|
const raw = getByIdStmt.get(info.lastInsertRowid);
|
|
@@ -49,6 +70,20 @@ export function createHandoffRepository(db) {
|
|
|
49
70
|
}
|
|
50
71
|
return parseHandoffRow(raw);
|
|
51
72
|
},
|
|
73
|
+
get,
|
|
74
|
+
pendingForTask(taskId) {
|
|
75
|
+
const raw = pendingStmt.get(taskId);
|
|
76
|
+
return raw === undefined ? undefined : parseHandoffRow(raw);
|
|
77
|
+
},
|
|
78
|
+
resolve(id, status, reason) {
|
|
79
|
+
const info = resolveStmt.run({
|
|
80
|
+
id,
|
|
81
|
+
delivery_status: status,
|
|
82
|
+
resolved_at: new Date().toISOString(),
|
|
83
|
+
resolution_reason: reason,
|
|
84
|
+
});
|
|
85
|
+
return info.changes === 0 ? undefined : get(id);
|
|
86
|
+
},
|
|
52
87
|
};
|
|
53
88
|
}
|
|
54
89
|
//# sourceMappingURL=handoffs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handoffs.js","sourceRoot":"","sources":["../../../src/db/repositories/handoffs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,
|
|
1
|
+
{"version":3,"file":"handoffs.js","sourceRoot":"","sources":["../../../src/db/repositories/handoffs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EACL,eAAe,EACf,oBAAoB,GAGrB,MAAM,YAAY,CAAC;AAmCpB,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;AAE3C,MAAM,UAAU,uBAAuB,CAAC,EAAmB;IACzD,MAAM,UAAU,GAAG,EAAE,CAAC,OAAO,CAAC;;;;;;;;;;;;GAY7B,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,EAAE,CAAC,OAAO,CAAC,qCAAqC,CAAC,CAAC;IACtE,MAAM,cAAc,GAAG,EAAE,CAAC,OAAO,CAC/B,0EAA0E,CAC3E,CAAC;IACF,MAAM,UAAU,GAAG,EAAE,CAAC,OAAO,CAC3B,oFAAoF,CACrF,CAAC;IACF,MAAM,WAAW,GAAG,EAAE,CAAC,OAAO,CAC5B;;8BAE0B,CAC3B,CAAC;IACF,MAAM,WAAW,GAAG,EAAE,CAAC,OAAO,CAC5B;;;;oDAIgD,CACjD,CAAC;IAEF,SAAS,GAAG,CAAC,EAAU;QACrB,MAAM,GAAG,GAAY,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACzC,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO;QACL,MAAM,CAAC,OAAO;YACZ,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC;gBAC1B,OAAO,EAAE,OAAO,CAAC,MAAM;g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GAAG,GAAY,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAChD,OAAO,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QACvD,CAAC;QACD,aAAa,CAAC,MAAM;YAClB,MAAM,GAAG,GAAY,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC5C,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;gBACtB,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC;QAC9B,CAAC;QACD,GAAG;QACH,cAAc,CAAC,MAAM;YACnB,MAAM,GAAG,GAAY,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC7C,OAAO,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;QAC9D,CAAC;QACD,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM;YACxB,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC;gBAC3B,EAAE;gBACF,eAAe,EAAE,MAAM;gBACvB,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACrC,iBAAiB,EAAE,MAAM;aAC1B,CAAC,CAAC;YACH,OAAO,IAAI,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ConcordDatabase } from '../connection.js';
|
|
2
|
+
import { type OwnershipEventRecord, type TaskStatus } from '../rows.js';
|
|
3
|
+
export interface NewOwnershipEvent {
|
|
4
|
+
taskId: string;
|
|
5
|
+
transition: string;
|
|
6
|
+
actorAgentId: string;
|
|
7
|
+
fromAgentId: string | null;
|
|
8
|
+
toAgentId: string | null;
|
|
9
|
+
fromStatus: TaskStatus;
|
|
10
|
+
toStatus: TaskStatus;
|
|
11
|
+
fromVersion: number;
|
|
12
|
+
toVersion: number;
|
|
13
|
+
reason: string | null;
|
|
14
|
+
}
|
|
15
|
+
export interface OwnershipEventRepository {
|
|
16
|
+
record(event: NewOwnershipEvent): OwnershipEventRecord;
|
|
17
|
+
listByTask(taskId: string): OwnershipEventRecord[];
|
|
18
|
+
}
|
|
19
|
+
export declare function createOwnershipEventRepository(db: ConcordDatabase): OwnershipEventRepository;
|