@notis_ai/cli 0.2.28 → 0.2.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +25 -8
  2. package/dist/agent-hooks/notis-agent-hook.mjs +1476 -712
  3. package/dist/base-skills/notis-cli/.notis-base-skill.json +1 -1
  4. package/dist/base-skills/notis-cli/SKILL.md +11 -0
  5. package/dist/base-skills/notis-spaces/.notis-base-skill.json +1 -1
  6. package/dist/base-skills/notis-spaces/references/release.md +6 -5
  7. package/dist/base-skills/notis-spaces/references/sdk.md +86 -14
  8. package/dist/sdk/src/components/NotisCommentBoundary.tsx +29 -96
  9. package/dist/sdk/src/components/NotisSelectionBoundary.tsx +3 -8
  10. package/dist/sdk/src/components/SelectionActionBar.tsx +144 -23
  11. package/dist/sdk/src/components/selectionId.ts +6 -0
  12. package/dist/sdk/src/hooks/useThreadItem.ts +56 -0
  13. package/dist/sdk/src/index.ts +6 -1
  14. package/dist/sdk/src/runtime.ts +13 -1
  15. package/dist/sdk/src/space.ts +230 -0
  16. package/dist/skill-sync-worker.mjs +185 -30
  17. package/dist/space-harness/host.js +260 -114
  18. package/dist/space-sdk/dist/{chunk-BFGB6XXC.js → chunk-6GJ2BS7B.js} +1 -3
  19. package/dist/space-sdk/dist/index.js +4 -2
  20. package/dist/space-sdk/dist/ui.js +19 -14
  21. package/dist/space-sdk/src/components/NotisCommentBoundary.d.ts +0 -10
  22. package/dist/space-sdk/src/hooks/useThreadItem.d.ts +28 -0
  23. package/dist/space-sdk/src/index.d.ts +3 -1
  24. package/dist/space-sdk/src/runtime.d.ts +13 -1
  25. package/dist/space-sdk/src/space.ts +230 -0
  26. package/dist/space-sdk/src/tailwind-candidates.d.ts +505 -22
  27. package/dist/space-sdk/src/ui/actions/useToast.d.ts +2 -0
  28. package/dist/space-sdk/src/ui/comments/CommentPane.d.ts +56 -10
  29. package/dist/space-sdk/src/ui/comments/PassageComments.d.ts +16 -7
  30. package/dist/space-sdk/src/ui/comments/agentRuntime.d.ts +59 -0
  31. package/dist/space-sdk/src/ui/comments/commentFiles.d.ts +5 -2
  32. package/dist/space-sdk/src/ui/comments/commentModel.d.ts +103 -8
  33. package/dist/space-sdk/src/ui/comments/commentWords.d.ts +82 -0
  34. package/dist/space-sdk/src/ui/comments/hostComments.d.ts +37 -0
  35. package/dist/space-sdk/src/ui/comments/index.d.ts +4 -0
  36. package/dist/space-sdk/src/ui/comments/paneParts.d.ts +119 -0
  37. package/dist/space-sdk/src/ui/comments/useCommentRouting.d.ts +75 -0
  38. package/dist/space-sdk/src/ui/comments/useComments.d.ts +165 -15
  39. package/dist/space-sdk/src/ui/comments/usePassageComments.d.ts +24 -8
  40. package/dist/space-sdk/src/ui/index.d.ts +2 -1
  41. package/dist/space-sdk/src/ui/layout/SidePane.d.ts +6 -1
  42. package/dist/space-sdk/src/ui/overlay/Tooltip.d.ts +8 -2
  43. package/dist/space-sdk/src/ui/styles.d.ts +27 -5
  44. package/dist/view-renderer/dist/host.js +330 -184
  45. package/dist/view-renderer/src/host.tsx +6 -3
  46. package/dist/view-renderer/src/renderer.js +62 -3
  47. package/package.json +3 -3
  48. package/skills/notis-cli/AGENT_INSTRUCTIONS.md +2 -1
  49. package/skills/notis-spaces/cli.md +8 -8
  50. package/src/cli.js +10 -2
  51. package/src/command-specs/computer.js +21 -1
  52. package/src/command-specs/profile.js +12 -5
  53. package/src/command-specs/spaces.js +57 -23
  54. package/src/command-specs/tools.js +1 -1
  55. package/src/runtime/agent-identity.js +187 -0
  56. package/src/runtime/api-hosts.js +92 -0
  57. package/src/runtime/app-platform.js +74 -11
  58. package/src/runtime/channel.js +3 -7
  59. package/src/runtime/oauth.js +95 -4
  60. package/src/runtime/profiles.js +200 -41
  61. package/src/runtime/skill-sync-service.js +4 -5
  62. package/src/runtime/space-fixture-broker.js +23 -2
  63. package/src/runtime/space-platform.js +2 -0
  64. package/src/runtime/space-source.js +66 -1
  65. package/src/runtime/space-test-server.js +20 -4
  66. package/src/runtime/space-verification.js +66 -10
  67. package/src/runtime/telemetry.js +14 -1
  68. package/src/runtime/transport.js +12 -0
  69. package/src/runtime/upsell.js +3 -6
  70. package/src/runtime/view-render.js +3 -1
  71. package/src/skill-sync-worker.js +13 -2
  72. package/src/space-harness-host.ts +6 -3
@@ -20,7 +20,7 @@ import * as NotisSDKUI from '../../sdk/src/ui/index';
20
20
  // The toolkit stylesheet the host adopts into every Space shadow root (esbuild text import).
21
21
  import toolkitCss from '../../sdk/src/ui/toolkit.css' with { type: 'text' };
22
22
 
23
- const state = { mounted: false, pending: 0, blocked: [] as string[], lastActivity: performance.now(), failed: false };
23
+ const state = { mounted: false, pending: 0, blocked: [] as string[], lastActivity: performance.now(), failed: false, failure: '' };
24
24
  // The Space runtime contract (packages/sdk/src/runtimeModules.ts): bundles import React and the SDK from these.
