@hearsay-tools/squawk 0.19.0-pr4576.9083 → 0.19.0-pr4577.9090

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 (113) hide show
  1. package/dist/built-in-cli-commands.js +6 -5
  2. package/dist/built-in-cli-commands.js.map +1 -1
  3. package/dist/built-in-launch-parts.d.ts +0 -4
  4. package/dist/built-in-launch-parts.js +1 -17
  5. package/dist/built-in-launch-parts.js.map +1 -1
  6. package/dist/ci-wait/controller.d.ts +7 -7
  7. package/dist/cli-dispatch.d.ts +2 -1
  8. package/dist/cli-dispatch.js +20 -7
  9. package/dist/cli-dispatch.js.map +1 -1
  10. package/dist/contract/hosts.d.ts +161 -0
  11. package/dist/contract/index.js +116 -0
  12. package/dist/core/cli-registry.d.ts +1 -0
  13. package/dist/core/cli-registry.js.map +1 -1
  14. package/dist/core/server-hook-registry.d.ts +17 -2
  15. package/dist/core/server-hook-registry.js +1 -0
  16. package/dist/core/server-hook-registry.js.map +1 -1
  17. package/dist/features/automations/tools.d.ts +8 -8
  18. package/dist/features/hosts/cli.d.ts +59 -0
  19. package/dist/features/hosts/cli.js +28 -17
  20. package/dist/features/hosts/cli.js.map +1 -1
  21. package/dist/features/hosts/host-server-cli.d.ts +13 -0
  22. package/dist/features/hosts/host-server-cli.js +246 -0
  23. package/dist/features/hosts/host-server-cli.js.map +1 -0
  24. package/dist/features/hosts/host-server.d.ts +51 -0
  25. package/dist/features/hosts/host-server.js +407 -0
  26. package/dist/features/hosts/host-server.js.map +1 -0
  27. package/dist/features/hosts/index.d.ts +2 -0
  28. package/dist/features/hosts/index.js +12 -0
  29. package/dist/features/hosts/index.js.map +1 -1
  30. package/dist/features/hosts/routes.d.ts +44 -44
  31. package/dist/features/hosts/runtime-archive.d.ts +103 -0
  32. package/dist/features/hosts/runtime-archive.js +619 -0
  33. package/dist/features/hosts/runtime-archive.js.map +1 -0
  34. package/dist/features/hosts/start-methods.d.ts +76 -0
  35. package/dist/features/hosts/start-methods.js +234 -0
  36. package/dist/features/hosts/start-methods.js.map +1 -0
  37. package/dist/features/hosts/tar-gz.d.ts +30 -0
  38. package/dist/features/hosts/tar-gz.js +143 -0
  39. package/dist/features/hosts/tar-gz.js.map +1 -0
  40. package/dist/features/webhooks/capability.d.ts +3 -0
  41. package/dist/features/webhooks/capability.js +6 -0
  42. package/dist/features/webhooks/capability.js.map +1 -0
  43. package/dist/features/webhooks/cli-command.d.ts +3 -0
  44. package/dist/features/webhooks/cli-command.js +10 -0
  45. package/dist/features/webhooks/cli-command.js.map +1 -0
  46. package/dist/{webhooks → features/webhooks}/cli.d.ts +2 -2
  47. package/dist/{webhooks → features/webhooks}/cli.js +7 -7
  48. package/dist/features/webhooks/cli.js.map +1 -0
  49. package/dist/features/webhooks/index.d.ts +13 -0
  50. package/dist/features/webhooks/index.js +14 -0
  51. package/dist/features/webhooks/index.js.map +1 -0
  52. package/dist/features/webhooks/launch-part.d.ts +7 -0
  53. package/dist/features/webhooks/launch-part.js +19 -0
  54. package/dist/features/webhooks/launch-part.js.map +1 -0
  55. package/dist/{webhooks → features/webhooks}/prompt.d.ts +1 -1
  56. package/dist/{webhooks → features/webhooks}/prompt.js +1 -1
  57. package/dist/features/webhooks/prompt.js.map +1 -0
  58. package/dist/features/webhooks/routes.d.ts +463 -0
  59. package/dist/features/webhooks/routes.js +177 -0
  60. package/dist/features/webhooks/routes.js.map +1 -0
  61. package/dist/features/webhooks/server-plugin.d.ts +16 -0
  62. package/dist/features/webhooks/server-plugin.js +98 -0
  63. package/dist/features/webhooks/server-plugin.js.map +1 -0
  64. package/dist/{runs → features/webhooks}/webhook.d.ts +5 -5
  65. package/dist/{runs → features/webhooks}/webhook.js +16 -10
  66. package/dist/features/webhooks/webhook.js.map +1 -0
  67. package/dist/host-server-store.d.ts +103 -0
  68. package/dist/host-server-store.js +348 -0
  69. package/dist/host-server-store.js.map +1 -0
  70. package/dist/index.js +2 -2
  71. package/dist/index.js.map +1 -1
  72. package/dist/plugin/index.d.ts +1 -1
  73. package/dist/plugin/index.js.map +1 -1
  74. package/dist/serve-command.d.ts +12 -3
  75. package/dist/serve-command.js +76 -18
  76. package/dist/serve-command.js.map +1 -1
  77. package/dist/server/live-routes.d.ts +6 -6
  78. package/dist/server/plugin-server-hooks.d.ts +12 -1
  79. package/dist/server/plugin-server-hooks.js +33 -0
  80. package/dist/server/plugin-server-hooks.js.map +1 -1
  81. package/dist/server/project-settings-routes.d.ts +0 -90
  82. package/dist/server/project-settings-routes.js +0 -30
  83. package/dist/server/project-settings-routes.js.map +1 -1
  84. package/dist/server/projects-routes.d.ts +1 -376
  85. package/dist/server/projects-routes.js +2 -137
  86. package/dist/server/projects-routes.js.map +1 -1
  87. package/dist/server/provider-sign-in-routes.d.ts +2 -2
  88. package/dist/server/providers-routes.d.ts +58 -58
  89. package/dist/server/repo-routes.d.ts +52 -52
  90. package/dist/server/runners-routes.d.ts +10 -10
  91. package/dist/server/runs-routes.d.ts +984 -1002
  92. package/dist/server/runs-routes.js +6 -11
  93. package/dist/server/runs-routes.js.map +1 -1
  94. package/dist/server/server-deps.d.ts +1 -4
  95. package/dist/server/server-deps.js +3 -7
  96. package/dist/server/server-deps.js.map +1 -1
  97. package/dist/server/server.d.ts +520 -1100
  98. package/dist/server/server.js +10 -16
  99. package/dist/server/server.js.map +1 -1
  100. package/dist/server/start-run-options.d.ts +5 -3
  101. package/dist/server/start-run-options.js +8 -3
  102. package/dist/server/start-run-options.js.map +1 -1
  103. package/dist/server/start-server.js +8 -11
  104. package/dist/server/start-server.js.map +1 -1
  105. package/dist/server/workspace-live-routes.d.ts +11 -11
  106. package/dist/server/workspace-projects.d.ts +2 -5
  107. package/dist/server/workspace-projects.js +10 -11
  108. package/dist/server/workspace-projects.js.map +1 -1
  109. package/dist/server/workspace-routes.d.ts +85 -85
  110. package/package.json +4 -4
  111. package/dist/runs/webhook.js.map +0 -1
  112. package/dist/webhooks/cli.js.map +0 -1
  113. package/dist/webhooks/prompt.js.map +0 -1
