@ljwei-stak/dsh-model-route-bot 0.66.3 → 0.67.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/.dsh-plugin/bot-product.mjs +81 -5
- package/.dsh-plugin/client.js +17490 -1791
- package/README.i18n.yaml +4 -4
- package/README.md +409 -364
- package/README.zh.md +409 -364
- package/apps/integration-client/README.md +31 -7
- package/apps/integration-client/api.mjs +14 -3
- package/apps/integration-client/binding-editor.jsx +308 -109
- package/apps/integration-client/binding-model.mjs +262 -0
- package/apps/integration-client/binding.css +144 -0
- package/apps/integration-client/bot-model-status.mjs +18 -0
- package/apps/integration-client/bot-profile-identity.jsx +197 -0
- package/apps/integration-client/bot-profile.css +57 -0
- package/apps/integration-client/bot-profile.mjs +97 -0
- package/apps/integration-client/bot-settings-dialog.css +18 -0
- package/apps/integration-client/bot-settings-dialog.jsx +111 -0
- package/apps/integration-client/bot-thread-header-bridge.css +20 -0
- package/apps/integration-client/bot-thread-header.jsx +278 -0
- package/apps/integration-client/bot-threads-panel.jsx +378 -0
- package/apps/integration-client/bot-threads.css +169 -0
- package/apps/integration-client/chat-design.mjs +250 -0
- package/apps/integration-client/chat-ui.jsx +175 -0
- package/apps/integration-client/chat.css +477 -0
- package/apps/integration-client/composer-draft-binding.mjs +50 -0
- package/apps/integration-client/composer-draft-bound.jsx +14 -0
- package/apps/integration-client/composer-draft-host.jsx +142 -0
- package/apps/integration-client/composer-draft-session.jsx +287 -0
- package/apps/integration-client/composer-draft-witness.mjs +115 -0
- package/apps/integration-client/composer-draft.css +4 -0
- package/apps/integration-client/composer-draft.mjs +322 -0
- package/apps/integration-client/contact-attention.jsx +54 -0
- package/apps/integration-client/data-panel.jsx +439 -0
- package/apps/integration-client/data.css +69 -0
- package/apps/integration-client/desktop-bridge.mjs +1 -0
- package/apps/integration-client/desktop-http-socket.mjs +49 -0
- package/apps/integration-client/desktop-keyboard.mjs +32 -0
- package/apps/integration-client/desktop-pane.jsx +99 -30
- package/apps/integration-client/desktop-stream.mjs +13 -3
- package/apps/integration-client/desktop-tools.jsx +19 -0
- package/apps/integration-client/desktop-touch.mjs +27 -0
- package/apps/integration-client/desktop.css +41 -0
- package/apps/integration-client/independent-chat-controller.mjs +224 -0
- package/apps/integration-client/independent-chat-entry.jsx +61 -0
- package/apps/integration-client/independent-chat-navigation.mjs +21 -0
- package/apps/integration-client/independent-chat-page.jsx +148 -0
- package/apps/integration-client/independent-chat-rich.jsx +64 -0
- package/apps/integration-client/independent-chat-rich.mjs +30 -0
- package/apps/integration-client/independent-chat.css +73 -0
- package/apps/integration-client/index.jsx +24 -16
- package/apps/integration-client/library-panel.jsx +4 -1
- package/apps/integration-client/licenses/jsqr-1.4.0-LICENSE.txt +202 -0
- package/apps/integration-client/main-route-editor.jsx +94 -0
- package/apps/integration-client/main-route-model.mjs +100 -0
- package/apps/integration-client/model-picker.css +37 -0
- package/apps/integration-client/model-picker.jsx +83 -0
- package/apps/integration-client/native-activity.css +141 -0
- package/apps/integration-client/native-activity.jsx +276 -0
- package/apps/integration-client/native-activity.mjs +384 -0
- package/apps/integration-client/notifications-panel.jsx +186 -0
- package/apps/integration-client/notifications.css +126 -0
- package/apps/integration-client/pairing-qr.jsx +79 -0
- package/apps/integration-client/panels.jsx +126 -115
- package/apps/integration-client/product-slots.jsx +46 -0
- package/apps/integration-client/routine-recorder.mjs +23 -2
- package/apps/integration-client/secure-pairing.jsx +84 -0
- package/apps/integration-client/tasks-panel.jsx +32 -10
- package/apps/integration-client/ui-icons.jsx +17 -0
- package/apps/integration-client/usage-explorer.jsx +43 -0
- package/apps/integration-client/usage-report.mjs +71 -0
- package/apps/integration-client/usage.css +34 -0
- package/apps/integration-client/web-panel-model.mjs +140 -0
- package/apps/integration-client/web-panel-page.jsx +221 -0
- package/apps/integration-client/web-panel-pins-live.jsx +28 -0
- package/apps/integration-client/web-panel.css +139 -0
- package/apps/integration-client/workspace-model.mjs +67 -0
- package/apps/integration-client/workspace-navigation.mjs +56 -0
- package/apps/integration-client/workspace-ui.jsx +173 -0
- package/apps/integration-client/workspace.css +332 -0
- package/modules/bot-runtime/SOURCE.json +176 -50
- package/modules/bot-runtime/index.mjs +169 -13
- package/modules/bot-runtime/product-overlay/OVERLAY.json +128 -2
- package/modules/bot-runtime/product-overlay/base/src/client/header.js +244 -0
- package/modules/bot-runtime/product-overlay/base/src/client/learning-card.js +202 -0
- package/modules/bot-runtime/product-overlay/base/src/client/model-menu.js +371 -0
- package/modules/bot-runtime/product-overlay/base/src/client/secret-card.js +363 -0
- package/modules/bot-runtime/product-overlay/base/src/client/sources.js +68 -0
- package/modules/bot-runtime/product-overlay/base/src/client/turn-error.js +260 -0
- package/modules/bot-runtime/product-overlay/base/src/host/channel.js +647 -0
- package/modules/bot-runtime/product-overlay/base/src/host/memory.js +2050 -0
- package/modules/bot-runtime/product-overlay/base/src/host/models.js +314 -0
- package/modules/bot-runtime/product-overlay/base/src/host/parts.js +1473 -0
- package/modules/bot-runtime/product-overlay/base/src/host/privacy.js +368 -0
- package/modules/bot-runtime/product-overlay/base/src/host/roster.js +776 -0
- package/modules/bot-runtime/product-overlay/base/src/host/store.js +512 -0
- package/modules/bot-runtime/product-overlay/base/src/host/usage.js +653 -0
- package/modules/bot-runtime/product-overlay/patches/src/client/details-drawer.js.patch +48 -2
- package/modules/bot-runtime/product-overlay/patches/src/client/header.js.patch +41 -0
- package/modules/bot-runtime/product-overlay/patches/src/client/index.js.patch +33 -1
- package/modules/bot-runtime/product-overlay/patches/src/client/learning-card.js.patch +20 -0
- package/modules/bot-runtime/product-overlay/patches/src/client/model-menu.js.patch +24 -0
- package/modules/bot-runtime/product-overlay/patches/src/client/secret-card.js.patch +25 -0
- package/modules/bot-runtime/product-overlay/patches/src/client/sources.js.patch +52 -0
- package/modules/bot-runtime/product-overlay/patches/src/client/turn-error.js.patch +23 -0
- package/modules/bot-runtime/product-overlay/patches/src/host/channel.js.patch +46 -0
- package/modules/bot-runtime/product-overlay/patches/src/host/memory.js.patch +11 -0
- package/modules/bot-runtime/product-overlay/patches/src/host/models.js.patch +16 -0
- package/modules/bot-runtime/product-overlay/patches/src/host/parts.js.patch +95 -0
- package/modules/bot-runtime/product-overlay/patches/src/host/privacy.js.patch +11 -0
- package/modules/bot-runtime/product-overlay/patches/src/host/roster.js.patch +145 -0
- package/modules/bot-runtime/product-overlay/patches/src/host/store.js.patch +68 -0
- package/modules/bot-runtime/product-overlay/patches/src/host/usage.js.patch +11 -0
- package/modules/bot-runtime/read-model.mjs +19 -4
- package/modules/bot-runtime/vendor/ds-bot/src/client/details-drawer.js +15 -5
- package/modules/bot-runtime/vendor/ds-bot/src/client/header.js +9 -2
- package/modules/bot-runtime/vendor/ds-bot/src/client/index.js +9 -2
- package/modules/bot-runtime/vendor/ds-bot/src/client/learning-card.js +2 -2
- package/modules/bot-runtime/vendor/ds-bot/src/client/model-menu.js +5 -3
- package/modules/bot-runtime/vendor/ds-bot/src/client/secret-card.js +3 -3
- package/modules/bot-runtime/vendor/ds-bot/src/client/sources.js +25 -2
- package/modules/bot-runtime/vendor/ds-bot/src/client/turn-error.js +3 -2
- package/modules/bot-runtime/vendor/ds-bot/src/host/channel.js +14 -2
- package/modules/bot-runtime/vendor/ds-bot/src/host/memory.js +1 -1
- package/modules/bot-runtime/vendor/ds-bot/src/host/models.js +7 -0
- package/modules/bot-runtime/vendor/ds-bot/src/host/parts.js +26 -9
- package/modules/bot-runtime/vendor/ds-bot/src/host/privacy.js +1 -1
- package/modules/bot-runtime/vendor/ds-bot/src/host/roster.js +112 -3
- package/modules/bot-runtime/vendor/ds-bot/src/host/store.js +34 -1
- package/modules/bot-runtime/vendor/ds-bot/src/host/usage.js +1 -1
- package/modules/independent-runtime/index.mjs +152 -62
- package/modules/independent-runtime/remote-tools.mjs +8 -5
- package/modules/openmaus-protocol/NOTICE +10 -0
- package/modules/openmaus-protocol/README.md +15 -0
- package/modules/openmaus-protocol/SOURCE.json +68 -0
- package/modules/openmaus-protocol/dist/protocol.mjs +1203 -0
- package/modules/openmaus-protocol/index.mjs +1 -0
- package/modules/openmaus-protocol/transport.mjs +77 -0
- package/modules/openmaus-protocol/vendor/LICENSE +202 -0
- package/modules/openmaus-protocol/vendor/companion/src/e2e/README.md +405 -0
- package/modules/openmaus-protocol/vendor/companion/src/e2e/credentials.ts +128 -0
- package/modules/openmaus-protocol/vendor/companion/src/e2e/descriptor.ts +84 -0
- package/modules/openmaus-protocol/vendor/companion/src/e2e/noise.ts +456 -0
- package/modules/openmaus-protocol/vendor/companion/src/e2e/phone.ts +104 -0
- package/modules/openmaus-protocol/vendor/companion/src/e2e/session.ts +417 -0
- package/modules/openmaus-protocol/vendor/companion/src/e2e/vectors/v1.json +2565 -0
- package/modules/openmaus-protocol/vendor/companion/src/e2e/vectors/v1.sha256 +1 -0
- package/modules/openmaus-protocol/vendor/companion/src/e2e/yamux.ts +335 -0
- package/package.json +20 -6
- package/packages/bot-acp/README.md +156 -0
- package/packages/bot-acp/licenses/LICENSE-OpenMausBot +202 -0
- package/packages/bot-acp/licenses/NOTICE.md +27 -0
- package/packages/bot-acp/src/acp-adapter.mjs +795 -0
- package/packages/bot-acp/src/acp-host.mjs +148 -0
- package/packages/bot-acp/src/native-launch.mjs +121 -0
- package/packages/bot-acp/src/permission-policy.mjs +283 -0
- package/packages/bot-acp/src/rpc-codec.mjs +265 -0
- package/packages/bot-acp/src/session-core.mjs +581 -0
- package/packages/bot-acp/src/stdio-rpc.mjs +329 -0
- package/packages/bot-engines/README.md +281 -0
- package/packages/bot-engines/licenses/LICENSE-OpenMausBot +202 -0
- package/packages/bot-engines/licenses/NOTICE.md +32 -0
- package/packages/bot-engines/src/claude-engine.mjs +772 -0
- package/packages/bot-engines/src/claude-llm-adapter.mjs +797 -0
- package/packages/bot-engines/src/claude-llm-turn.mjs +292 -0
- package/packages/bot-engines/src/claude-permission-broker.mjs +130 -0
- package/packages/bot-engines/src/claude-permission-proxy.mjs +87 -0
- package/packages/bot-engines/src/claude-protocol.mjs +177 -0
- package/packages/bot-engines/src/driver-catalog.mjs +334 -0
- package/packages/bot-engines/src/host-loop-request.mjs +95 -0
- package/packages/bot-engines/src/host-registrations.mjs +105 -0
- package/packages/capability-broker/src/cli-bootstrap.mjs +86 -16
- package/packages/capability-broker/src/cli-bridge-response.mjs +80 -0
- package/packages/capability-broker/src/cli-stdio-bridge.mjs +21 -8
- package/packages/cli-runtime/src/codex-session-core.mjs +4 -0
- package/packages/cli-runtime/src/native-cli-output.mjs +57 -0
- package/packages/cli-runtime/src/native-peer.ps1 +51 -3
- package/packages/cli-runtime/src/native-process.mjs +77 -14
- package/packages/model-router-plugin/README.md +3 -3
- package/packages/model-router-plugin/package.json +1 -1
- package/packages/orchestration/src/binding-product.mjs +19 -0
- package/packages/orchestration/src/bot-data-actions.mjs +45 -0
- package/packages/orchestration/src/bot-data-chart.mjs +109 -0
- package/packages/orchestration/src/bot-data-context.mjs +44 -0
- package/packages/orchestration/src/bot-data-engine.mjs +809 -0
- package/packages/orchestration/src/bot-data-io.mjs +186 -0
- package/packages/orchestration/src/bot-data-sql.mjs +195 -0
- package/packages/orchestration/src/bot-data-surface.mjs +144 -0
- package/packages/orchestration/src/bot-data-tools.mjs +68 -0
- package/packages/orchestration/src/bot-data-worker.mjs +228 -0
- package/packages/orchestration/src/bot-independent-execution.mjs +195 -0
- package/packages/orchestration/src/bot-independent-stream.mjs +74 -0
- package/packages/orchestration/src/bot-loop.mjs +152 -19
- package/packages/orchestration/src/bot-notifications.mjs +159 -0
- package/packages/orchestration/src/bot-policy.mjs +43 -4
- package/packages/orchestration/src/bot-profile.mjs +171 -0
- package/packages/orchestration/src/bot-routine.mjs +4 -4
- package/packages/orchestration/src/bot-runtime-assembly.mjs +255 -8
- package/packages/orchestration/src/bot-runtime-switch.mjs +13 -2
- package/packages/orchestration/src/bot-serving.mjs +164 -0
- package/packages/orchestration/src/bot-session-store.mjs +105 -9
- package/packages/orchestration/src/bot-settings.mjs +50 -11
- package/packages/orchestration/src/bot-thread-admission.mjs +84 -0
- package/packages/orchestration/src/bot-thread-host.mjs +187 -0
- package/packages/orchestration/src/bot-threads.mjs +790 -0
- package/packages/orchestration/src/data-product-access.mjs +37 -0
- package/packages/orchestration/src/data-tool-contract.mjs +291 -0
- package/packages/orchestration/src/desktop-http-carrier.mjs +120 -0
- package/packages/orchestration/src/desktop-proxy.mjs +311 -0
- package/packages/orchestration/src/desktop-sessions.mjs +43 -9
- package/packages/orchestration/src/ds-lifecycle.mjs +31 -4
- package/packages/orchestration/src/grant-refresh-queue.mjs +17 -0
- package/packages/orchestration/src/independent-chat-page.mjs +39 -0
- package/packages/orchestration/src/independent-chat-service.mjs +308 -0
- package/packages/orchestration/src/independent-context-state.mjs +44 -0
- package/packages/orchestration/src/independent-message-wire.mjs +84 -0
- package/packages/orchestration/src/independent-tool-catalog.mjs +175 -0
- package/packages/orchestration/src/independent-tool-families.mjs +73 -0
- package/packages/orchestration/src/independent-tool-host.mjs +344 -0
- package/packages/orchestration/src/main-bot-grant.mjs +15 -0
- package/packages/orchestration/src/main-model-routes.mjs +208 -0
- package/packages/orchestration/src/model-accounting.mjs +99 -35
- package/packages/orchestration/src/model-auxiliary-dispatch.mjs +187 -0
- package/packages/orchestration/src/model-loop-frame.mjs +179 -0
- package/packages/orchestration/src/model-prepared-generation.mjs +175 -0
- package/packages/orchestration/src/model-request-bounds.mjs +111 -0
- package/packages/orchestration/src/native-activity-contract.mjs +491 -0
- package/packages/orchestration/src/native-activity-service.mjs +102 -0
- package/packages/orchestration/src/native-activity-store.mjs +249 -0
- package/packages/orchestration/src/native-conversation-tools.mjs +78 -0
- package/packages/orchestration/src/native-data-tools.mjs +100 -0
- package/packages/orchestration/src/native-remote-actions.mjs +742 -0
- package/packages/orchestration/src/native-team-tools.mjs +73 -0
- package/packages/orchestration/src/pairing-invite.mjs +37 -0
- package/packages/orchestration/src/product-composition.mjs +1559 -1001
- package/packages/orchestration/src/remote-machines.mjs +82 -14
- package/packages/orchestration/src/routine-execution.mjs +5 -3
- package/packages/orchestration/src/routine-session.mjs +19 -13
- package/packages/orchestration/src/secure-pairing-host.mjs +112 -0
- package/packages/orchestration/src/task-journal.mjs +29 -0
- package/packages/orchestration/src/task-product.mjs +17 -0
- package/packages/orchestration/src/team-assignment-store.mjs +120 -0
- package/packages/orchestration/src/team-bridge.mjs +282 -0
- package/packages/orchestration/src/team-scheduler.mjs +83 -0
- package/packages/orchestration/src/team-sdk-tools.mjs +84 -0
- package/packages/orchestration/src/team-tool-contract.mjs +284 -0
- package/packages/orchestration/src/ui-host-namespace.mjs +23 -0
- package/packages/orchestration/src/web-panel-actions.mjs +103 -0
- package/packages/orchestration/src/web-panel-framing.mjs +227 -0
- package/packages/orchestration/src/web-panel-store.mjs +206 -0
- package/remote-computer-agent/README.md +39 -29
- package/remote-computer-agent/build.mjs +3 -0
- package/remote-computer-agent/dist/OPENMAUSBOT_LICENSE +202 -0
- package/remote-computer-agent/dist/OPENMAUSBOT_NOTICE +10 -0
- package/remote-computer-agent/dist/OPENMAUSBOT_SOURCE.json +68 -0
- package/remote-computer-agent/dist/cli-stdio-bridge.mjs +215 -25
- package/remote-computer-agent/dist/cli-stdio-bridge.mjs.map +4 -4
- package/remote-computer-agent/dist/cli.mjs +1688 -168
- package/remote-computer-agent/dist/cli.mjs.map +4 -4
- package/remote-computer-agent/dist/index.mjs +1579 -122
- package/remote-computer-agent/dist/index.mjs.map +4 -4
- package/remote-computer-agent/dist/native-peer.ps1 +51 -3
- package/remote-computer-agent/package-lock.json +308 -2
- package/remote-computer-agent/package.json +2 -1
- package/remote-computer-agent/pair-device.ps1 +20 -0
- package/remote-computer-agent/setup.ps1 +38 -16
- package/remote-computer-agent/src/cli.ts +24 -3
- package/remote-computer-agent/src/desktop-session.ts +11 -3
- package/remote-computer-agent/src/e2e-server.ts +81 -0
- package/remote-computer-agent/src/pairing-page.ts +35 -0
- package/remote-computer-agent/src/protocol.ts +25 -25
- package/remote-computer-agent/src/secure-pairing.ts +105 -0
- package/remote-computer-agent/src/store.ts +20 -5
- package/remote-computer-agent/src/transport.ts +39 -15
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The native MCP door for the four teammate-coordination tools.
|
|
3
|
+
*
|
|
4
|
+
* This is the independent-runtime half of the team family: it wraps the coordination
|
|
5
|
+
* service (createTeamCoordination in team-bridge.mjs) in the same handler shape the
|
|
6
|
+
* native conversation tools use (native-conversation-tools.mjs), reading names,
|
|
7
|
+
* descriptions and schemas from the ONE shared contract (team-tool-contract.mjs) so the
|
|
8
|
+
* native and SDK doors cannot drift.
|
|
9
|
+
*
|
|
10
|
+
* Authority: the calling Bot and its conversation are bound here from the Host-resolved
|
|
11
|
+
* native identity (`callerBotId`, `conversationId`) — never from the tool arguments,
|
|
12
|
+
* which parseTeamToolArgs has already refused any `botId`/`owner`/route/session key in.
|
|
13
|
+
* Every call re-runs the injected `validate()` around each awaited step, exactly as the
|
|
14
|
+
* other native doors do, so a subject, funding or credential that changed stops the call.
|
|
15
|
+
*
|
|
16
|
+
* A refusal is returned as a structured value the model can read, never a thrown crash:
|
|
17
|
+
* the model is told the coded reason and, for a durable identity it already holds, what
|
|
18
|
+
* to do next. An unknown outcome is never replayed from here.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { TEAM_TOOL_ENTRIES, TEAM_CODES, parseTeamToolArgs, projectCoordinateArgs } from './team-tool-contract.mjs'
|
|
22
|
+
import { redactNativeToolValue } from './native-conversation-tools.mjs'
|
|
23
|
+
|
|
24
|
+
const reference = value => typeof value === 'string' && /^[A-Za-z0-9_.:-]{1,160}$/.test(value) ? value : null
|
|
25
|
+
const safeCode = code => /^[A-Z][A-Z0-9_:-]{0,95}$/.test(code ?? '') ? code : 'TEAM_CALL_FAILED'
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @param {{
|
|
29
|
+
* service: object, // createTeamCoordination()
|
|
30
|
+
* callerBotId: string, // Host-resolved native identity botId
|
|
31
|
+
* conversationId?: string | null, // Host-resolved per-work-thread conversationId
|
|
32
|
+
* sessionId?: string | null,
|
|
33
|
+
* validate: () => Promise<void>, // re-check subject/funding/credential per step
|
|
34
|
+
* redact?: (text: string) => string,
|
|
35
|
+
* }} options
|
|
36
|
+
*/
|
|
37
|
+
export function createNativeTeamTools({ service, callerBotId, conversationId = null, sessionId = null, validate, redact = text => text } = {}) {
|
|
38
|
+
if (!service || typeof service.coordinateBots !== 'function') throw new TypeError('NATIVE_TEAM_REQUIRES_SERVICE')
|
|
39
|
+
if (typeof callerBotId !== 'string' || !callerBotId) throw new TypeError('NATIVE_TEAM_REQUIRES_CALLER')
|
|
40
|
+
if (typeof validate !== 'function') throw new TypeError('NATIVE_TEAM_REQUIRES_VALIDATE')
|
|
41
|
+
|
|
42
|
+
const handlers = TEAM_TOOL_ENTRIES.filter(() => service.canUse(callerBotId)).map(entry => ({
|
|
43
|
+
definition: { name: entry.name, description: entry.description, inputSchema: entry.inputSchema },
|
|
44
|
+
capability: entry.capability,
|
|
45
|
+
parse: args => parseTeamToolArgs(entry.name, args),
|
|
46
|
+
render: value => ({ content: [{ type: 'text', text: JSON.stringify(redactNativeToolValue(value, redact)) }], ...(value?.error ? { isError: true } : {}) }),
|
|
47
|
+
async execute(args, context) {
|
|
48
|
+
const turn = context.context
|
|
49
|
+
if (!turn?.turnId || !turn.callId || !context.signal) throw new Error('NATIVE_TOOL_TURN_REQUIRED')
|
|
50
|
+
const check = async () => { context.signal.throwIfAborted(); await validate(); context.signal.throwIfAborted(); if (!service.canUse(callerBotId)) throw Object.assign(new Error('TEAM_CALLER_NOT_AUTHORIZED'), { code: 'TEAM_CALLER_NOT_AUTHORIZED' }) }
|
|
51
|
+
try {
|
|
52
|
+
await check()
|
|
53
|
+
const request = { callerBotId, conversationId, sessionId, turnId: turn.turnId, callId: turn.callId, signal: context.signal }
|
|
54
|
+
let value
|
|
55
|
+
if (entry.method === 'coordinateBots') {
|
|
56
|
+
value = await service.coordinateBots({ ...request, args: projectCoordinateArgs(args) })
|
|
57
|
+
}
|
|
58
|
+
else if (entry.method === 'assignmentStatus') value = await service.assignmentStatus({ ...request, args })
|
|
59
|
+
else if (entry.method === 'listBots') value = await service.listBots(request)
|
|
60
|
+
else value = await service.listThreads(request)
|
|
61
|
+
await check()
|
|
62
|
+
service.validateResult?.(request, value)
|
|
63
|
+
return redactNativeToolValue(value, redact)
|
|
64
|
+
} catch (error) {
|
|
65
|
+
try { await check() } catch (changed) { error = changed }
|
|
66
|
+
const coded = safeCode(error?.code)
|
|
67
|
+
return { error: { code: coded, message: redact(String(error?.message ?? error)) } }
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
}))
|
|
71
|
+
|
|
72
|
+
return { tools: handlers.map(handler => handler.definition.name), handlers }
|
|
73
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const fail = code => { throw Object.assign(new Error(code), { code }) }
|
|
2
|
+
const id = value => typeof value === 'string' && /^[-A-Za-z0-9_.]{1,128}$/.test(value)
|
|
3
|
+
const object = (value, allowed) => {
|
|
4
|
+
if (!value || typeof value !== 'object' || Array.isArray(value) || Object.keys(value).some(key => !allowed.includes(key))) fail('PAIRING_INVITE_INVALID')
|
|
5
|
+
}
|
|
6
|
+
const list = value => {
|
|
7
|
+
if (!Array.isArray(value) || value.length > 64 || value.some(item => !id(item)) || new Set(value).size !== value.length) fail('PAIRING_INVITE_INVALID')
|
|
8
|
+
return [...value].sort()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Shared browser/Host shape validation. Cryptographic point validation belongs to the Host transport. */
|
|
12
|
+
export function parseSecureInvite(input) {
|
|
13
|
+
if (typeof input === 'string') {
|
|
14
|
+
if (input.length > 16384) fail('PAIRING_INVITE_INVALID')
|
|
15
|
+
try { input = JSON.parse(input) } catch { fail('PAIRING_INVITE_INVALID') }
|
|
16
|
+
}
|
|
17
|
+
object(input, ['format','version','inviteId','machineId','clientId','name','endpoint','expiresAt','token','code','transport','ceiling'])
|
|
18
|
+
if (input.format !== 'dsh-pairing-invite' || input.version !== 2) fail('PAIRING_VERSION_UNSUPPORTED')
|
|
19
|
+
if (![input.inviteId,input.machineId,input.clientId].every(id) || !Number.isSafeInteger(input.expiresAt) || input.expiresAt <= 0
|
|
20
|
+
|| typeof input.name !== 'string' || !input.name || input.name.length > 128 || /[\u0000-\u001f\u007f]/.test(input.name)
|
|
21
|
+
|| typeof input.token !== 'string' || !/^dsh_pair_[A-Za-z0-9_-]{43}$/.test(input.token)
|
|
22
|
+
|| input.code !== undefined && (typeof input.code !== 'string' || !/^\d{6}$/.test(input.code))) fail('PAIRING_INVITE_INVALID')
|
|
23
|
+
let endpoint
|
|
24
|
+
try { endpoint = new URL(input.endpoint) } catch { fail('PAIRING_INVITE_INVALID') }
|
|
25
|
+
if (!['http:','https:'].includes(endpoint.protocol) || endpoint.username || endpoint.password || endpoint.pathname !== '/' || endpoint.search || endpoint.hash || endpoint.href.length > 1024) fail('PAIRING_INVITE_INVALID')
|
|
26
|
+
object(input.transport, ['kind','publicKey','fingerprint'])
|
|
27
|
+
if (input.transport.kind !== 'noise-v1' || typeof input.transport.publicKey !== 'string' || !/^[A-Za-z0-9_-]{87}$/.test(input.transport.publicKey)
|
|
28
|
+
|| typeof input.transport.fingerprint !== 'string' || !/^[a-f0-9]{64}$/.test(input.transport.fingerprint)) fail('PAIRING_TRANSPORT_INVALID')
|
|
29
|
+
object(input.ceiling, ['botIds','hostManagedBots','roots','tools'])
|
|
30
|
+
if (input.ceiling.hostManagedBots !== undefined && typeof input.ceiling.hostManagedBots !== 'boolean') fail('PAIRING_INVITE_INVALID')
|
|
31
|
+
const ceiling = { botIds: list(input.ceiling.botIds ?? []), roots: list(input.ceiling.roots), tools: list(input.ceiling.tools),
|
|
32
|
+
...(input.ceiling.hostManagedBots === true ? { hostManagedBots: true } : {}) }
|
|
33
|
+
if (!ceiling.roots.length || !ceiling.tools.includes('machine_ping') || !ceiling.hostManagedBots && !ceiling.botIds.length) fail('PAIRING_INVITE_INVALID')
|
|
34
|
+
return { format: input.format, version: 2, inviteId: input.inviteId, machineId: input.machineId, clientId: input.clientId,
|
|
35
|
+
name: input.name, endpoint: endpoint.origin, expiresAt: input.expiresAt, token: input.token, ...(input.code ? { code: input.code } : {}),
|
|
36
|
+
transport: { ...input.transport }, ceiling }
|
|
37
|
+
}
|