ummaya 0.2.4 → 0.2.6
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 +15 -2
- package/bin/ummaya +10 -1
- package/bun.lock +180 -244
- package/npm-shrinkwrap.json +760 -1760
- package/package.json +39 -22
- package/prompts/manifest.yaml +1 -1
- package/prompts/system_v1.md +1 -0
- package/pyproject.toml +27 -2
- package/specs/2803-document-production-hardening/contracts/document-tools.schema.json +1043 -0
- package/src/ummaya/_canonical/__init__.py +2 -0
- package/src/ummaya/_canonical/baselines.yaml +113 -0
- package/src/ummaya/engine/engine.py +29 -132
- package/src/ummaya/evidence/__init__.py +21 -2
- 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 +88 -1
- 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 +81 -212
- package/src/ummaya/evidence/source_provenance.py +246 -0
- package/src/ummaya/evidence/source_provenance_redaction.py +176 -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 +5 -5
- package/src/ummaya/ipc/route_diagnostics.py +73 -0
- package/src/ummaya/ipc/stdio.py +1109 -477
- package/src/ummaya/llm/client.py +102 -3
- package/src/ummaya/llm/config.py +8 -3
- 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 +17 -1
- 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 +132 -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 +29 -0
- package/src/ummaya/tools/live_proxy.py +0 -3
- package/src/ummaya/tools/models.py +5 -1
- package/src/ummaya/tools/register_all.py +8 -0
- package/src/ummaya/tools/registry.py +10 -1
- 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 +34 -746
- package/tests/fixtures/documents/public_forms/baselines.yaml +113 -0
- package/tui/bun.lock +126 -305
- package/tui/package.json +35 -22
- package/tui/src/.cc-byte-identical-whitelist.yaml +266 -0
- package/tui/src/QueryEngine.ts +12 -8
- package/tui/src/bridge/inboundAttachments.ts +3 -3
- package/tui/src/cli/handlers/auth.ts +3 -12
- package/tui/src/cli/handlers/mcp.tsx +0 -1
- package/tui/src/cli/print.ts +8 -9
- package/tui/src/commands/insights.ts +1 -1
- package/tui/src/commands/install-github-app/types.ts +8 -30
- package/tui/src/commands/plugin/types.ts +6 -28
- package/tui/src/commands/plugin/unifiedTypes.ts +4 -26
- package/tui/src/commands/rename/generateSessionName.ts +1 -1
- 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/ScrollKeybindingHandler.tsx +6 -6
- package/tui/src/components/Spinner/types.ts +6 -28
- 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/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 +3 -3
- package/tui/src/ipc/frames.generated.ts +12 -12
- package/tui/src/ipc/llmClient.ts +151 -27
- package/tui/src/ipc/schema/frame.schema.json +1 -1
- package/tui/src/keybindings/defaultBindings.ts +4 -0
- package/tui/src/main.tsx +32 -15
- 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 -2186
- package/tui/src/screens/REPL.tsx +40 -29
- 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 +65 -2
- 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 -418
- 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/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 +1207 -714
- 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 +25 -32
- package/tui/src/tools/LookupPrimitive/prompt.ts +0 -2
- 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 +1 -11
- 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 +27 -10
- 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 +2 -1
- 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/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/pendingCallRegistry.ts +1 -6
- package/tui/src/tools/_shared/rootPrimitiveInput.ts +1 -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 +55 -860
- 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/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/claudeDesktop.ts +4 -4
- 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/mcp/dateTimeParser.ts +1 -1
- package/tui/src/utils/messages.ts +18 -0
- package/tui/src/utils/migrateSessions.ts +3 -3
- package/tui/src/utils/model/model.ts +6 -6
- 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/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/permissionValidation.ts +14 -2
- package/tui/src/utils/shell/prefix.ts +1 -1
- package/tui/src/utils/sideQuery.ts +1 -1
- package/tui/src/utils/systemThemeWatcher.ts +13 -3
- package/tui/src/utils/teleport.tsx +1 -1
- package/uv.lock +426 -45
- package/tui/src/services/api/claude.ts +0 -3540
- package/tui/src/tools/_shared/directPublicDataGuard.ts +0 -362
- package/tui/src/tools/_shared/kmaAnalysisGuard.ts +0 -197
- package/tui/src/tools/_shared/kmaAviationGuard.ts +0 -70
- package/tui/src/tools/_shared/nmcAedGuard.ts +0 -234
- package/tui/src/tools/_shared/protectedCheckGuard.ts +0 -207
- package/tui/src/tools/_shared/textToolCallGuard.ts +0 -91
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
"""Bounded style and target validation for document patches."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from ummaya.tools.documents.models import DocumentPatch, OperationType
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class DocumentPatchValidationError(ValueError):
|
|
10
|
+
"""Raised when a patch targets protected or unsupported document regions."""
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def validate_document_patch(patch: DocumentPatch) -> None:
|
|
14
|
+
"""Validate patch targets before any mutation engine is called."""
|
|
15
|
+
for operation in patch.operations:
|
|
16
|
+
target = operation.target_path.lower()
|
|
17
|
+
if "/protected/" in target or target.startswith("/protected"):
|
|
18
|
+
raise DocumentPatchValidationError(
|
|
19
|
+
f"protected template target cannot be edited: {operation.target_path}"
|
|
20
|
+
)
|
|
21
|
+
if "/formulas/" in target or target.endswith("/formula"):
|
|
22
|
+
raise DocumentPatchValidationError(
|
|
23
|
+
f"formula-backed spreadsheet target cannot be edited: {operation.target_path}"
|
|
24
|
+
)
|
|
25
|
+
if "/merged_regions/" in target or "/merged_cells/" in target:
|
|
26
|
+
raise DocumentPatchValidationError(
|
|
27
|
+
f"merged spreadsheet regions cannot be structurally edited: {operation.target_path}"
|
|
28
|
+
)
|
|
29
|
+
if target.endswith("/print_area") or "/print_areas/" in target:
|
|
30
|
+
raise DocumentPatchValidationError(
|
|
31
|
+
f"spreadsheet print areas cannot be edited by fill patches: {operation.target_path}"
|
|
32
|
+
)
|
|
33
|
+
if "/media/" in target or "/animations/" in target or "/masters/" in target:
|
|
34
|
+
raise DocumentPatchValidationError(
|
|
35
|
+
"presentation media, animation, and master targets are not promoted: "
|
|
36
|
+
f"{operation.target_path}"
|
|
37
|
+
)
|
|
38
|
+
if operation.operation_type in {
|
|
39
|
+
OperationType.set_paragraph_style,
|
|
40
|
+
OperationType.set_run_style,
|
|
41
|
+
OperationType.set_cell_style,
|
|
42
|
+
}:
|
|
43
|
+
if operation.style is None:
|
|
44
|
+
raise DocumentPatchValidationError("style operation requires a style payload")
|
|
45
|
+
if operation.style.target_path != operation.target_path:
|
|
46
|
+
raise DocumentPatchValidationError(
|
|
47
|
+
"style target_path must match the patch operation target_path"
|
|
48
|
+
)
|
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
"""Model-visible tool definitions for the Public AX document harness."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from datetime import UTC, datetime
|
|
7
|
+
from decimal import Decimal
|
|
8
|
+
from typing import Literal, cast
|
|
9
|
+
|
|
10
|
+
from pydantic import BaseModel, ConfigDict, Field, model_validator
|
|
11
|
+
|
|
12
|
+
from ummaya.tools.documents.contracts import (
|
|
13
|
+
DocumentPermission,
|
|
14
|
+
DocumentToolContract,
|
|
15
|
+
DocumentToolId,
|
|
16
|
+
load_document_tool_contracts,
|
|
17
|
+
)
|
|
18
|
+
from ummaya.tools.documents.models import (
|
|
19
|
+
BlockedReason,
|
|
20
|
+
DocumentFormat,
|
|
21
|
+
DocumentToolResult,
|
|
22
|
+
ScalarValue,
|
|
23
|
+
StyleAlignment,
|
|
24
|
+
StyleDescriptor,
|
|
25
|
+
ToolResultStatus,
|
|
26
|
+
)
|
|
27
|
+
from ummaya.tools.models import AdapterRealDomainPolicy, GovAPITool
|
|
28
|
+
|
|
29
|
+
DOCUMENT_TOOL_IDS = cast(tuple[DocumentToolId, ...], load_document_tool_contracts().tool_ids)
|
|
30
|
+
DOCUMENT_POLICY_URL = (
|
|
31
|
+
"https://github.com/umyunsang/UMMAYA/blob/main/specs/2803-document-production-hardening/spec.md"
|
|
32
|
+
)
|
|
33
|
+
_POLICY_VERIFIED_AT = datetime(2026, 6, 1, tzinfo=UTC)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class DocumentToolRequestModel(BaseModel):
|
|
37
|
+
"""Base model for model-visible document tool requests."""
|
|
38
|
+
|
|
39
|
+
model_config = ConfigDict(frozen=True, extra="forbid")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class DocumentLocator(DocumentToolRequestModel):
|
|
43
|
+
"""Local document locator passed by the LLM tool loop."""
|
|
44
|
+
|
|
45
|
+
path: str | None = Field(
|
|
46
|
+
default=None,
|
|
47
|
+
min_length=1,
|
|
48
|
+
description=(
|
|
49
|
+
"Absolute or relative local file path for first intake of a "
|
|
50
|
+
"user-provided document. Use document.path when the user gives a "
|
|
51
|
+
"local file path such as /Users/name/form.hwpx."
|
|
52
|
+
),
|
|
53
|
+
)
|
|
54
|
+
artifact_id: str | None = Field(
|
|
55
|
+
default=None,
|
|
56
|
+
min_length=1,
|
|
57
|
+
description=(
|
|
58
|
+
"Previously returned local artifact identifier from artifact_refs. "
|
|
59
|
+
"Do not invent artifact_id values."
|
|
60
|
+
),
|
|
61
|
+
)
|
|
62
|
+
expected_format: DocumentFormat | None = Field(
|
|
63
|
+
default=None,
|
|
64
|
+
description="Expected document format used to fail closed on mismatched files.",
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
@model_validator(mode="after")
|
|
68
|
+
def _require_path_or_artifact_id(self) -> DocumentLocator:
|
|
69
|
+
if self.path is None and self.artifact_id is None:
|
|
70
|
+
raise ValueError("document locator requires path or artifact_id")
|
|
71
|
+
return self
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class DocumentInspectRequest(DocumentToolRequestModel):
|
|
75
|
+
"""Inspect a local public-document artifact."""
|
|
76
|
+
|
|
77
|
+
correlation_id: str = Field(min_length=1)
|
|
78
|
+
document: DocumentLocator
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class DocumentExtractRequest(DocumentToolRequestModel):
|
|
82
|
+
"""Extract normalized document content for LLM reasoning."""
|
|
83
|
+
|
|
84
|
+
correlation_id: str = Field(min_length=1)
|
|
85
|
+
document: DocumentLocator
|
|
86
|
+
include_tables: bool
|
|
87
|
+
include_images: bool
|
|
88
|
+
include_fields: bool
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class DocumentFormSchemaRequest(DocumentToolRequestModel):
|
|
92
|
+
"""Return fillable/inferred public-form fields."""
|
|
93
|
+
|
|
94
|
+
correlation_id: str = Field(min_length=1)
|
|
95
|
+
document: DocumentLocator
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class DocumentCopyForEditRequest(DocumentToolRequestModel):
|
|
99
|
+
"""Create a working derivative before mutation."""
|
|
100
|
+
|
|
101
|
+
correlation_id: str = Field(min_length=1)
|
|
102
|
+
document: DocumentLocator
|
|
103
|
+
reason: str | None = Field(default=None, max_length=300)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class DocumentFieldPatch(DocumentToolRequestModel):
|
|
107
|
+
"""One field/cell value mutation requested by the LLM."""
|
|
108
|
+
|
|
109
|
+
target_path: str = Field(min_length=1)
|
|
110
|
+
value: ScalarValue
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class DocumentApplyFillRequest(DocumentToolRequestModel):
|
|
114
|
+
"""Apply ordered value patches to a working derivative."""
|
|
115
|
+
|
|
116
|
+
correlation_id: str = Field(min_length=1)
|
|
117
|
+
document: DocumentLocator
|
|
118
|
+
patches: tuple[DocumentFieldPatch, ...] = Field(min_length=1)
|
|
119
|
+
dry_run: bool = False
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
class DocumentPrimitiveRequest(DocumentToolRequestModel):
|
|
123
|
+
"""Single model-facing public-document operation request."""
|
|
124
|
+
|
|
125
|
+
correlation_id: str = Field(min_length=1)
|
|
126
|
+
document: DocumentLocator
|
|
127
|
+
operation: Literal["inspect", "extract", "fill", "style", "validate", "save"] = Field(
|
|
128
|
+
default="fill",
|
|
129
|
+
description=(
|
|
130
|
+
"Requested document operation. Normal document authoring uses fill or "
|
|
131
|
+
"style; the primitive still performs inspect/copy/render internally. "
|
|
132
|
+
"For write intents such as 'understand the document and complete it', "
|
|
133
|
+
"'fill it in', 'update it', 'revise it', or Korean requests like "
|
|
134
|
+
"'문서내용을 파악하고 알아서 작성해/수정해/채워줘', choose fill. Use "
|
|
135
|
+
"extract only for explicitly read-only requests that ask to inspect, "
|
|
136
|
+
"summarize, or extract content without changing the document."
|
|
137
|
+
),
|
|
138
|
+
)
|
|
139
|
+
instruction: str = Field(
|
|
140
|
+
min_length=1,
|
|
141
|
+
max_length=1200,
|
|
142
|
+
description=(
|
|
143
|
+
"Citizen-facing document task in natural language. Use this as the "
|
|
144
|
+
"high-level edit/review intent; do not call document_inspect or "
|
|
145
|
+
"document_render separately."
|
|
146
|
+
),
|
|
147
|
+
)
|
|
148
|
+
patches: tuple[DocumentFieldPatch, ...] = Field(
|
|
149
|
+
default=(),
|
|
150
|
+
description=(
|
|
151
|
+
"Optional explicit field or text patches when the target path is known "
|
|
152
|
+
"from the document schema or prior context."
|
|
153
|
+
),
|
|
154
|
+
)
|
|
155
|
+
styles: tuple[DocumentStylePatch, ...] = Field(
|
|
156
|
+
default=(),
|
|
157
|
+
description="Optional explicit bounded style patches.",
|
|
158
|
+
)
|
|
159
|
+
template_id: str | None = Field(
|
|
160
|
+
default=None,
|
|
161
|
+
min_length=1,
|
|
162
|
+
description="Optional offline public-form baseline to validate after editing.",
|
|
163
|
+
)
|
|
164
|
+
destination_display_name: str | None = Field(
|
|
165
|
+
default=None,
|
|
166
|
+
min_length=1,
|
|
167
|
+
description="Optional local export display name after review.",
|
|
168
|
+
)
|
|
169
|
+
destination_path: str | None = Field(
|
|
170
|
+
default=None,
|
|
171
|
+
min_length=1,
|
|
172
|
+
description=(
|
|
173
|
+
"Optional explicit local output path for a reviewed derivative. Use only "
|
|
174
|
+
"when the user asks to save/export the completed document to a local path."
|
|
175
|
+
),
|
|
176
|
+
)
|
|
177
|
+
approved_draft_id: str | None = Field(
|
|
178
|
+
default=None,
|
|
179
|
+
min_length=1,
|
|
180
|
+
description="Approved authoring draft identifier for narrative document insertion.",
|
|
181
|
+
)
|
|
182
|
+
approved_draft_sha256: str | None = Field(
|
|
183
|
+
default=None,
|
|
184
|
+
pattern=r"^[a-f0-9]{64}$",
|
|
185
|
+
description="SHA-256 of the user-approved narrative draft text.",
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
@model_validator(mode="after")
|
|
189
|
+
def _require_complete_authoring_approval(self) -> DocumentPrimitiveRequest:
|
|
190
|
+
if (self.approved_draft_id is None) != (self.approved_draft_sha256 is None):
|
|
191
|
+
raise ValueError("approved draft id and sha256 must be provided together")
|
|
192
|
+
return self
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
class DocumentStylePatch(DocumentToolRequestModel):
|
|
196
|
+
"""One bounded style mutation requested by the LLM."""
|
|
197
|
+
|
|
198
|
+
target_path: str = Field(min_length=1)
|
|
199
|
+
font_family: str | None = None
|
|
200
|
+
font_size_pt: Decimal | None = Field(default=None, gt=0)
|
|
201
|
+
bold: bool | None = None
|
|
202
|
+
italic: bool | None = None
|
|
203
|
+
underline: bool | None = None
|
|
204
|
+
font_color_rgb: str | None = Field(default=None, pattern=r"^[0-9A-Fa-f]{6}$")
|
|
205
|
+
fill_color_rgb: str | None = Field(default=None, pattern=r"^[0-9A-Fa-f]{6}$")
|
|
206
|
+
alignment: StyleAlignment | None = None
|
|
207
|
+
|
|
208
|
+
def to_style_descriptor(self, *, style_id: str) -> StyleDescriptor:
|
|
209
|
+
"""Convert the request patch to the internal portable style descriptor."""
|
|
210
|
+
return StyleDescriptor(
|
|
211
|
+
style_id=style_id,
|
|
212
|
+
target_path=self.target_path,
|
|
213
|
+
font_family=self.font_family,
|
|
214
|
+
font_size_pt=self.font_size_pt,
|
|
215
|
+
bold=self.bold,
|
|
216
|
+
italic=self.italic,
|
|
217
|
+
underline=self.underline,
|
|
218
|
+
font_color_rgb=self.font_color_rgb,
|
|
219
|
+
fill_color_rgb=self.fill_color_rgb,
|
|
220
|
+
alignment=self.alignment,
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
class DocumentApplyStyleRequest(DocumentToolRequestModel):
|
|
225
|
+
"""Apply ordered style patches to a working derivative."""
|
|
226
|
+
|
|
227
|
+
correlation_id: str = Field(min_length=1)
|
|
228
|
+
document: DocumentLocator
|
|
229
|
+
styles: tuple[DocumentStylePatch, ...] = Field(min_length=1)
|
|
230
|
+
dry_run: bool = False
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
class DocumentRenderRequest(DocumentToolRequestModel):
|
|
234
|
+
"""Render reviewer-readable local evidence for a derivative."""
|
|
235
|
+
|
|
236
|
+
correlation_id: str = Field(min_length=1)
|
|
237
|
+
document: DocumentLocator
|
|
238
|
+
page_limit: int | None = Field(default=None, ge=1)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
class DocumentValidatePublicFormRequest(DocumentToolRequestModel):
|
|
242
|
+
"""Validate a derivative against an offline public-form baseline."""
|
|
243
|
+
|
|
244
|
+
correlation_id: str = Field(min_length=1)
|
|
245
|
+
document: DocumentLocator
|
|
246
|
+
template_id: str = Field(min_length=1)
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
class DocumentSaveRequest(DocumentToolRequestModel):
|
|
250
|
+
"""Save a reviewed derivative as a local export artifact."""
|
|
251
|
+
|
|
252
|
+
correlation_id: str = Field(min_length=1)
|
|
253
|
+
document: DocumentLocator
|
|
254
|
+
destination_display_name: str = Field(min_length=1)
|
|
255
|
+
destination_path: str | None = Field(
|
|
256
|
+
default=None,
|
|
257
|
+
min_length=1,
|
|
258
|
+
description=(
|
|
259
|
+
"Optional explicit local output path. If omitted, save remains an "
|
|
260
|
+
"artifact-store export only."
|
|
261
|
+
),
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
class DocumentInspectResult(DocumentToolResult):
|
|
266
|
+
"""Output schema for document inspection tools."""
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
class DocumentExtractionResult(DocumentToolResult):
|
|
270
|
+
"""Output schema for document extraction and form-schema tools."""
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
class DocumentMutationResult(DocumentToolResult):
|
|
274
|
+
"""Output schema for derivative-producing document tools."""
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
class DocumentPrimitiveResult(DocumentToolResult):
|
|
278
|
+
"""Output schema for the model-facing document primitive."""
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
class DocumentValidationResult(DocumentToolResult):
|
|
282
|
+
"""Output schema for public-form validation tools."""
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
_REQUEST_MODELS: dict[str, type[BaseModel]] = {
|
|
286
|
+
"document": DocumentPrimitiveRequest,
|
|
287
|
+
"document_inspect": DocumentInspectRequest,
|
|
288
|
+
"document_extract": DocumentExtractRequest,
|
|
289
|
+
"document_form_schema": DocumentFormSchemaRequest,
|
|
290
|
+
"document_copy_for_edit": DocumentCopyForEditRequest,
|
|
291
|
+
"document_apply_fill": DocumentApplyFillRequest,
|
|
292
|
+
"document_apply_style": DocumentApplyStyleRequest,
|
|
293
|
+
"document_render": DocumentRenderRequest,
|
|
294
|
+
"document_validate_public_form": DocumentValidatePublicFormRequest,
|
|
295
|
+
"document_save": DocumentSaveRequest,
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
_OUTPUT_MODELS: dict[str, type[BaseModel]] = {
|
|
299
|
+
"document": DocumentPrimitiveResult,
|
|
300
|
+
"document_inspect": DocumentInspectResult,
|
|
301
|
+
"document_extract": DocumentExtractionResult,
|
|
302
|
+
"document_form_schema": DocumentExtractionResult,
|
|
303
|
+
"document_copy_for_edit": DocumentMutationResult,
|
|
304
|
+
"document_apply_fill": DocumentMutationResult,
|
|
305
|
+
"document_apply_style": DocumentMutationResult,
|
|
306
|
+
"document_render": DocumentMutationResult,
|
|
307
|
+
"document_validate_public_form": DocumentValidationResult,
|
|
308
|
+
"document_save": DocumentMutationResult,
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
_DISPLAY_NAMES: dict[str, str] = {
|
|
312
|
+
"document": "문서 작업",
|
|
313
|
+
"document_inspect": "문서 검사",
|
|
314
|
+
"document_extract": "문서 구조 추출",
|
|
315
|
+
"document_form_schema": "공문서 양식 필드 조회",
|
|
316
|
+
"document_copy_for_edit": "문서 편집본 생성",
|
|
317
|
+
"document_apply_fill": "문서 값 입력",
|
|
318
|
+
"document_apply_style": "문서 서식 적용",
|
|
319
|
+
"document_render": "문서 렌더 증거 생성",
|
|
320
|
+
"document_validate_public_form": "공문서 서식 검증",
|
|
321
|
+
"document_save": "문서 저장",
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
_DESCRIPTIONS: dict[str, str] = {
|
|
325
|
+
"document": (
|
|
326
|
+
"Single document primitive for local public-document authoring and review. "
|
|
327
|
+
"Use this one tool for HWPX, HWP, DOCX, PDF, XLSX, or PPTX document work. "
|
|
328
|
+
"It internally performs inspect, schema/extraction, working-copy creation, "
|
|
329
|
+
"fill/style mutation, render evidence, and automatic compact diff review. "
|
|
330
|
+
"For local files pass document.path. Do not call locate for files. Do not "
|
|
331
|
+
"call document_inspect, document_apply_fill, or document_render separately; "
|
|
332
|
+
"those are internal stages, not the model-facing workflow. Do not call "
|
|
333
|
+
"document_render separately after editing because automatic compact diff "
|
|
334
|
+
"review is included in this tool result. Do not claim that a "
|
|
335
|
+
"local/Downloads file is missing before this tool checks it; say only "
|
|
336
|
+
"that you are checking the document location and contents first."
|
|
337
|
+
),
|
|
338
|
+
"document_inspect": (
|
|
339
|
+
"Inspect a local HWPX, HWP, DOCX, PDF, XLSX, or PPTX artifact through a "
|
|
340
|
+
"promoted document engine. Returns artifact IDs, normalized structure, "
|
|
341
|
+
"style/form cues, and fail-closed security findings without mutating bytes. "
|
|
342
|
+
"For a user-provided local file path, call document_inspect first with "
|
|
343
|
+
"document.path and optional expected_format. Do not call locate for "
|
|
344
|
+
"files. Do not invent artifact_id values; only reuse artifact_refs "
|
|
345
|
+
"returned by prior document tool results."
|
|
346
|
+
),
|
|
347
|
+
"document_extract": (
|
|
348
|
+
"Extract LLM-readable paragraphs, tables, images, fields, metadata, and styles "
|
|
349
|
+
"from a previously inspected public-document artifact."
|
|
350
|
+
),
|
|
351
|
+
"document_form_schema": (
|
|
352
|
+
"Return the fillable or inferred public-form field schema so the model can "
|
|
353
|
+
"prepare values before requesting a derivative write."
|
|
354
|
+
),
|
|
355
|
+
"document_copy_for_edit": (
|
|
356
|
+
"Create an immutable working copy before any fill or style operation. This "
|
|
357
|
+
"tool writes only below the session artifact store and requires permission."
|
|
358
|
+
),
|
|
359
|
+
"document_apply_fill": (
|
|
360
|
+
"Apply ordered value patches to a working derivative through a promoted "
|
|
361
|
+
"mutation engine while preserving protected form content."
|
|
362
|
+
),
|
|
363
|
+
"document_apply_style": (
|
|
364
|
+
"Apply bounded font, color, alignment, and cell/paragraph style patches "
|
|
365
|
+
"through a promoted mutation engine."
|
|
366
|
+
),
|
|
367
|
+
"document_render": (
|
|
368
|
+
"Render reviewer-readable local evidence for generated derivatives and return "
|
|
369
|
+
"hash-linked render artifact IDs."
|
|
370
|
+
),
|
|
371
|
+
"document_validate_public_form": (
|
|
372
|
+
"Validate a generated derivative against an offline public-form conformance "
|
|
373
|
+
"baseline before it can be treated as ready for human review."
|
|
374
|
+
),
|
|
375
|
+
"document_save": (
|
|
376
|
+
"Save a reviewed derivative to a local export artifact without sending it to "
|
|
377
|
+
"an external agency channel."
|
|
378
|
+
),
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
_TRIGGER_EXAMPLES: dict[str, list[str]] = {
|
|
382
|
+
"document": [
|
|
383
|
+
"HWPX 양식을 13주차 활동일지로 작성해줘",
|
|
384
|
+
"공문서 파일을 채우고 내가 볼 수 있게 변경사항을 보여줘",
|
|
385
|
+
"주민등록등본 양식의 성명 칸을 채워줘",
|
|
386
|
+
],
|
|
387
|
+
"document_inspect": ["이 HWPX 공문서 읽어줘", "PDF 양식 구조 확인", "엑셀 민원 서식 검사"],
|
|
388
|
+
"document_extract": ["문서 표와 필드 추출", "공문서 본문 읽기"],
|
|
389
|
+
"document_form_schema": ["제출양식 입력칸 알려줘", "작성해야 할 필드 확인"],
|
|
390
|
+
"document_copy_for_edit": ["편집본 만들어줘", "원본 건드리지 말고 복사본 생성"],
|
|
391
|
+
"document_apply_fill": ["신청서에 값 입력", "양식 필드 채워줘"],
|
|
392
|
+
"document_apply_style": ["폰트와 정렬 맞춰줘", "공문서 서식 적용"],
|
|
393
|
+
"document_render": ["작성본을 렌더링해서 확인", "검토용 미리보기 생성"],
|
|
394
|
+
"document_validate_public_form": ["제출 전 서식 검증", "공문서 규격 맞는지 확인"],
|
|
395
|
+
"document_save": ["완성본 저장", "최종 제출 파일로 저장"],
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
def build_document_tool_definitions() -> tuple[GovAPITool, ...]:
|
|
400
|
+
"""Build all model-visible document harness tool definitions."""
|
|
401
|
+
catalog = load_document_tool_contracts()
|
|
402
|
+
return tuple(_build_tool(contract) for contract in catalog.tools)
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
def input_model_for_tool(tool_id: DocumentToolId) -> type[BaseModel]:
|
|
406
|
+
"""Return the Pydantic input model for a document tool contract."""
|
|
407
|
+
return _REQUEST_MODELS[tool_id]
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
def permission_for_tool(tool_id: DocumentToolId) -> DocumentPermission:
|
|
411
|
+
"""Return the document artifact permission kind for a model-visible tool."""
|
|
412
|
+
return load_document_tool_contracts().by_tool_id(tool_id).permission
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
def unsupported_document_tool_result(
|
|
416
|
+
*,
|
|
417
|
+
tool_id: str,
|
|
418
|
+
correlation_id: str,
|
|
419
|
+
message: str,
|
|
420
|
+
artifact_refs: tuple[str, ...] = (),
|
|
421
|
+
reason: BlockedReason = BlockedReason.unsupported_operation,
|
|
422
|
+
) -> DocumentToolResult:
|
|
423
|
+
"""Build a typed blocked result for unsupported document capabilities."""
|
|
424
|
+
return DocumentToolResult(
|
|
425
|
+
tool_id=tool_id,
|
|
426
|
+
correlation_id=correlation_id,
|
|
427
|
+
status=ToolResultStatus.blocked,
|
|
428
|
+
artifact_refs=list(artifact_refs),
|
|
429
|
+
text_summary=message,
|
|
430
|
+
blocked_reason=reason,
|
|
431
|
+
)
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
def needs_input_document_tool_result(
|
|
435
|
+
*,
|
|
436
|
+
tool_id: str,
|
|
437
|
+
correlation_id: str,
|
|
438
|
+
message: str,
|
|
439
|
+
artifact_refs: tuple[str, ...] = (),
|
|
440
|
+
) -> DocumentToolResult:
|
|
441
|
+
"""Build a typed needs-input result for incomplete document tool calls."""
|
|
442
|
+
return DocumentToolResult(
|
|
443
|
+
tool_id=tool_id,
|
|
444
|
+
correlation_id=correlation_id,
|
|
445
|
+
status=ToolResultStatus.needs_input,
|
|
446
|
+
artifact_refs=list(artifact_refs),
|
|
447
|
+
text_summary=message,
|
|
448
|
+
)
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
def _build_tool(contract: DocumentToolContract) -> GovAPITool:
|
|
452
|
+
permission = contract.permission
|
|
453
|
+
gate: Literal["read-only", "action"] = "action"
|
|
454
|
+
auth_type: Literal["public", "oauth"] = "public" if gate == "read-only" else "oauth"
|
|
455
|
+
tool_id = contract.tool_id
|
|
456
|
+
return GovAPITool(
|
|
457
|
+
id=tool_id,
|
|
458
|
+
name_ko=_DISPLAY_NAMES[tool_id],
|
|
459
|
+
ministry="UMMAYA",
|
|
460
|
+
category=["document", "public_ax", permission, contract.primitive],
|
|
461
|
+
endpoint=f"local://document-harness/{tool_id}",
|
|
462
|
+
auth_type=auth_type,
|
|
463
|
+
input_schema=_REQUEST_MODELS[tool_id],
|
|
464
|
+
output_schema=_OUTPUT_MODELS[tool_id],
|
|
465
|
+
search_hint=_search_hint(tool_id, contract),
|
|
466
|
+
policy=AdapterRealDomainPolicy(
|
|
467
|
+
real_classification_url=DOCUMENT_POLICY_URL,
|
|
468
|
+
real_classification_text=(
|
|
469
|
+
"UMMAYA local document artifact harness policy for session-scoped "
|
|
470
|
+
"read, derivative write, validation, and export operations."
|
|
471
|
+
),
|
|
472
|
+
citizen_facing_gate=gate,
|
|
473
|
+
last_verified=_POLICY_VERIFIED_AT,
|
|
474
|
+
),
|
|
475
|
+
adapter_mode="live",
|
|
476
|
+
is_concurrency_safe=False,
|
|
477
|
+
cache_ttl_seconds=0,
|
|
478
|
+
rate_limit_per_minute=30,
|
|
479
|
+
is_core=False,
|
|
480
|
+
primitive=contract.primitive,
|
|
481
|
+
llm_description=_DESCRIPTIONS[tool_id],
|
|
482
|
+
trigger_examples=_TRIGGER_EXAMPLES[tool_id],
|
|
483
|
+
)
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
def _search_hint(tool_id: DocumentToolId, contract: DocumentToolContract) -> str:
|
|
487
|
+
return (
|
|
488
|
+
f"문서 공문서 양식 서식 파일 {tool_id} {contract.permission} "
|
|
489
|
+
"single document primitive automatic compact diff hwpx hwp docx pdf xlsx pptx "
|
|
490
|
+
"public document harness form fill style render validate save local file path "
|
|
491
|
+
"document.path do not call locate do not call document_inspect do not call "
|
|
492
|
+
"document_apply_fill do not call document_render"
|
|
493
|
+
)
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
__all__ = [
|
|
497
|
+
"DOCUMENT_POLICY_URL",
|
|
498
|
+
"DOCUMENT_TOOL_IDS",
|
|
499
|
+
"DocumentApplyFillRequest",
|
|
500
|
+
"DocumentApplyStyleRequest",
|
|
501
|
+
"DocumentCopyForEditRequest",
|
|
502
|
+
"DocumentExtractRequest",
|
|
503
|
+
"DocumentFieldPatch",
|
|
504
|
+
"DocumentFormSchemaRequest",
|
|
505
|
+
"DocumentExtractionResult",
|
|
506
|
+
"DocumentInspectResult",
|
|
507
|
+
"DocumentPrimitiveRequest",
|
|
508
|
+
"DocumentPrimitiveResult",
|
|
509
|
+
"DocumentMutationResult",
|
|
510
|
+
"DocumentInspectRequest",
|
|
511
|
+
"DocumentLocator",
|
|
512
|
+
"DocumentRenderRequest",
|
|
513
|
+
"DocumentSaveRequest",
|
|
514
|
+
"DocumentStylePatch",
|
|
515
|
+
"DocumentValidationResult",
|
|
516
|
+
"DocumentToolRequestModel",
|
|
517
|
+
"DocumentValidatePublicFormRequest",
|
|
518
|
+
"build_document_tool_definitions",
|
|
519
|
+
"input_model_for_tool",
|
|
520
|
+
"needs_input_document_tool_result",
|
|
521
|
+
"permission_for_tool",
|
|
522
|
+
"unsupported_document_tool_result",
|
|
523
|
+
]
|