@cydm/pie 4.3.12 → 4.4.1

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.
Files changed (41) hide show
  1. package/dist/builtin/extensions/ask-user/index.js +6 -6
  2. package/dist/builtin/extensions/changelog/index.js +1 -1
  3. package/dist/builtin/extensions/cron/index.js +2 -2
  4. package/dist/builtin/extensions/document-attachments/index.js +1 -1
  5. package/dist/builtin/extensions/herdr-agent-state/index.js +1 -1
  6. package/dist/builtin/extensions/im-forward/README.md +15 -2
  7. package/dist/builtin/extensions/im-forward/index.js +95 -7
  8. package/dist/builtin/extensions/init/index.js +1 -1
  9. package/dist/builtin/extensions/mcp-adapter/index.js +2 -2
  10. package/dist/builtin/extensions/memory/index.js +11 -9
  11. package/dist/builtin/extensions/pie-ipc/index.js +6 -4
  12. package/dist/builtin/extensions/pie-proc/index.js +70 -7
  13. package/dist/builtin/extensions/plan-mode/index.js +6 -6
  14. package/dist/builtin/extensions/subagent/index.js +11 -9
  15. package/dist/builtin/extensions/todo/index.js +6 -6
  16. package/dist/builtin/skills/computer-use-axi/computer-use-axi-broker.js +1 -1
  17. package/dist/builtin/skills/computer-use-axi/computer-use-axi-runtime.js +1 -1
  18. package/dist/chunks/{auth-storage-3EGM3VTK.js → auth-storage-RABPRJ6T.js} +3 -3
  19. package/dist/chunks/chunk-7KLWHWZD.js +164 -0
  20. package/dist/chunks/{chunk-I7PBXG5Q.js → chunk-7LTQLJJF.js} +9 -6
  21. package/dist/chunks/{chunk-EGNGHINP.js → chunk-AKXEZH7K.js} +6 -1
  22. package/dist/chunks/{chunk-XXGYUYXI.js → chunk-BPSCGGVF.js} +1 -1
  23. package/dist/chunks/{chunk-VHKMWOG3.js → chunk-EQOI6RZV.js} +5 -3
  24. package/dist/chunks/{chunk-B4N5LJMD.js → chunk-IPLMGAML.js} +1 -1
  25. package/dist/chunks/{chunk-GY47MKCJ.js → chunk-IZDNZW3S.js} +8 -8
  26. package/dist/chunks/{chunk-6DNYGVZP.js → chunk-OV7SLSHR.js} +4 -2
  27. package/dist/chunks/{chunk-6JEYRAQM.js → chunk-R7VO46EK.js} +2 -2
  28. package/dist/chunks/{chunk-LZQXQOPJ.js → chunk-RZGYXAJU.js} +12 -1
  29. package/dist/chunks/{chunk-ILUHTKF3.js → chunk-UCKOXAME.js} +61 -11
  30. package/dist/chunks/{chunk-XMOWWL4B.js → chunk-XO3NM7BB.js} +3 -3
  31. package/dist/chunks/{chunk-N5B5IGJ6.js → chunk-YNTIOWCD.js} +5 -5
  32. package/dist/chunks/{config-74AUVDLT.js → config-HF2PDLN5.js} +8 -4
  33. package/dist/chunks/{manager-cli-4Z6RZ7F4.js → manager-cli-BYCF4RKN.js} +5 -3
  34. package/dist/chunks/{model-registry-NKE3BRSZ.js → model-registry-7FNIUYPF.js} +5 -5
  35. package/dist/chunks/{src-V2M7FLWY.js → src-A5YI46OD.js} +6 -6
  36. package/dist/chunks/{src-4EQ7PBEI.js → src-OA3TP6DS.js} +5 -5
  37. package/dist/chunks/{src-46R5ZFOU.js → src-OVWRBWKU.js} +4 -4
  38. package/dist/chunks/{src-BHIH4VLE.js → src-TF2RAGRU.js} +3 -3
  39. package/dist/chunks/{test-stream-FC6ZRENI.js → test-stream-7YZDGBPO.js} +3 -3
  40. package/dist/cli.js +231 -49
  41. package/package.json +2 -2
@@ -41,7 +41,7 @@ import path from "node:path";
41
41
  // src/config.ts
