@superblocksteam/workspace-sync 2.0.178-next.3 → 2.0.179-next.1

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 (51) hide show
  1. package/README.md +21 -6
  2. package/dist/atomic-write.d.ts +4 -1
  3. package/dist/atomic-write.d.ts.map +1 -1
  4. package/dist/atomic-write.js +12 -10
  5. package/dist/atomic-write.js.map +1 -1
  6. package/dist/control.d.ts +150 -4
  7. package/dist/control.d.ts.map +1 -1
  8. package/dist/control.js +120 -8
  9. package/dist/control.js.map +1 -1
  10. package/dist/dbfs-transport.d.ts +8 -9
  11. package/dist/dbfs-transport.d.ts.map +1 -1
  12. package/dist/dbfs-transport.js +1 -20
  13. package/dist/dbfs-transport.js.map +1 -1
  14. package/dist/draft-helpers.d.ts +13 -0
  15. package/dist/draft-helpers.d.ts.map +1 -1
  16. package/dist/draft-helpers.js +86 -6
  17. package/dist/draft-helpers.js.map +1 -1
  18. package/dist/file-draft-journal-blob-store.d.ts +14 -0
  19. package/dist/file-draft-journal-blob-store.d.ts.map +1 -0
  20. package/dist/file-draft-journal-blob-store.js +74 -0
  21. package/dist/file-draft-journal-blob-store.js.map +1 -0
  22. package/dist/index.d.ts +1 -0
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +1 -0
  25. package/dist/index.js.map +1 -1
  26. package/dist/session-draft-journal-store.d.ts +12 -10
  27. package/dist/session-draft-journal-store.d.ts.map +1 -1
  28. package/dist/session-draft-journal-store.js +22 -49
  29. package/dist/session-draft-journal-store.js.map +1 -1
  30. package/dist/sigv4.d.ts +36 -0
  31. package/dist/sigv4.d.ts.map +1 -0
  32. package/dist/sigv4.js +97 -0
  33. package/dist/sigv4.js.map +1 -0
  34. package/dist/snapshot/upload-snapshot.d.ts +6 -0
  35. package/dist/snapshot/upload-snapshot.d.ts.map +1 -1
  36. package/dist/snapshot/upload-snapshot.js +12 -1
  37. package/dist/snapshot/upload-snapshot.js.map +1 -1
  38. package/dist/socket-dbfs-transport.d.ts +1 -1
  39. package/dist/socket-dbfs-transport.d.ts.map +1 -1
  40. package/dist/socket-dbfs-transport.js +4 -0
  41. package/dist/socket-dbfs-transport.js.map +1 -1
  42. package/dist/sync-credential-provider.d.ts +2 -2
  43. package/dist/sync-engine.d.ts +34 -1
  44. package/dist/sync-engine.d.ts.map +1 -1
  45. package/dist/sync-engine.js +189 -30
  46. package/dist/sync-engine.js.map +1 -1
  47. package/dist/testing.d.ts +26 -4
  48. package/dist/testing.d.ts.map +1 -1
  49. package/dist/testing.js +23 -8
  50. package/dist/testing.js.map +1 -1
  51. package/package.json +11 -7
package/README.md CHANGED
@@ -19,9 +19,16 @@ host binds one, messages go to the console.
19
19
  `<root>/../.superblocks-native-drafts/<sha256(root)>.json`. This is the
20
20
  live-edit layout.
21
21
  - `SessionDraftJournalStore` writes a small pointer record to a session state
22
- directory and keeps file contents as DBFS blobs referenced by content hash.
23
- A fresh process over the same directory can still reconcile, accept or
24
- discard a killed session's drafts.
22
+ directory and keeps file contents in a `DraftJournalBlobStore` referenced by
23
+ content hash. A fresh process over the same directory can still reconcile,
24
+ accept or discard a killed session's drafts.
25
+ - `createFileDraftJournalBlobStore` is the blob store the AgentCore microVM
26
+ uses: one file per `hashFileContents` hash in
27
+ `<stateDir>/journal-blobs/`. Blobs stay on local disk, not in DBFS,
28
+ because they hold pre-turn originals that are not in the branch's tree, and
29
+ the server refuses `applications:sync` token reads of hashes outside that
30
+ tree. Reads verify each blob against its hash. When the pointer is replaced
31
+ or cleared, blobs it no longer references are deleted.
25
32
 
26
33
  ## Sync engine
27
34
 
@@ -32,9 +39,17 @@ session state directory is a cache, so the engine survives a kill at any step.
32
39
  - `interimFlush()` uploads blobs only and never moves the branch hash.
33
40
  `createFlushScheduler` runs it on the live-edit cadence (10s trailing, 30s
34
41
  cap).
