@notis_ai/cli 0.2.28 → 0.2.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -8
- package/dist/agent-hooks/notis-agent-hook.mjs +1476 -712
- 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-spaces/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-spaces/references/release.md +6 -5
- package/dist/base-skills/notis-spaces/references/sdk.md +86 -14
- package/dist/sdk/src/components/NotisCommentBoundary.tsx +29 -96
- package/dist/sdk/src/components/NotisSelectionBoundary.tsx +3 -8
- package/dist/sdk/src/components/SelectionActionBar.tsx +144 -23
- package/dist/sdk/src/components/selectionId.ts +6 -0
- package/dist/sdk/src/hooks/useThreadItem.ts +56 -0
- package/dist/sdk/src/index.ts +6 -1
- package/dist/sdk/src/runtime.ts +13 -1
- package/dist/sdk/src/space.ts +230 -0
- package/dist/skill-sync-worker.mjs +185 -30
- package/dist/space-harness/host.js +260 -114
- package/dist/space-sdk/dist/{chunk-BFGB6XXC.js → chunk-6GJ2BS7B.js} +1 -3
- package/dist/space-sdk/dist/index.js +4 -2
- package/dist/space-sdk/dist/ui.js +19 -14
- package/dist/space-sdk/src/components/NotisCommentBoundary.d.ts +0 -10
- package/dist/space-sdk/src/hooks/useThreadItem.d.ts +28 -0
- package/dist/space-sdk/src/index.d.ts +3 -1
- package/dist/space-sdk/src/runtime.d.ts +13 -1
- package/dist/space-sdk/src/space.ts +230 -0
- package/dist/space-sdk/src/tailwind-candidates.d.ts +505 -22
- package/dist/space-sdk/src/ui/actions/useToast.d.ts +2 -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 +165 -15
- package/dist/space-sdk/src/ui/comments/usePassageComments.d.ts +24 -8
- package/dist/space-sdk/src/ui/index.d.ts +2 -1
- package/dist/space-sdk/src/ui/layout/SidePane.d.ts +6 -1
- package/dist/space-sdk/src/ui/overlay/Tooltip.d.ts +8 -2
- package/dist/space-sdk/src/ui/styles.d.ts +27 -5
- package/dist/view-renderer/dist/host.js +330 -184
- package/dist/view-renderer/src/host.tsx +6 -3
- package/dist/view-renderer/src/renderer.js +62 -3
- package/package.json +3 -3
- package/skills/notis-cli/AGENT_INSTRUCTIONS.md +2 -1
- 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 +57 -23
- package/src/command-specs/tools.js +1 -1
- package/src/runtime/agent-identity.js +187 -0
- package/src/runtime/api-hosts.js +92 -0
- package/src/runtime/app-platform.js +74 -11
- package/src/runtime/channel.js +3 -7
- package/src/runtime/oauth.js +95 -4
- package/src/runtime/profiles.js +200 -41
- package/src/runtime/skill-sync-service.js +4 -5
- package/src/runtime/space-fixture-broker.js +23 -2
- package/src/runtime/space-platform.js +2 -0
- package/src/runtime/space-source.js +66 -1
- package/src/runtime/space-test-server.js +20 -4
- package/src/runtime/space-verification.js +66 -10
- package/src/runtime/telemetry.js +14 -1
- package/src/runtime/transport.js +12 -0
- package/src/runtime/upsell.js +3 -6
- package/src/runtime/view-render.js +3 -1
- package/src/skill-sync-worker.js +13 -2
- package/src/space-harness-host.ts +6 -3
|
@@ -3,7 +3,7 @@ import { createHash } from 'node:crypto';
|
|
|
3
3
|
import { existsSync, readFileSync } from 'node:fs';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { appFilesDigest } from './app-platform.js';
|
|
6
|
-
import { createSpaceFixtureBroker } from './space-fixture-broker.js';
|
|
6
|
+
import { createSpaceFixtureBroker, 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.
|
|
@@ -66,19 +66,42 @@ export async function verifySpaceRelease(release, { capabilities, timeoutMs = 45
|
|
|
66
66
|
await acquire(signal); held = true;
|
|
67
67
|
const library = await loadRenderer(); rendererDigest = library.rendererDigest;
|
|
68
68
|
pool = library.createBrowserPool({ concurrency: 2, maxQueue: 2 });
|
|
69
|
+
// The screenshots kept for the agent are taken once the view has finished loading its data, as `spaces screenshot`
|
|
70
|
+
// waits; a view still loading after the bounded wait keeps a screenshot of what it showed, and says so.
|
|
71
|
+
const readyTimeoutMs = readyWait(timeoutMs);
|
|
72
|
+
const screenshots = [];
|
|
69
73
|
const observations = await Promise.allSettled(brokers.map(async ({ width, broker, stop }) => {
|
|
70
74
|
const cancel = signal ? AbortSignal.any([signal, stop.signal]) : stop.signal;
|
|
71
|
-
const result = await library.renderView({ broker, pool, outputs: ['markdown', 'screenshot'], width, timeoutMs, signal: cancel
|
|
75
|
+
const result = await library.renderView({ broker, pool, outputs: ['markdown', 'screenshot'], width, timeoutMs, signal: cancel,
|
|
76
|
+
...(readyTimeoutMs ? { readyTimeoutMs } : {}) });
|
|
72
77
|
const blocked = result.blocked_calls || [];
|
|
73
|
-
|
|
78
|
+
const png = Buffer.from(result.screenshot.data_base64, 'base64');
|
|
79
|
+
screenshots.push({ width, png });
|
|
80
|
+
return { width, mounted: true, status: blocked.length ? 'failed' : 'passed', loaded: true,
|
|
74
81
|
markdown_sha256: createHash('sha256').update(result.markdown).digest('hex'),
|
|
75
|
-
screenshot_sha256:
|
|
82
|
+
screenshot_sha256: sha256(png),
|
|
76
83
|
screenshot_width: result.screenshot.width, screenshot_height: result.screenshot.height,
|
|
77
84
|
rendered_at: result.rendered_at, blocked_calls: blocked };
|
|
78
85
|
}));
|
|
79
|
-
const renders = observations.map((value, index) =>
|
|
80
|
-
|
|
86
|
+
const renders = observations.map((value, index) => {
|
|
87
|
+
if (value.status === 'fulfilled') return value.value;
|
|
88
|
+
const width = brokers[index].width, shot = value.reason?.code === 'render_not_ready' ? value.reason.screenshot : null;
|
|
89
|
+
if (value.reason?.code === 'render_view_failed') {
|
|
90
|
+
return { width, mounted: false, status: 'failed', error: 'render_view_failed', loaded: false,
|
|
91
|
+
message: `At ${width} px the view's code failed before it showed anything${value.reason.reason ? `: ${value.reason.reason}` : '.'}` };
|
|
92
|
+
}
|
|
93
|
+
if (!shot?.data_base64) return { width, mounted: false, status: 'failed', error: value.reason?.code || 'render_failed' };
|
|
94
|
+
const png = Buffer.from(shot.data_base64, 'base64');
|
|
95
|
+
screenshots.push({ width, png });
|
|
96
|
+
const mounted = value.reason.mounted === true;
|
|
97
|
+
const seconds = value.reason.waitedSeconds || Math.round((readyTimeoutMs || 0) / 1000);
|
|
98
|
+
return { width, mounted, status: 'failed', error: 'render_not_ready', loaded: false,
|
|
99
|
+
message: mounted ? `At ${width} px the view had not finished loading its data after ${seconds} s.`
|
|
100
|
+
: `At ${width} px the view had not shown anything after ${seconds} s.`,
|
|
101
|
+
screenshot_sha256: sha256(png), screenshot_width: shot.width, screenshot_height: shot.height,
|
|
102
|
+
blocked_calls: Array.isArray(value.reason.blocked) ? value.reason.blocked : [] };
|
|
81
103
|
});
|
|
104
|
+
screenshots.sort((left, right) => left.width - right.width);
|
|
82
105
|
const runtimeCalls = brokers.flatMap(({ width, broker }) => broker.calls.map(call => ({ width, ...call })));
|
|
83
106
|
const passed = renders.every(value => value.status === 'passed') && runtimeCalls.every(call => call.ok);
|
|
84
107
|
// Each distinct fixture reason once (both widths usually hit the same one), ahead of the generic line.
|
|
@@ -86,10 +109,13 @@ export async function verifySpaceRelease(release, { capabilities, timeoutMs = 45
|
|
|
86
109
|
.map(call => [call.error, { phase: 'fixture', operation: call.operation,
|
|
87
110
|
...(call.recordKey ? { record_key: call.recordKey } : {}), ...(call.actionId ? { action_id: call.actionId } : {}),
|
|
88
111
|
message: call.error }])).values()].slice(0, 10);
|
|
112
|
+
const notReady = renders.filter(value => value.error === 'render_not_ready' || value.error === 'render_view_failed')
|
|
113
|
+
.map(value => ({ phase: 'renderer', width: value.width, message: value.message }));
|
|
89
114
|
const result = { ...diagnostic, status: passed ? 'passed' : 'failed', mounted: renders.every(value => value.mounted),
|
|
90
115
|
fixture_digest: brokers[0].broker.fixtureDigest, renderer_digest: rendererDigest,
|
|
91
116
|
render_count: renders.length, browser_count: 1, renders, runtimeCalls,
|
|
92
|
-
errors: passed ? [] : [...fixtureErrors, { phase: 'renderer', message: 'At least one width or read-only fixture failed verification.' }] };
|
|
117
|
+
errors: passed ? [] : [...fixtureErrors, ...notReady, { phase: 'renderer', message: 'At least one width or read-only fixture failed verification.' }] };
|
|
118
|
+
Object.defineProperty(result, 'screenshots', { value: screenshots, enumerable: false });
|
|
93
119
|
// The skeleton is measured only from a view that rendered cleanly, with a renderer that can measure it.
|
|
94
120
|
if (passed && typeof library.buildSkeletonDocument === 'function') {
|
|
95
121
|
const capture = await captureSpaceSkeleton({ library, pool, release, capabilities, timeoutMs, signal, authorizationMode, unavailableActions });
|
|
@@ -108,6 +134,10 @@ export async function verifySpaceRelease(release, { capabilities, timeoutMs = 45
|
|
|
108
134
|
}
|
|
109
135
|
}
|
|
110
136
|
const FIXTURE_FAILURE_GRACE_MS = 1_500;
|
|
137
|
+
// How long verify waits for the view to finish loading its data before it shoots what it shows: the render timeout less
|
|
138
|
+
// a margin for that screenshot and the final checks (40 s of the default 45 s, about what the whole render left before).
|
|
139
|
+
const READY_MARGIN_MS = 5_000;
|
|
140
|
+
const readyWait = timeoutMs => (timeoutMs - READY_MARGIN_MS >= 1_000 ? timeoutMs - READY_MARGIN_MS : undefined);
|
|
111
141
|
|
|
112
142
|
const sha256 = bytes => createHash('sha256').update(bytes).digest('hex');
|
|
113
143
|
const captureFailure = (width, locale, error) => ({ check: 'capture_failed', severity: 'warning', width, locale,
|
|
@@ -122,8 +152,13 @@ async function captureSpaceSkeleton({ library, pool, release, capabilities, time
|
|
|
122
152
|
const findings = [], screenshots = [], combos = [];
|
|
123
153
|
let failed = false, document = null;
|
|
124
154
|
const widths = library.SKELETON_WIDTHS || [390, 1440], locales = library.SKELETON_LOCALES || ['en', 'fr'];
|
|
125
|
-
|
|
126
|
-
|
|
155
|
+
// One skeleton is shown to everyone who opens the Space, Site visitors included. When the Space marks parts of its
|
|
156
|
+
// view editor-only, it is measured from the view the public sees, so it never draws the editors' page for them. A
|
|
157
|
+
// view that is wholly editor-only does not exist for the public: it keeps the editors' skeleton.
|
|
158
|
+
const marks = release.manifest.editors_only;
|
|
159
|
+
const audience = marks && !marks.view ? 'public' : 'editor';
|
|
160
|
+
const render = (width, options, params) => library.renderView({ broker: createSpaceFixtureBroker({ release, capabilities, width,
|
|
161
|
+
outputs: ['markdown'], authorizationMode, unavailableActions, params, audience }), pool, outputs: ['markdown'], width, timeoutMs, signal, ...options });
|
|
127
162
|
// Both widths of one locale run together: the pool holds two renders at a time.
|
|
128
163
|
const each = async (step) => {
|
|
129
164
|
for (const locale of locales) {
|
|
@@ -147,6 +182,27 @@ async function captureSpaceSkeleton({ library, pool, release, capabilities, time
|
|
|
147
182
|
});
|
|
148
183
|
const measurements = {};
|
|
149
184
|
for (const combo of combos) if (combo.final) (measurements[combo.width] ||= {})[combo.locale] = { regions: combo.final.regions };
|
|
185
|
+
// Regions a view shows only under other params (a tab it can open on), declared in the fixtures as
|
|
186
|
+
// context.skeletonParams: measured the same way and added beside the opening view's own regions. A failure here
|
|
187
|
+
// is a warning and never drops the regions already measured.
|
|
188
|
+
for (const params of fixtureSkeletonParams(release)) {
|
|
189
|
+
for (const locale of locales) {
|
|
190
|
+
const settled = await Promise.allSettled(widths.map(async (width) => {
|
|
191
|
+
const pending = (await render(width, { pending: true, locale }, params))?.pending;
|
|
192
|
+
const known = new Set((measurements[width]?.[locale]?.regions || []).map(region => region.key));
|
|
193
|
+
const valid = pending?.static ? [] : (pending?.regions || []).filter(region => region.valid && !known.has(region.key));
|
|
194
|
+
if (!valid.length) return;
|
|
195
|
+
const final = (await render(width, { measure: { regions: valid }, locale }, params)).skeleton_measure;
|
|
196
|
+
const added = (final?.regions || []).filter(region => !known.has(region.key));
|
|
197
|
+
if (!added.length) return;
|
|
198
|
+
const entry = ((measurements[width] ||= {})[locale] ||= { regions: [] });
|
|
199
|
+
entry.regions = [...entry.regions, ...added];
|
|
200
|
+
}));
|
|
201
|
+
settled.forEach((value, index) => {
|
|
202
|
+
if (value.status === 'rejected') findings.push(captureFailure(widths[index], locale, value.reason));
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
150
206
|
const app = release.files[release.manifest.bundle?.js || 'bundle/app.js'];
|
|
151
207
|
if (Object.keys(measurements).length && typeof app === 'string') {
|
|
152
208
|
document = library.buildSkeletonDocument({ sourceHash: sha256(Buffer.from(app, 'base64')), measurements });
|
|
@@ -182,6 +238,6 @@ async function captureSpaceSkeleton({ library, pool, release, capabilities, time
|
|
|
182
238
|
screenshots.push({ width: combo.width, locale: combo.locale, png, sha256: sha256(png) });
|
|
183
239
|
}
|
|
184
240
|
const status = document ? 'captured' : failed ? 'failed' : 'none';
|
|
185
|
-
return { document, screenshots, skeleton: { status, regions: document ? Object.keys(document.regions).sort() : [], findings,
|
|
241
|
+
return { document, screenshots, skeleton: { status, audience, regions: document ? Object.keys(document.regions).sort() : [], findings,
|
|
186
242
|
pending_screenshots: screenshots.map(({ width, locale, sha256: digest }) => ({ width, locale, sha256: digest })) } };
|
|
187
243
|
}
|
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,7 @@ 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';
|
|
5
6
|
import {
|
|
6
7
|
credentialIsExpired,
|
|
7
8
|
getJwtExpiration,
|
|
@@ -336,8 +337,16 @@ export async function httpRequest({
|
|
|
336
337
|
// config write lock, instead of racing on a 401 retry.
|
|
337
338
|
let currentProfile;
|
|
338
339
|
if (runtime.credentialKind === 'oauth') {
|
|
340
|
+
const storedGrant = getProfile(loadConfig(), runtime.profileName);
|
|
339
341
|
if (requireAuth && credentialIsExpired(runtime, {
|
|
340
342
|
oauth_access_expires_at: runtime.oauthAccessExpiresAt,
|
|
343
|
+
// The stored refusal evidence (oauthGrantIsDead) of the same grant.
|
|
344
|
+
oauth_refresh_token: storedGrant.oauth_refresh_token,
|
|
345
|
+
oauth_refresh_rejected_for: storedGrant.oauth_refresh_rejected_for,
|
|
346
|
+
// A grant minted for a retired API name is spent too (CLI-038).
|
|
347
|
+
oauth_issuer: storedGrant.oauth_issuer,
|
|
348
|
+
oauth_resource: storedGrant.oauth_resource,
|
|
349
|
+
oauth_access_token: storedGrant.oauth_access_token,
|
|
341
350
|
})) {
|
|
342
351
|
await refreshOAuthCredential(runtime);
|
|
343
352
|
}
|
|
@@ -351,6 +360,8 @@ export async function httpRequest({
|
|
|
351
360
|
throw createExpiredAuthError(runtime);
|
|
352
361
|
}
|
|
353
362
|
|
|
363
|
+
// The agent making the call, when it declares itself (agent-identity.js); a bad declaration goes as written for the backend to judge.
|
|
364
|
+
const agentHeaders = agentIdentityHeaders(runtime);
|
|
354
365
|
let controller = new AbortController();
|
|
355
366
|
let timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
356
367
|
const requestId = `req_${randomUUID().replace(/-/g, '')}`;
|
|
@@ -363,6 +374,7 @@ export async function httpRequest({
|
|
|
363
374
|
const headers = {
|
|
364
375
|
'X-Notis-CLI-Version': runtime.cliVersion,
|
|
365
376
|
'X-Notis-Request-Id': requestId,
|
|
377
|
+
...agentHeaders,
|
|
366
378
|
};
|
|
367
379
|
if (spacesProtocol) headers['X-Notis-Spaces-Protocol'] = String(SPACES_PROTOCOL);
|
|
368
380
|
if (!multipart) {
|
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,10 @@ 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 } : {} });
|
|
33
35
|
throw error;
|
|
34
36
|
}
|
|
35
37
|
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);
|