@b3os/sdk 0.1.0 → 0.2.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 +172 -42
- package/dist/cjs/core/bytes.d.ts +30 -0
- package/dist/cjs/core/bytes.js +115 -0
- package/dist/cjs/core/bytes.js.map +1 -0
- package/dist/cjs/core/client.d.ts +80 -3
- package/dist/cjs/core/client.js +236 -33
- package/dist/cjs/core/client.js.map +1 -1
- package/dist/cjs/core/errors.d.ts +16 -4
- package/dist/cjs/core/errors.js +9 -6
- package/dist/cjs/core/errors.js.map +1 -1
- package/dist/cjs/core/handle.d.ts +36 -0
- package/dist/cjs/core/handle.js +97 -0
- package/dist/cjs/core/handle.js.map +1 -0
- package/dist/cjs/core/index.d.ts +8 -4
- package/dist/cjs/core/index.js +14 -1
- package/dist/cjs/core/index.js.map +1 -1
- package/dist/cjs/core/login.d.ts +24 -0
- package/dist/cjs/core/login.js +93 -0
- package/dist/cjs/core/login.js.map +1 -0
- package/dist/cjs/core/namespace.d.ts +1 -1
- package/dist/cjs/core/namespace.js +1 -1
- package/dist/cjs/core/op.d.ts +11 -1
- package/dist/cjs/core/timing.d.ts +1 -1
- package/dist/cjs/core/timing.js +8 -1
- package/dist/cjs/core/timing.js.map +1 -1
- package/dist/cjs/core/traces-api.d.ts +42 -0
- package/dist/cjs/core/traces-api.js +54 -0
- package/dist/cjs/core/traces-api.js.map +1 -0
- package/dist/cjs/core/traces.d.ts +120 -0
- package/dist/cjs/core/traces.js +306 -0
- package/dist/cjs/core/traces.js.map +1 -0
- package/dist/cjs/core/transport.js +1 -1
- package/dist/cjs/core/transport.js.map +1 -1
- package/dist/cjs/core/util.d.ts +15 -3
- package/dist/cjs/core/util.js +54 -2
- package/dist/cjs/core/util.js.map +1 -1
- package/dist/cjs/core/ws.d.ts +4 -0
- package/dist/cjs/core/ws.js +7 -4
- package/dist/cjs/core/ws.js.map +1 -1
- package/dist/cjs/generated/client.d.ts +2 -2
- package/dist/cjs/generated/client.js +2 -2
- package/dist/cjs/generated/errors.d.ts +1 -1
- package/dist/cjs/generated/errors.js +42 -0
- package/dist/cjs/generated/errors.js.map +1 -1
- package/dist/cjs/generated/ids.d.ts +12 -0
- package/dist/cjs/generated/ids.js +3 -0
- package/dist/cjs/generated/ids.js.map +1 -1
- package/dist/cjs/generated/jobs.js +1 -1
- package/dist/cjs/generated/ns/actions.d.ts +48 -6
- package/dist/cjs/generated/ns/actions.js +59 -6
- package/dist/cjs/generated/ns/actions.js.map +1 -1
- package/dist/cjs/generated/ns/infer.d.ts +185 -54
- package/dist/cjs/generated/ns/infer.js +28 -74
- package/dist/cjs/generated/ns/infer.js.map +1 -1
- package/dist/cjs/generated/ns/keys.d.ts +14 -1
- package/dist/cjs/generated/ns/keys.js +24 -1
- package/dist/cjs/generated/ns/keys.js.map +1 -1
- package/dist/cjs/generated/ns/render.d.ts +115 -6
- package/dist/cjs/generated/ns/render.js +135 -7
- package/dist/cjs/generated/ns/render.js.map +1 -1
- package/dist/cjs/generated/ns/requests.d.ts +3 -1
- package/dist/cjs/generated/ns/requests.js +3 -1
- package/dist/cjs/generated/ns/requests.js.map +1 -1
- package/dist/cjs/generated/ns/routines.d.ts +131 -9
- package/dist/cjs/generated/ns/routines.js +186 -9
- package/dist/cjs/generated/ns/routines.js.map +1 -1
- package/dist/cjs/generated/ns/sandboxes.d.ts +327 -31
- package/dist/cjs/generated/ns/sandboxes.js +417 -29
- package/dist/cjs/generated/ns/sandboxes.js.map +1 -1
- package/dist/cjs/generated/ns/vision.d.ts +133 -14
- package/dist/cjs/generated/ns/vision.js +158 -12
- package/dist/cjs/generated/ns/vision.js.map +1 -1
- package/dist/cjs/generated/ns/webhooks.d.ts +8 -5
- package/dist/cjs/generated/ns/webhooks.js +8 -5
- package/dist/cjs/generated/ns/webhooks.js.map +1 -1
- package/dist/cjs/generated/types.d.ts +2750 -328
- package/dist/cjs/helpers/agents.d.ts +95 -0
- package/dist/cjs/helpers/agents.js +205 -0
- package/dist/cjs/helpers/agents.js.map +1 -0
- package/dist/cjs/helpers/render.d.ts +15 -0
- package/dist/cjs/helpers/render.js +74 -0
- package/dist/cjs/helpers/render.js.map +1 -0
- package/dist/cjs/helpers/routines.d.ts +61 -0
- package/dist/cjs/helpers/routines.js +234 -0
- package/dist/cjs/helpers/routines.js.map +1 -0
- package/dist/cjs/helpers/sandboxes.d.ts +237 -0
- package/dist/cjs/helpers/sandboxes.js +608 -0
- package/dist/cjs/helpers/sandboxes.js.map +1 -0
- package/dist/cjs/index.d.ts +4 -1
- package/dist/cjs/index.js +8 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/routines.d.ts +1 -0
- package/dist/cjs/routines.js +21 -0
- package/dist/cjs/routines.js.map +1 -0
- package/dist/cjs/webhooks.js.map +1 -1
- package/dist/esm/core/bytes.d.ts +30 -0
- package/dist/esm/core/bytes.js +111 -0
- package/dist/esm/core/bytes.js.map +1 -0
- package/dist/esm/core/client.d.ts +80 -3
- package/dist/esm/core/client.js +233 -31
- package/dist/esm/core/client.js.map +1 -1
- package/dist/esm/core/errors.d.ts +16 -4
- package/dist/esm/core/errors.js +9 -6
- package/dist/esm/core/errors.js.map +1 -1
- package/dist/esm/core/handle.d.ts +36 -0
- package/dist/esm/core/handle.js +93 -0
- package/dist/esm/core/handle.js.map +1 -0
- package/dist/esm/core/index.d.ts +8 -4
- package/dist/esm/core/index.js +6 -2
- package/dist/esm/core/index.js.map +1 -1
- package/dist/esm/core/login.d.ts +24 -0
- package/dist/esm/core/login.js +85 -0
- package/dist/esm/core/login.js.map +1 -0
- package/dist/esm/core/namespace.d.ts +1 -1
- package/dist/esm/core/namespace.js +1 -1
- package/dist/esm/core/op.d.ts +11 -1
- package/dist/esm/core/timing.d.ts +1 -1
- package/dist/esm/core/timing.js +8 -1
- package/dist/esm/core/timing.js.map +1 -1
- package/dist/esm/core/traces-api.d.ts +42 -0
- package/dist/esm/core/traces-api.js +50 -0
- package/dist/esm/core/traces-api.js.map +1 -0
- package/dist/esm/core/traces.d.ts +120 -0
- package/dist/esm/core/traces.js +295 -0
- package/dist/esm/core/traces.js.map +1 -0
- package/dist/esm/core/transport.js +1 -1
- package/dist/esm/core/transport.js.map +1 -1
- package/dist/esm/core/util.d.ts +15 -3
- package/dist/esm/core/util.js +48 -1
- package/dist/esm/core/util.js.map +1 -1
- package/dist/esm/core/ws.d.ts +4 -0
- package/dist/esm/core/ws.js +7 -4
- package/dist/esm/core/ws.js.map +1 -1
- package/dist/esm/generated/client.d.ts +2 -2
- package/dist/esm/generated/client.js +2 -2
- package/dist/esm/generated/errors.d.ts +1 -1
- package/dist/esm/generated/errors.js +42 -0
- package/dist/esm/generated/errors.js.map +1 -1
- package/dist/esm/generated/ids.d.ts +12 -0
- package/dist/esm/generated/ids.js +3 -0
- package/dist/esm/generated/ids.js.map +1 -1
- package/dist/esm/generated/jobs.js +1 -1
- package/dist/esm/generated/ns/actions.d.ts +48 -6
- package/dist/esm/generated/ns/actions.js +59 -6
- package/dist/esm/generated/ns/actions.js.map +1 -1
- package/dist/esm/generated/ns/infer.d.ts +185 -54
- package/dist/esm/generated/ns/infer.js +28 -74
- package/dist/esm/generated/ns/infer.js.map +1 -1
- package/dist/esm/generated/ns/keys.d.ts +14 -1
- package/dist/esm/generated/ns/keys.js +24 -1
- package/dist/esm/generated/ns/keys.js.map +1 -1
- package/dist/esm/generated/ns/render.d.ts +115 -6
- package/dist/esm/generated/ns/render.js +135 -7
- package/dist/esm/generated/ns/render.js.map +1 -1
- package/dist/esm/generated/ns/requests.d.ts +3 -1
- package/dist/esm/generated/ns/requests.js +3 -1
- package/dist/esm/generated/ns/requests.js.map +1 -1
- package/dist/esm/generated/ns/routines.d.ts +131 -9
- package/dist/esm/generated/ns/routines.js +186 -9
- package/dist/esm/generated/ns/routines.js.map +1 -1
- package/dist/esm/generated/ns/sandboxes.d.ts +327 -31
- package/dist/esm/generated/ns/sandboxes.js +417 -29
- package/dist/esm/generated/ns/sandboxes.js.map +1 -1
- package/dist/esm/generated/ns/vision.d.ts +133 -14
- package/dist/esm/generated/ns/vision.js +158 -12
- package/dist/esm/generated/ns/vision.js.map +1 -1
- package/dist/esm/generated/ns/webhooks.d.ts +8 -5
- package/dist/esm/generated/ns/webhooks.js +8 -5
- package/dist/esm/generated/ns/webhooks.js.map +1 -1
- package/dist/esm/generated/types.d.ts +2750 -328
- package/dist/esm/helpers/agents.d.ts +95 -0
- package/dist/esm/helpers/agents.js +199 -0
- package/dist/esm/helpers/agents.js.map +1 -0
- package/dist/esm/helpers/render.d.ts +15 -0
- package/dist/esm/helpers/render.js +70 -0
- package/dist/esm/helpers/render.js.map +1 -0
- package/dist/esm/helpers/routines.d.ts +61 -0
- package/dist/esm/helpers/routines.js +226 -0
- package/dist/esm/helpers/routines.js.map +1 -0
- package/dist/esm/helpers/sandboxes.d.ts +237 -0
- package/dist/esm/helpers/sandboxes.js +600 -0
- package/dist/esm/helpers/sandboxes.js.map +1 -0
- package/dist/esm/index.d.ts +4 -1
- package/dist/esm/index.js +6 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/routines.d.ts +1 -0
- package/dist/esm/routines.js +5 -0
- package/dist/esm/routines.js.map +1 -0
- package/dist/esm/webhooks.js.map +1 -1
- package/package.json +14 -3
- package/src/core/bytes.ts +112 -0
- package/src/core/client.ts +285 -33
- package/src/core/errors.ts +27 -10
- package/src/core/handle.ts +107 -0
- package/src/core/index.ts +17 -2
- package/src/core/login.ts +98 -0
- package/src/core/namespace.ts +1 -1
- package/src/core/op.ts +11 -1
- package/src/core/timing.ts +7 -2
- package/src/core/traces-api.ts +80 -0
- package/src/core/traces.ts +375 -0
- package/src/core/transport.ts +1 -1
- package/src/core/util.ts +53 -3
- package/src/core/ws.ts +11 -4
- package/src/generated/client.ts +2 -2
- package/src/generated/errors.ts +84 -0
- package/src/generated/ids.ts +3 -0
- package/src/generated/jobs.ts +1 -1
- package/src/generated/ns/actions.ts +69 -6
- package/src/generated/ns/infer.ts +229 -61
- package/src/generated/ns/keys.ts +25 -1
- package/src/generated/ns/render.ts +172 -7
- package/src/generated/ns/requests.ts +3 -1
- package/src/generated/ns/routines.ts +205 -9
- package/src/generated/ns/sandboxes.ts +493 -34
- package/src/generated/ns/vision.ts +168 -14
- package/src/generated/ns/webhooks.ts +8 -5
- package/src/generated/types.ts +3034 -472
- package/src/helpers/agents.ts +300 -0
- package/src/helpers/render.ts +91 -0
- package/src/helpers/routines.ts +278 -0
- package/src/helpers/sandboxes.ts +788 -0
- package/src/index.ts +29 -5
- package/src/routines.ts +5 -0
- package/src/webhooks.ts +5 -1
package/src/core/transport.ts
CHANGED
|
@@ -331,7 +331,7 @@ export class NodeHttpTransport implements Transport {
|
|
|
331
331
|
/** Over a Unix socket (`{socketPath}`) or to a plain-HTTP base URL (`{baseUrl}`). */
|
|
332
332
|
constructor(target: { socketPath: string } | { baseUrl: string }) {
|
|
333
333
|
const http = builtin<typeof NodeHttp>("node:http");
|
|
334
|
-
if (!http) throw new Error("@b3os/sdk: this transport needs node:http (Node
|
|
334
|
+
if (!http) throw new Error("@b3os/sdk: this transport needs node:http (Node 22.3+)");
|
|
335
335
|
this.http = http;
|
|
336
336
|
// Pooled sockets idle for 20-25 s are closed by a sweep, before b3osd's 30 s header-read timeout can close one
|
|
337
337
|
// under a new request. The agent's `timeout` option would do the same, but it costs every request a listener
|
package/src/core/util.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Small runtime helpers shared by the core. Nothing here imports a Node module statically, so the package loads
|
|
2
2
|
// unchanged on Node, Bun, Deno, Cloudflare Workers and browsers.
|
|
3
3
|
|
|
4
|
-
export const SDK_VERSION = "0.
|
|
4
|
+
export const SDK_VERSION = "0.2.0";
|
|
5
5
|
|
|
6
6
|
interface ProcessLike {
|
|
7
7
|
env?: Record<string, string | undefined>;
|
|
@@ -78,6 +78,42 @@ export function uuid(): string {
|
|
|
78
78
|
return `${h.slice(0, 8)}-${h.slice(8, 12)}-${h.slice(12, 16)}-${h.slice(16, 20)}-${h.slice(20)}`;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/** `n` random bytes as lower-case hex, never all zeros (W3C trace context forbids all-zero ids). */
|
|
82
|
+
function randomHex(n: number): string {
|
|
83
|
+
const c = globalThis.crypto as typeof globalThis.crypto | undefined;
|
|
84
|
+
const b = new Uint8Array(n);
|
|
85
|
+
for (;;) {
|
|
86
|
+
if (c && typeof c.getRandomValues === "function") c.getRandomValues(b);
|
|
87
|
+
// Trace ids identify, they do not authorize: Math.random is enough where no CSPRNG exists.
|
|
88
|
+
else for (let i = 0; i < n; i++) b[i] = Math.floor(Math.random() * 256);
|
|
89
|
+
if (b.some((x) => x !== 0)) return Array.from(b, (x: number) => x.toString(16).padStart(2, "0")).join("");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** A W3C trace-id: 32 hex digits. */
|
|
94
|
+
export function newTraceId(): string {
|
|
95
|
+
return randomHex(16);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** A W3C parent-id (span id): 16 hex digits. */
|
|
99
|
+
export function newSpanId(): string {
|
|
100
|
+
return randomHex(8);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** A sampled W3C `traceparent` (version 00) in trace `traceId`, with a new span id. */
|
|
104
|
+
export function traceparentIn(traceId: string): string {
|
|
105
|
+
return `00-${traceId}-${newSpanId()}-01`;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** `traceparent` as W3C Trace Context level 1 defines version 00 (lower-case hex, non-zero ids). */
|
|
109
|
+
export const TRACEPARENT_RE = /^00-(?!0{32})[0-9a-f]{32}-(?!0{16})[0-9a-f]{16}-[0-9a-f]{2}$/;
|
|
110
|
+
|
|
111
|
+
/** The trace-id of a valid version-00 `traceparent`, else undefined. */
|
|
112
|
+
export function traceIdOf(traceparent: string | undefined): string | undefined {
|
|
113
|
+
const t = traceparent?.trim().toLowerCase();
|
|
114
|
+
return t && TRACEPARENT_RE.test(t) ? t.slice(3, 35) : undefined;
|
|
115
|
+
}
|
|
116
|
+
|
|
81
117
|
/** Resolves after `ms`, or rejects with the signal's reason when it aborts first. */
|
|
82
118
|
export function sleep(ms: number, signal?: AbortSignal): Promise<void> {
|
|
83
119
|
return new Promise((resolve, reject) => {
|
|
@@ -117,8 +153,11 @@ export function isObject(v: unknown): v is Record<string, unknown> {
|
|
|
117
153
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
118
154
|
}
|
|
119
155
|
|
|
120
|
-
|
|
121
|
-
|
|
156
|
+
// Typed through the global value, which each project's own lib declares: an inferred type would be written into the
|
|
157
|
+
// .d.ts as @types/node's `import("util").TextDecoder`, which a Workers or browser project without @types/node
|
|
158
|
+
// cannot resolve (dx#8).
|
|
159
|
+
export const textDecoder: InstanceType<typeof TextDecoder> = new TextDecoder();
|
|
160
|
+
export const textEncoder: InstanceType<typeof TextEncoder> = new TextEncoder();
|
|
122
161
|
|
|
123
162
|
export function concatBytes(chunks: Uint8Array[], total?: number): Uint8Array {
|
|
124
163
|
if (chunks.length === 1 && chunks[0]) return chunks[0];
|
|
@@ -136,3 +175,14 @@ export function concatBytes(chunks: Uint8Array[], total?: number): Uint8Array {
|
|
|
136
175
|
export function camel(s: string): string {
|
|
137
176
|
return s.replace(/[-_]([a-z0-9])/g, (_, c: string) => c.toUpperCase());
|
|
138
177
|
}
|
|
178
|
+
|
|
179
|
+
/** A transport error as one line: its code and the cause's message when they add something. */
|
|
180
|
+
export function describeErr(err: unknown): string {
|
|
181
|
+
if (err instanceof Error) {
|
|
182
|
+
const cause = (err as Error & { cause?: { code?: string; message?: string } }).cause;
|
|
183
|
+
const code = (err as { code?: string }).code ?? cause?.code;
|
|
184
|
+
const msg = cause?.message && cause.message !== err.message ? `${err.message} (${cause.message})` : err.message;
|
|
185
|
+
return code && !msg.includes(code) ? `${code}: ${msg}` : msg;
|
|
186
|
+
}
|
|
187
|
+
return String(err);
|
|
188
|
+
}
|
package/src/core/ws.ts
CHANGED
|
@@ -94,7 +94,10 @@ export function openSocket(url: string, protocols: string[], signal?: AbortSigna
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
export interface PtyExit {
|
|
97
|
+
/** The shell's exit code; `null` when it was killed by a signal or when no exit message came. */
|
|
97
98
|
code: number | null;
|
|
99
|
+
/** True when the server sent the exit message; false when the socket closed without one (a lost connection). */
|
|
100
|
+
exited: boolean;
|
|
98
101
|
/** WebSocket close code and reason when the socket closed without an exit message. */
|
|
99
102
|
closeCode?: number;
|
|
100
103
|
closeReason?: string;
|
|
@@ -112,6 +115,7 @@ export class PtySession implements AsyncIterable<Uint8Array> {
|
|
|
112
115
|
private iterated = false;
|
|
113
116
|
private queued = 0;
|
|
114
117
|
private exitCode: number | null = null;
|
|
118
|
+
private exited = false;
|
|
115
119
|
private readonly listeners = new Set<(chunk: Uint8Array) => void>();
|
|
116
120
|
readonly socket: WebSocket;
|
|
117
121
|
|
|
@@ -126,7 +130,10 @@ export class PtySession implements AsyncIterable<Uint8Array> {
|
|
|
126
130
|
if (typeof d === "string") {
|
|
127
131
|
try {
|
|
128
132
|
const msg = JSON.parse(d) as { type?: string; code?: number };
|
|
129
|
-
if (msg.type === "exit")
|
|
133
|
+
if (msg.type === "exit") {
|
|
134
|
+
this.exited = true;
|
|
135
|
+
this.exitCode = typeof msg.code === "number" ? msg.code : null;
|
|
136
|
+
}
|
|
130
137
|
} catch {
|
|
131
138
|
this.push(textEncoder.encode(d));
|
|
132
139
|
}
|
|
@@ -140,9 +147,9 @@ export class PtySession implements AsyncIterable<Uint8Array> {
|
|
|
140
147
|
for (const w of this.waiters) w({ value: undefined, done: true });
|
|
141
148
|
this.waiters = [];
|
|
142
149
|
settle(
|
|
143
|
-
this.
|
|
144
|
-
? { code: this.exitCode }
|
|
145
|
-
: { code: null, closeCode: ev.code, closeReason: ev.reason || undefined },
|
|
150
|
+
this.exited
|
|
151
|
+
? { code: this.exitCode, exited: true }
|
|
152
|
+
: { code: null, exited: false, closeCode: ev.code, closeReason: ev.reason || undefined },
|
|
146
153
|
);
|
|
147
154
|
});
|
|
148
155
|
}
|
package/src/generated/client.ts
CHANGED
|
@@ -24,8 +24,8 @@ import { WebhooksAPI } from "./ns/webhooks.ts";
|
|
|
24
24
|
*
|
|
25
25
|
* ```ts
|
|
26
26
|
* import { B3OS } from "@b3os/sdk";
|
|
27
|
-
* const
|
|
28
|
-
* const page = await
|
|
27
|
+
* const b3os = new B3OS();
|
|
28
|
+
* const page = await b3os.vision.scrape({ url: "https://example.com" });
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
export class B3OS extends B3OSCore {
|
package/src/generated/errors.ts
CHANGED
|
@@ -11,12 +11,16 @@ export const ERROR_CATALOG: Readonly<Record<string, readonly [status: number, re
|
|
|
11
11
|
not_acceptable: [406, 0, "Not acceptable"],
|
|
12
12
|
payload_too_large: [413, 0, "Payload too large"],
|
|
13
13
|
route_not_found: [404, 0, "Route not found"],
|
|
14
|
+
feature_not_enabled: [404, 0, "Feature not enabled"],
|
|
14
15
|
method_not_allowed: [405, 0, "Method not allowed"],
|
|
15
16
|
edge_only: [421, 0, "Served by beta-api.b3os.org"],
|
|
16
17
|
limit_exceeded: [422, 0, "Limit exceeded"],
|
|
18
|
+
option_not_allowed: [422, 0, "Option not allowed"],
|
|
17
19
|
idempotency_key_invalid: [400, 0, "Invalid idempotency key"],
|
|
18
20
|
idempotency_key_conflict: [409, 0, "Idempotency key conflict"],
|
|
19
21
|
idempotency_request_in_progress: [409, 1, "Request in progress"],
|
|
22
|
+
idempotency_response_evicted: [409, 0, "Stored response evicted"],
|
|
23
|
+
idempotency_outcome_unknown: [409, 0, "Outcome unknown"],
|
|
20
24
|
conflict: [409, 0, "Conflict"],
|
|
21
25
|
resource_not_found: [404, 0, "Not found"],
|
|
22
26
|
not_implemented: [501, 0, "Not implemented"],
|
|
@@ -68,6 +72,20 @@ export const ERROR_CATALOG: Readonly<Record<string, readonly [status: number, re
|
|
|
68
72
|
pack_signature_invalid: [422, 0, "Invalid pack signature"],
|
|
69
73
|
org_suspended: [403, 0, "Organization suspended"],
|
|
70
74
|
hook_queue_full: [503, 1, "Webhook queue full"],
|
|
75
|
+
email_unavailable: [503, 1, "Email sign-in unavailable"],
|
|
76
|
+
turnstile_required: [400, 0, "Turnstile token required"],
|
|
77
|
+
turnstile_failed: [403, 0, "Turnstile check failed"],
|
|
78
|
+
turnstile_unavailable: [503, 1, "Turnstile unavailable"],
|
|
79
|
+
github_app_not_configured: [503, 0, "GitHub App not configured"],
|
|
80
|
+
github_installation_not_found: [404, 0, "GitHub installation not found"],
|
|
81
|
+
github_repository_not_accessible: [404, 0, "GitHub repository not accessible"],
|
|
82
|
+
repository_link_not_found: [404, 0, "Repository link not found"],
|
|
83
|
+
eval_run_not_found: [404, 0, "Eval run not found"],
|
|
84
|
+
alert_destination_not_found: [404, 0, "Alert destination not found"],
|
|
85
|
+
trace_not_found: [404, 0, "Trace not found"],
|
|
86
|
+
deploy_not_found: [404, 0, "Deploy not found"],
|
|
87
|
+
deploy_not_rollbackable: [409, 0, "Deploy cannot be rolled back to"],
|
|
88
|
+
deploy_not_updatable: [409, 0, "Deploy cannot change this way"],
|
|
71
89
|
authorization_pending: [400, 1, "Authorization pending"],
|
|
72
90
|
slow_down: [400, 1, "Slow down"],
|
|
73
91
|
access_denied: [400, 0, "Access denied"],
|
|
@@ -81,6 +99,7 @@ export const ERROR_CATALOG: Readonly<Record<string, readonly [status: number, re
|
|
|
81
99
|
profile_domain_mismatch: [422, 0, "Profile domain mismatch"],
|
|
82
100
|
profile_conflict: [409, 0, "Profile changed since it was loaded"],
|
|
83
101
|
profile_name_taken: [409, 0, "Profile name taken"],
|
|
102
|
+
profile_not_exportable: [403, 0, "Profile not exportable"],
|
|
84
103
|
crawl_not_found: [404, 0, "Crawl not found"],
|
|
85
104
|
batch_not_found: [404, 0, "Batch scrape not found"],
|
|
86
105
|
robots_disallowed: [403, 0, "Disallowed by robots.txt"],
|
|
@@ -88,10 +107,16 @@ export const ERROR_CATALOG: Readonly<Record<string, readonly [status: number, re
|
|
|
88
107
|
navigation_failed: [502, 1, "Navigation failed"],
|
|
89
108
|
scrape_timeout: [504, 1, "Scrape timed out"],
|
|
90
109
|
target_not_found: [422, 0, "Target not found"],
|
|
110
|
+
target_covered: [422, 0, "Target covered"],
|
|
111
|
+
stale_ref: [422, 0, "Stale ref"],
|
|
91
112
|
act_step_failed: [422, 0, "Browser action failed"],
|
|
92
113
|
cdp_method_blocked: [403, 0, "CDP method not allowed"],
|
|
93
114
|
extraction_failed: [502, 1, "Extraction failed"],
|
|
94
115
|
scrape_no_cached_data: [404, 0, "No cached copy"],
|
|
116
|
+
scrape_lockdown_cache_miss: [404, 0, "Not in the cache (lockdown)"],
|
|
117
|
+
search_unavailable: [503, 1, "Search unavailable"],
|
|
118
|
+
search_failed: [502, 1, "Search failed"],
|
|
119
|
+
search_answer_too_large: [413, 0, "Search answer too large"],
|
|
95
120
|
screenshot_not_found: [404, 0, "Screenshot not found"],
|
|
96
121
|
video_not_found: [404, 0, "Video not found"],
|
|
97
122
|
artifact_not_found: [404, 0, "Artifact not found"],
|
|
@@ -99,23 +124,31 @@ export const ERROR_CATALOG: Readonly<Record<string, readonly [status: number, re
|
|
|
99
124
|
capture_failed: [502, 1, "Capture failed"],
|
|
100
125
|
script_invalid: [422, 0, "Invalid video script"],
|
|
101
126
|
script_step_failed: [422, 0, "Script step failed"],
|
|
127
|
+
profile_expired: [422, 0, "Profile no longer signs in"],
|
|
102
128
|
restyle_unavailable: [409, 0, "Restyle not available"],
|
|
129
|
+
background_unavailable: [503, 1, "Background unavailable"],
|
|
103
130
|
style_invalid: [422, 0, "Invalid style"],
|
|
104
131
|
sandbox_not_found: [404, 0, "Sandbox not found"],
|
|
105
132
|
sandbox_not_running: [409, 0, "Sandbox not running"],
|
|
106
133
|
template_not_found: [404, 0, "Template not found"],
|
|
107
134
|
snapshot_not_found: [404, 0, "Snapshot not found"],
|
|
135
|
+
snapshot_damaged: [409, 0, "Snapshot damaged"],
|
|
108
136
|
file_not_found: [404, 0, "File not found"],
|
|
109
137
|
path_invalid: [422, 0, "Invalid path"],
|
|
110
138
|
not_a_directory: [422, 0, "Not a directory"],
|
|
139
|
+
file_exists: [409, 0, "File exists"],
|
|
140
|
+
directory_not_empty: [409, 0, "Directory not empty"],
|
|
141
|
+
guest_outdated: [409, 0, "Sandbox agent predates the operation"],
|
|
111
142
|
file_too_large: [413, 0, "File too large"],
|
|
112
143
|
port_not_exposed: [404, 0, "Port not exposed"],
|
|
144
|
+
upstream_first_byte_timeout: [504, 0, "Upstream first byte timeout"],
|
|
113
145
|
process_not_found: [404, 0, "Process not found"],
|
|
114
146
|
kernel_unavailable: [409, 0, "Code kernel unavailable"],
|
|
115
147
|
language_unsupported: [422, 0, "Language not supported"],
|
|
116
148
|
guest_unreachable: [502, 1, "Sandbox agent unreachable"],
|
|
117
149
|
snapshot_failed: [500, 1, "Snapshot failed"],
|
|
118
150
|
fork_unavailable: [409, 0, "Fork not available"],
|
|
151
|
+
envd_token_invalid: [401, 0, "envd access token invalid"],
|
|
119
152
|
routine_not_found: [404, 0, "Routine not found"],
|
|
120
153
|
routine_version_not_found: [404, 0, "Routine version not found"],
|
|
121
154
|
run_not_found: [404, 0, "Run not found"],
|
|
@@ -123,6 +156,14 @@ export const ERROR_CATALOG: Readonly<Record<string, readonly [status: number, re
|
|
|
123
156
|
routine_invalid: [422, 0, "Invalid routine"],
|
|
124
157
|
routine_name_taken: [409, 0, "Routine name taken"],
|
|
125
158
|
run_not_waiting: [409, 0, "Run is not waiting for this signal"],
|
|
159
|
+
event_fan_out_too_large: [422, 0, "Event fans out too far"],
|
|
160
|
+
wait_link_invalid: [404, 0, "Wait link not valid"],
|
|
161
|
+
wait_not_ready: [409, 1, "Wait not ready"],
|
|
162
|
+
wait_already_answered: [410, 0, "Wait already answered"],
|
|
163
|
+
wait_link_expired: [410, 0, "Wait link expired"],
|
|
164
|
+
run_not_finished: [409, 0, "Run not finished"],
|
|
165
|
+
run_steps_not_kept: [410, 0, "Run steps not kept"],
|
|
166
|
+
replay_too_large: [422, 0, "Replay too large"],
|
|
126
167
|
run_as_revoked: [403, 0, "Publishing key revoked"],
|
|
127
168
|
webhook_signature_invalid: [401, 0, "Webhook verification failed"],
|
|
128
169
|
step_failed: [422, 0, "Step failed"],
|
|
@@ -130,6 +171,7 @@ export const ERROR_CATALOG: Readonly<Record<string, readonly [status: number, re
|
|
|
130
171
|
run_input_invalid: [422, 0, "Invalid run input"],
|
|
131
172
|
step_timed_out: [504, 1, "Step timed out"],
|
|
132
173
|
step_outcome_unknown: [409, 0, "Step outcome unknown"],
|
|
174
|
+
internal_recovery_failed: [500, 0, "Recovery failed"],
|
|
133
175
|
hook_attestation_unverifiable: [503, 1, "Webhook replay cannot be checked yet"],
|
|
134
176
|
pack_not_found: [404, 0, "Pack not found"],
|
|
135
177
|
pack_version_not_found: [404, 0, "Pack version not found"],
|
|
@@ -166,12 +208,16 @@ export type B3OSServerErrorCode =
|
|
|
166
208
|
| "not_acceptable"
|
|
167
209
|
| "payload_too_large"
|
|
168
210
|
| "route_not_found"
|
|
211
|
+
| "feature_not_enabled"
|
|
169
212
|
| "method_not_allowed"
|
|
170
213
|
| "edge_only"
|
|
171
214
|
| "limit_exceeded"
|
|
215
|
+
| "option_not_allowed"
|
|
172
216
|
| "idempotency_key_invalid"
|
|
173
217
|
| "idempotency_key_conflict"
|
|
174
218
|
| "idempotency_request_in_progress"
|
|
219
|
+
| "idempotency_response_evicted"
|
|
220
|
+
| "idempotency_outcome_unknown"
|
|
175
221
|
| "conflict"
|
|
176
222
|
| "resource_not_found"
|
|
177
223
|
| "not_implemented"
|
|
@@ -223,6 +269,20 @@ export type B3OSServerErrorCode =
|
|
|
223
269
|
| "pack_signature_invalid"
|
|
224
270
|
| "org_suspended"
|
|
225
271
|
| "hook_queue_full"
|
|
272
|
+
| "email_unavailable"
|
|
273
|
+
| "turnstile_required"
|
|
274
|
+
| "turnstile_failed"
|
|
275
|
+
| "turnstile_unavailable"
|
|
276
|
+
| "github_app_not_configured"
|
|
277
|
+
| "github_installation_not_found"
|
|
278
|
+
| "github_repository_not_accessible"
|
|
279
|
+
| "repository_link_not_found"
|
|
280
|
+
| "eval_run_not_found"
|
|
281
|
+
| "alert_destination_not_found"
|
|
282
|
+
| "trace_not_found"
|
|
283
|
+
| "deploy_not_found"
|
|
284
|
+
| "deploy_not_rollbackable"
|
|
285
|
+
| "deploy_not_updatable"
|
|
226
286
|
| "authorization_pending"
|
|
227
287
|
| "slow_down"
|
|
228
288
|
| "access_denied"
|
|
@@ -236,6 +296,7 @@ export type B3OSServerErrorCode =
|
|
|
236
296
|
| "profile_domain_mismatch"
|
|
237
297
|
| "profile_conflict"
|
|
238
298
|
| "profile_name_taken"
|
|
299
|
+
| "profile_not_exportable"
|
|
239
300
|
| "crawl_not_found"
|
|
240
301
|
| "batch_not_found"
|
|
241
302
|
| "robots_disallowed"
|
|
@@ -243,10 +304,16 @@ export type B3OSServerErrorCode =
|
|
|
243
304
|
| "navigation_failed"
|
|
244
305
|
| "scrape_timeout"
|
|
245
306
|
| "target_not_found"
|
|
307
|
+
| "target_covered"
|
|
308
|
+
| "stale_ref"
|
|
246
309
|
| "act_step_failed"
|
|
247
310
|
| "cdp_method_blocked"
|
|
248
311
|
| "extraction_failed"
|
|
249
312
|
| "scrape_no_cached_data"
|
|
313
|
+
| "scrape_lockdown_cache_miss"
|
|
314
|
+
| "search_unavailable"
|
|
315
|
+
| "search_failed"
|
|
316
|
+
| "search_answer_too_large"
|
|
250
317
|
| "screenshot_not_found"
|
|
251
318
|
| "video_not_found"
|
|
252
319
|
| "artifact_not_found"
|
|
@@ -254,23 +321,31 @@ export type B3OSServerErrorCode =
|
|
|
254
321
|
| "capture_failed"
|
|
255
322
|
| "script_invalid"
|
|
256
323
|
| "script_step_failed"
|
|
324
|
+
| "profile_expired"
|
|
257
325
|
| "restyle_unavailable"
|
|
326
|
+
| "background_unavailable"
|
|
258
327
|
| "style_invalid"
|
|
259
328
|
| "sandbox_not_found"
|
|
260
329
|
| "sandbox_not_running"
|
|
261
330
|
| "template_not_found"
|
|
262
331
|
| "snapshot_not_found"
|
|
332
|
+
| "snapshot_damaged"
|
|
263
333
|
| "file_not_found"
|
|
264
334
|
| "path_invalid"
|
|
265
335
|
| "not_a_directory"
|
|
336
|
+
| "file_exists"
|
|
337
|
+
| "directory_not_empty"
|
|
338
|
+
| "guest_outdated"
|
|
266
339
|
| "file_too_large"
|
|
267
340
|
| "port_not_exposed"
|
|
341
|
+
| "upstream_first_byte_timeout"
|
|
268
342
|
| "process_not_found"
|
|
269
343
|
| "kernel_unavailable"
|
|
270
344
|
| "language_unsupported"
|
|
271
345
|
| "guest_unreachable"
|
|
272
346
|
| "snapshot_failed"
|
|
273
347
|
| "fork_unavailable"
|
|
348
|
+
| "envd_token_invalid"
|
|
274
349
|
| "routine_not_found"
|
|
275
350
|
| "routine_version_not_found"
|
|
276
351
|
| "run_not_found"
|
|
@@ -278,6 +353,14 @@ export type B3OSServerErrorCode =
|
|
|
278
353
|
| "routine_invalid"
|
|
279
354
|
| "routine_name_taken"
|
|
280
355
|
| "run_not_waiting"
|
|
356
|
+
| "event_fan_out_too_large"
|
|
357
|
+
| "wait_link_invalid"
|
|
358
|
+
| "wait_not_ready"
|
|
359
|
+
| "wait_already_answered"
|
|
360
|
+
| "wait_link_expired"
|
|
361
|
+
| "run_not_finished"
|
|
362
|
+
| "run_steps_not_kept"
|
|
363
|
+
| "replay_too_large"
|
|
281
364
|
| "run_as_revoked"
|
|
282
365
|
| "webhook_signature_invalid"
|
|
283
366
|
| "step_failed"
|
|
@@ -285,6 +368,7 @@ export type B3OSServerErrorCode =
|
|
|
285
368
|
| "run_input_invalid"
|
|
286
369
|
| "step_timed_out"
|
|
287
370
|
| "step_outcome_unknown"
|
|
371
|
+
| "internal_recovery_failed"
|
|
288
372
|
| "hook_attestation_unverifiable"
|
|
289
373
|
| "pack_not_found"
|
|
290
374
|
| "pack_version_not_found"
|
package/src/generated/ids.ts
CHANGED
|
@@ -31,6 +31,9 @@ export const ID_PREFIXES = {
|
|
|
31
31
|
tkt: { object: "stream_ticket", product: "platform", secret: true },
|
|
32
32
|
evt: { object: "event", product: "platform" },
|
|
33
33
|
usr: { object: "user", product: "platform" },
|
|
34
|
+
dep: { object: "deploy", product: "platform" },
|
|
35
|
+
evr: { object: "eval_run", product: "platform" },
|
|
36
|
+
alt: { object: "alert", product: "platform" },
|
|
34
37
|
} as const;
|
|
35
38
|
|
|
36
39
|
export type IdPrefix = keyof typeof ID_PREFIXES;
|
package/src/generated/jobs.ts
CHANGED
|
@@ -10,7 +10,7 @@ export const JOB_OPS: Readonly<Record<string, JobOps>> = {
|
|
|
10
10
|
batch: visionOps.createBatch.job as JobOps,
|
|
11
11
|
crawl: visionOps.createCrawl.job as JobOps,
|
|
12
12
|
vid: renderOps.createVideo.job as JobOps,
|
|
13
|
-
run: routinesOps.
|
|
13
|
+
run: routinesOps.replayRun.job as JobOps,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -37,6 +37,15 @@ const getPackOp: Op = {
|
|
|
37
37
|
timeoutMs: 10000,
|
|
38
38
|
scope: "actions:read",
|
|
39
39
|
};
|
|
40
|
+
const getPackToolsOp: Op = {
|
|
41
|
+
id: "actionsGetPackTools",
|
|
42
|
+
method: "GET",
|
|
43
|
+
path: "/v1/actions/packs/{namespace}/{name}/tools",
|
|
44
|
+
params: ["namespace", "name"],
|
|
45
|
+
headerParams: { if_none_match: "If-None-Match" },
|
|
46
|
+
timeoutMs: 10000,
|
|
47
|
+
scope: "actions:read",
|
|
48
|
+
};
|
|
40
49
|
const getPackManifestOp: Op = {
|
|
41
50
|
id: "actionsGetPackManifest",
|
|
42
51
|
method: "GET",
|
|
@@ -126,6 +135,7 @@ export const actionsOps = {
|
|
|
126
135
|
describe: describeOp,
|
|
127
136
|
listPacks: listPacksOp,
|
|
128
137
|
getPack: getPackOp,
|
|
138
|
+
getPackTools: getPackToolsOp,
|
|
129
139
|
getPackManifest: getPackManifestOp,
|
|
130
140
|
listRegistryPacks: listRegistryPacksOp,
|
|
131
141
|
publishPack: publishPackOp,
|
|
@@ -145,10 +155,27 @@ export class ActionsAPI extends Namespace {
|
|
|
145
155
|
*
|
|
146
156
|
* Validates `input` against the action's schema, runs it, validates the result against its output schema and
|
|
147
157
|
* returns it. Credentials come from `connections` (pack connection key to `conn_` ID), or else from your
|
|
148
|
-
* project's most recently created connection for that pack and key
|
|
149
|
-
* user (
|
|
150
|
-
*
|
|
151
|
-
* connection
|
|
158
|
+
* project's most recently created connection for that pack and key that has no `subject`: an unnamed key never
|
|
159
|
+
* uses an end user's connection (one with a `subject`), even when it is newer; name end-user connections
|
|
160
|
+
* explicitly. A call with `subject` (your end user's ID) resolves each unnamed key to that subject's most
|
|
161
|
+
* recently created connection for the pack and key instead, never to another subject's or to one without a
|
|
162
|
+
* `subject`. With no such connection the call is refused with `422 connection_required`. Using a stored
|
|
163
|
+
* connection, named or not, also needs `vault:run`. A credential is sent only over `https`, and only to a host
|
|
164
|
+
* that both the called pack version declares for the connection and the connection is bound to (its `hosts`;
|
|
165
|
+
* a host a later pack version adds needs a new connection). A request to a plain `http` URL whose host would
|
|
166
|
+
* get a credential is refused with `403 egress_denied` (`reason: scheme`) and nothing is sent; after a
|
|
167
|
+
* redirect, a credential bound through a wildcard host (`*.atlassian.net`) goes only back to the host the
|
|
168
|
+
* request started at. A JavaScript action whose credential would be bound only through a wildcard host is
|
|
169
|
+
* refused with `501 not_implemented` on a node whose egress proxy for JavaScript actions cannot yet keep it
|
|
170
|
+
* on one host; nothing runs and nothing is billed. Credential values an upstream echoes are replaced by `*`
|
|
171
|
+
* characters before the response mapping reads the answer, and what a mapping computes, every error text
|
|
172
|
+
* and the output of a JavaScript action are searched again. Found are values as written, with JSON string
|
|
173
|
+
* escapes (`\/`, `\u0073`) or percent escapes in either hex case, also nested (a JSON text in a string, a URL
|
|
174
|
+
* in another URL's query), and for `basic` the `Authorization` value (values of at least 8 characters; error
|
|
175
|
+
* texts also drop shorter ones of at least 4). JavaScript code reads answers through the node's egress proxy:
|
|
176
|
+
* the built-in one replaces all of these spellings, the platform proxy only values written as is. Other
|
|
177
|
+
* encodings, such as base64 of an API key, are not recognized.
|
|
178
|
+
* Only `pure` and `read` actions are retried automatically; send `Idempotency-Key`
|
|
152
179
|
* with `write` actions so a retry of your own does not repeat the effect (packs that declare an
|
|
153
180
|
* idempotency header pass it upstream). `timing` phases: `validate` (input schema), `inject` (connections),
|
|
154
181
|
* `render` (request templates), `upstream` (every HTTP exchange, retries and redirects included), `map`
|
|
@@ -201,6 +228,30 @@ export class ActionsAPI extends Namespace {
|
|
|
201
228
|
return this._client._call<T.Pack>(getPackOp, { path: [namespace, name], query: params }, options);
|
|
202
229
|
}
|
|
203
230
|
|
|
231
|
+
/**
|
|
232
|
+
* List a pack's MCP tools
|
|
233
|
+
*
|
|
234
|
+
* Every action of a pack version that is exposed to MCP, as MCP tool definitions in one response, so an MCP
|
|
235
|
+
* server lists a pack's tools with one request instead of one describe per action. The node builds the list
|
|
236
|
+
* when it loads the pack. Tool names are the registry's (`mcp_name`); each tool also carries the action's `ref`
|
|
237
|
+
* and `effects`, which a server drops from `tools/list`. Cache the response for `ttlMs`; the `ETag` is the
|
|
238
|
+
* version's content hash plus the filters, and `If-None-Match` with it answers `304`.
|
|
239
|
+
*
|
|
240
|
+
* `GET /v1/actions/packs/{namespace}/{name}/tools` · scope `actions:read` · served by the node
|
|
241
|
+
*/
|
|
242
|
+
getPackTools(
|
|
243
|
+
namespace: string,
|
|
244
|
+
name: string,
|
|
245
|
+
params?: T.ActionsGetPackToolsParams,
|
|
246
|
+
options?: RequestOptions,
|
|
247
|
+
): APIPromise<T.PackTools> {
|
|
248
|
+
return this._client._call<T.PackTools>(
|
|
249
|
+
getPackToolsOp,
|
|
250
|
+
{ path: [namespace, name], query: params, headerParams: params },
|
|
251
|
+
options,
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
204
255
|
/**
|
|
205
256
|
* Get a pack manifest
|
|
206
257
|
*
|
|
@@ -292,8 +343,20 @@ export class ActionsAPI extends Namespace {
|
|
|
292
343
|
/**
|
|
293
344
|
* Search actions
|
|
294
345
|
*
|
|
295
|
-
* Full-text search over action titles, descriptions and
|
|
296
|
-
* can pass to describe and call. The same results back the `actions_search` MCP tool.
|
|
346
|
+
* Full-text search over action titles, descriptions, pack names and task phrases, ranked for agents. Returns
|
|
347
|
+
* references you can pass to describe and call. The same results back the `actions_search` MCP tool. With
|
|
348
|
+
* `kind=trigger` it searches triggers instead (results have `kind: trigger`, and their refs go in a routine's
|
|
349
|
+
* action trigger), and with `kind=any` both, ranked together, each result with its `kind`.
|
|
350
|
+
*
|
|
351
|
+
* Every answer says whether anything matched: `match` is `found` or `none`. A query that names a pack (`slack`,
|
|
352
|
+
* `google sheets`, or a pack's term such as `email` or `weather`) searches only the packs it names, and its
|
|
353
|
+
* other words are values (`weather in Tokyo`). A query that names no pack matches only an action that carries
|
|
354
|
+
* all of its words. A service the catalog does not have (`telegram message`) matches nothing, and verbs keep
|
|
355
|
+
* the effect class they ask for: `delete` or `send` only actions that write, `read` or `list` only actions
|
|
356
|
+
* that read. A removal, or an action that cannot be undone, must also be about what the query names
|
|
357
|
+
* (`delete the repo` matches nothing, since no GitHub action deletes a repository). With `match: none`,
|
|
358
|
+
* `data` is empty, `unmatched` lists the words the catalog does not know, and `fallback` names the generic
|
|
359
|
+
* HTTP actions to use instead. Never substitute an unrelated action.
|
|
297
360
|
*
|
|
298
361
|
* `GET /v1/actions/search` · scope `actions:read` · served by the node
|
|
299
362
|
*/
|