35
- - `commit(source)` reconciles the draft journal, snapshots the tree, uploads
36
- what DBFS lacks, asks the `BranchWriteGuard`, moves the branch hash, then
37
- writes the state store, retires the journal and reports draft state.
42
+ - `commit(source)` reconciles the draft journal, reports a drafted tree
43
+ (after asking the `BranchWriteGuard` and before the hash, so the server
44
+ files the turn as a draft), snapshots the tree, uploads what DBFS lacks,
45
+ asks the guard again, moves the branch hash, then writes the state store and
46
+ retires the journal. Only a `checkpoint` commit (accept or reject) clears
47
+ the server's draft flag, and only after its hash moves, so a failed accept
48
+ or reject leaves the server in draft. Every draft-state report asks the
49
+ guard first. An accept, reject or clear passes its marker step as
50
+ `settle`, which runs inside the commit queue after the draft journal is
51
+ dropped, so no other commit interleaves. Draft checks fail closed: only a
52
+ missing `.superblocks/drafts` directory counts as no drafts.
38
53
  - `rehydrate()` compares the server hash, the stored hash and the local tree
39
54
  on boot and returns `fresh`, `resumed`, `replayed` or `reloaded`. A
40
55
  `reloaded` tree keeps the local diff under `<stateDir>/orphaned/`.
@@ -3,5 +3,8 @@
3
3
  * never a torn write: write a temporary sibling, fsync it, rename it over the
4
4
  * target, then fsync the directory so the rename survives a crash.
5
5
  */
6
- export declare function writeFileAtomic(file: string, contents: string | Buffer, mode?: number): Promise<void>;
6
+ export declare function writeFileAtomic(file: string, contents: string | Buffer, options?: {
7
+ mode?: number;
8
+ preserveMode?: number;
9
+ }): Promise<void>;
7
10
  //# sourceMappingURL=atomic-write.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"atomic-write.d.ts","sourceRoot":"","sources":["../src/atomic-write.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,MAAM,EACzB,IAAI,SAAQ,GACX,OAAO,CAAC,IAAI,CAAC,CAoBf"}
