@concord-ai/concord-mcp 0.4.1 → 0.6.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/README.md +139 -39
- 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 +4 -0
- package/dist/artifacts/work-state-view.js +7 -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 +35 -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/install.js +25 -5
- package/dist/cli/commands/install.js.map +1 -1
- 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 +44 -3
- 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 +4 -1
- package/dist/db/index.js +2 -0
- package/dist/db/index.js.map +1 -1
- 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 +33 -3
- package/dist/db/rows.js +87 -2
- package/dist/db/rows.js.map +1 -1
- package/dist/db/schema.js +36 -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 +34 -250
- package/dist/domain/schemas.js +108 -97
- package/dist/domain/schemas.js.map +1 -1
- package/dist/index.js +20 -8
- package/dist/index.js.map +1 -1
- 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 +27 -34
- package/dist/install/instructions.js.map +1 -1
- package/dist/install/mcp-config.d.ts +24 -0
- package/dist/install/mcp-config.js +60 -0
- package/dist/install/mcp-config.js.map +1 -0
- package/dist/server.d.ts +6 -3
- package/dist/server.js +12 -15
- package/dist/server.js.map +1 -1
- package/dist/telemetry/client.d.ts +22 -0
- package/dist/telemetry/client.js +161 -0
- package/dist/telemetry/client.js.map +1 -0
- package/dist/telemetry/identity.d.ts +11 -0
- package/dist/telemetry/identity.js +59 -0
- package/dist/telemetry/identity.js.map +1 -0
- package/dist/telemetry/transport.d.ts +15 -0
- package/dist/telemetry/transport.js +83 -0
- package/dist/telemetry/transport.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 +4 -4
- package/dist/tools/get-task-context.js +3 -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 +38 -0
- package/dist/tools/workflow.js +444 -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 +118 -0
- package/dist/workspaces/manager.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createHmac, randomBytes, randomUUID } from 'node:crypto';
|
|
2
|
+
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { dirname, join } from 'node:path';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
const identitySchema = z.object({
|
|
7
|
+
installation_id: z.string().uuid(),
|
|
8
|
+
workspace_key: z.string().regex(/^[0-9a-f]{64}$/u),
|
|
9
|
+
notice_shown: z.boolean(),
|
|
10
|
+
});
|
|
11
|
+
export function telemetryConfigFile(env = process.env) {
|
|
12
|
+
const base = env['XDG_CONFIG_HOME'] ??
|
|
13
|
+
(process.platform === 'win32' ? env['APPDATA'] : undefined) ??
|
|
14
|
+
join(homedir(), '.config');
|
|
15
|
+
return join(base, 'concord', 'telemetry.json');
|
|
16
|
+
}
|
|
17
|
+
function persistIdentity(path, identity) {
|
|
18
|
+
try {
|
|
19
|
+
mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
|
|
20
|
+
writeFileSync(path, `${JSON.stringify({
|
|
21
|
+
installation_id: identity.installationId,
|
|
22
|
+
workspace_key: identity.workspaceKey,
|
|
23
|
+
notice_shown: identity.noticeShown,
|
|
24
|
+
})}\n`, { encoding: 'utf8', mode: 0o600 });
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** Load or create the anonymous identity. Failure disables telemetry. */
|
|
32
|
+
export function loadTelemetryIdentity(path) {
|
|
33
|
+
try {
|
|
34
|
+
const parsed = identitySchema.parse(JSON.parse(readFileSync(path, 'utf8')));
|
|
35
|
+
return {
|
|
36
|
+
installationId: parsed.installation_id,
|
|
37
|
+
workspaceKey: parsed.workspace_key,
|
|
38
|
+
noticeShown: parsed.notice_shown,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
const identity = {
|
|
43
|
+
installationId: randomUUID(),
|
|
44
|
+
workspaceKey: randomBytes(32).toString('hex'),
|
|
45
|
+
noticeShown: false,
|
|
46
|
+
};
|
|
47
|
+
return persistIdentity(path, identity) ? identity : undefined;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export function markTelemetryNoticeShown(path, identity) {
|
|
51
|
+
if (!identity.noticeShown && persistIdentity(path, { ...identity, noticeShown: true })) {
|
|
52
|
+
identity.noticeShown = true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** Stable only for this installation; the canonical path and key never leave the machine. */
|
|
56
|
+
export function workspacePseudonym(identity, repoRoot) {
|
|
57
|
+
return createHmac('sha256', identity.workspaceKey).update(repoRoot).digest('hex');
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/telemetry/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9B,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IAClC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC;IAClD,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE;CAC1B,CAAC,CAAC;AAQH,MAAM,UAAU,mBAAmB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACtE,MAAM,IAAI,GACR,GAAG,CAAC,iBAAiB,CAAC;QACtB,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC3D,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;IAC7B,OAA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AChE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,IAAY,EAAE,QAA2B;IAChF,IAAI,CAAC,QAAQ,CAAC,WAAW,IAAI,eAAe,CAAC,IAAI,EAAE,EAAE,GAAG,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QACvF,QAAQ,CAAC,WAAW,GAAG,IAAI,CAAC;IAC9B,CAAC;AACH,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,kBAAkB,CAAC,QAA2B,EAAE,QAAgB;IAC9E,OAAO,UAAU,CAAC,QAAQ,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACpF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Transport, TransportSendOptions } from '@modelcontextprotocol/sdk/shared/transport.js';
|
|
2
|
+
import { type JSONRPCMessage } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import type { TelemetryClient } from './client.js';
|
|
4
|
+
/** Observes MCP envelopes without retaining tool arguments or response bodies. */
|
|
5
|
+
export declare class TelemetryTransport implements Transport {
|
|
6
|
+
#private;
|
|
7
|
+
onclose: NonNullable<Transport['onclose']>;
|
|
8
|
+
onerror: NonNullable<Transport['onerror']>;
|
|
9
|
+
onmessage: NonNullable<Transport['onmessage']>;
|
|
10
|
+
constructor(inner: Transport, telemetry: TelemetryClient);
|
|
11
|
+
setProtocolVersion(version: string): void;
|
|
12
|
+
start(): Promise<void>;
|
|
13
|
+
send(message: JSONRPCMessage, options?: TransportSendOptions): Promise<void>;
|
|
14
|
+
close(): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { InitializeRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { performance } from 'node:perf_hooks';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
const responseSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
id: z.union([z.string(), z.number()]),
|
|
7
|
+
result: z.object({ isError: z.boolean().optional() }).passthrough().optional(),
|
|
8
|
+
error: z.object({ code: z.number() }).passthrough().optional(),
|
|
9
|
+
})
|
|
10
|
+
.passthrough();
|
|
11
|
+
const callRequestSchema = z
|
|
12
|
+
.object({
|
|
13
|
+
id: z.union([z.string(), z.number()]),
|
|
14
|
+
method: z.literal('tools/call'),
|
|
15
|
+
params: z.object({ name: z.string() }).passthrough(),
|
|
16
|
+
})
|
|
17
|
+
.passthrough();
|
|
18
|
+
/** Observes MCP envelopes without retaining tool arguments or response bodies. */
|
|
19
|
+
export class TelemetryTransport {
|
|
20
|
+
#inner;
|
|
21
|
+
#telemetry;
|
|
22
|
+
#pending = new Map();
|
|
23
|
+
onclose = () => undefined;
|
|
24
|
+
onerror = () => undefined;
|
|
25
|
+
onmessage = () => undefined;
|
|
26
|
+
constructor(inner, telemetry) {
|
|
27
|
+
this.#inner = inner;
|
|
28
|
+
this.#telemetry = telemetry;
|
|
29
|
+
}
|
|
30
|
+
setProtocolVersion(version) {
|
|
31
|
+
this.#inner.setProtocolVersion?.(version);
|
|
32
|
+
}
|
|
33
|
+
async start() {
|
|
34
|
+
this.#inner.onclose = () => {
|
|
35
|
+
void this.#telemetry.close();
|
|
36
|
+
this.onclose();
|
|
37
|
+
};
|
|
38
|
+
this.#inner.onerror = (error) => {
|
|
39
|
+
this.onerror(error);
|
|
40
|
+
};
|
|
41
|
+
this.#inner.onmessage = (message, extra) => {
|
|
42
|
+
this.#observeIncoming(message);
|
|
43
|
+
this.onmessage(message, extra);
|
|
44
|
+
};
|
|
45
|
+
await this.#inner.start();
|
|
46
|
+
}
|
|
47
|
+
async send(message, options) {
|
|
48
|
+
this.#observeOutgoing(message);
|
|
49
|
+
await this.#inner.send(message, options);
|
|
50
|
+
}
|
|
51
|
+
async close() {
|
|
52
|
+
await this.#telemetry.close();
|
|
53
|
+
await this.#inner.close();
|
|
54
|
+
}
|
|
55
|
+
#observeIncoming(message) {
|
|
56
|
+
const initialization = InitializeRequestSchema.safeParse(message);
|
|
57
|
+
if (initialization.success) {
|
|
58
|
+
this.#telemetry.setClientInfo(initialization.data.params.clientInfo.name, initialization.data.params.clientInfo.version);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const call = callRequestSchema.safeParse(message);
|
|
62
|
+
if (call.success) {
|
|
63
|
+
this.#pending.set(String(call.data.id), {
|
|
64
|
+
operation: call.data.params.name,
|
|
65
|
+
startedAt: performance.now(),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
#observeOutgoing(message) {
|
|
70
|
+
const response = responseSchema.safeParse(message);
|
|
71
|
+
if (!response.success) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const pending = this.#pending.get(String(response.data.id));
|
|
75
|
+
if (pending === undefined) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
this.#pending.delete(String(response.data.id));
|
|
79
|
+
const failed = response.data.error !== undefined || response.data.result?.isError === true;
|
|
80
|
+
this.#telemetry.recordOperation(pending.operation, failed ? 'error' : 'success', performance.now() - pending.startedAt);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/telemetry/transport.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAuB,MAAM,oCAAoC,CAAC;AAClG,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,MAAM,cAAc,GAAG,CAAC;KACrB,MAAM,CAAC;IACN,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACrC,MAAM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2
1
|
import type { Repositories, TaskRecord } from '../db/index.js';
|
|
2
|
+
import type { ClaimWorkInput } from '../domain/operations.js';
|
|
3
3
|
import { type OverlapWarning } from '../domain/overlap.js';
|
|
4
|
-
import { type ClaimWorkInput } from '../domain/schemas.js';
|
|
5
4
|
export interface ClaimWorkResult {
|
|
6
5
|
task: TaskRecord;
|
|
7
6
|
alreadyClaimed: boolean;
|
|
@@ -34,20 +33,3 @@ export interface ClaimWorkResult {
|
|
|
34
33
|
* merged scope, and the additions are reported back.
|
|
35
34
|
*/
|
|
36
35
|
export declare function handleClaimWork(repos: Repositories, input: ClaimWorkInput): ClaimWorkResult;
|
|
37
|
-
export declare function formatClaimWorkText(result: ClaimWorkResult): string;
|
|
38
|
-
/** The `claim_work` MCP structured output. All keys are snake_case, including
|
|
39
|
-
* overlap entries, so the payload is internally consistent. */
|
|
40
|
-
export declare function toClaimWorkStructured(result: ClaimWorkResult): {
|
|
41
|
-
task_id: string;
|
|
42
|
-
parent_task_id: string | null;
|
|
43
|
-
already_claimed: boolean;
|
|
44
|
-
overlaps: {
|
|
45
|
-
task_id: string;
|
|
46
|
-
title: string;
|
|
47
|
-
reasons: string[];
|
|
48
|
-
}[];
|
|
49
|
-
checked_against: number;
|
|
50
|
-
breadth_reasons: string[];
|
|
51
|
-
scope_added: string[];
|
|
52
|
-
};
|
|
53
|
-
export declare function registerClaimWork(server: McpServer, repos: Repositories, onWrite?: () => void): void;
|
package/dist/tools/claim-work.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { assessClaimBreadth } from '../domain/decomposition.js';
|
|
2
2
|
import { detectOverlaps } from '../domain/overlap.js';
|
|
3
|
-
import { claimWorkInputShape } from '../domain/schemas.js';
|
|
4
3
|
/** Union of two label lists, de-duplicated, existing entries first. */
|
|
5
4
|
function mergeUnique(existing, incoming) {
|
|
6
5
|
return [...new Set([...existing, ...incoming])];
|
|
@@ -23,6 +22,14 @@ export function handleClaimWork(repos, input) {
|
|
|
23
22
|
const inputDomains = input.domains ?? [];
|
|
24
23
|
const inputRiskTags = input.risk_tags ?? [];
|
|
25
24
|
const existing = repos.tasks.get(input.task_id);
|
|
25
|
+
if (input.agent_id !== undefined && repos.agents.get(input.agent_id) === undefined) {
|
|
26
|
+
throw new Error(`Agent ${input.agent_id} is not registered. Call start_work first.`);
|
|
27
|
+
}
|
|
28
|
+
if (existing?.agentId !== null &&
|
|
29
|
+
existing?.agentId !== undefined &&
|
|
30
|
+
input.agent_id !== existing.agentId) {
|
|
31
|
+
throw new Error(`Task ${input.task_id} is owned by ${existing.agentId}; use transfer_work to offer or reassign it.`);
|
|
32
|
+
}
|
|
26
33
|
// Parent is set at first claim and preserved thereafter (identity is idempotent).
|
|
27
34
|
const parentTaskId = existing ? existing.parentTaskId : (input.parent_task_id ?? null);
|
|
28
35
|
// Effective scope: the merged surface for an existing claim, else the input.
|
|
@@ -84,66 +91,4 @@ export function handleClaimWork(repos, input) {
|
|
|
84
91
|
scopeAdded,
|
|
85
92
|
};
|
|
86
93
|
}
|
|
87
|
-
export function formatClaimWorkText(result) {
|
|
88
|
-
const verb = result.alreadyClaimed ? 'Already claimed' : 'Claimed';
|
|
89
|
-
const lines = [`${verb} ${result.task.taskId} (${result.task.title}).`];
|
|
90
|
-
if (result.alreadyClaimed && result.scopeAdded.length > 0) {
|
|
91
|
-
lines.push(`Extended claim scope (added ${result.scopeAdded.join(', ')}).`);
|
|
92
|
-
}
|
|
93
|
-
if (result.overlaps.length === 0) {
|
|
94
|
-
if (result.checkedAgainst === 0) {
|
|
95
|
-
lines.push('No other active claims to check against yet. Overlaps are only checked at ' +
|
|
96
|
-
'claim time, so a later overlapping claim will not appear here — run ' +
|
|
97
|
-
'`concord status` to re-check as others claim work.');
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
lines.push(`No overlaps with the ${String(result.checkedAgainst)} other active task(s) at claim time. ` +
|
|
101
|
-
'This is a point-in-time check — run `concord status` to re-check as new work is claimed.');
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
lines.push(`Potential overlaps (${String(result.overlaps.length)} of ${String(result.checkedAgainst)} active task(s)):`);
|
|
106
|
-
for (const overlap of result.overlaps) {
|
|
107
|
-
lines.push(` - ${overlap.taskId} (${overlap.title}): ${overlap.reasons.join('; ')}`);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (result.breadthReasons.length > 0) {
|
|
111
|
-
lines.push(`Heads-up: this claim looks broad (${result.breadthReasons.join('; ')}). ` +
|
|
112
|
-
'Consider splitting it into smaller, independently-handoffable tasks and claiming each separately.');
|
|
113
|
-
}
|
|
114
|
-
return lines.join('\n');
|
|
115
|
-
}
|
|
116
|
-
/** The `claim_work` MCP structured output. All keys are snake_case, including
|
|
117
|
-
* overlap entries, so the payload is internally consistent. */
|
|
118
|
-
export function toClaimWorkStructured(result) {
|
|
119
|
-
return {
|
|
120
|
-
task_id: result.task.taskId,
|
|
121
|
-
parent_task_id: result.task.parentTaskId,
|
|
122
|
-
already_claimed: result.alreadyClaimed,
|
|
123
|
-
overlaps: result.overlaps.map((overlap) => ({
|
|
124
|
-
task_id: overlap.taskId,
|
|
125
|
-
title: overlap.title,
|
|
126
|
-
reasons: overlap.reasons,
|
|
127
|
-
})),
|
|
128
|
-
checked_against: result.checkedAgainst,
|
|
129
|
-
breadth_reasons: result.breadthReasons,
|
|
130
|
-
scope_added: result.scopeAdded,
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
export function registerClaimWork(server, repos, onWrite) {
|
|
134
|
-
server.registerTool('claim_work', {
|
|
135
|
-
title: 'Claim work',
|
|
136
|
-
description: 'Record that an agent is starting a task and flag overlaps with other active tasks. ' +
|
|
137
|
-
'Call this before editing code. Overlap detection is point-in-time (only against tasks ' +
|
|
138
|
-
'already active at claim time); run `concord status` to re-check as others claim.',
|
|
139
|
-
inputSchema: claimWorkInputShape,
|
|
140
|
-
}, (args) => {
|
|
141
|
-
const result = handleClaimWork(repos, args);
|
|
142
|
-
onWrite?.();
|
|
143
|
-
return {
|
|
144
|
-
content: [{ type: 'text', text: formatClaimWorkText(result) }],
|
|
145
|
-
structuredContent: toClaimWorkStructured(result),
|
|
146
|
-
};
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
94
|
//# sourceMappingURL=claim-work.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claim-work.js","sourceRoot":"","sources":["../../src/tools/claim-work.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"claim-work.js","sourceRoot":"","sources":["../../src/tools/claim-work.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAuB,MAAM,sBAAsB,CAAC;AA2B3E,uEAAuE;AACvE,SAAS,WAAW,CAAC,QAA2B,EAAE,QAA2B;IAC3E,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,QAAQ,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;AAClD,CAAC;AAED,+DAA+D;AAC/D,SAAS,YAAY,CAAC,QAA2B,EAAE,QAA2B;IAC5E,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC/B,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACpE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,KAAmB,EAAE,KAAqB;IACxE,MAAM,UAAU,GAAG,KAAK,CAAC,cAAc,IAAI,EAAE,CAAC;IAC9C,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC;IACzC,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC;IACzC,MAAM,aAA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{
|
|
2
|
-
import type {
|
|
1
|
+
import type { HandoffRecord, OwnershipEventRecord, Repositories, ReviewRecord, TaskRecord, TaskUpdateRecord } from '../db/index.js';
|
|
2
|
+
import type { GetTaskContextInput } from '../domain/operations.js';
|
|
3
3
|
import { type OverlapWarning } from '../domain/overlap.js';
|
|
4
|
-
import { type GetTaskContextInput } from '../domain/schemas.js';
|
|
5
4
|
export interface TaskContextResult {
|
|
6
5
|
task: TaskRecord;
|
|
7
6
|
updates: TaskUpdateRecord[];
|
|
8
7
|
latestHandoff: HandoffRecord | undefined;
|
|
9
8
|
latestReview: ReviewRecord | undefined;
|
|
10
9
|
overlaps: OverlapWarning[];
|
|
10
|
+
pendingHandoff: HandoffRecord | undefined;
|
|
11
|
+
ownershipHistory: OwnershipEventRecord[];
|
|
11
12
|
}
|
|
12
13
|
export declare function handleGetTaskContext(repos: Repositories, input: GetTaskContextInput): TaskContextResult;
|
|
13
|
-
export declare function registerGetTaskContext(server: McpServer, repos: Repositories): void;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { detectOverlaps } from '../domain/overlap.js';
|
|
2
|
-
import { getTaskContextInputShape } from '../domain/schemas.js';
|
|
3
2
|
export function handleGetTaskContext(repos, input) {
|
|
4
3
|
const task = repos.tasks.get(input.task_id);
|
|
5
4
|
if (!task) {
|
|
6
|
-
throw new Error(`Task "${input.task_id}" is not claimed. Call
|
|
5
|
+
throw new Error(`Task "${input.task_id}" is not claimed. Call start_work first.`);
|
|
7
6
|
}
|
|
8
7
|
const overlaps = task.status === 'active'
|
|
9
8
|
? detectOverlaps({
|
|
@@ -23,55 +22,8 @@ export function handleGetTaskContext(repos, input) {
|
|
|
23
22
|
latestHandoff: repos.handoffs.latestForTask(task.taskId),
|
|
24
23
|
latestReview: repos.reviews.latestForTask(task.taskId),
|
|
25
24
|
overlaps,
|
|
25
|
+
pendingHandoff: repos.handoffs.pendingForTask(task.taskId),
|
|
26
|
+
ownershipHistory: repos.ownershipEvents.listByTask(task.taskId),
|
|
26
27
|
};
|
|
27
28
|
}
|
|
28
|
-
function formatContext(result) {
|
|
29
|
-
const updates = result.updates.length === 0
|
|
30
|
-
? ' None'
|
|
31
|
-
: result.updates
|
|
32
|
-
.map((update) => ` [${update.kind}] ${update.content} — ${update.agent ?? 'unknown agent'}`)
|
|
33
|
-
.join('\n');
|
|
34
|
-
const overlaps = result.overlaps.length === 0
|
|
35
|
-
? ' None'
|
|
36
|
-
: result.overlaps
|
|
37
|
-
.map((overlap) => ` ${overlap.taskId}: ${overlap.reasons.join('; ')}`)
|
|
38
|
-
.join('\n');
|
|
39
|
-
return [
|
|
40
|
-
`${result.task.taskId} — ${result.task.title}`,
|
|
41
|
-
`Status: ${result.task.status}`,
|
|
42
|
-
`Agent: ${result.task.agent ?? 'unassigned'}`,
|
|
43
|
-
`Notes: ${result.task.notes ?? 'not recorded'}`,
|
|
44
|
-
'Updates:',
|
|
45
|
-
updates,
|
|
46
|
-
'Live overlaps:',
|
|
47
|
-
overlaps,
|
|
48
|
-
`Latest handoff: ${result.latestHandoff?.whatChanged ?? 'none'}`,
|
|
49
|
-
`Review plan: ${result.latestReview?.planSummary ?? 'not submitted'}`,
|
|
50
|
-
].join('\n');
|
|
51
|
-
}
|
|
52
|
-
export function registerGetTaskContext(server, repos) {
|
|
53
|
-
server.registerTool('get_task_context', {
|
|
54
|
-
title: 'Get task context',
|
|
55
|
-
description: "Read a claimed task's scope, ordered updates, latest handoff and review, and current overlaps.",
|
|
56
|
-
inputSchema: getTaskContextInputShape,
|
|
57
|
-
annotations: {
|
|
58
|
-
readOnlyHint: true,
|
|
59
|
-
destructiveHint: false,
|
|
60
|
-
idempotentHint: true,
|
|
61
|
-
openWorldHint: false,
|
|
62
|
-
},
|
|
63
|
-
}, (input) => {
|
|
64
|
-
const result = handleGetTaskContext(repos, input);
|
|
65
|
-
return {
|
|
66
|
-
content: [{ type: 'text', text: formatContext(result) }],
|
|
67
|
-
structuredContent: {
|
|
68
|
-
task: result.task,
|
|
69
|
-
updates: result.updates,
|
|
70
|
-
latest_handoff: result.latestHandoff ?? null,
|
|
71
|
-
latest_review: result.latestReview ?? null,
|
|
72
|
-
overlaps: result.overlaps,
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
29
|
//# sourceMappingURL=get-task-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-task-context.js","sourceRoot":"","sources":["../../src/tools/get-task-context.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,cAAc,EAAuB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"get-task-context.js","sourceRoot":"","sources":["../../src/tools/get-task-context.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,cAAc,EAAuB,MAAM,sBAAsB,CAAC;AAY3E,MAAM,UAAU,oBAAoB,CAClC,KAAmB,EACnB,KAA0B;IAE1B,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC5C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,SAAS,KAAK,CAAC,OAAO,0CAA0C,CAAC,CAAC;IACpF,CAAC;IAED,MAAM,QAAQ,GACZ,IAAI,CAAC,MAAM,KAAK,QAAQ;QACtB,CAAC,CAAC,cAAc,CACZ;YACE,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,EACD,KAAK,CAAC,KAAK;aACR,IAAI,EAAE;aACN,MAAM,CACL,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,IAAI,SAAS,CAAC,MAAM,KAAK,QAAQ,CACjF,CACJ;QACH,CAAC,CAAC,EAAE,CAAC;IAET,OAAO;QACL,IAAI;QACJ,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;QAClD,aAAa,EAAE,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;QACxD,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;QACtD,QAAQ;QACR,cAAc,EAAE,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC;QAC1D,gBAAgB,EAAE,KAAK,CAAC,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;KAChE,CAAC;AACJ,CAAC"}
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { type StatusView } from '../artifacts/work-state-view.js';
|
|
3
3
|
import type { Repositories } from '../db/index.js';
|
|
4
|
+
import { type SelectWorkspace } from './workspace-routing.js';
|
|
4
5
|
/** Stable URI for the read-only work-state resource. */
|
|
5
6
|
export declare const WORK_STATE_URI = "concord://work-state";
|
|
6
7
|
/**
|
|
7
8
|
* Read the current shared work-state. Pure read: no writes, no artifact
|
|
8
9
|
* regeneration. Overlaps are recomputed live across all active tasks, so this
|
|
9
|
-
* reflects claims made after any single agent's own `
|
|
10
|
+
* reflects claims made after any single agent's own `start_work` returned.
|
|
10
11
|
*/
|
|
11
12
|
export declare function handleGetWorkState(repos: Repositories): StatusView;
|
|
12
13
|
/**
|
|
13
|
-
* Register the read
|
|
14
|
-
*
|
|
15
|
-
* MCP-native read). Both return the same snapshot. This is read-only and does
|
|
16
|
-
* not change the three-tool *write* surface.
|
|
14
|
+
* Register the read-only `concord://work-state` resource. The public
|
|
15
|
+
* `inspect_work` workflow tool returns the same workspace snapshot.
|
|
17
16
|
*
|
|
18
17
|
* Returns a `notifyChanged` callback: call it after any write so subscribed
|
|
19
18
|
* clients are pushed a `resources/updated` for `concord://work-state`. MCP
|
|
20
19
|
* cannot wake an idle client — this is push while a session is connected.
|
|
21
20
|
*/
|
|
22
|
-
export declare function
|
|
21
|
+
export declare function registerWorkStateResource(server: McpServer, repos: Repositories, selectWorkspace?: SelectWorkspace): () => void;
|
|
@@ -1,59 +1,41 @@
|
|
|
1
1
|
import { SubscribeRequestSchema, UnsubscribeRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
-
import { buildStatus
|
|
2
|
+
import { buildStatus } from '../artifacts/work-state-view.js';
|
|
3
|
+
import { selectToolWorkspace, workspaceStructured, } from './workspace-routing.js';
|
|
3
4
|
/** Stable URI for the read-only work-state resource. */
|
|
4
5
|
export const WORK_STATE_URI = 'concord://work-state';
|
|
5
6
|
/**
|
|
6
7
|
* Read the current shared work-state. Pure read: no writes, no artifact
|
|
7
8
|
* regeneration. Overlaps are recomputed live across all active tasks, so this
|
|
8
|
-
* reflects claims made after any single agent's own `
|
|
9
|
+
* reflects claims made after any single agent's own `start_work` returned.
|
|
9
10
|
*/
|
|
10
11
|
export function handleGetWorkState(repos) {
|
|
11
12
|
return buildStatus(repos);
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
|
-
* Register the read
|
|
15
|
-
*
|
|
16
|
-
* MCP-native read). Both return the same snapshot. This is read-only and does
|
|
17
|
-
* not change the three-tool *write* surface.
|
|
15
|
+
* Register the read-only `concord://work-state` resource. The public
|
|
16
|
+
* `inspect_work` workflow tool returns the same workspace snapshot.
|
|
18
17
|
*
|
|
19
18
|
* Returns a `notifyChanged` callback: call it after any write so subscribed
|
|
20
19
|
* clients are pushed a `resources/updated` for `concord://work-state`. MCP
|
|
21
20
|
* cannot wake an idle client — this is push while a session is connected.
|
|
22
21
|
*/
|
|
23
|
-
export function
|
|
24
|
-
server.registerTool('get_work_state', {
|
|
25
|
-
title: 'Get work state',
|
|
26
|
-
description: 'Read the current shared work-state: who is present (the agent roster with liveness), ' +
|
|
27
|
-
'active claims, overlaps (recomputed live across all active tasks), and review-ready ' +
|
|
28
|
-
'tasks. Read-only — call this before claiming to see who else is here and what they are ' +
|
|
29
|
-
'already working on.',
|
|
30
|
-
}, () => {
|
|
31
|
-
const view = handleGetWorkState(repos);
|
|
32
|
-
return {
|
|
33
|
-
content: [{ type: 'text', text: renderStatusText(view) }],
|
|
34
|
-
structuredContent: {
|
|
35
|
-
presence: view.presence,
|
|
36
|
-
active: view.active,
|
|
37
|
-
overlaps: view.overlaps,
|
|
38
|
-
stale_claims: view.staleClaims,
|
|
39
|
-
review_ready: view.reviewReady,
|
|
40
|
-
open_questions: view.openQuestions,
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
});
|
|
22
|
+
export function registerWorkStateResource(server, repos, selectWorkspace) {
|
|
44
23
|
server.registerResource('work-state', WORK_STATE_URI, {
|
|
45
24
|
title: 'Concord work state',
|
|
46
25
|
description: 'Active claims, live overlaps, and review-ready tasks as JSON.',
|
|
47
26
|
mimeType: 'application/json',
|
|
48
|
-
}, (uri) =>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
27
|
+
}, (uri) => {
|
|
28
|
+
const workspace = selectToolWorkspace(selectWorkspace, undefined);
|
|
29
|
+
return {
|
|
30
|
+
contents: [
|
|
31
|
+
{
|
|
32
|
+
uri: uri.href,
|
|
33
|
+
mimeType: 'application/json',
|
|
34
|
+
text: `${JSON.stringify({ ...workspaceStructured(workspace), ...handleGetWorkState(repos) }, null, 2)}\n`,
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
});
|
|
57
39
|
// Advertise resource subscriptions and track which URIs clients care about,
|
|
58
40
|
// so writes push a targeted `resources/updated` rather than a broadcast.
|
|
59
41
|
server.server.registerCapabilities({ resources: { subscribe: true } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-work-state.js","sourceRoot":"","sources":["../../src/tools/get-work-state.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"get-work-state.js","sourceRoot":"","sources":["../../src/tools/get-work-state.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAmB,MAAM,iCAAiC,CAAC;AAE/E,OAAO,EACL,mBAAmB,EAEnB,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAEhC,wDAAwD;AACxD,MAAM,CAAC,MAAM,cAAc,GAAG,sBAAsB,CAAC;AAErD;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAmB;IACpD,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CACvC,MAAiB,EACjB,KAAmB,EACnB,eAAiC;IAEjC,MAAM,CAAC,gBAAgB,CACrB,YAAY,EACZ,cAAc,EACd;QACE,KAAK,EAAE,oBAAoB;QAC3B,WAAW,EAAE,+DAA+D;QAC5E,QAAQ,EAAE,kBAAkB;KAC7B,EACD,CAAC,GAAG,EAAE,EAAE;QACN,MAAM,SAAS,GAAG,mBAAmB,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;QAClE,OAAO;YACL,QAAQ,EAAE;gBACR;oBACE,GAAG,EAAE,GAAG,CAAC,IAAI;oBACb,QAAQ,EAAE,kBAAkB;oBAC5B,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CACrB,EAAE,GAAG,mBAAmB,CAAC,SAAS,CAAC,EAAE,GAAG,kBAAkB,CAAC,KAAK,CAAC,EAAE,EACnE,IAAI,EACJ,CAAC,CACF,IAAI;iBACN;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,4EAA4E;IAC5E,yEAAyE;IACzE,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IACvE,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IACtC,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,CAAC,OAAO,EAAE,EAAE;QAClE,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACpC,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,wBAAwB,EAAE,CAAC,OAAO,EAAE,EAAE;QACpE,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACvC,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,EAAE;QACV,IAAI,WAAW,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC;YACpC,KAAK,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC,CAAC;QAClE,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HandoffRecord, OwnershipEventRecord, Repositories, TaskRecord } from '../db/index.js';
|
|
2
|
+
import type { AcceptHandoffInput, DeclineHandoffInput, OfferHandoffInput } from '../domain/operations.js';
|
|
3
|
+
export interface HandoffLifecycleResult {
|
|
4
|
+
task: TaskRecord;
|
|
5
|
+
handoff: HandoffRecord;
|
|
6
|
+
ownershipEvent: OwnershipEventRecord;
|
|
7
|
+
}
|
|
8
|
+
export declare function handleOfferHandoff(repos: Repositories, input: OfferHandoffInput, now?: number): HandoffLifecycleResult;
|
|
9
|
+
export declare function handleAcceptHandoff(repos: Repositories, input: AcceptHandoffInput, now?: number): HandoffLifecycleResult;
|
|
10
|
+
export declare function handleDeclineHandoff(repos: Repositories, input: DeclineHandoffInput): HandoffLifecycleResult;
|