@pellux/goodvibes-agent 1.1.7 → 1.3.0

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 (274) hide show
  1. package/CHANGELOG.md +329 -0
  2. package/README.md +46 -30
  3. package/dist/package/{ast-grep-napi.linux-x64-gnu-mkk8xwww.node → ast-grep-napi.linux-x64-gnu-swtppvy9.node} +0 -0
  4. package/dist/package/{ast-grep-napi.linux-x64-musl-ryqtgdv6.node → ast-grep-napi.linux-x64-musl-ttfcdtap.node} +0 -0
  5. package/dist/package/main.js +138903 -91477
  6. package/docs/README.md +14 -7
  7. package/docs/channels-remote-and-api.md +8 -5
  8. package/docs/connected-host.md +14 -12
  9. package/docs/getting-started.md +58 -30
  10. package/docs/knowledge-artifacts-and-multimodal.md +7 -5
  11. package/docs/project-planning.md +2 -2
  12. package/docs/providers-and-routing.md +11 -3
  13. package/docs/tools-and-commands.md +116 -45
  14. package/docs/voice-and-live-tts.md +3 -1
  15. package/package.json +3 -2
  16. package/release/release-notes.md +142 -5
  17. package/release/release-readiness.json +124 -94
  18. package/src/agent/assistant-cockpit.ts +247 -0
  19. package/src/agent/autonomy-schedule-format.ts +96 -0
  20. package/src/agent/autonomy-schedule.ts +514 -0
  21. package/src/agent/channel-delivery-receipts.ts +292 -0
  22. package/src/agent/competitive-feature-inventory.ts +294 -0
  23. package/src/agent/document-registry-types.ts +106 -0
  24. package/src/agent/document-registry.ts +734 -0
  25. package/src/agent/harness-control.ts +2 -2
  26. package/src/agent/memory-prompt.ts +2 -2
  27. package/src/agent/operator-actions.ts +50 -6
  28. package/src/agent/persona-registry.ts +8 -0
  29. package/src/agent/project-context-files.ts +273 -0
  30. package/src/agent/prompt-context-receipts.ts +502 -0
  31. package/src/agent/reminder-schedule-format.ts +16 -2
  32. package/src/agent/research-run-registry.ts +582 -0
  33. package/src/agent/research-source-registry.ts +441 -0
  34. package/src/agent/routine-registry.ts +19 -3
  35. package/src/agent/routine-schedule-format.ts +27 -2
  36. package/src/agent/runtime-profile-starters.ts +7 -0
  37. package/src/agent/runtime-profile.ts +106 -4
  38. package/src/agent/schedule-edit-format.ts +129 -0
  39. package/src/agent/schedule-edit.ts +496 -0
  40. package/src/agent/schedule-next-routes.ts +42 -0
  41. package/src/agent/setup-wizard-artifact-receipts.ts +366 -0
  42. package/src/agent/setup-wizard-checkpoint.ts +140 -0
  43. package/src/agent/setup-wizard.ts +683 -0
  44. package/src/agent/skill-registry-types.ts +102 -0
  45. package/src/agent/skill-registry.ts +81 -107
  46. package/src/agent/vibe-confirmation-routes.ts +62 -0
  47. package/src/agent/vibe-file.ts +285 -0
  48. package/src/cli/agent-knowledge-command.ts +45 -2
  49. package/src/cli/help.ts +3 -0
  50. package/src/cli/profiles-command.ts +25 -11
  51. package/src/config/agent-settings-policy.ts +1 -18
  52. package/src/input/agent-workspace-activation.ts +53 -0
  53. package/src/input/agent-workspace-artifact-browser-editor.ts +494 -0
  54. package/src/input/agent-workspace-artifact-metadata.ts +17 -0
  55. package/src/input/agent-workspace-basic-command-editors.ts +5 -1
  56. package/src/input/agent-workspace-categories.ts +153 -155
  57. package/src/input/agent-workspace-channel-triage.ts +481 -0
  58. package/src/input/agent-workspace-channels.ts +263 -0
  59. package/src/input/agent-workspace-command-editor.ts +152 -0
  60. package/src/input/agent-workspace-context-snapshot.ts +349 -0
  61. package/src/input/agent-workspace-delegation-editor-submission.ts +8 -0
  62. package/src/input/agent-workspace-document-editor.ts +502 -0
  63. package/src/input/agent-workspace-document-ops-editor.ts +523 -0
  64. package/src/input/agent-workspace-host-category.ts +1 -1
  65. package/src/input/agent-workspace-local-library-snapshot.ts +167 -0
  66. package/src/input/agent-workspace-model-compare-editor.ts +376 -0
  67. package/src/input/agent-workspace-model-compare-prompt-submission.ts +552 -0
  68. package/src/input/agent-workspace-model-compare-types.ts +82 -0
  69. package/src/input/agent-workspace-model-compare-utils.ts +35 -0
  70. package/src/input/agent-workspace-onboarding-categories.ts +141 -0
  71. package/src/input/agent-workspace-operations-command-editor-submission.ts +53 -0
  72. package/src/input/agent-workspace-operations-command-editors.ts +22 -0
  73. package/src/input/agent-workspace-research-report-editor.ts +212 -0
  74. package/src/input/agent-workspace-research-run-editor.ts +144 -0
  75. package/src/input/agent-workspace-research-source-editor.ts +167 -0
  76. package/src/input/agent-workspace-review-packet-snapshot.ts +593 -0
  77. package/src/input/agent-workspace-review-packet-utils.ts +265 -0
  78. package/src/input/agent-workspace-settings.ts +313 -30
  79. package/src/input/agent-workspace-setup-checkpoint-action.ts +127 -0
  80. package/src/input/agent-workspace-setup-snapshot.ts +217 -0
  81. package/src/input/agent-workspace-setup.ts +61 -1
  82. package/src/input/agent-workspace-snapshot.ts +184 -149
  83. package/src/input/agent-workspace-types.ts +287 -2
  84. package/src/input/agent-workspace.ts +23 -1
  85. package/src/input/command-registry.ts +9 -2
  86. package/src/input/commands/agent-runtime-profile-runtime.ts +28 -13
  87. package/src/input/commands/channels-runtime.ts +102 -114
  88. package/src/input/commands/delegation-runtime.ts +87 -24
  89. package/src/input/commands/knowledge-browser-flags.ts +12 -0
  90. package/src/input/commands/knowledge.ts +28 -14
  91. package/src/input/commands/operator-actions-runtime.ts +6 -3
  92. package/src/input/commands/schedule-runtime.ts +71 -14
  93. package/src/input/commands/session-content.ts +2 -2
  94. package/src/input/commands/shell-core.ts +2 -0
  95. package/src/input/commands/vibe-runtime.ts +140 -0
  96. package/src/input/commands.ts +2 -0
  97. package/src/input/connected-host-routes.ts +123 -0
  98. package/src/input/settings-modal-types.ts +14 -0
  99. package/src/input/setup-wizard-live-receipts.ts +76 -0
  100. package/src/main.ts +15 -15
  101. package/src/panels/qr-panel.ts +2 -2
  102. package/src/renderer/agent-workspace-context-lines.ts +701 -0
  103. package/src/renderer/agent-workspace.ts +68 -421
  104. package/src/renderer/settings-modal-helpers.ts +12 -0
  105. package/src/renderer/settings-modal.ts +12 -0
  106. package/src/runtime/bootstrap-command-context.ts +11 -1
  107. package/src/runtime/bootstrap-command-parts.ts +14 -3
  108. package/src/runtime/bootstrap-core.ts +39 -1
  109. package/src/runtime/bootstrap-shell.ts +6 -0
  110. package/src/runtime/bootstrap.ts +113 -30
  111. package/src/runtime/connected-host-auth.ts +3 -2
  112. package/src/runtime/execution-ledger.ts +231 -0
  113. package/src/runtime/services.ts +88 -10
  114. package/src/runtime/tool-permission-safety.ts +199 -5
  115. package/src/shell/session-continuity-hints.ts +39 -0
  116. package/src/tools/agent-artifacts-tool.ts +606 -0
  117. package/src/tools/agent-audit-tool.ts +155 -0
  118. package/src/tools/agent-autonomy-schedule-tool.ts +238 -0
  119. package/src/tools/agent-autonomy-tool.ts +140 -0
  120. package/src/tools/agent-channel-send-tool.ts +24 -2
  121. package/src/tools/agent-channels-tool.ts +140 -0
  122. package/src/tools/agent-computer-tool.ts +168 -0
  123. package/src/tools/agent-context-policy.ts +137 -7
  124. package/src/tools/agent-context-tool.ts +143 -0
  125. package/src/tools/agent-delegation-tool.ts +128 -0
  126. package/src/tools/agent-device-tool.ts +240 -0
  127. package/src/tools/agent-documents-tool.ts +684 -0
  128. package/src/tools/agent-execution-tool.ts +230 -0
  129. package/src/tools/agent-harness-agent-orchestration-policy.ts +75 -0
  130. package/src/tools/agent-harness-agent-orchestration.ts +791 -0
  131. package/src/tools/agent-harness-autonomy-intake.ts +785 -0
  132. package/src/tools/agent-harness-autonomy-live-records.ts +742 -0
  133. package/src/tools/agent-harness-autonomy-queue-types.ts +88 -0
  134. package/src/tools/agent-harness-autonomy-queue.ts +571 -0
  135. package/src/tools/agent-harness-autonomy-watcher-read-models.ts +509 -0
  136. package/src/tools/agent-harness-background-processes-types.ts +35 -0
  137. package/src/tools/agent-harness-background-processes.ts +798 -0
  138. package/src/tools/agent-harness-browser-cockpit-route.ts +373 -0
  139. package/src/tools/agent-harness-browser-control.ts +346 -0
  140. package/src/tools/agent-harness-browser-pwa-read-models.ts +622 -0
  141. package/src/tools/agent-harness-channel-metadata.ts +168 -10
  142. package/src/tools/agent-harness-cli-command-policy.ts +110 -0
  143. package/src/tools/agent-harness-command-catalog.ts +4 -2
  144. package/src/tools/agent-harness-command-runner.ts +42 -0
  145. package/src/tools/agent-harness-connected-host-status.ts +7 -4
  146. package/src/tools/agent-harness-delegation-posture.ts +234 -19
  147. package/src/tools/agent-harness-device-live-read-models.ts +366 -0
  148. package/src/tools/agent-harness-document-ops-reviewer-readiness.ts +234 -0
  149. package/src/tools/agent-harness-document-ops-types.ts +72 -0
  150. package/src/tools/agent-harness-document-ops.ts +671 -0
  151. package/src/tools/agent-harness-execution-history.ts +489 -0
  152. package/src/tools/agent-harness-execution-posture.ts +385 -0
  153. package/src/tools/agent-harness-file-recovery.ts +135 -0
  154. package/src/tools/agent-harness-interactive-runtime-records.ts +421 -0
  155. package/src/tools/agent-harness-keybinding-metadata.ts +16 -12
  156. package/src/tools/agent-harness-learning-curator-common.ts +102 -0
  157. package/src/tools/agent-harness-learning-curator-consolidation.ts +295 -0
  158. package/src/tools/agent-harness-learning-curator-proposals.ts +606 -0
  159. package/src/tools/agent-harness-learning-curator-types.ts +151 -0
  160. package/src/tools/agent-harness-learning-curator.ts +417 -0
  161. package/src/tools/agent-harness-local-model-benchmarks.ts +269 -0
  162. package/src/tools/agent-harness-local-model-cookbook.ts +238 -0
  163. package/src/tools/agent-harness-local-model-endpoints.ts +788 -0
  164. package/src/tools/agent-harness-local-model-smoke.ts +277 -0
  165. package/src/tools/agent-harness-local-model-url.ts +78 -0
  166. package/src/tools/agent-harness-media-posture.ts +223 -2
  167. package/src/tools/agent-harness-memory-external-providers.ts +796 -0
  168. package/src/tools/agent-harness-memory-posture.ts +672 -0
  169. package/src/tools/agent-harness-memory-provider-certification.ts +219 -0
  170. package/src/tools/agent-harness-memory-refinement.ts +340 -0
  171. package/src/tools/agent-harness-metadata.ts +100 -168
  172. package/src/tools/agent-harness-mode-catalog.ts +86 -33
  173. package/src/tools/agent-harness-model-catalog.ts +162 -0
  174. package/src/tools/agent-harness-model-provider-health.ts +283 -0
  175. package/src/tools/agent-harness-model-readiness.ts +432 -0
  176. package/src/tools/agent-harness-model-routing-types.ts +327 -0
  177. package/src/tools/agent-harness-model-routing-utils.ts +30 -0
  178. package/src/tools/agent-harness-model-routing.ts +165 -193
  179. package/src/tools/agent-harness-operator-methods.ts +115 -133
  180. package/src/tools/agent-harness-pairing-posture.ts +452 -18
  181. package/src/tools/agent-harness-personal-ops-certification.ts +116 -0
  182. package/src/tools/agent-harness-personal-ops-discovery.ts +533 -0
  183. package/src/tools/agent-harness-personal-ops-intake.ts +385 -0
  184. package/src/tools/agent-harness-personal-ops-lanes.ts +270 -0
  185. package/src/tools/agent-harness-personal-ops-operations.ts +225 -0
  186. package/src/tools/agent-harness-personal-ops-provider-records.ts +358 -0
  187. package/src/tools/agent-harness-personal-ops-provider-task-records.ts +321 -0
  188. package/src/tools/agent-harness-personal-ops-records.ts +684 -0
  189. package/src/tools/agent-harness-personal-ops-runner.ts +637 -0
  190. package/src/tools/agent-harness-personal-ops-types.ts +240 -0
  191. package/src/tools/agent-harness-personal-ops.ts +613 -0
  192. package/src/tools/agent-harness-project-context.ts +144 -0
  193. package/src/tools/agent-harness-prompt-context.ts +589 -0
  194. package/src/tools/agent-harness-provider-account-metadata.ts +2 -2
  195. package/src/tools/agent-harness-release-evidence.ts +9 -7
  196. package/src/tools/agent-harness-release-readiness.ts +9 -7
  197. package/src/tools/agent-harness-remote-read-models.ts +541 -0
  198. package/src/tools/agent-harness-research-briefing.ts +446 -0
  199. package/src/tools/agent-harness-research-live-read-models.ts +500 -0
  200. package/src/tools/agent-harness-research-queue.ts +250 -0
  201. package/src/tools/agent-harness-research-runs.ts +307 -0
  202. package/src/tools/agent-harness-research-workflow.ts +395 -0
  203. package/src/tools/agent-harness-security-posture.ts +2 -2
  204. package/src/tools/agent-harness-service-posture.ts +9 -9
  205. package/src/tools/agent-harness-session-metadata.ts +3 -3
  206. package/src/tools/agent-harness-setup-connected-host.ts +501 -0
  207. package/src/tools/agent-harness-setup-describe.ts +557 -0
  208. package/src/tools/agent-harness-setup-handoffs.ts +502 -0
  209. package/src/tools/agent-harness-setup-model-helpers.ts +102 -0
  210. package/src/tools/agent-harness-setup-plan.ts +253 -0
  211. package/src/tools/agent-harness-setup-posture-types.ts +218 -0
  212. package/src/tools/agent-harness-setup-posture-utils.ts +173 -0
  213. package/src/tools/agent-harness-setup-posture.ts +449 -221
  214. package/src/tools/agent-harness-setup-smoke.ts +533 -0
  215. package/src/tools/agent-harness-sudo-posture.ts +114 -0
  216. package/src/tools/agent-harness-tool-schema.ts +142 -7
  217. package/src/tools/agent-harness-tool-types.ts +83 -0
  218. package/src/tools/agent-harness-tool-utils.ts +43 -0
  219. package/src/tools/agent-harness-tool.ts +319 -370
  220. package/src/tools/agent-harness-ui-surface-metadata.ts +76 -69
  221. package/src/tools/agent-harness-ui-surface-types.ts +46 -0
  222. package/src/tools/agent-harness-vibe-health.ts +105 -0
  223. package/src/tools/agent-harness-workspace-action-runner.ts +149 -0
  224. package/src/tools/agent-harness-workspace-actions.ts +114 -8
  225. package/src/tools/agent-harness-workspace-editor-execution.ts +214 -0
  226. package/src/tools/agent-harness-workspace-editor-runner.ts +755 -0
  227. package/src/tools/agent-host-tool.ts +159 -0
  228. package/src/tools/agent-knowledge-ingest-tool.ts +34 -1
  229. package/src/tools/agent-learning-consolidation-core.ts +327 -0
  230. package/src/tools/agent-learning-consolidation-tool.ts +758 -0
  231. package/src/tools/agent-memory-tool.ts +253 -0
  232. package/src/tools/agent-model-compare-export.ts +315 -0
  233. package/src/tools/agent-model-compare-handoff.ts +592 -0
  234. package/src/tools/agent-model-compare-judgment.ts +633 -0
  235. package/src/tools/agent-model-compare-run.ts +735 -0
  236. package/src/tools/agent-model-compare-tool.ts +698 -0
  237. package/src/tools/agent-model-compare-types.ts +191 -0
  238. package/src/tools/agent-model-compare-utils.ts +93 -0
  239. package/src/tools/agent-models-tool.ts +208 -0
  240. package/src/tools/agent-operator-action-tool.ts +1 -1
  241. package/src/tools/agent-operator-method-tool.ts +643 -0
  242. package/src/tools/agent-personal-ops-tool.ts +197 -0
  243. package/src/tools/agent-policy-explanation.ts +415 -0
  244. package/src/tools/agent-research-report-tool.ts +608 -0
  245. package/src/tools/agent-research-runner.ts +367 -0
  246. package/src/tools/agent-research-runs-tool.ts +434 -0
  247. package/src/tools/agent-research-sources-tool.ts +443 -0
  248. package/src/tools/agent-research-tool.ts +515 -0
  249. package/src/tools/agent-review-packet-presets-core.ts +757 -0
  250. package/src/tools/agent-review-packet-presets-tool.ts +466 -0
  251. package/src/tools/agent-review-packet-share-tool.ts +305 -0
  252. package/src/tools/agent-route-planner-candidates-setup.ts +411 -0
  253. package/src/tools/agent-route-planner-candidates-surfaces.ts +432 -0
  254. package/src/tools/agent-route-planner-candidates-work.ts +251 -0
  255. package/src/tools/agent-route-planner-helpers.ts +667 -0
  256. package/src/tools/agent-route-planner.ts +185 -0
  257. package/src/tools/agent-route-tool.ts +105 -0
  258. package/src/tools/agent-schedule-edit-tool.ts +210 -0
  259. package/src/tools/agent-schedule-tool.ts +282 -0
  260. package/src/tools/agent-security-tool.ts +145 -0
  261. package/src/tools/agent-sessions-tool.ts +122 -0
  262. package/src/tools/agent-settings-import-tool.ts +104 -0
  263. package/src/tools/agent-settings-tool.ts +176 -0
  264. package/src/tools/agent-setup-tool.ts +226 -0
  265. package/src/tools/agent-support-tool.ts +122 -0
  266. package/src/tools/agent-terminal-process-tools.ts +167 -0
  267. package/src/tools/agent-tool-policy-guard-types.ts +77 -0
  268. package/src/tools/agent-tool-policy-guard.ts +106 -85
  269. package/src/tools/agent-vibe-tool.ts +297 -0
  270. package/src/tools/agent-work-plan-tool.ts +265 -6
  271. package/src/tools/agent-workspace-tool.ts +305 -0
  272. package/src/tools/artifact-archive.ts +169 -0
  273. package/src/tools/tool-definition-compaction.ts +36 -0
  274. package/src/version.ts +1 -1