@@ -34,20 +34,10 @@ export declare function createHostsRoutes(deps: HostsRouteDeps): import("hono/ho
34
34
  "/hosts": {
35
35
  $post: {
36
36
  output: {
37
- host: {
38
- id: string;
39
- label: string;
40
- state: "unreachable";
41
- reason?: string | undefined;
42
- kind?: "ssh" | undefined;
43
- sshAlias?: string | undefined;
44
- installId?: string | undefined;
45
- port?: number | undefined;
46
- addedAt?: string | undefined;
47
- };
37
+ error: string;
48
38
  };
49
39
  outputFormat: "json";
50
- status: 201;
40
+ status: 404;
51
41
  input: {
52
42
  json: {
53
43
  sshAlias: string;
@@ -75,7 +65,7 @@ export declare function createHostsRoutes(deps: HostsRouteDeps): import("hono/ho
75
65
  error: string;
76
66
  };
77
67
  outputFormat: "json";
78
- status: 404;
68
+ status: 409;
79
69
  input: {
80
70
  json: {
81
71
  sshAlias: string;
@@ -89,7 +79,7 @@ export declare function createHostsRoutes(deps: HostsRouteDeps): import("hono/ho
89
79
  error: string;
90
80
  };
91
81
  outputFormat: "json";
92
- status: 409;
82
+ status: 500;
93
83
  input: {
94
84
  json: {
95
85
  sshAlias: string;
@@ -100,10 +90,20 @@ export declare function createHostsRoutes(deps: HostsRouteDeps): import("hono/ho
100
90
  };
101
91
  } | {
102
92
  output: {
103
- error: string;
93
+ host: {
94
+ id: string;
95
+ label: string;
96
+ state: "unreachable";
97
+ reason?: string | undefined;
98
+ kind?: "ssh" | undefined;
99
+ sshAlias?: string | undefined;
100
+ installId?: string | undefined;
101
+ port?: number | undefined;
102
+ addedAt?: string | undefined;
103
+ };
104
104
  };
105
105
  outputFormat: "json";
106
- status: 409;
106
+ status: 201;
107
107
  input: {
108
108
  json: {
109
109
  sshAlias: string;
@@ -117,7 +117,7 @@ export declare function createHostsRoutes(deps: HostsRouteDeps): import("hono/ho
117
117
  error: string;
118
118
  };
119
119
  outputFormat: "json";
120
- status: 500;
120
+ status: 409;
121
121
  input: {
122
122
  json: {
123
123
  sshAlias: string;
@@ -132,20 +132,11 @@ export declare function createHostsRoutes(deps: HostsRouteDeps): import("hono/ho
132
132
  "/hosts/:id": {
133
133
  $patch: {
134
134
  output: {
135
- host: {
136
- id: string;
137
- label: string;
138
- state: "unreachable";
139
- reason?: string | undefined;
140
- kind?: "ssh" | undefined;
141
- sshAlias?: string | undefined;
142
- installId?: string | undefined;
143
- port?: number | undefined;
144
- addedAt?: string | undefined;
145
- };
135
+ error: string;
136
+ code?: "invalid_input" | undefined;
146
137
  };
147
138
  outputFormat: "json";
148
- status: 200;
139
+ status: 400;
149
140
  input: {
150
141
  param: {
151
142
  id: string;
@@ -160,10 +151,9 @@ export declare function createHostsRoutes(deps: HostsRouteDeps): import("hono/ho
160
151
  } | {
161
152
  output: {
162
153
  error: string;
163
- code?: "invalid_input" | undefined;
164
154
  };
165
155
  outputFormat: "json";
166
- status: 400;
156
+ status: 404;
167
157
  input: {
168
158
  param: {
169
159
  id: string;
@@ -197,7 +187,7 @@ export declare function createHostsRoutes(deps: HostsRouteDeps): import("hono/ho
197
187
  error: string;
198
188
  };
199
189
  outputFormat: "json";
200
- status: 404;
190
+ status: 409;
201
191
  input: {
202
192
  param: {
203
193
  id: string;
@@ -214,7 +204,7 @@ export declare function createHostsRoutes(deps: HostsRouteDeps): import("hono/ho
214
204
  error: string;
215
205
  };
216
206
  outputFormat: "json";
217
- status: 409;
207
+ status: 500;
218
208
  input: {
219
209
  param: {
220
210
  id: string;
@@ -245,10 +235,20 @@ export declare function createHostsRoutes(deps: HostsRouteDeps): import("hono/ho
245
235
  };
246
236
  } | {
247
237
  output: {
248
- error: string;
238
+ host: {
239
+ id: string;
240
+ label: string;
241
+ state: "unreachable";
242
+ reason?: string | undefined;
243
+ kind?: "ssh" | undefined;
244
+ sshAlias?: string | undefined;
245
+ installId?: string | undefined;
246
+ port?: number | undefined;
247
+ addedAt?: string | undefined;
248
+ };
249
249
  };
250
250
  outputFormat: "json";
251
- status: 500;
251
+ status: 200;
252
252
  input: {
253
253
  param: {
254
254
  id: string;
@@ -266,11 +266,11 @@ export declare function createHostsRoutes(deps: HostsRouteDeps): import("hono/ho
266
266
  "/hosts/:id": {
267
267
  $delete: {
268
268
  output: {
269
- removed: true;
270
- id: string;
269
+ error: string;
270
+ code?: "invalid_input" | undefined;
271
271
  };
272
272
  outputFormat: "json";
273
- status: 200;
273
+ status: 400;
274
274
  input: {
275
275
  param: {
276
276
  id: string;
@@ -279,10 +279,9 @@ export declare function createHostsRoutes(deps: HostsRouteDeps): import("hono/ho
279
279
  } | {
280
280
  output: {
281
281
  error: string;
282
- code?: "invalid_input" | undefined;
283
282
  };
284
283
  outputFormat: "json";
285
- status: 400;
284
+ status: 404;
286
285
  input: {
287
286
  param: {
288
287
  id: string;
@@ -304,7 +303,7 @@ export declare function createHostsRoutes(deps: HostsRouteDeps): import("hono/ho
304
303
  error: string;
305
304
  };
306
305
  outputFormat: "json";
307
- status: 404;
306
+ status: 409;
308
307
  input: {
309
308
  param: {
310
309
  id: string;
@@ -315,7 +314,7 @@ export declare function createHostsRoutes(deps: HostsRouteDeps): import("hono/ho
315
314
  error: string;
316
315
  };
317
316
  outputFormat: "json";
318
- status: 409;
317
+ status: 500;
319
318
  input: {
320
319
  param: {
321
320
  id: string;
@@ -334,10 +333,11 @@ export declare function createHostsRoutes(deps: HostsRouteDeps): import("hono/ho
334
333
  };
335
334
  } | {
336
335
  output: {
337
- error: string;
336
+ removed: true;
337
+ id: string;
338
338
  };
339
339
  outputFormat: "json";
340
- status: 500;
340
+ status: 200;
341
341
  input: {
342
342
  param: {
343
343
  id: string;
@@ -0,0 +1,103 @@
1
+ import type { Writable } from 'node:stream';
2
+ import { type RecordedProcess } from '../../core/process-stat.ts';
3
+ import type { Home } from '../../home/home.ts';
4
+ import { type CockpitLease } from '../../home/leases.ts';
5
+ export type RuntimeArchiveErrorCode = 'missing_build' | 'missing_dependency' | 'invalid_version' | 'corrupt_archive' | 'verification_failed' | 'escaping_link' | 'invalid_staged_dir';
6
+ export declare class RuntimeArchiveError extends Error {
7
+ readonly code: RuntimeArchiveErrorCode;
8
+ constructor(code: RuntimeArchiveErrorCode, message: string);
9
+ }
10
+ /** Named error thrown when the resolved production dependency closure contains a native module. */
11
+ export declare class NativeModuleError extends Error {
12
+ readonly code: 'native_module';
13
+ readonly packageName: string;
14
+ readonly reason: string;
15
+ readonly filePath?: string | undefined;
16
+ constructor(packageName: string, reason: string, filePath?: string);
17
+ }
18
+ export interface ResolvedDependencyPackage {
19
+ archivePath: string;
20
+ sourceDir: string;
21
+ name: string;
22
+ version: string;
23
+ }
24
+ export interface ProductionClosure {
25
+ packageRoot: string;
26
+ name: string;
27
+ version: string;
28
+ packages: ResolvedDependencyPackage[];
29
+ }
30
+ /** Default root of the running Squawk package (`packages/cezar` or installed package dir). */
31
+ export declare function defaultRunningPackageRoot(): string;
32
+ export declare function hostRuntimesDir(home: Pick<Home, 'data'>): string;
33
+ export declare function validateRuntimeVersion(version: string): string;
34
+ export declare function hostRuntimeVersionDir(home: Pick<Home, 'data'>, version: string): string;
35
+ /**
36
+ * Resolve the production dependency closure of `packageRoot` following Node.js resolution.
37
+ * Rejects any native module in the closure with `NativeModuleError`.
38
+ */
39
+ export declare function resolveProductionClosure(packageRoot?: string): ProductionClosure;
40
+ export interface BuildRuntimeArchiveOptions {
41
+ packageRoot?: string | undefined;
42
+ outputPath?: string | undefined;
43
+ }
44
+ export interface BuiltRuntimeArchive {
45
+ version: string;
46
+ packageCount: number;
47
+ entryCount: number;
48
+ buffer?: Buffer | undefined;
49
+ outputPath?: string | undefined;
50
+ }
51
+ /** Build the runtime `.tar.gz` archive (writing atomically to `outputPath` or returning a `Buffer`). */
52
+ export declare function buildRuntimeArchive(options?: BuildRuntimeArchiveOptions): Promise<BuiltRuntimeArchive>;
53
+ /** Stream the runtime `.tar.gz` archive directly to a `Writable` (such as an SSH child's stdin). */
54
+ export declare function streamRuntimeArchive(destination: Writable, options?: {
55
+ packageRoot?: string | undefined;
56
+ }): Promise<{
57
+ version: string;
58
+ packageCount: number;
59
+ entryCount: number;
60
+ }>;
61
+ export interface RuntimeInstallDeps {
62
+ isProcessLive?: ((entry: RecordedProcess) => boolean) | undefined;
63
+ readProcessCommand?: ((pid: number) => string | undefined) | undefined;
64
+ listProcessCommands?: (() => string[] | undefined) | undefined;
65
+ verifyRuntime?: ((pkgDir: string, expectedVersion: string) => Promise<void>) | undefined;
66
+ readLeases?: ((home: Home) => CockpitLease[]) | undefined;
67
+ nowMs?: (() => number) | undefined;
68
+ unownedTempGraceMs?: number | undefined;
69
+ }
70
+ /**
71
+ * Remove stale `.runtime-tmp-*` folders beside `<data>/runtime/`:
72
+ * - Folders with an `owner.json` whose recorded process is dead are swept immediately.
73
+ * - Folders without `owner.json` (creation window or external shell `tar` staging) are kept until
74
+ * older than `unownedTempGraceMs` so concurrent cross-process installs cannot delete each other.
75
+ */
76
+ export declare function sweepStaleRuntimeTempDirs(home: Pick<Home, 'data'>, deps?: Pick<RuntimeInstallDeps, 'isProcessLive' | 'nowMs' | 'unownedTempGraceMs'>): string[];
77
+ /** Check an unpacked runtime by running its own `hsq --version` and comparing stdout to `expectedVersion`. */
78
+ export declare function verifyStagedRuntime(pkgDir: string, expectedVersion: string): Promise<void>;
79
+ /**
80
+ * Remove old `<data>/runtime/<version>/` folders when no server runs from them.
81
+ * Fails safe: keeps any version held by a live start claim, a live cockpit lease, or any running
82
+ * process of the user whose command line references it (protecting servers spawned from an old
83
+ * runtime before they commit their claim); skips pruning if `host-server.db`, leases, or process
84
+ * commands cannot be read.
85
+ */
86
+ export declare function pruneOldRuntimes(home: Home, keepVersion: string, deps?: Pick<RuntimeInstallDeps, 'isProcessLive' | 'readProcessCommand' | 'listProcessCommands' | 'readLeases'>): string[];
87
+ export interface InstallRuntimeResult {
88
+ version: string;
89
+ runtimeDir: string;
90
+ alreadyInstalled: boolean;
91
+ prunedVersions: string[];
92
+ }
93
+ /**
94
+ * Verify a staged runtime folder beside `<data>/runtime/`, atomically rename it to
95
+ * `<data>/runtime/<version>/`, clean up the temporary folder, sweep stale temp folders, and prune
96
+ * unused old runtime versions.
97
+ */
98
+ export declare function finalizeStagedRuntime(input: {
99
+ home: Home;
100
+ stagedDir: string;
101
+ version: string;
102
+ deps?: RuntimeInstallDeps | undefined;
103
+ }): Promise<InstallRuntimeResult>;