25
25
  Object.assign(window, { __notisRenderState: state, React, ReactDOM, ReactDOMClient, __ReactJSXRuntime: JSXRuntime,
26
26
  __NotisSDK: NotisSDK, __NotisSDKUI: NotisSDKUI });
@@ -228,7 +228,8 @@ async function start() {
228
228
  const host = document.createElement('div'); host.style.cssText = 'height:100vh;min-height:100vh';
229
229
  const shadow = host.attachShadow({ mode: 'open' });
230
230
  const styles = document.createElement('style'); styles.textContent = (snapshot.hostCss || '') + '\n' + snapshot.css; shadow.appendChild(styles);
231
- NotisSDKUI.adoptToolkitStyles(shadow);
231
+ // A Tailwind 3 Space keeps the toolkit unlayered, so its unlayered preflight does not reset toolkit pieces.
232
+ NotisSDKUI.adoptToolkitStyles(shadow, { cascade: NotisSDKUI.toolkitCascadeFor(snapshot.css) });
232
233
  const mount = document.createElement('div'); mount.style.cssText = 'height:100%;min-height:0'; shadow.appendChild(mount);
233
234
  document.body.appendChild(host);
234
235
  const controller = document.createElement('div'); document.body.appendChild(controller);
@@ -250,4 +251,6 @@ async function start() {
250
251
  onProtocolError={error => { if ((error as any)?.code === 'notis_sdk_query:actionUnavailable') return; state.blocked.push('render_read_only'); changed(); }}
251
252
  onCommit={mounted => { frame(); state.mounted = mounted; changed(); }} />);
252
253
  }
253
- void start().catch(() => { state.failed = true; });
254
+ // Why the view never started (most often its module did not load), for `spaces verify` to show; the render
255
+ // service never returns it.
256
+ void start().catch(error => { state.failed = true; state.failure = String(error?.message ?? error).slice(0, 300) || 'The view did not start.'; });
@@ -26,6 +26,8 @@ function publicSnapshot(snapshot) {
26
26
 
27
27
  const PNG_LIMIT = 32 * 1024 * 1024;
28
28
  const CAPTURE = { type: 'png', animations: 'disabled', caret: 'hide', scale: 'css' };
29
+ // Room a bounded ready wait leaves for the screenshot and the final authority check.
30
+ const CAPTURE_MARGIN_MS = 3000;
29
31
 
30
32
  /**
31
33
  * Chromium rasterizes everything a screenshot captures beyond the viewport, so a
@@ -89,12 +91,26 @@ async function capturePage(page, sliceHeight, maxBytes, maxHeight, maxPixels) {
89
91
  return stitcher.finish();
90
92
  }
91
93
 
94
+ function viewFailure(reason) {
95
+ const failure = new ViewRenderError('render_view_failed', "This view's code failed before it showed anything. Run notis spaces verify on its source to see why.", 422);
96
+ // What the browser said (a module that did not load), for `spaces verify` on the author's own source only: it is
97
+ // not enumerable, and the render service returns only the code.
98
+ if (reason) Object.defineProperty(failure, 'reason', { value: String(reason).slice(0, 300) });
99
+ return failure;
100
+ }
101
+
92
102
  function diagnosticFailure(error, stage, fallback = 'render_failed') {
93
103
  const failure = error instanceof ViewRenderError
94
104
  ? new ViewRenderError(error.code, error.message, error.status) : renderFailure(fallback);
95
105
  // Private in-process diagnostics only. Public JSON/error projections cannot
96
106
  // enumerate a browser exception, which may contain source or request data.
97
107
  Object.defineProperties(failure, { cause: { value: error }, stage: { value: stage } });
108
+ if (error instanceof ViewRenderError && error.reason) Object.defineProperty(failure, 'reason', { value: error.reason });
109
+ // A view that was not ready in time keeps the screenshot of what it showed, released after the final authority check.
110
+ if (error instanceof ViewRenderError && error.screenshot) {
111
+ Object.defineProperties(failure, { screenshot: { value: error.screenshot }, mounted: { value: error.mounted === true },
112
+ waitedSeconds: { value: error.waitedSeconds }, blocked: { value: Array.isArray(error.blocked) ? error.blocked : [] } });
113
+ }
98
114
  return failure;
99
115
  }
100
116
 
@@ -108,15 +124,26 @@ function diagnosticFailure(error, stage, fallback = 'render_failed') {
108
124
  * - `measure: { regions }` answers reads as usual and returns `skeleton_measure`, the bones measured inside each
109
125
  * region box before the page is expanded for a full-page capture.
110
126
  * - `locale` ('en' or 'fr') overrides the snapshot locale; `skeleton` is injected as `descriptor.context.skeleton`.
127
+ *
128
+ * `readyTimeoutMs`, shorter than the render timeout, bounds the wait for the view to finish loading its data (mounted,
129
+ * no read pending, quiet for 100 ms: the signal every capture waits for). A view still loading then fails with
130
+ * `render_not_ready`, carrying a viewport `screenshot` of what it showed (and whether it had `mounted`), released only
131
+ * after the final authority check, with the seconds it waited (`waitedSeconds`) and the calls it blocked (`blocked`).
132
+ * The wait also ends early enough to leave the capture room before the render timeout.
133
+ * Without it the wait runs to the render timeout, which fails with nothing captured.
111
134
  */
112
135
  export async function renderView({ broker, outputs, width, timeoutMs, signal, pool, host, maxHeight = 60000, maxPixels = 80000000, sliceHeight = 2048, maxPngBytes = PNG_LIMIT,
113
- pending = false, measure, locale, skeleton }) {
136
+ pending = false, measure, locale, skeleton, readyTimeoutMs }) {
114
137
  const config = inputs({ outputs, width, timeoutMs });
138
+ if (readyTimeoutMs !== undefined && (!Number.isInteger(readyTimeoutMs) || readyTimeoutMs < 1000 || readyTimeoutMs >= config.timeoutMs)) {
139
+ throw new TypeError('Bound the ready wait below the render timeout.');
140
+ }
115
141
  if (pending && measure) throw new TypeError('Choose a pending or a measuring render, not both.');
116
142
  if (locale !== undefined && !['en', 'fr'].includes(locale)) throw new TypeError('Override the locale with en or fr.');
117
143
  if (measure !== undefined && !Array.isArray(measure?.regions)) throw new TypeError('Measure a list of skeleton regions.');
118
144
  if (!Number.isInteger(sliceHeight) || sliceHeight < 256 || sliceHeight > 16384) throw new TypeError('Use a bounded screenshot slice height.');
119
145
  if (!Number.isInteger(maxPngBytes) || maxPngBytes < 1 || maxPngBytes > PNG_LIMIT) throw new TypeError('Use a PNG limit within the render transport limit.');
146
+ const deadlineAt = Date.now() + config.timeoutMs;
120
147
  const deadline = AbortSignal.timeout(config.timeoutMs);
121
148
  const cancellation = signal ? AbortSignal.any([signal, deadline]) : deadline;
122
149
  // Fail authorization before opening a browser or exposing cached page data.
@@ -219,7 +246,13 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
219
246
  Object.defineProperty(failure, 'cause', { value: transientFailure });
220
247
  throw failure;
221
248
  }
