@crouton-kit/crouter 0.3.40 → 0.3.41

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.
Files changed (188) hide show
  1. package/dist/build-root.js +1 -0
  2. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/__tests__/provider-rotation.test.ts +472 -9
  3. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/provider-rotation.ts +284 -76
  4. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/strip-skills-docs.ts +31 -24
  5. package/dist/builtin-pi-packages/pi-crtr-extensions/lib/subscription-state.ts +52 -15
  6. package/dist/clients/attach/attach-cmd.js +706 -733
  7. package/dist/clients/attach/chat-view.js +11 -0
  8. package/dist/clients/web/server.js +5 -28
  9. package/dist/clients/web/web-cmd.js +1 -1
  10. package/dist/commands/__tests__/revive-now-gate.test.js +60 -0
  11. package/dist/commands/canvas-rebuild-index.js +5 -5
  12. package/dist/commands/node-snapshot.js +9 -1
  13. package/dist/commands/node.js +37 -17
  14. package/dist/commands/push.js +8 -0
  15. package/dist/commands/revive.d.ts +10 -0
  16. package/dist/commands/revive.js +28 -10
  17. package/dist/commands/sys/__tests__/setup-core.test.js +19 -0
  18. package/dist/commands/sys/doctor.js +1 -1
  19. package/dist/commands/sys/setup-core.js +3 -2
  20. package/dist/commands/sys/setup.js +1 -1
  21. package/dist/commands/worktree.d.ts +2 -0
  22. package/dist/commands/worktree.js +94 -0
  23. package/dist/core/__tests__/boot.test.js +4 -4
  24. package/dist/core/__tests__/canvas.test.js +19 -7
  25. package/dist/core/__tests__/child-followup.test.js +15 -5
  26. package/dist/core/__tests__/daemon-boot.test.js +6 -1
  27. package/dist/core/__tests__/daemon-wedge.test.js +18 -1
  28. package/dist/core/__tests__/fault-classifier.test.js +30 -0
  29. package/dist/core/__tests__/fixtures/fake-engine.d.ts +13 -0
  30. package/dist/core/__tests__/fixtures/fake-engine.js +20 -0
  31. package/dist/core/__tests__/full/spike-harness.test.js +8 -5
  32. package/dist/core/__tests__/grace-clock.test.js +18 -2
  33. package/dist/core/__tests__/host-teardown-process-group.test.js +465 -0
  34. package/dist/core/__tests__/prune-to-limit.test.js +14 -0
  35. package/dist/core/__tests__/review-model-floor.test.js +32 -0
  36. package/dist/core/__tests__/revive.test.js +18 -4
  37. package/dist/core/__tests__/session-cycles.test.js +77 -0
  38. package/dist/core/__tests__/worktree.test.js +85 -0
  39. package/dist/core/canvas/boot.js +12 -7
  40. package/dist/core/canvas/canvas.d.ts +27 -8
  41. package/dist/core/canvas/canvas.js +54 -26
  42. package/dist/core/canvas/db.js +14 -0
  43. package/dist/core/canvas/history.js +1 -0
  44. package/dist/core/canvas/paths.d.ts +10 -9
  45. package/dist/core/canvas/paths.js +10 -9
  46. package/dist/core/canvas/pid.d.ts +155 -1
  47. package/dist/core/canvas/pid.js +306 -1
  48. package/dist/core/canvas/status-glyph.d.ts +7 -0
  49. package/dist/core/canvas/status-glyph.js +10 -1
  50. package/dist/core/canvas/types.d.ts +34 -0
  51. package/dist/core/fault-classifier.js +5 -1
  52. package/dist/core/runtime/bearings.js +4 -0
  53. package/dist/core/runtime/branded-host.d.ts +7 -0
  54. package/dist/core/runtime/branded-host.js +44 -17
  55. package/dist/core/runtime/broker-sdk.js +28 -68
  56. package/dist/core/runtime/broker.js +35 -4
  57. package/dist/core/runtime/host.d.ts +3 -3
  58. package/dist/core/runtime/host.js +148 -33
  59. package/dist/core/runtime/launch.d.ts +15 -15
  60. package/dist/core/runtime/launch.js +58 -4
  61. package/dist/core/runtime/naming.js +3 -2
  62. package/dist/core/runtime/nodes.d.ts +3 -1
  63. package/dist/core/runtime/nodes.js +1 -0
  64. package/dist/core/runtime/pi-cli.d.ts +2 -0
  65. package/dist/core/runtime/pi-cli.js +51 -0
  66. package/dist/core/runtime/placement.d.ts +1 -1
  67. package/dist/core/runtime/placement.js +5 -2
  68. package/dist/core/runtime/recap.js +2 -1
  69. package/dist/core/runtime/revive.d.ts +21 -15
  70. package/dist/core/runtime/revive.js +87 -52
  71. package/dist/core/runtime/session-cycles.d.ts +30 -0
  72. package/dist/core/runtime/session-cycles.js +77 -0
  73. package/dist/core/runtime/spawn.d.ts +4 -0
  74. package/dist/core/runtime/spawn.js +152 -100
  75. package/dist/core/runtime/tmux.d.ts +7 -10
  76. package/dist/core/runtime/tmux.js +9 -11
  77. package/dist/core/worktree.d.ts +35 -0
  78. package/dist/core/worktree.js +158 -0
  79. package/dist/daemon/crtrd.d.ts +17 -8
  80. package/dist/daemon/crtrd.js +191 -40
  81. package/dist/index.d.ts +3 -0
  82. package/dist/index.js +7 -0
  83. package/dist/pi-extensions/canvas-context-intro.d.ts +1 -0
  84. package/dist/pi-extensions/canvas-context-intro.js +34 -23
  85. package/dist/pi-extensions/canvas-stophook.js +11 -5
  86. package/dist/web-client/assets/{index-CbO8L0mN.js → index-B00YpRQ1.js} +20 -20
  87. package/dist/web-client/assets/index-DrkcvANq.css +2 -0
  88. package/dist/web-client/index.html +2 -2
  89. package/docs/compat/hearth-crtr-v1.md +191 -0
  90. package/docs/public-api.md +75 -0
  91. package/package.json +3 -4
  92. package/dist/core/__tests__/hearth-bootstrap.test.js +0 -136
  93. package/dist/core/hearth/__tests__/model-auth-guest.test.js +0 -151
  94. package/dist/core/hearth/config.d.ts +0 -3
  95. package/dist/core/hearth/config.js +0 -108
  96. package/dist/core/hearth/guest-env.d.ts +0 -9
  97. package/dist/core/hearth/guest-env.js +0 -27
  98. package/dist/core/hearth/index.d.ts +0 -4
  99. package/dist/core/hearth/index.js +0 -4
  100. package/dist/core/hearth/model-auth-guest.d.ts +0 -8
  101. package/dist/core/hearth/model-auth-guest.js +0 -430
  102. package/dist/core/hearth/provider.d.ts +0 -36
  103. package/dist/core/hearth/provider.js +0 -10
  104. package/dist/core/hearth/providers/__tests__/sweep-and-release.test.js +0 -362
  105. package/dist/core/hearth/providers/blaxel-bootstrap.d.ts +0 -12
  106. package/dist/core/hearth/providers/blaxel-bootstrap.js +0 -147
  107. package/dist/core/hearth/providers/blaxel-home.d.ts +0 -60
  108. package/dist/core/hearth/providers/blaxel-home.js +0 -405
  109. package/dist/core/hearth/providers/blaxel.d.ts +0 -36
  110. package/dist/core/hearth/providers/blaxel.js +0 -364
  111. package/dist/core/hearth/providers/types.d.ts +0 -93
  112. package/dist/core/hearth/types.d.ts +0 -155
  113. package/dist/hearth/control-plane/__tests__/error-serialization.test.js +0 -29
  114. package/dist/hearth/control-plane/__tests__/node-message.test.js +0 -60
  115. package/dist/hearth/control-plane/__tests__/oauth-serving-marker.test.d.ts +0 -1
  116. package/dist/hearth/control-plane/__tests__/oauth-serving-marker.test.js +0 -44
  117. package/dist/hearth/control-plane/__tests__/rate-limit-recurrence.test.d.ts +0 -1
  118. package/dist/hearth/control-plane/__tests__/rate-limit-recurrence.test.js +0 -49
  119. package/dist/hearth/control-plane/__tests__/relay-security.test.d.ts +0 -1
  120. package/dist/hearth/control-plane/__tests__/relay-security.test.js +0 -314
  121. package/dist/hearth/control-plane/__tests__/scheduler-scan-loop.test.d.ts +0 -1
  122. package/dist/hearth/control-plane/__tests__/scheduler-scan-loop.test.js +0 -133
  123. package/dist/hearth/control-plane/__tests__/trigger-delivery.test.d.ts +0 -1
  124. package/dist/hearth/control-plane/__tests__/trigger-delivery.test.js +0 -170
  125. package/dist/hearth/control-plane/__tests__/wake-roll.test.d.ts +0 -1
  126. package/dist/hearth/control-plane/__tests__/wake-roll.test.js +0 -230
  127. package/dist/hearth/control-plane/__tests__/webhook-ingress.test.d.ts +0 -1
  128. package/dist/hearth/control-plane/__tests__/webhook-ingress.test.js +0 -167
  129. package/dist/hearth/control-plane/config.d.ts +0 -21
  130. package/dist/hearth/control-plane/config.js +0 -77
  131. package/dist/hearth/control-plane/db.d.ts +0 -30
  132. package/dist/hearth/control-plane/db.js +0 -561
  133. package/dist/hearth/control-plane/hearth-target.d.ts +0 -23
  134. package/dist/hearth/control-plane/hearth-target.js +0 -68
  135. package/dist/hearth/control-plane/ingress/rate-limit.d.ts +0 -24
  136. package/dist/hearth/control-plane/ingress/rate-limit.js +0 -100
  137. package/dist/hearth/control-plane/ingress/route-store.d.ts +0 -31
  138. package/dist/hearth/control-plane/ingress/route-store.js +0 -61
  139. package/dist/hearth/control-plane/ingress/webhook-delivery-store.d.ts +0 -41
  140. package/dist/hearth/control-plane/ingress/webhook-delivery-store.js +0 -69
  141. package/dist/hearth/control-plane/ingress/webhook-route.d.ts +0 -55
  142. package/dist/hearth/control-plane/ingress/webhook-route.js +0 -285
  143. package/dist/hearth/control-plane/main.d.ts +0 -1
  144. package/dist/hearth/control-plane/main.js +0 -88
  145. package/dist/hearth/control-plane/node-message.d.ts +0 -31
  146. package/dist/hearth/control-plane/node-message.js +0 -98
  147. package/dist/hearth/control-plane/register.d.ts +0 -15
  148. package/dist/hearth/control-plane/register.js +0 -34
  149. package/dist/hearth/control-plane/registry.d.ts +0 -22
  150. package/dist/hearth/control-plane/registry.js +0 -168
  151. package/dist/hearth/control-plane/relay.d.ts +0 -44
  152. package/dist/hearth/control-plane/relay.js +0 -711
  153. package/dist/hearth/control-plane/scheduler/fire-store.d.ts +0 -36
  154. package/dist/hearth/control-plane/scheduler/fire-store.js +0 -73
  155. package/dist/hearth/control-plane/scheduler/recurrence.d.ts +0 -7
  156. package/dist/hearth/control-plane/scheduler/recurrence.js +0 -58
  157. package/dist/hearth/control-plane/scheduler/scan-loop.d.ts +0 -38
  158. package/dist/hearth/control-plane/scheduler/scan-loop.js +0 -138
  159. package/dist/hearth/control-plane/scheduler/schedule-store.d.ts +0 -32
  160. package/dist/hearth/control-plane/scheduler/schedule-store.js +0 -66
  161. package/dist/hearth/control-plane/secrets.d.ts +0 -31
  162. package/dist/hearth/control-plane/secrets.js +0 -134
  163. package/dist/hearth/control-plane/server.d.ts +0 -27
  164. package/dist/hearth/control-plane/server.js +0 -482
  165. package/dist/hearth/control-plane/serving.d.ts +0 -15
  166. package/dist/hearth/control-plane/serving.js +0 -106
  167. package/dist/hearth/control-plane/session.d.ts +0 -68
  168. package/dist/hearth/control-plane/session.js +0 -273
  169. package/dist/hearth/control-plane/triggers/acl.d.ts +0 -14
  170. package/dist/hearth/control-plane/triggers/acl.js +0 -52
  171. package/dist/hearth/control-plane/triggers/audit-store.d.ts +0 -38
  172. package/dist/hearth/control-plane/triggers/audit-store.js +0 -79
  173. package/dist/hearth/control-plane/triggers/deliver.d.ts +0 -43
  174. package/dist/hearth/control-plane/triggers/deliver.js +0 -76
  175. package/dist/hearth/control-plane/triggers/envelope.d.ts +0 -29
  176. package/dist/hearth/control-plane/triggers/envelope.js +0 -38
  177. package/dist/hearth/control-plane/types.d.ts +0 -86
  178. package/dist/hearth/control-plane/types.js +0 -1
  179. package/dist/hearth/control-plane/wake.d.ts +0 -86
  180. package/dist/hearth/control-plane/wake.js +0 -550
  181. package/dist/web-client/assets/index-DwO46Cs5.css +0 -2
  182. /package/dist/{core/__tests__/hearth-bootstrap.test.d.ts → commands/__tests__/revive-now-gate.test.d.ts} +0 -0
  183. /package/dist/{core/hearth/__tests__/model-auth-guest.test.d.ts → commands/sys/__tests__/setup-core.test.d.ts} +0 -0
  184. /package/dist/core/{hearth/providers/__tests__/sweep-and-release.test.d.ts → __tests__/fault-classifier.test.d.ts} +0 -0
  185. /package/dist/core/{hearth/providers/types.js → __tests__/host-teardown-process-group.test.d.ts} +0 -0
  186. /package/dist/core/{hearth/types.js → __tests__/review-model-floor.test.d.ts} +0 -0
  187. /package/dist/{hearth/control-plane/__tests__/error-serialization.test.d.ts → core/__tests__/session-cycles.test.d.ts} +0 -0
  188. /package/dist/{hearth/control-plane/__tests__/node-message.test.d.ts → core/__tests__/worktree.test.d.ts} +0 -0
