@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,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bundled multi-host feature (`packages/cezar/src/features/hosts/`, spec
|
|
3
|
+
* `.ai/specs/2026-11-30-multi-host-cockpit.md`, hearsay-tools/squawk#4537): registers `hsq host`
|
|
4
|
+
* and workspace-scoped `/api/v1/hosts*` routes solely through `SquawkPluginApi`. Nothing outside
|
|
5
|
+
* this folder imports it.
|
|
6
|
+
*/
|
|
7
|
+
import type { CliCommandDefinition, HttpBundleRouteDefinition, SquawkPluginApi } from '../../plugin/index.ts';
|
|
8
|
+
/** `hsq host`: operator CLI for `<config>/hosts.json`. */
|
|
9
|
+
export declare const hostCliCommand: CliCommandDefinition;
|
|
10
|
+
/** Workspace-scoped `/api/v1/hosts` and `/api/v1/hosts/:id` HTTP route bundle. */
|
|
11
|
+
export declare const hostsHttpRoute: HttpBundleRouteDefinition;
|
|
12
|
+
export default function setup(api: SquawkPluginApi): void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createHostsRoutes } from './routes.js';
|
|
2
|
+
/** `hsq host`: operator CLI for `<config>/hosts.json`. */
|
|
3
|
+
export const hostCliCommand = {
|
|
4
|
+
name: 'host',
|
|
5
|
+
usage: [
|
|
6
|
+
' cez host add <ssh-alias> [--id <id>] [--label <text>] [--port <n>] add a remote host',
|
|
7
|
+
' cez host list [--json] list saved remote hosts',
|
|
8
|
+
' cez host remove <id> remove a saved remote host',
|
|
9
|
+
],
|
|
10
|
+
parseMode: 'subcommand',
|
|
11
|
+
homeMode: 'conditional',
|
|
12
|
+
runtimeMode: 'none',
|
|
13
|
+
load: async (home) => async (argv, env) => (await import('./cli.js')).runHostCommand(argv, env, { home: () => home(env) }),
|
|
14
|
+
};
|
|
15
|
+
/** Workspace-scoped `/api/v1/hosts` and `/api/v1/hosts/:id` HTTP route bundle. */
|
|
16
|
+
export const hostsHttpRoute = {
|
|
17
|
+
kind: 'bundle',
|
|
18
|
+
id: 'hosts',
|
|
19
|
+
scope: 'workspace',
|
|
20
|
+
createRoutes: (context) => {
|
|
21
|
+
if (!context.server) {
|
|
22
|
+
throw new Error('HTTP routes: hosts bundle requires server plugin context.');
|
|
23
|
+
}
|
|
24
|
+
return createHostsRoutes({
|
|
25
|
+
home: context.home,
|
|
26
|
+
capabilities: context.server.capabilities,
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
export default function setup(api) {
|
|
31
|
+
api.registerCliCommand(hostCliCommand);
|
|
32
|
+
api.registerHttpRoute(hostsHttpRoute);
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/features/hosts/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,0DAA0D;AAC1D,MAAM,CAAC,MAAM,cAAc,GAAyB;IAClD,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE;QACL,yFAAyF;QACzF,oEAAoE;QACpE,uEAAuE;KACxE;IACD,SAAS,EAAE,YAAY;IACvB,QAAQ,EAAE,aAAa;IACvB,WAAW,EAAE,MAAM;IACnB,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,CACxC,CAAC,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;CAClF,CAAC;AAEF,kFAAkF;AAClF,MAAM,CAAC,MAAM,cAAc,GAA8B;IACvD,IAAI,EAAE,QAAQ;IACd,EAAE,EAAE,OAAO;IACX,KAAK,EAAE,WAAW;IAClB,YAAY,EAAE,CAAC,OAAO,EAAE,EAAE;QACxB,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;QAC/E,CAAC;QACD,OAAO,iBAAiB,CAAC;YACvB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,YAAY;SAC1C,CAAC,CAAC;IACL,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,GAAoB;IAChD,GAAG,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;IACvC,GAAG,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Saved remote host registry (`<config>/hosts.json`, mode `0600` via `HomeStore`).
|
|
3
|
+
*
|
|
4
|
+
* Every read parses the file fresh so multiple cockpits sharing one home stay in sync without
|
|
5
|
+
* restart. Every write parses the file inside the `HomeStore` write lock first and refuses to
|
|
6
|
+
* overwrite a file that cannot be parsed (spec § Architecture 1, Lock and ownership cases).
|
|
7
|
+
*/
|
|
8
|
+
import { type HostEntry } from '../../contract/index.js';
|
|
9
|
+
import type { Home } from '../../home/home.ts';
|
|
10
|
+
export type HostsRegistryErrorCode = 'corrupt' | 'duplicate' | 'not_found' | 'outside_write' | 'invalid_input';
|
|
11
|
+
export declare class HostsRegistryError extends Error {
|
|
12
|
+
readonly code: HostsRegistryErrorCode;
|
|
13
|
+
constructor(code: HostsRegistryErrorCode, message: string);
|
|
14
|
+
}
|
|
15
|
+
export interface HostsRegistryReadResult {
|
|
16
|
+
hosts: HostEntry[];
|
|
17
|
+
path: string;
|
|
18
|
+
/** Operator-facing warning (includes path details for CLI output). */
|
|
19
|
+
warning?: string;
|
|
20
|
+
/** Path-free warning safe for HTTP responses across local and hosted sessions. */
|
|
21
|
+
httpWarning?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface AddHostInput {
|
|
24
|
+
sshAlias: string;
|
|
25
|
+
id?: string | undefined;
|
|
26
|
+
label?: string | undefined;
|
|
27
|
+
port?: number | undefined;
|
|
28
|
+
now?: Date | undefined;
|
|
29
|
+
}
|
|
30
|
+
export interface UpdateHostPatch {
|
|
31
|
+
label?: string | undefined;
|
|
32
|
+
sshAlias?: string | undefined;
|
|
33
|
+
port?: number | null | undefined;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Read `<config>/hosts.json` fresh from disk.
|
|
37
|
+
* - Missing file: returns empty host list with no warning and writes nothing.
|
|
38
|
+
* - Unreadable or unparseable file: returns empty host list with a warning; never modifies disk.
|
|
39
|
+
*/
|
|
40
|
+
export declare function readHostsRegistry(home: Home): HostsRegistryReadResult;
|
|
41
|
+
/** Read one host entry fresh from disk before acting on it. */
|
|
42
|
+
export declare function getHostById(home: Home, id: string): {
|
|
43
|
+
host?: HostEntry;
|
|
44
|
+
warning?: string;
|
|
45
|
+
httpWarning?: string;
|
|
46
|
+
};
|
|
47
|
+
/** Add a new SSH host entry to `<config>/hosts.json` via `HomeStore` (mode `0600`). */
|
|
48
|
+
export declare function addHost(home: Home, input: AddHostInput): HostEntry;
|
|
49
|
+
/** Update an existing host entry's label, SSH alias, or pinned port (`port: null` clears it). */
|
|
50
|
+
export declare function updateHost(home: Home, id: string, patch: UpdateHostPatch): HostEntry;
|
|
51
|
+
/** Remove a saved host entry by id. Refuses to overwrite a corrupt `hosts.json`. */
|
|
52
|
+
export declare function removeHost(home: Home, id: string): HostEntry;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Saved remote host registry (`<config>/hosts.json`, mode `0600` via `HomeStore`).
|
|
3
|
+
*
|
|
4
|
+
* Every read parses the file fresh so multiple cockpits sharing one home stay in sync without
|
|
5
|
+
* restart. Every write parses the file inside the `HomeStore` write lock first and refuses to
|
|
6
|
+
* overwrite a file that cannot be parsed (spec § Architecture 1, Lock and ownership cases).
|
|
7
|
+
*/
|
|
8
|
+
import { createHostInputSchema, hostEntrySchema, hostIdSchema, hostsRegistryFileSchema, slugHostId, updateHostInputSchema, } from '../../contract/index.js';
|
|
9
|
+
import { HomeOutsideWriteError, HomeStore, readHomeFile } from '../../home/store.js';
|
|
10
|
+
export class HostsRegistryError extends Error {
|
|
11
|
+
code;
|
|
12
|
+
constructor(code, message) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = 'HostsRegistryError';
|
|
15
|
+
this.code = code;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function parseRawHostsContent(content, path) {
|
|
19
|
+
let decoded;
|
|
20
|
+
try {
|
|
21
|
+
decoded = JSON.parse(content);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return {
|
|
25
|
+
ok: false,
|
|
26
|
+
warning: `Could not parse ${path}: invalid JSON; no hosts were loaded.`,
|
|
27
|
+
httpWarning: 'hosts.json could not be parsed; no hosts were loaded.',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const parsed = hostsRegistryFileSchema.safeParse(decoded);
|
|
31
|
+
if (!parsed.success) {
|
|
32
|
+
const detail = parsed.error.issues
|
|
33
|
+
.map((issue) => (issue.path.length > 0 ? `${issue.path.join('.')}: ${issue.message}` : issue.message))
|
|
34
|
+
.join('; ');
|
|
35
|
+
return {
|
|
36
|
+
ok: false,
|
|
37
|
+
warning: `Could not parse ${path}: ${detail}; no hosts were loaded.`,
|
|
38
|
+
httpWarning: 'hosts.json contains invalid host entries; no hosts were loaded.',
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return { ok: true, hosts: parsed.data.hosts };
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Read `<config>/hosts.json` fresh from disk.
|
|
45
|
+
* - Missing file: returns empty host list with no warning and writes nothing.
|
|
46
|
+
* - Unreadable or unparseable file: returns empty host list with a warning; never modifies disk.
|
|
47
|
+
*/
|
|
48
|
+
export function readHostsRegistry(home) {
|
|
49
|
+
const path = home.hosts;
|
|
50
|
+
let content;
|
|
51
|
+
try {
|
|
52
|
+
content = readHomeFile(path, home);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (error.code === 'ENOENT') {
|
|
56
|
+
return { hosts: [], path };
|
|
57
|
+
}
|
|
58
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
59
|
+
return {
|
|
60
|
+
hosts: [],
|
|
61
|
+
path,
|
|
62
|
+
warning: `Could not read ${path}: ${detail}; no hosts were loaded.`,
|
|
63
|
+
httpWarning: 'hosts.json could not be read; no hosts were loaded.',
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const parsed = parseRawHostsContent(content, path);
|
|
67
|
+
if (!parsed.ok) {
|
|
68
|
+
return { hosts: [], path, warning: parsed.warning, httpWarning: parsed.httpWarning };
|
|
69
|
+
}
|
|
70
|
+
return { hosts: parsed.hosts, path };
|
|
71
|
+
}
|
|
72
|
+
/** Read one host entry fresh from disk before acting on it. */
|
|
73
|
+
export function getHostById(home, id) {
|
|
74
|
+
const loaded = readHostsRegistry(home);
|
|
75
|
+
const host = loaded.hosts.find((entry) => entry.id === id);
|
|
76
|
+
return {
|
|
77
|
+
...(host !== undefined ? { host } : {}),
|
|
78
|
+
...(loaded.warning !== undefined ? { warning: loaded.warning } : {}),
|
|
79
|
+
...(loaded.httpWarning !== undefined ? { httpWarning: loaded.httpWarning } : {}),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/** Parse `<config>/hosts.json` inside a write lock, throwing `corrupt` instead of overwriting. */
|
|
83
|
+
function readHostsForWrite(home) {
|
|
84
|
+
const path = home.hosts;
|
|
85
|
+
let content;
|
|
86
|
+
try {
|
|
87
|
+
content = readHomeFile(path, home);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
if (error.code === 'ENOENT')
|
|
91
|
+
return [];
|
|
92
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
93
|
+
throw new HostsRegistryError('corrupt', `Refusing to overwrite unreadable ${path}: ${detail}`);
|
|
94
|
+
}
|
|
95
|
+
const parsed = parseRawHostsContent(content, path);
|
|
96
|
+
if (!parsed.ok) {
|
|
97
|
+
throw new HostsRegistryError('corrupt', `Refusing to overwrite ${path}: ${parsed.warning}`);
|
|
98
|
+
}
|
|
99
|
+
return parsed.hosts;
|
|
100
|
+
}
|
|
101
|
+
function writeHostsTransaction(home, mutate) {
|
|
102
|
+
const store = new HomeStore(home);
|
|
103
|
+
try {
|
|
104
|
+
return store.transaction(() => {
|
|
105
|
+
const current = readHostsForWrite(home);
|
|
106
|
+
const { next, result } = mutate(current);
|
|
107
|
+
store.writeJson(home.hosts, { hosts: next });
|
|
108
|
+
return result;
|
|
109
|
+
}, [home.hosts]);
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
if (error instanceof HostsRegistryError)
|
|
113
|
+
throw error;
|
|
114
|
+
if (error instanceof HomeOutsideWriteError) {
|
|
115
|
+
throw new HostsRegistryError('outside_write', error.message);
|
|
116
|
+
}
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/** Add a new SSH host entry to `<config>/hosts.json` via `HomeStore` (mode `0600`). */
|
|
121
|
+
export function addHost(home, input) {
|
|
122
|
+
const validated = createHostInputSchema.safeParse({
|
|
123
|
+
sshAlias: input.sshAlias,
|
|
124
|
+
...(input.id !== undefined ? { id: input.id } : {}),
|
|
125
|
+
...(input.label !== undefined ? { label: input.label } : {}),
|
|
126
|
+
...(input.port !== undefined ? { port: input.port } : {}),
|
|
127
|
+
});
|
|
128
|
+
if (!validated.success) {
|
|
129
|
+
const detail = validated.error.issues.map((issue) => issue.message).join('; ');
|
|
130
|
+
throw new HostsRegistryError('invalid_input', detail);
|
|
131
|
+
}
|
|
132
|
+
const id = validated.data.id ?? slugHostId(validated.data.sshAlias);
|
|
133
|
+
const label = validated.data.label ?? validated.data.sshAlias;
|
|
134
|
+
const entry = hostEntrySchema.parse({
|
|
135
|
+
id,
|
|
136
|
+
label,
|
|
137
|
+
kind: 'ssh',
|
|
138
|
+
sshAlias: validated.data.sshAlias,
|
|
139
|
+
...(validated.data.port !== undefined ? { port: validated.data.port } : {}),
|
|
140
|
+
addedAt: (input.now ?? new Date()).toISOString(),
|
|
141
|
+
});
|
|
142
|
+
return writeHostsTransaction(home, (hosts) => {
|
|
143
|
+
if (hosts.some((existing) => existing.id === entry.id)) {
|
|
144
|
+
throw new HostsRegistryError('duplicate', `Host "${entry.id}" already exists.`);
|
|
145
|
+
}
|
|
146
|
+
return { next: [...hosts, entry], result: entry };
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
/** Update an existing host entry's label, SSH alias, or pinned port (`port: null` clears it). */
|
|
150
|
+
export function updateHost(home, id, patch) {
|
|
151
|
+
const validId = hostIdSchema.safeParse(id);
|
|
152
|
+
if (!validId.success) {
|
|
153
|
+
throw new HostsRegistryError('invalid_input', validId.error.issues[0]?.message ?? `invalid host id "${id}"`);
|
|
154
|
+
}
|
|
155
|
+
const validPatch = updateHostInputSchema.safeParse(patch);
|
|
156
|
+
if (!validPatch.success) {
|
|
157
|
+
const detail = validPatch.error.issues.map((issue) => issue.message).join('; ');
|
|
158
|
+
throw new HostsRegistryError('invalid_input', detail);
|
|
159
|
+
}
|
|
160
|
+
return writeHostsTransaction(home, (hosts) => {
|
|
161
|
+
const index = hosts.findIndex((existing) => existing.id === validId.data);
|
|
162
|
+
if (index === -1) {
|
|
163
|
+
throw new HostsRegistryError('not_found', `Host "${validId.data}" was not found.`);
|
|
164
|
+
}
|
|
165
|
+
const existing = hosts[index];
|
|
166
|
+
const nextPort = validPatch.data.port === null
|
|
167
|
+
? undefined
|
|
168
|
+
: (validPatch.data.port ?? existing.port);
|
|
169
|
+
const updated = hostEntrySchema.parse({
|
|
170
|
+
id: existing.id,
|
|
171
|
+
label: validPatch.data.label ?? existing.label,
|
|
172
|
+
kind: existing.kind,
|
|
173
|
+
sshAlias: validPatch.data.sshAlias ?? existing.sshAlias,
|
|
174
|
+
...(existing.installId !== undefined ? { installId: existing.installId } : {}),
|
|
175
|
+
...(nextPort !== undefined ? { port: nextPort } : {}),
|
|
176
|
+
addedAt: existing.addedAt,
|
|
177
|
+
});
|
|
178
|
+
const next = [...hosts];
|
|
179
|
+
next[index] = updated;
|
|
180
|
+
return { next, result: updated };
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
/** Remove a saved host entry by id. Refuses to overwrite a corrupt `hosts.json`. */
|
|
184
|
+
export function removeHost(home, id) {
|
|
185
|
+
const validId = hostIdSchema.safeParse(id);
|
|
186
|
+
if (!validId.success) {
|
|
187
|
+
throw new HostsRegistryError('invalid_input', validId.error.issues[0]?.message ?? `invalid host id "${id}"`);
|
|
188
|
+
}
|
|
189
|
+
return writeHostsTransaction(home, (hosts) => {
|
|
190
|
+
const existing = hosts.find((entry) => entry.id === validId.data);
|
|
191
|
+
if (!existing) {
|
|
192
|
+
throw new HostsRegistryError('not_found', `Host "${validId.data}" was not found.`);
|
|
193
|
+
}
|
|
194
|
+
const next = hosts.filter((entry) => entry.id !== validId.data);
|
|
195
|
+
return { next, result: existing };
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|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C,KAAK,CAAC,GAAG,OAAO,CAAC;QACtB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,UAAU,CAAC,IAAU,EAAE,EAAU;IAC/C,MAAM,OAAO,GAAG,YAAY,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC3C,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACrB,MAAM,IAAI,kBAAkB,CAAC,eAAe,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,IAAI,oBAAoB,EAAE,GAAG,CAAC,CAAC;IAC/G,CAAC;IAED,OAAO,qBAAqB,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE;QAC3C,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;QAClE,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,kBAAkB,CAAC,WAAW,EAAE,SAAS,OAAO,CAAC,IAAI,kBAAkB,CAAC,CAAC;QACrF,CAAC;QACD,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;QAChE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import type { Home } from '../../home/home.ts';
|
|
2
|
+
export interface HostsRouteDeps {
|
|
3
|
+
home: Home;
|
|
4
|
+
capabilities: () => Readonly<Record<string, boolean | undefined>>;
|
|
5
|
+
/** Optional `~/.ssh/config` path override for tests. */
|
|
6
|
+
sshConfigPath?: string | undefined;
|
|
7
|
+
env?: NodeJS.ProcessEnv | undefined;
|
|
8
|
+
}
|
|
9
|
+
/** Build the workspace-scoped Hono sub-app mounted under `/api/v1`. */
|
|
10
|
+
export declare function createHostsRoutes(deps: HostsRouteDeps): import("hono/hono-base").HonoBase<import("hono/types").BlankEnv, {
|
|
11
|
+
"/hosts": {
|
|
12
|
+
$get: {
|
|
13
|
+
output: {
|
|
14
|
+
hosts: {
|
|
15
|
+
id: string;
|
|
16
|
+
label: string;
|
|
17
|
+
state: "unreachable";
|
|
18
|
+
reason?: string | undefined;
|
|
19
|
+
kind?: "ssh" | undefined;
|
|
20
|
+
sshAlias?: string | undefined;
|
|
21
|
+
installId?: string | undefined;
|
|
22
|
+
port?: number | undefined;
|
|
23
|
+
addedAt?: string | undefined;
|
|
24
|
+
}[];
|
|
25
|
+
warning?: string | undefined;
|
|
26
|
+
sshSuggestions?: string[] | undefined;
|
|
27
|
+
};
|
|
28
|
+
outputFormat: "json";
|
|
29
|
+
status: 200;
|
|
30
|
+
input: {};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
} & {
|
|
34
|
+
"/hosts": {
|
|
35
|
+
$post: {
|
|
36
|
+
output: {
|
|
37
|
+
error: string;
|
|
38
|
+
};
|
|
39
|
+
outputFormat: "json";
|
|
40
|
+
status: 404;
|
|
41
|
+
input: {
|
|
42
|
+
json: {
|
|
43
|
+
sshAlias: string;
|
|
44
|
+
id?: string | undefined;
|
|
45
|
+
label?: string | undefined;
|
|
46
|
+
port?: number | undefined;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
} | {
|
|
50
|
+
output: {
|
|
51
|
+
error: string;
|
|
52
|
+
};
|
|
53
|
+
outputFormat: "json";
|
|
54
|
+
status: 400;
|
|
55
|
+
input: {
|
|
56
|
+
json: {
|
|
57
|
+
sshAlias: string;
|
|
58
|
+
id?: string | undefined;
|
|
59
|
+
label?: string | undefined;
|
|
60
|
+
port?: number | undefined;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
} | {
|
|
64
|
+
output: {
|
|
65
|
+
error: string;
|
|
66
|
+
};
|
|
67
|
+
outputFormat: "json";
|
|
68
|
+
status: 409;
|
|
69
|
+
input: {
|
|
70
|
+
json: {
|
|
71
|
+
sshAlias: string;
|
|
72
|
+
id?: string | undefined;
|
|
73
|
+
label?: string | undefined;
|
|
74
|
+
port?: number | undefined;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
} | {
|
|
78
|
+
output: {
|
|
79
|
+
error: string;
|
|
80
|
+
};
|
|
81
|
+
outputFormat: "json";
|
|
82
|
+
status: 500;
|
|
83
|
+
input: {
|
|
84
|
+
json: {
|
|
85
|
+
sshAlias: string;
|
|
86
|
+
id?: string | undefined;
|
|
87
|
+
label?: string | undefined;
|
|
88
|
+
port?: number | undefined;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
} | {
|
|
92
|
+
output: {
|
|
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
|
+
};
|
|
105
|
+
outputFormat: "json";
|
|
106
|
+
status: 201;
|
|
107
|
+
input: {
|
|
108
|
+
json: {
|
|
109
|
+
sshAlias: string;
|
|
110
|
+
id?: string | undefined;
|
|
111
|
+
label?: string | undefined;
|
|
112
|
+
port?: number | undefined;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
} | {
|
|
116
|
+
output: {
|
|
117
|
+
error: string;
|
|
118
|
+
};
|
|
119
|
+
outputFormat: "json";
|
|
120
|
+
status: 409;
|
|
121
|
+
input: {
|
|
122
|
+
json: {
|
|
123
|
+
sshAlias: string;
|
|
124
|
+
id?: string | undefined;
|
|
125
|
+
label?: string | undefined;
|
|
126
|
+
port?: number | undefined;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
} & {
|
|
132
|
+
"/hosts/:id": {
|
|
133
|
+
$patch: {
|
|
134
|
+
output: {
|
|
135
|
+
error: string;
|
|
136
|
+
code?: "invalid_input" | undefined;
|
|
137
|
+
};
|
|
138
|
+
outputFormat: "json";
|
|
139
|
+
status: 400;
|
|
140
|
+
input: {
|
|
141
|
+
param: {
|
|
142
|
+
id: string;
|
|
143
|
+
};
|
|
144
|
+
} & {
|
|
145
|
+
json: {
|
|
146
|
+
label?: string | undefined;
|
|
147
|
+
sshAlias?: string | undefined;
|
|
148
|
+
port?: number | null | undefined;
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
} | {
|
|
152
|
+
output: {
|
|
153
|
+
error: string;
|
|
154
|
+
};
|
|
155
|
+
outputFormat: "json";
|
|
156
|
+
status: 404;
|
|
157
|
+
input: {
|
|
158
|
+
param: {
|
|
159
|
+
id: string;
|
|
160
|
+
};
|
|
161
|
+
} & {
|
|
162
|
+
json: {
|
|
163
|
+
label?: string | undefined;
|
|
164
|
+
sshAlias?: string | undefined;
|
|
165
|
+
port?: number | null | undefined;
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
} | {
|
|
169
|
+
output: {
|
|
170
|
+
error: string;
|
|
171
|
+
};
|
|
172
|
+
outputFormat: "json";
|
|
173
|
+
status: 400;
|
|
174
|
+
input: {
|
|
175
|
+
param: {
|
|
176
|
+
id: string;
|
|
177
|
+
};
|
|
178
|
+
} & {
|
|
179
|
+
json: {
|
|
180
|
+
label?: string | undefined;
|
|
181
|
+
sshAlias?: string | undefined;
|
|
182
|
+
port?: number | null | undefined;
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
} | {
|
|
186
|
+
output: {
|
|
187
|
+
error: string;
|
|
188
|
+
};
|
|
189
|
+
outputFormat: "json";
|
|
190
|
+
status: 409;
|
|
191
|
+
input: {
|
|
192
|
+
param: {
|
|
193
|
+
id: string;
|
|
194
|
+
};
|
|
195
|
+
} & {
|
|
196
|
+
json: {
|
|
197
|
+
label?: string | undefined;
|
|
198
|
+
sshAlias?: string | undefined;
|
|
199
|
+
port?: number | null | undefined;
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
} | {
|
|
203
|
+
output: {
|
|
204
|
+
error: string;
|
|
205
|
+
};
|
|
206
|
+
outputFormat: "json";
|
|
207
|
+
status: 500;
|
|
208
|
+
input: {
|
|
209
|
+
param: {
|
|
210
|
+
id: string;
|
|
211
|
+
};
|
|
212
|
+
} & {
|
|
213
|
+
json: {
|
|
214
|
+
label?: string | undefined;
|
|
215
|
+
sshAlias?: string | undefined;
|
|
216
|
+
port?: number | null | undefined;
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
} | {
|
|
220
|
+
output: {
|
|
221
|
+
error: string;
|
|
222
|
+
};
|
|
223
|
+
outputFormat: "json";
|
|
224
|
+
status: 409;
|
|
225
|
+
input: {
|
|
226
|
+
param: {
|
|
227
|
+
id: string;
|
|
228
|
+
};
|
|
229
|
+
} & {
|
|
230
|
+
json: {
|
|
231
|
+
label?: string | undefined;
|
|
232
|
+
sshAlias?: string | undefined;
|
|
233
|
+
port?: number | null | undefined;
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
} | {
|
|
237
|
+
output: {
|
|
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
|
+
};
|
|
250
|
+
outputFormat: "json";
|
|
251
|
+
status: 200;
|
|
252
|
+
input: {
|
|
253
|
+
param: {
|
|
254
|
+
id: string;
|
|
255
|
+
};
|
|
256
|
+
} & {
|
|
257
|
+
json: {
|
|
258
|
+
label?: string | undefined;
|
|
259
|
+
sshAlias?: string | undefined;
|
|
260
|
+
port?: number | null | undefined;
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
} & {
|
|
266
|
+
"/hosts/:id": {
|
|
267
|
+
$delete: {
|
|
268
|
+
output: {
|
|
269
|
+
error: string;
|
|
270
|
+
code?: "invalid_input" | undefined;
|
|
271
|
+
};
|
|
272
|
+
outputFormat: "json";
|
|
273
|
+
status: 400;
|
|
274
|
+
input: {
|
|
275
|
+
param: {
|
|
276
|
+
id: string;
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
} | {
|
|
280
|
+
output: {
|
|
281
|
+
error: string;
|
|
282
|
+
};
|
|
283
|
+
outputFormat: "json";
|
|
284
|
+
status: 404;
|
|
285
|
+
input: {
|
|
286
|
+
param: {
|
|
287
|
+
id: string;
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
} | {
|
|
291
|
+
output: {
|
|
292
|
+
error: string;
|
|
293
|
+
};
|
|
294
|
+
outputFormat: "json";
|
|
295
|
+
status: 400;
|
|
296
|
+
input: {
|
|
297
|
+
param: {
|
|
298
|
+
id: string;
|
|
299
|
+
};
|
|
300
|
+
};
|
|
301
|
+
} | {
|
|
302
|
+
output: {
|
|
303
|
+
error: string;
|
|
304
|
+
};
|
|
305
|
+
outputFormat: "json";
|
|
306
|
+
status: 409;
|
|
307
|
+
input: {
|
|
308
|
+
param: {
|
|
309
|
+
id: string;
|
|
310
|
+
};
|
|
311
|
+
};
|
|
312
|
+
} | {
|
|
313
|
+
output: {
|
|
314
|
+
error: string;
|
|
315
|
+
};
|
|
316
|
+
outputFormat: "json";
|
|
317
|
+
status: 500;
|
|
318
|
+
input: {
|
|
319
|
+
param: {
|
|
320
|
+
id: string;
|
|
321
|
+
};
|
|
322
|
+
};
|
|
323
|
+
} | {
|
|
324
|
+
output: {
|
|
325
|
+
error: string;
|
|
326
|
+
};
|
|
327
|
+
outputFormat: "json";
|
|
328
|
+
status: 409;
|
|
329
|
+
input: {
|
|
330
|
+
param: {
|
|
331
|
+
id: string;
|
|
332
|
+
};
|
|
333
|
+
};
|
|
334
|
+
} | {
|
|
335
|
+
output: {
|
|
336
|
+
removed: true;
|
|
337
|
+
id: string;
|
|
338
|
+
};
|
|
339
|
+
outputFormat: "json";
|
|
340
|
+
status: 200;
|
|
341
|
+
input: {
|
|
342
|
+
param: {
|
|
343
|
+
id: string;
|
|
344
|
+
};
|
|
345
|
+
};
|
|
346
|
+
};
|
|
347
|
+
};
|
|
348
|
+
}, "/", "/hosts/:id">;
|