@giselles-ai/sandkit 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +163 -0
  3. package/dist/adapters/drizzle.d.ts +83 -0
  4. package/dist/adapters/drizzle.js +9 -0
  5. package/dist/adapters/drizzle.js.map +1 -0
  6. package/dist/adapters/memory.d.ts +6 -0
  7. package/dist/adapters/memory.js +8 -0
  8. package/dist/adapters/memory.js.map +1 -0
  9. package/dist/adapters/sqlite-bun.d.ts +7 -0
  10. package/dist/adapters/sqlite-bun.js +8 -0
  11. package/dist/adapters/sqlite-bun.js.map +1 -0
  12. package/dist/bin.js +697 -0
  13. package/dist/bin.js.map +1 -0
  14. package/dist/chunk-7DLK7LOM.js +44 -0
  15. package/dist/chunk-7DLK7LOM.js.map +1 -0
  16. package/dist/chunk-BDPTYR6V.js +407 -0
  17. package/dist/chunk-BDPTYR6V.js.map +1 -0
  18. package/dist/chunk-CSOBTLWV.js +202 -0
  19. package/dist/chunk-CSOBTLWV.js.map +1 -0
  20. package/dist/chunk-DLGUA3H7.js +9 -0
  21. package/dist/chunk-DLGUA3H7.js.map +1 -0
  22. package/dist/chunk-FSDVHEEX.js +45 -0
  23. package/dist/chunk-FSDVHEEX.js.map +1 -0
  24. package/dist/chunk-HVYCAAZQ.js +25 -0
  25. package/dist/chunk-HVYCAAZQ.js.map +1 -0
  26. package/dist/chunk-LC3IYBAL.js +100 -0
  27. package/dist/chunk-LC3IYBAL.js.map +1 -0
  28. package/dist/chunk-REGOUXVI.js +58 -0
  29. package/dist/chunk-REGOUXVI.js.map +1 -0
  30. package/dist/chunk-RMMOQD5Y.js +211 -0
  31. package/dist/chunk-RMMOQD5Y.js.map +1 -0
  32. package/dist/chunk-UDFWES6J.js +486 -0
  33. package/dist/chunk-UDFWES6J.js.map +1 -0
  34. package/dist/chunk-VISDS5T7.js +202 -0
  35. package/dist/chunk-VISDS5T7.js.map +1 -0
  36. package/dist/chunk-XM4HGRXW.js +37 -0
  37. package/dist/chunk-XM4HGRXW.js.map +1 -0
  38. package/dist/cli/index.d.ts +19 -0
  39. package/dist/cli/index.js +397 -0
  40. package/dist/cli/index.js.map +1 -0
  41. package/dist/index.d.ts +78 -0
  42. package/dist/index.js +1102 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/integrations/mock.d.ts +19 -0
  45. package/dist/integrations/mock.js +207 -0
  46. package/dist/integrations/mock.js.map +1 -0
  47. package/dist/integrations/vercel.d.ts +7 -0
  48. package/dist/integrations/vercel.js +400 -0
  49. package/dist/integrations/vercel.js.map +1 -0
  50. package/dist/policies/ai-gateway.d.ts +15 -0
  51. package/dist/policies/ai-gateway.js +12 -0
  52. package/dist/policies/ai-gateway.js.map +1 -0
  53. package/dist/policies/codex.d.ts +10 -0
  54. package/dist/policies/codex.js +12 -0
  55. package/dist/policies/codex.js.map +1 -0
  56. package/dist/policies/gemini.d.ts +10 -0
  57. package/dist/policies/gemini.js +12 -0
  58. package/dist/policies/gemini.js.map +1 -0
  59. package/dist/schema/index.d.ts +60 -0
  60. package/dist/schema/index.js +31 -0
  61. package/dist/schema/index.js.map +1 -0
  62. package/dist/types-BCgprbo8.d.ts +47 -0
  63. package/dist/types-BEKQnjeb.d.ts +139 -0
  64. package/dist/types-Cy36bS1j.d.ts +138 -0
  65. package/package.json +126 -0
