@parcha/agentrun-serve 0.1.0-beta.29 → 0.1.0-beta.31

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.
Files changed (172) hide show
  1. package/CHANGELOG.md +238 -0
  2. package/README.md +739 -116
  3. package/dist/adapters.d.ts +35 -6
  4. package/dist/adapters.js +152 -26
  5. package/dist/agents.d.ts +18 -7
  6. package/dist/agents.js +19 -10
  7. package/dist/app.js +101 -26
  8. package/dist/background.d.ts +29 -0
  9. package/dist/background.js +397 -0
  10. package/dist/box-egress-vm.d.ts +125 -0
  11. package/dist/box-egress-vm.js +350 -0
  12. package/dist/box-egress.d.ts +99 -0
  13. package/dist/box-egress.js +259 -0
  14. package/dist/box-image.d.ts +1 -1
  15. package/dist/box-image.js +9 -7
  16. package/dist/box-relay-vm.d.ts +84 -0
  17. package/dist/box-relay-vm.js +410 -0
  18. package/dist/box-relay.d.ts +8 -5
  19. package/dist/box-relay.js +14 -9
  20. package/dist/boxes.d.ts +28 -5
  21. package/dist/boxes.js +44 -18
  22. package/dist/browser-cost.d.ts +41 -0
  23. package/dist/browser-cost.js +158 -0
  24. package/dist/cap.d.ts +130 -21
  25. package/dist/cap.js +339 -67
  26. package/dist/cli.js +30 -4
  27. package/dist/coding-tools.d.ts +7 -3
  28. package/dist/coding-tools.js +16 -10
  29. package/dist/console/THIRD-PARTY-NOTICES.txt +580 -0
  30. package/dist/console/assets/index-CnJBf7Lc.js +486 -0
  31. package/dist/console/assets/index-DUHbWcIP.css +1 -0
  32. package/dist/console/index.html +2 -2
  33. package/dist/content-filter.d.ts +7 -0
  34. package/dist/content-filter.js +23 -0
  35. package/dist/decision-rows.d.ts +11 -3
  36. package/dist/decision-rows.js +18 -11
  37. package/dist/decisions.d.ts +3 -3
  38. package/dist/decisions.js +4 -3
  39. package/dist/errors.d.ts +2 -0
  40. package/dist/errors.js +5 -2
  41. package/dist/files.d.ts +9 -1
  42. package/dist/files.js +10 -2
  43. package/dist/grade.d.ts +11 -11
  44. package/dist/grade.js +43 -55
  45. package/dist/graph-served.d.ts +23 -0
  46. package/dist/graph-served.js +75 -0
  47. package/dist/graph-view.d.ts +7 -5
  48. package/dist/graph-view.js +10 -3
  49. package/dist/harness-app.d.ts +4 -2
  50. package/dist/harness-app.js +110 -19
  51. package/dist/harness-opencode/adapter.d.ts +45 -0
  52. package/dist/harness-opencode/adapter.js +272 -0
  53. package/dist/harness-opencode/binary.d.ts +18 -0
  54. package/dist/harness-opencode/binary.js +87 -0
  55. package/dist/harness-opencode/config.d.ts +24 -0
  56. package/dist/harness-opencode/config.js +61 -0
  57. package/dist/harness-opencode/harness.d.ts +77 -0
  58. package/dist/harness-opencode/harness.js +620 -0
  59. package/dist/harness-opencode/host/mcp.d.ts +40 -0
  60. package/dist/harness-opencode/host/mcp.js +208 -0
  61. package/dist/harness-opencode/host/policy.d.ts +71 -0
  62. package/dist/harness-opencode/host/policy.js +419 -0
  63. package/dist/harness-opencode/host/server.d.ts +55 -0
  64. package/dist/harness-opencode/host/server.js +165 -0
  65. package/dist/harness-opencode/index.d.ts +9 -0
  66. package/dist/harness-opencode/index.js +6 -0
  67. package/dist/harness-opencode/verify.d.ts +32 -0
  68. package/dist/harness-opencode/verify.js +75 -0
  69. package/dist/harness-opencode/versions.d.ts +33 -0
  70. package/dist/harness-opencode/versions.js +64 -0
  71. package/dist/harness.d.ts +4 -1
  72. package/dist/harness.js +5 -2
  73. package/dist/host-check.d.ts +12 -0
  74. package/dist/host-check.js +34 -0
  75. package/dist/host-tools.d.ts +12 -2
  76. package/dist/host-tools.js +26 -12
  77. package/dist/host.js +6 -2
  78. package/dist/hosted-search.js +5 -1
  79. package/dist/import.d.ts +2 -2
  80. package/dist/import.js +4 -3
  81. package/dist/key-check.d.ts +3 -2
  82. package/dist/key-check.js +7 -3
  83. package/dist/key-refusal.js +8 -4
  84. package/dist/key-words.d.ts +37 -0
  85. package/dist/key-words.js +40 -0
  86. package/dist/learn/check.d.ts +10 -1
  87. package/dist/learn/check.js +19 -1
  88. package/dist/learn/grade.d.ts +6 -2
  89. package/dist/learn/grade.js +28 -14
  90. package/dist/learn/index.d.ts +3 -3
  91. package/dist/learn/index.js +3 -3
  92. package/dist/learn/notes.js +2 -1
  93. package/dist/learn/reflect.d.ts +2 -2
  94. package/dist/learn/reflect.js +53 -5
  95. package/dist/learn/secrets.js +28 -8
  96. package/dist/learn/skills.d.ts +19 -4
  97. package/dist/learn/skills.js +95 -6
  98. package/dist/learned-workflow.d.ts +59 -0
  99. package/dist/learned-workflow.js +191 -0
  100. package/dist/learning-routes.d.ts +30 -1
  101. package/dist/learning-routes.js +173 -19
  102. package/dist/learning-run.d.ts +8 -6
  103. package/dist/learning-run.js +70 -27
  104. package/dist/learning-words.d.ts +12 -5
  105. package/dist/learning-words.js +34 -13
  106. package/dist/learning.d.ts +52 -3
  107. package/dist/learning.js +204 -4
  108. package/dist/mcp-gateway.d.ts +96 -0
  109. package/dist/mcp-gateway.js +408 -0
  110. package/dist/mcp-meta.d.ts +17 -0
  111. package/dist/mcp-meta.js +38 -0
  112. package/dist/mcp-servers.d.ts +33 -9
  113. package/dist/mcp-servers.js +58 -10
  114. package/dist/mcp.js +5 -5
  115. package/dist/model.d.ts +13 -11
  116. package/dist/model.js +11 -10
  117. package/dist/openapi/agentrun-v2.openapi.json +1 -0
  118. package/dist/openapi.js +407 -54
  119. package/dist/page.d.ts +2 -0
  120. package/dist/page.js +3 -0
  121. package/dist/paid-calls.d.ts +5 -1
  122. package/dist/paid-calls.js +1 -1
  123. package/dist/pause.d.ts +2 -0
  124. package/dist/place.d.ts +29 -5
  125. package/dist/place.js +51 -11
  126. package/dist/print.d.ts +7 -0
  127. package/dist/print.js +13 -0
  128. package/dist/propose.d.ts +2 -0
  129. package/dist/propose.js +38 -8
  130. package/dist/request-start.d.ts +12 -4
  131. package/dist/request-start.js +139 -15
  132. package/dist/run-box.d.ts +56 -4
  133. package/dist/run-box.js +183 -23
  134. package/dist/runnable.d.ts +13 -3
  135. package/dist/runnable.js +63 -6
  136. package/dist/runs.d.ts +266 -37
  137. package/dist/runs.js +884 -90
  138. package/dist/secrets.d.ts +27 -0
  139. package/dist/secrets.js +38 -2
  140. package/dist/server.d.ts +141 -36
  141. package/dist/server.js +562 -118
  142. package/dist/sign-ins.d.ts +99 -0
  143. package/dist/sign-ins.js +288 -0
  144. package/dist/skills.d.ts +16 -4
  145. package/dist/skills.js +35 -7
  146. package/dist/stats.d.ts +7 -2
  147. package/dist/stats.js +28 -7
  148. package/dist/tool-gate.d.ts +281 -0
  149. package/dist/tool-gate.js +585 -0
  150. package/dist/tool-keys.d.ts +48 -11
  151. package/dist/tool-keys.js +46 -8
  152. package/dist/tool-plane.d.ts +116 -27
  153. package/dist/tool-plane.js +232 -50
  154. package/dist/tools.d.ts +69 -14
  155. package/dist/tools.js +148 -26
  156. package/dist/trigger-secrets.d.ts +32 -0
  157. package/dist/trigger-secrets.js +143 -0
  158. package/dist/triggers.d.ts +439 -0
  159. package/dist/triggers.js +863 -0
  160. package/dist/turn-end.d.ts +3 -2
  161. package/dist/turn-end.js +3 -2
  162. package/dist/usage-lines.d.ts +26 -0
  163. package/dist/usage-lines.js +28 -0
  164. package/dist/validate.d.ts +2 -0
  165. package/dist/validate.js +11 -2
  166. package/dist/web-fetch.js +3 -3
  167. package/dist/webhooks.d.ts +11 -4
  168. package/dist/webhooks.js +17 -1
  169. package/launcher/agentrun-serve +1 -1
  170. package/package.json +16 -14
  171. package/dist/console/assets/index-BN7oVcO4.js +0 -445
  172. package/dist/console/assets/index-By-jkqki.css +0 -1
