@cydm/pie 1.0.22 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builtin/extensions/ask-user/index.js +3 -3
- package/dist/builtin/extensions/plan-mode/index.js +3 -3
- package/dist/builtin/extensions/subagent/index.js +4 -4
- package/dist/builtin/extensions/todo/index.js +3 -3
- package/dist/chunks/{chunk-ZYOTRKU7.js → chunk-4WU5VAX4.js} +2 -2
- package/dist/chunks/{chunk-VESPMEDG.js → chunk-7ABSJC2D.js} +45 -7
- package/dist/chunks/{chunk-NHR6EBM2.js → chunk-AFTBFF6J.js} +2 -2
- package/dist/chunks/{chunk-L5BJNCNG.js → chunk-PUZP2Q3F.js} +1 -1
- package/dist/chunks/{src-2FHZO63Y.js → src-UCXJ4C6P.js} +2 -2
- package/dist/chunks/{test-stream-UW74PA6T.js → test-stream-UKULOPZB.js} +1 -1
- package/dist/cli.js +325 -68
- package/package.json +2 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
createAskUserCapability
|
|
4
|
-
} from "../../../chunks/chunk-
|
|
5
|
-
import "../../../chunks/chunk-
|
|
6
|
-
import "../../../chunks/chunk-
|
|
4
|
+
} from "../../../chunks/chunk-AFTBFF6J.js";
|
|
5
|
+
import "../../../chunks/chunk-PUZP2Q3F.js";
|
|
6
|
+
import "../../../chunks/chunk-7ABSJC2D.js";
|
|
7
7
|
import "../../../chunks/chunk-TG2EQLX2.js";
|
|
8
8
|
|
|
9
9
|
// builtin/extensions/ask-user/index.ts
|
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
isPlanModeSafeCommand,
|
|
8
8
|
markCompletedPlanSteps,
|
|
9
9
|
restoreExecutionState
|
|
10
|
-
} from "../../../chunks/chunk-
|
|
11
|
-
import "../../../chunks/chunk-
|
|
12
|
-
import "../../../chunks/chunk-
|
|
10
|
+
} from "../../../chunks/chunk-AFTBFF6J.js";
|
|
11
|
+
import "../../../chunks/chunk-PUZP2Q3F.js";
|
|
12
|
+
import "../../../chunks/chunk-7ABSJC2D.js";
|
|
13
13
|
import "../../../chunks/chunk-TG2EQLX2.js";
|
|
14
14
|
|
|
15
15
|
// builtin/extensions/plan-mode/index.ts
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
createCliHostCapabilities
|
|
4
|
-
} from "../../../chunks/chunk-
|
|
4
|
+
} from "../../../chunks/chunk-4WU5VAX4.js";
|
|
5
5
|
import {
|
|
6
6
|
createSharedFileSystemTools,
|
|
7
7
|
createSubagentCapability
|
|
8
|
-
} from "../../../chunks/chunk-
|
|
9
|
-
import "../../../chunks/chunk-
|
|
10
|
-
import "../../../chunks/chunk-
|
|
8
|
+
} from "../../../chunks/chunk-AFTBFF6J.js";
|
|
9
|
+
import "../../../chunks/chunk-PUZP2Q3F.js";
|
|
10
|
+
import "../../../chunks/chunk-7ABSJC2D.js";
|
|
11
11
|
import "../../../chunks/chunk-TG2EQLX2.js";
|
|
12
12
|
|
|
13
13
|
// builtin/extensions/subagent/index.ts
|
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
executeManageTodoList,
|
|
8
8
|
executionStateToTodos,
|
|
9
9
|
restoreExecutionState
|
|
10
|
-
} from "../../../chunks/chunk-
|
|
11
|
-
import "../../../chunks/chunk-
|
|
12
|
-
import "../../../chunks/chunk-
|
|
10
|
+
} from "../../../chunks/chunk-AFTBFF6J.js";
|
|
11
|
+
import "../../../chunks/chunk-PUZP2Q3F.js";
|
|
12
|
+
import "../../../chunks/chunk-7ABSJC2D.js";
|
|
13
13
|
import "../../../chunks/chunk-TG2EQLX2.js";
|
|
14
14
|
|
|
15
15
|
// builtin/extensions/todo/index.ts
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
createSharedWebSearchTool,
|
|
9
9
|
interpretShellExit,
|
|
10
10
|
requestInteraction
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-AFTBFF6J.js";
|
|
12
12
|
import {
|
|
13
13
|
Type
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-7ABSJC2D.js";
|
|
15
15
|
|
|
16
16
|
// src/config.ts
|
|
17
17
|
import { existsSync, mkdirSync, readFileSync, renameSync } from "fs";
|
|
@@ -5791,6 +5791,31 @@ function convertTools2(tools) {
|
|
|
5791
5791
|
};
|
|
5792
5792
|
});
|
|
5793
5793
|
}
|
|
5794
|
+
function applyCacheBreakpoints(params, retention) {
|
|
5795
|
+
if (retention === "none") return;
|
|
5796
|
+
const cacheControl = {
|
|
5797
|
+
type: "ephemeral",
|
|
5798
|
+
...retention === "long" ? { ttl: "1h" } : {}
|
|
5799
|
+
};
|
|
5800
|
+
if (Array.isArray(params.system) && params.system.length > 0) {
|
|
5801
|
+
const last = params.system[params.system.length - 1];
|
|
5802
|
+
last.cache_control = { ...cacheControl };
|
|
5803
|
+
}
|
|
5804
|
+
if (Array.isArray(params.tools) && params.tools.length > 0) {
|
|
5805
|
+
const last = params.tools[params.tools.length - 1];
|
|
5806
|
+
last.cache_control = { ...cacheControl };
|
|
5807
|
+
}
|
|
5808
|
+
for (let i = params.messages.length - 1; i >= 0; i--) {
|
|
5809
|
+
const msg = params.messages[i];
|
|
5810
|
+
if (msg.role !== "user") continue;
|
|
5811
|
+
if (typeof msg.content === "string") {
|
|
5812
|
+
msg.content = [{ type: "text", text: msg.content, cache_control: { ...cacheControl } }];
|
|
5813
|
+
} else if (Array.isArray(msg.content) && msg.content.length > 0) {
|
|
5814
|
+
msg.content[msg.content.length - 1].cache_control = { ...cacheControl };
|
|
5815
|
+
}
|
|
5816
|
+
break;
|
|
5817
|
+
}
|
|
5818
|
+
}
|
|
5794
5819
|
var streamAnthropic = (model, context, options) => {
|
|
5795
5820
|
const stream = new AssistantMessageEventStream();
|
|
5796
5821
|
(async () => {
|
|
@@ -5813,6 +5838,20 @@ var streamAnthropic = (model, context, options) => {
|
|
|
5813
5838
|
};
|
|
5814
5839
|
try {
|
|
5815
5840
|
const apiKey = options?.apiKey ?? getEnvApiKey(model.provider, model.apiKeyEnv) ?? "";
|
|
5841
|
+
const modelHeaders = model.headers || {};
|
|
5842
|
+
const otherModelHeaders = {};
|
|
5843
|
+
let modelBetaValue;
|
|
5844
|
+
for (const [key, value] of Object.entries(modelHeaders)) {
|
|
5845
|
+
if (key.toLowerCase() === "anthropic-beta") {
|
|
5846
|
+
modelBetaValue = value;
|
|
5847
|
+
} else {
|
|
5848
|
+
otherModelHeaders[key] = value;
|
|
5849
|
+
}
|
|
5850
|
+
}
|
|
5851
|
+
const betaFlags = [
|
|
5852
|
+
...options?.cacheRetention === "long" ? ["extended-cache-ttl-2025-04-11"] : [],
|
|
5853
|
+
...modelBetaValue?.split(",") ?? []
|
|
5854
|
+
].map((flag) => flag.trim()).filter(Boolean);
|
|
5816
5855
|
const client = new Anthropic({
|
|
5817
5856
|
apiKey,
|
|
5818
5857
|
baseURL: model.baseUrl,
|
|
@@ -5821,7 +5860,8 @@ var streamAnthropic = (model, context, options) => {
|
|
|
5821
5860
|
accept: "application/json",
|
|
5822
5861
|
"anthropic-dangerous-direct-browser-access": "true",
|
|
5823
5862
|
"anthropic-version": "2023-06-01",
|
|
5824
|
-
...
|
|
5863
|
+
...otherModelHeaders,
|
|
5864
|
+
...betaFlags.length > 0 ? { "anthropic-beta": [...new Set(betaFlags)].join(",") } : {}
|
|
5825
5865
|
}
|
|
5826
5866
|
});
|
|
5827
5867
|
const params = {
|
|
@@ -5834,12 +5874,6 @@ var streamAnthropic = (model, context, options) => {
|
|
|
5834
5874
|
if (context.systemPrompt) {
|
|
5835
5875
|
params.system = [{ type: "text", text: sanitizeSurrogates(context.systemPrompt) }];
|
|
5836
5876
|
}
|
|
5837
|
-
if (isPromptCacheCapability(cacheCapability) && options?.cacheRetention !== "none") {
|
|
5838
|
-
params.cache_control = {
|
|
5839
|
-
type: "ephemeral",
|
|
5840
|
-
...options?.cacheRetention === "long" ? { ttl: "1h" } : {}
|
|
5841
|
-
};
|
|
5842
|
-
}
|
|
5843
5877
|
if (options?.temperature !== void 0) {
|
|
5844
5878
|
params.temperature = options.temperature;
|
|
5845
5879
|
}
|
|
@@ -5859,6 +5893,9 @@ var streamAnthropic = (model, context, options) => {
|
|
|
5859
5893
|
params.tool_choice = options.toolChoice;
|
|
5860
5894
|
}
|
|
5861
5895
|
}
|
|
5896
|
+
if (isPromptCacheCapability(cacheCapability)) {
|
|
5897
|
+
applyCacheBreakpoints(params, options?.cacheRetention);
|
|
5898
|
+
}
|
|
5862
5899
|
options?.onPayload?.(params);
|
|
5863
5900
|
const anthropicStream = client.messages.stream({ ...params, stream: true }, { signal: options?.signal });
|
|
5864
5901
|
stream.push({ type: "start", partial: output });
|
|
@@ -9462,6 +9499,7 @@ export {
|
|
|
9462
9499
|
Type,
|
|
9463
9500
|
EventStream,
|
|
9464
9501
|
getModelCacheCapability,
|
|
9502
|
+
EMPTY_ASSISTANT_CONTENT_ERROR,
|
|
9465
9503
|
streamSimple,
|
|
9466
9504
|
completeSimple,
|
|
9467
9505
|
MODEL_CLASS_FALLBACK_ORDER,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
Agent
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-PUZP2Q3F.js";
|
|
5
5
|
import {
|
|
6
6
|
FileSystemGateway,
|
|
7
7
|
Type,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
getPlatformConfig,
|
|
12
12
|
hashText,
|
|
13
13
|
streamSimple
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-7ABSJC2D.js";
|
|
15
15
|
import {
|
|
16
16
|
__require
|
|
17
17
|
} from "./chunk-TG2EQLX2.js";
|
package/dist/cli.js
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
getSettingsPath,
|
|
16
16
|
getThemesDir,
|
|
17
17
|
migrateConfigFromAgentDir
|
|
18
|
-
} from "./chunks/chunk-
|
|
18
|
+
} from "./chunks/chunk-4WU5VAX4.js";
|
|
19
19
|
import {
|
|
20
20
|
AGENTS_CONTEXT_FILE_NAME,
|
|
21
21
|
AgentSessionController,
|
|
@@ -59,10 +59,11 @@ import {
|
|
|
59
59
|
selectToolsForRuntimePolicy,
|
|
60
60
|
shouldPreserveExecutionStateForUserText,
|
|
61
61
|
supersedeExecutionState
|
|
62
|
-
} from "./chunks/chunk-
|
|
63
|
-
import "./chunks/chunk-
|
|
62
|
+
} from "./chunks/chunk-AFTBFF6J.js";
|
|
63
|
+
import "./chunks/chunk-PUZP2Q3F.js";
|
|
64
64
|
import {
|
|
65
65
|
Deref,
|
|
66
|
+
EMPTY_ASSISTANT_CONTENT_ERROR,
|
|
66
67
|
Errors,
|
|
67
68
|
ExtendsUndefinedCheck,
|
|
68
69
|
HasTransform,
|
|
@@ -94,7 +95,7 @@ import {
|
|
|
94
95
|
setLogger,
|
|
95
96
|
sortToolModelCandidatesByCapability,
|
|
96
97
|
type_exports
|
|
97
|
-
} from "./chunks/chunk-
|
|
98
|
+
} from "./chunks/chunk-7ABSJC2D.js";
|
|
98
99
|
import {
|
|
99
100
|
resolveCliProjectRoot
|
|
100
101
|
} from "./chunks/chunk-NTYHFBUA.js";
|
|
@@ -1905,7 +1906,7 @@ var require_core = __commonJS({
|
|
|
1905
1906
|
return match && match.index === 0;
|
|
1906
1907
|
}
|
|
1907
1908
|
var BACKREF_RE = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
|
|
1908
|
-
function
|
|
1909
|
+
function join20(regexps, separator = "|") {
|
|
1909
1910
|
let numCaptures = 0;
|
|
1910
1911
|
return regexps.map((regex) => {
|
|
1911
1912
|
numCaptures += 1;
|
|
@@ -2209,7 +2210,7 @@ var require_core = __commonJS({
|
|
|
2209
2210
|
this.exec = () => null;
|
|
2210
2211
|
}
|
|
2211
2212
|
const terminators = this.regexes.map((el) => el[1]);
|
|
2212
|
-
this.matcherRe = langRe(
|
|
2213
|
+
this.matcherRe = langRe(join20(terminators), true);
|
|
2213
2214
|
this.lastIndex = 0;
|
|
2214
2215
|
}
|
|
2215
2216
|
/** @param {string} s */
|
|
@@ -43946,7 +43947,7 @@ var require_dist = __commonJS({
|
|
|
43946
43947
|
});
|
|
43947
43948
|
|
|
43948
43949
|
// src/cli.ts
|
|
43949
|
-
import * as
|
|
43950
|
+
import * as fs27 from "fs";
|
|
43950
43951
|
import * as path26 from "path";
|
|
43951
43952
|
|
|
43952
43953
|
// src/cli-args.ts
|
|
@@ -58602,20 +58603,32 @@ var SessionSelectorComponent = class extends Container {
|
|
|
58602
58603
|
selectList;
|
|
58603
58604
|
sessions;
|
|
58604
58605
|
callbacks;
|
|
58605
|
-
|
|
58606
|
+
options;
|
|
58607
|
+
items = [];
|
|
58608
|
+
baseDescriptions = /* @__PURE__ */ new Map();
|
|
58609
|
+
loadedPreviews = /* @__PURE__ */ new Map();
|
|
58610
|
+
inflightPreviews = /* @__PURE__ */ new Set();
|
|
58611
|
+
destroyed = false;
|
|
58612
|
+
constructor(sessions, callbacks, options = {}) {
|
|
58606
58613
|
super();
|
|
58607
58614
|
this.sessions = sessions;
|
|
58608
58615
|
this.callbacks = callbacks;
|
|
58616
|
+
this.options = options;
|
|
58609
58617
|
this.addChild(new Text(theme.bold(theme.fg("accent", "Resume Session")), 0, 0));
|
|
58610
58618
|
this.addChild(new Spacer(1));
|
|
58611
|
-
|
|
58612
|
-
|
|
58613
|
-
|
|
58614
|
-
|
|
58615
|
-
|
|
58619
|
+
this.items = sessions.map((session) => {
|
|
58620
|
+
const description = `${session.messageCount} messages \xB7 ${formatDate(session.updatedAt)}`;
|
|
58621
|
+
this.baseDescriptions.set(session.id, description);
|
|
58622
|
+
return {
|
|
58623
|
+
value: session.id,
|
|
58624
|
+
label: session.name || `Session ${session.id.slice(0, 8)}`,
|
|
58625
|
+
description
|
|
58626
|
+
};
|
|
58627
|
+
});
|
|
58628
|
+
const maxVisible = options.maxVisible ?? Math.min(this.items.length, 8);
|
|
58616
58629
|
this.selectList = new SelectList(
|
|
58617
|
-
items,
|
|
58618
|
-
|
|
58630
|
+
this.items,
|
|
58631
|
+
maxVisible,
|
|
58619
58632
|
{
|
|
58620
58633
|
selectedPrefix: (text) => theme.fg("accent", text),
|
|
58621
58634
|
selectedText: (text) => theme.fg("accent", text),
|
|
@@ -58625,16 +58638,59 @@ var SessionSelectorComponent = class extends Container {
|
|
|
58625
58638
|
}
|
|
58626
58639
|
);
|
|
58627
58640
|
this.selectList.onSelect = (item) => {
|
|
58641
|
+
this.destroyed = true;
|
|
58628
58642
|
this.callbacks.onSelect(item.value);
|
|
58629
58643
|
};
|
|
58630
58644
|
this.selectList.onCancel = () => {
|
|
58645
|
+
this.destroyed = true;
|
|
58631
58646
|
this.callbacks.onCancel();
|
|
58632
58647
|
};
|
|
58648
|
+
this.selectList.onSelectionChange = (item) => {
|
|
58649
|
+
this.prefetchAroundValue(item.value);
|
|
58650
|
+
};
|
|
58633
58651
|
this.addChild(this.selectList);
|
|
58634
58652
|
this.addChild(new Spacer(1));
|
|
58635
58653
|
this.addChild(
|
|
58636
58654
|
new Text(theme.fg("dim", " \u2191\u2193 to navigate \xB7 \u2190\u2192 to page \xB7 Enter to select \xB7 Esc to cancel"), 0, 0)
|
|
58637
58655
|
);
|
|
58656
|
+
this.prefetchWindow(0);
|
|
58657
|
+
}
|
|
58658
|
+
/** Prefetch previews for the window surrounding the given item value. */
|
|
58659
|
+
prefetchAroundValue(value) {
|
|
58660
|
+
const index = this.items.findIndex((item) => item.value === value);
|
|
58661
|
+
if (index >= 0) {
|
|
58662
|
+
this.prefetchWindow(index);
|
|
58663
|
+
}
|
|
58664
|
+
}
|
|
58665
|
+
prefetchWindow(centerIndex) {
|
|
58666
|
+
if (!this.options.loadPreview) return;
|
|
58667
|
+
const maxVisible = this.options.maxVisible ?? Math.min(this.items.length, 8);
|
|
58668
|
+
const start = Math.max(0, centerIndex - 2);
|
|
58669
|
+
const end = Math.min(this.items.length, centerIndex + maxVisible);
|
|
58670
|
+
for (let i = start; i < end; i++) {
|
|
58671
|
+
this.prefetchOne(this.items[i]);
|
|
58672
|
+
}
|
|
58673
|
+
}
|
|
58674
|
+
prefetchOne(item) {
|
|
58675
|
+
const loader = this.options.loadPreview;
|
|
58676
|
+
if (!item || !loader) return;
|
|
58677
|
+
const id = item.value;
|
|
58678
|
+
if (this.loadedPreviews.has(id) || this.inflightPreviews.has(id)) return;
|
|
58679
|
+
this.inflightPreviews.add(id);
|
|
58680
|
+
void loader(id).then((preview) => {
|
|
58681
|
+
this.loadedPreviews.set(id, preview);
|
|
58682
|
+
if (preview) {
|
|
58683
|
+
const base = this.baseDescriptions.get(id) ?? "";
|
|
58684
|
+
item.description = `\u276F ${preview} \xB7 ${base}`;
|
|
58685
|
+
if (!this.destroyed) {
|
|
58686
|
+
this.options.requestRender?.();
|
|
58687
|
+
}
|
|
58688
|
+
}
|
|
58689
|
+
}).catch(() => {
|
|
58690
|
+
this.loadedPreviews.set(id, null);
|
|
58691
|
+
}).finally(() => {
|
|
58692
|
+
this.inflightPreviews.delete(id);
|
|
58693
|
+
});
|
|
58638
58694
|
}
|
|
58639
58695
|
handleInput(data) {
|
|
58640
58696
|
this.selectList.handleInput(data);
|
|
@@ -58644,6 +58700,123 @@ var SessionSelectorComponent = class extends Container {
|
|
|
58644
58700
|
}
|
|
58645
58701
|
};
|
|
58646
58702
|
|
|
58703
|
+
// src/session-preview.ts
|
|
58704
|
+
import { promises as fs21 } from "node:fs";
|
|
58705
|
+
import { join as join15 } from "node:path";
|
|
58706
|
+
var PREFIX_BYTES = 64 * 1024;
|
|
58707
|
+
var MAX_ENTRIES_SCANNED = 20;
|
|
58708
|
+
var MAX_PREVIEW_LENGTH = 120;
|
|
58709
|
+
var previewCache = /* @__PURE__ */ new Map();
|
|
58710
|
+
function getSessionFilePath(sessionId, sessionsDir) {
|
|
58711
|
+
const safeId = sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
58712
|
+
return join15(sessionsDir ?? getSessionsDir(), `${safeId}.json`);
|
|
58713
|
+
}
|
|
58714
|
+
function extractTextFromContent(content) {
|
|
58715
|
+
if (typeof content === "string") return content;
|
|
58716
|
+
if (Array.isArray(content)) {
|
|
58717
|
+
const parts = [];
|
|
58718
|
+
for (const block of content) {
|
|
58719
|
+
if (block && typeof block === "object" && block.type === "text") {
|
|
58720
|
+
parts.push(block.text || "");
|
|
58721
|
+
}
|
|
58722
|
+
}
|
|
58723
|
+
return parts.join(" ");
|
|
58724
|
+
}
|
|
58725
|
+
return "";
|
|
58726
|
+
}
|
|
58727
|
+
function* scanJsonObjects(text, startIndex) {
|
|
58728
|
+
let depth = 0;
|
|
58729
|
+
let inString = false;
|
|
58730
|
+
let escaped = false;
|
|
58731
|
+
let objectStart = -1;
|
|
58732
|
+
for (let i = startIndex; i < text.length; i++) {
|
|
58733
|
+
const ch = text[i];
|
|
58734
|
+
if (inString) {
|
|
58735
|
+
if (escaped) {
|
|
58736
|
+
escaped = false;
|
|
58737
|
+
} else if (ch === "\\") {
|
|
58738
|
+
escaped = true;
|
|
58739
|
+
} else if (ch === '"') {
|
|
58740
|
+
inString = false;
|
|
58741
|
+
}
|
|
58742
|
+
continue;
|
|
58743
|
+
}
|
|
58744
|
+
if (ch === '"') {
|
|
58745
|
+
inString = true;
|
|
58746
|
+
continue;
|
|
58747
|
+
}
|
|
58748
|
+
if (ch === "{") {
|
|
58749
|
+
if (depth === 0) objectStart = i;
|
|
58750
|
+
depth++;
|
|
58751
|
+
} else if (ch === "}") {
|
|
58752
|
+
depth--;
|
|
58753
|
+
if (depth === 0 && objectStart >= 0) {
|
|
58754
|
+
yield text.slice(objectStart, i + 1);
|
|
58755
|
+
objectStart = -1;
|
|
58756
|
+
}
|
|
58757
|
+
if (depth < 0) return;
|
|
58758
|
+
} else if (ch === "]" && depth === 0) {
|
|
58759
|
+
return;
|
|
58760
|
+
}
|
|
58761
|
+
}
|
|
58762
|
+
}
|
|
58763
|
+
function normalizePreview(text) {
|
|
58764
|
+
const normalized = text.replace(/\s+/g, " ").trim();
|
|
58765
|
+
if (!normalized) return null;
|
|
58766
|
+
return normalized.length > MAX_PREVIEW_LENGTH ? `${normalized.slice(0, MAX_PREVIEW_LENGTH)}...` : normalized;
|
|
58767
|
+
}
|
|
58768
|
+
async function readSessionPromptPreview(sessionId, sessionsDir) {
|
|
58769
|
+
const filePath = getSessionFilePath(sessionId, sessionsDir);
|
|
58770
|
+
let handle;
|
|
58771
|
+
try {
|
|
58772
|
+
handle = await fs21.open(filePath, "r");
|
|
58773
|
+
const buffer = Buffer.alloc(PREFIX_BYTES);
|
|
58774
|
+
const { bytesRead } = await handle.read(buffer, 0, PREFIX_BYTES, 0);
|
|
58775
|
+
const text = buffer.toString("utf-8", 0, bytesRead);
|
|
58776
|
+
const entriesIndex = text.indexOf('"entries"');
|
|
58777
|
+
if (entriesIndex < 0) return null;
|
|
58778
|
+
const arrayStart = text.indexOf("[", entriesIndex);
|
|
58779
|
+
if (arrayStart < 0) return null;
|
|
58780
|
+
let scanned = 0;
|
|
58781
|
+
for (const objectText of scanJsonObjects(text, arrayStart + 1)) {
|
|
58782
|
+
if (++scanned > MAX_ENTRIES_SCANNED) break;
|
|
58783
|
+
let entry;
|
|
58784
|
+
try {
|
|
58785
|
+
entry = JSON.parse(objectText);
|
|
58786
|
+
} catch {
|
|
58787
|
+
break;
|
|
58788
|
+
}
|
|
58789
|
+
if (entry?.type === "message" && entry.message?.role === "user") {
|
|
58790
|
+
return normalizePreview(extractTextFromContent(entry.message.content));
|
|
58791
|
+
}
|
|
58792
|
+
}
|
|
58793
|
+
return null;
|
|
58794
|
+
} catch {
|
|
58795
|
+
return null;
|
|
58796
|
+
} finally {
|
|
58797
|
+
if (handle) {
|
|
58798
|
+
await handle.close().catch(() => {
|
|
58799
|
+
});
|
|
58800
|
+
}
|
|
58801
|
+
}
|
|
58802
|
+
}
|
|
58803
|
+
async function getSessionPromptPreview(sessionId, sessionsDir) {
|
|
58804
|
+
const filePath = getSessionFilePath(sessionId, sessionsDir);
|
|
58805
|
+
let mtimeMs;
|
|
58806
|
+
try {
|
|
58807
|
+
mtimeMs = (await fs21.stat(filePath)).mtimeMs;
|
|
58808
|
+
} catch {
|
|
58809
|
+
return null;
|
|
58810
|
+
}
|
|
58811
|
+
const cached = previewCache.get(filePath);
|
|
58812
|
+
if (cached && cached.mtimeMs === mtimeMs) {
|
|
58813
|
+
return cached.preview;
|
|
58814
|
+
}
|
|
58815
|
+
const preview = await readSessionPromptPreview(sessionId, sessionsDir);
|
|
58816
|
+
previewCache.set(filePath, { mtimeMs, preview });
|
|
58817
|
+
return preview;
|
|
58818
|
+
}
|
|
58819
|
+
|
|
58647
58820
|
// src/components/tree-selector.ts
|
|
58648
58821
|
var RESET = "\x1B[0m";
|
|
58649
58822
|
var INVERSE = "\x1B[7m";
|
|
@@ -58672,7 +58845,7 @@ function extractContent(entry) {
|
|
|
58672
58845
|
}
|
|
58673
58846
|
if (!entry.message) return "";
|
|
58674
58847
|
const msg = entry.message;
|
|
58675
|
-
const
|
|
58848
|
+
const extractTextFromContent2 = (content) => {
|
|
58676
58849
|
if (typeof content === "string") return content;
|
|
58677
58850
|
if (Array.isArray(content)) {
|
|
58678
58851
|
const parts = [];
|
|
@@ -58694,10 +58867,10 @@ function extractContent(entry) {
|
|
|
58694
58867
|
return "";
|
|
58695
58868
|
};
|
|
58696
58869
|
if (msg.role === "user") {
|
|
58697
|
-
return
|
|
58870
|
+
return extractTextFromContent2(msg.content) || "(empty)";
|
|
58698
58871
|
}
|
|
58699
58872
|
if (msg.role === "assistant") {
|
|
58700
|
-
const textContent =
|
|
58873
|
+
const textContent = extractTextFromContent2(msg.content);
|
|
58701
58874
|
if (textContent) {
|
|
58702
58875
|
return textContent;
|
|
58703
58876
|
}
|
|
@@ -60195,15 +60368,22 @@ async function handleResumeCommand(host) {
|
|
|
60195
60368
|
return;
|
|
60196
60369
|
}
|
|
60197
60370
|
host.showSelector((done) => {
|
|
60198
|
-
const selector = new SessionSelectorComponent(
|
|
60199
|
-
|
|
60200
|
-
|
|
60201
|
-
|
|
60371
|
+
const selector = new SessionSelectorComponent(
|
|
60372
|
+
sessions,
|
|
60373
|
+
{
|
|
60374
|
+
onSelect: async (sessionId) => {
|
|
60375
|
+
await host.loadSession(sessionId);
|
|
60376
|
+
done();
|
|
60377
|
+
},
|
|
60378
|
+
onCancel: () => {
|
|
60379
|
+
done();
|
|
60380
|
+
}
|
|
60202
60381
|
},
|
|
60203
|
-
|
|
60204
|
-
|
|
60382
|
+
{
|
|
60383
|
+
loadPreview: (sessionId) => getSessionPromptPreview(sessionId),
|
|
60384
|
+
requestRender: () => host.ui.requestRender()
|
|
60205
60385
|
}
|
|
60206
|
-
|
|
60386
|
+
);
|
|
60207
60387
|
return { component: selector, focus: selector.getSelectList() };
|
|
60208
60388
|
});
|
|
60209
60389
|
}
|
|
@@ -60214,6 +60394,8 @@ async function loadSession(host, sessionId) {
|
|
|
60214
60394
|
host.showError(`Session not found: ${sessionId}`);
|
|
60215
60395
|
return;
|
|
60216
60396
|
}
|
|
60397
|
+
setControllerBusy(host, false);
|
|
60398
|
+
setWaitingForUser(host, false);
|
|
60217
60399
|
const activeSession = host.sessionManager.getActiveSession();
|
|
60218
60400
|
if (activeSession) {
|
|
60219
60401
|
host.agent.sessionId = activeSession.id;
|
|
@@ -60359,7 +60541,16 @@ async function loadSession(host, sessionId) {
|
|
|
60359
60541
|
}
|
|
60360
60542
|
var TITLE_SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
60361
60543
|
var TITLE_SPINNER_INTERVAL_MS = 80;
|
|
60544
|
+
var TITLE_WAITING_PREFIX = "\u23F8";
|
|
60362
60545
|
var titleSpinnerTimers = /* @__PURE__ */ new WeakMap();
|
|
60546
|
+
var controllerBusyHosts = /* @__PURE__ */ new WeakSet();
|
|
60547
|
+
var waitingForUserHosts = /* @__PURE__ */ new WeakSet();
|
|
60548
|
+
function isHostBusy(host) {
|
|
60549
|
+
return host.submitLock || controllerBusyHosts.has(host);
|
|
60550
|
+
}
|
|
60551
|
+
function isWaitingForUser(host) {
|
|
60552
|
+
return waitingForUserHosts.has(host);
|
|
60553
|
+
}
|
|
60363
60554
|
function updateTerminalTitle(host, spinnerFrame) {
|
|
60364
60555
|
const activeSession = host.sessionManager.getActiveSession();
|
|
60365
60556
|
if (!activeSession) {
|
|
@@ -60370,8 +60561,10 @@ function updateTerminalTitle(host, spinnerFrame) {
|
|
|
60370
60561
|
activeSession,
|
|
60371
60562
|
messages: host.sessionManager.getMessages()
|
|
60372
60563
|
});
|
|
60373
|
-
const
|
|
60374
|
-
const
|
|
60564
|
+
const waiting = isWaitingForUser(host);
|
|
60565
|
+
const busy = isHostBusy(host);
|
|
60566
|
+
const activityState = waiting ? "waiting" : busy ? "busy" : "ready";
|
|
60567
|
+
const prefix = spinnerFrame ? `${spinnerFrame} ` : waiting ? `${TITLE_WAITING_PREFIX} ` : "";
|
|
60375
60568
|
host.ui.terminal.setTitle(`${prefix}Pie \xB7 ${sessionLabel} [ms:session=${activeSession.id};state=${activityState}]`);
|
|
60376
60569
|
}
|
|
60377
60570
|
function stopTitleSpinner(host) {
|
|
@@ -60395,17 +60588,52 @@ function startTitleSpinner(host) {
|
|
|
60395
60588
|
titleSpinnerTimers.set(host, timer);
|
|
60396
60589
|
updateTerminalTitle(host, TITLE_SPINNER_FRAMES[0]);
|
|
60397
60590
|
}
|
|
60591
|
+
function syncTitleActivity(host) {
|
|
60592
|
+
if (isWaitingForUser(host)) {
|
|
60593
|
+
stopTitleSpinner(host);
|
|
60594
|
+
host.updateTerminalTitle();
|
|
60595
|
+
return;
|
|
60596
|
+
}
|
|
60597
|
+
if (isHostBusy(host)) {
|
|
60598
|
+
if (titleSpinnerTimers.has(host)) {
|
|
60599
|
+
return;
|
|
60600
|
+
}
|
|
60601
|
+
startTitleSpinner(host);
|
|
60602
|
+
return;
|
|
60603
|
+
}
|
|
60604
|
+
stopTitleSpinner(host);
|
|
60605
|
+
host.updateTerminalTitle();
|
|
60606
|
+
}
|
|
60398
60607
|
function setSubmitLock(host, locked) {
|
|
60399
60608
|
if (host.submitLock === locked) {
|
|
60400
60609
|
return;
|
|
60401
60610
|
}
|
|
60402
60611
|
host.submitLock = locked;
|
|
60403
|
-
|
|
60404
|
-
|
|
60405
|
-
|
|
60612
|
+
syncTitleActivity(host);
|
|
60613
|
+
}
|
|
60614
|
+
function setControllerBusy(host, busy) {
|
|
60615
|
+
const wasBusy = controllerBusyHosts.has(host);
|
|
60616
|
+
if (wasBusy === busy) {
|
|
60617
|
+
return;
|
|
60618
|
+
}
|
|
60619
|
+
if (busy) {
|
|
60620
|
+
controllerBusyHosts.add(host);
|
|
60406
60621
|
} else {
|
|
60407
|
-
|
|
60622
|
+
controllerBusyHosts.delete(host);
|
|
60623
|
+
}
|
|
60624
|
+
syncTitleActivity(host);
|
|
60625
|
+
}
|
|
60626
|
+
function setWaitingForUser(host, waiting) {
|
|
60627
|
+
const wasWaiting = waitingForUserHosts.has(host);
|
|
60628
|
+
if (wasWaiting === waiting) {
|
|
60629
|
+
return;
|
|
60630
|
+
}
|
|
60631
|
+
if (waiting) {
|
|
60632
|
+
waitingForUserHosts.add(host);
|
|
60633
|
+
} else {
|
|
60634
|
+
waitingForUserHosts.delete(host);
|
|
60408
60635
|
}
|
|
60636
|
+
syncTitleActivity(host);
|
|
60409
60637
|
}
|
|
60410
60638
|
async function handleTreeCommand(host) {
|
|
60411
60639
|
const entries = host.sessionManager.getEntries();
|
|
@@ -60542,7 +60770,7 @@ async function handleForkCommand(host) {
|
|
|
60542
60770
|
}
|
|
60543
60771
|
|
|
60544
60772
|
// src/commands/interactive-skill-commands.ts
|
|
60545
|
-
import * as
|
|
60773
|
+
import * as fs22 from "fs";
|
|
60546
60774
|
import * as os4 from "os";
|
|
60547
60775
|
import * as path20 from "path";
|
|
60548
60776
|
|
|
@@ -60886,7 +61114,7 @@ function expandSkillCommand(host, text) {
|
|
|
60886
61114
|
const skill = host.skills.find((s) => s.name === skillName);
|
|
60887
61115
|
if (!skill) return text;
|
|
60888
61116
|
try {
|
|
60889
|
-
const content =
|
|
61117
|
+
const content = fs22.readFileSync(skill.filePath, "utf-8");
|
|
60890
61118
|
const body = host.stripFrontmatter(content).trim();
|
|
60891
61119
|
const skillBlock = `<skill name="${skill.name}" location="${skill.filePath}">
|
|
60892
61120
|
References are relative to ${skill.baseDir}.
|
|
@@ -60956,13 +61184,13 @@ async function handleSkillsCreate(host, args) {
|
|
|
60956
61184
|
const skillDir = path20.join(skillsDir, name);
|
|
60957
61185
|
const skillFile = path20.join(skillDir, "SKILL.md");
|
|
60958
61186
|
console.error(`[SkillsCreate] Creating at: ${skillFile}`);
|
|
60959
|
-
if (
|
|
61187
|
+
if (fs22.existsSync(skillDir)) {
|
|
60960
61188
|
host.showError(`Skill "${name}" already exists at ${skillDir}`);
|
|
60961
61189
|
return;
|
|
60962
61190
|
}
|
|
60963
|
-
|
|
61191
|
+
fs22.mkdirSync(skillDir, { recursive: true });
|
|
60964
61192
|
const template = createSkillTemplate(name, description);
|
|
60965
|
-
|
|
61193
|
+
fs22.writeFileSync(skillFile, template, "utf-8");
|
|
60966
61194
|
console.error(`[SkillsCreate] Successfully created skill`);
|
|
60967
61195
|
host.chatContainer.addChild(new Spacer(1));
|
|
60968
61196
|
host.chatContainer.addChild(new Text(theme.fg("accent", `\u2713 Created skill: ${name}`), 1, 0));
|
|
@@ -61387,6 +61615,8 @@ function showThinkingLevelSelector(host) {
|
|
|
61387
61615
|
});
|
|
61388
61616
|
}
|
|
61389
61617
|
async function handleClearCommand(host) {
|
|
61618
|
+
host.setControllerBusy(false);
|
|
61619
|
+
host.setWaitingForUser(false);
|
|
61390
61620
|
host.executionState.clear();
|
|
61391
61621
|
host.executionReminder = null;
|
|
61392
61622
|
host.agent.reset();
|
|
@@ -62433,7 +62663,7 @@ function setupInteractiveEditorSubmitHandler(host) {
|
|
|
62433
62663
|
}
|
|
62434
62664
|
|
|
62435
62665
|
// src/input/interactive-file-pipeline.ts
|
|
62436
|
-
import * as
|
|
62666
|
+
import * as fs25 from "fs";
|
|
62437
62667
|
import * as path23 from "path";
|
|
62438
62668
|
|
|
62439
62669
|
// src/components/file-picker.ts
|
|
@@ -62655,7 +62885,7 @@ var FilePickerComponent = class extends Container {
|
|
|
62655
62885
|
};
|
|
62656
62886
|
|
|
62657
62887
|
// src/files/commands/file-commands.ts
|
|
62658
|
-
import * as
|
|
62888
|
+
import * as fs23 from "node:fs";
|
|
62659
62889
|
import * as path21 from "node:path";
|
|
62660
62890
|
var FileCommands = class {
|
|
62661
62891
|
context;
|
|
@@ -62672,7 +62902,7 @@ var FileCommands = class {
|
|
|
62672
62902
|
return;
|
|
62673
62903
|
}
|
|
62674
62904
|
const filePath = resolvePath(parsed.path);
|
|
62675
|
-
if (!
|
|
62905
|
+
if (!fs23.existsSync(filePath)) {
|
|
62676
62906
|
this.context.showError(`File not found: ${parsed.path}`);
|
|
62677
62907
|
return;
|
|
62678
62908
|
}
|
|
@@ -62711,7 +62941,7 @@ var FileCommands = class {
|
|
|
62711
62941
|
return;
|
|
62712
62942
|
}
|
|
62713
62943
|
const resolvedPath = resolvePath(filePath);
|
|
62714
|
-
if (!
|
|
62944
|
+
if (!fs23.existsSync(resolvedPath)) {
|
|
62715
62945
|
this.context.showError(`File not found: ${filePath}`);
|
|
62716
62946
|
return;
|
|
62717
62947
|
}
|
|
@@ -62742,7 +62972,7 @@ var FileCommands = class {
|
|
|
62742
62972
|
return;
|
|
62743
62973
|
}
|
|
62744
62974
|
const resolvedPath = resolvePath(parsed.path);
|
|
62745
|
-
if (!
|
|
62975
|
+
if (!fs23.existsSync(resolvedPath)) {
|
|
62746
62976
|
this.context.showError(`File not found: ${parsed.path}`);
|
|
62747
62977
|
return;
|
|
62748
62978
|
}
|
|
@@ -63220,7 +63450,7 @@ var FileStatusMonitor = class {
|
|
|
63220
63450
|
};
|
|
63221
63451
|
|
|
63222
63452
|
// src/files/mention/mention-handler.ts
|
|
63223
|
-
import * as
|
|
63453
|
+
import * as fs24 from "node:fs";
|
|
63224
63454
|
import * as path22 from "node:path";
|
|
63225
63455
|
var MentionHandler = class {
|
|
63226
63456
|
fileManager;
|
|
@@ -63590,8 +63820,8 @@ var MentionHandler = class {
|
|
|
63590
63820
|
}
|
|
63591
63821
|
if (this.isPath(query)) {
|
|
63592
63822
|
const resolvedPath = resolvePath(query);
|
|
63593
|
-
if (
|
|
63594
|
-
const stats =
|
|
63823
|
+
if (fs24.existsSync(resolvedPath)) {
|
|
63824
|
+
const stats = fs24.statSync(resolvedPath);
|
|
63595
63825
|
if (stats.isFile()) {
|
|
63596
63826
|
const type = FileCache.getFileTypeFromName(resolvedPath);
|
|
63597
63827
|
const name = path22.basename(resolvedPath);
|
|
@@ -63615,7 +63845,7 @@ var MentionHandler = class {
|
|
|
63615
63845
|
return void 0;
|
|
63616
63846
|
}
|
|
63617
63847
|
const queryPath = this.isPath(query) ? resolvePath(query) : void 0;
|
|
63618
|
-
const filter = queryPath ?
|
|
63848
|
+
const filter = queryPath ? fs24.existsSync(queryPath) && fs24.statSync(queryPath).isDirectory() ? "" : path22.basename(queryPath) : query;
|
|
63619
63849
|
const entries = this.fileManager.listPathEntries(currentDir, filter);
|
|
63620
63850
|
const options = [];
|
|
63621
63851
|
const homeDir = process.env.HOME || "";
|
|
@@ -63656,7 +63886,7 @@ var MentionHandler = class {
|
|
|
63656
63886
|
getBrowserDirectory(query = this.currentQuery) {
|
|
63657
63887
|
if (this.isPath(query)) {
|
|
63658
63888
|
const resolvedPath = resolvePath(query);
|
|
63659
|
-
if (
|
|
63889
|
+
if (fs24.existsSync(resolvedPath) && fs24.statSync(resolvedPath).isDirectory()) {
|
|
63660
63890
|
return resolvedPath;
|
|
63661
63891
|
}
|
|
63662
63892
|
return path22.dirname(resolvedPath);
|
|
@@ -64020,13 +64250,13 @@ function convertPreparedAttachmentItems(items) {
|
|
|
64020
64250
|
break;
|
|
64021
64251
|
case "image": {
|
|
64022
64252
|
if (!item.data && !item.path) return void 0;
|
|
64023
|
-
const data = item.data ??
|
|
64253
|
+
const data = item.data ?? fs25.readFileSync(item.path, "base64");
|
|
64024
64254
|
converted.push({ type: "image", data, mimeType: item.mimeType });
|
|
64025
64255
|
break;
|
|
64026
64256
|
}
|
|
64027
64257
|
case "video": {
|
|
64028
64258
|
if (!item.data && !item.path) return void 0;
|
|
64029
|
-
const data = item.data ??
|
|
64259
|
+
const data = item.data ?? fs25.readFileSync(item.path, "base64");
|
|
64030
64260
|
converted.push({ type: "video", data, mimeType: item.mimeType });
|
|
64031
64261
|
break;
|
|
64032
64262
|
}
|
|
@@ -64663,6 +64893,12 @@ function classifyCliFailure(context) {
|
|
|
64663
64893
|
terminal: false
|
|
64664
64894
|
});
|
|
64665
64895
|
}
|
|
64896
|
+
if (errorMessage3.includes(EMPTY_ASSISTANT_CONTENT_ERROR)) {
|
|
64897
|
+
return createClassification("provider_transient", errorMessage3, {
|
|
64898
|
+
retryable: true,
|
|
64899
|
+
terminal: false
|
|
64900
|
+
});
|
|
64901
|
+
}
|
|
64666
64902
|
if (PROVIDER_TRANSIENT_ERROR_PATTERN.test(errorMessage3)) {
|
|
64667
64903
|
return createClassification("provider_transient", errorMessage3, {
|
|
64668
64904
|
retryable: true,
|
|
@@ -65352,6 +65588,7 @@ function createInteractiveAgentSessionController(host) {
|
|
|
65352
65588
|
host.updatePendingMessagesDisplay();
|
|
65353
65589
|
host.safeRequestRender();
|
|
65354
65590
|
} else if (event.type === "queued_turn_dispatched") {
|
|
65591
|
+
host.setControllerBusy(true);
|
|
65355
65592
|
if (event.queuedInput.visibility === "user") {
|
|
65356
65593
|
host.chatContainer.addChild(new UserMessageComponent(event.queuedInput.displayText));
|
|
65357
65594
|
host.sessionTrace.noteDispatchStart({
|
|
@@ -65443,6 +65680,7 @@ function createInteractiveAgentSessionController(host) {
|
|
|
65443
65680
|
host.showStatus("Todo list preserved. Send 'continue' when you want to resume it.");
|
|
65444
65681
|
}
|
|
65445
65682
|
host.showError(event.failure.message);
|
|
65683
|
+
host.setControllerBusy(false);
|
|
65446
65684
|
} else if (event.type === "turn_cancelled") {
|
|
65447
65685
|
const outcome = host.executionState.abort();
|
|
65448
65686
|
host.logDebug("execution:turn_cancelled", {
|
|
@@ -65458,6 +65696,7 @@ function createInteractiveAgentSessionController(host) {
|
|
|
65458
65696
|
if (outcome.terminalSummary) {
|
|
65459
65697
|
host.appendWarningSummary(outcome.terminalSummary);
|
|
65460
65698
|
}
|
|
65699
|
+
host.setControllerBusy(false);
|
|
65461
65700
|
} else if (event.type === "runtime_guard_triggered") {
|
|
65462
65701
|
host.sessionTrace.noteStalled("runtime_guard_triggered", {
|
|
65463
65702
|
toolName: event.toolName,
|
|
@@ -65479,6 +65718,7 @@ function createInteractiveAgentSessionController(host) {
|
|
|
65479
65718
|
const prefix = event.reason === "overflow" ? "Context overflow recovery failed" : "Auto-compaction failed";
|
|
65480
65719
|
host.showError(`${prefix}: ${event.errorMessage}`);
|
|
65481
65720
|
host.footer.setState({ status: "ready" });
|
|
65721
|
+
host.setControllerBusy(false);
|
|
65482
65722
|
return;
|
|
65483
65723
|
}
|
|
65484
65724
|
host.resetFileObservationState();
|
|
@@ -65500,8 +65740,15 @@ function createInteractiveAgentSessionController(host) {
|
|
|
65500
65740
|
if (!event.willRetry && !event.result?.aborted) {
|
|
65501
65741
|
host.showStatus("Context auto-compacted");
|
|
65502
65742
|
}
|
|
65503
|
-
} else if (event.type === "auto_continue_scheduled"
|
|
65504
|
-
host.
|
|
65743
|
+
} else if (event.type === "auto_continue_scheduled") {
|
|
65744
|
+
host.setControllerBusy(true);
|
|
65745
|
+
if (event.reason === "todo_closure") {
|
|
65746
|
+
host.showStatus("Continuing active todo list");
|
|
65747
|
+
}
|
|
65748
|
+
} else if (event.type === "auto_continue_skipped") {
|
|
65749
|
+
if (event.reason !== "queued_messages" && event.reason !== "runtime_busy" && !host.isWaitingForUserInteraction()) {
|
|
65750
|
+
host.setControllerBusy(false);
|
|
65751
|
+
}
|
|
65505
65752
|
}
|
|
65506
65753
|
}
|
|
65507
65754
|
});
|
|
@@ -65782,11 +66029,15 @@ function installInteractiveInteractionHandler(host) {
|
|
|
65782
66029
|
registerInteractionHandler(async (request) => {
|
|
65783
66030
|
const beginWaitingForUser = () => {
|
|
65784
66031
|
host.activeInteractionCount++;
|
|
66032
|
+
host.setWaitingForUser(true);
|
|
65785
66033
|
host.footer.setState({ lifecycleEvent: "waiting_for_user_input" });
|
|
65786
66034
|
host.safeRequestRender();
|
|
65787
66035
|
};
|
|
65788
66036
|
const endWaitingForUser = () => {
|
|
65789
66037
|
host.activeInteractionCount = Math.max(0, host.activeInteractionCount - 1);
|
|
66038
|
+
if (host.activeInteractionCount === 0) {
|
|
66039
|
+
host.setWaitingForUser(false);
|
|
66040
|
+
}
|
|
65790
66041
|
host.footer.setState({ lifecycleEvent: "tool_execution_start" });
|
|
65791
66042
|
host.safeRequestRender();
|
|
65792
66043
|
};
|
|
@@ -66091,7 +66342,7 @@ var AttachmentResolver = class {
|
|
|
66091
66342
|
};
|
|
66092
66343
|
|
|
66093
66344
|
// src/extensions/loader.ts
|
|
66094
|
-
import * as
|
|
66345
|
+
import * as fs26 from "node:fs";
|
|
66095
66346
|
import * as os5 from "os";
|
|
66096
66347
|
import * as path24 from "path";
|
|
66097
66348
|
import { pathToFileURL } from "node:url";
|
|
@@ -66275,7 +66526,7 @@ function normalizeExtensionImportPath(extensionPath) {
|
|
|
66275
66526
|
}
|
|
66276
66527
|
async function loadExtension(extensionPath, cwd, uiContext, abortFn, isIdleFn, hasUI, actions) {
|
|
66277
66528
|
const resolvedPath = resolvePath2(extensionPath, cwd);
|
|
66278
|
-
if (!
|
|
66529
|
+
if (!fs26.existsSync(resolvedPath)) {
|
|
66279
66530
|
return { extension: null, error: `Extension not found: ${extensionPath}` };
|
|
66280
66531
|
}
|
|
66281
66532
|
try {
|
|
@@ -66296,12 +66547,12 @@ async function loadExtension(extensionPath, cwd, uiContext, abortFn, isIdleFn, h
|
|
|
66296
66547
|
}
|
|
66297
66548
|
}
|
|
66298
66549
|
function discoverExtensionsInDir(dir) {
|
|
66299
|
-
if (!
|
|
66550
|
+
if (!fs26.existsSync(dir)) {
|
|
66300
66551
|
return [];
|
|
66301
66552
|
}
|
|
66302
66553
|
const discovered = [];
|
|
66303
66554
|
try {
|
|
66304
|
-
const entries =
|
|
66555
|
+
const entries = fs26.readdirSync(dir, { withFileTypes: true });
|
|
66305
66556
|
for (const entry of entries) {
|
|
66306
66557
|
const entryPath = path24.join(dir, entry.name);
|
|
66307
66558
|
if (entry.isFile() && (entry.name.endsWith(".cjs") || entry.name.endsWith(".js") || entry.name.endsWith(".ts"))) {
|
|
@@ -66310,13 +66561,13 @@ function discoverExtensionsInDir(dir) {
|
|
|
66310
66561
|
}
|
|
66311
66562
|
if (entry.isDirectory()) {
|
|
66312
66563
|
const packageJsonPath = path24.join(entryPath, "package.json");
|
|
66313
|
-
if (
|
|
66564
|
+
if (fs26.existsSync(packageJsonPath)) {
|
|
66314
66565
|
try {
|
|
66315
|
-
const pkg = JSON.parse(
|
|
66566
|
+
const pkg = JSON.parse(fs26.readFileSync(packageJsonPath, "utf-8"));
|
|
66316
66567
|
const manifest = pkg.pie;
|
|
66317
66568
|
if (manifest?.main) {
|
|
66318
66569
|
const mainPath = path24.resolve(entryPath, manifest.main);
|
|
66319
|
-
if (
|
|
66570
|
+
if (fs26.existsSync(mainPath)) {
|
|
66320
66571
|
discovered.push({
|
|
66321
66572
|
entryPath: mainPath,
|
|
66322
66573
|
manifestName: manifest.name || pkg.name
|
|
@@ -66328,17 +66579,17 @@ function discoverExtensionsInDir(dir) {
|
|
|
66328
66579
|
}
|
|
66329
66580
|
}
|
|
66330
66581
|
const indexCjs = path24.join(entryPath, "index.cjs");
|
|
66331
|
-
if (
|
|
66582
|
+
if (fs26.existsSync(indexCjs)) {
|
|
66332
66583
|
discovered.push({ entryPath: indexCjs });
|
|
66333
66584
|
continue;
|
|
66334
66585
|
}
|
|
66335
66586
|
const indexJs = path24.join(entryPath, "index.js");
|
|
66336
|
-
if (
|
|
66587
|
+
if (fs26.existsSync(indexJs)) {
|
|
66337
66588
|
discovered.push({ entryPath: indexJs });
|
|
66338
66589
|
continue;
|
|
66339
66590
|
}
|
|
66340
66591
|
const indexTs = path24.join(entryPath, "index.ts");
|
|
66341
|
-
if (
|
|
66592
|
+
if (fs26.existsSync(indexTs)) {
|
|
66342
66593
|
discovered.push({ entryPath: indexTs });
|
|
66343
66594
|
continue;
|
|
66344
66595
|
}
|
|
@@ -66387,11 +66638,11 @@ async function loadExtensions(configuredPaths, cwd, uiContext, abortFn, isIdleFn
|
|
|
66387
66638
|
}
|
|
66388
66639
|
for (const p of configuredPaths) {
|
|
66389
66640
|
const resolved = resolvePath2(p, cwd);
|
|
66390
|
-
if (!
|
|
66641
|
+
if (!fs26.existsSync(resolved)) {
|
|
66391
66642
|
errors.push({ path: p, error: `Extension path not found: ${p}` });
|
|
66392
66643
|
continue;
|
|
66393
66644
|
}
|
|
66394
|
-
if (!
|
|
66645
|
+
if (!fs26.statSync(resolved).isDirectory()) {
|
|
66395
66646
|
errors.push({ path: p, error: `Extension path must be a directory: ${p}` });
|
|
66396
66647
|
continue;
|
|
66397
66648
|
}
|
|
@@ -67375,7 +67626,7 @@ var InteractiveMode = class {
|
|
|
67375
67626
|
if (savedLevel) {
|
|
67376
67627
|
this.thinkingLevel = savedLevel;
|
|
67377
67628
|
}
|
|
67378
|
-
const { Agent } = await import("./chunks/src-
|
|
67629
|
+
const { Agent } = await import("./chunks/src-UCXJ4C6P.js");
|
|
67379
67630
|
const activeSession = this.sessionManager.getActiveSession();
|
|
67380
67631
|
this.agent = new Agent({
|
|
67381
67632
|
initialState: {
|
|
@@ -67589,6 +67840,12 @@ var InteractiveMode = class {
|
|
|
67589
67840
|
setSubmitLock(locked) {
|
|
67590
67841
|
return setSubmitLock(this, locked);
|
|
67591
67842
|
}
|
|
67843
|
+
setControllerBusy(busy) {
|
|
67844
|
+
return setControllerBusy(this, busy);
|
|
67845
|
+
}
|
|
67846
|
+
setWaitingForUser(waiting) {
|
|
67847
|
+
return setWaitingForUser(this, waiting);
|
|
67848
|
+
}
|
|
67592
67849
|
async handleTreeCommand() {
|
|
67593
67850
|
return handleTreeCommand(this);
|
|
67594
67851
|
}
|
|
@@ -68053,7 +68310,7 @@ async function runPrintMode(params) {
|
|
|
68053
68310
|
`);
|
|
68054
68311
|
console.log("Assistant: ");
|
|
68055
68312
|
}
|
|
68056
|
-
const { Agent: AgentClass } = await import("./chunks/src-
|
|
68313
|
+
const { Agent: AgentClass } = await import("./chunks/src-UCXJ4C6P.js");
|
|
68057
68314
|
let agent;
|
|
68058
68315
|
const printModeExtensions = await loadPrintModeExtensions({
|
|
68059
68316
|
cwd: runtime.cwd,
|
|
@@ -68794,7 +69051,7 @@ async function runJsonEventsMode(params) {
|
|
|
68794
69051
|
if (runtime.initialModel.unconfigured || controller) {
|
|
68795
69052
|
return;
|
|
68796
69053
|
}
|
|
68797
|
-
const { Agent: AgentClass } = await import("./chunks/src-
|
|
69054
|
+
const { Agent: AgentClass } = await import("./chunks/src-UCXJ4C6P.js");
|
|
68798
69055
|
const jsonModeExtensions = await loadJsonModeExtensions({ runtime, getAgent: () => agent });
|
|
68799
69056
|
const tools = [...runtime.tools, ...jsonModeExtensions.extensionTools];
|
|
68800
69057
|
recordCliCompositionStep(runtime.compositionTrace, {
|
|
@@ -69180,8 +69437,8 @@ var logError = (msg, err) => {
|
|
|
69180
69437
|
const logPath = getRuntimeLogPath();
|
|
69181
69438
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
69182
69439
|
const stack = err instanceof Error ? err.stack || "" : "";
|
|
69183
|
-
|
|
69184
|
-
|
|
69440
|
+
fs27.mkdirSync(path26.dirname(logPath), { recursive: true });
|
|
69441
|
+
fs27.appendFileSync(logPath, `[${timestamp}] ${msg}
|
|
69185
69442
|
${stack}
|
|
69186
69443
|
|
|
69187
69444
|
`);
|
|
@@ -69331,7 +69588,7 @@ async function createCliTestStreamFnFromEnv() {
|
|
|
69331
69588
|
if (!process.env.PIE_TEST_MOCK_STREAM_SEQUENCE) {
|
|
69332
69589
|
return void 0;
|
|
69333
69590
|
}
|
|
69334
|
-
const { createTestStreamFnFromSequenceEnv } = await import("./chunks/test-stream-
|
|
69591
|
+
const { createTestStreamFnFromSequenceEnv } = await import("./chunks/test-stream-UKULOPZB.js");
|
|
69335
69592
|
return createTestStreamFnFromSequenceEnv();
|
|
69336
69593
|
}
|
|
69337
69594
|
async function startChat(initialPrompt, testCommand) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cydm/pie",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
4
4
|
"description": "Pie AI Agent CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"validate:models": "tsx scripts/validate-models-config.ts",
|
|
17
17
|
"test": "npm run test:offline",
|
|
18
18
|
"pretest:offline": "npm run build --workspace @pie/agent-framework && npm run build --workspace @pie/shared-headless-capabilities && npm run build",
|
|
19
|
-
"test:offline": "node --test --import tsx test/core-services.test.ts test/cli.test.ts test/cli-auto-compaction.test.ts test/execution-state-manager.test.ts test/queued-steer-execution-state.test.ts test/architecture-boundaries.test.ts test/attachment-resolver.test.ts test/kimi-attachment-extension.test.ts test/document-attachment-extension.test.ts test/auto-compact-overflow.test.ts test/hierarchical-command-system.test.ts test/message-queue-unit.test.ts test/evals-harness.test.ts test/session-trace.test.ts test/runtime-mode-context.test.ts test/tool-policy.test.ts test/yolo-command.test.ts test/footer-lifecycle.test.ts test/files-utils.test.ts test/source-size-guard.test.ts test/runtime-logger.test.ts test/release-readiness.test.ts test/code-intel-typescript-provider.test.ts test/init-extension-contract.test.ts test/skills-runtime.test.ts test/cross-host-parity.test.ts test/tool-name-rendering.test.ts test/tools-registry.test.ts test/system-prompt-contract.test.ts test/daily-agent-smoke.terminal.test.ts",
|
|
19
|
+
"test:offline": "node --test --import tsx test/core-services.test.ts test/cli.test.ts test/cli-auto-compaction.test.ts test/execution-state-manager.test.ts test/queued-steer-execution-state.test.ts test/architecture-boundaries.test.ts test/attachment-resolver.test.ts test/kimi-attachment-extension.test.ts test/document-attachment-extension.test.ts test/auto-compact-overflow.test.ts test/hierarchical-command-system.test.ts test/message-queue-unit.test.ts test/evals-harness.test.ts test/session-trace.test.ts test/runtime-mode-context.test.ts test/tool-policy.test.ts test/retry-policy.test.ts test/session-preview.test.ts test/yolo-command.test.ts test/footer-lifecycle.test.ts test/files-utils.test.ts test/source-size-guard.test.ts test/runtime-logger.test.ts test/release-readiness.test.ts test/code-intel-typescript-provider.test.ts test/init-extension-contract.test.ts test/skills-runtime.test.ts test/cross-host-parity.test.ts test/tool-name-rendering.test.ts test/tools-registry.test.ts test/system-prompt-contract.test.ts test/daily-agent-smoke.terminal.test.ts",
|
|
20
20
|
"test:all": "npm run test:offline && npm run test:terminal:vitest",
|
|
21
21
|
"test:terminal:vitest": "vitest run test/mention-file-select.terminal.test.ts test/tool-partial-display.terminal.test.ts test/viewport-position-final.test.ts",
|
|
22
22
|
"test:todo-tui": "PIE_REAL_TODO_TUI=1 node --test --import tsx test/todo-closure.terminal.test.ts",
|