@agimon-ai/po-task 0.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +131 -0
- package/dist/apiContracts.cjs +54 -0
- package/dist/apiContracts.cjs.map +1 -0
- package/dist/apiContracts.d.mts +53 -0
- package/dist/apiContracts.d.mts.map +1 -0
- package/dist/apiContracts.mjs +49 -0
- package/dist/apiContracts.mjs.map +1 -0
- package/dist/config-CFSs3iku.mjs +72 -0
- package/dist/config-CFSs3iku.mjs.map +1 -0
- package/dist/config-CdX-Bv8q.cjs +173 -0
- package/dist/config-CdX-Bv8q.cjs.map +1 -0
- package/dist/config.cjs +19 -0
- package/dist/config.d.mts +2 -0
- package/dist/config.mjs +2 -0
- package/dist/delegation-BiOy3_7g.mjs +7 -0
- package/dist/delegation-BiOy3_7g.mjs.map +1 -0
- package/dist/delegation-CdMqOZB4.mjs +626 -0
- package/dist/delegation-CdMqOZB4.mjs.map +1 -0
- package/dist/delegation-DsnKjMbJ.cjs +661 -0
- package/dist/delegation-DsnKjMbJ.cjs.map +1 -0
- package/dist/delegation-LDpHP2CC.cjs +12 -0
- package/dist/delegation-LDpHP2CC.cjs.map +1 -0
- package/dist/delegationManager.cjs +10 -0
- package/dist/delegationManager.d.mts +2 -0
- package/dist/delegationManager.mjs +3 -0
- package/dist/extensions/mcp-ui.mjs +23 -0
- package/dist/extensions/mcp-ui.mjs.map +1 -0
- package/dist/extensions/mcp.cjs +1144 -0
- package/dist/extensions/mcp.cjs.map +1 -0
- package/dist/extensions/mcp.d.mts +5 -0
- package/dist/extensions/mcp.d.mts.map +1 -0
- package/dist/extensions/mcp.mjs +1115 -0
- package/dist/extensions/mcp.mjs.map +1 -0
- package/dist/extensions/native.mjs +1175 -0
- package/dist/extensions/native.mjs.map +1 -0
- package/dist/extensions/server.cjs +569 -0
- package/dist/extensions/server.cjs.map +1 -0
- package/dist/extensions/server.d.mts +5 -0
- package/dist/extensions/server.d.mts.map +1 -0
- package/dist/extensions/server.mjs +563 -0
- package/dist/extensions/server.mjs.map +1 -0
- package/dist/extensions/web.mjs +1018 -0
- package/dist/extensions/web.mjs.map +1 -0
- package/dist/index-B-3sCF2S.d.mts +43 -0
- package/dist/index-B-3sCF2S.d.mts.map +1 -0
- package/dist/index-B1JPJdpZ.d.mts +51 -0
- package/dist/index-B1JPJdpZ.d.mts.map +1 -0
- package/dist/index-CUWCvh-E.d.mts +72 -0
- package/dist/index-CUWCvh-E.d.mts.map +1 -0
- package/dist/index-DlmXKyhQ.d.mts +34 -0
- package/dist/index-DlmXKyhQ.d.mts.map +1 -0
- package/dist/index-Dvb8X_qB.d.mts +67 -0
- package/dist/index-Dvb8X_qB.d.mts.map +1 -0
- package/dist/index-XY9VPmfm.d.mts +26 -0
- package/dist/index-XY9VPmfm.d.mts.map +1 -0
- package/dist/index-teIf67qQ.d.mts +196 -0
- package/dist/index-teIf67qQ.d.mts.map +1 -0
- package/dist/index.cjs +93 -0
- package/dist/index.d.mts +11 -0
- package/dist/index.mjs +12 -0
- package/dist/invariants-DhjEjBPU.cjs +79 -0
- package/dist/invariants-DhjEjBPU.cjs.map +1 -0
- package/dist/invariants-q_UamF7D.mjs +62 -0
- package/dist/invariants-q_UamF7D.mjs.map +1 -0
- package/dist/logSinkTelemetry-B23qGiP-.cjs +52 -0
- package/dist/logSinkTelemetry-B23qGiP-.cjs.map +1 -0
- package/dist/logSinkTelemetry-BMBsC54p.mjs +41 -0
- package/dist/logSinkTelemetry-BMBsC54p.mjs.map +1 -0
- package/dist/logSinkTelemetry.cjs +6 -0
- package/dist/logSinkTelemetry.d.mts +23 -0
- package/dist/logSinkTelemetry.d.mts.map +1 -0
- package/dist/logSinkTelemetry.mjs +3 -0
- package/dist/paths-CSya2l9_.cjs +308 -0
- package/dist/paths-CSya2l9_.cjs.map +1 -0
- package/dist/paths-Cah1vFGv.mjs +207 -0
- package/dist/paths-Cah1vFGv.mjs.map +1 -0
- package/dist/processLiveness-Ccd9wenT.mjs +20 -0
- package/dist/processLiveness-Ccd9wenT.mjs.map +1 -0
- package/dist/processLiveness-umpNgsPR.cjs +25 -0
- package/dist/processLiveness-umpNgsPR.cjs.map +1 -0
- package/dist/reconcile-BcD-hTbd.mjs +63 -0
- package/dist/reconcile-BcD-hTbd.mjs.map +1 -0
- package/dist/reconcile-cRL0NjDr.cjs +80 -0
- package/dist/reconcile-cRL0NjDr.cjs.map +1 -0
- package/dist/reducer-BEfJFM5L.mjs +345 -0
- package/dist/reducer-BEfJFM5L.mjs.map +1 -0
- package/dist/reducer-BV0YIZ2o.cjs +380 -0
- package/dist/reducer-BV0YIZ2o.cjs.map +1 -0
- package/dist/storeInvariants.cjs +5 -0
- package/dist/storeInvariants.d.mts +23 -0
- package/dist/storeInvariants.d.mts.map +1 -0
- package/dist/storeInvariants.mjs +2 -0
- package/dist/storePaths.cjs +14 -0
- package/dist/storePaths.d.mts +2 -0
- package/dist/storePaths.mjs +2 -0
- package/dist/storeProcessLiveness.cjs +3 -0
- package/dist/storeProcessLiveness.d.mts +11 -0
- package/dist/storeProcessLiveness.d.mts.map +1 -0
- package/dist/storeProcessLiveness.mjs +2 -0
- package/dist/storeReconcile.cjs +5 -0
- package/dist/storeReconcile.d.mts +2 -0
- package/dist/storeReconcile.mjs +2 -0
- package/dist/storeReducer.cjs +8 -0
- package/dist/storeReducer.d.mts +2 -0
- package/dist/storeReducer.mjs +2 -0
- package/dist/storeTaskGraph.cjs +7 -0
- package/dist/storeTaskGraph.d.mts +2 -0
- package/dist/storeTaskGraph.mjs +2 -0
- package/dist/storeTaskStore.cjs +3 -0
- package/dist/storeTaskStore.d.mts +2 -0
- package/dist/storeTaskStore.mjs +2 -0
- package/dist/storeTypes.cjs +6 -0
- package/dist/storeTypes.d.mts +2 -0
- package/dist/storeTypes.mjs +2 -0
- package/dist/task-CXF9VULl.cjs +49 -0
- package/dist/task-CXF9VULl.cjs.map +1 -0
- package/dist/task-DJpTteeJ.d.mts +187 -0
- package/dist/task-DJpTteeJ.d.mts.map +1 -0
- package/dist/task-DO0TwZ0z.mjs +132 -0
- package/dist/task-DO0TwZ0z.mjs.map +1 -0
- package/dist/task-Dhta7JyA.d.mts +126 -0
- package/dist/task-Dhta7JyA.d.mts.map +1 -0
- package/dist/task-UvW877Ez.cjs +227 -0
- package/dist/task-UvW877Ez.cjs.map +1 -0
- package/dist/task-giCbpKzV.mjs +26 -0
- package/dist/task-giCbpKzV.mjs.map +1 -0
- package/dist/taskGraph-BOQvT0-M.mjs +63 -0
- package/dist/taskGraph-BOQvT0-M.mjs.map +1 -0
- package/dist/taskGraph-BskRslrr.cjs +92 -0
- package/dist/taskGraph-BskRslrr.cjs.map +1 -0
- package/dist/taskGraph-D0zFHF2p.d.mts +25 -0
- package/dist/taskGraph-D0zFHF2p.d.mts.map +1 -0
- package/dist/taskResult-D2G7b4w-.cjs +224 -0
- package/dist/taskResult-D2G7b4w-.cjs.map +1 -0
- package/dist/taskResult-edBAAKSH.mjs +165 -0
- package/dist/taskResult-edBAAKSH.mjs.map +1 -0
- package/dist/taskStore-DjU60rMm.cjs +215 -0
- package/dist/taskStore-DjU60rMm.cjs.map +1 -0
- package/dist/taskStore-pAJ971Ml.mjs +208 -0
- package/dist/taskStore-pAJ971Ml.mjs.map +1 -0
- package/dist/telemetry-Ca0I3Tqo.cjs +30 -0
- package/dist/telemetry-Ca0I3Tqo.cjs.map +1 -0
- package/dist/telemetry-DyS44zAD.mjs +25 -0
- package/dist/telemetry-DyS44zAD.mjs.map +1 -0
- package/dist/telemetry-FMGRovb4.d.mts +35 -0
- package/dist/telemetry-FMGRovb4.d.mts.map +1 -0
- package/dist/toolPromptGuidelines.cjs +27 -0
- package/dist/toolPromptGuidelines.cjs.map +1 -0
- package/dist/toolPromptGuidelines.d.mts +13 -0
- package/dist/toolPromptGuidelines.d.mts.map +1 -0
- package/dist/toolPromptGuidelines.mjs +26 -0
- package/dist/toolPromptGuidelines.mjs.map +1 -0
- package/dist/toolResponseEnvelope.cjs +12 -0
- package/dist/toolResponseEnvelope.d.mts +2 -0
- package/dist/toolResponseEnvelope.mjs +2 -0
- package/dist/toolSchema.cjs +18 -0
- package/dist/toolSchema.d.mts +2 -0
- package/dist/toolSchema.mjs +2 -0
- package/package.json +223 -0
- package/src/types/webTasks.ts +24 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
//#endregion
|
|
23
|
+
let node_child_process = require("node:child_process");
|
|
24
|
+
let node_fs = require("node:fs");
|
|
25
|
+
node_fs = __toESM(node_fs, 1);
|
|
26
|
+
let node_path = require("node:path");
|
|
27
|
+
node_path = __toESM(node_path, 1);
|
|
28
|
+
let _agimon_ai_po_core_childProcess = require("@agimon-ai/po-core/childProcess");
|
|
29
|
+
let _agimon_ai_po_core_piSettings = require("@agimon-ai/po-core/piSettings");
|
|
30
|
+
//#region src/services/paths/index.ts
|
|
31
|
+
const STORE_PATH_ENV = "DOOM_TASK_STORE";
|
|
32
|
+
const STORE_DIR_NAME = "doom-task";
|
|
33
|
+
const STORE_FILE_NAME = "tasks.json";
|
|
34
|
+
const FILE_ENCODING = "utf8";
|
|
35
|
+
const NOT_FOUND_ERROR_CODE = "ENOENT";
|
|
36
|
+
function git(args, cwd) {
|
|
37
|
+
try {
|
|
38
|
+
const trimmed = (0, node_child_process.execFileSync)("git", args, {
|
|
39
|
+
cwd,
|
|
40
|
+
encoding: FILE_ENCODING,
|
|
41
|
+
stdio: [
|
|
42
|
+
"ignore",
|
|
43
|
+
"pipe",
|
|
44
|
+
"ignore"
|
|
45
|
+
]
|
|
46
|
+
}).trim();
|
|
47
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
48
|
+
} catch {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async function gitAsync(args, cwd) {
|
|
53
|
+
return new Promise((resolve) => {
|
|
54
|
+
(0, node_child_process.execFile)("git", args, {
|
|
55
|
+
cwd,
|
|
56
|
+
encoding: FILE_ENCODING
|
|
57
|
+
}, (error, stdout) => {
|
|
58
|
+
if (error) {
|
|
59
|
+
resolve(void 0);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const trimmed = stdout.trim();
|
|
63
|
+
resolve(trimmed.length > 0 ? trimmed : void 0);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function isWithin(root, candidate) {
|
|
68
|
+
const relative = node_path.default.relative(node_path.default.resolve(root), node_path.default.resolve(candidate));
|
|
69
|
+
return relative === "" || !relative.startsWith("..") && !node_path.default.isAbsolute(relative);
|
|
70
|
+
}
|
|
71
|
+
/** Resolve the tree root without relying on extension startup order. */
|
|
72
|
+
function resolveSessionKey(rootSessionId, env = process.env) {
|
|
73
|
+
if (!env[_agimon_ai_po_core_childProcess.SUBAGENT_CHILD_ENV]) return rootSessionId;
|
|
74
|
+
const parentSessionId = env[_agimon_ai_po_core_childProcess.SUBAGENT_PARENT_SESSION_ENV]?.trim();
|
|
75
|
+
if (!parentSessionId) throw new Error(`${_agimon_ai_po_core_childProcess.SUBAGENT_PARENT_SESSION_ENV} is required in a subagent child`);
|
|
76
|
+
return parentSessionId;
|
|
77
|
+
}
|
|
78
|
+
/** Resolve one root session tree to a task document under the Pi agent directory. */
|
|
79
|
+
function resolveStorePath(_cwd = process.cwd(), env = process.env, sessionKey = "standalone") {
|
|
80
|
+
const override = env[STORE_PATH_ENV]?.trim();
|
|
81
|
+
if (override) return node_path.default.resolve(override);
|
|
82
|
+
const trimmedSessionKey = sessionKey.trim();
|
|
83
|
+
if (!trimmedSessionKey) throw new Error("doom-task session id cannot be blank");
|
|
84
|
+
return node_path.default.join((0, _agimon_ai_po_core_piSettings.piAgentDirectory)(env), STORE_DIR_NAME, trimmedSessionKey, STORE_FILE_NAME);
|
|
85
|
+
}
|
|
86
|
+
/** Whether a deliberate unscoped task-store override is active. */
|
|
87
|
+
function hasStorePathOverride(env = process.env) {
|
|
88
|
+
return Boolean(env[STORE_PATH_ENV]?.trim());
|
|
89
|
+
}
|
|
90
|
+
/** Exact legacy Git-directory store, if the current working tree has one. */
|
|
91
|
+
function resolveLegacyStoreDirectory(cwd = process.cwd()) {
|
|
92
|
+
const commonDirectory = git([
|
|
93
|
+
"rev-parse",
|
|
94
|
+
"--path-format=absolute",
|
|
95
|
+
"--git-common-dir"
|
|
96
|
+
], cwd);
|
|
97
|
+
return commonDirectory ? node_path.default.join(commonDirectory, STORE_DIR_NAME) : void 0;
|
|
98
|
+
}
|
|
99
|
+
async function resolveLegacyStoreDirectoryAsync(cwd = process.cwd()) {
|
|
100
|
+
const commonDirectory = await gitAsync([
|
|
101
|
+
"rev-parse",
|
|
102
|
+
"--path-format=absolute",
|
|
103
|
+
"--git-common-dir"
|
|
104
|
+
], cwd);
|
|
105
|
+
return commonDirectory ? node_path.default.join(commonDirectory, STORE_DIR_NAME) : void 0;
|
|
106
|
+
}
|
|
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()) {
|
|
128
|
+
const result = {
|
|
129
|
+
removed: [],
|
|
130
|
+
errors: []
|
|
131
|
+
};
|
|
132
|
+
const target = await resolveLegacyStoreDirectoryAsync(cwd);
|
|
133
|
+
if (!target || node_path.default.basename(target) !== STORE_DIR_NAME || isWithin(target, currentStorePath)) return result;
|
|
134
|
+
try {
|
|
135
|
+
await node_fs.default.promises.access(target);
|
|
136
|
+
await node_fs.default.promises.rm(target, {
|
|
137
|
+
recursive: true,
|
|
138
|
+
force: true
|
|
139
|
+
});
|
|
140
|
+
result.removed.push(target);
|
|
141
|
+
} catch (error) {
|
|
142
|
+
if (error.code !== NOT_FOUND_ERROR_CODE) result.errors.push(`Could not remove legacy task store ${target}: ${String(error)}`);
|
|
143
|
+
}
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
/** Delete expired sibling session stores while preserving active or unreadable stores. */
|
|
147
|
+
function sweepStoreFiles(currentStorePath, ttlMs, now = Date.now()) {
|
|
148
|
+
const result = {
|
|
149
|
+
removed: [],
|
|
150
|
+
errors: []
|
|
151
|
+
};
|
|
152
|
+
const currentSessionDirectory = node_path.default.dirname(currentStorePath);
|
|
153
|
+
const storeDirectory = node_path.default.dirname(currentSessionDirectory);
|
|
154
|
+
let entries;
|
|
155
|
+
try {
|
|
156
|
+
entries = node_fs.default.readdirSync(storeDirectory);
|
|
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);
|
|
191
|
+
} catch (error) {
|
|
192
|
+
if (error.code === NOT_FOUND_ERROR_CODE) return result;
|
|
193
|
+
result.errors.push(`Could not read task store directory ${storeDirectory}: ${String(error)}`);
|
|
194
|
+
return result;
|
|
195
|
+
}
|
|
196
|
+
for (const entry of entries) {
|
|
197
|
+
const sessionDirectory = node_path.default.join(storeDirectory, entry);
|
|
198
|
+
const candidate = node_path.default.join(sessionDirectory, STORE_FILE_NAME);
|
|
199
|
+
if (sessionDirectory === currentSessionDirectory) continue;
|
|
200
|
+
try {
|
|
201
|
+
await node_fs.default.promises.access(candidate);
|
|
202
|
+
try {
|
|
203
|
+
await node_fs.default.promises.access(lockPathFor(candidate));
|
|
204
|
+
continue;
|
|
205
|
+
} catch (error) {
|
|
206
|
+
if (error.code !== NOT_FOUND_ERROR_CODE) throw error;
|
|
207
|
+
}
|
|
208
|
+
JSON.parse(await node_fs.default.promises.readFile(candidate, FILE_ENCODING));
|
|
209
|
+
if (now - (await node_fs.default.promises.stat(candidate)).mtimeMs <= ttlMs) continue;
|
|
210
|
+
await node_fs.default.promises.rm(sessionDirectory, {
|
|
211
|
+
recursive: true,
|
|
212
|
+
force: true
|
|
213
|
+
});
|
|
214
|
+
result.removed.push(sessionDirectory);
|
|
215
|
+
} catch (error) {
|
|
216
|
+
if (error.code === NOT_FOUND_ERROR_CODE) continue;
|
|
217
|
+
result.errors.push(`Could not sweep task store ${candidate}: ${String(error)}`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
222
|
+
function lockPathFor(storePath) {
|
|
223
|
+
return `${storePath}.lock`;
|
|
224
|
+
}
|
|
225
|
+
function tempPathFor(storePath, pid = process.pid) {
|
|
226
|
+
return `${storePath}.tmp.${pid}`;
|
|
227
|
+
}
|
|
228
|
+
//#endregion
|
|
229
|
+
Object.defineProperty(exports, "STORE_PATH_ENV", {
|
|
230
|
+
enumerable: true,
|
|
231
|
+
get: function() {
|
|
232
|
+
return STORE_PATH_ENV;
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
Object.defineProperty(exports, "__toESM", {
|
|
236
|
+
enumerable: true,
|
|
237
|
+
get: function() {
|
|
238
|
+
return __toESM;
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
Object.defineProperty(exports, "hasStorePathOverride", {
|
|
242
|
+
enumerable: true,
|
|
243
|
+
get: function() {
|
|
244
|
+
return hasStorePathOverride;
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
Object.defineProperty(exports, "lockPathFor", {
|
|
248
|
+
enumerable: true,
|
|
249
|
+
get: function() {
|
|
250
|
+
return lockPathFor;
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
Object.defineProperty(exports, "removeLegacyStoreDirectory", {
|
|
254
|
+
enumerable: true,
|
|
255
|
+
get: function() {
|
|
256
|
+
return removeLegacyStoreDirectory;
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
Object.defineProperty(exports, "removeLegacyStoreDirectoryAsync", {
|
|
260
|
+
enumerable: true,
|
|
261
|
+
get: function() {
|
|
262
|
+
return removeLegacyStoreDirectoryAsync;
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
Object.defineProperty(exports, "resolveLegacyStoreDirectory", {
|
|
266
|
+
enumerable: true,
|
|
267
|
+
get: function() {
|
|
268
|
+
return resolveLegacyStoreDirectory;
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
Object.defineProperty(exports, "resolveLegacyStoreDirectoryAsync", {
|
|
272
|
+
enumerable: true,
|
|
273
|
+
get: function() {
|
|
274
|
+
return resolveLegacyStoreDirectoryAsync;
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
Object.defineProperty(exports, "resolveSessionKey", {
|
|
278
|
+
enumerable: true,
|
|
279
|
+
get: function() {
|
|
280
|
+
return resolveSessionKey;
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
Object.defineProperty(exports, "resolveStorePath", {
|
|
284
|
+
enumerable: true,
|
|
285
|
+
get: function() {
|
|
286
|
+
return resolveStorePath;
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
Object.defineProperty(exports, "sweepStoreFiles", {
|
|
290
|
+
enumerable: true,
|
|
291
|
+
get: function() {
|
|
292
|
+
return sweepStoreFiles;
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
Object.defineProperty(exports, "sweepStoreFilesAsync", {
|
|
296
|
+
enumerable: true,
|
|
297
|
+
get: function() {
|
|
298
|
+
return sweepStoreFilesAsync;
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
Object.defineProperty(exports, "tempPathFor", {
|
|
302
|
+
enumerable: true,
|
|
303
|
+
get: function() {
|
|
304
|
+
return tempPathFor;
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
//# sourceMappingURL=paths-CSya2l9_.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths-CSya2l9_.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';\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 = 'DOOM_TASK_STORE';\n\nconst STORE_DIR_NAME = 'doom-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('doom-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 function removeLegacyStoreDirectory(currentStorePath: string, cwd: string = process.cwd()): StoreSweepResult {\n const result: StoreSweepResult = { removed: [], errors: [] };\n const target = resolveLegacyStoreDirectory(cwd);\n if (!target || path.basename(target) !== STORE_DIR_NAME || isWithin(target, currentStorePath)) return result;\n\n try {\n if (!fs.existsSync(target)) return result;\n fs.rmSync(target, { recursive: true, force: true });\n result.removed.push(target);\n } catch (error) {\n result.errors.push(`Could not remove legacy task store ${target}: ${String(error)}`);\n }\n return result;\n}\n\nexport async function removeLegacyStoreDirectoryAsync(\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.promises.access(target);\n await fs.promises.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 function sweepStoreFiles(currentStorePath: string, ttlMs: number, now: number = Date.now()): 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 = fs.readdirSync(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 || !fs.existsSync(candidate)) continue;\n try {\n if (fs.existsSync(lockPathFor(candidate))) continue;\n JSON.parse(fs.readFileSync(candidate, FILE_ENCODING));\n if (now - fs.statSync(candidate).mtimeMs <= ttlMs) continue;\n fs.rmSync(sessionDirectory, { recursive: true, force: true });\n result.removed.push(sessionDirectory);\n } catch (error) {\n result.errors.push(`Could not sweep task store ${candidate}: ${String(error)}`);\n }\n }\n return result;\n}\n\nexport async function sweepStoreFilesAsync(\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.promises.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 await fs.promises.access(candidate);\n try {\n await fs.promises.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.promises.readFile(candidate, FILE_ENCODING));\n if (now - (await fs.promises.stat(candidate)).mtimeMs <= ttlMs) continue;\n await fs.promises.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,SAA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AG;EAC5F,OAAO;CACT;CAEA,KAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,mBAAmBJ,UAAAA,QAAK,KAAK,gBAAgB,KAAK;EACxD,MAAM,YAAYA,UAAAA,QAAK,KAAK,kBAAkB,eAAe;EAC7D,IAAI,qBAAqB,yBAAyB;EAClD,IAAI;GACF,MAAMI,QAAAA,QAAG,SAAS,OAAO,SAAS;GAClC,IAAI;IACF,MAAMA,QAAAA,QAAG,SAAS,OAAO,YAAY,SAAS,CAAC;IAC/C;GACF,SAAS,OAAO;IACd,IAAK,MAAgC,SAAS,sBAAsB,MAAM;GAC5E;GACA,KAAK,MAAM,MAAMA,QAAAA,QAAG,SAAS,SAAS,WAAW,aAAa,CAAC;GAC/D,IAAI,OAAO,MAAMA,QAAAA,QAAG,SAAS,KAAK,SAAS,EAAA,CAAG,WAAW,OAAO;GAChE,MAAMA,QAAAA,QAAG,SAAS,GAAG,kBAAkB;IAAE,WAAW;IAAM,OAAO;GAAK,CAAC;GACvE,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"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { execFile, execFileSync } from "node:child_process";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { SUBAGENT_CHILD_ENV, SUBAGENT_PARENT_SESSION_ENV } from "@agimon-ai/po-core/childProcess";
|
|
5
|
+
import { piAgentDirectory } from "@agimon-ai/po-core/piSettings";
|
|
6
|
+
//#region src/services/paths/index.ts
|
|
7
|
+
const STORE_PATH_ENV = "DOOM_TASK_STORE";
|
|
8
|
+
const STORE_DIR_NAME = "doom-task";
|
|
9
|
+
const STORE_FILE_NAME = "tasks.json";
|
|
10
|
+
const FILE_ENCODING = "utf8";
|
|
11
|
+
const NOT_FOUND_ERROR_CODE = "ENOENT";
|
|
12
|
+
function git(args, cwd) {
|
|
13
|
+
try {
|
|
14
|
+
const trimmed = execFileSync("git", args, {
|
|
15
|
+
cwd,
|
|
16
|
+
encoding: FILE_ENCODING,
|
|
17
|
+
stdio: [
|
|
18
|
+
"ignore",
|
|
19
|
+
"pipe",
|
|
20
|
+
"ignore"
|
|
21
|
+
]
|
|
22
|
+
}).trim();
|
|
23
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
24
|
+
} catch {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async function gitAsync(args, cwd) {
|
|
29
|
+
return new Promise((resolve) => {
|
|
30
|
+
execFile("git", args, {
|
|
31
|
+
cwd,
|
|
32
|
+
encoding: FILE_ENCODING
|
|
33
|
+
}, (error, stdout) => {
|
|
34
|
+
if (error) {
|
|
35
|
+
resolve(void 0);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const trimmed = stdout.trim();
|
|
39
|
+
resolve(trimmed.length > 0 ? trimmed : void 0);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function isWithin(root, candidate) {
|
|
44
|
+
const relative = path.relative(path.resolve(root), path.resolve(candidate));
|
|
45
|
+
return relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
46
|
+
}
|
|
47
|
+
/** Resolve the tree root without relying on extension startup order. */
|
|
48
|
+
function resolveSessionKey(rootSessionId, env = process.env) {
|
|
49
|
+
if (!env[SUBAGENT_CHILD_ENV]) return rootSessionId;
|
|
50
|
+
const parentSessionId = env[SUBAGENT_PARENT_SESSION_ENV]?.trim();
|
|
51
|
+
if (!parentSessionId) throw new Error(`${SUBAGENT_PARENT_SESSION_ENV} is required in a subagent child`);
|
|
52
|
+
return parentSessionId;
|
|
53
|
+
}
|
|
54
|
+
/** Resolve one root session tree to a task document under the Pi agent directory. */
|
|
55
|
+
function resolveStorePath(_cwd = process.cwd(), env = process.env, sessionKey = "standalone") {
|
|
56
|
+
const override = env[STORE_PATH_ENV]?.trim();
|
|
57
|
+
if (override) return path.resolve(override);
|
|
58
|
+
const trimmedSessionKey = sessionKey.trim();
|
|
59
|
+
if (!trimmedSessionKey) throw new Error("doom-task session id cannot be blank");
|
|
60
|
+
return path.join(piAgentDirectory(env), STORE_DIR_NAME, trimmedSessionKey, STORE_FILE_NAME);
|
|
61
|
+
}
|
|
62
|
+
/** Whether a deliberate unscoped task-store override is active. */
|
|
63
|
+
function hasStorePathOverride(env = process.env) {
|
|
64
|
+
return Boolean(env[STORE_PATH_ENV]?.trim());
|
|
65
|
+
}
|
|
66
|
+
/** Exact legacy Git-directory store, if the current working tree has one. */
|
|
67
|
+
function resolveLegacyStoreDirectory(cwd = process.cwd()) {
|
|
68
|
+
const commonDirectory = git([
|
|
69
|
+
"rev-parse",
|
|
70
|
+
"--path-format=absolute",
|
|
71
|
+
"--git-common-dir"
|
|
72
|
+
], cwd);
|
|
73
|
+
return commonDirectory ? path.join(commonDirectory, STORE_DIR_NAME) : void 0;
|
|
74
|
+
}
|
|
75
|
+
async function resolveLegacyStoreDirectoryAsync(cwd = process.cwd()) {
|
|
76
|
+
const commonDirectory = await gitAsync([
|
|
77
|
+
"rev-parse",
|
|
78
|
+
"--path-format=absolute",
|
|
79
|
+
"--git-common-dir"
|
|
80
|
+
], cwd);
|
|
81
|
+
return commonDirectory ? path.join(commonDirectory, STORE_DIR_NAME) : void 0;
|
|
82
|
+
}
|
|
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()) {
|
|
104
|
+
const result = {
|
|
105
|
+
removed: [],
|
|
106
|
+
errors: []
|
|
107
|
+
};
|
|
108
|
+
const target = await resolveLegacyStoreDirectoryAsync(cwd);
|
|
109
|
+
if (!target || path.basename(target) !== STORE_DIR_NAME || isWithin(target, currentStorePath)) return result;
|
|
110
|
+
try {
|
|
111
|
+
await fs.promises.access(target);
|
|
112
|
+
await fs.promises.rm(target, {
|
|
113
|
+
recursive: true,
|
|
114
|
+
force: true
|
|
115
|
+
});
|
|
116
|
+
result.removed.push(target);
|
|
117
|
+
} catch (error) {
|
|
118
|
+
if (error.code !== NOT_FOUND_ERROR_CODE) result.errors.push(`Could not remove legacy task store ${target}: ${String(error)}`);
|
|
119
|
+
}
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
/** 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()) {
|
|
158
|
+
const result = {
|
|
159
|
+
removed: [],
|
|
160
|
+
errors: []
|
|
161
|
+
};
|
|
162
|
+
const currentSessionDirectory = path.dirname(currentStorePath);
|
|
163
|
+
const storeDirectory = path.dirname(currentSessionDirectory);
|
|
164
|
+
let entries;
|
|
165
|
+
try {
|
|
166
|
+
entries = await fs.promises.readdir(storeDirectory);
|
|
167
|
+
} catch (error) {
|
|
168
|
+
if (error.code === NOT_FOUND_ERROR_CODE) return result;
|
|
169
|
+
result.errors.push(`Could not read task store directory ${storeDirectory}: ${String(error)}`);
|
|
170
|
+
return result;
|
|
171
|
+
}
|
|
172
|
+
for (const entry of entries) {
|
|
173
|
+
const sessionDirectory = path.join(storeDirectory, entry);
|
|
174
|
+
const candidate = path.join(sessionDirectory, STORE_FILE_NAME);
|
|
175
|
+
if (sessionDirectory === currentSessionDirectory) continue;
|
|
176
|
+
try {
|
|
177
|
+
await fs.promises.access(candidate);
|
|
178
|
+
try {
|
|
179
|
+
await fs.promises.access(lockPathFor(candidate));
|
|
180
|
+
continue;
|
|
181
|
+
} catch (error) {
|
|
182
|
+
if (error.code !== NOT_FOUND_ERROR_CODE) throw error;
|
|
183
|
+
}
|
|
184
|
+
JSON.parse(await fs.promises.readFile(candidate, FILE_ENCODING));
|
|
185
|
+
if (now - (await fs.promises.stat(candidate)).mtimeMs <= ttlMs) continue;
|
|
186
|
+
await fs.promises.rm(sessionDirectory, {
|
|
187
|
+
recursive: true,
|
|
188
|
+
force: true
|
|
189
|
+
});
|
|
190
|
+
result.removed.push(sessionDirectory);
|
|
191
|
+
} catch (error) {
|
|
192
|
+
if (error.code === NOT_FOUND_ERROR_CODE) continue;
|
|
193
|
+
result.errors.push(`Could not sweep task store ${candidate}: ${String(error)}`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return result;
|
|
197
|
+
}
|
|
198
|
+
function lockPathFor(storePath) {
|
|
199
|
+
return `${storePath}.lock`;
|
|
200
|
+
}
|
|
201
|
+
function tempPathFor(storePath, pid = process.pid) {
|
|
202
|
+
return `${storePath}.tmp.${pid}`;
|
|
203
|
+
}
|
|
204
|
+
//#endregion
|
|
205
|
+
export { removeLegacyStoreDirectoryAsync as a, resolveSessionKey as c, sweepStoreFilesAsync as d, tempPathFor as f, removeLegacyStoreDirectory as i, resolveStorePath as l, hasStorePathOverride as n, resolveLegacyStoreDirectory as o, lockPathFor as r, resolveLegacyStoreDirectoryAsync as s, STORE_PATH_ENV as t, sweepStoreFiles as u };
|
|
206
|
+
|
|
207
|
+
//# sourceMappingURL=paths-Cah1vFGv.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths-Cah1vFGv.mjs","names":[],"sources":["../src/services/paths/index.ts"],"sourcesContent":["import { execFile, execFileSync } from 'node:child_process';\nimport fs from 'node:fs';\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 = 'DOOM_TASK_STORE';\n\nconst STORE_DIR_NAME = 'doom-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('doom-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 function removeLegacyStoreDirectory(currentStorePath: string, cwd: string = process.cwd()): StoreSweepResult {\n const result: StoreSweepResult = { removed: [], errors: [] };\n const target = resolveLegacyStoreDirectory(cwd);\n if (!target || path.basename(target) !== STORE_DIR_NAME || isWithin(target, currentStorePath)) return result;\n\n try {\n if (!fs.existsSync(target)) return result;\n fs.rmSync(target, { recursive: true, force: true });\n result.removed.push(target);\n } catch (error) {\n result.errors.push(`Could not remove legacy task store ${target}: ${String(error)}`);\n }\n return result;\n}\n\nexport async function removeLegacyStoreDirectoryAsync(\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.promises.access(target);\n await fs.promises.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 function sweepStoreFiles(currentStorePath: string, ttlMs: number, now: number = Date.now()): 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 = fs.readdirSync(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 || !fs.existsSync(candidate)) continue;\n try {\n if (fs.existsSync(lockPathFor(candidate))) continue;\n JSON.parse(fs.readFileSync(candidate, FILE_ENCODING));\n if (now - fs.statSync(candidate).mtimeMs <= ttlMs) continue;\n fs.rmSync(sessionDirectory, { recursive: true, force: true });\n result.removed.push(sessionDirectory);\n } catch (error) {\n result.errors.push(`Could not sweep task store ${candidate}: ${String(error)}`);\n }\n }\n return result;\n}\n\nexport async function sweepStoreFilesAsync(\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.promises.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 await fs.promises.access(candidate);\n try {\n await fs.promises.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.promises.readFile(candidate, FILE_ENCODING));\n if (now - (await fs.promises.stat(candidate)).mtimeMs <= ttlMs) continue;\n await fs.promises.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,UA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5F,OAAO;CACT;CAEA,KAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,mBAAmB,KAAK,KAAK,gBAAgB,KAAK;EACxD,MAAM,YAAY,KAAK,KAAK,kBAAkB,eAAe;EAC7D,IAAI,qBAAqB,yBAAyB;EAClD,IAAI;GACF,MAAM,GAAG,SAAS,OAAO,SAAS;GAClC,IAAI;IACF,MAAM,GAAG,SAAS,OAAO,YAAY,SAAS,CAAC;IAC/C;GACF,SAAS,OAAO;IACd,IAAK,MAAgC,SAAS,sBAAsB,MAAM;GAC5E;GACA,KAAK,MAAM,MAAM,GAAG,SAAS,SAAS,WAAW,aAAa,CAAC;GAC/D,IAAI,OAAO,MAAM,GAAG,SAAS,KAAK,SAAS,EAAA,CAAG,WAAW,OAAO;GAChE,MAAM,GAAG,SAAS,GAAG,kBAAkB;IAAE,WAAW;IAAM,OAAO;GAAK,CAAC;GACvE,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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/services/processLiveness/index.ts
|
|
2
|
+
/**
|
|
3
|
+
* Is a process still running?
|
|
4
|
+
*
|
|
5
|
+
* Signal 0 performs the permission and existence check without delivering a
|
|
6
|
+
* signal. EPERM means the process exists but belongs to another user, which
|
|
7
|
+
* still counts as alive.
|
|
8
|
+
*/
|
|
9
|
+
function isProcessAlive(pid) {
|
|
10
|
+
try {
|
|
11
|
+
process.kill(pid, 0);
|
|
12
|
+
return true;
|
|
13
|
+
} catch (error) {
|
|
14
|
+
return error.code === "EPERM";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { isProcessAlive as t };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=processLiveness-Ccd9wenT.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processLiveness-Ccd9wenT.mjs","names":[],"sources":["../src/services/processLiveness/index.ts"],"sourcesContent":["/**\n * Is a process still running?\n *\n * Signal 0 performs the permission and existence check without delivering a\n * signal. EPERM means the process exists but belongs to another user, which\n * still counts as alive.\n */\nexport function isProcessAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n return (error as NodeJS.ErrnoException).code === 'EPERM';\n }\n}\n"],"mappings":";;;;;;;;AAOA,SAAgB,eAAe,KAAsB;CACnD,IAAI;EACF,QAAQ,KAAK,KAAK,CAAC;EACnB,OAAO;CACT,SAAS,OAAO;EACd,OAAQ,MAAgC,SAAS;CACnD;AACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/services/processLiveness/index.ts
|
|
2
|
+
/**
|
|
3
|
+
* Is a process still running?
|
|
4
|
+
*
|
|
5
|
+
* Signal 0 performs the permission and existence check without delivering a
|
|
6
|
+
* signal. EPERM means the process exists but belongs to another user, which
|
|
7
|
+
* still counts as alive.
|
|
8
|
+
*/
|
|
9
|
+
function isProcessAlive(pid) {
|
|
10
|
+
try {
|
|
11
|
+
process.kill(pid, 0);
|
|
12
|
+
return true;
|
|
13
|
+
} catch (error) {
|
|
14
|
+
return error.code === "EPERM";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
Object.defineProperty(exports, "isProcessAlive", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function() {
|
|
21
|
+
return isProcessAlive;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=processLiveness-umpNgsPR.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processLiveness-umpNgsPR.cjs","names":[],"sources":["../src/services/processLiveness/index.ts"],"sourcesContent":["/**\n * Is a process still running?\n *\n * Signal 0 performs the permission and existence check without delivering a\n * signal. EPERM means the process exists but belongs to another user, which\n * still counts as alive.\n */\nexport function isProcessAlive(pid: number): boolean {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n return (error as NodeJS.ErrnoException).code === 'EPERM';\n }\n}\n"],"mappings":";;;;;;;;AAOA,SAAgB,eAAe,KAAsB;CACnD,IAAI;EACF,QAAQ,KAAK,KAAK,CAAC;EACnB,OAAO;CACT,SAAS,OAAO;EACd,OAAQ,MAAgC,SAAS;CACnD;AACF"}
|