agentxgo 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -2
- package/dist/adapters/codex/client.js +6 -0
- package/dist/adapters/dsh/client.js +6 -0
- package/dist/adapters/runtime-http/client.js +101 -0
- package/dist/adapters/runtime-http/endpoint.js +15 -0
- package/dist/bootstrap.js +161 -0
- package/dist/cli.js +134 -0
- package/dist/communication/assembly.js +172 -0
- package/dist/communication/calls.js +107 -0
- package/dist/communication/config.js +33 -0
- package/dist/communication/pump.js +136 -0
- package/dist/computer/authority.js +67 -0
- package/dist/computer/automatic.js +163 -0
- package/dist/computer/automation-main.js +59 -0
- package/dist/computer/automation.js +229 -0
- package/dist/computer/backend.js +160 -0
- package/dist/computer/clipboard.js +72 -0
- package/dist/computer/config.js +66 -0
- package/dist/computer/controller.js +378 -0
- package/dist/computer/desktop.js +225 -0
- package/dist/computer/job-main.js +114 -0
- package/dist/computer/main.js +9 -0
- package/dist/computer/native.js +28 -0
- package/dist/computer/processes.js +165 -0
- package/dist/computer/release.js +40 -0
- package/dist/computer/scratch.js +171 -0
- package/dist/computer/service.js +46 -0
- package/dist/computer/worker.js +70 -0
- package/dist/config.js +156 -0
- package/dist/continuation/checkpoints.js +98 -0
- package/dist/continuation/commands.js +81 -0
- package/dist/continuation/coordinator.js +490 -0
- package/dist/continuation/corrections.js +154 -0
- package/dist/continuation/events.js +171 -0
- package/dist/continuation/failure.js +93 -0
- package/dist/continuation/listening.js +24 -0
- package/dist/continuation/local-wait.js +67 -0
- package/dist/continuation/observations.js +100 -0
- package/dist/continuation/parking.js +190 -0
- package/dist/continuation/reading.js +77 -0
- package/dist/conversations/pump.js +158 -0
- package/dist/conversations/runtime-http.js +88 -0
- package/dist/deployment/cold-qualification.js +119 -0
- package/dist/deployment/cold-release.js +56 -0
- package/dist/deployment/components/cli.js +45 -0
- package/dist/deployment/components/lock.js +38 -0
- package/dist/deployment/components/manager.js +281 -0
- package/dist/deployment/components/release.js +50 -0
- package/dist/deployment/components/runner.js +15 -0
- package/dist/deployment/components/supervisor.js +289 -0
- package/dist/deployment/components/verify.js +66 -0
- package/dist/deployment/components/windows.js +70 -0
- package/dist/deployment/config.js +89 -0
- package/dist/deployment/failure.js +24 -0
- package/dist/deployment/kernel.js +85 -0
- package/dist/deployment/macos/activate.js +140 -0
- package/dist/deployment/macos/attachment.js +42 -0
- package/dist/deployment/macos/handoff.js +140 -0
- package/dist/deployment/macos/install.js +223 -0
- package/dist/deployment/macos/plan.js +155 -0
- package/dist/deployment/macos/proof.js +24 -0
- package/dist/deployment/main.js +16 -0
- package/dist/deployment/members.js +58 -0
- package/dist/deployment/preflight.js +41 -0
- package/dist/deployment/recovery-route.js +18 -0
- package/dist/deployment/runtime.js +114 -0
- package/dist/deployment/system.js +112 -0
- package/dist/deployment/windows-state.js +32 -0
- package/dist/doctor/config.js +155 -0
- package/dist/doctor/probe.js +212 -0
- package/dist/doctor/process.js +31 -0
- package/dist/doctor/run.js +105 -0
- package/dist/enrollment/cli.js +57 -0
- package/dist/enrollment/defaults.js +54 -0
- package/dist/enrollment/device.js +314 -0
- package/dist/enrollment/login.js +107 -0
- package/dist/enrollment/setup.js +164 -0
- package/dist/enrollment/terminal.js +55 -0
- package/dist/execution/artifact.js +157 -0
- package/dist/execution/codex/authority.js +356 -0
- package/dist/execution/codex/catalog.js +24 -0
- package/dist/execution/codex/config.js +77 -0
- package/dist/execution/codex/directories.js +67 -0
- package/dist/execution/codex/main.js +17 -0
- package/dist/execution/codex/read.js +35 -0
- package/dist/execution/codex/record.js +121 -0
- package/dist/execution/codex/role.js +2 -0
- package/dist/execution/codex/stream.js +2 -0
- package/dist/execution/codex/window-receipts.js +73 -0
- package/dist/execution/codex/wire.js +56 -0
- package/dist/execution/codex/worker.js +143 -0
- package/dist/execution/config.js +215 -0
- package/dist/execution/environment.js +61 -0
- package/dist/execution/gateway.js +212 -0
- package/dist/execution/lease-watchdog.js +172 -0
- package/dist/execution/local.js +159 -0
- package/dist/execution/main.js +71 -0
- package/dist/execution/native/config.js +45 -0
- package/dist/execution/native/input.js +7 -0
- package/dist/execution/native/main.js +9 -0
- package/dist/execution/native/records.js +168 -0
- package/dist/execution/native/worker.js +128 -0
- package/dist/execution/native-job-gate.js +63 -0
- package/dist/execution/process-types.js +1 -0
- package/dist/execution/process.js +246 -0
- package/dist/execution/results.js +111 -0
- package/dist/execution/role.js +210 -0
- package/dist/execution/runner.js +338 -0
- package/dist/execution/scope.js +415 -0
- package/dist/execution/scratch-files.js +352 -0
- package/dist/execution/scratch-paths.js +56 -0
- package/dist/execution/scratch.js +126 -0
- package/dist/execution/stdio.js +83 -0
- package/dist/execution/stream.js +159 -0
- package/dist/execution/watchdog.js +181 -0
- package/dist/execution/work.js +76 -0
- package/dist/execution/worker.js +106 -0
- package/dist/help.js +21 -0
- package/dist/lifecycle/http.js +178 -0
- package/dist/lifecycle/runtime.js +263 -0
- package/dist/lifecycle/status-command.js +78 -0
- package/dist/lifecycle/status.js +37 -0
- package/dist/lifecycle/wake-hints.js +68 -0
- package/dist/main.js +59 -0
- package/dist/ports/reports.js +1 -0
- package/dist/ports/runtime.js +1 -0
- package/dist/preparation/backend.js +44 -0
- package/dist/preparation/binding.js +47 -0
- package/dist/preparation/bootstrap.js +165 -0
- package/dist/preparation/config.js +143 -0
- package/dist/preparation/coordinator.js +251 -0
- package/dist/preparation/main.js +58 -0
- package/dist/preparation/runtime.js +122 -0
- package/dist/receptions/pump.js +109 -0
- package/dist/receptions/runtime-http.js +115 -0
- package/dist/recovery/activation.js +178 -0
- package/dist/recovery/admission.js +95 -0
- package/dist/recovery/automatic-preparation.js +194 -0
- package/dist/recovery/automatic-recovery.js +210 -0
- package/dist/recovery/confirmed-binding.js +45 -0
- package/dist/recovery/coordinator.js +351 -0
- package/dist/recovery/execution-policy.js +26 -0
- package/dist/recovery/preparation-policy.js +30 -0
- package/dist/recovery/prestart.js +62 -0
- package/dist/recovery/quarantine.js +153 -0
- package/dist/recovery/service-restart-view.js +32 -0
- package/dist/recovery/service-restart.js +368 -0
- package/dist/reports/pump.js +98 -0
- package/dist/resources/admission.js +25 -0
- package/dist/resources/guard.js +14 -0
- package/node_modules/@agent-stack/adapter-agentim/dist/account.js +42 -0
- package/node_modules/@agent-stack/adapter-agentim/dist/connection-file.js +32 -0
- package/node_modules/@agent-stack/adapter-agentim/dist/direct.js +114 -0
- package/node_modules/@agent-stack/adapter-agentim/dist/local.js +238 -0
- package/node_modules/@agent-stack/adapter-agentim/dist/operations-arguments.js +20 -0
- package/node_modules/@agent-stack/adapter-agentim/dist/operations-communication.js +56 -0
- package/node_modules/@agent-stack/adapter-agentim/dist/operations-operator.js +40 -0
- package/node_modules/@agent-stack/adapter-agentim/package.json +15 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/automatic-activation.js +94 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/automatic-preparation.js +90 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/checkpoint-seal.js +89 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/communication.js +238 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/computer-scratch.js +56 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/computer.js +183 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/database.js +174 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/index.js +4 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/input.js +55 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/journal.js +396 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/models.js +35 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/native-calls.js +123 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/native-window.js +12 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/observations.js +237 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/preparation.js +117 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/recovery-history.js +30 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/recovery-record.js +32 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/recovery.js +256 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/reports.js +105 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/runtime-events.js +246 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/runtime-settings.js +95 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/target-actions.js +355 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/target-local.js +210 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/target-scratch.js +207 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/terminal-checkpoints.js +286 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/terminal-store.js +136 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/trace-inputs.js +104 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/upgrade.js +25 -0
- package/node_modules/@agent-stack/bot-host-journal/dist/waits.js +213 -0
- package/node_modules/@agent-stack/bot-host-journal/package.json +10 -0
- package/node_modules/@agent-stack/bridge-client/dist/bot-transport.js +339 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/agents.js +22 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/bots/assistant.js +26 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/bots/auth.js +9 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/bots/client.js +160 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/bots/inventory.js +55 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/bots/native-events.js +52 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/bots/owner-route.js +21 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/bots/reports.js +41 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/bots/runtime.js +190 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/bridge-client.js +37 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/core.js +123 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/deployments.js +57 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/integrations.js +45 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/knowledge.js +33 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/management.js +112 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/platform-events.js +59 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/platform.js +82 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/public-runtime.js +94 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/run-work-acknowledgement.js +54 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/run-work-errors.js +34 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/runtime.js +46 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/tenant/authorization.js +7 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/tenant/management.js +59 -0
- package/node_modules/@agent-stack/bridge-client/dist/client/workspace.js +109 -0
- package/node_modules/@agent-stack/bridge-client/dist/index.js +9 -0
- package/node_modules/@agent-stack/bridge-client/package.json +11 -0
- package/node_modules/@agent-stack/contracts/dist/api-credentials.js +103 -0
- package/node_modules/@agent-stack/contracts/dist/bots/assistant-path.js +24 -0
- package/node_modules/@agent-stack/contracts/dist/bots/assistant.js +2 -0
- package/node_modules/@agent-stack/contracts/dist/bots/capabilities.js +66 -0
- package/node_modules/@agent-stack/contracts/dist/bots/capability-migration.js +1 -0
- package/node_modules/@agent-stack/contracts/dist/bots/capability-version.js +48 -0
- package/node_modules/@agent-stack/contracts/dist/bots/codex-policy.js +22 -0
- package/node_modules/@agent-stack/contracts/dist/bots/command-evidence.js +101 -0
- package/node_modules/@agent-stack/contracts/dist/bots/command-inventory.js +74 -0
- package/node_modules/@agent-stack/contracts/dist/bots/command-receipt.js +78 -0
- package/node_modules/@agent-stack/contracts/dist/bots/communication-native.js +33 -0
- package/node_modules/@agent-stack/contracts/dist/bots/communication-stream.js +13 -0
- package/node_modules/@agent-stack/contracts/dist/bots/communication.js +154 -0
- package/node_modules/@agent-stack/contracts/dist/bots/component-status.js +38 -0
- package/node_modules/@agent-stack/contracts/dist/bots/components.js +10 -0
- package/node_modules/@agent-stack/contracts/dist/bots/computer-validation.js +320 -0
- package/node_modules/@agent-stack/contracts/dist/bots/computer.js +10 -0
- package/node_modules/@agent-stack/contracts/dist/bots/conversations.js +31 -0
- package/node_modules/@agent-stack/contracts/dist/bots/corrections.js +1 -0
- package/node_modules/@agent-stack/contracts/dist/bots/delegation-renewal.js +17 -0
- package/node_modules/@agent-stack/contracts/dist/bots/delegation.js +35 -0
- package/node_modules/@agent-stack/contracts/dist/bots/delivery-history.js +115 -0
- package/node_modules/@agent-stack/contracts/dist/bots/delivery-read.js +121 -0
- package/node_modules/@agent-stack/contracts/dist/bots/elicitation.js +83 -0
- package/node_modules/@agent-stack/contracts/dist/bots/entries.js +65 -0
- package/node_modules/@agent-stack/contracts/dist/bots/event-exchanges.js +1 -0
- package/node_modules/@agent-stack/contracts/dist/bots/goal-window.js +84 -0
- package/node_modules/@agent-stack/contracts/dist/bots/host-actions.js +191 -0
- package/node_modules/@agent-stack/contracts/dist/bots/identities.js +1 -0
- package/node_modules/@agent-stack/contracts/dist/bots/index.js +72 -0
- package/node_modules/@agent-stack/contracts/dist/bots/installation.js +9 -0
- package/node_modules/@agent-stack/contracts/dist/bots/interaction-validation.js +227 -0
- package/node_modules/@agent-stack/contracts/dist/bots/interactions.js +1 -0
- package/node_modules/@agent-stack/contracts/dist/bots/lifecycle.js +13 -0
- package/node_modules/@agent-stack/contracts/dist/bots/local-execution.js +72 -0
- package/node_modules/@agent-stack/contracts/dist/bots/mcp-capabilities.js +53 -0
- package/node_modules/@agent-stack/contracts/dist/bots/mission.js +3 -0
- package/node_modules/@agent-stack/contracts/dist/bots/model-routing.js +43 -0
- package/node_modules/@agent-stack/contracts/dist/bots/native-events-validation.js +229 -0
- package/node_modules/@agent-stack/contracts/dist/bots/native-events.js +4 -0
- package/node_modules/@agent-stack/contracts/dist/bots/native-fact.js +32 -0
- package/node_modules/@agent-stack/contracts/dist/bots/native-host.js +10 -0
- package/node_modules/@agent-stack/contracts/dist/bots/observation.js +42 -0
- package/node_modules/@agent-stack/contracts/dist/bots/owner-progress.js +85 -0
- package/node_modules/@agent-stack/contracts/dist/bots/owner-transition.js +169 -0
- package/node_modules/@agent-stack/contracts/dist/bots/parking.js +75 -0
- package/node_modules/@agent-stack/contracts/dist/bots/preferences.js +39 -0
- package/node_modules/@agent-stack/contracts/dist/bots/preparations.js +2 -0
- package/node_modules/@agent-stack/contracts/dist/bots/project-oauth.js +1 -0
- package/node_modules/@agent-stack/contracts/dist/bots/quarantine-installation.js +117 -0
- package/node_modules/@agent-stack/contracts/dist/bots/quarantine.js +186 -0
- package/node_modules/@agent-stack/contracts/dist/bots/read-recovery.js +10 -0
- package/node_modules/@agent-stack/contracts/dist/bots/receptions.js +7 -0
- package/node_modules/@agent-stack/contracts/dist/bots/recovery-admission.js +163 -0
- package/node_modules/@agent-stack/contracts/dist/bots/recovery-errors.js +51 -0
- package/node_modules/@agent-stack/contracts/dist/bots/recovery-history.js +90 -0
- package/node_modules/@agent-stack/contracts/dist/bots/recovery-source.js +164 -0
- package/node_modules/@agent-stack/contracts/dist/bots/recovery-validation.js +160 -0
- package/node_modules/@agent-stack/contracts/dist/bots/recovery.js +13 -0
- package/node_modules/@agent-stack/contracts/dist/bots/relay.js +21 -0
- package/node_modules/@agent-stack/contracts/dist/bots/report-status.js +99 -0
- package/node_modules/@agent-stack/contracts/dist/bots/reports.js +8 -0
- package/node_modules/@agent-stack/contracts/dist/bots/restart-source.js +151 -0
- package/node_modules/@agent-stack/contracts/dist/bots/runtime-command.js +59 -0
- package/node_modules/@agent-stack/contracts/dist/bots/runtime-input.js +80 -0
- package/node_modules/@agent-stack/contracts/dist/bots/runtime-provider.js +12 -0
- package/node_modules/@agent-stack/contracts/dist/bots/runtime-settings.js +63 -0
- package/node_modules/@agent-stack/contracts/dist/bots/runtime-validation.js +35 -0
- package/node_modules/@agent-stack/contracts/dist/bots/runtime.js +1 -0
- package/node_modules/@agent-stack/contracts/dist/bots/same-native.js +44 -0
- package/node_modules/@agent-stack/contracts/dist/bots/service-restart.js +80 -0
- package/node_modules/@agent-stack/contracts/dist/bots/status.js +1 -0
- package/node_modules/@agent-stack/contracts/dist/bots/sync.js +1 -0
- package/node_modules/@agent-stack/contracts/dist/bots/targets.js +95 -0
- package/node_modules/@agent-stack/contracts/dist/bots/validation.js +82 -0
- package/node_modules/@agent-stack/contracts/dist/bots/versions.js +6 -0
- package/node_modules/@agent-stack/contracts/dist/bots/wake-hints.js +20 -0
- package/node_modules/@agent-stack/contracts/dist/bots/work-brief.js +120 -0
- package/node_modules/@agent-stack/contracts/dist/bots/work-control.js +47 -0
- package/node_modules/@agent-stack/contracts/dist/bots/work-events.js +38 -0
- package/node_modules/@agent-stack/contracts/dist/browser-chat-attachment.js +66 -0
- package/node_modules/@agent-stack/contracts/dist/business-outcomes.js +1 -0
- package/node_modules/@agent-stack/contracts/dist/chat-attachment.js +70 -0
- package/node_modules/@agent-stack/contracts/dist/chat-stream.js +105 -0
- package/node_modules/@agent-stack/contracts/dist/contracts/agent-ui.js +1 -0
- package/node_modules/@agent-stack/contracts/dist/contracts/base.js +6 -0
- package/node_modules/@agent-stack/contracts/dist/contracts/deployments.js +6 -0
- package/node_modules/@agent-stack/contracts/dist/contracts/index.js +8 -0
- package/node_modules/@agent-stack/contracts/dist/contracts/integrations.js +13 -0
- package/node_modules/@agent-stack/contracts/dist/contracts/knowledge.js +69 -0
- package/node_modules/@agent-stack/contracts/dist/contracts/live.js +56 -0
- package/node_modules/@agent-stack/contracts/dist/contracts/runtime.js +1 -0
- package/node_modules/@agent-stack/contracts/dist/contracts/workspace.js +9 -0
- package/node_modules/@agent-stack/contracts/dist/delivery-targets.js +139 -0
- package/node_modules/@agent-stack/contracts/dist/desktop-mcp.js +105 -0
- package/node_modules/@agent-stack/contracts/dist/employee-association.js +31 -0
- package/node_modules/@agent-stack/contracts/dist/event-links.js +1 -0
- package/node_modules/@agent-stack/contracts/dist/execution-oauth-callback.js +61 -0
- package/node_modules/@agent-stack/contracts/dist/host-page-context.js +156 -0
- package/node_modules/@agent-stack/contracts/dist/index.js +115 -0
- package/node_modules/@agent-stack/contracts/dist/installation-lifecycle.js +1 -0
- package/node_modules/@agent-stack/contracts/dist/installation-mcp.js +5 -0
- package/node_modules/@agent-stack/contracts/dist/installations.js +7 -0
- package/node_modules/@agent-stack/contracts/dist/integration-context.js +22 -0
- package/node_modules/@agent-stack/contracts/dist/integration-oauth.js +23 -0
- package/node_modules/@agent-stack/contracts/dist/integration-runtime.js +107 -0
- package/node_modules/@agent-stack/contracts/dist/interactive-run-wake.js +78 -0
- package/node_modules/@agent-stack/contracts/dist/interactive-work-acknowledgement.js +74 -0
- package/node_modules/@agent-stack/contracts/dist/interactive-work-events.js +131 -0
- package/node_modules/@agent-stack/contracts/dist/interactive-work-sources.js +142 -0
- package/node_modules/@agent-stack/contracts/dist/knowledge-attachment.js +50 -0
- package/node_modules/@agent-stack/contracts/dist/knowledge-catalog.js +94 -0
- package/node_modules/@agent-stack/contracts/dist/knowledge-organization.js +87 -0
- package/node_modules/@agent-stack/contracts/dist/live-audio.js +46 -0
- package/node_modules/@agent-stack/contracts/dist/live-business.js +1 -0
- package/node_modules/@agent-stack/contracts/dist/live-human.js +1 -0
- package/node_modules/@agent-stack/contracts/dist/live-transport.js +2 -0
- package/node_modules/@agent-stack/contracts/dist/mcp-directory.js +7 -0
- package/node_modules/@agent-stack/contracts/dist/mcp-refresh.js +1 -0
- package/node_modules/@agent-stack/contracts/dist/mcp-scopes.js +24 -0
- package/node_modules/@agent-stack/contracts/dist/native-studio-installation.js +1 -0
- package/node_modules/@agent-stack/contracts/dist/oauth-authorization.js +19 -0
- package/node_modules/@agent-stack/contracts/dist/platform-events.js +182 -0
- package/node_modules/@agent-stack/contracts/dist/reply-presentation.js +59 -0
- package/node_modules/@agent-stack/contracts/dist/reply.js +129 -0
- package/node_modules/@agent-stack/contracts/dist/request-body.js +38 -0
- package/node_modules/@agent-stack/contracts/dist/schedules.js +1 -0
- package/node_modules/@agent-stack/contracts/dist/task-work-events.js +107 -0
- package/node_modules/@agent-stack/contracts/dist/tasks.js +200 -0
- package/node_modules/@agent-stack/contracts/dist/templates.js +1 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/access-schemas.js +149 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/access-views.js +17 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/access.js +132 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/actions.js +173 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/attachments.js +68 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/authorization.js +160 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/capabilities.js +98 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/connections.js +31 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/conversation-work-events.js +72 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/conversation-work-schemas.js +136 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/conversations.js +31 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/deliveries.js +120 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/delivery-views.js +38 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/deployment-catalog.js +50 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/descriptor.js +50 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/events.js +39 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/feedback.js +161 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/guidance.js +284 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/host-enrollment.js +51 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/identity.js +31 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/installation-schemas.js +350 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/installation-views.js +69 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/installations.js +217 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/integration-configuration.js +96 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/integration-oauth.js +85 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/integrations.js +75 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/json.js +96 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/knowledge-management-input.js +211 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/knowledge-management-results.js +145 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/knowledge-management-schemas.js +139 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/knowledge-management.js +32 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/knowledge-organization.js +96 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/knowledge-program-input.js +111 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/knowledge-program-results.js +234 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/knowledge-programs.js +15 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/live.js +63 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/marketplace-schemas.js +110 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/marketplaces.js +51 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/mcp-directory.js +98 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/native-operations.js +113 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/operations.js +36 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/outcome-schemas.js +121 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/outcomes.js +87 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/queries.js +24 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/resource-views.js +463 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/resources.js +1 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/schedule-schemas.js +122 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/schedule-views.js +22 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/schedules.js +109 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/schemas.js +117 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/settings.js +34 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/sse.js +58 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/task-schemas.js +89 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/task-views.js +34 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/tasks.js +41 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/tests.js +1 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/transport.js +2 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/usage.js +61 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/views.js +52 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/widgets.js +215 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/work-changes.js +71 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/work-materials.js +102 -0
- package/node_modules/@agent-stack/contracts/dist/tenant/workspace-resources.js +87 -0
- package/node_modules/@agent-stack/contracts/dist/widget-authorization.js +55 -0
- package/node_modules/@agent-stack/contracts/dist/widget-avatar.js +24 -0
- package/node_modules/@agent-stack/contracts/dist/widget-context.js +57 -0
- package/node_modules/@agent-stack/contracts/dist/widget-conversation.js +13 -0
- package/node_modules/@agent-stack/contracts/dist/widget-host-auth.js +142 -0
- package/node_modules/@agent-stack/contracts/dist/widget-origin.js +16 -0
- package/node_modules/@agent-stack/contracts/dist/widget-turn.js +84 -0
- package/node_modules/@agent-stack/contracts/package.json +8 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/authority.js +64 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/bot/bootstrap.js +81 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/bot/codex-record.js +37 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/bot/codex-target.js +56 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/bot/conversation.js +1 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/bot/index.js +7 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/bot/process-identity.js +18 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/bot/quarantine-material.js +9 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/bot/recovery-inspection.js +103 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/bot/service.js +3 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/execution/index.js +7 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/execution/json.js +169 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/execution/observation.js +40 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/execution/runtime.js +1 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/execution/trace.js +1 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/execution/types.js +32 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/execution/wire.js +167 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/execution/wire.schema.json +1 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/index.js +31 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/interactive-run-wake.js +190 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/legacy.js +1 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/mcp.js +53 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/native-studio-connection.js +46 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/native-studio-execution.js +100 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/native-studio-registration.js +193 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/oauth-context.js +38 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/personal-mcp.js +1 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/signing.js +1 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/source-reply.js +153 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/storage.js +1 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/target-environment.js +45 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/tenant-management.js +57 -0
- package/node_modules/@agent-stack/runtime-contracts/dist/tool-trace.js +1 -0
- package/node_modules/@agent-stack/runtime-contracts/package.json +13 -0
- package/node_modules/@agentims/adapter/dist/authority/binding.js +40 -0
- package/node_modules/@agentims/adapter/dist/delivery/coordinator.js +202 -0
- package/node_modules/@agentims/adapter/dist/delivery/decision.js +51 -0
- package/node_modules/@agentims/adapter/dist/delivery/record.js +24 -0
- package/node_modules/@agentims/adapter/dist/delivery/types.js +1 -0
- package/node_modules/@agentims/adapter/dist/errors.js +40 -0
- package/node_modules/@agentims/adapter/dist/index.js +5 -0
- package/node_modules/@agentims/adapter/dist/lifecycle/budget.js +30 -0
- package/node_modules/@agentims/adapter/dist/receipts/send.js +24 -0
- package/node_modules/@agentims/adapter/dist/source/event-source.js +153 -0
- package/node_modules/@agentims/adapter/dist/source/types.js +1 -0
- package/node_modules/@agentims/adapter/dist/status/adapter-status.js +46 -0
- package/node_modules/@agentims/adapter/package.json +10 -0
- package/node_modules/@agentims/runtime/dist/accounts/backup.js +39 -0
- package/node_modules/@agentims/runtime/dist/accounts/communication.js +14 -0
- package/node_modules/@agentims/runtime/dist/accounts/context.js +36 -0
- package/node_modules/@agentims/runtime/dist/accounts/credential-lifecycle.js +57 -0
- package/node_modules/@agentims/runtime/dist/accounts/errors.js +13 -0
- package/node_modules/@agentims/runtime/dist/accounts/login.js +32 -0
- package/node_modules/@agentims/runtime/dist/accounts/password.js +18 -0
- package/node_modules/@agentims/runtime/dist/accounts/register.js +30 -0
- package/node_modules/@agentims/runtime/dist/accounts/selection.js +93 -0
- package/node_modules/@agentims/runtime/dist/accounts/types.js +1 -0
- package/node_modules/@agentims/runtime/dist/authentication/intent.js +15 -0
- package/node_modules/@agentims/runtime/dist/authentication/journals.js +39 -0
- package/node_modules/@agentims/runtime/dist/authentication/methods.js +42 -0
- package/node_modules/@agentims/runtime/dist/authentication/selection.js +20 -0
- package/node_modules/@agentims/runtime/dist/authentication/status.js +42 -0
- package/node_modules/@agentims/runtime/dist/cli/account-commands.js +72 -0
- package/node_modules/@agentims/runtime/dist/cli/arguments.js +120 -0
- package/node_modules/@agentims/runtime/dist/cli/authentication.js +22 -0
- package/node_modules/@agentims/runtime/dist/cli/command-names.js +9 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/account-authorization.js +12 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/cache-inspection.js +8 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/cache.js +14 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/catalog.js +40 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/contacts.js +5 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/conversations.js +15 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/definition.js +9 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/deliveries-native.js +6 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/deliveries.js +10 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/devices-native.js +7 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/discovery.js +4 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/drafts.js +6 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/encryption-dehydration.js +13 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/encryption-native.js +9 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/encryption-recovery.js +11 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/encryption-reset.js +9 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/encryption-secrets.js +9 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/encryption.js +12 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/identity.js +10 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/location.js +7 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/matrix-capabilities.js +38 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/matrix-identity.js +12 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/matrix-rooms.js +23 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/media.js +12 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/messages-native.js +8 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/messages.js +10 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/native-inspection.js +24 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/native-preferences.js +11 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/native-requests.js +6 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/oauth.js +15 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/outbox.js +10 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/pairing.js +8 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/profiles.js +6 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/qr-authorization.js +6 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/reliability.js +8 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/room-management.js +17 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/rtc.js +14 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/search.js +11 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/sync-qr.js +9 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/timeline-native.js +10 -0
- package/node_modules/@agentims/runtime/dist/cli/commands/verification-native.js +7 -0
- package/node_modules/@agentims/runtime/dist/cli/errors.js +83 -0
- package/node_modules/@agentims/runtime/dist/cli/help.js +74 -0
- package/node_modules/@agentims/runtime/dist/cli/history-commands.js +13 -0
- package/node_modules/@agentims/runtime/dist/cli/input.js +82 -0
- package/node_modules/@agentims/runtime/dist/cli/main.js +19 -0
- package/node_modules/@agentims/runtime/dist/cli/output.js +71 -0
- package/node_modules/@agentims/runtime/dist/cli/password-input.js +36 -0
- package/node_modules/@agentims/runtime/dist/cli/run.js +90 -0
- package/node_modules/@agentims/runtime/dist/cli/update-commands.js +76 -0
- package/node_modules/@agentims/runtime/dist/configuration/account-credential.js +30 -0
- package/node_modules/@agentims/runtime/dist/configuration/connection-descriptor.js +18 -0
- package/node_modules/@agentims/runtime/dist/configuration/device-binding.js +41 -0
- package/node_modules/@agentims/runtime/dist/configuration/environment.js +43 -0
- package/node_modules/@agentims/runtime/dist/configuration/executable.js +49 -0
- package/node_modules/@agentims/runtime/dist/configuration/http.js +4 -0
- package/node_modules/@agentims/runtime/dist/configuration/native-settings.js +13 -0
- package/node_modules/@agentims/runtime/dist/configuration/node-version.js +8 -0
- package/node_modules/@agentims/runtime/dist/configuration/private-state.js +115 -0
- package/node_modules/@agentims/runtime/dist/configuration/service-origin.js +48 -0
- package/node_modules/@agentims/runtime/dist/configuration/windows-command.js +14 -0
- package/node_modules/@agentims/runtime/dist/configuration/windows-security.js +13 -0
- package/node_modules/@agentims/runtime/dist/history/backup.js +45 -0
- package/node_modules/@agentims/runtime/dist/history/online.js +48 -0
- package/node_modules/@agentims/runtime/dist/history/recovery-file.js +19 -0
- package/node_modules/@agentims/runtime/dist/history/restore.js +19 -0
- package/node_modules/@agentims/runtime/dist/index.js +31 -0
- package/node_modules/@agentims/runtime/dist/lifecycle/communication.js +66 -0
- package/node_modules/@agentims/runtime/dist/lifecycle/embedded.js +24 -0
- package/node_modules/@agentims/runtime/dist/lifecycle/foreground-connection.js +61 -0
- package/node_modules/@agentims/runtime/dist/lifecycle/foreground.js +47 -0
- package/node_modules/@agentims/runtime/dist/lifecycle/identity.js +46 -0
- package/node_modules/@agentims/runtime/dist/lifecycle/process-priority.js +22 -0
- package/node_modules/@agentims/runtime/dist/lifecycle/process.js +60 -0
- package/node_modules/@agentims/runtime/dist/lifecycle/shutdown-lease.js +90 -0
- package/node_modules/@agentims/runtime/dist/lifecycle/start.js +69 -0
- package/node_modules/@agentims/runtime/dist/managed/connection.js +29 -0
- package/node_modules/@agentims/runtime/dist/managed/control.js +134 -0
- package/node_modules/@agentims/runtime/dist/managed/directory.js +19 -0
- package/node_modules/@agentims/runtime/dist/managed/errors.js +9 -0
- package/node_modules/@agentims/runtime/dist/managed/lease.js +32 -0
- package/node_modules/@agentims/runtime/dist/managed/shutdown.js +63 -0
- package/node_modules/@agentims/runtime/dist/managed/state.js +82 -0
- package/node_modules/@agentims/runtime/dist/storage/archive.js +89 -0
- package/node_modules/@agentims/runtime/dist/supervision/command.js +13 -0
- package/node_modules/@agentims/runtime/dist/supervision/launchd.js +64 -0
- package/node_modules/@agentims/runtime/dist/supervision/select.js +13 -0
- package/node_modules/@agentims/runtime/dist/supervision/service.js +4 -0
- package/node_modules/@agentims/runtime/dist/supervision/systemd.js +34 -0
- package/node_modules/@agentims/runtime/dist/supervision/windows.js +20 -0
- package/node_modules/@agentims/runtime/dist/updates/activation.js +65 -0
- package/node_modules/@agentims/runtime/dist/updates/admission.js +15 -0
- package/node_modules/@agentims/runtime/dist/updates/archive.js +45 -0
- package/node_modules/@agentims/runtime/dist/updates/binding-preflight.js +25 -0
- package/node_modules/@agentims/runtime/dist/updates/continuity.js +45 -0
- package/node_modules/@agentims/runtime/dist/updates/device-archive.js +43 -0
- package/node_modules/@agentims/runtime/dist/updates/discovery.js +91 -0
- package/node_modules/@agentims/runtime/dist/updates/download.js +66 -0
- package/node_modules/@agentims/runtime/dist/updates/embedded.js +143 -0
- package/node_modules/@agentims/runtime/dist/updates/host-continuation.js +43 -0
- package/node_modules/@agentims/runtime/dist/updates/inspection-config.js +18 -0
- package/node_modules/@agentims/runtime/dist/updates/installation-integrity.js +35 -0
- package/node_modules/@agentims/runtime/dist/updates/installation.js +134 -0
- package/node_modules/@agentims/runtime/dist/updates/ledger.js +75 -0
- package/node_modules/@agentims/runtime/dist/updates/locking.js +17 -0
- package/node_modules/@agentims/runtime/dist/updates/managed.js +271 -0
- package/node_modules/@agentims/runtime/dist/updates/manifest.js +97 -0
- package/node_modules/@agentims/runtime/dist/updates/offline.js +56 -0
- package/node_modules/@agentims/runtime/dist/updates/owner.js +14 -0
- package/node_modules/@agentims/runtime/dist/updates/pending.js +20 -0
- package/node_modules/@agentims/runtime/dist/updates/policy.js +73 -0
- package/node_modules/@agentims/runtime/dist/updates/records.js +33 -0
- package/node_modules/@agentims/runtime/dist/updates/restart.js +80 -0
- package/node_modules/@agentims/runtime/dist/updates/shutdown-owner.js +74 -0
- package/node_modules/@agentims/runtime/dist/updates/shutdown-proof.js +35 -0
- package/node_modules/@agentims/runtime/dist/updates/types.js +16 -0
- package/node_modules/@agentims/runtime/dist/updates/version.js +40 -0
- package/node_modules/@agentims/runtime/dist/updates/watch.js +87 -0
- package/node_modules/@agentims/runtime/package.json +11 -0
- package/node_modules/@agentims/sdk/dist/api/client.js +15 -0
- package/node_modules/@agentims/sdk/dist/api/embedded-options.js +1 -0
- package/node_modules/@agentims/sdk/dist/api/embedded.js +28 -0
- package/node_modules/@agentims/sdk/dist/api/errors.js +43 -0
- package/node_modules/@agentims/sdk/dist/api/facade.js +92 -0
- package/node_modules/@agentims/sdk/dist/api/json-value.js +1 -0
- package/node_modules/@agentims/sdk/dist/api/options.js +1 -0
- package/node_modules/@agentims/sdk/dist/api/request-data.js +43 -0
- package/node_modules/@agentims/sdk/dist/api/sdk-info.js +9 -0
- package/node_modules/@agentims/sdk/dist/features/account/client.js +57 -0
- package/node_modules/@agentims/sdk/dist/features/account/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/account/types.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/cache/client.js +40 -0
- package/node_modules/@agentims/sdk/dist/features/cache/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/cache/types.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/configuration/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/configuration/schema.js +8 -0
- package/node_modules/@agentims/sdk/dist/features/configuration/types.js +3 -0
- package/node_modules/@agentims/sdk/dist/features/contacts/client.js +12 -0
- package/node_modules/@agentims/sdk/dist/features/contacts/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/contacts/types.js +3 -0
- package/node_modules/@agentims/sdk/dist/features/conversations/client.js +54 -0
- package/node_modules/@agentims/sdk/dist/features/conversations/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/conversations/matrix.js +61 -0
- package/node_modules/@agentims/sdk/dist/features/conversations/types.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/deliveries/client.js +41 -0
- package/node_modules/@agentims/sdk/dist/features/deliveries/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/deliveries/types.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/devices/client.js +36 -0
- package/node_modules/@agentims/sdk/dist/features/devices/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/devices/types.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/directory/client.js +36 -0
- package/node_modules/@agentims/sdk/dist/features/directory/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/directory/types.js +3 -0
- package/node_modules/@agentims/sdk/dist/features/discovery/client.js +9 -0
- package/node_modules/@agentims/sdk/dist/features/discovery/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/discovery/types.js +3 -0
- package/node_modules/@agentims/sdk/dist/features/drafts/client.js +16 -0
- package/node_modules/@agentims/sdk/dist/features/drafts/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/drafts/types.js +3 -0
- package/node_modules/@agentims/sdk/dist/features/encryption/client.js +105 -0
- package/node_modules/@agentims/sdk/dist/features/encryption/dehydration.js +36 -0
- package/node_modules/@agentims/sdk/dist/features/encryption/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/encryption/types.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/events/client.js +45 -0
- package/node_modules/@agentims/sdk/dist/features/events/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/events/types.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/identity/client.js +77 -0
- package/node_modules/@agentims/sdk/dist/features/identity/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/identity/types.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/location/client.js +18 -0
- package/node_modules/@agentims/sdk/dist/features/location/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/location/types.js +3 -0
- package/node_modules/@agentims/sdk/dist/features/media/client.js +34 -0
- package/node_modules/@agentims/sdk/dist/features/media/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/media/types.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/messages/client.js +43 -0
- package/node_modules/@agentims/sdk/dist/features/messages/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/messages/types.js +3 -0
- package/node_modules/@agentims/sdk/dist/features/notifications/client.js +42 -0
- package/node_modules/@agentims/sdk/dist/features/notifications/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/notifications/types.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/oauth/client.js +52 -0
- package/node_modules/@agentims/sdk/dist/features/oauth/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/oauth/types.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/operations/client.js +16 -0
- package/node_modules/@agentims/sdk/dist/features/operations/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/operations/types.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/outbox/client.js +25 -0
- package/node_modules/@agentims/sdk/dist/features/outbox/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/outbox/types.js +3 -0
- package/node_modules/@agentims/sdk/dist/features/pairing/client.js +48 -0
- package/node_modules/@agentims/sdk/dist/features/pairing/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/pairing/types.js +3 -0
- package/node_modules/@agentims/sdk/dist/features/presence/client.js +15 -0
- package/node_modules/@agentims/sdk/dist/features/presence/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/presence/types.js +3 -0
- package/node_modules/@agentims/sdk/dist/features/profiles/client.js +15 -0
- package/node_modules/@agentims/sdk/dist/features/profiles/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/profiles/types.js +3 -0
- package/node_modules/@agentims/sdk/dist/features/reliability/client.js +32 -0
- package/node_modules/@agentims/sdk/dist/features/reliability/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/reliability/observe.js +48 -0
- package/node_modules/@agentims/sdk/dist/features/reliability/types.js +3 -0
- package/node_modules/@agentims/sdk/dist/features/rooms/client.js +76 -0
- package/node_modules/@agentims/sdk/dist/features/rooms/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/rooms/types.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/rtc/client.js +39 -0
- package/node_modules/@agentims/sdk/dist/features/rtc/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/rtc/types.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/search/client.js +31 -0
- package/node_modules/@agentims/sdk/dist/features/search/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/search/types.js +3 -0
- package/node_modules/@agentims/sdk/dist/features/sync/client.js +16 -0
- package/node_modules/@agentims/sdk/dist/features/sync/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/sync/types.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/timeline/client.js +27 -0
- package/node_modules/@agentims/sdk/dist/features/timeline/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/timeline/types.js +3 -0
- package/node_modules/@agentims/sdk/dist/features/verification/client.js +33 -0
- package/node_modules/@agentims/sdk/dist/features/verification/index.js +1 -0
- package/node_modules/@agentims/sdk/dist/features/verification/types.js +3 -0
- package/node_modules/@agentims/sdk/dist/index.js +7 -0
- package/node_modules/@agentims/sdk/dist/internal/native/binding.js +85 -0
- package/node_modules/@agentims/sdk/dist/internal/native/platform-resource.js +15 -0
- package/node_modules/@agentims/sdk/dist/internal/native/secrets-export.js +27 -0
- package/node_modules/@agentims/sdk/dist/internal/native/transport.js +92 -0
- package/node_modules/@agentims/sdk/dist/internal/protocol/codec.js +69 -0
- package/node_modules/@agentims/sdk/dist/internal/protocol/input.js +38 -0
- package/node_modules/@agentims/sdk/dist/internal/protocol/native-settings.js +48 -0
- package/node_modules/@agentims/sdk/dist/internal/protocol/operations.json +1 -0
- package/node_modules/@agentims/sdk/dist/internal/protocol/registry.js +72 -0
- package/node_modules/@agentims/sdk/dist/internal/protocol/schema.js +133 -0
- package/node_modules/@agentims/sdk/dist/internal/transport/client.js +102 -0
- package/node_modules/@agentims/sdk/dist/internal/transport/error-diagnostics.js +50 -0
- package/node_modules/@agentims/sdk/dist/internal/transport/request.js +59 -0
- package/node_modules/@agentims/sdk/dist/internal/transport/response.js +94 -0
- package/node_modules/@agentims/sdk/dist/internal/transport/retry-after.js +21 -0
- package/node_modules/@agentims/sdk/dist/internal/transport/stream-diagnostics.js +19 -0
- package/node_modules/@agentims/sdk/dist/internal/transport/types.js +1 -0
- package/node_modules/@agentims/sdk/package.json +8 -0
- package/package.json +31 -4
- package/release.json +746 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { botId, canonicalBotJson, } from '@agent-stack/contracts';
|
|
3
|
+
const hash = (value) => createHash('sha256').update(canonicalBotJson(value)).digest('hex');
|
|
4
|
+
/** Host 保存原配置意图/结果,不参与 Native 模型许可或中央 ACK。 */
|
|
5
|
+
export class BotRuntimeSettingsJournal {
|
|
6
|
+
storage;
|
|
7
|
+
constructor(storage) {
|
|
8
|
+
this.storage = storage;
|
|
9
|
+
storage.db
|
|
10
|
+
.exec(`CREATE TABLE IF NOT EXISTS runtime_settings(scope_key TEXT PRIMARY KEY,payload TEXT NOT NULL);
|
|
11
|
+
CREATE TABLE IF NOT EXISTS runtime_setting_commands(scope_key TEXT NOT NULL,request_id TEXT NOT NULL,digest TEXT NOT NULL,payload TEXT NOT NULL,result TEXT,PRIMARY KEY(scope_key,request_id));
|
|
12
|
+
CREATE TABLE IF NOT EXISTS runtime_setting_bindings(binding_key TEXT PRIMARY KEY,execution_id TEXT NOT NULL,bot_id TEXT NOT NULL);`);
|
|
13
|
+
}
|
|
14
|
+
/** 原租户/Host 路由已经核对的 Bot 关联仅作冷启动定位,不按版本或 Owner 换 key。 */
|
|
15
|
+
bind(key, executionId, botIdValue) {
|
|
16
|
+
this.storage.db
|
|
17
|
+
.prepare('INSERT INTO runtime_setting_bindings(binding_key,execution_id,bot_id) VALUES(?,?,?) ON CONFLICT(binding_key) DO UPDATE SET execution_id=excluded.execution_id,bot_id=excluded.bot_id')
|
|
18
|
+
.run(botId(key), botId(executionId), botId(botIdValue));
|
|
19
|
+
}
|
|
20
|
+
identity(key, executionId) {
|
|
21
|
+
const row = this.storage.db
|
|
22
|
+
.prepare('SELECT bot_id FROM runtime_setting_bindings WHERE binding_key=? AND execution_id=?')
|
|
23
|
+
.get(botId(key), botId(executionId));
|
|
24
|
+
return row ? String(row.bot_id) : undefined;
|
|
25
|
+
}
|
|
26
|
+
read(key) {
|
|
27
|
+
const row = this.storage.db
|
|
28
|
+
.prepare('SELECT payload FROM runtime_settings WHERE scope_key=?')
|
|
29
|
+
.get(botId(key));
|
|
30
|
+
return row ? JSON.parse(String(row.payload)) : null;
|
|
31
|
+
}
|
|
32
|
+
command(key, request) {
|
|
33
|
+
const row = this.storage.db
|
|
34
|
+
.prepare('SELECT * FROM runtime_setting_commands WHERE scope_key=? AND request_id=?')
|
|
35
|
+
.get(botId(key), botId(request.requestId));
|
|
36
|
+
if (!row)
|
|
37
|
+
return null;
|
|
38
|
+
if (row.digest !== hash(request))
|
|
39
|
+
throw new Error('BOT_RUNTIME_REQUEST_CONFLICT');
|
|
40
|
+
return {
|
|
41
|
+
record: JSON.parse(String(row.payload)),
|
|
42
|
+
result: row.result === null ? null : JSON.parse(String(row.result)),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** 同原请求只增加一次修订;默认值与当前角色保存同一份原始 Native 配置。 */
|
|
46
|
+
save(key, request, settings) {
|
|
47
|
+
return this.storage.transaction(() => {
|
|
48
|
+
const oldCommand = this.command(key, request);
|
|
49
|
+
if (oldCommand)
|
|
50
|
+
return oldCommand;
|
|
51
|
+
const previous = this.read(key);
|
|
52
|
+
const record = {
|
|
53
|
+
desired: {
|
|
54
|
+
selectionRevision: (previous?.desired.selectionRevision ?? 0) + 1,
|
|
55
|
+
requestId: request.requestId,
|
|
56
|
+
settings,
|
|
57
|
+
},
|
|
58
|
+
request,
|
|
59
|
+
default: request.scope === 'BOT_DEFAULT' ? settings : (previous?.default ?? null),
|
|
60
|
+
};
|
|
61
|
+
const payload = canonicalBotJson(record);
|
|
62
|
+
this.storage.db
|
|
63
|
+
.prepare('INSERT INTO runtime_settings(scope_key,payload) VALUES(?,?) ON CONFLICT(scope_key) DO UPDATE SET payload=excluded.payload')
|
|
64
|
+
.run(key, payload);
|
|
65
|
+
this.storage.db
|
|
66
|
+
.prepare('INSERT INTO runtime_setting_commands(scope_key,request_id,digest,payload) VALUES(?,?,?,?)')
|
|
67
|
+
.run(key, request.requestId, hash(request), payload);
|
|
68
|
+
return { record, result: null };
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
result(key, requestId, result) {
|
|
72
|
+
this.storage.db
|
|
73
|
+
.prepare('UPDATE runtime_setting_commands SET result=? WHERE scope_key=? AND request_id=?')
|
|
74
|
+
.run(canonicalBotJson(result), botId(key), botId(requestId));
|
|
75
|
+
}
|
|
76
|
+
/** 首次接管既有 Native 选择时只提升原意图修订;较新的本地命令始终优先。 */
|
|
77
|
+
rebase(key, requestId, floor) {
|
|
78
|
+
return this.storage.transaction(() => {
|
|
79
|
+
const current = this.read(key);
|
|
80
|
+
if (!current || current.desired.requestId !== requestId)
|
|
81
|
+
return null;
|
|
82
|
+
if (current.desired.selectionRevision > floor)
|
|
83
|
+
return current;
|
|
84
|
+
current.desired.selectionRevision = floor + 1;
|
|
85
|
+
const payload = canonicalBotJson(current);
|
|
86
|
+
this.storage.db
|
|
87
|
+
.prepare('UPDATE runtime_settings SET payload=? WHERE scope_key=?')
|
|
88
|
+
.run(payload, key);
|
|
89
|
+
this.storage.db
|
|
90
|
+
.prepare('UPDATE runtime_setting_commands SET payload=? WHERE scope_key=? AND request_id=?')
|
|
91
|
+
.run(payload, key, requestId);
|
|
92
|
+
return current;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import { chmodSync, lstatSync, realpathSync } from 'node:fs';
|
|
2
|
+
import { dirname, isAbsolute } from 'node:path';
|
|
3
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
4
|
+
import { botHostActionIdentity, botHostActionOutcome, botHostActionProcess, botId, canonicalBotJson, } from '@agent-stack/contracts';
|
|
5
|
+
import { TargetScratchStore } from './target-scratch.js';
|
|
6
|
+
import { botTargetNativeWindow } from './native-window.js';
|
|
7
|
+
import { TargetComputerJournal } from './computer.js';
|
|
8
|
+
import { TargetLocalStore } from './target-local.js';
|
|
9
|
+
import { TargetNativeCalls } from './native-calls.js';
|
|
10
|
+
const applicationId = 0x41535441;
|
|
11
|
+
const maxBytes = 64 * 1024 * 1024;
|
|
12
|
+
/** 目标本地账本保存执行回证与独立清理阶段,独立于普通 Host 的同步账本。 */
|
|
13
|
+
export class BotTargetActionJournal {
|
|
14
|
+
capacity;
|
|
15
|
+
clock;
|
|
16
|
+
computer;
|
|
17
|
+
local;
|
|
18
|
+
native;
|
|
19
|
+
db;
|
|
20
|
+
scratch;
|
|
21
|
+
targetId;
|
|
22
|
+
constructor(path, targetId, capacity = 4096, clock = Date.now) {
|
|
23
|
+
this.capacity = capacity;
|
|
24
|
+
this.clock = clock;
|
|
25
|
+
this.targetId = botId(targetId);
|
|
26
|
+
if (!isAbsolute(path) || !Number.isSafeInteger(capacity) || capacity < 1)
|
|
27
|
+
throw new Error('BOT_TARGET_JOURNAL_CONFIG_INVALID');
|
|
28
|
+
const directory = dirname(path);
|
|
29
|
+
const parent = lstatSync(directory, { throwIfNoEntry: false });
|
|
30
|
+
// 目标部署先准备私有真实路径,账本不会沿路径别名创建或改写其它文件。
|
|
31
|
+
if (!parent?.isDirectory() ||
|
|
32
|
+
parent.uid !== process.getuid?.() ||
|
|
33
|
+
(parent.mode & 0o077) !== 0 ||
|
|
34
|
+
realpathSync(directory) !== directory)
|
|
35
|
+
throw new Error('BOT_TARGET_JOURNAL_PRIVATE_DIRECTORY_REQUIRED');
|
|
36
|
+
// lstat 保留悬空链接本身,普通文件也不能通过硬链接复用到别处。
|
|
37
|
+
const previous = lstatSync(path, { throwIfNoEntry: false });
|
|
38
|
+
if (previous && (!previous.isFile() || previous.nlink !== 1 || previous.uid !== parent.uid))
|
|
39
|
+
throw new Error('BOT_TARGET_JOURNAL_FILE_INVALID');
|
|
40
|
+
this.db = new DatabaseSync(path);
|
|
41
|
+
this.native = new TargetNativeCalls(this.db, (work) => this.transact(work));
|
|
42
|
+
this.computer = new TargetComputerJournal(this.db, (work) => this.transact(work), this.targetId, capacity);
|
|
43
|
+
this.scratch = new TargetScratchStore(this.db);
|
|
44
|
+
this.local = new TargetLocalStore(this.db, (work) => this.transact(work), this.targetId, (id) => this.read(id), (identity, local) => this.reserveIdentity(identity, local));
|
|
45
|
+
try {
|
|
46
|
+
// 在第一次读取元数据前启用已有的 SQLite 短等待预算。
|
|
47
|
+
this.db.exec('PRAGMA busy_timeout=2000');
|
|
48
|
+
if (previous?.size &&
|
|
49
|
+
this.db.prepare('PRAGMA application_id').get()?.application_id !== applicationId)
|
|
50
|
+
throw new Error('BOT_TARGET_JOURNAL_FOREIGN_DATABASE');
|
|
51
|
+
chmodSync(path, 0o600);
|
|
52
|
+
this.db.exec('PRAGMA journal_mode=DELETE; PRAGMA synchronous=FULL');
|
|
53
|
+
if (this.db.prepare('PRAGMA quick_check').get()?.quick_check !== 'ok')
|
|
54
|
+
throw new Error('BOT_TARGET_JOURNAL_INTEGRITY_FAILED');
|
|
55
|
+
const pageSize = Number(this.db.prepare('PRAGMA page_size').get()?.page_size);
|
|
56
|
+
const maxPages = Math.floor(maxBytes / pageSize);
|
|
57
|
+
if (Number(this.db.prepare('PRAGMA page_count').get()?.page_count) > maxPages)
|
|
58
|
+
throw new Error('BOT_TARGET_JOURNAL_CAPACITY');
|
|
59
|
+
this.db.exec(`PRAGMA max_page_count=${maxPages}`);
|
|
60
|
+
this.transact(() => {
|
|
61
|
+
this.native.initialize();
|
|
62
|
+
this.db.exec(`
|
|
63
|
+
PRAGMA application_id=${applicationId};
|
|
64
|
+
CREATE TABLE IF NOT EXISTS target_meta (target_id TEXT PRIMARY KEY);
|
|
65
|
+
CREATE TABLE IF NOT EXISTS target_runner (slot INTEGER PRIMARY KEY CHECK(slot=1), runner_id TEXT NOT NULL, scope_ref TEXT);
|
|
66
|
+
CREATE TABLE IF NOT EXISTS target_native_window (slot INTEGER PRIMARY KEY CHECK(slot=1), payload TEXT NOT NULL);
|
|
67
|
+
CREATE TABLE IF NOT EXISTS target_actions (
|
|
68
|
+
action_id TEXT PRIMARY KEY,
|
|
69
|
+
identity_json TEXT NOT NULL,
|
|
70
|
+
state TEXT NOT NULL CHECK(state IN ('RESERVED','STARTING','RUNNING','UNKNOWN','SUCCEEDED','FAILED','CANCELLED')),
|
|
71
|
+
runner_id TEXT,
|
|
72
|
+
process_json TEXT,
|
|
73
|
+
outcome_json TEXT,
|
|
74
|
+
cancel_requested INTEGER NOT NULL DEFAULT 0 CHECK(cancel_requested IN (0,1)),
|
|
75
|
+
created_at_ms INTEGER NOT NULL,
|
|
76
|
+
updated_at_ms INTEGER NOT NULL
|
|
77
|
+
);
|
|
78
|
+
CREATE INDEX IF NOT EXISTS target_actions_runner ON target_actions(runner_id,state);
|
|
79
|
+
`);
|
|
80
|
+
const owner = this.db.prepare('SELECT target_id FROM target_meta').get();
|
|
81
|
+
if (owner && owner.target_id !== this.targetId)
|
|
82
|
+
throw new Error('BOT_TARGET_JOURNAL_TARGET_MISMATCH');
|
|
83
|
+
if (!owner)
|
|
84
|
+
this.db.prepare('INSERT INTO target_meta(target_id) VALUES(?)').run(this.targetId);
|
|
85
|
+
this.scratch.initialize();
|
|
86
|
+
this.computer.initialize();
|
|
87
|
+
this.local.initialize();
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
this.db.close();
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/** Full 先持久保留原身份,跨进程只重送原终态回证。 */
|
|
96
|
+
nativeWindow() {
|
|
97
|
+
const row = this.db.prepare('SELECT payload FROM target_native_window WHERE slot=1').get();
|
|
98
|
+
return row ? botTargetNativeWindow(JSON.parse(String(row.payload))) : null;
|
|
99
|
+
}
|
|
100
|
+
saveNativeWindow(window) {
|
|
101
|
+
const current = botTargetNativeWindow(window);
|
|
102
|
+
return this.transact(() => {
|
|
103
|
+
const prior = this.nativeWindow();
|
|
104
|
+
const frozen = (v) => canonicalBotJson({ ...v, receipt: null });
|
|
105
|
+
if (current.identity.targetId !== this.targetId ||
|
|
106
|
+
(prior &&
|
|
107
|
+
(frozen(prior) !== frozen(current) ||
|
|
108
|
+
(prior.receipt &&
|
|
109
|
+
canonicalBotJson(prior.receipt) !== canonicalBotJson(current.receipt)))))
|
|
110
|
+
throw new Error('BOT_CODEX_WINDOW_CONFLICT');
|
|
111
|
+
this.db
|
|
112
|
+
.prepare('INSERT INTO target_native_window(slot,payload) VALUES(1,?) ON CONFLICT(slot) DO UPDATE SET payload=excluded.payload')
|
|
113
|
+
.run(canonicalBotJson(current));
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
acknowledgeNativeWindow(receipt) {
|
|
117
|
+
this.transact(() => {
|
|
118
|
+
const prior = this.nativeWindow();
|
|
119
|
+
if (!prior?.receipt || canonicalBotJson(prior.receipt) !== canonicalBotJson(receipt))
|
|
120
|
+
throw new Error('BOT_CODEX_WINDOW_RECEIPT_MISMATCH');
|
|
121
|
+
this.db.prepare('DELETE FROM target_native_window WHERE slot=1').run();
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
transact(work) {
|
|
125
|
+
this.db.exec('BEGIN IMMEDIATE');
|
|
126
|
+
try {
|
|
127
|
+
const result = work();
|
|
128
|
+
this.db.exec('COMMIT');
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
try {
|
|
133
|
+
this.db.exec('ROLLBACK');
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
// SQLite 可能已自行回滚,保留首个写入错误。
|
|
137
|
+
}
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/** 回读精确的原动作,外部入口在调用前核对当前读权限。 */
|
|
142
|
+
read(actionId) {
|
|
143
|
+
const row = this.db
|
|
144
|
+
.prepare('SELECT * FROM target_actions WHERE action_id=?')
|
|
145
|
+
.get(botId(actionId));
|
|
146
|
+
if (!row)
|
|
147
|
+
return null;
|
|
148
|
+
const decode = (value) => typeof value === 'string' ? JSON.parse(value) : null;
|
|
149
|
+
const identity = botHostActionIdentity(decode(row.identity_json));
|
|
150
|
+
if (identity.actionId !== actionId || identity.targetId !== this.targetId)
|
|
151
|
+
throw new Error('BOT_TARGET_JOURNAL_IDENTITY_CORRUPT');
|
|
152
|
+
return {
|
|
153
|
+
identity,
|
|
154
|
+
state: row.state,
|
|
155
|
+
runnerId: row.runner_id,
|
|
156
|
+
process: row.process_json === null ? null : botHostActionProcess(decode(row.process_json)),
|
|
157
|
+
outcome: row.outcome_json === null ? null : botHostActionOutcome(decode(row.outcome_json)),
|
|
158
|
+
cancelRequested: row.cancel_requested === 1,
|
|
159
|
+
createdAtMs: Number(row.created_at_ms),
|
|
160
|
+
updatedAtMs: Number(row.updated_at_ms),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
original(actionId) {
|
|
164
|
+
const action = this.read(actionId);
|
|
165
|
+
if (!action)
|
|
166
|
+
throw new Error('BOT_TARGET_ACTION_NOT_FOUND');
|
|
167
|
+
// 所有动作状态变更都在原 SQLite 事务内读取收执,同时持久捕获异步上报。
|
|
168
|
+
this.local.capture(action);
|
|
169
|
+
return action;
|
|
170
|
+
}
|
|
171
|
+
/** 临时目录阶段和动作结果分开;外部监督器提供物理目录及 cgroup 证据。 */
|
|
172
|
+
registerScratch(actionId, runnerId, identity) {
|
|
173
|
+
return this.transact(() => this.scratch.register(this.original(actionId), runnerId, identity));
|
|
174
|
+
}
|
|
175
|
+
readScratch(actionId) {
|
|
176
|
+
return this.scratch.read(actionId);
|
|
177
|
+
}
|
|
178
|
+
activeTerminalScratch(limit = 16, afterActionId) {
|
|
179
|
+
return this.scratch.activeTerminal(limit, afterActionId);
|
|
180
|
+
}
|
|
181
|
+
qualifyScratch(actionId, eligibleAtMs) {
|
|
182
|
+
return this.transact(() => this.scratch.qualify(this.original(actionId), eligibleAtMs));
|
|
183
|
+
}
|
|
184
|
+
dueScratch(nowMs, limit = 16, afterActionId) {
|
|
185
|
+
return this.scratch.due(nowMs, limit, afterActionId);
|
|
186
|
+
}
|
|
187
|
+
/** 暂态错误和下一次重试时间只写当前清理阶段,不修改动作结果。 */
|
|
188
|
+
deferScratch(actionId, phase, retryAfterMs, code) {
|
|
189
|
+
return this.transact(() => this.scratch.defer(actionId, phase, retryAfterMs, code));
|
|
190
|
+
}
|
|
191
|
+
updateScratch(actionId, from, to, reason) {
|
|
192
|
+
return this.transact(() => this.scratch.update(actionId, from, to, reason));
|
|
193
|
+
}
|
|
194
|
+
/** 先持久接受原身份。同 ID 异摘要、异授权或异 Native 调用不能覆盖原动作。 */
|
|
195
|
+
reserve(raw) {
|
|
196
|
+
const identity = botHostActionIdentity(raw);
|
|
197
|
+
return this.transact(() => this.reserveIdentity(identity));
|
|
198
|
+
}
|
|
199
|
+
/** 永久本地模式只限制未结工作集;旧中央模式保留兼容容量语义。 */
|
|
200
|
+
reserveIdentity(identity, local = false) {
|
|
201
|
+
if (identity.targetId !== this.targetId)
|
|
202
|
+
throw new Error('BOT_TARGET_ACTION_TARGET_MISMATCH');
|
|
203
|
+
const encoded = canonicalBotJson(identity);
|
|
204
|
+
const prior = this.read(identity.actionId);
|
|
205
|
+
if (prior) {
|
|
206
|
+
if (canonicalBotJson(prior.identity) !== encoded)
|
|
207
|
+
throw new Error('BOT_TARGET_ACTION_CONFLICT');
|
|
208
|
+
return prior;
|
|
209
|
+
}
|
|
210
|
+
if (Number(this.db
|
|
211
|
+
.prepare('SELECT count(*) AS n FROM target_actions' +
|
|
212
|
+
(local ? ' WHERE outcome_json IS NULL' : ''))
|
|
213
|
+
.get()?.n) >= this.capacity)
|
|
214
|
+
throw new Error('BOT_TARGET_JOURNAL_CAPACITY');
|
|
215
|
+
const now = this.clock();
|
|
216
|
+
this.db
|
|
217
|
+
.prepare("INSERT INTO target_actions(action_id,identity_json,state,created_at_ms,updated_at_ms) VALUES(?,?,'RESERVED',?,?)")
|
|
218
|
+
.run(identity.actionId, encoded, now, now);
|
|
219
|
+
return this.original(identity.actionId);
|
|
220
|
+
}
|
|
221
|
+
/** 仅成功提交 STARTING 的调用者允许创建进程;重复请求继续读原记录。 */
|
|
222
|
+
begin(actionId, rawRunnerId) {
|
|
223
|
+
const runnerId = botId(rawRunnerId);
|
|
224
|
+
return this.transact(() => {
|
|
225
|
+
const registered = this.db.prepare('SELECT runner_id FROM target_runner WHERE slot=1').get();
|
|
226
|
+
if (registered && registered.runner_id !== runnerId)
|
|
227
|
+
throw new Error('BOT_TARGET_ACTION_RUNNER_MISMATCH');
|
|
228
|
+
const action = this.original(actionId);
|
|
229
|
+
if (action.state !== 'RESERVED')
|
|
230
|
+
return { launch: false, record: action };
|
|
231
|
+
this.db
|
|
232
|
+
.prepare("UPDATE target_actions SET state='STARTING',runner_id=?,updated_at_ms=MAX(updated_at_ms,?) WHERE action_id=?")
|
|
233
|
+
.run(runnerId, this.clock(), actionId);
|
|
234
|
+
return { launch: true, record: this.original(actionId) };
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
/** 进程启动回证同时核对原执行者与原 PID 启动身份。 */
|
|
238
|
+
running(actionId, rawRunnerId, rawProcess) {
|
|
239
|
+
const runnerId = botId(rawRunnerId), child = botHostActionProcess(rawProcess);
|
|
240
|
+
return this.transact(() => {
|
|
241
|
+
const action = this.original(actionId);
|
|
242
|
+
if (action.runnerId !== runnerId)
|
|
243
|
+
throw new Error('BOT_TARGET_ACTION_RUNNER_MISMATCH');
|
|
244
|
+
const encoded = canonicalBotJson(child);
|
|
245
|
+
// 已推进的终态或待核对状态优先,相同的旧启动回证只返回当前事实。
|
|
246
|
+
if (action.process && canonicalBotJson(action.process) === encoded)
|
|
247
|
+
return action;
|
|
248
|
+
if (action.state !== 'STARTING')
|
|
249
|
+
throw new Error('BOT_TARGET_ACTION_STATE_CONFLICT');
|
|
250
|
+
this.db
|
|
251
|
+
.prepare("UPDATE target_actions SET state='RUNNING',process_json=?,updated_at_ms=MAX(updated_at_ms,?) WHERE action_id=?")
|
|
252
|
+
.run(encoded, this.clock(), actionId);
|
|
253
|
+
return this.original(actionId);
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
/** 尚未启动可直接取消,已跨启动边界时保留取消请求等待目标确认。 */
|
|
257
|
+
requestCancel(actionId) {
|
|
258
|
+
return this.transact(() => {
|
|
259
|
+
const action = this.original(actionId);
|
|
260
|
+
if (action.outcome || action.cancelRequested)
|
|
261
|
+
return action;
|
|
262
|
+
const outcome = action.state === 'RESERVED'
|
|
263
|
+
? { state: 'CANCELLED', reason: 'CANCELLED_BEFORE_START' }
|
|
264
|
+
: null;
|
|
265
|
+
this.db
|
|
266
|
+
.prepare('UPDATE target_actions SET state=?,cancel_requested=1,outcome_json=?,updated_at_ms=MAX(updated_at_ms,?) WHERE action_id=?')
|
|
267
|
+
.run(outcome?.state ?? action.state, outcome ? canonicalBotJson(outcome) : null, this.clock(), actionId);
|
|
268
|
+
return this.original(actionId);
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
/** 终态由目标证据确认。相同回执可重读,旧执行者和替换 PID 不能结算。 */
|
|
272
|
+
finish(actionId, rawRunnerId, rawProcess, rawOutcome) {
|
|
273
|
+
const runnerId = botId(rawRunnerId);
|
|
274
|
+
const child = rawProcess === null ? null : botHostActionProcess(rawProcess);
|
|
275
|
+
const outcome = botHostActionOutcome(rawOutcome);
|
|
276
|
+
return this.transact(() => {
|
|
277
|
+
const action = this.original(actionId);
|
|
278
|
+
const encoded = canonicalBotJson(outcome);
|
|
279
|
+
if (action.runnerId !== runnerId ||
|
|
280
|
+
canonicalBotJson(action.process) !== canonicalBotJson(child))
|
|
281
|
+
throw new Error('BOT_TARGET_ACTION_PROCESS_MISMATCH');
|
|
282
|
+
if (action.outcome && canonicalBotJson(action.outcome) === encoded)
|
|
283
|
+
return action;
|
|
284
|
+
if ((action.state !== 'RUNNING' &&
|
|
285
|
+
!(action.state === 'UNKNOWN' && child) &&
|
|
286
|
+
!(action.state === 'STARTING' &&
|
|
287
|
+
outcome.state === 'FAILED' &&
|
|
288
|
+
outcome.reason === 'SPAWN_FAILED' &&
|
|
289
|
+
!child)) ||
|
|
290
|
+
(outcome.state === 'CANCELLED' && !action.cancelRequested))
|
|
291
|
+
throw new Error('BOT_TARGET_ACTION_STATE_CONFLICT');
|
|
292
|
+
this.db
|
|
293
|
+
.prepare('UPDATE target_actions SET state=?,outcome_json=?,updated_at_ms=MAX(updated_at_ms,?) WHERE action_id=?')
|
|
294
|
+
.run(outcome.state, encoded, this.clock(), actionId);
|
|
295
|
+
return this.original(actionId);
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
/** 启动新动作前由目标内核核对这些未结原执行域。 */
|
|
299
|
+
unknownActionIds() {
|
|
300
|
+
return this.db
|
|
301
|
+
.prepare("SELECT action_id FROM target_actions WHERE state='UNKNOWN' ORDER BY action_id")
|
|
302
|
+
.all()
|
|
303
|
+
.map((row) => botId(row.action_id));
|
|
304
|
+
}
|
|
305
|
+
/** 目标监督进程拿到系统独占锁后,登记新代次并隔离上一代未结动作。 */
|
|
306
|
+
rotateRunner(rawRunnerId, rawScopeRef) {
|
|
307
|
+
const runnerId = botId(rawRunnerId);
|
|
308
|
+
const scopeRef = rawScopeRef === undefined ? null : botId(rawScopeRef);
|
|
309
|
+
return this.transact(() => {
|
|
310
|
+
const previous = this.db
|
|
311
|
+
.prepare('SELECT runner_id,scope_ref FROM target_runner WHERE slot=1')
|
|
312
|
+
.get();
|
|
313
|
+
if (previous?.scope_ref && previous.scope_ref !== scopeRef)
|
|
314
|
+
throw new Error('BOT_TARGET_JOURNAL_SCOPE_MISMATCH');
|
|
315
|
+
if (previous?.runner_id === runnerId && previous.scope_ref === scopeRef)
|
|
316
|
+
return 0;
|
|
317
|
+
const interrupted = typeof previous?.runner_id === 'string' && previous.runner_id !== runnerId
|
|
318
|
+
? this.interrupt(previous.runner_id)
|
|
319
|
+
: 0;
|
|
320
|
+
this.db
|
|
321
|
+
.prepare('INSERT INTO target_runner(slot,runner_id,scope_ref) VALUES(1,?,?) ON CONFLICT(slot) DO UPDATE SET runner_id=excluded.runner_id,scope_ref=excluded.scope_ref')
|
|
322
|
+
.run(runnerId, scopeRef);
|
|
323
|
+
return interrupted;
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
/** 单个动作缺少目标回证时保留原记录,避免影响同一执行者的其它动作。 */
|
|
327
|
+
uncertain(actionId, rawRunnerId) {
|
|
328
|
+
const runnerId = botId(rawRunnerId);
|
|
329
|
+
return this.transact(() => {
|
|
330
|
+
const action = this.original(actionId);
|
|
331
|
+
if (action.runnerId !== runnerId)
|
|
332
|
+
throw new Error('BOT_TARGET_ACTION_RUNNER_MISMATCH');
|
|
333
|
+
if (action.state === 'STARTING' || action.state === 'RUNNING')
|
|
334
|
+
this.db
|
|
335
|
+
.prepare("UPDATE target_actions SET state='UNKNOWN',updated_at_ms=MAX(updated_at_ms,?) WHERE action_id=?")
|
|
336
|
+
.run(this.clock(), actionId);
|
|
337
|
+
return this.original(actionId);
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
/** 只有外部已确认失效的原执行者才能进入待核对。保留原进程和可重读结果。 */
|
|
341
|
+
interrupt(rawRunnerId) {
|
|
342
|
+
const runnerId = botId(rawRunnerId);
|
|
343
|
+
const result = this.db
|
|
344
|
+
.prepare("UPDATE target_actions SET state='UNKNOWN',updated_at_ms=MAX(updated_at_ms,?) WHERE runner_id=? AND state IN ('STARTING','RUNNING')")
|
|
345
|
+
.run(this.clock(), runnerId).changes;
|
|
346
|
+
for (const row of this.db
|
|
347
|
+
.prepare("SELECT action_id FROM target_actions WHERE runner_id=? AND state='UNKNOWN'")
|
|
348
|
+
.all(runnerId))
|
|
349
|
+
this.original(String(row.action_id));
|
|
350
|
+
return result;
|
|
351
|
+
}
|
|
352
|
+
close() {
|
|
353
|
+
this.db.close();
|
|
354
|
+
}
|
|
355
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { botHostActionIdentity, botHostActionRecord, botTargetLocalCaller, botTargetLocalFields, botTargetLocalProfile, canonicalBotJson, } from '@agent-stack/contracts';
|
|
2
|
+
const same = (a, b) => canonicalBotJson(a) === canonicalBotJson(b);
|
|
3
|
+
/** 与目标动作共用一个 SQLite 事务,持久保存固定角色、单调 Owner 和待上报原收执。 */
|
|
4
|
+
export class TargetLocalStore {
|
|
5
|
+
db;
|
|
6
|
+
transact;
|
|
7
|
+
targetId;
|
|
8
|
+
read;
|
|
9
|
+
reserveIdentity;
|
|
10
|
+
constructor(db, transact, targetId, read, reserveIdentity) {
|
|
11
|
+
this.db = db;
|
|
12
|
+
this.transact = transact;
|
|
13
|
+
this.targetId = targetId;
|
|
14
|
+
this.read = read;
|
|
15
|
+
this.reserveIdentity = reserveIdentity;
|
|
16
|
+
}
|
|
17
|
+
initialize() {
|
|
18
|
+
this.db.exec(`
|
|
19
|
+
CREATE TABLE IF NOT EXISTS target_local_profile(slot INTEGER PRIMARY KEY CHECK(slot=1),payload TEXT NOT NULL);
|
|
20
|
+
CREATE TABLE IF NOT EXISTS target_local_owner(slot INTEGER PRIMARY KEY CHECK(slot=1),payload TEXT NOT NULL);
|
|
21
|
+
CREATE TABLE IF NOT EXISTS target_local_actions(
|
|
22
|
+
action_id TEXT PRIMARY KEY,native_session_ref TEXT NOT NULL,native_call_ref TEXT NOT NULL,payload TEXT NOT NULL,
|
|
23
|
+
UNIQUE(native_session_ref,native_call_ref));
|
|
24
|
+
CREATE TABLE IF NOT EXISTS target_local_outbox(
|
|
25
|
+
sequence INTEGER PRIMARY KEY AUTOINCREMENT,action_id TEXT NOT NULL UNIQUE,payload TEXT NOT NULL);
|
|
26
|
+
CREATE TABLE IF NOT EXISTS target_local_sent(action_id TEXT PRIMARY KEY,payload TEXT NOT NULL);
|
|
27
|
+
`);
|
|
28
|
+
}
|
|
29
|
+
/** 重启可更新原角色的操作集合和单次超时,不能把旧账本重绑定给别的租户或 Bot。 */
|
|
30
|
+
configure(raw) {
|
|
31
|
+
const profile = botTargetLocalProfile(raw);
|
|
32
|
+
if (profile.targetId !== this.targetId)
|
|
33
|
+
throw new Error('BOT_TARGET_LOCAL_SCOPE_MISMATCH');
|
|
34
|
+
this.transact(() => {
|
|
35
|
+
const previous = this.profile();
|
|
36
|
+
const binding = ({ capabilities: _capabilities, maxTimeoutMs: _max, ...value }) => value;
|
|
37
|
+
if (previous && !same(binding(previous), binding(profile)))
|
|
38
|
+
throw new Error('BOT_TARGET_LOCAL_SCOPE_MISMATCH');
|
|
39
|
+
this.db
|
|
40
|
+
.prepare('INSERT INTO target_local_profile(slot,payload) VALUES(1,?) ON CONFLICT(slot) DO UPDATE SET payload=excluded.payload')
|
|
41
|
+
.run(canonicalBotJson(profile));
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
profile() {
|
|
45
|
+
const row = this.db.prepare('SELECT payload FROM target_local_profile WHERE slot=1').get();
|
|
46
|
+
return row ? botTargetLocalProfile(JSON.parse(String(row.payload))) : null;
|
|
47
|
+
}
|
|
48
|
+
/** 描述只读角色,不会因探测或旧动作回查推进 Owner。 */
|
|
49
|
+
describe(raw) {
|
|
50
|
+
const caller = botTargetLocalCaller(raw);
|
|
51
|
+
const profile = this.profile();
|
|
52
|
+
if (!profile ||
|
|
53
|
+
!same(caller.scope, profile.scope) ||
|
|
54
|
+
caller.botId !== profile.botId ||
|
|
55
|
+
caller.missionId !== profile.missionId)
|
|
56
|
+
throw new Error('BOT_TARGET_LOCAL_SCOPE_MISMATCH');
|
|
57
|
+
return { mode: 'LOCAL', profile };
|
|
58
|
+
}
|
|
59
|
+
fence(caller) {
|
|
60
|
+
this.describe(caller);
|
|
61
|
+
const row = this.db.prepare('SELECT payload FROM target_local_owner WHERE slot=1').get();
|
|
62
|
+
const old = row ? botTargetLocalCaller(JSON.parse(String(row.payload))) : null;
|
|
63
|
+
if (old &&
|
|
64
|
+
(caller.ownerEpoch < old.ownerEpoch ||
|
|
65
|
+
(caller.ownerEpoch === old.ownerEpoch &&
|
|
66
|
+
(caller.executionId !== old.executionId ||
|
|
67
|
+
caller.nativeSessionRef !== old.nativeSessionRef))))
|
|
68
|
+
throw new Error('BOT_TARGET_LOCAL_OWNER_FENCED');
|
|
69
|
+
this.db
|
|
70
|
+
.prepare('INSERT INTO target_local_owner(slot,payload) VALUES(1,?) ON CONFLICT(slot) DO UPDATE SET payload=excluded.payload')
|
|
71
|
+
.run(canonicalBotJson(caller));
|
|
72
|
+
}
|
|
73
|
+
/** 只核对新派发的当前 Owner;原动作的身份与参数永久保持。 */
|
|
74
|
+
authorize(raw) {
|
|
75
|
+
const caller = botTargetLocalCaller(raw);
|
|
76
|
+
this.transact(() => this.fence(caller));
|
|
77
|
+
}
|
|
78
|
+
reserve(rawCaller, rawIdentity, rawFields) {
|
|
79
|
+
const caller = botTargetLocalCaller(rawCaller), identity = botHostActionIdentity(rawIdentity), fields = botTargetLocalFields(rawFields);
|
|
80
|
+
const { profile } = this.describe(caller);
|
|
81
|
+
if (identity.targetId !== profile.targetId)
|
|
82
|
+
throw new Error('BOT_TARGET_ACTION_PROFILE_MISMATCH');
|
|
83
|
+
const currentProfile = () => {
|
|
84
|
+
if (fields.workspaceRef !== profile.workspaceRef ||
|
|
85
|
+
!profile.capabilities.includes(fields.capability) ||
|
|
86
|
+
fields.timeoutMs > profile.maxTimeoutMs)
|
|
87
|
+
throw new Error('BOT_TARGET_ACTION_PROFILE_MISMATCH');
|
|
88
|
+
};
|
|
89
|
+
return this.transact(() => {
|
|
90
|
+
// 旧调用先按稳定 Native 身份回读;换 Owner 不会生成另一份副作用。
|
|
91
|
+
const matches = this.db
|
|
92
|
+
.prepare('SELECT * FROM target_local_actions WHERE action_id=? OR (native_session_ref=? AND native_call_ref=?) LIMIT 2')
|
|
93
|
+
.all(identity.actionId, identity.nativeSessionRef, identity.nativeCallRef);
|
|
94
|
+
if (matches.length > 1)
|
|
95
|
+
throw new Error('BOT_TARGET_ACTION_CONFLICT');
|
|
96
|
+
const row = matches[0];
|
|
97
|
+
const prior = this.read(row ? String(row.action_id) : identity.actionId);
|
|
98
|
+
if (prior) {
|
|
99
|
+
const original = prior.identity;
|
|
100
|
+
// 旧中央记录没有本地 Bot 绑定,只允许当前已获权原 Session 的确切调用首次接续。
|
|
101
|
+
if (!row && identity.nativeSessionRef !== caller.nativeSessionRef)
|
|
102
|
+
throw new Error('BOT_TARGET_LOCAL_CALLER_MISMATCH');
|
|
103
|
+
if (original.targetId !== identity.targetId ||
|
|
104
|
+
original.nativeSessionRef !== identity.nativeSessionRef ||
|
|
105
|
+
original.nativeCallRef !== identity.nativeCallRef ||
|
|
106
|
+
original.parametersDigest !== identity.parametersDigest ||
|
|
107
|
+
(row && !same(JSON.parse(String(row.payload)).fields, fields)))
|
|
108
|
+
throw new Error('BOT_TARGET_ACTION_CONFLICT');
|
|
109
|
+
// 已跨启动边界的重复请求只回原收执。尚未派发则仍须当前单调 Owner。
|
|
110
|
+
if (prior.state === 'RESERVED') {
|
|
111
|
+
currentProfile();
|
|
112
|
+
this.fence(caller);
|
|
113
|
+
}
|
|
114
|
+
if (row)
|
|
115
|
+
return prior;
|
|
116
|
+
}
|
|
117
|
+
currentProfile();
|
|
118
|
+
this.fence(caller);
|
|
119
|
+
if (!prior &&
|
|
120
|
+
(identity.executionId !== caller.executionId ||
|
|
121
|
+
identity.ownerEpoch !== caller.ownerEpoch ||
|
|
122
|
+
identity.nativeSessionRef !== caller.nativeSessionRef ||
|
|
123
|
+
identity.missionRevision !== caller.missionRevision ||
|
|
124
|
+
identity.grantId !== profile.profileId))
|
|
125
|
+
throw new Error('BOT_TARGET_LOCAL_CALLER_MISMATCH');
|
|
126
|
+
const record = prior ?? this.reserveIdentity(identity, true);
|
|
127
|
+
this.db
|
|
128
|
+
.prepare('INSERT INTO target_local_actions(action_id,native_session_ref,native_call_ref,payload) VALUES(?,?,?,?)')
|
|
129
|
+
.run(record.identity.actionId, record.identity.nativeSessionRef, record.identity.nativeCallRef, canonicalBotJson({ profile, fields }));
|
|
130
|
+
this.capture(record);
|
|
131
|
+
return record;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
fields(actionId) {
|
|
135
|
+
const row = this.db
|
|
136
|
+
.prepare('SELECT payload FROM target_local_actions WHERE action_id=?')
|
|
137
|
+
.get(actionId);
|
|
138
|
+
return row ? JSON.parse(String(row.payload)).fields : null;
|
|
139
|
+
}
|
|
140
|
+
/** 原生监督端记录已存在的精确进程,调用者不能通过此接缝创建或替换 PID。 */
|
|
141
|
+
record(raw) {
|
|
142
|
+
const receipt = botHostActionRecord(raw);
|
|
143
|
+
return this.transact(() => {
|
|
144
|
+
const previous = this.read(receipt.identity.actionId);
|
|
145
|
+
if (!previous ||
|
|
146
|
+
!this.fields(receipt.identity.actionId) ||
|
|
147
|
+
!same(previous.identity, receipt.identity) ||
|
|
148
|
+
previous.createdAtMs !== receipt.createdAtMs ||
|
|
149
|
+
previous.updatedAtMs > receipt.updatedAtMs ||
|
|
150
|
+
(previous.process && !same(previous.process, receipt.process)) ||
|
|
151
|
+
(previous.outcome && !same(previous, receipt)))
|
|
152
|
+
throw new Error('BOT_TARGET_ACTION_CONFLICT');
|
|
153
|
+
this.db
|
|
154
|
+
.prepare('UPDATE target_actions SET state=?,runner_id=?,process_json=?,outcome_json=?,cancel_requested=?,updated_at_ms=? WHERE action_id=?')
|
|
155
|
+
.run(receipt.state, receipt.runnerId, receipt.process ? canonicalBotJson(receipt.process) : null, receipt.outcome ? canonicalBotJson(receipt.outcome) : null, receipt.cancelRequested ? 1 : 0, receipt.updatedAtMs, receipt.identity.actionId);
|
|
156
|
+
this.capture(receipt);
|
|
157
|
+
return receipt;
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
/** 调用方必须已在目标事务中;状态与待上报记录原子提交,掉电不丢终态。 */
|
|
161
|
+
capture(record) {
|
|
162
|
+
const row = this.db
|
|
163
|
+
.prepare('SELECT payload FROM target_local_actions WHERE action_id=?')
|
|
164
|
+
.get(record.identity.actionId);
|
|
165
|
+
if (!row)
|
|
166
|
+
return;
|
|
167
|
+
const saved = JSON.parse(String(row.payload));
|
|
168
|
+
const request = { operation: 'local-record', ...saved, receipt: record };
|
|
169
|
+
const payload = canonicalBotJson(request);
|
|
170
|
+
const old = this.db
|
|
171
|
+
.prepare('SELECT payload FROM target_local_outbox WHERE action_id=?')
|
|
172
|
+
.get(record.identity.actionId);
|
|
173
|
+
if (old?.payload === payload)
|
|
174
|
+
return;
|
|
175
|
+
const sent = this.db
|
|
176
|
+
.prepare('SELECT payload FROM target_local_sent WHERE action_id=?')
|
|
177
|
+
.get(record.identity.actionId);
|
|
178
|
+
if (!old && sent?.payload === payload)
|
|
179
|
+
return;
|
|
180
|
+
this.db
|
|
181
|
+
.prepare('INSERT INTO target_local_outbox(action_id,payload) VALUES(?,?) ON CONFLICT(action_id) DO UPDATE SET sequence=excluded.sequence,payload=excluded.payload')
|
|
182
|
+
.run(record.identity.actionId, payload);
|
|
183
|
+
}
|
|
184
|
+
enqueue(raw) {
|
|
185
|
+
const receipt = botHostActionRecord(raw);
|
|
186
|
+
this.transact(() => this.capture(receipt));
|
|
187
|
+
}
|
|
188
|
+
pending(limit = 16) {
|
|
189
|
+
return this.db
|
|
190
|
+
.prepare('SELECT sequence,payload FROM target_local_outbox ORDER BY sequence LIMIT ?')
|
|
191
|
+
.all(Math.min(Math.max(1, limit), 64))
|
|
192
|
+
.map((row) => ({
|
|
193
|
+
sequence: Number(row.sequence),
|
|
194
|
+
request: JSON.parse(String(row.payload)),
|
|
195
|
+
}));
|
|
196
|
+
}
|
|
197
|
+
acknowledge(sequence) {
|
|
198
|
+
this.transact(() => {
|
|
199
|
+
const row = this.db
|
|
200
|
+
.prepare('SELECT action_id,payload FROM target_local_outbox WHERE sequence=?')
|
|
201
|
+
.get(sequence);
|
|
202
|
+
if (!row)
|
|
203
|
+
return;
|
|
204
|
+
this.db
|
|
205
|
+
.prepare('INSERT INTO target_local_sent(action_id,payload) VALUES(?,?) ON CONFLICT(action_id) DO UPDATE SET payload=excluded.payload')
|
|
206
|
+
.run(String(row.action_id), String(row.payload));
|
|
207
|
+
this.db.prepare('DELETE FROM target_local_outbox WHERE sequence=?').run(sequence);
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}
|