@agentproto/adapter-pi 0.2.4 → 0.3.1
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/PI.md +5 -5
- package/README.md +2 -2
- package/SECRETS.md +8 -2
- package/dist/index.mjs +222 -55
- package/dist/index.mjs.map +1 -1
- package/dist/mcp-bridge-extension.mjs +199 -51
- package/dist/mcp-bridge-extension.mjs.map +1 -1
- package/package.json +3 -3
package/PI.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: pi
|
|
3
3
|
id: pi
|
|
4
|
-
description: earendil-works/pi — MIT headless TypeScript coding agent. Driven over pi's persistent JSON-over-stdio RPC mode (`pi --mode rpc`) as a spawned child. Multi-provider (Anthropic/OpenAI/Google), streaming, live-duplex (steer/follow-up/abort mid-turn). No native ACP/MCP, but injected MCP servers are bridged into pi tools via a generated pi extension (see MCP-BRIDGE.md).
|
|
4
|
+
description: earendil-works/pi — MIT headless TypeScript coding agent. Driven over pi's persistent JSON-over-stdio RPC mode (`pi --mode rpc`) as a spawned child. Multi-provider (Anthropic/OpenAI/Google/Moonshot), streaming, live-duplex (steer/follow-up/abort mid-turn). No native ACP/MCP, but injected MCP servers are bridged into pi tools via a generated pi extension (see MCP-BRIDGE.md).
|
|
5
5
|
version: 0.1.0
|
|
6
6
|
bin: pi
|
|
7
7
|
install:
|
|
@@ -18,7 +18,7 @@ version_check:
|
|
|
18
18
|
auth:
|
|
19
19
|
ref: ./SECRETS.md
|
|
20
20
|
state:
|
|
21
|
-
env: [ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_GENERATIVE_AI_API_KEY]
|
|
21
|
+
env: [ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_GENERATIVE_AI_API_KEY, MOONSHOT_API_KEY]
|
|
22
22
|
sandbox: ./SANDBOX.md
|
|
23
23
|
protocol: proprietary
|
|
24
24
|
adapter: "@agentproto/adapter-pi"
|
|
@@ -69,9 +69,9 @@ and translates the stream. See [`PI-RPC.md`](./PI-RPC.md) for the wire profile.
|
|
|
69
69
|
|
|
70
70
|
Default `anthropic/claude-sonnet-4-5`. `allowed` is a curated cross-provider
|
|
71
71
|
menu (`anthropic/claude-sonnet-4-5`, `openai/gpt-5.1`,
|
|
72
|
-
`google/gemini-2.5-flash`); the free-form `model`
|
|
73
|
-
pi's `--model` understands (`provider/id`, verified
|
|
74
|
-
`core/model-resolver.ts`). `env` maps provider → key env var.
|
|
72
|
+
`google/gemini-2.5-flash`, `moonshotai/kimi-k2.7-code`); the free-form `model`
|
|
73
|
+
option accepts any pattern pi's `--model` understands (`provider/id`, verified
|
|
74
|
+
against pi's `core/model-resolver.ts`). `env` maps provider → key env var.
|
|
75
75
|
|
|
76
76
|
## Options
|
|
77
77
|
|
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ Unlike `@agentproto/adapter-mastracode-inprocess` (the in-process proprietary
|
|
|
47
47
|
arm), **this arm spawns a real child** (`pi --mode rpc`) and translates pi's
|
|
48
48
|
RPC event stream into the canonical `StreamEvent` taxonomy.
|
|
49
49
|
|
|
50
|
-
- **Multi-provider** — Anthropic, OpenAI, Google (Gemini). One provider key
|
|
50
|
+
- **Multi-provider** — Anthropic, OpenAI, Google (Gemini), Moonshot AI. One provider key
|
|
51
51
|
minimum. See [`SECRETS.md`](./SECRETS.md).
|
|
52
52
|
- **Streaming** — text + thinking deltas, tool-call/result lifecycle.
|
|
53
53
|
- **Live duplex** — pi's RPC mode supports `steer` / `follow_up` / `abort`
|
|
@@ -60,7 +60,7 @@ RPC event stream into the canonical `StreamEvent` taxonomy.
|
|
|
60
60
|
|
|
61
61
|
| Option | Type | Notes |
|
|
62
62
|
| -------- | ------ | ----- |
|
|
63
|
-
| `model` | string | Passed to pi's `--model` (accepts `provider/id`, e.g. `anthropic/claude-sonnet-4-5`). |
|
|
63
|
+
| `model` | string | Passed to pi's `--model` (accepts `provider/id`, e.g. `anthropic/claude-sonnet-4-5`, `moonshotai/kimi-k2.7-code`). |
|
|
64
64
|
| `effort` | enum | Thinking level, mapped 1:1 to pi's `set_thinking_level`: `off \| minimal \| low \| medium \| high \| xhigh`. |
|
|
65
65
|
|
|
66
66
|
The pi binary is resolved from `definition.bin` (`pi`), overridable via the
|
package/SECRETS.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: pi-secrets
|
|
3
3
|
id: pi-secrets
|
|
4
|
-
description: Secret slots pi reads at boot. At minimum ONE model-provider key MUST be present — pi routes each turn to whichever provider the selected model belongs to (Anthropic / OpenAI / Google).
|
|
4
|
+
description: Secret slots pi reads at boot. At minimum ONE model-provider key MUST be present — pi routes each turn to whichever provider the selected model belongs to (Anthropic / OpenAI / Google / Moonshot).
|
|
5
5
|
version: 0.1.0
|
|
6
6
|
slots:
|
|
7
7
|
- name: ANTHROPIC_API_KEY
|
|
@@ -16,19 +16,24 @@ slots:
|
|
|
16
16
|
description: Google Generative AI (Gemini) key — enables `google/gemini-*` models.
|
|
17
17
|
required: false
|
|
18
18
|
sensitivity: high
|
|
19
|
+
- name: MOONSHOT_API_KEY
|
|
20
|
+
description: Moonshot AI API key — enables `moonshotai/kimi-*` models.
|
|
21
|
+
required: false
|
|
22
|
+
sensitivity: high
|
|
19
23
|
constraints:
|
|
20
24
|
- kind: at-least-one-of
|
|
21
25
|
of:
|
|
22
26
|
- ANTHROPIC_API_KEY
|
|
23
27
|
- OPENAI_API_KEY
|
|
24
28
|
- GOOGLE_GENERATIVE_AI_API_KEY
|
|
29
|
+
- MOONSHOT_API_KEY
|
|
25
30
|
tags: [pi, secrets, model-providers]
|
|
26
31
|
---
|
|
27
32
|
|
|
28
33
|
# Pi — secrets inventory
|
|
29
34
|
|
|
30
35
|
Pi routes each turn to the provider that owns the selected model. The adapter
|
|
31
|
-
declares the
|
|
36
|
+
declares the four provider key slots pi's supported providers read from the
|
|
32
37
|
process environment:
|
|
33
38
|
|
|
34
39
|
| Env var | Provider | Unlocks |
|
|
@@ -36,6 +41,7 @@ process environment:
|
|
|
36
41
|
| `ANTHROPIC_API_KEY` | Anthropic | `anthropic/claude-*` (adapter default) |
|
|
37
42
|
| `OPENAI_API_KEY` | OpenAI | `openai/gpt-*` |
|
|
38
43
|
| `GOOGLE_GENERATIVE_AI_API_KEY` | Google | `google/gemini-*` |
|
|
44
|
+
| `MOONSHOT_API_KEY` | Moonshot AI | `moonshotai/kimi-*` |
|
|
39
45
|
|
|
40
46
|
**At least one** must be present, and it must match the provider of the model
|
|
41
47
|
you route to (`models.default` is `anthropic/claude-sonnet-4-5`, so
|
package/dist/index.mjs
CHANGED
|
@@ -7244,6 +7244,109 @@ var require_cross_spawn = __commonJS({
|
|
|
7244
7244
|
}
|
|
7245
7245
|
});
|
|
7246
7246
|
|
|
7247
|
+
// ../../node_modules/.pnpm/content-type@1.0.5/node_modules/content-type/index.js
|
|
7248
|
+
var require_content_type = __commonJS({
|
|
7249
|
+
"../../node_modules/.pnpm/content-type@1.0.5/node_modules/content-type/index.js"(exports$1) {
|
|
7250
|
+
var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g;
|
|
7251
|
+
var TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/;
|
|
7252
|
+
var TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
7253
|
+
var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g;
|
|
7254
|
+
var QUOTE_REGEXP = /([\\"])/g;
|
|
7255
|
+
var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
7256
|
+
exports$1.format = format;
|
|
7257
|
+
exports$1.parse = parse3;
|
|
7258
|
+
function format(obj) {
|
|
7259
|
+
if (!obj || typeof obj !== "object") {
|
|
7260
|
+
throw new TypeError("argument obj is required");
|
|
7261
|
+
}
|
|
7262
|
+
var parameters = obj.parameters;
|
|
7263
|
+
var type = obj.type;
|
|
7264
|
+
if (!type || !TYPE_REGEXP.test(type)) {
|
|
7265
|
+
throw new TypeError("invalid type");
|
|
7266
|
+
}
|
|
7267
|
+
var string4 = type;
|
|
7268
|
+
if (parameters && typeof parameters === "object") {
|
|
7269
|
+
var param;
|
|
7270
|
+
var params = Object.keys(parameters).sort();
|
|
7271
|
+
for (var i = 0; i < params.length; i++) {
|
|
7272
|
+
param = params[i];
|
|
7273
|
+
if (!TOKEN_REGEXP.test(param)) {
|
|
7274
|
+
throw new TypeError("invalid parameter name");
|
|
7275
|
+
}
|
|
7276
|
+
string4 += "; " + param + "=" + qstring(parameters[param]);
|
|
7277
|
+
}
|
|
7278
|
+
}
|
|
7279
|
+
return string4;
|
|
7280
|
+
}
|
|
7281
|
+
function parse3(string4) {
|
|
7282
|
+
if (!string4) {
|
|
7283
|
+
throw new TypeError("argument string is required");
|
|
7284
|
+
}
|
|
7285
|
+
var header = typeof string4 === "object" ? getcontenttype(string4) : string4;
|
|
7286
|
+
if (typeof header !== "string") {
|
|
7287
|
+
throw new TypeError("argument string is required to be a string");
|
|
7288
|
+
}
|
|
7289
|
+
var index = header.indexOf(";");
|
|
7290
|
+
var type = index !== -1 ? header.slice(0, index).trim() : header.trim();
|
|
7291
|
+
if (!TYPE_REGEXP.test(type)) {
|
|
7292
|
+
throw new TypeError("invalid media type");
|
|
7293
|
+
}
|
|
7294
|
+
var obj = new ContentType(type.toLowerCase());
|
|
7295
|
+
if (index !== -1) {
|
|
7296
|
+
var key;
|
|
7297
|
+
var match;
|
|
7298
|
+
var value;
|
|
7299
|
+
PARAM_REGEXP.lastIndex = index;
|
|
7300
|
+
while (match = PARAM_REGEXP.exec(header)) {
|
|
7301
|
+
if (match.index !== index) {
|
|
7302
|
+
throw new TypeError("invalid parameter format");
|
|
7303
|
+
}
|
|
7304
|
+
index += match[0].length;
|
|
7305
|
+
key = match[1].toLowerCase();
|
|
7306
|
+
value = match[2];
|
|
7307
|
+
if (value.charCodeAt(0) === 34) {
|
|
7308
|
+
value = value.slice(1, -1);
|
|
7309
|
+
if (value.indexOf("\\") !== -1) {
|
|
7310
|
+
value = value.replace(QESC_REGEXP, "$1");
|
|
7311
|
+
}
|
|
7312
|
+
}
|
|
7313
|
+
obj.parameters[key] = value;
|
|
7314
|
+
}
|
|
7315
|
+
if (index !== header.length) {
|
|
7316
|
+
throw new TypeError("invalid parameter format");
|
|
7317
|
+
}
|
|
7318
|
+
}
|
|
7319
|
+
return obj;
|
|
7320
|
+
}
|
|
7321
|
+
function getcontenttype(obj) {
|
|
7322
|
+
var header;
|
|
7323
|
+
if (typeof obj.getHeader === "function") {
|
|
7324
|
+
header = obj.getHeader("content-type");
|
|
7325
|
+
} else if (typeof obj.headers === "object") {
|
|
7326
|
+
header = obj.headers && obj.headers["content-type"];
|
|
7327
|
+
}
|
|
7328
|
+
if (typeof header !== "string") {
|
|
7329
|
+
throw new TypeError("content-type header is missing from object");
|
|
7330
|
+
}
|
|
7331
|
+
return header;
|
|
7332
|
+
}
|
|
7333
|
+
function qstring(val) {
|
|
7334
|
+
var str = String(val);
|
|
7335
|
+
if (TOKEN_REGEXP.test(str)) {
|
|
7336
|
+
return str;
|
|
7337
|
+
}
|
|
7338
|
+
if (str.length > 0 && !TEXT_REGEXP.test(str)) {
|
|
7339
|
+
throw new TypeError("invalid parameter value");
|
|
7340
|
+
}
|
|
7341
|
+
return '"' + str.replace(QUOTE_REGEXP, "\\$1") + '"';
|
|
7342
|
+
}
|
|
7343
|
+
function ContentType(type) {
|
|
7344
|
+
this.parameters = /* @__PURE__ */ Object.create(null);
|
|
7345
|
+
this.type = type;
|
|
7346
|
+
}
|
|
7347
|
+
}
|
|
7348
|
+
});
|
|
7349
|
+
|
|
7247
7350
|
// src/mcp-bridge/config.ts
|
|
7248
7351
|
var DEFAULT_TOOL_PREFIX = "mcp__";
|
|
7249
7352
|
var MAX_TOOL_NAME_LEN = 64;
|
|
@@ -11664,7 +11767,7 @@ var optionalProcessor = (schema, ctx, _json, params) => {
|
|
|
11664
11767
|
seen.ref = def.innerType;
|
|
11665
11768
|
};
|
|
11666
11769
|
|
|
11667
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
11770
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
|
|
11668
11771
|
function isZ4Schema(s) {
|
|
11669
11772
|
const schema = s;
|
|
11670
11773
|
return !!schema._zod;
|
|
@@ -12739,7 +12842,7 @@ function date3(params) {
|
|
|
12739
12842
|
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
|
|
12740
12843
|
config(en_default());
|
|
12741
12844
|
|
|
12742
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
12845
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
|
|
12743
12846
|
var LATEST_PROTOCOL_VERSION = "2025-11-25";
|
|
12744
12847
|
var SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-06-18", "2025-03-26", "2024-11-05", "2024-10-07"];
|
|
12745
12848
|
var RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task";
|
|
@@ -14259,7 +14362,7 @@ var UrlElicitationRequiredError = class extends McpError {
|
|
|
14259
14362
|
}
|
|
14260
14363
|
};
|
|
14261
14364
|
|
|
14262
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
14365
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
|
|
14263
14366
|
function isTerminal(status) {
|
|
14264
14367
|
return status === "completed" || status === "failed" || status === "cancelled";
|
|
14265
14368
|
}
|
|
@@ -14267,7 +14370,7 @@ function isTerminal(status) {
|
|
|
14267
14370
|
// ../../node_modules/.pnpm/zod-to-json-schema@3.25.2_zod@4.4.3/node_modules/zod-to-json-schema/dist/esm/parsers/string.js
|
|
14268
14371
|
new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
14269
14372
|
|
|
14270
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
14373
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
|
|
14271
14374
|
function getMethodLiteral(schema) {
|
|
14272
14375
|
const shape = getObjectShape(schema);
|
|
14273
14376
|
const methodSchema = shape?.method;
|
|
@@ -14288,7 +14391,7 @@ function parseWithCompat(schema, data) {
|
|
|
14288
14391
|
return result.data;
|
|
14289
14392
|
}
|
|
14290
14393
|
|
|
14291
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
14394
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
|
|
14292
14395
|
var DEFAULT_REQUEST_TIMEOUT_MSEC = 6e4;
|
|
14293
14396
|
var Protocol = class {
|
|
14294
14397
|
constructor(_options) {
|
|
@@ -15242,7 +15345,7 @@ function mergeCapabilities(base, additional) {
|
|
|
15242
15345
|
return result;
|
|
15243
15346
|
}
|
|
15244
15347
|
|
|
15245
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
15348
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
|
|
15246
15349
|
var import_ajv = __toESM(require_ajv());
|
|
15247
15350
|
var import_ajv_formats = __toESM(require_dist());
|
|
15248
15351
|
function createDefaultAjvInstance() {
|
|
@@ -15310,7 +15413,7 @@ var AjvJsonSchemaValidator = class {
|
|
|
15310
15413
|
}
|
|
15311
15414
|
};
|
|
15312
15415
|
|
|
15313
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
15416
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/client.js
|
|
15314
15417
|
var ExperimentalClientTasks = class {
|
|
15315
15418
|
constructor(_client) {
|
|
15316
15419
|
this._client = _client;
|
|
@@ -15464,7 +15567,7 @@ var ExperimentalClientTasks = class {
|
|
|
15464
15567
|
}
|
|
15465
15568
|
};
|
|
15466
15569
|
|
|
15467
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
15570
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
|
|
15468
15571
|
function assertToolsCallTaskCapability(requests, method, entityName) {
|
|
15469
15572
|
if (!requests) {
|
|
15470
15573
|
throw new Error(`${entityName} does not support task creation (required for ${method})`);
|
|
@@ -15495,7 +15598,7 @@ function assertClientRequestTaskCapability(requests, method, entityName) {
|
|
|
15495
15598
|
}
|
|
15496
15599
|
}
|
|
15497
15600
|
|
|
15498
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
15601
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js
|
|
15499
15602
|
function applyElicitationDefaults(schema, data) {
|
|
15500
15603
|
if (!schema || data === null || typeof data !== "object")
|
|
15501
15604
|
return;
|
|
@@ -15615,16 +15718,7 @@ var Client = class extends Protocol {
|
|
|
15615
15718
|
if (!methodSchema) {
|
|
15616
15719
|
throw new Error("Schema is missing a method literal");
|
|
15617
15720
|
}
|
|
15618
|
-
|
|
15619
|
-
if (isZ4Schema(methodSchema)) {
|
|
15620
|
-
const v4Schema = methodSchema;
|
|
15621
|
-
const v4Def = v4Schema._zod?.def;
|
|
15622
|
-
methodValue = v4Def?.value ?? v4Schema.value;
|
|
15623
|
-
} else {
|
|
15624
|
-
const v3Schema = methodSchema;
|
|
15625
|
-
const legacyDef = v3Schema._def;
|
|
15626
|
-
methodValue = legacyDef?.value ?? v3Schema.value;
|
|
15627
|
-
}
|
|
15721
|
+
const methodValue = getLiteralValue(methodSchema);
|
|
15628
15722
|
if (typeof methodValue !== "string") {
|
|
15629
15723
|
throw new Error("Schema method literal must be a string");
|
|
15630
15724
|
}
|
|
@@ -16003,7 +16097,7 @@ var Client = class extends Protocol {
|
|
|
16003
16097
|
}
|
|
16004
16098
|
};
|
|
16005
16099
|
|
|
16006
|
-
// ../../node_modules/.pnpm/eventsource-parser@3.0
|
|
16100
|
+
// ../../node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/index.js
|
|
16007
16101
|
var ParseError = class extends Error {
|
|
16008
16102
|
constructor(message, options) {
|
|
16009
16103
|
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
@@ -16014,29 +16108,40 @@ var CR = 13;
|
|
|
16014
16108
|
var SPACE = 32;
|
|
16015
16109
|
function noop(_arg) {
|
|
16016
16110
|
}
|
|
16017
|
-
function createParser(
|
|
16018
|
-
if (typeof
|
|
16111
|
+
function createParser(config2) {
|
|
16112
|
+
if (typeof config2 == "function")
|
|
16019
16113
|
throw new TypeError(
|
|
16020
|
-
"`
|
|
16114
|
+
"`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?"
|
|
16021
16115
|
);
|
|
16022
|
-
const { onEvent = noop, onError = noop, onRetry = noop, onComment } =
|
|
16023
|
-
let isFirstChunk = true, id, data = "", dataLines = 0, eventType;
|
|
16116
|
+
const { onEvent = noop, onError = noop, onRetry = noop, onComment, maxBufferSize } = config2, pendingFragments = [];
|
|
16117
|
+
let pendingFragmentsLength = 0, isFirstChunk = true, id, data = "", dataLines = 0, eventType, terminated = false;
|
|
16024
16118
|
function feed(chunk) {
|
|
16119
|
+
if (terminated)
|
|
16120
|
+
throw new Error(
|
|
16121
|
+
"Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing."
|
|
16122
|
+
);
|
|
16025
16123
|
if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
|
|
16026
16124
|
const trailing2 = processLines(chunk);
|
|
16027
|
-
trailing2 !== "" && pendingFragments.push(trailing2);
|
|
16125
|
+
trailing2 !== "" && (pendingFragments.push(trailing2), pendingFragmentsLength = trailing2.length), checkBufferSize();
|
|
16028
16126
|
return;
|
|
16029
16127
|
}
|
|
16030
16128
|
if (chunk.indexOf(`
|
|
16031
16129
|
`) === -1 && chunk.indexOf("\r") === -1) {
|
|
16032
|
-
pendingFragments.push(chunk);
|
|
16130
|
+
pendingFragments.push(chunk), pendingFragmentsLength += chunk.length, checkBufferSize();
|
|
16033
16131
|
return;
|
|
16034
16132
|
}
|
|
16035
16133
|
pendingFragments.push(chunk);
|
|
16036
16134
|
const input = pendingFragments.join("");
|
|
16037
|
-
pendingFragments.length = 0;
|
|
16135
|
+
pendingFragments.length = 0, pendingFragmentsLength = 0;
|
|
16038
16136
|
const trailing = processLines(input);
|
|
16039
|
-
trailing !== "" && pendingFragments.push(trailing);
|
|
16137
|
+
trailing !== "" && (pendingFragments.push(trailing), pendingFragmentsLength = trailing.length), checkBufferSize();
|
|
16138
|
+
}
|
|
16139
|
+
function checkBufferSize() {
|
|
16140
|
+
maxBufferSize !== void 0 && (pendingFragmentsLength + data.length <= maxBufferSize || (terminated = true, pendingFragments.length = 0, pendingFragmentsLength = 0, id = void 0, data = "", dataLines = 0, eventType = void 0, onError(
|
|
16141
|
+
new ParseError(`Buffered data exceeded max buffer size of ${maxBufferSize} characters`, {
|
|
16142
|
+
type: "max-buffer-size-exceeded"
|
|
16143
|
+
})
|
|
16144
|
+
)));
|
|
16040
16145
|
}
|
|
16041
16146
|
function processLines(chunk) {
|
|
16042
16147
|
let searchIndex = 0;
|
|
@@ -16157,7 +16262,7 @@ ${value}`, dataLines++;
|
|
|
16157
16262
|
const incompleteLine = pendingFragments.join("");
|
|
16158
16263
|
parseLine(incompleteLine, 0, incompleteLine.length);
|
|
16159
16264
|
}
|
|
16160
|
-
isFirstChunk = true, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0;
|
|
16265
|
+
isFirstChunk = true, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0, pendingFragmentsLength = 0, terminated = false;
|
|
16161
16266
|
}
|
|
16162
16267
|
return { feed, reset };
|
|
16163
16268
|
}
|
|
@@ -16465,7 +16570,7 @@ function getBaseURL() {
|
|
|
16465
16570
|
return doc && typeof doc == "object" && "baseURI" in doc && typeof doc.baseURI == "string" ? doc.baseURI : void 0;
|
|
16466
16571
|
}
|
|
16467
16572
|
|
|
16468
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
16573
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.js
|
|
16469
16574
|
function normalizeHeaders(headers) {
|
|
16470
16575
|
if (!headers)
|
|
16471
16576
|
return {};
|
|
@@ -16535,7 +16640,7 @@ async function pkceChallenge(length) {
|
|
|
16535
16640
|
};
|
|
16536
16641
|
}
|
|
16537
16642
|
|
|
16538
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
16643
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth.js
|
|
16539
16644
|
var SafeUrlSchema = url().superRefine((val, ctx) => {
|
|
16540
16645
|
if (!URL.canParse(val)) {
|
|
16541
16646
|
ctx.addIssue({
|
|
@@ -16679,7 +16784,7 @@ object2({
|
|
|
16679
16784
|
token_type_hint: string2().optional()
|
|
16680
16785
|
}).strip();
|
|
16681
16786
|
|
|
16682
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
16787
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/auth-utils.js
|
|
16683
16788
|
function resourceUrlFromServerUrl(url2) {
|
|
16684
16789
|
const resourceURL = typeof url2 === "string" ? new URL(url2) : new URL(url2.href);
|
|
16685
16790
|
resourceURL.hash = "";
|
|
@@ -16699,7 +16804,7 @@ function checkResourceAllowed({ requestedResource, configuredResource }) {
|
|
|
16699
16804
|
return requestedPath.startsWith(configuredPath);
|
|
16700
16805
|
}
|
|
16701
16806
|
|
|
16702
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
16807
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/server/auth/errors.js
|
|
16703
16808
|
var OAuthError = class extends Error {
|
|
16704
16809
|
constructor(message, errorUri) {
|
|
16705
16810
|
super(message);
|
|
@@ -16794,7 +16899,7 @@ var OAUTH_ERRORS = {
|
|
|
16794
16899
|
[InvalidTargetError.errorCode]: InvalidTargetError
|
|
16795
16900
|
};
|
|
16796
16901
|
|
|
16797
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
16902
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/client/auth.js
|
|
16798
16903
|
var UnauthorizedError = class extends Error {
|
|
16799
16904
|
constructor(message) {
|
|
16800
16905
|
super(message ?? "Unauthorized");
|
|
@@ -17334,7 +17439,7 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
|
|
|
17334
17439
|
return OAuthClientInformationFullSchema.parse(await response.json());
|
|
17335
17440
|
}
|
|
17336
17441
|
|
|
17337
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
17442
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/client/sse.js
|
|
17338
17443
|
var SseError = class extends Error {
|
|
17339
17444
|
constructor(code, message, event) {
|
|
17340
17445
|
super(`SSE error: ${message}`);
|
|
@@ -17525,12 +17630,21 @@ var SSEClientTransport = class {
|
|
|
17525
17630
|
}
|
|
17526
17631
|
};
|
|
17527
17632
|
|
|
17528
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
17633
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
|
|
17529
17634
|
var import_cross_spawn = __toESM(require_cross_spawn());
|
|
17530
17635
|
|
|
17531
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
17636
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
|
|
17637
|
+
var STDIO_DEFAULT_MAX_BUFFER_SIZE = 10 * 1024 * 1024;
|
|
17532
17638
|
var ReadBuffer = class {
|
|
17639
|
+
constructor(options) {
|
|
17640
|
+
this._maxBufferSize = options?.maxBufferSize ?? STDIO_DEFAULT_MAX_BUFFER_SIZE;
|
|
17641
|
+
}
|
|
17533
17642
|
append(chunk) {
|
|
17643
|
+
const newSize = (this._buffer?.length ?? 0) + chunk.length;
|
|
17644
|
+
if (newSize > this._maxBufferSize) {
|
|
17645
|
+
this.clear();
|
|
17646
|
+
throw new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);
|
|
17647
|
+
}
|
|
17534
17648
|
this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;
|
|
17535
17649
|
}
|
|
17536
17650
|
readMessage() {
|
|
@@ -17556,7 +17670,7 @@ function serializeMessage(message) {
|
|
|
17556
17670
|
return JSON.stringify(message) + "\n";
|
|
17557
17671
|
}
|
|
17558
17672
|
|
|
17559
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
17673
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
|
|
17560
17674
|
var DEFAULT_INHERITED_ENV_VARS = process3.platform === "win32" ? [
|
|
17561
17675
|
"APPDATA",
|
|
17562
17676
|
"HOMEDRIVE",
|
|
@@ -17590,9 +17704,9 @@ function getDefaultEnvironment() {
|
|
|
17590
17704
|
}
|
|
17591
17705
|
var StdioClientTransport = class {
|
|
17592
17706
|
constructor(server) {
|
|
17593
|
-
this._readBuffer = new ReadBuffer();
|
|
17594
17707
|
this._stderrStream = null;
|
|
17595
17708
|
this._serverParams = server;
|
|
17709
|
+
this._readBuffer = new ReadBuffer({ maxBufferSize: server.maxBufferSize });
|
|
17596
17710
|
if (server.stderr === "pipe" || server.stderr === "overlapped") {
|
|
17597
17711
|
this._stderrStream = new PassThrough();
|
|
17598
17712
|
}
|
|
@@ -17631,8 +17745,14 @@ var StdioClientTransport = class {
|
|
|
17631
17745
|
this.onerror?.(error2);
|
|
17632
17746
|
});
|
|
17633
17747
|
this._process.stdout?.on("data", (chunk) => {
|
|
17634
|
-
|
|
17635
|
-
|
|
17748
|
+
try {
|
|
17749
|
+
this._readBuffer.append(chunk);
|
|
17750
|
+
this.processReadBuffer();
|
|
17751
|
+
} catch (error2) {
|
|
17752
|
+
this.onerror?.(error2);
|
|
17753
|
+
this.close().catch(() => {
|
|
17754
|
+
});
|
|
17755
|
+
}
|
|
17636
17756
|
});
|
|
17637
17757
|
this._process.stdout?.on("error", (error2) => {
|
|
17638
17758
|
this.onerror?.(error2);
|
|
@@ -17721,9 +17841,26 @@ var StdioClientTransport = class {
|
|
|
17721
17841
|
}
|
|
17722
17842
|
};
|
|
17723
17843
|
|
|
17724
|
-
// ../../node_modules/.pnpm
|
|
17844
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js
|
|
17845
|
+
var import_content_type = __toESM(require_content_type());
|
|
17846
|
+
function mediaTypeEssence(header) {
|
|
17847
|
+
if (!header) {
|
|
17848
|
+
return void 0;
|
|
17849
|
+
}
|
|
17850
|
+
try {
|
|
17851
|
+
return import_content_type.default.parse(header).type;
|
|
17852
|
+
} catch {
|
|
17853
|
+
const essence = (header.split(";", 1)[0] ?? "").trim().toLowerCase();
|
|
17854
|
+
if (essence === "" || header.slice(essence.length).includes(",")) {
|
|
17855
|
+
return void 0;
|
|
17856
|
+
}
|
|
17857
|
+
return essence;
|
|
17858
|
+
}
|
|
17859
|
+
}
|
|
17860
|
+
|
|
17861
|
+
// ../../node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/stream.js
|
|
17725
17862
|
var EventSourceParserStream = class extends TransformStream {
|
|
17726
|
-
constructor({ onError, onRetry, onComment } = {}) {
|
|
17863
|
+
constructor({ onError, onRetry, onComment, maxBufferSize } = {}) {
|
|
17727
17864
|
let parser;
|
|
17728
17865
|
super({
|
|
17729
17866
|
start(controller) {
|
|
@@ -17732,10 +17869,11 @@ var EventSourceParserStream = class extends TransformStream {
|
|
|
17732
17869
|
controller.enqueue(event);
|
|
17733
17870
|
},
|
|
17734
17871
|
onError(error2) {
|
|
17735
|
-
onError
|
|
17872
|
+
typeof onError == "function" && onError(error2), (onError === "terminate" || error2.type === "max-buffer-size-exceeded") && controller.error(error2);
|
|
17736
17873
|
},
|
|
17737
17874
|
onRetry,
|
|
17738
|
-
onComment
|
|
17875
|
+
onComment,
|
|
17876
|
+
maxBufferSize
|
|
17739
17877
|
});
|
|
17740
17878
|
},
|
|
17741
17879
|
transform(chunk) {
|
|
@@ -17745,7 +17883,7 @@ var EventSourceParserStream = class extends TransformStream {
|
|
|
17745
17883
|
}
|
|
17746
17884
|
};
|
|
17747
17885
|
|
|
17748
|
-
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.
|
|
17886
|
+
// ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.30.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js
|
|
17749
17887
|
var DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS = {
|
|
17750
17888
|
initialReconnectionDelay: 1e3,
|
|
17751
17889
|
maxReconnectionDelay: 3e4,
|
|
@@ -18061,11 +18199,12 @@ var StreamableHTTPClientTransport = class {
|
|
|
18061
18199
|
}
|
|
18062
18200
|
const messages = Array.isArray(message) ? message : [message];
|
|
18063
18201
|
const hasRequests = messages.filter((msg) => "method" in msg && "id" in msg && msg.id !== void 0).length > 0;
|
|
18064
|
-
const
|
|
18202
|
+
const contentType2 = response.headers.get("content-type");
|
|
18203
|
+
const responseMediaType = mediaTypeEssence(contentType2);
|
|
18065
18204
|
if (hasRequests) {
|
|
18066
|
-
if (
|
|
18205
|
+
if (responseMediaType === "text/event-stream") {
|
|
18067
18206
|
this._handleSseStream(response.body, { onresumptiontoken }, false);
|
|
18068
|
-
} else if (
|
|
18207
|
+
} else if (responseMediaType === "application/json") {
|
|
18069
18208
|
const data = await response.json();
|
|
18070
18209
|
const responseMessages = Array.isArray(data) ? data.map((msg) => JSONRPCMessageSchema.parse(msg)) : [JSONRPCMessageSchema.parse(data)];
|
|
18071
18210
|
for (const msg of responseMessages) {
|
|
@@ -18073,7 +18212,7 @@ var StreamableHTTPClientTransport = class {
|
|
|
18073
18212
|
}
|
|
18074
18213
|
} else {
|
|
18075
18214
|
await response.body?.cancel();
|
|
18076
|
-
throw new StreamableHTTPError(-1, `Unexpected content type: ${
|
|
18215
|
+
throw new StreamableHTTPError(-1, `Unexpected content type: ${contentType2}`);
|
|
18077
18216
|
}
|
|
18078
18217
|
} else {
|
|
18079
18218
|
await response.body?.cancel();
|
|
@@ -18764,7 +18903,7 @@ ${client._stderrTail?.() ?? ""}`
|
|
|
18764
18903
|
var pi = defineAgentCli({
|
|
18765
18904
|
name: "Pi",
|
|
18766
18905
|
id: "pi",
|
|
18767
|
-
description: "earendil-works/pi \u2014 MIT headless TypeScript coding agent. Driven over pi's persistent JSON-over-stdio RPC mode (`pi --mode rpc`) as a spawned child. Multi-provider (Anthropic/OpenAI/Google), streaming, live-duplex (steer/follow-up/abort mid-turn). No native ACP/MCP, but injected MCP servers are BRIDGED into pi tools via a generated pi extension (see MCP-BRIDGE.md); otherwise pi runs only its own built-in file/shell tools.",
|
|
18906
|
+
description: "earendil-works/pi \u2014 MIT headless TypeScript coding agent. Driven over pi's persistent JSON-over-stdio RPC mode (`pi --mode rpc`) as a spawned child. Multi-provider (Anthropic/OpenAI/Google/Moonshot), streaming, live-duplex (steer/follow-up/abort mid-turn). No native ACP/MCP, but injected MCP servers are BRIDGED into pi tools via a generated pi extension (see MCP-BRIDGE.md); otherwise pi runs only its own built-in file/shell tools.",
|
|
18768
18907
|
version: "0.1.0",
|
|
18769
18908
|
// Real binary. The proprietary arm never spawns it for you (that's
|
|
18770
18909
|
// client.ts's job) but the AIP-45 schema requires the field, and client.ts
|
|
@@ -18784,7 +18923,7 @@ var pi = defineAgentCli({
|
|
|
18784
18923
|
auth: {
|
|
18785
18924
|
ref: "./SECRETS.md",
|
|
18786
18925
|
state: {
|
|
18787
|
-
env: ["ANTHROPIC_API_KEY", "OPENAI_API_KEY", "GOOGLE_GENERATIVE_AI_API_KEY"]
|
|
18926
|
+
env: ["ANTHROPIC_API_KEY", "OPENAI_API_KEY", "GOOGLE_GENERATIVE_AI_API_KEY", "MOONSHOT_API_KEY"]
|
|
18788
18927
|
}
|
|
18789
18928
|
},
|
|
18790
18929
|
sandbox: "./SANDBOX.md",
|
|
@@ -18799,6 +18938,10 @@ var pi = defineAgentCli({
|
|
|
18799
18938
|
turn_idle_timeout_ms: 3e5,
|
|
18800
18939
|
context_carryover: true
|
|
18801
18940
|
},
|
|
18941
|
+
// Pi routes on the model id's own `<provider>/<id>` prefix directly (see
|
|
18942
|
+
// models.allowed below), no adapter mode — so the route falls out of the
|
|
18943
|
+
// chosen model → derived-from-model.
|
|
18944
|
+
routeSelection: "derived-from-model",
|
|
18802
18945
|
models: {
|
|
18803
18946
|
// Pi's `--model <pattern>` accepts `provider/id` (verified against pi
|
|
18804
18947
|
// 0.80.x cli/args.ts + core/model-resolver.ts). `provider` below is
|
|
@@ -18808,12 +18951,27 @@ var pi = defineAgentCli({
|
|
|
18808
18951
|
allowed: [
|
|
18809
18952
|
{ id: "anthropic/claude-sonnet-4-5", provider: "anthropic" },
|
|
18810
18953
|
{ id: "openai/gpt-5.1", provider: "openai" },
|
|
18811
|
-
{ id: "google/gemini-2.5-flash", provider: "google" }
|
|
18954
|
+
{ id: "google/gemini-2.5-flash", provider: "google" },
|
|
18955
|
+
// Model-id PREFIX stays `moonshotai/` — that's what pi's own `--model`
|
|
18956
|
+
// resolver expects (see the comment above). The `provider` field is a
|
|
18957
|
+
// BILLING endpoint, not a wire-format echo, and must be the CANONICAL
|
|
18958
|
+
// catalog slug `moonshot` (base.ts:48) — `moonshotai` is the upstream/
|
|
18959
|
+
// wire slug, already documented to drift from ours (base.ts:113-121).
|
|
18960
|
+
// Conflating the two is D3: it made the runtime's model→provider
|
|
18961
|
+
// eligibility projection compute an unrecognized "moonshotai" endpoint,
|
|
18962
|
+
// which doesn't match any real wallet, so a genuinely-eligible moonshot
|
|
18963
|
+
// profile was rejected.
|
|
18964
|
+
{ id: "moonshotai/kimi-k3", provider: "moonshot" },
|
|
18965
|
+
{ id: "moonshotai/kimi-k2.7-code", provider: "moonshot" }
|
|
18812
18966
|
],
|
|
18813
18967
|
env: {
|
|
18814
18968
|
anthropic: "ANTHROPIC_API_KEY",
|
|
18815
18969
|
openai: "OPENAI_API_KEY",
|
|
18816
|
-
google: "GOOGLE_GENERATIVE_AI_API_KEY"
|
|
18970
|
+
google: "GOOGLE_GENERATIVE_AI_API_KEY",
|
|
18971
|
+
// Keyed by the canonical provider slug (matches `provider` above), not
|
|
18972
|
+
// the wire-format `moonshotai` prefix — see the comment on the
|
|
18973
|
+
// `allowed` entry.
|
|
18974
|
+
moonshot: "MOONSHOT_API_KEY"
|
|
18817
18975
|
}
|
|
18818
18976
|
},
|
|
18819
18977
|
capabilities: {
|
|
@@ -18881,6 +19039,15 @@ var pi = defineAgentCli({
|
|
|
18881
19039
|
function piRuntime() {
|
|
18882
19040
|
return createAgentCliRuntime(pi);
|
|
18883
19041
|
}
|
|
19042
|
+
/*! Bundled license information:
|
|
19043
|
+
|
|
19044
|
+
content-type/index.js:
|
|
19045
|
+
(*!
|
|
19046
|
+
* content-type
|
|
19047
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
19048
|
+
* MIT Licensed
|
|
19049
|
+
*)
|
|
19050
|
+
*/
|
|
18884
19051
|
|
|
18885
19052
|
export { classifyPiLine, createAgentCliClient, createPiMapperState, mapPiEvent, mapStopReason, pi, piRuntime, resetPiMapperState };
|
|
18886
19053
|
//# sourceMappingURL=index.mjs.map
|