@sequenceholdings/artifact-studio 0.4.0 → 0.5.0

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.
Files changed (90) hide show
  1. package/README.md +35 -1
  2. package/VERSION-PIN.md +9 -0
  3. package/dist/active-deploy-policy.d.ts +9 -3
  4. package/dist/active-deploy-policy.js +20 -8
  5. package/dist/artifact-env-bindings.d.ts +9 -0
  6. package/dist/artifact-env-bindings.js +32 -0
  7. package/dist/build.js +6 -0
  8. package/dist/cli.js +61 -12
  9. package/dist/deployment-validation.d.ts +2 -0
  10. package/dist/deployment-validation.js +2 -0
  11. package/dist/dev-link.js +28 -2
  12. package/dist/env-binding-scan.d.ts +10 -0
  13. package/dist/env-binding-scan.js +179 -0
  14. package/dist/env-bindings.d.ts +52 -0
  15. package/dist/env-bindings.js +180 -0
  16. package/dist/gateway/control.d.ts +33 -0
  17. package/dist/gateway/control.js +29 -0
  18. package/dist/gateway/hosted-proxy.d.ts +5 -0
  19. package/dist/gateway/hosted-proxy.js +4 -1
  20. package/dist/gateway/lattice-invoke.d.ts +48 -0
  21. package/dist/gateway/lattice-invoke.js +245 -0
  22. package/dist/gateway/lattice-upstream.d.ts +38 -0
  23. package/dist/gateway/lattice-upstream.js +136 -0
  24. package/dist/gateway/server.js +2 -3
  25. package/dist/gateway/session.d.ts +3 -1
  26. package/dist/gateway/session.js +10 -3
  27. package/dist/manifest-next.d.ts +55 -0
  28. package/dist/manifest-next.js +35 -2
  29. package/dist/manifest-static.d.ts +35 -0
  30. package/dist/manifest-static.js +12 -0
  31. package/dist/manifest.d.ts +48 -0
  32. package/dist/next-build.d.ts +2 -1
  33. package/dist/next-build.js +12 -7
  34. package/dist/offline/cache.d.ts +4 -0
  35. package/dist/offline/cache.js +7 -0
  36. package/dist/offline/connector.d.ts +26 -0
  37. package/dist/offline/connector.js +118 -0
  38. package/dist/offline/crypto.d.ts +5 -0
  39. package/dist/offline/crypto.js +24 -0
  40. package/dist/offline/index.d.ts +8 -0
  41. package/dist/offline/index.js +7 -0
  42. package/dist/offline/indexed-db.d.ts +10 -0
  43. package/dist/offline/indexed-db.js +104 -0
  44. package/dist/offline/outbox.d.ts +7 -0
  45. package/dist/offline/outbox.js +46 -0
  46. package/dist/offline/replay.d.ts +25 -0
  47. package/dist/offline/replay.js +192 -0
  48. package/dist/offline/secure-store.d.ts +6 -0
  49. package/dist/offline/secure-store.js +51 -0
  50. package/dist/offline/types.d.ts +162 -0
  51. package/dist/offline/types.js +1 -0
  52. package/dist/orm-json-scalars.d.ts +21 -0
  53. package/dist/orm-json-scalars.js +21 -0
  54. package/dist/runtime-contracts.d.ts +7 -7
  55. package/dist/sdk-orm.d.ts +7 -1
  56. package/dist/sdk-orm.js +12 -5
  57. package/dist/sdk.d.ts +126 -0
  58. package/dist/server/broker-contract.d.ts +191 -5
  59. package/dist/server/broker-contract.js +142 -1
  60. package/dist/server/client.d.ts +60 -12
  61. package/dist/server/client.js +143 -20
  62. package/dist/server/errors.d.ts +26 -0
  63. package/dist/server/errors.js +29 -0
  64. package/dist/server/managed-server-path.d.ts +6 -0
  65. package/dist/server/managed-server-path.js +14 -0
  66. package/dist/server/processes.d.ts +290 -0
  67. package/dist/server/processes.js +56 -0
  68. package/dist/server/request-context.d.ts +6 -0
  69. package/dist/server/request-context.js +10 -1
  70. package/dist/server.d.ts +5 -1
  71. package/dist/server.js +1 -0
  72. package/dist/source-resolver.d.ts +9 -2
  73. package/dist/source-resolver.js +55 -8
  74. package/dist/templates/nextjs/AGENTS.md +10 -0
  75. package/dist/templates/nextjs/CLAUDE.md +1 -0
  76. package/dist/templates/nextjs/README.md +88 -0
  77. package/dist/templates/react-vite/AGENTS.md +8 -88
  78. package/dist/templates/react-vite/CLAUDE.md +0 -6
  79. package/dist/templates/react-vite/package.json +1 -1
  80. package/dist/templates/react-vite/src/App.tsx +37 -14
  81. package/dist/templates/react-vite/src/styles.css +10 -0
  82. package/package.json +7 -3
  83. package/templates/nextjs/AGENTS.md +10 -0
  84. package/templates/nextjs/CLAUDE.md +1 -0
  85. package/templates/nextjs/README.md +88 -0
  86. package/templates/react-vite/AGENTS.md +8 -88
  87. package/templates/react-vite/CLAUDE.md +0 -6
  88. package/templates/react-vite/package.json +1 -1
  89. package/templates/react-vite/src/App.tsx +37 -14
  90. package/templates/react-vite/src/styles.css +10 -0
