@creator-notes/cnotes 0.78.0 → 0.80.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 +7 -5
- package/dist/commands/canvas-milestone.d.ts +1 -1
- package/dist/commands/canvas-milestone.d.ts.map +1 -1
- package/dist/commands/canvas-milestone.js +6 -3
- package/dist/commands/canvas-milestone.js.map +1 -1
- package/dist/commands/canvas.d.ts.map +1 -1
- package/dist/commands/canvas.js +87 -37
- package/dist/commands/canvas.js.map +1 -1
- package/dist/commands/notes.d.ts.map +1 -1
- package/dist/commands/notes.js +16 -2
- 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 +151 -46
- package/dist/commands/operations.js.map +1 -1
- package/dist/commands/versions.d.ts.map +1 -1
- package/dist/commands/versions.js +4 -2
- package/dist/commands/versions.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/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/headline-warnings.d.ts +8 -0
- package/dist/lib/headline-warnings.d.ts.map +1 -0
- package/dist/lib/headline-warnings.js +27 -0
- package/dist/lib/headline-warnings.js.map +1 -0
- package/dist/lib/milestone-message.d.ts.map +1 -1
- package/dist/lib/milestone-message.js +5 -4
- package/dist/lib/milestone-message.js.map +1 -1
- package/dist/mcp-server.js +2 -2
- package/dist/mcp-server.js.map +1 -1
- package/package.json +1 -1
- package/skills/attention-planner/SKILL.md +3 -2
- package/skills/attention-planner/references/attention-type.md +5 -4
- package/skills/attention-planner/references/card-shapes.md +14 -17
- package/skills/attention-planner/references/orientation-canvas.md +3 -2
- package/skills/cnotes/SKILL.md +31 -12
- package/skills/cnotes/references/humanizer.md +8 -0
package/README.md
CHANGED
|
@@ -135,8 +135,10 @@ cnotes notes bulk-retype --ids '["NOTE-1","NOTE-3","NOTE-5"]' --type Insight --j
|
|
|
135
135
|
Content and metadata are separate operations:
|
|
136
136
|
|
|
137
137
|
```bash
|
|
138
|
-
# Update content -> create a new version
|
|
139
|
-
|
|
138
|
+
# Update content -> create a new version. First line is the timeline headline
|
|
139
|
+
# (verb-first, at most 110 characters). A blank line, then the body. The
|
|
140
|
+
# platform may rewrite an agent headline. The body is kept.
|
|
141
|
+
cnotes versions create MEETING-42 --description "Added the action items from the review" --markdown-file ./updated.md
|
|
140
142
|
|
|
141
143
|
# Update metadata (type, tags, pin, archive). Title is read-only —
|
|
142
144
|
# change it by creating a new version with a different # h1 heading.
|
|
@@ -160,9 +162,9 @@ cnotes canvas read <canvasId>
|
|
|
160
162
|
# editing, or to confirm a previous agent run actually applied.
|
|
161
163
|
cnotes canvas activity <canvasId> [--limit 50]
|
|
162
164
|
|
|
163
|
-
# Save a milestone. First line is the headline,
|
|
164
|
-
#
|
|
165
|
-
#
|
|
165
|
+
# Save a milestone. First line is the timeline headline (verb-first, at most
|
|
166
|
+
# 110 characters). A blank line, then the body. The platform may rewrite an
|
|
167
|
+
# agent headline. The body is kept. An active operations run is stamped on.
|
|
166
168
|
cnotes canvas milestone create <canvasId> --message "Opened pricing question: charge for agents or the workspace?"
|
|
167
169
|
cnotes canvas milestone list <canvasId>
|
|
168
170
|
cnotes canvas milestone show <milestoneId>
|
|
@@ -4,7 +4,7 @@ import type { Command } from "commander";
|
|
|
4
4
|
* web UI writes (`canvasSnapshots` kind "milestone", via createMilestone).
|
|
5
5
|
*
|
|
6
6
|
* The message is one git-style field: first line is the timeline headline,
|
|
7
|
-
* the rest is the body.
|
|
7
|
+
* the rest is the body. The platform may rewrite an agent headline. The body is kept.
|
|
8
8
|
* Writes ride the active operations run through X-Agent-Run-Id, the same
|
|
9
9
|
* header every other CLI write sends.
|
|
10
10
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas-milestone.d.ts","sourceRoot":"","sources":["../../src/commands/canvas-milestone.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"canvas-milestone.d.ts","sourceRoot":"","sources":["../../src/commands/canvas-milestone.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASzC;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CA8KvF"}
|
|
@@ -4,12 +4,13 @@ import { resolveConfig } from "../lib/config.js";
|
|
|
4
4
|
import { handleError } from "../lib/errors.js";
|
|
5
5
|
import { readMilestoneMessage } from "../lib/milestone-message.js";
|
|
6
6
|
import { outputJson, outputQuiet, outputTable, timeAgo, truncate } from "../lib/output.js";
|
|
7
|
+
import { readHeadlineWarnings, reportHeadlineWarnings } from "../lib/headline-warnings.js";
|
|
7
8
|
/**
|
|
8
9
|
* `cnotes canvas milestone`: save and read the same canvas milestones the
|
|
9
10
|
* web UI writes (`canvasSnapshots` kind "milestone", via createMilestone).
|
|
10
11
|
*
|
|
11
12
|
* The message is one git-style field: first line is the timeline headline,
|
|
12
|
-
* the rest is the body.
|
|
13
|
+
* the rest is the body. The platform may rewrite an agent headline. The body is kept.
|
|
13
14
|
* Writes ride the active operations run through X-Agent-Run-Id, the same
|
|
14
15
|
* header every other CLI write sends.
|
|
15
16
|
*/
|
|
@@ -18,8 +19,9 @@ export function registerCanvasMilestoneCommands(canvas, program) {
|
|
|
18
19
|
.command("milestone")
|
|
19
20
|
.description("Save and read canvas milestones. A milestone is a named snapshot of the canvas, like a git tag. " +
|
|
20
21
|
"The message is one field: the first line is the headline shown on the timeline, and the rest is the body. " +
|
|
21
|
-
"
|
|
22
|
-
"
|
|
22
|
+
"The first line is the timeline headline: verb-first, a specific object in the first 40 characters, at most 110 characters. " +
|
|
23
|
+
"A blank line, then the body. The platform may rewrite an agent headline and leaves the body. " +
|
|
24
|
+
"See https://creatornotes.app/blog/timeline-as-navigation");
|
|
23
25
|
milestone
|
|
24
26
|
.command("create")
|
|
25
27
|
.description("Save a milestone for the canvas's current state. Does nothing when there are no unsaved changes. " +
|
|
@@ -60,6 +62,7 @@ Examples:
|
|
|
60
62
|
console.log("No pending canvas changes. Milestone not saved.");
|
|
61
63
|
return;
|
|
62
64
|
}
|
|
65
|
+
reportHeadlineWarnings(readHeadlineWarnings(data));
|
|
63
66
|
if (cfg.quiet) {
|
|
64
67
|
outputQuiet(String(data.id ?? ""));
|
|
65
68
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas-milestone.js","sourceRoot":"","sources":["../../src/commands/canvas-milestone.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE3F;;;;;;;;GAQG;AACH,MAAM,UAAU,+BAA+B,CAAC,MAAe,EAAE,OAAgB;IAC/E,MAAM,SAAS,GAAG,MAAM;SACrB,OAAO,CAAC,WAAW,CAAC;SACpB,WAAW,CACV,kGAAkG;QAClG,4GA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,CAAC,UAAU,CAAC;YACvH,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAChB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACpB,OAAO,CAAC,GAAG,CAAC,OAAO,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;YAC7B,OAAO,CAAC,GAAG,CAAC,WAAW,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;QACzC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas.d.ts","sourceRoot":"","sources":["../../src/commands/canvas.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"canvas.d.ts","sourceRoot":"","sources":["../../src/commands/canvas.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AA2L5C,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA2gG7D"}
|
package/dist/commands/canvas.js
CHANGED
|
@@ -2,11 +2,13 @@ import { writeFileSync } from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { Option } from "commander";
|
|
4
4
|
import { ApiClient, resolveActiveAgentRun } from "../lib/api-client.js";
|
|
5
|
+
import { resolveActiveSlot, fetchRunStatus, isStillOpen } from "../lib/active-run.js";
|
|
5
6
|
import { resolveBaseConfig, resolveConfig } from "../lib/config.js";
|
|
6
7
|
import { ApiError, CliError, EXIT_CODES, handleError, ValidationError } from "../lib/errors.js";
|
|
7
8
|
import { parseJsonOption, readFileSafe } from "../lib/fs-utils.js";
|
|
8
|
-
import { loadConfig, setActiveAgentRunId,
|
|
9
|
-
import { outputJson, outputTable, outputQuiet, truncate, timeAgo
|
|
9
|
+
import { loadConfig, setActiveAgentRunId, registerAgentRun, unregisterAgentRun, isOwnedAgentRun, } from "../lib/auth-store.js";
|
|
10
|
+
import { outputJson, outputTable, outputQuiet, truncate, timeAgo } from "../lib/output.js";
|
|
11
|
+
import { readHeadlineWarnings, reportHeadlineWarnings } from "../lib/headline-warnings.js";
|
|
10
12
|
import { readCanvasMarkdown, renderCanvasMarkdown, parseSharedCanvasLink, sameServerOrigin, readCanvasSection, renderCanvasSectionMarkdown, } from "../lib/canvas-read.js";
|
|
11
13
|
import { resolveAgentSession } from "../lib/claude-session.js";
|
|
12
14
|
import { WARN, dim } from "../lib/style.js";
|
|
@@ -2254,14 +2256,16 @@ Examples:
|
|
|
2254
2256
|
.command("begin")
|
|
2255
2257
|
.description("Open an agent-run session — captures a before-snapshot and makes the run active for this server")
|
|
2256
2258
|
.requiredOption("--canvas <id>", "Canvas ID to bracket")
|
|
2257
|
-
.requiredOption("--prompt <text>", "
|
|
2259
|
+
.requiredOption("--prompt <text>", "Run headline. Verb-first, at most 110 characters. The platform may rewrite it. The body is kept.")
|
|
2258
2260
|
.option("--rationale <text>", "Optional rationale (e.g. agent's plan)")
|
|
2259
2261
|
.option("--force", "If an active run already exists on this server, end it server-side and start a fresh one")
|
|
2262
|
+
.option("--detached", "Open an independent run that does NOT become the active run on this server. Writes attach to it only through the printed CNOTES_AGENT_RUN_ID / CNOTES_AGENT_BEFORE_SNAPSHOT_ID exports. Use when another agent may hold the active run on this machine.")
|
|
2260
2263
|
.addHelpText("after", `
|
|
2261
2264
|
Examples:
|
|
2262
2265
|
$ cnotes canvas agent-run begin --canvas <id> --prompt "Reorganize into sections"
|
|
2263
2266
|
$ cnotes canvas place <id> --spec ./layout.json # attaches automatically
|
|
2264
2267
|
$ cnotes canvas agent-run end --canvas <id>
|
|
2268
|
+
$ eval "$(cnotes canvas agent-run begin --canvas <id> --prompt "..." --detached)" # your own run, env-scoped
|
|
2265
2269
|
|
|
2266
2270
|
After 'begin', every subsequent cnotes write on this server attaches to the
|
|
2267
2271
|
run automatically — no env var to export, and it survives across separate
|
|
@@ -2269,7 +2273,8 @@ shells. End with 'cnotes canvas agent-run end --canvas <id>'.
|
|
|
2269
2273
|
|
|
2270
2274
|
If a run is already open (from 'agent-run begin' or 'operations begin'),
|
|
2271
2275
|
begin refuses rather than silently clobbering it. Pass --force to end the
|
|
2272
|
-
prior run server-side and start fresh
|
|
2276
|
+
prior run server-side and start fresh, or --detached to open your own run
|
|
2277
|
+
alongside it (eval the printed exports so your writes carry it).
|
|
2273
2278
|
`)
|
|
2274
2279
|
.action(async (opts) => {
|
|
2275
2280
|
const cfg = resolveConfig(program.opts());
|
|
@@ -2285,24 +2290,17 @@ prior run server-side and start fresh.
|
|
|
2285
2290
|
// pointer, and a request carries exactly one X-Agent-Run-Id — so a
|
|
2286
2291
|
// second begin would either clobber the first or silently attach writes
|
|
2287
2292
|
// to the wrong run. Mirrors `cnotes operations begin`.
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
// idempotent server-side. Either way clear the local pointer so
|
|
2300
|
-
// the caller isn't wedged.
|
|
2301
|
-
}
|
|
2302
|
-
clearActiveAgentRunId(loadConfig(), cfg.serverUrl);
|
|
2303
|
-
}
|
|
2304
|
-
else {
|
|
2305
|
-
throw new CliError(`An active agent-run already exists on this server (agentRunId ${existing.agentRunId}, started ${formatAgo(existing.startedAt)}).`, EXIT_CODES.CONFLICT, "End it first (`cnotes canvas agent-run end --canvas <id>` or `cnotes operations end`), or pass --force to end it server-side and start fresh.");
|
|
2293
|
+
// A detached run never competes for the pointer, so it needs no
|
|
2294
|
+
// conflict check — and must not --force the active run away either.
|
|
2295
|
+
// Otherwise a stale holder (crashed bot) is forgotten and a running
|
|
2296
|
+
// one needs --force. Mirrors `cnotes operations begin`.
|
|
2297
|
+
if (!opts.detached) {
|
|
2298
|
+
const slot = await resolveActiveSlot(api, cfg.serverUrl, {
|
|
2299
|
+
force: opts.force,
|
|
2300
|
+
endCommand: "cnotes canvas agent-run end --canvas <id>` or `cnotes operations end",
|
|
2301
|
+
});
|
|
2302
|
+
if (slot.forgot) {
|
|
2303
|
+
console.error(`# forgot stale run ${slot.forgot.agentRunId} (${slot.forgot.status} server-side); starting fresh`);
|
|
2306
2304
|
}
|
|
2307
2305
|
}
|
|
2308
2306
|
const body = {
|
|
@@ -2327,36 +2325,58 @@ prior run server-side and start fresh.
|
|
|
2327
2325
|
// getRevertContext bails — "Revert this run" is dead for the whole
|
|
2328
2326
|
// batch. Persisting the run id without it produces a run that looks
|
|
2329
2327
|
// perfectly healthy and cannot be undone.
|
|
2330
|
-
|
|
2328
|
+
//
|
|
2329
|
+
// --detached records the run only in the open-run registry (so `end`
|
|
2330
|
+
// knows it is ours) and leaves the active pointer alone: the run is
|
|
2331
|
+
// carried by the printed env exports instead, so another agent's
|
|
2332
|
+
// active run on this machine is neither clobbered nor ended.
|
|
2333
|
+
const tracked = opts.detached
|
|
2334
|
+
? registerAgentRun(loadConfig(), cfg.serverUrl, data.agentRunId, {
|
|
2335
|
+
startedAt: Date.now(),
|
|
2336
|
+
beforeSnapshotId: data.beforeCheckpointId,
|
|
2337
|
+
canvasId: opts.canvas,
|
|
2338
|
+
detached: true,
|
|
2339
|
+
})
|
|
2340
|
+
: setActiveAgentRunId(loadConfig(), cfg.serverUrl, data.agentRunId, Date.now(), data.beforeCheckpointId);
|
|
2341
|
+
const persisted = tracked && !opts.detached;
|
|
2331
2342
|
// No stored config entry for this server (token came from --token /
|
|
2332
2343
|
// CNOTES_TOKEN against a server never logged into), so there is nowhere
|
|
2333
2344
|
// to record the run. Say so rather than printing "every write now
|
|
2334
2345
|
// attaches" — silently attaching nothing is the bug this flow exists to
|
|
2335
2346
|
// kill. stderr, so it can't corrupt --json or the eval form.
|
|
2336
|
-
if (!
|
|
2347
|
+
if (!tracked && !opts.detached) {
|
|
2337
2348
|
console.error(`# WARNING: could not persist the active run for ${cfg.serverUrl} — no stored login for that server.`);
|
|
2338
2349
|
console.error(`# Subsequent cnotes writes will NOT attach to it. Either run \`cnotes auth login\`,`);
|
|
2339
2350
|
console.error(`# or use the env form: eval "$(cnotes canvas agent-run begin --canvas ${opts.canvas} --prompt "...")"`);
|
|
2340
2351
|
}
|
|
2352
|
+
reportHeadlineWarnings(readHeadlineWarnings(data));
|
|
2341
2353
|
if (cfg.quiet) {
|
|
2342
2354
|
outputQuiet(data.agentRunId);
|
|
2343
2355
|
return;
|
|
2344
2356
|
}
|
|
2345
2357
|
if (wantsJson) {
|
|
2346
|
-
outputJson(
|
|
2358
|
+
outputJson({
|
|
2359
|
+
...data,
|
|
2360
|
+
activeRunPersisted: persisted,
|
|
2361
|
+
detached: Boolean(opts.detached),
|
|
2362
|
+
});
|
|
2347
2363
|
return;
|
|
2348
2364
|
}
|
|
2349
2365
|
// Still print the eval-friendly exports so the older
|
|
2350
2366
|
// eval "$(npx cnotes canvas agent-run begin ...)"
|
|
2351
2367
|
// form keeps working. The env var takes precedence over the persisted
|
|
2352
|
-
// pointer, so both paths agree on the same run.
|
|
2368
|
+
// pointer, so both paths agree on the same run. For a detached run the
|
|
2369
|
+
// exports are the ONLY way writes attach, so they are not optional.
|
|
2353
2370
|
console.log(`export CNOTES_AGENT_RUN_ID=${data.agentRunId}`);
|
|
2354
2371
|
console.log(`export CNOTES_AGENT_BEFORE_SNAPSHOT_ID=${data.beforeCheckpointId}`);
|
|
2355
2372
|
console.error(`# agent run started: v${data.beforeSnapshotNumber} (${data.agentRunId})`);
|
|
2356
2373
|
if (persisted) {
|
|
2357
2374
|
console.error(`# every cnotes write on this server now attaches to this run`);
|
|
2358
2375
|
}
|
|
2359
|
-
|
|
2376
|
+
else if (opts.detached) {
|
|
2377
|
+
console.error(`# detached run: writes attach only with the two exports above set (eval this output)`);
|
|
2378
|
+
}
|
|
2379
|
+
console.error(`# end with: npx cnotes canvas agent-run end --canvas ${opts.canvas}${opts.detached ? ` --run-id ${data.agentRunId}` : ""}`);
|
|
2360
2380
|
}
|
|
2361
2381
|
catch (error) {
|
|
2362
2382
|
handleError(error, wantsJson);
|
|
@@ -2366,7 +2386,7 @@ prior run server-side and start fresh.
|
|
|
2366
2386
|
.command("wrap")
|
|
2367
2387
|
.description("Run a shell command inside an agent-run scope (auto begin + end). Recommended for AI agents — no eval gymnastics, no env-var leakage, auto-closes the run even on subprocess failure.")
|
|
2368
2388
|
.requiredOption("--canvas <id>", "Canvas ID")
|
|
2369
|
-
.requiredOption("--prompt <text>", "
|
|
2389
|
+
.requiredOption("--prompt <text>", "Run headline. Verb-first, at most 110 characters. The platform may rewrite it. The body is kept.")
|
|
2370
2390
|
.option("--rationale <text>", "Optional rationale (e.g. agent's plan)")
|
|
2371
2391
|
.argument("<command...>", "Command to execute (e.g. -- bash -c '...')")
|
|
2372
2392
|
.addHelpText("after", `
|
|
@@ -2389,6 +2409,17 @@ Examples:
|
|
|
2389
2409
|
...(agentSession ? { agentSession } : {}),
|
|
2390
2410
|
});
|
|
2391
2411
|
console.error(`# agent run started: v${begin.beforeSnapshotNumber} (${begin.agentRunId})`);
|
|
2412
|
+
reportHeadlineWarnings(readHeadlineWarnings(begin));
|
|
2413
|
+
// Record the run as one this CLI opened — in the registry only, never as
|
|
2414
|
+
// the active pointer (see below). If the close at the end fails and the
|
|
2415
|
+
// user follows the printed `agent-run end --run-id` advice, `end` then
|
|
2416
|
+
// recognises the run as ours instead of refusing it.
|
|
2417
|
+
registerAgentRun(loadConfig(), cfg.serverUrl, begin.agentRunId, {
|
|
2418
|
+
startedAt: Date.now(),
|
|
2419
|
+
beforeSnapshotId: begin.beforeCheckpointId,
|
|
2420
|
+
canvasId: opts.canvas,
|
|
2421
|
+
detached: true,
|
|
2422
|
+
});
|
|
2392
2423
|
// Step 2: spawn the wrapped command with the run env var set.
|
|
2393
2424
|
// stdio is inherited so the subprocess prints to the user's terminal
|
|
2394
2425
|
// exactly as if they'd run it themselves. Only runId + before-snapshot
|
|
@@ -2433,6 +2464,9 @@ Examples:
|
|
|
2433
2464
|
action: "agentRunEnd",
|
|
2434
2465
|
agentRunId: begin.agentRunId,
|
|
2435
2466
|
});
|
|
2467
|
+
// Closed cleanly: forget it. Only this run — an outer `operations`
|
|
2468
|
+
// run this wrap was nested in stays active and open.
|
|
2469
|
+
unregisterAgentRun(loadConfig(), cfg.serverUrl, begin.agentRunId);
|
|
2436
2470
|
const status = exitCode === 0 ? "completed" : `exited ${exitCode}`;
|
|
2437
2471
|
console.error(`# agent run ${status}: v${end.afterSnapshotNumber} (${begin.agentRunId})`);
|
|
2438
2472
|
if (cfg.json) {
|
|
@@ -2456,7 +2490,15 @@ Examples:
|
|
|
2456
2490
|
.command("end")
|
|
2457
2491
|
.description("Close an agent-run session — captures an after-snapshot and clears the active run")
|
|
2458
2492
|
.requiredOption("--canvas <id>", "Canvas ID to close")
|
|
2459
|
-
.option("--run-id <id>", "Agent run ID (defaults to the active run on this server
|
|
2493
|
+
.option("--run-id <id>", "Agent run ID (defaults to CNOTES_AGENT_RUN_ID, then the active run on this server)")
|
|
2494
|
+
.option("--force", "End the run even though this CLI did not open it (another machine or login)")
|
|
2495
|
+
.addHelpText("after", `
|
|
2496
|
+
End only closes runs this CLI opened. Ending one run never touches another:
|
|
2497
|
+
the active pointer is cleared only when it was pointing at the run that
|
|
2498
|
+
ended, so a detached run can end while the active run stays open and vice
|
|
2499
|
+
versa. A run id this CLI has no record of is refused (exit code 5); pass
|
|
2500
|
+
--force to end it anyway.
|
|
2501
|
+
`)
|
|
2460
2502
|
.action(async (opts) => {
|
|
2461
2503
|
const cfg = resolveConfig(program.opts());
|
|
2462
2504
|
const api = new ApiClient(cfg.serverUrl, cfg.token);
|
|
@@ -2473,18 +2515,26 @@ Examples:
|
|
|
2473
2515
|
if (!runId) {
|
|
2474
2516
|
throw new ValidationError("No active run on this server, and no --run-id passed", "Open one with `cnotes canvas agent-run begin --canvas <id> --prompt \"...\"`, or pass --run-id <id> to close a specific run.");
|
|
2475
2517
|
}
|
|
2518
|
+
// Never close a run this CLI did not open (see `operations end`): the
|
|
2519
|
+
// registry holds every run begin/wrap opened here; `null` means there
|
|
2520
|
+
// is no stored login to check against, so let it through.
|
|
2521
|
+
// A run that is already over is harmless to end (idempotent), so
|
|
2522
|
+
// only a live unknown run is refused.
|
|
2523
|
+
const owned = isOwnedAgentRun(loadConfig(), cfg.serverUrl, runId);
|
|
2524
|
+
if (owned === false && !opts.force && isStillOpen(await fetchRunStatus(api, runId))) {
|
|
2525
|
+
throw new CliError(`This CLI has no record of opening run ${runId} on ${cfg.serverUrl}; it was not started here.`, EXIT_CODES.CONFLICT, "Ending it could close another agent's run. If you are sure, pass --force.");
|
|
2526
|
+
}
|
|
2476
2527
|
const data = await api.post(canvasActionPath(opts.canvas, cfg.workspaceId), {
|
|
2477
2528
|
action: "agentRunEnd",
|
|
2478
2529
|
agentRunId: runId,
|
|
2530
|
+
...(opts.force ? { force: true } : {}),
|
|
2479
2531
|
});
|
|
2480
|
-
//
|
|
2481
|
-
//
|
|
2482
|
-
//
|
|
2483
|
-
//
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
clearActiveAgentRunId(loadConfig(), cfg.serverUrl);
|
|
2487
|
-
}
|
|
2532
|
+
// Forget this run, and only this run: it leaves the open-run registry,
|
|
2533
|
+
// and the active pointer is cleared only when it was pointing at the
|
|
2534
|
+
// run we just closed — a concurrent run from another shell (active or
|
|
2535
|
+
// detached) is left as it was. Done after a successful response so a
|
|
2536
|
+
// transient server error can't desync local state from the server.
|
|
2537
|
+
unregisterAgentRun(loadConfig(), cfg.serverUrl, data.agentRunId);
|
|
2488
2538
|
if (cfg.quiet) {
|
|
2489
2539
|
outputQuiet(String(data.afterSnapshotNumber));
|
|
2490
2540
|
return;
|