@agimon-ai/doompi-task 0.0.1-alpha.18 → 0.0.1-alpha.19
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/README.md +4 -0
- package/dist/adapters/pi/extension.cjs +1 -1
- package/dist/adapters/pi/extension.cjs.map +1 -1
- package/dist/adapters/pi/extension.d.cts.map +1 -1
- package/dist/adapters/pi/extension.d.mts.map +1 -1
- package/dist/adapters/pi/extension.mjs +2 -2
- package/dist/adapters/pi/extension.mjs.map +1 -1
- package/dist/commands/task/taskTool.cjs +2 -2
- package/dist/commands/task/taskTool.cjs.map +1 -1
- package/dist/commands/task/taskTool.d.cts +1 -0
- package/dist/commands/task/taskTool.d.cts.map +1 -1
- package/dist/commands/task/taskTool.d.mts +1 -0
- package/dist/commands/task/taskTool.d.mts.map +1 -1
- package/dist/commands/task/taskTool.mjs +2 -2
- package/dist/commands/task/taskTool.mjs.map +1 -1
- package/dist/config.cjs +1 -1
- package/dist/config.d.cts +2 -2
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/services/store/reducer.cjs +1 -1
- package/dist/services/store/reducer.cjs.map +1 -1
- package/dist/services/store/reducer.d.cts +1 -1
- package/dist/services/store/reducer.d.cts.map +1 -1
- package/dist/services/store/reducer.d.mts +1 -1
- package/dist/services/store/reducer.d.mts.map +1 -1
- package/dist/services/store/reducer.mjs +1 -1
- package/dist/services/store/reducer.mjs.map +1 -1
- package/dist/types/config.cjs +1 -1
- package/dist/types/config.cjs.map +1 -1
- package/dist/types/config.d.cts +6 -1
- package/dist/types/config.d.cts.map +1 -1
- package/dist/types/config.d.mts +6 -1
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/config.mjs +1 -1
- package/dist/types/config.mjs.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -48,6 +48,10 @@ connects the graph to the Doom TUI and team runtime.
|
|
|
48
48
|
|
|
49
49
|
`SPC t t` opens the task board.
|
|
50
50
|
|
|
51
|
+
## Task limit
|
|
52
|
+
|
|
53
|
+
A board allows 15 non-deleted tasks by default. Set `DOOM_TASK_MAX_TASKS` to a positive integer to change the limit. When the board is full, updates still apply, but new tasks are rejected until completed tasks are deleted.
|
|
54
|
+
|
|
51
55
|
## Public API
|
|
52
56
|
|
|
53
57
|
The package exports its task model, storage, tools, TUI, and Pi/Doom adapters through
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const e=require("../telemetry/logSinkTelemetry.cjs"),t=require("../../services/delegation/manager.cjs"),n=require("../../schemas/task.cjs"),r=require("../../commands/index.cjs"),i=require("../../commands/task/taskTool.cjs"),
|
|
1
|
+
const e=require("../telemetry/logSinkTelemetry.cjs"),t=require("../../services/delegation/manager.cjs"),n=require("../../schemas/task.cjs"),r=require("../../commands/index.cjs"),i=require("../../types/config.cjs"),a=require("../../commands/task/taskTool.cjs"),o=require("../../services/narration/taskNarration.cjs"),s=require("../store/paths.cjs");require("../../services/store/paths.cjs");const c=require("../store/taskStore.cjs");require("../../services/store/taskStore.cjs");const l=require("../../tui/taskOverlay.cjs");let u=require("@agimon-ai/doompi-extension-contracts/background-work"),d=require("@agimon-ai/doompi-extension-contracts/narration"),f=require("@agimon-ai/doompi-extension-contracts/protocol"),p=require("@agimon-ai/doompi-ui/leader"),m=require("@earendil-works/pi-tui");const h=`@agimon-ai/doompi-task`,g={narrate:()=>void 0};function _(_){let v=e.createTaskErrorReporter(),y=e.toFailureReporter(v),b=g,x=new c.TaskStore({report:y,onCommitted:(e,t)=>o.narrateTaskCommit(b,e,t)}),S,C,w,T,E=()=>{C?.update(),T?.update()},D=new t.DelegationManager({events:_.events,store:x,cwd:process.cwd(),notify:(e,t)=>_.sendMessage(e,t),getSessionId:()=>S,onChange:E,runTimeoutMs:i.getDelegationTimeoutMs(),report:y,onNotifyError:(e,t)=>{v.recordNotificationError(e,t)}});C=new l.TaskOverlay({getTasks:()=>x.snapshot.tasks,delegation:D}),a.registerTaskTool(_,{store:x,delegation:D,maxTasks:i.getMaxTasks(),onChange:E,report:y}),r.registerTasksCommand(_,x),(0,p.registerDoomLeaderContribution)(_,{source:h,bindings:[{id:`tasks.open`,path:[{key:`t`,label:`tasks`,order:65},{key:`t`,label:`tasks`}],command:{name:n.COMMAND_NAME}}]}),_.registerMessageRenderer(t.NOTIFY_CUSTOM_TYPE,(e,t,n)=>{let r=typeof e.content==`string`?e.content:``;return new m.Text(n.fg(`muted`,r),0,0)});let O=i.resolveCollapseKey();O!==`off`&&_.registerShortcut(O,{description:`Collapse or expand the task overlay`,handler:e=>{!e.hasUI||!C?.isRegistered()||C.toggleCollapse()}}),_.on(`session_start`,async(n,r)=>{try{let n=r;if(S=n.sessionManager?.getSessionId(),!S)throw Error(`doom-task requires a session id`);b=(0,d.createNarrationRequester)({bus:_.events,source:h,sessionId:S}),T?.dispose(),T=n.hasUI?void 0:(0,u.registerBackgroundWorkProvider)((0,f.createProtocolRuntime)({bus:_.events,source:h,sessionId:S}),{provider:t.BACKGROUND_WORK_PROVIDER,listActiveWork:()=>D.listActiveWork()}),x.configureSession(s.resolveSessionKey(S));let a=await s.removeLegacyStoreDirectoryAsync(x.storePath),o=s.hasStorePathOverride()?{removed:[],errors:[]}:await s.sweepStoreFilesAsync(x.storePath,i.getStoreTtlMs()),c=[...a.errors,...o.errors];for(let t of c)y.warn(e.TASK_EVENT.storeSweepFailed,Error(t));c.length>0&&n.hasUI&&n.ui.notify(c.join(`
|
|
2
2
|
`),`warning`),n.hasUI&&C?.setUICtx(n.ui),await x.readAsync(),w=x.onExternalChange(E),D.start(),await D.reconcile(),E()}catch(t){throw y.error(e.TASK_EVENT.sessionStartFailed,t),t}}),_.on(`session_compact`,()=>E()),_.on(`session_tree`,()=>E()),_.on(`tool_execution_end`,e=>{e.toolName===`task`&&E()}),_.on(`session_shutdown`,async()=>{try{w?.(),T?.dispose(),T=void 0,D.dispose(),C?.dispose(),x.dispose(),b=g}finally{await v.shutdown()}})}exports.default=_,exports.taskExtension=_;
|
|
3
3
|
//# sourceMappingURL=extension.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.cjs","names":["createTaskErrorReporter","toFailureReporter","TaskStore","narrateTaskCommit","DelegationManager","getDelegationTimeoutMs","TaskOverlay","COMMAND_NAME","NOTIFY_CUSTOM_TYPE","Text","resolveCollapseKey","createNarrationRequester","registerBackgroundWorkProvider","createProtocolRuntime","BACKGROUND_WORK_PROVIDER","resolveSessionKey","removeLegacyStoreDirectoryAsync","hasStorePathOverride","sweepStoreFilesAsync","getStoreTtlMs","TASK_EVENT"],"sources":["../../../src/adapters/pi/extension.ts"],"sourcesContent":["import {\n type BackgroundWorkProviderHandle,\n registerBackgroundWorkProvider,\n} from '@agimon-ai/doompi-extension-contracts/background-work';\nimport { createNarrationRequester, type NarrationRequester } from '@agimon-ai/doompi-extension-contracts/narration';\nimport { createProtocolRuntime } from '@agimon-ai/doompi-extension-contracts/protocol';\nimport { registerDoomLeaderContribution } from '@agimon-ai/doompi-ui/leader';\nimport type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\nimport type { KeyId } from '@earendil-works/pi-tui';\nimport { Text } from '@earendil-works/pi-tui';\nimport { registerTasksCommand } from '../../commands/index.ts';\nimport { registerTaskTool } from '../../commands/task/taskTool.ts';\nimport { COMMAND_NAME, TOOL_NAME } from '../../schemas/task.ts';\nimport { BACKGROUND_WORK_PROVIDER, DelegationManager, NOTIFY_CUSTOM_TYPE } from '../../services/delegation/manager.ts';\nimport { narrateTaskCommit } from '../../services/narration/taskNarration.ts';\nimport {\n hasStorePathOverride,\n removeLegacyStoreDirectoryAsync,\n resolveSessionKey,\n sweepStoreFilesAsync,\n} from '../../services/store/paths.ts';\nimport { TaskStore } from '../../services/store/taskStore.ts';\nimport { TaskOverlay } from '../../tui/taskOverlay.ts';\nimport { COLLAPSE_KEY_OFF, getDelegationTimeoutMs, getStoreTtlMs, resolveCollapseKey } from '../../types/config.ts';\nimport { createTaskErrorReporter, TASK_EVENT, toFailureReporter } from '../telemetry/logSinkTelemetry.ts';\n\ninterface SessionContextLike {\n hasUI: boolean;\n ui: Parameters<TaskOverlay['setUICtx']>[0];\n sessionManager?: { getSessionId(): string };\n}\n\nconst LEADER_SOURCE = '@agimon-ai/doompi-task';\nconst SILENT_NARRATION_REQUESTER: NarrationRequester = { narrate: () => undefined };\n/** Between doom-plan's 60 and the core help group's 70, so `t` sits after `p`. */\nconst LEADER_GROUP_ORDER = 65;\nconst SESSION_START_EVENT = 'session_start';\nconst SESSION_COMPACT_EVENT = 'session_compact';\nconst SESSION_TREE_EVENT = 'session_tree';\nconst TOOL_EXECUTION_END_EVENT = 'tool_execution_end';\nconst SESSION_SHUTDOWN_EVENT = 'session_shutdown';\n\n/**\n * doom-task: a session-tree-scoped, file-backed task list with delegation.\n *\n * A root session and its delegated descendants share one durable JSON file.\n * Unrelated sessions resolve to separate stores outside repository metadata.\n */\nexport function taskExtension(pi: ExtensionAPI): void {\n const errorReporter = createTaskErrorReporter();\n const report = toFailureReporter(errorReporter);\n let narrationRequester = SILENT_NARRATION_REQUESTER;\n const store = new TaskStore({\n report,\n onCommitted: (previous, committed) => narrateTaskCommit(narrationRequester, previous, committed),\n });\n let sessionId: string | undefined;\n let overlay: TaskOverlay | undefined;\n let unwatch: (() => void) | undefined;\n let backgroundWork: BackgroundWorkProviderHandle | undefined;\n\n const refresh = (): void => {\n overlay?.update();\n backgroundWork?.update();\n };\n\n const delegation = new DelegationManager({\n events: pi.events,\n store,\n cwd: process.cwd(),\n notify: (message, options) => pi.sendMessage(message, options),\n getSessionId: () => sessionId,\n onChange: refresh,\n runTimeoutMs: getDelegationTimeoutMs(),\n report,\n onNotifyError: (error, taskId) => {\n void errorReporter.recordNotificationError(error, taskId);\n },\n });\n\n overlay = new TaskOverlay({ getTasks: () => store.snapshot.tasks, delegation });\n\n registerTaskTool(pi, { store, delegation, onChange: refresh, report });\n registerTasksCommand(pi, store);\n\n // `SPC t` remains a group so other task-related surfaces can share the prefix.\n // doom-pi-ui keeps no core group on `t`; a conflicting claim is rejected there\n // with a diagnostic.\n registerDoomLeaderContribution(pi, {\n source: LEADER_SOURCE,\n bindings: [\n {\n id: 'tasks.open',\n path: [\n { key: 't', label: 'tasks', order: LEADER_GROUP_ORDER },\n { key: 't', label: 'tasks' },\n ],\n command: { name: COMMAND_NAME },\n },\n ],\n });\n\n pi.registerMessageRenderer(NOTIFY_CUSTOM_TYPE, (message, _options, theme) => {\n const content = typeof message.content === 'string' ? message.content : '';\n return new Text(theme.fg('muted', content), 0, 0);\n });\n\n const collapseKey = resolveCollapseKey();\n if (collapseKey !== COLLAPSE_KEY_OFF) {\n pi.registerShortcut(collapseKey as KeyId, {\n description: 'Collapse or expand the task overlay',\n handler: (ctx) => {\n if (!ctx.hasUI || !overlay?.isRegistered()) return;\n overlay.toggleCollapse();\n },\n });\n }\n\n pi.on(SESSION_START_EVENT, async (_event, ctx) => {\n // Anything thrown before reconcile() skips the only recovery pass for\n // delegations left behind by the previous session, so the failure must not\n // disappear into the harness.\n try {\n const context = ctx as unknown as SessionContextLike;\n sessionId = context.sessionManager?.getSessionId();\n if (!sessionId) throw new Error('doom-task requires a session id');\n narrationRequester = createNarrationRequester({\n bus: pi.events,\n source: LEADER_SOURCE,\n sessionId,\n });\n backgroundWork?.dispose();\n backgroundWork = context.hasUI\n ? undefined\n : registerBackgroundWorkProvider(\n createProtocolRuntime({\n bus: pi.events,\n source: LEADER_SOURCE,\n sessionId,\n }),\n {\n provider: BACKGROUND_WORK_PROVIDER,\n listActiveWork: () => delegation.listActiveWork(),\n },\n );\n store.configureSession(resolveSessionKey(sessionId));\n const cleanup = await removeLegacyStoreDirectoryAsync(store.storePath);\n const sweep = hasStorePathOverride()\n ? { removed: [], errors: [] }\n : await sweepStoreFilesAsync(store.storePath, getStoreTtlMs());\n const storeErrors = [...cleanup.errors, ...sweep.errors];\n for (const failure of storeErrors) report.warn(TASK_EVENT.storeSweepFailed, new Error(failure));\n if (storeErrors.length > 0 && context.hasUI) context.ui.notify(storeErrors.join('\\n'), 'warning');\n if (context.hasUI) overlay?.setUICtx(context.ui);\n await store.readAsync();\n unwatch = store.onExternalChange(refresh);\n // A shutdown that kept the process alive left the manager unsubscribed.\n delegation.start();\n await delegation.reconcile();\n refresh();\n } catch (error) {\n report.error(TASK_EVENT.sessionStartFailed, error);\n throw error;\n }\n });\n\n pi.on(SESSION_COMPACT_EVENT, () => refresh());\n pi.on(SESSION_TREE_EVENT, () => refresh());\n\n pi.on(TOOL_EXECUTION_END_EVENT, (event) => {\n if (event.toolName === TOOL_NAME) refresh();\n });\n\n pi.on(SESSION_SHUTDOWN_EVENT, async () => {\n try {\n unwatch?.();\n backgroundWork?.dispose();\n backgroundWork = undefined;\n delegation.dispose();\n overlay?.dispose();\n store.dispose();\n narrationRequester = SILENT_NARRATION_REQUESTER;\n } finally {\n // Runs even if teardown throws: the buffered records are most valuable\n // exactly when something went wrong on the way out.\n await errorReporter.shutdown();\n }\n });\n}\n\nexport default taskExtension;\n"],"mappings":"wxBAgCA,MAAM,EAAgB,yBAChB,EAAiD,CAAE,YAAe,IAAA,EAAU,EAelF,SAAgB,EAAc,EAAwB,CACpD,IAAM,EAAgBA,EAAAA,wBAAwB,EACxC,EAASC,EAAAA,kBAAkB,CAAa,EAC1C,EAAqB,EACnB,EAAQ,IAAIC,EAAAA,UAAU,CAC1B,SACA,aAAc,EAAU,IAAcC,EAAAA,kBAAkB,EAAoB,EAAU,CAAS,CACjG,CAAC,EACG,EACA,EACA,EACA,EAEE,MAAsB,CAC1B,GAAS,OAAO,EAChB,GAAgB,OAAO,CACzB,EAEM,EAAa,IAAIC,EAAAA,kBAAkB,CACvC,OAAQ,EAAG,OACX,QACA,IAAK,QAAQ,IAAI,EACjB,QAAS,EAAS,IAAY,EAAG,YAAY,EAAS,CAAO,EAC7D,iBAAoB,EACp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SAAS,CAC/B,CACF,CAAC,CACH"}
|
|
1
|
+
{"version":3,"file":"extension.cjs","names":["createTaskErrorReporter","toFailureReporter","TaskStore","narrateTaskCommit","DelegationManager","getDelegationTimeoutMs","TaskOverlay","getMaxTasks","COMMAND_NAME","NOTIFY_CUSTOM_TYPE","Text","resolveCollapseKey","createNarrationRequester","registerBackgroundWorkProvider","createProtocolRuntime","BACKGROUND_WORK_PROVIDER","resolveSessionKey","removeLegacyStoreDirectoryAsync","hasStorePathOverride","sweepStoreFilesAsync","getStoreTtlMs","TASK_EVENT"],"sources":["../../../src/adapters/pi/extension.ts"],"sourcesContent":["import {\n type BackgroundWorkProviderHandle,\n registerBackgroundWorkProvider,\n} from '@agimon-ai/doompi-extension-contracts/background-work';\nimport { createNarrationRequester, type NarrationRequester } from '@agimon-ai/doompi-extension-contracts/narration';\nimport { createProtocolRuntime } from '@agimon-ai/doompi-extension-contracts/protocol';\nimport { registerDoomLeaderContribution } from '@agimon-ai/doompi-ui/leader';\nimport type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\nimport type { KeyId } from '@earendil-works/pi-tui';\nimport { Text } from '@earendil-works/pi-tui';\nimport { registerTasksCommand } from '../../commands/index.ts';\nimport { registerTaskTool } from '../../commands/task/taskTool.ts';\nimport { COMMAND_NAME, TOOL_NAME } from '../../schemas/task.ts';\nimport { BACKGROUND_WORK_PROVIDER, DelegationManager, NOTIFY_CUSTOM_TYPE } from '../../services/delegation/manager.ts';\nimport { narrateTaskCommit } from '../../services/narration/taskNarration.ts';\nimport {\n hasStorePathOverride,\n removeLegacyStoreDirectoryAsync,\n resolveSessionKey,\n sweepStoreFilesAsync,\n} from '../../services/store/paths.ts';\nimport { TaskStore } from '../../services/store/taskStore.ts';\nimport { TaskOverlay } from '../../tui/taskOverlay.ts';\nimport {\n COLLAPSE_KEY_OFF,\n getDelegationTimeoutMs,\n getMaxTasks,\n getStoreTtlMs,\n resolveCollapseKey,\n} from '../../types/config.ts';\nimport { createTaskErrorReporter, TASK_EVENT, toFailureReporter } from '../telemetry/logSinkTelemetry.ts';\n\ninterface SessionContextLike {\n hasUI: boolean;\n ui: Parameters<TaskOverlay['setUICtx']>[0];\n sessionManager?: { getSessionId(): string };\n}\n\nconst LEADER_SOURCE = '@agimon-ai/doompi-task';\nconst SILENT_NARRATION_REQUESTER: NarrationRequester = { narrate: () => undefined };\n/** Between doom-plan's 60 and the core help group's 70, so `t` sits after `p`. */\nconst LEADER_GROUP_ORDER = 65;\nconst SESSION_START_EVENT = 'session_start';\nconst SESSION_COMPACT_EVENT = 'session_compact';\nconst SESSION_TREE_EVENT = 'session_tree';\nconst TOOL_EXECUTION_END_EVENT = 'tool_execution_end';\nconst SESSION_SHUTDOWN_EVENT = 'session_shutdown';\n\n/**\n * doom-task: a session-tree-scoped, file-backed task list with delegation.\n *\n * A root session and its delegated descendants share one durable JSON file.\n * Unrelated sessions resolve to separate stores outside repository metadata.\n */\nexport function taskExtension(pi: ExtensionAPI): void {\n const errorReporter = createTaskErrorReporter();\n const report = toFailureReporter(errorReporter);\n let narrationRequester = SILENT_NARRATION_REQUESTER;\n const store = new TaskStore({\n report,\n onCommitted: (previous, committed) => narrateTaskCommit(narrationRequester, previous, committed),\n });\n let sessionId: string | undefined;\n let overlay: TaskOverlay | undefined;\n let unwatch: (() => void) | undefined;\n let backgroundWork: BackgroundWorkProviderHandle | undefined;\n\n const refresh = (): void => {\n overlay?.update();\n backgroundWork?.update();\n };\n\n const delegation = new DelegationManager({\n events: pi.events,\n store,\n cwd: process.cwd(),\n notify: (message, options) => pi.sendMessage(message, options),\n getSessionId: () => sessionId,\n onChange: refresh,\n runTimeoutMs: getDelegationTimeoutMs(),\n report,\n onNotifyError: (error, taskId) => {\n void errorReporter.recordNotificationError(error, taskId);\n },\n });\n\n overlay = new TaskOverlay({ getTasks: () => store.snapshot.tasks, delegation });\n\n registerTaskTool(pi, { store, delegation, maxTasks: getMaxTasks(), onChange: refresh, report });\n registerTasksCommand(pi, store);\n\n // `SPC t` remains a group so other task-related surfaces can share the prefix.\n // doom-pi-ui keeps no core group on `t`; a conflicting claim is rejected there\n // with a diagnostic.\n registerDoomLeaderContribution(pi, {\n source: LEADER_SOURCE,\n bindings: [\n {\n id: 'tasks.open',\n path: [\n { key: 't', label: 'tasks', order: LEADER_GROUP_ORDER },\n { key: 't', label: 'tasks' },\n ],\n command: { name: COMMAND_NAME },\n },\n ],\n });\n\n pi.registerMessageRenderer(NOTIFY_CUSTOM_TYPE, (message, _options, theme) => {\n const content = typeof message.content === 'string' ? message.content : '';\n return new Text(theme.fg('muted', content), 0, 0);\n });\n\n const collapseKey = resolveCollapseKey();\n if (collapseKey !== COLLAPSE_KEY_OFF) {\n pi.registerShortcut(collapseKey as KeyId, {\n description: 'Collapse or expand the task overlay',\n handler: (ctx) => {\n if (!ctx.hasUI || !overlay?.isRegistered()) return;\n overlay.toggleCollapse();\n },\n });\n }\n\n pi.on(SESSION_START_EVENT, async (_event, ctx) => {\n // Anything thrown before reconcile() skips the only recovery pass for\n // delegations left behind by the previous session, so the failure must not\n // disappear into the harness.\n try {\n const context = ctx as unknown as SessionContextLike;\n sessionId = context.sessionManager?.getSessionId();\n if (!sessionId) throw new Error('doom-task requires a session id');\n narrationRequester = createNarrationRequester({\n bus: pi.events,\n source: LEADER_SOURCE,\n sessionId,\n });\n backgroundWork?.dispose();\n backgroundWork = context.hasUI\n ? undefined\n : registerBackgroundWorkProvider(\n createProtocolRuntime({\n bus: pi.events,\n source: LEADER_SOURCE,\n sessionId,\n }),\n {\n provider: BACKGROUND_WORK_PROVIDER,\n listActiveWork: () => delegation.listActiveWork(),\n },\n );\n store.configureSession(resolveSessionKey(sessionId));\n const cleanup = await removeLegacyStoreDirectoryAsync(store.storePath);\n const sweep = hasStorePathOverride()\n ? { removed: [], errors: [] }\n : await sweepStoreFilesAsync(store.storePath, getStoreTtlMs());\n const storeErrors = [...cleanup.errors, ...sweep.errors];\n for (const failure of storeErrors) report.warn(TASK_EVENT.storeSweepFailed, new Error(failure));\n if (storeErrors.length > 0 && context.hasUI) context.ui.notify(storeErrors.join('\\n'), 'warning');\n if (context.hasUI) overlay?.setUICtx(context.ui);\n await store.readAsync();\n unwatch = store.onExternalChange(refresh);\n // A shutdown that kept the process alive left the manager unsubscribed.\n delegation.start();\n await delegation.reconcile();\n refresh();\n } catch (error) {\n report.error(TASK_EVENT.sessionStartFailed, error);\n throw error;\n }\n });\n\n pi.on(SESSION_COMPACT_EVENT, () => refresh());\n pi.on(SESSION_TREE_EVENT, () => refresh());\n\n pi.on(TOOL_EXECUTION_END_EVENT, (event) => {\n if (event.toolName === TOOL_NAME) refresh();\n });\n\n pi.on(SESSION_SHUTDOWN_EVENT, async () => {\n try {\n unwatch?.();\n backgroundWork?.dispose();\n backgroundWork = undefined;\n delegation.dispose();\n overlay?.dispose();\n store.dispose();\n narrationRequester = SILENT_NARRATION_REQUESTER;\n } finally {\n // Runs even if teardown throws: the buffered records are most valuable\n // exactly when something went wrong on the way out.\n await errorReporter.shutdown();\n }\n });\n}\n\nexport default taskExtension;\n"],"mappings":"wxBAsCA,MAAM,EAAgB,yBAChB,EAAiD,CAAE,YAAe,IAAA,EAAU,EAelF,SAAgB,EAAc,EAAwB,CACpD,IAAM,EAAgBA,EAAAA,wBAAwB,EACxC,EAASC,EAAAA,kBAAkB,CAAa,EAC1C,EAAqB,EACnB,EAAQ,IAAIC,EAAAA,UAAU,CAC1B,SACA,aAAc,EAAU,IAAcC,EAAAA,kBAAkB,EAAoB,EAAU,CAAS,CACjG,CAAC,EACG,EACA,EACA,EACA,EAEE,MAAsB,CAC1B,GAAS,OAAO,EAChB,GAAgB,OAAO,CACzB,EAEM,EAAa,IAAIC,EAAAA,kBAAkB,CACvC,OAAQ,EAAG,OACX,QACA,IAAK,QAAQ,IAAI,EACjB,QAAS,EAAS,IAAY,EAAG,YAAY,EAAS,CAAO,EAC7D,iBAAoB,EACpB,SAAU,EACV,aAAcC,EAAAA,uBAAuB,EACrC,SACA,eAAgB,EAAO,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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.d.cts","names":[],"sources":["../../../src/adapters/pi/extension.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"extension.d.cts","names":[],"sources":["../../../src/adapters/pi/extension.ts"],"mappings":";;;;;;;;iBAsDgB,cAAc,IAAI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.d.mts","names":[],"sources":["../../../src/adapters/pi/extension.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"extension.d.mts","names":[],"sources":["../../../src/adapters/pi/extension.ts"],"mappings":";;;;;;;;iBAsDgB,cAAc,IAAI"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{TASK_EVENT as e,createTaskErrorReporter as t,toFailureReporter as n}from"../telemetry/logSinkTelemetry.mjs";import{BACKGROUND_WORK_PROVIDER as r,DelegationManager as i,NOTIFY_CUSTOM_TYPE as a}from"../../services/delegation/manager.mjs";import{COMMAND_NAME as o}from"../../schemas/task.mjs";import{registerTasksCommand as s}from"../../commands/index.mjs";import{
|
|
2
|
-
`),`warning`),t.hasUI&&
|
|
1
|
+
import{TASK_EVENT as e,createTaskErrorReporter as t,toFailureReporter as n}from"../telemetry/logSinkTelemetry.mjs";import{BACKGROUND_WORK_PROVIDER as r,DelegationManager as i,NOTIFY_CUSTOM_TYPE as a}from"../../services/delegation/manager.mjs";import{COMMAND_NAME as o}from"../../schemas/task.mjs";import{registerTasksCommand as s}from"../../commands/index.mjs";import{getDelegationTimeoutMs as c,getMaxTasks as l,getStoreTtlMs as u,resolveCollapseKey as d}from"../../types/config.mjs";import{registerTaskTool as f}from"../../commands/task/taskTool.mjs";import{narrateTaskCommit as p}from"../../services/narration/taskNarration.mjs";import{hasStorePathOverride as m,removeLegacyStoreDirectoryAsync as h,resolveSessionKey as g,sweepStoreFilesAsync as _}from"../store/paths.mjs";import"../../services/store/paths.mjs";import{TaskStore as v}from"../store/taskStore.mjs";import"../../services/store/taskStore.mjs";import{TaskOverlay as y}from"../../tui/taskOverlay.mjs";import{registerBackgroundWorkProvider as b}from"@agimon-ai/doompi-extension-contracts/background-work";import{createNarrationRequester as x}from"@agimon-ai/doompi-extension-contracts/narration";import{createProtocolRuntime as S}from"@agimon-ai/doompi-extension-contracts/protocol";import{registerDoomLeaderContribution as C}from"@agimon-ai/doompi-ui/leader";import{Text as w}from"@earendil-works/pi-tui";const T=`@agimon-ai/doompi-task`,E={narrate:()=>void 0};function D(D){let O=t(),k=n(O),A=E,j=new v({report:k,onCommitted:(e,t)=>p(A,e,t)}),M,N,P,F,I=()=>{N?.update(),F?.update()},L=new i({events:D.events,store:j,cwd:process.cwd(),notify:(e,t)=>D.sendMessage(e,t),getSessionId:()=>M,onChange:I,runTimeoutMs:c(),report:k,onNotifyError:(e,t)=>{O.recordNotificationError(e,t)}});N=new y({getTasks:()=>j.snapshot.tasks,delegation:L}),f(D,{store:j,delegation:L,maxTasks:l(),onChange:I,report:k}),s(D,j),C(D,{source:T,bindings:[{id:`tasks.open`,path:[{key:`t`,label:`tasks`,order:65},{key:`t`,label:`tasks`}],command:{name:o}}]}),D.registerMessageRenderer(a,(e,t,n)=>{let r=typeof e.content==`string`?e.content:``;return new w(n.fg(`muted`,r),0,0)});let R=d();R!==`off`&&D.registerShortcut(R,{description:`Collapse or expand the task overlay`,handler:e=>{!e.hasUI||!N?.isRegistered()||N.toggleCollapse()}}),D.on(`session_start`,async(t,n)=>{try{let t=n;if(M=t.sessionManager?.getSessionId(),!M)throw Error(`doom-task requires a session id`);A=x({bus:D.events,source:T,sessionId:M}),F?.dispose(),F=t.hasUI?void 0:b(S({bus:D.events,source:T,sessionId:M}),{provider:r,listActiveWork:()=>L.listActiveWork()}),j.configureSession(g(M));let i=await h(j.storePath),a=m()?{removed:[],errors:[]}:await _(j.storePath,u()),o=[...i.errors,...a.errors];for(let t of o)k.warn(e.storeSweepFailed,Error(t));o.length>0&&t.hasUI&&t.ui.notify(o.join(`
|
|
2
|
+
`),`warning`),t.hasUI&&N?.setUICtx(t.ui),await j.readAsync(),P=j.onExternalChange(I),L.start(),await L.reconcile(),I()}catch(t){throw k.error(e.sessionStartFailed,t),t}}),D.on(`session_compact`,()=>I()),D.on(`session_tree`,()=>I()),D.on(`tool_execution_end`,e=>{e.toolName===`task`&&I()}),D.on(`session_shutdown`,async()=>{try{P?.(),F?.dispose(),F=void 0,L.dispose(),N?.dispose(),j.dispose(),A=E}finally{await O.shutdown()}})}export{D as default,D as taskExtension};
|
|
3
3
|
//# sourceMappingURL=extension.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.mjs","names":[],"sources":["../../../src/adapters/pi/extension.ts"],"sourcesContent":["import {\n type BackgroundWorkProviderHandle,\n registerBackgroundWorkProvider,\n} from '@agimon-ai/doompi-extension-contracts/background-work';\nimport { createNarrationRequester, type NarrationRequester } from '@agimon-ai/doompi-extension-contracts/narration';\nimport { createProtocolRuntime } from '@agimon-ai/doompi-extension-contracts/protocol';\nimport { registerDoomLeaderContribution } from '@agimon-ai/doompi-ui/leader';\nimport type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\nimport type { KeyId } from '@earendil-works/pi-tui';\nimport { Text } from '@earendil-works/pi-tui';\nimport { registerTasksCommand } from '../../commands/index.ts';\nimport { registerTaskTool } from '../../commands/task/taskTool.ts';\nimport { COMMAND_NAME, TOOL_NAME } from '../../schemas/task.ts';\nimport { BACKGROUND_WORK_PROVIDER, DelegationManager, NOTIFY_CUSTOM_TYPE } from '../../services/delegation/manager.ts';\nimport { narrateTaskCommit } from '../../services/narration/taskNarration.ts';\nimport {\n hasStorePathOverride,\n removeLegacyStoreDirectoryAsync,\n resolveSessionKey,\n sweepStoreFilesAsync,\n} from '../../services/store/paths.ts';\nimport { TaskStore } from '../../services/store/taskStore.ts';\nimport { TaskOverlay } from '../../tui/taskOverlay.ts';\nimport { COLLAPSE_KEY_OFF, getDelegationTimeoutMs, getStoreTtlMs, resolveCollapseKey } from '../../types/config.ts';\nimport { createTaskErrorReporter, TASK_EVENT, toFailureReporter } from '../telemetry/logSinkTelemetry.ts';\n\ninterface SessionContextLike {\n hasUI: boolean;\n ui: Parameters<TaskOverlay['setUICtx']>[0];\n sessionManager?: { getSessionId(): string };\n}\n\nconst LEADER_SOURCE = '@agimon-ai/doompi-task';\nconst SILENT_NARRATION_REQUESTER: NarrationRequester = { narrate: () => undefined };\n/** Between doom-plan's 60 and the core help group's 70, so `t` sits after `p`. */\nconst LEADER_GROUP_ORDER = 65;\nconst SESSION_START_EVENT = 'session_start';\nconst SESSION_COMPACT_EVENT = 'session_compact';\nconst SESSION_TREE_EVENT = 'session_tree';\nconst TOOL_EXECUTION_END_EVENT = 'tool_execution_end';\nconst SESSION_SHUTDOWN_EVENT = 'session_shutdown';\n\n/**\n * doom-task: a session-tree-scoped, file-backed task list with delegation.\n *\n * A root session and its delegated descendants share one durable JSON file.\n * Unrelated sessions resolve to separate stores outside repository metadata.\n */\nexport function taskExtension(pi: ExtensionAPI): void {\n const errorReporter = createTaskErrorReporter();\n const report = toFailureReporter(errorReporter);\n let narrationRequester = SILENT_NARRATION_REQUESTER;\n const store = new TaskStore({\n report,\n onCommitted: (previous, committed) => narrateTaskCommit(narrationRequester, previous, committed),\n });\n let sessionId: string | undefined;\n let overlay: TaskOverlay | undefined;\n let unwatch: (() => void) | undefined;\n let backgroundWork: BackgroundWorkProviderHandle | undefined;\n\n const refresh = (): void => {\n overlay?.update();\n backgroundWork?.update();\n };\n\n const delegation = new DelegationManager({\n events: pi.events,\n store,\n cwd: process.cwd(),\n notify: (message, options) => pi.sendMessage(message, options),\n getSessionId: () => sessionId,\n onChange: refresh,\n runTimeoutMs: getDelegationTimeoutMs(),\n report,\n onNotifyError: (error, taskId) => {\n void errorReporter.recordNotificationError(error, taskId);\n },\n });\n\n overlay = new TaskOverlay({ getTasks: () => store.snapshot.tasks, delegation });\n\n registerTaskTool(pi, { store, delegation, onChange: refresh, report });\n registerTasksCommand(pi, store);\n\n // `SPC t` remains a group so other task-related surfaces can share the prefix.\n // doom-pi-ui keeps no core group on `t`; a conflicting claim is rejected there\n // with a diagnostic.\n registerDoomLeaderContribution(pi, {\n source: LEADER_SOURCE,\n bindings: [\n {\n id: 'tasks.open',\n path: [\n { key: 't', label: 'tasks', order: LEADER_GROUP_ORDER },\n { key: 't', label: 'tasks' },\n ],\n command: { name: COMMAND_NAME },\n },\n ],\n });\n\n pi.registerMessageRenderer(NOTIFY_CUSTOM_TYPE, (message, _options, theme) => {\n const content = typeof message.content === 'string' ? message.content : '';\n return new Text(theme.fg('muted', content), 0, 0);\n });\n\n const collapseKey = resolveCollapseKey();\n if (collapseKey !== COLLAPSE_KEY_OFF) {\n pi.registerShortcut(collapseKey as KeyId, {\n description: 'Collapse or expand the task overlay',\n handler: (ctx) => {\n if (!ctx.hasUI || !overlay?.isRegistered()) return;\n overlay.toggleCollapse();\n },\n });\n }\n\n pi.on(SESSION_START_EVENT, async (_event, ctx) => {\n // Anything thrown before reconcile() skips the only recovery pass for\n // delegations left behind by the previous session, so the failure must not\n // disappear into the harness.\n try {\n const context = ctx as unknown as SessionContextLike;\n sessionId = context.sessionManager?.getSessionId();\n if (!sessionId) throw new Error('doom-task requires a session id');\n narrationRequester = createNarrationRequester({\n bus: pi.events,\n source: LEADER_SOURCE,\n sessionId,\n });\n backgroundWork?.dispose();\n backgroundWork = context.hasUI\n ? undefined\n : registerBackgroundWorkProvider(\n createProtocolRuntime({\n bus: pi.events,\n source: LEADER_SOURCE,\n sessionId,\n }),\n {\n provider: BACKGROUND_WORK_PROVIDER,\n listActiveWork: () => delegation.listActiveWork(),\n },\n );\n store.configureSession(resolveSessionKey(sessionId));\n const cleanup = await removeLegacyStoreDirectoryAsync(store.storePath);\n const sweep = hasStorePathOverride()\n ? { removed: [], errors: [] }\n : await sweepStoreFilesAsync(store.storePath, getStoreTtlMs());\n const storeErrors = [...cleanup.errors, ...sweep.errors];\n for (const failure of storeErrors) report.warn(TASK_EVENT.storeSweepFailed, new Error(failure));\n if (storeErrors.length > 0 && context.hasUI) context.ui.notify(storeErrors.join('\\n'), 'warning');\n if (context.hasUI) overlay?.setUICtx(context.ui);\n await store.readAsync();\n unwatch = store.onExternalChange(refresh);\n // A shutdown that kept the process alive left the manager unsubscribed.\n delegation.start();\n await delegation.reconcile();\n refresh();\n } catch (error) {\n report.error(TASK_EVENT.sessionStartFailed, error);\n throw error;\n }\n });\n\n pi.on(SESSION_COMPACT_EVENT, () => refresh());\n pi.on(SESSION_TREE_EVENT, () => refresh());\n\n pi.on(TOOL_EXECUTION_END_EVENT, (event) => {\n if (event.toolName === TOOL_NAME) refresh();\n });\n\n pi.on(SESSION_SHUTDOWN_EVENT, async () => {\n try {\n unwatch?.();\n backgroundWork?.dispose();\n backgroundWork = undefined;\n delegation.dispose();\n overlay?.dispose();\n store.dispose();\n narrationRequester = SILENT_NARRATION_REQUESTER;\n } finally {\n // Runs even if teardown throws: the buffered records are most valuable\n // exactly when something went wrong on the way out.\n await errorReporter.shutdown();\n }\n });\n}\n\nexport default taskExtension;\n"],"mappings":"w0CAgCA,MAAM,EAAgB,yBAChB,EAAiD,CAAE,YAAe,IAAA,EAAU,EAelF,SAAgB,EAAc,EAAwB,CACpD,IAAM,EAAgB,EAAwB,EACxC,EAAS,EAAkB,CAAa,EAC1C,EAAqB,EACnB,EAAQ,IAAI,EAAU,CAC1B,SACA,aAAc,EAAU,IAAc,EAAkB,EAAoB,EAAU,CAAS,CACjG,CAAC,EACG,EACA,EACA,EACA,EAEE,MAAsB,CAC1B,GAAS,OAAO,EAChB,GAAgB,OAAO,CACzB,EAEM,EAAa,IAAI,EAAkB,CACvC,OAAQ,EAAG,OACX,QACA,IAAK,QAAQ,IAAI,EACjB,QAAS,EAAS,IAAY,EAAG,YAAY,EAAS,CAAO,EAC7D,iBAAoB,EACpB,SAAU,EACV,aAAc,EAAuB,EACrC,SACA,eAAgB,EAAO,IAAW,CAChC,EAAmB,wBAAwB,EA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AAQ,EAAqB,EAC/B,CAAE,QAAS,CAAC,EAAG,OAAQ,CAAC,CAAE,EAC1B,MAAM,EAAqB,EAAM,UAAW,EAAc,CAAC,EACzD,EAAc,CAAC,GAAG,EAAQ,OAAQ,GAAG,EAAM,MAAM,EACvD,IAAK,IAAM,KAAW,EAAa,EAAO,KAAK,EAAW,iBAAsB,MAAM,CAAO,CAAC,EAC1F,EAAY,OAAS,GAAK,EAAQ,OAAO,EAAQ,GAAG,OAAO,EAAY,KAAK;CAAI,EAAG,SAAS,EAC5F,EAAQ,OAAO,GAAS,SAAS,EAAQ,EAAE,EAC/C,MAAM,EAAM,UAAU,EACtB,EAAU,EAAM,iBAAiB,CAAO,EAExC,EAAW,MAAM,EACjB,MAAM,EAAW,UAAU,EAC3B,EAAQ,CACV,OAAS,EAAO,CAEd,MADA,EAAO,MAAM,EAAW,mBAAoB,CAAK,EAC3C,CACR,CACF,CAAC,EAED,EAAG,GAAG,sBAA6B,EAAQ,CAAC,EAC5C,EAAG,GAAG,mBAA0B,EAAQ,CAAC,EAEzC,EAAG,GAAG,qBAA2B,GAAU,CACrC,EAAM,WAAA,QAAwB,EAAQ,CAC5C,CAAC,EAED,EAAG,GAAG,mBAAwB,SAAY,CACxC,GAAI,CACF,IAAU,EACV,GAAgB,QAAQ,EACxB,EAAiB,IAAA,GACjB,EAAW,QAAQ,EACnB,GAAS,QAAQ,EACjB,EAAM,QAAQ,EACd,EAAqB,CACvB,QAAU,CAGR,MAAM,EAAc,SAAS,CAC/B,CACF,CAAC,CACH"}
|
|
1
|
+
{"version":3,"file":"extension.mjs","names":[],"sources":["../../../src/adapters/pi/extension.ts"],"sourcesContent":["import {\n type BackgroundWorkProviderHandle,\n registerBackgroundWorkProvider,\n} from '@agimon-ai/doompi-extension-contracts/background-work';\nimport { createNarrationRequester, type NarrationRequester } from '@agimon-ai/doompi-extension-contracts/narration';\nimport { createProtocolRuntime } from '@agimon-ai/doompi-extension-contracts/protocol';\nimport { registerDoomLeaderContribution } from '@agimon-ai/doompi-ui/leader';\nimport type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\nimport type { KeyId } from '@earendil-works/pi-tui';\nimport { Text } from '@earendil-works/pi-tui';\nimport { registerTasksCommand } from '../../commands/index.ts';\nimport { registerTaskTool } from '../../commands/task/taskTool.ts';\nimport { COMMAND_NAME, TOOL_NAME } from '../../schemas/task.ts';\nimport { BACKGROUND_WORK_PROVIDER, DelegationManager, NOTIFY_CUSTOM_TYPE } from '../../services/delegation/manager.ts';\nimport { narrateTaskCommit } from '../../services/narration/taskNarration.ts';\nimport {\n hasStorePathOverride,\n removeLegacyStoreDirectoryAsync,\n resolveSessionKey,\n sweepStoreFilesAsync,\n} from '../../services/store/paths.ts';\nimport { TaskStore } from '../../services/store/taskStore.ts';\nimport { TaskOverlay } from '../../tui/taskOverlay.ts';\nimport {\n COLLAPSE_KEY_OFF,\n getDelegationTimeoutMs,\n getMaxTasks,\n getStoreTtlMs,\n resolveCollapseKey,\n} from '../../types/config.ts';\nimport { createTaskErrorReporter, TASK_EVENT, toFailureReporter } from '../telemetry/logSinkTelemetry.ts';\n\ninterface SessionContextLike {\n hasUI: boolean;\n ui: Parameters<TaskOverlay['setUICtx']>[0];\n sessionManager?: { getSessionId(): string };\n}\n\nconst LEADER_SOURCE = '@agimon-ai/doompi-task';\nconst SILENT_NARRATION_REQUESTER: NarrationRequester = { narrate: () => undefined };\n/** Between doom-plan's 60 and the core help group's 70, so `t` sits after `p`. */\nconst LEADER_GROUP_ORDER = 65;\nconst SESSION_START_EVENT = 'session_start';\nconst SESSION_COMPACT_EVENT = 'session_compact';\nconst SESSION_TREE_EVENT = 'session_tree';\nconst TOOL_EXECUTION_END_EVENT = 'tool_execution_end';\nconst SESSION_SHUTDOWN_EVENT = 'session_shutdown';\n\n/**\n * doom-task: a session-tree-scoped, file-backed task list with delegation.\n *\n * A root session and its delegated descendants share one durable JSON file.\n * Unrelated sessions resolve to separate stores outside repository metadata.\n */\nexport function taskExtension(pi: ExtensionAPI): void {\n const errorReporter = createTaskErrorReporter();\n const report = toFailureReporter(errorReporter);\n let narrationRequester = SILENT_NARRATION_REQUESTER;\n const store = new TaskStore({\n report,\n onCommitted: (previous, committed) => narrateTaskCommit(narrationRequester, previous, committed),\n });\n let sessionId: string | undefined;\n let overlay: TaskOverlay | undefined;\n let unwatch: (() => void) | undefined;\n let backgroundWork: BackgroundWorkProviderHandle | undefined;\n\n const refresh = (): void => {\n overlay?.update();\n backgroundWork?.update();\n };\n\n const delegation = new DelegationManager({\n events: pi.events,\n store,\n cwd: process.cwd(),\n notify: (message, options) => pi.sendMessage(message, options),\n getSessionId: () => sessionId,\n onChange: refresh,\n runTimeoutMs: getDelegationTimeoutMs(),\n report,\n onNotifyError: (error, taskId) => {\n void errorReporter.recordNotificationError(error, taskId);\n },\n });\n\n overlay = new TaskOverlay({ getTasks: () => store.snapshot.tasks, delegation });\n\n registerTaskTool(pi, { store, delegation, maxTasks: getMaxTasks(), onChange: refresh, report });\n registerTasksCommand(pi, store);\n\n // `SPC t` remains a group so other task-related surfaces can share the prefix.\n // doom-pi-ui keeps no core group on `t`; a conflicting claim is rejected there\n // with a diagnostic.\n registerDoomLeaderContribution(pi, {\n source: LEADER_SOURCE,\n bindings: [\n {\n id: 'tasks.open',\n path: [\n { key: 't', label: 'tasks', order: LEADER_GROUP_ORDER },\n { key: 't', label: 'tasks' },\n ],\n command: { name: COMMAND_NAME },\n },\n ],\n });\n\n pi.registerMessageRenderer(NOTIFY_CUSTOM_TYPE, (message, _options, theme) => {\n const content = typeof message.content === 'string' ? message.content : '';\n return new Text(theme.fg('muted', content), 0, 0);\n });\n\n const collapseKey = resolveCollapseKey();\n if (collapseKey !== COLLAPSE_KEY_OFF) {\n pi.registerShortcut(collapseKey as KeyId, {\n description: 'Collapse or expand the task overlay',\n handler: (ctx) => {\n if (!ctx.hasUI || !overlay?.isRegistered()) return;\n overlay.toggleCollapse();\n },\n });\n }\n\n pi.on(SESSION_START_EVENT, async (_event, ctx) => {\n // Anything thrown before reconcile() skips the only recovery pass for\n // delegations left behind by the previous session, so the failure must not\n // disappear into the harness.\n try {\n const context = ctx as unknown as SessionContextLike;\n sessionId = context.sessionManager?.getSessionId();\n if (!sessionId) throw new Error('doom-task requires a session id');\n narrationRequester = createNarrationRequester({\n bus: pi.events,\n source: LEADER_SOURCE,\n sessionId,\n });\n backgroundWork?.dispose();\n backgroundWork = context.hasUI\n ? undefined\n : registerBackgroundWorkProvider(\n createProtocolRuntime({\n bus: pi.events,\n source: LEADER_SOURCE,\n sessionId,\n }),\n {\n provider: BACKGROUND_WORK_PROVIDER,\n listActiveWork: () => delegation.listActiveWork(),\n },\n );\n store.configureSession(resolveSessionKey(sessionId));\n const cleanup = await removeLegacyStoreDirectoryAsync(store.storePath);\n const sweep = hasStorePathOverride()\n ? { removed: [], errors: [] }\n : await sweepStoreFilesAsync(store.storePath, getStoreTtlMs());\n const storeErrors = [...cleanup.errors, ...sweep.errors];\n for (const failure of storeErrors) report.warn(TASK_EVENT.storeSweepFailed, new Error(failure));\n if (storeErrors.length > 0 && context.hasUI) context.ui.notify(storeErrors.join('\\n'), 'warning');\n if (context.hasUI) overlay?.setUICtx(context.ui);\n await store.readAsync();\n unwatch = store.onExternalChange(refresh);\n // A shutdown that kept the process alive left the manager unsubscribed.\n delegation.start();\n await delegation.reconcile();\n refresh();\n } catch (error) {\n report.error(TASK_EVENT.sessionStartFailed, error);\n throw error;\n }\n });\n\n pi.on(SESSION_COMPACT_EVENT, () => refresh());\n pi.on(SESSION_TREE_EVENT, () => refresh());\n\n pi.on(TOOL_EXECUTION_END_EVENT, (event) => {\n if (event.toolName === TOOL_NAME) refresh();\n });\n\n pi.on(SESSION_SHUTDOWN_EVENT, async () => {\n try {\n unwatch?.();\n backgroundWork?.dispose();\n backgroundWork = undefined;\n delegation.dispose();\n overlay?.dispose();\n store.dispose();\n narrationRequester = SILENT_NARRATION_REQUESTER;\n } finally {\n // Runs even if teardown throws: the buffered records are most valuable\n // exactly when something went wrong on the way out.\n await errorReporter.shutdown();\n }\n });\n}\n\nexport default taskExtension;\n"],"mappings":"y1CAsCA,MAAM,EAAgB,yBAChB,EAAiD,CAAE,YAAe,IAAA,EAAU,EAelF,SAAgB,EAAc,EAAwB,CACpD,IAAM,EAAgB,EAAwB,EACxC,EAAS,EAAkB,CAAa,EAC1C,EAAqB,EACnB,EAAQ,IAAI,EAAU,CAC1B,SACA,aAAc,EAAU,IAAc,EAAkB,EAAoB,EAAU,CAAS,CACjG,CAAC,EACG,EACA,EACA,EACA,EAEE,MAAsB,CAC1B,GAAS,OAAO,EAChB,GAAgB,OAAO,CACzB,EAEM,EAAa,IAAI,EAAkB,CACvC,OAAQ,EAAG,OACX,QACA,IAAK,QAAQ,IAAI,EACjB,QAAS,EAAS,IAAY,EAAG,YAAY,EAAS,CAAO,EAC7D,iBAAoB,EACpB,SAAU,EACV,aAAc,EAAuB,EACrC,SACA,eAAgB,EAAO,IAAW,CAChC,EAAmB,wBAAwB,EAAO,CAAM,CAC1D,CACF,CAAC,EAED,EAAU,IAAI,EAAY,CAAE,aAAgB,EAAM,SAAS,MAAO,YAAW,CAAC,EAE9E,EAAiB,EAAI,CAAE,QAAO,aAAY,SAAU,EAAY,EAAG,SAAU,EAAS,QAAO,CAAC,EAC9F,EAAqB,EAAI,CAAK,EAK9B,EAA+B,EAAI,CACjC,OAAQ,EACR,SAAU,CACR,CACE,GAAI,aACJ,KAAM,CACJ,CAAE,IAAK,IAAK,MAAO,QAAS,MAAO,EAAmB,EACtD,CAAE,IAAK,IAAK,MAAO,OAAQ,CAC7B,EACA,QAAS,CAAE,KAAM,CAAa,CAChC,CACF,CACF,CAAC,EAED,EAAG,wBAAwB,GAAqB,EAAS,EAAU,IAAU,CAC3E,IAAM,EAAU,OAAO,EAAQ,SAAY,SAAW,EAAQ,QAAU,GACxE,OAAO,IAAI,EAAK,EAAM,GAAG,QAAS,CAAO,EAAG,EAAG,CAAC,CAClD,CAAC,EAED,IAAM,EAAc,EA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AQ,CAAC,EAC5C,EAAG,GAAG,mBAA0B,EAAQ,CAAC,EAEzC,EAAG,GAAG,qBAA2B,GAAU,CACrC,EAAM,WAAA,QAAwB,EAAQ,CAC5C,CAAC,EAED,EAAG,GAAG,mBAAwB,SAAY,CACxC,GAAI,CACF,IAAU,EACV,GAAgB,QAAQ,EACxB,EAAiB,IAAA,GACjB,EAAW,QAAQ,EACnB,GAAS,QAAQ,EACjB,EAAM,QAAQ,EACd,EAAqB,CACvB,QAAU,CAGR,MAAM,EAAc,SAAS,CAC/B,CACF,CAAC,CACH"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const e=require("../../adapters/telemetry/logSinkTelemetry.cjs"),t=require("../../schemas/task.cjs"),n=require("../../services/store/reducer.cjs"),r=require("../../tui/format.cjs")
|
|
2
|
-
`))}function f(e,n){let r=Object.keys(n).filter(r=>n[r]!==void 0&&!t.taskActionAcceptsField(e,r));if(r.length===0)return;let i=e===`upsert`?` ${t.MSG_UPSERT_FIELD_MISPLACED}`:``;throw d(e,`${e} does not accept ${r.join(`, `)}.${i}`)}function p(e){let t=e.assignments;if(!t||t.length===0)throw d(`assign`,`assign requires a non-empty assignments[] array`);return t}function m(e,t){return{agent:e.agent,inlineAgent:e.inlineAgent,instructions:e.instructions,relevantFiles:e.relevantFiles,priorFindings:e.priorFindings,model:e.model,context:e.context,signal:t}}async function h(t,n,r,i){let a=[];for(let[o,l]of n.entries()){let n;try{n=await t.assign(l.id,m(l,r))}catch(t){i?.error(e.TASK_EVENT.toolFailed,t,{[s]:`assign`,[c]:l.id}),n={ok:!1,message:t instanceof Error?t.message:String(t)}}a.push({index:o,id:l.id,agent:l.agent,...n})}return a}async function g(e,t,r){let{document:
|
|
1
|
+
const e=require("../../adapters/telemetry/logSinkTelemetry.cjs"),t=require("../../schemas/task.cjs"),n=require("../../services/store/reducer.cjs"),r=require("../../tui/format.cjs");require("../../types/config.cjs");const i=require("./promptGuidelines.cjs"),a=require("./responseEnvelope.cjs"),o=`Manage a shared task list to track multi-step progress, and delegate tasks to subagents`,s=`tool.action`,c=`task.id`,l=new Set([`upsert`,`list`,`get`,`delete`,`clear`]);var u=class extends Error{};function d(e,t){return new u([`Task ${e} failed: ${t}`,``,`Options:`,`- List the task board and inspect the current ids, states, and blockers.`,`- Correct the arguments or state conflict, then retry once.`,`- Ask the user before cancelling work or changing dependencies to recover.`].join(`
|
|
2
|
+
`))}function f(e,n){let r=Object.keys(n).filter(r=>n[r]!==void 0&&!t.taskActionAcceptsField(e,r));if(r.length===0)return;let i=e===`upsert`?` ${t.MSG_UPSERT_FIELD_MISPLACED}`:``;throw d(e,`${e} does not accept ${r.join(`, `)}.${i}`)}function p(e){let t=e.assignments;if(!t||t.length===0)throw d(`assign`,`assign requires a non-empty assignments[] array`);return t}function m(e,t){return{agent:e.agent,inlineAgent:e.inlineAgent,instructions:e.instructions,relevantFiles:e.relevantFiles,priorFindings:e.priorFindings,model:e.model,context:e.context,signal:t}}async function h(t,n,r,i){let a=[];for(let[o,l]of n.entries()){let n;try{n=await t.assign(l.id,m(l,r))}catch(t){i?.error(e.TASK_EVENT.toolFailed,t,{[s]:`assign`,[c]:l.id}),n={ok:!1,message:t instanceof Error?t.message:String(t)}}a.push({index:o,id:l.id,agent:l.agent,...n})}return a}async function g(e,t,r,i){let{document:o,value:s}=await e.mutate(e=>{let a=n.applyTaskMutation(e,t,r,void 0,i);return{...n.isCommittingOp(a.op)?{document:a.document}:{},value:a}});if(s.op.kind===`error`)throw d(t,s.op.message);if(s.op.kind===`upsert`&&s.op.applied===0)throw d(t,a.formatUpsertFailureText(s.op));return a.buildToolResult(t,r,o,s.op)}function _(n,m){let{store:_,delegation:v,maxTasks:y=15}=m;n.registerTool({name:t.TOOL_NAME,label:t.TOOL_LABEL,description:`Manage a shared task list for tracking multi-step progress, and delegate tasks to subagents. Actions: upsert (write tasks — a tasks[] array where an entry with an id changes that task and an entry without an id creates one, so one call can capture a whole plan), list, get, delete (tombstone), clear (close/reset the list), assign (hand one or more tasks through assignments[] to named subagents that work in the background), cancel (stop a delegated run). upsert and assign apply entries independently: successes remain committed or delegated and failures are reported by array index. Batch a plan and independent assignments, but report progress one task at a time. Status: pending → in_progress → completed, plus failed and a deleted tombstone. The list is shared within the current session tree, including delegated subagents, while unrelated sessions start empty. Session stores persist until retention cleanup.`,promptSnippet:o,promptGuidelines:i.DEFAULT_PROMPT_GUIDELINES,parameters:t.TaskParamsSchema,renderShell:`self`,async execute(t,n,r,i,o){let b=n.action,x=n;try{if(f(b,x),l.has(b)){let e=await g(_,b,x,y);return m.onChange?.(),e}if(b===`assign`){let e=p(x),t=e[0],n=e.length===1&&t?`Delegating task #${t.id}...`:`Delegating ${e.length} tasks...`;i?.(a.buildTextResult(b,x,_.snapshot,n));let o=await h(v,e,r,m.report);m.onChange?.();let s=a.formatAssignmentResults(o),c=o.flatMap(e=>e.ok?[e.id]:[]);if(c.length===0)throw d(b,s);return a.buildAssignmentResult(x,_.snapshot,s,{assigned:c,failed:o.length-c.length})}i?.(a.buildTextResult(b,x,_.snapshot,`Requesting cancellation for task #${x.id??`unknown`}...`));let e=await v.cancel(x.id??NaN);if(m.onChange?.(),!e.ok)throw d(b,e.message);return a.buildTextResult(b,x,_.snapshot,e.message,void 0)}catch(t){throw m.report?.error(e.TASK_EVENT.toolFailed,t,{[s]:b,...x.id===void 0?{}:{[c]:x.id}}),t instanceof u?t:d(b,t instanceof Error?t.message:String(t))}},renderCall(e,t,n){return r.renderTaskCall(e,t,_.snapshot.tasks)},renderResult(e,t,n,i){return r.renderTaskResult(e,t,n)}})}exports.DEFAULT_PROMPT_GUIDELINES=i.DEFAULT_PROMPT_GUIDELINES,exports.DEFAULT_PROMPT_SNIPPET=o,exports.registerTaskTool=_;
|
|
3
3
|
//# sourceMappingURL=taskTool.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taskTool.cjs","names":["taskActionAcceptsField","MSG_UPSERT_FIELD_MISPLACED","TASK_EVENT","applyTaskMutation","isCommittingOp","formatUpsertFailureText","buildToolResult","TOOL_NAME","TOOL_LABEL","DEFAULT_PROMPT_GUIDELINES","TaskParamsSchema","buildTextResult","formatAssignmentResults","buildAssignmentResult","renderTaskCall","renderTaskResult"],"sources":["../../../src/commands/task/taskTool.ts"],"sourcesContent":["import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\nimport { TASK_EVENT, type TaskFailureReporter } from '../../adapters/telemetry/logSinkTelemetry.ts';\nimport {\n MSG_UPSERT_FIELD_MISPLACED,\n TaskParamsSchema,\n TOOL_LABEL,\n TOOL_NAME,\n taskActionAcceptsField,\n} from '../../schemas/task.ts';\nimport type { AssignOptions, DelegationManager, DelegationOutcome } from '../../services/delegation/manager.ts';\nimport { applyTaskMutation, isCommittingOp, type ReducerAction } from '../../services/store/reducer.ts';\nimport type { TaskStore } from '../../services/store/taskStore.ts';\nimport type { TaskAction, TaskAssignment, TaskMutationParams } from '../../services/store/types.ts';\nimport { renderTaskCall, renderTaskResult } from '../../tui/format.ts';\nimport { DEFAULT_PROMPT_GUIDELINES } from './promptGuidelines.ts';\nimport {\n buildAssignmentResult,\n buildTextResult,\n buildToolResult,\n formatAssignmentResults,\n formatUpsertFailureText,\n type AssignmentItemResult,\n type ToolResult,\n} from './responseEnvelope.ts';\n\nexport { DEFAULT_PROMPT_GUIDELINES } from './promptGuidelines.ts';\n\nexport const DEFAULT_PROMPT_SNIPPET =\n 'Manage a shared task list to track multi-step progress, and delegate tasks to subagents';\n\nexport interface TaskToolDependencies {\n store: TaskStore;\n delegation: DelegationManager;\n onChange?: () => void;\n report?: TaskFailureReporter;\n}\n\nconst ACTION_ATTRIBUTE = 'tool.action';\nconst TASK_ID_ATTRIBUTE = 'task.id';\nconst REDUCER_ACTIONS = new Set<TaskAction>(['upsert', 'list', 'get', 'delete', 'clear']);\n\nclass TaskToolExecutionError extends Error {}\n\nfunction actionableTaskError(action: TaskAction, message: string): TaskToolExecutionError {\n return new TaskToolExecutionError(\n [\n `Task ${action} failed: ${message}`,\n '',\n 'Options:',\n '- List the task board and inspect the current ids, states, and blockers.',\n '- Correct the arguments or state conflict, then retry once.',\n '- Ask the user before cancelling work or changing dependencies to recover.',\n ].join('\\n'),\n );\n}\n\n/**\n * Reject a field that belongs to a different action.\n *\n * The params schema is flat and shared across every action, so this is the only\n * place `{\"action\":\"upsert\",\"id\":3}` can be caught — and it must be, because\n * the entry it carries has no id and would silently create a duplicate task.\n */\nfunction rejectStrayFields(action: TaskAction, params: TaskMutationParams): void {\n const stray = Object.keys(params).filter((key) => params[key] !== undefined && !taskActionAcceptsField(action, key));\n if (stray.length === 0) return;\n const hint = action === 'upsert' ? ` ${MSG_UPSERT_FIELD_MISPLACED}` : '';\n throw actionableTaskError(action, `${action} does not accept ${stray.join(', ')}.${hint}`);\n}\n\n/** assignments[] is the only assign contract, even when it contains one task. */\nfunction resolveAssignments(params: TaskMutationParams): TaskAssignment[] {\n const assignments = params.assignments;\n if (!assignments || assignments.length === 0) {\n throw actionableTaskError('assign', 'assign requires a non-empty assignments[] array');\n }\n return assignments;\n}\n\nfunction assignOptions(request: TaskAssignment, signal: AbortSignal | undefined): AssignOptions {\n return {\n agent: request.agent,\n inlineAgent: request.inlineAgent,\n instructions: request.instructions,\n relevantFiles: request.relevantFiles,\n priorFindings: request.priorFindings,\n model: request.model,\n context: request.context,\n signal,\n };\n}\n\nasync function executeAssignmentBatch(\n delegation: DelegationManager,\n assignments: readonly TaskAssignment[],\n signal: AbortSignal | undefined,\n report: TaskFailureReporter | undefined,\n): Promise<AssignmentItemResult[]> {\n const results: AssignmentItemResult[] = [];\n for (const [index, assignment] of assignments.entries()) {\n let outcome: DelegationOutcome;\n try {\n outcome = await delegation.assign(assignment.id, assignOptions(assignment, signal));\n } catch (error) {\n report?.error(TASK_EVENT.toolFailed, error, {\n [ACTION_ATTRIBUTE]: 'assign',\n [TASK_ID_ATTRIBUTE]: assignment.id,\n });\n outcome = { ok: false, message: error instanceof Error ? error.message : String(error) };\n }\n results.push({ index, id: assignment.id, agent: assignment.agent, ...outcome });\n }\n return results;\n}\n\n/** Run an action through the reducer, persisting only when it produced a change. */\nasync function executeReducerAction(\n store: TaskStore,\n action: ReducerAction,\n params: TaskMutationParams,\n): Promise<ToolResult> {\n const { document, value } = await store.mutate((current) => {\n const result = applyTaskMutation(current, action, params);\n return {\n ...(isCommittingOp(result.op) ? { document: result.document } : {}),\n value: result,\n };\n });\n if (value.op.kind === 'error') throw actionableTaskError(action, value.op.message);\n // An upsert that applied nothing is a failed call: it wrote nothing and left\n // `rev` alone, so it must not read to the model as a success. A batch where\n // some entries landed returns normally — that is what partial apply means.\n if (value.op.kind === 'upsert' && value.op.applied === 0) {\n throw actionableTaskError(action, formatUpsertFailureText(value.op));\n }\n // `document` is the committed document, so `details.rev` matches what landed\n // on disk; `value.document` is the pre-write copy and lags by one.\n return buildToolResult(action, params, document, value.op);\n}\n\nexport function registerTaskTool(pi: ExtensionAPI, dependencies: TaskToolDependencies): void {\n const { store, delegation } = dependencies;\n\n pi.registerTool({\n name: TOOL_NAME,\n label: TOOL_LABEL,\n description:\n 'Manage a shared task list for tracking multi-step progress, and delegate tasks to subagents. Actions: upsert (write tasks — a tasks[] array where an entry with an id changes that task and an entry without an id creates one, so one call can capture a whole plan), list, get, delete (tombstone), clear (close/reset the list), assign (hand one or more tasks through assignments[] to named subagents that work in the background), cancel (stop a delegated run). upsert and assign apply entries independently: successes remain committed or delegated and failures are reported by array index. Batch a plan and independent assignments, but report progress one task at a time. Status: pending → in_progress → completed, plus failed and a deleted tombstone. The list is shared within the current session tree, including delegated subagents, while unrelated sessions start empty. Session stores persist until retention cleanup.',\n promptSnippet: DEFAULT_PROMPT_SNIPPET,\n promptGuidelines: DEFAULT_PROMPT_GUIDELINES,\n parameters: TaskParamsSchema,\n // Task rows carry their own status colors. Owning the shell prevents Pi's\n // pending/success/error background fill from obscuring those row states.\n renderShell: 'self',\n\n async execute(_toolCallId, params, signal, onUpdate, _ctx) {\n const action = params.action as TaskAction;\n const mutationParams = params as TaskMutationParams;\n\n try {\n rejectStrayFields(action, mutationParams);\n if (REDUCER_ACTIONS.has(action)) {\n const result = await executeReducerAction(store, action as ReducerAction, mutationParams);\n dependencies.onChange?.();\n return result;\n }\n\n if (action === 'assign') {\n const assignments = resolveAssignments(mutationParams);\n const first = assignments[0];\n const progress =\n assignments.length === 1 && first\n ? `Delegating task #${first.id}...`\n : `Delegating ${assignments.length} tasks...`;\n onUpdate?.(buildTextResult(action, mutationParams, store.snapshot, progress));\n const results = await executeAssignmentBatch(delegation, assignments, signal, dependencies.report);\n dependencies.onChange?.();\n const text = formatAssignmentResults(results);\n const assigned = results.flatMap((item) => (item.ok ? [item.id] : []));\n if (assigned.length === 0) throw actionableTaskError(action, text);\n return buildAssignmentResult(mutationParams, store.snapshot, text, {\n assigned,\n failed: results.length - assigned.length,\n });\n }\n\n onUpdate?.(\n buildTextResult(\n action,\n mutationParams,\n store.snapshot,\n `Requesting cancellation for task #${mutationParams.id ?? 'unknown'}...`,\n ),\n );\n const outcome = await delegation.cancel(mutationParams.id ?? Number.NaN);\n dependencies.onChange?.();\n if (!outcome.ok) throw actionableTaskError(action, outcome.message);\n return buildTextResult(action, mutationParams, store.snapshot, outcome.message, undefined);\n } catch (error) {\n // Rethrown so pi still renders the failure to the model; recorded\n // because this is where a store fault becomes visible to the user.\n dependencies.report?.error(TASK_EVENT.toolFailed, error, {\n [ACTION_ATTRIBUTE]: action,\n ...(mutationParams.id === undefined ? {} : { [TASK_ID_ATTRIBUTE]: mutationParams.id }),\n });\n if (error instanceof TaskToolExecutionError) throw error;\n throw actionableTaskError(action, error instanceof Error ? error.message : String(error));\n }\n },\n\n // Render hooks receive no session identity, so they read the store snapshot\n // that the executing session last loaded. That is the foreground session's\n // own view, which is exactly what its transcript should show.\n renderCall(args, theme, _context) {\n return renderTaskCall(args as never, theme, store.snapshot.tasks);\n },\n\n renderResult(result, options, theme, _context) {\n return renderTaskResult(result, options, theme);\n },\n });\n}\n"],"mappings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AAK,CAClE,EAEA,aAAa,EAAQ,EAAS,EAAO,EAAU,CAC7C,OAAOC,EAAAA,iBAAiB,EAAQ,EAAS,CAAK,CAChD,CACF,CAAC,CACH"}
|
|
1
|
+
{"version":3,"file":"taskTool.cjs","names":["taskActionAcceptsField","MSG_UPSERT_FIELD_MISPLACED","TASK_EVENT","applyTaskMutation","isCommittingOp","formatUpsertFailureText","buildToolResult","TOOL_NAME","TOOL_LABEL","DEFAULT_PROMPT_GUIDELINES","TaskParamsSchema","buildTextResult","formatAssignmentResults","buildAssignmentResult","renderTaskCall","renderTaskResult"],"sources":["../../../src/commands/task/taskTool.ts"],"sourcesContent":["import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\nimport { TASK_EVENT, type TaskFailureReporter } from '../../adapters/telemetry/logSinkTelemetry.ts';\nimport {\n MSG_UPSERT_FIELD_MISPLACED,\n TaskParamsSchema,\n TOOL_LABEL,\n TOOL_NAME,\n taskActionAcceptsField,\n} from '../../schemas/task.ts';\nimport type { AssignOptions, DelegationManager, DelegationOutcome } from '../../services/delegation/manager.ts';\nimport { applyTaskMutation, isCommittingOp, type ReducerAction } from '../../services/store/reducer.ts';\nimport type { TaskStore } from '../../services/store/taskStore.ts';\nimport type { TaskAction, TaskAssignment, TaskMutationParams } from '../../services/store/types.ts';\nimport { renderTaskCall, renderTaskResult } from '../../tui/format.ts';\nimport { DEFAULT_MAX_TASKS } from '../../types/config.ts';\nimport { DEFAULT_PROMPT_GUIDELINES } from './promptGuidelines.ts';\nimport {\n type AssignmentItemResult,\n buildAssignmentResult,\n buildTextResult,\n buildToolResult,\n formatAssignmentResults,\n formatUpsertFailureText,\n type ToolResult,\n} from './responseEnvelope.ts';\n\nexport { DEFAULT_PROMPT_GUIDELINES } from './promptGuidelines.ts';\n\nexport const DEFAULT_PROMPT_SNIPPET =\n 'Manage a shared task list to track multi-step progress, and delegate tasks to subagents';\n\nexport interface TaskToolDependencies {\n store: TaskStore;\n delegation: DelegationManager;\n maxTasks?: number;\n onChange?: () => void;\n report?: TaskFailureReporter;\n}\n\nconst ACTION_ATTRIBUTE = 'tool.action';\nconst TASK_ID_ATTRIBUTE = 'task.id';\nconst REDUCER_ACTIONS = new Set<TaskAction>(['upsert', 'list', 'get', 'delete', 'clear']);\n\nclass TaskToolExecutionError extends Error {}\n\nfunction actionableTaskError(action: TaskAction, message: string): TaskToolExecutionError {\n return new TaskToolExecutionError(\n [\n `Task ${action} failed: ${message}`,\n '',\n 'Options:',\n '- List the task board and inspect the current ids, states, and blockers.',\n '- Correct the arguments or state conflict, then retry once.',\n '- Ask the user before cancelling work or changing dependencies to recover.',\n ].join('\\n'),\n );\n}\n\n/**\n * Reject a field that belongs to a different action.\n *\n * The params schema is flat and shared across every action, so this is the only\n * place `{\"action\":\"upsert\",\"id\":3}` can be caught — and it must be, because\n * the entry it carries has no id and would silently create a duplicate task.\n */\nfunction rejectStrayFields(action: TaskAction, params: TaskMutationParams): void {\n const stray = Object.keys(params).filter((key) => params[key] !== undefined && !taskActionAcceptsField(action, key));\n if (stray.length === 0) return;\n const hint = action === 'upsert' ? ` ${MSG_UPSERT_FIELD_MISPLACED}` : '';\n throw actionableTaskError(action, `${action} does not accept ${stray.join(', ')}.${hint}`);\n}\n\n/** assignments[] is the only assign contract, even when it contains one task. */\nfunction resolveAssignments(params: TaskMutationParams): TaskAssignment[] {\n const assignments = params.assignments;\n if (!assignments || assignments.length === 0) {\n throw actionableTaskError('assign', 'assign requires a non-empty assignments[] array');\n }\n return assignments;\n}\n\nfunction assignOptions(request: TaskAssignment, signal: AbortSignal | undefined): AssignOptions {\n return {\n agent: request.agent,\n inlineAgent: request.inlineAgent,\n instructions: request.instructions,\n relevantFiles: request.relevantFiles,\n priorFindings: request.priorFindings,\n model: request.model,\n context: request.context,\n signal,\n };\n}\n\nasync function executeAssignmentBatch(\n delegation: DelegationManager,\n assignments: readonly TaskAssignment[],\n signal: AbortSignal | undefined,\n report: TaskFailureReporter | undefined,\n): Promise<AssignmentItemResult[]> {\n const results: AssignmentItemResult[] = [];\n for (const [index, assignment] of assignments.entries()) {\n let outcome: DelegationOutcome;\n try {\n outcome = await delegation.assign(assignment.id, assignOptions(assignment, signal));\n } catch (error) {\n report?.error(TASK_EVENT.toolFailed, error, {\n [ACTION_ATTRIBUTE]: 'assign',\n [TASK_ID_ATTRIBUTE]: assignment.id,\n });\n outcome = { ok: false, message: error instanceof Error ? error.message : String(error) };\n }\n results.push({ index, id: assignment.id, agent: assignment.agent, ...outcome });\n }\n return results;\n}\n\n/** Run an action through the reducer, persisting only when it produced a change. */\nasync function executeReducerAction(\n store: TaskStore,\n action: ReducerAction,\n params: TaskMutationParams,\n maxTasks: number,\n): Promise<ToolResult> {\n const { document, value } = await store.mutate((current) => {\n const result = applyTaskMutation(current, action, params, undefined, maxTasks);\n return {\n ...(isCommittingOp(result.op) ? { document: result.document } : {}),\n value: result,\n };\n });\n if (value.op.kind === 'error') throw actionableTaskError(action, value.op.message);\n // An upsert that applied nothing is a failed call: it wrote nothing and left\n // `rev` alone, so it must not read to the model as a success. A batch where\n // some entries landed returns normally — that is what partial apply means.\n if (value.op.kind === 'upsert' && value.op.applied === 0) {\n throw actionableTaskError(action, formatUpsertFailureText(value.op));\n }\n // `document` is the committed document, so `details.rev` matches what landed\n // on disk; `value.document` is the pre-write copy and lags by one.\n return buildToolResult(action, params, document, value.op);\n}\n\nexport function registerTaskTool(pi: ExtensionAPI, dependencies: TaskToolDependencies): void {\n const { store, delegation, maxTasks = DEFAULT_MAX_TASKS } = dependencies;\n\n pi.registerTool({\n name: TOOL_NAME,\n label: TOOL_LABEL,\n description:\n 'Manage a shared task list for tracking multi-step progress, and delegate tasks to subagents. Actions: upsert (write tasks — a tasks[] array where an entry with an id changes that task and an entry without an id creates one, so one call can capture a whole plan), list, get, delete (tombstone), clear (close/reset the list), assign (hand one or more tasks through assignments[] to named subagents that work in the background), cancel (stop a delegated run). upsert and assign apply entries independently: successes remain committed or delegated and failures are reported by array index. Batch a plan and independent assignments, but report progress one task at a time. Status: pending → in_progress → completed, plus failed and a deleted tombstone. The list is shared within the current session tree, including delegated subagents, while unrelated sessions start empty. Session stores persist until retention cleanup.',\n promptSnippet: DEFAULT_PROMPT_SNIPPET,\n promptGuidelines: DEFAULT_PROMPT_GUIDELINES,\n parameters: TaskParamsSchema,\n // Task rows carry their own status colors. Owning the shell prevents Pi's\n // pending/success/error background fill from obscuring those row states.\n renderShell: 'self',\n\n async execute(_toolCallId, params, signal, onUpdate, _ctx) {\n const action = params.action as TaskAction;\n const mutationParams = params as TaskMutationParams;\n\n try {\n rejectStrayFields(action, mutationParams);\n if (REDUCER_ACTIONS.has(action)) {\n const result = await executeReducerAction(store, action as ReducerAction, mutationParams, maxTasks);\n dependencies.onChange?.();\n return result;\n }\n\n if (action === 'assign') {\n const assignments = resolveAssignments(mutationParams);\n const first = assignments[0];\n const progress =\n assignments.length === 1 && first\n ? `Delegating task #${first.id}...`\n : `Delegating ${assignments.length} tasks...`;\n onUpdate?.(buildTextResult(action, mutationParams, store.snapshot, progress));\n const results = await executeAssignmentBatch(delegation, assignments, signal, dependencies.report);\n dependencies.onChange?.();\n const text = formatAssignmentResults(results);\n const assigned = results.flatMap((item) => (item.ok ? [item.id] : []));\n if (assigned.length === 0) throw actionableTaskError(action, text);\n return buildAssignmentResult(mutationParams, store.snapshot, text, {\n assigned,\n failed: results.length - assigned.length,\n });\n }\n\n onUpdate?.(\n buildTextResult(\n action,\n mutationParams,\n store.snapshot,\n `Requesting cancellation for task #${mutationParams.id ?? 'unknown'}...`,\n ),\n );\n const outcome = await delegation.cancel(mutationParams.id ?? Number.NaN);\n dependencies.onChange?.();\n if (!outcome.ok) throw actionableTaskError(action, outcome.message);\n return buildTextResult(action, mutationParams, store.snapshot, outcome.message, undefined);\n } catch (error) {\n // Rethrown so pi still renders the failure to the model; recorded\n // because this is where a store fault becomes visible to the user.\n dependencies.report?.error(TASK_EVENT.toolFailed, error, {\n [ACTION_ATTRIBUTE]: action,\n ...(mutationParams.id === undefined ? {} : { [TASK_ID_ATTRIBUTE]: mutationParams.id }),\n });\n if (error instanceof TaskToolExecutionError) throw error;\n throw actionableTaskError(action, error instanceof Error ? error.message : String(error));\n }\n },\n\n // Render hooks receive no session identity, so they read the store snapshot\n // that the executing session last loaded. That is the foreground session's\n // own view, which is exactly what its transcript should show.\n renderCall(args, theme, _context) {\n return renderTaskCall(args as never, theme, store.snapshot.tasks);\n },\n\n renderResult(result, options, theme, _context) {\n return renderTaskResult(result, options, theme);\n },\n });\n}\n"],"mappings":"qSA4Ba,EACX,0FAUI,EAAmB,cACnB,EAAoB,UACpB,EAAkB,IAAI,IAAgB,CAAC,SAAU,OAAQ,MAAO,SAAU,OAAO,CAAC,EAExF,IAAM,EAAN,cAAqC,KAAM,CAAC,EAE5C,SAAS,EAAoB,EAAoB,EAAyC,CACxF,OAAO,IAAI,EACT,CACE,QAAQ,EAAO,WAAW,IAC1B,GACA,WACA,2EACA,8DACA,4EACF,CAAC,CAAC,KAAK;CAAI,CACb,CACF,CASA,SAAS,EAAkB,EAAoB,EAAkC,CAC/E,IAAM,EAAQ,OAAO,KAAK,CAAM,CAAC,CAAC,OAAQ,GAAQ,EAAO,KAAS,IAAA,IAAa,CAACA,EAAAA,uBAAuB,EAAQ,CAAG,CAAC,EACnH,GAAI,EAAM,SAAW,EAAG,OACxB,IAAM,EAAO,IAAW,SAAW,IAAIC,EAAAA,6BAA+B,GACtE,MAAM,EAAoB,EAAQ,GAAG,EAAO,mBAAmB,EAAM,KAAK,IAAI,EAAE,GAAG,GAAM,CAC3F,CAGA,SAAS,EAAmB,EAA8C,CACxE,IAAM,EAAc,EAAO,YAC3B,GAAI,CAAC,GAAe,EAAY,SAAW,EACzC,MAAM,EAAoB,SAAU,iDAAiD,EAEvF,OAAO,CACT,CAEA,SAAS,EAAc,EAAyB,EAAgD,CAC9F,MAAO,CACL,MAAO,EAAQ,MACf,YAAa,EAAQ,YACrB,aAAc,EAAQ,aACtB,cAAe,EAAQ,cACvB,cA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Q,QAAS,IAAA,EAAS,CAC3F,OAAS,EAAO,CAQd,MALA,EAAa,QAAQ,MAAMT,EAAAA,WAAW,WAAY,EAAO,EACtD,GAAmB,EACpB,GAAI,EAAe,KAAO,IAAA,GAAY,CAAC,EAAI,EAAG,GAAoB,EAAe,EAAG,CACtF,CAAC,EACG,aAAiB,EAA8B,EAC7C,EAAoB,EAAQ,aAAiB,MAAQ,EAAM,QAAU,OAAO,CAAK,CAAC,CAC1F,CACF,EAKA,WAAW,EAAM,EAAO,EAAU,CAChC,OAAOY,EAAAA,eAAe,EAAe,EAAO,EAAM,SAAS,KAAK,CAClE,EAEA,aAAa,EAAQ,EAAS,EAAO,EAAU,CAC7C,OAAOC,EAAAA,iBAAiB,EAAQ,EAAS,CAAK,CAChD,CACF,CAAC,CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taskTool.d.cts","names":[],"sources":["../../../src/commands/task/taskTool.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"taskTool.d.cts","names":[],"sources":["../../../src/commands/task/taskTool.ts"],"mappings":";;;;;;;cA4Ba;UAGI;EACf,OAAO;EACP,YAAY;EACZ;EACA;EACA,SAAS;;iBA2GK,iBAAiB,IAAI,cAAc,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taskTool.d.mts","names":[],"sources":["../../../src/commands/task/taskTool.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"taskTool.d.mts","names":[],"sources":["../../../src/commands/task/taskTool.ts"],"mappings":";;;;;;;cA4Ba;UAGI;EACf,OAAO;EACP,YAAY;EACZ;EACA;EACA,SAAS;;iBA2GK,iBAAiB,IAAI,cAAc,cAAc"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{TASK_EVENT as e}from"../../adapters/telemetry/logSinkTelemetry.mjs";import{MSG_UPSERT_FIELD_MISPLACED as t,TOOL_LABEL as n,TOOL_NAME as r,TaskParamsSchema as i,taskActionAcceptsField as a}from"../../schemas/task.mjs";import{applyTaskMutation as o,isCommittingOp as s}from"../../services/store/reducer.mjs";import{renderTaskCall as c,renderTaskResult as l}from"../../tui/format.mjs";import{DEFAULT_PROMPT_GUIDELINES as u}from"./promptGuidelines.mjs";import{buildAssignmentResult as d,buildTextResult as f,buildToolResult as p,formatAssignmentResults as m,formatUpsertFailureText as h}from"./responseEnvelope.mjs";const g=`Manage a shared task list to track multi-step progress, and delegate tasks to subagents`,_=`tool.action`,v=`task.id`,y=new Set([`upsert`,`list`,`get`,`delete`,`clear`]);var b=class extends Error{};function x(e,t){return new b([`Task ${e} failed: ${t}`,``,`Options:`,`- List the task board and inspect the current ids, states, and blockers.`,`- Correct the arguments or state conflict, then retry once.`,`- Ask the user before cancelling work or changing dependencies to recover.`].join(`
|
|
2
|
-
`))}function S(e,n){let r=Object.keys(n).filter(t=>n[t]!==void 0&&!a(e,t));if(r.length===0)return;let i=e===`upsert`?` ${t}`:``;throw x(e,`${e} does not accept ${r.join(`, `)}.${i}`)}function C(e){let t=e.assignments;if(!t||t.length===0)throw x(`assign`,`assign requires a non-empty assignments[] array`);return t}function w(e,t){return{agent:e.agent,inlineAgent:e.inlineAgent,instructions:e.instructions,relevantFiles:e.relevantFiles,priorFindings:e.priorFindings,model:e.model,context:e.context,signal:t}}async function T(t,n,r,i){let a=[];for(let[o,s]of n.entries()){let n;try{n=await t.assign(s.id,w(s,r))}catch(t){i?.error(e.toolFailed,t,{[_]:`assign`,[v]:s.id}),n={ok:!1,message:t instanceof Error?t.message:String(t)}}a.push({index:o,id:s.id,agent:s.agent,...n})}return a}async function E(e,t,n){let{document:
|
|
1
|
+
import{TASK_EVENT as e}from"../../adapters/telemetry/logSinkTelemetry.mjs";import{MSG_UPSERT_FIELD_MISPLACED as t,TOOL_LABEL as n,TOOL_NAME as r,TaskParamsSchema as i,taskActionAcceptsField as a}from"../../schemas/task.mjs";import{applyTaskMutation as o,isCommittingOp as s}from"../../services/store/reducer.mjs";import{renderTaskCall as c,renderTaskResult as l}from"../../tui/format.mjs";import"../../types/config.mjs";import{DEFAULT_PROMPT_GUIDELINES as u}from"./promptGuidelines.mjs";import{buildAssignmentResult as d,buildTextResult as f,buildToolResult as p,formatAssignmentResults as m,formatUpsertFailureText as h}from"./responseEnvelope.mjs";const g=`Manage a shared task list to track multi-step progress, and delegate tasks to subagents`,_=`tool.action`,v=`task.id`,y=new Set([`upsert`,`list`,`get`,`delete`,`clear`]);var b=class extends Error{};function x(e,t){return new b([`Task ${e} failed: ${t}`,``,`Options:`,`- List the task board and inspect the current ids, states, and blockers.`,`- Correct the arguments or state conflict, then retry once.`,`- Ask the user before cancelling work or changing dependencies to recover.`].join(`
|
|
2
|
+
`))}function S(e,n){let r=Object.keys(n).filter(t=>n[t]!==void 0&&!a(e,t));if(r.length===0)return;let i=e===`upsert`?` ${t}`:``;throw x(e,`${e} does not accept ${r.join(`, `)}.${i}`)}function C(e){let t=e.assignments;if(!t||t.length===0)throw x(`assign`,`assign requires a non-empty assignments[] array`);return t}function w(e,t){return{agent:e.agent,inlineAgent:e.inlineAgent,instructions:e.instructions,relevantFiles:e.relevantFiles,priorFindings:e.priorFindings,model:e.model,context:e.context,signal:t}}async function T(t,n,r,i){let a=[];for(let[o,s]of n.entries()){let n;try{n=await t.assign(s.id,w(s,r))}catch(t){i?.error(e.toolFailed,t,{[_]:`assign`,[v]:s.id}),n={ok:!1,message:t instanceof Error?t.message:String(t)}}a.push({index:o,id:s.id,agent:s.agent,...n})}return a}async function E(e,t,n,r){let{document:i,value:a}=await e.mutate(e=>{let i=o(e,t,n,void 0,r);return{...s(i.op)?{document:i.document}:{},value:i}});if(a.op.kind===`error`)throw x(t,a.op.message);if(a.op.kind===`upsert`&&a.op.applied===0)throw x(t,h(a.op));return p(t,n,i,a.op)}function D(t,a){let{store:o,delegation:s,maxTasks:p=15}=a;t.registerTool({name:r,label:n,description:`Manage a shared task list for tracking multi-step progress, and delegate tasks to subagents. Actions: upsert (write tasks — a tasks[] array where an entry with an id changes that task and an entry without an id creates one, so one call can capture a whole plan), list, get, delete (tombstone), clear (close/reset the list), assign (hand one or more tasks through assignments[] to named subagents that work in the background), cancel (stop a delegated run). upsert and assign apply entries independently: successes remain committed or delegated and failures are reported by array index. Batch a plan and independent assignments, but report progress one task at a time. Status: pending → in_progress → completed, plus failed and a deleted tombstone. The list is shared within the current session tree, including delegated subagents, while unrelated sessions start empty. Session stores persist until retention cleanup.`,promptSnippet:g,promptGuidelines:u,parameters:i,renderShell:`self`,async execute(t,n,r,i,c){let l=n.action,u=n;try{if(S(l,u),y.has(l)){let e=await E(o,l,u,p);return a.onChange?.(),e}if(l===`assign`){let e=C(u),t=e[0],n=e.length===1&&t?`Delegating task #${t.id}...`:`Delegating ${e.length} tasks...`;i?.(f(l,u,o.snapshot,n));let c=await T(s,e,r,a.report);a.onChange?.();let p=m(c),h=c.flatMap(e=>e.ok?[e.id]:[]);if(h.length===0)throw x(l,p);return d(u,o.snapshot,p,{assigned:h,failed:c.length-h.length})}i?.(f(l,u,o.snapshot,`Requesting cancellation for task #${u.id??`unknown`}...`));let e=await s.cancel(u.id??NaN);if(a.onChange?.(),!e.ok)throw x(l,e.message);return f(l,u,o.snapshot,e.message,void 0)}catch(t){throw a.report?.error(e.toolFailed,t,{[_]:l,...u.id===void 0?{}:{[v]:u.id}}),t instanceof b?t:x(l,t instanceof Error?t.message:String(t))}},renderCall(e,t,n){return c(e,t,o.snapshot.tasks)},renderResult(e,t,n,r){return l(e,t,n)}})}export{u as DEFAULT_PROMPT_GUIDELINES,g as DEFAULT_PROMPT_SNIPPET,D as registerTaskTool};
|
|
3
3
|
//# sourceMappingURL=taskTool.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taskTool.mjs","names":[],"sources":["../../../src/commands/task/taskTool.ts"],"sourcesContent":["import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\nimport { TASK_EVENT, type TaskFailureReporter } from '../../adapters/telemetry/logSinkTelemetry.ts';\nimport {\n MSG_UPSERT_FIELD_MISPLACED,\n TaskParamsSchema,\n TOOL_LABEL,\n TOOL_NAME,\n taskActionAcceptsField,\n} from '../../schemas/task.ts';\nimport type { AssignOptions, DelegationManager, DelegationOutcome } from '../../services/delegation/manager.ts';\nimport { applyTaskMutation, isCommittingOp, type ReducerAction } from '../../services/store/reducer.ts';\nimport type { TaskStore } from '../../services/store/taskStore.ts';\nimport type { TaskAction, TaskAssignment, TaskMutationParams } from '../../services/store/types.ts';\nimport { renderTaskCall, renderTaskResult } from '../../tui/format.ts';\nimport { DEFAULT_PROMPT_GUIDELINES } from './promptGuidelines.ts';\nimport {\n buildAssignmentResult,\n buildTextResult,\n buildToolResult,\n formatAssignmentResults,\n formatUpsertFailureText,\n type AssignmentItemResult,\n type ToolResult,\n} from './responseEnvelope.ts';\n\nexport { DEFAULT_PROMPT_GUIDELINES } from './promptGuidelines.ts';\n\nexport const DEFAULT_PROMPT_SNIPPET =\n 'Manage a shared task list to track multi-step progress, and delegate tasks to subagents';\n\nexport interface TaskToolDependencies {\n store: TaskStore;\n delegation: DelegationManager;\n onChange?: () => void;\n report?: TaskFailureReporter;\n}\n\nconst ACTION_ATTRIBUTE = 'tool.action';\nconst TASK_ID_ATTRIBUTE = 'task.id';\nconst REDUCER_ACTIONS = new Set<TaskAction>(['upsert', 'list', 'get', 'delete', 'clear']);\n\nclass TaskToolExecutionError extends Error {}\n\nfunction actionableTaskError(action: TaskAction, message: string): TaskToolExecutionError {\n return new TaskToolExecutionError(\n [\n `Task ${action} failed: ${message}`,\n '',\n 'Options:',\n '- List the task board and inspect the current ids, states, and blockers.',\n '- Correct the arguments or state conflict, then retry once.',\n '- Ask the user before cancelling work or changing dependencies to recover.',\n ].join('\\n'),\n );\n}\n\n/**\n * Reject a field that belongs to a different action.\n *\n * The params schema is flat and shared across every action, so this is the only\n * place `{\"action\":\"upsert\",\"id\":3}` can be caught — and it must be, because\n * the entry it carries has no id and would silently create a duplicate task.\n */\nfunction rejectStrayFields(action: TaskAction, params: TaskMutationParams): void {\n const stray = Object.keys(params).filter((key) => params[key] !== undefined && !taskActionAcceptsField(action, key));\n if (stray.length === 0) return;\n const hint = action === 'upsert' ? ` ${MSG_UPSERT_FIELD_MISPLACED}` : '';\n throw actionableTaskError(action, `${action} does not accept ${stray.join(', ')}.${hint}`);\n}\n\n/** assignments[] is the only assign contract, even when it contains one task. */\nfunction resolveAssignments(params: TaskMutationParams): TaskAssignment[] {\n const assignments = params.assignments;\n if (!assignments || assignments.length === 0) {\n throw actionableTaskError('assign', 'assign requires a non-empty assignments[] array');\n }\n return assignments;\n}\n\nfunction assignOptions(request: TaskAssignment, signal: AbortSignal | undefined): AssignOptions {\n return {\n agent: request.agent,\n inlineAgent: request.inlineAgent,\n instructions: request.instructions,\n relevantFiles: request.relevantFiles,\n priorFindings: request.priorFindings,\n model: request.model,\n context: request.context,\n signal,\n };\n}\n\nasync function executeAssignmentBatch(\n delegation: DelegationManager,\n assignments: readonly TaskAssignment[],\n signal: AbortSignal | undefined,\n report: TaskFailureReporter | undefined,\n): Promise<AssignmentItemResult[]> {\n const results: AssignmentItemResult[] = [];\n for (const [index, assignment] of assignments.entries()) {\n let outcome: DelegationOutcome;\n try {\n outcome = await delegation.assign(assignment.id, assignOptions(assignment, signal));\n } catch (error) {\n report?.error(TASK_EVENT.toolFailed, error, {\n [ACTION_ATTRIBUTE]: 'assign',\n [TASK_ID_ATTRIBUTE]: assignment.id,\n });\n outcome = { ok: false, message: error instanceof Error ? error.message : String(error) };\n }\n results.push({ index, id: assignment.id, agent: assignment.agent, ...outcome });\n }\n return results;\n}\n\n/** Run an action through the reducer, persisting only when it produced a change. */\nasync function executeReducerAction(\n store: TaskStore,\n action: ReducerAction,\n params: TaskMutationParams,\n): Promise<ToolResult> {\n const { document, value } = await store.mutate((current) => {\n const result = applyTaskMutation(current, action, params);\n return {\n ...(isCommittingOp(result.op) ? { document: result.document } : {}),\n value: result,\n };\n });\n if (value.op.kind === 'error') throw actionableTaskError(action, value.op.message);\n // An upsert that applied nothing is a failed call: it wrote nothing and left\n // `rev` alone, so it must not read to the model as a success. A batch where\n // some entries landed returns normally — that is what partial apply means.\n if (value.op.kind === 'upsert' && value.op.applied === 0) {\n throw actionableTaskError(action, formatUpsertFailureText(value.op));\n }\n // `document` is the committed document, so `details.rev` matches what landed\n // on disk; `value.document` is the pre-write copy and lags by one.\n return buildToolResult(action, params, document, value.op);\n}\n\nexport function registerTaskTool(pi: ExtensionAPI, dependencies: TaskToolDependencies): void {\n const { store, delegation } = dependencies;\n\n pi.registerTool({\n name: TOOL_NAME,\n label: TOOL_LABEL,\n description:\n 'Manage a shared task list for tracking multi-step progress, and delegate tasks to subagents. Actions: upsert (write tasks — a tasks[] array where an entry with an id changes that task and an entry without an id creates one, so one call can capture a whole plan), list, get, delete (tombstone), clear (close/reset the list), assign (hand one or more tasks through assignments[] to named subagents that work in the background), cancel (stop a delegated run). upsert and assign apply entries independently: successes remain committed or delegated and failures are reported by array index. Batch a plan and independent assignments, but report progress one task at a time. Status: pending → in_progress → completed, plus failed and a deleted tombstone. The list is shared within the current session tree, including delegated subagents, while unrelated sessions start empty. Session stores persist until retention cleanup.',\n promptSnippet: DEFAULT_PROMPT_SNIPPET,\n promptGuidelines: DEFAULT_PROMPT_GUIDELINES,\n parameters: TaskParamsSchema,\n // Task rows carry their own status colors. Owning the shell prevents Pi's\n // pending/success/error background fill from obscuring those row states.\n renderShell: 'self',\n\n async execute(_toolCallId, params, signal, onUpdate, _ctx) {\n const action = params.action as TaskAction;\n const mutationParams = params as TaskMutationParams;\n\n try {\n rejectStrayFields(action, mutationParams);\n if (REDUCER_ACTIONS.has(action)) {\n const result = await executeReducerAction(store, action as ReducerAction, mutationParams);\n dependencies.onChange?.();\n return result;\n }\n\n if (action === 'assign') {\n const assignments = resolveAssignments(mutationParams);\n const first = assignments[0];\n const progress =\n assignments.length === 1 && first\n ? `Delegating task #${first.id}...`\n : `Delegating ${assignments.length} tasks...`;\n onUpdate?.(buildTextResult(action, mutationParams, store.snapshot, progress));\n const results = await executeAssignmentBatch(delegation, assignments, signal, dependencies.report);\n dependencies.onChange?.();\n const text = formatAssignmentResults(results);\n const assigned = results.flatMap((item) => (item.ok ? [item.id] : []));\n if (assigned.length === 0) throw actionableTaskError(action, text);\n return buildAssignmentResult(mutationParams, store.snapshot, text, {\n assigned,\n failed: results.length - assigned.length,\n });\n }\n\n onUpdate?.(\n buildTextResult(\n action,\n mutationParams,\n store.snapshot,\n `Requesting cancellation for task #${mutationParams.id ?? 'unknown'}...`,\n ),\n );\n const outcome = await delegation.cancel(mutationParams.id ?? Number.NaN);\n dependencies.onChange?.();\n if (!outcome.ok) throw actionableTaskError(action, outcome.message);\n return buildTextResult(action, mutationParams, store.snapshot, outcome.message, undefined);\n } catch (error) {\n // Rethrown so pi still renders the failure to the model; recorded\n // because this is where a store fault becomes visible to the user.\n dependencies.report?.error(TASK_EVENT.toolFailed, error, {\n [ACTION_ATTRIBUTE]: action,\n ...(mutationParams.id === undefined ? {} : { [TASK_ID_ATTRIBUTE]: mutationParams.id }),\n });\n if (error instanceof TaskToolExecutionError) throw error;\n throw actionableTaskError(action, error instanceof Error ? error.message : String(error));\n }\n },\n\n // Render hooks receive no session identity, so they read the store snapshot\n // that the executing session last loaded. That is the foreground session's\n // own view, which is exactly what its transcript should show.\n renderCall(args, theme, _context) {\n return renderTaskCall(args as never, theme, store.snapshot.tasks);\n },\n\n renderResult(result, options, theme, _context) {\n return renderTaskResult(result, options, theme);\n },\n });\n}\n"],"mappings":"2mBA2BA,MAAa,EACX,0FASI,EAAmB,cACnB,EAAoB,UACpB,EAAkB,IAAI,IAAgB,CAAC,SAAU,OAAQ,MAAO,SAAU,OAAO,CAAC,EAExF,IAAM,EAAN,cAAqC,KAAM,CAAC,EAE5C,SAAS,EAAoB,EAAoB,EAAyC,CACxF,OAAO,IAAI,EACT,CACE,QAAQ,EAAO,WAAW,IAC1B,GACA,WACA,2EACA,8DACA,4EACF,CAAC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,EAAE,EAAI,CAAC,CAAE,EACrE,GAAI,EAAS,SAAW,EAAG,MAAM,EAAoB,EAAQ,CAAI,EACjE,OAAO,EAAsB,EAAgB,EAAM,SAAU,EAAM,CACjE,WACA,OAAQ,EAAQ,OAAS,EAAS,MACpC,CAAC,CACH,CAEA,IACE,EACE,EACA,EACA,EAAM,SACN,qCAAqC,EAAe,IAAM,UAAU,IACtE,CACF,EACA,IAAM,EAAU,MAAM,EAAW,OAAO,EAAe,IAAM,GAAU,EAEvE,GADA,EAAa,WAAW,EACpB,CAAC,EAAQ,GAAI,MAAM,EAAoB,EAAQ,EAAQ,OAAO,EAClE,OAAO,EAAgB,EAAQ,EAAgB,EAAM,SAAU,EAAQ,QAAS,IAAA,EAAS,CAC3F,OAAS,EAAO,CAQd,MALA,EAAa,QAAQ,MAAM,EAAW,WAAY,EAAO,EACtD,GAAmB,EACpB,GAAI,EAAe,KAAO,IAAA,GAAY,CAAC,EAAI,EAAG,GAAoB,EAAe,EAAG,CACtF,CAAC,EACG,aAAiB,EAA8B,EAC7C,EAAoB,EAAQ,aAAiB,MAAQ,EAAM,QAAU,OAAO,CAAK,CAAC,CAC1F,CACF,EAKA,WAAW,EAAM,EAAO,EAAU,CAChC,OAAO,EAAe,EAAe,EAAO,EAAM,SAAS,KAAK,CAClE,EAEA,aAAa,EAAQ,EAAS,EAAO,EAAU,CAC7C,OAAO,EAAiB,EAAQ,EAAS,CAAK,CAChD,CACF,CAAC,CACH"}
|
|
1
|
+
{"version":3,"file":"taskTool.mjs","names":[],"sources":["../../../src/commands/task/taskTool.ts"],"sourcesContent":["import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';\nimport { TASK_EVENT, type TaskFailureReporter } from '../../adapters/telemetry/logSinkTelemetry.ts';\nimport {\n MSG_UPSERT_FIELD_MISPLACED,\n TaskParamsSchema,\n TOOL_LABEL,\n TOOL_NAME,\n taskActionAcceptsField,\n} from '../../schemas/task.ts';\nimport type { AssignOptions, DelegationManager, DelegationOutcome } from '../../services/delegation/manager.ts';\nimport { applyTaskMutation, isCommittingOp, type ReducerAction } from '../../services/store/reducer.ts';\nimport type { TaskStore } from '../../services/store/taskStore.ts';\nimport type { TaskAction, TaskAssignment, TaskMutationParams } from '../../services/store/types.ts';\nimport { renderTaskCall, renderTaskResult } from '../../tui/format.ts';\nimport { DEFAULT_MAX_TASKS } from '../../types/config.ts';\nimport { DEFAULT_PROMPT_GUIDELINES } from './promptGuidelines.ts';\nimport {\n type AssignmentItemResult,\n buildAssignmentResult,\n buildTextResult,\n buildToolResult,\n formatAssignmentResults,\n formatUpsertFailureText,\n type ToolResult,\n} from './responseEnvelope.ts';\n\nexport { DEFAULT_PROMPT_GUIDELINES } from './promptGuidelines.ts';\n\nexport const DEFAULT_PROMPT_SNIPPET =\n 'Manage a shared task list to track multi-step progress, and delegate tasks to subagents';\n\nexport interface TaskToolDependencies {\n store: TaskStore;\n delegation: DelegationManager;\n maxTasks?: number;\n onChange?: () => void;\n report?: TaskFailureReporter;\n}\n\nconst ACTION_ATTRIBUTE = 'tool.action';\nconst TASK_ID_ATTRIBUTE = 'task.id';\nconst REDUCER_ACTIONS = new Set<TaskAction>(['upsert', 'list', 'get', 'delete', 'clear']);\n\nclass TaskToolExecutionError extends Error {}\n\nfunction actionableTaskError(action: TaskAction, message: string): TaskToolExecutionError {\n return new TaskToolExecutionError(\n [\n `Task ${action} failed: ${message}`,\n '',\n 'Options:',\n '- List the task board and inspect the current ids, states, and blockers.',\n '- Correct the arguments or state conflict, then retry once.',\n '- Ask the user before cancelling work or changing dependencies to recover.',\n ].join('\\n'),\n );\n}\n\n/**\n * Reject a field that belongs to a different action.\n *\n * The params schema is flat and shared across every action, so this is the only\n * place `{\"action\":\"upsert\",\"id\":3}` can be caught — and it must be, because\n * the entry it carries has no id and would silently create a duplicate task.\n */\nfunction rejectStrayFields(action: TaskAction, params: TaskMutationParams): void {\n const stray = Object.keys(params).filter((key) => params[key] !== undefined && !taskActionAcceptsField(action, key));\n if (stray.length === 0) return;\n const hint = action === 'upsert' ? ` ${MSG_UPSERT_FIELD_MISPLACED}` : '';\n throw actionableTaskError(action, `${action} does not accept ${stray.join(', ')}.${hint}`);\n}\n\n/** assignments[] is the only assign contract, even when it contains one task. */\nfunction resolveAssignments(params: TaskMutationParams): TaskAssignment[] {\n const assignments = params.assignments;\n if (!assignments || assignments.length === 0) {\n throw actionableTaskError('assign', 'assign requires a non-empty assignments[] array');\n }\n return assignments;\n}\n\nfunction assignOptions(request: TaskAssignment, signal: AbortSignal | undefined): AssignOptions {\n return {\n agent: request.agent,\n inlineAgent: request.inlineAgent,\n instructions: request.instructions,\n relevantFiles: request.relevantFiles,\n priorFindings: request.priorFindings,\n model: request.model,\n context: request.context,\n signal,\n };\n}\n\nasync function executeAssignmentBatch(\n delegation: DelegationManager,\n assignments: readonly TaskAssignment[],\n signal: AbortSignal | undefined,\n report: TaskFailureReporter | undefined,\n): Promise<AssignmentItemResult[]> {\n const results: AssignmentItemResult[] = [];\n for (const [index, assignment] of assignments.entries()) {\n let outcome: DelegationOutcome;\n try {\n outcome = await delegation.assign(assignment.id, assignOptions(assignment, signal));\n } catch (error) {\n report?.error(TASK_EVENT.toolFailed, error, {\n [ACTION_ATTRIBUTE]: 'assign',\n [TASK_ID_ATTRIBUTE]: assignment.id,\n });\n outcome = { ok: false, message: error instanceof Error ? error.message : String(error) };\n }\n results.push({ index, id: assignment.id, agent: assignment.agent, ...outcome });\n }\n return results;\n}\n\n/** Run an action through the reducer, persisting only when it produced a change. */\nasync function executeReducerAction(\n store: TaskStore,\n action: ReducerAction,\n params: TaskMutationParams,\n maxTasks: number,\n): Promise<ToolResult> {\n const { document, value } = await store.mutate((current) => {\n const result = applyTaskMutation(current, action, params, undefined, maxTasks);\n return {\n ...(isCommittingOp(result.op) ? { document: result.document } : {}),\n value: result,\n };\n });\n if (value.op.kind === 'error') throw actionableTaskError(action, value.op.message);\n // An upsert that applied nothing is a failed call: it wrote nothing and left\n // `rev` alone, so it must not read to the model as a success. A batch where\n // some entries landed returns normally — that is what partial apply means.\n if (value.op.kind === 'upsert' && value.op.applied === 0) {\n throw actionableTaskError(action, formatUpsertFailureText(value.op));\n }\n // `document` is the committed document, so `details.rev` matches what landed\n // on disk; `value.document` is the pre-write copy and lags by one.\n return buildToolResult(action, params, document, value.op);\n}\n\nexport function registerTaskTool(pi: ExtensionAPI, dependencies: TaskToolDependencies): void {\n const { store, delegation, maxTasks = DEFAULT_MAX_TASKS } = dependencies;\n\n pi.registerTool({\n name: TOOL_NAME,\n label: TOOL_LABEL,\n description:\n 'Manage a shared task list for tracking multi-step progress, and delegate tasks to subagents. Actions: upsert (write tasks — a tasks[] array where an entry with an id changes that task and an entry without an id creates one, so one call can capture a whole plan), list, get, delete (tombstone), clear (close/reset the list), assign (hand one or more tasks through assignments[] to named subagents that work in the background), cancel (stop a delegated run). upsert and assign apply entries independently: successes remain committed or delegated and failures are reported by array index. Batch a plan and independent assignments, but report progress one task at a time. Status: pending → in_progress → completed, plus failed and a deleted tombstone. The list is shared within the current session tree, including delegated subagents, while unrelated sessions start empty. Session stores persist until retention cleanup.',\n promptSnippet: DEFAULT_PROMPT_SNIPPET,\n promptGuidelines: DEFAULT_PROMPT_GUIDELINES,\n parameters: TaskParamsSchema,\n // Task rows carry their own status colors. Owning the shell prevents Pi's\n // pending/success/error background fill from obscuring those row states.\n renderShell: 'self',\n\n async execute(_toolCallId, params, signal, onUpdate, _ctx) {\n const action = params.action as TaskAction;\n const mutationParams = params as TaskMutationParams;\n\n try {\n rejectStrayFields(action, mutationParams);\n if (REDUCER_ACTIONS.has(action)) {\n const result = await executeReducerAction(store, action as ReducerAction, mutationParams, maxTasks);\n dependencies.onChange?.();\n return result;\n }\n\n if (action === 'assign') {\n const assignments = resolveAssignments(mutationParams);\n const first = assignments[0];\n const progress =\n assignments.length === 1 && first\n ? `Delegating task #${first.id}...`\n : `Delegating ${assignments.length} tasks...`;\n onUpdate?.(buildTextResult(action, mutationParams, store.snapshot, progress));\n const results = await executeAssignmentBatch(delegation, assignments, signal, dependencies.report);\n dependencies.onChange?.();\n const text = formatAssignmentResults(results);\n const assigned = results.flatMap((item) => (item.ok ? [item.id] : []));\n if (assigned.length === 0) throw actionableTaskError(action, text);\n return buildAssignmentResult(mutationParams, store.snapshot, text, {\n assigned,\n failed: results.length - assigned.length,\n });\n }\n\n onUpdate?.(\n buildTextResult(\n action,\n mutationParams,\n store.snapshot,\n `Requesting cancellation for task #${mutationParams.id ?? 'unknown'}...`,\n ),\n );\n const outcome = await delegation.cancel(mutationParams.id ?? Number.NaN);\n dependencies.onChange?.();\n if (!outcome.ok) throw actionableTaskError(action, outcome.message);\n return buildTextResult(action, mutationParams, store.snapshot, outcome.message, undefined);\n } catch (error) {\n // Rethrown so pi still renders the failure to the model; recorded\n // because this is where a store fault becomes visible to the user.\n dependencies.report?.error(TASK_EVENT.toolFailed, error, {\n [ACTION_ATTRIBUTE]: action,\n ...(mutationParams.id === undefined ? {} : { [TASK_ID_ATTRIBUTE]: mutationParams.id }),\n });\n if (error instanceof TaskToolExecutionError) throw error;\n throw actionableTaskError(action, error instanceof Error ? error.message : String(error));\n }\n },\n\n // Render hooks receive no session identity, so they read the store snapshot\n // that the executing session last loaded. That is the foreground session's\n // own view, which is exactly what its transcript should show.\n renderCall(args, theme, _context) {\n return renderTaskCall(args as never, theme, store.snapshot.tasks);\n },\n\n renderResult(result, options, theme, _context) {\n return renderTaskResult(result, options, theme);\n },\n });\n}\n"],"mappings":"0oBA4BA,MAAa,EACX,0FAUI,EAAmB,cACnB,EAAoB,UACpB,EAAkB,IAAI,IAAgB,CAAC,SAAU,OAAQ,MAAO,SAAU,OAAO,CAAC,EAExF,IAAM,EAAN,cAAqC,KAAM,CAAC,EAE5C,SAAS,EAAoB,EAAoB,EAAyC,CACxF,OAAO,IAAI,EACT,CACE,QAAQ,EAAO,WAAW,IAC1B,GACA,WACA,2EACA,8DACA,4EACF,CAAC,CAAC,KAAK;CAAI,CACb,CACF,CASA,SAAS,EAA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EAAK,EAAE,EAAI,CAAC,CAAE,EACrE,GAAI,EAAS,SAAW,EAAG,MAAM,EAAoB,EAAQ,CAAI,EACjE,OAAO,EAAsB,EAAgB,EAAM,SAAU,EAAM,CACjE,WACA,OAAQ,EAAQ,OAAS,EAAS,MACpC,CAAC,CACH,CAEA,IACE,EACE,EACA,EACA,EAAM,SACN,qCAAqC,EAAe,IAAM,UAAU,IACtE,CACF,EACA,IAAM,EAAU,MAAM,EAAW,OAAO,EAAe,IAAM,GAAU,EAEvE,GADA,EAAa,WAAW,EACpB,CAAC,EAAQ,GAAI,MAAM,EAAoB,EAAQ,EAAQ,OAAO,EAClE,OAAO,EAAgB,EAAQ,EAAgB,EAAM,SAAU,EAAQ,QAAS,IAAA,EAAS,CAC3F,OAAS,EAAO,CAQd,MALA,EAAa,QAAQ,MAAM,EAAW,WAAY,EAAO,EACtD,GAAmB,EACpB,GAAI,EAAe,KAAO,IAAA,GAAY,CAAC,EAAI,EAAG,GAAoB,EAAe,EAAG,CACtF,CAAC,EACG,aAAiB,EAA8B,EAC7C,EAAoB,EAAQ,aAAiB,MAAQ,EAAM,QAAU,OAAO,CAAK,CAAC,CAC1F,CACF,EAKA,WAAW,EAAM,EAAO,EAAU,CAChC,OAAO,EAAe,EAAe,EAAO,EAAM,SAAS,KAAK,CAClE,EAEA,aAAa,EAAQ,EAAS,EAAO,EAAU,CAC7C,OAAO,EAAiB,EAAQ,EAAS,CAAK,CAChD,CACF,CAAC,CACH"}
|
package/dist/config.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./types/config.cjs");exports.COLLAPSE_KEY_ENV=e.COLLAPSE_KEY_ENV,exports.COLLAPSE_KEY_OFF=e.COLLAPSE_KEY_OFF,exports.DEFAULT_COLLAPSE_KEY=e.DEFAULT_COLLAPSE_KEY,exports.DEFAULT_DELEGATION_TIMEOUT_MS=e.DEFAULT_DELEGATION_TIMEOUT_MS,exports.DEFAULT_MAX_WIDGET_LINES=e.DEFAULT_MAX_WIDGET_LINES,exports.DEFAULT_STORE_TTL_MS=e.DEFAULT_STORE_TTL_MS,exports.DELEGATION_TIMEOUT_MS_ENV=e.DELEGATION_TIMEOUT_MS_ENV,exports.MAX_WIDGET_LINES_ENV=e.MAX_WIDGET_LINES_ENV,exports.STORE_TTL_MS_ENV=e.STORE_TTL_MS_ENV,exports.getDelegationTimeoutMs=e.getDelegationTimeoutMs,exports.getMaxWidgetLines=e.getMaxWidgetLines,exports.getStoreTtlMs=e.getStoreTtlMs,exports.parsePiTaskConfig=e.parsePiTaskConfig,exports.resolveCollapseKey=e.resolveCollapseKey;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./types/config.cjs");exports.COLLAPSE_KEY_ENV=e.COLLAPSE_KEY_ENV,exports.COLLAPSE_KEY_OFF=e.COLLAPSE_KEY_OFF,exports.DEFAULT_COLLAPSE_KEY=e.DEFAULT_COLLAPSE_KEY,exports.DEFAULT_DELEGATION_TIMEOUT_MS=e.DEFAULT_DELEGATION_TIMEOUT_MS,exports.DEFAULT_MAX_TASKS=e.DEFAULT_MAX_TASKS,exports.DEFAULT_MAX_WIDGET_LINES=e.DEFAULT_MAX_WIDGET_LINES,exports.DEFAULT_STORE_TTL_MS=e.DEFAULT_STORE_TTL_MS,exports.DELEGATION_TIMEOUT_MS_ENV=e.DELEGATION_TIMEOUT_MS_ENV,exports.MAX_TASKS_ENV=e.MAX_TASKS_ENV,exports.MAX_WIDGET_LINES_ENV=e.MAX_WIDGET_LINES_ENV,exports.STORE_TTL_MS_ENV=e.STORE_TTL_MS_ENV,exports.getDelegationTimeoutMs=e.getDelegationTimeoutMs,exports.getMaxTasks=e.getMaxTasks,exports.getMaxWidgetLines=e.getMaxWidgetLines,exports.getStoreTtlMs=e.getStoreTtlMs,exports.parsePiTaskConfig=e.parsePiTaskConfig,exports.resolveCollapseKey=e.resolveCollapseKey;
|
package/dist/config.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, MAX_WIDGET_LINES_ENV, PiTaskConfig, STORE_TTL_MS_ENV, getDelegationTimeoutMs, getMaxWidgetLines, getStoreTtlMs, parsePiTaskConfig, resolveCollapseKey } from "./types/config.cjs";
|
|
2
|
-
export { COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, MAX_WIDGET_LINES_ENV, PiTaskConfig, STORE_TTL_MS_ENV, getDelegationTimeoutMs, getMaxWidgetLines, getStoreTtlMs, parsePiTaskConfig, resolveCollapseKey };
|
|
1
|
+
import { COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_TASKS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, MAX_TASKS_ENV, MAX_WIDGET_LINES_ENV, PiTaskConfig, STORE_TTL_MS_ENV, getDelegationTimeoutMs, getMaxTasks, getMaxWidgetLines, getStoreTtlMs, parsePiTaskConfig, resolveCollapseKey } from "./types/config.cjs";
|
|
2
|
+
export { COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_TASKS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, MAX_TASKS_ENV, MAX_WIDGET_LINES_ENV, PiTaskConfig, STORE_TTL_MS_ENV, getDelegationTimeoutMs, getMaxTasks, getMaxWidgetLines, getStoreTtlMs, parsePiTaskConfig, resolveCollapseKey };
|
package/dist/config.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, MAX_WIDGET_LINES_ENV, PiTaskConfig, STORE_TTL_MS_ENV, getDelegationTimeoutMs, getMaxWidgetLines, getStoreTtlMs, parsePiTaskConfig, resolveCollapseKey } from "./types/config.mjs";
|
|
2
|
-
export { COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, MAX_WIDGET_LINES_ENV, PiTaskConfig, STORE_TTL_MS_ENV, getDelegationTimeoutMs, getMaxWidgetLines, getStoreTtlMs, parsePiTaskConfig, resolveCollapseKey };
|
|
1
|
+
import { COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_TASKS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, MAX_TASKS_ENV, MAX_WIDGET_LINES_ENV, PiTaskConfig, STORE_TTL_MS_ENV, getDelegationTimeoutMs, getMaxTasks, getMaxWidgetLines, getStoreTtlMs, parsePiTaskConfig, resolveCollapseKey } from "./types/config.mjs";
|
|
2
|
+
export { COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_TASKS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, MAX_TASKS_ENV, MAX_WIDGET_LINES_ENV, PiTaskConfig, STORE_TTL_MS_ENV, getDelegationTimeoutMs, getMaxTasks, getMaxWidgetLines, getStoreTtlMs, parsePiTaskConfig, resolveCollapseKey };
|
package/dist/config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{COLLAPSE_KEY_ENV as e,COLLAPSE_KEY_OFF as t,DEFAULT_COLLAPSE_KEY as n,DEFAULT_DELEGATION_TIMEOUT_MS as r,
|
|
1
|
+
import{COLLAPSE_KEY_ENV as e,COLLAPSE_KEY_OFF as t,DEFAULT_COLLAPSE_KEY as n,DEFAULT_DELEGATION_TIMEOUT_MS as r,DEFAULT_MAX_TASKS as i,DEFAULT_MAX_WIDGET_LINES as a,DEFAULT_STORE_TTL_MS as o,DELEGATION_TIMEOUT_MS_ENV as s,MAX_TASKS_ENV as c,MAX_WIDGET_LINES_ENV as l,STORE_TTL_MS_ENV as u,getDelegationTimeoutMs as d,getMaxTasks as f,getMaxWidgetLines as p,getStoreTtlMs as m,parsePiTaskConfig as h,resolveCollapseKey as g}from"./types/config.mjs";export{e as COLLAPSE_KEY_ENV,t as COLLAPSE_KEY_OFF,n as DEFAULT_COLLAPSE_KEY,r as DEFAULT_DELEGATION_TIMEOUT_MS,i as DEFAULT_MAX_TASKS,a as DEFAULT_MAX_WIDGET_LINES,o as DEFAULT_STORE_TTL_MS,s as DELEGATION_TIMEOUT_MS_ENV,c as MAX_TASKS_ENV,l as MAX_WIDGET_LINES_ENV,u as STORE_TTL_MS_ENV,d as getDelegationTimeoutMs,f as getMaxTasks,p as getMaxWidgetLines,m as getStoreTtlMs,h as parsePiTaskConfig,g as resolveCollapseKey};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./services/store/types.cjs"),t=require("./services/store/reconcile.cjs"),n=require("./services/store/taskGraph.cjs"),r=require("./services/delegation/manager.cjs"),i=require("./schemas/task.cjs"),a=require("./services/store/reducer.cjs"),o=require("./tui/selectors.cjs"),s=require("./commands/task/promptGuidelines.cjs"),
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./services/store/types.cjs"),t=require("./services/store/reconcile.cjs"),n=require("./services/store/taskGraph.cjs"),r=require("./services/delegation/manager.cjs"),i=require("./schemas/task.cjs"),a=require("./services/store/reducer.cjs"),o=require("./tui/selectors.cjs"),s=require("./types/config.cjs"),c=require("./commands/task/promptGuidelines.cjs"),l=require("./commands/task/responseEnvelope.cjs"),u=require("./commands/task/taskTool.cjs"),d=require("./adapters/store/paths.cjs");require("./services/store/paths.cjs");const f=require("./adapters/store/taskStore.cjs");require("./services/store/taskStore.cjs");const p=require("./adapters/pi/extension.cjs");exports.BACKGROUND_WORK_PROVIDER=r.BACKGROUND_WORK_PROVIDER,exports.COLLAPSE_KEY_ENV=s.COLLAPSE_KEY_ENV,exports.COLLAPSE_KEY_OFF=s.COLLAPSE_KEY_OFF,exports.COMMAND_NAME=i.COMMAND_NAME,exports.DEFAULT_COLLAPSE_KEY=s.DEFAULT_COLLAPSE_KEY,exports.DEFAULT_DELEGATION_TIMEOUT_MS=s.DEFAULT_DELEGATION_TIMEOUT_MS,exports.DEFAULT_MAX_TASKS=s.DEFAULT_MAX_TASKS,exports.DEFAULT_MAX_WIDGET_LINES=s.DEFAULT_MAX_WIDGET_LINES,exports.DEFAULT_PROMPT_GUIDELINES=c.DEFAULT_PROMPT_GUIDELINES,exports.DEFAULT_PROMPT_SNIPPET=u.DEFAULT_PROMPT_SNIPPET,exports.DEFAULT_STORE_TTL_MS=s.DEFAULT_STORE_TTL_MS,exports.DELEGATION_TIMEOUT_MS_ENV=s.DELEGATION_TIMEOUT_MS_ENV,exports.DELETED_STATUS=e.DELETED_STATUS,exports.DelegationManager=r.DelegationManager,exports.ERR_CANCEL_UNACKNOWLEDGED=r.ERR_CANCEL_UNACKNOWLEDGED,exports.ERR_CHILD_SESSION=r.ERR_CHILD_SESSION,exports.ERR_NO_RUNTIME=r.ERR_NO_RUNTIME,exports.ERR_ORPHANED_BY_RESTART=t.ERR_ORPHANED_BY_RESTART,exports.ERR_ORPHANED_BY_SESSION=t.ERR_ORPHANED_BY_SESSION,exports.ERR_REQUIRES_INTERACTIVE=i.ERR_REQUIRES_INTERACTIVE,exports.MAX_BRIEF_FILES=r.MAX_BRIEF_FILES,exports.MAX_TASKS_ENV=s.MAX_TASKS_ENV,exports.MAX_UPSERT_ITEMS=a.MAX_UPSERT_ITEMS,exports.MAX_WIDGET_LINES_ENV=s.MAX_WIDGET_LINES_ENV,exports.MSG_ALL_COMPLETE_CLEAR=l.MSG_ALL_COMPLETE_CLEAR,exports.MSG_ASSIGN_PARTIAL=l.MSG_ASSIGN_PARTIAL,exports.MSG_NO_TASKS=i.MSG_NO_TASKS,exports.MSG_UPSERT_FIELD_MISPLACED=i.MSG_UPSERT_FIELD_MISPLACED,exports.MSG_UPSERT_NONE_APPLIED=l.MSG_UPSERT_NONE_APPLIED,exports.MSG_UPSERT_PARTIAL=l.MSG_UPSERT_PARTIAL,exports.NOTIFY_CUSTOM_TYPE=r.NOTIFY_CUSTOM_TYPE,exports.REF_PATTERN=a.REF_PATTERN,exports.STORE_PATH_ENV=d.STORE_PATH_ENV,exports.STORE_SCHEMA_VERSION=e.STORE_SCHEMA_VERSION,exports.STORE_TTL_MS_ENV=s.STORE_TTL_MS_ENV,exports.TASK_ACTIONS=i.TASK_ACTIONS,exports.TASK_ACTION_FIELDS=i.TASK_ACTION_FIELDS,exports.TASK_CONTEXTS=i.TASK_CONTEXTS,exports.TASK_STATUSES=i.TASK_STATUSES,exports.TOOL_LABEL=i.TOOL_LABEL,exports.TOOL_NAME=i.TOOL_NAME,exports.TaskAssignmentSchema=i.TaskAssignmentSchema,exports.TaskItemSchema=i.TaskItemSchema,exports.TaskParamsSchema=i.TaskParamsSchema,exports.TaskStore=f.TaskStore,exports.applyTaskMutation=a.applyTaskMutation,exports.buildAssignmentResult=l.buildAssignmentResult,exports.buildTextResult=l.buildTextResult,exports.buildToolResult=l.buildToolResult,exports.countTasks=o.countTasks,exports.deriveBlocks=n.deriveBlocks,exports.deriveTaskProjection=o.deriveTaskProjection,exports.detectCycle=n.detectCycle,exports.emptyDocument=e.emptyDocument,exports.formatAssignmentResults=l.formatAssignmentResults,exports.formatContent=l.formatContent,exports.formatUpsertFailure=a.formatUpsertFailure,exports.formatUpsertFailureText=l.formatUpsertFailureText,exports.getDelegationTimeoutMs=s.getDelegationTimeoutMs,exports.getMaxTasks=s.getMaxTasks,exports.getMaxWidgetLines=s.getMaxWidgetLines,exports.getStoreTtlMs=s.getStoreTtlMs,exports.groupTasks=o.groupTasks,exports.hasActiveWork=o.hasActiveWork,exports.hasStorePathOverride=d.hasStorePathOverride,exports.isBlocked=n.isBlocked,exports.isCommittingOp=a.isCommittingOp,exports.isDelegationActive=e.isDelegationActive,exports.isTaskListComplete=n.isTaskListComplete,exports.lockPathFor=d.lockPathFor,exports.parsePiTaskConfig=s.parsePiTaskConfig,exports.reconcileOrphanedDelegations=t.reconcileOrphanedDelegations,exports.registerTaskTool=u.registerTaskTool,exports.removeLegacyStoreDirectory=d.removeLegacyStoreDirectory,exports.removeLegacyStoreDirectoryAsync=d.removeLegacyStoreDirectoryAsync,exports.resolveCollapseKey=s.resolveCollapseKey,exports.resolveLegacyStoreDirectory=d.resolveLegacyStoreDirectory,exports.resolveLegacyStoreDirectoryAsync=d.resolveLegacyStoreDirectoryAsync,exports.resolveSessionKey=d.resolveSessionKey,exports.resolveStorePath=d.resolveStorePath,exports.selectOverlayLayout=o.selectOverlayLayout,exports.selectOverlayLayoutFromProjection=o.selectOverlayLayoutFromProjection,exports.shouldShowIds=o.shouldShowIds,exports.singleItemOutcome=a.singleItemOutcome,exports.sweepStoreFiles=d.sweepStoreFiles,exports.sweepStoreFilesAsync=d.sweepStoreFilesAsync,exports.taskActionAcceptsField=i.taskActionAcceptsField,exports.taskExtension=p.default,exports.tempPathFor=d.tempPathFor,exports.unresolvedBlockers=n.unresolvedBlockers,exports.visibleTasks=o.visibleTasks;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AssignmentSummary, DELETED_STATUS, DelegationResult, DelegationState, DepToken, STORE_SCHEMA_VERSION, Task, TaskAction, TaskAssignment, TaskDelegation, TaskDetails, TaskDocument, TaskItemMutation, TaskMutationParams, TaskStatus, UpsertItemOutcome, UpsertSummary, emptyDocument, isDelegationActive } from "./services/store/types.cjs";
|
|
2
2
|
import { TaskStore, TaskStoreCommitListener, TaskStoreOptions } from "./adapters/store/taskStore.cjs";
|
|
3
3
|
import "./services/store/taskStore.cjs";
|
|
4
|
-
import { COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, MAX_WIDGET_LINES_ENV, PiTaskConfig, STORE_TTL_MS_ENV, getDelegationTimeoutMs, getMaxWidgetLines, getStoreTtlMs, parsePiTaskConfig, resolveCollapseKey } from "./types/config.cjs";
|
|
4
|
+
import { COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_TASKS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, MAX_TASKS_ENV, MAX_WIDGET_LINES_ENV, PiTaskConfig, STORE_TTL_MS_ENV, getDelegationTimeoutMs, getMaxTasks, getMaxWidgetLines, getStoreTtlMs, parsePiTaskConfig, resolveCollapseKey } from "./types/config.cjs";
|
|
5
5
|
import { AssignOptions, BACKGROUND_WORK_PROVIDER, DelegationManager, DelegationManagerOptions, DelegationNotifier, DelegationOutcome, DelegationProgress, ERR_CANCEL_UNACKNOWLEDGED, ERR_CHILD_SESSION, ERR_NO_RUNTIME, MAX_BRIEF_FILES, NOTIFY_CUSTOM_TYPE } from "./services/delegation/manager.cjs";
|
|
6
6
|
import taskExtension from "./adapters/pi/extension.cjs";
|
|
7
7
|
import { ApplyResult, MAX_UPSERT_ITEMS, Op, REF_PATTERN, ReducerAction, applyTaskMutation, formatUpsertFailure, isCommittingOp, singleItemOutcome } from "./services/store/reducer.cjs";
|
|
@@ -13,4 +13,4 @@ import { STORE_PATH_ENV, StoreSweepResult, hasStorePathOverride, lockPathFor, re
|
|
|
13
13
|
import { ERR_ORPHANED_BY_RESTART, ERR_ORPHANED_BY_SESSION, ReconcileResult, ReconcileSelf, reconcileOrphanedDelegations } from "./services/store/reconcile.cjs";
|
|
14
14
|
import { deriveBlocks, detectCycle, isBlocked, isTaskListComplete, unresolvedBlockers } from "./services/store/taskGraph.cjs";
|
|
15
15
|
import { OverlayLayout, TaskCounts, TaskGroups, TaskProjection, countTasks, deriveTaskProjection, groupTasks, hasActiveWork, selectOverlayLayout, selectOverlayLayoutFromProjection, shouldShowIds, visibleTasks } from "./tui/selectors.cjs";
|
|
16
|
-
export { ApplyResult, AssignOptions, AssignmentItemResult, AssignmentSummary, BACKGROUND_WORK_PROVIDER, COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, COMMAND_NAME, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_PROMPT_GUIDELINES, DEFAULT_PROMPT_SNIPPET, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, DELETED_STATUS, DelegationManager, DelegationManagerOptions, DelegationNotifier, DelegationOutcome, DelegationProgress, DelegationResult, DelegationState, DepToken, ERR_CANCEL_UNACKNOWLEDGED, ERR_CHILD_SESSION, ERR_NO_RUNTIME, ERR_ORPHANED_BY_RESTART, ERR_ORPHANED_BY_SESSION, ERR_REQUIRES_INTERACTIVE, MAX_BRIEF_FILES, MAX_UPSERT_ITEMS, MAX_WIDGET_LINES_ENV, MSG_ALL_COMPLETE_CLEAR, MSG_ASSIGN_PARTIAL, MSG_NO_TASKS, MSG_UPSERT_FIELD_MISPLACED, MSG_UPSERT_NONE_APPLIED, MSG_UPSERT_PARTIAL, NOTIFY_CUSTOM_TYPE, Op, OverlayLayout, PiTaskConfig, REF_PATTERN, ReconcileResult, ReconcileSelf, ReducerAction, STORE_PATH_ENV, STORE_SCHEMA_VERSION, STORE_TTL_MS_ENV, type StoreSweepResult, TASK_ACTIONS, TASK_ACTION_FIELDS, TASK_CONTEXTS, TASK_STATUSES, TOOL_LABEL, TOOL_NAME, Task, TaskAction, TaskAssignment, TaskAssignmentParams, TaskAssignmentSchema, TaskCounts, TaskDelegation, TaskDetails, TaskDocument, TaskGroups, TaskItemMutation, TaskItemParams, TaskItemSchema, TaskMutationParams, TaskParams, TaskParamsSchema, TaskProjection, TaskStatus, TaskStore, type TaskStoreCommitListener, type TaskStoreOptions, TaskToolDependencies, ToolResult, UpsertItemOutcome, UpsertSummary, applyTaskMutation, buildAssignmentResult, buildTextResult, buildToolResult, countTasks, deriveBlocks, deriveTaskProjection, detectCycle, emptyDocument, formatAssignmentResults, formatContent, formatUpsertFailure, formatUpsertFailureText, getDelegationTimeoutMs, getMaxWidgetLines, getStoreTtlMs, groupTasks, hasActiveWork, hasStorePathOverride, isBlocked, isCommittingOp, isDelegationActive, isTaskListComplete, lockPathFor, parsePiTaskConfig, reconcileOrphanedDelegations, registerTaskTool, removeLegacyStoreDirectory, removeLegacyStoreDirectoryAsync, resolveCollapseKey, resolveLegacyStoreDirectory, resolveLegacyStoreDirectoryAsync, resolveSessionKey, resolveStorePath, selectOverlayLayout, selectOverlayLayoutFromProjection, shouldShowIds, singleItemOutcome, sweepStoreFiles, sweepStoreFilesAsync, taskActionAcceptsField, taskExtension, tempPathFor, unresolvedBlockers, visibleTasks };
|
|
16
|
+
export { ApplyResult, AssignOptions, AssignmentItemResult, AssignmentSummary, BACKGROUND_WORK_PROVIDER, COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, COMMAND_NAME, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_TASKS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_PROMPT_GUIDELINES, DEFAULT_PROMPT_SNIPPET, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, DELETED_STATUS, DelegationManager, DelegationManagerOptions, DelegationNotifier, DelegationOutcome, DelegationProgress, DelegationResult, DelegationState, DepToken, ERR_CANCEL_UNACKNOWLEDGED, ERR_CHILD_SESSION, ERR_NO_RUNTIME, ERR_ORPHANED_BY_RESTART, ERR_ORPHANED_BY_SESSION, ERR_REQUIRES_INTERACTIVE, MAX_BRIEF_FILES, MAX_TASKS_ENV, MAX_UPSERT_ITEMS, MAX_WIDGET_LINES_ENV, MSG_ALL_COMPLETE_CLEAR, MSG_ASSIGN_PARTIAL, MSG_NO_TASKS, MSG_UPSERT_FIELD_MISPLACED, MSG_UPSERT_NONE_APPLIED, MSG_UPSERT_PARTIAL, NOTIFY_CUSTOM_TYPE, Op, OverlayLayout, PiTaskConfig, REF_PATTERN, ReconcileResult, ReconcileSelf, ReducerAction, STORE_PATH_ENV, STORE_SCHEMA_VERSION, STORE_TTL_MS_ENV, type StoreSweepResult, TASK_ACTIONS, TASK_ACTION_FIELDS, TASK_CONTEXTS, TASK_STATUSES, TOOL_LABEL, TOOL_NAME, Task, TaskAction, TaskAssignment, TaskAssignmentParams, TaskAssignmentSchema, TaskCounts, TaskDelegation, TaskDetails, TaskDocument, TaskGroups, TaskItemMutation, TaskItemParams, TaskItemSchema, TaskMutationParams, TaskParams, TaskParamsSchema, TaskProjection, TaskStatus, TaskStore, type TaskStoreCommitListener, type TaskStoreOptions, TaskToolDependencies, ToolResult, UpsertItemOutcome, UpsertSummary, applyTaskMutation, buildAssignmentResult, buildTextResult, buildToolResult, countTasks, deriveBlocks, deriveTaskProjection, detectCycle, emptyDocument, formatAssignmentResults, formatContent, formatUpsertFailure, formatUpsertFailureText, getDelegationTimeoutMs, getMaxTasks, getMaxWidgetLines, getStoreTtlMs, groupTasks, hasActiveWork, hasStorePathOverride, isBlocked, isCommittingOp, isDelegationActive, isTaskListComplete, lockPathFor, parsePiTaskConfig, reconcileOrphanedDelegations, registerTaskTool, removeLegacyStoreDirectory, removeLegacyStoreDirectoryAsync, resolveCollapseKey, resolveLegacyStoreDirectory, resolveLegacyStoreDirectoryAsync, resolveSessionKey, resolveStorePath, selectOverlayLayout, selectOverlayLayoutFromProjection, shouldShowIds, singleItemOutcome, sweepStoreFiles, sweepStoreFilesAsync, taskActionAcceptsField, taskExtension, tempPathFor, unresolvedBlockers, visibleTasks };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AssignmentSummary, DELETED_STATUS, DelegationResult, DelegationState, DepToken, STORE_SCHEMA_VERSION, Task, TaskAction, TaskAssignment, TaskDelegation, TaskDetails, TaskDocument, TaskItemMutation, TaskMutationParams, TaskStatus, UpsertItemOutcome, UpsertSummary, emptyDocument, isDelegationActive } from "./services/store/types.mjs";
|
|
2
2
|
import { TaskStore, TaskStoreCommitListener, TaskStoreOptions } from "./adapters/store/taskStore.mjs";
|
|
3
3
|
import "./services/store/taskStore.mjs";
|
|
4
|
-
import { COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, MAX_WIDGET_LINES_ENV, PiTaskConfig, STORE_TTL_MS_ENV, getDelegationTimeoutMs, getMaxWidgetLines, getStoreTtlMs, parsePiTaskConfig, resolveCollapseKey } from "./types/config.mjs";
|
|
4
|
+
import { COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_TASKS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, MAX_TASKS_ENV, MAX_WIDGET_LINES_ENV, PiTaskConfig, STORE_TTL_MS_ENV, getDelegationTimeoutMs, getMaxTasks, getMaxWidgetLines, getStoreTtlMs, parsePiTaskConfig, resolveCollapseKey } from "./types/config.mjs";
|
|
5
5
|
import { AssignOptions, BACKGROUND_WORK_PROVIDER, DelegationManager, DelegationManagerOptions, DelegationNotifier, DelegationOutcome, DelegationProgress, ERR_CANCEL_UNACKNOWLEDGED, ERR_CHILD_SESSION, ERR_NO_RUNTIME, MAX_BRIEF_FILES, NOTIFY_CUSTOM_TYPE } from "./services/delegation/manager.mjs";
|
|
6
6
|
import taskExtension from "./adapters/pi/extension.mjs";
|
|
7
7
|
import { ApplyResult, MAX_UPSERT_ITEMS, Op, REF_PATTERN, ReducerAction, applyTaskMutation, formatUpsertFailure, isCommittingOp, singleItemOutcome } from "./services/store/reducer.mjs";
|
|
@@ -13,4 +13,4 @@ import { STORE_PATH_ENV, StoreSweepResult, hasStorePathOverride, lockPathFor, re
|
|
|
13
13
|
import { ERR_ORPHANED_BY_RESTART, ERR_ORPHANED_BY_SESSION, ReconcileResult, ReconcileSelf, reconcileOrphanedDelegations } from "./services/store/reconcile.mjs";
|
|
14
14
|
import { deriveBlocks, detectCycle, isBlocked, isTaskListComplete, unresolvedBlockers } from "./services/store/taskGraph.mjs";
|
|
15
15
|
import { OverlayLayout, TaskCounts, TaskGroups, TaskProjection, countTasks, deriveTaskProjection, groupTasks, hasActiveWork, selectOverlayLayout, selectOverlayLayoutFromProjection, shouldShowIds, visibleTasks } from "./tui/selectors.mjs";
|
|
16
|
-
export { ApplyResult, AssignOptions, AssignmentItemResult, AssignmentSummary, BACKGROUND_WORK_PROVIDER, COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, COMMAND_NAME, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_PROMPT_GUIDELINES, DEFAULT_PROMPT_SNIPPET, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, DELETED_STATUS, DelegationManager, DelegationManagerOptions, DelegationNotifier, DelegationOutcome, DelegationProgress, DelegationResult, DelegationState, DepToken, ERR_CANCEL_UNACKNOWLEDGED, ERR_CHILD_SESSION, ERR_NO_RUNTIME, ERR_ORPHANED_BY_RESTART, ERR_ORPHANED_BY_SESSION, ERR_REQUIRES_INTERACTIVE, MAX_BRIEF_FILES, MAX_UPSERT_ITEMS, MAX_WIDGET_LINES_ENV, MSG_ALL_COMPLETE_CLEAR, MSG_ASSIGN_PARTIAL, MSG_NO_TASKS, MSG_UPSERT_FIELD_MISPLACED, MSG_UPSERT_NONE_APPLIED, MSG_UPSERT_PARTIAL, NOTIFY_CUSTOM_TYPE, Op, OverlayLayout, PiTaskConfig, REF_PATTERN, ReconcileResult, ReconcileSelf, ReducerAction, STORE_PATH_ENV, STORE_SCHEMA_VERSION, STORE_TTL_MS_ENV, type StoreSweepResult, TASK_ACTIONS, TASK_ACTION_FIELDS, TASK_CONTEXTS, TASK_STATUSES, TOOL_LABEL, TOOL_NAME, Task, TaskAction, TaskAssignment, TaskAssignmentParams, TaskAssignmentSchema, TaskCounts, TaskDelegation, TaskDetails, TaskDocument, TaskGroups, TaskItemMutation, TaskItemParams, TaskItemSchema, TaskMutationParams, TaskParams, TaskParamsSchema, TaskProjection, TaskStatus, TaskStore, type TaskStoreCommitListener, type TaskStoreOptions, TaskToolDependencies, ToolResult, UpsertItemOutcome, UpsertSummary, applyTaskMutation, buildAssignmentResult, buildTextResult, buildToolResult, countTasks, deriveBlocks, deriveTaskProjection, detectCycle, emptyDocument, formatAssignmentResults, formatContent, formatUpsertFailure, formatUpsertFailureText, getDelegationTimeoutMs, getMaxWidgetLines, getStoreTtlMs, groupTasks, hasActiveWork, hasStorePathOverride, isBlocked, isCommittingOp, isDelegationActive, isTaskListComplete, lockPathFor, parsePiTaskConfig, reconcileOrphanedDelegations, registerTaskTool, removeLegacyStoreDirectory, removeLegacyStoreDirectoryAsync, resolveCollapseKey, resolveLegacyStoreDirectory, resolveLegacyStoreDirectoryAsync, resolveSessionKey, resolveStorePath, selectOverlayLayout, selectOverlayLayoutFromProjection, shouldShowIds, singleItemOutcome, sweepStoreFiles, sweepStoreFilesAsync, taskActionAcceptsField, taskExtension, tempPathFor, unresolvedBlockers, visibleTasks };
|
|
16
|
+
export { ApplyResult, AssignOptions, AssignmentItemResult, AssignmentSummary, BACKGROUND_WORK_PROVIDER, COLLAPSE_KEY_ENV, COLLAPSE_KEY_OFF, COMMAND_NAME, DEFAULT_COLLAPSE_KEY, DEFAULT_DELEGATION_TIMEOUT_MS, DEFAULT_MAX_TASKS, DEFAULT_MAX_WIDGET_LINES, DEFAULT_PROMPT_GUIDELINES, DEFAULT_PROMPT_SNIPPET, DEFAULT_STORE_TTL_MS, DELEGATION_TIMEOUT_MS_ENV, DELETED_STATUS, DelegationManager, DelegationManagerOptions, DelegationNotifier, DelegationOutcome, DelegationProgress, DelegationResult, DelegationState, DepToken, ERR_CANCEL_UNACKNOWLEDGED, ERR_CHILD_SESSION, ERR_NO_RUNTIME, ERR_ORPHANED_BY_RESTART, ERR_ORPHANED_BY_SESSION, ERR_REQUIRES_INTERACTIVE, MAX_BRIEF_FILES, MAX_TASKS_ENV, MAX_UPSERT_ITEMS, MAX_WIDGET_LINES_ENV, MSG_ALL_COMPLETE_CLEAR, MSG_ASSIGN_PARTIAL, MSG_NO_TASKS, MSG_UPSERT_FIELD_MISPLACED, MSG_UPSERT_NONE_APPLIED, MSG_UPSERT_PARTIAL, NOTIFY_CUSTOM_TYPE, Op, OverlayLayout, PiTaskConfig, REF_PATTERN, ReconcileResult, ReconcileSelf, ReducerAction, STORE_PATH_ENV, STORE_SCHEMA_VERSION, STORE_TTL_MS_ENV, type StoreSweepResult, TASK_ACTIONS, TASK_ACTION_FIELDS, TASK_CONTEXTS, TASK_STATUSES, TOOL_LABEL, TOOL_NAME, Task, TaskAction, TaskAssignment, TaskAssignmentParams, TaskAssignmentSchema, TaskCounts, TaskDelegation, TaskDetails, TaskDocument, TaskGroups, TaskItemMutation, TaskItemParams, TaskItemSchema, TaskMutationParams, TaskParams, TaskParamsSchema, TaskProjection, TaskStatus, TaskStore, type TaskStoreCommitListener, type TaskStoreOptions, TaskToolDependencies, ToolResult, UpsertItemOutcome, UpsertSummary, applyTaskMutation, buildAssignmentResult, buildTextResult, buildToolResult, countTasks, deriveBlocks, deriveTaskProjection, detectCycle, emptyDocument, formatAssignmentResults, formatContent, formatUpsertFailure, formatUpsertFailureText, getDelegationTimeoutMs, getMaxTasks, getMaxWidgetLines, getStoreTtlMs, groupTasks, hasActiveWork, hasStorePathOverride, isBlocked, isCommittingOp, isDelegationActive, isTaskListComplete, lockPathFor, parsePiTaskConfig, reconcileOrphanedDelegations, registerTaskTool, removeLegacyStoreDirectory, removeLegacyStoreDirectoryAsync, resolveCollapseKey, resolveLegacyStoreDirectory, resolveLegacyStoreDirectoryAsync, resolveSessionKey, resolveStorePath, selectOverlayLayout, selectOverlayLayoutFromProjection, shouldShowIds, singleItemOutcome, sweepStoreFiles, sweepStoreFilesAsync, taskActionAcceptsField, taskExtension, tempPathFor, unresolvedBlockers, visibleTasks };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DELETED_STATUS as e,STORE_SCHEMA_VERSION as t,emptyDocument as n,isDelegationActive as r}from"./services/store/types.mjs";import{ERR_ORPHANED_BY_RESTART as i,ERR_ORPHANED_BY_SESSION as a,reconcileOrphanedDelegations as o}from"./services/store/reconcile.mjs";import{deriveBlocks as s,detectCycle as c,isBlocked as l,isTaskListComplete as u,unresolvedBlockers as d}from"./services/store/taskGraph.mjs";import{BACKGROUND_WORK_PROVIDER as f,DelegationManager as p,ERR_CANCEL_UNACKNOWLEDGED as m,ERR_CHILD_SESSION as h,ERR_NO_RUNTIME as g,MAX_BRIEF_FILES as _,NOTIFY_CUSTOM_TYPE as v}from"./services/delegation/manager.mjs";import{COMMAND_NAME as y,ERR_REQUIRES_INTERACTIVE as b,MSG_NO_TASKS as x,MSG_UPSERT_FIELD_MISPLACED as S,TASK_ACTIONS as C,TASK_ACTION_FIELDS as w,TASK_CONTEXTS as T,TASK_STATUSES as E,TOOL_LABEL as D,TOOL_NAME as O,TaskAssignmentSchema as k,TaskItemSchema as A,TaskParamsSchema as j,taskActionAcceptsField as M}from"./schemas/task.mjs";import{MAX_UPSERT_ITEMS as N,REF_PATTERN as P,applyTaskMutation as F,formatUpsertFailure as I,isCommittingOp as L,singleItemOutcome as R}from"./services/store/reducer.mjs";import{countTasks as z,deriveTaskProjection as B,groupTasks as V,hasActiveWork as H,selectOverlayLayout as U,selectOverlayLayoutFromProjection as W,shouldShowIds as G,visibleTasks as K}from"./tui/selectors.mjs";import{
|
|
1
|
+
import{DELETED_STATUS as e,STORE_SCHEMA_VERSION as t,emptyDocument as n,isDelegationActive as r}from"./services/store/types.mjs";import{ERR_ORPHANED_BY_RESTART as i,ERR_ORPHANED_BY_SESSION as a,reconcileOrphanedDelegations as o}from"./services/store/reconcile.mjs";import{deriveBlocks as s,detectCycle as c,isBlocked as l,isTaskListComplete as u,unresolvedBlockers as d}from"./services/store/taskGraph.mjs";import{BACKGROUND_WORK_PROVIDER as f,DelegationManager as p,ERR_CANCEL_UNACKNOWLEDGED as m,ERR_CHILD_SESSION as h,ERR_NO_RUNTIME as g,MAX_BRIEF_FILES as _,NOTIFY_CUSTOM_TYPE as v}from"./services/delegation/manager.mjs";import{COMMAND_NAME as y,ERR_REQUIRES_INTERACTIVE as b,MSG_NO_TASKS as x,MSG_UPSERT_FIELD_MISPLACED as S,TASK_ACTIONS as C,TASK_ACTION_FIELDS as w,TASK_CONTEXTS as T,TASK_STATUSES as E,TOOL_LABEL as D,TOOL_NAME as O,TaskAssignmentSchema as k,TaskItemSchema as A,TaskParamsSchema as j,taskActionAcceptsField as M}from"./schemas/task.mjs";import{MAX_UPSERT_ITEMS as N,REF_PATTERN as P,applyTaskMutation as F,formatUpsertFailure as I,isCommittingOp as L,singleItemOutcome as R}from"./services/store/reducer.mjs";import{countTasks as z,deriveTaskProjection as B,groupTasks as V,hasActiveWork as H,selectOverlayLayout as U,selectOverlayLayoutFromProjection as W,shouldShowIds as G,visibleTasks as K}from"./tui/selectors.mjs";import{COLLAPSE_KEY_ENV as q,COLLAPSE_KEY_OFF as J,DEFAULT_COLLAPSE_KEY as Y,DEFAULT_DELEGATION_TIMEOUT_MS as X,DEFAULT_MAX_TASKS as Z,DEFAULT_MAX_WIDGET_LINES as Q,DEFAULT_STORE_TTL_MS as $,DELEGATION_TIMEOUT_MS_ENV as ee,MAX_TASKS_ENV as te,MAX_WIDGET_LINES_ENV as ne,STORE_TTL_MS_ENV as re,getDelegationTimeoutMs as ie,getMaxTasks as ae,getMaxWidgetLines as oe,getStoreTtlMs as se,parsePiTaskConfig as ce,resolveCollapseKey as le}from"./types/config.mjs";import{DEFAULT_PROMPT_GUIDELINES as ue}from"./commands/task/promptGuidelines.mjs";import{MSG_ALL_COMPLETE_CLEAR as de,MSG_ASSIGN_PARTIAL as fe,MSG_UPSERT_NONE_APPLIED as pe,MSG_UPSERT_PARTIAL as me,buildAssignmentResult as he,buildTextResult as ge,buildToolResult as _e,formatAssignmentResults as ve,formatContent as ye,formatUpsertFailureText as be}from"./commands/task/responseEnvelope.mjs";import{DEFAULT_PROMPT_SNIPPET as xe,registerTaskTool as Se}from"./commands/task/taskTool.mjs";import{STORE_PATH_ENV as Ce,hasStorePathOverride as we,lockPathFor as Te,removeLegacyStoreDirectory as Ee,removeLegacyStoreDirectoryAsync as De,resolveLegacyStoreDirectory as Oe,resolveLegacyStoreDirectoryAsync as ke,resolveSessionKey as Ae,resolveStorePath as je,sweepStoreFiles as Me,sweepStoreFilesAsync as Ne,tempPathFor as Pe}from"./adapters/store/paths.mjs";import"./services/store/paths.mjs";import{TaskStore as Fe}from"./adapters/store/taskStore.mjs";import"./services/store/taskStore.mjs";import Ie from"./adapters/pi/extension.mjs";export{f as BACKGROUND_WORK_PROVIDER,q as COLLAPSE_KEY_ENV,J as COLLAPSE_KEY_OFF,y as COMMAND_NAME,Y as DEFAULT_COLLAPSE_KEY,X as DEFAULT_DELEGATION_TIMEOUT_MS,Z as DEFAULT_MAX_TASKS,Q as DEFAULT_MAX_WIDGET_LINES,ue as DEFAULT_PROMPT_GUIDELINES,xe as DEFAULT_PROMPT_SNIPPET,$ as DEFAULT_STORE_TTL_MS,ee as DELEGATION_TIMEOUT_MS_ENV,e as DELETED_STATUS,p as DelegationManager,m as ERR_CANCEL_UNACKNOWLEDGED,h as ERR_CHILD_SESSION,g as ERR_NO_RUNTIME,i as ERR_ORPHANED_BY_RESTART,a as ERR_ORPHANED_BY_SESSION,b as ERR_REQUIRES_INTERACTIVE,_ as MAX_BRIEF_FILES,te as MAX_TASKS_ENV,N as MAX_UPSERT_ITEMS,ne as MAX_WIDGET_LINES_ENV,de as MSG_ALL_COMPLETE_CLEAR,fe as MSG_ASSIGN_PARTIAL,x as MSG_NO_TASKS,S as MSG_UPSERT_FIELD_MISPLACED,pe as MSG_UPSERT_NONE_APPLIED,me as MSG_UPSERT_PARTIAL,v as NOTIFY_CUSTOM_TYPE,P as REF_PATTERN,Ce as STORE_PATH_ENV,t as STORE_SCHEMA_VERSION,re as STORE_TTL_MS_ENV,C as TASK_ACTIONS,w as TASK_ACTION_FIELDS,T as TASK_CONTEXTS,E as TASK_STATUSES,D as TOOL_LABEL,O as TOOL_NAME,k as TaskAssignmentSchema,A as TaskItemSchema,j as TaskParamsSchema,Fe as TaskStore,F as applyTaskMutation,he as buildAssignmentResult,ge as buildTextResult,_e as buildToolResult,z as countTasks,s as deriveBlocks,B as deriveTaskProjection,c as detectCycle,n as emptyDocument,ve as formatAssignmentResults,ye as formatContent,I as formatUpsertFailure,be as formatUpsertFailureText,ie as getDelegationTimeoutMs,ae as getMaxTasks,oe as getMaxWidgetLines,se as getStoreTtlMs,V as groupTasks,H as hasActiveWork,we as hasStorePathOverride,l as isBlocked,L as isCommittingOp,r as isDelegationActive,u as isTaskListComplete,Te as lockPathFor,ce as parsePiTaskConfig,o as reconcileOrphanedDelegations,Se as registerTaskTool,Ee as removeLegacyStoreDirectory,De as removeLegacyStoreDirectoryAsync,le as resolveCollapseKey,Oe as resolveLegacyStoreDirectory,ke as resolveLegacyStoreDirectoryAsync,Ae as resolveSessionKey,je as resolveStorePath,U as selectOverlayLayout,W as selectOverlayLayoutFromProjection,G as shouldShowIds,R as singleItemOutcome,Me as sweepStoreFiles,Ne as sweepStoreFilesAsync,M as taskActionAcceptsField,Ie as taskExtension,Pe as tempPathFor,d as unresolvedBlockers,K as visibleTasks};
|