@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.
Files changed (90) hide show
  1. package/README.md +8 -4
  2. package/dist/artifacts/work-state-view.js +21 -5
  3. package/dist/artifacts/work-state-view.js.map +1 -1
  4. package/dist/cli/commands/adapters.js +12 -1
  5. package/dist/cli/commands/adapters.js.map +1 -1
  6. package/dist/cli/commands/cloud-codex.d.ts +14 -0
  7. package/dist/cli/commands/cloud-codex.js +148 -0
  8. package/dist/cli/commands/cloud-codex.js.map +1 -0
  9. package/dist/cli/commands/cloud-hooks.d.ts +11 -0
  10. package/dist/cli/commands/cloud-hooks.js +121 -0
  11. package/dist/cli/commands/cloud-hooks.js.map +1 -0
  12. package/dist/cli/commands/cloud-inbox.d.ts +49 -0
  13. package/dist/cli/commands/cloud-inbox.js +167 -0
  14. package/dist/cli/commands/cloud-inbox.js.map +1 -0
  15. package/dist/cli/commands/cloud-views.d.ts +11 -0
  16. package/dist/cli/commands/cloud-views.js +92 -0
  17. package/dist/cli/commands/cloud-views.js.map +1 -0
  18. package/dist/cli/commands/cloud.d.ts +41 -0
  19. package/dist/cli/commands/cloud.js +226 -0
  20. package/dist/cli/commands/cloud.js.map +1 -0
  21. package/dist/cli/commands/export.js +7 -0
  22. package/dist/cli/commands/export.js.map +1 -1
  23. package/dist/cli/commands/hook.js +39 -19
  24. package/dist/cli/commands/hook.js.map +1 -1
  25. package/dist/cli/commands/inbox.js +129 -57
  26. package/dist/cli/commands/inbox.js.map +1 -1
  27. package/dist/cli/commands/session-start-message.d.ts +8 -0
  28. package/dist/cli/commands/session-start-message.js +21 -0
  29. package/dist/cli/commands/session-start-message.js.map +1 -0
  30. package/dist/cli/commands/setup.d.ts +7 -2
  31. package/dist/cli/commands/setup.js +26 -11
  32. package/dist/cli/commands/setup.js.map +1 -1
  33. package/dist/cli/commands/status.js +4 -2
  34. package/dist/cli/commands/status.js.map +1 -1
  35. package/dist/cli/commands/tasks.js +4 -2
  36. package/dist/cli/commands/tasks.js.map +1 -1
  37. package/dist/cli/commands/who.js +4 -2
  38. package/dist/cli/commands/who.js.map +1 -1
  39. package/dist/cli/index.js +16 -1
  40. package/dist/cli/index.js.map +1 -1
  41. package/dist/cloud/browser-login.d.ts +27 -0
  42. package/dist/cloud/browser-login.js +115 -0
  43. package/dist/cloud/browser-login.js.map +1 -0
  44. package/dist/cloud/client.d.ts +68 -0
  45. package/dist/cloud/client.js +114 -0
  46. package/dist/cloud/client.js.map +1 -0
  47. package/dist/cloud/http-transport.d.ts +18 -0
  48. package/dist/cloud/http-transport.js +40 -0
  49. package/dist/cloud/http-transport.js.map +1 -0
  50. package/dist/cloud/proxy.d.ts +56 -0
  51. package/dist/cloud/proxy.js +162 -0
  52. package/dist/cloud/proxy.js.map +1 -0
  53. package/dist/cloud/runtime.d.ts +152 -0
  54. package/dist/cloud/runtime.js +332 -0
  55. package/dist/cloud/runtime.js.map +1 -0
  56. package/dist/cloud/settings.d.ts +62 -0
  57. package/dist/cloud/settings.js +162 -0
  58. package/dist/cloud/settings.js.map +1 -0
  59. package/dist/cloud/tokens.d.ts +20 -0
  60. package/dist/cloud/tokens.js +87 -0
  61. package/dist/cloud/tokens.js.map +1 -0
  62. package/dist/config/paths.d.ts +13 -0
  63. package/dist/config/paths.js +40 -0
  64. package/dist/config/paths.js.map +1 -1
  65. package/dist/db/repositories/reviews.d.ts +1 -0
  66. package/dist/db/repositories/reviews.js +23 -0
  67. package/dist/db/repositories/reviews.js.map +1 -1
  68. package/dist/db/repositories/tasks.d.ts +1 -0
  69. package/dist/db/repositories/tasks.js +9 -0
  70. package/dist/db/repositories/tasks.js.map +1 -1
  71. package/dist/domain/project-key.d.ts +23 -0
  72. package/dist/domain/project-key.js +109 -0
  73. package/dist/domain/project-key.js.map +1 -0
  74. package/dist/domain/pull-inbox.d.ts +12 -0
  75. package/dist/domain/pull-inbox.js +14 -1
  76. package/dist/domain/pull-inbox.js.map +1 -1
  77. package/dist/domain/schemas.d.ts +1 -1
  78. package/dist/index.js +11 -2
  79. package/dist/index.js.map +1 -1
  80. package/dist/install/adapters/index.js +6 -13
  81. package/dist/install/adapters/index.js.map +1 -1
  82. package/dist/relay/server.d.ts +2 -0
  83. package/dist/relay/server.js +26 -5
  84. package/dist/relay/server.js.map +1 -1
  85. package/dist/server.d.ts +1 -1
  86. package/dist/version.d.ts +1 -1
  87. package/dist/version.js +1 -1
  88. package/package.json +1 -1
  89. package/plugin/concord-relay/scripts/watch-inbox.sh +11 -0
  90. package/plugin/cursor/concord-relay/cursor-hook.mjs +16 -1
