@dipoleml/dcode-cli 1.0.0 → 1.2.0
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/dist/THIRD-PARTY-NOTICES.md +1081 -12
- package/dist/dcode.cjs +59155 -45279
- package/dist/packages/browser-use-plugin/README.md +12 -12
- package/dist/packages/browser-use-plugin/docs/api.json +1 -1
- package/dist/packages/browser-use-plugin/docs/overview.md +5 -4
- package/dist/packages/browser-use-plugin/docs/workflow.md +1 -1
- package/dist/packages/browser-use-plugin/scripts/build.mjs +1 -0
- package/dist/packages/browser-use-plugin/skills/control-browser/SKILL.md +10 -7
- package/dist/packages/bundled-skills/skills/dynamic-workflows/SKILL.md +760 -687
- package/dist/packages/bundled-skills/skills/dynamic-workflows/examples.md +310 -1
- package/dist/packages/bundled-skills/skills/dynamic-workflows/patterns.md +336 -4
- package/dist/packages/node-repl-host/.dcode-plugin/plugin.json +1 -1
- package/dist/packages/node-repl-host/dist/mcp/server.js +9 -14
- package/dist/packages/node-repl-host/scripts/build.mjs +1 -0
- package/dist/provider/dcode-builtin.json +6544 -183
- package/node_modules/@dcode/contracts/dist/compact/index.d.ts +7 -7
- package/node_modules/@dcode/contracts/dist/config/index.d.ts +1 -1
- package/node_modules/@dcode/contracts/dist/events/event-reducer.js +1 -0
- package/node_modules/@dcode/contracts/dist/events/in-memory-session-event-store.js +3 -2
- package/node_modules/@dcode/contracts/dist/events/session-event-retention.d.ts +8 -0
- package/node_modules/@dcode/contracts/dist/events/session-event-retention.js +18 -0
- package/node_modules/@dcode/contracts/dist/events/session.events.d.ts +94 -16
- package/node_modules/@dcode/contracts/dist/events/session.events.js +10 -0
- package/node_modules/@dcode/contracts/dist/hooks/index.d.ts +134 -134
- package/node_modules/@dcode/contracts/dist/hooks/workspace-hook-trust.d.ts +14 -14
- package/node_modules/@dcode/contracts/dist/index.d.ts +2 -0
- package/node_modules/@dcode/contracts/dist/index.js +2 -0
- package/node_modules/@dcode/contracts/dist/interfaces/browser-control.port.d.ts +22 -0
- package/node_modules/@dcode/contracts/dist/interfaces/dynamic-workflow-run-hole.port.d.ts +92 -0
- package/node_modules/@dcode/contracts/dist/interfaces/dynamic-workflow-run-hole.port.js +9 -0
- package/node_modules/@dcode/contracts/dist/interfaces/dynamic-workflow-run-retune.port.d.ts +4 -4
- package/node_modules/@dcode/contracts/dist/interfaces/dynamic-workflow-run-retune.port.js +7 -3
- package/node_modules/@dcode/contracts/dist/interfaces/dynamic-workflow-run-workspace.port.js +8 -3
- package/node_modules/@dcode/contracts/dist/interfaces/dynamic-workflow-run.port.d.ts +119 -18
- package/node_modules/@dcode/contracts/dist/interfaces/dynamic-workflow-run.port.js +13 -0
- package/node_modules/@dcode/contracts/dist/interfaces/index.d.ts +1 -0
- package/node_modules/@dcode/contracts/dist/interfaces/index.js +1 -0
- package/node_modules/@dcode/contracts/dist/interfaces/mcp.port.d.ts +161 -1
- package/node_modules/@dcode/contracts/dist/interfaces/mcp.port.js +17 -0
- package/node_modules/@dcode/contracts/dist/interfaces/permission-full-access.d.ts +15 -15
- package/node_modules/@dcode/contracts/dist/interfaces/permission-full-access.js +1 -1
- package/node_modules/@dcode/contracts/dist/interfaces/permission.port.d.ts +15 -1
- package/node_modules/@dcode/contracts/dist/interfaces/provider-endpoint-routing.port.d.ts +19 -0
- package/node_modules/@dcode/contracts/dist/interfaces/provider-endpoint-routing.port.js +1 -0
- package/node_modules/@dcode/contracts/dist/interfaces/session-store.port.d.ts +4 -2
- package/node_modules/@dcode/contracts/dist/interfaces/session-store.port.js +5 -0
- package/node_modules/@dcode/contracts/dist/interfaces/session.port.d.ts +92 -3
- package/node_modules/@dcode/contracts/dist/interfaces/session.port.js +4 -1
- package/node_modules/@dcode/contracts/dist/interfaces/topic-resource.port.d.ts +25 -0
- package/node_modules/@dcode/contracts/dist/interfaces/topic-resource.port.js +1 -0
- package/node_modules/@dcode/contracts/dist/model/index.d.ts +15 -1
- package/node_modules/@dcode/contracts/dist/model/index.js +5 -0
- package/node_modules/@dcode/contracts/dist/model/invocation-context.d.ts +6 -1
- package/node_modules/@dcode/contracts/dist/plugins/index.d.ts +23 -0
- package/node_modules/@dcode/contracts/dist/plugins/index.js +2 -1
- package/node_modules/@dcode/contracts/dist/telemetry/agent-execution.d.ts +2 -0
- package/node_modules/@dcode/contracts/dist/telemetry/agent-execution.js +2 -0
- package/node_modules/@dcode/contracts/dist/telemetry/index.d.ts +5 -1
- package/node_modules/@dcode/contracts/dist/telemetry/index.js +12 -0
- package/node_modules/@dcode/contracts/dist/tools/agent.d.ts +12 -12
- package/node_modules/@dcode/contracts/dist/tools/amend-workflow.d.ts +39 -15
- package/node_modules/@dcode/contracts/dist/tools/amend-workflow.js +12 -6
- package/node_modules/@dcode/contracts/dist/tools/automation.d.ts +32 -32
- package/node_modules/@dcode/contracts/dist/tools/automation.js +1 -1
- package/node_modules/@dcode/contracts/dist/tools/bash.d.ts +16 -16
- package/node_modules/@dcode/contracts/dist/tools/bash.js +1 -1
- package/node_modules/@dcode/contracts/dist/tools/create-workflow.d.ts +365 -66
- package/node_modules/@dcode/contracts/dist/tools/create-workflow.js +92 -11
- package/node_modules/@dcode/contracts/dist/tools/edit.d.ts +16 -16
- package/node_modules/@dcode/contracts/dist/tools/eval-workflow-snippet.d.ts +6 -6
- package/node_modules/@dcode/contracts/dist/tools/eval-workflow-snippet.js +5 -1
- package/node_modules/@dcode/contracts/dist/tools/fill-workflow-hole.d.ts +729 -0
- package/node_modules/@dcode/contracts/dist/tools/fill-workflow-hole.js +102 -0
- package/node_modules/@dcode/contracts/dist/tools/get-workflow-run.d.ts +136 -28
- package/node_modules/@dcode/contracts/dist/tools/get-workflow-run.js +36 -0
- package/node_modules/@dcode/contracts/dist/tools/grep.d.ts +4 -4
- package/node_modules/@dcode/contracts/dist/tools/grep.js +4 -0
- package/node_modules/@dcode/contracts/dist/tools/index.d.ts +2 -0
- package/node_modules/@dcode/contracts/dist/tools/index.js +4 -0
- package/node_modules/@dcode/contracts/dist/tools/list-saved-workflows.d.ts +8 -8
- package/node_modules/@dcode/contracts/dist/tools/list-workflow-runs.d.ts +8 -8
- package/node_modules/@dcode/contracts/dist/tools/node-repl.d.ts +2 -2
- package/node_modules/@dcode/contracts/dist/tools/off-peak.d.ts +3 -3
- package/node_modules/@dcode/contracts/dist/tools/off-peak.js +2 -2
- package/node_modules/@dcode/contracts/dist/tools/performance.d.ts +22 -22
- package/node_modules/@dcode/contracts/dist/tools/plan-mode.d.ts +12 -12
- package/node_modules/@dcode/contracts/dist/tools/plan-mode.js +6 -4
- package/node_modules/@dcode/contracts/dist/tools/read-session-context.d.ts +86 -13
- package/node_modules/@dcode/contracts/dist/tools/read-session-context.js +37 -6
- package/node_modules/@dcode/contracts/dist/tools/read.d.ts +38 -38
- package/node_modules/@dcode/contracts/dist/tools/save-workflow.d.ts +21 -10
- package/node_modules/@dcode/contracts/dist/tools/save-workflow.js +22 -2
- package/node_modules/@dcode/contracts/dist/tools/saved-workflow.d.ts +4 -4
- package/node_modules/@dcode/contracts/dist/tools/send-message.d.ts +2 -2
- package/node_modules/@dcode/contracts/dist/tools/skill.js +1 -0
- package/node_modules/@dcode/contracts/dist/tools/task-output.d.ts +6 -6
- package/node_modules/@dcode/contracts/dist/tools/tool-result-metadata.d.ts +1228 -259
- package/node_modules/@dcode/contracts/dist/tools/tool-result-metadata.js +41 -0
- package/node_modules/@dcode/contracts/dist/tools/webfetch.d.ts +2 -2
- package/node_modules/@dcode/contracts/dist/tools/workflow-observation-display.d.ts +20 -20
- package/node_modules/@dcode/contracts/dist/tools/workflow-settings.d.ts +55 -0
- package/node_modules/@dcode/contracts/dist/tools/workflow-settings.js +86 -0
- package/node_modules/@dcode/contracts/dist/tools/workflow.d.ts +8 -8
- package/node_modules/@dcode/contracts/dist/tools/write.d.ts +18 -18
- package/node_modules/@dcode/contracts/dist/workflow/index.d.ts +98 -98
- package/node_modules/@dcode/contracts/dist/workflow/script.d.ts +12 -12
- package/node_modules/@dcode/i18n/dist/index.js +2 -2
- package/node_modules/@dcode/i18n/dist/locale.d.ts +1 -1
- package/node_modules/@dcode/i18n/dist/locale.js +4 -4
- package/node_modules/@dcode/i18n/dist/locales/en-US.js +5 -5
- package/node_modules/@dcode/i18n/dist/locales/fr-CA.d.ts +3 -0
- package/node_modules/@dcode/i18n/dist/locales/fr-CA.js +354 -0
- package/node_modules/@dcode/model-option-map/package.json +1 -1
- package/node_modules/@dcode/shared/dist/api-key-usage-scene.d.ts +7 -0
- package/node_modules/@dcode/shared/dist/api-key-usage-scene.js +6 -0
- package/node_modules/@dcode/shared/dist/attachment-source.d.ts +8 -0
- package/node_modules/@dcode/shared/dist/attachment-source.js +4 -0
- package/node_modules/@dcode/shared/dist/background-bash-output.d.ts +4 -4
- package/node_modules/@dcode/shared/dist/bots.d.ts +759 -11
- package/node_modules/@dcode/shared/dist/bots.js +236 -2
- package/node_modules/@dcode/shared/dist/browser-use/command-metadata.d.ts +2 -2
- package/node_modules/@dcode/shared/dist/browser-use/commands.d.ts +4 -3
- package/node_modules/@dcode/shared/dist/browser-use/commands.js +3 -1
- package/node_modules/@dcode/shared/dist/browser-use/nodeReplBroker.d.ts +5 -4
- package/node_modules/@dcode/shared/dist/browser-use/result.d.ts +6 -6
- package/node_modules/@dcode/shared/dist/channel-mention.d.ts +173 -0
- package/node_modules/@dcode/shared/dist/channel-mention.js +120 -0
- package/node_modules/@dcode/shared/dist/channels.d.ts +128 -1
- package/node_modules/@dcode/shared/dist/channels.js +66 -0
- package/node_modules/@dcode/shared/dist/clientConfig.d.ts +1 -0
- package/node_modules/@dcode/shared/dist/clientConfig.js +18 -2
- package/node_modules/@dcode/shared/dist/cloudContent.d.ts +160 -0
- package/node_modules/@dcode/shared/dist/cloudContent.js +116 -0
- package/node_modules/@dcode/shared/dist/coding-plan-subscription.d.ts +59 -0
- package/node_modules/@dcode/shared/dist/conversation-message-projection-policy.js +2 -0
- package/node_modules/@dcode/shared/dist/conversation-share.d.ts +378 -74
- package/node_modules/@dcode/shared/dist/conversation-share.js +8 -6
- package/node_modules/@dcode/shared/dist/conversationSelection.d.ts +23 -0
- package/node_modules/@dcode/shared/dist/conversationSelection.js +30 -0
- package/node_modules/@dcode/shared/dist/database-startup.d.ts +5 -5
- package/node_modules/@dcode/shared/dist/dcode-agent-model-state.js +14 -6
- package/node_modules/@dcode/shared/dist/dcode-agent-policy.d.ts +16 -1
- package/node_modules/@dcode/shared/dist/dcode-agent-policy.js +17 -1
- package/node_modules/@dcode/shared/dist/dcode-agent-runtime.js +1 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol/index.d.ts +3215 -1800
- package/node_modules/@dcode/shared/dist/dcode-protocol/index.js +555 -24
- package/node_modules/@dcode/shared/dist/dcode-protocol/trace.d.ts +9 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol/trace.js +10 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-legacy-types.d.ts +30 -20
- package/node_modules/@dcode/shared/dist/dcode-protocol-legacy-types.js +3 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/apply.js +12 -3
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/attachment-ref.d.ts +5 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/attachment-ref.js +3 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/coalesce.d.ts +3 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/coalesce.js +3 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/command.d.ts +388 -57
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/command.js +67 -45
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/controller.d.ts +208 -103
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/create-session-config.d.ts +20 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/create-session-config.js +15 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/create-workflow-display.d.ts +34 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/create-workflow-display.js +45 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/delta.d.ts +1453 -278
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/delta.js +45 -2
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/index.d.ts +1 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/index.js +1 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/input-intent.d.ts +173 -6
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/input-intent.js +29 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/rows.d.ts +731 -125
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/rows.js +23 -11
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/sessions-index-workflow-activity.d.ts +30 -11
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/sessions-index-workflow-activity.js +35 -3
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/sessions-index.d.ts +40 -25
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/snapshot.d.ts +1444 -216
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/snapshot.js +3 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/submission.d.ts +1 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/submission.js +1 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/telemetry.d.ts +62 -58
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/toolDisplay.d.ts +185 -50
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/toolDisplay.js +31 -3
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/transport.d.ts +7728 -1585
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/transport.js +18 -5
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/wire-assembler.js +2 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/wire-fault.js +4 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/wire-reassembly.js +5 -3
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-artifacts.d.ts +29 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-artifacts.js +64 -4
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-command-rejections.d.ts +13 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-command-rejections.js +23 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-observation-display.d.ts +14 -14
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-row-meta.d.ts +52 -8
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-row-meta.js +22 -3
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-run-settings-command.d.ts +4 -4
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-run-settings-command.js +2 -2
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-actor-session.d.ts +21 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-actor-session.js +44 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-actor-status.d.ts +1 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-actor-status.js +3 -2
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-caps.js +5 -4
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-concurrency.d.ts +26 -19
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-concurrency.js +40 -32
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-delta.d.ts +4 -3
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-delta.js +4 -3
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-entries.d.ts +12 -2
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-entries.js +44 -6
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-eviction.d.ts +2 -2
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-eviction.js +17 -10
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-holes.d.ts +33 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-holes.js +202 -0
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-legacy.d.ts +1 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-legacy.js +1 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-phases.js +10 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-reducer.d.ts +1 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-reducer.js +29 -22
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-started.js +5 -2
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-tables.js +2 -1
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs-unlisted.js +6 -3
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs.d.ts +125 -40
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-runs.js +101 -26
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workflow-workspace.d.ts +4 -4
- package/node_modules/@dcode/shared/dist/dcode-protocol-v4/workspace-hook-review.d.ts +1 -1
- package/node_modules/@dcode/shared/dist/dcode-session-content-profile.d.ts +5 -0
- package/node_modules/@dcode/shared/dist/dcode-session-content-profile.js +49 -0
- package/node_modules/@dcode/shared/dist/dcode-slash-command-help.js +4 -4
- package/node_modules/@dcode/shared/dist/dcode-task-mode-schema.d.ts +6 -1
- package/node_modules/@dcode/shared/dist/dcode-task-mode-schema.js +13 -1
- package/node_modules/@dcode/shared/dist/dcode-task-types-core.d.ts +12 -2
- package/node_modules/@dcode/shared/dist/dcode-task-types.d.ts +23 -0
- package/node_modules/@dcode/shared/dist/dcodeEndpoint.d.ts +22 -1
- package/node_modules/@dcode/shared/dist/dcodeEndpoint.js +102 -17
- package/node_modules/@dcode/shared/dist/desktopMenu.js +48 -48
- package/node_modules/@dcode/shared/dist/dynamic-workflow-feature.d.ts +35 -6
- package/node_modules/@dcode/shared/dist/dynamic-workflow-feature.js +45 -6
- package/node_modules/@dcode/shared/dist/env.d.ts +5 -4
- package/node_modules/@dcode/shared/dist/env.js +9 -9
- package/node_modules/@dcode/shared/dist/errors.d.ts +24 -0
- package/node_modules/@dcode/shared/dist/errors.js +54 -0
- package/node_modules/@dcode/shared/dist/execution-state.d.ts +4 -2
- package/node_modules/@dcode/shared/dist/execution-state.js +1 -1
- package/node_modules/@dcode/shared/dist/feedback.d.ts +1 -1
- package/node_modules/@dcode/shared/dist/gen-ui/contract.d.ts +140 -0
- package/node_modules/@dcode/shared/dist/gen-ui/contract.example.d.ts +5 -0
- package/node_modules/@dcode/shared/dist/gen-ui/contract.example.js +36 -0
- package/node_modules/@dcode/shared/dist/gen-ui/contract.js +196 -0
- package/node_modules/@dcode/shared/dist/gen-ui/contract.test.d.ts +2 -0
- package/node_modules/@dcode/shared/dist/gen-ui/contract.test.js +75 -0
- package/node_modules/@dcode/shared/dist/gen-ui/index.d.ts +2 -0
- package/node_modules/@dcode/shared/dist/gen-ui/index.js +2 -0
- package/node_modules/@dcode/shared/dist/gen-ui/module.d.ts +7 -0
- package/node_modules/@dcode/shared/dist/gen-ui/module.js +7 -0
- package/node_modules/@dcode/shared/dist/gen-ui/tweakProtocol.d.ts +202 -0
- package/node_modules/@dcode/shared/dist/gen-ui/tweakProtocol.js +126 -0
- package/node_modules/@dcode/shared/dist/helpAppConfig.d.ts +1 -1
- package/node_modules/@dcode/shared/dist/helpAppConfig.js +2 -2
- package/node_modules/@dcode/shared/dist/highspeed.d.ts +181 -0
- package/node_modules/@dcode/shared/dist/highspeed.js +112 -0
- package/node_modules/@dcode/shared/dist/index.d.ts +27 -5
- package/node_modules/@dcode/shared/dist/index.js +24 -2
- package/node_modules/@dcode/shared/dist/localTtft.d.ts +27 -27
- package/node_modules/@dcode/shared/dist/marketingTouch.d.ts +930 -0
- package/node_modules/@dcode/shared/dist/marketingTouch.js +170 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/appTools.d.ts +83 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/appTools.js +124 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/content.d.ts +4 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/content.js +8 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/contract.d.ts +241 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/contract.example.d.ts +31 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/contract.example.js +42 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/contract.js +101 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/contract.test.d.ts +2 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/contract.test.js +64 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/hostContract.d.ts +47 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/hostContract.js +8 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/index.d.ts +9 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/index.js +9 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/instance.d.ts +10 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/instance.js +11 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/module.d.ts +12 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/module.js +12 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/resourceMime.d.ts +8 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/resourceMime.js +73 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/sampling.d.ts +101 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/sampling.js +107 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/sampling.test.d.ts +2 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/sampling.test.js +55 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/schemas.d.ts +78 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/schemas.js +65 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/toolMeta.d.ts +39 -0
- package/node_modules/@dcode/shared/dist/mcp-apps/toolMeta.js +199 -0
- package/node_modules/@dcode/shared/dist/mcp.d.ts +6 -2
- package/node_modules/@dcode/shared/dist/memory.d.ts +9 -0
- package/node_modules/@dcode/shared/dist/memory.js +2 -0
- package/node_modules/@dcode/shared/dist/model-execution.d.ts +31 -0
- package/node_modules/@dcode/shared/dist/model-execution.js +38 -0
- package/node_modules/@dcode/shared/dist/networkCapture.d.ts +49 -0
- package/node_modules/@dcode/shared/dist/networkCapture.js +41 -0
- package/node_modules/@dcode/shared/dist/node/genUiPaths.d.ts +6 -0
- package/node_modules/@dcode/shared/dist/node/genUiPaths.js +16 -0
- package/node_modules/@dcode/shared/dist/node/genUiPaths.test.d.ts +2 -0
- package/node_modules/@dcode/shared/dist/node/genUiPaths.test.js +30 -0
- package/node_modules/@dcode/shared/dist/node/networkCapture.d.ts +8 -0
- package/node_modules/@dcode/shared/dist/node/networkCapture.js +96 -0
- package/node_modules/@dcode/shared/dist/node/officialPluginCache.d.ts +1 -2
- package/node_modules/@dcode/shared/dist/node/subagentMarkdownMigration.d.ts +1 -2
- package/node_modules/@dcode/shared/dist/node.d.ts +2 -0
- package/node_modules/@dcode/shared/dist/node.js +2 -0
- package/node_modules/@dcode/shared/dist/output-style.d.ts +17 -0
- package/node_modules/@dcode/shared/dist/output-style.js +2 -0
- package/node_modules/@dcode/shared/dist/platform.d.ts +149 -1
- package/node_modules/@dcode/shared/dist/platform.js +2 -0
- package/node_modules/@dcode/shared/dist/platformUpdate.d.ts +61 -0
- package/node_modules/@dcode/shared/dist/platformUpdate.js +2 -0
- package/node_modules/@dcode/shared/dist/plugin-marketplaces.d.ts +5 -0
- package/node_modules/@dcode/shared/dist/plugin-marketplaces.js +20 -14
- package/node_modules/@dcode/shared/dist/project-access-token-client.d.ts +42 -0
- package/node_modules/@dcode/shared/dist/project-access-token-client.js +260 -0
- package/node_modules/@dcode/shared/dist/project-access-token-response.d.ts +4 -0
- package/node_modules/@dcode/shared/dist/project-access-token-response.js +9 -0
- package/node_modules/@dcode/shared/dist/project-access-token.d.ts +45 -0
- package/node_modules/@dcode/shared/dist/project-access-token.js +164 -0
- package/node_modules/@dcode/shared/dist/protocol.d.ts +46 -4
- package/node_modules/@dcode/shared/dist/protocol.js +1 -1
- package/node_modules/@dcode/shared/dist/provider-provisioning.d.ts +26 -2
- package/node_modules/@dcode/shared/dist/provider-provisioning.js +19 -3
- package/node_modules/@dcode/shared/dist/providers.d.ts +1 -2
- package/node_modules/@dcode/shared/dist/providers.js +1 -1
- package/node_modules/@dcode/shared/dist/remote-workspace-identity.d.ts +6 -1
- package/node_modules/@dcode/shared/dist/remote-workspace-identity.js +35 -1
- package/node_modules/@dcode/shared/dist/remoteAppConfig.js +1 -1
- package/node_modules/@dcode/shared/dist/remoteEnvironmentKey.js +19 -0
- package/node_modules/@dcode/shared/dist/remoteTarget.d.ts +14 -1
- package/node_modules/@dcode/shared/dist/remoteTarget.js +4 -0
- package/node_modules/@dcode/shared/dist/remoteUsageTelemetry.d.ts +27 -0
- package/node_modules/@dcode/shared/dist/remoteUsageTelemetry.js +43 -0
- package/node_modules/@dcode/shared/dist/rendererActionTrace.d.ts +35 -35
- package/node_modules/@dcode/shared/dist/request-security-edition/index.d.ts +3 -0
- package/node_modules/@dcode/shared/dist/request-security-edition/index.js +3 -0
- package/node_modules/@dcode/shared/dist/request-security-edition/policy.d.ts +3 -0
- package/node_modules/@dcode/shared/dist/request-security-edition/policy.js +5 -0
- package/node_modules/@dcode/shared/dist/request-security-edition/verification-policy.d.ts +19 -0
- package/node_modules/@dcode/shared/dist/request-security-edition/verification-policy.js +29 -0
- package/node_modules/@dcode/shared/dist/rewardsBridge.d.ts +8 -0
- package/node_modules/@dcode/shared/dist/rewardsBridge.js +80 -0
- package/node_modules/@dcode/shared/dist/rewardsEmbedded.d.ts +37 -0
- package/node_modules/@dcode/shared/dist/rewardsEmbedded.js +50 -0
- package/node_modules/@dcode/shared/dist/sessionCreateTelemetry.d.ts +3 -3
- package/node_modules/@dcode/shared/dist/subagent-profile-frontmatter.d.ts +10 -0
- package/node_modules/@dcode/shared/dist/subagent-profile-frontmatter.js +212 -0
- package/node_modules/@dcode/shared/dist/subagent-profile-parser.d.ts +10 -0
- package/node_modules/@dcode/shared/dist/subagent-profile-parser.js +200 -0
- package/node_modules/@dcode/shared/dist/subagent-profile.d.ts +82 -0
- package/node_modules/@dcode/shared/dist/subagent-profile.js +28 -0
- package/node_modules/@dcode/shared/dist/subagent-runtime-config.d.ts +135 -0
- package/node_modules/@dcode/shared/dist/subagent-runtime-config.js +39 -0
- package/node_modules/@dcode/shared/dist/subagents-types.d.ts +1 -1
- package/node_modules/@dcode/shared/dist/task-realtime-core.d.ts +57 -24
- package/node_modules/@dcode/shared/dist/task-realtime-core.js +8 -2
- package/node_modules/@dcode/shared/dist/test-ids-workflow.d.ts +4 -0
- package/node_modules/@dcode/shared/dist/test-ids-workflow.js +5 -0
- package/node_modules/@dcode/shared/dist/test-ids.d.ts +25 -0
- package/node_modules/@dcode/shared/dist/test-ids.js +25 -0
- package/node_modules/@dcode/shared/dist/tool-identity.d.ts +1 -1
- package/node_modules/@dcode/shared/dist/tool-identity.js +4 -0
- package/node_modules/@dcode/shared/dist/tool-plan-adapter.js +14 -1
- package/node_modules/@dcode/shared/dist/usage-stats.d.ts +13 -0
- package/node_modules/@dcode/shared/dist/validation.d.ts +1542 -166
- package/node_modules/@dcode/shared/dist/validation.js +423 -14
- package/node_modules/@dcode/shared/dist/validationAppSettings.d.ts +70 -14
- package/node_modules/@dcode/shared/dist/validationAppSettings.js +74 -12
- package/node_modules/@dcode/shared/dist/web-remote-control-heartbeat.d.ts +8 -0
- package/node_modules/@dcode/shared/dist/web-remote-control-heartbeat.js +40 -0
- package/node_modules/@dcode/shared/dist/web-remote-control-rpc-transport.d.ts +183 -0
- package/node_modules/@dcode/shared/dist/web-remote-control-rpc-transport.js +562 -0
- package/node_modules/@dcode/shared/dist/web-remote-control.d.ts +645 -0
- package/node_modules/@dcode/shared/dist/web-remote-control.js +174 -0
- package/node_modules/@dcode/shared/package.json +5 -2
- package/node_modules/@dcode/tui/dist/app-approval-panel.js +3 -2
- package/node_modules/@dcode/tui/dist/app-approval.d.ts +3 -1
- package/node_modules/@dcode/tui/dist/app-approval.js +9 -5
- package/node_modules/@dcode/tui/dist/app-compact-timeline.d.ts +3 -0
- package/node_modules/@dcode/tui/dist/app-compact-timeline.js +5 -2
- package/node_modules/@dcode/tui/dist/app-empty-transcript.d.ts +1 -0
- package/node_modules/@dcode/tui/dist/app-empty-transcript.js +1 -1
- package/node_modules/@dcode/tui/dist/app-file-mentions.d.ts +2 -0
- package/node_modules/@dcode/tui/dist/app-file-mentions.js +2 -2
- package/node_modules/@dcode/tui/dist/app-input-pane.d.ts +38 -0
- package/node_modules/@dcode/tui/dist/app-input-pane.js +19 -19
- package/node_modules/@dcode/tui/dist/app-input-status.d.ts +17 -0
- package/node_modules/@dcode/tui/dist/app-input-status.js +4 -4
- package/node_modules/@dcode/tui/dist/app-input.d.ts +1 -0
- package/node_modules/@dcode/tui/dist/app-input.js +1 -1
- package/node_modules/@dcode/tui/dist/app-markdown-theme.d.ts +2 -1
- package/node_modules/@dcode/tui/dist/app-markdown-theme.js +1 -1
- package/node_modules/@dcode/tui/dist/app-markdown.d.ts +1 -0
- package/node_modules/@dcode/tui/dist/app-markdown.js +1 -1
- package/node_modules/@dcode/tui/dist/app-mode-command.d.ts +3 -0
- package/node_modules/@dcode/tui/dist/app-mode-command.js +4 -4
- package/node_modules/@dcode/tui/dist/app-mode-suggestion-panel.d.ts +5 -0
- package/node_modules/@dcode/tui/dist/app-mode-suggestion-panel.js +1 -1
- package/node_modules/@dcode/tui/dist/app-mode.d.ts +1 -1
- package/node_modules/@dcode/tui/dist/app-mode.js +1 -1
- package/node_modules/@dcode/tui/dist/app-model-ref.d.ts +1 -0
- package/node_modules/@dcode/tui/dist/app-model-ref.js +1 -1
- package/node_modules/@dcode/tui/dist/app-motion.d.ts +13 -0
- package/node_modules/@dcode/tui/dist/app-motion.js +17 -7
- package/node_modules/@dcode/tui/dist/app-session-event-handler.d.ts +33 -0
- package/node_modules/@dcode/tui/dist/app-session-event-handler.js +4 -4
- package/node_modules/@dcode/tui/dist/app-shiki-diff-view.d.ts +18 -1
- package/node_modules/@dcode/tui/dist/app-shiki-diff-view.js +3 -3
- package/node_modules/@dcode/tui/dist/app-shiki-highlighter.d.ts +3 -0
- package/node_modules/@dcode/tui/dist/app-shiki-highlighter.js +7 -2
- package/node_modules/@dcode/tui/dist/app-sidebar-layout.d.ts +10 -0
- package/node_modules/@dcode/tui/dist/app-sidebar-layout.js +4 -4
- package/node_modules/@dcode/tui/dist/app-submit.d.ts +1 -0
- package/node_modules/@dcode/tui/dist/app-submit.js +1 -1
- package/node_modules/@dcode/tui/dist/app-thought-components.d.ts +7 -0
- package/node_modules/@dcode/tui/dist/app-thought-components.js +2 -2
- package/node_modules/@dcode/tui/dist/app-tool-transcript.d.ts +1 -0
- package/node_modules/@dcode/tui/dist/app-tool-transcript.js +3 -0
- package/node_modules/@dcode/tui/dist/app-view.d.ts +27 -0
- package/node_modules/@dcode/tui/dist/app-view.js +1 -1
- package/node_modules/@dcode/tui/dist/app-workflow-card.js +1 -1
- package/node_modules/@dcode/tui/dist/app-workflow-seed.d.ts +18 -1
- package/node_modules/@dcode/tui/dist/app-workflow-seed.js +4 -4
- package/node_modules/@dcode/tui/dist/index.js +5117 -2578
- package/node_modules/@dcode/tui/dist/tui.d.ts +3 -0
- package/node_modules/@dcode/tui/dist/tui.js +1 -1
- package/node_modules/@dcode/tui/dist/types.d.ts +1 -1
- package/node_modules/oniguruma-parser/LICENSE +1 -1
- package/node_modules/oniguruma-parser/README.md +15 -61
- package/node_modules/oniguruma-parser/dist/oniguruma-parser.min.js +4 -4
- package/node_modules/oniguruma-parser/dist/parser/parse.js +1 -1
- package/node_modules/oniguruma-parser/dist/traverser/traverse.js +1 -1
- package/node_modules/oniguruma-parser/package.json +5 -5
- package/node_modules/oniguruma-to-es/dist/cjs/generate.d.ts +1 -1
- package/node_modules/oniguruma-to-es/dist/cjs/index.js +121 -120
- package/node_modules/oniguruma-to-es/dist/cjs/subclass.d.ts +2 -2
- package/node_modules/oniguruma-to-es/dist/cjs/transform.d.ts +3 -5
- package/node_modules/oniguruma-to-es/dist/cjs/unicode.d.ts +1 -1
- package/node_modules/oniguruma-to-es/dist/esm/generate.d.ts +1 -1
- package/node_modules/oniguruma-to-es/dist/esm/index.js +1 -3
- package/node_modules/oniguruma-to-es/dist/esm/subclass.d.ts +2 -2
- package/node_modules/oniguruma-to-es/dist/esm/transform.d.ts +3 -5
- package/node_modules/oniguruma-to-es/dist/esm/unicode.d.ts +1 -1
- package/node_modules/oniguruma-to-es/dist/index.min.js +6 -6
- package/node_modules/oniguruma-to-es/package.json +5 -5
- package/package.json +5 -5
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { MCP_APPS_CSP_RELAXATION_META_KEY, MCP_APPS_SET_WIDGET_STATE_METHOD, PLUGIN_SANDBOX_PORT_NAME, buildMcpAppsClientCapabilities, buildMcpAppsCspExperimentalCapability, } from "./contract.js";
|
|
2
|
+
/** 一个带 UI 资源的工具 `_meta` 归一化后应得到的描述。 */
|
|
3
|
+
export const exampleToolUiDescriptor = {
|
|
4
|
+
resourceUri: "ui://example-plugin/widget.html",
|
|
5
|
+
visibility: ["model", "app"],
|
|
6
|
+
preferredDisplayMode: "inline",
|
|
7
|
+
csp: { connectDomains: ["https://api.example.com"], resourceDomains: [] },
|
|
8
|
+
prefersBorder: true,
|
|
9
|
+
};
|
|
10
|
+
/** main 登记成功后返回给 renderer 的句柄;partition 按 server 身份派生,同一 server 的页面共享。 */
|
|
11
|
+
export const exampleSandboxHandle = {
|
|
12
|
+
instance: {
|
|
13
|
+
runtimeId: "test-agent",
|
|
14
|
+
generation: 1,
|
|
15
|
+
token: "test-token",
|
|
16
|
+
appIdentity: "a".repeat(64),
|
|
17
|
+
},
|
|
18
|
+
sandboxId: "sb-01",
|
|
19
|
+
initId: 1,
|
|
20
|
+
shellUrl: "dcode-sandbox://shell-sb-01/",
|
|
21
|
+
partition: "persist:plugin-sandbox-v1-0123456789abcdef",
|
|
22
|
+
// 句柄能带的全部资源级字段都写上:contract.test 用它过 host 的 strict 回包 schema,字段漏同步会在这里失败。
|
|
23
|
+
resourceMeta: {
|
|
24
|
+
prefersBorder: true,
|
|
25
|
+
heightHint: 320,
|
|
26
|
+
minFrameHeight: 120,
|
|
27
|
+
showInline: false,
|
|
28
|
+
permissions: ["clipboardWrite"],
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
/** agent 对 MCP server `initialize` 时宣告的 ui 扩展能力。 */
|
|
32
|
+
export const exampleClientCapabilities = buildMcpAppsClientCapabilities();
|
|
33
|
+
/** 宿主在 hostCapabilities.experimental 里宣告的 CSP 放宽键。 */
|
|
34
|
+
export const exampleCspExperimental = buildMcpAppsCspExperimentalCapability();
|
|
35
|
+
/** 资源级 `_meta` 里声明放宽的写法。 */
|
|
36
|
+
export const exampleResourceMetaWithRelaxations = {
|
|
37
|
+
ui: { csp: { connectDomains: ["https://api.example.com"] } },
|
|
38
|
+
[MCP_APPS_CSP_RELAXATION_META_KEY]: { unsafeEval: true },
|
|
39
|
+
};
|
|
40
|
+
export const exampleSetWidgetStateMethod = MCP_APPS_SET_WIDGET_STATE_METHOD;
|
|
41
|
+
export const examplePortName = PLUGIN_SANDBOX_PORT_NAME;
|
|
42
|
+
//# sourceMappingURL=contract.example.js.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Apps 协议契约:agent、host、renderer 与 main 共用的常量、工具 UI 元数据类型、沙箱句柄与登记载荷。
|
|
3
|
+
* 页面 ↔ 宿主的线协议(`ui/*` 方法、握手、版本协商、JSON-RPC)由官方 `@modelcontextprotocol/ext-apps` 定义,
|
|
4
|
+
* 这里只保留 DCode 自己的扩展键与限额。只放类型与常量;归一化与 schema 在同目录其他文件,经 index.ts 导出。
|
|
5
|
+
*/
|
|
6
|
+
/** MCP 扩展标识(规范「Extension Identifier」);与官方 SDK `EXTENSION_ID` 一致。 */
|
|
7
|
+
export const MCP_APPS_EXTENSION_ID = "io.modelcontextprotocol/ui";
|
|
8
|
+
/** UI 资源 mimeType(规范 MUST);与官方 SDK `RESOURCE_MIME_TYPE` 一致。 */
|
|
9
|
+
export const MCP_APPS_RESOURCE_MIME_TYPE = "text/html;profile=mcp-app";
|
|
10
|
+
/** 弃用的扁平键 `_meta["ui/resourceUri"]`;规范要求宿主 MUST 同时兼容,与官方 SDK `RESOURCE_URI_META_KEY` 一致。 */
|
|
11
|
+
export const MCP_APPS_LEGACY_RESOURCE_URI_META_KEY = "ui/resourceUri";
|
|
12
|
+
/** agent 对每个 MCP server 宣告的能力片段;放进 `Client` 构造参数的 `capabilities.extensions`。 */
|
|
13
|
+
export function buildMcpAppsClientCapabilities() {
|
|
14
|
+
return { extensions: { [MCP_APPS_EXTENSION_ID]: { mimeTypes: [MCP_APPS_RESOURCE_MIME_TYPE] } } };
|
|
15
|
+
}
|
|
16
|
+
/** 宿主 hostInfo.name;hostInfo.version 只供页面 feature detect,与应用版本无关。 */
|
|
17
|
+
export const MCP_APPS_HOST_NAME = "dcode";
|
|
18
|
+
export const MCP_APPS_HOST_VERSION = "1";
|
|
19
|
+
/** `ui/initialize` 握手超时(端口到达起算)与卸载前 `ui/resource-teardown` 的等待上限。 */
|
|
20
|
+
export const MCP_APPS_HANDSHAKE_TIMEOUT_MS = 15_000;
|
|
21
|
+
export const MCP_APPS_TEARDOWN_TIMEOUT_MS = 500;
|
|
22
|
+
export const MCP_APPS_DEFAULT_TOOL_VISIBILITY = ["model", "app"];
|
|
23
|
+
/**
|
|
24
|
+
* 资源级 `_meta["dcode/csp"]`:宿主缺省按规范块(只有 'self' 'unsafe-inline'),不放行 `'unsafe-eval'` /
|
|
25
|
+
* `'wasm-unsafe-eval'`;需要 eval / WebAssembly 的资源在这里显式声明。宿主经
|
|
26
|
+
* `hostCapabilities.experimental["dcode/csp"].flags` 宣告支持的键。
|
|
27
|
+
*/
|
|
28
|
+
export const MCP_APPS_CSP_RELAXATION_META_KEY = "dcode/csp";
|
|
29
|
+
export const MCP_APPS_CSP_RELAXATION_FLAGS = ["unsafeEval", "wasmUnsafeEval"];
|
|
30
|
+
export function buildMcpAppsCspExperimentalCapability() {
|
|
31
|
+
return { [MCP_APPS_CSP_RELAXATION_META_KEY]: { flags: [...MCP_APPS_CSP_RELAXATION_FLAGS] } };
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 资源可声明的浏览器权限(规范草案 `UIResourceMeta.permissions` 的四键),顺序即归一化顺序。
|
|
35
|
+
* 宿主:未声明一律拒绝;camera / microphone / geolocation 首次使用时原生弹框确认,clipboardWrite 按声明放行。
|
|
36
|
+
*/
|
|
37
|
+
export const MCP_APPS_RESOURCE_PERMISSIONS = [
|
|
38
|
+
"camera",
|
|
39
|
+
"microphone",
|
|
40
|
+
"geolocation",
|
|
41
|
+
"clipboardWrite",
|
|
42
|
+
];
|
|
43
|
+
/** 规范权限键 → 插件 iframe `allow` 的 Permissions Policy 特性名。 */
|
|
44
|
+
export const MCP_APPS_IFRAME_ALLOW_TOKENS = {
|
|
45
|
+
camera: "camera",
|
|
46
|
+
microphone: "microphone",
|
|
47
|
+
geolocation: "geolocation",
|
|
48
|
+
clipboardWrite: "clipboard-write",
|
|
49
|
+
};
|
|
50
|
+
/** 与官方 SDK `buildAllowAttribute` 同形:`"camera; clipboard-write"`;没有声明返回空串。 */
|
|
51
|
+
export function buildMcpAppsIframeAllow(permissions) {
|
|
52
|
+
if (!permissions?.length)
|
|
53
|
+
return "";
|
|
54
|
+
return MCP_APPS_RESOURCE_PERMISSIONS.filter((key) => permissions.includes(key))
|
|
55
|
+
.map((key) => MCP_APPS_IFRAME_ALLOW_TOKENS[key])
|
|
56
|
+
.join("; ");
|
|
57
|
+
}
|
|
58
|
+
/** `_meta.ui.surface` / 清单 surface id 的长度与字符集(与 sandboxId 同源:可进 CSP host-source)。 */
|
|
59
|
+
export const MCP_APPS_SURFACE_ID_MAX_CHARS = 128;
|
|
60
|
+
export const MCP_APPS_SURFACE_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_.-]*$/;
|
|
61
|
+
export const MCP_APPS_UI_RESOURCE_SCHEME = "ui://";
|
|
62
|
+
export const MCP_APPS_RESOURCE_URI_MAX_CHARS = 2048;
|
|
63
|
+
/**
|
|
64
|
+
* `display.ui.structuredContent` / `widgetMeta` / `content` 的持久化上限(JSON 文本的 UTF-8 字节)。
|
|
65
|
+
* 超限不截断字符串(半截 JSON 没有意义):字段整个省略,`truncated: true` 且 `truncatedBytes` 记被丢弃的字节数;
|
|
66
|
+
* 页面侧 `toolOutput` 为 null、`toolResponseMetadata["dcode/truncated"] = { bytes }`,可用 tools/call 重取。
|
|
67
|
+
*/
|
|
68
|
+
export const MCP_APPS_STRUCTURED_CONTENT_MAX_BYTES = 64 * 1024;
|
|
69
|
+
export const MCP_APPS_WIDGET_META_MAX_BYTES = 16 * 1024;
|
|
70
|
+
export const MCP_APPS_CONTENT_MAX_BYTES = 32 * 1024;
|
|
71
|
+
export const MCP_APPS_TRUNCATED_META_KEY = "dcode/truncated";
|
|
72
|
+
/** host 侧接受的 `ui://` HTML 上限与 mimeType 白名单(规范只认带 profile 的;无 profile 的 text/html 是有意的宽松超集)。 */
|
|
73
|
+
// 官方 pdf-server 示例的单文件页面(内联 pdf.js)就有 4.3 MB,4 MiB 会把它拒掉;放到 16 MiB。
|
|
74
|
+
export const MCP_APPS_HTML_MAX_BYTES = 16 * 1024 * 1024;
|
|
75
|
+
export const MCP_APPS_HTML_MIME_TYPES = [MCP_APPS_RESOURCE_MIME_TYPE, "text/html"];
|
|
76
|
+
/**
|
|
77
|
+
* 页面经 ui/update-model-context 与 ui/message 送来的 image 块:白名单三种位图,单张解码后 ≤ 4 MiB;
|
|
78
|
+
* 不在白名单或超限整个请求 -32602 `unsupported_content`。
|
|
79
|
+
*/
|
|
80
|
+
export const MCP_APPS_IMAGE_MIME_TYPES = ["image/png", "image/jpeg", "image/webp"];
|
|
81
|
+
export const MCP_APPS_IMAGE_MAX_BYTES = 4 * 1024 * 1024;
|
|
82
|
+
export { MCP_APPS_UI_READ_RESOURCE_MAX_BYTES, MCP_APPS_UI_READ_RESOURCE_MIME_ALLOWLIST, isMcpAppsUiReadResourceMimeAllowed, } from "./resourceMime.js";
|
|
83
|
+
/**
|
|
84
|
+
* `hostCapabilities.experimental` 里 DCode 扩展的键。官方 SDK 的 zod 会剥掉标准位之外的未知能力键,
|
|
85
|
+
* 扩展一律放 experimental(规范预留位),页面按键 feature detect。
|
|
86
|
+
*/
|
|
87
|
+
export const MCP_APPS_WIDGET_STATE_EXPERIMENTAL_KEY = "dcode/widgetState";
|
|
88
|
+
export const MCP_APPS_RESOURCE_SUBSCRIBE_EXPERIMENTAL_KEY = "dcode/resourceSubscribe";
|
|
89
|
+
export const MCP_APPS_SURFACE_EXPERIMENTAL_KEY = "dcode/surface";
|
|
90
|
+
/**
|
|
91
|
+
* DCode 扩展方法 `ui/set-widget-state { widgetState }`(MCP Apps 无 widgetState):页面把界面状态交给宿主
|
|
92
|
+
* renderer 内存保存(不持久化,会话内重挂载可恢复);初值经 hostContext 的 `dcode/widgetState` 键随握手下发。
|
|
93
|
+
*/
|
|
94
|
+
export const MCP_APPS_SET_WIDGET_STATE_METHOD = "ui/set-widget-state";
|
|
95
|
+
export const MCP_APPS_WIDGET_STATE_CONTEXT_KEY = "dcode/widgetState";
|
|
96
|
+
/** 宿主 renderer ↔ relay shell 之间唯一一条 MessageChannel 的名字;上面跑原始 JSON-RPC(官方 AppBridge / App)。 */
|
|
97
|
+
export const PLUGIN_SANDBOX_PORT_NAME = "plugin-sandbox-rpc";
|
|
98
|
+
export function buildPluginSandboxScopeId(scope) {
|
|
99
|
+
return scope.kind === "toolCall" ? `tool:${scope.toolCallId}` : `surface:${scope.surfaceId}`;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=contract.js.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { MCP_APPS_EXTENSION_ID, MCP_APPS_RESOURCE_MIME_TYPE, MCP_APPS_UI_RESOURCE_SCHEME, MCP_APPS_LEGACY_RESOURCE_URI_META_KEY, buildMcpAppsClientCapabilities, isMcpAppsUiReadResourceMimeAllowed, } from "./contract.js";
|
|
3
|
+
import { normalizeMcpAppCspRelaxations, normalizeMcpToolUiMeta } from "./toolMeta.js";
|
|
4
|
+
import { exampleClientCapabilities, exampleResourceMetaWithRelaxations, exampleSandboxHandle, exampleToolUiDescriptor, } from "./contract.example.js";
|
|
5
|
+
describe("mcp-apps-protocol contract", () => {
|
|
6
|
+
it.each([
|
|
7
|
+
["PDF 文档", " Application/PDF ; version=1.7 "],
|
|
8
|
+
["办公文档", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"],
|
|
9
|
+
["电子表格", "application/vnd.ms-excel"],
|
|
10
|
+
["开放演示文档", "application/vnd.oasis.opendocument.presentation"],
|
|
11
|
+
["矢量图片", "image/svg+xml; charset=utf-8"],
|
|
12
|
+
["相机图片", "image/heic"],
|
|
13
|
+
["动画图片", "image/gif"],
|
|
14
|
+
["Audio", "audio/mpeg"],
|
|
15
|
+
["WAV 别名", "audio/x-wav"],
|
|
16
|
+
["Video", "video/mp4"],
|
|
17
|
+
["Archived", "application/zip"],
|
|
18
|
+
["GZIP 别名", "application/x-gzip"],
|
|
19
|
+
["Font", "font/woff2"],
|
|
20
|
+
["结构化数据", "application/yaml"],
|
|
21
|
+
["JSON 模型", "model/gltf+json"],
|
|
22
|
+
["已有文本前缀", "text/csv; charset=utf-8"],
|
|
23
|
+
["已有二进制", "application/octet-stream"],
|
|
24
|
+
["已有模型", "model/gltf-binary"],
|
|
25
|
+
])("页面资源接纳%s(%s)", (_label, mimeType) => {
|
|
26
|
+
expect(isMcpAppsUiReadResourceMimeAllowed(mimeType)).toBe(true);
|
|
27
|
+
});
|
|
28
|
+
it.each([
|
|
29
|
+
"application/x-msdownload",
|
|
30
|
+
"application/x-executable",
|
|
31
|
+
"application/vnd.example.unknown",
|
|
32
|
+
"image/x-example-unknown",
|
|
33
|
+
"application/pdf-malware",
|
|
34
|
+
"application/pdf,application/x-msdownload",
|
|
35
|
+
"",
|
|
36
|
+
" ; charset=utf-8",
|
|
37
|
+
])("资源扩容仍拒绝未知或不合法 MIME:%s", (mimeType) => {
|
|
38
|
+
expect(isMcpAppsUiReadResourceMimeAllowed(mimeType)).toBe(false);
|
|
39
|
+
});
|
|
40
|
+
it("扩展标识与 UI 资源 mimeType 与官方 SDK 常量一致", () => {
|
|
41
|
+
expect(MCP_APPS_EXTENSION_ID).toBe("io.modelcontextprotocol/ui");
|
|
42
|
+
expect(MCP_APPS_RESOURCE_MIME_TYPE).toBe("text/html;profile=mcp-app");
|
|
43
|
+
expect(MCP_APPS_LEGACY_RESOURCE_URI_META_KEY).toBe("ui/resourceUri");
|
|
44
|
+
expect(buildMcpAppsClientCapabilities()).toEqual(exampleClientCapabilities);
|
|
45
|
+
});
|
|
46
|
+
it("resourceUri 同时接受标准键、弃用扁平键与 openai/outputTemplate", () => {
|
|
47
|
+
expect(normalizeMcpToolUiMeta({ ui: { resourceUri: "ui://a/b" } })?.resourceUri).toBe("ui://a/b");
|
|
48
|
+
expect(normalizeMcpToolUiMeta({ "ui/resourceUri": "ui://a/c" })?.resourceUri).toBe("ui://a/c");
|
|
49
|
+
expect(normalizeMcpToolUiMeta({ "openai/outputTemplate": "ui://a/d" })?.resourceUri).toBe("ui://a/d");
|
|
50
|
+
expect(normalizeMcpToolUiMeta({ ui: { resourceUri: "https://a/b" } })).toBeNull();
|
|
51
|
+
});
|
|
52
|
+
it("dcode/csp 只认已知布尔键", () => {
|
|
53
|
+
expect(normalizeMcpAppCspRelaxations(exampleResourceMetaWithRelaxations)).toEqual({
|
|
54
|
+
unsafeEval: true,
|
|
55
|
+
});
|
|
56
|
+
expect(normalizeMcpAppCspRelaxations({ "dcode/csp": { unsafeEval: false, other: true } })).toBe(null);
|
|
57
|
+
});
|
|
58
|
+
it("示例描述与句柄满足契约形状", () => {
|
|
59
|
+
expect(exampleToolUiDescriptor.resourceUri.startsWith(MCP_APPS_UI_RESOURCE_SCHEME)).toBe(true);
|
|
60
|
+
expect(exampleSandboxHandle.shellUrl).toBe(`dcode-sandbox://shell-${exampleSandboxHandle.sandboxId}/`);
|
|
61
|
+
expect(exampleSandboxHandle.partition.startsWith("persist:plugin-sandbox-")).toBe(true);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=contract.test.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Apps 宿主侧契约的第二半:ui/download-file 项、tool-input / tool-result 载荷、宿主提供的 titleBar 与样式变量。
|
|
3
|
+
* hostInfo / hostCapabilities / hostContext 直接用官方 SDK 的 `McpUiHostCapabilities` / `McpUiHostContext`,不再重复定义。
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* `ui/download-file { contents }` 的一项——MCP 标准的 EmbeddedResource(内联 text / blob)
|
|
7
|
+
* 或 ResourceLink(只有 uri,宿主经同插件 server `resources/read` 取内容)。
|
|
8
|
+
*/
|
|
9
|
+
export type McpAppsDownloadFileItem = {
|
|
10
|
+
type: "resource";
|
|
11
|
+
resource: {
|
|
12
|
+
uri: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
mimeType?: string;
|
|
15
|
+
text?: string;
|
|
16
|
+
blob?: string;
|
|
17
|
+
};
|
|
18
|
+
} | {
|
|
19
|
+
type: "resource_link";
|
|
20
|
+
uri: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
mimeType?: string;
|
|
23
|
+
};
|
|
24
|
+
/** 单次 ui/download-file 的项数上限与单个文件解码后上限(与桌面 saveFile 的 50 MiB 同值)。 */
|
|
25
|
+
export declare const MCP_APPS_DOWNLOAD_FILE_MAX_ITEMS = 16;
|
|
26
|
+
export declare const MCP_APPS_DOWNLOAD_FILE_MAX_BYTES: number;
|
|
27
|
+
/** MCP 内容块(text / image / resource…);宿主只透传,不解释非 text 块。 */
|
|
28
|
+
export type McpAppsContentBlock = Record<string, unknown>;
|
|
29
|
+
/** `ui/notifications/tool-input` 与 `tool-result` 的载荷(与官方 SDK 通知参数同形)。 */
|
|
30
|
+
export interface McpAppsToolInputPayload {
|
|
31
|
+
arguments?: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
export interface McpAppsToolResultPayload {
|
|
34
|
+
content?: McpAppsContentBlock[];
|
|
35
|
+
structuredContent?: unknown;
|
|
36
|
+
isError?: boolean;
|
|
37
|
+
_meta?: Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
/** 宿主画在页面视口上方的面板头部;只在 fullscreen 给出(hostContext 允许附加键)。 */
|
|
40
|
+
export interface McpAppsHostTitleBar {
|
|
41
|
+
height: number;
|
|
42
|
+
leftInset: number;
|
|
43
|
+
viewportLeftInset: number;
|
|
44
|
+
}
|
|
45
|
+
/** MCP Apps 标准样式变量(键名见官方 `McpUiStyleVariableKey`),值是页面可直接使用的 CSS 文本。 */
|
|
46
|
+
export type McpAppsStyleVariables = Record<string, string>;
|
|
47
|
+
//# sourceMappingURL=hostContract.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Apps 宿主侧契约的第二半:ui/download-file 项、tool-input / tool-result 载荷、宿主提供的 titleBar 与样式变量。
|
|
3
|
+
* hostInfo / hostCapabilities / hostContext 直接用官方 SDK 的 `McpUiHostCapabilities` / `McpUiHostContext`,不再重复定义。
|
|
4
|
+
*/
|
|
5
|
+
/** 单次 ui/download-file 的项数上限与单个文件解码后上限(与桌面 saveFile 的 50 MiB 同值)。 */
|
|
6
|
+
export const MCP_APPS_DOWNLOAD_FILE_MAX_ITEMS = 16;
|
|
7
|
+
export const MCP_APPS_DOWNLOAD_FILE_MAX_BYTES = 50 * 1024 * 1024;
|
|
8
|
+
//# sourceMappingURL=hostContract.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./appTools.js";
|
|
2
|
+
export * from "./content.js";
|
|
3
|
+
export * from "./contract.js";
|
|
4
|
+
export * from "./hostContract.js";
|
|
5
|
+
export * from "./instance.js";
|
|
6
|
+
export * from "./schemas.js";
|
|
7
|
+
export * from "./sampling.js";
|
|
8
|
+
export * from "./toolMeta.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./appTools.js";
|
|
2
|
+
export * from "./content.js";
|
|
3
|
+
export * from "./contract.js";
|
|
4
|
+
export * from "./hostContract.js";
|
|
5
|
+
export * from "./instance.js";
|
|
6
|
+
export * from "./schemas.js";
|
|
7
|
+
export * from "./sampling.js";
|
|
8
|
+
export * from "./toolMeta.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Agent 签发的内存凭证;Main 的 initId 只用于端口握手。 */
|
|
3
|
+
export declare const mcpAppInstanceSchema: z.ZodObject<{
|
|
4
|
+
runtimeId: z.ZodString;
|
|
5
|
+
generation: z.ZodNumber;
|
|
6
|
+
appIdentity: z.ZodString;
|
|
7
|
+
token: z.ZodString;
|
|
8
|
+
}, z.core.$strict>;
|
|
9
|
+
export type McpAppInstance = z.infer<typeof mcpAppInstanceSchema>;
|
|
10
|
+
//# sourceMappingURL=instance.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Agent 签发的内存凭证;Main 的 initId 只用于端口握手。 */
|
|
3
|
+
export const mcpAppInstanceSchema = z
|
|
4
|
+
.object({
|
|
5
|
+
runtimeId: z.string().min(1),
|
|
6
|
+
generation: z.number().int().positive(),
|
|
7
|
+
appIdentity: z.string().regex(/^[a-f0-9]{64}$/),
|
|
8
|
+
token: z.string().min(1),
|
|
9
|
+
})
|
|
10
|
+
.strict();
|
|
11
|
+
//# sourceMappingURL=instance.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mcp-apps-protocol 模块清单(architecture-governance managed 模块)。
|
|
3
|
+
* 纯 domain:MCP Apps 的 DCode 扩展常量、`_meta` 归一化、`display.ui` schema 与沙箱契约类型,零 IO。
|
|
4
|
+
* 页面 ↔ 宿主的线协议由官方 `@modelcontextprotocol/ext-apps` 承担,本模块不再持有状态机。
|
|
5
|
+
*/
|
|
6
|
+
export declare const mcpAppsProtocolModule: {
|
|
7
|
+
readonly id: "mcp-apps-protocol";
|
|
8
|
+
readonly requires: readonly [];
|
|
9
|
+
readonly provides: readonly ["mcp-apps-protocol"];
|
|
10
|
+
readonly publicEntrypoints: readonly ["index.ts", "contract.ts"];
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=module.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mcp-apps-protocol 模块清单(architecture-governance managed 模块)。
|
|
3
|
+
* 纯 domain:MCP Apps 的 DCode 扩展常量、`_meta` 归一化、`display.ui` schema 与沙箱契约类型,零 IO。
|
|
4
|
+
* 页面 ↔ 宿主的线协议由官方 `@modelcontextprotocol/ext-apps` 承担,本模块不再持有状态机。
|
|
5
|
+
*/
|
|
6
|
+
export const mcpAppsProtocolModule = {
|
|
7
|
+
id: "mcp-apps-protocol",
|
|
8
|
+
requires: [],
|
|
9
|
+
provides: ["mcp-apps-protocol"],
|
|
10
|
+
publicEntrypoints: ["index.ts", "contract.ts"],
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 页面发起的 `resources/read`(`mcp/uiReadResource`)单次结果总大小上限,以及 mimeType 白名单。
|
|
3
|
+
* 白名单项以 `/` 结尾表示前缀匹配(如 `text/`),否则精确匹配(忽略参数与大小写)。
|
|
4
|
+
*/
|
|
5
|
+
export declare const MCP_APPS_UI_READ_RESOURCE_MAX_BYTES: number;
|
|
6
|
+
export declare const MCP_APPS_UI_READ_RESOURCE_MIME_ALLOWLIST: readonly string[];
|
|
7
|
+
export declare function isMcpAppsUiReadResourceMimeAllowed(mimeType: string): boolean;
|
|
8
|
+
//# sourceMappingURL=resourceMime.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 页面发起的 `resources/read`(`mcp/uiReadResource`)单次结果总大小上限,以及 mimeType 白名单。
|
|
3
|
+
* 白名单项以 `/` 结尾表示前缀匹配(如 `text/`),否则精确匹配(忽略参数与大小写)。
|
|
4
|
+
*/
|
|
5
|
+
export const MCP_APPS_UI_READ_RESOURCE_MAX_BYTES = 8 * 1024 * 1024;
|
|
6
|
+
// 原列表遗漏 PDF 等常见资源,导致插件已握手却读不到文件;按明确 MIME 扩展,保留未知类型拒绝规则。
|
|
7
|
+
export const MCP_APPS_UI_READ_RESOURCE_MIME_ALLOWLIST = [
|
|
8
|
+
"text/",
|
|
9
|
+
"application/json",
|
|
10
|
+
"application/xml",
|
|
11
|
+
"application/yaml",
|
|
12
|
+
"application/x-yaml",
|
|
13
|
+
// 文档与办公文件。
|
|
14
|
+
"application/pdf",
|
|
15
|
+
"application/rtf",
|
|
16
|
+
"application/msword",
|
|
17
|
+
"application/vnd.ms-excel",
|
|
18
|
+
"application/vnd.ms-powerpoint",
|
|
19
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
20
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
21
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
22
|
+
"application/vnd.oasis.opendocument.text",
|
|
23
|
+
"application/vnd.oasis.opendocument.spreadsheet",
|
|
24
|
+
"application/vnd.oasis.opendocument.presentation",
|
|
25
|
+
// 图片。
|
|
26
|
+
"image/png",
|
|
27
|
+
"image/jpeg",
|
|
28
|
+
"image/webp",
|
|
29
|
+
"image/svg+xml",
|
|
30
|
+
"image/gif",
|
|
31
|
+
"image/avif",
|
|
32
|
+
"image/bmp",
|
|
33
|
+
"image/tiff",
|
|
34
|
+
"image/x-icon",
|
|
35
|
+
"image/vnd.microsoft.icon",
|
|
36
|
+
"image/heic",
|
|
37
|
+
"image/heif",
|
|
38
|
+
// 音视频。
|
|
39
|
+
"audio/mpeg",
|
|
40
|
+
"audio/mp4",
|
|
41
|
+
"audio/ogg",
|
|
42
|
+
"audio/wav",
|
|
43
|
+
"audio/x-wav",
|
|
44
|
+
"audio/webm",
|
|
45
|
+
"audio/aac",
|
|
46
|
+
"audio/flac",
|
|
47
|
+
"video/mp4",
|
|
48
|
+
"video/webm",
|
|
49
|
+
"video/ogg",
|
|
50
|
+
"video/quicktime",
|
|
51
|
+
"video/mpeg",
|
|
52
|
+
// 归档、字体与模型只传输内容,由插件决定如何使用。
|
|
53
|
+
"application/zip",
|
|
54
|
+
"application/gzip",
|
|
55
|
+
"application/x-gzip",
|
|
56
|
+
"application/x-tar",
|
|
57
|
+
"application/x-7z-compressed",
|
|
58
|
+
"application/vnd.rar",
|
|
59
|
+
"font/woff",
|
|
60
|
+
"font/woff2",
|
|
61
|
+
"font/ttf",
|
|
62
|
+
"font/otf",
|
|
63
|
+
"model/gltf+json",
|
|
64
|
+
"model/gltf-binary",
|
|
65
|
+
"application/octet-stream",
|
|
66
|
+
];
|
|
67
|
+
export function isMcpAppsUiReadResourceMimeAllowed(mimeType) {
|
|
68
|
+
const essence = mimeType.split(";")[0].trim().toLowerCase();
|
|
69
|
+
if (!essence)
|
|
70
|
+
return false;
|
|
71
|
+
return MCP_APPS_UI_READ_RESOURCE_MIME_ALLOWLIST.some((entry) => entry.endsWith("/") ? essence.startsWith(entry) : essence === entry);
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=resourceMime.js.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const MCP_APPS_SAMPLING_TIMEOUT_MS = 60000;
|
|
3
|
+
export declare const MCP_APPS_SAMPLING_TRANSPORT_TIMEOUT_MS = 65000;
|
|
4
|
+
export declare const MCP_APPS_SAMPLING_MAX_BYTES: number;
|
|
5
|
+
export declare const MCP_APPS_SAMPLING_MAX_BLOCKS = 64;
|
|
6
|
+
export declare const MCP_APPS_SAMPLING_MAX_PER_SESSION = 4;
|
|
7
|
+
export declare const MCP_APPS_SAMPLING_MAX_PER_AGENT = 8;
|
|
8
|
+
export declare const MCP_APPS_SAMPLING_MAX_OPERATIONS = 4096;
|
|
9
|
+
/** 只开放宿主确实实现的官方子集;不静默剥除 tools/audio/模型配置等字段。 */
|
|
10
|
+
export declare const mcpAppsSamplingParamsSchema: z.ZodObject<{
|
|
11
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
12
|
+
role: z.ZodEnum<{
|
|
13
|
+
user: "user";
|
|
14
|
+
assistant: "assistant";
|
|
15
|
+
}>;
|
|
16
|
+
content: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
17
|
+
type: z.ZodLiteral<"text">;
|
|
18
|
+
text: z.ZodString;
|
|
19
|
+
annotations: z.ZodOptional<z.ZodObject<{
|
|
20
|
+
audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
21
|
+
user: "user";
|
|
22
|
+
assistant: "assistant";
|
|
23
|
+
}>>>;
|
|
24
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
lastModified: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, z.core.$strict>>;
|
|
27
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
28
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
29
|
+
type: z.ZodLiteral<"image">;
|
|
30
|
+
mimeType: z.ZodEnum<{
|
|
31
|
+
"image/jpeg": "image/jpeg";
|
|
32
|
+
"image/png": "image/png";
|
|
33
|
+
"image/webp": "image/webp";
|
|
34
|
+
}>;
|
|
35
|
+
data: z.ZodString;
|
|
36
|
+
annotations: z.ZodOptional<z.ZodObject<{
|
|
37
|
+
audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
38
|
+
user: "user";
|
|
39
|
+
assistant: "assistant";
|
|
40
|
+
}>>>;
|
|
41
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
42
|
+
lastModified: z.ZodOptional<z.ZodString>;
|
|
43
|
+
}, z.core.$strict>>;
|
|
44
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
45
|
+
}, z.core.$strict>], "type">, z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
46
|
+
type: z.ZodLiteral<"text">;
|
|
47
|
+
text: z.ZodString;
|
|
48
|
+
annotations: z.ZodOptional<z.ZodObject<{
|
|
49
|
+
audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
50
|
+
user: "user";
|
|
51
|
+
assistant: "assistant";
|
|
52
|
+
}>>>;
|
|
53
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
54
|
+
lastModified: z.ZodOptional<z.ZodString>;
|
|
55
|
+
}, z.core.$strict>>;
|
|
56
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
57
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
58
|
+
type: z.ZodLiteral<"image">;
|
|
59
|
+
mimeType: z.ZodEnum<{
|
|
60
|
+
"image/jpeg": "image/jpeg";
|
|
61
|
+
"image/png": "image/png";
|
|
62
|
+
"image/webp": "image/webp";
|
|
63
|
+
}>;
|
|
64
|
+
data: z.ZodString;
|
|
65
|
+
annotations: z.ZodOptional<z.ZodObject<{
|
|
66
|
+
audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
67
|
+
user: "user";
|
|
68
|
+
assistant: "assistant";
|
|
69
|
+
}>>>;
|
|
70
|
+
priority: z.ZodOptional<z.ZodNumber>;
|
|
71
|
+
lastModified: z.ZodOptional<z.ZodString>;
|
|
72
|
+
}, z.core.$strict>>;
|
|
73
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
74
|
+
}, z.core.$strict>], "type">>]>;
|
|
75
|
+
}, z.core.$strict>>;
|
|
76
|
+
systemPrompt: z.ZodOptional<z.ZodString>;
|
|
77
|
+
maxTokens: z.ZodNumber;
|
|
78
|
+
includeContext: z.ZodOptional<z.ZodLiteral<"none">>;
|
|
79
|
+
modelPreferences: z.ZodOptional<z.ZodObject<{
|
|
80
|
+
hints: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
81
|
+
name: z.ZodOptional<z.ZodString>;
|
|
82
|
+
}, z.core.$strict>>>;
|
|
83
|
+
costPriority: z.ZodOptional<z.ZodNumber>;
|
|
84
|
+
speedPriority: z.ZodOptional<z.ZodNumber>;
|
|
85
|
+
intelligencePriority: z.ZodOptional<z.ZodNumber>;
|
|
86
|
+
}, z.core.$strict>>;
|
|
87
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
88
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
89
|
+
}, z.core.$strict>;
|
|
90
|
+
export declare const mcpAppsSamplingResultSchema: z.ZodObject<{
|
|
91
|
+
role: z.ZodLiteral<"assistant">;
|
|
92
|
+
model: z.ZodString;
|
|
93
|
+
content: z.ZodObject<{
|
|
94
|
+
type: z.ZodLiteral<"text">;
|
|
95
|
+
text: z.ZodString;
|
|
96
|
+
}, z.core.$strict>;
|
|
97
|
+
stopReason: z.ZodString;
|
|
98
|
+
}, z.core.$strict>;
|
|
99
|
+
export type McpAppsSamplingParams = z.infer<typeof mcpAppsSamplingParamsSchema>;
|
|
100
|
+
export type McpAppsSamplingResult = z.infer<typeof mcpAppsSamplingResultSchema>;
|
|
101
|
+
//# sourceMappingURL=sampling.d.ts.map
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { MCP_APPS_IMAGE_MAX_BYTES, MCP_APPS_IMAGE_MIME_TYPES } from "./contract.js";
|
|
3
|
+
export const MCP_APPS_SAMPLING_TIMEOUT_MS = 60_000;
|
|
4
|
+
export const MCP_APPS_SAMPLING_TRANSPORT_TIMEOUT_MS = 65_000;
|
|
5
|
+
export const MCP_APPS_SAMPLING_MAX_BYTES = 8 * 1024 * 1024;
|
|
6
|
+
export const MCP_APPS_SAMPLING_MAX_BLOCKS = 64;
|
|
7
|
+
export const MCP_APPS_SAMPLING_MAX_PER_SESSION = 4;
|
|
8
|
+
export const MCP_APPS_SAMPLING_MAX_PER_AGENT = 8;
|
|
9
|
+
export const MCP_APPS_SAMPLING_MAX_OPERATIONS = 4096;
|
|
10
|
+
const utf8Bytes = (text) => new TextEncoder().encode(text).byteLength;
|
|
11
|
+
const annotations = z
|
|
12
|
+
.object({
|
|
13
|
+
audience: z.array(z.enum(["user", "assistant"])).optional(),
|
|
14
|
+
priority: z.number().min(0).max(1).optional(),
|
|
15
|
+
lastModified: z.string().optional(),
|
|
16
|
+
})
|
|
17
|
+
.strict()
|
|
18
|
+
.optional();
|
|
19
|
+
const samplingBlockSchema = z.discriminatedUnion("type", [
|
|
20
|
+
z
|
|
21
|
+
.object({
|
|
22
|
+
type: z.literal("text"),
|
|
23
|
+
text: z.string().max(MCP_APPS_SAMPLING_MAX_BYTES),
|
|
24
|
+
annotations,
|
|
25
|
+
_meta: z.record(z.string(), z.unknown()).optional(),
|
|
26
|
+
})
|
|
27
|
+
.strict(),
|
|
28
|
+
z
|
|
29
|
+
.object({
|
|
30
|
+
type: z.literal("image"),
|
|
31
|
+
mimeType: z.enum(MCP_APPS_IMAGE_MIME_TYPES),
|
|
32
|
+
data: z
|
|
33
|
+
.string()
|
|
34
|
+
.min(1)
|
|
35
|
+
.max(Math.ceil(MCP_APPS_IMAGE_MAX_BYTES / 3) * 4)
|
|
36
|
+
// 重复四字符分组会在 MiB 级图片上耗尽 V8 正则栈;平坦字符检查保持线性。
|
|
37
|
+
.refine((data) => data.length % 4 === 0 && /^[A-Za-z0-9+/]*={0,2}$/.test(data))
|
|
38
|
+
.refine((data) => decodedBytes(data) <= MCP_APPS_IMAGE_MAX_BYTES),
|
|
39
|
+
annotations,
|
|
40
|
+
_meta: z.record(z.string(), z.unknown()).optional(),
|
|
41
|
+
})
|
|
42
|
+
.strict(),
|
|
43
|
+
]);
|
|
44
|
+
const priority = z.number().min(0).max(1).optional();
|
|
45
|
+
/** 只开放宿主确实实现的官方子集;不静默剥除 tools/audio/模型配置等字段。 */
|
|
46
|
+
export const mcpAppsSamplingParamsSchema = z
|
|
47
|
+
.object({
|
|
48
|
+
messages: z
|
|
49
|
+
.array(z
|
|
50
|
+
.object({
|
|
51
|
+
role: z.enum(["user", "assistant"]),
|
|
52
|
+
content: z.union([
|
|
53
|
+
samplingBlockSchema,
|
|
54
|
+
z.array(samplingBlockSchema).min(1).max(MCP_APPS_SAMPLING_MAX_BLOCKS),
|
|
55
|
+
]),
|
|
56
|
+
})
|
|
57
|
+
.strict())
|
|
58
|
+
.min(1)
|
|
59
|
+
.max(MCP_APPS_SAMPLING_MAX_BLOCKS),
|
|
60
|
+
systemPrompt: z.string().max(MCP_APPS_SAMPLING_MAX_BYTES).optional(),
|
|
61
|
+
maxTokens: z.number().int().positive().safe(),
|
|
62
|
+
includeContext: z.literal("none").optional(),
|
|
63
|
+
modelPreferences: z
|
|
64
|
+
.object({
|
|
65
|
+
hints: z
|
|
66
|
+
.array(z.object({ name: z.string().max(256).optional() }).strict())
|
|
67
|
+
.max(16)
|
|
68
|
+
.optional(),
|
|
69
|
+
costPriority: priority,
|
|
70
|
+
speedPriority: priority,
|
|
71
|
+
intelligencePriority: priority,
|
|
72
|
+
})
|
|
73
|
+
.strict()
|
|
74
|
+
.optional(),
|
|
75
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
76
|
+
_meta: z.record(z.string(), z.unknown()).optional(),
|
|
77
|
+
})
|
|
78
|
+
.strict()
|
|
79
|
+
.superRefine((params, ctx) => {
|
|
80
|
+
const blocks = params.messages.flatMap((message) => Array.isArray(message.content) ? message.content : [message.content]);
|
|
81
|
+
let bytes = utf8Bytes(params.systemPrompt ?? "");
|
|
82
|
+
for (const block of blocks)
|
|
83
|
+
bytes += block.type === "image" ? decodedBytes(block.data) : utf8Bytes(block.text);
|
|
84
|
+
// metadata 不转发给 provider,但仍计入边界预算,避免任意扩展字段绕过载荷限制。
|
|
85
|
+
const metadataBytes = utf8Bytes(JSON.stringify({
|
|
86
|
+
metadata: params.metadata,
|
|
87
|
+
_meta: params._meta,
|
|
88
|
+
blockMetadata: blocks.map((b) => ({ _meta: b._meta, annotations: b.annotations })),
|
|
89
|
+
}));
|
|
90
|
+
if (blocks.length > MCP_APPS_SAMPLING_MAX_BLOCKS ||
|
|
91
|
+
bytes + metadataBytes > MCP_APPS_SAMPLING_MAX_BYTES)
|
|
92
|
+
ctx.addIssue({ code: "custom", message: "Sampling content exceeds host limits" });
|
|
93
|
+
});
|
|
94
|
+
function decodedBytes(data) {
|
|
95
|
+
return (data.length * 3) / 4 - (data.endsWith("==") ? 2 : data.endsWith("=") ? 1 : 0);
|
|
96
|
+
}
|
|
97
|
+
export const mcpAppsSamplingResultSchema = z
|
|
98
|
+
.object({
|
|
99
|
+
role: z.literal("assistant"),
|
|
100
|
+
model: z.string().min(1),
|
|
101
|
+
content: z
|
|
102
|
+
.object({ type: z.literal("text"), text: z.string().max(MCP_APPS_SAMPLING_MAX_BYTES) })
|
|
103
|
+
.strict(),
|
|
104
|
+
stopReason: z.string().min(1),
|
|
105
|
+
})
|
|
106
|
+
.strict();
|
|
107
|
+
//# sourceMappingURL=sampling.js.map
|