@code-yeongyu/senpi 2026.7.16 → 2026.7.17-2

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.
Files changed (149) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/dist/core/dynamic-prompt/build.d.ts +7 -0
  3. package/dist/core/dynamic-prompt/build.d.ts.map +1 -1
  4. package/dist/core/dynamic-prompt/build.js +5 -0
  5. package/dist/core/dynamic-prompt/build.js.map +1 -1
  6. package/dist/core/dynamic-prompt/workstation.d.ts +35 -0
  7. package/dist/core/dynamic-prompt/workstation.d.ts.map +1 -0
  8. package/dist/core/dynamic-prompt/workstation.js +81 -0
  9. package/dist/core/dynamic-prompt/workstation.js.map +1 -0
  10. package/dist/core/extensions/builtin/anthropic-web-search/index.d.ts +6 -2
  11. package/dist/core/extensions/builtin/anthropic-web-search/index.d.ts.map +1 -1
  12. package/dist/core/extensions/builtin/anthropic-web-search/index.js +73 -5
  13. package/dist/core/extensions/builtin/anthropic-web-search/index.js.map +1 -1
  14. package/dist/core/extensions/builtin/goal/command-registration.d.ts +1 -0
  15. package/dist/core/extensions/builtin/goal/command-registration.d.ts.map +1 -1
  16. package/dist/core/extensions/builtin/goal/command-registration.js +4 -5
  17. package/dist/core/extensions/builtin/goal/command-registration.js.map +1 -1
  18. package/dist/core/extensions/builtin/goal/elapsed-ticker.d.ts +43 -0
  19. package/dist/core/extensions/builtin/goal/elapsed-ticker.d.ts.map +1 -0
  20. package/dist/core/extensions/builtin/goal/elapsed-ticker.js +58 -0
  21. package/dist/core/extensions/builtin/goal/elapsed-ticker.js.map +1 -0
  22. package/dist/core/extensions/builtin/goal/index.d.ts.map +1 -1
  23. package/dist/core/extensions/builtin/goal/index.js +39 -14
  24. package/dist/core/extensions/builtin/goal/index.js.map +1 -1
  25. package/dist/core/extensions/builtin/goal/tool-registration.d.ts +1 -0
  26. package/dist/core/extensions/builtin/goal/tool-registration.d.ts.map +1 -1
  27. package/dist/core/extensions/builtin/goal/tool-registration.js +3 -4
  28. package/dist/core/extensions/builtin/goal/tool-registration.js.map +1 -1
  29. package/dist/core/extensions/builtin/goal/ui.d.ts +2 -2
  30. package/dist/core/extensions/builtin/goal/ui.d.ts.map +1 -1
  31. package/dist/core/extensions/builtin/goal/ui.js +8 -4
  32. package/dist/core/extensions/builtin/goal/ui.js.map +1 -1
  33. package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.d.ts.map +1 -1
  34. package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js +5 -1
  35. package/dist/core/extensions/builtin/prompt-preset/claude-fable-5.js.map +1 -1
  36. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.d.ts.map +1 -1
  37. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.js +5 -1
  38. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-5.js.map +1 -1
  39. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.d.ts.map +1 -1
  40. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.js +5 -1
  41. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-6.js.map +1 -1
  42. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.d.ts.map +1 -1
  43. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.js +5 -1
  44. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-7.js.map +1 -1
  45. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.d.ts.map +1 -1
  46. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.js +5 -1
  47. package/dist/core/extensions/builtin/prompt-preset/claude-opus-4-8.js.map +1 -1
  48. package/dist/core/extensions/builtin/prompt-preset/glm-5-2.js +1 -1
  49. package/dist/core/extensions/builtin/prompt-preset/glm-5-2.js.map +1 -1
  50. package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.js +1 -1
  51. package/dist/core/extensions/builtin/prompt-preset/gpt-5.2.js.map +1 -1
  52. package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.js +1 -1
  53. package/dist/core/extensions/builtin/prompt-preset/gpt-5.3-codex.js.map +1 -1
  54. package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.js +1 -1
  55. package/dist/core/extensions/builtin/prompt-preset/gpt-5.4.js.map +1 -1
  56. package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js +1 -1
  57. package/dist/core/extensions/builtin/prompt-preset/gpt-5.5.js.map +1 -1
  58. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js +1 -1
  59. package/dist/core/extensions/builtin/prompt-preset/gpt-5.6.js.map +1 -1
  60. package/dist/core/extensions/builtin/prompt-preset/gpt-5.js +1 -1
  61. package/dist/core/extensions/builtin/prompt-preset/gpt-5.js.map +1 -1
  62. package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.js +1 -1
  63. package/dist/core/extensions/builtin/prompt-preset/kimi-k2-6.js.map +1 -1
  64. package/dist/core/extensions/builtin/prompt-preset/kimi-k2-7.js +1 -1
  65. package/dist/core/extensions/builtin/prompt-preset/kimi-k2-7.js.map +1 -1
  66. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.d.ts +3 -0
  67. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.d.ts.map +1 -0
  68. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js +14 -0
  69. package/dist/core/extensions/builtin/prompt-preset/kimi-k3.js.map +1 -0
  70. package/dist/core/extensions/builtin/prompt-preset/presets.d.ts.map +1 -1
  71. package/dist/core/extensions/builtin/prompt-preset/presets.js +13 -0
  72. package/dist/core/extensions/builtin/prompt-preset/presets.js.map +1 -1
  73. package/dist/core/extensions/builtin/prompt-preset/settings.d.ts +1 -1
  74. package/dist/core/extensions/builtin/prompt-preset/settings.d.ts.map +1 -1
  75. package/dist/core/extensions/builtin/prompt-preset/settings.js +1 -0
  76. package/dist/core/extensions/builtin/prompt-preset/settings.js.map +1 -1
  77. package/dist/core/extensions/builtin/webfetch/webfetch/renderers.d.ts.map +1 -1
  78. package/dist/core/extensions/builtin/webfetch/webfetch/renderers.js +2 -1
  79. package/dist/core/extensions/builtin/webfetch/webfetch/renderers.js.map +1 -1
  80. package/dist/core/extensions/builtin/webfetch/webfetch/tool.d.ts +27 -0
  81. package/dist/core/extensions/builtin/webfetch/webfetch/tool.d.ts.map +1 -1
  82. package/dist/core/extensions/builtin/webfetch/webfetch/tool.js +60 -1
  83. package/dist/core/extensions/builtin/webfetch/webfetch/tool.js.map +1 -1
  84. package/dist/core/extensions/types.d.ts +5 -0
  85. package/dist/core/extensions/types.d.ts.map +1 -1
  86. package/dist/core/extensions/types.js.map +1 -1
  87. package/dist/core/model-config.d.ts +5 -0
  88. package/dist/core/model-config.d.ts.map +1 -1
  89. package/dist/core/model-config.js +1 -0
  90. package/dist/core/model-config.js.map +1 -1
  91. package/dist/modes/interactive/components/tool-execution-renderer.d.ts.map +1 -1
  92. package/dist/modes/interactive/components/tool-execution-renderer.js +1 -0
  93. package/dist/modes/interactive/components/tool-execution-renderer.js.map +1 -1
  94. package/docs/settings.md +1 -1
  95. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  96. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  97. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  98. package/examples/extensions/gondolin/package-lock.json +2 -2
  99. package/examples/extensions/gondolin/package.json +1 -1
  100. package/examples/extensions/sandbox/package-lock.json +2 -2
  101. package/examples/extensions/sandbox/package.json +1 -1
  102. package/examples/extensions/with-deps/package-lock.json +2 -2
  103. package/examples/extensions/with-deps/package.json +1 -1
  104. package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +37 -0
  105. package/node_modules/@code-yeongyu/senpi-codemode/package.json +3 -3
  106. package/node_modules/@code-yeongyu/senpi-codemode/src/index.ts +59 -19
  107. package/node_modules/@code-yeongyu/senpi-codemode/src/prompt/eval-prompt.ts +68 -2
  108. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/eval-tool.ts +6 -0
  109. package/node_modules/@code-yeongyu/senpi-codemode/src/tool/render.ts +6 -0
  110. package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
  111. package/node_modules/@earendil-works/pi-ai/README.md +1 -1
  112. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.d.ts.map +1 -1
  113. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js +58 -7
  114. package/node_modules/@earendil-works/pi-ai/dist/api/anthropic-messages.js.map +1 -1
  115. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts +2 -1
  116. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
  117. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +6 -1
  118. package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
  119. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts +70 -110
  120. package/node_modules/@earendil-works/pi-ai/dist/models.generated.d.ts.map +1 -1
  121. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.d.ts +26 -0
  122. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.d.ts.map +1 -1
  123. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.js +6 -0
  124. package/node_modules/@earendil-works/pi-ai/dist/providers/kimi-coding.models.js.map +1 -1
  125. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.js +3 -3
  126. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai-cn.models.js.map +1 -1
  127. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.js +3 -3
  128. package/node_modules/@earendil-works/pi-ai/dist/providers/moonshotai.models.js.map +1 -1
  129. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts +44 -0
  130. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.d.ts.map +1 -1
  131. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js +36 -0
  132. package/node_modules/@earendil-works/pi-ai/dist/providers/opencode-go.models.js.map +1 -1
  133. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js +20 -20
  134. package/node_modules/@earendil-works/pi-ai/dist/providers/openrouter.models.js.map +1 -1
  135. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.d.ts +0 -110
  136. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.d.ts.map +1 -1
  137. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.js +0 -90
  138. package/node_modules/@earendil-works/pi-ai/dist/providers/xai.models.js.map +1 -1
  139. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +14 -0
  140. package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
  141. package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
  142. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.d.ts +19 -0
  143. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.d.ts.map +1 -0
  144. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.js +171 -0
  145. package/node_modules/@earendil-works/pi-ai/dist/utils/tool-schema-compat.js.map +1 -0
  146. package/node_modules/@earendil-works/pi-ai/package.json +1 -1
  147. package/node_modules/@earendil-works/pi-pty/package.json +1 -1
  148. package/node_modules/@earendil-works/pi-tui/package.json +1 -1
  149. package/package.json +6 -6
