@moxt-ai/mobius 0.0.289 → 0.0.291
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/dist/acp/harness/codex/agent.js +1 -1
- package/dist/acp/harness/codex/agent.js.map +1 -1
- package/dist/acp/harness/codex/borrowed-agent.d.ts.map +1 -1
- package/dist/acp/harness/codex/borrowed-agent.js +1 -3
- package/dist/acp/harness/codex/borrowed-agent.js.map +1 -1
- package/dist/acp/harness/codex/owned-agent.d.ts +1 -1
- package/dist/acp/harness/codex/owned-agent.d.ts.map +1 -1
- package/dist/acp/harness/codex/owned-agent.js +8 -8
- package/dist/acp/harness/codex/owned-agent.js.map +1 -1
- package/dist/acp/protocol/elicitation.d.ts.map +1 -1
- package/dist/acp/protocol/elicitation.js +4 -0
- package/dist/acp/protocol/elicitation.js.map +1 -1
- package/dist/cli.js +315 -170
- package/dist/cli.js.map +4 -4
- package/dist/runtime.js +315 -170
- package/dist/runtime.js.map +4 -4
- package/dist/session/turn/session-turns.d.ts +1 -0
- package/dist/session/turn/session-turns.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -5398,7 +5398,7 @@ var program = new Command();
|
|
|
5398
5398
|
// package.json
|
|
5399
5399
|
var package_default = {
|
|
5400
5400
|
name: "@moxt-ai/mobius",
|
|
5401
|
-
version: "0.0.
|
|
5401
|
+
version: "0.0.291",
|
|
5402
5402
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
5403
5403
|
type: "module",
|
|
5404
5404
|
bin: {
|
|
@@ -70789,7 +70789,7 @@ var CodexBorrowedAcpAgent = class {
|
|
|
70789
70789
|
const text2 = previous !== void 0 && value.startsWith(previous) ? value.slice(previous.length) : value;
|
|
70790
70790
|
if (text2.length > 0) {
|
|
70791
70791
|
await this.#emit({
|
|
70792
|
-
sessionUpdate: item.type === "agentMessage"
|
|
70792
|
+
sessionUpdate: item.type === "agentMessage" ? "agent_message_chunk" : "agent_thought_chunk",
|
|
70793
70793
|
messageId: key,
|
|
70794
70794
|
content: { type: "text", text: text2 }
|
|
70795
70795
|
});
|
|
@@ -71017,11 +71017,11 @@ function steeringPrompt(prompt) {
|
|
|
71017
71017
|
}
|
|
71018
71018
|
return blocks;
|
|
71019
71019
|
}
|
|
71020
|
-
function agentMessageUpdate(messageId, text2
|
|
71020
|
+
function agentMessageUpdate(messageId, text2) {
|
|
71021
71021
|
return {
|
|
71022
71022
|
content: { text: text2, type: "text" },
|
|
71023
71023
|
messageId,
|
|
71024
|
-
sessionUpdate:
|
|
71024
|
+
sessionUpdate: "agent_message_chunk"
|
|
71025
71025
|
};
|
|
71026
71026
|
}
|
|
71027
71027
|
function userInputSchema(questions) {
|
|
@@ -71270,10 +71270,9 @@ var CodexOwnedAcpAgent = class {
|
|
|
71270
71270
|
if (method === "item/agentMessage/delta") {
|
|
71271
71271
|
const decoded = reasoningTextDeltaParamsSchema.safeParse(params);
|
|
71272
71272
|
if (decoded.success && decoded.data.threadId === this.#context.threadId() && this.#turn !== null && decoded.data.turnId === this.#turn.turn.id && decoded.data.delta.length > 0) {
|
|
71273
|
-
|
|
71274
|
-
this.#agentMessages.set(decoded.data.itemId, { phase, kind: "streaming" });
|
|
71273
|
+
this.#agentMessages.set(decoded.data.itemId, "streaming");
|
|
71275
71274
|
await this.#enqueue(async () => {
|
|
71276
|
-
await this.#context.emit(agentMessageUpdate(decoded.data.itemId, decoded.data.delta
|
|
71275
|
+
await this.#context.emit(agentMessageUpdate(decoded.data.itemId, decoded.data.delta));
|
|
71277
71276
|
});
|
|
71278
71277
|
}
|
|
71279
71278
|
return;
|
|
@@ -71287,16 +71286,16 @@ var CodexOwnedAcpAgent = class {
|
|
|
71287
71286
|
}
|
|
71288
71287
|
if (item.type === "agentMessage") {
|
|
71289
71288
|
if (method === "item/started") {
|
|
71290
|
-
this.#agentMessages.set(item.id,
|
|
71289
|
+
this.#agentMessages.set(item.id, "started");
|
|
71291
71290
|
return;
|
|
71292
71291
|
}
|
|
71293
71292
|
const message = this.#agentMessages.get(item.id);
|
|
71294
71293
|
this.#agentMessages.delete(item.id);
|
|
71295
|
-
if (message
|
|
71294
|
+
if (message === "streaming") {
|
|
71296
71295
|
return;
|
|
71297
71296
|
}
|
|
71298
71297
|
await this.#enqueue(async () => {
|
|
71299
|
-
await this.#context.emit(agentMessageUpdate(item.id, item.text
|
|
71298
|
+
await this.#context.emit(agentMessageUpdate(item.id, item.text));
|
|
71300
71299
|
});
|
|
71301
71300
|
return;
|
|
71302
71301
|
}
|
|
@@ -72215,6 +72214,7 @@ var elicitationFieldSchema = external_exports.object({
|
|
|
72215
72214
|
maximumLength: external_exports.string().max(128),
|
|
72216
72215
|
minimum: external_exports.string().max(128),
|
|
72217
72216
|
minimumLength: external_exports.string().max(128),
|
|
72217
|
+
multiline: external_exports.boolean().optional(),
|
|
72218
72218
|
name: external_exports.string().min(1).max(128),
|
|
72219
72219
|
options: external_exports.array(elicitationOptionSchema).max(200).readonly(),
|
|
72220
72220
|
pattern: external_exports.string().max(500),
|
|
@@ -74160,7 +74160,7 @@ var CodexAcpAgent = class {
|
|
|
74160
74160
|
continue;
|
|
74161
74161
|
}
|
|
74162
74162
|
if (item.type === "agentMessage") {
|
|
74163
|
-
await this.#emit(agentMessageUpdate(item.id, item.text
|
|
74163
|
+
await this.#emit(agentMessageUpdate(item.id, item.text));
|
|
74164
74164
|
continue;
|
|
74165
74165
|
}
|
|
74166
74166
|
if (item.type === "contextCompaction") {
|
|
@@ -74238,7 +74238,7 @@ import { spawnSync } from "node:child_process";
|
|
|
74238
74238
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
74239
74239
|
import { existsSync as existsSync7, readdirSync as readdirSync6, readFileSync as readFileSync8, realpathSync as realpathSync3, statSync as statSync3, unlinkSync as unlinkSync2 } from "node:fs";
|
|
74240
74240
|
import { basename as basename4, dirname as dirname7, isAbsolute as isAbsolute11, join as join17 } from "node:path";
|
|
74241
|
-
import { RequestError as
|
|
74241
|
+
import { RequestError as RequestError7 } from "@agentclientprotocol/sdk";
|
|
74242
74242
|
|
|
74243
74243
|
// src/acp/harness/pi/upstream/dist/pi-rpc/process.js
|
|
74244
74244
|
import { spawn as spawn4 } from "node:child_process";
|
|
@@ -74271,6 +74271,13 @@ var PiRpcSpawnError = class extends Error {
|
|
|
74271
74271
|
this.cause = opts?.cause;
|
|
74272
74272
|
}
|
|
74273
74273
|
};
|
|
74274
|
+
var PiRpcProcessError = class extends Error {
|
|
74275
|
+
code = "pi_process_exited";
|
|
74276
|
+
constructor(cause) {
|
|
74277
|
+
super("Pi process stopped unexpectedly.", { cause });
|
|
74278
|
+
this.name = "PiRpcProcessError";
|
|
74279
|
+
}
|
|
74280
|
+
};
|
|
74274
74281
|
var ESC = String.fromCharCode(27);
|
|
74275
74282
|
var CSI = String.fromCharCode(155);
|
|
74276
74283
|
var ANSI_ESCAPE_REGEX = new RegExp(`[${ESC}${CSI}][[\\]()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]`, "g");
|
|
@@ -74280,6 +74287,10 @@ function stripAnsi(s) {
|
|
|
74280
74287
|
var SESSION_STATS_TIMEOUT_MS = 1e3;
|
|
74281
74288
|
var PiRpcProcess = class _PiRpcProcess {
|
|
74282
74289
|
child;
|
|
74290
|
+
lifetime = new AbortController();
|
|
74291
|
+
get signal() {
|
|
74292
|
+
return this.lifetime.signal;
|
|
74293
|
+
}
|
|
74283
74294
|
pending = /* @__PURE__ */ new Map();
|
|
74284
74295
|
eventHandlers = [];
|
|
74285
74296
|
preludeLines = [];
|
|
@@ -74314,13 +74325,16 @@ var PiRpcProcess = class _PiRpcProcess {
|
|
|
74314
74325
|
}
|
|
74315
74326
|
});
|
|
74316
74327
|
child.on("exit", (code, signal) => {
|
|
74317
|
-
const err = new
|
|
74328
|
+
const err = new PiRpcProcessError({ code, signal });
|
|
74329
|
+
this.lifetime.abort(err);
|
|
74318
74330
|
for (const [, p] of this.pending) {
|
|
74319
74331
|
p.reject(err);
|
|
74320
74332
|
}
|
|
74321
74333
|
this.pending.clear();
|
|
74322
74334
|
});
|
|
74323
|
-
child.on("error", (
|
|
74335
|
+
child.on("error", (cause) => {
|
|
74336
|
+
const err = new PiRpcProcessError(cause);
|
|
74337
|
+
this.lifetime.abort(err);
|
|
74324
74338
|
for (const [, p] of this.pending) {
|
|
74325
74339
|
p.reject(err);
|
|
74326
74340
|
}
|
|
@@ -74402,6 +74416,7 @@ var PiRpcProcess = class _PiRpcProcess {
|
|
|
74402
74416
|
};
|
|
74403
74417
|
}
|
|
74404
74418
|
dispose(signal = "SIGTERM") {
|
|
74419
|
+
this.lifetime.abort();
|
|
74405
74420
|
if (this.child.killed) {
|
|
74406
74421
|
return;
|
|
74407
74422
|
}
|
|
@@ -74410,6 +74425,10 @@ var PiRpcProcess = class _PiRpcProcess {
|
|
|
74410
74425
|
} catch {
|
|
74411
74426
|
}
|
|
74412
74427
|
}
|
|
74428
|
+
terminateAfterFailure(cause) {
|
|
74429
|
+
this.lifetime.abort(new PiRpcProcessError(cause));
|
|
74430
|
+
this.dispose();
|
|
74431
|
+
}
|
|
74413
74432
|
/**
|
|
74414
74433
|
* Human-readable stdout lines emitted before RPC NDJSON begins (e.g. Context/Skills/Extensions info).
|
|
74415
74434
|
* Themes are typically noisy/less useful for ACP, so callers can filter as needed.
|
|
@@ -74430,8 +74449,8 @@ var PiRpcProcess = class _PiRpcProcess {
|
|
|
74430
74449
|
throw new Error(`pi steer failed: ${res.error ?? JSON.stringify(res.data)}`);
|
|
74431
74450
|
}
|
|
74432
74451
|
}
|
|
74433
|
-
async abort() {
|
|
74434
|
-
const res = await this.request({ type: "abort" });
|
|
74452
|
+
async abort(opts) {
|
|
74453
|
+
const res = await this.request({ type: "abort" }, opts);
|
|
74435
74454
|
if (!res.success) {
|
|
74436
74455
|
throw new Error(`pi abort failed: ${res.error ?? JSON.stringify(res.data)}`);
|
|
74437
74456
|
}
|
|
@@ -75128,7 +75147,176 @@ function getQuietStartup(cwd, environment = process.env) {
|
|
|
75128
75147
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
75129
75148
|
import { readFileSync as readFileSync7 } from "node:fs";
|
|
75130
75149
|
import { isAbsolute as isAbsolute10, resolve as resolvePath } from "node:path";
|
|
75150
|
+
import { RequestError as RequestError6 } from "@agentclientprotocol/sdk";
|
|
75151
|
+
|
|
75152
|
+
// src/acp/harness/pi/upstream/dist/acp/extension-questions.js
|
|
75131
75153
|
import { RequestError as RequestError5 } from "@agentclientprotocol/sdk";
|
|
75154
|
+
var questionBase = {
|
|
75155
|
+
id: external_exports.string().min(1).max(255),
|
|
75156
|
+
title: external_exports.string().max(255),
|
|
75157
|
+
timeout: external_exports.number().int().nonnegative().max(2147483647).optional()
|
|
75158
|
+
};
|
|
75159
|
+
var questionSchema = external_exports.discriminatedUnion("method", [
|
|
75160
|
+
external_exports.object({
|
|
75161
|
+
...questionBase,
|
|
75162
|
+
method: external_exports.literal("select"),
|
|
75163
|
+
options: external_exports.array(external_exports.string().min(1).max(255)).min(1).max(200).readonly()
|
|
75164
|
+
}),
|
|
75165
|
+
external_exports.object({ ...questionBase, method: external_exports.literal("confirm"), message: external_exports.string().max(2e3) }),
|
|
75166
|
+
external_exports.object({ ...questionBase, method: external_exports.literal("input"), placeholder: external_exports.string().max(500).optional() }),
|
|
75167
|
+
external_exports.object({ ...questionBase, method: external_exports.literal("editor"), prefill: external_exports.string().max(1e4).optional() })
|
|
75168
|
+
]).readonly();
|
|
75169
|
+
var QUESTION_TIMEOUT_MS = 36e5;
|
|
75170
|
+
var PiQuestionError = class extends RequestError5 {
|
|
75171
|
+
constructor(kind, cause) {
|
|
75172
|
+
const messages = {
|
|
75173
|
+
request_failed: "Pi could not request an answer.",
|
|
75174
|
+
invalid_response: "Pi received an invalid answer.",
|
|
75175
|
+
response_failed: "Pi could not receive the answer."
|
|
75176
|
+
};
|
|
75177
|
+
super(-32603, "Internal error", { code: `pi_question_${kind}`, details: messages[kind] });
|
|
75178
|
+
this.cause = cause;
|
|
75179
|
+
}
|
|
75180
|
+
};
|
|
75181
|
+
function questionField(question) {
|
|
75182
|
+
const title2 = question.title || "Answer";
|
|
75183
|
+
switch (question.method) {
|
|
75184
|
+
case "select":
|
|
75185
|
+
return { type: "string", title: title2, enum: [...question.options] };
|
|
75186
|
+
case "confirm":
|
|
75187
|
+
return {
|
|
75188
|
+
type: "string",
|
|
75189
|
+
title: title2,
|
|
75190
|
+
oneOf: [
|
|
75191
|
+
{ const: "yes", title: "Yes" },
|
|
75192
|
+
{ const: "no", title: "No" }
|
|
75193
|
+
]
|
|
75194
|
+
};
|
|
75195
|
+
case "input":
|
|
75196
|
+
return { type: "string", title: title2, description: question.placeholder, maxLength: 1e4 };
|
|
75197
|
+
case "editor":
|
|
75198
|
+
return {
|
|
75199
|
+
type: "string",
|
|
75200
|
+
title: title2,
|
|
75201
|
+
default: question.prefill,
|
|
75202
|
+
maxLength: 1e4,
|
|
75203
|
+
_meta: { "io.mobius/multiline": true }
|
|
75204
|
+
};
|
|
75205
|
+
}
|
|
75206
|
+
}
|
|
75207
|
+
var PiExtensionQuestions = class {
|
|
75208
|
+
sessionId;
|
|
75209
|
+
conn;
|
|
75210
|
+
proc;
|
|
75211
|
+
notify;
|
|
75212
|
+
turn = null;
|
|
75213
|
+
constructor(sessionId, conn, proc, notify) {
|
|
75214
|
+
this.sessionId = sessionId;
|
|
75215
|
+
this.conn = conn;
|
|
75216
|
+
this.proc = proc;
|
|
75217
|
+
this.notify = notify;
|
|
75218
|
+
}
|
|
75219
|
+
startTurn() {
|
|
75220
|
+
this.endTurn();
|
|
75221
|
+
this.turn = { controller: new AbortController(), requestIds: /* @__PURE__ */ new Set() };
|
|
75222
|
+
return this.turn.controller.signal;
|
|
75223
|
+
}
|
|
75224
|
+
endTurn(reason) {
|
|
75225
|
+
this.turn?.controller.abort(reason);
|
|
75226
|
+
this.turn = null;
|
|
75227
|
+
}
|
|
75228
|
+
async handle(event) {
|
|
75229
|
+
if (event.method !== "select" && event.method !== "confirm" && event.method !== "input" && event.method !== "editor") {
|
|
75230
|
+
return;
|
|
75231
|
+
}
|
|
75232
|
+
if (typeof event.id !== "string" || event.id.length === 0 || event.id.length > 255) {
|
|
75233
|
+
return;
|
|
75234
|
+
}
|
|
75235
|
+
const turn = this.turn;
|
|
75236
|
+
if (turn?.requestIds.has(event.id)) {
|
|
75237
|
+
return;
|
|
75238
|
+
}
|
|
75239
|
+
turn?.requestIds.add(event.id);
|
|
75240
|
+
try {
|
|
75241
|
+
await this.answer(event, turn);
|
|
75242
|
+
} catch (cause) {
|
|
75243
|
+
if (!this.proc.signal.aborted) {
|
|
75244
|
+
turn?.controller.abort(new PiQuestionError("response_failed", cause));
|
|
75245
|
+
this.proc.terminateAfterFailure(cause);
|
|
75246
|
+
}
|
|
75247
|
+
}
|
|
75248
|
+
}
|
|
75249
|
+
async answer(event, turn) {
|
|
75250
|
+
const id = typeof event.id === "string" ? event.id : "";
|
|
75251
|
+
const parsed = questionSchema.safeParse(event);
|
|
75252
|
+
if (!parsed.success) {
|
|
75253
|
+
await this.notify("Pi requested a question with unsupported or oversized fields. The question was cancelled without changing its content.");
|
|
75254
|
+
await this.proc.sendExtensionUiResponse({ id, cancelled: true });
|
|
75255
|
+
return;
|
|
75256
|
+
}
|
|
75257
|
+
const question = parsed.data;
|
|
75258
|
+
if (turn === null || turn.controller.signal.aborted) {
|
|
75259
|
+
await this.proc.sendExtensionUiResponse({ id: question.id, cancelled: true });
|
|
75260
|
+
return;
|
|
75261
|
+
}
|
|
75262
|
+
const deadline = new AbortController();
|
|
75263
|
+
const timeout = setTimeout(() => deadline.abort(), question.timeout || QUESTION_TIMEOUT_MS);
|
|
75264
|
+
const signal = AbortSignal.any([turn.controller.signal, deadline.signal]);
|
|
75265
|
+
let response = { id: question.id, cancelled: true };
|
|
75266
|
+
try {
|
|
75267
|
+
const answer = await this.conn.requestElicitation({
|
|
75268
|
+
sessionId: this.sessionId,
|
|
75269
|
+
mode: "form",
|
|
75270
|
+
message: (question.method === "confirm" ? question.message : "") || question.title || "Pi question",
|
|
75271
|
+
requestedSchema: {
|
|
75272
|
+
type: "object",
|
|
75273
|
+
properties: { value: questionField(question) },
|
|
75274
|
+
required: ["value"]
|
|
75275
|
+
}
|
|
75276
|
+
}, signal);
|
|
75277
|
+
const content = answer.action === "accept" ? answer.content : void 0;
|
|
75278
|
+
const value = typeof content === "object" && content !== null ? Reflect.get(content, "value") : void 0;
|
|
75279
|
+
if (!signal.aborted && answer.action === "accept") {
|
|
75280
|
+
if (typeof value !== "string") {
|
|
75281
|
+
throw new PiQuestionError("invalid_response");
|
|
75282
|
+
}
|
|
75283
|
+
switch (question.method) {
|
|
75284
|
+
case "select":
|
|
75285
|
+
if (!question.options.includes(value)) {
|
|
75286
|
+
throw new PiQuestionError("invalid_response");
|
|
75287
|
+
}
|
|
75288
|
+
response = { id: question.id, value };
|
|
75289
|
+
break;
|
|
75290
|
+
case "confirm":
|
|
75291
|
+
if (value !== "yes" && value !== "no") {
|
|
75292
|
+
throw new PiQuestionError("invalid_response");
|
|
75293
|
+
}
|
|
75294
|
+
response = { id: question.id, confirmed: value === "yes" };
|
|
75295
|
+
break;
|
|
75296
|
+
case "input":
|
|
75297
|
+
case "editor":
|
|
75298
|
+
if (value.length > 1e4) {
|
|
75299
|
+
throw new PiQuestionError("invalid_response");
|
|
75300
|
+
}
|
|
75301
|
+
response = { id: question.id, value };
|
|
75302
|
+
break;
|
|
75303
|
+
}
|
|
75304
|
+
} else if (!signal.aborted && answer.action !== "cancel" && answer.action !== "decline") {
|
|
75305
|
+
throw new PiQuestionError("invalid_response");
|
|
75306
|
+
}
|
|
75307
|
+
} catch (cause) {
|
|
75308
|
+
if (!signal.aborted && !(cause instanceof RequestError5 && cause.code === -32800)) {
|
|
75309
|
+
turn.controller.abort(cause instanceof PiQuestionError ? cause : new PiQuestionError("request_failed", cause));
|
|
75310
|
+
}
|
|
75311
|
+
} finally {
|
|
75312
|
+
clearTimeout(timeout);
|
|
75313
|
+
}
|
|
75314
|
+
if (deadline.signal.aborted && signal.reason === deadline.signal.reason) {
|
|
75315
|
+
await this.notify("Pi question timed out; no answer was submitted.");
|
|
75316
|
+
}
|
|
75317
|
+
await this.proc.sendExtensionUiResponse(response);
|
|
75318
|
+
}
|
|
75319
|
+
};
|
|
75132
75320
|
|
|
75133
75321
|
// src/acp/harness/pi/upstream/dist/acp/session-store.js
|
|
75134
75322
|
import { mkdirSync as mkdirSync2, readFileSync as readFileSync5, writeFileSync } from "node:fs";
|
|
@@ -75397,12 +75585,6 @@ ${stderr}`);
|
|
|
75397
75585
|
}
|
|
75398
75586
|
|
|
75399
75587
|
// src/acp/harness/pi/upstream/dist/acp/session.js
|
|
75400
|
-
var CONFIRM_PERMISSION_OPTIONS = [
|
|
75401
|
-
{ optionId: "yes", name: "Yes", kind: "allow_once" },
|
|
75402
|
-
{ optionId: "no", name: "No", kind: "reject_once" }
|
|
75403
|
-
];
|
|
75404
|
-
var EXTENSION_UI_RAW_INPUT_KEYS = ["title", "message", "options", "placeholder", "prefill"];
|
|
75405
|
-
var CHOICE_OPTION_PREFIX = "choice-";
|
|
75406
75588
|
function toUsageUpdate(stats) {
|
|
75407
75589
|
const used = stats?.contextUsage?.tokens;
|
|
75408
75590
|
const size = stats?.contextUsage?.contextWindow;
|
|
@@ -75523,7 +75705,7 @@ var SessionManager = class {
|
|
|
75523
75705
|
return;
|
|
75524
75706
|
}
|
|
75525
75707
|
try {
|
|
75526
|
-
s.
|
|
75708
|
+
s.dispose();
|
|
75527
75709
|
} catch {
|
|
75528
75710
|
}
|
|
75529
75711
|
this.sessions.delete(sessionId);
|
|
@@ -75548,7 +75730,7 @@ var SessionManager = class {
|
|
|
75548
75730
|
});
|
|
75549
75731
|
} catch (e) {
|
|
75550
75732
|
if (e instanceof PiRpcSpawnError) {
|
|
75551
|
-
throw
|
|
75733
|
+
throw RequestError6.internalError({ code: e.code }, e.message);
|
|
75552
75734
|
}
|
|
75553
75735
|
throw e;
|
|
75554
75736
|
}
|
|
@@ -75577,7 +75759,7 @@ var SessionManager = class {
|
|
|
75577
75759
|
get(sessionId) {
|
|
75578
75760
|
const s = this.sessions.get(sessionId);
|
|
75579
75761
|
if (!s) {
|
|
75580
|
-
throw
|
|
75762
|
+
throw RequestError6.invalidParams(`Unknown sessionId: ${sessionId}`);
|
|
75581
75763
|
}
|
|
75582
75764
|
return s;
|
|
75583
75765
|
}
|
|
@@ -75610,6 +75792,7 @@ var PiAcpSession = class {
|
|
|
75610
75792
|
startupInfoSent = false;
|
|
75611
75793
|
proc;
|
|
75612
75794
|
conn;
|
|
75795
|
+
extensionQuestions;
|
|
75613
75796
|
fileCommands;
|
|
75614
75797
|
// Used to map abort semantics to ACP stopReason.
|
|
75615
75798
|
// Applies to the currently running turn.
|
|
@@ -75664,8 +75847,38 @@ var PiAcpSession = class {
|
|
|
75664
75847
|
this.proc = opts.proc;
|
|
75665
75848
|
this.conn = opts.conn;
|
|
75666
75849
|
this.fileCommands = opts.fileCommands ?? [];
|
|
75850
|
+
this.extensionQuestions = new PiExtensionQuestions(this.sessionId, this.conn, this.proc, async (text2) => {
|
|
75851
|
+
this.emit({ sessionUpdate: "agent_message_chunk", content: { type: "text", text: text2 } });
|
|
75852
|
+
await this.flushEmits();
|
|
75853
|
+
});
|
|
75854
|
+
this.proc.signal.addEventListener("abort", () => {
|
|
75855
|
+
const cause = this.proc.signal.reason;
|
|
75856
|
+
if (cause instanceof PiRpcProcessError) {
|
|
75857
|
+
const pending = this.pendingTurn;
|
|
75858
|
+
const reason = pending?.questionSignal.reason;
|
|
75859
|
+
const error62 = reason instanceof RequestError6 ? reason : RequestError6.internalError({ code: cause.code, details: cause.message });
|
|
75860
|
+
if (!(reason instanceof RequestError6)) {
|
|
75861
|
+
error62.cause = cause;
|
|
75862
|
+
}
|
|
75863
|
+
this.extensionQuestions.endTurn(error62);
|
|
75864
|
+
this.pendingTurn = null;
|
|
75865
|
+
void this.flushEmits().then(() => {
|
|
75866
|
+
if (this.cancelRequested) {
|
|
75867
|
+
pending?.resolve("cancelled");
|
|
75868
|
+
} else {
|
|
75869
|
+
pending?.reject(error62);
|
|
75870
|
+
}
|
|
75871
|
+
});
|
|
75872
|
+
} else {
|
|
75873
|
+
this.extensionQuestions.endTurn();
|
|
75874
|
+
}
|
|
75875
|
+
}, { once: true });
|
|
75667
75876
|
this.proc.onEvent((ev2) => this.handlePiEvent(ev2));
|
|
75668
75877
|
}
|
|
75878
|
+
dispose() {
|
|
75879
|
+
this.extensionQuestions.endTurn();
|
|
75880
|
+
this.proc.dispose();
|
|
75881
|
+
}
|
|
75669
75882
|
setStartupInfo(text2) {
|
|
75670
75883
|
this.startupInfo = text2;
|
|
75671
75884
|
this.startupInfoSent = false;
|
|
@@ -75708,6 +75921,31 @@ var PiAcpSession = class {
|
|
|
75708
75921
|
});
|
|
75709
75922
|
return turnPromise;
|
|
75710
75923
|
}
|
|
75924
|
+
async compact(customInstructions, timeoutMs) {
|
|
75925
|
+
const signal = this.extensionQuestions.startTurn();
|
|
75926
|
+
try {
|
|
75927
|
+
const result = await this.proc.compact(customInstructions, { signal, timeoutMs });
|
|
75928
|
+
if (signal.aborted && signal.reason instanceof RequestError6) {
|
|
75929
|
+
throw signal.reason;
|
|
75930
|
+
}
|
|
75931
|
+
return result;
|
|
75932
|
+
} catch (cause) {
|
|
75933
|
+
if (signal.aborted && signal.reason instanceof RequestError6) {
|
|
75934
|
+
try {
|
|
75935
|
+
await this.proc.abort({ signal: this.proc.signal, timeoutMs });
|
|
75936
|
+
} catch (abortCause) {
|
|
75937
|
+
if (!this.proc.signal.aborted) {
|
|
75938
|
+
this.proc.terminateAfterFailure(abortCause);
|
|
75939
|
+
}
|
|
75940
|
+
}
|
|
75941
|
+
throw signal.reason;
|
|
75942
|
+
}
|
|
75943
|
+
throw cause;
|
|
75944
|
+
} finally {
|
|
75945
|
+
this.extensionQuestions.endTurn();
|
|
75946
|
+
await this.flushEmits();
|
|
75947
|
+
}
|
|
75948
|
+
}
|
|
75711
75949
|
async steer(message, images, signal) {
|
|
75712
75950
|
const target = this.pendingTurn;
|
|
75713
75951
|
if (target === null) {
|
|
@@ -75726,6 +75964,7 @@ var PiAcpSession = class {
|
|
|
75726
75964
|
}
|
|
75727
75965
|
async cancel() {
|
|
75728
75966
|
this.cancelRequested = true;
|
|
75967
|
+
this.extensionQuestions.endTurn();
|
|
75729
75968
|
if (this.turnQueue.length) {
|
|
75730
75969
|
const queued = this.turnQueue.splice(0, this.turnQueue.length);
|
|
75731
75970
|
for (const t of queued) {
|
|
@@ -75740,7 +75979,13 @@ var PiAcpSession = class {
|
|
|
75740
75979
|
_meta: { piAcp: { queueDepth: 0, running: Boolean(this.pendingTurn) } }
|
|
75741
75980
|
});
|
|
75742
75981
|
}
|
|
75743
|
-
|
|
75982
|
+
try {
|
|
75983
|
+
await this.proc.abort();
|
|
75984
|
+
} catch (cause) {
|
|
75985
|
+
if (!this.proc.signal.aborted) {
|
|
75986
|
+
throw cause;
|
|
75987
|
+
}
|
|
75988
|
+
}
|
|
75744
75989
|
}
|
|
75745
75990
|
wasCancelRequested() {
|
|
75746
75991
|
return this.cancelRequested;
|
|
@@ -75773,15 +76018,19 @@ var PiAcpSession = class {
|
|
|
75773
76018
|
await this.flushEmits();
|
|
75774
76019
|
}
|
|
75775
76020
|
async settleTurn() {
|
|
76021
|
+
const questionSignal = this.pendingTurn?.questionSignal;
|
|
76022
|
+
this.extensionQuestions.endTurn();
|
|
75776
76023
|
await this.publishContextUsage();
|
|
75777
76024
|
const retryFailure = this.turnRetryFailure;
|
|
75778
76025
|
this.turnRetryFailure = null;
|
|
75779
|
-
if (
|
|
76026
|
+
if (questionSignal?.aborted && questionSignal.reason instanceof RequestError6 && !this.cancelRequested) {
|
|
76027
|
+
this.pendingTurn?.reject(questionSignal.reason);
|
|
76028
|
+
} else if (retryFailure !== null && !this.cancelRequested) {
|
|
75780
76029
|
this.pendingTurn?.reject(
|
|
75781
76030
|
// The message rides in `data.details` so clients that unwrap the
|
|
75782
76031
|
// JSON-RPC internal-error envelope (like Mobius) surface the real
|
|
75783
76032
|
// model error; `code` keeps the failure machine-readable.
|
|
75784
|
-
|
|
76033
|
+
RequestError6.internalError({
|
|
75785
76034
|
code: "pi_retries_exhausted",
|
|
75786
76035
|
details: `Pi retries exhausted: ${retryFailure}`
|
|
75787
76036
|
})
|
|
@@ -75835,14 +76084,16 @@ var PiAcpSession = class {
|
|
|
75835
76084
|
this.bashToolCallIds.delete(toolCallId);
|
|
75836
76085
|
}
|
|
75837
76086
|
startTurn(t) {
|
|
76087
|
+
const questionSignal = this.extensionQuestions.startTurn();
|
|
75838
76088
|
this.cancelRequested = false;
|
|
75839
76089
|
this.turnRetryFailure = null;
|
|
75840
|
-
this.pendingTurn = { resolve: t.resolve, reject: t.reject };
|
|
76090
|
+
this.pendingTurn = { questionSignal, resolve: t.resolve, reject: t.reject };
|
|
75841
76091
|
this.emit({
|
|
75842
76092
|
sessionUpdate: "session_info_update",
|
|
75843
76093
|
_meta: { piAcp: { queueDepth: this.turnQueue.length, running: true } }
|
|
75844
76094
|
});
|
|
75845
76095
|
this.proc.prompt(t.message, t.images).catch((err) => {
|
|
76096
|
+
this.extensionQuestions.endTurn();
|
|
75846
76097
|
void this.flushEmits().finally(() => {
|
|
75847
76098
|
const authErr = maybeAuthRequiredError(err);
|
|
75848
76099
|
if (authErr) {
|
|
@@ -76081,14 +76332,15 @@ var PiAcpSession = class {
|
|
|
76081
76332
|
break;
|
|
76082
76333
|
}
|
|
76083
76334
|
case "extension_ui_request": {
|
|
76084
|
-
|
|
76085
|
-
|
|
76086
|
-
|
|
76087
|
-
|
|
76088
|
-
|
|
76089
|
-
void this.proc.sendExtensionUiResponse({ id, cancelled: true }).catch(() => {
|
|
76335
|
+
if (ev2.method === "notify") {
|
|
76336
|
+
this.emit({
|
|
76337
|
+
sessionUpdate: "agent_message_chunk",
|
|
76338
|
+
content: { type: "text", text: stringProp(ev2, "message") ?? "Pi notification" },
|
|
76339
|
+
_meta: { piAcp: { notify: { level: stringProp(ev2, "notifyType") ?? "info" } } }
|
|
76090
76340
|
});
|
|
76091
|
-
|
|
76341
|
+
break;
|
|
76342
|
+
}
|
|
76343
|
+
void this.extensionQuestions.handle(ev2);
|
|
76092
76344
|
break;
|
|
76093
76345
|
}
|
|
76094
76346
|
case "auto_retry_start": {
|
|
@@ -76141,119 +76393,11 @@ var PiAcpSession = class {
|
|
|
76141
76393
|
break;
|
|
76142
76394
|
}
|
|
76143
76395
|
}
|
|
76144
|
-
async handleExtensionUiRequest(ev2) {
|
|
76145
|
-
const id = stringProp(ev2, "id");
|
|
76146
|
-
const method = stringProp(ev2, "method");
|
|
76147
|
-
if (!id) {
|
|
76148
|
-
return;
|
|
76149
|
-
}
|
|
76150
|
-
if (method === "select") {
|
|
76151
|
-
await this.handleExtensionSelect(ev2, id);
|
|
76152
|
-
return;
|
|
76153
|
-
}
|
|
76154
|
-
if (method === "confirm") {
|
|
76155
|
-
await this.handleExtensionConfirm(ev2, id);
|
|
76156
|
-
return;
|
|
76157
|
-
}
|
|
76158
|
-
if (method === "input" || method === "editor") {
|
|
76159
|
-
this.emit({
|
|
76160
|
-
sessionUpdate: "agent_message_chunk",
|
|
76161
|
-
content: {
|
|
76162
|
-
type: "text",
|
|
76163
|
-
text: `Pi ${method} UI request is not supported in ACP yet; cancelling it.`
|
|
76164
|
-
}
|
|
76165
|
-
});
|
|
76166
|
-
await this.proc.sendExtensionUiResponse({ id, cancelled: true });
|
|
76167
|
-
return;
|
|
76168
|
-
}
|
|
76169
|
-
if (method === "notify") {
|
|
76170
|
-
this.emit({
|
|
76171
|
-
sessionUpdate: "agent_message_chunk",
|
|
76172
|
-
content: { type: "text", text: stringProp(ev2, "message") ?? "Pi notification" },
|
|
76173
|
-
_meta: { piAcp: { notify: { level: stringProp(ev2, "notifyType") ?? "info" } } }
|
|
76174
|
-
});
|
|
76175
|
-
await this.proc.sendExtensionUiResponse({ id, cancelled: true });
|
|
76176
|
-
return;
|
|
76177
|
-
}
|
|
76178
|
-
await this.proc.sendExtensionUiResponse({ id, cancelled: true });
|
|
76179
|
-
}
|
|
76180
|
-
async handleExtensionSelect(ev2, id) {
|
|
76181
|
-
const rawOptions = ev2.options;
|
|
76182
|
-
const options = Array.isArray(rawOptions) ? rawOptions.map((option) => String(option)) : [];
|
|
76183
|
-
if (!options.length) {
|
|
76184
|
-
await this.proc.sendExtensionUiResponse({ id, cancelled: true });
|
|
76185
|
-
return;
|
|
76186
|
-
}
|
|
76187
|
-
const permissionOptions = options.map((name2, index3) => ({
|
|
76188
|
-
optionId: `${CHOICE_OPTION_PREFIX}${index3}`,
|
|
76189
|
-
name: name2,
|
|
76190
|
-
kind: "allow_once"
|
|
76191
|
-
}));
|
|
76192
|
-
const selected = await this.requestExtensionPermission(id, ev2, permissionOptions);
|
|
76193
|
-
if (selected === null) {
|
|
76194
|
-
return;
|
|
76195
|
-
}
|
|
76196
|
-
const selectedOptionId = selected.outcome.outcome === "selected" ? selected.outcome.optionId : null;
|
|
76197
|
-
const index2 = selectedOptionId === null ? null : optionIndex(selectedOptionId);
|
|
76198
|
-
const value = index2 === null ? null : options.at(index2) ?? null;
|
|
76199
|
-
await this.proc.sendExtensionUiResponse(value === null ? { id, cancelled: true } : { id, value });
|
|
76200
|
-
}
|
|
76201
|
-
async handleExtensionConfirm(ev2, id) {
|
|
76202
|
-
const selected = await this.requestExtensionPermission(id, ev2, CONFIRM_PERMISSION_OPTIONS);
|
|
76203
|
-
if (selected === null) {
|
|
76204
|
-
return;
|
|
76205
|
-
}
|
|
76206
|
-
if (selected.outcome.outcome === "cancelled") {
|
|
76207
|
-
await this.proc.sendExtensionUiResponse({ id, cancelled: true });
|
|
76208
|
-
return;
|
|
76209
|
-
}
|
|
76210
|
-
await this.proc.sendExtensionUiResponse({ id, confirmed: selected.outcome.optionId === "yes" });
|
|
76211
|
-
}
|
|
76212
|
-
async requestExtensionPermission(id, ev2, options) {
|
|
76213
|
-
try {
|
|
76214
|
-
return await this.conn.requestPermission({
|
|
76215
|
-
sessionId: this.sessionId,
|
|
76216
|
-
toolCall: extensionUiToolCall(id, ev2),
|
|
76217
|
-
options
|
|
76218
|
-
});
|
|
76219
|
-
} catch {
|
|
76220
|
-
await this.proc.sendExtensionUiResponse({ id, cancelled: true });
|
|
76221
|
-
return null;
|
|
76222
|
-
}
|
|
76223
|
-
}
|
|
76224
76396
|
};
|
|
76225
|
-
function extensionUiToolCall(id, ev2) {
|
|
76226
|
-
const method = stringProp(ev2, "method") ?? "ui";
|
|
76227
|
-
const title2 = stringProp(ev2, "title") ?? `Pi ${method}`;
|
|
76228
|
-
const rawInput = { method };
|
|
76229
|
-
for (const key of EXTENSION_UI_RAW_INPUT_KEYS) {
|
|
76230
|
-
if (Object.hasOwn(ev2, key)) {
|
|
76231
|
-
rawInput[key] = ev2[key];
|
|
76232
|
-
}
|
|
76233
|
-
}
|
|
76234
|
-
return {
|
|
76235
|
-
toolCallId: `pi-ui-${id}`,
|
|
76236
|
-
title: title2,
|
|
76237
|
-
kind: "other",
|
|
76238
|
-
status: "pending",
|
|
76239
|
-
rawInput
|
|
76240
|
-
};
|
|
76241
|
-
}
|
|
76242
76397
|
function stringProp(source, key) {
|
|
76243
76398
|
const value = source[key];
|
|
76244
76399
|
return typeof value === "string" ? value : null;
|
|
76245
76400
|
}
|
|
76246
|
-
function optionIndex(optionId) {
|
|
76247
|
-
if (!optionId.startsWith(CHOICE_OPTION_PREFIX)) {
|
|
76248
|
-
return null;
|
|
76249
|
-
}
|
|
76250
|
-
const rawIndex = optionId.slice(CHOICE_OPTION_PREFIX.length);
|
|
76251
|
-
if (!rawIndex) {
|
|
76252
|
-
return null;
|
|
76253
|
-
}
|
|
76254
|
-
const index2 = Number(rawIndex);
|
|
76255
|
-
return Number.isSafeInteger(index2) && index2 >= 0 && String(index2) === rawIndex ? index2 : null;
|
|
76256
|
-
}
|
|
76257
76401
|
function toToolKind(toolName) {
|
|
76258
76402
|
switch (toolName) {
|
|
76259
76403
|
case "read":
|
|
@@ -76480,7 +76624,7 @@ var PiAcpAgent = class {
|
|
|
76480
76624
|
const restorePromise = (async () => {
|
|
76481
76625
|
const stored = this.findStoredSession(sessionId);
|
|
76482
76626
|
if (!stored) {
|
|
76483
|
-
throw
|
|
76627
|
+
throw RequestError7.invalidParams(`Unknown sessionId: ${sessionId}`);
|
|
76484
76628
|
}
|
|
76485
76629
|
const cwd = opts?.cwd ?? stored.cwd;
|
|
76486
76630
|
let proc;
|
|
@@ -76493,7 +76637,7 @@ var PiAcpAgent = class {
|
|
|
76493
76637
|
});
|
|
76494
76638
|
} catch (e) {
|
|
76495
76639
|
if (e?.name === "PiRpcSpawnError") {
|
|
76496
|
-
throw
|
|
76640
|
+
throw RequestError7.internalError({ code: e?.code }, String(e?.message ?? e));
|
|
76497
76641
|
}
|
|
76498
76642
|
throw e;
|
|
76499
76643
|
}
|
|
@@ -76553,7 +76697,7 @@ var PiAcpAgent = class {
|
|
|
76553
76697
|
}
|
|
76554
76698
|
async newSession(params) {
|
|
76555
76699
|
if (!isAbsolute11(params.cwd)) {
|
|
76556
|
-
throw
|
|
76700
|
+
throw RequestError7.invalidParams(`cwd must be an absolute path: ${params.cwd}`);
|
|
76557
76701
|
}
|
|
76558
76702
|
this.lastSessionCwd = params.cwd;
|
|
76559
76703
|
const fileCommands = loadSlashCommands(params.cwd, this.environment);
|
|
@@ -76592,16 +76736,16 @@ var PiAcpAgent = class {
|
|
|
76592
76736
|
}
|
|
76593
76737
|
if (availableModelsErr) {
|
|
76594
76738
|
this.cleanupFailedNewSession(session.sessionId, state);
|
|
76595
|
-
throw
|
|
76739
|
+
throw RequestError7.internalError({}, String(availableModelsErr?.message ?? availableModelsErr));
|
|
76596
76740
|
}
|
|
76597
76741
|
const rawModelsCount = Array.isArray(availableModels?.models) ? availableModels.models.length : 0;
|
|
76598
76742
|
if (rawModelsCount === 0) {
|
|
76599
76743
|
this.cleanupFailedNewSession(session.sessionId, state);
|
|
76600
|
-
throw
|
|
76744
|
+
throw RequestError7.authRequired({ authMethods: getAuthMethods() }, "Configure an API key or log in with an OAuth provider.");
|
|
76601
76745
|
}
|
|
76602
76746
|
if (stateErr && maybeAuthRequiredError(stateErr)) {
|
|
76603
76747
|
this.cleanupFailedNewSession(session.sessionId, state);
|
|
76604
|
-
throw
|
|
76748
|
+
throw RequestError7.authRequired({ authMethods: getAuthMethods() }, "Configure an API key or log in with an OAuth provider.");
|
|
76605
76749
|
}
|
|
76606
76750
|
let configuration;
|
|
76607
76751
|
try {
|
|
@@ -76611,7 +76755,7 @@ var PiAcpAgent = class {
|
|
|
76611
76755
|
configuration = await getSessionConfiguration(session.proc, { state, availableModels });
|
|
76612
76756
|
} catch (err) {
|
|
76613
76757
|
this.cleanupFailedNewSession(session.sessionId, state);
|
|
76614
|
-
throw maybeAuthRequiredError(err) ??
|
|
76758
|
+
throw maybeAuthRequiredError(err) ?? RequestError7.internalError({}, String(err?.message ?? err));
|
|
76615
76759
|
}
|
|
76616
76760
|
const { configOptions, models, modes } = configuration;
|
|
76617
76761
|
const quietStartup = getQuietStartup(params.cwd, this.environment);
|
|
@@ -76696,9 +76840,7 @@ var PiAcpAgent = class {
|
|
|
76696
76840
|
}
|
|
76697
76841
|
});
|
|
76698
76842
|
try {
|
|
76699
|
-
const res = await session.
|
|
76700
|
-
timeoutMs: COMPACT_TIMEOUT_MILLISECONDS2
|
|
76701
|
-
});
|
|
76843
|
+
const res = await session.compact(customInstructions, COMPACT_TIMEOUT_MILLISECONDS2);
|
|
76702
76844
|
const r = res && typeof res === "object" ? res : null;
|
|
76703
76845
|
const summary = typeof r?.summary === "string" ? r.summary : null;
|
|
76704
76846
|
if (summary !== null && summary.length > 0) {
|
|
@@ -77111,7 +77253,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
77111
77253
|
signal.throwIfAborted();
|
|
77112
77254
|
const parsed = steerRequestSchema.safeParse(params);
|
|
77113
77255
|
if (!parsed.success) {
|
|
77114
|
-
throw
|
|
77256
|
+
throw RequestError7.invalidParams("Invalid steering request");
|
|
77115
77257
|
}
|
|
77116
77258
|
const session = this.sessions.maybeGet(parsed.data.sessionId);
|
|
77117
77259
|
if (session === void 0) {
|
|
@@ -77152,11 +77294,11 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
77152
77294
|
}
|
|
77153
77295
|
async forkSession(params) {
|
|
77154
77296
|
if (!isAbsolute11(params.cwd)) {
|
|
77155
|
-
throw
|
|
77297
|
+
throw RequestError7.invalidParams(`cwd must be an absolute path: ${params.cwd}`);
|
|
77156
77298
|
}
|
|
77157
77299
|
const source = this.findStoredSession(params.sessionId);
|
|
77158
77300
|
if (!source) {
|
|
77159
|
-
throw
|
|
77301
|
+
throw RequestError7.invalidParams(`Unknown sessionId: ${params.sessionId}`);
|
|
77160
77302
|
}
|
|
77161
77303
|
this.lastSessionCwd = params.cwd;
|
|
77162
77304
|
const fileCommands = loadSlashCommands(params.cwd, this.environment);
|
|
@@ -77218,13 +77360,13 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
77218
77360
|
}
|
|
77219
77361
|
async loadSession(params) {
|
|
77220
77362
|
if (!isAbsolute11(params.cwd)) {
|
|
77221
|
-
throw
|
|
77363
|
+
throw RequestError7.invalidParams(`cwd must be an absolute path: ${params.cwd}`);
|
|
77222
77364
|
}
|
|
77223
77365
|
this.sessions.close(params.sessionId);
|
|
77224
77366
|
this.lastSessionCwd = params.cwd;
|
|
77225
77367
|
const stored = this.findStoredSession(params.sessionId);
|
|
77226
77368
|
if (!stored) {
|
|
77227
|
-
throw
|
|
77369
|
+
throw RequestError7.invalidParams(`Unknown sessionId: ${params.sessionId}`);
|
|
77228
77370
|
}
|
|
77229
77371
|
const enableSkillCommands = getEnableSkillCommands(params.cwd, this.environment);
|
|
77230
77372
|
const session = await this.restoreSession(params.sessionId, {
|
|
@@ -77399,7 +77541,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
77399
77541
|
const session = await this.restoreSession(params.sessionId);
|
|
77400
77542
|
const mode = params.modeId;
|
|
77401
77543
|
if (typeof mode !== "string" || mode.length === 0) {
|
|
77402
|
-
throw
|
|
77544
|
+
throw RequestError7.invalidParams("Expected nonempty string modeId");
|
|
77403
77545
|
}
|
|
77404
77546
|
await session.proc.setThinkingLevel(mode);
|
|
77405
77547
|
await emitConfigOptionsUpdate(this.conn, session.sessionId, session.proc);
|
|
@@ -77410,18 +77552,18 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
77410
77552
|
const configId = String(params.configId);
|
|
77411
77553
|
let modelChanged = false;
|
|
77412
77554
|
if (typeof params.value !== "string") {
|
|
77413
|
-
throw
|
|
77555
|
+
throw RequestError7.invalidParams(`Expected string value for config option: ${configId}`);
|
|
77414
77556
|
}
|
|
77415
77557
|
if (configId === MODEL_CONFIG_ID2) {
|
|
77416
77558
|
await setSessionModel(session.proc, params.value);
|
|
77417
77559
|
modelChanged = true;
|
|
77418
77560
|
} else if (configId === THOUGHT_LEVEL_CONFIG_ID) {
|
|
77419
77561
|
if (params.value.length === 0) {
|
|
77420
|
-
throw
|
|
77562
|
+
throw RequestError7.invalidParams("Expected nonempty thinking level");
|
|
77421
77563
|
}
|
|
77422
77564
|
await session.proc.setThinkingLevel(params.value);
|
|
77423
77565
|
} else {
|
|
77424
|
-
throw
|
|
77566
|
+
throw RequestError7.invalidParams(`Unknown config option: ${configId}`);
|
|
77425
77567
|
}
|
|
77426
77568
|
const configOptions = await emitConfigOptionsUpdate(this.conn, session.sessionId, session.proc);
|
|
77427
77569
|
if (modelChanged) {
|
|
@@ -77577,7 +77719,7 @@ async function setSessionModel(proc, requestedModelId) {
|
|
|
77577
77719
|
}
|
|
77578
77720
|
}
|
|
77579
77721
|
if (!provider || !modelId) {
|
|
77580
|
-
throw
|
|
77722
|
+
throw RequestError7.invalidParams(`Unknown modelId: ${requestedModelId}`);
|
|
77581
77723
|
}
|
|
77582
77724
|
await proc.setModel(provider, modelId);
|
|
77583
77725
|
}
|
|
@@ -77759,6 +77901,7 @@ function buildStartupInfo(opts) {
|
|
|
77759
77901
|
import { methods as methods4 } from "@agentclientprotocol/sdk";
|
|
77760
77902
|
function createPiAcpClient(connection, onSessionUpdate) {
|
|
77761
77903
|
return {
|
|
77904
|
+
requestElicitation: async (request, signal) => await connection.client.request(methods4.client.elicitation.create, request, { cancellationSignal: signal }),
|
|
77762
77905
|
requestPermission: async (request) => await connection.client.request(methods4.client.session.requestPermission, request),
|
|
77763
77906
|
sessionUpdate: onSessionUpdate
|
|
77764
77907
|
};
|
|
@@ -78235,7 +78378,7 @@ import {
|
|
|
78235
78378
|
methods as methods8,
|
|
78236
78379
|
ndJsonStream as ndJsonStream2,
|
|
78237
78380
|
PROTOCOL_VERSION as PROTOCOL_VERSION2,
|
|
78238
|
-
RequestError as
|
|
78381
|
+
RequestError as RequestError8
|
|
78239
78382
|
} from "@agentclientprotocol/sdk";
|
|
78240
78383
|
|
|
78241
78384
|
// src/acp/connection/create-client.ts
|
|
@@ -78409,7 +78552,7 @@ async function probeAcpReadiness(specification, agent, environment, defaultWorks
|
|
|
78409
78552
|
if (error62 instanceof AgentProbeError) {
|
|
78410
78553
|
throw error62;
|
|
78411
78554
|
}
|
|
78412
|
-
if (error62 instanceof
|
|
78555
|
+
if (error62 instanceof RequestError8 && error62.code === -32e3 && specification.authenticationCommand().length > 0) {
|
|
78413
78556
|
throw new AgentProbeError("authentication_required", "Agent authentication is required", {
|
|
78414
78557
|
cause: error62
|
|
78415
78558
|
});
|
|
@@ -78485,7 +78628,7 @@ async function probeAcpReadiness(specification, agent, environment, defaultWorks
|
|
|
78485
78628
|
if (error62 instanceof AgentProbeError) {
|
|
78486
78629
|
throw error62;
|
|
78487
78630
|
}
|
|
78488
|
-
if (error62 instanceof
|
|
78631
|
+
if (error62 instanceof RequestError8 && error62.code === -32e3 && specification.authenticationCommand().length > 0) {
|
|
78489
78632
|
throw new AgentProbeError("authentication_required", "Agent authentication is required", { cause: error62 });
|
|
78490
78633
|
}
|
|
78491
78634
|
throw new AgentProbeError("acp_incompatible", "ACP adapter initialization failed", { cause: error62 });
|
|
@@ -88653,7 +88796,7 @@ function buildPromptContent(options, capabilities) {
|
|
|
88653
88796
|
|
|
88654
88797
|
// src/acp/connection/agent-connection.ts
|
|
88655
88798
|
import { spawn as spawn9 } from "node:child_process";
|
|
88656
|
-
import { ndJsonStream as ndJsonStream3, RequestError as
|
|
88799
|
+
import { ndJsonStream as ndJsonStream3, RequestError as RequestError9 } from "@agentclientprotocol/sdk";
|
|
88657
88800
|
function requestErrorMessage(error62) {
|
|
88658
88801
|
const fallback = truncate2(error62.message, 500);
|
|
88659
88802
|
if (error62.message !== "Internal error" || !isRecord3(error62.data)) {
|
|
@@ -88858,14 +89001,14 @@ var AgentConnection = class {
|
|
|
88858
89001
|
]);
|
|
88859
89002
|
} catch (error62) {
|
|
88860
89003
|
signal.throwIfAborted();
|
|
88861
|
-
if (error62 instanceof
|
|
89004
|
+
if (error62 instanceof RequestError9 && error62.code === -32e3) {
|
|
88862
89005
|
throw new AcpExecutionError(
|
|
88863
89006
|
"Agent authentication is required",
|
|
88864
89007
|
{ cause: error62 },
|
|
88865
89008
|
"authentication_required"
|
|
88866
89009
|
);
|
|
88867
89010
|
}
|
|
88868
|
-
if (error62 instanceof
|
|
89011
|
+
if (error62 instanceof RequestError9) {
|
|
88869
89012
|
throw new AcpExecutionError(requestErrorMessage(error62), { cause: error62 }, "acp_agent_error");
|
|
88870
89013
|
}
|
|
88871
89014
|
throw error62;
|
|
@@ -89319,6 +89462,7 @@ function normalizeElicitationFields(requestedSchema) {
|
|
|
89319
89462
|
const options = normalizeElicitationOptions(property);
|
|
89320
89463
|
const normalizedType = type === "string" && options.length > 0 ? "select" : type;
|
|
89321
89464
|
const defaultValue = property["default"];
|
|
89465
|
+
const metadata = property["_meta"];
|
|
89322
89466
|
normalized.push({
|
|
89323
89467
|
defaultBooleanValue: typeof defaultValue === "boolean" ? defaultValue : false,
|
|
89324
89468
|
defaultNumberValue: typeof defaultValue === "number" && Number.isFinite(defaultValue) ? defaultValue : 0,
|
|
@@ -89330,6 +89474,7 @@ function normalizeElicitationFields(requestedSchema) {
|
|
|
89330
89474
|
maximumLength: numericString(property["maxLength"] ?? property["maxItems"]),
|
|
89331
89475
|
minimum: numericString(property["minimum"]),
|
|
89332
89476
|
minimumLength: numericString(property["minLength"] ?? property["minItems"]),
|
|
89477
|
+
...normalizedType === "string" && isRecord3(metadata) && metadata["io.mobius/multiline"] === true ? { multiline: true } : {},
|
|
89333
89478
|
name: truncate2(name2, 128),
|
|
89334
89479
|
options,
|
|
89335
89480
|
pattern: truncate2(readString2(property["pattern"]), 500),
|