@creator-notes/cnotes 0.79.0 → 0.81.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/.claude-plugin/plugin.json +1 -1
- package/README.md +1 -0
- package/dist/commands/auth-keys.js +2 -2
- package/dist/commands/auth-keys.js.map +1 -1
- package/dist/commands/brief.js +1 -1
- package/dist/commands/brief.js.map +1 -1
- package/dist/commands/canvas-milestone.js +3 -3
- package/dist/commands/canvas-milestone.js.map +1 -1
- package/dist/commands/canvas.d.ts.map +1 -1
- package/dist/commands/canvas.js +125 -78
- package/dist/commands/canvas.js.map +1 -1
- package/dist/commands/deps.js +3 -3
- package/dist/commands/deps.js.map +1 -1
- package/dist/commands/draft.d.ts.map +1 -1
- package/dist/commands/draft.js +301 -141
- package/dist/commands/draft.js.map +1 -1
- package/dist/commands/feedback.js +3 -3
- package/dist/commands/feedback.js.map +1 -1
- package/dist/commands/files.js +3 -3
- package/dist/commands/files.js.map +1 -1
- package/dist/commands/focus.js +3 -3
- package/dist/commands/focus.js.map +1 -1
- package/dist/commands/init.js +1 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/notes.d.ts.map +1 -1
- package/dist/commands/notes.js +15 -14
- package/dist/commands/notes.js.map +1 -1
- package/dist/commands/operations.d.ts +9 -0
- package/dist/commands/operations.d.ts.map +1 -1
- package/dist/commands/operations.js +152 -49
- package/dist/commands/operations.js.map +1 -1
- package/dist/commands/quality.js +1 -1
- package/dist/commands/quality.js.map +1 -1
- package/dist/commands/relationships.js +3 -3
- package/dist/commands/relationships.js.map +1 -1
- package/dist/commands/review.d.ts.map +1 -1
- package/dist/commands/review.js +10 -7
- package/dist/commands/review.js.map +1 -1
- package/dist/commands/schema.js +1 -1
- package/dist/commands/schema.js.map +1 -1
- package/dist/commands/search.js +2 -2
- package/dist/commands/search.js.map +1 -1
- package/dist/commands/shared.js +1 -1
- package/dist/commands/shared.js.map +1 -1
- package/dist/commands/theme.js +5 -5
- package/dist/commands/theme.js.map +1 -1
- package/dist/commands/timeline.js +1 -1
- package/dist/commands/timeline.js.map +1 -1
- package/dist/commands/types.js +4 -4
- package/dist/commands/types.js.map +1 -1
- package/dist/commands/upgrade.js +1 -1
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/commands/versions.js +2 -2
- package/dist/commands/versions.js.map +1 -1
- package/dist/commands/workspace.d.ts.map +1 -1
- package/dist/commands/workspace.js +90 -9
- package/dist/commands/workspace.js.map +1 -1
- package/dist/lib/active-run.d.ts +62 -0
- package/dist/lib/active-run.d.ts.map +1 -0
- package/dist/lib/active-run.js +75 -0
- package/dist/lib/active-run.js.map +1 -0
- package/dist/lib/api-client.d.ts +19 -1
- package/dist/lib/api-client.d.ts.map +1 -1
- package/dist/lib/api-client.js +32 -2
- package/dist/lib/api-client.js.map +1 -1
- package/dist/lib/auth-store.d.ts +66 -0
- package/dist/lib/auth-store.d.ts.map +1 -1
- package/dist/lib/auth-store.js +204 -28
- package/dist/lib/auth-store.js.map +1 -1
- package/dist/lib/build-schema.d.ts +1 -1
- package/dist/lib/build-schema.js +1 -1
- package/dist/lib/build-schema.js.map +1 -1
- package/dist/lib/config.d.ts +14 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +20 -5
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/draft-view.d.ts +306 -0
- package/dist/lib/draft-view.d.ts.map +1 -0
- package/dist/lib/draft-view.js +358 -0
- package/dist/lib/draft-view.js.map +1 -0
- package/dist/lib/errors.d.ts +6 -0
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +64 -1
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/urls.d.ts +15 -0
- package/dist/lib/urls.d.ts.map +1 -1
- package/dist/lib/urls.js +20 -0
- package/dist/lib/urls.js.map +1 -1
- package/dist/mcp-server.js +6 -2
- package/dist/mcp-server.js.map +1 -1
- package/package.json +1 -1
- package/skills/cnotes/SKILL.md +104 -64
package/dist/lib/auth-store.d.ts
CHANGED
|
@@ -13,6 +13,13 @@ export interface ServerConfig {
|
|
|
13
13
|
* Both bracketing commands share this one slot on purpose: a request carries
|
|
14
14
|
* exactly one X-Agent-Run-Id, so two concurrent "active" runs would be
|
|
15
15
|
* ambiguous. `begin` refuses when this is already set (unless --force).
|
|
16
|
+
*
|
|
17
|
+
* This slot is only the IMPLICIT-attach default. It is not the record of
|
|
18
|
+
* which runs this CLI has open — that is `agentRuns` below. A run opened
|
|
19
|
+
* with `begin --detached` never touches this slot: its writes carry the run
|
|
20
|
+
* id through CNOTES_AGENT_RUN_ID instead, so two agents sharing one config
|
|
21
|
+
* (two bots on one machine) can each hold their own run without one
|
|
22
|
+
* overwriting, or ending, the other's.
|
|
16
23
|
*/
|
|
17
24
|
activeAgentRunId?: string;
|
|
18
25
|
/** When activeAgentRunId was opened — used to surface helpful "started
|
|
@@ -34,6 +41,29 @@ export interface ServerConfig {
|
|
|
34
41
|
* canvas snapshot to carry.
|
|
35
42
|
*/
|
|
36
43
|
activeAgentBeforeSnapshotId?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Every agent-run this CLI config opened on this server and has not yet
|
|
46
|
+
* ended, keyed by agentRunId — the active one AND any detached ones. This is
|
|
47
|
+
* the ownership record `end` checks before closing a run: a run that is not
|
|
48
|
+
* here was opened by someone else (another machine, another login), and
|
|
49
|
+
* `end` refuses it unless told --force. The active pointer above is always
|
|
50
|
+
* also a key here (except for configs written by older CLIs, which `end`
|
|
51
|
+
* still honours).
|
|
52
|
+
*/
|
|
53
|
+
agentRuns?: Record<string, OpenAgentRun>;
|
|
54
|
+
}
|
|
55
|
+
/** One open run in {@link ServerConfig.agentRuns}. */
|
|
56
|
+
export interface OpenAgentRun {
|
|
57
|
+
startedAt: number;
|
|
58
|
+
/** Canvas runs only — see {@link ServerConfig.activeAgentBeforeSnapshotId}. */
|
|
59
|
+
beforeSnapshotId?: string;
|
|
60
|
+
/** Canvas runs only: the canvas the run was opened on. */
|
|
61
|
+
canvasId?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Opened with --detached: never installed as the active pointer, so its
|
|
64
|
+
* writes attach only through CNOTES_AGENT_RUN_ID.
|
|
65
|
+
*/
|
|
66
|
+
detached?: boolean;
|
|
37
67
|
}
|
|
38
68
|
export interface CliConfig {
|
|
39
69
|
version: 1;
|
|
@@ -68,6 +98,42 @@ export declare function setWorkspaceId(config: CliConfig, serverUrl: string, wor
|
|
|
68
98
|
* unattributed human edits. Same contract as setWorkspaceId above.
|
|
69
99
|
*/
|
|
70
100
|
export declare function setActiveAgentRunId(config: CliConfig, serverUrl: string, agentRunId: string, startedAt: number, beforeSnapshotId?: string): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Record an open run WITHOUT making it the active one. This is what
|
|
103
|
+
* `begin --detached` and `agent-run wrap` use: the run is tracked here (so
|
|
104
|
+
* `end` recognises it as ours) but writes attach to it only through
|
|
105
|
+
* CNOTES_AGENT_RUN_ID, never implicitly — so it can coexist with another
|
|
106
|
+
* agent's active run on the same config.
|
|
107
|
+
*
|
|
108
|
+
* Returns false when there is no stored config entry for `serverUrl` (same
|
|
109
|
+
* contract as setActiveAgentRunId): nothing on disk to record the run in.
|
|
110
|
+
*/
|
|
111
|
+
export declare function registerAgentRun(config: CliConfig, serverUrl: string, agentRunId: string, run: OpenAgentRun): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Forget one open run after it was ended: drops it from the registry and, if
|
|
114
|
+
* it was the active pointer, clears the pointer too. Any OTHER run — the
|
|
115
|
+
* active one when a detached run ends, or a detached run when the active one
|
|
116
|
+
* ends — is left exactly as it was. No-op when the run is unknown.
|
|
117
|
+
*/
|
|
118
|
+
export declare function unregisterAgentRun(config: CliConfig, serverUrl: string, agentRunId: string): void;
|
|
119
|
+
/**
|
|
120
|
+
* Did this CLI config open `agentRunId` on `serverUrl`? The answer `end` uses
|
|
121
|
+
* to refuse closing somebody else's run.
|
|
122
|
+
*
|
|
123
|
+
* - true: it is in the registry, or it is the active pointer (configs from
|
|
124
|
+
* CLIs that predate the registry only have the pointer).
|
|
125
|
+
* - false: there is a stored login for the server and the run is not ours.
|
|
126
|
+
* - null: no stored login for the server at all (token came from --token /
|
|
127
|
+
* CNOTES_TOKEN), so there is no record to check against. Callers
|
|
128
|
+
* treat this as "cannot tell" rather than "not ours": the run id
|
|
129
|
+
* can only have come from the caller's own `begin` output.
|
|
130
|
+
*/
|
|
131
|
+
export declare function isOwnedAgentRun(config: CliConfig, serverUrl: string, agentRunId: string): boolean | null;
|
|
132
|
+
/** Every run this CLI config has open on `serverUrl`, oldest first. */
|
|
133
|
+
export declare function listOpenAgentRuns(config: CliConfig, serverUrl: string): Array<{
|
|
134
|
+
agentRunId: string;
|
|
135
|
+
active: boolean;
|
|
136
|
+
} & OpenAgentRun>;
|
|
71
137
|
/**
|
|
72
138
|
* Clear the active agent-run for a server. Called by `cnotes operations end` /
|
|
73
139
|
* `cnotes canvas agent-run end` after a successful close, so the next cnotes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-store.d.ts","sourceRoot":"","sources":["../../src/lib/auth-store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth-store.d.ts","sourceRoot":"","sources":["../../src/lib/auth-store.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;;;;;;;;;;;;OAkBG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;yEACqE;IACrE,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC;;;;;;;;;;;;;;OAcG;IACH,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CAC1C;AAED,sDAAsD;AACtD,MAAM,WAAW,YAAY;I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jB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,YAAY,GAChB,OAAO,CAIT;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,IAAI,CAgBN;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,OAAO,GAAG,IAAI,CAKhB;AAED,uEAAuE;AACvE,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,MAAM,GAChB,KAAK,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAAG,YAAY,CAAC,CAoB/D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,MAAM,GAChB,IAAI,CAgBN;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,MAAM,GAChB;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAU7E"}
|
package/dist/lib/auth-store.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync, mkdirSync, chmodSync, existsSync, renameSync } from "node:fs";
|
|
1
|
+
import { readFileSync, writeFileSync, mkdirSync, chmodSync, existsSync, renameSync, rmSync, statSync, } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import { BRAND } from "./brand.js";
|
|
@@ -60,12 +60,95 @@ export function loadConfig() {
|
|
|
60
60
|
}
|
|
61
61
|
export function saveConfig(config) {
|
|
62
62
|
mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
|
|
63
|
-
|
|
63
|
+
// Write to a sibling temp file and rename it into place: the rename is
|
|
64
|
+
// atomic, so a cnotes process reading the config at the same moment (two
|
|
65
|
+
// bots on one machine) sees either the old file or the new one, never a
|
|
66
|
+
// half-written one that parses as "logged out".
|
|
67
|
+
const tmp = `${CONFIG_FILE}.${process.pid}.${Date.now()}.tmp`;
|
|
68
|
+
writeFileSync(tmp, JSON.stringify(config, null, 2) + "\n", {
|
|
64
69
|
encoding: "utf-8",
|
|
65
70
|
mode: 0o600,
|
|
66
71
|
});
|
|
67
|
-
|
|
68
|
-
|
|
72
|
+
chmodSync(tmp, 0o600);
|
|
73
|
+
renameSync(tmp, CONFIG_FILE);
|
|
74
|
+
}
|
|
75
|
+
// ---------------------------------------------------------------------------
|
|
76
|
+
// Read-modify-write under a lock.
|
|
77
|
+
//
|
|
78
|
+
// Every mutator below re-reads the config from disk, applies its change and
|
|
79
|
+
// writes it back while holding a directory lock (mkdir is atomic on every
|
|
80
|
+
// platform Node runs on). Without it, two `begin`s running at the same time
|
|
81
|
+
// (two bots on one machine) each load the same config, each add their own
|
|
82
|
+
// run, and the second write silently drops the first bot's run — which is
|
|
83
|
+
// then "not ours" when that bot tries to end it.
|
|
84
|
+
//
|
|
85
|
+
// The lock is advisory and bounded: a holder that died leaves a directory
|
|
86
|
+
// behind, so a lock older than LOCK_STALE_MS is broken, and after LOCK_WAIT_MS
|
|
87
|
+
// of waiting the write proceeds unlocked rather than wedging the command.
|
|
88
|
+
// ---------------------------------------------------------------------------
|
|
89
|
+
const LOCK_DIR = `${CONFIG_FILE}.lock`;
|
|
90
|
+
const LOCK_STALE_MS = 10_000;
|
|
91
|
+
const LOCK_WAIT_MS = 5_000;
|
|
92
|
+
const LOCK_POLL_MS = 15;
|
|
93
|
+
function sleepSync(ms) {
|
|
94
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
95
|
+
}
|
|
96
|
+
function acquireConfigLock() {
|
|
97
|
+
mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
|
|
98
|
+
const deadline = Date.now() + LOCK_WAIT_MS;
|
|
99
|
+
while (true) {
|
|
100
|
+
try {
|
|
101
|
+
mkdirSync(LOCK_DIR);
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
if (e.code !== "EEXIST")
|
|
106
|
+
return false;
|
|
107
|
+
try {
|
|
108
|
+
if (Date.now() - statSync(LOCK_DIR).mtimeMs > LOCK_STALE_MS) {
|
|
109
|
+
rmSync(LOCK_DIR, { recursive: true, force: true });
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
continue; // vanished between the EEXIST and the stat — retry
|
|
115
|
+
}
|
|
116
|
+
if (Date.now() > deadline)
|
|
117
|
+
return false;
|
|
118
|
+
sleepSync(LOCK_POLL_MS);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function releaseConfigLock() {
|
|
123
|
+
try {
|
|
124
|
+
rmSync(LOCK_DIR, { recursive: true, force: true });
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
/* a stale lock is broken by the next acquirer */
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Apply `fn` to the on-disk entry for `serverUrl` atomically, and mirror the
|
|
132
|
+
* result onto `config` (the caller's in-memory copy) so it does not go stale.
|
|
133
|
+
* Returns false, without writing, when there is no stored entry for the
|
|
134
|
+
* server. `fn` returns false to skip the write (nothing changed).
|
|
135
|
+
*/
|
|
136
|
+
function mutateServerConfig(config, serverUrl, fn) {
|
|
137
|
+
const locked = acquireConfigLock();
|
|
138
|
+
try {
|
|
139
|
+
const fresh = loadConfig();
|
|
140
|
+
const sc = fresh.servers[serverUrl];
|
|
141
|
+
if (!sc)
|
|
142
|
+
return false;
|
|
143
|
+
if (fn(sc) !== false)
|
|
144
|
+
saveConfig(fresh);
|
|
145
|
+
config.servers[serverUrl] = sc;
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
finally {
|
|
149
|
+
if (locked)
|
|
150
|
+
releaseConfigLock();
|
|
151
|
+
}
|
|
69
152
|
}
|
|
70
153
|
export function getServerConfig(config, server) {
|
|
71
154
|
const serverUrl = server || config.currentServer;
|
|
@@ -91,13 +174,9 @@ export function setCurrentServer(config, serverUrl) {
|
|
|
91
174
|
* back to a caller should surface this instead of claiming success.
|
|
92
175
|
*/
|
|
93
176
|
export function setWorkspaceId(config, serverUrl, workspaceId) {
|
|
94
|
-
|
|
95
|
-
if (sc) {
|
|
177
|
+
return mutateServerConfig(config, serverUrl, (sc) => {
|
|
96
178
|
sc.workspaceId = workspaceId;
|
|
97
|
-
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
return false;
|
|
179
|
+
});
|
|
101
180
|
}
|
|
102
181
|
/**
|
|
103
182
|
* Mark a given agent-run as the active one for a server. Subsequent cnotes
|
|
@@ -113,22 +192,111 @@ export function setWorkspaceId(config, serverUrl, workspaceId) {
|
|
|
113
192
|
* unattributed human edits. Same contract as setWorkspaceId above.
|
|
114
193
|
*/
|
|
115
194
|
export function setActiveAgentRunId(config, serverUrl, agentRunId, startedAt, beforeSnapshotId) {
|
|
195
|
+
return mutateServerConfig(config, serverUrl, (sc) => {
|
|
196
|
+
sc.activeAgentRunId = agentRunId;
|
|
197
|
+
sc.activeAgentRunStartedAt = startedAt;
|
|
198
|
+
// Always write the slot, so a canvas run never inherits the stale
|
|
199
|
+
// before-snapshot of a previous run (which belongs to a different canvas
|
|
200
|
+
// and would be dropped server-side anyway, silently costing
|
|
201
|
+
// revertability).
|
|
202
|
+
if (beforeSnapshotId) {
|
|
203
|
+
sc.activeAgentBeforeSnapshotId = beforeSnapshotId;
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
delete sc.activeAgentBeforeSnapshotId;
|
|
207
|
+
}
|
|
208
|
+
// The active run is an open run like any other: record it so `end` can
|
|
209
|
+
// tell it apart from a run this CLI never opened.
|
|
210
|
+
sc.agentRuns = {
|
|
211
|
+
...(sc.agentRuns ?? {}),
|
|
212
|
+
[agentRunId]: {
|
|
213
|
+
startedAt,
|
|
214
|
+
...(beforeSnapshotId ? { beforeSnapshotId } : {}),
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Record an open run WITHOUT making it the active one. This is what
|
|
221
|
+
* `begin --detached` and `agent-run wrap` use: the run is tracked here (so
|
|
222
|
+
* `end` recognises it as ours) but writes attach to it only through
|
|
223
|
+
* CNOTES_AGENT_RUN_ID, never implicitly — so it can coexist with another
|
|
224
|
+
* agent's active run on the same config.
|
|
225
|
+
*
|
|
226
|
+
* Returns false when there is no stored config entry for `serverUrl` (same
|
|
227
|
+
* contract as setActiveAgentRunId): nothing on disk to record the run in.
|
|
228
|
+
*/
|
|
229
|
+
export function registerAgentRun(config, serverUrl, agentRunId, run) {
|
|
230
|
+
return mutateServerConfig(config, serverUrl, (sc) => {
|
|
231
|
+
sc.agentRuns = { ...(sc.agentRuns ?? {}), [agentRunId]: run };
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Forget one open run after it was ended: drops it from the registry and, if
|
|
236
|
+
* it was the active pointer, clears the pointer too. Any OTHER run — the
|
|
237
|
+
* active one when a detached run ends, or a detached run when the active one
|
|
238
|
+
* ends — is left exactly as it was. No-op when the run is unknown.
|
|
239
|
+
*/
|
|
240
|
+
export function unregisterAgentRun(config, serverUrl, agentRunId) {
|
|
241
|
+
mutateServerConfig(config, serverUrl, (sc) => {
|
|
242
|
+
let changed = false;
|
|
243
|
+
if (sc.agentRuns && agentRunId in sc.agentRuns) {
|
|
244
|
+
delete sc.agentRuns[agentRunId];
|
|
245
|
+
if (Object.keys(sc.agentRuns).length === 0)
|
|
246
|
+
delete sc.agentRuns;
|
|
247
|
+
changed = true;
|
|
248
|
+
}
|
|
249
|
+
if (sc.activeAgentRunId === agentRunId) {
|
|
250
|
+
delete sc.activeAgentRunId;
|
|
251
|
+
delete sc.activeAgentRunStartedAt;
|
|
252
|
+
delete sc.activeAgentBeforeSnapshotId;
|
|
253
|
+
changed = true;
|
|
254
|
+
}
|
|
255
|
+
return changed;
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Did this CLI config open `agentRunId` on `serverUrl`? The answer `end` uses
|
|
260
|
+
* to refuse closing somebody else's run.
|
|
261
|
+
*
|
|
262
|
+
* - true: it is in the registry, or it is the active pointer (configs from
|
|
263
|
+
* CLIs that predate the registry only have the pointer).
|
|
264
|
+
* - false: there is a stored login for the server and the run is not ours.
|
|
265
|
+
* - null: no stored login for the server at all (token came from --token /
|
|
266
|
+
* CNOTES_TOKEN), so there is no record to check against. Callers
|
|
267
|
+
* treat this as "cannot tell" rather than "not ours": the run id
|
|
268
|
+
* can only have come from the caller's own `begin` output.
|
|
269
|
+
*/
|
|
270
|
+
export function isOwnedAgentRun(config, serverUrl, agentRunId) {
|
|
116
271
|
const sc = config.servers[serverUrl];
|
|
117
272
|
if (!sc)
|
|
118
|
-
return
|
|
119
|
-
sc.activeAgentRunId
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
273
|
+
return null;
|
|
274
|
+
if (sc.activeAgentRunId === agentRunId)
|
|
275
|
+
return true;
|
|
276
|
+
return Boolean(sc.agentRuns && agentRunId in sc.agentRuns);
|
|
277
|
+
}
|
|
278
|
+
/** Every run this CLI config has open on `serverUrl`, oldest first. */
|
|
279
|
+
export function listOpenAgentRuns(config, serverUrl) {
|
|
280
|
+
const sc = config.servers[serverUrl];
|
|
281
|
+
if (!sc)
|
|
282
|
+
return [];
|
|
283
|
+
const runs = { ...(sc.agentRuns ?? {}) };
|
|
284
|
+
// A pointer written by an older CLI has no registry entry; surface it too.
|
|
285
|
+
if (sc.activeAgentRunId && !(sc.activeAgentRunId in runs)) {
|
|
286
|
+
runs[sc.activeAgentRunId] = {
|
|
287
|
+
startedAt: sc.activeAgentRunStartedAt ?? 0,
|
|
288
|
+
...(sc.activeAgentBeforeSnapshotId
|
|
289
|
+
? { beforeSnapshotId: sc.activeAgentBeforeSnapshotId }
|
|
290
|
+
: {}),
|
|
291
|
+
};
|
|
129
292
|
}
|
|
130
|
-
|
|
131
|
-
|
|
293
|
+
return Object.entries(runs)
|
|
294
|
+
.map(([agentRunId, run]) => ({
|
|
295
|
+
agentRunId,
|
|
296
|
+
active: sc.activeAgentRunId === agentRunId,
|
|
297
|
+
...run,
|
|
298
|
+
}))
|
|
299
|
+
.sort((a, b) => a.startedAt - b.startedAt);
|
|
132
300
|
}
|
|
133
301
|
/**
|
|
134
302
|
* Clear the active agent-run for a server. Called by `cnotes operations end` /
|
|
@@ -136,14 +304,22 @@ export function setActiveAgentRunId(config, serverUrl, agentRunId, startedAt, be
|
|
|
136
304
|
* write reverts to "unattached" unless the user opens a new run.
|
|
137
305
|
*/
|
|
138
306
|
export function clearActiveAgentRunId(config, serverUrl) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
307
|
+
mutateServerConfig(config, serverUrl, (sc) => {
|
|
308
|
+
if (!(sc.activeAgentRunId || sc.activeAgentRunStartedAt || sc.activeAgentBeforeSnapshotId)) {
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
// The active run has ended, so it leaves the open-run registry with the
|
|
312
|
+
// pointer. Detached runs in the registry are untouched: they are other
|
|
313
|
+
// agents' business.
|
|
314
|
+
if (sc.activeAgentRunId && sc.agentRuns && sc.activeAgentRunId in sc.agentRuns) {
|
|
315
|
+
delete sc.agentRuns[sc.activeAgentRunId];
|
|
316
|
+
if (Object.keys(sc.agentRuns).length === 0)
|
|
317
|
+
delete sc.agentRuns;
|
|
318
|
+
}
|
|
142
319
|
delete sc.activeAgentRunId;
|
|
143
320
|
delete sc.activeAgentRunStartedAt;
|
|
144
321
|
delete sc.activeAgentBeforeSnapshotId;
|
|
145
|
-
|
|
146
|
-
}
|
|
322
|
+
});
|
|
147
323
|
}
|
|
148
324
|
/**
|
|
149
325
|
* Read the active agent-run for a server (if any). `beforeSnapshotId` is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-store.js","sourceRoot":"","sources":["../../src/lib/auth-store.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"auth-store.js","sourceRoot":"","sources":["../../src/lib/auth-store.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,aAAa,EACb,SAAS,EACT,SAAS,EACT,UAAU,EACV,UAAU,EACV,MAAM,EACN,QAAQ,GACT,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AA6EnC,4EAA4E;AAC5E,+EAA+E;AAC/E,4EAA4E;AAC5E,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;AACrF,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,eAAe,CAAC,CAAC;AAC3D,SAAS,sBAAsB;IAC7B,IAAI,CAAC;QACH,IACE,UAAU,KAAK,iBAAiB;YAChC,UAAU,CAAC,iBAAiB,CAAC;YAC7B,CAAC,UAAU,CAAC,UAAU,CAAC,EACvB,CAAC;YACD,UAAU,CAAC,iBAAiB,EAA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ClE,CAAC;QACD,OAAO,EAAE,CAAC,gBAAgB,CAAC;QAC3B,OAAO,EAAE,CAAC,uBAAuB,CAAC;QAClC,OAAO,EAAE,CAAC,2BAA2B,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAiB,EACjB,SAAiB;IAEjB,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACrC,IAAI,EAAE,EAAE,gBAAgB,IAAI,EAAE,CAAC,uBAAuB,EAAE,CAAC;QACvD,OAAO;YACL,UAAU,EAAE,EAAE,CAAC,gBAAgB;YAC/B,SAAS,EAAE,EAAE,CAAC,uBAAuB;YACrC,gBAAgB,EAAE,EAAE,CAAC,2BAA2B;SACjD,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -21,7 +21,7 @@ export declare const STATIC_SCHEMA: {
|
|
|
21
21
|
readonly note: "After finding a note (search semantic / notes list), see how it connects before acting — the agent mirror of the editor's Backlinks + Canvases affordances.";
|
|
22
22
|
readonly backlinks: "`cnotes rel list --note <displayId> --json` → { incoming, outgoing, all }. `incoming` = what links TO this note (backlinks); `outgoing` = what it cites. Each row carries relatedNote {displayId,title,type}, relationshipType {name,label}, and isStale.";
|
|
23
23
|
readonly canvases: "`cnotes notes canvases <displayId> --json` → the canvases the note appears on (container-aware: direct node OR nested in a list/grid). Each row: { id, name, via, viewType, visibility, isHome, goal, updatedAt }. `via` = node | list | both.";
|
|
24
|
-
readonly expand: "`cnotes notes get <id> --expand` returns the note plus the notes it links to, in one round-trip. Sources: live outgoing relationship rows and inline [[rel::ID]] / [[ID]] mentions (a bare [[ID]] is references). Each linked note is labelled `assumes -> OBSERVATION-6K13` (incoming: `assumes <- OTHER-1`). `--depth N` (default 1, max 4) walks further, deduped. The walk stops at 40 notes and sets `notice` when it does. `--rel a,b` limits slugs. `--summary` keeps the title and
|
|
24
|
+
readonly expand: "`cnotes notes get <id> --expand` returns the note plus the notes it links to, in one round-trip. Sources: live outgoing relationship rows and inline [[rel::ID]] / [[ID]] mentions (a bare [[ID]] is references). Each linked note is labelled `assumes -> OBSERVATION-6K13` (incoming: `assumes <- OTHER-1`). `--depth N` (default 1, max 4) walks further, deduped. The walk stops at 40 notes and sets `notice` when it does. `--rel a,b` limits slugs. `--summary` keeps the title and the first real prose paragraph of linked notes (skips leading headings, blanks, and chip-only lines; heading-only notes fall back to the last heading text, list-only notes to the first list); requested notes stay whole. `--incoming` also follows backlinks. JSON is `{ notes, linked, truncated, cap, omitted, notice }`. Each linked entry is `{ displayId, relation, direction, depth, from, label, links, note }` and `note` matches a `notes get` row. Without `--expand`, `notes get --json` stays a bare array.";
|
|
25
25
|
};
|
|
26
26
|
readonly resources: {
|
|
27
27
|
readonly note: {
|
package/dist/lib/build-schema.js
CHANGED
|
@@ -32,7 +32,7 @@ export const STATIC_SCHEMA = {
|
|
|
32
32
|
note: "After finding a note (search semantic / notes list), see how it connects before acting — the agent mirror of the editor's Backlinks + Canvases affordances.",
|
|
33
33
|
backlinks: "`cnotes rel list --note <displayId> --json` → { incoming, outgoing, all }. `incoming` = what links TO this note (backlinks); `outgoing` = what it cites. Each row carries relatedNote {displayId,title,type}, relationshipType {name,label}, and isStale.",
|
|
34
34
|
canvases: "`cnotes notes canvases <displayId> --json` → the canvases the note appears on (container-aware: direct node OR nested in a list/grid). Each row: { id, name, via, viewType, visibility, isHome, goal, updatedAt }. `via` = node | list | both.",
|
|
35
|
-
expand: "`cnotes notes get <id> --expand` returns the note plus the notes it links to, in one round-trip. Sources: live outgoing relationship rows and inline [[rel::ID]] / [[ID]] mentions (a bare [[ID]] is references). Each linked note is labelled `assumes -> OBSERVATION-6K13` (incoming: `assumes <- OTHER-1`). `--depth N` (default 1, max 4) walks further, deduped. The walk stops at 40 notes and sets `notice` when it does. `--rel a,b` limits slugs. `--summary` keeps the title and
|
|
35
|
+
expand: "`cnotes notes get <id> --expand` returns the note plus the notes it links to, in one round-trip. Sources: live outgoing relationship rows and inline [[rel::ID]] / [[ID]] mentions (a bare [[ID]] is references). Each linked note is labelled `assumes -> OBSERVATION-6K13` (incoming: `assumes <- OTHER-1`). `--depth N` (default 1, max 4) walks further, deduped. The walk stops at 40 notes and sets `notice` when it does. `--rel a,b` limits slugs. `--summary` keeps the title and the first real prose paragraph of linked notes (skips leading headings, blanks, and chip-only lines; heading-only notes fall back to the last heading text, list-only notes to the first list); requested notes stay whole. `--incoming` also follows backlinks. JSON is `{ notes, linked, truncated, cap, omitted, notice }`. Each linked entry is `{ displayId, relation, direction, depth, from, label, links, note }` and `note` matches a `notes get` row. Without `--expand`, `notes get --json` stays a bare array.",
|
|
36
36
|
},
|
|
37
37
|
resources: {
|
|
38
38
|
note: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-schema.js","sourceRoot":"","sources":["../../src/lib/build-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,aAAa,EAAE;QACb,IAAI,EAAE,iIAAiI;QACvI,MAAM,EAAE;YACN,YAAY;YACZ,UAAU;YACV,QAAQ;YACR,cAAc;YACd,aAAa;YACb,UAAU;YACV,SAAS;SACV;KACF;IACD,MAAM,EAAE;QACN,WAAW,EAAE,uCAAuC;QACpD,gBAAgB,EAAE,oGAAoG;QACtH,KAAK,EAAE;YACL,6FAA6F;YAC7F,qQAAqQ;YACrQ,uOAAuO;SACxO;KACF;IACD,SAAS,EAAE;QACT,IAAI,EAAE,6JAA6J;QACnK,SAAS,EAAE,2PAA2P;QACtQ,QAAQ,EAAE,gPAAgP;QAC1P,MAAM,EACJ,
|
|
1
|
+
{"version":3,"file":"build-schema.js","sourceRoot":"","sources":["../../src/lib/build-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,aAAa,EAAE;QACb,IAAI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GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAChE,GAAG,aAAa;KACjB,CAAC;AACJ,CAAC"}
|
package/dist/lib/config.d.ts
CHANGED
|
@@ -2,10 +2,24 @@ export interface ResolvedConfig {
|
|
|
2
2
|
serverUrl: string;
|
|
3
3
|
token: string;
|
|
4
4
|
workspaceId: string;
|
|
5
|
+
/**
|
|
6
|
+
* Where `workspaceId` came from. A `-w` flag or CNOTES_WORKSPACE beats the
|
|
7
|
+
* workspace saved in the config, so a command that saves a new active
|
|
8
|
+
* workspace (`draft open`, `draft checkout`) is shadowed while either is set.
|
|
9
|
+
*/
|
|
10
|
+
workspaceSource?: WorkspaceSource;
|
|
11
|
+
/** The overrides that were set, and the saved workspace they beat. */
|
|
12
|
+
workspaceOverrides: WorkspaceOverrides;
|
|
5
13
|
json: boolean;
|
|
6
14
|
quiet: boolean;
|
|
7
15
|
fields?: string[];
|
|
8
16
|
}
|
|
17
|
+
export type WorkspaceSource = "flag" | "env" | "config";
|
|
18
|
+
export interface WorkspaceOverrides {
|
|
19
|
+
flag?: string;
|
|
20
|
+
env?: string;
|
|
21
|
+
saved?: string;
|
|
22
|
+
}
|
|
9
23
|
interface GlobalOpts {
|
|
10
24
|
server?: string;
|
|
11
25
|
workspace?: string;
|
package/dist/lib/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,UAAU,UAAU;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;I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ED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC,cAAc,EAAE,aAAa,CAAC,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAalH"}
|
package/dist/lib/config.js
CHANGED
|
@@ -22,6 +22,22 @@ function resolveOutput(opts) {
|
|
|
22
22
|
const json = opts.json || process.env.CNOTES_JSON === "1" || !process.stdout.isTTY || quiet;
|
|
23
23
|
return { json: json ?? false, quiet: quiet && !fields, fields };
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* The working workspace and where it came from. Priority: the `-w` flag, then
|
|
27
|
+
* CNOTES_WORKSPACE, then the workspace saved for this server.
|
|
28
|
+
*/
|
|
29
|
+
function resolveWorkspace(opts, saved) {
|
|
30
|
+
const flag = opts.workspace?.trim() || undefined;
|
|
31
|
+
const env = process.env.CNOTES_WORKSPACE?.trim() || undefined;
|
|
32
|
+
const workspaceOverrides = { flag, env, saved };
|
|
33
|
+
if (flag)
|
|
34
|
+
return { workspaceId: flag, workspaceSource: "flag", workspaceOverrides };
|
|
35
|
+
if (env)
|
|
36
|
+
return { workspaceId: env, workspaceSource: "env", workspaceOverrides };
|
|
37
|
+
if (saved)
|
|
38
|
+
return { workspaceId: saved, workspaceSource: "config", workspaceOverrides };
|
|
39
|
+
return { workspaceOverrides };
|
|
40
|
+
}
|
|
25
41
|
/**
|
|
26
42
|
* Resolve server URL, token, and workspace from env vars, flags, and config file.
|
|
27
43
|
* Priority: flags > env vars > config file.
|
|
@@ -38,9 +54,7 @@ export function resolveConfig(opts) {
|
|
|
38
54
|
throw new AuthError();
|
|
39
55
|
}
|
|
40
56
|
// Workspace ID
|
|
41
|
-
const
|
|
42
|
-
const configWorkspace = getServerConfig(config, serverUrl)?.workspaceId;
|
|
43
|
-
const workspaceId = opts.workspace || envWorkspace || configWorkspace;
|
|
57
|
+
const { workspaceId, workspaceSource, workspaceOverrides } = resolveWorkspace(opts, getServerConfig(config, serverUrl)?.workspaceId);
|
|
44
58
|
if (!workspaceId) {
|
|
45
59
|
throw new ValidationError("No workspace selected. Run `cnotes workspace select` or pass --workspace <id>");
|
|
46
60
|
}
|
|
@@ -48,6 +62,8 @@ export function resolveConfig(opts) {
|
|
|
48
62
|
serverUrl,
|
|
49
63
|
token,
|
|
50
64
|
workspaceId,
|
|
65
|
+
workspaceSource,
|
|
66
|
+
workspaceOverrides,
|
|
51
67
|
...resolveOutput(opts),
|
|
52
68
|
};
|
|
53
69
|
}
|
|
@@ -60,11 +76,10 @@ export function resolveBaseConfig(opts) {
|
|
|
60
76
|
const envToken = process.env.CNOTES_TOKEN;
|
|
61
77
|
const configToken = getServerConfig(config, serverUrl)?.token;
|
|
62
78
|
const token = envToken || configToken || "";
|
|
63
|
-
const configWorkspace = getServerConfig(config, serverUrl)?.workspaceId;
|
|
64
79
|
return {
|
|
65
80
|
serverUrl,
|
|
66
81
|
token,
|
|
67
|
-
|
|
82
|
+
...resolveWorkspace(opts, getServerConfig(config, serverUrl)?.workspaceId),
|
|
68
83
|
...resolveOutput(opts),
|
|
69
84
|
};
|
|
70
85
|
}
|
package/dist/lib/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAmCzD;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,MAAe;IACzC,IAAI,CAAC,MAAM;QAAE,OAAO,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