@hearsay-tools/squawk 0.19.0-dev.9082 → 0.19.0-dev.9088

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 (99) hide show
  1. package/dist/boot.js +2 -0
  2. package/dist/boot.js.map +1 -1
  3. package/dist/built-in-cli-commands.js +6 -1
  4. package/dist/built-in-cli-commands.js.map +1 -1
  5. package/dist/ci-wait/controller.d.ts +7 -7
  6. package/dist/cli-dispatch.d.ts +2 -1
  7. package/dist/cli-dispatch.js +20 -7
  8. package/dist/cli-dispatch.js.map +1 -1
  9. package/dist/contract/hosts.d.ts +161 -0
  10. package/dist/contract/index.js +116 -0
  11. package/dist/core/cli-registry.d.ts +1 -0
  12. package/dist/core/cli-registry.js.map +1 -1
  13. package/dist/core/live-topic-registry.d.ts +29 -0
  14. package/dist/core/live-topic-registry.js +68 -0
  15. package/dist/core/live-topic-registry.js.map +1 -0
  16. package/dist/core/server-hook-registry.d.ts +2 -0
  17. package/dist/core/server-hook-registry.js.map +1 -1
  18. package/dist/delegation/routes.d.ts +78 -78
  19. package/dist/features/hosts/cli.d.ts +59 -0
  20. package/dist/features/hosts/cli.js +28 -17
  21. package/dist/features/hosts/cli.js.map +1 -1
  22. package/dist/features/hosts/host-server-cli.d.ts +13 -0
  23. package/dist/features/hosts/host-server-cli.js +246 -0
  24. package/dist/features/hosts/host-server-cli.js.map +1 -0
  25. package/dist/features/hosts/host-server.d.ts +51 -0
  26. package/dist/features/hosts/host-server.js +407 -0
  27. package/dist/features/hosts/host-server.js.map +1 -0
  28. package/dist/features/hosts/index.d.ts +2 -0
  29. package/dist/features/hosts/index.js +12 -0
  30. package/dist/features/hosts/index.js.map +1 -1
  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/reports/capability.d.ts +3 -0
  41. package/dist/features/reports/capability.js +6 -0
  42. package/dist/features/reports/capability.js.map +1 -0
  43. package/dist/features/reports/index.d.ts +13 -0
  44. package/dist/features/reports/index.js +12 -0
  45. package/dist/features/reports/index.js.map +1 -0
  46. package/dist/features/reports/live-topic.d.ts +5 -0
  47. package/dist/{server/reports-topic.js → features/reports/live-topic.js} +10 -7
  48. package/dist/features/reports/live-topic.js.map +1 -0
  49. package/dist/{artifacts → features/reports}/reports-index.d.ts +5 -5
  50. package/dist/{artifacts → features/reports}/reports-index.js +7 -7
  51. package/dist/features/reports/reports-index.js.map +1 -0
  52. package/dist/{artifacts → features/reports}/reports-watch.d.ts +3 -3
  53. package/dist/{artifacts → features/reports}/reports-watch.js +2 -2
  54. package/dist/features/reports/reports-watch.js.map +1 -0
  55. package/dist/{server/reports-api.d.ts → features/reports/routes.d.ts} +6 -2
  56. package/dist/features/reports/routes.js +32 -0
  57. package/dist/features/reports/routes.js.map +1 -0
  58. package/dist/features/reports/server-hook.d.ts +8 -0
  59. package/dist/features/reports/server-hook.js +25 -0
  60. package/dist/features/reports/server-hook.js.map +1 -0
  61. package/dist/host-server-store.d.ts +103 -0
  62. package/dist/host-server-store.js +348 -0
  63. package/dist/host-server-store.js.map +1 -0
  64. package/dist/index.js +2 -2
  65. package/dist/index.js.map +1 -1
  66. package/dist/plugin/api.d.ts +3 -0
  67. package/dist/plugin/api.js +10 -1
  68. package/dist/plugin/api.js.map +1 -1
  69. package/dist/plugin/cli.js +1 -1
  70. package/dist/plugin/cli.js.map +1 -1
  71. package/dist/plugin/index.d.ts +1 -0
  72. package/dist/plugin/index.js.map +1 -1
  73. package/dist/serve-command.d.ts +10 -1
  74. package/dist/serve-command.js +63 -9
  75. package/dist/serve-command.js.map +1 -1
  76. package/dist/server/activity-routes.js +0 -2
  77. package/dist/server/activity-routes.js.map +1 -1
  78. package/dist/server/plugin-live-topics.d.ts +18 -0
  79. package/dist/server/plugin-live-topics.js +120 -0
  80. package/dist/server/plugin-live-topics.js.map +1 -0
  81. package/dist/server/project-context.js +0 -2
  82. package/dist/server/project-context.js.map +1 -1
  83. package/dist/server/repo-routes.d.ts +13 -13
  84. package/dist/server/runs-routes.d.ts +1002 -1002
  85. package/dist/server/server.d.ts +2493 -2666
  86. package/dist/server/server.js +3 -4
  87. package/dist/server/server.js.map +1 -1
  88. package/dist/server/start-server.js +6 -3
  89. package/dist/server/start-server.js.map +1 -1
  90. package/dist/server/workspace-identity-routes.d.ts +5 -5
  91. package/dist/server/workspace-live-routes.d.ts +11 -11
  92. package/dist/server/workspace-routes.d.ts +85 -85
  93. package/package.json +4 -4
  94. package/dist/artifacts/reports-index.js.map +0 -1
  95. package/dist/artifacts/reports-watch.js.map +0 -1
  96. package/dist/server/reports-api.js +0 -22
  97. package/dist/server/reports-api.js.map +0 -1
  98. package/dist/server/reports-topic.d.ts +0 -5
  99. package/dist/server/reports-topic.js.map +0 -1