@@ -0,0 +1,502 @@
1
+ import type { AgentWorkspaceActionResult, AgentWorkspaceLocalEditor, AgentWorkspaceReviewPacketDefaults } from './agent-workspace-types.ts';
2
+
3
+ type AgentWorkspaceFieldReader = (fieldId: string) => string;
4
+
5
+ export interface AgentDocumentWorkspaceToolArgs {
6
+ readonly mode: 'list' | 'show' | 'create' | 'update' | 'review' | 'comment' | 'resolveComment' | 'suggest' | 'acceptSuggestion' | 'rejectSuggestion' | 'export' | 'insertArtifact' | 'attachArtifact';
7
+ readonly documentId?: string;
8
+ readonly artifactId?: string;
9
+ readonly attachmentLabel?: string;
10
+ readonly attachmentNote?: string;
11
+ readonly commentId?: string;
12
+ readonly comment?: string;
13
+ readonly suggestionId?: string;
14
+ readonly suggestionRationale?: string;
15
+ readonly query?: string;
16
+ readonly title?: string;
17
+ readonly body?: string;
18
+ readonly tags?: readonly string[];
19
+ readonly status?: string;
20
+ readonly placement?: string;
21
+ readonly sectionTitle?: string;
22
+ readonly includeContent?: boolean;
23
+ readonly changeSummary?: string;
24
+ readonly includeVersions?: boolean;
25
+ readonly limit?: number;
26
+ readonly confirm?: true;
27
+ readonly explicitUserRequest?: string;
28
+ }
29
+
30
+ function isAffirmative(value: string): boolean {
31
+ const normalized = value.trim().toLowerCase();
32
+ return normalized === 'yes' || normalized === 'true';
33
+ }
34
+
35
+ function splitList(value: string): readonly string[] {
36
+ return value
37
+ .split(/[,\n]/)
38
+ .map((entry) => entry.trim())
39
+ .filter(Boolean);
40
+ }
41
+
42
+ function readPositiveInteger(value: string): number | undefined {
43
+ if (!value.trim()) return undefined;
44
+ const parsed = Number(value);
45
+ if (!Number.isFinite(parsed)) return undefined;
46
+ return Math.max(1, Math.trunc(parsed));
47
+ }
48
+
49
+ export function createAgentDocumentBrowseEditor(): AgentWorkspaceLocalEditor {
50
+ return {
51
+ kind: 'document-browse',
52
+ mode: 'create',
53
+ title: 'Browse Documents',
54
+ selectedFieldIndex: 0,
55
+ message: 'List Agent-owned markdown drafts with version counts, status, tags, and last exported artifact id.',
56
+ fields: [
57
+ { id: 'query', label: 'Search', value: '', required: false, multiline: false, hint: 'Optional search across id, title, body, status, tags, and artifact id.' },
58
+ { id: 'limit', label: 'Limit', value: '20', required: false, multiline: false, hint: 'Maximum document rows to return. Defaults to 20.' },
59
+ ],
60
+ };
61
+ }
62
+
63
+ export function createAgentDocumentShowEditor(): AgentWorkspaceLocalEditor {
64
+ return {
65
+ kind: 'document-show',
66
+ mode: 'create',
67
+ title: 'Show Document',
68
+ selectedFieldIndex: 0,
69
+ message: 'Inspect one Agent-owned document draft and its version history.',
70
+ fields: [
71
+ { id: 'documentId', label: 'Document id', value: '', required: true, multiline: false, hint: 'Document id or exact title.' },
72
+ { id: 'includeVersions', label: 'Include versions', value: 'yes', required: false, multiline: false, hint: 'yes/no. Yes includes version summaries.' },
73
+ ],
74
+ };
75
+ }
76
+
77
+ export function createAgentDocumentCreateEditor(): AgentWorkspaceLocalEditor {
78
+ return {
79
+ kind: 'document-create',
80
+ mode: 'create',
81
+ title: 'Create Document Draft',
82
+ selectedFieldIndex: 0,
83
+ message: 'Create an Agent-owned markdown draft with an initial version. Type yes on the final field to save.',
84
+ fields: [
85
+ { id: 'title', label: 'Title', value: '', required: true, multiline: false, hint: 'Short document title.' },
86
+ { id: 'body', label: 'Markdown body', value: '', required: true, multiline: true, hint: 'Document body. Ctrl-J inserts a new line.' },
87
+ { id: 'tags', label: 'Tags', value: 'document', required: false, multiline: false, hint: 'Comma-separated optional tags.' },
88
+ { id: 'changeSummary', label: 'Version note', value: 'Initial draft.', required: false, multiline: false, hint: 'Short note for version history.' },
89
+ { id: 'confirm', label: 'Confirm', value: '', required: true, multiline: false, hint: 'Type yes to create this Agent document draft.' },
90
+ ],
91
+ };
92
+ }
93
+
94
+ export function createAgentDocumentUpdateEditor(): AgentWorkspaceLocalEditor {
95
+ return {
96
+ kind: 'document-update',
97
+ mode: 'create',
98
+ title: 'Revise Document Draft',
99
+ selectedFieldIndex: 0,
100
+ message: 'Revise an Agent-owned markdown draft and append a new version. Leave optional fields blank to keep existing values.',
101
+ fields: [
102
+ { id: 'documentId', label: 'Document id', value: '', required: true, multiline: false, hint: 'Document id or exact title to revise.' },
103
+ { id: 'title', label: 'Title', value: '', required: false, multiline: false, hint: 'Optional replacement title.' },
104
+ { id: 'body', label: 'Markdown body', value: '', required: false, multiline: true, hint: 'Optional replacement body. Ctrl-J inserts a new line.' },
105
+ { id: 'tags', label: 'Tags', value: '', required: false, multiline: false, hint: 'Optional replacement comma-separated tags.' },
106
+ { id: 'status', label: 'Status', value: '', required: false, multiline: false, hint: 'Optional draft, reviewed, or archived.' },
107
+ { id: 'changeSummary', label: 'Version note', value: 'Updated draft.', required: false, multiline: false, hint: 'Short note for version history.' },
108
+ { id: 'confirm', label: 'Confirm', value: '', required: true, multiline: false, hint: 'Type yes to save a new document version.' },
109
+ ],
110
+ };
111
+ }
112
+
113
+ export function createAgentDocumentReviewEditor(): AgentWorkspaceLocalEditor {
114
+ return {
115
+ kind: 'document-review',
116
+ mode: 'create',
117
+ title: 'Mark Document Reviewed',
118
+ selectedFieldIndex: 0,
119
+ message: 'Mark one Agent-owned document draft as reviewed and append a version history note.',
120
+ fields: [
121
+ { id: 'documentId', label: 'Document id', value: '', required: true, multiline: false, hint: 'Document id or exact title.' },
122
+ { id: 'confirm', label: 'Confirm', value: '', required: true, multiline: false, hint: 'Type yes to mark this document reviewed.' },
123
+ ],
124
+ };
125
+ }
126
+
127
+ export function createAgentDocumentCommentEditor(): AgentWorkspaceLocalEditor {
128
+ return {
129
+ kind: 'document-comment',
130
+ mode: 'create',
131
+ title: 'Add Document Comment',
132
+ selectedFieldIndex: 0,
133
+ message: 'Add one review comment to an Agent-owned document draft. Comments do not change the document body or append a content version.',
134
+ fields: [
135
+ { id: 'documentId', label: 'Document id', value: '', required: true, multiline: false, hint: 'Document id or exact title.' },
136
+ { id: 'comment', label: 'Comment', value: '', required: true, multiline: true, hint: 'Review note or requested change. Ctrl-J inserts a new line.' },
137
+ { id: 'confirm', label: 'Confirm', value: '', required: true, multiline: false, hint: 'Type yes to add this document comment.' },
138
+ ],
139
+ };
140
+ }
141
+
142
+ export function createAgentDocumentResolveCommentEditor(): AgentWorkspaceLocalEditor {
143
+ return {
144
+ kind: 'document-resolve-comment',
145
+ mode: 'create',
146
+ title: 'Resolve Document Comment',
147
+ selectedFieldIndex: 0,
148
+ message: 'Resolve one review comment on an Agent-owned document draft without changing the document body.',
149
+ fields: [
150
+ { id: 'documentId', label: 'Document id', value: '', required: true, multiline: false, hint: 'Document id or exact title.' },
151
+ { id: 'commentId', label: 'Comment id', value: '', required: true, multiline: false, hint: 'Comment id such as c1.' },
152
+ { id: 'confirm', label: 'Confirm', value: '', required: true, multiline: false, hint: 'Type yes to resolve this document comment.' },
153
+ ],
154
+ };
155
+ }
156
+
157
+ export function createAgentDocumentSuggestEditor(): AgentWorkspaceLocalEditor {
158
+ return {
159
+ kind: 'document-suggest',
160
+ mode: 'create',
161
+ title: 'Propose Document Suggestion',
162
+ selectedFieldIndex: 0,
163
+ message: 'Store an AI suggested replacement draft for user review. This does not change the current document until the suggestion is accepted.',
164
+ fields: [
165
+ { id: 'documentId', label: 'Document id', value: '', required: true, multiline: false, hint: 'Document id or exact title.' },
166
+ { id: 'title', label: 'Suggested title', value: '', required: false, multiline: false, hint: 'Optional replacement title. Blank keeps the current title.' },
167
+ { id: 'body', label: 'Suggested body', value: '', required: true, multiline: true, hint: 'Full replacement markdown body. Ctrl-J inserts a new line.' },
168
+ { id: 'tags', label: 'Suggested tags', value: '', required: false, multiline: false, hint: 'Optional replacement comma-separated tags. Blank keeps current tags.' },
169
+ { id: 'status', label: 'Suggested status', value: '', required: false, multiline: false, hint: 'Optional draft, reviewed, or archived.' },
170
+ { id: 'changeSummary', label: 'Change note', value: 'AI suggested revision.', required: false, multiline: false, hint: 'Short note shown in suggestion and version history after accept.' },
171
+ { id: 'suggestionRationale', label: 'Rationale', value: '', required: false, multiline: true, hint: 'Why this replacement helps the user. Ctrl-J inserts a new line.' },
172
+ { id: 'confirm', label: 'Confirm', value: '', required: true, multiline: false, hint: 'Type yes to save this pending suggestion.' },
173
+ ],
174
+ };
175
+ }
176
+
177
+ export function createAgentDocumentAcceptSuggestionEditor(): AgentWorkspaceLocalEditor {
178
+ return {
179
+ kind: 'document-accept-suggestion',
180
+ mode: 'create',
181
+ title: 'Accept Document Suggestion',
182
+ selectedFieldIndex: 0,
183
+ message: 'Accept one pending document suggestion and append a new content version.',
184
+ fields: [
185
+ { id: 'documentId', label: 'Document id', value: '', required: true, multiline: false, hint: 'Document id or exact title.' },
186
+ { id: 'suggestionId', label: 'Suggestion id', value: '', required: true, multiline: false, hint: 'Suggestion id such as s1.' },
187
+ { id: 'confirm', label: 'Confirm', value: '', required: true, multiline: false, hint: 'Type yes to apply this suggestion.' },
188
+ ],
189
+ };
190
+ }
191
+
192
+ export function createAgentDocumentRejectSuggestionEditor(): AgentWorkspaceLocalEditor {
193
+ return {
194
+ kind: 'document-reject-suggestion',
195
+ mode: 'create',
196
+ title: 'Reject Document Suggestion',
197
+ selectedFieldIndex: 0,
198
+ message: 'Reject one pending document suggestion without changing the document body.',
199
+ fields: [
200
+ { id: 'documentId', label: 'Document id', value: '', required: true, multiline: false, hint: 'Document id or exact title.' },
201
+ { id: 'suggestionId', label: 'Suggestion id', value: '', required: true, multiline: false, hint: 'Suggestion id such as s1.' },
202
+ { id: 'confirm', label: 'Confirm', value: '', required: true, multiline: false, hint: 'Type yes to reject this suggestion.' },
203
+ ],
204
+ };
205
+ }
206
+
207
+ export function createAgentDocumentExportEditor(defaults: AgentWorkspaceReviewPacketDefaults | null = null): AgentWorkspaceLocalEditor {
208
+ const defaultDocument = defaults?.documentId ?? '';
209
+ const defaultHint = defaults?.summary
210
+ ? `Packet default: ${defaults.summary}. ${defaults.documentTitle ? `Document: ${defaults.documentTitle}. ` : ''}Clear it to choose another document.`
211
+ : 'Document id or exact title to export.';
212
+ return {
213
+ kind: 'document-export',
214
+ mode: 'create',
215
+ title: 'Export Document Artifact',
216
+ selectedFieldIndex: 0,
217
+ message: 'Export one Agent-owned markdown draft as a saved artifact with document id and version metadata.',
218
+ fields: [
219
+ { id: 'documentId', label: 'Document id', value: defaultDocument, required: true, multiline: false, hint: defaultDocument ? defaultHint : 'Document id or exact title to export.' },
220
+ { id: 'confirm', label: 'Confirm', value: '', required: true, multiline: false, hint: 'Type yes to export this document as an artifact.' },
221
+ ],
222
+ };
223
+ }
224
+
225
+ export function createAgentDocumentInsertArtifactEditor(): AgentWorkspaceLocalEditor {
226
+ return {
227
+ kind: 'document-insert-artifact',
228
+ mode: 'create',
229
+ title: 'Insert Artifact in Document',
230
+ selectedFieldIndex: 0,
231
+ message: 'Insert one saved artifact into an Agent-owned markdown draft as a new version. Text artifacts insert bounded content; binary artifacts insert a safe reference block.',
232
+ fields: [
233
+ { id: 'documentId', label: 'Document id', value: '', required: true, multiline: false, hint: 'Document id or exact title to revise.' },
234
+ { id: 'artifactId', label: 'Artifact id', value: '', required: true, multiline: false, hint: 'Saved artifact id such as artifact-123.' },
235
+ { id: 'placement', label: 'Placement', value: 'append', required: false, multiline: false, hint: 'append, prepend, or replace. Defaults to append.' },
236
+ { id: 'sectionTitle', label: 'Section title', value: '', required: false, multiline: false, hint: 'Optional markdown heading for inserted artifact content.' },
237
+ { id: 'includeContent', label: 'Include text', value: 'yes', required: false, multiline: false, hint: 'yes/no. Yes inserts bounded text for text-like artifacts. Binary artifacts always insert a reference.' },
238
+ { id: 'changeSummary', label: 'Version note', value: 'Inserted saved artifact.', required: false, multiline: false, hint: 'Short note for version history.' },
239
+ { id: 'confirm', label: 'Confirm', value: '', required: true, multiline: false, hint: 'Type yes to save a new document version with this artifact.' },
240
+ ],
241
+ };
242
+ }
243
+
244
+ export function createAgentDocumentAttachArtifactEditor(): AgentWorkspaceLocalEditor {
245
+ return {
246
+ kind: 'document-attach-artifact',
247
+ mode: 'create',
248
+ title: 'Attach Artifact to Document',
249
+ selectedFieldIndex: 0,
250
+ message: 'Attach one saved artifact to an Agent-owned markdown draft without changing the document body. The attachment appears in show/export metadata.',
251
+ fields: [
252
+ { id: 'documentId', label: 'Document id', value: '', required: true, multiline: false, hint: 'Document id or exact title to attach the artifact to.' },
253
+ { id: 'artifactId', label: 'Artifact id', value: '', required: true, multiline: false, hint: 'Saved artifact id such as artifact-123.' },
254
+ { id: 'attachmentLabel', label: 'Label', value: '', required: false, multiline: false, hint: 'Optional short label. Defaults to the artifact filename or id.' },
255
+ { id: 'attachmentNote', label: 'Note', value: '', required: false, multiline: true, hint: 'Optional note explaining why this artifact belongs with the draft. Ctrl-J inserts a new line.' },
256
+ { id: 'confirm', label: 'Confirm', value: '', required: true, multiline: false, hint: 'Type yes to attach this artifact to the document.' },
257
+ ],
258
+ };
259
+ }
260
+
261
+ export function buildAgentDocumentToolArgs(
262
+ editor: AgentWorkspaceLocalEditor,
263
+ readField: AgentWorkspaceFieldReader,
264
+ explicitUserRequest: string,
265
+ ): AgentDocumentWorkspaceToolArgs {
266
+ const documentId = readField('documentId').trim();
267
+ const title = readField('title').trim();
268
+ const body = readField('body').trim();
269
+ const tags = splitList(readField('tags'));
270
+ const changeSummary = readField('changeSummary').trim();
271
+ if (editor.kind === 'document-browse') {
272
+ const query = readField('query').trim();
273
+ const limit = readPositiveInteger(readField('limit'));
274
+ return {
275
+ mode: 'list',
276
+ ...(query ? { query } : {}),
277
+ ...(limit ? { limit } : {}),
278
+ };
279
+ }
280
+ if (editor.kind === 'document-show') {
281
+ return {
282
+ mode: 'show',
283
+ documentId,
284
+ includeVersions: isAffirmative(readField('includeVersions')),
285
+ };
286
+ }
287
+ if (editor.kind === 'document-create') {
288
+ return {
289
+ mode: 'create',
290
+ title,
291
+ body,
292
+ ...(tags.length > 0 ? { tags } : {}),
293
+ ...(changeSummary ? { changeSummary } : {}),
294
+ confirm: true,
295
+ explicitUserRequest,
296
+ };
297
+ }
298
+ if (editor.kind === 'document-update') {
299
+ const status = readField('status').trim();
300
+ return {
301
+ mode: 'update',
302
+ documentId,
303
+ ...(title ? { title } : {}),
304
+ ...(body ? { body } : {}),
305
+ ...(tags.length > 0 ? { tags } : {}),
306
+ ...(status ? { status } : {}),
307
+ ...(changeSummary ? { changeSummary } : {}),
308
+ confirm: true,
309
+ explicitUserRequest,
310
+ };
311
+ }
312
+ if (editor.kind === 'document-review') {
313
+ return {
314
+ mode: 'review',
315
+ documentId,
316
+ confirm: true,
317
+ explicitUserRequest,
318
+ };
319
+ }
320
+ if (editor.kind === 'document-comment') {
321
+ return {
322
+ mode: 'comment',
323
+ documentId,
324
+ comment: readField('comment').trim(),
325
+ confirm: true,
326
+ explicitUserRequest,
327
+ };
328
+ }
329
+ if (editor.kind === 'document-resolve-comment') {
330
+ return {
331
+ mode: 'resolveComment',
332
+ documentId,
333
+ commentId: readField('commentId').trim(),
334
+ confirm: true,
335
+ explicitUserRequest,
336
+ };
337
+ }
338
+ if (editor.kind === 'document-suggest') {
339
+ const status = readField('status').trim();
340
+ const suggestionRationale = readField('suggestionRationale').trim();
341
+ return {
342
+ mode: 'suggest',
343
+ documentId,
344
+ ...(title ? { title } : {}),
345
+ body,
346
+ ...(tags.length > 0 ? { tags } : {}),
347
+ ...(status ? { status } : {}),
348
+ ...(changeSummary ? { changeSummary } : {}),
349
+ ...(suggestionRationale ? { suggestionRationale } : {}),
350
+ confirm: true,
351
+ explicitUserRequest,
352
+ };
353
+ }
354
+ if (editor.kind === 'document-accept-suggestion') {
355
+ return {
356
+ mode: 'acceptSuggestion',
357
+ documentId,
358
+ suggestionId: readField('suggestionId').trim(),
359
+ confirm: true,
360
+ explicitUserRequest,
361
+ };
362
+ }
363
+ if (editor.kind === 'document-reject-suggestion') {
364
+ return {
365
+ mode: 'rejectSuggestion',
366
+ documentId,
367
+ suggestionId: readField('suggestionId').trim(),
368
+ confirm: true,
369
+ explicitUserRequest,
370
+ };
371
+ }
372
+ if (editor.kind === 'document-insert-artifact') {
373
+ const placement = readField('placement').trim();
374
+ const sectionTitle = readField('sectionTitle').trim();
375
+ return {
376
+ mode: 'insertArtifact',
377
+ documentId,
378
+ artifactId: readField('artifactId').trim(),
379
+ ...(placement ? { placement } : {}),
380
+ ...(sectionTitle ? { sectionTitle } : {}),
381
+ includeContent: isAffirmative(readField('includeContent')),
382
+ ...(changeSummary ? { changeSummary } : {}),
383
+ confirm: true,
384
+ explicitUserRequest,
385
+ };
386
+ }
387
+ if (editor.kind === 'document-attach-artifact') {
388
+ const attachmentLabel = readField('attachmentLabel').trim();
389
+ const attachmentNote = readField('attachmentNote').trim();
390
+ return {
391
+ mode: 'attachArtifact',
392
+ documentId,
393
+ artifactId: readField('artifactId').trim(),
394
+ ...(attachmentLabel ? { attachmentLabel } : {}),
395
+ ...(attachmentNote ? { attachmentNote } : {}),
396
+ confirm: true,
397
+ explicitUserRequest,
398
+ };
399
+ }
400
+ return {
401
+ mode: 'export',
402
+ documentId,
403
+ confirm: true,
404
+ explicitUserRequest,
405
+ };
406
+ }
407
+
408
+ export function buildAgentDocumentPromptSubmission(
409
+ editor: AgentWorkspaceLocalEditor,
410
+ readField: AgentWorkspaceFieldReader,
411
+ promptDispatchAvailable: boolean,
412
+ ): {
413
+ readonly kind: 'editor';
414
+ readonly editor: AgentWorkspaceLocalEditor;
415
+ readonly status: string;
416
+ readonly actionResult?: AgentWorkspaceActionResult;
417
+ } | {
418
+ readonly kind: 'prompt';
419
+ readonly prompt: string;
420
+ readonly status: string;
421
+ readonly actionResult: AgentWorkspaceActionResult;
422
+ } {
423
+ const mutation = editor.kind === 'document-create'
424
+ || editor.kind === 'document-update'
425
+ || editor.kind === 'document-review'
426
+ || editor.kind === 'document-comment'
427
+ || editor.kind === 'document-resolve-comment'
428
+ || editor.kind === 'document-suggest'
429
+ || editor.kind === 'document-accept-suggestion'
430
+ || editor.kind === 'document-reject-suggestion'
431
+ || editor.kind === 'document-insert-artifact'
432
+ || editor.kind === 'document-attach-artifact'
433
+ || editor.kind === 'document-export';
434
+ if (mutation && !isAffirmative(readField('confirm'))) {
435
+ return {
436
+ kind: 'editor',
437
+ editor: { ...editor, message: 'Type yes to confirm this Agent document action.' },
438
+ status: 'Agent document action not confirmed.',
439
+ };
440
+ }
441
+
442
+ if (!promptDispatchAvailable) {
443
+ return {
444
+ kind: 'editor',
445
+ editor: {
446
+ ...editor,
447
+ message: 'Prompt dispatch is unavailable in this runtime. Use agent_harness mode:"run_workspace_action" with this editor schema.',
448
+ },
449
+ status: 'Prompt dispatch unavailable.',
450
+ actionResult: {
451
+ kind: 'error',
452
+ title: 'Prompt dispatch unavailable',
453
+ detail: 'This runtime cannot submit the document request from the workspace form.',
454
+ safety: mutation ? 'safe' : 'read-only',
455
+ },
456
+ };
457
+ }
458
+
459
+ const args = buildAgentDocumentToolArgs(
460
+ editor,
461
+ readField,
462
+ `Run the Agent document workspace action ${editor.title}.`,
463
+ );
464
+ const prompt = [
465
+ 'Use the `agent_documents` tool for this Agent document workspace request.',
466
+ `mode: ${JSON.stringify(args.mode)}`,
467
+ args.documentId ? `documentId: ${JSON.stringify(args.documentId)}` : 'documentId: none',
468
+ args.artifactId ? `artifactId: ${JSON.stringify(args.artifactId)}` : 'artifactId: none',
469
+ args.attachmentLabel ? `attachmentLabel: ${JSON.stringify(args.attachmentLabel)}` : 'attachmentLabel: none',
470
+ args.attachmentNote ? `attachmentNote: ${JSON.stringify(args.attachmentNote)}` : 'attachmentNote: none',
471
+ args.commentId ? `commentId: ${JSON.stringify(args.commentId)}` : 'commentId: none',
472
+ args.comment ? `comment: ${JSON.stringify(args.comment)}` : 'comment: none',
473
+ args.suggestionId ? `suggestionId: ${JSON.stringify(args.suggestionId)}` : 'suggestionId: none',
474
+ args.suggestionRationale ? `suggestionRationale: ${JSON.stringify(args.suggestionRationale)}` : 'suggestionRationale: none',
475
+ args.query ? `query: ${JSON.stringify(args.query)}` : 'query: none',
476
+ args.title ? `title: ${JSON.stringify(args.title)}` : 'title: none',
477
+ args.body ? `body: ${JSON.stringify(args.body)}` : 'body: none',
478
+ args.tags && args.tags.length > 0 ? `tags: ${JSON.stringify(args.tags)}` : 'tags: none',
479
+ args.status ? `status: ${JSON.stringify(args.status)}` : 'status: none',
480
+ args.placement ? `placement: ${JSON.stringify(args.placement)}` : 'placement: none',
481
+ args.sectionTitle ? `sectionTitle: ${JSON.stringify(args.sectionTitle)}` : 'sectionTitle: none',
482
+ args.changeSummary ? `changeSummary: ${JSON.stringify(args.changeSummary)}` : 'changeSummary: none',
483
+ typeof args.limit === 'number' ? `limit: ${args.limit}` : 'limit: default',
484
+ typeof args.includeVersions === 'boolean' ? `includeVersions: ${args.includeVersions ? 'true' : 'false'}` : 'includeVersions: default',
485
+ typeof args.includeContent === 'boolean' ? `includeContent: ${args.includeContent ? 'true' : 'false'}` : 'includeContent: default',
486
+ args.confirm ? 'confirm: true' : 'confirm: not required',
487
+ args.explicitUserRequest ? `explicitUserRequest: ${JSON.stringify(args.explicitUserRequest)}` : 'explicitUserRequest: not required',
488
+ 'Policy: Agent-owned document drafts only; no default knowledge write and no artifact export unless mode is export.',
489
+ ].join('\n');
490
+
491
+ return {
492
+ kind: 'prompt',
493
+ prompt,
494
+ status: 'Submitting Agent document request.',
495
+ actionResult: {
496
+ kind: 'guidance',
497
+ title: editor.title,
498
+ detail: 'Submitted an Agent document request through the first-class document tool.',
499
+ safety: mutation ? 'safe' : 'read-only',
500
+ },
501
+ };
502
+ }