@pellux/goodvibes-agent 1.1.6 → 1.2.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 (256) hide show
  1. package/CHANGELOG.md +176 -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 +132662 -91399
  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 +56 -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 +114 -45
  14. package/docs/voice-and-live-tts.md +3 -1
  15. package/package.json +3 -2
  16. package/release/release-notes.md +130 -5
  17. package/release/release-readiness.json +120 -90
  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 +296 -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-checkpoint.ts +140 -0
  42. package/src/agent/setup-wizard.ts +447 -0
  43. package/src/agent/skill-registry-types.ts +102 -0
  44. package/src/agent/skill-registry.ts +81 -107
  45. package/src/agent/vibe-confirmation-routes.ts +62 -0
  46. package/src/agent/vibe-file.ts +285 -0
  47. package/src/cli/agent-knowledge-command.ts +45 -2
  48. package/src/cli/help.ts +3 -0
  49. package/src/cli/profiles-command.ts +25 -11
  50. package/src/config/agent-settings-policy.ts +1 -18
  51. package/src/input/agent-workspace-activation.ts +53 -0
  52. package/src/input/agent-workspace-artifact-browser-editor.ts +494 -0
  53. package/src/input/agent-workspace-artifact-metadata.ts +17 -0
  54. package/src/input/agent-workspace-basic-command-editors.ts +5 -1
  55. package/src/input/agent-workspace-categories.ts +153 -155
  56. package/src/input/agent-workspace-channel-triage.ts +481 -0
  57. package/src/input/agent-workspace-channels.ts +263 -0
  58. package/src/input/agent-workspace-command-editor.ts +152 -0
  59. package/src/input/agent-workspace-context-snapshot.ts +349 -0
  60. package/src/input/agent-workspace-delegation-editor-submission.ts +8 -0
  61. package/src/input/agent-workspace-document-editor.ts +502 -0
  62. package/src/input/agent-workspace-document-ops-editor.ts +523 -0
  63. package/src/input/agent-workspace-host-category.ts +1 -1
  64. package/src/input/agent-workspace-local-library-snapshot.ts +167 -0
  65. package/src/input/agent-workspace-model-compare-editor.ts +376 -0
  66. package/src/input/agent-workspace-model-compare-prompt-submission.ts +552 -0
  67. package/src/input/agent-workspace-model-compare-types.ts +82 -0
  68. package/src/input/agent-workspace-model-compare-utils.ts +35 -0
  69. package/src/input/agent-workspace-onboarding-categories.ts +141 -0
  70. package/src/input/agent-workspace-operations-command-editor-submission.ts +53 -0
  71. package/src/input/agent-workspace-operations-command-editors.ts +22 -0
  72. package/src/input/agent-workspace-research-report-editor.ts +212 -0
  73. package/src/input/agent-workspace-research-run-editor.ts +144 -0
  74. package/src/input/agent-workspace-research-source-editor.ts +167 -0
  75. package/src/input/agent-workspace-review-packet-snapshot.ts +593 -0
  76. package/src/input/agent-workspace-review-packet-utils.ts +265 -0
  77. package/src/input/agent-workspace-settings.ts +262 -30
  78. package/src/input/agent-workspace-setup-checkpoint-action.ts +127 -0
  79. package/src/input/agent-workspace-setup-snapshot.ts +198 -0
  80. package/src/input/agent-workspace-setup.ts +34 -1
  81. package/src/input/agent-workspace-snapshot.ts +162 -147
  82. package/src/input/agent-workspace-types.ts +287 -2
  83. package/src/input/agent-workspace.ts +18 -0
  84. package/src/input/command-registry.ts +9 -2
  85. package/src/input/commands/agent-runtime-profile-runtime.ts +28 -13
  86. package/src/input/commands/channels-runtime.ts +102 -114
  87. package/src/input/commands/delegation-runtime.ts +87 -24
  88. package/src/input/commands/knowledge-browser-flags.ts +12 -0
  89. package/src/input/commands/knowledge.ts +28 -14
  90. package/src/input/commands/operator-actions-runtime.ts +6 -3
  91. package/src/input/commands/schedule-runtime.ts +71 -14
  92. package/src/input/commands/session-content.ts +2 -2
  93. package/src/input/commands/shell-core.ts +2 -0
  94. package/src/input/commands/vibe-runtime.ts +140 -0
  95. package/src/input/commands.ts +2 -0
  96. package/src/input/connected-host-routes.ts +123 -0
  97. package/src/input/settings-modal-types.ts +14 -0
  98. package/src/main.ts +15 -15
  99. package/src/panels/qr-panel.ts +2 -2
  100. package/src/renderer/agent-workspace-context-lines.ts +686 -0
  101. package/src/renderer/agent-workspace.ts +30 -419
  102. package/src/renderer/settings-modal-helpers.ts +12 -0
  103. package/src/renderer/settings-modal.ts +12 -0
  104. package/src/runtime/bootstrap-command-context.ts +11 -1
  105. package/src/runtime/bootstrap-command-parts.ts +14 -3
  106. package/src/runtime/bootstrap-core.ts +43 -1
  107. package/src/runtime/bootstrap-shell.ts +6 -0
  108. package/src/runtime/bootstrap.ts +113 -30
  109. package/src/runtime/connected-host-auth.ts +3 -2
  110. package/src/runtime/execution-ledger.ts +231 -0
  111. package/src/runtime/services.ts +88 -10
  112. package/src/runtime/tool-permission-safety.ts +287 -0
  113. package/src/shell/session-continuity-hints.ts +39 -0
  114. package/src/tools/agent-artifacts-tool.ts +606 -0
  115. package/src/tools/agent-audit-tool.ts +155 -0
  116. package/src/tools/agent-autonomy-schedule-tool.ts +238 -0
  117. package/src/tools/agent-autonomy-tool.ts +140 -0
  118. package/src/tools/agent-channel-send-tool.ts +24 -2
  119. package/src/tools/agent-channels-tool.ts +140 -0
  120. package/src/tools/agent-computer-tool.ts +168 -0
  121. package/src/tools/agent-context-policy.ts +267 -10
  122. package/src/tools/agent-context-tool.ts +143 -0
  123. package/src/tools/agent-delegation-tool.ts +128 -0
  124. package/src/tools/agent-device-tool.ts +240 -0
  125. package/src/tools/agent-documents-tool.ts +684 -0
  126. package/src/tools/agent-execution-tool.ts +230 -0
  127. package/src/tools/agent-harness-agent-orchestration.ts +703 -0
  128. package/src/tools/agent-harness-autonomy-intake.ts +785 -0
  129. package/src/tools/agent-harness-autonomy-live-records.ts +588 -0
  130. package/src/tools/agent-harness-autonomy-queue-types.ts +88 -0
  131. package/src/tools/agent-harness-autonomy-queue.ts +560 -0
  132. package/src/tools/agent-harness-background-processes-types.ts +35 -0
  133. package/src/tools/agent-harness-background-processes.ts +794 -0
  134. package/src/tools/agent-harness-browser-cockpit-route.ts +219 -0
  135. package/src/tools/agent-harness-browser-control.ts +338 -0
  136. package/src/tools/agent-harness-channel-metadata.ts +168 -10
  137. package/src/tools/agent-harness-cli-command-policy.ts +110 -0
  138. package/src/tools/agent-harness-command-catalog.ts +4 -2
  139. package/src/tools/agent-harness-command-runner.ts +42 -0
  140. package/src/tools/agent-harness-connected-host-status.ts +7 -4
  141. package/src/tools/agent-harness-delegation-posture.ts +234 -19
  142. package/src/tools/agent-harness-document-ops-reviewer-readiness.ts +234 -0
  143. package/src/tools/agent-harness-document-ops-types.ts +72 -0
  144. package/src/tools/agent-harness-document-ops.ts +671 -0
  145. package/src/tools/agent-harness-execution-history.ts +489 -0
  146. package/src/tools/agent-harness-execution-posture.ts +382 -0
  147. package/src/tools/agent-harness-file-recovery.ts +135 -0
  148. package/src/tools/agent-harness-keybinding-metadata.ts +16 -12
  149. package/src/tools/agent-harness-learning-curator-common.ts +102 -0
  150. package/src/tools/agent-harness-learning-curator-consolidation.ts +295 -0
  151. package/src/tools/agent-harness-learning-curator-proposals.ts +606 -0
  152. package/src/tools/agent-harness-learning-curator-types.ts +151 -0
  153. package/src/tools/agent-harness-learning-curator.ts +417 -0
  154. package/src/tools/agent-harness-local-model-benchmarks.ts +199 -0
  155. package/src/tools/agent-harness-local-model-cookbook.ts +238 -0
  156. package/src/tools/agent-harness-local-model-endpoints.ts +673 -0
  157. package/src/tools/agent-harness-media-posture.ts +208 -2
  158. package/src/tools/agent-harness-memory-posture.ts +556 -0
  159. package/src/tools/agent-harness-metadata.ts +100 -168
  160. package/src/tools/agent-harness-mode-catalog.ts +84 -33
  161. package/src/tools/agent-harness-model-catalog.ts +162 -0
  162. package/src/tools/agent-harness-model-provider-health.ts +186 -0
  163. package/src/tools/agent-harness-model-readiness.ts +406 -0
  164. package/src/tools/agent-harness-model-routing-types.ts +266 -0
  165. package/src/tools/agent-harness-model-routing-utils.ts +30 -0
  166. package/src/tools/agent-harness-model-routing.ts +137 -190
  167. package/src/tools/agent-harness-operator-methods.ts +115 -133
  168. package/src/tools/agent-harness-pairing-posture.ts +431 -18
  169. package/src/tools/agent-harness-personal-ops-discovery.ts +533 -0
  170. package/src/tools/agent-harness-personal-ops-intake.ts +385 -0
  171. package/src/tools/agent-harness-personal-ops-lanes.ts +204 -0
  172. package/src/tools/agent-harness-personal-ops-records.ts +732 -0
  173. package/src/tools/agent-harness-personal-ops-runner.ts +637 -0
  174. package/src/tools/agent-harness-personal-ops-types.ts +222 -0
  175. package/src/tools/agent-harness-personal-ops.ts +606 -0
  176. package/src/tools/agent-harness-project-context.ts +144 -0
  177. package/src/tools/agent-harness-prompt-context.ts +589 -0
  178. package/src/tools/agent-harness-provider-account-metadata.ts +2 -2
  179. package/src/tools/agent-harness-release-evidence.ts +9 -7
  180. package/src/tools/agent-harness-release-readiness.ts +9 -7
  181. package/src/tools/agent-harness-research-briefing.ts +427 -0
  182. package/src/tools/agent-harness-research-queue.ts +250 -0
  183. package/src/tools/agent-harness-research-runs.ts +295 -0
  184. package/src/tools/agent-harness-research-workflow.ts +322 -0
  185. package/src/tools/agent-harness-security-posture.ts +2 -2
  186. package/src/tools/agent-harness-service-posture.ts +9 -9
  187. package/src/tools/agent-harness-session-metadata.ts +3 -3
  188. package/src/tools/agent-harness-setup-connected-host.ts +501 -0
  189. package/src/tools/agent-harness-setup-describe.ts +557 -0
  190. package/src/tools/agent-harness-setup-handoffs.ts +502 -0
  191. package/src/tools/agent-harness-setup-model-helpers.ts +101 -0
  192. package/src/tools/agent-harness-setup-plan.ts +253 -0
  193. package/src/tools/agent-harness-setup-posture-types.ts +218 -0
  194. package/src/tools/agent-harness-setup-posture-utils.ts +173 -0
  195. package/src/tools/agent-harness-setup-posture.ts +449 -221
  196. package/src/tools/agent-harness-setup-smoke.ts +508 -0
  197. package/src/tools/agent-harness-sudo-posture.ts +114 -0
  198. package/src/tools/agent-harness-tool-schema.ts +120 -7
  199. package/src/tools/agent-harness-tool-types.ts +78 -0
  200. package/src/tools/agent-harness-tool-utils.ts +43 -0
  201. package/src/tools/agent-harness-tool.ts +311 -370
  202. package/src/tools/agent-harness-ui-surface-metadata.ts +76 -69
  203. package/src/tools/agent-harness-ui-surface-types.ts +46 -0
  204. package/src/tools/agent-harness-vibe-health.ts +105 -0
  205. package/src/tools/agent-harness-workspace-action-runner.ts +149 -0
  206. package/src/tools/agent-harness-workspace-actions.ts +114 -8
  207. package/src/tools/agent-harness-workspace-editor-execution.ts +214 -0
  208. package/src/tools/agent-harness-workspace-editor-runner.ts +755 -0
  209. package/src/tools/agent-host-tool.ts +159 -0
  210. package/src/tools/agent-knowledge-ingest-tool.ts +34 -1
  211. package/src/tools/agent-learning-consolidation-core.ts +327 -0
  212. package/src/tools/agent-learning-consolidation-tool.ts +758 -0
  213. package/src/tools/agent-memory-tool.ts +214 -0
  214. package/src/tools/agent-model-compare-export.ts +315 -0
  215. package/src/tools/agent-model-compare-handoff.ts +592 -0
  216. package/src/tools/agent-model-compare-judgment.ts +633 -0
  217. package/src/tools/agent-model-compare-run.ts +722 -0
  218. package/src/tools/agent-model-compare-tool.ts +698 -0
  219. package/src/tools/agent-model-compare-types.ts +191 -0
  220. package/src/tools/agent-model-compare-utils.ts +93 -0
  221. package/src/tools/agent-models-tool.ts +208 -0
  222. package/src/tools/agent-operator-action-tool.ts +1 -1
  223. package/src/tools/agent-operator-method-tool.ts +643 -0
  224. package/src/tools/agent-personal-ops-tool.ts +197 -0
  225. package/src/tools/agent-policy-explanation.ts +415 -0
  226. package/src/tools/agent-research-report-tool.ts +608 -0
  227. package/src/tools/agent-research-runs-tool.ts +434 -0
  228. package/src/tools/agent-research-sources-tool.ts +443 -0
  229. package/src/tools/agent-research-tool.ts +687 -0
  230. package/src/tools/agent-review-packet-presets-core.ts +757 -0
  231. package/src/tools/agent-review-packet-presets-tool.ts +466 -0
  232. package/src/tools/agent-review-packet-share-tool.ts +305 -0
  233. package/src/tools/agent-route-planner-candidates-setup.ts +411 -0
  234. package/src/tools/agent-route-planner-candidates-surfaces.ts +432 -0
  235. package/src/tools/agent-route-planner-candidates-work.ts +251 -0
  236. package/src/tools/agent-route-planner-helpers.ts +667 -0
  237. package/src/tools/agent-route-planner.ts +185 -0
  238. package/src/tools/agent-route-tool.ts +105 -0
  239. package/src/tools/agent-schedule-edit-tool.ts +210 -0
  240. package/src/tools/agent-schedule-tool.ts +282 -0
  241. package/src/tools/agent-security-tool.ts +145 -0
  242. package/src/tools/agent-sessions-tool.ts +122 -0
  243. package/src/tools/agent-settings-import-tool.ts +104 -0
  244. package/src/tools/agent-settings-tool.ts +176 -0
  245. package/src/tools/agent-setup-tool.ts +226 -0
  246. package/src/tools/agent-support-tool.ts +122 -0
  247. package/src/tools/agent-terminal-process-tools.ts +167 -0
  248. package/src/tools/agent-tool-policy-guard-types.ts +77 -0
  249. package/src/tools/agent-tool-policy-guard.ts +110 -89
  250. package/src/tools/agent-vibe-tool.ts +297 -0
  251. package/src/tools/agent-work-plan-tool.ts +265 -6
  252. package/src/tools/agent-workspace-tool.ts +305 -0
  253. package/src/tools/artifact-archive.ts +169 -0
  254. package/src/tools/tool-definition-compaction.ts +36 -0
  255. package/src/tools/tool-execution-safety.ts +41 -0
  256. package/src/version.ts +1 -1