@@ -0,0 +1,246 @@
1
+ /**
2
+ * `hsq host-server ensure | status | stop | resume | install-runtime`
3
+ * (spec § Architecture 2 steps 2–3 & § 6, hearsay-tools/squawk#4539).
4
+ *
5
+ * Commands executed on the remote machine to manage the hosted Squawk server, its SQLite start
6
+ * claim and pause records (`<state>/host-server.db`), and unpacked runtime versions under
7
+ * `<data>/runtime/<version>/`.
8
+ */
9
+ import { readFileSync } from 'node:fs';
10
+ import { join } from 'node:path';
11
+ import { hostServerEnsureResultSchema, hostServerInstallRuntimeResultSchema, hostServerResumeResultSchema, hostServerStatusResultSchema, hostServerStopResultSchema, hostStarterInstallIdSchema, } from '../../contract/index.js';
12
+ import { commandText } from '../../home/command.js';
13
+ import { HostServerStoreError } from '../../host-server-store.js';
14
+ import { HostCliUsageError, isHostCliHelp, parseStrictHostArgs, resolveHostCliIo, } from './cli.js';
15
+ import { ensureHostServer, getHostServerStatus, resumeHostServerAction, stopHostServer, } from './host-server.js';
16
+ import { defaultRunningPackageRoot, finalizeStagedRuntime, RuntimeArchiveError, } from './runtime-archive.js';
17
+ export const HOST_SERVER_CLI_USAGE = commandText(`usage:
18
+ cez host-server ensure --starter-id <id> [--port <n>] [--timeout-ms <n>] [--json]
19
+ adopt or start the remote hosted Squawk server
20
+ cez host-server status [--starter-id <id>] [--port <n>] [--json]
21
+ inspect the start claim, pause state, and live cockpit leases
22
+ cez host-server stop --starter-id <id> [--grace-ms <n>] [--json]
23
+ record a pause for <id> and stop its managed server if live
24
+ cez host-server resume --starter-id <id> [--json]
25
+ remove the pause record for <id>
26
+ cez host-server install-runtime --version <ver> --staged <dir> [--json]
27
+ verify and activate a staged remote runtime folder`);
28
+ function readPackageVersion() {
29
+ try {
30
+ const pkg = JSON.parse(readFileSync(join(defaultRunningPackageRoot(), 'package.json'), 'utf8'));
31
+ return pkg.version ?? '0.0.0';
32
+ }
33
+ catch {
34
+ return '0.0.0';
35
+ }
36
+ }
37
+ function parsePositiveInt(value, flag, max) {
38
+ if (value === undefined)
39
+ return undefined;
40
+ if (!/^[1-9]\d*$/.test(value)) {
41
+ throw new HostCliUsageError(`${flag} must be a positive integer, not "${value}"`);
42
+ }
43
+ const num = Number(value);
44
+ if (!Number.isSafeInteger(num) || (max !== undefined && num > max)) {
45
+ throw new HostCliUsageError(`${flag} is out of range: "${value}"`);
46
+ }
47
+ return num;
48
+ }
49
+ function requireStarterId(value, action) {
50
+ if (value === undefined) {
51
+ throw new HostCliUsageError(`${action} requires --starter-id <id>`);
52
+ }
53
+ const parsed = hostStarterInstallIdSchema.safeParse(value);
54
+ if (!parsed.success) {
55
+ throw new HostCliUsageError(`--starter-id: ${parsed.error.issues[0]?.message ?? 'invalid starter id'}`);
56
+ }
57
+ return parsed.data;
58
+ }
59
+ function parseOptionalStarterId(value) {
60
+ if (value === undefined)
61
+ return undefined;
62
+ const parsed = hostStarterInstallIdSchema.safeParse(value);
63
+ if (!parsed.success) {
64
+ throw new HostCliUsageError(`--starter-id: ${parsed.error.issues[0]?.message ?? 'invalid starter id'}`);
65
+ }
66
+ return parsed.data;
67
+ }
68
+ function parseHostServerArgv(argv) {
69
+ return parseStrictHostArgs(argv, {
70
+ 'starter-id': { type: 'string' },
71
+ port: { type: 'string' },
72
+ 'timeout-ms': { type: 'string' },
73
+ 'grace-ms': { type: 'string' },
74
+ version: { type: 'string' },
75
+ staged: { type: 'string' },
76
+ });
77
+ }
78
+ function ensureNoUnexpectedArgs(rest, action) {
79
+ if (rest.length > 0) {
80
+ throw new HostCliUsageError(`${action}: unexpected argument "${rest[0]}"`);
81
+ }
82
+ }
83
+ async function handleEnsure(values, home, io, env, deps) {
84
+ const starterInstallId = requireStarterId(values['starter-id'], 'ensure');
85
+ const port = parsePositiveInt(values.port, '--port', 65_535);
86
+ const timeoutMs = parsePositiveInt(values['timeout-ms'], '--timeout-ms');
87
+ const result = hostServerEnsureResultSchema.parse(await ensureHostServer(home, { starterInstallId, port, timeoutMs }, { env, ...deps.ops }));
88
+ if (values.json) {
89
+ io.stdout(JSON.stringify(result));
90
+ }
91
+ else if (result.status === 'ready') {
92
+ io.stdout(`ready (${result.ownership}) on port ${result.port}`);
93
+ }
94
+ else if (result.status === 'paused') {
95
+ io.stdout(`paused for ${result.starterInstallId}`);
96
+ }
97
+ else if (result.status === 'cannot-persist') {
98
+ io.stderr(`cannot-persist: ${result.reason} Run: ${result.operatorCommand}`);
99
+ }
100
+ else if (result.status === 'error') {
101
+ io.stderr(result.error);
102
+ }
103
+ else {
104
+ io.stdout(`${result.status}: ${result.reason}`);
105
+ }
106
+ return result.status === 'error' ? 1 : 0;
107
+ }
108
+ async function handleStatus(values, home, io, deps) {
109
+ const starterInstallId = parseOptionalStarterId(values['starter-id']);
110
+ const port = parsePositiveInt(values.port, '--port', 65_535);
111
+ const readOwnVersion = deps.readOwnVersion ?? readPackageVersion;
112
+ const result = hostServerStatusResultSchema.parse(await getHostServerStatus(home, { starterInstallId, port }, { ...deps.ops, readOwnVersion }));
113
+ if (values.json) {
114
+ io.stdout(JSON.stringify(result));
115
+ }
116
+ else {
117
+ io.stdout(`state=${result.state} paused=${String(result.paused)} leases=${result.leases.length}`);
118
+ }
119
+ return 0;
120
+ }
121
+ async function handleStop(values, home, io, deps) {
122
+ const starterInstallId = requireStarterId(values['starter-id'], 'stop');
123
+ const graceMs = parsePositiveInt(values['grace-ms'], '--grace-ms');
124
+ const result = hostServerStopResultSchema.parse(await stopHostServer(home, { starterInstallId, graceMs }, deps.ops));
125
+ if (values.json) {
126
+ io.stdout(JSON.stringify(result));
127
+ }
128
+ else {
129
+ io.stdout(`paused=${String(result.paused)} stopped=${String(result.stopped)} (${result.reason ?? 'ok'})`);
130
+ }
131
+ return result.reason === 'signal-failed' ? 1 : 0;
132
+ }
133
+ function handleResume(values, home, io) {
134
+ const starterInstallId = requireStarterId(values['starter-id'], 'resume');
135
+ const result = hostServerResumeResultSchema.parse(resumeHostServerAction(home, starterInstallId));
136
+ if (values.json) {
137
+ io.stdout(JSON.stringify(result));
138
+ }
139
+ else {
140
+ io.stdout(`resumed ${result.starterInstallId} (wasPaused=${String(result.wasPaused)})`);
141
+ }
142
+ return 0;
143
+ }
144
+ async function handleInstallRuntime(values, home, io, deps) {
145
+ if (!values.version) {
146
+ throw new HostCliUsageError('install-runtime requires --version <ver>');
147
+ }
148
+ if (!values.staged) {
149
+ throw new HostCliUsageError('install-runtime requires --staged <dir>');
150
+ }
151
+ const installed = await finalizeStagedRuntime({
152
+ home,
153
+ stagedDir: values.staged,
154
+ version: values.version,
155
+ deps: deps.runtimeInstall,
156
+ });
157
+ const payload = hostServerInstallRuntimeResultSchema.parse({
158
+ ok: true,
159
+ action: 'install-runtime',
160
+ ...installed,
161
+ });
162
+ if (values.json) {
163
+ io.stdout(JSON.stringify(payload));
164
+ }
165
+ else {
166
+ io.stdout(`runtime ${payload.version} ready at ${payload.runtimeDir}`);
167
+ }
168
+ return 0;
169
+ }
170
+ function reportCliError(error, action, json, io) {
171
+ const message = error instanceof Error ? error.message : String(error);
172
+ const exitCode = error instanceof HostCliUsageError ? 64 : 1;
173
+ if (json) {
174
+ if (action === 'ensure') {
175
+ const code = error instanceof HostServerStoreError && error.code === 'unreadable'
176
+ ? 'unreadable-store'
177
+ : error instanceof HostCliUsageError
178
+ ? 'invalid-input'
179
+ : 'start-failed';
180
+ io.stdout(JSON.stringify({
181
+ status: 'error',
182
+ code,
183
+ error: message,
184
+ ...(error instanceof HostServerStoreError ? { dbPath: error.dbPath } : {}),
185
+ }));
186
+ }
187
+ else {
188
+ const code = error instanceof HostServerStoreError
189
+ ? (error.code === 'unreadable' ? 'unreadable-store' : 'invalid-input')
190
+ : error instanceof RuntimeArchiveError
191
+ ? error.code
192
+ : error instanceof HostCliUsageError
193
+ ? 'invalid-input'
194
+ : 'error';
195
+ io.stdout(JSON.stringify({
196
+ ok: false,
197
+ code,
198
+ error: message,
199
+ ...(error instanceof HostServerStoreError ? { dbPath: error.dbPath } : {}),
200
+ }));
201
+ }
202
+ }
203
+ else {
204
+ io.stderr(message);
205
+ if (error instanceof HostCliUsageError)
206
+ io.stderr(`\n${HOST_SERVER_CLI_USAGE}`);
207
+ }
208
+ return exitCode;
209
+ }
210
+ export async function runHostServerCommand(argv, env, deps = {}) {
211
+ const io = resolveHostCliIo(deps);
212
+ if (isHostCliHelp(argv)) {
213
+ io.stdout(HOST_SERVER_CLI_USAGE);
214
+ return 0;
215
+ }
216
+ const wantsJson = argv.includes('--json');
217
+ let action;
218
+ try {
219
+ const { positionals, values } = parseHostServerArgv(argv);
220
+ const [head, ...rest] = positionals;
221
+ action = head;
222
+ if (!action) {
223
+ io.stdout(HOST_SERVER_CLI_USAGE);
224
+ return 0;
225
+ }
226
+ ensureNoUnexpectedArgs(rest, action);
227
+ if (!deps.home)
228
+ throw new Error('host-server command requires an operator Home');
229
+ const home = deps.home();
230
+ if (action === 'ensure')
231
+ return await handleEnsure(values, home, io, env, deps);
232
+ if (action === 'status')
233
+ return await handleStatus(values, home, io, deps);
234
+ if (action === 'stop')
235
+ return await handleStop(values, home, io, deps);
236
+ if (action === 'resume')
237
+ return handleResume(values, home, io);
238
+ if (action === 'install-runtime')
239
+ return await handleInstallRuntime(values, home, io, deps);
240
+ throw new HostCliUsageError(`unknown host-server subcommand: ${action}`);
241
+ }
242
+ catch (error) {
243
+ return reportCliError(error, action, wantsJson, io);
244
+ }
245
+ }
246
+ //# sourceMappingURL=host-server-cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-server-cli.js","sourceRoot":"","sources":["../../../src/features/hosts/host-server-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,4BAA4B,EAC5B,oCAAoC,EACpC,4BAA4B,EAC5B,4BAA4B,EAC5B,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,mBAAmB,EACnB,gBAAgB,GAEjB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,cAAc,GAEf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,mBAAmB,GAEpB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,CAAC,MAAM,qBAAqB,GAAG,WAAW,CAAC;;;;;;;;;;+EAU8B,CAAC,CAAC;AAWjF,SAAS,kBAAkB;IACzB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAA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C,CAAC;QACvE,IAAI,MAAM,KAAK,QAAQ;YAAE,OAAO,YAAY,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QAC/D,IAAI,MAAM,KAAK,iBAAiB;YAAE,OAAO,MAAM,oBAAoB,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;QAC5F,MAAM,IAAI,iBAAiB,CAAC,mCAAmC,MAAM,EAAE,CAAC,CAAC;IAC3E,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;AACH,CAAC"}
@@ -0,0 +1,51 @@
1
+ import type { HostServerEnsureResult, HostServerStatusResult, HostServerStopResult, HostServerResumeResult } from '../../contract/index.js';
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
+ import { type SpawnHostServerInput, type SpawnedHostServer, type StartMethodDetection, type StartMethodsDeps } from './start-methods.ts';
6
+ export interface HostServerOpsDeps {
7
+ isProcessLive?: ((entry: RecordedProcess) => boolean) | undefined;
8
+ readLeases?: ((home: Home) => CockpitLease[]) | undefined;
9
+ probeLoopbackPort?: ((port: number) => Promise<boolean>) | undefined;
10
+ detectStartMethod?: (() => Promise<StartMethodDetection>) | undefined;
11
+ spawnServer?: ((input: SpawnHostServerInput) => Promise<SpawnedHostServer>) | undefined;
12
+ startMethodsDeps?: StartMethodsDeps | undefined;
13
+ entryArgv?: readonly string[] | undefined;
14
+ env?: NodeJS.ProcessEnv | undefined;
15
+ nowMs?: (() => number) | undefined;
16
+ waitMs?: ((ms: number) => Promise<void>) | undefined;
17
+ readStartToken?: ((pid: number) => string | undefined) | undefined;
18
+ pidAlive?: ((pid: number) => boolean) | undefined;
19
+ sendSignal?: ((pid: number, signal: NodeJS.Signals) => void) | undefined;
20
+ readOwnVersion?: (() => string) | undefined;
21
+ }
22
+ export declare function defaultProbeLoopbackPort(port: number): Promise<boolean>;
23
+ export interface EnsureHostServerOptions {
24
+ starterInstallId: string;
25
+ port?: number | undefined;
26
+ timeoutMs?: number | undefined;
27
+ pollIntervalMs?: number | undefined;
28
+ }
29
+ /**
30
+ * `hsq host-server ensure`: inspect `host-server.db` and cockpit leases, spawn a hosted server
31
+ * with `--start-claim` only when needed and persistence is verified, and wait until ready or a
32
+ * terminal outcome is reached.
33
+ */
34
+ export declare function ensureHostServer(home: Home, options: EnsureHostServerOptions, deps?: HostServerOpsDeps): Promise<HostServerEnsureResult>;
35
+ export interface HostServerStatusOptions {
36
+ starterInstallId?: string | undefined;
37
+ port?: number | undefined;
38
+ }
39
+ /** Pure read-only status of the remote host server store and live cockpit leases. */
40
+ export declare function getHostServerStatus(home: Home, options?: HostServerStatusOptions, deps?: HostServerOpsDeps): Promise<HostServerStatusResult>;
41
+ export interface StopHostServerOptions {
42
+ starterInstallId: string;
43
+ graceMs?: number | undefined;
44
+ }
45
+ /**
46
+ * `hsq host-server stop`: atomically record the pause for `starterInstallId` and read the start
47
+ * claim, then signal ONLY a live claim owned by `starterInstallId` (verified by pid + startToken).
48
+ */
49
+ export declare function stopHostServer(home: Home, options: StopHostServerOptions, deps?: HostServerOpsDeps): Promise<HostServerStopResult>;
50
+ /** `hsq host-server resume`: atomically remove the pause record for `starterInstallId`. */
51
+ export declare function resumeHostServerAction(home: Home, starterInstallId: string): HostServerResumeResult;