dsh-data-domain-knowledge 0.1.0-alpha.9 → 0.1.1-alpha.2
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 +118 -567
- package/cordis.patch.yml +5 -418
- package/eval/README.md +19 -8
- package/eval/benchmark-extraction-format.mjs +20 -0
- package/eval/evaluate-retrieval.mjs +17 -8
- package/eval/queries.example.jsonl +1 -0
- package/lib/client.js +4181 -3239
- package/lib/contract-envelope.d.ts +91 -0
- package/lib/contract-envelope.js +106 -0
- package/lib/contract-layout.d.ts +130 -0
- package/lib/contract-layout.js +138 -0
- package/lib/contract-refs.d.ts +39 -0
- package/lib/contract-refs.js +9 -0
- package/lib/contract-version.d.ts +311 -0
- package/lib/contract-version.js +270 -0
- package/lib/contract-wire.d.ts +147 -0
- package/lib/contract-wire.js +99 -0
- package/lib/contracts.d.ts +12 -0
- package/lib/contracts.js +12 -0
- package/lib/doc-page.js +2 -2
- package/lib/pages.js +3329 -1296
- package/lib/types/agent-behavior-rules.d.ts +10 -0
- package/lib/types/agent-behavior-rules.d.ts.map +1 -0
- package/lib/types/agent-behavior-rules.js +28 -0
- package/lib/types/agent-behavior-rules.js.map +1 -0
- package/lib/types/axis-registry.d.ts +37 -5
- package/lib/types/axis-registry.d.ts.map +1 -1
- package/lib/types/axis-registry.js +234 -26
- package/lib/types/axis-registry.js.map +1 -1
- package/lib/types/card-organize.d.ts +27 -12
- package/lib/types/card-organize.d.ts.map +1 -1
- package/lib/types/card-organize.js +58 -73
- package/lib/types/card-organize.js.map +1 -1
- package/lib/types/compiler/embedding-identity.d.ts +3 -0
- package/lib/types/compiler/embedding-identity.d.ts.map +1 -0
- package/lib/types/compiler/embedding-identity.js +24 -0
- package/lib/types/compiler/embedding-identity.js.map +1 -0
- package/lib/types/compiler/snapshot.d.ts +16 -0
- package/lib/types/compiler/snapshot.d.ts.map +1 -0
- package/lib/types/compiler/snapshot.js +2 -0
- package/lib/types/compiler/snapshot.js.map +1 -0
- package/lib/types/config-schema.d.ts +6 -3
- package/lib/types/config-schema.d.ts.map +1 -1
- package/lib/types/config-schema.js +6 -2
- package/lib/types/config-schema.js.map +1 -1
- package/lib/types/convert/host.d.ts +6 -5
- package/lib/types/convert/host.d.ts.map +1 -1
- package/lib/types/convert/host.js +58 -18
- package/lib/types/convert/host.js.map +1 -1
- package/lib/types/convert/ingest.d.ts +10 -1
- package/lib/types/convert/ingest.d.ts.map +1 -1
- package/lib/types/convert/ingest.js +68 -9
- package/lib/types/convert/ingest.js.map +1 -1
- package/lib/types/derive-contract.d.ts +3 -0
- package/lib/types/derive-contract.d.ts.map +1 -0
- package/lib/types/derive-contract.js +15 -0
- package/lib/types/derive-contract.js.map +1 -0
- package/lib/types/diagnosis/cards.d.ts +7 -3
- package/lib/types/diagnosis/cards.d.ts.map +1 -1
- package/lib/types/diagnosis/cards.js +13 -8
- package/lib/types/diagnosis/cards.js.map +1 -1
- package/lib/types/diagnosis/run.d.ts +4 -13
- package/lib/types/diagnosis/run.d.ts.map +1 -1
- package/lib/types/diagnosis/run.js +26 -16
- package/lib/types/diagnosis/run.js.map +1 -1
- package/lib/types/diagnosis/schema.js +2 -2
- package/lib/types/diagnosis/schema.js.map +1 -1
- package/lib/types/diagnosis/seed-source.d.ts +1 -1
- package/lib/types/diagnosis/seed-source.d.ts.map +1 -1
- package/lib/types/diagnosis/seed-source.js +5 -4
- package/lib/types/diagnosis/seed-source.js.map +1 -1
- package/lib/types/diagnosis/seed.d.ts +4 -4
- package/lib/types/diagnosis/seed.d.ts.map +1 -1
- package/lib/types/diagnosis/seed.js +6 -8
- package/lib/types/diagnosis/seed.js.map +1 -1
- package/lib/types/diagnosis/store.d.ts +24 -18
- package/lib/types/diagnosis/store.d.ts.map +1 -1
- package/lib/types/diagnosis/store.js +130 -65
- package/lib/types/diagnosis/store.js.map +1 -1
- package/lib/types/diagnosis/types.d.ts +47 -15
- package/lib/types/diagnosis/types.d.ts.map +1 -1
- package/lib/types/diagnosis/types.js.map +1 -1
- package/lib/types/environment/dsh-python.d.ts +77 -0
- package/lib/types/environment/dsh-python.d.ts.map +1 -0
- package/lib/types/environment/dsh-python.js +139 -0
- package/lib/types/environment/dsh-python.js.map +1 -0
- package/lib/types/environment/install.d.ts +15 -0
- package/lib/types/environment/install.d.ts.map +1 -0
- package/lib/types/environment/install.js +297 -0
- package/lib/types/environment/install.js.map +1 -0
- package/lib/types/environment/manifest.d.ts +208 -0
- package/lib/types/environment/manifest.d.ts.map +1 -0
- package/lib/types/environment/manifest.js +26 -0
- package/lib/types/environment/manifest.js.map +1 -0
- package/lib/types/environment/model-catalog.d.ts +223 -0
- package/lib/types/environment/model-catalog.d.ts.map +1 -0
- package/lib/types/environment/model-catalog.js +129 -0
- package/lib/types/environment/model-catalog.js.map +1 -0
- package/lib/types/environment/process.d.ts +10 -0
- package/lib/types/environment/process.d.ts.map +1 -0
- package/lib/types/environment/process.js +54 -0
- package/lib/types/environment/process.js.map +1 -0
- package/lib/types/environment/selection.d.ts +9 -0
- package/lib/types/environment/selection.d.ts.map +1 -0
- package/lib/types/environment/selection.js +29 -0
- package/lib/types/environment/selection.js.map +1 -0
- package/lib/types/environment/service.d.ts +64 -0
- package/lib/types/environment/service.d.ts.map +1 -0
- package/lib/types/environment/service.js +424 -0
- package/lib/types/environment/service.js.map +1 -0
- package/lib/types/environment/types.d.ts +56 -0
- package/lib/types/environment/types.d.ts.map +1 -0
- package/lib/types/environment/types.js +2 -0
- package/lib/types/environment/types.js.map +1 -0
- package/lib/types/events.d.ts +76 -0
- package/lib/types/events.d.ts.map +1 -0
- package/lib/types/events.js +52 -0
- package/lib/types/events.js.map +1 -0
- package/lib/types/extract-contract.d.ts +3 -0
- package/lib/types/extract-contract.d.ts.map +1 -0
- package/lib/types/extract-contract.js +41 -0
- package/lib/types/extract-contract.js.map +1 -0
- package/lib/types/extract-model.d.ts +5 -0
- package/lib/types/extract-model.d.ts.map +1 -1
- package/lib/types/extract-model.js.map +1 -1
- package/lib/types/extract-table-contract.d.ts +3 -0
- package/lib/types/extract-table-contract.d.ts.map +1 -0
- package/lib/types/extract-table-contract.js +27 -0
- package/lib/types/extract-table-contract.js.map +1 -0
- package/lib/types/extract-table.d.ts +8 -0
- package/lib/types/extract-table.d.ts.map +1 -0
- package/lib/types/extract-table.js +158 -0
- package/lib/types/extract-table.js.map +1 -0
- package/lib/types/extraction-runs.d.ts +30 -6
- package/lib/types/extraction-runs.d.ts.map +1 -1
- package/lib/types/extraction-runs.js +69 -8
- package/lib/types/extraction-runs.js.map +1 -1
- package/lib/types/fs-atomic.d.ts +0 -7
- package/lib/types/fs-atomic.d.ts.map +1 -1
- package/lib/types/fs-atomic.js +17 -2
- package/lib/types/fs-atomic.js.map +1 -1
- package/lib/types/images.d.ts +26 -0
- package/lib/types/images.d.ts.map +1 -0
- package/lib/types/images.js +196 -0
- package/lib/types/images.js.map +1 -0
- package/lib/types/index.d.ts +2 -2
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +598 -209
- package/lib/types/index.js.map +1 -1
- package/lib/types/intent/engine.d.ts +12 -4
- package/lib/types/intent/engine.d.ts.map +1 -1
- package/lib/types/intent/engine.js +43 -5
- package/lib/types/intent/engine.js.map +1 -1
- package/lib/types/intent/host.d.ts +5 -8
- package/lib/types/intent/host.d.ts.map +1 -1
- package/lib/types/intent/host.js +56 -11
- package/lib/types/intent/host.js.map +1 -1
- package/lib/types/intent/scope.d.ts +25 -0
- package/lib/types/intent/scope.d.ts.map +1 -0
- package/lib/types/intent/scope.js +116 -0
- package/lib/types/intent/scope.js.map +1 -0
- package/lib/types/intent/tools.d.ts +24 -20
- package/lib/types/intent/tools.d.ts.map +1 -1
- package/lib/types/intent/tools.js +65 -23
- package/lib/types/intent/tools.js.map +1 -1
- package/lib/types/intent/types.d.ts +11 -4
- package/lib/types/intent/types.d.ts.map +1 -1
- package/lib/types/knowledge-bases.d.ts +11 -5
- package/lib/types/knowledge-bases.d.ts.map +1 -1
- package/lib/types/knowledge-bases.js +52 -20
- package/lib/types/knowledge-bases.js.map +1 -1
- package/lib/types/knowledge-contract.d.ts +32 -0
- package/lib/types/knowledge-contract.d.ts.map +1 -0
- package/lib/types/knowledge-contract.js +116 -0
- package/lib/types/knowledge-contract.js.map +1 -0
- package/lib/types/knowledge.d.ts +31 -9
- package/lib/types/knowledge.d.ts.map +1 -1
- package/lib/types/knowledge.js +137 -60
- package/lib/types/knowledge.js.map +1 -1
- package/lib/types/layout.d.ts +10 -29
- package/lib/types/layout.d.ts.map +1 -1
- package/lib/types/layout.js +17 -36
- package/lib/types/layout.js.map +1 -1
- package/lib/types/materialize-snapshot.d.ts +49 -0
- package/lib/types/materialize-snapshot.d.ts.map +1 -0
- package/lib/types/materialize-snapshot.js +2 -0
- package/lib/types/materialize-snapshot.js.map +1 -0
- package/lib/types/migrate.d.ts +11 -0
- package/lib/types/migrate.d.ts.map +1 -1
- package/lib/types/migrate.js +83 -2
- package/lib/types/migrate.js.map +1 -1
- package/lib/types/model-text.d.ts +58 -1
- package/lib/types/model-text.d.ts.map +1 -1
- package/lib/types/model-text.js +85 -30
- package/lib/types/model-text.js.map +1 -1
- package/lib/types/oplog.d.ts.map +1 -1
- package/lib/types/oplog.js +7 -0
- package/lib/types/oplog.js.map +1 -1
- package/lib/types/organize-contract.d.ts +18 -0
- package/lib/types/organize-contract.d.ts.map +1 -0
- package/lib/types/organize-contract.js +82 -0
- package/lib/types/organize-contract.js.map +1 -0
- package/lib/types/pipeline/engine.d.ts +66 -0
- package/lib/types/pipeline/engine.d.ts.map +1 -0
- package/lib/types/pipeline/engine.js +352 -0
- package/lib/types/pipeline/engine.js.map +1 -0
- package/lib/types/pipeline/store.d.ts +73 -0
- package/lib/types/pipeline/store.d.ts.map +1 -0
- package/lib/types/pipeline/store.js +143 -0
- package/lib/types/pipeline/store.js.map +1 -0
- package/lib/types/pipeline/types.d.ts +102 -0
- package/lib/types/pipeline/types.d.ts.map +1 -0
- package/lib/types/pipeline/types.js +5 -0
- package/lib/types/pipeline/types.js.map +1 -0
- package/lib/types/present.d.ts +2 -0
- package/lib/types/present.d.ts.map +1 -1
- package/lib/types/present.js +9 -4
- package/lib/types/present.js.map +1 -1
- package/lib/types/preset-ids.d.ts +4 -0
- package/lib/types/preset-ids.d.ts.map +1 -0
- package/lib/types/preset-ids.js +6 -0
- package/lib/types/preset-ids.js.map +1 -0
- package/lib/types/query-analysis.d.ts +13 -1
- package/lib/types/query-analysis.d.ts.map +1 -1
- package/lib/types/query-analysis.js +62 -6
- package/lib/types/query-analysis.js.map +1 -1
- package/lib/types/recall-rank.d.ts +3 -3
- package/lib/types/recall-rank.d.ts.map +1 -1
- package/lib/types/recall-rank.js +4 -4
- package/lib/types/recall-rank.js.map +1 -1
- package/lib/types/retention.d.ts +39 -0
- package/lib/types/retention.d.ts.map +1 -0
- package/lib/types/retention.js +42 -0
- package/lib/types/retention.js.map +1 -0
- package/lib/types/retrieval/vector-index.d.ts +32 -0
- package/lib/types/retrieval/vector-index.d.ts.map +1 -0
- package/lib/types/retrieval/vector-index.js +15 -0
- package/lib/types/retrieval/vector-index.js.map +1 -0
- package/lib/types/retrieval/visibility.d.ts +6 -0
- package/lib/types/retrieval/visibility.d.ts.map +1 -0
- package/lib/types/retrieval/visibility.js +11 -0
- package/lib/types/retrieval/visibility.js.map +1 -0
- package/lib/types/runtime.d.ts +272 -27
- package/lib/types/runtime.d.ts.map +1 -1
- package/lib/types/runtime.js +2751 -537
- package/lib/types/runtime.js.map +1 -1
- package/lib/types/settings-schema.d.ts +17 -15
- package/lib/types/settings-schema.d.ts.map +1 -1
- package/lib/types/settings-schema.js +50 -47
- package/lib/types/settings-schema.js.map +1 -1
- package/lib/types/settings-volatile.d.ts +4 -4
- package/lib/types/settings-volatile.js +4 -4
- package/lib/types/source-evidence.d.ts +14 -0
- package/lib/types/source-evidence.d.ts.map +1 -0
- package/lib/types/source-evidence.js +36 -0
- package/lib/types/source-evidence.js.map +1 -0
- package/lib/types/store/axis-references.d.ts +5 -0
- package/lib/types/store/axis-references.d.ts.map +1 -0
- package/lib/types/store/axis-references.js +106 -0
- package/lib/types/store/axis-references.js.map +1 -0
- package/lib/types/store/derived.d.ts +12 -1
- package/lib/types/store/derived.d.ts.map +1 -1
- package/lib/types/store/derived.js +71 -12
- package/lib/types/store/derived.js.map +1 -1
- package/lib/types/store/knowledge-db.d.ts +31 -1
- package/lib/types/store/knowledge-db.d.ts.map +1 -1
- package/lib/types/store/knowledge-db.js +252 -18
- package/lib/types/store/knowledge-db.js.map +1 -1
- package/lib/types/store/migrate.d.ts.map +1 -1
- package/lib/types/store/migrate.js +17 -6
- package/lib/types/store/migrate.js.map +1 -1
- package/lib/types/trajectory-types.d.ts +172 -0
- package/lib/types/trajectory-types.d.ts.map +1 -0
- package/lib/types/trajectory-types.js +36 -0
- package/lib/types/trajectory-types.js.map +1 -0
- package/lib/types/types.d.ts +59 -27
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/types.js +6 -15
- package/lib/types/types.js.map +1 -1
- package/lib/types/wiki-finalize.d.ts +16 -0
- package/lib/types/wiki-finalize.d.ts.map +1 -1
- package/lib/types/wiki-finalize.js +26 -0
- package/lib/types/wiki-finalize.js.map +1 -1
- package/lib/types/wiki-materialize.d.ts +4 -0
- package/lib/types/wiki-materialize.d.ts.map +1 -1
- package/lib/types/wiki-materialize.js +21 -7
- package/lib/types/wiki-materialize.js.map +1 -1
- package/lib/types/wiki-trial-types.d.ts +87 -0
- package/lib/types/wiki-trial-types.d.ts.map +1 -1
- package/lib/types/wiki-trial-types.js +0 -16
- package/lib/types/wiki-trial-types.js.map +1 -1
- package/lib/types/wiki-trial.d.ts +40 -16
- package/lib/types/wiki-trial.d.ts.map +1 -1
- package/lib/types/wiki-trial.js +337 -224
- package/lib/types/wiki-trial.js.map +1 -1
- package/package.json +29 -20
- package/python/prepare-models.py +19 -0
- package/python/requirements.txt +8 -6
- package/scripts/doctor.mjs +13 -19
- package/scripts/environment.mjs +29 -0
- package/scripts/setup-embedding.sh +15 -5
- package/src/agent-behavior-rules.ts +37 -0
- package/src/axis-registry.ts +234 -27
- package/src/card-organize.ts +69 -75
- package/src/client/AgentBehaviorRulesCard.tsx +65 -0
- package/src/client/AttributionEventGuide.tsx +41 -39
- package/src/client/AxisRegistrySection.tsx +204 -164
- package/src/client/CompileDialogs.tsx +44 -29
- package/src/client/DeleteDocumentDialog.tsx +36 -5
- package/src/client/DirectoryPicker.tsx +0 -10
- package/src/client/EnvironmentSetup.tsx +243 -0
- package/src/client/ExpansionGraph.tsx +13 -7
- package/src/client/ExtractionTasksPage.tsx +578 -0
- package/src/client/GuideArchitectureCanvas.tsx +470 -0
- package/src/client/ImportFilesDialog.tsx +2 -13
- package/src/client/IntentLogic.tsx +2 -2
- package/src/client/IntentTab.tsx +118 -47
- package/src/client/KnowledgeBaseTab.tsx +277 -197
- package/src/client/KnowledgeLayerSection.tsx +24 -6
- package/src/client/KnowledgePanel.tsx +58 -93
- package/src/client/KnowledgeSettingsDrawer.tsx +90 -0
- package/src/client/ListPager.tsx +15 -5
- package/src/client/MaterializeTrajectoryView.tsx +124 -0
- package/src/client/NodeSettings.tsx +210 -89
- package/src/client/NormalizeTrajectoryView.tsx +136 -0
- package/src/client/PipelineNotice.tsx +26 -0
- package/src/client/PreviewSections.tsx +118 -51
- package/src/client/RecallPanel.tsx +89 -85
- package/src/client/TabGuide.tsx +159 -184
- package/src/client/TrialReportView.tsx +391 -214
- package/src/client/TypeDefinitionDrawer.tsx +150 -23
- package/src/client/WikiCardPreview.tsx +62 -16
- package/src/client/WikiFlowPanel.tsx +4 -4
- package/src/client/arch/NodeLogicPanel.tsx +3 -4
- package/src/client/arch/model.ts +6 -9
- package/src/client/architecture.tsx +23 -33
- package/src/client/attribution/AttributionGraph.tsx +10 -6
- package/src/client/attribution/AttributionTab.tsx +136 -84
- package/src/client/attribution/CaseView.tsx +3 -1
- package/src/client/attribution/EventView.tsx +108 -0
- package/src/client/attribution/RunView.tsx +2 -2
- package/src/client/attribution/StageChrome.tsx +34 -3
- package/src/client/attribution/ViewSwitch.tsx +20 -5
- package/src/client/attribution/graph-options.ts +47 -39
- package/src/client/attribution/model.ts +17 -10
- package/src/client/config-scope.ts +3 -3
- package/src/client/graph/palette.ts +165 -0
- package/src/client/index.ts +49 -42
- package/src/client/pages.css +459 -135
- package/src/client/pages.tsx +37 -9
- package/src/client/problem-domains.ts +1 -1
- package/src/client/session-remote.ts +9 -0
- package/src/client/styles.css +205 -62
- package/src/client/wiki-trial.ts +44 -3
- package/src/compiler/embedding-identity.ts +21 -0
- package/src/compiler/snapshot.ts +17 -0
- package/src/config-schema.ts +8 -3
- package/src/convert/host.ts +56 -21
- package/src/convert/ingest.ts +74 -10
- package/src/derive-contract.ts +14 -0
- package/src/diagnosis/cards.ts +13 -8
- package/src/diagnosis/run.ts +27 -17
- package/src/diagnosis/schema.ts +2 -2
- package/src/diagnosis/seed-source.ts +5 -4
- package/src/diagnosis/seed.ts +6 -8
- package/src/diagnosis/store.ts +138 -69
- package/src/diagnosis/types.ts +34 -15
- package/src/environment/dsh-python.ts +156 -0
- package/src/environment/install.ts +244 -0
- package/src/environment/manifest.ts +28 -0
- package/src/environment/model-catalog.ts +147 -0
- package/src/environment/process.ts +54 -0
- package/src/environment/selection.ts +29 -0
- package/src/environment/service.ts +348 -0
- package/src/environment/types.ts +45 -0
- package/src/events.ts +108 -0
- package/src/extract-contract.ts +42 -0
- package/src/extract-model.ts +10 -1
- package/src/extract-table-contract.ts +26 -0
- package/src/extract-table.ts +132 -0
- package/src/extraction-runs.ts +70 -11
- package/src/fs-atomic.ts +19 -2
- package/src/images.ts +203 -0
- package/src/index.ts +553 -205
- package/src/intent/README.md +8 -6
- package/src/intent/engine.ts +44 -6
- package/src/intent/host.ts +59 -18
- package/src/intent/scope.ts +125 -0
- package/src/intent/tools.ts +70 -28
- package/src/intent/types.ts +11 -4
- package/src/knowledge-bases.ts +56 -20
- package/src/knowledge-contract.ts +114 -0
- package/src/knowledge.ts +138 -69
- package/src/layout.ts +17 -37
- package/src/materialize-snapshot.ts +46 -0
- package/src/migrate.ts +75 -2
- package/src/model-text.ts +109 -4
- package/src/oplog.ts +7 -0
- package/src/organize-contract.ts +83 -0
- package/src/pipeline/engine.ts +323 -0
- package/src/pipeline/store.ts +147 -0
- package/src/pipeline/types.ts +93 -0
- package/src/present.ts +10 -4
- package/src/preset-ids.ts +6 -0
- package/src/python/embedding_worker.py +66 -2
- package/src/query-analysis.ts +68 -8
- package/src/recall-rank.ts +5 -5
- package/src/retention.ts +76 -0
- package/src/retrieval/vector-index.ts +45 -0
- package/src/retrieval/visibility.ts +14 -0
- package/src/runtime.ts +2708 -567
- package/src/settings-schema.ts +11 -8
- package/src/settings-volatile.ts +4 -4
- package/src/source-evidence.ts +37 -0
- package/src/store/axis-references.ts +96 -0
- package/src/store/derived.ts +70 -12
- package/src/store/knowledge-db.ts +248 -17
- package/src/store/migrate.ts +16 -6
- package/src/trajectory-types.ts +142 -0
- package/src/types.ts +61 -35
- package/src/wiki-finalize.ts +28 -0
- package/src/wiki-materialize.ts +25 -6
- package/src/wiki-trial-types.ts +83 -1
- package/src/wiki-trial.ts +357 -185
- package/lib/types/intent/preset-tools.d.ts +0 -37
- package/lib/types/intent/preset-tools.d.ts.map +0 -1
- package/lib/types/intent/preset-tools.js +0 -45
- package/lib/types/intent/preset-tools.js.map +0 -1
- package/preset/tita-data-agent/agent.cordis.yml +0 -394
- package/preset/tita-data-agent/preset.yml +0 -3
- package/scripts/install-agent-preset.mjs +0 -92
- package/scripts/sync-agent-preset.mjs +0 -188
- package/src/client/AgentPresetCard.tsx +0 -247
- package/src/client/agent-preset.ts +0 -121
- package/src/client/convert/ConvertPanel.tsx +0 -583
- package/src/client/convert/styles.css +0 -138
- package/src/client/convert/styles.ts +0 -49
- package/src/intent/preset-tools.ts +0 -48
|
@@ -21,7 +21,7 @@ export interface AttributionGraphProps {
|
|
|
21
21
|
* 能按接近 1:1 渲染而不是被压成一半)。动线视角忽略它:段位决定一切。
|
|
22
22
|
*/
|
|
23
23
|
rankdir: 'LR' | 'TB'
|
|
24
|
-
/** `
|
|
24
|
+
/** `force` 关系全景(浮动节点);`line` 动线(五段泳道)。 */
|
|
25
25
|
layout: GraphLayout
|
|
26
26
|
/** 视口参数档位:面板内 / 全屏。决定缩放区间、留白与段位尺寸。 */
|
|
27
27
|
mode: StageMode
|
|
@@ -314,20 +314,24 @@ export function AttributionGraph({
|
|
|
314
314
|
*/
|
|
315
315
|
useEffect(() => {
|
|
316
316
|
const graph = graphRef.current
|
|
317
|
-
if (!graph) return
|
|
318
|
-
const
|
|
317
|
+
if (!graph || !builtRef.current) return
|
|
318
|
+
const rendered = graph.getData()
|
|
319
|
+
const onGraph = new Set(rendered.nodes.flatMap(node => typeof node.id === 'string' ? [node.id] : []))
|
|
320
|
+
const onGraphEdges = new Set(rendered.edges.flatMap(edge => typeof edge.id === 'string' ? [edge.id] : []))
|
|
319
321
|
const states: Record<string, string[]> = {}
|
|
322
|
+
// Clear this component's previous selection states before applying the new one. G6 keeps
|
|
323
|
+
// omitted states, so an empty selection must explicitly remove stale `dim`/`active` states.
|
|
324
|
+
for (const id of onGraph) states[id] = []
|
|
325
|
+
for (const id of onGraphEdges) states[id] = []
|
|
320
326
|
if (chainIds) {
|
|
321
327
|
for (const id of chainIds) if (onGraph.has(id)) states[id] = id === selectedId ? ['selected'] : ['active']
|
|
322
328
|
for (const id of dimmed.nodes) if (onGraph.has(id)) states[id] = ['dim']
|
|
323
|
-
const
|
|
324
|
-
for (const id of dimmed.edges) if (edgeIds.has(id)) states[id] = ['dim']
|
|
329
|
+
for (const id of dimmed.edges) if (onGraphEdges.has(id)) states[id] = ['dim']
|
|
325
330
|
} else if (selectedId && onGraph.has(selectedId)) {
|
|
326
331
|
// 起点不允许点亮(资产 / 检查点 / 失败原因):仍然给一个选中描边,
|
|
327
332
|
// 否则用户点了没反应,看起来像坏了。
|
|
328
333
|
states[selectedId] = ['selected']
|
|
329
334
|
}
|
|
330
|
-
if (Object.keys(states).length === 0) return
|
|
331
335
|
void graph.setElementState(states)
|
|
332
336
|
}, [chainIds, chainKey, dimmed, selectedId, renderToken])
|
|
333
337
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Database, GitBranch, History, Sparkles, Stethoscope, X,
|
|
2
|
+
CircleDot, Database, GitBranch, History, Sparkles, Stethoscope, X,
|
|
3
3
|
} from '@tita-agent/ui/icons'
|
|
4
|
-
import { useCallback, useEffect, useMemo,
|
|
5
|
-
import { createPortal } from 'react-dom'
|
|
4
|
+
import { useCallback, useEffect, useMemo, useState, type ReactNode } from 'react'
|
|
6
5
|
import { Button } from '@tita-agent/ui/components'
|
|
6
|
+
import { Dialog, DialogContent, DialogTitle } from '@tita-agent/ui/overlays'
|
|
7
7
|
import { AttributionGraph } from './AttributionGraph.tsx'
|
|
8
8
|
import { CaseView } from './CaseView.tsx'
|
|
9
|
+
import { EventView } from './EventView.tsx'
|
|
9
10
|
import { GraphStage } from './GraphStage.tsx'
|
|
10
11
|
import { InfoHint } from '../InfoHint.tsx'
|
|
11
12
|
import { RunView } from './RunView.tsx'
|
|
@@ -16,9 +17,9 @@ import {
|
|
|
16
17
|
import type { GraphLayout } from './graph-options.ts'
|
|
17
18
|
import {
|
|
18
19
|
CHECK_COST_BANDS, EMPTY_FILTER, EMPTY_GRAPH, FILTERABLE_KINDS, LANES, PROBLEM_CLASSES,
|
|
19
|
-
candidatesOf, chainOf,
|
|
20
|
+
candidatesOf, chainOf, filterGraph, gapHypothesisIds, laneKindVisible,
|
|
20
21
|
laneSegments, narrowedToLanes, neighborhoodOf, summarize, symptomCountByProblemClass,
|
|
21
|
-
type AttributionCase, type AttributionGraphData, type AttributionNodeKind, type FailureReason,
|
|
22
|
+
type AttributionCase, type AttributionEvent, type AttributionGraphData, type AttributionNode, type AttributionNodeKind, type FailureReason,
|
|
22
23
|
type LaneId, type ProblemClassId,
|
|
23
24
|
} from './model.ts'
|
|
24
25
|
|
|
@@ -26,6 +27,7 @@ import {
|
|
|
26
27
|
interface DiagnosisPayload {
|
|
27
28
|
graph?: AttributionGraphData
|
|
28
29
|
cases?: AttributionCase[]
|
|
30
|
+
events?: AttributionEvent[]
|
|
29
31
|
source?: string
|
|
30
32
|
migrated?: boolean
|
|
31
33
|
problems?: string[]
|
|
@@ -35,12 +37,29 @@ interface DiagnosisPayload {
|
|
|
35
37
|
|
|
36
38
|
/** 服务端的三种来源 → 徽标上那句人话。 */
|
|
37
39
|
function sourceLabelOf(source: string | undefined): string {
|
|
38
|
-
if (source === 'cards') return '
|
|
39
|
-
if (source === '
|
|
40
|
+
if (source === 'cards') return '可复用诊断卡片'
|
|
41
|
+
if (source === 'records') return 'Event 与排查记录'
|
|
42
|
+
if (source === 'jsonl') return '旧格式历史快照'
|
|
40
43
|
return '还没有排查知识'
|
|
41
44
|
}
|
|
42
45
|
|
|
43
|
-
type SubView = 'graph' | 'case' | 'run'
|
|
46
|
+
type SubView = 'graph' | 'case' | 'event' | 'run'
|
|
47
|
+
|
|
48
|
+
function normalizeQuestion(value: string): string {
|
|
49
|
+
return value.toLocaleLowerCase().replace(/[^\p{L}\p{N}]+/gu, '')
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** 只接受问题原文明确包含的现象标题;模糊匹配或多个命中都不自动猜。 */
|
|
53
|
+
function symptomMatchOf(question: string | undefined, symptoms: readonly AttributionNode[]): AttributionNode | undefined {
|
|
54
|
+
if (!question) return undefined
|
|
55
|
+
const normalized = normalizeQuestion(question)
|
|
56
|
+
if (normalized.length < 5) return undefined
|
|
57
|
+
const matches = symptoms.filter(symptom => {
|
|
58
|
+
const title = normalizeQuestion(symptom.title)
|
|
59
|
+
return title.length >= 4 && normalized.includes(title)
|
|
60
|
+
})
|
|
61
|
+
return matches.length === 1 ? matches[0] : undefined
|
|
62
|
+
}
|
|
44
63
|
|
|
45
64
|
/**
|
|
46
65
|
* 智能归因面板。
|
|
@@ -50,10 +69,8 @@ type SubView = 'graph' | 'case' | 'run'
|
|
|
50
69
|
* 全部从「图谱的兄弟节点」改成「浮在画布上的四条边」:画布吃掉全部高度,控件
|
|
51
70
|
* 叠在它上面。视觉结果就是「打开之后就是一张大图」。
|
|
52
71
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* 这一栏问的是「下一步查什么」。默认要服务提问更多的那个角色;想看形状时切「关系」,
|
|
56
|
-
* 一步操作。
|
|
72
|
+
* 默认读法是**关系全景**:没有问题时先看完整图;出现能明确匹配的会话问题时,
|
|
73
|
+
* 在这张图里高亮相关链路。需要按步骤读时,可以切到五段泳道动线。
|
|
57
74
|
*
|
|
58
75
|
* 三条读法各自回答一个问题(图谱=结构、案例=路径、排查=剪枝),它们是同一画框里
|
|
59
76
|
* 的三层内容,由顶部的分段切换换页 —— 切换器在**画框之外**(页面级控件),
|
|
@@ -63,8 +80,10 @@ type SubView = 'graph' | 'case' | 'run'
|
|
|
63
80
|
* - 画布左上 = 操作(四组按动线顺序);右上 = 读法(四个开关同排);
|
|
64
81
|
* 左下 = 读数(统计 + 来源);底中 = 搜索;右侧 = 图例正文 / 节点详情。
|
|
65
82
|
*/
|
|
66
|
-
export function AttributionTab({ visible, onOpenKnowledge }: {
|
|
83
|
+
export function AttributionTab({ visible, activeQuestion, onOpenKnowledge }: {
|
|
67
84
|
visible: boolean
|
|
85
|
+
/** 当前会话最近一条用户消息;仅精确匹配到唯一现象时自动高亮。 */
|
|
86
|
+
activeQuestion?: string
|
|
68
87
|
/**
|
|
69
88
|
* 切到「知识库」那一栏。空态的主操作要用它 —— 排查知识是从来源与卡片编译来的,
|
|
70
89
|
* 空的时候该把人送去**录知识的那一栏**,而不是让人在这一栏里等。
|
|
@@ -72,24 +91,11 @@ export function AttributionTab({ visible, onOpenKnowledge }: {
|
|
|
72
91
|
onOpenKnowledge?: () => void
|
|
73
92
|
}): ReactNode {
|
|
74
93
|
const [subView, setSubView] = useState<SubView>('graph')
|
|
75
|
-
/**
|
|
76
|
-
const [layout, setLayout] = useState<GraphLayout>('
|
|
94
|
+
/** 默认关系图:空问题态先看完整排查关系。 */
|
|
95
|
+
const [layout, setLayout] = useState<GraphLayout>('force')
|
|
77
96
|
const [overview, setOverview] = useState(true)
|
|
78
97
|
const [focusId, setFocusId] = useState<string | undefined>(undefined)
|
|
79
|
-
/**
|
|
80
|
-
* 被点亮的那条链的起点。
|
|
81
|
-
*
|
|
82
|
-
* 与 `focusId` **分开**:`focusId` 是「聚焦哪个节点的邻域」(默认落在度数最高的
|
|
83
|
-
* 假设上,打开这一栏就该看到最粗的那个结);`selectedId` 是「点亮谁的链」。
|
|
84
|
-
*
|
|
85
|
-
* **它现在默认落在①段的第一个现象上。** 上一版默认是空的,理由是「一进来就压暗
|
|
86
|
-
* 半张图,等于把全景变成需要用户先学会退出」—— 那条理由在真机上被否掉了:3 个现象
|
|
87
|
-
* 共享 7 个假设,14 条 `may_be_caused_by` 交叉成一片,而§7.4 第 9 条本来就写着
|
|
88
|
-
* 「路径高亮是**默认读法**,不是附加功能」。默认空着,等于这条读法默认没生效。
|
|
89
|
-
*
|
|
90
|
-
* 代价仍然存在,所以出口必须明显:**点空白即取消**,而且取消之后不再被自动改回来
|
|
91
|
-
* (见 `pickedDefault`)。
|
|
92
|
-
*/
|
|
98
|
+
/** 默认不选节点:没有当前问题时,关系视图完整展示全量图谱。 */
|
|
93
99
|
const [selectedId, setSelectedId] = useState<string | undefined>(undefined)
|
|
94
100
|
/**
|
|
95
101
|
* 动线视角的**当前现象**:①段只画它,其余现象进段头的切换入口。
|
|
@@ -102,13 +108,6 @@ export function AttributionTab({ visible, onOpenKnowledge }: {
|
|
|
102
108
|
* 动线回答的是「这个现象的下一步」,那本来就是一个现象的事(§4.6)。
|
|
103
109
|
*/
|
|
104
110
|
const [laneSymptomId, setLaneSymptomId] = useState<string | undefined>(undefined)
|
|
105
|
-
/**
|
|
106
|
-
* 已经替用户预置过一次焦点了吗?
|
|
107
|
-
*
|
|
108
|
-
* 预置只在**第一次拿到非空数据**时发生。少了这个闸,每次重载(载入示例、重建之后
|
|
109
|
-
* 刷新)都会把用户手动取消掉的焦点重新按回去 —— 那就是在跟用户抢方向盘。
|
|
110
|
-
*/
|
|
111
|
-
const pickedDefault = useRef(false)
|
|
112
111
|
const [activeCase, setActiveCase] = useState('')
|
|
113
112
|
const [full, setFull] = useState(false)
|
|
114
113
|
/** 左栏:面板态默认收起成 pill(380px 塞不下四组控件 + 五段泳道,§7.7 末段)。 */
|
|
@@ -125,6 +124,7 @@ export function AttributionTab({ visible, onOpenKnowledge }: {
|
|
|
125
124
|
*/
|
|
126
125
|
const [data, setData] = useState<AttributionGraphData>(EMPTY_GRAPH)
|
|
127
126
|
const [cases, setCases] = useState<AttributionCase[]>([])
|
|
127
|
+
const [events, setEvents] = useState<AttributionEvent[]>([])
|
|
128
128
|
const [phase, setPhase] = useState<'loading' | 'ready' | 'error'>('loading')
|
|
129
129
|
/** 空库:可以载入内置示例。 */
|
|
130
130
|
const [canLoadSample, setCanLoadSample] = useState(false)
|
|
@@ -182,17 +182,14 @@ export function AttributionTab({ visible, onOpenKnowledge }: {
|
|
|
182
182
|
const graph = payload.graph ?? EMPTY_GRAPH
|
|
183
183
|
const safe = Array.isArray(graph.nodes) && Array.isArray(graph.edges) ? graph : EMPTY_GRAPH
|
|
184
184
|
setData(safe)
|
|
185
|
-
//
|
|
186
|
-
|
|
187
|
-
setFocusId(defaultFocusId(safe))
|
|
185
|
+
// 载入后先显示全量关系图。只有对话问题明确对应到唯一现象时才自动高亮。
|
|
186
|
+
setFocusId(undefined)
|
|
188
187
|
setCases(payload.cases ?? [])
|
|
188
|
+
setEvents(payload.events ?? [])
|
|
189
|
+
if (safe.nodes.length === 0 && (payload.events?.length ?? 0) > 0) setSubView('event')
|
|
189
190
|
setCanLoadSample(payload.canLoadSample === true)
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
if (!pickedDefault.current) {
|
|
193
|
-
const start = defaultChainStart(safe)
|
|
194
|
-
if (start) { pickedDefault.current = true; setLaneSymptomId(start); setSelectedId(start) }
|
|
195
|
-
}
|
|
191
|
+
setLaneSymptomId(undefined)
|
|
192
|
+
setSelectedId(undefined)
|
|
196
193
|
const troubles = payload.problems ?? []
|
|
197
194
|
setRemote({
|
|
198
195
|
source: sourceLabelOf(payload.source),
|
|
@@ -228,10 +225,9 @@ export function AttributionTab({ visible, onOpenKnowledge }: {
|
|
|
228
225
|
}, [visible, reloadToken, applyPayload])
|
|
229
226
|
|
|
230
227
|
/**
|
|
231
|
-
*
|
|
228
|
+
* 载入内置示例:**显式的一次写**,将来源记录与可复用诊断卡写入当前知识库。
|
|
232
229
|
*
|
|
233
|
-
*
|
|
234
|
-
* 可以照常改、照常删,所以说明里必须把这件事讲清楚。
|
|
230
|
+
* 载完重新读一次,让图、只读排查视图、来源徽标全部换成当前库的数据。
|
|
235
231
|
*/
|
|
236
232
|
const loadSample = async (): Promise<void> => {
|
|
237
233
|
setSampleBusy(true); setSampleError(null)
|
|
@@ -240,7 +236,7 @@ export function AttributionTab({ visible, onOpenKnowledge }: {
|
|
|
240
236
|
const body = await response.json() as { ok?: boolean; data?: DiagnosisPayload; error?: { message?: string } }
|
|
241
237
|
if (!response.ok || body.ok === false) throw new Error(body.error?.message ?? `HTTP ${response.status}`)
|
|
242
238
|
applyPayload(body.data ?? {})
|
|
243
|
-
setSampleNotice('已载入内置示例:
|
|
239
|
+
setSampleNotice('已载入内置示例:7 条来源记录、23 张可复用诊断卡;3 条排查记录以只读案例视图呈现。')
|
|
244
240
|
} catch (error) {
|
|
245
241
|
setSampleError(error instanceof Error ? error.message : String(error))
|
|
246
242
|
} finally {
|
|
@@ -249,22 +245,21 @@ export function AttributionTab({ visible, onOpenKnowledge }: {
|
|
|
249
245
|
}
|
|
250
246
|
|
|
251
247
|
/**
|
|
252
|
-
*
|
|
248
|
+
* 全屏期间的滚动锁。
|
|
253
249
|
*
|
|
254
250
|
* 只把浮层铺满视口是不够的:滚轮落在浮层的非画布区域上时,事件会冒泡给宿主,
|
|
255
251
|
* 背后的页面照样滚。锁 `body` 是这里唯一简单可靠的做法(宿主用的是文档级滚动),
|
|
256
252
|
* 退出时按原值还原而不是写死 `''`。
|
|
253
|
+
*
|
|
254
|
+
* 焦点**不在这里管**:全屏那一层现在是共享的 Radix `Dialog`,它自带焦点移入、
|
|
255
|
+
* 焦点圈定与关闭后还原。原来这一层只有 Escape + 滚动锁 —— 焦点留在面板里,Tab
|
|
256
|
+
* 一路走到背后的按钮上,而背景既没有 inert 也没有读屏的边界。
|
|
257
257
|
*/
|
|
258
258
|
useEffect(() => {
|
|
259
259
|
if (!full) return
|
|
260
260
|
const previous = document.body.style.overflow
|
|
261
261
|
document.body.style.overflow = 'hidden'
|
|
262
|
-
|
|
263
|
-
window.addEventListener('keydown', onKeyDown)
|
|
264
|
-
return () => {
|
|
265
|
-
document.body.style.overflow = previous
|
|
266
|
-
window.removeEventListener('keydown', onKeyDown)
|
|
267
|
-
}
|
|
262
|
+
return () => { document.body.style.overflow = previous }
|
|
268
263
|
}, [full])
|
|
269
264
|
|
|
270
265
|
const filter = useMemo(
|
|
@@ -279,6 +274,13 @@ export function AttributionTab({ visible, onOpenKnowledge }: {
|
|
|
279
274
|
const stats = useMemo(() => summarize(filtered), [filtered])
|
|
280
275
|
const symptomCounts = useMemo(() => symptomCountByProblemClass(data.nodes), [data])
|
|
281
276
|
const symptoms = useMemo(() => data.nodes.filter(node => node.kind === 'symptom'), [data])
|
|
277
|
+
const matchedSymptom = useMemo(() => symptomMatchOf(activeQuestion, symptoms), [activeQuestion, symptoms])
|
|
278
|
+
useEffect(() => {
|
|
279
|
+
// 新会话问题或新载入的图谱:只在唯一、明确匹配时预选;其余情况保持全图。
|
|
280
|
+
setSelectedId(matchedSymptom?.id)
|
|
281
|
+
setFocusId(matchedSymptom?.id)
|
|
282
|
+
setLaneSymptomId(matchedSymptom?.id)
|
|
283
|
+
}, [activeQuestion, data, matchedSymptom?.id])
|
|
282
284
|
/**
|
|
283
285
|
* 当前选中的现象。**推导而不是存两份**:`symptomId` 的初值是空串,因为只有服务端
|
|
284
286
|
* 才知道这个库有哪几个现象 —— 换库、载入示例之后,原来那个 id 可能根本不存在,
|
|
@@ -422,6 +424,11 @@ export function AttributionTab({ visible, onOpenKnowledge }: {
|
|
|
422
424
|
hint: '路径:一次真实排查怎么走的,包括走错的那一段。',
|
|
423
425
|
meta: String(cases.length),
|
|
424
426
|
},
|
|
427
|
+
{
|
|
428
|
+
id: 'event', label: '事件', icon: CircleDot,
|
|
429
|
+
hint: '记录:从文档提取的一次具体发生、时间线、证据和待补信息。',
|
|
430
|
+
meta: String(events.length),
|
|
431
|
+
},
|
|
425
432
|
{
|
|
426
433
|
id: 'run', label: '排查', icon: Stethoscope,
|
|
427
434
|
hint: '剪枝:按优先分排出下一步该查什么,每个检查点都有主操作。',
|
|
@@ -431,7 +438,7 @@ export function AttributionTab({ visible, onOpenKnowledge }: {
|
|
|
431
438
|
|
|
432
439
|
const layoutHint = layout === 'line'
|
|
433
440
|
? `动线:五段泳道,段内各有排序;点一个现象或假设会点亮它那条链。${instanceOpen ? '⑤ 段已展开。' : '⑤ 段(实际查询与结果)默认折叠,点它可展开。'}`
|
|
434
|
-
: '
|
|
441
|
+
: '关系:显示全量有向关系。箭头表示方向,图例说明关系类型;点节点可看关联检查与依据。'
|
|
435
442
|
const filterCount = kinds.size + problems.size + subclasses.size + modes.size + costBands.size + automations.size + (gapOnly ? 1 : 0)
|
|
436
443
|
|
|
437
444
|
const stage = <GraphStage
|
|
@@ -454,8 +461,10 @@ export function AttributionTab({ visible, onOpenKnowledge }: {
|
|
|
454
461
|
onLaneCounts={setLaneCounts}
|
|
455
462
|
onSelect={id => {
|
|
456
463
|
// 再点一次取消,回到全亮;点空白处同理(§7.4 第 9 条)。
|
|
457
|
-
|
|
458
|
-
|
|
464
|
+
const next = id === undefined || selectedId === id ? undefined : id
|
|
465
|
+
setSelectedId(next)
|
|
466
|
+
setFocusId(next)
|
|
467
|
+
setLaneSymptomId(next && data.nodes.find(node => node.id === next)?.kind === 'symptom' ? next : undefined)
|
|
459
468
|
}}
|
|
460
469
|
/>}
|
|
461
470
|
topLeft={
|
|
@@ -507,6 +516,7 @@ export function AttributionTab({ visible, onOpenKnowledge }: {
|
|
|
507
516
|
showScope={subView === 'graph'}
|
|
508
517
|
/>}
|
|
509
518
|
{...(subView === 'case' ? { layer: <CaseView cases={cases} activeId={activeCase} onActiveChange={setActiveCase} /> } : {})}
|
|
519
|
+
{...(subView === 'event' ? { layer: <EventView events={events} /> } : {})}
|
|
510
520
|
{...(subView === 'run' ? {
|
|
511
521
|
layer: <RunView
|
|
512
522
|
data={data}
|
|
@@ -549,7 +559,17 @@ export function AttributionTab({ visible, onOpenKnowledge }: {
|
|
|
549
559
|
</label>}
|
|
550
560
|
<div className="flex flex-col gap-1.5">
|
|
551
561
|
{legendOpen && <LegendBody stats={stats} />}
|
|
552
|
-
{focused && <NodeDetailCard
|
|
562
|
+
{focused && <NodeDetailCard
|
|
563
|
+
node={focused}
|
|
564
|
+
nodes={data.nodes}
|
|
565
|
+
edges={data.edges}
|
|
566
|
+
onSelect={id => {
|
|
567
|
+
setSelectedId(id)
|
|
568
|
+
setFocusId(id)
|
|
569
|
+
setLaneSymptomId(data.nodes.find(node => node.id === id)?.kind === 'symptom' ? id : undefined)
|
|
570
|
+
}}
|
|
571
|
+
onClear={selectedId ? clearSelection : undefined}
|
|
572
|
+
/>}
|
|
553
573
|
</div>
|
|
554
574
|
</>,
|
|
555
575
|
} : {})}
|
|
@@ -574,7 +594,16 @@ export function AttributionTab({ visible, onOpenKnowledge }: {
|
|
|
574
594
|
showHint={false}
|
|
575
595
|
className="shrink-0"
|
|
576
596
|
/>
|
|
577
|
-
const
|
|
597
|
+
const selectedNode = data.nodes.find(node => node.id === selectedId)
|
|
598
|
+
const viewHint = subView === 'graph'
|
|
599
|
+
? activeQuestion
|
|
600
|
+
? selectedNode
|
|
601
|
+
? `当前选择:${selectedNode.title} · 相关路径已突出`
|
|
602
|
+
: matchedSymptom
|
|
603
|
+
? `已匹配现象:${matchedSymptom.title} · 当前显示全图`
|
|
604
|
+
: '当前问题没有唯一现象匹配 · 保留全图'
|
|
605
|
+
: '全量关系图 · 点选现象查看相关假设与检查点'
|
|
606
|
+
: viewItems.find(item => item.id === subView)?.hint ?? ''
|
|
578
607
|
const helpHint = <InfoHint
|
|
579
608
|
className="shrink-0"
|
|
580
609
|
href="/knowledge/pages/help/overview?node=attribution"
|
|
@@ -589,7 +618,7 @@ export function AttributionTab({ visible, onOpenKnowledge }: {
|
|
|
589
618
|
* 用户没法分辨「这是我的库」还是「这是样例」,实跑反馈里那句「为什么把我默认的知识库
|
|
590
619
|
* 内容也带进去了」问的就是这件事。现在空的就明说空,并且把「怎么让它有东西」摆出来。
|
|
591
620
|
*/
|
|
592
|
-
if (phase !== 'ready' || data.nodes.length === 0) {
|
|
621
|
+
if (phase !== 'ready' || (data.nodes.length === 0 && events.length === 0)) {
|
|
593
622
|
return <div className="flex min-h-0 flex-1 flex-col gap-1.5">
|
|
594
623
|
{helpError && <AttributionHelpNotice message={helpError} onDismiss={() => setHelpError(null)} />}
|
|
595
624
|
<div className="flex min-w-0 items-center justify-end">{helpHint}</div>
|
|
@@ -606,12 +635,21 @@ export function AttributionTab({ visible, onOpenKnowledge }: {
|
|
|
606
635
|
}
|
|
607
636
|
|
|
608
637
|
if (full) {
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
638
|
+
/*
|
|
639
|
+
* 全屏 = 共享 `Dialog` 铺满视口,而不是自己写一层 `role="dialog"`。
|
|
640
|
+
*
|
|
641
|
+
* 为什么必须借这一层:自写的那一层只有 Escape + 滚动锁,焦点既不进也不出 ——
|
|
642
|
+
* 打开全屏之后 Tab 会一路走到背后面板的按钮上,读屏也读不出「这是一个模态」
|
|
643
|
+
* (没有 inert,背景照旧可读)。Radix 给的是焦点圈定、初始焦点、关闭后还原,
|
|
644
|
+
* 以及 Escape / 点遮罩两种关闭。
|
|
645
|
+
*
|
|
646
|
+
* 尺寸与底色用 className 覆盖(`cn` 走的是 tailwind-merge,后面的同名工具类赢):
|
|
647
|
+
* 默认那张 420px 的板子在这里要变成整个视口,而 `bg-tita-surface-muted` /
|
|
648
|
+
* `bg-tita-surface` 是同一组里的类,所以底色也跟着换。
|
|
649
|
+
*/
|
|
650
|
+
return <Dialog open onOpenChange={next => { if (!next) setFull(false) }}>
|
|
651
|
+
<DialogContent
|
|
652
|
+
className="inset-0 top-0 left-0 z-[900] flex h-full max-h-none w-full max-w-none translate-x-0 translate-y-0 flex-col gap-2 overscroll-contain rounded-none border-0 bg-tita-surface-muted p-3 shadow-none"
|
|
615
653
|
>
|
|
616
654
|
{/* 全屏只有一行页头:标题 + 页面切换 + 当前页说明 + 出口。全屏是「同一块内容
|
|
617
655
|
换成整个视口」,所以这一行就是面板里那两行(页头 + 切换行)压成一行。 */}
|
|
@@ -622,7 +660,10 @@ export function AttributionTab({ visible, onOpenKnowledge }: {
|
|
|
622
660
|
>
|
|
623
661
|
<Stethoscope size={14} />
|
|
624
662
|
</span>
|
|
625
|
-
|
|
663
|
+
{/* 可见的 h2 **就是**这一层的标题:`asChild` 让它带上 Radix 要求的可达名,
|
|
664
|
+
不必再写一份收起来的副标题(插件没有自建 Tailwind,`sr-only` 在这里
|
|
665
|
+
并不可用 —— 用了就是一条永远不生效的类名)。 */}
|
|
666
|
+
<DialogTitle asChild><h2 className="shrink-0 text-[14px] font-[750] tracking-[-0.02em]">智能归因</h2></DialogTitle>
|
|
626
667
|
{switcher}
|
|
627
668
|
<p className="min-w-0 flex-1 truncate text-[11px] text-tita-ink-muted">{viewHint}</p>
|
|
628
669
|
<Button
|
|
@@ -633,9 +674,8 @@ export function AttributionTab({ visible, onOpenKnowledge }: {
|
|
|
633
674
|
><X size={12} />退出全屏(Esc)</Button>
|
|
634
675
|
</header>
|
|
635
676
|
{stage}
|
|
636
|
-
</
|
|
637
|
-
|
|
638
|
-
)
|
|
677
|
+
</DialogContent>
|
|
678
|
+
</Dialog>
|
|
639
679
|
}
|
|
640
680
|
|
|
641
681
|
return <div className="flex min-h-0 flex-1 flex-col gap-1.5">
|
|
@@ -647,12 +687,8 @@ export function AttributionTab({ visible, onOpenKnowledge }: {
|
|
|
647
687
|
>
|
|
648
688
|
<Sparkles size={12} className="mt-0.5 shrink-0" />
|
|
649
689
|
<span className="min-w-0 flex-1">{sampleNotice}</span>
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
aria-label="关闭提示"
|
|
653
|
-
className="shrink-0 rounded-sm focus-visible:outline-[3px] focus-visible:outline-offset-1 focus-visible:outline-tita-focus-ring"
|
|
654
|
-
onClick={() => setSampleNotice(null)}
|
|
655
|
-
><X size={12} /></button>
|
|
690
|
+
{/* 共享的 ghost 图标按钮:原来的手写 `<button>` 命中区只有 12px,焦点圈还是自己写的一条。 */}
|
|
691
|
+
<Button variant="ghost" size="icon" className="shrink-0" aria-label="关闭提示" title="关闭提示" onClick={() => setSampleNotice(null)}><X size={13} /></Button>
|
|
656
692
|
</div>}
|
|
657
693
|
{helpError && <AttributionHelpNotice message={helpError} onDismiss={() => setHelpError(null)} />}
|
|
658
694
|
<div className="flex min-w-0 items-center gap-2">
|
|
@@ -660,6 +696,27 @@ export function AttributionTab({ visible, onOpenKnowledge }: {
|
|
|
660
696
|
<p className="min-w-0 flex-1 truncate text-[10px] text-tita-ink-muted">{viewHint}</p>
|
|
661
697
|
{helpHint}
|
|
662
698
|
</div>
|
|
699
|
+
{subView === 'graph' && activeQuestion && <div
|
|
700
|
+
role="status"
|
|
701
|
+
className="shrink-0 rounded-md border border-tita-line bg-tita-surface-muted px-2 py-1.5"
|
|
702
|
+
title={activeQuestion}
|
|
703
|
+
>
|
|
704
|
+
<div className="flex items-start gap-1.5">
|
|
705
|
+
<CircleDot size={12} className="mt-0.5 shrink-0 text-tita-primary" />
|
|
706
|
+
<div className="min-w-0 flex-1">
|
|
707
|
+
<p className="line-clamp-2 break-words text-[10.5px] leading-snug text-tita-ink">{activeQuestion}</p>
|
|
708
|
+
<p className="mt-1 text-[9.5px] leading-snug text-tita-ink-muted">
|
|
709
|
+
{selectedNode
|
|
710
|
+
? matchedSymptom?.id === selectedNode.id
|
|
711
|
+
? `匹配现象:${selectedNode.title} · 相关路径已高亮`
|
|
712
|
+
: `已选节点:${selectedNode.title} · 相关关系已突出`
|
|
713
|
+
: matchedSymptom
|
|
714
|
+
? `匹配现象:${matchedSymptom.title} · 当前显示全图。点选它可重新高亮路径。`
|
|
715
|
+
: '未匹配到唯一现象,当前显示全图。点选一个现象可查看它关联的假设和检查点。'}
|
|
716
|
+
</p>
|
|
717
|
+
</div>
|
|
718
|
+
</div>
|
|
719
|
+
</div>}
|
|
663
720
|
{stage}
|
|
664
721
|
</div>
|
|
665
722
|
}
|
|
@@ -670,12 +727,7 @@ function AttributionHelpNotice({ message, onDismiss }: { message: string; onDism
|
|
|
670
727
|
className="flex items-start gap-1.5 rounded-lg border border-tita-line bg-tita-surface-muted p-2 text-[10.5px] leading-relaxed text-tita-danger"
|
|
671
728
|
>
|
|
672
729
|
<span className="min-w-0 flex-1">{message}</span>
|
|
673
|
-
<
|
|
674
|
-
type="button"
|
|
675
|
-
aria-label="关闭提示"
|
|
676
|
-
className="shrink-0 rounded-sm focus-visible:outline-[3px] focus-visible:outline-offset-1 focus-visible:outline-tita-focus-ring"
|
|
677
|
-
onClick={onDismiss}
|
|
678
|
-
><X size={12} /></button>
|
|
730
|
+
<Button variant="ghost" size="icon" className="shrink-0" aria-label="关闭提示" title="关闭提示" onClick={onDismiss}><X size={13} /></Button>
|
|
679
731
|
</div>
|
|
680
732
|
}
|
|
681
733
|
|
|
@@ -46,7 +46,9 @@ export function CaseView({ cases, activeId, onActiveChange }: {
|
|
|
46
46
|
<h3 className="text-[13px] font-semibold leading-snug">{active.title}</h3>
|
|
47
47
|
<p className="mt-0.5 text-[10.5px] text-tita-ink-muted">{active.id} · 耗时 {active.durationMinutes} min</p>
|
|
48
48
|
</div>
|
|
49
|
-
<Badge tone=
|
|
49
|
+
<Badge tone={active.rootCauseStatus === 'unconfirmed' ? 'warning' : 'success'}>
|
|
50
|
+
{active.rootCauseStatus === 'unconfirmed' ? '根因未确认' : '已确认根因'}
|
|
51
|
+
</Badge>
|
|
50
52
|
</header>
|
|
51
53
|
|
|
52
54
|
{/* ── wiki 段 ── */}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { CircleDot, FileText, GitBranch, Search } from '@tita-agent/ui/icons'
|
|
2
|
+
import { useEffect, type ReactNode } from 'react'
|
|
3
|
+
import { Badge, Card } from '@tita-agent/ui/components'
|
|
4
|
+
import type { AttributionEvent } from './model.ts'
|
|
5
|
+
|
|
6
|
+
function coordinateOf(event: AttributionEvent): string {
|
|
7
|
+
const { object, action, scene } = event.coordinate
|
|
8
|
+
if (!object && !action && !scene) return '未归入坐标'
|
|
9
|
+
return [object ?? '未归一对象', action ?? '未归一动作', scene ?? '未归一场景'].join(' × ')
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function identityLabel(event: AttributionEvent): string {
|
|
13
|
+
if (event.identityType === 'external_id') return event.externalId ? `外部 ID · ${event.externalId}` : '外部 ID'
|
|
14
|
+
if (event.identityType === 'composite') return '时间 + 坐标 + 现象'
|
|
15
|
+
return '来源内独立记录'
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function EventView({ events, focusEventId }: { events: AttributionEvent[]; focusEventId?: string }): ReactNode {
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (!focusEventId) return
|
|
21
|
+
const target = document.getElementById(`knowledge-event-${focusEventId}`)
|
|
22
|
+
target?.scrollIntoView({ block: 'center', behavior: 'smooth' })
|
|
23
|
+
}, [events, focusEventId])
|
|
24
|
+
if (events.length === 0) return <p className="py-5 text-center text-[11px] text-tita-ink-muted">还没有从文档中提取 Case。</p>
|
|
25
|
+
|
|
26
|
+
const groups = new Map<string, { label: string; events: AttributionEvent[] }>()
|
|
27
|
+
for (const event of events) {
|
|
28
|
+
const label = coordinateOf(event)
|
|
29
|
+
const current = groups.get(label) ?? { label, events: [] }
|
|
30
|
+
current.events.push(event)
|
|
31
|
+
groups.set(label, current)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return <div className="flex flex-col gap-4">
|
|
35
|
+
<div className="flex items-center gap-1.5 text-[10.5px] text-tita-ink-muted">
|
|
36
|
+
<CircleDot size={13} />
|
|
37
|
+
<span>{events.length} 个 Case</span>
|
|
38
|
+
<span aria-hidden="true">·</span>
|
|
39
|
+
<GitBranch size={12} />
|
|
40
|
+
<span>{groups.size} 个坐标组</span>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
{[...groups.values()].map(group => <section key={group.label} className="flex flex-col gap-2" aria-label={group.label}>
|
|
44
|
+
<h3 className="flex items-start gap-1.5 text-[11px] font-semibold leading-snug text-tita-ink">
|
|
45
|
+
<GitBranch size={12} className="mt-0.5 shrink-0 text-tita-primary" />
|
|
46
|
+
{group.label}
|
|
47
|
+
</h3>
|
|
48
|
+
{group.events.map(event => <article
|
|
49
|
+
key={event.id}
|
|
50
|
+
id={`knowledge-event-${event.id}`}
|
|
51
|
+
className={event.id === focusEventId ? 'rounded-lg ring-2 ring-tita-primary ring-offset-2 ring-offset-tita-surface' : undefined}
|
|
52
|
+
aria-label={event.id === focusEventId ? `已定位 Case:${event.title}` : undefined}
|
|
53
|
+
><Card className="gap-2 p-2.5">
|
|
54
|
+
<header className="flex items-start gap-2">
|
|
55
|
+
<div className="min-w-0 flex-1">
|
|
56
|
+
<h4 className="text-[12px] font-semibold leading-snug text-tita-ink">{event.title}</h4>
|
|
57
|
+
<p className="mt-0.5 break-all font-mono text-[9.5px] text-tita-ink-faint">{identityLabel(event)}</p>
|
|
58
|
+
</div>
|
|
59
|
+
{event.missing.length > 0 && <Badge tone="warning">待补 {event.missing.length}</Badge>}
|
|
60
|
+
</header>
|
|
61
|
+
|
|
62
|
+
<div className="flex flex-wrap gap-1.5 text-[10px] text-tita-ink-muted">
|
|
63
|
+
{event.occurredAt && <span>{event.occurredAt}</span>}
|
|
64
|
+
{event.recordCount > 1 && <Badge tone="blue">{event.recordCount} 份来源记录</Badge>}
|
|
65
|
+
</div>
|
|
66
|
+
{event.summary && <p className="text-[10.5px] leading-relaxed text-tita-ink-muted">{event.summary}</p>}
|
|
67
|
+
{event.symptom && <p className="rounded-md bg-tita-surface-muted px-2 py-1.5 text-[10.5px] leading-relaxed"><b>现象:</b>{event.symptom}</p>}
|
|
68
|
+
|
|
69
|
+
{event.timeline.length > 0 && <section aria-label="事件时间线" className="border-l border-tita-line-strong pl-2">
|
|
70
|
+
<h5 className="mb-1 text-[9.5px] font-semibold uppercase tracking-wide text-tita-ink-faint">时间线</h5>
|
|
71
|
+
<ol className="flex flex-col gap-1.5">
|
|
72
|
+
{event.timeline.map((step, index) => <li key={`${step.sourceId}-${step.id}-${index}`} className="text-[10px] leading-relaxed">
|
|
73
|
+
<div className="flex flex-wrap items-baseline gap-x-1.5">
|
|
74
|
+
{step.at && <time className="font-mono text-[9px] text-tita-ink-faint">{step.at}</time>}
|
|
75
|
+
<span className="font-medium text-tita-ink">{step.description}</span>
|
|
76
|
+
{step.result && <span className="text-tita-ink-muted">· {step.result}</span>}
|
|
77
|
+
</div>
|
|
78
|
+
{step.sourceId && <span className="font-mono text-[9px] text-tita-ink-faint">来源 {step.sourceId}</span>}
|
|
79
|
+
</li>)}
|
|
80
|
+
</ol>
|
|
81
|
+
</section>}
|
|
82
|
+
|
|
83
|
+
{event.rootCauses.length > 0 && <section className="flex flex-col gap-1">
|
|
84
|
+
<h5 className="text-[9.5px] font-semibold uppercase tracking-wide text-tita-ink-faint">根因记录</h5>
|
|
85
|
+
{event.rootCauses.map((root, index) => <p key={`${root.sourceId}-${index}`} className="text-[10.5px] leading-relaxed">
|
|
86
|
+
<Badge tone={root.status === 'confirmed' ? 'success' : 'warning'}>{root.status === 'confirmed' ? '已确认' : '待确认'}</Badge>
|
|
87
|
+
<span className="ml-1.5">{root.text}</span>
|
|
88
|
+
</p>)}
|
|
89
|
+
</section>}
|
|
90
|
+
|
|
91
|
+
{event.outcomes.length > 0 && <p className="text-[10.5px] leading-relaxed text-tita-ink-muted">
|
|
92
|
+
<b>处理结果:</b>{[...new Set(event.outcomes.map(item => item.text))].join(';')}
|
|
93
|
+
</p>}
|
|
94
|
+
|
|
95
|
+
<footer className="flex flex-col gap-1 border-t border-tita-line pt-1.5">
|
|
96
|
+
<div className="flex items-center gap-1 text-[9.5px] font-medium text-tita-ink-faint"><FileText size={11} />原文证据</div>
|
|
97
|
+
{event.sources.length > 0
|
|
98
|
+
? event.sources.slice(0, 3).map((source, index) => <blockquote key={`${source.documentId}-${index}`} className="border-l-2 border-tita-line-strong pl-1.5 text-[9.5px] leading-relaxed text-tita-ink-muted">
|
|
99
|
+
<span className="mb-0.5 flex items-center gap-1 font-mono text-[9px] text-tita-ink-faint"><Search size={9} />{source.documentId}</span>
|
|
100
|
+
{source.quote}
|
|
101
|
+
</blockquote>)
|
|
102
|
+
: <span className="text-[9.5px] text-tita-ink-faint">暂无可显示的引文</span>}
|
|
103
|
+
{event.missing.length > 0 && <p className="text-[9.5px] leading-relaxed text-tita-warning">待补:{event.missing.join('、')}</p>}
|
|
104
|
+
</footer>
|
|
105
|
+
</Card></article>)}
|
|
106
|
+
</section>)}
|
|
107
|
+
</div>
|
|
108
|
+
}
|
|
@@ -177,9 +177,9 @@ export function RunView({ data, cases, symptoms, symptomId, onSymptomChange, onS
|
|
|
177
177
|
不是一次进行中的排查 —— 没有「本次跑了哪些检查点、看到什么」的现场状态,
|
|
178
178
|
按一个按钮只能编出一份路径来,而那正好是这个产品最不该做的事。
|
|
179
179
|
真实的写回发生在排查进行时:Agent 调 `POST /diagnosis/run` 落一条
|
|
180
|
-
`agent_diagnosis_case` 的 SourceRaw
|
|
180
|
+
`agent_diagnosis_case` 的 SourceRaw;Case 由这条记录只读派生,Knowledge / Event 由独立链路抽取和归一。
|
|
181
181
|
*/}
|
|
182
|
-
<Button className="w-full" size="sm" disabled title="
|
|
182
|
+
<Button className="w-full" size="sm" disabled title="Agent 在排查结束时用 POST /diagnosis/run 落 SourceRaw;Case 只读派生,Knowledge / Event 由知识链路处理。">
|
|
183
183
|
写回由排查进行时完成(这一屏只读)
|
|
184
184
|
</Button>
|
|
185
185
|
</Card>
|