@@ -0,0 +1,287 @@
1
+ import type { PermissionCategory, PermissionCheckResult } from '@pellux/goodvibes-sdk/platform/permissions';
2
+ import { summarizeError } from '@pellux/goodvibes-sdk/platform/utils';
3
+
4
+ type PermissionManagerLike = {
5
+ check(toolName: string, args: Record<string, unknown>): Promise<boolean>;
6
+ checkDetailed?: (toolName: string, args: Record<string, unknown>) => Promise<PermissionCheckResult>;
7
+ getCategory(toolName: string, args?: Record<string, unknown>): PermissionCategory;
8
+ };
9
+
10
+ const SAFETY_MARKER = Symbol.for('goodvibes-agent.permission-safety-installed');
11
+
12
+ const READ_TOOL_NAMES = new Set([
13
+ 'read',
14
+ 'find',
15
+ 'fetch',
16
+ 'analyze',
17
+ 'inspect',
18
+ 'state',
19
+ 'registry',
20
+ 'route',
21
+ 'goodvibes_context',
22
+ 'autonomy',
23
+ 'channels',
24
+ 'computer',
25
+ 'context',
26
+ 'delegation',
27
+ 'device',
28
+ 'execution',
29
+ 'host',
30
+ 'memory',
31
+ 'models',
32
+ 'personal_ops',
33
+ 'research',
34
+ 'security',
35
+ 'setup',
36
+ 'settings',
37
+ 'vibe',
38
+ 'workspace',
39
+ 'agent_harness',
40
+ 'agent_knowledge',
41
+ 'agent_operator_briefing',
42
+ ]);
43
+
44
+ const WRITE_TOOL_NAMES = new Set([
45
+ 'write',
46
+ 'edit',
47
+ 'goodvibes_settings',
48
+ 'agent_artifacts',
49
+ 'agent_documents',
50
+ 'agent_knowledge_ingest',
51
+ 'agent_learning_consolidation',
52
+ 'agent_local_registry',
53
+ 'agent_research_runs',
54
+ 'agent_research_sources',
55
+ 'agent_research_report',
56
+ 'agent_review_packet_presets',
57
+ 'agent_work_plan',
58
+ ]);
59
+
60
+ const EXECUTE_TOOL_NAMES = new Set(['exec', 'repl', 'terminal', 'process']);
61
+ const READ_ONLY_PROCESS_ACTIONS = new Set(['', 'list', 'status', 'poll', 'log', 'output', 'capabilities', 'doctor', 'parity']);
62
+ const READ_ONLY_SCHEDULE_ACTIONS = new Set(['', 'list', 'status', 'show']);
63
+ const READ_ONLY_SETTINGS_IMPORT_ACTIONS = new Set(['', 'preview', 'inspect', 'show', 'plan']);
64
+ const READ_ONLY_SETTINGS_ACTIONS = new Set(['', 'list', 'status', 'settings', 'catalog', 'search', 'find', 'browse', 'get', 'show', 'inspect', 'read', 'setting', 'get_setting', 'import', 'import_settings', 'settings_import', 'import_goodvibes', 'goodvibes_import', 'preview_import']);
65
+ const READ_ONLY_SETUP_ACTIONS = new Set(['', 'status', 'summary', 'list', 'item', 'show', 'inspect', 'repair', 'fix', 'diagnose_repair', 'host_repair', 'repair_host', 'launch_host', 'checkpoint', 'checkpoint_status']);
66
+ const READ_ONLY_VIBE_ACTIONS = new Set(['', 'status', 'summary', 'list', 'show', 'file', 'source', 'read', 'inspect']);
67
+ const READ_ONLY_PERSONAL_OPS_ACTIONS = new Set(['', 'briefing', 'brief', 'daily', 'daily_brief', 'morning', 'status', 'summary', 'overview', 'map', 'list', 'queue', 'queues', 'review_queue', 'review_queues', 'personal_queue', 'ops_queue', 'intake', 'request', 'route', 'plan', 'triage', 'draft', 'lane', 'inspect', 'show']);
68
+ const READ_ONLY_RESEARCH_ACTIONS = new Set(['', 'briefing', 'brief', 'status', 'dashboard', 'cockpit', 'next', 'plan', 'workflow', 'research', 'runner', 'browser', 'browser_runner', 'browser_backed', 'deep_research', 'runs', 'list_runs', 'run_list', 'run', 'show_run', 'inspect_run', 'sources', 'queue', 'source_queue', 'source', 'show_source', 'inspect_source', 'bundle', 'bundle_sources', 'source_bundle', 'search', 'public_search', 'collect', 'collect_sources', 'source_candidates', 'reports', 'list_reports', 'report_list', 'visual_reports', 'report_artifact', 'show_report', 'inspect_report', 'show_visual_report', 'visual_report_artifact']);
69
+ const READ_ONLY_CHANNELS_ACTIONS = new Set(['', 'status', 'summary', 'list', 'readiness', 'channels', 'channel', 'show', 'inspect', 'setup', 'guide', 'setup_guide', 'channel_setup_guide', 'triage', 'inbox', 'blockers', 'retries', 'channel_triage', 'deliveries', 'delivery', 'receipts', 'history', 'channel_deliveries']);
70
+ const READ_ONLY_MEMORY_ACTIONS = new Set(['', 'status', 'summary', 'posture', 'memory_posture', 'recall', 'providers', 'provider', 'memory_provider', 'embedding', 'external', 'external_provider', 'curator', 'learning', 'learning_curator', 'queue', 'review_queue', 'plan', 'candidate', 'learning_candidate', 'card', 'inspect_candidate', 'list', 'records', 'memories', 'search', 'find', 'lookup', 'get', 'show', 'inspect', 'read']);
71
+ const READ_ONLY_COMPUTER_ACTIONS = new Set(['', 'status', 'summary', 'overview', 'computer', 'computer_use', 'plan', 'route', 'control_plan', 'browser_plan', 'desktop_plan', 'control', 'browser_control', 'desktop', 'desktop_control', 'screenshot', 'screen', 'screen_recording', 'observe', 'browser', 'pwa', 'cockpit', 'browser_cockpit', 'web', 'setup', 'configure', 'browser_desktop_control', 'mcp', 'tools', 'servers', 'mcp_servers']);
72
+ const READ_ONLY_DEVICE_ACTIONS = new Set(['', 'status', 'map', 'capabilities', 'device', 'devices', 'mobile', 'phone', 'pairing', 'capability', 'route', 'pairing_route', 'show', 'inspect', 'browser', 'pwa', 'cockpit', 'browser_cockpit', 'web', 'control', 'browser_control', 'desktop', 'desktop_control', 'computer_use', 'voice', 'media', 'voice_media', 'workflows', 'provider', 'media_provider', 'voice_provider']);
73
+ const READ_ONLY_MODELS_ACTIONS = new Set(['', 'status', 'routing', 'routes', 'models', 'model', 'readiness', 'route_readiness', 'route', 'model_route', 'inspect', 'show', 'candidate', 'endpoint', 'local', 'cookbook', 'local_cookbook', 'recipes', 'recipe', 'ollama', 'llama_cpp', 'llamacpp', 'vllm', 'local_servers', 'providers', 'provider_accounts', 'accounts', 'subscriptions', 'auth', 'logins', 'provider', 'provider_account', 'account', 'subscription', 'auth_status']);
74
+ const READ_ONLY_WORKSPACE_ACTIONS = new Set(['', 'status', 'summary', 'home', 'workspace', 'categories', 'workspace_categories', 'actions', 'list_actions', 'workspace_actions', 'tasks', 'action', 'show', 'inspect', 'workspace_action', 'surfaces', 'ui_surfaces', 'screens', 'views', 'surface', 'ui_surface', 'screen', 'view', 'panels', 'panes', 'panel', 'pane', 'shortcuts', 'shortcut_help', 'help', 'keybindings', 'bindings', 'keys', 'keybinding', 'binding', 'key', 'commands', 'slash_commands', 'command_catalog', 'command', 'slash_command', 'inspect_command', 'cli_commands', 'cli_catalog', 'cli_command', 'inspect_cli_command']);
75
+ const READ_ONLY_AUTONOMY_ACTIONS = new Set(['', 'intake', 'request', 'route', 'plan', 'triage', 'autonomy_intake', 'queue', 'list', 'work', 'ongoing', 'autonomy_queue', 'item', 'card', 'show', 'inspect', 'autonomy_queue_item', 'status', 'summary', 'overview']);
76
+ const READ_ONLY_DELEGATION_ACTIONS = new Set(['', 'status', 'summary', 'overview', 'policy', 'decision', 'decisions', 'delegation_posture', 'routes', 'list', 'catalog', 'posture', 'route', 'item', 'card', 'show', 'inspect', 'delegation_route']);
77
+ const READ_ONLY_EXECUTION_ACTIONS = new Set(['', 'status', 'summary', 'overview', 'routes', 'posture', 'execution_posture', 'route', 'show_route', 'inspect_route', 'execution_route', 'history', 'activity', 'records', 'execution_history', 'record', 'item', 'show', 'inspect', 'execution_history_item', 'processes', 'background', 'backgrounds', 'background_processes', 'capabilities', 'process_capabilities', 'process', 'background_process', 'recovery', 'file_recovery', 'undo_redo']);
78
+
79
+ type MarkedPermissionManager = PermissionManagerLike & { [SAFETY_MARKER]?: true };
80
+
81
+ export function installPermissionManagerSafetyGuard(manager: PermissionManagerLike): void {
82
+ const marked = manager as MarkedPermissionManager;
83
+ if (marked[SAFETY_MARKER]) return;
84
+ marked[SAFETY_MARKER] = true;
85
+
86
+ const originalGetCategory = manager.getCategory.bind(manager);
87
+ const originalCheck = manager.check.bind(manager);
88
+ const originalCheckDetailed = manager.checkDetailed?.bind(manager);
89
+
90
+ manager.getCategory = (toolName, args = {}) => {
91
+ try {
92
+ const category = originalGetCategory(toolName, args);
93
+ const knownCategory = fallbackPermissionCategoryForArgs(toolName, args);
94
+ return category === 'delegate' && knownCategory !== 'delegate' ? knownCategory : category;
95
+ } catch {
96
+ return fallbackPermissionCategoryForArgs(toolName, args);
97
+ }
98
+ };
99
+
100
+ manager.check = async (toolName, args) => {
101
+ try {
102
+ return await originalCheck(toolName, args);
103
+ } catch {
104
+ return fallbackPermissionCategoryForArgs(toolName, args) === 'read';
105
+ }
106
+ };
107
+
108
+ if (originalCheckDetailed) {
109
+ manager.checkDetailed = async (toolName, args) => {
110
+ try {
111
+ return await originalCheckDetailed(toolName, args);
112
+ } catch (error) {
113
+ const category = fallbackPermissionCategoryForArgs(toolName, args);
114
+ const approved = category === 'read';
115
+ return {
116
+ approved,
117
+ persisted: false,
118
+ sourceLayer: 'runtime_mode',
119
+ reasonCode: approved ? 'config_allow' : 'config_deny',
120
+ analysis: {
121
+ classification: 'generic',
122
+ riskLevel: category === 'read' ? 'low' : 'high',
123
+ summary: `Permission fallback for ${toolName}: ${summarizeError(error)}`,
124
+ reasons: ['permission-manager-exception'],
125
+ },
126
+ };
127
+ }
128
+ };
129
+ }
130
+ }
131
+
132
+ export function fallbackPermissionCategory(toolName: string): PermissionCategory {
133
+ if (READ_TOOL_NAMES.has(toolName)) return 'read';
134
+ if (WRITE_TOOL_NAMES.has(toolName)) return 'write';
135
+ if (EXECUTE_TOOL_NAMES.has(toolName)) return 'execute';
136
+ return 'delegate';
137
+ }
138
+
139
+ export function fallbackPermissionCategoryForArgs(toolName: string, args: Record<string, unknown>): PermissionCategory {
140
+ if (toolName === 'process') {
141
+ const action = typeof args.action === 'string'
142
+ ? args.action.trim().toLowerCase()
143
+ : typeof args.processAction === 'string'
144
+ ? args.processAction.trim().toLowerCase()
145
+ : '';
146
+ return READ_ONLY_PROCESS_ACTIONS.has(action) ? 'read' : 'execute';
147
+ }
148
+ if (toolName === 'schedule') {
149
+ const action = typeof args.action === 'string'
150
+ ? args.action.trim().toLowerCase()
151
+ : typeof args.mode === 'string'
152
+ ? args.mode.trim().toLowerCase()
153
+ : '';
154
+ return READ_ONLY_SCHEDULE_ACTIONS.has(action) ? 'read' : 'execute';
155
+ }
156
+ if (toolName === 'import_goodvibes_settings') {
157
+ const action = typeof args.action === 'string'
158
+ ? args.action.trim().toLowerCase()
159
+ : typeof args.mode === 'string'
160
+ ? args.mode.trim().toLowerCase()
161
+ : '';
162
+ return READ_ONLY_SETTINGS_IMPORT_ACTIONS.has(action) ? 'read' : 'write';
163
+ }
164
+ if (toolName === 'settings') {
165
+ const action = typeof args.action === 'string'
166
+ ? args.action.trim().toLowerCase().replace(/-/g, '_')
167
+ : typeof args.mode === 'string'
168
+ ? args.mode.trim().toLowerCase().replace(/-/g, '_')
169
+ : '';
170
+ const confirmed = args.confirm === true || (typeof args.confirm === 'string' && ['true', 'yes', 'apply', 'run'].includes(args.confirm.trim().toLowerCase()));
171
+ if ((action === 'import' || action === 'import_settings' || action === 'settings_import' || action === 'import_goodvibes' || action === 'goodvibes_import') && confirmed) return 'write';
172
+ return READ_ONLY_SETTINGS_ACTIONS.has(action) ? 'read' : 'write';
173
+ }
174
+ if (toolName === 'setup') {
175
+ const action = typeof args.action === 'string'
176
+ ? args.action.trim().toLowerCase().replace(/-/g, '_')
177
+ : typeof args.mode === 'string'
178
+ ? args.mode.trim().toLowerCase().replace(/-/g, '_')
179
+ : '';
180
+ return READ_ONLY_SETUP_ACTIONS.has(action) ? 'read' : 'write';
181
+ }
182
+ if (toolName === 'vibe') {
183
+ const action = typeof args.action === 'string'
184
+ ? args.action.trim().toLowerCase().replace(/-/g, '_')
185
+ : typeof args.mode === 'string'
186
+ ? args.mode.trim().toLowerCase().replace(/-/g, '_')
187
+ : '';
188
+ return READ_ONLY_VIBE_ACTIONS.has(action) ? 'read' : 'write';
189
+ }
190
+ if (toolName === 'personal_ops') {
191
+ const action = typeof args.action === 'string'
192
+ ? args.action.trim().toLowerCase().replace(/-/g, '_')
193
+ : typeof args.mode === 'string'
194
+ ? args.mode.trim().toLowerCase().replace(/-/g, '_')
195
+ : '';
196
+ return READ_ONLY_PERSONAL_OPS_ACTIONS.has(action) ? 'read' : 'write';
197
+ }
198
+ if (toolName === 'research') {
199
+ const action = typeof args.action === 'string'
200
+ ? args.action.trim().toLowerCase().replace(/-/g, '_')
201
+ : typeof args.mode === 'string'
202
+ ? args.mode.trim().toLowerCase().replace(/-/g, '_')
203
+ : '';
204
+ return READ_ONLY_RESEARCH_ACTIONS.has(action) ? 'read' : 'write';
205
+ }
206
+ if (toolName === 'channels') {
207
+ const action = typeof args.action === 'string'
208
+ ? args.action.trim().toLowerCase().replace(/-/g, '_')
209
+ : typeof args.mode === 'string'
210
+ ? args.mode.trim().toLowerCase().replace(/-/g, '_')
211
+ : '';
212
+ return READ_ONLY_CHANNELS_ACTIONS.has(action) ? 'read' : 'write';
213
+ }
214
+ if (toolName === 'memory') {
215
+ const action = typeof args.action === 'string'
216
+ ? args.action.trim().toLowerCase().replace(/-/g, '_')
217
+ : typeof args.mode === 'string'
218
+ ? args.mode.trim().toLowerCase().replace(/-/g, '_')
219
+ : '';
220
+ return READ_ONLY_MEMORY_ACTIONS.has(action) ? 'read' : 'write';
221
+ }
222
+ if (toolName === 'computer') {
223
+ const action = typeof args.action === 'string'
224
+ ? args.action.trim().toLowerCase().replace(/-/g, '_')
225
+ : typeof args.mode === 'string'
226
+ ? args.mode.trim().toLowerCase().replace(/-/g, '_')
227
+ : '';
228
+ return READ_ONLY_COMPUTER_ACTIONS.has(action) ? 'read' : 'write';
229
+ }
230
+ if (toolName === 'device') {
231
+ const action = typeof args.action === 'string'
232
+ ? args.action.trim().toLowerCase().replace(/-/g, '_')
233
+ : typeof args.mode === 'string'
234
+ ? args.mode.trim().toLowerCase().replace(/-/g, '_')
235
+ : '';
236
+ return READ_ONLY_DEVICE_ACTIONS.has(action) ? 'read' : 'write';
237
+ }
238
+ if (toolName === 'models') {
239
+ const action = typeof args.action === 'string'
240
+ ? args.action.trim().toLowerCase().replace(/-/g, '_')
241
+ : typeof args.mode === 'string'
242
+ ? args.mode.trim().toLowerCase().replace(/-/g, '_')
243
+ : '';
244
+ return READ_ONLY_MODELS_ACTIONS.has(action) ? 'read' : 'write';
245
+ }
246
+ if (toolName === 'workspace') {
247
+ const action = typeof args.action === 'string'
248
+ ? args.action.trim().toLowerCase().replace(/-/g, '_')
249
+ : typeof args.mode === 'string'
250
+ ? args.mode.trim().toLowerCase().replace(/-/g, '_')
251
+ : '';
252
+ return READ_ONLY_WORKSPACE_ACTIONS.has(action) ? 'read' : 'write';
253
+ }
254
+ if (toolName === 'autonomy') {
255
+ const action = typeof args.action === 'string'
256
+ ? args.action.trim().toLowerCase().replace(/-/g, '_')
257
+ : typeof args.mode === 'string'
258
+ ? args.mode.trim().toLowerCase().replace(/-/g, '_')
259
+ : '';
260
+ return READ_ONLY_AUTONOMY_ACTIONS.has(action) ? 'read' : 'write';
261
+ }
262
+ if (toolName === 'delegation') {
263
+ const action = typeof args.action === 'string'
264
+ ? args.action.trim().toLowerCase().replace(/-/g, '_')
265
+ : typeof args.mode === 'string'
266
+ ? args.mode.trim().toLowerCase().replace(/-/g, '_')
267
+ : '';
268
+ return READ_ONLY_DELEGATION_ACTIONS.has(action) ? 'read' : 'write';
269
+ }
270
+ if (toolName === 'execution') {
271
+ const action = typeof args.action === 'string'
272
+ ? args.action.trim().toLowerCase().replace(/-/g, '_')
273
+ : typeof args.mode === 'string'
274
+ ? args.mode.trim().toLowerCase().replace(/-/g, '_')
275
+ : '';
276
+ return READ_ONLY_EXECUTION_ACTIONS.has(action) ? 'read' : 'write';
277
+ }
278
+ if (toolName === 'agent_artifacts') {
279
+ const mode = typeof args.mode === 'string' ? args.mode.trim() : '';
280
+ return mode === 'list' || mode === 'show' ? 'read' : 'write';
281
+ }
282
+ if (toolName === 'agent_review_packet_presets') {
283
+ const mode = typeof args.mode === 'string' ? args.mode.trim() : '';
284
+ return mode === 'list' || mode === 'show' || mode === '' ? 'read' : 'write';
285
+ }
286
+ return fallbackPermissionCategory(toolName);
287
+ }
@@ -0,0 +1,39 @@
1
+ interface ShellSessionSnapshot {
2
+ readonly pendingApproval?: unknown;
3
+ }
4
+
5
+ interface ShellTaskRecord {
6
+ readonly status?: string;
7
+ }
8
+
9
+ interface ShellTaskSnapshot {
10
+ readonly tasks: readonly ShellTaskRecord[];
11
+ }
12
+
13
+ interface ShellRemoteContract {
14
+ readonly runnerId: string;
15
+ }
16
+
17
+ interface ShellRemoteSnapshot {
18
+ readonly contracts: readonly ShellRemoteContract[];
19
+ }
20
+
21
+ interface ShellPanelRecord {
22
+ readonly id: string;
23
+ }
24
+
25
+ export function buildShellSessionContinuityHints(
26
+ sessionSnapshot: ShellSessionSnapshot,
27
+ tasksSnapshot: ShellTaskSnapshot,
28
+ remoteSnapshot: ShellRemoteSnapshot,
29
+ openPanels: readonly ShellPanelRecord[],
30
+ ) {
31
+ return {
32
+ pendingApprovals: sessionSnapshot.pendingApproval ? 1 : 0,
33
+ activeTasks: tasksSnapshot.tasks.filter((task) => task.status === 'running' || task.status === 'queued').length,
34
+ blockedTasks: tasksSnapshot.tasks.filter((task) => task.status === 'blocked').length,
35
+ remoteContracts: remoteSnapshot.contracts.length,
36
+ remoteRunners: remoteSnapshot.contracts.slice(0, 4).map((contract) => contract.runnerId),
37
+ openPanels: openPanels.map((panel) => panel.id),
38
+ };
39
+ }