@@ -0,0 +1,47 @@
1
+ interface PolicyServiceDescriptor {
2
+ readonly id: string;
3
+ readonly name: string;
4
+ readonly description?: string;
5
+ readonly domains: readonly string[];
6
+ readonly headers?: readonly PolicyServiceHeaderTransform[];
7
+ }
8
+ interface PolicyServiceCredentialDefault {
9
+ readonly kind: "default";
10
+ }
11
+ interface PolicyServiceCredentialFromValue {
12
+ readonly kind: "value";
13
+ readonly value: string;
14
+ }
15
+ interface PolicyServiceCredentialRedacted {
16
+ readonly kind: "redacted";
17
+ }
18
+ type PolicyServiceCredentialSource = PolicyServiceCredentialDefault | PolicyServiceCredentialFromValue | PolicyServiceCredentialRedacted;
19
+ interface PolicyServiceHeaderTransform {
20
+ readonly headerName: string;
21
+ readonly valuePrefix?: string;
22
+ readonly credential: PolicyServiceCredentialSource;
23
+ }
24
+ interface WorkspaceAllowAllPolicy {
25
+ readonly mode: "allow-all";
26
+ }
27
+ interface WorkspaceDenyAllPolicy {
28
+ readonly mode: "deny-all";
29
+ }
30
+ interface WorkspaceUserDefinedPolicy {
31
+ readonly mode: "allow-services";
32
+ readonly services: readonly PolicyServiceDescriptor[];
33
+ }
34
+ /**
35
+ * Durable workspace firewall policy.
36
+ *
37
+ * Sandkit models the same three policy shapes exposed by Vercel Sandbox firewall:
38
+ * - allow-all
39
+ * - deny-all
40
+ * - user-defined
41
+ *
42
+ * User-defined policies are currently expressed as allowed service descriptors.
43
+ * Reference: https://vercel.com/docs/vercel-sandbox/concepts/firewall
44
+ */
45
+ type WorkspacePolicy = WorkspaceAllowAllPolicy | WorkspaceDenyAllPolicy | WorkspaceUserDefinedPolicy;
46
+
47
+ export type { PolicyServiceDescriptor as P, WorkspacePolicy as W, PolicyServiceCredentialSource as a };
@@ -0,0 +1,139 @@
1
+ import { a as SandkitAdapter, S as SharedSetup, W as WorkspaceRecord, b as WorkspaceMetadata, c as WorkspaceStatus } from './types-Cy36bS1j.js';
2
+ import { W as WorkspacePolicy } from './types-BCgprbo8.js';
3
+
4
+ type JsonPrimitive = boolean | number | string | null;
5
+ type JsonValue = JsonPrimitive | JsonValue[] | {
6
+ [key: string]: JsonValue;
7
+ };
8
+
9
+ interface WorkspaceCreateOptions {
10
+ id?: string;
11
+ name?: string;
12
+ metadata?: WorkspaceMetadata;
13
+ policy?: WorkspacePolicy;
14
+ sandbox?: {
15
+ /**
16
+ * Durable workspace default for provider port publication. This affects
17
+ * create/restore behavior for live session/public URL flows, not the
18
+ * durable runCommand() unit-of-work model itself.
19
+ */
20
+ readonly exposedPorts?: readonly number[];
21
+ };
22
+ status?: WorkspaceStatus;
23
+ sandboxId?: string;
24
+ lastResumedAt?: string;
25
+ }
26
+ interface CommandResult {
27
+ exitCode: number;
28
+ stderr: string;
29
+ stdout: string;
30
+ }
31
+ interface SandboxSessionLease {
32
+ readonly sandboxId: string;
33
+ readonly observedAt: string;
34
+ readonly expiresAt: string;
35
+ }
36
+ interface WorkspaceSandboxLease {
37
+ readonly sandboxId: string;
38
+ readonly observedAt: string;
39
+ readonly expiresAt: string;
40
+ readonly remainingMs: number;
41
+ }
42
+ interface WorkspaceSessionProcess {
43
+ readonly processId: string;
44
+ wait(): Promise<CommandResult>;
45
+ /**
46
+ * Accesses the same normalized log stream used by onStdout/onStderr callbacks.
47
+ * Sandkit keeps a single internal stream, so callbacks and logs() observe
48
+ * the same sequence and buffered historical chunks are replayed to new readers.
49
+ */
50
+ logs?: () => AsyncIterable<WorkspaceSessionLog>;
51
+ }
52
+ interface WorkspaceSessionLog {
53
+ readonly stream: "stdout" | "stderr";
54
+ readonly chunk: string;
55
+ }
56
+ interface WorkspaceSessionProcessStartInput {
57
+ readonly command: string;
58
+ readonly args: readonly string[];
59
+ /**
60
+ * Optional per-call policy override for this session process.
61
+ */
62
+ readonly policy?: WorkspacePolicy;
63
+ /**
64
+ * Callbacks consume chunks from Sandkit's normalized process log stream.
65
+ */
66
+ readonly onStdout?: ((chunk: string) => void) | undefined;
67
+ /**
68
+ * Callbacks consume chunks from Sandkit's normalized process log stream.
69
+ */
70
+ readonly onStderr?: ((chunk: string) => void) | undefined;
71
+ }
72
+ interface SandboxRunCommandOptions {
73
+ readonly command: string;
74
+ readonly args?: readonly string[];
75
+ readonly policy?: WorkspacePolicy;
76
+ }
77
+ interface PersistedSandboxState {
78
+ readonly kind: string;
79
+ readonly sessionId: string;
80
+ readonly state?: JsonValue;
81
+ }
82
+ interface SandboxDriver {
83
+ readonly id: string;
84
+ readonly provider: string;
85
+ applyPolicy(policy: WorkspacePolicy): Promise<void>;
86
+ /**
87
+ * Returns lease timing observed from the current sandbox instance.
88
+ * Some providers expose this as an interpreted timeout value.
89
+ * Sandkit persists lease updates only from explicit session open/extend paths,
90
+ * so callers should not treat mere reads as lease refreshes.
91
+ */
92
+ getSessionLease(): Promise<SandboxSessionLease>;
93
+ runCommand(command: string, args: string[]): Promise<CommandResult>;
94
+ startProcess?(input: WorkspaceSessionProcessStartInput): Promise<WorkspaceSessionProcess>;
95
+ /** Persists and restores durability state through commit() and attach/restore APIs. */
96
+ snapshot(): Promise<PersistedSandboxState>;
97
+ url?(port: number): Promise<string>;
98
+ extendTimeout?(durationMs: number): Promise<void>;
99
+ }
100
+ interface SandboxCreateOptions {
101
+ readonly policy: WorkspacePolicy;
102
+ readonly exposedPorts?: readonly number[];
103
+ readonly timeoutMs?: number;
104
+ }
105
+ interface SandboxDriverFactory {
106
+ createSandbox(workspace: WorkspaceRecord, options: SandboxCreateOptions): Promise<SandboxDriver>;
107
+ resumeSandbox(workspace: WorkspaceRecord, snapshot: PersistedSandboxState, options: SandboxCreateOptions): Promise<SandboxDriver>;
108
+ isSessionUnavailableError?(error: unknown): boolean;
109
+ }
110
+ interface VercelSandboxOptions {
111
+ runtime?: string;
112
+ /**
113
+ * Provider default sandbox lease timeout in milliseconds. Sandkit uses this
114
+ * when creating or restoring a sandbox unless openSession({ timeoutMs })
115
+ * supplies a live-session override.
116
+ */
117
+ defaultTimeout?: number;
118
+ /**
119
+ * Legacy alias retained for compatibility with existing call sites.
120
+ * Prefer defaultTimeout for new code.
121
+ */
122
+ timeout?: number;
123
+ }
124
+ declare const sandboxProviderContract: unique symbol;
125
+ type SandboxProviderRecord = {
126
+ readonly provider: string;
127
+ readonly driverFactory: SandboxDriverFactory;
128
+ };
129
+ interface SandkitSandboxProvider {
130
+ readonly [sandboxProviderContract]: SandboxProviderRecord;
131
+ }
132
+ interface SandkitOptions {
133
+ readonly database?: SandkitAdapter | undefined;
134
+ readonly setup?: SharedSetup | undefined;
135
+ readonly network?: readonly unknown[] | undefined;
136
+ readonly sandbox: SandkitSandboxProvider;
137
+ }
138
+
139
+ export type { CommandResult as C, PersistedSandboxState as P, SandkitOptions as S, VercelSandboxOptions as V, WorkspaceSessionProcess as W, SandboxDriverFactory as a, SandboxRunCommandOptions as b, WorkspaceSessionProcessStartInput as c, WorkspaceSandboxLease as d, WorkspaceCreateOptions as e, SandboxCreateOptions as f, SandboxDriver as g, SandkitSandboxProvider as h };
@@ -0,0 +1,138 @@
1
+ import { W as WorkspacePolicy } from './types-BCgprbo8.js';
2
+
3
+ type WorkspaceStatus = "active" | "inactive" | "archived";
4
+ type RunStatus = "started" | "succeeded" | "failed";
5
+ interface WorkspaceMetadata {
6
+ [key: string]: unknown;
7
+ }
8
+ type SharedSetupStateValue = null | boolean | number | string | SharedSetupStateValue[] | {
9
+ [key: string]: SharedSetupStateValue;
10
+ };
11
+ interface SharedSetup {
12
+ readonly command: string;
13
+ readonly args?: readonly string[];
14
+ /**
15
+ * Shared setup state is durable and reused across workspaces, so this policy
16
+ * must also be durable. Explicit secret-bearing policies are rejected.
17
+ */
18
+ readonly policy?: WorkspacePolicy;
19
+ }
20
+ /**
21
+ * Internal durable artifact produced by a successful shared bootstrap.
22
+ */
23
+ interface SharedSetupState {
24
+ readonly kind: string;
25
+ readonly sessionId: string;
26
+ readonly state?: SharedSetupStateValue;
27
+ }
28
+ interface WorkspaceRecord {
29
+ id: string;
30
+ name?: string;
31
+ metadata?: WorkspaceMetadata;
32
+ status: WorkspaceStatus;
33
+ sandboxId?: string;
34
+ lastResumedAt?: string;
35
+ createdAt: string;
36
+ updatedAt: string;
37
+ }
38
+ interface WorkspaceCreateInput {
39
+ id?: string;
40
+ name?: string;
41
+ metadata?: WorkspaceMetadata;
42
+ policy?: WorkspacePolicy;
43
+ status?: WorkspaceStatus;
44
+ sandboxId?: string;
45
+ lastResumedAt?: string;
46
+ }
47
+ interface WorkspaceUpdateInput {
48
+ name?: string;
49
+ metadata?: WorkspaceMetadata;
50
+ status?: WorkspaceStatus;
51
+ sandboxId?: string | null;
52
+ lastResumedAt?: string | null;
53
+ }
54
+ interface SetupStateRecord {
55
+ readonly id: string;
56
+ readonly state: SharedSetupState;
57
+ readonly createdAt: string;
58
+ readonly updatedAt: string;
59
+ }
60
+ interface SetupStatePutInput {
61
+ readonly id: string;
62
+ readonly state: SharedSetupState;
63
+ }
64
+ interface SetupStateAdapter {
65
+ getSetupState(id: string): Promise<SetupStateRecord | null>;
66
+ putSetupState(input: SetupStatePutInput): Promise<SetupStateRecord>;
67
+ deleteSetupState(id: string): Promise<void>;
68
+ }
69
+ interface WorkspaceAdapter {
70
+ createWorkspace(input?: WorkspaceCreateInput): Promise<WorkspaceRecord>;
71
+ getWorkspace(id: string): Promise<WorkspaceRecord | null>;
72
+ updateWorkspace(id: string, input: WorkspaceUpdateInput): Promise<WorkspaceRecord>;
73
+ }
74
+ interface RunRecord {
75
+ readonly id: string;
76
+ readonly workspaceId: string;
77
+ readonly provider: string;
78
+ readonly executionTargetId: string;
79
+ readonly command: string;
80
+ readonly args?: readonly string[];
81
+ readonly status: RunStatus;
82
+ readonly exitCode?: number;
83
+ readonly stdout?: string;
84
+ readonly stderr?: string;
85
+ readonly startedAt: string;
86
+ readonly finishedAt?: string;
87
+ readonly policySnapshotId?: string;
88
+ readonly providerCommit?: unknown;
89
+ }
90
+ interface RunCreateInput {
91
+ id?: string;
92
+ workspaceId: string;
93
+ provider: string;
94
+ executionTargetId: string;
95
+ command: string;
96
+ args?: readonly string[] | null;
97
+ status?: RunStatus;
98
+ startedAt?: string;
99
+ policySnapshotId?: string | null;
100
+ }
101
+ interface RunFinishInput {
102
+ status: RunStatus;
103
+ finishedAt: string;
104
+ exitCode?: number | null;
105
+ stdout?: string | null;
106
+ stderr?: string | null;
107
+ providerCommit?: unknown;
108
+ }
109
+ interface PolicySnapshotRecord {
110
+ readonly id: string;
111
+ readonly workspaceId: string;
112
+ readonly policyId: string;
113
+ readonly config: unknown;
114
+ readonly createdAt: string;
115
+ }
116
+ interface PolicySnapshotCreateInput {
117
+ id?: string;
118
+ workspaceId: string;
119
+ policyId: string;
120
+ config: unknown;
121
+ createdAt?: string;
122
+ }
123
+ interface RunAdapter {
124
+ createRun(input: RunCreateInput): Promise<RunRecord>;
125
+ finishRun(id: string, input: RunFinishInput): Promise<RunRecord>;
126
+ }
127
+ interface PolicySnapshotAdapter {
128
+ createPolicySnapshot(input: PolicySnapshotCreateInput): Promise<PolicySnapshotRecord>;
129
+ }
130
+ interface SandkitAdapter {
131
+ readonly id: string;
132
+ readonly workspaces: WorkspaceAdapter;
133
+ readonly setupStates: SetupStateAdapter;
134
+ readonly runs: RunAdapter;
135
+ readonly policySnapshots: PolicySnapshotAdapter;
136
+ }
137
+
138
+ export type { SharedSetup as S, WorkspaceRecord as W, SandkitAdapter as a, WorkspaceMetadata as b, WorkspaceStatus as c };
package/package.json ADDED
@@ -0,0 +1,126 @@
1
+ {
2
+ "name": "@giselles-ai/sandkit",
3
+ "version": "0.1.0",
4
+ "description": "Workspace state, session management, and durable command execution for Vercel Sandbox.",
5
+ "keywords": [
6
+ "agent",
7
+ "drizzle",
8
+ "durable-execution",
9
+ "resumable-workflows",
10
+ "sandbox",
11
+ "sandbox-orchestration",
12
+ "session-management",
13
+ "state-management",
14
+ "stateful-sandbox",
15
+ "typescript",
16
+ "vercel",
17
+ "vercel-sandbox",
18
+ "workflow",
19
+ "workspace"
20
+ ],
21
+ "homepage": "https://github.com/giselles-ai/sandkit",
22
+ "bugs": {
23
+ "url": "https://github.com/giselles-ai/sandkit/issues"
24
+ },
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/giselles-ai/sandkit.git"
29
+ },
30
+ "bin": {
31
+ "sandkit": "./dist/bin.js"
32
+ },
33
+ "files": [
34
+ "dist",
35
+ "README.md"
36
+ ],
37
+ "type": "module",
38
+ "main": "./dist/index.js",
39
+ "module": "./dist/index.js",
40
+ "types": "./dist/index.d.ts",
41
+ "exports": {
42
+ "./package.json": "./package.json",
43
+ ".": {
44
+ "types": "./dist/index.d.ts",
45
+ "import": "./dist/index.js",
46
+ "default": "./dist/index.js"
47
+ },
48
+ "./adapters/drizzle": {
49
+ "types": "./dist/adapters/drizzle.d.ts",
50
+ "import": "./dist/adapters/drizzle.js",
51
+ "default": "./dist/adapters/drizzle.js"
52
+ },
53
+ "./adapters/memory": {
54
+ "types": "./dist/adapters/memory.d.ts",
55
+ "import": "./dist/adapters/memory.js",
56
+ "default": "./dist/adapters/memory.js"
57
+ },
58
+ "./adapters/sqlite-bun": {
59
+ "types": "./dist/adapters/sqlite-bun.d.ts",
60
+ "import": "./dist/adapters/sqlite-bun.js",
61
+ "default": "./dist/adapters/sqlite-bun.js"
62
+ },
63
+ "./policies/ai-gateway": {
64
+ "types": "./dist/policies/ai-gateway.d.ts",
65
+ "import": "./dist/policies/ai-gateway.js",
66
+ "default": "./dist/policies/ai-gateway.js"
67
+ },
68
+ "./policies/codex": {
69
+ "types": "./dist/policies/codex.d.ts",
70
+ "import": "./dist/policies/codex.js",
71
+ "default": "./dist/policies/codex.js"
72
+ },
73
+ "./policies/gemini": {
74
+ "types": "./dist/policies/gemini.d.ts",
75
+ "import": "./dist/policies/gemini.js",
76
+ "default": "./dist/policies/gemini.js"
77
+ },
78
+ "./schema": {
79
+ "types": "./dist/schema/index.d.ts",
80
+ "import": "./dist/schema/index.js",
81
+ "default": "./dist/schema/index.js"
82
+ },
83
+ "./integrations/vercel": {
84
+ "types": "./dist/integrations/vercel.d.ts",
85
+ "import": "./dist/integrations/vercel.js",
86
+ "default": "./dist/integrations/vercel.js"
87
+ },
88
+ "./integrations/mock": {
89
+ "types": "./dist/integrations/mock.d.ts",
90
+ "import": "./dist/integrations/mock.js",
91
+ "default": "./dist/integrations/mock.js"
92
+ },
93
+ "./cli": {
94
+ "types": "./dist/cli/index.d.ts",
95
+ "import": "./dist/cli/index.js",
96
+ "default": "./dist/cli/index.js"
97
+ }
98
+ },
99
+ "scripts": {
100
+ "lint": "oxlint src tsup.config.ts",
101
+ "lint:fix": "oxlint src tsup.config.ts --fix",
102
+ "fmt": "oxfmt src tsup.config.ts",
103
+ "fmt:check": "oxfmt --check src tsup.config.ts",
104
+ "build": "bun run clean && tsup",
105
+ "clean": "del-cli dist *.tsbuildinfo",
106
+ "prepack": "bun run build"
107
+ },
108
+ "dependencies": {
109
+ "@vercel/sandbox": "1.8.1"
110
+ },
111
+ "devDependencies": {
112
+ "@types/bun": "1.3.11",
113
+ "del-cli": "7.0.0",
114
+ "drizzle-orm": "0.45.1",
115
+ "tsup": "8.5.1",
116
+ "typescript": "5.9.3"
117
+ },
118
+ "peerDependencies": {
119
+ "drizzle-orm": "^0.44.2"
120
+ },
121
+ "peerDependenciesMeta": {
122
+ "drizzle-orm": {
123
+ "optional": true
124
+ }
125
+ }
126
+ }