@saturn-universe/tools 0.0.0-stage → 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.
- package/LICENSE +661 -0
- package/dist/container-sandbox.d.ts +168 -0
- package/dist/container-sandbox.js +1241 -0
- package/dist/counter.d.ts +5 -0
- package/dist/counter.js +82 -0
- package/dist/data-review.d.ts +4 -0
- package/dist/data-review.js +146 -0
- package/dist/execution-backend.d.ts +55 -0
- package/dist/execution-backend.js +339 -0
- package/dist/executor.d.ts +25 -0
- package/dist/executor.js +978 -0
- package/dist/file-window.d.ts +3 -0
- package/dist/file-window.js +12 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +17 -0
- package/dist/mcp-headers.d.ts +3 -0
- package/dist/mcp-headers.js +51 -0
- package/dist/mcp-http.d.ts +3 -0
- package/dist/mcp-http.js +253 -0
- package/dist/mcp-stdio.d.ts +2 -0
- package/dist/mcp-stdio.js +147 -0
- package/dist/mcp-wire.d.ts +33 -0
- package/dist/mcp-wire.js +85 -0
- package/dist/mcp.d.ts +19 -0
- package/dist/mcp.js +325 -0
- package/dist/path-containment.d.ts +3 -0
- package/dist/path-containment.js +11 -0
- package/dist/planner.d.ts +3 -0
- package/dist/planner.js +162 -0
- package/dist/process-manager.d.ts +67 -0
- package/dist/process-manager.js +423 -0
- package/dist/process-output.d.ts +34 -0
- package/dist/process-output.js +162 -0
- package/dist/process-worker.d.ts +1 -0
- package/dist/process-worker.js +202 -0
- package/dist/registry.d.ts +33 -0
- package/dist/registry.js +227 -0
- package/dist/search.d.ts +9 -0
- package/dist/search.js +96 -0
- package/dist/team.d.ts +36 -0
- package/dist/team.js +284 -0
- package/dist/text-patch.d.ts +15 -0
- package/dist/text-patch.js +81 -0
- package/dist/todo.d.ts +3 -0
- package/dist/todo.js +105 -0
- package/dist/workspace-discovery.d.ts +42 -0
- package/dist/workspace-discovery.js +404 -0
- package/dist/workspace-snapshot.d.ts +28 -0
- package/dist/workspace-snapshot.js +371 -0
- package/dist/workspace.d.ts +22 -0
- package/dist/workspace.js +1819 -0
- package/package.json +16 -3
- package/README.md +0 -3
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import type { ChildProcess } from 'node:child_process';
|
|
2
|
+
import type { AgentSessionId, RunId, SandboxBackendKind, SandboxNetworkMode, SandboxReadonlyMount, SandboxResourceLimits } from '@saturn-universe/core';
|
|
3
|
+
import type { ExecutionBackend, ExecutionTarget } from './execution-backend.js';
|
|
4
|
+
import type { ProcessStartInput } from './process-manager.js';
|
|
5
|
+
export type ContainerBackendKind = Exclude<SandboxBackendKind, 'host'>;
|
|
6
|
+
export interface ContainerStartSpec {
|
|
7
|
+
readonly backend: ContainerBackendKind;
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly image: string;
|
|
10
|
+
readonly workDirHost: string;
|
|
11
|
+
readonly workDirContainer: string;
|
|
12
|
+
readonly workDirReadOnly?: boolean;
|
|
13
|
+
readonly network: SandboxNetworkMode;
|
|
14
|
+
readonly networkName?: string;
|
|
15
|
+
readonly proxyUrl?: string;
|
|
16
|
+
readonly capAdd?: readonly string[];
|
|
17
|
+
readonly readonlyMounts?: readonly SandboxReadonlyMount[];
|
|
18
|
+
readonly kvm?: boolean;
|
|
19
|
+
readonly tmpfsSizeMb?: number;
|
|
20
|
+
readonly resources?: SandboxResourceLimits;
|
|
21
|
+
readonly user?: string;
|
|
22
|
+
readonly workspaceHash: string;
|
|
23
|
+
readonly runId: string;
|
|
24
|
+
readonly memberId: string;
|
|
25
|
+
readonly extraLabels?: Readonly<Record<string, string>>;
|
|
26
|
+
}
|
|
27
|
+
export interface ContainerExecStreamOptions {
|
|
28
|
+
readonly containerId: string;
|
|
29
|
+
readonly command: readonly string[];
|
|
30
|
+
readonly workdir: string;
|
|
31
|
+
readonly stdin?: string;
|
|
32
|
+
readonly timeoutMs: number;
|
|
33
|
+
readonly signal: AbortSignal;
|
|
34
|
+
readonly onStdout: (chunk: Buffer) => Promise<void> | void;
|
|
35
|
+
readonly onStderr: (chunk: Buffer) => Promise<void> | void;
|
|
36
|
+
readonly shouldStop?: () => boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface ContainerExecStreamResult {
|
|
39
|
+
readonly launched: boolean;
|
|
40
|
+
readonly exitCode: number | null;
|
|
41
|
+
readonly signal: string | null;
|
|
42
|
+
readonly timedOut?: boolean;
|
|
43
|
+
readonly cancelled?: boolean;
|
|
44
|
+
readonly terminationConfirmed?: boolean;
|
|
45
|
+
readonly startError?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface ContainerCaptureResult {
|
|
48
|
+
readonly exitCode: number | null;
|
|
49
|
+
readonly stdout: Buffer;
|
|
50
|
+
readonly stderr: Buffer;
|
|
51
|
+
readonly truncated: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface ManagedContainerInfo {
|
|
54
|
+
readonly id: string;
|
|
55
|
+
readonly name: string;
|
|
56
|
+
readonly labels: Readonly<Record<string, string>>;
|
|
57
|
+
}
|
|
58
|
+
export interface ManagedNetworkInfo {
|
|
59
|
+
readonly id: string;
|
|
60
|
+
readonly name: string;
|
|
61
|
+
readonly labels: Readonly<Record<string, string>>;
|
|
62
|
+
}
|
|
63
|
+
export interface TargetSeedMount {
|
|
64
|
+
readonly hostPath: string;
|
|
65
|
+
readonly containerPath: string;
|
|
66
|
+
}
|
|
67
|
+
export interface TargetContainerStartSpec {
|
|
68
|
+
readonly backend: ContainerBackendKind;
|
|
69
|
+
readonly name: string;
|
|
70
|
+
readonly image: string;
|
|
71
|
+
readonly workDirHost: string;
|
|
72
|
+
readonly workDirContainer: string;
|
|
73
|
+
readonly networkName: string;
|
|
74
|
+
readonly networkAlias: string;
|
|
75
|
+
readonly command: string;
|
|
76
|
+
readonly capAdd?: readonly string[];
|
|
77
|
+
readonly allowedCapabilities?: readonly string[];
|
|
78
|
+
readonly seedMounts?: readonly TargetSeedMount[];
|
|
79
|
+
readonly tmpfsSizeMb?: number;
|
|
80
|
+
readonly resources?: SandboxResourceLimits;
|
|
81
|
+
readonly user?: string;
|
|
82
|
+
readonly workspaceHash: string;
|
|
83
|
+
readonly runId: string;
|
|
84
|
+
readonly targetName: string;
|
|
85
|
+
readonly extraLabels?: Readonly<Record<string, string>>;
|
|
86
|
+
}
|
|
87
|
+
export interface ContainerInspectState {
|
|
88
|
+
readonly exists: boolean;
|
|
89
|
+
readonly running: boolean;
|
|
90
|
+
readonly status?: string;
|
|
91
|
+
readonly exitCode?: number;
|
|
92
|
+
readonly error?: string;
|
|
93
|
+
}
|
|
94
|
+
export interface ContainerLogsResult {
|
|
95
|
+
readonly logs: string;
|
|
96
|
+
readonly truncated: boolean;
|
|
97
|
+
}
|
|
98
|
+
export interface ContainerRunner {
|
|
99
|
+
checkRuntime(backend: ContainerBackendKind): Promise<{
|
|
100
|
+
readonly ok: boolean;
|
|
101
|
+
readonly reason?: string;
|
|
102
|
+
}>;
|
|
103
|
+
hasImage(image: string): Promise<boolean>;
|
|
104
|
+
listManagedContainers(labels: Readonly<Record<string, string>>): Promise<readonly ManagedContainerInfo[]>;
|
|
105
|
+
startContainer(spec: ContainerStartSpec): Promise<{
|
|
106
|
+
readonly containerId: string;
|
|
107
|
+
}>;
|
|
108
|
+
execInContainer(options: ContainerExecStreamOptions): Promise<ContainerExecStreamResult>;
|
|
109
|
+
execCaptureBuffer(containerId: string, command: readonly string[], options?: {
|
|
110
|
+
readonly workdir?: string;
|
|
111
|
+
readonly maxBytes?: number;
|
|
112
|
+
readonly timeoutMs?: number;
|
|
113
|
+
readonly signal?: AbortSignal;
|
|
114
|
+
}): Promise<ContainerCaptureResult>;
|
|
115
|
+
spawnExec(containerId: string, command: readonly string[], workdir: string, signal: AbortSignal): ChildProcess;
|
|
116
|
+
removeContainer(containerId: string): Promise<void>;
|
|
117
|
+
buildExecProcessInput(containerId: string, workdir: string, input: ProcessStartInput, executionKey?: string): ProcessStartInput;
|
|
118
|
+
createInternalNetwork?(name: string, labels: Readonly<Record<string, string>>): Promise<void>;
|
|
119
|
+
connectNetwork?(networkName: string, containerId: string, aliases?: readonly string[]): Promise<void>;
|
|
120
|
+
disconnectNetwork?(networkName: string, containerId: string): Promise<void>;
|
|
121
|
+
removeNetwork?(networkName: string): Promise<void>;
|
|
122
|
+
listManagedNetworks?(labels: Readonly<Record<string, string>>): Promise<readonly ManagedNetworkInfo[]>;
|
|
123
|
+
startTargetContainer?(spec: TargetContainerStartSpec): Promise<{
|
|
124
|
+
readonly containerId: string;
|
|
125
|
+
}>;
|
|
126
|
+
inspectContainerState?(containerId: string): Promise<ContainerInspectState>;
|
|
127
|
+
getContainerLogs?(containerId: string, options?: {
|
|
128
|
+
readonly tailLines?: number;
|
|
129
|
+
readonly maxBytes?: number;
|
|
130
|
+
}): Promise<ContainerLogsResult>;
|
|
131
|
+
}
|
|
132
|
+
export interface ContainerSandboxSession {
|
|
133
|
+
readonly runId: RunId;
|
|
134
|
+
readonly agentSessionId: AgentSessionId;
|
|
135
|
+
readonly memberId: string;
|
|
136
|
+
readonly containerId: string;
|
|
137
|
+
readonly hostWorkDir: string;
|
|
138
|
+
readonly containerWorkDir: string;
|
|
139
|
+
readonly readonly: boolean;
|
|
140
|
+
readonly readonlyMounts: readonly SandboxReadonlyMount[];
|
|
141
|
+
readonly backend: ContainerBackendKind;
|
|
142
|
+
readonly image: string;
|
|
143
|
+
readonly network: SandboxNetworkMode;
|
|
144
|
+
}
|
|
145
|
+
export interface ContainerSandboxBackendOptions {
|
|
146
|
+
readonly runner: ContainerRunner;
|
|
147
|
+
readonly hostFallback: ExecutionBackend;
|
|
148
|
+
readonly resolveSession: (target?: ExecutionTarget) => ContainerSandboxSession | undefined;
|
|
149
|
+
readonly failClosed?: boolean | ((target?: ExecutionTarget) => boolean);
|
|
150
|
+
readonly resolveRecoveryContext?: (target?: ExecutionTarget) => Pick<ContainerSandboxSession, 'hostWorkDir' | 'containerWorkDir' | 'readonly' | 'readonlyMounts'> | undefined;
|
|
151
|
+
readonly recoverSession?: (target?: ExecutionTarget) => Promise<ContainerSandboxSession | undefined>;
|
|
152
|
+
readonly onAfterCommand?: (session: ContainerSandboxSession) => Promise<string | void>;
|
|
153
|
+
}
|
|
154
|
+
export declare const DEFAULT_ALLOWED_TARGET_CAPABILITIES: readonly ["SYS_CHROOT"];
|
|
155
|
+
export declare const CONTAINER_PROCESS_LAUNCH_SCRIPT: string;
|
|
156
|
+
export declare const CONTAINER_PROCESS_STOP_SCRIPT: string;
|
|
157
|
+
export declare function normalizeReadonlyContainerPath(containerPath: string): string;
|
|
158
|
+
export declare function validateReadonlyMount(mount: SandboxReadonlyMount): SandboxReadonlyMount;
|
|
159
|
+
export declare function validateTargetName(rawName?: string): string;
|
|
160
|
+
export declare function validateTargetCapabilities(requested?: readonly string[], allowed?: readonly string[]): readonly string[];
|
|
161
|
+
export declare function validateTargetSeedFilePath(containerPath: string): string;
|
|
162
|
+
export declare function buildTargetDockerRunArgs(spec: TargetContainerStartSpec): string[];
|
|
163
|
+
export declare function buildDockerRunArgs(spec: ContainerStartSpec): string[];
|
|
164
|
+
export declare function dockerClientEnvironment(base?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
165
|
+
export declare function createDockerContainerRunner(dockerBinary?: string): ContainerRunner;
|
|
166
|
+
export declare function hostPathToContainerPath(session: ContainerSandboxSession, hostOrContainerPath: string): string;
|
|
167
|
+
export declare function containerPathToHostPath(session: ContainerSandboxSession, suppliedPath: string): string | undefined;
|
|
168
|
+
export declare function createContainerSandboxBackend({ runner, hostFallback, resolveSession, failClosed, resolveRecoveryContext, recoverSession, onAfterCommand, }: ContainerSandboxBackendOptions): ExecutionBackend;
|