1
+ {"version":3,"file":"atomic-write.d.ts","sourceRoot":"","sources":["../src/atomic-write.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,MAAM,EACzB,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAO,GACrD,OAAO,CAAC,IAAI,CAAC,CA0Bf"}
@@ -6,17 +6,19 @@ import path from "node:path";
6
6
  * never a torn write: write a temporary sibling, fsync it, rename it over the
7
7
  * target, then fsync the directory so the rename survives a crash.
8
8
  */
9
- export async function writeFileAtomic(file, contents, mode = 0o600) {
10
- const temporary = `${file}.${randomUUID()}.tmp`;
11
- const handle = await fs.open(temporary, "wx", mode);
12
- try {
13
- await handle.writeFile(contents);
14
- await handle.sync();
15
- }
16
- finally {
17
- await handle.close();
18
- }
9
+ export async function writeFileAtomic(file, contents, options = {}) {
10
+ const temporary = path.join(path.dirname(file), `.${randomUUID()}.tmp`);
11
+ const handle = await fs.open(temporary, "wx", options.preserveMode ?? options.mode ?? 0o600);
19
12
  try {
13
+ try {
14
+ await handle.writeFile(contents);
15
+ if (options.preserveMode !== undefined)
16
+ await handle.chmod(options.preserveMode);
17
+ await handle.sync();
18
+ }
19
+ finally {
20
+ await handle.close();
21
+ }
20
22
  await fs.rename(temporary, file);
21
23
  const directory = await fs.open(path.dirname(file), "r");
22
24
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"atomic-write.js","sourceRoot":"","sources":["../src/atomic-write.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,IAAY,EACZ,QAAyB,EACzB,IAAI,GAAG,KAAK;IAEZ,MAAM,SAAS,GAAG,GAAG,IAAI,IAAI,UAAU,EAAE,MAAM,CAAC;IAChD,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACpD,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;IACF,IAAI,CAAC;QACH,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YACjC,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS;gBACpC,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;YAC3C,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QACtB,CAAC;gBAAS,CAAC;YACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;QACD,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QACjC,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;QACzD,IAAI,CAAC;YACH,MAAM,SAAS,CAAC,IAAI,EAAE,CAAC;QACzB,CAAC;gBAAS,CAAC;YACT,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC;QAC1B,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,EAAE,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC"}
package/dist/control.d.ts CHANGED
@@ -16,8 +16,6 @@ export declare const WORKSPACE_STATE_PATH = "/_sb_workspace/state";
16
16
  export declare const WORKSPACE_COMMIT_PATH = "/_sb_workspace/commit";
17
17
  /** Edge, AI service → edge: the VM's current session endpoint. */
18
18
  export declare const WORKSPACE_ENDPOINT_PATH = "/_sb_workspace/endpoint";
19
- /** Edge, VM → edge: read-only package registry proxy (prefix). */
20
- export declare const WORKSPACE_REGISTRY_PATH = "/_sb_workspace/registry/";
21
19
  /**
22
20
  * Carries the workspace token on every request between the parties. Not
23
21
  * `Authorization`: SigV4 owns that header on the edge → VM hop.
@@ -56,6 +54,13 @@ export declare function deriveWorkspaceEndpointToken(secret: string, sessionKey:
56
54
  * `runtime.bedrock-agentcore.<region>.on.aws`.
57
55
  */
58
56
  export declare function isAgentCoreSessionEndpoint(url: string, region: string): boolean;
57
+ /**
58
+ * The URL that reaches `port` in the VM. AgentCore returns the session
59
+ * endpoint without a port, and that bare host answers AccessDenied; each
60
+ * allowed port is addressed as `<port>--<host>`. A URL that already names a
61
+ * port is kept as it is.
62
+ */
63
+ export declare function sessionEndpointForPort(sessionEndpointUrl: string, port: number): string;
59
64
  /**
60
65
  * Constant-time string comparison. Both sides are hashed first so inputs of
61
66
  * different lengths compare in constant time too.
@@ -186,8 +191,12 @@ export type WorkspaceCommitResult = z.infer<typeof workspaceCommitResultSchema>;
186
191
  * (`PUT` {@link WORKSPACE_ENDPOINT_PATH}). Each `workspace.open` that returns
187
192
  * a new URL sends a new one; the edge then pushes its state there.
188
193
  *
189
- * - `sigv4`: an AgentCore session endpoint. The edge signs each request and
190
- * WebSocket handshake for `bedrock-agentcore` in `region`.
194
+ * - `sigv4`: an AgentCore session endpoint. Each request and WebSocket
195
+ * handshake needs a SigV4 signature for `bedrock-agentcore` in `region`,
196
+ * which only the Superblocks server can make: the edge asks `signer.url`
197
+ * ({@link BUILDER_RUNTIME_SIGN_PATH}) for each one, presenting
198
+ * `signer.grant`. The AI service sends the endpoint again with a fresh
199
+ * grant before the old one expires.
191
200
  * - `none`: a local builder runtime reached directly, for development.
192
201
  */
193
202
  export declare const workspaceEndpointSchema: z.ZodDiscriminatedUnion<"auth", [z.ZodObject<{
@@ -195,16 +204,34 @@ export declare const workspaceEndpointSchema: z.ZodDiscriminatedUnion<"auth", [z
195
204
  url: z.ZodEffects<z.ZodString, string, string>;
196
205
  region: z.ZodString;
197
206
  sessionKey: z.ZodString;
207
+ signer: z.ZodObject<{
208
+ url: z.ZodString;
209
+ grant: z.ZodString;
210
+ }, "strip", z.ZodTypeAny, {
211
+ url: string;
212
+ grant: string;
213
+ }, {
214
+ url: string;
215
+ grant: string;
216
+ }>;
198
217
  }, "strip", z.ZodTypeAny, {
199
218
  auth: "sigv4";
200
219
  url: string;
201
220
  region: string;
202
221
  sessionKey: string;
222
+ signer: {
223
+ url: string;
224
+ grant: string;
225
+ };
203
226
  }, {
204
227
  auth: "sigv4";
205
228
  url: string;
206
229
  region: string;
207
230
  sessionKey: string;
231
+ signer: {
232
+ url: string;
233
+ grant: string;
234
+ };
208
235
  }>, z.ZodObject<{
209
236
  auth: z.ZodLiteral<"none">;
210
237
  url: z.ZodEffects<z.ZodString, string, string>;
@@ -219,6 +246,125 @@ export declare const workspaceEndpointSchema: z.ZodDiscriminatedUnion<"auth", [z
219
246
  sessionKey: string;
220
247
  }>]>;
221
248
  export type WorkspaceEndpoint = z.infer<typeof workspaceEndpointSchema>;
249
+ /**
250
+ * The server is the only caller of the AgentCore builder runtime. The AI
251
+ * service trades the user's token for a builder-runtime token
252
+ * ({@link BUILDER_RUNTIME_TOKEN_PATH}), which names the app, branch and chat
253
+ * the server checked, and sends invocation payloads to
254
+ * {@link BUILDER_RUNTIME_INVOCATIONS_PATH}. The server picks the runtime and
255
+ * the runtime session itself; the response is the runtime's event stream.
256
+ */
257
+ export declare const BUILDER_RUNTIME_TOKEN_PATH = "/api/v1/token/builder-runtime";
258
+ export declare const BUILDER_RUNTIME_INVOCATIONS_PATH = "/api/v1/ai/builder-runtime/invocations";
259
+ /**
260
+ * On an invocation request: which of the token's runtime sessions it runs in.
261
+ * `workspace` is the branch's workspace session (opens, and turns whose tools
262
+ * run in the VM); `chat` is the chat's own session. The server maps either to
263
+ * a session it derived, so the pod cannot name any other.
264
+ */
265
+ export declare const BUILDER_RUNTIME_SESSION_HEADER = "x-sb-builder-runtime-session";
266
+ export declare const builderRuntimeSessionSchema: z.ZodEnum<["workspace", "chat"]>;
267
+ export type BuilderRuntimeSession = z.infer<typeof builderRuntimeSessionSchema>;
268
+ /**
269
+ * Signs one request to a session endpoint (`POST`, body
270
+ * {@link workspaceSignRequestSchema}, `Authorization: Bearer <grant>`). The
271
+ * grant names the one session endpoint origin it may sign for.
272
+ */
273
+ export declare const BUILDER_RUNTIME_SIGN_PATH = "/api/v1/ai/builder-runtime/sign";
274
+ /**
275
+ * Renews a sign grant (`POST`, body {@link builderRuntimeSignGrantSchema},
276
+ * builder-runtime token as bearer) for the same session endpoint.
277
+ */
278
+ export declare const BUILDER_RUNTIME_SIGN_GRANT_PATH = "/api/v1/ai/builder-runtime/sign-grant";
279
+ /**
280
+ * On a `workspace.open` response: where the VM ingress is reachable, as JSON
281
+ * {@link builderRuntimeEndpointHeaderSchema}. Absent when AgentCore returned no
282
+ * session endpoint.
283
+ */
284
+ export declare const BUILDER_RUNTIME_ENDPOINT_HEADER = "x-sb-workspace-endpoint";
285
+ /** On a `workspace.open` response: the sign grant for that endpoint. */
286
+ export declare const BUILDER_RUNTIME_SIGN_GRANT_HEADER = "x-sb-workspace-sign-grant";
287
+ export declare const builderRuntimeEndpointHeaderSchema: z.ZodObject<{
288
+ url: z.ZodEffects<z.ZodString, string, string>;
289
+ region: z.ZodString;
290
+ }, "strip", z.ZodTypeAny, {
291
+ url: string;
292
+ region: string;
293
+ }, {
294
+ url: string;
295
+ region: string;
296
+ }>;
297
+ export type BuilderRuntimeEndpointHeader = z.infer<typeof builderRuntimeEndpointHeaderSchema>;
298
+ /** A sign grant, as sent to and returned by the renew route. */
299
+ export declare const builderRuntimeSignGrantSchema: z.ZodObject<{
300
+ grant: z.ZodString;
301
+ }, "strip", z.ZodTypeAny, {
302
+ grant: string;
303
+ }, {
304
+ grant: string;
305
+ }>;
306
+ /**
307
+ * One request the edge wants signed. `headers` are the lowercased headers the
308
+ * signer covers (`host` and `x-amz-*`); the body is never sent because the
309
+ * signature uses an unsigned payload. The server signs only a URL on the
310
+ * grant's session endpoint, so the schema bounds sizes and leaves the rest to
311
+ * that check.
312
+ */
313
+ export declare const workspaceSignRequestSchema: z.ZodObject<{
314
+ method: z.ZodEnum<["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]>;
315
+ url: z.ZodString;
316
+ headers: z.ZodRecord<z.ZodString, z.ZodString>;
317
+ }, "strip", z.ZodTypeAny, {
318
+ method: "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT";
319
+ url: string;
320
+ headers: Record<string, string>;
321
+ }, {
322
+ method: "DELETE" | "GET" | "HEAD" | "OPTIONS" | "PATCH" | "POST" | "PUT";
323
+ url: string;
324
+ headers: Record<string, string>;
325
+ }>;
326
+ export type WorkspaceSignRequest = z.infer<typeof workspaceSignRequestSchema>;
327
+ /** The signed header set: the request's headers plus the SigV4 headers. */
328
+ export declare const workspaceSignResponseSchema: z.ZodObject<{
329
+ headers: z.ZodRecord<z.ZodString, z.ZodString>;
330
+ }, "strip", z.ZodTypeAny, {
331
+ headers: Record<string, string>;
332
+ }, {
333
+ headers: Record<string, string>;
334
+ }>;
335
+ export type WorkspaceSignResponse = z.infer<typeof workspaceSignResponseSchema>;
336
+ /**
337
+ * The audience of the statement the server signs for each invocation. The VM
338
+ * runs an invocation only when the statement verifies against the server's
339
+ * keys, names the runtime session AgentCore delivered it on, and hashes to
340
+ * the payload it carries.
341
+ */
342
+ export declare const BUILDER_RUNTIME_INVOCATION_AUDIENCE = "https://superblocks-builder-runtime-invocation";
343
+ /** The body the server sends to AgentCore: the statement and the payload. */
344
+ export declare const builderRuntimeInvocationEnvelopeSchema: z.ZodObject<{
345
+ authorization: z.ZodString;
346
+ payload: z.ZodString;
347
+ }, "strict", z.ZodTypeAny, {
348
+ authorization: string;
349
+ payload: string;
350
+ }, {
351
+ authorization: string;
352
+ payload: string;
353
+ }>;
354
+ export type BuilderRuntimeInvocationEnvelope = z.infer<typeof builderRuntimeInvocationEnvelopeSchema>;
355
+ /** The statement's own claims, beside the standard `iss`, `aud` and `exp`. */
356
+ export declare const builderRuntimeInvocationClaimsSchema: z.ZodObject<{
357
+ rsid: z.ZodString;
358
+ payload_sha256: z.ZodString;
359
+ }, "strip", z.ZodTypeAny, {
360
+ rsid: string;
361
+ payload_sha256: string;
362
+ }, {
363
+ rsid: string;
364
+ payload_sha256: string;
365
+ }>;
366
+ /** The hex SHA-256 of an invocation payload, as the statement names it. */
367
+ export declare function invocationPayloadDigest(payload: string): string;
222
368
  /**
223
369
  * The edge's view of the VM, reported in its health response as
224
370
  * `workspace.ingress`. The AI service reopens the workspace when it stays
@@ -1 +1 @@
1
- {"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../src/control.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;;GAGG;AACH,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,oBAAoB,CAAC;AAE1D,wEAAwE;AACxE,eAAO,MAAM,oBAAoB,yBAAyB,CAAC;AAC3D,gFAAgF;AAChF,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAC7D,kEAAkE;AAClE,eAAO,MAAM,uBAAuB,4BAA4B,CAAC;AACjE,kEAAkE;AAClE,eAAO,MAAM,uBAAuB,6BAA6B,CAAC;AAElE;;;GAGG;AACH,eAAO,MAAM,sBAAsB,yBAAyB,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,uBAAuB,CAAC;AAEnE;;;;GAIG;AACH,eAAO,MAAM,uCAAuC,gCACrB,CAAC;AAEhC,yEAAyE;AACzE,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEhE;AAMD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,GACjB,MAAM,CAKR;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,GACjB,MAAM,CAQR;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,GACb,OAAO,CAeT;AAED;;;GAGG;AACH,wBAAgB,WA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B,8DAKtC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
package/dist/control.js CHANGED
@@ -1,10 +1,13 @@
1
1
  /**
2
- * The contract between the three parties of an AgentCore workspace:
2
+ * The contract between the parties of an AgentCore workspace:
3
3
  *
4
- * - the AI service, which opens the VM and learns its session endpoint URL;
4
+ * - the Superblocks server, the only holder of AWS credentials, which calls
5
+ * the builder runtime and signs requests to session endpoints;
6
+ * - the AI service, which opens the VM through the server and learns its
7
+ * session endpoint URL;
5
8
  * - the workspace edge in the live-edit pod, the browser's front door, which
6
- * signs and forwards traffic to that URL and owns lock, activity and the
7
- * sync credential;
9
+ * forwards traffic to that URL with the server's signatures and owns lock,
10
+ * activity and the sync credential;
8
11
  * - the workspace ingress in the VM, the one listener the session endpoint
9
12
  * reaches.
10
13
  *
@@ -37,8 +40,6 @@ export const WORKSPACE_STATE_PATH = "/_sb_workspace/state";
37
40
  export const WORKSPACE_COMMIT_PATH = "/_sb_workspace/commit";
38
41
  /** Edge, AI service → edge: the VM's current session endpoint. */
39
42
  export const WORKSPACE_ENDPOINT_PATH = "/_sb_workspace/endpoint";
40
- /** Edge, VM → edge: read-only package registry proxy (prefix). */
41
- export const WORKSPACE_REGISTRY_PATH = "/_sb_workspace/registry/";
42
43
  /**
43
44
  * Carries the workspace token on every request between the parties. Not
44
45
  * `Authorization`: SigV4 owns that header on the edge → VM hop.
@@ -110,6 +111,18 @@ export function isAgentCoreSessionEndpoint(url, region) {
110
111
  parsed.password === "" &&
111
112
  parsed.hostname.endsWith(`.runtime.bedrock-agentcore.${region}.on.aws`));
112
113
  }
114
+ /**
115
+ * The URL that reaches `port` in the VM. AgentCore returns the session
116
+ * endpoint without a port, and that bare host answers AccessDenied; each
117
+ * allowed port is addressed as `<port>--<host>`. A URL that already names a
118
+ * port is kept as it is.
119
+ */
120
+ export function sessionEndpointForPort(sessionEndpointUrl, port) {
121
+ const url = new URL(sessionEndpointUrl);
122
+ if (!/^\d+--/.test(url.hostname))
123
+ url.hostname = `${port}--${url.hostname}`;
124
+ return url.origin;
125
+ }
113
126
  /**
114
127
  * Constant-time string comparison. Both sides are hashed first so inputs of
115
128
  * different lengths compare in constant time too.
@@ -200,8 +213,12 @@ const endpointUrl = z
200
213
  * (`PUT` {@link WORKSPACE_ENDPOINT_PATH}). Each `workspace.open` that returns
201
214
  * a new URL sends a new one; the edge then pushes its state there.
202
215
  *
203
- * - `sigv4`: an AgentCore session endpoint. The edge signs each request and
204
- * WebSocket handshake for `bedrock-agentcore` in `region`.
216
+ * - `sigv4`: an AgentCore session endpoint. Each request and WebSocket
217
+ * handshake needs a SigV4 signature for `bedrock-agentcore` in `region`,
218
+ * which only the Superblocks server can make: the edge asks `signer.url`
219
+ * ({@link BUILDER_RUNTIME_SIGN_PATH}) for each one, presenting
220
+ * `signer.grant`. The AI service sends the endpoint again with a fresh
221
+ * grant before the old one expires.
205
222
  * - `none`: a local builder runtime reached directly, for development.
206
223
  */
207
224
  export const workspaceEndpointSchema = z.discriminatedUnion("auth", [
@@ -210,6 +227,10 @@ export const workspaceEndpointSchema = z.discriminatedUnion("auth", [
210
227
  url: endpointUrl,
211
228
  region: z.string().min(1).max(64),
212
229
  sessionKey: z.string().min(1).max(1024),
230
+ signer: z.object({
231
+ url: z.string().url().max(2048),
232
+ grant: z.string().min(1).max(8192),
233
+ }),
213
234
  }),
214
235
  z.object({
215
236
  auth: z.literal("none"),
@@ -218,6 +239,97 @@ export const workspaceEndpointSchema = z.discriminatedUnion("auth", [
218
239
  }),
219
240
  ]);
220
241
  // ---------------------------------------------------------------------------
242
+ // Live-edit pod → Superblocks server: the builder runtime gateway
243
+ // ---------------------------------------------------------------------------
244
+ /**
245
+ * The server is the only caller of the AgentCore builder runtime. The AI
246
+ * service trades the user's token for a builder-runtime token
247
+ * ({@link BUILDER_RUNTIME_TOKEN_PATH}), which names the app, branch and chat
248
+ * the server checked, and sends invocation payloads to
249
+ * {@link BUILDER_RUNTIME_INVOCATIONS_PATH}. The server picks the runtime and
250
+ * the runtime session itself; the response is the runtime's event stream.
251
+ */
252
+ export const BUILDER_RUNTIME_TOKEN_PATH = "/api/v1/token/builder-runtime";
253
+ export const BUILDER_RUNTIME_INVOCATIONS_PATH = "/api/v1/ai/builder-runtime/invocations";
254
+ /**
255
+ * On an invocation request: which of the token's runtime sessions it runs in.
256
+ * `workspace` is the branch's workspace session (opens, and turns whose tools
257
+ * run in the VM); `chat` is the chat's own session. The server maps either to
258
+ * a session it derived, so the pod cannot name any other.
259
+ */
260
+ export const BUILDER_RUNTIME_SESSION_HEADER = "x-sb-builder-runtime-session";
261
+ export const builderRuntimeSessionSchema = z.enum(["workspace", "chat"]);
262
+ /**
263
+ * Signs one request to a session endpoint (`POST`, body
264
+ * {@link workspaceSignRequestSchema}, `Authorization: Bearer <grant>`). The
265
+ * grant names the one session endpoint origin it may sign for.
266
+ */
267
+ export const BUILDER_RUNTIME_SIGN_PATH = "/api/v1/ai/builder-runtime/sign";
268
+ /**
269
+ * Renews a sign grant (`POST`, body {@link builderRuntimeSignGrantSchema},
270
+ * builder-runtime token as bearer) for the same session endpoint.
271
+ */
272
+ export const BUILDER_RUNTIME_SIGN_GRANT_PATH = "/api/v1/ai/builder-runtime/sign-grant";
273
+ /**
274
+ * On a `workspace.open` response: where the VM ingress is reachable, as JSON
275
+ * {@link builderRuntimeEndpointHeaderSchema}. Absent when AgentCore returned no
276
+ * session endpoint.
277
+ */
278
+ export const BUILDER_RUNTIME_ENDPOINT_HEADER = "x-sb-workspace-endpoint";
279
+ /** On a `workspace.open` response: the sign grant for that endpoint. */
280
+ export const BUILDER_RUNTIME_SIGN_GRANT_HEADER = "x-sb-workspace-sign-grant";
281
+ export const builderRuntimeEndpointHeaderSchema = z.object({
282
+ url: endpointUrl,
283
+ region: z.string().min(1).max(64),
284
+ });
285
+ /** A sign grant, as sent to and returned by the renew route. */
286
+ export const builderRuntimeSignGrantSchema = z.object({
287
+ grant: z.string().min(1).max(8192),
288
+ });
289
+ /**
290
+ * One request the edge wants signed. `headers` are the lowercased headers the
291
+ * signer covers (`host` and `x-amz-*`); the body is never sent because the
292
+ * signature uses an unsigned payload. The server signs only a URL on the
293
+ * grant's session endpoint, so the schema bounds sizes and leaves the rest to
294
+ * that check.
295
+ */
296
+ export const workspaceSignRequestSchema = z.object({
297
+ method: z.enum(["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]),
298
+ // Node's default limit for a whole request head.
299
+ url: z.string().url().max(16_384),
300
+ headers: z.record(z.string().max(256), z.string().max(8192)),
301
+ });
302
+ /** The signed header set: the request's headers plus the SigV4 headers. */
303
+ export const workspaceSignResponseSchema = z.object({
304
+ headers: z.record(z.string(), z.string()),
305
+ });
306
+ // ---------------------------------------------------------------------------
307
+ // Superblocks server → VM: the signed invocation
308
+ // ---------------------------------------------------------------------------
309
+ /**
310
+ * The audience of the statement the server signs for each invocation. The VM
311
+ * runs an invocation only when the statement verifies against the server's
312
+ * keys, names the runtime session AgentCore delivered it on, and hashes to
313
+ * the payload it carries.
314
+ */
315
+ export const BUILDER_RUNTIME_INVOCATION_AUDIENCE = "https://superblocks-builder-runtime-invocation";
316
+ /** The body the server sends to AgentCore: the statement and the payload. */
317
+ export const builderRuntimeInvocationEnvelopeSchema = z
318
+ .object({
319
+ authorization: z.string().min(1).max(8192),
320
+ payload: z.string().min(2),
321
+ })
322
+ .strict();
323
+ /** The statement's own claims, beside the standard `iss`, `aud` and `exp`. */
324
+ export const builderRuntimeInvocationClaimsSchema = z.object({
325
+ rsid: z.string().min(1).max(256),
326
+ payload_sha256: z.string().regex(/^[a-f0-9]{64}$/),
327
+ });
328
+ /** The hex SHA-256 of an invocation payload, as the statement names it. */
329
+ export function invocationPayloadDigest(payload) {
330
+ return createHash("sha256").update(payload, "utf8").digest("hex");
331
+ }
332
+ // ---------------------------------------------------------------------------
221
333
  // Edge health, read by the AI service
222
334
  // ---------------------------------------------------------------------------
223
335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,GAAG,CAAC,CAAC,CAAC;CAC3B,CAAC;KACD,MAAM,EAAE,CAAC;AAKZ,8EAA8E;AAC9E,MAAM,CAAC,MAAM,oCAAoC,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3D,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAChC,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC;CACnD,CAAC,CAAC;AAEH,2EAA2E;AAC3E,MAAM,UAAU,uBAAuB,CAAC,OAAe;IACrD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACpE,CAAC;AAED,8EAA8E;AAC9E,sCAAsC;AACtC,8EAA8E;AAE9E;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,IAAI,CAAC;IAChD,SAAS;IACT,WAAW;IACX,aAAa;IACb,QAAQ;CACT,CAAC,CAAC"}
@@ -1,5 +1,4 @@
1
- import type { ApplicationHashChangeSource, DirectoryEntry } from "@superblocksteam/shared";
2
- import type { DraftJournalBlobStore } from "./session-draft-journal-store.js";
1
+ import type { ApplicationHashChangeSource, CheckpointSkipReason, DirectoryEntry } from "@superblocksteam/shared";
3
2
  import type { PutManyItems } from "./snapshot/upload-snapshot.js";
4
3
  export interface SetHashRequest {
5
4
  hash: string;
@@ -13,6 +12,13 @@ export interface SetHashRequest {
13
12
  export interface SetHashResult {
14
13
  hash: string;
15
14
  commitId?: string;
15
+ /** Why the server made no checkpoint, when it skipped one by design. */
16
+ checkpointSkipped?: CheckpointSkipReason;
17
+ /**
18
+ * Protected paths whose changes the server holds for a user's approval.
19
+ * `hash` is then the tree the server stored, without those changes.
20
+ */
21
+ heldPaths?: string[];
16
22
  }
17
23
  /** A file to read out of a stored tree. */
18
24
  export interface DbfsFileRef {
@@ -35,8 +41,6 @@ export interface DbfsTransport {
35
41
  getDirectory(hash: string): Promise<DirectoryEntry[]>;
36
42
  /** File contents by path inside the tree `rootHash`, in request order. */
37
43
  getContents(rootHash: string, files: DbfsFileRef[]): Promise<Buffer[]>;
38
- /** One blob by content hash. */
39
- getBlob(hash: string): Promise<Buffer>;
40
44
  /** The branch's current working-copy hash. */
41
45
  getServerHash(): Promise<string>;
42
46
  /** Moves the branch's working-copy hash. */
@@ -44,9 +48,4 @@ export interface DbfsTransport {
44
48
  /** Reports whether the workspace has unaccepted drafts. */
45
49
  setDraftState(hasDraft: boolean): Promise<void>;
46
50
  }
47
- /**
48
- * Stores native draft journal contents as DBFS blobs through a transport, for
49
- * `SessionDraftJournalStore`.
50
- */
51
- export declare function journalBlobStoreFromTransport(transport: Pick<DbfsTransport, "putMany" | "getBlob">): DraftJournalBlobStore;
52
51
  //# sourceMappingURL=dbfs-transport.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dbfs-transport.d.ts","sourceRoot":"","sources":["../src/dbfs-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,MAAM,EAAE,2BAA2B,CAAC;CACrC;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,2CAA2C;AAC3C,MAAM,WAAW,WAAW;IAC1B,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,qDAAq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AQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,MAAM,EAAE,2BAA2B,CAAC;CACrC;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,iBAAiB,CAAC,EAAE,oBAAoB,CAAC;IACzC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,2CAA2C;AAC3C,MAAM,WAAW,WAAW;IAC1B,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,4EAA4E;IAC5E,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,wEAAwE;IACxE,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAChD,qCAAqC;IACrC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IACtD,0EAA0E;IAC1E,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACvE,8CAA8C;IAC9C,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACjC,4CAA4C;IAC5C,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACzD,2DAA2D;IAC3D,aAAa,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjD"}
@@ -1,21 +1,2 @@
1
- const BLOB_BATCH = 64;
2
- /**
3
- * Stores native draft journal contents as DBFS blobs through a transport, for
4
- * `SessionDraftJournalStore`.
5
- */
6
- export function journalBlobStoreFromTransport(transport) {
7
- return {
8
- async put(contents) {
9
- const hashes = [];
10
- for (let idx = 0; idx < contents.length; idx += BLOB_BATCH) {
11
- hashes.push(...(await transport.putMany(contents.slice(idx, idx + BLOB_BATCH).map((bytes) => ({
12
- type: "fileContents",
13
- contents: bytes.toString("base64"),
14
- })))));
15
- }
16
- return hashes;
17
- },
18
- get: (hash) => transport.getBlob(hash),
19
- };
20
- }
1
+ export {};
21
2
  //# sourceMappingURL=dbfs-transport.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dbfs-transport.js","sourceRoot":"","sources":["../src/dbfs-transport.ts"],"names":[],"mappings":"AAuDA,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB;;;GAGG;AACH,MAAM,UAAU,6BAA6B,CAC3C,SAAqD;IAErD,OAAO;QACL,KAAK,CAAC,GAAG,CAAC,QAAQ;YAChB,MAAM,MAAM,GAAa,EAAE,CAAC;YAC5B,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,QAAQ,CAAC,MAAM,EAAE,GAAG,IAAI,UAAU,EAAE,CAAC;gBAC3D,MAAM,CAAC,IAAI,CACT,GAAG,CAAC,MAAM,SAAS,CAAC,OAAO,CACzB,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;oBACpD,IAAI,EAAE,cAAuB;oBAC7B,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC;iBACnC,CAAC,CAAC,CACJ,CAAC,CACH,CAAC;YACJ,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;KACvC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"dbfs-transport.js","sourceRoot":"","sources":["../src/dbfs-transport.ts"],"names":[],"mappings":""}
@@ -73,6 +73,19 @@ export declare function createDraftDelete(filePath: string, appRootDirPath: stri
73
73
  * @returns A promise that resolves to true if any draft files are found, false otherwise.
74
74
  */
75
75
  export declare function hasSwapFiles(appRootDirPath: string): Promise<boolean>;
76
+ /**
77
+ * {@link hasSwapFiles} for decisions that clear the server's draft flag: only
78
+ * a missing drafts directory means no drafts. A directory or entry that
79
+ * cannot be read counts as a draft, so an unreadable tree never reads as
80
+ * reviewed.
81
+ */
82
+ export declare function hasDraftsFailClosed(appRootDirPath: string): Promise<boolean>;
83
+ /**
84
+ * Throws unless the drafts directory is gone. Accept, reject and clear all
85
+ * end by removing it, and their helpers swallow removal and read errors, so
86
+ * this is the check that they finished.
87
+ */
88
+ export declare function assertDraftsSettled(appRootDirPath: string, action: string): Promise<void>;
76
89
  /**
77
90
  * Discards all draft changes by removing draft additions, then restoring the
78
91
  * originals of edits and deletions. Each marker is retired once its step
@@ -1 +1 @@
1
- {"version":3,"file":"draft-helpers.d.ts","sourceRoot":"","sources":["../src/draft-helpers.ts"],"names":[],"mappings":"AAUA,QAAA,MAAM,UAAU;aACd,GAAG;aACH,MAAM;aACN,IAAI;CACI,CAAC;AAoFX;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,iBAwCvB;AAED;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GAAG,MAAM,EAC7B,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC,CAyDzB;AAED;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,GAAG,MAAM,EAC7B,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC,CAKf;AAsFD;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAA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