@concord-ai/concord-mcp 0.10.5 → 0.12.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 +8 -4
- package/dist/artifacts/work-state-view.js +21 -5
- package/dist/artifacts/work-state-view.js.map +1 -1
- package/dist/cli/commands/adapters.js +12 -1
- package/dist/cli/commands/adapters.js.map +1 -1
- package/dist/cli/commands/cloud-codex.d.ts +14 -0
- package/dist/cli/commands/cloud-codex.js +148 -0
- package/dist/cli/commands/cloud-codex.js.map +1 -0
- package/dist/cli/commands/cloud-hooks.d.ts +11 -0
- package/dist/cli/commands/cloud-hooks.js +121 -0
- package/dist/cli/commands/cloud-hooks.js.map +1 -0
- package/dist/cli/commands/cloud-inbox.d.ts +49 -0
- package/dist/cli/commands/cloud-inbox.js +167 -0
- package/dist/cli/commands/cloud-inbox.js.map +1 -0
- package/dist/cli/commands/cloud-views.d.ts +11 -0
- package/dist/cli/commands/cloud-views.js +92 -0
- package/dist/cli/commands/cloud-views.js.map +1 -0
- package/dist/cli/commands/cloud.d.ts +41 -0
- package/dist/cli/commands/cloud.js +226 -0
- package/dist/cli/commands/cloud.js.map +1 -0
- package/dist/cli/commands/export.js +7 -0
- package/dist/cli/commands/export.js.map +1 -1
- package/dist/cli/commands/hook.js +39 -19
- package/dist/cli/commands/hook.js.map +1 -1
- package/dist/cli/commands/inbox.js +129 -57
- package/dist/cli/commands/inbox.js.map +1 -1
- package/dist/cli/commands/session-start-message.d.ts +8 -0
- package/dist/cli/commands/session-start-message.js +21 -0
- package/dist/cli/commands/session-start-message.js.map +1 -0
- package/dist/cli/commands/setup.d.ts +7 -2
- package/dist/cli/commands/setup.js +26 -11
- package/dist/cli/commands/setup.js.map +1 -1
- package/dist/cli/commands/status.js +4 -2
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/tasks.js +4 -2
- package/dist/cli/commands/tasks.js.map +1 -1
- package/dist/cli/commands/who.js +4 -2
- package/dist/cli/commands/who.js.map +1 -1
- package/dist/cli/index.js +16 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cloud/browser-login.d.ts +27 -0
- package/dist/cloud/browser-login.js +115 -0
- package/dist/cloud/browser-login.js.map +1 -0
- package/dist/cloud/client.d.ts +68 -0
- package/dist/cloud/client.js +114 -0
- package/dist/cloud/client.js.map +1 -0
- package/dist/cloud/http-transport.d.ts +18 -0
- package/dist/cloud/http-transport.js +40 -0
- package/dist/cloud/http-transport.js.map +1 -0
- package/dist/cloud/proxy.d.ts +56 -0
- package/dist/cloud/proxy.js +162 -0
- package/dist/cloud/proxy.js.map +1 -0
- package/dist/cloud/runtime.d.ts +152 -0
- package/dist/cloud/runtime.js +332 -0
- package/dist/cloud/runtime.js.map +1 -0
- package/dist/cloud/settings.d.ts +62 -0
- package/dist/cloud/settings.js +162 -0
- package/dist/cloud/settings.js.map +1 -0
- package/dist/cloud/tokens.d.ts +20 -0
- package/dist/cloud/tokens.js +87 -0
- package/dist/cloud/tokens.js.map +1 -0
- package/dist/config/paths.d.ts +13 -0
- package/dist/config/paths.js +40 -0
- package/dist/config/paths.js.map +1 -1
- package/dist/db/repositories/reviews.d.ts +1 -0
- package/dist/db/repositories/reviews.js +23 -0
- package/dist/db/repositories/reviews.js.map +1 -1
- package/dist/db/repositories/tasks.d.ts +1 -0
- package/dist/db/repositories/tasks.js +9 -0
- package/dist/db/repositories/tasks.js.map +1 -1
- package/dist/domain/project-key.d.ts +23 -0
- package/dist/domain/project-key.js +109 -0
- package/dist/domain/project-key.js.map +1 -0
- package/dist/domain/pull-inbox.d.ts +12 -0
- package/dist/domain/pull-inbox.js +14 -1
- package/dist/domain/pull-inbox.js.map +1 -1
- package/dist/domain/schemas.d.ts +1 -1
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/install/adapters/index.js +6 -13
- package/dist/install/adapters/index.js.map +1 -1
- package/dist/relay/server.d.ts +2 -0
- package/dist/relay/server.js +26 -5
- package/dist/relay/server.js.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/plugin/concord-relay/scripts/watch-inbox.sh +11 -0
- package/plugin/cursor/concord-relay/cursor-hook.mjs +16 -1
package/README.md
CHANGED
|
@@ -169,13 +169,17 @@ To restrict explicit workspace selection, set `CONCORD_ALLOWED_ROOTS` to a
|
|
|
169
169
|
path-delimited list of allowed repository roots. Without an allowlist, decoded
|
|
170
170
|
roots must still exist and be directories.
|
|
171
171
|
|
|
172
|
-
`concord setup`
|
|
173
|
-
|
|
174
|
-
Teams that want selected artifacts in PRs can
|
|
175
|
-
|
|
172
|
+
`concord setup` writes a `.concord/.gitignore` containing `*`, so the generated
|
|
173
|
+
workspace ignores itself and stays local without editing the repository's shared
|
|
174
|
+
`.gitignore`. Teams that want selected artifacts in PRs can add negation rules to
|
|
175
|
+
that file (setup keeps existing rules, only ensuring the `*` catch-all) or
|
|
176
|
+
force-add the human-readable files. Repositories set up by Concord 0.10.5 or
|
|
177
|
+
earlier also have a `.concord/` rule in the root `.gitignore`; remove it before
|
|
178
|
+
negations in `.concord/.gitignore` can take effect.
|
|
176
179
|
|
|
177
180
|
```text
|
|
178
181
|
.concord/
|
|
182
|
+
├── .gitignore ignores the whole directory
|
|
179
183
|
├── concord.db local source of truth
|
|
180
184
|
├── HANDOFF.md human-readable handoff
|
|
181
185
|
├── REVIEW_PACKET.md review-ready evidence
|
|
@@ -3,16 +3,28 @@ import { effectiveEndpointCapabilities } from '../domain/delivery.js';
|
|
|
3
3
|
import { detectOverlaps } from '../domain/overlap.js';
|
|
4
4
|
import { endpointPromptable } from '../tools/agent-messages.js';
|
|
5
5
|
import { buildRoster, detectStaleClaims, } from '../domain/presence.js';
|
|
6
|
+
const ACTIVE_STATUSES = [
|
|
7
|
+
'assigned',
|
|
8
|
+
'active',
|
|
9
|
+
'blocked',
|
|
10
|
+
'handoff_offered',
|
|
11
|
+
];
|
|
12
|
+
const STATUS_VIEW_STATUSES = [
|
|
13
|
+
...ACTIVE_STATUSES,
|
|
14
|
+
'review_ready',
|
|
15
|
+
];
|
|
6
16
|
function touchesOf(task) {
|
|
7
17
|
const values = task.modules.length > 0 ? task.modules : task.expectedFiles.map((f) => dirname(f));
|
|
8
18
|
const unique = [...new Set(values.filter((v) => v !== '.' && v !== ''))];
|
|
9
19
|
return unique.length > 0 ? unique.join(', ') : '-';
|
|
10
20
|
}
|
|
11
21
|
export function buildStatus(repos, now = Date.now()) {
|
|
12
|
-
|
|
22
|
+
// Status only renders active/review-ready tasks. Keep historical completed/closed
|
|
23
|
+
// rows out of the hot path so long-lived workspaces do not pay to parse them.
|
|
24
|
+
const tasks = repos.tasks.listByStatuses(STATUS_VIEW_STATUSES);
|
|
13
25
|
const agents = repos.agents.list();
|
|
14
26
|
const endpointsByAgent = new Map(repos.agentEndpoints.list().map((endpoint) => [endpoint.agentId, endpoint]));
|
|
15
|
-
const activeStatuses = new Set(
|
|
27
|
+
const activeStatuses = new Set(ACTIVE_STATUSES);
|
|
16
28
|
const active = tasks.filter((task) => activeStatuses.has(task.status));
|
|
17
29
|
const overlaps = [];
|
|
18
30
|
// Overlap is symmetric. Scan only the upper triangle so every task pair is
|
|
@@ -32,10 +44,14 @@ export function buildStatus(repos, now = Date.now()) {
|
|
|
32
44
|
overlaps.push({ a: task.taskId, b: warning.taskId, reasons: warning.reasons });
|
|
33
45
|
}
|
|
34
46
|
}
|
|
47
|
+
const reviewTasks = tasks.filter((task) => task.status === 'review_ready');
|
|
48
|
+
const latestReviews = new Map(repos.reviews
|
|
49
|
+
.latestForTasks(reviewTasks.map((task) => task.taskId))
|
|
50
|
+
.map((review) => [review.taskId, review]));
|
|
35
51
|
const reviewReady = [];
|
|
36
52
|
const openQuestions = [];
|
|
37
|
-
for (const task of
|
|
38
|
-
const review =
|
|
53
|
+
for (const task of reviewTasks) {
|
|
54
|
+
const review = latestReviews.get(task.taskId);
|
|
39
55
|
if (review === undefined) {
|
|
40
56
|
continue;
|
|
41
57
|
}
|
|
@@ -66,7 +82,7 @@ export function buildStatus(repos, now = Date.now()) {
|
|
|
66
82
|
reviewReady,
|
|
67
83
|
openQuestions,
|
|
68
84
|
presence: buildRoster(agents, now),
|
|
69
|
-
staleClaims: detectStaleClaims(
|
|
85
|
+
staleClaims: detectStaleClaims(active, agents, now),
|
|
70
86
|
communications: agents.map((agent) => {
|
|
71
87
|
const endpoint = endpointsByAgent.get(agent.agentId);
|
|
72
88
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"work-state-view.js","sourceRoot":"","sources":["../../src/artifacts/work-state-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EACL,WAAW,EACX,iBAAiB,GAGlB,MAAM,uBAAuB,CAAC;AA0D/B,SAAS,SAAS,CAAC,IAAgB;IACjC,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAClG,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IACzE,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CA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,IAAI,CAAC,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvC,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,MAAM,MAAM,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -8,6 +8,8 @@ import { CodexDaemonClient } from '../../relay/codex-client.js';
|
|
|
8
8
|
import { startAgentRelay } from '../../relay/server.js';
|
|
9
9
|
import { installGlobalAdapters, renderAdapterReport, statusGlobalAdapters, uninstallGlobalAdapters, } from '../../install/adapters/index.js';
|
|
10
10
|
import { openContext } from '../context.js';
|
|
11
|
+
import { hostCodexInCloud } from './cloud-codex.js';
|
|
12
|
+
import { cloudAccess } from './cloud-inbox.js';
|
|
11
13
|
async function hostCodex(agentId, threadId) {
|
|
12
14
|
const context = openContext(process.cwd());
|
|
13
15
|
ensureAgentRegistered(context.repos, { agentId, kind: 'codex' }, context.repoRoot);
|
|
@@ -152,6 +154,15 @@ export function registerAdaptersCommand(program) {
|
|
|
152
154
|
.command('host-codex', { hidden: true })
|
|
153
155
|
.requiredOption('--agent <id>')
|
|
154
156
|
.requiredOption('--thread <id>')
|
|
155
|
-
.action(async (options) =>
|
|
157
|
+
.action(async (options) => {
|
|
158
|
+
const access = cloudAccess(process.cwd());
|
|
159
|
+
if (access.kind === 'unusable')
|
|
160
|
+
throw new Error(`Concord Cloud: ${access.reason}`);
|
|
161
|
+
if (access.kind === 'cloud') {
|
|
162
|
+
await hostCodexInCloud(access.runtime, options.agent, options.thread);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
await hostCodex(options.agent, options.thread);
|
|
166
|
+
});
|
|
156
167
|
}
|
|
157
168
|
//# sourceMappingURL=adapters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapters.js","sourceRoot":"","sources":["../../../src/cli/commands/adapters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"adapters.js","sourceRoot":"","sources":["../../../src/cli/commands/adapters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EACL,qBAAqB,EACrB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AAC;IACzF,CAAC,CAAC,CAAC;IACL,QAAQ;SACL,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,2DAA2D,CAAC;SACxE,QAAQ,CAAC,WAAW,EAAE,sCAAsC,CAAC;SAC7D,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IACzD,QAAQ;SACL,OAAO,CAAC,YAAY,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;SACvC,cAAc,CAAC,cAAc,CAAC;SAC9B,cAAc,CAAC,eAAe,CAAC;SAC/B,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACxB,MAAM,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC1C,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU;YAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QACnF,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC5B,MAAM,gBAAgB,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;YACtE,OAAO;QACT,CAAC;QACD,MAAM,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type CloudRuntime } from '../../cloud/runtime.js';
|
|
2
|
+
import { type DeliverableMessage } from '../../domain/pull-inbox.js';
|
|
3
|
+
import type { AgentSessionAdapter } from '../../relay/server.js';
|
|
4
|
+
/**
|
|
5
|
+
* Hands drained messages to the session, one at a time and never two at once.
|
|
6
|
+
* A handoff has no time limit: a wedged session stalls the host, which then
|
|
7
|
+
* drains nothing more and lets its receiver lease lapse, so later messages
|
|
8
|
+
* wait for the session's hooks instead. Stopping the host ends a handoff in
|
|
9
|
+
* progress and hands over nothing more. Every message not handed over — or
|
|
10
|
+
* whose handoff ended unconfirmed — is reported as not delivered.
|
|
11
|
+
*/
|
|
12
|
+
export declare function deliverToSession(runtime: CloudRuntime, agentKey: string, adapter: AgentSessionAdapter, messages: readonly DeliverableMessage[], stop?: AbortSignal): Promise<void>;
|
|
13
|
+
/** Hosts one Codex thread's live receiver against the cloud, until stopped. */
|
|
14
|
+
export declare function hostCodexInCloud(runtime: CloudRuntime, agentKey: string, threadId: string): Promise<void>;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { before, CloudApiError, agentCachePath, readAgentState, reportDeliveryFailure, } from '../../cloud/runtime.js';
|
|
6
|
+
import { renderInboxBody } from '../../domain/pull-inbox.js';
|
|
7
|
+
import { CodexAppServerAdapter } from '../../relay/adapters.js';
|
|
8
|
+
import { CodexDaemonClient } from '../../relay/codex-client.js';
|
|
9
|
+
import { RELAY_PROTOCOL_VERSION } from '../../relay/protocol.js';
|
|
10
|
+
import { watchCloud } from './cloud-inbox.js';
|
|
11
|
+
/**
|
|
12
|
+
* Codex, live, in a repository linked to Concord Cloud. The cloud cannot dial
|
|
13
|
+
* this machine, so the local host that already steers Codex through its
|
|
14
|
+
* app-server pulls instead: it holds the session's receiver and long-polls the
|
|
15
|
+
* cloud, and hands each message to Codex as it arrives — steering a turn under
|
|
16
|
+
* way, or starting one when Codex is idle — as the local relay does.
|
|
17
|
+
*/
|
|
18
|
+
/** How often saved failure reports are tried again while the host runs. */
|
|
19
|
+
const REPORT_RETRY_MS = 60_000;
|
|
20
|
+
const undeliveredSchema = z.object({ messageId: z.string(), detail: z.string() });
|
|
21
|
+
/** One file per report not yet made, so hosts never rewrite each other's. */
|
|
22
|
+
function unreportedDir(runtime, agentKey) {
|
|
23
|
+
return agentCachePath(runtime.repoRoot, agentKey).replace(/\.json$/, '.unreported');
|
|
24
|
+
}
|
|
25
|
+
function savedReports(dir) {
|
|
26
|
+
if (!existsSync(dir))
|
|
27
|
+
return [];
|
|
28
|
+
return readdirSync(dir).flatMap((name) => {
|
|
29
|
+
try {
|
|
30
|
+
const raw = JSON.parse(readFileSync(join(dir, name), 'utf8'));
|
|
31
|
+
const parsed = undeliveredSchema.safeParse(raw);
|
|
32
|
+
return parsed.success ? [{ ...parsed.data, file: join(dir, name) }] : [];
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Tells the cloud these messages were not delivered, so their senders do not
|
|
41
|
+
* take silence for delivery. The batch was drained, so a report that cannot be
|
|
42
|
+
* made now is saved and made on a later round, with any saved before.
|
|
43
|
+
*/
|
|
44
|
+
async function reportUndelivered(runtime, agentKey, failures) {
|
|
45
|
+
const state = readAgentState(runtime, agentKey);
|
|
46
|
+
if (state === undefined)
|
|
47
|
+
return;
|
|
48
|
+
const dir = unreportedDir(runtime, agentKey);
|
|
49
|
+
const pending = [
|
|
50
|
+
...savedReports(dir),
|
|
51
|
+
...failures.map((failure) => ({ ...failure, file: undefined })),
|
|
52
|
+
];
|
|
53
|
+
for (const failure of pending) {
|
|
54
|
+
let keep = false;
|
|
55
|
+
try {
|
|
56
|
+
await reportDeliveryFailure(runtime, state, failure.messageId, failure.detail);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
// Refused for good (the message moved on): nothing a retry would change.
|
|
60
|
+
keep = !(error instanceof CloudApiError && error.status < 500 && error.status !== 429);
|
|
61
|
+
}
|
|
62
|
+
if (keep && failure.file === undefined) {
|
|
63
|
+
mkdirSync(dir, { recursive: true });
|
|
64
|
+
const file = join(dir, `${createHash('sha256').update(failure.messageId).digest('hex').slice(0, 16)}.json`);
|
|
65
|
+
writeFileSync(file, JSON.stringify({ messageId: failure.messageId, detail: failure.detail }));
|
|
66
|
+
}
|
|
67
|
+
else if (!keep && failure.file !== undefined) {
|
|
68
|
+
rmSync(failure.file, { force: true });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Hands drained messages to the session, one at a time and never two at once.
|
|
74
|
+
* A handoff has no time limit: a wedged session stalls the host, which then
|
|
75
|
+
* drains nothing more and lets its receiver lease lapse, so later messages
|
|
76
|
+
* wait for the session's hooks instead. Stopping the host ends a handoff in
|
|
77
|
+
* progress and hands over nothing more. Every message not handed over — or
|
|
78
|
+
* whose handoff ended unconfirmed — is reported as not delivered.
|
|
79
|
+
*/
|
|
80
|
+
export async function deliverToSession(runtime, agentKey, adapter, messages, stop) {
|
|
81
|
+
const failures = [];
|
|
82
|
+
const stopped = () => stop?.aborted === true;
|
|
83
|
+
for (const message of messages) {
|
|
84
|
+
if (stopped()) {
|
|
85
|
+
failures.push({
|
|
86
|
+
messageId: message.messageId,
|
|
87
|
+
detail: 'The Codex host stopped before handing it over.',
|
|
88
|
+
});
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const delivery = {
|
|
92
|
+
version: RELAY_PROTOCOL_VERSION,
|
|
93
|
+
type: 'deliver',
|
|
94
|
+
messageId: message.messageId,
|
|
95
|
+
senderAgentId: message.senderAgentId,
|
|
96
|
+
recipientAgentId: agentKey,
|
|
97
|
+
// Framed as every other channel frames it, so the session knows who
|
|
98
|
+
// wrote and which id to answer.
|
|
99
|
+
content: renderInboxBody([message]),
|
|
100
|
+
};
|
|
101
|
+
const handoff = adapter.isBusy() ? adapter.steer(delivery) : adapter.inject(delivery);
|
|
102
|
+
try {
|
|
103
|
+
await (stop === undefined ? handoff : before(handoff, stop));
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
const detail = stopped()
|
|
107
|
+
? 'The Codex host stopped before Codex confirmed it; it may not have arrived.'
|
|
108
|
+
: error instanceof Error
|
|
109
|
+
? error.message
|
|
110
|
+
: String(error);
|
|
111
|
+
process.stderr.write(`Concord: could not hand ${message.messageId} to Codex: ${detail}\n`);
|
|
112
|
+
failures.push({ messageId: message.messageId, detail });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
await reportUndelivered(runtime, agentKey, failures);
|
|
116
|
+
}
|
|
117
|
+
/** Hosts one Codex thread's live receiver against the cloud, until stopped. */
|
|
118
|
+
export async function hostCodexInCloud(runtime, agentKey, threadId) {
|
|
119
|
+
const client = new CodexDaemonClient();
|
|
120
|
+
await client.connect();
|
|
121
|
+
await client.resumeThread(threadId);
|
|
122
|
+
const adapter = new CodexAppServerAdapter(client, threadId, () => client.currentTurnId());
|
|
123
|
+
// Reports saved while the cloud was unreachable are made now and every
|
|
124
|
+
// minute, not only when the next message happens to arrive.
|
|
125
|
+
// One pass at a time: a slow cloud must not stack passes sending the same reports.
|
|
126
|
+
let flushing = false;
|
|
127
|
+
const flush = () => {
|
|
128
|
+
if (flushing)
|
|
129
|
+
return;
|
|
130
|
+
flushing = true;
|
|
131
|
+
void reportUndelivered(runtime, agentKey, [])
|
|
132
|
+
.catch(() => undefined)
|
|
133
|
+
.finally(() => {
|
|
134
|
+
flushing = false;
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
flush();
|
|
138
|
+
const retrying = setInterval(flush, REPORT_RETRY_MS);
|
|
139
|
+
retrying.unref();
|
|
140
|
+
try {
|
|
141
|
+
await watchCloud(runtime, agentKey, 'codex', false, (messages, stop) => deliverToSession(runtime, agentKey, adapter, messages, stop));
|
|
142
|
+
}
|
|
143
|
+
finally {
|
|
144
|
+
clearInterval(retrying);
|
|
145
|
+
client.close();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=cloud-codex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+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+1,11 @@
|
|
|
1
|
+
import { type CloudRuntime } from '../../cloud/runtime.js';
|
|
2
|
+
import type { HookDecision, SessionStartResult } from './hook.js';
|
|
3
|
+
/**
|
|
4
|
+
* The local guard's rule, over the cloud's claims: another task holding the
|
|
5
|
+
* file blocks the edit when `CONCORD_TASK` names the caller's own task, and
|
|
6
|
+
* warns otherwise. Claims held by this session's own agent are never a
|
|
7
|
+
* conflict — the cloud says who holds each one, which the local check cannot.
|
|
8
|
+
*/
|
|
9
|
+
export declare function decideCloudPreToolUse(runtime: CloudRuntime, rawJson: string, selfTaskId: string | undefined, selfAgentKey: string | undefined): Promise<HookDecision>;
|
|
10
|
+
/** Session start in a linked repository: registered in the cloud, and told who else is there. */
|
|
11
|
+
export declare function handleCloudSessionStart(runtime: CloudRuntime, rawJson: string, env?: NodeJS.ProcessEnv): Promise<SessionStartResult>;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { isAbsolute } from 'node:path';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { repoRelative } from '../../cloud/proxy.js';
|
|
4
|
+
import { listClaims, listCloudAgents, } from '../../cloud/runtime.js';
|
|
5
|
+
import { UNRESOLVED_IDENTITY_MESSAGE } from '../../domain/identity.js';
|
|
6
|
+
import { deriveLiveness } from '../../domain/presence.js';
|
|
7
|
+
import { sessionStartIdentity } from '../agent-identity.js';
|
|
8
|
+
import { registerInCloud } from './cloud-inbox.js';
|
|
9
|
+
import { sessionStartMessage } from './session-start-message.js';
|
|
10
|
+
/**
|
|
11
|
+
* The Claude Code hooks in a repository linked to Concord Cloud: the edit
|
|
12
|
+
* guard asks the cloud who holds a file, and session start registers there and
|
|
13
|
+
* names everyone in the organization, on any machine.
|
|
14
|
+
*
|
|
15
|
+
* Neither records telemetry: these are not local operations.
|
|
16
|
+
*/
|
|
17
|
+
const preToolUsePayloadSchema = z
|
|
18
|
+
.object({
|
|
19
|
+
tool_input: z.object({ file_path: z.string().optional() }).loose().optional(),
|
|
20
|
+
})
|
|
21
|
+
.loose();
|
|
22
|
+
/**
|
|
23
|
+
* The guard runs before every edit, and Cloud Run may be starting from zero:
|
|
24
|
+
* past this, the edit goes ahead with a warning rather than stalling.
|
|
25
|
+
*/
|
|
26
|
+
const GUARD_TIMEOUT_MS = 3_000;
|
|
27
|
+
const NOT_APPLICABLE = {
|
|
28
|
+
block: false,
|
|
29
|
+
message: '',
|
|
30
|
+
result: 'not_applicable',
|
|
31
|
+
conflictingTaskCount: 0,
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The local guard's rule, over the cloud's claims: another task holding the
|
|
35
|
+
* file blocks the edit when `CONCORD_TASK` names the caller's own task, and
|
|
36
|
+
* warns otherwise. Claims held by this session's own agent are never a
|
|
37
|
+
* conflict — the cloud says who holds each one, which the local check cannot.
|
|
38
|
+
*/
|
|
39
|
+
export async function decideCloudPreToolUse(runtime, rawJson, selfTaskId, selfAgentKey) {
|
|
40
|
+
let parsed;
|
|
41
|
+
try {
|
|
42
|
+
parsed = JSON.parse(rawJson);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return NOT_APPLICABLE;
|
|
46
|
+
}
|
|
47
|
+
const filePath = preToolUsePayloadSchema.parse(parsed).tool_input?.file_path;
|
|
48
|
+
if (filePath === undefined || filePath === '')
|
|
49
|
+
return NOT_APPLICABLE;
|
|
50
|
+
const file = repoRelative(runtime, filePath);
|
|
51
|
+
// Outside this repository: nothing the project's claims could cover.
|
|
52
|
+
if (isAbsolute(file))
|
|
53
|
+
return NOT_APPLICABLE;
|
|
54
|
+
let claims;
|
|
55
|
+
try {
|
|
56
|
+
claims = await listClaims(runtime, [file], AbortSignal.timeout(GUARD_TIMEOUT_MS));
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
60
|
+
return {
|
|
61
|
+
block: false,
|
|
62
|
+
message: `Concord: could not check ${file} against Concord Cloud (${detail}); editing anyway.`,
|
|
63
|
+
result: 'not_applicable',
|
|
64
|
+
conflictingTaskCount: 0,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const others = claims.filter((claim) => claim.taskKey !== selfTaskId &&
|
|
68
|
+
(selfAgentKey === undefined || claim.agentKey !== selfAgentKey));
|
|
69
|
+
if (others.length === 0) {
|
|
70
|
+
return { block: false, message: '', result: 'clear', conflictingTaskCount: 0 };
|
|
71
|
+
}
|
|
72
|
+
const tasks = [...new Map(others.map((claim) => [claim.taskKey, claim])).values()];
|
|
73
|
+
const detail = tasks
|
|
74
|
+
.map((claim) => `${claim.taskKey} (${claim.title}, ${claim.agentKey ?? 'unassigned'})`)
|
|
75
|
+
.join(', ');
|
|
76
|
+
if (selfTaskId === undefined) {
|
|
77
|
+
return {
|
|
78
|
+
block: false,
|
|
79
|
+
message: `Concord: ${file} is also claimed by ${detail}. Set CONCORD_TASK=<your task id> to block colliding edits.`,
|
|
80
|
+
result: 'warned',
|
|
81
|
+
conflictingTaskCount: tasks.length,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
block: true,
|
|
86
|
+
message: `Concord: ${file} is claimed by another active task (${detail}). Coordinate or update your claim before editing.`,
|
|
87
|
+
result: 'blocked',
|
|
88
|
+
conflictingTaskCount: tasks.length,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const sessionStartPayloadSchema = z
|
|
92
|
+
.object({ session_id: z.string().optional(), cwd: z.string().optional() })
|
|
93
|
+
.loose();
|
|
94
|
+
/** Session start in a linked repository: registered in the cloud, and told who else is there. */
|
|
95
|
+
export async function handleCloudSessionStart(runtime, rawJson, env = process.env) {
|
|
96
|
+
let parsed;
|
|
97
|
+
try {
|
|
98
|
+
parsed = JSON.parse(rawJson);
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
parsed = {};
|
|
102
|
+
}
|
|
103
|
+
const payload = sessionStartPayloadSchema.parse(parsed);
|
|
104
|
+
const identity = sessionStartIdentity(payload.session_id, env);
|
|
105
|
+
if (identity === undefined) {
|
|
106
|
+
return { agentId: undefined, message: `Concord: ${UNRESOLVED_IDENTITY_MESSAGE}` };
|
|
107
|
+
}
|
|
108
|
+
await registerInCloud(runtime, identity.agentId, identity.kind, payload.cwd ?? process.cwd());
|
|
109
|
+
const now = Date.now();
|
|
110
|
+
const others = (await listCloudAgents(runtime))
|
|
111
|
+
.filter((agent) => agent.agentKey !== identity.agentId)
|
|
112
|
+
.map((agent) => ({
|
|
113
|
+
agentId: agent.agentKey,
|
|
114
|
+
liveness: deriveLiveness(agent.lastSeenAt, now),
|
|
115
|
+
status: agent.status,
|
|
116
|
+
summary: agent.summary,
|
|
117
|
+
}))
|
|
118
|
+
.filter((peer) => peer.liveness !== 'archived');
|
|
119
|
+
return { agentId: identity.agentId, message: sessionStartMessage(identity.agentId, others) };
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=cloud-hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud-hooks.js","sourceRoot":"","sources":["../../../src/cli/commands/cloud-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EACL,UAAU,EACV,eAAe,GAGhB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE;;;;;;GAMG;AAEH,MAAM,uBAAuB,GAAG,CAAC;KAC9B,MAAM,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C,CAAC;SAC5C,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,QAAQ,CAAC,OAAO,CAAC;SACtD,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACf,OAAO,EAAE,KAAK,CAAC,QAAQ;QACvB,QAAQ,EAAE,cAAc,CAAC,KAAK,CAAC,UAAU,EAAE,GAAG,CAAC;QAC/C,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,OAAO,EAAE,KAAK,CAAC,OAAO;KACvB,CAAC,CAAC;SACF,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC;IAClD,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,mBAAmB,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC;AAC/F,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type CloudAgentRef, type CloudRuntime } from '../../cloud/runtime.js';
|
|
2
|
+
import type { DeliverableMessage } from '../../domain/pull-inbox.js';
|
|
3
|
+
/**
|
|
4
|
+
* The inbox commands, in a repository linked to Concord Cloud: the same output,
|
|
5
|
+
* from the cloud instead of `.concord/concord.db`.
|
|
6
|
+
*
|
|
7
|
+
* None of this records telemetry: these are not local operations, and the
|
|
8
|
+
* cloud records its own usage.
|
|
9
|
+
*/
|
|
10
|
+
/** Whether this directory's repository is linked to Concord Cloud. */
|
|
11
|
+
export declare function cloudLinked(cwd: string, env?: NodeJS.ProcessEnv): boolean;
|
|
12
|
+
/** Where a command's work lives: locally, in the cloud, or in a link this machine cannot use. */
|
|
13
|
+
export type CloudAccess = {
|
|
14
|
+
readonly kind: 'local';
|
|
15
|
+
} | {
|
|
16
|
+
readonly kind: 'cloud';
|
|
17
|
+
readonly runtime: CloudRuntime;
|
|
18
|
+
} | {
|
|
19
|
+
readonly kind: 'unusable';
|
|
20
|
+
readonly reason: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* A hook runs inside the harness's own time limit (Cursor allows 15 s, Grok
|
|
24
|
+
* 5 s), so all its requests, retries included, are over within this.
|
|
25
|
+
*/
|
|
26
|
+
export declare const HOOK_TIMEOUT_MS = 4000;
|
|
27
|
+
export declare function cloudAccess(cwd: string, options?: {
|
|
28
|
+
readonly timeoutMs?: number;
|
|
29
|
+
}, env?: NodeJS.ProcessEnv): CloudAccess;
|
|
30
|
+
/** Whether a running `inbox watch` on this machine holds the agent's receiver. */
|
|
31
|
+
export declare function watching(runtime: CloudRuntime, agentKey: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Registers the session (from the cached ids when known) and advertises its
|
|
34
|
+
* endpoint. A fresh registration advertises before its ids are kept, so one
|
|
35
|
+
* that could not be advertised is registered again next time.
|
|
36
|
+
*/
|
|
37
|
+
export declare function registerInCloud(runtime: CloudRuntime, agentKey: string, provider: string, cwd: string, asMonitor?: boolean): Promise<CloudAgentRef>;
|
|
38
|
+
/** Takes every message waiting for the session, as a hook does after a tool call. */
|
|
39
|
+
export declare function drainFromCloud(runtime: CloudRuntime, agentKey: string, provider: string): Promise<DeliverableMessage[]>;
|
|
40
|
+
/**
|
|
41
|
+
* The session's live receiver: long-polls the cloud, so a message arrives
|
|
42
|
+
* within moments rather than on the next two-second poll. Each round renews
|
|
43
|
+
* the receiver lease and waits on one drain. Stops on SIGINT, SIGTERM or
|
|
44
|
+
* SIGHUP, after the first batch with `once`, or on a failure retrying cannot
|
|
45
|
+
* fix (a lapsed login); releases the lease either way.
|
|
46
|
+
*/
|
|
47
|
+
export declare function watchCloud(runtime: CloudRuntime, agentKey: string, provider: string, once: boolean,
|
|
48
|
+
/** Awaited before the next round, so a slow handoff never overlaps the next batch. */
|
|
49
|
+
emit: (messages: readonly DeliverableMessage[], stop: AbortSignal) => Promise<void> | void): Promise<void>;
|