coding-agents-sdk 0.0.1 → 0.3.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 +274 -0
- package/dist/SdkAgent-a97nkDuR.mjs +1 -0
- package/dist/adapters/claude-code-cli/index.d.mts +2 -0
- package/dist/adapters/claude-code-cli/index.mjs +2 -0
- package/dist/adapters/claude-code-sdk/index.d.mts +2 -0
- package/dist/adapters/claude-code-sdk/index.mjs +4 -0
- package/dist/adapters/codex-cli/index.d.mts +2 -0
- package/dist/adapters/codex-cli/index.mjs +2 -0
- package/dist/adapters/codex-sdk/index.d.mts +2 -0
- package/dist/adapters/codex-sdk/index.mjs +1 -0
- package/dist/adapters/gemini-cli/index.d.mts +2 -0
- package/dist/adapters/gemini-cli/index.mjs +1 -0
- package/dist/classify-error-V6x6jP_R.mjs +8 -0
- package/dist/container/index.d.mts +2 -0
- package/dist/container/index.mjs +1 -0
- package/dist/container-BY7JDOGo.mjs +1 -0
- package/dist/container-DWTITDhL.mjs +1 -0
- package/dist/container-vkn5-3Xl.mjs +1 -0
- package/dist/diff-BCfLDXNN.mjs +1 -0
- package/dist/env-Dkd8Sgjf.mjs +1 -0
- package/dist/errors-XV0frS3r.mjs +1 -0
- package/dist/events-D31_b0sA.d.mts +239 -0
- package/dist/execution-target-BJ5mWjDM.mjs +4 -0
- package/dist/index-COHwWTg_.d.mts +315 -0
- package/dist/index-CzvanLE_.d.mts +46 -0
- package/dist/index-DCaZeLrI.d.mts +51 -0
- package/dist/index-DNyKelMh.d.mts +39 -0
- package/dist/index-DP4Jxoax.d.mts +110 -0
- package/dist/index-R77YR8ak.d.mts +224 -0
- package/dist/index-jUwKDQ34.d.mts +146 -0
- package/dist/index.d.mts +17 -0
- package/dist/index.mjs +1 -0
- package/dist/oci-C_S_FKHj.mjs +1 -0
- package/dist/sandbox/index.d.mts +2 -0
- package/dist/sandbox/index.mjs +1 -0
- package/dist/sandbox-DeKpyenZ.mjs +1 -0
- package/dist/schemas/index.d.mts +2 -0
- package/dist/schemas/index.mjs +1 -0
- package/dist/schemas-BM6qORw3.mjs +1 -0
- package/dist/spawner-BJesLc8I.mjs +1 -0
- package/dist/structured-output-DEkBQ-1Z.mjs +1 -0
- package/dist/types-COlDAzs5.d.mts +162 -0
- package/dist/types-CwvWHEpy.mjs +1 -0
- package/dist/util-CGg8cK92.mjs +1 -0
- package/package.json +90 -9
- package/index.js +0 -7
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { D as ProcessSpawner, f as EnsureDisjoint, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-COlDAzs5.mjs";
|
|
2
|
+
import { t as Container } from "./index-R77YR8ak.mjs";
|
|
3
|
+
import { i as Sandbox } from "./index-DCaZeLrI.mjs";
|
|
4
|
+
import { z } from "zod/v4";
|
|
5
|
+
|
|
6
|
+
//#region src/adapters/gemini-cli/events/schemas.d.ts
|
|
7
|
+
declare const geminiEventSchema: z.ZodObject<{
|
|
8
|
+
type: z.ZodString;
|
|
9
|
+
}, z.core.$loose>;
|
|
10
|
+
type GeminiEvent = z.infer<typeof geminiEventSchema>;
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/adapters/gemini-cli/types.d.ts
|
|
13
|
+
type GeminiCliPermissionMode = "default" | "full";
|
|
14
|
+
interface GeminiCliRunOptions {
|
|
15
|
+
allowedTools?: string[];
|
|
16
|
+
disallowedTools?: string[];
|
|
17
|
+
permissionMode?: GeminiCliPermissionMode;
|
|
18
|
+
extraArgs?: string[];
|
|
19
|
+
}
|
|
20
|
+
type GeminiCliAgentOptions = ExclusiveExecutionTargetOptions<Container, Sandbox> & GeminiCliRunOptions & {
|
|
21
|
+
command?: string[] | string;
|
|
22
|
+
cwd?: string;
|
|
23
|
+
env?: Record<string, string>;
|
|
24
|
+
propagateEnv?: boolean;
|
|
25
|
+
sessionId?: string;
|
|
26
|
+
model?: string;
|
|
27
|
+
systemPrompt?: string;
|
|
28
|
+
logPath?: string;
|
|
29
|
+
spawner?: ProcessSpawner;
|
|
30
|
+
onEvent?: AgentEventHandler;
|
|
31
|
+
};
|
|
32
|
+
interface GeminiCliAgent extends BaseAgent<EnsureDisjoint<GeminiCliRunOptions>> {
|
|
33
|
+
readonly type: "gemini-cli";
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/adapters/gemini-cli/adapter.d.ts
|
|
37
|
+
declare const createGeminiCliAgent: (options?: GeminiCliAgentOptions) => GeminiCliAgent;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { GeminiCliRunOptions as a, GeminiCliPermissionMode as i, GeminiCliAgent as n, GeminiEvent as o, GeminiCliAgentOptions as r, createGeminiCliAgent as t };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { S as McpServerConfig } from "./events-D31_b0sA.mjs";
|
|
2
|
+
import { D as ProcessSpawner, f as EnsureDisjoint, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-COlDAzs5.mjs";
|
|
3
|
+
import { t as Container } from "./index-R77YR8ak.mjs";
|
|
4
|
+
import { i as Sandbox } from "./index-DCaZeLrI.mjs";
|
|
5
|
+
import { z } from "zod/v4";
|
|
6
|
+
|
|
7
|
+
//#region src/adapters/codex-cli/events/schemas.d.ts
|
|
8
|
+
declare const codexEventSchema: z.ZodObject<{
|
|
9
|
+
type: z.ZodString;
|
|
10
|
+
}, z.core.$loose>;
|
|
11
|
+
type CodexEvent = z.infer<typeof codexEventSchema>;
|
|
12
|
+
declare const codexThreadStartedEventSchema: z.ZodObject<{
|
|
13
|
+
type: z.ZodLiteral<"thread.started">;
|
|
14
|
+
thread_id: z.ZodString;
|
|
15
|
+
}, z.core.$loose>;
|
|
16
|
+
type CodexThreadStartedEvent = z.infer<typeof codexThreadStartedEventSchema>;
|
|
17
|
+
declare const codexTurnCompletedEventSchema: z.ZodObject<{
|
|
18
|
+
type: z.ZodLiteral<"turn.completed">;
|
|
19
|
+
usage: z.ZodOptional<z.ZodObject<{
|
|
20
|
+
input_tokens: z.ZodOptional<z.ZodNumber>;
|
|
21
|
+
cached_input_tokens: z.ZodOptional<z.ZodNumber>;
|
|
22
|
+
output_tokens: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
reasoning_output_tokens: z.ZodOptional<z.ZodNumber>;
|
|
24
|
+
total_tokens: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
}, z.core.$loose>>;
|
|
26
|
+
last_agent_message: z.ZodOptional<z.ZodString>;
|
|
27
|
+
duration_ms: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
num_turns: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
}, z.core.$loose>;
|
|
30
|
+
type CodexTurnCompletedEvent = z.infer<typeof codexTurnCompletedEventSchema>;
|
|
31
|
+
declare const codexTurnFailedEventSchema: z.ZodObject<{
|
|
32
|
+
type: z.ZodLiteral<"turn.failed">;
|
|
33
|
+
usage: z.ZodOptional<z.ZodObject<{
|
|
34
|
+
input_tokens: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
cached_input_tokens: z.ZodOptional<z.ZodNumber>;
|
|
36
|
+
output_tokens: z.ZodOptional<z.ZodNumber>;
|
|
37
|
+
reasoning_output_tokens: z.ZodOptional<z.ZodNumber>;
|
|
38
|
+
total_tokens: z.ZodOptional<z.ZodNumber>;
|
|
39
|
+
}, z.core.$loose>>;
|
|
40
|
+
last_agent_message: z.ZodOptional<z.ZodString>;
|
|
41
|
+
duration_ms: z.ZodOptional<z.ZodNumber>;
|
|
42
|
+
num_turns: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
message: z.ZodOptional<z.ZodString>;
|
|
44
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
45
|
+
}, z.core.$loose>;
|
|
46
|
+
type CodexTurnFailedEvent = z.infer<typeof codexTurnFailedEventSchema>;
|
|
47
|
+
declare const codexItemStartedEventSchema: z.ZodObject<{
|
|
48
|
+
type: z.ZodLiteral<"item.started">;
|
|
49
|
+
item: z.ZodObject<{
|
|
50
|
+
id: z.ZodString;
|
|
51
|
+
type: z.ZodString;
|
|
52
|
+
}, z.core.$loose>;
|
|
53
|
+
}, z.core.$loose>;
|
|
54
|
+
type CodexItemStartedEvent = z.infer<typeof codexItemStartedEventSchema>;
|
|
55
|
+
declare const codexItemUpdatedEventSchema: z.ZodObject<{
|
|
56
|
+
type: z.ZodLiteral<"item.updated">;
|
|
57
|
+
item: z.ZodObject<{
|
|
58
|
+
id: z.ZodString;
|
|
59
|
+
type: z.ZodString;
|
|
60
|
+
}, z.core.$loose>;
|
|
61
|
+
}, z.core.$loose>;
|
|
62
|
+
type CodexItemUpdatedEvent = z.infer<typeof codexItemUpdatedEventSchema>;
|
|
63
|
+
declare const codexItemCompletedEventSchema: z.ZodObject<{
|
|
64
|
+
type: z.ZodLiteral<"item.completed">;
|
|
65
|
+
item: z.ZodObject<{
|
|
66
|
+
id: z.ZodString;
|
|
67
|
+
type: z.ZodString;
|
|
68
|
+
}, z.core.$loose>;
|
|
69
|
+
}, z.core.$loose>;
|
|
70
|
+
type CodexItemCompletedEvent = z.infer<typeof codexItemCompletedEventSchema>;
|
|
71
|
+
declare const codexErrorEventSchema: z.ZodObject<{
|
|
72
|
+
type: z.ZodLiteral<"error">;
|
|
73
|
+
message: z.ZodOptional<z.ZodString>;
|
|
74
|
+
error: z.ZodOptional<z.ZodUnknown>;
|
|
75
|
+
}, z.core.$loose>;
|
|
76
|
+
type CodexErrorEvent = z.infer<typeof codexErrorEventSchema>;
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/adapters/codex-cli/types.d.ts
|
|
79
|
+
type CodexCliSandboxMode = "danger-full-access" | "read-only" | "workspace-write";
|
|
80
|
+
type CodexCliPermissionMode = "default" | "full-access" | "full-auto";
|
|
81
|
+
interface CodexCliRunOptions {
|
|
82
|
+
codexSandboxMode?: CodexCliSandboxMode;
|
|
83
|
+
additionalDirectories?: string[];
|
|
84
|
+
skipGitRepoCheck?: boolean;
|
|
85
|
+
permissionMode?: CodexCliPermissionMode;
|
|
86
|
+
ephemeral?: boolean;
|
|
87
|
+
mcpConfig?: string;
|
|
88
|
+
mcpServers?: Record<string, McpServerConfig>;
|
|
89
|
+
extraArgs?: string[];
|
|
90
|
+
systemPrompt?: never;
|
|
91
|
+
}
|
|
92
|
+
type CodexCliAgentOptions = CodexCliRunOptions & ExclusiveExecutionTargetOptions<Container, Sandbox> & {
|
|
93
|
+
command?: string[] | string;
|
|
94
|
+
cwd?: string;
|
|
95
|
+
env?: Record<string, string>;
|
|
96
|
+
propagateEnv?: boolean;
|
|
97
|
+
sessionId?: string;
|
|
98
|
+
model?: string;
|
|
99
|
+
logPath?: string;
|
|
100
|
+
spawner?: ProcessSpawner;
|
|
101
|
+
onEvent?: AgentEventHandler;
|
|
102
|
+
};
|
|
103
|
+
interface CodexCliAgent extends BaseAgent<EnsureDisjoint<CodexCliRunOptions>> {
|
|
104
|
+
readonly type: "codex-cli";
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/adapters/codex-cli/adapter.d.ts
|
|
108
|
+
declare const createCodexCliAgent: (options?: CodexCliAgentOptions) => CodexCliAgent;
|
|
109
|
+
//#endregion
|
|
110
|
+
export { CodexCliRunOptions as a, CodexEvent as c, CodexItemUpdatedEvent as d, CodexThreadStartedEvent as f, CodexCliPermissionMode as i, CodexItemCompletedEvent as l, CodexTurnFailedEvent as m, CodexCliAgent as n, CodexCliSandboxMode as o, CodexTurnCompletedEvent as p, CodexCliAgentOptions as r, CodexErrorEvent as s, createCodexCliAgent as t, CodexItemStartedEvent as u };
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { D as ProcessSpawner } from "./types-COlDAzs5.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/container/types.d.ts
|
|
4
|
+
type ContainerType = "docker" | "e2b" | "podman";
|
|
5
|
+
interface PortMapping {
|
|
6
|
+
container: number;
|
|
7
|
+
host?: number;
|
|
8
|
+
protocol?: "tcp" | "udp";
|
|
9
|
+
}
|
|
10
|
+
interface VolumeMount {
|
|
11
|
+
source: string;
|
|
12
|
+
target: string;
|
|
13
|
+
readonly?: boolean;
|
|
14
|
+
}
|
|
15
|
+
interface ContainerConfigBase<TType extends ContainerType> {
|
|
16
|
+
type: TType;
|
|
17
|
+
workdir: string;
|
|
18
|
+
name?: string;
|
|
19
|
+
env?: Record<string, string>;
|
|
20
|
+
}
|
|
21
|
+
interface ExecOptions {
|
|
22
|
+
cwd?: string;
|
|
23
|
+
env?: Record<string, string>;
|
|
24
|
+
timeoutMs?: number;
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
}
|
|
27
|
+
interface ExecResult {
|
|
28
|
+
exitCode: number;
|
|
29
|
+
stdout: string;
|
|
30
|
+
stderr: string;
|
|
31
|
+
}
|
|
32
|
+
type ContainerStatus = "created" | "disposed" | "running" | "stopped";
|
|
33
|
+
type WorkdirChangeKind = "added" | "deleted" | "modified" | "renamed";
|
|
34
|
+
interface WorkdirSnapshotOptions {
|
|
35
|
+
cwd?: string;
|
|
36
|
+
}
|
|
37
|
+
interface WorkdirSnapshot {
|
|
38
|
+
readonly cwd: string;
|
|
39
|
+
readonly createdAt: Date;
|
|
40
|
+
}
|
|
41
|
+
interface WorkdirFileChange {
|
|
42
|
+
readonly path: string;
|
|
43
|
+
readonly previousPath?: string;
|
|
44
|
+
readonly kind: WorkdirChangeKind;
|
|
45
|
+
readonly beforeHash?: string;
|
|
46
|
+
readonly afterHash?: string;
|
|
47
|
+
readonly beforeSize?: number;
|
|
48
|
+
readonly afterSize?: number;
|
|
49
|
+
}
|
|
50
|
+
interface WorkdirDiffStats {
|
|
51
|
+
readonly durationMs: number;
|
|
52
|
+
readonly filesCompared: number;
|
|
53
|
+
}
|
|
54
|
+
interface WorkdirDiff {
|
|
55
|
+
readonly cwd: string;
|
|
56
|
+
readonly changedFiles: readonly string[];
|
|
57
|
+
readonly fileChanges: readonly WorkdirFileChange[];
|
|
58
|
+
readonly stats: WorkdirDiffStats;
|
|
59
|
+
}
|
|
60
|
+
interface ContainerIdentity<TType extends ContainerType, TConfig extends ContainerConfigBase<TType>> {
|
|
61
|
+
readonly type: TType;
|
|
62
|
+
readonly id: string;
|
|
63
|
+
readonly name: string;
|
|
64
|
+
readonly config: TConfig;
|
|
65
|
+
readonly status: ContainerStatus;
|
|
66
|
+
readonly workdir: string;
|
|
67
|
+
}
|
|
68
|
+
interface ContainerLifecycle {
|
|
69
|
+
start: () => Promise<void>;
|
|
70
|
+
stop: () => Promise<void>;
|
|
71
|
+
dispose: () => Promise<void>;
|
|
72
|
+
[Symbol.asyncDispose]: () => Promise<void>;
|
|
73
|
+
}
|
|
74
|
+
interface ContainerExecution {
|
|
75
|
+
exec: (command: string, args: string[], options?: ExecOptions) => Promise<ExecResult>;
|
|
76
|
+
execShell: (script: string, options?: ExecOptions) => Promise<ExecResult>;
|
|
77
|
+
readonly spawner: ProcessSpawner;
|
|
78
|
+
}
|
|
79
|
+
interface ContainerFileSystem {
|
|
80
|
+
copyTo: (hostPath: string, containerPath: string) => Promise<void>;
|
|
81
|
+
copyFrom: (containerPath: string, hostPath: string) => Promise<void>;
|
|
82
|
+
writeFile: (path: string, content: Uint8Array | string) => Promise<void>;
|
|
83
|
+
readFile: (path: string) => Promise<string>;
|
|
84
|
+
fileExists: (path: string) => Promise<boolean>;
|
|
85
|
+
mkdir: (path: string) => Promise<void>;
|
|
86
|
+
}
|
|
87
|
+
interface ContainerObservability {
|
|
88
|
+
logs: (options?: {
|
|
89
|
+
tail?: number;
|
|
90
|
+
}) => Promise<string>;
|
|
91
|
+
syncStatus: () => Promise<ContainerStatus>;
|
|
92
|
+
snapshotWorkdir: (options?: WorkdirSnapshotOptions) => Promise<WorkdirSnapshot>;
|
|
93
|
+
diffWorkdir: (snapshot: WorkdirSnapshot) => Promise<WorkdirDiff>;
|
|
94
|
+
releaseWorkdirSnapshot: (snapshot: WorkdirSnapshot) => Promise<void>;
|
|
95
|
+
}
|
|
96
|
+
interface ContainerBase<TType extends ContainerType, TConfig extends ContainerConfigBase<TType>> extends ContainerExecution, ContainerFileSystem, ContainerIdentity<TType, TConfig>, ContainerLifecycle, ContainerObservability {}
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/container/oci.d.ts
|
|
99
|
+
interface OciBuildBase {
|
|
100
|
+
context?: string;
|
|
101
|
+
args?: Record<string, string>;
|
|
102
|
+
tag?: string;
|
|
103
|
+
}
|
|
104
|
+
type OciBuildConfig = OciBuildBase & ({
|
|
105
|
+
dockerfile: string;
|
|
106
|
+
content?: never;
|
|
107
|
+
} | {
|
|
108
|
+
dockerfile?: never;
|
|
109
|
+
content: string;
|
|
110
|
+
});
|
|
111
|
+
interface OciProviderBase {
|
|
112
|
+
ports?: PortMapping[];
|
|
113
|
+
mounts?: VolumeMount[];
|
|
114
|
+
user?: string;
|
|
115
|
+
binary?: string;
|
|
116
|
+
extraArgs?: string[];
|
|
117
|
+
network?: string;
|
|
118
|
+
platform?: string;
|
|
119
|
+
}
|
|
120
|
+
type OciProviderConfig = OciProviderBase & ({
|
|
121
|
+
image: string;
|
|
122
|
+
build?: never;
|
|
123
|
+
} | {
|
|
124
|
+
image?: never;
|
|
125
|
+
build: OciBuildConfig;
|
|
126
|
+
});
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/container/docker/types.d.ts
|
|
129
|
+
type DockerBuildBase = OciBuildBase;
|
|
130
|
+
type DockerBuildConfig = OciBuildConfig;
|
|
131
|
+
type DockerContainerBase = OciProviderBase;
|
|
132
|
+
type DockerProviderConfig = OciProviderConfig;
|
|
133
|
+
type DockerContainerConfig = ContainerConfigBase<"docker"> & OciProviderConfig;
|
|
134
|
+
interface DockerContainer extends ContainerBase<"docker", DockerContainerConfig> {
|
|
135
|
+
getMappedPort: (containerPort: number) => number | undefined;
|
|
136
|
+
}
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/container/e2b/types.d.ts
|
|
139
|
+
interface E2BSandboxNetworkOptions {
|
|
140
|
+
allowOut?: string[];
|
|
141
|
+
denyOut?: string[];
|
|
142
|
+
allowPublicTraffic?: boolean;
|
|
143
|
+
maskRequestHost?: string;
|
|
144
|
+
}
|
|
145
|
+
interface E2BSandboxLifecycleOptions {
|
|
146
|
+
onTimeout: "kill" | "pause";
|
|
147
|
+
autoResume?: boolean;
|
|
148
|
+
}
|
|
149
|
+
interface E2BConnectionConfig {
|
|
150
|
+
apiKey?: string;
|
|
151
|
+
accessToken?: string;
|
|
152
|
+
domain?: string;
|
|
153
|
+
requestTimeoutMs?: number;
|
|
154
|
+
headers?: Record<string, string>;
|
|
155
|
+
}
|
|
156
|
+
interface E2BContainerBase extends E2BConnectionConfig {
|
|
157
|
+
user?: string;
|
|
158
|
+
timeoutMs?: number;
|
|
159
|
+
}
|
|
160
|
+
interface E2BCreateConfig extends E2BContainerBase {
|
|
161
|
+
sandboxId?: never;
|
|
162
|
+
template?: string;
|
|
163
|
+
metadata?: Record<string, string>;
|
|
164
|
+
secure?: boolean;
|
|
165
|
+
allowInternetAccess?: boolean;
|
|
166
|
+
network?: E2BSandboxNetworkOptions;
|
|
167
|
+
lifecycle?: E2BSandboxLifecycleOptions;
|
|
168
|
+
}
|
|
169
|
+
interface E2BConnectConfig extends E2BContainerBase {
|
|
170
|
+
sandboxId: string;
|
|
171
|
+
template?: never;
|
|
172
|
+
metadata?: never;
|
|
173
|
+
secure?: never;
|
|
174
|
+
allowInternetAccess?: never;
|
|
175
|
+
network?: never;
|
|
176
|
+
lifecycle?: never;
|
|
177
|
+
}
|
|
178
|
+
type E2BProviderConfig = E2BConnectConfig | E2BCreateConfig;
|
|
179
|
+
type E2BContainerConfig = ContainerConfigBase<"e2b"> & E2BProviderConfig;
|
|
180
|
+
interface E2BContainer extends ContainerBase<"e2b", E2BContainerConfig> {
|
|
181
|
+
getHost: (port: number) => string;
|
|
182
|
+
}
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region src/container/podman/types.d.ts
|
|
185
|
+
type PodmanBuildBase = OciBuildBase;
|
|
186
|
+
type PodmanBuildConfig = OciBuildConfig;
|
|
187
|
+
type PodmanContainerBase = OciProviderBase;
|
|
188
|
+
type PodmanProviderConfig = OciProviderConfig;
|
|
189
|
+
type PodmanContainerConfig = ContainerConfigBase<"podman"> & OciProviderConfig;
|
|
190
|
+
interface PodmanContainer extends ContainerBase<"podman", PodmanContainerConfig> {
|
|
191
|
+
getMappedPort: (containerPort: number) => number | undefined;
|
|
192
|
+
}
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region src/container/errors.d.ts
|
|
195
|
+
declare class ContainerError extends Error {
|
|
196
|
+
constructor(message: string);
|
|
197
|
+
}
|
|
198
|
+
declare class ContainerCreateError extends ContainerError {
|
|
199
|
+
constructor(message: string);
|
|
200
|
+
}
|
|
201
|
+
declare class ContainerStartError extends ContainerError {
|
|
202
|
+
constructor(message: string);
|
|
203
|
+
}
|
|
204
|
+
declare class ContainerExecError extends ContainerError {
|
|
205
|
+
constructor(message: string);
|
|
206
|
+
}
|
|
207
|
+
declare class ContainerNotRunningError extends ContainerError {
|
|
208
|
+
constructor(message?: string);
|
|
209
|
+
}
|
|
210
|
+
declare class ContainerDisposedError extends ContainerError {
|
|
211
|
+
constructor(message?: string);
|
|
212
|
+
}
|
|
213
|
+
declare class ContainerDiffError extends ContainerError {
|
|
214
|
+
constructor(message: string);
|
|
215
|
+
}
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region src/container/index.d.ts
|
|
218
|
+
type ContainerConfig = DockerContainerConfig | E2BContainerConfig | PodmanContainerConfig;
|
|
219
|
+
type Container = DockerContainer | E2BContainer | PodmanContainer;
|
|
220
|
+
declare function createContainer(config: DockerContainerConfig): Promise<DockerContainer>;
|
|
221
|
+
declare function createContainer(config: E2BContainerConfig): Promise<E2BContainer>;
|
|
222
|
+
declare function createContainer(config: PodmanContainerConfig): Promise<PodmanContainer>;
|
|
223
|
+
//#endregion
|
|
224
|
+
export { ContainerBase as A, ExecResult as B, E2BProviderConfig as C, DockerContainerBase as D, DockerContainer as E, ContainerLifecycle as F, WorkdirDiffStats as G, VolumeMount as H, ContainerObservability as I, WorkdirSnapshotOptions as J, WorkdirFileChange as K, ContainerStatus as L, ContainerExecution as M, ContainerFileSystem as N, DockerContainerConfig as O, ContainerIdentity as P, ContainerType as R, E2BCreateConfig as S, DockerBuildConfig as T, WorkdirChangeKind as U, PortMapping as V, WorkdirDiff as W, E2BConnectConfig as _, ContainerDiffError as a, E2BContainerBase as b, ContainerExecError as c, PodmanBuildBase as d, PodmanBuildConfig as f, PodmanProviderConfig as g, PodmanContainerConfig as h, ContainerCreateError as i, ContainerConfigBase as j, DockerProviderConfig as k, ContainerNotRunningError as l, PodmanContainerBase as m, ContainerConfig as n, ContainerDisposedError as o, PodmanContainer as p, WorkdirSnapshot as q, createContainer as r, ContainerError as s, Container as t, ContainerStartError as u, E2BConnectionConfig as v, DockerBuildBase as w, E2BContainerConfig as x, E2BContainer as y, ExecOptions as z };
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { f as EnsureDisjoint, l as BaseAgent, t as AgentEventHandler } from "./types-COlDAzs5.mjs";
|
|
2
|
+
//#region src/adapters/codex-sdk/types.d.ts
|
|
3
|
+
type CodexSdkSandboxMode = "danger-full-access" | "read-only" | "workspace-write";
|
|
4
|
+
type CodexSdkModelReasoningEffort = "high" | "low" | "medium" | "minimal" | "xhigh";
|
|
5
|
+
type CodexSdkWebSearchMode = "cached" | "disabled" | "live";
|
|
6
|
+
type CodexSdkConfigValue = CodexSdkConfigObject | CodexSdkConfigValue[] | boolean | number | string;
|
|
7
|
+
type CodexSdkConfigObject = {
|
|
8
|
+
[key: string]: CodexSdkConfigValue;
|
|
9
|
+
};
|
|
10
|
+
type CodexSdkPermissionMode = "never" | "on-failure" | "on-request" | "untrusted";
|
|
11
|
+
interface CodexSdkUsage {
|
|
12
|
+
input_tokens: number;
|
|
13
|
+
cached_input_tokens: number;
|
|
14
|
+
output_tokens: number;
|
|
15
|
+
}
|
|
16
|
+
interface CodexSdkCommandExecutionItem {
|
|
17
|
+
id: string;
|
|
18
|
+
type: "command_execution";
|
|
19
|
+
command: string;
|
|
20
|
+
aggregated_output: string;
|
|
21
|
+
exit_code?: number;
|
|
22
|
+
status: "completed" | "failed" | "in_progress";
|
|
23
|
+
}
|
|
24
|
+
interface CodexSdkFileUpdateChange {
|
|
25
|
+
path: string;
|
|
26
|
+
kind: "add" | "delete" | "update";
|
|
27
|
+
}
|
|
28
|
+
interface CodexSdkFileChangeItem {
|
|
29
|
+
id: string;
|
|
30
|
+
type: "file_change";
|
|
31
|
+
changes: CodexSdkFileUpdateChange[];
|
|
32
|
+
status: "completed" | "failed";
|
|
33
|
+
}
|
|
34
|
+
interface CodexSdkMcpToolCallItem {
|
|
35
|
+
id: string;
|
|
36
|
+
type: "mcp_tool_call";
|
|
37
|
+
server: string;
|
|
38
|
+
tool: string;
|
|
39
|
+
arguments: unknown;
|
|
40
|
+
result?: {
|
|
41
|
+
content: unknown[];
|
|
42
|
+
structured_content: unknown;
|
|
43
|
+
};
|
|
44
|
+
error?: {
|
|
45
|
+
message: string;
|
|
46
|
+
};
|
|
47
|
+
status: "completed" | "failed" | "in_progress";
|
|
48
|
+
}
|
|
49
|
+
interface CodexSdkAgentMessageItem {
|
|
50
|
+
id: string;
|
|
51
|
+
type: "agent_message";
|
|
52
|
+
text: string;
|
|
53
|
+
}
|
|
54
|
+
interface CodexSdkReasoningItem {
|
|
55
|
+
id: string;
|
|
56
|
+
type: "reasoning";
|
|
57
|
+
text: string;
|
|
58
|
+
}
|
|
59
|
+
interface CodexSdkWebSearchItem {
|
|
60
|
+
id: string;
|
|
61
|
+
type: "web_search";
|
|
62
|
+
query: string;
|
|
63
|
+
}
|
|
64
|
+
interface CodexSdkErrorItem {
|
|
65
|
+
id: string;
|
|
66
|
+
type: "error";
|
|
67
|
+
message: string;
|
|
68
|
+
}
|
|
69
|
+
interface CodexSdkTodoItem {
|
|
70
|
+
text: string;
|
|
71
|
+
completed: boolean;
|
|
72
|
+
}
|
|
73
|
+
interface CodexSdkTodoListItem {
|
|
74
|
+
id: string;
|
|
75
|
+
type: "todo_list";
|
|
76
|
+
items: CodexSdkTodoItem[];
|
|
77
|
+
}
|
|
78
|
+
interface CodexSdkThreadError {
|
|
79
|
+
message: string;
|
|
80
|
+
}
|
|
81
|
+
interface CodexSdkThreadStartedEvent {
|
|
82
|
+
type: "thread.started";
|
|
83
|
+
thread_id: string;
|
|
84
|
+
}
|
|
85
|
+
interface CodexSdkTurnStartedEvent {
|
|
86
|
+
type: "turn.started";
|
|
87
|
+
}
|
|
88
|
+
interface CodexSdkTurnCompletedEvent {
|
|
89
|
+
type: "turn.completed";
|
|
90
|
+
usage: CodexSdkUsage;
|
|
91
|
+
}
|
|
92
|
+
interface CodexSdkTurnFailedEvent {
|
|
93
|
+
type: "turn.failed";
|
|
94
|
+
error: CodexSdkThreadError;
|
|
95
|
+
}
|
|
96
|
+
interface CodexSdkItemStartedEvent {
|
|
97
|
+
type: "item.started";
|
|
98
|
+
item: CodexSdkItem;
|
|
99
|
+
}
|
|
100
|
+
interface CodexSdkItemUpdatedEvent {
|
|
101
|
+
type: "item.updated";
|
|
102
|
+
item: CodexSdkItem;
|
|
103
|
+
}
|
|
104
|
+
interface CodexSdkItemCompletedEvent {
|
|
105
|
+
type: "item.completed";
|
|
106
|
+
item: CodexSdkItem;
|
|
107
|
+
}
|
|
108
|
+
interface CodexSdkThreadErrorEvent {
|
|
109
|
+
type: "error";
|
|
110
|
+
message: string;
|
|
111
|
+
}
|
|
112
|
+
interface CodexSdkRunOptions {
|
|
113
|
+
permissionMode?: CodexSdkPermissionMode;
|
|
114
|
+
sandboxMode?: CodexSdkSandboxMode;
|
|
115
|
+
skipGitRepoCheck?: boolean;
|
|
116
|
+
modelReasoningEffort?: CodexSdkModelReasoningEffort;
|
|
117
|
+
networkAccessEnabled?: boolean;
|
|
118
|
+
webSearchMode?: CodexSdkWebSearchMode;
|
|
119
|
+
webSearchEnabled?: boolean;
|
|
120
|
+
additionalDirectories?: string[];
|
|
121
|
+
systemPrompt?: never;
|
|
122
|
+
}
|
|
123
|
+
interface CodexSdkAgentOptions extends CodexSdkRunOptions {
|
|
124
|
+
command?: string;
|
|
125
|
+
baseUrl?: string;
|
|
126
|
+
apiKey?: string;
|
|
127
|
+
config?: CodexSdkConfigObject;
|
|
128
|
+
env?: Record<string, string>;
|
|
129
|
+
propagateEnv?: boolean;
|
|
130
|
+
container?: never;
|
|
131
|
+
sandbox?: never;
|
|
132
|
+
cwd?: string;
|
|
133
|
+
sessionId?: string;
|
|
134
|
+
model?: string;
|
|
135
|
+
onEvent?: AgentEventHandler;
|
|
136
|
+
}
|
|
137
|
+
interface CodexSdkAgent extends BaseAgent<EnsureDisjoint<CodexSdkRunOptions>> {
|
|
138
|
+
readonly type: "codex-sdk";
|
|
139
|
+
}
|
|
140
|
+
type CodexSdkItem = CodexSdkAgentMessageItem | CodexSdkCommandExecutionItem | CodexSdkErrorItem | CodexSdkFileChangeItem | CodexSdkMcpToolCallItem | CodexSdkReasoningItem | CodexSdkTodoListItem | CodexSdkWebSearchItem;
|
|
141
|
+
type CodexSdkEvent = CodexSdkItemCompletedEvent | CodexSdkItemStartedEvent | CodexSdkItemUpdatedEvent | CodexSdkThreadErrorEvent | CodexSdkThreadStartedEvent | CodexSdkTurnCompletedEvent | CodexSdkTurnFailedEvent | CodexSdkTurnStartedEvent;
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/adapters/codex-sdk/adapter.d.ts
|
|
144
|
+
declare const createCodexSdkAgent: (options?: CodexSdkAgentOptions) => CodexSdkAgent;
|
|
145
|
+
//#endregion
|
|
146
|
+
export { CodexSdkItem as a, CodexSdkEvent as i, CodexSdkAgent as n, CodexSdkPermissionMode as o, CodexSdkAgentOptions as r, CodexSdkRunOptions as s, createCodexSdkAgent as t };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { C as OutputSchema, S as McpServerConfig, T as agentCapabilitiesSchema, a as SessionStartEvent, b as ImageContentPart, c as ToolResultEvent, i as SessionEndEvent, n as MessageEvent, o as StderrEvent, r as ReasoningEvent, s as ToolCallEvent, t as AgentEvent, u as eventSchema, v as AgentCapabilities, w as TextContentPart, x as JsonSchema, y as ContentPart } from "./events-D31_b0sA.mjs";
|
|
2
|
+
import { C as RunTiming, E as ZodRunRequest, S as RunStatus, T as StructuredRunRequest, _ as RunProcessInfo, a as AgentValidationError, b as RunResultBase, c as AnyRunResult, d as CompletedRunResult, f as EnsureDisjoint, g as RunError, h as JsonSchemaRunRequest, i as AgentType, l as BaseAgent, m as FailedRunResult, n as AgentMetrics, o as AnyCompletedRunResult, r as AgentRunError, s as AnyRunRequest, t as AgentEventHandler, u as CancelledRunResult, v as RunRequest, w as StopReason, x as RunStats, y as RunResult } from "./types-COlDAzs5.mjs";
|
|
3
|
+
import { A as ContainerBase, B as ExecResult, C as E2BProviderConfig, D as DockerContainerBase, E as DockerContainer, F as ContainerLifecycle, G as WorkdirDiffStats, H as VolumeMount, I as ContainerObservability, J as WorkdirSnapshotOptions, K as WorkdirFileChange, L as ContainerStatus, M as ContainerExecution, N as ContainerFileSystem, O as DockerContainerConfig, P as ContainerIdentity, R as ContainerType, S as E2BCreateConfig, T as DockerBuildConfig, U as WorkdirChangeKind, V as PortMapping, W as WorkdirDiff, _ as E2BConnectConfig, a as ContainerDiffError, b as E2BContainerBase, c as ContainerExecError, d as PodmanBuildBase, f as PodmanBuildConfig, g as PodmanProviderConfig, h as PodmanContainerConfig, i as ContainerCreateError, j as ContainerConfigBase, k as DockerProviderConfig, l as ContainerNotRunningError, m as PodmanContainerBase, n as ContainerConfig, o as ContainerDisposedError, p as PodmanContainer, q as WorkdirSnapshot, r as createContainer, s as ContainerError, t as Container, u as ContainerStartError, v as E2BConnectionConfig, w as DockerBuildBase, x as E2BContainerConfig, y as E2BContainer, z as ExecOptions } from "./index-R77YR8ak.mjs";
|
|
4
|
+
import { a as SandboxBase, c as SandboxExecution, d as SandboxStatus, f as SandboxType, i as Sandbox, l as SandboxIdentity, n as BubblewrapSandbox, o as SandboxConfig, r as BubblewrapSandboxConfig, s as SandboxConfigBase, t as createSandbox, u as SandboxLifecycle } from "./index-DCaZeLrI.mjs";
|
|
5
|
+
import { a as ClaudeCodeCliRunOptions, c as ClaudeRateLimitEvent, d as ClaudeUserEvent, i as ClaudeCodeCliPermissionMode, l as ClaudeResultEvent, n as ClaudeCodeCliAgent, o as ClaudeAssistantEvent, r as ClaudeCodeCliAgentOptions, s as ClaudeEvent, u as ClaudeSystemEvent } from "./index-COHwWTg_.mjs";
|
|
6
|
+
import { a as ClaudeCodeSdkExecutable, c as ClaudeCodeSdkSettingSource, i as ClaudeCodeSdkEvent, l as ClaudeCodeSdkSettings, n as ClaudeCodeSdkAgent, o as ClaudeCodeSdkPermissionMode, r as ClaudeCodeSdkAgentOptions, s as ClaudeCodeSdkRunOptions } from "./index-CzvanLE_.mjs";
|
|
7
|
+
import { a as CodexCliRunOptions, c as CodexEvent, d as CodexItemUpdatedEvent, f as CodexThreadStartedEvent, i as CodexCliPermissionMode, l as CodexItemCompletedEvent, m as CodexTurnFailedEvent, n as CodexCliAgent, o as CodexCliSandboxMode, p as CodexTurnCompletedEvent, r as CodexCliAgentOptions, s as CodexErrorEvent, u as CodexItemStartedEvent } from "./index-DP4Jxoax.mjs";
|
|
8
|
+
import { a as CodexSdkItem, i as CodexSdkEvent, n as CodexSdkAgent, o as CodexSdkPermissionMode, r as CodexSdkAgentOptions, s as CodexSdkRunOptions } from "./index-jUwKDQ34.mjs";
|
|
9
|
+
import { a as GeminiCliRunOptions, i as GeminiCliPermissionMode, n as GeminiCliAgent, o as GeminiEvent, r as GeminiCliAgentOptions } from "./index-DNyKelMh.mjs";
|
|
10
|
+
//#region src/core/agent/create-agent.d.ts
|
|
11
|
+
declare function createAgent(type: "claude-code-cli", options?: ClaudeCodeCliAgentOptions): Promise<ClaudeCodeCliAgent>;
|
|
12
|
+
declare function createAgent(type: "claude-code-sdk", options?: ClaudeCodeSdkAgentOptions): Promise<ClaudeCodeSdkAgent>;
|
|
13
|
+
declare function createAgent(type: "codex-cli", options?: CodexCliAgentOptions): Promise<CodexCliAgent>;
|
|
14
|
+
declare function createAgent(type: "codex-sdk", options?: CodexSdkAgentOptions): Promise<CodexSdkAgent>;
|
|
15
|
+
declare function createAgent(type: "gemini-cli", options?: GeminiCliAgentOptions): Promise<GeminiCliAgent>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { type AgentCapabilities, type AgentEvent, type AgentEventHandler, type AgentMetrics, AgentRunError, type AgentType, AgentValidationError, type AnyCompletedRunResult, type AnyRunRequest, type AnyRunResult, type BaseAgent, type BubblewrapSandbox, type BubblewrapSandboxConfig, type CancelledRunResult, type ClaudeAssistantEvent, type ClaudeCodeCliAgent, type ClaudeCodeCliAgentOptions, type ClaudeCodeCliPermissionMode, type ClaudeCodeCliRunOptions, type ClaudeCodeSdkAgent, type ClaudeCodeSdkAgentOptions, type ClaudeCodeSdkEvent, type ClaudeCodeSdkExecutable, type ClaudeCodeSdkPermissionMode, type ClaudeCodeSdkRunOptions, type ClaudeCodeSdkSettingSource, type ClaudeCodeSdkSettings, type ClaudeEvent, type ClaudeRateLimitEvent, type ClaudeResultEvent, type ClaudeSystemEvent, type ClaudeUserEvent, type CodexCliAgent, type CodexCliAgentOptions, type CodexCliPermissionMode, type CodexCliRunOptions, type CodexCliSandboxMode, type CodexErrorEvent, type CodexEvent, type CodexItemCompletedEvent, type CodexItemStartedEvent, type CodexItemUpdatedEvent, type CodexSdkAgent, type CodexSdkAgentOptions, type CodexSdkEvent, type CodexSdkItem, type CodexSdkPermissionMode, type CodexSdkRunOptions, type CodexThreadStartedEvent, type CodexTurnCompletedEvent, type CodexTurnFailedEvent, type CompletedRunResult, type Container, type ContainerBase, type ContainerConfig, type ContainerConfigBase, ContainerCreateError, ContainerDiffError, ContainerDisposedError, ContainerError, ContainerExecError, type ContainerExecution, type ContainerFileSystem, type ContainerIdentity, type ContainerLifecycle, ContainerNotRunningError, type ContainerObservability, ContainerStartError, type ContainerStatus, type ContainerType, type ContentPart, type DockerBuildBase, type DockerBuildConfig, type DockerContainer, type DockerContainerBase, type DockerContainerConfig, type DockerProviderConfig, type E2BConnectConfig, type E2BConnectionConfig, type E2BContainer, type E2BContainerBase, type E2BContainerConfig, type E2BCreateConfig, type E2BProviderConfig, type EnsureDisjoint, type ExecOptions, type ExecResult, type FailedRunResult, type GeminiCliAgent, type GeminiCliAgentOptions, type GeminiCliPermissionMode, type GeminiCliRunOptions, type GeminiEvent, type ImageContentPart, type JsonSchema, type JsonSchemaRunRequest, type McpServerConfig, type MessageEvent, type OutputSchema, type PodmanBuildBase, type PodmanBuildConfig, type PodmanContainer, type PodmanContainerBase, type PodmanContainerConfig, type PodmanProviderConfig, type PortMapping, type ReasoningEvent, type RunError, type RunProcessInfo, type RunRequest, type RunResult, type RunResultBase, type RunStats, type RunStatus, type RunTiming, type Sandbox, type SandboxBase, type SandboxConfig, type SandboxConfigBase, type SandboxExecution, type SandboxIdentity, type SandboxLifecycle, type SandboxStatus, type SandboxType, type SessionEndEvent, type SessionStartEvent, type StderrEvent, type StopReason, type StructuredRunRequest, type TextContentPart, type ToolCallEvent, type ToolResultEvent, type VolumeMount, type WorkdirChangeKind, type WorkdirDiff, type WorkdirDiffStats, type WorkdirFileChange, type WorkdirSnapshot, type WorkdirSnapshotOptions, type ZodRunRequest, agentCapabilitiesSchema, createAgent, createContainer, createSandbox, eventSchema };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./types-CwvWHEpy.mjs";import{a as n,i as r,n as i,o as a,r as o,s,t as c}from"./errors-XV0frS3r.mjs";import{createContainer as l}from"./container/index.mjs";import{t as u}from"./sandbox-DeKpyenZ.mjs";import{n as d,u as f}from"./schemas-BM6qORw3.mjs";const p=(e,t)=>{if(!(e instanceof Error)||!e.message.includes(t))return!1;let n=typeof e==`object`&&e&&`code`in e?e.code:void 0;return n===`ERR_MODULE_NOT_FOUND`||n===`MODULE_NOT_FOUND`},m=(t,n,r)=>{throw p(r,n)?new e(`Agent type "${t}" requires the optional peer dependency "${n}". Install it to use this adapter.`):r};async function h(t,n){switch(t){case`claude-code-cli`:{let{createClaudeCodeCliAgent:e}=await import(`./adapters/claude-code-cli/index.mjs`);return e(n)}case`claude-code-sdk`:{let e=n;try{let{createClaudeCodeSdkAgent:t}=await import(`./adapters/claude-code-sdk/index.mjs`);return t(e)}catch(e){return m(`claude-code-sdk`,`@anthropic-ai/claude-agent-sdk`,e)}}case`codex-cli`:{let{createCodexCliAgent:e}=await import(`./adapters/codex-cli/index.mjs`);return e(n)}case`codex-sdk`:{let e=n;try{let{createCodexSdkAgent:t}=await import(`./adapters/codex-sdk/index.mjs`);return t(e)}catch(e){return m(`codex-sdk`,`@openai/codex-sdk`,e)}}case`gemini-cli`:{let{createGeminiCliAgent:e}=await import(`./adapters/gemini-cli/index.mjs`);return e(n)}default:throw new e(`Unsupported agent type.`)}}export{t as AgentRunError,e as AgentValidationError,c as ContainerCreateError,i as ContainerDiffError,o as ContainerDisposedError,r as ContainerError,n as ContainerExecError,a as ContainerNotRunningError,s as ContainerStartError,f as agentCapabilitiesSchema,h as createAgent,l as createContainer,u as createSandbox,d as eventSchema};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./util-CGg8cK92.mjs";import{a as t,n,o as r,r as i,s as a,t as o}from"./errors-XV0frS3r.mjs";import{t as s}from"./spawner-BJesLc8I.mjs";import{i as c,n as l,r as u,t as d}from"./diff-BCfLDXNN.mjs";import{execFile as f}from"node:child_process";import{isAbsolute as p,join as m,posix as h}from"node:path";import{promisify as g}from"node:util";import{mkdtemp as _,rm as v,writeFile as y}from"node:fs/promises";import{tmpdir as b}from"node:os";import{randomBytes as x}from"node:crypto";const S=g(f),C=()=>`cw-${x(6).toString(`hex`)}`,w=async(e,t,n)=>{let r=await S(e,t,{encoding:`utf8`,timeout:n?.timeoutMs,signal:n?.signal,maxBuffer:50*1024*1024});return{stdout:r.stdout,stderr:r.stderr}},T=async(t,n)=>{let r=n.tag??`cw-build-${x(4).toString(`hex`)}`,i=[`build`,`-t`,r];if(n.args)for(let[e,t]of Object.entries(n.args))i.push(`--build-arg`,`${e}=${t}`);`dockerfile`in n&&n.dockerfile&&(i.push(`-f`,n.dockerfile),i.push(n.context??`.`));let a;if(`content`in n&&n.content){a=await _(m(b(),`cw-oci-build-`));let e=m(a,`Dockerfile`);await y(e,n.content,{encoding:`utf8`,mode:384}),i.push(`-f`,e),i.push(n.context??a)}try{await w(t,i)}catch(t){throw new o(`Image build failed: ${e(t)}`)}finally{a&&await v(a,{recursive:!0,force:!0}).catch(()=>{})}return r},E=async(e,t,n)=>{let r=await Promise.all(n.map(async n=>{try{let{container:r,protocol:i=`tcp`}=n,{stdout:a}=await w(e,[`port`,t,`${r}/${i}`]),o=/:(\d+)$/m.exec(a.trim());if(o?.[1])return[r,Number(o[1])]}catch{}})),i=new Map;for(let e of r)e&&i.set(e[0],e[1]);return i},D=(e,t)=>({spawn:(n,r,i={})=>{let a=[`exec`,`-i`];if(i.cwd&&a.push(`-w`,i.cwd),i.env)for(let[e,t]of Object.entries(i.env))a.push(`-e`,`${e}=${t}`);return a.push(e,n,...r),s.spawn(t,a,{stdio:i.stdio})}}),O=(e,t)=>{let n=h.relative(e,t);return n===``||!n.startsWith(`..`)&&!h.isAbsolute(n)},k=(e,t)=>{if(!e||e.length===0)return;let n=h.normalize(t),r;for(let t of e){if(!p(t.source))continue;let e=h.normalize(t.target);O(e,n)&&(!r||e.length>h.normalize(r.target).length)&&(r=t)}if(!r)return;let i=h.relative(h.normalize(r.target),n);return i===``?r.source:m(r.source,...i.split(`/`))},A=async(f,p,m)=>{let{binary:g,builtImage:_,containerName:v,workdir:y,user:b,network:x,platform:S,env:T,ports:O,mounts:A,extraArgs:j,image:M}=p,N=v??C(),P=[`create`,`--name`,N];if(b&&P.push(`--user`,b),x&&P.push(`--network`,x),S&&P.push(`--platform`,S),T)for(let[e,t]of Object.entries(T))P.push(`-e`,`${e}=${t}`);if(O)for(let e of O){let{host:t,container:n,protocol:r=`tcp`}=e;P.push(`-p`,`${t??``}:${n}/${r}`)}if(A)for(let e of A){let{readonly:t,source:n,target:r}=e,i=t?`ro`:`rw`;P.push(`-v`,`${n}:${r}:${i}`)}j&&P.push(...j),P.push(M,`sleep`,`infinity`);let F;try{let{stdout:e}=await w(g,P);F=e.trim()}catch(t){throw new o(`Container create failed: ${e(t)}`)}let I=`created`,L=new Map,R=()=>{if(I===`disposed`)throw new i},z=()=>{if(R(),I!==`running`)throw new r},B=D(F,g),V=l({owner:{},workdir:y,materialize:async(t,r)=>{R();let i=k(A,t);if(i){await d(i,r);return}z();try{await w(g,[`exec`,F,`sh`,`-c`,`test -d ${u(t)}`])}catch{throw new n(`Target path is not a directory: ${t}`)}try{await w(g,[`cp`,`${F}:${t}/.`,r])}catch(r){throw new n(`Failed to materialize container path ${t}: ${e(r)}`)}}}),H={get type(){return f},get id(){return F},get name(){return N},get config(){return m},get status(){return I},get workdir(){return y},get spawner(){return B},async start(){if(R(),I!==`running`){try{await w(g,[`start`,F])}catch(t){throw new a(`Container start failed: ${e(t)}`)}try{await w(g,[`exec`,F,`mkdir`,`-p`,y])}catch(t){try{await w(g,[`stop`,`-t`,`0`,F]),I=`stopped`}catch{try{let{stdout:e}=await w(g,[`inspect`,`--format`,`{{.State.Status}}`,F]);I=e.trim()===`running`?`running`:`stopped`}catch{I=`disposed`}}throw new a(`Container start failed: ${e(t)}`)}I=`running`,O?.length&&(L=await E(g,F,O))}},async stop(){if(R(),I===`running`){try{await w(g,[`stop`,`-t`,`2`,F])}catch{try{let{stdout:e}=await w(g,[`inspect`,`--format`,`{{.State.Status}}`,F]);if(e.trim()===`running`)return}catch{I=`disposed`;return}}I=`stopped`}},async dispose(){if(I!==`disposed`){try{await w(g,[`stop`,`-t`,`0`,F])}catch{}try{await w(g,[`rm`,`-f`,F])}catch{}_&&await w(g,[`rmi`,M]).catch(()=>{}),await V.disposeSnapshots().catch(()=>{}),I=`disposed`}},async exec(e,t,n={}){z();let r=[`exec`];if(n.cwd&&r.push(`-w`,n.cwd),n.env)for(let[e,t]of Object.entries(n.env))r.push(`-e`,`${e}=${t}`);r.push(F,e,...t);try{let{stdout:e,stderr:t}=await w(g,r,{timeoutMs:n.timeoutMs,signal:n.signal});return{exitCode:0,stdout:e,stderr:t}}catch(e){if(c(e))return{exitCode:typeof e.code==`number`?e.code:-1,stdout:String(e.stdout??``),stderr:String(e.stderr??``)};throw e}},async copyTo(e,t){z(),await w(g,[`cp`,e,`${F}:${t}`])},async copyFrom(e,t){z(),await w(g,[`cp`,`${F}:${e}`,t])},async writeFile(e,n){z();let r=h.isAbsolute(e)?e:h.resolve(y,e),i=h.dirname(r),a=typeof n==`string`?Buffer.from(n,`utf8`):n,o=[`exec`,`-i`];b&&o.push(`--user`,b),o.push(F,`sh`,`-c`,`mkdir -p ${u(i)} && cat > ${u(r)}`);let c=s.spawn(g,o,{stdio:[`pipe`,`ignore`,`ignore`]});c.stdin?.write?.(a),c.stdin?.end();let l=await c.wait();if(l.exitCode!==0)throw new t(`writeFile failed for ${r} (exit ${l.exitCode})`)},async readFile(e){z();let t=h.isAbsolute(e)?e:h.resolve(y,e),{stdout:n}=await w(g,[`exec`,F,`cat`,t]);return n},async fileExists(e){z();let t=h.isAbsolute(e)?e:h.resolve(y,e);try{return await w(g,[`exec`,F,`test`,`-e`,t]),!0}catch{return!1}},async mkdir(e){z();let t=h.isAbsolute(e)?e:h.resolve(y,e);await w(g,[`exec`,F,`mkdir`,`-p`,t])},async execShell(e,t={}){return H.exec(`sh`,[`-c`,e],t)},async logs(e={}){R();let t=[`logs`];e.tail!==void 0&&t.push(`--tail`,String(e.tail)),t.push(F);let{stdout:n}=await w(g,t);return n},async syncStatus(){R();try{let{stdout:e}=await w(g,[`inspect`,`--format`,`{{.State.Status}}`,F]),t=e.trim();I=t===`running`?`running`:t===`created`?`created`:`stopped`}catch{I=`disposed`}return I},async snapshotWorkdir(e={}){return V.snapshotWorkdir(e)},async diffWorkdir(e){return V.diffWorkdir(e)},async releaseWorkdirSnapshot(e){return V.releaseWorkdirSnapshot(e)},getMappedPort(e){return L.get(e)},[Symbol.asyncDispose](){return H.dispose()}};return H},j=async(e,t)=>{if(t.image)return t.image;if(t.build)return T(e,t.build);throw new o(`Either image or build must be provided.`)};export{j as n,A as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as SandboxBase, c as SandboxExecution, d as SandboxStatus, f as SandboxType, i as Sandbox, l as SandboxIdentity, n as BubblewrapSandbox, o as SandboxConfig, r as BubblewrapSandboxConfig, s as SandboxConfigBase, t as createSandbox, u as SandboxLifecycle } from "../index-DCaZeLrI.mjs";
|
|
2
|
+
export { BubblewrapSandbox, BubblewrapSandboxConfig, Sandbox, SandboxBase, SandboxConfig, SandboxConfigBase, SandboxExecution, SandboxIdentity, SandboxLifecycle, SandboxStatus, SandboxType, createSandbox };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"../sandbox-DeKpyenZ.mjs";export{e as createSandbox};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./util-CGg8cK92.mjs";import{t}from"./env-Dkd8Sgjf.mjs";import{t as n}from"./spawner-BJesLc8I.mjs";import{execFile as r}from"node:child_process";import{posix as i}from"node:path";import{promisify as a}from"node:util";const o=`bwrap`,s=[`/tmp`],c=a(r),l=(e,t)=>e.binds?.some(e=>e.target===t)??!1,u=(e,t)=>{let n=i.relative(e,t);return n===``||!n.startsWith(`..`)&&!i.isAbsolute(n)},d=(e,t)=>e.target.length-t.target.length,f=e=>{let t=l(e,e.workdir)?[...e.binds??[]]:[{source:e.workdir,target:e.workdir},...e.binds??[]],n=e.tmpfs??s,r=t.filter(e=>!n.some(t=>u(t,e.target))).toSorted(d),i=t.filter(e=>n.some(t=>u(t,e.target))).toSorted(d);return[...r,...i]},p=e=>{let t=[`--ro-bind`,`/`,`/`];for(let n of f(e))t.push(n.readonly?`--ro-bind`:`--bind`,n.source,n.target);return t},m=(e,t)=>{let n=[];(e.clearEnv??!0)&&n.push(`--clearenv`);for(let t of e.unsetEnv??[])n.push(`--unsetenv`,t);let r={...e.setEnv,...t.env};for(let[e,t]of Object.entries(r))n.push(`--setenv`,e,t);return n},h=e=>{let t=[`--die-with-parent`,`--new-session`];return(e.unshareAll??!0)&&t.push(`--unshare-all`),e.shareNetwork&&t.push(`--share-net`),e.uid!==void 0&&t.push(`--uid`,String(e.uid)),e.gid!==void 0&&t.push(`--gid`,String(e.gid)),e.hostname&&t.push(`--hostname`,e.hostname),t},g=e=>{let t=[`--ro-bind`,`/`,`/`];e.proc!==!1&&t.push(`--proc`,e.proc??`/proc`),e.dev!==!1&&t.push(`--dev`,e.dev??`/dev`);for(let n of e.tmpfs??s)t.push(`--tmpfs`,n);t.push(...p(e).slice(3));for(let n of e.remountReadonly??[])t.push(`--remount-ro`,n);return t},_=(e,t,n,r={})=>[...h(e),...g(e),...m(e,r),`--chdir`,r.cwd??e.workdir,...e.args??[],`--`,t,...n],v=async n=>{try{await c(n,[`--version`],{env:t(),encoding:`utf8`})}catch(t){throw Error(`Bubblewrap start failed: ${e(t)}`)}},y=(e,n,r,i)=>({spawn(a,s,c={}){return n(),r(i.spawn(e.binary??o,_(e,a,s,c),{env:t(),stdio:c.stdio}))}}),b=async(e,t=n)=>{let r=`created`,i=new Set,a=()=>{if(r===`disposed`)throw Error(`Bubblewrap sandbox has been disposed.`)},s=()=>{if(a(),r!==`running`)throw Error(`Bubblewrap sandbox is not running.`)},c=e=>{let t={process:e,waitPromise:e.wait().finally(()=>{i.delete(t)})};return i.add(t),{...e,wait:()=>t.waitPromise}},l=async()=>{let e=Array.from(i,e=>(e.process.kill(`SIGKILL`),e.waitPromise));await Promise.allSettled(e)},u=y(e,s,c,t),d={type:`bubblewrap`,config:e,get status(){return r},get workdir(){return e.workdir},get spawner(){return u},async start(){a(),r!==`running`&&(await v(e.binary??o),r=`running`)},async stop(){a(),r===`running`&&(r=`stopped`,await l())},async dispose(){r!==`disposed`&&(r=`disposed`,await l())},[Symbol.asyncDispose](){return d.dispose()}};return d};async function x(e){switch(e.type){case`bubblewrap`:return b(e)}throw Error(`Unsupported sandbox type.`)}export{x as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { C as OutputSchema, D as imageContentPartSchema, E as contentPartSchema, O as textContentPartSchema, S as McpServerConfig, T as agentCapabilitiesSchema, _ as toolResultEventSchema, a as SessionStartEvent, b as ImageContentPart, c as ToolResultEvent, d as messageEventSchema, f as reasoningEventSchema, g as toolCallEventSchema, h as stderrEventSchema, i as SessionEndEvent, l as baseEventSchema, m as sessionStartEventSchema, n as MessageEvent, o as StderrEvent, p as sessionEndEventSchema, r as ReasoningEvent, s as ToolCallEvent, t as AgentEvent, u as eventSchema, v as AgentCapabilities, w as TextContentPart, x as JsonSchema, y as ContentPart } from "../events-D31_b0sA.mjs";
|
|
2
|
+
export { type AgentCapabilities, type AgentEvent, type ContentPart, type ImageContentPart, type JsonSchema, type McpServerConfig, type MessageEvent, type OutputSchema, type ReasoningEvent, type SessionEndEvent, type SessionStartEvent, type StderrEvent, type TextContentPart, type ToolCallEvent, type ToolResultEvent, agentCapabilitiesSchema, baseEventSchema, contentPartSchema, eventSchema, imageContentPartSchema, messageEventSchema, reasoningEventSchema, sessionEndEventSchema, sessionStartEventSchema, stderrEventSchema, textContentPartSchema, toolCallEventSchema, toolResultEventSchema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,p as c,r as l,s as u,t as d,u as f}from"../schemas-BM6qORw3.mjs";export{f as agentCapabilitiesSchema,d as baseEventSchema,n as contentPartSchema,o as eventSchema,r as imageContentPartSchema,l as messageEventSchema,i as reasoningEventSchema,e as sessionEndEventSchema,s as sessionStartEventSchema,u as stderrEventSchema,c as textContentPartSchema,t as toolCallEventSchema,a as toolResultEventSchema};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as e}from"zod/v4";const t=e.object({type:e.literal(`text`),text:e.string()}),n=e.object({type:e.literal(`image`),path:e.string(),mediaType:e.string().optional()}),r=e.discriminatedUnion(`type`,[t,n]),i=e.object({structuredOutput:e.boolean(),sessionResume:e.boolean(),imageInput:e.boolean(),mcp:e.boolean(),eventStreaming:e.boolean(),sessionFork:e.boolean().optional()}),a=e.object({id:e.string(),runId:e.string(),timestamp:e.date()}),o=a.extend({type:e.literal(`session-start`),requestedSessionId:e.string().optional(),sessionId:e.string().optional(),resumed:e.boolean()}),s=a.extend({type:e.literal(`message`),sessionId:e.string().optional(),model:e.string().nullable(),role:e.enum([`system`,`user`,`assistant`]),content:e.array(r),text:e.string().optional()}),c=a.extend({type:e.literal(`reasoning`),sessionId:e.string().optional(),model:e.string().nullable(),content:e.array(r),text:e.string().optional()}),l=a.extend({type:e.literal(`tool-call`),sessionId:e.string().optional(),model:e.string().nullable(),toolCallId:e.string(),toolName:e.string(),input:e.unknown().optional()}),u=a.extend({type:e.literal(`tool-result`),sessionId:e.string().optional(),toolCallId:e.string(),toolName:e.string().optional(),input:e.unknown().optional(),output:e.unknown(),isError:e.boolean().optional(),error:e.string().optional()}),d=a.extend({type:e.literal(`stderr`),sessionId:e.string().optional(),text:e.string()}),f=a.extend({type:e.literal(`session-end`),sessionId:e.string().optional(),status:e.enum([`completed`,`failed`,`cancelled`]),error:e.string().optional()}),p=e.discriminatedUnion(`type`,[o,s,c,l,u,d,f]);export{f as a,l as c,r as d,n as f,c as i,u as l,p as n,o,t as p,s as r,d as s,a as t,i as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{spawn as e}from"node:child_process";const t=e=>({async*[Symbol.asyncIterator](){for await(let t of e){if(t instanceof Buffer){yield new Uint8Array(t);continue}if(typeof t==`string`){yield new TextEncoder().encode(t);continue}if(t instanceof Uint8Array){yield t;continue}throw Error(`Unsupported stdout/stderr chunk type: ${typeof t}`)}}}),n={spawn:(n,r,i={})=>{let a=e(n,r,{cwd:i.cwd,env:i.env,stdio:i.stdio}),o=new Promise((e,t)=>{let n=(t,n)=>{a.removeListener(`error`,r),e({exitCode:t,signal:n})},r=e=>{a.removeListener(`close`,n),t(e)};a.once(`error`,r),a.once(`close`,n)});return{stdout:a.stdout?t(a.stdout):null,stderr:a.stderr?t(a.stderr):null,stdin:a.stdin?{write:e=>a.stdin?.write(e),end:()=>a.stdin?.end()}:null,kill:e=>a.kill(e),wait:()=>o}}};export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=e=>{let t;for(let[,n]of e)n.toolName===`StructuredOutput`&&n.input!==void 0&&(t=n.input);return t},t=(t,n,r,i)=>{if(t!==void 0)return{value:t};if(!n.schemaRequested)return{};let a=e(n.toolCalls);return a===void 0?r.isSuccess?{error:{kind:`parse`,message:i}}:{}:{value:a}};export{t};
|