@agimon-ai/po-task 0.0.0-alpha.7 → 0.0.0-alpha.71
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 +149 -21
- package/README.md +12 -2
- package/dist/apiContracts.cjs +1 -0
- package/dist/apiContracts.cjs.map +1 -1
- package/dist/apiContracts.mjs +1 -0
- package/dist/apiContracts.mjs.map +1 -1
- package/dist/{delegation-Dsqf7fUM.mjs → delegation-5TOl_dEq.mjs} +4 -3
- package/dist/delegation-5TOl_dEq.mjs.map +1 -0
- package/dist/{delegation-frvEXhIz.cjs → delegation-BJtAUTVg.cjs} +4 -3
- 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 +60 -61
- package/dist/extensions/mcp.cjs.map +1 -1
- package/dist/extensions/mcp.mjs +60 -61
- package/dist/extensions/mcp.mjs.map +1 -1
- package/dist/extensions/native.mjs +420 -315
- package/dist/extensions/native.mjs.map +1 -1
- package/dist/extensions/server.cjs +398 -136
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts +2 -2
- package/dist/extensions/server.d.mts.map +1 -1
- package/dist/extensions/server.mjs +397 -135
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/extensions/web.mjs +254 -206
- package/dist/extensions/web.mjs.map +1 -1
- package/dist/{index-DlmXKyhQ.d.mts → index-CdJx5tdI.d.mts} +2 -2
- package/dist/{index-DlmXKyhQ.d.mts.map → index-CdJx5tdI.d.mts.map} +1 -1
- package/dist/{index-B1JPJdpZ.d.mts → index-DrE00rrP.d.mts} +3 -3
- package/dist/{index-B1JPJdpZ.d.mts.map → index-DrE00rrP.d.mts.map} +1 -1
- package/dist/{index-qQGWsPum.d.mts → index-DuT-Lbxy.d.mts} +2 -3
- package/dist/index-DuT-Lbxy.d.mts.map +1 -0
- package/dist/{index-CUWCvh-E.d.mts → index-nx0ueNkm.d.mts} +2 -2
- package/dist/{index-CUWCvh-E.d.mts.map → index-nx0ueNkm.d.mts.map} +1 -1
- package/dist/{index-B9QNwUBr.d.mts → index-sahNy7Hg.d.mts} +3 -3
- package/dist/{index-B9QNwUBr.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 +10 -10
- package/dist/index.mjs +4 -4
- package/dist/{logSinkTelemetry-BhbKdn-x.mjs → logSinkTelemetry-3GMazFYa.mjs} +2 -2
- package/dist/logSinkTelemetry-3GMazFYa.mjs.map +1 -0
- package/dist/{logSinkTelemetry-BGb8WQBz.cjs → logSinkTelemetry-DhzIQMsV.cjs} +3 -3
- package/dist/logSinkTelemetry-DhzIQMsV.cjs.map +1 -0
- package/dist/logSinkTelemetry.cjs +1 -1
- package/dist/logSinkTelemetry.d.mts +1 -1
- package/dist/logSinkTelemetry.mjs +1 -1
- 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/storeInvariants.d.mts +1 -1
- package/dist/storePaths.cjs +1 -3
- package/dist/storePaths.d.mts +2 -2
- package/dist/storePaths.mjs +1 -1
- package/dist/storeReconcile.d.mts +1 -1
- package/dist/storeReducer.d.mts +1 -1
- package/dist/storeTaskGraph.d.mts +1 -1
- package/dist/storeTaskStore.cjs +1 -1
- package/dist/storeTaskStore.d.mts +1 -1
- package/dist/storeTaskStore.mjs +1 -1
- package/dist/storeTypes.d.mts +1 -1
- package/dist/{task-4HeGAS8o.d.mts → task--hlnpS7L.d.mts} +2 -2
- package/dist/{task-4HeGAS8o.d.mts.map → task--hlnpS7L.d.mts.map} +1 -1
- package/dist/task-CXF9VULl.cjs.map +1 -1
- package/dist/{task-DJpTteeJ.d.mts → task-DdTKZNtU.d.mts} +3 -1
- package/dist/task-DdTKZNtU.d.mts.map +1 -0
- package/dist/task-giCbpKzV.mjs.map +1 -1
- package/dist/{taskGraph-D0zFHF2p.d.mts → taskGraph-CB8ffMCz.d.mts} +2 -2
- package/dist/{taskGraph-D0zFHF2p.d.mts.map → taskGraph-CB8ffMCz.d.mts.map} +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/dist/toolResponseEnvelope.d.mts +1 -1
- package/dist/toolSchema.d.mts +1 -1
- package/llms.txt +11 -0
- package/package.json +18 -17
- package/src/prompts/codemode-how-to-task/SKILL.md +40 -0
- package/src/types/webTasks.ts +1 -0
- package/dist/delegation-Dsqf7fUM.mjs.map +0 -1
- package/dist/delegation-frvEXhIz.cjs.map +0 -1
- package/dist/index-CA4Opp4r.d.mts.map +0 -1
- package/dist/index-qQGWsPum.d.mts.map +0 -1
- package/dist/logSinkTelemetry-BGb8WQBz.cjs.map +0 -1
- package/dist/logSinkTelemetry-BhbKdn-x.mjs.map +0 -1
- package/dist/paths-DajceJig.mjs.map +0 -1
- package/dist/paths-P-XvOUuH.cjs.map +0 -1
- package/dist/task-DJpTteeJ.d.mts.map +0 -1
- package/dist/taskStore-BAi54FKL.mjs.map +0 -1
- package/dist/taskStore-C4vcUOzA.cjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logSinkTelemetry-3GMazFYa.mjs","names":[],"sources":["../src/services/logSinkTelemetry/index.ts"],"sourcesContent":["import { createPoTelemetry, type PoTelemetry, type PoTelemetryOptions } from '@agimon-ai/po-core/telemetry';\n\nimport { TASK_EVENT, type TaskErrorAttributes, type TaskFailureReporter } from '../../types/telemetry';\n\nexport {\n TASK_EVENT,\n type TaskErrorAttributes,\n type TaskErrorSink,\n type TaskEventName,\n type TaskEventSink,\n type TaskFailureReporter,\n} from '../../types/telemetry';\n\nconst SERVICE_NAME = 'po-task';\nconst PACKAGE_NAME = '@agimon-ai/po-task';\nconst NOTIFICATION_OPERATION = 'completion_notification';\n\nexport interface TaskErrorReporterOptions {\n cwd?: string;\n workspaceRoot?: string;\n env?: NodeJS.ProcessEnv;\n telemetryFactory?: NonNullable<PoTelemetryOptions['telemetryFactory']>;\n warn?: (message: string) => void;\n}\n\nexport interface TaskErrorReporter {\n recordError(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;\n recordWarning(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;\n recordEvent(event: string, attributes?: TaskErrorAttributes): Promise<void>;\n recordNotificationError(error: unknown, taskId: number): Promise<void>;\n flush(): Promise<void>;\n shutdown(): Promise<void>;\n}\n\nexport function createTaskErrorReporter(options: TaskErrorReporterOptions = {}): TaskErrorReporter {\n const telemetry: PoTelemetry = createPoTelemetry({\n serviceName: SERVICE_NAME,\n packageName: PACKAGE_NAME,\n cwd: options.cwd,\n workspaceRoot: options.workspaceRoot,\n env: options.env,\n telemetryFactory: options.telemetryFactory,\n warn: options.warn,\n enableLogs: true,\n enableTraces: true,\n });\n return {\n recordError: (event, error, attributes) => telemetry.recordError(event, error, attributes),\n recordWarning: (event, error, attributes) => telemetry.recordWarning(event, error, attributes),\n recordEvent: (event, attributes) => telemetry.recordEvent(event, attributes),\n recordNotificationError: (error, taskId) =>\n telemetry.recordError(TASK_EVENT.notificationFailed, error, {\n 'task.id': taskId,\n 'task.operation': NOTIFICATION_OPERATION,\n }),\n flush: () => telemetry.flush(),\n shutdown: () => telemetry.shutdown(),\n };\n}\n\nexport function toFailureReporter(reporter: TaskErrorReporter): TaskFailureReporter {\n return {\n error: (event, error, attributes) => void reporter.recordError(event, error, attributes),\n warn: (event, error, attributes) => void reporter.recordWarning(event, error, attributes),\n event: (event, attributes) => void reporter.recordEvent(event, attributes),\n };\n}\n"],"mappings":";;;AAaA,MAAM,eAAe;AACrB,MAAM,eAAe;AACrB,MAAM,yBAAyB;AAmB/B,SAAgB,wBAAwB,UAAoC,CAAC,GAAsB;CACjG,MAAM,YAAyB,kBAAkB;EAC/C,aAAa;EACb,aAAa;EACb,KAAK,QAAQ;EACb,eAAe,QAAQ;EACvB,KAAK,QAAQ;EACb,kBAAkB,QAAQ;EAC1B,MAAM,QAAQ;EACd,YAAY;EACZ,cAAc;CAChB,CAAC;CACD,OAAO;EACL,cAAc,OAAO,OAAO,eAAe,UAAU,YAAY,OAAO,OAAO,UAAU;EACzF,gBAAgB,OAAO,OAAO,eAAe,UAAU,cAAc,OAAO,OAAO,UAAU;EAC7F,cAAc,OAAO,eAAe,UAAU,YAAY,OAAO,UAAU;EAC3E,0BAA0B,OAAO,WAC/B,UAAU,YAAY,WAAW,oBAAoB,OAAO;GAC1D,WAAW;GACX,kBAAkB;EACpB,CAAC;EACH,aAAa,UAAU,MAAM;EAC7B,gBAAgB,UAAU,SAAS;CACrC;AACF;AAEA,SAAgB,kBAAkB,UAAkD;CAClF,OAAO;EACL,QAAQ,OAAO,OAAO,eAAe,KAAK,SAAS,YAAY,OAAO,OAAO,UAAU;EACvF,OAAO,OAAO,OAAO,eAAe,KAAK,SAAS,cAAc,OAAO,OAAO,UAAU;EACxF,QAAQ,OAAO,eAAe,KAAK,SAAS,YAAY,OAAO,UAAU;CAC3E;AACF"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const require_telemetry = require("./telemetry-x3JxCA5K.cjs");
|
|
2
|
-
let
|
|
2
|
+
let _agimon_ai_po_core_telemetry = require("@agimon-ai/po-core/telemetry");
|
|
3
3
|
//#region src/services/logSinkTelemetry/index.ts
|
|
4
4
|
const SERVICE_NAME = "po-task";
|
|
5
5
|
const PACKAGE_NAME = "@agimon-ai/po-task";
|
|
6
6
|
const NOTIFICATION_OPERATION = "completion_notification";
|
|
7
7
|
function createTaskErrorReporter(options = {}) {
|
|
8
|
-
const telemetry = (0,
|
|
8
|
+
const telemetry = (0, _agimon_ai_po_core_telemetry.createPoTelemetry)({
|
|
9
9
|
serviceName: SERVICE_NAME,
|
|
10
10
|
packageName: PACKAGE_NAME,
|
|
11
11
|
cwd: options.cwd,
|
|
@@ -49,4 +49,4 @@ Object.defineProperty(exports, "toFailureReporter", {
|
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
//# sourceMappingURL=logSinkTelemetry-
|
|
52
|
+
//# sourceMappingURL=logSinkTelemetry-DhzIQMsV.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logSinkTelemetry-DhzIQMsV.cjs","names":["createPoTelemetry","TASK_EVENT"],"sources":["../src/services/logSinkTelemetry/index.ts"],"sourcesContent":["import { createPoTelemetry, type PoTelemetry, type PoTelemetryOptions } from '@agimon-ai/po-core/telemetry';\n\nimport { TASK_EVENT, type TaskErrorAttributes, type TaskFailureReporter } from '../../types/telemetry';\n\nexport {\n TASK_EVENT,\n type TaskErrorAttributes,\n type TaskErrorSink,\n type TaskEventName,\n type TaskEventSink,\n type TaskFailureReporter,\n} from '../../types/telemetry';\n\nconst SERVICE_NAME = 'po-task';\nconst PACKAGE_NAME = '@agimon-ai/po-task';\nconst NOTIFICATION_OPERATION = 'completion_notification';\n\nexport interface TaskErrorReporterOptions {\n cwd?: string;\n workspaceRoot?: string;\n env?: NodeJS.ProcessEnv;\n telemetryFactory?: NonNullable<PoTelemetryOptions['telemetryFactory']>;\n warn?: (message: string) => void;\n}\n\nexport interface TaskErrorReporter {\n recordError(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;\n recordWarning(event: string, error: unknown, attributes?: TaskErrorAttributes): Promise<void>;\n recordEvent(event: string, attributes?: TaskErrorAttributes): Promise<void>;\n recordNotificationError(error: unknown, taskId: number): Promise<void>;\n flush(): Promise<void>;\n shutdown(): Promise<void>;\n}\n\nexport function createTaskErrorReporter(options: TaskErrorReporterOptions = {}): TaskErrorReporter {\n const telemetry: PoTelemetry = createPoTelemetry({\n serviceName: SERVICE_NAME,\n packageName: PACKAGE_NAME,\n cwd: options.cwd,\n workspaceRoot: options.workspaceRoot,\n env: options.env,\n telemetryFactory: options.telemetryFactory,\n warn: options.warn,\n enableLogs: true,\n enableTraces: true,\n });\n return {\n recordError: (event, error, attributes) => telemetry.recordError(event, error, attributes),\n recordWarning: (event, error, attributes) => telemetry.recordWarning(event, error, attributes),\n recordEvent: (event, attributes) => telemetry.recordEvent(event, attributes),\n recordNotificationError: (error, taskId) =>\n telemetry.recordError(TASK_EVENT.notificationFailed, error, {\n 'task.id': taskId,\n 'task.operation': NOTIFICATION_OPERATION,\n }),\n flush: () => telemetry.flush(),\n shutdown: () => telemetry.shutdown(),\n };\n}\n\nexport function toFailureReporter(reporter: TaskErrorReporter): TaskFailureReporter {\n return {\n error: (event, error, attributes) => void reporter.recordError(event, error, attributes),\n warn: (event, error, attributes) => void reporter.recordWarning(event, error, attributes),\n event: (event, attributes) => void reporter.recordEvent(event, attributes),\n };\n}\n"],"mappings":";;;AAaA,MAAM,eAAe;AACrB,MAAM,eAAe;AACrB,MAAM,yBAAyB;AAmB/B,SAAgB,wBAAwB,UAAoC,CAAC,GAAsB;CACjG,MAAM,aAAA,GAAyBA,6BAAAA,kBAAAA,CAAkB;EAC/C,aAAa;EACb,aAAa;EACb,KAAK,QAAQ;EACb,eAAe,QAAQ;EACvB,KAAK,QAAQ;EACb,kBAAkB,QAAQ;EAC1B,MAAM,QAAQ;EACd,YAAY;EACZ,cAAc;CAChB,CAAC;CACD,OAAO;EACL,cAAc,OAAO,OAAO,eAAe,UAAU,YAAY,OAAO,OAAO,UAAU;EACzF,gBAAgB,OAAO,OAAO,eAAe,UAAU,cAAc,OAAO,OAAO,UAAU;EAC7F,cAAc,OAAO,eAAe,UAAU,YAAY,OAAO,UAAU;EAC3E,0BAA0B,OAAO,WAC/B,UAAU,YAAYC,kBAAAA,WAAW,oBAAoB,OAAO;GAC1D,WAAW;GACX,kBAAkB;EACpB,CAAC;EACH,aAAa,UAAU,MAAM;EAC7B,gBAAgB,UAAU,SAAS;CACrC;AACF;AAEA,SAAgB,kBAAkB,UAAkD;CAClF,OAAO;EACL,QAAQ,OAAO,OAAO,eAAe,KAAK,SAAS,YAAY,OAAO,OAAO,UAAU;EACvF,OAAO,OAAO,OAAO,eAAe,KAAK,SAAS,cAAc,OAAO,OAAO,UAAU;EACxF,QAAQ,OAAO,eAAe,KAAK,SAAS,YAAY,OAAO,UAAU;CAC3E;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_telemetry = require("./telemetry-x3JxCA5K.cjs");
|
|
3
|
-
const require_logSinkTelemetry = require("./logSinkTelemetry-
|
|
3
|
+
const require_logSinkTelemetry = require("./logSinkTelemetry-DhzIQMsV.cjs");
|
|
4
4
|
exports.TASK_EVENT = require_telemetry.TASK_EVENT;
|
|
5
5
|
exports.createTaskErrorReporter = require_logSinkTelemetry.createTaskErrorReporter;
|
|
6
6
|
exports.toFailureReporter = require_logSinkTelemetry.toFailureReporter;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as TaskEventSink, i as TaskEventName, n as TaskErrorAttributes, o as TaskFailureReporter, r as TaskErrorSink, t as TASK_EVENT } from "./telemetry-DYfgUFF8.mjs";
|
|
2
|
-
import { PoTelemetryOptions } from "@agimon-ai/po-telemetry";
|
|
2
|
+
import { PoTelemetryOptions } from "@agimon-ai/po-core/telemetry";
|
|
3
3
|
//#region src/services/logSinkTelemetry/index.d.ts
|
|
4
4
|
export interface TaskErrorReporterOptions {
|
|
5
5
|
cwd?: string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { t as TASK_EVENT } from "./telemetry-gEGWTaMI.mjs";
|
|
2
|
-
import { n as toFailureReporter, t as createTaskErrorReporter } from "./logSinkTelemetry-
|
|
2
|
+
import { n as toFailureReporter, t as createTaskErrorReporter } from "./logSinkTelemetry-3GMazFYa.mjs";
|
|
3
3
|
export { TASK_EVENT, createTaskErrorReporter, toFailureReporter };
|
|
@@ -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,MA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AY,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,WAAW,KAAK,SAAS,KAAK,QAAQ,IAAI,GAAG,KAAK,QAAQ,SAAS,CAAC;CAC1E,OAAO,aAAa,MAAO,CAAC,SAAS,WAAW,IAAI,KAAK,CAAC,KAAK,WAAW,QAAQ;AACpF;;AAGA,SAAgB,kBACd,eACA,MAAoD,QAAQ,KACpD;CACR,IAAI,CAAC,IAAI,qBAAqB,OAAO;CACrC,MAAM,kBAAkB,IAAI,4BAA4B,EAAE,KAAK;CAC/D,IAAI,CAAC,iBAAiB,MAAM,IAAI,MAAM,G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;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";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as reconcileOrphanedDelegations, i as ReconcileSelf, n as ERR_ORPHANED_BY_SESSION, r as ReconcileResult, t as ERR_ORPHANED_BY_RESTART } from "./index-
|
|
1
|
+
import { a as reconcileOrphanedDelegations, i as ReconcileSelf, n as ERR_ORPHANED_BY_SESSION, r as ReconcileResult, t as ERR_ORPHANED_BY_RESTART } from "./index-CdJx5tdI.mjs";
|
|
2
2
|
export { ERR_ORPHANED_BY_RESTART, ERR_ORPHANED_BY_SESSION, ReconcileResult, ReconcileSelf, reconcileOrphanedDelegations };
|
package/dist/storeReducer.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ReducerAction, c as isCommittingOp, i as REF_PATTERN, l as singleItemOutcome, n as MAX_UPSERT_ITEMS, o as applyTaskMutation, r as Op, s as formatUpsertFailure, t as ApplyResult } from "./index-
|
|
1
|
+
import { a as ReducerAction, c as isCommittingOp, i as REF_PATTERN, l as singleItemOutcome, n as MAX_UPSERT_ITEMS, o as applyTaskMutation, r as Op, s as formatUpsertFailure, t as ApplyResult } from "./index-nx0ueNkm.mjs";
|
|
2
2
|
export { ApplyResult, MAX_UPSERT_ITEMS, Op, REF_PATTERN, ReducerAction, applyTaskMutation, formatUpsertFailure, isCommittingOp, singleItemOutcome };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as unresolvedBlockers, i as isTaskListComplete, n as detectCycle, r as isBlocked, t as deriveBlocks } from "./taskGraph-
|
|
1
|
+
import { a as unresolvedBlockers, i as isTaskListComplete, n as detectCycle, r as isBlocked, t as deriveBlocks } from "./taskGraph-CB8ffMCz.mjs";
|
|
2
2
|
export { deriveBlocks, detectCycle, isBlocked, isTaskListComplete, unresolvedBlockers };
|
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";
|
package/dist/storeTypes.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as UpsertSummary, a as DepToken, c as TaskAction, d as TaskDetails, f as TaskDocument, g as UpsertItemOutcome, h as TaskStatus, i as DelegationState, l as TaskAssignment, m as TaskMutationParams, n as DELETED_STATUS, o as STORE_SCHEMA_VERSION, p as TaskItemMutation, r as DelegationResult, s as Task, t as AssignmentSummary, u as TaskDelegation, v as emptyDocument, y as isDelegationActive } from "./task-
|
|
1
|
+
import { _ as UpsertSummary, a as DepToken, c as TaskAction, d as TaskDetails, f as TaskDocument, g as UpsertItemOutcome, h as TaskStatus, i as DelegationState, l as TaskAssignment, m as TaskMutationParams, n as DELETED_STATUS, o as STORE_SCHEMA_VERSION, p as TaskItemMutation, r as DelegationResult, s as Task, t as AssignmentSummary, u as TaskDelegation, v as emptyDocument, y as isDelegationActive } from "./task-DdTKZNtU.mjs";
|
|
2
2
|
export { AssignmentSummary, DELETED_STATUS, DelegationResult, DelegationState, DepToken, STORE_SCHEMA_VERSION, Task, TaskAction, TaskAssignment, TaskDelegation, TaskDetails, TaskDocument, TaskItemMutation, TaskMutationParams, TaskStatus, UpsertItemOutcome, UpsertSummary, emptyDocument, isDelegationActive };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as TaskAction } from "./task-
|
|
1
|
+
import { c as TaskAction } from "./task-DdTKZNtU.mjs";
|
|
2
2
|
import { Static, Type } from "typebox";
|
|
3
3
|
//#region src/constants/task.d.ts
|
|
4
4
|
declare const COMMAND_NAME = "tasks";
|
|
@@ -123,4 +123,4 @@ type TaskAssignmentParams = Static<typeof TaskAssignmentSchema>;
|
|
|
123
123
|
type TaskParams = Static<typeof TaskParamsSchema>;
|
|
124
124
|
//#endregion
|
|
125
125
|
export { TaskParamsSchema as _, RemoteTaskParamsSchema as a, TASK_CONTEXTS as c, TOOL_NAME as d, TaskAssignmentParams as f, TaskParams as g, TaskItemSchema as h, REMOTE_TASK_ACTIONS as i, TASK_STATUSES as l, TaskItemParams as m, MSG_NO_TASKS as n, TASK_ACTIONS as o, TaskAssignmentSchema as p, MSG_UPSERT_FIELD_MISPLACED as r, TASK_ACTION_FIELDS as s, ERR_REQUIRES_INTERACTIVE as t, TOOL_LABEL as u, taskActionAcceptsField as v, COMMAND_NAME as y };
|
|
126
|
-
//# sourceMappingURL=task
|
|
126
|
+
//# sourceMappingURL=task--hlnpS7L.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task
|
|
1
|
+
{"version":3,"file":"task--hlnpS7L.d.mts","names":[],"sources":["../src/constants/task.ts","../src/schemas/task.ts"],"mappings":";;;cAAa;;;cCOA;cACA;cACA;cAEA;cACA;cAEA;cACA;;;;;;;;;cAUA;;;;;;;;;iBAUG,uBAAuB,QAAQ,YAAY;;cAK9C;;;;;;cAcA,gBAAc,KAAA;;;;;;;;;;;;;;cA2Dd,sBAAoB,KAAA;;;;;;;;;;;;;;;;cA6BpB,kBAAgB,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAiChB;cAEA,wBAAsB,KAAA;;;;;;;;;;;;;;;;;;;KAKvB,iBAAiB,cAAc;KAC/B,uBAAuB,cAAc;KACrC,aAAa,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-CXF9VULl.cjs","names":[],"sources":["../src/models/task.ts"],"sourcesContent":["/**\n * Domain types for the file-backed task store.\n *\n * The on-disk document is the durable source of truth (unlike rpiv-todo, which\n * replayed state from the transcript). Every field here round-trips through\n * JSON, so nothing may hold non-serializable values.\n */\n\nimport type { InlineAgent } from '@agimon-ai/po-core/delegation';\n\nexport type TaskStatus = 'pending' | 'in_progress' | 'completed' | 'failed' | 'deleted';\n\nexport const DELETED_STATUS: TaskStatus = 'deleted';\n\nexport type TaskAction = 'upsert' | 'list' | 'get' | 'delete' | 'clear' | 'assign' | 'cancel';\n\nexport type DelegationState = 'requested' | 'running' | 'completed' | 'failed' | 'cancelled';\n\n/** Terminal result of a delegated subagent run, copied off the delegation response. */\nexport interface DelegationResult {\n status: string;\n output?: string;\n outputPath?: string;\n sessionFile?: string;\n error?: string;\n durationMs?: number;\n toolCount?: number;\n}\n\n/**\n * Delegation bookkeeping attached to a task that was handed to a subagent.\n *\n * `pid` is the harness process that owns the run: it is the only way to tell an\n * genuinely-running delegation from one orphaned by a harness crash, since the\n * child dies with its parent but the file survives.\n */\nexport interface TaskDelegation {\n requestId: string;\n agent: string;\n state: DelegationState;\n sessionId?: string;\n pid?: number;\n runId?: string;\n model?: string;\n startedAt?: string;\n endedAt?: string;\n result?: DelegationResult;\n}\n\nexport interface Task {\n id: number;\n subject: string;\n description?: string;\n activeForm?: string;\n status: TaskStatus;\n blockedBy?: number[];\n owner?: string;\n metadata?: Record<string, unknown>;\n createdAt?: string;\n updatedAt?: string;\n delegation?: TaskDelegation;\n}\n\nexport const STORE_SCHEMA_VERSION = 1;\n\n/** The complete on-disk document. `rev` increments on every committed write. */\nexport interface TaskDocument {\n version: number;\n rev: number;\n nextId: number;\n tasks: Task[];\n}\n\nexport function emptyDocument(): TaskDocument {\n return { version: STORE_SCHEMA_VERSION, rev: 0, nextId: 1, tasks: [] };\n}\n\n/**\n * A dependency target inside an upsert item: an existing task id, or the `ref`\n * of a task created earlier in the same call.\n *\n * Refs must start with a letter (see `REF_PATTERN`), so a ref is structurally\n * unconfusable with a stringified id and the discrimination is just `typeof`.\n */\nexport type DepToken = number | string;\n\n/**\n * One entry of an `upsert` call. No `id` creates a task; an `id` updates one.\n *\n * `blockedBy` (absolute set) is create-only and `addBlockedBy`/`removeBlockedBy`\n * (additive merge) are update-only, matching the split the two former actions\n * had. A field used against the wrong kind fails that item rather than being\n * silently ignored.\n */\nexport interface TaskItemMutation {\n id?: number;\n ref?: string;\n subject?: string;\n description?: string;\n activeForm?: string;\n status?: TaskStatus;\n blockedBy?: DepToken[];\n addBlockedBy?: DepToken[];\n removeBlockedBy?: DepToken[];\n owner?: string;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * What one upsert item did. `index` is its position in the request array, so a\n * model reading a partial result can tell which entries still need resending.\n *\n * `message` is unprefixed: the `item[N] failed:` framing belongs to the\n * formatter, because the Task Space overlay shows this text on its own.\n */\nexport type UpsertItemOutcome =\n | {\n index: number;\n kind: 'created';\n id: number;\n subject: string;\n status: TaskStatus;\n ref?: string;\n blockedBy?: number[];\n }\n | { index: number; kind: 'updated'; id: number; fromStatus: TaskStatus; toStatus: TaskStatus }\n | { index: number; kind: 'unchanged'; id: number; status: TaskStatus }\n | { index: number; kind: 'failed'; message: string; id?: number; ref?: string };\n\n/** Which tasks an upsert touched, so renderResult names them instead of guessing. */\nexport interface UpsertSummary {\n /** Ids of applied entries, in request order. A failed entry contributes nothing. */\n applied: number[];\n failed: number;\n}\n\n/** One task-to-agent handoff inside a native assignment batch. */\nexport interface TaskAssignment {\n id: number;\n agent: string;\n inlineAgent?: InlineAgent;\n instructions?: string;\n relevantFiles?: string[];\n priorFindings?: string;\n model?: string;\n context?: 'fresh' | 'fork';\n}\n\n/** Which assignment entries started, so renderResult can show one consolidated batch. */\nexport interface AssignmentSummary {\n /** Ids of successful entries, in request order. A failed entry contributes nothing. */\n assigned: number[];\n failed: number;\n}\n\n/**\n * Open-shape input bag the reducer accepts. The index signature lets the\n * runtime pass a TypeBox `Static<typeof TaskParamsSchema>` through without\n * casting each field.\n *\n * Per-task fields live on `tasks[]`, not here: a top-level `subject` or\n * `status` would be ambiguous once one call can carry many tasks.\n */\nexport interface TaskMutationParams {\n [key: string]: unknown;\n tasks?: TaskItemMutation[];\n /** `assign` only: independent task-to-agent handoffs dispatched by one tool call. */\n assignments?: TaskAssignment[];\n /** `list` filter only. To set a status, upsert the task by id. */\n status?: TaskStatus;\n /** `get`, `delete`, and `cancel` only. Assign ids live in `assignments[]`. */\n id?: number;\n includeDeleted?: boolean;\n}\n\n/** Snapshot returned under a tool result's `details` for renderResult. */\nexport interface TaskDetails {\n action: TaskAction;\n params: Record<string, unknown>;\n tasks: Task[];\n nextId: number;\n rev: number;\n error?: string;\n upsert?: UpsertSummary;\n assignment?: AssignmentSummary;\n}\n\n/**\n * A delegation is \"live\" while the owning run may still produce a response.\n *\n * Takes the delegation shape rather than `Task` so the cockpit's `WebTask`,\n * which carries the state as a plain string, answers the question the same way\n * the store does.\n */\nexport function isDelegationActive(task: { delegation?: { state?: string } }): boolean {\n const state = task.delegation?.state;\n return state === 'requested' || state === 'running';\n}\n"],"mappings":";AAYA,MAAa,iBAA6B;
|
|
1
|
+
{"version":3,"file":"task-CXF9VULl.cjs","names":[],"sources":["../src/models/task.ts"],"sourcesContent":["/**\n * Domain types for the file-backed task store.\n *\n * The on-disk document is the durable source of truth (unlike rpiv-todo, which\n * replayed state from the transcript). Every field here round-trips through\n * JSON, so nothing may hold non-serializable values.\n */\n\nimport type { InlineAgent } from '@agimon-ai/po-core/delegation';\n\nexport type TaskStatus = 'pending' | 'in_progress' | 'completed' | 'failed' | 'deleted';\n\nexport const DELETED_STATUS: TaskStatus = 'deleted';\n\nexport type TaskAction = 'upsert' | 'list' | 'get' | 'delete' | 'clear' | 'assign' | 'cancel';\n\nexport type DelegationState = 'requested' | 'running' | 'completed' | 'failed' | 'cancelled';\n\n/** Terminal result of a delegated subagent run, copied off the delegation response. */\nexport interface DelegationResult {\n status: string;\n output?: string;\n outputPath?: string;\n sessionFile?: string;\n error?: string;\n durationMs?: number;\n toolCount?: number;\n}\n\n/**\n * Delegation bookkeeping attached to a task that was handed to a subagent.\n *\n * `pid` is the harness process that owns the run: it is the only way to tell an\n * genuinely-running delegation from one orphaned by a harness crash, since the\n * child dies with its parent but the file survives.\n */\nexport interface TaskDelegation {\n requestId: string;\n agent: string;\n /** The named run identity minted by the delegation provider, not the agent definition. */\n identity?: string;\n state: DelegationState;\n sessionId?: string;\n pid?: number;\n runId?: string;\n model?: string;\n startedAt?: string;\n endedAt?: string;\n result?: DelegationResult;\n}\n\nexport interface Task {\n id: number;\n subject: string;\n description?: string;\n activeForm?: string;\n status: TaskStatus;\n blockedBy?: number[];\n owner?: string;\n metadata?: Record<string, unknown>;\n createdAt?: string;\n updatedAt?: string;\n delegation?: TaskDelegation;\n}\n\nexport const STORE_SCHEMA_VERSION = 1;\n\n/** The complete on-disk document. `rev` increments on every committed write. */\nexport interface TaskDocument {\n version: number;\n rev: number;\n nextId: number;\n tasks: Task[];\n}\n\nexport function emptyDocument(): TaskDocument {\n return { version: STORE_SCHEMA_VERSION, rev: 0, nextId: 1, tasks: [] };\n}\n\n/**\n * A dependency target inside an upsert item: an existing task id, or the `ref`\n * of a task created earlier in the same call.\n *\n * Refs must start with a letter (see `REF_PATTERN`), so a ref is structurally\n * unconfusable with a stringified id and the discrimination is just `typeof`.\n */\nexport type DepToken = number | string;\n\n/**\n * One entry of an `upsert` call. No `id` creates a task; an `id` updates one.\n *\n * `blockedBy` (absolute set) is create-only and `addBlockedBy`/`removeBlockedBy`\n * (additive merge) are update-only, matching the split the two former actions\n * had. A field used against the wrong kind fails that item rather than being\n * silently ignored.\n */\nexport interface TaskItemMutation {\n id?: number;\n ref?: string;\n subject?: string;\n description?: string;\n activeForm?: string;\n status?: TaskStatus;\n blockedBy?: DepToken[];\n addBlockedBy?: DepToken[];\n removeBlockedBy?: DepToken[];\n owner?: string;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * What one upsert item did. `index` is its position in the request array, so a\n * model reading a partial result can tell which entries still need resending.\n *\n * `message` is unprefixed: the `item[N] failed:` framing belongs to the\n * formatter, because the Task Space overlay shows this text on its own.\n */\nexport type UpsertItemOutcome =\n | {\n index: number;\n kind: 'created';\n id: number;\n subject: string;\n status: TaskStatus;\n ref?: string;\n blockedBy?: number[];\n }\n | { index: number; kind: 'updated'; id: number; fromStatus: TaskStatus; toStatus: TaskStatus }\n | { index: number; kind: 'unchanged'; id: number; status: TaskStatus }\n | { index: number; kind: 'failed'; message: string; id?: number; ref?: string };\n\n/** Which tasks an upsert touched, so renderResult names them instead of guessing. */\nexport interface UpsertSummary {\n /** Ids of applied entries, in request order. A failed entry contributes nothing. */\n applied: number[];\n failed: number;\n}\n\n/** One task-to-agent handoff inside a native assignment batch. */\nexport interface TaskAssignment {\n id: number;\n agent: string;\n inlineAgent?: InlineAgent;\n instructions?: string;\n relevantFiles?: string[];\n priorFindings?: string;\n model?: string;\n context?: 'fresh' | 'fork';\n}\n\n/** Which assignment entries started, so renderResult can show one consolidated batch. */\nexport interface AssignmentSummary {\n /** Ids of successful entries, in request order. A failed entry contributes nothing. */\n assigned: number[];\n failed: number;\n}\n\n/**\n * Open-shape input bag the reducer accepts. The index signature lets the\n * runtime pass a TypeBox `Static<typeof TaskParamsSchema>` through without\n * casting each field.\n *\n * Per-task fields live on `tasks[]`, not here: a top-level `subject` or\n * `status` would be ambiguous once one call can carry many tasks.\n */\nexport interface TaskMutationParams {\n [key: string]: unknown;\n tasks?: TaskItemMutation[];\n /** `assign` only: independent task-to-agent handoffs dispatched by one tool call. */\n assignments?: TaskAssignment[];\n /** `list` filter only. To set a status, upsert the task by id. */\n status?: TaskStatus;\n /** `get`, `delete`, and `cancel` only. Assign ids live in `assignments[]`. */\n id?: number;\n includeDeleted?: boolean;\n}\n\n/** Snapshot returned under a tool result's `details` for renderResult. */\nexport interface TaskDetails {\n action: TaskAction;\n params: Record<string, unknown>;\n tasks: Task[];\n nextId: number;\n rev: number;\n error?: string;\n upsert?: UpsertSummary;\n assignment?: AssignmentSummary;\n}\n\n/**\n * A delegation is \"live\" while the owning run may still produce a response.\n *\n * Takes the delegation shape rather than `Task` so the cockpit's `WebTask`,\n * which carries the state as a plain string, answers the question the same way\n * the store does.\n */\nexport function isDelegationActive(task: { delegation?: { state?: string } }): boolean {\n const state = task.delegation?.state;\n return state === 'requested' || state === 'running';\n}\n"],"mappings":";AAYA,MAAa,iBAA6B;AAqD1C,MAAa,uBAAuB;AAUpC,SAAgB,gBAA8B;CAC5C,OAAO;EAAE,SAAA;EAA+B,KAAK;EAAG,QAAQ;EAAG,OAAO,CAAC;CAAE;AACvE;;;;;;;;AAuHA,SAAgB,mBAAmB,MAAoD;CACrF,MAAM,QAAQ,KAAK,YAAY;CAC/B,OAAO,UAAU,eAAe,UAAU;AAC5C"}
|
|
@@ -24,6 +24,8 @@ interface DelegationResult {
|
|
|
24
24
|
interface TaskDelegation {
|
|
25
25
|
requestId: string;
|
|
26
26
|
agent: string;
|
|
27
|
+
/** The named run identity minted by the delegation provider, not the agent definition. */
|
|
28
|
+
identity?: string;
|
|
27
29
|
state: DelegationState;
|
|
28
30
|
sessionId?: string;
|
|
29
31
|
pid?: number;
|
|
@@ -184,4 +186,4 @@ declare function isDelegationActive(task: {
|
|
|
184
186
|
}): boolean;
|
|
185
187
|
//#endregion
|
|
186
188
|
export { UpsertSummary as _, DepToken as a, TaskAction as c, TaskDetails as d, TaskDocument as f, UpsertItemOutcome as g, TaskStatus as h, DelegationState as i, TaskAssignment as l, TaskMutationParams as m, DELETED_STATUS as n, STORE_SCHEMA_VERSION as o, TaskItemMutation as p, DelegationResult as r, Task as s, AssignmentSummary as t, TaskDelegation as u, emptyDocument as v, isDelegationActive as y };
|
|
187
|
-
//# sourceMappingURL=task-
|
|
189
|
+
//# sourceMappingURL=task-DdTKZNtU.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-DdTKZNtU.d.mts","names":[],"sources":["../src/models/task.ts"],"mappings":";;KAUY;cAEC,gBAAgB;KAEjB;KAEA;;UAGK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;;;;UAUe;EACf;EACA;;EAEA;EACA,OAAO;EACP;EACA;EACA;EACA;EACA;EACA;EACA,SAAS;;UAGM;EACf;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA,WAAW;EACX;EACA;EACA,aAAa;;cAGF;;UAGI;EACf;EACA;EACA;EACA,OAAO;;iBAGO,iBAAiB;;;;;;;;KAWrB;;;;;;;;;UAUK;EACf;EACA;EACA;EACA;EACA;EACA,SAAS;EACT,YAAY;EACZ,eAAe;EACf,kBAAkB;EAClB;EACA,WAAW;;;;;;;;;KAUD;EAEN;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;;EAEA;EAAe;EAAiB;EAAY,YAAY;EAAY,UAAU;;EAC9E;EAAe;EAAmB;EAAY,QAAQ;;EACtD;EAAe;EAAgB;EAAiB;EAAa;;;UAGlD;;EAEf;EACA;;;UAIe;EACf;EACA;EACA,cAAc;EACd;EACA;EACA;EACA;EACA;;;UAIe;;EAEf;EACA;;;;;;;;;;UAWe;GACd;EACD,QAAQ;;EAER,cAAc;;EAEd,SAAS;;EAET;EACA;;;UAIe;EACf,QAAQ;EACR,QAAQ;EACR,OAAO;EACP;EACA;EACA;EACA,SAAS;EACT,aAAa;;;;;;;;;iBAUC,mBAAmB;EAAQ;IAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-giCbpKzV.mjs","names":[],"sources":["../src/models/task.ts"],"sourcesContent":["/**\n * Domain types for the file-backed task store.\n *\n * The on-disk document is the durable source of truth (unlike rpiv-todo, which\n * replayed state from the transcript). Every field here round-trips through\n * JSON, so nothing may hold non-serializable values.\n */\n\nimport type { InlineAgent } from '@agimon-ai/po-core/delegation';\n\nexport type TaskStatus = 'pending' | 'in_progress' | 'completed' | 'failed' | 'deleted';\n\nexport const DELETED_STATUS: TaskStatus = 'deleted';\n\nexport type TaskAction = 'upsert' | 'list' | 'get' | 'delete' | 'clear' | 'assign' | 'cancel';\n\nexport type DelegationState = 'requested' | 'running' | 'completed' | 'failed' | 'cancelled';\n\n/** Terminal result of a delegated subagent run, copied off the delegation response. */\nexport interface DelegationResult {\n status: string;\n output?: string;\n outputPath?: string;\n sessionFile?: string;\n error?: string;\n durationMs?: number;\n toolCount?: number;\n}\n\n/**\n * Delegation bookkeeping attached to a task that was handed to a subagent.\n *\n * `pid` is the harness process that owns the run: it is the only way to tell an\n * genuinely-running delegation from one orphaned by a harness crash, since the\n * child dies with its parent but the file survives.\n */\nexport interface TaskDelegation {\n requestId: string;\n agent: string;\n state: DelegationState;\n sessionId?: string;\n pid?: number;\n runId?: string;\n model?: string;\n startedAt?: string;\n endedAt?: string;\n result?: DelegationResult;\n}\n\nexport interface Task {\n id: number;\n subject: string;\n description?: string;\n activeForm?: string;\n status: TaskStatus;\n blockedBy?: number[];\n owner?: string;\n metadata?: Record<string, unknown>;\n createdAt?: string;\n updatedAt?: string;\n delegation?: TaskDelegation;\n}\n\nexport const STORE_SCHEMA_VERSION = 1;\n\n/** The complete on-disk document. `rev` increments on every committed write. */\nexport interface TaskDocument {\n version: number;\n rev: number;\n nextId: number;\n tasks: Task[];\n}\n\nexport function emptyDocument(): TaskDocument {\n return { version: STORE_SCHEMA_VERSION, rev: 0, nextId: 1, tasks: [] };\n}\n\n/**\n * A dependency target inside an upsert item: an existing task id, or the `ref`\n * of a task created earlier in the same call.\n *\n * Refs must start with a letter (see `REF_PATTERN`), so a ref is structurally\n * unconfusable with a stringified id and the discrimination is just `typeof`.\n */\nexport type DepToken = number | string;\n\n/**\n * One entry of an `upsert` call. No `id` creates a task; an `id` updates one.\n *\n * `blockedBy` (absolute set) is create-only and `addBlockedBy`/`removeBlockedBy`\n * (additive merge) are update-only, matching the split the two former actions\n * had. A field used against the wrong kind fails that item rather than being\n * silently ignored.\n */\nexport interface TaskItemMutation {\n id?: number;\n ref?: string;\n subject?: string;\n description?: string;\n activeForm?: string;\n status?: TaskStatus;\n blockedBy?: DepToken[];\n addBlockedBy?: DepToken[];\n removeBlockedBy?: DepToken[];\n owner?: string;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * What one upsert item did. `index` is its position in the request array, so a\n * model reading a partial result can tell which entries still need resending.\n *\n * `message` is unprefixed: the `item[N] failed:` framing belongs to the\n * formatter, because the Task Space overlay shows this text on its own.\n */\nexport type UpsertItemOutcome =\n | {\n index: number;\n kind: 'created';\n id: number;\n subject: string;\n status: TaskStatus;\n ref?: string;\n blockedBy?: number[];\n }\n | { index: number; kind: 'updated'; id: number; fromStatus: TaskStatus; toStatus: TaskStatus }\n | { index: number; kind: 'unchanged'; id: number; status: TaskStatus }\n | { index: number; kind: 'failed'; message: string; id?: number; ref?: string };\n\n/** Which tasks an upsert touched, so renderResult names them instead of guessing. */\nexport interface UpsertSummary {\n /** Ids of applied entries, in request order. A failed entry contributes nothing. */\n applied: number[];\n failed: number;\n}\n\n/** One task-to-agent handoff inside a native assignment batch. */\nexport interface TaskAssignment {\n id: number;\n agent: string;\n inlineAgent?: InlineAgent;\n instructions?: string;\n relevantFiles?: string[];\n priorFindings?: string;\n model?: string;\n context?: 'fresh' | 'fork';\n}\n\n/** Which assignment entries started, so renderResult can show one consolidated batch. */\nexport interface AssignmentSummary {\n /** Ids of successful entries, in request order. A failed entry contributes nothing. */\n assigned: number[];\n failed: number;\n}\n\n/**\n * Open-shape input bag the reducer accepts. The index signature lets the\n * runtime pass a TypeBox `Static<typeof TaskParamsSchema>` through without\n * casting each field.\n *\n * Per-task fields live on `tasks[]`, not here: a top-level `subject` or\n * `status` would be ambiguous once one call can carry many tasks.\n */\nexport interface TaskMutationParams {\n [key: string]: unknown;\n tasks?: TaskItemMutation[];\n /** `assign` only: independent task-to-agent handoffs dispatched by one tool call. */\n assignments?: TaskAssignment[];\n /** `list` filter only. To set a status, upsert the task by id. */\n status?: TaskStatus;\n /** `get`, `delete`, and `cancel` only. Assign ids live in `assignments[]`. */\n id?: number;\n includeDeleted?: boolean;\n}\n\n/** Snapshot returned under a tool result's `details` for renderResult. */\nexport interface TaskDetails {\n action: TaskAction;\n params: Record<string, unknown>;\n tasks: Task[];\n nextId: number;\n rev: number;\n error?: string;\n upsert?: UpsertSummary;\n assignment?: AssignmentSummary;\n}\n\n/**\n * A delegation is \"live\" while the owning run may still produce a response.\n *\n * Takes the delegation shape rather than `Task` so the cockpit's `WebTask`,\n * which carries the state as a plain string, answers the question the same way\n * the store does.\n */\nexport function isDelegationActive(task: { delegation?: { state?: string } }): boolean {\n const state = task.delegation?.state;\n return state === 'requested' || state === 'running';\n}\n"],"mappings":";AAYA,MAAa,iBAA6B;
|
|
1
|
+
{"version":3,"file":"task-giCbpKzV.mjs","names":[],"sources":["../src/models/task.ts"],"sourcesContent":["/**\n * Domain types for the file-backed task store.\n *\n * The on-disk document is the durable source of truth (unlike rpiv-todo, which\n * replayed state from the transcript). Every field here round-trips through\n * JSON, so nothing may hold non-serializable values.\n */\n\nimport type { InlineAgent } from '@agimon-ai/po-core/delegation';\n\nexport type TaskStatus = 'pending' | 'in_progress' | 'completed' | 'failed' | 'deleted';\n\nexport const DELETED_STATUS: TaskStatus = 'deleted';\n\nexport type TaskAction = 'upsert' | 'list' | 'get' | 'delete' | 'clear' | 'assign' | 'cancel';\n\nexport type DelegationState = 'requested' | 'running' | 'completed' | 'failed' | 'cancelled';\n\n/** Terminal result of a delegated subagent run, copied off the delegation response. */\nexport interface DelegationResult {\n status: string;\n output?: string;\n outputPath?: string;\n sessionFile?: string;\n error?: string;\n durationMs?: number;\n toolCount?: number;\n}\n\n/**\n * Delegation bookkeeping attached to a task that was handed to a subagent.\n *\n * `pid` is the harness process that owns the run: it is the only way to tell an\n * genuinely-running delegation from one orphaned by a harness crash, since the\n * child dies with its parent but the file survives.\n */\nexport interface TaskDelegation {\n requestId: string;\n agent: string;\n /** The named run identity minted by the delegation provider, not the agent definition. */\n identity?: string;\n state: DelegationState;\n sessionId?: string;\n pid?: number;\n runId?: string;\n model?: string;\n startedAt?: string;\n endedAt?: string;\n result?: DelegationResult;\n}\n\nexport interface Task {\n id: number;\n subject: string;\n description?: string;\n activeForm?: string;\n status: TaskStatus;\n blockedBy?: number[];\n owner?: string;\n metadata?: Record<string, unknown>;\n createdAt?: string;\n updatedAt?: string;\n delegation?: TaskDelegation;\n}\n\nexport const STORE_SCHEMA_VERSION = 1;\n\n/** The complete on-disk document. `rev` increments on every committed write. */\nexport interface TaskDocument {\n version: number;\n rev: number;\n nextId: number;\n tasks: Task[];\n}\n\nexport function emptyDocument(): TaskDocument {\n return { version: STORE_SCHEMA_VERSION, rev: 0, nextId: 1, tasks: [] };\n}\n\n/**\n * A dependency target inside an upsert item: an existing task id, or the `ref`\n * of a task created earlier in the same call.\n *\n * Refs must start with a letter (see `REF_PATTERN`), so a ref is structurally\n * unconfusable with a stringified id and the discrimination is just `typeof`.\n */\nexport type DepToken = number | string;\n\n/**\n * One entry of an `upsert` call. No `id` creates a task; an `id` updates one.\n *\n * `blockedBy` (absolute set) is create-only and `addBlockedBy`/`removeBlockedBy`\n * (additive merge) are update-only, matching the split the two former actions\n * had. A field used against the wrong kind fails that item rather than being\n * silently ignored.\n */\nexport interface TaskItemMutation {\n id?: number;\n ref?: string;\n subject?: string;\n description?: string;\n activeForm?: string;\n status?: TaskStatus;\n blockedBy?: DepToken[];\n addBlockedBy?: DepToken[];\n removeBlockedBy?: DepToken[];\n owner?: string;\n metadata?: Record<string, unknown>;\n}\n\n/**\n * What one upsert item did. `index` is its position in the request array, so a\n * model reading a partial result can tell which entries still need resending.\n *\n * `message` is unprefixed: the `item[N] failed:` framing belongs to the\n * formatter, because the Task Space overlay shows this text on its own.\n */\nexport type UpsertItemOutcome =\n | {\n index: number;\n kind: 'created';\n id: number;\n subject: string;\n status: TaskStatus;\n ref?: string;\n blockedBy?: number[];\n }\n | { index: number; kind: 'updated'; id: number; fromStatus: TaskStatus; toStatus: TaskStatus }\n | { index: number; kind: 'unchanged'; id: number; status: TaskStatus }\n | { index: number; kind: 'failed'; message: string; id?: number; ref?: string };\n\n/** Which tasks an upsert touched, so renderResult names them instead of guessing. */\nexport interface UpsertSummary {\n /** Ids of applied entries, in request order. A failed entry contributes nothing. */\n applied: number[];\n failed: number;\n}\n\n/** One task-to-agent handoff inside a native assignment batch. */\nexport interface TaskAssignment {\n id: number;\n agent: string;\n inlineAgent?: InlineAgent;\n instructions?: string;\n relevantFiles?: string[];\n priorFindings?: string;\n model?: string;\n context?: 'fresh' | 'fork';\n}\n\n/** Which assignment entries started, so renderResult can show one consolidated batch. */\nexport interface AssignmentSummary {\n /** Ids of successful entries, in request order. A failed entry contributes nothing. */\n assigned: number[];\n failed: number;\n}\n\n/**\n * Open-shape input bag the reducer accepts. The index signature lets the\n * runtime pass a TypeBox `Static<typeof TaskParamsSchema>` through without\n * casting each field.\n *\n * Per-task fields live on `tasks[]`, not here: a top-level `subject` or\n * `status` would be ambiguous once one call can carry many tasks.\n */\nexport interface TaskMutationParams {\n [key: string]: unknown;\n tasks?: TaskItemMutation[];\n /** `assign` only: independent task-to-agent handoffs dispatched by one tool call. */\n assignments?: TaskAssignment[];\n /** `list` filter only. To set a status, upsert the task by id. */\n status?: TaskStatus;\n /** `get`, `delete`, and `cancel` only. Assign ids live in `assignments[]`. */\n id?: number;\n includeDeleted?: boolean;\n}\n\n/** Snapshot returned under a tool result's `details` for renderResult. */\nexport interface TaskDetails {\n action: TaskAction;\n params: Record<string, unknown>;\n tasks: Task[];\n nextId: number;\n rev: number;\n error?: string;\n upsert?: UpsertSummary;\n assignment?: AssignmentSummary;\n}\n\n/**\n * A delegation is \"live\" while the owning run may still produce a response.\n *\n * Takes the delegation shape rather than `Task` so the cockpit's `WebTask`,\n * which carries the state as a plain string, answers the question the same way\n * the store does.\n */\nexport function isDelegationActive(task: { delegation?: { state?: string } }): boolean {\n const state = task.delegation?.state;\n return state === 'requested' || state === 'running';\n}\n"],"mappings":";AAYA,MAAa,iBAA6B;AAqD1C,MAAa,uBAAuB;AAUpC,SAAgB,gBAA8B;CAC5C,OAAO;EAAE,SAAA;EAA+B,KAAK;EAAG,QAAQ;EAAG,OAAO,CAAC;CAAE;AACvE;;;;;;;;AAuHA,SAAgB,mBAAmB,MAAoD;CACrF,MAAM,QAAQ,KAAK,YAAY;CAC/B,OAAO,UAAU,eAAe,UAAU;AAC5C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { s as Task } from "./task-
|
|
1
|
+
import { s as Task } from "./task-DdTKZNtU.mjs";
|
|
2
2
|
//#region src/models/taskGraph.d.ts
|
|
3
3
|
/** True when a non-empty list has no visible work left to finish. */
|
|
4
4
|
declare function isTaskListComplete(taskList: readonly Task[]): boolean;
|
|
@@ -22,4 +22,4 @@ declare function unresolvedBlockers(taskList: readonly Task[], task: Task): numb
|
|
|
22
22
|
declare function isBlocked(taskList: readonly Task[], task: Task): boolean;
|
|
23
23
|
//#endregion
|
|
24
24
|
export { unresolvedBlockers as a, isTaskListComplete as i, detectCycle as n, isBlocked as r, deriveBlocks as t };
|
|
25
|
-
//# sourceMappingURL=taskGraph-
|
|
25
|
+
//# sourceMappingURL=taskGraph-CB8ffMCz.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taskGraph-
|
|
1
|
+
{"version":3,"file":"taskGraph-CB8ffMCz.d.mts","names":[],"sources":["../src/models/taskGraph.ts"],"mappings":";;;iBAMgB,mBAAmB,mBAAmB;;;;;;;iBAWtC,YAAY,mBAAmB,QAAQ,gBAAgB;;iBA+BvD,aAAa,mBAAmB,SAAS;;;;;;;;iBAmBzC,mBAAmB,mBAAmB,QAAQ,MAAM;iBAQpD,UAAU,mBAAmB,QAAQ,MAAM"}
|