@hasna/sandboxes 0.1.23 → 0.1.25

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 (85) hide show
  1. package/LICENSE +5 -15
  2. package/README.md +11 -0
  3. package/dist/cli/index.d.ts +0 -1
  4. package/dist/cli/index.js +3690 -2940
  5. package/dist/db/agents.d.ts +0 -1
  6. package/dist/db/database.d.ts +1 -2
  7. package/dist/db/events.d.ts +0 -1
  8. package/dist/db/pg-migrations.d.ts +0 -1
  9. package/dist/db/projects.d.ts +0 -1
  10. package/dist/db/sandboxes.d.ts +0 -1
  11. package/dist/db/sessions.d.ts +0 -1
  12. package/dist/db/snapshots.d.ts +0 -1
  13. package/dist/db/templates.d.ts +0 -1
  14. package/dist/db/webhooks.d.ts +0 -1
  15. package/dist/index.d.ts +2 -1
  16. package/dist/index.js +4197 -3171
  17. package/dist/lib/agent-runner.d.ts +0 -1
  18. package/dist/lib/agents/claude.d.ts +0 -1
  19. package/dist/lib/agents/codex.d.ts +0 -1
  20. package/dist/lib/agents/gemini.d.ts +0 -1
  21. package/dist/lib/agents/index.d.ts +0 -1
  22. package/dist/lib/agents/opencode.d.ts +0 -1
  23. package/dist/lib/agents/pi.d.ts +0 -1
  24. package/dist/lib/agents/takumi.d.ts +9 -0
  25. package/dist/lib/agents/types.d.ts +0 -1
  26. package/dist/lib/archive.d.ts +31 -0
  27. package/dist/lib/config.d.ts +0 -1
  28. package/dist/lib/images.d.ts +0 -1
  29. package/dist/lib/keepalive.d.ts +0 -1
  30. package/dist/lib/runtime-state.d.ts +0 -1
  31. package/dist/lib/secrets.d.ts +26 -0
  32. package/dist/lib/stream.d.ts +0 -1
  33. package/dist/lib/version.d.ts +0 -1
  34. package/dist/lib/webhook.d.ts +0 -1
  35. package/dist/mcp/http.d.ts +14 -0
  36. package/dist/mcp/index.d.ts +0 -1
  37. package/dist/mcp/index.js +10620 -9017
  38. package/dist/mcp/server.d.ts +3 -0
  39. package/dist/providers/daytona.d.ts +2 -2
  40. package/dist/providers/e2b.d.ts +2 -2
  41. package/dist/providers/index.d.ts +0 -1
  42. package/dist/providers/modal.d.ts +2 -2
  43. package/dist/providers/types.d.ts +3 -2
  44. package/dist/sdk.d.ts +65 -0
  45. package/dist/server/index.d.ts +0 -1
  46. package/dist/server/index.js +30357 -7575
  47. package/dist/server/serve.d.ts +0 -1
  48. package/dist/types/index.d.ts +9 -2
  49. package/package.json +1 -1
  50. package/dist/cli/index.d.ts.map +0 -1
  51. package/dist/db/agents.d.ts.map +0 -1
  52. package/dist/db/database.d.ts.map +0 -1
  53. package/dist/db/events.d.ts.map +0 -1
  54. package/dist/db/pg-migrations.d.ts.map +0 -1
  55. package/dist/db/projects.d.ts.map +0 -1
  56. package/dist/db/sandboxes.d.ts.map +0 -1
  57. package/dist/db/sessions.d.ts.map +0 -1
  58. package/dist/db/snapshots.d.ts.map +0 -1
  59. package/dist/db/templates.d.ts.map +0 -1
  60. package/dist/db/webhooks.d.ts.map +0 -1
  61. package/dist/index.d.ts.map +0 -1
  62. package/dist/lib/agent-runner.d.ts.map +0 -1
  63. package/dist/lib/agents/claude.d.ts.map +0 -1
  64. package/dist/lib/agents/codex.d.ts.map +0 -1
  65. package/dist/lib/agents/gemini.d.ts.map +0 -1
  66. package/dist/lib/agents/index.d.ts.map +0 -1
  67. package/dist/lib/agents/opencode.d.ts.map +0 -1
  68. package/dist/lib/agents/pi.d.ts.map +0 -1
  69. package/dist/lib/agents/types.d.ts.map +0 -1
  70. package/dist/lib/config.d.ts.map +0 -1
  71. package/dist/lib/images.d.ts.map +0 -1
  72. package/dist/lib/keepalive.d.ts.map +0 -1
  73. package/dist/lib/runtime-state.d.ts.map +0 -1
  74. package/dist/lib/stream.d.ts.map +0 -1
  75. package/dist/lib/version.d.ts.map +0 -1
  76. package/dist/lib/webhook.d.ts.map +0 -1
  77. package/dist/mcp/index.d.ts.map +0 -1
  78. package/dist/providers/daytona.d.ts.map +0 -1
  79. package/dist/providers/e2b.d.ts.map +0 -1
  80. package/dist/providers/index.d.ts.map +0 -1
  81. package/dist/providers/modal.d.ts.map +0 -1
  82. package/dist/providers/types.d.ts.map +0 -1
  83. package/dist/server/index.d.ts.map +0 -1
  84. package/dist/server/serve.d.ts.map +0 -1
  85. package/dist/types/index.d.ts.map +0 -1
