create-walle 0.10.2 → 0.10.3
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 +3 -1
- package/lib/release-schema.json +2 -2
- package/lib/runtime-closure-policy.json +8 -7
- package/package.json +1 -1
- package/template/coding-task-manager/api-prompts.js +45 -7
- package/template/coding-task-manager/bin/claude-hook.js +55 -1
- package/template/coding-task-manager/bin/ctm-relay-client.js +35 -12
- package/template/coding-task-manager/bin/land.js +2069 -0
- package/template/coding-task-manager/bin/memory-census.js +4 -2
- package/template/coding-task-manager/bin/memory-sync-verify.js +151 -0
- package/template/coding-task-manager/bin/probe-refusal-scope.js +530 -0
- package/template/coding-task-manager/db.js +156 -32
- package/template/coding-task-manager/lib/acp/acp-client.js +383 -0
- package/template/coding-task-manager/lib/acp/dsh-context-truth.js +176 -0
- package/template/coding-task-manager/lib/acp/dsh-launch-model.js +302 -0
- package/template/coding-task-manager/lib/acp/dsh-mcp-servers.js +194 -0
- package/template/coding-task-manager/lib/acp/dsh-prompt-lane.js +616 -0
- package/template/coding-task-manager/lib/acp/dsh-route-patch.js +308 -0
- package/template/coding-task-manager/lib/acp/dsh-session-runtime.js +522 -0
- package/template/coding-task-manager/lib/acp/dsh-transcript.js +395 -0
- package/template/coding-task-manager/lib/acp/dsh-usage-log.js +162 -0
- package/template/coding-task-manager/lib/acp/ndjson-stdio-transport.js +225 -0
- package/template/coding-task-manager/lib/adopted-host-redial.js +47 -11
- package/template/coding-task-manager/lib/adopted-launch-environment.js +123 -0
- package/template/coding-task-manager/lib/agent-auto-update-runtime.js +0 -3
- package/template/coding-task-manager/lib/agent-auto-update.js +26 -10
- package/template/coding-task-manager/lib/agent-bundle/build.js +657 -0
- package/template/coding-task-manager/lib/agent-bundle/codex-install.js +558 -0
- package/template/coding-task-manager/lib/agent-bundle/drift.js +120 -0
- package/template/coding-task-manager/lib/agent-bundle/gc.js +522 -0
- package/template/coding-task-manager/lib/agent-bundle/inventory.js +346 -0
- package/template/coding-task-manager/lib/agent-bundle/push.js +717 -0
- package/template/coding-task-manager/lib/agent-bundle/skill-transfer.js +724 -0
- package/template/coding-task-manager/lib/agent-bundle/spawn.js +119 -0
- package/template/coding-task-manager/lib/agent-bundle/store.js +568 -0
- package/template/coding-task-manager/lib/agent-capabilities.js +142 -12
- package/template/coding-task-manager/lib/agent-cli-cache.js +30 -5
- package/template/coding-task-manager/lib/agent-definitions.js +19 -0
- package/template/coding-task-manager/lib/agent-hooks-codex-toml.js +28 -16
- package/template/coding-task-manager/lib/agent-hooks-codex-workspace.js +9 -1
- package/template/coding-task-manager/lib/agent-hooks-installer.js +23 -8
- package/template/coding-task-manager/lib/agent-hooks-prune.js +37 -11
- package/template/coding-task-manager/lib/agent-hooks-shim.js +105 -0
- package/template/coding-task-manager/lib/agent-presets.js +84 -1
- package/template/coding-task-manager/lib/agent-upgrade-jobs.js +12 -1
- package/template/coding-task-manager/lib/agent-version-service.js +74 -11
- package/template/coding-task-manager/lib/all-sessions-query.js +6 -2
- package/template/coding-task-manager/lib/api/agent-bundles.js +436 -0
- package/template/coding-task-manager/lib/api/backup-retention.js +83 -0
- package/template/coding-task-manager/lib/api/conversation-sync-routes.js +124 -0
- package/template/coding-task-manager/lib/api/diagnostics.js +549 -69
- package/template/coding-task-manager/lib/api/fleet.js +118 -0
- package/template/coding-task-manager/lib/api/hub-bridge.js +243 -0
- package/template/coding-task-manager/lib/api/ingress.js +9 -1
- package/template/coding-task-manager/lib/api/landing.js +403 -0
- package/template/coding-task-manager/lib/api/machines.js +691 -2
- package/template/coding-task-manager/lib/api/memory-sync-routes.js +335 -0
- package/template/coding-task-manager/lib/api/misc-ops.js +8 -3
- package/template/coding-task-manager/lib/api/remote-sessions.js +1326 -0
- package/template/coding-task-manager/lib/api/session-attach.js +623 -0
- package/template/coding-task-manager/lib/api/session-messages.js +1384 -0
- package/template/coding-task-manager/lib/api/sessions.js +77 -51
- package/template/coding-task-manager/lib/api/setup-network.js +544 -16
- package/template/coding-task-manager/lib/api/setup-wizard-handlers.js +884 -0
- package/template/coding-task-manager/lib/api/setup.js +829 -10
- package/template/coding-task-manager/lib/api/walle-bridge.js +9 -1
- package/template/coding-task-manager/lib/attachment-reconciler-wiring.js +5 -2
- package/template/coding-task-manager/lib/auth-rate-limit.js +23 -0
- package/template/coding-task-manager/lib/auth-rules.js +292 -21
- package/template/coding-task-manager/lib/background-stop.js +369 -0
- package/template/coding-task-manager/lib/best-of-attempts.js +4 -1
- package/template/coding-task-manager/lib/best-of-launch-plan.js +52 -0
- package/template/coding-task-manager/lib/box-keep-awake.js +89 -0
- package/template/coding-task-manager/lib/broadcast-reason-stats.js +152 -0
- package/template/coding-task-manager/lib/broadcast-serialize.js +5 -0
- package/template/coding-task-manager/lib/build-info.js +4 -2
- package/template/coding-task-manager/lib/claude-model-truth.js +13 -2
- package/template/coding-task-manager/lib/claude-transcript-terminal-renderer.js +17 -13
- package/template/coding-task-manager/lib/client-diag-handler.js +64 -2
- package/template/coding-task-manager/lib/codex-app-server-client.js +14 -16
- package/template/coding-task-manager/lib/codex-configuration-history.js +55 -0
- package/template/coding-task-manager/lib/codex-harness-qualification.js +43 -20
- package/template/coding-task-manager/lib/codex-rollout-history.js +743 -0
- package/template/coding-task-manager/lib/coding-agent-models.js +27 -12
- package/template/coding-task-manager/lib/coding-cli-skill-installer.js +44 -14
- package/template/coding-task-manager/lib/coding-session-model-adapters.js +43 -2
- package/template/coding-task-manager/lib/coding-session-model-owner.js +1 -1
- package/template/coding-task-manager/lib/coding-session-model-public.js +7 -1
- package/template/coding-task-manager/lib/coding-session-model-runtime.js +23 -4
- package/template/coding-task-manager/lib/coding-session-model-scan.js +31 -0
- package/template/coding-task-manager/lib/coding-session-model-state.js +7 -0
- package/template/coding-task-manager/lib/conversation-freshness-diagnostics.js +280 -0
- package/template/coding-task-manager/lib/conversation-item-clock.js +261 -0
- package/template/coding-task-manager/lib/conversation-source-registry.js +5 -0
- package/template/coding-task-manager/lib/conversation-store-v2.js +44 -0
- package/template/coding-task-manager/lib/conversation-sync.js +355 -0
- package/template/coding-task-manager/lib/create/resolve-launch-params.js +96 -12
- package/template/coding-task-manager/lib/create/worker-role-profile.js +4 -4
- package/template/coding-task-manager/lib/create-intent-lease.js +51 -0
- package/template/coding-task-manager/lib/ctm-session-context-api.js +97 -6
- package/template/coding-task-manager/lib/db-domain-tables.js +1 -0
- package/template/coding-task-manager/lib/db-domains.js +1 -0
- package/template/coding-task-manager/lib/db-owner-dispatch-probe.js +32 -0
- package/template/coding-task-manager/lib/db-owner-request-counts.js +178 -0
- package/template/coding-task-manager/lib/db-owner-worker-client.js +68 -14
- package/template/coding-task-manager/lib/db-schema-source-files.js +5 -0
- package/template/coding-task-manager/lib/deferred-restore-attempt.js +6 -2
- package/template/coding-task-manager/lib/feature-manifest.js +4 -0
- package/template/coding-task-manager/lib/fleet-conversation-route.js +97 -0
- package/template/coding-task-manager/lib/fleet-fanout.js +78 -0
- package/template/coding-task-manager/lib/fleet-hub.js +762 -0
- package/template/coding-task-manager/lib/fleet-origin-follower.js +252 -0
- package/template/coding-task-manager/lib/fleet-resolver-effects.js +147 -0
- package/template/coding-task-manager/lib/fleet-resolver-tick.js +148 -0
- package/template/coding-task-manager/lib/fleet-resolver.js +454 -0
- package/template/coding-task-manager/lib/fleet-session-list-routes.js +114 -0
- package/template/coding-task-manager/lib/fleet-session-lists.js +672 -0
- package/template/coding-task-manager/lib/fleet-update.js +798 -0
- package/template/coding-task-manager/lib/fs-watcher-root-watch.js +141 -0
- package/template/coding-task-manager/lib/fs-watcher.js +58 -42
- package/template/coding-task-manager/lib/harness-history-transition.js +50 -9
- package/template/coding-task-manager/lib/headless-term-service.js +84 -8
- package/template/coding-task-manager/lib/hermetic-agent-launch-guard.js +10 -0
- package/template/coding-task-manager/lib/history-transition-read-op.js +175 -8
- package/template/coding-task-manager/lib/host-cpu-categories.js +310 -0
- package/template/coding-task-manager/lib/host-fseventsd-sampler.js +399 -0
- package/template/coding-task-manager/lib/host-handoff.js +16 -19
- package/template/coding-task-manager/lib/host-stats.js +150 -3
- package/template/coding-task-manager/lib/hosted-sync-worker.js +43 -320
- package/template/coding-task-manager/lib/hub-bridge-access.js +798 -0
- package/template/coding-task-manager/lib/hub-bridge-box.js +409 -0
- package/template/coding-task-manager/lib/hub-bridge-mcp.js +380 -0
- package/template/coding-task-manager/lib/hub-bridge-mesh.js +313 -0
- package/template/coding-task-manager/lib/hub-bridge-ops.js +721 -0
- package/template/coding-task-manager/lib/hub-bridge.js +398 -0
- package/template/coding-task-manager/lib/idle-notify.js +491 -0
- package/template/coding-task-manager/lib/instance-id-ownership-manifest.js +8 -0
- package/template/coding-task-manager/lib/instance-manifest.js +5 -1
- package/template/coding-task-manager/lib/instance-sync-status.js +18 -8
- package/template/coding-task-manager/lib/landing/agent-rule.txt +1 -0
- package/template/coding-task-manager/lib/landing/batch-runner.js +366 -0
- package/template/coding-task-manager/lib/landing/config.js +536 -0
- package/template/coding-task-manager/lib/landing/ctm-view.js +256 -0
- package/template/coding-task-manager/lib/landing/gate.js +360 -0
- package/template/coding-task-manager/lib/landing/git.js +344 -0
- package/template/coding-task-manager/lib/landing/lease.js +247 -0
- package/template/coding-task-manager/lib/landing/merge-delta.js +380 -0
- package/template/coding-task-manager/lib/landing/proof.js +223 -0
- package/template/coding-task-manager/lib/landing/queue.js +998 -0
- package/template/coding-task-manager/lib/landing/radar.js +489 -0
- package/template/coding-task-manager/lib/landing/resolve-cli.js +424 -0
- package/template/coding-task-manager/lib/landing/state.js +263 -0
- package/template/coding-task-manager/lib/landing/stop.js +49 -0
- package/template/coding-task-manager/lib/landing/sync-cli.js +475 -0
- package/template/coding-task-manager/lib/landing/sync.js +456 -0
- package/template/coding-task-manager/lib/landing/train.js +885 -0
- package/template/coding-task-manager/lib/landing/window.js +57 -0
- package/template/coding-task-manager/lib/launch-environment.js +121 -0
- package/template/coding-task-manager/lib/launch-model-override.js +36 -10
- package/template/coding-task-manager/lib/launch-plan-pool.js +2 -1
- package/template/coding-task-manager/lib/launch-plan-warm-cache.js +6 -0
- package/template/coding-task-manager/lib/lead-model-observer.js +57 -1
- package/template/coding-task-manager/lib/lead-model-options.js +160 -3
- package/template/coding-task-manager/lib/lead-model-restore-reconciliation.js +106 -24
- package/template/coding-task-manager/lib/lead-model-switch-runtime.js +352 -68
- package/template/coding-task-manager/lib/lead-model-switch.js +114 -10
- package/template/coding-task-manager/lib/lead-model-transition-runtime.js +14 -2
- package/template/coding-task-manager/lib/lead-model-transition-store.js +24 -6
- package/template/coding-task-manager/lib/lead-route-preflight.js +179 -0
- package/template/coding-task-manager/lib/lead-switch-history-mode.js +110 -0
- package/template/coding-task-manager/lib/lead-wire-agent.js +7 -0
- package/template/coding-task-manager/lib/lifecycle-wake-experiment.js +9 -2
- package/template/coding-task-manager/lib/live-defer-announce.js +45 -0
- package/template/coding-task-manager/lib/machine-registry.js +750 -5
- package/template/coding-task-manager/lib/macos-capabilities.js +32 -15
- package/template/coding-task-manager/lib/main-thread-lint-exemptions.json +433 -53
- package/template/coding-task-manager/lib/mainloop-observability.js +14 -9
- package/template/coding-task-manager/lib/media-draft-owner.js +16 -3
- package/template/coding-task-manager/lib/memory-join.js +337 -0
- package/template/coding-task-manager/lib/memory-sync-verify.js +393 -0
- package/template/coding-task-manager/lib/memory-sync.js +565 -0
- package/template/coding-task-manager/lib/migrations/v57-delegate-pref-mirror-opencode.js +68 -0
- package/template/coding-task-manager/lib/migrations/v58-subagent-launch-native-subagents.js +42 -0
- package/template/coding-task-manager/lib/migrations/v59-coding-session-model-state-dsh.js +73 -0
- package/template/coding-task-manager/lib/migrations/v60-delegate-pref-mirror-dsh.js +78 -0
- package/template/coding-task-manager/lib/migrations/v61-conversation-item-clock.js +71 -0
- package/template/coding-task-manager/lib/model-availability.js +727 -0
- package/template/coding-task-manager/lib/model-execution-recipe-metadata.js +4 -6
- package/template/coding-task-manager/lib/model-host-receipt.js +6 -3
- package/template/coding-task-manager/lib/model-id-rule.js +19 -0
- package/template/coding-task-manager/lib/model-proxy/anthropic-face.js +4 -0
- package/template/coding-task-manager/lib/model-proxy/auto-mode-review.js +110 -23
- package/template/coding-task-manager/lib/model-proxy/chat-response-translators.js +3 -0
- package/template/coding-task-manager/lib/model-proxy/generation-probe.js +60 -17
- package/template/coding-task-manager/lib/model-proxy/historical-tool-declarations.js +37 -0
- package/template/coding-task-manager/lib/model-proxy/lead-request-validation.js +1 -0
- package/template/coding-task-manager/lib/model-proxy/lead-token-admin.js +130 -0
- package/template/coding-task-manager/lib/model-proxy/refusal-scope.js +151 -0
- package/template/coding-task-manager/lib/model-proxy/request-budget-store.js +11 -2
- package/template/coding-task-manager/lib/model-proxy/tokens.js +69 -5
- package/template/coding-task-manager/lib/model-proxy/upstream-outcome.js +9 -0
- package/template/coding-task-manager/lib/native-agent-model-args.js +25 -22
- package/template/coding-task-manager/lib/native-history-control.js +6 -4
- package/template/coding-task-manager/lib/native-lead-settings-client.js +44 -4
- package/template/coding-task-manager/lib/oauth-proxy-supervisor.js +173 -36
- package/template/coding-task-manager/lib/online-backup-worker-client.js +2 -0
- package/template/coding-task-manager/lib/opencode-cli.js +480 -0
- package/template/coding-task-manager/lib/opencode-launch-model.js +471 -0
- package/template/coding-task-manager/lib/opencode-v1-plugin/model-carrier.mjs +35 -0
- package/template/coding-task-manager/lib/opencode-v2-plugin/server.js +118 -0
- package/template/coding-task-manager/lib/owner-action-manifest-data.json +1 -1
- package/template/coding-task-manager/lib/park-composer-draft.js +54 -0
- package/template/coding-task-manager/lib/park-fresh-relaunch.js +41 -10
- package/template/coding-task-manager/lib/perf-phase-trace.js +72 -0
- package/template/coding-task-manager/lib/perf-summary.js +7 -0
- package/template/coding-task-manager/lib/perf-tracker.js +63 -2
- package/template/coding-task-manager/lib/project-config.js +7 -0
- package/template/coding-task-manager/lib/prompt-purge-v2.js +52 -1
- package/template/coding-task-manager/lib/provider-login-broker.js +72 -15
- package/template/coding-task-manager/lib/provider-login-tab.js +10 -2
- package/template/coding-task-manager/lib/read-pool-client.js +89 -2
- package/template/coding-task-manager/lib/read-pool-worker-handle.js +29 -4
- package/template/coding-task-manager/lib/recent-catalog-query.js +15 -0
- package/template/coding-task-manager/lib/recent-session-catalog-response.js +67 -10
- package/template/coding-task-manager/lib/recovery-evidence.js +26 -11
- package/template/coding-task-manager/lib/relay-client.js +57 -3
- package/template/coding-task-manager/lib/relink-audit.js +34 -5
- package/template/coding-task-manager/lib/remote-machine-catalog.js +321 -26
- package/template/coding-task-manager/lib/remote-machine-create.js +576 -36
- package/template/coding-task-manager/lib/remote-machine-link.js +546 -59
- package/template/coding-task-manager/lib/remote-machine-proxy.js +143 -9
- package/template/coding-task-manager/lib/remote-session-forward.js +65 -7
- package/template/coding-task-manager/lib/remote-terminal-target.js +9 -2
- package/template/coding-task-manager/lib/restart-guard.js +18 -6
- package/template/coding-task-manager/lib/restore-seed-modes.js +87 -0
- package/template/coding-task-manager/lib/restored-scrollback-hydration-runtime.js +22 -2
- package/template/coding-task-manager/lib/resume-admission.js +17 -3
- package/template/coding-task-manager/lib/review-repo-registry.js +58 -19
- package/template/coding-task-manager/lib/root-delivery-runtime.js +2 -2
- package/template/coding-task-manager/lib/root-prompt-flow.js +1 -1
- package/template/coding-task-manager/lib/runtime-contract.js +3 -1
- package/template/coding-task-manager/lib/schema-indexes.js +1 -0
- package/template/coding-task-manager/lib/session-context-locator.js +742 -0
- package/template/coding-task-manager/lib/session-create/attachment.js +2 -2
- package/template/coding-task-manager/lib/session-create/create-phases.js +118 -0
- package/template/coding-task-manager/lib/session-create/delegate-worker.js +86 -16
- package/template/coding-task-manager/lib/session-create/dsh-session.js +930 -0
- package/template/coding-task-manager/lib/session-create/lead-route-launch.js +186 -13
- package/template/coding-task-manager/lib/session-create/native-lead-lifetime.js +55 -3
- package/template/coding-task-manager/lib/session-create/opencode-lead-provider.js +50 -0
- package/template/coding-task-manager/lib/session-create/prepared.js +162 -38
- package/template/coding-task-manager/lib/session-create/provider-process.js +160 -28
- package/template/coding-task-manager/lib/session-create/response.js +7 -7
- package/template/coding-task-manager/lib/session-create/structured-session.js +27 -0
- package/template/coding-task-manager/lib/session-create/subagent-pick-table.js +3 -1
- package/template/coding-task-manager/lib/session-create/subagent-pick.js +458 -9
- package/template/coding-task-manager/lib/session-create/transcript.js +1 -1
- package/template/coding-task-manager/lib/session-create/worker-budget-setup.js +21 -2
- package/template/coding-task-manager/lib/session-create/worker-continuation.js +7 -1
- package/template/coding-task-manager/lib/session-create/worker-launch-sandbox.js +39 -10
- package/template/coding-task-manager/lib/session-create/worker-observability.js +2 -2
- package/template/coding-task-manager/lib/session-empty.js +13 -10
- package/template/coding-task-manager/lib/session-host-manager.js +60 -0
- package/template/coding-task-manager/lib/session-jobs.js +3 -1
- package/template/coding-task-manager/lib/session-lifecycle.js +10 -4
- package/template/coding-task-manager/lib/session-model-action-preconditions.js +6 -2
- package/template/coding-task-manager/lib/session-model-intent-contract.js +11 -8
- package/template/coding-task-manager/lib/session-park.js +738 -0
- package/template/coding-task-manager/lib/session-path-grant.js +13 -4
- package/template/coding-task-manager/lib/session-status-ledger.js +106 -4
- package/template/coding-task-manager/lib/session-transport.js +17 -0
- package/template/coding-task-manager/lib/session-workspace-projection.js +54 -5
- package/template/coding-task-manager/lib/session-workspace-tracking-runtime.js +213 -1
- package/template/coding-task-manager/lib/skill-autocomplete-query.js +120 -3
- package/template/coding-task-manager/lib/skill-autocomplete.js +15 -1
- package/template/coding-task-manager/lib/sqlite-file-set.js +39 -0
- package/template/coding-task-manager/lib/standup-search-adapter.js +16 -2
- package/template/coding-task-manager/lib/state-sync/client-ledger.js +12 -0
- package/template/coding-task-manager/lib/state-sync/frame-emitter.js +319 -100
- package/template/coding-task-manager/lib/storage/coding-session-model-store.js +4 -1
- package/template/coding-task-manager/lib/storage/delegate-pref-mirror-store.js +32 -9
- package/template/coding-task-manager/lib/structured-session-boot-sweep.js +235 -0
- package/template/coding-task-manager/lib/submission-ack.js +90 -2
- package/template/coding-task-manager/lib/systemd-scope.js +115 -0
- package/template/coding-task-manager/lib/telemetry-receiver.js +39 -0
- package/template/coding-task-manager/lib/terminal-attach-geometry.js +985 -0
- package/template/coding-task-manager/lib/terminal-bootstrap.js +30 -0
- package/template/coding-task-manager/lib/terminal-draft-operation.js +357 -0
- package/template/coding-task-manager/lib/terminal-input-admission.js +17 -1
- package/template/coding-task-manager/lib/terminal-input-prepared.js +563 -0
- package/template/coding-task-manager/lib/transcript-cache-temps.js +171 -0
- package/template/coding-task-manager/lib/transcript-frame-cache.js +8 -3
- package/template/coding-task-manager/lib/transcript-source.js +36 -4
- package/template/coding-task-manager/lib/transcript-store.js +9 -0
- package/template/coding-task-manager/lib/typing-interaction-trace.js +106 -3
- package/template/coding-task-manager/lib/usage-ledger/backfill.js +40 -5
- package/template/coding-task-manager/lib/usage-ledger/client.js +4 -1
- package/template/coding-task-manager/lib/usage-ledger/dsh-parse.js +152 -0
- package/template/coding-task-manager/lib/usage-ledger/dsh-read.js +73 -0
- package/template/coding-task-manager/lib/usage-ledger/ingest.js +34 -6
- package/template/coding-task-manager/lib/usage-ledger/live.js +35 -8
- package/template/coding-task-manager/lib/usage-ledger/read.js +29 -20
- package/template/coding-task-manager/lib/usage-ledger/schema.js +61 -1
- package/template/coding-task-manager/lib/usage-ledger/task-coordinator.js +4 -2
- package/template/coding-task-manager/lib/wake-skip-reasons.js +1 -0
- package/template/coding-task-manager/lib/walle/turn.js +1 -1
- package/template/coding-task-manager/lib/walle-history-serve.js +838 -0
- package/template/coding-task-manager/lib/walle-kill-authority.js +2 -2
- package/template/coding-task-manager/lib/walle-log-rotation.js +164 -1
- package/template/coding-task-manager/lib/walle-mcp-auto-config.js +56 -2
- package/template/coding-task-manager/lib/walle-row-history.js +495 -0
- package/template/coding-task-manager/lib/walle-supervisor.js +33 -14
- package/template/coding-task-manager/lib/watch-worker-client.js +203 -0
- package/template/coding-task-manager/lib/worker-terminal-output.js +5 -2
- package/template/coding-task-manager/lib/ws/hub-bridge.js +35 -0
- package/template/coding-task-manager/lib/ws/lifecycle.js +6 -11
- package/template/coding-task-manager/lib/ws/misc.js +1 -1
- package/template/coding-task-manager/lib/ws/state-sync.js +106 -4
- package/template/coding-task-manager/lib/ws/terminal-attach.js +91 -0
- package/template/coding-task-manager/oauth-proxy.js +112 -115
- package/template/coding-task-manager/package-lock.json +10 -94
- package/template/coding-task-manager/package.json +4 -3
- package/template/coding-task-manager/protocol/message-table.json +10 -0
- package/template/coding-task-manager/protocol/messages.js +10 -0
- package/template/coding-task-manager/protocol/ws-schema.json +20 -0
- package/template/coding-task-manager/protocol/ws-schema.md +2 -0
- package/template/coding-task-manager/public/css/app.css +170 -0
- package/template/coding-task-manager/public/css/walle-session.css +4 -0
- package/template/coding-task-manager/public/index.html +473 -243
- package/template/coding-task-manager/public/js/agent-command.js +86 -0
- package/template/coding-task-manager/public/js/app/backups-panel.js +111 -5
- package/template/coding-task-manager/public/js/app/coding-agent-upgrade.js +103 -4
- package/template/coding-task-manager/public/js/app/machines-page.js +1328 -8
- package/template/coding-task-manager/public/js/app/models-tab.js +113 -38
- package/template/coding-task-manager/public/js/app/restart-banner.js +53 -0
- package/template/coding-task-manager/public/js/app/worktrees-panel.js +184 -2
- package/template/coding-task-manager/public/js/background-work.js +196 -27
- package/template/coding-task-manager/public/js/coding-session-model-presentation.js +138 -10
- package/template/coding-task-manager/public/js/core/active-session-groups.js +179 -0
- package/template/coding-task-manager/public/js/core/pending-create.js +238 -0
- package/template/coding-task-manager/public/js/core/recent-machine-source.js +228 -0
- package/template/coding-task-manager/public/js/core/session-commands.js +180 -14
- package/template/coding-task-manager/public/js/dashboard-client-function-order.json +8 -0
- package/template/coding-task-manager/public/js/document-review-links.js +9 -1
- package/template/coding-task-manager/public/js/file-resolution-client.js +52 -1
- package/template/coding-task-manager/public/js/history-app-seam.js +22 -2
- package/template/coding-task-manager/public/js/machine-pool-shared.js +558 -3
- package/template/coding-task-manager/public/js/message-renderer.js +4 -3
- package/template/coding-task-manager/public/js/model-picker.js +3 -1
- package/template/coding-task-manager/public/js/native-subagent-review.js +15 -2
- package/template/coding-task-manager/public/js/new-session-agent-grid.js +346 -0
- package/template/coding-task-manager/public/js/pasted-content.js +236 -0
- package/template/coding-task-manager/public/js/pe-private-content-lifetime.js +39 -7
- package/template/coding-task-manager/public/js/private-model-lifetime.js +6 -2
- package/template/coding-task-manager/public/js/prompts.js +11 -10
- package/template/coding-task-manager/public/js/protocol.js +10 -0
- package/template/coding-task-manager/public/js/restart-banner-policy.js +29 -1
- package/template/coding-task-manager/public/js/session-model-picker.js +447 -57
- package/template/coding-task-manager/public/js/session-search-utils.js +18 -2
- package/template/coding-task-manager/public/js/session-usage-view.js +2 -1
- package/template/coding-task-manager/public/js/session-workspace-tracking.js +51 -1
- package/template/coding-task-manager/public/js/state-sync-client.js +10 -1
- package/template/coding-task-manager/public/js/stream-view.js +6 -5
- package/template/coding-task-manager/public/js/terminal/conv-only-session.js +287 -0
- package/template/coding-task-manager/public/js/terminal/runtime-09.js +2 -0
- package/template/coding-task-manager/public/js/terminal/runtime-10.js +5 -5
- package/template/coding-task-manager/public/js/terminal/runtime-12.js +8 -1
- package/template/coding-task-manager/public/js/terminal/runtime-16.js +4 -0
- package/template/coding-task-manager/public/js/terminal/runtime-20.js +1 -1
- package/template/coding-task-manager/public/js/terminal-attachment-draft.js +67 -13
- package/template/coding-task-manager/public/js/terminal-image-orchestration.js +52 -6
- package/template/coding-task-manager/public/js/terminal-wheel.js +23 -3
- package/template/coding-task-manager/public/js/walle/chat-conversation.js +4 -4
- package/template/coding-task-manager/public/js/walle.js +6 -0
- package/template/coding-task-manager/public/js/ws/live-dispatch.js +10 -0
- package/template/coding-task-manager/public/m/app.css +140 -0
- package/template/coding-task-manager/public/m/app.js +507 -68
- package/template/coding-task-manager/public/m/index.html +17 -0
- package/template/coding-task-manager/public/m/machines.js +838 -4
- package/template/coding-task-manager/public/m/private-api.js +31 -1
- package/template/coding-task-manager/public/usage.html +1 -0
- package/template/coding-task-manager/scripts/dev-route-fixture/synthetic-route-upstream.js +104 -0
- package/template/coding-task-manager/scripts/dev-route-fixture.js +339 -0
- package/template/coding-task-manager/scripts/opencode-lead-route-probe.js +195 -0
- package/template/coding-task-manager/scripts/opencode-v2-contract-probe/fake-anthropic.js +168 -0
- package/template/coding-task-manager/scripts/opencode-v2-contract-probe/probe-plugin/server.js +95 -0
- package/template/coding-task-manager/scripts/opencode-v2-contract-probe.js +673 -0
- package/template/coding-task-manager/server.js +1950 -11679
- package/template/coding-task-manager/session-integrity.js +64 -4
- package/template/coding-task-manager/workers/db-owner-worker.js +19 -2
- package/template/coding-task-manager/workers/online-backup-worker.js +1 -0
- package/template/coding-task-manager/workers/read-pool-model-collector.js +51 -3
- package/template/coding-task-manager/workers/read-pool-worker.js +76 -6
- package/template/coding-task-manager/workers/session-host-pool-process.js +6 -6
- package/template/coding-task-manager/workers/session-host-process.js +5 -5
- package/template/coding-task-manager/workers/watch-worker.js +105 -0
- package/template/coding-task-manager/workers/worktree-worker.js +168 -33
- package/template/ctm-relay/lib/protocol.js +14 -1
- package/template/package-lock.json +2 -2
- package/template/package.json +1 -1
- package/template/shared/backup-retention.js +82 -0
- package/template/shared/conversation-admission.js +2 -0
- package/template/shared/conversation-provenance.js +3 -7
- package/template/shared/conversation-storage-v2-contract.js +5 -0
- package/template/shared/linked-worktree.js +51 -0
- package/template/shared/macos-fda-target.js +57 -0
- package/template/shared/orphan-parents.js +55 -0
- package/template/shared/release-schema.json +2 -2
- package/template/shared/storage/contract.js +3 -0
- package/template/wall-e/adapters/imessage.js +12 -0
- package/template/wall-e/agent.js +71 -4
- package/template/wall-e/api-walle.js +21 -1
- package/template/wall-e/bin/train-gemma-e4b-tooluse.js +2 -2
- package/template/wall-e/bin/walle-mcp-stdio.js +5 -5
- package/template/wall-e/brain/brain-join.js +859 -0
- package/template/wall-e/brain/brain-sync-membership.js +20 -0
- package/template/wall-e/brain/brain-sync-store.js +131 -77
- package/template/wall-e/brain/brain-sync-v2-schema.js +203 -0
- package/template/wall-e/brain/brain-sync-v2.js +578 -0
- package/template/wall-e/brain/delegate-model-prefs-store.js +13 -4
- package/template/wall-e/brain/deterministic-id.js +51 -0
- package/template/wall-e/brain/memories.js +2 -2
- package/template/wall-e/brain/migrations.js +40 -6
- package/template/wall-e/brain/model-identity-migration.js +1 -1
- package/template/wall-e/brain/owner-call-whitelist.js +23 -7
- package/template/wall-e/brain/schema.js +45 -85
- package/template/wall-e/brain.js +171 -35
- package/template/wall-e/chat.js +3 -3
- package/template/wall-e/coding/agent-shell-env.js +7 -2
- package/template/wall-e/coding/prompt-bundle.js +66 -21
- package/template/wall-e/config/main-loop-exemptions.json +2 -2
- package/template/wall-e/http/admin-api.js +37 -0
- package/template/wall-e/http/gws-api.js +4 -0
- package/template/wall-e/http/helper-rules-api.js +7 -1
- package/template/wall-e/http/model-admin.js +8 -1
- package/template/wall-e/http/model-delegate-pref-admin.js +3 -3
- package/template/wall-e/http/model-proxy-providers.js +174 -1
- package/template/wall-e/http/model-route-health.js +157 -0
- package/template/wall-e/http/sync-api.js +278 -464
- package/template/wall-e/jobs/job-runner.js +28 -1
- package/template/wall-e/lib/brain-owner-op-priority.js +9 -1
- package/template/wall-e/lib/ctm-data-dir.js +26 -0
- package/template/wall-e/lib/derivation-home.js +147 -0
- package/template/wall-e/lib/helper-rules/evaluate.js +50 -9
- package/template/wall-e/lib/helper-rules/grade.js +51 -8
- package/template/wall-e/lib/helper-rules/lead-call-hook.js +38 -5
- package/template/wall-e/lib/helper-rules/store.js +4 -2
- package/template/wall-e/lib/landing-mcp-tools.js +170 -0
- package/template/wall-e/lib/mcp-client-config.js +133 -14
- package/template/wall-e/lib/mcp-gateway-migrate.js +28 -64
- package/template/wall-e/lib/mcp-integration.js +58 -13
- package/template/wall-e/lib/parent-death.js +7 -1
- package/template/wall-e/lib/scheduler-worker-jobs.js +6 -4
- package/template/wall-e/llm/delegate-lead-prefs.js +16 -1
- package/template/wall-e/llm/delegate-vendor-default.js +12 -5
- package/template/wall-e/llm/model-roles.js +1 -1
- package/template/wall-e/llm/native-delegate-selection.js +56 -8
- package/template/wall-e/llm/worker-delegate-args.js +72 -7
- package/template/wall-e/llm/worker-mcp-routing.js +66 -17
- package/template/wall-e/loops/brain-custom-writes.js +19 -0
- package/template/wall-e/loops/ingest.js +17 -1
- package/template/wall-e/loops/think.js +19 -4
- package/template/wall-e/mcp-contract.js +222 -6
- package/template/wall-e/mcp-protocol-contract.js +40 -5
- package/template/wall-e/mcp-server.js +128 -29
- package/template/wall-e/mcp-worker-schemas.js +5 -5
- package/template/wall-e/memory/ctm-context-client.js +85 -0
- package/template/wall-e/memory/ctm-session-context.js +9 -3
- package/template/wall-e/memory/hub-bridge-client.js +388 -0
- package/template/wall-e/memory/replica-origin.js +56 -0
- package/template/wall-e/memory/session-pool.js +135 -0
- package/template/wall-e/runtime/live-capabilities.js +8 -3
- package/template/wall-e/server.js +4 -2
- package/template/wall-e/shared/release-schema.json +2 -2
- package/template/wall-e/shared/sqlite-file-set.js +39 -0
- package/template/wall-e/shared/storage/contract.js +3 -0
- package/template/wall-e/skills/_templates/delegate-worker/VERSION +1 -1
- package/template/wall-e/skills/_templates/delegate-worker/released-sha256.json +7 -1
- package/template/wall-e/skills/_templates/delegate-worker/templates/claude/SKILL.md +4 -4
- package/template/wall-e/skills/_templates/delegate-worker/templates/codex/SKILL.md +6 -6
- package/template/wall-e/skills/_templates/fleet-sync/VERSION +1 -0
- package/template/wall-e/skills/_templates/fleet-sync/released-sha256.json +16 -0
- package/template/wall-e/skills/_templates/fleet-sync/templates/claude/SKILL.md +64 -0
- package/template/wall-e/skills/_templates/fleet-sync/templates/codex/SKILL.md +64 -0
- package/template/wall-e/tools/chrome-automation.js +6 -0
- package/template/wall-e/training/setup-cuda-train-env.sh +2 -2
- package/template/wall-e/workers/brain-owner-worker.js +18 -4
- package/template/wall-e/workers/mcp-gateway-process.js +5 -5
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// WP-3 (docs/shared-memory-every-machine-2026-10-31.html §5 D-9/D-12, §6.6): the box-side MEMBER
|
|
4
|
+
// front routes. Every CTM serves them — only a paired member is ever asked — and each is a thin,
|
|
5
|
+
// verbatim proxy to THIS host's loopback Wall-E (D-12: the hub reaches a box only through its CTM
|
|
6
|
+
// URL; Wall-E's own v2 routes accept only the local CTM token).
|
|
7
|
+
//
|
|
8
|
+
// GET /api/sync/brain/v2/vector -> GET <local Wall-E>/api/walle/sync/v2/vector
|
|
9
|
+
// POST /api/sync/brain/v2/changes -> POST /api/walle/sync/v2/changes
|
|
10
|
+
// POST /api/sync/brain/v2/apply -> POST /api/walle/sync/v2/apply
|
|
11
|
+
// GET /api/sync/brain/v2/digest?table= -> GET /api/walle/sync/v2/digest?table=<same>
|
|
12
|
+
//
|
|
13
|
+
// WP-4 (§5 D-6, §6.7) add the JOIN family. The hub ships its snapshot in 4 MiB chunks to the member
|
|
14
|
+
// CTM, which assembles them under <dataDir>/sync-inbox — the member's own disk is the only place the
|
|
15
|
+
// bytes can live, so these three are NOT proxies: `join/chunk` and `join/transfer` do real,
|
|
16
|
+
// bounded local file I/O; `join/import` and `join/status` forward verbatim to the box's Wall-E
|
|
17
|
+
// exactly like the four above.
|
|
18
|
+
//
|
|
19
|
+
// POST /api/sync/brain/v2/join/chunk { joinId, index, total, chunkBytes, fileBytes, fileSha256,
|
|
20
|
+
// dataBase64 } -> 200 { ok, received, complete:false }
|
|
21
|
+
// | 200 { ok, complete:true, path }
|
|
22
|
+
// GET /api/sync/brain/v2/join/transfer?joinId= -> 200 { ok, joinId, total, received, complete, path }
|
|
23
|
+
// POST /api/sync/brain/v2/join/import -> POST /api/walle/sync/v2/join/import
|
|
24
|
+
// GET /api/sync/brain/v2/join/status -> GET /api/walle/sync/v2/join/status
|
|
25
|
+
//
|
|
26
|
+
// The Wall-E status code and JSON body are returned VERBATIM (a 409 clock_seed_pending, a 503
|
|
27
|
+
// brain_sync_disabled and a 413 too_many_entries all pass through unchanged). A Wall-E that cannot
|
|
28
|
+
// be reached becomes 503 { ok:false, error:'walle_unreachable' }; a request body over the 8 MiB cap
|
|
29
|
+
// becomes 413 before any forward.
|
|
30
|
+
//
|
|
31
|
+
// Like lib/api/machines.js this is NEW surface: the handler bodies live here, so there is no legacy
|
|
32
|
+
// handleApi branch to delete and api-router-parity's no-dual-dispatch rule is satisfied by
|
|
33
|
+
// construction. Auth is NOT evaluated here — lib/auth-rules.js carries the four rows (scope `sync`,
|
|
34
|
+
// peerControl: true, so only the pool/sync bearer reaches them) — and a route with no rule is 403
|
|
35
|
+
// auth_rule_missing by design, so the rule rows and these registrations must land together.
|
|
36
|
+
|
|
37
|
+
const crypto = require('node:crypto');
|
|
38
|
+
const fs = require('node:fs');
|
|
39
|
+
const fsp = require('node:fs/promises');
|
|
40
|
+
const path = require('node:path');
|
|
41
|
+
|
|
42
|
+
const { registerApiRoutes } = require('../api-router');
|
|
43
|
+
const { CHUNK_BYTES } = require('../memory-join');
|
|
44
|
+
|
|
45
|
+
// §6.6: one apply page is at most 2000 entries; 8 MiB comfortably covers a full page and is the
|
|
46
|
+
// route's own refusal point, independent of Wall-E's. §6.7's chunk route reuses the same cap: a
|
|
47
|
+
// 4 MiB chunk is ~5.4 MiB of base64 inside JSON, so 8 MiB is the honest bound for both.
|
|
48
|
+
const MAX_BODY_BYTES = 8 * 1024 * 1024;
|
|
49
|
+
const BODY_TOO_LARGE = 'request_body_too_large';
|
|
50
|
+
|
|
51
|
+
// §6.7: the ingest directory and its file names. A join is `<dataDir>/sync-inbox/join-<joinId>`,
|
|
52
|
+
// with a `.part` while the chunks are arriving, a `.part.json` sidecar tracking `received[]`, and
|
|
53
|
+
// `.db` once the whole-file sha256 matches.
|
|
54
|
+
const INBOX_DIR_NAME = 'sync-inbox';
|
|
55
|
+
const JOIN_ID_RE = /^[A-Za-z0-9._:-]{1,200}$/;
|
|
56
|
+
const SHA256_HEX_RE = /^[0-9a-f]{64}$/;
|
|
57
|
+
const SIDECAR_SUFFIX = '.part.json';
|
|
58
|
+
const PART_SUFFIX = '.part';
|
|
59
|
+
const FINAL_SUFFIX = '.db';
|
|
60
|
+
|
|
61
|
+
let _deps = null;
|
|
62
|
+
|
|
63
|
+
function configure({ sendJsonResponse, readJsonRequestBody, walleClient, dataDir, statfs } = {}) {
|
|
64
|
+
_deps = { sendJsonResponse, readJsonRequestBody, walleClient, dataDir, statfs };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function _walle() {
|
|
68
|
+
return (_deps && _deps.walleClient) || require('../walle-client');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// §6.7: the ingest directory. Resolved lazily so a test can inject a temp dir (`dataDir` seam) and
|
|
72
|
+
// production keeps lib/data-dir.js's single source of truth; process.env is never read here.
|
|
73
|
+
function _dataDir() {
|
|
74
|
+
if (_deps && _deps.dataDir) return String(_deps.dataDir);
|
|
75
|
+
return require('../data-dir').getDataDir();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function _joinFiles(joinId) {
|
|
79
|
+
const dir = path.join(_dataDir(), INBOX_DIR_NAME);
|
|
80
|
+
return {
|
|
81
|
+
dir,
|
|
82
|
+
part: path.join(dir, `join-${joinId}${PART_SUFFIX}`),
|
|
83
|
+
sidecar: path.join(dir, `join-${joinId}${SIDECAR_SUFFIX}`),
|
|
84
|
+
final: path.join(dir, `join-${joinId}${FINAL_SUFFIX}`),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Every file call here is ASYNC (node:fs/promises): this module sits on the server's main thread,
|
|
89
|
+
// where a synchronous multi-megabyte hash or write would stall every other request (../bin/main-thread-lint.js).
|
|
90
|
+
|
|
91
|
+
async function _readSidecar(sidecarPath) {
|
|
92
|
+
try {
|
|
93
|
+
const parsed = JSON.parse(await fsp.readFile(sidecarPath, 'utf8'));
|
|
94
|
+
return {
|
|
95
|
+
total: Number(parsed.total) || 0,
|
|
96
|
+
fileBytes: Number(parsed.fileBytes) || 0,
|
|
97
|
+
fileSha256: String(parsed.fileSha256 || ''),
|
|
98
|
+
received: Array.isArray(parsed.received) ? parsed.received.map(Number).filter(Number.isInteger) : [],
|
|
99
|
+
};
|
|
100
|
+
} catch {
|
|
101
|
+
return null; // expected: no sidecar yet (or an unreadable one) — the caller rebuilds it
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Atomic sidecar write: a temp file in the same directory then a rename, so a crash mid-write can
|
|
106
|
+
// never leave a half-parsed `received[]` that would make the hub re-send or skip a chunk.
|
|
107
|
+
async function _writeSidecar(sidecarPath, value) {
|
|
108
|
+
const tmp = `${sidecarPath}.${process.pid}.tmp`;
|
|
109
|
+
await fsp.writeFile(tmp, JSON.stringify(value), { mode: 0o600 });
|
|
110
|
+
await fsp.rename(tmp, sidecarPath);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
async function _sha256OfFile(filePath) {
|
|
114
|
+
const hash = crypto.createHash('sha256');
|
|
115
|
+
const handle = await fsp.open(filePath, 'r');
|
|
116
|
+
try {
|
|
117
|
+
const buffer = Buffer.alloc(CHUNK_BYTES);
|
|
118
|
+
let position = 0;
|
|
119
|
+
for (;;) {
|
|
120
|
+
const { bytesRead } = await handle.read(buffer, 0, buffer.length, position);
|
|
121
|
+
if (bytesRead <= 0) break;
|
|
122
|
+
hash.update(buffer.subarray(0, bytesRead));
|
|
123
|
+
position += bytesRead;
|
|
124
|
+
}
|
|
125
|
+
} finally {
|
|
126
|
+
try { await handle.close(); } catch { /* expected: a close fault must not mask the hash verdict */ }
|
|
127
|
+
}
|
|
128
|
+
return hash.digest('hex');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async function _unlinkQuiet(filePath) {
|
|
132
|
+
try { await fsp.unlink(filePath); } catch { /* expected: already gone — the delete is idempotent */ }
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async function _exists(filePath) {
|
|
136
|
+
try { await fsp.stat(filePath); return true; } catch { /* expected: a missing path is the normal case */ return false; }
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function _freeBytes(dir) {
|
|
140
|
+
try {
|
|
141
|
+
const statfs = (_deps && typeof _deps.statfs === 'function') ? _deps.statfs : fs.statfsSync;
|
|
142
|
+
const stats = statfs(dir);
|
|
143
|
+
return Number(stats.bavail) * Number(stats.bsize);
|
|
144
|
+
} catch {
|
|
145
|
+
// expected: an unsupported platform/filesystem — treat as "unknown" and let the write fail
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
function _send(res, status, payload) {
|
|
152
|
+
if (_deps && typeof _deps.sendJsonResponse === 'function') return _deps.sendJsonResponse(res, status, payload || {});
|
|
153
|
+
const body = JSON.stringify(payload || {});
|
|
154
|
+
res.writeHead(status, { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) });
|
|
155
|
+
res.end(body);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async function _readBody(req) {
|
|
159
|
+
const reader = (_deps && _deps.readJsonRequestBody);
|
|
160
|
+
if (typeof reader !== 'function') {
|
|
161
|
+
// No reader injected (route registrations run without configure()): an empty body is the honest
|
|
162
|
+
// answer, and the forward still returns Wall-E's verdict.
|
|
163
|
+
return { ok: true, body: undefined };
|
|
164
|
+
}
|
|
165
|
+
try {
|
|
166
|
+
return { ok: true, body: await reader(req, { limitBytes: MAX_BODY_BYTES }) };
|
|
167
|
+
} catch (err) {
|
|
168
|
+
const tooLarge = err && err.message === BODY_TOO_LARGE;
|
|
169
|
+
return { ok: false, tooLarge };
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
async function _forward(res, pathname, { method = 'GET', body, headers } = {}) {
|
|
174
|
+
let result;
|
|
175
|
+
try {
|
|
176
|
+
const opts = body === undefined ? { method } : { method, body };
|
|
177
|
+
if (headers && Object.keys(headers).length) opts.headers = headers;
|
|
178
|
+
result = await _walle().requestJson(pathname, opts);
|
|
179
|
+
} catch {
|
|
180
|
+
// expected: the local Wall-E daemon is unreachable (down / mid-restart) — a truthful 503 the hub
|
|
181
|
+
// retries, never a fabricated empty page.
|
|
182
|
+
return _send(res, 503, { ok: false, error: 'walle_unreachable' });
|
|
183
|
+
}
|
|
184
|
+
const status = Number(result && result.status) || 502;
|
|
185
|
+
const payload = result && result.json != null ? result.json : { ok: false, error: 'walle_bad_response' };
|
|
186
|
+
return _send(res, status, payload);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
async function _handleVector(req, res) {
|
|
190
|
+
return _forward(res, '/api/walle/sync/v2/vector', { method: 'GET' });
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
async function _handleChanges(req, res) {
|
|
194
|
+
const read = await _readBody(req);
|
|
195
|
+
if (!read.ok) return _send(res, 413, { ok: false, error: 'payload_too_large' });
|
|
196
|
+
return _forward(res, '/api/walle/sync/v2/changes', { method: 'POST', body: read.body === undefined ? {} : read.body });
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
async function _handleApply(req, res) {
|
|
200
|
+
const read = await _readBody(req);
|
|
201
|
+
if (!read.ok) return _send(res, 413, { ok: false, error: 'payload_too_large' });
|
|
202
|
+
// shared-memory D-5: the calling home names itself; Wall-E records this node as its member.
|
|
203
|
+
const home = String((req && req.headers && req.headers['x-ctm-memory-sync-home']) || '').slice(0, 160).trim();
|
|
204
|
+
return _forward(res, '/api/walle/sync/v2/apply', {
|
|
205
|
+
method: 'POST', body: read.body === undefined ? {} : read.body, ...(home ? { headers: { 'X-CTM-Memory-Sync-Home': home } } : {}),
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
async function _handleDigest(req, res, url) {
|
|
210
|
+
const table = (url && url.searchParams && url.searchParams.get('table')) || '';
|
|
211
|
+
const query = table ? `?table=${encodeURIComponent(table)}` : '';
|
|
212
|
+
return _forward(res, `/api/walle/sync/v2/digest${query}`, { method: 'GET' });
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// ------------------------------------------------------------------------------------------------
|
|
216
|
+
// §6.7 join: the member CTM assembles the hub's snapshot on its own disk (A-10). A join lives in
|
|
217
|
+
// <dataDir>/sync-inbox as join-<joinId>.part (+ .part.json) until every chunk is in and the
|
|
218
|
+
// whole-file sha256 matches, then becomes join-<joinId>.db for the local Wall-E to import (WP-4a).
|
|
219
|
+
|
|
220
|
+
// One received chunk: write it at its own offset, record the index, and — when that was the last
|
|
221
|
+
// one — verify the whole file before renaming it into place. Re-sending an index overwrites it.
|
|
222
|
+
async function _handleJoinChunk(req, res) {
|
|
223
|
+
const read = await _readBody(req);
|
|
224
|
+
// §6.7: 8 MiB, the same bound as every other v2 body (4 MiB raw -> ~5.4 MiB of base64 JSON).
|
|
225
|
+
if (!read.ok) return _send(res, 413, { ok: false, error: 'payload_too_large' });
|
|
226
|
+
const body = (read.body && typeof read.body === 'object') ? read.body : {};
|
|
227
|
+
const joinId = String(body.joinId || '');
|
|
228
|
+
if (!JOIN_ID_RE.test(joinId)) return _send(res, 400, { ok: false, error: 'invalid_join_id' });
|
|
229
|
+
const index = Number(body.index);
|
|
230
|
+
const total = Number(body.total);
|
|
231
|
+
const fileBytes = Number(body.fileBytes);
|
|
232
|
+
const chunkBytes = Number(body.chunkBytes);
|
|
233
|
+
if (!Number.isInteger(index) || index < 0 || !Number.isInteger(total) || total < 1 || index >= total) {
|
|
234
|
+
return _send(res, 400, { ok: false, error: 'index_out_of_range' });
|
|
235
|
+
}
|
|
236
|
+
if (!Number.isInteger(fileBytes) || fileBytes < 0) return _send(res, 400, { ok: false, error: 'invalid_file_bytes' });
|
|
237
|
+
if (!Number.isInteger(chunkBytes) || chunkBytes < 0 || chunkBytes > CHUNK_BYTES) {
|
|
238
|
+
return _send(res, 400, { ok: false, error: 'invalid_chunk_bytes' });
|
|
239
|
+
}
|
|
240
|
+
if (index * CHUNK_BYTES + chunkBytes > fileBytes) return _send(res, 400, { ok: false, error: 'chunk_out_of_file' });
|
|
241
|
+
const data = Buffer.from(String(body.dataBase64 || ''), 'base64');
|
|
242
|
+
if (data.length !== chunkBytes) return _send(res, 400, { ok: false, error: 'chunk_length_mismatch' });
|
|
243
|
+
|
|
244
|
+
const files = _joinFiles(joinId);
|
|
245
|
+
try {
|
|
246
|
+
await fsp.mkdir(files.dir, { recursive: true, mode: 0o700 });
|
|
247
|
+
} catch {
|
|
248
|
+
return _send(res, 500, { ok: false, error: 'join_inbox_unwritable' });
|
|
249
|
+
}
|
|
250
|
+
// §6.7: the free-space precondition is checked before index 0 lands — 2x the snapshot, so the
|
|
251
|
+
// member can hold the .part and the imported DB side by side.
|
|
252
|
+
if (index === 0 || !(await _exists(files.part))) {
|
|
253
|
+
const free = _freeBytes(files.dir);
|
|
254
|
+
if (free != null && free < 2 * fileBytes) return _send(res, 507, { ok: false, error: 'insufficient_storage' });
|
|
255
|
+
}
|
|
256
|
+
let handle;
|
|
257
|
+
try {
|
|
258
|
+
handle = await fsp.open(files.part, (await _exists(files.part)) ? 'r+' : 'w', 0o600);
|
|
259
|
+
} catch {
|
|
260
|
+
return _send(res, 500, { ok: false, error: 'join_part_open_failed' });
|
|
261
|
+
}
|
|
262
|
+
try {
|
|
263
|
+
await handle.write(data, 0, data.length, index * CHUNK_BYTES);
|
|
264
|
+
} catch {
|
|
265
|
+
return _send(res, 500, { ok: false, error: 'join_part_write_failed' });
|
|
266
|
+
} finally {
|
|
267
|
+
try { await handle.close(); } catch { /* expected: a close fault must not mask the write verdict */ }
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const prior = (await _readSidecar(files.sidecar)) || { received: [] };
|
|
271
|
+
const received = Array.from(new Set([...prior.received, index])).sort((a, b) => a - b);
|
|
272
|
+
const sidecar = { total, fileBytes, fileSha256: String(body.fileSha256 || ''), received };
|
|
273
|
+
try {
|
|
274
|
+
await _writeSidecar(files.sidecar, sidecar);
|
|
275
|
+
} catch {
|
|
276
|
+
return _send(res, 500, { ok: false, error: 'join_sidecar_write_failed' });
|
|
277
|
+
}
|
|
278
|
+
if (received.length < total) return _send(res, 200, { ok: true, received: index, complete: false });
|
|
279
|
+
|
|
280
|
+
// Every index is in: verify the assembled file and either promote it or drop the whole transfer.
|
|
281
|
+
const actual = await _sha256OfFile(files.part);
|
|
282
|
+
if (!SHA256_HEX_RE.test(sidecar.fileSha256) || actual !== sidecar.fileSha256) {
|
|
283
|
+
await _unlinkQuiet(files.part);
|
|
284
|
+
await _unlinkQuiet(files.sidecar);
|
|
285
|
+
return _send(res, 422, { ok: false, error: 'sha256_mismatch' });
|
|
286
|
+
}
|
|
287
|
+
try {
|
|
288
|
+
await fsp.rename(files.part, files.final);
|
|
289
|
+
} catch {
|
|
290
|
+
return _send(res, 500, { ok: false, error: 'join_promote_failed' });
|
|
291
|
+
}
|
|
292
|
+
await _unlinkQuiet(files.sidecar);
|
|
293
|
+
return _send(res, 200, { ok: true, complete: true, path: files.final });
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// What the hub has already managed to send for this join — the resume answer after either side
|
|
297
|
+
// restarted (P-3, checkpoints on both sides).
|
|
298
|
+
async function _handleJoinTransfer(req, res, url) {
|
|
299
|
+
const joinId = String((url && url.searchParams && url.searchParams.get('joinId')) || '');
|
|
300
|
+
if (!JOIN_ID_RE.test(joinId)) return _send(res, 400, { ok: false, error: 'invalid_join_id' });
|
|
301
|
+
const files = _joinFiles(joinId);
|
|
302
|
+
const sidecar = await _readSidecar(files.sidecar);
|
|
303
|
+
if (sidecar) {
|
|
304
|
+
return _send(res, 200, { ok: true, joinId, total: sidecar.total, received: sidecar.received, complete: false, path: null });
|
|
305
|
+
}
|
|
306
|
+
if (await _exists(files.final)) {
|
|
307
|
+
return _send(res, 200, { ok: true, joinId, total: 0, received: [], complete: true, path: files.final });
|
|
308
|
+
}
|
|
309
|
+
return _send(res, 200, { ok: true, joinId, total: 0, received: [], complete: false, path: null });
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
async function _handleJoinImport(req, res) {
|
|
313
|
+
const read = await _readBody(req);
|
|
314
|
+
if (!read.ok) return _send(res, 413, { ok: false, error: 'payload_too_large' });
|
|
315
|
+
return _forward(res, '/api/walle/sync/v2/join/import', { method: 'POST', body: read.body === undefined ? {} : read.body });
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
async function _handleJoinStatus(req, res) {
|
|
319
|
+
return _forward(res, '/api/walle/sync/v2/join/status', { method: 'GET' });
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function register() {
|
|
323
|
+
registerApiRoutes('memory-sync', [
|
|
324
|
+
{ method: 'GET', path: '/api/sync/brain/v2/vector', handler: (req, res, url) => _handleVector(req, res, url) },
|
|
325
|
+
{ method: 'POST', path: '/api/sync/brain/v2/changes', handler: (req, res, url) => _handleChanges(req, res, url) },
|
|
326
|
+
{ method: 'POST', path: '/api/sync/brain/v2/apply', handler: (req, res, url) => _handleApply(req, res, url) },
|
|
327
|
+
{ method: 'GET', path: '/api/sync/brain/v2/digest', handler: (req, res, url) => _handleDigest(req, res, url) },
|
|
328
|
+
{ method: 'POST', path: '/api/sync/brain/v2/join/chunk', handler: (req, res, url) => _handleJoinChunk(req, res, url) },
|
|
329
|
+
{ method: 'GET', path: '/api/sync/brain/v2/join/transfer', handler: (req, res, url) => _handleJoinTransfer(req, res, url) },
|
|
330
|
+
{ method: 'POST', path: '/api/sync/brain/v2/join/import', handler: (req, res, url) => _handleJoinImport(req, res, url) },
|
|
331
|
+
{ method: 'GET', path: '/api/sync/brain/v2/join/status', handler: (req, res, url) => _handleJoinStatus(req, res, url) },
|
|
332
|
+
]);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
module.exports = { configure, register };
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
|
|
34
34
|
const { registerApiRoutes } = require('../api-router');
|
|
35
35
|
const remoteMachineProxy = require('../remote-machine-proxy');
|
|
36
|
+
const { noteCreateIntent } = require('../create-intent-lease');
|
|
36
37
|
|
|
37
38
|
let _deps = null;
|
|
38
39
|
|
|
@@ -263,9 +264,13 @@ function register() {
|
|
|
263
264
|
handler: (req, res, url) => handleWorkspaceSessionsDelete(req, res, url),
|
|
264
265
|
},
|
|
265
266
|
{ method: 'DELETE', prefix: '/api/workspaces/', handler: (req, res, url) => handleWorkspaceDelete(req, res, url) },
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
267
|
+
// WP-3 (D-4): the new-session modal's three picker calls note a create intent on the machine
|
|
268
|
+
// that ANSWERS them. The note sits in the `local` arrow, so the `_machineRouted` proxy branch
|
|
269
|
+
// (a request naming another box) never notes here -- the box that would restart is the box
|
|
270
|
+
// that notes, and a hub must not hold its own restart for a peer's create.
|
|
271
|
+
{ method: 'GET', path: '/api/projects', handler: _machineRouted('GET /api/projects', (req, res) => { noteCreateIntent('GET /api/projects', req); return _deps.apiGetProjects(req, res); }) },
|
|
272
|
+
{ method: 'GET', path: '/api/path-suggest', handler: _machineRouted('GET /api/path-suggest', (req, res, url) => { noteCreateIntent('GET /api/path-suggest', req); return _deps.apiPathSuggest(req, res, url); }) },
|
|
273
|
+
{ method: 'POST', path: '/api/path-status', handler: _machineRouted('POST /api/path-status', (req, res) => { noteCreateIntent('POST /api/path-status', req); return _deps.apiPathStatus(req, res); }) },
|
|
269
274
|
{ method: 'GET', path: '/api/rules', handler: (req, res, url) => _deps.apiGetRules(req, res, url) },
|
|
270
275
|
{ method: 'PUT', path: '/api/rules', handler: (req, res) => _deps.apiPutRules(req, res) },
|
|
271
276
|
{ method: 'GET', path: '/api/rules/list', handler: (req, res) => _deps.apiListRules(req, res) },
|