@karlorz/codexhost-cli-win32-x64 0.18.0-1 → 0.19.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/app/codexhost-distribution.json +1 -1
- package/app/console-server.mjs +59 -2
- package/app/console-web.js +76 -4
- package/app/cpa-live-voice-hook.js +59 -2
- package/app/desktop-controller.mjs +290 -12
- package/app/host-runtime.mjs +12896 -2966
- package/app/plugins/antigravity/plugin.mjs +654 -216
- package/app/plugins/claude-code/plugin.mjs +138 -11
- package/app/plugins/codebuddy/plugin.mjs +152 -20
- package/app/plugins/codex-usage/plugin.mjs +59 -2
- package/app/plugins/copilot/plugin.mjs +59 -2
- package/app/plugins/cursor-cli/plugin.mjs +134 -12
- package/app/plugins/deepseek-harness/manifest.json +2 -2
- package/app/plugins/deepseek-harness/plugin.mjs +86 -7
- package/app/plugins/devin/plugin.mjs +59 -2
- package/app/plugins/grok/plugin.mjs +1093 -970
- package/app/plugins/hermes/plugin.mjs +138 -14
- package/app/plugins/kimi-code/plugin.mjs +59 -2
- package/app/plugins/kiro-cli/plugin.mjs +287 -18
- package/app/plugins/omp/plugin.mjs +789 -628
- package/app/plugins/opencode/plugin.mjs +59 -2
- package/app/plugins/pi/plugin.mjs +786 -660
- package/app/plugins/qoder/plugin.mjs +61 -6
- package/app/plugins/qoder-cn/plugin.mjs +61 -6
- package/app/plugins/qwen-code/plugin.mjs +168 -94
- package/app/plugins/workbuddy/plugin.mjs +152 -20
- package/app/plugins/zcode/plugin.mjs +132 -5
- package/app/renderer-extension.js +426 -39
- package/app/web/assets/{index-py6Ho-Dy.js → index-BCyiiDDL.js} +62 -62
- package/app/web/assets/index-BNQIOOHE.css +1 -0
- package/app/web/codexhost-settings.js +76 -4
- package/app/web/index.html +2 -2
- package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +8 -8
- package/app/web/plugins/deepseek-ai__dsh-client-file-upload/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-locale/client.js +3 -3
- package/app/web/plugins/deepseek-ai__dsh-client-ui-attachment/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +129 -8
- package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +8 -6
- package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +95 -93
- package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
- package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.excel.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-files/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +16 -16
- package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +1 -1
- package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +11 -11
- package/app/web-modules/server.mjs +2345 -1518
- package/bin/codexhost.exe +0 -0
- package/libexec/codexhost-node-repl.exe +0 -0
- package/libexec/codexhost-shim.exe +0 -0
- package/libexec/codexhost-updater.exe +0 -0
- package/package.json +1 -1
- package/app/web/assets/index-C3lniEH1.css +0 -1
|
@@ -408,15 +408,6 @@ function createHarnessInstaller(environment, source) {
|
|
|
408
408
|
};
|
|
409
409
|
}
|
|
410
410
|
|
|
411
|
-
// dist/antigravity-adapter.js
|
|
412
|
-
import { spawn } from "node:child_process";
|
|
413
|
-
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
414
|
-
import { access as access2, readFile as readFile2, unlink } from "node:fs/promises";
|
|
415
|
-
import https3 from "node:https";
|
|
416
|
-
import os6 from "node:os";
|
|
417
|
-
import path11 from "node:path";
|
|
418
|
-
import readline from "node:readline";
|
|
419
|
-
|
|
420
411
|
// ../../../node_modules/zod/v4/classic/external.js
|
|
421
412
|
var external_exports = {};
|
|
422
413
|
__export(external_exports, {
|
|
@@ -15928,6 +15919,10 @@ var CLIENT_CHANNEL_VERSION = 1;
|
|
|
15928
15919
|
var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
|
|
15929
15920
|
var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
|
|
15930
15921
|
var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
|
|
15922
|
+
var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
|
|
15923
|
+
var clientThreadTreeSchema = external_exports.object({
|
|
15924
|
+
parents: external_exports.record(external_exports.string().min(1), external_exports.string().min(1))
|
|
15925
|
+
}).strict();
|
|
15931
15926
|
var clientProjectlessWorkspaceSchema = external_exports.object({
|
|
15932
15927
|
prompt: external_exports.string().max(16384).optional()
|
|
15933
15928
|
}).strict();
|
|
@@ -15944,6 +15939,11 @@ var clientChannelCursorSchema = external_exports.object({
|
|
|
15944
15939
|
sequence: external_exports.number().int().nonnegative()
|
|
15945
15940
|
});
|
|
15946
15941
|
var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
|
|
15942
|
+
external_exports.object({
|
|
15943
|
+
type: external_exports.literal("skills-changed"),
|
|
15944
|
+
cursor: clientChannelCursorSchema,
|
|
15945
|
+
cwd: external_exports.string().optional()
|
|
15946
|
+
}),
|
|
15947
15947
|
external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
|
|
15948
15948
|
external_exports.object({
|
|
15949
15949
|
type: external_exports.literal("preferences-changed"),
|
|
@@ -16141,6 +16141,28 @@ var voiceTranscribeResultSchema = external_exports.discriminatedUnion("ok", [
|
|
|
16141
16141
|
external_exports.object({ ok: external_exports.literal(false), error: external_exports.object({ code: voiceErrorCodeSchema }).strict() }).strict()
|
|
16142
16142
|
]);
|
|
16143
16143
|
|
|
16144
|
+
// ../../shared-contracts/dist/skills.js
|
|
16145
|
+
var skillsListParamsSchema = external_exports.object({
|
|
16146
|
+
threadId: hostThreadIdSchema.optional(),
|
|
16147
|
+
cwd: external_exports.string().min(1).optional()
|
|
16148
|
+
}).strict().refine((params) => !(params.threadId && params.cwd), {
|
|
16149
|
+
message: "Specify threadId or cwd, not both"
|
|
16150
|
+
});
|
|
16151
|
+
var librarySkillSchema = external_exports.object({
|
|
16152
|
+
name: external_exports.string().min(1).regex(/^[^\s[\]]+$/u),
|
|
16153
|
+
description: external_exports.string().optional(),
|
|
16154
|
+
path: external_exports.string().min(1),
|
|
16155
|
+
scope: external_exports.enum(["project", "global"]),
|
|
16156
|
+
source: external_exports.string().min(1)
|
|
16157
|
+
}).strict();
|
|
16158
|
+
var skillsListResultSchema = external_exports.object({
|
|
16159
|
+
revision: external_exports.number().int().nonnegative(),
|
|
16160
|
+
complete: external_exports.boolean(),
|
|
16161
|
+
skills: external_exports.array(librarySkillSchema),
|
|
16162
|
+
warnings: external_exports.array(external_exports.string()).optional()
|
|
16163
|
+
}).strict();
|
|
16164
|
+
var skillsChangedParamsSchema = external_exports.object({ cwd: external_exports.string().min(1).optional() }).strict();
|
|
16165
|
+
|
|
16144
16166
|
// ../../shared-contracts/dist/web-access-tokens.js
|
|
16145
16167
|
var webNetworkAccessUrlSchema = external_exports.object({
|
|
16146
16168
|
/**
|
|
@@ -16246,8 +16268,8 @@ var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
|
|
|
16246
16268
|
var delegationReadParamsSchema = external_exports.strictObject({
|
|
16247
16269
|
threadId: external_exports.string().min(1).max(1024),
|
|
16248
16270
|
view: external_exports.enum(["result", "messages"]),
|
|
16249
|
-
|
|
16250
|
-
|
|
16271
|
+
from: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional(),
|
|
16272
|
+
to: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional()
|
|
16251
16273
|
});
|
|
16252
16274
|
|
|
16253
16275
|
// ../../shared-contracts/dist/credential-imports.js
|
|
@@ -17249,6 +17271,17 @@ var updateStatusResultSchema = external_exports.strictObject({
|
|
|
17249
17271
|
status: updateStatusSchema.nullable()
|
|
17250
17272
|
});
|
|
17251
17273
|
|
|
17274
|
+
// ../../shared-contracts/dist/thread-watch-notice.js
|
|
17275
|
+
var THREAD_WATCH_NOTICE_OUTCOMES = [
|
|
17276
|
+
"completed",
|
|
17277
|
+
"failed",
|
|
17278
|
+
"interrupted",
|
|
17279
|
+
"timedOut",
|
|
17280
|
+
"unreadable",
|
|
17281
|
+
"notFound"
|
|
17282
|
+
];
|
|
17283
|
+
var ENTRY_PATTERN = new RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): ` + `(${THREAD_WATCH_NOTICE_OUTCOMES.join("|")})(?:. (.+))?$`, "u");
|
|
17284
|
+
|
|
17252
17285
|
// ../../shared-contracts/dist/remote-runtime.js
|
|
17253
17286
|
var remoteUpdatePhaseSchema = external_exports.enum([
|
|
17254
17287
|
"idle",
|
|
@@ -17296,6 +17329,14 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
|
|
|
17296
17329
|
archived: external_exports.boolean()
|
|
17297
17330
|
}),
|
|
17298
17331
|
external_exports.strictObject({ kind: external_exports.literal("read"), ...thread }),
|
|
17332
|
+
external_exports.strictObject({
|
|
17333
|
+
kind: external_exports.literal("configure"),
|
|
17334
|
+
...thread,
|
|
17335
|
+
epoch: identity,
|
|
17336
|
+
modelId: identity.optional(),
|
|
17337
|
+
thinkingOptionId: identity.optional(),
|
|
17338
|
+
permissionModeId: identity.optional()
|
|
17339
|
+
}).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting"),
|
|
17299
17340
|
external_exports.strictObject({
|
|
17300
17341
|
kind: external_exports.literal("prompt"),
|
|
17301
17342
|
...thread,
|
|
@@ -17368,6 +17409,13 @@ var remoteConnectionsReplySchema = external_exports.union([
|
|
|
17368
17409
|
external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
|
|
17369
17410
|
]);
|
|
17370
17411
|
|
|
17412
|
+
// ../../shared-contracts/dist/thread-title.js
|
|
17413
|
+
var threadTitleInputSchema = external_exports.strictObject({
|
|
17414
|
+
prompt: external_exports.string().trim().min(1).max(2e3),
|
|
17415
|
+
cwd: external_exports.string().max(4096).nullable()
|
|
17416
|
+
});
|
|
17417
|
+
var threadTitleResultSchema = external_exports.string().trim().min(1).max(60).nullable();
|
|
17418
|
+
|
|
17371
17419
|
// ../../shared-contracts/dist/web-ui-extensions.js
|
|
17372
17420
|
var webUiExtensionIdSchema = external_exports.string().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u);
|
|
17373
17421
|
var localizedTextSchema2 = external_exports.union([
|
|
@@ -17605,6 +17653,69 @@ var requestFields = /* @__PURE__ */ new Set([
|
|
|
17605
17653
|
"provider"
|
|
17606
17654
|
]);
|
|
17607
17655
|
|
|
17656
|
+
// ../../harness-adapter/dist/subagent-configuration.js
|
|
17657
|
+
function subagentConfiguration(value) {
|
|
17658
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
17659
|
+
return {};
|
|
17660
|
+
const row = value;
|
|
17661
|
+
const text = (value2) => typeof value2 === "string" && value2.trim() ? value2 : void 0;
|
|
17662
|
+
const model2 = row.model === "inherit" ? void 0 : text(row.model);
|
|
17663
|
+
const reasoningEffort = text(row.reasoningEffort) ?? text(row.reasoning_effort) ?? text(row.thinking);
|
|
17664
|
+
return { ...model2 ? { model: model2 } : {}, ...reasoningEffort ? { reasoningEffort } : {} };
|
|
17665
|
+
}
|
|
17666
|
+
function inheritSubagentConfiguration(child, parent) {
|
|
17667
|
+
const native = subagentConfiguration(child);
|
|
17668
|
+
const model2 = native.model ?? parent.model;
|
|
17669
|
+
const reasoningEffort = native.reasoningEffort ?? parent.reasoningEffort;
|
|
17670
|
+
const next = { ...child };
|
|
17671
|
+
delete next.model;
|
|
17672
|
+
delete next.reasoningEffort;
|
|
17673
|
+
return { ...next, ...model2 ? { model: model2 } : {}, ...reasoningEffort ? { reasoningEffort } : {} };
|
|
17674
|
+
}
|
|
17675
|
+
function configureSubagentEvent(event, parent) {
|
|
17676
|
+
const children = (states) => states.map((child) => inheritSubagentConfiguration(child, parent));
|
|
17677
|
+
if (event.type === "item.started" && event.item.type === "subagentDelegation")
|
|
17678
|
+
return { ...event, item: { ...event.item, subagents: children(event.item.subagents) } };
|
|
17679
|
+
if (event.type === "item.updated" && event.update.type === "subagents.replace")
|
|
17680
|
+
return { ...event, update: { ...event.update, subagents: children(event.update.subagents) } };
|
|
17681
|
+
if (event.type === "item.completed" && event.snapshot.item.type === "subagentDelegation")
|
|
17682
|
+
return {
|
|
17683
|
+
...event,
|
|
17684
|
+
snapshot: {
|
|
17685
|
+
...event.snapshot,
|
|
17686
|
+
item: {
|
|
17687
|
+
...event.snapshot.item,
|
|
17688
|
+
subagents: children(event.snapshot.item.subagents)
|
|
17689
|
+
}
|
|
17690
|
+
}
|
|
17691
|
+
};
|
|
17692
|
+
return event;
|
|
17693
|
+
}
|
|
17694
|
+
function configureSubagentSnapshot(snapshot, parent) {
|
|
17695
|
+
return {
|
|
17696
|
+
...snapshot,
|
|
17697
|
+
turns: snapshot.turns.map((turn) => ({
|
|
17698
|
+
...turn,
|
|
17699
|
+
items: turn.items.map((entry) => entry.item.type === "subagentDelegation" ? {
|
|
17700
|
+
...entry,
|
|
17701
|
+
item: {
|
|
17702
|
+
...entry.item,
|
|
17703
|
+
subagents: entry.item.subagents.map((child) => inheritSubagentConfiguration(child, parent))
|
|
17704
|
+
}
|
|
17705
|
+
} : entry)
|
|
17706
|
+
}))
|
|
17707
|
+
};
|
|
17708
|
+
}
|
|
17709
|
+
|
|
17710
|
+
// dist/antigravity-adapter.js
|
|
17711
|
+
import { spawn } from "node:child_process";
|
|
17712
|
+
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
17713
|
+
import { access as access2, readFile as readFile2, unlink } from "node:fs/promises";
|
|
17714
|
+
import https3 from "node:https";
|
|
17715
|
+
import os6 from "node:os";
|
|
17716
|
+
import path11 from "node:path";
|
|
17717
|
+
import readline from "node:readline";
|
|
17718
|
+
|
|
17608
17719
|
// dist/command.js
|
|
17609
17720
|
import path4 from "node:path";
|
|
17610
17721
|
var antigravityDiscoverySpec = {
|
|
@@ -17631,7 +17742,8 @@ function resolveAntigravityExecutable(input = {}) {
|
|
|
17631
17742
|
|
|
17632
17743
|
// dist/fork.js
|
|
17633
17744
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
17634
|
-
import {
|
|
17745
|
+
import { constants } from "node:fs";
|
|
17746
|
+
import { access, copyFile, cp, mkdir as mkdir2, rm as rm3 } from "node:fs/promises";
|
|
17635
17747
|
import os4 from "node:os";
|
|
17636
17748
|
import path7 from "node:path";
|
|
17637
17749
|
|
|
@@ -17707,6 +17819,8 @@ var hostItemSchema = external_exports.discriminatedUnion("type", [
|
|
|
17707
17819
|
nativeSubagentId: external_exports.string().optional(),
|
|
17708
17820
|
description: external_exports.string(),
|
|
17709
17821
|
role: external_exports.string().optional(),
|
|
17822
|
+
model: external_exports.string().optional(),
|
|
17823
|
+
reasoningEffort: external_exports.string().optional(),
|
|
17710
17824
|
background: external_exports.boolean(),
|
|
17711
17825
|
status: external_exports.enum(["pending", "running", "completed", "failed", "interrupted"]),
|
|
17712
17826
|
resultSummary: external_exports.string().optional()
|
|
@@ -17958,6 +18072,113 @@ async function nativeTurnBoundaryError(dbPath, sidecarTurnCount) {
|
|
|
17958
18072
|
return null;
|
|
17959
18073
|
}
|
|
17960
18074
|
|
|
18075
|
+
// dist/native-trajectory-metadata.js
|
|
18076
|
+
var DEFAULT_CLI_PROJECT_ID = "default-cli-project";
|
|
18077
|
+
function encodeVarint(value) {
|
|
18078
|
+
const bytes = [];
|
|
18079
|
+
let remaining = value >>> 0;
|
|
18080
|
+
while (remaining >= 128) {
|
|
18081
|
+
bytes.push(remaining & 127 | 128);
|
|
18082
|
+
remaining >>>= 7;
|
|
18083
|
+
}
|
|
18084
|
+
bytes.push(remaining);
|
|
18085
|
+
return Buffer.from(bytes);
|
|
18086
|
+
}
|
|
18087
|
+
function decodeVarint(buffer, start) {
|
|
18088
|
+
let value = 0n;
|
|
18089
|
+
for (let index = 0; index < 10; index++) {
|
|
18090
|
+
const byte = buffer[start + index];
|
|
18091
|
+
if (byte === void 0 || index === 9 && byte > 1)
|
|
18092
|
+
return null;
|
|
18093
|
+
value |= BigInt(byte & 127) << BigInt(index * 7);
|
|
18094
|
+
if ((byte & 128) === 0)
|
|
18095
|
+
return [value, start + index + 1];
|
|
18096
|
+
}
|
|
18097
|
+
return null;
|
|
18098
|
+
}
|
|
18099
|
+
function encodeLengthDelimited(fieldNumber, payload) {
|
|
18100
|
+
return Buffer.concat([
|
|
18101
|
+
encodeVarint(fieldNumber << 3 | 2),
|
|
18102
|
+
encodeVarint(payload.length),
|
|
18103
|
+
Buffer.from(payload)
|
|
18104
|
+
]);
|
|
18105
|
+
}
|
|
18106
|
+
function minimalTrajectoryMetadataBlob(cascadeId, projectId = DEFAULT_CLI_PROJECT_ID) {
|
|
18107
|
+
return Buffer.concat([
|
|
18108
|
+
encodeLengthDelimited(6, Buffer.from(cascadeId, "utf8")),
|
|
18109
|
+
encodeLengthDelimited(18, Buffer.from(projectId, "utf8"))
|
|
18110
|
+
]);
|
|
18111
|
+
}
|
|
18112
|
+
function minimalRawSummaryBlob(trajectoryId, metadataBlob) {
|
|
18113
|
+
return Buffer.concat([
|
|
18114
|
+
encodeLengthDelimited(4, Buffer.from(trajectoryId, "utf8")),
|
|
18115
|
+
Buffer.from([40, 1]),
|
|
18116
|
+
encodeLengthDelimited(17, metadataBlob),
|
|
18117
|
+
Buffer.from([176, 1, 4])
|
|
18118
|
+
]);
|
|
18119
|
+
}
|
|
18120
|
+
function rewriteTrajectoryMetadataCascadeId(blob, cascadeId) {
|
|
18121
|
+
const chunks = [];
|
|
18122
|
+
let offset = 0;
|
|
18123
|
+
let wroteCascadeId = false;
|
|
18124
|
+
let hasProjectId = false;
|
|
18125
|
+
while (offset < blob.length) {
|
|
18126
|
+
const fieldStart = offset;
|
|
18127
|
+
const tagParsed = decodeVarint(blob, offset);
|
|
18128
|
+
if (!tagParsed)
|
|
18129
|
+
return null;
|
|
18130
|
+
const [tag, afterTag] = tagParsed;
|
|
18131
|
+
if (tag < 8n || tag > 0xffffffffn)
|
|
18132
|
+
return null;
|
|
18133
|
+
const fieldNumber = Number(tag >> 3n);
|
|
18134
|
+
const wireType = Number(tag & 7n);
|
|
18135
|
+
if (fieldNumber === 6 && wireType !== 2)
|
|
18136
|
+
return null;
|
|
18137
|
+
offset = afterTag;
|
|
18138
|
+
if (wireType === 0) {
|
|
18139
|
+
const valParsed = decodeVarint(blob, offset);
|
|
18140
|
+
if (!valParsed)
|
|
18141
|
+
return null;
|
|
18142
|
+
offset = valParsed[1];
|
|
18143
|
+
} else if (wireType === 1) {
|
|
18144
|
+
if (offset + 8 > blob.length)
|
|
18145
|
+
return null;
|
|
18146
|
+
offset += 8;
|
|
18147
|
+
} else if (wireType === 2) {
|
|
18148
|
+
const lenParsed = decodeVarint(blob, offset);
|
|
18149
|
+
if (!lenParsed)
|
|
18150
|
+
return null;
|
|
18151
|
+
const [length, afterLen] = lenParsed;
|
|
18152
|
+
if (length > BigInt(blob.length - afterLen))
|
|
18153
|
+
return null;
|
|
18154
|
+
offset = afterLen + Number(length);
|
|
18155
|
+
if (fieldNumber === 6) {
|
|
18156
|
+
if (!wroteCascadeId) {
|
|
18157
|
+
chunks.push(encodeLengthDelimited(6, Buffer.from(cascadeId, "utf8")));
|
|
18158
|
+
wroteCascadeId = true;
|
|
18159
|
+
}
|
|
18160
|
+
continue;
|
|
18161
|
+
}
|
|
18162
|
+
if (fieldNumber === 18)
|
|
18163
|
+
hasProjectId = true;
|
|
18164
|
+
} else if (wireType === 5) {
|
|
18165
|
+
if (offset + 4 > blob.length)
|
|
18166
|
+
return null;
|
|
18167
|
+
offset += 4;
|
|
18168
|
+
} else {
|
|
18169
|
+
return null;
|
|
18170
|
+
}
|
|
18171
|
+
chunks.push(Buffer.from(blob.subarray(fieldStart, offset)));
|
|
18172
|
+
}
|
|
18173
|
+
if (!wroteCascadeId) {
|
|
18174
|
+
chunks.push(encodeLengthDelimited(6, Buffer.from(cascadeId, "utf8")));
|
|
18175
|
+
}
|
|
18176
|
+
if (!hasProjectId) {
|
|
18177
|
+
chunks.push(encodeLengthDelimited(18, Buffer.from(DEFAULT_CLI_PROJECT_ID, "utf8")));
|
|
18178
|
+
}
|
|
18179
|
+
return Buffer.concat(chunks);
|
|
18180
|
+
}
|
|
18181
|
+
|
|
17961
18182
|
// dist/usage-statistics.js
|
|
17962
18183
|
import { lstat, opendir } from "node:fs/promises";
|
|
17963
18184
|
import os3 from "node:os";
|
|
@@ -18140,7 +18361,7 @@ function createAntigravityUsageStatistics(environment) {
|
|
|
18140
18361
|
}
|
|
18141
18362
|
|
|
18142
18363
|
// dist/fork.js
|
|
18143
|
-
var
|
|
18364
|
+
var DEFAULT_CLI_PROJECT_ID2 = "default-cli-project";
|
|
18144
18365
|
var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;
|
|
18145
18366
|
function nativeConversationDbPath(nativeSessionId, homedir2 = os4.homedir()) {
|
|
18146
18367
|
return path7.join(homedir2, ".gemini", "antigravity-cli", "conversations", `${nativeSessionId}.db`);
|
|
@@ -18154,120 +18375,6 @@ function nativeBrainRoot(homedir2 = os4.homedir()) {
|
|
|
18154
18375
|
function nativeBrainDirPath(nativeSessionId, homedir2 = os4.homedir()) {
|
|
18155
18376
|
return path7.join(nativeBrainRoot(homedir2), nativeSessionId);
|
|
18156
18377
|
}
|
|
18157
|
-
function encodeVarint(value) {
|
|
18158
|
-
const bytes = [];
|
|
18159
|
-
let remaining = value >>> 0;
|
|
18160
|
-
while (remaining >= 128) {
|
|
18161
|
-
bytes.push(remaining & 127 | 128);
|
|
18162
|
-
remaining >>>= 7;
|
|
18163
|
-
}
|
|
18164
|
-
bytes.push(remaining);
|
|
18165
|
-
return Buffer.from(bytes);
|
|
18166
|
-
}
|
|
18167
|
-
function decodeVarint(buffer, startOffset) {
|
|
18168
|
-
let value = 0;
|
|
18169
|
-
let shift = 0;
|
|
18170
|
-
let offset = startOffset;
|
|
18171
|
-
while (offset < buffer.length) {
|
|
18172
|
-
const byte = buffer[offset];
|
|
18173
|
-
if (byte === void 0)
|
|
18174
|
-
return null;
|
|
18175
|
-
offset += 1;
|
|
18176
|
-
value += (byte & 127) * 2 ** shift;
|
|
18177
|
-
if ((byte & 128) === 0)
|
|
18178
|
-
return [value, offset];
|
|
18179
|
-
shift += 7;
|
|
18180
|
-
if (shift > 53)
|
|
18181
|
-
return null;
|
|
18182
|
-
}
|
|
18183
|
-
return null;
|
|
18184
|
-
}
|
|
18185
|
-
function encodeLengthDelimited(fieldNumber, payload) {
|
|
18186
|
-
return Buffer.concat([
|
|
18187
|
-
encodeVarint(fieldNumber << 3 | 2),
|
|
18188
|
-
encodeVarint(payload.length),
|
|
18189
|
-
Buffer.from(payload)
|
|
18190
|
-
]);
|
|
18191
|
-
}
|
|
18192
|
-
function minimalTrajectoryMetadataBlob(cascadeId, projectId = DEFAULT_CLI_PROJECT_ID) {
|
|
18193
|
-
return Buffer.concat([
|
|
18194
|
-
encodeLengthDelimited(6, Buffer.from(cascadeId, "utf8")),
|
|
18195
|
-
encodeLengthDelimited(18, Buffer.from(projectId, "utf8"))
|
|
18196
|
-
]);
|
|
18197
|
-
}
|
|
18198
|
-
function minimalRawSummaryBlob(trajectoryId, metadataBlob) {
|
|
18199
|
-
return Buffer.concat([
|
|
18200
|
-
encodeLengthDelimited(4, Buffer.from(trajectoryId, "utf8")),
|
|
18201
|
-
Buffer.from([40, 1]),
|
|
18202
|
-
encodeLengthDelimited(17, metadataBlob),
|
|
18203
|
-
Buffer.from([176, 1, 4])
|
|
18204
|
-
]);
|
|
18205
|
-
}
|
|
18206
|
-
function updateTrajectoryMetadataCascadeId(blob, cascadeId) {
|
|
18207
|
-
if (!blob || blob.length === 0)
|
|
18208
|
-
return minimalTrajectoryMetadataBlob(cascadeId);
|
|
18209
|
-
return rewriteTrajectoryMetadataCascadeId(blob, cascadeId) ?? minimalTrajectoryMetadataBlob(cascadeId);
|
|
18210
|
-
}
|
|
18211
|
-
function rewriteTrajectoryMetadataCascadeId(blob, cascadeId) {
|
|
18212
|
-
const chunks = [];
|
|
18213
|
-
let offset = 0;
|
|
18214
|
-
let wroteCascadeId = false;
|
|
18215
|
-
let hasProjectId = false;
|
|
18216
|
-
while (offset < blob.length) {
|
|
18217
|
-
const fieldStart = offset;
|
|
18218
|
-
const tagParsed = decodeVarint(blob, offset);
|
|
18219
|
-
if (!tagParsed)
|
|
18220
|
-
return null;
|
|
18221
|
-
const [tag, afterTag] = tagParsed;
|
|
18222
|
-
const fieldNumber = tag >>> 3;
|
|
18223
|
-
const wireType = tag & 7;
|
|
18224
|
-
offset = afterTag;
|
|
18225
|
-
if (wireType === 0) {
|
|
18226
|
-
const valParsed = decodeVarint(blob, offset);
|
|
18227
|
-
if (!valParsed)
|
|
18228
|
-
return null;
|
|
18229
|
-
offset = valParsed[1];
|
|
18230
|
-
chunks.push(Buffer.from(blob.subarray(fieldStart, offset)));
|
|
18231
|
-
} else if (wireType === 1) {
|
|
18232
|
-
if (offset + 8 > blob.length)
|
|
18233
|
-
return null;
|
|
18234
|
-
offset += 8;
|
|
18235
|
-
chunks.push(Buffer.from(blob.subarray(fieldStart, offset)));
|
|
18236
|
-
} else if (wireType === 2) {
|
|
18237
|
-
const lenParsed = decodeVarint(blob, offset);
|
|
18238
|
-
if (!lenParsed)
|
|
18239
|
-
return null;
|
|
18240
|
-
const [length, afterLen] = lenParsed;
|
|
18241
|
-
if (afterLen + length > blob.length)
|
|
18242
|
-
return null;
|
|
18243
|
-
offset = afterLen + length;
|
|
18244
|
-
if (fieldNumber === 6) {
|
|
18245
|
-
if (!wroteCascadeId) {
|
|
18246
|
-
chunks.push(encodeLengthDelimited(6, Buffer.from(cascadeId, "utf8")));
|
|
18247
|
-
wroteCascadeId = true;
|
|
18248
|
-
}
|
|
18249
|
-
} else {
|
|
18250
|
-
if (fieldNumber === 18)
|
|
18251
|
-
hasProjectId = true;
|
|
18252
|
-
chunks.push(Buffer.from(blob.subarray(fieldStart, offset)));
|
|
18253
|
-
}
|
|
18254
|
-
} else if (wireType === 5) {
|
|
18255
|
-
if (offset + 4 > blob.length)
|
|
18256
|
-
return null;
|
|
18257
|
-
offset += 4;
|
|
18258
|
-
chunks.push(Buffer.from(blob.subarray(fieldStart, offset)));
|
|
18259
|
-
} else {
|
|
18260
|
-
return null;
|
|
18261
|
-
}
|
|
18262
|
-
}
|
|
18263
|
-
if (!wroteCascadeId) {
|
|
18264
|
-
chunks.push(encodeLengthDelimited(6, Buffer.from(cascadeId, "utf8")));
|
|
18265
|
-
}
|
|
18266
|
-
if (!hasProjectId) {
|
|
18267
|
-
chunks.push(encodeLengthDelimited(18, Buffer.from(DEFAULT_CLI_PROJECT_ID, "utf8")));
|
|
18268
|
-
}
|
|
18269
|
-
return Buffer.concat(chunks);
|
|
18270
|
-
}
|
|
18271
18378
|
async function pathExists(targetPath2) {
|
|
18272
18379
|
return access(targetPath2).then(() => true, (error51) => {
|
|
18273
18380
|
if (error51?.code === "ENOENT")
|
|
@@ -18340,7 +18447,7 @@ function upsertConversationSummaryRow(DatabaseSync, summariesDbPath, conversatio
|
|
|
18340
18447
|
\`parent_conversation_id\`, \`nesting_depth\`, \`battle_id\`, \`winning_conversation_id\`,
|
|
18341
18448
|
\`not_fully_idle\`, \`killed\`, \`last_user_input_time\`, \`last_user_input_step_index\`,
|
|
18342
18449
|
\`app_data_dir\`, \`raw_summary\`, \`group_id\`
|
|
18343
|
-
) VALUES (?, '', '', ?, ?, '[]', 'CASCADE_RUN_STATUS_IDLE', '', ?, '', '', 0, '', '', 0, 0, ?, -1, '', ?, '')`).run(conversationId, stepCount, now,
|
|
18450
|
+
) VALUES (?, '', '', ?, ?, '[]', 'CASCADE_RUN_STATUS_IDLE', '', ?, '', '', 0, '', '', 0, 0, ?, -1, '', ?, '')`).run(conversationId, stepCount, now, DEFAULT_CLI_PROJECT_ID2, now, rawSummary);
|
|
18344
18451
|
}
|
|
18345
18452
|
} finally {
|
|
18346
18453
|
sumDb.close();
|
|
@@ -18521,28 +18628,24 @@ async function cloneNativeConversationDb(sourceSessionId, derivedSessionId, reta
|
|
|
18521
18628
|
const sourceDb = nativeConversationDbPath(sourceSessionId, homedir2);
|
|
18522
18629
|
const targetDb = nativeConversationDbPath(derivedSessionId, homedir2);
|
|
18523
18630
|
const summariesDbPath = nativeConversationSummariesDbPath(homedir2);
|
|
18524
|
-
|
|
18525
|
-
|
|
18526
|
-
await mkdir2(path7.dirname(targetDb), { recursive: true });
|
|
18527
|
-
await copyFile(sourceDb, targetDb);
|
|
18528
|
-
copiedFromDisk = true;
|
|
18529
|
-
} catch {
|
|
18530
|
-
copiedFromDisk = false;
|
|
18531
|
-
}
|
|
18532
|
-
let DatabaseSync;
|
|
18533
|
-
try {
|
|
18534
|
-
({ DatabaseSync } = await import("node:sqlite"));
|
|
18535
|
-
} catch {
|
|
18536
|
-
return copiedFromDisk;
|
|
18537
|
-
}
|
|
18538
|
-
if (!copiedFromDisk) {
|
|
18631
|
+
const { DatabaseSync } = await import("node:sqlite");
|
|
18632
|
+
if (!await pathExists(sourceDb)) {
|
|
18539
18633
|
const sourceSummary = await pathExists(summariesDbPath) ? readConversationSummaryRow(DatabaseSync, summariesDbPath, sourceSessionId) : void 0;
|
|
18540
18634
|
const sourceBrainExists = await pathExists(nativeBrainDirPath(sourceSessionId, homedir2));
|
|
18541
18635
|
if (!UUID_PATTERN.test(sourceSessionId) && !sourceSummary && !sourceBrainExists) {
|
|
18542
18636
|
return false;
|
|
18543
18637
|
}
|
|
18544
|
-
|
|
18638
|
+
if (await pathExists(targetDb)) {
|
|
18639
|
+
throw new Error("Antigravity derived native conversation database already exists");
|
|
18640
|
+
}
|
|
18641
|
+
if (!await seedNativeConversationDb(derivedSessionId, homedir2, sourceSummary)) {
|
|
18642
|
+
await rm3(targetDb, { force: true });
|
|
18643
|
+
throw new Error("Antigravity could not seed the derived native conversation database");
|
|
18644
|
+
}
|
|
18645
|
+
return true;
|
|
18545
18646
|
}
|
|
18647
|
+
await mkdir2(path7.dirname(targetDb), { recursive: true });
|
|
18648
|
+
await copyFile(sourceDb, targetDb, constants.COPYFILE_EXCL);
|
|
18546
18649
|
let trajectoryId = randomUUID2();
|
|
18547
18650
|
let metadataBlob = minimalTrajectoryMetadataBlob(derivedSessionId);
|
|
18548
18651
|
let remainingStepCount = 0;
|
|
@@ -18550,64 +18653,49 @@ async function cloneNativeConversationDb(sourceSessionId, derivedSessionId, reta
|
|
|
18550
18653
|
const db = new DatabaseSync(targetDb);
|
|
18551
18654
|
try {
|
|
18552
18655
|
db.prepare("UPDATE trajectory_meta SET cascade_id = ?").run(derivedSessionId);
|
|
18553
|
-
|
|
18554
|
-
|
|
18555
|
-
|
|
18556
|
-
|
|
18557
|
-
|
|
18558
|
-
|
|
18559
|
-
|
|
18560
|
-
|
|
18561
|
-
|
|
18562
|
-
db.prepare("INSERT OR REPLACE INTO trajectory_metadata_blob (id, data) VALUES ('main', ?)").run(metadataBlob);
|
|
18563
|
-
} catch {
|
|
18564
|
-
}
|
|
18656
|
+
const metaRow = db.prepare("SELECT trajectory_id FROM trajectory_meta LIMIT 1").get();
|
|
18657
|
+
if (metaRow?.trajectory_id)
|
|
18658
|
+
trajectoryId = metaRow.trajectory_id;
|
|
18659
|
+
const blobRow = db.prepare("SELECT data FROM trajectory_metadata_blob WHERE id = 'main'").get();
|
|
18660
|
+
const rewritten = blobRow?.data?.length ? rewriteTrajectoryMetadataCascadeId(blobRow.data, derivedSessionId) : minimalTrajectoryMetadataBlob(derivedSessionId);
|
|
18661
|
+
if (!rewritten)
|
|
18662
|
+
throw new Error("Antigravity could not parse source trajectory metadata");
|
|
18663
|
+
metadataBlob = rewritten;
|
|
18664
|
+
db.prepare("INSERT OR REPLACE INTO trajectory_metadata_blob (id, data) VALUES ('main', ?)").run(metadataBlob);
|
|
18565
18665
|
if (retainedTurnsCount !== void 0) {
|
|
18566
|
-
|
|
18567
|
-
|
|
18568
|
-
|
|
18569
|
-
|
|
18570
|
-
|
|
18571
|
-
|
|
18572
|
-
|
|
18573
|
-
db.prepare("DELETE FROM steps WHERE idx >= ?").run(cutoff.idx);
|
|
18574
|
-
}
|
|
18575
|
-
}
|
|
18576
|
-
} catch {
|
|
18577
|
-
}
|
|
18578
|
-
try {
|
|
18579
|
-
db.prepare("DELETE FROM gen_metadata WHERE idx >= ?").run(retainedTurnsCount);
|
|
18580
|
-
} catch {
|
|
18581
|
-
}
|
|
18582
|
-
try {
|
|
18583
|
-
db.prepare("DELETE FROM executor_metadata WHERE idx >= ?").run(retainedTurnsCount);
|
|
18584
|
-
} catch {
|
|
18585
|
-
}
|
|
18586
|
-
try {
|
|
18587
|
-
db.prepare("DELETE FROM parent_references WHERE idx >= ?").run(retainedTurnsCount);
|
|
18588
|
-
} catch {
|
|
18666
|
+
if (retainedTurnsCount === 0) {
|
|
18667
|
+
db.prepare("DELETE FROM steps").run();
|
|
18668
|
+
} else {
|
|
18669
|
+
const rows = db.prepare("SELECT idx FROM steps WHERE step_type = 14 ORDER BY idx ASC").all();
|
|
18670
|
+
const cutoff = rows[retainedTurnsCount];
|
|
18671
|
+
if (cutoff)
|
|
18672
|
+
db.prepare("DELETE FROM steps WHERE idx >= ?").run(cutoff.idx);
|
|
18589
18673
|
}
|
|
18590
|
-
|
|
18591
|
-
|
|
18592
|
-
|
|
18674
|
+
for (const table of [
|
|
18675
|
+
"gen_metadata",
|
|
18676
|
+
"executor_metadata",
|
|
18677
|
+
"parent_references",
|
|
18678
|
+
"battle_mode_infos"
|
|
18679
|
+
]) {
|
|
18680
|
+
if (db.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?").get(table)) {
|
|
18681
|
+
db.prepare(`DELETE FROM ${table} WHERE idx >= ?`).run(retainedTurnsCount);
|
|
18682
|
+
}
|
|
18593
18683
|
}
|
|
18594
18684
|
}
|
|
18595
|
-
|
|
18596
|
-
|
|
18597
|
-
|
|
18598
|
-
remainingStepCount = countRow.c;
|
|
18599
|
-
} catch {
|
|
18600
|
-
}
|
|
18685
|
+
const countRow = db.prepare("SELECT count(*) as c FROM steps").get();
|
|
18686
|
+
if (countRow)
|
|
18687
|
+
remainingStepCount = countRow.c;
|
|
18601
18688
|
} finally {
|
|
18602
18689
|
db.close();
|
|
18603
18690
|
}
|
|
18604
|
-
|
|
18605
|
-
|
|
18606
|
-
|
|
18607
|
-
|
|
18608
|
-
|
|
18609
|
-
|
|
18610
|
-
|
|
18691
|
+
if (await pathExists(summariesDbPath)) {
|
|
18692
|
+
const sourceRow = readConversationSummaryRow(DatabaseSync, summariesDbPath, sourceSessionId);
|
|
18693
|
+
const effectiveStepCount = retainedTurnsCount !== void 0 ? remainingStepCount : typeof sourceRow?.step_count === "number" ? sourceRow.step_count : remainingStepCount;
|
|
18694
|
+
upsertConversationSummaryRow(DatabaseSync, summariesDbPath, derivedSessionId, trajectoryId, metadataBlob, effectiveStepCount, sourceRow);
|
|
18695
|
+
}
|
|
18696
|
+
} catch (error51) {
|
|
18697
|
+
await rm3(targetDb, { force: true });
|
|
18698
|
+
throw error51;
|
|
18611
18699
|
}
|
|
18612
18700
|
return true;
|
|
18613
18701
|
}
|
|
@@ -18710,6 +18798,19 @@ async function forkAntigravitySession(options) {
|
|
|
18710
18798
|
const model2 = sourceSession?.model ?? sourceHistory.model;
|
|
18711
18799
|
const thinkingOptionId = sourceSession?.thinkingOptionId ?? sourceHistory.thinkingOptionId;
|
|
18712
18800
|
const permissionMode = sourceSession?.permissionMode ?? "dangerously-skip-permissions";
|
|
18801
|
+
try {
|
|
18802
|
+
await copyNativeConversationDbIfExists(sourceRef.nativeSessionId, derivedNativeSessionId, retainedTurns.length, homedir2);
|
|
18803
|
+
} catch (error51) {
|
|
18804
|
+
return {
|
|
18805
|
+
ok: false,
|
|
18806
|
+
error: {
|
|
18807
|
+
code: "nativeFailure",
|
|
18808
|
+
message: error51 instanceof Error ? error51.message : String(error51),
|
|
18809
|
+
retryable: false
|
|
18810
|
+
}
|
|
18811
|
+
};
|
|
18812
|
+
}
|
|
18813
|
+
await copyNativeBrainDirIfExists(sourceRef.nativeSessionId, derivedNativeSessionId, homedir2);
|
|
18713
18814
|
const forkedHistory = await AntigravityHistory.createDerived({
|
|
18714
18815
|
environment: sessionEnvironment,
|
|
18715
18816
|
nativeSessionId: derivedNativeSessionId,
|
|
@@ -18717,10 +18818,6 @@ async function forkAntigravitySession(options) {
|
|
|
18717
18818
|
...model2 ? { model: model2 } : {},
|
|
18718
18819
|
...thinkingOptionId ? { thinkingOptionId } : {}
|
|
18719
18820
|
});
|
|
18720
|
-
await Promise.all([
|
|
18721
|
-
copyNativeConversationDbIfExists(sourceRef.nativeSessionId, derivedNativeSessionId, retainedTurns.length, homedir2),
|
|
18722
|
-
copyNativeBrainDirIfExists(sourceRef.nativeSessionId, derivedNativeSessionId, homedir2)
|
|
18723
|
-
]);
|
|
18724
18821
|
const derivedNativeRef = {
|
|
18725
18822
|
harnessId,
|
|
18726
18823
|
nativeSessionId: derivedNativeSessionId,
|
|
@@ -18860,6 +18957,109 @@ function decodeAntigravityPermissionModeId(value) {
|
|
|
18860
18957
|
return "dangerously-skip-permissions";
|
|
18861
18958
|
}
|
|
18862
18959
|
|
|
18960
|
+
// dist/recovered-native-error.js
|
|
18961
|
+
var USER_INPUT_STEP = 14;
|
|
18962
|
+
var PLANNER_RESPONSE_STEP = 15;
|
|
18963
|
+
var ERROR_MESSAGE_STEP = 17;
|
|
18964
|
+
var DONE_STATUS = 3;
|
|
18965
|
+
var UNSETTLED_STATUSES = /* @__PURE__ */ new Set([0, 1, 2, 8, 9, 11]);
|
|
18966
|
+
var RETRIED_REQUEST_ERROR = /^API error \(attempt \d+\):/;
|
|
18967
|
+
var SETTLE_ATTEMPTS = 3;
|
|
18968
|
+
var SETTLE_DELAY_MS = 150;
|
|
18969
|
+
async function nativeTurnRecoveredFromError(query) {
|
|
18970
|
+
const error51 = query.error.trim();
|
|
18971
|
+
if (!query.conversationId || !error51)
|
|
18972
|
+
return false;
|
|
18973
|
+
let DatabaseSync;
|
|
18974
|
+
try {
|
|
18975
|
+
({ DatabaseSync } = await import("node:sqlite"));
|
|
18976
|
+
} catch {
|
|
18977
|
+
return false;
|
|
18978
|
+
}
|
|
18979
|
+
const dbPath = nativeConversationDbPath(query.conversationId, query.homedir);
|
|
18980
|
+
const errorBytes = Buffer.from(error51, "utf8");
|
|
18981
|
+
for (let attempt = 1; ; attempt += 1) {
|
|
18982
|
+
let verdict;
|
|
18983
|
+
try {
|
|
18984
|
+
verdict = readVerdict(DatabaseSync, dbPath, errorBytes);
|
|
18985
|
+
} catch {
|
|
18986
|
+
return false;
|
|
18987
|
+
}
|
|
18988
|
+
if (verdict !== "unsettled")
|
|
18989
|
+
return verdict === "recovered";
|
|
18990
|
+
if (attempt >= SETTLE_ATTEMPTS)
|
|
18991
|
+
return false;
|
|
18992
|
+
await new Promise((resolve) => setTimeout(resolve, SETTLE_DELAY_MS));
|
|
18993
|
+
}
|
|
18994
|
+
}
|
|
18995
|
+
function readVerdict(DatabaseSync, dbPath, errorBytes) {
|
|
18996
|
+
const db = new DatabaseSync(dbPath, { readOnly: true });
|
|
18997
|
+
try {
|
|
18998
|
+
const turnStart = db.prepare("SELECT MAX(idx) AS idx FROM steps WHERE step_type = ?").get(USER_INPUT_STEP);
|
|
18999
|
+
if (turnStart?.idx === null || turnStart?.idx === void 0)
|
|
19000
|
+
return "notRecovered";
|
|
19001
|
+
const steps = db.prepare(`SELECT idx, step_type, status,
|
|
19002
|
+
(instr(COALESCE(step_payload, X''), ?) > 0
|
|
19003
|
+
OR instr(COALESCE(error_details, X''), ?) > 0) AS has_error
|
|
19004
|
+
FROM steps WHERE idx > ? ORDER BY idx ASC`).all(errorBytes, errorBytes, turnStart.idx);
|
|
19005
|
+
if (steps.some((step) => step.has_error)) {
|
|
19006
|
+
return verdictForTurn(steps, RETRIED_REQUEST_ERROR.test(new TextDecoder().decode(errorBytes)));
|
|
19007
|
+
}
|
|
19008
|
+
const earlier = db.prepare(`SELECT 1 AS found FROM steps
|
|
19009
|
+
WHERE idx < ?
|
|
19010
|
+
AND (instr(COALESCE(step_payload, X''), ?) > 0
|
|
19011
|
+
OR instr(COALESCE(error_details, X''), ?) > 0)
|
|
19012
|
+
LIMIT 1`).get(turnStart.idx, errorBytes, errorBytes);
|
|
19013
|
+
if (!earlier)
|
|
19014
|
+
return "notRecovered";
|
|
19015
|
+
return verdictForFinishedTurn(steps);
|
|
19016
|
+
} finally {
|
|
19017
|
+
db.close();
|
|
19018
|
+
}
|
|
19019
|
+
}
|
|
19020
|
+
function verdictForTurn(steps, retriedRequest) {
|
|
19021
|
+
let errorAt = -1;
|
|
19022
|
+
for (let index = steps.length - 1; index >= 0; index -= 1) {
|
|
19023
|
+
if (steps[index]?.has_error) {
|
|
19024
|
+
errorAt = index;
|
|
19025
|
+
break;
|
|
19026
|
+
}
|
|
19027
|
+
}
|
|
19028
|
+
if (errorAt < 0)
|
|
19029
|
+
return "notRecovered";
|
|
19030
|
+
const after = steps.slice(errorAt + 1);
|
|
19031
|
+
const verdict = verdictForFinishedTurn(after);
|
|
19032
|
+
if (verdict !== "notRecovered" || !retriedRequest)
|
|
19033
|
+
return verdict;
|
|
19034
|
+
return retriedRequestRecovered(after) ? "recovered" : "notRecovered";
|
|
19035
|
+
}
|
|
19036
|
+
function settled(step) {
|
|
19037
|
+
return !UNSETTLED_STATUSES.has(step.status);
|
|
19038
|
+
}
|
|
19039
|
+
function completedPlannerResponse(step) {
|
|
19040
|
+
return step.step_type === PLANNER_RESPONSE_STEP && step.status === DONE_STATUS;
|
|
19041
|
+
}
|
|
19042
|
+
function verdictForFinishedTurn(steps) {
|
|
19043
|
+
const last = steps.at(-1);
|
|
19044
|
+
if (!last)
|
|
19045
|
+
return "notRecovered";
|
|
19046
|
+
if (!steps.every(settled))
|
|
19047
|
+
return "unsettled";
|
|
19048
|
+
return completedPlannerResponse(last) ? "recovered" : "notRecovered";
|
|
19049
|
+
}
|
|
19050
|
+
function retriedRequestRecovered(steps) {
|
|
19051
|
+
if (!steps.every(settled))
|
|
19052
|
+
return false;
|
|
19053
|
+
let lastReply = -1;
|
|
19054
|
+
steps.forEach((step, index) => {
|
|
19055
|
+
if (completedPlannerResponse(step))
|
|
19056
|
+
lastReply = index;
|
|
19057
|
+
});
|
|
19058
|
+
if (lastReply < 0)
|
|
19059
|
+
return false;
|
|
19060
|
+
return !steps.slice(lastReply + 1).some((step) => step.step_type === ERROR_MESSAGE_STEP || step.step_type === PLANNER_RESPONSE_STEP && step.status !== DONE_STATUS);
|
|
19061
|
+
}
|
|
19062
|
+
|
|
18863
19063
|
// dist/rollback.js
|
|
18864
19064
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
18865
19065
|
async function rollbackAntigravityLastTurn(options) {
|
|
@@ -18934,6 +19134,19 @@ async function rollbackAntigravityLastTurn(options) {
|
|
|
18934
19134
|
const model2 = sourceSession?.model ?? sourceHistory.model;
|
|
18935
19135
|
const thinkingOptionId = sourceSession?.thinkingOptionId ?? sourceHistory.thinkingOptionId;
|
|
18936
19136
|
const permissionMode = sourceSession?.permissionMode ?? "dangerously-skip-permissions";
|
|
19137
|
+
try {
|
|
19138
|
+
await copyNativeConversationDbIfExists(sourceRef.nativeSessionId, derivedNativeSessionId, mappedTurns.length, homedir2);
|
|
19139
|
+
} catch (error51) {
|
|
19140
|
+
return {
|
|
19141
|
+
ok: false,
|
|
19142
|
+
error: {
|
|
19143
|
+
code: "nativeFailure",
|
|
19144
|
+
message: error51 instanceof Error ? error51.message : String(error51),
|
|
19145
|
+
retryable: false
|
|
19146
|
+
}
|
|
19147
|
+
};
|
|
19148
|
+
}
|
|
19149
|
+
await copyNativeBrainDirIfExists(sourceRef.nativeSessionId, derivedNativeSessionId, homedir2);
|
|
18937
19150
|
const rolledBackHistory = await AntigravityHistory.createDerived({
|
|
18938
19151
|
environment: sessionEnvironment,
|
|
18939
19152
|
nativeSessionId: derivedNativeSessionId,
|
|
@@ -18941,10 +19154,6 @@ async function rollbackAntigravityLastTurn(options) {
|
|
|
18941
19154
|
...model2 ? { model: model2 } : {},
|
|
18942
19155
|
...thinkingOptionId ? { thinkingOptionId } : {}
|
|
18943
19156
|
});
|
|
18944
|
-
await Promise.all([
|
|
18945
|
-
copyNativeConversationDbIfExists(sourceRef.nativeSessionId, derivedNativeSessionId, mappedTurns.length, homedir2),
|
|
18946
|
-
copyNativeBrainDirIfExists(sourceRef.nativeSessionId, derivedNativeSessionId, homedir2)
|
|
18947
|
-
]);
|
|
18948
19157
|
const derivedNativeRef = {
|
|
18949
19158
|
harnessId,
|
|
18950
19159
|
nativeSessionId: derivedNativeSessionId,
|
|
@@ -19312,6 +19521,7 @@ function completeAntigravityToolItem(item, step, toolOutputLimit, cwd) {
|
|
|
19312
19521
|
|
|
19313
19522
|
// dist/code-action-diff.js
|
|
19314
19523
|
var DIFF_CONTEXT_LINES = 3;
|
|
19524
|
+
var TRAJECTORY_PAGE_SIZE = 256;
|
|
19315
19525
|
function isRecord2(value) {
|
|
19316
19526
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19317
19527
|
}
|
|
@@ -19491,6 +19701,75 @@ function requestAntigravityTrajectorySteps(port, conversationId, timeoutMs) {
|
|
|
19491
19701
|
request.end(JSON.stringify({ cascadeId: conversationId }));
|
|
19492
19702
|
});
|
|
19493
19703
|
}
|
|
19704
|
+
function plannerStepThinking(step) {
|
|
19705
|
+
if (!isRecord2(step) || step.type !== "CORTEX_STEP_TYPE_PLANNER_RESPONSE")
|
|
19706
|
+
return null;
|
|
19707
|
+
const plannerResponse = isRecord2(step.plannerResponse) ? step.plannerResponse : null;
|
|
19708
|
+
if (!plannerResponse)
|
|
19709
|
+
return null;
|
|
19710
|
+
for (const candidate of [
|
|
19711
|
+
plannerResponse.thinking,
|
|
19712
|
+
plannerResponse.rawThinking,
|
|
19713
|
+
plannerResponse.raw_thinking
|
|
19714
|
+
]) {
|
|
19715
|
+
if (typeof candidate === "string" && candidate.trim().length > 0)
|
|
19716
|
+
return candidate;
|
|
19717
|
+
}
|
|
19718
|
+
return null;
|
|
19719
|
+
}
|
|
19720
|
+
function parseAntigravityStepThinking(value, stepIndex, stepOffset = 0) {
|
|
19721
|
+
if (!isRecord2(value) || !Array.isArray(value.steps))
|
|
19722
|
+
return null;
|
|
19723
|
+
const relativeIndex = stepIndex - stepOffset;
|
|
19724
|
+
if (relativeIndex >= 0 && relativeIndex < value.steps.length) {
|
|
19725
|
+
const direct = plannerStepThinking(value.steps[relativeIndex]);
|
|
19726
|
+
if (direct !== null)
|
|
19727
|
+
return direct;
|
|
19728
|
+
}
|
|
19729
|
+
for (const step of value.steps) {
|
|
19730
|
+
if (isRecord2(step) && step.stepIndex === stepIndex) {
|
|
19731
|
+
const matched = plannerStepThinking(step);
|
|
19732
|
+
if (matched !== null)
|
|
19733
|
+
return matched;
|
|
19734
|
+
}
|
|
19735
|
+
}
|
|
19736
|
+
return null;
|
|
19737
|
+
}
|
|
19738
|
+
function requestAntigravityStepThinking(port, conversationId, stepIndex, timeoutMs) {
|
|
19739
|
+
const stepOffset = stepIndex >= TRAJECTORY_PAGE_SIZE ? stepIndex : 0;
|
|
19740
|
+
return new Promise((resolve) => {
|
|
19741
|
+
const request = https.request({
|
|
19742
|
+
hostname: "127.0.0.1",
|
|
19743
|
+
port,
|
|
19744
|
+
path: "/exa.language_server_pb.LanguageServerService/GetCascadeTrajectorySteps",
|
|
19745
|
+
method: "POST",
|
|
19746
|
+
rejectUnauthorized: false,
|
|
19747
|
+
timeout: timeoutMs,
|
|
19748
|
+
headers: { "content-type": "application/json" }
|
|
19749
|
+
}, (response) => {
|
|
19750
|
+
let body = "";
|
|
19751
|
+
response.setEncoding("utf8");
|
|
19752
|
+
response.on("data", (chunk) => {
|
|
19753
|
+
body += chunk;
|
|
19754
|
+
});
|
|
19755
|
+
response.on("end", () => {
|
|
19756
|
+
if (response.statusCode !== 200)
|
|
19757
|
+
return resolve(null);
|
|
19758
|
+
try {
|
|
19759
|
+
resolve(parseAntigravityStepThinking(JSON.parse(body), stepIndex, stepOffset));
|
|
19760
|
+
} catch {
|
|
19761
|
+
resolve(null);
|
|
19762
|
+
}
|
|
19763
|
+
});
|
|
19764
|
+
});
|
|
19765
|
+
request.on("timeout", () => request.destroy());
|
|
19766
|
+
request.on("error", () => resolve(null));
|
|
19767
|
+
request.end(JSON.stringify({
|
|
19768
|
+
cascadeId: conversationId,
|
|
19769
|
+
...stepOffset > 0 ? { stepOffset } : {}
|
|
19770
|
+
}));
|
|
19771
|
+
});
|
|
19772
|
+
}
|
|
19494
19773
|
|
|
19495
19774
|
// dist/stream-events.js
|
|
19496
19775
|
function isRecord3(value) {
|
|
@@ -19651,7 +19930,7 @@ async function fetchAntigravityQuota(run, now = /* @__PURE__ */ new Date()) {
|
|
|
19651
19930
|
|
|
19652
19931
|
// dist/question-bridge.js
|
|
19653
19932
|
import { randomBytes, randomUUID as randomUUID4, timingSafeEqual } from "node:crypto";
|
|
19654
|
-
import { mkdir as mkdir3, mkdtemp as mkdtemp2, rm as
|
|
19933
|
+
import { mkdir as mkdir3, mkdtemp as mkdtemp2, rm as rm4, writeFile as writeFile3 } from "node:fs/promises";
|
|
19655
19934
|
import { createServer } from "node:http";
|
|
19656
19935
|
import os5 from "node:os";
|
|
19657
19936
|
import path9 from "node:path";
|
|
@@ -20025,7 +20304,7 @@ var AntigravityQuestionBridge = class _AntigravityQuestionBridge {
|
|
|
20025
20304
|
this.#server.closeAllConnections();
|
|
20026
20305
|
});
|
|
20027
20306
|
if (this.#options.directory === void 0) {
|
|
20028
|
-
await
|
|
20307
|
+
await rm4(this.directory, { recursive: true, force: true, maxRetries: 5, retryDelay: 50 });
|
|
20029
20308
|
}
|
|
20030
20309
|
})();
|
|
20031
20310
|
return this.#disposal;
|
|
@@ -20047,6 +20326,7 @@ var transcriptStepSchema = external_exports.object({
|
|
|
20047
20326
|
type: external_exports.string(),
|
|
20048
20327
|
status: external_exports.string(),
|
|
20049
20328
|
content: external_exports.string().optional(),
|
|
20329
|
+
thinking: external_exports.string().optional(),
|
|
20050
20330
|
tool_calls: external_exports.array(external_exports.object({ name: external_exports.string(), args: external_exports.unknown().optional() })).optional()
|
|
20051
20331
|
});
|
|
20052
20332
|
async function subagentRpc(port, conversationId, method) {
|
|
@@ -20166,6 +20446,16 @@ function parseSubagentTranscript(text, parentId, childId, status, cwd, outputLim
|
|
|
20166
20446
|
}
|
|
20167
20447
|
} : { status: "succeeded" };
|
|
20168
20448
|
if (step.type === "PLANNER_RESPONSE") {
|
|
20449
|
+
if (step.thinking?.trim()) {
|
|
20450
|
+
current.items.push({
|
|
20451
|
+
item: {
|
|
20452
|
+
type: "reasoning",
|
|
20453
|
+
itemId: hostItemIdSchema.parse(`${itemId}-thinking`),
|
|
20454
|
+
text: step.thinking.slice(0, outputLimit)
|
|
20455
|
+
},
|
|
20456
|
+
outcome
|
|
20457
|
+
});
|
|
20458
|
+
}
|
|
20169
20459
|
if (step.content) {
|
|
20170
20460
|
current.items.push({
|
|
20171
20461
|
item: { type: "agentMessage", itemId, text: step.content.slice(0, outputLimit) },
|
|
@@ -20240,6 +20530,40 @@ async function readSubagentTranscript(input) {
|
|
|
20240
20530
|
};
|
|
20241
20531
|
}
|
|
20242
20532
|
}
|
|
20533
|
+
async function readTranscriptStepThinking(conversationId, stepIndex, outputLimit, home) {
|
|
20534
|
+
if (!conversationId || /[/\\]|^\.\.?$/u.test(conversationId))
|
|
20535
|
+
return null;
|
|
20536
|
+
const logsDir = path10.join(nativeBrainDirPath(conversationId, home), ".system_generated", "logs");
|
|
20537
|
+
for (const filename of ["transcript_full.jsonl", "transcript.jsonl"]) {
|
|
20538
|
+
try {
|
|
20539
|
+
const handle = await open(path10.join(logsDir, filename), "r");
|
|
20540
|
+
let text;
|
|
20541
|
+
try {
|
|
20542
|
+
const size = (await handle.stat()).size;
|
|
20543
|
+
if (size === 0 || size > MAX_TRANSCRIPT_BYTES)
|
|
20544
|
+
continue;
|
|
20545
|
+
const buffer = Buffer.alloc(size);
|
|
20546
|
+
const { bytesRead } = await handle.read(buffer, 0, size, 0);
|
|
20547
|
+
text = buffer.subarray(0, bytesRead).toString("utf8");
|
|
20548
|
+
} finally {
|
|
20549
|
+
await handle.close();
|
|
20550
|
+
}
|
|
20551
|
+
for (const line of text.split("\n")) {
|
|
20552
|
+
if (!line.trim())
|
|
20553
|
+
continue;
|
|
20554
|
+
try {
|
|
20555
|
+
const parsed = JSON.parse(line);
|
|
20556
|
+
if (isRecord3(parsed) && parsed.step_index === stepIndex && parsed.type === "PLANNER_RESPONSE" && typeof parsed.thinking === "string" && parsed.thinking.trim().length > 0) {
|
|
20557
|
+
return parsed.thinking.slice(0, outputLimit);
|
|
20558
|
+
}
|
|
20559
|
+
} catch {
|
|
20560
|
+
}
|
|
20561
|
+
}
|
|
20562
|
+
} catch {
|
|
20563
|
+
}
|
|
20564
|
+
}
|
|
20565
|
+
return null;
|
|
20566
|
+
}
|
|
20243
20567
|
|
|
20244
20568
|
// dist/subagents.js
|
|
20245
20569
|
var infoSchema = external_exports.object({
|
|
@@ -20247,6 +20571,10 @@ var infoSchema = external_exports.object({
|
|
|
20247
20571
|
conversation_id: nativeSubagentIdSchema,
|
|
20248
20572
|
type_name: external_exports.string().max(256).optional(),
|
|
20249
20573
|
role: external_exports.string().max(2048).optional(),
|
|
20574
|
+
model: external_exports.string().max(512).optional().catch(void 0),
|
|
20575
|
+
reasoningEffort: external_exports.string().max(128).optional().catch(void 0),
|
|
20576
|
+
reasoning_effort: external_exports.string().max(128).optional().catch(void 0),
|
|
20577
|
+
thinking: external_exports.string().max(128).optional().catch(void 0),
|
|
20250
20578
|
initial_prompt: external_exports.string().max(128e3).optional()
|
|
20251
20579
|
})).max(32)
|
|
20252
20580
|
});
|
|
@@ -20302,14 +20630,15 @@ var AntigravitySubagents = class {
|
|
|
20302
20630
|
return true;
|
|
20303
20631
|
}
|
|
20304
20632
|
const subagents = parsed.data.subagents.map((child) => {
|
|
20305
|
-
const state = {
|
|
20633
|
+
const state = inheritSubagentConfiguration({
|
|
20306
20634
|
subagentId: child.conversation_id,
|
|
20307
20635
|
nativeSubagentId: child.conversation_id,
|
|
20308
20636
|
description: child.role || child.type_name || "Antigravity Subagent",
|
|
20309
20637
|
...child.type_name ? { role: child.type_name } : {},
|
|
20638
|
+
...subagentConfiguration(child),
|
|
20310
20639
|
background: true,
|
|
20311
20640
|
status: "running"
|
|
20312
|
-
};
|
|
20641
|
+
}, this.#options.parentConfiguration ?? {});
|
|
20313
20642
|
this.#states.set(child.conversation_id, state);
|
|
20314
20643
|
return state;
|
|
20315
20644
|
});
|
|
@@ -20933,7 +21262,19 @@ var AntigravitySession = class {
|
|
|
20933
21262
|
return historySubagentState(this.#history, id);
|
|
20934
21263
|
}
|
|
20935
21264
|
initialState;
|
|
21265
|
+
#subagentConfiguration() {
|
|
21266
|
+
const state = this.#state();
|
|
21267
|
+
const model2 = state.effectiveModel ? state.effectiveModel.id : void 0;
|
|
21268
|
+
return {
|
|
21269
|
+
...model2 ? { model: model2 } : {},
|
|
21270
|
+
...state.effectiveThinkingOptionId ? { reasoningEffort: state.effectiveThinkingOptionId } : {}
|
|
21271
|
+
};
|
|
21272
|
+
}
|
|
20936
21273
|
async readSnapshot() {
|
|
21274
|
+
const result = await this.#readSnapshot();
|
|
21275
|
+
return result.ok ? { ok: true, value: configureSubagentSnapshot(result.value, this.#subagentConfiguration()) } : result;
|
|
21276
|
+
}
|
|
21277
|
+
async #readSnapshot() {
|
|
20937
21278
|
if (this.#closed)
|
|
20938
21279
|
return { ok: false, error: invalidState("Antigravity Session is closed") };
|
|
20939
21280
|
return { ok: true, value: { turns: this.#history.snapshot(), state: this.#state() } };
|
|
@@ -21070,6 +21411,10 @@ var AntigravitySession = class {
|
|
|
21070
21411
|
questions,
|
|
21071
21412
|
subagents: new AntigravitySubagents({
|
|
21072
21413
|
turnId: command.turnId,
|
|
21414
|
+
parentConfiguration: {
|
|
21415
|
+
...this.#model ? { model: this.#model.id } : {},
|
|
21416
|
+
...this.#thinkingOptionId ? { reasoningEffort: this.#thinkingOptionId } : {}
|
|
21417
|
+
},
|
|
21073
21418
|
parentId: () => this.#nativeRef?.nativeSessionId,
|
|
21074
21419
|
port: () => this.#languageServerPort(active),
|
|
21075
21420
|
cwd: this.#cwd,
|
|
@@ -21105,6 +21450,9 @@ var AntigravitySession = class {
|
|
|
21105
21450
|
codeActionCursor: 0,
|
|
21106
21451
|
fileChanges: /* @__PURE__ */ new Map(),
|
|
21107
21452
|
pendingSteps: /* @__PURE__ */ new Map(),
|
|
21453
|
+
thinkingSteps: /* @__PURE__ */ new Set(),
|
|
21454
|
+
checkedActiveThinkingSteps: /* @__PURE__ */ new Set(),
|
|
21455
|
+
pendingAgentText: /* @__PURE__ */ new Map(),
|
|
21108
21456
|
httpsPort: null
|
|
21109
21457
|
};
|
|
21110
21458
|
this.#active = active;
|
|
@@ -21327,7 +21675,14 @@ ${line}`).slice(-8e3);
|
|
|
21327
21675
|
if (!timedOut && finishedReason !== "interrupted" && repliedThisTurn && event.result.error?.trim() && this.#reportedEarlier(error51)) {
|
|
21328
21676
|
this.#completeTurn(active, { status: "succeeded", checkpoint }, nativeTurnRef);
|
|
21329
21677
|
} else {
|
|
21330
|
-
|
|
21678
|
+
const recovered = !timedOut && finishedReason !== "interrupted" && repliedThisTurn && event.result.error?.trim() && await nativeTurnRecoveredFromError({
|
|
21679
|
+
conversationId: convId,
|
|
21680
|
+
error: event.result.error,
|
|
21681
|
+
homedir: antigravityHome(this.#environment)
|
|
21682
|
+
});
|
|
21683
|
+
if (this.#active !== active)
|
|
21684
|
+
return;
|
|
21685
|
+
this.#completeTurn(active, active.cancellationRequested ? { status: "cancelled", reason: "Cancelled by user", checkpoint } : recovered ? { status: "succeeded", checkpoint } : { status: "failed", error: error51, checkpoint }, nativeTurnRef);
|
|
21331
21686
|
}
|
|
21332
21687
|
}
|
|
21333
21688
|
}
|
|
@@ -21395,14 +21750,13 @@ ${line}`).slice(-8e3);
|
|
|
21395
21750
|
step = { ...step, step_type: "tool" };
|
|
21396
21751
|
}
|
|
21397
21752
|
if (step.step_type === "agent_response") {
|
|
21398
|
-
|
|
21399
|
-
|
|
21400
|
-
|
|
21401
|
-
|
|
21402
|
-
|
|
21403
|
-
if (
|
|
21404
|
-
this.#
|
|
21405
|
-
return;
|
|
21753
|
+
await this.#maybeProjectStepThinking(active, step);
|
|
21754
|
+
const isDelta = typeof step.text_delta === "string" && step.text_delta.length > 0;
|
|
21755
|
+
const text = isDelta ? step.text_delta : step.text ?? (typeof step.content === "string" ? step.content : void 0) ?? (typeof step.message === "string" ? step.message : void 0);
|
|
21756
|
+
if (typeof text === "string" && text.length > 0) {
|
|
21757
|
+
this.#emitOrBufferAgentResponseText(active, step.step_index, text, isDelta);
|
|
21758
|
+
} else if (active.thinkingSteps.has(step.step_index)) {
|
|
21759
|
+
this.#flushPendingAgentText(active, step.step_index);
|
|
21406
21760
|
}
|
|
21407
21761
|
return;
|
|
21408
21762
|
}
|
|
@@ -21412,6 +21766,7 @@ ${line}`).slice(-8e3);
|
|
|
21412
21766
|
}
|
|
21413
21767
|
if (step.step_type !== "tool")
|
|
21414
21768
|
return;
|
|
21769
|
+
this.#flushAllPendingAgentText(active);
|
|
21415
21770
|
if (active.agentItem) {
|
|
21416
21771
|
this.#completeItem(active, active.agentItem, { status: "succeeded" });
|
|
21417
21772
|
active.agentItem = null;
|
|
@@ -21531,6 +21886,87 @@ ${line}`).slice(-8e3);
|
|
|
21531
21886
|
active.httpsPort = port;
|
|
21532
21887
|
return port;
|
|
21533
21888
|
}
|
|
21889
|
+
/**
|
|
21890
|
+
* `agy --output-format stream-json` strips `<thought>` blocks from step text
|
|
21891
|
+
* and omits `thinking` from `step_update`, reporting only `usage.thinking_tokens`
|
|
21892
|
+
* when a planner step finishes. Resolve the step's thinking from inline fields,
|
|
21893
|
+
* the Language Server trajectory, or the native brain transcript before
|
|
21894
|
+
* projecting the step's visible response or subsequent tool calls. Reply text
|
|
21895
|
+
* for the same step is buffered until this returns with the step recorded in
|
|
21896
|
+
* `thinkingSteps`, so a late-fetched reasoning Item is not outranked by the
|
|
21897
|
+
* streamed answer.
|
|
21898
|
+
*/
|
|
21899
|
+
async #maybeProjectStepThinking(active, step) {
|
|
21900
|
+
if (active.thinkingSteps.has(step.step_index))
|
|
21901
|
+
return;
|
|
21902
|
+
const isTerminal = step.state === "DONE" || step.state === "ERROR";
|
|
21903
|
+
if (!isTerminal && active.checkedActiveThinkingSteps.has(step.step_index))
|
|
21904
|
+
return;
|
|
21905
|
+
if (!isTerminal)
|
|
21906
|
+
active.checkedActiveThinkingSteps.add(step.step_index);
|
|
21907
|
+
const inlineThinking = typeof step.thinking_delta === "string" && step.thinking_delta.trim().length > 0 ? step.thinking_delta : typeof step.thinking === "string" && step.thinking.trim().length > 0 ? step.thinking : null;
|
|
21908
|
+
let thinking = inlineThinking;
|
|
21909
|
+
if (thinking === null) {
|
|
21910
|
+
const thinkingTokens = safeToken(step.usage?.thinking_tokens);
|
|
21911
|
+
if (!isTerminal || thinkingTokens === void 0 || thinkingTokens > 0) {
|
|
21912
|
+
const port = await this.#languageServerPort(active);
|
|
21913
|
+
if (port !== null) {
|
|
21914
|
+
thinking = await requestAntigravityStepThinking(port, step.conversation_id, step.step_index, TRAJECTORY_TIMEOUT_MS);
|
|
21915
|
+
}
|
|
21916
|
+
if (thinking === null) {
|
|
21917
|
+
const home = (process.platform === "win32" ? this.#environment.USERPROFILE : this.#environment.HOME) || void 0;
|
|
21918
|
+
thinking = await readTranscriptStepThinking(step.conversation_id, step.step_index, this.#toolOutputLimit, home);
|
|
21919
|
+
}
|
|
21920
|
+
}
|
|
21921
|
+
}
|
|
21922
|
+
if (isTerminal)
|
|
21923
|
+
active.thinkingSteps.add(step.step_index);
|
|
21924
|
+
if (thinking === null || thinking.trim().length === 0) {
|
|
21925
|
+
if (!isTerminal && !this.#thinkingOptionId)
|
|
21926
|
+
active.thinkingSteps.add(step.step_index);
|
|
21927
|
+
return;
|
|
21928
|
+
}
|
|
21929
|
+
active.thinkingSteps.add(step.step_index);
|
|
21930
|
+
if (active.agentItem) {
|
|
21931
|
+
this.#completeItem(active, active.agentItem, { status: "succeeded" });
|
|
21932
|
+
active.agentItem = null;
|
|
21933
|
+
active.agentText = "";
|
|
21934
|
+
}
|
|
21935
|
+
const item = {
|
|
21936
|
+
type: "reasoning",
|
|
21937
|
+
itemId: this.#newItemId(),
|
|
21938
|
+
text: thinking.slice(0, this.#toolOutputLimit)
|
|
21939
|
+
};
|
|
21940
|
+
this.#event({ type: "item.started", turnId: active.command.turnId, item });
|
|
21941
|
+
this.#completeItem(active, item, { status: "succeeded" });
|
|
21942
|
+
}
|
|
21943
|
+
/**
|
|
21944
|
+
* Emit agent_response text only after that step's thinking is resolved when
|
|
21945
|
+
* a late reasoning Item is still possible. Otherwise buffer so the streamed
|
|
21946
|
+
* answer cannot outrank thinking that only becomes available at DONE.
|
|
21947
|
+
*/
|
|
21948
|
+
#emitOrBufferAgentResponseText(active, stepIndex, text, isDelta) {
|
|
21949
|
+
if (active.thinkingSteps.has(stepIndex) || !this.#thinkingOptionId) {
|
|
21950
|
+
this.#flushPendingAgentText(active, stepIndex);
|
|
21951
|
+
this.#appendOrSyncAgentText(active, text, isDelta);
|
|
21952
|
+
return;
|
|
21953
|
+
}
|
|
21954
|
+
const previous = active.pendingAgentText.get(stepIndex) ?? "";
|
|
21955
|
+
active.pendingAgentText.set(stepIndex, isDelta ? previous + text : text);
|
|
21956
|
+
}
|
|
21957
|
+
#flushPendingAgentText(active, stepIndex) {
|
|
21958
|
+
const pending = active.pendingAgentText.get(stepIndex);
|
|
21959
|
+
if (pending === void 0)
|
|
21960
|
+
return;
|
|
21961
|
+
active.pendingAgentText.delete(stepIndex);
|
|
21962
|
+
if (pending.length > 0)
|
|
21963
|
+
this.#appendOrSyncAgentText(active, pending, true);
|
|
21964
|
+
}
|
|
21965
|
+
#flushAllPendingAgentText(active) {
|
|
21966
|
+
for (const stepIndex of [...active.pendingAgentText.keys()].sort((a, b) => a - b)) {
|
|
21967
|
+
this.#flushPendingAgentText(active, stepIndex);
|
|
21968
|
+
}
|
|
21969
|
+
}
|
|
21534
21970
|
#appendOrSyncAgentText(active, text, isExplicitDelta) {
|
|
21535
21971
|
if (!text)
|
|
21536
21972
|
return;
|
|
@@ -21585,6 +22021,7 @@ ${line}`).slice(-8e3);
|
|
|
21585
22021
|
this.#active = null;
|
|
21586
22022
|
const itemOutcome = outcome.status === "failed" ? { status: "failed", error: outcome.error } : outcome.status === "cancelled" ? { status: "cancelled", ...outcome.reason ? { reason: outcome.reason } : {} } : { status: "succeeded" };
|
|
21587
22023
|
active.subagents.finish(itemOutcome);
|
|
22024
|
+
this.#flushAllPendingAgentText(active);
|
|
21588
22025
|
if (active.compactionItem)
|
|
21589
22026
|
this.#completeItem(active, active.compactionItem, itemOutcome);
|
|
21590
22027
|
active.compactionItem = null;
|
|
@@ -21737,6 +22174,7 @@ ${line}`).slice(-8e3);
|
|
|
21737
22174
|
};
|
|
21738
22175
|
}
|
|
21739
22176
|
#event(event) {
|
|
22177
|
+
event = configureSubagentEvent(event, this.#subagentConfiguration());
|
|
21740
22178
|
this.#channel.emit({ kind: "event", event });
|
|
21741
22179
|
}
|
|
21742
22180
|
#newItemId() {
|