@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
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
3
|
import { existsSync, readFileSync } from 'node:fs';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { appFilesDigest } from './app-platform.js';
|
|
6
|
-
import { createSpaceFixtureBroker, fixtureSkeletonParams } from './space-fixture-broker.js';
|
|
5
|
+
import { appFilesDigest, VERIFY_LOCALES, VERIFY_WIDTHS } from './app-platform.js';
|
|
6
|
+
import { createSpaceFixtureBroker, fixtureContexts, fixtureSkeletonParams } from './space-fixture-broker.js';
|
|
7
7
|
|
|
8
8
|
// Kept for the standalone legacy worker's lifecycle tests while that diagnostic
|
|
9
9
|
// entrypoint is retired. The primary verifier below never starts that worker.
|
|
@@ -43,7 +43,16 @@ async function acquire(signal) {
|
|
|
43
43
|
}
|
|
44
44
|
function releaseSlot() { const next = waiting.shift(); if (next) next.accept(); else active--; }
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
const LANGUAGES = { en: 'English', fr: 'French' };
|
|
47
|
+
/** Where one render was taken, for messages: "390 px in French" and, with several contexts, the context's name. */
|
|
48
|
+
const placeOf = ({ width, locale, context }) => `${width} px in ${LANGUAGES[locale]}${context ? `, context ${context}` : ''}`;
|
|
49
|
+
// The reads a reader's loading pass holds: the opened item's record and body; the list around it answers.
|
|
50
|
+
const READER_HOLDS = ['record', 'document_body', 'html', 'report'];
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Initial deployment checks the exact captured bytes at both product widths, in English and French, once per fixture
|
|
54
|
+
* context (`contexts` in the fixtures, else the one `context`).
|
|
55
|
+
*/
|
|
47
56
|
export async function verifySpaceRelease(release, { capabilities, timeoutMs = 45_000, signal, loadRenderer = loadSpaceVerificationRenderer,
|
|
48
57
|
authorizationMode = 'authorize_missing', unavailableActions = [] } = {}) {
|
|
49
58
|
const diagnostic = { schema: 'notis-space-render/v1', local_key: release.manifest.local_key,
|
|
@@ -54,13 +63,18 @@ export async function verifySpaceRelease(release, { capabilities, timeoutMs = 45
|
|
|
54
63
|
if (signal?.aborted) return { ...diagnostic, status: 'failed', errors: [{ phase: 'browser', message: 'Verification cancelled.' }] };
|
|
55
64
|
if (release.manifest.kind === 'container') return { ...diagnostic, status: 'not_applicable_container' };
|
|
56
65
|
let pool, held = false, rendererDigest;
|
|
57
|
-
|
|
66
|
+
// Several contexts name their images and messages; one context keeps the plain names.
|
|
67
|
+
const contexts = fixtureContexts(release), named = contexts.length > 1;
|
|
68
|
+
const brokers = [];
|
|
69
|
+
for (const { name } of contexts.length ? contexts : [{ name: undefined }]) for (const locale of VERIFY_LOCALES) for (const width of VERIFY_WIDTHS) {
|
|
70
|
+
brokers.push({ width, locale, contextName: name, ...(named ? { context: name } : {}), broker: null, stop: new AbortController(), timer: null });
|
|
71
|
+
}
|
|
58
72
|
try {
|
|
59
73
|
// Validate fixture authority before opening a browser or acquiring a slot.
|
|
60
74
|
// A failed fixture read already fails the check, and the view usually waits on it until the timeout: the
|
|
61
75
|
// render stops shortly after, once the reads the view sends together have had their say.
|
|
62
76
|
for (const item of brokers) item.broker = createSpaceFixtureBroker({ release, capabilities, width: item.width,
|
|
63
|
-
authorizationMode, unavailableActions, onFailure: () => {
|
|
77
|
+
authorizationMode, unavailableActions, context: item.contextName, onFailure: () => {
|
|
64
78
|
item.timer ??= setTimeout(() => item.stop.abort(), FIXTURE_FAILURE_GRACE_MS);
|
|
65
79
|
} });
|
|
66
80
|
await acquire(signal); held = true;
|
|
@@ -70,51 +84,70 @@ export async function verifySpaceRelease(release, { capabilities, timeoutMs = 45
|
|
|
70
84
|
// waits; a view still loading after the bounded wait keeps a screenshot of what it showed, and says so.
|
|
71
85
|
const readyTimeoutMs = readyWait(timeoutMs);
|
|
72
86
|
const screenshots = [];
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
const tag = ({ width, locale, context }) => ({ width, locale, ...(context ? { context } : {}) });
|
|
88
|
+
const observations = [];
|
|
89
|
+
// Both widths of one context and locale render together: the pool holds two renders at a time.
|
|
90
|
+
for (let index = 0; index < brokers.length; index += VERIFY_WIDTHS.length) {
|
|
91
|
+
observations.push(...await Promise.allSettled(brokers.slice(index, index + VERIFY_WIDTHS.length).map(async (item) => {
|
|
92
|
+
const { width, locale, broker, stop } = item;
|
|
93
|
+
const cancel = signal ? AbortSignal.any([signal, stop.signal]) : stop.signal;
|
|
94
|
+
const result = await library.renderView({ broker, pool, outputs: ['markdown', 'screenshot'], width, locale, timeoutMs, signal: cancel,
|
|
95
|
+
...(readyTimeoutMs ? { readyTimeoutMs } : {}) });
|
|
96
|
+
const blocked = result.blocked_calls || [];
|
|
97
|
+
const png = Buffer.from(result.screenshot.data_base64, 'base64');
|
|
98
|
+
screenshots.push({ ...tag(item), png });
|
|
99
|
+
return { ...tag(item), mounted: true, status: blocked.length ? 'failed' : 'passed', loaded: true,
|
|
100
|
+
markdown_sha256: createHash('sha256').update(result.markdown).digest('hex'),
|
|
101
|
+
screenshot_sha256: sha256(png),
|
|
102
|
+
screenshot_width: result.screenshot.width, screenshot_height: result.screenshot.height,
|
|
103
|
+
rendered_at: result.rendered_at, blocked_calls: blocked };
|
|
104
|
+
})));
|
|
105
|
+
}
|
|
86
106
|
const renders = observations.map((value, index) => {
|
|
87
107
|
if (value.status === 'fulfilled') return value.value;
|
|
88
|
-
const
|
|
89
|
-
|
|
108
|
+
const item = brokers[index], where = tag(item), place = placeOf(item);
|
|
109
|
+
const shot = value.reason?.code === 'render_not_ready' ? value.reason.screenshot : null;
|
|
110
|
+
if (value.reason?.code === 'render_view_failed') {
|
|
111
|
+
return { ...where, mounted: false, status: 'failed', error: 'render_view_failed', loaded: false,
|
|
112
|
+
message: `At ${place} the view's code failed before it showed anything${value.reason.reason ? `: ${value.reason.reason}` : '.'}` };
|
|
113
|
+
}
|
|
114
|
+
if (!shot?.data_base64) return { ...where, mounted: false, status: 'failed', error: value.reason?.code || 'render_failed',
|
|
115
|
+
...(Array.isArray(value.reason?.blocked) && value.reason.blocked.length ? { blocked_calls: value.reason.blocked } : {}) };
|
|
90
116
|
const png = Buffer.from(shot.data_base64, 'base64');
|
|
91
|
-
screenshots.push({
|
|
117
|
+
screenshots.push({ ...where, png });
|
|
92
118
|
const mounted = value.reason.mounted === true;
|
|
93
119
|
const seconds = value.reason.waitedSeconds || Math.round((readyTimeoutMs || 0) / 1000);
|
|
94
|
-
return {
|
|
95
|
-
message: mounted ? `At ${
|
|
96
|
-
: `At ${
|
|
120
|
+
return { ...where, mounted, status: 'failed', error: 'render_not_ready', loaded: false,
|
|
121
|
+
message: mounted ? `At ${place} the view had not finished loading its data after ${seconds} s.`
|
|
122
|
+
: `At ${place} the view had not shown anything after ${seconds} s.`,
|
|
97
123
|
screenshot_sha256: sha256(png), screenshot_width: shot.width, screenshot_height: shot.height,
|
|
98
124
|
blocked_calls: Array.isArray(value.reason.blocked) ? value.reason.blocked : [] };
|
|
99
125
|
});
|
|
100
|
-
|
|
101
|
-
|
|
126
|
+
const order = item => brokers.findIndex(value => value.width === item.width && value.locale === item.locale && value.context === item.context);
|
|
127
|
+
screenshots.sort((left, right) => order(left) - order(right));
|
|
128
|
+
const runtimeCalls = brokers.flatMap(item => item.broker.calls.map(call => ({ ...tag(item), ...call })));
|
|
102
129
|
const passed = renders.every(value => value.status === 'passed') && runtimeCalls.every(call => call.ok);
|
|
103
130
|
// Each distinct fixture reason once (both widths usually hit the same one), ahead of the generic line.
|
|
104
131
|
const fixtureErrors = [...new Map(runtimeCalls.filter(call => !call.ok && call.error)
|
|
105
132
|
.map(call => [call.error, { phase: 'fixture', operation: call.operation,
|
|
106
133
|
...(call.recordKey ? { record_key: call.recordKey } : {}), ...(call.actionId ? { action_id: call.actionId } : {}),
|
|
107
134
|
message: call.error }])).values()].slice(0, 10);
|
|
108
|
-
|
|
109
|
-
|
|
135
|
+
// An image URL the fixtures do not provide is named once, whatever width or language met it.
|
|
136
|
+
const images = [...new Set(renders.flatMap(value => (value.blocked_calls || []).map(call => call.image)).filter(Boolean))];
|
|
137
|
+
if (images.length) fixtureErrors.push({ phase: 'fixture', operation: 'asset',
|
|
138
|
+
message: `The view shows ${images.length === 1 ? 'an image' : `${images.length} images`} its fixtures do not provide (${images.slice(0, 3).join(', ')}${images.length > 3 ? ', ...' : ''}). `
|
|
139
|
+
+ 'Add each URL to "images" in the fixtures, mapped to a picture file next to them: {"images": {"https://example.com/photo.jpg": "./photos/photo.jpg"}}.' });
|
|
140
|
+
const notReady = renders.filter(value => value.error === 'render_not_ready' || value.error === 'render_view_failed')
|
|
141
|
+
.map(value => ({ phase: 'renderer', ...tag(value), message: value.message }));
|
|
110
142
|
const result = { ...diagnostic, status: passed ? 'passed' : 'failed', mounted: renders.every(value => value.mounted),
|
|
111
143
|
fixture_digest: brokers[0].broker.fixtureDigest, renderer_digest: rendererDigest,
|
|
112
|
-
render_count: renders.length, browser_count: 1, renders, runtimeCalls,
|
|
144
|
+
render_count: renders.length, browser_count: 1, ...(named ? { contexts: contexts.map(value => value.name) } : {}), renders, runtimeCalls,
|
|
113
145
|
errors: passed ? [] : [...fixtureErrors, ...notReady, { phase: 'renderer', message: 'At least one width or read-only fixture failed verification.' }] };
|
|
114
146
|
Object.defineProperty(result, 'screenshots', { value: screenshots, enumerable: false });
|
|
115
147
|
// The skeleton is measured only from a view that rendered cleanly, with a renderer that can measure it.
|
|
116
148
|
if (passed && typeof library.buildSkeletonDocument === 'function') {
|
|
117
|
-
const capture = await captureSpaceSkeleton({ library, pool, release, capabilities, timeoutMs, signal, authorizationMode, unavailableActions
|
|
149
|
+
const capture = await captureSpaceSkeleton({ library, pool, release, capabilities, timeoutMs, signal, authorizationMode, unavailableActions,
|
|
150
|
+
contexts, named });
|
|
118
151
|
result.skeleton = capture.skeleton;
|
|
119
152
|
Object.defineProperty(result, 'skeletonDocument', { value: capture.document, enumerable: false });
|
|
120
153
|
Object.defineProperty(result, 'pendingScreenshots', { value: capture.screenshots, enumerable: false });
|
|
@@ -136,15 +169,19 @@ const READY_MARGIN_MS = 5_000;
|
|
|
136
169
|
const readyWait = timeoutMs => (timeoutMs - READY_MARGIN_MS >= 1_000 ? timeoutMs - READY_MARGIN_MS : undefined);
|
|
137
170
|
|
|
138
171
|
const sha256 = bytes => createHash('sha256').update(bytes).digest('hex');
|
|
139
|
-
const captureFailure = (width, locale, error) => ({ check: 'capture_failed', severity: 'warning', width, locale,
|
|
172
|
+
const captureFailure = (width, locale, error, extra = {}) => ({ check: 'capture_failed', severity: 'warning', width, locale, ...extra,
|
|
140
173
|
message: `The loading skeleton could not be measured: ${String(error?.code || error?.message || error).slice(0, 300)}` });
|
|
141
174
|
|
|
142
175
|
/**
|
|
143
176
|
* Loading skeleton capture, per width and locale: (1) pending with the view's fallback skeleton gives the region
|
|
144
177
|
* boxes and landmarks, (2) final measures the bones inside those boxes, (3) pending again with the measured bones
|
|
145
178
|
* injected is checked and screenshotted. Never throws: failures become warnings and status `failed`.
|
|
179
|
+
* The first fixture context is the opening view; `context.skeletonParams` and every other context add the regions they
|
|
180
|
+
* show. (4) A context whose params open a list item (`open`) is also drawn with the list answered and the item's record
|
|
181
|
+
* held: the reader's loading state, checked and screenshotted as `state: 'reader'`.
|
|
146
182
|
*/
|
|
147
|
-
async function captureSpaceSkeleton({ library, pool, release, capabilities, timeoutMs, signal, authorizationMode, unavailableActions
|
|
183
|
+
async function captureSpaceSkeleton({ library, pool, release, capabilities, timeoutMs, signal, authorizationMode, unavailableActions,
|
|
184
|
+
contexts = [], named = false }) {
|
|
148
185
|
const findings = [], screenshots = [], combos = [];
|
|
149
186
|
let failed = false, document = null;
|
|
150
187
|
const widths = library.SKELETON_WIDTHS || [390, 1440], locales = library.SKELETON_LOCALES || ['en', 'fr'];
|
|
@@ -153,8 +190,10 @@ async function captureSpaceSkeleton({ library, pool, release, capabilities, time
|
|
|
153
190
|
// view that is wholly editor-only does not exist for the public: it keeps the editors' skeleton.
|
|
154
191
|
const marks = release.manifest.editors_only;
|
|
155
192
|
const audience = marks && !marks.view ? 'public' : 'editor';
|
|
156
|
-
const render = (width, options, params) => library.renderView({ broker: createSpaceFixtureBroker({ release, capabilities, width,
|
|
157
|
-
outputs: ['markdown'], authorizationMode, unavailableActions, params, audience }), pool, outputs: ['markdown'], width, timeoutMs, signal, ...options });
|
|
193
|
+
const render = (width, options, params, context) => library.renderView({ broker: createSpaceFixtureBroker({ release, capabilities, width,
|
|
194
|
+
outputs: ['markdown'], authorizationMode, unavailableActions, params, audience, context }), pool, outputs: ['markdown'], width, timeoutMs, signal, ...options });
|
|
195
|
+
// The pending landmarks end a region's measurement at the next one below it (a section head under a KPI row).
|
|
196
|
+
const measuring = (regions, pending) => ({ measure: { regions, landmarks: pending?.landmarks || [] } });
|
|
158
197
|
// Both widths of one locale run together: the pool holds two renders at a time.
|
|
159
198
|
const each = async (step) => {
|
|
160
199
|
for (const locale of locales) {
|
|
@@ -174,28 +213,30 @@ async function captureSpaceSkeleton({ library, pool, release, capabilities, time
|
|
|
174
213
|
combo.regions = combo.first?.pending?.static ? [] : (combo.first?.pending?.regions || []);
|
|
175
214
|
const valid = combo.regions.filter(region => region.valid);
|
|
176
215
|
if (!valid.length) return;
|
|
177
|
-
combo.final = (await render(combo.width, {
|
|
216
|
+
combo.final = (await render(combo.width, { ...measuring(valid, combo.first.pending), locale: combo.locale })).skeleton_measure;
|
|
178
217
|
});
|
|
179
218
|
const measurements = {};
|
|
180
219
|
for (const combo of combos) if (combo.final) (measurements[combo.width] ||= {})[combo.locale] = { regions: combo.final.regions };
|
|
181
220
|
// Regions a view shows only under other params (a tab it can open on), declared in the fixtures as
|
|
182
|
-
// context.skeletonParams: measured the same way and added beside the opening
|
|
183
|
-
// is a warning and never drops the regions already measured.
|
|
184
|
-
|
|
221
|
+
// context.skeletonParams, or in another fixture context: measured the same way and added beside the opening
|
|
222
|
+
// view's own regions. A failure here is a warning and never drops the regions already measured.
|
|
223
|
+
const extras = [...fixtureSkeletonParams(release).map(params => ({ params })),
|
|
224
|
+
...contexts.slice(1).map(value => ({ context: value.name }))];
|
|
225
|
+
for (const { params, context } of extras) {
|
|
185
226
|
for (const locale of locales) {
|
|
186
227
|
const settled = await Promise.allSettled(widths.map(async (width) => {
|
|
187
|
-
const pending = (await render(width, { pending: true, locale }, params))?.pending;
|
|
228
|
+
const pending = (await render(width, { pending: true, locale }, params, context))?.pending;
|
|
188
229
|
const known = new Set((measurements[width]?.[locale]?.regions || []).map(region => region.key));
|
|
189
230
|
const valid = pending?.static ? [] : (pending?.regions || []).filter(region => region.valid && !known.has(region.key));
|
|
190
231
|
if (!valid.length) return;
|
|
191
|
-
const final = (await render(width, {
|
|
232
|
+
const final = (await render(width, { ...measuring(valid, pending), locale }, params, context)).skeleton_measure;
|
|
192
233
|
const added = (final?.regions || []).filter(region => !known.has(region.key));
|
|
193
234
|
if (!added.length) return;
|
|
194
235
|
const entry = ((measurements[width] ||= {})[locale] ||= { regions: [] });
|
|
195
236
|
entry.regions = [...entry.regions, ...added];
|
|
196
237
|
}));
|
|
197
238
|
settled.forEach((value, index) => {
|
|
198
|
-
if (value.status === 'rejected') findings.push(captureFailure(widths[index], locale, value.reason));
|
|
239
|
+
if (value.status === 'rejected') findings.push(captureFailure(widths[index], locale, value.reason, context && named ? { context } : {}));
|
|
199
240
|
});
|
|
200
241
|
}
|
|
201
242
|
}
|
|
@@ -221,6 +262,20 @@ async function captureSpaceSkeleton({ library, pool, release, capabilities, time
|
|
|
221
262
|
} catch (error) {
|
|
222
263
|
failed = true; findings.push(captureFailure(null, null, error));
|
|
223
264
|
}
|
|
265
|
+
// The reader's loading state: the list answers, the opened item's reads stay held. A view that opens nothing
|
|
266
|
+
// with these params is static there and adds nothing.
|
|
267
|
+
const readers = [];
|
|
268
|
+
for (const value of contexts.filter(item => item.open)) {
|
|
269
|
+
const extra = { state: 'reader', ...(named ? { context: value.name } : {}) };
|
|
270
|
+
for (const locale of locales) {
|
|
271
|
+
const settled = await Promise.allSettled(widths.map(width => render(width, { pending: { hold: READER_HOLDS }, locale,
|
|
272
|
+
...(document ? { skeleton: document } : {}) }, undefined, value.name)));
|
|
273
|
+
settled.forEach((result, index) => {
|
|
274
|
+
if (result.status === 'rejected') { findings.push(captureFailure(widths[index], locale, result.reason, extra)); return; }
|
|
275
|
+
readers.push({ width: widths[index], locale, extra, shown: result.value });
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}
|
|
224
279
|
for (const combo of combos) {
|
|
225
280
|
const shown = combo.checked || combo.first;
|
|
226
281
|
if (!shown) continue;
|
|
@@ -233,7 +288,16 @@ async function captureSpaceSkeleton({ library, pool, release, capabilities, time
|
|
|
233
288
|
const png = Buffer.from(shown.screenshot.data_base64, 'base64');
|
|
234
289
|
screenshots.push({ width: combo.width, locale: combo.locale, png, sha256: sha256(png) });
|
|
235
290
|
}
|
|
291
|
+
for (const { width, locale, extra, shown } of readers) {
|
|
292
|
+
if (!shown?.pending || shown.pending.static) continue;
|
|
293
|
+
try {
|
|
294
|
+
findings.push(...library.runSkeletonChecks({ width, locale, pending: shown.pending, regions: [] }).map(finding => ({ ...finding, ...extra })));
|
|
295
|
+
} catch (error) { findings.push(captureFailure(width, locale, error, extra)); }
|
|
296
|
+
if (!shown.screenshot?.data_base64) continue;
|
|
297
|
+
const png = Buffer.from(shown.screenshot.data_base64, 'base64');
|
|
298
|
+
screenshots.push({ width, locale, ...extra, png, sha256: sha256(png) });
|
|
299
|
+
}
|
|
236
300
|
const status = document ? 'captured' : failed ? 'failed' : 'none';
|
|
237
301
|
return { document, screenshots, skeleton: { status, audience, regions: document ? Object.keys(document.regions).sort() : [], findings,
|
|
238
|
-
pending_screenshots: screenshots.map(({
|
|
302
|
+
pending_screenshots: screenshots.map(({ png: _png, ...value }) => value) } };
|
|
239
303
|
}
|
|
@@ -38,7 +38,23 @@ const OPS = new Set(['equals', 'not_equals', 'in', 'contains', 'not_contains', '
|
|
|
38
38
|
const PAGE_COLUMN_OPS = { record_key: ['equals', 'not_equals', 'in'], id: ['equals', 'not_equals', 'in'],
|
|
39
39
|
content_type: ['equals', 'not_equals', 'is_empty', 'is_not_empty'], file_type: ['equals', 'not_equals', 'is_empty', 'is_not_empty'],
|
|
40
40
|
title: ['equals', 'not_equals', 'is_empty', 'is_not_empty'] };
|
|
41
|
-
const PAGE_PROPERTY_OPS = { select: ['equals', 'not_equals', 'is_empty', 'is_not_empty'], checkbox: ['equals', 'not_equals'] };
|
|
41
|
+
const PAGE_PROPERTY_OPS = { select: ['equals', 'not_equals', 'in', 'is_empty', 'is_not_empty'], checkbox: ['equals', 'not_equals'] };
|
|
42
|
+
// `in` lists up to 500 record ids, or up to 100 options of a select or status property (in_list_limit in
|
|
43
|
+
// server/lib/native_data_query.py).
|
|
44
|
+
const IN_LIMITS = { column: [500, 'record ids'], property: [100, 'options'] };
|
|
45
|
+
// A filter nests at most 12 levels and holds at most 200 conditions (normalize_native_filter).
|
|
46
|
+
const MAX_FILTER_DEPTH = 12;
|
|
47
|
+
const MAX_FILTER_CONDITIONS = 200;
|
|
48
|
+
|
|
49
|
+
function inLimit(field) {
|
|
50
|
+
return IN_LIMITS[plain(field) && 'column' in field ? 'column' : 'property'];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// What an `in` adds to the filter: a property `in` listing more than one value reads as an `or` of them, so it adds
|
|
54
|
+
// that many conditions and one level; a column `in` adds nothing (in_expansion in server/lib/native_data_query.py).
|
|
55
|
+
function inExpansion(field, value) {
|
|
56
|
+
return plain(field) && !('column' in field) && Array.isArray(value) && value.length > 1 ? value.length : 0;
|
|
57
|
+
}
|
|
42
58
|
const EMPTY_OPS = new Set(['is_empty', 'is_not_empty']);
|
|
43
59
|
const KIND_ALIASES = { phone: 'phone_number', string: 'text' };
|
|
44
60
|
const CRON_BOUNDS = [[0, 59], [0, 23], [1, 31], [1, 12], [0, 7]];
|
|
@@ -197,9 +213,9 @@ function checkPlaceholder(value, params, collection, where) {
|
|
|
197
213
|
if (property !== undefined && params[name].type !== 'record') throw usageError(`${where}: only record params have properties, such as {${name}}.`);
|
|
198
214
|
}
|
|
199
215
|
|
|
200
|
-
function walkFilter(node, visit, where, depth = 0, budget = { left:
|
|
216
|
+
function walkFilter(node, visit, where, depth = 0, budget = { left: MAX_FILTER_CONDITIONS }) {
|
|
201
217
|
budget.left -= 1;
|
|
202
|
-
if (depth >
|
|
218
|
+
if (depth > MAX_FILTER_DEPTH || budget.left < 0) throw usageError(`${where}: the filter is too complex; use fewer conditions.`);
|
|
203
219
|
if (depth === 0 && plain(node) && !Object.keys(node).length) return;
|
|
204
220
|
if (!plain(node)) throw usageError(`${where}: a filter is an object.`);
|
|
205
221
|
for (const group of ['and', 'or']) {
|
|
@@ -215,6 +231,13 @@ function walkFilter(node, visit, where, depth = 0, budget = { left: 200 }) {
|
|
|
215
231
|
|| typeof Object.values(field)[0] !== 'string' || !OPS.has(node.op)) {
|
|
216
232
|
throw usageError(`${where}: each condition is { field: { property }, op, value } in the native filter language.`);
|
|
217
233
|
}
|
|
234
|
+
// A list over its length limit is left to visit(), which names the limit instead of calling the filter too complex.
|
|
235
|
+
const fits = !Array.isArray(node.value) || node.value.length <= inLimit(field)[0];
|
|
236
|
+
const extra = node.op === 'in' && fits ? inExpansion(field, node.value) : 0;
|
|
237
|
+
budget.left -= extra;
|
|
238
|
+
if (extra && (depth + 1 > MAX_FILTER_DEPTH || budget.left < 0)) {
|
|
239
|
+
throw usageError(`${where}: the filter is too complex; use fewer conditions.`);
|
|
240
|
+
}
|
|
218
241
|
visit(node);
|
|
219
242
|
}
|
|
220
243
|
|
|
@@ -268,8 +291,9 @@ function validatePage(name, page, resource) {
|
|
|
268
291
|
return;
|
|
269
292
|
}
|
|
270
293
|
if (!('value' in condition)) throw usageError(`${where}: ${condition.op} needs a value.`);
|
|
271
|
-
|
|
272
|
-
|
|
294
|
+
const [cap, items] = inLimit(condition.field);
|
|
295
|
+
if (condition.op === 'in' && (!Array.isArray(condition.value) || condition.value.length < 1 || condition.value.length > cap)) {
|
|
296
|
+
throw usageError(`${where}: in takes a list of 1 to ${cap} ${items}.`);
|
|
273
297
|
}
|
|
274
298
|
for (const value of condition.op === 'in' ? condition.value : [condition.value]) {
|
|
275
299
|
// Fixed values only: neither {param} nor {{param}} is ever bound in a page rule (the server refuses both).
|
|
@@ -315,6 +339,15 @@ function validateShows(name, declaration, params, resources, collection) {
|
|
|
315
339
|
throw usageError(`${where}: when names a declared boolean param.`);
|
|
316
340
|
}
|
|
317
341
|
if (!('value' in condition)) return;
|
|
342
|
+
if (condition.op === 'in') {
|
|
343
|
+
// A property `in` (select or status) always lists 1 to 100 values; a column `in` given as a list lists 1 to
|
|
344
|
+
// 500 (a scalar there stays as before). Each value is fixed or one placeholder.
|
|
345
|
+
const [cap, items] = inLimit(condition.field);
|
|
346
|
+
const listed = condition.value;
|
|
347
|
+
if ((Array.isArray(listed) || !('column' in condition.field)) && (!Array.isArray(listed) || listed.length < 1 || listed.length > cap)) {
|
|
348
|
+
throw usageError(`${where}: in takes a list of 1 to ${cap} ${items}.`);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
318
351
|
const values = condition.op === 'in' && Array.isArray(condition.value) ? condition.value : [condition.value];
|
|
319
352
|
values.forEach(value => checkPlaceholder(value, params, collection, where));
|
|
320
353
|
}, where);
|
package/src/runtime/telemetry.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { oauthGrantOnRetiredAddress } from './profiles.js';
|
|
2
|
+
|
|
1
3
|
const ERROR_CATEGORIES = new Map([
|
|
2
4
|
[2, 'usage'],
|
|
3
5
|
[3, 'auth'],
|
|
@@ -64,10 +66,21 @@ export async function reportCliCommand({
|
|
|
64
66
|
) {
|
|
65
67
|
return false;
|
|
66
68
|
}
|
|
69
|
+
// An OAuth token only goes to the API that issued it: a grant the server
|
|
70
|
+
// proved dead routes the profile to stable (CLI-035), not its token.
|
|
71
|
+
// A grant minted for a retired API name goes nowhere (CLI-038).
|
|
72
|
+
if (runtime.credentialKind === 'oauth' && oauthGrantOnRetiredAddress({
|
|
73
|
+
oauth_issuer: runtime.oauthIssuer,
|
|
74
|
+
oauth_resource: runtime.oauthResource,
|
|
75
|
+
oauth_access_token: runtime.jwt,
|
|
76
|
+
})) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
const apiBase = (runtime.credentialKind === 'oauth' && runtime.oauthApiBase) || runtime.apiBase;
|
|
67
80
|
const controller = new AbortController();
|
|
68
81
|
const timeout = setTimeout(() => controller.abort(), 1_500);
|
|
69
82
|
try {
|
|
70
|
-
const response = await fetchImpl(`${
|
|
83
|
+
const response = await fetchImpl(`${apiBase}/cli_telemetry`, {
|
|
71
84
|
method: 'POST',
|
|
72
85
|
headers: {
|
|
73
86
|
Authorization: `Bearer ${runtime.jwt}`,
|
package/src/runtime/transport.js
CHANGED
|
@@ -2,6 +2,8 @@ import { randomUUID } from 'node:crypto';
|
|
|
2
2
|
import { createReadStream } from 'node:fs';
|
|
3
3
|
import { dirname } from 'node:path';
|
|
4
4
|
import { CliError, EXIT_CODES } from './errors.js';
|
|
5
|
+
import { agentIdentityHeaders } from './agent-identity.js';
|
|
6
|
+
import { deadlineDispatcher, isTransportTimeout, networkCauseCode } from './http-agent.js';
|
|
5
7
|
import {
|
|
6
8
|
credentialIsExpired,
|
|
7
9
|
getJwtExpiration,
|
|
@@ -336,8 +338,16 @@ export async function httpRequest({
|
|
|
336
338
|
// config write lock, instead of racing on a 401 retry.
|
|
337
339
|
let currentProfile;
|
|
338
340
|
if (runtime.credentialKind === 'oauth') {
|
|
341
|
+
const storedGrant = getProfile(loadConfig(), runtime.profileName);
|
|
339
342
|
if (requireAuth && credentialIsExpired(runtime, {
|
|
340
343
|
oauth_access_expires_at: runtime.oauthAccessExpiresAt,
|
|
344
|
+
// The stored refusal evidence (oauthGrantIsDead) of the same grant.
|
|
345
|
+
oauth_refresh_token: storedGrant.oauth_refresh_token,
|
|
346
|
+
oauth_refresh_rejected_for: storedGrant.oauth_refresh_rejected_for,
|
|
347
|
+
// A grant minted for a retired API name is spent too (CLI-038).
|
|
348
|
+
oauth_issuer: storedGrant.oauth_issuer,
|
|
349
|
+
oauth_resource: storedGrant.oauth_resource,
|
|
350
|
+
oauth_access_token: storedGrant.oauth_access_token,
|
|
341
351
|
})) {
|
|
342
352
|
await refreshOAuthCredential(runtime);
|
|
343
353
|
}
|
|
@@ -351,6 +361,8 @@ export async function httpRequest({
|
|
|
351
361
|
throw createExpiredAuthError(runtime);
|
|
352
362
|
}
|
|
353
363
|
|
|
364
|
+
// The agent making the call, when it declares itself (agent-identity.js); a bad declaration goes as written for the backend to judge.
|
|
365
|
+
const agentHeaders = agentIdentityHeaders(runtime);
|
|
354
366
|
let controller = new AbortController();
|
|
355
367
|
let timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
356
368
|
const requestId = `req_${randomUUID().replace(/-/g, '')}`;
|
|
@@ -363,6 +375,7 @@ export async function httpRequest({
|
|
|
363
375
|
const headers = {
|
|
364
376
|
'X-Notis-CLI-Version': runtime.cliVersion,
|
|
365
377
|
'X-Notis-Request-Id': requestId,
|
|
378
|
+
...agentHeaders,
|
|
366
379
|
};
|
|
367
380
|
if (spacesProtocol) headers['X-Notis-Spaces-Protocol'] = String(SPACES_PROTOCOL);
|
|
368
381
|
if (!multipart) {
|
|
@@ -389,6 +402,8 @@ export async function httpRequest({
|
|
|
389
402
|
};
|
|
390
403
|
};
|
|
391
404
|
|
|
405
|
+
// The AbortController above is this request's one deadline (http-agent.js).
|
|
406
|
+
const dispatcher = await deadlineDispatcher();
|
|
392
407
|
try {
|
|
393
408
|
let requestBody = resolveBody();
|
|
394
409
|
let response = await fetch(`${runtime.apiBase}${path}`, {
|
|
@@ -396,6 +411,7 @@ export async function httpRequest({
|
|
|
396
411
|
headers: { ...headers, ...requestBody.headers },
|
|
397
412
|
body: requestBody.body,
|
|
398
413
|
signal: controller.signal,
|
|
414
|
+
...(dispatcher ? { dispatcher } : {}),
|
|
399
415
|
...(requestBody.duplex ? { duplex: requestBody.duplex } : {}),
|
|
400
416
|
});
|
|
401
417
|
|
|
@@ -423,6 +439,7 @@ export async function httpRequest({
|
|
|
423
439
|
headers: { ...headers, ...requestBody.headers },
|
|
424
440
|
body: requestBody.body,
|
|
425
441
|
signal: controller.signal,
|
|
442
|
+
...(dispatcher ? { dispatcher } : {}),
|
|
426
443
|
...(requestBody.duplex ? { duplex: requestBody.duplex } : {}),
|
|
427
444
|
});
|
|
428
445
|
payloadReadError = null;
|
|
@@ -475,24 +492,34 @@ export async function httpRequest({
|
|
|
475
492
|
throw error;
|
|
476
493
|
}
|
|
477
494
|
|
|
478
|
-
|
|
495
|
+
// This attempt's own limit, which a command may set longer or a retry shorter than --timeout-ms.
|
|
496
|
+
if (error?.name === 'AbortError' || isTransportTimeout(error)) {
|
|
497
|
+
// Our own deadline names its limit; a transport that stopped first (a checkout without undici) names its code.
|
|
498
|
+
const limit = error?.name === 'AbortError'
|
|
499
|
+
? `within ${timeoutMs >= 1000 ? `${Math.round(timeoutMs / 1000)} s` : `${timeoutMs} ms`}` : `before the transport gave up (${networkCauseCode(error)})`;
|
|
479
500
|
throw new CliError({
|
|
480
501
|
code: 'network_timeout',
|
|
481
|
-
message:
|
|
502
|
+
message: `${path} got no answer from ${runtime.apiBase} ${limit} (request ${requestId}).`,
|
|
482
503
|
exitCode: EXIT_CODES.network,
|
|
483
504
|
retryable: true,
|
|
505
|
+
details: { path, request_id: requestId, timeout_ms: timeoutMs },
|
|
484
506
|
hints: [
|
|
485
507
|
{ command: 'notis doctor', reason: 'Check API reachability' },
|
|
486
|
-
|
|
508
|
+
// A retry's attempt gets only what is left of the budget: never suggest less than the limit already set.
|
|
509
|
+
{ command: `--timeout-ms ${Math.max(timeoutMs, runtime.timeoutMs || 0) * 2}`, reason: 'Retry with a longer timeout' },
|
|
487
510
|
],
|
|
488
511
|
});
|
|
489
512
|
}
|
|
490
513
|
|
|
514
|
+
// fetch says only "fetch failed": the network code under it (ECONNRESET, ENOTFOUND, ...) is what a user can act on.
|
|
515
|
+
const causeCode = networkCauseCode(error);
|
|
516
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
491
517
|
throw new CliError({
|
|
492
518
|
code: 'network_error',
|
|
493
|
-
message:
|
|
519
|
+
message: `${path} failed before ${runtime.apiBase} answered: ${message}${causeCode && !message.includes(causeCode) ? ` (${causeCode})` : ''} (request ${requestId}).`,
|
|
494
520
|
exitCode: EXIT_CODES.network,
|
|
495
521
|
retryable: true,
|
|
522
|
+
details: { path, request_id: requestId, ...(causeCode ? { cause_code: causeCode } : {}) },
|
|
496
523
|
cause: error,
|
|
497
524
|
});
|
|
498
525
|
}
|
package/src/runtime/upsell.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
// plus Cloud Computer overrides); this module only finds it in a payload and
|
|
4
4
|
// turns it into the lines and hints a person or agent acts on.
|
|
5
5
|
|
|
6
|
+
import { portalOriginForApiHost } from './api-hosts.js';
|
|
7
|
+
|
|
6
8
|
const UPSELL_CODES = new Set([
|
|
7
9
|
'entitlement_upgrade_required',
|
|
8
10
|
'cloud_computer_team_limit',
|
|
@@ -10,11 +12,6 @@ const UPSELL_CODES = new Set([
|
|
|
10
12
|
|
|
11
13
|
const NESTED_KEYS = ['error', 'details', 'data', 'result', 'response', 'entitlement_access'];
|
|
12
14
|
|
|
13
|
-
const PORTAL_ORIGINS = {
|
|
14
|
-
'api.notis.ai': 'https://app.notis.ai',
|
|
15
|
-
'api-nightly.notis.ai': 'https://app-nightly.notis.ai',
|
|
16
|
-
'api-beta.notis.ai': 'https://app-nightly.notis.ai',
|
|
17
|
-
};
|
|
18
15
|
|
|
19
16
|
function isUpsellBody(value) {
|
|
20
17
|
if (!value || typeof value !== 'object' || Array.isArray(value)) return false;
|
|
@@ -66,7 +63,7 @@ export function findUpsell(value, depth = 0) {
|
|
|
66
63
|
|
|
67
64
|
export function portalOriginFor(apiBase) {
|
|
68
65
|
try {
|
|
69
|
-
return
|
|
66
|
+
return portalOriginForApiHost(new URL(apiBase).hostname);
|
|
70
67
|
} catch {
|
|
71
68
|
return null;
|
|
72
69
|
}
|
|
@@ -28,8 +28,13 @@ export async function renderViewWithCliRuntime({ runtime, url, outputs = ['markd
|
|
|
28
28
|
await broker.complete(result, { signal });
|
|
29
29
|
}
|
|
30
30
|
catch (error) {
|
|
31
|
+
// The stage a render stopped at (a fixed step name, never page content) makes a rare failure diagnosable.
|
|
31
32
|
if (error instanceof library.ViewRenderError) throw new CliError({ code: error.code,
|
|
32
|
-
message: error.message, exitCode: EXIT_CODES.backend, retryable: error.status >= 500 || error.status === 429, cause: error
|
|
33
|
+
message: error.message, exitCode: EXIT_CODES.backend, retryable: error.status >= 500 || error.status === 429, cause: error,
|
|
34
|
+
details: { ...(typeof error.stage === 'string' && /^[a-z_]{1,40}$/.test(error.stage) ? { stage: error.stage } : {}),
|
|
35
|
+
// A refused read names its action and reason code; a failed view's reason is page text and stays out.
|
|
36
|
+
...(error.code === 'render_read_unavailable' ? { ...(typeof error.actionId === 'string' ? { action_id: error.actionId } : {}),
|
|
37
|
+
...(typeof error.reason === 'string' && /^[a-z_]{1,40}$/.test(error.reason) ? { reason: error.reason } : {}) } : {}) } });
|
|
33
38
|
throw error;
|
|
34
39
|
}
|
|
35
40
|
if (!directory) return { result, artifacts: null };
|
package/src/skill-sync-worker.js
CHANGED
|
@@ -4,13 +4,17 @@ import { homedir } from 'node:os';
|
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { getCurrentProfileName, getProfile, loadConfig, resolveRuntimeProfile } from './runtime/profiles.js';
|
|
6
6
|
import { ensureFreshOAuthCredential } from './runtime/oauth.js';
|
|
7
|
+
import { renamedRetiredApiOrigin } from './runtime/api-hosts.js';
|
|
7
8
|
import { runSkillSync, fetchSyncSettings } from '../dist/skill-sync/index.js';
|
|
8
9
|
import { withSkillSyncLock } from './runtime/sync-skills.js';
|
|
9
10
|
|
|
10
11
|
// The server rejected the stored sign-in itself. Presenting it again can only
|
|
11
12
|
// fail the same way, so the worker waits for the sign-in to change instead of
|
|
12
13
|
// asking every minute (docs/no-dead-ends.md).
|
|
13
|
-
|
|
14
|
+
// A grant minted for a retired API name (CLI-038) is refused for good too.
|
|
15
|
+
const REJECTED_SIGN_IN_CODES = new Set([
|
|
16
|
+
'invalid_grant', 'invalid_client', 'unauthorized_client', 'oauth_grant_retired_address',
|
|
17
|
+
]);
|
|
14
18
|
|
|
15
19
|
function currentCliProfile() {
|
|
16
20
|
try {
|
|
@@ -42,7 +46,14 @@ export async function runAutomaticSkillSync({ profile, apiBase, userId }, {
|
|
|
42
46
|
currentProfile = currentCliProfile,
|
|
43
47
|
} = {}) {
|
|
44
48
|
const runtime = resolveRuntime({ profile }, { requireAuth: true });
|
|
45
|
-
|
|
49
|
+
// A service installed on a retired API name serves the same API under its
|
|
50
|
+
// current name, which the grant now routes to (CLI-038).
|
|
51
|
+
const current = value => renamedRetiredApiOrigin(value) || value;
|
|
52
|
+
const boundApiBase = current(apiBase);
|
|
53
|
+
// The service is bound to the API of the grant it was installed with. A
|
|
54
|
+
// grant the server proved dead routes like a signed-out profile, so compare
|
|
55
|
+
// the grant's own API: its refresh then reports the refusal code.
|
|
56
|
+
if (runtime.credentialKind !== 'oauth' || current(runtime.oauthApiBase || runtime.apiBase) !== boundApiBase
|
|
46
57
|
|| runtime.oauthUserId !== userId) throw new Error('Automatic skill sync account changed; run notis skills sync to rebind');
|
|
47
58
|
await refresh(runtime);
|
|
48
59
|
const saved = await settings(runtime.apiBase, runtime.jwt);
|
|
@@ -65,10 +65,13 @@ async function start() {
|
|
|
65
65
|
if (!family || !authority.viewerReads.includes(family)) return protocolFailure('Undeclared verification viewer read.');
|
|
66
66
|
return runFixture({ op: 'viewerRead', actionId: operation, ok: null }, { viewer_read: { operation, input } });
|
|
67
67
|
} : undefined,
|
|
68
|
-
shown: Object.values(authority.shows || {}).some(list => 'database' in list) ? <T,>(name: string, params: Record<string, unknown> = {}
|
|
68
|
+
shown: Object.values(authority.shows || {}).some(list => 'database' in list) ? <T,>(name: string, params: Record<string, unknown> = {},
|
|
69
|
+
options: { pageSize?: number; offset?: number } = {}): Promise<T> => {
|
|
69
70
|
const list = authority.shows && Object.hasOwn(authority.shows, name) ? authority.shows[name] : null;
|
|
70
71
|
if (!list || !('database' in list)) return protocolFailure('Undeclared verification list.');
|
|
71
|
-
|
|
72
|
+
// The fixture holds the whole list; the page asked for is cut from it, as the host does live.
|
|
73
|
+
const page = { ...(options.pageSize ? { page_size: options.pageSize } : {}), ...(options.offset ? { offset: options.offset } : {}) };
|
|
74
|
+
return runFixture({ op: 'shown', actionId: name, ok: null }, { shown: { name, params, options: page } });
|
|
72
75
|
} : undefined,
|
|
73
76
|
documentBody(request: SpaceDocumentBodyRequest) {
|
|
74
77
|
return runFixture({ op: 'documentBody', actionId: request?.readAction, ok: null }, { document_body: request });
|
|
@@ -101,7 +104,7 @@ async function start() {
|
|
|
101
104
|
const host = document.createElement('div'); host.style.cssText = 'min-height:100vh;height:100vh';
|
|
102
105
|
const shadow = host.attachShadow({ mode: 'open' });
|
|
103
106
|
const css = document.createElement('style'); css.textContent = snapshot.css; shadow.appendChild(css);
|
|
104
|
-
NotisSDKUI.adoptToolkitStyles(shadow);
|
|
107
|
+
NotisSDKUI.adoptToolkitStyles(shadow, { cascade: NotisSDKUI.toolkitCascadeFor(snapshot.css) });
|
|
105
108
|
const mount = document.createElement('div'); mount.setAttribute('data-notis-app-mount', 'true');
|
|
106
109
|
mount.style.cssText = 'min-height:0;height:100%'; shadow.appendChild(mount);
|
|
107
110
|
document.body.appendChild(host);
|