@plimsollmark/client 0.14.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.
@@ -0,0 +1,316 @@
1
+ // The piece both add-ons share: one sandbox per conversation, behind a key the
2
+ // framework supplies (a Trigger.dev run id, a Mastra thread id). It is the
3
+ // framework-neutral half of Trigger.dev's code-sandbox recipe: warm at the start
4
+ // of a turn without blocking, reuse for every executeCode call, dispose when the
5
+ // conversation goes to sleep.
6
+ //
7
+ // On a daemon that keeps sessions (Describe's supportsSessions: docker with a
8
+ // project image, openshell) a key holds one plimsoll session, and every call is a
9
+ // cell: code run in an interpreter the session keeps alive, so variables and
10
+ // loaded data survive between calls as they do in a notebook, and the files a call
11
+ // is given or writes stay in the work directory. On any other daemon, and for a
12
+ // call without a key, each call runs in a fresh sandbox through a small runner that
13
+ // prints the last expression the same way; nothing persists. The tool's output says
14
+ // which, so the model is never told state survived when it did not. A daemon without
15
+ // projects (wasm) runs a fresh call as a JavaScript snippet, and refuses Python and
16
+ // files before sending anything.
17
+ //
18
+ // Whether earlier state exists is something only the sandbox knows: this instance
19
+ // forgets a key when it is disposed or idles out, and a conversation that resumes
20
+ // in another process starts with a new instance. So a call says what is new rather
21
+ // than what was lost: freshInterpreter whenever its interpreter just started,
22
+ // freshSandbox whenever it is the first answered call in a newly opened sandbox,
23
+ // the conversation's first call included.
24
+ import { PlimsollClient } from "./client.js";
25
+ import { PlimsollError } from "./errors.js";
26
+ export const DEFAULT_LANGUAGES = ["python", "javascript"];
27
+ /** @internal A fresh call on a daemon without projects: the code as a snippet, its last value printed. Node and QuickJS alike. */
28
+ export function snippetRunner(code) {
29
+ return [
30
+ "(() => {",
31
+ " const show = (v) => {",
32
+ ' if (typeof require === "function") { try { return require("node:util").inspect(v, { depth: 4 }); } catch (_) {} }',
33
+ " try { const s = JSON.stringify(v); if (s !== undefined) return s; } catch (_) {}",
34
+ " return String(v);",
35
+ " };",
36
+ ` const v = (0, eval)(${JSON.stringify(code)});`,
37
+ " Promise.resolve(v).then((v) => { if (v !== undefined) console.log(show(v)); });",
38
+ "})();",
39
+ "",
40
+ ].join("\n");
41
+ }
42
+ /** @internal A fresh run prints its last expression as a cell does, through these runners. */
43
+ export const RUNNERS = {
44
+ python: {
45
+ path: ".plimsoll/run.py",
46
+ file: ".plimsoll/cell.py",
47
+ step: "python3 .plimsoll/run.py",
48
+ source: [
49
+ "import ast",
50
+ "src = open('.plimsoll/cell.py').read()",
51
+ "tree = ast.parse(src, 'cell', 'exec')",
52
+ "last = ast.Expression(tree.body.pop().value) if tree.body and isinstance(tree.body[-1], ast.Expr) else None",
53
+ "ns = {'__name__': '__main__'}",
54
+ "exec(compile(tree, 'cell', 'exec'), ns)",
55
+ "if last is not None:",
56
+ " value = eval(compile(last, 'cell', 'eval'), ns)",
57
+ " if value is not None:",
58
+ " print(repr(value))",
59
+ "",
60
+ ].join("\n"),
61
+ },
62
+ javascript: {
63
+ path: ".plimsoll/run.cjs",
64
+ file: ".plimsoll/cell.js",
65
+ step: "node .plimsoll/run.cjs",
66
+ source: [
67
+ "const fs = require('node:fs'), util = require('node:util'), vm = require('node:vm');",
68
+ "Promise.resolve(vm.runInThisContext(fs.readFileSync('.plimsoll/cell.js', 'utf8'), { filename: 'cell.js' })).then((v) => {",
69
+ " if (v !== undefined) console.log(util.inspect(v, { depth: 4 }));",
70
+ "});",
71
+ "",
72
+ ].join("\n"),
73
+ },
74
+ };
75
+ export class CodeSandboxes {
76
+ #opts;
77
+ #entries = new Map();
78
+ #info;
79
+ #client;
80
+ constructor(opts) {
81
+ this.#opts = opts;
82
+ }
83
+ get client() {
84
+ const c = this.#opts.client;
85
+ return (this.#client ??= typeof c === "function" ? c() : c);
86
+ }
87
+ /** The languages the tool offers, the first being the default. */
88
+ get languages() {
89
+ return this.#opts.languages ?? DEFAULT_LANGUAGES;
90
+ }
91
+ #describe() {
92
+ this.#info ??= this.client.describe().catch((e) => {
93
+ this.#info = undefined; // retry the next time instead of caching a failure
94
+ throw e;
95
+ });
96
+ return this.#info;
97
+ }
98
+ /** Whether calls under a key share one sandbox on this daemon. */
99
+ async persistent() {
100
+ const mode = this.#opts.sessions ?? "auto";
101
+ if (mode === "never")
102
+ return false;
103
+ const info = await this.#describe();
104
+ if (!info.supportsSessions && mode === "always") {
105
+ throw new PlimsollError("unimplemented", `plimsoll: the daemon (${info.sandbox}) does not keep sessions`, { notDispatched: "unsupported" });
106
+ }
107
+ return info.supportsSessions;
108
+ }
109
+ /**
110
+ * Starts creating the key's sandbox and returns at once. A failure here is
111
+ * not lost: the next run under the key opens a session again.
112
+ */
113
+ warm(key) {
114
+ void this.#session(key).catch(() => undefined);
115
+ }
116
+ /** Runs one call of the tool under the key. */
117
+ async run(key, input, signal) {
118
+ const language = input.language ?? this.languages[0];
119
+ if (!this.languages.includes(language)) {
120
+ throw new PlimsollError("invalid_argument", `plimsoll: this tool runs ${this.languages.join(" or ")}, not ${language}`, { notDispatched: "request" });
121
+ }
122
+ const info = await this.#describe();
123
+ const proved = info.environments.project.languages;
124
+ // A daemon that states no languages predates the statement: let it try.
125
+ if (proved.length > 0 && !proved.includes(language)) {
126
+ throw new PlimsollError("unimplemented", `plimsoll: the sandbox image has no ${language} interpreter (it runs ${proved.join(", ")})`, {
127
+ notDispatched: "unsupported",
128
+ });
129
+ }
130
+ const files = input.files ?? [];
131
+ const opts = { timeoutMs: this.#opts.timeoutMs, minimumIsolation: this.#opts.minimumIsolation, signal };
132
+ // Without a key there is no conversation to scope a sandbox to, and sharing
133
+ // one across conversations would hand one user's files to another.
134
+ if (key === undefined || !(await this.persistent())) {
135
+ return this.#fresh(info, language, input.code, files, opts);
136
+ }
137
+ let retried = false;
138
+ for (;;) {
139
+ // The call holds its entry from here, the open included, so the idle close
140
+ // cannot let the sandbox go while the call waits for it to open.
141
+ const entry = this.#entryFor(key);
142
+ entry.busy++;
143
+ let session;
144
+ try {
145
+ session = await entry.session;
146
+ const first = !entry.answered;
147
+ const r = await session.runCell({ language, code: input.code, files }, opts);
148
+ entry.answered = true;
149
+ // What the call defined, and the files it wrote, can be there for the next call
150
+ // only if its interpreter, and the sandbox, outlived it; the next call's fresh
151
+ // flags say whether they did.
152
+ const ended = session.ended !== undefined;
153
+ if (ended)
154
+ this.#drop(key, session); // the next call opens a new one
155
+ return {
156
+ ...this.#cut(language, r.exitCode, r.timedOut, r.stdout, r.stderr, r.stdoutTruncated || r.stderrTruncated),
157
+ stateKept: !r.interpreterEnded && !ended,
158
+ ...(r.interpreterStarted ? { freshInterpreter: true } : {}),
159
+ filesPersist: !ended,
160
+ ...(first ? { freshSandbox: true } : {}),
161
+ isolation: r.isolation,
162
+ };
163
+ }
164
+ catch (e) {
165
+ // A call refused because its session had ended ran nothing, so it is
166
+ // safe to run once more in a new sandbox; anything else is not.
167
+ if (!retried && session && e instanceof PlimsollError && e.sessionEnded && e.notDispatched) {
168
+ retried = true;
169
+ this.#drop(key, session);
170
+ continue;
171
+ }
172
+ throw e;
173
+ }
174
+ finally {
175
+ entry.busy--;
176
+ this.#touch(key);
177
+ }
178
+ }
179
+ }
180
+ /** Closes the key's sandbox, if it has one. Safe to call more than once. */
181
+ async dispose(key) {
182
+ const entry = this.#entries.get(key);
183
+ if (!entry)
184
+ return;
185
+ this.#entries.delete(key);
186
+ if (entry.timer)
187
+ clearTimeout(entry.timer);
188
+ const session = await entry.session.catch(() => undefined);
189
+ // An ended session is collected the same way.
190
+ await session?.close().catch((e) => this.#closeError(key, e));
191
+ }
192
+ /** Closes every sandbox this instance holds, for shutdown. */
193
+ async disposeAll() {
194
+ await Promise.all([...this.#entries.keys()].map((k) => this.dispose(k)));
195
+ }
196
+ // A fresh sandbox for one call: the files, the code and a runner that prints the
197
+ // last expression, as one project.
198
+ async #fresh(info, language, code, files, opts) {
199
+ if (!info.supportsProject) {
200
+ // A snippet is all this daemon runs (wasm): JavaScript, without files.
201
+ if (language !== "javascript") {
202
+ throw new PlimsollError("unimplemented", `plimsoll: the daemon (${info.sandbox}) runs JavaScript snippets only, not ${language}`, {
203
+ notDispatched: "unsupported",
204
+ });
205
+ }
206
+ if (files.length > 0) {
207
+ throw new PlimsollError("unimplemented", `plimsoll: the daemon (${info.sandbox}) runs JavaScript snippets only, which take no files`, {
208
+ notDispatched: "unsupported",
209
+ });
210
+ }
211
+ const r = await this.client.runJavaScript(snippetRunner(code), opts);
212
+ return {
213
+ ...this.#cut(language, r.exitCode, r.timedOut, r.stdout, r.stderr, r.stdoutTruncated || r.stderrTruncated),
214
+ stateKept: false,
215
+ filesPersist: false,
216
+ isolation: r.isolation,
217
+ };
218
+ }
219
+ const runner = RUNNERS[language];
220
+ const r = await this.client.runProject({
221
+ files: [...files, { path: runner.file, content: code }, { path: runner.path, content: runner.source }],
222
+ steps: [runner.step],
223
+ }, opts);
224
+ const step = r.steps[0];
225
+ if (!step) {
226
+ // The runner never started: the outcome says why (a bad file path, a timeout).
227
+ return {
228
+ ...this.#cut(language, r.outcome === "timed_out" ? 124 : 1, r.outcome === "timed_out", "", `plimsoll: the run ${r.outcome}: ${r.detail}`, false),
229
+ stateKept: false,
230
+ filesPersist: false,
231
+ isolation: r.isolation,
232
+ };
233
+ }
234
+ return {
235
+ ...this.#cut(language, step.exitCode, step.timedOut || r.outcome === "timed_out", step.stdout, step.stderr, step.stdoutTruncated || step.stderrTruncated),
236
+ stateKept: false,
237
+ filesPersist: false,
238
+ isolation: r.isolation,
239
+ };
240
+ }
241
+ #session(key) {
242
+ return this.#entryFor(key).session;
243
+ }
244
+ // The key's entry, opening a session for it when it has none. The idle close is
245
+ // armed once the session is open: an open slower than the idle interval is not idle.
246
+ #entryFor(key) {
247
+ let entry = this.#entries.get(key);
248
+ if (!entry) {
249
+ const session = this.persistent().then((ok) => {
250
+ if (!ok)
251
+ throw new PlimsollError("unimplemented", "plimsoll: the daemon does not keep sessions", { notDispatched: "unsupported" });
252
+ return this.client.openSession({
253
+ minimumIsolation: this.#opts.minimumIsolation,
254
+ lifetimeMs: this.#opts.sessionLifetimeMs,
255
+ idleTimeoutMs: this.#opts.sessionIdleTimeoutMs,
256
+ });
257
+ });
258
+ const e = { session, answered: false, busy: 0 };
259
+ entry = e;
260
+ this.#entries.set(key, e);
261
+ // A failed open leaves no entry behind, so the next call tries again.
262
+ session.then((s) => {
263
+ e.opened = s;
264
+ if (this.#entries.get(key) === e)
265
+ this.#touch(key);
266
+ }, () => {
267
+ if (this.#entries.get(key) === e)
268
+ this.#entries.delete(key);
269
+ });
270
+ }
271
+ return entry;
272
+ }
273
+ // Forgets an ended session at once, so the next call under the key opens a
274
+ // new one, and collects its end from the daemon in the background.
275
+ #drop(key, session) {
276
+ const entry = this.#entries.get(key);
277
+ if (entry?.opened === session) {
278
+ this.#entries.delete(key);
279
+ if (entry.timer)
280
+ clearTimeout(entry.timer);
281
+ }
282
+ void session.close().catch((e) => this.#closeError(key, e));
283
+ }
284
+ #closeError(key, err) {
285
+ if (this.#opts.onCloseError)
286
+ this.#opts.onCloseError(key, err);
287
+ else
288
+ console.warn(`plimsoll: closing the sandbox for ${key} failed:`, err instanceof Error ? err.message : err);
289
+ }
290
+ #touch(key) {
291
+ const entry = this.#entries.get(key);
292
+ const ms = this.#opts.idleCloseMs ?? 10 * 60_000;
293
+ if (!entry || ms <= 0)
294
+ return;
295
+ if (entry.timer)
296
+ clearTimeout(entry.timer);
297
+ // A call in flight keeps its sandbox; the call's end arms the timer again.
298
+ entry.timer = setTimeout(() => {
299
+ if (this.#entries.get(key) === entry && entry.busy === 0)
300
+ void this.dispose(key);
301
+ }, ms);
302
+ entry.timer.unref?.();
303
+ }
304
+ #cut(language, exitCode, timedOut, stdout, stderr, truncated) {
305
+ const max = this.#opts.maxOutputChars ?? 16_000;
306
+ const cut = (s) => (s.length > max ? s.slice(0, max) : s);
307
+ return {
308
+ language,
309
+ exitCode,
310
+ timedOut,
311
+ stdout: cut(stdout),
312
+ stderr: cut(stderr),
313
+ truncated: truncated || stdout.length > max || stderr.length > max,
314
+ };
315
+ }
316
+ }
package/dist/tool.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ import { z } from "zod";
2
+ import { type ToolLanguages } from "./sandboxes.ts";
3
+ /** The tool's description for the languages it offers. */
4
+ export declare function executeCodeDescription(languages?: ToolLanguages): string;
5
+ /** The tool's input schema for the languages it offers. */
6
+ export declare function executeCodeInput(languages?: ToolLanguages): z.ZodObject<{
7
+ code: z.ZodString;
8
+ language: z.ZodDefault<z.ZodEnum<{
9
+ javascript: "javascript";
10
+ python: "python";
11
+ }>>;
12
+ files: z.ZodOptional<z.ZodArray<z.ZodObject<{
13
+ path: z.ZodString;
14
+ content: z.ZodString;
15
+ }, z.core.$strip>>>;
16
+ }, z.core.$strip>;
17
+ /** The tool's input after the schema applied its default language. */
18
+ export type ExecuteCodeToolInput = z.output<ReturnType<typeof executeCodeInput>>;
19
+ export declare const executeCodeOutput: z.ZodObject<{
20
+ language: z.ZodString;
21
+ exitCode: z.ZodNumber;
22
+ timedOut: z.ZodBoolean;
23
+ stdout: z.ZodString;
24
+ stderr: z.ZodString;
25
+ truncated: z.ZodBoolean;
26
+ stateKept: z.ZodBoolean;
27
+ freshInterpreter: z.ZodOptional<z.ZodLiteral<true>>;
28
+ filesPersist: z.ZodBoolean;
29
+ freshSandbox: z.ZodOptional<z.ZodLiteral<true>>;
30
+ isolation: z.ZodString;
31
+ }, z.core.$strip>;
package/dist/tool.js ADDED
@@ -0,0 +1,49 @@
1
+ // The executeCode tool's model-facing surface, shared by the add-ons so the
2
+ // Trigger.dev and Mastra tools describe the same thing in the same words.
3
+ import { z } from "zod";
4
+ import { DEFAULT_LANGUAGES } from "./sandboxes.js";
5
+ const NAMES = { python: "Python", javascript: "JavaScript (Node.js)" };
6
+ /** The tool's description for the languages it offers. */
7
+ export function executeCodeDescription(languages = DEFAULT_LANGUAGES) {
8
+ const names = languages.map((l) => NAMES[l]).join(" or ");
9
+ return (`Run ${names} in an isolated sandbox with no network access and return its exit code, stdout and stderr. ` +
10
+ "The value of the code's last expression is printed, as in a notebook, so the last line can simply name what you want to see. " +
11
+ "Within one conversation the sandbox usually keeps an interpreter per language between calls, so variables, functions, imports and loaded data " +
12
+ "from earlier calls are still defined: the result's stateKept says whether this call's interpreter was still running when it answered, so what it defined can still be there " +
13
+ "for the next call (false when its deadline ended the interpreter, or the sandbox ended). freshInterpreter means " +
14
+ "this call's interpreter had just started, so nothing earlier calls defined exists and has to be rebuilt; freshSandbox means no file from " +
15
+ "earlier calls is there either. " +
16
+ "To give the code data, such as another tool's output, pass it in files rather than pasting it into the code; the code reads each file by its relative path. " +
17
+ "Files written to the working directory can still be there on the next call when filesPersist is true; freshSandbox on that call says they are not.");
18
+ }
19
+ /** The tool's input schema for the languages it offers. */
20
+ export function executeCodeInput(languages = DEFAULT_LANGUAGES) {
21
+ return z.object({
22
+ code: z.string().min(1).describe("The source code to run. Print what you need, or end with an expression to show its value."),
23
+ language: z
24
+ .enum(languages)
25
+ .default(languages[0])
26
+ .describe(`The language of code: ${languages.map((l) => `"${l}"`).join(" or ")}. Default "${languages[0]}".`),
27
+ files: z
28
+ .array(z.object({
29
+ path: z.string().min(1).describe("A relative path, such as data/orders.csv."),
30
+ content: z.string().describe("The file's text."),
31
+ }))
32
+ .max(200)
33
+ .optional()
34
+ .describe("Text files written into the working directory before the code runs, for data the code should read."),
35
+ });
36
+ }
37
+ export const executeCodeOutput = z.object({
38
+ language: z.string(),
39
+ exitCode: z.number(),
40
+ timedOut: z.boolean(),
41
+ stdout: z.string(),
42
+ stderr: z.string(),
43
+ truncated: z.boolean(),
44
+ stateKept: z.boolean(),
45
+ freshInterpreter: z.literal(true).optional(),
46
+ filesPersist: z.boolean(),
47
+ freshSandbox: z.literal(true).optional(),
48
+ isolation: z.string(),
49
+ });
@@ -0,0 +1,17 @@
1
+ import { type Tool } from "ai";
2
+ import { CodeSandboxes, type CodeSandboxesOptions, type ExecuteCodeOutput } from "./sandboxes.ts";
3
+ import { type ExecuteCodeToolInput } from "./tool.ts";
4
+ export type PlimsollCodeSandboxOptions = CodeSandboxesOptions & {
5
+ /** The chat.local id; unique across your project's chat.local() calls. */
6
+ localId?: string;
7
+ };
8
+ export type PlimsollCodeSandbox = {
9
+ /** The AI SDK tool to pass to streamText's tools. */
10
+ executeCode: Tool<ExecuteCodeToolInput, ExecuteCodeOutput>;
11
+ /** Call from onTurnStart: records the run id for the tool and starts the sandbox without waiting. */
12
+ warm(runId: string): void;
13
+ /** Call from onChatSuspend and onComplete. */
14
+ dispose(runId: string): Promise<void>;
15
+ sandboxes: CodeSandboxes;
16
+ };
17
+ export declare function plimsollCodeSandbox(opts: PlimsollCodeSandboxOptions): PlimsollCodeSandbox;
@@ -0,0 +1,29 @@
1
+ // Trigger.dev add-on: the code-sandbox recipe from Trigger.dev's own docs
2
+ // (https://trigger.dev/docs/ai-chat/patterns/code-sandbox) with plimsoll as the
3
+ // sandbox. Warm in onTurnStart without blocking, reuse for every executeCode call,
4
+ // dispose in onChatSuspend (right before the run sleeps) and in onComplete.
5
+ //
6
+ // The sandboxes live in this module's memory, keyed by run id; chat.local holds
7
+ // only the run id, because Trigger.dev serializes chat.local into subtask
8
+ // metadata and a session ID is a capability that must stay in this process.
9
+ import { chat } from "@trigger.dev/sdk/ai";
10
+ import { tool } from "ai";
11
+ import { CodeSandboxes } from "./sandboxes.js";
12
+ import { executeCodeDescription, executeCodeInput } from "./tool.js";
13
+ export function plimsollCodeSandbox(opts) {
14
+ const sandboxes = new CodeSandboxes(opts);
15
+ const current = chat.local({ id: opts.localId ?? "plimsollCodeSandbox" });
16
+ function warm(runId) {
17
+ current.init({ runId });
18
+ sandboxes.warm(runId);
19
+ }
20
+ function dispose(runId) {
21
+ return sandboxes.dispose(runId);
22
+ }
23
+ const executeCode = tool({
24
+ description: executeCodeDescription(sandboxes.languages),
25
+ inputSchema: executeCodeInput(sandboxes.languages),
26
+ execute: async (input, { abortSignal }) => sandboxes.run(current.get().runId, input, abortSignal),
27
+ });
28
+ return { executeCode, warm, dispose, sandboxes };
29
+ }
package/dist/wire.d.ts ADDED
@@ -0,0 +1,187 @@
1
+ export type WireSoftwareRule = {
2
+ mode: string;
3
+ identities: string[];
4
+ };
5
+ export type WireJavaScriptRun = {
6
+ code: string;
7
+ grantProfile?: string;
8
+ };
9
+ export type WireProjectRun = {
10
+ files?: {
11
+ path: string;
12
+ content: string;
13
+ }[];
14
+ steps?: string[];
15
+ artifacts?: string[];
16
+ grantProfile?: string;
17
+ };
18
+ export type WireEnvelope = {
19
+ protocol: number;
20
+ minimumIsolation?: string;
21
+ traceId?: string;
22
+ timeoutMs?: number;
23
+ softwareRule?: WireSoftwareRule;
24
+ };
25
+ /** A session's call to its interpreter (sessions.md, "Interpreters"). */
26
+ export type WireCellRun = {
27
+ language: string;
28
+ code: string;
29
+ files?: {
30
+ path: string;
31
+ content: string;
32
+ }[];
33
+ };
34
+ export type WireRunRequest = WireEnvelope & {
35
+ javascript?: WireJavaScriptRun;
36
+ project?: WireProjectRun;
37
+ };
38
+ export type WireSessionRunRequest = WireRunRequest & {
39
+ sessionId: string;
40
+ };
41
+ export type WireRecord = {
42
+ version?: number;
43
+ requestSha256?: string;
44
+ resultSha256?: string;
45
+ provider?: string;
46
+ isolation?: string;
47
+ environment?: string;
48
+ policy?: string;
49
+ startedUnixMs?: string | number;
50
+ endedUnixMs?: string | number;
51
+ session?: string;
52
+ sequence?: string | number;
53
+ previousSha256?: string;
54
+ softwareIdentity?: string;
55
+ softwareRuleId?: string;
56
+ recordSha256?: string;
57
+ };
58
+ export type WireAdvice = {
59
+ pattern?: string;
60
+ severity?: string;
61
+ remedy?: string;
62
+ method?: string;
63
+ route?: string;
64
+ detail?: string;
65
+ suggestedMethod?: string;
66
+ suggestedRoute?: string;
67
+ extraCalls?: number;
68
+ addedLatencyMs?: string | number;
69
+ bytesMoved?: string | number;
70
+ };
71
+ export type WireJavaScriptResult = {
72
+ stdout?: string;
73
+ stderr?: string;
74
+ exitCode?: number;
75
+ timedOut?: boolean;
76
+ stdoutTruncated?: boolean;
77
+ stderrTruncated?: boolean;
78
+ advice?: WireAdvice[];
79
+ };
80
+ export type WireStepResult = {
81
+ command?: string;
82
+ stdout?: string;
83
+ stderr?: string;
84
+ exitCode?: number;
85
+ timedOut?: boolean;
86
+ durationMs?: string | number;
87
+ stdoutTruncated?: boolean;
88
+ stderrTruncated?: boolean;
89
+ };
90
+ export type WireProjectResult = {
91
+ steps?: WireStepResult[];
92
+ outcome?: string | number;
93
+ artifacts?: {
94
+ path?: string;
95
+ content?: string;
96
+ }[];
97
+ outcomeDetail?: string;
98
+ artifactsTruncated?: boolean;
99
+ advice?: WireAdvice[];
100
+ };
101
+ export type WireCellResult = {
102
+ stdout?: string;
103
+ stderr?: string;
104
+ exitCode?: number;
105
+ timedOut?: boolean;
106
+ stdoutTruncated?: boolean;
107
+ stderrTruncated?: boolean;
108
+ interpreterStarted?: boolean;
109
+ interpreterEnded?: boolean;
110
+ };
111
+ export type WireRunResponse = {
112
+ sandbox?: string;
113
+ isolation?: string;
114
+ durationMs?: string | number;
115
+ record?: WireRecord;
116
+ softwareIdentity?: string;
117
+ environment?: string;
118
+ javascript?: WireJavaScriptResult;
119
+ project?: WireProjectResult;
120
+ module?: unknown;
121
+ cell?: WireCellResult;
122
+ };
123
+ export type WireSessionRunResponse = {
124
+ run?: WireRunResponse;
125
+ ended?: string | number;
126
+ endDetail?: string;
127
+ };
128
+ export type WirePayloadEnvironment = {
129
+ identity?: string;
130
+ maxTimeoutMs?: number;
131
+ softwareIdentity?: string;
132
+ languages?: string[];
133
+ };
134
+ export type WireDescribeResponse = {
135
+ sandbox?: string;
136
+ isolation?: string;
137
+ supportsProject?: boolean;
138
+ supportsJavascriptGrants?: boolean;
139
+ supportsProjectGrants?: boolean;
140
+ supportsModule?: boolean;
141
+ protocol?: number;
142
+ javascriptEnvironment?: WirePayloadEnvironment;
143
+ projectEnvironment?: WirePayloadEnvironment;
144
+ moduleEnvironment?: WirePayloadEnvironment;
145
+ resources?: {
146
+ memoryMb?: number;
147
+ cpus?: number;
148
+ pids?: number;
149
+ diskMb?: number;
150
+ };
151
+ policy?: string;
152
+ supportsSessions?: boolean;
153
+ sessionLifetimeMs?: number;
154
+ sessionIdleTimeoutMs?: number;
155
+ };
156
+ export type WireOpenSessionRequest = {
157
+ protocol: number;
158
+ minimumIsolation?: string;
159
+ traceId?: string;
160
+ lifetimeMs?: number;
161
+ idleTimeoutMs?: number;
162
+ softwareRule?: WireSoftwareRule;
163
+ };
164
+ export type WireOpenSessionResponse = {
165
+ sessionId?: string;
166
+ session?: string;
167
+ sandbox?: string;
168
+ isolation?: string;
169
+ expiresUnixMs?: string | number;
170
+ idleTimeoutMs?: number;
171
+ softwareIdentity?: string;
172
+ };
173
+ export type WireCloseSessionResponse = {
174
+ session?: string;
175
+ calls?: string | number;
176
+ lastRecordSha256?: string;
177
+ ended?: string | number;
178
+ };
179
+ /** A Connect error body: https://connectrpc.com/docs/protocol#error-end-stream */
180
+ export type WireError = {
181
+ code?: string;
182
+ message?: string;
183
+ details?: {
184
+ type?: string;
185
+ value?: string;
186
+ }[];
187
+ };
package/dist/wire.js ADDED
@@ -0,0 +1,6 @@
1
+ // The proto3 JSON forms of plimsoll.v1 messages this client sends and reads
2
+ // (proto/plimsoll/v1/sandbox.proto). Field names are protobuf's lowerCamelCase
3
+ // JSON names; bytes are base64; 64-bit integers arrive as strings; enums as their
4
+ // names; a field at its zero value is omitted, which is why everything read is
5
+ // optional.
6
+ export {};