@sleep2agi/commhub-server 0.9.0-preview.28 → 0.9.0-preview.280
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 +120 -3
- package/bin/commhub.ts +93 -9
- package/build-info.json +7 -0
- package/package.json +10 -8
- package/src/ack-create-request-transport.test.ts +182 -0
- package/src/ack-create-request.test.ts +52 -8
- package/src/admin-delete-network-http.test.ts +229 -0
- package/src/admin-networks-http.test.ts +88 -0
- package/src/adoption-candidates-http.test.ts +140 -0
- package/src/adoption-candidates.ts +158 -0
- package/src/agent-access-batch.test.ts +215 -0
- package/src/agent-access.ts +585 -0
- package/src/agent-acl-groups-http.test.ts +247 -0
- package/src/agent-acl-http.test.ts +691 -0
- package/src/agent-acl-slice3-http.test.ts +888 -0
- package/src/agent-department-grants.test.ts +129 -0
- package/src/agent-department-http.test.ts +215 -0
- package/src/agent-groups-perf.test.ts +228 -0
- package/src/agent-notice.ts +48 -0
- package/src/agent-team-whoami-http.test.ts +98 -0
- package/src/agent-teams-http.test.ts +330 -0
- package/src/agent-teams.ts +244 -0
- package/src/alias-baseline-2571.test.ts +162 -0
- package/src/alias-baseline.ts +113 -0
- package/src/alias-filter.test.ts +72 -0
- package/src/alias-filter.ts +42 -0
- package/src/all-status-cache.test.ts +31 -0
- package/src/all-status-cache.ts +37 -0
- package/src/anet-variant-real-daemon-http.test.ts +184 -0
- package/src/api-host-supervisors-can-create-nodes.test.ts +350 -0
- package/src/api-host-supervisors-fallback.test.ts +6 -7
- package/src/api-host-supervisors-runtime-readiness.test.ts +195 -0
- package/src/api-nodes-shape.test.ts +131 -4
- package/src/auth-abuse-counters.test.ts +144 -0
- package/src/auth-abuse-counters.ts +122 -0
- package/src/auth-layer-shape.test.ts +105 -0
- package/src/auth-password-change-cli-tokens-http.test.ts +423 -0
- package/src/auth-sessions-http.test.ts +260 -0
- package/src/auth-validate.test.ts +5 -1
- package/src/auth-weak-password-login.test.ts +176 -0
- package/src/auth.ts +641 -68
- package/src/backfill-node-ids-2664.test.ts +128 -0
- package/src/binding-generation-http.test.ts +141 -0
- package/src/blocked-exit-on-reply.test.ts +122 -0
- package/src/broadcast-fanout-2721.test.ts +149 -0
- package/src/broadcast-fanout.ts +117 -0
- package/src/build-commit-report-http.test.ts +218 -0
- package/src/build-info.test.ts +60 -0
- package/src/build-info.ts +85 -0
- package/src/chain-attempt-dedup.test.ts +447 -0
- package/src/clip.test.ts +36 -0
- package/src/clip.ts +48 -0
- package/src/clone-node.test.ts +269 -0
- package/src/clone-node.ts +289 -0
- package/src/codex-config-flags.ts +77 -0
- package/src/codex-fork-contract.ts +23 -0
- package/src/codex-fork-migration.test.ts +38 -0
- package/src/commhub-bin-args.test.ts +85 -0
- package/src/config-apply-sec1.test.ts +37 -0
- package/src/config-apply-validate.test.ts +188 -1
- package/src/config-apply-validate.ts +226 -3
- package/src/contracts/session-project-create.ts +14 -0
- package/src/contracts/session-source-delivery.ts +16 -0
- package/src/contracts/session-source-directory.ts +54 -0
- package/src/contracts/session-source-evidence.ts +72 -0
- package/src/contracts/session-source-execution.ts +24 -0
- package/src/contracts/session-source-transport.ts +18 -0
- package/src/cors-origins.test.ts +73 -0
- package/src/create-node-blocked-gate.test.ts +365 -0
- package/src/create-node-error-domain.test.ts +127 -0
- package/src/create-node-network-id.test.ts +91 -0
- package/src/create-node-tool-schema.test.ts +59 -0
- package/src/create-node-unicode-name.test.ts +126 -0
- package/src/create-node-validate.test.ts +199 -7
- package/src/create-node-validate.ts +232 -15
- package/src/create-node-workdir.test.ts +298 -0
- package/src/create-node.ts +88 -23
- package/src/daemon-provider-snapshots.test.ts +453 -0
- package/src/daemon-provider-snapshots.ts +327 -0
- package/src/daemon-token-owner-http.test.ts +346 -0
- package/src/dashboard-slash-routing-http.test.ts +109 -0
- package/src/db-adapter-guard.test.ts +148 -0
- package/src/db-adapter-translate.test.ts +128 -0
- package/src/db-adapter.ts +377 -91
- package/src/db-timestamp.test.ts +38 -0
- package/src/db-timestamp.ts +15 -0
- package/src/db.ts +1334 -154
- package/src/delivered-without-push.test.ts +140 -0
- package/src/department-groups-http.test.ts +209 -0
- package/src/department-groups-sync-http.test.ts +328 -0
- package/src/department-groups.ts +434 -0
- package/src/department-heads-http.test.ts +350 -0
- package/src/department-heads.ts +226 -0
- package/src/departments-agent-count.test.ts +139 -0
- package/src/departments-http.test.ts +185 -0
- package/src/departments-mcp-error-domain.test.ts +135 -0
- package/src/departments-mcp.test.ts +128 -0
- package/src/departments.ts +318 -0
- package/src/desktop-message-seam.test.ts +150 -0
- package/src/desktop-message.test.ts +368 -0
- package/src/dm-file-scope-http.test.ts +227 -0
- package/src/empty-node-sweeper.test.ts +104 -0
- package/src/empty-node-sweeper.ts +88 -0
- package/src/env-transport-gate-http.test.ts +240 -0
- package/src/env-transport-gate.ts +80 -0
- package/src/env-transport-policy.ts +56 -0
- package/src/etag-of.test.ts +57 -0
- package/src/event-loop-lag.test.ts +180 -0
- package/src/event-loop-lag.ts +201 -0
- package/src/expiry-counters.test.ts +187 -0
- package/src/expiry-counters.ts +227 -0
- package/src/expiry-evidence-db.test.ts +103 -0
- package/src/ext-token-shared.test.ts +60 -0
- package/src/ext-validation-regression.test.ts +10 -17
- package/src/external-schedule-edits-http.test.ts +321 -0
- package/src/external-schedule-edits-timestamps.test.ts +64 -0
- package/src/external-schedule-edits.ts +327 -0
- package/src/file-download-authz-dev-open.test.ts +1 -1
- package/src/file-download-authz.test.ts +25 -4
- package/src/file-download-date-bucket.test.ts +1 -1
- package/src/file-network-scope-dev-open.test.ts +1 -1
- package/src/file-network-scope.test.ts +7 -6
- package/src/group-membership-events-http.test.ts +264 -0
- package/src/group-messages-http.test.ts +483 -0
- package/src/group-messages.ts +297 -0
- package/src/health-anon-readers.ts +67 -0
- package/src/health-host-disk-2756.test.ts +71 -0
- package/src/health-identity-root.test.ts +98 -0
- package/src/health-redaction.test.ts +1599 -7
- package/src/health-status-reasons.test.ts +84 -0
- package/src/host-supervisor-identity-http.test.ts +152 -0
- package/src/host-supervisor-identity.ts +92 -0
- package/src/host-supervisors-daemon-version.test.ts +137 -0
- package/src/http-gzip.test.ts +94 -0
- package/src/http-gzip.ts +112 -0
- package/src/hub-catalog-read-http.test.ts +664 -0
- package/src/hub-provider-config.test.ts +166 -0
- package/src/hub-provider-config.ts +202 -0
- package/src/hub-timestamp.test.ts +38 -0
- package/src/hub-timestamp.ts +27 -0
- package/src/human-dm.ts +215 -0
- package/src/human-inbox.ts +42 -0
- package/src/inbox-caller.ts +49 -0
- package/src/inbox-count-sse.test.ts +318 -0
- package/src/inbox-count.ts +29 -0
- package/src/index.ts +6 -2
- package/src/license-state.test.ts +105 -0
- package/src/license-state.ts +48 -0
- package/src/lifecycle-error-domain.test.ts +149 -0
- package/src/list-ack-error-domain.test.ts +108 -0
- package/src/list-host-supervisors.test.ts +15 -4
- package/src/list-tasks-omit-default.test.ts +84 -0
- package/src/list-tasks-since-last.test.ts +100 -0
- package/src/list-tasks-since.test.ts +104 -0
- package/src/mcp-context-cost-http.test.ts +127 -0
- package/src/mcp-inflight.test.ts +92 -0
- package/src/mcp-inflight.ts +38 -0
- package/src/mcp-projects-events-http.test.ts +168 -0
- package/src/mcp-route-label-http.test.ts +120 -0
- package/src/mcp-write-network-resolution.test.ts +21 -0
- package/src/member-audit-network-id-http.test.ts +93 -0
- package/src/member-presence-http.test.ts +210 -0
- package/src/messages-ack-by-agent-http.test.ts +142 -0
- package/src/migrate-sqlite-to-pg.test.ts +47 -0
- package/src/migrate-sqlite-to-pg.ts +263 -0
- package/src/model-auth-notify-http.test.ts +181 -0
- package/src/model-auth-notify.ts +116 -0
- package/src/network-name-http.test.ts +75 -0
- package/src/network-quota-config.test.ts +100 -0
- package/src/network-rules-http.test.ts +169 -0
- package/src/network-rules.ts +129 -0
- package/src/network-scope.ts +222 -3
- package/src/network-token-membership-http.test.ts +186 -0
- package/src/node-alias-control.ts +12 -0
- package/src/node-attrs.test.ts +47 -2
- package/src/node-caller-identity-http.test.ts +1108 -0
- package/src/node-config-last-update.test.ts +126 -0
- package/src/node-config-last-update.ts +107 -0
- package/src/node-create-request-status-http.test.ts +105 -0
- package/src/node-daemon-bindings.test.ts +142 -0
- package/src/node-daemon-bindings.ts +135 -0
- package/src/node-failure-alert.test.ts +150 -0
- package/src/node-failure-alert.ts +177 -0
- package/src/node-files-transport.test.ts +350 -0
- package/src/node-health-codex-login.test.ts +120 -0
- package/src/node-health-dispatch-http.test.ts +373 -0
- package/src/node-health-guard-origin.test.ts +98 -0
- package/src/node-health-guard.ts +121 -0
- package/src/node-health-passthrough.test.ts +115 -0
- package/src/node-health-store.ts +101 -0
- package/src/node-id-alias.test.ts +190 -0
- package/src/node-identity-conflict-http.test.ts +269 -0
- package/src/node-identity-conflict.ts +142 -0
- package/src/node-identity-mismatch.test.ts +74 -0
- package/src/node-in-flight-tasks.ts +31 -0
- package/src/node-lifecycle-controllable.test.ts +64 -0
- package/src/node-lifecycle-controllable.ts +53 -0
- package/src/node-lifecycle-read-http.test.ts +257 -0
- package/src/node-lifecycle-read.ts +126 -0
- package/src/node-logs-transport.test.ts +266 -0
- package/src/node-peer-allowlist.test.ts +114 -0
- package/src/node-permissions-http.test.ts +901 -0
- package/src/node-permissions.ts +496 -0
- package/src/node-request-retention.test.ts +281 -0
- package/src/node-request-retention.ts +120 -0
- package/src/node-secret-rest-http.test.ts +190 -0
- package/src/node-secret-vault-inject.test.ts +132 -0
- package/src/node-security-write-gate.test.ts +72 -0
- package/src/node-serviceability.test.ts +86 -0
- package/src/node-serviceability.ts +124 -0
- package/src/node-session-control-http.test.ts +398 -0
- package/src/node-session-control.ts +316 -0
- package/src/node-skills-transport.test.ts +212 -0
- package/src/node-token-identity.ts +35 -0
- package/src/node-token-ownership.ts +51 -0
- package/src/node-token-privilege-http.test.ts +224 -0
- package/src/node-token-usage.test.ts +128 -0
- package/src/node-token-usage.ts +228 -0
- package/src/not-found-api-http.test.ts +67 -0
- package/src/observer-avatar-http.test.ts +103 -10
- package/src/observer-push.test.ts +76 -0
- package/src/opencode-catalog-report-http.test.ts +139 -0
- package/src/opencode-v2-catalog.test.ts +282 -0
- package/src/opencode-v2-catalog.ts +357 -0
- package/src/package-self-contained.test.ts +32 -0
- package/src/package-version-consistency.test.ts +25 -0
- package/src/parent-infer.test.ts +82 -0
- package/src/parent-infer.ts +110 -0
- package/src/parent-source-marker.test.ts +70 -0
- package/src/parent-source-orphan.test.ts +121 -0
- package/src/password-network-tokens.ts +25 -0
- package/src/peer-reply-atomic.test.ts +462 -0
- package/src/peer-reply-capability.test.ts +70 -0
- package/src/pg-worker.ts +87 -0
- package/src/poll-pacing.test.ts +74 -0
- package/src/poll-pacing.ts +123 -0
- package/src/probe-provider-error-domain.test.ts +145 -0
- package/src/project-dir-warn-clear-http.test.ts +132 -0
- package/src/project-viewer-can-http.test.ts +116 -0
- package/src/provider-skill-error-domain.test.ts +130 -0
- package/src/provider-tools-shape.test.ts +165 -0
- package/src/push.test.ts +20 -10
- package/src/push.ts +373 -9
- package/src/redact-tokens.test.ts +86 -0
- package/src/redact-tokens.ts +43 -0
- package/src/rejection-counters.test.ts +72 -0
- package/src/rejection-counters.ts +173 -0
- package/src/rename.ts +38 -10
- package/src/reply-target-derivation.test.ts +96 -0
- package/src/report-status-handover-capabilities-http.test.ts +124 -0
- package/src/report-status-host-schema.test.ts +272 -0
- package/src/report-status-resume-id-handover.test.ts +184 -0
- package/src/report-status-secret-keys.test.ts +140 -0
- package/src/require-explicit-test-db.ts +9 -0
- package/src/requirement-due-reminders-http.test.ts +620 -0
- package/src/requirement-due-reminders.ts +416 -0
- package/src/requirement-events-http.test.ts +318 -0
- package/src/requirement-events.test.ts +45 -0
- package/src/requirement-events.ts +144 -0
- package/src/requirement-notify.ts +165 -0
- package/src/requirement-participant-notify-http.test.ts +313 -0
- package/src/requirement-tag-ops-http.test.ts +454 -0
- package/src/requirement-tag-tree-http.test.ts +275 -0
- package/src/requirement-tag-tree.ts +127 -0
- package/src/requirement-tags.ts +102 -0
- package/src/requirements-abandoned-http.test.ts +236 -0
- package/src/requirements-assignee-drift.test.ts +154 -0
- package/src/requirements-comment-http.test.ts +174 -0
- package/src/requirements-completed-at-migration.test.ts +70 -0
- package/src/requirements-errors-mcp-http.test.ts +164 -0
- package/src/requirements-errors.ts +158 -0
- package/src/requirements-etag-http.test.ts +91 -0
- package/src/requirements-http.test.ts +709 -0
- package/src/requirements-last-event-http.test.ts +349 -0
- package/src/requirements-list-mcp-slim-http.test.ts +155 -0
- package/src/requirements-list-slim-http.test.ts +324 -0
- package/src/requirements-mcp.test.ts +180 -0
- package/src/requirements-migrate.ts +283 -0
- package/src/requirements-owner-strict-mcp-http.test.ts +145 -0
- package/src/requirements-people-http.test.ts +114 -0
- package/src/requirements-people-mcp-http.test.ts +231 -0
- package/src/requirements-people.ts +196 -0
- package/src/requirements-priority-lowest.test.ts +114 -0
- package/src/requirements-projects-network-echo.test.ts +57 -0
- package/src/requirements-projects-parent-http.test.ts +123 -0
- package/src/requirements-search-http.test.ts +182 -0
- package/src/requirements-search.test.ts +32 -0
- package/src/requirements-search.ts +145 -0
- package/src/requirements-seq-http.test.ts +193 -0
- package/src/requirements-seq-migration.test.ts +63 -0
- package/src/requirements-start-date.test.ts +125 -0
- package/src/requirements-stats-http.test.ts +357 -0
- package/src/requirements-stats.ts +195 -0
- package/src/requirements-status-participants-http.test.ts +222 -0
- package/src/requirements-upgrade-e2e.test.ts +126 -0
- package/src/requirements-upgrade-migration.test.ts +98 -0
- package/src/requirements.ts +2205 -0
- package/src/resolve-port.test.ts +57 -0
- package/src/resolve-port.ts +44 -0
- package/src/rest-alias-network-fallback-http.test.ts +123 -0
- package/src/rest-alias-network-fallback.test.ts +60 -0
- package/src/rest-alias-network-fallback.ts +65 -0
- package/src/rest-explicit-columns-http.test.ts +266 -0
- package/src/rest-identity.test.ts +130 -0
- package/src/rest-identity.ts +141 -0
- package/src/rest-projections.ts +72 -0
- package/src/rest-read-network-real-chain.test.ts +97 -0
- package/src/rest-write-network-resolution.test.ts +133 -0
- package/src/restart-readiness-http.test.ts +121 -0
- package/src/restricted-files.ts +76 -0
- package/src/retention-first-sweep-quiet.test.ts +31 -0
- package/src/retention.test.ts +100 -40
- package/src/retention.ts +423 -104
- package/src/route-callers-http.test.ts +120 -0
- package/src/route-timing.test.ts +218 -0
- package/src/route-timing.ts +262 -0
- package/src/rules-file-duplicate-alias.test.ts +234 -0
- package/src/rules-file-session-target.test.ts +207 -0
- package/src/rules-file-transport.test.ts +280 -0
- package/src/runtime-label.test.ts +22 -0
- package/src/runtime-label.ts +21 -0
- package/src/runtime-readiness.ts +90 -0
- package/src/schedule-agent-mcp-http.test.ts +486 -0
- package/src/schedule-agent.ts +252 -0
- package/src/schedule-starved.test.ts +92 -0
- package/src/schedule-starved.ts +114 -0
- package/src/scheduled-backoff-http.test.ts +203 -0
- package/src/scheduled-backoff.ts +64 -0
- package/src/scheduled-doorbell-nodeless-session.test.ts +134 -0
- package/src/scheduled-failure-backoff-2622.test.ts +145 -0
- package/src/scheduled-failure-code.test.ts +73 -0
- package/src/scheduled-failure-code.ts +105 -0
- package/src/scheduled-failures-http.test.ts +279 -0
- package/src/scheduled-failures.ts +425 -0
- package/src/scheduled-noprogress-backoff-2622.test.ts +163 -0
- package/src/scheduled-offline-backoff-probe.test.ts +56 -0
- package/src/scheduled-offline.test.ts +131 -0
- package/src/scheduled-offline.ts +66 -0
- package/src/scheduled-outcome-guidance-http.test.ts +139 -0
- package/src/scheduled-outcome-guidance.ts +9 -0
- package/src/scheduled-reply-unread-http.test.ts +212 -0
- package/src/scheduled-requirement-wake-http.test.ts +289 -0
- package/src/scheduled-requirement-wake.ts +125 -0
- package/src/scheduled-run-terminal.test.ts +290 -0
- package/src/scheduled-skip-blocking-task.test.ts +120 -0
- package/src/scheduled-skip-path-backoff-2622.test.ts +98 -0
- package/src/scheduled-stuck-http.test.ts +316 -0
- package/src/scheduled-stuck-notice-cap.test.ts +80 -0
- package/src/scheduled-stuck.ts +219 -0
- package/src/scheduled-tasks-http.test.ts +679 -0
- package/src/scheduled-tasks.ts +964 -0
- package/src/scheduled-work-outcome-http.test.ts +154 -0
- package/src/scheduled-work-outcome.ts +50 -0
- package/src/scoped-secrets.ts +167 -0
- package/src/secret-echo-negative-control.test.ts +118 -0
- package/src/send-dedup-request-id.test.ts +229 -0
- package/src/send-reply-agent-warning.test.ts +38 -38
- package/src/send-reply-alias-optional.test.ts +131 -0
- package/src/send-reply-attachments.test.ts +28 -7
- package/src/send_dedup.test.ts +54 -0
- package/src/send_dedup.ts +52 -6
- package/src/serve-error.test.ts +73 -0
- package/src/serve-error.ts +56 -0
- package/src/server.ts +5033 -377
- package/src/session-fork-store.test.ts +43 -0
- package/src/session-fork-store.ts +51 -0
- package/src/session-project-attach-migration.test.ts +22 -0
- package/src/session-project-attach-native.test.ts +121 -0
- package/src/session-project-create-http.test.ts +407 -0
- package/src/session-project-create-native.test.ts +290 -0
- package/src/session-project-create.ts +159 -0
- package/src/session-source-admission-store.ts +58 -0
- package/src/session-source-create.test.ts +155 -0
- package/src/session-source-create.ts +97 -0
- package/src/session-source-delivery.ts +109 -0
- package/src/session-source-directory-http.test.ts +192 -0
- package/src/session-source-evidence.test.ts +898 -0
- package/src/session-source-evidence.ts +191 -0
- package/src/session-source-execution.ts +87 -0
- package/src/session-source-grant.test.ts +117 -0
- package/src/session-source-grant.ts +78 -0
- package/src/session-source-issuer.test.ts +250 -0
- package/src/session-source-issuer.ts +164 -0
- package/src/session-source-transport.ts +375 -0
- package/src/session-task-on-dispatch.ts +14 -0
- package/src/session-token-ownership-http.test.ts +122 -0
- package/src/shared/codex-inventory.ts +41 -0
- package/src/shared/daemon-provider-login.ts +31 -0
- package/src/shared/daemon-provider-snapshot.ts +52 -0
- package/src/shared/external-schedule-contract.ts +60 -0
- package/src/shared/node-name.test.ts +62 -0
- package/src/shared/node-name.ts +161 -0
- package/src/shared/probe-host-allowlist-drift.test.ts +45 -0
- package/src/shared/provider-application.ts +29 -0
- package/src/shared/provider-collection.ts +14 -0
- package/src/shared/provider-initialization.ts +8 -0
- package/src/shared/reserved-env-drift.test.ts +10 -0
- package/src/shared/scoped-secret-contract.ts +5 -0
- package/src/shared/task-content-limit-drift.test.ts +28 -0
- package/src/shared/task-content-limit.ts +25 -0
- package/src/side-thread-command-transport.test.ts +312 -0
- package/src/side-thread-command-transport.ts +318 -0
- package/src/side-thread-http-integration.test.ts +233 -0
- package/src/side-thread-http.ts +504 -0
- package/src/side-thread-production.test.ts +72 -0
- package/src/side-thread-production.ts +118 -0
- package/src/side-thread.test.ts +1067 -0
- package/src/side-thread.ts +2499 -0
- package/src/skillhub-http.test.ts +144 -0
- package/src/sqlite-close-checkpoint.test.ts +78 -0
- package/src/start-node.test.ts +265 -0
- package/src/start-request-error-domain.test.ts +182 -0
- package/src/start-skill-error-domain.test.ts +122 -0
- package/src/stats-versions-http.test.ts +65 -0
- package/src/status-alias-filter-http.test.ts +106 -0
- package/src/status-alias-resolver-http.test.ts +163 -0
- package/src/status-alias-resolver.ts +19 -0
- package/src/status-node-id-filter-http.test.ts +161 -0
- package/src/status-node-secrets-capable-http.test.ts +44 -0
- package/src/status-read-cache-http.test.ts +229 -0
- package/src/status-read-cache.ts +129 -0
- package/src/stop-delete-node.test.ts +567 -1
- package/src/task-access-http.test.ts +407 -0
- package/src/task-access.ts +420 -0
- package/src/task-activity.ts +60 -0
- package/src/task-auth-origin-http.test.ts +93 -0
- package/src/task-auth-origin.test.ts +24 -0
- package/src/task-auth-origin.ts +7 -0
- package/src/task-consumption.test.ts +512 -0
- package/src/task-diagnostic-http.test.ts +149 -0
- package/src/task-diagnostic.test.ts +115 -0
- package/src/task-diagnostic.ts +118 -0
- package/src/task-expiry-notice-http.test.ts +298 -0
- package/src/task-expiry-notice.ts +318 -0
- package/src/task-idempotency-mcp.test.ts +148 -0
- package/src/task-idempotency.test.ts +76 -0
- package/src/task-idempotency.ts +81 -0
- package/src/task-late-replies.ts +54 -0
- package/src/task-late-reply-http.test.ts +227 -0
- package/src/task-lifecycle-watcher-busy.test.ts +114 -0
- package/src/task-lifecycle-watcher.test.ts +209 -0
- package/src/task-lifecycle-watcher.ts +109 -0
- package/src/task-network-resolution-http.test.ts +140 -0
- package/src/task-not-found-error-domain.test.ts +117 -0
- package/src/task-offline-delivery-2668.test.ts +119 -0
- package/src/task-offline-delivery.ts +81 -0
- package/src/task-orphan-http.test.ts +287 -0
- package/src/task-orphan.ts +119 -0
- package/src/task-queue-ahead-http.test.ts +309 -0
- package/src/task-queue-ahead-scale.test.ts +236 -0
- package/src/task-queue-ahead.ts +186 -0
- package/src/task-rejection-log-http.test.ts +160 -0
- package/src/task-rejection-log.ts +61 -0
- package/src/task-sender-http.test.ts +143 -0
- package/src/task-stale-open-http.test.ts +292 -0
- package/src/task-stale-open.ts +103 -0
- package/src/tasks-pagination-http.test.ts +141 -0
- package/src/team-rules-status-http.test.ts +90 -0
- package/src/team-rules-status.test.ts +59 -0
- package/src/team-rules-status.ts +72 -0
- package/src/tmux-allowlist.test.ts +48 -0
- package/src/token-usage-http.test.ts +156 -0
- package/src/tool-audience-http.test.ts +266 -0
- package/src/tool-audience.ts +130 -0
- package/src/tools-list-json-schema.test.ts +94 -0
- package/src/tools.ts +4530 -471
- package/src/update-node-config-error-domain.test.ts +107 -0
- package/src/uploads-http.test.ts +6 -4
- package/src/uploads.ts +23 -4
- package/src/user-avatar-http.test.ts +74 -0
- package/src/user-avatar-image.ts +160 -0
- package/src/user-avatar-migration.test.ts +25 -0
- package/src/user-avatar-upload-http.test.ts +353 -0
- package/src/user-inbox-by-agent-http.test.ts +189 -0
- package/src/user-inbox-netid-notnull.test.ts +122 -0
- package/src/user-inbox-read-http.test.ts +223 -0
- package/src/user-inbox-schema.test.ts +54 -0
- package/src/version-stats.test.ts +66 -0
- package/src/version-stats.ts +109 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// get_all_status response cache (perf).
|
|
2
|
+
//
|
|
3
|
+
// Production 2026-11-09: ~20 LLM agents each called get_all_status about once a
|
|
4
|
+
// minute (465 calls / 22 min). Every call re-read all ~400 sessions and built a
|
|
5
|
+
// ~580 KB JSON string (then wrapped/escaped again by MCP) — several MB of
|
|
6
|
+
// short-lived garbage per call. The Hub's event loop stalled 2–9 s every few
|
|
7
|
+
// seconds (663 stalls in ~2 h) and phone sends sat at 「发送中」.
|
|
8
|
+
//
|
|
9
|
+
// Identical requests within TTL_MS reuse one serialized response. The key is the
|
|
10
|
+
// caller's full read scope (which already encodes network + per-member
|
|
11
|
+
// restrictions) plus every filter, so two callers share an entry only when the
|
|
12
|
+
// SQL they would run is identical. Status that is ≤10 s stale is fine for a roster.
|
|
13
|
+
export const ALL_STATUS_TTL_MS = 10_000;
|
|
14
|
+
const MAX_ENTRIES = 256;
|
|
15
|
+
const cache = new Map<string, { at: number; text: string }>();
|
|
16
|
+
|
|
17
|
+
export function allStatusCacheKey(scope: unknown, filters: unknown): string {
|
|
18
|
+
return JSON.stringify([scope, filters]);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Return the cached text for `key`, or build, store and return it. */
|
|
22
|
+
export function cachedAllStatus(key: string | null, build: () => string, now: () => number = Date.now): { text: string; hit: boolean } {
|
|
23
|
+
if (key === null) return { text: build(), hit: false }; // uncacheable scope
|
|
24
|
+
const t = now();
|
|
25
|
+
const hit = cache.get(key);
|
|
26
|
+
if (hit && t - hit.at < ALL_STATUS_TTL_MS) return { text: hit.text, hit: true };
|
|
27
|
+
const text = build();
|
|
28
|
+
if (cache.size >= MAX_ENTRIES) {
|
|
29
|
+
for (const [k, v] of cache) if (t - v.at >= ALL_STATUS_TTL_MS) cache.delete(k);
|
|
30
|
+
if (cache.size >= MAX_ENTRIES) cache.delete(cache.keys().next().value!);
|
|
31
|
+
}
|
|
32
|
+
cache.set(key, { at: t, text });
|
|
33
|
+
return { text, hit: false };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Tests only. */
|
|
37
|
+
export function clearAllStatusCache(): void { cache.clear(); }
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// Isolated real Hub + real agent-node CLI startup probe, no direct handler calls.
|
|
2
|
+
import { expect, test } from "bun:test";
|
|
3
|
+
import { spawn } from "node:child_process";
|
|
4
|
+
import { mkdtempSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { register, createNetworkTokenForNode } from "./auth.js";
|
|
8
|
+
import { db } from "./db.js";
|
|
9
|
+
|
|
10
|
+
test("real daemon reaches owned TEST-ONLY runtime readiness", async () => {
|
|
11
|
+
const root = mkdtempSync(join(tmpdir(), "anet-4099-daemon-"));
|
|
12
|
+
const stamp = Date.now(), alias = `variant-daemon-${stamp}`, nodeId = `node_variant_${stamp}`;
|
|
13
|
+
const user = register(`variant_owner_${stamp}`, "Fixture4099Only!x");
|
|
14
|
+
const network = user.network_id!;
|
|
15
|
+
const minted = createNetworkTokenForNode(user.user!.user_id, network, alias, nodeId);
|
|
16
|
+
expect(minted.ok).toBe(true);
|
|
17
|
+
const hubModule: any = await import("./server.js");
|
|
18
|
+
const hub = hubModule.bootServer({ port: 0, hostname: "127.0.0.1" });
|
|
19
|
+
const url = `http://127.0.0.1:${hub.port}`;
|
|
20
|
+
let holdAck = false, ackWaiting = false;
|
|
21
|
+
const pullWire: string[] = [];
|
|
22
|
+
let releaseAck!: () => void, sawAck!: () => void, sawHeartbeat!: () => void;
|
|
23
|
+
const ackHeld = new Promise<void>(r => { sawAck = r; });
|
|
24
|
+
const ackGate = new Promise<void>(r => { releaseAck = r; });
|
|
25
|
+
const heartbeatAfterAck = new Promise<void>(r => { sawHeartbeat = r; });
|
|
26
|
+
const proxy = Bun.serve({ hostname: "127.0.0.1", port: 0, async fetch(req) {
|
|
27
|
+
const body = req.method === "GET" || req.method === "HEAD" ? undefined : await req.arrayBuffer();
|
|
28
|
+
let name = "";
|
|
29
|
+
if (body) { try { name = JSON.parse(new TextDecoder().decode(body))?.params?.name ?? ""; } catch {} }
|
|
30
|
+
if (holdAck && name === "ack_config_update") { ackWaiting = true; sawAck(); await ackGate; }
|
|
31
|
+
const target = new URL(req.url); target.host = `127.0.0.1:${hub.port}`;
|
|
32
|
+
const response = await fetch(target, { method: req.method, headers: req.headers, body, signal: req.signal });
|
|
33
|
+
if (name === "get_config_update") pullWire.push(await response.clone().text());
|
|
34
|
+
if (ackWaiting && name === "report_status") sawHeartbeat();
|
|
35
|
+
return response;
|
|
36
|
+
} });
|
|
37
|
+
const daemonUrl = `http://127.0.0.1:${proxy.port}`;
|
|
38
|
+
const configPath = join(root, "config.json");
|
|
39
|
+
writeFileSync(configPath, JSON.stringify({ alias, node_id: nodeId, network_id: network, hub: daemonUrl,
|
|
40
|
+
runtime: "opencode-cli", opencodeGeneration: "v2", opencodeMode: "copresence", model: "fixture/model", flags: { opencodeUnsafeTools: true } }), { mode: 0o600 });
|
|
41
|
+
let providerSignal!: () => void;
|
|
42
|
+
const providerReached = new Promise<void>(resolve => { providerSignal = resolve; });
|
|
43
|
+
const provider = Bun.serve({ hostname: "127.0.0.1", port: 0, fetch() {
|
|
44
|
+
providerSignal();
|
|
45
|
+
return new Response(new ReadableStream({ start(c) { c.enqueue(new TextEncoder().encode(": held\n\n")); } }), { headers: { "content-type": "text/event-stream" } });
|
|
46
|
+
} });
|
|
47
|
+
const config = { providers: { fixture: { name: "fixture", package: "@opencode/ai/providers/openai-compatible",
|
|
48
|
+
settings: { baseURL: `http://127.0.0.1:${provider.port}/v1`, apiKey: "synthetic" },
|
|
49
|
+
models: { model: { name: "model", limit: { context: 128000, output: 16000 }, variants: [{ id: "high" }, { id: "low" }] } },
|
|
50
|
+
} } };
|
|
51
|
+
mkdirSync(join(root, ".config", "opencode"), { recursive: true, mode: 0o700 });
|
|
52
|
+
writeFileSync(join(root, ".config", "opencode", "opencode.json"), JSON.stringify(config), { mode: 0o600 });
|
|
53
|
+
const daemon = spawn("/tool/bun", ["/out/cli.js", "--config", configPath], { cwd: root, env: {
|
|
54
|
+
PATH: process.env.PATH, HOME: root, TMPDIR: root, XDG_CACHE_HOME: join(root, "cache"), XDG_DATA_HOME: join(root, "data"),
|
|
55
|
+
XDG_CONFIG_HOME: join(root, "config"), XDG_STATE_HOME: join(root, "state"), COMMHUB_TOKEN: minted.token!,
|
|
56
|
+
ANET_OPENCODE_BIN: "/tmp/opencode/anet-4099-test-only-29040e2/cli/cli-linux-x64/bin/opencode", ANET_OPENCODE_SAFE_BASE: "/safe", ANET_VARIANT_TEST_ONLY: "1", ANET_STATUS_HEARTBEAT_MS: "3000", ANET_STATUS_HEARTBEAT_JITTER_MS: "0",
|
|
57
|
+
}, stdio: ["ignore", "pipe", "pipe"] });
|
|
58
|
+
let output = "";
|
|
59
|
+
let nativePid: number | undefined;
|
|
60
|
+
try {
|
|
61
|
+
const outcome = await new Promise<string>(resolve => {
|
|
62
|
+
const timeout = setTimeout(() => resolve("timeout"), 20000);
|
|
63
|
+
const onOutput = (chunk: Buffer) => {
|
|
64
|
+
output += chunk.toString();
|
|
65
|
+
if (/SSE connected/.test(output)) { clearTimeout(timeout); resolve("ready"); }
|
|
66
|
+
};
|
|
67
|
+
daemon.stdout.on("data", onOutput); daemon.stderr.on("data", onOutput);
|
|
68
|
+
daemon.once("exit", (code, signal) => { clearTimeout(timeout); resolve(`exit ${code} ${signal ?? ""}`); });
|
|
69
|
+
});
|
|
70
|
+
console.log("daemon pid", daemon.pid, "startup", outcome, "log", output.replace(/(?:ntok|utok)_[A-Za-z0-9_-]+/g, "[synthetic-token]"));
|
|
71
|
+
expect(outcome).toBe("ready");
|
|
72
|
+
const rpc = async (name: string, args: any) => {
|
|
73
|
+
const response = await fetch(`${url}/mcp`, { method: "POST", headers: { authorization: `Bearer ${user.token}`, "content-type": "application/json", accept: "application/json, text/event-stream" }, body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/call", params: { name, arguments: args } }) });
|
|
74
|
+
const raw = await response.text(), line = raw.split("\n").find(x => x.startsWith("data: "));
|
|
75
|
+
const envelope = JSON.parse(line ? line.slice(6) : raw);
|
|
76
|
+
return JSON.parse(envelope.result.content[0].text);
|
|
77
|
+
};
|
|
78
|
+
const getConfig = async () => (await fetch(`${url}/api/nodes/${nodeId}/config?network_id=${network}`, { headers: { authorization: `Bearer ${user.token}` } })).json() as Promise<any>;
|
|
79
|
+
const until = async (label: string, check: () => Promise<any>) => {
|
|
80
|
+
const deadline = Date.now() + 18000;
|
|
81
|
+
while (Date.now() < deadline) { const value = await check(); if (value) return value; await new Promise(r => setTimeout(r, 250)); }
|
|
82
|
+
throw Error(`timed out waiting for ${label}`);
|
|
83
|
+
};
|
|
84
|
+
const ready = await until("daemon fresh catalog capability", async () => { const cfg = await getConfig(); return cfg.opencode_variant_config_capable === true && cfg; });
|
|
85
|
+
console.log("daemon capability/readback", JSON.stringify(ready));
|
|
86
|
+
const { readOpenCodeV2CatalogEndpoint } = await import("../../agent-node/src/runtime/opencode-v2-catalog-endpoint.js");
|
|
87
|
+
const endpoint = readOpenCodeV2CatalogEndpoint(root)!;
|
|
88
|
+
expect(endpoint).toBeTruthy();
|
|
89
|
+
const native = async (path: string, method = "GET", body?: unknown) => fetch(`${endpoint.url}${path}`, { method, headers: { authorization: endpoint.authorization, "x-opencode-directory": endpoint.directory, "content-type": "application/json" }, ...(body ? { body: JSON.stringify(body) } : {}) });
|
|
90
|
+
const info = await (await native("/api/info")).json() as any;
|
|
91
|
+
nativePid = info.pid;
|
|
92
|
+
const launch = await Bun.file(join(root, "opencode-attach.sh")).text();
|
|
93
|
+
const sessionId = /--session '([^']+)'/.exec(launch)?.[1];
|
|
94
|
+
expect(sessionId).toBeTruthy();
|
|
95
|
+
console.log("runtime identity", JSON.stringify({ daemonPid: daemon.pid, nativePid: info.pid, version: info.version, sessionId }));
|
|
96
|
+
expect(info.version).toBe("2.0.22-anet-test.29040e2");
|
|
97
|
+
holdAck = true;
|
|
98
|
+
const queued = await rpc("update_node_config", { node_id: nodeId, base_revision: ready.config_revision, patch: { modelVariant: "high" } });
|
|
99
|
+
expect(queued.ok).toBe(true);
|
|
100
|
+
await Promise.race([ackHeld, new Promise<never>((_, reject) => setTimeout(() => reject(Error("daemon ack not intercepted")), 18000))]);
|
|
101
|
+
await Promise.race([heartbeatAfterAck, new Promise<never>((_, reject) => setTimeout(() => reject(Error("heartbeat did not follow held ack")), 18000))]);
|
|
102
|
+
const heartbeatPending = await getConfig();
|
|
103
|
+
expect(heartbeatPending.last_update).toMatchObject({ update_id: queued.update_id, status: "pending" });
|
|
104
|
+
expect(heartbeatPending.modelVariant).toBe("high");
|
|
105
|
+
expect((await (await native(`/api/session/${sessionId}`)).json() as any).data.model.variant).toBe("high");
|
|
106
|
+
console.log("real heartbeat while ack held", JSON.stringify({ update: queued.update_id, status: "pending", actualVariant: "high" }));
|
|
107
|
+
holdAck = false; releaseAck();
|
|
108
|
+
const done = await until("real daemon high ack", async () => { const cfg = await getConfig();
|
|
109
|
+
if (cfg.last_update?.update_id === queued.update_id && ["rejected", "timeout"].includes(cfg.last_update.status)) throw Error(`high terminal ${JSON.stringify(cfg.last_update)}`);
|
|
110
|
+
return cfg.last_update?.update_id === queued.update_id && cfg.last_update?.status === "applied" && cfg.modelVariant === "high" && cfg; });
|
|
111
|
+
const actual = await (await native(`/api/session/${sessionId}`)).json() as any;
|
|
112
|
+
expect(actual.data.model).toMatchObject({ providerID: "fixture", id: "model", variant: "high" });
|
|
113
|
+
console.log("real SSE high applied", JSON.stringify({ update: queued.update_id, config: done, model: actual.data.model }));
|
|
114
|
+
expect(output).toContain("SSE config_update");
|
|
115
|
+
const waitTerminal = async (id: string) => until(`update ${id}`, async () => { const cfg = await getConfig(); return cfg.last_update?.update_id === id && cfg.last_update.terminal && cfg; });
|
|
116
|
+
const omitted = await rpc("update_node_config", { node_id: nodeId, base_revision: done.config_revision, patch: { model: "fixture/model" } });
|
|
117
|
+
expect(omitted.ok).toBe(true);
|
|
118
|
+
const preserved = await waitTerminal(omitted.update_id);
|
|
119
|
+
expect(preserved.last_update.status).toBe("applied");
|
|
120
|
+
const storedPatch = JSON.parse(db.get<any>("SELECT patch_json FROM node_config_updates WHERE update_id = ?1", omitted.update_id).patch_json);
|
|
121
|
+
expect(storedPatch._anet_variant_ack_required).toBe(true);
|
|
122
|
+
const omittedWire = pullWire.find(w => w.includes(omitted.update_id));
|
|
123
|
+
expect(omittedWire).toBeDefined();
|
|
124
|
+
expect(omittedWire).not.toContain("_anet_variant_ack_required");
|
|
125
|
+
expect((await (await native(`/api/session/${sessionId}`)).json() as any).data.model.variant).toBe("high");
|
|
126
|
+
const invalid = await rpc("update_node_config", { node_id: nodeId, base_revision: preserved.config_revision, patch: { modelVariant: "nonexistent" } });
|
|
127
|
+
expect(invalid.ok).toBe(true);
|
|
128
|
+
const invalidResult = await waitTerminal(invalid.update_id);
|
|
129
|
+
expect(invalidResult.last_update.status).toBe("rejected");
|
|
130
|
+
expect((await (await native(`/api/session/${sessionId}`)).json() as any).data.model.variant).toBe("high");
|
|
131
|
+
let cleared = invalidResult;
|
|
132
|
+
for (let attempt = 0; attempt < 5; attempt++) {
|
|
133
|
+
const clear = await rpc("update_node_config", { node_id: nodeId, base_revision: cleared.config_revision, patch: { modelVariant: null } });
|
|
134
|
+
expect(clear.ok).toBe(true);
|
|
135
|
+
cleared = await waitTerminal(clear.update_id);
|
|
136
|
+
if (cleared.last_update.error !== "variant_concurrent") break;
|
|
137
|
+
await new Promise(r => setTimeout(r, 1000));
|
|
138
|
+
}
|
|
139
|
+
expect(cleared.last_update.status).toBe("applied");
|
|
140
|
+
await until("clear heartbeat readback", async () => { const cfg = await getConfig(); return cfg.modelVariant === null && cfg; });
|
|
141
|
+
const again = await rpc("update_node_config", { node_id: nodeId, base_revision: cleared.config_revision, patch: { modelVariant: "high" } });
|
|
142
|
+
expect(again.ok).toBe(true);
|
|
143
|
+
const restored = await waitTerminal(again.update_id);
|
|
144
|
+
expect(restored.last_update.status).toBe("applied");
|
|
145
|
+
console.log("omitted invalid clear restore", JSON.stringify({ omitted: preserved.last_update, invalid: invalidResult.last_update, clear: cleared.last_update, restore: restored.last_update }));
|
|
146
|
+
const prompt = await native(`/api/session/${sessionId}/prompt`, "POST", { text: "synthetic local test" });
|
|
147
|
+
expect(prompt.status).toBe(200);
|
|
148
|
+
await Promise.race([providerReached, new Promise<never>((_, reject) => setTimeout(() => reject(Error("synthetic provider not reached")), 10000))]);
|
|
149
|
+
const busy = await rpc("update_node_config", { node_id: nodeId, base_revision: restored.config_revision, patch: { modelVariant: "low" } });
|
|
150
|
+
expect(busy.ok).toBe(true);
|
|
151
|
+
const rejected = await until("real daemon busy ack", async () => { const cfg = await getConfig(); return cfg.last_update?.update_id === busy.update_id && cfg.last_update?.status === "rejected" && cfg; });
|
|
152
|
+
const after = await (await native(`/api/session/${sessionId}`)).json() as any;
|
|
153
|
+
expect(after.data.model).toMatchObject({ providerID: "fixture", id: "model", variant: "high" });
|
|
154
|
+
expect((await (await native("/api/info")).json() as any).pid).toBe(info.pid);
|
|
155
|
+
expect(daemon.exitCode).toBeNull();
|
|
156
|
+
console.log("real SSE busy rejected", JSON.stringify({ update: busy.update_id, config: rejected, model: after.data.model, nativePid: info.pid, daemonPid: daemon.pid }));
|
|
157
|
+
} catch (error) {
|
|
158
|
+
try { console.log("diagnostic hub config", JSON.stringify(await (await fetch(`${url}/api/nodes/${nodeId}/config?network_id=${network}`, { headers: { authorization: `Bearer ${user.token}` } })).json())); } catch {}
|
|
159
|
+
const { readOpenCodeV2CatalogEndpoint } = await import("../../agent-node/src/runtime/opencode-v2-catalog-endpoint.js");
|
|
160
|
+
const endpoint = readOpenCodeV2CatalogEndpoint(root);
|
|
161
|
+
if (endpoint) {
|
|
162
|
+
try {
|
|
163
|
+
const r = await fetch(`${endpoint.url}/api/model`, { headers: { authorization: endpoint.authorization, "x-opencode-directory": endpoint.directory } });
|
|
164
|
+
const body = await r.json() as any;
|
|
165
|
+
console.log("diagnostic catalog", JSON.stringify({ status: r.status, location: body.location, fixture: body.data?.filter((m: any) => m.providerID === "fixture").map((m: any) => ({ id: m.id, variants: m.variants?.map((v: any) => v.id) })) }));
|
|
166
|
+
} catch (diagnostic) { console.log("diagnostic catalog failed", String(diagnostic)); }
|
|
167
|
+
}
|
|
168
|
+
console.log("daemon tail", output.slice(-12000).replace(/(?:ntok|utok)_[A-Za-z0-9_-]+/g, "[synthetic-token]"));
|
|
169
|
+
throw error;
|
|
170
|
+
} finally {
|
|
171
|
+
const exited = daemon.exitCode !== null || daemon.signalCode !== null ? Promise.resolve() : new Promise<void>(resolve => daemon.once("exit", () => resolve()));
|
|
172
|
+
daemon.kill("SIGTERM");
|
|
173
|
+
await Promise.race([exited, new Promise<never>((_, reject) => setTimeout(() => reject(Error("owned daemon did not exit")), 10000))]);
|
|
174
|
+
if (nativePid) {
|
|
175
|
+
const pid = nativePid;
|
|
176
|
+
const inactive = () => { try { return readFileSync(`/proc/${pid}/stat`, "utf8").split(") ")[1]?.startsWith("Z ") === true; } catch { return true; } };
|
|
177
|
+
const deadline = Date.now() + 10000;
|
|
178
|
+
while (!inactive() && Date.now() < deadline) await new Promise(r => setTimeout(r, 100));
|
|
179
|
+
expect(inactive()).toBe(true);
|
|
180
|
+
console.log("owned lifecycle end", JSON.stringify({ daemonPid: daemon.pid, nativePid: pid, daemonExitCode: daemon.exitCode, daemonSignal: daemon.signalCode, nativeInactive: inactive() }));
|
|
181
|
+
}
|
|
182
|
+
releaseAck(); proxy.stop(true); provider.stop(true); hub.stop(true);
|
|
183
|
+
}
|
|
184
|
+
}, 120000);
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
// #1353 Fix ② — /api/host-supervisors surfaces daemon's self-reported
|
|
2
|
+
// can_create_nodes + create_nodes_blocked_reason so dashboard's
|
|
3
|
+
// "选服务器" picker can filter or dim broken daemons.
|
|
4
|
+
//
|
|
5
|
+
// Fix ① (PR #1510) added the hub-side dispatch gate — daemon that
|
|
6
|
+
// reports can_create_nodes=false gets refused with the reason. But
|
|
7
|
+
// the dashboard picker still LISTS the daemon and the user finds out
|
|
8
|
+
// only after clicking. This exposes the fact one layer earlier so the
|
|
9
|
+
// picker never surfaces the daemon in the first place.
|
|
10
|
+
//
|
|
11
|
+
// 🔴 Pre-#1371 compat is the same shape as Fix ①: only include the
|
|
12
|
+
// two keys when the daemon actually reported them. Old daemons (that
|
|
13
|
+
// never report) get the same undefined-passthrough dashboard sees a
|
|
14
|
+
// row WITHOUT the keys, not a row with can_create_nodes:false, so
|
|
15
|
+
// the dashboard's own default UI doesn't silently dim every legacy
|
|
16
|
+
// daemon.
|
|
17
|
+
|
|
18
|
+
import { describe, expect, test, beforeAll, afterAll } from "bun:test";
|
|
19
|
+
import "./require-explicit-test-db.js";
|
|
20
|
+
import { register, login } from "./auth.js";
|
|
21
|
+
import { db } from "./db.js";
|
|
22
|
+
|
|
23
|
+
let BASE = "";
|
|
24
|
+
let server: any = null;
|
|
25
|
+
|
|
26
|
+
let userToken = "";
|
|
27
|
+
let userNetworkId = "";
|
|
28
|
+
let userId = "";
|
|
29
|
+
|
|
30
|
+
beforeAll(async () => {
|
|
31
|
+
process.env.HOST = "127.0.0.1";
|
|
32
|
+
const suffix = `${Date.now()}_${Math.floor(Math.random() * 1000)}`;
|
|
33
|
+
const password = "BootstrapPw123Aa!";
|
|
34
|
+
|
|
35
|
+
// Seed admin so subsequent registrations aren't auto-admin (admin
|
|
36
|
+
// path skips resolveRestNetworkScope's default-network fallback —
|
|
37
|
+
// that would change our fixture's role/scope in ways unrelated to
|
|
38
|
+
// this fix).
|
|
39
|
+
const seed = register(`hsc_seed_${suffix}`, password, undefined, "seed");
|
|
40
|
+
if (!seed.ok) throw new Error("seed failed");
|
|
41
|
+
db.run("UPDATE users SET role = 'admin' WHERE username = ?1", [`hsc_seed_${suffix}`]);
|
|
42
|
+
|
|
43
|
+
const u = register(`hsc_u_${suffix}`, password, undefined, "seed");
|
|
44
|
+
if (!u.ok || !u.token) throw new Error("user register failed");
|
|
45
|
+
userToken = u.token;
|
|
46
|
+
userNetworkId = u.network_id ?? "";
|
|
47
|
+
userId = login(`hsc_u_${suffix}`, password).user!.user_id;
|
|
48
|
+
|
|
49
|
+
const { bootServer } = await import("./server.js");
|
|
50
|
+
server = bootServer({ port: 0, hostname: "127.0.0.1" });
|
|
51
|
+
BASE = `http://127.0.0.1:${server.port}`;
|
|
52
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
afterAll(() => {
|
|
56
|
+
try { server?.stop?.(true); } catch {}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
function seedDaemon(alias: string, snapshotOverride: object | null): void {
|
|
60
|
+
const nodeId = `hsc_n_${alias}`;
|
|
61
|
+
const snap = snapshotOverride === null
|
|
62
|
+
? null
|
|
63
|
+
: JSON.stringify(snapshotOverride);
|
|
64
|
+
db.run(
|
|
65
|
+
`INSERT OR REPLACE INTO nodes (
|
|
66
|
+
node_id, node_name, alias, runtime, model, config_path,
|
|
67
|
+
channels, server, hostname, network_id,
|
|
68
|
+
config_revision, config_snapshot
|
|
69
|
+
) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12)`,
|
|
70
|
+
[nodeId, alias, alias, "claude-agent-sdk", "claude-sonnet-4-5",
|
|
71
|
+
"/tmp/cfg.json", "[]", "test-host", "test-host", userNetworkId,
|
|
72
|
+
0, snap],
|
|
73
|
+
);
|
|
74
|
+
db.run(
|
|
75
|
+
`INSERT OR REPLACE INTO api_tokens (
|
|
76
|
+
token_id, token_hash, user_id, network_id, name, scope
|
|
77
|
+
) VALUES (?1, ?2, ?3, ?4, ?5, ?6)`,
|
|
78
|
+
[`hsc_t_${alias}`, `hash_${alias}`, userId, userNetworkId, `node:${alias}`, "network"],
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function clearDaemons(): void {
|
|
83
|
+
db.run("DELETE FROM nodes WHERE network_id = ?1", [userNetworkId]);
|
|
84
|
+
db.run("DELETE FROM api_tokens WHERE network_id = ?1 AND name LIKE 'node:%'", [userNetworkId]);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function listDaemons(): Promise<any[]> {
|
|
88
|
+
const res = await fetch(`${BASE}/api/host-supervisors`, {
|
|
89
|
+
headers: { "Authorization": `Bearer ${userToken}` },
|
|
90
|
+
});
|
|
91
|
+
const body = await res.json();
|
|
92
|
+
if (!body.ok) throw new Error("list failed: " + JSON.stringify(body));
|
|
93
|
+
return body.daemons;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function findDaemon(rows: any[], alias: string): any {
|
|
97
|
+
const d = rows.find(r => r.alias === alias);
|
|
98
|
+
if (!d) throw new Error(`daemon ${alias} not in response`);
|
|
99
|
+
return d;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
describe("#1353 Fix ② — /api/host-supervisors surfaces can_create_nodes + blocked_reason", () => {
|
|
103
|
+
test("🔴 witnessed-red: blocked daemon → response carries can_create_nodes:false + blocked_reason", async () => {
|
|
104
|
+
clearDaemons();
|
|
105
|
+
seedDaemon("blocked-a", {
|
|
106
|
+
role: "host_supervisor",
|
|
107
|
+
daemon_capabilities: {
|
|
108
|
+
runtimes_supported: ["claude-agent-sdk"],
|
|
109
|
+
can_create_nodes: false,
|
|
110
|
+
create_nodes_blocked_reason: "anet_bin_permission",
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
const d = findDaemon(await listDaemons(), "blocked-a");
|
|
114
|
+
expect(d.can_create_nodes).toBe(false);
|
|
115
|
+
expect(d.create_nodes_blocked_reason).toBe("anet_bin_permission");
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test("healthy daemon (can_create_nodes:true) → can_create_nodes:true, NO blocked_reason", async () => {
|
|
119
|
+
clearDaemons();
|
|
120
|
+
seedDaemon("healthy-a", {
|
|
121
|
+
role: "host_supervisor",
|
|
122
|
+
daemon_capabilities: {
|
|
123
|
+
runtimes_supported: ["claude-agent-sdk"],
|
|
124
|
+
can_create_nodes: true,
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
const d = findDaemon(await listDaemons(), "healthy-a");
|
|
128
|
+
expect(d.can_create_nodes).toBe(true);
|
|
129
|
+
// 🔴 defensive: dashboard's picker likely renders blocked_reason
|
|
130
|
+
// when present regardless of can_create_nodes value. Don't
|
|
131
|
+
// confuse it by shipping a stale reason on a healthy daemon.
|
|
132
|
+
expect(d.create_nodes_blocked_reason).toBeUndefined();
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test("healthy daemon that ALSO reports stale blocked_reason → reason NOT emitted (defensive)", async () => {
|
|
136
|
+
// Belt-and-braces: even if a future daemon shape bug leaves a
|
|
137
|
+
// stale reason string in the snapshot after recovering, the REST
|
|
138
|
+
// response should not surface it when the daemon is currently OK.
|
|
139
|
+
clearDaemons();
|
|
140
|
+
seedDaemon("healthy-b", {
|
|
141
|
+
role: "host_supervisor",
|
|
142
|
+
daemon_capabilities: {
|
|
143
|
+
runtimes_supported: ["claude-agent-sdk"],
|
|
144
|
+
can_create_nodes: true,
|
|
145
|
+
create_nodes_blocked_reason: "anet_bin_permission", // stale
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
const d = findDaemon(await listDaemons(), "healthy-b");
|
|
149
|
+
expect(d.can_create_nodes).toBe(true);
|
|
150
|
+
expect(d.create_nodes_blocked_reason).toBeUndefined();
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test("🔴 pre-#1371 compat: daemon that never reports can_create_nodes → BOTH keys absent from response", async () => {
|
|
154
|
+
// Same "known-blocked, NOT unknown-treated-as-blocked" rule as
|
|
155
|
+
// Fix ①. A pre-#1371 daemon (preview.10 through ~preview.55) never
|
|
156
|
+
// reports these fields. The response for it must not fabricate a
|
|
157
|
+
// false value — the dashboard could reasonably render an
|
|
158
|
+
// explicit `false` as "dim / hide" which would silently start
|
|
159
|
+
// hiding every daemon that hasn't upgraded.
|
|
160
|
+
clearDaemons();
|
|
161
|
+
seedDaemon("legacy-a", {
|
|
162
|
+
role: "host_supervisor",
|
|
163
|
+
daemon_capabilities: {
|
|
164
|
+
runtimes_supported: ["claude-agent-sdk"],
|
|
165
|
+
// no can_create_nodes / create_nodes_blocked_reason
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
const d = findDaemon(await listDaemons(), "legacy-a");
|
|
169
|
+
expect("can_create_nodes" in d).toBe(false);
|
|
170
|
+
expect("create_nodes_blocked_reason" in d).toBe(false);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test("pre-#1371 compat: daemon with no daemon_capabilities at all → BOTH keys absent", async () => {
|
|
174
|
+
clearDaemons();
|
|
175
|
+
seedDaemon("legacy-b", { role: "host_supervisor" });
|
|
176
|
+
const d = findDaemon(await listDaemons(), "legacy-b");
|
|
177
|
+
expect("can_create_nodes" in d).toBe(false);
|
|
178
|
+
expect("create_nodes_blocked_reason" in d).toBe(false);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
test("pre-#1371 compat: NULL config_snapshot (very old daemon) → BOTH keys absent, daemon does NOT crash the listing", async () => {
|
|
182
|
+
// A daemon that never called report_status leaves config_snapshot NULL.
|
|
183
|
+
// /api/host-supervisors filters by role from the snapshot, so a NULL
|
|
184
|
+
// snapshot drops from the list entirely — but if it did surface (via
|
|
185
|
+
// any future path), it must not crash the reducer.
|
|
186
|
+
clearDaemons();
|
|
187
|
+
seedDaemon("legacy-c", { role: "host_supervisor" }); // seed with something to be listable
|
|
188
|
+
const rows = await listDaemons();
|
|
189
|
+
// Just prove the list doesn't throw and the daemon is present with
|
|
190
|
+
// no capability keys.
|
|
191
|
+
const d = findDaemon(rows, "legacy-c");
|
|
192
|
+
expect("can_create_nodes" in d).toBe(false);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
test("all 4 categorized reason codes round-trip through the REST response", async () => {
|
|
196
|
+
const codes = ["anet_bin_identity", "anet_bin_source", "anet_bin_shape", "anet_bin_permission"];
|
|
197
|
+
for (const code of codes) {
|
|
198
|
+
clearDaemons();
|
|
199
|
+
seedDaemon(`blocked-${code}`, {
|
|
200
|
+
role: "host_supervisor",
|
|
201
|
+
daemon_capabilities: {
|
|
202
|
+
runtimes_supported: ["claude-agent-sdk"],
|
|
203
|
+
can_create_nodes: false,
|
|
204
|
+
create_nodes_blocked_reason: code,
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
const d = findDaemon(await listDaemons(), `blocked-${code}`);
|
|
208
|
+
expect(d.can_create_nodes).toBe(false);
|
|
209
|
+
expect(d.create_nodes_blocked_reason).toBe(code);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
test(".40-shape 'anet_bin_pin_unresolved' pre-#1377 code also passes through the REST response", async () => {
|
|
214
|
+
// The Zod enum still accepts this coarse pre-#1377 code (agent-node
|
|
215
|
+
// @2.5.0-preview.40 daemons in the wild emit it), and Fix ① surfaces
|
|
216
|
+
// it verbatim to callers; the REST surface must too, otherwise
|
|
217
|
+
// dashboard sees the daemon as "blocked with no reason".
|
|
218
|
+
clearDaemons();
|
|
219
|
+
seedDaemon("blocked-40shape", {
|
|
220
|
+
role: "host_supervisor",
|
|
221
|
+
daemon_capabilities: {
|
|
222
|
+
runtimes_supported: ["claude-agent-sdk"],
|
|
223
|
+
can_create_nodes: false,
|
|
224
|
+
create_nodes_blocked_reason: "anet_bin_pin_unresolved",
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
const d = findDaemon(await listDaemons(), "blocked-40shape");
|
|
228
|
+
expect(d.create_nodes_blocked_reason).toBe("anet_bin_pin_unresolved");
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
test("malformed config_snapshot: existing behavior (daemon drops from list due to role-filter) unchanged", async () => {
|
|
232
|
+
// The parse is wrapped in try/catch (existing behavior). A malformed
|
|
233
|
+
// snapshot means snapRole stays null → filter drops it. This just
|
|
234
|
+
// pins that our added parsing doesn't turn a malformed snapshot
|
|
235
|
+
// into a crash.
|
|
236
|
+
clearDaemons();
|
|
237
|
+
// Seed a legit daemon so the list has SOMETHING to prove no crash.
|
|
238
|
+
seedDaemon("healthy-c", {
|
|
239
|
+
role: "host_supervisor",
|
|
240
|
+
daemon_capabilities: { runtimes_supported: [] },
|
|
241
|
+
});
|
|
242
|
+
// Seed the malformed one — should be filtered out silently.
|
|
243
|
+
const nodeId = "hsc_n_malformed";
|
|
244
|
+
db.run(
|
|
245
|
+
`INSERT OR REPLACE INTO nodes (
|
|
246
|
+
node_id, node_name, alias, runtime, model, config_path,
|
|
247
|
+
channels, server, hostname, network_id,
|
|
248
|
+
config_revision, config_snapshot
|
|
249
|
+
) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12)`,
|
|
250
|
+
[nodeId, "malformed", "malformed", "claude-agent-sdk", "claude-sonnet-4-5",
|
|
251
|
+
"/tmp/cfg.json", "[]", "test-host", "test-host", userNetworkId,
|
|
252
|
+
0, "{not json"],
|
|
253
|
+
);
|
|
254
|
+
db.run(
|
|
255
|
+
`INSERT OR REPLACE INTO api_tokens (
|
|
256
|
+
token_id, token_hash, user_id, network_id, name, scope
|
|
257
|
+
) VALUES (?1, ?2, ?3, ?4, ?5, ?6)`,
|
|
258
|
+
["hsc_t_malformed", "hash_malformed", userId, userNetworkId, "node:malformed", "network"],
|
|
259
|
+
);
|
|
260
|
+
const rows = await listDaemons();
|
|
261
|
+
// healthy-c is present; malformed is filtered out because
|
|
262
|
+
// snapRole stayed null.
|
|
263
|
+
expect(rows.find((r: any) => r.alias === "healthy-c")).toBeDefined();
|
|
264
|
+
expect(rows.find((r: any) => r.alias === "malformed")).toBeUndefined();
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
/* #1545 —— `can_create_nodes` 说的是「能不能」,这一组说的是「**那是什么时候测的**」。
|
|
269
|
+
*
|
|
270
|
+
* 为什么非要分开:agent-node ≤ 2.5.0-preview.54 用一个进程级缓存只算一次
|
|
271
|
+
* (`cli.ts` 的 `_createCapCache`)。开机时二进制好、之后被 chmod 掉 ⇒ 它会
|
|
272
|
+
* **永远上报 ready**。hub 这边,那条记录和一个 3 秒前刚测出来的 ready
|
|
273
|
+
* 在 `last_seen_at` 上一模一样 —— 心跳是新的,那一格不是。
|
|
274
|
+
*
|
|
275
|
+
* 🔴 缺席**不得**当成 0。把「没报」渲染成「刚测的」,正好朝「没问题」方向说谎,
|
|
276
|
+
* 而这正是 #1545 里比沉默更糟的那一半。
|
|
277
|
+
*/
|
|
278
|
+
describe("#1545 /api/host-supervisors —— can_create_nodes 的年龄", () => {
|
|
279
|
+
test("daemon 报了年龄 → 原样带出", async () => {
|
|
280
|
+
clearDaemons();
|
|
281
|
+
seedDaemon("age-fresh", {
|
|
282
|
+
role: "host_supervisor",
|
|
283
|
+
daemon_capabilities: {
|
|
284
|
+
can_create_nodes: false,
|
|
285
|
+
create_nodes_blocked_reason: "anet_bin_source",
|
|
286
|
+
create_capability_observed_ms_ago: 12,
|
|
287
|
+
},
|
|
288
|
+
});
|
|
289
|
+
const d = findDaemon(await listDaemons(), "age-fresh");
|
|
290
|
+
expect(d.create_capability_observed_ms_ago).toBe(12);
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
test("🔴 daemon 没报年龄 → 这一格必须**缺席**,不能是 0/null", async () => {
|
|
294
|
+
clearDaemons();
|
|
295
|
+
seedDaemon("age-absent", {
|
|
296
|
+
role: "host_supervisor",
|
|
297
|
+
daemon_capabilities: { can_create_nodes: true },
|
|
298
|
+
});
|
|
299
|
+
const d = findDaemon(await listDaemons(), "age-absent");
|
|
300
|
+
// 能力本身照常带出 —— 加年龄这一格不许把旧 daemon 的既有信息弄丢。
|
|
301
|
+
expect(d.can_create_nodes).toBe(true);
|
|
302
|
+
expect("create_capability_observed_ms_ago" in d).toBe(false);
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
/* 🔴 消毒**不是 clamp**:clamp 会把一个坏值变成一个看起来正常的年龄,
|
|
306
|
+
* 而这一格存在的全部意义就是让人分辨新鲜和陈旧。坏值一律当作「没报」。 */
|
|
307
|
+
test.each([
|
|
308
|
+
["负数", -1],
|
|
309
|
+
["超过一年", 400 * 24 * 60 * 60 * 1000],
|
|
310
|
+
["null(schema 的 .catch 兜底值)", null],
|
|
311
|
+
["字符串(直接写库,绕过 schema)", "12"],
|
|
312
|
+
])("坏值当作没报,而不是 clamp 成边界:%s", async (label, value) => {
|
|
313
|
+
clearDaemons();
|
|
314
|
+
const alias = `age-bad-${String(label).slice(0, 4)}`;
|
|
315
|
+
seedDaemon(alias, {
|
|
316
|
+
role: "host_supervisor",
|
|
317
|
+
daemon_capabilities: {
|
|
318
|
+
can_create_nodes: true,
|
|
319
|
+
create_capability_observed_ms_ago: value,
|
|
320
|
+
},
|
|
321
|
+
});
|
|
322
|
+
const d = findDaemon(await listDaemons(), alias);
|
|
323
|
+
expect(d.can_create_nodes).toBe(true); // 能力仍在
|
|
324
|
+
expect("create_capability_observed_ms_ago" in d).toBe(false); // 年龄不在
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
/* 边界校准:上面用 400 天证明「太旧被丢」,这里用**刚好一年**证明门不是恒丢。
|
|
328
|
+
* 只验被丢那一侧的话,一个恒丢的实现能全绿通过。 */
|
|
329
|
+
test("边界:恰好一年被接受 ⇒ 上面那条不是因为恒丢才绿", async () => {
|
|
330
|
+
clearDaemons();
|
|
331
|
+
const oneYear = 365 * 24 * 60 * 60 * 1000;
|
|
332
|
+
seedDaemon("age-boundary", {
|
|
333
|
+
role: "host_supervisor",
|
|
334
|
+
daemon_capabilities: { can_create_nodes: true, create_capability_observed_ms_ago: oneYear },
|
|
335
|
+
});
|
|
336
|
+
const d = findDaemon(await listDaemons(), "age-boundary");
|
|
337
|
+
expect(d.create_capability_observed_ms_ago).toBe(oneYear);
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
test("年龄只在 can_create_nodes 存在时出现(旧 daemon 两格都没有)", async () => {
|
|
341
|
+
clearDaemons();
|
|
342
|
+
seedDaemon("age-legacy", {
|
|
343
|
+
role: "host_supervisor",
|
|
344
|
+
daemon_capabilities: { runtimes_supported: ["claude-agent-sdk"] },
|
|
345
|
+
});
|
|
346
|
+
const d = findDaemon(await listDaemons(), "age-legacy");
|
|
347
|
+
expect("can_create_nodes" in d).toBe(false);
|
|
348
|
+
expect("create_capability_observed_ms_ago" in d).toBe(false);
|
|
349
|
+
});
|
|
350
|
+
});
|
|
@@ -20,13 +20,10 @@
|
|
|
20
20
|
// server on an ephemeral port with a temp DB, hit it with fetch().
|
|
21
21
|
|
|
22
22
|
import { describe, expect, test, beforeAll, afterAll } from "bun:test";
|
|
23
|
-
import
|
|
24
|
-
import { join } from "path";
|
|
25
|
-
import { tmpdir } from "os";
|
|
23
|
+
import "./require-explicit-test-db.js";
|
|
26
24
|
import { register, login, createNetwork } from "./auth.js";
|
|
27
25
|
import { db } from "./db.js";
|
|
28
26
|
|
|
29
|
-
const SERVER_DB = mkdtempSync(join(tmpdir(), "anet-hs-fallback-db-")) + "/commhub.db";
|
|
30
27
|
// #438 corrective: private bootServer({ port: 0 }) instance (see
|
|
31
28
|
// uploads-http.test.ts for rationale).
|
|
32
29
|
let BASE = "";
|
|
@@ -41,8 +38,11 @@ let soloNetworkId = "";
|
|
|
41
38
|
let multiNetworkA = "", multiNetworkB = "";
|
|
42
39
|
let soloDaemonAlias = "";
|
|
43
40
|
|
|
41
|
+
// 30s 而不是 bun 默认的 5s:这个 hook 跑 register()(KDF)+bootServer(),
|
|
42
|
+
// 本机空载基线 ~620ms,而 2026-08-17 与 2026-08-31 两次 CI 上它被 5s 上限打死
|
|
43
|
+
// (0 pass / 1 fail / Ran 1 test —— 见 #928、#1627)。5247ms 是**被截断的下界**,
|
|
44
|
+
// 不是测量值,所以余量按基线的 ~48x 取,而不是按那个数取。
|
|
44
45
|
beforeAll(async () => {
|
|
45
|
-
process.env.COMMHUB_DB = SERVER_DB;
|
|
46
46
|
process.env.HOST = "127.0.0.1";
|
|
47
47
|
|
|
48
48
|
const suffix = `${Date.now()}_${Math.floor(Math.random() * 1000)}`;
|
|
@@ -120,7 +120,7 @@ beforeAll(async () => {
|
|
|
120
120
|
server = bootServer({ port: 0, hostname: "127.0.0.1" });
|
|
121
121
|
BASE = `http://127.0.0.1:${server.port}`;
|
|
122
122
|
await new Promise((r) => setTimeout(r, 100));
|
|
123
|
-
});
|
|
123
|
+
}, 30_000);
|
|
124
124
|
|
|
125
125
|
// Insert a minimal `nodes` row + `api_tokens` row so the daemon shows up
|
|
126
126
|
// in /api/host-supervisors' JOIN-then-role-filter query (index.ts
|
|
@@ -155,7 +155,6 @@ function seedHostSupervisorDaemon(opts: {
|
|
|
155
155
|
|
|
156
156
|
afterAll(() => {
|
|
157
157
|
try { server?.stop?.(true); } catch {}
|
|
158
|
-
try { rmSync(SERVER_DB, { recursive: true, force: true }); } catch {}
|
|
159
158
|
});
|
|
160
159
|
|
|
161
160
|
async function get(path: string, token: string): Promise<{ status: number; body: any }> {
|