@@ -0,0 +1,208 @@
1
+ // The session's host tools as an MCP server on the loopback interface, for OpenCode's MCP client. Written for AgentRun.
2
+ //
3
+ // OpenCode reaches a tool that is not its own only through MCP. The adapter turns every OpenCode tool off and gives it
4
+ // this one server, `hands`, so the model is offered exactly the host's tools, named `hands_<name>` (OpenCode names an MCP
5
+ // tool `<server>_<tool>`). The transport is MCP's streamable HTTP, the subset OpenCode's client uses:
6
+ // - `POST /mcp` with one JSON-RPC message and the session's own key as a bearer token (compared in constant time):
7
+ // `initialize`, `ping` and `tools/list` are answered as JSON, a notification gets 202, and `tools/call` is answered as
8
+ // an event stream that carries a progress notification every `progressMs` while the call runs, then its result. A call
9
+ // may wait on a person (`ask_person`) far longer than an MCP client's request timeout, and OpenCode's client resets
10
+ // that timeout on each progress notification.
11
+ // - `GET /mcp` (a stream of the server's own notifications, which this server never sends) is 405, as the
12
+ // specification allows; any other path or method is 404.
13
+ // The server never runs a tool itself: `call` does, through the kernel's tool bridge, so each call is an effect whose
14
+ // intent is durable before it runs. A client that goes away before the answer aborts the call's signal.
15
+ import { createServer } from "node:http";
16
+ import { sameKey } from "@parcha/agentrun-kernel/host";
17
+ /** How long close() waits for the calls it aborted to settle. */
18
+ export const CLOSE_SETTLE_MS = 5_000;
19
+ /** The MCP protocol versions this server speaks; a client's own is answered in kind when it is one of them. */
20
+ const VERSIONS = ["2025-11-25", "2025-06-18", "2025-03-26", "2024-11-05"];
21
+ const MAX_BODY = 8 * 1024 * 1024;
22
+ /** Where the server listens and OpenCode connects to it: this machine only, on the port the system chose. */
23
+ const ADDRESS = "http://127.0.0.1/mcp"; // key-gate: loopback-rule the MCP server of the adapter listens here and OpenCode connects here, 127.0.0.1 only
24
+ const isPlain = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
25
+ function json(res, status, body) {
26
+ if (body === undefined)
27
+ return void res.writeHead(status).end();
28
+ const text = JSON.stringify(body);
29
+ res.writeHead(status, { "content-type": "application/json", "content-length": Buffer.byteLength(text) }).end(text);
30
+ }
31
+ const error = (id, code, message) => ({ jsonrpc: "2.0", id: id ?? null, error: { code, message } });
32
+ async function bodyOf(req) {
33
+ let size = 0;
34
+ const chunks = [];
35
+ for await (const chunk of req) {
36
+ size += chunk.length;
37
+ if (size > MAX_BODY)
38
+ return undefined;
39
+ chunks.push(chunk);
40
+ }
41
+ return Buffer.concat(chunks).toString("utf8");
42
+ }
43
+ /** Start the server on the loopback interface, on a port of the system's choosing. */
44
+ export async function startMcpServer(options) {
45
+ if (!options.key)
46
+ throw new Error("opencode: the MCP server needs the session's key");
47
+ const tools = options.tools.map((t) => ({ name: t.name, description: t.description, inputSchema: t.inputSchema }));
48
+ const known = new Set(tools.map((t) => t.name));
49
+ const progressMs = options.progressMs ?? 15_000;
50
+ // Each call under way: its abort, and what stops its progress timer.
51
+ const open = new Set();
52
+ // Each call's own run (options.call), until it settles: what settle() and close() wait for.
53
+ const running = new Set();
54
+ const settle = async (ms) => {
55
+ if (running.size === 0)
56
+ return true;
57
+ let timer;
58
+ const done = await Promise.race([Promise.allSettled([...running]).then(() => true), new Promise((resolve) => (timer = setTimeout(() => resolve(false), ms)))]);
59
+ clearTimeout(timer);
60
+ return done && running.size === 0;
61
+ };
62
+ let closed = false;
63
+ const server = createServer((req, res) => {
64
+ void handle(req, res).catch((err) => {
65
+ options.log?.("opencode: the MCP server failed a request", { error: String(err?.message ?? err).slice(0, 200) });
66
+ if (!res.headersSent)
67
+ json(res, 500, error(null, -32603, "internal error"));
68
+ else
69
+ res.end();
70
+ });
71
+ });
72
+ async function handle(req, res) {
73
+ const path = (req.url ?? "").split("?")[0];
74
+ if (path !== "/mcp")
75
+ return json(res, 404);
76
+ const auth = String(req.headers.authorization ?? "");
77
+ if (!sameKey(auth.startsWith("Bearer ") ? auth.slice(7) : "", options.key))
78
+ return json(res, 401);
79
+ if (req.method === "GET")
80
+ return void res.writeHead(405, { allow: "POST" }).end();
81
+ if (req.method === "DELETE")
82
+ return json(res, 200);
83
+ if (req.method !== "POST")
84
+ return json(res, 404);
85
+ if (closed)
86
+ return json(res, 503);
87
+ const text = await bodyOf(req);
88
+ if (text === undefined)
89
+ return json(res, 413, error(null, -32600, "the request is too large"));
90
+ let message;
91
+ try {
92
+ message = JSON.parse(text);
93
+ }
94
+ catch {
95
+ return json(res, 400, error(null, -32700, "the body is not JSON"));
96
+ }
97
+ if (!isPlain(message) || message.jsonrpc !== "2.0" || typeof message.method !== "string") {
98
+ // A response or a batch: this server sends no requests and takes one message at a time.
99
+ return json(res, 400, error(isPlain(message) ? message.id : null, -32600, "one JSON-RPC request or notification at a time"));
100
+ }
101
+ const { id, method } = message;
102
+ const params = isPlain(message.params) ? message.params : {};
103
+ if (id === undefined)
104
+ return json(res, 202);
105
+ switch (method) {
106
+ case "initialize": {
107
+ const asked = typeof params.protocolVersion === "string" ? params.protocolVersion : "";
108
+ const protocolVersion = VERSIONS.includes(asked) ? asked : VERSIONS[1];
109
+ return json(res, 200, { jsonrpc: "2.0", id, result: { protocolVersion, capabilities: { tools: { listChanged: false } }, serverInfo: { name: "hands", version: "1" } } });
110
+ }
111
+ case "ping":
112
+ return json(res, 200, { jsonrpc: "2.0", id, result: {} });
113
+ case "tools/list":
114
+ return json(res, 200, { jsonrpc: "2.0", id, result: { tools } });
115
+ case "tools/call":
116
+ return call(id, params, req, res);
117
+ default:
118
+ return json(res, 200, error(id, -32601, `no method ${method.slice(0, 80)}`));
119
+ }
120
+ }
121
+ async function call(id, params, req, res) {
122
+ const name = typeof params.name === "string" ? params.name : "";
123
+ if (!known.has(name))
124
+ return json(res, 200, { jsonrpc: "2.0", id, result: { content: [{ type: "text", text: `unknown tool: ${name.slice(0, 80)}` }], isError: true } });
125
+ const args = isPlain(params.arguments) ? params.arguments : {};
126
+ const meta = isPlain(params._meta) ? params._meta : {};
127
+ const token = typeof meta.progressToken === "string" || typeof meta.progressToken === "number" ? meta.progressToken : undefined;
128
+ const controller = new AbortController();
129
+ let timer;
130
+ // Its progress stops, and nothing more is written, once its client is gone or the server has let it go. The call
131
+ // itself still runs until it settles (`running`), so the drive's settle waits for its real outcome.
132
+ let gone = false;
133
+ const release = () => {
134
+ gone = true;
135
+ if (timer)
136
+ clearInterval(timer);
137
+ timer = undefined;
138
+ };
139
+ const entry = { controller, release };
140
+ open.add(entry);
141
+ // The client going away (its abort, its process ending) stops the call; a finished answer does not.
142
+ let answered = false;
143
+ res.on("close", () => {
144
+ release();
145
+ if (!answered)
146
+ controller.abort(new Error("the MCP client went away before the answer"));
147
+ });
148
+ res.writeHead(200, { "content-type": "text/event-stream", "cache-control": "no-cache", connection: "keep-alive" });
149
+ const send = (body) => void (gone || res.write(`event: message\ndata: ${JSON.stringify(body)}\n\n`));
150
+ let progress = 0;
151
+ if (token !== undefined)
152
+ timer = setInterval(() => {
153
+ progress += 1;
154
+ send({ jsonrpc: "2.0", method: "notifications/progress", params: { progressToken: token, progress } });
155
+ }, progressMs);
156
+ try {
157
+ const work = options.call(name, args, controller.signal);
158
+ running.add(work);
159
+ void work.then(() => running.delete(work), () => running.delete(work));
160
+ const answer = await work;
161
+ const content = [{ type: "text", text: answer.text }, ...(answer.images ?? []).map((image) => ({ type: "image", data: image.data, mimeType: image.mimeType }))];
162
+ answered = true;
163
+ send({ jsonrpc: "2.0", id, result: { content, isError: answer.isError } });
164
+ }
165
+ catch (err) {
166
+ answered = true;
167
+ // The drive is stopping (an interrupt, a halt): the call has no answer the log holds, so none is given.
168
+ send(error(id, -32603, String(err?.message ?? err).slice(0, 500)));
169
+ }
170
+ finally {
171
+ // A call the server let go (close()) settles here to nothing: its entry is gone, and so is its response.
172
+ const ended = gone;
173
+ release();
174
+ open.delete(entry);
175
+ if (!ended)
176
+ res.end();
177
+ }
178
+ }
179
+ await new Promise((resolve, reject) => {
180
+ server.once("error", reject);
181
+ server.listen(0, new URL(ADDRESS).hostname, () => resolve());
182
+ });
183
+ const address = server.address();
184
+ if (!address || typeof address === "string")
185
+ throw new Error("opencode: the MCP server has no port");
186
+ const url = new URL(ADDRESS);
187
+ url.port = String(address.port);
188
+ return {
189
+ url: url.href,
190
+ settle,
191
+ async close() {
192
+ if (closed)
193
+ return;
194
+ closed = true;
195
+ for (const { controller } of open)
196
+ controller.abort(new Error("the session's MCP server closed"));
197
+ if (!(await settle(CLOSE_SETTLE_MS)))
198
+ options.log?.("opencode: a host tool call was still running when the MCP server closed", { running: running.size });
199
+ // Past the window, a call that ignores its abort is let go: nothing of it stays live in this process.
200
+ for (const { release } of open)
201
+ release();
202
+ open.clear();
203
+ running.clear();
204
+ server.closeAllConnections?.();
205
+ await new Promise((resolve) => server.close(() => resolve()));
206
+ },
207
+ };
208
+ }
@@ -0,0 +1,71 @@
1
+ import { type ProviderPolicy, type ProxyRoute, type ProxyUsage } from "@parcha/agentrun-kernel/host";
2
+ /** The prefix OpenCode gives the adapter's MCP tools: the server is `hands`. */
3
+ export declare const TOOL_PREFIX = "hands_";
4
+ export declare const OPENCODE_RESPONSES_ROUTES: readonly ProxyRoute[];
5
+ /** The keys a Responses request from the pinned build may carry; anything else is refused. */
6
+ export declare const BODY_KEYS: ReadonlySet<string>;
7
+ /** A function call an answer carries, as the watch reads it. */
8
+ export interface WatchedCall {
9
+ callId: string;
10
+ /** The model's name for the tool (`hands_<host tool>`). */
11
+ name: string;
12
+ /** The arguments' JSON text, as the model wrote it. */
13
+ arguments: string;
14
+ }
15
+ export interface OpenCodePolicyOptions {
16
+ /** The session's model: the body's model is set to it. */
17
+ model: string;
18
+ /** The session's own tool names (the host's): only `hands_<name>` function tools pass. */
19
+ tools: readonly string[];
20
+ /** The most output tokens one request may ask for. Default 32 000. */
21
+ maxOutputTokens?: number;
22
+ /** Told of each function call an answer carries, before OpenCode has that part of the answer. */
23
+ onCall?: (call: WatchedCall) => void;
24
+ }
25
+ /**
26
+ * Whether the provider stopped the answer on its content filter: the stream's terminal event (or a whole body) is an
27
+ * `incomplete` response whose `incomplete_details.reason` is `content_filter`. Read by parsing each `data:` line on its
28
+ * own, as usageOf reads the usage, never by matching text; an answer cut at its output limit (`max_output_tokens`) is not one.
29
+ *
30
+ * The terminal event carries the whole response (its output, encrypted reasoning included), so its line can be longer
31
+ * than the proxy keeps of an answer; then the proxy's start of that line is read. The response's fields come in a fixed
32
+ * order, `id`, `object`, `created_at`, `status`, `background`, `error`, `incomplete_details`, then `instructions`, the
33
+ * tools and the output, so `incomplete_details` is near the line's start. It is read only on a line that is the event's
34
+ * own: one the SSE `event: response.incomplete` names (OpenAI's API), or whose data says `"type":"response.incomplete"`
35
+ * before its `"response":{` (a gateway that sends each event as its data alone: LiteLLM), as the first
36
+ * `"incomplete_details":{` after `"response":{` (one JSON object), whatever the JSON's spacing.
37
+ */
38
+ export declare function filtered(text: string, lineStarts?: readonly string[]): boolean;
39
+ /** The usage of the response an answer ends with: its `response.completed` (or `response.incomplete`) event, each `data:`
40
+ * line parsed on its own, or a whole JSON body's; for a line the proxy's 64 KiB window cut, the last `"usage":{` object
41
+ * in the text. Undefined, an unknown cost, when there is none. */
42
+ export declare function usageOf(text: string): ProxyUsage | undefined;
43
+ /** The input tokens the provider bills for `body` that it does not carry (codex's figure: the same Responses API). A file
44
+ * input has no stated bound, so a body with one cannot be measured. */
45
+ export declare function responsesServerInputOverhead(body: Record<string, unknown>): number;
46
+ /** The tokens a request keeps for its answer when a spend cap limits its output. */
47
+ export declare const ANSWER_TOKENS_LEAST = 1024;
48
+ /** What a reasoning request at each effort is allowed for its reasoning beside its answer, when its output is limited:
49
+ * OpenAI's reasoning shares `max_output_tokens` and takes no budget, so a limit under its reasoning comes back
50
+ * incomplete with no answer. The figures are codex's (pi-ai's thinking budgets by level, xhigh at high's). */
51
+ export declare const REASONING_TOKENS_ALLOWED: Readonly<Record<string, number>>;
52
+ /** The output tokens a Responses body asks for at most: its `max_output_tokens`, as `apply` clamped it. */
53
+ export declare function responsesOutputAsked(body: Record<string, unknown>): number | undefined;
54
+ /** The least output a Responses body may be limited to and still answer: 1,024 tokens, plus its reasoning effort's
55
+ * allowance when it reasons. */
56
+ export declare function responsesOutputLeast(body: Record<string, unknown>): number;
57
+ /** The reasoning tokens a Responses request may bill that its stream never shows (only a summary of its reasoning
58
+ * streams): its effort's budget; none at effort `none`; and with no effort the body says (the model then reasons at its
59
+ * own default, or not at all), its output limit, `fallback` when the body names none: the conservative side. An
60
+ * estimate, as the efforts' budgets are not limits the provider keeps: a stopped request counts the part of it that
61
+ * did not stream (less `responsesReasoningBytes` of what it sent), never past its hold. */
62
+ export declare function responsesReasoningHidden(body: Record<string, unknown>, fallback: number): number;
63
+ /** The bytes of reasoning one Responses stream event carries: a reasoning delta's text, UTF-8; 0 for answer text, a
64
+ * function call's arguments and every other event. */
65
+ export declare function responsesReasoningBytes(event: string): number;
66
+ /** The bytes of content one Responses stream event carries: a content delta's text, UTF-8, never the framing around it
67
+ * (its sequence number, item id, indexes, logprobs, obfuscation); 0 for every other event. */
68
+ export declare function responsesContentBytes(event: string): number;
69
+ /** A Responses body with its output limited to `max` tokens, reasoning included: never raised, and never longer. */
70
+ export declare function limitResponsesOutput(body: Record<string, unknown>, max: number): Record<string, unknown>;
71
+ export declare function openCodePolicy(options: OpenCodePolicyOptions): ProviderPolicy;