@@ -12,4 +12,3 @@ export interface RunAgentOpts {
12
12
  }
13
13
  export declare function runAgent(sandboxId: string, opts: RunAgentOpts): Promise<SandboxSession>;
14
14
  export declare function stopAgent(sandboxId: string): Promise<void>;
15
- //# sourceMappingURL=agent-runner.d.ts.map
@@ -7,4 +7,3 @@ export declare class ClaudeDriver implements AgentDriver {
7
7
  configure(provider: SandboxProvider, providerSandboxId: string, _envVars: Record<string, string>): Promise<void>;
8
8
  buildCommand(prompt: string): string;
9
9
  }
10
- //# sourceMappingURL=claude.d.ts.map
@@ -7,4 +7,3 @@ export declare class CodexDriver implements AgentDriver {
7
7
  configure(provider: SandboxProvider, providerSandboxId: string, _envVars: Record<string, string>): Promise<void>;
8
8
  buildCommand(prompt: string): string;
9
9
  }
10
- //# sourceMappingURL=codex.d.ts.map
@@ -7,4 +7,3 @@ export declare class GeminiDriver implements AgentDriver {
7
7
  configure(provider: SandboxProvider, providerSandboxId: string, _envVars: Record<string, string>): Promise<void>;
8
8
  buildCommand(prompt: string): string;
9
9
  }
10
- //# sourceMappingURL=gemini.d.ts.map
@@ -2,4 +2,3 @@ import type { AgentDriver } from "./types.js";
2
2
  export type { AgentDriver };
3
3
  export declare function getAgentDriver(name: string): AgentDriver | undefined;
4
4
  export declare function listAgentDrivers(): AgentDriver[];
5
- //# sourceMappingURL=index.d.ts.map
@@ -7,4 +7,3 @@ export declare class OpenCodeDriver implements AgentDriver {
7
7
  configure(_provider: SandboxProvider, _providerSandboxId: string, _envVars: Record<string, string>): Promise<void>;
8
8
  buildCommand(prompt: string): string;
9
9
  }
10
- //# sourceMappingURL=opencode.d.ts.map
@@ -7,4 +7,3 @@ export declare class PiDriver implements AgentDriver {
7
7
  configure(_provider: SandboxProvider, _providerSandboxId: string, _envVars: Record<string, string>): Promise<void>;
8
8
  buildCommand(prompt: string): string;
9
9
  }
10
- //# sourceMappingURL=pi.d.ts.map
@@ -0,0 +1,9 @@
1
+ import type { SandboxProvider } from "../../providers/types.js";
2
+ import type { AgentDriver } from "./types.js";
3
+ export declare class TakumiDriver implements AgentDriver {
4
+ readonly name = "takumi";
5
+ readonly requiredEnvVars: string[];
6
+ install(provider: SandboxProvider, providerSandboxId: string): Promise<void>;
7
+ configure(provider: SandboxProvider, providerSandboxId: string, envVars: Record<string, string>): Promise<void>;
8
+ buildCommand(prompt: string): string;
9
+ }
@@ -20,4 +20,3 @@ export interface AgentDriver {
20
20
  */
21
21
  buildCommand(prompt: string): string;
22
22
  }
23
- //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Directories that are almost never worth shipping into a sandbox and that
3
+ * dominate upload size. Callers can override via `TarDirectoryOptions.exclude`.
4
+ */
5
+ export declare const DEFAULT_UPLOAD_EXCLUDES: string[];
6
+ export interface TarDirectoryOptions {
7
+ /**
8
+ * Path/glob patterns to exclude (matched by `tar --exclude`). A bare name
9
+ * like `node_modules` excludes that directory and its contents at any depth
10
+ * on both bsdtar (macOS) and GNU tar (Linux). Defaults to
11
+ * {@link DEFAULT_UPLOAD_EXCLUDES}; pass `[]` to include everything.
12
+ */
13
+ exclude?: string[];
14
+ }
15
+ /** Single-quote a value for safe POSIX shell interpolation. */
16
+ export declare function shellQuote(value: string): string;
17
+ /**
18
+ * Create a gzipped tar of a local directory's contents and return it as a Buffer.
19
+ *
20
+ * The archive is rooted at the directory contents (members are relative, e.g.
21
+ * `./src/index.ts`), so it extracts cleanly into any target with
22
+ * `tar -xzf - -C <dir>`. Uses the system `tar`, which is present on macOS
23
+ * (bsdtar) and Linux (GNU tar).
24
+ */
25
+ export declare function tarDirectory(localDir: string, opts?: TarDirectoryOptions): Promise<Buffer>;
26
+ /**
27
+ * Build the shell command that unpacks an uploaded tarball into `remoteDir`
28
+ * and removes the tarball afterward. Shared by providers that upload a single
29
+ * archive then extract it in-sandbox.
30
+ */
31
+ export declare function buildUntarCommand(remoteTarPath: string, remoteDir: string): string;
@@ -7,4 +7,3 @@ export declare function getDefaultImage(): string | undefined;
7
7
  export declare function getProviderApiKey(provider: SandboxProviderName): string | undefined;
