better-dsh 0.2.3 → 0.2.4
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/cordis.patch.yml +1 -1
- package/docs/50_test-reports/2026-09-06-write/345/267/245/345/205/267sandbox/345/215/207/347/272/247/351/200/217/344/274/240bug/345/244/215/345/217/221/345/217/212/346/214/202/350/265/267-/344/272/213/344/273/266/346/212/245/345/221/212.md +176 -0
- package/docs/50_test-reports/2026-09-08-hashline-edit-E_RANGE_UNVERIFIED/350/267/250/350/275/256/344/274/232/350/257/235/351/224/256/345/244/261/346/225/210-/350/257/212/346/226/255/346/212/245/345/221/212.md +226 -0
- package/docs/50_test-reports/2026-09-11-control-prompt-into-eval-description/345/256/236/346/265/213/346/212/245/345/221/212.md +222 -0
- package/docs/50_test-reports/2026-09-12-fs-scheme-resolution-/345/256/236/346/265/213/346/212/245/345/221/212.md +81 -0
- package/docs/50_test-reports/2026-09-12-url-schemes-grammar-matrix/344/270/216catalog-centralize-/345/256/236/346/265/213/346/212/245/345/221/212.md +234 -0
- package/docs/50_test-reports/2026-09-12-url-schemes-recallable-context-design/351/252/214/350/257/201/346/212/245/345/221/212.md +160 -0
- package/docs/50_test-reports/2026-09-12-url-schemes-recallable-context-/345/256/236/346/265/213/345/211/247/346/234/254.md +44 -0
- package/docs/50_test-reports/2026-09-12-url-schemes-recallable-context-/345/256/236/346/265/213/346/212/245/345/221/212.md +89 -0
- package/docs/50_test-reports/2026-09-12-url-schemes-/345/205/255scheme/345/206/222/347/203/237/344/270/216/350/276/271/347/225/214/345/256/236/346/265/213/346/212/245/345/221/212.md +198 -0
- package/docs/50_test-reports/2026-09-13-hashline-off/344/270/213scheme/345/217/257/350/276/276/346/200/247/345/267/245/345/205/267/351/235/242/344/270/215/345/257/271/347/247/260-/345/256/236/346/265/213/346/212/245/345/221/212.md +246 -0
- package/docs/50_test-reports/2026-09-13-preact-ui-shell/345/256/236/346/265/213/346/212/245/345/221/212.md +50 -0
- package/docs/50_test-reports/2026-09-14-4999-skill/346/270/205/345/215/225/344/270/216lsp-gate/345/256/236/346/265/213/346/212/245/345/221/212.md +63 -0
- package/docs/50_test-reports/upstream-dsh-0.1.3-alpha.2-local-test-report.md +44 -0
- package/docs/50_test-reports/upstream-dsh-0.1.3-alpha.2-report.md +110 -0
- package/docs/50_test-reports/upstream-dsh-0.1.5-rc.2-local-test-report.md +79 -0
- package/docs/50_test-reports/v0.2.3b-hashline-content-locator/345/256/236/346/265/213/346/212/245/345/221/212.md +73 -0
- package/docs/50_test-reports/v0.2.3c-mobile-wave/345/256/236/346/265/213/346/212/245/345/221/212.md +47 -0
- package/docs/50_test-reports/v0.2.4-ios-focus-zoom-suppression/345/256/236/346/265/213/346/212/245/345/221/212.md +158 -0
- package/docs/specs/agent/spec.md +54 -0
- package/docs/specs/ast/spec.md +34 -0
- package/docs/specs/compaction-recall/spec.md +46 -0
- package/docs/specs/ctx/spec.md +107 -0
- package/docs/specs/dsh/spec.md +47 -0
- package/docs/specs/dvc/spec.md +87 -0
- package/docs/specs/escalation-guidance/spec.md +44 -0
- package/docs/specs/fs-scheme-resolution/spec.md +37 -0
- package/docs/specs/hash-edit/spec.md +41 -0
- package/docs/specs/http-read/spec.md +73 -0
- package/docs/specs/kernel-provisioning/spec.md +53 -0
- package/docs/specs/lsp/spec.md +121 -0
- package/docs/specs/mobile-layout/spec.md +108 -0
- package/docs/specs/model-failover/spec.md +20 -0
- package/docs/specs/preact-ui-shell/spec.md +22 -0
- package/docs/specs/repl-dispatch-resilience/spec.md +21 -0
- package/docs/specs/skill/spec.md +58 -0
- package/docs/specs/tool-surface/spec.md +222 -0
- package/docs/specs/url-schema/spec.md +148 -0
- package/docs/specs/web-trust-fence/spec.md +43 -0
- package/docs/upstream-dsh-0.1.5-rc.2-report.md +156 -0
- package/dsh-docs/AGENTS.md +75 -0
- package/dsh-docs/agent-lifecycle.md +84 -0
- package/dsh-docs/agent-lifecycle.zh.md +86 -0
- package/dsh-docs/api-gateway.md +164 -0
- package/dsh-docs/api-gateway.zh.md +164 -0
- package/dsh-docs/architecture.md +150 -0
- package/dsh-docs/architecture.zh.md +154 -0
- package/dsh-docs/capability-seams.md +543 -0
- package/dsh-docs/capability-seams.zh.md +545 -0
- package/dsh-docs/config-catalog.md +3473 -0
- package/dsh-docs/config-catalog.zh.md +3474 -0
- package/dsh-docs/cookbook/adding-a-package.md +117 -0
- package/dsh-docs/cookbook/adding-a-package.zh.md +119 -0
- package/dsh-docs/cookbook/adding-a-remote-api.md +197 -0
- package/dsh-docs/cookbook/adding-a-remote-api.zh.md +197 -0
- package/dsh-docs/cookbook/adding-a-session-format-version.md +109 -0
- package/dsh-docs/cookbook/adding-a-session-format-version.zh.md +109 -0
- package/dsh-docs/cookbook/adding-a-settings-card.md +102 -0
- package/dsh-docs/cookbook/adding-a-settings-card.zh.md +102 -0
- package/dsh-docs/cookbook/adding-a-tool.md +101 -0
- package/dsh-docs/cookbook/adding-a-tool.zh.md +103 -0
- package/dsh-docs/cookbook/adding-a-vendored-package.md +59 -0
- package/dsh-docs/cookbook/adding-a-vendored-package.zh.md +59 -0
- package/dsh-docs/cookbook/adding-an-llm-adapter.md +43 -0
- package/dsh-docs/cookbook/adding-an-llm-adapter.zh.md +43 -0
- package/dsh-docs/cookbook/extension-cookbook.md +132 -0
- package/dsh-docs/cookbook/extension-cookbook.zh.md +136 -0
- package/dsh-docs/cookbook/maintaining-dsh-code-review.md +64 -0
- package/dsh-docs/cookbook/maintaining-dsh-code-review.zh.md +64 -0
- package/dsh-docs/cookbook/responding-to-pr-review-on-a-stack.md +32 -0
- package/dsh-docs/cookbook/responding-to-pr-review-on-a-stack.zh.md +32 -0
- package/dsh-docs/cordis-api/context.md +364 -0
- package/dsh-docs/cordis-api/context.zh.md +366 -0
- package/dsh-docs/cordis-api/events.md +207 -0
- package/dsh-docs/cordis-api/events.zh.md +209 -0
- package/dsh-docs/cordis-api/fiber.md +375 -0
- package/dsh-docs/cordis-api/fiber.zh.md +377 -0
- package/dsh-docs/cordis-api/inherited.md +39 -0
- package/dsh-docs/cordis-api/registry.md +152 -0
- package/dsh-docs/cordis-api/registry.zh.md +154 -0
- package/dsh-docs/cordis-api/service.md +102 -0
- package/dsh-docs/cordis-api/service.zh.md +104 -0
- package/dsh-docs/cordis-primer.md +45 -0
- package/dsh-docs/cordis-primer.zh.md +51 -0
- package/dsh-docs/cordis-tutorial/01-first-plugin.md +95 -0
- package/dsh-docs/cordis-tutorial/01-first-plugin.zh.md +95 -0
- package/dsh-docs/cordis-tutorial/02-lifecycle-and-effects.md +98 -0
- package/dsh-docs/cordis-tutorial/02-lifecycle-and-effects.zh.md +98 -0
- package/dsh-docs/cordis-tutorial/03-services.md +98 -0
- package/dsh-docs/cordis-tutorial/03-services.zh.md +98 -0
- package/dsh-docs/cordis-tutorial/04-events.md +144 -0
- package/dsh-docs/cordis-tutorial/04-events.zh.md +144 -0
- package/dsh-docs/cordis-tutorial/05-config.md +84 -0
- package/dsh-docs/cordis-tutorial/05-config.zh.md +84 -0
- package/dsh-docs/cordis-tutorial/06-composition-and-hmr.md +113 -0
- package/dsh-docs/cordis-tutorial/06-composition-and-hmr.zh.md +113 -0
- package/dsh-docs/cordis-tutorial/07-into-the-harness.md +108 -0
- package/dsh-docs/cordis-tutorial/07-into-the-harness.zh.md +108 -0
- package/dsh-docs/cordis-tutorial/index.md +60 -0
- package/dsh-docs/cordis-tutorial/index.zh.md +62 -0
- package/dsh-docs/deepseek-llm-api-wire-extensions.md +163 -0
- package/dsh-docs/deepseek-llm-api-wire-extensions.zh.md +163 -0
- package/dsh-docs/defensive-patterns.md +33 -0
- package/dsh-docs/defensive-patterns.zh.md +35 -0
- package/dsh-docs/development.md +167 -0
- package/dsh-docs/development.zh.md +173 -0
- package/dsh-docs/event-producer-consumer.md +86 -0
- package/dsh-docs/event-producer-consumer.zh.md +88 -0
- package/dsh-docs/glossary.md +45 -0
- package/dsh-docs/glossary.zh.md +45 -0
- package/dsh-docs/graph-atlas.md +22 -0
- package/dsh-docs/graph-atlas.zh.md +24 -0
- package/dsh-docs/i18n/README.md +60 -0
- package/dsh-docs/i18n/README.zh.md +62 -0
- package/dsh-docs/i18n/style-samples.md +87 -0
- package/dsh-docs/i18n/terminology.md +214 -0
- package/dsh-docs/i18n/translation-prompt.md +263 -0
- package/dsh-docs/i18n/translation-rules.md +69 -0
- package/dsh-docs/i18n/translation-rules.zh.md +69 -0
- package/dsh-docs/module-graph.md +1411 -0
- package/dsh-docs/module-graph.zh.md +1413 -0
- package/dsh-docs/persistence-catalog.md +1075 -0
- package/dsh-docs/persistence-catalog.zh.md +1077 -0
- package/dsh-docs/postmortem/0001-acp-default-export-drops-inject.md +113 -0
- package/dsh-docs/postmortem/0001-acp-default-export-drops-inject.zh.md +113 -0
- package/dsh-docs/postmortem/0002-js-expression-disabled-filesystem-tools.md +47 -0
- package/dsh-docs/postmortem/0002-js-expression-disabled-filesystem-tools.zh.md +47 -0
- package/dsh-docs/postmortem/0003-web-agent-gui-feedback-loop.md +53 -0
- package/dsh-docs/postmortem/0003-web-agent-gui-feedback-loop.zh.md +53 -0
- package/dsh-docs/postmortem/0004-landlock-partial-notice-misclassified-child-failures.md +55 -0
- package/dsh-docs/postmortem/0004-landlock-partial-notice-misclassified-child-failures.zh.md +55 -0
- package/dsh-docs/postmortem/README.md +18 -0
- package/dsh-docs/postmortem/README.zh.md +18 -0
- package/dsh-docs/rescope.md +53 -0
- package/dsh-docs/rescope.zh.md +53 -0
- package/dsh-docs/session-format-status.md +47 -0
- package/dsh-docs/session-format-status.zh.md +47 -0
- package/dsh-docs/subsystems/README.md +61 -0
- package/dsh-docs/subsystems/README.zh.md +61 -0
- package/dsh-docs/subsystems/agent-team.md +207 -0
- package/dsh-docs/subsystems/agent-team.zh.md +207 -0
- package/dsh-docs/subsystems/approval.md +170 -0
- package/dsh-docs/subsystems/approval.zh.md +170 -0
- package/dsh-docs/subsystems/attachment.md +351 -0
- package/dsh-docs/subsystems/attachment.zh.md +351 -0
- package/dsh-docs/subsystems/client-modules.md +168 -0
- package/dsh-docs/subsystems/client-modules.zh.md +168 -0
- package/dsh-docs/subsystems/client-resources.md +91 -0
- package/dsh-docs/subsystems/client-resources.zh.md +91 -0
- package/dsh-docs/subsystems/code-runtime.md +195 -0
- package/dsh-docs/subsystems/code-runtime.zh.md +195 -0
- package/dsh-docs/subsystems/commands.md +219 -0
- package/dsh-docs/subsystems/commands.zh.md +219 -0
- package/dsh-docs/subsystems/compaction.md +238 -0
- package/dsh-docs/subsystems/compaction.zh.md +238 -0
- package/dsh-docs/subsystems/conversation.md +258 -0
- package/dsh-docs/subsystems/conversation.zh.md +258 -0
- package/dsh-docs/subsystems/core.md +1209 -0
- package/dsh-docs/subsystems/core.zh.md +1219 -0
- package/dsh-docs/subsystems/credentials.md +329 -0
- package/dsh-docs/subsystems/credentials.zh.md +329 -0
- package/dsh-docs/subsystems/extensions.md +382 -0
- package/dsh-docs/subsystems/extensions.zh.md +382 -0
- package/dsh-docs/subsystems/feedback.md +266 -0
- package/dsh-docs/subsystems/feedback.zh.md +266 -0
- package/dsh-docs/subsystems/filesystem.md +505 -0
- package/dsh-docs/subsystems/filesystem.zh.md +505 -0
- package/dsh-docs/subsystems/goal.md +277 -0
- package/dsh-docs/subsystems/goal.zh.md +277 -0
- package/dsh-docs/subsystems/invariants.md +88 -0
- package/dsh-docs/subsystems/invariants.zh.md +88 -0
- package/dsh-docs/subsystems/jobs.md +290 -0
- package/dsh-docs/subsystems/jobs.zh.md +290 -0
- package/dsh-docs/subsystems/llm-streaming.md +1080 -0
- package/dsh-docs/subsystems/llm-streaming.zh.md +1086 -0
- package/dsh-docs/subsystems/lsp.md +202 -0
- package/dsh-docs/subsystems/lsp.zh.md +202 -0
- package/dsh-docs/subsystems/permission-presets.md +131 -0
- package/dsh-docs/subsystems/permission-presets.zh.md +131 -0
- package/dsh-docs/subsystems/persistence.md +395 -0
- package/dsh-docs/subsystems/persistence.zh.md +395 -0
- package/dsh-docs/subsystems/plan.md +87 -0
- package/dsh-docs/subsystems/plan.zh.md +87 -0
- package/dsh-docs/subsystems/sandbox.md +220 -0
- package/dsh-docs/subsystems/sandbox.zh.md +220 -0
- package/dsh-docs/subsystems/schedule.md +192 -0
- package/dsh-docs/subsystems/schedule.zh.md +192 -0
- package/dsh-docs/subsystems/scope.md +59 -0
- package/dsh-docs/subsystems/scope.zh.md +59 -0
- package/dsh-docs/subsystems/session-projection.md +354 -0
- package/dsh-docs/subsystems/session-projection.zh.md +354 -0
- package/dsh-docs/subsystems/session-query.md +509 -0
- package/dsh-docs/subsystems/session-query.zh.md +509 -0
- package/dsh-docs/subsystems/session-reference.md +219 -0
- package/dsh-docs/subsystems/session-reference.zh.md +219 -0
- package/dsh-docs/subsystems/session-telemetry.md +194 -0
- package/dsh-docs/subsystems/session-telemetry.zh.md +194 -0
- package/dsh-docs/subsystems/session-title.md +204 -0
- package/dsh-docs/subsystems/session-title.zh.md +204 -0
- package/dsh-docs/subsystems/session.md +1155 -0
- package/dsh-docs/subsystems/session.zh.md +1159 -0
- package/dsh-docs/subsystems/settings.md +405 -0
- package/dsh-docs/subsystems/settings.zh.md +405 -0
- package/dsh-docs/subsystems/shell.md +303 -0
- package/dsh-docs/subsystems/shell.zh.md +303 -0
- package/dsh-docs/subsystems/sidebar-right.md +148 -0
- package/dsh-docs/subsystems/sidebar-right.zh.md +148 -0
- package/dsh-docs/subsystems/skills.md +354 -0
- package/dsh-docs/subsystems/skills.zh.md +354 -0
- package/dsh-docs/subsystems/slots.md +175 -0
- package/dsh-docs/subsystems/slots.zh.md +175 -0
- package/dsh-docs/subsystems/spill.md +117 -0
- package/dsh-docs/subsystems/spill.zh.md +117 -0
- package/dsh-docs/subsystems/storage.md +260 -0
- package/dsh-docs/subsystems/storage.zh.md +260 -0
- package/dsh-docs/subsystems/subagent.md +766 -0
- package/dsh-docs/subsystems/subagent.zh.md +770 -0
- package/dsh-docs/subsystems/subprocess.md +324 -0
- package/dsh-docs/subsystems/subprocess.zh.md +324 -0
- package/dsh-docs/subsystems/system-prompt.md +220 -0
- package/dsh-docs/subsystems/system-prompt.zh.md +220 -0
- package/dsh-docs/subsystems/terminal.md +184 -0
- package/dsh-docs/subsystems/terminal.zh.md +184 -0
- package/dsh-docs/subsystems/todo.md +32 -0
- package/dsh-docs/subsystems/todo.zh.md +32 -0
- package/dsh-docs/subsystems/token-meter.md +105 -0
- package/dsh-docs/subsystems/token-meter.zh.md +105 -0
- package/dsh-docs/subsystems/tools.md +720 -0
- package/dsh-docs/subsystems/tools.zh.md +720 -0
- package/dsh-docs/subsystems/typert.md +343 -0
- package/dsh-docs/subsystems/typert.zh.md +343 -0
- package/dsh-docs/subsystems/user-questions.md +178 -0
- package/dsh-docs/subsystems/user-questions.zh.md +178 -0
- package/dsh-docs/subsystems/web-client.md +95 -0
- package/dsh-docs/subsystems/web-client.zh.md +95 -0
- package/dsh-docs/subsystems/web-server.md +154 -0
- package/dsh-docs/subsystems/web-server.zh.md +154 -0
- package/dsh-docs/subsystems/web.md +206 -0
- package/dsh-docs/subsystems/web.zh.md +206 -0
- package/dsh-docs/subsystems/webhook.md +70 -0
- package/dsh-docs/subsystems/webhook.zh.md +70 -0
- package/dsh-docs/subsystems/workflow.md +278 -0
- package/dsh-docs/subsystems/workflow.zh.md +278 -0
- package/dsh-docs/subsystems/workspace.md +321 -0
- package/dsh-docs/subsystems/workspace.zh.md +321 -0
- package/dsh-docs/testing.md +54 -0
- package/dsh-docs/testing.zh.md +54 -0
- package/dsh-docs/tool-catalog.md +2225 -0
- package/dsh-docs/tool-catalog.zh.md +2233 -0
- package/dsh-docs/tool-execution-pipeline.md +62 -0
- package/dsh-docs/tool-execution-pipeline.zh.md +64 -0
- package/dsh-docs/user/develop/basic/config.md +106 -0
- package/dsh-docs/user/develop/basic/config.zh.md +106 -0
- package/dsh-docs/user/develop/basic/index.md +144 -0
- package/dsh-docs/user/develop/basic/index.zh.md +144 -0
- package/dsh-docs/user/develop/basic/publish.md +183 -0
- package/dsh-docs/user/develop/basic/publish.zh.md +183 -0
- package/dsh-docs/user/develop/basic/tool.md +52 -0
- package/dsh-docs/user/develop/basic/tool.zh.md +52 -0
- package/dsh-docs/user/develop/framework/events.md +143 -0
- package/dsh-docs/user/develop/framework/events.zh.md +143 -0
- package/dsh-docs/user/develop/framework/index.md +137 -0
- package/dsh-docs/user/develop/framework/index.zh.md +137 -0
- package/dsh-docs/user/develop/framework/service.md +148 -0
- package/dsh-docs/user/develop/framework/service.zh.md +150 -0
- package/dsh-docs/user/develop/practice/dynamic-cordis.md +15 -0
- package/dsh-docs/user/develop/practice/dynamic-cordis.zh.md +15 -0
- package/dsh-docs/user/develop/practice/index.md +155 -0
- package/dsh-docs/user/develop/practice/index.zh.md +155 -0
- package/dsh-docs/user/develop/practice/llm-adapter.md +189 -0
- package/dsh-docs/user/develop/practice/llm-adapter.zh.md +189 -0
- package/dsh-docs/user/guide/github-review.md +102 -0
- package/dsh-docs/user/guide/github-review.zh.md +102 -0
- package/dsh-docs/user/guide/index.md +30 -0
- package/dsh-docs/user/guide/index.zh.md +30 -0
- package/dsh-docs/user/guide/mcp-memory.md +101 -0
- package/dsh-docs/user/guide/mcp-memory.zh.md +101 -0
- package/dsh-docs/user/guide/network-proxy.md +85 -0
- package/dsh-docs/user/guide/network-proxy.zh.md +85 -0
- package/dsh-docs/user/guide/providers.md +190 -0
- package/dsh-docs/user/guide/providers.zh.md +190 -0
- package/dsh-docs/user/guide/python-sdk.md +150 -0
- package/dsh-docs/user/guide/python-sdk.zh.md +150 -0
- package/dsh-docs/user/guide/schedule.md +21 -0
- package/dsh-docs/user/guide/schedule.zh.md +21 -0
- package/dsh-docs/user/index.md +11 -0
- package/dsh-docs/user/index.zh.md +11 -0
- package/dsh-docs/web-styling.md +29 -0
- package/dsh-docs/web-styling.zh.md +29 -0
- package/eval-description.md +33 -0
- package/lib/client/index.js +327 -88
- package/lib/fs-aware/sandbox-plugin.d.ts +71 -0
- package/lib/fs-aware/sandbox-plugin.js +249 -0
- package/lib/index.d.ts +22 -22
- package/lib/index.js +3095 -3204
- package/lib/lsp-server-registry-DkaYmTwt.js +972 -0
- package/lib/lsp-server-registry-_hk-Wcia.js +3 -0
- package/lib/py-sdk-Chvy92MB.js +178 -0
- package/lib/py-sdk.d.ts +19 -2
- package/lib/py-sdk.js +2 -2
- package/lib/wrap-JFjcWwZf.js +747 -0
- package/package.json +9 -3
- package/url-schemes-instruction.md +22 -0
- package/control-prompt.md +0 -37
- package/docs/50_test-reports/v0.1.8d_artifacts/README.md +0 -138
- package/docs/50_test-reports/v0.1.8d_artifacts/code-mode-repl-only.observation.md +0 -74
- package/docs/50_test-reports/v0.1.8d_artifacts/dsh-session-session-4a293388-9ae1-474b-87a0-9e17bb556d94.jsonl +0 -3890
- package/docs/50_test-reports/v0.1.8d_artifacts/dsh-session-session-4a293388-9ae1-474b-87a0-9e17bb556d94.w-sample-0435.jsonl +0 -544
- package/docs/50_test-reports/v0.1.8d_artifacts/functions.json +0 -592
- package/docs/50_test-reports/v0.1.8d_artifacts/skills-catalog.snapshot.md +0 -30
- package/docs/50_test-reports/v0.1.8d_artifacts/tools-sdk.output-schemas.json +0 -1236
- package/docs/50_test-reports/v0.1.8d_artifacts/tools-sdk.python.txt +0 -592
- package/docs/50_test-reports/v0.1.8d_artifacts/tools-sdk.typescript.txt +0 -516
- package/docs/50_test-reports/v0.1.8d_artifacts/wire-vs-transcription.diff.md +0 -54
- package/docs/50_test-reports/v0.2.0b_artifacts/f2probe/Cargo.lock +0 -7
- package/docs/50_test-reports/v0.2.0b_artifacts/f2probe/Cargo.toml +0 -6
- package/docs/50_test-reports/v0.2.0b_artifacts/f2probe/src/bin/messy.rs +0 -8
- package/docs/50_test-reports/v0.2.0b_artifacts/f2probe/src/main.rs +0 -4
- package/docs/50_test-reports/v0.2.0b_artifacts/hashline-probe.md +0 -5
- package/docs/50_test-reports/v0.2.0b_artifacts/slowprobe/Cargo.lock +0 -7
- package/docs/50_test-reports/v0.2.0b_artifacts/slowprobe/Cargo.toml +0 -7
- package/docs/50_test-reports/v0.2.0b_artifacts/slowprobe/build.rs +0 -4
- package/docs/50_test-reports/v0.2.0b_artifacts/slowprobe/src/main.rs +0 -13
- package/docs/60_exploration-and-research/cordis-research.md +0 -350
- package/docs/60_exploration-and-research/dsh-web-profile-package-map.md +0 -186
- package/docs/60_exploration-and-research/dsh-web-ui-slot-system-research.md +0 -310
- package/docs/60_exploration-and-research/dsh-webui-strip-boundary-research.md +0 -300
- package/docs/60_exploration-and-research/ios-chat-app-bridge-research.md +0 -324
- package/docs/60_exploration-and-research/web-frontend-composability-research.md +0 -191
- package/docs/REPL-/345/267/245/345/205/267/350/260/203/347/224/250-/346/210/252/346/226/255/350/257/212/346/226/255.md +0 -110
- package/docs/adr/0001-bridge-tool-layer-not-service-layer.md +0 -14
- package/docs/adr/0002-masking-is-presentation-only.md +0 -15
- package/docs/plans/A2A-messaging-channel-test-archive.md +0 -256
- package/docs/plans/code-mode-vs-rlm-ipython-comparison.md +0 -137
- package/docs/plans/dashr-blueprint-review.md +0 -201
- package/docs/plans/dashr-blueprint.md +0 -561
- package/docs/plans/dashr-compaction-window-and-archive.md +0 -307
- package/docs/plans/dashr-profile-layer-feasibility.md +0 -367
- package/docs/plans/dashr-sandbox-escalation-semantics-gap.md +0 -171
- package/docs/plans/dashr-security-sandbox-analysis.md +0 -187
- package/docs/plans/dashr-surface-invariant-and-omp-imports.md +0 -97
- package/docs/plans/ipython-kernel-interactive-interface-test-report.md +0 -152
- package/docs/plans/kernel-refactoring/Dash-IPython-Control-Prompt-draft.md +0 -146
- package/docs/plans/kernel-refactoring/Dash-IPython-Control-Prompt-draft_v3.md +0 -50
- package/docs/plans/kernel-refactoring/Dash-IPython-Control-Prompt-draft_v4.md +0 -79
- package/docs/plans/kernel-refactoring/Dash-vs-PrimeAgent-systemprompt-toolcatalog-comparison.md +0 -138
- package/docs/plans/kernel-refactoring/RLM-system-prompt-injection-gap-report.md +0 -161
- package/docs/plans/kernel-refactoring/V0.1.5-development-plan.md +0 -109
- package/docs/plans/kernel-refactoring/actinoable-surface-to-llm-in-agent-runtime_dsh.md +0 -50
- package/docs/plans/kernel-refactoring/actinoable-surface-to-llm-in-agent-runtime_prime.md +0 -113
- package/docs/plans/recallable-compaction.md +0 -147
- package/docs/plans/spike-tag-repro.mjs +0 -102
- package/docs/plans/upstream-analysis.md +0 -128
- package/docs/v0.1.8-improved-/345/256/236/346/265/213/346/212/245/345/221/212.md +0 -142
- package/docs/v0.1.8-/345/256/236/346/265/213/346/212/245/345/221/212.md +0 -193
- package/docs/v0.1.8b-/345/256/236/346/265/213/346/212/245/345/221/212.md +0 -96
- package/docs/v0.1.8c-/345/256/236/346/265/213/346/212/245/345/221/212.md +0 -127
- package/docs/v0.1.8d-/345/256/236/346/265/213/346/212/245/345/221/212.md +0 -150
- package/docs/v0.1.8d_artifacts/README.md +0 -138
- package/docs/v0.1.8d_artifacts/code-mode-repl-only.observation.md +0 -74
- package/docs/v0.1.8d_artifacts/dsh-session-session-4a293388-9ae1-474b-87a0-9e17bb556d94.jsonl +0 -3890
- package/docs/v0.1.8d_artifacts/dsh-session-session-4a293388-9ae1-474b-87a0-9e17bb556d94.w-sample-0435.jsonl +0 -544
- package/docs/v0.1.8d_artifacts/functions.json +0 -592
- package/docs/v0.1.8d_artifacts/skills-catalog.snapshot.md +0 -30
- package/docs/v0.1.8d_artifacts/tools-sdk.output-schemas.json +0 -1236
- package/docs/v0.1.8d_artifacts/tools-sdk.python.txt +0 -592
- package/docs/v0.1.8d_artifacts/tools-sdk.typescript.txt +0 -516
- package/docs/v0.1.8d_artifacts/wire-vs-transcription.diff.md +0 -54
- package/docs/v0.1.8e-/345/256/236/346/265/213/346/212/245/345/221/212.md +0 -224
- package/docs/v0.1.9a-/345/256/236/346/265/213/346/212/245/345/221/212.md +0 -168
- package/docs/v0.2.0b-/345/256/236/346/265/213/346/212/245/345/221/212.md +0 -123
- package/docs/v0.2.0b_artifacts/f2probe/Cargo.lock +0 -7
- package/docs/v0.2.0b_artifacts/f2probe/Cargo.toml +0 -6
- package/docs/v0.2.0b_artifacts/f2probe/src/bin/messy.rs +0 -8
- package/docs/v0.2.0b_artifacts/f2probe/src/main.rs +0 -4
- package/docs/v0.2.0b_artifacts/hashline-probe.md +0 -5
- package/docs/v0.2.0b_artifacts/slowprobe/Cargo.lock +0 -7
- package/docs/v0.2.0b_artifacts/slowprobe/Cargo.toml +0 -7
- package/docs/v0.2.0b_artifacts/slowprobe/build.rs +0 -4
- package/docs/v0.2.0b_artifacts/slowprobe/src/main.rs +0 -13
- package/docs/v0.2.1-/345/256/236/346/265/213/346/212/245/345/221/212.md +0 -110
- package/docs/v0.2.1b-/345/256/236/346/265/213/346/212/245/345/221/212.md +0 -86
- package/docs/v0.2.1c-/345/256/236/346/265/213/346/212/245/345/221/212.md +0 -66
- package/lib/py-sdk-BCaOGYz7.d.ts +0 -125
- package/lib/py-sdk-CbgYiX8O.js +0 -691
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Extend a running agent with Cordis tools
|
|
2
|
+
|
|
3
|
+
English | [中文](dynamic-cordis.zh.md)
|
|
4
|
+
|
|
5
|
+
This practice guide enables [`@deepseek-ai/dsh-tool-cordis`](../../../../packages/extensions/tool-cordis/README.md). The agent can inspect its current Cordis process and mount or unmount model-authored plugins in memory. Temporary plugins disappear when they are unmounted or the process exits and may affect other sessions in the same process.
|
|
6
|
+
|
|
7
|
+
## Run it
|
|
8
|
+
|
|
9
|
+
Start the browser interface with the checked-in overlay:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pnpm dsh web --patch apps/cli/config/examples/cordis/cordis.yml
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The command requires a model credential. The [Cordis tool reference](../../../../packages/extensions/tool-cordis/README.md) defines the tool arguments, lifetime, cleanup, and safety contracts.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# 用 Cordis 工具扩展运行中的智能体
|
|
2
|
+
|
|
3
|
+
[English](dynamic-cordis.md) | 中文
|
|
4
|
+
|
|
5
|
+
本实战指南启用 [`@deepseek-ai/dsh-tool-cordis`](../../../../packages/extensions/tool-cordis/README.zh.md)。智能体可以检查当前 Cordis 进程,并在内存中挂载或卸载模型编写的插件。临时插件会在卸载或进程退出时消失,并可能影响同一进程中的其他会话。
|
|
6
|
+
|
|
7
|
+
## 运行
|
|
8
|
+
|
|
9
|
+
使用仓库内 overlay 启动浏览器界面:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pnpm dsh web --patch apps/cli/config/examples/cordis/cordis.yml
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
该命令需要模型凭据。[Cordis 工具参考](../../../../packages/extensions/tool-cordis/README.zh.md)定义了四类约定:工具参数、存续时间、清理行为和安全性。
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# Three-role capability design
|
|
2
|
+
|
|
3
|
+
English | [中文](index.zh.md)
|
|
4
|
+
|
|
5
|
+
This page has two parts: a concept reference for the three-role capability pattern, followed by an advanced tutorial that builds one capability. Complete the [basic plugin path](../basic/index.md) and [services tutorial](../framework/service.md) first.
|
|
6
|
+
|
|
7
|
+
## Concept reference
|
|
8
|
+
|
|
9
|
+
When a capability is general enough to need replaceable providers, such as Bash execution, Harness separates three roles: a **Service Definition**, a **Service Provider**, and a **Consumer**. Put the roles in separate packages when they need to evolve or be replaced independently; a package may otherwise own more than one role. The complete capability is its seam. No individual role is a seam.
|
|
10
|
+
|
|
11
|
+
## Bash example
|
|
12
|
+
|
|
13
|
+
The Bash execution capability consists of:
|
|
14
|
+
|
|
15
|
+
- **Service Definition** (`dsh-shell`) — defines the Cordis service and Bash request and result types
|
|
16
|
+
- **Service Provider** (`dsh-bash-local`) — executes commands on the local machine
|
|
17
|
+
- **Consumer** (`dsh-tool-bash`) — exposes the capability as a model-callable tool
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
┌─────────────┐ ┌──────────────────┐ ┌──────────────┐
|
|
21
|
+
│ dsh-shell │────▶│ dsh-bash-local │ │ dsh-tool-bash│
|
|
22
|
+
│(definition) │ │ (provider) │ │(consumer/tool)│
|
|
23
|
+
└─────────────┘ └──────────────────┘ └──────────────┘
|
|
24
|
+
▲ │
|
|
25
|
+
└────────────────────────────────────────────┘
|
|
26
|
+
inject: ['shell']
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Benefits of the split
|
|
30
|
+
|
|
31
|
+
### Replace providers
|
|
32
|
+
|
|
33
|
+
One Service Definition can have multiple providers selected through `cordis.yml`:
|
|
34
|
+
|
|
35
|
+
```yaml
|
|
36
|
+
# Local execution
|
|
37
|
+
- name: '@deepseek-ai/dsh-bash-local'
|
|
38
|
+
|
|
39
|
+
# Replace this row with another package that provides the same service.
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The Service Definition and tool remain unchanged while the provider changes.
|
|
43
|
+
|
|
44
|
+
### Evolve independently
|
|
45
|
+
|
|
46
|
+
- The Service Definition changes rarely after callers depend on its contract.
|
|
47
|
+
- Service Providers can improve performance and security independently.
|
|
48
|
+
- Consumers can change how they present the capability to the model.
|
|
49
|
+
|
|
50
|
+
### Decouple dependencies
|
|
51
|
+
|
|
52
|
+
- The Service Provider depends on the Service Definition.
|
|
53
|
+
- The Consumer depends on the Service Definition.
|
|
54
|
+
- The Service Provider and Consumer **do not depend on each other**.
|
|
55
|
+
|
|
56
|
+
The [capability-seam reference](../../../capability-seams.md) owns the current built-in families and package links.
|
|
57
|
+
|
|
58
|
+
## Tutorial: develop a three-role capability
|
|
59
|
+
|
|
60
|
+
### Step 1: write the Service Definition
|
|
61
|
+
|
|
62
|
+
```ts ignore-check
|
|
63
|
+
// packages/my-cap/my-cap/src/index.ts
|
|
64
|
+
import { Service, type Context } from '@deepseek-ai/cordis'
|
|
65
|
+
|
|
66
|
+
declare module '@deepseek-ai/cordis' {
|
|
67
|
+
interface Context {
|
|
68
|
+
myCap: MyCapService
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export abstract class MyCapService extends Service {
|
|
73
|
+
constructor(ctx: Context) {
|
|
74
|
+
super(ctx, 'myCap')
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Execute the capability. */
|
|
78
|
+
abstract execute(request: MyCapRequest): Promise<MyCapResult>
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface MyCapRequest {
|
|
82
|
+
input: string
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface MyCapResult {
|
|
86
|
+
output: string
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Step 2: write a Service Provider
|
|
91
|
+
|
|
92
|
+
```ts ignore-check
|
|
93
|
+
// packages/my-cap/my-cap-local/src/index.ts
|
|
94
|
+
import type { Context } from '@deepseek-ai/cordis'
|
|
95
|
+
import { MyCapService, type MyCapRequest, type MyCapResult } from '@deepseek-ai/dsh-my-cap'
|
|
96
|
+
|
|
97
|
+
class MyCapLocal extends MyCapService {
|
|
98
|
+
async execute(request: MyCapRequest): Promise<MyCapResult> {
|
|
99
|
+
// Local provider behavior.
|
|
100
|
+
return { output: request.input.toUpperCase() }
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export const name = 'my-cap-local'
|
|
105
|
+
|
|
106
|
+
export function apply(ctx: Context) {
|
|
107
|
+
ctx.plugin(MyCapLocal)
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Step 3: write a consumer
|
|
112
|
+
|
|
113
|
+
```ts ignore-check
|
|
114
|
+
// packages/my-cap/tool-my-cap/src/index.ts
|
|
115
|
+
import type { Context } from '@deepseek-ai/cordis'
|
|
116
|
+
import { defineTool } from '@deepseek-ai/dsh-tools'
|
|
117
|
+
|
|
118
|
+
export const name = 'tool-my-cap'
|
|
119
|
+
export const inject = ['tools', 'myCap']
|
|
120
|
+
|
|
121
|
+
export function apply(ctx: Context) {
|
|
122
|
+
ctx.tools.register(defineTool({
|
|
123
|
+
name: 'my_cap',
|
|
124
|
+
description: 'Execute my capability.',
|
|
125
|
+
parameters: {
|
|
126
|
+
input: { type: 'string', required: true },
|
|
127
|
+
},
|
|
128
|
+
output: {
|
|
129
|
+
schema: { type: 'string' },
|
|
130
|
+
render: (_args, value) => [{ type: 'text', text: value }],
|
|
131
|
+
},
|
|
132
|
+
async execute(args) {
|
|
133
|
+
const result = await ctx.myCap.execute({ input: args.input })
|
|
134
|
+
return result.output
|
|
135
|
+
},
|
|
136
|
+
}))
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Compose them in cordis.yml
|
|
141
|
+
|
|
142
|
+
```yaml
|
|
143
|
+
- name: '@deepseek-ai/dsh-my-cap-local'
|
|
144
|
+
- name: '@deepseek-ai/dsh-tool-my-cap'
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Design points
|
|
148
|
+
|
|
149
|
+
- **Do not split preemptively** — use separate packages only when the roles need to evolve independently. A simple tool plugin does not.
|
|
150
|
+
- **The Service Definition owns Request/Result types** — Service Providers and Consumers depend only on the Service Definition package.
|
|
151
|
+
- **Explicit > implicit** — resolve defaults in an explicit `resolve(request): Spec` step rather than hiding `?? default` expressions inside `run()`.
|
|
152
|
+
|
|
153
|
+
## Next steps
|
|
154
|
+
|
|
155
|
+
- [LLM adapter](./llm-adapter.md) — implement an LLM provider
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# 能力的三种角色设计
|
|
2
|
+
|
|
3
|
+
[English](index.md) | 中文
|
|
4
|
+
|
|
5
|
+
本文分为两部分:先参考三种角色能力模式的概念,再通过高级教程构建一项能力。请先完成[基础插件路径](../basic/index.zh.md)和[服务教程](../framework/service.zh.md)。
|
|
6
|
+
|
|
7
|
+
## 概念参考
|
|
8
|
+
|
|
9
|
+
当一项能力足够通用,需要支持可替换的提供方时(例如 Bash 执行),harness 会区分三种角色:**Service Definition**、**Service Provider** 和 **Consumer**。角色需要独立演进或替换时,将它们放入不同包;否则一个包可以承担多个角色。完整能力构成其 seam。任何单一角色都不是 seam。
|
|
10
|
+
|
|
11
|
+
## 以 Bash 为例
|
|
12
|
+
|
|
13
|
+
以 Bash 执行能力为例:
|
|
14
|
+
|
|
15
|
+
- **Service Definition** (`dsh-shell`):定义 Cordis 服务以及 Bash 请求和结果类型
|
|
16
|
+
- **Service Provider** (`dsh-bash-local`):在本地计算机上执行命令
|
|
17
|
+
- **Consumer** (`dsh-tool-bash`):将该能力公开为模型可调用的工具
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
┌─────────────┐ ┌──────────────────┐ ┌──────────────┐
|
|
21
|
+
│ dsh-shell │────▶│ dsh-bash-local │ │ dsh-tool-bash│
|
|
22
|
+
│(definition) │ │ (provider) │ │(consumer/tool)│
|
|
23
|
+
└─────────────┘ └──────────────────┘ └──────────────┘
|
|
24
|
+
▲ │
|
|
25
|
+
└────────────────────────────────────────────┘
|
|
26
|
+
inject: ['shell']
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 拆分的好处
|
|
30
|
+
|
|
31
|
+
### 提供方可替换
|
|
32
|
+
|
|
33
|
+
同一个 Service Definition 可以有多个提供方,可通过 `cordis.yml` 选择:
|
|
34
|
+
|
|
35
|
+
```yaml
|
|
36
|
+
# Local execution
|
|
37
|
+
- name: '@deepseek-ai/dsh-bash-local'
|
|
38
|
+
|
|
39
|
+
# Replace this row with another package that provides the same service.
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
更换提供方时,Service Definition 和工具均保持不变。
|
|
43
|
+
|
|
44
|
+
### 独立演进
|
|
45
|
+
|
|
46
|
+
- 调用方开始依赖 Service Definition 的约定后,Service Definition 很少改动。
|
|
47
|
+
- Service Provider 可以独立优化性能和安全性。
|
|
48
|
+
- Consumer 可以调整能力向模型呈现的方式。
|
|
49
|
+
|
|
50
|
+
### 依赖解耦
|
|
51
|
+
|
|
52
|
+
- Service Provider 依赖 Service Definition。
|
|
53
|
+
- Consumer 依赖 Service Definition。
|
|
54
|
+
- Service Provider 和 Consumer **互不依赖**。
|
|
55
|
+
|
|
56
|
+
当前内置系列及其包链接由[能力 seam 参考](../../../capability-seams.zh.md)负责。
|
|
57
|
+
|
|
58
|
+
## 教程:开发三种角色的能力
|
|
59
|
+
|
|
60
|
+
### 第一步:编写 Service Definition
|
|
61
|
+
|
|
62
|
+
```ts ignore-check
|
|
63
|
+
// packages/my-cap/my-cap/src/index.ts
|
|
64
|
+
import { Service, type Context } from '@deepseek-ai/cordis'
|
|
65
|
+
|
|
66
|
+
declare module '@deepseek-ai/cordis' {
|
|
67
|
+
interface Context {
|
|
68
|
+
myCap: MyCapService
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export abstract class MyCapService extends Service {
|
|
73
|
+
constructor(ctx: Context) {
|
|
74
|
+
super(ctx, 'myCap')
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Execute the capability. */
|
|
78
|
+
abstract execute(request: MyCapRequest): Promise<MyCapResult>
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface MyCapRequest {
|
|
82
|
+
input: string
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface MyCapResult {
|
|
86
|
+
output: string
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 第二步:编写 Service Provider
|
|
91
|
+
|
|
92
|
+
```ts ignore-check
|
|
93
|
+
// packages/my-cap/my-cap-local/src/index.ts
|
|
94
|
+
import type { Context } from '@deepseek-ai/cordis'
|
|
95
|
+
import { MyCapService, type MyCapRequest, type MyCapResult } from '@deepseek-ai/dsh-my-cap'
|
|
96
|
+
|
|
97
|
+
class MyCapLocal extends MyCapService {
|
|
98
|
+
async execute(request: MyCapRequest): Promise<MyCapResult> {
|
|
99
|
+
// Local provider behavior.
|
|
100
|
+
return { output: request.input.toUpperCase() }
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export const name = 'my-cap-local'
|
|
105
|
+
|
|
106
|
+
export function apply(ctx: Context) {
|
|
107
|
+
ctx.plugin(MyCapLocal)
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### 第三步:编写消费方
|
|
112
|
+
|
|
113
|
+
```ts ignore-check
|
|
114
|
+
// packages/my-cap/tool-my-cap/src/index.ts
|
|
115
|
+
import type { Context } from '@deepseek-ai/cordis'
|
|
116
|
+
import { defineTool } from '@deepseek-ai/dsh-tools'
|
|
117
|
+
|
|
118
|
+
export const name = 'tool-my-cap'
|
|
119
|
+
export const inject = ['tools', 'myCap']
|
|
120
|
+
|
|
121
|
+
export function apply(ctx: Context) {
|
|
122
|
+
ctx.tools.register(defineTool({
|
|
123
|
+
name: 'my_cap',
|
|
124
|
+
description: 'Execute my capability.',
|
|
125
|
+
parameters: {
|
|
126
|
+
input: { type: 'string', required: true },
|
|
127
|
+
},
|
|
128
|
+
output: {
|
|
129
|
+
schema: { type: 'string' },
|
|
130
|
+
render: (_args, value) => [{ type: 'text', text: value }],
|
|
131
|
+
},
|
|
132
|
+
async execute(args) {
|
|
133
|
+
const result = await ctx.myCap.execute({ input: args.input })
|
|
134
|
+
return result.output
|
|
135
|
+
},
|
|
136
|
+
}))
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 在 cordis.yml 中组合
|
|
141
|
+
|
|
142
|
+
```yaml
|
|
143
|
+
- name: '@deepseek-ai/dsh-my-cap-local'
|
|
144
|
+
- name: '@deepseek-ai/dsh-tool-my-cap'
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## 设计要点
|
|
148
|
+
|
|
149
|
+
- **不要预防性拆分**:只有角色需要独立演进时,才使用不同包。简单的工具插件无需拆分。
|
|
150
|
+
- **Service Definition 拥有 Request/Result 类型**:Service Provider 和 Consumer 只依赖 Service Definition 包。
|
|
151
|
+
- **显式优于隐式**:实现应通过显式的 `resolve(request): Spec` 步骤处理默认值,而不是在 `run()` 中隐藏 `?? default`。
|
|
152
|
+
|
|
153
|
+
## 下一步
|
|
154
|
+
|
|
155
|
+
- [LLM(大语言模型)适配器](./llm-adapter.zh.md):实现一个 LLM 提供方
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# LLM adapters
|
|
2
|
+
|
|
3
|
+
English | [中文](llm-adapter.zh.md)
|
|
4
|
+
|
|
5
|
+
This guide connects a new LLM provider to Harness.
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
An LLM adapter extends `LlmAdapter` and implements `stream()`, translating Harness's provider-neutral request into a provider API call and translating the response back into Harness chunks.
|
|
10
|
+
|
|
11
|
+
## Minimal implementation
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import type { Context } from '@deepseek-ai/cordis'
|
|
15
|
+
import Schema from '@deepseek-ai/schemastery'
|
|
16
|
+
import { LlmAdapter, type GenerateOptions, type StreamChunk } from '@deepseek-ai/dsh-llm'
|
|
17
|
+
|
|
18
|
+
class MyAdapter extends LlmAdapter {
|
|
19
|
+
private apiKey: string
|
|
20
|
+
|
|
21
|
+
constructor(apiKey: string) {
|
|
22
|
+
super()
|
|
23
|
+
this.apiKey = apiKey
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async *stream(options: GenerateOptions): AsyncIterable<StreamChunk> {
|
|
27
|
+
// 1. Convert options.messages to the provider format.
|
|
28
|
+
// 2. Call the streaming API.
|
|
29
|
+
// 3. Convert the response into StreamChunk values.
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface Config {
|
|
34
|
+
apiKey: string
|
|
35
|
+
providers: string[]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const Config: Schema<Config> = Schema.object({
|
|
39
|
+
apiKey: Schema.string().required(),
|
|
40
|
+
providers: Schema.array(Schema.string()).required(),
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
export const name = 'my-llm-adapter'
|
|
44
|
+
export const inject = ['llm']
|
|
45
|
+
|
|
46
|
+
export function apply(ctx: Context, config: Config) {
|
|
47
|
+
const adapter = new MyAdapter(config.apiKey)
|
|
48
|
+
ctx.llm.registerAdapter(config.providers, adapter)
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## StreamChunk protocol
|
|
53
|
+
|
|
54
|
+
`stream()` yields chunks using this protocol:
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { brandString } from '@deepseek-ai/dsh-brand'
|
|
58
|
+
import type { StreamChunk, ToolCallId } from '@deepseek-ai/dsh-llm'
|
|
59
|
+
|
|
60
|
+
async function* exampleChunks(): AsyncIterable<StreamChunk> {
|
|
61
|
+
// 1. Start each content block with block-start.
|
|
62
|
+
yield { type: 'block-start', index: 0, blockType: 'text' }
|
|
63
|
+
|
|
64
|
+
// 2. Stream text through text-delta.
|
|
65
|
+
yield { type: 'text-delta', index: 0, text: 'Hello' }
|
|
66
|
+
yield { type: 'text-delta', index: 0, text: ' world' }
|
|
67
|
+
|
|
68
|
+
// 3. End each content block with block-end and the complete block.
|
|
69
|
+
yield {
|
|
70
|
+
type: 'block-end',
|
|
71
|
+
index: 0,
|
|
72
|
+
block: { type: 'text', text: 'Hello world' },
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 4. Tool-call block.
|
|
76
|
+
yield { type: 'block-start', index: 1, blockType: 'tool-call' }
|
|
77
|
+
yield {
|
|
78
|
+
type: 'tool-call-delta',
|
|
79
|
+
index: 1,
|
|
80
|
+
id: brandString<ToolCallId>('call-123'),
|
|
81
|
+
name: 'bash',
|
|
82
|
+
argumentsDelta: '{"command":"ls"}',
|
|
83
|
+
}
|
|
84
|
+
yield {
|
|
85
|
+
type: 'block-end',
|
|
86
|
+
index: 1,
|
|
87
|
+
block: {
|
|
88
|
+
type: 'tool-call',
|
|
89
|
+
id: brandString<ToolCallId>('call-123'),
|
|
90
|
+
name: 'bash',
|
|
91
|
+
arguments: '{"command":"ls"}',
|
|
92
|
+
},
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// 5. Token usage.
|
|
96
|
+
yield { type: 'usage', usage: { inputTokens: 100, outputTokens: 50 } }
|
|
97
|
+
|
|
98
|
+
// 6. Finish reason.
|
|
99
|
+
yield { type: 'finish', reason: { kind: 'stop' } }
|
|
100
|
+
// Alternatively, { kind: 'tool-calls' } requests tool execution.
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Key rules
|
|
105
|
+
|
|
106
|
+
- Every `block-start` has a matching `block-end`.
|
|
107
|
+
- `index` increases from 0 and identifies content-block order.
|
|
108
|
+
- A `tool-call-delta` carries raw JSON text in `argumentsDelta`, either all at once or over multiple chunks.
|
|
109
|
+
- `finish` is the final chunk.
|
|
110
|
+
- Emit `usage` before `finish`.
|
|
111
|
+
|
|
112
|
+
## GenerateOptions
|
|
113
|
+
|
|
114
|
+
`stream()` receives the exported `GenerateOptions` type. It includes the model, adapter-owned reasoning-effort id, conversation history, system prompt, tool schemas, generation parameters, stop sequences, and abort signal; treat the TypeScript type exported by `@deepseek-ai/dsh-llm` as authoritative. Map supported fields to the provider API. If the provider cannot honor a field, throw `LlmError` with a stable code instead of silently dropping it.
|
|
115
|
+
|
|
116
|
+
Override `resolveModel(provider, model, signal?)` to return exact provider/model identity plus optional `context` and `reasoning` metadata in one lookup. Reasoning metadata contains ordered opaque ids and display names plus an optional configured default; preserve the adapter's authoritative selectable list, including `off` when its upstream capability API returns it, instead of promoting those values into a core enum. Honor the optional signal for asynchronous lookup so cancellation and disposal reach quiescence. The service validates the aggregate and rejects unsupported explicit efforts before `stream()`; omitting `reasoning` means that model has no selectable reasoning-effort capability.
|
|
117
|
+
|
|
118
|
+
## Register an adapter
|
|
119
|
+
|
|
120
|
+
```ts ignore-check
|
|
121
|
+
ctx.llm.registerAdapter(['my-provider'], adapter)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The first argument lists provider routes handled by the adapter. `GenerateOptions.provider` selects the registered adapter, while `GenerateOptions.model` passes an adapter-owned model id without lifecycle registration. Override `listModels()` when the adapter can advertise model choices to selectors.
|
|
125
|
+
|
|
126
|
+
## Use it from cordis.yml
|
|
127
|
+
|
|
128
|
+
```yaml
|
|
129
|
+
- id: my-llm
|
|
130
|
+
name: './src/my-llm-adapter.ts'
|
|
131
|
+
config:
|
|
132
|
+
apiKey: !!js process.env.MY_API_KEY
|
|
133
|
+
providers:
|
|
134
|
+
- my-provider
|
|
135
|
+
|
|
136
|
+
- id: agent-loop
|
|
137
|
+
name: '@deepseek-ai/dsh-agent-loop'
|
|
138
|
+
config:
|
|
139
|
+
agents:
|
|
140
|
+
- id: main
|
|
141
|
+
provider: my-provider
|
|
142
|
+
model: my-model-v1
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Reference implementations
|
|
146
|
+
|
|
147
|
+
The repository contains complete implementations:
|
|
148
|
+
|
|
149
|
+
- `packages/llm/llm-deepseek/` — DeepSeek API adapter using the OpenAI-compatible format
|
|
150
|
+
- `packages/llm/llm-pi-ai/` — Pi AI adapter using a different API format
|
|
151
|
+
|
|
152
|
+
Compare the two shipped adapters to see the same harness contract implemented over different provider SDKs.
|
|
153
|
+
|
|
154
|
+
## Error handling
|
|
155
|
+
|
|
156
|
+
Adapters throw transport and protocol failures as `LlmError` values with stable codes. The agent loop preserves the error and code for diagnostics and policy; it does not convert an ordinary `Error` automatically. Every provider HTTP request must also merge `attributionHeaders()` and forward `options.signal`.
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
import {
|
|
160
|
+
attributionHeaders,
|
|
161
|
+
LlmAdapter,
|
|
162
|
+
LlmError,
|
|
163
|
+
type GenerateOptions,
|
|
164
|
+
type StreamChunk,
|
|
165
|
+
} from '@deepseek-ai/dsh-llm'
|
|
166
|
+
|
|
167
|
+
class HttpAdapter extends LlmAdapter {
|
|
168
|
+
constructor(private readonly endpoint: string) {
|
|
169
|
+
super()
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
async *stream(options: GenerateOptions): AsyncIterable<StreamChunk> {
|
|
173
|
+
const response = await fetch(this.endpoint, {
|
|
174
|
+
method: 'POST',
|
|
175
|
+
headers: {
|
|
176
|
+
'content-type': 'application/json',
|
|
177
|
+
...attributionHeaders(),
|
|
178
|
+
},
|
|
179
|
+
body: JSON.stringify({ model: options.model, messages: options.messages }),
|
|
180
|
+
...options.signal ? { signal: options.signal } : {},
|
|
181
|
+
})
|
|
182
|
+
if (!response.ok) {
|
|
183
|
+
throw new LlmError(`Provider API error: ${response.status}`, 'PROVIDER_HTTP_ERROR')
|
|
184
|
+
}
|
|
185
|
+
// A real adapter parses the response and emits the complete chunk sequence.
|
|
186
|
+
yield { type: 'finish', reason: { kind: 'stop' } }
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
```
|