@notis_ai/cli 0.2.29 → 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 +1030 -610
- 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 +82 -17
- package/dist/sdk/src/hooks/useThreadItem.ts +56 -0
- package/dist/sdk/src/index.ts +6 -1
- package/dist/sdk/src/runtime.ts +8 -1
- package/dist/sdk/src/space.ts +230 -0
- package/dist/skill-sync-worker.mjs +185 -30
- package/dist/space-harness/host.js +237 -93
- 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 +18 -13
- 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 +8 -1
- package/dist/space-sdk/src/space.ts +230 -0
- package/dist/space-sdk/src/tailwind-candidates.d.ts +492 -14
- 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 +147 -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 +307 -163
- package/dist/view-renderer/src/host.tsx +6 -3
- package/dist/view-renderer/src/renderer.js +25 -2
- 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 +30 -16
- package/src/runtime/agent-identity.js +187 -0
- package/src/runtime/api-hosts.js +92 -0
- 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-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 +5 -1
- 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
|
@@ -4,11 +4,10 @@ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from '
|
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
5
|
import { dirname, join } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { LIVE_API_ORIGINS } from './api-hosts.js';
|
|
7
8
|
import { isValidProfileName, loadConfig } from './profiles.js';
|
|
8
9
|
import { withSkillSyncLock } from './sync-skills.js';
|
|
9
10
|
|
|
10
|
-
// Every live API, current names first, then the beta name nightly answered on.
|
|
11
|
-
const LIVE_API_BASES = ['https://api.notis.ai', 'https://api-nightly.notis.ai', 'https://api-beta.notis.ai'];
|
|
12
11
|
|
|
13
12
|
export const SKILL_SYNC_SERVICE_LABEL = 'ai.notis.skills-sync';
|
|
14
13
|
const bundlePath = fileURLToPath(new URL('../../dist/skill-sync-worker.mjs', import.meta.url));
|
|
@@ -31,7 +30,7 @@ export async function maybeInstallSkillSyncService(runtime, {
|
|
|
31
30
|
} = {}) {
|
|
32
31
|
if (process.platform !== 'darwin' || runtime.credentialKind !== 'oauth'
|
|
33
32
|
|| config.current_profile !== runtime.profileName
|
|
34
|
-
|| !
|
|
33
|
+
|| !LIVE_API_ORIGINS.includes(runtime.apiBase)) return;
|
|
35
34
|
// Ordinary commands must not steal another explicitly bound account's job.
|
|
36
35
|
const plist = join(homedir(), 'Library', 'LaunchAgents', `${SKILL_SYNC_SERVICE_LABEL}.plist`);
|
|
37
36
|
if (existsSync(plist)) {
|
|
@@ -50,7 +49,7 @@ export async function maybeInstallSkillSyncService(runtime, {
|
|
|
50
49
|
export async function installSkillSyncService(runtime, options = {}) {
|
|
51
50
|
if ((options.platform || process.platform) !== 'darwin') return { status: 'unsupported_platform' };
|
|
52
51
|
if (runtime.credentialKind !== 'oauth' || !runtime.oauthUserId
|
|
53
|
-
|| !
|
|
52
|
+
|| !LIVE_API_ORIGINS.includes(runtime.apiBase)) {
|
|
54
53
|
return { status: 'skipped_non_personal_profile' };
|
|
55
54
|
}
|
|
56
55
|
// Registration upgrades must not kill a worker holding the filesystem lock,
|
|
@@ -68,7 +67,7 @@ async function installSkillSyncServiceLocked(runtime, {
|
|
|
68
67
|
if (platform !== 'darwin') return { status: 'unsupported_platform' };
|
|
69
68
|
if (runtime.credentialKind !== 'oauth' || runtime.envCredentialOverride
|
|
70
69
|
|| !isValidProfileName(runtime.profileName)
|
|
71
|
-
|| !
|
|
70
|
+
|| !LIVE_API_ORIGINS.includes(runtime.apiBase)) {
|
|
72
71
|
return { status: 'skipped_non_personal_profile' };
|
|
73
72
|
}
|
|
74
73
|
const root = join(home, '.notis', 'skills', 'service');
|
|
@@ -32,6 +32,8 @@ export function generateSpaceManifest(selection) {
|
|
|
32
32
|
...(definition.cloudComputer ? { cloud_computer: definition.cloudComputer } : {}),
|
|
33
33
|
// Agents its database changes wake; absent when undeclared.
|
|
34
34
|
...(definition.agents?.length ? { agents: definition.agents } : {}),
|
|
35
|
+
// Live items agents attach to threads; absent when undeclared.
|
|
36
|
+
...(definition.threadItems && Object.keys(definition.threadItems).length ? { thread_items: definition.threadItems } : {}),
|
|
35
37
|
// Absent when nothing is editor-only (SPC-073: unmarked means public).
|
|
36
38
|
...(editorsOnly ? { editors_only: editorsOnly } : {}),
|
|
37
39
|
readable_context: definition.readableContext || '', collection: definition.collection || null,
|
|
@@ -7,7 +7,7 @@ import { usageError } from './errors.js';
|
|
|
7
7
|
import { VIEW_DEFINITION_FIELDS, viewManifestFields } from './space-view-manifest.js';
|
|
8
8
|
import { editorOnlyColumns, editorsOnlyFlag, withoutMarker } from './space-audience.js';
|
|
9
9
|
|
|
10
|
-
const CONFIG_FIELDS = new Set(['name', 'description', 'icon', 'accent', 'entry', 'layout', 'readableContext', 'resources', 'actions', 'navigation', 'viewerReads', 'cloudComputer', 'agents', 'collection', 'sourceIncludes', 'verificationFixtures', 'editorsOnly', ...VIEW_DEFINITION_FIELDS]);
|
|
10
|
+
const CONFIG_FIELDS = new Set(['name', 'description', 'icon', 'accent', 'entry', 'layout', 'readableContext', 'resources', 'actions', 'navigation', 'viewerReads', 'cloudComputer', 'agents', 'threadItems', 'collection', 'sourceIncludes', 'verificationFixtures', 'editorsOnly', ...VIEW_DEFINITION_FIELDS]);
|
|
11
11
|
/** Reads with each signed-in viewer's own authority (never an issuer grant); see docs/notis-spaces-platform.md. */
|
|
12
12
|
export const VIEWER_READ_FAMILIES = Object.freeze(['databases', 'skills']);
|
|
13
13
|
const WORKSPACE_INDEXES = new Set(['notis.config.ts', 'notis.config.js', 'notis.config.mjs']);
|
|
@@ -226,6 +226,7 @@ export async function loadSelectedSpace(projectDir, selectedKey) {
|
|
|
226
226
|
if (definition.cloudComputer != null) validateCloudComputer(definition.cloudComputer);
|
|
227
227
|
if (definition.cloudComputer != null && !entry) throw usageError('A container has no page, so it cannot use the cloud computer.');
|
|
228
228
|
if (definition.agents != null) validateSpaceAgents(definition.agents, resources);
|
|
229
|
+
if (definition.threadItems != null) validateThreadItems(definition.threadItems, definition.actions || {});
|
|
229
230
|
if (definition.collection && (resources[definition.collection.database]?.kind !== 'database' || !definition.collection.titleProperty)) {
|
|
230
231
|
throw usageError('A collection needs a declared database binding and title property.');
|
|
231
232
|
}
|
|
@@ -386,3 +387,67 @@ export function validateSpaceAgents(agents, resources = {}) {
|
|
|
386
387
|
}
|
|
387
388
|
}
|
|
388
389
|
}
|
|
390
|
+
|
|
391
|
+
const THREAD_ITEM_FIELDS = ['label', 'description', 'inputs', 'read', 'title', 'url', 'states', 'checks', 'actions', 'page'];
|
|
392
|
+
const THREAD_ITEM_STATE_FIELDS = ['id', 'label', 'icon', 'when', 'needsYou', 'final'];
|
|
393
|
+
const THREAD_ITEM_ACTION_FIELDS = ['label', 'tool', 'arguments', 'confirm', 'states', 'primary'];
|
|
394
|
+
const REFUSED_ITEM_TOOL = /^(LOCAL_|COMPOSIO_|NOTIS_|CUSTOM_|MCP_)/;
|
|
395
|
+
|
|
396
|
+
function threadItemLabel(value) {
|
|
397
|
+
if (typeof value === 'string') return value.trim().length > 0;
|
|
398
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value) && typeof value.en === 'string' && value.en.trim().length > 0
|
|
399
|
+
&& Object.keys(value).every(name => ['en', 'fr'].includes(name) && typeof value[name] === 'string' && value[name].trim());
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* The live item kinds agents attach to threads (`threadItems`). The shape is checked here so a
|
|
404
|
+
* mistake fails before the build; server/lib/space_thread_items.py repeats every check, including
|
|
405
|
+
* placeholders and conditions, when the Space is published.
|
|
406
|
+
*/
|
|
407
|
+
export function validateThreadItems(threadItems, actions = {}) {
|
|
408
|
+
const kinds = threadItems && typeof threadItems === 'object' && !Array.isArray(threadItems) ? Object.entries(threadItems) : null;
|
|
409
|
+
if (!kinds || kinds.length < 1 || kinds.length > 8) throw usageError('Declare threadItems as 1 to 8 item kinds.');
|
|
410
|
+
for (const [kind, spec] of kinds) {
|
|
411
|
+
if (!/^[a-z][a-z0-9_]{0,39}$/.test(kind)) throw usageError('Each thread item kind needs a short id: lowercase letters, digits and _.');
|
|
412
|
+
if (!spec || typeof spec !== 'object' || Array.isArray(spec) || Object.keys(spec).some(name => !THREAD_ITEM_FIELDS.includes(name))) {
|
|
413
|
+
throw usageError(`Thread item ${kind} takes ${THREAD_ITEM_FIELDS.join(', ')} only.`);
|
|
414
|
+
}
|
|
415
|
+
if (!threadItemLabel(spec.label)) throw usageError(`Thread item ${kind} needs a label.`);
|
|
416
|
+
if (spec.inputs?.type !== 'object' || spec.inputs?.additionalProperties !== false || !spec.inputs.properties
|
|
417
|
+
|| !Array.isArray(spec.inputs.required) || !spec.inputs.required.length) {
|
|
418
|
+
throw usageError(`Thread item ${kind} declares its inputs as a closed object with the fields an agent must give in required.`);
|
|
419
|
+
}
|
|
420
|
+
if (!spec.read || typeof spec.read.action !== 'string' || !Object.hasOwn(actions, spec.read.action)) {
|
|
421
|
+
throw usageError(`Thread item ${kind} reads through one of this Space's actions: read: { action: '<id>' }.`);
|
|
422
|
+
}
|
|
423
|
+
if (typeof spec.title !== 'string' && !threadItemLabel(spec.title)) throw usageError(`Thread item ${kind} needs a title template.`);
|
|
424
|
+
if (!Array.isArray(spec.states) || spec.states.length < 1 || spec.states.length > 12) {
|
|
425
|
+
throw usageError(`Thread item ${kind} lists 1 to 12 states in the order they are checked.`);
|
|
426
|
+
}
|
|
427
|
+
const stateIds = new Set();
|
|
428
|
+
for (const state of spec.states) {
|
|
429
|
+
if (!state || typeof state !== 'object' || Object.keys(state).some(name => !THREAD_ITEM_STATE_FIELDS.includes(name))
|
|
430
|
+
|| typeof state.id !== 'string' || !/^[a-z][a-z0-9_-]{0,39}$/.test(state.id) || stateIds.has(state.id)) {
|
|
431
|
+
throw usageError(`Each state of thread item ${kind} has its own id and takes ${THREAD_ITEM_STATE_FIELDS.join(', ')} only.`);
|
|
432
|
+
}
|
|
433
|
+
stateIds.add(state.id);
|
|
434
|
+
if (!threadItemLabel(state.label)) throw usageError(`State ${state.id} of thread item ${kind} needs a label.`);
|
|
435
|
+
if (typeof state.icon !== 'string' || !/^phosphor:[a-z0-9]+(-[a-z0-9]+)*$/.test(state.icon)) {
|
|
436
|
+
throw usageError(`State ${state.id} of thread item ${kind} needs a Phosphor icon, written phosphor:<name>.`);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
if (spec.states.at(-1).when != null) throw usageError(`The last state of thread item ${kind} has no condition, so every item has a state.`);
|
|
440
|
+
for (const [actionId, action] of Object.entries(spec.actions || {})) {
|
|
441
|
+
if (!action || typeof action !== 'object' || Object.keys(action).some(name => !THREAD_ITEM_ACTION_FIELDS.includes(name))) {
|
|
442
|
+
throw usageError(`Action ${actionId} of thread item ${kind} takes ${THREAD_ITEM_ACTION_FIELDS.join(', ')} only.`);
|
|
443
|
+
}
|
|
444
|
+
if (!threadItemLabel(action.label)) throw usageError(`Action ${actionId} of thread item ${kind} needs a label.`);
|
|
445
|
+
if (typeof action.tool !== 'string' || !/^[A-Z][A-Z0-9]*(_[A-Z0-9]+)+$/.test(action.tool) || REFUSED_ITEM_TOOL.test(action.tool)) {
|
|
446
|
+
throw usageError(`Action ${actionId} of thread item ${kind} runs one connected app tool, such as GITHUB_MERGE_A_PULL_REQUEST.`);
|
|
447
|
+
}
|
|
448
|
+
if (action.states != null && (!Array.isArray(action.states) || action.states.some(id => !stateIds.has(id)))) {
|
|
449
|
+
throw usageError(`Action ${actionId} of thread item ${kind} lists states this item declares.`);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
@@ -60,6 +60,21 @@ function recordViewExample(operation,key) {
|
|
|
60
60
|
}
|
|
61
61
|
const VIEWER_READS={list_databases:'databases',get_database:'databases',query_database:'databases',list_skills:'skills',get_skill:'skills'};
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* A shown fixture holds the whole list; a read asks for one page of it (page_size rows from offset), as the host
|
|
65
|
+
* does live. Without this a view reading every page (useShown allPages) got all rows on each page and counted
|
|
66
|
+
* them once per page.
|
|
67
|
+
*/
|
|
68
|
+
function shownPage(result,options) {
|
|
69
|
+
if(!object(options) || !object(result) || !Array.isArray(result.rows)) return result;
|
|
70
|
+
const offset=Number.isSafeInteger(options.offset) && options.offset>0 ? options.offset : 0;
|
|
71
|
+
// An offset with no page size reads one page of the live default size (100, server/lib/space_view_manifest.py).
|
|
72
|
+
const size=Number.isSafeInteger(options.page_size) && options.page_size>0 ? options.page_size : offset ? 100 : null;
|
|
73
|
+
if(size===null) return result;
|
|
74
|
+
result.rows=result.rows.slice(offset,offset+size);
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
|
|
63
78
|
export function createSpaceFixtureEngine(release) {
|
|
64
79
|
const bodyTemplates=structuredClone(release.manifest.actions || {});
|
|
65
80
|
const bodyResources=structuredClone(release.manifest.resources || {});
|
|
@@ -203,12 +218,12 @@ export function createSpaceFixtureEngine(release) {
|
|
|
203
218
|
if(!matched) throw usageError('Add an explicit synthetic document body fixture.');
|
|
204
219
|
return structuredClone(matched.result);
|
|
205
220
|
},
|
|
206
|
-
executeShown(name,params) {
|
|
221
|
+
executeShown(name,params,options={}) {
|
|
207
222
|
if(!Object.hasOwn(declaredLists,name)) throw usageError('This view does not declare that list.');
|
|
208
223
|
if(!object(params)) throw usageError('List params must be an object.');
|
|
209
224
|
const matched=shownCases[name]?.find(entry=>isDeepStrictEqual(entry.params,params));
|
|
210
225
|
if(!matched) throw usageError(`Add an explicit synthetic shown fixture for ${name} and these params.`);
|
|
211
|
-
return structuredClone(matched.result);
|
|
226
|
+
return shownPage(structuredClone(matched.result),options);
|
|
212
227
|
},
|
|
213
228
|
executeViewerRead(operation,input) {
|
|
214
229
|
if(!Object.hasOwn(VIEWER_READS,operation) || !declaredReads.includes(VIEWER_READS[operation])) throw usageError('This Space does not declare that viewer read.');
|
|
@@ -318,8 +333,9 @@ export async function startSpaceTestServer({release,capabilities,port=0,authoriz
|
|
|
318
333
|
const input=JSON.parse(Buffer.concat(chunks).toString('utf8'));
|
|
319
334
|
if(object(input) && Object.keys(input).length===1 && Object.hasOwn(input,'shown')) {
|
|
320
335
|
const list=input.shown;
|
|
321
|
-
|
|
322
|
-
|
|
336
|
+
const keys=object(list) ? Object.keys(list).sort().join(',') : '';
|
|
337
|
+
if(keys!=='name,params' && keys!=='name,options,params') return response(400,'{}');
|
|
338
|
+
try {return response(200,JSON.stringify({result:engine.executeShown(list.name,list.params,list.options)}));}
|
|
323
339
|
catch(error) {return response(400,JSON.stringify({message:error.message}));}
|
|
324
340
|
}
|
|
325
341
|
if(object(input) && Object.keys(input).length===1 && Object.hasOwn(input,'viewer_read')) {
|
|
@@ -86,6 +86,10 @@ export async function verifySpaceRelease(release, { capabilities, timeoutMs = 45
|
|
|
86
86
|
const renders = observations.map((value, index) => {
|
|
87
87
|
if (value.status === 'fulfilled') return value.value;
|
|
88
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
|
+
}
|
|
89
93
|
if (!shot?.data_base64) return { width, mounted: false, status: 'failed', error: value.reason?.code || 'render_failed' };
|
|
90
94
|
const png = Buffer.from(shot.data_base64, 'base64');
|
|
91
95
|
screenshots.push({ width, png });
|
|
@@ -105,7 +109,7 @@ export async function verifySpaceRelease(release, { capabilities, timeoutMs = 45
|
|
|
105
109
|
.map(call => [call.error, { phase: 'fixture', operation: call.operation,
|
|
106
110
|
...(call.recordKey ? { record_key: call.recordKey } : {}), ...(call.actionId ? { action_id: call.actionId } : {}),
|
|
107
111
|
message: call.error }])).values()].slice(0, 10);
|
|
108
|
-
const notReady = renders.filter(value => value.error === 'render_not_ready')
|
|
112
|
+
const notReady = renders.filter(value => value.error === 'render_not_ready' || value.error === 'render_view_failed')
|
|
109
113
|
.map(value => ({ phase: 'renderer', width: value.width, message: value.message }));
|
|
110
114
|
const result = { ...diagnostic, status: passed ? 'passed' : 'failed', mounted: renders.every(value => value.mounted),
|
|
111
115
|
fixture_digest: brokers[0].broker.fixtureDigest, renderer_digest: rendererDigest,
|
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);
|