@concord-ai/concord-mcp 0.13.0 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -0
- package/dist/cli/commands/check.js +2 -3
- package/dist/cli/commands/check.js.map +1 -1
- package/dist/cli/commands/cloud-inbox.d.ts +1 -1
- package/dist/cli/commands/cloud-inbox.js +3 -3
- package/dist/cli/commands/cloud-inbox.js.map +1 -1
- package/dist/cli/commands/cloud.d.ts +4 -0
- package/dist/cli/commands/cloud.js +62 -16
- package/dist/cli/commands/cloud.js.map +1 -1
- package/dist/cli/commands/doctor.d.ts +17 -1
- package/dist/cli/commands/doctor.js +54 -7
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/inbox.d.ts +12 -0
- package/dist/cli/commands/inbox.js +32 -5
- package/dist/cli/commands/inbox.js.map +1 -1
- package/dist/cli/commands/setup.d.ts +25 -0
- package/dist/cli/commands/setup.js +74 -7
- package/dist/cli/commands/setup.js.map +1 -1
- package/dist/cli/commands/watch.d.ts +6 -0
- package/dist/cli/commands/watch.js +9 -1
- package/dist/cli/commands/watch.js.map +1 -1
- package/dist/cli/context.d.ts +7 -1
- package/dist/cli/context.js +7 -4
- package/dist/cli/context.js.map +1 -1
- package/dist/cli/dashboard/app.js +4 -23
- package/dist/cli/dashboard/app.js.map +1 -1
- package/dist/cloud/proxy.d.ts +2 -2
- package/dist/cloud/proxy.js +5 -4
- package/dist/cloud/proxy.js.map +1 -1
- package/dist/cloud/settings.d.ts +8 -3
- package/dist/cloud/settings.js +14 -3
- package/dist/cloud/settings.js.map +1 -1
- package/dist/cloud/target.d.ts +24 -0
- package/dist/cloud/target.js +33 -0
- package/dist/cloud/target.js.map +1 -0
- package/dist/config/user-config.d.ts +17 -0
- package/dist/config/user-config.js +65 -0
- package/dist/config/user-config.js.map +1 -0
- package/dist/db/connection.js +17 -3
- package/dist/db/connection.js.map +1 -1
- package/dist/db/index.d.ts +8 -4
- package/dist/db/index.js +16 -12
- package/dist/db/index.js.map +1 -1
- package/dist/db/project-scope-migration.d.ts +14 -0
- package/dist/db/project-scope-migration.js +168 -0
- package/dist/db/project-scope-migration.js.map +1 -0
- package/dist/db/repositories/agent-messages.d.ts +4 -1
- package/dist/db/repositories/agent-messages.js +9 -5
- package/dist/db/repositories/agent-messages.js.map +1 -1
- package/dist/db/repositories/events.d.ts +1 -1
- package/dist/db/repositories/events.js +9 -7
- package/dist/db/repositories/events.js.map +1 -1
- package/dist/db/repositories/handoffs.d.ts +1 -1
- package/dist/db/repositories/handoffs.js +17 -13
- package/dist/db/repositories/handoffs.js.map +1 -1
- package/dist/db/repositories/ownership-events.d.ts +1 -1
- package/dist/db/repositories/ownership-events.js +7 -5
- package/dist/db/repositories/ownership-events.js.map +1 -1
- package/dist/db/repositories/reviews.d.ts +1 -1
- package/dist/db/repositories/reviews.js +12 -9
- package/dist/db/repositories/reviews.js.map +1 -1
- package/dist/db/repositories/task-updates.d.ts +1 -1
- package/dist/db/repositories/task-updates.js +7 -5
- package/dist/db/repositories/task-updates.js.map +1 -1
- package/dist/db/repositories/tasks.d.ts +2 -1
- package/dist/db/repositories/tasks.js +26 -15
- package/dist/db/repositories/tasks.js.map +1 -1
- package/dist/db/rows.d.ts +2 -0
- package/dist/db/rows.js +2 -0
- package/dist/db/rows.js.map +1 -1
- package/dist/db/schema.js +3 -0
- package/dist/db/schema.js.map +1 -1
- package/dist/domain/overlap.d.ts +8 -1
- package/dist/domain/overlap.js +12 -0
- package/dist/domain/overlap.js.map +1 -1
- package/dist/index.js +20 -1
- package/dist/index.js.map +1 -1
- package/dist/install/adapters/index.d.ts +12 -2
- package/dist/install/adapters/index.js +92 -94
- package/dist/install/adapters/index.js.map +1 -1
- package/dist/install/adapters/links.d.ts +55 -0
- package/dist/install/adapters/links.js +152 -0
- package/dist/install/adapters/links.js.map +1 -0
- package/dist/install/block.d.ts +6 -0
- package/dist/install/block.js +15 -0
- package/dist/install/block.js.map +1 -1
- package/dist/install/claude-plugin.d.ts +2 -22
- package/dist/install/claude-plugin.js +6 -68
- package/dist/install/claude-plugin.js.map +1 -1
- package/dist/install/codex-config.d.ts +2 -0
- package/dist/install/codex-config.js +5 -2
- package/dist/install/codex-config.js.map +1 -1
- package/dist/install/global-mode.d.ts +15 -0
- package/dist/install/global-mode.js +142 -0
- package/dist/install/global-mode.js.map +1 -0
- package/dist/install/instructions.d.ts +4 -0
- package/dist/install/instructions.js +21 -0
- package/dist/install/instructions.js.map +1 -1
- package/dist/install/mcp-config.d.ts +18 -7
- package/dist/install/mcp-config.js +110 -27
- package/dist/install/mcp-config.js.map +1 -1
- package/dist/install/toml-lines.d.ts +18 -0
- package/dist/install/toml-lines.js +135 -0
- package/dist/install/toml-lines.js.map +1 -0
- package/dist/server.d.ts +1 -1
- package/dist/server.js +2 -2
- package/dist/server.js.map +1 -1
- package/dist/tools/agent-messages.d.ts +1 -1
- package/dist/tools/agent-messages.js +8 -3
- package/dist/tools/agent-messages.js.map +1 -1
- package/dist/tools/claim-work.js +2 -2
- package/dist/tools/claim-work.js.map +1 -1
- package/dist/tools/workflow.d.ts +4 -1
- package/dist/tools/workflow.js +17 -11
- package/dist/tools/workflow.js.map +1 -1
- package/dist/tools/workspace-routing.d.ts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/workspaces/client-roots.d.ts +32 -0
- package/dist/workspaces/client-roots.js +39 -0
- package/dist/workspaces/client-roots.js.map +1 -0
- package/dist/workspaces/manager.d.ts +13 -1
- package/dist/workspaces/manager.js +35 -4
- package/dist/workspaces/manager.js.map +1 -1
- package/dist/workspaces/store.d.ts +44 -0
- package/dist/workspaces/store.js +84 -0
- package/dist/workspaces/store.js.map +1 -0
- package/package.json +3 -3
- package/plugin/cursor/concord-relay/cursor-hook.mjs +30 -6
package/dist/cloud/settings.d.ts
CHANGED
|
@@ -5,9 +5,10 @@ import { z } from 'zod';
|
|
|
5
5
|
* - **Credentials** (`~/.concord/credentials.json`, mode 0600) — the API URL and
|
|
6
6
|
* key. Per user, never in a repository: `.mcp.json` and friends are usually
|
|
7
7
|
* committed, and a key must not ride along.
|
|
8
|
-
* - **Link** (`<repo>/.concord/cloud.json`) —
|
|
9
|
-
* the cloud
|
|
10
|
-
*
|
|
8
|
+
* - **Link** (`<repo>/.concord/cloud.json`) — this repository's own choice: to
|
|
9
|
+
* work through the cloud as a named project, or (`{ "local": true }`) to stay
|
|
10
|
+
* local. Without one, a signed-in machine works through the cloud by default;
|
|
11
|
+
* see `cloud/target.ts`.
|
|
11
12
|
*/
|
|
12
13
|
declare const oauthTokensSchema: z.ZodObject<{
|
|
13
14
|
accessToken: z.ZodString;
|
|
@@ -55,6 +56,10 @@ export declare function readCredentials(env: NodeJS.ProcessEnv): CloudCredential
|
|
|
55
56
|
export declare function writeCredentials(env: NodeJS.ProcessEnv, credentials: CloudCredentials): void;
|
|
56
57
|
export declare function readLink(repoRoot: string): CloudLink | undefined;
|
|
57
58
|
export declare function writeLink(repoRoot: string, link: CloudLink): void;
|
|
59
|
+
/** Whether this repository chose to stay local (`concord cloud unlink`). */
|
|
60
|
+
export declare function readLocalChoice(repoRoot: string): boolean;
|
|
61
|
+
/** Keep this repository local while the machine is signed in, replacing any link. */
|
|
62
|
+
export declare function writeLocalChoice(repoRoot: string): void;
|
|
58
63
|
/** Returns whether a link was there to remove. */
|
|
59
64
|
export declare function removeLink(repoRoot: string): boolean;
|
|
60
65
|
/** Returns whether there were credentials to remove. */
|
package/dist/cloud/settings.js
CHANGED
|
@@ -8,9 +8,10 @@ import { concordDir, userHome } from '../config/paths.js';
|
|
|
8
8
|
* - **Credentials** (`~/.concord/credentials.json`, mode 0600) — the API URL and
|
|
9
9
|
* key. Per user, never in a repository: `.mcp.json` and friends are usually
|
|
10
10
|
* committed, and a key must not ride along.
|
|
11
|
-
* - **Link** (`<repo>/.concord/cloud.json`) —
|
|
12
|
-
* the cloud
|
|
13
|
-
*
|
|
11
|
+
* - **Link** (`<repo>/.concord/cloud.json`) — this repository's own choice: to
|
|
12
|
+
* work through the cloud as a named project, or (`{ "local": true }`) to stay
|
|
13
|
+
* local. Without one, a signed-in machine works through the cloud by default;
|
|
14
|
+
* see `cloud/target.ts`.
|
|
14
15
|
*/
|
|
15
16
|
const oauthTokensSchema = z.object({
|
|
16
17
|
accessToken: z.string().min(1),
|
|
@@ -34,6 +35,8 @@ const linkSchema = z.object({
|
|
|
34
35
|
/** The repository's normalised git remote; see `normalizeProjectKey`. */
|
|
35
36
|
projectKey: z.string().min(1),
|
|
36
37
|
});
|
|
38
|
+
/** A repository's choice to stay local while this machine is signed in. */
|
|
39
|
+
const localChoiceSchema = z.object({ local: z.literal(true) });
|
|
37
40
|
export function credentialsPath(env) {
|
|
38
41
|
return join(userHome(env), '.concord', 'credentials.json');
|
|
39
42
|
}
|
|
@@ -143,6 +146,14 @@ export function readLink(repoRoot) {
|
|
|
143
146
|
export function writeLink(repoRoot, link) {
|
|
144
147
|
writeJson(linkPath(repoRoot), linkSchema.parse(link));
|
|
145
148
|
}
|
|
149
|
+
/** Whether this repository chose to stay local (`concord cloud unlink`). */
|
|
150
|
+
export function readLocalChoice(repoRoot) {
|
|
151
|
+
return readJson(linkPath(repoRoot), localChoiceSchema) !== undefined;
|
|
152
|
+
}
|
|
153
|
+
/** Keep this repository local while the machine is signed in, replacing any link. */
|
|
154
|
+
export function writeLocalChoice(repoRoot) {
|
|
155
|
+
writeJson(linkPath(repoRoot), { local: true });
|
|
156
|
+
}
|
|
146
157
|
/** Returns whether a link was there to remove. */
|
|
147
158
|
export function removeLink(repoRoot) {
|
|
148
159
|
const path = linkPath(repoRoot);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/cloud/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,UAAU,EACV,MAAM,EACN,aAAa,GACd,MAAM,SAAS,CAAC;A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,QAAQ,CAAC,CAAC;IAChC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IACpC,MAAM,CAAC,IAAI,CAAC,CAAC;IACb,OAAO,IAAI,CAAC;AACd,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,iBAAiB,CAAC,GAAsB;IACtD,MAAM,IAAI,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IACpC,MAAM,CAAC,IAAI,CAAC,CAAC;IACb,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type OriginRemote } from '../workspaces/store.js';
|
|
2
|
+
/**
|
|
3
|
+
* Whether a workspace works through Concord Cloud, and as which project.
|
|
4
|
+
*
|
|
5
|
+
* Signed in, the cloud is the default: a repository is its git remote's
|
|
6
|
+
* project, as every clone of it names it, and anywhere outside a repository is
|
|
7
|
+
* `general`, where agents that belong to no repository meet — when the client
|
|
8
|
+
* names that folder (Claude Code's `CLAUDE_PROJECT_DIR`, or `CONCORD_REPO_ROOT`).
|
|
9
|
+
* A server started elsewhere without one may yet learn its repository from MCP
|
|
10
|
+
* roots, so it is not presumed to be outside one.
|
|
11
|
+
*
|
|
12
|
+
* A repository can still choose for itself — `concord cloud link` names its
|
|
13
|
+
* project, `concord cloud unlink` keeps it local — and these stay local too:
|
|
14
|
+
* one already holding local Concord state (its open work must not vanish from
|
|
15
|
+
* view; linking moves it on purpose), and one with no remote, which the cloud
|
|
16
|
+
* has no shared name for.
|
|
17
|
+
*/
|
|
18
|
+
export interface CloudTarget {
|
|
19
|
+
readonly apiUrl: string;
|
|
20
|
+
readonly projectKey: string;
|
|
21
|
+
/** `link`: the repository's own link; `default`: the signed-in machine's default. */
|
|
22
|
+
readonly source: 'link' | 'default';
|
|
23
|
+
}
|
|
24
|
+
export declare function cloudTargetFor(repoRoot: string, env: NodeJS.ProcessEnv, originRemote?: OriginRemote): CloudTarget | undefined;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { databasePath } from '../config/paths.js';
|
|
3
|
+
import { hasExplicitRepoRoot } from '../workspaces/client-roots.js';
|
|
4
|
+
import { GENERAL_PROJECT, gitOriginRemote, isRepository, repositoryProjectKey, } from '../workspaces/store.js';
|
|
5
|
+
import { readCredentials, readLink, readLocalChoice, readMachineKey } from './settings.js';
|
|
6
|
+
/** Each repository's remote, asked of git once per process: hooks resolve this on every edit. */
|
|
7
|
+
const remotes = new Map();
|
|
8
|
+
function cachedOriginRemote(repoRoot) {
|
|
9
|
+
if (!remotes.has(repoRoot))
|
|
10
|
+
remotes.set(repoRoot, gitOriginRemote(repoRoot));
|
|
11
|
+
return remotes.get(repoRoot);
|
|
12
|
+
}
|
|
13
|
+
export function cloudTargetFor(repoRoot, env, originRemote = cachedOriginRemote) {
|
|
14
|
+
const link = readLink(repoRoot);
|
|
15
|
+
if (link !== undefined)
|
|
16
|
+
return { ...link, source: 'link' };
|
|
17
|
+
if (readLocalChoice(repoRoot) || existsSync(databasePath(repoRoot)))
|
|
18
|
+
return undefined;
|
|
19
|
+
// A default needs this machine's identity to act on; without one it stays
|
|
20
|
+
// local, for every caller alike, rather than failing to start.
|
|
21
|
+
const credentials = readCredentials(env);
|
|
22
|
+
if (credentials === undefined || readMachineKey(env) === undefined)
|
|
23
|
+
return undefined;
|
|
24
|
+
const projectKey = isRepository(repoRoot)
|
|
25
|
+
? repositoryProjectKey(repoRoot, originRemote)
|
|
26
|
+
: hasExplicitRepoRoot(env)
|
|
27
|
+
? GENERAL_PROJECT
|
|
28
|
+
: undefined;
|
|
29
|
+
return projectKey === undefined
|
|
30
|
+
? undefined
|
|
31
|
+
: { apiUrl: credentials.apiUrl, projectKey, source: 'default' };
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=target.js.map
|
|
@@ -0,0 +1 @@
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,MAAM,UAAU,GAAG,YAAY,CAAC,QAAQ,CAAC;QACvC,CAAC,CAAC,oBAAoB,CAAC,QAAQ,EAAE,YAAY,CAAC;QAC9C,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC;YACxB,CAAC,CAAC,eAAe;YACjB,CAAC,CAAC,SAAS,CAAC;IAChB,OAAO,UAAU,KAAK,SAAS;QAC7B,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** The user's choices, from `~/.concord/config.json`. */
|
|
2
|
+
export interface UserConfig {
|
|
3
|
+
/** Use the machine-wide store outside set-up repositories; undefined until asked. */
|
|
4
|
+
readonly globalMode?: boolean;
|
|
5
|
+
/** The user-level MCP registrations global mode added: the only ones it removes. */
|
|
6
|
+
readonly globalRegistrations?: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
/** `~/.concord/`, home to the machine-wide store and the user's settings. */
|
|
9
|
+
export declare function userConcordDir(env: NodeJS.ProcessEnv): string;
|
|
10
|
+
export declare function globalDatabasePath(env: NodeJS.ProcessEnv): string;
|
|
11
|
+
/**
|
|
12
|
+
* Read the user's settings. A missing or unreadable file reads as no choice
|
|
13
|
+
* made: hooks run on every tool call and must not fail on a hand-edited file.
|
|
14
|
+
*/
|
|
15
|
+
export declare function readUserConfig(env: NodeJS.ProcessEnv): UserConfig;
|
|
16
|
+
/** Merge `update` into the user's settings, keeping any keys this version does not know. */
|
|
17
|
+
export declare function writeUserConfig(env: NodeJS.ProcessEnv, update: UserConfig): string;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { chmodSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { CONCORD_DIR, userHome } from './paths.js';
|
|
5
|
+
/**
|
|
6
|
+
* The machine-wide store: every repository that was never set up, plus
|
|
7
|
+
* `general` for sessions outside any repository. Not `concord.db`, which is
|
|
8
|
+
* what a session started in the home directory itself has always created.
|
|
9
|
+
*/
|
|
10
|
+
const GLOBAL_DB_FILENAME = 'global.db';
|
|
11
|
+
const USER_CONFIG_FILENAME = 'config.json';
|
|
12
|
+
const userConfigSchema = z
|
|
13
|
+
.object({
|
|
14
|
+
globalMode: z.boolean().optional(),
|
|
15
|
+
globalRegistrations: z.array(z.string()).optional(),
|
|
16
|
+
})
|
|
17
|
+
.loose();
|
|
18
|
+
/** The whole file as JSON, so settings this version does not know survive a write. */
|
|
19
|
+
const storedConfigSchema = z.record(z.string(), z.json());
|
|
20
|
+
/** `~/.concord/`, home to the machine-wide store and the user's settings. */
|
|
21
|
+
export function userConcordDir(env) {
|
|
22
|
+
return join(userHome(env), CONCORD_DIR);
|
|
23
|
+
}
|
|
24
|
+
export function globalDatabasePath(env) {
|
|
25
|
+
return join(userConcordDir(env), GLOBAL_DB_FILENAME);
|
|
26
|
+
}
|
|
27
|
+
function userConfigPath(env) {
|
|
28
|
+
return join(userConcordDir(env), USER_CONFIG_FILENAME);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Read the user's settings. A missing or unreadable file reads as no choice
|
|
32
|
+
* made: hooks run on every tool call and must not fail on a hand-edited file.
|
|
33
|
+
*/
|
|
34
|
+
export function readUserConfig(env) {
|
|
35
|
+
try {
|
|
36
|
+
const raw = JSON.parse(readFileSync(userConfigPath(env), 'utf8'));
|
|
37
|
+
const parsed = userConfigSchema.parse(raw);
|
|
38
|
+
return {
|
|
39
|
+
...(parsed.globalMode === undefined ? {} : { globalMode: parsed.globalMode }),
|
|
40
|
+
...(parsed.globalRegistrations === undefined
|
|
41
|
+
? {}
|
|
42
|
+
: { globalRegistrations: parsed.globalRegistrations }),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** Merge `update` into the user's settings, keeping any keys this version does not know. */
|
|
50
|
+
export function writeUserConfig(env, update) {
|
|
51
|
+
const path = userConfigPath(env);
|
|
52
|
+
let current = {};
|
|
53
|
+
try {
|
|
54
|
+
current = storedConfigSchema.parse(JSON.parse(readFileSync(path, 'utf8')));
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// Missing or unreadable: start from the update alone.
|
|
58
|
+
}
|
|
59
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
60
|
+
writeFileSync(path, `${JSON.stringify({ ...current, ...update }, null, 2)}\n`, { mode: 0o600 });
|
|
61
|
+
if (process.platform !== 'win32')
|
|
62
|
+
chmodSync(path, 0o600);
|
|
63
|
+
return path;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=user-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-config.js","sourceRoot":"","sources":["../../src/config/user-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEnD;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,WAAW,CAAC;AACvC,MAAM,oBAAoB,GAAG,aAAa,CAAC;AAE3C,MAAM,gBAAgB,GAAG,CAAC;KACvB,MAAM,CAAC;IACN,UAAU,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAClC,mBAAmB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CACpD,CAAC;KACD,KAAK,EAAE,CAAC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AAI,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,OAAO,GAAuC,EAAE,CAAC;IACrD,IAAI,CAAC;QACH,OAAO,GAAG,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAC7E,CAAC;IAAC,MAAM,CAAC;QACP,sDAAsD;IACxD,CAAC;IACD,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,aAAa,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAChG,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO;QAAE,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACzD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/db/connection.js
CHANGED
|
@@ -19,10 +19,18 @@ export function openDatabase(filename) {
|
|
|
19
19
|
// sharing one workspace database. Wait for brief writers instead of making
|
|
20
20
|
// a live inbox watcher exit on the first SQLITE_BUSY response.
|
|
21
21
|
db.pragma('busy_timeout = 5000');
|
|
22
|
-
|
|
22
|
+
// Enforcement stays off while migrating: rebuilding a referenced table is
|
|
23
|
+
// only possible without it, and SQLite ignores the pragma inside a transaction.
|
|
24
|
+
db.pragma('foreign_keys = OFF');
|
|
23
25
|
runMigrations(db);
|
|
26
|
+
db.pragma('foreign_keys = ON');
|
|
24
27
|
return db;
|
|
25
28
|
}
|
|
29
|
+
const foreignKeyViolationsSchema = z.array(z.unknown());
|
|
30
|
+
/**
|
|
31
|
+
* Apply each outstanding migration atomically with its version bump, so an
|
|
32
|
+
* interrupted upgrade leaves the previous schema rather than half of the next.
|
|
33
|
+
*/
|
|
26
34
|
function runMigrations(db) {
|
|
27
35
|
const applied = readUserVersion(db);
|
|
28
36
|
for (let index = applied; index < migrations.length; index += 1) {
|
|
@@ -30,8 +38,14 @@ function runMigrations(db) {
|
|
|
30
38
|
if (migration === undefined) {
|
|
31
39
|
continue;
|
|
32
40
|
}
|
|
33
|
-
db.
|
|
34
|
-
|
|
41
|
+
db.transaction(() => {
|
|
42
|
+
db.exec(migration);
|
|
43
|
+
const violations = foreignKeyViolationsSchema.parse(db.pragma('foreign_key_check'));
|
|
44
|
+
if (violations.length > 0) {
|
|
45
|
+
throw new Error(`Migration ${String(index + 1)} left foreign-key violations.`);
|
|
46
|
+
}
|
|
47
|
+
db.pragma(`user_version = ${String(index + 1)}`);
|
|
48
|
+
})();
|
|
35
49
|
}
|
|
36
50
|
}
|
|
37
51
|
function readUserVersion(db) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/db/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAKzC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC;AAEzD;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC3C,IAAI,QAAQ,KAAK,UAAU,EAAE,CAAC;QAC5B,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,CAAC;IACD,MAAM,EAAE,GAAG,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAClC,EAAE,C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AAC,CAAC,OAAO,EAAE,CAAC,CAAC;AAExD;;;GAGG;AACH,SAAS,aAAa,CAAC,EAAmB;IACxC,MAAM,OAAO,GAAG,eAAe,CAAC,EAAE,CAAC,CAAC;IACpC,KAAK,IAAI,KAAK,GAAG,OAAO,EAAE,KAAK,GAAG,UAAU,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAChE,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;QACpC,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,SAAS;QACX,CAAC;QACD,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE;YAClB,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACnB,MAAM,UAAU,GAAG,0BAA0B,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC;YACpF,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC1B,MAAM,IAAI,KAAK,CAAC,aAAa,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,+BAA+B,CAAC,CAAC;YACjF,CAAC;YACD,EAAE,CAAC,MAAM,CAAC,kBAAkB,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;QACnD,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,EAAmB;IAC1C,MAAM,GAAG,GAAY,EAAE,CAAC,MAAM,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IACjE,OAAO,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACtC,CAAC"}
|
package/dist/db/index.d.ts
CHANGED
|
@@ -10,7 +10,9 @@ import { type TaskUpdateRepository } from './repositories/task-updates.js';
|
|
|
10
10
|
import { type TaskRepository } from './repositories/tasks.js';
|
|
11
11
|
export type { ConcordDatabase } from './connection.js';
|
|
12
12
|
export { openDatabase } from './connection.js';
|
|
13
|
+
export { LOCAL_PROJECT } from './project-scope-migration.js';
|
|
13
14
|
export type { NewTask, TaskRepository } from './repositories/tasks.js';
|
|
15
|
+
export { createTaskRepository } from './repositories/tasks.js';
|
|
14
16
|
export type { NewHandoff, HandoffRepository } from './repositories/handoffs.js';
|
|
15
17
|
export type { NewReview, ReviewRepository } from './repositories/reviews.js';
|
|
16
18
|
export type { NewTaskUpdate, TaskUpdateRepository } from './repositories/task-updates.js';
|
|
@@ -23,6 +25,8 @@ export type { TaskRecord, TaskStatus, HandoffRecord, ReviewRecord, ProvenanceEnt
|
|
|
23
25
|
/** The full set of Concord repositories bound to one database. */
|
|
24
26
|
export interface Repositories {
|
|
25
27
|
db: ConcordDatabase;
|
|
28
|
+
/** The project task-scoped repositories see. */
|
|
29
|
+
project: string;
|
|
26
30
|
tasks: TaskRepository;
|
|
27
31
|
handoffs: HandoffRepository;
|
|
28
32
|
reviews: ReviewRepository;
|
|
@@ -33,7 +37,7 @@ export interface Repositories {
|
|
|
33
37
|
agentMessages: AgentMessageRepository;
|
|
34
38
|
ownershipEvents: OwnershipEventRepository;
|
|
35
39
|
}
|
|
36
|
-
/** Bind all repositories to an
|
|
37
|
-
export declare function createRepositories(db: ConcordDatabase): Repositories;
|
|
38
|
-
/** Open the database at `filename` and bind all repositories
|
|
39
|
-
export declare function openRepositories(filename: string): Repositories;
|
|
40
|
+
/** Bind all repositories to an open database; task-scoped ones see only `project`. */
|
|
41
|
+
export declare function createRepositories(db: ConcordDatabase, project?: string): Repositories;
|
|
42
|
+
/** Open the database at `filename` and bind all repositories to `project`. */
|
|
43
|
+
export declare function openRepositories(filename: string, project?: string): Repositories;
|
package/dist/db/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { openDatabase } from './connection.js';
|
|
2
|
+
import { LOCAL_PROJECT } from './project-scope-migration.js';
|
|
2
3
|
import { createAgentEndpointRepository, } from './repositories/agent-endpoints.js';
|
|
3
4
|
import { createAgentMessageRepository, } from './repositories/agent-messages.js';
|
|
4
5
|
import { createAgentRepository } from './repositories/agents.js';
|
|
@@ -9,23 +10,26 @@ import { createReviewRepository } from './repositories/reviews.js';
|
|
|
9
10
|
import { createTaskUpdateRepository, } from './repositories/task-updates.js';
|
|
10
11
|
import { createTaskRepository } from './repositories/tasks.js';
|
|
11
12
|
export { openDatabase } from './connection.js';
|
|
12
|
-
|
|
13
|
-
export
|
|
13
|
+
export { LOCAL_PROJECT } from './project-scope-migration.js';
|
|
14
|
+
export { createTaskRepository } from './repositories/tasks.js';
|
|
15
|
+
/** Bind all repositories to an open database; task-scoped ones see only `project`. */
|
|
16
|
+
export function createRepositories(db, project = LOCAL_PROJECT) {
|
|
14
17
|
return {
|
|
15
18
|
db,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
project,
|
|
20
|
+
tasks: createTaskRepository(db, project),
|
|
21
|
+
handoffs: createHandoffRepository(db, project),
|
|
22
|
+
reviews: createReviewRepository(db, project),
|
|
23
|
+
taskUpdates: createTaskUpdateRepository(db, project),
|
|
24
|
+
events: createEventRepository(db, project),
|
|
21
25
|
agents: createAgentRepository(db),
|
|
22
26
|
agentEndpoints: createAgentEndpointRepository(db),
|
|
23
|
-
agentMessages: createAgentMessageRepository(db),
|
|
24
|
-
ownershipEvents: createOwnershipEventRepository(db),
|
|
27
|
+
agentMessages: createAgentMessageRepository(db, project),
|
|
28
|
+
ownershipEvents: createOwnershipEventRepository(db, project),
|
|
25
29
|
};
|
|
26
30
|
}
|
|
27
|
-
/** Open the database at `filename` and bind all repositories
|
|
28
|
-
export function openRepositories(filename) {
|
|
29
|
-
return createRepositories(openDatabase(filename));
|
|
31
|
+
/** Open the database at `filename` and bind all repositories to `project`. */
|
|
32
|
+
export function openRepositories(filename, project = LOCAL_PROJECT) {
|
|
33
|
+
return createRepositories(openDatabase(filename), project);
|
|
30
34
|
}
|
|
31
35
|
//# sourceMappingURL=index.js.map
|
package/dist/db/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/db/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwB,MAAM,iBAAiB,CAAC;AACrE,OAAO,EACL,6BAA6B,GAE9B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,4BAA4B,GAE7B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAwB,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,qBAAqB,EAAwB,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAA0B,MAAM,4BAA4B,CAAC;AAC7F,OAAO,EACL,8BAA8B,GAE/B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAyB,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EACL,0BAA0B,GAE3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAuB,MAAM,yBAAyB,CAAC;AAGpF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/db/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAwB,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EACL,6BAA6B,GAE9B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,4BAA4B,GAE7B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAwB,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,qBAAqB,EAAwB,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAA0B,MAAM,4BAA4B,CAAC;AAC7F,OAAO,EACL,8BAA8B,GAE/B,MAAM,oCAAoC,CAAC;AAC5C,OAAO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* Migration 012 — a task is unique per `(project, task_id)`, as Concord Cloud
|
|
5
|
+
* keys it, so one store can hold several repositories whose agents chose the
|
|
6
|
+
* same task id. Existing rows land in `LOCAL_PROJECT`, unchanged in behaviour.
|
|
7
|
+
*
|
|
8
|
+
* SQLite cannot change a key in place, so `tasks` and every table referencing
|
|
9
|
+
* it are rebuilt. Each copy is `SELECT *, ''`: the new table repeats the
|
|
10
|
+
* version-11 columns in order with `project` appended, and this only ever runs
|
|
11
|
+
* on version 11. The runner disables foreign keys around it, as SQLite's
|
|
12
|
+
* rebuild procedure requires, and checks them before committing.
|
|
13
|
+
*/
|
|
14
|
+
export declare const PROJECT_SCOPE_MIGRATION = "\n CREATE TABLE tasks_012 (\n task_id TEXT NOT NULL,\n title TEXT NOT NULL,\n owner TEXT,\n agent TEXT,\n branch TEXT,\n worktree TEXT,\n expected_files TEXT NOT NULL DEFAULT '[]',\n modules TEXT NOT NULL DEFAULT '[]',\n domains TEXT NOT NULL DEFAULT '[]',\n risk_tags TEXT NOT NULL DEFAULT '[]',\n notes TEXT,\n status TEXT NOT NULL DEFAULT 'active',\n created_at TEXT NOT NULL,\n updated_at TEXT NOT NULL,\n parent_task_id TEXT,\n agent_id TEXT,\n version INTEGER NOT NULL DEFAULT 1,\n assigned_agent_id TEXT,\n lease_expires_at TEXT,\n project TEXT NOT NULL DEFAULT '',\n PRIMARY KEY (project, task_id)\n );\n INSERT INTO tasks_012 SELECT *, '' FROM tasks;\n DROP TABLE tasks;\n ALTER TABLE tasks_012 RENAME TO tasks;\n\n CREATE TABLE handoffs_012 (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n task_id TEXT NOT NULL,\n status TEXT NOT NULL,\n changed_files TEXT NOT NULL DEFAULT '[]',\n what_changed TEXT NOT NULL,\n tests_run TEXT NOT NULL DEFAULT '[]',\n known_risks TEXT NOT NULL DEFAULT '[]',\n assumptions TEXT NOT NULL DEFAULT '[]',\n decisions TEXT NOT NULL DEFAULT '[]',\n guardrails_checked TEXT NOT NULL DEFAULT '[]',\n needs_review_from TEXT NOT NULL DEFAULT '[]',\n next_steps TEXT NOT NULL DEFAULT '[]',\n created_at TEXT NOT NULL,\n from_agent_id TEXT,\n to_agent_id TEXT,\n delivery_status TEXT NOT NULL DEFAULT 'recorded',\n expires_at TEXT,\n resolved_at TEXT,\n task_version INTEGER,\n resolution_reason TEXT,\n reported_outcome TEXT,\n project TEXT NOT NULL DEFAULT '',\n FOREIGN KEY (project, task_id) REFERENCES tasks(project, task_id)\n );\n INSERT INTO handoffs_012 SELECT *, '' FROM handoffs;\n DROP TABLE handoffs;\n ALTER TABLE handoffs_012 RENAME TO handoffs;\n CREATE INDEX idx_handoffs_task_id ON handoffs(project, task_id);\n CREATE INDEX idx_handoffs_pending_recipient ON handoffs(to_agent_id, delivery_status);\n\n CREATE TABLE reviews_012 (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n task_id TEXT NOT NULL,\n plan_summary TEXT NOT NULL,\n tests_run TEXT NOT NULL DEFAULT '[]',\n diff_size TEXT,\n guardrails_checked TEXT NOT NULL DEFAULT '[]',\n assumptions TEXT NOT NULL DEFAULT '[]',\n open_questions TEXT NOT NULL DEFAULT '[]',\n provenance TEXT NOT NULL DEFAULT '[]',\n created_at TEXT NOT NULL,\n project TEXT NOT NULL DEFAULT '',\n FOREIGN KEY (project, task_id) REFERENCES tasks(project, task_id)\n );\n INSERT INTO reviews_012 SELECT *, '' FROM reviews;\n DROP TABLE reviews;\n ALTER TABLE reviews_012 RENAME TO reviews;\n CREATE INDEX idx_reviews_task_id ON reviews(project, task_id);\n\n CREATE TABLE task_updates_012 (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n task_id TEXT NOT NULL,\n kind TEXT NOT NULL,\n content TEXT NOT NULL,\n agent TEXT,\n created_at TEXT NOT NULL,\n project TEXT NOT NULL DEFAULT '',\n FOREIGN KEY (project, task_id) REFERENCES tasks(project, task_id)\n );\n INSERT INTO task_updates_012 SELECT *, '' FROM task_updates;\n DROP TABLE task_updates;\n ALTER TABLE task_updates_012 RENAME TO task_updates;\n CREATE INDEX idx_task_updates_task_id ON task_updates(project, task_id);\n\n CREATE TABLE task_ownership_events_012 (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n task_id TEXT NOT NULL,\n transition TEXT NOT NULL,\n actor_agent_id TEXT NOT NULL,\n from_agent_id TEXT,\n to_agent_id TEXT,\n from_status TEXT NOT NULL,\n to_status TEXT NOT NULL,\n from_version INTEGER NOT NULL,\n to_version INTEGER NOT NULL,\n reason TEXT,\n created_at TEXT NOT NULL,\n project TEXT NOT NULL DEFAULT '',\n FOREIGN KEY (project, task_id) REFERENCES tasks(project, task_id)\n );\n INSERT INTO task_ownership_events_012 SELECT *, '' FROM task_ownership_events;\n DROP TABLE task_ownership_events;\n ALTER TABLE task_ownership_events_012 RENAME TO task_ownership_events;\n CREATE INDEX idx_ownership_events_task_id ON task_ownership_events(project, task_id, id);\n\n CREATE TABLE agent_messages_012 (\n message_id TEXT PRIMARY KEY,\n task_id TEXT,\n sender_agent_id TEXT NOT NULL REFERENCES agents(agent_id),\n recipient_agent_id TEXT NOT NULL REFERENCES agents(agent_id),\n reply_to_message_id TEXT REFERENCES agent_messages(message_id),\n content TEXT NOT NULL,\n delivery_mode TEXT NOT NULL DEFAULT 'steer',\n status TEXT NOT NULL DEFAULT 'pending',\n provider TEXT,\n provider_receipt TEXT,\n error_code TEXT,\n error_detail TEXT,\n idempotency_key TEXT NOT NULL,\n created_at TEXT NOT NULL,\n delivered_at TEXT,\n replied_at TEXT,\n failed_at TEXT,\n project TEXT NOT NULL DEFAULT '',\n CHECK (delivery_mode = 'steer'),\n CHECK (status IN ('pending', 'delivered', 'replied', 'failed')),\n UNIQUE (sender_agent_id, idempotency_key),\n FOREIGN KEY (project, task_id) REFERENCES tasks(project, task_id)\n );\n INSERT INTO agent_messages_012 SELECT *, '' FROM agent_messages;\n DROP TABLE agent_messages;\n ALTER TABLE agent_messages_012 RENAME TO agent_messages;\n CREATE INDEX idx_agent_messages_recipient\n ON agent_messages(recipient_agent_id, created_at, message_id);\n CREATE INDEX idx_agent_messages_sender\n ON agent_messages(sender_agent_id, created_at, message_id);\n CREATE INDEX idx_agent_messages_task\n ON agent_messages(project, task_id, created_at, message_id);\n CREATE INDEX idx_agent_messages_pending_recipient\n ON agent_messages(recipient_agent_id, status, created_at, message_id);\n\n ALTER TABLE events ADD COLUMN project TEXT NOT NULL DEFAULT '';\n DROP INDEX idx_events_task_id;\n CREATE INDEX idx_events_project_task ON events(project, task_id);\n";
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/** The project of a repository's own `.concord/` store: it holds only itself. */
|
|
2
|
+
export const LOCAL_PROJECT = '';
|
|
3
|
+
/**
|
|
4
|
+
* Migration 012 — a task is unique per `(project, task_id)`, as Concord Cloud
|
|
5
|
+
* keys it, so one store can hold several repositories whose agents chose the
|
|
6
|
+
* same task id. Existing rows land in `LOCAL_PROJECT`, unchanged in behaviour.
|
|
7
|
+
*
|
|
8
|
+
* SQLite cannot change a key in place, so `tasks` and every table referencing
|
|
9
|
+
* it are rebuilt. Each copy is `SELECT *, ''`: the new table repeats the
|
|
10
|
+
* version-11 columns in order with `project` appended, and this only ever runs
|
|
11
|
+
* on version 11. The runner disables foreign keys around it, as SQLite's
|
|
12
|
+
* rebuild procedure requires, and checks them before committing.
|
|
13
|
+
*/
|
|
14
|
+
export const PROJECT_SCOPE_MIGRATION = `
|
|
15
|
+
CREATE TABLE tasks_012 (
|
|
16
|
+
task_id TEXT NOT NULL,
|
|
17
|
+
title TEXT NOT NULL,
|
|
18
|
+
owner TEXT,
|
|
19
|
+
agent TEXT,
|
|
20
|
+
branch TEXT,
|
|
21
|
+
worktree TEXT,
|
|
22
|
+
expected_files TEXT NOT NULL DEFAULT '[]',
|
|
23
|
+
modules TEXT NOT NULL DEFAULT '[]',
|
|
24
|
+
domains TEXT NOT NULL DEFAULT '[]',
|
|
25
|
+
risk_tags TEXT NOT NULL DEFAULT '[]',
|
|
26
|
+
notes TEXT,
|
|
27
|
+
status TEXT NOT NULL DEFAULT 'active',
|
|
28
|
+
created_at TEXT NOT NULL,
|
|
29
|
+
updated_at TEXT NOT NULL,
|
|
30
|
+
parent_task_id TEXT,
|
|
31
|
+
agent_id TEXT,
|
|
32
|
+
version INTEGER NOT NULL DEFAULT 1,
|
|
33
|
+
assigned_agent_id TEXT,
|
|
34
|
+
lease_expires_at TEXT,
|
|
35
|
+
project TEXT NOT NULL DEFAULT '',
|
|
36
|
+
PRIMARY KEY (project, task_id)
|
|
37
|
+
);
|
|
38
|
+
INSERT INTO tasks_012 SELECT *, '' FROM tasks;
|
|
39
|
+
DROP TABLE tasks;
|
|
40
|
+
ALTER TABLE tasks_012 RENAME TO tasks;
|
|
41
|
+
|
|
42
|
+
CREATE TABLE handoffs_012 (
|
|
43
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
44
|
+
task_id TEXT NOT NULL,
|
|
45
|
+
status TEXT NOT NULL,
|
|
46
|
+
changed_files TEXT NOT NULL DEFAULT '[]',
|
|
47
|
+
what_changed TEXT NOT NULL,
|
|
48
|
+
tests_run TEXT NOT NULL DEFAULT '[]',
|
|
49
|
+
known_risks TEXT NOT NULL DEFAULT '[]',
|
|
50
|
+
assumptions TEXT NOT NULL DEFAULT '[]',
|
|
51
|
+
decisions TEXT NOT NULL DEFAULT '[]',
|
|
52
|
+
guardrails_checked TEXT NOT NULL DEFAULT '[]',
|
|
53
|
+
needs_review_from TEXT NOT NULL DEFAULT '[]',
|
|
54
|
+
next_steps TEXT NOT NULL DEFAULT '[]',
|
|
55
|
+
created_at TEXT NOT NULL,
|
|
56
|
+
from_agent_id TEXT,
|
|
57
|
+
to_agent_id TEXT,
|
|
58
|
+
delivery_status TEXT NOT NULL DEFAULT 'recorded',
|
|
59
|
+
expires_at TEXT,
|
|
60
|
+
resolved_at TEXT,
|
|
61
|
+
task_version INTEGER,
|
|
62
|
+
resolution_reason TEXT,
|
|
63
|
+
reported_outcome TEXT,
|
|
64
|
+
project TEXT NOT NULL DEFAULT '',
|
|
65
|
+
FOREIGN KEY (project, task_id) REFERENCES tasks(project, task_id)
|
|
66
|
+
);
|
|
67
|
+
INSERT INTO handoffs_012 SELECT *, '' FROM handoffs;
|
|
68
|
+
DROP TABLE handoffs;
|
|
69
|
+
ALTER TABLE handoffs_012 RENAME TO handoffs;
|
|
70
|
+
CREATE INDEX idx_handoffs_task_id ON handoffs(project, task_id);
|
|
71
|
+
CREATE INDEX idx_handoffs_pending_recipient ON handoffs(to_agent_id, delivery_status);
|
|
72
|
+
|
|
73
|
+
CREATE TABLE reviews_012 (
|
|
74
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
75
|
+
task_id TEXT NOT NULL,
|
|
76
|
+
plan_summary TEXT NOT NULL,
|
|
77
|
+
tests_run TEXT NOT NULL DEFAULT '[]',
|
|
78
|
+
diff_size TEXT,
|
|
79
|
+
guardrails_checked TEXT NOT NULL DEFAULT '[]',
|
|
80
|
+
assumptions TEXT NOT NULL DEFAULT '[]',
|
|
81
|
+
open_questions TEXT NOT NULL DEFAULT '[]',
|
|
82
|
+
provenance TEXT NOT NULL DEFAULT '[]',
|
|
83
|
+
created_at TEXT NOT NULL,
|
|
84
|
+
project TEXT NOT NULL DEFAULT '',
|
|
85
|
+
FOREIGN KEY (project, task_id) REFERENCES tasks(project, task_id)
|
|
86
|
+
);
|
|
87
|
+
INSERT INTO reviews_012 SELECT *, '' FROM reviews;
|
|
88
|
+
DROP TABLE reviews;
|
|
89
|
+
ALTER TABLE reviews_012 RENAME TO reviews;
|
|
90
|
+
CREATE INDEX idx_reviews_task_id ON reviews(project, task_id);
|
|
91
|
+
|
|
92
|
+
CREATE TABLE task_updates_012 (
|
|
93
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
94
|
+
task_id TEXT NOT NULL,
|
|
95
|
+
kind TEXT NOT NULL,
|
|
96
|
+
content TEXT NOT NULL,
|
|
97
|
+
agent TEXT,
|
|
98
|
+
created_at TEXT NOT NULL,
|
|
99
|
+
project TEXT NOT NULL DEFAULT '',
|
|
100
|
+
FOREIGN KEY (project, task_id) REFERENCES tasks(project, task_id)
|
|
101
|
+
);
|
|
102
|
+
INSERT INTO task_updates_012 SELECT *, '' FROM task_updates;
|
|
103
|
+
DROP TABLE task_updates;
|
|
104
|
+
ALTER TABLE task_updates_012 RENAME TO task_updates;
|
|
105
|
+
CREATE INDEX idx_task_updates_task_id ON task_updates(project, task_id);
|
|
106
|
+
|
|
107
|
+
CREATE TABLE task_ownership_events_012 (
|
|
108
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
109
|
+
task_id TEXT NOT NULL,
|
|
110
|
+
transition TEXT NOT NULL,
|
|
111
|
+
actor_agent_id TEXT NOT NULL,
|
|
112
|
+
from_agent_id TEXT,
|
|
113
|
+
to_agent_id TEXT,
|
|
114
|
+
from_status TEXT NOT NULL,
|
|
115
|
+
to_status TEXT NOT NULL,
|
|
116
|
+
from_version INTEGER NOT NULL,
|
|
117
|
+
to_version INTEGER NOT NULL,
|
|
118
|
+
reason TEXT,
|
|
119
|
+
created_at TEXT NOT NULL,
|
|
120
|
+
project TEXT NOT NULL DEFAULT '',
|
|
121
|
+
FOREIGN KEY (project, task_id) REFERENCES tasks(project, task_id)
|
|
122
|
+
);
|
|
123
|
+
INSERT INTO task_ownership_events_012 SELECT *, '' FROM task_ownership_events;
|
|
124
|
+
DROP TABLE task_ownership_events;
|
|
125
|
+
ALTER TABLE task_ownership_events_012 RENAME TO task_ownership_events;
|
|
126
|
+
CREATE INDEX idx_ownership_events_task_id ON task_ownership_events(project, task_id, id);
|
|
127
|
+
|
|
128
|
+
CREATE TABLE agent_messages_012 (
|
|
129
|
+
message_id TEXT PRIMARY KEY,
|
|
130
|
+
task_id TEXT,
|
|
131
|
+
sender_agent_id TEXT NOT NULL REFERENCES agents(agent_id),
|
|
132
|
+
recipient_agent_id TEXT NOT NULL REFERENCES agents(agent_id),
|
|
133
|
+
reply_to_message_id TEXT REFERENCES agent_messages(message_id),
|
|
134
|
+
content TEXT NOT NULL,
|
|
135
|
+
delivery_mode TEXT NOT NULL DEFAULT 'steer',
|
|
136
|
+
status TEXT NOT NULL DEFAULT 'pending',
|
|
137
|
+
provider TEXT,
|
|
138
|
+
provider_receipt TEXT,
|
|
139
|
+
error_code TEXT,
|
|
140
|
+
error_detail TEXT,
|
|
141
|
+
idempotency_key TEXT NOT NULL,
|
|
142
|
+
created_at TEXT NOT NULL,
|
|
143
|
+
delivered_at TEXT,
|
|
144
|
+
replied_at TEXT,
|
|
145
|
+
failed_at TEXT,
|
|
146
|
+
project TEXT NOT NULL DEFAULT '',
|
|
147
|
+
CHECK (delivery_mode = 'steer'),
|
|
148
|
+
CHECK (status IN ('pending', 'delivered', 'replied', 'failed')),
|
|
149
|
+
UNIQUE (sender_agent_id, idempotency_key),
|
|
150
|
+
FOREIGN KEY (project, task_id) REFERENCES tasks(project, task_id)
|
|
151
|
+
);
|
|
152
|
+
INSERT INTO agent_messages_012 SELECT *, '' FROM agent_messages;
|
|
153
|
+
DROP TABLE agent_messages;
|
|
154
|
+
ALTER TABLE agent_messages_012 RENAME TO agent_messages;
|
|
155
|
+
CREATE INDEX idx_agent_messages_recipient
|
|
156
|
+
ON agent_messages(recipient_agent_id, created_at, message_id);
|
|
157
|
+
CREATE INDEX idx_agent_messages_sender
|
|
158
|
+
ON agent_messages(sender_agent_id, created_at, message_id);
|
|
159
|
+
CREATE INDEX idx_agent_messages_task
|
|
160
|
+
ON agent_messages(project, task_id, created_at, message_id);
|
|
161
|
+
CREATE INDEX idx_agent_messages_pending_recipient
|
|
162
|
+
ON agent_messages(recipient_agent_id, status, created_at, message_id);
|
|
163
|
+
|
|
164
|
+
ALTER TABLE events ADD COLUMN project TEXT NOT NULL DEFAULT '';
|
|
165
|
+
DROP INDEX idx_events_task_id;
|
|
166
|
+
CREATE INDEX idx_events_project_task ON events(project, task_id);
|
|
167
|
+
`;
|
|
168
|
+
//# sourceMappingURL=project-scope-migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-scope-migration.js","sourceRoot":"","sources":["../../src/db/project-scope-migration.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC;AAEhC;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyJtC,CAAC"}
|
|
@@ -2,6 +2,8 @@ import type { ConcordDatabase } from '../connection.js';
|
|
|
2
2
|
import { type AgentMessageErrorCode, type AgentMessageEvent, type AgentMessageEventRecord, type AgentMessageRecord } from '../rows.js';
|
|
3
3
|
export interface NewAgentMessage {
|
|
4
4
|
messageId: string;
|
|
5
|
+
/** The project `taskId` belongs to, when not this repository's (a reply's). */
|
|
6
|
+
project?: string | undefined;
|
|
5
7
|
taskId: string | null;
|
|
6
8
|
senderAgentId: string;
|
|
7
9
|
recipientAgentId: string;
|
|
@@ -27,4 +29,5 @@ export interface AgentMessageRepository {
|
|
|
27
29
|
recordEvent(messageId: string, event: AgentMessageEvent, detail?: string | null): void;
|
|
28
30
|
listEvents(messageId: string): AgentMessageEventRecord[];
|
|
29
31
|
}
|
|
30
|
-
|
|
32
|
+
/** Messages span the store; only the task a message names is scoped to `project`. */
|
|
33
|
+
export declare function createAgentMessageRepository(db: ConcordDatabase, project?: string): AgentMessageRepository;
|