@caupulican/pi-adaptative 0.81.40 → 0.81.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +1 -0
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +1 -1
- package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +1 -0
- package/dist/cli/args.d.ts +2 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +22 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-paths.d.ts +6 -0
- package/dist/core/agent-paths.d.ts.map +1 -1
- package/dist/core/agent-paths.js +12 -0
- package/dist/core/agent-paths.js.map +1 -1
- package/dist/core/agent-session-contracts.d.ts +293 -0
- package/dist/core/agent-session-contracts.d.ts.map +1 -0
- package/dist/core/agent-session-contracts.js +26 -0
- package/dist/core/agent-session-contracts.js.map +1 -0
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +3 -0
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session.d.ts +26 -405
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +86 -307
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +3 -1
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tool-surface.js +2 -1
- package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
- package/dist/core/background-lane-controller.d.ts +3 -1
- package/dist/core/background-lane-controller.d.ts.map +1 -1
- package/dist/core/background-lane-controller.js +1 -0
- package/dist/core/background-lane-controller.js.map +1 -1
- package/dist/core/bedrock-sso-login.d.ts +16 -0
- package/dist/core/bedrock-sso-login.d.ts.map +1 -0
- package/dist/core/bedrock-sso-login.js +98 -0
- package/dist/core/bedrock-sso-login.js.map +1 -0
- package/dist/core/compaction-controller.d.ts.map +1 -1
- package/dist/core/compaction-controller.js +1 -1
- package/dist/core/compaction-controller.js.map +1 -1
- package/dist/core/compaction-support.d.ts +3 -8
- package/dist/core/compaction-support.d.ts.map +1 -1
- package/dist/core/compaction-support.js +3 -3
- package/dist/core/compaction-support.js.map +1 -1
- package/dist/core/context-pipeline.d.ts +1 -1
- package/dist/core/context-pipeline.d.ts.map +1 -1
- package/dist/core/context-pipeline.js +7 -33
- package/dist/core/context-pipeline.js.map +1 -1
- package/dist/core/cost/cost-summary.d.ts.map +1 -1
- package/dist/core/cost/cost-summary.js +5 -3
- package/dist/core/cost/cost-summary.js.map +1 -1
- package/dist/core/cost/daily-usage.d.ts.map +1 -1
- package/dist/core/cost/daily-usage.js +4 -5
- package/dist/core/cost/daily-usage.js.map +1 -1
- package/dist/core/default-tool-surface.d.ts.map +1 -1
- package/dist/core/default-tool-surface.js +1 -0
- package/dist/core/default-tool-surface.js.map +1 -1
- package/dist/core/extension-import-authority.d.ts +6 -0
- package/dist/core/extension-import-authority.d.ts.map +1 -0
- package/dist/core/extension-import-authority.js +10 -0
- package/dist/core/extension-import-authority.js.map +1 -0
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +2 -3
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +3 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +14 -5
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/stale-context.d.ts +2 -0
- package/dist/core/extensions/stale-context.d.ts.map +1 -0
- package/dist/core/extensions/stale-context.js +2 -0
- package/dist/core/extensions/stale-context.js.map +1 -0
- package/dist/core/extensions/types.d.ts +8 -0
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/foreground-recovery-controller.d.ts +1 -0
- package/dist/core/foreground-recovery-controller.d.ts.map +1 -1
- package/dist/core/foreground-recovery-controller.js +13 -13
- package/dist/core/foreground-recovery-controller.js.map +1 -1
- package/dist/core/goal-loop-controller.d.ts +14 -9
- package/dist/core/goal-loop-controller.d.ts.map +1 -1
- package/dist/core/goal-loop-controller.js +47 -75
- package/dist/core/goal-loop-controller.js.map +1 -1
- package/dist/core/goals/compact-goal-context.d.ts +11 -0
- package/dist/core/goals/compact-goal-context.d.ts.map +1 -0
- package/dist/core/goals/compact-goal-context.js +59 -0
- package/dist/core/goals/compact-goal-context.js.map +1 -0
- package/dist/core/goals/goal-acceptance.d.ts.map +1 -1
- package/dist/core/goals/goal-acceptance.js +2 -0
- package/dist/core/goals/goal-acceptance.js.map +1 -1
- package/dist/core/goals/goal-auto-continue-controller.d.ts +2 -1
- package/dist/core/goals/goal-auto-continue-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-auto-continue-controller.js +5 -8
- package/dist/core/goals/goal-auto-continue-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-controller.d.ts +2 -2
- package/dist/core/goals/goal-continuation-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-controller.js +42 -11
- package/dist/core/goals/goal-continuation-controller.js.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.d.ts +4 -29
- package/dist/core/goals/goal-continuation-defaults.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-defaults.js +4 -32
- package/dist/core/goals/goal-continuation-defaults.js.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.d.ts +8 -18
- package/dist/core/goals/goal-continuation-prompt.d.ts.map +1 -1
- package/dist/core/goals/goal-continuation-prompt.js +9 -179
- package/dist/core/goals/goal-continuation-prompt.js.map +1 -1
- package/dist/core/goals/goal-lifecycle.d.ts +35 -12
- package/dist/core/goals/goal-lifecycle.d.ts.map +1 -1
- package/dist/core/goals/goal-lifecycle.js +98 -13
- package/dist/core/goals/goal-lifecycle.js.map +1 -1
- package/dist/core/goals/goal-record.d.ts +17 -0
- package/dist/core/goals/goal-record.d.ts.map +1 -0
- package/dist/core/goals/goal-record.js +31 -0
- package/dist/core/goals/goal-record.js.map +1 -0
- package/dist/core/goals/goal-session-controller.d.ts +42 -0
- package/dist/core/goals/goal-session-controller.d.ts.map +1 -0
- package/dist/core/goals/goal-session-controller.js +128 -0
- package/dist/core/goals/goal-session-controller.js.map +1 -0
- package/dist/core/goals/goal-state.d.ts +45 -25
- package/dist/core/goals/goal-state.d.ts.map +1 -1
- package/dist/core/goals/goal-state.js +85 -15
- package/dist/core/goals/goal-state.js.map +1 -1
- package/dist/core/goals/goal-tool-core.d.ts +1 -4
- package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
- package/dist/core/goals/goal-tool-core.js +49 -34
- package/dist/core/goals/goal-tool-core.js.map +1 -1
- package/dist/core/goals/session-goal-state.d.ts +18 -8
- package/dist/core/goals/session-goal-state.d.ts.map +1 -1
- package/dist/core/goals/session-goal-state.js +134 -11
- package/dist/core/goals/session-goal-state.js.map +1 -1
- package/dist/core/human-input-controller.d.ts +47 -0
- package/dist/core/human-input-controller.d.ts.map +1 -0
- package/dist/core/human-input-controller.js +181 -0
- package/dist/core/human-input-controller.js.map +1 -0
- package/dist/core/local-runtime-controller.d.ts +1 -1
- package/dist/core/local-runtime-controller.d.ts.map +1 -1
- package/dist/core/local-runtime-controller.js.map +1 -1
- package/dist/core/model-capability.d.ts +0 -19
- package/dist/core/model-capability.d.ts.map +1 -1
- package/dist/core/model-capability.js +0 -19
- package/dist/core/model-capability.js.map +1 -1
- package/dist/core/model-registry.d.ts +6 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +13 -5
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +16 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +32 -16
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-router-controller.d.ts +1 -1
- package/dist/core/model-router-controller.d.ts.map +1 -1
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/model-selection-controller.d.ts +1 -1
- package/dist/core/model-selection-controller.d.ts.map +1 -1
- package/dist/core/model-selection-controller.js.map +1 -1
- package/dist/core/orchestration/delegation-ledger.d.ts.map +1 -1
- package/dist/core/orchestration/delegation-ledger.js +3 -0
- package/dist/core/orchestration/delegation-ledger.js.map +1 -1
- package/dist/core/orchestration/work-state-projection.d.ts.map +1 -1
- package/dist/core/orchestration/work-state-projection.js +1 -1
- package/dist/core/orchestration/work-state-projection.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +20 -3
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/profile-filter-controller.d.ts +8 -1
- package/dist/core/profile-filter-controller.d.ts.map +1 -1
- package/dist/core/profile-filter-controller.js +23 -5
- package/dist/core/profile-filter-controller.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +1 -0
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +18 -29
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/reflection-controller.d.ts +1 -1
- package/dist/core/reflection-controller.d.ts.map +1 -1
- package/dist/core/reflection-controller.js +3 -1
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/request-auth.d.ts +7 -0
- package/dist/core/request-auth.d.ts.map +1 -0
- package/dist/core/request-auth.js +8 -0
- package/dist/core/request-auth.js.map +1 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +16 -6
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/risk-classifier.d.ts.map +1 -1
- package/dist/core/risk-classifier.js +8 -0
- package/dist/core/risk-classifier.js.map +1 -1
- package/dist/core/runtime-builder.d.ts +15 -3
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +132 -79
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +7 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/secrets/credential-exposure-guard.d.ts +9 -0
- package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -0
- package/dist/core/secrets/credential-exposure-guard.js +241 -0
- package/dist/core/secrets/credential-exposure-guard.js.map +1 -0
- package/dist/core/secrets/secret-dotenv.d.ts +27 -0
- package/dist/core/secrets/secret-dotenv.d.ts.map +1 -0
- package/dist/core/secrets/secret-dotenv.js +183 -0
- package/dist/core/secrets/secret-dotenv.js.map +1 -0
- package/dist/core/secrets/secret-vault-format.d.ts +112 -0
- package/dist/core/secrets/secret-vault-format.d.ts.map +1 -0
- package/dist/core/secrets/secret-vault-format.js +397 -0
- package/dist/core/secrets/secret-vault-format.js.map +1 -0
- package/dist/core/secrets/secret-vault.d.ts +72 -0
- package/dist/core/secrets/secret-vault.d.ts.map +1 -0
- package/dist/core/secrets/secret-vault.js +671 -0
- package/dist/core/secrets/secret-vault.js.map +1 -0
- package/dist/core/session-analytics.d.ts +4 -23
- package/dist/core/session-analytics.d.ts.map +1 -1
- package/dist/core/session-analytics.js +39 -69
- package/dist/core/session-analytics.js.map +1 -1
- package/dist/core/session-role.d.ts +5 -0
- package/dist/core/session-role.d.ts.map +1 -1
- package/dist/core/session-role.js +14 -1
- package/dist/core/session-role.js.map +1 -1
- package/dist/core/session-tree-navigator.d.ts +4 -6
- package/dist/core/session-tree-navigator.d.ts.map +1 -1
- package/dist/core/session-tree-navigator.js +4 -1
- package/dist/core/session-tree-navigator.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +2 -2
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tool-capability-policy.d.ts.map +1 -1
- package/dist/core/tool-capability-policy.js +1 -0
- package/dist/core/tool-capability-policy.js.map +1 -1
- package/dist/core/tool-gate-controller.d.ts.map +1 -1
- package/dist/core/tool-gate-controller.js +8 -2
- package/dist/core/tool-gate-controller.js.map +1 -1
- package/dist/core/tool-protocol-controller.d.ts +2 -4
- package/dist/core/tool-protocol-controller.d.ts.map +1 -1
- package/dist/core/tool-protocol-controller.js.map +1 -1
- package/dist/core/tool-recovery-stats.d.ts +21 -1
- package/dist/core/tool-recovery-stats.d.ts.map +1 -1
- package/dist/core/tool-recovery-stats.js.map +1 -1
- package/dist/core/tools/bash.d.ts +5 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +59 -5
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +6 -7
- package/dist/core/tools/delegate-status.js.map +1 -1
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +6 -8
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/git-filter.d.ts +1 -8
- package/dist/core/tools/git-filter.d.ts.map +1 -1
- package/dist/core/tools/git-filter.js +2 -63
- package/dist/core/tools/git-filter.js.map +1 -1
- package/dist/core/tools/goal.d.ts +5 -3
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +97 -19
- package/dist/core/tools/goal.js.map +1 -1
- package/dist/core/tools/index.d.ts +1 -0
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +1 -0
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/orchestration-panel.d.ts +1 -4
- package/dist/core/tools/orchestration-panel.d.ts.map +1 -1
- package/dist/core/tools/orchestration-panel.js +0 -44
- package/dist/core/tools/orchestration-panel.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +11 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +36 -3
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/python.d.ts +2 -0
- package/dist/core/tools/python.d.ts.map +1 -1
- package/dist/core/tools/python.js +3 -1
- package/dist/core/tools/python.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/search-command-guard.d.ts +14 -0
- package/dist/core/tools/search-command-guard.d.ts.map +1 -0
- package/dist/core/tools/search-command-guard.js +333 -0
- package/dist/core/tools/search-command-guard.js.map +1 -0
- package/dist/core/tools/secret-store.d.ts +38 -0
- package/dist/core/tools/secret-store.d.ts.map +1 -0
- package/dist/core/tools/secret-store.js +412 -0
- package/dist/core/tools/secret-store.js.map +1 -0
- package/dist/core/tools/shell-command-parser.d.ts +16 -0
- package/dist/core/tools/shell-command-parser.d.ts.map +1 -0
- package/dist/core/tools/shell-command-parser.js +113 -0
- package/dist/core/tools/shell-command-parser.js.map +1 -0
- package/dist/core/tools/task-steps.d.ts.map +1 -1
- package/dist/core/tools/task-steps.js +4 -7
- package/dist/core/tools/task-steps.js.map +1 -1
- package/dist/core/util/atomic-file.d.ts +6 -2
- package/dist/core/util/atomic-file.d.ts.map +1 -1
- package/dist/core/util/atomic-file.js +4 -4
- package/dist/core/util/atomic-file.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +25 -11
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.d.ts +4 -0
- package/dist/modes/interactive/auth-dialogs-controller.d.ts.map +1 -1
- package/dist/modes/interactive/auth-dialogs-controller.js +60 -1
- package/dist/modes/interactive/auth-dialogs-controller.js.map +1 -1
- package/dist/modes/interactive/components/activity-lane.d.ts +55 -0
- package/dist/modes/interactive/components/activity-lane.d.ts.map +1 -0
- package/dist/modes/interactive/components/activity-lane.js +304 -0
- package/dist/modes/interactive/components/activity-lane.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +19 -10
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/expandable-text.d.ts +12 -0
- package/dist/modes/interactive/components/expandable-text.d.ts.map +1 -0
- package/dist/modes/interactive/components/expandable-text.js +17 -0
- package/dist/modes/interactive/components/expandable-text.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +15 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +30 -21
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts +1 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +6 -1
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +2 -2
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +23 -14
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +4 -4
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +19 -11
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +53 -20
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-group.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-group.js +3 -0
- package/dist/modes/interactive/components/tool-group.js.map +1 -1
- package/dist/modes/interactive/components/usage-action-selector.d.ts +16 -0
- package/dist/modes/interactive/components/usage-action-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/usage-action-selector.js +46 -0
- package/dist/modes/interactive/components/usage-action-selector.js.map +1 -0
- package/dist/modes/interactive/extension-ui-host.d.ts.map +1 -1
- package/dist/modes/interactive/extension-ui-host.js +1 -0
- package/dist/modes/interactive/extension-ui-host.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts +15 -0
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +27 -19
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/history-reload-math.d.ts +6 -2
- package/dist/modes/interactive/history-reload-math.d.ts.map +1 -1
- package/dist/modes/interactive/history-reload-math.js +10 -5
- package/dist/modes/interactive/history-reload-math.js.map +1 -1
- package/dist/modes/interactive/interactive-event-controller.d.ts +74 -0
- package/dist/modes/interactive/interactive-event-controller.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-event-controller.js +328 -0
- package/dist/modes/interactive/interactive-event-controller.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +20 -25
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +196 -608
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/loaded-resources-view.d.ts +20 -0
- package/dist/modes/interactive/loaded-resources-view.d.ts.map +1 -0
- package/dist/modes/interactive/loaded-resources-view.js +147 -0
- package/dist/modes/interactive/loaded-resources-view.js.map +1 -0
- package/dist/modes/interactive/resource-display.d.ts.map +1 -1
- package/dist/modes/interactive/resource-display.js +8 -2
- package/dist/modes/interactive/resource-display.js.map +1 -1
- package/dist/modes/interactive/resource-shell-commands.d.ts +1 -5
- package/dist/modes/interactive/resource-shell-commands.d.ts.map +1 -1
- package/dist/modes/interactive/resource-shell-commands.js +0 -5
- package/dist/modes/interactive/resource-shell-commands.js.map +1 -1
- package/dist/modes/interactive/session-flow-commands.d.ts +10 -6
- package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-flow-commands.js +123 -70
- package/dist/modes/interactive/session-flow-commands.js.map +1 -1
- package/dist/modes/interactive/usage-commands.d.ts +34 -0
- package/dist/modes/interactive/usage-commands.d.ts.map +1 -0
- package/dist/modes/interactive/usage-commands.js +225 -0
- package/dist/modes/interactive/usage-commands.js.map +1 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +5 -3
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +3 -1
- package/dist/utils/version-check.js.map +1 -1
- package/docs/UI_POLISH_ORCHESTRATION.md +25 -31
- package/docs/UI_QUALITY_ORCHESTRATION.md +22 -24
- package/docs/providers.md +9 -1
- package/docs/ui-reference/README.md +6 -6
- package/docs/ui-reference/orchestration-after.txt +14 -7
- package/docs/ui-reference/orchestration-before.txt +12 -6
- package/docs/ui-reference/orchestration-reference.txt +15 -5
- package/docs/usage.md +9 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +13 -13
- package/package.json +4 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-command-guard.js","sourceRoot":"","sources":["../../../src/core/tools/search-command-guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,MAAM,CAAC,MAAM,yBAAyB,GAAG,eAAwB,CAAC;AAMlE,MAAM,mBAAmB,GAAG,IAAI,GAAG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YAC/B,oBAAoB,GAAG,IAAI,CAAC;YAC5B,SAAS;QACV,CAAC;QACD,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;QACnC,IAAI,UAAU,CAAC,IAAI,KAAK,OAAO;YAAE,OAAO,UAAU,CAAC;QACnD,UAAU,GAAG,EAAE,CAAC;QAChB,oBAAoB,GAAG,KAAK,CAAC;QAC7B,SAAS,GAAG,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC;IACnC,CAAC;IAED,OAAO,aAAa,EAAE,CAAC;AAAA,CACvB","sourcesContent":["import { homedir } from \"node:os\";\nimport { basename, resolve } from \"node:path\";\nimport { tokenizeShellCommand } from \"./shell-command-parser.ts\";\n\nexport const BROAD_SEARCH_OUTPUT_ROUTE = \"route-to-file\" as const;\n\nexport type SearchScopeAssessment =\n\t| { kind: \"scoped\" }\n\t| { kind: \"broad\"; searchTool: \"rg\" | \"grep\" | \"find\" | \"fd\"; reason: string };\n\nconst RG_LONG_VALUE_FLAGS = new Set([\n\t\"--after-context\",\n\t\"--before-context\",\n\t\"--color\",\n\t\"--colors\",\n\t\"--context\",\n\t\"--context-separator\",\n\t\"--encoding\",\n\t\"--engine\",\n\t\"--field-context-separator\",\n\t\"--field-match-separator\",\n\t\"--glob\",\n\t\"--iglob\",\n\t\"--ignore-file\",\n\t\"--max-columns\",\n\t\"--max-count\",\n\t\"--max-depth\",\n\t\"--max-filesize\",\n\t\"--path-separator\",\n\t\"--pre\",\n\t\"--pre-glob\",\n\t\"--replace\",\n\t\"--sort\",\n\t\"--sortr\",\n\t\"--threads\",\n\t\"--type\",\n\t\"--type-add\",\n\t\"--type-clear\",\n\t\"--type-not\",\n]);\nconst RG_SHORT_VALUE_FLAGS = new Set(\"ABCEMTdfgjmrt\".split(\"\"));\nconst RG_SCOPE_LONG_FLAGS = new Set([\"--glob\", \"--iglob\", \"--max-depth\", \"--type\", \"--type-not\"]);\nconst RG_SCOPE_SHORT_FLAGS = new Set([\"g\", \"t\", \"T\"]);\nconst RG_META_FLAGS = new Set([\"--generate\", \"--help\", \"--pcre2-version\", \"--type-list\", \"--version\", \"-h\"]);\n\ntype TargetScope = \"current\" | \"global\" | \"narrow\";\n\nfunction targetScope(target: string, cwd: string): TargetScope {\n\tconst normalized = target.trim().replace(/[\\\\/]+$/u, \"\") || target.trim();\n\tif (\n\t\tnormalized === \"/\" ||\n\t\tnormalized === \"\\\\\" ||\n\t\t/^[A-Za-z]:$/u.test(normalized) ||\n\t\tnormalized === \"~\" ||\n\t\tnormalized === \"$HOME\" ||\n\t\tnormalized === \"%USERPROFILE%\" ||\n\t\tresolve(normalized) === resolve(homedir())\n\t) {\n\t\treturn \"global\";\n\t}\n\tif (\n\t\tnormalized === \".\" ||\n\t\tnormalized === \"*\" ||\n\t\tnormalized === \"**\" ||\n\t\tnormalized === \"./*\" ||\n\t\tnormalized === \"./**\" ||\n\t\tnormalized === \"$PWD\" ||\n\t\tnormalized === \"$(pwd)\" ||\n\t\tnormalized === \"%CD%\" ||\n\t\tresolve(cwd, normalized) === resolve(cwd)\n\t)\n\t\treturn \"current\";\n\treturn \"narrow\";\n}\n\nfunction hasSafeTarget(targets: string[], cwd: string, hasScopeFilter: boolean): boolean {\n\tif (targets.includes(\"-\")) return true;\n\tconst scopes = (targets.length > 0 ? targets : [\".\"]).map((target) => targetScope(target, cwd));\n\tif (scopes.includes(\"global\")) return false;\n\treturn scopes.includes(\"narrow\") || hasScopeFilter;\n}\n\ninterface RgArguments {\n\tfilesMode: boolean;\n\thasPatternOption: boolean;\n\thasScopeFilter: boolean;\n\tmetaOnly: boolean;\n\tpositionals: string[];\n}\n\nfunction parseRgArguments(args: string[]): RgArguments {\n\tconst parsed: RgArguments = {\n\t\tfilesMode: false,\n\t\thasPatternOption: false,\n\t\thasScopeFilter: false,\n\t\tmetaOnly: false,\n\t\tpositionals: [],\n\t};\n\tlet pastDoubleDash = false;\n\n\tfor (let index = 0; index < args.length; index++) {\n\t\tconst arg = args[index];\n\t\tif (pastDoubleDash) {\n\t\t\tparsed.positionals.push(arg);\n\t\t\tcontinue;\n\t\t}\n\t\tif (arg === \"--\") {\n\t\t\tpastDoubleDash = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (RG_META_FLAGS.has(arg)) {\n\t\t\tparsed.metaOnly = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (arg === \"--files\") {\n\t\t\tparsed.filesMode = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (arg === \"--regexp\" || arg === \"--file\") {\n\t\t\tparsed.hasPatternOption = true;\n\t\t\tindex++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (arg.startsWith(\"--regexp=\") || arg.startsWith(\"--file=\")) {\n\t\t\tparsed.hasPatternOption = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (arg.startsWith(\"--\")) {\n\t\t\tconst flag = arg.split(\"=\", 1)[0];\n\t\t\tif (RG_SCOPE_LONG_FLAGS.has(flag)) parsed.hasScopeFilter = true;\n\t\t\tif (RG_LONG_VALUE_FLAGS.has(flag) && !arg.includes(\"=\")) index++;\n\t\t\tcontinue;\n\t\t}\n\t\tif (arg.startsWith(\"-\") && arg.length > 1) {\n\t\t\tconst cluster = arg.slice(1);\n\t\t\tfor (let flagIndex = 0; flagIndex < cluster.length; flagIndex++) {\n\t\t\t\tconst flag = cluster[flagIndex];\n\t\t\t\tif (flag === \"e\" || flag === \"f\") parsed.hasPatternOption = true;\n\t\t\t\tif (RG_SCOPE_SHORT_FLAGS.has(flag)) parsed.hasScopeFilter = true;\n\t\t\t\tif (flag === \"e\" || RG_SHORT_VALUE_FLAGS.has(flag)) {\n\t\t\t\t\tif (flagIndex === cluster.length - 1) index++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tparsed.positionals.push(arg);\n\t}\n\n\treturn parsed;\n}\n\nfunction assessRg(args: string[], cwd: string, readsPipe: boolean): SearchScopeAssessment {\n\tconst parsed = parseRgArguments(args);\n\tif (parsed.metaOnly) return { kind: \"scoped\" };\n\tconst targets = parsed.filesMode\n\t\t? parsed.positionals\n\t\t: parsed.hasPatternOption\n\t\t\t? parsed.positionals\n\t\t\t: parsed.positionals.slice(1);\n\tif (readsPipe && targets.length === 0 && !parsed.filesMode) return { kind: \"scoped\" };\n\tif (hasSafeTarget(targets, cwd, parsed.hasScopeFilter)) return { kind: \"scoped\" };\n\treturn {\n\t\tkind: \"broad\",\n\t\tsearchTool: \"rg\",\n\t\treason: \"rg would search the whole working tree without a narrow path, glob, or type filter\",\n\t};\n}\n\nfunction assessRecursiveGrep(args: string[], cwd: string, readsPipe: boolean): SearchScopeAssessment {\n\tconst recursive = args.some(\n\t\t(arg) => arg === \"-r\" || arg === \"-R\" || arg === \"--recursive\" || /^-[^-]*[rR]/u.test(arg),\n\t);\n\tif (!recursive || readsPipe) return { kind: \"scoped\" };\n\tconst hasPatternOption = args.some((arg) => arg === \"-e\" || arg.startsWith(\"-e\") || arg === \"--regexp\");\n\tconst hasScopeFilter = args.some(\n\t\t(arg) =>\n\t\t\targ === \"--include\" ||\n\t\t\targ.startsWith(\"--include=\") ||\n\t\t\targ === \"--exclude\" ||\n\t\t\targ.startsWith(\"--exclude=\") ||\n\t\t\targ === \"--exclude-dir\" ||\n\t\t\targ.startsWith(\"--exclude-dir=\"),\n\t);\n\tconst valueFlags = new Set([\"-A\", \"-B\", \"-C\", \"-D\", \"-d\", \"-e\", \"-f\", \"-m\", \"--regexp\"]);\n\tconst positionals: string[] = [];\n\tlet pastDoubleDash = false;\n\tfor (let index = 0; index < args.length; index++) {\n\t\tconst arg = args[index];\n\t\tif (pastDoubleDash) positionals.push(arg);\n\t\telse if (arg === \"--\") pastDoubleDash = true;\n\t\telse if (valueFlags.has(arg) || [\"--include\", \"--exclude\", \"--exclude-dir\"].includes(arg)) index++;\n\t\telse if (!arg.startsWith(\"-\")) positionals.push(arg);\n\t}\n\tconst targets = hasPatternOption ? positionals : positionals.slice(1);\n\tif (hasSafeTarget(targets, cwd, hasScopeFilter)) return { kind: \"scoped\" };\n\treturn {\n\t\tkind: \"broad\",\n\t\tsearchTool: \"grep\",\n\t\treason: \"recursive grep would scan the whole working tree without a narrow path or include filter\",\n\t};\n}\n\nfunction assessFind(args: string[], cwd: string): SearchScopeAssessment {\n\tlet index = 0;\n\twhile (index < args.length) {\n\t\tconst arg = args[index];\n\t\tif (arg === \"-H\" || arg === \"-L\" || arg === \"-P\" || /^-O\\d*$/u.test(arg)) index++;\n\t\telse if (arg === \"-D\") index += 2;\n\t\telse break;\n\t}\n\tconst targets: string[] = [];\n\twhile (index < args.length && !args[index].startsWith(\"-\") && args[index] !== \"!\" && args[index] !== \"(\") {\n\t\ttargets.push(args[index++]);\n\t}\n\tconst hasScopeFilter = args.some((arg) => [\"-iname\", \"-ipath\", \"-iregex\", \"-name\", \"-path\", \"-regex\"].includes(arg));\n\tif (hasSafeTarget(targets, cwd, hasScopeFilter)) return { kind: \"scoped\" };\n\treturn {\n\t\tkind: \"broad\",\n\t\tsearchTool: \"find\",\n\t\treason: \"find would enumerate the whole working tree without a narrow path or name/path predicate\",\n\t};\n}\n\nfunction assessFd(args: string[], cwd: string): SearchScopeAssessment {\n\tconst positionals: string[] = [];\n\tlet hasScopeFilter = false;\n\tlet pastDoubleDash = false;\n\tconst valueFlags = new Set([\n\t\t\"-d\",\n\t\t\"--max-depth\",\n\t\t\"--min-depth\",\n\t\t\"-e\",\n\t\t\"--extension\",\n\t\t\"-E\",\n\t\t\"--exclude\",\n\t\t\"-t\",\n\t\t\"--type\",\n\t\t\"--base-directory\",\n\t\t\"--changed-before\",\n\t\t\"--changed-within\",\n\t\t\"--color\",\n\t\t\"--owner\",\n\t\t\"--path-separator\",\n\t\t\"--search-path\",\n\t]);\n\tfor (let index = 0; index < args.length; index++) {\n\t\tconst arg = args[index];\n\t\tif (pastDoubleDash) positionals.push(arg);\n\t\telse if (arg === \"--\") pastDoubleDash = true;\n\t\telse if (arg === \"-e\" || arg === \"--extension\") {\n\t\t\thasScopeFilter = true;\n\t\t\tindex++;\n\t\t} else if (arg.startsWith(\"--extension=\")) hasScopeFilter = true;\n\t\telse if (valueFlags.has(arg)) index++;\n\t\telse if (!arg.startsWith(\"-\")) positionals.push(arg);\n\t}\n\tconst pattern = positionals[0];\n\tconst targets = positionals.slice(1);\n\tconst meaningfulPattern = Boolean(pattern && pattern !== \".\" && pattern !== \".*\" && pattern !== \"*\");\n\tif (meaningfulPattern || hasSafeTarget(targets, cwd, hasScopeFilter)) return { kind: \"scoped\" };\n\treturn {\n\t\tkind: \"broad\",\n\t\tsearchTool: \"fd\",\n\t\treason: \"fd would enumerate the whole working tree without a narrow pattern, path, glob, extension, or type\",\n\t};\n}\n\nfunction commandName(value: string): string {\n\treturn basename(value)\n\t\t.toLowerCase()\n\t\t.replace(/\\.exe$/u, \"\");\n}\n\nfunction stripInvocationPrefixes(args: string[]): string[] {\n\tlet index = 0;\n\twhile (index < args.length && /^[A-Za-z_][A-Za-z0-9_]*=/u.test(args[index])) index++;\n\tif (args[index] === \"command\") {\n\t\tindex++;\n\t\twhile (args[index]?.startsWith(\"-\")) index++;\n\t}\n\tif (args[index] === \"env\") {\n\t\tindex++;\n\t\twhile (args[index]?.startsWith(\"-\") || /^[A-Za-z_][A-Za-z0-9_]*=/u.test(args[index] ?? \"\")) index++;\n\t}\n\treturn args.slice(index);\n}\n\nfunction assessInvocation(args: string[], cwd: string, readsPipe: boolean): SearchScopeAssessment {\n\tconst invocation = stripInvocationPrefixes(args);\n\tconst name = commandName(invocation[0] ?? \"\");\n\tconst commandArgs = invocation.slice(1);\n\tswitch (name) {\n\t\tcase \"rg\":\n\t\tcase \"ripgrep\":\n\t\t\treturn assessRg(commandArgs, cwd, readsPipe);\n\t\tcase \"grep\":\n\t\t\treturn assessRecursiveGrep(commandArgs, cwd, readsPipe);\n\t\tcase \"find\":\n\t\t\treturn assessFind(commandArgs, cwd);\n\t\tcase \"fd\":\n\t\tcase \"fdfind\":\n\t\t\treturn assessFd(commandArgs, cwd);\n\t\tdefault:\n\t\t\treturn { kind: \"scoped\" };\n\t}\n}\n\n/**\n * Reject shell searches whose filesystem scope cannot be proven narrow. Dedicated grep/find\n * tools already own result caps and artifacts; this closes the raw-shell bypass before execution.\n */\nexport function assessShellSearchScope(command: string, cwd: string): SearchScopeAssessment {\n\tconst tokens = tokenizeShellCommand(command);\n\tif (!tokens) {\n\t\treturn { kind: \"scoped\" };\n\t}\n\n\tlet invocation: string[] = [];\n\tlet ignoreRedirectTarget = false;\n\tlet readsPipe = false;\n\tconst assessCurrent = (): SearchScopeAssessment => assessInvocation(invocation, cwd, readsPipe);\n\n\tfor (const token of tokens) {\n\t\tif (token.kind === \"arg\") {\n\t\t\tif (!ignoreRedirectTarget) invocation.push(token.value);\n\t\t\tcontinue;\n\t\t}\n\t\tif (token.kind === \"redirect\") {\n\t\t\tignoreRedirectTarget = true;\n\t\t\tcontinue;\n\t\t}\n\t\tconst assessment = assessCurrent();\n\t\tif (assessment.kind === \"broad\") return assessment;\n\t\tinvocation = [];\n\t\tignoreRedirectTarget = false;\n\t\treadsPipe = token.kind === \"pipe\";\n\t}\n\n\treturn assessCurrent();\n}\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type Static, Type } from "typebox";
|
|
2
|
+
import { type SecretProfileSummary, SecretVault } from "../secrets/secret-vault.ts";
|
|
3
|
+
declare const secretStoreSchema: Type.TObject<{
|
|
4
|
+
action: Type.TUnion<[Type.TLiteral<"set">, Type.TLiteral<"list">, Type.TLiteral<"materialize">, Type.TLiteral<"remove">, Type.TLiteral<"lock">]>;
|
|
5
|
+
profile: Type.TOptional<Type.TString>;
|
|
6
|
+
description: Type.TOptional<Type.TString>;
|
|
7
|
+
envFile: Type.TOptional<Type.TString>;
|
|
8
|
+
variableNames: Type.TOptional<Type.TArray<Type.TString>>;
|
|
9
|
+
scope: Type.TOptional<Type.TUnion<[Type.TLiteral<"managed">, Type.TLiteral<"workspace">]>>;
|
|
10
|
+
}>;
|
|
11
|
+
export type SecretStoreToolInput = Static<typeof secretStoreSchema>;
|
|
12
|
+
export type SecretStoreStatus = "cancelled" | "error" | "listed" | "locked" | "materialized" | "removed" | "stored" | "unavailable";
|
|
13
|
+
export interface SecretStoreToolDetails {
|
|
14
|
+
action: SecretStoreToolInput["action"];
|
|
15
|
+
status: SecretStoreStatus;
|
|
16
|
+
profile?: string;
|
|
17
|
+
variableNames?: string[];
|
|
18
|
+
profiles?: SecretProfileSummary[];
|
|
19
|
+
scope?: "managed" | "workspace";
|
|
20
|
+
envFile?: string;
|
|
21
|
+
materialized?: boolean;
|
|
22
|
+
code?: string;
|
|
23
|
+
message?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface SecretStoreToolOptions {
|
|
26
|
+
agentDir?: string;
|
|
27
|
+
vault?: SecretVault;
|
|
28
|
+
}
|
|
29
|
+
export declare function createSecretStoreToolDefinition(options: SecretStoreToolOptions): import("../extensions/types.ts").ToolDefinition<Type.TObject<{
|
|
30
|
+
action: Type.TUnion<[Type.TLiteral<"set">, Type.TLiteral<"list">, Type.TLiteral<"materialize">, Type.TLiteral<"remove">, Type.TLiteral<"lock">]>;
|
|
31
|
+
profile: Type.TOptional<Type.TString>;
|
|
32
|
+
description: Type.TOptional<Type.TString>;
|
|
33
|
+
envFile: Type.TOptional<Type.TString>;
|
|
34
|
+
variableNames: Type.TOptional<Type.TArray<Type.TString>>;
|
|
35
|
+
scope: Type.TOptional<Type.TUnion<[Type.TLiteral<"managed">, Type.TLiteral<"workspace">]>>;
|
|
36
|
+
}>, SecretStoreToolDetails, any> & import("../extensions/types.ts").ToolDefinition<any, any, any>;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=secret-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret-store.d.ts","sourceRoot":"","sources":["../../../src/core/tools/secret-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAK5C,OAAO,EAQN,KAAK,oBAAoB,EACzB,WAAW,EAEX,MAAM,4BAA4B,CAAC;AAOpC,QAAA,MAAM,iBAAiB;;;;;;;EA0DtB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEpE,MAAM,MAAM,iBAAiB,GAC1B,WAAW,GACX,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,cAAc,GACd,SAAS,GACT,QAAQ,GACR,aAAa,CAAC;AAEjB,MAAM,WAAW,sBAAsB;IACtC,MAAM,EAAE,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IACvC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAClC,KAAK,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,WAAW,CAAC;CACpB;AA8YD,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,sBAAsB;;;;;;;kGA6E9E","sourcesContent":["import { type Static, Type } from \"typebox\";\nimport { ExtensionEditorComponent } from \"../../modes/interactive/components/extension-editor.ts\";\nimport type { Theme } from \"../../modes/interactive/theme/theme.ts\";\nimport { defineTool, type ExtensionContext } from \"../extensions/types.ts\";\nimport { parseDotenvDocument, SecretDotenvError } from \"../secrets/secret-dotenv.ts\";\nimport {\n\tMAX_VARIABLES_PER_PROFILE,\n\tSECRET_DESCRIPTION_MAX_CHARS,\n\tSECRET_PRINTABLE_METADATA_PATTERN,\n\tSECRET_PROFILE_ID_MAX_CHARS,\n\tSECRET_PROFILE_ID_PATTERN,\n\tSECRET_VARIABLE_NAME_MAX_CHARS,\n\tSECRET_VARIABLE_NAME_PATTERN,\n\ttype SecretProfileSummary,\n\tSecretVault,\n\tSecretVaultError,\n} from \"../secrets/secret-vault.ts\";\nimport {\n\temptyOrchestrationCall,\n\tOrchestrationPanelComponent,\n\ttype OrchestrationPanelModel,\n} from \"./orchestration-panel.ts\";\n\nconst secretStoreSchema = Type.Object(\n\t{\n\t\taction: Type.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"set\"),\n\t\t\t\tType.Literal(\"list\"),\n\t\t\t\tType.Literal(\"materialize\"),\n\t\t\t\tType.Literal(\"remove\"),\n\t\t\t\tType.Literal(\"lock\"),\n\t\t\t],\n\t\t\t{ description: \"Credential-management action.\" },\n\t\t),\n\t\tprofile: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tminLength: 1,\n\t\t\t\tmaxLength: SECRET_PROFILE_ID_MAX_CHARS,\n\t\t\t\tpattern: SECRET_PROFILE_ID_PATTERN,\n\t\t\t\tdescription: \"Portable profile identifier, such as project-dev or aws-work.\",\n\t\t\t}),\n\t\t),\n\t\tdescription: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tminLength: 1,\n\t\t\t\tmaxLength: SECRET_DESCRIPTION_MAX_CHARS,\n\t\t\t\tpattern: SECRET_PRINTABLE_METADATA_PATTERN,\n\t\t\t\tdescription: \"Non-secret profile description.\",\n\t\t\t}),\n\t\t),\n\t\tenvFile: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tminLength: 1,\n\t\t\t\tmaxLength: 512,\n\t\t\t\tdescription:\n\t\t\t\t\t\"Relative dotenv location inside the current workspace, such as .env, .env.local, or config/dev.env. Valid only for set.\",\n\t\t\t}),\n\t\t),\n\t\tvariableNames: Type.Optional(\n\t\t\tType.Array(\n\t\t\t\tType.String({\n\t\t\t\t\tminLength: 1,\n\t\t\t\t\tmaxLength: SECRET_VARIABLE_NAME_MAX_CHARS,\n\t\t\t\t\tpattern: SECRET_VARIABLE_NAME_PATTERN,\n\t\t\t\t}),\n\t\t\t\t{\n\t\t\t\t\tminItems: 1,\n\t\t\t\t\tmaxItems: MAX_VARIABLES_PER_PROFILE,\n\t\t\t\t\tdescription: \"Specific variable names to remove. Omit to remove the whole profile.\",\n\t\t\t\t},\n\t\t\t),\n\t\t),\n\t\tscope: Type.Optional(\n\t\t\tType.Union([Type.Literal(\"managed\"), Type.Literal(\"workspace\")], {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Materialization target. workspace resolves the durable current-project binding; managed writes private Pi state.\",\n\t\t\t}),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type SecretStoreToolInput = Static<typeof secretStoreSchema>;\n\nexport type SecretStoreStatus =\n\t| \"cancelled\"\n\t| \"error\"\n\t| \"listed\"\n\t| \"locked\"\n\t| \"materialized\"\n\t| \"removed\"\n\t| \"stored\"\n\t| \"unavailable\";\n\nexport interface SecretStoreToolDetails {\n\taction: SecretStoreToolInput[\"action\"];\n\tstatus: SecretStoreStatus;\n\tprofile?: string;\n\tvariableNames?: string[];\n\tprofiles?: SecretProfileSummary[];\n\tscope?: \"managed\" | \"workspace\";\n\tenvFile?: string;\n\tmaterialized?: boolean;\n\tcode?: string;\n\tmessage?: string;\n}\n\nexport interface SecretStoreToolOptions {\n\tagentDir?: string;\n\tvault?: SecretVault;\n}\n\ntype SecretStoreResult = {\n\tcontent: Array<{ type: \"text\"; text: string }>;\n\tdetails: SecretStoreToolDetails;\n};\n\nfunction result(details: SecretStoreToolDetails, text: string): SecretStoreResult {\n\treturn { content: [{ type: \"text\", text }], details };\n}\n\nfunction cancelled(action: SecretStoreToolInput[\"action\"], profile?: string): SecretStoreResult {\n\treturn result(\n\t\t{ action, status: \"cancelled\", ...(profile ? { profile } : {}), code: \"owner_cancelled\" },\n\t\t\"Secret store action was cancelled by the owner.\",\n\t);\n}\n\nfunction failed(action: SecretStoreToolInput[\"action\"], error: unknown, profile?: string): SecretStoreResult {\n\tconst code = error instanceof SecretVaultError ? error.code : \"safe_failure\";\n\tconst message =\n\t\terror instanceof SecretVaultError ? error.message : \"Secret store failed safely without exposing values.\";\n\treturn result(\n\t\t{ action, status: \"error\", ...(profile ? { profile } : {}), code, message },\n\t\t`Secret store failed: ${message}`,\n\t);\n}\n\nfunction invalid(\n\taction: SecretStoreToolInput[\"action\"],\n\tcode: string,\n\tmessage: string,\n\tprofile?: string,\n): SecretStoreResult {\n\treturn result(\n\t\t{ action, status: \"error\", ...(profile ? { profile } : {}), code, message },\n\t\t`Secret store request is invalid: ${message}`,\n\t);\n}\n\nfunction panelModel(details: SecretStoreToolDetails | undefined, expanded: boolean): OrchestrationPanelModel {\n\tif (!details) return { label: \"secrets\", status: \"error\", emptyText: \"No secret-store result was retained.\" };\n\tconst success = [\"listed\", \"locked\", \"materialized\", \"removed\", \"stored\"].includes(details.status);\n\tconst rows = expanded\n\t\t? (details.profiles ?? []).map((profile) => ({\n\t\t\t\tstatus: \"info\" as const,\n\t\t\t\tlabel: profile.profile,\n\t\t\t\tmeta: [\n\t\t\t\t\t`${profile.variableNames.length} variable${profile.variableNames.length === 1 ? \"\" : \"s\"}`,\n\t\t\t\t\t`${profile.bindings.length} binding${profile.bindings.length === 1 ? \"\" : \"s\"}`,\n\t\t\t\t],\n\t\t\t\tdetails: [\n\t\t\t\t\t...(profile.description ? [profile.description] : []),\n\t\t\t\t\t...profile.bindings.map((binding) => `${binding.envFile} · ${binding.workspace}`),\n\t\t\t\t],\n\t\t\t}))\n\t\t: undefined;\n\treturn {\n\t\tlabel: \"secrets\",\n\t\taction: details.status,\n\t\tstatus: success ? \"success\" : details.status === \"cancelled\" ? \"warning\" : \"error\",\n\t\tsummary: [\n\t\t\tdetails.profile,\n\t\t\tdetails.envFile,\n\t\t\tdetails.scope,\n\t\t\tdetails.variableNames\n\t\t\t\t? `${details.variableNames.length} variable${details.variableNames.length === 1 ? \"\" : \"s\"}`\n\t\t\t\t: undefined,\n\t\t\tdetails.profiles ? `${details.profiles.length} profile${details.profiles.length === 1 ? \"\" : \"s\"}` : undefined,\n\t\t].filter((value): value is string => value !== undefined),\n\t\trows,\n\t\tnotices:\n\t\t\texpanded && details.message ? [{ status: success ? \"info\" : \"error\", text: details.message }] : undefined,\n\t};\n}\n\nasync function ensureUnlocked(\n\tvault: SecretVault,\n\taction: SecretStoreToolInput[\"action\"],\n\tctx: ExtensionContext,\n\tsignal: AbortSignal | undefined,\n\tprofile?: string,\n): Promise<SecretStoreResult | undefined> {\n\tif (vault.isUnlocked) return undefined;\n\tif (await vault.exists()) {\n\t\twhile (!signal?.aborted) {\n\t\t\tlet passphrase = await ctx.ui.input(\"Unlock secret vault\", \"Master passphrase\", {\n\t\t\t\tsignal,\n\t\t\t\tsensitive: true,\n\t\t\t});\n\t\t\tif (passphrase === undefined || signal?.aborted) return cancelled(action, profile);\n\t\t\ttry {\n\t\t\t\tawait vault.unlock(passphrase);\n\t\t\t\treturn undefined;\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof SecretVaultError && [\"invalid_passphrase\", \"unlock_failed\"].includes(error.code)) {\n\t\t\t\t\tctx.ui.notify(error.message, \"error\");\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\treturn failed(action, error, profile);\n\t\t\t} finally {\n\t\t\t\tpassphrase = \"\";\n\t\t\t}\n\t\t}\n\t\treturn cancelled(action, profile);\n\t}\n\n\twhile (!signal?.aborted) {\n\t\tlet passphrase = await ctx.ui.input(\"Create secret vault\", \"New master passphrase\", { signal, sensitive: true });\n\t\tif (passphrase === undefined || signal?.aborted) return cancelled(action, profile);\n\t\tlet confirmation = await ctx.ui.input(\"Confirm secret vault\", \"Repeat master passphrase\", {\n\t\t\tsignal,\n\t\t\tsensitive: true,\n\t\t});\n\t\tif (confirmation === undefined || signal?.aborted) {\n\t\t\tpassphrase = \"\";\n\t\t\treturn cancelled(action, profile);\n\t\t}\n\t\ttry {\n\t\t\tif (passphrase !== confirmation) {\n\t\t\t\tctx.ui.notify(\"The two master passphrases do not match.\", \"error\");\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tawait vault.initialize(passphrase);\n\t\t\treturn undefined;\n\t\t} catch (error) {\n\t\t\tif (error instanceof SecretVaultError && error.code === \"invalid_passphrase\") {\n\t\t\t\tctx.ui.notify(error.message, \"error\");\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\treturn failed(action, error, profile);\n\t\t} finally {\n\t\t\tpassphrase = \"\";\n\t\t\tconfirmation = \"\";\n\t\t}\n\t}\n\treturn cancelled(action, profile);\n}\n\nfunction validateInput(input: SecretStoreToolInput): SecretStoreResult | undefined {\n\tif (input.action === \"lock\" || input.action === \"list\") {\n\t\tif (\n\t\t\tinput.profile !== undefined ||\n\t\t\tinput.description !== undefined ||\n\t\t\tinput.envFile !== undefined ||\n\t\t\tinput.variableNames !== undefined ||\n\t\t\tinput.scope !== undefined\n\t\t) {\n\t\t\treturn invalid(input.action, \"unexpected_fields\", `Action ${input.action} does not accept profile fields.`);\n\t\t}\n\t\treturn undefined;\n\t}\n\tif (input.action === \"set\" && !input.profile) {\n\t\treturn invalid(input.action, \"profile_required\", \"Action set requires a profile.\");\n\t}\n\tif (input.action === \"remove\" && !input.profile) {\n\t\treturn invalid(input.action, \"profile_required\", \"Action remove requires a profile.\");\n\t}\n\tif (input.action !== \"set\" && (input.description !== undefined || input.envFile !== undefined)) {\n\t\treturn invalid(\n\t\t\tinput.action,\n\t\t\t\"unexpected_profile_fields\",\n\t\t\t\"description and envFile are valid only for set.\",\n\t\t\tinput.profile,\n\t\t);\n\t}\n\tif (input.action !== \"remove\" && input.variableNames !== undefined) {\n\t\treturn invalid(\n\t\t\tinput.action,\n\t\t\t\"unexpected_variable_names\",\n\t\t\t\"variableNames is valid only for remove.\",\n\t\t\tinput.profile,\n\t\t);\n\t}\n\tif (input.action !== \"materialize\" && input.scope !== undefined) {\n\t\treturn invalid(input.action, \"unexpected_scope\", \"scope is valid only for materialize.\", input.profile);\n\t}\n\tif (input.variableNames && new Set(input.variableNames).size !== input.variableNames.length) {\n\t\treturn invalid(input.action, \"duplicate_variables\", \"Variable names must be unique.\", input.profile);\n\t}\n\treturn undefined;\n}\n\nasync function openPrivateDotenvEditor(\n\tctx: ExtensionContext,\n\ttitle: string,\n\tprefill: string,\n\tsignal: AbortSignal | undefined,\n): Promise<string | undefined> {\n\tif (signal?.aborted) return undefined;\n\ttry {\n\t\treturn await ctx.ui.custom<string | undefined>(\n\t\t\t(tui, _theme, keybindings, done) =>\n\t\t\t\tnew ExtensionEditorComponent(\n\t\t\t\t\ttui,\n\t\t\t\t\tkeybindings,\n\t\t\t\t\ttitle,\n\t\t\t\t\tprefill,\n\t\t\t\t\t(value) => done(value),\n\t\t\t\t\t() => done(undefined),\n\t\t\t\t\t{\n\t\t\t\t\t\tprivateContent: true,\n\t\t\t\t\t\tallowExternalEditor: false,\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\tnotice: \"Private plaintext editor · content stays local and never enters model context\",\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t);\n\t} catch (error) {\n\t\tif (signal?.aborted) return undefined;\n\t\tthrow error;\n\t}\n}\n\nasync function captureValidDotenv(\n\tctx: ExtensionContext,\n\ttitle: string,\n\tprefill: string,\n\tsignal: AbortSignal | undefined,\n): Promise<{ document: string; variableNames: string[] } | undefined> {\n\tlet draft = prefill;\n\twhile (!signal?.aborted) {\n\t\tconst edited = await openPrivateDotenvEditor(ctx, title, draft, signal);\n\t\tif (edited === undefined || signal?.aborted) return undefined;\n\t\ttry {\n\t\t\tconst parsed = parseDotenvDocument(edited);\n\t\t\tconst variableNames = parsed.variables.map((variable) => variable.name);\n\t\t\tfor (const variable of parsed.variables) variable.value = \"\";\n\t\t\tdraft = \"\";\n\t\t\treturn { document: parsed.document, variableNames };\n\t\t} catch (error) {\n\t\t\tctx.ui.notify(error instanceof SecretDotenvError ? error.message : \"The dotenv document is invalid.\", \"error\");\n\t\t\tdraft = edited;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nasync function executeSet(\n\tvault: SecretVault,\n\tinput: SecretStoreToolInput & { profile: string },\n\tctx: ExtensionContext,\n\tsignal: AbortSignal | undefined,\n): Promise<SecretStoreResult> {\n\tlet document = \"\";\n\tlet originalUnmanagedContent: string | undefined;\n\ttry {\n\t\tconst target = vault.resolveBindingTarget(ctx.cwd, input.envFile ?? \".env\");\n\t\tconst destinationState = await vault.inspectEnvDestination(target.destination, input.profile);\n\t\tif (destinationState === \"managed-other\") {\n\t\t\treturn invalid(\n\t\t\t\tinput.action,\n\t\t\t\t\"destination_conflict\",\n\t\t\t\t\"The selected dotenv location is already managed by another profile.\",\n\t\t\t\tinput.profile,\n\t\t\t);\n\t\t}\n\t\tconst storedDocument = await vault.getProfileDocument(input.profile);\n\t\tlet prefill = storedDocument ?? \"\";\n\t\tif (destinationState === \"unmanaged\") {\n\t\t\toriginalUnmanagedContent = await vault.readOwnerDotenv(target.destination);\n\t\t\tprefill = originalUnmanagedContent;\n\t\t}\n\t\tif (destinationState === \"managed-profile\" && storedDocument === undefined) {\n\t\t\treturn invalid(\n\t\t\t\tinput.action,\n\t\t\t\t\"profile_missing\",\n\t\t\t\t\"The dotenv target claims this profile, but the encrypted profile is missing.\",\n\t\t\t\tinput.profile,\n\t\t\t);\n\t\t}\n\n\t\tconst captured = await captureValidDotenv(\n\t\t\tctx,\n\t\t\t`Secrets · ${input.profile} → ${target.destination}`,\n\t\t\tprefill,\n\t\t\tsignal,\n\t\t);\n\t\tprefill = \"\";\n\t\tif (!captured) return cancelled(input.action, input.profile);\n\t\tdocument = captured.document;\n\t\tawait vault.replaceProfileDocument(input.profile, input.description, document, {\n\t\t\tworkspace: target.workspace,\n\t\t\tenvFile: target.envFile,\n\t\t});\n\t\ttry {\n\t\t\tawait vault.materializeEnv(input.profile, target.destination, {\n\t\t\t\tallowReplaceUnmanaged: destinationState === \"unmanaged\",\n\t\t\t\texpectedUnmanagedContent: originalUnmanagedContent,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof SecretVaultError ? error.message : \"Dotenv materialization failed safely.\";\n\t\t\tctx.ui.notify(`Profile stored, but ${target.destination} was not refreshed: ${message}`, \"warning\");\n\t\t\treturn result(\n\t\t\t\t{\n\t\t\t\t\taction: input.action,\n\t\t\t\t\tstatus: \"stored\",\n\t\t\t\t\tprofile: input.profile,\n\t\t\t\t\tenvFile: target.envFile,\n\t\t\t\t\tvariableNames: captured.variableNames,\n\t\t\t\t\tmaterialized: false,\n\t\t\t\t\tcode: \"materialization_failed\",\n\t\t\t\t\tmessage,\n\t\t\t\t},\n\t\t\t\t`Stored profile ${input.profile}, but its bound dotenv could not be refreshed. Retry secret_store materialize; no values were exposed.`,\n\t\t\t);\n\t\t}\n\t\tctx.ui.notify(`Credential profile ${input.profile} stored and activated at ${target.destination}`, \"info\");\n\t\treturn result(\n\t\t\t{\n\t\t\t\taction: input.action,\n\t\t\t\tstatus: \"stored\",\n\t\t\t\tprofile: input.profile,\n\t\t\t\tenvFile: target.envFile,\n\t\t\t\tvariableNames: captured.variableNames,\n\t\t\t\tmaterialized: true,\n\t\t\t},\n\t\t\t`Stored and activated ${captured.variableNames.length} variables for profile ${input.profile} at its bound workspace dotenv location. Values never entered model context.`,\n\t\t);\n\t} catch (error) {\n\t\treturn failed(input.action, error, input.profile);\n\t} finally {\n\t\tdocument = \"\";\n\t\toriginalUnmanagedContent = undefined;\n\t}\n}\n\nasync function executeMaterialize(\n\tvault: SecretVault,\n\tinput: SecretStoreToolInput,\n\tctx: ExtensionContext,\n): Promise<SecretStoreResult> {\n\ttry {\n\t\tconst scope = input.scope ?? \"workspace\";\n\t\tconst binding = await vault.resolveBindingForWorkspace(ctx.cwd, input.profile);\n\t\tconst destination = scope === \"managed\" ? vault.getManagedEnvPath(binding.profile) : binding.destination;\n\t\tconst destinationState = await vault.inspectEnvDestination(destination, binding.profile);\n\t\tif (destinationState === \"unmanaged\" || destinationState === \"managed-other\") {\n\t\t\treturn invalid(\n\t\t\t\tinput.action,\n\t\t\t\t\"destination_conflict\",\n\t\t\t\t\"The bound dotenv location is no longer safely managed. Use set to review it in the private editor.\",\n\t\t\t\tbinding.profile,\n\t\t\t);\n\t\t}\n\t\tconst materialized = await vault.materializeEnv(binding.profile, destination, {\n\t\t\tactivationWorkspace: ctx.cwd,\n\t\t\tmanaged: scope === \"managed\",\n\t\t});\n\t\tctx.ui.notify(`Credential profile ${binding.profile} activated at ${destination}`, \"info\");\n\t\treturn result(\n\t\t\t{\n\t\t\t\taction: input.action,\n\t\t\t\tstatus: \"materialized\",\n\t\t\t\tprofile: binding.profile,\n\t\t\t\tvariableNames: materialized.variableNames,\n\t\t\t\tscope,\n\t\t\t\tenvFile: scope === \"workspace\" ? binding.envFile : undefined,\n\t\t\t\tmaterialized: true,\n\t\t\t},\n\t\t\t`Activated profile ${binding.profile} for the current workspace. Its dotenv and process environment are available without exposing values to the model.`,\n\t\t);\n\t} catch (error) {\n\t\treturn failed(input.action, error, input.profile);\n\t}\n}\n\nasync function executeRemove(\n\tvault: SecretVault,\n\tinput: SecretStoreToolInput & { profile: string },\n\tctx: ExtensionContext,\n\tsignal: AbortSignal | undefined,\n): Promise<SecretStoreResult> {\n\tconst target = input.variableNames?.length\n\t\t? `${input.variableNames.join(\", \")} from profile ${input.profile}`\n\t\t: `the entire profile ${input.profile}`;\n\tconst approved = await ctx.ui.confirm(\n\t\t\"Remove stored secrets\",\n\t\t`Remove ${target}? Pi-managed workspace and private dotenv copies are invalidated.`,\n\t\t{ signal },\n\t);\n\tif (!approved || signal?.aborted) return cancelled(input.action, input.profile);\n\ttry {\n\t\tconst removal = await vault.removeProfile(input.profile, input.variableNames);\n\t\treturn result(\n\t\t\t{\n\t\t\t\taction: input.action,\n\t\t\t\tstatus: \"removed\",\n\t\t\t\tprofile: input.profile,\n\t\t\t\tvariableNames: removal.removedVariableNames,\n\t\t\t},\n\t\t\t`Removed ${removal.removedVariableNames.length} secret variable${removal.removedVariableNames.length === 1 ? \"\" : \"s\"} from profile ${input.profile}.`,\n\t\t);\n\t} catch (error) {\n\t\treturn failed(input.action, error, input.profile);\n\t}\n}\n\nexport function createSecretStoreToolDefinition(options: SecretStoreToolOptions) {\n\tconst vault = options.vault ?? (options.agentDir ? SecretVault.forAgentDir(options.agentDir) : undefined);\n\tif (!vault) throw new Error(\"secret_store requires an agentDir or SecretVault\");\n\treturn defineTool<typeof secretStoreSchema, SecretStoreToolDetails>({\n\t\tname: \"secret_store\",\n\t\tlabel: \"Secret Store\",\n\t\tdescription:\n\t\t\t\"Open a model-blind native dotenv editor, encrypt owner credentials, bind profiles to workspace dotenv locations, and activate them for normal process use without returning values to the model.\",\n\t\tpromptSnippet:\n\t\t\t\"Manage credentials through the model-blind secret vault. Before credential-dependent work, materialize the current workspace binding; use set to open the owner's private dotenv editor.\",\n\t\tpromptGuidelines: [\n\t\t\t\"Use secret_store whenever credentials are needed. Never ask the owner to paste a secret into chat or place a value in tool arguments.\",\n\t\t\t\"Use set with a profile and relative envFile. The harness opens a private plaintext editor, persists the workspace binding, writes the dotenv, and activates the environment.\",\n\t\t\t\"Before credential-dependent commands in a later session, call materialize without a profile to resolve the current workspace binding. Use list only when selection or discovery is needed.\",\n\t\t\t\"After activation, run the consuming application normally. Never read, grep, print, echo, source, or otherwise inspect credential files or environment values.\",\n\t\t\t\"Treat cancellation as owner intent. Do not immediately repeat the same credential request.\",\n\t\t],\n\t\tparameters: secretStoreSchema,\n\t\texecutionMode: \"sequential\",\n\t\trenderShell: \"self\",\n\t\trenderCall() {\n\t\t\treturn emptyOrchestrationCall();\n\t\t},\n\t\trenderResult(toolResult, { expanded, isPartial }, theme: Theme) {\n\t\t\tif (isPartial) {\n\t\t\t\treturn new OrchestrationPanelComponent(theme, {\n\t\t\t\t\tlabel: \"secrets\",\n\t\t\t\t\taction: \"waiting for you\",\n\t\t\t\t\tstatus: \"running\",\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn new OrchestrationPanelComponent(theme, panelModel(toolResult.details, expanded), expanded);\n\t\t},\n\t\tasync execute(_toolCallId, input, signal, _onUpdate, ctx) {\n\t\t\tif (!ctx.hasUI || ctx.mode !== \"tui\") {\n\t\t\t\treturn result(\n\t\t\t\t\t{\n\t\t\t\t\t\taction: input.action,\n\t\t\t\t\t\tstatus: \"unavailable\",\n\t\t\t\t\t\t...(input.profile ? { profile: input.profile } : {}),\n\t\t\t\t\t\tcode: \"user_tui_required\",\n\t\t\t\t\t\tmessage: \"Secret values can be captured only in a user-visible TUI session.\",\n\t\t\t\t\t},\n\t\t\t\t\t\"secret_store requires a user-visible TUI session.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (signal?.aborted) return cancelled(input.action, input.profile);\n\t\t\tconst validation = validateInput(input);\n\t\t\tif (validation) return validation;\n\t\t\tif (input.action === \"lock\") {\n\t\t\t\tvault.lock();\n\t\t\t\treturn result(\n\t\t\t\t\t{ action: input.action, status: \"locked\" },\n\t\t\t\t\t\"Secret vault locked; cached key, credential environment, and exact-value redaction cache were cleared.\",\n\t\t\t\t);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst unlockResult = await ensureUnlocked(vault, input.action, ctx, signal, input.profile);\n\t\t\t\tif (unlockResult) return unlockResult;\n\t\t\t\tif (input.action === \"list\") {\n\t\t\t\t\tconst profiles = await vault.listProfiles();\n\t\t\t\t\treturn result(\n\t\t\t\t\t\t{ action: input.action, status: \"listed\", profiles },\n\t\t\t\t\t\t`Secret vault contains ${profiles.length} profile${profiles.length === 1 ? \"\" : \"s\"}. Only names, variable names, and workspace bindings were returned.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (input.action === \"set\" && input.profile) {\n\t\t\t\t\treturn executeSet(vault, { ...input, profile: input.profile }, ctx, signal);\n\t\t\t\t}\n\t\t\t\tif (input.action === \"materialize\") return executeMaterialize(vault, input, ctx);\n\t\t\t\tif (!input.profile) return invalid(input.action, \"profile_required\", \"A profile is required.\");\n\t\t\t\treturn executeRemove(vault, { ...input, profile: input.profile }, ctx, signal);\n\t\t\t} catch (error) {\n\t\t\t\treturn failed(input.action, error, input.profile);\n\t\t\t}\n\t\t},\n\t});\n}\n"]}
|
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { ExtensionEditorComponent } from "../../modes/interactive/components/extension-editor.js";
|
|
3
|
+
import { defineTool } from "../extensions/types.js";
|
|
4
|
+
import { parseDotenvDocument, SecretDotenvError } from "../secrets/secret-dotenv.js";
|
|
5
|
+
import { MAX_VARIABLES_PER_PROFILE, SECRET_DESCRIPTION_MAX_CHARS, SECRET_PRINTABLE_METADATA_PATTERN, SECRET_PROFILE_ID_MAX_CHARS, SECRET_PROFILE_ID_PATTERN, SECRET_VARIABLE_NAME_MAX_CHARS, SECRET_VARIABLE_NAME_PATTERN, SecretVault, SecretVaultError, } from "../secrets/secret-vault.js";
|
|
6
|
+
import { emptyOrchestrationCall, OrchestrationPanelComponent, } from "./orchestration-panel.js";
|
|
7
|
+
const secretStoreSchema = Type.Object({
|
|
8
|
+
action: Type.Union([
|
|
9
|
+
Type.Literal("set"),
|
|
10
|
+
Type.Literal("list"),
|
|
11
|
+
Type.Literal("materialize"),
|
|
12
|
+
Type.Literal("remove"),
|
|
13
|
+
Type.Literal("lock"),
|
|
14
|
+
], { description: "Credential-management action." }),
|
|
15
|
+
profile: Type.Optional(Type.String({
|
|
16
|
+
minLength: 1,
|
|
17
|
+
maxLength: SECRET_PROFILE_ID_MAX_CHARS,
|
|
18
|
+
pattern: SECRET_PROFILE_ID_PATTERN,
|
|
19
|
+
description: "Portable profile identifier, such as project-dev or aws-work.",
|
|
20
|
+
})),
|
|
21
|
+
description: Type.Optional(Type.String({
|
|
22
|
+
minLength: 1,
|
|
23
|
+
maxLength: SECRET_DESCRIPTION_MAX_CHARS,
|
|
24
|
+
pattern: SECRET_PRINTABLE_METADATA_PATTERN,
|
|
25
|
+
description: "Non-secret profile description.",
|
|
26
|
+
})),
|
|
27
|
+
envFile: Type.Optional(Type.String({
|
|
28
|
+
minLength: 1,
|
|
29
|
+
maxLength: 512,
|
|
30
|
+
description: "Relative dotenv location inside the current workspace, such as .env, .env.local, or config/dev.env. Valid only for set.",
|
|
31
|
+
})),
|
|
32
|
+
variableNames: Type.Optional(Type.Array(Type.String({
|
|
33
|
+
minLength: 1,
|
|
34
|
+
maxLength: SECRET_VARIABLE_NAME_MAX_CHARS,
|
|
35
|
+
pattern: SECRET_VARIABLE_NAME_PATTERN,
|
|
36
|
+
}), {
|
|
37
|
+
minItems: 1,
|
|
38
|
+
maxItems: MAX_VARIABLES_PER_PROFILE,
|
|
39
|
+
description: "Specific variable names to remove. Omit to remove the whole profile.",
|
|
40
|
+
})),
|
|
41
|
+
scope: Type.Optional(Type.Union([Type.Literal("managed"), Type.Literal("workspace")], {
|
|
42
|
+
description: "Materialization target. workspace resolves the durable current-project binding; managed writes private Pi state.",
|
|
43
|
+
})),
|
|
44
|
+
}, { additionalProperties: false });
|
|
45
|
+
function result(details, text) {
|
|
46
|
+
return { content: [{ type: "text", text }], details };
|
|
47
|
+
}
|
|
48
|
+
function cancelled(action, profile) {
|
|
49
|
+
return result({ action, status: "cancelled", ...(profile ? { profile } : {}), code: "owner_cancelled" }, "Secret store action was cancelled by the owner.");
|
|
50
|
+
}
|
|
51
|
+
function failed(action, error, profile) {
|
|
52
|
+
const code = error instanceof SecretVaultError ? error.code : "safe_failure";
|
|
53
|
+
const message = error instanceof SecretVaultError ? error.message : "Secret store failed safely without exposing values.";
|
|
54
|
+
return result({ action, status: "error", ...(profile ? { profile } : {}), code, message }, `Secret store failed: ${message}`);
|
|
55
|
+
}
|
|
56
|
+
function invalid(action, code, message, profile) {
|
|
57
|
+
return result({ action, status: "error", ...(profile ? { profile } : {}), code, message }, `Secret store request is invalid: ${message}`);
|
|
58
|
+
}
|
|
59
|
+
function panelModel(details, expanded) {
|
|
60
|
+
if (!details)
|
|
61
|
+
return { label: "secrets", status: "error", emptyText: "No secret-store result was retained." };
|
|
62
|
+
const success = ["listed", "locked", "materialized", "removed", "stored"].includes(details.status);
|
|
63
|
+
const rows = expanded
|
|
64
|
+
? (details.profiles ?? []).map((profile) => ({
|
|
65
|
+
status: "info",
|
|
66
|
+
label: profile.profile,
|
|
67
|
+
meta: [
|
|
68
|
+
`${profile.variableNames.length} variable${profile.variableNames.length === 1 ? "" : "s"}`,
|
|
69
|
+
`${profile.bindings.length} binding${profile.bindings.length === 1 ? "" : "s"}`,
|
|
70
|
+
],
|
|
71
|
+
details: [
|
|
72
|
+
...(profile.description ? [profile.description] : []),
|
|
73
|
+
...profile.bindings.map((binding) => `${binding.envFile} · ${binding.workspace}`),
|
|
74
|
+
],
|
|
75
|
+
}))
|
|
76
|
+
: undefined;
|
|
77
|
+
return {
|
|
78
|
+
label: "secrets",
|
|
79
|
+
action: details.status,
|
|
80
|
+
status: success ? "success" : details.status === "cancelled" ? "warning" : "error",
|
|
81
|
+
summary: [
|
|
82
|
+
details.profile,
|
|
83
|
+
details.envFile,
|
|
84
|
+
details.scope,
|
|
85
|
+
details.variableNames
|
|
86
|
+
? `${details.variableNames.length} variable${details.variableNames.length === 1 ? "" : "s"}`
|
|
87
|
+
: undefined,
|
|
88
|
+
details.profiles ? `${details.profiles.length} profile${details.profiles.length === 1 ? "" : "s"}` : undefined,
|
|
89
|
+
].filter((value) => value !== undefined),
|
|
90
|
+
rows,
|
|
91
|
+
notices: expanded && details.message ? [{ status: success ? "info" : "error", text: details.message }] : undefined,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
async function ensureUnlocked(vault, action, ctx, signal, profile) {
|
|
95
|
+
if (vault.isUnlocked)
|
|
96
|
+
return undefined;
|
|
97
|
+
if (await vault.exists()) {
|
|
98
|
+
while (!signal?.aborted) {
|
|
99
|
+
let passphrase = await ctx.ui.input("Unlock secret vault", "Master passphrase", {
|
|
100
|
+
signal,
|
|
101
|
+
sensitive: true,
|
|
102
|
+
});
|
|
103
|
+
if (passphrase === undefined || signal?.aborted)
|
|
104
|
+
return cancelled(action, profile);
|
|
105
|
+
try {
|
|
106
|
+
await vault.unlock(passphrase);
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
if (error instanceof SecretVaultError && ["invalid_passphrase", "unlock_failed"].includes(error.code)) {
|
|
111
|
+
ctx.ui.notify(error.message, "error");
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
return failed(action, error, profile);
|
|
115
|
+
}
|
|
116
|
+
finally {
|
|
117
|
+
passphrase = "";
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return cancelled(action, profile);
|
|
121
|
+
}
|
|
122
|
+
while (!signal?.aborted) {
|
|
123
|
+
let passphrase = await ctx.ui.input("Create secret vault", "New master passphrase", { signal, sensitive: true });
|
|
124
|
+
if (passphrase === undefined || signal?.aborted)
|
|
125
|
+
return cancelled(action, profile);
|
|
126
|
+
let confirmation = await ctx.ui.input("Confirm secret vault", "Repeat master passphrase", {
|
|
127
|
+
signal,
|
|
128
|
+
sensitive: true,
|
|
129
|
+
});
|
|
130
|
+
if (confirmation === undefined || signal?.aborted) {
|
|
131
|
+
passphrase = "";
|
|
132
|
+
return cancelled(action, profile);
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
if (passphrase !== confirmation) {
|
|
136
|
+
ctx.ui.notify("The two master passphrases do not match.", "error");
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
await vault.initialize(passphrase);
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
if (error instanceof SecretVaultError && error.code === "invalid_passphrase") {
|
|
144
|
+
ctx.ui.notify(error.message, "error");
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
return failed(action, error, profile);
|
|
148
|
+
}
|
|
149
|
+
finally {
|
|
150
|
+
passphrase = "";
|
|
151
|
+
confirmation = "";
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return cancelled(action, profile);
|
|
155
|
+
}
|
|
156
|
+
function validateInput(input) {
|
|
157
|
+
if (input.action === "lock" || input.action === "list") {
|
|
158
|
+
if (input.profile !== undefined ||
|
|
159
|
+
input.description !== undefined ||
|
|
160
|
+
input.envFile !== undefined ||
|
|
161
|
+
input.variableNames !== undefined ||
|
|
162
|
+
input.scope !== undefined) {
|
|
163
|
+
return invalid(input.action, "unexpected_fields", `Action ${input.action} does not accept profile fields.`);
|
|
164
|
+
}
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
if (input.action === "set" && !input.profile) {
|
|
168
|
+
return invalid(input.action, "profile_required", "Action set requires a profile.");
|
|
169
|
+
}
|
|
170
|
+
if (input.action === "remove" && !input.profile) {
|
|
171
|
+
return invalid(input.action, "profile_required", "Action remove requires a profile.");
|
|
172
|
+
}
|
|
173
|
+
if (input.action !== "set" && (input.description !== undefined || input.envFile !== undefined)) {
|
|
174
|
+
return invalid(input.action, "unexpected_profile_fields", "description and envFile are valid only for set.", input.profile);
|
|
175
|
+
}
|
|
176
|
+
if (input.action !== "remove" && input.variableNames !== undefined) {
|
|
177
|
+
return invalid(input.action, "unexpected_variable_names", "variableNames is valid only for remove.", input.profile);
|
|
178
|
+
}
|
|
179
|
+
if (input.action !== "materialize" && input.scope !== undefined) {
|
|
180
|
+
return invalid(input.action, "unexpected_scope", "scope is valid only for materialize.", input.profile);
|
|
181
|
+
}
|
|
182
|
+
if (input.variableNames && new Set(input.variableNames).size !== input.variableNames.length) {
|
|
183
|
+
return invalid(input.action, "duplicate_variables", "Variable names must be unique.", input.profile);
|
|
184
|
+
}
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
async function openPrivateDotenvEditor(ctx, title, prefill, signal) {
|
|
188
|
+
if (signal?.aborted)
|
|
189
|
+
return undefined;
|
|
190
|
+
try {
|
|
191
|
+
return await ctx.ui.custom((tui, _theme, keybindings, done) => new ExtensionEditorComponent(tui, keybindings, title, prefill, (value) => done(value), () => done(undefined), {
|
|
192
|
+
privateContent: true,
|
|
193
|
+
allowExternalEditor: false,
|
|
194
|
+
signal,
|
|
195
|
+
notice: "Private plaintext editor · content stays local and never enters model context",
|
|
196
|
+
}));
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
if (signal?.aborted)
|
|
200
|
+
return undefined;
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
async function captureValidDotenv(ctx, title, prefill, signal) {
|
|
205
|
+
let draft = prefill;
|
|
206
|
+
while (!signal?.aborted) {
|
|
207
|
+
const edited = await openPrivateDotenvEditor(ctx, title, draft, signal);
|
|
208
|
+
if (edited === undefined || signal?.aborted)
|
|
209
|
+
return undefined;
|
|
210
|
+
try {
|
|
211
|
+
const parsed = parseDotenvDocument(edited);
|
|
212
|
+
const variableNames = parsed.variables.map((variable) => variable.name);
|
|
213
|
+
for (const variable of parsed.variables)
|
|
214
|
+
variable.value = "";
|
|
215
|
+
draft = "";
|
|
216
|
+
return { document: parsed.document, variableNames };
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
ctx.ui.notify(error instanceof SecretDotenvError ? error.message : "The dotenv document is invalid.", "error");
|
|
220
|
+
draft = edited;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return undefined;
|
|
224
|
+
}
|
|
225
|
+
async function executeSet(vault, input, ctx, signal) {
|
|
226
|
+
let document = "";
|
|
227
|
+
let originalUnmanagedContent;
|
|
228
|
+
try {
|
|
229
|
+
const target = vault.resolveBindingTarget(ctx.cwd, input.envFile ?? ".env");
|
|
230
|
+
const destinationState = await vault.inspectEnvDestination(target.destination, input.profile);
|
|
231
|
+
if (destinationState === "managed-other") {
|
|
232
|
+
return invalid(input.action, "destination_conflict", "The selected dotenv location is already managed by another profile.", input.profile);
|
|
233
|
+
}
|
|
234
|
+
const storedDocument = await vault.getProfileDocument(input.profile);
|
|
235
|
+
let prefill = storedDocument ?? "";
|
|
236
|
+
if (destinationState === "unmanaged") {
|
|
237
|
+
originalUnmanagedContent = await vault.readOwnerDotenv(target.destination);
|
|
238
|
+
prefill = originalUnmanagedContent;
|
|
239
|
+
}
|
|
240
|
+
if (destinationState === "managed-profile" && storedDocument === undefined) {
|
|
241
|
+
return invalid(input.action, "profile_missing", "The dotenv target claims this profile, but the encrypted profile is missing.", input.profile);
|
|
242
|
+
}
|
|
243
|
+
const captured = await captureValidDotenv(ctx, `Secrets · ${input.profile} → ${target.destination}`, prefill, signal);
|
|
244
|
+
prefill = "";
|
|
245
|
+
if (!captured)
|
|
246
|
+
return cancelled(input.action, input.profile);
|
|
247
|
+
document = captured.document;
|
|
248
|
+
await vault.replaceProfileDocument(input.profile, input.description, document, {
|
|
249
|
+
workspace: target.workspace,
|
|
250
|
+
envFile: target.envFile,
|
|
251
|
+
});
|
|
252
|
+
try {
|
|
253
|
+
await vault.materializeEnv(input.profile, target.destination, {
|
|
254
|
+
allowReplaceUnmanaged: destinationState === "unmanaged",
|
|
255
|
+
expectedUnmanagedContent: originalUnmanagedContent,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
catch (error) {
|
|
259
|
+
const message = error instanceof SecretVaultError ? error.message : "Dotenv materialization failed safely.";
|
|
260
|
+
ctx.ui.notify(`Profile stored, but ${target.destination} was not refreshed: ${message}`, "warning");
|
|
261
|
+
return result({
|
|
262
|
+
action: input.action,
|
|
263
|
+
status: "stored",
|
|
264
|
+
profile: input.profile,
|
|
265
|
+
envFile: target.envFile,
|
|
266
|
+
variableNames: captured.variableNames,
|
|
267
|
+
materialized: false,
|
|
268
|
+
code: "materialization_failed",
|
|
269
|
+
message,
|
|
270
|
+
}, `Stored profile ${input.profile}, but its bound dotenv could not be refreshed. Retry secret_store materialize; no values were exposed.`);
|
|
271
|
+
}
|
|
272
|
+
ctx.ui.notify(`Credential profile ${input.profile} stored and activated at ${target.destination}`, "info");
|
|
273
|
+
return result({
|
|
274
|
+
action: input.action,
|
|
275
|
+
status: "stored",
|
|
276
|
+
profile: input.profile,
|
|
277
|
+
envFile: target.envFile,
|
|
278
|
+
variableNames: captured.variableNames,
|
|
279
|
+
materialized: true,
|
|
280
|
+
}, `Stored and activated ${captured.variableNames.length} variables for profile ${input.profile} at its bound workspace dotenv location. Values never entered model context.`);
|
|
281
|
+
}
|
|
282
|
+
catch (error) {
|
|
283
|
+
return failed(input.action, error, input.profile);
|
|
284
|
+
}
|
|
285
|
+
finally {
|
|
286
|
+
document = "";
|
|
287
|
+
originalUnmanagedContent = undefined;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
async function executeMaterialize(vault, input, ctx) {
|
|
291
|
+
try {
|
|
292
|
+
const scope = input.scope ?? "workspace";
|
|
293
|
+
const binding = await vault.resolveBindingForWorkspace(ctx.cwd, input.profile);
|
|
294
|
+
const destination = scope === "managed" ? vault.getManagedEnvPath(binding.profile) : binding.destination;
|
|
295
|
+
const destinationState = await vault.inspectEnvDestination(destination, binding.profile);
|
|
296
|
+
if (destinationState === "unmanaged" || destinationState === "managed-other") {
|
|
297
|
+
return invalid(input.action, "destination_conflict", "The bound dotenv location is no longer safely managed. Use set to review it in the private editor.", binding.profile);
|
|
298
|
+
}
|
|
299
|
+
const materialized = await vault.materializeEnv(binding.profile, destination, {
|
|
300
|
+
activationWorkspace: ctx.cwd,
|
|
301
|
+
managed: scope === "managed",
|
|
302
|
+
});
|
|
303
|
+
ctx.ui.notify(`Credential profile ${binding.profile} activated at ${destination}`, "info");
|
|
304
|
+
return result({
|
|
305
|
+
action: input.action,
|
|
306
|
+
status: "materialized",
|
|
307
|
+
profile: binding.profile,
|
|
308
|
+
variableNames: materialized.variableNames,
|
|
309
|
+
scope,
|
|
310
|
+
envFile: scope === "workspace" ? binding.envFile : undefined,
|
|
311
|
+
materialized: true,
|
|
312
|
+
}, `Activated profile ${binding.profile} for the current workspace. Its dotenv and process environment are available without exposing values to the model.`);
|
|
313
|
+
}
|
|
314
|
+
catch (error) {
|
|
315
|
+
return failed(input.action, error, input.profile);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
async function executeRemove(vault, input, ctx, signal) {
|
|
319
|
+
const target = input.variableNames?.length
|
|
320
|
+
? `${input.variableNames.join(", ")} from profile ${input.profile}`
|
|
321
|
+
: `the entire profile ${input.profile}`;
|
|
322
|
+
const approved = await ctx.ui.confirm("Remove stored secrets", `Remove ${target}? Pi-managed workspace and private dotenv copies are invalidated.`, { signal });
|
|
323
|
+
if (!approved || signal?.aborted)
|
|
324
|
+
return cancelled(input.action, input.profile);
|
|
325
|
+
try {
|
|
326
|
+
const removal = await vault.removeProfile(input.profile, input.variableNames);
|
|
327
|
+
return result({
|
|
328
|
+
action: input.action,
|
|
329
|
+
status: "removed",
|
|
330
|
+
profile: input.profile,
|
|
331
|
+
variableNames: removal.removedVariableNames,
|
|
332
|
+
}, `Removed ${removal.removedVariableNames.length} secret variable${removal.removedVariableNames.length === 1 ? "" : "s"} from profile ${input.profile}.`);
|
|
333
|
+
}
|
|
334
|
+
catch (error) {
|
|
335
|
+
return failed(input.action, error, input.profile);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
export function createSecretStoreToolDefinition(options) {
|
|
339
|
+
const vault = options.vault ?? (options.agentDir ? SecretVault.forAgentDir(options.agentDir) : undefined);
|
|
340
|
+
if (!vault)
|
|
341
|
+
throw new Error("secret_store requires an agentDir or SecretVault");
|
|
342
|
+
return defineTool({
|
|
343
|
+
name: "secret_store",
|
|
344
|
+
label: "Secret Store",
|
|
345
|
+
description: "Open a model-blind native dotenv editor, encrypt owner credentials, bind profiles to workspace dotenv locations, and activate them for normal process use without returning values to the model.",
|
|
346
|
+
promptSnippet: "Manage credentials through the model-blind secret vault. Before credential-dependent work, materialize the current workspace binding; use set to open the owner's private dotenv editor.",
|
|
347
|
+
promptGuidelines: [
|
|
348
|
+
"Use secret_store whenever credentials are needed. Never ask the owner to paste a secret into chat or place a value in tool arguments.",
|
|
349
|
+
"Use set with a profile and relative envFile. The harness opens a private plaintext editor, persists the workspace binding, writes the dotenv, and activates the environment.",
|
|
350
|
+
"Before credential-dependent commands in a later session, call materialize without a profile to resolve the current workspace binding. Use list only when selection or discovery is needed.",
|
|
351
|
+
"After activation, run the consuming application normally. Never read, grep, print, echo, source, or otherwise inspect credential files or environment values.",
|
|
352
|
+
"Treat cancellation as owner intent. Do not immediately repeat the same credential request.",
|
|
353
|
+
],
|
|
354
|
+
parameters: secretStoreSchema,
|
|
355
|
+
executionMode: "sequential",
|
|
356
|
+
renderShell: "self",
|
|
357
|
+
renderCall() {
|
|
358
|
+
return emptyOrchestrationCall();
|
|
359
|
+
},
|
|
360
|
+
renderResult(toolResult, { expanded, isPartial }, theme) {
|
|
361
|
+
if (isPartial) {
|
|
362
|
+
return new OrchestrationPanelComponent(theme, {
|
|
363
|
+
label: "secrets",
|
|
364
|
+
action: "waiting for you",
|
|
365
|
+
status: "running",
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
return new OrchestrationPanelComponent(theme, panelModel(toolResult.details, expanded), expanded);
|
|
369
|
+
},
|
|
370
|
+
async execute(_toolCallId, input, signal, _onUpdate, ctx) {
|
|
371
|
+
if (!ctx.hasUI || ctx.mode !== "tui") {
|
|
372
|
+
return result({
|
|
373
|
+
action: input.action,
|
|
374
|
+
status: "unavailable",
|
|
375
|
+
...(input.profile ? { profile: input.profile } : {}),
|
|
376
|
+
code: "user_tui_required",
|
|
377
|
+
message: "Secret values can be captured only in a user-visible TUI session.",
|
|
378
|
+
}, "secret_store requires a user-visible TUI session.");
|
|
379
|
+
}
|
|
380
|
+
if (signal?.aborted)
|
|
381
|
+
return cancelled(input.action, input.profile);
|
|
382
|
+
const validation = validateInput(input);
|
|
383
|
+
if (validation)
|
|
384
|
+
return validation;
|
|
385
|
+
if (input.action === "lock") {
|
|
386
|
+
vault.lock();
|
|
387
|
+
return result({ action: input.action, status: "locked" }, "Secret vault locked; cached key, credential environment, and exact-value redaction cache were cleared.");
|
|
388
|
+
}
|
|
389
|
+
try {
|
|
390
|
+
const unlockResult = await ensureUnlocked(vault, input.action, ctx, signal, input.profile);
|
|
391
|
+
if (unlockResult)
|
|
392
|
+
return unlockResult;
|
|
393
|
+
if (input.action === "list") {
|
|
394
|
+
const profiles = await vault.listProfiles();
|
|
395
|
+
return result({ action: input.action, status: "listed", profiles }, `Secret vault contains ${profiles.length} profile${profiles.length === 1 ? "" : "s"}. Only names, variable names, and workspace bindings were returned.`);
|
|
396
|
+
}
|
|
397
|
+
if (input.action === "set" && input.profile) {
|
|
398
|
+
return executeSet(vault, { ...input, profile: input.profile }, ctx, signal);
|
|
399
|
+
}
|
|
400
|
+
if (input.action === "materialize")
|
|
401
|
+
return executeMaterialize(vault, input, ctx);
|
|
402
|
+
if (!input.profile)
|
|
403
|
+
return invalid(input.action, "profile_required", "A profile is required.");
|
|
404
|
+
return executeRemove(vault, { ...input, profile: input.profile }, ctx, signal);
|
|
405
|
+
}
|
|
406
|
+
catch (error) {
|
|
407
|
+
return failed(input.action, error, input.profile);
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
//# sourceMappingURL=secret-store.js.map
|