@scotthuang/agent-knock-knock 0.12.15 → 0.12.16
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/CHANGELOG.md +21 -0
- package/README.md +5 -1
- package/dist/src/cli-core.js +61 -2
- package/dist/src/cli-core.js.map +1 -1
- package/dist/src/command-json-callback-transport.d.ts +38 -0
- package/dist/src/command-json-callback-transport.js +298 -0
- package/dist/src/command-json-callback-transport.js.map +1 -0
- package/dist/src/host-adapter.d.ts +52 -0
- package/dist/src/host-adapter.js +123 -0
- package/dist/src/host-adapter.js.map +1 -0
- package/dist/src/host-bridge-mcp.d.ts +22 -0
- package/dist/src/host-bridge-mcp.js +145 -0
- package/dist/src/host-bridge-mcp.js.map +1 -0
- package/dist/src/host-bridge-tools.d.ts +61 -0
- package/dist/src/host-bridge-tools.js +130 -0
- package/dist/src/host-bridge-tools.js.map +1 -0
- package/dist/src/host-bridge.d.ts +28 -0
- package/dist/src/host-bridge.js +156 -0
- package/dist/src/host-bridge.js.map +1 -0
- package/dist/src/host-lifecycle-service.d.ts +39 -0
- package/dist/src/host-lifecycle-service.js +101 -0
- package/dist/src/host-lifecycle-service.js.map +1 -0
- package/dist/src/host-profile-callback-transport.d.ts +14 -0
- package/dist/src/host-profile-callback-transport.js +70 -0
- package/dist/src/host-profile-callback-transport.js.map +1 -0
- package/dist/src/host-profile-cli-adapter.d.ts +8 -0
- package/dist/src/host-profile-cli-adapter.js +169 -0
- package/dist/src/host-profile-cli-adapter.js.map +1 -0
- package/dist/src/host-profile-runtime.d.ts +55 -0
- package/dist/src/host-profile-runtime.js +152 -0
- package/dist/src/host-profile-runtime.js.map +1 -0
- package/dist/src/host-profile.d.ts +121 -0
- package/dist/src/host-profile.js +723 -0
- package/dist/src/host-profile.js.map +1 -0
- package/dist/src/native-thread-resume-snapshot.js +1 -1
- package/dist/src/native-thread-resume-snapshot.js.map +1 -1
- package/dist/src/openclaw-plugin-command-adapter.d.ts +13 -0
- package/dist/src/openclaw-plugin-command-adapter.js +125 -47
- package/dist/src/openclaw-plugin-command-adapter.js.map +1 -1
- package/dist/src/openclaw-plugin-helpers.js +1 -1
- package/dist/src/openclaw-plugin-helpers.js.map +1 -1
- package/dist/src/openclaw-plugin-supervisor.d.ts +1 -1
- package/dist/src/openclaw-plugin-supervisor.js +44 -72
- package/dist/src/openclaw-plugin-supervisor.js.map +1 -1
- package/dist/src/terminal-command-cli-adapter.js +4 -4
- package/dist/src/terminal-command-cli-adapter.js.map +1 -1
- package/dist/src/terminal-dispatch-presenter.js +1 -1
- package/dist/src/terminal-dispatch-presenter.js.map +1 -1
- package/dist/src/terminal-watch-callback-cli-adapter.d.ts +2 -1
- package/dist/src/terminal-watch-callback-cli-adapter.js +4 -3
- package/dist/src/terminal-watch-callback-cli-adapter.js.map +1 -1
- package/dist/src/terminal-watch-cli-adapter.d.ts +4 -0
- package/dist/src/terminal-watch-cli-adapter.js +33 -3
- package/dist/src/terminal-watch-cli-adapter.js.map +1 -1
- package/dist/src/terminal-watch-service.d.ts +5 -0
- package/dist/src/terminal-watch-service.js +6 -1
- package/dist/src/terminal-watch-service.js.map +1 -1
- package/dist/src/terminal-watch-store.d.ts +2 -0
- package/dist/src/terminal-watch-store.js +13 -0
- package/dist/src/terminal-watch-store.js.map +1 -1
- package/docs/host-bridge-profiles.md +325 -0
- package/examples/host-profiles/command-json-starter.json +62 -0
- package/package.json +30 -2
- package/schemas/host-profile-v1.schema.json +266 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface HostProfileCliOptions extends Record<string, unknown> {
|
|
2
|
+
action?: unknown;
|
|
3
|
+
profile?: unknown;
|
|
4
|
+
host?: unknown;
|
|
5
|
+
hostVersion?: unknown;
|
|
6
|
+
}
|
|
7
|
+
export declare function runHostProfileCommand(options: HostProfileCliOptions): void;
|
|
8
|
+
export declare function runHostProfileDoctor(options: HostProfileCliOptions): void;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { assertHostProfileCompatibility, assertHostProfileCallbackExecutableReady, hostProfileControllerScope, resolveHostProfileControllerContext } from "./host-profile.js";
|
|
3
|
+
import { cliCwd, cliEnv, setCliExitCode, writeCliStdout } from "./cli-runtime-context.js";
|
|
4
|
+
import { writeCliJson } from "./cli-command-runtime.js";
|
|
5
|
+
import { defaultHostProfileRegistry, selectHostProfileV1 } from "./host-profile-runtime.js";
|
|
6
|
+
const HOST_PROFILE_STARTER_URL = new URL("../../examples/host-profiles/command-json-starter.json", import.meta.url);
|
|
7
|
+
export function runHostProfileCommand(options) {
|
|
8
|
+
const action = requiredString(options.action, "host-profile action");
|
|
9
|
+
if (action === "example") {
|
|
10
|
+
if (options.profile !== undefined) {
|
|
11
|
+
throw new Error("host-profile example does not accept a Profile path");
|
|
12
|
+
}
|
|
13
|
+
writeCliStdout(fs.readFileSync(HOST_PROFILE_STARTER_URL, "utf8"));
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (action === "list") {
|
|
17
|
+
if (options.profile !== undefined) {
|
|
18
|
+
throw new Error("host-profile list does not accept a Profile path");
|
|
19
|
+
}
|
|
20
|
+
writeCliJson({
|
|
21
|
+
schema: "agent-knock-knock/host-profile-list",
|
|
22
|
+
version: 1,
|
|
23
|
+
profiles: defaultHostProfileRegistry.list()
|
|
24
|
+
});
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (action !== "validate") {
|
|
28
|
+
throw new Error("host-profile action must be example, list, or validate");
|
|
29
|
+
}
|
|
30
|
+
const selected = selectHostProfileV1(requiredString(options.profile, "host-profile validate path or built-in id"), { cwd: cliCwd(), registry: defaultHostProfileRegistry });
|
|
31
|
+
const compatibility = optionalCompatibility(options);
|
|
32
|
+
if (compatibility) {
|
|
33
|
+
assertHostProfileCompatibility(selected.profile, compatibility);
|
|
34
|
+
}
|
|
35
|
+
const controllerScope = hostProfileControllerScope(selected.profile);
|
|
36
|
+
writeCliJson({
|
|
37
|
+
ok: true,
|
|
38
|
+
schema: selected.profile.schema,
|
|
39
|
+
version: selected.profile.version,
|
|
40
|
+
source: selected.source,
|
|
41
|
+
selection: selected.selection,
|
|
42
|
+
id: selected.profile.id,
|
|
43
|
+
revision: selected.profile.revision,
|
|
44
|
+
fingerprint: selected.fingerprint,
|
|
45
|
+
compatibility: selected.profile.compatibility,
|
|
46
|
+
compatibility_checked: compatibility !== undefined,
|
|
47
|
+
controller_context_driver: selected.profile.controllerContext.driver,
|
|
48
|
+
controller_context_scope: controllerScope,
|
|
49
|
+
standalone_bridge_compatible: controllerScope === "startup_v1",
|
|
50
|
+
callback_driver: selected.profile.callback.driver
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
export function runHostProfileDoctor(options) {
|
|
54
|
+
const checks = [];
|
|
55
|
+
let selected;
|
|
56
|
+
try {
|
|
57
|
+
selected = selectHostProfileV1(requiredString(options.profile, "--host-profile"), { cwd: cliCwd(), registry: defaultHostProfileRegistry });
|
|
58
|
+
checks.push({ name: "profile", status: "ok" });
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
checks.push({
|
|
62
|
+
name: "profile",
|
|
63
|
+
status: "error",
|
|
64
|
+
detail: errorMessage(error)
|
|
65
|
+
});
|
|
66
|
+
finishDoctor(checks);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const controllerScope = hostProfileControllerScope(selected.profile);
|
|
70
|
+
if (controllerScope === "route_bound_v1") {
|
|
71
|
+
checks.push({
|
|
72
|
+
name: "standalone_bridge_scope",
|
|
73
|
+
status: "error",
|
|
74
|
+
scope: controllerScope,
|
|
75
|
+
detail: "route_bound_v1 is for a Host-native connector and is not supported " +
|
|
76
|
+
"by the standalone Host Bridge"
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
const compatibility = requiredCompatibility(options);
|
|
81
|
+
assertHostProfileCompatibility(selected.profile, compatibility);
|
|
82
|
+
checks.push({
|
|
83
|
+
name: "host_compatibility",
|
|
84
|
+
status: "ok",
|
|
85
|
+
host: compatibility.host,
|
|
86
|
+
version: compatibility.version,
|
|
87
|
+
range: selected.profile.compatibility.range
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
checks.push({
|
|
92
|
+
name: "host_compatibility",
|
|
93
|
+
status: "error",
|
|
94
|
+
detail: errorMessage(error)
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
resolveHostProfileControllerContext(selected.profile, cliEnv());
|
|
99
|
+
checks.push({
|
|
100
|
+
name: "controller_context",
|
|
101
|
+
status: "ok",
|
|
102
|
+
variable: selected.profile.controllerContext.sessionIdVariable
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
checks.push({
|
|
107
|
+
name: "controller_context",
|
|
108
|
+
status: "error",
|
|
109
|
+
variable: selected.profile.controllerContext.sessionIdVariable,
|
|
110
|
+
detail: errorMessage(error)
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
assertHostProfileCallbackExecutableReady(selected.profile.callback.executable, selected.profile.callback.environment.allow);
|
|
115
|
+
checks.push({
|
|
116
|
+
name: "callback_executable",
|
|
117
|
+
status: "ok",
|
|
118
|
+
path: selected.profile.callback.executable
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
checks.push({
|
|
123
|
+
name: "callback_executable",
|
|
124
|
+
status: "error",
|
|
125
|
+
path: selected.profile.callback.executable,
|
|
126
|
+
detail: errorMessage(error)
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
finishDoctor(checks, {
|
|
130
|
+
profile_id: selected.profile.id,
|
|
131
|
+
profile_revision: selected.profile.revision,
|
|
132
|
+
profile_fingerprint: selected.fingerprint,
|
|
133
|
+
controller_context_scope: controllerScope,
|
|
134
|
+
standalone_bridge_compatible: controllerScope === "startup_v1"
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function finishDoctor(checks, detail = {}) {
|
|
138
|
+
const ok = checks.every((check) => check.status === "ok");
|
|
139
|
+
writeCliJson({
|
|
140
|
+
ok,
|
|
141
|
+
mode: "host_bridge",
|
|
142
|
+
...detail,
|
|
143
|
+
checks
|
|
144
|
+
});
|
|
145
|
+
if (!ok)
|
|
146
|
+
setCliExitCode(1);
|
|
147
|
+
}
|
|
148
|
+
function optionalCompatibility(options) {
|
|
149
|
+
if (options.host === undefined && options.hostVersion === undefined) {
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
return requiredCompatibility(options);
|
|
153
|
+
}
|
|
154
|
+
function requiredCompatibility(options) {
|
|
155
|
+
return {
|
|
156
|
+
host: requiredString(options.host, "--host"),
|
|
157
|
+
version: requiredString(options.hostVersion, "--host-version")
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function requiredString(value, label) {
|
|
161
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
162
|
+
throw new Error(`${label} is required`);
|
|
163
|
+
}
|
|
164
|
+
return value;
|
|
165
|
+
}
|
|
166
|
+
function errorMessage(error) {
|
|
167
|
+
return error instanceof Error ? error.message : String(error);
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=host-profile-cli-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-profile-cli-adapter.js","sourceRoot":"","sources":["../../src/host-profile-cli-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EACL,8BAA8B,EAC9B,wCAAwC,EACxC,0BAA0B,EAC1B,mCAAmC,EACpC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,MAAM,EACN,MAAM,EACN,cAAc,EACd,cAAc,EACf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EACL,0BAA0B,EAC1B,m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,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC;IAC1D,YAAY,CAAC;QACX,EAAE;QACF,IAAI,EAAE,aAAa;QACnB,GAAG,MAAM;QACT,MAAM;KACP,CAAC,CAAC;IACH,IAAI,CAAC,EAAE;QAAE,cAAc,CAAC,CAAC,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,qBAAqB,CAC5B,OAA8B;IAE9B,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QACpE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC;AAED,SAAS,qBAAqB,CAC5B,OAA8B;IAE9B,OAAO;QACL,IAAI,EAAE,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;QAC5C,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,WAAW,EAAE,gBAAgB,CAAC;KAC/D,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,KAAc,EAAE,KAAa;IACnD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,cAAc,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type HostProfileControllerScopeV1, type HostProfileRegistry, type HostProfileV1 } from "./host-profile.js";
|
|
2
|
+
import { type CallbackRouteV1 } from "./callback-transport.js";
|
|
3
|
+
export declare const AKK_HOST_PROFILE_SELECTION: "AKK_HOST_PROFILE_SELECTION";
|
|
4
|
+
export declare const AKK_HOST_PROFILE_SOURCE: "AKK_HOST_PROFILE_SOURCE";
|
|
5
|
+
export declare const AKK_HOST_PROFILE_FINGERPRINT: "AKK_HOST_PROFILE_FINGERPRINT";
|
|
6
|
+
export declare const AKK_HOST_PROFILE_HOST: "AKK_HOST_PROFILE_HOST";
|
|
7
|
+
export declare const AKK_HOST_PROFILE_HOST_VERSION: "AKK_HOST_PROFILE_HOST_VERSION";
|
|
8
|
+
export declare const defaultHostProfileRegistry: HostProfileRegistry;
|
|
9
|
+
export interface SelectedHostProfileV1 {
|
|
10
|
+
readonly source: "built_in" | "file";
|
|
11
|
+
readonly selection: string;
|
|
12
|
+
readonly fingerprint: string;
|
|
13
|
+
readonly profile: HostProfileV1;
|
|
14
|
+
}
|
|
15
|
+
export interface TrustedHostProfileRuntimeV1 {
|
|
16
|
+
readonly selected: SelectedHostProfileV1;
|
|
17
|
+
readonly controllerScope: HostProfileControllerScopeV1;
|
|
18
|
+
readonly controllerSessionId: string;
|
|
19
|
+
readonly host: string;
|
|
20
|
+
readonly hostVersion: string;
|
|
21
|
+
readonly callbackRoute: CallbackRouteV1;
|
|
22
|
+
}
|
|
23
|
+
export interface SelectHostProfileOptions {
|
|
24
|
+
readonly cwd?: string;
|
|
25
|
+
readonly registry?: HostProfileRegistry;
|
|
26
|
+
}
|
|
27
|
+
export interface CreateTrustedHostProfileRuntimeOptions extends SelectHostProfileOptions {
|
|
28
|
+
readonly selection: string;
|
|
29
|
+
readonly host: string;
|
|
30
|
+
readonly hostVersion: string;
|
|
31
|
+
readonly environment: Readonly<Record<string, string | undefined>>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Resolve one startup-selected Profile. A registry id wins over filesystem
|
|
35
|
+
* interpretation so an explicit user file cannot shadow a bundled Profile.
|
|
36
|
+
*/
|
|
37
|
+
export declare function selectHostProfileV1(selection: string, options?: SelectHostProfileOptions): SelectedHostProfileV1;
|
|
38
|
+
/** Capture all authority needed by a Host-launched Bridge at startup. */
|
|
39
|
+
export declare function createTrustedHostProfileRuntime(options: CreateTrustedHostProfileRuntimeOptions): TrustedHostProfileRuntimeV1;
|
|
40
|
+
/**
|
|
41
|
+
* Build the private child-process environment used by the Bridge. The exact
|
|
42
|
+
* Profile fingerprint and route-creation controller identity are captured
|
|
43
|
+
* once; model-facing tool arguments have no route/profile fields and cannot
|
|
44
|
+
* override them. A route-bound callback later uses only that persisted route.
|
|
45
|
+
*/
|
|
46
|
+
export declare function hostProfileRelayEnvironment(runtime: TrustedHostProfileRuntimeV1, baseEnvironment: Readonly<NodeJS.ProcessEnv>): NodeJS.ProcessEnv;
|
|
47
|
+
/**
|
|
48
|
+
* Re-resolve trusted Bridge authority inside a CLI/monitor child. User Profile
|
|
49
|
+
* edits after Bridge startup fail closed unless their complete fingerprint is
|
|
50
|
+
* unchanged.
|
|
51
|
+
*/
|
|
52
|
+
export declare function trustedHostProfileRuntimeFromEnvironment(environment: Readonly<NodeJS.ProcessEnv>, options?: SelectHostProfileOptions): TrustedHostProfileRuntimeV1 | undefined;
|
|
53
|
+
/** Add only trusted in-process route fields needed by new Turn/Watch creation. */
|
|
54
|
+
export declare function applyTrustedHostProfileCliOptions(commandName: string | undefined, options: Readonly<Record<string, unknown>>, environment: Readonly<NodeJS.ProcessEnv>, cwd: string): Record<string, unknown>;
|
|
55
|
+
export declare function callbackRouteForHostProfile(profile: HostProfileV1, controllerSessionId: string): CallbackRouteV1;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { assertHostProfileCompatibility, createHostProfileRegistry, hostProfileControllerScope, hostProfileFingerprint, HOST_PROFILE_PRIVATE_ENVIRONMENT_VARIABLES, loadHostProfileV1, resolveHostProfileControllerContext } from "./host-profile.js";
|
|
2
|
+
import { CALLBACK_ROUTE_SCHEMA, CALLBACK_ROUTE_VERSION } from "./callback-transport.js";
|
|
3
|
+
export const AKK_HOST_PROFILE_SELECTION = HOST_PROFILE_PRIVATE_ENVIRONMENT_VARIABLES[0];
|
|
4
|
+
export const AKK_HOST_PROFILE_SOURCE = HOST_PROFILE_PRIVATE_ENVIRONMENT_VARIABLES[1];
|
|
5
|
+
export const AKK_HOST_PROFILE_FINGERPRINT = HOST_PROFILE_PRIVATE_ENVIRONMENT_VARIABLES[2];
|
|
6
|
+
export const AKK_HOST_PROFILE_HOST = HOST_PROFILE_PRIVATE_ENVIRONMENT_VARIABLES[3];
|
|
7
|
+
export const AKK_HOST_PROFILE_HOST_VERSION = HOST_PROFILE_PRIVATE_ENVIRONMENT_VARIABLES[4];
|
|
8
|
+
export const defaultHostProfileRegistry = createHostProfileRegistry();
|
|
9
|
+
/**
|
|
10
|
+
* Resolve one startup-selected Profile. A registry id wins over filesystem
|
|
11
|
+
* interpretation so an explicit user file cannot shadow a bundled Profile.
|
|
12
|
+
*/
|
|
13
|
+
export function selectHostProfileV1(selection, options = {}) {
|
|
14
|
+
const requested = requiredCleanString(selection, "host profile selection");
|
|
15
|
+
const registry = options.registry ?? defaultHostProfileRegistry;
|
|
16
|
+
const builtIn = registry.resolve(requested);
|
|
17
|
+
if (builtIn) {
|
|
18
|
+
return Object.freeze({
|
|
19
|
+
source: "built_in",
|
|
20
|
+
selection: builtIn.id,
|
|
21
|
+
fingerprint: hostProfileFingerprint(builtIn),
|
|
22
|
+
profile: builtIn
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
const loaded = loadHostProfileV1(requested, {
|
|
26
|
+
cwd: options.cwd,
|
|
27
|
+
registry
|
|
28
|
+
});
|
|
29
|
+
return Object.freeze({
|
|
30
|
+
source: "file",
|
|
31
|
+
selection: loaded.path,
|
|
32
|
+
fingerprint: loaded.fingerprint,
|
|
33
|
+
profile: loaded.profile
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/** Capture all authority needed by a Host-launched Bridge at startup. */
|
|
37
|
+
export function createTrustedHostProfileRuntime(options) {
|
|
38
|
+
const selected = selectHostProfileV1(options.selection, options);
|
|
39
|
+
const host = requiredCleanString(options.host, "controller Host id");
|
|
40
|
+
const hostVersion = requiredCleanString(options.hostVersion, "controller Host version");
|
|
41
|
+
assertHostProfileCompatibility(selected.profile, {
|
|
42
|
+
host,
|
|
43
|
+
version: hostVersion
|
|
44
|
+
});
|
|
45
|
+
const context = resolveHostProfileControllerContext(selected.profile, options.environment);
|
|
46
|
+
return Object.freeze({
|
|
47
|
+
selected,
|
|
48
|
+
controllerScope: hostProfileControllerScope(selected.profile),
|
|
49
|
+
controllerSessionId: context.controllerSessionId,
|
|
50
|
+
host,
|
|
51
|
+
hostVersion,
|
|
52
|
+
callbackRoute: callbackRouteForHostProfile(selected.profile, context.controllerSessionId)
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Build the private child-process environment used by the Bridge. The exact
|
|
57
|
+
* Profile fingerprint and route-creation controller identity are captured
|
|
58
|
+
* once; model-facing tool arguments have no route/profile fields and cannot
|
|
59
|
+
* override them. A route-bound callback later uses only that persisted route.
|
|
60
|
+
*/
|
|
61
|
+
export function hostProfileRelayEnvironment(runtime, baseEnvironment) {
|
|
62
|
+
return {
|
|
63
|
+
...baseEnvironment,
|
|
64
|
+
[AKK_HOST_PROFILE_SELECTION]: runtime.selected.selection,
|
|
65
|
+
[AKK_HOST_PROFILE_SOURCE]: runtime.selected.source,
|
|
66
|
+
[AKK_HOST_PROFILE_FINGERPRINT]: runtime.selected.fingerprint,
|
|
67
|
+
[AKK_HOST_PROFILE_HOST]: runtime.host,
|
|
68
|
+
[AKK_HOST_PROFILE_HOST_VERSION]: runtime.hostVersion,
|
|
69
|
+
[runtime.selected.profile.controllerContext.sessionIdVariable]: runtime.controllerSessionId
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Re-resolve trusted Bridge authority inside a CLI/monitor child. User Profile
|
|
74
|
+
* edits after Bridge startup fail closed unless their complete fingerprint is
|
|
75
|
+
* unchanged.
|
|
76
|
+
*/
|
|
77
|
+
export function trustedHostProfileRuntimeFromEnvironment(environment, options = {}) {
|
|
78
|
+
const selection = environment[AKK_HOST_PROFILE_SELECTION];
|
|
79
|
+
const markerValues = [
|
|
80
|
+
environment[AKK_HOST_PROFILE_SOURCE],
|
|
81
|
+
environment[AKK_HOST_PROFILE_FINGERPRINT],
|
|
82
|
+
environment[AKK_HOST_PROFILE_HOST],
|
|
83
|
+
environment[AKK_HOST_PROFILE_HOST_VERSION]
|
|
84
|
+
];
|
|
85
|
+
if (selection === undefined && markerValues.every((value) => value === undefined)) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
if (selection === undefined || markerValues.some((value) => value === undefined)) {
|
|
89
|
+
throw new Error("trusted Host Profile runtime environment is incomplete");
|
|
90
|
+
}
|
|
91
|
+
const runtime = createTrustedHostProfileRuntime({
|
|
92
|
+
selection,
|
|
93
|
+
host: environment[AKK_HOST_PROFILE_HOST],
|
|
94
|
+
hostVersion: environment[AKK_HOST_PROFILE_HOST_VERSION],
|
|
95
|
+
environment,
|
|
96
|
+
...options
|
|
97
|
+
});
|
|
98
|
+
if (runtime.selected.source !== environment[AKK_HOST_PROFILE_SOURCE]) {
|
|
99
|
+
throw new Error("trusted Host Profile source changed after Bridge startup");
|
|
100
|
+
}
|
|
101
|
+
if (runtime.selected.fingerprint !== environment[AKK_HOST_PROFILE_FINGERPRINT]) {
|
|
102
|
+
throw new Error("trusted Host Profile changed after Bridge startup; restart the Host Bridge");
|
|
103
|
+
}
|
|
104
|
+
return runtime;
|
|
105
|
+
}
|
|
106
|
+
/** Add only trusted in-process route fields needed by new Turn/Watch creation. */
|
|
107
|
+
export function applyTrustedHostProfileCliOptions(commandName, options, environment, cwd) {
|
|
108
|
+
const runtime = trustedHostProfileRuntimeFromEnvironment(environment, { cwd });
|
|
109
|
+
if (!runtime)
|
|
110
|
+
return options;
|
|
111
|
+
const createsManagedTurn = commandName === "delegate" ||
|
|
112
|
+
(commandName === "send" && !nonBlankString(options.turn));
|
|
113
|
+
const ownsTerminalWatchRoute = commandName === "watch-terminal" ||
|
|
114
|
+
commandName === "reconcile-watches";
|
|
115
|
+
if (!createsManagedTurn && !ownsTerminalWatchRoute) {
|
|
116
|
+
return options;
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
...options,
|
|
120
|
+
callbackRoute: runtime.callbackRoute,
|
|
121
|
+
callbackRouteControllerScope: runtime.controllerScope,
|
|
122
|
+
openclawSession: runtime.controllerSessionId,
|
|
123
|
+
gatewaySession: runtime.controllerSessionId,
|
|
124
|
+
openclawBin: "agent-knock-knock-host-bridge"
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
export function callbackRouteForHostProfile(profile, controllerSessionId) {
|
|
128
|
+
return Object.freeze({
|
|
129
|
+
schema: CALLBACK_ROUTE_SCHEMA,
|
|
130
|
+
version: CALLBACK_ROUTE_VERSION,
|
|
131
|
+
transport: profile.callback.driver,
|
|
132
|
+
profile_id: profile.id,
|
|
133
|
+
profile_revision: profile.revision,
|
|
134
|
+
controller_session_id: requiredCleanString(controllerSessionId, "controller session id"),
|
|
135
|
+
capabilities: Object.freeze({ wake: true, respond: true })
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function requiredCleanString(value, label) {
|
|
139
|
+
if (typeof value !== "string" ||
|
|
140
|
+
value.length === 0 ||
|
|
141
|
+
value.trim() !== value ||
|
|
142
|
+
/[\u0000-\u001f\u007f]/u.test(value)) {
|
|
143
|
+
throw new Error(`${label} is missing or invalid`);
|
|
144
|
+
}
|
|
145
|
+
return value;
|
|
146
|
+
}
|
|
147
|
+
function nonBlankString(value) {
|
|
148
|
+
return typeof value === "string" && value.trim().length > 0
|
|
149
|
+
? value
|
|
150
|
+
: undefined;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=host-profile-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-profile-runtime.js","sourceRoot":"","sources":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AAM;QAClC,UAAU,EAAE,OAAO,CAAC,EAAE;QACtB,gBAAgB,EAAE,OAAO,CAAC,QAAQ;QAClC,qBAAqB,EAAE,mBAAmB,CACxC,mBAAmB,EACnB,uBAAuB,CACxB;QACD,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;KAC3D,CAAC,CAAC;AACL,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAc,EAAE,KAAa;IACxD,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,CAAC,MAAM,KAAK,CAAC;QAClB,KAAK,CAAC,IAAI,EAAE,KAAK,KAAK;QACtB,wBAAwB,CAAC,IAAI,CAAC,KAAK,CAAC,EACpC,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,wBAAwB,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QACzD,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export declare const HOST_PROFILE_SCHEMA = "agent-knock-knock/host-profile";
|
|
2
|
+
export declare const HOST_PROFILE_VERSION: 1;
|
|
3
|
+
export declare const HOST_PROFILE_JSON_SCHEMA: string;
|
|
4
|
+
export declare const HOST_PROFILE_BUILTIN_ID_PREFIX = "builtin-";
|
|
5
|
+
export declare const HOST_PROFILE_MAX_FILE_BYTES: number;
|
|
6
|
+
export declare const HOST_PROFILE_MAX_TIMEOUT_MS = 30000;
|
|
7
|
+
export declare const HOST_PROFILE_MAX_OUTPUT_BYTES: number;
|
|
8
|
+
export declare const HOST_PROFILE_PRIVATE_ENVIRONMENT_VARIABLES: readonly ["AKK_HOST_PROFILE_SELECTION", "AKK_HOST_PROFILE_SOURCE", "AKK_HOST_PROFILE_FINGERPRINT", "AKK_HOST_PROFILE_HOST", "AKK_HOST_PROFILE_HOST_VERSION"];
|
|
9
|
+
export declare const HOST_PROFILE_PLACEHOLDERS: readonly ["controller.session_id", "envelope.delivery_id", "envelope.idempotency_key", "envelope.message_id", "envelope.body"];
|
|
10
|
+
export type HostProfilePlaceholder = (typeof HOST_PROFILE_PLACEHOLDERS)[number];
|
|
11
|
+
export type HostProfileAcknowledgementDispositionV1 = "accepted" | "retryable_failure" | "permanent_failure" | "uncertain";
|
|
12
|
+
export type HostProfileControllerScopeV1 = "startup_v1" | "route_bound_v1";
|
|
13
|
+
export interface HostProfileCompatibilityV1 {
|
|
14
|
+
readonly host: string;
|
|
15
|
+
readonly range: string;
|
|
16
|
+
}
|
|
17
|
+
export interface HostProfileEnvironmentControllerContextV1 {
|
|
18
|
+
readonly driver: "environment_v1";
|
|
19
|
+
readonly sessionIdVariable: string;
|
|
20
|
+
/**
|
|
21
|
+
* Omitted is the original v1 behavior and is equivalent to startup_v1.
|
|
22
|
+
* Keeping it omitted in the parsed model preserves existing fingerprints.
|
|
23
|
+
*/
|
|
24
|
+
readonly scope?: HostProfileControllerScopeV1;
|
|
25
|
+
}
|
|
26
|
+
export interface HostProfileCallbackEnvironmentV1 {
|
|
27
|
+
readonly allow: readonly string[];
|
|
28
|
+
}
|
|
29
|
+
export interface HostProfileJsonPointerV1 {
|
|
30
|
+
readonly jsonPointer: string;
|
|
31
|
+
}
|
|
32
|
+
export interface HostProfileDispositionAcknowledgementV1 {
|
|
33
|
+
readonly jsonPointer: string;
|
|
34
|
+
readonly mapping: Readonly<Record<string, HostProfileAcknowledgementDispositionV1>>;
|
|
35
|
+
}
|
|
36
|
+
export interface HostProfileAcknowledgementV1 {
|
|
37
|
+
readonly disposition: HostProfileDispositionAcknowledgementV1;
|
|
38
|
+
readonly acceptanceId: HostProfileJsonPointerV1;
|
|
39
|
+
readonly acknowledgedDeliveryId: HostProfileJsonPointerV1;
|
|
40
|
+
readonly acknowledgedMessageId: HostProfileJsonPointerV1;
|
|
41
|
+
}
|
|
42
|
+
export interface HostProfileCommandJsonCallbackV1 {
|
|
43
|
+
readonly driver: "command_json_v1";
|
|
44
|
+
readonly executable: string;
|
|
45
|
+
readonly arguments: readonly string[];
|
|
46
|
+
readonly stdin: "${envelope.body}";
|
|
47
|
+
readonly environment: HostProfileCallbackEnvironmentV1;
|
|
48
|
+
readonly timeoutMs: number;
|
|
49
|
+
readonly maxOutputBytes: number;
|
|
50
|
+
readonly acknowledgement: HostProfileAcknowledgementV1;
|
|
51
|
+
}
|
|
52
|
+
export interface HostProfileV1 {
|
|
53
|
+
readonly $schema: typeof HOST_PROFILE_JSON_SCHEMA;
|
|
54
|
+
readonly schema: typeof HOST_PROFILE_SCHEMA;
|
|
55
|
+
readonly version: typeof HOST_PROFILE_VERSION;
|
|
56
|
+
readonly id: string;
|
|
57
|
+
readonly revision: string;
|
|
58
|
+
readonly compatibility: HostProfileCompatibilityV1;
|
|
59
|
+
readonly controllerContext: HostProfileEnvironmentControllerContextV1;
|
|
60
|
+
readonly callback: HostProfileCommandJsonCallbackV1;
|
|
61
|
+
}
|
|
62
|
+
export interface ParseHostProfileOptions {
|
|
63
|
+
/** Built-ins alone may use the reserved built-in id namespace. */
|
|
64
|
+
source?: "user" | "built_in";
|
|
65
|
+
/** Exact ids already owned by a built-in registry. */
|
|
66
|
+
reservedIds?: Iterable<string>;
|
|
67
|
+
}
|
|
68
|
+
export interface LoadedHostProfileV1 {
|
|
69
|
+
readonly source: "file";
|
|
70
|
+
readonly path: string;
|
|
71
|
+
readonly fingerprint: string;
|
|
72
|
+
readonly profile: HostProfileV1;
|
|
73
|
+
}
|
|
74
|
+
export interface HostProfileRegistryEntryV1 {
|
|
75
|
+
readonly source: "built_in";
|
|
76
|
+
readonly id: string;
|
|
77
|
+
readonly revision: string;
|
|
78
|
+
readonly fingerprint: string;
|
|
79
|
+
readonly compatibility: HostProfileCompatibilityV1;
|
|
80
|
+
}
|
|
81
|
+
export interface HostProfileRegistry {
|
|
82
|
+
list(): readonly HostProfileRegistryEntryV1[];
|
|
83
|
+
resolve(id: string): HostProfileV1 | undefined;
|
|
84
|
+
isReserved(id: string): boolean;
|
|
85
|
+
}
|
|
86
|
+
export interface LoadHostProfileOptions {
|
|
87
|
+
cwd?: string;
|
|
88
|
+
registry?: HostProfileRegistry;
|
|
89
|
+
}
|
|
90
|
+
export interface ResolvedHostProfileControllerContextV1 {
|
|
91
|
+
readonly driver: "environment_v1";
|
|
92
|
+
readonly variable: string;
|
|
93
|
+
readonly controllerSessionId: string;
|
|
94
|
+
}
|
|
95
|
+
export interface HostProfileCompatibilityInputV1 {
|
|
96
|
+
readonly host: string;
|
|
97
|
+
readonly version: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Parse one untrusted Profile document into a deeply immutable v1 model.
|
|
101
|
+
*
|
|
102
|
+
* Runtime validation is deliberately implemented here instead of delegated to
|
|
103
|
+
* a JSON Schema package. The published schema is documentation and tooling;
|
|
104
|
+
* this parser remains the fail-closed authority used by AKK.
|
|
105
|
+
*/
|
|
106
|
+
export declare function parseHostProfileV1(value: unknown, options?: ParseHostProfileOptions): HostProfileV1;
|
|
107
|
+
/** Verify the configured callback path and its symlink target at Host startup. */
|
|
108
|
+
export declare function assertHostProfileCallbackExecutableReady(executable: string, environmentVariables?: readonly string[]): void;
|
|
109
|
+
export declare function hostProfileFingerprint(profile: HostProfileV1): string;
|
|
110
|
+
/** Create the immutable built-in Profile lookup used by later Bridge wiring. */
|
|
111
|
+
export declare function createHostProfileRegistry(builtInProfiles?: readonly unknown[]): HostProfileRegistry;
|
|
112
|
+
/** Load one explicit JSON file; no search path or implicit Profile selection. */
|
|
113
|
+
export declare function loadHostProfileV1(profilePath: string, options?: LoadHostProfileOptions): LoadedHostProfileV1;
|
|
114
|
+
/** Resolve trusted controller identity only from the Host-supplied environment. */
|
|
115
|
+
export declare function resolveHostProfileControllerContext(profile: HostProfileV1, environment: Readonly<Record<string, string | undefined>>): ResolvedHostProfileControllerContextV1;
|
|
116
|
+
/** Return whether one exact Host identity satisfies the Profile's AND range. */
|
|
117
|
+
export declare function hostProfileSupportsHostVersion(profile: HostProfileV1, input: HostProfileCompatibilityInputV1): boolean;
|
|
118
|
+
/** Assert compatibility before a Bridge is allowed to use a Profile. */
|
|
119
|
+
export declare function assertHostProfileCompatibility(profile: HostProfileV1, input: HostProfileCompatibilityInputV1): void;
|
|
120
|
+
/** Normalize the optional scope without changing legacy Profile fingerprints. */
|
|
121
|
+
export declare function hostProfileControllerScope(profile: HostProfileV1): HostProfileControllerScopeV1;
|