222
- if (authorityLost || cancellation.aborted || await page.evaluate(() => Boolean(window.__notisRenderState.failed))) {
249
+ const host = await page.evaluate(() => ({ failed: Boolean(window.__notisRenderState?.failed),
250
+ mounted: Boolean(window.__notisRenderState?.mounted), failure: String(window.__notisRenderState?.failure || '') }));
251
+ // The view's code did not start (a module that does not load, an import this host does not provide; the
252
+ // host records why in `failure`): rendering again cannot help, and it is not about access. A view that
253
+ // threw while rendering keeps the outcome it had, since that may depend on the data it read.
254
+ if (!authorityLost && !cancellation.aborted && host.failed && !host.mounted && host.failure) throw viewFailure(host.failure);
255
+ if (authorityLost || cancellation.aborted || host.failed) {
223
256
  const failure = renderFailure('render_access_changed');
224
257
  if (authorityFailure) Object.defineProperty(failure, 'cause', { value: authorityFailure });
225
258
  throw failure;
@@ -266,7 +299,33 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
266
299
  rendered_at: new Date().toISOString() };
267
300
  }
268
301
  stage = 'host_ready';
269
- await page.waitForFunction(() => window.__notisRenderState?.mounted && window.__notisRenderState.pending === 0 && performance.now() - window.__notisRenderState.lastActivity > 100, undefined, { timeout: config.timeoutMs });
302
+ const ready = () => window.__notisRenderState?.mounted && window.__notisRenderState.pending === 0 && performance.now() - window.__notisRenderState.lastActivity > 100;
303
+ // A view whose code did not start has nothing left to wait for: stop at once instead of waiting out the
304
+ // render timeout. Any other failure still waits for the reads in flight, whose outcome decides the error.
305
+ // (Each function runs in the page on its own, so this one cannot call ready.)
306
+ const readyOrFailed = () => Boolean(window.__notisRenderState?.failure) || (window.__notisRenderState?.mounted
307
+ && window.__notisRenderState.pending === 0 && performance.now() - window.__notisRenderState.lastActivity > 100);
308
+ // The bounded wait also leaves the capture and the final authority check room before the render deadline.
309
+ const readyWait = readyTimeoutMs === undefined ? config.timeoutMs
310
+ : Math.max(1, Math.min(readyTimeoutMs, deadlineAt - Date.now() - CAPTURE_MARGIN_MS));
311
+ const readyStarted = Date.now();
312
+ try {
313
+ await page.waitForFunction(readyOrFailed, undefined, { timeout: readyWait });
314
+ if (await page.evaluate(() => Boolean(window.__notisRenderState?.failure))) await complete();
315
+ }
316
+ catch (error) {
317
+ if (readyTimeoutMs === undefined || cancellation.aborted || error?.name !== 'TimeoutError') throw error;
318
+ stage = 'not_ready_capture';
319
+ const mounted = await page.evaluate(() => Boolean(window.__notisRenderState?.mounted));
320
+ const png = await page.screenshot(CAPTURE);
321
+ await complete();
322
+ const seconds = Math.max(1, Math.round((Date.now() - readyStarted) / 1000));
323
+ const failure = new ViewRenderError('render_not_ready', `This view had not finished loading its data after ${seconds} s.`, 504);
324
+ Object.defineProperties(failure, { mounted: { value: mounted }, waitedSeconds: { value: seconds }, blocked: { value: [...blocked] },
325
+ screenshot: { value: { mime_type: 'image/png', viewport_width: config.width,
326
+ data_base64: png.toString('base64'), width: png.readUInt32BE(16), height: png.readUInt32BE(20) } } });
327
+ throw failure;
328
+ }
270
329
  // A committed data response must settle React layout and browser fonts.
271
330
  stage = 'fonts_layout';
272
331
  await page.evaluate(async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notis_ai/cli",
3
- "version": "0.2.28",
3
+ "version": "0.2.30",
4
4
  "description": "Agent-first Notis CLI for Spaces, Skills and generic tool execution",
5
5
  "type": "module",
6
6
  "bin": {
@@ -52,8 +52,8 @@
52
52
  "react-dom": "19.3.0"
53
53
  },
54
54
  "notisRelease": {
55
- "sourceSha": "b30c41a5c3e0b065aaf9a0be08c918eea77be86d",
55
+ "sourceSha": "c85c7d62766a6561de18ec338247843d089cadae",
56
56
  "channel": "stable"
57
57
  },
58
- "gitHead": "b30c41a5c3e0b065aaf9a0be08c918eea77be86d"
58
+ "gitHead": "c85c7d62766a6561de18ec338247843d089cadae"
59
59
  }
@@ -37,7 +37,7 @@ Call these with `notis tools exec <TOOL>` (add `--get-schema` first when you nee
37
37
  },