42
42
  import { existsSync, mkdirSync, readFileSync, renameSync } from "fs";
43
43
  import { homedir } from "os";
44
- import { dirname, join } from "path";
44
+ import { dirname, isAbsolute, join } from "path";
45
45
  import { fileURLToPath } from "url";
46
46
  var __filename = fileURLToPath(import.meta.url);
47
47
  var __dirname = dirname(__filename);
@@ -3,9 +3,9 @@ import {
3
3
  AuthStorage,
4
4
  FileAuthStorageBackend,
5
5
  InMemoryAuthStorageBackend
6
- } from "./chunk-6DNYGVZP.js";
7
- import "./chunk-ILUHTKF3.js";
8
- import "./chunk-LZQXQOPJ.js";
6
+ } from "./chunk-OV7SLSHR.js";
7
+ import "./chunk-UCKOXAME.js";
8
+ import "./chunk-RZGYXAJU.js";
9
9
  export {
10
10
  AuthStorage,
11
11
  FileAuthStorageBackend,
@@ -0,0 +1,164 @@
1
+ import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+ import {
3
+ config_exports,
4
+ init_config
5
+ } from "./chunk-UCKOXAME.js";
6
+ import {
7
+ __toCommonJS
8
+ } from "./chunk-RZGYXAJU.js";
9
+
10
+ // src/app/session-ownership.ts
11
+ import * as fs from "node:fs";
12
+ import * as os from "node:os";
13
+ import * as path from "node:path";
14
+ var STALE_MS = 2e4;
15
+ function sessionOwnersRoot() {
16
+ const store = process.env.PIE_SESSIONS_STORE_ROOT_FOR_OWNERS ?? sessionStoreRoot();
17
+ return path.join(store, "session-owners");
18
+ }
19
+ function sessionStoreRoot() {
20
+ try {
21
+ const { getSessionsDir } = (init_config(), __toCommonJS(config_exports));
22
+ return path.dirname(getSessionsDir());
23
+ } catch {
24
+ const storeOverride = process.env.PIE_SESSIONS_DIR;
25
+ if (storeOverride !== void 0 && storeOverride !== "") {
26
+ const expanded = storeOverride === "~" ? path.join(os.homedir(), "sessions") : storeOverride.startsWith("~/") ? path.join(os.homedir(), storeOverride.slice(2)) : storeOverride;
27
+ if (path.isAbsolute(expanded)) return path.dirname(expanded);
28
+ }
29
+ const agentDir = process.env.PIE_CODING_AGENT_DIR;
30
+ if (agentDir !== void 0 && agentDir !== "") {
31
+ if (agentDir === "~") return path.join(os.homedir(), ".pie");
32
+ if (agentDir.startsWith("~/")) return path.join(os.homedir(), agentDir.slice(2));
33
+ if (path.isAbsolute(agentDir)) return agentDir;
34
+ }
35
+ return path.join(os.homedir(), ".pie");
36
+ }
37
+ }
38
+ function lockPath(sessionId) {
39
+ const safe = sessionId.replace(/[^a-zA-Z0-9._-]/g, "_");
40
+ return path.join(sessionOwnersRoot(), `${safe}.lock`);
41
+ }
42
+ function pidAlive(pid) {
43
+ if (!Number.isInteger(pid) || pid <= 0) return false;
44
+ try {
45
+ process.kill(pid, 0);
46
+ return true;
47
+ } catch (error) {
48
+ return error.code === "EPERM";
49
+ }
50
+ }
51
+ function readLock(sessionId) {
52
+ try {
53
+ const parsed = JSON.parse(fs.readFileSync(lockPath(sessionId), "utf8"));
54
+ if (typeof parsed.pid === "number" && typeof parsed.holder === "string" && typeof parsed.heartbeatAt === "number" && typeof parsed.sessionId === "string") {
55
+ return { pid: parsed.pid, holder: parsed.holder, heartbeatAt: parsed.heartbeatAt, sessionId: parsed.sessionId };
56
+ }
57
+ return void 0;
58
+ } catch {
59
+ return void 0;
60
+ }
61
+ }
62
+ function sessionOwnerAlive(sessionId, now = Date.now()) {
63
+ const info = readLock(sessionId);
64
+ if (!info) return void 0;
65
+ if (!pidAlive(info.pid)) return void 0;
66
+ if (now - info.heartbeatAt >= STALE_MS) return void 0;
67
+ return info;
68
+ }
69
+ function claimSessionOwnership(sessionId, holder, onLost) {
70
+ const target = lockPath(sessionId);
71
+ const writeMine = () => {
72
+ fs.mkdirSync(path.dirname(target), { recursive: true, mode: 448 });
73
+ fs.writeFileSync(target, `${JSON.stringify({ pid: process.pid, holder, heartbeatAt: Date.now(), sessionId })}
74
+ `);
75
+ };
76
+ let existing;
77
+ try {
78
+ existing = readLock(sessionId);
79
+ } catch {
80
+ return { holder: { pid: -1, holder: "(unreadable lock)", heartbeatAt: Date.now(), sessionId } };
81
+ }
82
+ if (existing && pidAlive(existing.pid) && Date.now() - existing.heartbeatAt < STALE_MS) {
83
+ return { holder: existing };
84
+ }
85
+ if (existing) {
86
+ try {
87
+ fs.rmSync(target, { force: true });
88
+ } catch {
89
+ }
90
+ }
91
+ const tmp = `${target}.${process.pid}.${Date.now()}.tmp`;
92
+ try {
93
+ fs.mkdirSync(path.dirname(target), { recursive: true, mode: 448 });
94
+ fs.writeFileSync(tmp, `${JSON.stringify({ pid: process.pid, holder, heartbeatAt: Date.now(), sessionId })}
95
+ `);
96
+ try {
97
+ fs.linkSync(tmp, target);
98
+ fs.rmSync(tmp, { force: true });
99
+ } catch (error) {
100
+ fs.rmSync(tmp, { force: true });
101
+ if (error.code !== "EEXIST") throw error;
102
+ const winner = readLock(sessionId);
103
+ return { holder: winner ?? { pid: -1, holder: "(concurrent claim)", heartbeatAt: Date.now(), sessionId } };
104
+ }
105
+ const verified = readLock(sessionId);
106
+ if (!verified || verified.pid !== process.pid) {
107
+ return { holder: verified ?? { pid: -1, holder: "(takeover race lost)", heartbeatAt: Date.now(), sessionId } };
108
+ }
109
+ } catch {
110
+ return { holder: { pid: -1, holder: "(lock IO failed)", heartbeatAt: Date.now(), sessionId } };
111
+ }
112
+ let released = false;
113
+ let lost = false;
114
+ const heartbeatTimer = setInterval(() => {
115
+ if (released) return;
116
+ try {
117
+ const current = readLock(sessionId);
118
+ if (current && current.pid !== process.pid) {
119
+ if (!lost) {
120
+ lost = true;
121
+ try {
122
+ onLost?.("takeover");
123
+ } catch {
124
+ }
125
+ }
126
+ released = true;
127
+ clearInterval(heartbeatTimer);
128
+ return;
129
+ }
130
+ fs.writeFileSync(target, `${JSON.stringify({ pid: process.pid, holder, heartbeatAt: Date.now(), sessionId })}
131
+ `);
132
+ } catch {
133
+ }
134
+ }, 5e3);
135
+ heartbeatTimer.unref();
136
+ return {
137
+ handle: {
138
+ heartbeat: () => {
139
+ try {
140
+ writeMine();
141
+ } catch {
142
+ }
143
+ },
144
+ release: () => {
145
+ if (released) return;
146
+ released = true;
147
+ clearInterval(heartbeatTimer);
148
+ try {
149
+ const current = readLock(sessionId);
150
+ if (current && current.pid === process.pid) fs.rmSync(target, { force: true });
151
+ } catch {
152
+ }
153
+ }
154
+ }
155
+ };
156
+ }
157
+ function liveSessionHolder(sessionId) {
158
+ return sessionOwnerAlive(sessionId);
159
+ }
160
+
161
+ export {
162
+ claimSessionOwnership,
163
+ liveSessionHolder
164
+ };
@@ -1,8 +1,9 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  getBuiltinDir,
4
- getConfigDir
5
- } from "./chunk-ILUHTKF3.js";
4
+ getConfigDir,
5
+ init_config
6
+ } from "./chunk-UCKOXAME.js";
6
7
  import {
7
8
  classifyShellCommand,
8
9
  createSharedWebFetchTool,
@@ -10,18 +11,18 @@ import {
10
11
  createSharedWebSearchTool,
11
12
  defaultShellKindForPlatform,
12
13
  interpretShellExit
13
- } from "./chunk-N5B5IGJ6.js";
14
+ } from "./chunk-YNTIOWCD.js";
14
15
  import {
15
16
  requestInteraction
16
- } from "./chunk-XMOWWL4B.js";
17
+ } from "./chunk-XO3NM7BB.js";
17
18
  import {
18
19
  EMPTY_ASSISTANT_CONTENT_ERROR,
19
20
  OPENAI_COMPAT_PROTOCOL_ERROR_CODE,
20
21
  getLogger
21
- } from "./chunk-6JEYRAQM.js";
22
+ } from "./chunk-R7VO46EK.js";
22
23
  import {
23
24
  Type
24
- } from "./chunk-XXGYUYXI.js";
25
+ } from "./chunk-BPSCGGVF.js";
25
26
 
