@notis_ai/cli 0.2.30 → 0.2.31

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 (78) hide show
  1. package/README.md +1 -0
  2. package/dist/agent-hooks/notis-agent-hook.mjs +37890 -10794
  3. package/dist/base-skills/notis-cli/.notis-base-skill.json +1 -1
  4. package/dist/base-skills/notis-cli/references/native-databases.md +1 -1
  5. package/dist/base-skills/notis-query/.notis-base-skill.json +1 -1
  6. package/dist/base-skills/notis-query/references/query.md +6 -4
  7. package/dist/base-skills/notis-spaces/.notis-base-skill.json +1 -1
  8. package/dist/base-skills/notis-spaces/SKILL.md +8 -3
  9. package/dist/base-skills/notis-spaces/references/architecture.md +4 -1
  10. package/dist/base-skills/notis-spaces/references/design.md +7 -1
  11. package/dist/base-skills/notis-spaces/references/fixtures.md +27 -2
  12. package/dist/base-skills/notis-spaces/references/sdk.md +90 -31
  13. package/dist/base-skills/notis-spaces/references/troubleshooting.md +3 -0
  14. package/dist/base-skills/notis-spaces/references/views.md +20 -0
  15. package/dist/sdk/src/hooks/useNativeDocuments.ts +50 -12
  16. package/dist/sdk/src/index.ts +1 -1
  17. package/dist/sdk/src/space.ts +3 -1
  18. package/dist/sdk/src/tailwind.ts +53 -3
  19. package/dist/sdk/src/ui/icons.tsx +1 -0
  20. package/dist/sdk/src/words/types.ts +28 -0
  21. package/dist/skill-sync/index.js +10 -90
  22. package/dist/skill-sync-worker.mjs +50 -93
  23. package/dist/space-harness/host.js +150 -81
  24. package/dist/space-sdk/dist/chunk-3DFOGU26.js +3 -0
  25. package/dist/space-sdk/dist/index.js +2 -2
  26. package/dist/space-sdk/dist/ui.js +12 -12
  27. package/dist/space-sdk/src/hooks/useNativeDocuments.d.ts +23 -0
  28. package/dist/space-sdk/src/index.d.ts +1 -1
  29. package/dist/space-sdk/src/space.ts +3 -1
  30. package/dist/space-sdk/src/tailwind-candidates.d.ts +273 -2
  31. package/dist/space-sdk/src/tailwind.ts +53 -3
  32. package/dist/space-sdk/src/ui/blocks/DataTable.d.ts +19 -4
  33. package/dist/space-sdk/src/ui/blocks/Meter.d.ts +12 -3
  34. package/dist/space-sdk/src/ui/blocks/Tabs.d.ts +7 -1
  35. package/dist/space-sdk/src/ui/blocks/index.d.ts +1 -1
  36. package/dist/space-sdk/src/ui/charts/CalendarHeatmap.d.ts +69 -0
  37. package/dist/space-sdk/src/ui/charts/Chart.d.ts +18 -3
  38. package/dist/space-sdk/src/ui/charts/chartData.d.ts +19 -0
  39. package/dist/space-sdk/src/ui/charts/heatmapData.d.ts +81 -0
  40. package/dist/space-sdk/src/ui/index.d.ts +4 -2
  41. package/dist/space-sdk/src/ui/list/Row.d.ts +11 -1
  42. package/dist/space-sdk/src/ui/period/dateFormat.d.ts +2 -0
  43. package/dist/space-sdk/src/ui/period/dateWords.d.ts +9 -0
  44. package/dist/space-sdk/src/ui/period/periods.d.ts +15 -2
  45. package/dist/space-sdk/src/words/types.ts +28 -0
  46. package/dist/view-renderer/dist/host.js +219 -150
  47. package/dist/view-renderer/src/dom.js +3 -2
  48. package/dist/view-renderer/src/errors.js +9 -0
  49. package/dist/view-renderer/src/host.tsx +12 -5
  50. package/dist/view-renderer/src/remote-broker.js +3 -1
  51. package/dist/view-renderer/src/renderer.js +63 -16
  52. package/dist/view-renderer/src/skeleton.js +70 -18
  53. package/package.json +5 -4
  54. package/skills/notis-query/cli.md +3 -0
  55. package/src/command-specs/spaces.js +71 -15
  56. package/src/command-specs/tools.js +3 -0
  57. package/src/runtime/api-hosts.generated.js +35 -0
  58. package/src/runtime/api-hosts.js +27 -10
  59. package/src/runtime/app-platform.js +68 -24
  60. package/src/runtime/http-agent.js +53 -0
  61. package/src/runtime/native-record-files.js +11 -0
  62. package/src/runtime/oauth.js +2 -1
  63. package/src/runtime/skill-sync/cloud-client.ts +0 -10
  64. package/src/runtime/skill-sync/index.ts +13 -15
  65. package/src/runtime/skill-sync/local-scanner.ts +0 -67
  66. package/src/runtime/skill-sync/types.ts +1 -0
  67. package/src/runtime/skill-sync/write-cloud-skill.ts +7 -23
  68. package/src/runtime/space-dependencies.js +66 -0
  69. package/src/runtime/space-fixture-broker.js +23 -8
  70. package/src/runtime/space-platform.js +47 -3
  71. package/src/runtime/space-source.js +10 -1
  72. package/src/runtime/space-test-server.js +105 -6
  73. package/src/runtime/space-verification.js +103 -43
  74. package/src/runtime/space-view-manifest.js +38 -5
  75. package/src/runtime/transport.js +19 -4
  76. package/src/runtime/view-render.js +4 -1
  77. package/template/tailwind.config.ts +2 -35
  78. package/dist/space-sdk/dist/chunk-6GJ2BS7B.js +0 -3
