@getmateo/protocol 0.0.0-stage → 0.17.1
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/LICENSE +211 -0
- package/README.md +11 -2
- package/dist/addresses.d.ts +6 -0
- package/dist/addresses.js +2 -0
- package/dist/agent-attention-notification.d.ts +57 -0
- package/dist/agent-attention-notification.js +177 -0
- package/dist/agent-deep-link.d.ts +8 -0
- package/dist/agent-deep-link.js +49 -0
- package/dist/agent-labels.d.ts +14 -0
- package/dist/agent-labels.js +38 -0
- package/dist/agent-lifecycle.d.ts +3 -0
- package/dist/agent-lifecycle.js +8 -0
- package/dist/agent-message.d.ts +20 -0
- package/dist/agent-message.js +12 -0
- package/dist/agent-profile.d.ts +31 -0
- package/dist/agent-profile.js +32 -0
- package/dist/agent-runtime-config.d.ts +4 -0
- package/dist/agent-runtime-config.js +5 -0
- package/dist/agent-shells.d.ts +25 -0
- package/dist/agent-shells.js +17 -0
- package/dist/agent-state-bucket.d.ts +15 -0
- package/dist/agent-state-bucket.js +41 -0
- package/dist/agent-title-limits.d.ts +2 -0
- package/dist/agent-title-limits.js +2 -0
- package/dist/agent-types.d.ts +484 -0
- package/dist/agent-types.js +33 -0
- package/dist/binary-frames/demux.d.ts +15 -0
- package/dist/binary-frames/demux.js +28 -0
- package/dist/binary-frames/file-transfer.d.ts +51 -0
- package/dist/binary-frames/file-transfer.js +108 -0
- package/dist/binary-frames/host-route.d.ts +13 -0
- package/dist/binary-frames/host-route.js +39 -0
- package/dist/binary-frames/index.d.ts +5 -0
- package/dist/binary-frames/index.js +5 -0
- package/dist/binary-frames/terminal.d.ts +35 -0
- package/dist/binary-frames/terminal.js +100 -0
- package/dist/branch-slug.d.ts +14 -0
- package/dist/branch-slug.js +49 -0
- package/dist/browser-automation/capabilities.d.ts +7 -0
- package/dist/browser-automation/capabilities.js +31 -0
- package/dist/browser-automation/rpc-schemas.d.ts +1113 -0
- package/dist/browser-automation/rpc-schemas.js +463 -0
- package/dist/build-metadata.d.ts +17 -0
- package/dist/build-metadata.js +61 -0
- package/dist/chat/rpc-schemas.d.ts +158 -0
- package/dist/chat/rpc-schemas.js +104 -0
- package/dist/chat/types.d.ts +30 -0
- package/dist/chat/types.js +23 -0
- package/dist/check-traits.d.ts +11 -0
- package/dist/check-traits.js +10 -0
- package/dist/chunked-transport.d.ts +42 -0
- package/dist/chunked-transport.js +277 -0
- package/dist/client-capabilities.d.ts +24 -0
- package/dist/client-capabilities.js +52 -0
- package/dist/connection-offer.d.ts +36 -0
- package/dist/connection-offer.js +53 -0
- package/dist/daemon-auth.d.ts +548 -0
- package/dist/daemon-auth.js +152 -0
- package/dist/daemon-endpoints.d.ts +54 -0
- package/dist/daemon-endpoints.js +243 -0
- package/dist/error-utils.d.ts +11 -0
- package/dist/error-utils.js +27 -0
- package/dist/fleet.d.ts +381 -0
- package/dist/fleet.js +134 -0
- package/dist/forge-manifest.d.ts +66 -0
- package/dist/forge-manifest.js +92 -0
- package/dist/generated/validation/ws-outbound-schema-metadata.d.ts +14023 -0
- package/dist/generated/validation/ws-outbound-schema-metadata.js +258 -0
- package/dist/generated/validation/ws-outbound.aot.d.ts +512 -0
- package/dist/generated/validation/ws-outbound.aot.js +105425 -0
- package/dist/git-remote.d.ts +33 -0
- package/dist/git-remote.js +94 -0
- package/dist/gitea-status.d.ts +10 -0
- package/dist/gitea-status.js +23 -0
- package/dist/gitlab-pipeline.d.ts +10 -0
- package/dist/gitlab-pipeline.js +17 -0
- package/dist/global-terminal.d.ts +3 -0
- package/dist/global-terminal.js +8 -0
- package/dist/host-connection-schema.d.ts +11 -0
- package/dist/host-connection-schema.js +9 -0
- package/dist/host-target.d.ts +20 -0
- package/dist/host-target.js +137 -0
- package/dist/hosts.d.ts +133 -0
- package/dist/hosts.js +82 -0
- package/dist/literal-union.d.ts +2 -0
- package/dist/literal-union.js +2 -0
- package/dist/loop/rpc-schemas.d.ts +636 -0
- package/dist/loop/rpc-schemas.js +164 -0
- package/dist/mateo-config-schema.d.ts +138 -0
- package/dist/mateo-config-schema.js +98 -0
- package/dist/mateo-tool-call-detail.d.ts +2 -0
- package/dist/mateo-tool-call-detail.js +3 -0
- package/dist/mateo-tool-presentation/agent-message.d.ts +10 -0
- package/dist/mateo-tool-presentation/agent-message.js +23 -0
- package/dist/mateo-tool-presentation/catalog.d.ts +320 -0
- package/dist/mateo-tool-presentation/catalog.js +318 -0
- package/dist/mateo-tool-presentation/detail-sections.d.ts +15 -0
- package/dist/mateo-tool-presentation/detail-sections.js +161 -0
- package/dist/mateo-tool-presentation/index.d.ts +22 -0
- package/dist/mateo-tool-presentation/index.js +62 -0
- package/dist/mateo-tool-presentation/summary-text.d.ts +7 -0
- package/dist/mateo-tool-presentation/summary-text.js +22 -0
- package/dist/messages.d.ts +69382 -0
- package/dist/messages.js +6717 -0
- package/dist/path-utils.d.ts +2 -0
- package/dist/path-utils.js +16 -0
- package/dist/plugin-config.d.ts +18 -0
- package/dist/plugin-config.js +13 -0
- package/dist/plugin-overview.d.ts +12 -0
- package/dist/plugin-overview.js +50 -0
- package/dist/plugin-registry.d.ts +153 -0
- package/dist/plugin-registry.js +83 -0
- package/dist/plugin-requirements.d.ts +11 -0
- package/dist/plugin-requirements.js +26 -0
- package/dist/plugin-source-reference.d.ts +11 -0
- package/dist/plugin-source-reference.js +68 -0
- package/dist/provider-config.d.ts +141 -0
- package/dist/provider-config.js +113 -0
- package/dist/provider-icon-names.d.ts +5 -0
- package/dist/provider-icon-names.js +54 -0
- package/dist/provider-manifest.d.ts +30 -0
- package/dist/provider-manifest.js +247 -0
- package/dist/provider-snapshot-codec.d.ts +18 -0
- package/dist/provider-snapshot-codec.js +71 -0
- package/dist/schedule/cadence.d.ts +6 -0
- package/dist/schedule/cadence.js +28 -0
- package/dist/schedule/cron-expression.d.ts +14 -0
- package/dist/schedule/cron-expression.js +107 -0
- package/dist/schedule/rpc-schemas.d.ts +570 -0
- package/dist/schedule/rpc-schemas.js +158 -0
- package/dist/schedule/types.d.ts +201 -0
- package/dist/schedule/types.js +68 -0
- package/dist/search/text-match.d.ts +78 -0
- package/dist/search/text-match.js +330 -0
- package/dist/service-defaults.d.ts +3 -0
- package/dist/service-defaults.js +5 -0
- package/dist/ssh-transport.d.ts +11 -0
- package/dist/ssh-transport.js +72 -0
- package/dist/terminal-activity.d.ts +21 -0
- package/dist/terminal-activity.js +25 -0
- package/dist/terminal-input-mode.d.ts +30 -0
- package/dist/terminal-input-mode.js +180 -0
- package/dist/terminal-key-input.d.ts +13 -0
- package/dist/terminal-key-input.js +210 -0
- package/dist/terminal-profile.d.ts +10 -0
- package/dist/terminal-profile.js +11 -0
- package/dist/terminal-profiles.d.ts +41 -0
- package/dist/terminal-profiles.js +276 -0
- package/dist/terminal-snapshot.d.ts +4 -0
- package/dist/terminal-snapshot.js +220 -0
- package/dist/terminal-stream-protocol.d.ts +2 -0
- package/dist/terminal-stream-protocol.js +2 -0
- package/dist/terminal-subscription-key.d.ts +2 -0
- package/dist/terminal-subscription-key.js +9 -0
- package/dist/timeline-identity.d.ts +3 -0
- package/dist/timeline-identity.js +8 -0
- package/dist/tool-call-display.d.ts +13 -0
- package/dist/tool-call-display.js +144 -0
- package/dist/tool-name-normalization.d.ts +9 -0
- package/dist/tool-name-normalization.js +82 -0
- package/dist/user-agent.d.ts +26 -0
- package/dist/user-agent.js +101 -0
- package/dist/validation/ws-outbound-envelope.d.ts +13261 -0
- package/dist/validation/ws-outbound-envelope.js +17 -0
- package/dist/validation/ws-outbound.d.ts +12 -0
- package/dist/validation/ws-outbound.js +38 -0
- package/dist/websocket-message-limit.d.ts +5 -0
- package/dist/websocket-message-limit.js +5 -0
- package/dist/workspace-labels.d.ts +9 -0
- package/dist/workspace-labels.js +19 -0
- package/package.json +43 -4
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface GitRemoteLocation {
|
|
2
|
+
transport: "scp" | "ssh" | "http" | "https";
|
|
3
|
+
host: string;
|
|
4
|
+
/**
|
|
5
|
+
* Explicit non-default port from the remote (e.g. a self-hosted forge on
|
|
6
|
+
* `:60443`), or undefined for a default-port or scp-form remote. Kept separate
|
|
7
|
+
* from `host` so host-identity matching (forge detection, cloud-host checks)
|
|
8
|
+
* stays port-agnostic; only consumers that reconstruct a URL (web links) use it.
|
|
9
|
+
*/
|
|
10
|
+
port?: string;
|
|
11
|
+
path: string;
|
|
12
|
+
}
|
|
13
|
+
export interface GitHubRemoteIdentity {
|
|
14
|
+
owner: string;
|
|
15
|
+
name: string;
|
|
16
|
+
repo: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function parseGitHubRemoteUrl(remoteUrl: string): GitHubRemoteIdentity | null;
|
|
19
|
+
/**
|
|
20
|
+
* Whether `repo` is already a complete git remote (a URL or scp-like address)
|
|
21
|
+
* rather than `owner/repo` shorthand that still needs a clone protocol picked.
|
|
22
|
+
*
|
|
23
|
+
* Clients (app + CLI) and the daemon must agree on this classification: the
|
|
24
|
+
* daemon treats `parseGitRemoteLocation(repo) !== null` as "complete remote"
|
|
25
|
+
* and everything else as shorthand, so reuse the same parser here instead of a
|
|
26
|
+
* separate regex that would drift (e.g. accepting `git://` the parser rejects).
|
|
27
|
+
*/
|
|
28
|
+
export declare function isCompleteGitRemote(repo: string): boolean;
|
|
29
|
+
export declare function parseGitRemoteLocation(remoteUrl: string): GitRemoteLocation | null;
|
|
30
|
+
export declare function parseGitHubRemoteIdentity(path: string): GitHubRemoteIdentity | null;
|
|
31
|
+
export declare function isGitHubHost(host: string): boolean;
|
|
32
|
+
export declare function normalizeHost(host: string): string;
|
|
33
|
+
//# sourceMappingURL=git-remote.d.ts.map
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { getForgeDefinition } from "./forge-manifest.js";
|
|
2
|
+
const GITHUB_HOSTS = new Set(getForgeDefinition("github")?.cloudHosts ?? []);
|
|
3
|
+
const TRANSPORT_BY_PROTOCOL = {
|
|
4
|
+
"https:": "https",
|
|
5
|
+
"http:": "http",
|
|
6
|
+
"ssh:": "ssh",
|
|
7
|
+
};
|
|
8
|
+
const DEFAULT_PORT_BY_PROTOCOL = {
|
|
9
|
+
"https:": "443",
|
|
10
|
+
"http:": "80",
|
|
11
|
+
"ssh:": "22",
|
|
12
|
+
};
|
|
13
|
+
export function parseGitHubRemoteUrl(remoteUrl) {
|
|
14
|
+
const location = parseGitRemoteLocation(remoteUrl);
|
|
15
|
+
if (!location || !isGitHubHost(location.host))
|
|
16
|
+
return null;
|
|
17
|
+
return parseGitHubRemoteIdentity(location.path);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Whether `repo` is already a complete git remote (a URL or scp-like address)
|
|
21
|
+
* rather than `owner/repo` shorthand that still needs a clone protocol picked.
|
|
22
|
+
*
|
|
23
|
+
* Clients (app + CLI) and the daemon must agree on this classification: the
|
|
24
|
+
* daemon treats `parseGitRemoteLocation(repo) !== null` as "complete remote"
|
|
25
|
+
* and everything else as shorthand, so reuse the same parser here instead of a
|
|
26
|
+
* separate regex that would drift (e.g. accepting `git://` the parser rejects).
|
|
27
|
+
*/
|
|
28
|
+
export function isCompleteGitRemote(repo) {
|
|
29
|
+
return parseGitRemoteLocation(repo) !== null;
|
|
30
|
+
}
|
|
31
|
+
export function parseGitRemoteLocation(remoteUrl) {
|
|
32
|
+
const trimmed = remoteUrl.trim();
|
|
33
|
+
if (!trimmed)
|
|
34
|
+
return null;
|
|
35
|
+
// scp form has no scheme. Testing it first would match `ssh://git@host:22/x`
|
|
36
|
+
// — `[^@]+` happily eats `ssh://git` — and swallow the port into the path.
|
|
37
|
+
const scpLike = trimmed.includes("://") ? null : trimmed.match(/^[^@]+@([^:]+):(.+)$/u);
|
|
38
|
+
if (scpLike) {
|
|
39
|
+
const host = normalizeHost(scpLike[1] ?? "");
|
|
40
|
+
const path = normalizeRemotePath(scpLike[2] ?? "");
|
|
41
|
+
if (!isValidRemoteHost(host) || !path)
|
|
42
|
+
return null;
|
|
43
|
+
return { transport: "scp", host, path };
|
|
44
|
+
}
|
|
45
|
+
let parsed;
|
|
46
|
+
try {
|
|
47
|
+
parsed = new URL(trimmed);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const transport = TRANSPORT_BY_PROTOCOL[parsed.protocol.toLowerCase()];
|
|
53
|
+
if (!transport)
|
|
54
|
+
return null;
|
|
55
|
+
const host = normalizeHost(parsed.hostname);
|
|
56
|
+
let path;
|
|
57
|
+
try {
|
|
58
|
+
path = decodeURIComponent(parsed.pathname);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const normalizedPath = normalizeRemotePath(path);
|
|
64
|
+
if (!isValidRemoteHost(host) || !normalizedPath)
|
|
65
|
+
return null;
|
|
66
|
+
const protocol = parsed.protocol.toLowerCase();
|
|
67
|
+
const port = parsed.port && parsed.port !== DEFAULT_PORT_BY_PROTOCOL[protocol] ? parsed.port : undefined;
|
|
68
|
+
return { transport, host, port, path: normalizedPath };
|
|
69
|
+
}
|
|
70
|
+
export function parseGitHubRemoteIdentity(path) {
|
|
71
|
+
const segments = path.split("/").filter(Boolean);
|
|
72
|
+
if (segments.length !== 2)
|
|
73
|
+
return null;
|
|
74
|
+
const [owner, name] = segments;
|
|
75
|
+
if (!owner || !name)
|
|
76
|
+
return null;
|
|
77
|
+
return { owner, name, repo: `${owner}/${name}` };
|
|
78
|
+
}
|
|
79
|
+
export function isGitHubHost(host) {
|
|
80
|
+
return GITHUB_HOSTS.has(host);
|
|
81
|
+
}
|
|
82
|
+
export function normalizeHost(host) {
|
|
83
|
+
return host.trim().replace(/\.+$/u, "").toLowerCase();
|
|
84
|
+
}
|
|
85
|
+
function normalizeRemotePath(path) {
|
|
86
|
+
let normalized = path.trim().replace(/^\/+|\/+$/gu, "");
|
|
87
|
+
if (normalized.endsWith(".git"))
|
|
88
|
+
normalized = normalized.slice(0, -4);
|
|
89
|
+
return normalized || null;
|
|
90
|
+
}
|
|
91
|
+
function isValidRemoteHost(host) {
|
|
92
|
+
return /^[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?$/u.test(host);
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=git-remote.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps a Gitea/Forgejo commit-status state (individual status or the combined
|
|
3
|
+
* aggregate, e.g. a forge fact's ciStatus) onto the neutral check status.
|
|
4
|
+
* Shared by the daemon's Gitea adapter and the app's Gitea forge module so the
|
|
5
|
+
* "warning is terminal and non-passing" rule lives in one place: upstream
|
|
6
|
+
* treats warning as IsSuccess() == false, so it blocks merges and must not
|
|
7
|
+
* render as a plain pass or hang as pending.
|
|
8
|
+
*/
|
|
9
|
+
export declare function mapGiteaCommitState(state: string): "success" | "failure" | "pending" | "skipped";
|
|
10
|
+
//# sourceMappingURL=gitea-status.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps a Gitea/Forgejo commit-status state (individual status or the combined
|
|
3
|
+
* aggregate, e.g. a forge fact's ciStatus) onto the neutral check status.
|
|
4
|
+
* Shared by the daemon's Gitea adapter and the app's Gitea forge module so the
|
|
5
|
+
* "warning is terminal and non-passing" rule lives in one place: upstream
|
|
6
|
+
* treats warning as IsSuccess() == false, so it blocks merges and must not
|
|
7
|
+
* render as a plain pass or hang as pending.
|
|
8
|
+
*/
|
|
9
|
+
export function mapGiteaCommitState(state) {
|
|
10
|
+
switch (state.toLowerCase()) {
|
|
11
|
+
case "success":
|
|
12
|
+
return "success";
|
|
13
|
+
case "failure":
|
|
14
|
+
case "error":
|
|
15
|
+
case "warning":
|
|
16
|
+
return "failure";
|
|
17
|
+
case "skipped":
|
|
18
|
+
return "skipped";
|
|
19
|
+
default:
|
|
20
|
+
return "pending";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=gitea-status.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical set of GitLab pipeline/job statuses that count as "still active"
|
|
3
|
+
* (not yet terminal). Shared by the daemon (merge-capability facts, checks
|
|
4
|
+
* aggregation) and the app (pipeline presentation) so a new GitLab transitional
|
|
5
|
+
* status only needs to be added in one place.
|
|
6
|
+
*/
|
|
7
|
+
export declare const GITLAB_ACTIVE_PIPELINE_STATUSES: readonly ["created", "waiting_for_resource", "preparing", "pending", "running", "canceling", "scheduled"];
|
|
8
|
+
export type GitLabActivePipelineStatus = (typeof GITLAB_ACTIVE_PIPELINE_STATUSES)[number];
|
|
9
|
+
export declare const GITLAB_ACTIVE_PIPELINE_STATUS_SET: Set<string>;
|
|
10
|
+
//# sourceMappingURL=gitlab-pipeline.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical set of GitLab pipeline/job statuses that count as "still active"
|
|
3
|
+
* (not yet terminal). Shared by the daemon (merge-capability facts, checks
|
|
4
|
+
* aggregation) and the app (pipeline presentation) so a new GitLab transitional
|
|
5
|
+
* status only needs to be added in one place.
|
|
6
|
+
*/
|
|
7
|
+
export const GITLAB_ACTIVE_PIPELINE_STATUSES = [
|
|
8
|
+
"created",
|
|
9
|
+
"waiting_for_resource",
|
|
10
|
+
"preparing",
|
|
11
|
+
"pending",
|
|
12
|
+
"running",
|
|
13
|
+
"canceling",
|
|
14
|
+
"scheduled",
|
|
15
|
+
];
|
|
16
|
+
export const GITLAB_ACTIVE_PIPELINE_STATUS_SET = new Set(GITLAB_ACTIVE_PIPELINE_STATUSES);
|
|
17
|
+
//# sourceMappingURL=gitlab-pipeline.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// A global terminal belongs to no workspace: it survives workspace archive and never appears in a
|
|
2
|
+
// workspace's terminal list. It still needs an owner id on the wire, so it carries this reserved
|
|
3
|
+
// one. Real workspace ids are always `wks_<hex>`, so it cannot collide with one.
|
|
4
|
+
export const GLOBAL_TERMINAL_WORKSPACE_ID = "global";
|
|
5
|
+
export function isGlobalTerminalWorkspaceId(workspaceId) {
|
|
6
|
+
return workspaceId === GLOBAL_TERMINAL_WORKSPACE_ID;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=global-terminal.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const DirectTcpHostConnectionSchema: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
type: z.ZodLiteral<"directTcp">;
|
|
5
|
+
endpoint: z.ZodString;
|
|
6
|
+
useTls: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
7
|
+
password: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export type DirectTcpHostConnection = z.input<typeof DirectTcpHostConnectionSchema>;
|
|
10
|
+
export type NormalizedDirectTcpHostConnection = z.output<typeof DirectTcpHostConnectionSchema>;
|
|
11
|
+
//# sourceMappingURL=host-connection-schema.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const DirectTcpHostConnectionSchema = z.object({
|
|
3
|
+
id: z.string(),
|
|
4
|
+
type: z.literal("directTcp"),
|
|
5
|
+
endpoint: z.string(),
|
|
6
|
+
useTls: z.boolean().optional().default(false),
|
|
7
|
+
password: z.string().optional(),
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=host-connection-schema.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ConnectionOffer } from "./connection-offer.js";
|
|
2
|
+
import { type SshTransportTarget } from "./ssh-transport.js";
|
|
3
|
+
export type HostTarget = {
|
|
4
|
+
kind: "ssh";
|
|
5
|
+
ssh: SshTransportTarget;
|
|
6
|
+
password?: string;
|
|
7
|
+
description: string;
|
|
8
|
+
} | {
|
|
9
|
+
kind: "socket";
|
|
10
|
+
url: string;
|
|
11
|
+
socketPath?: string;
|
|
12
|
+
password?: string;
|
|
13
|
+
offer?: ConnectionOffer;
|
|
14
|
+
/** A fleet peer credential, carried in the `peer` parameter of relay://, tcp:// or ws(s)://. */
|
|
15
|
+
peerCredential?: string;
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
/** The shared saved-host and CLI grammar. Errors never echo credential-bearing input. */
|
|
19
|
+
export declare function parseHostTarget(input: string): HostTarget;
|
|
20
|
+
//# sourceMappingURL=host-target.d.ts.map
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { parseConnectionOfferFromUrl } from "./connection-offer.js";
|
|
2
|
+
import { buildDaemonWebSocketUrl, buildRelayWebSocketUrl, normalizeHostPort, parseConnectionUri, parseRelayConnectionUri, shouldUseTlsForDefaultHostedRelay, } from "./daemon-endpoints.js";
|
|
3
|
+
import { parseSshTransportUri } from "./ssh-transport.js";
|
|
4
|
+
/** The shared saved-host and CLI grammar. Errors never echo credential-bearing input. */
|
|
5
|
+
export function parseHostTarget(input) {
|
|
6
|
+
try {
|
|
7
|
+
return parse(input.trim());
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
throw Object.assign(new Error("Invalid host connection. Use host:port, ws(s)://, tcp://, unix://, pipe://, ssh:// or a pairing URL."), { code: "invalid_connection" });
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function parse(input) {
|
|
14
|
+
if (!input)
|
|
15
|
+
throw new Error("empty");
|
|
16
|
+
if (input.startsWith("ssh://")) {
|
|
17
|
+
return sshTarget(input);
|
|
18
|
+
}
|
|
19
|
+
const peer = peerTarget(input);
|
|
20
|
+
if (peer)
|
|
21
|
+
return peer;
|
|
22
|
+
if (input.startsWith("relay://") || input.includes("#connect=")) {
|
|
23
|
+
const relay = parseRelayConnectionUri(input);
|
|
24
|
+
return relayTarget(relay.offer, relay.password);
|
|
25
|
+
}
|
|
26
|
+
const offer = parseConnectionOfferFromUrl(input);
|
|
27
|
+
if (offer)
|
|
28
|
+
return relayTarget(offer);
|
|
29
|
+
if (input.startsWith("unix://") ||
|
|
30
|
+
input.startsWith("pipe://") ||
|
|
31
|
+
input.startsWith("/") ||
|
|
32
|
+
input.startsWith("~") ||
|
|
33
|
+
input.startsWith("\\\\.\\pipe\\")) {
|
|
34
|
+
const socketPath = input.replace(/^(unix|pipe):\/\//, "");
|
|
35
|
+
if (!socketPath || socketPath === "~")
|
|
36
|
+
throw new Error("empty socket");
|
|
37
|
+
const pipe = input.startsWith("pipe://") || input.startsWith("\\\\.\\pipe\\");
|
|
38
|
+
return {
|
|
39
|
+
kind: "socket",
|
|
40
|
+
socketPath,
|
|
41
|
+
url: pipe ? "ws://localhost/ws" : `ws+unix://${socketPath}:/ws`,
|
|
42
|
+
description: `${pipe ? "pipe" : "unix"}://${socketPath}`,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (input.startsWith("tcp://"))
|
|
46
|
+
return tcpTarget(input);
|
|
47
|
+
if (/^wss?:\/\//.test(input))
|
|
48
|
+
return websocketTarget(input);
|
|
49
|
+
const endpoint = validatedEndpoint(/^\d+$/.test(input) ? `127.0.0.1:${input}` : input);
|
|
50
|
+
return {
|
|
51
|
+
kind: "socket",
|
|
52
|
+
url: buildDaemonWebSocketUrl(endpoint, { useTls: false }),
|
|
53
|
+
description: `tcp://${endpoint}`,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** Separates a fleet peer credential from relay://, tcp:// and ws(s):// addresses. */
|
|
57
|
+
function peerTarget(input) {
|
|
58
|
+
if (!/^(relay|tcp|wss?):\/\//.test(input) || input.includes("#"))
|
|
59
|
+
return null;
|
|
60
|
+
const url = new URL(input);
|
|
61
|
+
const peers = url.searchParams.getAll("peer");
|
|
62
|
+
if (peers.length === 0)
|
|
63
|
+
return null;
|
|
64
|
+
if (peers.length > 1 || !peers[0])
|
|
65
|
+
throw new Error("Invalid peer");
|
|
66
|
+
url.searchParams.delete("peer");
|
|
67
|
+
const target = parse(url.toString());
|
|
68
|
+
if (target.kind !== "socket")
|
|
69
|
+
throw new Error("Unexpected peer target");
|
|
70
|
+
return { ...target, peerCredential: peers[0] };
|
|
71
|
+
}
|
|
72
|
+
function relayTarget(offer, password) {
|
|
73
|
+
const endpoint = validatedEndpoint(offer.relay.endpoint);
|
|
74
|
+
return {
|
|
75
|
+
kind: "socket",
|
|
76
|
+
url: buildRelayWebSocketUrl({
|
|
77
|
+
endpoint,
|
|
78
|
+
serverId: offer.serverId,
|
|
79
|
+
role: "client",
|
|
80
|
+
useTls: offer.relay.useTls ?? shouldUseTlsForDefaultHostedRelay(offer.relay.endpoint),
|
|
81
|
+
}),
|
|
82
|
+
offer,
|
|
83
|
+
password,
|
|
84
|
+
description: `relay://${endpoint}/${encodeURIComponent(offer.serverId)}`,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function tcpTarget(input) {
|
|
88
|
+
const uri = new URL(input);
|
|
89
|
+
if (uri.pathname && uri.pathname !== "/")
|
|
90
|
+
throw new Error("Unexpected TCP path");
|
|
91
|
+
if (uri.hash)
|
|
92
|
+
throw new Error("Unexpected TCP fragment");
|
|
93
|
+
const parts = parseConnectionUri(input);
|
|
94
|
+
const endpoint = validatedEndpoint(`${parts.isIpv6 ? `[${parts.host}]` : parts.host}:${parts.port}`);
|
|
95
|
+
return {
|
|
96
|
+
kind: "socket",
|
|
97
|
+
url: buildDaemonWebSocketUrl(endpoint, { useTls: parts.useTls }),
|
|
98
|
+
password: parts.password,
|
|
99
|
+
description: `tcp://${endpoint}`,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function websocketTarget(input) {
|
|
103
|
+
const url = new URL(input);
|
|
104
|
+
if (!url.hostname || url.username || url.password || url.hash)
|
|
105
|
+
throw new Error("invalid url");
|
|
106
|
+
const password = url.searchParams.get("password") ?? undefined;
|
|
107
|
+
// Unknown query parameters may themselves contain credentials; discovery shows only the origin.
|
|
108
|
+
if (url.pathname === "/")
|
|
109
|
+
url.pathname = "/ws";
|
|
110
|
+
url.searchParams.delete("password");
|
|
111
|
+
return { kind: "socket", url: url.toString(), password, description: url.origin };
|
|
112
|
+
}
|
|
113
|
+
function sshTarget(input) {
|
|
114
|
+
const uri = new URL(input);
|
|
115
|
+
if (uri.searchParams.getAll("password").length > 1)
|
|
116
|
+
throw new Error("Duplicate daemon password");
|
|
117
|
+
const password = uri.searchParams.get("password") || undefined;
|
|
118
|
+
uri.searchParams.delete("password");
|
|
119
|
+
const ssh = parseSshTransportUri(uri.toString());
|
|
120
|
+
return {
|
|
121
|
+
kind: "ssh",
|
|
122
|
+
ssh,
|
|
123
|
+
...(password ? { password } : {}),
|
|
124
|
+
description: `ssh://${uri.hostname}${ssh.sshPort ? `:${ssh.sshPort}` : ""} (daemon port ${ssh.daemonPort})`,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/** A bare endpoint has exactly one authority; URL syntax must use an explicit supported scheme. */
|
|
128
|
+
function validatedEndpoint(input) {
|
|
129
|
+
if (!/^(?:[a-zA-Z0-9_][a-zA-Z0-9_.-]*|\[[0-9a-fA-F:.]+\]):[0-9]{1,5}$/.test(input))
|
|
130
|
+
throw new Error("Invalid endpoint");
|
|
131
|
+
// URL parsing validates IPv6 literals and rejects invalid authority/port encodings.
|
|
132
|
+
const url = new URL(`http://${input}`);
|
|
133
|
+
if (!url.hostname)
|
|
134
|
+
throw new Error("Missing endpoint host");
|
|
135
|
+
return normalizeHostPort(input);
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=host-target.js.map
|
package/dist/hosts.d.ts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const HostMetadataSchema: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
3
|
+
export declare const HostAddSchema: z.ZodObject<{
|
|
4
|
+
connection: z.ZodString;
|
|
5
|
+
label: z.ZodOptional<z.ZodString>;
|
|
6
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
7
|
+
sourceKey: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export declare const HostUpdateSchema: z.ZodObject<{
|
|
10
|
+
label: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
11
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
12
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
+
connection: z.ZodOptional<z.ZodString>;
|
|
14
|
+
replaceIdentity: z.ZodOptional<z.ZodBoolean>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export declare const HostSummarySchema: z.ZodObject<{
|
|
17
|
+
registrationId: z.ZodString;
|
|
18
|
+
serverId: z.ZodNullable<z.ZodString>;
|
|
19
|
+
label: z.ZodNullable<z.ZodString>;
|
|
20
|
+
source: z.ZodObject<{
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
key: z.ZodString;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
25
|
+
enabled: z.ZodBoolean;
|
|
26
|
+
status: z.ZodEnum<{
|
|
27
|
+
error: "error";
|
|
28
|
+
connecting: "connecting";
|
|
29
|
+
online: "online";
|
|
30
|
+
offline: "offline";
|
|
31
|
+
disabled: "disabled";
|
|
32
|
+
}>;
|
|
33
|
+
targetDescription: z.ZodString;
|
|
34
|
+
lastOnlineAt: z.ZodNullable<z.ZodString>;
|
|
35
|
+
nextRetryAt: z.ZodNullable<z.ZodString>;
|
|
36
|
+
error: z.ZodNullable<z.ZodObject<{
|
|
37
|
+
code: z.ZodString;
|
|
38
|
+
message: z.ZodString;
|
|
39
|
+
}, z.core.$strip>>;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
export declare const HostDirectorySchema: z.ZodObject<{
|
|
42
|
+
self: z.ZodObject<{
|
|
43
|
+
serverId: z.ZodString;
|
|
44
|
+
label: z.ZodString;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
hosts: z.ZodArray<z.ZodObject<{
|
|
47
|
+
registrationId: z.ZodString;
|
|
48
|
+
serverId: z.ZodNullable<z.ZodString>;
|
|
49
|
+
label: z.ZodNullable<z.ZodString>;
|
|
50
|
+
source: z.ZodObject<{
|
|
51
|
+
id: z.ZodString;
|
|
52
|
+
key: z.ZodString;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
55
|
+
enabled: z.ZodBoolean;
|
|
56
|
+
status: z.ZodEnum<{
|
|
57
|
+
error: "error";
|
|
58
|
+
connecting: "connecting";
|
|
59
|
+
online: "online";
|
|
60
|
+
offline: "offline";
|
|
61
|
+
disabled: "disabled";
|
|
62
|
+
}>;
|
|
63
|
+
targetDescription: z.ZodString;
|
|
64
|
+
lastOnlineAt: z.ZodNullable<z.ZodString>;
|
|
65
|
+
nextRetryAt: z.ZodNullable<z.ZodString>;
|
|
66
|
+
error: z.ZodNullable<z.ZodObject<{
|
|
67
|
+
code: z.ZodString;
|
|
68
|
+
message: z.ZodString;
|
|
69
|
+
}, z.core.$strip>>;
|
|
70
|
+
}, z.core.$strip>>;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
export type HostAdd = z.infer<typeof HostAddSchema>;
|
|
73
|
+
export type HostUpdate = z.infer<typeof HostUpdateSchema>;
|
|
74
|
+
export type HostSummary = z.infer<typeof HostSummarySchema>;
|
|
75
|
+
export type HostDirectory = z.infer<typeof HostDirectorySchema>;
|
|
76
|
+
export declare const HostsRouteOpenRequestSchema: z.ZodObject<{
|
|
77
|
+
type: z.ZodLiteral<"hosts.route.open.request">;
|
|
78
|
+
requestId: z.ZodString;
|
|
79
|
+
serverId: z.ZodString;
|
|
80
|
+
scopeId: z.ZodString;
|
|
81
|
+
}, z.core.$strip>;
|
|
82
|
+
export declare const HostsRouteFrameRequestSchema: z.ZodObject<{
|
|
83
|
+
type: z.ZodLiteral<"hosts.route.frame.request">;
|
|
84
|
+
routeId: z.ZodString;
|
|
85
|
+
data: z.ZodString;
|
|
86
|
+
binary: z.ZodLiteral<false>;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
export declare const HostsRouteCloseRequestSchema: z.ZodObject<{
|
|
89
|
+
type: z.ZodLiteral<"hosts.route.close.request">;
|
|
90
|
+
routeId: z.ZodOptional<z.ZodString>;
|
|
91
|
+
scopeId: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, z.core.$strip>;
|
|
93
|
+
export declare const HostsRouteOpenResponseSchema: z.ZodObject<{
|
|
94
|
+
type: z.ZodLiteral<"hosts.route.open.response">;
|
|
95
|
+
payload: z.ZodObject<{
|
|
96
|
+
requestId: z.ZodString;
|
|
97
|
+
routeId: z.ZodString;
|
|
98
|
+
}, z.core.$strip>;
|
|
99
|
+
}, z.core.$strip>;
|
|
100
|
+
export declare const HostsRouteFrameSchema: z.ZodObject<{
|
|
101
|
+
type: z.ZodLiteral<"hosts.route.frame">;
|
|
102
|
+
payload: z.ZodObject<{
|
|
103
|
+
subscriptionId: z.ZodString;
|
|
104
|
+
data: z.ZodString;
|
|
105
|
+
binary: z.ZodLiteral<false>;
|
|
106
|
+
}, z.core.$strip>;
|
|
107
|
+
}, z.core.$strip>;
|
|
108
|
+
export declare const HostsRouteClosedSchema: z.ZodObject<{
|
|
109
|
+
type: z.ZodLiteral<"hosts.route.closed">;
|
|
110
|
+
payload: z.ZodObject<{
|
|
111
|
+
subscriptionId: z.ZodString;
|
|
112
|
+
code: z.ZodString;
|
|
113
|
+
message: z.ZodString;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
}, z.core.$strip>;
|
|
116
|
+
export declare const HostsLinkOpenRequestSchema: z.ZodObject<{
|
|
117
|
+
type: z.ZodLiteral<"hosts.link.open.request">;
|
|
118
|
+
requestId: z.ZodString;
|
|
119
|
+
channelId: z.ZodString;
|
|
120
|
+
}, z.core.$strip>;
|
|
121
|
+
export declare const HostsLinkOpenResponseSchema: z.ZodObject<{
|
|
122
|
+
type: z.ZodLiteral<"hosts.link.open.response">;
|
|
123
|
+
payload: z.ZodObject<{
|
|
124
|
+
requestId: z.ZodString;
|
|
125
|
+
routeId: z.ZodString;
|
|
126
|
+
}, z.core.$strip>;
|
|
127
|
+
}, z.core.$strip>;
|
|
128
|
+
export declare const HostsLinkAckSchema: z.ZodObject<{
|
|
129
|
+
type: z.ZodLiteral<"hosts.link.ack.request">;
|
|
130
|
+
routeId: z.ZodString;
|
|
131
|
+
sequence: z.ZodNumber;
|
|
132
|
+
}, z.core.$strip>;
|
|
133
|
+
//# sourceMappingURL=hosts.d.ts.map
|
package/dist/hosts.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const HostMetadataSchema = z.record(z.string().max(256), z.string().max(4096));
|
|
3
|
+
export const HostAddSchema = z.object({
|
|
4
|
+
connection: z.string().min(1).max(16384),
|
|
5
|
+
label: z.string().max(256).optional(),
|
|
6
|
+
metadata: HostMetadataSchema.optional(),
|
|
7
|
+
sourceKey: z.string().min(1).max(256).optional(),
|
|
8
|
+
});
|
|
9
|
+
export const HostUpdateSchema = z.object({
|
|
10
|
+
label: z.string().max(256).nullable().optional(),
|
|
11
|
+
metadata: HostMetadataSchema.optional(),
|
|
12
|
+
enabled: z.boolean().optional(),
|
|
13
|
+
connection: z.string().min(1).max(16384).optional(),
|
|
14
|
+
replaceIdentity: z.boolean().optional(),
|
|
15
|
+
});
|
|
16
|
+
export const HostSummarySchema = z.object({
|
|
17
|
+
registrationId: z.string(),
|
|
18
|
+
serverId: z.string().nullable(),
|
|
19
|
+
label: z.string().nullable(),
|
|
20
|
+
source: z.object({ id: z.string(), key: z.string() }),
|
|
21
|
+
metadata: HostMetadataSchema,
|
|
22
|
+
enabled: z.boolean(),
|
|
23
|
+
status: z.enum(["connecting", "online", "offline", "error", "disabled"]),
|
|
24
|
+
targetDescription: z.string(),
|
|
25
|
+
lastOnlineAt: z.string().nullable(),
|
|
26
|
+
nextRetryAt: z.string().nullable(),
|
|
27
|
+
error: z.object({ code: z.string(), message: z.string() }).nullable(),
|
|
28
|
+
});
|
|
29
|
+
export const HostDirectorySchema = z.object({
|
|
30
|
+
self: z.object({ serverId: z.string(), label: z.string() }),
|
|
31
|
+
hosts: z.array(HostSummarySchema),
|
|
32
|
+
});
|
|
33
|
+
export const HostsRouteOpenRequestSchema = z.object({
|
|
34
|
+
type: z.literal("hosts.route.open.request"),
|
|
35
|
+
requestId: z.string(),
|
|
36
|
+
serverId: z.string(),
|
|
37
|
+
scopeId: z.string().min(1).max(256),
|
|
38
|
+
});
|
|
39
|
+
export const HostsRouteFrameRequestSchema = z.object({
|
|
40
|
+
type: z.literal("hosts.route.frame.request"),
|
|
41
|
+
routeId: z.string(),
|
|
42
|
+
data: z.string().max(100 * 1024 * 1024),
|
|
43
|
+
binary: z.literal(false),
|
|
44
|
+
});
|
|
45
|
+
export const HostsRouteCloseRequestSchema = z.object({
|
|
46
|
+
type: z.literal("hosts.route.close.request"),
|
|
47
|
+
routeId: z.string().optional(),
|
|
48
|
+
scopeId: z.string().optional(),
|
|
49
|
+
});
|
|
50
|
+
export const HostsRouteOpenResponseSchema = z.object({
|
|
51
|
+
type: z.literal("hosts.route.open.response"),
|
|
52
|
+
payload: z.object({ requestId: z.string(), routeId: z.string() }),
|
|
53
|
+
});
|
|
54
|
+
export const HostsRouteFrameSchema = z.object({
|
|
55
|
+
type: z.literal("hosts.route.frame"),
|
|
56
|
+
payload: z.object({ subscriptionId: z.string(), data: z.string(), binary: z.literal(false) }),
|
|
57
|
+
});
|
|
58
|
+
export const HostsRouteClosedSchema = z.object({
|
|
59
|
+
type: z.literal("hosts.route.closed"),
|
|
60
|
+
payload: z.object({ subscriptionId: z.string(), code: z.string(), message: z.string() }),
|
|
61
|
+
});
|
|
62
|
+
// Logical B sessions are admitted under the authenticated physical link, never hello auth.
|
|
63
|
+
export const HostsLinkOpenRequestSchema = z.object({
|
|
64
|
+
type: z.literal("hosts.link.open.request"),
|
|
65
|
+
requestId: z.string(),
|
|
66
|
+
channelId: z.string().min(1).max(256),
|
|
67
|
+
});
|
|
68
|
+
export const HostsLinkOpenResponseSchema = z.object({
|
|
69
|
+
type: z.literal("hosts.link.open.response"),
|
|
70
|
+
payload: z.object({
|
|
71
|
+
requestId: z.string(),
|
|
72
|
+
routeId: z.string(),
|
|
73
|
+
}),
|
|
74
|
+
});
|
|
75
|
+
// The receiving daemon acknowledges each forwarded frame after its own write settles,
|
|
76
|
+
// so a slow receiver applies backpressure to the destination instead of buffering.
|
|
77
|
+
export const HostsLinkAckSchema = z.object({
|
|
78
|
+
type: z.literal("hosts.link.ack.request"),
|
|
79
|
+
routeId: z.string(),
|
|
80
|
+
sequence: z.number().int().positive(),
|
|
81
|
+
});
|
|
82
|
+
//# sourceMappingURL=hosts.js.map
|