@superblocksteam/workspace-sync 2.0.180-next.3 → 2.0.183-next.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.
- package/README.md +32 -7
- package/dist/control.d.ts +161 -88
- package/dist/control.d.ts.map +1 -1
- package/dist/control.js +7 -50
- package/dist/control.js.map +1 -1
- package/dist/dbfs-transport.d.ts +3 -4
- package/dist/dbfs-transport.d.ts.map +1 -1
- package/dist/draft-helpers.d.ts +23 -0
- package/dist/draft-helpers.d.ts.map +1 -1
- package/dist/draft-helpers.js +179 -5
- package/dist/draft-helpers.js.map +1 -1
- package/dist/draft-journal-store.d.ts +30 -0
- package/dist/draft-journal-store.d.ts.map +1 -0
- package/dist/draft-journal-store.js +7 -0
- package/dist/draft-journal-store.js.map +1 -0
- package/dist/file-draft-journal-blob-store.d.ts +14 -0
- package/dist/file-draft-journal-blob-store.d.ts.map +1 -0
- package/dist/file-draft-journal-blob-store.js +74 -0
- package/dist/file-draft-journal-blob-store.js.map +1 -0
- package/dist/file-draft-journal-store.d.ts +26 -0
- package/dist/file-draft-journal-store.d.ts.map +1 -0
- package/dist/file-draft-journal-store.js +123 -0
- package/dist/file-draft-journal-store.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/native-draft-session.d.ts +28 -0
- package/dist/native-draft-session.d.ts.map +1 -0
- package/dist/native-draft-session.js +154 -0
- package/dist/native-draft-session.js.map +1 -0
- package/dist/session-draft-journal-store.d.ts +44 -0
- package/dist/session-draft-journal-store.d.ts.map +1 -0
- package/dist/session-draft-journal-store.js +150 -0
- package/dist/session-draft-journal-store.js.map +1 -0
- package/dist/socket-dbfs-transport.d.ts +1 -0
- package/dist/socket-dbfs-transport.d.ts.map +1 -1
- package/dist/socket-dbfs-transport.js +7 -0
- package/dist/socket-dbfs-transport.js.map +1 -1
- package/dist/sync-engine.d.ts +39 -20
- package/dist/sync-engine.d.ts.map +1 -1
- package/dist/sync-engine.js +136 -32
- package/dist/sync-engine.js.map +1 -1
- package/dist/testing.d.ts +18 -8
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +19 -21
- package/dist/testing.js.map +1 -1
- package/package.json +7 -8
- package/dist/control-verifier.d.ts +0 -33
- package/dist/control-verifier.d.ts.map +0 -1
- package/dist/control-verifier.js +0 -82
- package/dist/control-verifier.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# @superblocksteam/workspace-sync
|
|
2
2
|
|
|
3
3
|
DBFS sync primitives for an app workspace: listing and snapshotting the local
|
|
4
|
-
tree, uploading a snapshot, downloading a tree, and
|
|
4
|
+
tree, uploading a snapshot, downloading a tree, draft markers, and the native
|
|
5
|
+
draft journal.
|
|
5
6
|
|
|
6
7
|
This is a leaf package. It depends on `@superblocksteam/shared` and
|
|
7
8
|
`@superblocksteam/util`, never on `vite-plugin-file-sync`, the CLI or the
|
|
@@ -10,6 +11,25 @@ server, so it can run outside the dev-server pod.
|
|
|
10
11
|
`vite-plugin-file-sync` binds its logger with `setSyncLoggerProvider`. Until a
|
|
11
12
|
host binds one, messages go to the console.
|
|
12
13
|
|
|
14
|
+
## Native draft journal stores
|
|
15
|
+
|
|
16
|
+
`NativeDraftJournal` persists through a `DraftJournalStore`:
|
|
17
|
+
|
|
18
|
+
- `FileDraftJournalStore` (the default) writes one base64 JSON file to
|
|
19
|
+
`<root>/../.superblocks-native-drafts/<sha256(root)>.json`. This is the
|
|
20
|
+
live-edit layout.
|
|
21
|
+
- `SessionDraftJournalStore` writes a small pointer record to a session state
|
|
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.
|
|
32
|
+
|
|
13
33
|
## Sync engine
|
|
14
34
|
|
|
15
35
|
`createWorkspaceSyncEngine` runs a workspace without the live-edit
|
|
@@ -19,12 +39,17 @@ session state directory is a cache, so the engine survives a kill at any step.
|
|
|
19
39
|
- `interimFlush()` uploads blobs only and never moves the branch hash.
|
|
20
40
|
`createFlushScheduler` runs it on the live-edit cadence (10s trailing, 30s
|
|
21
41
|
cap).
|
|
22
|
-
- `commit(source)`
|
|
23
|
-
`BranchWriteGuard
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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.
|
|
28
53
|
- `rehydrate()` compares the server hash, the stored hash and the local tree
|
|
29
54
|
on boot and returns `fresh`, `resumed`, `replayed` or `reloaded`. A
|
|
30
55
|
`reloaded` tree keeps the local diff under `<stateDir>/orphaned/`.
|
package/dist/control.d.ts
CHANGED
|
@@ -14,11 +14,6 @@ export declare const WORKSPACE_CONTROL_PREFIX = "/_sb_workspace/";
|
|
|
14
14
|
export declare const WORKSPACE_STATE_PATH = "/_sb_workspace/state";
|
|
15
15
|
/** VM ingress, edge → VM: commit the tree to DBFS now and report the result. */
|
|
16
16
|
export declare const WORKSPACE_COMMIT_PATH = "/_sb_workspace/commit";
|
|
17
|
-
/**
|
|
18
|
-
* VM ingress, edge -> VM: replace the VM's tree with the server's after the
|
|
19
|
-
* branch moved under it (a checkpoint restore), and report the result.
|
|
20
|
-
*/
|
|
21
|
-
export declare const WORKSPACE_RELOAD_PATH = "/_sb_workspace/reload";
|
|
22
17
|
/** Edge, AI service → edge: the VM's current session endpoint. */
|
|
23
18
|
export declare const WORKSPACE_ENDPOINT_PATH = "/_sb_workspace/endpoint";
|
|
24
19
|
/**
|
|
@@ -26,13 +21,6 @@ export declare const WORKSPACE_ENDPOINT_PATH = "/_sb_workspace/endpoint";
|
|
|
26
21
|
* `Authorization`: SigV4 owns that header on the edge → VM hop.
|
|
27
22
|
*/
|
|
28
23
|
export declare const WORKSPACE_TOKEN_HEADER = "x-sb-workspace-token";
|
|
29
|
-
/**
|
|
30
|
-
* Carries the control JWT on the edge's own control requests to the VM
|
|
31
|
-
* ingress ({@link WORKSPACE_STATE_PATH}, {@link WORKSPACE_COMMIT_PATH}).
|
|
32
|
-
* `authorization` is SigV4 on that hop. Invocations do not carry it: the
|
|
33
|
-
* server signs a statement for each of those.
|
|
34
|
-
*/
|
|
35
|
-
export declare const WORKSPACE_CONTROL_HEADER = "x-sb-workspace-control";
|
|
36
24
|
/**
|
|
37
25
|
* The browser's Host. The edge → VM hop must send the session endpoint's own
|
|
38
26
|
* Host (it is signed), so the edge moves the original here and the VM ingress
|
|
@@ -40,16 +28,11 @@ export declare const WORKSPACE_CONTROL_HEADER = "x-sb-workspace-control";
|
|
|
40
28
|
*/
|
|
41
29
|
export declare const WORKSPACE_ORIGINAL_HOST_HEADER = "x-sb-original-host";
|
|
42
30
|
/**
|
|
43
|
-
* The
|
|
44
|
-
*
|
|
31
|
+
* The browser's `Authorization`. SigV4 owns `Authorization` on the edge → VM
|
|
32
|
+
* hop, so the edge moves the browser's value here (dropping any inbound copy)
|
|
33
|
+
* and the VM ingress restores it before the workspace host checks it.
|
|
45
34
|
*/
|
|
46
|
-
export declare const
|
|
47
|
-
/**
|
|
48
|
-
* The AI service's internal token on its dev socket upgrade (SigV4 owns
|
|
49
|
-
* Authorization on the edge -> VM hop). The edge passes it only from inside
|
|
50
|
-
* the pod; the VM verifies it.
|
|
51
|
-
*/
|
|
52
|
-
export declare const WORKSPACE_INTERNAL_AUTHORIZATION_HEADER = "x-sb-internal-authorization";
|
|
35
|
+
export declare const WORKSPACE_ORIGINAL_AUTHORIZATION_HEADER = "x-sb-original-authorization";
|
|
53
36
|
/** True when `pathname` is a control path that must not be forwarded. */
|
|
54
37
|
export declare function isWorkspaceControlPath(pathname: string): boolean;
|
|
55
38
|
/**
|
|
@@ -90,8 +73,15 @@ export declare function tokensEqual(a: string, b: string): boolean;
|
|
|
90
73
|
export declare function hasWorkspaceToken(headers: Record<string, string | string[] | undefined>, expected: string): boolean;
|
|
91
74
|
export declare const workspaceSyncCredentialSchema: z.ZodObject<{
|
|
92
75
|
token: z.ZodString;
|
|
76
|
+
/** Epoch milliseconds after which the server rejects the token. */
|
|
93
77
|
expiresAt: z.ZodNumber;
|
|
94
|
-
}, z.
|
|
78
|
+
}, "strip", z.ZodTypeAny, {
|
|
79
|
+
token: string;
|
|
80
|
+
expiresAt: number;
|
|
81
|
+
}, {
|
|
82
|
+
token: string;
|
|
83
|
+
expiresAt: number;
|
|
84
|
+
}>;
|
|
95
85
|
export type WorkspaceSyncCredential = z.infer<typeof workspaceSyncCredentialSchema>;
|
|
96
86
|
/**
|
|
97
87
|
* Everything the VM needs from the edge, sent whole every time
|
|
@@ -101,14 +91,44 @@ export type WorkspaceSyncCredential = z.infer<typeof workspaceSyncCredentialSche
|
|
|
101
91
|
* its copy; it never merges.
|
|
102
92
|
*/
|
|
103
93
|
export declare const workspaceStateSchema: z.ZodObject<{
|
|
94
|
+
/** The edge holds the branch lock; without it the VM must not commit. */
|
|
104
95
|
lockHeld: z.ZodBoolean;
|
|
96
|
+
/** A user was recently active in the editor (feeds the VM's busy policy). */
|
|
105
97
|
userActive: z.ZodBoolean;
|
|
98
|
+
/** The edge is shutting down; going quiet after this is not a failure. */
|
|
106
99
|
draining: z.ZodBoolean;
|
|
100
|
+
/**
|
|
101
|
+
* Absent until the edge has minted one. A snapshot without one leaves the
|
|
102
|
+
* VM's last credential in place; the server enforces its expiry.
|
|
103
|
+
*/
|
|
107
104
|
credential: z.ZodOptional<z.ZodObject<{
|
|
108
105
|
token: z.ZodString;
|
|
106
|
+
/** Epoch milliseconds after which the server rejects the token. */
|
|
109
107
|
expiresAt: z.ZodNumber;
|
|
110
|
-
}, z.
|
|
111
|
-
|
|
108
|
+
}, "strip", z.ZodTypeAny, {
|
|
109
|
+
token: string;
|
|
110
|
+
expiresAt: number;
|
|
111
|
+
}, {
|
|
112
|
+
token: string;
|
|
113
|
+
expiresAt: number;
|
|
114
|
+
}>>;
|
|
115
|
+
}, "strip", z.ZodTypeAny, {
|
|
116
|
+
lockHeld: boolean;
|
|
117
|
+
userActive: boolean;
|
|
118
|
+
draining: boolean;
|
|
119
|
+
credential?: {
|
|
120
|
+
token: string;
|
|
121
|
+
expiresAt: number;
|
|
122
|
+
} | undefined;
|
|
123
|
+
}, {
|
|
124
|
+
lockHeld: boolean;
|
|
125
|
+
userActive: boolean;
|
|
126
|
+
draining: boolean;
|
|
127
|
+
credential?: {
|
|
128
|
+
token: string;
|
|
129
|
+
expiresAt: number;
|
|
130
|
+
} | undefined;
|
|
131
|
+
}>;
|
|
112
132
|
export type WorkspaceState = z.infer<typeof workspaceStateSchema>;
|
|
113
133
|
/**
|
|
114
134
|
* The VM's answer to a state snapshot. `bootId` is random per VM process, for
|
|
@@ -116,51 +136,56 @@ export type WorkspaceState = z.infer<typeof workspaceStateSchema>;
|
|
|
116
136
|
*/
|
|
117
137
|
export declare const workspaceStatusSchema: z.ZodObject<{
|
|
118
138
|
bootId: z.ZodString;
|
|
119
|
-
devServer: z.ZodEnum<
|
|
120
|
-
|
|
121
|
-
failed: "failed";
|
|
122
|
-
ready: "ready";
|
|
123
|
-
}>;
|
|
139
|
+
devServer: z.ZodEnum<["booting", "ready", "failed"]>;
|
|
140
|
+
/** Local changes not yet committed to DBFS. */
|
|
124
141
|
unsynced: z.ZodBoolean;
|
|
125
142
|
dbfsHash: z.ZodOptional<z.ZodString>;
|
|
126
|
-
}, z.
|
|
143
|
+
}, "strip", z.ZodTypeAny, {
|
|
144
|
+
bootId: string;
|
|
145
|
+
devServer: "booting" | "failed" | "ready";
|
|
146
|
+
unsynced: boolean;
|
|
147
|
+
dbfsHash?: string | undefined;
|
|
148
|
+
}, {
|
|
149
|
+
bootId: string;
|
|
150
|
+
devServer: "booting" | "failed" | "ready";
|
|
151
|
+
unsynced: boolean;
|
|
152
|
+
dbfsHash?: string | undefined;
|
|
153
|
+
}>;
|
|
127
154
|
export type WorkspaceStatus = z.infer<typeof workspaceStatusSchema>;
|
|
128
155
|
/**
|
|
129
156
|
* The response body of `POST` {@link WORKSPACE_COMMIT_PATH}, always with
|
|
130
157
|
* status 200 so the edge reads one shape. `not_ready` means the workspace is
|
|
131
158
|
* not open or has no state snapshot yet; the edge reports it like an error.
|
|
132
159
|
*/
|
|
133
|
-
export declare const workspaceCommitResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
160
|
+
export declare const workspaceCommitResultSchema: z.ZodDiscriminatedUnion<"outcome", [z.ZodObject<{
|
|
134
161
|
outcome: z.ZodLiteral<"committed">;
|
|
135
162
|
dbfsHash: z.ZodOptional<z.ZodString>;
|
|
136
|
-
},
|
|
163
|
+
}, "strip", z.ZodTypeAny, {
|
|
164
|
+
outcome: "committed";
|
|
165
|
+
dbfsHash?: string | undefined;
|
|
166
|
+
}, {
|
|
167
|
+
outcome: "committed";
|
|
168
|
+
dbfsHash?: string | undefined;
|
|
169
|
+
}>, z.ZodObject<{
|
|
137
170
|
outcome: z.ZodLiteral<"not_ready">;
|
|
138
171
|
reason: z.ZodString;
|
|
139
|
-
},
|
|
172
|
+
}, "strip", z.ZodTypeAny, {
|
|
173
|
+
outcome: "not_ready";
|
|
174
|
+
reason: string;
|
|
175
|
+
}, {
|
|
176
|
+
outcome: "not_ready";
|
|
177
|
+
reason: string;
|
|
178
|
+
}>, z.ZodObject<{
|
|
140
179
|
outcome: z.ZodLiteral<"error">;
|
|
141
180
|
error: z.ZodString;
|
|
142
|
-
}, z.
|
|
181
|
+
}, "strip", z.ZodTypeAny, {
|
|
182
|
+
outcome: "error";
|
|
183
|
+
error: string;
|
|
184
|
+
}, {
|
|
185
|
+
outcome: "error";
|
|
186
|
+
error: string;
|
|
187
|
+
}>]>;
|
|
143
188
|
export type WorkspaceCommitResult = z.infer<typeof workspaceCommitResultSchema>;
|
|
144
|
-
/**
|
|
145
|
-
* The response body of `POST` {@link WORKSPACE_RELOAD_PATH}, always with
|
|
146
|
-
* status 200 like the commit. When the server's branch hash is the VM's
|
|
147
|
-
* stored one there is nothing to load and the VM answers at once. When the
|
|
148
|
-
* branch moved (a restore), the VM waits for a running turn, then the server
|
|
149
|
-
* tree replaces the local one and any unsaved local diff is set aside.
|
|
150
|
-
* `filesChanged` says whether the tree was replaced.
|
|
151
|
-
*/
|
|
152
|
-
export declare const workspaceReloadResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
153
|
-
outcome: z.ZodLiteral<"reloaded">;
|
|
154
|
-
dbfsHash: z.ZodOptional<z.ZodString>;
|
|
155
|
-
filesChanged: z.ZodBoolean;
|
|
156
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
157
|
-
outcome: z.ZodLiteral<"not_ready">;
|
|
158
|
-
reason: z.ZodString;
|
|
159
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
160
|
-
outcome: z.ZodLiteral<"error">;
|
|
161
|
-
error: z.ZodString;
|
|
162
|
-
}, z.core.$strip>], "outcome">;
|
|
163
|
-
export type WorkspaceReloadResult = z.infer<typeof workspaceReloadResultSchema>;
|
|
164
189
|
/**
|
|
165
190
|
* Where the VM's ingress is reachable and how the edge authenticates to it
|
|
166
191
|
* (`PUT` {@link WORKSPACE_ENDPOINT_PATH}). Each `workspace.open` that returns
|
|
@@ -174,20 +199,52 @@ export type WorkspaceReloadResult = z.infer<typeof workspaceReloadResultSchema>;
|
|
|
174
199
|
* grant before the old one expires.
|
|
175
200
|
* - `none`: a local builder runtime reached directly, for development.
|
|
176
201
|
*/
|
|
177
|
-
export declare const workspaceEndpointSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
202
|
+
export declare const workspaceEndpointSchema: z.ZodDiscriminatedUnion<"auth", [z.ZodObject<{
|
|
178
203
|
auth: z.ZodLiteral<"sigv4">;
|
|
179
|
-
url: z.ZodString
|
|
204
|
+
url: z.ZodEffects<z.ZodString, string, string>;
|
|
180
205
|
region: z.ZodString;
|
|
181
206
|
sessionKey: z.ZodString;
|
|
182
207
|
signer: z.ZodObject<{
|
|
183
208
|
url: z.ZodString;
|
|
184
209
|
grant: z.ZodString;
|
|
185
|
-
}, z.
|
|
186
|
-
|
|
210
|
+
}, "strip", z.ZodTypeAny, {
|
|
211
|
+
url: string;
|
|
212
|
+
grant: string;
|
|
213
|
+
}, {
|
|
214
|
+
url: string;
|
|
215
|
+
grant: string;
|
|
216
|
+
}>;
|
|
217
|
+
}, "strip", z.ZodTypeAny, {
|
|
218
|
+
auth: "sigv4";
|
|
219
|
+
url: string;
|
|
220
|
+
region: string;
|
|
221
|
+
sessionKey: string;
|
|
222
|
+
signer: {
|
|
223
|
+
url: string;
|
|
224
|
+
grant: string;
|
|
225
|
+
};
|
|
226
|
+
}, {
|
|
227
|
+
auth: "sigv4";
|
|
228
|
+
url: string;
|
|
229
|
+
region: string;
|
|
230
|
+
sessionKey: string;
|
|
231
|
+
signer: {
|
|
232
|
+
url: string;
|
|
233
|
+
grant: string;
|
|
234
|
+
};
|
|
235
|
+
}>, z.ZodObject<{
|
|
187
236
|
auth: z.ZodLiteral<"none">;
|
|
188
|
-
url: z.ZodString
|
|
237
|
+
url: z.ZodEffects<z.ZodString, string, string>;
|
|
189
238
|
sessionKey: z.ZodString;
|
|
190
|
-
}, z.
|
|
239
|
+
}, "strip", z.ZodTypeAny, {
|
|
240
|
+
auth: "none";
|
|
241
|
+
url: string;
|
|
242
|
+
sessionKey: string;
|
|
243
|
+
}, {
|
|
244
|
+
auth: "none";
|
|
245
|
+
url: string;
|
|
246
|
+
sessionKey: string;
|
|
247
|
+
}>]>;
|
|
191
248
|
export type WorkspaceEndpoint = z.infer<typeof workspaceEndpointSchema>;
|
|
192
249
|
/**
|
|
193
250
|
* The server is the only caller of the AgentCore builder runtime. The AI
|
|
@@ -206,10 +263,7 @@ export declare const BUILDER_RUNTIME_INVOCATIONS_PATH = "/api/v1/ai/builder-runt
|
|
|
206
263
|
* a session it derived, so the pod cannot name any other.
|
|
207
264
|
*/
|
|
208
265
|
export declare const BUILDER_RUNTIME_SESSION_HEADER = "x-sb-builder-runtime-session";
|
|
209
|
-
export declare const builderRuntimeSessionSchema: z.ZodEnum<
|
|
210
|
-
chat: "chat";
|
|
211
|
-
workspace: "workspace";
|
|
212
|
-
}>;
|
|
266
|
+
export declare const builderRuntimeSessionSchema: z.ZodEnum<["workspace", "chat"]>;
|
|
213
267
|
export type BuilderRuntimeSession = z.infer<typeof builderRuntimeSessionSchema>;
|
|
214
268
|
/**
|
|
215
269
|
* Signs one request to a session endpoint (`POST`, body
|
|
@@ -231,14 +285,24 @@ export declare const BUILDER_RUNTIME_ENDPOINT_HEADER = "x-sb-workspace-endpoint"
|
|
|
231
285
|
/** On a `workspace.open` response: the sign grant for that endpoint. */
|
|
232
286
|
export declare const BUILDER_RUNTIME_SIGN_GRANT_HEADER = "x-sb-workspace-sign-grant";
|
|
233
287
|
export declare const builderRuntimeEndpointHeaderSchema: z.ZodObject<{
|
|
234
|
-
url: z.ZodString
|
|
288
|
+
url: z.ZodEffects<z.ZodString, string, string>;
|
|
235
289
|
region: z.ZodString;
|
|
236
|
-
}, z.
|
|
290
|
+
}, "strip", z.ZodTypeAny, {
|
|
291
|
+
url: string;
|
|
292
|
+
region: string;
|
|
293
|
+
}, {
|
|
294
|
+
url: string;
|
|
295
|
+
region: string;
|
|
296
|
+
}>;
|
|
237
297
|
export type BuilderRuntimeEndpointHeader = z.infer<typeof builderRuntimeEndpointHeaderSchema>;
|
|
238
298
|
/** A sign grant, as sent to and returned by the renew route. */
|
|
239
299
|
export declare const builderRuntimeSignGrantSchema: z.ZodObject<{
|
|
240
300
|
grant: z.ZodString;
|
|
241
|
-
}, z.
|
|
301
|
+
}, "strip", z.ZodTypeAny, {
|
|
302
|
+
grant: string;
|
|
303
|
+
}, {
|
|
304
|
+
grant: string;
|
|
305
|
+
}>;
|
|
242
306
|
/**
|
|
243
307
|
* One request the edge wants signed. `headers` are the lowercased headers the
|
|
244
308
|
* signer covers (`host` and `x-amz-*`); the body is never sent because the
|
|
@@ -247,23 +311,27 @@ export declare const builderRuntimeSignGrantSchema: z.ZodObject<{
|
|
|
247
311
|
* that check.
|
|
248
312
|
*/
|
|
249
313
|
export declare const workspaceSignRequestSchema: z.ZodObject<{
|
|
250
|
-
method: z.ZodEnum<
|
|
251
|
-
DELETE: "DELETE";
|
|
252
|
-
GET: "GET";
|
|
253
|
-
HEAD: "HEAD";
|
|
254
|
-
OPTIONS: "OPTIONS";
|
|
255
|
-
PATCH: "PATCH";
|
|
256
|
-
POST: "POST";
|
|
257
|
-
PUT: "PUT";
|
|
258
|
-
}>;
|
|
314
|
+
method: z.ZodEnum<["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]>;
|
|
259
315
|
url: z.ZodString;
|
|
260
316
|
headers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
261
|
-
}, z.
|
|
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
|
+
}>;
|
|
262
326
|
export type WorkspaceSignRequest = z.infer<typeof workspaceSignRequestSchema>;
|
|
263
327
|
/** The signed header set: the request's headers plus the SigV4 headers. */
|
|
264
328
|
export declare const workspaceSignResponseSchema: z.ZodObject<{
|
|
265
329
|
headers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
266
|
-
}, z.
|
|
330
|
+
}, "strip", z.ZodTypeAny, {
|
|
331
|
+
headers: Record<string, string>;
|
|
332
|
+
}, {
|
|
333
|
+
headers: Record<string, string>;
|
|
334
|
+
}>;
|
|
267
335
|
export type WorkspaceSignResponse = z.infer<typeof workspaceSignResponseSchema>;
|
|
268
336
|
/**
|
|
269
337
|
* The audience of the statement the server signs for each invocation. The VM
|
|
@@ -276,13 +344,25 @@ export declare const BUILDER_RUNTIME_INVOCATION_AUDIENCE = "https://superblocks-
|
|
|
276
344
|
export declare const builderRuntimeInvocationEnvelopeSchema: z.ZodObject<{
|
|
277
345
|
authorization: z.ZodString;
|
|
278
346
|
payload: z.ZodString;
|
|
279
|
-
}, z.
|
|
347
|
+
}, "strict", z.ZodTypeAny, {
|
|
348
|
+
authorization: string;
|
|
349
|
+
payload: string;
|
|
350
|
+
}, {
|
|
351
|
+
authorization: string;
|
|
352
|
+
payload: string;
|
|
353
|
+
}>;
|
|
280
354
|
export type BuilderRuntimeInvocationEnvelope = z.infer<typeof builderRuntimeInvocationEnvelopeSchema>;
|
|
281
355
|
/** The statement's own claims, beside the standard `iss`, `aud` and `exp`. */
|
|
282
356
|
export declare const builderRuntimeInvocationClaimsSchema: z.ZodObject<{
|
|
283
357
|
rsid: z.ZodString;
|
|
284
358
|
payload_sha256: z.ZodString;
|
|
285
|
-
}, z.
|
|
359
|
+
}, "strip", z.ZodTypeAny, {
|
|
360
|
+
rsid: string;
|
|
361
|
+
payload_sha256: string;
|
|
362
|
+
}, {
|
|
363
|
+
rsid: string;
|
|
364
|
+
payload_sha256: string;
|
|
365
|
+
}>;
|
|
286
366
|
/** The hex SHA-256 of an invocation payload, as the statement names it. */
|
|
287
367
|
export declare function invocationPayloadDigest(payload: string): string;
|
|
288
368
|
/**
|
|
@@ -298,13 +378,6 @@ export declare function invocationPayloadDigest(payload: string): string;
|
|
|
298
378
|
* until the workspace is reopened).
|
|
299
379
|
* - `closed`: the edge is shutting down.
|
|
300
380
|
*/
|
|
301
|
-
export declare const workspaceIngressStateSchema: z.ZodEnum<
|
|
302
|
-
closed: "closed";
|
|
303
|
-
reachable: "reachable";
|
|
304
|
-
unreachable: "unreachable";
|
|
305
|
-
waiting: "waiting";
|
|
306
|
-
}>;
|
|
381
|
+
export declare const workspaceIngressStateSchema: z.ZodEnum<["waiting", "reachable", "unreachable", "closed"]>;
|
|
307
382
|
export type WorkspaceIngressState = z.infer<typeof workspaceIngressStateSchema>;
|
|
308
|
-
export { createWorkspaceControlVerifier, WORKSPACE_CONTROL_AUDIENCE, WORKSPACE_CONTROL_ISSUER, WORKSPACE_CONTROL_SCOPE, WorkspaceControlError, } from "./control-verifier.js";
|
|
309
|
-
export type { WorkspaceControlClaims, WorkspaceControlErrorReason, } from "./control-verifier.js";
|
|
310
383
|
//# sourceMappingURL=control.d.ts.map
|
package/dist/control.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../src/control.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"control.d.ts","sourceRoot":"","sources":["../src/control.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;;GAGG;AACH,eAAO,MAA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
* reaches.
|
|
13
13
|
*
|
|
14
|
-
* Constants, the shared bearer token
|
|
15
|
-
*
|
|
14
|
+
* Constants, the shared bearer token and message schemas only: no IO, so any
|
|
15
|
+
* party can be replaced as long as it speaks this file. Import it as
|
|
16
|
+
* `@superblocksteam/workspace-sync/control`.
|
|
16
17
|
*
|
|
17
18
|
* The edge and the VM image ship separately, so the schemas strip unknown
|
|
18
19
|
* fields instead of rejecting them: either side may add a field first.
|
|
@@ -37,11 +38,6 @@ export const WORKSPACE_CONTROL_PREFIX = "/_sb_workspace/";
|
|
|
37
38
|
export const WORKSPACE_STATE_PATH = "/_sb_workspace/state";
|
|
38
39
|
/** VM ingress, edge → VM: commit the tree to DBFS now and report the result. */
|
|
39
40
|
export const WORKSPACE_COMMIT_PATH = "/_sb_workspace/commit";
|
|
40
|
-
/**
|
|
41
|
-
* VM ingress, edge -> VM: replace the VM's tree with the server's after the
|
|
42
|
-
* branch moved under it (a checkpoint restore), and report the result.
|
|
43
|
-
*/
|
|
44
|
-
export const WORKSPACE_RELOAD_PATH = "/_sb_workspace/reload";
|
|
45
41
|
/** Edge, AI service → edge: the VM's current session endpoint. */
|
|
46
42
|
export const WORKSPACE_ENDPOINT_PATH = "/_sb_workspace/endpoint";
|
|
47
43
|
/**
|
|
@@ -49,13 +45,6 @@ export const WORKSPACE_ENDPOINT_PATH = "/_sb_workspace/endpoint";
|
|
|
49
45
|
* `Authorization`: SigV4 owns that header on the edge → VM hop.
|
|
50
46
|
*/
|
|
51
47
|
export const WORKSPACE_TOKEN_HEADER = "x-sb-workspace-token";
|
|
52
|
-
/**
|
|
53
|
-
* Carries the control JWT on the edge's own control requests to the VM
|
|
54
|
-
* ingress ({@link WORKSPACE_STATE_PATH}, {@link WORKSPACE_COMMIT_PATH}).
|
|
55
|
-
* `authorization` is SigV4 on that hop. Invocations do not carry it: the
|
|
56
|
-
* server signs a statement for each of those.
|
|
57
|
-
*/
|
|
58
|
-
export const WORKSPACE_CONTROL_HEADER = "x-sb-workspace-control";
|
|
59
48
|
/**
|
|
60
49
|
* The browser's Host. The edge → VM hop must send the session endpoint's own
|
|
61
50
|
* Host (it is signed), so the edge moves the original here and the VM ingress
|
|
@@ -63,16 +52,11 @@ export const WORKSPACE_CONTROL_HEADER = "x-sb-workspace-control";
|
|
|
63
52
|
*/
|
|
64
53
|
export const WORKSPACE_ORIGINAL_HOST_HEADER = "x-sb-original-host";
|
|
65
54
|
/**
|
|
66
|
-
* The
|
|
67
|
-
*
|
|
68
|
-
|
|
69
|
-
export const WORKSPACE_EDGE_AUTHENTICATED_HEADER = "x-sb-edge-authenticated";
|
|
70
|
-
/**
|
|
71
|
-
* The AI service's internal token on its dev socket upgrade (SigV4 owns
|
|
72
|
-
* Authorization on the edge -> VM hop). The edge passes it only from inside
|
|
73
|
-
* the pod; the VM verifies it.
|
|
55
|
+
* The browser's `Authorization`. SigV4 owns `Authorization` on the edge → VM
|
|
56
|
+
* hop, so the edge moves the browser's value here (dropping any inbound copy)
|
|
57
|
+
* and the VM ingress restores it before the workspace host checks it.
|
|
74
58
|
*/
|
|
75
|
-
export const
|
|
59
|
+
export const WORKSPACE_ORIGINAL_AUTHORIZATION_HEADER = "x-sb-original-authorization";
|
|
76
60
|
/** True when `pathname` is a control path that must not be forwarded. */
|
|
77
61
|
export function isWorkspaceControlPath(pathname) {
|
|
78
62
|
return pathname.startsWith(WORKSPACE_CONTROL_PREFIX);
|
|
@@ -218,32 +202,6 @@ export const workspaceCommitResultSchema = z.discriminatedUnion("outcome", [
|
|
|
218
202
|
}),
|
|
219
203
|
]);
|
|
220
204
|
// ---------------------------------------------------------------------------
|
|
221
|
-
// Edge → VM: reload
|
|
222
|
-
// ---------------------------------------------------------------------------
|
|
223
|
-
/**
|
|
224
|
-
* The response body of `POST` {@link WORKSPACE_RELOAD_PATH}, always with
|
|
225
|
-
* status 200 like the commit. When the server's branch hash is the VM's
|
|
226
|
-
* stored one there is nothing to load and the VM answers at once. When the
|
|
227
|
-
* branch moved (a restore), the VM waits for a running turn, then the server
|
|
228
|
-
* tree replaces the local one and any unsaved local diff is set aside.
|
|
229
|
-
* `filesChanged` says whether the tree was replaced.
|
|
230
|
-
*/
|
|
231
|
-
export const workspaceReloadResultSchema = z.discriminatedUnion("outcome", [
|
|
232
|
-
z.object({
|
|
233
|
-
outcome: z.literal("reloaded"),
|
|
234
|
-
dbfsHash: z.string().optional(),
|
|
235
|
-
filesChanged: z.boolean(),
|
|
236
|
-
}),
|
|
237
|
-
z.object({
|
|
238
|
-
outcome: z.literal("not_ready"),
|
|
239
|
-
reason: z.string().max(512),
|
|
240
|
-
}),
|
|
241
|
-
z.object({
|
|
242
|
-
outcome: z.literal("error"),
|
|
243
|
-
error: z.string().max(512),
|
|
244
|
-
}),
|
|
245
|
-
]);
|
|
246
|
-
// ---------------------------------------------------------------------------
|
|
247
205
|
// AI service → edge: session endpoint
|
|
248
206
|
// ---------------------------------------------------------------------------
|
|
249
207
|
const endpointUrl = z
|
|
@@ -393,5 +351,4 @@ export const workspaceIngressStateSchema = z.enum([
|
|
|
393
351
|
"unreachable",
|
|
394
352
|
"closed",
|
|
395
353
|
]);
|
|
396
|
-
export { createWorkspaceControlVerifier, WORKSPACE_CONTROL_AUDIENCE, WORKSPACE_CONTROL_ISSUER, WORKSPACE_CONTROL_SCOPE, WorkspaceControlError, } from "./control-verifier.js";
|
|
397
354
|
//# sourceMappingURL=control.js.map
|
package/dist/control.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control.js","sourceRoot":"","sources":["../src/control.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"control.js","sourceRoot":"","sources":["../src/control.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,8EAA8E;AAC9E,2BAA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;AAC9E,iDAAiD;AACjD,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAC9C,gDAAgD,CAAC;AAEnD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,sCAAsC,GAAG,CAAC;KACpD,MAAM,CAAC;IACN,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC;IAC1C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,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"}
|
package/dist/dbfs-transport.d.ts
CHANGED
|
@@ -12,10 +12,7 @@ export interface SetHashRequest {
|
|
|
12
12
|
export interface SetHashResult {
|
|
13
13
|
hash: string;
|
|
14
14
|
commitId?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Why the server made no new checkpoint. With `no-changes` an `ai:accept`
|
|
17
|
-
* still returns the last checkpoint's id, which is not a new commit.
|
|
18
|
-
*/
|
|
15
|
+
/** Why the server made no checkpoint, when it skipped one by design. */
|
|
19
16
|
checkpointSkipped?: CheckpointSkipReason;
|
|
20
17
|
/**
|
|
21
18
|
* Protected paths whose changes the server holds for a user's approval.
|
|
@@ -48,5 +45,7 @@ export interface DbfsTransport {
|
|
|
48
45
|
getServerHash(): Promise<string>;
|
|
49
46
|
/** Moves the branch's working-copy hash. */
|
|
50
47
|
setHash(request: SetHashRequest): Promise<SetHashResult>;
|
|
48
|
+
/** Reports whether the workspace has unaccepted drafts. */
|
|
49
|
+
setDraftState(hasDraft: boolean): Promise<void>;
|
|
51
50
|
}
|
|
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,oBAAoB,EACpB,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,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;IAClB
|
|
1
|
+
{"version":3,"file":"dbfs-transport.d.ts","sourceRoot":"","sources":["../src/dbfs-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,oBAAoB,EACpB,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,WAA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string, content: string | Buffe
|
|
|
47
47
|
* file untouched. `original` is the pre-draft content of an edit or a delete.
|
|
48
48
|
*/
|
|
49
49
|
export declare function writeDraftMarker(relativePath: string, appRootDirPath: string, kind: keyof typeof MARKER_EXT, original?: Buffer): Promise<void>;
|
|
50
|
+
export declare class DraftMarkers {
|
|
51
|
+
private readonly root;
|
|
52
|
+
constructor(root: string);
|
|
53
|
+
prepare(): Promise<void>;
|
|
54
|
+
originals(targets: string[], before: Map<string, Buffer>, maxBytes: number, maxFiles: number): Promise<Map<string, Buffer>>;
|
|
55
|
+
private assertSafePath;
|
|
56
|
+
private markerFiles;
|
|
57
|
+
reconcile(relative: string, original: Buffer | undefined, current: Buffer | undefined): Promise<void>;
|
|
58
|
+
private withinTargets;
|
|
59
|
+
}
|
|
50
60
|
/**
|
|
51
61
|
* Creates a draft deletion by backing up the file content and removing it from the workspace.
|
|
52
62
|
*
|
|
@@ -63,6 +73,19 @@ export declare function createDraftDelete(filePath: string, appRootDirPath: stri
|
|
|
63
73
|
* @returns A promise that resolves to true if any draft files are found, false otherwise.
|
|
64
74
|
*/
|
|
65
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>;
|
|
66
89
|
/**
|
|
67
90
|
* Discards all draft changes by removing draft additions, then restoring the
|
|
68
91
|
* originals of edits and deletions. Each marker is retired once its step
|