@@ -218,8 +218,9 @@ export async function settleFrameImages() {
218
218
  if (element.shadowRoot) collect(element.shadowRoot);
219
219
  } };
220
220
  collect(document);
221
+ // The addresses of the images that could not load; none when every image decoded.
221
222
  return (await Promise.all(images.map(async image => {
222
223
  image.loading = 'eager';
223
- try { await image.decode(); return true; } catch { return false; }
224
- }))).every(Boolean);
224
+ try { await image.decode(); return null; } catch { return image.currentSrc || image.src || ''; }
225
+ }))).filter(value => value !== null).slice(0, 20);
225
226
  }
@@ -1,6 +1,15 @@
1
1
  export class ViewRenderError extends Error {
2
2
  constructor(code, message, status = 409) { super(message); this.name = 'ViewRenderError'; this.code = code; this.status = status; }
3
3
  }
4
+ // A declared provider read the backend refused, with what clears it: never page content or provider text.
5
+ const REASON = /^[a-z_]{1,40}$/, ACTION = /^[A-Za-z0-9_-]{1,100}$/;
6
+ export function readRefusal(result, status) {
7
+ const error = new ViewRenderError('render_read_unavailable', typeof result?.message === 'string' && result.message.length <= 600
8
+ ? result.message : 'A declared read could not be confirmed, so the render stopped before showing its data.', status);
9
+ if (typeof result?.reason === 'string' && REASON.test(result.reason)) error.reason = result.reason;
10
+ if (typeof result?.action_id === 'string' && ACTION.test(result.action_id)) error.actionId = result.action_id;
11
+ return error;
12
+ }
4
13
  export function renderFailure(code = 'render_failed') {
5
14
  // Browser/source errors may contain private content. Never return them before
6
15
  // final authority revalidation, or log tokens/source/request arguments.
@@ -88,7 +88,9 @@ function ReadOnlyBlocks({ blocks }) {
88
88
  }
89
89
  function DocumentEditor({ recordKey, variant = 'full', showProperties = true, className }) {
90
90
  const loaded = useRead({ operation: 'record', record_key: recordKey });
91
- if (!loaded.value) return <div role="status">{text(loaded.failed ? 'unavailable' : 'opening')}</div>;
91
+ // While the record loads, the SDK's page skeleton, as for DocumentPage below.
92
+ if (!loaded.value) return loaded.failed ? <div role="status">{text('unavailable')}</div>
93
+ : <NotisSDK.DocumentPageSkeleton className={className} />;
92
94
  const value = loaded.value;
93
95
  if (value.document?.view_type === 'html') return <HtmlFrame recordKey={recordKey} className={className} />;
94
96
  if (value.document?.view_type === 'report') return <ReportFrame recordKey={recordKey} className={className} />;
@@ -103,9 +105,12 @@ function DocumentPage(props) {
103
105
  ? <HtmlFrame recordKey={props.recordKey} className={props.className} />
104
106
  : <RecordDocumentPage {...props} />;
105
107
  }
106
- function RecordDocumentPage({ recordKey, className, header, meta, properties, aboveBody, belowBody, layout }) {
108
+ function RecordDocumentPage({ recordKey, className, header, meta, properties, aboveBody, belowBody, layout, width }) {
107
109
  const loaded = useRead({ operation: 'record', record_key: recordKey });
108
- if (!loaded.value) return <div role="status">{text(loaded.failed ? 'unavailable' : 'opening')}</div>;
110
+ // While the record loads the page shows the SDK's DocumentPageSkeleton, as the Portal's page does, so a loading
111
+ // capture of an opened item shows the reader's real loading state.
112
+ if (!loaded.value) return loaded.failed ? <div role="status">{text('unavailable')}</div>
113
+ : <NotisSDK.DocumentPageSkeleton width={width} className={className} />;
109
114
  const value = loaded.value;
110
115
  if (value.document?.view_type === 'html') return <HtmlFrame recordKey={recordKey} className={className} />;
111
116
  if (value.document?.view_type === 'report') return <ReportFrame recordKey={recordKey} className={className} />;
@@ -170,11 +175,13 @@ async function start() {
170
175
  locale = snapshot.locale || 'en';
171
176
  document.documentElement.lang = locale;
172
177
  const authority = structuredClone(snapshot.descriptor.space);
178
+ // The descriptor's params are the audience's own: viewed as the public, its editor-only params are gone.
179
+ const params = snapshot.descriptor.context?.params ?? snapshot.params ?? {};
173
180
  const shown = {};
174
181
  let activeMarkdown: string | null = null;
175
182
  const runtime = {
176
183
  ...snapshot.descriptor, databases: [], queryClient: createQueryClient({ maxEntries: 100 }),
177
- context: { ...snapshot.descriptor.context, locale, params: Object.fromEntries(Object.entries(snapshot.params || {}).map(([key, value]) => [key, String(value)])), renderReadOnly: true },
184
+ context: { ...snapshot.descriptor.context, locale, params: Object.fromEntries(Object.entries(params).map(([key, value]) => [key, String(value)])), renderReadOnly: true },
178
185
  listTools: denied, callTool: denied, request: denied,
179
186
  // A view-params change only moves this render's own URL (a list opening its first item), never a write.
180
187
  navigate: target => (target?.kind === 'view-params' ? Promise.resolve() : denied()),
@@ -215,7 +222,7 @@ async function start() {
215
222
  Object.assign(window, { __notisRenderMarkdown: async () => {
216
223
  if (snapshot.markdownExport) {
217
224
  if (typeof module[snapshot.markdownExport] !== 'function') throw new Error('The declared Markdown export is unavailable.');
218
- return await (module[snapshot.markdownExport] as any)({ params: snapshot.params, shown });
225
+ return await (module[snapshot.markdownExport] as any)({ params, shown });
219
226
  }
220
227
  return activeMarkdown;
221
228
  } });
@@ -1,4 +1,4 @@
1
- import { ViewRenderError } from './errors.js';
1
+ import { ViewRenderError, readRefusal } from './errors.js';
2
2
 
3
3
  /** The purpose credential never enters request URLs, browser headers or source. */
4
4
  export function createRemoteRenderBroker({ apiBase, credential, fetcher = fetch }) {
@@ -24,6 +24,8 @@ export function createRemoteRenderBroker({ apiBase, credential, fetcher = fetch
24
24
  body: JSON.stringify(body) });
25
25
  let result;
26
26
  try { result = await response.json(); } catch { throw new ViewRenderError('render_broker_unavailable', 'The render read could not be confirmed.', 503); }
27
+ // A refused declared read keeps the backend's fixed explanation of what clears it (render_read_unavailable).
28
+ if (!response.ok && result?.error === 'render_read_unavailable' && response.status === 409) throw readRefusal(result, response.status);
27
29
  if (!response.ok) throw new ViewRenderError(typeof result?.error === 'string' ? result.error : 'render_unavailable', 'This view is unavailable for rendering.', response.status);
28
30
  return result;
29
31
  }
@@ -106,6 +106,8 @@ function diagnosticFailure(error, stage, fallback = 'render_failed') {
106
106
  // enumerate a browser exception, which may contain source or request data.
107
107
  Object.defineProperties(failure, { cause: { value: error }, stage: { value: stage } });
108
108
  if (error instanceof ViewRenderError && error.reason) Object.defineProperty(failure, 'reason', { value: error.reason });
109
+ if (error instanceof ViewRenderError && error.actionId) Object.defineProperty(failure, 'actionId', { value: error.actionId });
110
+ if (error instanceof ViewRenderError && !error.screenshot && Array.isArray(error.blocked)) Object.defineProperty(failure, 'blocked', { value: error.blocked });
109
111
  // A view that was not ready in time keeps the screenshot of what it showed, released after the final authority check.
110
112
  if (error instanceof ViewRenderError && error.screenshot) {
111
113
  Object.defineProperties(failure, { screenshot: { value: error.screenshot }, mounted: { value: error.mounted === true },
@@ -121,8 +123,11 @@ function diagnosticFailure(error, stage, fallback = 'render_failed') {
121
123
  * - `pending: true` holds every `/__read` until the render ends, waits until the view is mounted with a read
122
124
  * pending and its DOM is quiet for 300 ms, and returns `pending` (the loading-state probe) and a viewport
123
125
  * `screenshot` instead of the usual outputs. A view that never reads is reported as `pending.static`.
124
- * - `measure: { regions }` answers reads as usual and returns `skeleton_measure`, the bones measured inside each
125
- * region box before the page is expanded for a full-page capture.
126
+ * `pending: { hold: ['record', ...] }` holds only those read operations and answers the others, so a list loads
127
+ * and the item it opens stays loading (the reader's loading state); a view that never sends one is static.
128
+ * - `measure: { regions, landmarks? }` answers reads as usual and returns `skeleton_measure`, the bones measured inside
129
+ * each region box before the page is expanded for a full-page capture. `landmarks`, the pending pass's, end a region
130
+ * box at the next landmark below it in its column.
126
131
  * - `locale` ('en' or 'fr') overrides the snapshot locale; `skeleton` is injected as `descriptor.context.skeleton`.
127
132
  *
128
133
  * `readyTimeoutMs`, shorter than the render timeout, bounds the wait for the view to finish loading its data (mounted,
@@ -139,6 +144,10 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
139
144
  throw new TypeError('Bound the ready wait below the render timeout.');
140
145
  }
141
146
  if (pending && measure) throw new TypeError('Choose a pending or a measuring render, not both.');
147
+ if (pending !== false && pending !== true && !(pending && Array.isArray(pending.hold) && pending.hold.length
148
+ && pending.hold.every(operation => READ_OPERATIONS.has(operation)))) throw new TypeError('Hold every read or a list of read operations.');
149
+ // The read operations a pending render holds; null holds every read.
150
+ const holding = pending === true ? null : pending ? new Set(pending.hold) : undefined;
142
151
  if (locale !== undefined && !['en', 'fr'].includes(locale)) throw new TypeError('Override the locale with en or fr.');
143
152
  if (measure !== undefined && !Array.isArray(measure?.regions)) throw new TypeError('Measure a list of skeleton regions.');
144
153
  if (!Number.isInteger(sliceHeight) || sliceHeight < 256 || sliceHeight > 16384) throw new TypeError('Use a bounded screenshot slice height.');
@@ -170,11 +179,21 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
170
179
  const ownPool = !pool;
171
180
  pool ||= createBrowserPool();
172
181
  const blocked = [];
173
- let authorityLost = false, authorityFailure, transientFailure, assetRequests = 0, assetBytes = 0, readRequests = 0;
182
+ let authorityLost = false, authorityFailure, transientFailure, readRefused, assetRequests = 0, assetBytes = 0, readRequests = 0, heldReads = 0;
174
183
  let stage = 'browser_context';
175
184
  let assetOrigin = null;
176
185
  try { const asset = new URL(snapshot.asset_origin); if (asset.protocol === 'https:' && asset.origin === snapshot.asset_origin) assetOrigin = asset.origin; } catch {}
177
- const policy = assetOrigin ? CSP.replace("img-src 'self' data: blob:", "img-src 'self' data: blob: " + assetOrigin).replace("font-src 'self' data:", "font-src 'self' data: " + assetOrigin) : CSP;
186
+ // Offline fixtures name the exact image URLs they provide (a meal photo, a cover); the broker serves their bytes.
187
+ const assetImages = new Set((Array.isArray(snapshot.asset_images) ? snapshot.asset_images : []).slice(0, 32).filter(value => {
188
+ try { const image = new URL(value); return image.protocol === 'https:' && image.href === value && !image.hash; } catch { return false; }
189
+ }));
190
+ // Each fixture image is allowed by its own path (a CSP source has no query); a path CSP cannot write falls back to its site.
191
+ const imageSources = [...new Set([assetOrigin, ...[...assetImages].map(value => {
192
+ const url = new URL(value);
193
+ return /[;,'\s]/.test(url.pathname) ? url.origin : url.origin + url.pathname;
194
+ })].filter(Boolean))];
195
+ let policy = imageSources.length ? CSP.replace("img-src 'self' data: blob:", "img-src 'self' data: blob: " + imageSources.join(' ')) : CSP;
196
+ if (assetOrigin) policy = policy.replace("font-src 'self' data:", "font-src 'self' data: " + assetOrigin);
178
197
  try {
179
198
  return await pool.use(async context => {
180
199
  stage = 'browser_setup';
@@ -194,15 +213,18 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
194
213
  try {
195
214
  if (url.origin !== RENDER_ORIGIN || url.search || url.hash) {
196
215
  const kind = request.resourceType();
197
- if (url.origin === assetOrigin && request.method() === 'GET' && ['image', 'font'].includes(kind)
198
- && !url.search && !url.hash && ++assetRequests <= 128) {
216
+ const fixtureImage = assetImages.has(url.href) && request.method() === 'GET' && kind === 'image';
217
+ if ((fixtureImage || (url.origin === assetOrigin && request.method() === 'GET' && ['image', 'font'].includes(kind)
218
+ && !url.search && !url.hash)) && ++assetRequests <= 128) {
199
219
  const asset = await broker.read({ operation: 'asset', url: url.href, kind }, { signal: cancellation });
200
220
  const bytes = Buffer.from(asset.data_base64, 'base64'); assetBytes += bytes.length;
201
221
  if (assetBytes > 32 * 1024 * 1024 || !/^(image|font)\//.test(asset.mime_type)) throw renderFailure('render_asset_limit');
202
222
  return route.fulfill({ status: 200, body: bytes, contentType: asset.mime_type,
203
223
  headers: { 'Cache-Control': 'no-store', 'Access-Control-Allow-Origin': '*', 'X-Content-Type-Options': 'nosniff' } });
204
224
  }
205
- if (blocked.length < 100) blocked.push({ code: 'render_egress_denied' });
225
+ // An offline fixture render names the image it could not show, so verify can say which URL to provide.
226
+ const missingImage = Array.isArray(snapshot.asset_images) && kind === 'image' && url.protocol === 'https:';
227
+ if (blocked.length < 100) blocked.push({ code: 'render_egress_denied', ...(missingImage ? { image: url.href.slice(0, 500) } : {}) });
206
228
  return route.abort('blockedbyclient');
207
229
  }
208
230
  if (request.method() === 'GET') {
@@ -220,7 +242,10 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
220
242
  return respond(403, { error: 'render_read_only', message: 'Rendering never changes records or runs write actions.' });
221
243
  }
222
244
  if (++readRequests > 128) throw new ViewRenderError('render_read_limit', 'This render exceeded its read limit.', 429);
223
- if (pending) { await held; return route.abort('aborted').catch(() => {}); }
245
+ if (pending && (holding === null || holding.has(payload.operation))) {
246
+ heldReads++;
247
+ await held; return route.abort('aborted').catch(() => {});
248
+ }
224
249
  // The server independently reconstructs and classifies every call.
225
250
  const result = await broker.read(payload, { signal: cancellation });
226
251
  return respond(200, { result });
@@ -228,9 +253,16 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
228
253
  const code = ['render_read_only', 'render_paid_background_denied'].includes(error?.code) ? error.code : 'render_read_unavailable';
229
254
  if (['render_read_only', 'render_paid_background_denied'].includes(code)) {
230
255
  if (blocked.length < 100) blocked.push({ code, ...(typeof payload?.action_id === 'string' && /^[a-zA-Z0-9_-]{1,100}$/.test(payload.action_id) ? { action_id: payload.action_id } : {}) });
231
- } else if (error?.status >= 500 || error?.status === 429) {
232
- // Backend load is not an access change: fail the capture as retryable.
256
+ } else if (cancellation.aborted) {
257
+ // The render ran out of time (or was cancelled) while this read waited: a timeout, never an access change.
258
+ } else if (error?.status >= 500 || error?.status === 429 || error instanceof TypeError || ['AbortError', 'TimeoutError'].includes(error?.name)) {
259
+ // Backend load, or a read that never got an answer (fetch's TypeError for a dropped connection or a
260
+ // failed network, an aborted request), is not an access change: fail the capture as retryable.
233
261
  transientFailure ||= error;
262
+ } else if (error?.code === 'render_read_unavailable' && error?.status === 409) {
263
+ // Notis refused one declared read (a connection to renew, a moved read scope): not a change of
264
+ // this render's access. The render stops with that read's id and what clears it.
265
+ readRefused ||= error;
234
266
  } else { authorityLost = true; authorityFailure ||= error; }
235
267
  await respond(error?.status === 401 || error?.status === 404 ? error.status : 403, { error: code, message: 'This read is unavailable in the current render.' }).catch(() => {});
236
268
  }
@@ -252,7 +284,12 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
252
284
  // host records why in `failure`): rendering again cannot help, and it is not about access. A view that
253
285
  // threw while rendering keeps the outcome it had, since that may depend on the data it read.
254
286
  if (!authorityLost && !cancellation.aborted && host.failed && !host.mounted && host.failure) throw viewFailure(host.failure);
255
- if (authorityLost || cancellation.aborted || host.failed) {
287
+ if (readRefused && !authorityLost && !cancellation.aborted) throw readRefused;
288
+ // Out of time with no refused read: the view was slow (a busy machine or server), its access did not change.
289
+ if (cancellation.aborted && !authorityLost) {
290
+ throw signal?.aborted ? new ViewRenderError('render_cancelled', 'The render was cancelled.', 499) : renderFailure('render_timeout');
291
+ }
292
+ if (authorityLost || host.failed) {
256
293
  const failure = renderFailure('render_access_changed');
257
294
  if (authorityFailure) Object.defineProperty(failure, 'cause', { value: authorityFailure });
258
295
  throw failure;
@@ -278,8 +315,8 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
278
315
  return { mounted: Boolean(value.mounted), pending: value.pending || 0, idle: performance.now() - (value.lastActivity || 0), failed: Boolean(value.failed) };
279
316
  });
280
317
  if (now.failed) break;
281
- if (now.mounted && now.pending > 0 && readRequests > 0) break;
282
- if (now.mounted && now.pending === 0 && now.idle > 100) { isStatic = readRequests === 0; break; }
318
+ if (now.mounted && now.pending > 0 && heldReads > 0) break;
319
+ if (now.mounted && now.pending === 0 && now.idle > 100) { isStatic = heldReads === 0; break; }
283
320
  await new Promise(resolve => setTimeout(resolve, 25));
284
321
  }
285
322
  stage = 'pending_settle';
@@ -336,7 +373,9 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
336
373
  // Bones are measured on the viewport layout the skeleton stands in for, before any expansion.
337
374
  stage = 'skeleton_measure';
338
375
  const regions = measure.regions.map(({ key, x, y, width, height }) => ({ key, x, y, width, height }));
339
- const skeletonMeasure = await page.evaluate(skeletonProbe, { mode: 'final', regions, landmarkSelector: LANDMARK_SELECTOR });
376
+ const stops = (Array.isArray(measure.landmarks) ? measure.landmarks : []).slice(0, 20)
377
+ .map(({ sel, x, y, w, h, text }) => ({ sel: String(sel), x, y, w, h, text: String(text || '').slice(0, 60) }));
378
+ const skeletonMeasure = await page.evaluate(skeletonProbe, { mode: 'final', regions, stops, landmarkSelector: LANDMARK_SELECTOR });
340
379
  const finalAuthority = await complete();
341
380
  return { url: snapshot.url, view: snapshot.view, ...(typeof finalAuthority.render_id === 'string' ? { render_id: finalAuthority.render_id } : {}),
342
381
  skeleton_measure: skeletonMeasure, rendered_at: new Date().toISOString() };
@@ -346,7 +385,13 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
346
385
  stage = 'layout_expansion';
347
386
  for (let pass = 0; pass < 10; pass++) {
348
387
  for (const frame of [...page.frames()].reverse()) {
349
- if (!await frame.evaluate(settleFrameImages)) throw renderFailure('render_asset_unavailable');
388
+ const brokenImages = await frame.evaluate(settleFrameImages);
389
+ if (brokenImages.length) {
390
+ // An offline fixture render names the pictures that could not load, so verify can say which URL to provide.
391
+ const named = Array.isArray(snapshot.asset_images)
392
+ ? brokenImages.filter(value => /^https:\/\//.test(value)).map(value => ({ code: 'render_egress_denied', image: value.slice(0, 500) })) : [];
393
+ throw Object.defineProperty(renderFailure('render_asset_unavailable'), 'blocked', { value: [...blocked, ...named] });
394
+ }
350
395
  if (frame !== page.mainFrame() && !frozenFrames.has(frame)) {
351
396
  await frame.evaluate(freezeFrameViewportSizes); frozenFrames.add(frame);
352
397
  }
@@ -402,6 +447,8 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
402
447
  rendered_at: new Date().toISOString(), ...(blocked.length ? { blocked_calls: blocked } : {}) };
403
448
  }, { signal: cancellation, width: config.width, locale: snapshot.locale || 'en', timezone: snapshot.timezone || 'UTC' });
404
449
  } catch (error) {
405
- throw diagnosticFailure(error, stage, cancellation.aborted ? 'render_timeout' : 'render_failed');
450
+ // The pool reports its own deadline abort (a slow browser start on a busy machine) as a cancellation: it is a timeout.
451
+ const timedOut = cancellation.aborted && !signal?.aborted && error?.code === 'render_cancelled';
452
+ throw diagnosticFailure(timedOut ? renderFailure('render_timeout') : error, stage, cancellation.aborted ? 'render_timeout' : 'render_failed');
406
453
  } finally { release(); if (ownPool) await pool.close(); }
407
454
  }
@@ -25,8 +25,11 @@ export const LOADING_WORDS = /\b(en cours de chargement|chargement|loading|pleas
25
25
  const DRIFT_PX = 8;
26
26
  const JUMP_PX = 48;
27
27
 
28
- /** In-page probe. Must not reference anything outside its own body. */
29
- export function skeletonProbe({ mode, regions: wanted = [], landmarkSelector, loadingPattern } = {}) {
28
+ /**
29
+ * In-page probe. Must not reference anything outside its own body. `stops` (final mode) are the pending landmarks:
30
+ * one below a region in its column ends that region's measurement where the same landmark sits in the final view.
31
+ */
32
+ export function skeletonProbe({ mode, regions: wanted = [], landmarkSelector, loadingPattern, stops = [] } = {}) {
30
33
  const LEAF = new Set(['IMG', 'SVG', 'svg', 'CANVAS', 'VIDEO', 'INPUT', 'TEXTAREA', 'SELECT', 'BUTTON', 'PICTURE']);
31
34
  const KEY = /^[a-z0-9][a-z0-9_-]{0,31}$/;
32
35
  const findRoot = () => {
@@ -68,7 +71,8 @@ export function skeletonProbe({ mode, regions: wanted = [], landmarkSelector, lo
68
71
  const role = el.getAttribute('role');
69
72
  const token = [...el.classList].find(name => name.startsWith('nui-'));
70
73
  return { sel: role ? `[role=${role}]` : token ? `.${token}` : el.tagName.toLowerCase(),
71
- x: Math.round(r.left), y: Math.round(r.top), w: Math.round(r.width), h: Math.round(r.height) };
74
+ x: Math.round(r.left), y: Math.round(r.top), w: Math.round(r.width), h: Math.round(r.height),
75
+ text: (el.textContent || '').replace(/\s+/g, ' ').trim().slice(0, 60) };
72
76
  });
73
77
  const viewport = { width: innerWidth, height: innerHeight };
74
78
  const app = { x: Math.round(frame.left), y: Math.round(frame.top), width: Math.round(frame.width), height: Math.round(frame.height) };
@@ -76,9 +80,13 @@ export function skeletonProbe({ mode, regions: wanted = [], landmarkSelector, lo
76
80
  if (mode === 'pending') {
77
81
  const all = elements(appRoot);
78
82
  const seen = new Map();
83
+ const duplicates = new Set();
79
84
  for (const el of all) {
80
85
  const key = el.getAttribute('data-notis-skeleton-key');
81
- if (key === null || seen.has(key) || seen.size >= 32) continue;
86
+ if (key === null) continue;
87
+ // A second region with the same key (not one nested in the first) is never measured.
88
+ if (seen.has(key)) { if (!seen.get(key).el.contains(el) && !el.contains(seen.get(key).el)) duplicates.add(key); continue; }
89
+ if (seen.size >= 32) continue;
82
90
  const r = el.getBoundingClientRect();
83
91
  const left = Math.max(r.left, frame.left), right = Math.min(r.right, frame.right);
84
92
  seen.set(key, { el, key, valid: KEY.test(key), x: left, y: r.top, width: Math.max(0, right - left), height: r.height });
@@ -122,6 +130,9 @@ export function skeletonProbe({ mode, regions: wanted = [], landmarkSelector, lo
122
130
  const loading = new RegExp(loadingPattern, 'i').exec(text);
123
131
  return { mode, viewport, app, landmarks: landmarks(), loadingText: loading ? loading[0] : null,
124
132
  spinnerOnly: spinners.length > 0 && content.length === 0, emptyStates, appBlank: inked.size === 0,
133
+ duplicateKeys: [...duplicates].slice(0, 8),
134
+ // Record pages drawing the SDK's DocumentPageSkeleton (an opened item still loading).
135
+ pageSkeletons: appRoot.querySelectorAll('[data-notis-skeleton="document-page"]').length,
125
136
  regions: [...seen.values()].map(({ el, ...region }) => {
126
137
  const inner = [el, ...elements(el, 5000)];
127
138
  return { ...region, x: Math.round(region.x * 100) / 100, y: Math.round(region.y * 100) / 100,
@@ -131,10 +142,25 @@ export function skeletonProbe({ mode, regions: wanted = [], landmarkSelector, lo
131
142
  }) };
132
143
  }
133
144
 
134
- // Final: measure each pending region box. The box stops at the next region below it in the same column.
145
+ // Final: measure each pending region box. The box stops at the next region below it in the same column, and at
146
+ // the next landmark below it (a section head drawn while loading), where that landmark sits in the final view.
147
+ const finalMarks = landmarks();
148
+ const counted = new Map();
149
+ // A stop pairs with the final landmark of its selector and text (its nth when several share both), so a landmark
150
+ // the loaded view adds above it is never taken for it; a heading whose text changed (a count) pairs by order.
151
+ const moved = stops.map(stop => {
152
+ const id = `${stop.sel}\n${stop.text || ''}`;
153
+ const index = counted.get(id) || 0; counted.set(id, index + 1);
154
+ const order = counted.get(stop.sel) || 0; counted.set(stop.sel, order + 1);
155
+ const same = finalMarks.filter(mark => mark.sel === stop.sel);
156
+ return { stop, now: same.filter(mark => (mark.text || '') === (stop.text || ''))[index] || same[order] };
157
+ }).filter(value => value.now);
135
158
  const measured = wanted.map(region => {
136
- const below = wanted.filter(other => other !== region && other.y > region.y + 1
137
- && other.x < region.x + region.width && other.x + other.width > region.x).map(other => other.y - region.y);
159
+ const column = other => other.x < region.x + region.width && other.x + (other.width ?? other.w) > region.x;
160
+ const below = wanted.filter(other => other !== region && other.y > region.y + 1 && column(other)).map(other => other.y - region.y);
161
+ for (const { stop, now } of moved) {
162
+ if (stop.y >= region.y + (region.height || 0) - 1 && column(stop) && now.y > region.y + 1) below.push(now.y - region.y);
163
+ }
138
164
  const R = { x: region.x, y: region.y, width: Math.max(1, region.width), maxH: Math.min(innerHeight * 2, ...below) };
139
165
  const bones = [];
140
166
  const groups = [];
@@ -208,7 +234,7 @@ export function skeletonProbe({ mode, regions: wanted = [], landmarkSelector, lo
208
234
  for (const child of appRoot.children) walk(child, { left: -Infinity, top: -Infinity, right: Infinity, bottom: Infinity });
209
235
  return { key: region.key, width: Math.round(R.width), bones, groups };
210
236
  });
211
- return { mode: 'final', viewport, app, landmarks: landmarks(), regions: measured };
237
+ return { mode: 'final', viewport, app, landmarks: finalMarks, regions: measured };
212
238
  }
213
239
 
214
240
  /** In-page: resolve once the document and open shadow roots stay unchanged for `quietMs`, at most `capMs`. */
@@ -415,18 +441,44 @@ export function runSkeletonChecks({ width, locale, pending, regions = pending?.r
415
441
  if (pending.loadingText) add('loading_text', `The loading state shows the text "${pending.loadingText}". Show the skeleton instead of a loading message.`);
416
442
  if (pending.spinnerOnly) add('page_spinner', 'The loading state shows only a spinner. Show the skeleton instead.');
417
443
  if (pending.emptyStates > 0) add('empty_before_data', 'An empty state is visible before the first read answers. Show the skeleton until the data arrives.');
418
- if (final?.landmarks?.length) {
419
- const seen = new Map();
444
+ for (const key of pending.duplicateKeys || []) {
445
+ add('duplicate_key', `Two ViewSkeleton regions use the key "${key}", so only the first is measured. Give each part that loads on its own its own skeletonKey.`, key);
446
+ }
447
+ if (final?.landmarks) {
448
+ // Only the first screen is compared. Per selector, the landmarks are paired in order when both states show as
449
+ // many; otherwise one finding names the heading that is missing or extra, instead of every later one moving.
450
+ const firstScreen = list => (list || []).filter(value => value.y < viewport && value.y + (value.h || 0) > 0);
451
+ const before = firstScreen(pending.landmarks), after = firstScreen(final.landmarks);
420
452
  const drifted = [];
421
- for (const landmark of final.landmarks) {
422
- const occurrence = seen.get(landmark.sel) || 0; seen.set(landmark.sel, occurrence + 1);
423
- const before = (pending.landmarks || []).filter(value => value.sel === landmark.sel)[occurrence];
424
- if (!before) continue;
425
- const drift = Math.max(Math.abs(before.x - landmark.x), Math.abs(before.y - landmark.y));
426
- if (drift > DRIFT_PX) drifted.push({ sel: landmark.sel, drift });
453
+ for (const sel of [...new Set([...before, ...after].map(value => value.sel))]) {
454
+ let was = before.filter(value => value.sel === sel), now = after.filter(value => value.sel === sel);
455
+ const allWas = (pending.landmarks || []).filter(value => value.sel === sel);
456
+ const allNow = final.landmarks.filter(value => value.sel === sel);
457
+ if (was.length !== now.length && allWas.length === allNow.length) {
458
+ // As many on the whole page: one crossed the first screen's edge, a move and not a missing heading.
459
+ const pairs = allWas.map((value, index) => [value, allNow[index]]).filter(([a, b]) => before.includes(a) || after.includes(b));
460
+ was = pairs.map(([a]) => a); now = pairs.map(([, b]) => b);
461
+ }
462
+ if (was.length !== now.length) {
463
+ const left = now.map(value => value.text || ''), gone = [];
464
+ for (const value of was) { const at = left.indexOf(value.text || ''); if (at >= 0) left.splice(at, 1); else gone.push(value.text || ''); }
465
+ const named = list => list.filter(Boolean).slice(0, 3).map(text => `"${text}"`).join(', ');
466
+ if (now.length > was.length) {
467
+ const extra = named(left);
468
+ add('landmark_count', `${now.length - was.length} "${sel}"${extra ? ` (${extra})` : ''} ${now.length - was.length === 1 ? 'appears' : 'appear'} on the first screen only once the data arrives, pushing what follows down. Draw ${now.length - was.length === 1 ? 'it' : 'them'} while loading too.`);
469
+ } else {
470
+ const missing = named(gone);
471
+ add('landmark_count', `${was.length - now.length} "${sel}"${missing ? ` (${missing})` : ''} on the first screen while loading ${was.length - now.length === 1 ? 'is' : 'are'} gone once the data arrives. Draw only what the loaded view shows.`);
472
+ }
473
+ continue;
474
+ }
475
+ was.forEach((value, index) => {
476
+ const drift = Math.max(Math.abs(value.x - now[index].x), Math.abs(value.y - now[index].y));
477
+ if (drift > DRIFT_PX) drifted.push({ sel, drift, text: now[index].text });
478
+ });
427
479
  }
428
- for (const { sel, drift } of drifted.slice(0, 5)) {
429
- add('landmark_drift', `"${sel}" moves ${Math.round(drift)} px when the data arrives. Keep its place reserved while loading.`);
480
+ for (const { sel, drift, text } of drifted.slice(0, 5)) {
481
+ add('landmark_drift', `"${sel}"${text ? ` ("${text}")` : ''} moves ${Math.round(drift)} px when the data arrives. Keep its place reserved while loading.`);
430
482
  }
431
483
  }
432
484
  for (const region of regions) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@notis_ai/cli",
3
- "version": "0.2.30",
3
+ "version": "0.2.31",
4
4
  "description": "Agent-first Notis CLI for Spaces, Skills and generic tool execution",
5
5
  "type": "module",
6
6
  "bin": {
@@ -35,7 +35,8 @@
35
35
  "ajv-formats": "^3.0.1",
36
36
  "commander": "^15.0.0",
37
37
  "esbuild": "^0.28.2",
38
- "playwright-core": "1.64.1"
38
+ "playwright-core": "1.64.1",
39
+ "undici": "^7.30.1"
39
40
  },
40
41
  "keywords": [
41
42
  "notis",
@@ -52,8 +53,8 @@
52
53
  "react-dom": "19.3.0"
53
54
  },
54
55
  "notisRelease": {
55
- "sourceSha": "c85c7d62766a6561de18ec338247843d089cadae",
56
+ "sourceSha": "b5902cc7f64ba2ed2615c903c6e88a58d588bf5f",
56
57
  "channel": "stable"
57
58
  },
58
- "gitHead": "c85c7d62766a6561de18ec338247843d089cadae"
59
+ "gitHead": "b5902cc7f64ba2ed2615c903c6e88a58d588bf5f"
59
60
  }
@@ -24,8 +24,11 @@ npx --package @notis_ai/cli@latest -- notis tools exec LOCAL_NOTIS_DATABASE_GET_
24
24
  npx --package @notis_ai/cli@latest -- notis tools exec LOCAL_NOTIS_DATABASE_GET_DATABASE --arguments '{"database_slug":"tasks"}'
25
25
  npx --package @notis_ai/cli@latest -- notis tools exec LOCAL_NOTIS_DATABASE_QUERY --dry-run --arguments '{"database_slug":"tasks","query":{"page_size":10}}'
26
26
  npx --package @notis_ai/cli@latest -- notis tools exec LOCAL_NOTIS_DATABASE_QUERY --arguments '{"database_slug":"tasks","query":{"page_size":10}}'
27
+ npx --package @notis_ai/cli@latest -- notis tools exec LOCAL_NOTIS_DATABASE_QUERY --arguments '{"protocol":1,"target":{"database_id":"<database id>"},"input":{"mode":"rows","page_size":10}}'
27
28
  ```
28
29
 
30
+ A read by slug or bare `database_id` of a database used in Spaces runs through your main view of it and returns `resolved_target` (`{space_id, binding}`): reuse it for the next call and for every write, which never takes a bare ID.
31
+
29
32
  ## Supporting command
30
33
 
31
34
  ### `npx --package @notis_ai/cli@latest -- notis doctor`