@agimon-ai/po-task 0.0.0-alpha.45 → 0.0.0-alpha.46
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/{delegation-CLcleXHi.mjs → delegation-5TOl_dEq.mjs} +2 -2
- package/dist/delegation-5TOl_dEq.mjs.map +1 -0
- package/dist/{delegation-DRp6iZid.cjs → delegation-BJtAUTVg.cjs} +2 -2
- package/dist/delegation-BJtAUTVg.cjs.map +1 -0
- package/dist/delegationManager.cjs +1 -1
- package/dist/delegationManager.d.mts +1 -1
- package/dist/delegationManager.mjs +1 -1
- package/dist/extensions/mcp.cjs +28 -34
- package/dist/extensions/mcp.cjs.map +1 -1
- package/dist/extensions/mcp.mjs +27 -33
- package/dist/extensions/mcp.mjs.map +1 -1
- package/dist/extensions/server.cjs +31 -15
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.mjs +31 -15
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/{index-S77ZvGc-.d.mts → index-DuT-Lbxy.d.mts} +1 -2
- package/dist/index-DuT-Lbxy.d.mts.map +1 -0
- package/dist/{index-Dyan0ai0.d.mts → index-sahNy7Hg.d.mts} +2 -2
- package/dist/{index-Dyan0ai0.d.mts.map → index-sahNy7Hg.d.mts.map} +1 -1
- package/dist/{index-CA4Opp4r.d.mts → index-tAu1TIyi.d.mts} +4 -6
- package/dist/index-tAu1TIyi.d.mts.map +1 -0
- package/dist/index.cjs +3 -5
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +4 -4
- package/dist/{paths-P-XvOUuH.cjs → paths-CWVDY8Yd.cjs} +12 -78
- package/dist/paths-CWVDY8Yd.cjs.map +1 -0
- package/dist/{paths-DajceJig.mjs → paths-CjATVpi8.mjs} +12 -66
- package/dist/paths-CjATVpi8.mjs.map +1 -0
- package/dist/storePaths.cjs +1 -3
- package/dist/storePaths.d.mts +2 -2
- package/dist/storePaths.mjs +1 -1
- package/dist/storeTaskStore.cjs +1 -1
- package/dist/storeTaskStore.d.mts +1 -1
- package/dist/storeTaskStore.mjs +1 -1
- package/dist/{taskStore-C4vcUOzA.cjs → taskStore-B-BbY2Ci.cjs} +30 -36
- package/dist/taskStore-B-BbY2Ci.cjs.map +1 -0
- package/dist/{taskStore-BAi54FKL.mjs → taskStore-wuXXFCZT.mjs} +29 -35
- package/dist/taskStore-wuXXFCZT.mjs.map +1 -0
- package/package.json +6 -6
- package/dist/delegation-CLcleXHi.mjs.map +0 -1
- package/dist/delegation-DRp6iZid.cjs.map +0 -1
- package/dist/index-CA4Opp4r.d.mts.map +0 -1
- package/dist/index-S77ZvGc-.d.mts.map +0 -1
- package/dist/paths-DajceJig.mjs.map +0 -1
- package/dist/paths-P-XvOUuH.cjs.map +0 -1
- package/dist/taskStore-BAi54FKL.mjs.map +0 -1
- package/dist/taskStore-C4vcUOzA.cjs.map +0 -1
|
@@ -21,8 +21,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
21
|
}) : target, mod));
|
|
22
22
|
//#endregion
|
|
23
23
|
let node_child_process = require("node:child_process");
|
|
24
|
-
let
|
|
25
|
-
|
|
24
|
+
let node_fs_promises = require("node:fs/promises");
|
|
25
|
+
node_fs_promises = __toESM(node_fs_promises, 1);
|
|
26
26
|
let node_path = require("node:path");
|
|
27
27
|
node_path = __toESM(node_path, 1);
|
|
28
28
|
let _agimon_ai_po_core_childProcess = require("@agimon-ai/po-core/childProcess");
|
|
@@ -105,26 +105,7 @@ async function resolveLegacyStoreDirectoryAsync(cwd = process.cwd()) {
|
|
|
105
105
|
return commonDirectory ? node_path.default.join(commonDirectory, STORE_DIR_NAME) : void 0;
|
|
106
106
|
}
|
|
107
107
|
/** Remove only the validated legacy Git store unless it contains the active override. */
|
|
108
|
-
function removeLegacyStoreDirectory(currentStorePath, cwd = process.cwd()) {
|
|
109
|
-
const result = {
|
|
110
|
-
removed: [],
|
|
111
|
-
errors: []
|
|
112
|
-
};
|
|
113
|
-
const target = resolveLegacyStoreDirectory(cwd);
|
|
114
|
-
if (!target || node_path.default.basename(target) !== STORE_DIR_NAME || isWithin(target, currentStorePath)) return result;
|
|
115
|
-
try {
|
|
116
|
-
if (!node_fs.default.existsSync(target)) return result;
|
|
117
|
-
node_fs.default.rmSync(target, {
|
|
118
|
-
recursive: true,
|
|
119
|
-
force: true
|
|
120
|
-
});
|
|
121
|
-
result.removed.push(target);
|
|
122
|
-
} catch (error) {
|
|
123
|
-
result.errors.push(`Could not remove legacy task store ${target}: ${String(error)}`);
|
|
124
|
-
}
|
|
125
|
-
return result;
|
|
126
|
-
}
|
|
127
|
-
async function removeLegacyStoreDirectoryAsync(currentStorePath, cwd = process.cwd()) {
|
|
108
|
+
async function removeLegacyStoreDirectory(currentStorePath, cwd = process.cwd()) {
|
|
128
109
|
const result = {
|
|
129
110
|
removed: [],
|
|
130
111
|
errors: []
|
|
@@ -132,8 +113,8 @@ async function removeLegacyStoreDirectoryAsync(currentStorePath, cwd = process.c
|
|
|
132
113
|
const target = await resolveLegacyStoreDirectoryAsync(cwd);
|
|
133
114
|
if (!target || node_path.default.basename(target) !== STORE_DIR_NAME || isWithin(target, currentStorePath)) return result;
|
|
134
115
|
try {
|
|
135
|
-
await
|
|
136
|
-
await
|
|
116
|
+
await node_fs_promises.default.access(target);
|
|
117
|
+
await node_fs_promises.default.rm(target, {
|
|
137
118
|
recursive: true,
|
|
138
119
|
force: true
|
|
139
120
|
});
|
|
@@ -144,7 +125,7 @@ async function removeLegacyStoreDirectoryAsync(currentStorePath, cwd = process.c
|
|
|
144
125
|
return result;
|
|
145
126
|
}
|
|
146
127
|
/** Delete expired sibling session stores while preserving active or unreadable stores. */
|
|
147
|
-
function sweepStoreFiles(currentStorePath, ttlMs, now = Date.now()) {
|
|
128
|
+
async function sweepStoreFiles(currentStorePath, ttlMs, now = Date.now()) {
|
|
148
129
|
const result = {
|
|
149
130
|
removed: [],
|
|
150
131
|
errors: []
|
|
@@ -153,41 +134,7 @@ function sweepStoreFiles(currentStorePath, ttlMs, now = Date.now()) {
|
|
|
153
134
|
const storeDirectory = node_path.default.dirname(currentSessionDirectory);
|
|
154
135
|
let entries;
|
|
155
136
|
try {
|
|
156
|
-
entries =
|
|
157
|
-
} catch (error) {
|
|
158
|
-
if (error.code === NOT_FOUND_ERROR_CODE) return result;
|
|
159
|
-
result.errors.push(`Could not read task store directory ${storeDirectory}: ${String(error)}`);
|
|
160
|
-
return result;
|
|
161
|
-
}
|
|
162
|
-
for (const entry of entries) {
|
|
163
|
-
const sessionDirectory = node_path.default.join(storeDirectory, entry);
|
|
164
|
-
const candidate = node_path.default.join(sessionDirectory, STORE_FILE_NAME);
|
|
165
|
-
if (sessionDirectory === currentSessionDirectory || !node_fs.default.existsSync(candidate)) continue;
|
|
166
|
-
try {
|
|
167
|
-
if (node_fs.default.existsSync(lockPathFor(candidate))) continue;
|
|
168
|
-
JSON.parse(node_fs.default.readFileSync(candidate, FILE_ENCODING));
|
|
169
|
-
if (now - node_fs.default.statSync(candidate).mtimeMs <= ttlMs) continue;
|
|
170
|
-
node_fs.default.rmSync(sessionDirectory, {
|
|
171
|
-
recursive: true,
|
|
172
|
-
force: true
|
|
173
|
-
});
|
|
174
|
-
result.removed.push(sessionDirectory);
|
|
175
|
-
} catch (error) {
|
|
176
|
-
result.errors.push(`Could not sweep task store ${candidate}: ${String(error)}`);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
return result;
|
|
180
|
-
}
|
|
181
|
-
async function sweepStoreFilesAsync(currentStorePath, ttlMs, now = Date.now()) {
|
|
182
|
-
const result = {
|
|
183
|
-
removed: [],
|
|
184
|
-
errors: []
|
|
185
|
-
};
|
|
186
|
-
const currentSessionDirectory = node_path.default.dirname(currentStorePath);
|
|
187
|
-
const storeDirectory = node_path.default.dirname(currentSessionDirectory);
|
|
188
|
-
let entries;
|
|
189
|
-
try {
|
|
190
|
-
entries = await node_fs.default.promises.readdir(storeDirectory);
|
|
137
|
+
entries = await node_fs_promises.default.readdir(storeDirectory);
|
|
191
138
|
} catch (error) {
|
|
192
139
|
if (error.code === NOT_FOUND_ERROR_CODE) return result;
|
|
193
140
|
result.errors.push(`Could not read task store directory ${storeDirectory}: ${String(error)}`);
|
|
@@ -198,16 +145,15 @@ async function sweepStoreFilesAsync(currentStorePath, ttlMs, now = Date.now()) {
|
|
|
198
145
|
const candidate = node_path.default.join(sessionDirectory, STORE_FILE_NAME);
|
|
199
146
|
if (sessionDirectory === currentSessionDirectory) continue;
|
|
200
147
|
try {
|
|
201
|
-
await node_fs.default.promises.access(candidate);
|
|
202
148
|
try {
|
|
203
|
-
await
|
|
149
|
+
await node_fs_promises.default.access(lockPathFor(candidate));
|
|
204
150
|
continue;
|
|
205
151
|
} catch (error) {
|
|
206
152
|
if (error.code !== NOT_FOUND_ERROR_CODE) throw error;
|
|
207
153
|
}
|
|
208
|
-
JSON.parse(await
|
|
209
|
-
if (now - (await
|
|
210
|
-
await
|
|
154
|
+
JSON.parse(await node_fs_promises.default.readFile(candidate, FILE_ENCODING));
|
|
155
|
+
if (now - (await node_fs_promises.default.stat(candidate)).mtimeMs <= ttlMs) continue;
|
|
156
|
+
await node_fs_promises.default.rm(sessionDirectory, {
|
|
211
157
|
recursive: true,
|
|
212
158
|
force: true
|
|
213
159
|
});
|
|
@@ -256,12 +202,6 @@ Object.defineProperty(exports, "removeLegacyStoreDirectory", {
|
|
|
256
202
|
return removeLegacyStoreDirectory;
|
|
257
203
|
}
|
|
258
204
|
});
|
|
259
|
-
Object.defineProperty(exports, "removeLegacyStoreDirectoryAsync", {
|
|
260
|
-
enumerable: true,
|
|
261
|
-
get: function() {
|
|
262
|
-
return removeLegacyStoreDirectoryAsync;
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
205
|
Object.defineProperty(exports, "resolveLegacyStoreDirectory", {
|
|
266
206
|
enumerable: true,
|
|
267
207
|
get: function() {
|
|
@@ -292,12 +232,6 @@ Object.defineProperty(exports, "sweepStoreFiles", {
|
|
|
292
232
|
return sweepStoreFiles;
|
|
293
233
|
}
|
|
294
234
|
});
|
|
295
|
-
Object.defineProperty(exports, "sweepStoreFilesAsync", {
|
|
296
|
-
enumerable: true,
|
|
297
|
-
get: function() {
|
|
298
|
-
return sweepStoreFilesAsync;
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
235
|
Object.defineProperty(exports, "tempPathFor", {
|
|
302
236
|
enumerable: true,
|
|
303
237
|
get: function() {
|
|
@@ -305,4 +239,4 @@ Object.defineProperty(exports, "tempPathFor", {
|
|
|
305
239
|
}
|
|
306
240
|
});
|
|
307
241
|
|
|
308
|
-
//# sourceMappingURL=paths-
|
|
242
|
+
//# sourceMappingURL=paths-CWVDY8Yd.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths-CWVDY8Yd.cjs","names":["execFileSync","path","SUBAGENT_CHILD_ENV","SUBAGENT_PARENT_SESSION_ENV","piAgentDirectory","fs"],"sources":["../src/services/paths/index.ts"],"sourcesContent":["import { execFile, execFileSync } from 'node:child_process';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { SUBAGENT_CHILD_ENV, SUBAGENT_PARENT_SESSION_ENV } from '@agimon-ai/po-core/childProcess';\nimport { piAgentDirectory } from '@agimon-ai/po-core/piSettings';\n\nexport const STORE_PATH_ENV = 'PO_TASK_STORE';\n\nconst STORE_DIR_NAME = 'po-task';\nconst STORE_FILE_NAME = 'tasks.json';\nconst FILE_ENCODING = 'utf8';\nconst NOT_FOUND_ERROR_CODE = 'ENOENT';\n\nfunction git(args: string[], cwd: string): string | undefined {\n try {\n const output = execFileSync('git', args, {\n cwd,\n encoding: FILE_ENCODING,\n stdio: ['ignore', 'pipe', 'ignore'],\n });\n const trimmed = output.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n } catch {\n return undefined;\n }\n}\n\nasync function gitAsync(args: string[], cwd: string): Promise<string | undefined> {\n return new Promise((resolve) => {\n execFile('git', args, { cwd, encoding: FILE_ENCODING }, (error, stdout) => {\n if (error) {\n resolve(undefined);\n return;\n }\n const trimmed = stdout.trim();\n resolve(trimmed.length > 0 ? trimmed : undefined);\n });\n });\n}\n\nfunction isWithin(root: string, candidate: string): boolean {\n const relative = path.relative(path.resolve(root), path.resolve(candidate));\n return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));\n}\n\n/** Resolve the tree root without relying on extension startup order. */\nexport function resolveSessionKey(\n rootSessionId: string,\n env: Readonly<Record<string, string | undefined>> = process.env,\n): string {\n if (!env[SUBAGENT_CHILD_ENV]) return rootSessionId;\n const parentSessionId = env[SUBAGENT_PARENT_SESSION_ENV]?.trim();\n if (!parentSessionId) throw new Error(`${SUBAGENT_PARENT_SESSION_ENV} is required in a subagent child`);\n return parentSessionId;\n}\n\n/** Resolve one root session tree to a task document under the Pi agent directory. */\nexport function resolveStorePath(\n _cwd: string = process.cwd(),\n env: Readonly<Record<string, string | undefined>> = process.env,\n sessionKey: string = 'standalone',\n): string {\n const override = env[STORE_PATH_ENV]?.trim();\n if (override) return path.resolve(override);\n\n const trimmedSessionKey = sessionKey.trim();\n if (!trimmedSessionKey) throw new Error('po-task session id cannot be blank');\n return path.join(piAgentDirectory(env), STORE_DIR_NAME, trimmedSessionKey, STORE_FILE_NAME);\n}\n\n/** Whether a deliberate unscoped task-store override is active. */\nexport function hasStorePathOverride(env: Readonly<Record<string, string | undefined>> = process.env): boolean {\n return Boolean(env[STORE_PATH_ENV]?.trim());\n}\n\n/** Exact legacy Git-directory store, if the current working tree has one. */\nexport function resolveLegacyStoreDirectory(cwd: string = process.cwd()): string | undefined {\n const commonDirectory = git(['rev-parse', '--path-format=absolute', '--git-common-dir'], cwd);\n return commonDirectory ? path.join(commonDirectory, STORE_DIR_NAME) : undefined;\n}\n\nexport async function resolveLegacyStoreDirectoryAsync(cwd: string = process.cwd()): Promise<string | undefined> {\n const commonDirectory = await gitAsync(['rev-parse', '--path-format=absolute', '--git-common-dir'], cwd);\n return commonDirectory ? path.join(commonDirectory, STORE_DIR_NAME) : undefined;\n}\n\nexport interface StoreSweepResult {\n removed: string[];\n errors: string[];\n}\n\n/** Remove only the validated legacy Git store unless it contains the active override. */\nexport async function removeLegacyStoreDirectory(\n currentStorePath: string,\n cwd: string = process.cwd(),\n): Promise<StoreSweepResult> {\n const result: StoreSweepResult = { removed: [], errors: [] };\n const target = await resolveLegacyStoreDirectoryAsync(cwd);\n if (!target || path.basename(target) !== STORE_DIR_NAME || isWithin(target, currentStorePath)) return result;\n\n try {\n await fs.access(target);\n await fs.rm(target, { recursive: true, force: true });\n result.removed.push(target);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== NOT_FOUND_ERROR_CODE) {\n result.errors.push(`Could not remove legacy task store ${target}: ${String(error)}`);\n }\n }\n return result;\n}\n\n/** Delete expired sibling session stores while preserving active or unreadable stores. */\nexport async function sweepStoreFiles(\n currentStorePath: string,\n ttlMs: number,\n now: number = Date.now(),\n): Promise<StoreSweepResult> {\n const result: StoreSweepResult = { removed: [], errors: [] };\n const currentSessionDirectory = path.dirname(currentStorePath);\n const storeDirectory = path.dirname(currentSessionDirectory);\n let entries: string[];\n try {\n entries = await fs.readdir(storeDirectory);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === NOT_FOUND_ERROR_CODE) return result;\n result.errors.push(`Could not read task store directory ${storeDirectory}: ${String(error)}`);\n return result;\n }\n\n for (const entry of entries) {\n const sessionDirectory = path.join(storeDirectory, entry);\n const candidate = path.join(sessionDirectory, STORE_FILE_NAME);\n if (sessionDirectory === currentSessionDirectory) continue;\n try {\n try {\n await fs.access(lockPathFor(candidate));\n continue;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== NOT_FOUND_ERROR_CODE) throw error;\n }\n JSON.parse(await fs.readFile(candidate, FILE_ENCODING));\n if (now - (await fs.stat(candidate)).mtimeMs <= ttlMs) continue;\n await fs.rm(sessionDirectory, { recursive: true, force: true });\n result.removed.push(sessionDirectory);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === NOT_FOUND_ERROR_CODE) continue;\n result.errors.push(`Could not sweep task store ${candidate}: ${String(error)}`);\n }\n }\n return result;\n}\n\nexport function lockPathFor(storePath: string): string {\n return `${storePath}.lock`;\n}\n\nexport function tempPathFor(storePath: string, pid: number = process.pid): string {\n return `${storePath}.tmp.${pid}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAa,iBAAiB;AAE9B,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;AACxB,MAAM,gBAAgB;AACtB,MAAM,uBAAuB;AAE7B,SAAS,IAAI,MAAgB,KAAiC;CAC5D,IAAI;EAMF,MAAM,WAAA,GALSA,mBAAAA,aAAAA,CAAa,OAAO,MAAM;GACvC;GACA,UAAU;GACV,OAAO;IAAC;IAAU;IAAQ;GAAQ;EACpC,CACqB,CAAC,CAAC,KAAK;EAC5B,OAAO,QAAQ,SAAS,IAAI,UAAU,KAAA;CACxC,QAAQ;EACN;CACF;AACF;AAEA,eAAe,SAAS,MAAgB,KAA0C;CAChF,OAAO,IAAI,SAAS,YAAY;EAC9B,CAAA,GAAA,mBAAA,SAAA,CAAS,OAAO,MAAM;GAAE;GAAK,UAAU;EAAc,IAAI,OAAO,WAAW;GACzE,IAAI,OAAO;IACT,QAAQ,KAAA,CAAS;IACjB;GACF;GACA,MAAM,UAAU,OAAO,KAAK;GAC5B,QAAQ,QAAQ,SAAS,IAAI,UAAU,KAAA,CAAS;EAClD,CAAC;CACH,CAAC;AACH;AAEA,SAAS,SAAS,MAAc,WAA4B;CAC1D,MAAM,WAAWC,UAAAA,QAAK,SAASA,UAAAA,QAAK,QAAQ,IAAI,GAAGA,UAAAA,QAAK,QAAQ,SAAS,CAAC;CAC1E,OAAO,aAAa,MAAO,CAAC,SAAS,WAAW,IAAI,KAAK,CAACA,UAAAA,QAAK,WAAW,QAAQ;AACpF;;AAGA,SAAgB,kBACd,eACA,MAAoD,QAAQ,KACpD;CACR,IAAI,CAAC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AAO;GACvD,MAAMA,iBAAAA,QAAG,GAAG,kBAAkB;IAAE,WAAW;IAAM,OAAO;GAAK,CAAC;GAC9D,OAAO,QAAQ,KAAK,gBAAgB;EACtC,SAAS,OAAO;GACd,IAAK,MAAgC,SAAS,sBAAsB;GACpE,OAAO,OAAO,KAAK,8BAA8B,UAAU,IAAI,OAAO,KAAK,GAAG;EAChF;CACF;CACA,OAAO;AACT;AAEA,SAAgB,YAAY,WAA2B;CACrD,OAAO,GAAG,UAAU;AACtB;AAEA,SAAgB,YAAY,WAAmB,MAAc,QAAQ,KAAa;CAChF,OAAO,GAAG,UAAU,OAAO;AAC7B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { execFile, execFileSync } from "node:child_process";
|
|
2
|
-
import fs from "node:fs";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { SUBAGENT_CHILD_ENV, SUBAGENT_PARENT_SESSION_ENV } from "@agimon-ai/po-core/childProcess";
|
|
5
5
|
import { piAgentDirectory } from "@agimon-ai/po-core/piSettings";
|
|
@@ -81,26 +81,7 @@ async function resolveLegacyStoreDirectoryAsync(cwd = process.cwd()) {
|
|
|
81
81
|
return commonDirectory ? path.join(commonDirectory, STORE_DIR_NAME) : void 0;
|
|
82
82
|
}
|
|
83
83
|
/** Remove only the validated legacy Git store unless it contains the active override. */
|
|
84
|
-
function removeLegacyStoreDirectory(currentStorePath, cwd = process.cwd()) {
|
|
85
|
-
const result = {
|
|
86
|
-
removed: [],
|
|
87
|
-
errors: []
|
|
88
|
-
};
|
|
89
|
-
const target = resolveLegacyStoreDirectory(cwd);
|
|
90
|
-
if (!target || path.basename(target) !== STORE_DIR_NAME || isWithin(target, currentStorePath)) return result;
|
|
91
|
-
try {
|
|
92
|
-
if (!fs.existsSync(target)) return result;
|
|
93
|
-
fs.rmSync(target, {
|
|
94
|
-
recursive: true,
|
|
95
|
-
force: true
|
|
96
|
-
});
|
|
97
|
-
result.removed.push(target);
|
|
98
|
-
} catch (error) {
|
|
99
|
-
result.errors.push(`Could not remove legacy task store ${target}: ${String(error)}`);
|
|
100
|
-
}
|
|
101
|
-
return result;
|
|
102
|
-
}
|
|
103
|
-
async function removeLegacyStoreDirectoryAsync(currentStorePath, cwd = process.cwd()) {
|
|
84
|
+
async function removeLegacyStoreDirectory(currentStorePath, cwd = process.cwd()) {
|
|
104
85
|
const result = {
|
|
105
86
|
removed: [],
|
|
106
87
|
errors: []
|
|
@@ -108,8 +89,8 @@ async function removeLegacyStoreDirectoryAsync(currentStorePath, cwd = process.c
|
|
|
108
89
|
const target = await resolveLegacyStoreDirectoryAsync(cwd);
|
|
109
90
|
if (!target || path.basename(target) !== STORE_DIR_NAME || isWithin(target, currentStorePath)) return result;
|
|
110
91
|
try {
|
|
111
|
-
await fs.
|
|
112
|
-
await fs.
|
|
92
|
+
await fs.access(target);
|
|
93
|
+
await fs.rm(target, {
|
|
113
94
|
recursive: true,
|
|
114
95
|
force: true
|
|
115
96
|
});
|
|
@@ -120,41 +101,7 @@ async function removeLegacyStoreDirectoryAsync(currentStorePath, cwd = process.c
|
|
|
120
101
|
return result;
|
|
121
102
|
}
|
|
122
103
|
/** Delete expired sibling session stores while preserving active or unreadable stores. */
|
|
123
|
-
function sweepStoreFiles(currentStorePath, ttlMs, now = Date.now()) {
|
|
124
|
-
const result = {
|
|
125
|
-
removed: [],
|
|
126
|
-
errors: []
|
|
127
|
-
};
|
|
128
|
-
const currentSessionDirectory = path.dirname(currentStorePath);
|
|
129
|
-
const storeDirectory = path.dirname(currentSessionDirectory);
|
|
130
|
-
let entries;
|
|
131
|
-
try {
|
|
132
|
-
entries = fs.readdirSync(storeDirectory);
|
|
133
|
-
} catch (error) {
|
|
134
|
-
if (error.code === NOT_FOUND_ERROR_CODE) return result;
|
|
135
|
-
result.errors.push(`Could not read task store directory ${storeDirectory}: ${String(error)}`);
|
|
136
|
-
return result;
|
|
137
|
-
}
|
|
138
|
-
for (const entry of entries) {
|
|
139
|
-
const sessionDirectory = path.join(storeDirectory, entry);
|
|
140
|
-
const candidate = path.join(sessionDirectory, STORE_FILE_NAME);
|
|
141
|
-
if (sessionDirectory === currentSessionDirectory || !fs.existsSync(candidate)) continue;
|
|
142
|
-
try {
|
|
143
|
-
if (fs.existsSync(lockPathFor(candidate))) continue;
|
|
144
|
-
JSON.parse(fs.readFileSync(candidate, FILE_ENCODING));
|
|
145
|
-
if (now - fs.statSync(candidate).mtimeMs <= ttlMs) continue;
|
|
146
|
-
fs.rmSync(sessionDirectory, {
|
|
147
|
-
recursive: true,
|
|
148
|
-
force: true
|
|
149
|
-
});
|
|
150
|
-
result.removed.push(sessionDirectory);
|
|
151
|
-
} catch (error) {
|
|
152
|
-
result.errors.push(`Could not sweep task store ${candidate}: ${String(error)}`);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return result;
|
|
156
|
-
}
|
|
157
|
-
async function sweepStoreFilesAsync(currentStorePath, ttlMs, now = Date.now()) {
|
|
104
|
+
async function sweepStoreFiles(currentStorePath, ttlMs, now = Date.now()) {
|
|
158
105
|
const result = {
|
|
159
106
|
removed: [],
|
|
160
107
|
errors: []
|
|
@@ -163,7 +110,7 @@ async function sweepStoreFilesAsync(currentStorePath, ttlMs, now = Date.now()) {
|
|
|
163
110
|
const storeDirectory = path.dirname(currentSessionDirectory);
|
|
164
111
|
let entries;
|
|
165
112
|
try {
|
|
166
|
-
entries = await fs.
|
|
113
|
+
entries = await fs.readdir(storeDirectory);
|
|
167
114
|
} catch (error) {
|
|
168
115
|
if (error.code === NOT_FOUND_ERROR_CODE) return result;
|
|
169
116
|
result.errors.push(`Could not read task store directory ${storeDirectory}: ${String(error)}`);
|
|
@@ -174,16 +121,15 @@ async function sweepStoreFilesAsync(currentStorePath, ttlMs, now = Date.now()) {
|
|
|
174
121
|
const candidate = path.join(sessionDirectory, STORE_FILE_NAME);
|
|
175
122
|
if (sessionDirectory === currentSessionDirectory) continue;
|
|
176
123
|
try {
|
|
177
|
-
await fs.promises.access(candidate);
|
|
178
124
|
try {
|
|
179
|
-
await fs.
|
|
125
|
+
await fs.access(lockPathFor(candidate));
|
|
180
126
|
continue;
|
|
181
127
|
} catch (error) {
|
|
182
128
|
if (error.code !== NOT_FOUND_ERROR_CODE) throw error;
|
|
183
129
|
}
|
|
184
|
-
JSON.parse(await fs.
|
|
185
|
-
if (now - (await fs.
|
|
186
|
-
await fs.
|
|
130
|
+
JSON.parse(await fs.readFile(candidate, FILE_ENCODING));
|
|
131
|
+
if (now - (await fs.stat(candidate)).mtimeMs <= ttlMs) continue;
|
|
132
|
+
await fs.rm(sessionDirectory, {
|
|
187
133
|
recursive: true,
|
|
188
134
|
force: true
|
|
189
135
|
});
|
|
@@ -202,6 +148,6 @@ function tempPathFor(storePath, pid = process.pid) {
|
|
|
202
148
|
return `${storePath}.tmp.${pid}`;
|
|
203
149
|
}
|
|
204
150
|
//#endregion
|
|
205
|
-
export {
|
|
151
|
+
export { resolveLegacyStoreDirectory as a, resolveStorePath as c, removeLegacyStoreDirectory as i, sweepStoreFiles as l, hasStorePathOverride as n, resolveLegacyStoreDirectoryAsync as o, lockPathFor as r, resolveSessionKey as s, STORE_PATH_ENV as t, tempPathFor as u };
|
|
206
152
|
|
|
207
|
-
//# sourceMappingURL=paths-
|
|
153
|
+
//# sourceMappingURL=paths-CjATVpi8.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths-CjATVpi8.mjs","names":[],"sources":["../src/services/paths/index.ts"],"sourcesContent":["import { execFile, execFileSync } from 'node:child_process';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { SUBAGENT_CHILD_ENV, SUBAGENT_PARENT_SESSION_ENV } from '@agimon-ai/po-core/childProcess';\nimport { piAgentDirectory } from '@agimon-ai/po-core/piSettings';\n\nexport const STORE_PATH_ENV = 'PO_TASK_STORE';\n\nconst STORE_DIR_NAME = 'po-task';\nconst STORE_FILE_NAME = 'tasks.json';\nconst FILE_ENCODING = 'utf8';\nconst NOT_FOUND_ERROR_CODE = 'ENOENT';\n\nfunction git(args: string[], cwd: string): string | undefined {\n try {\n const output = execFileSync('git', args, {\n cwd,\n encoding: FILE_ENCODING,\n stdio: ['ignore', 'pipe', 'ignore'],\n });\n const trimmed = output.trim();\n return trimmed.length > 0 ? trimmed : undefined;\n } catch {\n return undefined;\n }\n}\n\nasync function gitAsync(args: string[], cwd: string): Promise<string | undefined> {\n return new Promise((resolve) => {\n execFile('git', args, { cwd, encoding: FILE_ENCODING }, (error, stdout) => {\n if (error) {\n resolve(undefined);\n return;\n }\n const trimmed = stdout.trim();\n resolve(trimmed.length > 0 ? trimmed : undefined);\n });\n });\n}\n\nfunction isWithin(root: string, candidate: string): boolean {\n const relative = path.relative(path.resolve(root), path.resolve(candidate));\n return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));\n}\n\n/** Resolve the tree root without relying on extension startup order. */\nexport function resolveSessionKey(\n rootSessionId: string,\n env: Readonly<Record<string, string | undefined>> = process.env,\n): string {\n if (!env[SUBAGENT_CHILD_ENV]) return rootSessionId;\n const parentSessionId = env[SUBAGENT_PARENT_SESSION_ENV]?.trim();\n if (!parentSessionId) throw new Error(`${SUBAGENT_PARENT_SESSION_ENV} is required in a subagent child`);\n return parentSessionId;\n}\n\n/** Resolve one root session tree to a task document under the Pi agent directory. */\nexport function resolveStorePath(\n _cwd: string = process.cwd(),\n env: Readonly<Record<string, string | undefined>> = process.env,\n sessionKey: string = 'standalone',\n): string {\n const override = env[STORE_PATH_ENV]?.trim();\n if (override) return path.resolve(override);\n\n const trimmedSessionKey = sessionKey.trim();\n if (!trimmedSessionKey) throw new Error('po-task session id cannot be blank');\n return path.join(piAgentDirectory(env), STORE_DIR_NAME, trimmedSessionKey, STORE_FILE_NAME);\n}\n\n/** Whether a deliberate unscoped task-store override is active. */\nexport function hasStorePathOverride(env: Readonly<Record<string, string | undefined>> = process.env): boolean {\n return Boolean(env[STORE_PATH_ENV]?.trim());\n}\n\n/** Exact legacy Git-directory store, if the current working tree has one. */\nexport function resolveLegacyStoreDirectory(cwd: string = process.cwd()): string | undefined {\n const commonDirectory = git(['rev-parse', '--path-format=absolute', '--git-common-dir'], cwd);\n return commonDirectory ? path.join(commonDirectory, STORE_DIR_NAME) : undefined;\n}\n\nexport async function resolveLegacyStoreDirectoryAsync(cwd: string = process.cwd()): Promise<string | undefined> {\n const commonDirectory = await gitAsync(['rev-parse', '--path-format=absolute', '--git-common-dir'], cwd);\n return commonDirectory ? path.join(commonDirectory, STORE_DIR_NAME) : undefined;\n}\n\nexport interface StoreSweepResult {\n removed: string[];\n errors: string[];\n}\n\n/** Remove only the validated legacy Git store unless it contains the active override. */\nexport async function removeLegacyStoreDirectory(\n currentStorePath: string,\n cwd: string = process.cwd(),\n): Promise<StoreSweepResult> {\n const result: StoreSweepResult = { removed: [], errors: [] };\n const target = await resolveLegacyStoreDirectoryAsync(cwd);\n if (!target || path.basename(target) !== STORE_DIR_NAME || isWithin(target, currentStorePath)) return result;\n\n try {\n await fs.access(target);\n await fs.rm(target, { recursive: true, force: true });\n result.removed.push(target);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== NOT_FOUND_ERROR_CODE) {\n result.errors.push(`Could not remove legacy task store ${target}: ${String(error)}`);\n }\n }\n return result;\n}\n\n/** Delete expired sibling session stores while preserving active or unreadable stores. */\nexport async function sweepStoreFiles(\n currentStorePath: string,\n ttlMs: number,\n now: number = Date.now(),\n): Promise<StoreSweepResult> {\n const result: StoreSweepResult = { removed: [], errors: [] };\n const currentSessionDirectory = path.dirname(currentStorePath);\n const storeDirectory = path.dirname(currentSessionDirectory);\n let entries: string[];\n try {\n entries = await fs.readdir(storeDirectory);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === NOT_FOUND_ERROR_CODE) return result;\n result.errors.push(`Could not read task store directory ${storeDirectory}: ${String(error)}`);\n return result;\n }\n\n for (const entry of entries) {\n const sessionDirectory = path.join(storeDirectory, entry);\n const candidate = path.join(sessionDirectory, STORE_FILE_NAME);\n if (sessionDirectory === currentSessionDirectory) continue;\n try {\n try {\n await fs.access(lockPathFor(candidate));\n continue;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== NOT_FOUND_ERROR_CODE) throw error;\n }\n JSON.parse(await fs.readFile(candidate, FILE_ENCODING));\n if (now - (await fs.stat(candidate)).mtimeMs <= ttlMs) continue;\n await fs.rm(sessionDirectory, { recursive: true, force: true });\n result.removed.push(sessionDirectory);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === NOT_FOUND_ERROR_CODE) continue;\n result.errors.push(`Could not sweep task store ${candidate}: ${String(error)}`);\n }\n }\n return result;\n}\n\nexport function lockPathFor(storePath: string): string {\n return `${storePath}.lock`;\n}\n\nexport function tempPathFor(storePath: string, pid: number = process.pid): string {\n return `${storePath}.tmp.${pid}`;\n}\n"],"mappings":";;;;;;AAOA,MAAa,iBAAiB;AAE9B,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;AACxB,MAAM,gBAAgB;AACtB,MAAM,uBAAuB;AAE7B,SAAS,IAAI,MAAgB,KAAiC;CAC5D,IAAI;EAMF,MAAM,UALS,aAAa,OAAO,MAAM;GACvC;GACA,UAAU;GACV,OAAO;IAAC;IAAU;IAAQ;GAAQ;EACpC,CACqB,CAAC,CAAC,KAAK;EAC5B,OAAO,QAAQ,SAAS,IAAI,UAAU,KAAA;CACxC,QAAQ;EACN;CACF;AACF;AAEA,eAAe,SAAS,MAAgB,KAA0C;CAChF,OAAO,IAAI,SAAS,YAAY;EAC9B,SAAS,OAAO,MAAM;GAAE;GAAK,UAAU;EAAc,IAAI,OAAO,WAAW;GACzE,IAAI,OAAO;IACT,QAAQ,KAAA,CAAS;IACjB;GACF;GACA,MAAM,UAAU,OAAO,KAAK;GAC5B,QAAQ,QAAQ,SAAS,IAAI,UAAU,KAAA,CAAS;EAClD,CAAC;CACH,CAAC;AACH;AAEA,SAAS,SAAS,MAAc,WAA4B;CAC1D,MAAM,WA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,SAAS,EAAA,CAAG,WAAW,OAAO;GACvD,MAAM,GAAG,GAAG,kBAAkB;IAAE,WAAW;IAAM,OAAO;GAAK,CAAC;GAC9D,OAAO,QAAQ,KAAK,gBAAgB;EACtC,SAAS,OAAO;GACd,IAAK,MAAgC,SAAS,sBAAsB;GACpE,OAAO,OAAO,KAAK,8BAA8B,UAAU,IAAI,OAAO,KAAK,GAAG;EAChF;CACF;CACA,OAAO;AACT;AAEA,SAAgB,YAAY,WAA2B;CACrD,OAAO,GAAG,UAAU;AACtB;AAEA,SAAgB,YAAY,WAAmB,MAAc,QAAQ,KAAa;CAChF,OAAO,GAAG,UAAU,OAAO;AAC7B"}
|
package/dist/storePaths.cjs
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_paths = require("./paths-
|
|
2
|
+
const require_paths = require("./paths-CWVDY8Yd.cjs");
|
|
3
3
|
exports.STORE_PATH_ENV = require_paths.STORE_PATH_ENV;
|
|
4
4
|
exports.hasStorePathOverride = require_paths.hasStorePathOverride;
|
|
5
5
|
exports.lockPathFor = require_paths.lockPathFor;
|
|
6
6
|
exports.removeLegacyStoreDirectory = require_paths.removeLegacyStoreDirectory;
|
|
7
|
-
exports.removeLegacyStoreDirectoryAsync = require_paths.removeLegacyStoreDirectoryAsync;
|
|
8
7
|
exports.resolveLegacyStoreDirectory = require_paths.resolveLegacyStoreDirectory;
|
|
9
8
|
exports.resolveLegacyStoreDirectoryAsync = require_paths.resolveLegacyStoreDirectoryAsync;
|
|
10
9
|
exports.resolveSessionKey = require_paths.resolveSessionKey;
|
|
11
10
|
exports.resolveStorePath = require_paths.resolveStorePath;
|
|
12
11
|
exports.sweepStoreFiles = require_paths.sweepStoreFiles;
|
|
13
|
-
exports.sweepStoreFilesAsync = require_paths.sweepStoreFilesAsync;
|
|
14
12
|
exports.tempPathFor = require_paths.tempPathFor;
|
package/dist/storePaths.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as removeLegacyStoreDirectory, c as
|
|
2
|
-
export { STORE_PATH_ENV, StoreSweepResult, hasStorePathOverride, lockPathFor, removeLegacyStoreDirectory,
|
|
1
|
+
import { a as removeLegacyStoreDirectory, c as resolveSessionKey, d as tempPathFor, i as lockPathFor, l as resolveStorePath, n as StoreSweepResult, o as resolveLegacyStoreDirectory, r as hasStorePathOverride, s as resolveLegacyStoreDirectoryAsync, t as STORE_PATH_ENV, u as sweepStoreFiles } from "./index-tAu1TIyi.mjs";
|
|
2
|
+
export { STORE_PATH_ENV, StoreSweepResult, hasStorePathOverride, lockPathFor, removeLegacyStoreDirectory, resolveLegacyStoreDirectory, resolveLegacyStoreDirectoryAsync, resolveSessionKey, resolveStorePath, sweepStoreFiles, tempPathFor };
|
package/dist/storePaths.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as STORE_PATH_ENV, n as hasStorePathOverride, r as lockPathFor, i as removeLegacyStoreDirectory, a as
|
|
1
|
+
export { t as STORE_PATH_ENV, n as hasStorePathOverride, r as lockPathFor, i as removeLegacyStoreDirectory, a as resolveLegacyStoreDirectory, o as resolveLegacyStoreDirectoryAsync, s as resolveSessionKey, c as resolveStorePath, l as sweepStoreFiles, u as tempPathFor } from "./paths-CjATVpi8.mjs";
|
package/dist/storeTaskStore.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as TaskStoreOptions, t as TaskStore } from "./index-
|
|
1
|
+
import { n as TaskStoreOptions, t as TaskStore } from "./index-DuT-Lbxy.mjs";
|
|
2
2
|
export { TaskStore, TaskStoreOptions };
|
package/dist/storeTaskStore.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as TaskStore } from "./taskStore-
|
|
1
|
+
export { t as TaskStore } from "./taskStore-wuXXFCZT.mjs";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const require_paths = require("./paths-
|
|
1
|
+
const require_paths = require("./paths-CWVDY8Yd.cjs");
|
|
2
2
|
const require_telemetry = require("./telemetry-x3JxCA5K.cjs");
|
|
3
3
|
const require_task = require("./task-CXF9VULl.cjs");
|
|
4
4
|
const require_processLiveness = require("./processLiveness-umpNgsPR.cjs");
|
|
5
5
|
const require_invariants = require("./invariants-DhjEjBPU.cjs");
|
|
6
|
-
let
|
|
7
|
-
|
|
6
|
+
let node_fs_promises = require("node:fs/promises");
|
|
7
|
+
node_fs_promises = require_paths.__toESM(node_fs_promises, 1);
|
|
8
8
|
let node_path = require("node:path");
|
|
9
9
|
node_path = require_paths.__toESM(node_path, 1);
|
|
10
10
|
//#region src/services/taskStore/index.ts
|
|
@@ -71,16 +71,6 @@ var TaskStore = class {
|
|
|
71
71
|
get snapshot() {
|
|
72
72
|
return this.cached;
|
|
73
73
|
}
|
|
74
|
-
read() {
|
|
75
|
-
try {
|
|
76
|
-
const raw = node_fs.default.readFileSync(this.storePath, UTF8_ENCODING);
|
|
77
|
-
this.cached = normalizeDocument(JSON.parse(raw));
|
|
78
|
-
} catch (error) {
|
|
79
|
-
if (error.code !== MISSING_FILE_CODE) this.report?.error(require_telemetry.TASK_EVENT.storeReadFailed, error, { [STORE_PATH_ATTRIBUTE]: this.storePath });
|
|
80
|
-
this.cached = require_task.emptyDocument();
|
|
81
|
-
}
|
|
82
|
-
return this.cached;
|
|
83
|
-
}
|
|
84
74
|
async readAsync(shouldApply = () => true, onReadError) {
|
|
85
75
|
const storePath = this.storePath;
|
|
86
76
|
const document = await this.readDocumentAsync(storePath, onReadError);
|
|
@@ -90,7 +80,7 @@ var TaskStore = class {
|
|
|
90
80
|
}
|
|
91
81
|
async readDocumentAsync(storePath = this.storePath, onReadError) {
|
|
92
82
|
try {
|
|
93
|
-
const raw = await
|
|
83
|
+
const raw = await node_fs_promises.default.readFile(storePath, UTF8_ENCODING);
|
|
94
84
|
return normalizeDocument(JSON.parse(raw));
|
|
95
85
|
} catch (error) {
|
|
96
86
|
if (error.code !== MISSING_FILE_CODE) {
|
|
@@ -111,15 +101,16 @@ var TaskStore = class {
|
|
|
111
101
|
*/
|
|
112
102
|
async mutate(mutate) {
|
|
113
103
|
const release = await this.acquireLock();
|
|
114
|
-
const outcome = (() => {
|
|
104
|
+
const outcome = await (async () => {
|
|
115
105
|
try {
|
|
116
|
-
const current = this.
|
|
106
|
+
const current = await this.readDocumentAsync();
|
|
107
|
+
this.cached = current;
|
|
117
108
|
const mutation = mutate(current);
|
|
118
109
|
if (!mutation.document) return { result: {
|
|
119
110
|
document: current,
|
|
120
111
|
value: mutation.value
|
|
121
112
|
} };
|
|
122
|
-
const committed = this.write(mutation.document);
|
|
113
|
+
const committed = await this.write(mutation.document);
|
|
123
114
|
return {
|
|
124
115
|
result: {
|
|
125
116
|
document: committed,
|
|
@@ -128,7 +119,7 @@ var TaskStore = class {
|
|
|
128
119
|
notification: committed
|
|
129
120
|
};
|
|
130
121
|
} finally {
|
|
131
|
-
release();
|
|
122
|
+
await release();
|
|
132
123
|
}
|
|
133
124
|
})();
|
|
134
125
|
if (outcome.notification) this.notifyCommitted(outcome.notification);
|
|
@@ -141,49 +132,52 @@ var TaskStore = class {
|
|
|
141
132
|
this.report?.error(require_telemetry.TASK_EVENT.storeListenerFailed, error, { [STORE_PATH_ATTRIBUTE]: this.storePath });
|
|
142
133
|
}
|
|
143
134
|
}
|
|
144
|
-
write(document) {
|
|
135
|
+
async write(document) {
|
|
145
136
|
const next = {
|
|
146
137
|
...document,
|
|
147
138
|
version: 1,
|
|
148
139
|
rev: document.rev + 1
|
|
149
140
|
};
|
|
150
|
-
|
|
141
|
+
await node_fs_promises.default.mkdir(node_path.default.dirname(this.storePath), { recursive: true });
|
|
151
142
|
const temp = require_paths.tempPathFor(this.storePath);
|
|
152
|
-
|
|
153
|
-
|
|
143
|
+
await node_fs_promises.default.writeFile(temp, `${JSON.stringify(next, void 0, 2)}\n`, UTF8_ENCODING);
|
|
144
|
+
await node_fs_promises.default.rename(temp, this.storePath);
|
|
154
145
|
this.cached = next;
|
|
155
146
|
return next;
|
|
156
147
|
}
|
|
157
148
|
async acquireLock() {
|
|
158
149
|
const lockPath = require_paths.lockPathFor(this.storePath);
|
|
159
|
-
|
|
150
|
+
await node_fs_promises.default.mkdir(node_path.default.dirname(this.storePath), { recursive: true });
|
|
160
151
|
const deadline = Date.now() + this.lockTimeoutMs;
|
|
161
152
|
for (;;) try {
|
|
162
|
-
const handle =
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
153
|
+
const handle = await node_fs_promises.default.open(lockPath, "wx");
|
|
154
|
+
try {
|
|
155
|
+
await handle.writeFile(JSON.stringify({
|
|
156
|
+
pid: process.pid,
|
|
157
|
+
time: Date.now()
|
|
158
|
+
}));
|
|
159
|
+
} finally {
|
|
160
|
+
await handle.close();
|
|
161
|
+
}
|
|
162
|
+
return () => node_fs_promises.default.rm(lockPath, { force: true });
|
|
169
163
|
} catch (error) {
|
|
170
164
|
if (error.code !== LOCK_EXISTS_CODE) throw error;
|
|
171
165
|
if (Date.now() >= deadline) {
|
|
172
166
|
this.report?.warn(require_telemetry.TASK_EVENT.storeLockTimeout, /* @__PURE__ */ new Error(`Task store lock still held after ${this.lockTimeoutMs}ms; proceeding without it`), { [STORE_PATH_ATTRIBUTE]: this.storePath });
|
|
173
|
-
return () => {};
|
|
167
|
+
return async () => {};
|
|
174
168
|
}
|
|
175
|
-
this.breakStaleLock(lockPath);
|
|
169
|
+
await this.breakStaleLock(lockPath);
|
|
176
170
|
await sleep(LOCK_RETRY_BASE_MS + Math.random() * LOCK_RETRY_MAX_MS);
|
|
177
171
|
}
|
|
178
172
|
}
|
|
179
173
|
/** Remove a lock left behind by a dead process or one held implausibly long. */
|
|
180
|
-
breakStaleLock(lockPath) {
|
|
174
|
+
async breakStaleLock(lockPath) {
|
|
181
175
|
try {
|
|
182
|
-
const holder = JSON.parse(
|
|
176
|
+
const holder = JSON.parse(await node_fs_promises.default.readFile(lockPath, UTF8_ENCODING));
|
|
183
177
|
const expired = typeof holder.time === "number" && Date.now() - holder.time > LOCK_STALE_MS;
|
|
184
178
|
const dead = typeof holder.pid === "number" && !require_processLiveness.isProcessAlive(holder.pid);
|
|
185
179
|
if (!expired && !dead) return false;
|
|
186
|
-
|
|
180
|
+
await node_fs_promises.default.unlink(lockPath);
|
|
187
181
|
return true;
|
|
188
182
|
} catch (error) {
|
|
189
183
|
if (error.code !== MISSING_FILE_CODE) this.report?.warn(require_telemetry.TASK_EVENT.storeLockBreakFailed, error, { [STORE_PATH_ATTRIBUTE]: lockPath });
|
|
@@ -212,4 +206,4 @@ Object.defineProperty(exports, "TaskStore", {
|
|
|
212
206
|
}
|
|
213
207
|
});
|
|
214
208
|
|
|
215
|
-
//# sourceMappingURL=taskStore-
|
|
209
|
+
//# sourceMappingURL=taskStore-B-BbY2Ci.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taskStore-B-BbY2Ci.cjs","names":["emptyDocument","canonicalizeTasks","resolveStorePath","asyncFs","TASK_EVENT","path","tempPathFor","lockPathFor","isProcessAlive"],"sources":["../src/services/taskStore/index.ts"],"sourcesContent":["import asyncFs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport { emptyDocument, STORE_SCHEMA_VERSION, type Task, type TaskDocument } from '../../models/task';\nimport { TASK_EVENT, type TaskFailureReporter } from '../../types/telemetry';\nimport { canonicalizeTasks } from '../invariants';\nimport { lockPathFor, resolveStorePath, STORE_PATH_ENV, tempPathFor } from '../paths';\nimport { isProcessAlive } from '../processLiveness';\n\nconst LOCK_TIMEOUT_MS = 2000;\nconst LOCK_STALE_MS = 10_000;\nconst LOCK_RETRY_BASE_MS = 10;\nconst LOCK_RETRY_MAX_MS = 60;\nconst UTF8_ENCODING = 'utf8';\nconst MISSING_FILE_CODE = 'ENOENT';\nconst LOCK_EXISTS_CODE = 'EEXIST';\nconst STORE_PATH_ATTRIBUTE = 'store.path';\n\nexport interface TaskStoreOptions {\n cwd?: string;\n env?: Readonly<Record<string, string | undefined>>;\n storePath?: string;\n /** How long to wait for the advisory lock before proceeding lock-free. */\n lockTimeoutMs?: number;\n /** Where swallowed failures go, so silent degradation stays visible. */\n report?: TaskFailureReporter;\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Coerce arbitrary parsed JSON into a valid document.\n *\n * A corrupt or truncated store must not take the session down: the worst\n * acceptable outcome is starting from an empty list, never a crash on startup.\n */\nfunction normalizeDocument(parsed: unknown): TaskDocument {\n if (!parsed || typeof parsed !== 'object') return emptyDocument();\n const candidate = parsed as Partial<TaskDocument>;\n if (!Array.isArray(candidate.tasks)) return emptyDocument();\n\n const tasks = canonicalizeTasks(\n candidate.tasks.filter(\n (task): task is Task => Boolean(task) && typeof task === 'object' && typeof (task as Task).id === 'number',\n ),\n );\n const maxId = tasks.reduce((max, task) => Math.max(max, task.id), 0);\n return {\n version: typeof candidate.version === 'number' ? candidate.version : STORE_SCHEMA_VERSION,\n rev: typeof candidate.rev === 'number' ? candidate.rev : 0,\n nextId: typeof candidate.nextId === 'number' && candidate.nextId > maxId ? candidate.nextId : maxId + 1,\n tasks,\n };\n}\n\n/**\n * File-backed task store shared by one root session and its delegated children.\n *\n * Durability model: the JSON file is the source of truth. Mutations are\n * read-modify-write under an advisory lock so concurrent delegated processes\n * cannot clobber each other, and writes land via temp-file rename so a\n * crash mid-write can never leave a partial document behind.\n */\nexport class TaskStore {\n storePath: string;\n\n private readonly cwd: string;\n private readonly env: Readonly<Record<string, string | undefined>>;\n private cached: TaskDocument = emptyDocument();\n private readonly listeners = new Set<(document: TaskDocument) => void>();\n private readonly lockTimeoutMs: number;\n private readonly report?: TaskFailureReporter;\n\n constructor(options: TaskStoreOptions = {}) {\n this.cwd = options.cwd ?? process.cwd();\n this.env = options.env ?? process.env;\n this.storePath = options.storePath ?? resolveStorePath(this.cwd, this.env);\n this.lockTimeoutMs = options.lockTimeoutMs ?? LOCK_TIMEOUT_MS;\n this.report = options.report;\n }\n\n /** Bind a default store to the current session tree before reading it. */\n configureSession(sessionKey: string): void {\n if (this.env[STORE_PATH_ENV]?.trim()) return;\n this.storePath = resolveStorePath(this.cwd, this.env, sessionKey);\n this.cached = emptyDocument();\n }\n\n /** Last document read from disk, without hitting the filesystem. */\n get snapshot(): TaskDocument {\n return this.cached;\n }\n\n async readAsync(\n shouldApply: () => boolean = () => true,\n onReadError?: (error: unknown) => void,\n ): Promise<TaskDocument> {\n const storePath = this.storePath;\n const document = await this.readDocumentAsync(storePath, onReadError);\n if (!shouldApply()) return document;\n this.cached = document;\n return document;\n }\n\n private async readDocumentAsync(\n storePath: string = this.storePath,\n onReadError?: (error: unknown) => void,\n ): Promise<TaskDocument> {\n try {\n const raw = await asyncFs.readFile(storePath, UTF8_ENCODING);\n return normalizeDocument(JSON.parse(raw));\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== MISSING_FILE_CODE) {\n this.report?.error(TASK_EVENT.storeReadFailed, error, { [STORE_PATH_ATTRIBUTE]: storePath });\n try {\n onReadError?.(error);\n } catch {\n // Diagnostic failures must not change fail-open reads.\n }\n }\n return emptyDocument();\n }\n }\n\n /**\n * Apply a mutation under the store lock.\n *\n * `mutate` receives the freshest on-disk document and returns either the next\n * document to commit or `undefined` for a read-only action (list/get), which\n * skips the write entirely so queries never bump `rev`.\n */\n async mutate<T>(\n mutate: (document: TaskDocument) => { document?: TaskDocument; value: T },\n ): Promise<{ document: TaskDocument; value: T }> {\n const release = await this.acquireLock();\n const outcome = await (async () => {\n try {\n const current = await this.readDocumentAsync();\n this.cached = current;\n const mutation = mutate(current);\n if (!mutation.document) {\n return { result: { document: current, value: mutation.value } };\n }\n const committed = await this.write(mutation.document);\n return {\n result: { document: committed, value: mutation.value },\n notification: committed,\n };\n } finally {\n await release();\n }\n })();\n if (outcome.notification) {\n this.notifyCommitted(outcome.notification);\n }\n return outcome.result;\n }\n\n private notifyCommitted(committed: TaskDocument): void {\n for (const listener of this.listeners) {\n try {\n listener(committed);\n } catch (error) {\n this.report?.error(TASK_EVENT.storeListenerFailed, error, { [STORE_PATH_ATTRIBUTE]: this.storePath });\n }\n }\n }\n\n private async write(document: TaskDocument): Promise<TaskDocument> {\n const next: TaskDocument = { ...document, version: STORE_SCHEMA_VERSION, rev: document.rev + 1 };\n await asyncFs.mkdir(path.dirname(this.storePath), { recursive: true });\n const temp = tempPathFor(this.storePath);\n await asyncFs.writeFile(temp, `${JSON.stringify(next, undefined, 2)}\\n`, UTF8_ENCODING);\n await asyncFs.rename(temp, this.storePath);\n this.cached = next;\n return next;\n }\n\n private async acquireLock(): Promise<() => Promise<void>> {\n const lockPath = lockPathFor(this.storePath);\n await asyncFs.mkdir(path.dirname(this.storePath), { recursive: true });\n const deadline = Date.now() + this.lockTimeoutMs;\n\n for (;;) {\n try {\n const handle = await asyncFs.open(lockPath, 'wx');\n try {\n await handle.writeFile(JSON.stringify({ pid: process.pid, time: Date.now() }));\n } finally {\n await handle.close();\n }\n return () => asyncFs.rm(lockPath, { force: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== LOCK_EXISTS_CODE) throw error;\n // The deadline is checked before breaking a stale lock so a peer that\n // keeps recreating one cannot spin this loop without bound.\n if (Date.now() >= deadline) {\n // Proceeding lock-free beats stalling the agent: the rename is atomic,\n // so the worst case is a lost concurrent update, not a corrupt file.\n // Reported because a lost update here can strand a delegation.\n this.report?.warn(\n TASK_EVENT.storeLockTimeout,\n new Error(`Task store lock still held after ${this.lockTimeoutMs}ms; proceeding without it`),\n { [STORE_PATH_ATTRIBUTE]: this.storePath },\n );\n return async () => {};\n }\n // Clearing a dead holder's lock still goes through the backoff. Yielding\n // on every iteration is what stops a peer that keeps recreating the\n // lock from turning this into a spin.\n await this.breakStaleLock(lockPath);\n await sleep(LOCK_RETRY_BASE_MS + Math.random() * LOCK_RETRY_MAX_MS);\n }\n }\n }\n\n /** Remove a lock left behind by a dead process or one held implausibly long. */\n private async breakStaleLock(lockPath: string): Promise<boolean> {\n try {\n const holder = JSON.parse(await asyncFs.readFile(lockPath, UTF8_ENCODING)) as { pid?: number; time?: number };\n const expired = typeof holder.time === 'number' && Date.now() - holder.time > LOCK_STALE_MS;\n const dead = typeof holder.pid === 'number' && !isProcessAlive(holder.pid);\n if (!expired && !dead) return false;\n await asyncFs.unlink(lockPath);\n return true;\n } catch (error) {\n // Losing the race to another breaker is normal; a persistent failure here\n // shows up as the lock timeout above, so this stays a warning.\n if ((error as NodeJS.ErrnoException).code !== MISSING_FILE_CODE) {\n this.report?.warn(TASK_EVENT.storeLockBreakFailed, error, { [STORE_PATH_ATTRIBUTE]: lockPath });\n }\n return false;\n }\n }\n\n /**\n * Listen for commits made through this store instance.\n *\n * Live cross-process updates use the owning session's direct event bus. This\n * listener publishes local commits to that bus and never watches the filesystem.\n */\n onExternalChange(listener: (document: TaskDocument) => void): () => void {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n }\n\n dispose(): void {\n this.listeners.clear();\n }\n}\n"],"mappings":";;;;;;;;;;AASA,MAAM,kBAAkB;AACxB,MAAM,gBAAgB;AACtB,MAAM,qBAAqB;AAC3B,MAAM,oBAAoB;AAC1B,MAAM,gBAAgB;AACtB,MAAM,oBAAoB;AAC1B,MAAM,mBAAmB;AACzB,MAAM,uBAAuB;AAY7B,SAAS,MAAM,IAA2B;CACxC,OAAO,IAAI,SAAS,YAAY,WAAW,SAAS,EAAE,CAAC;AACzD;;;;;;;AAQA,SAAS,kBAAkB,QAA+B;CACxD,IAAI,CAAC,UAAU,OAAO,WAAW,UAAU,OAAOA,aAAAA,cAAc;CAChE,MAAM,YAAY;CAClB,IAAI,CAAC,MAAM,QAAQ,UAAU,KAAK,GAAG,OAAOA,aAAAA,cAAc;CAE1D,MAAM,QAAQC,mBAAAA,kBACZ,UAAU,MAAM,QACb,SAAuB,QAAQ,IAAI,KAAK,OAAO,SAAS,YAAY,OAAQ,KAAc,OAAO,QACpG,CACF;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