@notis_ai/cli 0.2.25 → 0.2.26
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 +186 -5
- package/config/notis_app_design_rules.json +36 -14
- package/config/portal-route-roots.json +1 -0
- package/dist/agent-hooks/notis-agent-hook.mjs +2784 -541
- package/dist/base-skills/notis-cli/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-cli/references/intelligence.md +1 -1
- package/dist/base-skills/notis-query/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-query/SKILL.md +0 -1
- package/dist/base-skills/notis-query/references/documents.md +7 -0
- package/dist/base-skills/notis-query/references/query.md +1 -0
- package/dist/base-skills/notis-spaces/.notis-base-skill.json +1 -1
- package/dist/base-skills/notis-spaces/SKILL.md +96 -24
- package/dist/base-skills/notis-spaces/references/architecture.md +4 -3
- package/dist/base-skills/notis-spaces/references/design.md +37 -18
- package/dist/base-skills/notis-spaces/references/reading.md +8 -1
- package/dist/base-skills/notis-spaces/references/reports.md +6 -6
- package/dist/base-skills/notis-spaces/references/sdk.md +71 -7
- package/dist/base-skills/notis-spaces/references/store.md +22 -13
- package/dist/base-skills/notis-spaces/references/views.md +99 -6
- package/dist/sdk/package.json +3 -0
- package/dist/sdk/src/cloudComputerWords.ts +53 -0
- package/dist/sdk/src/components/Audience.tsx +76 -0
- package/dist/sdk/src/components/DocumentPage.tsx +15 -4
- package/dist/sdk/src/components/MarkdownEditor.tsx +44 -14
- package/dist/sdk/src/components/MultiSelectActionBar.tsx +16 -5
- package/dist/sdk/src/components/Skeleton.tsx +162 -6
- package/dist/sdk/src/hooks/useAction.ts +12 -2
- package/dist/sdk/src/hooks/useAgentQueue.ts +125 -0
- package/dist/sdk/src/hooks/useCloudComputerJob.ts +142 -0
- package/dist/sdk/src/hooks/useCloudComputerService.ts +388 -0
- package/dist/sdk/src/hooks/useCloudComputerShell.ts +95 -7
- package/dist/sdk/src/hooks/useCollectionInteractions.ts +40 -2
- package/dist/sdk/src/hooks/useItemThread.ts +58 -0
- package/dist/sdk/src/hooks/useMarqueeSelection.ts +6 -1
- package/dist/sdk/src/hooks/useNativeDocuments.ts +61 -8
- package/dist/sdk/src/hooks/useNotisNavigation.ts +31 -8
- package/dist/sdk/src/hooks/useQuery.ts +67 -10
- package/dist/sdk/src/hooks/useViewParams.ts +47 -11
- package/dist/sdk/src/index.ts +31 -4
- package/dist/sdk/src/interactions.ts +2 -0
- package/dist/sdk/src/nativeData.ts +2 -0
- package/dist/sdk/src/optimisticRows.ts +329 -0
- package/dist/sdk/src/perf.ts +188 -0
- package/dist/sdk/src/provider.tsx +2 -1
- package/dist/sdk/src/queryCache.ts +366 -17
- package/dist/sdk/src/runtime.ts +55 -4
- package/dist/sdk/src/skeleton.ts +103 -0
- package/dist/sdk/src/space.ts +662 -28
- package/dist/sdk/src/spacePublicUI.ts +36 -0
- package/dist/sdk/src/ui/engine/step.ts +54 -0
- package/dist/sdk/src/ui/icons.tsx +3 -1
- package/dist/sdk/src/words/shell.ts +1 -0
- package/dist/skill-sync/index.js +7 -2
- package/dist/skill-sync-worker.mjs +40 -26
- package/dist/space-harness/host.js +272 -105
- package/dist/space-sdk/dist/chunk-BWHAORT4.js +5 -0
- package/dist/space-sdk/dist/index.js +9 -4
- package/dist/space-sdk/dist/ui.js +12 -12
- package/dist/space-sdk/package.json +3 -0
- package/dist/space-sdk/src/cloudComputerWords.d.ts +34 -0
- package/dist/space-sdk/src/components/Audience.d.ts +46 -0
- package/dist/space-sdk/src/components/DocumentPage.d.ts +3 -1
- package/dist/space-sdk/src/components/MarkdownEditor.d.ts +21 -0
- package/dist/space-sdk/src/components/MultiSelectActionBar.d.ts +5 -1
- package/dist/space-sdk/src/components/Skeleton.d.ts +7 -2
- package/dist/space-sdk/src/hooks/useAction.d.ts +8 -1
- package/dist/space-sdk/src/hooks/useAgentQueue.d.ts +61 -0
- package/dist/space-sdk/src/hooks/useCloudComputerJob.d.ts +35 -0
- package/dist/space-sdk/src/hooks/useCloudComputerService.d.ts +75 -0
- package/dist/space-sdk/src/hooks/useCloudComputerShell.d.ts +36 -3
- package/dist/space-sdk/src/hooks/useCollectionInteractions.d.ts +6 -0
- package/dist/space-sdk/src/hooks/useItemThread.d.ts +32 -0
- package/dist/space-sdk/src/hooks/useMarqueeSelection.d.ts +2 -1
- package/dist/space-sdk/src/hooks/useNativeDocumentBody.d.ts +1 -0
- package/dist/space-sdk/src/hooks/useNativeDocuments.d.ts +20 -5
- package/dist/space-sdk/src/hooks/useNotisNavigation.d.ts +11 -2
- package/dist/space-sdk/src/hooks/useQuery.d.ts +24 -2
- package/dist/space-sdk/src/hooks/useViewParams.d.ts +2 -0
- package/dist/space-sdk/src/index.d.ts +24 -4
- package/dist/space-sdk/src/nativeData.d.ts +6 -0
- package/dist/space-sdk/src/queryCache.d.ts +97 -2
- package/dist/space-sdk/src/runtime.d.ts +53 -4
- package/dist/space-sdk/src/skeleton.d.ts +42 -0
- package/dist/space-sdk/src/space.ts +662 -28
- package/dist/space-sdk/src/tailwind-candidates.d.ts +754 -5
- package/dist/space-sdk/src/ui/cloud/CloudComputerFrame.d.ts +29 -0
- package/dist/space-sdk/src/ui/cloud/CloudComputerWaking.d.ts +20 -0
- package/dist/space-sdk/src/ui/comments/CommentPane.d.ts +15 -2
- package/dist/space-sdk/src/ui/comments/PassageComments.d.ts +50 -0
- package/dist/space-sdk/src/ui/comments/commentFiles.d.ts +64 -0
- package/dist/space-sdk/src/ui/comments/commentModel.d.ts +49 -1
- package/dist/space-sdk/src/ui/comments/commentWords.d.ts +26 -0
- package/dist/space-sdk/src/ui/comments/index.d.ts +4 -0
- package/dist/space-sdk/src/ui/comments/passageModel.d.ts +82 -0
- package/dist/space-sdk/src/ui/comments/useComments.d.ts +34 -4
- package/dist/space-sdk/src/ui/comments/usePassageComments.d.ts +67 -0
- package/dist/space-sdk/src/ui/engine/index.d.ts +2 -2
- package/dist/space-sdk/src/ui/engine/step.d.ts +9 -0
- package/dist/space-sdk/src/ui/fields/fields.d.ts +2 -1
- package/dist/space-sdk/src/ui/index.d.ts +4 -0
- package/dist/space-sdk/src/ui/layout/Panels.d.ts +9 -2
- package/dist/space-sdk/src/ui/layout/SidePane.d.ts +42 -0
- package/dist/space-sdk/src/ui/layout/index.d.ts +2 -1
- package/dist/space-sdk/src/ui/layout/panelMath.d.ts +11 -2
- package/dist/space-sdk/src/ui/list/ListReader.d.ts +38 -7
- package/dist/space-sdk/src/ui/list/Row.d.ts +4 -0
- package/dist/space-sdk/src/ui/list/SelectionBar.d.ts +9 -4
- package/dist/space-sdk/src/ui/list/useListKeys.d.ts +4 -0
- package/dist/space-sdk/src/words/shell.ts +1 -0
- package/dist/view-renderer/dist/host.js +355 -188
- package/dist/view-renderer/dist/theme.css +1 -1
- package/dist/view-renderer/src/host.tsx +4 -1
- package/dist/view-renderer/src/index.js +3 -0
- package/dist/view-renderer/src/pool.js +8 -4
- package/dist/view-renderer/src/renderer.js +92 -23
- package/dist/view-renderer/src/skeleton.js +450 -0
- package/package.json +4 -4
- package/skills/notis-cli/AGENT_INSTRUCTIONS.md +8 -4
- package/skills/notis-onboarding/BRIEF.md +15 -9
- package/skills/notis-spaces/cli.md +43 -4
- package/src/command-specs/auth.js +5 -3
- package/src/command-specs/cc.js +410 -0
- package/src/command-specs/computer.js +320 -0
- package/src/command-specs/diagnostics.js +2 -13
- package/src/command-specs/documents.js +22 -4
- package/src/command-specs/index.js +7 -0
- package/src/command-specs/onboarding.js +127 -7
- package/src/command-specs/skills.js +2 -2
- package/src/command-specs/spaces.js +162 -30
- package/src/command-specs/tools.js +26 -8
- package/src/command-specs/views.js +4 -1
- package/src/runtime/agent-setup.js +20 -2
- package/src/runtime/app-boundary-validator.js +2 -1
- package/src/runtime/app-platform.js +13 -0
- package/src/runtime/auth-recovery.js +5 -0
- package/src/runtime/channel.js +16 -2
- package/src/runtime/cloud-transfer.js +587 -0
- package/src/runtime/computer-ssh.js +127 -0
- package/src/runtime/oauth.js +50 -4
- package/src/runtime/skill-sync/index.ts +20 -1
- package/src/runtime/skill-sync/local-scanner.ts +1 -0
- package/src/runtime/skill-sync/types.ts +2 -0
- package/src/runtime/space-audience.js +94 -0
- package/src/runtime/space-collection-scaffold.js +2 -1
- package/src/runtime/space-fixture-broker.js +2 -1
- package/src/runtime/space-lock.js +1 -4
- package/src/runtime/space-platform.js +18 -2
- package/src/runtime/space-source.js +105 -7
- package/src/runtime/space-test-server.js +13 -2
- package/src/runtime/space-verification.js +99 -6
- package/src/runtime/space-view-manifest.js +22 -4
- package/src/runtime/sync-skills.js +24 -20
- package/src/runtime/transport.js +19 -0
- package/src/runtime/view-render.js +2 -2
- package/template/.harness/index.html.tmpl +1 -1
- package/dist/skill-sync/index.js.map +0 -7
- package/dist/space-sdk/dist/chunk-SVZATGZB.js +0 -5
|
@@ -11,6 +11,7 @@ import { appFilesDigest } from './app-platform.js';
|
|
|
11
11
|
import { usageError } from './errors.js';
|
|
12
12
|
|
|
13
13
|
const ROOT=resolve(dirname(fileURLToPath(import.meta.url)),'../..');
|
|
14
|
+
const MAX_SHOWN_FIXTURE_CASES=256;
|
|
14
15
|
// Credentialless worker + non-forwarding proxy own the offline boundary.
|
|
15
16
|
// Source shares the Shadow host realm and may call only this fixture origin.
|
|
16
17
|
const HOST_POLICY="default-src 'none'; script-src 'self' blob: data:; style-src 'self' 'unsafe-inline'; img-src data: blob:; font-src data:; connect-src 'self'; frame-src 'none'; frame-ancestors 'self'; form-action 'none'; base-uri 'none'";
|
|
@@ -35,6 +36,11 @@ function shownListParams(where, params) {
|
|
|
35
36
|
return [...names].sort();
|
|
36
37
|
}
|
|
37
38
|
/** Public runtime declarations (server declared_view_runtime): params, list names and chrome, never filters (nor a record page's rule). */
|
|
39
|
+
/** The runtime descriptor's editorsOnly summary (server/lib/space_audience.py runtime_editors_only). */
|
|
40
|
+
function editorsOnlyDescriptor(value) {
|
|
41
|
+
return {...(value.view===true?{view:true}:{}),shows:[...(value.shows || [])],actions:[...(value.actions || [])],
|
|
42
|
+
params:[...(value.params || [])],columns:structuredClone(value.columns || {})};
|
|
43
|
+
}
|
|
38
44
|
function viewDeclarations(manifest) {
|
|
39
45
|
const shows=Object.fromEntries(Object.entries(manifest.shows || {}).map(([name,value])=>[name,Object.hasOwn(value,'where')
|
|
40
46
|
? {database:value.database,...(value.open?{open:value.open}:{}),params:shownListParams(value.where,manifest.params)} : {about:value.about,...(value.services?.length?{services:value.services}:{})}]));
|
|
@@ -73,9 +79,12 @@ export function createSpaceFixtureEngine(release) {
|
|
|
73
79
|
const shownCases=fixtures.shown ?? {};
|
|
74
80
|
if(!object(shownCases)) throw usageError('Declare shown fixtures by list name.');
|
|
75
81
|
for(const [name,cases] of Object.entries(shownCases)) {
|
|
76
|
-
if(!Object.hasOwn(declaredLists,name) || !Array.isArray(cases) || !cases.length
|
|
82
|
+
if(!Object.hasOwn(declaredLists,name) || !Array.isArray(cases) || !cases.length) {
|
|
77
83
|
throw usageError(`Declare shown fixtures only for lists this view declares with a filter (${name}).`);
|
|
78
84
|
}
|
|
85
|
+
if(cases.length>MAX_SHOWN_FIXTURE_CASES) {
|
|
86
|
+
throw usageError(`Shown fixtures for ${name} contain ${cases.length} cases; the limit is ${MAX_SHOWN_FIXTURE_CASES}.`);
|
|
87
|
+
}
|
|
79
88
|
const previous=[];
|
|
80
89
|
for(const entry of cases) {
|
|
81
90
|
if(!object(entry) || Object.keys(entry).some(key=>!['params','result'].includes(key)) || !object(entry.params) || !object(entry.result)) {
|
|
@@ -261,7 +270,9 @@ export function spaceHarnessSnapshot(release,capabilities,engine,{authorizationM
|
|
|
261
270
|
cacheKey:`${artifact}:${engine.digest}`,exportCandidates:['SpaceView'],
|
|
262
271
|
descriptor:{resource:{kind:'space',id:identity,revision:1},
|
|
263
272
|
space:{id:identity,revision:1,cacheScope:`stub:${artifact}:${engine.digest}`,actions,bindings,...(navigation.length?{navigation}:{}),
|
|
264
|
-
...(viewerReads.length?{viewerReads}:{}),...viewDeclarations(manifest)
|
|
273
|
+
...(viewerReads.length?{viewerReads}:{}),...viewDeclarations(manifest),
|
|
274
|
+
// A local verification renders as an Editor, with the editor-only summary the server gives Editors.
|
|
275
|
+
audience:'editor',...(manifest.editors_only?{editorsOnly:editorsOnlyDescriptor(manifest.editors_only)}:{})},
|
|
265
276
|
app:{id:identity,name:manifest.name},route:{slug:'view',path:'/',name:manifest.name},context:engine.context} };
|
|
266
277
|
}
|
|
267
278
|
|
|
@@ -19,7 +19,7 @@ export async function loadSpaceVerificationRenderer() {
|
|
|
19
19
|
const entry = new URL('src/index.js', root);
|
|
20
20
|
if (!existsSync(fileURLToPath(entry))) continue;
|
|
21
21
|
const digest = createHash('sha256');
|
|
22
|
-
for (const file of ['src/renderer.js', 'src/dom.js', 'src/pool.js', 'dist/host.js', 'dist/host.css', 'dist/theme.css']) {
|
|
22
|
+
for (const file of ['src/renderer.js', 'src/dom.js', 'src/pool.js', 'src/skeleton.js', 'dist/host.js', 'dist/host.css', 'dist/theme.css']) {
|
|
23
23
|
digest.update(file); digest.update(readFileSync(new URL(file, root)));
|
|
24
24
|
}
|
|
25
25
|
return { ...(await import(entry.href)), rendererDigest: digest.digest('hex') };
|
|
@@ -54,16 +54,21 @@ export async function verifySpaceRelease(release, { capabilities, timeoutMs = 45
|
|
|
54
54
|
if (signal?.aborted) return { ...diagnostic, status: 'failed', errors: [{ phase: 'browser', message: 'Verification cancelled.' }] };
|
|
55
55
|
if (release.manifest.kind === 'container') return { ...diagnostic, status: 'not_applicable_container' };
|
|
56
56
|
let pool, held = false, rendererDigest;
|
|
57
|
-
const brokers = [390, 1440].map(width => ({ width, broker: null }));
|
|
57
|
+
const brokers = [390, 1440].map(width => ({ width, broker: null, stop: new AbortController(), timer: null }));
|
|
58
58
|
try {
|
|
59
59
|
// Validate fixture authority before opening a browser or acquiring a slot.
|
|
60
|
+
// A failed fixture read already fails the check, and the view usually waits on it until the timeout: the
|
|
61
|
+
// render stops shortly after, once the reads the view sends together have had their say.
|
|
60
62
|
for (const item of brokers) item.broker = createSpaceFixtureBroker({ release, capabilities, width: item.width,
|
|
61
|
-
authorizationMode, unavailableActions
|
|
63
|
+
authorizationMode, unavailableActions, onFailure: () => {
|
|
64
|
+
item.timer ??= setTimeout(() => item.stop.abort(), FIXTURE_FAILURE_GRACE_MS);
|
|
65
|
+
} });
|
|
62
66
|
await acquire(signal); held = true;
|
|
63
67
|
const library = await loadRenderer(); rendererDigest = library.rendererDigest;
|
|
64
68
|
pool = library.createBrowserPool({ concurrency: 2, maxQueue: 2 });
|
|
65
|
-
const observations = await Promise.allSettled(brokers.map(async ({ width, broker }) => {
|
|
66
|
-
const
|
|
69
|
+
const observations = await Promise.allSettled(brokers.map(async ({ width, broker, stop }) => {
|
|
70
|
+
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 });
|
|
67
72
|
const blocked = result.blocked_calls || [];
|
|
68
73
|
return { width, mounted: true, status: blocked.length ? 'failed' : 'passed',
|
|
69
74
|
markdown_sha256: createHash('sha256').update(result.markdown).digest('hex'),
|
|
@@ -81,14 +86,102 @@ export async function verifySpaceRelease(release, { capabilities, timeoutMs = 45
|
|
|
81
86
|
.map(call => [call.error, { phase: 'fixture', operation: call.operation,
|
|
82
87
|
...(call.recordKey ? { record_key: call.recordKey } : {}), ...(call.actionId ? { action_id: call.actionId } : {}),
|
|
83
88
|
message: call.error }])).values()].slice(0, 10);
|
|
84
|
-
|
|
89
|
+
const result = { ...diagnostic, status: passed ? 'passed' : 'failed', mounted: renders.every(value => value.mounted),
|
|
85
90
|
fixture_digest: brokers[0].broker.fixtureDigest, renderer_digest: rendererDigest,
|
|
86
91
|
render_count: renders.length, browser_count: 1, renders, runtimeCalls,
|
|
87
92
|
errors: passed ? [] : [...fixtureErrors, { phase: 'renderer', message: 'At least one width or read-only fixture failed verification.' }] };
|
|
93
|
+
// The skeleton is measured only from a view that rendered cleanly, with a renderer that can measure it.
|
|
94
|
+
if (passed && typeof library.buildSkeletonDocument === 'function') {
|
|
95
|
+
const capture = await captureSpaceSkeleton({ library, pool, release, capabilities, timeoutMs, signal, authorizationMode, unavailableActions });
|
|
96
|
+
result.skeleton = capture.skeleton;
|
|
97
|
+
Object.defineProperty(result, 'skeletonDocument', { value: capture.document, enumerable: false });
|
|
98
|
+
Object.defineProperty(result, 'pendingScreenshots', { value: capture.screenshots, enumerable: false });
|
|
99
|
+
Object.defineProperty(result, 'skeletonJson', { value: capture.document ? library.canonicalSkeletonJson(capture.document) : null, enumerable: false });
|
|
100
|
+
}
|
|
101
|
+
return result;
|
|
88
102
|
} catch (error) {
|
|
89
103
|
return { ...diagnostic, status: 'failed', ...(rendererDigest ? { renderer_digest: rendererDigest } : {}),
|
|
90
104
|
errors: [{ phase: 'harness', message: error.message }] };
|
|
91
105
|
} finally {
|
|
106
|
+
for (const item of brokers) clearTimeout(item.timer);
|
|
92
107
|
try { await pool?.close(); } finally { if (held) releaseSlot(); }
|
|
93
108
|
}
|
|
94
109
|
}
|
|
110
|
+
const FIXTURE_FAILURE_GRACE_MS = 1_500;
|
|
111
|
+
|
|
112
|
+
const sha256 = bytes => createHash('sha256').update(bytes).digest('hex');
|
|
113
|
+
const captureFailure = (width, locale, error) => ({ check: 'capture_failed', severity: 'warning', width, locale,
|
|
114
|
+
message: `The loading skeleton could not be measured: ${String(error?.code || error?.message || error).slice(0, 300)}` });
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Loading skeleton capture, per width and locale: (1) pending with the view's fallback skeleton gives the region
|
|
118
|
+
* boxes and landmarks, (2) final measures the bones inside those boxes, (3) pending again with the measured bones
|
|
119
|
+
* injected is checked and screenshotted. Never throws: failures become warnings and status `failed`.
|
|
120
|
+
*/
|
|
121
|
+
async function captureSpaceSkeleton({ library, pool, release, capabilities, timeoutMs, signal, authorizationMode, unavailableActions }) {
|
|
122
|
+
const findings = [], screenshots = [], combos = [];
|
|
123
|
+
let failed = false, document = null;
|
|
124
|
+
const widths = library.SKELETON_WIDTHS || [390, 1440], locales = library.SKELETON_LOCALES || ['en', 'fr'];
|
|
125
|
+
const render = (width, options) => library.renderView({ broker: createSpaceFixtureBroker({ release, capabilities, width,
|
|
126
|
+
outputs: ['markdown'], authorizationMode, unavailableActions }), pool, outputs: ['markdown'], width, timeoutMs, signal, ...options });
|
|
127
|
+
// Both widths of one locale run together: the pool holds two renders at a time.
|
|
128
|
+
const each = async (step) => {
|
|
129
|
+
for (const locale of locales) {
|
|
130
|
+
const settled = await Promise.allSettled(widths.map(width => step(combos.find(value => value.width === width && value.locale === locale))));
|
|
131
|
+
settled.forEach((value, index) => {
|
|
132
|
+
if (value.status === 'fulfilled') return;
|
|
133
|
+
const combo = combos.find(item => item.width === widths[index] && item.locale === locale);
|
|
134
|
+
combo.error = value.reason; failed = true;
|
|
135
|
+
findings.push(captureFailure(combo.width, locale, value.reason));
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
for (const locale of locales) for (const width of widths) combos.push({ width, locale });
|
|
140
|
+
try {
|
|
141
|
+
await each(async (combo) => { combo.first = await render(combo.width, { pending: true, locale: combo.locale }); });
|
|
142
|
+
await each(async (combo) => {
|
|
143
|
+
combo.regions = combo.first?.pending?.static ? [] : (combo.first?.pending?.regions || []);
|
|
144
|
+
const valid = combo.regions.filter(region => region.valid);
|
|
145
|
+
if (!valid.length) return;
|
|
146
|
+
combo.final = (await render(combo.width, { measure: { regions: valid }, locale: combo.locale })).skeleton_measure;
|
|
147
|
+
});
|
|
148
|
+
const measurements = {};
|
|
149
|
+
for (const combo of combos) if (combo.final) (measurements[combo.width] ||= {})[combo.locale] = { regions: combo.final.regions };
|
|
150
|
+
const app = release.files[release.manifest.bundle?.js || 'bundle/app.js'];
|
|
151
|
+
if (Object.keys(measurements).length && typeof app === 'string') {
|
|
152
|
+
document = library.buildSkeletonDocument({ sourceHash: sha256(Buffer.from(app, 'base64')), measurements });
|
|
153
|
+
const invalid = document && library.validateSkeletonDocument(document, { appJsSha256: document.sourceHash });
|
|
154
|
+
const bytes = document && Buffer.byteLength(library.canonicalSkeletonJson(document));
|
|
155
|
+
const tooLarge = bytes > (library.SKELETON_LIMITS?.maxBytes || 512 * 1024);
|
|
156
|
+
if (invalid || tooLarge) {
|
|
157
|
+
failed = true;
|
|
158
|
+
findings.push({ check: 'skeleton_invalid', severity: 'warning', width: null, locale: null,
|
|
159
|
+
message: `The measured skeleton was dropped: ${invalid || 'it is larger than 512 KiB'}.` });
|
|
160
|
+
document = null;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (document) {
|
|
164
|
+
await each(async (combo) => {
|
|
165
|
+
if (!combo.final) return;
|
|
166
|
+
combo.checked = await render(combo.width, { pending: true, locale: combo.locale, skeleton: document });
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
} catch (error) {
|
|
170
|
+
failed = true; findings.push(captureFailure(null, null, error));
|
|
171
|
+
}
|
|
172
|
+
for (const combo of combos) {
|
|
173
|
+
const shown = combo.checked || combo.first;
|
|
174
|
+
if (!shown) continue;
|
|
175
|
+
const heights = Object.fromEntries((combo.final?.regions || []).map(region => [region.key, library.buildSkeletonEntry(region).height]));
|
|
176
|
+
try {
|
|
177
|
+
findings.push(...library.runSkeletonChecks({ width: combo.width, locale: combo.locale, pending: shown.pending,
|
|
178
|
+
regions: combo.regions || [], final: combo.final, heights }));
|
|
179
|
+
} catch (error) { failed = true; findings.push(captureFailure(combo.width, combo.locale, error)); }
|
|
180
|
+
if (shown.pending?.static || !shown.screenshot?.data_base64) continue;
|
|
181
|
+
const png = Buffer.from(shown.screenshot.data_base64, 'base64');
|
|
182
|
+
screenshots.push({ width: combo.width, locale: combo.locale, png, sha256: sha256(png) });
|
|
183
|
+
}
|
|
184
|
+
const status = document ? 'captured' : failed ? 'failed' : 'none';
|
|
185
|
+
return { document, screenshots, skeleton: { status, regions: document ? Object.keys(document.regions).sort() : [], findings,
|
|
186
|
+
pending_screenshots: screenshots.map(({ width, locale, sha256: digest }) => ({ width, locale, sha256: digest })) } };
|
|
187
|
+
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* specVersion. Containers remain non-executable; explicit specVersion 2 is unchanged.
|
|
8
8
|
*/
|
|
9
9
|
import { usageError } from './errors.js';
|
|
10
|
+
import { editorsOnlyFlag, manifestDeclarations } from './space-audience.js';
|
|
10
11
|
import portalRouteRoots from '../../config/portal-route-roots.json' with { type: 'json' };
|
|
11
12
|
const RESERVED_PATHS = new Set(portalRouteRoots);
|
|
12
13
|
|
|
@@ -15,7 +16,8 @@ export const VIEW_DEFINITION_FIELDS = Object.freeze(['specVersion', 'path', 'par
|
|
|
15
16
|
export const VIEW_PARAM_TYPES = Object.freeze(['record', 'enum', 'text', 'number', 'date', 'period', 'boolean']);
|
|
16
17
|
const RELATIVE_DATES = ['today', 'tomorrow'];
|
|
17
18
|
const PERIODS = [...RELATIVE_DATES, 'this_week', 'last_week', 'this_month', 'last_month'];
|
|
18
|
-
|
|
19
|
+
// `view_as` is the Portal's View as the public (server/lib/space_view_manifest.py RESERVED_PARAMS).
|
|
20
|
+
const RESERVED_PARAMS = new Set(['record', 'assistantThread', 'view_as']);
|
|
19
21
|
const PAGE_ONLY = ['params', 'shows', 'memory', 'chrome', 'markdown', 'questions'];
|
|
20
22
|
const NAME = /^[a-z][A-Za-z0-9_]{0,63}$/;
|
|
21
23
|
// Credentials never ride in links, so no view param may look like one (the Portal drops these names).
|
|
@@ -131,7 +133,7 @@ export function viewParamValue(declaration, value) {
|
|
|
131
133
|
|
|
132
134
|
function validateParam(name, declaration, resources) {
|
|
133
135
|
if (!NAME.test(name) || RESERVED_PARAMS.has(name) || CREDENTIAL_PARAM.test(name)) throw usageError(`Param names are camelCase words; "${name}" is not available.`);
|
|
134
|
-
const allowed = new Set(['type', 'description', 'required', 'default', 'values', 'database', 'main', 'slugProperty', 'page', 'timezone']);
|
|
136
|
+
const allowed = new Set(['type', 'description', 'required', 'default', 'values', 'database', 'main', 'slugProperty', 'page', 'timezone', 'editorsOnly']);
|
|
135
137
|
if (!plain(declaration) || Object.keys(declaration).some(field => !allowed.has(field)) || !VIEW_PARAM_TYPES.includes(declaration.type)) {
|
|
136
138
|
throw usageError(`Declare param "${name}" as { type, description, ... } with type ${VIEW_PARAM_TYPES.join(', ')}.`);
|
|
137
139
|
}
|
|
@@ -143,6 +145,16 @@ function validateParam(name, declaration, resources) {
|
|
|
143
145
|
} catch { throw usageError(`Param "${name}": timezone is an IANA timezone for a date or period.`); }
|
|
144
146
|
}
|
|
145
147
|
if ('required' in declaration && typeof declaration.required !== 'boolean') throw usageError(`Param "${name}": required is true or false.`);
|
|
148
|
+
// The public never sets an editor-only param, so it must open the view without it (its default, if any, applies).
|
|
149
|
+
const editorOnly = editorsOnlyFlag(declaration.editorsOnly, `Param "${name}"`);
|
|
150
|
+
if (editorOnly && declaration.required === true) {
|
|
151
|
+
throw usageError(`Param "${name}": an editor-only param cannot be required, or the public could never open this view. Give it a default instead.`);
|
|
152
|
+
}
|
|
153
|
+
// A record param chooses the record a page or a record Site shows: hidden from the public, its filters would
|
|
154
|
+
// read as unset and widen to every record (server/lib/space_audience.py refuses it too).
|
|
155
|
+
if (editorOnly && declaration.type === 'record') {
|
|
156
|
+
throw usageError(`Param "${name}": a record param chooses the record this view shows, so it cannot be editors-only. Mark the lists or columns it reveals instead.`);
|
|
157
|
+
}
|
|
146
158
|
if (declaration.type === 'enum') {
|
|
147
159
|
const values = declaration.values;
|
|
148
160
|
if (!Array.isArray(values) || values.length < 1 || values.length > 100 || new Set(values).size !== values.length
|
|
@@ -276,6 +288,11 @@ function validatePage(name, page, resource) {
|
|
|
276
288
|
function validateShows(name, declaration, params, resources, collection) {
|
|
277
289
|
const where = `shows.${name}`;
|
|
278
290
|
if (!NAME.test(name)) throw usageError(`Shows names are camelCase words; "${name}" is not available.`);
|
|
291
|
+
editorsOnlyFlag(declaration?.editorsOnly, where);
|
|
292
|
+
if (plain(declaration) && 'editorsOnly' in declaration) {
|
|
293
|
+
const { editorsOnly, ...rest } = declaration;
|
|
294
|
+
declaration = rest;
|
|
295
|
+
}
|
|
279
296
|
if (plain(declaration) && 'about' in declaration) {
|
|
280
297
|
const services = declaration.services ?? [];
|
|
281
298
|
if (Object.keys(declaration).some(field => !['about', 'services'].includes(field)) || !text(declaration.about, 500)
|
|
@@ -359,8 +376,9 @@ export function viewManifestFields(definition, { entry, resources }) {
|
|
|
359
376
|
...(version !== undefined ? { spec_version: version } : {}),
|
|
360
377
|
...(definition.path !== undefined ? { path: definition.path } : {}),
|
|
361
378
|
...(definition.questions !== undefined ? { questions: definition.questions } : {}),
|
|
362
|
-
|
|
363
|
-
...(definition.
|
|
379
|
+
// Editor-only markers leave the copied items; the manifest's editors_only key carries them (space-audience.js).
|
|
380
|
+
...(definition.params !== undefined ? { params: manifestDeclarations(params) } : {}),
|
|
381
|
+
...(definition.shows !== undefined ? { shows: manifestDeclarations(definition.shows) } : {}),
|
|
364
382
|
...(definition.memory !== undefined ? { memory: definition.memory } : {}),
|
|
365
383
|
...(definition.chrome !== undefined ? { chrome: definition.chrome } : {}),
|
|
366
384
|
...(definition.markdown !== undefined ? { markdown: { export_name: 'SpaceMarkdown' } } : {}),
|
|
@@ -19,8 +19,8 @@ async function lockSnapshot(lockDirectory) {
|
|
|
19
19
|
try {
|
|
20
20
|
owner = raw ? JSON.parse(raw) : {};
|
|
21
21
|
} catch {
|
|
22
|
-
// A
|
|
23
|
-
//
|
|
22
|
+
// A lock left by an older CLI can lack its owner. Preserve the
|
|
23
|
+
// directory mtime as a reclaimable ownerless lease.
|
|
24
24
|
}
|
|
25
25
|
return {
|
|
26
26
|
id: typeof owner.id === 'string' ? owner.id : null,
|
|
@@ -77,11 +77,27 @@ async function quarantineStaleLock(lockDirectory, snapshot) {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Acquires the lock by publishing a directory that already holds its owner: it is built in a private staging
|
|
82
|
+
* folder and renamed onto the shared path, which fails while another owner's lock is there. The shared path
|
|
83
|
+
* never holds an ownerless lock a reclaimer could take for stale, and a failed attempt only removes its own folder.
|
|
84
|
+
*/
|
|
85
|
+
async function publishOwnedLock(lockDirectory, owner) {
|
|
86
|
+
const quarantineRoot = join(dirname(lockDirectory), '.stale-operation-locks');
|
|
87
|
+
const staging = join(quarantineRoot, `staging.${owner.id}`);
|
|
88
|
+
await mkdir(quarantineRoot, { recursive: true, mode: 0o700 });
|
|
89
|
+
await mkdir(staging, { mode: 0o700 });
|
|
90
|
+
try {
|
|
91
|
+
await writeFile(join(staging, 'owner'), JSON.stringify(owner), { mode: 0o600 });
|
|
92
|
+
await rename(staging, lockDirectory);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
await rm(staging, { recursive: true, force: true });
|
|
95
|
+
// Held by another owner: renaming onto a directory that is not empty refuses (Windows says EPERM).
|
|
96
|
+
const held = ['EEXIST', 'ENOTEMPTY'].includes(error?.code)
|
|
97
|
+
|| (error?.code === 'EPERM' && await lockSnapshot(lockDirectory) !== null);
|
|
98
|
+
if (held) throw Object.assign(new Error('Lock held.'), { code: 'EEXIST' });
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
85
101
|
}
|
|
86
102
|
|
|
87
103
|
async function releaseOwnedLock(lockDirectory, ownerId) {
|
|
@@ -118,19 +134,7 @@ export async function withSkillSyncLock(callback, {
|
|
|
118
134
|
|
|
119
135
|
for (;;) {
|
|
120
136
|
try {
|
|
121
|
-
await
|
|
122
|
-
try {
|
|
123
|
-
await writeLockOwnerAtomically(lockDirectory, {
|
|
124
|
-
id: ownerId,
|
|
125
|
-
pid: process.pid,
|
|
126
|
-
at: now(),
|
|
127
|
-
});
|
|
128
|
-
} catch (error) {
|
|
129
|
-
// This process exclusively created the directory and has not yet
|
|
130
|
-
// published an owner, so it is safe to undo a failed acquisition.
|
|
131
|
-
await rm(lockDirectory, { recursive: true, force: true });
|
|
132
|
-
throw error;
|
|
133
|
-
}
|
|
137
|
+
await publishOwnedLock(lockDirectory, { id: ownerId, pid: process.pid, at: now() });
|
|
134
138
|
break;
|
|
135
139
|
} catch (error) {
|
|
136
140
|
if (error?.code !== 'EEXIST') throw error;
|
package/src/runtime/transport.js
CHANGED
|
@@ -133,6 +133,25 @@ export function normalizeBackendError(status, payload, runtime) {
|
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
if (status === 409 && (backendError === 'store_check_required' || payload?.error_code === 'store_check_required')) {
|
|
137
|
+
// The Store refused an install or update without a check receipt the person confirmed: the agent sees that code
|
|
138
|
+
// and its reason (missing, expired, used, other_version, not_confirmed, unknown), with the check as the next step.
|
|
139
|
+
const reason = typeof payload?.reason === 'string' && payload.reason ? payload.reason : null;
|
|
140
|
+
return new CliError({
|
|
141
|
+
code: 'store_check_required',
|
|
142
|
+
message: reason ? `${message} (store_check_required: ${reason})` : `${message} (store_check_required)`,
|
|
143
|
+
exitCode: EXIT_CODES.conflict,
|
|
144
|
+
retryable: false,
|
|
145
|
+
details: { ...(payload || {}), ...(reason ? { reason } : {}) },
|
|
146
|
+
hints: [
|
|
147
|
+
{ command: 'notis spaces store check <listing-id>', reason: 'Check the Space, tell the person the risks and wait for their yes' },
|
|
148
|
+
{ command: 'notis spaces store install <listing-id> --request-id <id> --receipt <receipt_id> --confirmed',
|
|
149
|
+
reason: 'Install with the check receipt once they said yes (update: notis spaces store update <install-id> ...)' },
|
|
150
|
+
...(payload?.hints || []),
|
|
151
|
+
],
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
136
155
|
if (status === 409) {
|
|
137
156
|
return new CliError({
|
|
138
157
|
code: 'conflict',
|
|
@@ -15,10 +15,10 @@ async function rendererLibrary() {
|
|
|
15
15
|
|
|
16
16
|
/** Root command registration supplies flags/output formatting; this adapter holds no browser JWT. */
|
|
17
17
|
export async function renderViewWithCliRuntime({ runtime, url, outputs = ['markdown', 'screenshot'], width = 1440,
|
|
18
|
-
directory, signal, loadLibrary = rendererLibrary, request = httpRequest }) {
|
|
18
|
+
viewAs, directory, signal, loadLibrary = rendererLibrary, request = httpRequest }) {
|
|
19
19
|
if (typeof url !== 'string' || !url.trim() || ![390, 1440].includes(width)) throw usageError('Choose a view link and width 390 or 1440.');
|
|
20
20
|
const ticket = (await request({ runtime, method: 'POST', path: '/portal_view_render/prepare', spacesProtocol: true,
|
|
21
|
-
body: { url, outputs, width }, signal })).payload;
|
|
21
|
+
body: { url, outputs, width, ...(viewAs === 'public' ? { view_as: 'public' } : {}) }, signal })).payload;
|
|
22
22
|
if (typeof ticket?.credential !== 'string') throw usageError('The short-lived render ticket is missing.');
|
|
23
23
|
const library = await loadLibrary();
|
|
24
24
|
const broker = library.createRemoteRenderBroker({ apiBase: runtime.apiBase, credential: ticket.credential });
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
--secondary: 210 40% 96.1%;
|
|
32
32
|
--secondary-foreground: 222.2 47.4% 11.2%;
|
|
33
33
|
--muted: 210 40% 96.1%;
|
|
34
|
-
--muted-foreground: 0 0%
|
|
34
|
+
--muted-foreground: 0 0% 40%;
|
|
35
35
|
--accent: 210 40% 96.1%;
|
|
36
36
|
--accent-foreground: 222.2 47.4% 11.2%;
|
|
37
37
|
--destructive: 0 84.2% 60.2%;
|