@astralyn/pi 0.82.5 → 0.82.7
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/CHANGELOG.md +55 -0
- package/README.md +1 -1
- package/dist/cli/project-trust.d.ts.map +1 -1
- package/dist/cli/project-trust.js +4 -1
- package/dist/cli/project-trust.js.map +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js +11 -13
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +4 -22
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/types.d.ts +32 -5
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +2 -2
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/tools/bash.d.ts +1 -5
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +16 -41
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +42 -11
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +6 -7
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +17 -8
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +3 -3
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +3 -13
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +6 -36
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +4 -4
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +7 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +11 -0
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +2 -3
- package/dist/core/tools/write.js.map +1 -1
- package/dist/extensions/deepwiki/render.d.ts.map +1 -1
- package/dist/extensions/deepwiki/render.js +34 -22
- package/dist/extensions/deepwiki/render.js.map +1 -1
- package/dist/extensions/plan/constants.d.ts +43 -6
- package/dist/extensions/plan/constants.d.ts.map +1 -1
- package/dist/extensions/plan/constants.js +51 -8
- package/dist/extensions/plan/constants.js.map +1 -1
- package/dist/extensions/plan/index.d.ts +12 -3
- package/dist/extensions/plan/index.d.ts.map +1 -1
- package/dist/extensions/plan/index.js +173 -35
- package/dist/extensions/plan/index.js.map +1 -1
- package/dist/extensions/plan/schema.d.ts +5 -0
- package/dist/extensions/plan/schema.d.ts.map +1 -1
- package/dist/extensions/plan/schema.js.map +1 -1
- package/dist/extensions/plan/state.d.ts +11 -2
- package/dist/extensions/plan/state.d.ts.map +1 -1
- package/dist/extensions/plan/state.js +31 -9
- package/dist/extensions/plan/state.js.map +1 -1
- package/dist/extensions/plan/storage.d.ts +11 -3
- package/dist/extensions/plan/storage.d.ts.map +1 -1
- package/dist/extensions/plan/storage.js +45 -20
- package/dist/extensions/plan/storage.js.map +1 -1
- package/dist/extensions/plan/view.d.ts +44 -0
- package/dist/extensions/plan/view.d.ts.map +1 -0
- package/dist/extensions/plan/view.js +149 -0
- package/dist/extensions/plan/view.js.map +1 -0
- package/dist/extensions/question/dialog.d.ts.map +1 -1
- package/dist/extensions/question/dialog.js +29 -10
- package/dist/extensions/question/dialog.js.map +1 -1
- package/dist/extensions/question/index.d.ts.map +1 -1
- package/dist/extensions/question/index.js +7 -2
- package/dist/extensions/question/index.js.map +1 -1
- package/dist/extensions/question/render.d.ts +4 -8
- package/dist/extensions/question/render.d.ts.map +1 -1
- package/dist/extensions/question/render.js +202 -29
- package/dist/extensions/question/render.js.map +1 -1
- package/dist/extensions/question/results.d.ts.map +1 -1
- package/dist/extensions/question/results.js +1 -0
- package/dist/extensions/question/results.js.map +1 -1
- package/dist/extensions/question/schema.d.ts.map +1 -1
- package/dist/extensions/question/schema.js +2 -2
- package/dist/extensions/question/schema.js.map +1 -1
- package/dist/extensions/question/types.d.ts +1 -0
- package/dist/extensions/question/types.d.ts.map +1 -1
- package/dist/extensions/question/types.js +1 -1
- package/dist/extensions/question/types.js.map +1 -1
- package/dist/extensions/router/stream.d.ts +1 -0
- package/dist/extensions/router/stream.d.ts.map +1 -1
- package/dist/extensions/router/stream.js +75 -0
- package/dist/extensions/router/stream.js.map +1 -1
- package/dist/extensions/subagent/activity.d.ts.map +1 -1
- package/dist/extensions/subagent/activity.js +25 -4
- package/dist/extensions/subagent/activity.js.map +1 -1
- package/dist/extensions/subagent/constants.d.ts +1 -0
- package/dist/extensions/subagent/constants.d.ts.map +1 -1
- package/dist/extensions/subagent/constants.js +1 -0
- package/dist/extensions/subagent/constants.js.map +1 -1
- package/dist/extensions/subagent/index.d.ts.map +1 -1
- package/dist/extensions/subagent/index.js +16 -0
- package/dist/extensions/subagent/index.js.map +1 -1
- package/dist/extensions/subagent/render.d.ts.map +1 -1
- package/dist/extensions/subagent/render.js +352 -152
- package/dist/extensions/subagent/render.js.map +1 -1
- package/dist/extensions/subagent/resolve.d.ts.map +1 -1
- package/dist/extensions/subagent/resolve.js +13 -9
- package/dist/extensions/subagent/resolve.js.map +1 -1
- package/dist/extensions/subagent/retry.d.ts +17 -0
- package/dist/extensions/subagent/retry.d.ts.map +1 -0
- package/dist/extensions/subagent/retry.js +41 -0
- package/dist/extensions/subagent/retry.js.map +1 -0
- package/dist/extensions/subagent/runner.d.ts.map +1 -1
- package/dist/extensions/subagent/runner.js +37 -7
- package/dist/extensions/subagent/runner.js.map +1 -1
- package/dist/extensions/subagent/schema.d.ts.map +1 -1
- package/dist/extensions/subagent/schema.js +2 -2
- package/dist/extensions/subagent/schema.js.map +1 -1
- package/dist/extensions/subagent/sdk-runner.d.ts +6 -0
- package/dist/extensions/subagent/sdk-runner.d.ts.map +1 -1
- package/dist/extensions/subagent/sdk-runner.js +46 -24
- package/dist/extensions/subagent/sdk-runner.js.map +1 -1
- package/dist/extensions/subagent/types.d.ts +7 -0
- package/dist/extensions/subagent/types.d.ts.map +1 -1
- package/dist/extensions/subagent/types.js.map +1 -1
- package/dist/extensions/todo/constants.d.ts +17 -6
- package/dist/extensions/todo/constants.d.ts.map +1 -1
- package/dist/extensions/todo/constants.js +22 -9
- package/dist/extensions/todo/constants.js.map +1 -1
- package/dist/extensions/todo/index.d.ts +0 -14
- package/dist/extensions/todo/index.d.ts.map +1 -1
- package/dist/extensions/todo/index.js +13 -1
- package/dist/extensions/todo/index.js.map +1 -1
- package/dist/extensions/todo/schema.d.ts +53 -2
- package/dist/extensions/todo/schema.d.ts.map +1 -1
- package/dist/extensions/todo/schema.js +57 -8
- package/dist/extensions/todo/schema.js.map +1 -1
- package/dist/extensions/todo/state.d.ts +16 -5
- package/dist/extensions/todo/state.d.ts.map +1 -1
- package/dist/extensions/todo/state.js +874 -130
- package/dist/extensions/todo/state.js.map +1 -1
- package/dist/extensions/todo/view.d.ts +16 -1
- package/dist/extensions/todo/view.d.ts.map +1 -1
- package/dist/extensions/todo/view.js +428 -1
- package/dist/extensions/todo/view.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +2 -1
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/armin.d.ts.map +1 -1
- package/dist/modes/interactive/components/armin.js +5 -0
- package/dist/modes/interactive/components/armin.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +4 -2
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.d.ts +13 -6
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -1
- package/dist/modes/interactive/components/countdown-timer.js +54 -17
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +6 -1
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +23 -11
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts +11 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js +56 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +3 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +52 -2
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +10 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +139 -18
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-group.d.ts +1 -0
- package/dist/modes/interactive/components/tool-group.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-group.js +5 -0
- package/dist/modes/interactive/components/tool-group.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts +10 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +55 -2
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +5 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +79 -19
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +3 -2
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +8 -1
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/utils/paths.d.ts +6 -0
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +8 -0
- package/dist/utils/paths.js.map +1 -1
- package/docs/bundled/README.md +1 -0
- package/docs/bundled/extensions/deepwiki.md +1 -1
- package/docs/bundled/extensions/plan.md +13 -10
- package/docs/bundled/extensions/question.md +7 -5
- package/docs/bundled/extensions/router.md +3 -4
- package/docs/bundled/extensions/statusline.md +0 -1
- package/docs/bundled/extensions/subagent.md +5 -4
- package/docs/bundled/extensions/todo.md +9 -7
- package/docs/bundled/tool-presentation.md +17 -16
- package/docs/extensions.md +34 -5
- package/docs/rpc.md +1 -1
- package/docs/usage.md +1 -1
- package/npm-shrinkwrap.json +6 -6
- package/package.json +1 -1
- package/dist/utils/output-decoder.d.ts +0 -52
- package/dist/utils/output-decoder.d.ts.map +0 -1
- package/dist/utils/output-decoder.js +0 -134
- package/dist/utils/output-decoder.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-runner.js","sourceRoot":"","sources":["../../../src/extensions/subagent/sdk-runner.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EACN,eAAe,EACf,QAAQ,EACR,cAAc,EACd,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,aAAa,EACb,WAAW,GACX,MAAM,eAAe,CAAC;AACv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AAW,EAAE,EAAE,CAAC;QAChB,OAAO,EAAE,OAAO,EAAE,CAAC;QACnB,GAAG,CAAC,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QACxD,GAAG,CAAC,WAAW,GAAG,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC;QAClE,IAAI,GAAG,CAAC,KAAK;YAAE,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;QAClE,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACzB,UAAU,EAAE,EAAE,CAAC;IAChB,CAAC;IACD,OAAO,GAAG,CAAC;AAAA,CACX","sourcesContent":["import type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { AgentSessionEvent } from \"../../core/agent-session.ts\";\nimport type { ModelRuntime } from \"../../core/model-runtime.ts\";\nimport { DefaultResourceLoader } from \"../../core/resource-loader.ts\";\nimport { createAgentSession } from \"../../core/sdk.ts\";\nimport { SessionManager } from \"../../core/session-manager.ts\";\nimport { SettingsManager } from \"../../core/settings-manager.ts\";\nimport {\n\tactivitySummary,\n\taddUsage,\n\tappendActivity,\n\tassistantText,\n\tboundText,\n\tfinalAssistantText,\n\tresultSummary,\n\tsetLiveText,\n} from \"./activity.ts\";\nimport { ERROR_TEXT_LIMIT, LIVE_TEXT_LIMIT, SINGLE_OUTPUT_LIMIT } from \"./constants.ts\";\nimport type { ResolvedSubagentTask, SubagentRunDetails, ToolActivity } from \"./types.ts\";\n\nexport interface SdkRunnerOptions {\n\ttask: ResolvedSubagentTask;\n\trun: SubagentRunDetails;\n\tmodelRuntime: ModelRuntime;\n\tagentDir: string;\n\tprojectTrusted: boolean;\n\tsignal?: AbortSignal;\n\tonProgress?: () => void;\n\tregisterAbort?: (abort: () => Promise<void>) => () => void;\n}\n\nfunction workerSystemPrompt(base: string | undefined, task: ResolvedSubagentTask): string {\n\treturn [\n\t\tbase,\n\t\t`You are Pi subagent \"${task.agent.name}\", working independently on one delegated task.`,\n\t\t\"You cannot see the parent conversation; rely entirely on the task briefing and repository context available in your working directory.\",\n\t\t\"Only your final message is returned to the caller; nothing you write in earlier turns is visible to anyone.\",\n\t\t\"Complete the task fully—do not gold-plate it, but do not leave it half-done.\",\n\t\t\"Stay inside the assigned working directory and delegated scope.\",\n\t\t\"Do not ask the end user questions. If blocked, report the exact blocker and what would resolve it.\",\n\t\t\"Do not spawn subagents or invoke tools outside the configured tool list.\",\n\t\t\"When referencing files in the final report, use absolute paths so the caller can locate them unambiguously.\",\n\t\t\"Include code snippets only when the exact text is load-bearing (a bug you found, a signature the caller asked for); do not recap code you merely read.\",\n\t\t\"End with a concise report covering findings or changes, verification performed, blockers, and unresolved risks. The caller will relay it to the user, so include only the essentials.\",\n\t\ttask.agent.systemPrompt,\n\t]\n\t\t.filter((part): part is string => Boolean(part?.trim()))\n\t\t.join(\"\\n\\n\");\n}\n\nfunction lastAssistantMessage(session: { messages: readonly AgentMessage[] }) {\n\tfor (let index = session.messages.length - 1; index >= 0; index--) {\n\t\tconst message = session.messages[index];\n\t\tif (message?.role === \"assistant\") return message;\n\t}\n\treturn undefined;\n}\n\nfunction assistantError(message: ReturnType<typeof lastAssistantMessage>): string | undefined {\n\tif (!message || message.role !== \"assistant\") return undefined;\n\treturn message.errorMessage;\n}\n\ninterface ThrottledEmitter {\n\temit: () => void;\n\t/** Drops any pending timer so nothing fires after the run has settled. */\n\tcancel: () => void;\n}\n\nfunction createThrottledEmitter(onProgress: (() => void) | undefined): ThrottledEmitter {\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\treturn {\n\t\temit: () => {\n\t\t\tif (!onProgress || timer) return;\n\t\t\ttimer = setTimeout(() => {\n\t\t\t\ttimer = undefined;\n\t\t\t\tonProgress();\n\t\t\t}, 80);\n\t\t},\n\t\tcancel: () => {\n\t\t\tif (timer) clearTimeout(timer);\n\t\t\ttimer = undefined;\n\t\t},\n\t};\n}\n\nexport async function runSdkTask(options: SdkRunnerOptions): Promise<SubagentRunDetails> {\n\tconst { task, run, modelRuntime, agentDir, projectTrusted, signal, onProgress } = options;\n\tconst throttled = createThrottledEmitter(onProgress);\n\tlet unsubscribe: (() => void) | undefined;\n\tlet unregisterAbort: (() => void) | undefined;\n\tlet session: Awaited<ReturnType<typeof createAgentSession>>[\"session\"] | undefined;\n\tconst activeActivities = new Map<string, ToolActivity>();\n\tconst seenAssistantMessages = new Set<unknown>();\n\tconst markAbort = async (): Promise<void> => {\n\t\trun.status = \"aborted\";\n\t\tif (session) await session.abort();\n\t};\n\n\ttry {\n\t\tif (signal?.aborted) {\n\t\t\trun.status = \"aborted\";\n\t\t\trun.error = \"Subagent was aborted before it started.\";\n\t\t\treturn run;\n\t\t}\n\n\t\trun.status = \"running\";\n\t\trun.startedAt = Date.now();\n\t\tonProgress?.();\n\t\tconst settingsManager = SettingsManager.create(task.cwd, agentDir, { projectTrusted });\n\t\tconst resourceLoader = new DefaultResourceLoader({\n\t\t\tcwd: task.cwd,\n\t\t\tagentDir,\n\t\t\tsettingsManager,\n\t\t\tnoExtensions: true,\n\t\t\tnoSkills: true,\n\t\t\tnoPromptTemplates: true,\n\t\t\tnoThemes: true,\n\t\t\t// Read-only explorers skip AGENTS.md/CLAUDE.md: they don't need\n\t\t\t// commit/PR/style rules, and the parent interprets their results.\n\t\t\tnoContextFiles: task.agent.omitContextFiles ?? false,\n\t\t\tsystemPromptOverride: (base) => workerSystemPrompt(base, task),\n\t\t});\n\t\tawait resourceLoader.reload();\n\t\tconst created = await createAgentSession({\n\t\t\tcwd: task.cwd,\n\t\t\tagentDir,\n\t\t\tmodelRuntime,\n\t\t\tmodel: task.model,\n\t\t\tthinkingLevel: task.thinking,\n\t\t\ttools: task.agent.tools,\n\t\t\tresourceLoader,\n\t\t\tsessionManager: SessionManager.inMemory(task.cwd),\n\t\t\tsettingsManager,\n\t\t});\n\t\tsession = created.session;\n\t\tconst emitImmediate = () => onProgress?.();\n\t\tconst emitText = throttled.emit;\n\t\tunsubscribe = session.subscribe((event: AgentSessionEvent) => {\n\t\t\tif (event.type === \"auto_retry_start\") {\n\t\t\t\t// Session-level auto-retry backoff: without this the UI shows a\n\t\t\t\t// stale \"Thinking…\" for the whole retry window.\n\t\t\t\tconst seconds = Math.max(1, Math.round(event.delayMs / 1000));\n\t\t\t\trun.currentActivity = `Retrying (${event.attempt}/${event.maxAttempts}) in ${seconds}s — ${boundText(\n\t\t\t\t\tevent.errorMessage.replace(/\\s+/gu, \" \").trim(),\n\t\t\t\t\t160,\n\t\t\t\t)}`;\n\t\t\t\temitImmediate();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (event.type === \"auto_retry_end\") {\n\t\t\t\trun.currentActivity = event.success ? undefined : run.currentActivity;\n\t\t\t\temitImmediate();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (event.type === \"turn_end\") {\n\t\t\t\trun.usage.turns++;\n\t\t\t\trun.currentActivity = undefined;\n\t\t\t\temitImmediate();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (event.type === \"message_end\" && event.message.role === \"assistant\") {\n\t\t\t\tif (!seenAssistantMessages.has(event.message)) {\n\t\t\t\t\tseenAssistantMessages.add(event.message);\n\t\t\t\t\taddUsage(run.usage, event.message.usage);\n\t\t\t\t}\n\t\t\t\trun.liveText = setLiveText(assistantText(event.message));\n\t\t\t\temitText();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (event.type === \"message_update\") {\n\t\t\t\tif (event.message.role === \"assistant\") run.liveText = setLiveText(assistantText(event.message));\n\t\t\t\tif (event.assistantMessageEvent.type === \"thinking_delta\") run.currentActivity = \"Thinking…\";\n\t\t\t\tif (event.assistantMessageEvent.type === \"text_delta\") run.currentActivity = \"Writing response…\";\n\t\t\t\temitText();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (event.type === \"tool_execution_start\") {\n\t\t\t\trun.usage.toolUses++;\n\t\t\t\tconst activity: ToolActivity = {\n\t\t\t\t\tid: event.toolCallId,\n\t\t\t\t\ttoolName: event.toolName,\n\t\t\t\t\tsummary: activitySummary(event.toolName, event.args),\n\t\t\t\t\tstatus: \"running\",\n\t\t\t\t\tstartedAt: Date.now(),\n\t\t\t\t};\n\t\t\t\tactiveActivities.set(event.toolCallId, activity);\n\t\t\t\tappendActivity(run.activities, activity);\n\t\t\t\trun.currentActivity = activity.summary;\n\t\t\t\temitImmediate();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (event.type === \"tool_execution_update\") {\n\t\t\t\trun.currentActivity = activitySummary(event.toolName, event.args);\n\t\t\t\temitText();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (event.type === \"tool_execution_end\") {\n\t\t\t\tconst activity = activeActivities.get(event.toolCallId);\n\t\t\t\tif (activity) {\n\t\t\t\t\tactivity.status = event.isError ? \"failed\" : \"succeeded\";\n\t\t\t\t\tactivity.endedAt = Date.now();\n\t\t\t\t\tactivity.resultSummary = resultSummary(event.result);\n\t\t\t\t}\n\t\t\t\trun.currentActivity = undefined;\n\t\t\t\temitImmediate();\n\t\t\t}\n\t\t});\n\t\tconst abortListener = () => {\n\t\t\tvoid markAbort().catch(() => undefined);\n\t\t};\n\t\tunregisterAbort = options.registerAbort?.(markAbort);\n\t\tif (signal) signal.addEventListener(\"abort\", abortListener, { once: true });\n\t\ttry {\n\t\t\tawait session.prompt(task.prompt);\n\t\t} finally {\n\t\t\tif (signal) signal.removeEventListener(\"abort\", abortListener);\n\t\t}\n\t\tconst finalMessage = lastAssistantMessage(session);\n\t\trun.finalOutput = finalAssistantText(session.messages);\n\t\tconst error = assistantError(finalMessage);\n\t\tif (signal?.aborted || finalMessage?.stopReason === \"aborted\") {\n\t\t\trun.status = \"aborted\";\n\t\t\trun.error = boundText(error ?? \"Subagent was aborted.\", ERROR_TEXT_LIMIT);\n\t\t} else if (finalMessage?.stopReason === \"error\" || error) {\n\t\t\trun.status = \"failed\";\n\t\t\trun.error = boundText(error ?? \"Subagent failed.\", ERROR_TEXT_LIMIT);\n\t\t} else {\n\t\t\trun.status = \"completed\";\n\t\t}\n\t} catch (error) {\n\t\tif (signal?.aborted || run.status === \"aborted\") {\n\t\t\trun.status = \"aborted\";\n\t\t\trun.error = run.error ?? \"Subagent was aborted.\";\n\t\t} else {\n\t\t\trun.status = \"failed\";\n\t\t\trun.error = boundText(error instanceof Error ? error.message : String(error), ERROR_TEXT_LIMIT);\n\t\t}\n\t\tif (session) run.finalOutput = finalAssistantText(session.messages);\n\t} finally {\n\t\tthrottled.cancel();\n\t\tunregisterAbort?.();\n\t\tunsubscribe?.();\n\t\tsession?.dispose();\n\t\trun.liveText = boundText(run.liveText, LIVE_TEXT_LIMIT);\n\t\trun.finalOutput = boundText(run.finalOutput, SINGLE_OUTPUT_LIMIT);\n\t\tif (run.error) run.error = boundText(run.error, ERROR_TEXT_LIMIT);\n\t\trun.endedAt = Date.now();\n\t\tonProgress?.();\n\t}\n\treturn run;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sdk-runner.js","sourceRoot":"","sources":["../../../src/extensions/subagent/sdk-runner.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EACN,eAAe,EACf,QAAQ,EACR,cAAc,EACd,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,aAAa,EACb,WAAW,GACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACxF,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAcpE,SAAS,kBAAkB,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AM,CAAC;YACP,GAAG,CAAC,MAAM,GAAG,QAAQ,CAAC;YACtB,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAC,CAAC;QACjG,CAAC;QACD,IAAI,OAAO;YAAE,GAAG,CAAC,WAAW,GAAG,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACrE,CAAC;YAAS,CAAC;QACV,IAAI,MAAM;YAAE,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAC/D,SAAS,CAAC,MAAM,EAAE,CAAC;QACnB,eAAe,EAAE,EAAE,CAAC;QACpB,WAAW,EAAE,EAAE,CAAC;QAChB,OAAO,EAAE,OAAO,EAAE,CAAC;QACnB,GAAG,CAAC,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QACxD,GAAG,CAAC,WAAW,GAAG,SAAS,CAAC,GAAG,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC;QAClE,IAAI,GAAG,CAAC,KAAK;YAAE,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;QAClE,kBAAkB,CAAC,GAAG,CAAC,CAAC;QACxB,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACzB,UAAU,EAAE,EAAE,CAAC;IAChB,CAAC;IACD,OAAO,GAAG,CAAC;AAAA,CACX","sourcesContent":["import type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { AgentSessionEvent } from \"../../core/agent-session.ts\";\nimport type { ModelRuntime } from \"../../core/model-runtime.ts\";\nimport { DefaultResourceLoader } from \"../../core/resource-loader.ts\";\nimport { createAgentSession } from \"../../core/sdk.ts\";\nimport { SessionManager } from \"../../core/session-manager.ts\";\nimport { SettingsManager } from \"../../core/settings-manager.ts\";\nimport {\n\tactivitySummary,\n\taddUsage,\n\tappendActivity,\n\tassistantText,\n\tboundText,\n\tfinalAssistantText,\n\tresultSummary,\n\tsetLiveText,\n} from \"./activity.ts\";\nimport { ERROR_TEXT_LIMIT, LIVE_TEXT_LIMIT, SINGLE_OUTPUT_LIMIT } from \"./constants.ts\";\nimport { beginSubagentRetry, clearSubagentRetry } from \"./retry.ts\";\nimport type { ResolvedSubagentTask, SubagentRunDetails, ToolActivity } from \"./types.ts\";\n\nexport interface SdkRunnerOptions {\n\ttask: ResolvedSubagentTask;\n\trun: SubagentRunDetails;\n\tmodelRuntime: ModelRuntime;\n\tagentDir: string;\n\tprojectTrusted: boolean;\n\tsignal?: AbortSignal;\n\tonProgress?: () => void;\n\tregisterAbort?: (abort: () => Promise<void>) => () => void;\n}\n\nfunction workerSystemPrompt(base: string | undefined, task: ResolvedSubagentTask): string {\n\treturn [\n\t\tbase,\n\t\t`You are Pi subagent \"${task.agent.name}\", working independently on one delegated task.`,\n\t\t\"You cannot see the parent conversation; rely entirely on the task briefing and repository context available in your working directory.\",\n\t\t\"Only your final message is returned to the caller; nothing you write in earlier turns is visible to anyone.\",\n\t\t\"Complete the task fully—do not gold-plate it, but do not leave it half-done.\",\n\t\t\"Stay inside the assigned working directory and delegated scope.\",\n\t\t\"Do not ask the end user questions. If blocked, report the exact blocker and what would resolve it.\",\n\t\t\"Do not spawn subagents or invoke tools outside the configured tool list.\",\n\t\t\"When referencing files in the final report, use absolute paths so the caller can locate them unambiguously.\",\n\t\t\"Include code snippets only when the exact text is load-bearing (a bug you found, a signature the caller asked for); do not recap code you merely read.\",\n\t\t\"End with a concise report covering findings or changes, verification performed, blockers, and unresolved risks. The caller will relay it to the user, so include only the essentials.\",\n\t\ttask.agent.systemPrompt,\n\t]\n\t\t.filter((part): part is string => Boolean(part?.trim()))\n\t\t.join(\"\\n\\n\");\n}\n\nfunction lastAssistantMessage(session: { messages: readonly AgentMessage[] }) {\n\tfor (let index = session.messages.length - 1; index >= 0; index--) {\n\t\tconst message = session.messages[index];\n\t\tif (message?.role === \"assistant\") return message;\n\t}\n\treturn undefined;\n}\n\nfunction assistantError(message: ReturnType<typeof lastAssistantMessage>): string | undefined {\n\tif (!message || message.role !== \"assistant\") return undefined;\n\treturn message.errorMessage;\n}\n\ninterface ThrottledEmitter {\n\temit: () => void;\n\t/** Drops any pending timer so nothing fires after the run has settled. */\n\tcancel: () => void;\n}\n\nfunction createThrottledEmitter(onProgress: (() => void) | undefined): ThrottledEmitter {\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\treturn {\n\t\temit: () => {\n\t\t\tif (!onProgress || timer) return;\n\t\t\ttimer = setTimeout(() => {\n\t\t\t\ttimer = undefined;\n\t\t\t\tonProgress();\n\t\t\t}, 80);\n\t\t},\n\t\tcancel: () => {\n\t\t\tif (timer) clearTimeout(timer);\n\t\t\ttimer = undefined;\n\t\t},\n\t};\n}\n\ntype AutoRetryEvent = Extract<AgentSessionEvent, { type: \"auto_retry_start\" | \"auto_retry_end\" }>;\n\nexport function applySubagentAutoRetryEvent(run: SubagentRunDetails, event: AutoRetryEvent): void {\n\tif (event.type === \"auto_retry_start\") {\n\t\tbeginSubagentRetry(run, {\n\t\t\tattempt: event.attempt,\n\t\t\tmaxAttempts: event.maxAttempts,\n\t\t\tdelayMs: event.delayMs,\n\t\t\terror: event.errorMessage,\n\t\t});\n\t\treturn;\n\t}\n\tclearSubagentRetry(run);\n}\n\nexport async function runSdkTask(options: SdkRunnerOptions): Promise<SubagentRunDetails> {\n\tconst { task, run, modelRuntime, agentDir, projectTrusted, signal, onProgress } = options;\n\tconst throttled = createThrottledEmitter(onProgress);\n\tlet unsubscribe: (() => void) | undefined;\n\tlet unregisterAbort: (() => void) | undefined;\n\tlet session: Awaited<ReturnType<typeof createAgentSession>>[\"session\"] | undefined;\n\tconst activeActivities = new Map<string, ToolActivity>();\n\tconst seenAssistantMessages = new Set<unknown>();\n\tconst markAbort = async (): Promise<void> => {\n\t\tclearSubagentRetry(run);\n\t\trun.status = \"aborted\";\n\t\trun.error ??= \"Subagent was aborted.\";\n\t\tif (session) await session.abort();\n\t};\n\tconst isAborted = (): boolean => signal?.aborted === true || run.status === \"aborted\";\n\tconst abortListener = () => {\n\t\tvoid markAbort().catch(() => undefined);\n\t};\n\tunregisterAbort = options.registerAbort?.(markAbort);\n\tif (signal) signal.addEventListener(\"abort\", abortListener, { once: true });\n\n\ttry {\n\t\tif (isAborted()) {\n\t\t\tclearSubagentRetry(run);\n\t\t\trun.status = \"aborted\";\n\t\t\trun.error = \"Subagent was aborted before it started.\";\n\t\t\treturn run;\n\t\t}\n\n\t\tclearSubagentRetry(run);\n\t\trun.status = \"running\";\n\t\trun.startedAt = Date.now();\n\t\tonProgress?.();\n\t\tconst settingsManager = SettingsManager.create(task.cwd, agentDir, { projectTrusted });\n\t\tconst resourceLoader = new DefaultResourceLoader({\n\t\t\tcwd: task.cwd,\n\t\t\tagentDir,\n\t\t\tsettingsManager,\n\t\t\tnoExtensions: true,\n\t\t\tnoSkills: true,\n\t\t\tnoPromptTemplates: true,\n\t\t\tnoThemes: true,\n\t\t\t// Read-only explorers skip AGENTS.md/CLAUDE.md: they don't need\n\t\t\t// commit/PR/style rules, and the parent interprets their results.\n\t\t\tnoContextFiles: task.agent.omitContextFiles ?? false,\n\t\t\tsystemPromptOverride: (base) => workerSystemPrompt(base, task),\n\t\t});\n\t\tawait resourceLoader.reload();\n\t\tif (isAborted()) {\n\t\t\trun.error ??= \"Subagent was aborted during initialization.\";\n\t\t\treturn run;\n\t\t}\n\t\tconst created = await createAgentSession({\n\t\t\tcwd: task.cwd,\n\t\t\tagentDir,\n\t\t\tmodelRuntime,\n\t\t\tmodel: task.model,\n\t\t\tthinkingLevel: task.thinking,\n\t\t\ttools: task.agent.tools,\n\t\t\tresourceLoader,\n\t\t\tsessionManager: SessionManager.inMemory(task.cwd),\n\t\t\tsettingsManager,\n\t\t});\n\t\tsession = created.session;\n\t\tif (isAborted()) {\n\t\t\trun.error ??= \"Subagent was aborted during initialization.\";\n\t\t\tawait session.abort();\n\t\t\treturn run;\n\t\t}\n\t\tconst emitImmediate = () => onProgress?.();\n\t\tconst emitText = throttled.emit;\n\t\tunsubscribe = session.subscribe((event: AgentSessionEvent) => {\n\t\t\tif (event.type === \"auto_retry_start\" || event.type === \"auto_retry_end\") {\n\t\t\t\tapplySubagentAutoRetryEvent(run, event);\n\t\t\t\temitImmediate();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (event.type === \"turn_end\") {\n\t\t\t\tclearSubagentRetry(run);\n\t\t\t\trun.usage.turns++;\n\t\t\t\trun.currentActivity = undefined;\n\t\t\t\temitImmediate();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (event.type === \"message_end\" && event.message.role === \"assistant\") {\n\t\t\t\tclearSubagentRetry(run);\n\t\t\t\tif (!seenAssistantMessages.has(event.message)) {\n\t\t\t\t\tseenAssistantMessages.add(event.message);\n\t\t\t\t\taddUsage(run.usage, event.message.usage);\n\t\t\t\t}\n\t\t\t\trun.liveText = setLiveText(assistantText(event.message));\n\t\t\t\temitText();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (event.type === \"message_update\") {\n\t\t\t\tclearSubagentRetry(run);\n\t\t\t\tif (event.message.role === \"assistant\") run.liveText = setLiveText(assistantText(event.message));\n\t\t\t\tif (event.assistantMessageEvent.type === \"thinking_delta\") run.currentActivity = \"Thinking…\";\n\t\t\t\tif (event.assistantMessageEvent.type === \"text_delta\") run.currentActivity = \"Writing response…\";\n\t\t\t\temitText();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (event.type === \"tool_execution_start\") {\n\t\t\t\tclearSubagentRetry(run);\n\t\t\t\trun.usage.toolUses++;\n\t\t\t\tconst activity: ToolActivity = {\n\t\t\t\t\tid: event.toolCallId,\n\t\t\t\t\ttoolName: event.toolName,\n\t\t\t\t\tsummary: activitySummary(event.toolName, event.args),\n\t\t\t\t\tstatus: \"running\",\n\t\t\t\t\tstartedAt: Date.now(),\n\t\t\t\t};\n\t\t\t\tactiveActivities.set(event.toolCallId, activity);\n\t\t\t\tappendActivity(run.activities, activity);\n\t\t\t\trun.currentActivity = activity.summary;\n\t\t\t\temitImmediate();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (event.type === \"tool_execution_update\") {\n\t\t\t\tclearSubagentRetry(run);\n\t\t\t\trun.currentActivity = activitySummary(event.toolName, event.args);\n\t\t\t\temitText();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (event.type === \"tool_execution_end\") {\n\t\t\t\tclearSubagentRetry(run);\n\t\t\t\tconst activity = activeActivities.get(event.toolCallId);\n\t\t\t\tif (activity) {\n\t\t\t\t\tactivity.status = event.isError ? \"failed\" : \"succeeded\";\n\t\t\t\t\tactivity.endedAt = Date.now();\n\t\t\t\t\tactivity.resultSummary = resultSummary(event.result);\n\t\t\t\t}\n\t\t\t\trun.currentActivity = undefined;\n\t\t\t\temitImmediate();\n\t\t\t}\n\t\t});\n\t\tawait session.prompt(task.prompt);\n\t\tconst finalMessage = lastAssistantMessage(session);\n\t\trun.finalOutput = finalAssistantText(session.messages);\n\t\tconst error = assistantError(finalMessage);\n\t\tif (signal?.aborted || finalMessage?.stopReason === \"aborted\") {\n\t\t\trun.status = \"aborted\";\n\t\t\trun.error = boundText(error ?? \"Subagent was aborted.\", ERROR_TEXT_LIMIT);\n\t\t} else if (finalMessage?.stopReason === \"error\" || error) {\n\t\t\trun.status = \"failed\";\n\t\t\trun.error = boundText(error ?? \"Subagent failed.\", ERROR_TEXT_LIMIT);\n\t\t} else {\n\t\t\trun.status = \"completed\";\n\t\t}\n\t} catch (error) {\n\t\tif (signal?.aborted || run.status === \"aborted\") {\n\t\t\trun.status = \"aborted\";\n\t\t\trun.error = run.error ?? \"Subagent was aborted.\";\n\t\t} else {\n\t\t\trun.status = \"failed\";\n\t\t\trun.error = boundText(error instanceof Error ? error.message : String(error), ERROR_TEXT_LIMIT);\n\t\t}\n\t\tif (session) run.finalOutput = finalAssistantText(session.messages);\n\t} finally {\n\t\tif (signal) signal.removeEventListener(\"abort\", abortListener);\n\t\tthrottled.cancel();\n\t\tunregisterAbort?.();\n\t\tunsubscribe?.();\n\t\tsession?.dispose();\n\t\trun.liveText = boundText(run.liveText, LIVE_TEXT_LIMIT);\n\t\trun.finalOutput = boundText(run.finalOutput, SINGLE_OUTPUT_LIMIT);\n\t\tif (run.error) run.error = boundText(run.error, ERROR_TEXT_LIMIT);\n\t\tclearSubagentRetry(run);\n\t\trun.endedAt = Date.now();\n\t\tonProgress?.();\n\t}\n\treturn run;\n}\n"]}
|
|
@@ -70,6 +70,12 @@ export interface SubagentUsage {
|
|
|
70
70
|
/** Context watermark: total tokens of the latest request, not a running sum. */
|
|
71
71
|
contextTokens?: number;
|
|
72
72
|
}
|
|
73
|
+
export interface SubagentRetryDetails {
|
|
74
|
+
attempt: number;
|
|
75
|
+
maxAttempts: number;
|
|
76
|
+
deadline: number;
|
|
77
|
+
error: string;
|
|
78
|
+
}
|
|
73
79
|
export interface SubagentRunDetails {
|
|
74
80
|
id: string;
|
|
75
81
|
agent: string;
|
|
@@ -83,6 +89,7 @@ export interface SubagentRunDetails {
|
|
|
83
89
|
startedAt?: number;
|
|
84
90
|
endedAt?: number;
|
|
85
91
|
currentActivity?: string;
|
|
92
|
+
retry?: SubagentRetryDetails;
|
|
86
93
|
activities: ToolActivity[];
|
|
87
94
|
liveText: string;
|
|
88
95
|
finalOutput: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/extensions/subagent/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE/D,MAAM,MAAM,WAAW,GAAG,SAA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MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,IAAI,EAAE,kBAAkB,EAAE,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,uBAAuB;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,eAAe,CAAC;IACzB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CACjB","sourcesContent":["import type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, Model, Usage } from \"@earendil-works/pi-ai\";\n\nexport type AgentSource = \"builtin\" | \"user\" | \"project\";\nexport type SubagentMode = \"single\" | \"parallel\";\nexport type SubagentRunStatus = \"queued\" | \"running\" | \"completed\" | \"failed\" | \"aborted\";\nexport type ToolActivityStatus = \"running\" | \"succeeded\" | \"failed\";\n\nexport interface AgentDefinition {\n\tname: string;\n\tdescription: string;\n\ttools: string[];\n\tsystemPrompt: string;\n\tsource: AgentSource;\n\tfilePath: string;\n\tbackend: \"sdk\";\n\t/**\n\t * Skip loading AGENTS.md/CLAUDE.md into the worker's system prompt.\n\t * Read-only exploration doesn't need commit/PR/style rules; the parent\n\t * has full context to interpret results. Builtin-only, not a\n\t * frontmatter field.\n\t */\n\tomitContextFiles?: boolean;\n}\n\nexport interface AgentDiagnostic {\n\tpath: string;\n\tmessage: string;\n\tsource: Exclude<AgentSource, \"builtin\">;\n}\n\nexport interface AgentDiscoveryResult {\n\tagents: AgentDefinition[];\n\tdiagnostics: AgentDiagnostic[];\n\tprojectAgentsDir?: string;\n\tprojectAgentsTrusted: boolean;\n}\n\nexport interface SubagentProfileOverride {\n\tmodel?: string;\n\tthinking?: ThinkingLevel;\n}\n\nexport interface SubagentConfigFile {\n\tversion: 1;\n\tprofiles: Record<string, SubagentProfileOverride>;\n}\n\nexport interface ResolvedSubagentTask {\n\tagent: AgentDefinition;\n\tdescription: string;\n\tprompt: string;\n\tcwd: string;\n\tmodel: Model<Api>;\n\tthinking: ThinkingLevel;\n\tmodelSource: \"profile\" | \"parent\";\n\tthinkingSource: \"profile\" | \"parent\";\n}\n\nexport interface ToolActivity {\n\tid: string;\n\ttoolName: string;\n\tsummary: string;\n\tstatus: ToolActivityStatus;\n\tstartedAt: number;\n\tendedAt?: number;\n\tresultSummary?: string;\n}\n\nexport interface SubagentUsage {\n\tturns: number;\n\ttoolUses: number;\n\tinput: number;\n\toutput: number;\n\tcacheRead: number;\n\tcacheWrite: number;\n\ttotalTokens: number;\n\tcost: number;\n\t/** Context watermark: total tokens of the latest request, not a running sum. */\n\tcontextTokens?: number;\n}\n\nexport interface SubagentRunDetails {\n\tid: string;\n\tagent: string;\n\tagentSource: AgentSource;\n\tdescription: string;\n\tprompt: string;\n\tcwd: string;\n\tmodel: string;\n\tthinking: ThinkingLevel;\n\tstatus: SubagentRunStatus;\n\tstartedAt?: number;\n\tendedAt?: number;\n\tcurrentActivity?: string;\n\tactivities: ToolActivity[];\n\tliveText: string;\n\tfinalOutput: string;\n\terror?: string;\n\tusage: SubagentUsage;\n}\n\nexport interface SubagentDetails {\n\tmode: SubagentMode;\n\tstatus: SubagentRunStatus;\n\truns: SubagentRunDetails[];\n\tstartedAt: number;\n\tendedAt?: number;\n\tusage: SubagentUsage;\n\terror?: string;\n}\n\nexport interface SubagentExecutionResult {\n\tcontent: string;\n\tdetails: SubagentDetails;\n\tusage?: Usage;\n\tisError: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/extensions/subagent/types.ts"],"names":[],"mappings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M,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,aAAa,CAAC;IACxB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,UAAU,EAAE,YAAY,EAAE,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,IAAI,EAAE,kBAAkB,EAAE,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,aAAa,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,uBAAuB;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,eAAe,CAAC;IACzB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;CACjB","sourcesContent":["import type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, Model, Usage } from \"@earendil-works/pi-ai\";\n\nexport type AgentSource = \"builtin\" | \"user\" | \"project\";\nexport type SubagentMode = \"single\" | \"parallel\";\nexport type SubagentRunStatus = \"queued\" | \"running\" | \"completed\" | \"failed\" | \"aborted\";\nexport type ToolActivityStatus = \"running\" | \"succeeded\" | \"failed\";\n\nexport interface AgentDefinition {\n\tname: string;\n\tdescription: string;\n\ttools: string[];\n\tsystemPrompt: string;\n\tsource: AgentSource;\n\tfilePath: string;\n\tbackend: \"sdk\";\n\t/**\n\t * Skip loading AGENTS.md/CLAUDE.md into the worker's system prompt.\n\t * Read-only exploration doesn't need commit/PR/style rules; the parent\n\t * has full context to interpret results. Builtin-only, not a\n\t * frontmatter field.\n\t */\n\tomitContextFiles?: boolean;\n}\n\nexport interface AgentDiagnostic {\n\tpath: string;\n\tmessage: string;\n\tsource: Exclude<AgentSource, \"builtin\">;\n}\n\nexport interface AgentDiscoveryResult {\n\tagents: AgentDefinition[];\n\tdiagnostics: AgentDiagnostic[];\n\tprojectAgentsDir?: string;\n\tprojectAgentsTrusted: boolean;\n}\n\nexport interface SubagentProfileOverride {\n\tmodel?: string;\n\tthinking?: ThinkingLevel;\n}\n\nexport interface SubagentConfigFile {\n\tversion: 1;\n\tprofiles: Record<string, SubagentProfileOverride>;\n}\n\nexport interface ResolvedSubagentTask {\n\tagent: AgentDefinition;\n\tdescription: string;\n\tprompt: string;\n\tcwd: string;\n\tmodel: Model<Api>;\n\tthinking: ThinkingLevel;\n\tmodelSource: \"profile\" | \"parent\";\n\tthinkingSource: \"profile\" | \"parent\";\n}\n\nexport interface ToolActivity {\n\tid: string;\n\ttoolName: string;\n\tsummary: string;\n\tstatus: ToolActivityStatus;\n\tstartedAt: number;\n\tendedAt?: number;\n\tresultSummary?: string;\n}\n\nexport interface SubagentUsage {\n\tturns: number;\n\ttoolUses: number;\n\tinput: number;\n\toutput: number;\n\tcacheRead: number;\n\tcacheWrite: number;\n\ttotalTokens: number;\n\tcost: number;\n\t/** Context watermark: total tokens of the latest request, not a running sum. */\n\tcontextTokens?: number;\n}\n\nexport interface SubagentRetryDetails {\n\tattempt: number;\n\tmaxAttempts: number;\n\tdeadline: number;\n\terror: string;\n}\n\nexport interface SubagentRunDetails {\n\tid: string;\n\tagent: string;\n\tagentSource: AgentSource;\n\tdescription: string;\n\tprompt: string;\n\tcwd: string;\n\tmodel: string;\n\tthinking: ThinkingLevel;\n\tstatus: SubagentRunStatus;\n\tstartedAt?: number;\n\tendedAt?: number;\n\tcurrentActivity?: string;\n\tretry?: SubagentRetryDetails;\n\tactivities: ToolActivity[];\n\tliveText: string;\n\tfinalOutput: string;\n\terror?: string;\n\tusage: SubagentUsage;\n}\n\nexport interface SubagentDetails {\n\tmode: SubagentMode;\n\tstatus: SubagentRunStatus;\n\truns: SubagentRunDetails[];\n\tstartedAt: number;\n\tendedAt?: number;\n\tusage: SubagentUsage;\n\terror?: string;\n}\n\nexport interface SubagentExecutionResult {\n\tcontent: string;\n\tdetails: SubagentDetails;\n\tusage?: Usage;\n\tisError: boolean;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/extensions/subagent/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, Model, Usage } from \"@earendil-works/pi-ai\";\n\nexport type AgentSource = \"builtin\" | \"user\" | \"project\";\nexport type SubagentMode = \"single\" | \"parallel\";\nexport type SubagentRunStatus = \"queued\" | \"running\" | \"completed\" | \"failed\" | \"aborted\";\nexport type ToolActivityStatus = \"running\" | \"succeeded\" | \"failed\";\n\nexport interface AgentDefinition {\n\tname: string;\n\tdescription: string;\n\ttools: string[];\n\tsystemPrompt: string;\n\tsource: AgentSource;\n\tfilePath: string;\n\tbackend: \"sdk\";\n\t/**\n\t * Skip loading AGENTS.md/CLAUDE.md into the worker's system prompt.\n\t * Read-only exploration doesn't need commit/PR/style rules; the parent\n\t * has full context to interpret results. Builtin-only, not a\n\t * frontmatter field.\n\t */\n\tomitContextFiles?: boolean;\n}\n\nexport interface AgentDiagnostic {\n\tpath: string;\n\tmessage: string;\n\tsource: Exclude<AgentSource, \"builtin\">;\n}\n\nexport interface AgentDiscoveryResult {\n\tagents: AgentDefinition[];\n\tdiagnostics: AgentDiagnostic[];\n\tprojectAgentsDir?: string;\n\tprojectAgentsTrusted: boolean;\n}\n\nexport interface SubagentProfileOverride {\n\tmodel?: string;\n\tthinking?: ThinkingLevel;\n}\n\nexport interface SubagentConfigFile {\n\tversion: 1;\n\tprofiles: Record<string, SubagentProfileOverride>;\n}\n\nexport interface ResolvedSubagentTask {\n\tagent: AgentDefinition;\n\tdescription: string;\n\tprompt: string;\n\tcwd: string;\n\tmodel: Model<Api>;\n\tthinking: ThinkingLevel;\n\tmodelSource: \"profile\" | \"parent\";\n\tthinkingSource: \"profile\" | \"parent\";\n}\n\nexport interface ToolActivity {\n\tid: string;\n\ttoolName: string;\n\tsummary: string;\n\tstatus: ToolActivityStatus;\n\tstartedAt: number;\n\tendedAt?: number;\n\tresultSummary?: string;\n}\n\nexport interface SubagentUsage {\n\tturns: number;\n\ttoolUses: number;\n\tinput: number;\n\toutput: number;\n\tcacheRead: number;\n\tcacheWrite: number;\n\ttotalTokens: number;\n\tcost: number;\n\t/** Context watermark: total tokens of the latest request, not a running sum. */\n\tcontextTokens?: number;\n}\n\nexport interface SubagentRunDetails {\n\tid: string;\n\tagent: string;\n\tagentSource: AgentSource;\n\tdescription: string;\n\tprompt: string;\n\tcwd: string;\n\tmodel: string;\n\tthinking: ThinkingLevel;\n\tstatus: SubagentRunStatus;\n\tstartedAt?: number;\n\tendedAt?: number;\n\tcurrentActivity?: string;\n\tactivities: ToolActivity[];\n\tliveText: string;\n\tfinalOutput: string;\n\terror?: string;\n\tusage: SubagentUsage;\n}\n\nexport interface SubagentDetails {\n\tmode: SubagentMode;\n\tstatus: SubagentRunStatus;\n\truns: SubagentRunDetails[];\n\tstartedAt: number;\n\tendedAt?: number;\n\tusage: SubagentUsage;\n\terror?: string;\n}\n\nexport interface SubagentExecutionResult {\n\tcontent: string;\n\tdetails: SubagentDetails;\n\tusage?: Usage;\n\tisError: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/extensions/subagent/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, Model, Usage } from \"@earendil-works/pi-ai\";\n\nexport type AgentSource = \"builtin\" | \"user\" | \"project\";\nexport type SubagentMode = \"single\" | \"parallel\";\nexport type SubagentRunStatus = \"queued\" | \"running\" | \"completed\" | \"failed\" | \"aborted\";\nexport type ToolActivityStatus = \"running\" | \"succeeded\" | \"failed\";\n\nexport interface AgentDefinition {\n\tname: string;\n\tdescription: string;\n\ttools: string[];\n\tsystemPrompt: string;\n\tsource: AgentSource;\n\tfilePath: string;\n\tbackend: \"sdk\";\n\t/**\n\t * Skip loading AGENTS.md/CLAUDE.md into the worker's system prompt.\n\t * Read-only exploration doesn't need commit/PR/style rules; the parent\n\t * has full context to interpret results. Builtin-only, not a\n\t * frontmatter field.\n\t */\n\tomitContextFiles?: boolean;\n}\n\nexport interface AgentDiagnostic {\n\tpath: string;\n\tmessage: string;\n\tsource: Exclude<AgentSource, \"builtin\">;\n}\n\nexport interface AgentDiscoveryResult {\n\tagents: AgentDefinition[];\n\tdiagnostics: AgentDiagnostic[];\n\tprojectAgentsDir?: string;\n\tprojectAgentsTrusted: boolean;\n}\n\nexport interface SubagentProfileOverride {\n\tmodel?: string;\n\tthinking?: ThinkingLevel;\n}\n\nexport interface SubagentConfigFile {\n\tversion: 1;\n\tprofiles: Record<string, SubagentProfileOverride>;\n}\n\nexport interface ResolvedSubagentTask {\n\tagent: AgentDefinition;\n\tdescription: string;\n\tprompt: string;\n\tcwd: string;\n\tmodel: Model<Api>;\n\tthinking: ThinkingLevel;\n\tmodelSource: \"profile\" | \"parent\";\n\tthinkingSource: \"profile\" | \"parent\";\n}\n\nexport interface ToolActivity {\n\tid: string;\n\ttoolName: string;\n\tsummary: string;\n\tstatus: ToolActivityStatus;\n\tstartedAt: number;\n\tendedAt?: number;\n\tresultSummary?: string;\n}\n\nexport interface SubagentUsage {\n\tturns: number;\n\ttoolUses: number;\n\tinput: number;\n\toutput: number;\n\tcacheRead: number;\n\tcacheWrite: number;\n\ttotalTokens: number;\n\tcost: number;\n\t/** Context watermark: total tokens of the latest request, not a running sum. */\n\tcontextTokens?: number;\n}\n\nexport interface SubagentRetryDetails {\n\tattempt: number;\n\tmaxAttempts: number;\n\tdeadline: number;\n\terror: string;\n}\n\nexport interface SubagentRunDetails {\n\tid: string;\n\tagent: string;\n\tagentSource: AgentSource;\n\tdescription: string;\n\tprompt: string;\n\tcwd: string;\n\tmodel: string;\n\tthinking: ThinkingLevel;\n\tstatus: SubagentRunStatus;\n\tstartedAt?: number;\n\tendedAt?: number;\n\tcurrentActivity?: string;\n\tretry?: SubagentRetryDetails;\n\tactivities: ToolActivity[];\n\tliveText: string;\n\tfinalOutput: string;\n\terror?: string;\n\tusage: SubagentUsage;\n}\n\nexport interface SubagentDetails {\n\tmode: SubagentMode;\n\tstatus: SubagentRunStatus;\n\truns: SubagentRunDetails[];\n\tstartedAt: number;\n\tendedAt?: number;\n\tusage: SubagentUsage;\n\terror?: string;\n}\n\nexport interface SubagentExecutionResult {\n\tcontent: string;\n\tdetails: SubagentDetails;\n\tusage?: Usage;\n\tisError: boolean;\n}\n"]}
|
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* todo/constants.ts — tool identity, command name, and prompt copy.
|
|
3
|
-
*
|
|
4
|
-
* Name/label/command live here so `index.ts` only assembles the tool, matching
|
|
5
|
-
* the question/deepwiki constants.ts pattern. Prompt copy is the model-facing
|
|
6
|
-
* contract; keep it stable.
|
|
2
|
+
* todo/constants.ts — tool identity, command name, input bounds, and prompt copy.
|
|
7
3
|
*/
|
|
8
4
|
export declare const TODO_TOOL_NAME = "todo";
|
|
9
5
|
export declare const TODO_TOOL_LABEL = "Todo";
|
|
10
6
|
export declare const TODOS_COMMAND_NAME = "todos";
|
|
11
7
|
/** Max tasks shown in a single `list` tool result body (model-facing). */
|
|
12
8
|
export declare const LIST_DISPLAY_MAX_ITEMS = 50;
|
|
13
|
-
export declare const
|
|
9
|
+
export declare const TODO_MAX_LIST_LIMIT = 50;
|
|
10
|
+
export declare const TODO_MAX_LIST_QUERY_LENGTH = 200;
|
|
11
|
+
/** Input limits keep task snapshots and model-facing output bounded. */
|
|
12
|
+
export declare const TODO_MAX_BATCH_ITEMS = 20;
|
|
13
|
+
export declare const TODO_MAX_SUBJECT_LENGTH = 240;
|
|
14
|
+
export declare const TODO_MAX_DESCRIPTION_LENGTH = 4000;
|
|
15
|
+
export declare const TODO_MAX_ACTIVE_FORM_LENGTH = 240;
|
|
16
|
+
export declare const TODO_MAX_OWNER_LENGTH = 160;
|
|
17
|
+
export declare const TODO_MAX_BATCH_KEY_LENGTH = 120;
|
|
18
|
+
export declare const TODO_MAX_BLOCKED_BY = 50;
|
|
19
|
+
/** Metadata is JSON-like, deeply copied, and bounded independently of task text. */
|
|
20
|
+
export declare const TODO_MAX_METADATA_KEY_LENGTH = 160;
|
|
21
|
+
export declare const TODO_MAX_METADATA_DEPTH = 8;
|
|
22
|
+
export declare const TODO_MAX_METADATA_ENTRIES = 100;
|
|
23
|
+
export declare const TODO_MAX_METADATA_BYTES = 16384;
|
|
24
|
+
export declare const TODO_TOOL_DESCRIPTION = "Manage the conversation's task list for multi-step coding work.\n\n## When to Use\n- Work with three or more meaningful steps, user-provided task lists, or long sessions where progress can drift\n- Capture new user requirements as tasks right away; after completing a task, add follow-up tasks discovered during implementation\n\n## When NOT to Use\n- Trivial single-step tasks and simple Q&A \u2014 just do the work\n\n## Actions\n- create: add one pending task; subject (short, imperative, reviewable scope) and description (what done means: acceptance criteria or verification detail) are required\n- create_many: atomically add up to 20 pending tasks in input order; each item needs subject and description, and optional unique keys can be linked within the batch with blockedByKeys\n- update: change status or details, and manage dependencies via addBlockedBy/removeBlockedBy (what this task waits on) and addBlocks/removeBlocks (what waits on this task); dependencies are validated and cycle-checked\n- list: one-line summaries with unresolved blockers, optionally filtered by status, paged with limit/afterId, searched with query, or narrowed with unblockedOnly; get: one task in full; delete: tombstone an obsolete task and release its dependents; clear: requires confirm=true and the exact expectedCount, without reusing ids\n- Parameters that do not apply to the chosen action are rejected with guidance\n\n## Status Workflow\npending -> in_progress -> completed; deleted is the only terminal state. Keep exactly one task in_progress (starting one demotes any other active task): mark it in_progress BEFORE starting the work, and completed only when implementation and verification are genuinely done \u2014 never with failing tests or partial work; reopen instead of duplicating. When blocked, do not fake completion: create a task for the blocker and link it with addBlockedBy.\n\n## Examples\n{\"action\": \"create\", \"subject\": \"Fix login redirect\", \"description\": \"Redirect lands on the dashboard; auth tests pass\"}\n{\"action\": \"create_many\", \"items\": [{\"key\": \"parser\", \"subject\": \"Wire parser\", \"description\": \"Parser handles config\"}, {\"subject\": \"Test parser\", \"description\": \"Parser tests pass\", \"blockedByKeys\": [\"parser\"]}]}\n{\"action\": \"update\", \"id\": 2, \"status\": \"in_progress\", \"activeForm\": \"fixing login redirect\"}\n{\"action\": \"update\", \"id\": 1, \"addBlocks\": [2, 3]}\n\n## Tips\n- list before create to avoid duplicates; prefer working in id order \u2014 earlier tasks usually set up context for later ones\n- Use dependencies only for real ordering constraints, and delete obsolete tasks promptly so their dependents are released";
|
|
14
25
|
export declare const TODO_PROMPT_SNIPPET = "Track multi-step coding work with a small outcome-oriented task list";
|
|
15
26
|
export declare const TODO_PROMPT_GUIDELINES: string[];
|
|
16
27
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/extensions/todo/constants.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/extensions/todo/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,eAAe,SAAS,CAAC;AACtC,eAAO,MAAM,kBAAkB,UAAU,CAAC;AAE1C,0EAA0E;AAC1E,eAAO,MAAM,sBAAsB,KAAK,CAAC;AACzC,eAAO,MAAM,mBAAmB,KAAyB,CAAC;AAC1D,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C,wEAAwE;AACxE,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,2BAA2B,OAAQ,CAAC;AACjD,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAC/C,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAC7C,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC,oFAAoF;AACpF,eAAO,MAAM,4BAA4B,MAAM,CAAC;AAChD,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAC7C,eAAO,MAAM,uBAAuB,QAAS,CAAC;AAE9C,eAAO,MAAM,qBAAqB,kqFA2ByF,CAAC;AAE5H,eAAO,MAAM,mBAAmB,yEAAyE,CAAC;AAE1G,eAAO,MAAM,sBAAsB,UAIlC,CAAC","sourcesContent":["/**\n * todo/constants.ts — tool identity, command name, input bounds, and prompt copy.\n */\n\nexport const TODO_TOOL_NAME = \"todo\";\nexport const TODO_TOOL_LABEL = \"Todo\";\nexport const TODOS_COMMAND_NAME = \"todos\";\n\n/** Max tasks shown in a single `list` tool result body (model-facing). */\nexport const LIST_DISPLAY_MAX_ITEMS = 50;\nexport const TODO_MAX_LIST_LIMIT = LIST_DISPLAY_MAX_ITEMS;\nexport const TODO_MAX_LIST_QUERY_LENGTH = 200;\n\n/** Input limits keep task snapshots and model-facing output bounded. */\nexport const TODO_MAX_BATCH_ITEMS = 20;\nexport const TODO_MAX_SUBJECT_LENGTH = 240;\nexport const TODO_MAX_DESCRIPTION_LENGTH = 4_000;\nexport const TODO_MAX_ACTIVE_FORM_LENGTH = 240;\nexport const TODO_MAX_OWNER_LENGTH = 160;\nexport const TODO_MAX_BATCH_KEY_LENGTH = 120;\nexport const TODO_MAX_BLOCKED_BY = 50;\n\n/** Metadata is JSON-like, deeply copied, and bounded independently of task text. */\nexport const TODO_MAX_METADATA_KEY_LENGTH = 160;\nexport const TODO_MAX_METADATA_DEPTH = 8;\nexport const TODO_MAX_METADATA_ENTRIES = 100;\nexport const TODO_MAX_METADATA_BYTES = 16_384;\n\nexport const TODO_TOOL_DESCRIPTION = `Manage the conversation's task list for multi-step coding work.\n\n## When to Use\n- Work with three or more meaningful steps, user-provided task lists, or long sessions where progress can drift\n- Capture new user requirements as tasks right away; after completing a task, add follow-up tasks discovered during implementation\n\n## When NOT to Use\n- Trivial single-step tasks and simple Q&A — just do the work\n\n## Actions\n- create: add one pending task; subject (short, imperative, reviewable scope) and description (what done means: acceptance criteria or verification detail) are required\n- create_many: atomically add up to 20 pending tasks in input order; each item needs subject and description, and optional unique keys can be linked within the batch with blockedByKeys\n- update: change status or details, and manage dependencies via addBlockedBy/removeBlockedBy (what this task waits on) and addBlocks/removeBlocks (what waits on this task); dependencies are validated and cycle-checked\n- list: one-line summaries with unresolved blockers, optionally filtered by status, paged with limit/afterId, searched with query, or narrowed with unblockedOnly; get: one task in full; delete: tombstone an obsolete task and release its dependents; clear: requires confirm=true and the exact expectedCount, without reusing ids\n- Parameters that do not apply to the chosen action are rejected with guidance\n\n## Status Workflow\npending -> in_progress -> completed; deleted is the only terminal state. Keep exactly one task in_progress (starting one demotes any other active task): mark it in_progress BEFORE starting the work, and completed only when implementation and verification are genuinely done — never with failing tests or partial work; reopen instead of duplicating. When blocked, do not fake completion: create a task for the blocker and link it with addBlockedBy.\n\n## Examples\n{\"action\": \"create\", \"subject\": \"Fix login redirect\", \"description\": \"Redirect lands on the dashboard; auth tests pass\"}\n{\"action\": \"create_many\", \"items\": [{\"key\": \"parser\", \"subject\": \"Wire parser\", \"description\": \"Parser handles config\"}, {\"subject\": \"Test parser\", \"description\": \"Parser tests pass\", \"blockedByKeys\": [\"parser\"]}]}\n{\"action\": \"update\", \"id\": 2, \"status\": \"in_progress\", \"activeForm\": \"fixing login redirect\"}\n{\"action\": \"update\", \"id\": 1, \"addBlocks\": [2, 3]}\n\n## Tips\n- list before create to avoid duplicates; prefer working in id order — earlier tasks usually set up context for later ones\n- Use dependencies only for real ordering constraints, and delete obsolete tasks promptly so their dependents are released`;\n\nexport const TODO_PROMPT_SNIPPET = \"Track multi-step coding work with a small outcome-oriented task list\";\n\nexport const TODO_PROMPT_GUIDELINES = [\n\t\"Use `todo` for work with three or more meaningful steps, user-provided task lists, or long sessions where progress can drift; list before creating to avoid duplicates, use create_many for a known batch of up to 20 tasks, and capture follow-up work discovered during implementation as new tasks.\",\n\t\"Mark the active `todo` task in_progress before starting work (exactly one at a time; the tool demotes any other active item) and completed immediately after verification — never while tests fail or work is partial; reopen instead of duplicating, and when blocked create a task for the blocker and link it with addBlockedBy.\",\n\t\"Keep the `todo` list short and outcome-oriented; prefer working in id order, use dependencies only for real prerequisites, and delete obsolete items promptly so their dependents are released. Clear only with confirm=true and the current expectedCount.\",\n];\n"]}
|
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* todo/constants.ts — tool identity, command name, and prompt copy.
|
|
3
|
-
*
|
|
4
|
-
* Name/label/command live here so `index.ts` only assembles the tool, matching
|
|
5
|
-
* the question/deepwiki constants.ts pattern. Prompt copy is the model-facing
|
|
6
|
-
* contract; keep it stable.
|
|
2
|
+
* todo/constants.ts — tool identity, command name, input bounds, and prompt copy.
|
|
7
3
|
*/
|
|
8
4
|
export const TODO_TOOL_NAME = "todo";
|
|
9
5
|
export const TODO_TOOL_LABEL = "Todo";
|
|
10
6
|
export const TODOS_COMMAND_NAME = "todos";
|
|
11
7
|
/** Max tasks shown in a single `list` tool result body (model-facing). */
|
|
12
8
|
export const LIST_DISPLAY_MAX_ITEMS = 50;
|
|
9
|
+
export const TODO_MAX_LIST_LIMIT = LIST_DISPLAY_MAX_ITEMS;
|
|
10
|
+
export const TODO_MAX_LIST_QUERY_LENGTH = 200;
|
|
11
|
+
/** Input limits keep task snapshots and model-facing output bounded. */
|
|
12
|
+
export const TODO_MAX_BATCH_ITEMS = 20;
|
|
13
|
+
export const TODO_MAX_SUBJECT_LENGTH = 240;
|
|
14
|
+
export const TODO_MAX_DESCRIPTION_LENGTH = 4_000;
|
|
15
|
+
export const TODO_MAX_ACTIVE_FORM_LENGTH = 240;
|
|
16
|
+
export const TODO_MAX_OWNER_LENGTH = 160;
|
|
17
|
+
export const TODO_MAX_BATCH_KEY_LENGTH = 120;
|
|
18
|
+
export const TODO_MAX_BLOCKED_BY = 50;
|
|
19
|
+
/** Metadata is JSON-like, deeply copied, and bounded independently of task text. */
|
|
20
|
+
export const TODO_MAX_METADATA_KEY_LENGTH = 160;
|
|
21
|
+
export const TODO_MAX_METADATA_DEPTH = 8;
|
|
22
|
+
export const TODO_MAX_METADATA_ENTRIES = 100;
|
|
23
|
+
export const TODO_MAX_METADATA_BYTES = 16_384;
|
|
13
24
|
export const TODO_TOOL_DESCRIPTION = `Manage the conversation's task list for multi-step coding work.
|
|
14
25
|
|
|
15
26
|
## When to Use
|
|
@@ -20,9 +31,10 @@ export const TODO_TOOL_DESCRIPTION = `Manage the conversation's task list for mu
|
|
|
20
31
|
- Trivial single-step tasks and simple Q&A — just do the work
|
|
21
32
|
|
|
22
33
|
## Actions
|
|
23
|
-
- create: add
|
|
34
|
+
- create: add one pending task; subject (short, imperative, reviewable scope) and description (what done means: acceptance criteria or verification detail) are required
|
|
35
|
+
- create_many: atomically add up to 20 pending tasks in input order; each item needs subject and description, and optional unique keys can be linked within the batch with blockedByKeys
|
|
24
36
|
- update: change status or details, and manage dependencies via addBlockedBy/removeBlockedBy (what this task waits on) and addBlocks/removeBlocks (what waits on this task); dependencies are validated and cycle-checked
|
|
25
|
-
- list: one-line summaries with unresolved blockers, optionally filtered by status; get: one task in full; delete: tombstone an obsolete task and release its dependents; clear:
|
|
37
|
+
- list: one-line summaries with unresolved blockers, optionally filtered by status, paged with limit/afterId, searched with query, or narrowed with unblockedOnly; get: one task in full; delete: tombstone an obsolete task and release its dependents; clear: requires confirm=true and the exact expectedCount, without reusing ids
|
|
26
38
|
- Parameters that do not apply to the chosen action are rejected with guidance
|
|
27
39
|
|
|
28
40
|
## Status Workflow
|
|
@@ -30,6 +42,7 @@ pending -> in_progress -> completed; deleted is the only terminal state. Keep ex
|
|
|
30
42
|
|
|
31
43
|
## Examples
|
|
32
44
|
{"action": "create", "subject": "Fix login redirect", "description": "Redirect lands on the dashboard; auth tests pass"}
|
|
45
|
+
{"action": "create_many", "items": [{"key": "parser", "subject": "Wire parser", "description": "Parser handles config"}, {"subject": "Test parser", "description": "Parser tests pass", "blockedByKeys": ["parser"]}]}
|
|
33
46
|
{"action": "update", "id": 2, "status": "in_progress", "activeForm": "fixing login redirect"}
|
|
34
47
|
{"action": "update", "id": 1, "addBlocks": [2, 3]}
|
|
35
48
|
|
|
@@ -38,8 +51,8 @@ pending -> in_progress -> completed; deleted is the only terminal state. Keep ex
|
|
|
38
51
|
- Use dependencies only for real ordering constraints, and delete obsolete tasks promptly so their dependents are released`;
|
|
39
52
|
export const TODO_PROMPT_SNIPPET = "Track multi-step coding work with a small outcome-oriented task list";
|
|
40
53
|
export const TODO_PROMPT_GUIDELINES = [
|
|
41
|
-
"Use `todo` for work with three or more meaningful steps, user-provided task lists, or long sessions where progress can drift; list before creating to avoid duplicates, and capture follow-up work discovered during implementation as new tasks.",
|
|
54
|
+
"Use `todo` for work with three or more meaningful steps, user-provided task lists, or long sessions where progress can drift; list before creating to avoid duplicates, use create_many for a known batch of up to 20 tasks, and capture follow-up work discovered during implementation as new tasks.",
|
|
42
55
|
"Mark the active `todo` task in_progress before starting work (exactly one at a time; the tool demotes any other active item) and completed immediately after verification — never while tests fail or work is partial; reopen instead of duplicating, and when blocked create a task for the blocker and link it with addBlockedBy.",
|
|
43
|
-
"Keep the `todo` list short and outcome-oriented; prefer working in id order, use dependencies only for real prerequisites, and delete obsolete items promptly so their dependents are released.",
|
|
56
|
+
"Keep the `todo` list short and outcome-oriented; prefer working in id order, use dependencies only for real prerequisites, and delete obsolete items promptly so their dependents are released. Clear only with confirm=true and the current expectedCount.",
|
|
44
57
|
];
|
|
45
58
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/extensions/todo/constants.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/extensions/todo/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC;AACrC,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AACtC,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAE1C,0EAA0E;AAC1E,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AACzC,MAAM,CAAC,MAAM,mBAAmB,GAAG,sBAAsB,CAAC;AAC1D,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAE9C,wEAAwE;AACxE,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AACvC,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAC3C,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAK,CAAC;AACjD,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,CAAC;AAC/C,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AACzC,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAC7C,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAEtC,oFAAoF;AACpF,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC;AAChD,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AACzC,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAC7C,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAE9C,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;2HA2BsF,CAAC;AAE5H,MAAM,CAAC,MAAM,mBAAmB,GAAG,sEAAsE,CAAC;AAE1G,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACrC,wSAAwS;IACxS,uUAAqU;IACrU,6PAA6P;CAC7P,CAAC","sourcesContent":["/**\n * todo/constants.ts — tool identity, command name, input bounds, and prompt copy.\n */\n\nexport const TODO_TOOL_NAME = \"todo\";\nexport const TODO_TOOL_LABEL = \"Todo\";\nexport const TODOS_COMMAND_NAME = \"todos\";\n\n/** Max tasks shown in a single `list` tool result body (model-facing). */\nexport const LIST_DISPLAY_MAX_ITEMS = 50;\nexport const TODO_MAX_LIST_LIMIT = LIST_DISPLAY_MAX_ITEMS;\nexport const TODO_MAX_LIST_QUERY_LENGTH = 200;\n\n/** Input limits keep task snapshots and model-facing output bounded. */\nexport const TODO_MAX_BATCH_ITEMS = 20;\nexport const TODO_MAX_SUBJECT_LENGTH = 240;\nexport const TODO_MAX_DESCRIPTION_LENGTH = 4_000;\nexport const TODO_MAX_ACTIVE_FORM_LENGTH = 240;\nexport const TODO_MAX_OWNER_LENGTH = 160;\nexport const TODO_MAX_BATCH_KEY_LENGTH = 120;\nexport const TODO_MAX_BLOCKED_BY = 50;\n\n/** Metadata is JSON-like, deeply copied, and bounded independently of task text. */\nexport const TODO_MAX_METADATA_KEY_LENGTH = 160;\nexport const TODO_MAX_METADATA_DEPTH = 8;\nexport const TODO_MAX_METADATA_ENTRIES = 100;\nexport const TODO_MAX_METADATA_BYTES = 16_384;\n\nexport const TODO_TOOL_DESCRIPTION = `Manage the conversation's task list for multi-step coding work.\n\n## When to Use\n- Work with three or more meaningful steps, user-provided task lists, or long sessions where progress can drift\n- Capture new user requirements as tasks right away; after completing a task, add follow-up tasks discovered during implementation\n\n## When NOT to Use\n- Trivial single-step tasks and simple Q&A — just do the work\n\n## Actions\n- create: add one pending task; subject (short, imperative, reviewable scope) and description (what done means: acceptance criteria or verification detail) are required\n- create_many: atomically add up to 20 pending tasks in input order; each item needs subject and description, and optional unique keys can be linked within the batch with blockedByKeys\n- update: change status or details, and manage dependencies via addBlockedBy/removeBlockedBy (what this task waits on) and addBlocks/removeBlocks (what waits on this task); dependencies are validated and cycle-checked\n- list: one-line summaries with unresolved blockers, optionally filtered by status, paged with limit/afterId, searched with query, or narrowed with unblockedOnly; get: one task in full; delete: tombstone an obsolete task and release its dependents; clear: requires confirm=true and the exact expectedCount, without reusing ids\n- Parameters that do not apply to the chosen action are rejected with guidance\n\n## Status Workflow\npending -> in_progress -> completed; deleted is the only terminal state. Keep exactly one task in_progress (starting one demotes any other active task): mark it in_progress BEFORE starting the work, and completed only when implementation and verification are genuinely done — never with failing tests or partial work; reopen instead of duplicating. When blocked, do not fake completion: create a task for the blocker and link it with addBlockedBy.\n\n## Examples\n{\"action\": \"create\", \"subject\": \"Fix login redirect\", \"description\": \"Redirect lands on the dashboard; auth tests pass\"}\n{\"action\": \"create_many\", \"items\": [{\"key\": \"parser\", \"subject\": \"Wire parser\", \"description\": \"Parser handles config\"}, {\"subject\": \"Test parser\", \"description\": \"Parser tests pass\", \"blockedByKeys\": [\"parser\"]}]}\n{\"action\": \"update\", \"id\": 2, \"status\": \"in_progress\", \"activeForm\": \"fixing login redirect\"}\n{\"action\": \"update\", \"id\": 1, \"addBlocks\": [2, 3]}\n\n## Tips\n- list before create to avoid duplicates; prefer working in id order — earlier tasks usually set up context for later ones\n- Use dependencies only for real ordering constraints, and delete obsolete tasks promptly so their dependents are released`;\n\nexport const TODO_PROMPT_SNIPPET = \"Track multi-step coding work with a small outcome-oriented task list\";\n\nexport const TODO_PROMPT_GUIDELINES = [\n\t\"Use `todo` for work with three or more meaningful steps, user-provided task lists, or long sessions where progress can drift; list before creating to avoid duplicates, use create_many for a known batch of up to 20 tasks, and capture follow-up work discovered during implementation as new tasks.\",\n\t\"Mark the active `todo` task in_progress before starting work (exactly one at a time; the tool demotes any other active item) and completed immediately after verification — never while tests fail or work is partial; reopen instead of duplicating, and when blocked create a task for the blocker and link it with addBlockedBy.\",\n\t\"Keep the `todo` list short and outcome-oriented; prefer working in id order, use dependencies only for real prerequisites, and delete obsolete items promptly so their dependents are released. Clear only with confirm=true and the current expectedCount.\",\n];\n"]}
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* todo — Pi-native task tracking for multi-step work.
|
|
3
|
-
*
|
|
4
|
-
* The state is intentionally conversation-backed: every tool result carries a
|
|
5
|
-
* full snapshot in `details`, and lifecycle handlers replay the current branch.
|
|
6
|
-
* This keeps /reload, compaction, and session-tree navigation aligned with the
|
|
7
|
-
* conversation without adding a separate disk database. (Compaction-safe by
|
|
8
|
-
* design: sessionManager.getBranch() returns the FULL branch history including
|
|
9
|
-
* pre-compaction toolResult entries — only buildSessionContext summarizes.)
|
|
10
|
-
*
|
|
11
|
-
* State is keyed per session id (see state.ts): resume and /tree switches can
|
|
12
|
-
* change the session within one process, and execute + lifecycle handlers
|
|
13
|
-
* re-point the active bucket before touching state.
|
|
14
|
-
*/
|
|
15
1
|
import { type ExtensionAPI } from "../../core/extensions/types.ts";
|
|
16
2
|
export default function todo(pi: ExtensionAPI): void;
|
|
17
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/todo/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/todo/index.ts"],"names":[],"mappings":"AAeA,OAAO,EAEN,KAAK,YAAY,EAGjB,MAAM,gCAAgC,CAAC;AAyCxC,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAuFnD","sourcesContent":["/**\n * todo — Pi-native task tracking for multi-step work.\n *\n * The state is intentionally conversation-backed: every tool result carries a\n * full snapshot in `details`, and lifecycle handlers replay the current branch.\n * This keeps /reload, compaction, and session-tree navigation aligned with the\n * conversation without adding a separate disk database. (Compaction-safe by\n * design: sessionManager.getBranch() returns the FULL branch history including\n * pre-compaction toolResult entries — only buildSessionContext summarizes.)\n *\n * State is keyed per session id (see state.ts): resume and /tree switches can\n * change the session within one process, and execute + lifecycle handlers\n * re-point the active bucket before touching state.\n */\nimport { Text } from \"@earendil-works/pi-tui\";\nimport {\n\ttype AgentToolResult,\n\ttype ExtensionAPI,\n\tisStaleExtensionContextError,\n\ttype ToolExecutionMode,\n} from \"../../core/extensions/types.ts\";\nimport {\n\tTODO_PROMPT_GUIDELINES,\n\tTODO_PROMPT_SNIPPET,\n\tTODO_TOOL_DESCRIPTION,\n\tTODO_TOOL_LABEL,\n\tTODO_TOOL_NAME,\n\tTODOS_COMMAND_NAME,\n} from \"./constants.ts\";\nimport { TodoOverlay } from \"./overlay.ts\";\nimport { type TodoDetails, TodoParamsSchema } from \"./schema.ts\";\nimport {\n\tapplyTodoMutation,\n\tbuildTodoDetails,\n\tcommitTodoState,\n\tdisposeTodoSession,\n\tformatTodoContent,\n\tgetTodoState,\n\treplaceTodoState,\n\treplayTodosFromBranch,\n\tsetActiveTodoSession,\n} from \"./state.ts\";\nimport { formatCommandList, formatTodoCall, formatTodoGroupCall } from \"./view.ts\";\n\ninterface TodoSessionCtx {\n\tsessionManager: { getBranch(): Iterable<unknown>; getSessionId(): string };\n}\n\nfunction safeReplay(ctx: TodoSessionCtx): void {\n\t// Every ctx.sessionManager access goes through a stale guard, so the whole\n\t// body stays inside the try: a lifecycle event can race session replacement\n\t// (resume, /tree, /reload), and a stale ctx just means another session took\n\t// over — nothing left to replay for it.\n\ttry {\n\t\tsetActiveTodoSession(ctx.sessionManager.getSessionId());\n\t\treplaceTodoState(replayTodosFromBranch(ctx));\n\t} catch (error) {\n\t\tif (!isStaleExtensionContextError(error)) throw error;\n\t}\n}\n\nexport default function todo(pi: ExtensionAPI): void {\n\tlet overlay: TodoOverlay | undefined;\n\n\tpi.registerTool({\n\t\tname: TODO_TOOL_NAME,\n\t\tlabel: TODO_TOOL_LABEL,\n\t\tdescription: TODO_TOOL_DESCRIPTION,\n\t\tpromptSnippet: TODO_PROMPT_SNIPPET,\n\t\tpromptGuidelines: TODO_PROMPT_GUIDELINES,\n\t\tparameters: TodoParamsSchema,\n\t\texecutionMode: \"sequential\" as ToolExecutionMode,\n\t\t// Consecutive todo calls collapse into one run like read/find's `explore`\n\t\t// group; the overlay already carries the live list, so the transcript only\n\t\t// needs the sequence of operations.\n\t\ttoolGroup: TODO_TOOL_NAME,\n\n\t\tasync execute(_toolCallId, params, _signal, _onUpdate, ctx): Promise<AgentToolResult<TodoDetails>> {\n\t\t\t// Re-point the active bucket: resume//tree can switch sessions between\n\t\t\t// lifecycle events and this call.\n\t\t\tsetActiveTodoSession(ctx.sessionManager.getSessionId());\n\t\t\tconst result = applyTodoMutation(getTodoState(), params);\n\t\t\tif (result.operation.kind === \"error\") {\n\t\t\t\tthrow new Error(result.operation.message);\n\t\t\t}\n\t\t\tcommitTodoState(result.state);\n\t\t\tconst text = formatTodoContent(result.operation, result.state);\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text }],\n\t\t\t\tdetails: buildTodoDetails(params, result.state),\n\t\t\t};\n\t\t},\n\n\t\trenderCall(args, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(\n\t\t\t\tcontext.toolGroupSummary\n\t\t\t\t\t? formatTodoGroupCall(args, theme, context)\n\t\t\t\t\t: formatTodoCall(args, theme, context.expanded, context.result),\n\t\t\t);\n\t\t\treturn text;\n\t\t},\n\t});\n\n\tpi.registerCommand(TODOS_COMMAND_NAME, {\n\t\tdescription: \"Show todos for the current conversation branch\",\n\t\thandler: async (_args, ctx) => {\n\t\t\tif (!ctx.hasUI) {\n\t\t\t\tctx.ui.notify(\"/todos requires an interactive UI.\", \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetActiveTodoSession(ctx.sessionManager.getSessionId());\n\t\t\tctx.ui.notify(formatCommandList(getTodoState()), \"info\");\n\t\t},\n\t});\n\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\tsafeReplay(ctx);\n\t\tif (ctx.hasUI) {\n\t\t\toverlay ??= new TodoOverlay();\n\t\t\toverlay.setUI(ctx.ui);\n\t\t\toverlay.resetVisibility();\n\t\t\toverlay.update();\n\t\t}\n\t});\n\n\tpi.on(\"session_compact\", async (_event, ctx) => {\n\t\tsafeReplay(ctx);\n\t\toverlay?.resetVisibility();\n\t\toverlay?.update();\n\t});\n\n\tpi.on(\"session_tree\", async (_event, ctx) => {\n\t\tsafeReplay(ctx);\n\t\toverlay?.resetVisibility();\n\t\toverlay?.update();\n\t});\n\n\tpi.on(\"session_shutdown\", async (_event, ctx) => {\n\t\tdisposeTodoSession(ctx.sessionManager.getSessionId());\n\t\toverlay?.dispose();\n\t\toverlay = undefined;\n\t});\n\n\tpi.on(\"tool_execution_end\", async (event) => {\n\t\tif (event.toolName !== TODO_TOOL_NAME || event.isError) return;\n\t\toverlay?.update();\n\t});\n}\n"]}
|
|
@@ -12,12 +12,13 @@
|
|
|
12
12
|
* change the session within one process, and execute + lifecycle handlers
|
|
13
13
|
* re-point the active bucket before touching state.
|
|
14
14
|
*/
|
|
15
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
15
16
|
import { isStaleExtensionContextError, } from "../../core/extensions/types.js";
|
|
16
17
|
import { TODO_PROMPT_GUIDELINES, TODO_PROMPT_SNIPPET, TODO_TOOL_DESCRIPTION, TODO_TOOL_LABEL, TODO_TOOL_NAME, TODOS_COMMAND_NAME, } from "./constants.js";
|
|
17
18
|
import { TodoOverlay } from "./overlay.js";
|
|
18
19
|
import { TodoParamsSchema } from "./schema.js";
|
|
19
20
|
import { applyTodoMutation, buildTodoDetails, commitTodoState, disposeTodoSession, formatTodoContent, getTodoState, replaceTodoState, replayTodosFromBranch, setActiveTodoSession, } from "./state.js";
|
|
20
|
-
import { formatCommandList } from "./view.js";
|
|
21
|
+
import { formatCommandList, formatTodoCall, formatTodoGroupCall } from "./view.js";
|
|
21
22
|
function safeReplay(ctx) {
|
|
22
23
|
// Every ctx.sessionManager access goes through a stale guard, so the whole
|
|
23
24
|
// body stays inside the try: a lifecycle event can race session replacement
|
|
@@ -42,6 +43,10 @@ export default function todo(pi) {
|
|
|
42
43
|
promptGuidelines: TODO_PROMPT_GUIDELINES,
|
|
43
44
|
parameters: TodoParamsSchema,
|
|
44
45
|
executionMode: "sequential",
|
|
46
|
+
// Consecutive todo calls collapse into one run like read/find's `explore`
|
|
47
|
+
// group; the overlay already carries the live list, so the transcript only
|
|
48
|
+
// needs the sequence of operations.
|
|
49
|
+
toolGroup: TODO_TOOL_NAME,
|
|
45
50
|
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
46
51
|
// Re-point the active bucket: resume//tree can switch sessions between
|
|
47
52
|
// lifecycle events and this call.
|
|
@@ -57,6 +62,13 @@ export default function todo(pi) {
|
|
|
57
62
|
details: buildTodoDetails(params, result.state),
|
|
58
63
|
};
|
|
59
64
|
},
|
|
65
|
+
renderCall(args, theme, context) {
|
|
66
|
+
const text = context.lastComponent ?? new Text("", 0, 0);
|
|
67
|
+
text.setText(context.toolGroupSummary
|
|
68
|
+
? formatTodoGroupCall(args, theme, context)
|
|
69
|
+
: formatTodoCall(args, theme, context.expanded, context.result));
|
|
70
|
+
return text;
|
|
71
|
+
},
|
|
60
72
|
});
|
|
61
73
|
pi.registerCommand(TODOS_COMMAND_NAME, {
|
|
62
74
|
description: "Show todos for the current conversation branch",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/todo/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAGN,4BAA4B,GAE5B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACN,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,kBAAkB,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAoB,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EACN,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/extensions/todo/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAGN,4BAA4B,GAE5B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACN,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,kBAAkB,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAoB,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EACN,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAMnF,SAAS,UAAU,CAAC,GAAmB,EAAQ;IAC9C,2EAA2E;IAC3E,4EAA4E;IAC5E,4EAA4E;IAC5E,0CAAwC;IACxC,IAAI,CAAC;QACJ,oBAAoB,CAAC,GAAG,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC,CAAC;QACxD,g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GAAG,CAAC,EAAE,CAAC,CAAC;YACtB,OAAO,CAAC,eAAe,EAAE,CAAC;YAC1B,OAAO,CAAC,MAAM,EAAE,CAAC;QAClB,CAAC;IAAA,CACD,CAAC,CAAC;IAEH,EAAE,CAAC,EAAE,CAAC,iBAAiB,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC;QAC/C,UAAU,CAAC,GAAG,CAAC,CAAC;QAChB,OAAO,EAAE,eAAe,EAAE,CAAC;QAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;IAAA,CAClB,CAAC,CAAC;IAEH,EAAE,CAAC,EAAE,CAAC,cAAc,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC;QAC5C,UAAU,CAAC,GAAG,CAAC,CAAC;QAChB,OAAO,EAAE,eAAe,EAAE,CAAC;QAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;IAAA,CAClB,CAAC,CAAC;IAEH,EAAE,CAAC,EAAE,CAAC,kBAAkB,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC;QAChD,kBAAkB,CAAC,GAAG,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC,CAAC;QACtD,OAAO,EAAE,OAAO,EAAE,CAAC;QACnB,OAAO,GAAG,SAAS,CAAC;IAAA,CACpB,CAAC,CAAC;IAEH,EAAE,CAAC,EAAE,CAAC,oBAAoB,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC;QAC5C,IAAI,KAAK,CAAC,QAAQ,KAAK,cAAc,IAAI,KAAK,CAAC,OAAO;YAAE,OAAO;QAC/D,OAAO,EAAE,MAAM,EAAE,CAAC;IAAA,CAClB,CAAC,CAAC;AAAA,CACH","sourcesContent":["/**\n * todo — Pi-native task tracking for multi-step work.\n *\n * The state is intentionally conversation-backed: every tool result carries a\n * full snapshot in `details`, and lifecycle handlers replay the current branch.\n * This keeps /reload, compaction, and session-tree navigation aligned with the\n * conversation without adding a separate disk database. (Compaction-safe by\n * design: sessionManager.getBranch() returns the FULL branch history including\n * pre-compaction toolResult entries — only buildSessionContext summarizes.)\n *\n * State is keyed per session id (see state.ts): resume and /tree switches can\n * change the session within one process, and execute + lifecycle handlers\n * re-point the active bucket before touching state.\n */\nimport { Text } from \"@earendil-works/pi-tui\";\nimport {\n\ttype AgentToolResult,\n\ttype ExtensionAPI,\n\tisStaleExtensionContextError,\n\ttype ToolExecutionMode,\n} from \"../../core/extensions/types.ts\";\nimport {\n\tTODO_PROMPT_GUIDELINES,\n\tTODO_PROMPT_SNIPPET,\n\tTODO_TOOL_DESCRIPTION,\n\tTODO_TOOL_LABEL,\n\tTODO_TOOL_NAME,\n\tTODOS_COMMAND_NAME,\n} from \"./constants.ts\";\nimport { TodoOverlay } from \"./overlay.ts\";\nimport { type TodoDetails, TodoParamsSchema } from \"./schema.ts\";\nimport {\n\tapplyTodoMutation,\n\tbuildTodoDetails,\n\tcommitTodoState,\n\tdisposeTodoSession,\n\tformatTodoContent,\n\tgetTodoState,\n\treplaceTodoState,\n\treplayTodosFromBranch,\n\tsetActiveTodoSession,\n} from \"./state.ts\";\nimport { formatCommandList, formatTodoCall, formatTodoGroupCall } from \"./view.ts\";\n\ninterface TodoSessionCtx {\n\tsessionManager: { getBranch(): Iterable<unknown>; getSessionId(): string };\n}\n\nfunction safeReplay(ctx: TodoSessionCtx): void {\n\t// Every ctx.sessionManager access goes through a stale guard, so the whole\n\t// body stays inside the try: a lifecycle event can race session replacement\n\t// (resume, /tree, /reload), and a stale ctx just means another session took\n\t// over — nothing left to replay for it.\n\ttry {\n\t\tsetActiveTodoSession(ctx.sessionManager.getSessionId());\n\t\treplaceTodoState(replayTodosFromBranch(ctx));\n\t} catch (error) {\n\t\tif (!isStaleExtensionContextError(error)) throw error;\n\t}\n}\n\nexport default function todo(pi: ExtensionAPI): void {\n\tlet overlay: TodoOverlay | undefined;\n\n\tpi.registerTool({\n\t\tname: TODO_TOOL_NAME,\n\t\tlabel: TODO_TOOL_LABEL,\n\t\tdescription: TODO_TOOL_DESCRIPTION,\n\t\tpromptSnippet: TODO_PROMPT_SNIPPET,\n\t\tpromptGuidelines: TODO_PROMPT_GUIDELINES,\n\t\tparameters: TodoParamsSchema,\n\t\texecutionMode: \"sequential\" as ToolExecutionMode,\n\t\t// Consecutive todo calls collapse into one run like read/find's `explore`\n\t\t// group; the overlay already carries the live list, so the transcript only\n\t\t// needs the sequence of operations.\n\t\ttoolGroup: TODO_TOOL_NAME,\n\n\t\tasync execute(_toolCallId, params, _signal, _onUpdate, ctx): Promise<AgentToolResult<TodoDetails>> {\n\t\t\t// Re-point the active bucket: resume//tree can switch sessions between\n\t\t\t// lifecycle events and this call.\n\t\t\tsetActiveTodoSession(ctx.sessionManager.getSessionId());\n\t\t\tconst result = applyTodoMutation(getTodoState(), params);\n\t\t\tif (result.operation.kind === \"error\") {\n\t\t\t\tthrow new Error(result.operation.message);\n\t\t\t}\n\t\t\tcommitTodoState(result.state);\n\t\t\tconst text = formatTodoContent(result.operation, result.state);\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\", text }],\n\t\t\t\tdetails: buildTodoDetails(params, result.state),\n\t\t\t};\n\t\t},\n\n\t\trenderCall(args, theme, context) {\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(\n\t\t\t\tcontext.toolGroupSummary\n\t\t\t\t\t? formatTodoGroupCall(args, theme, context)\n\t\t\t\t\t: formatTodoCall(args, theme, context.expanded, context.result),\n\t\t\t);\n\t\t\treturn text;\n\t\t},\n\t});\n\n\tpi.registerCommand(TODOS_COMMAND_NAME, {\n\t\tdescription: \"Show todos for the current conversation branch\",\n\t\thandler: async (_args, ctx) => {\n\t\t\tif (!ctx.hasUI) {\n\t\t\t\tctx.ui.notify(\"/todos requires an interactive UI.\", \"warning\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetActiveTodoSession(ctx.sessionManager.getSessionId());\n\t\t\tctx.ui.notify(formatCommandList(getTodoState()), \"info\");\n\t\t},\n\t});\n\n\tpi.on(\"session_start\", async (_event, ctx) => {\n\t\tsafeReplay(ctx);\n\t\tif (ctx.hasUI) {\n\t\t\toverlay ??= new TodoOverlay();\n\t\t\toverlay.setUI(ctx.ui);\n\t\t\toverlay.resetVisibility();\n\t\t\toverlay.update();\n\t\t}\n\t});\n\n\tpi.on(\"session_compact\", async (_event, ctx) => {\n\t\tsafeReplay(ctx);\n\t\toverlay?.resetVisibility();\n\t\toverlay?.update();\n\t});\n\n\tpi.on(\"session_tree\", async (_event, ctx) => {\n\t\tsafeReplay(ctx);\n\t\toverlay?.resetVisibility();\n\t\toverlay?.update();\n\t});\n\n\tpi.on(\"session_shutdown\", async (_event, ctx) => {\n\t\tdisposeTodoSession(ctx.sessionManager.getSessionId());\n\t\toverlay?.dispose();\n\t\toverlay = undefined;\n\t});\n\n\tpi.on(\"tool_execution_end\", async (event) => {\n\t\tif (event.toolName !== TODO_TOOL_NAME || event.isError) return;\n\t\toverlay?.update();\n\t});\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Static, Type } from "typebox";
|
|
2
2
|
export type TodoStatus = "pending" | "in_progress" | "completed" | "deleted";
|
|
3
|
-
export type TodoAction = "create" | "update" | "list" | "get" | "delete" | "clear";
|
|
3
|
+
export type TodoAction = "create" | "create_many" | "update" | "list" | "get" | "delete" | "clear";
|
|
4
4
|
export interface TodoItem {
|
|
5
5
|
id: number;
|
|
6
6
|
subject: string;
|
|
@@ -15,19 +15,64 @@ export interface TodoState {
|
|
|
15
15
|
items: TodoItem[];
|
|
16
16
|
nextId: number;
|
|
17
17
|
}
|
|
18
|
+
/** Current shape of snapshots written to todo tool results. */
|
|
19
|
+
export declare const TODO_DETAILS_SCHEMA_VERSION = 1;
|
|
20
|
+
export type TodoOperationSummary = {
|
|
21
|
+
kind: "create";
|
|
22
|
+
ids: number[];
|
|
23
|
+
} | {
|
|
24
|
+
kind: "create_many";
|
|
25
|
+
ids: number[];
|
|
26
|
+
} | {
|
|
27
|
+
kind: "update";
|
|
28
|
+
id: number;
|
|
29
|
+
status: TodoStatus;
|
|
30
|
+
} | {
|
|
31
|
+
kind: "list";
|
|
32
|
+
status?: TodoStatus;
|
|
33
|
+
includeDeleted: boolean;
|
|
34
|
+
limit?: number;
|
|
35
|
+
afterId?: number;
|
|
36
|
+
query?: string;
|
|
37
|
+
unblockedOnly: boolean;
|
|
38
|
+
/** Exact status counts for the returned page, not the full snapshot. */
|
|
39
|
+
statusCounts?: Partial<Record<TodoStatus, number>>;
|
|
40
|
+
resultCount?: number;
|
|
41
|
+
} | {
|
|
42
|
+
kind: "get";
|
|
43
|
+
id: number;
|
|
44
|
+
} | {
|
|
45
|
+
kind: "delete";
|
|
46
|
+
id: number;
|
|
47
|
+
} | {
|
|
48
|
+
kind: "clear";
|
|
49
|
+
count: number;
|
|
50
|
+
};
|
|
18
51
|
export interface TodoDetails {
|
|
52
|
+
schemaVersion: typeof TODO_DETAILS_SCHEMA_VERSION;
|
|
19
53
|
action: TodoAction;
|
|
20
54
|
params: Record<string, unknown>;
|
|
55
|
+
operation: TodoOperationSummary;
|
|
21
56
|
items: TodoItem[];
|
|
22
57
|
nextId: number;
|
|
23
58
|
}
|
|
24
59
|
export declare const TodoParamsSchema: Type.TObject<{
|
|
25
|
-
action: Type.TUnsafe<"clear" | "create" | "delete" | "get" | "list" | "update">;
|
|
60
|
+
action: Type.TUnsafe<"clear" | "create" | "create_many" | "delete" | "get" | "list" | "update">;
|
|
26
61
|
subject: Type.TOptional<Type.TString>;
|
|
27
62
|
description: Type.TOptional<Type.TString>;
|
|
28
63
|
activeForm: Type.TOptional<Type.TString>;
|
|
29
64
|
status: Type.TOptional<Type.TUnsafe<"completed" | "deleted" | "in_progress" | "pending">>;
|
|
30
65
|
blockedBy: Type.TOptional<Type.TArray<Type.TInteger>>;
|
|
66
|
+
items: Type.TOptional<Type.TArray<Type.TObject<{
|
|
67
|
+
key: Type.TOptional<Type.TString>;
|
|
68
|
+
subject: Type.TString;
|
|
69
|
+
description: Type.TString;
|
|
70
|
+
activeForm: Type.TOptional<Type.TString>;
|
|
71
|
+
blockedBy: Type.TOptional<Type.TArray<Type.TInteger>>;
|
|
72
|
+
blockedByKeys: Type.TOptional<Type.TArray<Type.TString>>;
|
|
73
|
+
owner: Type.TOptional<Type.TString>;
|
|
74
|
+
metadata: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
|
|
75
|
+
}>>>;
|
|
31
76
|
addBlockedBy: Type.TOptional<Type.TArray<Type.TInteger>>;
|
|
32
77
|
removeBlockedBy: Type.TOptional<Type.TArray<Type.TInteger>>;
|
|
33
78
|
addBlocks: Type.TOptional<Type.TArray<Type.TInteger>>;
|
|
@@ -36,6 +81,12 @@ export declare const TodoParamsSchema: Type.TObject<{
|
|
|
36
81
|
metadata: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
|
|
37
82
|
id: Type.TOptional<Type.TInteger>;
|
|
38
83
|
includeDeleted: Type.TOptional<Type.TBoolean>;
|
|
84
|
+
limit: Type.TOptional<Type.TInteger>;
|
|
85
|
+
afterId: Type.TOptional<Type.TInteger>;
|
|
86
|
+
query: Type.TOptional<Type.TString>;
|
|
87
|
+
unblockedOnly: Type.TOptional<Type.TBoolean>;
|
|
88
|
+
confirm: Type.TOptional<Type.TBoolean>;
|
|
89
|
+
expectedCount: Type.TOptional<Type.TInteger>;
|
|
39
90
|
}>;
|
|
40
91
|
export type TodoParams = Static<typeof TodoParamsSchema>;
|
|
41
92
|
export declare const EMPTY_TODO_STATE: TodoState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/extensions/todo/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,aAAa,GAAG,WAAW,GAAG,SAAS,CAAC;AAC7E,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEnF,MAAM,WAAW,QAAQ;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,UAAU,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,SAAS;IACzB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC3B,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CACf;AAcD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;EAgE3B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEzD,eAAO,MAAM,gBAAgB,EAAE,SAAoC,CAAC","sourcesContent":["import { StringEnum } from \"@earendil-works/pi-ai\";\nimport { type Static, Type } from \"typebox\";\n\nexport type TodoStatus = \"pending\" | \"in_progress\" | \"completed\" | \"deleted\";\nexport type TodoAction = \"create\" | \"update\" | \"list\" | \"get\" | \"delete\" | \"clear\";\n\nexport interface TodoItem {\n\tid: number;\n\tsubject: string;\n\tdescription?: string;\n\tactiveForm?: string;\n\tstatus: TodoStatus;\n\tblockedBy?: number[];\n\towner?: string;\n\tmetadata?: Record<string, unknown>;\n}\n\nexport interface TodoState {\n\titems: TodoItem[];\n\tnextId: number;\n}\n\nexport interface TodoDetails {\n\taction: TodoAction;\n\tparams: Record<string, unknown>;\n\titems: TodoItem[];\n\tnextId: number;\n}\n\nconst StatusSchema = StringEnum([\"pending\", \"in_progress\", \"completed\", \"deleted\"] as const, {\n\tdescription:\n\t\t\"Task status: pending for future work, in_progress for the single active task, completed for verified done work, and deleted for an immutable obsolete-task tombstone. Set deleted through update or use the delete action. With action list, status also acts as a filter: only tasks with this status are listed.\",\n});\n\nconst ActionSchema = StringEnum([\"create\", \"update\", \"list\", \"get\", \"delete\", \"clear\"] as const, {\n\tdescription:\n\t\t\"Todo operation: create a pending task, update status/details/dependencies, list current tasks (optionally filtered by status), get one task, delete an obsolete task and release dependents, or clear the list without reusing ids. Parameters that do not apply to the chosen action are rejected.\",\n});\n\nconst TaskId = (description: string) => Type.Integer({ minimum: 1, description });\n\nexport const TodoParamsSchema = Type.Object({\n\taction: ActionSchema,\n\tsubject: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Short imperative task subject, required for create; use a reviewable unit of work, not a micro-step.\",\n\t\t}),\n\t),\n\tdescription: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"What done means for this task: notes, acceptance criteria, or verification detail. Required for create; on update an empty string removes it.\",\n\t\t}),\n\t),\n\tactiveForm: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Present-continuous label shown while in_progress, such as 'reading code' or 'updating prompts'; on update an empty string removes it.\",\n\t\t}),\n\t),\n\tstatus: Type.Optional(StatusSchema),\n\tblockedBy: Type.Optional(\n\t\tType.Array(TaskId(\"Existing task id this task depends on.\"), {\n\t\t\tdescription:\n\t\t\t\t\"Initial dependency ids, create only (update rejects it; use addBlockedBy/removeBlockedBy there); use only for real ordering constraints.\",\n\t\t}),\n\t),\n\taddBlockedBy: Type.Optional(\n\t\tType.Array(TaskId(\"Existing task id that must complete first.\"), {\n\t\t\tdescription: \"Dependency ids to add on update; dependencies must exist and cannot create cycles.\",\n\t\t}),\n\t),\n\tremoveBlockedBy: Type.Optional(\n\t\tType.Array(TaskId(\"Dependency id to detach.\"), { description: \"Dependency ids to remove on update.\" }),\n\t),\n\taddBlocks: Type.Optional(\n\t\tType.Array(TaskId(\"Existing task id that must wait for this one.\"), {\n\t\t\tdescription:\n\t\t\t\t\"Update only: ids of tasks that cannot start until this task completes (the reverse of addBlockedBy); targets must exist and cannot create cycles.\",\n\t\t}),\n\t),\n\tremoveBlocks: Type.Optional(\n\t\tType.Array(TaskId(\"Dependent task id to release.\"), {\n\t\t\tdescription: \"Update only: ids of tasks that should no longer wait for this task.\",\n\t\t}),\n\t),\n\towner: Type.Optional(\n\t\tType.String({\n\t\t\tdescription:\n\t\t\t\t\"Optional owner or agent label for multi-agent coordination; on update an empty string removes it.\",\n\t\t}),\n\t),\n\tmetadata: Type.Optional(\n\t\tType.Record(Type.String(), Type.Unknown(), {\n\t\t\tdescription: \"Optional structured metadata for integrations; null values delete keys on update.\",\n\t\t}),\n\t),\n\tid: Type.Optional(TaskId(\"Task id, required for update, get, and delete.\")),\n\tincludeDeleted: Type.Optional(\n\t\tType.Boolean({\n\t\t\tdescription:\n\t\t\t\t\"Include deleted tombstones in unfiltered list output; an explicit status=deleted query includes them automatically.\",\n\t\t}),\n\t),\n});\n\nexport type TodoParams = Static<typeof TodoParamsSchema>;\n\nexport const EMPTY_TODO_STATE: TodoState = { items: [], nextId: 1 };\n"]}
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/extensions/todo/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAe5C,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,aAAa,GAAG,WAAW,GAAG,SAAS,CAAC;AAC7E,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,aAAa,GAAG,QAAQ,GAAG,MAAM,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AAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAC3B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpC,MAAM,WAAW,WAAW;IAC3B,aAAa,EAAE,OAAO,2BAA2B,CAAC;IAClD,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,SAAS,EAAE,oBAAoB,CAAC;IAChC,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CACf;AAgDD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyF3B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEzD,eAAO,MAAM,gBAAgB,EAAE,SAAoC,CAAC","sourcesContent":["import { StringEnum } from \"@earendil-works/pi-ai\";\nimport { type Static, Type } from \"typebox\";\nimport {\n\tTODO_MAX_ACTIVE_FORM_LENGTH,\n\tTODO_MAX_BATCH_ITEMS,\n\tTODO_MAX_BATCH_KEY_LENGTH,\n\tTODO_MAX_BLOCKED_BY,\n\tTODO_MAX_DESCRIPTION_LENGTH,\n\tTODO_MAX_LIST_LIMIT,\n\tTODO_MAX_LIST_QUERY_LENGTH,\n\tTODO_MAX_METADATA_ENTRIES,\n\tTODO_MAX_METADATA_KEY_LENGTH,\n\tTODO_MAX_OWNER_LENGTH,\n\tTODO_MAX_SUBJECT_LENGTH,\n} from \"./constants.ts\";\n\nexport type TodoStatus = \"pending\" | \"in_progress\" | \"completed\" | \"deleted\";\nexport type TodoAction = \"create\" | \"create_many\" | \"update\" | \"list\" | \"get\" | \"delete\" | \"clear\";\n\nexport interface TodoItem {\n\tid: number;\n\tsubject: string;\n\tdescription?: string;\n\tactiveForm?: string;\n\tstatus: TodoStatus;\n\tblockedBy?: number[];\n\towner?: string;\n\tmetadata?: Record<string, unknown>;\n}\n\nexport interface TodoState {\n\titems: TodoItem[];\n\tnextId: number;\n}\n\n/** Current shape of snapshots written to todo tool results. */\nexport const TODO_DETAILS_SCHEMA_VERSION = 1;\n\nexport type TodoOperationSummary =\n\t| { kind: \"create\"; ids: number[] }\n\t| { kind: \"create_many\"; ids: number[] }\n\t| { kind: \"update\"; id: number; status: TodoStatus }\n\t| {\n\t\t\tkind: \"list\";\n\t\t\tstatus?: TodoStatus;\n\t\t\tincludeDeleted: boolean;\n\t\t\tlimit?: number;\n\t\t\tafterId?: number;\n\t\t\tquery?: string;\n\t\t\tunblockedOnly: boolean;\n\t\t\t/** Exact status counts for the returned page, not the full snapshot. */\n\t\t\tstatusCounts?: Partial<Record<TodoStatus, number>>;\n\t\t\tresultCount?: number;\n\t }\n\t| { kind: \"get\"; id: number }\n\t| { kind: \"delete\"; id: number }\n\t| { kind: \"clear\"; count: number };\n\nexport interface TodoDetails {\n\tschemaVersion: typeof TODO_DETAILS_SCHEMA_VERSION;\n\taction: TodoAction;\n\tparams: Record<string, unknown>;\n\toperation: TodoOperationSummary;\n\titems: TodoItem[];\n\tnextId: number;\n}\n\nconst StatusSchema = StringEnum([\"pending\", \"in_progress\", \"completed\", \"deleted\"] as const, {\n\tdescription:\n\t\t\"Task status: pending for future work, in_progress for the single active task, completed for verified done work, and deleted for an immutable obsolete-task tombstone. Set deleted through update or use the delete action. With action list, status also acts as a filter: only tasks with this status are listed.\",\n});\n\nconst ActionSchema = StringEnum([\"create\", \"create_many\", \"update\", \"list\", \"get\", \"delete\", \"clear\"] as const, {\n\tdescription:\n\t\t\"Todo operation: create one pending task, create_many pending tasks atomically, update status/details/dependencies, list current tasks, get one task, delete an obsolete task, or clear the list with confirmation. Parameters that do not apply to the chosen action are rejected.\",\n});\n\nconst TaskId = (description: string) => Type.Integer({ minimum: 1, description });\n\nconst MetadataSchema = Type.Record(Type.String({ maxLength: TODO_MAX_METADATA_KEY_LENGTH }), Type.Unknown(), {\n\tmaxProperties: TODO_MAX_METADATA_ENTRIES,\n\tdescription: \"Structured JSON-like metadata. Values and total payload are validated by the tool.\",\n});\n\nconst CreateManyItemSchema = Type.Object({\n\tkey: Type.Optional(\n\t\tType.String({\n\t\t\tmaxLength: TODO_MAX_BATCH_KEY_LENGTH,\n\t\t\tdescription: \"Optional unique batch key used by blockedByKeys references.\",\n\t\t}),\n\t),\n\tsubject: Type.String({\n\t\tmaxLength: TODO_MAX_SUBJECT_LENGTH,\n\t\tdescription: \"Short imperative task subject.\",\n\t}),\n\tdescription: Type.String({\n\t\tmaxLength: TODO_MAX_DESCRIPTION_LENGTH,\n\t\tdescription: \"What done means for this task.\",\n\t}),\n\tactiveForm: Type.Optional(Type.String({ maxLength: TODO_MAX_ACTIVE_FORM_LENGTH })),\n\tblockedBy: Type.Optional(\n\t\tType.Array(TaskId(\"Existing task id this task depends on.\"), { maxItems: TODO_MAX_BLOCKED_BY }),\n\t),\n\tblockedByKeys: Type.Optional(\n\t\tType.Array(Type.String({ maxLength: TODO_MAX_BATCH_KEY_LENGTH }), {\n\t\t\tmaxItems: TODO_MAX_BLOCKED_BY,\n\t\t\tdescription: \"Keys of tasks in this create_many batch that must complete first.\",\n\t\t}),\n\t),\n\towner: Type.Optional(Type.String({ maxLength: TODO_MAX_OWNER_LENGTH })),\n\tmetadata: Type.Optional(MetadataSchema),\n});\n\nexport const TodoParamsSchema = Type.Object({\n\taction: ActionSchema,\n\tsubject: Type.Optional(\n\t\tType.String({\n\t\t\tmaxLength: TODO_MAX_SUBJECT_LENGTH,\n\t\t\tdescription:\n\t\t\t\t\"Short imperative task subject, required for create; use a reviewable unit of work, not a micro-step.\",\n\t\t}),\n\t),\n\tdescription: Type.Optional(\n\t\tType.String({\n\t\t\tmaxLength: TODO_MAX_DESCRIPTION_LENGTH,\n\t\t\tdescription:\n\t\t\t\t\"What done means for this task: notes, acceptance criteria, or verification detail. Required for create; on update an empty string removes it.\",\n\t\t}),\n\t),\n\tactiveForm: Type.Optional(\n\t\tType.String({\n\t\t\tmaxLength: TODO_MAX_ACTIVE_FORM_LENGTH,\n\t\t\tdescription:\n\t\t\t\t\"Present-continuous label shown while in_progress, such as 'reading code' or 'updating prompts'; on update an empty string removes it.\",\n\t\t}),\n\t),\n\tstatus: Type.Optional(StatusSchema),\n\tblockedBy: Type.Optional(\n\t\tType.Array(TaskId(\"Existing task id this task depends on.\"), {\n\t\t\tmaxItems: TODO_MAX_BLOCKED_BY,\n\t\t\tdescription:\n\t\t\t\t\"Initial dependency ids, create only (update rejects it; use addBlockedBy/removeBlockedBy there); use only for real ordering constraints.\",\n\t\t}),\n\t),\n\titems: Type.Optional(\n\t\tType.Array(CreateManyItemSchema, {\n\t\t\tminItems: 1,\n\t\t\tmaxItems: TODO_MAX_BATCH_ITEMS,\n\t\t\tdescription:\n\t\t\t\t\"create_many only: up to 20 pending tasks, created atomically in input order. Use key and blockedByKeys for dependencies within this batch.\",\n\t\t}),\n\t),\n\taddBlockedBy: Type.Optional(\n\t\tType.Array(TaskId(\"Existing task id that must complete first.\"), {\n\t\t\tmaxItems: TODO_MAX_BLOCKED_BY,\n\t\t\tdescription: \"Dependency ids to add on update; dependencies must exist and cannot create cycles.\",\n\t\t}),\n\t),\n\tremoveBlockedBy: Type.Optional(Type.Array(TaskId(\"Dependency id to detach.\"), { maxItems: TODO_MAX_BLOCKED_BY })),\n\taddBlocks: Type.Optional(\n\t\tType.Array(TaskId(\"Existing task id that must wait for this one.\"), {\n\t\t\tmaxItems: TODO_MAX_BLOCKED_BY,\n\t\t\tdescription:\n\t\t\t\t\"Update only: ids of tasks that cannot start until this task completes (the reverse of addBlockedBy); targets must exist and cannot create cycles.\",\n\t\t}),\n\t),\n\tremoveBlocks: Type.Optional(Type.Array(TaskId(\"Dependent task id to release.\"), { maxItems: TODO_MAX_BLOCKED_BY })),\n\towner: Type.Optional(\n\t\tType.String({\n\t\t\tmaxLength: TODO_MAX_OWNER_LENGTH,\n\t\t\tdescription:\n\t\t\t\t\"Optional owner or agent label for multi-agent coordination; on update an empty string removes it.\",\n\t\t}),\n\t),\n\tmetadata: Type.Optional(\n\t\tType.Record(Type.String({ maxLength: TODO_MAX_METADATA_KEY_LENGTH }), Type.Unknown(), {\n\t\t\tmaxProperties: TODO_MAX_METADATA_ENTRIES,\n\t\t\tdescription: \"Optional bounded JSON-like structured metadata; null values delete keys on update.\",\n\t\t}),\n\t),\n\tid: Type.Optional(TaskId(\"Task id, required for update, get, and delete.\")),\n\tincludeDeleted: Type.Optional(\n\t\tType.Boolean({\n\t\t\tdescription:\n\t\t\t\t\"Include deleted tombstones in unfiltered list output; an explicit status=deleted query includes them automatically.\",\n\t\t}),\n\t),\n\tlimit: Type.Optional(\n\t\tType.Integer({ minimum: 1, maximum: TODO_MAX_LIST_LIMIT, description: \"List page size (1 through 50).\" }),\n\t),\n\tafterId: Type.Optional(TaskId(\"List only tasks with ids greater than this id.\")),\n\tquery: Type.Optional(\n\t\tType.String({\n\t\t\tmaxLength: TODO_MAX_LIST_QUERY_LENGTH,\n\t\t\tdescription: \"Case-insensitive subject and description search for list.\",\n\t\t}),\n\t),\n\tunblockedOnly: Type.Optional(Type.Boolean({ description: \"List only tasks with no unresolved dependencies.\" })),\n\tconfirm: Type.Optional(Type.Boolean({ description: \"clear only: must be true.\" })),\n\texpectedCount: Type.Optional(\n\t\tType.Integer({ minimum: 0, description: \"clear only: exact current task count required as a safety check.\" }),\n\t),\n});\n\nexport type TodoParams = Static<typeof TodoParamsSchema>;\n\nexport const EMPTY_TODO_STATE: TodoState = { items: [], nextId: 1 };\n"]}
|