@@ -1,86 +0,0 @@
1
- import type { GuestNodeId, MachineId, TenantId } from '../../core/hearth/types.js';
2
- export type HearthProvider = 'blaxel';
3
- export type HomeId = string;
4
- export type UserId = string;
5
- export type ProviderSandboxId = MachineId;
6
- export type ProviderVolumeId = string;
7
- export type PreviewEndpoint = string;
8
- export type RelayAuthRef = string;
9
- export type HomeStatus = 'provisioning' | 'running' | 'suspended' | 'restoring' | 'terminating' | 'terminated' | 'unknown';
10
- export type HomeHealthVerdict = 'healthy' | 'degraded' | 'unknown';
11
- export interface Home {
12
- home_id: HomeId;
13
- tenant_id: TenantId;
14
- user_id: UserId;
15
- provider: HearthProvider;
16
- provider_sandbox_id: ProviderSandboxId | null;
17
- provider_volume_id: ProviderVolumeId | null;
18
- preview_endpoint: PreviewEndpoint | null;
19
- home_agent_target: GuestNodeId | null;
20
- relay_auth_ref: RelayAuthRef | null;
21
- status: HomeStatus;
22
- template_version: string | null;
23
- last_ready_at: string | null;
24
- last_wake_at: string | null;
25
- last_suspend_at: string | null;
26
- last_wake_latency_ms: number | null;
27
- health_verdict: HomeHealthVerdict;
28
- created_at: string;
29
- updated_at: string;
30
- }
31
- export type ResolvedHome = Home;
32
- export interface CreateHomeInput {
33
- home_id: HomeId;
34
- tenant_id: TenantId;
35
- user_id: UserId;
36
- provider?: HearthProvider;
37
- provider_sandbox_id?: ProviderSandboxId | null;
38
- provider_volume_id?: ProviderVolumeId | null;
39
- preview_endpoint?: PreviewEndpoint | null;
40
- home_agent_target?: GuestNodeId | null;
41
- relay_auth_ref?: RelayAuthRef | null;
42
- status?: HomeStatus;
43
- template_version?: string | null;
44
- last_ready_at?: string | null;
45
- last_wake_at?: string | null;
46
- last_suspend_at?: string | null;
47
- last_wake_latency_ms?: number | null;
48
- health_verdict?: HomeHealthVerdict;
49
- created_at?: string;
50
- updated_at?: string;
51
- }
52
- export interface RefreshProviderPointersInput {
53
- provider_sandbox_id: ProviderSandboxId | null;
54
- preview_endpoint: PreviewEndpoint | null;
55
- status?: HomeStatus;
56
- template_version?: string | null;
57
- }
58
- export interface TouchWakeInput {
59
- at?: string;
60
- latency_ms?: number | null;
61
- }
62
- export type HomePatch = Partial<Pick<Home, 'provider_sandbox_id' | 'provider_volume_id' | 'preview_endpoint' | 'relay_auth_ref' | 'status' | 'template_version' | 'last_ready_at' | 'last_wake_at' | 'last_suspend_at' | 'last_wake_latency_ms' | 'health_verdict'>>;
63
- export interface TenantSession {
64
- tenant_id: TenantId;
65
- user_id: UserId;
66
- }
67
- /** The single global auto-upgrade target row (`hearth_target`, db.ts v9).
68
- * `channel` is always `'home'` (single-tenant, one image line). The DESIRED
69
- * crtr version/image the fleet rolls onto; `home.template_version` is the
70
- * ACTUAL running version. `last_bad_target_version`, when set, is a release
71
- * whose live roll already failed — the wake-path stale predicate excludes it
72
- * so no home re-rolls onto it until the target advances. */
73
- export interface HearthTarget {
74
- channel: 'home';
75
- target_template_version: string;
76
- target_image_ref: string;
77
- published_at: string;
78
- source: string;
79
- last_bad_target_version: string | null;
80
- }
81
- export interface SetHearthTargetInput {
82
- target_template_version: string;
83
- target_image_ref: string;
84
- source: string;
85
- published_at?: string;
86
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,86 +0,0 @@
1
- import { type HomeBackend } from '../../core/hearth/provider.js';
2
- import type { M0Config } from '../../core/hearth/types.js';
3
- import { type ControlPlaneConfig } from './config.js';
4
- import { getHearthTarget, recordBadTarget } from './hearth-target.js';
5
- import { getHomeById, refreshProviderPointers, setHealthVerdict, setHomeStatus, touchReady, touchWake } from './registry.js';
6
- import { resolveSecret } from './secrets.js';
7
- import type { HomeId, HomeStatus } from './types.js';
8
- export interface WakeResult {
9
- preview_endpoint: string;
10
- relayToken: string;
11
- }
12
- /** Normalize a provider-observed runtime status into the CP `HomeStatus`
13
- * vocabulary before it is ever persisted (Q3 / P3.4 review Minor finding):
14
- * the provider's `MachineState` is broad (and may include future
15
- * pause/suspend/standby spellings the SDK doesn't expose yet); CP's
16
- * `HomeStatus` enum does not have a `'paused'` member. Anything
17
- * pause/suspend/standby-shaped collapses to `'suspended'`; an exact
18
- * `'running'` passes through; everything else (provisioning, terminating,
19
- * terminated, restoring, unrecognized) becomes `'unknown'` rather than
20
- * guessing a more specific CP status from a provider-specific string. */
21
- export declare function normalizeProviderStatus(providerStatus: string | null | undefined): HomeStatus;
22
- /** One bounded attempt: open a WebSocket to `/node/<target>` carrying the
23
- * relay token and require the upgrade to both succeed AND survive a short
24
- * settle window (or yield a first frame) within `attemptTimeoutMs` — proof
25
- * the in-guest web server answered AND relayed to a live broker `view.sock`
26
- * (R-WAKE-2), not just that the SPA shell route is up. Every branch
27
- * (success, handshake rejection, error, premature close, attempt timeout)
28
- * closes the socket and resolves exactly once — a success closes gracefully
29
- * (code 1000) so the guest relay does not record a false fault, anything
30
- * else terminates it. */
31
- declare function probeNodeOnce(previewEndpoint: string, target: string, relayToken: string, attemptTimeoutMs: number): Promise<boolean>;
32
- /** Retry the single-shot probe until it confirms `/node/<target>` is serving
33
- * or `windowMs` elapses. Always runs at least one attempt (R-WAKE-1: "a
34
- * single failed probe does not abort"). Every timer this loop starts
35
- * (the per-attempt abort timeout, the inter-attempt backoff) is cleared/
36
- * resolved before the loop returns — nothing is left armed. */
37
- declare function probeNodeReady(previewEndpoint: string, target: string, relayToken: string, windowMs: number): Promise<boolean>;
38
- /** Indirection seam so a smoke/test script can swap any step (the provider
39
- * backend, the registry setters, the secret resolver, the probe itself, the
40
- * clock) without touching a real DB/provider/filesystem. Production code
41
- * never reassigns these; only ad hoc verification scripts do. */
42
- export declare const wakeInternals: {
43
- getHomeById: typeof getHomeById;
44
- getHearthTarget: typeof getHearthTarget;
45
- recordBadTarget: typeof recordBadTarget;
46
- refreshProviderPointers: typeof refreshProviderPointers;
47
- setHomeStatus: typeof setHomeStatus;
48
- setHealthVerdict: typeof setHealthVerdict;
49
- touchWake: typeof touchWake;
50
- touchReady: typeof touchReady;
51
- resolveSecret: typeof resolveSecret;
52
- getHomeBackend: (config: M0Config) => HomeBackend;
53
- loadM0Config: () => M0Config;
54
- loadControlPlaneConfig: () => ControlPlaneConfig;
55
- probeNodeOnce: typeof probeNodeOnce;
56
- probeNodeReady: typeof probeNodeReady;
57
- now: () => number;
58
- };
59
- /** Cheap, non-probing fast path: return a still-fresh warm-verdict cache hit
60
- * for `home_id`, or `null` if there is none (expired or never confirmed).
61
- * Never reads the registry and never calls the provider — callers fall back
62
- * to `ensureAwake` on a `null` (Q1: "no call to provider"). */
63
- export declare function resolveRunning(home_id: HomeId): WakeResult | null;
64
- /** Drop the cached warm verdict for a home (e.g. an upstream relay forward
65
- * failed) so the next `ensureAwake`/`resolveRunning` re-checks instead of
66
- * trusting a stale "ready" answer. */
67
- export declare function invalidateWarmVerdict(home_id: HomeId): void;
68
- /** Clear all warm verdicts and in-flight wake coalescing. Test/smoke-script
69
- * hygiene only — production never needs this (one CP process, S2). */
70
- export declare function resetWakeCacheForTests(): void;
71
- export declare function serializeError(error: unknown): string;
72
- /** Bring a home up and ready, returning the route to relay to once it is.
73
- * Reads the registry, resolves the relay token, calls the provider
74
- * wake/resume seam, ready-probes `/node/<home_agent_target>`, refreshes
75
- * provider pointers on a recreate, records wake/ready timing, clears the
76
- * health verdict to `healthy` on success, and returns
77
- * `{ preview_endpoint, relayToken }`. Throws on a ready-probe timeout
78
- * (wake-failure UX is deferred — gap note 2 — a throw is the accepted
79
- * cutover behavior).
80
- *
81
- * A fresh warm-verdict cache hit short-circuits without re-entering this
82
- * pipeline at all. Otherwise concurrent callers for the SAME `home_id`
83
- * coalesce onto one in-flight wake (Q1) instead of each driving their own
84
- * provider call. */
85
- export declare function ensureAwake(home_id: HomeId): Promise<WakeResult>;
86
- export {};