8
8
  export declare function setConfigValue(key: string, value: string): void;
9
9
  export declare function getConfigValue(key: string): string | undefined;
10
- //# sourceMappingURL=config.d.ts.map
@@ -10,4 +10,3 @@ export declare const BUILTIN_IMAGES: Record<string, {
10
10
  }>;
11
11
  export declare function resolveImage(image: string): string;
12
12
  export declare function getBuiltinImageSetupScript(image: string): string | undefined;
13
- //# sourceMappingURL=images.d.ts.map
@@ -2,4 +2,3 @@ export declare function startKeepAlive(sandboxId: string, intervalMs?: number):
2
2
  export declare function stopKeepAlive(sandboxId: string): void;
3
3
  export declare function isKeepAliveActive(sandboxId: string): boolean;
4
4
  export declare function stopAllKeepAlives(): void;
5
- //# sourceMappingURL=keepalive.d.ts.map
@@ -2,4 +2,3 @@ export declare function getErrorMessage(error: unknown): string;
2
2
  export declare function finalizeSessionExit(sessionId: string, exitCode: number): void;
3
3
  export declare function finalizeSessionFailure(sessionId: string, _error?: unknown, exitCode?: number): void;
4
4
  export declare function finalizeSandboxProvisionFailure(sandboxId: string, error?: unknown): string;
5
- //# sourceMappingURL=runtime-state.d.ts.map
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Resolve credentials from the @hasna/secrets vault and inject them into agents
3
+ * as per-call environment variables — never persisted to the sandbox record.
4
+ */
5
+ export type SecretResolver = (key: string) => Promise<string>;
6
+ export interface SecretMapping {
7
+ /** Environment variable name to expose inside the sandbox (e.g. ANTHROPIC_API_KEY). */
8
+ env: string;
9
+ /** Vault key to read (e.g. hasnaxyz/anthropic/live/api_key). */
10
+ key: string;
11
+ }
12
+ /** Parse an `ENV_NAME=vault/key` spec into a {@link SecretMapping}. */
13
+ export declare function parseSecretMapping(spec: string): SecretMapping;
14
+ /**
15
+ * Default resolver: read a secret value from the @hasna/secrets vault via the
16
+ * globally-installed `secrets` CLI (`secrets get <key>`).
17
+ */
18
+ export declare const cliSecretResolver: SecretResolver;
19
+ /**
20
+ * Resolve secret mappings to an `{ ENV_NAME: value }` record using the vault.
21
+ * The returned record is meant to be passed as per-call env vars (callEnvVars),
22
+ * so resolved secret values are never written to the persisted sandbox record.
23
+ */
24
+ export declare function resolveSecretEnv(mappings: SecretMapping[], resolver?: SecretResolver): Promise<Record<string, string>>;
25
+ /** Convenience: parse `ENV=key` specs and resolve them in one step. */
26
+ export declare function resolveSecretSpecs(specs: string[], resolver?: SecretResolver): Promise<Record<string, string>>;
@@ -10,4 +10,3 @@ export declare function createStreamCollector(sandboxId: string, sessionId?: str
10
10
  };
11
11
  };
12
12
  export declare function emitLifecycleEvent(sandboxId: string, message: string): void;
13
- //# sourceMappingURL=stream.d.ts.map
@@ -1,2 +1 @@
1
1
  export declare function getPackageVersion(): string;
2
- //# sourceMappingURL=version.d.ts.map
@@ -11,4 +11,3 @@ export declare function dispatchWebhook(event: string, data: {
11
11
  [key: string]: unknown;
12
12
  }): Promise<void>;
13
13
  export declare const WEBHOOK_EVENTS: readonly ["sandbox.created", "sandbox.started", "sandbox.stopped", "sandbox.deleted", "session.started", "session.completed", "session.output"];
14
- //# sourceMappingURL=webhook.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { type Server } from "node:http";
2
+ export declare const DEFAULT_MCP_HTTP_PORT = 8831;
3
+ export declare function isHttpMode(argv: string[]): boolean;
4
+ export declare function resolveMcpHttpPort(argv: string[]): number;
5
+ export declare function healthPayload(name?: string): {
6
+ status: string;
7
+ name: string;
8
+ };
9
+ export declare function handleMcpHttpRoutes(req: Request): Promise<Response | null>;
10
+ export declare function startMcpHttpServer(options?: {
11
+ port?: number;
12
+ hostname?: string;
13
+ onListening?: (port: number) => void;
14
+ }): Server;
@@ -1,3 +1,2 @@
1
1
  #!/usr/bin/env bun
2
2
  export {};
3
- //# sourceMappingURL=index.d.ts.map