26
27
  // src/runtime/retry-policy.ts
27
28
  var TRANSIENT_NETWORK_ERROR_PATTERN = /sse stream aborted|sse stream closed before end|sse stream ended before response completed|responses stream ended without a terminal event|(?:read\s+)?ECONNRESET|ETIMEDOUT|EAI_AGAIN|ENOTFOUND|ECONNREFUSED|(?:read\s+|write\s+)?EPIPE|socket hang up|request timeout|websocket upgrade refused|websocket handshake|websocket connection failed|websocket transport failed|connection closed before opening|client network socket disconnected before secure TLS connection was established|connection.?error|connection.?refused|other side closed|fetch failed|upstream.?connect|reset before headers|terminated/i;
@@ -1411,6 +1412,7 @@ ${commandNonzeroHint}`;
1411
1412
  }
1412
1413
 
1413
1414
  // src/capabilities/rendered-page-reader.ts
1415
+ init_config();
1414
1416
  import { spawn as spawn2 } from "node:child_process";
1415
1417
  import { createRequire } from "node:module";
1416
1418
  import * as fs from "node:fs";
@@ -1615,6 +1617,7 @@ function createCliWebResearchHealthStore(configDir) {
1615
1617
  }
1616
1618
 
1617
1619
  // src/capabilities/index.ts
1620
+ init_config();
1618
1621
  function createCliHostCapabilities(cwd, options = {}) {
1619
1622
  const bashTool = createBashTool(cwd, options.getBashEnv ? { getEnv: options.getBashEnv } : void 0);
1620
1623
  const healthStore = createCliWebResearchHealthStore(options.configDir ?? getConfigDir());
@@ -1381,6 +1381,10 @@ function tryClaimConsumer(binding, holder, onLost, shouldYield) {
1381
1381
  }
1382
1382
  };
1383
1383
  }
1384
+ function currentConsumer(binding) {
1385
+ const info = readLock(binding);
1386
+ return { info, alive: lockAlive(info) };
1387
+ }
1384
1388
 
1385
1389
  export {
1386
1390
  isRecord,
@@ -1433,5 +1437,6 @@ export {
1433
1437
  isTurnUserImDriven,
1434
1438
  registerDispatchReceiver,
1435
1439
  takeDispatchFrame,
1436
- tryClaimConsumer
1440
+ tryClaimConsumer,
1441
+ currentConsumer
1437
1442
  };
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  __export
4
- } from "./chunk-LZQXQOPJ.js";
4
+ } from "./chunk-RZGYXAJU.js";
5
5
 
6
6
  // ../../node_modules/@sinclair/typebox/build/esm/value/guard/guard.mjs
7
7
  function IsAsyncIterator(value) {
@@ -1,15 +1,17 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
- getConfigDir
4
- } from "./chunk-ILUHTKF3.js";
3
+ getConfigDir,
4
+ init_config
5
+ } from "./chunk-UCKOXAME.js";
5
6
  import {
6
7
  MODEL_CLASS_FALLBACK_ORDER,
7
8
  modelSupportsToolPurpose,
8
9
  requiredCapabilityForToolPurpose,
9
10
  sortToolModelCandidatesByCapability
10
- } from "./chunk-6JEYRAQM.js";
11
+ } from "./chunk-R7VO46EK.js";
11
12
 
12
13
  // src/core/model-registry.ts
14
+ init_config();
13
15
  import * as fs from "fs";
14
16
  import * as path from "path";
15
17
  import { createHash, createHmac, randomBytes } from "node:crypto";
@@ -4,7 +4,7 @@ import {
4
4
  disposeModelTransports,
5
5
  streamSimple,
6
6
  validateToolArguments
7
- } from "./chunk-6JEYRAQM.js";
7
+ } from "./chunk-R7VO46EK.js";
8
8
 
9
9
  // ../../packages/agent-core/src/failure.ts
10
10
  function getAgentFailureMetadata(error) {
@@ -147,7 +147,7 @@ function pathContains(parent, child) {
147
147
  }
148
148
  async function readExcludeCwds() {
149
149
  try {
150
- const { getSettingsPath } = await import("./config-74AUVDLT.js");
150
+ const { getSettingsPath } = await import("./config-HF2PDLN5.js");
151
151
  const raw = JSON.parse(fs.readFileSync(getSettingsPath(), "utf8"));
152
152
  const list = raw?.extensions?.memory?.excludeCwds;
153
153
  if (!Array.isArray(list)) return [];
@@ -171,11 +171,11 @@ async function runDistillWorkerMain(memoryRoot, date, noExit = false) {
171
171
  let result;
172
172
  let ledger;
173
173
  try {
174
- const { ModelRegistry } = await import("./model-registry-NKE3BRSZ.js");
175
- const { AuthStorage } = await import("./auth-storage-3EGM3VTK.js");
176
- const { getSessionsDir } = await import("./config-74AUVDLT.js");
177
- const { FileSessionStore } = await import("./src-4EQ7PBEI.js");
178
- const { MemoryStore, runDistillation } = await import("./src-V2M7FLWY.js");
174
+ const { ModelRegistry } = await import("./model-registry-7FNIUYPF.js");
175
+ const { AuthStorage } = await import("./auth-storage-RABPRJ6T.js");
176
+ const { getSessionsDir } = await import("./config-HF2PDLN5.js");
177
+ const { FileSessionStore } = await import("./src-OA3TP6DS.js");
178
+ const { MemoryStore, runDistillation } = await import("./src-A5YI46OD.js");
179
179
  const store = new MemoryStore(memoryRoot);
180
180
  ledger = store;
181
181
  const registry = new ModelRegistry(AuthStorage.create());
@@ -190,7 +190,7 @@ async function runDistillWorkerMain(memoryRoot, date, noExit = false) {
190
190
  if (!resolved.model || !resolved.apiKey) {
191
191
  throw new Error(`no complete model/key pair for class ${modelClass}${resolved.fallbackReason ? `: ${resolved.fallbackReason}` : ""}`);
192
192
  }
193
- const { completeSimple } = await import("./src-BHIH4VLE.js");
193
+ const { completeSimple } = await import("./src-TF2RAGRU.js");
194
194
  const message = await withModelTimeout(
195
195
  completeSimple(
196
196
  resolved.model,
@@ -255,7 +255,7 @@ async function runDistillAuto(memoryRoot, days = 7, runner) {
255
255
  } catch {
256
256
  }
257
257
  };
258
- const { MemoryStore, todayKey } = await import("./src-V2M7FLWY.js");
258
+ const { MemoryStore, todayKey } = await import("./src-A5YI46OD.js");
259
259
  const store = new MemoryStore(memoryRoot);
260
260
  const today = todayKey(Date.now());
261
261
  const dates = [];
@@ -1,9 +1,11 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
- getConfigDir
4
- } from "./chunk-ILUHTKF3.js";
3
+ getConfigDir,
4
+ init_config
5
+ } from "./chunk-UCKOXAME.js";
5
6
 
6
7
  // src/core/auth-storage.ts
8
+ init_config();
7
9
  import * as fs from "fs";
8
10
  import * as path from "path";
9
11
  var AUTH_LOCK_WRITE_GRACE_MS = 1e3;
@@ -41,13 +41,13 @@ import {
41
41
  TypeSystemPolicy,
42
42
  Union,
43
43
  Unknown
44
- } from "./chunk-XXGYUYXI.js";
44
+ } from "./chunk-BPSCGGVF.js";
45
45
  import {
46
46
  __commonJS,
47
47
  __export,
48
48
  __require,
49
49
  __toESM
50
- } from "./chunk-LZQXQOPJ.js";
50
+ } from "./chunk-RZGYXAJU.js";
51
51
 
52
52
  // ../../node_modules/partial-json/dist/options.js
53
53
  var require_options = __commonJS({
@@ -11,6 +11,14 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
11
11
  if (typeof require !== "undefined") return require.apply(this, arguments);
12
12
  throw Error('Dynamic require of "' + x + '" is not supported');
13
13
  });
14
+ var __esm = (fn, res, err) => function __init() {
15
+ if (err) throw err[0];
16
+ try {
17
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
18
+ } catch (e) {
19
+ throw err = [e], e;
20
+ }
21
+ };
14
22
  var __commonJS = (cb, mod) => function __require2() {
15
23
  try {
16
24
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
@@ -38,10 +46,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
38
46
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
39
47
  mod
40
48
  ));
49
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
41
50
 
42
51
  export {
43
52
  __require,
53
+ __esm,
44
54
  __commonJS,
45
55
  __export,
46
- __toESM
56
+ __toESM,
57
+ __toCommonJS
47
58
  };
@@ -1,13 +1,38 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
+ import {
3
+ __esm,
4
+ __export
5
+ } from "./chunk-RZGYXAJU.js";
2
6
 
3
7
  // src/config.ts
8
+ var config_exports = {};
9
+ __export(config_exports, {
10
+ APP_NAME: () => APP_NAME,
11
+ CONFIG_DIR_NAME: () => CONFIG_DIR_NAME,
12
+ ENV_AGENT_DIR: () => ENV_AGENT_DIR,
13
+ VERSION: () => VERSION,
14
+ getAgentDir: () => getAgentDir,
15
+ getBuiltinDir: () => getBuiltinDir,
16
+ getConfigDir: () => getConfigDir,
17
+ getCustomThemesDir: () => getCustomThemesDir,
18
+ getDebugLogPath: () => getDebugLogPath,
19
+ getKeybindingsPath: () => getKeybindingsPath,
20
+ getLogsDir: () => getLogsDir,
21
+ getPackageDir: () => getPackageDir,
22
+ getPackageJsonPath: () => getPackageJsonPath,
23
+ getProjectSettingsPath: () => getProjectSettingsPath,
24
+ getRuntimeLogPath: () => getRuntimeLogPath,
25
+ getSessionsDir: () => getSessionsDir,
26
+ getSettingsPath: () => getSettingsPath,
27
+ getThemesDir: () => getThemesDir,
28
+ isBunRuntime: () => isBunRuntime,
29
+ migrateConfigFromAgentDir: () => migrateConfigFromAgentDir,
30
+ resolveSessionsDirOverride: () => resolveSessionsDirOverride
31
+ });
4
32
  import { existsSync, mkdirSync, readFileSync, renameSync } from "fs";
5
33
  import { homedir } from "os";
6
- import { dirname, join } from "path";
34
+ import { dirname, isAbsolute, join } from "path";
7
35
  import { fileURLToPath } from "url";
8
- var __filename = fileURLToPath(import.meta.url);
9
- var __dirname = dirname(__filename);
10
- var isBunRuntime = !!process.versions.bun;
11
36
  function getPackageDir() {
12
37
  const envDir = process.env.PIE_PACKAGE_DIR;
13
38
  if (envDir) {
@@ -40,11 +65,6 @@ function getBuiltinDir() {
40
65
  function getPackageJsonPath() {
41
66
  return join(getPackageDir(), "package.json");
42
67
  }
43
- var pkg = JSON.parse(readFileSync(getPackageJsonPath(), "utf-8"));
44
- var APP_NAME = "pie";
45
- var CONFIG_DIR_NAME = ".pie";
46
- var VERSION = pkg.version;
47
- var ENV_AGENT_DIR = "PIE_CODING_AGENT_DIR";
48
68
  function getConfigDir() {
49
69
  const envDir = process.env[ENV_AGENT_DIR];
50
70
  if (envDir !== void 0 && envDir !== "") {
@@ -74,8 +94,22 @@ function getSettingsPath() {
74
94
  function getProjectSettingsPath(cwd) {
75
95
  return join(cwd, CONFIG_DIR_NAME, "settings.json");
76
96
  }
97
+ function resolveSessionsDirOverride() {
98
+ const override = process.env.PIE_SESSIONS_DIR;
99
+ if (override !== void 0 && override !== "") {
100
+ if (override === "~") return join(homedir(), "sessions");
101
+ if (override.startsWith("~/")) return join(homedir(), override.slice(2));
102
+ if (!isAbsolute(override)) {
103
+ throw new Error(
104
+ `PIE_SESSIONS_DIR is relative ("${override}"); it must be an absolute path \u2014 a relative store would resolve differently across working directories`
105
+ );
106
+ }
107
+ return override;
108
+ }
109
+ return void 0;
110
+ }
77
111
  function getSessionsDir() {
78
- return join(getConfigDir(), "sessions");
112
+ return resolveSessionsDirOverride() ?? join(getConfigDir(), "sessions");
79
113
  }
80
114
  function getLogsDir() {
81
115
  return join(getConfigDir(), "logs");
@@ -124,6 +158,19 @@ function migrateConfigFromAgentDir() {
124
158
  }
125
159
  }
126
160
  }
161
+ var __filename, __dirname, isBunRuntime, pkg, APP_NAME, CONFIG_DIR_NAME, VERSION, ENV_AGENT_DIR;
162
+ var init_config = __esm({
163
+ "src/config.ts"() {
164
+ __filename = fileURLToPath(import.meta.url);
165
+ __dirname = dirname(__filename);
166
+ isBunRuntime = !!process.versions.bun;
167
+ pkg = JSON.parse(readFileSync(getPackageJsonPath(), "utf-8"));
168
+ APP_NAME = "pie";
169
+ CONFIG_DIR_NAME = ".pie";
170
+ VERSION = pkg.version;
171
+ ENV_AGENT_DIR = "PIE_CODING_AGENT_DIR";
172
+ }
173
+ });
127
174
 
128
175
  export {
129
176
  isBunRuntime,
@@ -141,9 +188,12 @@ export {
141
188
  getKeybindingsPath,
142
189
  getSettingsPath,
143
190
  getProjectSettingsPath,
191
+ resolveSessionsDirOverride,
144
192
  getSessionsDir,
145
193
  getLogsDir,
146
194
  getRuntimeLogPath,
147
195
  getDebugLogPath,
148
- migrateConfigFromAgentDir
196
+ migrateConfigFromAgentDir,
197
+ config_exports,
198
+ init_config
149
199
  };
@@ -2,17 +2,17 @@ import { createRequire as __createRequire } from "node:module"; const require =
2
2
  import {
3
3
  createAgentOperationError,
4
4
  getAgentFailureMetadata
5
- } from "./chunk-B4N5LJMD.js";
5
+ } from "./chunk-IPLMGAML.js";
6
6
  import {
7
7
  FileSystemGateway,
8
8
  detectPlatform,
9
9
  getFileSystemGateway,
10
10
  getPlatformConfig,
11
11
  streamSimple
12
- } from "./chunk-6JEYRAQM.js";
12
+ } from "./chunk-R7VO46EK.js";
13
13
  import {
14
14
  Type
15
- } from "./chunk-XXGYUYXI.js";
15
+ } from "./chunk-BPSCGGVF.js";
16
16
 
17
17
  // ../../packages/agent-framework/src/skills/parser.ts
18
18
  function parseFrontmatter(yaml) {
@@ -13,11 +13,11 @@ import {
13
13
  parseEntryIdSeq,
14
14
  readAncestryPage,
15
15
  requestInteraction
16
- } from "./chunk-XMOWWL4B.js";
16
+ } from "./chunk-XO3NM7BB.js";
17
17
  import {
18
18
  Agent,
19
19
  getToolCallerIdentity
20
- } from "./chunk-B4N5LJMD.js";
20
+ } from "./chunk-IPLMGAML.js";
21
21
  import {
22
22
  AssistantMessageEventStream,
23
23
  completeSimple,
@@ -25,14 +25,14 @@ import {
25
25
  getFileSystem,
26
26
  hashText,
27
27
  streamSimple
28
- } from "./chunk-6JEYRAQM.js";
28
+ } from "./chunk-R7VO46EK.js";
29
29
  import {
30
30
  Type
31
- } from "./chunk-XXGYUYXI.js";
31
+ } from "./chunk-BPSCGGVF.js";
32
32
  import {
33
33
  __commonJS,
34
34
  __toESM
35
- } from "./chunk-LZQXQOPJ.js";
35
+ } from "./chunk-RZGYXAJU.js";
36
36
 
37
37
  // ../../node_modules/shell-quote/quote.js
38
38
  var require_quote = __commonJS({
@@ -18,10 +18,13 @@ import {
18
18
  getSessionsDir,
19
19
  getSettingsPath,
20
20
  getThemesDir,
21
+ init_config,
21
22
  isBunRuntime,
22
- migrateConfigFromAgentDir
23
- } from "./chunk-ILUHTKF3.js";
24
- import "./chunk-LZQXQOPJ.js";
23
+ migrateConfigFromAgentDir,
24
+ resolveSessionsDirOverride
25
+ } from "./chunk-UCKOXAME.js";
26
+ import "./chunk-RZGYXAJU.js";
27
+ init_config();
25
28
  export {
26
29
  APP_NAME,
27
30
  CONFIG_DIR_NAME,
@@ -42,5 +45,6 @@ export {
42
45
  getSettingsPath,
43
46
  getThemesDir,
44
47
  isBunRuntime,
45
- migrateConfigFromAgentDir
48
+ migrateConfigFromAgentDir,
49
+ resolveSessionsDirOverride
46
50
  };
@@ -3,9 +3,10 @@ import {
3
3
  readProcessCommandLine
4
4
  } from "./chunk-X6LBWHK3.js";
5
5
  import {
6
- getConfigDir
7
- } from "./chunk-ILUHTKF3.js";
8
- import "./chunk-LZQXQOPJ.js";
6
+ getConfigDir,
7
+ init_config
8
+ } from "./chunk-UCKOXAME.js";
9
+ import "./chunk-RZGYXAJU.js";
9
10
 
10
11
  // src/commands/manager-cli.ts
11
12
  import { spawn, execFileSync } from "node:child_process";
@@ -13,6 +14,7 @@ import { createRequire } from "node:module";
13
14
  import * as fs from "node:fs";
14
15
  import * as os from "node:os";
15
16
  import * as path from "node:path";
17
+ init_config();
16
18
  var require_ = createRequire(import.meta.url);
17
19
  var CRON_SECTION_MARKER = "## \u5B9A\u65F6\u4EFB\u52A1";
18
20
  var CRON_SECTION = `