@@ -0,0 +1,43 @@
1
+ import type { ExtensionContext } from "../../types.ts";
2
+ import type { Goal } from "./types.ts";
3
+ /** Footer live-elapsed refresh cadence while a goal is actively pursued. */
4
+ export declare const GOAL_ELAPSED_TICK_INTERVAL_MS = 1000;
5
+ /** Renders the goal footer segment for the current live elapsed second count. */
6
+ export type GoalElapsedRender = (ctx: ExtensionContext, goal: Goal, liveElapsedSeconds: number) => void;
7
+ export interface GoalElapsedTickerOptions {
8
+ readonly render: GoalElapsedRender;
9
+ /** Injectable clock for tests; defaults to Date.now. */
10
+ readonly now?: () => number;
11
+ }
12
+ /**
13
+ * Live elapsed seconds for an actively pursued goal: the committed
14
+ * `timeUsedSeconds` plus whole seconds since the current measurement window
15
+ * opened. Mirrors the rounding in `accountCurrentAgentTurn` so the footer never
16
+ * disagrees with what the next turn commits.
17
+ */
18
+ export declare function goalLiveElapsedSeconds(goal: Goal, measuredFromMilliseconds: number, nowMilliseconds: number): number;
19
+ /**
20
+ * Drives a once-per-second footer refresh while a goal is active so the
21
+ * "Pursuing goal (…)" elapsed time advances live instead of freezing between
22
+ * usage-accounting checkpoints. The interval is unref'd so it never keeps the
23
+ * process alive.
24
+ */
25
+ export declare class GoalElapsedTicker {
26
+ private readonly render;
27
+ private readonly now;
28
+ private intervalId;
29
+ private ctx;
30
+ private goal;
31
+ private measuredFromMilliseconds;
32
+ constructor(options: GoalElapsedTickerOptions);
33
+ get running(): boolean;
34
+ /**
35
+ * Point the ticker at the current goal and measurement window, render once
36
+ * immediately, and start the interval if it is not already running.
37
+ */
38
+ sync(ctx: ExtensionContext, goal: Goal, measuredFromMilliseconds: number): void;
39
+ /** Stop the interval and drop the retained context/goal snapshot. */
40
+ stop(): void;
41
+ private tick;
42
+ }
43
+ //# sourceMappingURL=elapsed-ticker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elapsed-ticker.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/elapsed-ticker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,4EAA4E;AAC5E,eAAO,MAAM,6BAA6B,OAAO,CAAC;AAElD,iFAAiF;AACjF,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,KAAK,IAAI,CAAC;AAExG,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,wDAAwD;IACxD,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CAC5B;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,IAAI,EAAE,wBAAwB,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,CAGpH;AAED;;;;;GAKG;AACH,qBAAa,iBAAiB;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAC3C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;IACnC,OAAO,CAAC,UAAU,CAA6B;IAC/C,OAAO,CAAC,GAAG,CAA+B;IAC1C,OAAO,CAAC,IAAI,CAAmB;IAC/B,OAAO,CAAC,wBAAwB,CAAK;IAErC,YAAY,OAAO,EAAE,wBAAwB,EAG5C;IAED,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;;OAGG;IACH,IAAI,CAAC,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,wBAAwB,EAAE,MAAM,GAAG,IAAI,CAS9E;IAED,qEAAqE;IACrE,IAAI,IAAI,IAAI,CAOX;IAED,OAAO,CAAC,IAAI;CAIZ"}
@@ -0,0 +1,58 @@
1
+ /** Footer live-elapsed refresh cadence while a goal is actively pursued. */
2
+ export const GOAL_ELAPSED_TICK_INTERVAL_MS = 1000;
3
+ /**
4
+ * Live elapsed seconds for an actively pursued goal: the committed
5
+ * `timeUsedSeconds` plus whole seconds since the current measurement window
6
+ * opened. Mirrors the rounding in `accountCurrentAgentTurn` so the footer never
7
+ * disagrees with what the next turn commits.
8
+ */
9
+ export function goalLiveElapsedSeconds(goal, measuredFromMilliseconds, nowMilliseconds) {
10
+ const elapsedSeconds = Math.max(0, Math.round((nowMilliseconds - measuredFromMilliseconds) / 1000));
11
+ return goal.timeUsedSeconds + elapsedSeconds;
12
+ }
13
+ /**
14
+ * Drives a once-per-second footer refresh while a goal is active so the
15
+ * "Pursuing goal (…)" elapsed time advances live instead of freezing between
16
+ * usage-accounting checkpoints. The interval is unref'd so it never keeps the
17
+ * process alive.
18
+ */
19
+ export class GoalElapsedTicker {
20
+ constructor(options) {
21
+ this.measuredFromMilliseconds = 0;
22
+ this.render = options.render;
23
+ this.now = options.now ?? Date.now;
24
+ }
25
+ get running() {
26
+ return this.intervalId !== undefined;
27
+ }
28
+ /**
29
+ * Point the ticker at the current goal and measurement window, render once
30
+ * immediately, and start the interval if it is not already running.
31
+ */
32
+ sync(ctx, goal, measuredFromMilliseconds) {
33
+ this.ctx = ctx;
34
+ this.goal = goal;
35
+ this.measuredFromMilliseconds = measuredFromMilliseconds;
36
+ this.tick();
37
+ if (this.intervalId !== undefined)
38
+ return;
39
+ const handle = setInterval(() => this.tick(), GOAL_ELAPSED_TICK_INTERVAL_MS);
40
+ handle.unref();
41
+ this.intervalId = handle;
42
+ }
43
+ /** Stop the interval and drop the retained context/goal snapshot. */
44
+ stop() {
45
+ if (this.intervalId !== undefined) {
46
+ clearInterval(this.intervalId);
47
+ this.intervalId = undefined;
48
+ }
49
+ this.ctx = undefined;
50
+ this.goal = undefined;
51
+ }
52
+ tick() {
53
+ if (this.ctx === undefined || this.goal === undefined)
54
+ return;
55
+ this.render(this.ctx, this.goal, goalLiveElapsedSeconds(this.goal, this.measuredFromMilliseconds, this.now()));
56
+ }
57
+ }
58
+ //# sourceMappingURL=elapsed-ticker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elapsed-ticker.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/elapsed-ticker.ts"],"names":[],"mappings":"AAGA,4EAA4E;AAC5E,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,CAAC;AAWlD;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAU,EAAE,wBAAgC,EAAE,eAAuB;IAC3G,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CA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I,CAAC,GAAG,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS;YAAE,OAAO;QAC9D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,sBAAsB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,wBAAwB,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAChH,CAAC;CACD","sourcesContent":["import type { ExtensionContext } from \"../../types.ts\";\nimport type { Goal } from \"./types.ts\";\n\n/** Footer live-elapsed refresh cadence while a goal is actively pursued. */\nexport const GOAL_ELAPSED_TICK_INTERVAL_MS = 1000;\n\n/** Renders the goal footer segment for the current live elapsed second count. */\nexport type GoalElapsedRender = (ctx: ExtensionContext, goal: Goal, liveElapsedSeconds: number) => void;\n\nexport interface GoalElapsedTickerOptions {\n\treadonly render: GoalElapsedRender;\n\t/** Injectable clock for tests; defaults to Date.now. */\n\treadonly now?: () => number;\n}\n\n/**\n * Live elapsed seconds for an actively pursued goal: the committed\n * `timeUsedSeconds` plus whole seconds since the current measurement window\n * opened. Mirrors the rounding in `accountCurrentAgentTurn` so the footer never\n * disagrees with what the next turn commits.\n */\nexport function goalLiveElapsedSeconds(goal: Goal, measuredFromMilliseconds: number, nowMilliseconds: number): number {\n\tconst elapsedSeconds = Math.max(0, Math.round((nowMilliseconds - measuredFromMilliseconds) / 1000));\n\treturn goal.timeUsedSeconds + elapsedSeconds;\n}\n\n/**\n * Drives a once-per-second footer refresh while a goal is active so the\n * \"Pursuing goal (…)\" elapsed time advances live instead of freezing between\n * usage-accounting checkpoints. The interval is unref'd so it never keeps the\n * process alive.\n */\nexport class GoalElapsedTicker {\n\tprivate readonly render: GoalElapsedRender;\n\tprivate readonly now: () => number;\n\tprivate intervalId: NodeJS.Timeout | undefined;\n\tprivate ctx: ExtensionContext | undefined;\n\tprivate goal: Goal | undefined;\n\tprivate measuredFromMilliseconds = 0;\n\n\tconstructor(options: GoalElapsedTickerOptions) {\n\t\tthis.render = options.render;\n\t\tthis.now = options.now ?? Date.now;\n\t}\n\n\tget running(): boolean {\n\t\treturn this.intervalId !== undefined;\n\t}\n\n\t/**\n\t * Point the ticker at the current goal and measurement window, render once\n\t * immediately, and start the interval if it is not already running.\n\t */\n\tsync(ctx: ExtensionContext, goal: Goal, measuredFromMilliseconds: number): void {\n\t\tthis.ctx = ctx;\n\t\tthis.goal = goal;\n\t\tthis.measuredFromMilliseconds = measuredFromMilliseconds;\n\t\tthis.tick();\n\t\tif (this.intervalId !== undefined) return;\n\t\tconst handle = setInterval(() => this.tick(), GOAL_ELAPSED_TICK_INTERVAL_MS);\n\t\thandle.unref();\n\t\tthis.intervalId = handle;\n\t}\n\n\t/** Stop the interval and drop the retained context/goal snapshot. */\n\tstop(): void {\n\t\tif (this.intervalId !== undefined) {\n\t\t\tclearInterval(this.intervalId);\n\t\t\tthis.intervalId = undefined;\n\t\t}\n\t\tthis.ctx = undefined;\n\t\tthis.goal = undefined;\n\t}\n\n\tprivate tick(): void {\n\t\tif (this.ctx === undefined || this.goal === undefined) return;\n\t\tthis.render(this.ctx, this.goal, goalLiveElapsedSeconds(this.goal, this.measuredFromMilliseconds, this.now()));\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,gBAAgB,CAAC;AA0BrE,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CA+I5D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,gBAAgB,CAAC;AA2BrE,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAkL5D"}
@@ -3,6 +3,7 @@ import { join } from "node:path";
3
3
  import { getAgentDir } from "../../../../config.js";
4
4
  import { registerGoalCommand } from "./command-registration.js";
5
5
  import { shouldQueueGoalContinuationAfterAgentEnd, shouldQueueGoalContinuationWhenIdle } from "./continuation.js";
6
+ import { GoalElapsedTicker } from "./elapsed-ticker.js";
6
7
  import { formatGoalForTool, goalStatusLabel } from "./format.js";
7
8
  import { buildContinuationPrompt } from "./prompt.js";
8
9
  import { accountGoalUsage, readGoal, updateGoal } from "./store.js";
