@sayknow-cli/coding-agent 0.3.7 → 0.3.9

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 (272) hide show
  1. package/dist/types/append-only-mode.d.ts +31 -0
  2. package/dist/types/capability/rule.d.ts +8 -0
  3. package/dist/types/cli/completion-cli.d.ts +41 -0
  4. package/dist/types/cli/config-cli.d.ts +1 -0
  5. package/dist/types/cli/fixture-report.d.ts +20 -0
  6. package/dist/types/cli/fixture-report.test.d.ts +1 -0
  7. package/dist/types/cli/nofile-limit.d.ts +11 -0
  8. package/dist/types/cli/notify-cli.d.ts +7 -0
  9. package/dist/types/cli/update-cli.d.ts +22 -0
  10. package/dist/types/cli.d.ts +124 -1
  11. package/dist/types/commands/completion.d.ts +29 -0
  12. package/dist/types/commands/config.d.ts +3 -0
  13. package/dist/types/commands/deep-interview.d.ts +3 -0
  14. package/dist/types/config/file-lock.d.ts +7 -6
  15. package/dist/types/config/keybindings.d.ts +2 -2
  16. package/dist/types/config/model-profile-activation.d.ts +6 -0
  17. package/dist/types/config/model-profiles.d.ts +1 -0
  18. package/dist/types/config/settings-schema.d.ts +119 -1
  19. package/dist/types/config/settings.d.ts +8 -0
  20. package/dist/types/discovery/index.d.ts +1 -0
  21. package/dist/types/export/html/template.generated.d.ts +1 -1
  22. package/dist/types/export/ttsr.d.ts +14 -3
  23. package/dist/types/extensibility/extensions/runner.d.ts +2 -1
  24. package/dist/types/extensibility/extensions/types.d.ts +8 -0
  25. package/dist/types/goals/runtime.d.ts +1 -0
  26. package/dist/types/hooks/native-skill-hook.d.ts +12 -0
  27. package/dist/types/main.d.ts +4 -1
  28. package/dist/types/modes/components/assistant-message.d.ts +5 -1
  29. package/dist/types/modes/components/model-selector.d.ts +4 -0
  30. package/dist/types/modes/components/queued-message-selector.d.ts +12 -0
  31. package/dist/types/modes/components/settings-selector.d.ts +2 -0
  32. package/dist/types/modes/components/status-line.d.ts +9 -0
  33. package/dist/types/modes/components/thinking-selector.d.ts +2 -2
  34. package/dist/types/modes/controllers/command-controller.d.ts +1 -0
  35. package/dist/types/modes/controllers/event-controller.d.ts +5 -0
  36. package/dist/types/modes/controllers/input-controller.d.ts +1 -3
  37. package/dist/types/modes/controllers/selector-controller.d.ts +1 -0
  38. package/dist/types/modes/interactive-mode.d.ts +4 -0
  39. package/dist/types/modes/print-mode.d.ts +13 -1
  40. package/dist/types/modes/prompt-action-autocomplete.d.ts +1 -1
  41. package/dist/types/modes/rpc/rpc-mode.d.ts +1 -3
  42. package/dist/types/modes/rpc/rpc-socket-security.d.ts +3 -0
  43. package/dist/types/modes/rpc/rpc-types.d.ts +14 -0
  44. package/dist/types/modes/shared/agent-wire/event-contract.d.ts +19 -0
  45. package/dist/types/modes/shared/agent-wire/event-envelope.d.ts +23 -1
  46. package/dist/types/modes/types.d.ts +3 -0
  47. package/dist/types/modes/utils/injected-user-submission.d.ts +52 -0
  48. package/dist/types/modes/utils/ui-helpers.d.ts +1 -0
  49. package/dist/types/notifications/config-commands.d.ts +9 -0
  50. package/dist/types/notifications/config.d.ts +30 -1
  51. package/dist/types/notifications/daemon-paths.d.ts +1 -0
  52. package/dist/types/notifications/index.d.ts +8 -3
  53. package/dist/types/notifications/lifecycle-commands.d.ts +12 -3
  54. package/dist/types/notifications/lifecycle-control-runtime.d.ts +2 -1
  55. package/dist/types/notifications/reply-sent-store.d.ts +53 -0
  56. package/dist/types/notifications/rich-draft.d.ts +68 -0
  57. package/dist/types/notifications/rich-render.d.ts +90 -0
  58. package/dist/types/notifications/telegram-daemon.d.ts +45 -3
  59. package/dist/types/notifications/telegram-reference.d.ts +7 -5
  60. package/dist/types/notifications/threaded-render.d.ts +14 -0
  61. package/dist/types/runtime-api-key.d.ts +7 -0
  62. package/dist/types/sdk.d.ts +3 -0
  63. package/dist/types/session/agent-session.d.ts +61 -6
  64. package/dist/types/session/agent-storage.d.ts +1 -0
  65. package/dist/types/session/file-mention-pruning.d.ts +8 -0
  66. package/dist/types/session/messages.d.ts +4 -0
  67. package/dist/types/session/session-manager.d.ts +17 -1
  68. package/dist/types/skc-runtime/deep-interview-ambiguity.d.ts +39 -0
  69. package/dist/types/skc-runtime/deep-interview-recorder.d.ts +10 -1
  70. package/dist/types/skc-runtime/deep-interview-state.d.ts +17 -2
  71. package/dist/types/skc-runtime/session-state-sidecar.d.ts +7 -0
  72. package/dist/types/skc-runtime/state-writer.d.ts +3 -0
  73. package/dist/types/skc-runtime/tmux-common.d.ts +1 -0
  74. package/dist/types/skc-runtime/ultragoal-receipt-freshness.d.ts +42 -0
  75. package/dist/types/skc-runtime/ultragoal-runtime.d.ts +120 -13
  76. package/dist/types/skill-state/active-state.d.ts +18 -1
  77. package/dist/types/system-prompt.d.ts +18 -2
  78. package/dist/types/task/executor.d.ts +3 -0
  79. package/dist/types/task/fork-context-budget.d.ts +7 -0
  80. package/dist/types/task/token-log.d.ts +30 -0
  81. package/dist/types/task/token-log.test.d.ts +1 -0
  82. package/dist/types/tools/bisect.d.ts +81 -0
  83. package/dist/types/tools/computer.d.ts +2 -2
  84. package/dist/types/tools/index.d.ts +1 -0
  85. package/dist/types/tools/search.d.ts +2 -2
  86. package/dist/types/tools/ultragoal-ask-guard.d.ts +9 -2
  87. package/dist/types/utils/file-mentions.d.ts +14 -0
  88. package/dist/types/utils/git.d.ts +32 -0
  89. package/dist/types/utils/pasted-image-path.d.ts +30 -0
  90. package/dist/types/web/scrapers/youtube.d.ts +8 -0
  91. package/dist/types/workflow/workflow-intent-diff.d.ts +8 -2
  92. package/dist/types/workflow/workflow-intent-report-consumer.d.ts +50 -0
  93. package/dist/types/workflow/workflow-intent-report-schema.d.ts +2 -0
  94. package/dist/types/workflow/workflow-intent-report.d.ts +48 -0
  95. package/package.json +8 -8
  96. package/src/append-only-mode.ts +58 -0
  97. package/src/autoresearch/prompt.md +1 -1
  98. package/src/autoresearch/tools/log-experiment.ts +1 -1
  99. package/src/capability/rule.ts +9 -0
  100. package/src/cli/completion-cli.ts +234 -0
  101. package/src/cli/config-cli.ts +61 -9
  102. package/src/cli/fast-help.ts +1 -0
  103. package/src/cli/fixture-report.test.ts +230 -0
  104. package/src/cli/fixture-report.ts +171 -0
  105. package/src/cli/nofile-limit.ts +48 -0
  106. package/src/cli/notify-cli.ts +103 -17
  107. package/src/cli/telegram-cli.ts +1 -1
  108. package/src/cli/update-cli.ts +148 -33
  109. package/src/cli.ts +29 -1
  110. package/src/commands/completion.ts +84 -0
  111. package/src/commands/config.ts +2 -0
  112. package/src/commands/contribution-prep.ts +1 -1
  113. package/src/commands/deep-interview.ts +2 -1
  114. package/src/config/file-lock.ts +73 -34
  115. package/src/config/keybindings.ts +3 -3
  116. package/src/config/model-profile-activation.ts +65 -0
  117. package/src/config/model-profiles.ts +31 -2
  118. package/src/config/settings-schema.ts +76 -1
  119. package/src/config/settings.ts +22 -0
  120. package/src/defaults/skc/skills/team/SKILL.md +17 -14
  121. package/src/defaults/skc/skills/ultragoal/SKILL.md +59 -4
  122. package/src/defaults/skc/skills/ultragoal/pipeline-validation-contracts.md +30 -0
  123. package/src/defaults/skc-defaults.ts +9 -0
  124. package/src/discovery/helpers.ts +10 -0
  125. package/src/discovery/index.ts +1 -0
  126. package/src/export/html/template.generated.ts +1 -1
  127. package/src/export/html/template.js +60 -2
  128. package/src/export/ttsr.ts +96 -18
  129. package/src/extensibility/extensions/runner.ts +183 -219
  130. package/src/extensibility/extensions/types.ts +9 -0
  131. package/src/extensibility/skc-plugins/runtime-adapters.ts +156 -44
  132. package/src/goals/runtime.ts +10 -2
  133. package/src/hindsight/backend.ts +1 -3
  134. package/src/hooks/native-skill-hook.ts +124 -4
  135. package/src/internal-urls/docs-index.generated.ts +17 -8
  136. package/src/lsp/client.ts +1 -0
  137. package/src/main.ts +95 -43
  138. package/src/memories/index.ts +12 -1
  139. package/src/modes/components/assistant-message.ts +241 -82
  140. package/src/modes/components/custom-editor.ts +1 -0
  141. package/src/modes/components/footer.ts +7 -2
  142. package/src/modes/components/model-selector.ts +54 -11
  143. package/src/modes/components/queued-message-selector.ts +92 -0
  144. package/src/modes/components/settings-selector.ts +4 -0
  145. package/src/modes/components/status-line.ts +167 -54
  146. package/src/modes/components/thinking-selector.ts +10 -8
  147. package/src/modes/components/tool-execution.ts +44 -19
  148. package/src/modes/components/welcome.ts +181 -44
  149. package/src/modes/controllers/command-controller.ts +40 -4
  150. package/src/modes/controllers/event-controller.ts +77 -49
  151. package/src/modes/controllers/extension-ui-controller.ts +12 -11
  152. package/src/modes/controllers/input-controller.ts +192 -35
  153. package/src/modes/controllers/selector-controller.ts +168 -24
  154. package/src/modes/interactive-mode.ts +56 -16
  155. package/src/modes/print-mode.ts +43 -4
  156. package/src/modes/prompt-action-autocomplete.ts +21 -20
  157. package/src/modes/rpc/rpc-mode.ts +32 -12
  158. package/src/modes/rpc/rpc-socket-security.ts +13 -1
  159. package/src/modes/rpc/rpc-types.ts +9 -0
  160. package/src/modes/shared/agent-wire/command-validation.ts +4 -0
  161. package/src/modes/shared/agent-wire/event-contract.ts +22 -0
  162. package/src/modes/shared/agent-wire/event-envelope.ts +82 -0
  163. package/src/modes/shared/agent-wire/scopes.ts +1 -0
  164. package/src/modes/types.ts +3 -0
  165. package/src/modes/utils/hotkeys-markdown.ts +1 -0
  166. package/src/modes/utils/injected-user-submission.ts +94 -0
  167. package/src/modes/utils/ui-helpers.ts +20 -7
  168. package/src/notifications/config-commands.ts +20 -0
  169. package/src/notifications/config.ts +52 -5
  170. package/src/notifications/daemon-paths.ts +2 -0
  171. package/src/notifications/index.ts +144 -18
  172. package/src/notifications/lifecycle-commands.ts +74 -23
  173. package/src/notifications/lifecycle-control-runtime.ts +8 -3
  174. package/src/notifications/lifecycle-orchestrator.ts +19 -6
  175. package/src/notifications/reply-sent-store.ts +134 -0
  176. package/src/notifications/rich-draft.ts +107 -0
  177. package/src/notifications/rich-render.ts +142 -0
  178. package/src/notifications/telegram-daemon-control.ts +5 -3
  179. package/src/notifications/telegram-daemon.ts +606 -98
  180. package/src/notifications/telegram-reference.ts +17 -16
  181. package/src/notifications/threaded-render.ts +45 -2
  182. package/src/prompts/agents/architect.md +19 -10
  183. package/src/prompts/agents/critic.md +16 -18
  184. package/src/prompts/agents/executor.md +14 -11
  185. package/src/prompts/agents/planner.md +18 -13
  186. package/src/prompts/ci-green-request.md +3 -8
  187. package/src/prompts/goals/goal-continuation.md +0 -5
  188. package/src/prompts/goals/goal-mode-active.md +0 -5
  189. package/src/prompts/system/agent-creation-architect.md +2 -2
  190. package/src/prompts/system/plan-mode-active.md +1 -1
  191. package/src/prompts/system/plan-mode-subagent.md +3 -3
  192. package/src/prompts/system/project-prompt.md +0 -13
  193. package/src/prompts/system/subagent-system-prompt.md +3 -2
  194. package/src/prompts/system/system-prompt.md +29 -17
  195. package/src/prompts/system/volatile-project-context.md +10 -0
  196. package/src/prompts/system/web-search.md +4 -7
  197. package/src/prompts/tools/apply-patch.md +6 -0
  198. package/src/prompts/tools/ast-edit.md +1 -0
  199. package/src/prompts/tools/bash.md +1 -1
  200. package/src/prompts/tools/bisect.md +22 -0
  201. package/src/prompts/tools/browser.md +1 -1
  202. package/src/prompts/tools/computer.md +2 -2
  203. package/src/prompts/tools/cron.md +0 -2
  204. package/src/prompts/tools/eval.md +2 -2
  205. package/src/prompts/tools/find.md +1 -1
  206. package/src/prompts/tools/github.md +6 -6
  207. package/src/prompts/tools/goal.md +1 -3
  208. package/src/prompts/tools/image-gen.md +12 -5
  209. package/src/prompts/tools/irc.md +5 -4
  210. package/src/prompts/tools/job.md +2 -2
  211. package/src/prompts/tools/lsp.md +1 -1
  212. package/src/prompts/tools/monitor.md +2 -2
  213. package/src/prompts/tools/patch.md +2 -2
  214. package/src/prompts/tools/replace.md +2 -21
  215. package/src/prompts/tools/rewind.md +1 -1
  216. package/src/prompts/tools/search-tool-bm25.md +6 -11
  217. package/src/prompts/tools/search.md +1 -1
  218. package/src/prompts/tools/skill.md +3 -2
  219. package/src/prompts/tools/ssh.md +2 -1
  220. package/src/prompts/tools/subagent.md +2 -2
  221. package/src/prompts/tools/task.md +4 -5
  222. package/src/prompts/tools/todo-write.md +1 -1
  223. package/src/prompts/tools/vim.md +1 -0
  224. package/src/prompts/tools/web-search.md +2 -0
  225. package/src/prompts/tools/write.md +8 -2
  226. package/src/runtime-api-key.ts +16 -0
  227. package/src/sdk.ts +88 -36
  228. package/src/session/agent-session.ts +1013 -141
  229. package/src/session/agent-storage.ts +4 -0
  230. package/src/session/file-mention-pruning.ts +64 -0
  231. package/src/session/messages.ts +4 -0
  232. package/src/session/session-manager.ts +103 -4
  233. package/src/skc-runtime/deep-interview-ambiguity.ts +206 -0
  234. package/src/skc-runtime/deep-interview-recorder.ts +62 -8
  235. package/src/skc-runtime/deep-interview-state.ts +44 -2
  236. package/src/skc-runtime/session-state-sidecar.ts +263 -20
  237. package/src/skc-runtime/state-runtime.ts +12 -2
  238. package/src/skc-runtime/state-writer.ts +15 -0
  239. package/src/skc-runtime/tmux-common.ts +1 -0
  240. package/src/skc-runtime/ultragoal-guard.ts +55 -66
  241. package/src/skc-runtime/ultragoal-receipt-freshness.ts +315 -0
  242. package/src/skc-runtime/ultragoal-runtime.ts +1672 -159
  243. package/src/skc-runtime/workflow-manifest.generated.json +113 -2
  244. package/src/skc-runtime/workflow-manifest.ts +74 -1
  245. package/src/skill-state/active-state.ts +141 -5
  246. package/src/skill-state/deep-interview-mutation-guard.ts +67 -3
  247. package/src/slash-commands/builtin-registry.ts +296 -72
  248. package/src/system-prompt.ts +57 -16
  249. package/src/task/executor.ts +132 -24
  250. package/src/task/fork-context-advisory.ts +2 -7
  251. package/src/task/fork-context-budget.ts +9 -0
  252. package/src/task/index.ts +13 -6
  253. package/src/task/output-manager.ts +20 -8
  254. package/src/task/receipt.ts +26 -7
  255. package/src/task/token-log.test.ts +188 -0
  256. package/src/task/token-log.ts +179 -0
  257. package/src/tools/bisect.ts +367 -0
  258. package/src/tools/computer.ts +246 -43
  259. package/src/tools/index.ts +3 -0
  260. package/src/tools/output-meta.ts +116 -4
  261. package/src/tools/search.ts +8 -2
  262. package/src/tools/skill.ts +15 -0
  263. package/src/tools/telegram-send.ts +6 -0
  264. package/src/tools/ultragoal-ask-guard.ts +39 -5
  265. package/src/utils/file-mentions.ts +39 -7
  266. package/src/utils/git.ts +73 -0
  267. package/src/utils/pasted-image-path.ts +170 -0
  268. package/src/web/scrapers/youtube.ts +24 -12
  269. package/src/workflow/workflow-intent-diff.ts +29 -6
  270. package/src/workflow/workflow-intent-report-consumer.ts +221 -0
  271. package/src/workflow/workflow-intent-report-schema.ts +129 -0
  272. package/src/workflow/workflow-intent-report.ts +135 -0
