@cydm/pie 4.14.1 → 4.15.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 +5 -5
- package/dist/builtin/extensions/ask-user/index.js +4 -4
- package/dist/builtin/extensions/im-forward/index.js +889 -205
- package/dist/builtin/extensions/memory/index.js +6 -6
- package/dist/builtin/extensions/memory/package.json +1 -2
- package/dist/builtin/extensions/pie-proc/index.js +6 -6
- package/dist/builtin/extensions/plan-mode/index.js +4 -4
- package/dist/builtin/extensions/subagent/index.js +5 -5
- package/dist/builtin/extensions/todo/index.js +4 -4
- package/dist/chunks/{chunk-IQDVL34H.js → chunk-6AYPNTCO.js} +8 -8
- package/dist/chunks/{chunk-SYZR74QO.js → chunk-J6EZ335F.js} +8 -7
- package/dist/chunks/{chunk-X3ZVZB2R.js → chunk-JE53PC46.js} +633 -148
- package/dist/chunks/{chunk-2WLKAMOH.js → chunk-LIA52LJU.js} +3 -3
- package/dist/chunks/{chunk-SAXKBFX3.js → chunk-MTH6QSYD.js} +1 -1
- package/dist/chunks/{chunk-TTSQWGAT.js → chunk-NAMH667S.js} +10 -15
- package/dist/chunks/{chunk-DJ4LO7PQ.js → chunk-VWDCKHCC.js} +1 -1
- package/dist/chunks/{chunk-IM7DLPPY.js → chunk-YKV45EMY.js} +239 -141
- package/dist/chunks/{chunk-OQCKDEEE.js → chunk-ZBIR5YS7.js} +1 -1
- package/dist/chunks/{chunk-TNRZEQD5.js → chunk-ZH6EAKVM.js} +2 -2
- package/dist/chunks/{host-image-fallback-AEKY2LSZ.js → host-image-fallback-GX2KXZXQ.js} +1 -1
- package/dist/chunks/{memory-git-G56IXFWU.js → memory-git-BJMYZHIE.js} +5 -5
- package/dist/chunks/{model-registry-4LM2I6FR.js → model-registry-T6EMM66I.js} +2 -2
- package/dist/chunks/{read-file-understanding-GTNZHAK5.js → read-file-understanding-ZRE5KDG3.js} +5 -5
- package/dist/chunks/{src-3YJ4UVEC.js → src-DLAIQCKP.js} +3 -3
- package/dist/chunks/{src-APNP4M4N.js → src-FWL3LCBK.js} +2 -2
- package/dist/chunks/{src-T6AUO53N.js → src-OP6LFLR6.js} +8 -4
- package/dist/chunks/{src-TNUD7EDH.js → src-XJKZIY3S.js} +11 -1
- package/dist/chunks/{test-stream-EF2DHEHV.js → test-stream-P3CUEGEE.js} +1 -1
- package/dist/cli.js +408 -52
- package/models.schema.json +4 -0
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
normalizeFileManagerPlatform,
|
|
20
20
|
resolvePath,
|
|
21
21
|
understandReadFile
|
|
22
|
-
} from "./chunks/chunk-
|
|
22
|
+
} from "./chunks/chunk-ZH6EAKVM.js";
|
|
23
23
|
import {
|
|
24
24
|
CLI_RETRY_MAX_RETRIES,
|
|
25
25
|
classifyCliFailure,
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
logTransportLifecycle,
|
|
37
37
|
setYoloGrantListener,
|
|
38
38
|
truncateHeadTail
|
|
39
|
-
} from "./chunks/chunk-
|
|
39
|
+
} from "./chunks/chunk-LIA52LJU.js";
|
|
40
40
|
import "./chunks/chunk-F7EBZTZO.js";
|
|
41
41
|
import {
|
|
42
42
|
MEMORY_DISTILL_RETRYABLE_EXIT_CODE,
|
|
@@ -52,12 +52,12 @@ import {
|
|
|
52
52
|
runDistillWorkerMain,
|
|
53
53
|
spawnDistillAutoWorker,
|
|
54
54
|
spawnDistillWorker
|
|
55
|
-
} from "./chunks/chunk-
|
|
55
|
+
} from "./chunks/chunk-6AYPNTCO.js";
|
|
56
56
|
import {
|
|
57
57
|
commitCuratedMemoryBestEffort,
|
|
58
58
|
isMemoryGitInitialized,
|
|
59
59
|
readCuratedMemoryGitLog
|
|
60
|
-
} from "./chunks/chunk-
|
|
60
|
+
} from "./chunks/chunk-VWDCKHCC.js";
|
|
61
61
|
import {
|
|
62
62
|
SessionOwnershipLifecycle,
|
|
63
63
|
claimSessionOwnership,
|
|
@@ -67,7 +67,7 @@ import {
|
|
|
67
67
|
import "./chunks/chunk-Q4NJEPIZ.js";
|
|
68
68
|
import {
|
|
69
69
|
ModelRegistry
|
|
70
|
-
} from "./chunks/chunk-
|
|
70
|
+
} from "./chunks/chunk-NAMH667S.js";
|
|
71
71
|
import {
|
|
72
72
|
VERSION,
|
|
73
73
|
getAgentDir,
|
|
@@ -117,7 +117,7 @@ import {
|
|
|
117
117
|
shouldPreserveExecutionStateForUserText,
|
|
118
118
|
supersedeExecutionState,
|
|
119
119
|
todayKey
|
|
120
|
-
} from "./chunks/chunk-
|
|
120
|
+
} from "./chunks/chunk-JE53PC46.js";
|
|
121
121
|
import {
|
|
122
122
|
AGENTS_CONTEXT_FILE_NAME,
|
|
123
123
|
AgentSessionController,
|
|
@@ -157,8 +157,8 @@ import {
|
|
|
157
157
|
setEnablementInMap,
|
|
158
158
|
setExtensionEnabledInSettings,
|
|
159
159
|
verifyPreparedCompactionCommit
|
|
160
|
-
} from "./chunks/chunk-
|
|
161
|
-
import "./chunks/chunk-
|
|
160
|
+
} from "./chunks/chunk-J6EZ335F.js";
|
|
161
|
+
import "./chunks/chunk-MTH6QSYD.js";
|
|
162
162
|
import {
|
|
163
163
|
ALL_THINKING_LEVELS,
|
|
164
164
|
Deref,
|
|
@@ -183,7 +183,7 @@ import {
|
|
|
183
183
|
streamSimple,
|
|
184
184
|
type_exports,
|
|
185
185
|
validateExplicitThinkingSelection
|
|
186
|
-
} from "./chunks/chunk-
|
|
186
|
+
} from "./chunks/chunk-YKV45EMY.js";
|
|
187
187
|
import {
|
|
188
188
|
IsArray,
|
|
189
189
|
IsBigInt,
|
|
@@ -53148,26 +53148,49 @@ Disable or narrow capabilities:
|
|
|
53148
53148
|
import { randomBytes } from "node:crypto";
|
|
53149
53149
|
import * as fs4 from "node:fs";
|
|
53150
53150
|
import * as path4 from "node:path";
|
|
53151
|
+
var DEFAULT_MODEL_API = "openai-responses";
|
|
53151
53152
|
var SUPPORTED_MODEL_APIS = [
|
|
53152
|
-
"openai-completions",
|
|
53153
53153
|
"openai-responses",
|
|
53154
|
+
"openai-completions",
|
|
53154
53155
|
"anthropic-messages"
|
|
53155
53156
|
];
|
|
53157
|
+
var OPENAI_COMPLETIONS_ONLY_COMPAT_KEYS = /* @__PURE__ */ new Set([
|
|
53158
|
+
"forcedReasoningEffort",
|
|
53159
|
+
"supportsDeveloperRole",
|
|
53160
|
+
"supportsUsageInStreaming",
|
|
53161
|
+
"maxTokensField",
|
|
53162
|
+
"requiresToolResultName",
|
|
53163
|
+
"requiresAssistantAfterToolResult",
|
|
53164
|
+
"requiresThinkingAsText",
|
|
53165
|
+
"supportsStrictMode",
|
|
53166
|
+
"streamRequiresDone",
|
|
53167
|
+
"streamRequiresFinishReason",
|
|
53168
|
+
"cacheCapability"
|
|
53169
|
+
]);
|
|
53170
|
+
var OPENAI_RESPONSES_ONLY_COMPAT_KEYS = /* @__PURE__ */ new Set([
|
|
53171
|
+
"store",
|
|
53172
|
+
"supportsEncryptedReasoning",
|
|
53173
|
+
"responsesContinuation",
|
|
53174
|
+
"supportsReasoningSummary",
|
|
53175
|
+
"reasoningSummary",
|
|
53176
|
+
"timeoutReplay",
|
|
53177
|
+
"supportsPromptCacheKey"
|
|
53178
|
+
]);
|
|
53156
53179
|
function getDefaultModelsPath() {
|
|
53157
53180
|
return path4.join(getConfigDir(), "models.json");
|
|
53158
53181
|
}
|
|
53159
53182
|
function createModelsTemplate() {
|
|
53160
53183
|
const template = {
|
|
53161
53184
|
profiles: {
|
|
53162
|
-
"example-
|
|
53163
|
-
api: "openai-
|
|
53185
|
+
"example-responses": {
|
|
53186
|
+
api: "openai-responses",
|
|
53164
53187
|
baseUrl: "https://api.example.com/v1",
|
|
53165
|
-
apiKeyEnv: "
|
|
53188
|
+
apiKeyEnv: "PIE_EXAMPLE_RESPONSES_API_KEY",
|
|
53166
53189
|
models: [
|
|
53167
53190
|
{
|
|
53168
|
-
id: "your-
|
|
53169
|
-
name: "Your
|
|
53170
|
-
reasoning:
|
|
53191
|
+
id: "your-model",
|
|
53192
|
+
name: "Your Model",
|
|
53193
|
+
reasoning: true,
|
|
53171
53194
|
input: ["text", "image"],
|
|
53172
53195
|
contextWindow: 128e3,
|
|
53173
53196
|
maxTokens: 16384,
|
|
@@ -53176,6 +53199,9 @@ function createModelsTemplate() {
|
|
|
53176
53199
|
output: 0,
|
|
53177
53200
|
cacheRead: 0,
|
|
53178
53201
|
cacheWrite: 0
|
|
53202
|
+
},
|
|
53203
|
+
webSearch: {
|
|
53204
|
+
type: "openai_responses"
|
|
53179
53205
|
}
|
|
53180
53206
|
}
|
|
53181
53207
|
]
|
|
@@ -53236,12 +53262,12 @@ function createModelsTemplate() {
|
|
|
53236
53262
|
}
|
|
53237
53263
|
},
|
|
53238
53264
|
defaults: {
|
|
53239
|
-
provider: "example-
|
|
53240
|
-
modelId: "your-
|
|
53265
|
+
provider: "example-responses",
|
|
53266
|
+
modelId: "your-model",
|
|
53241
53267
|
modelClasses: {
|
|
53242
|
-
light: { provider: "example-
|
|
53243
|
-
balanced: { provider: "example-
|
|
53244
|
-
strong: { provider: "example-
|
|
53268
|
+
light: { provider: "example-responses", modelId: "your-model" },
|
|
53269
|
+
balanced: { provider: "example-responses", modelId: "your-model" },
|
|
53270
|
+
strong: { provider: "example-responses", modelId: "your-model" }
|
|
53245
53271
|
}
|
|
53246
53272
|
}
|
|
53247
53273
|
};
|
|
@@ -53426,6 +53452,7 @@ function validateModelsConfig(options = {}) {
|
|
|
53426
53452
|
const routePurposes = ["web_search", "read_file.image", "read_file.video", "read_file.audio", "read_file.document"];
|
|
53427
53453
|
const webSearchRouteCandidates = registry.resolveToolModelCandidates("web_search").filter((route) => route.model).map((route) => `${route.model?.provider}/${route.model?.id}:${route.model?.webSearch?.type}:${route.routeSource}`);
|
|
53428
53454
|
const toolModelRoutes = routePurposes.map((purpose) => registry.resolveToolModel(purpose)).filter((route) => route.model).map((route) => `${route.purpose}:${route.model?.provider}/${route.model?.id}:${route.routeSource}`).sort();
|
|
53455
|
+
const warnings = collectCompatApiWarnings(models);
|
|
53429
53456
|
return {
|
|
53430
53457
|
ok: true,
|
|
53431
53458
|
path: modelsPath,
|
|
@@ -53437,9 +53464,32 @@ function validateModelsConfig(options = {}) {
|
|
|
53437
53464
|
webSearchRouteCandidates,
|
|
53438
53465
|
fileCapabilityModels,
|
|
53439
53466
|
modelClasses,
|
|
53440
|
-
toolModelRoutes
|
|
53467
|
+
toolModelRoutes,
|
|
53468
|
+
...warnings.length > 0 ? { warnings } : {}
|
|
53441
53469
|
};
|
|
53442
53470
|
}
|
|
53471
|
+
function collectCompatApiWarnings(models) {
|
|
53472
|
+
const warnings = [];
|
|
53473
|
+
for (const model of models) {
|
|
53474
|
+
if (!model.compat || typeof model.compat !== "object" || Array.isArray(model.compat)) continue;
|
|
53475
|
+
const keys = Object.keys(model.compat).sort();
|
|
53476
|
+
if (keys.length === 0) continue;
|
|
53477
|
+
if (model.api === "openai-responses") {
|
|
53478
|
+
const ignored = keys.filter((k2) => OPENAI_COMPLETIONS_ONLY_COMPAT_KEYS.has(k2));
|
|
53479
|
+
if (ignored.length > 0) {
|
|
53480
|
+
warnings.push(`Model "${model.provider}/${model.id}" uses api "openai-responses" but sets Chat-Completions-only compat key(s): ${ignored.join(", ")} (ignored by Responses).`);
|
|
53481
|
+
}
|
|
53482
|
+
} else if (model.api === "openai-completions") {
|
|
53483
|
+
const ignored = keys.filter((k2) => OPENAI_RESPONSES_ONLY_COMPAT_KEYS.has(k2));
|
|
53484
|
+
if (ignored.length > 0) {
|
|
53485
|
+
warnings.push(`Model "${model.provider}/${model.id}" uses api "openai-completions" but sets Responses-only compat key(s): ${ignored.join(", ")} (ignored by Chat Completions).`);
|
|
53486
|
+
}
|
|
53487
|
+
} else if (model.api === "anthropic-messages") {
|
|
53488
|
+
warnings.push(`Model "${model.provider}/${model.id}" uses api "anthropic-messages" but sets compat key(s): ${keys.join(", ")} (ignored by Anthropic adapter).`);
|
|
53489
|
+
}
|
|
53490
|
+
}
|
|
53491
|
+
return warnings.sort();
|
|
53492
|
+
}
|
|
53443
53493
|
async function probeModelsConfig(options) {
|
|
53444
53494
|
const registry = new ModelRegistry(AuthStorage.create(), resolveModelsPath(options.path));
|
|
53445
53495
|
const loadError = registry.getLoadError();
|
|
@@ -53785,12 +53835,12 @@ var MODELS_INIT_SPEC = {
|
|
|
53785
53835
|
var MODELS_ADD_SPEC = {
|
|
53786
53836
|
path: "models add",
|
|
53787
53837
|
summary: "Add or update a usable model profile in models.json (interactive in TTY or via flags).",
|
|
53788
|
-
usage: "models add [--profile <name>] [--api <openai-
|
|
53838
|
+
usage: "models add [--profile <name>] [--api <openai-responses|openai-completions|anthropic-messages>] [--base-url <url>] [--model <id>] [--api-key-env <VAR> | --api-key <key>] [--reasoning] [--default] [--backup-corrupt] [--path <path>] [--json]",
|
|
53789
53839
|
flags: [
|
|
53790
53840
|
{ name: "--json", kind: "boolean", description: "Emit the machine envelope (compact JSON)." },
|
|
53791
53841
|
{ name: "--path", kind: "string", description: "Target models.json path (default ~/.pie/models.json)." },
|
|
53792
53842
|
{ name: "--profile", kind: "string", description: "Profile/provider name (e.g. openai, anthropic, deepseek)." },
|
|
53793
|
-
{ name: "--api", kind: "string", description: "Protocol: openai-
|
|
53843
|
+
{ name: "--api", kind: "string", description: "Protocol: openai-responses (default, HTTP SSE), openai-completions, or anthropic-messages." },
|
|
53794
53844
|
{ name: "--base-url", kind: "string", description: "Provider API base URL (https://...)." },
|
|
53795
53845
|
{ name: "--model", kind: "string", description: "Model ID exposed by the provider." },
|
|
53796
53846
|
{ name: "--name", kind: "string", description: "Optional display name for the model." },
|
|
@@ -54138,8 +54188,8 @@ ${renderCommandUsage(MODELS_ADD_SPEC)}`, allArgs);
|
|
|
54138
54188
|
try {
|
|
54139
54189
|
if (!profile) profile = (await rl.question("Profile name (e.g. openai, anthropic, custom): ")).trim();
|
|
54140
54190
|
if (!api) {
|
|
54141
|
-
const ans = (await rl.question(`API protocol [${SUPPORTED_MODEL_APIS.join(" / ")}] (default
|
|
54142
|
-
api = ans ||
|
|
54191
|
+
const ans = (await rl.question(`API protocol [${SUPPORTED_MODEL_APIS.join(" / ")}] (default ${DEFAULT_MODEL_API}): `)).trim();
|
|
54192
|
+
api = ans || DEFAULT_MODEL_API;
|
|
54143
54193
|
}
|
|
54144
54194
|
if (!baseUrl) baseUrl = (await rl.question("Base URL (e.g. https://api.openai.com/v1): ")).trim();
|
|
54145
54195
|
if (!modelId) modelId = (await rl.question("Model ID (e.g. gpt-4.1, claude-sonnet-4-5): ")).trim();
|
|
@@ -54159,7 +54209,7 @@ ${renderCommandUsage(MODELS_ADD_SPEC)}`, allArgs);
|
|
|
54159
54209
|
const result = addModelProfile({
|
|
54160
54210
|
path: getFlagString(parsed, "--path"),
|
|
54161
54211
|
profile: profile ?? "",
|
|
54162
|
-
api: api ??
|
|
54212
|
+
api: api ?? DEFAULT_MODEL_API,
|
|
54163
54213
|
baseUrl: baseUrl ?? "",
|
|
54164
54214
|
modelId: modelId ?? "",
|
|
54165
54215
|
modelName: getFlagString(parsed, "--name"),
|
|
@@ -54265,6 +54315,12 @@ ${renderCommandUsage(MODELS_VALIDATE_SPEC)}`, allArgs);
|
|
|
54265
54315
|
if (result.toolModelRoutes && result.toolModelRoutes.length > 0) {
|
|
54266
54316
|
console.log(`Tool model routes: ${result.toolModelRoutes.join(", ")}`);
|
|
54267
54317
|
}
|
|
54318
|
+
if (result.warnings && result.warnings.length > 0) {
|
|
54319
|
+
console.log("Warnings:");
|
|
54320
|
+
for (const warning of result.warnings) {
|
|
54321
|
+
console.log(`- ${warning}`);
|
|
54322
|
+
}
|
|
54323
|
+
}
|
|
54268
54324
|
if (probePurpose) {
|
|
54269
54325
|
const probeReport = probe ?? await probeModelsConfig({ path: getFlagString(parsed, "--path"), probe: probePurpose });
|
|
54270
54326
|
console.log(`Probe ${probeReport.purpose}: ${probeReport.message}`);
|
|
@@ -71192,7 +71248,7 @@ async function forkAtEntry(host, entryId) {
|
|
|
71192
71248
|
);
|
|
71193
71249
|
}
|
|
71194
71250
|
}
|
|
71195
|
-
async function navigateToEntry(host, entryId) {
|
|
71251
|
+
async function navigateToEntry(host, entryId, opts) {
|
|
71196
71252
|
try {
|
|
71197
71253
|
const success = host.sessionManager.branch(entryId);
|
|
71198
71254
|
if (!success) {
|
|
@@ -71222,6 +71278,7 @@ async function navigateToEntry(host, entryId) {
|
|
|
71222
71278
|
host.showError(
|
|
71223
71279
|
`Failed to navigate: ${error instanceof Error ? error.message : String(error)}`
|
|
71224
71280
|
);
|
|
71281
|
+
if (opts?.throwOnError) throw error;
|
|
71225
71282
|
}
|
|
71226
71283
|
}
|
|
71227
71284
|
function renderChatHistory(host, messages) {
|
|
@@ -75649,7 +75706,8 @@ async function handleCompactCommand(host) {
|
|
|
75649
75706
|
const compactOptions = {
|
|
75650
75707
|
model: host.options.model,
|
|
75651
75708
|
apiKey: host.options.apiKey,
|
|
75652
|
-
systemPrompt: host.agent.state.systemPrompt
|
|
75709
|
+
systemPrompt: host.agent.state.systemPrompt,
|
|
75710
|
+
sessionId: host.agent.sessionId ?? host.sessionManager.getActiveSession()?.id
|
|
75653
75711
|
};
|
|
75654
75712
|
let summary;
|
|
75655
75713
|
const beforeCompact = await host.extensionRunner?.emitSessionBeforeCompact({
|
|
@@ -79338,6 +79396,7 @@ async function createCliAutoCompactionResult(params) {
|
|
|
79338
79396
|
model: params.model,
|
|
79339
79397
|
apiKey: params.apiKey,
|
|
79340
79398
|
systemPrompt: params.systemPrompt,
|
|
79399
|
+
sessionId: params.context.sessionManager.getActiveSession()?.id,
|
|
79341
79400
|
signal: params.context.signal
|
|
79342
79401
|
};
|
|
79343
79402
|
const summary = await createCompactionSummary(projectCliHostEnvelopes(params.context.messages, params.onProjection, params.envelopeRegistry), compactOptions);
|
|
@@ -80194,7 +80253,7 @@ function takePendingManualCompactSummary(controller) {
|
|
|
80194
80253
|
function isJournalOnlyControlAudit(customType, data) {
|
|
80195
80254
|
if (customType !== "pie.ipc.control") return false;
|
|
80196
80255
|
const control = data?.control;
|
|
80197
|
-
return control === "session.context" || control === "session.compact" || control === "turn.abort" || control === "session.shutdown";
|
|
80256
|
+
return control === "session.context" || control === "session.compact" || control === "session.tree" || control === "session.branch" || control === "turn.abort" || control === "session.shutdown";
|
|
80198
80257
|
}
|
|
80199
80258
|
function isJournalOnlyAuditEntry(customType, data, options) {
|
|
80200
80259
|
if (isJournalOnlyControlAudit(customType, data)) return true;
|
|
@@ -80620,7 +80679,8 @@ function createCacheRetentionStreamFn(configured, getConfiguredRetention) {
|
|
|
80620
80679
|
const base = configured ?? ((model, context, options) => streamSimple(model, context, options));
|
|
80621
80680
|
return (model, context, options) => {
|
|
80622
80681
|
const requested = options?.cacheRetention;
|
|
80623
|
-
const
|
|
80682
|
+
const setting = getConfiguredRetention?.();
|
|
80683
|
+
const configuredRetention = model.api === "anthropic-messages" ? setting : model.api === "openai-responses" && setting === "none" ? "none" : void 0;
|
|
80624
80684
|
const cacheRetention = requested ?? configuredRetention;
|
|
80625
80685
|
return base(model, context, {
|
|
80626
80686
|
...options,
|
|
@@ -81233,6 +81293,236 @@ function showExtensionCustom(host, factory, options) {
|
|
|
81233
81293
|
});
|
|
81234
81294
|
}
|
|
81235
81295
|
|
|
81296
|
+
// src/runtime/headless-session-tree.ts
|
|
81297
|
+
var ANSI_ESCAPE_RE2 = /\x1b(?:\[[0-?]*[ -/]*[@-~]|\][^\x07\x1b]*(?:\x07|\x1b\\)|[@-Z\\-_])/g;
|
|
81298
|
+
var CONTROL_CHARS_RE2 = /[\x00-\x1f\x7f-\x9f]/g;
|
|
81299
|
+
var HAS_CONTROL_CHAR_RE = /[\x00-\x1f\x7f-\x9f]/;
|
|
81300
|
+
var MAX_SCAN_ENTRIES = 12800;
|
|
81301
|
+
var MAX_SCAN_CHUNKS = 500;
|
|
81302
|
+
var SCAN_CHUNK_SIZE = 256;
|
|
81303
|
+
var MAX_TREE_PREVIEW_CHARS = 88;
|
|
81304
|
+
var MAX_ENTRY_ID_LEN = 128;
|
|
81305
|
+
function isValidTreeEntryId(value) {
|
|
81306
|
+
return typeof value === "string" && value.length > 0 && value.length <= MAX_ENTRY_ID_LEN && !HAS_CONTROL_CHAR_RE.test(value) && !/\s/.test(value);
|
|
81307
|
+
}
|
|
81308
|
+
function classifyTreeEntryKind(summary) {
|
|
81309
|
+
if (summary.type === "compaction") return "compaction";
|
|
81310
|
+
if (summary.type === "fork") return "fork";
|
|
81311
|
+
if (summary.type === "custom") return "custom";
|
|
81312
|
+
if (summary.role === "user") return "user";
|
|
81313
|
+
if (summary.role === "assistant") return "assistant";
|
|
81314
|
+
if (summary.role === "toolResult" || summary.role === "tool") return "tool";
|
|
81315
|
+
return "custom";
|
|
81316
|
+
}
|
|
81317
|
+
function cleanTreePreview(summary) {
|
|
81318
|
+
let text = (summary.preview ?? "").replace(ANSI_ESCAPE_RE2, "").replace(/[\r\n\t]+/g, " ").replace(CONTROL_CHARS_RE2, "").trim();
|
|
81319
|
+
if (summary.type === "message" && summary.role === "user") {
|
|
81320
|
+
if (text.startsWith("[pie-ipc]")) {
|
|
81321
|
+
const unwrapped = text.replace(/^\[pie-ipc\][^\n]*?says:\s*/, "").trim();
|
|
81322
|
+
if (unwrapped) text = unwrapped;
|
|
81323
|
+
}
|
|
81324
|
+
text = text.replace(/^\[(?:Feishu|Lark|Slack|Telegram|Discord|IM)\]\s*/, "").trim();
|
|
81325
|
+
text = text.replace(/^(?:<at\b[^>]*>[^<]*<\/at>\s*)+/, "").trim();
|
|
81326
|
+
}
|
|
81327
|
+
text = text.replace(/\s+/g, " ").trim();
|
|
81328
|
+
if (!text && summary.type === "custom" && summary.customType) {
|
|
81329
|
+
text = `[${summary.customType}]`;
|
|
81330
|
+
}
|
|
81331
|
+
if (text.length <= MAX_TREE_PREVIEW_CHARS) return text;
|
|
81332
|
+
return `${text.slice(0, MAX_TREE_PREVIEW_CHARS - 1)}\u2026`;
|
|
81333
|
+
}
|
|
81334
|
+
function toNodeSummary(summary, activeEntryId, activePathSeqs) {
|
|
81335
|
+
const onActivePath = activePathSeqs.has(summary.seq);
|
|
81336
|
+
const isHead = activeEntryId !== null && summary.id === activeEntryId;
|
|
81337
|
+
let activePathAfterCount = 0;
|
|
81338
|
+
if (onActivePath && !isHead) {
|
|
81339
|
+
for (const s of activePathSeqs) {
|
|
81340
|
+
if (s > summary.seq) activePathAfterCount += 1;
|
|
81341
|
+
}
|
|
81342
|
+
}
|
|
81343
|
+
return {
|
|
81344
|
+
seq: summary.seq,
|
|
81345
|
+
id: summary.id,
|
|
81346
|
+
parentSeq: summary.parentSeq,
|
|
81347
|
+
kind: classifyTreeEntryKind(summary),
|
|
81348
|
+
timestamp: summary.timestamp,
|
|
81349
|
+
preview: cleanTreePreview(summary),
|
|
81350
|
+
childCount: summary.childCount,
|
|
81351
|
+
estTokens: summary.estTokens,
|
|
81352
|
+
onActivePath,
|
|
81353
|
+
isHead,
|
|
81354
|
+
isBranchPoint: summary.childCount > 1,
|
|
81355
|
+
isBranchTip: !onActivePath && summary.childCount === 0,
|
|
81356
|
+
activePathAfterCount,
|
|
81357
|
+
...summary.label ? { label: summary.label.replace(CONTROL_CHARS_RE2, "").slice(0, 40) } : {}
|
|
81358
|
+
};
|
|
81359
|
+
}
|
|
81360
|
+
function isKeyTreeEntry(summary, activeEntryId, activePathSeqs) {
|
|
81361
|
+
if (activeEntryId !== null && summary.id === activeEntryId) return true;
|
|
81362
|
+
if (summary.type === "compaction" || summary.type === "fork") return true;
|
|
81363
|
+
if (summary.childCount > 1) return true;
|
|
81364
|
+
if (summary.childCount === 0 && !activePathSeqs.has(summary.seq)) return true;
|
|
81365
|
+
return summary.type === "message" && summary.role === "user";
|
|
81366
|
+
}
|
|
81367
|
+
function buildHeadlessSessionTreeReport(params) {
|
|
81368
|
+
const activeSession = params.sessionManager.getActiveSession();
|
|
81369
|
+
if (!activeSession) {
|
|
81370
|
+
return { ok: false, reason: "no active session" };
|
|
81371
|
+
}
|
|
81372
|
+
const raw = params.payload && typeof params.payload === "object" && !Array.isArray(params.payload) ? params.payload : {};
|
|
81373
|
+
const activeEntryId = params.sessionManager.getActiveEntryId();
|
|
81374
|
+
const activePathSeqs = params.sessionManager.getActivePathSeqs();
|
|
81375
|
+
if (raw.entryId !== void 0) {
|
|
81376
|
+
if (!isValidTreeEntryId(raw.entryId)) {
|
|
81377
|
+
return { ok: false, reason: "invalid entryId" };
|
|
81378
|
+
}
|
|
81379
|
+
const summary = params.sessionManager.getEntrySummary(raw.entryId);
|
|
81380
|
+
return {
|
|
81381
|
+
ok: true,
|
|
81382
|
+
report: {
|
|
81383
|
+
mode: "entry",
|
|
81384
|
+
sessionId: activeSession.id,
|
|
81385
|
+
activeEntryId,
|
|
81386
|
+
activePathLength: activePathSeqs.size,
|
|
81387
|
+
isIdle: params.isIdle,
|
|
81388
|
+
compactionRunning: params.compactionRunning,
|
|
81389
|
+
entry: summary ? toNodeSummary(summary, activeEntryId, activePathSeqs) : null
|
|
81390
|
+
}
|
|
81391
|
+
};
|
|
81392
|
+
}
|
|
81393
|
+
const filter = raw.filter === "all" ? "all" : "key";
|
|
81394
|
+
const reqPageSize = typeof raw.pageSize === "number" && Number.isFinite(raw.pageSize) ? Math.floor(raw.pageSize) : 5;
|
|
81395
|
+
const pageSize = Math.min(Math.max(1, reqPageSize), 8);
|
|
81396
|
+
const reqPage = typeof raw.page === "number" && Number.isFinite(raw.page) ? Math.floor(raw.page) : 1;
|
|
81397
|
+
const probe = params.sessionManager.getEntrySummariesPage({ limit: 1 });
|
|
81398
|
+
const totalEntries = probe.total;
|
|
81399
|
+
let truncated = false;
|
|
81400
|
+
let afterSeq;
|
|
81401
|
+
const scanned = [];
|
|
81402
|
+
for (let p = 0; p < MAX_SCAN_CHUNKS; p += 1) {
|
|
81403
|
+
const chunk = params.sessionManager.getEntrySummariesPage({ limit: SCAN_CHUNK_SIZE, afterSeq });
|
|
81404
|
+
if (chunk.summaries.length === 0) break;
|
|
81405
|
+
scanned.push(...chunk.summaries);
|
|
81406
|
+
if (scanned.length > MAX_SCAN_ENTRIES * 2) {
|
|
81407
|
+
scanned.splice(0, scanned.length - MAX_SCAN_ENTRIES);
|
|
81408
|
+
truncated = true;
|
|
81409
|
+
}
|
|
81410
|
+
const lastSeq = chunk.summaries[chunk.summaries.length - 1].seq;
|
|
81411
|
+
if (!chunk.hasMore || afterSeq !== void 0 && lastSeq <= afterSeq) break;
|
|
81412
|
+
afterSeq = lastSeq;
|
|
81413
|
+
if (p === MAX_SCAN_CHUNKS - 1 && chunk.hasMore) truncated = true;
|
|
81414
|
+
}
|
|
81415
|
+
if (scanned.length > MAX_SCAN_ENTRIES) {
|
|
81416
|
+
scanned.splice(0, scanned.length - MAX_SCAN_ENTRIES);
|
|
81417
|
+
truncated = true;
|
|
81418
|
+
}
|
|
81419
|
+
if (activeEntryId && !scanned.some((s) => s.id === activeEntryId)) {
|
|
81420
|
+
const headSummary = params.sessionManager.getEntrySummary(activeEntryId);
|
|
81421
|
+
if (headSummary) scanned.push(headSummary);
|
|
81422
|
+
}
|
|
81423
|
+
let branchPointCount = 0;
|
|
81424
|
+
let otherBranchTipCount = 0;
|
|
81425
|
+
for (const s of scanned) {
|
|
81426
|
+
if (s.childCount > 1) branchPointCount += 1;
|
|
81427
|
+
if (s.childCount === 0 && !activePathSeqs.has(s.seq)) otherBranchTipCount += 1;
|
|
81428
|
+
}
|
|
81429
|
+
const matched = filter === "all" ? scanned : scanned.filter((s) => isKeyTreeEntry(s, activeEntryId, activePathSeqs));
|
|
81430
|
+
matched.sort((a, b2) => b2.seq - a.seq);
|
|
81431
|
+
const totalFiltered = matched.length;
|
|
81432
|
+
const totalPages = Math.max(1, Math.ceil(totalFiltered / pageSize));
|
|
81433
|
+
const page = Math.min(Math.max(1, reqPage), totalPages);
|
|
81434
|
+
const slice = matched.slice((page - 1) * pageSize, page * pageSize);
|
|
81435
|
+
return {
|
|
81436
|
+
ok: true,
|
|
81437
|
+
report: {
|
|
81438
|
+
mode: "page",
|
|
81439
|
+
sessionId: activeSession.id,
|
|
81440
|
+
activeEntryId,
|
|
81441
|
+
activePathLength: activePathSeqs.size,
|
|
81442
|
+
totalEntries,
|
|
81443
|
+
totalFiltered,
|
|
81444
|
+
branchPointCount,
|
|
81445
|
+
otherBranchTipCount,
|
|
81446
|
+
filter,
|
|
81447
|
+
page,
|
|
81448
|
+
pageSize,
|
|
81449
|
+
totalPages,
|
|
81450
|
+
isIdle: params.isIdle,
|
|
81451
|
+
compactionRunning: params.compactionRunning,
|
|
81452
|
+
...truncated ? { truncated: true } : {},
|
|
81453
|
+
nodes: slice.map((s) => toNodeSummary(s, activeEntryId, activePathSeqs))
|
|
81454
|
+
}
|
|
81455
|
+
};
|
|
81456
|
+
}
|
|
81457
|
+
var branchInFlightBySession = /* @__PURE__ */ new Set();
|
|
81458
|
+
async function runHeadlessSessionBranch(params) {
|
|
81459
|
+
const activeSession = params.sessionManager.getActiveSession();
|
|
81460
|
+
if (!activeSession) {
|
|
81461
|
+
return { ok: false, reason: "no active session" };
|
|
81462
|
+
}
|
|
81463
|
+
const raw = params.payload && typeof params.payload === "object" && !Array.isArray(params.payload) ? params.payload : {};
|
|
81464
|
+
if (!isValidTreeEntryId(raw.entryId)) {
|
|
81465
|
+
return { ok: false, reason: "session.branch requires a valid payload.entryId" };
|
|
81466
|
+
}
|
|
81467
|
+
if (typeof raw.expectedSessionId === "string" && raw.expectedSessionId.trim() && raw.expectedSessionId.trim() !== activeSession.id) {
|
|
81468
|
+
return { ok: false, reason: "target session changed; refresh tree before retrying" };
|
|
81469
|
+
}
|
|
81470
|
+
const busyReason = params.isBusy();
|
|
81471
|
+
if (busyReason) {
|
|
81472
|
+
return { ok: false, reason: busyReason };
|
|
81473
|
+
}
|
|
81474
|
+
if (branchInFlightBySession.has(activeSession.id)) {
|
|
81475
|
+
return { ok: false, reason: "a branch switch is already in progress; retry shortly" };
|
|
81476
|
+
}
|
|
81477
|
+
const target = params.sessionManager.getEntrySummary(raw.entryId);
|
|
81478
|
+
if (!target) {
|
|
81479
|
+
return { ok: false, reason: `entry "${raw.entryId}" not found in active session` };
|
|
81480
|
+
}
|
|
81481
|
+
const fromEntryId = params.sessionManager.getActiveEntryId();
|
|
81482
|
+
const alreadyActive = fromEntryId === raw.entryId;
|
|
81483
|
+
if (!alreadyActive) {
|
|
81484
|
+
branchInFlightBySession.add(activeSession.id);
|
|
81485
|
+
try {
|
|
81486
|
+
if (params.applyBranch) {
|
|
81487
|
+
await params.applyBranch(raw.entryId);
|
|
81488
|
+
if (params.sessionManager.getActiveEntryId() !== raw.entryId) {
|
|
81489
|
+
return { ok: false, reason: `failed to switch branch to "${raw.entryId}"` };
|
|
81490
|
+
}
|
|
81491
|
+
} else {
|
|
81492
|
+
const ok = params.sessionManager.branch(raw.entryId);
|
|
81493
|
+
if (!ok) {
|
|
81494
|
+
return { ok: false, reason: `failed to switch branch to "${raw.entryId}"` };
|
|
81495
|
+
}
|
|
81496
|
+
await params.syncRuntime();
|
|
81497
|
+
}
|
|
81498
|
+
await params.sessionManager.save();
|
|
81499
|
+
} catch (error) {
|
|
81500
|
+
if (params.sessionManager.getActiveEntryId() !== fromEntryId) {
|
|
81501
|
+
try {
|
|
81502
|
+
params.sessionManager.branch(fromEntryId);
|
|
81503
|
+
await params.syncRuntime();
|
|
81504
|
+
} catch {
|
|
81505
|
+
}
|
|
81506
|
+
}
|
|
81507
|
+
return { ok: false, reason: error instanceof Error ? error.message : String(error) };
|
|
81508
|
+
} finally {
|
|
81509
|
+
branchInFlightBySession.delete(activeSession.id);
|
|
81510
|
+
}
|
|
81511
|
+
}
|
|
81512
|
+
return {
|
|
81513
|
+
ok: true,
|
|
81514
|
+
sessionId: activeSession.id,
|
|
81515
|
+
fromEntryId,
|
|
81516
|
+
activeEntryId: raw.entryId,
|
|
81517
|
+
alreadyActive,
|
|
81518
|
+
seq: target.seq,
|
|
81519
|
+
kind: classifyTreeEntryKind(target),
|
|
81520
|
+
preview: cleanTreePreview(target),
|
|
81521
|
+
pathLength: params.sessionManager.getActivePathSeqs().size,
|
|
81522
|
+
messageCount: params.sessionManager.getMessages().length
|
|
81523
|
+
};
|
|
81524
|
+
}
|
|
81525
|
+
|
|
81236
81526
|
// src/extensions/provider-login.ts
|
|
81237
81527
|
var inFlightLogins = /* @__PURE__ */ new Map();
|
|
81238
81528
|
async function loginExtensionProvider(options) {
|
|
@@ -81678,6 +81968,41 @@ async function loadInteractiveExtensions(host) {
|
|
|
81678
81968
|
message: `manual compaction submitted for ${receipt.sessionId || "session"}; the outcome is observable via session.context (lastCompactOutcome) \u2014 a controller-side refusal (busy/transitioning) also lands there`
|
|
81679
81969
|
};
|
|
81680
81970
|
}
|
|
81971
|
+
if (control === "session.tree") {
|
|
81972
|
+
const controller = host.agentSessionController;
|
|
81973
|
+
const busy = Boolean(host.submitLock || host.isProcessing || host.isInterrupting || host.agent.state.isStreaming || host.isWaitingForUserInteraction?.() || controller && (controller.hasQueuedMessages || controller.turnRecoveryState === "retry_pending" || controller.turnRecoveryState === "retrying" || controller.turnRecoveryState === "compacting"));
|
|
81974
|
+
const compacting = manualCompactRunning || Boolean(host.isCompacting) || controller?.turnRecoveryState === "compacting";
|
|
81975
|
+
const result = buildHeadlessSessionTreeReport({
|
|
81976
|
+
sessionManager: host.sessionManager,
|
|
81977
|
+
isIdle: !busy && !compacting,
|
|
81978
|
+
compactionRunning: compacting,
|
|
81979
|
+
payload
|
|
81980
|
+
});
|
|
81981
|
+
return result.ok ? { ok: true, message: JSON.stringify(result.report) } : { ok: false, message: result.reason };
|
|
81982
|
+
}
|
|
81983
|
+
if (control === "session.branch") {
|
|
81984
|
+
const controller = host.agentSessionController;
|
|
81985
|
+
const result = await runHeadlessSessionBranch({
|
|
81986
|
+
sessionManager: host.sessionManager,
|
|
81987
|
+
syncRuntime: () => {
|
|
81988
|
+
controller?.syncFromActiveSession();
|
|
81989
|
+
},
|
|
81990
|
+
applyBranch: host.branchForIpcControl ? (entryId) => host.branchForIpcControl(entryId) : void 0,
|
|
81991
|
+
isBusy: () => {
|
|
81992
|
+
if (manualCompactRunning || host.isCompacting || controller?.turnRecoveryState === "compacting") {
|
|
81993
|
+
return "a compaction is running; wait for it to finish";
|
|
81994
|
+
}
|
|
81995
|
+
if (host.submitLock || host.isProcessing || host.agent.state.isStreaming || controller?.hasQueuedMessages || controller?.turnRecoveryState === "retry_pending" || controller?.turnRecoveryState === "retrying") {
|
|
81996
|
+
return "a turn is active or queued; stop it before switching branch";
|
|
81997
|
+
}
|
|
81998
|
+
if (host.isInterrupting) return "turn interrupt in progress; retry when idle";
|
|
81999
|
+
if (host.isWaitingForUserInteraction?.()) return "waiting for user interaction; retry when idle";
|
|
82000
|
+
return null;
|
|
82001
|
+
},
|
|
82002
|
+
payload
|
|
82003
|
+
});
|
|
82004
|
+
return result.ok ? { ok: true, message: JSON.stringify(result) } : { ok: false, message: result.reason };
|
|
82005
|
+
}
|
|
81681
82006
|
if (control === "turn.abort") {
|
|
81682
82007
|
const busy = host.isProcessing || host.agent.state.isStreaming;
|
|
81683
82008
|
if (!busy) return { ok: true, message: "already idle (no active turn)" };
|
|
@@ -82309,7 +82634,7 @@ var InteractiveMode = class {
|
|
|
82309
82634
|
const activeSession = this.sessionManager.getActiveSession();
|
|
82310
82635
|
this.thinkingLevelEphemeral = Boolean(this.options.explicitThinkingLevel);
|
|
82311
82636
|
this.thinkingLevel = resolveInitialThinkingLevel({ explicitThinkingLevel: this.options.explicitThinkingLevel, session: activeSession, settingsManager: this.options.settingsManager, model: this.options.model });
|
|
82312
|
-
const { Agent } = await import("./chunks/src-
|
|
82637
|
+
const { Agent } = await import("./chunks/src-FWL3LCBK.js");
|
|
82313
82638
|
this.agent = new Agent({
|
|
82314
82639
|
initialState: {
|
|
82315
82640
|
systemPrompt: this.buildSystemPrompt(),
|
|
@@ -82525,14 +82850,16 @@ var InteractiveMode = class {
|
|
|
82525
82850
|
async switchModel(fullModelId) {
|
|
82526
82851
|
return switchModel(this, fullModelId);
|
|
82527
82852
|
}
|
|
82528
|
-
|
|
82853
|
+
// IPC control parity: model.set, thinking.set (persist:false), and session.branch.
|
|
82529
82854
|
async switchModelForIpcControl(fullModelId) {
|
|
82530
82855
|
return this.switchModel(fullModelId);
|
|
82531
82856
|
}
|
|
82532
|
-
/** ipc control parity — thinking.set via the /think path, persist:false. */
|
|
82533
82857
|
setThinkingLevelForIpcControl(level) {
|
|
82534
82858
|
return setThinkingLevel(this, level, { persist: false });
|
|
82535
82859
|
}
|
|
82860
|
+
async branchForIpcControl(entryId) {
|
|
82861
|
+
return navigateToEntry(this, entryId, { throwOnError: true });
|
|
82862
|
+
}
|
|
82536
82863
|
showThinkingLevelSelector() {
|
|
82537
82864
|
return showThinkingLevelSelector(this);
|
|
82538
82865
|
}
|
|
@@ -82649,18 +82976,7 @@ var InteractiveMode = class {
|
|
|
82649
82976
|
return handleToolsCommand(this, args);
|
|
82650
82977
|
}
|
|
82651
82978
|
isInteractiveCommand(commandPath) {
|
|
82652
|
-
|
|
82653
|
-
"/skills/create",
|
|
82654
|
-
"/skills/use",
|
|
82655
|
-
"/tools/subagent",
|
|
82656
|
-
"/sessions/fork",
|
|
82657
|
-
// Plan submit/revise return agent-turn instructions the hierarchical
|
|
82658
|
-
// menu would otherwise discard: route them into the editor so the
|
|
82659
|
-
// input pipeline's result-processing handles them like typed commands.
|
|
82660
|
-
"/tools/plan/submit",
|
|
82661
|
-
"/tools/plan/revise"
|
|
82662
|
-
];
|
|
82663
|
-
return interactiveCommands.some((cmd) => commandPath.startsWith(cmd));
|
|
82979
|
+
return ["/skills/create", "/skills/use", "/tools/subagent", "/sessions/fork", "/tools/plan/submit", "/tools/plan/revise"].some((cmd) => commandPath.startsWith(cmd));
|
|
82664
82980
|
}
|
|
82665
82981
|
toggleYoloMode() {
|
|
82666
82982
|
void this.handleYoloCommand();
|
|
@@ -82703,7 +83019,7 @@ var InteractiveMode = class {
|
|
|
82703
83019
|
/** Live mention handler for extension-driven attachments (duck-typed onto
|
|
82704
83020
|
* InteractiveExtensionLoaderHost); undefined while attachments init. */
|
|
82705
83021
|
async describeImageFile(filePath, displayName) {
|
|
82706
|
-
const { describeImageViaUnderstandingChain } = await import("./chunks/host-image-fallback-
|
|
83022
|
+
const { describeImageViaUnderstandingChain } = await import("./chunks/host-image-fallback-GX2KXZXQ.js");
|
|
82707
83023
|
return describeImageViaUnderstandingChain({ modelRegistry: this.options.modelRegistry, getAgentModel: () => this.agent?.state.model, filePath, displayName });
|
|
82708
83024
|
}
|
|
82709
83025
|
activeModelInputs() {
|
|
@@ -83337,7 +83653,7 @@ async function runPrintMode(params) {
|
|
|
83337
83653
|
`);
|
|
83338
83654
|
console.log("Assistant: ");
|
|
83339
83655
|
}
|
|
83340
|
-
const { Agent: AgentClass } = await import("./chunks/src-
|
|
83656
|
+
const { Agent: AgentClass } = await import("./chunks/src-FWL3LCBK.js");
|
|
83341
83657
|
let agent;
|
|
83342
83658
|
const printModeExtensions = await loadPrintModeExtensions({
|
|
83343
83659
|
cwd: runtime.cwd,
|
|
@@ -84691,6 +85007,42 @@ async function loadJsonModeExtensions(params) {
|
|
|
84691
85007
|
if (receipt.status === "refused") return { ok: false, message: receipt.reason };
|
|
84692
85008
|
return { ok: true, message: `manual compaction submitted for ${receipt.sessionId || "session"}; the outcome is observable via session.context (lastCompactOutcome) \u2014 a controller-side refusal (busy/transitioning) also lands there` };
|
|
84693
85009
|
}
|
|
85010
|
+
if (control === "session.tree") {
|
|
85011
|
+
const controller = params.getController();
|
|
85012
|
+
if (!controller) return { ok: false, message: "runtime not composed" };
|
|
85013
|
+
const result = buildHeadlessSessionTreeReport({
|
|
85014
|
+
sessionManager: params.runtime.sessionManager,
|
|
85015
|
+
isIdle: hostIsIdle(controller) && !manualCompactRunning && !shutdownReserved,
|
|
85016
|
+
compactionRunning: manualCompactRunning,
|
|
85017
|
+
payload
|
|
85018
|
+
});
|
|
85019
|
+
return result.ok ? { ok: true, message: JSON.stringify(result.report) } : { ok: false, message: result.reason };
|
|
85020
|
+
}
|
|
85021
|
+
if (control === "session.branch") {
|
|
85022
|
+
const controller = params.getController();
|
|
85023
|
+
if (!controller) return { ok: false, message: "runtime not composed" };
|
|
85024
|
+
const result = await runHeadlessSessionBranch({
|
|
85025
|
+
sessionManager: params.runtime.sessionManager,
|
|
85026
|
+
syncRuntime: () => controller.syncFromActiveSession(),
|
|
85027
|
+
isBusy: () => {
|
|
85028
|
+
if (shutdownReserved) return "worker is shutting down; cannot switch branch";
|
|
85029
|
+
if (manualCompactRunning || controller.turnRecoveryState === "compacting") {
|
|
85030
|
+
return "a compaction is running; wait for it to finish";
|
|
85031
|
+
}
|
|
85032
|
+
if (!hostIsIdle(controller)) {
|
|
85033
|
+
return "a turn is active or queued; stop it before switching branch";
|
|
85034
|
+
}
|
|
85035
|
+
return null;
|
|
85036
|
+
},
|
|
85037
|
+
payload
|
|
85038
|
+
});
|
|
85039
|
+
if (!result.ok) return { ok: false, message: result.reason };
|
|
85040
|
+
writeEvent({
|
|
85041
|
+
type: "extension.log",
|
|
85042
|
+
message: `im/session.branch: switched to #${result.seq} (${result.activeEntryId}, path=${result.pathLength})`
|
|
85043
|
+
});
|
|
85044
|
+
return { ok: true, message: JSON.stringify(result) };
|
|
85045
|
+
}
|
|
84694
85046
|
if (control === "turn.abort") {
|
|
84695
85047
|
if (!params.abortActiveTurn) return { ok: false, message: "host does not support remote turn abort" };
|
|
84696
85048
|
const aborted = params.abortActiveTurn();
|
|
@@ -84812,7 +85164,7 @@ async function loadJsonModeExtensions(params) {
|
|
|
84812
85164
|
}
|
|
84813
85165
|
async function describeImageViaUnderstanding(params, filePath, displayName) {
|
|
84814
85166
|
try {
|
|
84815
|
-
const { understandReadFile: understandReadFile2 } = await import("./chunks/read-file-understanding-
|
|
85167
|
+
const { understandReadFile: understandReadFile2 } = await import("./chunks/read-file-understanding-ZRE5KDG3.js");
|
|
84816
85168
|
const ext = filePath.toLowerCase().split(".").pop() ?? "";
|
|
84817
85169
|
const mime = ext === "png" ? "image/png" : ext === "gif" ? "image/gif" : ext === "webp" ? "image/webp" : "image/jpeg";
|
|
84818
85170
|
const agentModel = params.getAgent?.()?.state?.model;
|
|
@@ -84987,7 +85339,7 @@ function createJsonEventsRuntimeManager(input) {
|
|
|
84987
85339
|
throw err;
|
|
84988
85340
|
}
|
|
84989
85341
|
}
|
|
84990
|
-
const { Agent: AgentClass } = await import("./chunks/src-
|
|
85342
|
+
const { Agent: AgentClass } = await import("./chunks/src-FWL3LCBK.js");
|
|
84991
85343
|
if (host.runtimeClosing) return;
|
|
84992
85344
|
const compositionRegistry = createCliHostEnvelopeRegistry();
|
|
84993
85345
|
const jsonModeExtensions = await loadJsonModeExtensions({
|
|
@@ -85940,7 +86292,7 @@ function createJsonEventsSidechatService(ctx) {
|
|
|
85940
86292
|
const sideTrace = trace();
|
|
85941
86293
|
const sideApiKey = rt.apiKey;
|
|
85942
86294
|
const snapshot = structuredClone(parent.state.messages);
|
|
85943
|
-
const { Agent: AgentClass } = await import("./chunks/src-
|
|
86295
|
+
const { Agent: AgentClass } = await import("./chunks/src-FWL3LCBK.js");
|
|
85944
86296
|
const sideAgent = new AgentClass({
|
|
85945
86297
|
initialState: {
|
|
85946
86298
|
systemPrompt: parent.state.systemPrompt,
|
|
@@ -85950,6 +86302,7 @@ function createJsonEventsSidechatService(ctx) {
|
|
|
85950
86302
|
messages: snapshot
|
|
85951
86303
|
},
|
|
85952
86304
|
apiKey: sideApiKey,
|
|
86305
|
+
sessionId: parent.sessionId ?? ctx.sessionId,
|
|
85953
86306
|
// The sidechat snapshot clones the parent's stored history, including
|
|
85954
86307
|
// persisted hostContext facts; project them like the main agent does.
|
|
85955
86308
|
transformContext: async (messages) => projectCliHostEnvelopes(
|
|
@@ -86541,6 +86894,9 @@ async function runJsonEventsMode(params) {
|
|
|
86541
86894
|
}
|
|
86542
86895
|
}
|
|
86543
86896
|
} finally {
|
|
86897
|
+
input.close();
|
|
86898
|
+
process.stdin.pause();
|
|
86899
|
+
process.stdin.unref?.();
|
|
86544
86900
|
await activeTurnPromise;
|
|
86545
86901
|
await activeSidechatPromise;
|
|
86546
86902
|
runtimeClosing = true;
|
|
@@ -86728,7 +87084,7 @@ async function runWithJsonEventsConsoleIsolation(fn) {
|
|
|
86728
87084
|
}
|
|
86729
87085
|
async function createCliTestStreamFnFromEnv() {
|
|
86730
87086
|
if (!process.env.PIE_TEST_MOCK_STREAM_SEQUENCE) return void 0;
|
|
86731
|
-
return (await import("./chunks/test-stream-
|
|
87087
|
+
return (await import("./chunks/test-stream-P3CUEGEE.js")).createTestStreamFnFromSequenceEnv();
|
|
86732
87088
|
}
|
|
86733
87089
|
async function startChat(initialPrompt, testCommand, explicitSessionId, explicitThinkingLevel, explicitModelRef) {
|
|
86734
87090
|
const flagArgv = flagArgsBeforeDelimiter(process.argv);
|