@notis_ai/cli 0.2.29 → 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.
- package/README.md +26 -8
- package/dist/agent-hooks/notis-agent-hook.mjs +38399 -10883
- package/dist/base-skills/notis-cli/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-cli/SKILL.md +11 -0
- package/dist/base-skills/notis-cli/references/native-databases.md +1 -1
- package/dist/base-skills/notis-query/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-query/references/query.md +6 -4
- package/dist/base-skills/notis-spaces/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-spaces/SKILL.md +8 -3
- package/dist/base-skills/notis-spaces/references/architecture.md +4 -1
- package/dist/base-skills/notis-spaces/references/design.md +7 -1
- package/dist/base-skills/notis-spaces/references/fixtures.md +27 -2
- package/dist/base-skills/notis-spaces/references/release.md +6 -5
- package/dist/base-skills/notis-spaces/references/sdk.md +172 -48
- package/dist/base-skills/notis-spaces/references/troubleshooting.md +3 -0
- package/dist/base-skills/notis-spaces/references/views.md +20 -0
- package/dist/sdk/src/hooks/useNativeDocuments.ts +50 -12
- package/dist/sdk/src/hooks/useThreadItem.ts +56 -0
- package/dist/sdk/src/index.ts +7 -2
- package/dist/sdk/src/runtime.ts +8 -1
- package/dist/sdk/src/space.ts +233 -1
- package/dist/sdk/src/tailwind.ts +53 -3
- package/dist/sdk/src/ui/icons.tsx +1 -0
- package/dist/sdk/src/words/types.ts +28 -0
- package/dist/skill-sync/index.js +10 -90
- package/dist/skill-sync-worker.mjs +232 -120
- package/dist/space-harness/host.js +309 -96
- package/dist/space-sdk/dist/chunk-3DFOGU26.js +3 -0
- package/dist/space-sdk/dist/index.js +4 -2
- package/dist/space-sdk/dist/ui.js +19 -14
- package/dist/space-sdk/src/hooks/useNativeDocuments.d.ts +23 -0
- package/dist/space-sdk/src/hooks/useThreadItem.d.ts +28 -0
- package/dist/space-sdk/src/index.d.ts +4 -2
- package/dist/space-sdk/src/runtime.d.ts +8 -1
- package/dist/space-sdk/src/space.ts +233 -1
- package/dist/space-sdk/src/tailwind-candidates.d.ts +765 -16
- package/dist/space-sdk/src/tailwind.ts +53 -3
- package/dist/space-sdk/src/ui/actions/useToast.d.ts +2 -0
- package/dist/space-sdk/src/ui/blocks/DataTable.d.ts +19 -4
- package/dist/space-sdk/src/ui/blocks/Meter.d.ts +12 -3
- package/dist/space-sdk/src/ui/blocks/Tabs.d.ts +7 -1
- package/dist/space-sdk/src/ui/blocks/index.d.ts +1 -1
- package/dist/space-sdk/src/ui/charts/CalendarHeatmap.d.ts +69 -0
- package/dist/space-sdk/src/ui/charts/Chart.d.ts +18 -3
- package/dist/space-sdk/src/ui/charts/chartData.d.ts +19 -0
- package/dist/space-sdk/src/ui/charts/heatmapData.d.ts +81 -0
- package/dist/space-sdk/src/ui/comments/CommentPane.d.ts +56 -10
- package/dist/space-sdk/src/ui/comments/PassageComments.d.ts +16 -7
- package/dist/space-sdk/src/ui/comments/agentRuntime.d.ts +59 -0
- package/dist/space-sdk/src/ui/comments/commentFiles.d.ts +5 -2
- package/dist/space-sdk/src/ui/comments/commentModel.d.ts +103 -8
- package/dist/space-sdk/src/ui/comments/commentWords.d.ts +82 -0
- package/dist/space-sdk/src/ui/comments/hostComments.d.ts +37 -0
- package/dist/space-sdk/src/ui/comments/index.d.ts +4 -0
- package/dist/space-sdk/src/ui/comments/paneParts.d.ts +119 -0
- package/dist/space-sdk/src/ui/comments/useCommentRouting.d.ts +75 -0
- package/dist/space-sdk/src/ui/comments/useComments.d.ts +147 -15
- package/dist/space-sdk/src/ui/comments/usePassageComments.d.ts +24 -8
- package/dist/space-sdk/src/ui/index.d.ts +6 -3
- package/dist/space-sdk/src/ui/layout/SidePane.d.ts +6 -1
- package/dist/space-sdk/src/ui/list/Row.d.ts +11 -1
- package/dist/space-sdk/src/ui/overlay/Tooltip.d.ts +8 -2
- package/dist/space-sdk/src/ui/period/dateFormat.d.ts +2 -0
- package/dist/space-sdk/src/ui/period/dateWords.d.ts +9 -0
- package/dist/space-sdk/src/ui/period/periods.d.ts +15 -2
- package/dist/space-sdk/src/ui/styles.d.ts +27 -5
- package/dist/space-sdk/src/words/types.ts +28 -0
- package/dist/view-renderer/dist/host.js +379 -166
- package/dist/view-renderer/src/dom.js +3 -2
- package/dist/view-renderer/src/errors.js +9 -0
- package/dist/view-renderer/src/host.tsx +18 -8
- package/dist/view-renderer/src/remote-broker.js +3 -1
- package/dist/view-renderer/src/renderer.js +87 -17
- package/dist/view-renderer/src/skeleton.js +70 -18
- package/package.json +5 -4
- package/skills/notis-cli/AGENT_INSTRUCTIONS.md +2 -1
- package/skills/notis-query/cli.md +3 -0
- package/skills/notis-spaces/cli.md +8 -8
- package/src/cli.js +10 -2
- package/src/command-specs/computer.js +21 -1
- package/src/command-specs/profile.js +12 -5
- package/src/command-specs/spaces.js +101 -31
- package/src/command-specs/tools.js +3 -0
- package/src/runtime/agent-identity.js +187 -0
- package/src/runtime/api-hosts.generated.js +35 -0
- package/src/runtime/api-hosts.js +109 -0
- package/src/runtime/app-platform.js +68 -24
- package/src/runtime/channel.js +3 -7
- package/src/runtime/http-agent.js +53 -0
- package/src/runtime/native-record-files.js +11 -0
- package/src/runtime/oauth.js +97 -5
- package/src/runtime/profiles.js +200 -41
- package/src/runtime/skill-sync/cloud-client.ts +0 -10
- package/src/runtime/skill-sync/index.ts +13 -15
- package/src/runtime/skill-sync/local-scanner.ts +0 -67
- package/src/runtime/skill-sync/types.ts +1 -0
- package/src/runtime/skill-sync/write-cloud-skill.ts +7 -23
- package/src/runtime/skill-sync-service.js +4 -5
- package/src/runtime/space-dependencies.js +66 -0
- package/src/runtime/space-fixture-broker.js +23 -8
- package/src/runtime/space-platform.js +49 -3
- package/src/runtime/space-source.js +76 -2
- package/src/runtime/space-test-server.js +125 -10
- package/src/runtime/space-verification.js +106 -42
- package/src/runtime/space-view-manifest.js +38 -5
- package/src/runtime/telemetry.js +14 -1
- package/src/runtime/transport.js +31 -4
- package/src/runtime/upsell.js +3 -6
- package/src/runtime/view-render.js +6 -1
- package/src/skill-sync-worker.js +13 -2
- package/src/space-harness-host.ts +6 -3
- package/template/tailwind.config.ts +2 -35
- package/dist/space-sdk/dist/chunk-BFGB6XXC.js +0 -5
|
@@ -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
|
|
224
|
-
}))).
|
|
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.
|
|
@@ -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 });
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
|
225
|
+
return await (module[snapshot.markdownExport] as any)({ params, shown });
|
|
219
226
|
}
|
|
220
227
|
return activeMarkdown;
|
|
221
228
|
} });
|
|
@@ -228,7 +235,8 @@ async function start() {
|
|
|
228
235
|
const host = document.createElement('div'); host.style.cssText = 'height:100vh;min-height:100vh';
|
|
229
236
|
const shadow = host.attachShadow({ mode: 'open' });
|
|
230
237
|
const styles = document.createElement('style'); styles.textContent = (snapshot.hostCss || '') + '\n' + snapshot.css; shadow.appendChild(styles);
|
|
231
|
-
|
|
238
|
+
// A Tailwind 3 Space keeps the toolkit unlayered, so its unlayered preflight does not reset toolkit pieces.
|
|
239
|
+
NotisSDKUI.adoptToolkitStyles(shadow, { cascade: NotisSDKUI.toolkitCascadeFor(snapshot.css) });
|
|
232
240
|
const mount = document.createElement('div'); mount.style.cssText = 'height:100%;min-height:0'; shadow.appendChild(mount);
|
|
233
241
|
document.body.appendChild(host);
|
|
234
242
|
const controller = document.createElement('div'); document.body.appendChild(controller);
|
|
@@ -250,4 +258,6 @@ async function start() {
|
|
|
250
258
|
onProtocolError={error => { if ((error as any)?.code === 'notis_sdk_query:actionUnavailable') return; state.blocked.push('render_read_only'); changed(); }}
|
|
251
259
|
onCommit={mounted => { frame(); state.mounted = mounted; changed(); }} />);
|
|
252
260
|
}
|
|
253
|
-
|
|
261
|
+
// Why the view never started (most often its module did not load), for `spaces verify` to show; the render
|
|
262
|
+
// service never returns it.
|
|
263
|
+
void start().catch(error => { state.failed = true; state.failure = String(error?.message ?? error).slice(0, 300) || 'The view did not start.'; });
|
|
@@ -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
|
}
|
|
@@ -91,12 +91,23 @@ async function capturePage(page, sliceHeight, maxBytes, maxHeight, maxPixels) {
|
|
|
91
91
|
return stitcher.finish();
|
|
92
92
|
}
|
|
93
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
|
+
|
|
94
102
|
function diagnosticFailure(error, stage, fallback = 'render_failed') {
|
|
95
103
|
const failure = error instanceof ViewRenderError
|
|
96
104
|
? new ViewRenderError(error.code, error.message, error.status) : renderFailure(fallback);
|
|
97
105
|
// Private in-process diagnostics only. Public JSON/error projections cannot
|
|
98
106
|
// enumerate a browser exception, which may contain source or request data.
|
|
99
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
|
+
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 });
|
|
100
111
|
// A view that was not ready in time keeps the screenshot of what it showed, released after the final authority check.
|
|
101
112
|
if (error instanceof ViewRenderError && error.screenshot) {
|
|
102
113
|
Object.defineProperties(failure, { screenshot: { value: error.screenshot }, mounted: { value: error.mounted === true },
|
|
@@ -112,8 +123,11 @@ function diagnosticFailure(error, stage, fallback = 'render_failed') {
|
|
|
112
123
|
* - `pending: true` holds every `/__read` until the render ends, waits until the view is mounted with a read
|
|
113
124
|
* pending and its DOM is quiet for 300 ms, and returns `pending` (the loading-state probe) and a viewport
|
|
114
125
|
* `screenshot` instead of the usual outputs. A view that never reads is reported as `pending.static`.
|
|
115
|
-
*
|
|
116
|
-
*
|
|
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.
|
|
117
131
|
* - `locale` ('en' or 'fr') overrides the snapshot locale; `skeleton` is injected as `descriptor.context.skeleton`.
|
|
118
132
|
*
|
|
119
133
|
* `readyTimeoutMs`, shorter than the render timeout, bounds the wait for the view to finish loading its data (mounted,
|
|
@@ -130,6 +144,10 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
|
|
|
130
144
|
throw new TypeError('Bound the ready wait below the render timeout.');
|
|
131
145
|
}
|
|
132
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;
|
|
133
151
|
if (locale !== undefined && !['en', 'fr'].includes(locale)) throw new TypeError('Override the locale with en or fr.');
|
|
134
152
|
if (measure !== undefined && !Array.isArray(measure?.regions)) throw new TypeError('Measure a list of skeleton regions.');
|
|
135
153
|
if (!Number.isInteger(sliceHeight) || sliceHeight < 256 || sliceHeight > 16384) throw new TypeError('Use a bounded screenshot slice height.');
|
|
@@ -161,11 +179,21 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
|
|
|
161
179
|
const ownPool = !pool;
|
|
162
180
|
pool ||= createBrowserPool();
|
|
163
181
|
const blocked = [];
|
|
164
|
-
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;
|
|
165
183
|
let stage = 'browser_context';
|
|
166
184
|
let assetOrigin = null;
|
|
167
185
|
try { const asset = new URL(snapshot.asset_origin); if (asset.protocol === 'https:' && asset.origin === snapshot.asset_origin) assetOrigin = asset.origin; } catch {}
|
|
168
|
-
|
|
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);
|
|
169
197
|
try {
|
|
170
198
|
return await pool.use(async context => {
|
|
171
199
|
stage = 'browser_setup';
|
|
@@ -185,15 +213,18 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
|
|
|
185
213
|
try {
|
|
186
214
|
if (url.origin !== RENDER_ORIGIN || url.search || url.hash) {
|
|
187
215
|
const kind = request.resourceType();
|
|
188
|
-
|
|
189
|
-
|
|
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) {
|
|
190
219
|
const asset = await broker.read({ operation: 'asset', url: url.href, kind }, { signal: cancellation });
|
|
191
220
|
const bytes = Buffer.from(asset.data_base64, 'base64'); assetBytes += bytes.length;
|
|
192
221
|
if (assetBytes > 32 * 1024 * 1024 || !/^(image|font)\//.test(asset.mime_type)) throw renderFailure('render_asset_limit');
|
|
193
222
|
return route.fulfill({ status: 200, body: bytes, contentType: asset.mime_type,
|
|
194
223
|
headers: { 'Cache-Control': 'no-store', 'Access-Control-Allow-Origin': '*', 'X-Content-Type-Options': 'nosniff' } });
|
|
195
224
|
}
|
|
196
|
-
|
|
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) } : {}) });
|
|
197
228
|
return route.abort('blockedbyclient');
|
|
198
229
|
}
|
|
199
230
|
if (request.method() === 'GET') {
|
|
@@ -211,7 +242,10 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
|
|
|
211
242
|
return respond(403, { error: 'render_read_only', message: 'Rendering never changes records or runs write actions.' });
|
|
212
243
|
}
|
|
213
244
|
if (++readRequests > 128) throw new ViewRenderError('render_read_limit', 'This render exceeded its read limit.', 429);
|
|
214
|
-
if (pending
|
|
245
|
+
if (pending && (holding === null || holding.has(payload.operation))) {
|
|
246
|
+
heldReads++;
|
|
247
|
+
await held; return route.abort('aborted').catch(() => {});
|
|
248
|
+
}
|
|
215
249
|
// The server independently reconstructs and classifies every call.
|
|
216
250
|
const result = await broker.read(payload, { signal: cancellation });
|
|
217
251
|
return respond(200, { result });
|
|
@@ -219,9 +253,16 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
|
|
|
219
253
|
const code = ['render_read_only', 'render_paid_background_denied'].includes(error?.code) ? error.code : 'render_read_unavailable';
|
|
220
254
|
if (['render_read_only', 'render_paid_background_denied'].includes(code)) {
|
|
221
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 } : {}) });
|
|
222
|
-
} else if (
|
|
223
|
-
//
|
|
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.
|
|
224
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;
|
|
225
266
|
} else { authorityLost = true; authorityFailure ||= error; }
|
|
226
267
|
await respond(error?.status === 401 || error?.status === 404 ? error.status : 403, { error: code, message: 'This read is unavailable in the current render.' }).catch(() => {});
|
|
227
268
|
}
|
|
@@ -237,7 +278,18 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
|
|
|
237
278
|
Object.defineProperty(failure, 'cause', { value: transientFailure });
|
|
238
279
|
throw failure;
|
|
239
280
|
}
|
|
240
|
-
|
|
281
|
+
const host = await page.evaluate(() => ({ failed: Boolean(window.__notisRenderState?.failed),
|
|
282
|
+
mounted: Boolean(window.__notisRenderState?.mounted), failure: String(window.__notisRenderState?.failure || '') }));
|
|
283
|
+
// The view's code did not start (a module that does not load, an import this host does not provide; the
|
|
284
|
+
// host records why in `failure`): rendering again cannot help, and it is not about access. A view that
|
|
285
|
+
// threw while rendering keeps the outcome it had, since that may depend on the data it read.
|
|
286
|
+
if (!authorityLost && !cancellation.aborted && host.failed && !host.mounted && host.failure) throw viewFailure(host.failure);
|
|
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) {
|
|
241
293
|
const failure = renderFailure('render_access_changed');
|
|
242
294
|
if (authorityFailure) Object.defineProperty(failure, 'cause', { value: authorityFailure });
|
|
243
295
|
throw failure;
|
|
@@ -263,8 +315,8 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
|
|
|
263
315
|
return { mounted: Boolean(value.mounted), pending: value.pending || 0, idle: performance.now() - (value.lastActivity || 0), failed: Boolean(value.failed) };
|
|
264
316
|
});
|
|
265
317
|
if (now.failed) break;
|
|
266
|
-
if (now.mounted && now.pending > 0 &&
|
|
267
|
-
if (now.mounted && now.pending === 0 && now.idle > 100) { isStatic =
|
|
318
|
+
if (now.mounted && now.pending > 0 && heldReads > 0) break;
|
|
319
|
+
if (now.mounted && now.pending === 0 && now.idle > 100) { isStatic = heldReads === 0; break; }
|
|
268
320
|
await new Promise(resolve => setTimeout(resolve, 25));
|
|
269
321
|
}
|
|
270
322
|
stage = 'pending_settle';
|
|
@@ -285,11 +337,19 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
|
|
|
285
337
|
}
|
|
286
338
|
stage = 'host_ready';
|
|
287
339
|
const ready = () => window.__notisRenderState?.mounted && window.__notisRenderState.pending === 0 && performance.now() - window.__notisRenderState.lastActivity > 100;
|
|
340
|
+
// A view whose code did not start has nothing left to wait for: stop at once instead of waiting out the
|
|
341
|
+
// render timeout. Any other failure still waits for the reads in flight, whose outcome decides the error.
|
|
342
|
+
// (Each function runs in the page on its own, so this one cannot call ready.)
|
|
343
|
+
const readyOrFailed = () => Boolean(window.__notisRenderState?.failure) || (window.__notisRenderState?.mounted
|
|
344
|
+
&& window.__notisRenderState.pending === 0 && performance.now() - window.__notisRenderState.lastActivity > 100);
|
|
288
345
|
// The bounded wait also leaves the capture and the final authority check room before the render deadline.
|
|
289
346
|
const readyWait = readyTimeoutMs === undefined ? config.timeoutMs
|
|
290
347
|
: Math.max(1, Math.min(readyTimeoutMs, deadlineAt - Date.now() - CAPTURE_MARGIN_MS));
|
|
291
348
|
const readyStarted = Date.now();
|
|
292
|
-
try {
|
|
349
|
+
try {
|
|
350
|
+
await page.waitForFunction(readyOrFailed, undefined, { timeout: readyWait });
|
|
351
|
+
if (await page.evaluate(() => Boolean(window.__notisRenderState?.failure))) await complete();
|
|
352
|
+
}
|
|
293
353
|
catch (error) {
|
|
294
354
|
if (readyTimeoutMs === undefined || cancellation.aborted || error?.name !== 'TimeoutError') throw error;
|
|
295
355
|
stage = 'not_ready_capture';
|
|
@@ -313,7 +373,9 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
|
|
|
313
373
|
// Bones are measured on the viewport layout the skeleton stands in for, before any expansion.
|
|
314
374
|
stage = 'skeleton_measure';
|
|
315
375
|
const regions = measure.regions.map(({ key, x, y, width, height }) => ({ key, x, y, width, height }));
|
|
316
|
-
const
|
|
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 });
|
|
317
379
|
const finalAuthority = await complete();
|
|
318
380
|
return { url: snapshot.url, view: snapshot.view, ...(typeof finalAuthority.render_id === 'string' ? { render_id: finalAuthority.render_id } : {}),
|
|
319
381
|
skeleton_measure: skeletonMeasure, rendered_at: new Date().toISOString() };
|
|
@@ -323,7 +385,13 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
|
|
|
323
385
|
stage = 'layout_expansion';
|
|
324
386
|
for (let pass = 0; pass < 10; pass++) {
|
|
325
387
|
for (const frame of [...page.frames()].reverse()) {
|
|
326
|
-
|
|
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
|
+
}
|
|
327
395
|
if (frame !== page.mainFrame() && !frozenFrames.has(frame)) {
|
|
328
396
|
await frame.evaluate(freezeFrameViewportSizes); frozenFrames.add(frame);
|
|
329
397
|
}
|
|
@@ -379,6 +447,8 @@ export async function renderView({ broker, outputs, width, timeoutMs, signal, po
|
|
|
379
447
|
rendered_at: new Date().toISOString(), ...(blocked.length ? { blocked_calls: blocked } : {}) };
|
|
380
448
|
}, { signal: cancellation, width: config.width, locale: snapshot.locale || 'en', timezone: snapshot.timezone || 'UTC' });
|
|
381
449
|
} catch (error) {
|
|
382
|
-
|
|
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');
|
|
383
453
|
} finally { release(); if (ownPool) await pool.close(); }
|
|
384
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
|
-
/**
|
|
29
|
-
|
|
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
|
|
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
|
|
137
|
-
|
|
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:
|
|
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
|
-
|
|
419
|
-
|
|
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
|
|
422
|
-
|
|
423
|
-
const
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
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.
|
|
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": "
|
|
56
|
+
"sourceSha": "b5902cc7f64ba2ed2615c903c6e88a58d588bf5f",
|
|
56
57
|
"channel": "stable"
|
|
57
58
|
},
|
|
58
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "b5902cc7f64ba2ed2615c903c6e88a58d588bf5f"
|
|
59
60
|
}
|
|
@@ -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.
|
|
@@ -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`
|
|
@@ -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`
|