@@ -3,12 +3,11 @@ Launches subagents to parallelize workflows.
3
3
  - Results are delivered automatically when complete.
4
4
  - The tool result lists the assigned task ids (e.g. `0-AuthLoader`) — those are the live agent ids.
5
5
  {{#if ircEnabled}}
6
- - Coordinate with running tasks via `irc` using those ids. `subagent` cancel terminates a task and **cannot carry a message** — never cancel because an await timed out; cancel only when the task has actually failed, gone off-track, or become unrecoverably wrong.
7
- - If genuinely blocked on completion, wait with `subagent` action `await` and a timeout; timeout only bounds your wait and does not stop or fail the subagent.
6
+ - Coordinate with running tasks via `irc` using those ids. `subagent` cancel terminates a task and **cannot carry a message**.
8
7
  {{else}}
9
- - If genuinely blocked on completion, wait with `subagent` action `await` and a timeout; timeout only bounds your wait and does not stop or fail the subagent.
10
- - Use `subagent` action `inspect` or `list` to snapshot manager state; `cancel` only when a task has actually failed, gone off-track, or become unrecoverably wrong.
8
+ - Use `subagent` action `inspect` or `list` to snapshot manager state.
11
9
  {{/if}}
10
+ - To wait or cancel, use the `subagent` tool; its await/cancel doctrine applies (never cancel just because an await timed out).
12
11
 
13
12
  {{#if ircEnabled}}
14
13
  Subagents have no conversation history, but they can reach you and their siblings live via the `irc` tool. Front-load every fact, file path, and direction they need in {{#if contextEnabled}}`context` or `assignment`{{else}}each `assignment`{{/if}}.
@@ -19,7 +18,7 @@ Subagents have no conversation history. Every fact, file path, and direction the
19
18
  <parameters>
20
19
  - `agent`: agent type for all tasks
21
20
  - `tasks`: tasks to execute in parallel
22
- - `.id`: CamelCase, ≤32 chars
21
+ - `.id`: filesystem-safe, ≤48 chars, matching `[A-Za-z0-9][A-Za-z0-9_-]*`; prefer CamelCase
23
22
  - `.description`: UI label only — subagent never sees it
24
23
  - `.assignment`: complete self-contained instructions; one-liners and missing acceptance criteria are PROHIBITED
25
24
  {{#if contextEnabled}}- `context`: shared background prepended to every assignment; session-specific only{{/if}}
@@ -12,7 +12,7 @@ Allowed `op` values are only `init`, `start`, `done`, `drop`, `rm`, `append`, an
12
12
  |`start`|`task`|Mark in progress|
13
13
  |`done`|`task` or `phase`|Mark completed|
14
14
  |`drop`|`task` or `phase`|Mark abandoned|
15
- |`rm`|`task` or `phase`|Remove|
15
+ |`rm`|`task` or `phase` or *(none = clear all tasks)*|Remove a task; with `phase`, empties the phase (the phase entry remains); bare `rm` clears every task in every phase|
16
16
  |`append`|`phase`, `items: string[]`|Append tasks to `phase`; lazily creates phase|
17
17
  |`note`|`task`, `text`|Append a note to a task. Reminders for future-you only.|
18
18
 
@@ -1,6 +1,7 @@
1
1
  Vim-style `edit` mode. The tool name stays `edit`; every call requires `file`, and the buffer loads automatically on first use.
2
2
  - `{"file": "path"}` - view file
3
3
  - `{"file": "path", "steps": [{"kbd": ["…"], "insert": "…"}]}` - edit file
4
+ - `pause` (optional boolean) - a "paused" call skips the auto-save after its steps and may leave the last step in INSERT mode; the buffer stays open for the next call. Non-paused calls auto-save once after all steps complete.
4
5
 
5
6
  **Multi-location edits: always edit highest line number first (bottom-up).** Each insert shifts lines below it.
6
7
 
@@ -3,9 +3,11 @@ Searches the web for up-to-date information beyond knowledge cutoff.
3
3
  <instruction>
4
4
  - You SHOULD prefer primary sources (papers, official docs) and corroborate key claims with multiple sources
5
5
  - You MUST include links for cited sources in the final response
6
+ - Provider-neutral params: `recency` (freshness window), `limit`/`num_search_results` (result counts), `max_tokens`, `temperature`
6
7
  </instruction>
7
8
 
8
9
  <xai>
10
+ The parameters below apply ONLY when the active search provider is `xai`; ignore them (and never pass them) on any other provider.
9
11
  - With provider `xai`, use `xai_search_mode: "web"` for normal web search, `"x"` for X/Twitter search, or `"web_and_x"` when both surfaces are relevant.
10
12
  - xAI web filters: `allowed_domains` or `excluded_domains` (max 5, mutually exclusive), plus `enable_image_understanding` and `enable_image_search`.
11
13
  - xAI X filters: `allowed_x_handles` or `excluded_x_handles` (max 20, mutually exclusive), `from_date`, `to_date`, `enable_image_understanding`, and `enable_video_understanding`.
@@ -3,10 +3,16 @@ Creates or overwrites file at specified path.
3
3
  <conditions>
4
4
  - Creating new files explicitly required by task
5
5
  - Replacing entire file contents when editing would be more complex
6
- - Supports `.tar`, `.tar.gz`, `.tgz`, and `.zip` archive entries via `archive.ext:path/inside/archive`
7
- - Supports SQLite row operations via `db.sqlite:table` (insert), `db.sqlite:table:key` (update with JSON content, delete with empty content)
8
6
  </conditions>
9
7
 
8
+ <instruction>
9
+ - Archives: write entries inside `.tar`, `.tar.gz`, `.tgz`, and `.zip` via `archive.ext:path/inside/archive`.
10
+ - SQLite rows:
11
+ - `db.sqlite:table` with JSON content — insert a row
12
+ - `db.sqlite:table:key` with JSON content — update the row with that primary key
13
+ - `db.sqlite:table:key` with empty content — DELETE that row (destructive; double-check the key)
14
+ </instruction>
15
+
10
16
  <critical>
11
17
  - You SHOULD use Edit tool for modifying existing files (more precise, preserves formatting)
12
18
  - You NEVER create documentation files (*.md, README) unless explicitly requested
@@ -0,0 +1,16 @@
1
+ export interface RuntimeApiKeyTarget {
2
+ setRuntimeApiKey(provider: string, apiKey: string): void;
3
+ }
4
+
5
+ export interface RuntimeApiKeyModel {
6
+ provider: string;
7
+ }
8
+
9
+ export function applyCliRuntimeApiKeyOverride(
10
+ target: RuntimeApiKeyTarget,
11
+ apiKey: string | undefined,
12
+ model: RuntimeApiKeyModel | undefined,
13
+ ): void {
14
+ if (!apiKey || !model) return;
15
+ target.setRuntimeApiKey(model.provider, apiKey);
16
+ }
package/src/sdk.ts CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  type AgentMessage,
5
5
  type AgentTelemetryConfig,
6
6
  type AgentTool,
7
- AppendOnlyContextManager,
7
+ type AppendOnlyContextManager,
8
8
  INTENT_FIELD,
9
9
  type ThinkingLevel,
10
10
  } from "@sayknow-cli/agent-core";
@@ -32,7 +32,11 @@ import {
32
32
  prompt,
33
33
  Snowflake,
34
34
  } from "@sayknow-cli/utils";
35
-
35
+ import {
36
+ createAppendOnlyContextManager,
37
+ providerSupportsAppendOnlyAuto,
38
+ resolveAppendOnlyMode,
39
+ } from "./append-only-mode";
36
40
  import { type AsyncJob, AsyncJobManager, isBackgroundJobSupportEnabled, jobElapsedMs } from "./async";
37
41
  import { loadCapability } from "./capability";
38
42
  import { type Rule, ruleCapability, setActiveRules } from "./capability/rule";
@@ -119,7 +123,12 @@ import {
119
123
  } from "./system-prompt";
120
124
  import { AgentOutputManager } from "./task/output-manager";
121
125
  import { parseThinkingLevel, resolveThinkingLevelForModel, toReasoningEffort } from "./thinking";
122
- import { collectDiscoverableTools, type DiscoverableTool } from "./tool-discovery/tool-index";
126
+ import {
127
+ collectDiscoverableTools,
128
+ type DiscoverableTool,
129
+ isMCPBridgeTool,
130
+ isMCPToolName,
131
+ } from "./tool-discovery/tool-index";
123
132
  import {
124
133
  applyConfiguredSearchTimeout,
125
134
  BashTool,
@@ -617,23 +626,12 @@ function registerJsVmCleanup(): void {
617
626
  postmortem.register("js-vm-cleanup", disposeAllVmContexts);
618
627
  }
619
628
 
620
- /**
621
- * Resolve whether to enable append-only context mode based on the setting and provider.
622
- *
623
- * - `"on"` → always enable
624
- * - `"off"` → never enable
625
- * - `"auto"` → enable for DeepSeek (prefix-caching provider)
629
+ /*
630
+ * Append-only context-mode resolution + manager construction live in
631
+ * ./append-only-mode so the initial build, the runtime model/setting-change
632
+ * path, and the status UI share one implementation. Re-exported for importers/tests.
626
633
  */
627
- function resolveAppendOnlyMode(setting: "auto" | "on" | "off" | undefined, provider: string): boolean {
628
- switch (setting ?? "auto") {
629
- case "on":
630
- return true;
631
- case "off":
632
- return false;
633
- default:
634
- return provider === "deepseek";
635
- }
636
- }
634
+ export { createAppendOnlyContextManager, providerSupportsAppendOnlyAuto, resolveAppendOnlyMode };
637
635
 
638
636
  function customToolToDefinition(tool: CustomTool): ToolDefinition {
639
637
  const definition: ToolDefinition & { [TOOL_DEFINITION_MARKER]: true } = {
@@ -868,6 +866,10 @@ function withEmbeddedDefaultSkcSkills(skills: Skill[]): Skill[] {
868
866
  return [...byName.values()];
869
867
  }
870
868
 
869
+ export function resolveIntentTracingEnabled(intentTracingSetting: boolean | undefined, hasUI: boolean): boolean {
870
+ return (!!intentTracingSetting || $flag("PI_INTENT_TRACING")) && hasUI;
871
+ }
872
+
871
873
  export async function createAgentSession(options: CreateAgentSessionOptions = {}): Promise<CreateAgentSessionResult> {
872
874
  const cwd = options.cwd ?? getProjectDir();
873
875
  const agentDir = options.agentDir ?? getDefaultAgentDir();
@@ -1127,8 +1129,15 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
1127
1129
  rulebookRules.push(rule);
1128
1130
  }
1129
1131
  }
1130
- if (existingSession.injectedTtsrRules.length > 0) {
1131
- ttsrManager.restoreInjected(existingSession.injectedTtsrRules);
1132
+ if (ttsrManager.getSettings().enabled !== false) {
1133
+ if ((existingSession.ttsrMessageCount ?? 0) > 0) {
1134
+ ttsrManager.restoreMessageCount(existingSession.ttsrMessageCount ?? 0);
1135
+ }
1136
+ if (existingSession.injectedTtsrRuleRecords && existingSession.injectedTtsrRuleRecords.length > 0) {
1137
+ ttsrManager.restoreInjected(existingSession.injectedTtsrRuleRecords);
1138
+ } else if (existingSession.injectedTtsrRules.length > 0) {
1139
+ ttsrManager.restoreInjected(existingSession.injectedTtsrRules);
1140
+ }
1132
1141
  }
1133
1142
  return { ttsrManager, rulebookRules, alwaysApplyRules };
1134
1143
  });
@@ -1216,8 +1225,8 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
1216
1225
 
1217
1226
  const agentRegistry = options.agentRegistry ?? AgentRegistry.global();
1218
1227
  const resolvedAgentId = options.agentId ?? options.parentTaskPrefix ?? MAIN_AGENT_ID;
1219
- const resolvedAgentDisplayName =
1220
- options.agentDisplayName ?? ((options.taskDepth ?? 0) > 0 || options.parentTaskPrefix ? "sub" : "main");
1228
+ const isSubSession = taskDepth > 0 || Boolean(options.parentTaskPrefix) || Boolean(options.currentAgentType);
1229
+ const resolvedAgentDisplayName = options.agentDisplayName ?? (isSubSession ? "sub" : "main");
1221
1230
  const evalKernelOwnerId = `agent-session:${Snowflake.next()}`;
1222
1231
 
1223
1232
  try {
@@ -1522,12 +1531,20 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
1522
1531
  }
1523
1532
  let notificationCfg: NotificationConfig | undefined;
1524
1533
  try {
1525
- notificationCfg = getNotificationConfig(Settings.instance);
1534
+ notificationCfg = getNotificationConfig(settings);
1526
1535
  } catch {
1527
1536
  notificationCfg = undefined;
1528
1537
  }
1529
- if (shouldRegisterNotificationsExtension({ env: process.env, cfg: notificationCfg })) {
1530
- inlineExtensions.push(createNotificationsExtension);
1538
+ if (
1539
+ shouldRegisterNotificationsExtension({
1540
+ env: process.env,
1541
+ cfg: notificationCfg,
1542
+ taskDepth,
1543
+ parentTaskPrefix: options.parentTaskPrefix,
1544
+ currentAgentType: options.currentAgentType,
1545
+ })
1546
+ ) {
1547
+ inlineExtensions.push(api => createNotificationsExtension(api, { settings }));
1531
1548
  }
1532
1549
 
1533
1550
  // Extension/module discovery is quarantined; retain only the private
@@ -1655,6 +1672,12 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
1655
1672
  cwd,
1656
1673
  sessionManager,
1657
1674
  modelRegistry,
1675
+ {
1676
+ kind: isSubSession ? "sub" : "main",
1677
+ taskDepth,
1678
+ ...(options.parentTaskPrefix ? { parentTaskPrefix: options.parentTaskPrefix } : {}),
1679
+ ...(options.currentAgentType ? { currentAgentType: options.currentAgentType } : {}),
1680
+ },
1658
1681
  );
1659
1682
  }
1660
1683
 
@@ -1774,7 +1797,11 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
1774
1797
 
1775
1798
  const repeatToolDescriptions = settings.get("repeatToolDescriptions");
1776
1799
  const eagerTasks = settings.get("task.eager");
1777
- const intentField = settings.get("tools.intentTracing") || $flag("PI_INTENT_TRACING") ? INTENT_FIELD : undefined;
1800
+ const intentTracingEnabled = resolveIntentTracingEnabled(
1801
+ settings.get("tools.intentTracing"),
1802
+ options.hasUI ?? false,
1803
+ );
1804
+ const intentField = intentTracingEnabled ? INTENT_FIELD : undefined;
1778
1805
  const rebuildSystemPrompt = async (
1779
1806
  toolNames: string[],
1780
1807
  tools: Map<string, AgentTool>,
@@ -1790,7 +1817,15 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
1790
1817
  { source: "builtin" },
1791
1818
  )
1792
1819
  : [];
1793
- const discoverableToolsForDesc: DiscoverableTool[] = [...discoverableBuiltinTools];
1820
+ const discoverableMCPTools: DiscoverableTool[] = mcpDiscoveryEnabled
1821
+ ? collectDiscoverableTools(
1822
+ Array.from(tools.values()).filter(
1823
+ tool => isMCPToolName(tool.name) && !activeToolNames.has(tool.name),
1824
+ ),
1825
+ { source: "mcp" },
1826
+ )
1827
+ : [];
1828
+ const discoverableToolsForDesc: DiscoverableTool[] = [...discoverableBuiltinTools, ...discoverableMCPTools];
1794
1829
  const promptTools = buildSystemPromptToolMetadata(tools, {
1795
1830
  search_tool_bm25: { description: renderSearchToolBm25Description(discoverableToolsForDesc) },
1796
1831
  });
@@ -1839,13 +1874,14 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
1839
1874
  intentField,
1840
1875
  mcpDiscoveryMode: false,
1841
1876
  mcpDiscoveryServerSummaries: [],
1842
- toolDiscoveryActive: effectiveDiscoveryMode === "all",
1843
- discoverableTools: discoverableBuiltinTools
1877
+ toolDiscoveryActive: effectiveDiscoveryMode === "all" || mcpDiscoveryEnabled,
1878
+ discoverableTools: [...discoverableBuiltinTools, ...discoverableMCPTools]
1844
1879
  .map(tool => ({ name: tool.name, summary: tool.summary }))
1845
1880
  .sort((a, b) => a.name.localeCompare(b.name)),
1846
1881
  eagerTasks,
1847
1882
  secretsEnabled,
1848
1883
  workspaceTree: workspaceTreePromise,
1884
+ subagent: options.parentTaskPrefix !== undefined,
1849
1885
  });
1850
1886
 
1851
1887
  if (options.systemPrompt === undefined) {
@@ -1870,11 +1906,12 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
1870
1906
  : toolNamesFromRegistry;
1871
1907
  const normalizedRequested = requestedToolNames.filter(name => toolRegistry.has(name));
1872
1908
  const requestedToolNameSet = new Set(normalizedRequested);
1873
- // Effective discovery mode only covers built-in tools; MCP tool discovery
1874
- // is quarantined from the SKC public surface.
1909
+ // Generic tool discovery hides non-essential built-ins behind search_tool_bm25.
1910
+ // Legacy MCP discovery remains separately controlled by mcp.discoveryMode so
1911
+ // loaded MCP catalogs can be searched without enabling every hidden built-in.
1875
1912
  const toolsDiscoveryModeSetting = settings.get("tools.discoveryMode");
1876
1913
  const effectiveDiscoveryMode: "off" | "all" = toolsDiscoveryModeSetting === "all" ? "all" : "off";
1877
- const mcpDiscoveryEnabled = false;
1914
+ const mcpDiscoveryEnabled = settings.get("mcp.discoveryMode") === true;
1878
1915
  const defaultInactiveToolNames = new Set(
1879
1916
  registeredTools.filter(tool => tool.definition.defaultInactive).map(tool => tool.definition.name),
1880
1917
  );
@@ -1887,6 +1924,20 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
1887
1924
  const discoveryDefaultServerToolNames: string[] = [];
1888
1925
  let initialSelectedMCPToolNames: string[] = [];
1889
1926
  let defaultSelectedMCPToolNames: string[] = [];
1927
+ if (mcpDiscoveryEnabled) {
1928
+ const defaultServerNames = new Set(settings.get("mcp.discoveryDefaultServers") ?? []);
1929
+ for (const tool of toolRegistry.values()) {
1930
+ if (!isMCPBridgeTool(tool)) continue;
1931
+ discoverableMCPToolNames.add(tool.name);
1932
+ if (initialRequestedActiveToolNames.includes(tool.name)) {
1933
+ explicitlyRequestedMCPToolNames.push(tool.name);
1934
+ }
1935
+ const serverName = (tool as AgentTool & { mcpServerName?: string }).mcpServerName;
1936
+ if (serverName && defaultServerNames.has(serverName)) {
1937
+ discoveryDefaultServerToolNames.push(tool.name);
1938
+ }
1939
+ }
1940
+ }
1890
1941
  let initialToolNames = [...initialRequestedActiveToolNames];
1891
1942
  if (mcpDiscoveryEnabled) {
1892
1943
  const restoredSelectedMCPToolNames = existingSession.selectedMCPToolNames.filter(name =>
@@ -1947,7 +1998,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
1947
1998
  agentRegistry.register({
1948
1999
  id: resolvedAgentId,
1949
2000
  displayName: resolvedAgentDisplayName,
1950
- kind: (options.taskDepth ?? 0) > 0 || options.parentTaskPrefix ? "sub" : "main",
2001
+ kind: isSubSession ? "sub" : "main",
1951
2002
  parentId: options.parentTaskPrefix,
1952
2003
  session: null,
1953
2004
  sessionFile: sessionManager.getSessionFile() ?? null,
@@ -2045,7 +2096,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
2045
2096
 
2046
2097
  const appendOnlyContext =
2047
2098
  model && resolveAppendOnlyMode(settings.get("provider.appendOnlyContext"), model.provider)
2048
- ? new AppendOnlyContextManager()
2099
+ ? createAppendOnlyContextManager(model.provider)
2049
2100
  : undefined;
2050
2101
  if (appendOnlyContext && options.forkContextSeed && !hasExistingSession) {
2051
2102
  if (options.forkContextSeed.appendOnlyPrefixSnapshot) {
@@ -2216,6 +2267,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
2216
2267
  onResponse,
2217
2268
  convertToLlm: convertToLlmFinal,
2218
2269
  rebuildSystemPrompt,
2270
+ workspaceTree: resolvedWorkspaceTree,
2219
2271
  reloadSshTool,
2220
2272
  requestedToolNames: requestedToolNameSet,
2221
2273
  discoverableToolAllowedNames: options.discoverableToolAllowedNames,
@@ -2237,7 +2289,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
2237
2289
  initialSelectedMCPToolNames,
2238
2290
  defaultSelectedMCPToolNames,
2239
2291
  persistInitialMCPToolSelection: !hasExistingSession,
2240
- defaultSelectedMCPServerNames: [],
2292
+ defaultSelectedMCPServerNames: settings.get("mcp.discoveryDefaultServers") ?? [],
2241
2293
  ttsrManager,
2242
2294
  obfuscator,
2243
2295
  agentId: resolvedAgentId,