@@ -0,0 +1,136 @@
1
+ import { request as httpsRequest } from 'node:https';
2
+ import { assertSafeRequest } from '../tunnel/protocol.js';
3
+ import { isManagedServerInvokePath } from '../server/managed-server-path.js';
4
+ import { HOSTED_ARTIFACT_PROXY_LIMITS, cloudRunOrigin, hostedIdentityToken } from './hosted-proxy.js';
5
+ const BODY_CAP = 1024 * 1024;
6
+ /**
7
+ * Buffered POST into a hosted Next.js app. The destination must already be a
8
+ * Cloud Run origin Atlas resolved; this rejects anything else before dialing.
9
+ */
10
+ export async function invokeHostedArtifact(input) {
11
+ if (!isManagedServerInvokePath(input.path))
12
+ throw new Error('Invalid managed server path');
13
+ const upstream = cloudRunOrigin(input.upstreamUrl);
14
+ const audience = input.upstreamAudience === undefined ? upstream : cloudRunOrigin(input.upstreamAudience);
15
+ assertSafeRequest('POST', input.path);
16
+ const payload = Buffer.from(JSON.stringify(input.body ?? {}));
17
+ if (payload.byteLength > BODY_CAP)
18
+ throw new Error('Managed server body exceeds 1 MiB');
19
+ const timeoutMs = Math.min(Math.max(input.timeoutMs, 1), HOSTED_ARTIFACT_PROXY_LIMITS.maxTimeoutMs);
20
+ const signal = invocationSignal({ timeoutMs, signal: input.signal });
21
+ const token = await withSignal((input.identityTokenProvider ?? hostedIdentityToken)({ audience: audience.origin, signal }), signal);
22
+ if (!/^[A-Za-z0-9._~-]+$/.test(token) || token.length > 16384)
23
+ throw new Error('Invalid platform token');
24
+ const headers = {
25
+ host: upstream.host,
26
+ 'content-type': 'application/json',
27
+ 'content-length': String(payload.byteLength),
28
+ 'accept-encoding': 'identity',
29
+ 'x-serverless-authorization': `Bearer ${token}`,
30
+ 'x-sequence-artifact-context': input.requestContext,
31
+ };
32
+ const hop = { origin: upstream, path: input.path, headers, body: payload, timeoutMs, signal };
33
+ const response = await withSignal(input.dispatch ? input.dispatch(hop) : postCloudRun({ ...hop, dial: input.dial }), signal);
34
+ if (response.body.byteLength > BODY_CAP)
35
+ throw new Error('Managed server response exceeds 1 MiB');
36
+ return { status: response.status, body: decodeBody(response) };
37
+ }
38
+ function decodeBody(response) {
39
+ if (response.body.byteLength === 0)
40
+ return null;
41
+ const text = response.body.toString('utf8');
42
+ if (response.contentType?.split(';', 1)[0]?.trim().toLowerCase() !== 'application/json')
43
+ return text;
44
+ try {
45
+ return JSON.parse(text);
46
+ }
47
+ catch {
48
+ return text;
49
+ }
50
+ }
51
+ /**
52
+ * `timeoutMs` is a deadline from the start of the call, not socket idle time.
53
+ * Streaming a chunk forever must not extend it. `signal` is the worker's
54
+ * disconnect; either one destroys the Cloud Run request.
55
+ */
56
+ function invocationSignal({ timeoutMs, signal }) {
57
+ const deadline = AbortSignal.timeout(timeoutMs);
58
+ return signal ? AbortSignal.any([signal, deadline]) : deadline;
59
+ }
60
+ function invocationAbortError(signal) {
61
+ const reason = signal.reason;
62
+ if (reason instanceof Error && reason.name === 'TimeoutError')
63
+ return new Error('Managed server invocation timed out');
64
+ if (reason instanceof Error && /timed out/i.test(reason.message))
65
+ return reason;
66
+ return new Error('Managed server invocation cancelled');
67
+ }
68
+ function withSignal(work, signal) {
69
+ if (signal.aborted)
70
+ return Promise.reject(invocationAbortError(signal));
71
+ return new Promise((resolve, reject) => {
72
+ const onAbort = () => reject(invocationAbortError(signal));
73
+ signal.addEventListener('abort', onAbort, { once: true });
74
+ work.then((value) => { signal.removeEventListener('abort', onAbort); resolve(value); }, (error) => { signal.removeEventListener('abort', onAbort); reject(error); });
75
+ });
76
+ }
77
+ function postCloudRun(input) {
78
+ return new Promise((resolve, reject) => {
79
+ if (input.signal.aborted) {
80
+ reject(invocationAbortError(input.signal));
81
+ return;
82
+ }
83
+ let settled = false;
84
+ let incoming;
85
+ let onAbort = () => { };
86
+ const stop = () => input.signal.removeEventListener('abort', onAbort);
87
+ const fail = (error) => {
88
+ if (settled)
89
+ return;
90
+ settled = true;
91
+ stop();
92
+ incoming?.destroy();
93
+ request.destroy();
94
+ reject(error instanceof Error ? error : new Error('Managed server invocation failed'));
95
+ };
96
+ const succeed = (value) => {
97
+ if (settled)
98
+ return;
99
+ settled = true;
100
+ stop();
101
+ resolve(value);
102
+ };
103
+ const request = (input.dial ?? httpsRequest)(input.origin, {
104
+ method: 'POST',
105
+ path: input.path,
106
+ headers: input.headers,
107
+ timeout: input.timeoutMs,
108
+ }, (response) => {
109
+ incoming = response;
110
+ const chunks = [];
111
+ let length = 0;
112
+ response.on('data', (chunk) => {
113
+ length += chunk.byteLength;
114
+ if (length > BODY_CAP) {
115
+ fail(new Error('Managed server response exceeds 1 MiB'));
116
+ return;
117
+ }
118
+ chunks.push(chunk);
119
+ });
120
+ response.on('end', () => {
121
+ const contentType = response.headers['content-type'];
122
+ succeed({
123
+ status: response.statusCode ?? 502,
124
+ ...(typeof contentType === 'string' ? { contentType } : {}),
125
+ body: Buffer.concat(chunks),
126
+ });
127
+ });
128
+ response.on('error', fail);
129
+ });
130
+ onAbort = () => fail(invocationAbortError(input.signal));
131
+ input.signal.addEventListener('abort', onAbort, { once: true });
132
+ request.on('error', fail);
133
+ request.on('timeout', () => fail(new Error('Managed server invocation timed out')));
134
+ request.end(input.body);
135
+ });
136
+ }
@@ -6,6 +6,7 @@ import { assertSafeRequest, normalizePublicOrigin } from '../tunnel/protocol.js'
6
6
  import { GatewayControlError } from './control.js';
