@hearsay-tools/squawk 0.19.0-pr4560.9041 → 0.19.0-pr4562.9049
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/dist/contract/hosts.d.ts +141 -0
- package/dist/contract/index.d.ts +1 -0
- package/dist/contract/index.js +127 -1
- package/dist/contract/workspace.d.ts +10 -0
- package/dist/delegation/routes.d.ts +4 -4
- package/dist/delegation/transport.d.ts +14 -14
- package/dist/features/automations/tools.d.ts +8 -8
- package/dist/features/hosts/cli.d.ts +8 -0
- package/dist/features/hosts/cli.js +172 -0
- package/dist/features/hosts/cli.js.map +1 -0
- package/dist/features/hosts/index.d.ts +12 -0
- package/dist/features/hosts/index.js +34 -0
- package/dist/features/hosts/index.js.map +1 -0
- package/dist/features/hosts/registry.d.ts +52 -0
- package/dist/features/hosts/registry.js +198 -0
- package/dist/features/hosts/registry.js.map +1 -0
- package/dist/features/hosts/routes.d.ts +348 -0
- package/dist/features/hosts/routes.js +113 -0
- package/dist/features/hosts/routes.js.map +1 -0
- package/dist/features/hosts/ssh-config.d.ts +9 -0
- package/dist/features/hosts/ssh-config.js +59 -0
- package/dist/features/hosts/ssh-config.js.map +1 -0
- package/dist/home/entry-authorization.js +1 -1
- package/dist/home/entry-authorization.js.map +1 -1
- package/dist/home/home.d.ts +2 -0
- package/dist/home/home.js +1 -0
- package/dist/home/home.js.map +1 -1
- package/dist/home/migration-plan.js +1 -1
- package/dist/home/migration-plan.js.map +1 -1
- package/dist/runs/run-decode.d.ts +72 -72
- package/dist/server/live-routes.d.ts +6 -6
- package/dist/server/server.d.ts +1689 -1670
- package/dist/server/server.js +1 -1
- package/dist/server/server.js.map +1 -1
- package/dist/server/workspace-identity-routes.d.ts +29 -0
- package/dist/server/workspace-identity-routes.js +21 -0
- package/dist/server/workspace-identity-routes.js.map +1 -0
- package/dist/server/workspace-live-routes.d.ts +28 -7
- package/dist/server/workspace-live-routes.js +5 -1
- package/dist/server/workspace-live-routes.js.map +1 -1
- package/dist/workflows/continuation-admission.d.ts +72 -72
- package/dist/workflows/run/wait-engine.d.ts +72 -72
- package/dist/workspace/backups.d.ts +1 -1
- package/dist/workspace/backups.js +1 -1
- package/dist/workspace/backups.js.map +1 -1
- package/package.json +4 -4
- package/web/dist/assets/{accounts-section-JYR2cUD1.js → accounts-section-COsAMTyo.js} +1 -1
- package/web/dist/assets/{activity-motion-CNYtkGbr.js → activity-motion-76L1dElc.js} +1 -1
- package/web/dist/assets/{activity-route-DaOODJfE.js → activity-route-DdwSinTQ.js} +1 -1
- package/web/dist/assets/{agent-config-section-ChCUYJvh.js → agent-config-section-DnlY8Xbm.js} +1 -1
- package/web/dist/assets/{agent-defaults-section-D36po1w1.js → agent-defaults-section-CTqsSyJl.js} +1 -1
- package/web/dist/assets/{appearance-BaKisvC2.js → appearance-n_gwtyLp.js} +1 -1
- package/web/dist/assets/{archive-on-merge-field-UIiTWcbw.js → archive-on-merge-field-DERpOUSW.js} +1 -1
- package/web/dist/assets/attention-W6-bv4kF.js +1 -0
- package/web/dist/assets/{automations-route-CGSoXi8F.js → automations-route-0LAhg_x5.js} +1 -1
- package/web/dist/assets/{commit-list-D5mq6f1e.js → commit-list-CadGnHIA.js} +1 -1
- package/web/dist/assets/{diff-D09l13xg.js → diff-CBzW3VnD.js} +2 -2
- package/web/dist/assets/{diff-controls-6choyWOW.js → diff-controls-xM4G82ba.js} +1 -1
- package/web/dist/assets/{diff-view-DpEo21jl.js → diff-view-CsOtiJCz.js} +1 -1
- package/web/dist/assets/{discard-changes-dialog-CV4M8057.js → discard-changes-dialog-CNqUNfUn.js} +1 -1
- package/web/dist/assets/{file-preview-BuhO1VP-.js → file-preview-19dGBVJX.js} +1 -1
- package/web/dist/assets/{folder-browser-CUUWpb8F.js → folder-browser-TThsZhk0.js} +1 -1
- package/web/dist/assets/{git-toolbar-CO6UuTb4.js → git-toolbar-DBujlKow.js} +1 -1
- package/web/dist/assets/{github-B889h5f5.js → github-ZwURT9M2.js} +1 -1
- package/web/dist/assets/{global-activity-route-BkpZPyJJ.js → global-activity-route-CIVosoix.js} +1 -1
- package/web/dist/assets/{index-ChOV2nBM.js → index-D103Um8l.js} +5 -5
- package/web/dist/assets/{label-DRXJ8ljY.js → label-BXrhRQd2.js} +1 -1
- package/web/dist/assets/{markdown-C5Y3C4ot.js → markdown-LhFEpE4H.js} +1 -1
- package/web/dist/assets/{open-in-menu-CI3ceNjU.js → open-in-menu-BMkr5oG0.js} +1 -1
- package/web/dist/assets/{option-select-B70jYJmb.js → option-select-Da93ehWa.js} +1 -1
- package/web/dist/assets/{preferences-section-BqkzoH2b.js → preferences-section-B61tMP9F.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-BJOWI8lQ.js → preview-pane-connected-Ck1twV31.js} +1 -1
- package/web/dist/assets/{project-location-6FRHBXD1.js → project-location-BxI-ZznW.js} +1 -1
- package/web/dist/assets/{project-router-C53GCY_8.js → project-router-C9kvPm0I.js} +1 -1
- package/web/dist/assets/{projects-section-BqJfeeng.js → projects-section-DmTebwNS.js} +1 -1
- package/web/dist/assets/{prompt-templates-section-D76qYrSf.js → prompt-templates-section-DEW2ZnZN.js} +1 -1
- package/web/dist/assets/{queries-jsRcJKo6.js → queries-DiD4Q1Wu.js} +1 -1
- package/web/dist/assets/{reference-chip-95DURw1q.js → reference-chip-BKBFx58a.js} +1 -1
- package/web/dist/assets/{remote-settings-notice-DnWNbH2y.js → remote-settings-notice-VMKnQhpL.js} +1 -1
- package/web/dist/assets/{repo-git-BeRg8mHS.js → repo-git-C5psU7Pd.js} +1 -1
- package/web/dist/assets/{report-reader-CpJLRVEU.js → report-reader-8cCY5bW-.js} +1 -1
- package/web/dist/assets/{report-selection-DAPzf1Aa.js → report-selection-Bh4oD7_H.js} +1 -1
- package/web/dist/assets/{reports-BfFbGW9C.js → reports-Kg2iWyJ-.js} +1 -1
- package/web/dist/assets/{resources-section-Dy4MvxQ3.js → resources-section-C53gZAXt.js} +1 -1
- package/web/dist/assets/{review-panel-yvq4rZum.js → review-panel-MYGp4HC0.js} +1 -1
- package/web/dist/assets/{run-detail-refresh-DYY7EWeq.js → run-detail-refresh-DunSTM2R.js} +1 -1
- package/web/dist/assets/{run-header-Ceq-E2oX.js → run-header-C4vK0P6B.js} +1 -1
- package/web/dist/assets/{select-8oIZpehA.js → select-DXc-QPv8.js} +1 -1
- package/web/dist/assets/{session-context-section-CZqQQJGv.js → session-context-section-D3-UzL9i.js} +1 -1
- package/web/dist/assets/{settings-agent-picker-BaGf1RsO.js → settings-agent-picker-CoEypfgX.js} +1 -1
- package/web/dist/assets/{settings-save-bar-Cf4yhgkq.js → settings-save-bar-DcWNDjHM.js} +1 -1
- package/web/dist/assets/{settings-shell-z82OVv2a.js → settings-shell-CgnhBNeW.js} +1 -1
- package/web/dist/assets/{sidebar-section-qfOGEVL3.js → sidebar-section-C2OqOS5F.js} +1 -1
- package/web/dist/assets/{skills-2MhY3En5.js → skills-qgUk6jpv.js} +1 -1
- package/web/dist/assets/{tab-link-BGfSJ-ah.js → tab-link-BAAxhYEU.js} +1 -1
- package/web/dist/assets/{task-changes-lt1cfvG6.js → task-changes-DotOEkRZ.js} +1 -1
- package/web/dist/assets/{task-commits-BctQpv8y.js → task-commits-567GPEpw.js} +1 -1
- package/web/dist/assets/{task-file-scope-D5aDzxzp.js → task-file-scope-DuyZU3G4.js} +1 -1
- package/web/dist/assets/{task-files-DSBZuGO1.js → task-files-BjW6TUBB.js} +1 -1
- package/web/dist/assets/{task-github-item-DnNiAi4a.js → task-github-item-Dhr5xFce.js} +1 -1
- package/web/dist/assets/{task-groups-7p6Gvpg8.js → task-groups-DhYlsi5m.js} +1 -1
- package/web/dist/assets/{task-thread-DhI_-n7G.js → task-thread-rYoDnc1T.js} +1 -1
- package/web/dist/assets/{thread-state-BcHmo8Fn.js → thread-state-B_k1TffK.js} +1 -1
- package/web/dist/assets/{toaster-C1BFyQ8i.js → toaster-CVP6q4Vk.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-KMwiaQ7P.js → use-hand-to-agent-state-BCazCBg5.js} +1 -1
- package/web/dist/assets/use-path-bases-Br5NgJFk.js +1 -0
- package/web/dist/assets/use-workspace-config-save-DBbFEKc0.js +1 -0
- package/web/dist/assets/{workflows-CRHgSxlj.js → workflows-DTT8SRqH.js} +1 -1
- package/web/dist/assets/{workspace-tools-D0zfWP2r.js → workspace-tools-C2UU3h3_.js} +1 -1
- package/web/dist/assets/{worktrees-section-CtUlEBb7.js → worktrees-section-6bEgqVh9.js} +1 -1
- package/web/dist/index.html +12 -12
- package/web/dist/assets/attention-xl4bwNkx.js +0 -1
- package/web/dist/assets/use-path-bases-DRgUcnZ6.js +0 -1
- package/web/dist/assets/use-workspace-config-save-D2fOudMd.js +0 -1
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Multi-host cockpit contract (`packages/contract/src/hosts.ts`, spec
|
|
4
|
+
* `.ai/specs/2026-11-30-multi-host-cockpit.md`, epic hearsay-tools/squawk#4536).
|
|
5
|
+
*
|
|
6
|
+
* Node-free by construction — `zod` only. S3 widens `HOST_STATES` and `hostStateSchema`; S4 and
|
|
7
|
+
* S5 add project and index schemas alongside these exports without rewriting them.
|
|
8
|
+
*/
|
|
9
|
+
/** Host id grammar: 1–32 lowercase alphanumeric characters or hyphens, starting with `[a-z0-9]`. */
|
|
10
|
+
export declare const HOST_ID_PATTERN: RegExp;
|
|
11
|
+
/** Reserved id for the local server; never allowed as a saved remote host id. */
|
|
12
|
+
export declare const LOCAL_HOST_ID = "local";
|
|
13
|
+
export declare const hostIdSchema: z.ZodString;
|
|
14
|
+
export type HostId = z.infer<typeof hostIdSchema>;
|
|
15
|
+
export declare const hostLabelSchema: z.ZodString;
|
|
16
|
+
export declare const hostSshAliasSchema: z.ZodString;
|
|
17
|
+
export declare const hostPortSchema: z.ZodNumber;
|
|
18
|
+
/** Derive the default host id from an SSH alias (lowercased, non-alphanumeric runs to `-`, max 32). */
|
|
19
|
+
export declare function slugHostId(sshAlias: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Host states. Named schema so S3 can widen it to the full set in spec § 6
|
|
22
|
+
* (`connecting`, `connected`, `unreachable`, `needs-node`, `version-mismatch`, `not-hosted`,
|
|
23
|
+
* `identity-changed`, `several-servers`, `paused`, `cannot-persist`).
|
|
24
|
+
*/
|
|
25
|
+
export declare const HOST_STATES: readonly ['unreachable'];
|
|
26
|
+
export declare const hostStateSchema: z.ZodEnum<{
|
|
27
|
+
unreachable: "unreachable";
|
|
28
|
+
}>;
|
|
29
|
+
export type HostState = z.infer<typeof hostStateSchema>;
|
|
30
|
+
/** Default unreachable reason in S1 before SSH bootstrap (S3) exists. */
|
|
31
|
+
export declare const HOST_NOT_CONNECTED_REASON = "not connected yet";
|
|
32
|
+
/** Saved host entry in `<config>/hosts.json` (spec § Architecture 1). */
|
|
33
|
+
export declare const hostEntrySchema: z.ZodObject<{
|
|
34
|
+
id: z.ZodString;
|
|
35
|
+
label: z.ZodString;
|
|
36
|
+
kind: z.ZodLiteral<"ssh">;
|
|
37
|
+
sshAlias: z.ZodString;
|
|
38
|
+
installId: z.ZodOptional<z.ZodString>;
|
|
39
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
40
|
+
addedAt: z.ZodISODateTime;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
export type HostEntry = z.infer<typeof hostEntrySchema>;
|
|
43
|
+
/** On-disk `<config>/hosts.json` document. Rejects invalid entries and duplicate host ids. */
|
|
44
|
+
export declare const hostsRegistryFileSchema: z.ZodObject<{
|
|
45
|
+
hosts: z.ZodArray<z.ZodObject<{
|
|
46
|
+
id: z.ZodString;
|
|
47
|
+
label: z.ZodString;
|
|
48
|
+
kind: z.ZodLiteral<"ssh">;
|
|
49
|
+
sshAlias: z.ZodString;
|
|
50
|
+
installId: z.ZodOptional<z.ZodString>;
|
|
51
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
52
|
+
addedAt: z.ZodISODateTime;
|
|
53
|
+
}, z.core.$strip>>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
export type HostsRegistryFile = z.infer<typeof hostsRegistryFileSchema>;
|
|
56
|
+
/**
|
|
57
|
+
* Host item returned by `GET /api/v1/hosts` and host mutation responses.
|
|
58
|
+
* Non-`settingsAdmin` sessions receive `id`, `label` and `state` ONLY; `reason`, `kind`,
|
|
59
|
+
* `sshAlias`, `installId`, `port` and `addedAt` appear only for `settingsAdmin` (because `reason`
|
|
60
|
+
* can carry the first line of `ssh` stderr in S3+, which can name the machine behind the alias).
|
|
61
|
+
*/
|
|
62
|
+
export declare const hostSummarySchema: z.ZodObject<{
|
|
63
|
+
id: z.ZodString;
|
|
64
|
+
label: z.ZodString;
|
|
65
|
+
state: z.ZodEnum<{
|
|
66
|
+
unreachable: "unreachable";
|
|
67
|
+
}>;
|
|
68
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
69
|
+
kind: z.ZodOptional<z.ZodLiteral<"ssh">>;
|
|
70
|
+
sshAlias: z.ZodOptional<z.ZodString>;
|
|
71
|
+
installId: z.ZodOptional<z.ZodString>;
|
|
72
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
73
|
+
addedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
74
|
+
}, z.core.$strip>;
|
|
75
|
+
export type HostSummary = z.infer<typeof hostSummarySchema>;
|
|
76
|
+
/**
|
|
77
|
+
* `GET /api/v1/hosts`.
|
|
78
|
+
* `sshSuggestions` (read-only aliases from `~/.ssh/config`) is present ONLY when the session has
|
|
79
|
+
* `settingsAdmin`. `warning` is present when `<config>/hosts.json` cannot be parsed.
|
|
80
|
+
*/
|
|
81
|
+
export declare const hostsListResponseSchema: z.ZodObject<{
|
|
82
|
+
hosts: z.ZodArray<z.ZodObject<{
|
|
83
|
+
id: z.ZodString;
|
|
84
|
+
label: z.ZodString;
|
|
85
|
+
state: z.ZodEnum<{
|
|
86
|
+
unreachable: "unreachable";
|
|
87
|
+
}>;
|
|
88
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
89
|
+
kind: z.ZodOptional<z.ZodLiteral<"ssh">>;
|
|
90
|
+
sshAlias: z.ZodOptional<z.ZodString>;
|
|
91
|
+
installId: z.ZodOptional<z.ZodString>;
|
|
92
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
93
|
+
addedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
94
|
+
}, z.core.$strip>>;
|
|
95
|
+
warning: z.ZodOptional<z.ZodString>;
|
|
96
|
+
sshSuggestions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
97
|
+
}, z.core.$strip>;
|
|
98
|
+
export type HostsListResponse = z.infer<typeof hostsListResponseSchema>;
|
|
99
|
+
/** Path parameter schema for `/api/v1/hosts/:id`. */
|
|
100
|
+
export declare const hostRouteParamsSchema: z.ZodObject<{
|
|
101
|
+
id: z.ZodString;
|
|
102
|
+
}, z.core.$strip>;
|
|
103
|
+
export type HostRouteParams = z.infer<typeof hostRouteParamsSchema>;
|
|
104
|
+
/** `POST /api/v1/hosts` request body (`settingsAdmin` required). */
|
|
105
|
+
export declare const createHostInputSchema: z.ZodObject<{
|
|
106
|
+
sshAlias: z.ZodString;
|
|
107
|
+
id: z.ZodOptional<z.ZodString>;
|
|
108
|
+
label: z.ZodOptional<z.ZodString>;
|
|
109
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
110
|
+
}, z.core.$strict>;
|
|
111
|
+
export type CreateHostInput = z.infer<typeof createHostInputSchema>;
|
|
112
|
+
/** `PATCH /api/v1/hosts/:id` request body (`settingsAdmin` required). `port: null` clears a pinned port. */
|
|
113
|
+
export declare const updateHostInputSchema: z.ZodObject<{
|
|
114
|
+
label: z.ZodOptional<z.ZodString>;
|
|
115
|
+
sshAlias: z.ZodOptional<z.ZodString>;
|
|
116
|
+
port: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
117
|
+
}, z.core.$strict>;
|
|
118
|
+
export type UpdateHostInput = z.infer<typeof updateHostInputSchema>;
|
|
119
|
+
/** `POST /api/v1/hosts` (201) and `PATCH /api/v1/hosts/:id` (200) response. */
|
|
120
|
+
export declare const hostResponseSchema: z.ZodObject<{
|
|
121
|
+
host: z.ZodObject<{
|
|
122
|
+
id: z.ZodString;
|
|
123
|
+
label: z.ZodString;
|
|
124
|
+
state: z.ZodEnum<{
|
|
125
|
+
unreachable: "unreachable";
|
|
126
|
+
}>;
|
|
127
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
128
|
+
kind: z.ZodOptional<z.ZodLiteral<"ssh">>;
|
|
129
|
+
sshAlias: z.ZodOptional<z.ZodString>;
|
|
130
|
+
installId: z.ZodOptional<z.ZodString>;
|
|
131
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
132
|
+
addedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
133
|
+
}, z.core.$strip>;
|
|
134
|
+
}, z.core.$strip>;
|
|
135
|
+
export type HostResponse = z.infer<typeof hostResponseSchema>;
|
|
136
|
+
/** `DELETE /api/v1/hosts/:id` (200) response. */
|
|
137
|
+
export declare const removeHostResponseSchema: z.ZodObject<{
|
|
138
|
+
removed: z.ZodLiteral<true>;
|
|
139
|
+
id: z.ZodString;
|
|
140
|
+
}, z.core.$strip>;
|
|
141
|
+
export type RemoveHostResponse = z.infer<typeof removeHostResponseSchema>;
|
package/dist/contract/index.d.ts
CHANGED
package/dist/contract/index.js
CHANGED
|
@@ -4073,6 +4073,10 @@ var openProjectInResponseSchema = z28.object({
|
|
|
4073
4073
|
opened: z28.literal(true),
|
|
4074
4074
|
path: z28.string()
|
|
4075
4075
|
});
|
|
4076
|
+
var workspaceIdentityResponseSchema = z28.object({
|
|
4077
|
+
installId: z28.uuid(),
|
|
4078
|
+
version: z28.string()
|
|
4079
|
+
});
|
|
4076
4080
|
|
|
4077
4081
|
// ../contract/src/skills.ts
|
|
4078
4082
|
import { z as z29 } from "zod";
|
|
@@ -6388,7 +6392,7 @@ function controlLocation(control, separator = " \u2192 ") {
|
|
|
6388
6392
|
|
|
6389
6393
|
// ../contract/src/home-recovery.ts
|
|
6390
6394
|
import { z as z56 } from "zod";
|
|
6391
|
-
var HOME_FILE_PATTERN = /^(?:(?:config\.json(?:\.bak)?|agent-accounts\.json|ui-state\.json|server\.json|server\.install\.lock)|(?:remote-settings|server-instances)\/[a-zA-Z0-9-]+\.(?:json|install\.lock)|mcp-tokens\/[a-zA-Z0-9-]+\.json)$/;
|
|
6395
|
+
var HOME_FILE_PATTERN = /^(?:(?:config\.json(?:\.bak)?|agent-accounts\.json|hosts\.json|ui-state\.json|server\.json|server\.install\.lock)|(?:remote-settings|server-instances)\/[a-zA-Z0-9-]+\.(?:json|install\.lock)|mcp-tokens\/[a-zA-Z0-9-]+\.json)$/;
|
|
6392
6396
|
var homeFileSchema = z56.string().regex(HOME_FILE_PATTERN);
|
|
6393
6397
|
var recoveryFile = z56.object({
|
|
6394
6398
|
file: homeFileSchema,
|
|
@@ -6489,6 +6493,108 @@ var agentToolMetadataSchema = z60.object({
|
|
|
6489
6493
|
inputSchema: z60.object({ type: z60.literal("object"), properties: z60.record(z60.string(), z60.unknown()).optional() }).catchall(z60.unknown())
|
|
6490
6494
|
});
|
|
6491
6495
|
var agentToolCatalogSchema = z60.object({ tools: z60.array(agentToolMetadataSchema), instructions: z60.string() });
|
|
6496
|
+
|
|
6497
|
+
// ../contract/src/hosts.ts
|
|
6498
|
+
import { z as z61 } from "zod";
|
|
6499
|
+
var HOST_ID_PATTERN = /^[a-z0-9][a-z0-9-]{0,31}$/;
|
|
6500
|
+
var LOCAL_HOST_ID = "local";
|
|
6501
|
+
var CONTROL_CHARS_PATTERN = /[\u0000-\u001f\u007f]/;
|
|
6502
|
+
var INVALID_SSH_ALIAS_CHARS = /[\s*?![\]\\'"`]/;
|
|
6503
|
+
var hostIdSchema = z61.string().regex(HOST_ID_PATTERN, "host id must match ^[a-z0-9][a-z0-9-]{0,31}$").refine((value) => value !== LOCAL_HOST_ID, {
|
|
6504
|
+
message: `host id "${LOCAL_HOST_ID}" is reserved`
|
|
6505
|
+
});
|
|
6506
|
+
var hostLabelSchema = z61.string().trim().min(1, "label must not be empty").max(255, "label must be at most 255 characters").refine((value) => !CONTROL_CHARS_PATTERN.test(value), {
|
|
6507
|
+
message: "label must not contain control characters"
|
|
6508
|
+
});
|
|
6509
|
+
var hostSshAliasSchema = z61.string().min(1, "sshAlias must not be empty").max(255, "sshAlias must be at most 255 characters").refine((value) => !CONTROL_CHARS_PATTERN.test(value), {
|
|
6510
|
+
message: "sshAlias must not contain control characters"
|
|
6511
|
+
}).refine((value) => !INVALID_SSH_ALIAS_CHARS.test(value), {
|
|
6512
|
+
message: "sshAlias must not contain whitespace, quotes, or wildcard characters"
|
|
6513
|
+
}).refine((value) => !value.startsWith("-"), {
|
|
6514
|
+
message: 'sshAlias must not start with "-"'
|
|
6515
|
+
});
|
|
6516
|
+
var hostPortSchema = z61.number().int("port must be an integer").min(1, "port must be between 1 and 65535").max(65535, "port must be between 1 and 65535");
|
|
6517
|
+
function slugHostId(sshAlias) {
|
|
6518
|
+
return sshAlias.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 32).replace(/-+$/g, "");
|
|
6519
|
+
}
|
|
6520
|
+
var HOST_STATES = ["unreachable"];
|
|
6521
|
+
var hostStateSchema = z61.enum(HOST_STATES);
|
|
6522
|
+
var HOST_NOT_CONNECTED_REASON = "not connected yet";
|
|
6523
|
+
var hostEntrySchema = z61.object({
|
|
6524
|
+
id: hostIdSchema,
|
|
6525
|
+
label: hostLabelSchema,
|
|
6526
|
+
kind: z61.literal("ssh"),
|
|
6527
|
+
sshAlias: hostSshAliasSchema,
|
|
6528
|
+
installId: z61.string().min(1).max(128).optional(),
|
|
6529
|
+
port: hostPortSchema.optional(),
|
|
6530
|
+
addedAt: z61.iso.datetime()
|
|
6531
|
+
});
|
|
6532
|
+
var hostsRegistryFileSchema = z61.object({
|
|
6533
|
+
hosts: z61.array(hostEntrySchema)
|
|
6534
|
+
}).superRefine((data, ctx) => {
|
|
6535
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6536
|
+
for (const [index, entry] of data.hosts.entries()) {
|
|
6537
|
+
if (seen.has(entry.id)) {
|
|
6538
|
+
ctx.addIssue({
|
|
6539
|
+
code: "custom",
|
|
6540
|
+
path: ["hosts", index, "id"],
|
|
6541
|
+
message: `duplicate host id "${entry.id}"`
|
|
6542
|
+
});
|
|
6543
|
+
}
|
|
6544
|
+
seen.add(entry.id);
|
|
6545
|
+
}
|
|
6546
|
+
});
|
|
6547
|
+
var hostSummarySchema = z61.object({
|
|
6548
|
+
id: hostIdSchema,
|
|
6549
|
+
label: hostLabelSchema,
|
|
6550
|
+
state: hostStateSchema,
|
|
6551
|
+
reason: z61.string().optional(),
|
|
6552
|
+
kind: z61.literal("ssh").optional(),
|
|
6553
|
+
sshAlias: hostSshAliasSchema.optional(),
|
|
6554
|
+
installId: z61.string().min(1).max(128).optional(),
|
|
6555
|
+
port: hostPortSchema.optional(),
|
|
6556
|
+
addedAt: z61.iso.datetime().optional()
|
|
6557
|
+
});
|
|
6558
|
+
var hostsListResponseSchema = z61.object({
|
|
6559
|
+
hosts: z61.array(hostSummarySchema),
|
|
6560
|
+
warning: z61.string().optional(),
|
|
6561
|
+
sshSuggestions: z61.array(hostSshAliasSchema).optional()
|
|
6562
|
+
});
|
|
6563
|
+
var hostRouteParamsSchema = z61.object({
|
|
6564
|
+
id: hostIdSchema
|
|
6565
|
+
});
|
|
6566
|
+
var createHostInputSchema = z61.object({
|
|
6567
|
+
sshAlias: hostSshAliasSchema,
|
|
6568
|
+
id: hostIdSchema.optional(),
|
|
6569
|
+
label: hostLabelSchema.optional(),
|
|
6570
|
+
port: hostPortSchema.optional()
|
|
6571
|
+
}).strict().superRefine((data, ctx) => {
|
|
6572
|
+
if (data.id !== void 0) return;
|
|
6573
|
+
const derived = slugHostId(data.sshAlias);
|
|
6574
|
+
const parsed = hostIdSchema.safeParse(derived);
|
|
6575
|
+
if (!parsed.success) {
|
|
6576
|
+
ctx.addIssue({
|
|
6577
|
+
code: "custom",
|
|
6578
|
+
path: ["id"],
|
|
6579
|
+
message: parsed.error.issues[0]?.message ?? `cannot derive valid host id from "${data.sshAlias}"; provide id explicitly`
|
|
6580
|
+
});
|
|
6581
|
+
}
|
|
6582
|
+
});
|
|
6583
|
+
var updateHostInputSchema = z61.object({
|
|
6584
|
+
label: hostLabelSchema.optional(),
|
|
6585
|
+
sshAlias: hostSshAliasSchema.optional(),
|
|
6586
|
+
port: hostPortSchema.nullable().optional()
|
|
6587
|
+
}).strict().refine(
|
|
6588
|
+
(data) => data.label !== void 0 || data.sshAlias !== void 0 || data.port !== void 0,
|
|
6589
|
+
{ message: "at least one of label, sshAlias, or port must be provided" }
|
|
6590
|
+
);
|
|
6591
|
+
var hostResponseSchema = z61.object({
|
|
6592
|
+
host: hostSummarySchema
|
|
6593
|
+
});
|
|
6594
|
+
var removeHostResponseSchema = z61.object({
|
|
6595
|
+
removed: z61.literal(true),
|
|
6596
|
+
id: hostIdSchema
|
|
6597
|
+
});
|
|
6492
6598
|
export {
|
|
6493
6599
|
ACTIVITY_CHECKS_MAX,
|
|
6494
6600
|
ACTIVITY_CHECK_NAME_MAX,
|
|
@@ -6525,6 +6631,9 @@ export {
|
|
|
6525
6631
|
HANDOFF_AUTOSAVE_RECORDS_MAX,
|
|
6526
6632
|
HOME_FILE_PATTERN,
|
|
6527
6633
|
HOME_RECOVERY_REASONS,
|
|
6634
|
+
HOST_ID_PATTERN,
|
|
6635
|
+
HOST_NOT_CONNECTED_REASON,
|
|
6636
|
+
HOST_STATES,
|
|
6528
6637
|
HUMAN_ASK_EVENT_TYPES,
|
|
6529
6638
|
ISOLATED_BASELINE_REFUSAL,
|
|
6530
6639
|
LAST_WAITS_LIMIT,
|
|
@@ -6534,6 +6643,7 @@ export {
|
|
|
6534
6643
|
LIVE_PROTOCOL,
|
|
6535
6644
|
LIVE_RUN_LIMIT,
|
|
6536
6645
|
LIVE_WORKER_NAME,
|
|
6646
|
+
LOCAL_HOST_ID,
|
|
6537
6647
|
MAX_CONVERSATION_REQUEST_SECONDS,
|
|
6538
6648
|
MAX_RESUME_REQUEST_SECONDS,
|
|
6539
6649
|
NOTE_MAX,
|
|
@@ -6747,6 +6857,7 @@ export {
|
|
|
6747
6857
|
createAgentProfileInputSchema,
|
|
6748
6858
|
createAgentProfileSchema,
|
|
6749
6859
|
createAutomationInputSchema,
|
|
6860
|
+
createHostInputSchema,
|
|
6750
6861
|
createPrResponseSchema,
|
|
6751
6862
|
createProjectInputSchema,
|
|
6752
6863
|
createProjectResponseSchema,
|
|
@@ -6839,6 +6950,17 @@ export {
|
|
|
6839
6950
|
homeRecoveryReaderSchema,
|
|
6840
6951
|
homeRecoverySchema,
|
|
6841
6952
|
hostDiscoveryRequestSchema,
|
|
6953
|
+
hostEntrySchema,
|
|
6954
|
+
hostIdSchema,
|
|
6955
|
+
hostLabelSchema,
|
|
6956
|
+
hostPortSchema,
|
|
6957
|
+
hostResponseSchema,
|
|
6958
|
+
hostRouteParamsSchema,
|
|
6959
|
+
hostSshAliasSchema,
|
|
6960
|
+
hostStateSchema,
|
|
6961
|
+
hostSummarySchema,
|
|
6962
|
+
hostsListResponseSchema,
|
|
6963
|
+
hostsRegistryFileSchema,
|
|
6842
6964
|
humanAskClosedEventSchema,
|
|
6843
6965
|
humanInputDeliveredEventSchema,
|
|
6844
6966
|
humanWaitEntrySchema,
|
|
@@ -7011,6 +7133,7 @@ export {
|
|
|
7011
7133
|
registerProjectResponseSchema,
|
|
7012
7134
|
relatedRunTitleSchema,
|
|
7013
7135
|
removeAgentProfileResponseSchema,
|
|
7136
|
+
removeHostResponseSchema,
|
|
7014
7137
|
removeProjectResponseSchema,
|
|
7015
7138
|
removeQueuedMessageResponseSchema,
|
|
7016
7139
|
removeWorktreeResponseSchema,
|
|
@@ -7130,6 +7253,7 @@ export {
|
|
|
7130
7253
|
sharedWorkspaceSchema,
|
|
7131
7254
|
sidebarLimitsSchema,
|
|
7132
7255
|
skillSchema,
|
|
7256
|
+
slugHostId,
|
|
7133
7257
|
spawnGrantSchema,
|
|
7134
7258
|
sqlPrefilterTokens,
|
|
7135
7259
|
squawkAskAnswerSchema,
|
|
@@ -7177,6 +7301,7 @@ export {
|
|
|
7177
7301
|
updateAgentProfileInputSchema,
|
|
7178
7302
|
updateAgentProfileSchema,
|
|
7179
7303
|
updateAutomationInputSchema,
|
|
7304
|
+
updateHostInputSchema,
|
|
7180
7305
|
updateProjectInputSchema,
|
|
7181
7306
|
updateProjectResponseSchema,
|
|
7182
7307
|
updateProjectWebhookInputSchema,
|
|
@@ -7260,6 +7385,7 @@ export {
|
|
|
7260
7385
|
workflowsResponseSchema,
|
|
7261
7386
|
workspaceConfigResponseSchema,
|
|
7262
7387
|
workspaceEventsQuerySchema,
|
|
7388
|
+
workspaceIdentityResponseSchema,
|
|
7263
7389
|
workspaceLastLocationSchema,
|
|
7264
7390
|
workspaceReadyEventSchema,
|
|
7265
7391
|
workspaceRunDeletedEventSchema,
|
|
@@ -507,3 +507,13 @@ export declare const openProjectInResponseSchema: z.ZodObject<{
|
|
|
507
507
|
path: z.ZodString;
|
|
508
508
|
}, z.core.$strip>;
|
|
509
509
|
export type OpenProjectInResponse = z.infer<typeof openProjectInResponseSchema>;
|
|
510
|
+
/**
|
|
511
|
+
* `GET /api/v1/workspace/identity` — the home's install id (`home/install-marker.ts`) and server
|
|
512
|
+
* version, used by multi-host verification to confirm a tunnel reaches the expected machine and
|
|
513
|
+
* matching Squawk version (spec `.ai/specs/2026-11-30-multi-host-cockpit.md` § Architecture 1).
|
|
514
|
+
*/
|
|
515
|
+
export declare const workspaceIdentityResponseSchema: z.ZodObject<{
|
|
516
|
+
installId: z.ZodUUID;
|
|
517
|
+
version: z.ZodString;
|
|
518
|
+
}, z.core.$strip>;
|
|
519
|
+
export type WorkspaceIdentityResponse = z.infer<typeof workspaceIdentityResponseSchema>;
|
|
@@ -247,13 +247,13 @@ export declare function createDelegationRoutes(service: DelegationService, crede
|
|
|
247
247
|
status: 200;
|
|
248
248
|
input: {
|
|
249
249
|
json: {
|
|
250
|
-
workerIds: string[];
|
|
251
|
-
timeoutSeconds?: number | undefined;
|
|
252
|
-
mode?: "all" | "any" | "one" | undefined;
|
|
253
|
-
} | {
|
|
254
250
|
requestIds: string[];
|
|
255
251
|
mode?: "all" | "any" | "one" | undefined;
|
|
256
252
|
timeoutSeconds?: number | undefined;
|
|
253
|
+
} | {
|
|
254
|
+
workerIds: string[];
|
|
255
|
+
timeoutSeconds?: number | undefined;
|
|
256
|
+
mode?: "all" | "any" | "one" | undefined;
|
|
257
257
|
} | {
|
|
258
258
|
peerIds: string[];
|
|
259
259
|
timeoutSeconds?: number | undefined;
|
|
@@ -72,16 +72,6 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
72
72
|
"/discover": {
|
|
73
73
|
$post: {
|
|
74
74
|
output: {
|
|
75
|
-
scope: "host-default-account";
|
|
76
|
-
runners: {
|
|
77
|
-
requiresAccountHome?: boolean | undefined;
|
|
78
|
-
status: "connected" | "disconnected" | "not-installed" | "unknown";
|
|
79
|
-
enabled?: boolean | undefined;
|
|
80
|
-
hint?: string | undefined;
|
|
81
|
-
authFailureId?: string | undefined;
|
|
82
|
-
runner: string;
|
|
83
|
-
}[];
|
|
84
|
-
} | {
|
|
85
75
|
runner: string;
|
|
86
76
|
models: {
|
|
87
77
|
id: string;
|
|
@@ -92,6 +82,16 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
92
82
|
source: "cache" | "live" | "unavailable";
|
|
93
83
|
stale: boolean;
|
|
94
84
|
reason?: string | undefined;
|
|
85
|
+
} | {
|
|
86
|
+
scope: "host-default-account";
|
|
87
|
+
runners: {
|
|
88
|
+
requiresAccountHome?: boolean | undefined;
|
|
89
|
+
status: "connected" | "disconnected" | "not-installed" | "unknown";
|
|
90
|
+
enabled?: boolean | undefined;
|
|
91
|
+
hint?: string | undefined;
|
|
92
|
+
authFailureId?: string | undefined;
|
|
93
|
+
runner: string;
|
|
94
|
+
}[];
|
|
95
95
|
} | {
|
|
96
96
|
tasks: {
|
|
97
97
|
id: string;
|
|
@@ -222,13 +222,13 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
|
|
|
222
222
|
status: 200;
|
|
223
223
|
input: {
|
|
224
224
|
json: {
|
|
225
|
-
requestIds: string[];
|
|
226
|
-
mode?: "all" | "any" | "one" | undefined;
|
|
227
|
-
timeoutSeconds?: number | undefined;
|
|
228
|
-
} | {
|
|
229
225
|
workerIds: string[];
|
|
230
226
|
timeoutSeconds?: number | undefined;
|
|
231
227
|
mode?: "all" | "any" | "one" | undefined;
|
|
228
|
+
} | {
|
|
229
|
+
requestIds: string[];
|
|
230
|
+
mode?: "all" | "any" | "one" | undefined;
|
|
231
|
+
timeoutSeconds?: number | undefined;
|
|
232
232
|
} | {
|
|
233
233
|
peerIds: string[];
|
|
234
234
|
timeoutSeconds?: number | undefined;
|
|
@@ -7,6 +7,10 @@ export declare function invokeScheduleTaskTool(input: unknown): Promise<{
|
|
|
7
7
|
}[];
|
|
8
8
|
isError: boolean;
|
|
9
9
|
details: {
|
|
10
|
+
ok: false;
|
|
11
|
+
code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
|
|
12
|
+
message: string;
|
|
13
|
+
} | {
|
|
10
14
|
ok: true;
|
|
11
15
|
task: {
|
|
12
16
|
id: string;
|
|
@@ -19,10 +23,6 @@ export declare function invokeScheduleTaskTool(input: unknown): Promise<{
|
|
|
19
23
|
url?: string | undefined;
|
|
20
24
|
};
|
|
21
25
|
note: string;
|
|
22
|
-
} | {
|
|
23
|
-
ok: false;
|
|
24
|
-
code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
|
|
25
|
-
message: string;
|
|
26
26
|
};
|
|
27
27
|
}>;
|
|
28
28
|
export declare function formatScheduleTaskTool(answer: Awaited<ReturnType<typeof callScheduleTask>>): {
|
|
@@ -32,6 +32,10 @@ export declare function formatScheduleTaskTool(answer: Awaited<ReturnType<typeof
|
|
|
32
32
|
}[];
|
|
33
33
|
isError: boolean;
|
|
34
34
|
details: {
|
|
35
|
+
ok: false;
|
|
36
|
+
code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
|
|
37
|
+
message: string;
|
|
38
|
+
} | {
|
|
35
39
|
ok: true;
|
|
36
40
|
task: {
|
|
37
41
|
id: string;
|
|
@@ -44,10 +48,6 @@ export declare function formatScheduleTaskTool(answer: Awaited<ReturnType<typeof
|
|
|
44
48
|
url?: string | undefined;
|
|
45
49
|
};
|
|
46
50
|
note: string;
|
|
47
|
-
} | {
|
|
48
|
-
ok: false;
|
|
49
|
-
code: "automations_off" | "conflict" | "invalid_request" | "not_found" | "unavailable";
|
|
50
|
-
message: string;
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
53
|
export declare function invokeScheduledTasksTool(input: unknown): Promise<{
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Home } from '../../home/home.ts';
|
|
2
|
+
export declare const HOST_CLI_USAGE: string;
|
|
3
|
+
export interface HostCliDeps {
|
|
4
|
+
home?: () => Home;
|
|
5
|
+
stdout?: (line: string) => void;
|
|
6
|
+
stderr?: (line: string) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function runHostCommand(argv: string[], _env: NodeJS.ProcessEnv, deps?: HostCliDeps): Promise<number>;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `hsq host add | list | remove` (spec § Architecture 1, hearsay-tools/squawk#4537).
|
|
3
|
+
*
|
|
4
|
+
* Host-operator CLI for managing `<config>/hosts.json` directly through `HomeStore`.
|
|
5
|
+
* Works with no cockpit running; running cockpits of the same home see updates on the next read.
|
|
6
|
+
*/
|
|
7
|
+
import { parseArgs } from 'node:util';
|
|
8
|
+
import { HOST_NOT_CONNECTED_REASON } from '../../contract/index.js';
|
|
9
|
+
import { commandText } from '../../home/command.js';
|
|
10
|
+
import { HostsRegistryError, addHost, readHostsRegistry, removeHost } from './registry.js';
|
|
11
|
+
export const HOST_CLI_USAGE = commandText(`usage:
|
|
12
|
+
cez host add <ssh-alias> [--id <id>] [--label <text>] [--port <n>] [--json]
|
|
13
|
+
add a remote Squawk host to <config>/hosts.json
|
|
14
|
+
cez host list [--json] list saved remote hosts
|
|
15
|
+
cez host remove <id> [--json]
|
|
16
|
+
remove a saved remote host`);
|
|
17
|
+
class HostCliUsageError extends Error {
|
|
18
|
+
}
|
|
19
|
+
function parsePortFlag(value) {
|
|
20
|
+
if (value === undefined)
|
|
21
|
+
return undefined;
|
|
22
|
+
if (!/^[1-9]\d{0,4}$/.test(value) || Number(value) > 65_535) {
|
|
23
|
+
throw new HostCliUsageError(`--port must be an integer between 1 and 65535, not "${value}"`);
|
|
24
|
+
}
|
|
25
|
+
return Number(value);
|
|
26
|
+
}
|
|
27
|
+
function parseHostArgv(argv) {
|
|
28
|
+
try {
|
|
29
|
+
return parseArgs({
|
|
30
|
+
args: argv,
|
|
31
|
+
options: {
|
|
32
|
+
id: { type: 'string' },
|
|
33
|
+
label: { type: 'string' },
|
|
34
|
+
port: { type: 'string' },
|
|
35
|
+
json: { type: 'boolean', default: false },
|
|
36
|
+
help: { type: 'boolean', short: 'h', default: false },
|
|
37
|
+
},
|
|
38
|
+
allowPositionals: true,
|
|
39
|
+
strict: true,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
throw new HostCliUsageError(error instanceof Error ? error.message : 'invalid arguments');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function formatHostRow(entry, idWidth, labelWidth) {
|
|
47
|
+
const portSuffix = entry.port !== undefined ? ` port=${entry.port}` : '';
|
|
48
|
+
return ` · ${entry.id.padEnd(idWidth)} ${entry.label.padEnd(labelWidth)} unreachable (${HOST_NOT_CONNECTED_REASON}) ssh=${entry.sshAlias}${portSuffix}`;
|
|
49
|
+
}
|
|
50
|
+
function runList(rest, values, home, io) {
|
|
51
|
+
if (rest.length > 0)
|
|
52
|
+
throw new HostCliUsageError(`unexpected argument "${rest[0]}"`);
|
|
53
|
+
if (values.id !== undefined || values.label !== undefined || values.port !== undefined) {
|
|
54
|
+
throw new HostCliUsageError('list accepts only --json');
|
|
55
|
+
}
|
|
56
|
+
const loaded = readHostsRegistry(home);
|
|
57
|
+
if (values.json) {
|
|
58
|
+
io.stdout(JSON.stringify({
|
|
59
|
+
hosts: loaded.hosts.map((entry) => ({
|
|
60
|
+
...entry,
|
|
61
|
+
state: 'unreachable',
|
|
62
|
+
reason: HOST_NOT_CONNECTED_REASON,
|
|
63
|
+
})),
|
|
64
|
+
path: loaded.path,
|
|
65
|
+
...(loaded.warning !== undefined ? { warning: loaded.warning } : {}),
|
|
66
|
+
}, null, 2));
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
if (loaded.warning !== undefined) {
|
|
70
|
+
io.stderr(`Warning: ${loaded.warning}`);
|
|
71
|
+
}
|
|
72
|
+
if (loaded.hosts.length === 0) {
|
|
73
|
+
io.stdout('no hosts saved');
|
|
74
|
+
io.stdout(commandText('add one with: cez host add <ssh-alias>'));
|
|
75
|
+
return 0;
|
|
76
|
+
}
|
|
77
|
+
const idWidth = Math.max(...loaded.hosts.map((entry) => entry.id.length));
|
|
78
|
+
const labelWidth = Math.max(...loaded.hosts.map((entry) => entry.label.length));
|
|
79
|
+
for (const entry of loaded.hosts) {
|
|
80
|
+
io.stdout(formatHostRow(entry, idWidth, labelWidth));
|
|
81
|
+
}
|
|
82
|
+
io.stdout(`${loaded.hosts.length} host(s) — registry: ${loaded.path}`);
|
|
83
|
+
return 0;
|
|
84
|
+
}
|
|
85
|
+
function runAdd(rest, values, home, io) {
|
|
86
|
+
if (rest.length === 0)
|
|
87
|
+
throw new HostCliUsageError('add requires <ssh-alias>');
|
|
88
|
+
if (rest.length > 1)
|
|
89
|
+
throw new HostCliUsageError(`unexpected argument "${rest[1]}"`);
|
|
90
|
+
const port = parsePortFlag(values.port);
|
|
91
|
+
const created = addHost(home, {
|
|
92
|
+
sshAlias: rest[0],
|
|
93
|
+
id: values.id,
|
|
94
|
+
label: values.label,
|
|
95
|
+
port,
|
|
96
|
+
});
|
|
97
|
+
if (values.json) {
|
|
98
|
+
io.stdout(JSON.stringify({
|
|
99
|
+
ok: true,
|
|
100
|
+
host: { ...created, state: 'unreachable', reason: HOST_NOT_CONNECTED_REASON },
|
|
101
|
+
path: home.hosts,
|
|
102
|
+
}, null, 2));
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
const portText = created.port !== undefined ? ` (port ${created.port})` : '';
|
|
106
|
+
io.stdout(`added host ${created.id} (${created.label}) → ssh ${created.sshAlias}${portText}`);
|
|
107
|
+
return 0;
|
|
108
|
+
}
|
|
109
|
+
function runRemove(rest, values, home, io) {
|
|
110
|
+
if (values.id !== undefined || values.label !== undefined || values.port !== undefined) {
|
|
111
|
+
throw new HostCliUsageError('remove accepts only <id> and --json');
|
|
112
|
+
}
|
|
113
|
+
if (rest.length === 0)
|
|
114
|
+
throw new HostCliUsageError('remove requires <id>');
|
|
115
|
+
if (rest.length > 1)
|
|
116
|
+
throw new HostCliUsageError(`unexpected argument "${rest[1]}"`);
|
|
117
|
+
const removed = removeHost(home, rest[0]);
|
|
118
|
+
if (values.json) {
|
|
119
|
+
io.stdout(JSON.stringify({ ok: true, removed: true, id: removed.id, path: home.hosts }, null, 2));
|
|
120
|
+
return 0;
|
|
121
|
+
}
|
|
122
|
+
io.stdout(`removed host ${removed.id}`);
|
|
123
|
+
return 0;
|
|
124
|
+
}
|
|
125
|
+
function reportCliError(error, json, io) {
|
|
126
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
127
|
+
const code = error instanceof HostsRegistryError ? error.code : error instanceof HostCliUsageError ? 'invalid_input' : 'error';
|
|
128
|
+
const exitCode = error instanceof HostCliUsageError ? 64 : 1;
|
|
129
|
+
if (json) {
|
|
130
|
+
io.stdout(JSON.stringify({ ok: false, code, error: message }, null, 2));
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
io.stderr(message);
|
|
134
|
+
if (error instanceof HostCliUsageError)
|
|
135
|
+
io.stderr(`\n${HOST_CLI_USAGE}`);
|
|
136
|
+
}
|
|
137
|
+
return exitCode;
|
|
138
|
+
}
|
|
139
|
+
export async function runHostCommand(argv, _env, deps = {}) {
|
|
140
|
+
const io = {
|
|
141
|
+
stdout: deps.stdout ?? ((line) => console.log(line)),
|
|
142
|
+
stderr: deps.stderr ?? ((line) => console.error(line)),
|
|
143
|
+
};
|
|
144
|
+
if (argv.length === 0 || argv[0] === 'help' || argv.includes('--help') || argv.includes('-h')) {
|
|
145
|
+
io.stdout(HOST_CLI_USAGE);
|
|
146
|
+
return 0;
|
|
147
|
+
}
|
|
148
|
+
const wantsJson = argv.includes('--json');
|
|
149
|
+
try {
|
|
150
|
+
const { positionals, values } = parseHostArgv(argv);
|
|
151
|
+
const [action, ...rest] = positionals;
|
|
152
|
+
if (!action) {
|
|
153
|
+
io.stdout(HOST_CLI_USAGE);
|
|
154
|
+
return 0;
|
|
155
|
+
}
|
|
156
|
+
if (!['add', 'list', 'remove'].includes(action)) {
|
|
157
|
+
throw new HostCliUsageError(`unknown host subcommand: ${action}`);
|
|
158
|
+
}
|
|
159
|
+
if (!deps.home)
|
|
160
|
+
throw new Error('host command requires an operator Home');
|
|
161
|
+
const home = deps.home();
|
|
162
|
+
if (action === 'list')
|
|
163
|
+
return runList(rest, values, home, io);
|
|
164
|
+
if (action === 'add')
|
|
165
|
+
return runAdd(rest, values, home, io);
|
|
166
|
+
return runRemove(rest, values, home, io);
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
return reportCliError(error, wantsJson, io);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","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