@blackbelt-technology/pi-agent-dashboard 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +2 -2
- package/README.md +47 -6
- package/docs/architecture.md +1369 -63
- package/package.json +14 -9
- package/packages/extension/package.json +5 -3
- package/packages/extension/src/bridge-handlers/dispatch.ts +57 -3
- package/packages/extension/src/bridge-handlers/instance.ts +10 -1
- package/packages/extension/src/bridge-handlers/lifecycle.ts +65 -26
- package/packages/extension/src/bridge-ticket-client.ts +61 -7
- package/packages/extension/src/bridge-tls-checks.ts +79 -0
- package/packages/extension/src/bridge.ts +41 -28
- package/packages/extension/src/canvas-tool.ts +2 -0
- package/packages/extension/src/command-handler.ts +80 -6
- package/packages/extension/src/connect-target.ts +23 -0
- package/packages/extension/src/connection.ts +30 -7
- package/packages/extension/src/dashboard-http-origin.ts +88 -0
- package/packages/extension/src/dev-build.ts +11 -1
- package/packages/extension/src/git-link-builder.ts +11 -2
- package/packages/extension/src/inbound-limits.ts +138 -0
- package/packages/extension/src/local-token-header.ts +77 -6
- package/packages/extension/src/model-refresh.ts +69 -0
- package/packages/extension/src/pinned-endpoint.ts +44 -0
- package/packages/extension/src/project-trust-live.ts +143 -0
- package/packages/extension/src/project-trust.ts +159 -20
- package/packages/extension/src/provider-register.ts +59 -18
- package/packages/extension/src/remote-registration-gate.ts +21 -21
- package/packages/extension/src/remote-upgrade-preparer.ts +104 -0
- package/packages/extension/src/role-model-tools.ts +47 -6
- package/packages/extension/src/server-auto-start.ts +1 -1
- package/packages/extension/src/server-proof-probe.ts +117 -0
- package/packages/extension/src/session-sync.ts +42 -12
- package/packages/extension/src/vault-delivery.ts +11 -1
- package/packages/server/package.json +8 -8
- package/packages/server/src/access/access-grants.ts +61 -8
- package/packages/server/src/access/access-health.ts +10 -0
- package/packages/server/src/access/access-plane.ts +5 -1
- package/packages/server/src/access/containment-gate.ts +55 -17
- package/packages/server/src/access/cwd-verdict.ts +3 -3
- package/packages/server/src/access/pi-trust-live.ts +244 -0
- package/packages/server/src/access/pi-trust-mirror-service.ts +44 -11
- package/packages/server/src/access/planes.ts +106 -1
- package/packages/server/src/access/preview-egress-store.ts +153 -0
- package/packages/server/src/access/prompt-channel.ts +5 -0
- package/packages/server/src/access/provisioning-wiring.ts +113 -0
- package/packages/server/src/access/provisioning.ts +763 -0
- package/packages/server/src/access/yolo-session.ts +54 -2
- package/packages/server/src/acp-bridge/acp-session-adapter.ts +8 -3
- package/packages/server/src/agent-events/agent-event-hub.ts +158 -0
- package/packages/server/src/auth/audit-log.ts +80 -0
- package/packages/server/src/auth/auth-plugin.ts +44 -25
- package/packages/server/src/auth/auth.ts +24 -4
- package/packages/server/src/auth/bearer-auth.ts +52 -12
- package/packages/server/src/auth/cors-origin.ts +76 -29
- package/packages/server/src/auth/csp-report-paths.ts +31 -0
- package/packages/server/src/auth/csp-report-sink.ts +302 -0
- package/packages/server/src/auth/csp-report-store.ts +406 -0
- package/packages/server/src/auth/csp.ts +105 -9
- package/packages/server/src/auth/dashboard-credential-store.ts +4 -0
- package/packages/server/src/auth/dashboard-state-caller.ts +29 -0
- package/packages/server/src/auth/local-proof-refusal-log.ts +89 -0
- package/packages/server/src/auth/local-proof.ts +69 -18
- package/packages/server/src/auth/localhost-guard.ts +48 -10
- package/packages/server/src/auth/nav-intent.ts +72 -0
- package/packages/server/src/auth/passkey/passkey-assets.ts +99 -0
- package/packages/server/src/auth/passkey/passkey-pages.ts +17 -81
- package/packages/server/src/auth/passkey/passkey-routes.ts +8 -0
- package/packages/server/src/auth/pi-legacy-credentials.ts +3 -0
- package/packages/server/src/auth/plugin-server-trust.ts +29 -0
- package/packages/server/src/auth/plugin-trust-store.ts +103 -0
- package/packages/server/src/auth/proven-tls.ts +45 -0
- package/packages/server/src/auth/provider-auth-storage.ts +6 -1
- package/packages/server/src/auth/radius-mcp.ts +1 -1
- package/packages/server/src/auth/request-principal.ts +32 -0
- package/packages/server/src/auth/secret-rotation.ts +246 -0
- package/packages/server/src/auth/secure-origin.ts +56 -0
- package/packages/server/src/auth/serve-app-host.ts +111 -11
- package/packages/server/src/auth/ws-ticket.ts +39 -1
- package/packages/server/src/auth/ws-upgrade-reject-log.ts +4 -1
- package/packages/server/src/browser-handlers/directory-handler.ts +23 -0
- package/packages/server/src/browser-handlers/folder-gate.ts +55 -0
- package/packages/server/src/browser-handlers/handler-context.ts +25 -2
- package/packages/server/src/browser-handlers/session-action-handler.ts +9 -1
- package/packages/server/src/browser-handlers/subscription-handler.ts +100 -2
- package/packages/server/src/browser-handlers/terminal-handler.ts +108 -10
- package/packages/server/src/canvas/canvas-accumulator.ts +35 -7
- package/packages/server/src/cli.ts +210 -39
- package/packages/server/src/config-api.ts +23 -1
- package/packages/server/src/config-snapshot.ts +48 -1
- package/packages/server/src/directory-service.ts +160 -54
- package/packages/server/src/event-wiring.ts +143 -108
- package/packages/server/src/git-worktree/git-operations.ts +44 -10
- package/packages/server/src/git-worktree/redact-git-text.ts +124 -0
- package/packages/server/src/git-worktree/ref-arg.ts +39 -0
- package/packages/server/src/git-worktree/worktree-init-trust.ts +43 -1
- package/packages/server/src/identity/http-road-classification.ts +13 -1
- package/packages/server/src/identity/ws-message-scope.ts +1 -0
- package/packages/server/src/identity/ws-road-classification.ts +1 -0
- package/packages/server/src/known-server-moves.ts +36 -15
- package/packages/server/src/lib/browse-roots.ts +118 -17
- package/packages/server/src/lib/client-dist.ts +36 -21
- package/packages/server/src/lib/dashboard-state-guard.ts +230 -0
- package/packages/server/src/lib/diagram-render.ts +4 -6
- package/packages/server/src/lib/eml.ts +3 -8
- package/packages/server/src/lib/file-cwd-admission.ts +145 -0
- package/packages/server/src/lib/grep-worker.ts +23 -0
- package/packages/server/src/lib/grep.ts +93 -7
- package/packages/server/src/lib/index-html.ts +81 -0
- package/packages/server/src/lib/office-preview.ts +2 -3
- package/packages/server/src/lib/path-containment.ts +7 -0
- package/packages/server/src/lib/resolve-file-mention.ts +11 -9
- package/packages/server/src/lib/route-admission.ts +80 -0
- package/packages/server/src/lib/writable-md-target.ts +4 -0
- package/packages/server/src/lifecycle/recovery-server.ts +65 -18
- package/packages/server/src/live-server/capability-redact.ts +15 -0
- package/packages/server/src/live-server/live-browser-gate.ts +22 -0
- package/packages/server/src/live-server/live-capability.ts +224 -17
- package/packages/server/src/live-server/live-csp-report.ts +63 -0
- package/packages/server/src/live-server/live-csp.ts +93 -0
- package/packages/server/src/live-server/live-egress.ts +435 -0
- package/packages/server/src/live-server/live-exposure.ts +149 -0
- package/packages/server/src/live-server/live-log.ts +21 -0
- package/packages/server/src/live-server/live-origin-scan.ts +298 -0
- package/packages/server/src/live-server/live-server-manager.ts +209 -33
- package/packages/server/src/live-server/live-server-proxy.ts +162 -17
- package/packages/server/src/live-server/live-static.ts +228 -0
- package/packages/server/src/openspec/dependencies-file.ts +122 -0
- package/packages/server/src/openspec/openspec-change-watcher.ts +3 -1
- package/packages/server/src/openspec/openspec-dependency-inputs.ts +281 -0
- package/packages/server/src/openspec/openspec-poll-fs-helpers.ts +72 -26
- package/packages/server/src/openspec/openspec-poll-worker-pool.ts +48 -12
- package/packages/server/src/openspec/openspec-poll-worker.ts +95 -9
- package/packages/server/src/openspec/workflow-schema-status.ts +379 -0
- package/packages/server/src/openspec/workflow-schema.ts +141 -267
- package/packages/server/src/package/npm-search-proxy.ts +5 -2
- package/packages/server/src/package/provider-probe.ts +8 -2
- package/packages/server/src/pairing/browser-gateway.ts +188 -12
- package/packages/server/src/pairing/device-token-services.ts +26 -0
- package/packages/server/src/pairing/paired-devices.ts +335 -22
- package/packages/server/src/pairing/pairing.ts +34 -4
- package/packages/server/src/pairing/socket-locality.ts +26 -0
- package/packages/server/src/persistence/preferences-store.ts +9 -0
- package/packages/server/src/pi/bridge-channel.ts +33 -0
- package/packages/server/src/pi/bridge-upgrade-auth.ts +18 -3
- package/packages/server/src/pi/gateway-listeners.ts +9 -3
- package/packages/server/src/pi/host-project-trust.ts +14 -6
- package/packages/server/src/pi/pi-gateway.ts +191 -21
- package/packages/server/src/pi/resource-toggle-trust.ts +1 -1
- package/packages/server/src/plugin-discovery-wiring.ts +142 -0
- package/packages/server/src/plugin-event-seam.ts +116 -4
- package/packages/server/src/plugin-runtime-clients.ts +89 -0
- package/packages/server/src/routes/access-routes.ts +159 -9
- package/packages/server/src/routes/agent-event-stream-routes.ts +137 -0
- package/packages/server/src/routes/canvas-types-routes.ts +20 -6
- package/packages/server/src/routes/csp-violations-routes.ts +162 -0
- package/packages/server/src/routes/file-routes.ts +329 -209
- package/packages/server/src/routes/file-write-binary-routes.ts +77 -20
- package/packages/server/src/routes/folder-project-routes.ts +18 -12
- package/packages/server/src/routes/git-routes.ts +319 -203
- package/packages/server/src/routes/grep-routes.ts +38 -14
- package/packages/server/src/routes/known-servers-routes.ts +189 -91
- package/packages/server/src/routes/live-server-routes.ts +378 -15
- package/packages/server/src/routes/local-proof-routes.ts +14 -0
- package/packages/server/src/routes/nav-intent-routes.ts +46 -0
- package/packages/server/src/routes/openspec-group-routes.ts +53 -44
- package/packages/server/src/routes/openspec-routes.ts +379 -28
- package/packages/server/src/routes/package-routes.ts +58 -10
- package/packages/server/src/routes/pairing-routes.ts +146 -10
- package/packages/server/src/routes/pi-trust-query-routes.ts +330 -0
- package/packages/server/src/routes/plugin-activation-routes.ts +59 -0
- package/packages/server/src/routes/plugin-runtime-client-routes.ts +149 -0
- package/packages/server/src/routes/provider-auth-routes.ts +15 -2
- package/packages/server/src/routes/resource-activation-routes.ts +18 -4
- package/packages/server/src/routes/session-routes.ts +51 -4
- package/packages/server/src/routes/system-routes.ts +84 -15
- package/packages/server/src/routes/ui-link-base.ts +88 -0
- package/packages/server/src/runtime-overlay/runtime-io.ts +2 -9
- package/packages/server/src/server.ts +648 -137
- package/packages/server/src/session/hydration-state.ts +148 -0
- package/packages/server/src/session/memory-session-manager.ts +7 -0
- package/packages/server/src/session/replay-exit-controller.ts +221 -0
- package/packages/server/src/session/retained-transcript.ts +9 -2
- package/packages/server/src/session/session-load-worker.ts +11 -2
- package/packages/server/src/spawn-process/headless-pid-registry.ts +14 -9
- package/packages/server/src/terminal/terminal-manager.ts +54 -46
- package/packages/server/src/tls/tls-bridge-route.ts +61 -0
- package/packages/server/src/tls/tls-config-validation.ts +2 -0
- package/packages/server/src/vault/device-expiry-sweep.ts +36 -0
- package/packages/server/src/vault/vault-delivery-hub.ts +155 -25
- package/packages/server/src/watch-files-handler.ts +66 -0
- package/packages/shared/package.json +1 -1
- package/packages/shared/src/browser-protocol.ts +148 -2
- package/packages/shared/src/canvas-declare.ts +27 -0
- package/packages/shared/src/config.ts +372 -53
- package/packages/shared/src/containment-guard.ts +35 -0
- package/packages/shared/src/dashboard-plugin/anthropic-peer-names.ts +9 -0
- package/packages/shared/src/dashboard-plugin/event-type-owners.ts +50 -0
- package/packages/shared/src/dashboard-plugin/file-handler.ts +2 -0
- package/packages/shared/src/dashboard-plugin/host-api.ts +61 -0
- package/packages/shared/src/dashboard-plugin/host-fx-classes.ts +23 -0
- package/packages/shared/src/dashboard-plugin/host-import-map.ts +38 -0
- package/packages/shared/src/dashboard-plugin/index.ts +2 -0
- package/packages/shared/src/dashboard-plugin/manifest-types.ts +54 -1
- package/packages/shared/src/dashboard-plugin/plugin-status.ts +54 -0
- package/packages/shared/src/dashboard-plugin/slot-props.ts +45 -3
- package/packages/shared/src/dashboard-plugin/slot-types.ts +8 -0
- package/packages/shared/src/dashboard-plugin/subagent-types.ts +219 -0
- package/packages/shared/src/dashboard-plugin/ui-primitives.ts +28 -0
- package/packages/shared/src/display-prefs.ts +13 -0
- package/packages/shared/src/doctor-core.ts +94 -27
- package/packages/shared/src/live-server.ts +141 -0
- package/packages/shared/src/local-proof-signal.ts +16 -0
- package/packages/shared/src/loopback-host.ts +26 -0
- package/packages/shared/src/mcp/verb-tiers.generated.ts +178 -0
- package/packages/shared/src/mdns-discovery.ts +25 -6
- package/packages/shared/src/nav-intent.ts +29 -0
- package/packages/shared/src/openspec-dependencies.ts +760 -0
- package/packages/shared/src/openspec-poller.ts +3 -2
- package/packages/shared/src/pairing-knock-client.ts +44 -4
- package/packages/shared/src/pi-trust-live-query.ts +93 -0
- package/packages/shared/src/pi-trust-mirror-snapshot.ts +5 -7
- package/packages/shared/src/pi-trust-mirror-types.ts +36 -3
- package/packages/shared/src/pi-trust-mirror.ts +29 -3
- package/packages/shared/src/pi-trust-resource-digest.ts +255 -0
- package/packages/shared/src/platform/ensure-bundled-git.ts +57 -34
- package/packages/shared/src/platform/git-source.ts +88 -26
- package/packages/shared/src/platform/git.ts +14 -8
- package/packages/shared/src/platform/process.ts +48 -4
- package/packages/shared/src/platform/resolve-pi-shell.ts +76 -0
- package/packages/shared/src/platform/select-git-source.ts +7 -0
- package/packages/shared/src/plugin-route-cwd.ts +95 -0
- package/packages/shared/src/preview-egress.ts +138 -0
- package/packages/shared/src/project-root.ts +16 -0
- package/packages/shared/src/protocol.ts +40 -1
- package/packages/shared/src/recommended-extensions.ts +18 -0
- package/packages/shared/src/recovery-timing.ts +27 -0
- package/packages/shared/src/remote-credentials.ts +63 -0
- package/packages/shared/src/rest-api.ts +55 -8
- package/packages/shared/src/route-tiers.ts +55 -1
- package/packages/shared/src/runtime-overlay/archive-safety.d.mts +2 -0
- package/packages/shared/src/runtime-overlay/archive-safety.mjs +33 -0
- package/packages/shared/src/runtime-overlay/manifest.d.mts +7 -0
- package/packages/shared/src/runtime-overlay/manifest.mjs +22 -2
- package/packages/shared/src/safe-local-path.ts +24 -0
- package/packages/shared/src/sanitize-profiles.ts +98 -0
- package/packages/shared/src/server-launcher.ts +9 -1
- package/packages/shared/src/server-pinning.ts +55 -2
- package/packages/shared/src/server-routes.ts +462 -0
- package/packages/shared/src/session-ui-path.ts +11 -0
- package/packages/shared/src/tls-only-token.ts +16 -0
- package/packages/shared/src/tool-registry/definitions.ts +5 -5
- package/packages/shared/src/tool-registry/strategies.ts +12 -11
- package/packages/shared/src/types.ts +66 -0
- package/packages/shared/src/url-policy.ts +96 -0
- package/packages/shared/src/vault-delivery.ts +15 -0
- package/packages/shared/src/ws-message-tiers.ts +1 -0
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
import {
|
|
33
33
|
resolveOpenSpecPackageSchemasDir,
|
|
34
34
|
resolveOpenSpecPackageVersion,
|
|
35
|
+
userSchemasDir,
|
|
35
36
|
} from "@blackbelt-technology/pi-dashboard-shared/platform/openspec.js";
|
|
36
37
|
import type { PiResourcesResult } from "@blackbelt-technology/pi-dashboard-shared/rest-api.js";
|
|
37
38
|
import { createSemaphore, type Semaphore } from "@blackbelt-technology/pi-dashboard-shared/semaphore.js";
|
|
@@ -44,11 +45,7 @@ import type {
|
|
|
44
45
|
import { computeFolderGroupKeys, createFolderHeadPoll, type FolderHeadPoll } from "./git-worktree/folder-head-poll.js";
|
|
45
46
|
import type { EventLoopSpikeMetrics, EventLoopTurn } from "./metrics/eventloop-spike-metrics.js";
|
|
46
47
|
import { type BrokeReason, deriveOpenSpecReadiness, hasWorkflowSchemaStatus } from "./openspec/readiness.js";
|
|
47
|
-
import {
|
|
48
|
-
computeWorkflowSchemaStatus,
|
|
49
|
-
makeValidateLocal,
|
|
50
|
-
type WorkflowSchemaDeps,
|
|
51
|
-
} from "./openspec/workflow-schema.js";
|
|
48
|
+
import { makeValidateLocal, type WorkflowSchemaDeps } from "./openspec/workflow-schema.js";
|
|
52
49
|
|
|
53
50
|
/**
|
|
54
51
|
* Debounce for the folder-HEAD entry refresh, so a registration burst collapses
|
|
@@ -70,11 +67,14 @@ import {
|
|
|
70
67
|
import type {
|
|
71
68
|
PollWorkerPerChangeIn,
|
|
72
69
|
PollWorkerRequest,
|
|
70
|
+
SchemaStatusRequest,
|
|
71
|
+
SchemaStatusResponse,
|
|
73
72
|
StatusAllBuildResponse,
|
|
74
73
|
} from "./openspec/openspec-poll-worker.js";
|
|
75
74
|
import {
|
|
76
75
|
createOpenSpecPollWorkerPool,
|
|
77
76
|
type PollWorkerPool,
|
|
77
|
+
type PollWorkerPoolOptions,
|
|
78
78
|
} from "./openspec/openspec-poll-worker-pool.js";
|
|
79
79
|
import type { PreferencesStore } from "./persistence/preferences-store.js";
|
|
80
80
|
import { scanPiResources } from "./pi/pi-resource-scanner.js";
|
|
@@ -103,6 +103,10 @@ export interface LoadResult {
|
|
|
103
103
|
success: boolean;
|
|
104
104
|
events: Array<{ eventType: string; timestamp: number; data: Record<string, unknown> }>;
|
|
105
105
|
error?: string;
|
|
106
|
+
/** Branch entry count + last-entry id of the hydrated transcript: the skip-wipe
|
|
107
|
+
* fingerprint source. See change: fix-large-session-resume-replay (D5). */
|
|
108
|
+
entryCount?: number;
|
|
109
|
+
leafEntryId?: string;
|
|
106
110
|
}
|
|
107
111
|
|
|
108
112
|
export interface DirectoryAddedResult {
|
|
@@ -201,6 +205,20 @@ export interface DirectoryService {
|
|
|
201
205
|
*/
|
|
202
206
|
ensureLoadWorkerPool(): SessionLoadWorkerPool | null;
|
|
203
207
|
getOpenSpecData(cwd: string): OpenSpecData | undefined;
|
|
208
|
+
/**
|
|
209
|
+
* Which poll path produced the cached data for `cwd`: `"all"` (`status --all`),
|
|
210
|
+
* `"fallback"` (CLI without it) or `undefined` (never polled). The dependencies
|
|
211
|
+
* REST gate answers 409 `status-all-unsupported` on `"fallback"`.
|
|
212
|
+
* See change: add-openspec-change-dependencies.
|
|
213
|
+
*/
|
|
214
|
+
getOpenSpecPollMode(cwd: string): "all" | "fallback" | undefined;
|
|
215
|
+
/**
|
|
216
|
+
* The ONE spawn semaphore bounding every `openspec` CLI spawn: the poll, and
|
|
217
|
+
* (passed in by `server.ts`) the REST workflow-schema validate. Resized by
|
|
218
|
+
* `reconfigurePolling`, so holders see the new cap.
|
|
219
|
+
* See change: move-workflow-schema-status-to-poll-worker.
|
|
220
|
+
*/
|
|
221
|
+
readonly semaphore: Semaphore;
|
|
204
222
|
/** Force refresh: bypasses the mtime gate. Still honors the semaphore. */
|
|
205
223
|
refreshOpenSpec(cwd: string): Promise<OpenSpecData>;
|
|
206
224
|
/**
|
|
@@ -338,6 +356,13 @@ type DirCache = {
|
|
|
338
356
|
allCwdMtime: number | undefined;
|
|
339
357
|
/** Tracked extras per change from the last successful result; `null` before one (legacy set only). */
|
|
340
358
|
allExtras: Record<string, TrackedExtras> | null;
|
|
359
|
+
/**
|
|
360
|
+
* Capability ids touched by an active delta in the last build, stored with the
|
|
361
|
+
* cwd-level stamp: the probe stats their main-spec paths. `null` = unknown
|
|
362
|
+
* (cold start, worker restart) → the gate does not skip. See change:
|
|
363
|
+
* add-openspec-change-dependencies.
|
|
364
|
+
*/
|
|
365
|
+
allCapIds: string[] | null;
|
|
341
366
|
/** Worker build output BEFORE readiness/skills finalization, reused on gate hits. */
|
|
342
367
|
allData: OpenSpecData | undefined;
|
|
343
368
|
/**
|
|
@@ -360,6 +385,7 @@ function emptyDirCache(): DirCache {
|
|
|
360
385
|
mode: undefined,
|
|
361
386
|
allCwdMtime: undefined,
|
|
362
387
|
allExtras: null,
|
|
388
|
+
allCapIds: null,
|
|
363
389
|
allData: undefined,
|
|
364
390
|
};
|
|
365
391
|
}
|
|
@@ -436,15 +462,24 @@ export interface DirectoryServiceOptions {
|
|
|
436
462
|
openspecVersionResolver?: () => Promise<string | null>;
|
|
437
463
|
/**
|
|
438
464
|
* Test seams for `OpenSpecData.workflowSchema`: CLI/semaphore deps of the
|
|
439
|
-
* `newer`/`conflict` `schema validate`, the package-schemas dir
|
|
440
|
-
* the user-level schemas dir
|
|
441
|
-
*
|
|
465
|
+
* main-thread `newer`/`conflict` `schema validate`, the package-schemas dir
|
|
466
|
+
* resolver, the user-level schemas dir, and `computeStatus` — the in-process
|
|
467
|
+
* implementation of the pool's `schemaStatus` request (threaded into the
|
|
468
|
+
* pool as `schemaStatusImpl`). Defaults are the real ones.
|
|
469
|
+
* See changes: add-pi-spec-driven-schema, move-workflow-schema-status-to-poll-worker.
|
|
442
470
|
*/
|
|
443
471
|
workflowSchema?: {
|
|
444
472
|
deps?: Partial<WorkflowSchemaDeps>;
|
|
445
473
|
packageSchemasDir?: () => Promise<string | null>;
|
|
446
474
|
userSchemasDirPath?: string;
|
|
475
|
+
computeStatus?: (req: SchemaStatusRequest) => Promise<SchemaStatusResponse>;
|
|
447
476
|
};
|
|
477
|
+
/**
|
|
478
|
+
* Test seam: builds the poll worker pool (default `createOpenSpecPollWorkerPool`),
|
|
479
|
+
* so tests can record or delay requests or point the pool at a fixture worker.
|
|
480
|
+
* See change: move-workflow-schema-status-to-poll-worker.
|
|
481
|
+
*/
|
|
482
|
+
pollWorkerPoolFactory?: (opts: PollWorkerPoolOptions) => PollWorkerPool;
|
|
448
483
|
/**
|
|
449
484
|
* Per-turn slow-tick alarm threshold (ms). Independent of the retained wall
|
|
450
485
|
* `durationMs` alarm: fires when any single instrumented turn's synchronous
|
|
@@ -483,8 +518,10 @@ export interface DirectoryServiceOptions {
|
|
|
483
518
|
* successful poll — same cwd-level stamp, same change set, every change
|
|
484
519
|
* stamped (an unstamped/racy entry always trips) at its probed mtime.
|
|
485
520
|
*/
|
|
486
|
-
function statusAllGateHit(cache: DirCache, pre: ProbeResponse): boolean {
|
|
487
|
-
|
|
521
|
+
export function statusAllGateHit(cache: DirCache, pre: ProbeResponse): boolean {
|
|
522
|
+
// `allCapIds === null`: the cwd-level stamp does not yet cover the main-spec
|
|
523
|
+
// paths (cold start, worker restart) — never skip. See change: add-openspec-change-dependencies.
|
|
524
|
+
if (!cache.allData || cache.allCapIds === null || cache.allCwdMtime === undefined || pre.cwdMtime !== cache.allCwdMtime) return false;
|
|
488
525
|
if (cache.changes.size !== pre.names.length) return false;
|
|
489
526
|
return pre.names.every((n) => {
|
|
490
527
|
const e = cache.changes.get(n);
|
|
@@ -511,6 +548,7 @@ function applyStatusAllBuild(cache: DirCache, out: Extract<StatusAllBuildRespons
|
|
|
511
548
|
for (const key of Array.from(cache.changes.keys())) if (!live.has(key)) cache.changes.delete(key);
|
|
512
549
|
cache.allCwdMtime = out.cwdStamp;
|
|
513
550
|
cache.allExtras = out.extras;
|
|
551
|
+
cache.allCapIds = out.capabilityIds;
|
|
514
552
|
cache.allData = out.data;
|
|
515
553
|
}
|
|
516
554
|
|
|
@@ -619,9 +657,12 @@ export function createDirectoryService(
|
|
|
619
657
|
d,
|
|
620
658
|
{ breakReason },
|
|
621
659
|
);
|
|
622
|
-
|
|
660
|
+
// Never carry a previous tick's `workflowSchema`: the key is set below only
|
|
661
|
+
// from THIS tick's request, so a failed computation omits it.
|
|
662
|
+
const { workflowSchema: _previous, ...carried } = d;
|
|
663
|
+
const out: OpenSpecData = { ...carried, hasOpenSpecSkills: skills, readiness };
|
|
623
664
|
// Separate from readiness (never alters it): successful-poll payloads only —
|
|
624
|
-
// the success call sites pass the status promise
|
|
665
|
+
// the success call sites pass the status promise enqueued earlier in the tick.
|
|
625
666
|
if (schemaStatus && breakReason === undefined && d.initialized === true && hasWorkflowSchemaStatus(readiness)) {
|
|
626
667
|
const workflowSchema = await schemaStatus;
|
|
627
668
|
if (workflowSchema) out.workflowSchema = workflowSchema;
|
|
@@ -629,36 +670,82 @@ export function createDirectoryService(
|
|
|
629
670
|
return out;
|
|
630
671
|
}
|
|
631
672
|
|
|
632
|
-
// `OpenSpecData.workflowSchema` —
|
|
633
|
-
//
|
|
634
|
-
//
|
|
635
|
-
//
|
|
636
|
-
// `schema validate`
|
|
637
|
-
// (cwd, fingerprint, CLI version).
|
|
673
|
+
// `OpenSpecData.workflowSchema` — the filesystem part is computed by the poll
|
|
674
|
+
// worker's `schemaStatus` request on EVERY tick (gate hit included), enqueued
|
|
675
|
+
// once per tick right after the cwd's probe (status-all path) or before the
|
|
676
|
+
// list spawn (fallback path), and attached at finalize. Only the
|
|
677
|
+
// `newer`/`conflict` `schema validate` stays on the main thread: through the
|
|
678
|
+
// shared spawn semaphore, memoized by (cwd, fingerprint, CLI version).
|
|
679
|
+
// See change: move-workflow-schema-status-to-poll-worker.
|
|
638
680
|
const workflowSchemaOpts = options.workflowSchema;
|
|
639
|
-
let packageSchemasDirMemo: { version: string | null; dir: string } | null = null;
|
|
681
|
+
let packageSchemasDirMemo: { version: string | null; dir: string | null } | null = null;
|
|
640
682
|
async function packageSchemasDirFor(version: string | null): Promise<string | null> {
|
|
641
683
|
if (workflowSchemaOpts?.packageSchemasDir) return workflowSchemaOpts.packageSchemasDir();
|
|
642
684
|
if (packageSchemasDirMemo && packageSchemasDirMemo.version === version) return packageSchemasDirMemo.dir;
|
|
643
|
-
const dir = await resolveOpenSpecPackageSchemasDir();
|
|
644
|
-
if (dir)
|
|
685
|
+
const dir = await resolveOpenSpecPackageSchemasDir().catch(() => undefined);
|
|
686
|
+
if (dir === undefined) return null; // resolution threw: do not memoize
|
|
687
|
+
packageSchemasDirMemo = { version, dir }; // a `null` (no CLI) is memoized too: no per-tick re-walk
|
|
645
688
|
return dir;
|
|
646
689
|
}
|
|
647
|
-
|
|
690
|
+
type SchemaStatusInputs = Pick<SchemaStatusRequest, "packageSchemasDir" | "userSchemasDir">;
|
|
691
|
+
/**
|
|
692
|
+
* Main-thread inputs of the `schemaStatus` request (the worker module must not
|
|
693
|
+
* import them). Advisory: a resolution failure yields `{ error }`, never a throw,
|
|
694
|
+
* so it can neither fail a poll nor escape `pollOne`.
|
|
695
|
+
*/
|
|
696
|
+
async function schemaStatusInputsFor(version: string | null): Promise<SchemaStatusInputs | { error: unknown }> {
|
|
697
|
+
try {
|
|
698
|
+
return {
|
|
699
|
+
packageSchemasDir: await packageSchemasDirFor(version),
|
|
700
|
+
userSchemasDir: workflowSchemaOpts?.userSchemasDirPath ?? userSchemasDir(),
|
|
701
|
+
};
|
|
702
|
+
} catch (error) {
|
|
703
|
+
return { error };
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
// cwds whose status computation failed on the previous tick (log once per failure run).
|
|
707
|
+
const schemaStatusFailing = new Set<string>();
|
|
708
|
+
function noteSchemaStatusFailure(cwd: string, err: unknown): void {
|
|
709
|
+
if (schemaStatusFailing.has(cwd)) return;
|
|
710
|
+
schemaStatusFailing.add(cwd);
|
|
711
|
+
console.warn(
|
|
712
|
+
`[openspec-poll] workflow-schema status failed for ${cwd} (worker request and in-process fallback); omitting workflowSchema this tick:`,
|
|
713
|
+
err,
|
|
714
|
+
);
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Enqueue the `schemaStatus` request NOW (synchronously — callers rely on its
|
|
718
|
+
* place in the pool FIFO) and resolve the finished status. Never rejects: a
|
|
719
|
+
* computation failure (worker AND in-process fallback) resolves `undefined`,
|
|
720
|
+
* so the key is omitted for the tick and an abandoned promise is never an
|
|
721
|
+
* unhandled rejection.
|
|
722
|
+
*/
|
|
723
|
+
function requestSchemaStatus(
|
|
648
724
|
cwd: string,
|
|
649
725
|
version: string | null,
|
|
726
|
+
inputs: SchemaStatusInputs | { error: unknown },
|
|
650
727
|
): Promise<OpenSpecWorkflowSchemaStatus | undefined> {
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
return
|
|
654
|
-
localVersion,
|
|
655
|
-
packageSchemasDir: () => packageSchemasDirFor(version),
|
|
656
|
-
...(workflowSchemaOpts?.userSchemasDirPath ? { userSchemasDirPath: workflowSchemaOpts.userSchemasDirPath } : {}),
|
|
657
|
-
validateLocal: makeValidateLocal(cwd, localVersion, { semaphore, ...workflowSchemaOpts?.deps }),
|
|
658
|
-
});
|
|
659
|
-
} catch {
|
|
660
|
-
return undefined; // advisory only: never fail or alter a poll
|
|
728
|
+
if ("error" in inputs) {
|
|
729
|
+
noteSchemaStatusFailure(cwd, inputs.error);
|
|
730
|
+
return Promise.resolve(undefined);
|
|
661
731
|
}
|
|
732
|
+
const localVersion = version ?? "";
|
|
733
|
+
const run = async (): Promise<OpenSpecWorkflowSchemaStatus | undefined> => {
|
|
734
|
+
try {
|
|
735
|
+
const res = await ensureWorkerPool().schemaStatus({ cwd, localVersion, ...inputs });
|
|
736
|
+
let status = res.status;
|
|
737
|
+
if (res.validateFingerprint !== undefined) {
|
|
738
|
+
const validate = makeValidateLocal(cwd, localVersion, { semaphore, ...workflowSchemaOpts?.deps });
|
|
739
|
+
if (!(await validate(res.validateFingerprint))) status = { ...status, generated: "incompatible" };
|
|
740
|
+
}
|
|
741
|
+
schemaStatusFailing.delete(cwd);
|
|
742
|
+
return status;
|
|
743
|
+
} catch (err) {
|
|
744
|
+
noteSchemaStatusFailure(cwd, err);
|
|
745
|
+
return undefined; // advisory only: never fail or alter a poll
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
return run();
|
|
662
749
|
}
|
|
663
750
|
|
|
664
751
|
/** Cleared disabled payload — allocation-only, no stat, no CLI. */
|
|
@@ -714,10 +801,12 @@ export function createDirectoryService(
|
|
|
714
801
|
function ensureWorkerPool(): PollWorkerPool {
|
|
715
802
|
if (workerPool) return workerPool;
|
|
716
803
|
const cpuCount = os.cpus().length || 1;
|
|
717
|
-
|
|
804
|
+
const poolOptions: PollWorkerPoolOptions = {
|
|
718
805
|
size: Math.max(1, Math.min(cfg.maxConcurrentSpawns, cpuCount)),
|
|
719
806
|
useWorker: cfg.useWorker !== false,
|
|
720
|
-
|
|
807
|
+
...(workflowSchemaOpts?.computeStatus ? { schemaStatusImpl: workflowSchemaOpts.computeStatus } : {}),
|
|
808
|
+
};
|
|
809
|
+
workerPool = (options.pollWorkerPoolFactory ?? createOpenSpecPollWorkerPool)(poolOptions);
|
|
721
810
|
return workerPool;
|
|
722
811
|
}
|
|
723
812
|
|
|
@@ -960,7 +1049,7 @@ export function createDirectoryService(
|
|
|
960
1049
|
}
|
|
961
1050
|
}
|
|
962
1051
|
}
|
|
963
|
-
return { success: true, events: out.events };
|
|
1052
|
+
return { success: true, events: out.events, entryCount: out.entryCount, leafEntryId: out.leafEntryId };
|
|
964
1053
|
}
|
|
965
1054
|
return { success: false, events: [], error: out.error };
|
|
966
1055
|
} finally {
|
|
@@ -1021,7 +1110,7 @@ export function createDirectoryService(
|
|
|
1021
1110
|
const out = await result;
|
|
1022
1111
|
entryCount = out.entryCount ?? 0;
|
|
1023
1112
|
eventCount = out.events.length;
|
|
1024
|
-
if (out.success) return { success: true, events: out.events };
|
|
1113
|
+
if (out.success) return { success: true, events: out.events, entryCount: out.entryCount, leafEntryId: out.leafEntryId };
|
|
1025
1114
|
return { success: false, events: [], error: out.error };
|
|
1026
1115
|
} finally {
|
|
1027
1116
|
inFlightLoadJobs.delete(sessionId);
|
|
@@ -1061,18 +1150,15 @@ export function createDirectoryService(
|
|
|
1061
1150
|
// (stdout received → build dispatched) → await build → `dirPollPost`
|
|
1062
1151
|
// (response applied; the caller times the broadcast). Returns `null` when
|
|
1063
1152
|
// the CLI turned out not to support `--all`, so the caller continues on the
|
|
1064
|
-
// fallback in the same poll.
|
|
1153
|
+
// fallback in the same poll. Also hands back the tick's `schemaStatus`
|
|
1154
|
+
// request (enqueued right after the probe), so the fallback reuses it.
|
|
1065
1155
|
async function pollOneStatusAll(
|
|
1066
1156
|
cwd: string,
|
|
1067
1157
|
force: boolean,
|
|
1068
1158
|
cache: DirCache,
|
|
1069
|
-
ctx: {
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
schemaStatus: Promise<OpenSpecWorkflowSchemaStatus | undefined>;
|
|
1073
|
-
},
|
|
1074
|
-
): Promise<OpenSpecData | null> {
|
|
1075
|
-
const { hasOpenspecDir, cliVersion, schemaStatus } = ctx;
|
|
1159
|
+
ctx: { hasOpenspecDir: boolean; cliVersion: string | null },
|
|
1160
|
+
): Promise<{ data: OpenSpecData | null; schemaStatus: Promise<OpenSpecWorkflowSchemaStatus | undefined> }> {
|
|
1161
|
+
const { hasOpenspecDir, cliVersion } = ctx;
|
|
1076
1162
|
const gateEnabled = cfg.changeDetection === "mtime" && !force;
|
|
1077
1163
|
if (cache.mode !== "all") {
|
|
1078
1164
|
cache.mode = "all";
|
|
@@ -1081,13 +1167,19 @@ export function createDirectoryService(
|
|
|
1081
1167
|
cache.listResult = undefined;
|
|
1082
1168
|
cache.allCwdMtime = undefined;
|
|
1083
1169
|
cache.allExtras = null;
|
|
1170
|
+
cache.allCapIds = null;
|
|
1084
1171
|
cache.allData = undefined;
|
|
1085
1172
|
}
|
|
1086
1173
|
|
|
1087
1174
|
const openspecDir = await canonicalOpenspecDir(cwd);
|
|
1088
|
-
const probeReq = { openspecDir, extras: cache.allExtras };
|
|
1175
|
+
const probeReq = { openspecDir, extras: cache.allExtras, capabilityIds: cache.allCapIds };
|
|
1176
|
+
const schemaInputs = await schemaStatusInputsFor(cliVersion);
|
|
1089
1177
|
const pool = ensureWorkerPool();
|
|
1090
|
-
const
|
|
1178
|
+
const probePromise = pool.probe(probeReq);
|
|
1179
|
+
// Enqueued right after the probe (before it is awaited): the FIFO keeps the
|
|
1180
|
+
// probe ahead of it, the CLI spawn and `build` never wait for it.
|
|
1181
|
+
const schemaStatus = requestSchemaStatus(cwd, cliVersion, schemaInputs);
|
|
1182
|
+
const pre = await probePromise.catch(() => ({
|
|
1091
1183
|
cwdMtime: undefined as number | undefined,
|
|
1092
1184
|
names: [] as string[],
|
|
1093
1185
|
changes: {} as Record<string, number | undefined>,
|
|
@@ -1101,7 +1193,7 @@ export function createDirectoryService(
|
|
|
1101
1193
|
cache.data = reused;
|
|
1102
1194
|
cache.serialized = undefined;
|
|
1103
1195
|
caches.set(cwd, cache);
|
|
1104
|
-
return reused;
|
|
1196
|
+
return { data: reused, schemaStatus };
|
|
1105
1197
|
}
|
|
1106
1198
|
const rawPromise = semaphore.run(() => runOpenSpecStatusAll(cwd));
|
|
1107
1199
|
// Read concurrently with the CLI; awaited before the `dirPollCli` turn
|
|
@@ -1124,6 +1216,7 @@ export function createDirectoryService(
|
|
|
1124
1216
|
cache.data = empty;
|
|
1125
1217
|
cache.allCwdMtime = undefined;
|
|
1126
1218
|
cache.allExtras = null;
|
|
1219
|
+
cache.allCapIds = null;
|
|
1127
1220
|
cache.allData = undefined;
|
|
1128
1221
|
cache.listMtimeMs = undefined;
|
|
1129
1222
|
cache.listResult = undefined;
|
|
@@ -1149,7 +1242,7 @@ export function createDirectoryService(
|
|
|
1149
1242
|
try {
|
|
1150
1243
|
out = await buildPromise;
|
|
1151
1244
|
} catch {
|
|
1152
|
-
return failedPayload();
|
|
1245
|
+
return { data: await failedPayload(), schemaStatus };
|
|
1153
1246
|
}
|
|
1154
1247
|
|
|
1155
1248
|
// dirPollPost: the build response applied to the cache. Timed up to its
|
|
@@ -1158,11 +1251,11 @@ export function createDirectoryService(
|
|
|
1158
1251
|
if (out.kind === "unsupported") {
|
|
1159
1252
|
statusAllSupport.markUnsupported(cliVersion);
|
|
1160
1253
|
recordTurn("dirPollPost", postStart);
|
|
1161
|
-
return null; // continue on the fallback in this same poll
|
|
1254
|
+
return { data: null, schemaStatus }; // continue on the fallback in this same poll
|
|
1162
1255
|
}
|
|
1163
1256
|
if (out.kind === "failed") {
|
|
1164
1257
|
recordTurn("dirPollPost", postStart);
|
|
1165
|
-
return failedPayload();
|
|
1258
|
+
return { data: await failedPayload(), schemaStatus };
|
|
1166
1259
|
}
|
|
1167
1260
|
|
|
1168
1261
|
applyStatusAllBuild(cache, out);
|
|
@@ -1175,7 +1268,7 @@ export function createDirectoryService(
|
|
|
1175
1268
|
// add-openspec-init-affordances.
|
|
1176
1269
|
cache.serialized = undefined;
|
|
1177
1270
|
caches.set(cwd, cache);
|
|
1178
|
-
return finalized;
|
|
1271
|
+
return { data: finalized, schemaStatus };
|
|
1179
1272
|
}
|
|
1180
1273
|
|
|
1181
1274
|
// ── Core gated poll ──────────────────────────────────────────────
|
|
@@ -1228,11 +1321,17 @@ export function createDirectoryService(
|
|
|
1228
1321
|
// poll (`pollOneStatusAll` resolves `null`). See change:
|
|
1229
1322
|
// use-openspec-status-all.
|
|
1230
1323
|
const cliVersion = await resolveCliVersion();
|
|
1231
|
-
|
|
1324
|
+
//
|
|
1325
|
+
// The `schemaStatus` request is enqueued at most once per tick: inside
|
|
1326
|
+
// `pollOneStatusAll` (right after its probe) or, on the fallback path,
|
|
1327
|
+
// before the `list` spawn. See change: move-workflow-schema-status-to-poll-worker.
|
|
1328
|
+
let schemaStatus: Promise<OpenSpecWorkflowSchemaStatus | undefined> | undefined;
|
|
1232
1329
|
if (!statusAllSupport.isKnownUnsupported(cliVersion, force)) {
|
|
1233
|
-
const handled = await pollOneStatusAll(cwd, force, cache, { hasOpenspecDir, cliVersion
|
|
1234
|
-
|
|
1330
|
+
const handled = await pollOneStatusAll(cwd, force, cache, { hasOpenspecDir, cliVersion });
|
|
1331
|
+
schemaStatus = handled.schemaStatus;
|
|
1332
|
+
if (handled.data) return handled.data;
|
|
1235
1333
|
}
|
|
1334
|
+
schemaStatus ??= requestSchemaStatus(cwd, cliVersion, await schemaStatusInputsFor(cliVersion));
|
|
1236
1335
|
if (cache.mode !== "fallback") {
|
|
1237
1336
|
// Entering (or re-entering) the fallback path: drop `--all` state so
|
|
1238
1337
|
// stamps over the two different tracked sets are never compared.
|
|
@@ -1240,6 +1339,7 @@ export function createDirectoryService(
|
|
|
1240
1339
|
cache.changes.clear();
|
|
1241
1340
|
cache.allCwdMtime = undefined;
|
|
1242
1341
|
cache.allExtras = null;
|
|
1342
|
+
cache.allCapIds = null;
|
|
1243
1343
|
cache.allData = undefined;
|
|
1244
1344
|
cache.listMtimeMs = undefined;
|
|
1245
1345
|
cache.listResult = undefined;
|
|
@@ -1516,6 +1616,7 @@ export function createDirectoryService(
|
|
|
1516
1616
|
cache.data = empty;
|
|
1517
1617
|
cache.allCwdMtime = undefined;
|
|
1518
1618
|
cache.allExtras = null;
|
|
1619
|
+
cache.allCapIds = null;
|
|
1519
1620
|
cache.allData = undefined;
|
|
1520
1621
|
cache.listMtimeMs = undefined;
|
|
1521
1622
|
cache.listResult = undefined;
|
|
@@ -2081,6 +2182,10 @@ export function createDirectoryService(
|
|
|
2081
2182
|
return caches.get(cwd)?.data;
|
|
2082
2183
|
},
|
|
2083
2184
|
|
|
2185
|
+
getOpenSpecPollMode(cwd: string): "all" | "fallback" | undefined {
|
|
2186
|
+
return caches.get(cwd)?.mode;
|
|
2187
|
+
},
|
|
2188
|
+
|
|
2084
2189
|
invalidateOpenSpecSignatureCache,
|
|
2085
2190
|
|
|
2086
2191
|
refreshOpenSpec,
|
|
@@ -2309,5 +2414,6 @@ export function createDirectoryService(
|
|
|
2309
2414
|
},
|
|
2310
2415
|
|
|
2311
2416
|
refreshFolderHeadsForEnteringKeys,
|
|
2417
|
+
semaphore,
|
|
2312
2418
|
};
|
|
2313
2419
|
}
|