@@ -18,11 +19,24 @@ export default function goalExtension(pi) {
18
19
  let agentTurnInProgress = false;
19
20
  let agentGoalAccounting = null;
20
21
  let completedThisTurnGoalId = null;
22
+ const goalTicker = new GoalElapsedTicker({
23
+ render: (renderCtx, renderGoal, live) => {
24
+ try {
25
+ updateGoalUi(renderCtx, renderGoal, live);
26
+ }
27
+ catch (error) {
28
+ if (error instanceof Error && error.message.startsWith(STALE_EXTENSION_CONTEXT_ERROR_PREFIX))
29
+ return;
30
+ throw error;
31
+ }
32
+ },
33
+ });
21
34
  registerGoalTools(pi, {
22
35
  goalStoreRef,
23
36
  accountCurrentAgentTurn,
24
37
  beginAgentGoalAccounting,
25
38
  markGoalCompletedThisTurn,
39
+ refreshGoalUi,
26
40
  });
27
41
  registerGoalCommand(pi, {
28
42
  goalStoreRef,
@@ -31,6 +45,7 @@ export default function goalExtension(pi) {
31
45
  stopAgentGoalAccounting,
32
46
  clearAgentGoalAccounting,
33
47
  queueGoalContinuation,
48
+ refreshGoalUi,
34
49
  });
35
50
  pi.on("session_start", async (event, ctx) => {
36
51
  const goal = await readGoal(goalStoreRef(ctx));
@@ -40,7 +55,7 @@ export default function goalExtension(pi) {
40
55
  else {
41
56
  clearAgentGoalAccounting();
42
57
  }
43
- updateGoalUi(ctx, goal);
58
+ refreshGoalUi(ctx, goal);
44
59
  if (await maybePromptResumePausedGoal(pi, ctx, event.reason, goal)) {
45
60
  return;
46
61
  }
@@ -70,7 +85,7 @@ export default function goalExtension(pi) {
70
85
  else {
71
86
  clearAgentGoalAccounting();
72
87
  }
73
- updateGoalUiBestEffort(ctx, goal);
88
+ refreshGoalUiBestEffort(ctx, goal);
74
89
  if (goal?.status === "active" &&
75
90
  !ctx.signal?.aborted &&
76
91
  shouldQueueGoalContinuationAfterAgentEnd(goal, ctx.hasPendingMessages(), event.messages)) {
@@ -82,6 +97,7 @@ export default function goalExtension(pi) {
82
97
  await accountCurrentAgentTurn(ctx, EMPTY_USAGE, "active");
83
98
  }
84
99
  clearAgentGoalAccounting();
100
+ goalTicker.stop();
85
101
  });
86
102
  async function maybePromptResumePausedGoal(pi, ctx, sessionStartReason, goal) {
87
103
  if (!isResumeOfPausedGoal(ctx, sessionStartReason, goal)) {
@@ -95,7 +111,7 @@ export default function goalExtension(pi) {
95
111
  return true;
96
112
  const resumed = await updateGoal(goalStoreRef(ctx), { status: "active" });
97
113
  beginAgentGoalAccounting(resumed);
98
- updateGoalUi(ctx, resumed);
114
+ refreshGoalUi(ctx, resumed);
99
115
  ctx.ui.notify(`Goal ${goalStatusLabel(resumed.status)}\n${formatGoalForTool(resumed)}`, "info");
100
116
  queueGoalContinuation(pi, ctx, resumed);
101
117
  return true;
@@ -125,6 +141,26 @@ export default function goalExtension(pi) {
125
141
  agentGoalAccounting = null;
126
142
  completedThisTurnGoalId = null;
127
143
  }
144
+ function refreshGoalUi(ctx, goal) {
145
+ const accounting = agentGoalAccounting;
146
+ if (ctx.hasUI && goal?.status === "active" && accounting?.goalId === goal.id) {
147
+ goalTicker.sync(ctx, goal, accounting.measuredFromMilliseconds);
148
+ return;
149
+ }
150
+ goalTicker.stop();
151
+ updateGoalUi(ctx, goal);
152
+ }
153
+ function refreshGoalUiBestEffort(ctx, goal) {
154
+ try {
155
+ refreshGoalUi(ctx, goal);
156
+ }
157
+ catch (error) {
158
+ if (error instanceof Error && error.message.startsWith(STALE_EXTENSION_CONTEXT_ERROR_PREFIX)) {
159
+ return;
160
+ }
161
+ throw error;
162
+ }
163
+ }
128
164
  async function accountCurrentAgentTurn(ctx, usage, mode) {
129
165
  const accounting = agentGoalAccounting;
130
166
  const ref = goalStoreRef(ctx);
@@ -142,17 +178,6 @@ export default function goalExtension(pi) {
142
178
  return goal;
143
179
  }
144
180
  }
145
- function updateGoalUiBestEffort(ctx, goal) {
146
- try {
147
- updateGoalUi(ctx, goal);
148
- }
149
- catch (error) {
150
- if (error instanceof Error && error.message.startsWith(STALE_EXTENSION_CONTEXT_ERROR_PREFIX)) {
151
- return;
152
- }
153
- throw error;
154
- }
155
- }
156
181
  function isResumeOfPausedGoal(ctx, sessionStartReason, goal) {
157
182
  return (sessionStartReason === "resume" &&
158
183
  goal?.status === "paused" &&
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,wCAAwC,EAAE,mCAAmC,EAAE,MAAM,mBAAmB,CAAC;AAClH,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,8BAA8B,GAAG,mBAAmB,CAAC;AAC3D,MAAM,kBAAkB,GAAG,aAAa,CAAC;AACzC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,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAChC,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC;YAAE,SAAS;QAChD,KAAK,CAAC,KAAK,IAAI,iBAAiB,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACzD,KAAK,CAAC,MAAM,IAAI,iBAAiB,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC3D,KAAK,CAAC,SAAS,IAAI,iBAAiB,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACjE,KAAK,CAAC,UAAU,IAAI,iBAAiB,CAAC,OAAO,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QACnE,KAAK,CAAC,WAAW,IAAI,iBAAiB,CAAC,OAAO,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,SAAS,uBAAuB,CAAC,OAAgB;IAChD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,KAAK,CAAC;IACrC,OAAO,OAAO,CAAC,IAAI,KAAK,WAAW,IAAI,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,iBAAiB,CAAC,KAA8B,EAAE,GAAW;IACrE,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACxE,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { join } from \"node:path\";\nimport { getAgentDir } from \"../../../../config.ts\";\nimport type { ExtensionAPI, ExtensionContext } from \"../../types.ts\";\nimport { registerGoalCommand } from \"./command-registration.ts\";\nimport { shouldQueueGoalContinuationAfterAgentEnd, shouldQueueGoalContinuationWhenIdle } from \"./continuation.ts\";\nimport { formatGoalForTool, goalStatusLabel } from \"./format.ts\";\nimport { buildContinuationPrompt } from \"./prompt.ts\";\nimport { accountGoalUsage, readGoal, updateGoal } from \"./store.ts\";\nimport { registerGoalTools } from \"./tool-registration.ts\";\nimport type { Goal, GoalAccountingMode, GoalStoreRef, TokenUsageSnapshot } from \"./types.ts\";\nimport { isRecord } from \"./types.ts\";\nimport { updateGoalUi } from \"./ui.ts\";\n\nconst GOAL_CONTINUATION_MESSAGE_TYPE = \"goal-continuation\";\nconst RESUME_GOAL_CHOICE = \"Resume goal\";\nconst LEAVE_GOAL_PAUSED_CHOICE = \"Leave paused\";\nconst EMPTY_USAGE: TokenUsageSnapshot = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0 };\nconst STALE_EXTENSION_CONTEXT_ERROR_PREFIX = \"This extension ctx is stale after session replacement or reload.\";\n\ntype AssistantUsageMessage = {\n\trole: \"assistant\";\n\tusage: Record<string, unknown>;\n};\ntype AgentGoalAccounting = {\n\tgoalId: string;\n\tmeasuredFromMilliseconds: number;\n};\n\nexport default function goalExtension(pi: ExtensionAPI): void {\n\tlet agentTurnInProgress = false;\n\tlet agentGoalAccounting: AgentGoalAccounting | null = null;\n\tlet completedThisTurnGoalId: string | null = null;\n\n\tregisterGoalTools(pi, {\n\t\tgoalStoreRef,\n\t\taccountCurrentAgentTurn,\n\t\tbeginAgentGoalAccounting,\n\t\tmarkGoalCompletedThisTurn,\n\t});\n\tregisterGoalCommand(pi, {\n\t\tgoalStoreRef,\n\t\taccountCurrentAgentTurn,\n\t\tbeginAgentGoalAccounting,\n\t\tstopAgentGoalAccounting,\n\t\tclearAgentGoalAccounting,\n\t\tqueueGoalContinuation,\n\t});\n\n\tpi.on(\"session_start\", async (event, ctx) => {\n\t\tconst goal = await readGoal(goalStoreRef(ctx));\n\t\tif (goal?.status === \"active\") {\n\t\t\tbeginAgentGoalAccounting(goal);\n\t\t} else {\n\t\t\tclearAgentGoalAccounting();\n\t\t}\n\t\tupdateGoalUi(ctx, goal);\n\t\tif (await maybePromptResumePausedGoal(pi, ctx, event.reason, goal)) {\n\t\t\treturn;\n\t\t}\n\t\tif (shouldQueueGoalContinuationWhenIdle(goal, ctx.isIdle(), ctx.hasPendingMessages())) {\n\t\t\tqueueHiddenGoalPrompt(pi, buildContinuationPrompt(goal));\n\t\t}\n\t});\n\n\tpi.on(\"agent_start\", async (_event, ctx) => {\n\t\tagentTurnInProgress = true;\n\t\tcompletedThisTurnGoalId = null;\n\t\tconst goal = await readGoal(goalStoreRef(ctx));\n\t\tif (goal?.status === \"active\") {\n\t\t\tbeginAgentGoalAccounting(goal);\n\t\t} else {\n\t\t\tagentGoalAccounting = null;\n\t\t}\n\t});\n\n\tpi.on(\"agent_end\", async (event, ctx) => {\n\t\tconst mode: GoalAccountingMode = completedThisTurnGoalId === null ? \"active\" : \"activeOrComplete\";\n\t\tconst goal = await accountCurrentAgentTurn(ctx, collectAssistantUsage(event.messages), mode);\n\t\tagentTurnInProgress = false;\n\t\tcompletedThisTurnGoalId = null;\n\t\tif (goal?.status === \"active\") {\n\t\t\tbeginAgentGoalAccounting(goal);\n\t\t} else {\n\t\t\tclearAgentGoalAccounting();\n\t\t}\n\t\tupdateGoalUiBestEffort(ctx, goal);\n\t\tif (\n\t\t\tgoal?.status === \"active\" &&\n\t\t\t!ctx.signal?.aborted &&\n\t\t\tshouldQueueGoalContinuationAfterAgentEnd(goal, ctx.hasPendingMessages(), event.messages)\n\t\t) {\n\t\t\tqueueHiddenGoalPrompt(pi, buildContinuationPrompt(goal));\n\t\t}\n\t});\n\n\tpi.on(\"session_shutdown\", async (_event, ctx) => {\n\t\tif (agentGoalAccounting !== null) {\n\t\t\tawait accountCurrentAgentTurn(ctx, EMPTY_USAGE, \"active\");\n\t\t}\n\t\tclearAgentGoalAccounting();\n\t});\n\n\tasync function maybePromptResumePausedGoal(\n\t\tpi: ExtensionAPI,\n\t\tctx: ExtensionContext,\n\t\tsessionStartReason: string,\n\t\tgoal: Goal | null,\n\t): Promise<boolean> {\n\t\tif (!isResumeOfPausedGoal(ctx, sessionStartReason, goal)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst choice = await ctx.ui.select(`Resume paused goal?\\nGoal: ${goal.objective}`, [\n\t\t\tRESUME_GOAL_CHOICE,\n\t\t\tLEAVE_GOAL_PAUSED_CHOICE,\n\t\t]);\n\t\tif (choice !== RESUME_GOAL_CHOICE) return true;\n\n\t\tconst resumed = await updateGoal(goalStoreRef(ctx), { status: \"active\" });\n\t\tbeginAgentGoalAccounting(resumed);\n\t\tupdateGoalUi(ctx, resumed);\n\t\tctx.ui.notify(`Goal ${goalStatusLabel(resumed.status)}\\n${formatGoalForTool(resumed)}`, \"info\");\n\t\tqueueGoalContinuation(pi, ctx, resumed);\n\t\treturn true;\n\t}\n\n\tfunction beginAgentGoalAccounting(goal: Goal): void {\n\t\tif (goal.status !== \"active\") return;\n\t\tif (agentGoalAccounting?.goalId === goal.id) return;\n\t\tagentGoalAccounting = { goalId: goal.id, measuredFromMilliseconds: Date.now() };\n\t}\n\n\tfunction markGoalCompletedThisTurn(goal: Goal): void {\n\t\tif (!agentTurnInProgress) return;\n\t\tcompletedThisTurnGoalId = goal.id;\n\t\tagentGoalAccounting = { goalId: goal.id, measuredFromMilliseconds: Date.now() };\n\t}\n\n\tfunction stopAgentGoalAccounting(goalId: string): void {\n\t\tif (agentGoalAccounting?.goalId === goalId) {\n\t\t\tagentGoalAccounting = null;\n\t\t}\n\t\tif (completedThisTurnGoalId === goalId) {\n\t\t\tcompletedThisTurnGoalId = null;\n\t\t}\n\t}\n\n\tfunction clearAgentGoalAccounting(): void {\n\t\tagentGoalAccounting = null;\n\t\tcompletedThisTurnGoalId = null;\n\t}\n\n\tasync function accountCurrentAgentTurn(\n\t\tctx: ExtensionContext,\n\t\tusage: TokenUsageSnapshot,\n\t\tmode: GoalAccountingMode,\n\t): Promise<Goal | null> {\n\t\tconst accounting = agentGoalAccounting;\n\t\tconst ref = goalStoreRef(ctx);\n\t\tif (accounting === null) return readGoal(ref);\n\n\t\tconst now = Date.now();\n\t\tconst elapsedSeconds = Math.max(0, Math.round((now - accounting.measuredFromMilliseconds) / 1000));\n\t\tconst goal = await accountGoalUsage(ref, usage, elapsedSeconds, mode, accounting.goalId);\n\t\tif (goal?.id === accounting.goalId) {\n\t\t\tagentGoalAccounting = { goalId: accounting.goalId, measuredFromMilliseconds: now };\n\t\t} else {\n\t\t\tclearAgentGoalAccounting();\n\t\t}\n\t\treturn goal;\n\t}\n}\n\nfunction updateGoalUiBestEffort(ctx: ExtensionContext, goal: Goal | null): void {\n\ttry {\n\t\tupdateGoalUi(ctx, goal);\n\t} catch (error) {\n\t\tif (error instanceof Error && error.message.startsWith(STALE_EXTENSION_CONTEXT_ERROR_PREFIX)) {\n\t\t\treturn;\n\t\t}\n\t\tthrow error;\n\t}\n}\n\nfunction isResumeOfPausedGoal(ctx: ExtensionContext, sessionStartReason: string, goal: Goal | null): goal is Goal {\n\treturn (\n\t\tsessionStartReason === \"resume\" &&\n\t\tgoal?.status === \"paused\" &&\n\t\tctx.hasUI &&\n\t\tctx.isIdle() &&\n\t\t!ctx.hasPendingMessages()\n\t);\n}\n\nfunction queueGoalContinuation(pi: ExtensionAPI, ctx: ExtensionContext, goal: Goal): void {\n\tif (shouldQueueGoalContinuationWhenIdle(goal, ctx.isIdle(), ctx.hasPendingMessages())) {\n\t\tqueueHiddenGoalPrompt(pi, buildContinuationPrompt(goal));\n\t}\n}\n\nfunction queueHiddenGoalPrompt(pi: ExtensionAPI, content: string): void {\n\tpi.sendMessage(\n\t\t{ customType: GOAL_CONTINUATION_MESSAGE_TYPE, content, display: false },\n\t\t{ triggerTurn: true, deliverAs: \"followUp\" },\n\t);\n}\n\nfunction goalStoreRef(ctx: ExtensionContext): GoalStoreRef {\n\tconst sessionFile = ctx.sessionManager.getSessionFile();\n\tconst baseDir =\n\t\tsessionFile === undefined\n\t\t\t? join(getAgentDir(), \"extensions\", \"goal\", \"no-session\", cwdStoreKey(ctx.cwd))\n\t\t\t: join(ctx.sessionManager.getSessionDir(), \"extensions\", \"goal\");\n\n\treturn {\n\t\tbaseDir,\n\t\tthreadId: ctx.sessionManager.getSessionId(),\n\t};\n}\n\nfunction cwdStoreKey(cwd: string): string {\n\treturn createHash(\"sha256\").update(cwd).digest(\"hex\").slice(0, 24);\n}\n\nfunction collectAssistantUsage(messages: unknown[]): TokenUsageSnapshot {\n\tconst usage: TokenUsageSnapshot = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0 };\n\tfor (const message of messages) {\n\t\tif (!isAssistantUsageMessage(message)) continue;\n\t\tusage.input += numericUsageField(message.usage, \"input\");\n\t\tusage.output += numericUsageField(message.usage, \"output\");\n\t\tusage.cacheRead += numericUsageField(message.usage, \"cacheRead\");\n\t\tusage.cacheWrite += numericUsageField(message.usage, \"cacheWrite\");\n\t\tusage.totalTokens += numericUsageField(message.usage, \"totalTokens\");\n\t}\n\treturn usage;\n}\n\nfunction isAssistantUsageMessage(message: unknown): message is AssistantUsageMessage {\n\tif (!isRecord(message)) return false;\n\treturn message.role === \"assistant\" && isRecord(message.usage);\n}\n\nfunction numericUsageField(usage: Record<string, unknown>, key: string): number {\n\tconst value = usage[key];\n\treturn typeof value === \"number\" && Number.isFinite(value) ? value : 0;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,wCAAwC,EAAE,mCAAmC,EAAE,MAAM,mBAAmB,CAAC;AAClH,OAAO,EAAE,iBAAiB,EAAE,MAAM,q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SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;IACvG,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAChC,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC;YAAE,SAAS;QAChD,KAAK,CAAC,KAAK,IAAI,iBAAiB,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACzD,KAAK,CAAC,MAAM,IAAI,iBAAiB,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC3D,KAAK,CAAC,SAAS,IAAI,iBAAiB,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACjE,KAAK,CAAC,UAAU,IAAI,iBAAiB,CAAC,OAAO,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QACnE,KAAK,CAAC,WAAW,IAAI,iBAAiB,CAAC,OAAO,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,SAAS,uBAAuB,CAAC,OAAgB;IAChD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,KAAK,CAAC;IACrC,OAAO,OAAO,CAAC,IAAI,KAAK,WAAW,IAAI,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,iBAAiB,CAAC,KAA8B,EAAE,GAAW;IACrE,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACxE,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { join } from \"node:path\";\nimport { getAgentDir } from \"../../../../config.ts\";\nimport type { ExtensionAPI, ExtensionContext } from \"../../types.ts\";\nimport { registerGoalCommand } from \"./command-registration.ts\";\nimport { shouldQueueGoalContinuationAfterAgentEnd, shouldQueueGoalContinuationWhenIdle } from \"./continuation.ts\";\nimport { GoalElapsedTicker } from \"./elapsed-ticker.ts\";\nimport { formatGoalForTool, goalStatusLabel } from \"./format.ts\";\nimport { buildContinuationPrompt } from \"./prompt.ts\";\nimport { accountGoalUsage, readGoal, updateGoal } from \"./store.ts\";\nimport { registerGoalTools } from \"./tool-registration.ts\";\nimport type { Goal, GoalAccountingMode, GoalStoreRef, TokenUsageSnapshot } from \"./types.ts\";\nimport { isRecord } from \"./types.ts\";\nimport { updateGoalUi } from \"./ui.ts\";\n\nconst GOAL_CONTINUATION_MESSAGE_TYPE = \"goal-continuation\";\nconst RESUME_GOAL_CHOICE = \"Resume goal\";\nconst LEAVE_GOAL_PAUSED_CHOICE = \"Leave paused\";\nconst EMPTY_USAGE: TokenUsageSnapshot = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0 };\nconst STALE_EXTENSION_CONTEXT_ERROR_PREFIX = \"This extension ctx is stale after session replacement or reload.\";\n\ntype AssistantUsageMessage = {\n\trole: \"assistant\";\n\tusage: Record<string, unknown>;\n};\ntype AgentGoalAccounting = {\n\tgoalId: string;\n\tmeasuredFromMilliseconds: number;\n};\n\nexport default function goalExtension(pi: ExtensionAPI): void {\n\tlet agentTurnInProgress = false;\n\tlet agentGoalAccounting: AgentGoalAccounting | null = null;\n\tlet completedThisTurnGoalId: string | null = null;\n\n\tconst goalTicker = new GoalElapsedTicker({\n\t\trender: (renderCtx, renderGoal, live) => {\n\t\t\ttry {\n\t\t\t\tupdateGoalUi(renderCtx, renderGoal, live);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof Error && error.message.startsWith(STALE_EXTENSION_CONTEXT_ERROR_PREFIX)) return;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t});\n\n\tregisterGoalTools(pi, {\n\t\tgoalStoreRef,\n\t\taccountCurrentAgentTurn,\n\t\tbeginAgentGoalAccounting,\n\t\tmarkGoalCompletedThisTurn,\n\t\trefreshGoalUi,\n\t});\n\tregisterGoalCommand(pi, {\n\t\tgoalStoreRef,\n\t\taccountCurrentAgentTurn,\n\t\tbeginAgentGoalAccounting,\n\t\tstopAgentGoalAccounting,\n\t\tclearAgentGoalAccounting,\n\t\tqueueGoalContinuation,\n\t\trefreshGoalUi,\n\t});\n\n\tpi.on(\"session_start\", async (event, ctx) => {\n\t\tconst goal = await readGoal(goalStoreRef(ctx));\n\t\tif (goal?.status === \"active\") {\n\t\t\tbeginAgentGoalAccounting(goal);\n\t\t} else {\n\t\t\tclearAgentGoalAccounting();\n\t\t}\n\t\trefreshGoalUi(ctx, goal);\n\t\tif (await maybePromptResumePausedGoal(pi, ctx, event.reason, goal)) {\n\t\t\treturn;\n\t\t}\n\t\tif (shouldQueueGoalContinuationWhenIdle(goal, ctx.isIdle(), ctx.hasPendingMessages())) {\n\t\t\tqueueHiddenGoalPrompt(pi, buildContinuationPrompt(goal));\n\t\t}\n\t});\n\n\tpi.on(\"agent_start\", async (_event, ctx) => {\n\t\tagentTurnInProgress = true;\n\t\tcompletedThisTurnGoalId = null;\n\t\tconst goal = await readGoal(goalStoreRef(ctx));\n\t\tif (goal?.status === \"active\") {\n\t\t\tbeginAgentGoalAccounting(goal);\n\t\t} else {\n\t\t\tagentGoalAccounting = null;\n\t\t}\n\t});\n\n\tpi.on(\"agent_end\", async (event, ctx) => {\n\t\tconst mode: GoalAccountingMode = completedThisTurnGoalId === null ? \"active\" : \"activeOrComplete\";\n\t\tconst goal = await accountCurrentAgentTurn(ctx, collectAssistantUsage(event.messages), mode);\n\t\tagentTurnInProgress = false;\n\t\tcompletedThisTurnGoalId = null;\n\t\tif (goal?.status === \"active\") {\n\t\t\tbeginAgentGoalAccounting(goal);\n\t\t} else {\n\t\t\tclearAgentGoalAccounting();\n\t\t}\n\t\trefreshGoalUiBestEffort(ctx, goal);\n\t\tif (\n\t\t\tgoal?.status === \"active\" &&\n\t\t\t!ctx.signal?.aborted &&\n\t\t\tshouldQueueGoalContinuationAfterAgentEnd(goal, ctx.hasPendingMessages(), event.messages)\n\t\t) {\n\t\t\tqueueHiddenGoalPrompt(pi, buildContinuationPrompt(goal));\n\t\t}\n\t});\n\n\tpi.on(\"session_shutdown\", async (_event, ctx) => {\n\t\tif (agentGoalAccounting !== null) {\n\t\t\tawait accountCurrentAgentTurn(ctx, EMPTY_USAGE, \"active\");\n\t\t}\n\t\tclearAgentGoalAccounting();\n\t\tgoalTicker.stop();\n\t});\n\n\tasync function maybePromptResumePausedGoal(\n\t\tpi: ExtensionAPI,\n\t\tctx: ExtensionContext,\n\t\tsessionStartReason: string,\n\t\tgoal: Goal | null,\n\t): Promise<boolean> {\n\t\tif (!isResumeOfPausedGoal(ctx, sessionStartReason, goal)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst choice = await ctx.ui.select(`Resume paused goal?\\nGoal: ${goal.objective}`, [\n\t\t\tRESUME_GOAL_CHOICE,\n\t\t\tLEAVE_GOAL_PAUSED_CHOICE,\n\t\t]);\n\t\tif (choice !== RESUME_GOAL_CHOICE) return true;\n\n\t\tconst resumed = await updateGoal(goalStoreRef(ctx), { status: \"active\" });\n\t\tbeginAgentGoalAccounting(resumed);\n\t\trefreshGoalUi(ctx, resumed);\n\t\tctx.ui.notify(`Goal ${goalStatusLabel(resumed.status)}\\n${formatGoalForTool(resumed)}`, \"info\");\n\t\tqueueGoalContinuation(pi, ctx, resumed);\n\t\treturn true;\n\t}\n\n\tfunction beginAgentGoalAccounting(goal: Goal): void {\n\t\tif (goal.status !== \"active\") return;\n\t\tif (agentGoalAccounting?.goalId === goal.id) return;\n\t\tagentGoalAccounting = { goalId: goal.id, measuredFromMilliseconds: Date.now() };\n\t}\n\n\tfunction markGoalCompletedThisTurn(goal: Goal): void {\n\t\tif (!agentTurnInProgress) return;\n\t\tcompletedThisTurnGoalId = goal.id;\n\t\tagentGoalAccounting = { goalId: goal.id, measuredFromMilliseconds: Date.now() };\n\t}\n\n\tfunction stopAgentGoalAccounting(goalId: string): void {\n\t\tif (agentGoalAccounting?.goalId === goalId) {\n\t\t\tagentGoalAccounting = null;\n\t\t}\n\t\tif (completedThisTurnGoalId === goalId) {\n\t\t\tcompletedThisTurnGoalId = null;\n\t\t}\n\t}\n\n\tfunction clearAgentGoalAccounting(): void {\n\t\tagentGoalAccounting = null;\n\t\tcompletedThisTurnGoalId = null;\n\t}\n\n\tfunction refreshGoalUi(ctx: ExtensionContext, goal: Goal | null): void {\n\t\tconst accounting = agentGoalAccounting;\n\t\tif (ctx.hasUI && goal?.status === \"active\" && accounting?.goalId === goal.id) {\n\t\t\tgoalTicker.sync(ctx, goal, accounting.measuredFromMilliseconds);\n\t\t\treturn;\n\t\t}\n\t\tgoalTicker.stop();\n\t\tupdateGoalUi(ctx, goal);\n\t}\n\n\tfunction refreshGoalUiBestEffort(ctx: ExtensionContext, goal: Goal | null): void {\n\t\ttry {\n\t\t\trefreshGoalUi(ctx, goal);\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error && error.message.startsWith(STALE_EXTENSION_CONTEXT_ERROR_PREFIX)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tasync function accountCurrentAgentTurn(\n\t\tctx: ExtensionContext,\n\t\tusage: TokenUsageSnapshot,\n\t\tmode: GoalAccountingMode,\n\t): Promise<Goal | null> {\n\t\tconst accounting = agentGoalAccounting;\n\t\tconst ref = goalStoreRef(ctx);\n\t\tif (accounting === null) return readGoal(ref);\n\n\t\tconst now = Date.now();\n\t\tconst elapsedSeconds = Math.max(0, Math.round((now - accounting.measuredFromMilliseconds) / 1000));\n\t\tconst goal = await accountGoalUsage(ref, usage, elapsedSeconds, mode, accounting.goalId);\n\t\tif (goal?.id === accounting.goalId) {\n\t\t\tagentGoalAccounting = { goalId: accounting.goalId, measuredFromMilliseconds: now };\n\t\t} else {\n\t\t\tclearAgentGoalAccounting();\n\t\t}\n\t\treturn goal;\n\t}\n}\n\nfunction isResumeOfPausedGoal(ctx: ExtensionContext, sessionStartReason: string, goal: Goal | null): goal is Goal {\n\treturn (\n\t\tsessionStartReason === \"resume\" &&\n\t\tgoal?.status === \"paused\" &&\n\t\tctx.hasUI &&\n\t\tctx.isIdle() &&\n\t\t!ctx.hasPendingMessages()\n\t);\n}\n\nfunction queueGoalContinuation(pi: ExtensionAPI, ctx: ExtensionContext, goal: Goal): void {\n\tif (shouldQueueGoalContinuationWhenIdle(goal, ctx.isIdle(), ctx.hasPendingMessages())) {\n\t\tqueueHiddenGoalPrompt(pi, buildContinuationPrompt(goal));\n\t}\n}\n\nfunction queueHiddenGoalPrompt(pi: ExtensionAPI, content: string): void {\n\tpi.sendMessage(\n\t\t{ customType: GOAL_CONTINUATION_MESSAGE_TYPE, content, display: false },\n\t\t{ triggerTurn: true, deliverAs: \"followUp\" },\n\t);\n}\n\nfunction goalStoreRef(ctx: ExtensionContext): GoalStoreRef {\n\tconst sessionFile = ctx.sessionManager.getSessionFile();\n\tconst baseDir =\n\t\tsessionFile === undefined\n\t\t\t? join(getAgentDir(), \"extensions\", \"goal\", \"no-session\", cwdStoreKey(ctx.cwd))\n\t\t\t: join(ctx.sessionManager.getSessionDir(), \"extensions\", \"goal\");\n\n\treturn {\n\t\tbaseDir,\n\t\tthreadId: ctx.sessionManager.getSessionId(),\n\t};\n}\n\nfunction cwdStoreKey(cwd: string): string {\n\treturn createHash(\"sha256\").update(cwd).digest(\"hex\").slice(0, 24);\n}\n\nfunction collectAssistantUsage(messages: unknown[]): TokenUsageSnapshot {\n\tconst usage: TokenUsageSnapshot = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0 };\n\tfor (const message of messages) {\n\t\tif (!isAssistantUsageMessage(message)) continue;\n\t\tusage.input += numericUsageField(message.usage, \"input\");\n\t\tusage.output += numericUsageField(message.usage, \"output\");\n\t\tusage.cacheRead += numericUsageField(message.usage, \"cacheRead\");\n\t\tusage.cacheWrite += numericUsageField(message.usage, \"cacheWrite\");\n\t\tusage.totalTokens += numericUsageField(message.usage, \"totalTokens\");\n\t}\n\treturn usage;\n}\n\nfunction isAssistantUsageMessage(message: unknown): message is AssistantUsageMessage {\n\tif (!isRecord(message)) return false;\n\treturn message.role === \"assistant\" && isRecord(message.usage);\n}\n\nfunction numericUsageField(usage: Record<string, unknown>, key: string): number {\n\tconst value = usage[key];\n\treturn typeof value === \"number\" && Number.isFinite(value) ? value : 0;\n}\n"]}
@@ -5,6 +5,7 @@ export type GoalToolRegistrationDeps = {
5
5
  readonly accountCurrentAgentTurn: (ctx: ExtensionContext, usage: TokenUsageSnapshot, mode: GoalAccountingMode) => Promise<Goal | null>;
6
6
  readonly beginAgentGoalAccounting: (goal: Goal) => void;
7
7
  readonly markGoalCompletedThisTurn: (goal: Goal) => void;
8
+ readonly refreshGoalUi: (ctx: ExtensionContext, goal: Goal | null) => void;
8
9
  };
9
10
  export declare function registerGoalTools(pi: ExtensionAPI, deps: GoalToolRegistrationDeps): void;
10
11
  //# sourceMappingURL=tool-registration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool-registration.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/tool-registration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGtF,OAAO,KAAK,EAAE,IAAI,EAAE,kBAAkB,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAQ7F,MAAM,MAAM,wBAAwB,GAAG;IACtC,QAAQ,CAAC,YAAY,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,YAAY,CAAC;IAC/D,QAAQ,CAAC,uBAAuB,EAAE,CACjC,GAAG,EAAE,gBAAgB,EACrB,KAAK,EAAE,kBAAkB,EACzB,IAAI,EAAE,kBAAkB,KACpB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IAC1B,QAAQ,CAAC,wBAAwB,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACxD,QAAQ,CAAC,yBAAyB,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CACzD,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,wBAAwB,GAAG,IAAI,CAuExF"}
1
+ {"version":3,"file":"tool-registration.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/tool-registration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGtF,OAAO,KAAK,EAAE,IAAI,EAAE,kBAAkB,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAO7F,MAAM,MAAM,wBAAwB,GAAG;IACtC,QAAQ,CAAC,YAAY,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,YAAY,CAAC;IAC/D,QAAQ,CAAC,uBAAuB,EAAE,CACjC,GAAG,EAAE,gBAAgB,EACrB,KAAK,EAAE,kBAAkB,EACzB,IAAI,EAAE,kBAAkB,KACpB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IAC1B,QAAQ,CAAC,wBAAwB,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACxD,QAAQ,CAAC,yBAAyB,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACzD,QAAQ,CAAC,aAAa,EAAE,CAAC,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC;CAC3E,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,wBAAwB,GAAG,IAAI,CAuExF"}
@@ -2,7 +2,6 @@ import { Type } from "typebox";
2
2
  import { formatGoalToolResponse } from "./format.js";
3
3
  import { createGoal, readGoal, updateGoal } from "./store.js";
4
4
  import { COMPLETABLE_GOAL_STATUS_VALUES } from "./types.js";
5
- import { updateGoalUi } from "./ui.js";
6
5
  const EMPTY_USAGE = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0 };
7
6
  export function registerGoalTools(pi, deps) {
8
7
  pi.registerTool({
@@ -21,7 +20,7 @@ export function registerGoalTools(pi, deps) {
21
20
  }
22
21
  const goal = await createGoal(ref, params.objective);
23
22
  deps.beginAgentGoalAccounting(goal);
24
- updateGoalUi(ctx, goal);
23
+ deps.refreshGoalUi(ctx, goal);
25
24
  return toolText(formatGoalToolResponse(goal));
26
25
  },
27
26
  });
@@ -41,7 +40,7 @@ export function registerGoalTools(pi, deps) {
41
40
  await deps.accountCurrentAgentTurn(ctx, EMPTY_USAGE, "active");
42
41
  const goal = await updateGoal(deps.goalStoreRef(ctx), { status: "complete" });
43
42
  deps.markGoalCompletedThisTurn(goal);
44
- updateGoalUi(ctx, goal);
43
+ deps.refreshGoalUi(ctx, goal);
45
44
  return toolText(formatGoalToolResponse(goal));
46
45
  },
47
46
  });
@@ -52,7 +51,7 @@ export function registerGoalTools(pi, deps) {
52
51
  parameters: Type.Object({}, { additionalProperties: false }),
53
52
  async execute(_toolCallId, _params, _signal, _onUpdate, ctx) {
54
53
  const goal = await readGoal(deps.goalStoreRef(ctx));
55
- updateGoalUi(ctx, goal);
54
+ deps.refreshGoalUi(ctx, goal);
56
55
  return toolText(formatGoalToolResponse(goal));
57
56
  },
58
57
  });
@@ -1 +1 @@
1
- {"version":3,"file":"tool-registration.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/tool-registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE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C,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;YACpD,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YACxB,OAAO,QAAQ,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAC;QAC/C,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY;IAC7B,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AACpE,CAAC","sourcesContent":["import { Type } from \"typebox\";\nimport type { AgentToolResult, ExtensionAPI, ExtensionContext } from \"../../types.ts\";\nimport { formatGoalToolResponse } from \"./format.ts\";\nimport { createGoal, readGoal, updateGoal } from \"./store.ts\";\nimport type { Goal, GoalAccountingMode, GoalStoreRef, TokenUsageSnapshot } from \"./types.ts\";\nimport { COMPLETABLE_GOAL_STATUS_VALUES } from \"./types.ts\";\nimport { updateGoalUi } from \"./ui.ts\";\n\nconst EMPTY_USAGE: TokenUsageSnapshot = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0 };\n\ntype GoalToolResult = AgentToolResult<Record<string, never>>;\n\nexport type GoalToolRegistrationDeps = {\n\treadonly goalStoreRef: (ctx: ExtensionContext) => GoalStoreRef;\n\treadonly accountCurrentAgentTurn: (\n\t\tctx: ExtensionContext,\n\t\tusage: TokenUsageSnapshot,\n\t\tmode: GoalAccountingMode,\n\t) => Promise<Goal | null>;\n\treadonly beginAgentGoalAccounting: (goal: Goal) => void;\n\treadonly markGoalCompletedThisTurn: (goal: Goal) => void;\n};\n\nexport function registerGoalTools(pi: ExtensionAPI, deps: GoalToolRegistrationDeps): void {\n\tpi.registerTool({\n\t\tname: \"create_goal\",\n\t\tlabel: \"Create Goal\",\n\t\tdescription:\n\t\t\t\"Create a goal only when explicitly requested by the user or system/developer instructions; do not infer goals from ordinary tasks.\\nFails if a goal already exists; use update_goal only for status.\",\n\t\tparameters: Type.Object(\n\t\t\t{\n\t\t\t\tobjective: Type.String({\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"Required. The concrete objective to start pursuing. This starts a new active goal only when no goal is currently defined; if a goal already exists, this tool fails.\",\n\t\t\t\t}),\n\t\t\t},\n\t\t\t{ additionalProperties: false },\n\t\t),\n\t\tasync execute(_toolCallId, params, _signal, _onUpdate, ctx) {\n\t\t\tconst ref = deps.goalStoreRef(ctx);\n\t\t\tif ((await readGoal(ref)) !== null) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"cannot create a new goal because this thread already has a goal; use update_goal only when the existing goal is complete\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst goal = await createGoal(ref, params.objective);\n\t\t\tdeps.beginAgentGoalAccounting(goal);\n\t\t\tupdateGoalUi(ctx, goal);\n\t\t\treturn toolText(formatGoalToolResponse(goal));\n\t\t},\n\t});\n\n\tpi.registerTool({\n\t\tname: \"update_goal\",\n\t\tlabel: \"Update Goal\",\n\t\tdescription:\n\t\t\t\"Update the existing goal.\\nUse this tool only to mark the goal achieved.\\nSet status to `complete` only when the objective has actually been achieved and no required work remains.\\nDo not mark a goal complete merely because you are stopping work.\\nYou cannot use this tool to pause or resume a goal; those status changes are controlled by the user or system.\\nWhen marking the goal achieved with status `complete`, report the final elapsed time and token usage from the tool result to the user.\",\n\t\tparameters: Type.Object(\n\t\t\t{\n\t\t\t\tstatus: Type.Union(\n\t\t\t\t\tCOMPLETABLE_GOAL_STATUS_VALUES.map((status) => Type.Literal(status)),\n\t\t\t\t\t{\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"Required. Set to complete only when the objective is achieved and no required work remains.\",\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t},\n\t\t\t{ additionalProperties: false },\n\t\t),\n\t\tasync execute(_toolCallId, params, _signal, _onUpdate, ctx) {\n\t\t\tif (params.status !== \"complete\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"update_goal can only mark the existing goal complete; pause and resume are controlled by the user or system\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait deps.accountCurrentAgentTurn(ctx, EMPTY_USAGE, \"active\");\n\t\t\tconst goal = await updateGoal(deps.goalStoreRef(ctx), { status: \"complete\" });\n\t\t\tdeps.markGoalCompletedThisTurn(goal);\n\t\t\tupdateGoalUi(ctx, goal);\n\t\t\treturn toolText(formatGoalToolResponse(goal));\n\t\t},\n\t});\n\n\tpi.registerTool({\n\t\tname: \"get_goal\",\n\t\tlabel: \"Get Goal\",\n\t\tdescription: \"Get the current goal for this thread, including status, token and elapsed-time usage.\",\n\t\tparameters: Type.Object({}, { additionalProperties: false }),\n\t\tasync execute(_toolCallId, _params, _signal, _onUpdate, ctx) {\n\t\t\tconst goal = await readGoal(deps.goalStoreRef(ctx));\n\t\t\tupdateGoalUi(ctx, goal);\n\t\t\treturn toolText(formatGoalToolResponse(goal));\n\t\t},\n\t});\n}\n\nfunction toolText(text: string): GoalToolResult {\n\treturn { content: [{ type: \"text\" as const, text }], details: {} };\n}\n"]}
1
+ {"version":3,"file":"tool-registration.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/tool-registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE9D,OAAO,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AAE5D,MAAM,WAAW,GAAuB,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;AAgB7G,MAAM,UAAU,iBAAiB,CAAC,EAAgB,EAAE,IAA8B;IACjF,EAAE,CAAC,YAAY,CAAC;QACf,IAA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AAE,OAAO,EAAE,EAAE,EAAE,CAAC;AACpE,CAAC","sourcesContent":["import { Type } from \"typebox\";\nimport type { AgentToolResult, ExtensionAPI, ExtensionContext } from \"../../types.ts\";\nimport { formatGoalToolResponse } from \"./format.ts\";\nimport { createGoal, readGoal, updateGoal } from \"./store.ts\";\nimport type { Goal, GoalAccountingMode, GoalStoreRef, TokenUsageSnapshot } from \"./types.ts\";\nimport { COMPLETABLE_GOAL_STATUS_VALUES } from \"./types.ts\";\n\nconst EMPTY_USAGE: TokenUsageSnapshot = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0 };\n\ntype GoalToolResult = AgentToolResult<Record<string, never>>;\n\nexport type GoalToolRegistrationDeps = {\n\treadonly goalStoreRef: (ctx: ExtensionContext) => GoalStoreRef;\n\treadonly accountCurrentAgentTurn: (\n\t\tctx: ExtensionContext,\n\t\tusage: TokenUsageSnapshot,\n\t\tmode: GoalAccountingMode,\n\t) => Promise<Goal | null>;\n\treadonly beginAgentGoalAccounting: (goal: Goal) => void;\n\treadonly markGoalCompletedThisTurn: (goal: Goal) => void;\n\treadonly refreshGoalUi: (ctx: ExtensionContext, goal: Goal | null) => void;\n};\n\nexport function registerGoalTools(pi: ExtensionAPI, deps: GoalToolRegistrationDeps): void {\n\tpi.registerTool({\n\t\tname: \"create_goal\",\n\t\tlabel: \"Create Goal\",\n\t\tdescription:\n\t\t\t\"Create a goal only when explicitly requested by the user or system/developer instructions; do not infer goals from ordinary tasks.\\nFails if a goal already exists; use update_goal only for status.\",\n\t\tparameters: Type.Object(\n\t\t\t{\n\t\t\t\tobjective: Type.String({\n\t\t\t\t\tdescription:\n\t\t\t\t\t\t\"Required. The concrete objective to start pursuing. This starts a new active goal only when no goal is currently defined; if a goal already exists, this tool fails.\",\n\t\t\t\t}),\n\t\t\t},\n\t\t\t{ additionalProperties: false },\n\t\t),\n\t\tasync execute(_toolCallId, params, _signal, _onUpdate, ctx) {\n\t\t\tconst ref = deps.goalStoreRef(ctx);\n\t\t\tif ((await readGoal(ref)) !== null) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"cannot create a new goal because this thread already has a goal; use update_goal only when the existing goal is complete\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst goal = await createGoal(ref, params.objective);\n\t\t\tdeps.beginAgentGoalAccounting(goal);\n\t\t\tdeps.refreshGoalUi(ctx, goal);\n\t\t\treturn toolText(formatGoalToolResponse(goal));\n\t\t},\n\t});\n\n\tpi.registerTool({\n\t\tname: \"update_goal\",\n\t\tlabel: \"Update Goal\",\n\t\tdescription:\n\t\t\t\"Update the existing goal.\\nUse this tool only to mark the goal achieved.\\nSet status to `complete` only when the objective has actually been achieved and no required work remains.\\nDo not mark a goal complete merely because you are stopping work.\\nYou cannot use this tool to pause or resume a goal; those status changes are controlled by the user or system.\\nWhen marking the goal achieved with status `complete`, report the final elapsed time and token usage from the tool result to the user.\",\n\t\tparameters: Type.Object(\n\t\t\t{\n\t\t\t\tstatus: Type.Union(\n\t\t\t\t\tCOMPLETABLE_GOAL_STATUS_VALUES.map((status) => Type.Literal(status)),\n\t\t\t\t\t{\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\"Required. Set to complete only when the objective is achieved and no required work remains.\",\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t},\n\t\t\t{ additionalProperties: false },\n\t\t),\n\t\tasync execute(_toolCallId, params, _signal, _onUpdate, ctx) {\n\t\t\tif (params.status !== \"complete\") {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"update_goal can only mark the existing goal complete; pause and resume are controlled by the user or system\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait deps.accountCurrentAgentTurn(ctx, EMPTY_USAGE, \"active\");\n\t\t\tconst goal = await updateGoal(deps.goalStoreRef(ctx), { status: \"complete\" });\n\t\t\tdeps.markGoalCompletedThisTurn(goal);\n\t\t\tdeps.refreshGoalUi(ctx, goal);\n\t\t\treturn toolText(formatGoalToolResponse(goal));\n\t\t},\n\t});\n\n\tpi.registerTool({\n\t\tname: \"get_goal\",\n\t\tlabel: \"Get Goal\",\n\t\tdescription: \"Get the current goal for this thread, including status, token and elapsed-time usage.\",\n\t\tparameters: Type.Object({}, { additionalProperties: false }),\n\t\tasync execute(_toolCallId, _params, _signal, _onUpdate, ctx) {\n\t\t\tconst goal = await readGoal(deps.goalStoreRef(ctx));\n\t\t\tdeps.refreshGoalUi(ctx, goal);\n\t\t\treturn toolText(formatGoalToolResponse(goal));\n\t\t},\n\t});\n}\n\nfunction toolText(text: string): GoalToolResult {\n\treturn { content: [{ type: \"text\" as const, text }], details: {} };\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { ExtensionContext } from "../../types.ts";
2
2
  import type { Goal } from "./types.ts";
3
3
  export declare const STATUS_KEY = "goal";
4
- export declare function updateGoalUi(ctx: ExtensionContext, goal: Goal | null): void;
5
- export declare function goalStatusText(goal: Goal): string;
4
+ export declare function updateGoalUi(ctx: ExtensionContext, goal: Goal | null, liveElapsedSeconds?: number): void;
5
+ export declare function goalStatusText(goal: Goal, liveElapsedSeconds?: number): string;
6
6
  //# sourceMappingURL=ui.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,eAAO,MAAM,UAAU,SAAS,CAAC;AAEjC,wBAAgB,YAAY,CAAC,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAG3E;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAWjD"}
1
+ {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,eAAO,MAAM,UAAU,SAAS,CAAC;AAEjC,wBAAgB,YAAY,CAAC,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAGxG;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,MAAM,CAe9E"}
@@ -1,16 +1,20 @@
1
1
  import { formatGoalElapsedSeconds } from "./format.js";
2
2
  export const STATUS_KEY = "goal";
3
- export function updateGoalUi(ctx, goal) {
3
+ export function updateGoalUi(ctx, goal, liveElapsedSeconds) {
4
4
  if (!ctx.hasUI)
5
5
  return;
6
- ctx.ui.setStatus(STATUS_KEY, goal === null ? undefined : goalStatusText(goal));
6
+ ctx.ui.setStatus(STATUS_KEY, goal === null ? undefined : goalStatusText(goal, liveElapsedSeconds));
7
7
  }
8
- export function goalStatusText(goal) {
8
+ export function goalStatusText(goal, liveElapsedSeconds) {
9
9
  switch (goal.status) {
10
- case "active":
10
+ case "active": {
11
+ if (liveElapsedSeconds !== undefined) {
12
+ return `Pursuing goal (${formatGoalElapsedSeconds(liveElapsedSeconds)})`;
13
+ }
11
14
  return goal.timeUsedSeconds > 0
12
15
  ? `Pursuing goal (${formatGoalElapsedSeconds(goal.timeUsedSeconds)})`
13
16
  : "Pursuing goal";
17
+ }
14
18
  case "paused":
15
19
  return "Goal paused (/goal resume)";
16
20
  case "complete":
@@ -1 +1 @@
1
- {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/ui.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAGvD,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC;AAEjC,MAAM,UAAU,YAAY,CAAC,GAAqB,EAAE,IAAiB;IACpE,IAAI,CAAC,GAAG,CAAC,KAAK;QAAE,OAAO;IACvB,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAU;IACxC,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACrB,KAAK,QAAQ;YACZ,OAAO,IAAI,CAAC,eAAe,GAAG,CAAC;gBAC9B,CAAC,CAAC,kBAAkB,wBAAwB,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG;gBACrE,CAAC,CAAC,eAAe,CAAC;QACpB,KAAK,QAAQ;YACZ,OAAO,4BAA4B,CAAC;QACrC,KAAK,UAAU;YACd,OAAO,eAAe,CAAC;IACzB,CAAC;AACF,CAAC","sourcesContent":["import type { ExtensionContext } from \"../../types.ts\";\nimport { formatGoalElapsedSeconds } from \"./format.ts\";\nimport type { Goal } from \"./types.ts\";\n\nexport const STATUS_KEY = \"goal\";\n\nexport function updateGoalUi(ctx: ExtensionContext, goal: Goal | null): void {\n\tif (!ctx.hasUI) return;\n\tctx.ui.setStatus(STATUS_KEY, goal === null ? undefined : goalStatusText(goal));\n}\n\nexport function goalStatusText(goal: Goal): string {\n\tswitch (goal.status) {\n\t\tcase \"active\":\n\t\t\treturn goal.timeUsedSeconds > 0\n\t\t\t\t? `Pursuing goal (${formatGoalElapsedSeconds(goal.timeUsedSeconds)})`\n\t\t\t\t: \"Pursuing goal\";\n\t\tcase \"paused\":\n\t\t\treturn \"Goal paused (/goal resume)\";\n\t\tcase \"complete\":\n\t\t\treturn \"Goal achieved\";\n\t}\n}\n"]}
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/goal/ui.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAGvD,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC;AAEjC,MAAM,UAAU,YAAY,CAAC,GAAqB,EAAE,IAAiB,EAAE,kBAA2B;IACjG,IAAI,CAAC,GAAG,CAAC,KAAK;QAAE,OAAO;IACvB,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC;AACpG,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAU,EAAE,kBAA2B;IACrE,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACrB,KAAK,QAAQ,EAAE,CAAC;YACf,IAAI,kBAAkB,KAAK,SAAS,EAAE,CAAC;gBACtC,OAAO,kBAAkB,wBAAwB,CAAC,kBAAkB,CAAC,GAAG,CAAC;YAC1E,CAAC;YACD,OAAO,IAAI,CAAC,eAAe,GAAG,CAAC;gBAC9B,CAAC,CAAC,kBAAkB,wBAAwB,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG;gBACrE,CAAC,CAAC,eAAe,CAAC;QACpB,CAAC;QACD,KAAK,QAAQ;YACZ,OAAO,4BAA4B,CAAC;QACrC,KAAK,UAAU;YACd,OAAO,eAAe,CAAC;IACzB,CAAC;AACF,CAAC","sourcesContent":["import type { ExtensionContext } from \"../../types.ts\";\nimport { formatGoalElapsedSeconds } from \"./format.ts\";\nimport type { Goal } from \"./types.ts\";\n\nexport const STATUS_KEY = \"goal\";\n\nexport function updateGoalUi(ctx: ExtensionContext, goal: Goal | null, liveElapsedSeconds?: number): void {\n\tif (!ctx.hasUI) return;\n\tctx.ui.setStatus(STATUS_KEY, goal === null ? undefined : goalStatusText(goal, liveElapsedSeconds));\n}\n\nexport function goalStatusText(goal: Goal, liveElapsedSeconds?: number): string {\n\tswitch (goal.status) {\n\t\tcase \"active\": {\n\t\t\tif (liveElapsedSeconds !== undefined) {\n\t\t\t\treturn `Pursuing goal (${formatGoalElapsedSeconds(liveElapsedSeconds)})`;\n\t\t\t}\n\t\t\treturn goal.timeUsedSeconds > 0\n\t\t\t\t? `Pursuing goal (${formatGoalElapsedSeconds(goal.timeUsedSeconds)})`\n\t\t\t\t: \"Pursuing goal\";\n\t\t}\n\t\tcase \"paused\":\n\t\t\treturn \"Goal paused (/goal resume)\";\n\t\tcase \"complete\":\n\t\t\treturn \"Goal achieved\";\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"claude-fable-5.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-fable-5.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AAclH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAExF"}
1
+ {"version":3,"file":"claude-fable-5.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-fable-5.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AAclH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAMxF"}
@@ -11,6 +11,10 @@ Terse shorthand between tool calls is fine; your final summary is for a reader w
11
11
  Do not stop, summarize, or suggest a new session on account of context limits. Continue the work.`;
12
12
  }
13
13
  export function buildClaudeFable5Prompt(options) {
14
- return buildDynamicSystemPrompt({ ...options, tuningSection: buildClaudeFable5Tuning() });
14
+ return buildDynamicSystemPrompt({
15
+ ...options,
16
+ tuningSection: buildClaudeFable5Tuning(),
17
+ workstationDialect: "claude",
18
+ });
15
19
  }
16
20
  //# sourceMappingURL=claude-fable-5.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"claude-fable-5.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-fable-5.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAElH,SAAS,uBAAuB;IAC/B,OAAO;;;;;;;;kGAQ0F,CAAC;AACnG,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAwC;IAC/E,OAAO,wBAAwB,CAAC,EAAE,GAAG,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAC;AAC3F,CAAC","sourcesContent":["import { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\n\nfunction buildClaudeFable5Tuning(): string {\n\treturn `When you have enough information to act, act. Do not re-derive facts already established in the conversation, re-litigate a decision the user has already made, or narrate options you will not pursue. When weighing a choice, give a recommendation, not a survey.\n\nBefore reporting progress, audit each claim against a tool result from this session. Only report work you can point to evidence for; if something is not yet verified, say so explicitly. If tests fail, say so with the output.\n\nPause for the user only when the work genuinely requires them: a destructive or irreversible action, a real scope change, or input only they can provide. If you hit one of these, ask and end the turn rather than ending on a promise. Before ending your turn, check your last paragraph: if it is a plan, a question, or a promise about work you have not done, do that work now with tool calls.\n\nTerse shorthand between tool calls is fine; your final summary is for a reader who did not see it. Lead with the outcome in complete sentences, then supporting detail. Keep output short by dropping detail that does not change what the reader does next, not by compressing into fragments, arrow chains, or labels you made up mid-task.\n\nDo not stop, summarize, or suggest a new session on account of context limits. Continue the work.`;\n}\n\nexport function buildClaudeFable5Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({ ...options, tuningSection: buildClaudeFable5Tuning() });\n}\n"]}
1
+ {"version":3,"file":"claude-fable-5.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-fable-5.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAElH,SAAS,uBAAuB;IAC/B,OAAO;;;;;;;;kGAQ0F,CAAC;AACnG,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAwC;IAC/E,OAAO,wBAAwB,CAAC;QAC/B,GAAG,OAAO;QACV,aAAa,EAAE,uBAAuB,EAAE;QACxC,kBAAkB,EAAE,QAAQ;KAC5B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\n\nfunction buildClaudeFable5Tuning(): string {\n\treturn `When you have enough information to act, act. Do not re-derive facts already established in the conversation, re-litigate a decision the user has already made, or narrate options you will not pursue. When weighing a choice, give a recommendation, not a survey.\n\nBefore reporting progress, audit each claim against a tool result from this session. Only report work you can point to evidence for; if something is not yet verified, say so explicitly. If tests fail, say so with the output.\n\nPause for the user only when the work genuinely requires them: a destructive or irreversible action, a real scope change, or input only they can provide. If you hit one of these, ask and end the turn rather than ending on a promise. Before ending your turn, check your last paragraph: if it is a plan, a question, or a promise about work you have not done, do that work now with tool calls.\n\nTerse shorthand between tool calls is fine; your final summary is for a reader who did not see it. Lead with the outcome in complete sentences, then supporting detail. Keep output short by dropping detail that does not change what the reader does next, not by compressing into fragments, arrow chains, or labels you made up mid-task.\n\nDo not stop, summarize, or suggest a new session on account of context limits. Continue the work.`;\n}\n\nexport function buildClaudeFable5Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({\n\t\t...options,\n\t\ttuningSection: buildClaudeFable5Tuning(),\n\t\tworkstationDialect: \"claude\",\n\t});\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"claude-opus-4-5.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-opus-4-5.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AAQlH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAExF"}
1
+ {"version":3,"file":"claude-opus-4-5.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-opus-4-5.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AAQlH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAMxF"}
@@ -5,6 +5,10 @@ function buildClaudeOpus45Tuning() {
5
5
  Do not wrap up early because the context window is running low; the harness auto-compacts context. Keep working until the task is complete.`;
6
6
  }
7
7
  export function buildClaudeOpus45Prompt(options) {
8
- return buildDynamicSystemPrompt({ ...options, tuningSection: buildClaudeOpus45Tuning() });
8
+ return buildDynamicSystemPrompt({
9
+ ...options,
10
+ tuningSection: buildClaudeOpus45Tuning(),
11
+ workstationDialect: "claude",
12
+ });
9
13
  }
10
14
  //# sourceMappingURL=claude-opus-4-5.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"claude-opus-4-5.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-opus-4-5.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAElH,SAAS,uBAAuB;IAC/B,OAAO;;4IAEoI,CAAC;AAC7I,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAwC;IAC/E,OAAO,wBAAwB,CAAC,EAAE,GAAG,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAC;AAC3F,CAAC","sourcesContent":["import { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\n\nfunction buildClaudeOpus45Tuning(): string {\n\treturn `Break complex tasks into ordered steps with clear dependencies before executing. When a request covers a set of items, apply it to every item rather than only the first, and state the scope you applied.\n\nDo not wrap up early because the context window is running low; the harness auto-compacts context. Keep working until the task is complete.`;\n}\n\nexport function buildClaudeOpus45Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({ ...options, tuningSection: buildClaudeOpus45Tuning() });\n}\n"]}
1
+ {"version":3,"file":"claude-opus-4-5.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-opus-4-5.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAElH,SAAS,uBAAuB;IAC/B,OAAO;;4IAEoI,CAAC;AAC7I,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAwC;IAC/E,OAAO,wBAAwB,CAAC;QAC/B,GAAG,OAAO;QACV,aAAa,EAAE,uBAAuB,EAAE;QACxC,kBAAkB,EAAE,QAAQ;KAC5B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\n\nfunction buildClaudeOpus45Tuning(): string {\n\treturn `Break complex tasks into ordered steps with clear dependencies before executing. When a request covers a set of items, apply it to every item rather than only the first, and state the scope you applied.\n\nDo not wrap up early because the context window is running low; the harness auto-compacts context. Keep working until the task is complete.`;\n}\n\nexport function buildClaudeOpus45Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({\n\t\t...options,\n\t\ttuningSection: buildClaudeOpus45Tuning(),\n\t\tworkstationDialect: \"claude\",\n\t});\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"claude-opus-4-6.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-opus-4-6.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AAQlH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAExF"}
1
+ {"version":3,"file":"claude-opus-4-6.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-opus-4-6.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AAQlH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAMxF"}
@@ -5,6 +5,10 @@ function buildClaudeOpus46Tuning() {
5
5
  Do not wrap up early because the context window is running low; the harness auto-compacts context. Keep working until the task is complete.`;
6
6
  }
7
7
  export function buildClaudeOpus46Prompt(options) {
8
- return buildDynamicSystemPrompt({ ...options, tuningSection: buildClaudeOpus46Tuning() });
8
+ return buildDynamicSystemPrompt({
9
+ ...options,
10
+ tuningSection: buildClaudeOpus46Tuning(),
11
+ workstationDialect: "claude",
12
+ });
9
13
  }
10
14
  //# sourceMappingURL=claude-opus-4-6.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"claude-opus-4-6.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-opus-4-6.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAElH,SAAS,uBAAuB;IAC/B,OAAO;;4IAEoI,CAAC;AAC7I,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAwC;IAC/E,OAAO,wBAAwB,CAAC,EAAE,GAAG,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAC;AAC3F,CAAC","sourcesContent":["import { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\n\nfunction buildClaudeOpus46Tuning(): string {\n\treturn `Choose an approach and commit to it; revisit only when new information directly contradicts your reasoning. When a request covers a set of items, apply it to every item and state the scope you applied.\n\nDo not wrap up early because the context window is running low; the harness auto-compacts context. Keep working until the task is complete.`;\n}\n\nexport function buildClaudeOpus46Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({ ...options, tuningSection: buildClaudeOpus46Tuning() });\n}\n"]}
1
+ {"version":3,"file":"claude-opus-4-6.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-opus-4-6.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAElH,SAAS,uBAAuB;IAC/B,OAAO;;4IAEoI,CAAC;AAC7I,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAwC;IAC/E,OAAO,wBAAwB,CAAC;QAC/B,GAAG,OAAO;QACV,aAAa,EAAE,uBAAuB,EAAE;QACxC,kBAAkB,EAAE,QAAQ;KAC5B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\n\nfunction buildClaudeOpus46Tuning(): string {\n\treturn `Choose an approach and commit to it; revisit only when new information directly contradicts your reasoning. When a request covers a set of items, apply it to every item and state the scope you applied.\n\nDo not wrap up early because the context window is running low; the harness auto-compacts context. Keep working until the task is complete.`;\n}\n\nexport function buildClaudeOpus46Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({\n\t\t...options,\n\t\ttuningSection: buildClaudeOpus46Tuning(),\n\t\tworkstationDialect: \"claude\",\n\t});\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"claude-opus-4-7.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-opus-4-7.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AAYlH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAExF"}
1
+ {"version":3,"file":"claude-opus-4-7.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-opus-4-7.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AAYlH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAMxF"}
@@ -9,6 +9,10 @@ For frontend design with no specified visual direction, derive one from the proj
9
9
  Do not wrap up early because the context window is running low; the harness auto-compacts context. Keep working until the task is complete.`;
10
10
  }
11
11
  export function buildClaudeOpus47Prompt(options) {
12
- return buildDynamicSystemPrompt({ ...options, tuningSection: buildClaudeOpus47Tuning() });
12
+ return buildDynamicSystemPrompt({
13
+ ...options,
14
+ tuningSection: buildClaudeOpus47Tuning(),
15
+ workstationDialect: "claude",
16
+ });
13
17
  }
14
18
  //# sourceMappingURL=claude-opus-4-7.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"claude-opus-4-7.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-opus-4-7.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAElH,SAAS,uBAAuB;IAC/B,OAAO;;;;;;4IAMoI,CAAC;AAC7I,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAwC;IAC/E,OAAO,wBAAwB,CAAC,EAAE,GAAG,OAAO,EAAE,aAAa,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAC;AAC3F,CAAC","sourcesContent":["import { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\n\nfunction buildClaudeOpus47Tuning(): string {\n\treturn `Apply instructions at the scope the user evidently intends: \"every\", \"all\", and \"each\" mean the full set rather than the first item, and a fix that plainly recurs covers every occurrence. State the scope you applied.\n\nPrefer tool calls over reasoning when a tool can resolve the question directly; do not reason past a fact you can look up.\n\nFor frontend design with no specified visual direction, derive one from the project's context or propose distinct options before building; do not fall back to your default cream/serif/terracotta house style or generic AI aesthetics.\n\nDo not wrap up early because the context window is running low; the harness auto-compacts context. Keep working until the task is complete.`;\n}\n\nexport function buildClaudeOpus47Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({ ...options, tuningSection: buildClaudeOpus47Tuning() });\n}\n"]}
1
+ {"version":3,"file":"claude-opus-4-7.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-opus-4-7.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAElH,SAAS,uBAAuB;IAC/B,OAAO;;;;;;4IAMoI,CAAC;AAC7I,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAwC;IAC/E,OAAO,wBAAwB,CAAC;QAC/B,GAAG,OAAO;QACV,aAAa,EAAE,uBAAuB,EAAE;QACxC,kBAAkB,EAAE,QAAQ;KAC5B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { type BuildDynamicSystemPromptOptions, buildDynamicSystemPrompt } from \"../../../dynamic-prompt/build.ts\";\n\nfunction buildClaudeOpus47Tuning(): string {\n\treturn `Apply instructions at the scope the user evidently intends: \"every\", \"all\", and \"each\" mean the full set rather than the first item, and a fix that plainly recurs covers every occurrence. State the scope you applied.\n\nPrefer tool calls over reasoning when a tool can resolve the question directly; do not reason past a fact you can look up.\n\nFor frontend design with no specified visual direction, derive one from the project's context or propose distinct options before building; do not fall back to your default cream/serif/terracotta house style or generic AI aesthetics.\n\nDo not wrap up early because the context window is running low; the harness auto-compacts context. Keep working until the task is complete.`;\n}\n\nexport function buildClaudeOpus47Prompt(options: BuildDynamicSystemPromptOptions): string {\n\treturn buildDynamicSystemPrompt({\n\t\t...options,\n\t\ttuningSection: buildClaudeOpus47Tuning(),\n\t\tworkstationDialect: \"claude\",\n\t});\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"claude-opus-4-8.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-opus-4-8.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AAYlH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAExF"}
1
+ {"version":3,"file":"claude-opus-4-8.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/prompt-preset/claude-opus-4-8.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,+BAA+B,EAA4B,MAAM,kCAAkC,CAAC;AAYlH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,+BAA+B,GAAG,MAAM,CAMxF"}