@superblocksteam/workspace-sync 2.0.183 → 2.0.186-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 +7 -32
- package/dist/agent-skill-path-cases.d.ts +22 -0
- package/dist/agent-skill-path-cases.d.ts.map +1 -0
- package/dist/agent-skill-path-cases.js +52 -0
- package/dist/agent-skill-path-cases.js.map +1 -0
- package/dist/control-verifier.d.ts +33 -0
- package/dist/control-verifier.d.ts.map +1 -0
- package/dist/control-verifier.js +82 -0
- package/dist/control-verifier.js.map +1 -0
- package/dist/control.d.ts +94 -161
- package/dist/control.d.ts.map +1 -1
- package/dist/control.js +56 -7
- package/dist/control.js.map +1 -1
- package/dist/dbfs-transport.d.ts +4 -3
- package/dist/dbfs-transport.d.ts.map +1 -1
- package/dist/draft-helpers.d.ts +0 -23
- package/dist/draft-helpers.d.ts.map +1 -1
- package/dist/draft-helpers.js +5 -179
- package/dist/draft-helpers.js.map +1 -1
- package/dist/index.d.ts +0 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -5
- package/dist/index.js.map +1 -1
- package/dist/socket-dbfs-transport.d.ts +0 -1
- package/dist/socket-dbfs-transport.d.ts.map +1 -1
- package/dist/socket-dbfs-transport.js +0 -7
- package/dist/socket-dbfs-transport.js.map +1 -1
- package/dist/sync-engine.d.ts +20 -39
- package/dist/sync-engine.d.ts.map +1 -1
- package/dist/sync-engine.js +32 -136
- package/dist/sync-engine.js.map +1 -1
- package/dist/sync-paths.d.ts +41 -0
- package/dist/sync-paths.d.ts.map +1 -1
- package/dist/sync-paths.js +54 -0
- package/dist/sync-paths.js.map +1 -1
- package/dist/testing.d.ts +8 -18
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +21 -19
- package/dist/testing.js.map +1 -1
- package/package.json +7 -15
- package/dist/draft-journal-store.d.ts +0 -30
- package/dist/draft-journal-store.d.ts.map +0 -1
- package/dist/draft-journal-store.js +0 -7
- package/dist/draft-journal-store.js.map +0 -1
- package/dist/file-draft-journal-blob-store.d.ts +0 -14
- package/dist/file-draft-journal-blob-store.d.ts.map +0 -1
- package/dist/file-draft-journal-blob-store.js +0 -74
- package/dist/file-draft-journal-blob-store.js.map +0 -1
- package/dist/file-draft-journal-store.d.ts +0 -26
- package/dist/file-draft-journal-store.d.ts.map +0 -1
- package/dist/file-draft-journal-store.js +0 -123
- package/dist/file-draft-journal-store.js.map +0 -1
- package/dist/native-draft-session.d.ts +0 -28
- package/dist/native-draft-session.d.ts.map +0 -1
- package/dist/native-draft-session.js +0 -154
- package/dist/native-draft-session.js.map +0 -1
- package/dist/session-draft-journal-store.d.ts +0 -44
- package/dist/session-draft-journal-store.d.ts.map +0 -1
- package/dist/session-draft-journal-store.js +0 -150
- package/dist/session-draft-journal-store.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
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, draft markers
|
|
5
|
-
draft journal.
|
|
4
|
+
tree, uploading a snapshot, downloading a tree, and draft markers.
|
|
6
5
|
|
|
7
6
|
This is a leaf package. It depends on `@superblocksteam/shared` and
|
|
8
7
|
`@superblocksteam/util`, never on `vite-plugin-file-sync`, the CLI or the
|
|
@@ -11,25 +10,6 @@ server, so it can run outside the dev-server pod.
|
|
|
11
10
|
`vite-plugin-file-sync` binds its logger with `setSyncLoggerProvider`. Until a
|
|
12
11
|
host binds one, messages go to the console.
|
|
13
12
|
|
|
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
|
-
|
|
33
13
|
## Sync engine
|
|
34
14
|
|
|
35
15
|
`createWorkspaceSyncEngine` runs a workspace without the live-edit
|
|
@@ -39,17 +19,12 @@ session state directory is a cache, so the engine survives a kill at any step.
|
|
|
39
19
|
- `interimFlush()` uploads blobs only and never moves the branch hash.
|
|
40
20
|
`createFlushScheduler` runs it on the live-edit cadence (10s trailing, 30s
|
|
41
21
|
cap).
|
|
42
|
-
- `commit(source)`
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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.
|
|
22
|
+
- `commit(source)` snapshots the tree, uploads what DBFS lacks, asks the
|
|
23
|
+
`BranchWriteGuard`, moves the branch hash, then writes the state store. An
|
|
24
|
+
unchanged tree skips the server. A turn end passes `turnBaseHash`, the
|
|
25
|
+
stored hash when the turn began: when commits during the turn moved the
|
|
26
|
+
hash past it, the turn end still reaches the server with its source
|
|
27
|
+
(`ai:accept`), which makes the checkpoint or reports `checkpointSkipped`.
|
|
53
28
|
- `rehydrate()` compares the server hash, the stored hash and the local tree
|
|
54
29
|
on boot and returns `fresh`, `resumed`, `replayed` or `reloaded`. A
|
|
55
30
|
`reloaded` tree keeps the local diff under `<stateDir>/orphaned/`.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paths from the app root, and whether a native builder may write them. Every
|
|
3
|
+
* layer that keeps `skills` folders read-only runs these against its own
|
|
4
|
+
* check, so the one exception (`isInsideAgentSkillsFolder` in `sync-paths.ts`)
|
|
5
|
+
* means the same thing in each. Published as the
|
|
6
|
+
* `@superblocksteam/workspace-sync/agent-skill-path-cases` subpath for those
|
|
7
|
+
* tests. Not for production use.
|
|
8
|
+
*/
|
|
9
|
+
export declare const AGENT_SKILL_PATH_CASES: {
|
|
10
|
+
/** Files of a project agent's own skills. A native builder may create, change and delete them. */
|
|
11
|
+
readonly writable: readonly ["agents/Support/skills/refund-policy/SKILL.md", "agents/Support/skills/refund-policy/references/tiers.md", "agents/orders-analyst/skills/customer-name/SKILL.md", "agents/a_b-1/skills/x/SKILL.md", "agents/Support/skills/notes.md"];
|
|
12
|
+
/** Still read-only. Every layer refuses these, or holds them for the user's approval. */
|
|
13
|
+
readonly refused: readonly ["skills/app/a.md", "skills/system/project-agents/SKILL.md", "agents/skills/a.md", "agents/Support/docs/skills/a.md", "server/agents/Support/skills/a/SKILL.md", "client/skills/a.md", "client/pages/skills/a.md", ".claude/skills/a/SKILL.md", "agents/.claude/skills/a/SKILL.md", "agents/.codex/skills/a/SKILL.md", "agents/Support/skills/a/AGENTS.md", "agents/Support/skills/a/.npmrc", "agents/Support/skills/a/skills/b.md", "agents/Support/skills/skills/b.md"];
|
|
14
|
+
/**
|
|
15
|
+
* Refused by the layers that check the rule itself: the server and the dev
|
|
16
|
+
* server. Claude Code's deny rules in the workspace VM are globs that ignore
|
|
17
|
+
* case and cannot say "not an agent name" or "not as a file", so they let
|
|
18
|
+
* these through, and the server holds them.
|
|
19
|
+
*/
|
|
20
|
+
readonly refusedWhereExact: readonly ["agents/Support/skills", "Agents/Support/skills/a/SKILL.md", "agents/my.agent/skills/a/SKILL.md", "agents/Support Team/skills/a/SKILL.md", "agents/9lives/skills/a/SKILL.md"];
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=agent-skill-path-cases.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-skill-path-cases.d.ts","sourceRoot":"","sources":["../src/agent-skill-path-cases.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB;IACjC,kGAAkG;aAClG,QAAQ,YACN,8CAA8C,EAC9C,yDAAyD,EACzD,qDAAqD,EACrD,gCAAgC,EAChC,gCAAgC;IAElC,yFAAyF;aACzF,OAAO,YAEL,iBAAiB,EACjB,uCAAuC,EACvC,oBAAoB,EACpB,iCAAiC,EACjC,yCAAyC,EACzC,oBAAoB,EACpB,0BAA0B,EAC1B,2BAA2B,EAC3B,kCAAkC,EAClC,iCAAiC,EAEjC,mCAAmC,EACnC,gCAAgC,EAChC,qCAAqC,EACrC,mCAAmC;IAErC;;;;;OAKG;aACH,iBAAiB,YAEf,uBAAuB,EACvB,kCAAkC,EAClC,mCAAmC,EACnC,uCAAuC,EACvC,iCAAiC;CAE3B,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paths from the app root, and whether a native builder may write them. Every
|
|
3
|
+
* layer that keeps `skills` folders read-only runs these against its own
|
|
4
|
+
* check, so the one exception (`isInsideAgentSkillsFolder` in `sync-paths.ts`)
|
|
5
|
+
* means the same thing in each. Published as the
|
|
6
|
+
* `@superblocksteam/workspace-sync/agent-skill-path-cases` subpath for those
|
|
7
|
+
* tests. Not for production use.
|
|
8
|
+
*/
|
|
9
|
+
export const AGENT_SKILL_PATH_CASES = {
|
|
10
|
+
/** Files of a project agent's own skills. A native builder may create, change and delete them. */
|
|
11
|
+
writable: [
|
|
12
|
+
"agents/Support/skills/refund-policy/SKILL.md",
|
|
13
|
+
"agents/Support/skills/refund-policy/references/tiers.md",
|
|
14
|
+
"agents/orders-analyst/skills/customer-name/SKILL.md",
|
|
15
|
+
"agents/a_b-1/skills/x/SKILL.md",
|
|
16
|
+
"agents/Support/skills/notes.md",
|
|
17
|
+
],
|
|
18
|
+
/** Still read-only. Every layer refuses these, or holds them for the user's approval. */
|
|
19
|
+
refused: [
|
|
20
|
+
// Not an agent's skills folder.
|
|
21
|
+
"skills/app/a.md",
|
|
22
|
+
"skills/system/project-agents/SKILL.md",
|
|
23
|
+
"agents/skills/a.md",
|
|
24
|
+
"agents/Support/docs/skills/a.md",
|
|
25
|
+
"server/agents/Support/skills/a/SKILL.md",
|
|
26
|
+
"client/skills/a.md",
|
|
27
|
+
"client/pages/skills/a.md",
|
|
28
|
+
".claude/skills/a/SKILL.md",
|
|
29
|
+
"agents/.claude/skills/a/SKILL.md",
|
|
30
|
+
"agents/.codex/skills/a/SKILL.md",
|
|
31
|
+
// Inside an agent's skills folder, every other protected name still counts.
|
|
32
|
+
"agents/Support/skills/a/AGENTS.md",
|
|
33
|
+
"agents/Support/skills/a/.npmrc",
|
|
34
|
+
"agents/Support/skills/a/skills/b.md",
|
|
35
|
+
"agents/Support/skills/skills/b.md",
|
|
36
|
+
],
|
|
37
|
+
/**
|
|
38
|
+
* Refused by the layers that check the rule itself: the server and the dev
|
|
39
|
+
* server. Claude Code's deny rules in the workspace VM are globs that ignore
|
|
40
|
+
* case and cannot say "not an agent name" or "not as a file", so they let
|
|
41
|
+
* these through, and the server holds them.
|
|
42
|
+
*/
|
|
43
|
+
refusedWhereExact: [
|
|
44
|
+
// The folder itself, written as a file.
|
|
45
|
+
"agents/Support/skills",
|
|
46
|
+
"Agents/Support/skills/a/SKILL.md",
|
|
47
|
+
"agents/my.agent/skills/a/SKILL.md",
|
|
48
|
+
"agents/Support Team/skills/a/SKILL.md",
|
|
49
|
+
"agents/9lives/skills/a/SKILL.md",
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=agent-skill-path-cases.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-skill-path-cases.js","sourceRoot":"","sources":["../src/agent-skill-path-cases.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,kGAAkG;IAClG,QAAQ,EAAE;QACR,8CAA8C;QAC9C,yDAAyD;QACzD,qDAAqD;QACrD,gCAAgC;QAChC,gCAAgC;KACjC;IACD,yFAAyF;IACzF,OAAO,EAAE;QACP,gCAAgC;QAChC,iBAAiB;QACjB,uCAAuC;QACvC,oBAAoB;QACpB,iCAAiC;QACjC,yCAAyC;QACzC,oBAAoB;QACpB,0BAA0B;QAC1B,2BAA2B;QAC3B,kCAAkC;QAClC,iCAAiC;QACjC,4EAA4E;QAC5E,mCAAmC;QACnC,gCAAgC;QAChC,qCAAqC;QACrC,mCAAmC;KACpC;IACD;;;;;OAKG;IACH,iBAAiB,EAAE;QACjB,wCAAwC;QACxC,uBAAuB;QACvB,kCAAkC;QAClC,mCAAmC;QACnC,uCAAuC;QACvC,iCAAiC;KAClC;CACO,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { JwtVerifier } from "@superblocksteam/shared";
|
|
2
|
+
/** Exact `scope` claim required on a workspace control token (`apps:*`, like the other application scopes). */
|
|
3
|
+
export declare const WORKSPACE_CONTROL_SCOPE = "apps:control";
|
|
4
|
+
/** Exact `aud` claim required on a workspace control token. */
|
|
5
|
+
export declare const WORKSPACE_CONTROL_AUDIENCE = "https://superblocks-workspace-control";
|
|
6
|
+
/** Exact `iss` claim required on a workspace control token. */
|
|
7
|
+
export declare const WORKSPACE_CONTROL_ISSUER = "superblocks";
|
|
8
|
+
export type WorkspaceControlErrorReason = "invalid" | "expired" | "scope" | "claims";
|
|
9
|
+
/** A workspace control token failed verification or claim checks. */
|
|
10
|
+
export declare class WorkspaceControlError extends Error {
|
|
11
|
+
readonly reason: WorkspaceControlErrorReason;
|
|
12
|
+
constructor(reason: WorkspaceControlErrorReason);
|
|
13
|
+
}
|
|
14
|
+
/** Claims the builder runtime and workspace edge both rely on. `expiresAt` is epoch seconds. */
|
|
15
|
+
export type WorkspaceControlClaims = {
|
|
16
|
+
applicationId: string;
|
|
17
|
+
branchName: string;
|
|
18
|
+
organizationId: string;
|
|
19
|
+
subject: string;
|
|
20
|
+
expiresAt: number;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Verifies a workspace control JWT: ES256, the control issuer, audience, and
|
|
24
|
+
* scope, then the application claims. `clockToleranceSeconds` defaults to 30.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createWorkspaceControlVerifier({ jwksUri, clockToleranceSeconds, verifier, }: {
|
|
27
|
+
jwksUri: string;
|
|
28
|
+
clockToleranceSeconds?: number;
|
|
29
|
+
verifier?: Pick<JwtVerifier, "verify">;
|
|
30
|
+
}): {
|
|
31
|
+
verify(token: string): Promise<WorkspaceControlClaims>;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=control-verifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-verifier.d.ts","sourceRoot":"","sources":["../src/control-verifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAItD,+GAA+G;AAC/G,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AACtD,+DAA+D;AAC/D,eAAO,MAAM,0BAA0B,0CACE,CAAC;AAC1C,+DAA+D;AAC/D,eAAO,MAAM,wBAAwB,gBAAgB,CAAC;AAEtD,MAAM,MAAM,2BAA2B,GACnC,SAAS,GACT,SAAS,GACT,OAAO,GACP,QAAQ,CAAC;AAEb,qEAAqE;AACrE,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,MAAM,EAAE,2BAA2B,CAAC;IAE7C,YAAY,MAAM,EAAE,2BAA2B,EAI9C;CACF;AAED,gGAAgG;AAChG,MAAM,MAAM,sBAAsB,GAAG;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAyBF;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,EAC7C,OAAO,EACP,qBAA0B,EAC1B,QAAQ,GACT,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;CACxC,GAAG;IAAE,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAA;CAAE,CA0C7D"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { JwtVerifier } from "@superblocksteam/shared";
|
|
2
|
+
// Defined here, not in control.ts, so that module can re-export this one
|
|
3
|
+
// without a cycle.
|
|
4
|
+
/** Exact `scope` claim required on a workspace control token (`apps:*`, like the other application scopes). */
|
|
5
|
+
export const WORKSPACE_CONTROL_SCOPE = "apps:control";
|
|
6
|
+
/** Exact `aud` claim required on a workspace control token. */
|
|
7
|
+
export const WORKSPACE_CONTROL_AUDIENCE = "https://superblocks-workspace-control";
|
|
8
|
+
/** Exact `iss` claim required on a workspace control token. */
|
|
9
|
+
export const WORKSPACE_CONTROL_ISSUER = "superblocks";
|
|
10
|
+
/** A workspace control token failed verification or claim checks. */
|
|
11
|
+
export class WorkspaceControlError extends Error {
|
|
12
|
+
reason;
|
|
13
|
+
constructor(reason) {
|
|
14
|
+
super(`Workspace control token rejected: ${reason}`);
|
|
15
|
+
this.name = "WorkspaceControlError";
|
|
16
|
+
this.reason = reason;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const isNonEmptyString = (value) => typeof value === "string" && value.length > 0;
|
|
20
|
+
const audienceIsExact = (aud) => {
|
|
21
|
+
if (aud === WORKSPACE_CONTROL_AUDIENCE)
|
|
22
|
+
return true;
|
|
23
|
+
return (Array.isArray(aud) &&
|
|
24
|
+
aud.length === 1 &&
|
|
25
|
+
aud[0] === WORKSPACE_CONTROL_AUDIENCE);
|
|
26
|
+
};
|
|
27
|
+
const isJoseExpired = (error) => {
|
|
28
|
+
const seen = new Set();
|
|
29
|
+
let current = error;
|
|
30
|
+
while (current && typeof current === "object" && !seen.has(current)) {
|
|
31
|
+
seen.add(current);
|
|
32
|
+
if ("code" in current && current.code === "ERR_JWT_EXPIRED")
|
|
33
|
+
return true;
|
|
34
|
+
current = "cause" in current ? current.cause : undefined;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Verifies a workspace control JWT: ES256, the control issuer, audience, and
|
|
40
|
+
* scope, then the application claims. `clockToleranceSeconds` defaults to 30.
|
|
41
|
+
*/
|
|
42
|
+
export function createWorkspaceControlVerifier({ jwksUri, clockToleranceSeconds = 30, verifier, }) {
|
|
43
|
+
const jwtVerifier = verifier ?? new JwtVerifier({ jwksUri });
|
|
44
|
+
return {
|
|
45
|
+
async verify(token) {
|
|
46
|
+
let payload;
|
|
47
|
+
try {
|
|
48
|
+
payload = await jwtVerifier.verify(token, {
|
|
49
|
+
algorithms: ["ES256"],
|
|
50
|
+
issuer: WORKSPACE_CONTROL_ISSUER,
|
|
51
|
+
audience: WORKSPACE_CONTROL_AUDIENCE,
|
|
52
|
+
clockTolerance: clockToleranceSeconds,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
if (isJoseExpired(error))
|
|
57
|
+
throw new WorkspaceControlError("expired");
|
|
58
|
+
throw new WorkspaceControlError("invalid");
|
|
59
|
+
}
|
|
60
|
+
if (payload.scope !== WORKSPACE_CONTROL_SCOPE) {
|
|
61
|
+
throw new WorkspaceControlError("scope");
|
|
62
|
+
}
|
|
63
|
+
if (!audienceIsExact(payload.aud) ||
|
|
64
|
+
!isNonEmptyString(payload.app_id) ||
|
|
65
|
+
!isNonEmptyString(payload.branch) ||
|
|
66
|
+
!isNonEmptyString(payload.org_id) ||
|
|
67
|
+
!isNonEmptyString(payload.sub) ||
|
|
68
|
+
typeof payload.exp !== "number" ||
|
|
69
|
+
!Number.isFinite(payload.exp)) {
|
|
70
|
+
throw new WorkspaceControlError("claims");
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
applicationId: payload.app_id,
|
|
74
|
+
branchName: payload.branch,
|
|
75
|
+
organizationId: payload.org_id,
|
|
76
|
+
subject: payload.sub,
|
|
77
|
+
expiresAt: payload.exp,
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=control-verifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-verifier.js","sourceRoot":"","sources":["../src/control-verifier.ts"],"names":[],"mappings":"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"}
|
package/dist/control.d.ts
CHANGED
|
@@ -14,6 +14,11 @@ 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";
|
|
17
22
|
/** Edge, AI service → edge: the VM's current session endpoint. */
|
|
18
23
|
export declare const WORKSPACE_ENDPOINT_PATH = "/_sb_workspace/endpoint";
|
|
19
24
|
/**
|
|
@@ -21,6 +26,13 @@ export declare const WORKSPACE_ENDPOINT_PATH = "/_sb_workspace/endpoint";
|
|
|
21
26
|
* `Authorization`: SigV4 owns that header on the edge → VM hop.
|
|
22
27
|
*/
|
|
23
28
|
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";
|
|
24
36
|
/**
|
|
25
37
|
* The browser's Host. The edge → VM hop must send the session endpoint's own
|
|
26
38
|
* Host (it is signed), so the edge moves the original here and the VM ingress
|
|
@@ -28,11 +40,16 @@ export declare const WORKSPACE_TOKEN_HEADER = "x-sb-workspace-token";
|
|
|
28
40
|
*/
|
|
29
41
|
export declare const WORKSPACE_ORIGINAL_HOST_HEADER = "x-sb-original-host";
|
|
30
42
|
/**
|
|
31
|
-
* The
|
|
32
|
-
*
|
|
33
|
-
* and the VM ingress restores it before the workspace host checks it.
|
|
43
|
+
* The user the edge authenticated a forwarded request for. The edge drops
|
|
44
|
+
* inbound copies; the VM trusts it because only the edge reaches the ingress.
|
|
34
45
|
*/
|
|
35
|
-
export declare const
|
|
46
|
+
export declare const WORKSPACE_EDGE_AUTHENTICATED_HEADER = "x-sb-edge-authenticated";
|
|
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";
|
|
36
53
|
/** True when `pathname` is a control path that must not be forwarded. */
|
|
37
54
|
export declare function isWorkspaceControlPath(pathname: string): boolean;
|
|
38
55
|
/**
|
|
@@ -73,15 +90,8 @@ export declare function tokensEqual(a: string, b: string): boolean;
|
|
|
73
90
|
export declare function hasWorkspaceToken(headers: Record<string, string | string[] | undefined>, expected: string): boolean;
|
|
74
91
|
export declare const workspaceSyncCredentialSchema: z.ZodObject<{
|
|
75
92
|
token: z.ZodString;
|
|
76
|
-
/** Epoch milliseconds after which the server rejects the token. */
|
|
77
93
|
expiresAt: z.ZodNumber;
|
|
78
|
-
},
|
|
79
|
-
token: string;
|
|
80
|
-
expiresAt: number;
|
|
81
|
-
}, {
|
|
82
|
-
token: string;
|
|
83
|
-
expiresAt: number;
|
|
84
|
-
}>;
|
|
94
|
+
}, z.core.$strip>;
|
|
85
95
|
export type WorkspaceSyncCredential = z.infer<typeof workspaceSyncCredentialSchema>;
|
|
86
96
|
/**
|
|
87
97
|
* Everything the VM needs from the edge, sent whole every time
|
|
@@ -91,44 +101,14 @@ export type WorkspaceSyncCredential = z.infer<typeof workspaceSyncCredentialSche
|
|
|
91
101
|
* its copy; it never merges.
|
|
92
102
|
*/
|
|
93
103
|
export declare const workspaceStateSchema: z.ZodObject<{
|
|
94
|
-
/** The edge holds the branch lock; without it the VM must not commit. */
|
|
95
104
|
lockHeld: z.ZodBoolean;
|
|
96
|
-
/** A user was recently active in the editor (feeds the VM's busy policy). */
|
|
97
105
|
userActive: z.ZodBoolean;
|
|
98
|
-
/** The edge is shutting down; going quiet after this is not a failure. */
|
|
99
106
|
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
|
-
*/
|
|
104
107
|
credential: z.ZodOptional<z.ZodObject<{
|
|
105
108
|
token: z.ZodString;
|
|
106
|
-
/** Epoch milliseconds after which the server rejects the token. */
|
|
107
109
|
expiresAt: z.ZodNumber;
|
|
108
|
-
},
|
|
109
|
-
|
|
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
|
-
}>;
|
|
110
|
+
}, z.core.$strip>>;
|
|
111
|
+
}, z.core.$strip>;
|
|
132
112
|
export type WorkspaceState = z.infer<typeof workspaceStateSchema>;
|
|
133
113
|
/**
|
|
134
114
|
* The VM's answer to a state snapshot. `bootId` is random per VM process, for
|
|
@@ -136,56 +116,51 @@ export type WorkspaceState = z.infer<typeof workspaceStateSchema>;
|
|
|
136
116
|
*/
|
|
137
117
|
export declare const workspaceStatusSchema: z.ZodObject<{
|
|
138
118
|
bootId: z.ZodString;
|
|
139
|
-
devServer: z.ZodEnum<
|
|
140
|
-
|
|
119
|
+
devServer: z.ZodEnum<{
|
|
120
|
+
booting: "booting";
|
|
121
|
+
failed: "failed";
|
|
122
|
+
ready: "ready";
|
|
123
|
+
}>;
|
|
141
124
|
unsynced: z.ZodBoolean;
|
|
142
125
|
dbfsHash: z.ZodOptional<z.ZodString>;
|
|
143
|
-
},
|
|
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
|
-
}>;
|
|
126
|
+
}, z.core.$strip>;
|
|
154
127
|
export type WorkspaceStatus = z.infer<typeof workspaceStatusSchema>;
|
|
155
128
|
/**
|
|
156
129
|
* The response body of `POST` {@link WORKSPACE_COMMIT_PATH}, always with
|
|
157
130
|
* status 200 so the edge reads one shape. `not_ready` means the workspace is
|
|
158
131
|
* not open or has no state snapshot yet; the edge reports it like an error.
|
|
159
132
|
*/
|
|
160
|
-
export declare const workspaceCommitResultSchema: z.ZodDiscriminatedUnion<
|
|
133
|
+
export declare const workspaceCommitResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
161
134
|
outcome: z.ZodLiteral<"committed">;
|
|
162
135
|
dbfsHash: z.ZodOptional<z.ZodString>;
|
|
163
|
-
},
|
|
164
|
-
outcome: "committed";
|
|
165
|
-
dbfsHash?: string | undefined;
|
|
166
|
-
}, {
|
|
167
|
-
outcome: "committed";
|
|
168
|
-
dbfsHash?: string | undefined;
|
|
169
|
-
}>, z.ZodObject<{
|
|
136
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
170
137
|
outcome: z.ZodLiteral<"not_ready">;
|
|
171
138
|
reason: z.ZodString;
|
|
172
|
-
},
|
|
173
|
-
outcome: "not_ready";
|
|
174
|
-
reason: string;
|
|
175
|
-
}, {
|
|
176
|
-
outcome: "not_ready";
|
|
177
|
-
reason: string;
|
|
178
|
-
}>, z.ZodObject<{
|
|
139
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
179
140
|
outcome: z.ZodLiteral<"error">;
|
|
180
141
|
error: z.ZodString;
|
|
181
|
-
},
|
|
182
|
-
outcome: "error";
|
|
183
|
-
error: string;
|
|
184
|
-
}, {
|
|
185
|
-
outcome: "error";
|
|
186
|
-
error: string;
|
|
187
|
-
}>]>;
|
|
142
|
+
}, z.core.$strip>], "outcome">;
|
|
188
143
|
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>;
|
|
189
164
|
/**
|
|
190
165
|
* Where the VM's ingress is reachable and how the edge authenticates to it
|
|
191
166
|
* (`PUT` {@link WORKSPACE_ENDPOINT_PATH}). Each `workspace.open` that returns
|
|
@@ -199,52 +174,20 @@ export type WorkspaceCommitResult = z.infer<typeof workspaceCommitResultSchema>;
|
|
|
199
174
|
* grant before the old one expires.
|
|
200
175
|
* - `none`: a local builder runtime reached directly, for development.
|
|
201
176
|
*/
|
|
202
|
-
export declare const workspaceEndpointSchema: z.ZodDiscriminatedUnion<
|
|
177
|
+
export declare const workspaceEndpointSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
203
178
|
auth: z.ZodLiteral<"sigv4">;
|
|
204
|
-
url: z.
|
|
179
|
+
url: z.ZodString;
|
|
205
180
|
region: z.ZodString;
|
|
206
181
|
sessionKey: z.ZodString;
|
|
207
182
|
signer: z.ZodObject<{
|
|
208
183
|
url: z.ZodString;
|
|
209
184
|
grant: z.ZodString;
|
|
210
|
-
},
|
|
211
|
-
|
|
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<{
|
|
185
|
+
}, z.core.$strip>;
|
|
186
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
236
187
|
auth: z.ZodLiteral<"none">;
|
|
237
|
-
url: z.
|
|
188
|
+
url: z.ZodString;
|
|
238
189
|
sessionKey: z.ZodString;
|
|
239
|
-
},
|
|
240
|
-
auth: "none";
|
|
241
|
-
url: string;
|
|
242
|
-
sessionKey: string;
|
|
243
|
-
}, {
|
|
244
|
-
auth: "none";
|
|
245
|
-
url: string;
|
|
246
|
-
sessionKey: string;
|
|
247
|
-
}>]>;
|
|
190
|
+
}, z.core.$strip>], "auth">;
|
|
248
191
|
export type WorkspaceEndpoint = z.infer<typeof workspaceEndpointSchema>;
|
|
249
192
|
/**
|
|
250
193
|
* The server is the only caller of the AgentCore builder runtime. The AI
|
|
@@ -263,7 +206,16 @@ export declare const BUILDER_RUNTIME_INVOCATIONS_PATH = "/api/v1/ai/builder-runt
|
|
|
263
206
|
* a session it derived, so the pod cannot name any other.
|
|
264
207
|
*/
|
|
265
208
|
export declare const BUILDER_RUNTIME_SESSION_HEADER = "x-sb-builder-runtime-session";
|
|
266
|
-
export declare const builderRuntimeSessionSchema: z.ZodEnum<
|
|
209
|
+
export declare const builderRuntimeSessionSchema: z.ZodEnum<{
|
|
210
|
+
chat: "chat";
|
|
211
|
+
workspace: "workspace";
|
|
212
|
+
}>;
|
|
213
|
+
/**
|
|
214
|
+
* On a `turn.attach` request: the prompt id of the turn it resumes, which names
|
|
215
|
+
* the turn's run. A header, not a payload field, so a runtime that predates it
|
|
216
|
+
* still accepts the payload; the server alone reads it.
|
|
217
|
+
*/
|
|
218
|
+
export declare const BUILDER_RUNTIME_PROMPT_HEADER = "x-sb-builder-runtime-prompt";
|
|
267
219
|
export type BuilderRuntimeSession = z.infer<typeof builderRuntimeSessionSchema>;
|
|
268
220
|
/**
|
|
269
221
|
* Signs one request to a session endpoint (`POST`, body
|
|
@@ -285,24 +237,14 @@ export declare const BUILDER_RUNTIME_ENDPOINT_HEADER = "x-sb-workspace-endpoint"
|
|
|
285
237
|
/** On a `workspace.open` response: the sign grant for that endpoint. */
|
|
286
238
|
export declare const BUILDER_RUNTIME_SIGN_GRANT_HEADER = "x-sb-workspace-sign-grant";
|
|
287
239
|
export declare const builderRuntimeEndpointHeaderSchema: z.ZodObject<{
|
|
288
|
-
url: z.
|
|
240
|
+
url: z.ZodString;
|
|
289
241
|
region: z.ZodString;
|
|
290
|
-
},
|
|
291
|
-
url: string;
|
|
292
|
-
region: string;
|
|
293
|
-
}, {
|
|
294
|
-
url: string;
|
|
295
|
-
region: string;
|
|
296
|
-
}>;
|
|
242
|
+
}, z.core.$strip>;
|
|
297
243
|
export type BuilderRuntimeEndpointHeader = z.infer<typeof builderRuntimeEndpointHeaderSchema>;
|
|
298
244
|
/** A sign grant, as sent to and returned by the renew route. */
|
|
299
245
|
export declare const builderRuntimeSignGrantSchema: z.ZodObject<{
|
|
300
246
|
grant: z.ZodString;
|
|
301
|
-
},
|
|
302
|
-
grant: string;
|
|
303
|
-
}, {
|
|
304
|
-
grant: string;
|
|
305
|
-
}>;
|
|
247
|
+
}, z.core.$strip>;
|
|
306
248
|
/**
|
|
307
249
|
* One request the edge wants signed. `headers` are the lowercased headers the
|
|
308
250
|
* signer covers (`host` and `x-amz-*`); the body is never sent because the
|
|
@@ -311,27 +253,23 @@ export declare const builderRuntimeSignGrantSchema: z.ZodObject<{
|
|
|
311
253
|
* that check.
|
|
312
254
|
*/
|
|
313
255
|
export declare const workspaceSignRequestSchema: z.ZodObject<{
|
|
314
|
-
method: z.ZodEnum<
|
|
256
|
+
method: z.ZodEnum<{
|
|
257
|
+
DELETE: "DELETE";
|
|
258
|
+
GET: "GET";
|
|
259
|
+
HEAD: "HEAD";
|
|
260
|
+
OPTIONS: "OPTIONS";
|
|
261
|
+
PATCH: "PATCH";
|
|
262
|
+
POST: "POST";
|
|
263
|
+
PUT: "PUT";
|
|
264
|
+
}>;
|
|
315
265
|
url: z.ZodString;
|
|
316
266
|
headers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
317
|
-
},
|
|
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
|
-
}>;
|
|
267
|
+
}, z.core.$strip>;
|
|
326
268
|
export type WorkspaceSignRequest = z.infer<typeof workspaceSignRequestSchema>;
|
|
327
269
|
/** The signed header set: the request's headers plus the SigV4 headers. */
|
|
328
270
|
export declare const workspaceSignResponseSchema: z.ZodObject<{
|
|
329
271
|
headers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
330
|
-
},
|
|
331
|
-
headers: Record<string, string>;
|
|
332
|
-
}, {
|
|
333
|
-
headers: Record<string, string>;
|
|
334
|
-
}>;
|
|
272
|
+
}, z.core.$strip>;
|
|
335
273
|
export type WorkspaceSignResponse = z.infer<typeof workspaceSignResponseSchema>;
|
|
336
274
|
/**
|
|
337
275
|
* The audience of the statement the server signs for each invocation. The VM
|
|
@@ -344,25 +282,13 @@ export declare const BUILDER_RUNTIME_INVOCATION_AUDIENCE = "https://superblocks-
|
|
|
344
282
|
export declare const builderRuntimeInvocationEnvelopeSchema: z.ZodObject<{
|
|
345
283
|
authorization: z.ZodString;
|
|
346
284
|
payload: z.ZodString;
|
|
347
|
-
},
|
|
348
|
-
authorization: string;
|
|
349
|
-
payload: string;
|
|
350
|
-
}, {
|
|
351
|
-
authorization: string;
|
|
352
|
-
payload: string;
|
|
353
|
-
}>;
|
|
285
|
+
}, z.core.$strict>;
|
|
354
286
|
export type BuilderRuntimeInvocationEnvelope = z.infer<typeof builderRuntimeInvocationEnvelopeSchema>;
|
|
355
287
|
/** The statement's own claims, beside the standard `iss`, `aud` and `exp`. */
|
|
356
288
|
export declare const builderRuntimeInvocationClaimsSchema: z.ZodObject<{
|
|
357
289
|
rsid: z.ZodString;
|
|
358
290
|
payload_sha256: z.ZodString;
|
|
359
|
-
},
|
|
360
|
-
rsid: string;
|
|
361
|
-
payload_sha256: string;
|
|
362
|
-
}, {
|
|
363
|
-
rsid: string;
|
|
364
|
-
payload_sha256: string;
|
|
365
|
-
}>;
|
|
291
|
+
}, z.core.$strip>;
|
|
366
292
|
/** The hex SHA-256 of an invocation payload, as the statement names it. */
|
|
367
293
|
export declare function invocationPayloadDigest(payload: string): string;
|
|
368
294
|
/**
|
|
@@ -378,6 +304,13 @@ export declare function invocationPayloadDigest(payload: string): string;
|
|
|
378
304
|
* until the workspace is reopened).
|
|
379
305
|
* - `closed`: the edge is shutting down.
|
|
380
306
|
*/
|
|
381
|
-
export declare const workspaceIngressStateSchema: z.ZodEnum<
|
|
307
|
+
export declare const workspaceIngressStateSchema: z.ZodEnum<{
|
|
308
|
+
closed: "closed";
|
|
309
|
+
reachable: "reachable";
|
|
310
|
+
unreachable: "unreachable";
|
|
311
|
+
waiting: "waiting";
|
|
312
|
+
}>;
|
|
382
313
|
export type WorkspaceIngressState = z.infer<typeof workspaceIngressStateSchema>;
|
|
314
|
+
export { createWorkspaceControlVerifier, WORKSPACE_CONTROL_AUDIENCE, WORKSPACE_CONTROL_ISSUER, WORKSPACE_CONTROL_SCOPE, WorkspaceControlError, } from "./control-verifier.js";
|
|
315
|
+
export type { WorkspaceControlClaims, WorkspaceControlErrorReason, } from "./control-verifier.js";
|
|
383
316
|
//# sourceMappingURL=control.d.ts.map
|