7
7
  import { decodeGatewaySession, gatewaySessionCookies, renewGatewaySession, signGatewayContext } from './session.js';
8
8
  import { proxyHostedArtifact } from './hosted-proxy.js';
9
+ import { routeSequenceRequest } from './lattice-invoke.js';
9
10
  import { admitHostedMutation, ReleaseAdmissionError } from './release-admission.js';
10
11
  import { ArtifactAdmissionError } from './admission.js';
11
12
  import { gatewayClientAddress } from './control-admission.js';
@@ -285,10 +286,8 @@ export function createArtifactGateway(options) {
285
286
  await exchangeTicket({ request, response, origin });
286
287
  return;
287
288
  }
288
- if (request.url?.startsWith('/_sequence/')) {
289
- json(response, 404, 'not_found');
289
+ if (await routeSequenceRequest({ request, response, control: options.control, privateKey: options.contextPrivateKey, keyId: options.contextKeyId, admission: options.admission, usage }))
290
290
  return;
291
- }
292
291
  if (['GET', 'HEAD'].includes(request.method ?? 'GET')) {
293
292
  const url = new URL(request.url ?? '/', origin);
294
293
  if (url.searchParams.has('__sequence_release')) {
@@ -71,7 +71,7 @@ export declare function decodeGatewaySession(input: {
71
71
  frameworkBuildId?: string;
72
72
  }): GatewaySession | null;
73
73
  /** A fresh jti on every signature: a context names one originating request and its method. */
74
- export declare function signGatewayContext({ session, method, path, privateKey, keyId, now, capabilities, serviceAccountId, requestId }: {
74
+ export declare function signGatewayContext({ session, method, path, privateKey, keyId, now, capabilities, serviceAccountId, requestId, ttlSeconds }: {
75
75
  session: GatewaySession;
76
76
  method: string;
77
77
  path: string;
@@ -81,5 +81,7 @@ export declare function signGatewayContext({ session, method, path, privateKey,
81
81
  capabilities?: string[];
82
82
  serviceAccountId?: string | null;
83
83
  requestId?: string;
84
+ /** Seconds until exp. Browser requests stay at 60; a Lattice run may last up to 300. */
85
+ ttlSeconds?: number;
84
86
  }): string;
85
87
  export {};
@@ -1,6 +1,6 @@
1
1
  import { createHmac, createPrivateKey, randomUUID, sign, timingSafeEqual } from 'node:crypto';
2
2
  import { z } from 'zod';
3
- import { artifactRequestContextSchema } from '../server/request-context.js';
3
+ import { ARTIFACT_CONTEXT_MAX_AGE_SECONDS, ARTIFACT_LATTICE_CONTEXT_MAX_AGE_SECONDS, artifactRequestContextSchema } from '../server/request-context.js';
4
4
  import { normalizePublicOrigin } from '../tunnel/protocol.js';
5
5
  import { artifactNextFrameworkBuildIdSchema } from '../runtime-contracts.js';
6
6
  export const GATEWAY_SESSION_COOKIE = '__Host-atlas-artifact-session';
@@ -137,13 +137,20 @@ export function decodeGatewaySession(input) {
137
137
  return matches.sort((left, right) => right.expiresAt - left.expiresAt || (left.deploymentId ?? '').localeCompare(right.deploymentId ?? ''))[0] ?? null;
138
138
  }
139
139
  /** A fresh jti on every signature: a context names one originating request and its method. */
140
- export function signGatewayContext({ session, method, path, privateKey, keyId, now = Math.floor(Date.now() / 1000), capabilities = [], serviceAccountId = null, requestId = randomUUID() }) {
140
+ export function signGatewayContext({ session, method, path, privateKey, keyId, now = Math.floor(Date.now() / 1000), capabilities = [], serviceAccountId = null, requestId = randomUUID(), ttlSeconds = ARTIFACT_CONTEXT_MAX_AGE_SECONDS }) {
141
+ const latticeRun = session.lattice?.runId ?? null;
142
+ const ceiling = latticeRun !== null && latticeRun !== ''
143
+ ? ARTIFACT_LATTICE_CONTEXT_MAX_AGE_SECONDS
144
+ : ARTIFACT_CONTEXT_MAX_AGE_SECONDS;
145
+ if (!Number.isInteger(ttlSeconds) || ttlSeconds < 1 || ttlSeconds > ceiling) {
146
+ throw new Error(`Artifact context lifetime must be 1..${ceiling} seconds`);
147
+ }
141
148
  const context = artifactRequestContextSchema.parse({
142
149
  v: 1, iss: 'atlas-artifact-gateway', aud: `artifact:${session.projectId}`,
143
150
  sub: session.ownerId, projectId: session.projectId, environment: session.environment,
144
151
  mode: session.kind === 'development' ? 'development' : session.published ? 'published' : 'preview',
145
152
  deploymentId: session.deploymentId, devSessionId: session.sessionId, requestId, jti: randomUUID(),
146
- method, path, iat: now, exp: now + 60, capabilities, serviceAccountId,
153
+ method, path, iat: now, exp: now + ttlSeconds, capabilities, serviceAccountId,
147
154
  bridge: session.bridge, theme: 'system',
148
155
  lattice: session.lattice ?? { runId: null, nodeId: null, stepId: null, processId: null },
149
156
  ...(session.taskRoutes ? { taskRoutes: session.taskRoutes } : {}),
@@ -20,7 +20,18 @@ export declare const ARTIFACT_NEXT_RESOURCE_DEFAULTS: {
20
20
  max_instances: number;
21
21
  timeout_seconds: number;
22
22
  };
23
+ /**
24
+ * Where the server's audit events (`client.audit.record`) go: an Atlas audit service id. Every
25
+ * application may record under `artifact_studio`; Atlas admits a first-party service, such as
26
+ * `application_portal`, only for the projects it registers for it. Server-only: browsers can't audit.
27
+ */
28
+ export declare const artifactNextAuditCapabilitySchema: z.ZodObject<{
29
+ service: z.ZodString;
30
+ }, z.core.$strict>;
23
31
  export declare const artifactNextServerCapabilitiesSchema: z.ZodPrefault<z.ZodObject<{
32
+ audit: z.ZodOptional<z.ZodObject<{
33
+ service: z.ZodString;
34
+ }, z.core.$strict>>;
24
35
  storage: z.ZodOptional<z.ZodRecord<z.ZodUUID, z.ZodEnum<{
25
36
  viewer: "viewer";
26
37
  editor: "editor";
@@ -37,6 +48,11 @@ export declare const artifactNextServerCapabilitiesSchema: z.ZodPrefault<z.ZodOb
37
48
  functions: z.ZodPrefault<z.ZodObject<{
38
49
  invoke: z.ZodDefault<z.ZodArray<z.ZodString>>;
39
50
  }, z.core.$strict>>;
51
+ processes: z.ZodPrefault<z.ZodObject<{
52
+ start: z.ZodDefault<z.ZodArray<z.ZodString>>;
53
+ read: z.ZodDefault<z.ZodArray<z.ZodString>>;
54
+ act: z.ZodDefault<z.ZodArray<z.ZodString>>;
55
+ }, z.core.$strict>>;
40
56
  }, z.core.$strict>>;
41
57
  export type ArtifactNextServerCapabilities = z.infer<typeof artifactNextServerCapabilitiesSchema>;
42
58
  export declare const artifactNextResourceLimitsSchema: z.ZodPrefault<z.ZodObject<{
@@ -70,6 +86,9 @@ export declare const artifactNextBuildConfigSchema: z.ZodPrefault<z.ZodObject<{
70
86
  }, z.core.$strict>>;
71
87
  export declare const artifactNextServerSchema: z.ZodPrefault<z.ZodObject<{
72
88
  capabilities: z.ZodPrefault<z.ZodObject<{
89
+ audit: z.ZodOptional<z.ZodObject<{
90
+ service: z.ZodString;
91
+ }, z.core.$strict>>;
73
92
  storage: z.ZodOptional<z.ZodRecord<z.ZodUUID, z.ZodEnum<{
74
93
  viewer: "viewer";
75
94
  editor: "editor";
@@ -86,6 +105,11 @@ export declare const artifactNextServerSchema: z.ZodPrefault<z.ZodObject<{
86
105
  functions: z.ZodPrefault<z.ZodObject<{
87
106
  invoke: z.ZodDefault<z.ZodArray<z.ZodString>>;
88
107
  }, z.core.$strict>>;
108
+ processes: z.ZodPrefault<z.ZodObject<{
109
+ start: z.ZodDefault<z.ZodArray<z.ZodString>>;
110
+ read: z.ZodDefault<z.ZodArray<z.ZodString>>;
111
+ act: z.ZodDefault<z.ZodArray<z.ZodString>>;
112
+ }, z.core.$strict>>;
89
113
  }, z.core.$strict>>;
90
114
  service_account: z.ZodOptional<z.ZodString>;
91
115
  secrets: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -105,8 +129,18 @@ export declare const artifactNextServerSchema: z.ZodPrefault<z.ZodObject<{
105
129
  cache: z.ZodOptional<z.ZodObject<{
106
130
  capacity_gb: z.ZodNumber;
107
131
  }, z.core.$strict>>;
132
+ lattice: z.ZodOptional<z.ZodObject<{
133
+ accept: z.ZodDefault<z.ZodArray<z.ZodString>>;
134
+ }, z.core.$strict>>;
108
135
  }, z.core.$strict>>;
109
136
  export declare const artifactStudioNextManifestSchema: z.ZodObject<{
137
+ ontology: z.ZodOptional<z.ZodObject<{
138
+ version: z.ZodLiteral<1>;
139
+ read: z.ZodDefault<z.ZodArray<z.ZodString>>;
140
+ write: z.ZodDefault<z.ZodArray<z.ZodString>>;
141
+ produce: z.ZodDefault<z.ZodArray<z.ZodString>>;
142
+ invoke: z.ZodDefault<z.ZodArray<z.ZodString>>;
143
+ }, z.core.$strict>>;
110
144
  bundle: z.ZodObject<{
111
145
  name: z.ZodString;
112
146
  schema_version: z.ZodLiteral<2>;
@@ -155,6 +189,11 @@ export declare const artifactStudioNextManifestSchema: z.ZodObject<{
155
189
  functions: z.ZodPrefault<z.ZodObject<{
156
190
  invoke: z.ZodDefault<z.ZodArray<z.ZodString>>;
157
191
  }, z.core.$strict>>;
192
+ processes: z.ZodPrefault<z.ZodObject<{
193
+ start: z.ZodDefault<z.ZodArray<z.ZodString>>;
194
+ read: z.ZodDefault<z.ZodArray<z.ZodString>>;
195
+ act: z.ZodDefault<z.ZodArray<z.ZodString>>;
196
+ }, z.core.$strict>>;
158
197
  }, z.core.$strict>>;
159
198
  build: z.ZodPrefault<z.ZodObject<{
160
199
  public_env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
@@ -166,6 +205,9 @@ export declare const artifactStudioNextManifestSchema: z.ZodObject<{
166
205
  }, z.core.$strict>>;
167
206
  server: z.ZodPrefault<z.ZodObject<{
168
207
  capabilities: z.ZodPrefault<z.ZodObject<{
208
+ audit: z.ZodOptional<z.ZodObject<{
209
+ service: z.ZodString;
210
+ }, z.core.$strict>>;
169
211
  storage: z.ZodOptional<z.ZodRecord<z.ZodUUID, z.ZodEnum<{
170
212
  viewer: "viewer";
171
213
  editor: "editor";
@@ -182,6 +224,11 @@ export declare const artifactStudioNextManifestSchema: z.ZodObject<{
182
224
  functions: z.ZodPrefault<z.ZodObject<{
183
225
  invoke: z.ZodDefault<z.ZodArray<z.ZodString>>;
184
226
  }, z.core.$strict>>;
227
+ processes: z.ZodPrefault<z.ZodObject<{
228
+ start: z.ZodDefault<z.ZodArray<z.ZodString>>;
229
+ read: z.ZodDefault<z.ZodArray<z.ZodString>>;
230
+ act: z.ZodDefault<z.ZodArray<z.ZodString>>;
231
+ }, z.core.$strict>>;
185
232
  }, z.core.$strict>>;
186
233
  service_account: z.ZodOptional<z.ZodString>;
187
234
  secrets: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -201,10 +248,18 @@ export declare const artifactStudioNextManifestSchema: z.ZodObject<{
201
248
  cache: z.ZodOptional<z.ZodObject<{
202
249
  capacity_gb: z.ZodNumber;
203
250
  }, z.core.$strict>>;
251
+ lattice: z.ZodOptional<z.ZodObject<{
252
+ accept: z.ZodDefault<z.ZodArray<z.ZodString>>;
253
+ }, z.core.$strict>>;
204
254
  }, z.core.$strict>>;
205
255
  targets: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
206
256
  url: z.ZodString;
207
257
  }, z.core.$strict>>>;
258
+ presentation: z.ZodOptional<z.ZodObject<{
259
+ mobile: z.ZodOptional<z.ZodEnum<{
260
+ responsive: "responsive";
261
+ }>>;
262
+ }, z.core.$strip>>;
208
263
  sidebarIcon: z.ZodOptional<z.ZodString>;
209
264
  sidebarBadge: z.ZodOptional<z.ZodObject<{
210
265
  endpoint: z.ZodString;
@@ -1,7 +1,9 @@
1
1
  import { storageScopesSchema } from '@sequenceholdings/storage';
2
+ import { ontologyContractSchema } from '@sequenceholdings/orm/canonical';
2
3
  import { z } from 'zod';
3
4
  import { capabilityPinsSchema, customRolesBlockSchema, validateCapabilityPins } from './manifest-custom-roles.js';
4
- import { apiCapabilityPathAllowed, artifactStudioStaticManifestSchema, sidebarBadgeSchema } from './manifest-static.js';
5
+ import { isManagedServerInvokePath } from './server/managed-server-path.js';
6
+ import { apiCapabilityPathAllowed, artifactPresentationSchema, artifactStudioStaticManifestSchema, sidebarBadgeSchema, } from './manifest-static.js';
5
7
  /** Approved major/minor profile. Builds additionally record exact patch versions. */
6
8
  export const ARTIFACT_NEXT_RUNTIME = Object.freeze({ sdk: 'sequence', node: 24, react: 19, next: '16.3' });
7
9
  /** Admission policy for new development sessions and builds; retained releases keep their recorded toolchain. */
@@ -30,13 +32,34 @@ const ormTableRef = /^[a-z][a-z0-9_]{0,40}\/(?:[a-z][a-z0-9_]{0,62}|platformUser
30
32
  const ormOperationRef = /^[a-z][a-z0-9_]{0,40}\/ops\/[_A-Za-z][_0-9A-Za-z]*$/;
31
33
  const dataReadRef = boundedRef.refine((ref) => ormTableRef.test(ref), 'ORM read references use namespace/table');
32
34
  const dataWriteRef = boundedRef.refine((ref) => ormTableRef.test(ref) || ormOperationRef.test(ref), 'ORM write references use namespace/ops/Operation or namespace/table');
35
+ const latticeProcessRef = z.string().min(2).max(128).regex(/^[A-Za-z0-9._-]+$/, 'Process references are Lattice process ids');
33
36
  const reachShape = {
34
37
  storage: storageScopesSchema.optional(),
35
38
  data: z.strictObject({ read: z.array(dataReadRef).max(256).default([]), write: z.array(dataWriteRef).max(256).default([]) }).prefault({}),
36
39
  api: z.strictObject({ read: z.array(apiPath).max(256).default([]), write: z.array(apiPath).max(256).default([]) }).prefault({}),
37
40
  functions: z.strictObject({ invoke: z.array(boundedRef).max(256).default([]) }).prefault({}),
41
+ // `start`: processes the server may start runs of. `read`: processes whose runs, template and
42
+ // the user's own steps it may read. `act`: processes whose human steps it may advance and
43
+ // reassign, and whose runs' viewers it may manage. All name exact process ids; the user's own
44
+ // Invoker / Viewer / Advancer / Owner grants decide what happens.
45
+ processes: z.strictObject({
46
+ start: z.array(latticeProcessRef).max(256).default([]),
47
+ read: z.array(latticeProcessRef).max(256).default([]),
48
+ act: z.array(latticeProcessRef).max(256).default([]),
49
+ }).prefault({}),
38
50
  };
39
- export const artifactNextServerCapabilitiesSchema = z.strictObject(reachShape).prefault({});
51
+ /**
52
+ * Where the server's audit events (`client.audit.record`) go: an Atlas audit service id. Every
53
+ * application may record under `artifact_studio`; Atlas admits a first-party service, such as
54
+ * `application_portal`, only for the projects it registers for it. Server-only: browsers can't audit.
55
+ */
56
+ export const artifactNextAuditCapabilitySchema = z.strictObject({
57
+ service: z.string().regex(/^[a-z][a-z0-9_]{0,63}$/, 'Audit services are Atlas audit service ids, such as artifact_studio'),
58
+ });
59
+ export const artifactNextServerCapabilitiesSchema = z.strictObject({
60
+ ...reachShape,
61
+ audit: artifactNextAuditCapabilitySchema.optional(),
62
+ }).prefault({});
40
63
  // Reuse role semantics and validation; only the new manifest rejects unknown keys.
41
64
  const strictCustomRoles = customRolesBlockSchema.safeExtend({
42
65
  definitions: z.record(customRolesBlockSchema.shape.definitions.unwrap().keyType, customRolesBlockSchema.shape.definitions.unwrap().valueType.strict()).default({}),
@@ -83,6 +106,7 @@ export const artifactNextBuildConfigSchema = z.strictObject({
83
106
  public_fonts: z.array(artifactNextPublicFontSchema).max(8).refine((fonts) => new Set(fonts.map((font) => font.path)).size === fonts.length, 'Public font destination paths must be unique').default([]),
84
107
  }).prefault({});
85
108
  const hostname = z.string().max(253).regex(/^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?$/, 'Egress entries must be exact lowercase DNS hostnames without schemes, ports, paths, IPs, or wildcards').refine((host) => !host.endsWith('.localhost') && !host.endsWith('.local') && !host.endsWith('.internal'), 'Egress cannot target local or platform-internal hostnames');
109
+ const managedServerInvokePath = z.string().refine(isManagedServerInvokePath, 'Lattice accept paths are exact origin-relative paths with no query or traversal');
86
110
  export const artifactNextServerSchema = z.strictObject({
87
111
  capabilities: artifactNextServerCapabilitiesSchema,
88
112
  service_account: serviceAccountRef.optional(),
@@ -90,6 +114,10 @@ export const artifactNextServerSchema = z.strictObject({
90
114
  egress: z.array(hostname).max(64).default([]),
91
115
  resources: artifactNextResourceLimitsSchema,
92
116
  cache: z.strictObject({ capacity_gb: z.number().int().min(1).max(16) }).optional(),
117
+ /** Paths Lattice may POST. Exact match only; omitted means Lattice cannot call this server. */
118
+ lattice: z.strictObject({
119
+ accept: z.array(managedServerInvokePath).max(32).default([]),
120
+ }).optional(),
93
121
  }).superRefine((server, ctx) => {
94
122
  if (new Set(server.secrets.map((secret) => secret.name)).size !== server.secrets.length) {
95
123
  ctx.addIssue({ code: 'custom', path: ['secrets'], message: 'Each secret environment name must be unique' });
@@ -97,6 +125,9 @@ export const artifactNextServerSchema = z.strictObject({
97
125
  if (new Set(server.egress).size !== server.egress.length) {
98
126
  ctx.addIssue({ code: 'custom', path: ['egress'], message: 'Egress hosts must be unique' });
99
127
  }
128
+ if (server.lattice && new Set(server.lattice.accept).size !== server.lattice.accept.length) {
129
+ ctx.addIssue({ code: 'custom', path: ['lattice', 'accept'], message: 'Lattice accept paths must be unique' });
130
+ }
100
131
  }).prefault({});
101
132
  const appRoot = z.string().min(1).max(512).refine((value) => {
102
133
  if (value === '.')
@@ -105,6 +136,7 @@ const appRoot = z.string().min(1).max(512).refine((value) => {
105
136
  value.split('/').every((part) => part !== '' && part !== '.' && part !== '..' && !part.startsWith('.') && part !== 'node_modules');
106
137
  }, 'app_root must be a relative source directory without traversal, hidden directories, or node_modules').default('.');
107
138
  export const artifactStudioNextManifestSchema = z.strictObject({
139
+ ontology: ontologyContractSchema.optional(),
108
140
  bundle: z.strictObject({ name: z.string().min(1).max(255), schema_version: z.literal(2) }),
109
141
  artifact: z.strictObject({
110
142
  project_id: artifactStudioStaticManifestSchema.shape.artifact.shape.project_id,
@@ -120,6 +152,7 @@ export const artifactStudioNextManifestSchema = z.strictObject({
120
152
  build: artifactNextBuildConfigSchema,
121
153
  server: artifactNextServerSchema,
122
154
  targets: z.record(z.string().min(1), z.strictObject({ url: z.string().url() })).default({}),
155
+ presentation: artifactPresentationSchema.optional(),
123
156
  sidebarIcon: z.string().max(64).optional(),
124
157
  sidebarBadge: sidebarBadgeSchema.strict().optional(),
125
158
  }).superRefine((manifest, ctx) => {
@@ -8,8 +8,30 @@ export declare const sidebarBadgeSchema: z.ZodObject<{
8
8
  }>>;
9
9
  }, z.core.$strip>;
10
10
  export type SidebarBadgeManifest = z.infer<typeof sidebarBadgeSchema>;
11
+ export declare const artifactPresentationSchema: z.ZodObject<{
12
+ mobile: z.ZodOptional<z.ZodEnum<{
13
+ responsive: "responsive";
14
+ }>>;
15
+ }, z.core.$strip>;
16
+ export type ArtifactPresentation = z.infer<typeof artifactPresentationSchema>;
17
+ export declare const artifactOfflineCapabilitySchema: z.ZodObject<{
18
+ mode: z.ZodEnum<{
19
+ read: "read";
20
+ "read-write": "read-write";
21
+ }>;
22
+ max_age_hours: z.ZodNumber;
23
+ policy_version: z.ZodNumber;
24
+ }, z.core.$strip>;
25
+ export type ArtifactOfflineCapability = z.infer<typeof artifactOfflineCapabilitySchema>;
11
26
  export declare function apiCapabilityPathAllowed(pathname: string, allowed: readonly string[]): boolean;
12
27
  export declare const artifactStudioStaticManifestSchema: z.ZodObject<{
28
+ ontology: z.ZodOptional<z.ZodObject<{
29
+ version: z.ZodLiteral<1>;
30
+ read: z.ZodDefault<z.ZodArray<z.ZodString>>;
31
+ write: z.ZodDefault<z.ZodArray<z.ZodString>>;
32
+ produce: z.ZodDefault<z.ZodArray<z.ZodString>>;
33
+ invoke: z.ZodDefault<z.ZodArray<z.ZodString>>;
34
+ }, z.core.$strict>>;
13
35
  bundle: z.ZodObject<{
14
36
  name: z.ZodString;
15
37
  schema_version: z.ZodDefault<z.ZodLiteral<1>>;
@@ -63,6 +85,19 @@ export declare const artifactStudioStaticManifestSchema: z.ZodObject<{
63
85
  targets: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
64
86
  url: z.ZodString;
65
87
  }, z.core.$strict>>>;
88
+ presentation: z.ZodOptional<z.ZodObject<{
89
+ mobile: z.ZodOptional<z.ZodEnum<{
90
+ responsive: "responsive";
91
+ }>>;
92
+ }, z.core.$strip>>;
93
+ offline: z.ZodOptional<z.ZodObject<{
94
+ mode: z.ZodEnum<{
95
+ read: "read";
96
+ "read-write": "read-write";
97
+ }>;
98
+ max_age_hours: z.ZodNumber;
99
+ policy_version: z.ZodNumber;
100
+ }, z.core.$strip>>;
66
101
  sidebarIcon: z.ZodOptional<z.ZodString>;
67
102
  sidebarBadge: z.ZodOptional<z.ZodObject<{
68
103
  endpoint: z.ZodString;
@@ -1,4 +1,5 @@
1
1
  import { storageScopesSchema } from '@sequenceholdings/storage';
2
+ import { ontologyContractSchema } from '@sequenceholdings/orm/canonical';
2
3
  import { z } from 'zod';
3
4
  import { capabilityPinsSchema, customRolesBlockSchema, validateCapabilityPins, } from './manifest-custom-roles.js';
4
5
  import { normalizeArtifactPath } from './paths.js';
@@ -13,6 +14,14 @@ export const sidebarBadgeSchema = z.object({
13
14
  endpoint: apiCapabilityPathSchema,
14
15
  tone: sidebarBadgeToneSchema.optional(),
15
16
  });
17
+ export const artifactPresentationSchema = z.object({
18
+ mobile: z.enum(['responsive']).optional(),
19
+ });
20
+ export const artifactOfflineCapabilitySchema = z.object({
21
+ mode: z.enum(['read', 'read-write']),
22
+ max_age_hours: z.number().int().min(1),
23
+ policy_version: z.number().int().min(1),
24
+ });
16
25
  function matchesApiCapabilityEntry(pathname, entry) {
17
26
  if (!entry.startsWith('/api/'))
18
27
  return false;
@@ -41,6 +50,7 @@ export function apiCapabilityPathAllowed(pathname, allowed) {
41
50
  return allowed.some((entry) => matchesApiCapabilityEntry(pathname, entry));
42
51
  }
43
52
  export const artifactStudioStaticManifestSchema = z.object({
53
+ ontology: ontologyContractSchema.optional(),
44
54
  bundle: z.object({
45
55
  name: z.string().min(1).max(255),
46
56
  schema_version: z.literal(1).default(1),
@@ -99,6 +109,8 @@ export const artifactStudioStaticManifestSchema = z.object({
99
109
  targets: z.record(z.string().min(1), z.object({
100
110
  url: z.string().url(),
101
111
  }).strict()).default({}),
112
+ presentation: artifactPresentationSchema.optional(),
113
+ offline: artifactOfflineCapabilitySchema.optional(),
102
114
  sidebarIcon: z.string().max(64).optional(),
103
115
  sidebarBadge: sidebarBadgeSchema.optional(),
104
116
  }).superRefine((manifest, ctx) => {
@@ -5,6 +5,13 @@ export * from './manifest-static.js';
5
5
  export * from './manifest-next.js';
6
6
  /** Versioned parsing keeps schema-v1 stripping/default behavior unchanged. */
7
7
  export declare const artifactStudioManifestSchema: z.ZodUnion<readonly [z.ZodObject<{
8
+ ontology: z.ZodOptional<z.ZodObject<{
9
+ version: z.ZodLiteral<1>;
10
+ read: z.ZodDefault<z.ZodArray<z.ZodString>>;
11
+ write: z.ZodDefault<z.ZodArray<z.ZodString>>;
12
+ produce: z.ZodDefault<z.ZodArray<z.ZodString>>;
13
+ invoke: z.ZodDefault<z.ZodArray<z.ZodString>>;
14
+ }, z.core.$strict>>;
8
15
  bundle: z.ZodObject<{
9
16
  name: z.ZodString;
10
17
  schema_version: z.ZodDefault<z.ZodLiteral<1>>;
@@ -58,6 +65,19 @@ export declare const artifactStudioManifestSchema: z.ZodUnion<readonly [z.ZodObj
58
65
  targets: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
59
66
  url: z.ZodString;
60
67
  }, z.core.$strict>>>;
68
+ presentation: z.ZodOptional<z.ZodObject<{
69
+ mobile: z.ZodOptional<z.ZodEnum<{
70
+ responsive: "responsive";
71
+ }>>;
72
+ }, z.core.$strip>>;
73
+ offline: z.ZodOptional<z.ZodObject<{
74
+ mode: z.ZodEnum<{
75
+ read: "read";
76
+ "read-write": "read-write";
77
+ }>;
78
+ max_age_hours: z.ZodNumber;
79
+ policy_version: z.ZodNumber;
80
+ }, z.core.$strip>>;
61
81
  sidebarIcon: z.ZodOptional<z.ZodString>;
62
82
  sidebarBadge: z.ZodOptional<z.ZodObject<{
63
83
  endpoint: z.ZodString;
@@ -67,6 +87,13 @@ export declare const artifactStudioManifestSchema: z.ZodUnion<readonly [z.ZodObj
67
87
  }>>;
68
88
  }, z.core.$strip>>;
69
89
  }, z.core.$strip>, z.ZodObject<{
90
+ ontology: z.ZodOptional<z.ZodObject<{
91
+ version: z.ZodLiteral<1>;
92
+ read: z.ZodDefault<z.ZodArray<z.ZodString>>;
93
+ write: z.ZodDefault<z.ZodArray<z.ZodString>>;
94
+ produce: z.ZodDefault<z.ZodArray<z.ZodString>>;
95
+ invoke: z.ZodDefault<z.ZodArray<z.ZodString>>;
96
+ }, z.core.$strict>>;
70
97
  bundle: z.ZodObject<{
71
98
  name: z.ZodString;
72
99
  schema_version: z.ZodLiteral<2>;
@@ -115,6 +142,11 @@ export declare const artifactStudioManifestSchema: z.ZodUnion<readonly [z.ZodObj
115
142
  functions: z.ZodPrefault<z.ZodObject<{
116
143
  invoke: z.ZodDefault<z.ZodArray<z.ZodString>>;
117
144
  }, z.core.$strict>>;
145
+ processes: z.ZodPrefault<z.ZodObject<{
146
+ start: z.ZodDefault<z.ZodArray<z.ZodString>>;
147
+ read: z.ZodDefault<z.ZodArray<z.ZodString>>;
148
+ act: z.ZodDefault<z.ZodArray<z.ZodString>>;
149
+ }, z.core.$strict>>;
118
150
  }, z.core.$strict>>;
119
151
  build: z.ZodPrefault<z.ZodObject<{
120
152
  public_env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
@@ -126,6 +158,9 @@ export declare const artifactStudioManifestSchema: z.ZodUnion<readonly [z.ZodObj
126
158
  }, z.core.$strict>>;
127
159
  server: z.ZodPrefault<z.ZodObject<{
128
160
  capabilities: z.ZodPrefault<z.ZodObject<{
161
+ audit: z.ZodOptional<z.ZodObject<{
162
+ service: z.ZodString;
163
+ }, z.core.$strict>>;
129
164
  storage: z.ZodOptional<z.ZodRecord<z.ZodUUID, z.ZodEnum<{
130
165
  viewer: "viewer";
131
166
  editor: "editor";
@@ -142,6 +177,11 @@ export declare const artifactStudioManifestSchema: z.ZodUnion<readonly [z.ZodObj
142
177
  functions: z.ZodPrefault<z.ZodObject<{
143
178
  invoke: z.ZodDefault<z.ZodArray<z.ZodString>>;
144
179
  }, z.core.$strict>>;
180
+ processes: z.ZodPrefault<z.ZodObject<{
181
+ start: z.ZodDefault<z.ZodArray<z.ZodString>>;
182
+ read: z.ZodDefault<z.ZodArray<z.ZodString>>;
183
+ act: z.ZodDefault<z.ZodArray<z.ZodString>>;
184
+ }, z.core.$strict>>;
145
185
  }, z.core.$strict>>;
146
186
  service_account: z.ZodOptional<z.ZodString>;
147
187
  secrets: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -161,10 +201,18 @@ export declare const artifactStudioManifestSchema: z.ZodUnion<readonly [z.ZodObj
161
201
  cache: z.ZodOptional<z.ZodObject<{
162
202
  capacity_gb: z.ZodNumber;
163
203
  }, z.core.$strict>>;
204
+ lattice: z.ZodOptional<z.ZodObject<{
205
+ accept: z.ZodDefault<z.ZodArray<z.ZodString>>;
206
+ }, z.core.$strict>>;
164
207
  }, z.core.$strict>>;
165
208
  targets: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
166
209
  url: z.ZodString;
167
210
  }, z.core.$strict>>>;
211
+ presentation: z.ZodOptional<z.ZodObject<{
212
+ mobile: z.ZodOptional<z.ZodEnum<{
213
+ responsive: "responsive";
214
+ }>>;
215
+ }, z.core.$strip>>;
168
216
  sidebarIcon: z.ZodOptional<z.ZodString>;
169
217
  sidebarBadge: z.ZodOptional<z.ZodObject<{
170
218
  endpoint: z.ZodString;
@@ -15,8 +15,9 @@ export declare function resolveNextRepositoryId({ spec, repository, baseUrl, tok
15
15
  baseUrl: string;
16
16
  token: string;
17
17
  }): Promise<string>;
18
- export declare function submitNextBuild({ root, manifest, projectId, baseUrl, getToken, provenance, repository, repositoryId, channel, out }: {
18
+ export declare function submitNextBuild({ root, sourceRoot, manifest, projectId, baseUrl, getToken, provenance, repository, repositoryId, channel, out }: {
19
19
  root: string;
20
+ sourceRoot: string;
20
21
  manifest: ArtifactStudioNextManifest;
21
22
  projectId: string;
22
23
  baseUrl: string;