@plimsollmark/client 0.27.2 → 0.28.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 +104 -3
- package/dist/ai-sdk.d.ts +20 -1
- package/dist/ai-sdk.js +28 -1
- package/dist/checkpoint.d.ts +41 -0
- package/dist/checkpoint.js +131 -0
- package/dist/client.d.ts +114 -15
- package/dist/client.js +335 -40
- package/dist/errors.d.ts +27 -4
- package/dist/errors.js +60 -10
- package/dist/granted.gen.d.ts +32 -0
- package/dist/granted.gen.js +33 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +2 -1
- package/dist/mastra.d.ts +38 -1
- package/dist/mastra.js +23 -1
- package/dist/record.d.ts +36 -2
- package/dist/record.js +130 -41
- package/dist/sandboxes.d.ts +59 -1
- package/dist/sandboxes.js +179 -0
- package/dist/tables.gen.d.ts +76 -0
- package/dist/tables.gen.js +85 -2
- package/dist/tool.d.ts +13 -4
- package/dist/tool.js +57 -9
- package/dist/trigger.js +4 -1
- package/dist/wire.d.ts +48 -0
- package/dist/wire.js +25 -1
- package/package.json +2 -2
package/dist/tables.gen.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Code generated by internal/wiretables (make generate). DO NOT EDIT.
|
|
2
|
-
// The protocol's enums and
|
|
3
|
-
//
|
|
2
|
+
// The protocol's enums and the wire rules every client checks, from
|
|
3
|
+
// proto/plimsoll/v1/sandbox.proto and the Go packages that enforce them (protocol, record,
|
|
4
|
+
// sandbox, client), so this client and the Go and Python ones cannot drift apart.
|
|
4
5
|
/** plimsoll.v1.ProjectOutcome, by number. */
|
|
5
6
|
export const OUTCOMES = {
|
|
6
7
|
PROJECT_OUTCOME_UNSPECIFIED: 0,
|
|
@@ -42,3 +43,85 @@ export const REFUSAL_NAMES = ["unknown", "request", "permission", "protocol", "u
|
|
|
42
43
|
export const TIERS = ["none", "process", "container", "kernel", "vm"];
|
|
43
44
|
/** The languages plimsoll keeps an interpreter for (sandbox.Languages). */
|
|
44
45
|
export const LANGUAGES = ["javascript", "python"];
|
|
46
|
+
/** The wire protocol number a client states on every request (protocol.Number). */
|
|
47
|
+
export const PROTOCOL = 7;
|
|
48
|
+
/** The header carrying a client's ID for one request, which the daemon echoes (protocol.RequestIDHeader). */
|
|
49
|
+
export const REQUEST_ID_HEADER = "Plimsoll-Request-Id";
|
|
50
|
+
/** The daemon's mark on an answer written before any handler ran (protocol.NotDispatchedHeader). */
|
|
51
|
+
export const NOT_DISPATCHED_HEADER = "Plimsoll-Not-Dispatched";
|
|
52
|
+
/** A correlation id's grammar; the daemon drops one outside it (protocol.TraceIDPattern). */
|
|
53
|
+
export const TRACE_ID_PATTERN = "^[A-Za-z0-9._:-]{1,64}$";
|
|
54
|
+
/** The text of a session call, close or attach refused because another worker attached (protocol.StaleOwnerText). */
|
|
55
|
+
export const STALE_OWNER_TEXT = "session ownership generation is stale";
|
|
56
|
+
/** The text of an attach refused because its checkpoint is not the session's head (protocol.CheckpointMismatchText). */
|
|
57
|
+
export const CHECKPOINT_MISMATCH_TEXT = "session checkpoint does not match";
|
|
58
|
+
/** The tiers a request may state as its floor, weakest first: every tier but none. */
|
|
59
|
+
export const FLOORS = ["process", "container", "kernel", "vm"];
|
|
60
|
+
/** The record version a live answer carries (record.Version). */
|
|
61
|
+
export const RECORD_VERSION = 5;
|
|
62
|
+
/** Each published record version's digest fields, in order (record.PublishedLayouts). */
|
|
63
|
+
export const RECORD_FIELDS = {
|
|
64
|
+
1: ["request_sha256", "result_sha256", "provider", "isolation", "environment", "policy", "started_unix_ms", "ended_unix_ms", "session", "sequence", "previous_sha256"],
|
|
65
|
+
2: ["request_sha256", "result_sha256", "provider", "isolation", "environment", "policy", "software_identity", "software_rule_id", "started_unix_ms", "ended_unix_ms", "session", "sequence", "previous_sha256"],
|
|
66
|
+
3: ["request_sha256", "result_sha256", "unanswered", "provider", "isolation", "environment", "policy", "software_identity", "software_rule_id", "started_unix_ms", "ended_unix_ms", "session", "sequence", "previous_sha256"],
|
|
67
|
+
4: ["request_sha256", "result_sha256", "unanswered", "provider", "isolation", "environment", "policy", "software_identity", "software_rule_id", "instance", "started_unix_ms", "ended_unix_ms", "session", "sequence", "previous_sha256"],
|
|
68
|
+
5: ["request_sha256", "result_sha256", "unanswered", "provider", "isolation", "isolation_qualification", "environment", "policy", "software_identity", "software_rule_id", "instance", "warm", "daemon_version", "started_unix_ms", "ended_unix_ms", "session", "sequence", "previous_sha256"],
|
|
69
|
+
};
|
|
70
|
+
/** The last record version whose daemons stamped both times from the wall clock; reading such a record that ends before it starts is retired (record.LastWallClockEndVersion). */
|
|
71
|
+
export const LAST_WALL_CLOCK_END_VERSION = 2;
|
|
72
|
+
/** The refusal of a version 1 or 2 record that ends before it starts: a retired reading, not a forgery (record.RetiredEndBeforeStartText). */
|
|
73
|
+
export const RETIRED_END_BEFORE_START_TEXT = "the record ends before it starts, and that reading is retired by the decision of 2026-11-21: records of versions 1 and 2 that end before they start are no longer read; daemons v0.10.0 to v0.12.0 could write one during a clock step";
|
|
74
|
+
/** The codes an unanswered call's record may name (record.UnansweredCodes). */
|
|
75
|
+
export const UNANSWERED_CODES = ["aborted", "already_exists", "canceled", "data_loss", "deadline_exceeded", "failed_precondition", "internal", "invalid_argument", "not_found", "out_of_range", "permission_denied", "resource_exhausted", "unauthenticated", "unavailable", "unimplemented", "unknown"];
|
|
76
|
+
/** The most bytes an isolation qualification may take (record.MaxQualificationBytes). */
|
|
77
|
+
export const MAX_QUALIFICATION_BYTES = 1024;
|
|
78
|
+
/** The code points a qualification may not hold, as inclusive ranges (record.QualificationForbidden). */
|
|
79
|
+
export const QUALIFICATION_FORBIDDEN = [[0x0000, 0x001F], [0x007F, 0x009F], [0x061C, 0x061C], [0x200E, 0x200E], [0x200F, 0x200F], [0x2028, 0x2028], [0x2029, 0x2029], [0x202A, 0x202E], [0x2066, 0x2069]];
|
|
80
|
+
/** The most bytes a record's daemon version may take (record.MaxDaemonVersionBytes). */
|
|
81
|
+
export const MAX_DAEMON_VERSION_BYTES = 128;
|
|
82
|
+
/** A daemon version's grammar, when it is not empty (record.DaemonVersionPattern). */
|
|
83
|
+
export const DAEMON_VERSION_PATTERN = "^(?:\\(devel\\)|v[0-9]+\\.[0-9]+\\.[0-9]+(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?)$";
|
|
84
|
+
/** A typed instance reference's grammar, when it is not empty (sandbox.InstancePattern). */
|
|
85
|
+
export const INSTANCE_PATTERN = "^[a-z][a-z0-9-]{0,31}:[A-Za-z0-9._:-]{1,127}$";
|
|
86
|
+
/** The most bytes of code a snippet or a cell may carry (sandbox.MaxCodeBytes). */
|
|
87
|
+
export const MAX_CODE_BYTES = 262144;
|
|
88
|
+
/** The most bytes a request's files may hold together (sandbox.MaxProjectBytes). */
|
|
89
|
+
export const MAX_PROJECT_BYTES = 4194304;
|
|
90
|
+
/** The most files a request may write (sandbox.MaxProjectFiles). */
|
|
91
|
+
export const MAX_PROJECT_FILES = 200;
|
|
92
|
+
/** The most steps a project may run (sandbox.MaxProjectSteps). */
|
|
93
|
+
export const MAX_PROJECT_STEPS = 20;
|
|
94
|
+
/** The most artifacts a project may ask for (sandbox.MaxProjectArtifacts). */
|
|
95
|
+
export const MAX_PROJECT_ARTIFACTS = 100;
|
|
96
|
+
/** The most bytes a file or artifact path may take (sandbox.MaxProjectPathBytes). */
|
|
97
|
+
export const MAX_PROJECT_PATH_BYTES = 1024;
|
|
98
|
+
/** The most bytes one step's command may take (sandbox.MaxProjectStepBytes). */
|
|
99
|
+
export const MAX_PROJECT_STEP_BYTES = 16384;
|
|
100
|
+
/** The most parameter rows a module run may carry (sandbox.MaxModuleRows). */
|
|
101
|
+
export const MAX_MODULE_ROWS = 100000;
|
|
102
|
+
/** The most values one module row may carry (sandbox.MaxModuleRowWidth). */
|
|
103
|
+
export const MAX_MODULE_ROW_WIDTH = 64;
|
|
104
|
+
/** The most steps one module instance may take (sandbox.MaxModuleSteps). */
|
|
105
|
+
export const MAX_MODULE_STEPS = 1000000;
|
|
106
|
+
/** The most bytes a module run's results may take (sandbox.MaxModuleResultBytes). */
|
|
107
|
+
export const MAX_MODULE_RESULT_BYTES = 8388608;
|
|
108
|
+
/** The bytes a module run's results start with before the rows (sandbox.ModuleResultHeaderBytes). */
|
|
109
|
+
export const MODULE_RESULT_HEADER_BYTES = 20;
|
|
110
|
+
/** A model id's grammar (sandbox.ModuleIDPattern). */
|
|
111
|
+
export const MODULE_ID_PATTERN = "^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$";
|
|
112
|
+
/** The most identities an approved software rule may name (sandbox.MaxSoftwareIdentities). */
|
|
113
|
+
export const MAX_SOFTWARE_IDENTITIES = 32;
|
|
114
|
+
/** The most bytes one software identity may take (sandbox.MaxSoftwareIdentityBytes). */
|
|
115
|
+
export const MAX_SOFTWARE_IDENTITY_BYTES = 256;
|
|
116
|
+
/** The characters a software identity may hold (sandbox.SoftwareIdentityPattern). */
|
|
117
|
+
export const SOFTWARE_IDENTITY_PATTERN = "^[A-Za-z0-9._:/@+-]+$";
|
|
118
|
+
/** The largest answer a client reads (client.MaxResponseBytes). */
|
|
119
|
+
export const MAX_RESPONSE_BYTES = 33554432;
|
|
120
|
+
/** The one version of a session checkpoint the clients write and read (client.CheckpointVersion). */
|
|
121
|
+
export const CHECKPOINT_VERSION = 1;
|
|
122
|
+
/** A daemon name's grammar: the application's own name for a daemon, never a URL (client.DaemonNamePattern). */
|
|
123
|
+
export const DAEMON_NAME_PATTERN = "^[A-Za-z0-9._-]{1,64}$";
|
|
124
|
+
/** A software rule's ID as a checkpoint states it (client.SoftwareRuleIDPattern). */
|
|
125
|
+
export const SOFTWARE_RULE_ID_PATTERN = "^(?:exact:[A-Za-z0-9._:/@+-]{1,256}|approved:sha256:[0-9a-f]{64})$";
|
|
126
|
+
/** What a client says when it refuses a repeat of a call lost across a takeover (client.CallAlreadySentText). */
|
|
127
|
+
export const CALL_ALREADY_SENT_TEXT = "this call was already sent once in the session, and its answer was lost";
|
package/dist/tool.d.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import type { Language } from "./client.ts";
|
|
3
|
+
import { type GrantPlan, type ToolLanguages } from "./sandboxes.ts";
|
|
4
|
+
/**
|
|
5
|
+
* What a granted tool tells its model about the API, in the same words as the Python
|
|
6
|
+
* kits' (plimsoll_client._code_tool.api_text): the routes are the only requests sent, the
|
|
7
|
+
* credential is added outside, the budget, what a call that changes data means, and how
|
|
8
|
+
* each offered language calls it; then the API's description as the application gave it.
|
|
9
|
+
*/
|
|
10
|
+
export declare function apiText(languages: readonly Language[], plan: GrantPlan): string;
|
|
11
|
+
/** The tool's description for the languages it offers, and with a grant plan what its code can call. */
|
|
12
|
+
export declare function executeCodeDescription(languages?: ToolLanguages, scope?: "fresh" | "conversation", plan?: GrantPlan): string;
|
|
5
13
|
/** The tool's input schema for the languages it offers. */
|
|
6
|
-
export declare function executeCodeInput(languages?: ToolLanguages): z.ZodObject<{
|
|
14
|
+
export declare function executeCodeInput(languages?: ToolLanguages, granted?: boolean): z.ZodObject<{
|
|
7
15
|
code: z.ZodString;
|
|
8
16
|
language: z.ZodDefault<z.ZodEnum<{
|
|
9
17
|
javascript: "javascript";
|
|
@@ -28,5 +36,6 @@ export declare const executeCodeOutput: z.ZodObject<{
|
|
|
28
36
|
filesPersist: z.ZodBoolean;
|
|
29
37
|
freshSandbox: z.ZodOptional<z.ZodLiteral<true>>;
|
|
30
38
|
isolation: z.ZodString;
|
|
39
|
+
isolationQualification: z.ZodOptional<z.ZodString>;
|
|
31
40
|
recordSha256: z.ZodString;
|
|
32
41
|
}, z.core.$strip>;
|
package/dist/tool.js
CHANGED
|
@@ -2,12 +2,59 @@
|
|
|
2
2
|
// tools describe the same thing in the same words, with explicit fresh-call scope.
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { DEFAULT_LANGUAGES } from "./sandboxes.js";
|
|
5
|
+
import { MAX_PROJECT_FILES } from "./tables.gen.js";
|
|
5
6
|
const NAMES = { python: "Python", javascript: "JavaScript (Node.js)" };
|
|
6
|
-
// The daemon accepts
|
|
7
|
-
// files, so the shared tool schema
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
// The daemon accepts MAX_PROJECT_FILES project files. A fresh call adds its runner and
|
|
8
|
+
// code files, so the shared tool schema leaves those two slots available; a granted
|
|
9
|
+
// tool one more, for the plimsoll_host module a granted Python call carries.
|
|
10
|
+
const MAX_INPUT_FILES = MAX_PROJECT_FILES - 2;
|
|
11
|
+
// How JavaScript calls the API: in a granted project's cell form, top-level await works; in
|
|
12
|
+
// the snippet form a daemon that runs snippets only gets (sandbox.SnippetCell, evaluated as a
|
|
13
|
+
// script), it does not, and a final promise is printed once it settles.
|
|
14
|
+
const CELL_JS = "In JavaScript, call it through the global client the description names, as it shows; each call returns a promise, so await it.";
|
|
15
|
+
const SNIPPET_JS = "In JavaScript, call it through the global client the description names, as it shows; each call returns a promise. " +
|
|
16
|
+
"Top-level await does not work in this sandbox: put the calls in an async function and end the code with its call, " +
|
|
17
|
+
"(async () => { ... return value; })(), whose value is printed once it settles.";
|
|
18
|
+
/**
|
|
19
|
+
* What a granted tool tells its model about the API, in the same words as the Python
|
|
20
|
+
* kits' (plimsoll_client._code_tool.api_text): the routes are the only requests sent, the
|
|
21
|
+
* credential is added outside, the budget, what a call that changes data means, and how
|
|
22
|
+
* each offered language calls it; then the API's description as the application gave it.
|
|
23
|
+
*/
|
|
24
|
+
export function apiText(languages, plan) {
|
|
25
|
+
const lines = [
|
|
26
|
+
"This tool's code can call one web API, described below, from inside the sandbox. Only its routes listed below " +
|
|
27
|
+
"(each a method and a path) are sent to it: any other request is refused before it leaves, and so is a call " +
|
|
28
|
+
"past the run's call budget (status 429). plimsoll adds the API's key outside the sandbox; the code never needs " +
|
|
29
|
+
"one. A call that changes data takes effect even if the program fails afterwards, and a run is never retried.",
|
|
30
|
+
];
|
|
31
|
+
if (languages.includes("javascript")) {
|
|
32
|
+
lines.push(plan.snippets ? SNIPPET_JS : CELL_JS);
|
|
33
|
+
}
|
|
34
|
+
if (languages.includes("python")) {
|
|
35
|
+
lines.push("In Python, import plimsoll_host and call plimsoll_host.get(path), post(path, body), put(path, body), " +
|
|
36
|
+
"patch(path, body), delete(path) or call(method, path, body) with a route's method and path from the " +
|
|
37
|
+
"list below; each returns the answer's parsed JSON and raises plimsoll_host.HostAPIError, which has " +
|
|
38
|
+
".status and .body, for any other status.");
|
|
39
|
+
}
|
|
40
|
+
else if (!plan.languages.includes("python")) {
|
|
41
|
+
lines.push(`Python code cannot call the API on this sandbox (its provider, ${plan.provider}, gives a Python step no way to reach it).`);
|
|
42
|
+
}
|
|
43
|
+
lines.push("The API:\n" + plan.apiDescription);
|
|
44
|
+
return lines.join("\n");
|
|
45
|
+
}
|
|
46
|
+
/** The tool's description for the languages it offers, and with a grant plan what its code can call. */
|
|
47
|
+
export function executeCodeDescription(languages = DEFAULT_LANGUAGES, scope = "conversation", plan) {
|
|
48
|
+
if (plan) {
|
|
49
|
+
const names = languages.map((l) => NAMES[l]).join(" or ");
|
|
50
|
+
return (`Run ${names} in an isolated sandbox with no network access except the one web API described below, and return its exit code, stdout and stderr. ` +
|
|
51
|
+
"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. " +
|
|
52
|
+
"Every call uses a fresh sandbox and interpreter: no earlier variable, import or file is retained, because a call that can reach the API never runs in a kept sandbox, so kept state between calls is not available to this tool. stateKept and filesPersist are false. " +
|
|
53
|
+
"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. " +
|
|
54
|
+
"The result also reports the isolation tier, the sentence its provider requires beside that tier when it states one (isolationQualification), and the SHA-256 of the run record the client checked." +
|
|
55
|
+
"\n\n" +
|
|
56
|
+
apiText(languages, plan));
|
|
57
|
+
}
|
|
11
58
|
const names = languages.map((l) => NAMES[l]).join(" or ");
|
|
12
59
|
const state = scope === "fresh"
|
|
13
60
|
? "Every call uses a fresh sandbox and interpreter: no earlier variable, import or file is retained. stateKept and filesPersist are false. "
|
|
@@ -17,14 +64,14 @@ export function executeCodeDescription(languages = DEFAULT_LANGUAGES, scope = "c
|
|
|
17
64
|
"this call's interpreter had just started, so nothing earlier calls defined exists and has to be rebuilt; freshSandbox means no file from " +
|
|
18
65
|
"earlier calls is there either. " +
|
|
19
66
|
"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. ";
|
|
20
|
-
return (`Run ${names} in an isolated sandbox with no network access
|
|
67
|
+
return (`Run ${names} in an isolated sandbox with no network access and return its exit code, stdout and stderr. ` +
|
|
21
68
|
"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. " +
|
|
22
69
|
state +
|
|
23
70
|
"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. " +
|
|
24
|
-
"The result also reports the isolation tier and the SHA-256 of the run record the client checked.");
|
|
71
|
+
"The result also reports the isolation tier, the sentence its provider requires beside that tier when it states one (isolationQualification), and the SHA-256 of the run record the client checked.");
|
|
25
72
|
}
|
|
26
73
|
/** The tool's input schema for the languages it offers. */
|
|
27
|
-
export function executeCodeInput(languages = DEFAULT_LANGUAGES) {
|
|
74
|
+
export function executeCodeInput(languages = DEFAULT_LANGUAGES, granted = false) {
|
|
28
75
|
return z.object({
|
|
29
76
|
code: z.string().min(1).describe("The source code to run. Print what you need, or end with an expression to show its value."),
|
|
30
77
|
language: z
|
|
@@ -36,7 +83,7 @@ export function executeCodeInput(languages = DEFAULT_LANGUAGES) {
|
|
|
36
83
|
path: z.string().min(1).describe("A relative path, such as data/orders.csv."),
|
|
37
84
|
content: z.string().describe("The file's text."),
|
|
38
85
|
}))
|
|
39
|
-
.max(MAX_INPUT_FILES)
|
|
86
|
+
.max(granted ? MAX_INPUT_FILES - 1 : MAX_INPUT_FILES)
|
|
40
87
|
.optional()
|
|
41
88
|
.describe("Text files written into the working directory before the code runs, for data the code should read."),
|
|
42
89
|
});
|
|
@@ -53,5 +100,6 @@ export const executeCodeOutput = z.object({
|
|
|
53
100
|
filesPersist: z.boolean(),
|
|
54
101
|
freshSandbox: z.literal(true).optional(),
|
|
55
102
|
isolation: z.string(),
|
|
103
|
+
isolationQualification: z.string().optional(),
|
|
56
104
|
recordSha256: z.string().regex(/^[0-9a-f]{64}$/),
|
|
57
105
|
});
|
package/dist/trigger.js
CHANGED
|
@@ -9,9 +9,12 @@
|
|
|
9
9
|
// stay in this process, and the owner is a user's identity.
|
|
10
10
|
import { chat } from "@trigger.dev/sdk/ai";
|
|
11
11
|
import { tool } from "ai";
|
|
12
|
-
import { CodeSandboxes } from "./sandboxes.js";
|
|
12
|
+
import { CodeSandboxes, refuseGrant } from "./sandboxes.js";
|
|
13
13
|
import { executeCodeDescription, executeCodeInput } from "./tool.js";
|
|
14
14
|
export function plimsollCodeSandbox(opts) {
|
|
15
|
+
// A granted call cannot keep the run's sandbox; a chat that calls the operator's API
|
|
16
|
+
// builds the AI SDK add-on's plimsollGrantedCodeTool inside its run instead.
|
|
17
|
+
refuseGrant(opts, "plimsollGrantedCodeTool from @plimsollmark/client/ai-sdk, inside the run");
|
|
15
18
|
const sandboxes = new CodeSandboxes(opts);
|
|
16
19
|
const current = chat.local({ id: opts.localId ?? "plimsollCodeSandbox" });
|
|
17
20
|
// The owner warm named for each run, in this module's memory only.
|
package/dist/wire.d.ts
CHANGED
|
@@ -38,8 +38,10 @@ export type WireRunRequest = WireEnvelope & {
|
|
|
38
38
|
project?: WireProjectRun;
|
|
39
39
|
cell?: WireCellRun;
|
|
40
40
|
};
|
|
41
|
+
/** A session call: the run request with the session ID and the current ownership generation (a uint64, as a decimal string). */
|
|
41
42
|
export type WireSessionRunRequest = WireRunRequest & {
|
|
42
43
|
sessionId: string;
|
|
44
|
+
generation: string;
|
|
43
45
|
};
|
|
44
46
|
export type WireRecord = {
|
|
45
47
|
version?: number;
|
|
@@ -58,6 +60,9 @@ export type WireRecord = {
|
|
|
58
60
|
softwareIdentity?: string;
|
|
59
61
|
softwareRuleId?: string;
|
|
60
62
|
instance?: string;
|
|
63
|
+
isolationQualification?: string;
|
|
64
|
+
warm?: boolean;
|
|
65
|
+
daemonVersion?: string;
|
|
61
66
|
recordSha256?: string;
|
|
62
67
|
};
|
|
63
68
|
export type WireAdvice = {
|
|
@@ -122,6 +127,8 @@ export type WireRunResponse = {
|
|
|
122
127
|
environment?: string;
|
|
123
128
|
instance?: string;
|
|
124
129
|
warm?: boolean;
|
|
130
|
+
isolationQualification?: string;
|
|
131
|
+
daemonVersion?: string;
|
|
125
132
|
javascript?: WireJavaScriptResult;
|
|
126
133
|
project?: WireProjectResult;
|
|
127
134
|
module?: unknown;
|
|
@@ -177,6 +184,10 @@ export type WireOpenSessionRequest = {
|
|
|
177
184
|
warmOnly?: boolean;
|
|
178
185
|
};
|
|
179
186
|
export type WireOpenSessionResponse = {
|
|
187
|
+
generation?: string | number;
|
|
188
|
+
/** The floor and software rule the open sent, as the daemon keeps them. */
|
|
189
|
+
minimumIsolation?: string;
|
|
190
|
+
softwareRule?: WireSoftwareRule;
|
|
180
191
|
sessionId?: string;
|
|
181
192
|
session?: string;
|
|
182
193
|
sandbox?: string;
|
|
@@ -184,6 +195,30 @@ export type WireOpenSessionResponse = {
|
|
|
184
195
|
expiresUnixMs?: string | number;
|
|
185
196
|
idleTimeoutMs?: number;
|
|
186
197
|
softwareIdentity?: string;
|
|
198
|
+
isolationQualification?: string;
|
|
199
|
+
};
|
|
200
|
+
export type WireCloseSessionRequest = {
|
|
201
|
+
protocol: number;
|
|
202
|
+
sessionId: string;
|
|
203
|
+
generation: string;
|
|
204
|
+
};
|
|
205
|
+
/** A session's public chain head, the uint64s as decimal strings (plimsoll.v1.SessionCheckpoint). */
|
|
206
|
+
export type WireSessionCheckpoint = {
|
|
207
|
+
generation?: string | number;
|
|
208
|
+
calls?: string | number;
|
|
209
|
+
lastRecordSha256?: string;
|
|
210
|
+
};
|
|
211
|
+
export type WireAttachSessionRequest = {
|
|
212
|
+
protocol: number;
|
|
213
|
+
session: string;
|
|
214
|
+
checkpoint: WireSessionCheckpoint;
|
|
215
|
+
traceId?: string;
|
|
216
|
+
lostRequestSha256?: string;
|
|
217
|
+
};
|
|
218
|
+
export type WireAttachSessionResponse = {
|
|
219
|
+
sessionInfo?: WireOpenSessionResponse;
|
|
220
|
+
checkpoint?: WireSessionCheckpoint;
|
|
221
|
+
lostRecord?: WireRecord;
|
|
187
222
|
};
|
|
188
223
|
export type WireCloseSessionResponse = {
|
|
189
224
|
session?: string;
|
|
@@ -209,5 +244,18 @@ export declare class WireShapeError extends Error {
|
|
|
209
244
|
* "length" allocates that many bytes and reads each index, so a 30-byte
|
|
210
245
|
* {"length":2000000000} would cost 2 GB and a blocked event loop past the
|
|
211
246
|
* response's 32 MiB cap (Claude Security scan, 2026-10-27).
|
|
247
|
+
*
|
|
248
|
+
* The text must be base64 throughout, standard or URL-safe, padded or not, as protobuf
|
|
249
|
+
* JSON and Connect error details may carry it, and as the Python client reads it:
|
|
250
|
+
* Buffer.from skips any character outside the alphabet, so "CAY!" read as "CAY", and a
|
|
251
|
+
* refusal detail with a stray character marked a call nothing ran in where the Go and
|
|
252
|
+
* Python clients believe nothing of the detail (finding hunt-quality-93).
|
|
253
|
+
*
|
|
254
|
+
* The padding is counted off the end, not stripped with a pattern: /=+$/ is tried from
|
|
255
|
+
* every "=" of a run that is not at the end, so an answer holding a million "=" and one
|
|
256
|
+
* letter took minutes on one synchronous call that no deadline can cut (finding
|
|
257
|
+
* hunt-security-35). The alphabet test left is one anchored character class: one pass.
|
|
212
258
|
*/
|
|
213
259
|
export declare function wireBytes(v: unknown): Buffer;
|
|
260
|
+
/** How many times ch (one UTF-16 unit) ends s, counted from the end in one pass. */
|
|
261
|
+
export declare function trailing(s: string, ch: string): number;
|
package/dist/wire.js
CHANGED
|
@@ -12,11 +12,35 @@ export class WireShapeError extends Error {
|
|
|
12
12
|
* "length" allocates that many bytes and reads each index, so a 30-byte
|
|
13
13
|
* {"length":2000000000} would cost 2 GB and a blocked event loop past the
|
|
14
14
|
* response's 32 MiB cap (Claude Security scan, 2026-10-27).
|
|
15
|
+
*
|
|
16
|
+
* The text must be base64 throughout, standard or URL-safe, padded or not, as protobuf
|
|
17
|
+
* JSON and Connect error details may carry it, and as the Python client reads it:
|
|
18
|
+
* Buffer.from skips any character outside the alphabet, so "CAY!" read as "CAY", and a
|
|
19
|
+
* refusal detail with a stray character marked a call nothing ran in where the Go and
|
|
20
|
+
* Python clients believe nothing of the detail (finding hunt-quality-93).
|
|
21
|
+
*
|
|
22
|
+
* The padding is counted off the end, not stripped with a pattern: /=+$/ is tried from
|
|
23
|
+
* every "=" of a run that is not at the end, so an answer holding a million "=" and one
|
|
24
|
+
* letter took minutes on one synchronous call that no deadline can cut (finding
|
|
25
|
+
* hunt-security-35). The alphabet test left is one anchored character class: one pass.
|
|
15
26
|
*/
|
|
16
27
|
export function wireBytes(v) {
|
|
17
28
|
if (v === undefined || v === null)
|
|
18
29
|
return Buffer.alloc(0);
|
|
19
30
|
if (typeof v !== "string")
|
|
20
31
|
throw new WireShapeError(`a bytes field holds a ${Array.isArray(v) ? "list" : typeof v}, not base64 text`);
|
|
21
|
-
|
|
32
|
+
const core = v.slice(0, v.length - trailing(v, "="));
|
|
33
|
+
// Node's base64 decoder reads both alphabets, as Python's does with its URL-safe
|
|
34
|
+
// characters translated.
|
|
35
|
+
if (!/^[A-Za-z0-9+/_-]*$/.test(core) || core.length % 4 === 1)
|
|
36
|
+
throw new WireShapeError("a bytes field is not base64 text");
|
|
37
|
+
return Buffer.from(core, "base64");
|
|
38
|
+
}
|
|
39
|
+
/** How many times ch (one UTF-16 unit) ends s, counted from the end in one pass. */
|
|
40
|
+
export function trailing(s, ch) {
|
|
41
|
+
const c = ch.charCodeAt(0);
|
|
42
|
+
let n = 0;
|
|
43
|
+
while (n < s.length && s.charCodeAt(s.length - 1 - n) === c)
|
|
44
|
+
n++;
|
|
45
|
+
return n;
|
|
22
46
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plimsollmark/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "TypeScript client for plimsolld, with AI SDK, Trigger.dev and Mastra executeCode add-ons",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/plimsollmark/plimsoll/tree/main/clients/typescript#readme",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@mastra/core": ">=1.73.0 <2",
|
|
58
58
|
"@trigger.dev/sdk": ">=4.7.0 <5",
|
|
59
59
|
"ai": ">=7.0.126 <8",
|
|
60
|
-
"zod": ">=4.6.
|
|
60
|
+
"zod": ">=4.6.7 <5"
|
|
61
61
|
},
|
|
62
62
|
"peerDependenciesMeta": {
|
|
63
63
|
"@mastra/core": {
|