@@ -4,11 +4,11 @@ import {
4
4
  assertNoSecretSubstrings,
5
5
  configuredRemoteCredentialValues,
6
6
  loadResolvedModelsConfig
7
- } from "./chunk-VHKMWOG3.js";
8
- import "./chunk-ILUHTKF3.js";
9
- import "./chunk-6JEYRAQM.js";
10
- import "./chunk-XXGYUYXI.js";
11
- import "./chunk-LZQXQOPJ.js";
7
+ } from "./chunk-EQOI6RZV.js";
8
+ import "./chunk-UCKOXAME.js";
9
+ import "./chunk-R7VO46EK.js";
10
+ import "./chunk-BPSCGGVF.js";
11
+ import "./chunk-RZGYXAJU.js";
12
12
  export {
13
13
  ModelRegistry,
14
14
  assertNoSecretSubstrings,
@@ -213,14 +213,14 @@ import {
213
213
  understandFileWithModel,
214
214
  validateTodos,
215
215
  writeJournalNarrative
216
- } from "./chunk-N5B5IGJ6.js";
217
- import "./chunk-XMOWWL4B.js";
218
- import "./chunk-B4N5LJMD.js";
216
+ } from "./chunk-YNTIOWCD.js";
217
+ import "./chunk-XO3NM7BB.js";
218
+ import "./chunk-IPLMGAML.js";
219
219
  import {
220
220
  hashText
221
- } from "./chunk-6JEYRAQM.js";
222
- import "./chunk-XXGYUYXI.js";
223
- import "./chunk-LZQXQOPJ.js";
221
+ } from "./chunk-R7VO46EK.js";
222
+ import "./chunk-BPSCGGVF.js";
223
+ import "./chunk-RZGYXAJU.js";
224
224
  export {
225
225
  ANTONYM_PAIRS,
226
226
  AskUserMultiParamsSchema,