@@ -0,0 +1,167 @@
1
+ import { setTimeout as delay } from 'node:timers/promises';
2
+ import { cloudSessionFor } from '../../cloud/proxy.js';
3
+ import { asCloudAgent, CloudApiError, connectPullEndpoint, drainCloud, MAX_WAIT_SECONDS, readAgentState, releaseReceiver, renewReceiver, takeDrainKey, toDeliverables, updateAgentState, } from '../../cloud/runtime.js';
4
+ import { readLink } from '../../cloud/settings.js';
5
+ import { resolveCheckoutRoot, resolveRepoRoot } from '../../config/paths.js';
6
+ import { capabilityFor, encodeCapabilities, monitorCapabilityFor } from '../../domain/delivery.js';
7
+ /**
8
+ * The inbox commands, in a repository linked to Concord Cloud: the same output,
9
+ * from the cloud instead of `.concord/concord.db`.
10
+ *
11
+ * None of this records telemetry: these are not local operations, and the
12
+ * cloud records its own usage.
13
+ */
14
+ /** Whether this directory's repository is linked to Concord Cloud. */
15
+ export function cloudLinked(cwd, env = process.env) {
16
+ try {
17
+ return readLink(resolveRepoRoot(cwd, env)) !== undefined;
18
+ }
19
+ catch {
20
+ return false;
21
+ }
22
+ }
23
+ /**
24
+ * A hook runs inside the harness's own time limit (Cursor allows 15 s, Grok
25
+ * 5 s), so all its requests, retries included, are over within this.
26
+ */
27
+ export const HOOK_TIMEOUT_MS = 4_000;
28
+ export function cloudAccess(cwd, options = {}, env = process.env) {
29
+ if (!cloudLinked(cwd, env))
30
+ return { kind: 'local' };
31
+ try {
32
+ // The checkout this command runs in, which in a linked worktree is not the
33
+ // primary one holding the link: paths are made relative to it.
34
+ const session = cloudSessionFor(resolveRepoRoot(cwd, env), env, undefined, resolveCheckoutRoot(cwd, env));
35
+ if (session === undefined)
36
+ return { kind: 'local' };
37
+ const deadline = options.timeoutMs === undefined ? {} : { deadline: Date.now() + options.timeoutMs };
38
+ return { kind: 'cloud', runtime: { ...session, fetch, ...deadline } };
39
+ }
40
+ catch (error) {
41
+ // Linked, but not logged in, or logged in elsewhere: say so, never fall
42
+ // back to a local inbox no other agent would see.
43
+ return { kind: 'unusable', reason: error instanceof Error ? error.message : String(error) };
44
+ }
45
+ }
46
+ /** How long the receiver lease lasts; renewed well within it each round. */
47
+ const RECEIVER_TTL_SECONDS = 90;
48
+ /** Pause after a failed round, so an outage is not met with a request storm. */
49
+ const RETRY_DELAY_MS = 5_000;
50
+ /** Whether a running `inbox watch` on this machine holds the agent's receiver. */
51
+ export function watching(runtime, agentKey) {
52
+ return (readAgentState(runtime, agentKey)?.watchingUntil ?? 0) > Date.now();
53
+ }
54
+ /**
55
+ * Advertises the session as able to drain its messages. A running monitor's
56
+ * idle reach is kept: advertising less would make the agent look unreachable
57
+ * while it waits, and re-registering clears the cloud's receiver lease, so the
58
+ * lease is taken again on the monitor's behalf.
59
+ */
60
+ async function advertise(runtime, agent, agentKey, provider, asMonitor) {
61
+ const monitor = asMonitor || watching(runtime, agentKey);
62
+ const capability = monitor ? monitorCapabilityFor(provider) : capabilityFor(provider);
63
+ await connectPullEndpoint(runtime, agent, agentKey, provider, encodeCapabilities(capability));
64
+ if (monitor && !asMonitor)
65
+ await renewReceiver(runtime, agent, RECEIVER_TTL_SECONDS);
66
+ }
67
+ /**
68
+ * Registers the session (from the cached ids when known) and advertises its
69
+ * endpoint. A fresh registration advertises before its ids are kept, so one
70
+ * that could not be advertised is registered again next time.
71
+ */
72
+ export function registerInCloud(runtime, agentKey, provider, cwd, asMonitor = false) {
73
+ let advertised = false;
74
+ const advertiseOnce = async (agent) => {
75
+ await advertise(runtime, agent, agentKey, provider, asMonitor);
76
+ advertised = true;
77
+ };
78
+ return asCloudAgent(runtime, { agentKey, kind: provider, cwd }, async (agent) => {
79
+ if (!advertised)
80
+ await advertiseOnce(agent);
81
+ return agent;
82
+ }, advertiseOnce);
83
+ }
84
+ /** A failure worth repeating: the network, a timeout, or the cloud briefly unwell. */
85
+ function transient(error) {
86
+ if (error instanceof CloudApiError)
87
+ return error.status === 429 || error.status >= 500;
88
+ return error instanceof TypeError || error.name === 'TimeoutError';
89
+ }
90
+ /**
91
+ * Drains once, under a key held until the answer arrives: a drain whose answer
92
+ * was lost — to the network, a timeout, or the process ending — is retried
93
+ * with its key, now or by a later drain, and the cloud replays its batch.
94
+ */
95
+ async function drainOnce(runtime, agent, agentKey, waitSeconds, signal) {
96
+ const ticket = takeDrainKey(runtime, agentKey);
97
+ let messages;
98
+ try {
99
+ // A replayed key answers at once, so it never waits.
100
+ messages = await drainCloud(runtime, agent, ticket.key, ticket.replay ? 0 : waitSeconds, signal);
101
+ }
102
+ catch (error) {
103
+ if (signal?.aborted === true || !(error instanceof Error) || !transient(error))
104
+ throw error;
105
+ messages = await drainCloud(runtime, agent, ticket.key, 0, signal);
106
+ }
107
+ ticket.finish();
108
+ return toDeliverables(messages);
109
+ }
110
+ /** Takes every message waiting for the session, as a hook does after a tool call. */
111
+ export function drainFromCloud(runtime, agentKey, provider) {
112
+ return asCloudAgent(runtime, { agentKey, kind: provider }, (agent) => drainOnce(runtime, agent, agentKey, 0),
113
+ // Registered here because session start could not: advertise it too, as
114
+ // every local drain does.
115
+ (agent) => advertise(runtime, agent, agentKey, provider, false));
116
+ }
117
+ /**
118
+ * The session's live receiver: long-polls the cloud, so a message arrives
119
+ * within moments rather than on the next two-second poll. Each round renews
120
+ * the receiver lease and waits on one drain. Stops on SIGINT, SIGTERM or
121
+ * SIGHUP, after the first batch with `once`, or on a failure retrying cannot
122
+ * fix (a lapsed login); releases the lease either way.
123
+ */
124
+ export async function watchCloud(runtime, agentKey, provider, once,
125
+ /** Awaited before the next round, so a slow handoff never overlaps the next batch. */
126
+ emit) {
127
+ const stop = new AbortController();
128
+ const stopped = () => stop.signal.aborted;
129
+ const stopWatching = () => {
130
+ stop.abort();
131
+ };
132
+ const signals = ['SIGINT', 'SIGTERM', 'SIGHUP'];
133
+ for (const name of signals)
134
+ process.once(name, stopWatching);
135
+ let agent;
136
+ try {
137
+ while (!stopped()) {
138
+ try {
139
+ agent ??= await registerInCloud(runtime, agentKey, provider, process.cwd(), true);
140
+ await renewReceiver(runtime, agent, RECEIVER_TTL_SECONDS);
141
+ updateAgentState(runtime, agentKey, {
142
+ watchingUntil: Date.now() + RECEIVER_TTL_SECONDS * 1000,
143
+ });
144
+ const messages = await drainOnce(runtime, agent, agentKey, MAX_WAIT_SECONDS, stop.signal);
145
+ if (messages.length > 0)
146
+ await emit(messages, stop.signal);
147
+ if (once && messages.length > 0)
148
+ return;
149
+ }
150
+ catch (error) {
151
+ if (stopped())
152
+ return;
153
+ if (!(error instanceof Error) || !transient(error))
154
+ throw error;
155
+ await delay(RETRY_DELAY_MS, undefined, { signal: stop.signal }).catch(() => undefined);
156
+ }
157
+ }
158
+ }
159
+ finally {
160
+ for (const name of signals)
161
+ process.off(name, stopWatching);
162
+ updateAgentState(runtime, agentKey, { watchingUntil: undefined });
163
+ if (agent !== undefined)
164
+ await releaseReceiver(runtime, agent).catch(() => undefined);
165
+ }
166
+ }
167
+ //# sourceMappingURL=cloud-inbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloud-inbox.js","sourceRoot":"","sources":["../../../src/cli/commands/cloud-inbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,UAAU,EACV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AK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YACzF,CAAC;QACH,CAAC;IACH,CAAC;YAAS,CAAC;QACT,KAAK,MAAM,IAAI,IAAI,OAAO;YAAE,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QAC5D,gBAAgB,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC,CAAC;QAClE,IAAI,KAAK,KAAK,SAAS;YAAE,MAAM,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACxF,CAAC;AACH,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { type CloudRuntime } from '../../cloud/runtime.js';
2
+ /** Everyone in the organization, on any machine, liveliest first. */
3
+ export declare function runCloudWho(runtime: CloudRuntime, now?: number): Promise<string>;
4
+ /** The project's tasks, in the local `tasks` table's layout, holders by key. */
5
+ export declare function runCloudTasks(runtime: CloudRuntime): Promise<string>;
6
+ /** The workspace as agents see it: the cloud's own `inspect_work` overview. */
7
+ export declare function runCloudStatus(runtime: CloudRuntime): Promise<string>;
8
+ /** Why `export` does nothing here: its artifacts are written from the local database. */
9
+ export declare const CLOUD_EXPORT_MESSAGE: string;
10
+ /** Runs `view` against the cloud for a linked repository; undefined when it is local. */
11
+ export declare function inCloud(cwd: string, view: (runtime: CloudRuntime) => Promise<string>): Promise<string | undefined>;
@@ -0,0 +1,92 @@
1
+ import { z } from 'zod';
2
+ import { renderRosterLines } from '../../artifacts/work-state-view.js';
3
+ import { cloudSessionFor, connectCloud } from '../../cloud/proxy.js';
4
+ import { listCloudAgents, listCloudTasks, TASK_PAGE, } from '../../cloud/runtime.js';
5
+ import { agentStatusValues } from '../../db/rows.js';
6
+ import { deriveLiveness } from '../../domain/presence.js';
7
+ import { cloudAccess } from './cloud-inbox.js';
8
+ /**
9
+ * `who`, `tasks` and `status` in a repository linked to Concord Cloud: the
10
+ * organization's agents and the project's tasks as the cloud holds them, not
11
+ * the empty local database. None records telemetry.
12
+ */
13
+ function heading(runtime) {
14
+ return `Workspace: Concord Cloud ${runtime.projectKey} (${runtime.apiUrl})`;
15
+ }
16
+ const agentStatus = z.enum(agentStatusValues).catch('active');
17
+ /** Everyone in the organization, on any machine, liveliest first. */
18
+ export async function runCloudWho(runtime, now = Date.now()) {
19
+ const roster = (await listCloudAgents(runtime))
20
+ .map((agent) => ({
21
+ agentId: agent.agentKey,
22
+ kind: agent.kind,
23
+ owner: null,
24
+ summary: agent.summary,
25
+ status: agentStatus.parse(agent.status),
26
+ liveness: deriveLiveness(agent.lastSeenAt, now),
27
+ lastSeen: agent.lastSeenAt,
28
+ ageSeconds: Math.max(0, Math.floor((now - Date.parse(agent.lastSeenAt)) / 1000)),
29
+ }))
30
+ .filter((entry) => entry.liveness !== 'archived')
31
+ // Liveness only decays with time, so the most recently seen are the liveliest.
32
+ .sort((first, second) => second.lastSeen.localeCompare(first.lastSeen));
33
+ return [heading(runtime), "Who's here", ...renderRosterLines(roster)].join('\n');
34
+ }
35
+ /** The project's tasks, in the local `tasks` table's layout, holders by key. */
36
+ export async function runCloudTasks(runtime) {
37
+ const [tasks, agents] = await Promise.all([listCloudTasks(runtime), listCloudAgents(runtime)]);
38
+ if (tasks.length === 0) {
39
+ return [heading(runtime), 'No tasks yet. Agents create tasks by calling start_work.'].join('\n');
40
+ }
41
+ const keys = new Map(agents.map((agent) => [agent.id, agent.agentKey]));
42
+ const holder = (id) => (id === null ? undefined : keys.get(id));
43
+ const rows = tasks.map((task) => {
44
+ const agent = holder(task.agentId) ?? holder(task.assignedAgentId) ?? '-';
45
+ return `${task.taskKey.padEnd(10)} ${task.status.padEnd(13)} v${String(task.version).padEnd(4)} ${agent.padEnd(18)} ${task.updatedAt} ${task.title}`;
46
+ });
47
+ // A full page may not be all of them: the cloud returns the most recent first.
48
+ const more = tasks.length >= TASK_PAGE
49
+ ? [
50
+ `Showing the ${String(TASK_PAGE)} most recently updated tasks; see the dashboard for older ones.`,
51
+ ]
52
+ : [];
53
+ return [heading(runtime), ...rows, ...more].join('\n');
54
+ }
55
+ const toolResult = z.object({
56
+ isError: z.boolean().optional(),
57
+ content: z.array(z.object({ type: z.string(), text: z.string().optional() })),
58
+ });
59
+ /** The workspace as agents see it: the cloud's own `inspect_work` overview. */
60
+ export async function runCloudStatus(runtime) {
61
+ const session = cloudSessionFor(runtime.repoRoot, process.env, undefined, runtime.checkoutRoot);
62
+ if (session === undefined)
63
+ throw new Error('This repository is no longer linked to Concord Cloud.');
64
+ const client = await connectCloud(session);
65
+ try {
66
+ const raw = await client.callTool({ name: 'inspect_work', arguments: {} });
67
+ const result = toolResult.parse(raw);
68
+ const text = result.content
69
+ .flatMap((part) => (part.type === 'text' && part.text !== undefined ? [part.text] : []))
70
+ .join('\n');
71
+ if (result.isError === true) {
72
+ throw new Error(`Concord Cloud could not show the workspace: ${text}`);
73
+ }
74
+ return [heading(runtime), text].join('\n');
75
+ }
76
+ finally {
77
+ await client.close();
78
+ }
79
+ }
80
+ /** Why `export` does nothing here: its artifacts are written from the local database. */
81
+ export const CLOUD_EXPORT_MESSAGE = 'This repository is linked to Concord Cloud, where its work state lives; `concord export` ' +
82
+ 'writes artifacts from the local database. See the dashboard at https://app.getconcord.ai.';
83
+ /** Runs `view` against the cloud for a linked repository; undefined when it is local. */
84
+ export async function inCloud(cwd, view) {
85
+ const access = cloudAccess(cwd);
86
+ if (access.kind === 'local')
87
+ return undefined;
88
+ if (access.kind === 'unusable')
89
+ throw new Error(`Concord Cloud: ${access.reason}`);
90
+ return view(access.runtime);
91
+ }
92
+ //# sourceMappingURL=cloud-views.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloud-views.js","sourceRoot":"","sources":["../../../src/cli/commands/cloud-views.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,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M,CAAC,IAAI,KAAK,UAAU;QAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IACnF,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,41 @@
1
+ import type { Command } from '@commander-js/extra-typings';
2
+ import { type Fetch } from '../../cloud/client.js';
3
+ import { type BrowserLoginDeps } from '../../cloud/browser-login.js';
4
+ /**
5
+ * `concord cloud` — connecting this machine and a repository to Concord Cloud.
6
+ * Non-local operations, so the CLI records no telemetry for them.
7
+ */
8
+ export interface CloudDeps {
9
+ readonly env: NodeJS.ProcessEnv;
10
+ readonly cwd: string;
11
+ readonly fetch: Fetch;
12
+ /** Reads a secret piped on stdin, for `--key-stdin`. */
13
+ readonly readStdin: () => Promise<string>;
14
+ /** The repository's `origin` remote, or undefined when there is none. */
15
+ readonly originRemote: (repoRoot: string) => string | undefined;
16
+ readonly hostname: () => string;
17
+ readonly newMachineKey: () => string;
18
+ /** For browser login: open a URL, tell the person, read a pasted code. */
19
+ readonly browser: Omit<BrowserLoginDeps, 'fetch'>;
20
+ }
21
+ /** Concord Cloud, unless `--url` names another deployment. */
22
+ export declare const DEFAULT_API_URL = "https://api.getconcord.ai";
23
+ export declare const API_KEY_ENV = "CONCORD_CLOUD_API_KEY";
24
+ export declare function runCloudLogin(options: {
25
+ readonly url?: string;
26
+ readonly keyStdin?: boolean;
27
+ readonly browser?: boolean;
28
+ }, deps: CloudDeps): Promise<string>;
29
+ export declare function runCloudLogout(deps: CloudDeps): string;
30
+ export declare function runCloudLink(options: {
31
+ readonly project?: string;
32
+ }, deps: CloudDeps): string;
33
+ export declare function runCloudUnlink(deps: CloudDeps): string;
34
+ export declare function runCloudStatus(deps: CloudDeps): Promise<string>;
35
+ /**
36
+ * How to open a URL in the browser on each platform, with the URL passed as a
37
+ * single argument and never through a shell. On Windows that rules out
38
+ * `cmd /c start`: `cmd` reads `&` (in every OAuth URL) as a command separator.
39
+ */
40
+ export declare function browserCommand(platform: NodeJS.Platform, url: string): [string, string[]];
41
+ export declare function registerCloudCommand(program: Command): void;
@@ -0,0 +1,226 @@
1
+ import { spawn, spawnSync } from 'node:child_process';
2
+ import { createInterface } from 'node:readline';
3
+ import { randomUUID } from 'node:crypto';
4
+ import { hostname } from 'node:os';
5
+ import { assertKeySafeUrl, checkKey, fetchMeta, incompatibility, registerMachine, sameApi, } from '../../cloud/client.js';
6
+ import { ensureMachineKey, readCredentials, readLink, removeCredentials, removeLink, writeCredentials, writeLink, } from '../../cloud/settings.js';
7
+ import { browserLogin } from '../../cloud/browser-login.js';
8
+ import { bearerFor } from '../../cloud/tokens.js';
9
+ import { resolveRepoRoot } from '../../config/paths.js';
10
+ import { normalizeProjectKey } from '../../domain/project-key.js';
11
+ import { VERSION } from '../../version.js';
12
+ /** Concord Cloud, unless `--url` names another deployment. */
13
+ export const DEFAULT_API_URL = 'https://api.getconcord.ai';
14
+ export const API_KEY_ENV = 'CONCORD_CLOUD_API_KEY';
15
+ /** A key shown in output: enough to tell keys apart, never enough to use one. */
16
+ function maskKey(apiKey) {
17
+ return `${apiKey.slice(0, 7)}…`;
18
+ }
19
+ export async function runCloudLogin(options, deps) {
20
+ const apiUrl = options.url ?? DEFAULT_API_URL;
21
+ // A key only ever from stdin or the environment: a flag lands in shell history.
22
+ const apiKey = (options.keyStdin === true ? await deps.readStdin() : (deps.env[API_KEY_ENV] ?? '')).trim();
23
+ if (options.keyStdin === true && apiKey === '') {
24
+ throw new Error('No API key arrived on stdin.');
25
+ }
26
+ assertKeySafeUrl(apiUrl);
27
+ const meta = await fetchMeta(apiUrl, deps.fetch);
28
+ const problem = incompatibility(meta);
29
+ if (problem !== null) {
30
+ throw new Error(`Cannot use ${apiUrl}: ${problem}.`);
31
+ }
32
+ let credentials;
33
+ if (apiKey !== '') {
34
+ credentials = { apiUrl, apiKey };
35
+ }
36
+ else if (meta.cliLogin !== undefined) {
37
+ const oauth = await browserLogin(meta.cliLogin, { paste: options.browser === false }, { ...deps.browser, fetch: deps.fetch });
38
+ credentials = { apiUrl, oauth };
39
+ }
40
+ else {
41
+ throw new Error(`${apiUrl} offers no browser login; pass an API key with --key-stdin or ${API_KEY_ENV}.`);
42
+ }
43
+ const bearer = 'apiKey' in credentials ? credentials.apiKey : credentials.oauth.accessToken;
44
+ // Kept across logins and logouts, so this machine stays one machine.
45
+ const machineKey = ensureMachineKey(deps.env, deps.newMachineKey);
46
+ const host = deps.hostname();
47
+ const registered = await registerMachine(apiUrl, bearer, { machineKey, name: host, hostname: host, platform: process.platform, runtimeVersion: VERSION }, deps.fetch);
48
+ if (registered === 'rejected') {
49
+ throw new Error(`${apiUrl} rejected ${'apiKey' in credentials ? 'that API key' : 'the sign-in'}.`);
50
+ }
51
+ writeCredentials(deps.env, credentials);
52
+ return `Logged in to ${apiUrl} (API v${String(meta.apiVersion)}) ${'apiKey' in credentials ? `with key ${maskKey(credentials.apiKey)}` : 'through the browser'}.`;
53
+ }
54
+ export function runCloudLogout(deps) {
55
+ return removeCredentials(deps.env)
56
+ ? 'Logged out; linked repositories stay linked but cannot reach the cloud until you log in again.'
57
+ : 'Not logged in.';
58
+ }
59
+ export function runCloudLink(options, deps) {
60
+ const credentials = readCredentials(deps.env);
61
+ if (credentials === undefined) {
62
+ throw new Error('Not logged in; run `concord cloud login` first.');
63
+ }
64
+ const repoRoot = resolveRepoRoot(deps.cwd, deps.env);
65
+ const remote = options.project ?? deps.originRemote(repoRoot);
66
+ if (remote === undefined) {
67
+ throw new Error('This repository has no `origin` remote. Name it with --project <remote>, ' +
68
+ 'such as github.com/org/repo, so every clone links to the same project.');
69
+ }
70
+ const projectKey = normalizeProjectKey(remote);
71
+ if (projectKey === null) {
72
+ throw new Error(`"${remote}" is not a git remote, such as github.com/org/repo.`);
73
+ }
74
+ writeLink(repoRoot, { apiUrl: credentials.apiUrl, projectKey });
75
+ return `Linked ${repoRoot} to ${projectKey} on ${credentials.apiUrl}.`;
76
+ }
77
+ export function runCloudUnlink(deps) {
78
+ const repoRoot = resolveRepoRoot(deps.cwd, deps.env);
79
+ return removeLink(repoRoot)
80
+ ? `Unlinked ${repoRoot}; Concord stays local here.`
81
+ : `${repoRoot} was not linked.`;
82
+ }
83
+ export async function runCloudStatus(deps) {
84
+ const repoRoot = resolveRepoRoot(deps.cwd, deps.env);
85
+ const credentials = readCredentials(deps.env);
86
+ const link = readLink(repoRoot);
87
+ const lines = [
88
+ credentials === undefined
89
+ ? 'Login: none (run `concord cloud login`)'
90
+ : `Login: ${credentials.apiUrl} ${'apiKey' in credentials
91
+ ? `with key ${maskKey(credentials.apiKey)}`
92
+ : 'signed in through the browser'}`,
93
+ link === undefined
94
+ ? `Repository: ${repoRoot} is local (not linked)`
95
+ : `Repository: ${repoRoot} is linked to ${link.projectKey} on ${link.apiUrl}`,
96
+ ];
97
+ if (credentials !== undefined &&
98
+ link !== undefined &&
99
+ !sameApi(link.apiUrl, credentials.apiUrl)) {
100
+ lines.push(`Warning: linked to ${link.apiUrl}, but logged in to ${credentials.apiUrl}; ` +
101
+ 'the checks below are for the login, and cloud mode will refuse this pair.');
102
+ }
103
+ if (credentials !== undefined) {
104
+ // Two checks, reported apart, so a failing key check never hides an API
105
+ // that answered.
106
+ try {
107
+ const meta = await fetchMeta(credentials.apiUrl, deps.fetch);
108
+ const problem = incompatibility(meta);
109
+ lines.push(problem === null
110
+ ? `API: reachable, v${String(meta.apiVersion)}, compatible`
111
+ : `API: reachable but ${problem}`);
112
+ }
113
+ catch (error) {
114
+ lines.push(`API: unreachable (${error instanceof Error ? error.message : String(error)})`);
115
+ }
116
+ try {
117
+ const bearer = await bearerFor(deps.env, credentials.apiUrl, deps.fetch)();
118
+ const key = await checkKey(credentials.apiUrl, bearer, deps.fetch);
119
+ lines.push(key === 'ok' ? 'Key: accepted' : 'Key: rejected — log in again');
120
+ }
121
+ catch (error) {
122
+ lines.push(`Key: not checked (${error instanceof Error ? error.message : String(error)})`);
123
+ }
124
+ }
125
+ return lines.join('\n');
126
+ }
127
+ function originRemote(repoRoot) {
128
+ const result = spawnSync('git', ['-C', repoRoot, 'remote', 'get-url', 'origin'], {
129
+ encoding: 'utf8',
130
+ });
131
+ const url = result.status === 0 ? result.stdout.trim() : '';
132
+ return url === '' ? undefined : url;
133
+ }
134
+ async function readStdin() {
135
+ const chunks = [];
136
+ for await (const chunk of process.stdin) {
137
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)));
138
+ }
139
+ return Buffer.concat(chunks).toString('utf8');
140
+ }
141
+ /**
142
+ * How to open a URL in the browser on each platform, with the URL passed as a
143
+ * single argument and never through a shell. On Windows that rules out
144
+ * `cmd /c start`: `cmd` reads `&` (in every OAuth URL) as a command separator.
145
+ */
146
+ export function browserCommand(platform, url) {
147
+ if (platform === 'darwin')
148
+ return ['open', [url]];
149
+ if (platform === 'win32')
150
+ return ['rundll32', ['url.dll,FileProtocolHandler', url]];
151
+ return ['xdg-open', [url]];
152
+ }
153
+ function openUrl(url) {
154
+ const [command, args] = browserCommand(process.platform, url);
155
+ // Fire and forget: the link is printed too, for when no browser opens.
156
+ spawn(command, args, { stdio: 'ignore', detached: true, shell: false })
157
+ .on('error', () => undefined)
158
+ .unref();
159
+ }
160
+ async function readLine() {
161
+ const lines = createInterface({ input: process.stdin, terminal: false });
162
+ try {
163
+ for await (const line of lines)
164
+ return line;
165
+ return '';
166
+ }
167
+ finally {
168
+ lines.close();
169
+ }
170
+ }
171
+ function liveDeps() {
172
+ return {
173
+ env: process.env,
174
+ cwd: process.cwd(),
175
+ fetch,
176
+ readStdin,
177
+ originRemote,
178
+ hostname,
179
+ newMachineKey: randomUUID,
180
+ browser: {
181
+ openUrl,
182
+ print: (line) => process.stderr.write(`${line}\n`),
183
+ readLine,
184
+ },
185
+ };
186
+ }
187
+ /** Prints a command's result, or its error as one line with a failing exit code. */
188
+ async function report(run) {
189
+ try {
190
+ process.stdout.write(`${await run()}\n`);
191
+ }
192
+ catch (error) {
193
+ process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
194
+ process.exitCode = 1;
195
+ }
196
+ }
197
+ export function registerCloudCommand(program) {
198
+ const cloud = program
199
+ .command('cloud')
200
+ .description('Connect this machine and repository to Concord Cloud');
201
+ cloud
202
+ .command('login')
203
+ .description(`Sign in to Concord Cloud in the browser, or with an API key (stdin or ${API_KEY_ENV})`)
204
+ .option('--url <url>', `Concord Cloud API URL (default ${DEFAULT_API_URL})`)
205
+ .option('--key-stdin', 'read an API key from stdin instead of signing in')
206
+ .option('--no-browser', 'show a sign-in link and paste the code back (for SSH sessions)')
207
+ .action((options) => report(() => runCloudLogin(options, liveDeps())));
208
+ cloud
209
+ .command('logout')
210
+ .description('Forget the saved Concord Cloud API key')
211
+ .action(() => report(() => runCloudLogout(liveDeps())));
212
+ cloud
213
+ .command('link')
214
+ .description('Link this repository to Concord Cloud')
215
+ .option('--project <remote>', 'the repository, when it has no origin remote')
216
+ .action((options) => report(() => runCloudLink(options, liveDeps())));
217
+ cloud
218
+ .command('unlink')
219
+ .description('Return this repository to local Concord')
220
+ .action(() => report(() => runCloudUnlink(liveDeps())));
221
+ cloud
222
+ .command('status')
223
+ .description('Show the login, link and whether the API is usable')
224
+ .action(() => report(() => runCloudStatus(liveDeps())));
225
+ }
226
+ //# sourceMappingURL=cloud.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloud.js","sourceRoot":"","sources":["../../../src/cli/commands/cloud.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAInC,OAAO,EACL,gBAAgB,EAChB,QAAQ,EACR,SAAS,EACT,eAAe,EACf,eAAe,EACf,OAAO,GAER,MAAM,uBAA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;IAE1D,KAAK;SACF,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,uCAAuC,CAAC;SACpD,MAAM,CAAC,oBAAoB,EAAE,8CAA8C,CAAC;SAC5E,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;IAExE,KAAK;SACF,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,yCAAyC,CAAC;SACtD,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;IAE1D,KAAK;SACF,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,oDAAoD,CAAC;SACjE,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;AAC5D,CAAC"}
@@ -2,6 +2,8 @@ import { existsSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { writeArtifacts } from '../../artifacts/index.js';
4
4
  import { openContext } from '../context.js';
5
+ import { cloudLinked } from './cloud-inbox.js';
6
+ import { CLOUD_EXPORT_MESSAGE } from './cloud-views.js';
5
7
  const ARTIFACT_FILES = ['HANDOFF.md', 'REVIEW_PACKET.md', 'WORK_STATE.json', 'events.jsonl'];
6
8
  /** Regenerate the markdown/JSON artifacts and return the files that now exist. */
7
9
  export function runExportMarkdown(cwd) {
@@ -20,6 +22,11 @@ export function registerExportCommand(program) {
20
22
  process.exitCode = 1;
21
23
  return;
22
24
  }
25
+ if (cloudLinked(process.cwd())) {
26
+ process.stderr.write(`${CLOUD_EXPORT_MESSAGE}\n`);
27
+ process.exitCode = 1;
28
+ return;
29
+ }
23
30
  const written = runExportMarkdown(process.cwd());
24
31
  process.stdout.write(`Wrote ${String(written.length)} artifact(s): ${written.join(', ')}\n`);
25
32
  });
@@ -1 +1 @@
1
- {"version":3,"file":"export.js","sourceRoot":"","sources":["../../../src/cli/commands/export.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,cAAc,GAAG,CAAC,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,cAAc,CAAC,CAAC;AAE7F,kFAAkF;AAClF,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC3C,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IAC7B,cAAc,CAAC,GAAG,CAAC,WAAW,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;IAC3C,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AAClF,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IACpD,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,QAAQ,CAAC,UAAU,EAAE,eAAe,EAAE,UAAU,CAAC;SACjD,WAAW,CAAC,kDAAkD,CAAC;SAC/D,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;QACjB,IAAI,MAAM,KAAK,UAAU,EAAE,CAAC;YAC1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,8BAA8B,MAAM,mCAAmC,CACxE,CAAC;YACF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;YACrB,OAAO;QACT,CAAC;QACD,MAAM,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACjD,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