38
38
  {
39
39
  "name": "LOCAL_NOTIS_SEARCH_THREADS",
40
- "description": "Find the current user's earlier conversations across channels, including voice calls. Search by title/latest inbound user-message preview and filter by channel, source, status, failure cause or date. A failed conversation has status 'failed' and names its saved cause in failure_cause. This is not full-transcript search: broaden a missed keyword query or list recent threads, then inspect likely matches with LOCAL_NOTIS_LOAD_CONVERSATION_HISTORY using the returned thread_id. Returns up to 50 summaries."
40
+ "description": "Find the current user's earlier conversations across channels, including voice calls. Search by title/latest inbound user-message preview and filter by channel, source, status, failure cause or date. A failed conversation has status 'failed' and names its saved cause in failure_cause. This is not full-transcript search: broaden a missed keyword query or list recent threads, then inspect likely matches with LOCAL_NOTIS_LOAD_CONVERSATION_HISTORY using the returned thread_id. summary_line is the last reply's bold opening line. Returns up to 50 summaries."
41
41
  },
42
42
  {
43
43
  "name": "LOCAL_NOTIS_SEARCH_MEMORIES",
@@ -86,6 +86,7 @@ Call these with `notis tools exec <TOOL>` (add `--get-schema` first when you nee
86
86
 
87
87
  - Cold discovery can exceed 30 seconds. Use `--timeout-ms 90000` for discovery calls when needed; after `network_timeout`, retry the exact command once with that timeout instead of looping.
88
88
  - Before writing a Notion or native database row, read the schema and relevant property descriptions.
89
+ - Before writing for the user (comments, rows), declare yourself once per session with a fresh lowercase imaginary rock-band name: `export NOTIS_AGENT_NAME="fred-and-the-machine"` (or `--agent-name`; lowercase letters and digits in at least two words joined by hyphens, 3 to 60 characters). The CLI keeps one id per name on this computer, so set `NOTIS_AGENT_ID` only to override it. Where the user has unified comments on, the write then shows your name, never reads as the user's own, and never wakes you, and a comment written through the CLI without a name is refused (`agent_name_required`); elsewhere the name is ignored.
89
90
  - When answering about meetings or availability, check every connected calendar.
90
91
  - Use `notis doctor` before concluding that authentication or API reachability is broken.
91
92
  - Keep credentials and other secrets out of tool arguments and search queries unless the target tool explicitly requires them.
@@ -261,8 +261,8 @@ Render one frozen Space with offline fixtures and validate its current action au
261
261
  When to use: Check immutable build bytes and authoring compatibility without executing actions or publishing.
262
262
 
263
263
  Options:
264
- - `--space <key>` — Exact source key from the workspace index.
265
- - `--space-id <id>` — Exact existing destination Space.
264
+ - `--space <key>` — Exact source key from the workspace index. Optional when the workspace holds one Space.
265
+ - `--space-id <id>` — Exact existing destination Space. Optional in a pulled workspace: the Space it was pulled from.
266
266
  - `--reuse-grants <json>` — Explicit action-key to saved-grant-ID map. Otherwise your own connections are used.
267
267
  - `--reuse-grants-only` — Never authorize new actions. Reuse only the supplied saved grants; other declarations remain unavailable. Requires existing bound databases.
268
268
 
@@ -276,8 +276,8 @@ Seal a checked unpublished revision of the same Space and return its authenticat
276
276
  When to use: Review a checked candidate using current Editor access without changing live source or cloning the Space.
277
277
 
278
278
  Options:
279
- - `--space <key>` — Exact source key from the workspace index.
280
- - `--space-id <id>` — Exact existing destination Space.
279
+ - `--space <key>` — Exact source key from the workspace index. Optional when the workspace holds one Space.
280
+ - `--space-id <id>` — Exact existing destination Space. Optional in a pulled workspace: the Space it was pulled from.
281
281
  - `--reuse-grants <json>` — Explicit action-key to saved-grant-ID map. Otherwise your own connections are used.
282
282
  - `--reuse-grants-only` — Never authorize new actions. Reuse only the supplied saved grants; other declarations remain unavailable. Requires existing bound databases.
283
283
  - `--request-id <key>` — Stable intent key. Reuse after timeouts or lost replies.
@@ -293,8 +293,8 @@ Publish one built Space with a retry-safe, independent source revision.
293
293
  When to use: Update only the selected existing Space; this does not publish to the Store or change siblings.
294
294
 
295
295
  Options:
296
- - `--space <key>` — Exact source key from the workspace index.
297
- - `--space-id <id>` — Exact existing destination Space.
296
+ - `--space <key>` — Exact source key from the workspace index. Optional when the workspace holds one Space.
297
+ - `--space-id <id>` — Exact existing destination Space. Optional in a pulled workspace: the Space it was pulled from.
298
298
  - `--reuse-grants <json>` — Explicit action-key to saved-grant-ID map. Otherwise your own connections are used.
299
299
  - `--reuse-grants-only` — Never authorize new actions. Reuse only the supplied saved grants; other declarations remain unavailable. Requires existing bound databases.
300
300
  - `--request-id <key>` — Stable intent key. Reuse after timeouts or lost replies.
@@ -528,7 +528,7 @@ Build one independent Space and save its frozen source/artifact snapshot.
528
528
  When to use: Prepare a selected Space for verification without publishing it or changing siblings.
529
529
 
530
530
  Options:
531
- - `--space <key>` — Exact source key from the workspace Space index.
531
+ - `--space <key>` — Exact source key from the workspace Space index. Optional when the workspace holds one Space.
532
532
 
533
533
  Examples:
534
534
  - `npx --package @notis_ai/cli@latest -- notis spaces build . --space overview`
@@ -540,7 +540,7 @@ Inspect one local Space definition and its declared capabilities.
540
540
  When to use: Read the selected source definition without loading sibling definitions or account resources.
541
541
 
542
542
  Options:
543
- - `--space <key>` — Exact source key from the workspace Space index.
543
+ - `--space <key>` — Exact source key from the workspace Space index. Optional when the workspace holds one Space.
544
544
 
545
545
  Examples:
546
546
  - `npx --package @notis_ai/cli@latest -- notis spaces inspect . --space overview`
package/src/cli.js CHANGED
@@ -23,6 +23,7 @@ import {
23
23
  resolveOutputMode,
24
24
  resolveRuntimeProfile,
25
25
  resolveWorktreeRuntime,
26
+ routingProfile,
26
27
  workspacePath,
27
28
  } from './runtime/profiles.js';
28
29
 
@@ -236,6 +237,11 @@ export function createProgram(launchContext = {}) {
236
237
  .option('--timeout-ms <n>', 'Time limit in milliseconds for each call, automatic retries included')
237
238
  .option('--idempotency-key <key>', 'Override the generated idempotency key for mutating commands')
238
239
  .option('--no-retry', 'Turn off automatic retries of interrupted calls that are safe to repeat (or set NOTIS_NO_RETRY=1)')
240
+ // Any agent using the CLI declares itself, so what it writes is its own (a comment's Author), not the person's.
241
+ // A comment written through the CLI needs the name (agent-identity.js).
242
+ .option('--agent-name <name>', 'The agent making this call, a lowercase band name such as fred-and-the-machine, shown as the Author of what it writes; required to write comments (or set NOTIS_AGENT_NAME)')
243
+ .option('--agent-id <id>', 'Override the id this computer keeps for the agent name (generated on first use) (or set NOTIS_AGENT_ID)')
244
+ .option('--agent-thread <thread>', 'The thread or session the agent runs in: a Notis thread id or link of yours gets the replies (or set NOTIS_AGENT_THREAD)')
239
245
  .addOption(new Option('--notis-managed-agent-hook').hideHelp());
240
246
 
241
247
  const parentMap = new Map([['', program]]);
@@ -283,7 +289,7 @@ export function channelProfileForArgs(
283
289
  const config = suppliedConfig || loadConfig();
284
290
  const explicitProfile = profileName || env.NOTIS_PROFILE;
285
291
  if (explicitProfile) {
286
- return getProfile(config, explicitProfile);
292
+ return routingProfile(getProfile(config, explicitProfile), env);
287
293
  }
288
294
  const resolvedWorktree = suppliedWorktreeRuntime === undefined
289
295
  ? resolveWorktreeRuntime()
@@ -299,7 +305,9 @@ export function channelProfileForArgs(
299
305
  }
300
306
  // NOTIS_JWT replaces the credential, not the route. Unless NOTIS_API_BASE
301
307
  // was explicit above, the selected/current profile still owns the channel.
302
- return getProfile(config, config.current_profile || DEFAULT_PROFILE);
308
+ // A signed-out profile's channel is a leftover (routingProfile): it runs on
309
+ // this build, and the next login pins the account's own channel.
310
+ return routingProfile(getProfile(config, config.current_profile || DEFAULT_PROFILE), env);
303
311
  }
304
312
 
305
313
  function interruptedExitCode(signal) {
@@ -173,8 +173,28 @@ const STATUS_LINES = {
173
173
  none: 'You have no Cloud Computer yet. It starts the first time Notis needs it.',
174
174
  };
175
175
 
176
+ // boat's own word (machine_state) on a live read while it starts or stops. The status only knows Notis's own work,
177
+ // so it reads "stopped" for a machine awake in its idle tail: boat's awake wins over that (bx_yaqe7sjj, 2026-11-12).
178
+ const MACHINE_LINES = {
179
+ starting: 'Your Cloud Computer is starting.',
180
+ stopping: 'Your Cloud Computer is finishing a stop. It starts again when Notis has work to do.',
181
+ };
182
+
183
+ const AWAKE_IDLE = 'Your Cloud Computer is awake, with nothing to do. It goes to sleep after its sleep time.';
184
+ const AWAKE_ALWAYS_ON = 'Your Cloud Computer is awake, with nothing to do. It stays on: always on is set.';
185
+
186
+ function liveLine(computer) {
187
+ if (computer.status === 'stopped' && computer.machine_state === 'awake') {
188
+ // sleep.after_seconds is null when always on: that machine never goes to sleep.
189
+ return computer.sleep && computer.sleep.after_seconds === null ? AWAKE_ALWAYS_ON : AWAKE_IDLE;
190
+ }
191
+ return ['running', 'stopped'].includes(computer.status) ? MACHINE_LINES[computer.machine_state] : null;
192
+ }
193
+
176
194
  function statusText(computer) {
177
- if (computer.status !== 'not_responding') return STATUS_LINES[computer.status] || STATUS_LINES.none;
195
+ if (computer.status !== 'not_responding') {
196
+ return liveLine(computer) || STATUS_LINES[computer.status] || STATUS_LINES.none;
197
+ }
178
198
  const reason = computer.status_reason ? ` Reason: ${computer.status_reason}.` : '';
179
199
  const saved = computer.last_saved_at ? ` Last saved ${computer.last_saved_at}.` : '';
180
200
  return `Your Cloud Computer is not responding.${reason}${saved} Restart it with: notis computer restart`;
@@ -1,4 +1,5 @@
1
1
  import { spawn } from 'node:child_process';
2
+ import { isLiveApiOrigin } from '../runtime/api-hosts.js';
2
3
  import { CHANNEL_SWITCH_ENV } from '../runtime/channel.js';
3
4
  import { CliError, EXIT_CODES } from '../runtime/errors.js';
4
5
  import { quoteShellArgument } from '../runtime/auth-recovery.js';
@@ -9,6 +10,8 @@ import {
9
10
  loadConfig,
10
11
  normalizeConfig,
11
12
  profileHasCredential,
13
+ oauthGrantOnRetiredAddress,
14
+ profileIsSignedIn,
12
15
  profileExists,
13
16
  resolveWorktreeRuntime,
14
17
  updateConfig,
@@ -116,8 +119,6 @@ async function listHandler(ctx) {
116
119
  });
117
120
  }
118
121
 
119
- const SKILL_SYNC_API_BASE_PATTERN = /^https:\/\/api(?:-beta)?\.notis\.ai\/?$/;
120
-
121
122
  // Overrides that belong to this `profile use` run. Inherited, a NOTIS_JWT would
122
123
  // sync its own account into the agent folders under the named profile.
123
124
  const RELINK_DROPPED_ENV = ['NOTIS_JWT', 'NOTIS_API_BASE', 'NOTIS_PROFILE', CHANNEL_SWITCH_ENV];
@@ -134,7 +135,10 @@ export function relinkSkillsInBackground(name, profile, {
134
135
  // Never from a test run: a detached sync would outlive it and reach the real API.
135
136
  if (env.NODE_ENV === 'test' || env.NODE_TEST_CONTEXT || !argv[1]) return false;
136
137
  if (!profile?.oauth_access_token && !profile?.oauth_refresh_token) return false;
137
- if (!SKILL_SYNC_API_BASE_PATTERN.test(String(profile.api_base || ''))) return false;
138
+ // A grant minted for a retired API name is signed out (CLI-038).
139
+ if (oauthGrantOnRetiredAddress(profile)) return false;
140
+ // Every live Notis API, nightly's current name included (CLI-039).
141
+ if (!isLiveApiOrigin(profile.api_base)) return false;
138
142
  // Like the automatic sync, the relink runs as the named profile alone: its
139
143
  // credential, its endpoint and the CLI build for its channel.
140
144
  const childEnv = { ...env };
@@ -171,7 +175,8 @@ async function useHandler(ctx) {
171
175
  const profile = getProfile(next, requested);
172
176
  const worktreeOverride = Boolean(worktreeRuntime);
173
177
  const worktreeBlocked = Boolean(worktreeUnavailable);
174
- const authenticated = profileHasCredential(profile);
178
+ // A dead grant (CLI-035) reads as signed out, as `profile list` shows it.
179
+ const authenticated = profileIsSignedIn(profile);
175
180
  if (authenticated) relinkSkillsInBackground(requested, profile);
176
181
 
177
182
  return ctx.output.emitSuccess({
@@ -193,7 +198,9 @@ async function useHandler(ctx) {
193
198
  ? `Saved profile "${requested}" as the default outside this worktree; this checkout still uses "${worktreeRuntime.profile}" unless --profile is explicit.`
194
199
  : authenticated
195
200
  ? `Switched to profile "${requested}".`
196
- : `Switched to profile "${requested}", which has no credential yet.`,
201
+ : profileHasCredential(profile)
202
+ ? `Switched to profile "${requested}", whose sign-in has ended; sign in again.`
203
+ : `Switched to profile "${requested}", which has no credential yet.`,
197
204
  hints: worktreeBlocked
198
205
  ? [
199
206
  {
@@ -1,5 +1,5 @@
1
1
  import { scaffoldSpaceCollection } from '../runtime/space-collection-scaffold.js';
2
- import { appFilesDigest, pullAppSource, resolveProjectDir, saveSpacePendingScreenshots, saveSpaceVerification, spacePublicationIntent, syncSpaceSdk } from '../runtime/app-platform.js';
2
+ import { appFilesDigest, clearSpaceScreenshots, loadAppConfig, pullAppSource, resolveProjectDir, saveSpacePendingScreenshots, saveSpaceScreenshots, saveSpaceVerification, spacePublicationIntent, syncSpaceSdk } from '../runtime/app-platform.js';
3
3
  import { buildSpaceArtifact, prepareSpaceRelease, requireSpaceIcon } from '../runtime/space-platform.js';
4
4
  import { verifySpaceRelease } from '../runtime/space-verification.js';
5
5
  import { loadSelectedSpace } from '../runtime/space-source.js';
@@ -16,10 +16,24 @@ import { unifiedDiffSummary, versionName } from './version-history.js';
16
16
  import { createHash } from 'node:crypto';
17
17
  import { viewRenderCommandSpec } from './views.js';
18
18
 
19
- function selected(ctx) {
20
- if (!ctx.options.space) throw usageError('Choose the independent Space with --space <key>.');
19
+ async function selected(ctx) {
21
20
  // build, verify, preview, deploy and inspect write or stage inside this folder.
22
- return { directory: assertSourceRoot(resolveProjectDir(ctx.args.dir || '.')), key: ctx.options.space };
21
+ const directory = assertSourceRoot(resolveProjectDir(ctx.args.dir || '.'));
22
+ if (ctx.options.space) return { directory, key: ctx.options.space };
23
+ // A folder that holds one Space (a pulled Space always does) needs no --space.
24
+ const workspace = await loadAppConfig(directory);
25
+ const keys = workspace && typeof workspace.spaces === 'object' && workspace.spaces ? Object.keys(workspace.spaces) : [];
26
+ if (keys.length === 1) return { directory, key: keys[0] };
27
+ throw usageError(keys.length ? `Choose the Space with --space <key>: this workspace declares ${keys.join(', ')}.`
28
+ : 'Choose the independent Space with --space <key>.');
29
+ }
30
+
31
+ /** --space-id, else the Space this folder was pulled from on the same API (its lock file). */
32
+ function destinationSpaceId(ctx, directory) {
33
+ if (ctx.options.spaceId) return ctx.options.spaceId;
34
+ const lock = readSpaceLock(directory);
35
+ if (lock && lock.api_base === ctx.runtime.apiBase.replace(/\/$/, '')) return lock.space_id;
36
+ throw usageError('Pass --space-id <id> for the existing Space.');
23
37
  }
24
38
 
25
39
  function requestId(ctx) {
@@ -131,10 +145,22 @@ function describePendingChanges(summary) {
131
145
 
132
146
  const SKELETON_FILE = 'bundle/skeleton.json';
133
147
 
148
+ /** Reviewable: where the screenshots of the loaded view are, and each width that had not finished loading its data. */
149
+ function describeScreenshots(render) {
150
+ const renders = render?.renders || [];
151
+ const paths = renders.filter(value => value.loaded && value.screenshot_path).map(value => value.screenshot_path);
152
+ const parts = paths.length ? [`Screenshots after the data loaded: ${paths.join(', ')}.`] : [];
153
+ for (const value of renders.filter(item => item.loaded === false)) {
154
+ const message = value.message;
155
+ if (message) parts.push(value.screenshot_path ? `${message.replace(/\.$/, '')}; ${value.screenshot_path} shows what it showed then.` : message);
156
+ }
157
+ return parts.length ? ` ${parts.join(' ')}` : '';
158
+ }
159
+
134
160
  /** Reviewable: the measured loading skeleton, its warnings and where the loading screenshots are. */
135
161
  function describeSkeleton(skeleton) {
136
162
  if (!skeleton) return '';
137
- const parts = [skeleton.status === 'captured' ? `Loading skeleton measured for ${skeleton.regions.join(', ')}.`
163
+ const parts = [skeleton.status === 'captured' ? `Loading skeleton measured for ${skeleton.regions.join(', ')}${skeleton.audience === 'public' ? ', as the public sees the view' : ''}.`
138
164
  : skeleton.status === 'failed' ? 'The loading skeleton could not be measured; the view keeps its fallback skeleton.' : ''];
139
165
  const findings = skeleton.findings || [];
140
166
  if (findings.length) {
@@ -156,17 +182,20 @@ function sameVerification(verification, body, sourceDigest) {
156
182
  }
157
183
 
158
184
  async function sourceRelease(ctx, publish, stageOnly = false) {
159
- const { directory, key } = selected(ctx);
160
- if (!ctx.options.spaceId) throw usageError('Pass --space-id <id> for the existing Space.');
185
+ const { directory, key } = await selected(ctx);
186
+ const spaceId = destinationSpaceId(ctx, directory);
161
187
  const intentKey = publish ? requestId(ctx) : null;
188
+ // A verify that stops at any point (a build older than its source, a refused source check, a cancelled render), or
189
+ // a release without a loading skeleton, leaves no image of an older build.
190
+ clearSpaceScreenshots(directory, key);
162
191
  const release = await prepareSpaceRelease(directory, key);
163
192
  try {
164
193
  if (publish) requireSpaceIcon(release.manifest, key);
165
- const identity = [ctx.runtime.apiBase.replace(/\/$/, ''), ctx.runtime.profileName, key, ctx.options.spaceId, intentKey];
194
+ const identity = [ctx.runtime.apiBase.replace(/\/$/, ''), ctx.runtime.profileName, key, spaceId, intentKey];
166
195
  let verification = publish && !ctx.options.dryRun ? spacePublicationIntent(directory, identity) : null;
167
- const local = intentChanges(directory, ctx.options.spaceId, release.manifest,
168
- localSpaceChanges(directory, ctx.options.spaceId, release.manifest), verification);
169
- const body = { space_id: ctx.options.spaceId, manifest: release.manifest, source_files: release.sourceFiles,
196
+ const local = intentChanges(directory, spaceId, release.manifest,
197
+ localSpaceChanges(directory, spaceId, release.manifest), verification);
198
+ const body = { space_id: spaceId, manifest: release.manifest, source_files: release.sourceFiles,
170
199
  artifact_files: release.files, reuse_grants: object(ctx.options.reuseGrants || '{}', '--reuse-grants'),
171
200
  ...(ctx.options.reuseGrantsOnly ? { authorization_mode: 'reuse_only' } : {}),
172
201
  ...(local.changes ? { changes: local.changes } : {}) };
@@ -196,14 +225,19 @@ async function sourceRelease(ctx, publish, stageOnly = false) {
196
225
  // Test seam only: the command context never carries it from user options.
197
226
  ...(typeof ctx.loadSpaceRenderer === 'function' ? { loadRenderer: ctx.loadSpaceRenderer } : {}) }); }
198
227
  finally { process.removeListener('SIGINT', cancel); process.removeListener('SIGTERM', cancel); }
228
+ const saved = saveSpaceScreenshots(directory, key, render.screenshots || []);
229
+ if (render.renders) render.renders = render.renders.map(value => {
230
+ const path = saved.find(item => item.width === value.width)?.path;
231
+ return path ? { ...value, screenshot_path: path } : value;
232
+ });
199
233
  if (render.skeleton) {
200
- const paths = saveSpacePendingScreenshots(directory, render.pendingScreenshots || []);
234
+ const paths = saveSpacePendingScreenshots(directory, key, render.pendingScreenshots || []);
201
235
  render.skeleton.pending_screenshots = render.skeleton.pending_screenshots.map((value, index) => ({ ...value, ...(paths[index] ? { path: paths[index] } : {}) }));
202
236
  }
203
237
  const diagnosticPath = saveSpaceVerification(directory, { ...render, space_id: body.space_id });
204
238
  if (!['passed', 'not_applicable_container'].includes(render.status)) {
205
239
  const reason = render.errors?.find(value => value.phase === 'fixture')?.message;
206
- throw usageError(`The built Space did not pass offline render verification. Nothing was published.${reason ? ` ${reason}` : ''}`,
240
+ throw usageError(`The built Space did not pass offline render verification. Nothing was published.${reason ? ` ${reason}` : ''}${describeScreenshots(render)}`,
207
241
  { render, diagnostic_path: diagnosticPath });
208
242
  }
209
243
  // The measured skeleton joins the release in memory, replacing any file at its path; nothing is written to disk.
@@ -246,12 +280,12 @@ async function sourceRelease(ctx, publish, stageOnly = false) {
246
280
  : serverVerification;
247
281
  if (publish && !ctx.options.dryRun && !stageOnly) recordPublication(directory, local, result);
248
282
  const data = { ...result, render, diagnostic_path: diagnosticPath, ...(local.summary ? { local_changes: local.summary } : {}) };
249
- const skeletonSummary = describeSkeleton(render.skeleton);
283
+ const skeletonSummary = describeSkeleton(render.skeleton), screenshotSummary = describeScreenshots(render);
250
284
  return ctx.output.emitSuccess({ command: ctx.spec.command_path.join(' '), data,
251
285
  humanSummary: publish && !ctx.options.dryRun
252
- ? stageOnly ? `Prepared ${key} as revision ${result.candidate_revision}. ${result.preview_url || 'This container has no executable preview.'} Live source was not changed.${describePendingChanges(local.summary).replace(/\.$/, '; they go live with notis spaces promote.')}`
253
- : `Published ${key} as revision ${result.published_revision}${result.replayed ? ' (confirmed retry)' : ''}.${describeAppliedChanges(result)}${describeViewerReads(serverVerification.capabilities)}${describeCloudComputer(serverVerification.capabilities)}${skeletonSummary}`
254
- : `Verified ${key}'s frozen source${render.status === 'passed' ? ', rendered fixtures' : ' (container)'} and current authorizations; nothing was published.${describePendingChanges(local.summary)}${describeViewerReads(serverVerification.capabilities)}${describeCloudComputer(serverVerification.capabilities)}${skeletonSummary}`,
286
+ ? stageOnly ? `Prepared ${key} as revision ${result.candidate_revision}. ${result.preview_url || 'This container has no executable preview.'} Live source was not changed.${describePendingChanges(local.summary).replace(/\.$/, '; they go live with notis spaces promote.')}${screenshotSummary}`
287
+ : `Published ${key} as revision ${result.published_revision}${result.replayed ? ' (confirmed retry)' : ''}.${describeAppliedChanges(result)}${describeViewerReads(serverVerification.capabilities)}${describeCloudComputer(serverVerification.capabilities)}${screenshotSummary}${skeletonSummary}`
288
+ : `Verified ${key}'s frozen source${render.status === 'passed' ? ', rendered fixtures' : ' (container)'} and current authorizations; nothing was published.${describePendingChanges(local.summary)}${describeViewerReads(serverVerification.capabilities)}${describeCloudComputer(serverVerification.capabilities)}${screenshotSummary}${skeletonSummary}`,
255
289
  warnings: skeletonWarnings.length ? [...(local.warnings || []), ...skeletonWarnings] : local.warnings, meta: { mutating: publish && !ctx.options.dryRun } });
256
290
  } finally { release.close(); }
257
291
  }
@@ -671,8 +705,8 @@ export const spacesCommandSpecs = [
671
705
  : operation === 'preview' ? 'Review a checked candidate using current Editor access without changing live source or cloning the Space.'
672
706
  : 'Update only the selected existing Space; this does not publish to the Store or change siblings.',
673
707
  args_schema: { arguments: [{ token: '[dir]', key: 'dir', description: 'Source workspace (default current directory).' }],
674
- options: [{ flags: '--space <key>', description: 'Exact source key from the workspace index.' },
675
- { flags: '--space-id <id>', description: 'Exact existing destination Space.' },
708
+ options: [{ flags: '--space <key>', description: 'Exact source key from the workspace index. Optional when the workspace holds one Space.' },
709
+ { flags: '--space-id <id>', description: 'Exact existing destination Space. Optional in a pulled workspace: the Space it was pulled from.' },
676
710
  { flags: '--reuse-grants <json>', description: 'Explicit action-key to saved-grant-ID map. Otherwise your own connections are used.' },
677
711
  { flags: '--reuse-grants-only', description: 'Never authorize new actions. Reuse only the supplied saved grants; other declarations remain unavailable. Requires existing bound databases.' },
678
712
  ...(operation !== 'verify' ? [requestOption, { flags: '--dry-run', description: 'Validate without uploading or publishing.' }] : [])] },
@@ -886,12 +920,12 @@ export const spacesCommandSpecs = [
886
920
  summary: 'Build one independent Space and save its frozen source/artifact snapshot.',
887
921
  when_to_use: 'Prepare a selected Space for verification without publishing it or changing siblings.',
888
922
  args_schema: { arguments: [{ token: '[dir]', key: 'dir', description: 'Source workspace (default current directory).' }],
889
- options: [{ flags: '--space <key>', description: 'Exact source key from the workspace Space index.' }] },
923
+ options: [{ flags: '--space <key>', description: 'Exact source key from the workspace Space index. Optional when the workspace holds one Space.' }] },
890
924
  examples: ['notis spaces build . --space overview'],
891
925
  mutates: true, idempotent: true, require_auth: false,
892
926
  backend_call: { type: 'local', name: 'space_build' },
893
927
  async handler(ctx) {
894
- const { directory, key } = selected(ctx);
928
+ const { directory, key } = await selected(ctx);
895
929
  const result = await buildSpaceArtifact(directory, key, { stdio: ctx.output.isMachineMode() ? 'pipe' : 'inherit' });
896
930
  return ctx.output.emitSuccess({ command: 'spaces build', data: result, humanSummary: `Built ${key}; no Space was published.` });
897
931
  },
@@ -901,12 +935,12 @@ export const spacesCommandSpecs = [
901
935
  summary: 'Inspect one local Space definition and its declared capabilities.',
902
936
  when_to_use: 'Read the selected source definition without loading sibling definitions or account resources.',
903
937
  args_schema: { arguments: [{ token: '[dir]', key: 'dir', description: 'Source workspace (default current directory).' }],
904
- options: [{ flags: '--space <key>', description: 'Exact source key from the workspace Space index.' }] },
938
+ options: [{ flags: '--space <key>', description: 'Exact source key from the workspace Space index. Optional when the workspace holds one Space.' }] },
905
939
  examples: ['notis spaces inspect . --space overview'],
906
940
  mutates: false, idempotent: true, require_auth: false,
907
941
  backend_call: { type: 'local', name: 'space_source_inspect' },
908
942
  async handler(ctx) {
909
- const { directory, key } = selected(ctx);
943
+ const { directory, key } = await selected(ctx);
910
944
  const selection = await loadSelectedSpace(directory, key);
911
945
  return ctx.output.emitSuccess({ command: 'spaces inspect', data: { key, definition: selection.definition, definition_path: selection.definitionPath },
912
946
  humanSummary: `${selection.definition.name} (${key})` });
@@ -201,7 +201,7 @@ export function classifyToolMutation(toolName, args = {}) {
201
201
  const normalized = localNotisToolSlug(toolName).toUpperCase();
202
202
  if (normalized === 'LOCAL_NOTIS_SANDBOX_PREVIEW') {
203
203
  if (args.action === 'status') return false;
204
- if (['register', 'open', 'heartbeat', 'stop'].includes(args.action)) return true;
204
+ if (['register', 'open', 'heartbeat', 'stop', 'delete'].includes(args.action)) return true;
205
205
  return null;
206
206
  }
207
207
  if (normalized.includes('EXECUTE_SQL') && typeof args.query === 'string') {