ummaya 0.2.3 → 0.2.5
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/README.md +17 -3
- package/bin/ummaya +10 -1
- package/npm-shrinkwrap.json +253 -2
- package/package.json +5 -1
- package/prompts/manifest.yaml +2 -2
- package/prompts/session_guidance_v1.md +3 -1
- package/prompts/system_v1.md +9 -7
- package/pyproject.toml +26 -7
- package/specs/2803-document-production-hardening/contracts/document-tools.schema.json +1043 -0
- package/src/ummaya/_canonical/__init__.py +2 -0
- package/src/ummaya/context/builder.py +17 -11
- package/src/ummaya/engine/engine.py +30 -113
- package/src/ummaya/engine/query.py +20 -0
- package/src/ummaya/evidence/__init__.py +44 -0
- package/src/ummaya/evidence/__main__.py +7 -0
- package/src/ummaya/evidence/dataset_contract.py +193 -0
- package/src/ummaya/evidence/document_authoring_cases.py +33 -0
- package/src/ummaya/evidence/document_harness.py +313 -0
- package/src/ummaya/evidence/document_viewer_ux.py +391 -0
- package/src/ummaya/evidence/gates.py +70 -0
- package/src/ummaya/evidence/json_types.py +20 -0
- package/src/ummaya/evidence/models.py +145 -0
- package/src/ummaya/evidence/output_payload.py +89 -0
- package/src/ummaya/evidence/payload_documents.py +233 -0
- package/src/ummaya/evidence/route_contracts.py +224 -0
- package/src/ummaya/evidence/route_helpers.py +150 -0
- package/src/ummaya/evidence/runner.py +177 -0
- package/src/ummaya/evidence/source_provenance.py +246 -0
- package/src/ummaya/evidence/source_provenance_redaction.py +176 -0
- package/src/ummaya/evidence/task_registry.py +264 -0
- package/src/ummaya/evidence/tool_layer.py +39 -0
- package/src/ummaya/evidence/tool_layer_models.py +151 -0
- package/src/ummaya/ipc/adapter_manifest_emitter.py +26 -10
- package/src/ummaya/ipc/document_intent_normalization.py +185 -0
- package/src/ummaya/ipc/frame_schema.py +52 -5
- package/src/ummaya/ipc/route_diagnostics.py +73 -0
- package/src/ummaya/ipc/stdio.py +2282 -417
- package/src/ummaya/llm/client.py +234 -59
- package/src/ummaya/llm/config.py +8 -3
- package/src/ummaya/llm/reasoning.py +84 -0
- package/src/ummaya/primitives/__init__.py +6 -2
- package/src/ummaya/primitives/delegation.py +1 -1
- package/src/ummaya/primitives/document.py +28 -0
- package/src/ummaya/settings.py +0 -3
- package/src/ummaya/tools/discovery_bridge.py +34 -2
- package/src/ummaya/tools/documents/__init__.py +297 -0
- package/src/ummaya/tools/documents/adapter_registry.py +487 -0
- package/src/ummaya/tools/documents/archive_container_probe.py +167 -0
- package/src/ummaya/tools/documents/artifact_store.py +454 -0
- package/src/ummaya/tools/documents/authoring.py +283 -0
- package/src/ummaya/tools/documents/baselines.py +114 -0
- package/src/ummaya/tools/documents/capability.py +331 -0
- package/src/ummaya/tools/documents/contracts.py +112 -0
- package/src/ummaya/tools/documents/conversion.py +521 -0
- package/src/ummaya/tools/documents/diff.py +275 -0
- package/src/ummaya/tools/documents/engines.py +163 -0
- package/src/ummaya/tools/documents/evaluation.py +291 -0
- package/src/ummaya/tools/documents/explicit_values.py +108 -0
- package/src/ummaya/tools/documents/fixtures.py +174 -0
- package/src/ummaya/tools/documents/format_completion_audit.py +471 -0
- package/src/ummaya/tools/documents/formats/__init__.py +2 -0
- package/src/ummaya/tools/documents/formats/archive.py +528 -0
- package/src/ummaya/tools/documents/formats/base.py +41 -0
- package/src/ummaya/tools/documents/formats/code_file.py +211 -0
- package/src/ummaya/tools/documents/formats/data_file.py +272 -0
- package/src/ummaya/tools/documents/formats/hwp.py +284 -0
- package/src/ummaya/tools/documents/formats/hwpx.py +1837 -0
- package/src/ummaya/tools/documents/formats/odf.py +435 -0
- package/src/ummaya/tools/documents/formats/ooxml.py +1030 -0
- package/src/ummaya/tools/documents/formats/passive.py +766 -0
- package/src/ummaya/tools/documents/formats/pdf.py +702 -0
- package/src/ummaya/tools/documents/formats/text_web.py +268 -0
- package/src/ummaya/tools/documents/hwp_conversion_probe.py +178 -0
- package/src/ummaya/tools/documents/hwp_direct_candidate.py +141 -0
- package/src/ummaya/tools/documents/inspection.py +289 -0
- package/src/ummaya/tools/documents/intake.py +1079 -0
- package/src/ummaya/tools/documents/legacy_office_promotion_probe.py +366 -0
- package/src/ummaya/tools/documents/models.py +1598 -0
- package/src/ummaya/tools/documents/odf_promotion_probe.py +167 -0
- package/src/ummaya/tools/documents/orchestrator.py +96 -0
- package/src/ummaya/tools/documents/passive_capability_probe.py +251 -0
- package/src/ummaya/tools/documents/patch.py +170 -0
- package/src/ummaya/tools/documents/pdfa_conformance.py +284 -0
- package/src/ummaya/tools/documents/pdfa_promotion_probe.py +198 -0
- package/src/ummaya/tools/documents/permissions.py +110 -0
- package/src/ummaya/tools/documents/planner.py +616 -0
- package/src/ummaya/tools/documents/registry.py +2733 -0
- package/src/ummaya/tools/documents/render.py +978 -0
- package/src/ummaya/tools/documents/render_comparison.py +113 -0
- package/src/ummaya/tools/documents/render_comparison_models.py +74 -0
- package/src/ummaya/tools/documents/render_comparison_regions.py +73 -0
- package/src/ummaya/tools/documents/render_comparison_style.py +161 -0
- package/src/ummaya/tools/documents/reread.py +157 -0
- package/src/ummaya/tools/documents/runtime_authoring.py +244 -0
- package/src/ummaya/tools/documents/runtime_authoring_bundle.py +76 -0
- package/src/ummaya/tools/documents/scorecard.py +184 -0
- package/src/ummaya/tools/documents/socratic_planner.py +193 -0
- package/src/ummaya/tools/documents/style.py +48 -0
- package/src/ummaya/tools/documents/tool_defs.py +523 -0
- package/src/ummaya/tools/documents/validate.py +347 -0
- package/src/ummaya/tools/executor.py +61 -12
- package/src/ummaya/tools/geocoding/kakao_client.py +1 -2
- package/src/ummaya/tools/kma/apihub_catalog.py +984 -1
- package/src/ummaya/tools/kma/apihub_structured_adapter.py +86 -6
- package/src/ummaya/tools/kma/apihub_url_adapter.py +593 -0
- package/src/ummaya/tools/kma/apihub_url_catalog.py +296 -0
- package/src/ummaya/tools/live_proxy.py +0 -3
- package/src/ummaya/tools/location_adapters.py +8 -6
- package/src/ummaya/tools/manifest_metadata.py +16 -3
- package/src/ummaya/tools/models.py +5 -1
- package/src/ummaya/tools/mvp_surface.py +2 -2
- package/src/ummaya/tools/nmc/emergency_search.py +8 -6
- package/src/ummaya/tools/register_all.py +17 -0
- package/src/ummaya/tools/registry.py +10 -1
- package/src/ummaya/tools/resolve_location.py +4 -4
- package/src/ummaya/tools/routing/__init__.py +59 -0
- package/src/ummaya/tools/routing/builder.py +105 -0
- package/src/ummaya/tools/routing/cards.py +29 -0
- package/src/ummaya/tools/routing/decision_service.py +534 -0
- package/src/ummaya/tools/routing/decision_types.py +74 -0
- package/src/ummaya/tools/routing/feasibility.py +122 -0
- package/src/ummaya/tools/routing/intent.py +17 -0
- package/src/ummaya/tools/routing/intent_extractor.py +207 -0
- package/src/ummaya/tools/routing/intent_patterns.py +160 -0
- package/src/ummaya/tools/routing/intent_public_data.py +150 -0
- package/src/ummaya/tools/routing/intent_types.py +48 -0
- package/src/ummaya/tools/routing/lint.py +78 -0
- package/src/ummaya/tools/routing/metadata.py +174 -0
- package/src/ummaya/tools/routing/projection.py +340 -0
- package/src/ummaya/tools/routing/retrieval_policy.py +629 -0
- package/src/ummaya/tools/routing/schema.py +81 -0
- package/src/ummaya/tools/routing/types.py +96 -0
- package/src/ummaya/tools/routing_index.py +2 -2
- package/src/ummaya/tools/search.py +40 -106
- package/src/ummaya/tools/verified_data_go_kr/_manifest.py +115 -25
- package/src/ummaya/tools/verified_data_go_kr/airkorea_air_quality.py +109 -4
- package/src/ummaya/tools/verified_data_go_kr/nmc_aed_site.py +108 -2
- package/src/ummaya/tools/verified_data_go_kr/pps_bid_public_info.py +174 -9
- package/src/ummaya/tools/verified_data_go_kr/tago_bus_arrival.py +66 -3
- package/src/ummaya/tools/verified_data_go_kr/tago_bus_location.py +12 -2
- package/src/ummaya/tools/verified_data_go_kr/tago_bus_route.py +8 -2
- package/src/ummaya/tools/verified_data_go_kr/tago_bus_route_station.py +114 -0
- package/src/ummaya/tools/verified_data_go_kr/tago_bus_station.py +14 -3
- package/src/ummaya/tools/verify_canonical_map.py +21 -0
- package/tests/fixtures/documents/public_forms/baselines.yaml +113 -0
- package/tui/package.json +1 -2
- package/tui/src/.cc-byte-identical-whitelist.yaml +266 -0
- package/tui/src/QueryEngine.ts +12 -4
- package/tui/src/bridge/inboundAttachments.ts +3 -3
- package/tui/src/cli/handlers/auth.ts +4 -13
- package/tui/src/cli/handlers/mcp.tsx +3 -3
- package/tui/src/cli/print.ts +69 -18
- package/tui/src/cli/update.ts +13 -13
- package/tui/src/commands/copy/index.ts +1 -1
- package/tui/src/commands/cost/cost.ts +2 -2
- package/tui/src/commands/init-verifiers.ts +5 -5
- package/tui/src/commands/init.ts +30 -30
- package/tui/src/commands/insights.ts +44 -44
- package/tui/src/commands/install-github-app/install-github-app.tsx +2 -2
- package/tui/src/commands/install-github-app/setupGitHubActions.ts +3 -3
- package/tui/src/commands/install-github-app/types.ts +8 -30
- package/tui/src/commands/install.tsx +5 -5
- package/tui/src/commands/mcp/addCommand.ts +5 -5
- package/tui/src/commands/mcp/xaaIdpCommand.ts +2 -2
- package/tui/src/commands/plugin/ManageMarketplaces.tsx +2 -2
- package/tui/src/commands/plugin/types.ts +6 -28
- package/tui/src/commands/plugin/unifiedTypes.ts +4 -26
- package/tui/src/commands/reasoning/index.ts +13 -0
- package/tui/src/commands/reasoning/reasoning.tsx +177 -0
- package/tui/src/commands/rename/generateSessionName.ts +1 -1
- package/tui/src/commands/thinkback/thinkback.tsx +3 -3
- package/tui/src/commands.ts +2 -0
- package/tui/src/components/Feedback.tsx +1 -1
- package/tui/src/components/LogoV2/EmergencyTip.tsx +11 -2
- package/tui/src/components/LogoV2/WelcomeV2.tsx +1 -3
- package/tui/src/components/Messages.tsx +2 -1
- package/tui/src/components/ScrollKeybindingHandler.tsx +6 -6
- package/tui/src/components/Spinner/types.ts +6 -28
- package/tui/src/components/Spinner.tsx +2 -2
- package/tui/src/components/agents/generateAgent.ts +1 -1
- package/tui/src/components/agents/new-agent-creation/types.ts +4 -26
- package/tui/src/components/config/EnvSecretIsolatedEditor.tsx +1 -1
- package/tui/src/components/design-system/LoadingState.tsx +2 -2
- package/tui/src/components/mcp/types.ts +16 -38
- package/tui/src/components/messages/AssistantToolUseMessage.tsx +3 -2
- package/tui/src/components/messages/UserCrossSessionMessage.ts +16 -4
- package/tui/src/components/messages/UserForkBoilerplateMessage.ts +16 -4
- package/tui/src/components/messages/UserGitHubWebhookMessage.ts +16 -4
- package/tui/src/components/messages/UserToolResultMessage/utils.tsx +3 -2
- package/tui/src/components/permissions/MonitorPermissionRequest/MonitorPermissionRequest.ts +9 -4
- package/tui/src/components/permissions/ReviewArtifactPermissionRequest/ReviewArtifactPermissionRequest.ts +9 -4
- package/tui/src/components/primitive/DocumentSocraticReviewBlock.tsx +129 -0
- package/tui/src/components/primitive/DocumentToolResultCard.tsx +224 -0
- package/tui/src/components/primitive/documentSocraticReview.ts +215 -0
- package/tui/src/components/primitive/index.tsx +43 -1
- package/tui/src/components/primitive/types.ts +137 -0
- package/tui/src/components/ui/option.ts +4 -26
- package/tui/src/constants/common.ts +0 -2
- package/tui/src/constants/prompts.ts +4 -3
- package/tui/src/constants/querySource.ts +4 -26
- package/tui/src/entrypoints/sdk/controlTypes.ts +26 -48
- package/tui/src/entrypoints/sdk/coreTypes.generated.ts +3 -25
- package/tui/src/entrypoints/sdk/runtimeTypes.ts +38 -60
- package/tui/src/entrypoints/sdk/sdkUtilityTypes.ts +4 -26
- package/tui/src/entrypoints/sdk/settingsTypes.generated.ts +3 -25
- package/tui/src/entrypoints/sdk/toolTypes.ts +3 -25
- package/tui/src/hooks/toolPermission/handlers/interactiveHandler.ts +10 -0
- package/tui/src/hooks/useApiKeyVerification.ts +1 -1
- package/tui/src/hooks/useVirtualScroll.ts +1 -1
- package/tui/src/ink/ink.tsx +33 -14
- package/tui/src/ink/reconciler.ts +2 -3
- package/tui/src/ink/render-to-screen.ts +30 -10
- package/tui/src/ipc/bridge.ts +62 -15
- package/tui/src/ipc/bridgeSingleton.ts +5 -1
- package/tui/src/ipc/codec.ts +29 -3
- package/tui/src/ipc/frames.generated.ts +407 -312
- package/tui/src/ipc/llmClient.ts +279 -76
- package/tui/src/ipc/llmTypes.ts +16 -1
- package/tui/src/ipc/schema/frame.schema.json +1 -3475
- package/tui/src/keybindings/defaultBindings.ts +4 -0
- package/tui/src/main.tsx +32 -11
- package/tui/src/native-ts/file-index/index.ts +33 -3
- package/tui/src/observability/surface.ts +2 -2
- package/tui/src/probes/toolRegistryProbe.tsx +3 -1
- package/tui/src/projectOnboardingState.ts +7 -6
- package/tui/src/query/chatMessageTypes.ts +18 -0
- package/tui/src/query/chatMessagesBuilder.ts +1 -1
- package/tui/src/query/deps.ts +1 -1
- package/tui/src/query/messageGuards.ts +106 -0
- package/tui/src/query/publicDataTerminalRepair.ts +384 -0
- package/tui/src/query/run.ts +1075 -0
- package/tui/src/query/supportBoundary.ts +168 -0
- package/tui/src/query/toolResultErrors.ts +103 -0
- package/tui/src/query/toolRunner.ts +687 -0
- package/tui/src/query/unavailableToolRepair.ts +118 -0
- package/tui/src/query.ts +9 -1721
- package/tui/src/screens/REPL.tsx +42 -31
- package/tui/src/services/api/adapterManifest.ts +4 -0
- package/tui/src/services/api/backendChat/events.ts +117 -0
- package/tui/src/services/api/backendChat/finalMessage.ts +40 -0
- package/tui/src/services/api/backendChat/frame.ts +9 -0
- package/tui/src/services/api/backendChat/streaming.ts +430 -0
- package/tui/src/services/api/backendChat/types.ts +62 -0
- package/tui/src/services/api/backendChat.ts +1 -0
- package/tui/src/services/api/client.ts +98 -14
- package/tui/src/services/api/errorUtils.ts +5 -5
- package/tui/src/services/api/errors.ts +1 -1
- package/tui/src/services/api/logging.ts +1 -1
- package/tui/src/services/api/ummaya/evidence.ts +194 -0
- package/tui/src/services/api/ummaya/messages.ts +255 -0
- package/tui/src/services/api/ummaya/nonStreaming.ts +66 -0
- package/tui/src/services/api/ummaya/provider.ts +200 -0
- package/tui/src/services/api/ummaya/reasoning.ts +24 -0
- package/tui/src/services/api/ummaya/request.ts +200 -0
- package/tui/src/services/api/ummaya/selectionContext.ts +240 -0
- package/tui/src/services/api/ummaya/streaming.ts +365 -0
- package/tui/src/services/api/ummaya/streamingPayload.ts +129 -0
- package/tui/src/services/api/ummaya/streamingReader.ts +40 -0
- package/tui/src/services/api/ummaya/toolSelection.ts +217 -0
- package/tui/src/services/api/ummaya/types.ts +110 -0
- package/tui/src/services/api/ummaya/usage.ts +30 -0
- package/tui/src/services/api/ummaya.ts +26 -364
- package/tui/src/services/api/withRetry.ts +1 -1
- package/tui/src/services/awaySummary.ts +2 -2
- package/tui/src/services/claudeAiLimits.ts +1 -1
- package/tui/src/services/compact/autoCompact.ts +1 -1
- package/tui/src/services/compact/compact.ts +1 -1
- package/tui/src/services/lsp/types.ts +8 -30
- package/tui/src/services/tips/types.ts +6 -28
- package/tui/src/services/tokenEstimation.ts +1 -1
- package/tui/src/services/toolRegistry/bootGuard.ts +5 -5
- package/tui/src/services/toolUseSummary/toolUseSummaryGenerator.ts +1 -1
- package/tui/src/services/tools/toolExecution.ts +94 -1
- package/tui/src/skills/bundled/stuck.ts +12 -12
- package/tui/src/state/AppStateStore.ts +7 -0
- package/tui/src/store/pendingPermissionSlot.ts +1 -1
- package/tui/src/store/session-store.ts +10 -36
- package/tui/src/stubs/any-stub.ts +15 -10
- package/tui/src/stubs/color-diff-napi.ts +37 -23
- package/tui/src/stubs/globals.d.ts +3 -3
- package/tui/src/stubs/macro-preload.ts +23 -12
- package/tui/src/tools/AdapterTool/AdapterTool.ts +1239 -163
- package/tui/src/tools/AdapterTool/routeDiagnostics.ts +75 -0
- package/tui/src/tools/AgentTool/AgentTool.tsx +84 -1371
- package/tui/src/tools/AgentTool/agentToolHandoff.ts +114 -0
- package/tui/src/tools/AgentTool/agentToolPartialResult.ts +16 -0
- package/tui/src/tools/AgentTool/agentToolProgress.ts +32 -0
- package/tui/src/tools/AgentTool/agentToolResolver.ts +161 -0
- package/tui/src/tools/AgentTool/agentToolResult.ts +163 -0
- package/tui/src/tools/AgentTool/agentToolUtils.ts +14 -686
- package/tui/src/tools/AgentTool/asyncAgentLifecycle.ts +208 -0
- package/tui/src/tools/AgentTool/asyncLifecycle.ts +153 -0
- package/tui/src/tools/AgentTool/backgroundedCompletion.ts +126 -0
- package/tui/src/tools/AgentTool/backgroundedLifecycle.ts +174 -0
- package/tui/src/tools/AgentTool/foregroundBackground.ts +83 -0
- package/tui/src/tools/AgentTool/foregroundDrain.tsx +133 -0
- package/tui/src/tools/AgentTool/foregroundFinalize.ts +98 -0
- package/tui/src/tools/AgentTool/foregroundLifecycle.tsx +237 -0
- package/tui/src/tools/AgentTool/foregroundProgress.tsx +169 -0
- package/tui/src/tools/AgentTool/foregroundTask.ts +89 -0
- package/tui/src/tools/AgentTool/forkSubagent.ts +1 -12
- package/tui/src/tools/AgentTool/forkSubagentGate.ts +34 -0
- package/tui/src/tools/AgentTool/launchRouting.ts +203 -0
- package/tui/src/tools/AgentTool/lifecycle.ts +244 -0
- package/tui/src/tools/AgentTool/mcpRouting.ts +73 -0
- package/tui/src/tools/AgentTool/orchestrationSupport.ts +70 -0
- package/tui/src/tools/AgentTool/permissions.ts +39 -0
- package/tui/src/tools/AgentTool/promptSetup.ts +181 -0
- package/tui/src/tools/AgentTool/remoteRouting.ts +62 -0
- package/tui/src/tools/AgentTool/resultMapping.ts +116 -0
- package/tui/src/tools/AgentTool/resumeAgent.ts +39 -107
- package/tui/src/tools/AgentTool/resumeAgentHelpers.ts +140 -0
- package/tui/src/tools/AgentTool/runAgent.ts +1 -1
- package/tui/src/tools/AgentTool/runtimeConfig.ts +57 -0
- package/tui/src/tools/AgentTool/schemas.ts +196 -0
- package/tui/src/tools/AgentTool/sourceVerificationPropagation.ts +263 -0
- package/tui/src/tools/AgentTool/worktreeLifecycle.ts +105 -0
- package/tui/src/tools/AskUserQuestionTool/AskUserQuestionTool.tsx +174 -202
- package/tui/src/tools/BashTool/BashTool.tsx +71 -1072
- package/tui/src/tools/BashTool/bashCommandHelpers.ts +12 -12
- package/tui/src/tools/BashTool/bashPermissions/astPreflight.ts +173 -0
- package/tui/src/tools/BashTool/bashPermissions/classifierChecks.ts +199 -0
- package/tui/src/tools/BashTool/bashPermissions/compoundGuards.ts +53 -0
- package/tui/src/tools/BashTool/bashPermissions/constants.ts +99 -0
- package/tui/src/tools/BashTool/bashPermissions/index.ts +38 -0
- package/tui/src/tools/BashTool/bashPermissions/legacyMisparsing.ts +62 -0
- package/tui/src/tools/BashTool/bashPermissions/main.ts +135 -0
- package/tui/src/tools/BashTool/bashPermissions/normalizedCommands.ts +33 -0
- package/tui/src/tools/BashTool/bashPermissions/operatorFlow.ts +98 -0
- package/tui/src/tools/BashTool/bashPermissions/permissionChecks.ts +200 -0
- package/tui/src/tools/BashTool/bashPermissions/prefixSuggestions.ts +88 -0
- package/tui/src/tools/BashTool/bashPermissions/promptClassifierRules.ts +125 -0
- package/tui/src/tools/BashTool/bashPermissions/ruleDelegates.ts +19 -0
- package/tui/src/tools/BashTool/bashPermissions/ruleMatching.ts +145 -0
- package/tui/src/tools/BashTool/bashPermissions/sandboxAutoAllow.ts +75 -0
- package/tui/src/tools/BashTool/bashPermissions/subcommandFlow.ts +205 -0
- package/tui/src/tools/BashTool/bashPermissions/subcommandGuards.ts +73 -0
- package/tui/src/tools/BashTool/bashPermissions/subcommandResultHelpers.ts +116 -0
- package/tui/src/tools/BashTool/bashPermissions/types.ts +26 -0
- package/tui/src/tools/BashTool/bashPermissions/wrapperStripping.ts +139 -0
- package/tui/src/tools/BashTool/bashPermissions.ts +26 -2621
- package/tui/src/tools/BashTool/call.ts +202 -0
- package/tui/src/tools/BashTool/callLoader.ts +35 -0
- package/tui/src/tools/BashTool/commandClassification.ts +151 -0
- package/tui/src/tools/BashTool/commandClassificationLoader.ts +40 -0
- package/tui/src/tools/BashTool/cwdReset.ts +33 -0
- package/tui/src/tools/BashTool/lineTruncation.ts +11 -0
- package/tui/src/tools/BashTool/modeValidation.ts +13 -1
- package/tui/src/tools/BashTool/outputPersistence.ts +42 -0
- package/tui/src/tools/BashTool/permissionClassification.ts +66 -0
- package/tui/src/tools/BashTool/permissionLoader.ts +44 -0
- package/tui/src/tools/BashTool/resultLoader.ts +29 -0
- package/tui/src/tools/BashTool/resultMapping.ts +83 -0
- package/tui/src/tools/BashTool/sandboxPolicy.ts +79 -0
- package/tui/src/tools/BashTool/schemas.ts +65 -0
- package/tui/src/tools/BashTool/sedEditExecution.ts +59 -0
- package/tui/src/tools/BashTool/shellExecution.tsx +245 -0
- package/tui/src/tools/BashTool/shellOutputUtils.ts +85 -0
- package/tui/src/tools/BashTool/shellPermissionGauntlet.ts +97 -0
- package/tui/src/tools/BashTool/uiLoader.ts +37 -0
- package/tui/src/tools/BriefTool/upload.ts +1 -1
- package/tui/src/tools/CalculatorTool/parser.ts +2 -2
- package/tui/src/tools/DocumentPrimitive/DocumentPrimitive.ts +262 -0
- package/tui/src/tools/DocumentPrimitive/dispatchNormalization.ts +270 -0
- package/tui/src/tools/DocumentPrimitive/documentDestinationPath.ts +18 -0
- package/tui/src/tools/DocumentPrimitive/documentMutationGuard.ts +22 -0
- package/tui/src/tools/DocumentPrimitive/documentPatchNormalization.ts +248 -0
- package/tui/src/tools/DocumentPrimitive/documentSourceVerification.ts +245 -0
- package/tui/src/tools/DocumentPrimitive/documentSourceVerificationFields.ts +103 -0
- package/tui/src/tools/DocumentPrimitive/modelVisibleOutput.ts +40 -0
- package/tui/src/tools/DocumentPrimitive/prompt.ts +35 -0
- package/tui/src/tools/FileEditTool/FileEditTool.ts +9 -507
- package/tui/src/tools/FileEditTool/call.ts +228 -0
- package/tui/src/tools/FileEditTool/validateInput.ts +196 -0
- package/tui/src/tools/FileReadTool/imageProcessor.ts +13 -0
- package/tui/src/tools/FileWriteTool/FileWriteTool.ts +7 -300
- package/tui/src/tools/FileWriteTool/call.ts +223 -0
- package/tui/src/tools/FileWriteTool/validateInput.ts +80 -0
- package/tui/src/tools/ListMcpResourcesTool/ListMcpResourcesTool.ts +19 -3
- package/tui/src/tools/LookupPrimitive/LookupPrimitive.ts +48 -29
- package/tui/src/tools/LookupPrimitive/prompt.ts +6 -7
- package/tui/src/tools/MCPTool/trustPolicy.ts +118 -0
- package/tui/src/tools/McpAuthTool/McpAuthTool.ts +21 -3
- package/tui/src/tools/NotebookEditTool/NotebookEditTool.ts +7 -326
- package/tui/src/tools/NotebookEditTool/call.ts +254 -0
- package/tui/src/tools/NotebookEditTool/notebookModel.ts +51 -0
- package/tui/src/tools/NotebookEditTool/validateInput.ts +142 -0
- package/tui/src/tools/PowerShellTool/PowerShellTool.tsx +46 -937
- package/tui/src/tools/PowerShellTool/acceptEditsCommandValidation.ts +162 -0
- package/tui/src/tools/PowerShellTool/call.ts +179 -0
- package/tui/src/tools/PowerShellTool/callLoader.ts +37 -0
- package/tui/src/tools/PowerShellTool/commandClassification.ts +86 -0
- package/tui/src/tools/PowerShellTool/modeValidation.ts +25 -332
- package/tui/src/tools/PowerShellTool/outputPersistence.ts +42 -0
- package/tui/src/tools/PowerShellTool/permissionClassification.ts +28 -0
- package/tui/src/tools/PowerShellTool/resultLoader.ts +31 -0
- package/tui/src/tools/PowerShellTool/resultMapping.ts +75 -0
- package/tui/src/tools/PowerShellTool/schemas.ts +40 -0
- package/tui/src/tools/PowerShellTool/shellExecution.tsx +258 -0
- package/tui/src/tools/PowerShellTool/symlinkModeValidation.ts +44 -0
- package/tui/src/tools/PowerShellTool/uiLoader.ts +37 -0
- package/tui/src/tools/PowerShellTool/validation.ts +39 -0
- package/tui/src/tools/ReadMcpResourceTool/ReadMcpResourceTool.ts +19 -3
- package/tui/src/tools/ResolveLocationPrimitive/ResolveLocationPrimitive.ts +30 -19
- package/tui/src/tools/ResolveLocationPrimitive/prompt.ts +2 -6
- package/tui/src/tools/SkillTool/SkillTool.ts +2 -2
- package/tui/src/tools/SubmitPrimitive/SubmitPrimitive.ts +51 -18
- package/tui/src/tools/TaskCreateTool/TaskCreateTool.ts +16 -2
- package/tui/src/tools/TaskGetTool/TaskGetTool.ts +23 -3
- package/tui/src/tools/TaskListTool/TaskListTool.ts +22 -4
- package/tui/src/tools/TaskOutputTool/TaskOutputTool.tsx +46 -547
- package/tui/src/tools/TaskOutputTool/lookup.ts +216 -0
- package/tui/src/tools/TaskOutputTool/render.tsx +257 -0
- package/tui/src/tools/TaskOutputTool/schemas.ts +55 -0
- package/tui/src/tools/TaskOutputTool/serialization.ts +36 -0
- package/tui/src/tools/TaskStopTool/TaskStopTool.ts +10 -0
- package/tui/src/tools/TaskUpdateTool/TaskUpdateTool.ts +14 -364
- package/tui/src/tools/TaskUpdateTool/completion.ts +62 -0
- package/tui/src/tools/TaskUpdateTool/schemas.ts +62 -0
- package/tui/src/tools/TaskUpdateTool/serialization.ts +46 -0
- package/tui/src/tools/TaskUpdateTool/statusUpdate.ts +247 -0
- package/tui/src/tools/TodoWriteTool/TodoWriteTool.ts +21 -2
- package/tui/src/tools/ToolSearchTool/ToolSearchTool.ts +21 -302
- package/tui/src/tools/ToolSearchTool/ccSupportTools.ts +223 -0
- package/tui/src/tools/ToolSearchTool/descriptionCache.ts +50 -0
- package/tui/src/tools/ToolSearchTool/keywordSearch.ts +216 -0
- package/tui/src/tools/ToolSearchTool/prompt.ts +10 -4
- package/tui/src/tools/ToolSearchTool/resultMapping.ts +30 -0
- package/tui/src/tools/ToolSearchTool/schemas.ts +30 -0
- package/tui/src/tools/ToolSearchTool/searchPool.ts +47 -0
- package/tui/src/tools/ToolSearchTool/supportIntentHints.ts +140 -0
- package/tui/src/tools/TranslateTool/TranslateTool.ts +1 -1
- package/tui/src/tools/VerifyPrimitive/VerifyPrimitive.ts +27 -10
- package/tui/src/tools/WebFetchTool/WebFetchTool.ts +43 -138
- package/tui/src/tools/WebFetchTool/call.ts +227 -0
- package/tui/src/tools/WebFetchTool/resolvedAddressSafety.ts +78 -0
- package/tui/src/tools/WebFetchTool/sourceVerification.ts +204 -0
- package/tui/src/tools/WebFetchTool/types.ts +23 -0
- package/tui/src/tools/WebFetchTool/urlSafety.ts +181 -0
- package/tui/src/tools/WebFetchTool/utils.ts +1 -1
- package/tui/src/tools/WebSearchTool/UI.tsx +0 -1
- package/tui/src/tools/WebSearchTool/WebSearchTool.ts +9 -313
- package/tui/src/tools/WebSearchTool/call.ts +33 -0
- package/tui/src/tools/WebSearchTool/responseMapping.ts +190 -0
- package/tui/src/tools/WebSearchTool/resultBlock.ts +47 -0
- package/tui/src/tools/WebSearchTool/schemas.ts +47 -0
- package/tui/src/tools/WebSearchTool/toolSchema.ts +12 -0
- package/tui/src/tools/WorkspaceToolAdapter/WorkspaceToolAdapter.ts +79 -0
- package/tui/src/tools/WorkspaceToolAdapter/allowedRootPolicy.ts +85 -0
- package/tui/src/tools/WorkspaceToolAdapter/documentFormatGuards.ts +73 -0
- package/tui/src/tools/WorkspaceToolAdapter/inputNormalization.ts +105 -0
- package/tui/src/tools/WorkspaceToolAdapter/mcpExposurePolicy.ts +64 -0
- package/tui/src/tools/WorkspaceToolAdapter/toolDefFactory.ts +215 -0
- package/tui/src/tools/WorkspaceToolAdapter/toolNames.ts +6 -0
- package/tui/src/tools/WorkspaceToolAdapter/workspacePolicy.ts +15 -0
- package/tui/src/tools/_shared/citizenUserText.ts +49 -0
- package/tui/src/tools/_shared/dispatchPrimitive.ts +6 -6
- package/tui/src/tools/_shared/documentChangeToPatch.ts +125 -0
- package/tui/src/tools/_shared/documentDispatchArguments.ts +87 -0
- package/tui/src/tools/_shared/documentPrimitiveTimeout.ts +13 -0
- package/tui/src/tools/_shared/documentToolResultRender.ts +98 -0
- package/tui/src/tools/_shared/locationInputRepair.ts +112 -0
- package/tui/src/tools/_shared/pendingCallRegistry.ts +1 -6
- package/tui/src/tools/_shared/rootPrimitiveInput.ts +68 -0
- package/tui/src/tools/_shared/toolChoiceRepair/documentCompletionPatterns.ts +58 -0
- package/tui/src/tools/_shared/toolChoiceRepair/documentCompletionPrompt.ts +271 -0
- package/tui/src/tools/_shared/toolChoiceRepair/documentRepair.ts +452 -0
- package/tui/src/tools/_shared/toolChoiceRepair/messageAccess.ts +80 -0
- package/tui/src/tools/_shared/toolChoiceRepair/publicDataRepair.ts +92 -0
- package/tui/src/tools/_shared/toolChoiceRepair/supportRepair.ts +135 -0
- package/tui/src/tools/_shared/toolChoiceRepair.ts +61 -0
- package/tui/src/tools/shared/mockDisclaimer.ts +1 -1
- package/tui/src/tools.ts +39 -190
- package/tui/src/types/fileSuggestion.ts +4 -26
- package/tui/src/types/generated/events_mono/claude_code/v1/claude_code_internal_event.ts +186 -148
- package/tui/src/types/generated/events_mono/common/v1/auth.ts +25 -11
- package/tui/src/types/generated/events_mono/growthbook/v1/growthbook_experiment_event.ts +47 -30
- package/tui/src/types/generated/google/protobuf/timestamp.ts +21 -7
- package/tui/src/types/message.ts +80 -102
- package/tui/src/types/messageQueueTypes.ts +6 -28
- package/tui/src/types/notebook.ts +16 -38
- package/tui/src/types/statusLine.ts +4 -26
- package/tui/src/types/tools.ts +24 -46
- package/tui/src/types/utils.ts +6 -28
- package/tui/src/upstreamproxy/relay.ts +7 -3
- package/tui/src/upstreamproxy/upstreamproxy.ts +1 -1
- package/tui/src/utils/assistantMessageFactories.ts +9 -3
- package/tui/src/utils/attachments.ts +1 -1
- package/tui/src/utils/auth.ts +129 -139
- package/tui/src/utils/bash/ast.ts +23 -23
- package/tui/src/utils/bash/bashParser.ts +5 -5
- package/tui/src/utils/billing.ts +1 -1
- package/tui/src/utils/collapseReadSearch.ts +3 -3
- package/tui/src/utils/cronTasks.ts +1 -1
- package/tui/src/utils/execFileNoThrow.ts +1 -1
- package/tui/src/utils/filePersistence/types.ts +16 -38
- package/tui/src/utils/forkedAgent.ts +1 -1
- package/tui/src/utils/gracefulShutdown.ts +4 -4
- package/tui/src/utils/heapDumpService.ts +12 -8
- package/tui/src/utils/hooks/apiQueryHookHelper.ts +1 -1
- package/tui/src/utils/hooks/execPromptHook.ts +1 -1
- package/tui/src/utils/hooks/skillImprovement.ts +1 -1
- package/tui/src/utils/kExaoneReasoning.ts +138 -0
- package/tui/src/utils/mcp/dateTimeParser.ts +1 -1
- package/tui/src/utils/messages.ts +19 -0
- package/tui/src/utils/migrateSessions.ts +3 -3
- package/tui/src/utils/model/model.ts +6 -6
- package/tui/src/utils/multiToolLayout.ts +13 -0
- package/tui/src/utils/permissions/yoloClassifier.ts +1 -1
- package/tui/src/utils/plugins/headlessPluginInstall.ts +1 -1
- package/tui/src/utils/plugins/mcpPluginIntegration.ts +1 -1
- package/tui/src/utils/plugins/mcpbHandler.ts +1 -1
- package/tui/src/utils/plugins/pluginLoader.ts +8 -8
- package/tui/src/utils/processUserInput/processSlashCommand.tsx +2 -2
- package/tui/src/utils/processUserInput/processUserInput.ts +26 -0
- package/tui/src/utils/protectedNamespace.ts +5 -3
- package/tui/src/utils/rawJsonToolCall.ts +242 -0
- package/tui/src/utils/ripgrep.ts +16 -7
- package/tui/src/utils/sessionTitle.ts +1 -1
- package/tui/src/utils/settings/applySettingsChange.ts +4 -0
- package/tui/src/utils/settings/permissionValidation.ts +14 -2
- package/tui/src/utils/settings/types.ts +9 -3
- package/tui/src/utils/shell/prefix.ts +1 -1
- package/tui/src/utils/sideQuery.ts +1 -1
- package/tui/src/utils/stats.ts +1 -1
- package/tui/src/utils/systemThemeWatcher.ts +13 -3
- package/tui/src/utils/teleport.tsx +1 -1
- package/uv.lock +394 -22
- package/assets/copilot-gate-logo.svg +0 -58
- package/assets/govon-logo.svg +0 -40
- package/src/ummaya/eval/__init__.py +0 -5
- package/src/ummaya/eval/retrieval.py +0 -713
- package/tui/src/services/api/claude.ts +0 -3510
- package/tui/src/utils/messageStream.ts +0 -186
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { feature } from 'bun:bundle'
|
|
2
|
+
import type { ToolUseContext } from '../../../Tool.js'
|
|
3
|
+
import { createPermissionRequestMessage } from '../../../utils/permissions/permissions.js'
|
|
4
|
+
import { bashCommandIsSafeAsync_DEPRECATED, stripSafeHeredocSubstitutions } from '../bashSecurity.js'
|
|
5
|
+
import type { BashToolInput } from '../schemas.js'
|
|
6
|
+
import { BASH_TOOL_NAME } from '../toolName.js'
|
|
7
|
+
import { buildPendingClassifierCheck } from './classifierChecks.js'
|
|
8
|
+
import { bashToolCheckExactMatchPermission } from './permissionChecks.js'
|
|
9
|
+
|
|
10
|
+
const bashCommandIsSafeAsync = bashCommandIsSafeAsync_DEPRECATED
|
|
11
|
+
|
|
12
|
+
export async function checkLegacyMisparsing(
|
|
13
|
+
input: BashToolInput,
|
|
14
|
+
context: ToolUseContext,
|
|
15
|
+
) {
|
|
16
|
+
const originalCommandSafetyResult = await bashCommandIsSafeAsync(input.command)
|
|
17
|
+
if (
|
|
18
|
+
originalCommandSafetyResult.behavior !== 'ask' ||
|
|
19
|
+
!originalCommandSafetyResult.isBashSecurityCheckForMisparsing
|
|
20
|
+
) {
|
|
21
|
+
return null
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const remainder = stripSafeHeredocSubstitutions(input.command)
|
|
25
|
+
const remainderResult =
|
|
26
|
+
remainder !== null ? await bashCommandIsSafeAsync(remainder) : null
|
|
27
|
+
if (
|
|
28
|
+
remainder !== null &&
|
|
29
|
+
!(
|
|
30
|
+
remainderResult?.behavior === 'ask' &&
|
|
31
|
+
remainderResult.isBashSecurityCheckForMisparsing
|
|
32
|
+
)
|
|
33
|
+
) {
|
|
34
|
+
return null
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const appState = context.getAppState()
|
|
38
|
+
const exactMatchResult = bashToolCheckExactMatchPermission(
|
|
39
|
+
input,
|
|
40
|
+
appState.toolPermissionContext,
|
|
41
|
+
)
|
|
42
|
+
if (exactMatchResult.behavior === 'allow') return exactMatchResult
|
|
43
|
+
|
|
44
|
+
const decisionReason = {
|
|
45
|
+
type: 'other' as const,
|
|
46
|
+
reason: originalCommandSafetyResult.message,
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
behavior: 'ask' as const,
|
|
50
|
+
message: createPermissionRequestMessage(BASH_TOOL_NAME, decisionReason),
|
|
51
|
+
decisionReason,
|
|
52
|
+
suggestions: [],
|
|
53
|
+
...(feature('BASH_CLASSIFIER')
|
|
54
|
+
? {
|
|
55
|
+
pendingClassifierCheck: buildPendingClassifierCheck(
|
|
56
|
+
input.command,
|
|
57
|
+
appState.toolPermissionContext,
|
|
58
|
+
),
|
|
59
|
+
}
|
|
60
|
+
: {}),
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { ToolUseContext } from '../../../Tool.js'
|
|
2
|
+
import {
|
|
3
|
+
getCommandSubcommandPrefix,
|
|
4
|
+
splitCommand_DEPRECATED,
|
|
5
|
+
} from '../../../utils/bash/commands.js'
|
|
6
|
+
import { getCwd } from '../../../utils/cwd.js'
|
|
7
|
+
import { logForDebugging } from '../../../utils/debug.js'
|
|
8
|
+
import { isEnvTruthy } from '../../../utils/envUtils.js'
|
|
9
|
+
import { createPermissionRequestMessage } from '../../../utils/permissions/permissions.js'
|
|
10
|
+
import { getPlatform } from '../../../utils/platform.js'
|
|
11
|
+
import { SandboxManager } from '../../../utils/sandbox/sandbox-adapter.js'
|
|
12
|
+
import { windowsPathToPosixPath } from '../../../utils/windowsPaths.js'
|
|
13
|
+
import type { BashToolInput } from '../schemas.js'
|
|
14
|
+
import { shouldUseSandbox } from '../shouldUseSandbox.js'
|
|
15
|
+
import { BASH_TOOL_NAME } from '../toolName.js'
|
|
16
|
+
import { prepareAstPermissionState } from './astPreflight.js'
|
|
17
|
+
import { checkSubcommandDirectoryGuards } from './compoundGuards.js'
|
|
18
|
+
import { MAX_SUBCOMMANDS_FOR_SECURITY_CHECK } from './constants.js'
|
|
19
|
+
import { checkLegacyMisparsing } from './legacyMisparsing.js'
|
|
20
|
+
import { resolveCommandOperatorPermission } from './operatorFlow.js'
|
|
21
|
+
import { bashToolCheckExactMatchPermission } from './permissionChecks.js'
|
|
22
|
+
import { checkPromptClassifierRules } from './promptClassifierRules.js'
|
|
23
|
+
import { checkSandboxAutoAllow } from './sandboxAutoAllow.js'
|
|
24
|
+
import { resolveSubcommandPermissionFlow } from './subcommandFlow.js'
|
|
25
|
+
import { filterCdCwdSubcommands } from './subcommandGuards.js'
|
|
26
|
+
|
|
27
|
+
const splitCommand = splitCommand_DEPRECATED
|
|
28
|
+
|
|
29
|
+
export async function bashToolHasPermission(
|
|
30
|
+
input: BashToolInput,
|
|
31
|
+
context: ToolUseContext,
|
|
32
|
+
getCommandSubcommandPrefixFn = getCommandSubcommandPrefix,
|
|
33
|
+
) {
|
|
34
|
+
let appState = context.getAppState()
|
|
35
|
+
const astPreflight = await prepareAstPermissionState(
|
|
36
|
+
input,
|
|
37
|
+
appState.toolPermissionContext,
|
|
38
|
+
)
|
|
39
|
+
if (astPreflight.kind === 'return') return astPreflight.result
|
|
40
|
+
const astState = astPreflight.state
|
|
41
|
+
|
|
42
|
+
if (
|
|
43
|
+
SandboxManager.isSandboxingEnabled() &&
|
|
44
|
+
SandboxManager.isAutoAllowBashIfSandboxedEnabled() &&
|
|
45
|
+
shouldUseSandbox(input)
|
|
46
|
+
) {
|
|
47
|
+
const sandboxAutoAllowResult = checkSandboxAutoAllow(
|
|
48
|
+
input,
|
|
49
|
+
appState.toolPermissionContext,
|
|
50
|
+
)
|
|
51
|
+
if (sandboxAutoAllowResult.behavior !== 'passthrough') {
|
|
52
|
+
return sandboxAutoAllowResult
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const exactMatchResult = bashToolCheckExactMatchPermission(
|
|
57
|
+
input,
|
|
58
|
+
appState.toolPermissionContext,
|
|
59
|
+
)
|
|
60
|
+
if (exactMatchResult.behavior === 'deny') return exactMatchResult
|
|
61
|
+
|
|
62
|
+
const promptClassifierResult = await checkPromptClassifierRules(
|
|
63
|
+
input,
|
|
64
|
+
context,
|
|
65
|
+
getCommandSubcommandPrefixFn,
|
|
66
|
+
)
|
|
67
|
+
if (promptClassifierResult !== null) return promptClassifierResult
|
|
68
|
+
|
|
69
|
+
const operatorResult = await resolveCommandOperatorPermission(
|
|
70
|
+
input,
|
|
71
|
+
context,
|
|
72
|
+
astState,
|
|
73
|
+
getCommandSubcommandPrefixFn,
|
|
74
|
+
bashToolHasPermission,
|
|
75
|
+
)
|
|
76
|
+
if (operatorResult !== null) return operatorResult
|
|
77
|
+
|
|
78
|
+
if (
|
|
79
|
+
astState.astSubcommands === null &&
|
|
80
|
+
!isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_COMMAND_INJECTION_CHECK)
|
|
81
|
+
) {
|
|
82
|
+
const legacyMisparsingResult = await checkLegacyMisparsing(input, context)
|
|
83
|
+
if (legacyMisparsingResult !== null) return legacyMisparsingResult
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const cwd = getCwd()
|
|
87
|
+
const cwdMingw =
|
|
88
|
+
getPlatform() === 'windows' ? windowsPathToPosixPath(cwd) : cwd
|
|
89
|
+
const rawSubcommands =
|
|
90
|
+
astState.astSubcommands ??
|
|
91
|
+
astState.shadowLegacySubs ??
|
|
92
|
+
splitCommand(input.command)
|
|
93
|
+
const { subcommands, astCommandsByIdx } = filterCdCwdSubcommands(
|
|
94
|
+
rawSubcommands,
|
|
95
|
+
astState.astCommands,
|
|
96
|
+
cwd,
|
|
97
|
+
cwdMingw,
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
if (
|
|
101
|
+
astState.astSubcommands === null &&
|
|
102
|
+
subcommands.length > MAX_SUBCOMMANDS_FOR_SECURITY_CHECK
|
|
103
|
+
) {
|
|
104
|
+
logForDebugging(
|
|
105
|
+
`bashPermissions: ${subcommands.length} subcommands exceeds cap (${MAX_SUBCOMMANDS_FOR_SECURITY_CHECK}) — returning ask`,
|
|
106
|
+
{ level: 'debug' },
|
|
107
|
+
)
|
|
108
|
+
const decisionReason = {
|
|
109
|
+
type: 'other' as const,
|
|
110
|
+
reason: `Command splits into ${subcommands.length} subcommands, too many to safety-check individually`,
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
behavior: 'ask' as const,
|
|
114
|
+
message: createPermissionRequestMessage(BASH_TOOL_NAME, decisionReason),
|
|
115
|
+
decisionReason,
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const directoryGuard = checkSubcommandDirectoryGuards(input, subcommands)
|
|
120
|
+
if (directoryGuard.result !== null) return directoryGuard.result
|
|
121
|
+
|
|
122
|
+
appState = context.getAppState()
|
|
123
|
+
return resolveSubcommandPermissionFlow({
|
|
124
|
+
input,
|
|
125
|
+
context,
|
|
126
|
+
exactMatchResult,
|
|
127
|
+
subcommands,
|
|
128
|
+
astCommandsByIdx,
|
|
129
|
+
astRedirects: astState.astRedirects,
|
|
130
|
+
astCommands: astState.astCommands,
|
|
131
|
+
astSubcommands: astState.astSubcommands,
|
|
132
|
+
compoundCommandHasCd: directoryGuard.compoundCommandHasCd,
|
|
133
|
+
getCommandSubcommandPrefixFn,
|
|
134
|
+
})
|
|
135
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { splitCommand_DEPRECATED } from '../../../utils/bash/commands.js'
|
|
2
|
+
import { tryParseShellCommand } from '../../../utils/bash/shellQuote.js'
|
|
3
|
+
import { stripSafeWrappers } from './wrapperStripping.js'
|
|
4
|
+
|
|
5
|
+
const splitCommand = splitCommand_DEPRECATED
|
|
6
|
+
|
|
7
|
+
export function isNormalizedGitCommand(command: string): boolean {
|
|
8
|
+
if (command.startsWith('git ') || command === 'git') return true
|
|
9
|
+
const stripped = stripSafeWrappers(command)
|
|
10
|
+
const parsed = tryParseShellCommand(stripped)
|
|
11
|
+
if (parsed.success && parsed.tokens.length > 0) {
|
|
12
|
+
if (parsed.tokens[0] === 'git') return true
|
|
13
|
+
if (parsed.tokens[0] === 'xargs' && parsed.tokens.includes('git')) {
|
|
14
|
+
return true
|
|
15
|
+
}
|
|
16
|
+
return false
|
|
17
|
+
}
|
|
18
|
+
return /^git(?:\s|$)/.test(stripped)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function isNormalizedCdCommand(command: string): boolean {
|
|
22
|
+
const stripped = stripSafeWrappers(command)
|
|
23
|
+
const parsed = tryParseShellCommand(stripped)
|
|
24
|
+
if (parsed.success && parsed.tokens.length > 0) {
|
|
25
|
+
const cmd = parsed.tokens[0]
|
|
26
|
+
return cmd === 'cd' || cmd === 'pushd' || cmd === 'popd'
|
|
27
|
+
}
|
|
28
|
+
return /^(?:cd|pushd|popd)(?:\s|$)/.test(stripped)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function commandHasAnyCd(command: string): boolean {
|
|
32
|
+
return splitCommand(command).some(subcmd => isNormalizedCdCommand(subcmd.trim()))
|
|
33
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { feature } from 'bun:bundle'
|
|
2
|
+
import type { ToolUseContext } from '../../../Tool.js'
|
|
3
|
+
import { getCwd } from '../../../utils/cwd.js'
|
|
4
|
+
import { createPermissionRequestMessage } from '../../../utils/permissions/permissions.js'
|
|
5
|
+
import { checkCommandOperatorPermissions } from '../bashCommandHelpers.js'
|
|
6
|
+
import { bashCommandIsSafeAsync_DEPRECATED } from '../bashSecurity.js'
|
|
7
|
+
import { checkPathConstraints } from '../pathValidation.js'
|
|
8
|
+
import type { BashToolInput } from '../schemas.js'
|
|
9
|
+
import { BASH_TOOL_NAME } from '../toolName.js'
|
|
10
|
+
import { buildPendingClassifierCheck } from './classifierChecks.js'
|
|
11
|
+
import {
|
|
12
|
+
commandHasAnyCd,
|
|
13
|
+
isNormalizedCdCommand,
|
|
14
|
+
isNormalizedGitCommand,
|
|
15
|
+
} from './normalizedCommands.js'
|
|
16
|
+
import type {
|
|
17
|
+
BashAstPermissionState,
|
|
18
|
+
CommandPrefixResolver,
|
|
19
|
+
PermissionRunner,
|
|
20
|
+
} from './types.js'
|
|
21
|
+
|
|
22
|
+
const bashCommandIsSafeAsync = bashCommandIsSafeAsync_DEPRECATED
|
|
23
|
+
|
|
24
|
+
export async function resolveCommandOperatorPermission(
|
|
25
|
+
input: BashToolInput,
|
|
26
|
+
context: ToolUseContext,
|
|
27
|
+
astState: BashAstPermissionState,
|
|
28
|
+
getCommandSubcommandPrefixFn: CommandPrefixResolver,
|
|
29
|
+
runPermissionCheck: PermissionRunner,
|
|
30
|
+
) {
|
|
31
|
+
const commandOperatorResult = await checkCommandOperatorPermissions(
|
|
32
|
+
input,
|
|
33
|
+
(i: BashToolInput) =>
|
|
34
|
+
runPermissionCheck(i, context, getCommandSubcommandPrefixFn),
|
|
35
|
+
{ isNormalizedCdCommand, isNormalizedGitCommand },
|
|
36
|
+
astState.astRoot,
|
|
37
|
+
)
|
|
38
|
+
if (commandOperatorResult.behavior === 'passthrough') return null
|
|
39
|
+
|
|
40
|
+
if (commandOperatorResult.behavior === 'allow') {
|
|
41
|
+
const safetyResult =
|
|
42
|
+
astState.astSubcommands === null
|
|
43
|
+
? await bashCommandIsSafeAsync(input.command)
|
|
44
|
+
: null
|
|
45
|
+
if (
|
|
46
|
+
safetyResult !== null &&
|
|
47
|
+
safetyResult.behavior !== 'passthrough' &&
|
|
48
|
+
safetyResult.behavior !== 'allow'
|
|
49
|
+
) {
|
|
50
|
+
const appState = context.getAppState()
|
|
51
|
+
const reason =
|
|
52
|
+
safetyResult.message ?? 'Command contains patterns that require approval'
|
|
53
|
+
return {
|
|
54
|
+
behavior: 'ask' as const,
|
|
55
|
+
message: createPermissionRequestMessage(BASH_TOOL_NAME, {
|
|
56
|
+
type: 'other',
|
|
57
|
+
reason,
|
|
58
|
+
}),
|
|
59
|
+
decisionReason: { type: 'other' as const, reason },
|
|
60
|
+
...(feature('BASH_CLASSIFIER')
|
|
61
|
+
? {
|
|
62
|
+
pendingClassifierCheck: buildPendingClassifierCheck(
|
|
63
|
+
input.command,
|
|
64
|
+
appState.toolPermissionContext,
|
|
65
|
+
),
|
|
66
|
+
}
|
|
67
|
+
: {}),
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const appState = context.getAppState()
|
|
72
|
+
const pathResult = checkPathConstraints(
|
|
73
|
+
input,
|
|
74
|
+
getCwd(),
|
|
75
|
+
appState.toolPermissionContext,
|
|
76
|
+
commandHasAnyCd(input.command),
|
|
77
|
+
astState.astRedirects,
|
|
78
|
+
astState.astCommands,
|
|
79
|
+
)
|
|
80
|
+
if (pathResult.behavior !== 'passthrough') return pathResult
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (commandOperatorResult.behavior === 'ask') {
|
|
84
|
+
const appState = context.getAppState()
|
|
85
|
+
return {
|
|
86
|
+
...commandOperatorResult,
|
|
87
|
+
...(feature('BASH_CLASSIFIER')
|
|
88
|
+
? {
|
|
89
|
+
pendingClassifierCheck: buildPendingClassifierCheck(
|
|
90
|
+
input.command,
|
|
91
|
+
appState.toolPermissionContext,
|
|
92
|
+
),
|
|
93
|
+
}
|
|
94
|
+
: {}),
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return commandOperatorResult
|
|
98
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import type { ToolPermissionContext } from '../../../Tool.js'
|
|
2
|
+
import type { CommandPrefixResult } from '../../../utils/bash/commands.js'
|
|
3
|
+
import type { SimpleCommand } from '../../../utils/bash/ast.js'
|
|
4
|
+
import { getCwd } from '../../../utils/cwd.js'
|
|
5
|
+
import { isEnvTruthy } from '../../../utils/envUtils.js'
|
|
6
|
+
import type {
|
|
7
|
+
PermissionDecisionReason,
|
|
8
|
+
PermissionResult,
|
|
9
|
+
} from '../../../utils/permissions/PermissionResult.js'
|
|
10
|
+
import { createPermissionRequestMessage } from '../../../utils/permissions/permissions.js'
|
|
11
|
+
import type { BashToolInput } from '../schemas.js'
|
|
12
|
+
import { bashCommandIsSafeAsync_DEPRECATED } from '../bashSecurity.js'
|
|
13
|
+
import { checkPermissionMode } from '../modeValidation.js'
|
|
14
|
+
import { checkPathConstraints } from '../pathValidation.js'
|
|
15
|
+
import { checkReadOnlyConstraints } from '../readOnlyValidation.js'
|
|
16
|
+
import { checkSedConstraints } from '../sedValidation.js'
|
|
17
|
+
import { BASH_TOOL_NAME } from '../toolName.js'
|
|
18
|
+
import { commandHasAnyCd } from './normalizedCommands.js'
|
|
19
|
+
import {
|
|
20
|
+
suggestionForExactCommand,
|
|
21
|
+
suggestionForPrefix,
|
|
22
|
+
} from './prefixSuggestions.js'
|
|
23
|
+
import { matchingRulesForInput } from './ruleMatching.js'
|
|
24
|
+
|
|
25
|
+
const bashCommandIsSafeAsync = bashCommandIsSafeAsync_DEPRECATED
|
|
26
|
+
|
|
27
|
+
export const bashToolCheckExactMatchPermission = (
|
|
28
|
+
input: BashToolInput,
|
|
29
|
+
toolPermissionContext: ToolPermissionContext,
|
|
30
|
+
): PermissionResult => {
|
|
31
|
+
const command = input.command.trim()
|
|
32
|
+
const { matchingDenyRules, matchingAskRules, matchingAllowRules } =
|
|
33
|
+
matchingRulesForInput(input, toolPermissionContext, 'exact')
|
|
34
|
+
|
|
35
|
+
if (matchingDenyRules[0] !== undefined) {
|
|
36
|
+
return {
|
|
37
|
+
behavior: 'deny',
|
|
38
|
+
message: `Permission to use ${BASH_TOOL_NAME} with command ${command} has been denied.`,
|
|
39
|
+
decisionReason: { type: 'rule', rule: matchingDenyRules[0] },
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (matchingAskRules[0] !== undefined) {
|
|
43
|
+
return {
|
|
44
|
+
behavior: 'ask',
|
|
45
|
+
message: createPermissionRequestMessage(BASH_TOOL_NAME),
|
|
46
|
+
decisionReason: { type: 'rule', rule: matchingAskRules[0] },
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (matchingAllowRules[0] !== undefined) {
|
|
50
|
+
return {
|
|
51
|
+
behavior: 'allow',
|
|
52
|
+
updatedInput: input,
|
|
53
|
+
decisionReason: { type: 'rule', rule: matchingAllowRules[0] },
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const decisionReason = {
|
|
58
|
+
type: 'other' as const,
|
|
59
|
+
reason: 'This command requires approval',
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
behavior: 'passthrough',
|
|
63
|
+
message: createPermissionRequestMessage(BASH_TOOL_NAME, decisionReason),
|
|
64
|
+
decisionReason,
|
|
65
|
+
suggestions: suggestionForExactCommand(command),
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const bashToolCheckPermission = (
|
|
70
|
+
input: BashToolInput,
|
|
71
|
+
toolPermissionContext: ToolPermissionContext,
|
|
72
|
+
compoundCommandHasCd?: boolean,
|
|
73
|
+
astCommand?: SimpleCommand,
|
|
74
|
+
): PermissionResult => {
|
|
75
|
+
const command = input.command.trim()
|
|
76
|
+
const exactMatchResult = bashToolCheckExactMatchPermission(
|
|
77
|
+
input,
|
|
78
|
+
toolPermissionContext,
|
|
79
|
+
)
|
|
80
|
+
if (
|
|
81
|
+
exactMatchResult.behavior === 'deny' ||
|
|
82
|
+
exactMatchResult.behavior === 'ask'
|
|
83
|
+
) {
|
|
84
|
+
return exactMatchResult
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const { matchingDenyRules, matchingAskRules, matchingAllowRules } =
|
|
88
|
+
matchingRulesForInput(input, toolPermissionContext, 'prefix', {
|
|
89
|
+
skipCompoundCheck: astCommand !== undefined,
|
|
90
|
+
})
|
|
91
|
+
if (matchingDenyRules[0] !== undefined) {
|
|
92
|
+
return {
|
|
93
|
+
behavior: 'deny',
|
|
94
|
+
message: `Permission to use ${BASH_TOOL_NAME} with command ${command} has been denied.`,
|
|
95
|
+
decisionReason: { type: 'rule', rule: matchingDenyRules[0] },
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (matchingAskRules[0] !== undefined) {
|
|
99
|
+
return {
|
|
100
|
+
behavior: 'ask',
|
|
101
|
+
message: createPermissionRequestMessage(BASH_TOOL_NAME),
|
|
102
|
+
decisionReason: { type: 'rule', rule: matchingAskRules[0] },
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const pathResult = checkPathConstraints(
|
|
107
|
+
input,
|
|
108
|
+
getCwd(),
|
|
109
|
+
toolPermissionContext,
|
|
110
|
+
compoundCommandHasCd,
|
|
111
|
+
astCommand?.redirects,
|
|
112
|
+
astCommand ? [astCommand] : undefined,
|
|
113
|
+
)
|
|
114
|
+
if (pathResult.behavior !== 'passthrough') return pathResult
|
|
115
|
+
if (exactMatchResult.behavior === 'allow') return exactMatchResult
|
|
116
|
+
if (matchingAllowRules[0] !== undefined) {
|
|
117
|
+
return {
|
|
118
|
+
behavior: 'allow',
|
|
119
|
+
updatedInput: input,
|
|
120
|
+
decisionReason: { type: 'rule', rule: matchingAllowRules[0] },
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const sedConstraintResult = checkSedConstraints(input, toolPermissionContext)
|
|
125
|
+
if (sedConstraintResult.behavior !== 'passthrough') return sedConstraintResult
|
|
126
|
+
const modeResult = checkPermissionMode(input, toolPermissionContext)
|
|
127
|
+
if (modeResult.behavior !== 'passthrough') return modeResult
|
|
128
|
+
if (checkReadOnlyConstraints(input, commandHasAnyCd(input.command)).behavior === 'allow') {
|
|
129
|
+
return {
|
|
130
|
+
behavior: 'allow',
|
|
131
|
+
updatedInput: input,
|
|
132
|
+
decisionReason: { type: 'other', reason: 'Read-only command is allowed' },
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const decisionReason = {
|
|
137
|
+
type: 'other' as const,
|
|
138
|
+
reason: 'This command requires approval',
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
behavior: 'passthrough',
|
|
142
|
+
message: createPermissionRequestMessage(BASH_TOOL_NAME, decisionReason),
|
|
143
|
+
decisionReason,
|
|
144
|
+
suggestions: suggestionForExactCommand(command),
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export async function checkCommandAndSuggestRules(
|
|
149
|
+
input: BashToolInput,
|
|
150
|
+
toolPermissionContext: ToolPermissionContext,
|
|
151
|
+
commandPrefixResult: CommandPrefixResult | null | undefined,
|
|
152
|
+
compoundCommandHasCd?: boolean,
|
|
153
|
+
astParseSucceeded?: boolean,
|
|
154
|
+
): Promise<PermissionResult> {
|
|
155
|
+
const exactMatchResult = bashToolCheckExactMatchPermission(
|
|
156
|
+
input,
|
|
157
|
+
toolPermissionContext,
|
|
158
|
+
)
|
|
159
|
+
if (exactMatchResult.behavior !== 'passthrough') return exactMatchResult
|
|
160
|
+
|
|
161
|
+
const permissionResult = bashToolCheckPermission(
|
|
162
|
+
input,
|
|
163
|
+
toolPermissionContext,
|
|
164
|
+
compoundCommandHasCd,
|
|
165
|
+
)
|
|
166
|
+
if (
|
|
167
|
+
permissionResult.behavior === 'deny' ||
|
|
168
|
+
permissionResult.behavior === 'ask'
|
|
169
|
+
) {
|
|
170
|
+
return permissionResult
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (
|
|
174
|
+
!astParseSucceeded &&
|
|
175
|
+
!isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_COMMAND_INJECTION_CHECK)
|
|
176
|
+
) {
|
|
177
|
+
const safetyResult = await bashCommandIsSafeAsync(input.command)
|
|
178
|
+
if (safetyResult.behavior !== 'passthrough') {
|
|
179
|
+
const decisionReason: PermissionDecisionReason = {
|
|
180
|
+
type: 'other',
|
|
181
|
+
reason:
|
|
182
|
+
safetyResult.behavior === 'ask' && safetyResult.message
|
|
183
|
+
? safetyResult.message
|
|
184
|
+
: 'This command contains patterns that could pose security risks and requires approval',
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
behavior: 'ask',
|
|
188
|
+
message: createPermissionRequestMessage(BASH_TOOL_NAME, decisionReason),
|
|
189
|
+
decisionReason,
|
|
190
|
+
suggestions: [],
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (permissionResult.behavior === 'allow') return permissionResult
|
|
196
|
+
const suggestedUpdates = commandPrefixResult?.commandPrefix
|
|
197
|
+
? suggestionForPrefix(commandPrefixResult.commandPrefix)
|
|
198
|
+
: suggestionForExactCommand(input.command)
|
|
199
|
+
return { ...permissionResult, suggestions: suggestedUpdates }
|
|
200
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { PermissionUpdate } from '../../../utils/permissions/PermissionUpdateSchema.js'
|
|
2
|
+
import {
|
|
3
|
+
suggestionForExactCommand as sharedSuggestionForExactCommand,
|
|
4
|
+
suggestionForPrefix as sharedSuggestionForPrefix,
|
|
5
|
+
} from '../../../utils/permissions/shellRuleMatching.js'
|
|
6
|
+
import { BASH_TOOL_NAME } from '../toolName.js'
|
|
7
|
+
import {
|
|
8
|
+
ANT_ONLY_SAFE_ENV_VARS,
|
|
9
|
+
BARE_SHELL_PREFIXES,
|
|
10
|
+
ENV_VAR_ASSIGN_RE,
|
|
11
|
+
SAFE_ENV_VARS,
|
|
12
|
+
} from './constants.js'
|
|
13
|
+
|
|
14
|
+
function safeEnvPrefixEnd(tokens: readonly string[]): number | null {
|
|
15
|
+
let i = 0
|
|
16
|
+
while (i < tokens.length) {
|
|
17
|
+
const token = tokens[i]
|
|
18
|
+
if (token === undefined || !ENV_VAR_ASSIGN_RE.test(token)) break
|
|
19
|
+
const varName = token.split('=')[0]
|
|
20
|
+
if (varName === undefined) return null
|
|
21
|
+
const isAntOnlySafe =
|
|
22
|
+
process.env.USER_TYPE === 'ant' && ANT_ONLY_SAFE_ENV_VARS.has(varName)
|
|
23
|
+
if (!SAFE_ENV_VARS.has(varName) && !isAntOnlySafe) return null
|
|
24
|
+
i++
|
|
25
|
+
}
|
|
26
|
+
return i
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function getSimpleCommandPrefix(command: string): string | null {
|
|
30
|
+
const tokens = command.trim().split(/\s+/).filter(Boolean)
|
|
31
|
+
if (tokens.length === 0) return null
|
|
32
|
+
|
|
33
|
+
const prefixEnd = safeEnvPrefixEnd(tokens)
|
|
34
|
+
if (prefixEnd === null) return null
|
|
35
|
+
const remaining = tokens.slice(prefixEnd)
|
|
36
|
+
if (remaining.length < 2) return null
|
|
37
|
+
const subcmd = remaining[1]
|
|
38
|
+
if (subcmd === undefined) return null
|
|
39
|
+
if (!/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/.test(subcmd)) return null
|
|
40
|
+
return remaining.slice(0, 2).join(' ')
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function getFirstWordPrefix(command: string): string | null {
|
|
44
|
+
const tokens = command.trim().split(/\s+/).filter(Boolean)
|
|
45
|
+
const prefixEnd = safeEnvPrefixEnd(tokens)
|
|
46
|
+
if (prefixEnd === null) return null
|
|
47
|
+
const cmd = tokens[prefixEnd]
|
|
48
|
+
if (!cmd) return null
|
|
49
|
+
if (!/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/.test(cmd)) return null
|
|
50
|
+
if (BARE_SHELL_PREFIXES.has(cmd)) return null
|
|
51
|
+
return cmd
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function suggestionForExactCommand(command: string): PermissionUpdate[] {
|
|
55
|
+
const heredocPrefix = extractPrefixBeforeHeredoc(command)
|
|
56
|
+
if (heredocPrefix) {
|
|
57
|
+
return sharedSuggestionForPrefix(BASH_TOOL_NAME, heredocPrefix)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (command.includes('\n')) {
|
|
61
|
+
const firstLine = command.split('\n')[0]?.trim() ?? ''
|
|
62
|
+
if (firstLine) return sharedSuggestionForPrefix(BASH_TOOL_NAME, firstLine)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const prefix = getSimpleCommandPrefix(command)
|
|
66
|
+
if (prefix) return sharedSuggestionForPrefix(BASH_TOOL_NAME, prefix)
|
|
67
|
+
return sharedSuggestionForExactCommand(BASH_TOOL_NAME, command)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function extractPrefixBeforeHeredoc(command: string): string | null {
|
|
71
|
+
if (!command.includes('<<')) return null
|
|
72
|
+
const idx = command.indexOf('<<')
|
|
73
|
+
if (idx <= 0) return null
|
|
74
|
+
const before = command.substring(0, idx).trim()
|
|
75
|
+
if (!before) return null
|
|
76
|
+
|
|
77
|
+
const prefix = getSimpleCommandPrefix(before)
|
|
78
|
+
if (prefix) return prefix
|
|
79
|
+
|
|
80
|
+
const tokens = before.split(/\s+/).filter(Boolean)
|
|
81
|
+
const prefixEnd = safeEnvPrefixEnd(tokens)
|
|
82
|
+
if (prefixEnd === null || prefixEnd >= tokens.length) return null
|
|
83
|
+
return tokens.slice(prefixEnd, prefixEnd + 2).join(' ') || null
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function suggestionForPrefix(prefix: string): PermissionUpdate[] {
|
|
87
|
+
return sharedSuggestionForPrefix(BASH_TOOL_NAME, prefix)
|
|
88
|
+
}
|