@notis_ai/cli 0.2.25 → 0.2.27
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 +2866 -553
- 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/context.md +3 -0
- 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/NotisSelectionBoundary.tsx +79 -25
- 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 +88 -13
- package/dist/skill-sync-worker.mjs +127 -38
- 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/NotisSelectionBoundary.d.ts +19 -2
- 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 +761 -6
- 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/dom.js +15 -2
- 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/cloud-client.ts +98 -15
- package/src/runtime/skill-sync/index.ts +42 -4
- package/src/runtime/skill-sync/local-scanner.ts +1 -0
- package/src/runtime/skill-sync/types.ts +6 -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/src/skill-sync-worker.js +5 -1
- 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
|
@@ -5,19 +5,35 @@ import { appFilesDigest, buildArtifact, freezeSourceWorkspace, prepareAppRelease
|
|
|
5
5
|
import { validateProjectBoundary, validateProjectDesign, validateSourceDesign } from './app-boundary-validator.js';
|
|
6
6
|
import { collectSelectedSpaceSource, loadSelectedSpace } from './space-source.js';
|
|
7
7
|
import { viewManifestFields } from './space-view-manifest.js';
|
|
8
|
+
import { editorsOnlySummary, manifestActions, manifestResources } from './space-audience.js';
|
|
8
9
|
import { usageError } from './errors.js';
|
|
9
10
|
import { assertSourceRoot } from './source-root.js';
|
|
10
11
|
|
|
12
|
+
const SPACE_ICON = /^(phosphor:[a-z0-9]+(-[a-z0-9]+)*|https:\/\/\S{1,2000})$/;
|
|
13
|
+
|
|
14
|
+
/** Publication requires a chosen icon: the manifest carries an empty one until the agent sets it. */
|
|
15
|
+
export function requireSpaceIcon(manifest, key) {
|
|
16
|
+
if (typeof manifest?.icon === 'string' && SPACE_ICON.test(manifest.icon.trim())) return;
|
|
17
|
+
throw usageError(`Set icon in the ${key} Space's space.config.ts before deploying: a Phosphor icon that fits what the Space is about, `
|
|
18
|
+
+ "written 'phosphor:<kebab-name>' (for example 'phosphor:calendar-check'), or an https image URL. Nothing was published.");
|
|
19
|
+
}
|
|
20
|
+
|
|
11
21
|
export function generateSpaceManifest(selection) {
|
|
12
22
|
const definition = selection.definition;
|
|
23
|
+
const editorsOnly = editorsOnlySummary(definition);
|
|
13
24
|
return { schema: 'notis-space/v1', kind: selection.entry ? 'presentation' : 'container', local_key: selection.key,
|
|
14
|
-
name: definition.name, description: definition.description || '', icon: definition.icon ||
|
|
15
|
-
|
|
25
|
+
name: definition.name, description: definition.description || '', icon: definition.icon || '', accent: definition.accent || null,
|
|
26
|
+
// Editor-only markers never ride on the copied items: the one editors_only key below carries them.
|
|
27
|
+
resources: manifestResources(definition.resources), actions: manifestActions(definition.actions),
|
|
16
28
|
...(definition.navigation ? { navigation: definition.navigation } : {}),
|
|
17
29
|
// Absent when none, so manifests without viewer reads stay byte-identical.
|
|
18
30
|
...(definition.viewerReads?.length ? { viewer_reads: [...definition.viewerReads].sort() } : {}),
|
|
19
31
|
// Absent when undeclared, for the same reason.
|
|
20
32
|
...(definition.cloudComputer ? { cloud_computer: definition.cloudComputer } : {}),
|
|
33
|
+
// Agents its database changes wake; absent when undeclared.
|
|
34
|
+
...(definition.agents?.length ? { agents: definition.agents } : {}),
|
|
35
|
+
// Absent when nothing is editor-only (SPC-073: unmarked means public).
|
|
36
|
+
...(editorsOnly ? { editors_only: editorsOnly } : {}),
|
|
21
37
|
readable_context: definition.readableContext || '', collection: definition.collection || null,
|
|
22
38
|
// V4 declarations are mandatory for every presentation; the wire schema stays v1.
|
|
23
39
|
...viewManifestFields(definition, { entry: selection.entry, resources: definition.resources || {} }),
|
|
@@ -5,8 +5,9 @@ import { dirname, extname, join, relative, resolve, sep } from 'node:path';
|
|
|
5
5
|
import { collectSourceFiles, loadAppConfig } from './app-platform.js';
|
|
6
6
|
import { usageError } from './errors.js';
|
|
7
7
|
import { VIEW_DEFINITION_FIELDS, viewManifestFields } from './space-view-manifest.js';
|
|
8
|
+
import { editorOnlyColumns, editorsOnlyFlag, withoutMarker } from './space-audience.js';
|
|
8
9
|
|
|
9
|
-
const CONFIG_FIELDS = new Set(['name', 'description', 'icon', 'accent', 'entry', 'layout', 'readableContext', 'resources', 'actions', 'navigation', 'viewerReads', 'cloudComputer', 'collection', 'sourceIncludes', 'verificationFixtures', ...VIEW_DEFINITION_FIELDS]);
|
|
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
11
|
/** Reads with each signed-in viewer's own authority (never an issuer grant); see docs/notis-spaces-platform.md. */
|
|
11
12
|
export const VIEWER_READ_FAMILIES = Object.freeze(['databases', 'skills']);
|
|
12
13
|
const WORKSPACE_INDEXES = new Set(['notis.config.ts', 'notis.config.js', 'notis.config.mjs']);
|
|
@@ -88,6 +89,64 @@ function localPath(value) {
|
|
|
88
89
|
return value.replace(/^\.\//, '').replace(/\/$/, '');
|
|
89
90
|
}
|
|
90
91
|
|
|
92
|
+
const CLOUD_COMPUTER_LEVELS = ['read', 'shell'];
|
|
93
|
+
const CLOUD_COMPUTER_FIELDS = ['access', 'services'];
|
|
94
|
+
const CLOUD_SERVICE_FIELDS = ['id', 'command', 'cwd', 'ready'];
|
|
95
|
+
const CLOUD_SERVICE_ID = /^[a-z][a-z0-9-]{0,39}$/;
|
|
96
|
+
const MAX_CLOUD_SERVICES = 4;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* `cloudComputer` is 'read' | 'shell' | { access, services? }. The object is copied
|
|
100
|
+
* into the manifest as-is, so every rule here matches the server's own check.
|
|
101
|
+
*/
|
|
102
|
+
export function validateCloudComputer(value) {
|
|
103
|
+
const levels = "cloudComputer is 'read', 'shell' or { access: 'read' | 'shell', services? }: the page uses each signed-in viewer's own cloud computer once that viewer allows it.";
|
|
104
|
+
if (typeof value === 'string') {
|
|
105
|
+
if (!CLOUD_COMPUTER_LEVELS.includes(value)) throw usageError(levels);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) throw usageError(levels);
|
|
109
|
+
const unknown = Object.keys(value).filter(name => !CLOUD_COMPUTER_FIELDS.includes(name)).sort();
|
|
110
|
+
if (unknown.length) throw usageError(`Unsupported cloudComputer fields: ${unknown.join(', ')}. Use access and services.`);
|
|
111
|
+
if (!CLOUD_COMPUTER_LEVELS.includes(value.access)) throw usageError(levels);
|
|
112
|
+
if (value.services === undefined) return;
|
|
113
|
+
if (!Array.isArray(value.services)) throw usageError('cloudComputer.services is a list of { id, command, cwd?, ready? }.');
|
|
114
|
+
if (value.services.length && value.access !== 'shell') throw usageError("cloudComputer.services needs access: 'shell'.");
|
|
115
|
+
if (value.services.length > MAX_CLOUD_SERVICES) throw usageError(`cloudComputer declares at most ${MAX_CLOUD_SERVICES} services.`);
|
|
116
|
+
const seen = new Set();
|
|
117
|
+
for (const service of value.services) {
|
|
118
|
+
if (!service || typeof service !== 'object' || Array.isArray(service)) throw usageError('Each cloudComputer service is { id, command, cwd?, ready? }.');
|
|
119
|
+
const extra = Object.keys(service).filter(name => !CLOUD_SERVICE_FIELDS.includes(name)).sort();
|
|
120
|
+
if (extra.length) throw usageError(`Unsupported cloudComputer service fields: ${extra.join(', ')}. Use id, command, cwd and ready.`);
|
|
121
|
+
if (typeof service.id !== 'string' || !CLOUD_SERVICE_ID.test(service.id)) {
|
|
122
|
+
throw usageError('A cloudComputer service id starts with a lowercase letter, then up to 39 lowercase letters, digits or dashes.');
|
|
123
|
+
}
|
|
124
|
+
if (seen.has(service.id)) throw usageError(`cloudComputer service ${service.id} is declared twice.`);
|
|
125
|
+
seen.add(service.id);
|
|
126
|
+
const label = `cloudComputer service ${service.id}`;
|
|
127
|
+
if (typeof service.command !== 'string' || !service.command.trim() || service.command.length > 4096 || service.command.includes('\0')) {
|
|
128
|
+
throw usageError(`${label} needs a command of 1 to 4096 characters.`);
|
|
129
|
+
}
|
|
130
|
+
if (service.cwd !== undefined) {
|
|
131
|
+
if (typeof service.cwd === 'string') {
|
|
132
|
+
if (!service.cwd || service.cwd.length > 1024 || service.cwd.includes('\0')
|
|
133
|
+
|| service.cwd.split('/').some(part => part === '..')
|
|
134
|
+
|| (service.cwd.startsWith('/') && service.cwd !== '/vercel/sandbox' && !service.cwd.startsWith('/vercel/sandbox/'))) {
|
|
135
|
+
throw usageError(`${label} cwd is a cloud computer folder inside /vercel/sandbox, or { space: '<folder>' } inside the Space folder.`);
|
|
136
|
+
}
|
|
137
|
+
} else if (!service.cwd || typeof service.cwd !== 'object' || Array.isArray(service.cwd)
|
|
138
|
+
|| Object.keys(service.cwd).join(',') !== 'space' || typeof service.cwd.space !== 'string'
|
|
139
|
+
|| service.cwd.space.length > 1024 || service.cwd.space.startsWith('/') || service.cwd.space.includes('\0')
|
|
140
|
+
|| service.cwd.space.includes('\\') || service.cwd.space.split('/').some(part => part === '..')) {
|
|
141
|
+
throw usageError(`${label} cwd { space } is a folder relative to the Space folder, without a leading / or .. ('' or '.' is the Space folder).`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (service.ready !== undefined && (typeof service.ready !== 'string' || !service.ready.startsWith('/') || service.ready.length > 512)) {
|
|
145
|
+
throw usageError(`${label} ready is a path starting with / of at most 512 characters.`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
91
150
|
export async function loadSelectedSpace(projectDir, selectedKey) {
|
|
92
151
|
projectDir = realpathSync(projectDir);
|
|
93
152
|
selectedKey = key(selectedKey, 'Space');
|
|
@@ -130,11 +189,16 @@ export async function loadSelectedSpace(projectDir, selectedKey) {
|
|
|
130
189
|
if (!target || typeof target !== 'object' || Object.keys(target).join(',') !== 'key') throw usageError('A navigation reference needs one portable key.');
|
|
131
190
|
key(target.key, 'Navigation target');
|
|
132
191
|
}
|
|
192
|
+
// Editor-only parts (SPC-074): the whole view here, its columns on each database resource below.
|
|
193
|
+
if (editorsOnlyFlag(definition.editorsOnly, 'This view') && !entry) {
|
|
194
|
+
throw usageError('A container has no page, so it cannot be editors-only. Mark the views inside it.');
|
|
195
|
+
}
|
|
133
196
|
for (const [alias, resource] of Object.entries(resources)) {
|
|
134
197
|
key(alias, 'Resource alias');
|
|
198
|
+
editorOnlyColumns(alias, resource);
|
|
135
199
|
if (resource?.kind === 'database' && resource.create != null) {
|
|
136
200
|
const value = resource.create;
|
|
137
|
-
if (Object.keys(resource).some(name => !['kind', 'create'].includes(name))
|
|
201
|
+
if (Object.keys(resource).some(name => !['kind', 'create', 'columns'].includes(name))
|
|
138
202
|
|| !value || typeof value !== 'object' || Array.isArray(value)
|
|
139
203
|
|| Object.keys(value).some(name => !['name', 'schema', 'starterRows'].includes(name))
|
|
140
204
|
|| typeof value.name !== 'string' || !value.name.trim() || value.name.length > 200
|
|
@@ -149,7 +213,9 @@ export async function loadSelectedSpace(projectDir, selectedKey) {
|
|
|
149
213
|
continue;
|
|
150
214
|
}
|
|
151
215
|
if (!resource || !['database', 'document', 'skill', 'automation'].includes(resource.kind) || typeof resource.key !== 'string'
|
|
152
|
-
|| Object.keys(resource).some(name => !['kind', 'key'].includes(name)))
|
|
216
|
+
|| Object.keys(resource).some(name => !['kind', 'key', ...(resource.kind === 'database' ? ['columns'] : [])].includes(name))) {
|
|
217
|
+
throw usageError(`Invalid resource reference: ${alias}`);
|
|
218
|
+
}
|
|
153
219
|
}
|
|
154
220
|
if (definition.viewerReads != null && (!Array.isArray(definition.viewerReads)
|
|
155
221
|
|| definition.viewerReads.some(family => !VIEWER_READ_FAMILIES.includes(family))
|
|
@@ -157,15 +223,16 @@ export async function loadSelectedSpace(projectDir, selectedKey) {
|
|
|
157
223
|
throw usageError("viewerReads lists 'databases' and/or 'skills' once each: the page reads what each signed-in viewer can open.");
|
|
158
224
|
}
|
|
159
225
|
if (definition.viewerReads?.length && !entry) throw usageError('A container has no page, so it cannot declare viewerReads.');
|
|
160
|
-
if (definition.cloudComputer != null
|
|
161
|
-
throw usageError("cloudComputer is 'read' or 'shell': the page uses each signed-in viewer's own cloud computer once that viewer allows it.");
|
|
162
|
-
}
|
|
226
|
+
if (definition.cloudComputer != null) validateCloudComputer(definition.cloudComputer);
|
|
163
227
|
if (definition.cloudComputer != null && !entry) throw usageError('A container has no page, so it cannot use the cloud computer.');
|
|
228
|
+
if (definition.agents != null) validateSpaceAgents(definition.agents, resources);
|
|
164
229
|
if (definition.collection && (resources[definition.collection.database]?.kind !== 'database' || !definition.collection.titleProperty)) {
|
|
165
230
|
throw usageError('A collection needs a declared database binding and title property.');
|
|
166
231
|
}
|
|
167
|
-
for (const [actionId,
|
|
232
|
+
for (const [actionId, declared] of Object.entries(definition.actions || {})) {
|
|
168
233
|
key(actionId, 'Action');
|
|
234
|
+
editorsOnlyFlag(declared?.editorsOnly, `Action ${actionId}`);
|
|
235
|
+
const template = withoutMarker(declared);
|
|
169
236
|
if (!template || typeof template.tool !== 'string' || !template.tool || Object.keys(template).sort().join(',') !== 'arguments,inputs,tool'
|
|
170
237
|
|| template.inputs?.type !== 'object' || template.inputs?.additionalProperties !== false || !template.arguments || Array.isArray(template.arguments)) {
|
|
171
238
|
throw usageError(`Action ${actionId} needs the canonical closed inputs/tool/arguments template.`);
|
|
@@ -288,3 +355,34 @@ export function collectSelectedSpaceSource(projectDir, selection, { buildInputs
|
|
|
288
355
|
return result;
|
|
289
356
|
} finally { compiler.close(); }
|
|
290
357
|
}
|
|
358
|
+
|
|
359
|
+
const AGENT_FIELDS = ['id', 'on', 'thread', 'runtime', 'skill', 'wake', 'columns'];
|
|
360
|
+
const AGENT_COLUMNS = ['thread', 'scope', 'answer', 'author'];
|
|
361
|
+
|
|
362
|
+
/** The `agents` a Space's database changes wake (server/lib/space_agents.py repeats every check). */
|
|
363
|
+
export function validateSpaceAgents(agents, resources = {}) {
|
|
364
|
+
if (!Array.isArray(agents) || agents.length < 1 || agents.length > 8) throw usageError('Declare agents as a list of 1 to 8 agents.');
|
|
365
|
+
const seen = new Set();
|
|
366
|
+
for (const agent of agents) {
|
|
367
|
+
if (!agent || typeof agent !== 'object' || Array.isArray(agent) || Object.keys(agent).some(name => !AGENT_FIELDS.includes(name))) {
|
|
368
|
+
throw usageError(`Each agent takes ${AGENT_FIELDS.join(', ')} only.`);
|
|
369
|
+
}
|
|
370
|
+
if (typeof agent.id !== 'string' || !/^[a-z][a-z0-9_-]{0,39}$/.test(agent.id) || seen.has(agent.id)) {
|
|
371
|
+
throw usageError('Each agent needs its own short id: lowercase letters, digits, - and _.');
|
|
372
|
+
}
|
|
373
|
+
seen.add(agent.id);
|
|
374
|
+
const on = agent.on;
|
|
375
|
+
if (!on || typeof on !== 'object' || Object.keys(on).some(name => !['database', 'event'].includes(name)) || resources[on.database]?.kind !== 'database') {
|
|
376
|
+
throw usageError(`Agent ${agent.id} watches one of this Space's database resources: on: { database: '<alias>' }.`);
|
|
377
|
+
}
|
|
378
|
+
if (on.event != null && !['created', 'changed'].includes(on.event)) throw usageError(`Agent ${agent.id} wakes on 'created' or 'changed'.`);
|
|
379
|
+
if (agent.thread != null && !['best_match', 'space'].includes(agent.thread)) throw usageError(`Agent ${agent.id} uses thread 'best_match' or 'space'.`);
|
|
380
|
+
if (agent.runtime != null && !['notis', 'cloud_computer'].includes(agent.runtime)) throw usageError(`Agent ${agent.id} runs on 'notis' or 'cloud_computer'.`);
|
|
381
|
+
if (agent.wake != null && !['all', 'sent'].includes(agent.wake)) throw usageError(`Agent ${agent.id} wakes for 'all' comments or only those 'sent' to it.`);
|
|
382
|
+
if (agent.skill != null && resources[agent.skill]?.kind !== 'skill') throw usageError(`Agent ${agent.id} names a Skill this Space links.`);
|
|
383
|
+
if (agent.columns != null && (typeof agent.columns !== 'object' || Array.isArray(agent.columns)
|
|
384
|
+
|| Object.entries(agent.columns).some(([name, value]) => !AGENT_COLUMNS.includes(name) || typeof value !== 'string' || !value || value.length > 100))) {
|
|
385
|
+
throw usageError(`Agent ${agent.id} renames only the ${AGENT_COLUMNS.join(', ')} columns.`);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
@@ -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 });
|
package/src/skill-sync-worker.js
CHANGED
|
@@ -106,7 +106,11 @@ export async function main(args = process.argv.slice(2), {
|
|
|
106
106
|
} catch (error) {
|
|
107
107
|
// Persist only a classified error, never a bearer, signed URL or response body.
|
|
108
108
|
const code = error.code || 'sync_failed';
|
|
109
|
-
|
|
109
|
+
// An HTTP refusal keeps its status, e.g. `edge_blocked` with 403 when the
|
|
110
|
+
// edge in front of the API refused the request before it reached Notis.
|
|
111
|
+
const httpStatus = Number.isInteger(error.status) ? { http_status: error.status } : {};
|
|
112
|
+
record({ status: 'error', code, ...httpStatus,
|
|
113
|
+
...(REJECTED_SIGN_IN_CODES.has(code) && signIn ? { sign_in: signIn } : {}) });
|
|
110
114
|
process.exitCode = 1;
|
|
111
115
|
} finally {
|
|
112
116
|
clearTimeout(deadline);
|
|
@@ -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%;
|