@lobehub/cli 0.0.216 → 0.0.218
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/index.js +1159 -1208
- package/man/man1/lh.1 +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -50500,285 +50500,428 @@ const classifyCliMessageError = ({ agentType, command, detail: rawDetail }) => {
|
|
|
50500
50500
|
};
|
|
50501
50501
|
|
|
50502
50502
|
//#endregion
|
|
50503
|
-
//#region ../../packages/heterogeneous-agents/src/adapters/
|
|
50503
|
+
//#region ../../packages/heterogeneous-agents/src/adapters/acpCommon.ts
|
|
50504
50504
|
init_object$1();
|
|
50505
|
-
const IDENTIFIER = "antigravity";
|
|
50506
|
-
const tokenCount = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : 0;
|
|
50507
|
-
const extractUsage = (raw) => {
|
|
50508
|
-
if (!isRecord$8(raw)) return;
|
|
50509
|
-
const inputCacheMissTokens = tokenCount(raw.input_tokens);
|
|
50510
|
-
const inputCachedTokens = tokenCount(raw.cache_read_tokens);
|
|
50511
|
-
const totalOutputTokens = tokenCount(raw.output_tokens);
|
|
50512
|
-
const outputReasoningTokens = Math.min(tokenCount(raw.thinking_tokens), totalOutputTokens);
|
|
50513
|
-
const totalInputTokens = inputCacheMissTokens + inputCachedTokens;
|
|
50514
|
-
return {
|
|
50515
|
-
inputCachedTokens,
|
|
50516
|
-
inputCacheMissTokens,
|
|
50517
|
-
outputReasoningTokens,
|
|
50518
|
-
outputTextTokens: totalOutputTokens - outputReasoningTokens,
|
|
50519
|
-
totalInputTokens,
|
|
50520
|
-
totalOutputTokens,
|
|
50521
|
-
totalTokens: totalInputTokens + totalOutputTokens
|
|
50522
|
-
};
|
|
50523
|
-
};
|
|
50524
|
-
const stringifyOutput = (value) => typeof value === "string" ? value : value === void 0 ? "" : JSON.stringify(value);
|
|
50525
50505
|
/**
|
|
50526
|
-
*
|
|
50527
|
-
*
|
|
50528
|
-
*
|
|
50506
|
+
* Shared stream/step lifecycle for ACP `sessionUpdate` adapters.
|
|
50507
|
+
*
|
|
50508
|
+
* ACP does not frame model rounds explicitly, so adapters detect step
|
|
50509
|
+
* boundaries themselves (tool completion, response completion, …) and set
|
|
50510
|
+
* {@link pendingStepBoundary}. The next `ensureStream(true)` call consumes the
|
|
50511
|
+
* boundary: it closes the open stream, bumps `stepIndex`, resets the per-step
|
|
50512
|
+
* tool list, and re-opens a stream whose `stream_start` payload comes from the
|
|
50513
|
+
* adapter-provided builder (which appends `newStep` for steps > 0).
|
|
50529
50514
|
*/
|
|
50530
|
-
var
|
|
50531
|
-
|
|
50532
|
-
|
|
50533
|
-
flushed = false;
|
|
50534
|
-
hasResponseText = false;
|
|
50535
|
-
latestTurnCompleted = false;
|
|
50536
|
-
model;
|
|
50537
|
-
pendingTools = /* @__PURE__ */ new Map();
|
|
50538
|
-
resultReceived = false;
|
|
50539
|
-
completionValidated = false;
|
|
50540
|
-
responseStep;
|
|
50541
|
-
runtimeEndStrategy;
|
|
50542
|
-
seenInitialUserInput = false;
|
|
50543
|
-
seenUserInputSteps = /* @__PURE__ */ new Set();
|
|
50515
|
+
var AcpStreamLifecycle = class {
|
|
50516
|
+
/** Set by the adapter when the next model round must open a new step. */
|
|
50517
|
+
pendingStepBoundary = false;
|
|
50544
50518
|
stepIndex = 0;
|
|
50519
|
+
/** Tool calls announced within the current step (reset at each boundary). */
|
|
50545
50520
|
stepTools = [];
|
|
50546
50521
|
streamOpen = false;
|
|
50547
|
-
|
|
50548
|
-
|
|
50549
|
-
usageByStep = /* @__PURE__ */ new Map();
|
|
50550
|
-
constructor(options = {}) {
|
|
50551
|
-
this.runtimeEndStrategy = options.runtimeEndStrategy ?? "on-result";
|
|
50552
|
-
this.takeNextSteerUuid = options.takeNextSteerUuid;
|
|
50522
|
+
constructor(buildStreamStartData) {
|
|
50523
|
+
this.buildStreamStartData = buildStreamStartData;
|
|
50553
50524
|
}
|
|
50554
|
-
|
|
50555
|
-
|
|
50556
|
-
|
|
50557
|
-
this.
|
|
50558
|
-
|
|
50559
|
-
|
|
50560
|
-
|
|
50561
|
-
|
|
50562
|
-
|
|
50563
|
-
if (raw.event !== "step_update" || !isRecord$8(raw.step_update)) return [];
|
|
50564
|
-
const step = raw.step_update;
|
|
50565
|
-
const index = step.step_index;
|
|
50566
|
-
if (typeof index !== "number" || !Number.isSafeInteger(index) || index < 0) return [];
|
|
50567
|
-
const conversationId = pickString$1(step.conversation_id);
|
|
50568
|
-
if (this.sessionId && conversationId && conversationId !== this.sessionId) return [];
|
|
50569
|
-
this.sessionId ??= conversationId;
|
|
50570
|
-
if (this.completedSteps.has(index)) return [];
|
|
50571
|
-
this.latestTurnCompleted = false;
|
|
50525
|
+
event(type, data) {
|
|
50526
|
+
return {
|
|
50527
|
+
data,
|
|
50528
|
+
stepIndex: this.stepIndex,
|
|
50529
|
+
timestamp: Date.now(),
|
|
50530
|
+
type
|
|
50531
|
+
};
|
|
50532
|
+
}
|
|
50533
|
+
ensureStream(consumeStepBoundary) {
|
|
50572
50534
|
const events = [];
|
|
50573
|
-
if (
|
|
50574
|
-
|
|
50575
|
-
|
|
50576
|
-
|
|
50577
|
-
|
|
50578
|
-
const uuid = this.takeNextSteerUuid?.();
|
|
50579
|
-
if (uuid) {
|
|
50580
|
-
events.push(...this.closeStream());
|
|
50581
|
-
events.push(this.event("step_complete", {
|
|
50582
|
-
phase: "user_message",
|
|
50583
|
-
uuid
|
|
50584
|
-
}));
|
|
50585
|
-
}
|
|
50586
|
-
}
|
|
50587
|
-
}
|
|
50588
|
-
} else if (step.step_type === "agent_response") {
|
|
50589
|
-
if (this.toolSinceResponse || this.responseStep !== void 0 && this.responseStep !== index) {
|
|
50590
|
-
events.push(...this.closeStream());
|
|
50591
|
-
this.stepIndex += 1;
|
|
50592
|
-
this.stepTools = [];
|
|
50593
|
-
this.hasResponseText = false;
|
|
50594
|
-
}
|
|
50595
|
-
events.push(...this.openStream());
|
|
50596
|
-
this.toolSinceResponse = false;
|
|
50597
|
-
this.responseStep = index;
|
|
50598
|
-
if (typeof step.text_delta === "string" && step.text_delta) {
|
|
50599
|
-
this.hasResponseText = true;
|
|
50600
|
-
events.push(this.event("stream_chunk", {
|
|
50601
|
-
chunkType: "text",
|
|
50602
|
-
content: step.text_delta
|
|
50603
|
-
}));
|
|
50604
|
-
}
|
|
50605
|
-
} else if (step.step_type === "tool" || isRecord$8(step.subagent_info)) events.push(...this.handleTool(index, step));
|
|
50606
|
-
if (step.state === "DONE") {
|
|
50607
|
-
this.completedSteps.add(index);
|
|
50608
|
-
const usage = extractUsage(step.usage);
|
|
50609
|
-
if (usage) this.usageByStep.set(index, usage);
|
|
50535
|
+
if (consumeStepBoundary && this.pendingStepBoundary) {
|
|
50536
|
+
events.push(...this.closeStream());
|
|
50537
|
+
this.pendingStepBoundary = false;
|
|
50538
|
+
this.stepIndex += 1;
|
|
50539
|
+
this.stepTools = [];
|
|
50610
50540
|
}
|
|
50541
|
+
if (this.streamOpen) return events;
|
|
50542
|
+
this.streamOpen = true;
|
|
50543
|
+
events.push(this.event("stream_start", this.buildStreamStartData(this.stepIndex)));
|
|
50611
50544
|
return events;
|
|
50612
50545
|
}
|
|
50613
|
-
|
|
50614
|
-
if (this.
|
|
50615
|
-
this.
|
|
50616
|
-
return [
|
|
50546
|
+
closeStream(data = {}) {
|
|
50547
|
+
if (!this.streamOpen) return [];
|
|
50548
|
+
this.streamOpen = false;
|
|
50549
|
+
return [this.event("stream_end", data)];
|
|
50617
50550
|
}
|
|
50618
|
-
|
|
50619
|
-
|
|
50620
|
-
|
|
50621
|
-
|
|
50622
|
-
|
|
50623
|
-
|
|
50624
|
-
|
|
50625
|
-
|
|
50551
|
+
};
|
|
50552
|
+
/**
|
|
50553
|
+
* Read the text out of one ACP ContentBlock-ish value: plain strings, `text`
|
|
50554
|
+
* blocks, nested `content` wrappers, and the `diff` / `output` string fields
|
|
50555
|
+
* some agents put on tool-call content.
|
|
50556
|
+
*/
|
|
50557
|
+
const acpContentBlockText = (value) => {
|
|
50558
|
+
if (typeof value === "string") return value;
|
|
50559
|
+
if (!isRecord$8(value)) return "";
|
|
50560
|
+
if (value.type === "text" && typeof value.text === "string") return value.text;
|
|
50561
|
+
if (typeof value.content === "string") return value.content;
|
|
50562
|
+
if (isRecord$8(value.content)) return acpContentBlockText(value.content);
|
|
50563
|
+
if (typeof value.diff === "string") return value.diff;
|
|
50564
|
+
if (typeof value.output === "string") return value.output;
|
|
50565
|
+
return "";
|
|
50566
|
+
};
|
|
50567
|
+
/**
|
|
50568
|
+
* ACP extension marker for replayed history: `_meta.isReplay` on either the
|
|
50569
|
+
* notification `params` or the nested `update`.
|
|
50570
|
+
*/
|
|
50571
|
+
const isAcpReplayMessage = (raw) => {
|
|
50572
|
+
const params = toRecord$1(toRecord$1(raw)?.params);
|
|
50573
|
+
const update = toRecord$1(params?.update);
|
|
50574
|
+
return toRecord$1(params?._meta)?.isReplay === true || toRecord$1(update?._meta)?.isReplay === true;
|
|
50575
|
+
};
|
|
50576
|
+
/** ACP extension dedup marker: `_meta.eventId` on the notification `params`. */
|
|
50577
|
+
const acpEventIdOf = (raw) => {
|
|
50578
|
+
const meta = toRecord$1(toRecord$1(toRecord$1(raw)?.params)?._meta);
|
|
50579
|
+
return typeof meta?.eventId === "string" ? meta.eventId : void 0;
|
|
50580
|
+
};
|
|
50581
|
+
|
|
50582
|
+
//#endregion
|
|
50583
|
+
//#region ../../packages/heterogeneous-agents/src/adapters/traeAcp.ts
|
|
50584
|
+
init_object$1();
|
|
50585
|
+
const DEFAULT_PROVIDER = "trae";
|
|
50586
|
+
const toFiniteNumber$3 = (value) => {
|
|
50587
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
50588
|
+
if (typeof value === "string") {
|
|
50589
|
+
const parsed = Number(value);
|
|
50590
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
50626
50591
|
}
|
|
50627
|
-
|
|
50628
|
-
|
|
50629
|
-
|
|
50630
|
-
|
|
50631
|
-
|
|
50632
|
-
|
|
50633
|
-
|
|
50634
|
-
|
|
50635
|
-
})];
|
|
50592
|
+
};
|
|
50593
|
+
const stringify$1 = (value) => {
|
|
50594
|
+
if (typeof value === "string") return value;
|
|
50595
|
+
if (value === void 0) return "";
|
|
50596
|
+
try {
|
|
50597
|
+
return JSON.stringify(value);
|
|
50598
|
+
} catch {
|
|
50599
|
+
return String(value);
|
|
50636
50600
|
}
|
|
50637
|
-
|
|
50638
|
-
|
|
50639
|
-
|
|
50640
|
-
|
|
50641
|
-
|
|
50642
|
-
|
|
50643
|
-
|
|
50644
|
-
|
|
50645
|
-
|
|
50646
|
-
totalOutputTokens: total.totalOutputTokens + next.totalOutputTokens,
|
|
50647
|
-
totalTokens: total.totalTokens + next.totalTokens
|
|
50648
|
-
}));
|
|
50649
|
-
events.push(this.event("step_complete", {
|
|
50650
|
-
model: this.model,
|
|
50651
|
-
phase: "turn_metadata",
|
|
50652
|
-
provider: IDENTIFIER,
|
|
50653
|
-
usage
|
|
50654
|
-
}));
|
|
50655
|
-
this.usageByStep.clear();
|
|
50601
|
+
};
|
|
50602
|
+
const toolContent = (content, fallback) => {
|
|
50603
|
+
if (!Array.isArray(content)) return stringify$1(content ?? fallback);
|
|
50604
|
+
return content.map((value) => {
|
|
50605
|
+
const block = value;
|
|
50606
|
+
if (block?.type === "content") {
|
|
50607
|
+
const nestedContent = block.content;
|
|
50608
|
+
if (nestedContent?.type === "text") return stringify$1(nestedContent.text);
|
|
50609
|
+
return stringify$1(block.content);
|
|
50656
50610
|
}
|
|
50657
|
-
if (
|
|
50658
|
-
|
|
50659
|
-
|
|
50611
|
+
if (block?.type === "diff") return [block.path, block.newText].filter((value) => typeof value === "string").join("\n");
|
|
50612
|
+
if (block?.type === "terminal") return `[Terminal: ${stringify$1(block.terminalId)}]`;
|
|
50613
|
+
return stringify$1(block);
|
|
50614
|
+
}).filter(Boolean).join("\n") || stringify$1(fallback);
|
|
50615
|
+
};
|
|
50616
|
+
/**
|
|
50617
|
+
* Maps the standard ACP `sessionUpdate` vocabulary into the shared event
|
|
50618
|
+
* contract. TRAE is the default provider; other standard-ACP agents reuse it
|
|
50619
|
+
* via {@link AcpSessionAdapterOptions}.
|
|
50620
|
+
*/
|
|
50621
|
+
var TraeAcpAdapter = class {
|
|
50622
|
+
sessionId;
|
|
50623
|
+
eventPrefix;
|
|
50624
|
+
provider;
|
|
50625
|
+
completedTools = /* @__PURE__ */ new Set();
|
|
50626
|
+
lastCostUsd;
|
|
50627
|
+
lastUsage;
|
|
50628
|
+
model;
|
|
50629
|
+
pendingTools = /* @__PURE__ */ new Set();
|
|
50630
|
+
snapshotSeq = /* @__PURE__ */ new Map();
|
|
50631
|
+
stream = new AcpStreamLifecycle((stepIndex) => ({
|
|
50632
|
+
...this.model ? { model: this.model } : {},
|
|
50633
|
+
...stepIndex > 0 ? { newStep: true } : {},
|
|
50634
|
+
provider: this.provider,
|
|
50635
|
+
sessionId: this.sessionId
|
|
50636
|
+
}));
|
|
50637
|
+
terminal = false;
|
|
50638
|
+
toolResultStateById = /* @__PURE__ */ new Map();
|
|
50639
|
+
constructor(options = {}) {
|
|
50640
|
+
this.provider = options.provider ?? DEFAULT_PROVIDER;
|
|
50641
|
+
this.eventPrefix = options.eventPrefix ?? this.provider;
|
|
50642
|
+
}
|
|
50643
|
+
adapt(value) {
|
|
50644
|
+
if (!value || typeof value !== "object" || this.terminal) return [];
|
|
50645
|
+
const raw = value;
|
|
50646
|
+
if (raw.type === "session_configured") {
|
|
50647
|
+
if (typeof raw.model === "string") this.model = raw.model;
|
|
50648
|
+
return [];
|
|
50649
|
+
}
|
|
50650
|
+
if (raw.type === `${this.eventPrefix}_session`) {
|
|
50651
|
+
if (typeof raw.sessionId === "string") this.sessionId = raw.sessionId;
|
|
50652
|
+
if (typeof raw.model === "string") this.model = raw.model;
|
|
50653
|
+
return [];
|
|
50654
|
+
}
|
|
50655
|
+
if (raw.type === `${this.eventPrefix}_prompt_completed`) {
|
|
50656
|
+
const usage = this.toUsageData(raw.usage) ?? this.lastUsage;
|
|
50657
|
+
const costUsd = this.toCostUsd(raw.cost) ?? this.lastCostUsd;
|
|
50658
|
+
return this.complete(raw.stopReason, usage, costUsd);
|
|
50659
|
+
}
|
|
50660
|
+
if (raw.type === `${this.eventPrefix}_error`) return this.fail(stringify$1(raw.message) || `${this.provider} ACP failed`);
|
|
50661
|
+
switch (raw.sessionUpdate) {
|
|
50662
|
+
case "usage_update": {
|
|
50663
|
+
const usage = this.extractUsageFromUsageUpdate(raw);
|
|
50664
|
+
if (usage) this.lastUsage = usage;
|
|
50665
|
+
const costUsd = this.toCostUsd(raw.cost);
|
|
50666
|
+
if (costUsd !== void 0) this.lastCostUsd = costUsd;
|
|
50667
|
+
return [];
|
|
50668
|
+
}
|
|
50669
|
+
case "agent_message_chunk": {
|
|
50670
|
+
const text = raw.content?.text;
|
|
50671
|
+
return typeof text === "string" && text ? [...this.stream.ensureStream(true), this.stream.event("stream_chunk", {
|
|
50672
|
+
chunkType: "text",
|
|
50673
|
+
content: text
|
|
50674
|
+
})] : [];
|
|
50675
|
+
}
|
|
50676
|
+
case "agent_thought_chunk": {
|
|
50677
|
+
const reasoning = raw.content?.text;
|
|
50678
|
+
return typeof reasoning === "string" && reasoning ? [...this.stream.ensureStream(true), this.stream.event("stream_chunk", {
|
|
50679
|
+
chunkType: "reasoning",
|
|
50680
|
+
reasoning
|
|
50681
|
+
})] : [];
|
|
50682
|
+
}
|
|
50683
|
+
case "tool_call": return this.startTool(raw);
|
|
50684
|
+
case "tool_call_update": return this.updateTool(raw);
|
|
50685
|
+
default: return [];
|
|
50660
50686
|
}
|
|
50661
|
-
return events;
|
|
50662
50687
|
}
|
|
50663
|
-
|
|
50664
|
-
|
|
50665
|
-
|
|
50666
|
-
|
|
50667
|
-
|
|
50668
|
-
|
|
50669
|
-
|
|
50670
|
-
this.
|
|
50671
|
-
const
|
|
50672
|
-
if (
|
|
50673
|
-
|
|
50674
|
-
|
|
50675
|
-
|
|
50676
|
-
|
|
50677
|
-
|
|
50678
|
-
|
|
50679
|
-
|
|
50680
|
-
|
|
50681
|
-
|
|
50682
|
-
};
|
|
50683
|
-
this.pendingTools.set(index, pending);
|
|
50684
|
-
} else if (info?.parameters !== void 0) pending.payload.arguments = args;
|
|
50685
|
-
if (info?.parameters !== void 0 || step.state === "DONE") events.push(...this.startTool(pending));
|
|
50686
|
-
if (step.state === "DONE") {
|
|
50687
|
-
const error = toRecord$1(info?.error);
|
|
50688
|
-
const content = [stringifyOutput(info?.output ?? subagents), pickString$1(error?.message) ?? stringifyOutput(info?.error)].filter(Boolean).join("\n");
|
|
50689
|
-
events.push(...this.toolResult(pending, content, info?.error != null));
|
|
50690
|
-
this.pendingTools.delete(index);
|
|
50688
|
+
flush() {
|
|
50689
|
+
if (this.terminal) return [];
|
|
50690
|
+
return this.complete("end_turn", this.lastUsage, this.lastCostUsd);
|
|
50691
|
+
}
|
|
50692
|
+
updateTool(raw) {
|
|
50693
|
+
const id = raw.toolCallId;
|
|
50694
|
+
if (typeof id !== "string" || this.completedTools.has(id)) return [];
|
|
50695
|
+
const startEvents = this.pendingTools.has(id) ? [] : this.startTool(raw);
|
|
50696
|
+
const resultState = this.mergeToolResultState(id, raw);
|
|
50697
|
+
if (raw.status === "running" || raw.status === "in_progress" || raw.status === "pending") {
|
|
50698
|
+
const snapshotSeq = (this.snapshotSeq.get(id) ?? 0) + 1;
|
|
50699
|
+
this.snapshotSeq.set(id, snapshotSeq);
|
|
50700
|
+
return [...startEvents, this.stream.event("stream_chunk", {
|
|
50701
|
+
chunkType: "tool_state",
|
|
50702
|
+
pluginState: { ...raw },
|
|
50703
|
+
snapshotMode: "replace",
|
|
50704
|
+
snapshotSeq,
|
|
50705
|
+
toolCallId: id
|
|
50706
|
+
})];
|
|
50691
50707
|
}
|
|
50708
|
+
if (raw.status !== "completed" && raw.status !== "failed") return [];
|
|
50709
|
+
this.completedTools.add(id);
|
|
50710
|
+
this.pendingTools.delete(id);
|
|
50711
|
+
const isSuccess = raw.status === "completed";
|
|
50712
|
+
const result = resultState.latest === "content" ? toolContent(resultState.content, resultState.rawOutput ?? resultState.output) : stringify$1(resultState.latest === "rawOutput" ? resultState.rawOutput : resultState.output);
|
|
50713
|
+
const events = [
|
|
50714
|
+
...startEvents,
|
|
50715
|
+
this.stream.event("tool_result", {
|
|
50716
|
+
content: result,
|
|
50717
|
+
isError: !isSuccess,
|
|
50718
|
+
toolCallId: id
|
|
50719
|
+
}),
|
|
50720
|
+
this.stream.event("tool_end", {
|
|
50721
|
+
isSuccess,
|
|
50722
|
+
toolCallId: id
|
|
50723
|
+
})
|
|
50724
|
+
];
|
|
50725
|
+
if (this.pendingTools.size === 0) this.stream.pendingStepBoundary = true;
|
|
50692
50726
|
return events;
|
|
50693
50727
|
}
|
|
50694
|
-
startTool(
|
|
50695
|
-
|
|
50696
|
-
|
|
50697
|
-
this.
|
|
50698
|
-
|
|
50699
|
-
|
|
50700
|
-
|
|
50701
|
-
|
|
50702
|
-
|
|
50703
|
-
|
|
50704
|
-
|
|
50705
|
-
|
|
50706
|
-
|
|
50728
|
+
startTool(raw) {
|
|
50729
|
+
const id = raw.toolCallId;
|
|
50730
|
+
if (typeof id !== "string" || this.completedTools.has(id)) return [];
|
|
50731
|
+
this.mergeToolResultState(id, raw);
|
|
50732
|
+
if (this.pendingTools.has(id)) return [];
|
|
50733
|
+
const payload = {
|
|
50734
|
+
apiName: [
|
|
50735
|
+
raw.name,
|
|
50736
|
+
raw.title,
|
|
50737
|
+
raw.kind
|
|
50738
|
+
].find((value) => typeof value === "string" && value.length > 0) ?? "unknown",
|
|
50739
|
+
arguments: stringify$1(raw.rawInput ?? raw.input ?? raw.parameters ?? {}),
|
|
50740
|
+
id,
|
|
50741
|
+
identifier: typeof raw.identifier === "string" && raw.identifier ? raw.identifier : this.provider,
|
|
50742
|
+
type: "default"
|
|
50743
|
+
};
|
|
50744
|
+
const streamEvents = this.stream.ensureStream(true);
|
|
50745
|
+
this.pendingTools.add(id);
|
|
50746
|
+
this.stream.stepTools.push(payload);
|
|
50707
50747
|
return [
|
|
50708
|
-
...
|
|
50709
|
-
this.event("
|
|
50710
|
-
|
|
50711
|
-
|
|
50712
|
-
|
|
50713
|
-
|
|
50714
|
-
|
|
50715
|
-
|
|
50716
|
-
|
|
50717
|
-
result: {
|
|
50718
|
-
content,
|
|
50719
|
-
success: !isError
|
|
50720
|
-
},
|
|
50721
|
-
toolCallId: tool.payload.id
|
|
50722
|
-
}, tool.stepIndex)
|
|
50748
|
+
...streamEvents,
|
|
50749
|
+
this.stream.event("stream_chunk", {
|
|
50750
|
+
chunkType: "tools_calling",
|
|
50751
|
+
toolsCalling: [...this.stream.stepTools]
|
|
50752
|
+
}),
|
|
50753
|
+
this.stream.event("tool_start", {
|
|
50754
|
+
toolCalling: payload,
|
|
50755
|
+
toolCallId: id
|
|
50756
|
+
})
|
|
50723
50757
|
];
|
|
50724
50758
|
}
|
|
50725
|
-
|
|
50726
|
-
const
|
|
50759
|
+
mergeToolResultState(toolCallId, raw) {
|
|
50760
|
+
const state = this.toolResultStateById.get(toolCallId) ?? {};
|
|
50761
|
+
if (raw.content !== void 0) state.content = raw.content;
|
|
50762
|
+
if (raw.rawOutput !== void 0) state.rawOutput = raw.rawOutput;
|
|
50763
|
+
if (raw.output !== void 0) state.output = raw.output;
|
|
50764
|
+
if (raw.content !== void 0) state.latest = "content";
|
|
50765
|
+
else if (raw.rawOutput !== void 0) state.latest = "rawOutput";
|
|
50766
|
+
else if (raw.output !== void 0) state.latest = "output";
|
|
50767
|
+
this.toolResultStateById.set(toolCallId, state);
|
|
50768
|
+
return state;
|
|
50769
|
+
}
|
|
50770
|
+
closePending() {
|
|
50771
|
+
const events = [...this.pendingTools].map((toolCallId) => this.stream.event("tool_end", {
|
|
50772
|
+
isSuccess: false,
|
|
50773
|
+
toolCallId
|
|
50774
|
+
}));
|
|
50727
50775
|
this.pendingTools.clear();
|
|
50728
50776
|
return events;
|
|
50729
50777
|
}
|
|
50730
|
-
|
|
50731
|
-
|
|
50732
|
-
|
|
50733
|
-
|
|
50734
|
-
|
|
50735
|
-
|
|
50736
|
-
|
|
50737
|
-
|
|
50738
|
-
|
|
50739
|
-
|
|
50740
|
-
|
|
50741
|
-
|
|
50742
|
-
|
|
50743
|
-
|
|
50744
|
-
|
|
50745
|
-
|
|
50746
|
-
|
|
50747
|
-
|
|
50748
|
-
|
|
50749
|
-
|
|
50750
|
-
|
|
50751
|
-
message: "Antigravity completed without returning all tool results."
|
|
50752
|
-
}));
|
|
50753
|
-
} else {
|
|
50754
|
-
const detail = pickString$1(result.error) || `Antigravity ended with status ${String(result.status ?? "unknown")}.`;
|
|
50755
|
-
events.push(this.event("error", classifyCliMessageError({
|
|
50756
|
-
agentType: IDENTIFIER,
|
|
50757
|
-
detail
|
|
50758
|
-
}) ?? {
|
|
50759
|
-
agentType: IDENTIFIER,
|
|
50760
|
-
code: "antigravity_run_error",
|
|
50761
|
-
message: detail
|
|
50762
|
-
}));
|
|
50763
|
-
}
|
|
50764
|
-
events.push(...this.closeStream());
|
|
50765
|
-
if (keepOpenForMoreTurns) {
|
|
50766
|
-
this.hasResponseText = false;
|
|
50767
|
-
this.responseStep = void 0;
|
|
50768
|
-
this.toolSinceResponse = false;
|
|
50769
|
-
this.stepTools = [];
|
|
50770
|
-
this.stepIndex += 1;
|
|
50778
|
+
complete(stopReason, usage, costUsd) {
|
|
50779
|
+
if (this.terminal) return [];
|
|
50780
|
+
this.terminal = true;
|
|
50781
|
+
const runtimeEndData = stopReason === "cancelled" ? {
|
|
50782
|
+
reason: "interrupted",
|
|
50783
|
+
stopReason
|
|
50784
|
+
} : { stopReason };
|
|
50785
|
+
const result = [
|
|
50786
|
+
...this.closePending(),
|
|
50787
|
+
...this.stream.closeStream({ stopReason }),
|
|
50788
|
+
this.stream.event("visible_output_end", {})
|
|
50789
|
+
];
|
|
50790
|
+
if (usage) {
|
|
50791
|
+
if (costUsd !== void 0) usage.cost = costUsd;
|
|
50792
|
+
const stepCompleteData = {
|
|
50793
|
+
model: this.model,
|
|
50794
|
+
phase: "turn_metadata",
|
|
50795
|
+
provider: this.provider,
|
|
50796
|
+
usage
|
|
50797
|
+
};
|
|
50798
|
+
result.push(this.stream.event("step_complete", stepCompleteData));
|
|
50771
50799
|
}
|
|
50772
|
-
|
|
50800
|
+
result.push(this.stream.event("agent_runtime_end", runtimeEndData));
|
|
50801
|
+
return result;
|
|
50773
50802
|
}
|
|
50774
|
-
|
|
50803
|
+
/**
|
|
50804
|
+
* Convert an ACP experimental `Usage` shape into the shared `UsageData`.
|
|
50805
|
+
* Returns `undefined` when required fields are missing or invalid.
|
|
50806
|
+
*/
|
|
50807
|
+
toUsageData(usage) {
|
|
50808
|
+
if (!isRecord$8(usage)) return;
|
|
50809
|
+
const total = toFiniteNumber$3(usage.totalTokens) ?? toFiniteNumber$3(usage.total_tokens);
|
|
50810
|
+
const input = toFiniteNumber$3(usage.inputTokens) ?? toFiniteNumber$3(usage.input_tokens);
|
|
50811
|
+
const output = toFiniteNumber$3(usage.outputTokens) ?? toFiniteNumber$3(usage.output_tokens);
|
|
50812
|
+
if (typeof input !== "number" || typeof output !== "number" || input < 0 || output < 0) return;
|
|
50813
|
+
const cachedRead = toFiniteNumber$3(usage.cachedReadTokens) ?? toFiniteNumber$3(usage.cached_read_tokens) ?? toFiniteNumber$3(usage.cacheReadTokens) ?? toFiniteNumber$3(usage.cache_read_tokens) ?? 0;
|
|
50814
|
+
const cachedWrite = toFiniteNumber$3(usage.cachedWriteTokens) ?? toFiniteNumber$3(usage.cached_write_tokens) ?? toFiniteNumber$3(usage.cacheWriteTokens) ?? toFiniteNumber$3(usage.cache_write_tokens) ?? 0;
|
|
50815
|
+
const thought = toFiniteNumber$3(usage.thoughtTokens) ?? toFiniteNumber$3(usage.thought_tokens) ?? toFiniteNumber$3(usage.reasoningTokens) ?? toFiniteNumber$3(usage.reasoning_tokens) ?? 0;
|
|
50816
|
+
const inputCacheMiss = Math.max(0, input - cachedRead);
|
|
50817
|
+
const outputText = Math.max(0, output - thought);
|
|
50818
|
+
const totalTokens = total ?? input + output + cachedWrite;
|
|
50775
50819
|
return {
|
|
50776
|
-
|
|
50777
|
-
|
|
50778
|
-
|
|
50779
|
-
|
|
50820
|
+
inputCachedTokens: cachedRead || void 0,
|
|
50821
|
+
inputCacheMissTokens: inputCacheMiss,
|
|
50822
|
+
inputWriteCacheTokens: cachedWrite || void 0,
|
|
50823
|
+
outputReasoningTokens: thought || void 0,
|
|
50824
|
+
outputTextTokens: outputText,
|
|
50825
|
+
totalInputTokens: input + cachedWrite,
|
|
50826
|
+
totalOutputTokens: output,
|
|
50827
|
+
totalTokens
|
|
50780
50828
|
};
|
|
50781
50829
|
}
|
|
50830
|
+
/**
|
|
50831
|
+
* Extract token usage from a `usage_update` notification.
|
|
50832
|
+
* The ACP spec only requires `used`/`size`/`cost`; per-turn token breakdown
|
|
50833
|
+
* lives in `_meta` as vendor extensions. Subclasses may override this to
|
|
50834
|
+
* parse provider-specific `_meta` keys (e.g. `cognition.ai/*Tokens`).
|
|
50835
|
+
*/
|
|
50836
|
+
extractUsageFromUsageUpdate(_raw) {}
|
|
50837
|
+
/** Extract a USD cost amount from an ACP `cost` object. */
|
|
50838
|
+
toCostUsd(cost) {
|
|
50839
|
+
if (!isRecord$8(cost)) return;
|
|
50840
|
+
if (cost.currency !== "USD") return;
|
|
50841
|
+
const amount = toFiniteNumber$3(cost.amount);
|
|
50842
|
+
if (amount === void 0 || amount <= 0) return;
|
|
50843
|
+
return amount;
|
|
50844
|
+
}
|
|
50845
|
+
fail(message) {
|
|
50846
|
+
if (this.terminal) return [];
|
|
50847
|
+
this.terminal = true;
|
|
50848
|
+
return [
|
|
50849
|
+
...this.closePending(),
|
|
50850
|
+
...this.stream.closeStream(),
|
|
50851
|
+
this.stream.event("visible_output_end", {}),
|
|
50852
|
+
this.stream.event("error", {
|
|
50853
|
+
agentType: this.provider,
|
|
50854
|
+
error: message,
|
|
50855
|
+
message
|
|
50856
|
+
})
|
|
50857
|
+
];
|
|
50858
|
+
}
|
|
50859
|
+
};
|
|
50860
|
+
|
|
50861
|
+
//#endregion
|
|
50862
|
+
//#region ../../packages/heterogeneous-agents/src/adapters/antigravityAcp.ts
|
|
50863
|
+
init_object$1();
|
|
50864
|
+
const IDENTIFIER = "antigravity";
|
|
50865
|
+
const tokenCount = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : 0;
|
|
50866
|
+
/**
|
|
50867
|
+
* `agy acp` reports `inputTokens` without cache reads (`totalTokens` is input
|
|
50868
|
+
* + cached reads + output), unlike the ACP usage shape the base adapter
|
|
50869
|
+
* assumes. Our totals include cached input.
|
|
50870
|
+
*/
|
|
50871
|
+
const toAntigravityUsage = (raw) => {
|
|
50872
|
+
if (!isRecord$8(raw)) return;
|
|
50873
|
+
const inputCacheMissTokens = tokenCount(raw.inputTokens);
|
|
50874
|
+
const inputCachedTokens = tokenCount(raw.cachedReadTokens);
|
|
50875
|
+
const totalOutputTokens = tokenCount(raw.outputTokens);
|
|
50876
|
+
if (!inputCacheMissTokens && !inputCachedTokens && !totalOutputTokens) return;
|
|
50877
|
+
const outputReasoningTokens = Math.min(tokenCount(raw.thoughtTokens), totalOutputTokens);
|
|
50878
|
+
const totalInputTokens = inputCacheMissTokens + inputCachedTokens;
|
|
50879
|
+
return {
|
|
50880
|
+
inputCachedTokens: inputCachedTokens || void 0,
|
|
50881
|
+
inputCacheMissTokens,
|
|
50882
|
+
outputReasoningTokens: outputReasoningTokens || void 0,
|
|
50883
|
+
outputTextTokens: totalOutputTokens - outputReasoningTokens,
|
|
50884
|
+
totalInputTokens,
|
|
50885
|
+
totalOutputTokens,
|
|
50886
|
+
totalTokens: totalInputTokens + totalOutputTokens
|
|
50887
|
+
};
|
|
50888
|
+
};
|
|
50889
|
+
/**
|
|
50890
|
+
* Maps `agy acp` session updates (the standard ACP vocabulary) into the shared
|
|
50891
|
+
* event contract, plus the steer delivery the session reports as
|
|
50892
|
+
* `antigravity_user_message` once agy took a message into the running turn.
|
|
50893
|
+
*/
|
|
50894
|
+
var AntigravityAcpAdapter = class extends TraeAcpAdapter {
|
|
50895
|
+
constructor() {
|
|
50896
|
+
super({
|
|
50897
|
+
eventPrefix: IDENTIFIER,
|
|
50898
|
+
provider: IDENTIFIER
|
|
50899
|
+
});
|
|
50900
|
+
}
|
|
50901
|
+
adapt(value) {
|
|
50902
|
+
if (!isRecord$8(value)) return [];
|
|
50903
|
+
if (value.type === `${IDENTIFIER}_user_message`) {
|
|
50904
|
+
if (typeof value.uuid !== "string" || !value.uuid) return [];
|
|
50905
|
+
this.stream.pendingStepBoundary = true;
|
|
50906
|
+
return [this.stream.event("step_complete", {
|
|
50907
|
+
phase: "user_message",
|
|
50908
|
+
uuid: value.uuid
|
|
50909
|
+
})];
|
|
50910
|
+
}
|
|
50911
|
+
const events = super.adapt(value);
|
|
50912
|
+
if (value.type !== `${IDENTIFIER}_error`) return events;
|
|
50913
|
+
const classified = classifyCliMessageError({
|
|
50914
|
+
agentType: IDENTIFIER,
|
|
50915
|
+
detail: typeof value.message === "string" ? value.message : void 0
|
|
50916
|
+
});
|
|
50917
|
+
return classified ? events.map((event) => event.type === "error" ? {
|
|
50918
|
+
...event,
|
|
50919
|
+
data: classified
|
|
50920
|
+
} : event) : events;
|
|
50921
|
+
}
|
|
50922
|
+
toUsageData(usage) {
|
|
50923
|
+
return toAntigravityUsage(usage);
|
|
50924
|
+
}
|
|
50782
50925
|
};
|
|
50783
50926
|
|
|
50784
50927
|
//#endregion
|
|
@@ -51370,7 +51513,7 @@ const getPathValue = (raw, path) => {
|
|
|
51370
51513
|
}
|
|
51371
51514
|
return current;
|
|
51372
51515
|
};
|
|
51373
|
-
const toFiniteNumber$
|
|
51516
|
+
const toFiniteNumber$2 = (value) => {
|
|
51374
51517
|
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
51375
51518
|
if (typeof value === "string" && value.trim()) {
|
|
51376
51519
|
const parsed = Number(value);
|
|
@@ -51379,7 +51522,7 @@ const toFiniteNumber$3 = (value) => {
|
|
|
51379
51522
|
};
|
|
51380
51523
|
const pickNumber = (raw, paths) => {
|
|
51381
51524
|
for (const path of paths) {
|
|
51382
|
-
const value = toFiniteNumber$
|
|
51525
|
+
const value = toFiniteNumber$2(getPathValue(raw, path));
|
|
51383
51526
|
if (value !== void 0) return value;
|
|
51384
51527
|
}
|
|
51385
51528
|
};
|
|
@@ -54057,7 +54200,7 @@ const CODEX_PROPOSED_PLAN_API_NAME = "proposed_plan";
|
|
|
54057
54200
|
//#region ../../packages/heterogeneous-agents/src/adapters/codexAppServer.ts
|
|
54058
54201
|
const CODEX_IDENTIFIER = "codex";
|
|
54059
54202
|
const isToolItem = (item) => item.type === "collabAgentToolCall" || item.type === "commandExecution" || item.type === "dynamicToolCall" || item.type === "fileChange" || item.type === "mcpToolCall" || item.type === "webSearch";
|
|
54060
|
-
const stringify
|
|
54203
|
+
const stringify = (value) => {
|
|
54061
54204
|
if (typeof value === "string") return value;
|
|
54062
54205
|
if (value === null || value === void 0) return "";
|
|
54063
54206
|
try {
|
|
@@ -54113,8 +54256,8 @@ const toMcpContent = (item) => {
|
|
|
54113
54256
|
if (!item.result) return "";
|
|
54114
54257
|
return item.result.content.map((content) => {
|
|
54115
54258
|
if (typeof content === "string") return content;
|
|
54116
|
-
if (content && typeof content === "object" && "text" in content) return typeof content.text === "string" ? content.text : stringify
|
|
54117
|
-
return stringify
|
|
54259
|
+
if (content && typeof content === "object" && "text" in content) return typeof content.text === "string" ? content.text : stringify(content);
|
|
54260
|
+
return stringify(content);
|
|
54118
54261
|
}).filter(Boolean).join("\n\n");
|
|
54119
54262
|
};
|
|
54120
54263
|
const getWebSearchQuery = (item) => {
|
|
@@ -54185,7 +54328,7 @@ const toToolResult = (item) => {
|
|
|
54185
54328
|
toolCallId: item.id
|
|
54186
54329
|
};
|
|
54187
54330
|
case "dynamicToolCall": return {
|
|
54188
|
-
content: item.contentItems?.map((entry) => entry.type === "inputText" ? entry.text : stringify
|
|
54331
|
+
content: item.contentItems?.map((entry) => entry.type === "inputText" ? entry.text : stringify(entry)).join("\n\n") || `${item.tool} ${success ? "completed" : "failed"}.`,
|
|
54189
54332
|
isError: !success,
|
|
54190
54333
|
pluginState: {
|
|
54191
54334
|
arguments: item.arguments,
|
|
@@ -54751,365 +54894,6 @@ var CodexAppServerAdapter = class {
|
|
|
54751
54894
|
}
|
|
54752
54895
|
};
|
|
54753
54896
|
|
|
54754
|
-
//#endregion
|
|
54755
|
-
//#region ../../packages/heterogeneous-agents/src/adapters/acpCommon.ts
|
|
54756
|
-
init_object$1();
|
|
54757
|
-
/**
|
|
54758
|
-
* Shared stream/step lifecycle for ACP `sessionUpdate` adapters.
|
|
54759
|
-
*
|
|
54760
|
-
* ACP does not frame model rounds explicitly, so adapters detect step
|
|
54761
|
-
* boundaries themselves (tool completion, response completion, …) and set
|
|
54762
|
-
* {@link pendingStepBoundary}. The next `ensureStream(true)` call consumes the
|
|
54763
|
-
* boundary: it closes the open stream, bumps `stepIndex`, resets the per-step
|
|
54764
|
-
* tool list, and re-opens a stream whose `stream_start` payload comes from the
|
|
54765
|
-
* adapter-provided builder (which appends `newStep` for steps > 0).
|
|
54766
|
-
*/
|
|
54767
|
-
var AcpStreamLifecycle = class {
|
|
54768
|
-
/** Set by the adapter when the next model round must open a new step. */
|
|
54769
|
-
pendingStepBoundary = false;
|
|
54770
|
-
stepIndex = 0;
|
|
54771
|
-
/** Tool calls announced within the current step (reset at each boundary). */
|
|
54772
|
-
stepTools = [];
|
|
54773
|
-
streamOpen = false;
|
|
54774
|
-
constructor(buildStreamStartData) {
|
|
54775
|
-
this.buildStreamStartData = buildStreamStartData;
|
|
54776
|
-
}
|
|
54777
|
-
event(type, data) {
|
|
54778
|
-
return {
|
|
54779
|
-
data,
|
|
54780
|
-
stepIndex: this.stepIndex,
|
|
54781
|
-
timestamp: Date.now(),
|
|
54782
|
-
type
|
|
54783
|
-
};
|
|
54784
|
-
}
|
|
54785
|
-
ensureStream(consumeStepBoundary) {
|
|
54786
|
-
const events = [];
|
|
54787
|
-
if (consumeStepBoundary && this.pendingStepBoundary) {
|
|
54788
|
-
events.push(...this.closeStream());
|
|
54789
|
-
this.pendingStepBoundary = false;
|
|
54790
|
-
this.stepIndex += 1;
|
|
54791
|
-
this.stepTools = [];
|
|
54792
|
-
}
|
|
54793
|
-
if (this.streamOpen) return events;
|
|
54794
|
-
this.streamOpen = true;
|
|
54795
|
-
events.push(this.event("stream_start", this.buildStreamStartData(this.stepIndex)));
|
|
54796
|
-
return events;
|
|
54797
|
-
}
|
|
54798
|
-
closeStream(data = {}) {
|
|
54799
|
-
if (!this.streamOpen) return [];
|
|
54800
|
-
this.streamOpen = false;
|
|
54801
|
-
return [this.event("stream_end", data)];
|
|
54802
|
-
}
|
|
54803
|
-
};
|
|
54804
|
-
/**
|
|
54805
|
-
* Read the text out of one ACP ContentBlock-ish value: plain strings, `text`
|
|
54806
|
-
* blocks, nested `content` wrappers, and the `diff` / `output` string fields
|
|
54807
|
-
* some agents put on tool-call content.
|
|
54808
|
-
*/
|
|
54809
|
-
const acpContentBlockText = (value) => {
|
|
54810
|
-
if (typeof value === "string") return value;
|
|
54811
|
-
if (!isRecord$8(value)) return "";
|
|
54812
|
-
if (value.type === "text" && typeof value.text === "string") return value.text;
|
|
54813
|
-
if (typeof value.content === "string") return value.content;
|
|
54814
|
-
if (isRecord$8(value.content)) return acpContentBlockText(value.content);
|
|
54815
|
-
if (typeof value.diff === "string") return value.diff;
|
|
54816
|
-
if (typeof value.output === "string") return value.output;
|
|
54817
|
-
return "";
|
|
54818
|
-
};
|
|
54819
|
-
/**
|
|
54820
|
-
* ACP extension marker for replayed history: `_meta.isReplay` on either the
|
|
54821
|
-
* notification `params` or the nested `update`.
|
|
54822
|
-
*/
|
|
54823
|
-
const isAcpReplayMessage = (raw) => {
|
|
54824
|
-
const params = toRecord$1(toRecord$1(raw)?.params);
|
|
54825
|
-
const update = toRecord$1(params?.update);
|
|
54826
|
-
return toRecord$1(params?._meta)?.isReplay === true || toRecord$1(update?._meta)?.isReplay === true;
|
|
54827
|
-
};
|
|
54828
|
-
/** ACP extension dedup marker: `_meta.eventId` on the notification `params`. */
|
|
54829
|
-
const acpEventIdOf = (raw) => {
|
|
54830
|
-
const meta = toRecord$1(toRecord$1(toRecord$1(raw)?.params)?._meta);
|
|
54831
|
-
return typeof meta?.eventId === "string" ? meta.eventId : void 0;
|
|
54832
|
-
};
|
|
54833
|
-
|
|
54834
|
-
//#endregion
|
|
54835
|
-
//#region ../../packages/heterogeneous-agents/src/adapters/traeAcp.ts
|
|
54836
|
-
init_object$1();
|
|
54837
|
-
const DEFAULT_PROVIDER = "trae";
|
|
54838
|
-
const toFiniteNumber$2 = (value) => {
|
|
54839
|
-
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
54840
|
-
if (typeof value === "string") {
|
|
54841
|
-
const parsed = Number(value);
|
|
54842
|
-
if (Number.isFinite(parsed)) return parsed;
|
|
54843
|
-
}
|
|
54844
|
-
};
|
|
54845
|
-
const stringify = (value) => {
|
|
54846
|
-
if (typeof value === "string") return value;
|
|
54847
|
-
if (value === void 0) return "";
|
|
54848
|
-
try {
|
|
54849
|
-
return JSON.stringify(value);
|
|
54850
|
-
} catch {
|
|
54851
|
-
return String(value);
|
|
54852
|
-
}
|
|
54853
|
-
};
|
|
54854
|
-
const toolContent = (content, fallback) => {
|
|
54855
|
-
if (!Array.isArray(content)) return stringify(content ?? fallback);
|
|
54856
|
-
return content.map((value) => {
|
|
54857
|
-
const block = value;
|
|
54858
|
-
if (block?.type === "content") {
|
|
54859
|
-
const nestedContent = block.content;
|
|
54860
|
-
if (nestedContent?.type === "text") return stringify(nestedContent.text);
|
|
54861
|
-
return stringify(block.content);
|
|
54862
|
-
}
|
|
54863
|
-
if (block?.type === "diff") return [block.path, block.newText].filter((value) => typeof value === "string").join("\n");
|
|
54864
|
-
if (block?.type === "terminal") return `[Terminal: ${stringify(block.terminalId)}]`;
|
|
54865
|
-
return stringify(block);
|
|
54866
|
-
}).filter(Boolean).join("\n") || stringify(fallback);
|
|
54867
|
-
};
|
|
54868
|
-
/**
|
|
54869
|
-
* Maps the standard ACP `sessionUpdate` vocabulary into the shared event
|
|
54870
|
-
* contract. TRAE is the default provider; other standard-ACP agents reuse it
|
|
54871
|
-
* via {@link AcpSessionAdapterOptions}.
|
|
54872
|
-
*/
|
|
54873
|
-
var TraeAcpAdapter = class {
|
|
54874
|
-
sessionId;
|
|
54875
|
-
eventPrefix;
|
|
54876
|
-
provider;
|
|
54877
|
-
completedTools = /* @__PURE__ */ new Set();
|
|
54878
|
-
lastCostUsd;
|
|
54879
|
-
lastUsage;
|
|
54880
|
-
model;
|
|
54881
|
-
pendingTools = /* @__PURE__ */ new Set();
|
|
54882
|
-
snapshotSeq = /* @__PURE__ */ new Map();
|
|
54883
|
-
stream = new AcpStreamLifecycle((stepIndex) => ({
|
|
54884
|
-
...this.model ? { model: this.model } : {},
|
|
54885
|
-
...stepIndex > 0 ? { newStep: true } : {},
|
|
54886
|
-
provider: this.provider,
|
|
54887
|
-
sessionId: this.sessionId
|
|
54888
|
-
}));
|
|
54889
|
-
terminal = false;
|
|
54890
|
-
toolResultStateById = /* @__PURE__ */ new Map();
|
|
54891
|
-
constructor(options = {}) {
|
|
54892
|
-
this.provider = options.provider ?? DEFAULT_PROVIDER;
|
|
54893
|
-
this.eventPrefix = options.eventPrefix ?? this.provider;
|
|
54894
|
-
}
|
|
54895
|
-
adapt(value) {
|
|
54896
|
-
if (!value || typeof value !== "object" || this.terminal) return [];
|
|
54897
|
-
const raw = value;
|
|
54898
|
-
if (raw.type === "session_configured") {
|
|
54899
|
-
if (typeof raw.model === "string") this.model = raw.model;
|
|
54900
|
-
return [];
|
|
54901
|
-
}
|
|
54902
|
-
if (raw.type === `${this.eventPrefix}_session`) {
|
|
54903
|
-
if (typeof raw.sessionId === "string") this.sessionId = raw.sessionId;
|
|
54904
|
-
if (typeof raw.model === "string") this.model = raw.model;
|
|
54905
|
-
return [];
|
|
54906
|
-
}
|
|
54907
|
-
if (raw.type === `${this.eventPrefix}_prompt_completed`) {
|
|
54908
|
-
const usage = this.toUsageData(raw.usage) ?? this.lastUsage;
|
|
54909
|
-
const costUsd = this.toCostUsd(raw.cost) ?? this.lastCostUsd;
|
|
54910
|
-
return this.complete(raw.stopReason, usage, costUsd);
|
|
54911
|
-
}
|
|
54912
|
-
if (raw.type === `${this.eventPrefix}_error`) return this.fail(stringify(raw.message) || `${this.provider} ACP failed`);
|
|
54913
|
-
switch (raw.sessionUpdate) {
|
|
54914
|
-
case "usage_update": {
|
|
54915
|
-
const usage = this.extractUsageFromUsageUpdate(raw);
|
|
54916
|
-
if (usage) this.lastUsage = usage;
|
|
54917
|
-
const costUsd = this.toCostUsd(raw.cost);
|
|
54918
|
-
if (costUsd !== void 0) this.lastCostUsd = costUsd;
|
|
54919
|
-
return [];
|
|
54920
|
-
}
|
|
54921
|
-
case "agent_message_chunk": {
|
|
54922
|
-
const text = raw.content?.text;
|
|
54923
|
-
return typeof text === "string" && text ? [...this.stream.ensureStream(true), this.stream.event("stream_chunk", {
|
|
54924
|
-
chunkType: "text",
|
|
54925
|
-
content: text
|
|
54926
|
-
})] : [];
|
|
54927
|
-
}
|
|
54928
|
-
case "agent_thought_chunk": {
|
|
54929
|
-
const reasoning = raw.content?.text;
|
|
54930
|
-
return typeof reasoning === "string" && reasoning ? [...this.stream.ensureStream(true), this.stream.event("stream_chunk", {
|
|
54931
|
-
chunkType: "reasoning",
|
|
54932
|
-
reasoning
|
|
54933
|
-
})] : [];
|
|
54934
|
-
}
|
|
54935
|
-
case "tool_call": return this.startTool(raw);
|
|
54936
|
-
case "tool_call_update": return this.updateTool(raw);
|
|
54937
|
-
default: return [];
|
|
54938
|
-
}
|
|
54939
|
-
}
|
|
54940
|
-
flush() {
|
|
54941
|
-
if (this.terminal) return [];
|
|
54942
|
-
return this.complete("end_turn", this.lastUsage, this.lastCostUsd);
|
|
54943
|
-
}
|
|
54944
|
-
updateTool(raw) {
|
|
54945
|
-
const id = raw.toolCallId;
|
|
54946
|
-
if (typeof id !== "string" || this.completedTools.has(id)) return [];
|
|
54947
|
-
const startEvents = this.pendingTools.has(id) ? [] : this.startTool(raw);
|
|
54948
|
-
const resultState = this.mergeToolResultState(id, raw);
|
|
54949
|
-
if (raw.status === "running" || raw.status === "in_progress" || raw.status === "pending") {
|
|
54950
|
-
const snapshotSeq = (this.snapshotSeq.get(id) ?? 0) + 1;
|
|
54951
|
-
this.snapshotSeq.set(id, snapshotSeq);
|
|
54952
|
-
return [...startEvents, this.stream.event("stream_chunk", {
|
|
54953
|
-
chunkType: "tool_state",
|
|
54954
|
-
pluginState: { ...raw },
|
|
54955
|
-
snapshotMode: "replace",
|
|
54956
|
-
snapshotSeq,
|
|
54957
|
-
toolCallId: id
|
|
54958
|
-
})];
|
|
54959
|
-
}
|
|
54960
|
-
if (raw.status !== "completed" && raw.status !== "failed") return [];
|
|
54961
|
-
this.completedTools.add(id);
|
|
54962
|
-
this.pendingTools.delete(id);
|
|
54963
|
-
const isSuccess = raw.status === "completed";
|
|
54964
|
-
const result = resultState.latest === "content" ? toolContent(resultState.content, resultState.rawOutput ?? resultState.output) : stringify(resultState.latest === "rawOutput" ? resultState.rawOutput : resultState.output);
|
|
54965
|
-
const events = [
|
|
54966
|
-
...startEvents,
|
|
54967
|
-
this.stream.event("tool_result", {
|
|
54968
|
-
content: result,
|
|
54969
|
-
isError: !isSuccess,
|
|
54970
|
-
toolCallId: id
|
|
54971
|
-
}),
|
|
54972
|
-
this.stream.event("tool_end", {
|
|
54973
|
-
isSuccess,
|
|
54974
|
-
toolCallId: id
|
|
54975
|
-
})
|
|
54976
|
-
];
|
|
54977
|
-
if (this.pendingTools.size === 0) this.stream.pendingStepBoundary = true;
|
|
54978
|
-
return events;
|
|
54979
|
-
}
|
|
54980
|
-
startTool(raw) {
|
|
54981
|
-
const id = raw.toolCallId;
|
|
54982
|
-
if (typeof id !== "string" || this.completedTools.has(id)) return [];
|
|
54983
|
-
this.mergeToolResultState(id, raw);
|
|
54984
|
-
if (this.pendingTools.has(id)) return [];
|
|
54985
|
-
const payload = {
|
|
54986
|
-
apiName: [
|
|
54987
|
-
raw.name,
|
|
54988
|
-
raw.title,
|
|
54989
|
-
raw.kind
|
|
54990
|
-
].find((value) => typeof value === "string" && value.length > 0) ?? "unknown",
|
|
54991
|
-
arguments: stringify(raw.rawInput ?? raw.input ?? raw.parameters ?? {}),
|
|
54992
|
-
id,
|
|
54993
|
-
identifier: typeof raw.identifier === "string" && raw.identifier ? raw.identifier : this.provider,
|
|
54994
|
-
type: "default"
|
|
54995
|
-
};
|
|
54996
|
-
const streamEvents = this.stream.ensureStream(true);
|
|
54997
|
-
this.pendingTools.add(id);
|
|
54998
|
-
this.stream.stepTools.push(payload);
|
|
54999
|
-
return [
|
|
55000
|
-
...streamEvents,
|
|
55001
|
-
this.stream.event("stream_chunk", {
|
|
55002
|
-
chunkType: "tools_calling",
|
|
55003
|
-
toolsCalling: [...this.stream.stepTools]
|
|
55004
|
-
}),
|
|
55005
|
-
this.stream.event("tool_start", {
|
|
55006
|
-
toolCalling: payload,
|
|
55007
|
-
toolCallId: id
|
|
55008
|
-
})
|
|
55009
|
-
];
|
|
55010
|
-
}
|
|
55011
|
-
mergeToolResultState(toolCallId, raw) {
|
|
55012
|
-
const state = this.toolResultStateById.get(toolCallId) ?? {};
|
|
55013
|
-
if (raw.content !== void 0) state.content = raw.content;
|
|
55014
|
-
if (raw.rawOutput !== void 0) state.rawOutput = raw.rawOutput;
|
|
55015
|
-
if (raw.output !== void 0) state.output = raw.output;
|
|
55016
|
-
if (raw.content !== void 0) state.latest = "content";
|
|
55017
|
-
else if (raw.rawOutput !== void 0) state.latest = "rawOutput";
|
|
55018
|
-
else if (raw.output !== void 0) state.latest = "output";
|
|
55019
|
-
this.toolResultStateById.set(toolCallId, state);
|
|
55020
|
-
return state;
|
|
55021
|
-
}
|
|
55022
|
-
closePending() {
|
|
55023
|
-
const events = [...this.pendingTools].map((toolCallId) => this.stream.event("tool_end", {
|
|
55024
|
-
isSuccess: false,
|
|
55025
|
-
toolCallId
|
|
55026
|
-
}));
|
|
55027
|
-
this.pendingTools.clear();
|
|
55028
|
-
return events;
|
|
55029
|
-
}
|
|
55030
|
-
complete(stopReason, usage, costUsd) {
|
|
55031
|
-
if (this.terminal) return [];
|
|
55032
|
-
this.terminal = true;
|
|
55033
|
-
const runtimeEndData = stopReason === "cancelled" ? {
|
|
55034
|
-
reason: "interrupted",
|
|
55035
|
-
stopReason
|
|
55036
|
-
} : { stopReason };
|
|
55037
|
-
const result = [
|
|
55038
|
-
...this.closePending(),
|
|
55039
|
-
...this.stream.closeStream({ stopReason }),
|
|
55040
|
-
this.stream.event("visible_output_end", {})
|
|
55041
|
-
];
|
|
55042
|
-
if (usage) {
|
|
55043
|
-
if (costUsd !== void 0) usage.cost = costUsd;
|
|
55044
|
-
const stepCompleteData = {
|
|
55045
|
-
model: this.model,
|
|
55046
|
-
phase: "turn_metadata",
|
|
55047
|
-
provider: this.provider,
|
|
55048
|
-
usage
|
|
55049
|
-
};
|
|
55050
|
-
result.push(this.stream.event("step_complete", stepCompleteData));
|
|
55051
|
-
}
|
|
55052
|
-
result.push(this.stream.event("agent_runtime_end", runtimeEndData));
|
|
55053
|
-
return result;
|
|
55054
|
-
}
|
|
55055
|
-
/**
|
|
55056
|
-
* Convert an ACP experimental `Usage` shape into the shared `UsageData`.
|
|
55057
|
-
* Returns `undefined` when required fields are missing or invalid.
|
|
55058
|
-
*/
|
|
55059
|
-
toUsageData(usage) {
|
|
55060
|
-
if (!isRecord$8(usage)) return;
|
|
55061
|
-
const total = toFiniteNumber$2(usage.totalTokens) ?? toFiniteNumber$2(usage.total_tokens);
|
|
55062
|
-
const input = toFiniteNumber$2(usage.inputTokens) ?? toFiniteNumber$2(usage.input_tokens);
|
|
55063
|
-
const output = toFiniteNumber$2(usage.outputTokens) ?? toFiniteNumber$2(usage.output_tokens);
|
|
55064
|
-
if (typeof input !== "number" || typeof output !== "number" || input < 0 || output < 0) return;
|
|
55065
|
-
const cachedRead = toFiniteNumber$2(usage.cachedReadTokens) ?? toFiniteNumber$2(usage.cached_read_tokens) ?? toFiniteNumber$2(usage.cacheReadTokens) ?? toFiniteNumber$2(usage.cache_read_tokens) ?? 0;
|
|
55066
|
-
const cachedWrite = toFiniteNumber$2(usage.cachedWriteTokens) ?? toFiniteNumber$2(usage.cached_write_tokens) ?? toFiniteNumber$2(usage.cacheWriteTokens) ?? toFiniteNumber$2(usage.cache_write_tokens) ?? 0;
|
|
55067
|
-
const thought = toFiniteNumber$2(usage.thoughtTokens) ?? toFiniteNumber$2(usage.thought_tokens) ?? toFiniteNumber$2(usage.reasoningTokens) ?? toFiniteNumber$2(usage.reasoning_tokens) ?? 0;
|
|
55068
|
-
const inputCacheMiss = Math.max(0, input - cachedRead);
|
|
55069
|
-
const outputText = Math.max(0, output - thought);
|
|
55070
|
-
const totalTokens = total ?? input + output + cachedWrite;
|
|
55071
|
-
return {
|
|
55072
|
-
inputCachedTokens: cachedRead || void 0,
|
|
55073
|
-
inputCacheMissTokens: inputCacheMiss,
|
|
55074
|
-
inputWriteCacheTokens: cachedWrite || void 0,
|
|
55075
|
-
outputReasoningTokens: thought || void 0,
|
|
55076
|
-
outputTextTokens: outputText,
|
|
55077
|
-
totalInputTokens: input + cachedWrite,
|
|
55078
|
-
totalOutputTokens: output,
|
|
55079
|
-
totalTokens
|
|
55080
|
-
};
|
|
55081
|
-
}
|
|
55082
|
-
/**
|
|
55083
|
-
* Extract token usage from a `usage_update` notification.
|
|
55084
|
-
* The ACP spec only requires `used`/`size`/`cost`; per-turn token breakdown
|
|
55085
|
-
* lives in `_meta` as vendor extensions. Subclasses may override this to
|
|
55086
|
-
* parse provider-specific `_meta` keys (e.g. `cognition.ai/*Tokens`).
|
|
55087
|
-
*/
|
|
55088
|
-
extractUsageFromUsageUpdate(_raw) {}
|
|
55089
|
-
/** Extract a USD cost amount from an ACP `cost` object. */
|
|
55090
|
-
toCostUsd(cost) {
|
|
55091
|
-
if (!isRecord$8(cost)) return;
|
|
55092
|
-
if (cost.currency !== "USD") return;
|
|
55093
|
-
const amount = toFiniteNumber$2(cost.amount);
|
|
55094
|
-
if (amount === void 0 || amount <= 0) return;
|
|
55095
|
-
return amount;
|
|
55096
|
-
}
|
|
55097
|
-
fail(message) {
|
|
55098
|
-
if (this.terminal) return [];
|
|
55099
|
-
this.terminal = true;
|
|
55100
|
-
return [
|
|
55101
|
-
...this.closePending(),
|
|
55102
|
-
...this.stream.closeStream(),
|
|
55103
|
-
this.stream.event("visible_output_end", {}),
|
|
55104
|
-
this.stream.event("error", {
|
|
55105
|
-
agentType: this.provider,
|
|
55106
|
-
error: message,
|
|
55107
|
-
message
|
|
55108
|
-
})
|
|
55109
|
-
];
|
|
55110
|
-
}
|
|
55111
|
-
};
|
|
55112
|
-
|
|
55113
54897
|
//#endregion
|
|
55114
54898
|
//#region ../../packages/heterogeneous-agents/src/adapters/copilotAcp.ts
|
|
55115
54899
|
/**
|
|
@@ -56669,7 +56453,7 @@ const getHeterogeneousTypeLabel = (type) => {
|
|
|
56669
56453
|
* by registering here — no other code changes needed.
|
|
56670
56454
|
*/
|
|
56671
56455
|
const localAgentRegistry = {
|
|
56672
|
-
"antigravity": { createAdapter: () => new
|
|
56456
|
+
"antigravity": { createAdapter: () => new AntigravityAcpAdapter() },
|
|
56673
56457
|
"amp": { createAdapter: () => new AmpAdapter() },
|
|
56674
56458
|
"claude-code": { createAdapter: () => new ClaudeCodeAdapter() },
|
|
56675
56459
|
"codebuddy": { createAdapter: () => new CodeBuddyAdapter() },
|
|
@@ -70259,23 +70043,33 @@ const numberOption = (value) => {
|
|
|
70259
70043
|
};
|
|
70260
70044
|
const collect$2 = (value, previous = []) => [...previous, value];
|
|
70261
70045
|
/**
|
|
70262
|
-
* Operation-scoped: reads stay in the run's own conversation,
|
|
70263
|
-
* requester. Never falls back to the device
|
|
70046
|
+
* Operation-scoped: reads stay in the run's Channel (its own conversation, or another Thread of
|
|
70047
|
+
* it by `--thread`), and messages go out as the run's requester. Never falls back to the device
|
|
70048
|
+
* owner's account.
|
|
70264
70049
|
*/
|
|
70265
70050
|
const registerChannelCommand = (program) => {
|
|
70266
70051
|
const channel = program.command("channel").description("Read the current Agent run’s Channel conversation, message Agents in other Channels, and message people for your requester");
|
|
70267
|
-
channel.command("history").description("Read recent public messages; page backwards with the returned cursor").option("--before <sequence>", "Exclusive nextBeforeSequence cursor", numberOption).option("--limit <count>", "Messages per page (1–20, default 10)", numberOption).option("--json", "Print structured JSON").action(async (options) => {
|
|
70052
|
+
channel.command("history").description("Read recent public messages; page backwards with the returned cursor").option("--before <sequence>", "Exclusive nextBeforeSequence cursor", numberOption).option("--limit <count>", "Messages per page (1–20, default 10)", numberOption).option("--thread <threadId>", "Read another Thread of this Channel (from `channel threads`) live, instead of your own conversation").option("--json", "Print structured JSON").action(async (options) => {
|
|
70268
70053
|
outputJson(projectChannelHistory(await (await getTrpcClient()).channel.readMessages.query({
|
|
70269
70054
|
beforeSequence: options.before,
|
|
70270
|
-
limit: options.limit
|
|
70055
|
+
limit: options.limit,
|
|
70056
|
+
threadId: options.thread
|
|
70271
70057
|
})));
|
|
70272
70058
|
});
|
|
70273
|
-
channel.command("message <id>").description("Read a full public message and its attachment links").option("--offset <characters>", "Continue at nextOffset", numberOption).option("--json", "Print structured JSON").action(async (messageId, options) => {
|
|
70059
|
+
channel.command("message <id>").description("Read a full public message and its attachment links").option("--offset <characters>", "Continue at nextOffset", numberOption).option("--thread <threadId>", "The Thread `history --thread` returned the message from").option("--json", "Print structured JSON").action(async (messageId, options) => {
|
|
70274
70060
|
outputJson(projectChannelHistory(await (await getTrpcClient()).channel.readMessage.query({
|
|
70275
70061
|
messageId,
|
|
70276
|
-
offset: options.offset
|
|
70062
|
+
offset: options.offset,
|
|
70063
|
+
threadId: options.thread
|
|
70277
70064
|
})));
|
|
70278
70065
|
});
|
|
70066
|
+
channel.command("threads").description("List the Threads of this Channel, newest first, to read one with --thread").option("--active", "Only Threads where you have a queued or running reply").option("--before <threadId>", "Exclusive cursor: nextBefore of the previous page").option("--limit <count>", "Threads per page (1–20, default 10)", numberOption).option("--json", "Print structured JSON").action(async (options) => {
|
|
70067
|
+
outputJson(await (await getTrpcClient()).channel.listThreads.query({
|
|
70068
|
+
activeOnly: options.active,
|
|
70069
|
+
before: options.before,
|
|
70070
|
+
limit: options.limit
|
|
70071
|
+
}));
|
|
70072
|
+
});
|
|
70279
70073
|
channel.command("list").description("List the Channels your requester belongs to and the Agents in each, to find where to reach an Agent").option("--agent <agentId>", "Only Channels this Agent is a member of").option("--query <text>", "Match the Channel title or an Agent name").option("--limit <count>", "Channels to return (1–20, default 10)", numberOption).option("--json", "Print structured JSON").action(async (options) => {
|
|
70280
70074
|
outputJson(await (await getTrpcClient()).channel.listChannels.query({
|
|
70281
70075
|
agentId: options.agent,
|
|
@@ -70641,14 +70435,6 @@ const QUOTA_SOURCE_LABELS = {
|
|
|
70641
70435
|
|
|
70642
70436
|
//#endregion
|
|
70643
70437
|
//#region ../../packages/heterogeneous-agents/src/spawn/antigravity.ts
|
|
70644
|
-
/** agy reads a single JSONL user message, then finishes the turn when stdin closes. */
|
|
70645
|
-
const ANTIGRAVITY_BASE_ARGS = [
|
|
70646
|
-
"--input-format",
|
|
70647
|
-
"stream-json",
|
|
70648
|
-
"--output-format",
|
|
70649
|
-
"stream-json",
|
|
70650
|
-
"--dangerously-skip-permissions"
|
|
70651
|
-
];
|
|
70652
70438
|
/** A Connect service can inherit an old SSH session that makes agy skip the desktop keyring. */
|
|
70653
70439
|
const getAntigravitySpawnEnv = (env) => {
|
|
70654
70440
|
if (env.LOBEHUB_CONNECT_SERVICE !== "1") return env;
|
|
@@ -70658,39 +70444,53 @@ const getAntigravitySpawnEnv = (env) => {
|
|
|
70658
70444
|
delete childEnv.SSH_TTY;
|
|
70659
70445
|
return childEnv;
|
|
70660
70446
|
};
|
|
70661
|
-
|
|
70662
|
-
|
|
70663
|
-
|
|
70664
|
-
|
|
70665
|
-
});
|
|
70447
|
+
/**
|
|
70448
|
+
* Flags LobeHub owns: the ACP session carries the prompt, output and
|
|
70449
|
+
* conversation, and `agy acp` has no per-run `--settings`.
|
|
70450
|
+
*/
|
|
70666
70451
|
const MANAGED_FLAGS = new Set([
|
|
70667
70452
|
"--",
|
|
70453
|
+
"--continue",
|
|
70454
|
+
"--conversation",
|
|
70668
70455
|
"--input-format",
|
|
70669
70456
|
"--output-format",
|
|
70670
70457
|
"--print",
|
|
70671
70458
|
"--prompt",
|
|
70672
70459
|
"--prompt-interactive",
|
|
70673
70460
|
"--remote-control",
|
|
70674
|
-
"
|
|
70675
|
-
"-p",
|
|
70676
|
-
"--continue",
|
|
70461
|
+
"--settings",
|
|
70677
70462
|
"-c",
|
|
70678
|
-
"
|
|
70463
|
+
"-i",
|
|
70464
|
+
"-p"
|
|
70679
70465
|
]);
|
|
70680
|
-
|
|
70681
|
-
|
|
70682
|
-
|
|
70683
|
-
|
|
70684
|
-
|
|
70685
|
-
|
|
70686
|
-
|
|
70687
|
-
|
|
70688
|
-
|
|
70689
|
-
|
|
70690
|
-
|
|
70691
|
-
|
|
70692
|
-
|
|
70693
|
-
];
|
|
70466
|
+
/** Selector flags applied through ACP `session/set_config_option` instead of argv. */
|
|
70467
|
+
const SESSION_CONFIG_FLAGS = {
|
|
70468
|
+
"--effort": "effort",
|
|
70469
|
+
"--mode": "mode",
|
|
70470
|
+
"--model": "model"
|
|
70471
|
+
};
|
|
70472
|
+
/**
|
|
70473
|
+
* Split user/selector args into the `agy acp` argv and the session options
|
|
70474
|
+
* ACP sets per session (`--model` full ids such as `gemini-4-neon-xhigh`,
|
|
70475
|
+
* `--effort`, `--mode`). Tool permissions are always auto-approved, as the
|
|
70476
|
+
* print-mode runs were.
|
|
70477
|
+
*/
|
|
70478
|
+
const buildAntigravityAcpLaunch = (extraArgs = []) => {
|
|
70479
|
+
const launch = { args: ["acp", "--dangerously-skip-permissions"] };
|
|
70480
|
+
for (let index = 0; index < extraArgs.length; index += 1) {
|
|
70481
|
+
const arg = extraArgs[index];
|
|
70482
|
+
const [flag, inlineValue] = arg.split(/=(.*)/s, 2);
|
|
70483
|
+
if (MANAGED_FLAGS.has(flag)) throw new Error(`LobeHub manages Antigravity's prompt, session and settings flags: ${flag}`);
|
|
70484
|
+
const key = SESSION_CONFIG_FLAGS[flag];
|
|
70485
|
+
if (!key) {
|
|
70486
|
+
if (arg !== "--dangerously-skip-permissions") launch.args.push(arg);
|
|
70487
|
+
continue;
|
|
70488
|
+
}
|
|
70489
|
+
const value = inlineValue ?? extraArgs[++index];
|
|
70490
|
+
if (!value?.trim()) throw new Error(`Antigravity flag ${flag} needs a value`);
|
|
70491
|
+
launch[key] = value.trim();
|
|
70492
|
+
}
|
|
70493
|
+
return launch;
|
|
70694
70494
|
};
|
|
70695
70495
|
|
|
70696
70496
|
//#endregion
|
|
@@ -71674,12 +71474,7 @@ var init_resolveCliCommand = __esmMin((() => {
|
|
|
71674
71474
|
detectValidatedCommand = async (command, options, probeEnv) => detectValidatedCommandCandidates([command], options, probeEnv);
|
|
71675
71475
|
HETEROGENEOUS_CLI_AGENT_OPTIONS = {
|
|
71676
71476
|
"antigravity": {
|
|
71677
|
-
validateHelpKeywords: [
|
|
71678
|
-
"--input-format",
|
|
71679
|
-
"--output-format",
|
|
71680
|
-
"--conversation",
|
|
71681
|
-
"stream-json"
|
|
71682
|
-
],
|
|
71477
|
+
validateHelpKeywords: ["Agent Client Protocol"],
|
|
71683
71478
|
validatePattern: /^(?:(?:agy|antigravity(?: cli)?) (?:version )?)?v?\d+\.\d+\.\d+(?:-[\dA-Z.-]+)?(?:\+[\dA-Z.-]+)?$/i
|
|
71684
71479
|
},
|
|
71685
71480
|
"amp": {
|
|
@@ -73381,7 +73176,6 @@ const buildQoderInput = async (blocks, options) => {
|
|
|
73381
73176
|
* extra CLI args required to attach images. The single source of truth for
|
|
73382
73177
|
* how each external agent CLI receives multimodal input.
|
|
73383
73178
|
*
|
|
73384
|
-
* - `antigravity`: stream-json text on stdin with local paths for the built-in image reader
|
|
73385
73179
|
* - `amp` / `claude-code` / `codebuddy`: stream-json on stdin with text + base64 image content blocks
|
|
73386
73180
|
* - `codex`: raw text on stdin + repeatable `--image <path>` flags
|
|
73387
73181
|
* - `kimi-code`: `--prompt <text>` with materialized image paths referenced in the text
|
|
@@ -73395,18 +73189,6 @@ const buildQoderInput = async (blocks, options) => {
|
|
|
73395
73189
|
const buildAgentInput = async (agentType, prompt, options = {}) => {
|
|
73396
73190
|
const blocks = toBlocks$1(prompt);
|
|
73397
73191
|
switch (agentType) {
|
|
73398
|
-
case "antigravity": {
|
|
73399
|
-
const imagePaths = await resolvePathInputImagePaths(blocks, options);
|
|
73400
|
-
const attachments = imagePaths.length ? ["Use your built-in image-reading tool to inspect the attached images before answering:", ...imagePaths.map((imagePath) => `- ${JSON.stringify(path.resolve(imagePath))}`)].join("\n") : "";
|
|
73401
|
-
const content = [collectText(blocks), attachments].filter(Boolean).join("\n\n");
|
|
73402
|
-
return {
|
|
73403
|
-
args: [],
|
|
73404
|
-
stdin: `${JSON.stringify({
|
|
73405
|
-
event: "user",
|
|
73406
|
-
message: { content }
|
|
73407
|
-
})}\n`
|
|
73408
|
-
};
|
|
73409
|
-
}
|
|
73410
73192
|
case "amp":
|
|
73411
73193
|
case "claude-code":
|
|
73412
73194
|
case "codebuddy": return buildClaudeCompatibleStdin(blocks, options);
|
|
@@ -76154,158 +75936,642 @@ var AcpAgentSession = class {
|
|
|
76154
75936
|
};
|
|
76155
75937
|
|
|
76156
75938
|
//#endregion
|
|
76157
|
-
//#region ../../packages/heterogeneous-agents/src/spawn/
|
|
75939
|
+
//#region ../../packages/heterogeneous-agents/src/spawn/traeAcpSession.ts
|
|
75940
|
+
const NOTIFICATION_DRAIN_QUIET_MS$2 = 250;
|
|
75941
|
+
const NOTIFICATION_DRAIN_TIMEOUT_MS$2 = 2e3;
|
|
75942
|
+
const TRANSPORT$5 = "trae-acp";
|
|
75943
|
+
const sleep$7 = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
75944
|
+
const TRAE_GLOBAL_VALUE_FLAGS = new Set([
|
|
75945
|
+
"--config",
|
|
75946
|
+
"--permission-mode",
|
|
75947
|
+
"--profile",
|
|
75948
|
+
"-c",
|
|
75949
|
+
"-p"
|
|
75950
|
+
]);
|
|
75951
|
+
const isInlineTraeGlobalArg = (arg) => arg.startsWith("--config=") || arg.startsWith("--permission-mode=") || arg.startsWith("--profile=") || arg.startsWith("-c=") || arg.startsWith("-p=");
|
|
76158
75952
|
/**
|
|
76159
|
-
*
|
|
76160
|
-
*
|
|
75953
|
+
* TRAE requires configuration flags before `acp serve`, while ACP Server flags
|
|
75954
|
+
* belong after it. Keep unknown/user server flags in their historical position
|
|
75955
|
+
* and move only the documented global flags plus their values.
|
|
75956
|
+
* @see https://docs.trae.cn/cli_agent-client-protocol
|
|
76161
75957
|
*/
|
|
76162
|
-
const
|
|
76163
|
-
const
|
|
76164
|
-
const
|
|
76165
|
-
|
|
75958
|
+
const buildTraeAcpArgs = (args = []) => {
|
|
75959
|
+
const globalArgs = [];
|
|
75960
|
+
const serverArgs = [];
|
|
75961
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
75962
|
+
const arg = args[index];
|
|
75963
|
+
if (TRAE_GLOBAL_VALUE_FLAGS.has(arg)) {
|
|
75964
|
+
globalArgs.push(arg);
|
|
75965
|
+
const value = args[index + 1];
|
|
75966
|
+
if (value !== void 0) {
|
|
75967
|
+
globalArgs.push(value);
|
|
75968
|
+
index += 1;
|
|
75969
|
+
}
|
|
75970
|
+
continue;
|
|
75971
|
+
}
|
|
75972
|
+
if (isInlineTraeGlobalArg(arg)) {
|
|
75973
|
+
globalArgs.push(arg);
|
|
75974
|
+
continue;
|
|
75975
|
+
}
|
|
75976
|
+
serverArgs.push(arg);
|
|
75977
|
+
}
|
|
75978
|
+
return [
|
|
75979
|
+
...globalArgs,
|
|
75980
|
+
"acp",
|
|
75981
|
+
"serve",
|
|
75982
|
+
"--yolo",
|
|
75983
|
+
...serverArgs
|
|
75984
|
+
];
|
|
75985
|
+
};
|
|
75986
|
+
const buildTraeAcpPrompt = async (prompt, options = {}) => {
|
|
75987
|
+
const blocks = typeof prompt === "string" ? [{
|
|
75988
|
+
text: prompt,
|
|
75989
|
+
type: "text"
|
|
75990
|
+
}] : prompt;
|
|
75991
|
+
const result = [];
|
|
75992
|
+
for (const block of blocks) if (block.type === "text") result.push({
|
|
75993
|
+
text: block.text,
|
|
75994
|
+
type: "text"
|
|
75995
|
+
});
|
|
75996
|
+
else {
|
|
75997
|
+
const image = await normalizeImage(block.source, options);
|
|
75998
|
+
result.push({
|
|
75999
|
+
data: image.buffer.toString("base64"),
|
|
76000
|
+
mimeType: image.mediaType,
|
|
76001
|
+
type: "image"
|
|
76002
|
+
});
|
|
76003
|
+
}
|
|
76004
|
+
return result;
|
|
76005
|
+
};
|
|
76006
|
+
const toTraeModel = (id, name) => ({
|
|
76007
|
+
id,
|
|
76008
|
+
...typeof name === "string" && name && name !== id ? { label: name } : {},
|
|
76009
|
+
modelId: id,
|
|
76010
|
+
providerId: "trae"
|
|
76011
|
+
});
|
|
76012
|
+
const parseConfigOptionModels$1 = (options) => {
|
|
76013
|
+
if (!Array.isArray(options)) return [];
|
|
76014
|
+
const values = options.flatMap((value) => {
|
|
76015
|
+
const option = value;
|
|
76016
|
+
return Array.isArray(option?.options) ? option.options : [value];
|
|
76017
|
+
});
|
|
76018
|
+
const seen = /* @__PURE__ */ new Set();
|
|
76019
|
+
const models = [];
|
|
76020
|
+
for (const value of values) {
|
|
76021
|
+
const option = value;
|
|
76022
|
+
if (typeof option?.value !== "string" || !option.value || seen.has(option.value)) continue;
|
|
76023
|
+
seen.add(option.value);
|
|
76024
|
+
models.push(toTraeModel(option.value, option.name));
|
|
76025
|
+
}
|
|
76026
|
+
return models;
|
|
76166
76027
|
};
|
|
76167
76028
|
/**
|
|
76168
|
-
*
|
|
76169
|
-
*
|
|
76029
|
+
* Read model selection from the current stable ACP config-options API, with a
|
|
76030
|
+
* compatibility fallback for the never-stabilized dedicated model API still
|
|
76031
|
+
* exposed by older TRAE CLI builds.
|
|
76170
76032
|
*/
|
|
76171
|
-
const
|
|
76172
|
-
|
|
76173
|
-
|
|
76033
|
+
const parseTraeAcpModelCatalog = (result) => {
|
|
76034
|
+
const selectableOptions = (Array.isArray(result?.configOptions) ? result.configOptions.map((value) => value) : []).filter((option) => option?.type === void 0 || option.type === "select");
|
|
76035
|
+
const modelConfig = selectableOptions.find((option) => option?.category === "model") ?? selectableOptions.find((option) => option?.id === "model") ?? selectableOptions.find((option) => typeof option?.name === "string" && option.name.toLowerCase() === "model");
|
|
76036
|
+
if (modelConfig && typeof modelConfig.id === "string" && modelConfig.id) return {
|
|
76037
|
+
configId: modelConfig.id,
|
|
76038
|
+
currentModelId: typeof modelConfig.currentValue === "string" ? modelConfig.currentValue : void 0,
|
|
76039
|
+
models: parseConfigOptionModels$1(modelConfig.options),
|
|
76040
|
+
protocol: "config-option"
|
|
76041
|
+
};
|
|
76042
|
+
if (!Array.isArray(result?.models?.availableModels)) return;
|
|
76043
|
+
const seen = /* @__PURE__ */ new Set();
|
|
76044
|
+
const models = [];
|
|
76045
|
+
for (const value of result.models.availableModels) {
|
|
76046
|
+
const option = value;
|
|
76047
|
+
if (typeof option?.modelId !== "string" || !option.modelId || seen.has(option.modelId)) continue;
|
|
76048
|
+
seen.add(option.modelId);
|
|
76049
|
+
models.push(toTraeModel(option.modelId, option.name));
|
|
76050
|
+
}
|
|
76174
76051
|
return {
|
|
76175
|
-
|
|
76176
|
-
|
|
76052
|
+
currentModelId: typeof result.models.currentModelId === "string" ? result.models.currentModelId : void 0,
|
|
76053
|
+
models,
|
|
76054
|
+
protocol: "legacy-model"
|
|
76177
76055
|
};
|
|
76178
76056
|
};
|
|
76057
|
+
/** TRAE's ACP v1 lifecycle: model config-options and legacy model API on the shared base. */
|
|
76058
|
+
var TraeAcpSession = class TraeAcpSession extends AcpAgentSession {
|
|
76059
|
+
acceptUpdates = false;
|
|
76060
|
+
lastSessionUpdateAt = 0;
|
|
76061
|
+
modelDiscovery;
|
|
76062
|
+
resolvedPrompt = [];
|
|
76063
|
+
constructor(options) {
|
|
76064
|
+
super(options, {
|
|
76065
|
+
args: buildTraeAcpArgs(options.args),
|
|
76066
|
+
pipeline: { agentType: "trae" },
|
|
76067
|
+
processLabel: "TRAE ACP",
|
|
76068
|
+
transport: TRANSPORT$5
|
|
76069
|
+
});
|
|
76070
|
+
}
|
|
76071
|
+
get nativeSessionId() {
|
|
76072
|
+
return this.acpSessionId;
|
|
76073
|
+
}
|
|
76074
|
+
/** Create a short-lived ACP session and read its agent-provided model selector. */
|
|
76075
|
+
async discoverModels() {
|
|
76076
|
+
return (await this.discoverModelCatalog()).models;
|
|
76077
|
+
}
|
|
76078
|
+
async prepareRun() {
|
|
76079
|
+
this.resolvedPrompt = await this.resolvePrompt();
|
|
76080
|
+
}
|
|
76081
|
+
buildInitializeParams() {
|
|
76082
|
+
return {
|
|
76083
|
+
clientCapabilities: {},
|
|
76084
|
+
clientInfo: {
|
|
76085
|
+
name: "lobehub",
|
|
76086
|
+
title: "LobeHub",
|
|
76087
|
+
version: this.options.clientVersion
|
|
76088
|
+
},
|
|
76089
|
+
protocolVersion: 1
|
|
76090
|
+
};
|
|
76091
|
+
}
|
|
76092
|
+
validateInitialized(initialized) {
|
|
76093
|
+
if (typeof initialized?.protocolVersion === "number" && initialized.protocolVersion !== 1) throw new Error(`TRAE ACP returned unsupported protocol version: ${initialized.protocolVersion}`);
|
|
76094
|
+
}
|
|
76095
|
+
async establishSession(initialized) {
|
|
76096
|
+
if (this.resolvedPrompt.some((block) => block.type === "image") && initialized?.agentCapabilities?.promptCapabilities?.image !== true) throw new Error("TRAE ACP agent does not support image prompt blocks");
|
|
76097
|
+
if (this.options.resumeSessionId && initialized?.agentCapabilities?.loadSession !== true) throw new Error("TRAE ACP agent does not support loading sessions");
|
|
76098
|
+
const sessionResult = await this.client.request(this.options.resumeSessionId ? "session/load" : "session/new", {
|
|
76099
|
+
cwd: this.options.cwd,
|
|
76100
|
+
mcpServers: [],
|
|
76101
|
+
...this.options.resumeSessionId ? { sessionId: this.options.resumeSessionId } : {}
|
|
76102
|
+
});
|
|
76103
|
+
const sessionId = sessionResult?.sessionId ?? this.options.resumeSessionId;
|
|
76104
|
+
if (!sessionId) throw new Error("TRAE ACP returned no session id");
|
|
76105
|
+
this.acpSessionId = sessionId;
|
|
76106
|
+
this.options.onSessionId(sessionId);
|
|
76107
|
+
const model = await this.applyInitialModel(sessionId, sessionResult);
|
|
76108
|
+
if (model) {
|
|
76109
|
+
this.pipeline.configureSession({ model });
|
|
76110
|
+
this.options.onModel?.(model);
|
|
76111
|
+
}
|
|
76112
|
+
await this.pushToPipeline({
|
|
76113
|
+
model,
|
|
76114
|
+
sessionId,
|
|
76115
|
+
type: "trae_session"
|
|
76116
|
+
});
|
|
76117
|
+
return sessionId;
|
|
76118
|
+
}
|
|
76119
|
+
onBeforePrompt() {
|
|
76120
|
+
this.acceptUpdates = true;
|
|
76121
|
+
}
|
|
76122
|
+
buildPromptParams(sessionId) {
|
|
76123
|
+
return {
|
|
76124
|
+
prompt: this.resolvedPrompt,
|
|
76125
|
+
sessionId
|
|
76126
|
+
};
|
|
76127
|
+
}
|
|
76128
|
+
async settlePrompt(result) {
|
|
76129
|
+
await this.drainNotifications();
|
|
76130
|
+
await this.client.drain();
|
|
76131
|
+
await this.pushToPipeline({
|
|
76132
|
+
stopReason: result?.stopReason,
|
|
76133
|
+
type: "trae_prompt_completed"
|
|
76134
|
+
});
|
|
76135
|
+
}
|
|
76136
|
+
async onRunFailure(error) {
|
|
76137
|
+
await this.pushToPipeline({
|
|
76138
|
+
message: error.message,
|
|
76139
|
+
type: "trae_error"
|
|
76140
|
+
});
|
|
76141
|
+
await this.emitEvents(await this.pipeline.flush());
|
|
76142
|
+
}
|
|
76143
|
+
async onRunCancelled() {
|
|
76144
|
+
await this.pushToPipeline({
|
|
76145
|
+
stopReason: "cancelled",
|
|
76146
|
+
type: "trae_prompt_completed"
|
|
76147
|
+
});
|
|
76148
|
+
}
|
|
76149
|
+
onHostClose() {
|
|
76150
|
+
this.modelDiscovery?.close();
|
|
76151
|
+
}
|
|
76152
|
+
async handleAgentMessage(message) {
|
|
76153
|
+
if (message.method !== "session/update") return;
|
|
76154
|
+
if (!this.acceptUpdates) return;
|
|
76155
|
+
this.lastSessionUpdateAt = Date.now();
|
|
76156
|
+
const update = message.params?.update;
|
|
76157
|
+
if (!update || typeof update !== "object") return;
|
|
76158
|
+
if (update.sessionUpdate === "config_option_update") {
|
|
76159
|
+
const catalog = parseTraeAcpModelCatalog({ configOptions: update.configOptions });
|
|
76160
|
+
if (catalog?.currentModelId) {
|
|
76161
|
+
this.pipeline.configureSession({ model: catalog.currentModelId });
|
|
76162
|
+
this.options.onModel?.(catalog.currentModelId);
|
|
76163
|
+
}
|
|
76164
|
+
}
|
|
76165
|
+
await this.pushToPipeline(update);
|
|
76166
|
+
}
|
|
76167
|
+
handleServerRequest(message) {
|
|
76168
|
+
if (message.method === "session/request_permission") {
|
|
76169
|
+
const optionId = selectAcpPermissionOption(message.params, [
|
|
76170
|
+
(option) => option.optionId === "allow_session" || option.optionId === "approve_for_session",
|
|
76171
|
+
(option) => option.kind === "allow_once",
|
|
76172
|
+
(option) => option.kind === "reject_once"
|
|
76173
|
+
]);
|
|
76174
|
+
if (optionId) return { outcome: {
|
|
76175
|
+
optionId,
|
|
76176
|
+
outcome: "selected"
|
|
76177
|
+
} };
|
|
76178
|
+
throw new AcpServerRequestError(-32603, "No safe permission option was offered");
|
|
76179
|
+
}
|
|
76180
|
+
throw new AcpServerRequestError(-32601, `Unsupported ACP client request: ${message.method}`);
|
|
76181
|
+
}
|
|
76182
|
+
async discoverModelCatalog() {
|
|
76183
|
+
try {
|
|
76184
|
+
const initialized = await this.initializeConnection();
|
|
76185
|
+
const sessionResult = await this.client.request("session/new", {
|
|
76186
|
+
cwd: this.options.cwd,
|
|
76187
|
+
mcpServers: []
|
|
76188
|
+
});
|
|
76189
|
+
if (!sessionResult?.sessionId) throw new Error("TRAE ACP returned no session id");
|
|
76190
|
+
const catalog = parseTraeAcpModelCatalog(sessionResult);
|
|
76191
|
+
if (!catalog) throw new Error("TRAE ACP did not expose a model configuration option");
|
|
76192
|
+
if (initialized?.agentCapabilities?.sessionCapabilities?.close) await this.client.request("session/close", { sessionId: sessionResult.sessionId });
|
|
76193
|
+
return catalog;
|
|
76194
|
+
} finally {
|
|
76195
|
+
this.client.close();
|
|
76196
|
+
}
|
|
76197
|
+
}
|
|
76198
|
+
async resolvePrompt() {
|
|
76199
|
+
const prompt = this.options.prompt;
|
|
76200
|
+
if (Array.isArray(prompt) && prompt.every((block) => "type" in block && (block.type === "text" || "data" in block && block.type === "image"))) return prompt;
|
|
76201
|
+
return buildTraeAcpPrompt(prompt, this.options.inputOptions);
|
|
76202
|
+
}
|
|
76203
|
+
async applyInitialModel(sessionId, sessionResult) {
|
|
76204
|
+
let catalog = parseTraeAcpModelCatalog(sessionResult);
|
|
76205
|
+
const requestedModel = this.options.initialModel?.trim();
|
|
76206
|
+
if (!requestedModel || requestedModel === "default") return catalog?.currentModelId;
|
|
76207
|
+
if (!catalog && this.options.resumeSessionId) catalog = await this.discoverResumeModelCatalog();
|
|
76208
|
+
if (!catalog) throw new Error("TRAE ACP did not expose a model configuration option");
|
|
76209
|
+
const selected = catalog.models.find((model) => model.id === requestedModel || model.label === requestedModel);
|
|
76210
|
+
if (!selected) throw new Error(`TRAE ACP model is unavailable: ${requestedModel}`);
|
|
76211
|
+
if (catalog.protocol === "config-option") return parseTraeAcpModelCatalog({ configOptions: (await this.client.request("session/set_config_option", {
|
|
76212
|
+
configId: catalog.configId,
|
|
76213
|
+
sessionId,
|
|
76214
|
+
value: selected.id
|
|
76215
|
+
}))?.configOptions })?.currentModelId ?? selected.id;
|
|
76216
|
+
await this.client.request("session/set_model", {
|
|
76217
|
+
modelId: selected.id,
|
|
76218
|
+
sessionId
|
|
76219
|
+
});
|
|
76220
|
+
return selected.id;
|
|
76221
|
+
}
|
|
76222
|
+
async discoverResumeModelCatalog() {
|
|
76223
|
+
const discovery = new TraeAcpSession({
|
|
76224
|
+
...this.options,
|
|
76225
|
+
initialModel: void 0,
|
|
76226
|
+
onEvents: () => {},
|
|
76227
|
+
onModel: void 0,
|
|
76228
|
+
onRuntimeStatus: () => {},
|
|
76229
|
+
onSessionId: () => {},
|
|
76230
|
+
operationId: `${this.options.operationId}-model-discovery`,
|
|
76231
|
+
prompt: "",
|
|
76232
|
+
resumeSessionId: void 0,
|
|
76233
|
+
sessionId: `${this.options.sessionId}-model-discovery`
|
|
76234
|
+
});
|
|
76235
|
+
this.modelDiscovery = discovery;
|
|
76236
|
+
try {
|
|
76237
|
+
return await discovery.discoverModelCatalog();
|
|
76238
|
+
} finally {
|
|
76239
|
+
discovery.close();
|
|
76240
|
+
if (this.modelDiscovery === discovery) this.modelDiscovery = void 0;
|
|
76241
|
+
}
|
|
76242
|
+
}
|
|
76243
|
+
async drainNotifications() {
|
|
76244
|
+
const deadline = Date.now() + NOTIFICATION_DRAIN_TIMEOUT_MS$2;
|
|
76245
|
+
let quietSince = Date.now();
|
|
76246
|
+
while (Date.now() < deadline) {
|
|
76247
|
+
await sleep$7(Math.min(NOTIFICATION_DRAIN_QUIET_MS$2, deadline - Date.now()));
|
|
76248
|
+
await this.client.drain();
|
|
76249
|
+
if (this.lastSessionUpdateAt > quietSince) {
|
|
76250
|
+
quietSince = this.lastSessionUpdateAt;
|
|
76251
|
+
continue;
|
|
76252
|
+
}
|
|
76253
|
+
if (Date.now() - quietSince >= NOTIFICATION_DRAIN_QUIET_MS$2) return;
|
|
76254
|
+
}
|
|
76255
|
+
}
|
|
76256
|
+
};
|
|
76257
|
+
const listTraeAcpModels = async (options) => new TraeAcpSession({
|
|
76258
|
+
args: options.args ?? [],
|
|
76259
|
+
clientVersion: options.clientVersion ?? "1.0.0",
|
|
76260
|
+
commandPath: options.commandPath,
|
|
76261
|
+
cwd: options.cwd,
|
|
76262
|
+
env: options.env,
|
|
76263
|
+
onEvents: () => {},
|
|
76264
|
+
onRawMessage: () => {},
|
|
76265
|
+
onRuntimeStatus: () => {},
|
|
76266
|
+
onSessionId: () => {},
|
|
76267
|
+
onStderr: () => {},
|
|
76268
|
+
operationId: "trae-model-discovery",
|
|
76269
|
+
prompt: "",
|
|
76270
|
+
requestTimeoutMs: options.timeoutMs,
|
|
76271
|
+
sessionId: "trae-model-discovery"
|
|
76272
|
+
}).discoverModels();
|
|
76273
|
+
|
|
76274
|
+
//#endregion
|
|
76275
|
+
//#region ../../packages/heterogeneous-agents/src/spawn/antigravityAcpSession.ts
|
|
76276
|
+
init_object$1();
|
|
76277
|
+
const TRANSPORT$4 = "antigravity-acp";
|
|
76278
|
+
const USAGE_FIELDS = [
|
|
76279
|
+
"inputTokens",
|
|
76280
|
+
"outputTokens",
|
|
76281
|
+
"cachedReadTokens",
|
|
76282
|
+
"thoughtTokens"
|
|
76283
|
+
];
|
|
76284
|
+
const findConfigOption = (configOptions, id) => Array.isArray(configOptions) ? configOptions.find((value) => isRecord$8(value) && value.id === id) : void 0;
|
|
76285
|
+
const configValue = (configOptions, id) => {
|
|
76286
|
+
const option = findConfigOption(configOptions, id);
|
|
76287
|
+
return isRecord$8(option) && typeof option.currentValue === "string" ? option.currentValue : void 0;
|
|
76288
|
+
};
|
|
76289
|
+
/** Values of a select option, flattening grouped options. */
|
|
76290
|
+
const configOptionValues = (configOptions, id) => {
|
|
76291
|
+
const option = findConfigOption(configOptions, id);
|
|
76292
|
+
const collect = (entries) => Array.isArray(entries) ? entries.flatMap((entry) => {
|
|
76293
|
+
if (!isRecord$8(entry)) return [];
|
|
76294
|
+
if (Array.isArray(entry.options)) return collect(entry.options);
|
|
76295
|
+
return typeof entry.value === "string" ? [entry.value] : [];
|
|
76296
|
+
}) : [];
|
|
76297
|
+
return isRecord$8(option) ? collect(option.options) : [];
|
|
76298
|
+
};
|
|
76299
|
+
const availableModelIds = (result) => {
|
|
76300
|
+
const models = result.models?.availableModels;
|
|
76301
|
+
return new Set(Array.isArray(models) ? models.flatMap((model) => isRecord$8(model) && typeof model.modelId === "string" ? [model.modelId] : []) : []);
|
|
76302
|
+
};
|
|
76179
76303
|
/**
|
|
76180
|
-
*
|
|
76181
|
-
*
|
|
76182
|
-
*
|
|
76304
|
+
* The `model` value agy takes for a selection. The selector groups `agy models`
|
|
76305
|
+
* slugs into a model and an effort (`gpt-oss-120b` + `medium`), but a model
|
|
76306
|
+
* whose thinking tier is fixed only exists under its full slug
|
|
76307
|
+
* (`gpt-oss-120b-medium`).
|
|
76183
76308
|
*/
|
|
76184
|
-
|
|
76185
|
-
|
|
76186
|
-
|
|
76187
|
-
|
|
76188
|
-
|
|
76189
|
-
|
|
76190
|
-
|
|
76191
|
-
|
|
76192
|
-
|
|
76193
|
-
|
|
76194
|
-
|
|
76195
|
-
|
|
76196
|
-
|
|
76197
|
-
|
|
76198
|
-
|
|
76199
|
-
|
|
76200
|
-
|
|
76201
|
-
|
|
76202
|
-
|
|
76203
|
-
|
|
76309
|
+
const resolveModelValue = (model, effort, sessionResult) => {
|
|
76310
|
+
const known = new Set([...configOptionValues(sessionResult.configOptions, "model"), ...availableModelIds(sessionResult)]);
|
|
76311
|
+
if (known.size === 0 || known.has(model)) return model;
|
|
76312
|
+
if (effort && known.has(`${model}-${effort}`)) return `${model}-${effort}`;
|
|
76313
|
+
const variants = [...known].filter((id) => id.startsWith(`${model}-`));
|
|
76314
|
+
return variants.length === 1 ? variants[0] : model;
|
|
76315
|
+
};
|
|
76316
|
+
const buildAntigravityAcpPrompt = (prompt, options = {}) => buildTraeAcpPrompt(prompt, options);
|
|
76317
|
+
/** The response to a `session/prompt`: it carries a stop reason, or failed as one. */
|
|
76318
|
+
const isPromptResponse = (message) => {
|
|
76319
|
+
if (message.method !== void 0 || message.id === void 0) return false;
|
|
76320
|
+
if (message.error) return message.requestMethod === "session/prompt";
|
|
76321
|
+
return isRecord$8(message.result) && "stopReason" in message.result;
|
|
76322
|
+
};
|
|
76323
|
+
/**
|
|
76324
|
+
* Antigravity over `agy acp`. One run is one user turn; a message the user
|
|
76325
|
+
* sends while it runs is steered in with another `session/prompt`: agy ends
|
|
76326
|
+
* the pending prompt (`end_turn`) and carries on with the new one inside the
|
|
76327
|
+
* same work. The run ends when the latest prompt settles.
|
|
76328
|
+
*/
|
|
76329
|
+
var AntigravityAcpSession = class extends AcpAgentSession {
|
|
76330
|
+
/** Session updates before the prompt (a `session/load` replay) are history, not output. */
|
|
76331
|
+
acceptUpdates = false;
|
|
76332
|
+
/** Read confirmations, chained so each lands before any update that follows it. */
|
|
76333
|
+
confirmations = Promise.resolve();
|
|
76334
|
+
launch;
|
|
76335
|
+
/** Prompt responses handled so far, in stdout order. */
|
|
76336
|
+
promptResponses = 0;
|
|
76337
|
+
/** Steered prompts written to agy, in order, that the run has not settled yet. */
|
|
76338
|
+
steers = [];
|
|
76339
|
+
steerCount = 0;
|
|
76340
|
+
steerable = false;
|
|
76341
|
+
unconfirmedSteers = [];
|
|
76342
|
+
usage = {
|
|
76343
|
+
cachedReadTokens: 0,
|
|
76344
|
+
inputTokens: 0,
|
|
76345
|
+
outputTokens: 0,
|
|
76346
|
+
thoughtTokens: 0
|
|
76347
|
+
};
|
|
76348
|
+
constructor(options) {
|
|
76349
|
+
const launch = buildAntigravityAcpLaunch(options.args);
|
|
76350
|
+
super(options, {
|
|
76351
|
+
args: launch.args,
|
|
76352
|
+
pipeline: {
|
|
76353
|
+
agentType: "antigravity",
|
|
76354
|
+
cwd: options.cwd
|
|
76355
|
+
},
|
|
76356
|
+
processLabel: "Antigravity ACP",
|
|
76357
|
+
transport: TRANSPORT$4
|
|
76358
|
+
});
|
|
76359
|
+
this.launch = launch;
|
|
76204
76360
|
}
|
|
76205
|
-
get
|
|
76206
|
-
return this.
|
|
76361
|
+
get sessionId() {
|
|
76362
|
+
return this.acpSessionId;
|
|
76207
76363
|
}
|
|
76208
76364
|
/**
|
|
76209
|
-
* Write
|
|
76210
|
-
* (
|
|
76211
|
-
*
|
|
76365
|
+
* Write a user message into the running turn. `false` when the run takes no
|
|
76366
|
+
* input now (not prompting yet, interrupted, or settling): nothing was
|
|
76367
|
+
* written, so the message can wait for the next run. agy confirms it read
|
|
76368
|
+
* the message when the prompt it interrupts returns, reported as
|
|
76369
|
+
* `step_complete { phase: 'user_message', uuid }`.
|
|
76212
76370
|
*/
|
|
76213
|
-
|
|
76214
|
-
|
|
76215
|
-
if (
|
|
76216
|
-
|
|
76217
|
-
|
|
76218
|
-
|
|
76219
|
-
|
|
76220
|
-
|
|
76371
|
+
steer(prompt, uuid) {
|
|
76372
|
+
const sessionId = this.acpSessionId;
|
|
76373
|
+
if (!this.steerable || !sessionId || this.closedByHost) return false;
|
|
76374
|
+
const result = this.client.request("session/prompt", {
|
|
76375
|
+
prompt,
|
|
76376
|
+
sessionId
|
|
76377
|
+
}, false);
|
|
76378
|
+
result.catch(() => {});
|
|
76379
|
+
this.steers.push(result);
|
|
76380
|
+
const index = ++this.steerCount;
|
|
76381
|
+
if (this.promptResponses >= index) this.confirmSteer(uuid);
|
|
76382
|
+
else this.unconfirmedSteers.push({
|
|
76383
|
+
index,
|
|
76384
|
+
uuid
|
|
76385
|
+
});
|
|
76221
76386
|
return true;
|
|
76222
76387
|
}
|
|
76223
|
-
|
|
76224
|
-
|
|
76225
|
-
|
|
76388
|
+
interrupt() {
|
|
76389
|
+
this.steerable = false;
|
|
76390
|
+
super.interrupt();
|
|
76226
76391
|
}
|
|
76227
|
-
|
|
76228
|
-
|
|
76229
|
-
|
|
76230
|
-
|
|
76231
|
-
|
|
76232
|
-
|
|
76233
|
-
|
|
76234
|
-
|
|
76235
|
-
|
|
76236
|
-
|
|
76237
|
-
|
|
76238
|
-
|
|
76392
|
+
buildInitializeParams() {
|
|
76393
|
+
return {
|
|
76394
|
+
clientCapabilities: {
|
|
76395
|
+
fs: {
|
|
76396
|
+
readTextFile: false,
|
|
76397
|
+
writeTextFile: false
|
|
76398
|
+
},
|
|
76399
|
+
terminal: false
|
|
76400
|
+
},
|
|
76401
|
+
clientInfo: {
|
|
76402
|
+
name: "lobehub",
|
|
76403
|
+
title: "LobeHub",
|
|
76404
|
+
version: this.options.clientVersion
|
|
76405
|
+
},
|
|
76406
|
+
protocolVersion: 1
|
|
76407
|
+
};
|
|
76408
|
+
}
|
|
76409
|
+
validateInitialized(initialized) {
|
|
76410
|
+
if (initialized.protocolVersion !== 1 && initialized.protocolVersion !== String(1)) throw new Error(`Antigravity ACP returned unsupported protocol version: ${String(initialized.protocolVersion)}`);
|
|
76411
|
+
if (this.options.prompt.some((block) => block.type === "image") && initialized.agentCapabilities?.promptCapabilities?.image !== true) throw new Error("This Antigravity CLI does not accept images over ACP. Update agy and retry.");
|
|
76412
|
+
}
|
|
76413
|
+
async establishSession(initialized) {
|
|
76414
|
+
const sessionResult = await this.openSession(initialized);
|
|
76415
|
+
const sessionId = sessionResult.sessionId ?? this.options.resumeSessionId;
|
|
76416
|
+
if (!sessionId) throw new Error("Antigravity ACP returned no session id");
|
|
76417
|
+
const model = await this.applySessionConfig(sessionId, sessionResult);
|
|
76418
|
+
if (model) {
|
|
76419
|
+
this.pipeline.configureSession({ model });
|
|
76420
|
+
this.options.onModel?.(model);
|
|
76239
76421
|
}
|
|
76240
|
-
|
|
76241
|
-
|
|
76242
|
-
|
|
76422
|
+
this.options.onSessionId(sessionId);
|
|
76423
|
+
await this.pushToPipeline({
|
|
76424
|
+
model,
|
|
76425
|
+
sessionId,
|
|
76426
|
+
type: "antigravity_session"
|
|
76427
|
+
});
|
|
76428
|
+
return sessionId;
|
|
76243
76429
|
}
|
|
76244
|
-
|
|
76245
|
-
|
|
76246
|
-
|
|
76247
|
-
this.close();
|
|
76430
|
+
onBeforePrompt() {
|
|
76431
|
+
this.acceptUpdates = true;
|
|
76432
|
+
this.steerable = true;
|
|
76248
76433
|
}
|
|
76249
|
-
|
|
76250
|
-
|
|
76251
|
-
|
|
76252
|
-
|
|
76434
|
+
buildPromptParams(sessionId) {
|
|
76435
|
+
return {
|
|
76436
|
+
prompt: this.options.prompt,
|
|
76437
|
+
sessionId
|
|
76438
|
+
};
|
|
76253
76439
|
}
|
|
76254
|
-
|
|
76255
|
-
|
|
76256
|
-
|
|
76257
|
-
|
|
76258
|
-
|
|
76259
|
-
|
|
76260
|
-
|
|
76261
|
-
|
|
76262
|
-
|
|
76263
|
-
const
|
|
76264
|
-
if (
|
|
76265
|
-
|
|
76266
|
-
|
|
76267
|
-
|
|
76268
|
-
|
|
76269
|
-
|
|
76270
|
-
|
|
76271
|
-
|
|
76272
|
-
|
|
76440
|
+
/**
|
|
76441
|
+
* The first prompt settled; settle every message steered in after it, in
|
|
76442
|
+
* order. Each was confirmed as read when the prompt before it returned.
|
|
76443
|
+
*/
|
|
76444
|
+
async settlePrompt(result) {
|
|
76445
|
+
let last = isRecord$8(result) ? result : {};
|
|
76446
|
+
this.addUsage(last.usage);
|
|
76447
|
+
for (;;) {
|
|
76448
|
+
await this.client.drain();
|
|
76449
|
+
const next = this.steers.shift();
|
|
76450
|
+
if (!next) break;
|
|
76451
|
+
last = await next;
|
|
76452
|
+
this.addUsage(last.usage);
|
|
76453
|
+
}
|
|
76454
|
+
this.steerable = false;
|
|
76455
|
+
await this.confirmations;
|
|
76456
|
+
const used = Object.values(this.usage).some((value) => value > 0);
|
|
76457
|
+
await this.pushToPipeline({
|
|
76458
|
+
stopReason: last.stopReason,
|
|
76459
|
+
type: "antigravity_prompt_completed",
|
|
76460
|
+
...used && { usage: { ...this.usage } }
|
|
76461
|
+
});
|
|
76462
|
+
}
|
|
76463
|
+
async onRunFailure(error) {
|
|
76464
|
+
this.steerable = false;
|
|
76465
|
+
await this.pushToPipeline({
|
|
76466
|
+
message: error.message,
|
|
76467
|
+
type: "antigravity_error"
|
|
76468
|
+
});
|
|
76469
|
+
await this.emitEvents(await this.pipeline.flush());
|
|
76470
|
+
}
|
|
76471
|
+
async onRunCancelled() {
|
|
76472
|
+
this.steerable = false;
|
|
76473
|
+
await this.pushToPipeline({
|
|
76474
|
+
stopReason: "cancelled",
|
|
76475
|
+
type: "antigravity_prompt_completed"
|
|
76476
|
+
});
|
|
76477
|
+
}
|
|
76478
|
+
onHostClose() {
|
|
76479
|
+
this.steerable = false;
|
|
76480
|
+
}
|
|
76481
|
+
async handleAgentMessage(message) {
|
|
76482
|
+
await this.confirmations;
|
|
76483
|
+
if (isPromptResponse(message)) {
|
|
76484
|
+
this.promptResponses += 1;
|
|
76485
|
+
const next = this.unconfirmedSteers[0];
|
|
76486
|
+
if (next && next.index <= this.promptResponses) {
|
|
76487
|
+
this.unconfirmedSteers.shift();
|
|
76488
|
+
await this.confirmSteer(next.uuid);
|
|
76273
76489
|
}
|
|
76274
|
-
this.openTurn();
|
|
76275
76490
|
return;
|
|
76276
76491
|
}
|
|
76277
|
-
if (
|
|
76278
|
-
|
|
76279
|
-
|
|
76280
|
-
|
|
76281
|
-
|
|
76282
|
-
status
|
|
76283
|
-
};
|
|
76284
|
-
if (status !== "SUCCESS") this.close();
|
|
76285
|
-
else this.closeIfIdle();
|
|
76286
|
-
}
|
|
76287
|
-
}
|
|
76288
|
-
openTurn() {
|
|
76289
|
-
this.turnOpen = true;
|
|
76290
|
-
this.lastOutcome = void 0;
|
|
76492
|
+
if (!this.acceptUpdates || message.method !== "session/update") return;
|
|
76493
|
+
const params = isRecord$8(message.params) ? message.params : void 0;
|
|
76494
|
+
if (!isRecord$8(params?.update)) return;
|
|
76495
|
+
if (typeof params.sessionId === "string" && params.sessionId !== this.acpSessionId) return;
|
|
76496
|
+
await this.pushToPipeline(params.update);
|
|
76291
76497
|
}
|
|
76292
|
-
|
|
76293
|
-
|
|
76294
|
-
|
|
76498
|
+
/**
|
|
76499
|
+
* `--dangerously-skip-permissions` makes agy approve tools itself; should it
|
|
76500
|
+
* still ask, approve as the print-mode runs did.
|
|
76501
|
+
*/
|
|
76502
|
+
handleServerRequest(message) {
|
|
76503
|
+
if (message.method !== "session/request_permission") throw new AcpServerRequestError(-32601, `Unsupported ACP client request: ${message.method}`);
|
|
76504
|
+
const optionId = selectAcpPermissionOption(message.params, [(option) => option.kind === "allow_always", (option) => option.kind === "allow_once"]);
|
|
76505
|
+
return optionId ? { outcome: {
|
|
76506
|
+
optionId,
|
|
76507
|
+
outcome: "selected"
|
|
76508
|
+
} } : { outcome: { outcome: "cancelled" } };
|
|
76295
76509
|
}
|
|
76296
|
-
|
|
76297
|
-
|
|
76298
|
-
|
|
76299
|
-
|
|
76510
|
+
/**
|
|
76511
|
+
* Resume without replaying history; agy points sessions it cannot resume to
|
|
76512
|
+
* `session/load`, whose replay arrives before the prompt and is dropped.
|
|
76513
|
+
*/
|
|
76514
|
+
async openSession(initialized) {
|
|
76515
|
+
const params = {
|
|
76516
|
+
cwd: this.options.cwd,
|
|
76517
|
+
mcpServers: []
|
|
76518
|
+
};
|
|
76519
|
+
const resumeSessionId = this.options.resumeSessionId;
|
|
76520
|
+
if (!resumeSessionId) return this.client.request("session/new", params);
|
|
76521
|
+
const resumeParams = {
|
|
76522
|
+
...params,
|
|
76523
|
+
sessionId: resumeSessionId
|
|
76524
|
+
};
|
|
76525
|
+
if (initialized.agentCapabilities?.sessionCapabilities?.resume !== void 0) try {
|
|
76526
|
+
return await this.client.request("session/resume", resumeParams);
|
|
76527
|
+
} catch (error) {
|
|
76528
|
+
if (!(error instanceof AcpRpcResponseError)) throw error;
|
|
76529
|
+
}
|
|
76530
|
+
const loaded = await this.client.request("session/load", resumeParams);
|
|
76531
|
+
await this.client.drain();
|
|
76532
|
+
return loaded;
|
|
76300
76533
|
}
|
|
76301
|
-
|
|
76302
|
-
|
|
76303
|
-
|
|
76304
|
-
|
|
76534
|
+
/**
|
|
76535
|
+
* Apply the selected model (a full id such as `gemini-4-neon-xhigh`, which
|
|
76536
|
+
* agy splits into model and thinking level), effort and mode. Returns the
|
|
76537
|
+
* model the session runs.
|
|
76538
|
+
*/
|
|
76539
|
+
async applySessionConfig(sessionId, sessionResult) {
|
|
76540
|
+
let configOptions = sessionResult.configOptions;
|
|
76541
|
+
const set = async (configId, value) => {
|
|
76542
|
+
const result = await this.client.request("session/set_config_option", {
|
|
76543
|
+
configId,
|
|
76544
|
+
sessionId,
|
|
76545
|
+
value
|
|
76546
|
+
});
|
|
76547
|
+
if (result.configOptions !== void 0) configOptions = result.configOptions;
|
|
76548
|
+
};
|
|
76549
|
+
const { effort, mode } = this.launch;
|
|
76550
|
+
const model = this.launch.model && this.launch.model !== "default" ? resolveModelValue(this.launch.model, effort, sessionResult) : void 0;
|
|
76551
|
+
if (model) await set("model", model);
|
|
76552
|
+
if (effort && findConfigOption(configOptions, "thought_level")) await set("thought_level", effort);
|
|
76553
|
+
if (mode) await set("mode", mode);
|
|
76554
|
+
const family = configValue(configOptions, "model");
|
|
76555
|
+
if (!family) return model;
|
|
76556
|
+
const level = configValue(configOptions, "thought_level");
|
|
76557
|
+
const variant = level ? `${family}-${level}` : void 0;
|
|
76558
|
+
return variant && availableModelIds(sessionResult).has(variant) ? variant : family;
|
|
76559
|
+
}
|
|
76560
|
+
confirmSteer(uuid) {
|
|
76561
|
+
const confirmed = this.confirmations.then(() => this.pushToPipeline({
|
|
76562
|
+
type: "antigravity_user_message",
|
|
76563
|
+
uuid
|
|
76564
|
+
}));
|
|
76565
|
+
confirmed.catch(() => {});
|
|
76566
|
+
this.confirmations = confirmed;
|
|
76567
|
+
return confirmed;
|
|
76305
76568
|
}
|
|
76306
|
-
|
|
76307
|
-
|
|
76308
|
-
|
|
76569
|
+
addUsage(usage) {
|
|
76570
|
+
if (!isRecord$8(usage)) return;
|
|
76571
|
+
for (const field of USAGE_FIELDS) {
|
|
76572
|
+
const value = usage[field];
|
|
76573
|
+
if (typeof value === "number" && Number.isFinite(value) && value > 0) this.usage[field] += value;
|
|
76574
|
+
}
|
|
76309
76575
|
}
|
|
76310
76576
|
};
|
|
76311
76577
|
|
|
@@ -77296,342 +77562,6 @@ const readClaudeCodeSessionCost = async (params) => {
|
|
|
77296
77562
|
}
|
|
77297
77563
|
};
|
|
77298
77564
|
|
|
77299
|
-
//#endregion
|
|
77300
|
-
//#region ../../packages/heterogeneous-agents/src/spawn/traeAcpSession.ts
|
|
77301
|
-
const NOTIFICATION_DRAIN_QUIET_MS$2 = 250;
|
|
77302
|
-
const NOTIFICATION_DRAIN_TIMEOUT_MS$2 = 2e3;
|
|
77303
|
-
const TRANSPORT$4 = "trae-acp";
|
|
77304
|
-
const sleep$7 = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
77305
|
-
const TRAE_GLOBAL_VALUE_FLAGS = new Set([
|
|
77306
|
-
"--config",
|
|
77307
|
-
"--permission-mode",
|
|
77308
|
-
"--profile",
|
|
77309
|
-
"-c",
|
|
77310
|
-
"-p"
|
|
77311
|
-
]);
|
|
77312
|
-
const isInlineTraeGlobalArg = (arg) => arg.startsWith("--config=") || arg.startsWith("--permission-mode=") || arg.startsWith("--profile=") || arg.startsWith("-c=") || arg.startsWith("-p=");
|
|
77313
|
-
/**
|
|
77314
|
-
* TRAE requires configuration flags before `acp serve`, while ACP Server flags
|
|
77315
|
-
* belong after it. Keep unknown/user server flags in their historical position
|
|
77316
|
-
* and move only the documented global flags plus their values.
|
|
77317
|
-
* @see https://docs.trae.cn/cli_agent-client-protocol
|
|
77318
|
-
*/
|
|
77319
|
-
const buildTraeAcpArgs = (args = []) => {
|
|
77320
|
-
const globalArgs = [];
|
|
77321
|
-
const serverArgs = [];
|
|
77322
|
-
for (let index = 0; index < args.length; index += 1) {
|
|
77323
|
-
const arg = args[index];
|
|
77324
|
-
if (TRAE_GLOBAL_VALUE_FLAGS.has(arg)) {
|
|
77325
|
-
globalArgs.push(arg);
|
|
77326
|
-
const value = args[index + 1];
|
|
77327
|
-
if (value !== void 0) {
|
|
77328
|
-
globalArgs.push(value);
|
|
77329
|
-
index += 1;
|
|
77330
|
-
}
|
|
77331
|
-
continue;
|
|
77332
|
-
}
|
|
77333
|
-
if (isInlineTraeGlobalArg(arg)) {
|
|
77334
|
-
globalArgs.push(arg);
|
|
77335
|
-
continue;
|
|
77336
|
-
}
|
|
77337
|
-
serverArgs.push(arg);
|
|
77338
|
-
}
|
|
77339
|
-
return [
|
|
77340
|
-
...globalArgs,
|
|
77341
|
-
"acp",
|
|
77342
|
-
"serve",
|
|
77343
|
-
"--yolo",
|
|
77344
|
-
...serverArgs
|
|
77345
|
-
];
|
|
77346
|
-
};
|
|
77347
|
-
const buildTraeAcpPrompt = async (prompt, options = {}) => {
|
|
77348
|
-
const blocks = typeof prompt === "string" ? [{
|
|
77349
|
-
text: prompt,
|
|
77350
|
-
type: "text"
|
|
77351
|
-
}] : prompt;
|
|
77352
|
-
const result = [];
|
|
77353
|
-
for (const block of blocks) if (block.type === "text") result.push({
|
|
77354
|
-
text: block.text,
|
|
77355
|
-
type: "text"
|
|
77356
|
-
});
|
|
77357
|
-
else {
|
|
77358
|
-
const image = await normalizeImage(block.source, options);
|
|
77359
|
-
result.push({
|
|
77360
|
-
data: image.buffer.toString("base64"),
|
|
77361
|
-
mimeType: image.mediaType,
|
|
77362
|
-
type: "image"
|
|
77363
|
-
});
|
|
77364
|
-
}
|
|
77365
|
-
return result;
|
|
77366
|
-
};
|
|
77367
|
-
const toTraeModel = (id, name) => ({
|
|
77368
|
-
id,
|
|
77369
|
-
...typeof name === "string" && name && name !== id ? { label: name } : {},
|
|
77370
|
-
modelId: id,
|
|
77371
|
-
providerId: "trae"
|
|
77372
|
-
});
|
|
77373
|
-
const parseConfigOptionModels$1 = (options) => {
|
|
77374
|
-
if (!Array.isArray(options)) return [];
|
|
77375
|
-
const values = options.flatMap((value) => {
|
|
77376
|
-
const option = value;
|
|
77377
|
-
return Array.isArray(option?.options) ? option.options : [value];
|
|
77378
|
-
});
|
|
77379
|
-
const seen = /* @__PURE__ */ new Set();
|
|
77380
|
-
const models = [];
|
|
77381
|
-
for (const value of values) {
|
|
77382
|
-
const option = value;
|
|
77383
|
-
if (typeof option?.value !== "string" || !option.value || seen.has(option.value)) continue;
|
|
77384
|
-
seen.add(option.value);
|
|
77385
|
-
models.push(toTraeModel(option.value, option.name));
|
|
77386
|
-
}
|
|
77387
|
-
return models;
|
|
77388
|
-
};
|
|
77389
|
-
/**
|
|
77390
|
-
* Read model selection from the current stable ACP config-options API, with a
|
|
77391
|
-
* compatibility fallback for the never-stabilized dedicated model API still
|
|
77392
|
-
* exposed by older TRAE CLI builds.
|
|
77393
|
-
*/
|
|
77394
|
-
const parseTraeAcpModelCatalog = (result) => {
|
|
77395
|
-
const selectableOptions = (Array.isArray(result?.configOptions) ? result.configOptions.map((value) => value) : []).filter((option) => option?.type === void 0 || option.type === "select");
|
|
77396
|
-
const modelConfig = selectableOptions.find((option) => option?.category === "model") ?? selectableOptions.find((option) => option?.id === "model") ?? selectableOptions.find((option) => typeof option?.name === "string" && option.name.toLowerCase() === "model");
|
|
77397
|
-
if (modelConfig && typeof modelConfig.id === "string" && modelConfig.id) return {
|
|
77398
|
-
configId: modelConfig.id,
|
|
77399
|
-
currentModelId: typeof modelConfig.currentValue === "string" ? modelConfig.currentValue : void 0,
|
|
77400
|
-
models: parseConfigOptionModels$1(modelConfig.options),
|
|
77401
|
-
protocol: "config-option"
|
|
77402
|
-
};
|
|
77403
|
-
if (!Array.isArray(result?.models?.availableModels)) return;
|
|
77404
|
-
const seen = /* @__PURE__ */ new Set();
|
|
77405
|
-
const models = [];
|
|
77406
|
-
for (const value of result.models.availableModels) {
|
|
77407
|
-
const option = value;
|
|
77408
|
-
if (typeof option?.modelId !== "string" || !option.modelId || seen.has(option.modelId)) continue;
|
|
77409
|
-
seen.add(option.modelId);
|
|
77410
|
-
models.push(toTraeModel(option.modelId, option.name));
|
|
77411
|
-
}
|
|
77412
|
-
return {
|
|
77413
|
-
currentModelId: typeof result.models.currentModelId === "string" ? result.models.currentModelId : void 0,
|
|
77414
|
-
models,
|
|
77415
|
-
protocol: "legacy-model"
|
|
77416
|
-
};
|
|
77417
|
-
};
|
|
77418
|
-
/** TRAE's ACP v1 lifecycle: model config-options and legacy model API on the shared base. */
|
|
77419
|
-
var TraeAcpSession = class TraeAcpSession extends AcpAgentSession {
|
|
77420
|
-
acceptUpdates = false;
|
|
77421
|
-
lastSessionUpdateAt = 0;
|
|
77422
|
-
modelDiscovery;
|
|
77423
|
-
resolvedPrompt = [];
|
|
77424
|
-
constructor(options) {
|
|
77425
|
-
super(options, {
|
|
77426
|
-
args: buildTraeAcpArgs(options.args),
|
|
77427
|
-
pipeline: { agentType: "trae" },
|
|
77428
|
-
processLabel: "TRAE ACP",
|
|
77429
|
-
transport: TRANSPORT$4
|
|
77430
|
-
});
|
|
77431
|
-
}
|
|
77432
|
-
get nativeSessionId() {
|
|
77433
|
-
return this.acpSessionId;
|
|
77434
|
-
}
|
|
77435
|
-
/** Create a short-lived ACP session and read its agent-provided model selector. */
|
|
77436
|
-
async discoverModels() {
|
|
77437
|
-
return (await this.discoverModelCatalog()).models;
|
|
77438
|
-
}
|
|
77439
|
-
async prepareRun() {
|
|
77440
|
-
this.resolvedPrompt = await this.resolvePrompt();
|
|
77441
|
-
}
|
|
77442
|
-
buildInitializeParams() {
|
|
77443
|
-
return {
|
|
77444
|
-
clientCapabilities: {},
|
|
77445
|
-
clientInfo: {
|
|
77446
|
-
name: "lobehub",
|
|
77447
|
-
title: "LobeHub",
|
|
77448
|
-
version: this.options.clientVersion
|
|
77449
|
-
},
|
|
77450
|
-
protocolVersion: 1
|
|
77451
|
-
};
|
|
77452
|
-
}
|
|
77453
|
-
validateInitialized(initialized) {
|
|
77454
|
-
if (typeof initialized?.protocolVersion === "number" && initialized.protocolVersion !== 1) throw new Error(`TRAE ACP returned unsupported protocol version: ${initialized.protocolVersion}`);
|
|
77455
|
-
}
|
|
77456
|
-
async establishSession(initialized) {
|
|
77457
|
-
if (this.resolvedPrompt.some((block) => block.type === "image") && initialized?.agentCapabilities?.promptCapabilities?.image !== true) throw new Error("TRAE ACP agent does not support image prompt blocks");
|
|
77458
|
-
if (this.options.resumeSessionId && initialized?.agentCapabilities?.loadSession !== true) throw new Error("TRAE ACP agent does not support loading sessions");
|
|
77459
|
-
const sessionResult = await this.client.request(this.options.resumeSessionId ? "session/load" : "session/new", {
|
|
77460
|
-
cwd: this.options.cwd,
|
|
77461
|
-
mcpServers: [],
|
|
77462
|
-
...this.options.resumeSessionId ? { sessionId: this.options.resumeSessionId } : {}
|
|
77463
|
-
});
|
|
77464
|
-
const sessionId = sessionResult?.sessionId ?? this.options.resumeSessionId;
|
|
77465
|
-
if (!sessionId) throw new Error("TRAE ACP returned no session id");
|
|
77466
|
-
this.acpSessionId = sessionId;
|
|
77467
|
-
this.options.onSessionId(sessionId);
|
|
77468
|
-
const model = await this.applyInitialModel(sessionId, sessionResult);
|
|
77469
|
-
if (model) {
|
|
77470
|
-
this.pipeline.configureSession({ model });
|
|
77471
|
-
this.options.onModel?.(model);
|
|
77472
|
-
}
|
|
77473
|
-
await this.pushToPipeline({
|
|
77474
|
-
model,
|
|
77475
|
-
sessionId,
|
|
77476
|
-
type: "trae_session"
|
|
77477
|
-
});
|
|
77478
|
-
return sessionId;
|
|
77479
|
-
}
|
|
77480
|
-
onBeforePrompt() {
|
|
77481
|
-
this.acceptUpdates = true;
|
|
77482
|
-
}
|
|
77483
|
-
buildPromptParams(sessionId) {
|
|
77484
|
-
return {
|
|
77485
|
-
prompt: this.resolvedPrompt,
|
|
77486
|
-
sessionId
|
|
77487
|
-
};
|
|
77488
|
-
}
|
|
77489
|
-
async settlePrompt(result) {
|
|
77490
|
-
await this.drainNotifications();
|
|
77491
|
-
await this.client.drain();
|
|
77492
|
-
await this.pushToPipeline({
|
|
77493
|
-
stopReason: result?.stopReason,
|
|
77494
|
-
type: "trae_prompt_completed"
|
|
77495
|
-
});
|
|
77496
|
-
}
|
|
77497
|
-
async onRunFailure(error) {
|
|
77498
|
-
await this.pushToPipeline({
|
|
77499
|
-
message: error.message,
|
|
77500
|
-
type: "trae_error"
|
|
77501
|
-
});
|
|
77502
|
-
await this.emitEvents(await this.pipeline.flush());
|
|
77503
|
-
}
|
|
77504
|
-
async onRunCancelled() {
|
|
77505
|
-
await this.pushToPipeline({
|
|
77506
|
-
stopReason: "cancelled",
|
|
77507
|
-
type: "trae_prompt_completed"
|
|
77508
|
-
});
|
|
77509
|
-
}
|
|
77510
|
-
onHostClose() {
|
|
77511
|
-
this.modelDiscovery?.close();
|
|
77512
|
-
}
|
|
77513
|
-
async handleAgentMessage(message) {
|
|
77514
|
-
if (message.method !== "session/update") return;
|
|
77515
|
-
if (!this.acceptUpdates) return;
|
|
77516
|
-
this.lastSessionUpdateAt = Date.now();
|
|
77517
|
-
const update = message.params?.update;
|
|
77518
|
-
if (!update || typeof update !== "object") return;
|
|
77519
|
-
if (update.sessionUpdate === "config_option_update") {
|
|
77520
|
-
const catalog = parseTraeAcpModelCatalog({ configOptions: update.configOptions });
|
|
77521
|
-
if (catalog?.currentModelId) {
|
|
77522
|
-
this.pipeline.configureSession({ model: catalog.currentModelId });
|
|
77523
|
-
this.options.onModel?.(catalog.currentModelId);
|
|
77524
|
-
}
|
|
77525
|
-
}
|
|
77526
|
-
await this.pushToPipeline(update);
|
|
77527
|
-
}
|
|
77528
|
-
handleServerRequest(message) {
|
|
77529
|
-
if (message.method === "session/request_permission") {
|
|
77530
|
-
const optionId = selectAcpPermissionOption(message.params, [
|
|
77531
|
-
(option) => option.optionId === "allow_session" || option.optionId === "approve_for_session",
|
|
77532
|
-
(option) => option.kind === "allow_once",
|
|
77533
|
-
(option) => option.kind === "reject_once"
|
|
77534
|
-
]);
|
|
77535
|
-
if (optionId) return { outcome: {
|
|
77536
|
-
optionId,
|
|
77537
|
-
outcome: "selected"
|
|
77538
|
-
} };
|
|
77539
|
-
throw new AcpServerRequestError(-32603, "No safe permission option was offered");
|
|
77540
|
-
}
|
|
77541
|
-
throw new AcpServerRequestError(-32601, `Unsupported ACP client request: ${message.method}`);
|
|
77542
|
-
}
|
|
77543
|
-
async discoverModelCatalog() {
|
|
77544
|
-
try {
|
|
77545
|
-
const initialized = await this.initializeConnection();
|
|
77546
|
-
const sessionResult = await this.client.request("session/new", {
|
|
77547
|
-
cwd: this.options.cwd,
|
|
77548
|
-
mcpServers: []
|
|
77549
|
-
});
|
|
77550
|
-
if (!sessionResult?.sessionId) throw new Error("TRAE ACP returned no session id");
|
|
77551
|
-
const catalog = parseTraeAcpModelCatalog(sessionResult);
|
|
77552
|
-
if (!catalog) throw new Error("TRAE ACP did not expose a model configuration option");
|
|
77553
|
-
if (initialized?.agentCapabilities?.sessionCapabilities?.close) await this.client.request("session/close", { sessionId: sessionResult.sessionId });
|
|
77554
|
-
return catalog;
|
|
77555
|
-
} finally {
|
|
77556
|
-
this.client.close();
|
|
77557
|
-
}
|
|
77558
|
-
}
|
|
77559
|
-
async resolvePrompt() {
|
|
77560
|
-
const prompt = this.options.prompt;
|
|
77561
|
-
if (Array.isArray(prompt) && prompt.every((block) => "type" in block && (block.type === "text" || "data" in block && block.type === "image"))) return prompt;
|
|
77562
|
-
return buildTraeAcpPrompt(prompt, this.options.inputOptions);
|
|
77563
|
-
}
|
|
77564
|
-
async applyInitialModel(sessionId, sessionResult) {
|
|
77565
|
-
let catalog = parseTraeAcpModelCatalog(sessionResult);
|
|
77566
|
-
const requestedModel = this.options.initialModel?.trim();
|
|
77567
|
-
if (!requestedModel || requestedModel === "default") return catalog?.currentModelId;
|
|
77568
|
-
if (!catalog && this.options.resumeSessionId) catalog = await this.discoverResumeModelCatalog();
|
|
77569
|
-
if (!catalog) throw new Error("TRAE ACP did not expose a model configuration option");
|
|
77570
|
-
const selected = catalog.models.find((model) => model.id === requestedModel || model.label === requestedModel);
|
|
77571
|
-
if (!selected) throw new Error(`TRAE ACP model is unavailable: ${requestedModel}`);
|
|
77572
|
-
if (catalog.protocol === "config-option") return parseTraeAcpModelCatalog({ configOptions: (await this.client.request("session/set_config_option", {
|
|
77573
|
-
configId: catalog.configId,
|
|
77574
|
-
sessionId,
|
|
77575
|
-
value: selected.id
|
|
77576
|
-
}))?.configOptions })?.currentModelId ?? selected.id;
|
|
77577
|
-
await this.client.request("session/set_model", {
|
|
77578
|
-
modelId: selected.id,
|
|
77579
|
-
sessionId
|
|
77580
|
-
});
|
|
77581
|
-
return selected.id;
|
|
77582
|
-
}
|
|
77583
|
-
async discoverResumeModelCatalog() {
|
|
77584
|
-
const discovery = new TraeAcpSession({
|
|
77585
|
-
...this.options,
|
|
77586
|
-
initialModel: void 0,
|
|
77587
|
-
onEvents: () => {},
|
|
77588
|
-
onModel: void 0,
|
|
77589
|
-
onRuntimeStatus: () => {},
|
|
77590
|
-
onSessionId: () => {},
|
|
77591
|
-
operationId: `${this.options.operationId}-model-discovery`,
|
|
77592
|
-
prompt: "",
|
|
77593
|
-
resumeSessionId: void 0,
|
|
77594
|
-
sessionId: `${this.options.sessionId}-model-discovery`
|
|
77595
|
-
});
|
|
77596
|
-
this.modelDiscovery = discovery;
|
|
77597
|
-
try {
|
|
77598
|
-
return await discovery.discoverModelCatalog();
|
|
77599
|
-
} finally {
|
|
77600
|
-
discovery.close();
|
|
77601
|
-
if (this.modelDiscovery === discovery) this.modelDiscovery = void 0;
|
|
77602
|
-
}
|
|
77603
|
-
}
|
|
77604
|
-
async drainNotifications() {
|
|
77605
|
-
const deadline = Date.now() + NOTIFICATION_DRAIN_TIMEOUT_MS$2;
|
|
77606
|
-
let quietSince = Date.now();
|
|
77607
|
-
while (Date.now() < deadline) {
|
|
77608
|
-
await sleep$7(Math.min(NOTIFICATION_DRAIN_QUIET_MS$2, deadline - Date.now()));
|
|
77609
|
-
await this.client.drain();
|
|
77610
|
-
if (this.lastSessionUpdateAt > quietSince) {
|
|
77611
|
-
quietSince = this.lastSessionUpdateAt;
|
|
77612
|
-
continue;
|
|
77613
|
-
}
|
|
77614
|
-
if (Date.now() - quietSince >= NOTIFICATION_DRAIN_QUIET_MS$2) return;
|
|
77615
|
-
}
|
|
77616
|
-
}
|
|
77617
|
-
};
|
|
77618
|
-
const listTraeAcpModels = async (options) => new TraeAcpSession({
|
|
77619
|
-
args: options.args ?? [],
|
|
77620
|
-
clientVersion: options.clientVersion ?? "1.0.0",
|
|
77621
|
-
commandPath: options.commandPath,
|
|
77622
|
-
cwd: options.cwd,
|
|
77623
|
-
env: options.env,
|
|
77624
|
-
onEvents: () => {},
|
|
77625
|
-
onRawMessage: () => {},
|
|
77626
|
-
onRuntimeStatus: () => {},
|
|
77627
|
-
onSessionId: () => {},
|
|
77628
|
-
onStderr: () => {},
|
|
77629
|
-
operationId: "trae-model-discovery",
|
|
77630
|
-
prompt: "",
|
|
77631
|
-
requestTimeoutMs: options.timeoutMs,
|
|
77632
|
-
sessionId: "trae-model-discovery"
|
|
77633
|
-
}).discoverModels();
|
|
77634
|
-
|
|
77635
77565
|
//#endregion
|
|
77636
77566
|
//#region ../../packages/heterogeneous-agents/src/spawn/copilotAcpSession.ts
|
|
77637
77567
|
init_object$1();
|
|
@@ -80034,7 +79964,7 @@ const resolveHeteroSpawnCwd = (workDir) => [
|
|
|
80034
79964
|
init_config();
|
|
80035
79965
|
init_cliSpawn();
|
|
80036
79966
|
/**
|
|
80037
|
-
* ACP runtimes (Cursor, Devin, Droid, Grok, TRAE) behind the ordinary
|
|
79967
|
+
* ACP runtimes (Antigravity, Cursor, Devin, Droid, Grok, TRAE) behind the ordinary
|
|
80038
79968
|
* `SpawnAgentHandle` contract returned by `spawnAgent`.
|
|
80039
79969
|
*/
|
|
80040
79970
|
/** Guarded raw-stdout tee: diagnostic sink failures must not affect the ACP run. */
|
|
@@ -80141,9 +80071,10 @@ const createAcpSpawnBridge = () => {
|
|
|
80141
80071
|
stderr
|
|
80142
80072
|
};
|
|
80143
80073
|
};
|
|
80144
|
-
const createAcpSpawnHandle = (bridge, session, getSessionId = () => session.sessionId) => {
|
|
80074
|
+
const createAcpSpawnHandle = (bridge, session, getSessionId = () => session.sessionId, extra = {}) => {
|
|
80145
80075
|
const { exit, interrupt, kill } = bridge.attach(session);
|
|
80146
80076
|
return {
|
|
80077
|
+
...extra,
|
|
80147
80078
|
events: bridge.events,
|
|
80148
80079
|
exit,
|
|
80149
80080
|
interrupt,
|
|
@@ -80157,6 +80088,39 @@ const createAcpSpawnHandle = (bridge, session, getSessionId = () => session.sess
|
|
|
80157
80088
|
stderr: bridge.stderr
|
|
80158
80089
|
};
|
|
80159
80090
|
};
|
|
80091
|
+
/**
|
|
80092
|
+
* Antigravity (`agy acp`): the handle also takes follow-ups mid-run
|
|
80093
|
+
* (`sendUserMessage`), which the session steers into the running turn.
|
|
80094
|
+
*/
|
|
80095
|
+
const spawnAntigravityAcpAgent = async (options, command, cwd) => {
|
|
80096
|
+
const prompt = await buildAntigravityAcpPrompt(options.prompt, options.inputOptions);
|
|
80097
|
+
const bridge = createAcpSpawnBridge();
|
|
80098
|
+
const session = new AntigravityAcpSession({
|
|
80099
|
+
args: options.extraArgs ?? [],
|
|
80100
|
+
clientVersion: "lobehub-cli",
|
|
80101
|
+
commandPath: command,
|
|
80102
|
+
cwd,
|
|
80103
|
+
detached: options.detached,
|
|
80104
|
+
env: getHeterogeneousAgentSpawnEnv("antigravity", options.env, process.env),
|
|
80105
|
+
onEvents: bridge.onEvents,
|
|
80106
|
+
onRawMessage: teeAcpRawStdout(options.onRawStdout),
|
|
80107
|
+
onRuntimeStatus: () => {},
|
|
80108
|
+
onSessionId: () => {},
|
|
80109
|
+
onStderr: bridge.onStderr,
|
|
80110
|
+
operationId: options.operationId,
|
|
80111
|
+
prompt,
|
|
80112
|
+
resumeSessionId: options.resumeSessionId,
|
|
80113
|
+
sessionId: options.operationId
|
|
80114
|
+
});
|
|
80115
|
+
return createAcpSpawnHandle(bridge, session, void 0, {
|
|
80116
|
+
sendUserMessage: async (followUp, sendOptions) => {
|
|
80117
|
+
if (!sendOptions?.uuid) return false;
|
|
80118
|
+
const blocks = await buildAntigravityAcpPrompt(followUp, options.inputOptions);
|
|
80119
|
+
return session.steer(blocks, sendOptions.uuid);
|
|
80120
|
+
},
|
|
80121
|
+
supportsSteerImageAttachments: true
|
|
80122
|
+
});
|
|
80123
|
+
};
|
|
80160
80124
|
const spawnGrokAcpAgent = async (options, command, cwd) => {
|
|
80161
80125
|
const prompt = await buildGrokAcpPrompt(options.prompt, options.inputOptions);
|
|
80162
80126
|
const bridge = createAcpSpawnBridge();
|
|
@@ -80502,7 +80466,6 @@ const buildQoderArgs = ({ extraArgs = [], inputArgs = [], resumeSessionId }) =>
|
|
|
80502
80466
|
];
|
|
80503
80467
|
const buildSpawnArgs = (params) => {
|
|
80504
80468
|
switch (params.agentType) {
|
|
80505
|
-
case "antigravity": return buildAntigravityArgs(params);
|
|
80506
80469
|
case "amp": return buildAmpArgs(params);
|
|
80507
80470
|
case "claude-code": return buildClaudeCodeArgs(params);
|
|
80508
80471
|
case "codebuddy": return buildCodeBuddyArgs(params);
|
|
@@ -80550,6 +80513,7 @@ const spawnAgent = async (options) => {
|
|
|
80550
80513
|
const command = resolveHeterogeneousAgentCommand(options.agentType, options.command);
|
|
80551
80514
|
const cwd = options.cwd || process.cwd();
|
|
80552
80515
|
assertSpawnableWorkingDirectory(cwd);
|
|
80516
|
+
if (options.agentType === "antigravity") return spawnAntigravityAcpAgent(options, command, cwd);
|
|
80553
80517
|
if (options.agentType === "copilot") return spawnCopilotAcpAgent(options, command, cwd);
|
|
80554
80518
|
if (options.agentType === "devin") return spawnDevinAcpAgent(options, command, cwd);
|
|
80555
80519
|
if (options.agentType === "grok-build") return spawnGrokAcpAgent(options, command, cwd);
|
|
@@ -80579,7 +80543,6 @@ const spawnAgent = async (options) => {
|
|
|
80579
80543
|
/** One-shot JSONL CLI spawn; `spawnAgent` owns the Codex JWT file around it. */
|
|
80580
80544
|
const spawnCliAgent = async (options, command, cwd, inputPlan, childEnv, codexJwtFile) => {
|
|
80581
80545
|
const claudeLiveInput = options.agentType === "claude-code" && options.liveInput === true;
|
|
80582
|
-
const antigravityLiveInput = options.agentType === "antigravity" && options.liveInput === true;
|
|
80583
80546
|
const permissionMode = options.agentType === "claude-code" ? options.permissionMode : void 0;
|
|
80584
80547
|
const permissionPrompts = claudeLiveInput && !!options.askUserBridge;
|
|
80585
80548
|
const args = buildSpawnArgs({
|
|
@@ -80618,15 +80581,10 @@ const spawnCliAgent = async (options, command, cwd, inputPlan, childEnv, codexJw
|
|
|
80618
80581
|
]
|
|
80619
80582
|
});
|
|
80620
80583
|
const claudeLive = claudeLiveInput && proc.stdin ? new ClaudeCodeLiveInput(proc.stdin) : void 0;
|
|
80621
|
-
const antigravityLive = antigravityLiveInput && proc.stdin ? new AntigravityLiveInput(proc.stdin) : void 0;
|
|
80622
|
-
const live = claudeLive ?? antigravityLive;
|
|
80623
80584
|
const pipeline = new AgentStreamPipeline({
|
|
80624
80585
|
adapter: claudeLive ? new ClaudeCodeAdapter({
|
|
80625
80586
|
runtimeEndStrategy: "on-transport-close",
|
|
80626
80587
|
signalBackgroundTaskCompletion: true
|
|
80627
|
-
}) : antigravityLive ? new AntigravityAdapter({
|
|
80628
|
-
runtimeEndStrategy: "on-transport-close",
|
|
80629
|
-
takeNextSteerUuid: () => antigravityLive.takeSteerUuid()
|
|
80630
80588
|
}) : void 0,
|
|
80631
80589
|
agentType: options.agentType,
|
|
80632
80590
|
cwd,
|
|
@@ -80692,7 +80650,7 @@ const spawnCliAgent = async (options, command, cwd, inputPlan, childEnv, codexJw
|
|
|
80692
80650
|
wake();
|
|
80693
80651
|
});
|
|
80694
80652
|
}
|
|
80695
|
-
if (
|
|
80653
|
+
if (claudeLive) claudeLive.send(inputPlan.stdin);
|
|
80696
80654
|
else if (proc.stdin) proc.stdin.write(inputPlan.stdin, () => {
|
|
80697
80655
|
proc.stdin?.end();
|
|
80698
80656
|
});
|
|
@@ -80715,7 +80673,7 @@ const spawnCliAgent = async (options, command, cwd, inputPlan, childEnv, codexJw
|
|
|
80715
80673
|
pipelineQueue = pipelineQueue.then(async () => {
|
|
80716
80674
|
try {
|
|
80717
80675
|
const events = await pipeline.flush();
|
|
80718
|
-
|
|
80676
|
+
claudeLive?.finish();
|
|
80719
80677
|
const { code, signal } = await exit;
|
|
80720
80678
|
if (code === 0 && !killedByUs) events.push(...pipeline.validateCompletion());
|
|
80721
80679
|
sawErrorEvent ||= events.some((event) => event.type === "error");
|
|
@@ -80725,11 +80683,6 @@ const spawnCliAgent = async (options, command, cwd, inputPlan, childEnv, codexJw
|
|
|
80725
80683
|
killedByHost: killedByUs,
|
|
80726
80684
|
sawError: sawErrorEvent,
|
|
80727
80685
|
signal
|
|
80728
|
-
}) : antigravityLive ? resolveAntigravityLiveRuntimeEnd(antigravityLive.lastTurn, {
|
|
80729
|
-
code,
|
|
80730
|
-
killedByHost: killedByUs,
|
|
80731
|
-
sawError: sawErrorEvent,
|
|
80732
|
-
signal
|
|
80733
80686
|
}) : void 0;
|
|
80734
80687
|
if (liveEnd) for (const event of pipeline.completeRuntime(liveEnd)) queue.push(event);
|
|
80735
80688
|
for (const event of await pipeline.collectPostRunUsage({ env: childEnv })) queue.push(event);
|
|
@@ -80745,7 +80698,7 @@ const spawnCliAgent = async (options, command, cwd, inputPlan, childEnv, codexJw
|
|
|
80745
80698
|
if (options.onRawStdout) try {
|
|
80746
80699
|
options.onRawStdout(chunk);
|
|
80747
80700
|
} catch {}
|
|
80748
|
-
|
|
80701
|
+
claudeLive?.observe(chunk);
|
|
80749
80702
|
enqueuePush(chunk);
|
|
80750
80703
|
});
|
|
80751
80704
|
stdout.on("end", enqueueFlush);
|
|
@@ -80800,14 +80753,9 @@ const spawnCliAgent = async (options, command, cwd, inputPlan, childEnv, codexJw
|
|
|
80800
80753
|
},
|
|
80801
80754
|
supportsSteerImageAttachments: true
|
|
80802
80755
|
},
|
|
80803
|
-
...antigravityLive && { sendUserMessage: async (prompt, sendOptions) => {
|
|
80804
|
-
if (!antigravityLive.isOpen) return false;
|
|
80805
|
-
const plan = await buildAgentInput("antigravity", prompt, options.inputOptions);
|
|
80806
|
-
return antigravityLive.send(plan.stdin, sendOptions?.uuid);
|
|
80807
|
-
} },
|
|
80808
80756
|
kill: (signal = "SIGINT") => {
|
|
80809
80757
|
killedByUs = true;
|
|
80810
|
-
|
|
80758
|
+
claudeLive?.close();
|
|
80811
80759
|
killProcessTree(proc, signal, detached);
|
|
80812
80760
|
},
|
|
80813
80761
|
pid: proc.pid,
|
|
@@ -276098,7 +276046,7 @@ function logForDebugging(message, options) {
|
|
|
276098
276046
|
var init_debug = __esmMin((() => {}));
|
|
276099
276047
|
|
|
276100
276048
|
//#endregion
|
|
276101
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
276049
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/forge.js
|
|
276102
276050
|
var require_forge = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
276103
276051
|
/**
|
|
276104
276052
|
* Node.js module for Forge.
|
|
@@ -276111,7 +276059,7 @@ var require_forge = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
276111
276059
|
}));
|
|
276112
276060
|
|
|
276113
276061
|
//#endregion
|
|
276114
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
276062
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/baseN.js
|
|
276115
276063
|
var require_baseN = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
276116
276064
|
/**
|
|
276117
276065
|
* Base-N/Base-X encoding/decoding functions.
|
|
@@ -276246,7 +276194,7 @@ var require_baseN = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
276246
276194
|
}));
|
|
276247
276195
|
|
|
276248
276196
|
//#endregion
|
|
276249
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
276197
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/util.js
|
|
276250
276198
|
var require_util$2 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
276251
276199
|
/**
|
|
276252
276200
|
* Utility functions for web applications.
|
|
@@ -277551,14 +277499,14 @@ var require_util$2 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
277551
277499
|
var chr1, chr2, chr3;
|
|
277552
277500
|
var i = 0;
|
|
277553
277501
|
while (i < input.length) {
|
|
277554
|
-
chr1 = input.charCodeAt(i++);
|
|
277502
|
+
chr1 = input.charCodeAt(i++) & 255;
|
|
277555
277503
|
chr2 = input.charCodeAt(i++);
|
|
277556
277504
|
chr3 = input.charCodeAt(i++);
|
|
277557
277505
|
line += _base64.charAt(chr1 >> 2);
|
|
277558
|
-
line += _base64.charAt((chr1 & 3) << 4 | chr2 >> 4);
|
|
277506
|
+
line += _base64.charAt((chr1 & 3) << 4 | (chr2 & 255) >> 4);
|
|
277559
277507
|
if (isNaN(chr2)) line += "==";
|
|
277560
277508
|
else {
|
|
277561
|
-
line += _base64.charAt((chr2 & 15) << 2 | chr3 >> 6);
|
|
277509
|
+
line += _base64.charAt((chr2 & 15) << 2 | (chr3 & 255) >> 6);
|
|
277562
277510
|
line += isNaN(chr3) ? "=" : _base64.charAt(chr3 & 63);
|
|
277563
277511
|
}
|
|
277564
277512
|
if (maxline && line.length > maxline) {
|
|
@@ -278359,7 +278307,7 @@ var require_util$2 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
278359
278307
|
}));
|
|
278360
278308
|
|
|
278361
278309
|
//#endregion
|
|
278362
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
278310
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/cipher.js
|
|
278363
278311
|
var require_cipher = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
278364
278312
|
/**
|
|
278365
278313
|
* Cipher base API.
|
|
@@ -278541,7 +278489,7 @@ var require_cipher = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
278541
278489
|
}));
|
|
278542
278490
|
|
|
278543
278491
|
//#endregion
|
|
278544
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
278492
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/cipherModes.js
|
|
278545
278493
|
var require_cipherModes = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
278546
278494
|
/**
|
|
278547
278495
|
* Supported cipher modes.
|
|
@@ -279147,7 +279095,7 @@ var require_cipherModes = /* @__PURE__ */ __commonJSMin$2(((exports, module) =>
|
|
|
279147
279095
|
}));
|
|
279148
279096
|
|
|
279149
279097
|
//#endregion
|
|
279150
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
279098
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/aes.js
|
|
279151
279099
|
var require_aes = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
279152
279100
|
/**
|
|
279153
279101
|
* Advanced Encryption Standard (AES) implementation.
|
|
@@ -279738,7 +279686,7 @@ var require_aes = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
279738
279686
|
}));
|
|
279739
279687
|
|
|
279740
279688
|
//#endregion
|
|
279741
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
279689
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/oids.js
|
|
279742
279690
|
var require_oids = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
279743
279691
|
/**
|
|
279744
279692
|
* Object IDs for ASN.1.
|
|
@@ -279889,7 +279837,7 @@ var require_oids = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
279889
279837
|
}));
|
|
279890
279838
|
|
|
279891
279839
|
//#endregion
|
|
279892
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
279840
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/asn1.js
|
|
279893
279841
|
var require_asn1 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
279894
279842
|
/**
|
|
279895
279843
|
* Javascript implementation of Abstract Syntax Notation Number One.
|
|
@@ -280859,7 +280807,7 @@ var require_asn1 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
280859
280807
|
}));
|
|
280860
280808
|
|
|
280861
280809
|
//#endregion
|
|
280862
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
280810
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/md.js
|
|
280863
280811
|
var require_md = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
280864
280812
|
/**
|
|
280865
280813
|
* Node.js module for Forge message digests.
|
|
@@ -280874,7 +280822,7 @@ var require_md = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
280874
280822
|
}));
|
|
280875
280823
|
|
|
280876
280824
|
//#endregion
|
|
280877
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
280825
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/hmac.js
|
|
280878
280826
|
var require_hmac = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
280879
280827
|
/**
|
|
280880
280828
|
* Hash-based Message Authentication Code implementation. Requires a message
|
|
@@ -280976,7 +280924,7 @@ var require_hmac = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
280976
280924
|
}));
|
|
280977
280925
|
|
|
280978
280926
|
//#endregion
|
|
280979
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
280927
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/md5.js
|
|
280980
280928
|
var require_md5 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
280981
280929
|
/**
|
|
280982
280930
|
* Message Digest Algorithm 5 with 128-bit digest (MD5) implementation.
|
|
@@ -281295,7 +281243,7 @@ var require_md5 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
281295
281243
|
}));
|
|
281296
281244
|
|
|
281297
281245
|
//#endregion
|
|
281298
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
281246
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/pem.js
|
|
281299
281247
|
var require_pem = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
281300
281248
|
/**
|
|
281301
281249
|
* Javascript implementation of basic PEM (Privacy Enhanced Mail) algorithms.
|
|
@@ -281592,7 +281540,7 @@ var require_pem = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
281592
281540
|
}));
|
|
281593
281541
|
|
|
281594
281542
|
//#endregion
|
|
281595
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
281543
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/des.js
|
|
281596
281544
|
var require_des = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
281597
281545
|
/**
|
|
281598
281546
|
* DES (Data Encryption Standard) implementation.
|
|
@@ -282773,7 +282721,7 @@ var require_des = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
282773
282721
|
}));
|
|
282774
282722
|
|
|
282775
282723
|
//#endregion
|
|
282776
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
282724
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/pbkdf2.js
|
|
282777
282725
|
var require_pbkdf2 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
282778
282726
|
/**
|
|
282779
282727
|
* Password-Based Key-Derivation Function #2 implementation.
|
|
@@ -282892,7 +282840,7 @@ var require_pbkdf2 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
282892
282840
|
}));
|
|
282893
282841
|
|
|
282894
282842
|
//#endregion
|
|
282895
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
282843
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/sha256.js
|
|
282896
282844
|
var require_sha256 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
282897
282845
|
/**
|
|
282898
282846
|
* Secure Hash Algorithm with 256-bit digest (SHA-256) implementation.
|
|
@@ -283154,7 +283102,7 @@ var require_sha256 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
283154
283102
|
}));
|
|
283155
283103
|
|
|
283156
283104
|
//#endregion
|
|
283157
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
283105
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/prng.js
|
|
283158
283106
|
var require_prng = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
283159
283107
|
/**
|
|
283160
283108
|
* A javascript implementation of a cryptographically-secure
|
|
@@ -283363,11 +283311,11 @@ var require_prng = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
283363
283311
|
ctx.seedFile = function(needed, callback) {
|
|
283364
283312
|
_crypto.randomBytes(needed, function(err, bytes) {
|
|
283365
283313
|
if (err) return callback(err);
|
|
283366
|
-
callback(null, bytes.toString());
|
|
283314
|
+
callback(null, bytes.toString("binary"));
|
|
283367
283315
|
});
|
|
283368
283316
|
};
|
|
283369
283317
|
ctx.seedFileSync = function(needed) {
|
|
283370
|
-
return _crypto.randomBytes(needed).toString();
|
|
283318
|
+
return _crypto.randomBytes(needed).toString("binary");
|
|
283371
283319
|
};
|
|
283372
283320
|
} else {
|
|
283373
283321
|
ctx.seedFile = function(needed, callback) {
|
|
@@ -283440,7 +283388,7 @@ var require_prng = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
283440
283388
|
}));
|
|
283441
283389
|
|
|
283442
283390
|
//#endregion
|
|
283443
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
283391
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/random.js
|
|
283444
283392
|
var require_random = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
283445
283393
|
/**
|
|
283446
283394
|
* An API for getting cryptographically-secure random bytes. The bytes are
|
|
@@ -283574,7 +283522,7 @@ var require_random = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
283574
283522
|
}));
|
|
283575
283523
|
|
|
283576
283524
|
//#endregion
|
|
283577
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
283525
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/rc2.js
|
|
283578
283526
|
var require_rc2 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
283579
283527
|
/**
|
|
283580
283528
|
* RC2 implementation.
|
|
@@ -283893,7 +283841,7 @@ var require_rc2 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
283893
283841
|
var T = key.length();
|
|
283894
283842
|
var T1 = effKeyBits;
|
|
283895
283843
|
var T8 = Math.ceil(T1 / 8);
|
|
283896
|
-
var TM = 255 >> (T1 & 7);
|
|
283844
|
+
var TM = 255 >> (-T1 & 7);
|
|
283897
283845
|
var i;
|
|
283898
283846
|
for (i = T; i < 128; i++) L.putByte(piTable[L.at(i - 1) + L.at(i - T) & 255]);
|
|
283899
283847
|
L.setAt(128 - T8, piTable[L.at(128 - T8) & TM]);
|
|
@@ -284131,9 +284079,10 @@ var require_rc2 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
284131
284079
|
}));
|
|
284132
284080
|
|
|
284133
284081
|
//#endregion
|
|
284134
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
284082
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/jsbn.js
|
|
284135
284083
|
var require_jsbn = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
284136
284084
|
var forge = require_forge();
|
|
284085
|
+
require_util$2();
|
|
284137
284086
|
module.exports = forge.jsbn = forge.jsbn || {};
|
|
284138
284087
|
var dbits;
|
|
284139
284088
|
var j_lm = true;
|
|
@@ -284179,7 +284128,7 @@ var require_jsbn = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
284179
284128
|
}
|
|
284180
284129
|
return c;
|
|
284181
284130
|
}
|
|
284182
|
-
if (
|
|
284131
|
+
if (forge.util.isNodejs) {
|
|
284183
284132
|
BigInteger.prototype.am = am3;
|
|
284184
284133
|
dbits = 28;
|
|
284185
284134
|
} else if (j_lm && navigator.appName == "Microsoft Internet Explorer") {
|
|
@@ -285462,7 +285411,7 @@ var require_jsbn = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
285462
285411
|
}));
|
|
285463
285412
|
|
|
285464
285413
|
//#endregion
|
|
285465
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
285414
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/sha1.js
|
|
285466
285415
|
var require_sha1 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
285467
285416
|
/**
|
|
285468
285417
|
* Secure Hash Algorithm with 160-bit digest (SHA-1) implementation.
|
|
@@ -285687,7 +285636,7 @@ var require_sha1 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
285687
285636
|
}));
|
|
285688
285637
|
|
|
285689
285638
|
//#endregion
|
|
285690
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
285639
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/pkcs1.js
|
|
285691
285640
|
var require_pkcs1 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
285692
285641
|
/**
|
|
285693
285642
|
* Partial implementation of PKCS#1 v2.2: RSA-OEAP
|
|
@@ -285881,7 +285830,7 @@ var require_pkcs1 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
285881
285830
|
}));
|
|
285882
285831
|
|
|
285883
285832
|
//#endregion
|
|
285884
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
285833
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/prime.js
|
|
285885
285834
|
var require_prime = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
285886
285835
|
/**
|
|
285887
285836
|
* Prime number generation API.
|
|
@@ -286068,7 +286017,7 @@ var require_prime = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
286068
286017
|
}));
|
|
286069
286018
|
|
|
286070
286019
|
//#endregion
|
|
286071
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
286020
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/rsa.js
|
|
286072
286021
|
var require_rsa = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
286073
286022
|
/**
|
|
286074
286023
|
* Javascript implementation of basic RSA algorithms.
|
|
@@ -287070,6 +287019,7 @@ var require_rsa = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
287070
287019
|
error.errors = errors;
|
|
287071
287020
|
throw error;
|
|
287072
287021
|
}
|
|
287022
|
+
if (capture.privateKeyVersion !== "\0" || obj.value.length !== 9) throw new Error("Cannot read private key. Only two-prime RSAPrivateKey version 0 is supported.");
|
|
287073
287023
|
var n = forge.util.createBuffer(capture.privateKeyModulus).toHex(), e = forge.util.createBuffer(capture.privateKeyPublicExponent).toHex(), d = forge.util.createBuffer(capture.privateKeyPrivateExponent).toHex(), p = forge.util.createBuffer(capture.privateKeyPrime1).toHex(), q = forge.util.createBuffer(capture.privateKeyPrime2).toHex(), dP = forge.util.createBuffer(capture.privateKeyExponent1).toHex(), dQ = forge.util.createBuffer(capture.privateKeyExponent2).toHex(), qInv = forge.util.createBuffer(capture.privateKeyCoefficient).toHex();
|
|
287074
287024
|
return pki.setRsaPrivateKey(new BigInteger(n, 16), new BigInteger(e, 16), new BigInteger(d, 16), new BigInteger(p, 16), new BigInteger(q, 16), new BigInteger(dP, 16), new BigInteger(dQ, 16), new BigInteger(qInv, 16));
|
|
287075
287025
|
};
|
|
@@ -287387,7 +287337,7 @@ var require_rsa = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
287387
287337
|
}));
|
|
287388
287338
|
|
|
287389
287339
|
//#endregion
|
|
287390
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
287340
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/pbe.js
|
|
287391
287341
|
var require_pbe = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
287392
287342
|
/**
|
|
287393
287343
|
* Password-based encryption functions.
|
|
@@ -288189,7 +288139,7 @@ var require_pbe = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
288189
288139
|
}));
|
|
288190
288140
|
|
|
288191
288141
|
//#endregion
|
|
288192
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
288142
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/pkcs7asn1.js
|
|
288193
288143
|
var require_pkcs7asn1 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
288194
288144
|
/**
|
|
288195
288145
|
* Javascript implementation of ASN.1 validators for PKCS#7 v1.5.
|
|
@@ -288589,7 +288539,7 @@ var require_pkcs7asn1 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
288589
288539
|
}));
|
|
288590
288540
|
|
|
288591
288541
|
//#endregion
|
|
288592
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
288542
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/mgf1.js
|
|
288593
288543
|
var require_mgf1 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
288594
288544
|
/**
|
|
288595
288545
|
* Javascript implementation of mask generation function MGF1.
|
|
@@ -288637,7 +288587,7 @@ generate: function(seed, maskLen) {
|
|
|
288637
288587
|
}));
|
|
288638
288588
|
|
|
288639
288589
|
//#endregion
|
|
288640
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
288590
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/mgf.js
|
|
288641
288591
|
var require_mgf = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
288642
288592
|
/**
|
|
288643
288593
|
* Node.js module for Forge mask generation functions.
|
|
@@ -288653,7 +288603,7 @@ var require_mgf = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
288653
288603
|
}));
|
|
288654
288604
|
|
|
288655
288605
|
//#endregion
|
|
288656
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
288606
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/pss.js
|
|
288657
288607
|
var require_pss = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
288658
288608
|
/**
|
|
288659
288609
|
* Javascript implementation of PKCS#1 PSS signature padding.
|
|
@@ -288789,7 +288739,7 @@ var require_pss = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
288789
288739
|
}));
|
|
288790
288740
|
|
|
288791
288741
|
//#endregion
|
|
288792
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
288742
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/x509.js
|
|
288793
288743
|
var require_x509 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
288794
288744
|
/**
|
|
288795
288745
|
* Javascript implementation of X.509 and related components (such as
|
|
@@ -291446,7 +291396,7 @@ var require_x509 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
291446
291396
|
}));
|
|
291447
291397
|
|
|
291448
291398
|
//#endregion
|
|
291449
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
291399
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/pkcs12.js
|
|
291450
291400
|
var require_pkcs12 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
291451
291401
|
/**
|
|
291452
291402
|
* Javascript implementation of PKCS#12.
|
|
@@ -292191,7 +292141,7 @@ var require_pkcs12 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
292191
292141
|
}));
|
|
292192
292142
|
|
|
292193
292143
|
//#endregion
|
|
292194
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
292144
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/pki.js
|
|
292195
292145
|
var require_pki = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
292196
292146
|
/**
|
|
292197
292147
|
* Javascript implementation of a basic Public Key Infrastructure, including
|
|
@@ -292279,7 +292229,7 @@ var require_pki = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
292279
292229
|
}));
|
|
292280
292230
|
|
|
292281
292231
|
//#endregion
|
|
292282
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
292232
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/tls.js
|
|
292283
292233
|
var require_tls = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
292284
292234
|
/**
|
|
292285
292235
|
* A Javascript implementation of Transport Layer Security (TLS).
|
|
@@ -295968,7 +295918,7 @@ var require_tls = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
295968
295918
|
}));
|
|
295969
295919
|
|
|
295970
295920
|
//#endregion
|
|
295971
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
295921
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/aesCipherSuites.js
|
|
295972
295922
|
var require_aesCipherSuites = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
295973
295923
|
/**
|
|
295974
295924
|
* A Javascript implementation of AES Cipher Suites for TLS.
|
|
@@ -296158,7 +296108,7 @@ var require_aesCipherSuites = /* @__PURE__ */ __commonJSMin$2(((exports, module)
|
|
|
296158
296108
|
}));
|
|
296159
296109
|
|
|
296160
296110
|
//#endregion
|
|
296161
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
296111
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/sha512.js
|
|
296162
296112
|
var require_sha512 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
296163
296113
|
/**
|
|
296164
296114
|
* Secure Hash Algorithm with a 1024-bit block size implementation.
|
|
@@ -296566,7 +296516,7 @@ var require_sha512 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
296566
296516
|
}));
|
|
296567
296517
|
|
|
296568
296518
|
//#endregion
|
|
296569
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
296519
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/asn1-validator.js
|
|
296570
296520
|
var require_asn1_validator = /* @__PURE__ */ __commonJSMin$2(((exports) => {
|
|
296571
296521
|
/**
|
|
296572
296522
|
* Copyright (c) 2019 Digital Bazaar, Inc.
|
|
@@ -296638,7 +296588,7 @@ var require_asn1_validator = /* @__PURE__ */ __commonJSMin$2(((exports) => {
|
|
|
296638
296588
|
}));
|
|
296639
296589
|
|
|
296640
296590
|
//#endregion
|
|
296641
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
296591
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/ed25519.js
|
|
296642
296592
|
var require_ed25519 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
296643
296593
|
/**
|
|
296644
296594
|
* JavaScript implementation of Ed25519.
|
|
@@ -297675,7 +297625,7 @@ var require_ed25519 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
297675
297625
|
}));
|
|
297676
297626
|
|
|
297677
297627
|
//#endregion
|
|
297678
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
297628
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/kem.js
|
|
297679
297629
|
var require_kem = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
297680
297630
|
/**
|
|
297681
297631
|
* Javascript implementation of RSA-KEM.
|
|
@@ -297815,7 +297765,7 @@ var require_kem = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
297815
297765
|
}));
|
|
297816
297766
|
|
|
297817
297767
|
//#endregion
|
|
297818
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
297768
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/log.js
|
|
297819
297769
|
var require_log = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
297820
297770
|
/**
|
|
297821
297771
|
* Cross-browser support for logging in a web application.
|
|
@@ -298041,7 +297991,7 @@ var require_log = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
298041
297991
|
forge.log.addLogger(logger);
|
|
298042
297992
|
sConsoleLogger = logger;
|
|
298043
297993
|
} else console = { log: function() {} };
|
|
298044
|
-
if (sConsoleLogger !== null && typeof window !== "undefined" && window.location) {
|
|
297994
|
+
if (sConsoleLogger !== null && typeof window !== "undefined" && window.location && window.location.href && typeof URL === "function") {
|
|
298045
297995
|
var query = new URL(window.location.href).searchParams;
|
|
298046
297996
|
if (query.has("console.level")) forge.log.setLevel(sConsoleLogger, query.get("console.level").slice(-1)[0]);
|
|
298047
297997
|
if (query.has("console.lock")) {
|
|
@@ -298052,7 +298002,7 @@ var require_log = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
298052
298002
|
}));
|
|
298053
298003
|
|
|
298054
298004
|
//#endregion
|
|
298055
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
298005
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/md.all.js
|
|
298056
298006
|
var require_md_all = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
298057
298007
|
/**
|
|
298058
298008
|
* Node.js module for all known Forge message digests.
|
|
@@ -298069,7 +298019,7 @@ var require_md_all = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
298069
298019
|
}));
|
|
298070
298020
|
|
|
298071
298021
|
//#endregion
|
|
298072
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
298022
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/pkcs7.js
|
|
298073
298023
|
var require_pkcs7 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
298074
298024
|
/**
|
|
298075
298025
|
* Javascript implementation of PKCS#7 v1.5.
|
|
@@ -298800,7 +298750,7 @@ var require_pkcs7 = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
298800
298750
|
}));
|
|
298801
298751
|
|
|
298802
298752
|
//#endregion
|
|
298803
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
298753
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/ssh.js
|
|
298804
298754
|
var require_ssh = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
298805
298755
|
/**
|
|
298806
298756
|
* Functions to output keys in SSH-friendly formats.
|
|
@@ -298957,7 +298907,7 @@ var require_ssh = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
298957
298907
|
*/
|
|
298958
298908
|
function _addBigIntegerToBuffer(buffer, val) {
|
|
298959
298909
|
var hexVal = val.toString(16);
|
|
298960
|
-
if (hexVal[0] >= "8") hexVal = "00" + hexVal;
|
|
298910
|
+
if (hexVal[0] >= "8" && hexVal.length % 2 === 0) hexVal = "00" + hexVal;
|
|
298961
298911
|
var bytes = forge.util.hexToBytes(hexVal);
|
|
298962
298912
|
buffer.putInt32(bytes.length);
|
|
298963
298913
|
buffer.putBytes(bytes);
|
|
@@ -298986,7 +298936,7 @@ var require_ssh = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
|
298986
298936
|
}));
|
|
298987
298937
|
|
|
298988
298938
|
//#endregion
|
|
298989
|
-
//#region node_modules/.pnpm/node-forge@1.4.
|
|
298939
|
+
//#region node_modules/.pnpm/node-forge@1.4.4/node_modules/node-forge/lib/index.js
|
|
298990
298940
|
var require_lib = /* @__PURE__ */ __commonJSMin$2(((exports, module) => {
|
|
298991
298941
|
/**
|
|
298992
298942
|
* Node.js module for Forge.
|
|
@@ -588161,14 +588111,15 @@ const isPermanentRefusal = (error) => {
|
|
|
588161
588111
|
const isUserMessageReplay = (event) => event.type === "step_complete" && event.data?.phase === "user_message" && typeof event.data?.uuid === "string";
|
|
588162
588112
|
const isMainStreamStart = (event) => event.type === "stream_start" && !event.data?.subagent;
|
|
588163
588113
|
/**
|
|
588164
|
-
* Stream a Claude Code
|
|
588114
|
+
* Stream a Claude Code, native Codex or Antigravity run's events while typing the
|
|
588165
588115
|
* follow-ups the user queues behind it into the live session (steer), instead
|
|
588166
588116
|
* of leaving them for the next turn.
|
|
588167
588117
|
*
|
|
588168
588118
|
* Polls `aiAgent.waitHeteroSteer` for as long as the run streams and its
|
|
588169
588119
|
* session takes input; a message the session refuses goes back with
|
|
588170
588120
|
* `aiAgent.returnHeteroSteer`. The agent reports every message it picks up
|
|
588171
|
-
* (Claude Code replays it, Codex echoes its client id
|
|
588121
|
+
* (Claude Code replays it, Codex echoes its client id, Antigravity ends the
|
|
588122
|
+
* prompt it interrupts):
|
|
588172
588123
|
* the replay of a delivery is forwarded for the server to write the message
|
|
588173
588124
|
* into the conversation; any other replay (the run's own prompt) is dropped.
|
|
588174
588125
|
* Once the server answered, the next main `stream_start` carries `liveSteer`
|
|
@@ -588237,7 +588188,7 @@ async function* withHeteroSteer(handle, context) {
|
|
|
588237
588188
|
const res = await client.aiAgent.waitHeteroSteer.mutate({
|
|
588238
588189
|
...acceptsControl && { acceptsControl: true },
|
|
588239
588190
|
...handle.supportsSteerImageAttachments && { acceptsImageAttachments: true },
|
|
588240
|
-
|
|
588191
|
+
acceptsImages: true,
|
|
588241
588192
|
...!answered && { blockMs: 1 },
|
|
588242
588193
|
...waitingForUser() && { holdSteer: true },
|
|
588243
588194
|
operationId
|
|
@@ -589298,7 +589249,7 @@ const exec = async (options) => {
|
|
|
589298
589249
|
extraArgs,
|
|
589299
589250
|
includePartialMessages: options.type === "claude-code",
|
|
589300
589251
|
initialModel: usesHeterogeneousSessionInitialModel(options.type) ? options.model : void 0,
|
|
589301
|
-
liveInput: options.type === "claude-code"
|
|
589252
|
+
liveInput: options.type === "claude-code",
|
|
589302
589253
|
operationId,
|
|
589303
589254
|
...dispatchedModeSpawnOptions(options.type, resolved),
|
|
589304
589255
|
uploadImage
|