@agimon-ai/po-task 0.0.0-alpha.2 → 0.0.0-alpha.21
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 +10 -10
- package/dist/apiContracts.cjs +1 -1
- package/dist/apiContracts.cjs.map +1 -1
- package/dist/apiContracts.d.mts +18 -18
- package/dist/apiContracts.mjs +1 -1
- package/dist/apiContracts.mjs.map +1 -1
- package/dist/{config-CdX-Bv8q.cjs → config-BC-bztyx.cjs} +8 -8
- package/dist/config-BC-bztyx.cjs.map +1 -0
- package/dist/{config-CFSs3iku.mjs → config-BTadoGeF.mjs} +8 -8
- package/dist/config-BTadoGeF.mjs.map +1 -0
- package/dist/config.cjs +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +1 -2
- package/dist/{delegation-CdMqOZB4.mjs → delegation-Dsqf7fUM.mjs} +11 -11
- package/dist/delegation-Dsqf7fUM.mjs.map +1 -0
- package/dist/{delegation-DsnKjMbJ.cjs → delegation-frvEXhIz.cjs} +10 -10
- package/dist/delegation-frvEXhIz.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-ui.mjs.map +1 -1
- package/dist/extensions/mcp.cjs +23 -23
- package/dist/extensions/mcp.cjs.map +1 -1
- package/dist/extensions/mcp.d.mts +1 -1
- package/dist/extensions/mcp.mjs +23 -23
- package/dist/extensions/mcp.mjs.map +1 -1
- package/dist/extensions/native.mjs +14 -0
- package/dist/extensions/native.mjs.map +1 -1
- package/dist/extensions/server.cjs +92 -32
- 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 +96 -36
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/extensions/web.mjs +28 -28
- package/dist/extensions/web.mjs.map +1 -1
- package/dist/{index-teIf67qQ.d.mts → index-B9QNwUBr.d.mts} +8 -8
- package/dist/{index-teIf67qQ.d.mts.map → index-B9QNwUBr.d.mts.map} +1 -1
- package/dist/{index-B-3sCF2S.d.mts → index-BsZ8DxpJ.d.mts} +7 -7
- package/dist/{index-B-3sCF2S.d.mts.map → index-BsZ8DxpJ.d.mts.map} +1 -1
- package/dist/{index-XY9VPmfm.d.mts → index-CA4Opp4r.d.mts} +2 -2
- package/dist/{index-XY9VPmfm.d.mts.map → index-CA4Opp4r.d.mts.map} +1 -1
- package/dist/{index-Dvb8X_qB.d.mts → index-qQGWsPum.d.mts} +2 -2
- package/dist/index-qQGWsPum.d.mts.map +1 -0
- package/dist/index.cjs +4 -4
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +4 -4
- package/dist/{logSinkTelemetry-B23qGiP-.cjs → logSinkTelemetry-BGb8WQBz.cjs} +4 -4
- package/dist/logSinkTelemetry-BGb8WQBz.cjs.map +1 -0
- package/dist/{logSinkTelemetry-BMBsC54p.mjs → logSinkTelemetry-BhbKdn-x.mjs} +5 -5
- package/dist/logSinkTelemetry-BhbKdn-x.mjs.map +1 -0
- package/dist/logSinkTelemetry.cjs +2 -2
- package/dist/logSinkTelemetry.d.mts +3 -3
- package/dist/logSinkTelemetry.mjs +2 -2
- package/dist/{paths-Cah1vFGv.mjs → paths-DajceJig.mjs} +4 -4
- package/dist/paths-DajceJig.mjs.map +1 -0
- package/dist/{paths-CSya2l9_.cjs → paths-P-XvOUuH.cjs} +4 -4
- package/dist/paths-P-XvOUuH.cjs.map +1 -0
- package/dist/storeInvariants.mjs +1 -2
- package/dist/storePaths.cjs +1 -1
- package/dist/storePaths.d.mts +1 -1
- package/dist/storePaths.mjs +1 -2
- package/dist/storeProcessLiveness.mjs +1 -2
- package/dist/storeReconcile.mjs +1 -2
- package/dist/storeReducer.mjs +1 -2
- package/dist/storeTaskGraph.mjs +1 -2
- package/dist/storeTaskStore.cjs +1 -1
- package/dist/storeTaskStore.d.mts +1 -1
- package/dist/storeTaskStore.mjs +1 -2
- package/dist/storeTypes.mjs +1 -2
- package/dist/{task-Dhta7JyA.d.mts → task-4HeGAS8o.d.mts} +6 -6
- package/dist/{task-Dhta7JyA.d.mts.map → task-4HeGAS8o.d.mts.map} +1 -1
- package/dist/{taskStore-pAJ971Ml.mjs → taskStore-BAi54FKL.mjs} +4 -4
- package/dist/{taskStore-pAJ971Ml.mjs.map → taskStore-BAi54FKL.mjs.map} +1 -1
- package/dist/{taskStore-DjU60rMm.cjs → taskStore-C4vcUOzA.cjs} +4 -4
- package/dist/{taskStore-DjU60rMm.cjs.map → taskStore-C4vcUOzA.cjs.map} +1 -1
- package/dist/telemetry-DYfgUFF8.d.mts +35 -0
- package/dist/telemetry-DYfgUFF8.d.mts.map +1 -0
- package/dist/telemetry-gEGWTaMI.mjs +25 -0
- package/dist/telemetry-gEGWTaMI.mjs.map +1 -0
- package/dist/telemetry-x3JxCA5K.cjs +30 -0
- package/dist/telemetry-x3JxCA5K.cjs.map +1 -0
- package/dist/toolPromptGuidelines.cjs +1 -1
- package/dist/toolPromptGuidelines.cjs.map +1 -1
- package/dist/toolPromptGuidelines.mjs +1 -1
- package/dist/toolPromptGuidelines.mjs.map +1 -1
- package/dist/toolResponseEnvelope.mjs +1 -2
- package/dist/toolSchema.d.mts +1 -1
- package/dist/toolSchema.mjs +1 -2
- package/package.json +20 -19
- package/dist/config-CFSs3iku.mjs.map +0 -1
- package/dist/config-CdX-Bv8q.cjs.map +0 -1
- package/dist/delegation-CdMqOZB4.mjs.map +0 -1
- package/dist/delegation-DsnKjMbJ.cjs.map +0 -1
- package/dist/index-Dvb8X_qB.d.mts.map +0 -1
- package/dist/logSinkTelemetry-B23qGiP-.cjs.map +0 -1
- package/dist/logSinkTelemetry-BMBsC54p.mjs.map +0 -1
- package/dist/paths-CSya2l9_.cjs.map +0 -1
- package/dist/paths-Cah1vFGv.mjs.map +0 -1
- package/dist/telemetry-Ca0I3Tqo.cjs +0 -30
- package/dist/telemetry-Ca0I3Tqo.cjs.map +0 -1
- package/dist/telemetry-DyS44zAD.mjs +0 -25
- package/dist/telemetry-DyS44zAD.mjs.map +0 -1
- package/dist/telemetry-FMGRovb4.d.mts +0 -35
- package/dist/telemetry-FMGRovb4.d.mts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taskStore-DjU60rMm.cjs","names":["emptyDocument","canonicalizeTasks","resolveStorePath","fs","TASK_EVENT","path","tempPathFor","lockPathFor","isProcessAlive"],"sources":["../src/services/taskStore/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { emptyDocument, STORE_SCHEMA_VERSION, type Task, type TaskDocument } from '../../models/task';\nimport { TASK_EVENT, type TaskFailureReporter } from '../../types/telemetry';\nimport { canonicalizeTasks } from '../invariants';\nimport { lockPathFor, resolveStorePath, STORE_PATH_ENV, tempPathFor } from '../paths';\nimport { isProcessAlive } from '../processLiveness';\n\nconst LOCK_TIMEOUT_MS = 2000;\nconst LOCK_STALE_MS = 10_000;\nconst LOCK_RETRY_BASE_MS = 10;\nconst LOCK_RETRY_MAX_MS = 60;\nconst UTF8_ENCODING = 'utf8';\nconst MISSING_FILE_CODE = 'ENOENT';\nconst LOCK_EXISTS_CODE = 'EEXIST';\nconst STORE_PATH_ATTRIBUTE = 'store.path';\n\nexport interface TaskStoreOptions {\n cwd?: string;\n env?: Readonly<Record<string, string | undefined>>;\n storePath?: string;\n /** How long to wait for the advisory lock before proceeding lock-free. */\n lockTimeoutMs?: number;\n /** Where swallowed failures go, so silent degradation stays visible. */\n report?: TaskFailureReporter;\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Coerce arbitrary parsed JSON into a valid document.\n *\n * A corrupt or truncated store must not take the session down: the worst\n * acceptable outcome is starting from an empty list, never a crash on startup.\n */\nfunction normalizeDocument(parsed: unknown): TaskDocument {\n if (!parsed || typeof parsed !== 'object') return emptyDocument();\n const candidate = parsed as Partial<TaskDocument>;\n if (!Array.isArray(candidate.tasks)) return emptyDocument();\n\n const tasks = canonicalizeTasks(\n candidate.tasks.filter(\n (task): task is Task => Boolean(task) && typeof task === 'object' && typeof (task as Task).id === 'number',\n ),\n );\n const maxId = tasks.reduce((max, task) => Math.max(max, task.id), 0);\n return {\n version: typeof candidate.version === 'number' ? candidate.version : STORE_SCHEMA_VERSION,\n rev: typeof candidate.rev === 'number' ? candidate.rev : 0,\n nextId: typeof candidate.nextId === 'number' && candidate.nextId > maxId ? candidate.nextId : maxId + 1,\n tasks,\n };\n}\n\n/**\n * File-backed task store shared by one root session and its delegated children.\n *\n * Durability model: the JSON file is the source of truth. Mutations are\n * read-modify-write under an advisory lock so concurrent delegated processes\n * cannot clobber each other, and writes land via temp-file rename so a\n * crash mid-write can never leave a partial document behind.\n */\nexport class TaskStore {\n storePath: string;\n\n private readonly cwd: string;\n private readonly env: Readonly<Record<string, string | undefined>>;\n private cached: TaskDocument = emptyDocument();\n private readonly listeners = new Set<(document: TaskDocument) => void>();\n private readonly lockTimeoutMs: number;\n private readonly report?: TaskFailureReporter;\n\n constructor(options: TaskStoreOptions = {}) {\n this.cwd = options.cwd ?? process.cwd();\n this.env = options.env ?? process.env;\n this.storePath = options.storePath ?? resolveStorePath(this.cwd, this.env);\n this.lockTimeoutMs = options.lockTimeoutMs ?? LOCK_TIMEOUT_MS;\n this.report = options.report;\n }\n\n /** Bind a default store to the current session tree before reading it. */\n configureSession(sessionKey: string): void {\n if (this.env[STORE_PATH_ENV]?.trim()) return;\n this.storePath = resolveStorePath(this.cwd, this.env, sessionKey);\n this.cached = emptyDocument();\n }\n\n /** Last document read from disk, without hitting the filesystem. */\n get snapshot(): TaskDocument {\n return this.cached;\n }\n\n read(): TaskDocument {\n try {\n const raw = fs.readFileSync(this.storePath, UTF8_ENCODING);\n this.cached = normalizeDocument(JSON.parse(raw));\n } catch (error) {\n // A missing file is the normal state before the first write. Anything\n // else means the task list just silently became empty, which is worth a\n // record: unreadable or corrupt JSON looks identical to \"no tasks yet\".\n if ((error as NodeJS.ErrnoException).code !== MISSING_FILE_CODE) {\n this.report?.error(TASK_EVENT.storeReadFailed, error, { [STORE_PATH_ATTRIBUTE]: this.storePath });\n }\n this.cached = emptyDocument();\n }\n return this.cached;\n }\n\n async readAsync(\n shouldApply: () => boolean = () => true,\n onReadError?: (error: unknown) => void,\n ): Promise<TaskDocument> {\n const storePath = this.storePath;\n const document = await this.readDocumentAsync(storePath, onReadError);\n if (!shouldApply()) return document;\n this.cached = document;\n return document;\n }\n\n private async readDocumentAsync(\n storePath: string = this.storePath,\n onReadError?: (error: unknown) => void,\n ): Promise<TaskDocument> {\n try {\n const raw = await fs.promises.readFile(storePath, UTF8_ENCODING);\n return normalizeDocument(JSON.parse(raw));\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== MISSING_FILE_CODE) {\n this.report?.error(TASK_EVENT.storeReadFailed, error, { [STORE_PATH_ATTRIBUTE]: storePath });\n try {\n onReadError?.(error);\n } catch {\n // Diagnostic failures must not change fail-open reads.\n }\n }\n return emptyDocument();\n }\n }\n\n /**\n * Apply a mutation under the store lock.\n *\n * `mutate` receives the freshest on-disk document and returns either the next\n * document to commit or `undefined` for a read-only action (list/get), which\n * skips the write entirely so queries never bump `rev`.\n */\n async mutate<T>(\n mutate: (document: TaskDocument) => { document?: TaskDocument; value: T },\n ): Promise<{ document: TaskDocument; value: T }> {\n const release = await this.acquireLock();\n const outcome = (() => {\n try {\n const current = this.read();\n const mutation = mutate(current);\n if (!mutation.document) {\n return { result: { document: current, value: mutation.value } };\n }\n const committed = this.write(mutation.document);\n return {\n result: { document: committed, value: mutation.value },\n notification: committed,\n };\n } finally {\n release();\n }\n })();\n if (outcome.notification) {\n this.notifyCommitted(outcome.notification);\n }\n return outcome.result;\n }\n\n private notifyCommitted(committed: TaskDocument): void {\n for (const listener of this.listeners) {\n try {\n listener(committed);\n } catch (error) {\n this.report?.error(TASK_EVENT.storeListenerFailed, error, { [STORE_PATH_ATTRIBUTE]: this.storePath });\n }\n }\n }\n\n private write(document: TaskDocument): TaskDocument {\n const next: TaskDocument = { ...document, version: STORE_SCHEMA_VERSION, rev: document.rev + 1 };\n fs.mkdirSync(path.dirname(this.storePath), { recursive: true });\n const temp = tempPathFor(this.storePath);\n fs.writeFileSync(temp, `${JSON.stringify(next, undefined, 2)}\\n`, UTF8_ENCODING);\n fs.renameSync(temp, this.storePath);\n this.cached = next;\n return next;\n }\n\n private async acquireLock(): Promise<() => void> {\n const lockPath = lockPathFor(this.storePath);\n fs.mkdirSync(path.dirname(this.storePath), { recursive: true });\n const deadline = Date.now() + this.lockTimeoutMs;\n\n for (;;) {\n try {\n const handle = fs.openSync(lockPath, 'wx');\n fs.writeSync(handle, JSON.stringify({ pid: process.pid, time: Date.now() }));\n fs.closeSync(handle);\n return () => fs.rmSync(lockPath, { force: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== LOCK_EXISTS_CODE) throw error;\n // The deadline is checked before breaking a stale lock so a peer that\n // keeps recreating one cannot spin this loop without bound.\n if (Date.now() >= deadline) {\n // Proceeding lock-free beats stalling the agent: the rename is atomic,\n // so the worst case is a lost concurrent update, not a corrupt file.\n // Reported because a lost update here can strand a delegation.\n this.report?.warn(\n TASK_EVENT.storeLockTimeout,\n new Error(`Task store lock still held after ${this.lockTimeoutMs}ms; proceeding without it`),\n { [STORE_PATH_ATTRIBUTE]: this.storePath },\n );\n return () => {};\n }\n // Clearing a dead holder's lock still goes through the backoff. Yielding\n // on every iteration is what stops a peer that keeps recreating the\n // lock from turning this into a spin.\n this.breakStaleLock(lockPath);\n await sleep(LOCK_RETRY_BASE_MS + Math.random() * LOCK_RETRY_MAX_MS);\n }\n }\n }\n\n /** Remove a lock left behind by a dead process or one held implausibly long. */\n private breakStaleLock(lockPath: string): boolean {\n try {\n const holder = JSON.parse(fs.readFileSync(lockPath, UTF8_ENCODING)) as { pid?: number; time?: number };\n const expired = typeof holder.time === 'number' && Date.now() - holder.time > LOCK_STALE_MS;\n const dead = typeof holder.pid === 'number' && !isProcessAlive(holder.pid);\n if (!expired && !dead) return false;\n fs.unlinkSync(lockPath);\n return true;\n } catch (error) {\n // Losing the race to another breaker is normal; a persistent failure here\n // shows up as the lock timeout above, so this stays a warning.\n if ((error as NodeJS.ErrnoException).code !== MISSING_FILE_CODE) {\n this.report?.warn(TASK_EVENT.storeLockBreakFailed, error, { [STORE_PATH_ATTRIBUTE]: lockPath });\n }\n return false;\n }\n }\n\n /**\n * Listen for commits made through this store instance.\n *\n * Live cross-process updates use the owning session's direct event bus. This\n * listener publishes local commits to that bus and never watches the filesystem.\n */\n onExternalChange(listener: (document: TaskDocument) => void): () => void {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n }\n\n dispose(): void {\n this.listeners.clear();\n }\n}\n"],"mappings":";;;;;;;;;;AASA,MAAM,kBAAkB;AACxB,MAAM,gBAAgB;AACtB,MAAM,qBAAqB;AAC3B,MAAM,oBAAoB;AAC1B,MAAM,gBAAgB;AACtB,MAAM,oBAAoB;AAC1B,MAAM,mBAAmB;AACzB,MAAM,uBAAuB;AAY7B,SAAS,MAAM,IAA2B;CACxC,OAAO,IAAI,SAAS,YAAY,WAAW,SAAS,EAAE,CAAC;AACzD;;;;;;;AAQA,SAAS,kBAAkB,QAA+B;CACxD,IAAI,CAAC,UAAU,OAAO,WAAW,UAAU,OAAOA,aAAAA,cAAc;CAChE,MAAM,YAAY;CAClB,IAAI,CAAC,MAAM,QAAQ,UAAU,KAAK,GAAG,OAAOA,aAAAA,cAAc;CAE1D,MAAM,QAAQC,mBAAAA,kBACZ,UAAU,MAAM,QACb,SAAuB,QAAQ,IAAI,KAAK,OAAO,SAAS,YAAY,OAAQ,KAAc,OAAO,QACpG,CACF;CACA,MAAM,QAAQ,MAAM,QAAQ,KAAK,SAAS,KAAK,IAAI,KAAK,KAAK,EAAE,GAAG,CAAC;CACnE,OAAO;EACL,SAAS,OAAO,UAAU,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Y,KAAK,IAAI,IAAI,OAAO,OAAO;GAC9E,MAAM,OAAO,OAAO,OAAO,QAAQ,YAAY,CAACK,wBAAAA,eAAe,OAAO,GAAG;GACzE,IAAI,CAAC,WAAW,CAAC,MAAM,OAAO;GAC9B,QAAA,QAAG,WAAW,QAAQ;GACtB,OAAO;EACT,SAAS,OAAO;GAGd,IAAK,MAAgC,SAAS,mBAC5C,KAAK,QAAQ,KAAKJ,kBAAAA,WAAW,sBAAsB,OAAO,GAAG,uBAAuB,SAAS,CAAC;GAEhG,OAAO;EACT;CACF;;;;;;;CAQA,iBAAiB,UAAwD;EACvE,KAAK,UAAU,IAAI,QAAQ;EAC3B,aAAa,KAAK,UAAU,OAAO,QAAQ;CAC7C;CAEA,UAAgB;EACd,KAAK,UAAU,MAAM;CACvB;AACF"}
|
|
1
|
+
{"version":3,"file":"taskStore-C4vcUOzA.cjs","names":["emptyDocument","canonicalizeTasks","resolveStorePath","fs","TASK_EVENT","path","tempPathFor","lockPathFor","isProcessAlive"],"sources":["../src/services/taskStore/index.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { emptyDocument, STORE_SCHEMA_VERSION, type Task, type TaskDocument } from '../../models/task';\nimport { TASK_EVENT, type TaskFailureReporter } from '../../types/telemetry';\nimport { canonicalizeTasks } from '../invariants';\nimport { lockPathFor, resolveStorePath, STORE_PATH_ENV, tempPathFor } from '../paths';\nimport { isProcessAlive } from '../processLiveness';\n\nconst LOCK_TIMEOUT_MS = 2000;\nconst LOCK_STALE_MS = 10_000;\nconst LOCK_RETRY_BASE_MS = 10;\nconst LOCK_RETRY_MAX_MS = 60;\nconst UTF8_ENCODING = 'utf8';\nconst MISSING_FILE_CODE = 'ENOENT';\nconst LOCK_EXISTS_CODE = 'EEXIST';\nconst STORE_PATH_ATTRIBUTE = 'store.path';\n\nexport interface TaskStoreOptions {\n cwd?: string;\n env?: Readonly<Record<string, string | undefined>>;\n storePath?: string;\n /** How long to wait for the advisory lock before proceeding lock-free. */\n lockTimeoutMs?: number;\n /** Where swallowed failures go, so silent degradation stays visible. */\n report?: TaskFailureReporter;\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Coerce arbitrary parsed JSON into a valid document.\n *\n * A corrupt or truncated store must not take the session down: the worst\n * acceptable outcome is starting from an empty list, never a crash on startup.\n */\nfunction normalizeDocument(parsed: unknown): TaskDocument {\n if (!parsed || typeof parsed !== 'object') return emptyDocument();\n const candidate = parsed as Partial<TaskDocument>;\n if (!Array.isArray(candidate.tasks)) return emptyDocument();\n\n const tasks = canonicalizeTasks(\n candidate.tasks.filter(\n (task): task is Task => Boolean(task) && typeof task === 'object' && typeof (task as Task).id === 'number',\n ),\n );\n const maxId = tasks.reduce((max, task) => Math.max(max, task.id), 0);\n return {\n version: typeof candidate.version === 'number' ? candidate.version : STORE_SCHEMA_VERSION,\n rev: typeof candidate.rev === 'number' ? candidate.rev : 0,\n nextId: typeof candidate.nextId === 'number' && candidate.nextId > maxId ? candidate.nextId : maxId + 1,\n tasks,\n };\n}\n\n/**\n * File-backed task store shared by one root session and its delegated children.\n *\n * Durability model: the JSON file is the source of truth. Mutations are\n * read-modify-write under an advisory lock so concurrent delegated processes\n * cannot clobber each other, and writes land via temp-file rename so a\n * crash mid-write can never leave a partial document behind.\n */\nexport class TaskStore {\n storePath: string;\n\n private readonly cwd: string;\n private readonly env: Readonly<Record<string, string | undefined>>;\n private cached: TaskDocument = emptyDocument();\n private readonly listeners = new Set<(document: TaskDocument) => void>();\n private readonly lockTimeoutMs: number;\n private readonly report?: TaskFailureReporter;\n\n constructor(options: TaskStoreOptions = {}) {\n this.cwd = options.cwd ?? process.cwd();\n this.env = options.env ?? process.env;\n this.storePath = options.storePath ?? resolveStorePath(this.cwd, this.env);\n this.lockTimeoutMs = options.lockTimeoutMs ?? LOCK_TIMEOUT_MS;\n this.report = options.report;\n }\n\n /** Bind a default store to the current session tree before reading it. */\n configureSession(sessionKey: string): void {\n if (this.env[STORE_PATH_ENV]?.trim()) return;\n this.storePath = resolveStorePath(this.cwd, this.env, sessionKey);\n this.cached = emptyDocument();\n }\n\n /** Last document read from disk, without hitting the filesystem. */\n get snapshot(): TaskDocument {\n return this.cached;\n }\n\n read(): TaskDocument {\n try {\n const raw = fs.readFileSync(this.storePath, UTF8_ENCODING);\n this.cached = normalizeDocument(JSON.parse(raw));\n } catch (error) {\n // A missing file is the normal state before the first write. Anything\n // else means the task list just silently became empty, which is worth a\n // record: unreadable or corrupt JSON looks identical to \"no tasks yet\".\n if ((error as NodeJS.ErrnoException).code !== MISSING_FILE_CODE) {\n this.report?.error(TASK_EVENT.storeReadFailed, error, { [STORE_PATH_ATTRIBUTE]: this.storePath });\n }\n this.cached = emptyDocument();\n }\n return this.cached;\n }\n\n async readAsync(\n shouldApply: () => boolean = () => true,\n onReadError?: (error: unknown) => void,\n ): Promise<TaskDocument> {\n const storePath = this.storePath;\n const document = await this.readDocumentAsync(storePath, onReadError);\n if (!shouldApply()) return document;\n this.cached = document;\n return document;\n }\n\n private async readDocumentAsync(\n storePath: string = this.storePath,\n onReadError?: (error: unknown) => void,\n ): Promise<TaskDocument> {\n try {\n const raw = await fs.promises.readFile(storePath, UTF8_ENCODING);\n return normalizeDocument(JSON.parse(raw));\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== MISSING_FILE_CODE) {\n this.report?.error(TASK_EVENT.storeReadFailed, error, { [STORE_PATH_ATTRIBUTE]: storePath });\n try {\n onReadError?.(error);\n } catch {\n // Diagnostic failures must not change fail-open reads.\n }\n }\n return emptyDocument();\n }\n }\n\n /**\n * Apply a mutation under the store lock.\n *\n * `mutate` receives the freshest on-disk document and returns either the next\n * document to commit or `undefined` for a read-only action (list/get), which\n * skips the write entirely so queries never bump `rev`.\n */\n async mutate<T>(\n mutate: (document: TaskDocument) => { document?: TaskDocument; value: T },\n ): Promise<{ document: TaskDocument; value: T }> {\n const release = await this.acquireLock();\n const outcome = (() => {\n try {\n const current = this.read();\n const mutation = mutate(current);\n if (!mutation.document) {\n return { result: { document: current, value: mutation.value } };\n }\n const committed = this.write(mutation.document);\n return {\n result: { document: committed, value: mutation.value },\n notification: committed,\n };\n } finally {\n release();\n }\n })();\n if (outcome.notification) {\n this.notifyCommitted(outcome.notification);\n }\n return outcome.result;\n }\n\n private notifyCommitted(committed: TaskDocument): void {\n for (const listener of this.listeners) {\n try {\n listener(committed);\n } catch (error) {\n this.report?.error(TASK_EVENT.storeListenerFailed, error, { [STORE_PATH_ATTRIBUTE]: this.storePath });\n }\n }\n }\n\n private write(document: TaskDocument): TaskDocument {\n const next: TaskDocument = { ...document, version: STORE_SCHEMA_VERSION, rev: document.rev + 1 };\n fs.mkdirSync(path.dirname(this.storePath), { recursive: true });\n const temp = tempPathFor(this.storePath);\n fs.writeFileSync(temp, `${JSON.stringify(next, undefined, 2)}\\n`, UTF8_ENCODING);\n fs.renameSync(temp, this.storePath);\n this.cached = next;\n return next;\n }\n\n private async acquireLock(): Promise<() => void> {\n const lockPath = lockPathFor(this.storePath);\n fs.mkdirSync(path.dirname(this.storePath), { recursive: true });\n const deadline = Date.now() + this.lockTimeoutMs;\n\n for (;;) {\n try {\n const handle = fs.openSync(lockPath, 'wx');\n fs.writeSync(handle, JSON.stringify({ pid: process.pid, time: Date.now() }));\n fs.closeSync(handle);\n return () => fs.rmSync(lockPath, { force: true });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== LOCK_EXISTS_CODE) throw error;\n // The deadline is checked before breaking a stale lock so a peer that\n // keeps recreating one cannot spin this loop without bound.\n if (Date.now() >= deadline) {\n // Proceeding lock-free beats stalling the agent: the rename is atomic,\n // so the worst case is a lost concurrent update, not a corrupt file.\n // Reported because a lost update here can strand a delegation.\n this.report?.warn(\n TASK_EVENT.storeLockTimeout,\n new Error(`Task store lock still held after ${this.lockTimeoutMs}ms; proceeding without it`),\n { [STORE_PATH_ATTRIBUTE]: this.storePath },\n );\n return () => {};\n }\n // Clearing a dead holder's lock still goes through the backoff. Yielding\n // on every iteration is what stops a peer that keeps recreating the\n // lock from turning this into a spin.\n this.breakStaleLock(lockPath);\n await sleep(LOCK_RETRY_BASE_MS + Math.random() * LOCK_RETRY_MAX_MS);\n }\n }\n }\n\n /** Remove a lock left behind by a dead process or one held implausibly long. */\n private breakStaleLock(lockPath: string): boolean {\n try {\n const holder = JSON.parse(fs.readFileSync(lockPath, UTF8_ENCODING)) as { pid?: number; time?: number };\n const expired = typeof holder.time === 'number' && Date.now() - holder.time > LOCK_STALE_MS;\n const dead = typeof holder.pid === 'number' && !isProcessAlive(holder.pid);\n if (!expired && !dead) return false;\n fs.unlinkSync(lockPath);\n return true;\n } catch (error) {\n // Losing the race to another breaker is normal; a persistent failure here\n // shows up as the lock timeout above, so this stays a warning.\n if ((error as NodeJS.ErrnoException).code !== MISSING_FILE_CODE) {\n this.report?.warn(TASK_EVENT.storeLockBreakFailed, error, { [STORE_PATH_ATTRIBUTE]: lockPath });\n }\n return false;\n }\n }\n\n /**\n * Listen for commits made through this store instance.\n *\n * Live cross-process updates use the owning session's direct event bus. This\n * listener publishes local commits to that bus and never watches the filesystem.\n */\n onExternalChange(listener: (document: TaskDocument) => void): () => void {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n }\n\n dispose(): void {\n this.listeners.clear();\n }\n}\n"],"mappings":";;;;;;;;;;AASA,MAAM,kBAAkB;AACxB,MAAM,gBAAgB;AACtB,MAAM,qBAAqB;AAC3B,MAAM,oBAAoB;AAC1B,MAAM,gBAAgB;AACtB,MAAM,oBAAoB;AAC1B,MAAM,mBAAmB;AACzB,MAAM,uBAAuB;AAY7B,SAAS,MAAM,IAA2B;CACxC,OAAO,IAAI,SAAS,YAAY,WAAW,SAAS,EAAE,CAAC;AACzD;;;;;;;AAQA,SAAS,kBAAkB,QAA+B;CACxD,IAAI,CAAC,UAAU,OAAO,WAAW,UAAU,OAAOA,aAAAA,cAAc;CAChE,MAAM,YAAY;CAClB,IAAI,CAA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A0B,GAC3F,GAAG,uBAAuB,KAAK,UAAU,CAC3C;IACA,aAAa,CAAC;GAChB;GAIA,KAAK,eAAe,QAAQ;GAC5B,MAAM,MAAM,qBAAqB,KAAK,OAAO,IAAI,iBAAiB;EACpE;CAEJ;;CAGA,eAAuB,UAA2B;EAChD,IAAI;GACF,MAAM,SAAS,KAAK,MAAMD,QAAAA,QAAG,aAAa,UAAU,aAAa,CAAC;GAClE,MAAM,UAAU,OAAO,OAAO,SAAS,YAAY,KAAK,IAAI,IAAI,OAAO,OAAO;GAC9E,MAAM,OAAO,OAAO,OAAO,QAAQ,YAAY,CAACK,wBAAAA,eAAe,OAAO,GAAG;GACzE,IAAI,CAAC,WAAW,CAAC,MAAM,OAAO;GAC9B,QAAA,QAAG,WAAW,QAAQ;GACtB,OAAO;EACT,SAAS,OAAO;GAGd,IAAK,MAAgC,SAAS,mBAC5C,KAAK,QAAQ,KAAKJ,kBAAAA,WAAW,sBAAsB,OAAO,GAAG,uBAAuB,SAAS,CAAC;GAEhG,OAAO;EACT;CACF;;;;;;;CAQA,iBAAiB,UAAwD;EACvE,KAAK,UAAU,IAAI,QAAQ;EAC3B,aAAa,KAAK,UAAU,OAAO,QAAQ;CAC7C;CAEA,UAAgB;EACd,KAAK,UAAU,MAAM;CACvB;AACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/types/telemetry.d.ts
|
|
2
|
+
declare const TASK_EVENT: {
|
|
3
|
+
readonly notificationFailed: "po_task.notification_failed";
|
|
4
|
+
readonly storeReadFailed: "po_task.store_read_failed";
|
|
5
|
+
readonly storeLockTimeout: "po_task.store_lock_timeout";
|
|
6
|
+
readonly storeLockBreakFailed: "po_task.store_lock_break_failed";
|
|
7
|
+
readonly storeWatchFailed: "po_task.store_watch_failed";
|
|
8
|
+
readonly storeListenerFailed: "po_task.store_listener_failed";
|
|
9
|
+
readonly storeSweepFailed: "po_task.store_sweep_failed";
|
|
10
|
+
readonly sessionStartFailed: "po_task.session_start_failed";
|
|
11
|
+
readonly sessionStartDegraded: "po_task.session_start_degraded";
|
|
12
|
+
readonly toolFailed: "po_task.tool_failed";
|
|
13
|
+
readonly delegationRequestFailed: "po_task.delegation_request_failed";
|
|
14
|
+
readonly delegationStartFailed: "po_task.delegation_start_failed";
|
|
15
|
+
readonly delegationResponseFailed: "po_task.delegation_response_failed";
|
|
16
|
+
readonly delegationSettleFailed: "po_task.delegation_settle_failed";
|
|
17
|
+
readonly delegationTimedOut: "po_task.delegation_timed_out";
|
|
18
|
+
readonly delegationOrphaned: "po_task.delegation_orphaned";
|
|
19
|
+
readonly delegationAssigned: "po_task.delegation_assigned";
|
|
20
|
+
readonly delegationCompleted: "po_task.delegation_completed";
|
|
21
|
+
};
|
|
22
|
+
type TaskEventName = (typeof TASK_EVENT)[keyof typeof TASK_EVENT];
|
|
23
|
+
type TaskErrorAttributes = Record<string, string | number | boolean>;
|
|
24
|
+
type TaskErrorSink = (event: TaskEventName, error: unknown, attributes?: TaskErrorAttributes) => void;
|
|
25
|
+
type TaskEventSink = (event: TaskEventName, attributes?: TaskErrorAttributes) => void;
|
|
26
|
+
/** Host-neutral telemetry port consumed by Task services and store adapters. */
|
|
27
|
+
interface TaskFailureReporter {
|
|
28
|
+
error: TaskErrorSink;
|
|
29
|
+
warn: TaskErrorSink;
|
|
30
|
+
/** Info-level event sink. Required so an unwired reporter fails to compile. */
|
|
31
|
+
event: TaskEventSink;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { TaskEventSink as a, TaskEventName as i, TaskErrorAttributes as n, TaskFailureReporter as o, TaskErrorSink as r, TASK_EVENT as t };
|
|
35
|
+
//# sourceMappingURL=telemetry-DYfgUFF8.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry-DYfgUFF8.d.mts","names":[],"sources":["../src/types/telemetry.ts"],"mappings":";cAAa;;;;;;;;;;;;;;;;;;;;KAuBD,wBAAwB,yBAAyB;KACjD,sBAAsB;KACtB,iBAAiB,OAAO,eAAe,gBAAgB,aAAa;KACpE,iBAAiB,OAAO,eAAe,aAAa;;UAG/C;EACf,OAAO;EACP,MAAM;;EAEN,OAAO"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/types/telemetry.ts
|
|
2
|
+
const TASK_EVENT = {
|
|
3
|
+
notificationFailed: "po_task.notification_failed",
|
|
4
|
+
storeReadFailed: "po_task.store_read_failed",
|
|
5
|
+
storeLockTimeout: "po_task.store_lock_timeout",
|
|
6
|
+
storeLockBreakFailed: "po_task.store_lock_break_failed",
|
|
7
|
+
storeWatchFailed: "po_task.store_watch_failed",
|
|
8
|
+
storeListenerFailed: "po_task.store_listener_failed",
|
|
9
|
+
storeSweepFailed: "po_task.store_sweep_failed",
|
|
10
|
+
sessionStartFailed: "po_task.session_start_failed",
|
|
11
|
+
sessionStartDegraded: "po_task.session_start_degraded",
|
|
12
|
+
toolFailed: "po_task.tool_failed",
|
|
13
|
+
delegationRequestFailed: "po_task.delegation_request_failed",
|
|
14
|
+
delegationStartFailed: "po_task.delegation_start_failed",
|
|
15
|
+
delegationResponseFailed: "po_task.delegation_response_failed",
|
|
16
|
+
delegationSettleFailed: "po_task.delegation_settle_failed",
|
|
17
|
+
delegationTimedOut: "po_task.delegation_timed_out",
|
|
18
|
+
delegationOrphaned: "po_task.delegation_orphaned",
|
|
19
|
+
delegationAssigned: "po_task.delegation_assigned",
|
|
20
|
+
delegationCompleted: "po_task.delegation_completed"
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { TASK_EVENT as t };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=telemetry-gEGWTaMI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry-gEGWTaMI.mjs","names":[],"sources":["../src/types/telemetry.ts"],"sourcesContent":["export const TASK_EVENT = {\n notificationFailed: 'po_task.notification_failed',\n storeReadFailed: 'po_task.store_read_failed',\n storeLockTimeout: 'po_task.store_lock_timeout',\n storeLockBreakFailed: 'po_task.store_lock_break_failed',\n storeWatchFailed: 'po_task.store_watch_failed',\n storeListenerFailed: 'po_task.store_listener_failed',\n storeSweepFailed: 'po_task.store_sweep_failed',\n sessionStartFailed: 'po_task.session_start_failed',\n sessionStartDegraded: 'po_task.session_start_degraded',\n toolFailed: 'po_task.tool_failed',\n delegationRequestFailed: 'po_task.delegation_request_failed',\n delegationStartFailed: 'po_task.delegation_start_failed',\n delegationResponseFailed: 'po_task.delegation_response_failed',\n delegationSettleFailed: 'po_task.delegation_settle_failed',\n delegationTimedOut: 'po_task.delegation_timed_out',\n delegationOrphaned: 'po_task.delegation_orphaned',\n // Info-level lifecycle events. These are the measurement pair: the shape of\n // the brief that went out, and the cost of the run it produced.\n delegationAssigned: 'po_task.delegation_assigned',\n delegationCompleted: 'po_task.delegation_completed',\n} as const;\n\nexport type TaskEventName = (typeof TASK_EVENT)[keyof typeof TASK_EVENT];\nexport type TaskErrorAttributes = Record<string, string | number | boolean>;\nexport type TaskErrorSink = (event: TaskEventName, error: unknown, attributes?: TaskErrorAttributes) => void;\nexport type TaskEventSink = (event: TaskEventName, attributes?: TaskErrorAttributes) => void;\n\n/** Host-neutral telemetry port consumed by Task services and store adapters. */\nexport interface TaskFailureReporter {\n error: TaskErrorSink;\n warn: TaskErrorSink;\n /** Info-level event sink. Required so an unwired reporter fails to compile. */\n event: TaskEventSink;\n}\n"],"mappings":";AAAA,MAAa,aAAa;CACxB,oBAAoB;CACpB,iBAAiB;CACjB,kBAAkB;CAClB,sBAAsB;CACtB,kBAAkB;CAClB,qBAAqB;CACrB,kBAAkB;CAClB,oBAAoB;CACpB,sBAAsB;CACtB,YAAY;CACZ,yBAAyB;CACzB,uBAAuB;CACvB,0BAA0B;CAC1B,wBAAwB;CACxB,oBAAoB;CACpB,oBAAoB;CAGpB,oBAAoB;CACpB,qBAAqB;AACvB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/types/telemetry.ts
|
|
2
|
+
const TASK_EVENT = {
|
|
3
|
+
notificationFailed: "po_task.notification_failed",
|
|
4
|
+
storeReadFailed: "po_task.store_read_failed",
|
|
5
|
+
storeLockTimeout: "po_task.store_lock_timeout",
|
|
6
|
+
storeLockBreakFailed: "po_task.store_lock_break_failed",
|
|
7
|
+
storeWatchFailed: "po_task.store_watch_failed",
|
|
8
|
+
storeListenerFailed: "po_task.store_listener_failed",
|
|
9
|
+
storeSweepFailed: "po_task.store_sweep_failed",
|
|
10
|
+
sessionStartFailed: "po_task.session_start_failed",
|
|
11
|
+
sessionStartDegraded: "po_task.session_start_degraded",
|
|
12
|
+
toolFailed: "po_task.tool_failed",
|
|
13
|
+
delegationRequestFailed: "po_task.delegation_request_failed",
|
|
14
|
+
delegationStartFailed: "po_task.delegation_start_failed",
|
|
15
|
+
delegationResponseFailed: "po_task.delegation_response_failed",
|
|
16
|
+
delegationSettleFailed: "po_task.delegation_settle_failed",
|
|
17
|
+
delegationTimedOut: "po_task.delegation_timed_out",
|
|
18
|
+
delegationOrphaned: "po_task.delegation_orphaned",
|
|
19
|
+
delegationAssigned: "po_task.delegation_assigned",
|
|
20
|
+
delegationCompleted: "po_task.delegation_completed"
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
Object.defineProperty(exports, "TASK_EVENT", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function() {
|
|
26
|
+
return TASK_EVENT;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=telemetry-x3JxCA5K.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry-x3JxCA5K.cjs","names":[],"sources":["../src/types/telemetry.ts"],"sourcesContent":["export const TASK_EVENT = {\n notificationFailed: 'po_task.notification_failed',\n storeReadFailed: 'po_task.store_read_failed',\n storeLockTimeout: 'po_task.store_lock_timeout',\n storeLockBreakFailed: 'po_task.store_lock_break_failed',\n storeWatchFailed: 'po_task.store_watch_failed',\n storeListenerFailed: 'po_task.store_listener_failed',\n storeSweepFailed: 'po_task.store_sweep_failed',\n sessionStartFailed: 'po_task.session_start_failed',\n sessionStartDegraded: 'po_task.session_start_degraded',\n toolFailed: 'po_task.tool_failed',\n delegationRequestFailed: 'po_task.delegation_request_failed',\n delegationStartFailed: 'po_task.delegation_start_failed',\n delegationResponseFailed: 'po_task.delegation_response_failed',\n delegationSettleFailed: 'po_task.delegation_settle_failed',\n delegationTimedOut: 'po_task.delegation_timed_out',\n delegationOrphaned: 'po_task.delegation_orphaned',\n // Info-level lifecycle events. These are the measurement pair: the shape of\n // the brief that went out, and the cost of the run it produced.\n delegationAssigned: 'po_task.delegation_assigned',\n delegationCompleted: 'po_task.delegation_completed',\n} as const;\n\nexport type TaskEventName = (typeof TASK_EVENT)[keyof typeof TASK_EVENT];\nexport type TaskErrorAttributes = Record<string, string | number | boolean>;\nexport type TaskErrorSink = (event: TaskEventName, error: unknown, attributes?: TaskErrorAttributes) => void;\nexport type TaskEventSink = (event: TaskEventName, attributes?: TaskErrorAttributes) => void;\n\n/** Host-neutral telemetry port consumed by Task services and store adapters. */\nexport interface TaskFailureReporter {\n error: TaskErrorSink;\n warn: TaskErrorSink;\n /** Info-level event sink. Required so an unwired reporter fails to compile. */\n event: TaskEventSink;\n}\n"],"mappings":";AAAA,MAAa,aAAa;CACxB,oBAAoB;CACpB,iBAAiB;CACjB,kBAAkB;CAClB,sBAAsB;CACtB,kBAAkB;CAClB,qBAAqB;CACrB,kBAAkB;CAClB,oBAAoB;CACpB,sBAAsB;CACtB,YAAY;CACZ,yBAAyB;CACzB,uBAAuB;CACvB,0BAA0B;CAC1B,wBAAwB;CACxB,oBAAoB;CACpB,oBAAoB;CAGpB,oBAAoB;CACpB,qBAAqB;AACvB"}
|
|
@@ -19,7 +19,7 @@ const DEFAULT_PROMPT_GUIDELINES = [
|
|
|
19
19
|
"Assign through assignments[] even for a single task: {\"action\":\"assign\",\"assignments\":[{\"id\":1,\"agent\":\"researcher\"}]}. Put independent ready tasks in one batch rather than repeated calls or multi_tool, and do not start a direct subagent run for work already on the task list. Successful entries keep running when another entry fails, so retry only the failures.",
|
|
20
20
|
"Fill relevantFiles only with files you actually read or located, and priorFindings only with verified facts in a few lines, not directives. A guessed path costs more than an omitted one.",
|
|
21
21
|
"Subject stays short and imperative. description is the durable brief handed to the subagent, extended at assign time by instructions, relevantFiles and priorFindings, so do not repeat one in the other.",
|
|
22
|
-
"When a delegated task completes and unblocks another, reconsider it promptly. If a child asks for a decision or an assignment fails to start, respond, rescope or retry instead of leaving it pending.
|
|
22
|
+
"When a delegated task completes and unblocks another, reconsider it promptly. If a child asks for a decision or an assignment fails to start, respond, rescope or retry instead of leaving it pending. Po Task records delegated lifecycle and results on the task itself."
|
|
23
23
|
];
|
|
24
24
|
//#endregion
|
|
25
25
|
exports.DEFAULT_PROMPT_GUIDELINES = DEFAULT_PROMPT_GUIDELINES;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolPromptGuidelines.cjs","names":[],"sources":["../src/constants/promptGuidelines.ts"],"sourcesContent":["/**\n * Cross-call behaviour the schema cannot express.\n *\n * Every rule lives in exactly one surface. Argument-site mechanics belong to\n * the parameter descriptions in `schemas/task.ts`, the use/do-not-use policy\n * and session scoping belong to the tool description, and general delegation\n * judgement belongs to the Team orchestrator prompt. What is left here is what\n * none of those three can carry: how calls should be sequenced across a turn.\n */\nexport const DEFAULT_PROMPT_GUIDELINES: string[] = [\n 'Batch the whole plan in one upsert: {\"action\":\"upsert\",\"tasks\":[{\"subject\":\"Research the store\"},{\"subject\":\"Write the reducer\"}]}. Report progress one call at a time: mark a task in_progress before you start it and completed the moment it lands, never batched at the end of a turn. Keep one task in_progress for your own work; delegated tasks run in parallel and do not count.',\n 'Never mark a task completed while tests fail or the work is partial. Use failed, or keep it in_progress and add a task for the blocker in the same upsert.',\n 'When every non-deleted task is completed, review the list once and call {\"action\":\"clear\"}.',\n \"Status flow: pending, in_progress, completed. failed is recoverable, deleted is a tombstone. Pass activeForm (e.g. 'writing tests') when marking in_progress.\",\n 'upsert applies each entry independently: passing entries commit and failures are reported by array index. Resend only the corrected failures, because resending an applied entry with no id creates a duplicate task.',\n 'Apply the session delegation criteria before choosing what to delegate, then call subagent {\"action\":\"agents\"} and use an exact discovered name. Prefer a general-purpose write-capable agent such as delegate or worker when no specialist fits, and use a focused inlineAgent only for read-only work.',\n 'Assign through assignments[] even for a single task: {\"action\":\"assign\",\"assignments\":[{\"id\":1,\"agent\":\"researcher\"}]}. Put independent ready tasks in one batch rather than repeated calls or multi_tool, and do not start a direct subagent run for work already on the task list. Successful entries keep running when another entry fails, so retry only the failures.',\n 'Fill relevantFiles only with files you actually read or located, and priorFindings only with verified facts in a few lines, not directives. A guessed path costs more than an omitted one.',\n 'Subject stays short and imperative. description is the durable brief handed to the subagent, extended at assign time by instructions, relevantFiles and priorFindings, so do not repeat one in the other.',\n 'When a delegated task completes and unblocks another, reconsider it promptly. If a child asks for a decision or an assignment fails to start, respond, rescope or retry instead of leaving it pending.
|
|
1
|
+
{"version":3,"file":"toolPromptGuidelines.cjs","names":[],"sources":["../src/constants/promptGuidelines.ts"],"sourcesContent":["/**\n * Cross-call behaviour the schema cannot express.\n *\n * Every rule lives in exactly one surface. Argument-site mechanics belong to\n * the parameter descriptions in `schemas/task.ts`, the use/do-not-use policy\n * and session scoping belong to the tool description, and general delegation\n * judgement belongs to the Team orchestrator prompt. What is left here is what\n * none of those three can carry: how calls should be sequenced across a turn.\n */\nexport const DEFAULT_PROMPT_GUIDELINES: string[] = [\n 'Batch the whole plan in one upsert: {\"action\":\"upsert\",\"tasks\":[{\"subject\":\"Research the store\"},{\"subject\":\"Write the reducer\"}]}. Report progress one call at a time: mark a task in_progress before you start it and completed the moment it lands, never batched at the end of a turn. Keep one task in_progress for your own work; delegated tasks run in parallel and do not count.',\n 'Never mark a task completed while tests fail or the work is partial. Use failed, or keep it in_progress and add a task for the blocker in the same upsert.',\n 'When every non-deleted task is completed, review the list once and call {\"action\":\"clear\"}.',\n \"Status flow: pending, in_progress, completed. failed is recoverable, deleted is a tombstone. Pass activeForm (e.g. 'writing tests') when marking in_progress.\",\n 'upsert applies each entry independently: passing entries commit and failures are reported by array index. Resend only the corrected failures, because resending an applied entry with no id creates a duplicate task.',\n 'Apply the session delegation criteria before choosing what to delegate, then call subagent {\"action\":\"agents\"} and use an exact discovered name. Prefer a general-purpose write-capable agent such as delegate or worker when no specialist fits, and use a focused inlineAgent only for read-only work.',\n 'Assign through assignments[] even for a single task: {\"action\":\"assign\",\"assignments\":[{\"id\":1,\"agent\":\"researcher\"}]}. Put independent ready tasks in one batch rather than repeated calls or multi_tool, and do not start a direct subagent run for work already on the task list. Successful entries keep running when another entry fails, so retry only the failures.',\n 'Fill relevantFiles only with files you actually read or located, and priorFindings only with verified facts in a few lines, not directives. A guessed path costs more than an omitted one.',\n 'Subject stays short and imperative. description is the durable brief handed to the subagent, extended at assign time by instructions, relevantFiles and priorFindings, so do not repeat one in the other.',\n 'When a delegated task completes and unblocks another, reconsider it promptly. If a child asks for a decision or an assignment fails to start, respond, rescope or retry instead of leaving it pending. Po Task records delegated lifecycle and results on the task itself.',\n];\n"],"mappings":";;;;;;;;;;;AASA,MAAa,4BAAsC;CACjD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
|
|
@@ -18,7 +18,7 @@ const DEFAULT_PROMPT_GUIDELINES = [
|
|
|
18
18
|
"Assign through assignments[] even for a single task: {\"action\":\"assign\",\"assignments\":[{\"id\":1,\"agent\":\"researcher\"}]}. Put independent ready tasks in one batch rather than repeated calls or multi_tool, and do not start a direct subagent run for work already on the task list. Successful entries keep running when another entry fails, so retry only the failures.",
|
|
19
19
|
"Fill relevantFiles only with files you actually read or located, and priorFindings only with verified facts in a few lines, not directives. A guessed path costs more than an omitted one.",
|
|
20
20
|
"Subject stays short and imperative. description is the durable brief handed to the subagent, extended at assign time by instructions, relevantFiles and priorFindings, so do not repeat one in the other.",
|
|
21
|
-
"When a delegated task completes and unblocks another, reconsider it promptly. If a child asks for a decision or an assignment fails to start, respond, rescope or retry instead of leaving it pending.
|
|
21
|
+
"When a delegated task completes and unblocks another, reconsider it promptly. If a child asks for a decision or an assignment fails to start, respond, rescope or retry instead of leaving it pending. Po Task records delegated lifecycle and results on the task itself."
|
|
22
22
|
];
|
|
23
23
|
//#endregion
|
|
24
24
|
export { DEFAULT_PROMPT_GUIDELINES };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolPromptGuidelines.mjs","names":[],"sources":["../src/constants/promptGuidelines.ts"],"sourcesContent":["/**\n * Cross-call behaviour the schema cannot express.\n *\n * Every rule lives in exactly one surface. Argument-site mechanics belong to\n * the parameter descriptions in `schemas/task.ts`, the use/do-not-use policy\n * and session scoping belong to the tool description, and general delegation\n * judgement belongs to the Team orchestrator prompt. What is left here is what\n * none of those three can carry: how calls should be sequenced across a turn.\n */\nexport const DEFAULT_PROMPT_GUIDELINES: string[] = [\n 'Batch the whole plan in one upsert: {\"action\":\"upsert\",\"tasks\":[{\"subject\":\"Research the store\"},{\"subject\":\"Write the reducer\"}]}. Report progress one call at a time: mark a task in_progress before you start it and completed the moment it lands, never batched at the end of a turn. Keep one task in_progress for your own work; delegated tasks run in parallel and do not count.',\n 'Never mark a task completed while tests fail or the work is partial. Use failed, or keep it in_progress and add a task for the blocker in the same upsert.',\n 'When every non-deleted task is completed, review the list once and call {\"action\":\"clear\"}.',\n \"Status flow: pending, in_progress, completed. failed is recoverable, deleted is a tombstone. Pass activeForm (e.g. 'writing tests') when marking in_progress.\",\n 'upsert applies each entry independently: passing entries commit and failures are reported by array index. Resend only the corrected failures, because resending an applied entry with no id creates a duplicate task.',\n 'Apply the session delegation criteria before choosing what to delegate, then call subagent {\"action\":\"agents\"} and use an exact discovered name. Prefer a general-purpose write-capable agent such as delegate or worker when no specialist fits, and use a focused inlineAgent only for read-only work.',\n 'Assign through assignments[] even for a single task: {\"action\":\"assign\",\"assignments\":[{\"id\":1,\"agent\":\"researcher\"}]}. Put independent ready tasks in one batch rather than repeated calls or multi_tool, and do not start a direct subagent run for work already on the task list. Successful entries keep running when another entry fails, so retry only the failures.',\n 'Fill relevantFiles only with files you actually read or located, and priorFindings only with verified facts in a few lines, not directives. A guessed path costs more than an omitted one.',\n 'Subject stays short and imperative. description is the durable brief handed to the subagent, extended at assign time by instructions, relevantFiles and priorFindings, so do not repeat one in the other.',\n 'When a delegated task completes and unblocks another, reconsider it promptly. If a child asks for a decision or an assignment fails to start, respond, rescope or retry instead of leaving it pending.
|
|
1
|
+
{"version":3,"file":"toolPromptGuidelines.mjs","names":[],"sources":["../src/constants/promptGuidelines.ts"],"sourcesContent":["/**\n * Cross-call behaviour the schema cannot express.\n *\n * Every rule lives in exactly one surface. Argument-site mechanics belong to\n * the parameter descriptions in `schemas/task.ts`, the use/do-not-use policy\n * and session scoping belong to the tool description, and general delegation\n * judgement belongs to the Team orchestrator prompt. What is left here is what\n * none of those three can carry: how calls should be sequenced across a turn.\n */\nexport const DEFAULT_PROMPT_GUIDELINES: string[] = [\n 'Batch the whole plan in one upsert: {\"action\":\"upsert\",\"tasks\":[{\"subject\":\"Research the store\"},{\"subject\":\"Write the reducer\"}]}. Report progress one call at a time: mark a task in_progress before you start it and completed the moment it lands, never batched at the end of a turn. Keep one task in_progress for your own work; delegated tasks run in parallel and do not count.',\n 'Never mark a task completed while tests fail or the work is partial. Use failed, or keep it in_progress and add a task for the blocker in the same upsert.',\n 'When every non-deleted task is completed, review the list once and call {\"action\":\"clear\"}.',\n \"Status flow: pending, in_progress, completed. failed is recoverable, deleted is a tombstone. Pass activeForm (e.g. 'writing tests') when marking in_progress.\",\n 'upsert applies each entry independently: passing entries commit and failures are reported by array index. Resend only the corrected failures, because resending an applied entry with no id creates a duplicate task.',\n 'Apply the session delegation criteria before choosing what to delegate, then call subagent {\"action\":\"agents\"} and use an exact discovered name. Prefer a general-purpose write-capable agent such as delegate or worker when no specialist fits, and use a focused inlineAgent only for read-only work.',\n 'Assign through assignments[] even for a single task: {\"action\":\"assign\",\"assignments\":[{\"id\":1,\"agent\":\"researcher\"}]}. Put independent ready tasks in one batch rather than repeated calls or multi_tool, and do not start a direct subagent run for work already on the task list. Successful entries keep running when another entry fails, so retry only the failures.',\n 'Fill relevantFiles only with files you actually read or located, and priorFindings only with verified facts in a few lines, not directives. A guessed path costs more than an omitted one.',\n 'Subject stays short and imperative. description is the durable brief handed to the subagent, extended at assign time by instructions, relevantFiles and priorFindings, so do not repeat one in the other.',\n 'When a delegated task completes and unblocks another, reconsider it promptly. If a child asks for a decision or an assignment fails to start, respond, rescope or retry instead of leaving it pending. Po Task records delegated lifecycle and results on the task itself.',\n];\n"],"mappings":";;;;;;;;;;AASA,MAAa,4BAAsC;CACjD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { MSG_ALL_COMPLETE_CLEAR, MSG_ASSIGN_PARTIAL, MSG_UPSERT_NONE_APPLIED, MSG_UPSERT_PARTIAL, buildAssignmentResult, buildTextResult, buildToolResult, formatAssignmentResults, formatContent, formatUpsertFailureText };
|
|
1
|
+
export { t as MSG_ALL_COMPLETE_CLEAR, n as MSG_ASSIGN_PARTIAL, r as MSG_UPSERT_NONE_APPLIED, i as MSG_UPSERT_PARTIAL, a as buildAssignmentResult, o as buildTextResult, s as buildToolResult, c as formatAssignmentResults, l as formatContent, u as formatUpsertFailureText } from "./taskResult-edBAAKSH.mjs";
|
package/dist/toolSchema.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as TaskParamsSchema, a as RemoteTaskParamsSchema, c as TASK_CONTEXTS, d as TOOL_NAME, f as TaskAssignmentParams, g as TaskParams, h as TaskItemSchema, i as REMOTE_TASK_ACTIONS, l as TASK_STATUSES, m as TaskItemParams, n as MSG_NO_TASKS, o as TASK_ACTIONS, p as TaskAssignmentSchema, r as MSG_UPSERT_FIELD_MISPLACED, s as TASK_ACTION_FIELDS, t as ERR_REQUIRES_INTERACTIVE, u as TOOL_LABEL, v as taskActionAcceptsField, y as COMMAND_NAME } from "./task-
|
|
1
|
+
import { _ as TaskParamsSchema, a as RemoteTaskParamsSchema, c as TASK_CONTEXTS, d as TOOL_NAME, f as TaskAssignmentParams, g as TaskParams, h as TaskItemSchema, i as REMOTE_TASK_ACTIONS, l as TASK_STATUSES, m as TaskItemParams, n as MSG_NO_TASKS, o as TASK_ACTIONS, p as TaskAssignmentSchema, r as MSG_UPSERT_FIELD_MISPLACED, s as TASK_ACTION_FIELDS, t as ERR_REQUIRES_INTERACTIVE, u as TOOL_LABEL, v as taskActionAcceptsField, y as COMMAND_NAME } from "./task-4HeGAS8o.mjs";
|
|
2
2
|
export { COMMAND_NAME, ERR_REQUIRES_INTERACTIVE, MSG_NO_TASKS, MSG_UPSERT_FIELD_MISPLACED, REMOTE_TASK_ACTIONS, RemoteTaskParamsSchema, TASK_ACTIONS, TASK_ACTION_FIELDS, TASK_CONTEXTS, TASK_STATUSES, TOOL_LABEL, TOOL_NAME, TaskAssignmentParams, TaskAssignmentSchema, TaskItemParams, TaskItemSchema, TaskParams, TaskParamsSchema, taskActionAcceptsField };
|
package/dist/toolSchema.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { COMMAND_NAME, ERR_REQUIRES_INTERACTIVE, MSG_NO_TASKS, MSG_UPSERT_FIELD_MISPLACED, REMOTE_TASK_ACTIONS, RemoteTaskParamsSchema, TASK_ACTIONS, TASK_ACTION_FIELDS, TASK_CONTEXTS, TASK_STATUSES, TOOL_LABEL, TOOL_NAME, TaskAssignmentSchema, TaskItemSchema, TaskParamsSchema, taskActionAcceptsField };
|
|
1
|
+
export { g as COMMAND_NAME, t as ERR_REQUIRES_INTERACTIVE, n as MSG_NO_TASKS, r as MSG_UPSERT_FIELD_MISPLACED, i as REMOTE_TASK_ACTIONS, a as RemoteTaskParamsSchema, o as TASK_ACTIONS, s as TASK_ACTION_FIELDS, c as TASK_CONTEXTS, l as TASK_STATUSES, u as TOOL_LABEL, d as TOOL_NAME, f as TaskAssignmentSchema, p as TaskItemSchema, m as TaskParamsSchema, h as taskActionAcceptsField } from "./task-DO0TwZ0z.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/po-task",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.21",
|
|
4
4
|
"description": "Persistent, dependency-aware task graphs and subagent delegation for Pi coding sessions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"bugs": {
|
|
19
19
|
"url": "https://github.com/AgiFlow/po/issues"
|
|
20
20
|
},
|
|
21
|
-
"license": "
|
|
21
|
+
"license": "BUSL-1.1",
|
|
22
22
|
"author": "Vuong Ngo",
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
@@ -129,33 +129,33 @@
|
|
|
129
129
|
"registry": "https://registry.npmjs.org/"
|
|
130
130
|
},
|
|
131
131
|
"dependencies": {
|
|
132
|
-
"@agimon-ai/po-core": "0.0.0-alpha.
|
|
133
|
-
"@agimon-ai/po-telemetry": "0.0.0-alpha.
|
|
134
|
-
"@agimon-ai/po-ui": "0.0.0-alpha.
|
|
135
|
-
"@agimon-ai/po-web-components": "0.0.0-alpha.
|
|
136
|
-
"@deepseek-ai/cordis": "4.0.
|
|
137
|
-
"typebox": "1.3.
|
|
132
|
+
"@agimon-ai/po-core": "0.0.0-alpha.21",
|
|
133
|
+
"@agimon-ai/po-telemetry": "0.0.0-alpha.21",
|
|
134
|
+
"@agimon-ai/po-ui": "0.0.0-alpha.21",
|
|
135
|
+
"@agimon-ai/po-web-components": "0.0.0-alpha.21",
|
|
136
|
+
"@deepseek-ai/cordis": "4.0.5",
|
|
137
|
+
"typebox": "1.3.37"
|
|
138
138
|
},
|
|
139
139
|
"devDependencies": {
|
|
140
|
-
"@agimon-ai/po-build": "0.0.0-alpha.
|
|
141
|
-
"@agimon-ai/po-native-components": "0.0.0-alpha.
|
|
140
|
+
"@agimon-ai/po-build": "0.0.0-alpha.21",
|
|
141
|
+
"@agimon-ai/po-native-components": "0.0.0-alpha.21",
|
|
142
142
|
"@babel/core": "7.29.7",
|
|
143
|
-
"@earendil-works/pi-coding-agent": "1.
|
|
143
|
+
"@earendil-works/pi-coding-agent": "1.3.0",
|
|
144
144
|
"@tanstack/react-store": "0.11.2",
|
|
145
145
|
"@tanstack/store": "0.11.2",
|
|
146
|
-
"@types/node": "26.6.
|
|
147
|
-
"@types/react": "19.
|
|
148
|
-
"@vitest/coverage-v8": "5.0.
|
|
146
|
+
"@types/node": "26.6.5",
|
|
147
|
+
"@types/react": "~19.2.4",
|
|
148
|
+
"@vitest/coverage-v8": "5.0.4",
|
|
149
149
|
"react": "19.3.0",
|
|
150
150
|
"react-dom": "19.3.0",
|
|
151
151
|
"react-native": "0.86.3",
|
|
152
|
-
"react-native-unistyles": "3.5.
|
|
153
|
-
"tsdown": "0.23.
|
|
154
|
-
"typescript": "
|
|
155
|
-
"vitest": "5.0.
|
|
152
|
+
"react-native-unistyles": "3.5.3",
|
|
153
|
+
"tsdown": "0.23.1",
|
|
154
|
+
"typescript": "~6.0.3",
|
|
155
|
+
"vitest": "5.0.4"
|
|
156
156
|
},
|
|
157
157
|
"peerDependencies": {
|
|
158
|
-
"@earendil-works/pi-coding-agent": "1.
|
|
158
|
+
"@earendil-works/pi-coding-agent": "1.3.0"
|
|
159
159
|
},
|
|
160
160
|
"peerDependenciesMeta": {
|
|
161
161
|
"@earendil-works/pi-coding-agent": {
|
|
@@ -186,6 +186,7 @@
|
|
|
186
186
|
],
|
|
187
187
|
"client": "./dist/extensions/native.mjs",
|
|
188
188
|
"scopes": [
|
|
189
|
+
"workspace",
|
|
189
190
|
"session"
|
|
190
191
|
]
|
|
191
192
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-CFSs3iku.mjs","names":[],"sources":["../src/services/config/index.ts"],"sourcesContent":["/**\n * Extension configuration, read from the environment.\n *\n * Env rather than a config file: po already carries per-launch state to Pi\n * through env vars, so this keeps doom-task consistent with how the harness\n * configures the rest of the extension set.\n */\n\nexport const MAX_WIDGET_LINES_ENV = 'DOOM_TASK_MAX_WIDGET_LINES';\nexport const MAX_TASKS_ENV = 'DOOM_TASK_MAX_TASKS';\nexport const COLLAPSE_KEY_ENV = 'DOOM_TASK_COLLAPSE_KEY';\nexport const STORE_TTL_MS_ENV = 'DOOM_TASK_STORE_TTL_MS';\nexport const DELEGATION_TIMEOUT_MS_ENV = 'DOOM_TASK_DELEGATION_TIMEOUT_MS';\n\nexport const DEFAULT_MAX_WIDGET_LINES = 12;\nexport const DEFAULT_MAX_TASKS = 15;\nexport const DEFAULT_COLLAPSE_KEY = 'ctrl+shift+t';\nexport const DEFAULT_STORE_TTL_MS = 30 * 24 * 60 * 60 * 1000;\n/** Deliberately under the subagents auto-drain ceiling (30 min) so a headless\n * session still gets the failure and a model turn before draining gives up. */\nexport const DEFAULT_DELEGATION_TIMEOUT_MS = 20 * 60 * 1000;\nexport const COLLAPSE_KEY_OFF = 'off';\n\nconst MIN_WIDGET_LINES = 3;\nconst MAX_WIDGET_LINES = 60;\n\nexport interface PiTaskConfig {\n maxWidgetLines: number;\n maxTasks: number;\n storeTtlMs: number;\n collapseKey: string;\n delegationTimeoutMs: number;\n}\n\nfunction configRecord(value: unknown): Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>) : {};\n}\n\n/** Parse configuration only after the Pi host has applied its project-trust policy. */\nexport function parsePiTaskConfig(value: unknown): PiTaskConfig {\n const config = configRecord(value);\n const maxWidgetLines =\n typeof config.maxWidgetLines === 'number' && Number.isFinite(config.maxWidgetLines)\n ? Math.min(Math.max(config.maxWidgetLines, MIN_WIDGET_LINES), MAX_WIDGET_LINES)\n : DEFAULT_MAX_WIDGET_LINES;\n const maxTasks =\n typeof config.maxTasks === 'number' && Number.isSafeInteger(config.maxTasks) && config.maxTasks > 0\n ? config.maxTasks\n : DEFAULT_MAX_TASKS;\n const storeTtlMs =\n typeof config.storeTtlMs === 'number' && Number.isFinite(config.storeTtlMs) && config.storeTtlMs > 0\n ? config.storeTtlMs\n : DEFAULT_STORE_TTL_MS;\n const delegationTimeoutMs =\n typeof config.delegationTimeoutMs === 'number' &&\n Number.isFinite(config.delegationTimeoutMs) &&\n config.delegationTimeoutMs > 0\n ? config.delegationTimeoutMs\n : DEFAULT_DELEGATION_TIMEOUT_MS;\n const collapseKey =\n typeof config.collapseKey === 'string' && config.collapseKey.trim()\n ? config.collapseKey.trim().toLowerCase() === COLLAPSE_KEY_OFF\n ? COLLAPSE_KEY_OFF\n : config.collapseKey.trim()\n : DEFAULT_COLLAPSE_KEY;\n\n return { maxWidgetLines, maxTasks, storeTtlMs, collapseKey, delegationTimeoutMs };\n}\n\n/** Rows the overlay may use for content, clamped to a sane range. */\nexport function getMaxWidgetLines(env: NodeJS.ProcessEnv = process.env): number {\n const raw = Number.parseInt(env[MAX_WIDGET_LINES_ENV] ?? '', 10);\n if (!Number.isFinite(raw)) return DEFAULT_MAX_WIDGET_LINES;\n return Math.min(Math.max(raw, MIN_WIDGET_LINES), MAX_WIDGET_LINES);\n}\n\n/** Maximum number of non-deleted tasks retained on one board. */\nexport function getMaxTasks(env: NodeJS.ProcessEnv = process.env): number {\n const raw = Number(env[MAX_TASKS_ENV]);\n return Number.isSafeInteger(raw) && raw > 0 ? raw : DEFAULT_MAX_TASKS;\n}\n\n/** Retention window for inactive session-tree stores. */\nexport function getStoreTtlMs(env: NodeJS.ProcessEnv = process.env): number {\n const raw = Number(env[STORE_TTL_MS_ENV]);\n return Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_STORE_TTL_MS;\n}\n\n/** How long a delegated run may go without reporting a result. */\nexport function getDelegationTimeoutMs(env: NodeJS.ProcessEnv = process.env): number {\n const raw = Number(env[DELEGATION_TIMEOUT_MS_ENV]);\n return Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_DELEGATION_TIMEOUT_MS;\n}\n\n/** Collapse shortcut, or the `off` sentinel when the user disabled it. */\nexport function resolveCollapseKey(env: NodeJS.ProcessEnv = process.env): string {\n const configured = env[COLLAPSE_KEY_ENV]?.trim();\n if (!configured) return DEFAULT_COLLAPSE_KEY;\n return configured.toLowerCase() === COLLAPSE_KEY_OFF ? COLLAPSE_KEY_OFF : configured;\n}\n"],"mappings":";;;;;;;;AAQA,MAAa,uBAAuB;AACpC,MAAa,gBAAgB;AAC7B,MAAa,mBAAmB;AAChC,MAAa,mBAAmB;AAChC,MAAa,4BAA4B;AAEzC,MAAa,2BAA2B;AACxC,MAAa,oBAAoB;AACjC,MAAa,uBAAuB;AACpC,MAAa,uBAAuB;;;AAGpC,MAAa,gCAAgC;AAC7C,MAAa,mBAAmB;AAEhC,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;AAUzB,SAAS,aAAa,OAAyC;CAC7D,OAAO,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IAAK,QAAoC,CAAC;AACtH;;AAGA,SAAgB,kBAAkB,OAA8B;CAC9D,MAAM,SAAS,aAAa,KAAK;CACjC,MAAM,iBACJ,OAAO,OAAO,mBAAmB,YAAY,OAAO,SAAS,OAAO,cAAc,IAC9E,KAAK,IAAI,KAAK,IAAI,OAAO,gBAAgB,gBAAgB,GAAG,gBAAgB,IAAA;CAElF,MAAM,WACJ,OAAO,OAAO,aAAa,YAAY,OAAO,cAAc,OAAO,QAAQ,KAAK,OAAO,WAAW,IAC9F,OAAO,WAAA;CAEb,MAAM,aACJ,OAAO,OAAO,eAAe,YAAY,OAAO,SAAS,OAAO,UAAU,KAAK,OAAO,aAAa,IAC/F,OAAO,aACP;CACN,MAAM,sBACJ,OAAO,OAAO,wBAAwB,YACtC,OAAO,SAAS,OAAO,mBAAmB,KAC1C,OAAO,sBAAsB,IACzB,OAAO,sBACP;CAQN,OAAO;EAAE;EAAgB;EAAU;EAAY,aAN7C,OAAO,OAAO,gBAAgB,YAAY,OAAO,YAAY,KAAK,IAC9D,OAAO,YAAY,KAAK,CAAC,CAAC,YAAY,MAAA,QAAA,QAEpC,OAAO,YAAY,KAAK,IAC1B;EAEsD;CAAoB;AAClF;;AAGA,SAAgB,kBAAkB,MAAyB,QAAQ,KAAa;CAC9E,MAAM,MAAM,OAAO,SAAS,IAAA,iCAA6B,IAAI,EAAE;CAC/D,IAAI,CAAC,OAAO,SAAS,GAAG,GAAG,OAAA;CAC3B,OAAO,KAAK,IAAI,KAAK,IAAI,KAAK,gBAAgB,GAAG,gBAAgB;AACnE;;AAGA,SAAgB,YAAY,MAAyB,QAAQ,KAAa;CACxE,MAAM,MAAM,OAAO,IAAI,cAAc;CACrC,OAAO,OAAO,cAAc,GAAG,KAAK,MAAM,IAAI,MAAA;AAChD;;AAGA,SAAgB,cAAc,MAAyB,QAAQ,KAAa;CAC1E,MAAM,MAAM,OAAO,IAAI,iBAAiB;CACxC,OAAO,OAAO,SAAS,GAAG,KAAK,MAAM,IAAI,MAAM;AACjD;;AAGA,SAAgB,uBAAuB,MAAyB,QAAQ,KAAa;CACnF,MAAM,MAAM,OAAO,IAAI,0BAA0B;CACjD,OAAO,OAAO,SAAS,GAAG,KAAK,MAAM,IAAI,MAAM;AACjD;;AAGA,SAAgB,mBAAmB,MAAyB,QAAQ,KAAa;CAC/E,MAAM,aAAa,IAAI,iBAAiB,EAAE,KAAK;CAC/C,IAAI,CAAC,YAAY,OAAO;CACxB,OAAO,WAAW,YAAY,MAAA,QAAA,QAA4C;AAC5E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-CdX-Bv8q.cjs","names":[],"sources":["../src/services/config/index.ts"],"sourcesContent":["/**\n * Extension configuration, read from the environment.\n *\n * Env rather than a config file: po already carries per-launch state to Pi\n * through env vars, so this keeps doom-task consistent with how the harness\n * configures the rest of the extension set.\n */\n\nexport const MAX_WIDGET_LINES_ENV = 'DOOM_TASK_MAX_WIDGET_LINES';\nexport const MAX_TASKS_ENV = 'DOOM_TASK_MAX_TASKS';\nexport const COLLAPSE_KEY_ENV = 'DOOM_TASK_COLLAPSE_KEY';\nexport const STORE_TTL_MS_ENV = 'DOOM_TASK_STORE_TTL_MS';\nexport const DELEGATION_TIMEOUT_MS_ENV = 'DOOM_TASK_DELEGATION_TIMEOUT_MS';\n\nexport const DEFAULT_MAX_WIDGET_LINES = 12;\nexport const DEFAULT_MAX_TASKS = 15;\nexport const DEFAULT_COLLAPSE_KEY = 'ctrl+shift+t';\nexport const DEFAULT_STORE_TTL_MS = 30 * 24 * 60 * 60 * 1000;\n/** Deliberately under the subagents auto-drain ceiling (30 min) so a headless\n * session still gets the failure and a model turn before draining gives up. */\nexport const DEFAULT_DELEGATION_TIMEOUT_MS = 20 * 60 * 1000;\nexport const COLLAPSE_KEY_OFF = 'off';\n\nconst MIN_WIDGET_LINES = 3;\nconst MAX_WIDGET_LINES = 60;\n\nexport interface PiTaskConfig {\n maxWidgetLines: number;\n maxTasks: number;\n storeTtlMs: number;\n collapseKey: string;\n delegationTimeoutMs: number;\n}\n\nfunction configRecord(value: unknown): Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>) : {};\n}\n\n/** Parse configuration only after the Pi host has applied its project-trust policy. */\nexport function parsePiTaskConfig(value: unknown): PiTaskConfig {\n const config = configRecord(value);\n const maxWidgetLines =\n typeof config.maxWidgetLines === 'number' && Number.isFinite(config.maxWidgetLines)\n ? Math.min(Math.max(config.maxWidgetLines, MIN_WIDGET_LINES), MAX_WIDGET_LINES)\n : DEFAULT_MAX_WIDGET_LINES;\n const maxTasks =\n typeof config.maxTasks === 'number' && Number.isSafeInteger(config.maxTasks) && config.maxTasks > 0\n ? config.maxTasks\n : DEFAULT_MAX_TASKS;\n const storeTtlMs =\n typeof config.storeTtlMs === 'number' && Number.isFinite(config.storeTtlMs) && config.storeTtlMs > 0\n ? config.storeTtlMs\n : DEFAULT_STORE_TTL_MS;\n const delegationTimeoutMs =\n typeof config.delegationTimeoutMs === 'number' &&\n Number.isFinite(config.delegationTimeoutMs) &&\n config.delegationTimeoutMs > 0\n ? config.delegationTimeoutMs\n : DEFAULT_DELEGATION_TIMEOUT_MS;\n const collapseKey =\n typeof config.collapseKey === 'string' && config.collapseKey.trim()\n ? config.collapseKey.trim().toLowerCase() === COLLAPSE_KEY_OFF\n ? COLLAPSE_KEY_OFF\n : config.collapseKey.trim()\n : DEFAULT_COLLAPSE_KEY;\n\n return { maxWidgetLines, maxTasks, storeTtlMs, collapseKey, delegationTimeoutMs };\n}\n\n/** Rows the overlay may use for content, clamped to a sane range. */\nexport function getMaxWidgetLines(env: NodeJS.ProcessEnv = process.env): number {\n const raw = Number.parseInt(env[MAX_WIDGET_LINES_ENV] ?? '', 10);\n if (!Number.isFinite(raw)) return DEFAULT_MAX_WIDGET_LINES;\n return Math.min(Math.max(raw, MIN_WIDGET_LINES), MAX_WIDGET_LINES);\n}\n\n/** Maximum number of non-deleted tasks retained on one board. */\nexport function getMaxTasks(env: NodeJS.ProcessEnv = process.env): number {\n const raw = Number(env[MAX_TASKS_ENV]);\n return Number.isSafeInteger(raw) && raw > 0 ? raw : DEFAULT_MAX_TASKS;\n}\n\n/** Retention window for inactive session-tree stores. */\nexport function getStoreTtlMs(env: NodeJS.ProcessEnv = process.env): number {\n const raw = Number(env[STORE_TTL_MS_ENV]);\n return Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_STORE_TTL_MS;\n}\n\n/** How long a delegated run may go without reporting a result. */\nexport function getDelegationTimeoutMs(env: NodeJS.ProcessEnv = process.env): number {\n const raw = Number(env[DELEGATION_TIMEOUT_MS_ENV]);\n return Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_DELEGATION_TIMEOUT_MS;\n}\n\n/** Collapse shortcut, or the `off` sentinel when the user disabled it. */\nexport function resolveCollapseKey(env: NodeJS.ProcessEnv = process.env): string {\n const configured = env[COLLAPSE_KEY_ENV]?.trim();\n if (!configured) return DEFAULT_COLLAPSE_KEY;\n return configured.toLowerCase() === COLLAPSE_KEY_OFF ? COLLAPSE_KEY_OFF : configured;\n}\n"],"mappings":";;;;;;;;AAQA,MAAa,uBAAuB;AACpC,MAAa,gBAAgB;AAC7B,MAAa,mBAAmB;AAChC,MAAa,mBAAmB;AAChC,MAAa,4BAA4B;AAEzC,MAAa,2BAA2B;AACxC,MAAa,oBAAoB;AACjC,MAAa,uBAAuB;AACpC,MAAa,uBAAuB;;;AAGpC,MAAa,gCAAgC;AAC7C,MAAa,mBAAmB;AAEhC,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;AAUzB,SAAS,aAAa,OAAyC;CAC7D,OAAO,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IAAK,QAAoC,CAAC;AACtH;;AAGA,SAAgB,kBAAkB,OAA8B;CAC9D,MAAM,SAAS,aAAa,KAAK;CACjC,MAAM,iBACJ,OAAO,OAAO,mBAAmB,YAAY,OAAO,SAAS,OAAO,cAAc,IAC9E,KAAK,IAAI,KAAK,IAAI,OAAO,gBAAgB,gBAAgB,GAAG,gBAAgB,IAAA;CAElF,MAAM,WACJ,OAAO,OAAO,aAAa,YAAY,OAAO,cAAc,OAAO,QAAQ,KAAK,OAAO,WAAW,IAC9F,OAAO,WAAA;CAEb,MAAM,aACJ,OAAO,OAAO,eAAe,YAAY,OAAO,SAAS,OAAO,UAAU,KAAK,OAAO,aAAa,IAC/F,OAAO,aACP;CACN,MAAM,sBACJ,OAAO,OAAO,wBAAwB,YACtC,OAAO,SAAS,OAAO,mBAAmB,KAC1C,OAAO,sBAAsB,IACzB,OAAO,sBACP;CAQN,OAAO;EAAE;EAAgB;EAAU;EAAY,aAN7C,OAAO,OAAO,gBAAgB,YAAY,OAAO,YAAY,KAAK,IAC9D,OAAO,YAAY,KAAK,CAAC,CAAC,YAAY,MAAA,QAAA,QAEpC,OAAO,YAAY,KAAK,IAC1B;EAEsD;CAAoB;AAClF;;AAGA,SAAgB,kBAAkB,MAAyB,QAAQ,KAAa;CAC9E,MAAM,MAAM,OAAO,SAAS,IAAA,iCAA6B,IAAI,EAAE;CAC/D,IAAI,CAAC,OAAO,SAAS,GAAG,GAAG,OAAA;CAC3B,OAAO,KAAK,IAAI,KAAK,IAAI,KAAK,gBAAgB,GAAG,gBAAgB;AACnE;;AAGA,SAAgB,YAAY,MAAyB,QAAQ,KAAa;CACxE,MAAM,MAAM,OAAO,IAAI,cAAc;CACrC,OAAO,OAAO,cAAc,GAAG,KAAK,MAAM,IAAI,MAAA;AAChD;;AAGA,SAAgB,cAAc,MAAyB,QAAQ,KAAa;CAC1E,MAAM,MAAM,OAAO,IAAI,iBAAiB;CACxC,OAAO,OAAO,SAAS,GAAG,KAAK,MAAM,IAAI,MAAM;AACjD;;AAGA,SAAgB,uBAAuB,MAAyB,QAAQ,KAAa;CACnF,MAAM,MAAM,OAAO,IAAI,0BAA0B;CACjD,OAAO,OAAO,SAAS,GAAG,KAAK,MAAM,IAAI,MAAM;AACjD;;AAGA,SAAgB,mBAAmB,MAAyB,QAAQ,KAAa;CAC/E,MAAM,aAAa,IAAI,iBAAiB,EAAE,KAAK;CAC/C,IAAI,CAAC,YAAY,OAAO;CACxB,OAAO,WAAW,YAAY,MAAA,QAAA,QAA4C;AAC5E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delegation-CdMqOZB4.mjs","names":[],"sources":["../src/services/delegation/index.ts"],"sourcesContent":["import {\n type DelegationAccepted as DelegationAcceptedPayload,\n DOOM_DELEGATION_ACCEPTED_EVENT,\n DOOM_DELEGATION_FINISHED_EVENT,\n DOOM_DELEGATION_STARTED_EVENT,\n DOOM_DELEGATION_UPDATED_EVENT,\n type DoomDelegationService,\n type DelegationResult,\n type DelegationStarted as DelegationStartedPayload,\n type DelegationUpdate,\n type InlineAgent,\n} from '@agimon-ai/po-core/delegation';\nimport type { Context } from '@deepseek-ai/cordis';\n\nimport { isBlocked, isTaskListComplete } from '../../models/taskGraph';\nimport { MAX_BRIEF_FILES } from '../../types/delegation';\nimport { TASK_EVENT, type TaskEventName, type TaskFailureReporter } from '../../types/telemetry';\nimport { reconcileOrphanedDelegations } from '../reconcile';\nimport type { TaskStore } from '../taskStore';\n\nexport { MAX_BRIEF_FILES };\nimport { isDelegationActive, type Task, type TaskDelegation, type TaskDocument } from '../../models/task';\n\nexport const NOTIFY_CUSTOM_TYPE = 'doom-task-notify';\nexport const BACKGROUND_WORK_PROVIDER = 'doom-task';\n\nconst DEFAULT_STARTED_TIMEOUT_MS = 5000;\nconst DEFAULT_RUN_TIMEOUT_MS = 20 * 60 * 1000;\nconst DEFAULT_CANCEL_TIMEOUT_MS = 10_000;\nconst MAX_RUN_TIMEOUT_GRACE_MS = 60_000;\nconst MAX_STORED_OUTPUT = 4000;\n/**\n * Cap on files rendered into a brief. Exported so the tool schema can state the\n * same number to the model rather than restating it and drifting.\n */\nconst MAX_BRIEF_NOTES = 1500;\nconst COMPLETED_STATE = 'completed';\nconst FAILED_STATE = 'failed';\nconst CANCELLED_STATE = 'cancelled';\nconst TIMED_OUT_STATUS = 'timed_out';\nconst DELETED_STATUS: Task['status'] = 'deleted';\n\nconst TASK_ID_ATTRIBUTE = 'task.id';\nconst REQUEST_ID_ATTRIBUTE = 'delegation.request_id';\n// `_name` suffix is load-bearing: the telemetry redactor drops string values\n// whose key has no safe meaning, and a bare `delegation.agent` is dropped.\nconst AGENT_ATTRIBUTE = 'delegation.agent_name';\nconst PID_ATTRIBUTE = 'delegation.pid';\nconst CONTEXT_PRESENT_ATTRIBUTE = 'delegation.context_present';\nconst CONTEXT_FILE_COUNT_ATTRIBUTE = 'delegation.context_file_count';\nconst CONTEXT_NOTES_LENGTH_ATTRIBUTE = 'delegation.context_notes_length';\nconst BRIEF_LENGTH_ATTRIBUTE = 'delegation.brief_length';\nconst TOOL_COUNT_ATTRIBUTE = 'delegation.tool_count';\nconst DURATION_MS_ATTRIBUTE = 'delegation.duration_ms';\nconst OUTCOME_ATTRIBUTE = 'delegation.outcome';\n\ntype SettlementState = typeof COMPLETED_STATE | typeof FAILED_STATE | typeof CANCELLED_STATE;\n\nexport const ERR_NO_RUNTIME =\n 'No subagent runtime responded. Delegation needs the subagents extension — relaunch po with agents enabled.';\nexport const ERR_CHILD_SESSION =\n 'assign is only available in the main session. Update this task directly instead of re-delegating it.';\nexport const ERR_CANCEL_UNACKNOWLEDGED = 'Subagent did not acknowledge the cancel request';\n\n/** Live progress from a running subagent. Kept in memory: persisting per-tool\n * ticks would rewrite the store file every second for no durable benefit. */\nexport interface DelegationProgress {\n agent: string;\n currentTool?: string;\n toolCount?: number;\n tokens?: number;\n /** Latest child-runtime duration baseline, excluding assignment wait. */\n durationMs?: number;\n /** Wall-clock time at which durationMs was observed or rebased. */\n durationObservedAt?: number;\n /** Assign-time context-pack shape, carried so the completion event can be\n * grouped by it without joining back to the assignment event. */\n contextFileCount?: number;\n contextNotesLength?: number;\n}\n\nexport type DelegationNotifier = (\n message: { customType: string; content: string; display: boolean },\n options?: { triggerTurn?: boolean; deliverAs?: 'steer' | 'followUp' | 'nextTurn' },\n) => void;\n\nexport interface DelegationPlatform {\n readonly environment: Readonly<Record<string, string | undefined>>;\n readonly processId: number;\n readonly createRequestId: () => string;\n readonly formatBriefPath: (entry: string, cwd: string) => string;\n}\n\nexport interface DelegationManagerOptions {\n store: TaskStore;\n cwd: string;\n platform: DelegationPlatform;\n notify?: DelegationNotifier;\n getSessionId?: () => string | undefined;\n onChange?: () => void;\n startedTimeoutMs?: number;\n /** How long a started run may go without reporting a result. */\n runTimeoutMs?: number;\n /** How long to wait for a cancelled run to report back before forcing it. */\n cancelTimeoutMs?: number;\n now?: () => string;\n nowMs?: () => number;\n /** Called when a completion notification could not be delivered. */\n onNotifyError: (error: unknown, taskId: number) => void;\n /** Where other swallowed delegation failures go. */\n report?: TaskFailureReporter;\n}\n\nexport interface AssignOptions {\n agent?: string;\n inlineAgent?: InlineAgent;\n instructions?: string;\n /** Paths the parent already located, rendered into the brief so the child\n * skips rediscovering them. */\n relevantFiles?: string[];\n /** Facts the parent already established, rendered into the brief so the child\n * does not re-derive them. */\n priorFindings?: string;\n model?: string;\n context?: 'fresh' | 'fork';\n signal?: AbortSignal;\n}\n\nexport interface DelegationOutcome {\n ok: boolean;\n message: string;\n}\n\n/** Result of the guarded store mutation that claims a task for delegation. */\ninterface AssignAttempt extends DelegationOutcome {\n task?: Task;\n}\n\ninterface PendingTask {\n readonly taskId: number;\n readonly sessionId?: string;\n}\n\nfunction truncate(value: string | undefined, limit = MAX_STORED_OUTPUT): string | undefined {\n if (!value) return undefined;\n return value.length <= limit ? value : `${value.slice(0, limit)}\\n… (truncated)`;\n}\n\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/** The assign-time context pack, normalized once for the brief and the telemetry. */\ninterface BriefContext {\n files: string[];\n notes?: string;\n}\n\n/** Normalize the parent context with host-owned path semantics. */\nfunction briefContext(options: AssignOptions, cwd: string, platform: DelegationPlatform): BriefContext {\n const files = new Set<string>();\n for (const entry of options.relevantFiles ?? []) {\n if (files.size >= MAX_BRIEF_FILES) break;\n const normalized = platform.formatBriefPath(entry.trim(), cwd);\n if (normalized && normalized !== '.') files.add(normalized);\n }\n return { files: [...files], notes: truncate(options.priorFindings?.trim(), MAX_BRIEF_NOTES) };\n}\n\n/**\n * Build the brief handed to the subagent.\n *\n * Doom Team owns the child tool surface and the parent owns the task record.\n * Keeping those responsibilities explicit prevents a child from attempting to\n * call a task tool that is not loaded in its runtime, while still giving it a\n * reliable path to ask the parent for a decision.\n *\n * The context pack is the parent's verified discovery handed over. The whole\n * block is omitted when nothing was supplied: this brief is the child's whole\n * starting context, so an empty section header is pure token cost.\n */\nfunction buildBrief(task: Task, instructions: string | undefined, context: BriefContext): string {\n const sections = [`Task #${task.id}: ${task.subject}`];\n if (task.description) sections.push(task.description);\n if (instructions) sections.push(instructions);\n if (context.files.length > 0 || context.notes) {\n const contextLines = ['Parent context — consume before repository discovery:'];\n if (context.files.length > 0) {\n contextLines.push(`- Parent-verified files (read these first with direct reads): ${context.files.join(', ')}`);\n }\n if (context.notes) {\n contextLines.push(\n `- Established facts (do not re-derive unless direct evidence contradicts them): ${context.notes}`,\n );\n }\n contextLines.push(\n 'This pack satisfies initial repository/context exploration. Do not begin with repository-wide listing, find, or grep. Expand only after consuming the pack and naming a concrete missing dependency or invalid path; search narrowly for that item and state why.',\n );\n sections.push(contextLines.join('\\n'));\n }\n sections.push(\n 'Coordination: work directly without changing the task record; ask main through intercom only for blockers or decisions; report changed files and verification when done.',\n );\n return sections.join('\\n\\n');\n}\n\n/**\n * Owns the lifecycle of tasks delegated to subagents.\n *\n * Delegation rides Team's injected Cordis service rather than spawning\n * processes directly, so doom-task stays decoupled from the subagent runtime\n * and degrades to a clear error when that service is not loaded.\n *\n * Liveness rule: every entry in `pendingTasks` has a timer armed against it, so\n * a delegation always has a deadline no matter which phase it is in. Losing\n * that pairing is what previously left tasks running forever.\n */\nexport class DelegationManager {\n private readonly options: DelegationManagerOptions;\n private readonly progress = new Map<string, DelegationProgress>();\n private readonly pendingTasks = new Map<string, PendingTask>();\n private readonly settlingRequests = new Set<string>();\n private readonly timers = new Map<string, ReturnType<typeof setTimeout>>();\n private readonly subscriptions: Array<() => void> = [];\n private service: DoomDelegationService | undefined;\n\n constructor(options: DelegationManagerOptions) {\n this.options = options;\n }\n\n setCwd(cwd: string): void {\n this.options.cwd = cwd;\n }\n\n private now(): string {\n return this.options.now?.() ?? new Date().toISOString();\n }\n\n private nowMs(): number {\n return this.options.nowMs?.() ?? Date.now();\n }\n\n private get runTimeoutMs(): number {\n return this.options.runTimeoutMs ?? DEFAULT_RUN_TIMEOUT_MS;\n }\n\n private report(event: TaskEventName, error: unknown, attributes?: Record<string, string | number | boolean>): void {\n this.options.report?.error(event, error, attributes);\n }\n\n /** True in a session that is itself a subagent child. */\n get isChildSession(): boolean {\n return Boolean(this.options.platform.environment.PI_SUBAGENT_CHILD);\n }\n\n /** Live progress for a task, for the overlay to render. */\n progressFor(task: Task): DelegationProgress | undefined {\n const requestId = task.delegation?.requestId;\n return requestId ? this.progress.get(requestId) : undefined;\n }\n\n /** Displayed runtime duration, rebased from the latest child observation. */\n static elapsedMs(progress: DelegationProgress, nowMs = Date.now()): number {\n const baseline = progress.durationMs ?? 0;\n const observedAt = progress.durationObservedAt ?? nowMs;\n return baseline + Math.max(0, nowMs - observedAt);\n }\n\n /** Rebind to the active Team service without stacking lifecycle listeners. */\n bind(ctx: Context, service: DoomDelegationService): () => void {\n this.unbind();\n this.service = service;\n this.subscriptions.push(\n ctx.on(DOOM_DELEGATION_ACCEPTED_EVENT, (event) => {\n this.handleAccepted(event);\n }),\n ctx.on(DOOM_DELEGATION_STARTED_EVENT, (event) => {\n this.handleStarted(event);\n }),\n ctx.on(DOOM_DELEGATION_UPDATED_EVENT, (event) => {\n this.handleUpdate(event);\n }),\n ctx.on(DOOM_DELEGATION_FINISHED_EVENT, (event) => {\n void this.handleResponse(event).catch((error: unknown) => {\n this.report(TASK_EVENT.delegationResponseFailed, error, { [REQUEST_ID_ATTRIBUTE]: event.requestId });\n });\n }),\n );\n return () => {\n if (this.service === service) this.unbind();\n };\n }\n\n /** Remove only the cross-package binding; task state and watchdogs remain live. */\n unbind(): void {\n for (const unsubscribe of this.subscriptions.splice(0)) unsubscribe();\n this.service = undefined;\n }\n\n /** Items still in flight, surfaced so auto-stop will not kill the harness. */\n listActiveWork(): Array<{ id: string; sessionId: string }> {\n return [...this.pendingTasks.entries()].flatMap(([requestId, pending]) =>\n pending.sessionId ? [{ id: `task-${pending.taskId}:${requestId}`, sessionId: pending.sessionId }] : [],\n );\n }\n\n /**\n * Return tasks nothing can finish to `pending`.\n *\n * The live request set is read inside the mutation so a delegation assigned\n * while the lock was contended is not mistaken for a leftover.\n */\n async reconcile(isCurrent: () => boolean = () => true): Promise<Task[]> {\n const { value } = await this.options.store.mutate((document) => {\n if (!isCurrent()) return { value: [] as Task[] };\n const result = reconcileOrphanedDelegations(document, this.now(), undefined, {\n pid: this.options.platform.processId,\n liveRequestIds: new Set(this.pendingTasks.keys()),\n });\n if (result.orphaned.length === 0) return { value: [] as Task[] };\n return { document: result.document, value: result.orphaned };\n });\n\n if (!isCurrent()) return [];\n for (const task of value) {\n this.options.report?.warn(TASK_EVENT.delegationOrphaned, new Error(task.delegation?.result?.error ?? ''), {\n [TASK_ID_ATTRIBUTE]: task.id,\n ...(task.delegation?.agent ? { [AGENT_ATTRIBUTE]: task.delegation.agent } : {}),\n ...(task.delegation?.pid === undefined ? {} : { [PID_ATTRIBUTE]: task.delegation.pid }),\n });\n }\n\n if (value.length > 0) this.options.onChange?.();\n return value;\n }\n\n async assign(taskId: number, options: AssignOptions): Promise<DelegationOutcome> {\n const agent = options.agent?.trim();\n if (!agent) return { ok: false, message: 'agent required for assign' };\n if (this.isChildSession) return { ok: false, message: ERR_CHILD_SESSION };\n if (options.signal?.aborted) return { ok: false, message: 'delegation cancelled before it started' };\n\n const requestId = this.options.platform.createRequestId();\n const startedAt = this.now();\n const sessionId = this.options.getSessionId?.();\n const context = briefContext(options, this.options.cwd, this.options.platform);\n\n const { value: outcome } = await this.options.store.mutate<AssignAttempt>((current) => {\n const index = current.tasks.findIndex((task) => task.id === taskId);\n if (index === -1) return { value: { ok: false, message: `#${taskId} not found` } };\n\n const task = current.tasks[index];\n if (task.status === DELETED_STATUS) return { value: { ok: false, message: `#${taskId} is deleted` } };\n if (task.status === COMPLETED_STATE) {\n return { value: { ok: false, message: `#${taskId} is already completed` } };\n }\n if (isDelegationActive(task)) {\n return { value: { ok: false, message: `#${taskId} is already delegated to ${task.delegation?.agent}` } };\n }\n if (isBlocked(current.tasks, task)) {\n const blockers = (task.blockedBy ?? []).map((id) => `#${id}`).join(', ');\n return { value: { ok: false, message: `#${taskId} is blocked by ${blockers}` } };\n }\n\n const delegation: TaskDelegation = {\n requestId,\n agent,\n state: 'requested',\n pid: this.options.platform.processId,\n startedAt,\n ...(sessionId ? { sessionId } : {}),\n ...(options.model ? { model: options.model } : {}),\n };\n\n const tasks = [...current.tasks];\n tasks[index] = { ...task, owner: agent, updatedAt: startedAt, delegation };\n return {\n document: { ...current, tasks },\n value: { ok: true, message: '', task: tasks[index] },\n };\n });\n\n if (!outcome.ok || !outcome.task) return { ok: false, message: outcome.message };\n\n const contextNotesLength = context.notes?.length ?? 0;\n this.pendingTasks.set(requestId, { taskId, sessionId });\n this.progress.set(requestId, { agent, contextFileCount: context.files.length, contextNotesLength });\n this.armStartedTimeout(requestId);\n this.options.onChange?.();\n const request = {\n requestId,\n taskId,\n agent,\n ...(options.inlineAgent ? { inlineAgent: options.inlineAgent } : {}),\n prompt: buildBrief(outcome.task, options.instructions, context),\n ...(options.context ? { context: options.context } : {}),\n cwd: this.options.cwd,\n artifacts: true,\n timeoutMs: this.runTimeoutMs,\n runMode: 'detached' as const,\n teamTask: { id: String(outcome.task.id), subject: outcome.task.subject },\n ...(options.model ? { model: options.model } : {}),\n };\n\n try {\n const service = this.service;\n if (!service) throw new Error(ERR_NO_RUNTIME);\n void service.request(request).catch((error: unknown) => {\n this.report(TASK_EVENT.delegationRequestFailed, error, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n [AGENT_ATTRIBUTE]: agent,\n });\n this.settleDetached(requestId, FAILED_STATE, {\n status: FAILED_STATE,\n error: `Delegation request failed: ${messageOf(error)}`,\n });\n });\n } catch (error) {\n this.report(TASK_EVENT.delegationRequestFailed, error, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n [AGENT_ATTRIBUTE]: agent,\n });\n const detail = messageOf(error);\n await this.settle(requestId, FAILED_STATE, {\n status: FAILED_STATE,\n error: `Delegation request failed: ${detail}`,\n });\n return { ok: false, message: `Could not dispatch #${taskId} to ${agent}: ${detail}` };\n }\n\n // Recorded only after the service accepted the request call, so it means a\n // brief actually entered Team's state machine rather than merely being assembled.\n this.options.report?.event(TASK_EVENT.delegationAssigned, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n [AGENT_ATTRIBUTE]: agent,\n [CONTEXT_PRESENT_ATTRIBUTE]: context.files.length > 0 || contextNotesLength > 0,\n [CONTEXT_FILE_COUNT_ATTRIBUTE]: context.files.length,\n [CONTEXT_NOTES_LENGTH_ATTRIBUTE]: contextNotesLength,\n [BRIEF_LENGTH_ATTRIBUTE]: request.prompt.length,\n });\n\n return {\n ok: true,\n message: `Delegated #${taskId} to ${agent} in the background. It runs independently of this turn and will notify you when it finishes. Continue non-overlapping work, or end your turn.`,\n };\n }\n\n async cancel(taskId: number): Promise<DelegationOutcome> {\n const document = this.options.store.read();\n const task = document.tasks.find((candidate) => candidate.id === taskId);\n if (!task) return { ok: false, message: `#${taskId} not found` };\n if (!task.delegation || !isDelegationActive(task)) {\n return { ok: false, message: `#${taskId} has no running delegation` };\n }\n\n const { requestId } = task.delegation;\n this.service?.cancel({ requestId });\n // Only this session can force the outcome; a delegation owned elsewhere\n // gets the request and nothing more.\n this.armCancelTimeout(requestId);\n return { ok: true, message: `Cancelling delegation for #${taskId} (${task.delegation.agent})` };\n }\n\n /** Settle without awaiting, reporting rather than dropping a failure. */\n private settleDetached(\n requestId: string,\n state: SettlementState,\n result: TaskDelegation['result'],\n event: TaskEventName = TASK_EVENT.delegationSettleFailed,\n ): void {\n void this.settle(requestId, state, result).catch((error: unknown) => {\n this.report(event, error, { [REQUEST_ID_ATTRIBUTE]: requestId });\n });\n }\n\n /**\n * Fail a delegation that nobody acknowledged.\n *\n * Provider loss or a stalled Team runtime can still leave a dispatched\n * request silent. Without this acknowledgement deadline the task would sit\n * in `requested` forever.\n */\n private armStartedTimeout(requestId: string): void {\n this.armTimer(requestId, this.options.startedTimeoutMs ?? DEFAULT_STARTED_TIMEOUT_MS, () => {\n this.settleDetached(requestId, FAILED_STATE, { status: FAILED_STATE, error: ERR_NO_RUNTIME });\n });\n }\n\n /**\n * Bound a run that already started.\n *\n * The request carries the same budget, so in the normal case the runtime ends\n * the run itself and reports a richer result. The grace period biases toward\n * that answer; this timer only covers a runtime that goes silent, which is\n * precisely the case where no response event will ever arrive.\n */\n private armRunTimeout(requestId: string): void {\n const grace = Math.min(MAX_RUN_TIMEOUT_GRACE_MS, this.runTimeoutMs);\n this.armTimer(requestId, this.runTimeoutMs + grace, () => {\n const taskId = this.pendingTasks.get(requestId)?.taskId;\n const agent = this.progress.get(requestId)?.agent;\n const error = new Error(`Delegation produced no result within ${this.runTimeoutMs}ms`);\n this.options.report?.warn(TASK_EVENT.delegationTimedOut, error, {\n ...(taskId === undefined ? {} : { [TASK_ID_ATTRIBUTE]: taskId }),\n [REQUEST_ID_ATTRIBUTE]: requestId,\n ...(agent ? { [AGENT_ATTRIBUTE]: agent } : {}),\n });\n this.service?.cancel({ requestId, reason: error.message });\n this.settleDetached(requestId, FAILED_STATE, { status: TIMED_OUT_STATUS, error: error.message });\n });\n }\n\n /**\n * Guarantee a cancel reaches a terminal state.\n *\n * Calling the service is a request, not an outcome: a runtime that has\n * already forgotten the request answers nothing at all. The window still\n * favours a real response, which carries the run's partial output.\n */\n private armCancelTimeout(requestId: string): void {\n if (!this.pendingTasks.has(requestId)) return;\n this.armTimer(requestId, this.options.cancelTimeoutMs ?? DEFAULT_CANCEL_TIMEOUT_MS, () => {\n this.settleDetached(requestId, CANCELLED_STATE, {\n status: CANCELLED_STATE,\n error: ERR_CANCEL_UNACKNOWLEDGED,\n });\n });\n }\n\n private armTimer(requestId: string, delayMs: number, onFire: () => void): void {\n this.clearTimer(requestId);\n const timer = setTimeout(onFire, delayMs);\n timer.unref?.();\n this.timers.set(requestId, timer);\n }\n\n private clearTimer(requestId: string): void {\n const timer = this.timers.get(requestId);\n if (timer) clearTimeout(timer);\n this.timers.delete(requestId);\n }\n\n /** Runtime acknowledgement moves the request off the short extension-presence watchdog while launch is in flight. */\n private handleAccepted(event: DelegationAcceptedPayload): void {\n if (!this.pendingTasks.has(event.requestId)) return;\n this.armRunTimeout(event.requestId);\n }\n\n private handleStarted(event: DelegationStartedPayload): void {\n const { runId } = event;\n const taskId = this.pendingTasks.get(event.requestId)?.taskId;\n if (taskId === undefined) return;\n this.armRunTimeout(event.requestId);\n const existing = this.progress.get(event.requestId);\n if (existing) {\n this.progress.set(event.requestId, {\n ...existing,\n durationMs: existing.durationMs ?? 0,\n durationObservedAt: existing.durationObservedAt ?? this.nowMs(),\n });\n }\n\n void this.options.store\n .mutate((document) =>\n this.patchDelegation(document, event.requestId, (task, delegation) => ({\n ...task,\n status: task.status === COMPLETED_STATE ? task.status : 'in_progress',\n delegation: {\n ...delegation,\n state: 'running',\n startedAt: delegation.startedAt ?? this.now(),\n ...(runId ? { runId } : {}),\n },\n })),\n )\n .then(() => this.options.onChange?.())\n .catch((error: unknown) => {\n this.report(TASK_EVENT.delegationStartFailed, error, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: event.requestId,\n });\n });\n }\n\n private handleUpdate(event: DelegationUpdate): void {\n const existing = this.progress.get(event.requestId);\n if (!existing) return;\n\n const observedAt = this.nowMs();\n const currentElapsed = DelegationManager.elapsedMs(existing, observedAt);\n const hasDuration = event.durationMs !== undefined;\n this.progress.set(event.requestId, {\n // Spread, not field-by-field: anything carried on progress that this\n // event does not report (the assign-time context shape) must survive the\n // first update, or the completion event reports it as absent.\n ...existing,\n currentTool: event.currentTool ?? existing.currentTool,\n toolCount:\n event.toolCount === undefined ? existing.toolCount : Math.max(existing.toolCount ?? 0, event.toolCount),\n tokens: event.tokens === undefined ? existing.tokens : Math.max(existing.tokens ?? 0, event.tokens),\n durationMs: hasDuration ? Math.max(currentElapsed, event.durationMs!) : existing.durationMs,\n durationObservedAt: hasDuration ? observedAt : existing.durationObservedAt,\n });\n this.options.onChange?.();\n }\n\n private async handleResponse(event: DelegationResult): Promise<void> {\n if (!this.pendingTasks.has(event.requestId)) return;\n\n const succeeded = event.status === COMPLETED_STATE && !event.error;\n const state = succeeded ? COMPLETED_STATE : event.status === CANCELLED_STATE ? CANCELLED_STATE : FAILED_STATE;\n await this.settle(event.requestId, state, {\n status: event.status,\n error: event.error,\n output: truncate(event.output),\n outputPath: event.outputPath,\n sessionFile: event.sessionFile,\n durationMs: event.durationMs,\n toolCount: event.toolCount,\n });\n }\n\n /**\n * Apply the terminal state of a delegation and tell the model about it.\n *\n * A cancelled run returns the task to `pending` (the work is still wanted,\n * just not by that agent); a failure marks it `failed` so it stays visible\n * rather than silently rejoining the backlog.\n *\n * The request is claimed in `settlingRequests` while it remains published as\n * active work. It is removed only after the terminal state and model notification\n * have been handed off, so an auto-stop observer cannot end the session between\n * receiving the result and delivering it to the model.\n */\n private async settle(requestId: string, state: SettlementState, result: TaskDelegation['result']): Promise<void> {\n const pending = this.pendingTasks.get(requestId);\n if (!pending || this.settlingRequests.has(requestId)) return;\n this.settlingRequests.add(requestId);\n this.clearTimer(requestId);\n const { taskId } = pending;\n const progress = this.progress.get(requestId);\n\n try {\n const endedAt = this.now();\n let task: Task | undefined;\n try {\n const { value } = await this.options.store.mutate((document) =>\n this.patchDelegation(document, requestId, (current, delegation) => ({\n ...current,\n status: state === COMPLETED_STATE ? COMPLETED_STATE : state === CANCELLED_STATE ? 'pending' : FAILED_STATE,\n updatedAt: endedAt,\n delegation: { ...delegation, state, endedAt, ...(result ? { result } : {}) },\n })),\n );\n task = value;\n } catch (error) {\n this.report(TASK_EVENT.delegationSettleFailed, error, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n });\n }\n\n const agent = task?.delegation?.agent ?? progress?.agent ?? 'subagent';\n const subject = task?.subject ?? `#${taskId}`;\n\n // Repeats the assign-time context shape so the cost question (\"did packs\n // reduce child tool calls?\") is one grouping rather than a self-join.\n // A run that never started reports neither metric, keeping the medians clean.\n this.options.report?.event(TASK_EVENT.delegationCompleted, {\n [TASK_ID_ATTRIBUTE]: taskId,\n [REQUEST_ID_ATTRIBUTE]: requestId,\n [AGENT_ATTRIBUTE]: agent,\n [OUTCOME_ATTRIBUTE]: state,\n [CONTEXT_PRESENT_ATTRIBUTE]: (progress?.contextFileCount ?? 0) > 0 || (progress?.contextNotesLength ?? 0) > 0,\n [CONTEXT_FILE_COUNT_ATTRIBUTE]: progress?.contextFileCount ?? 0,\n [CONTEXT_NOTES_LENGTH_ATTRIBUTE]: progress?.contextNotesLength ?? 0,\n ...(result?.toolCount === undefined ? {} : { [TOOL_COUNT_ATTRIBUTE]: result.toolCount }),\n ...(result?.durationMs === undefined ? {} : { [DURATION_MS_ATTRIBUTE]: result.durationMs }),\n });\n const listComplete =\n state === COMPLETED_STATE && task !== undefined && isTaskListComplete(this.options.store.snapshot.tasks);\n this.notifyModel(state, taskId, subject, agent, result, listComplete);\n } finally {\n this.pendingTasks.delete(requestId);\n this.progress.delete(requestId);\n this.settlingRequests.delete(requestId);\n this.options.onChange?.();\n }\n }\n\n private notifyModel(\n state: SettlementState,\n taskId: number,\n subject: string,\n agent: string,\n result: TaskDelegation['result'],\n listComplete: boolean,\n ): void {\n const notify = this.options.notify;\n if (!notify) return;\n\n const headline =\n state === COMPLETED_STATE\n ? `Subagent ${agent} completed task #${taskId}: ${subject}`\n : state === CANCELLED_STATE\n ? `Subagent ${agent} was cancelled on task #${taskId}: ${subject} (returned to pending)`\n : `Subagent ${agent} failed task #${taskId}: ${subject}`;\n\n const lines = [headline];\n if (listComplete) {\n lines.push(\n '',\n 'All tasks are completed. Review the full task list once more, then close it with task {\"action\":\"clear\"}.',\n );\n }\n if (result?.error) lines.push(`Error: ${result.error}`);\n if (result?.output) lines.push('', result.output);\n if (result?.outputPath) lines.push('', `Full output: ${result.outputPath}`);\n\n try {\n notify(\n { customType: NOTIFY_CUSTOM_TYPE, content: lines.join('\\n'), display: true },\n { triggerTurn: true, deliverAs: 'steer' },\n );\n } catch (error) {\n // The delegation state is already committed to the store, so a failed\n // notification costs the model its wake-up, not the result. Report it\n // rather than rethrowing, which would strand the settled run.\n this.options.onNotifyError(error, taskId);\n }\n }\n\n /**\n * Rewrite the task carrying `requestId`, returning the updated task as the mutation value.\n *\n * Terminal delegations are left alone. The document here is the freshest one,\n * read under the store lock, which is the only place the check is meaningful:\n * a `started` event can land after a cancel already settled the run, and\n * without this guard its write would resurrect a delegation that nothing is\n * tracking any more.\n */\n private patchDelegation(\n document: TaskDocument,\n requestId: string,\n patch: (task: Task, delegation: TaskDelegation) => Task,\n ): { document?: TaskDocument; value: Task | undefined } {\n const index = document.tasks.findIndex((task) => task.delegation?.requestId === requestId);\n if (index === -1) return { value: undefined };\n\n const task = document.tasks[index];\n if (!isDelegationActive(task)) return { value: task };\n\n const updated = patch(task, task.delegation!);\n if (updated === task) return { value: task };\n const tasks = [...document.tasks];\n tasks[index] = updated;\n return { document: { ...document, tasks }, value: updated };\n }\n\n dispose(): void {\n this.unbind();\n this.reset();\n }\n\n /** Clear one Pi session's transient delegation state without losing service injection. */\n reset(): void {\n const changed = this.pendingTasks.size > 0 || this.progress.size > 0;\n for (const timer of this.timers.values()) clearTimeout(timer);\n this.timers.clear();\n this.pendingTasks.clear();\n this.settlingRequests.clear();\n this.progress.clear();\n if (changed) this.options.onChange?.();\n }\n}\n"],"mappings":";;;;;;;AAuBA,MAAa,qBAAqB;AAClC,MAAa,2BAA2B;AAExC,MAAM,6BAA6B;AACnC,MAAM,yBAAyB;AAC/B,MAAM,4BAA4B;AAClC,MAAM,2BAA2B;AACjC,MAAM,oBAAoB;;;;;AAK1B,MAAM,kBAAkB;AACxB,MAAM,kBAAkB;AACxB,MAAM,eAAe;AACrB,MAAM,kBAAkB;AACxB,MAAM,mBAAmB;AACzB,MAAM,iBAAiC;AAEvC,MAAM,oBAAoB;AAC1B,MAAM,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