@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.
Files changed (64) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +5 -1
  3. package/dist/src/cli-core.js +61 -2
  4. package/dist/src/cli-core.js.map +1 -1
  5. package/dist/src/command-json-callback-transport.d.ts +38 -0
  6. package/dist/src/command-json-callback-transport.js +298 -0
  7. package/dist/src/command-json-callback-transport.js.map +1 -0
  8. package/dist/src/host-adapter.d.ts +52 -0
  9. package/dist/src/host-adapter.js +123 -0
  10. package/dist/src/host-adapter.js.map +1 -0
  11. package/dist/src/host-bridge-mcp.d.ts +22 -0
  12. package/dist/src/host-bridge-mcp.js +145 -0
  13. package/dist/src/host-bridge-mcp.js.map +1 -0
  14. package/dist/src/host-bridge-tools.d.ts +61 -0
  15. package/dist/src/host-bridge-tools.js +130 -0
  16. package/dist/src/host-bridge-tools.js.map +1 -0
  17. package/dist/src/host-bridge.d.ts +28 -0
  18. package/dist/src/host-bridge.js +156 -0
  19. package/dist/src/host-bridge.js.map +1 -0
  20. package/dist/src/host-lifecycle-service.d.ts +39 -0
  21. package/dist/src/host-lifecycle-service.js +101 -0
  22. package/dist/src/host-lifecycle-service.js.map +1 -0
  23. package/dist/src/host-profile-callback-transport.d.ts +14 -0
  24. package/dist/src/host-profile-callback-transport.js +70 -0
  25. package/dist/src/host-profile-callback-transport.js.map +1 -0
  26. package/dist/src/host-profile-cli-adapter.d.ts +8 -0
  27. package/dist/src/host-profile-cli-adapter.js +169 -0
  28. package/dist/src/host-profile-cli-adapter.js.map +1 -0
  29. package/dist/src/host-profile-runtime.d.ts +55 -0
  30. package/dist/src/host-profile-runtime.js +152 -0
  31. package/dist/src/host-profile-runtime.js.map +1 -0
  32. package/dist/src/host-profile.d.ts +121 -0
  33. package/dist/src/host-profile.js +723 -0
  34. package/dist/src/host-profile.js.map +1 -0
  35. package/dist/src/native-thread-resume-snapshot.js +1 -1
  36. package/dist/src/native-thread-resume-snapshot.js.map +1 -1
  37. package/dist/src/openclaw-plugin-command-adapter.d.ts +13 -0
  38. package/dist/src/openclaw-plugin-command-adapter.js +125 -47
  39. package/dist/src/openclaw-plugin-command-adapter.js.map +1 -1
  40. package/dist/src/openclaw-plugin-helpers.js +1 -1
  41. package/dist/src/openclaw-plugin-helpers.js.map +1 -1
  42. package/dist/src/openclaw-plugin-supervisor.d.ts +1 -1
  43. package/dist/src/openclaw-plugin-supervisor.js +44 -72
  44. package/dist/src/openclaw-plugin-supervisor.js.map +1 -1
  45. package/dist/src/terminal-command-cli-adapter.js +4 -4
  46. package/dist/src/terminal-command-cli-adapter.js.map +1 -1
  47. package/dist/src/terminal-dispatch-presenter.js +1 -1
  48. package/dist/src/terminal-dispatch-presenter.js.map +1 -1
  49. package/dist/src/terminal-watch-callback-cli-adapter.d.ts +2 -1
  50. package/dist/src/terminal-watch-callback-cli-adapter.js +4 -3
  51. package/dist/src/terminal-watch-callback-cli-adapter.js.map +1 -1
  52. package/dist/src/terminal-watch-cli-adapter.d.ts +4 -0
  53. package/dist/src/terminal-watch-cli-adapter.js +33 -3
  54. package/dist/src/terminal-watch-cli-adapter.js.map +1 -1
  55. package/dist/src/terminal-watch-service.d.ts +5 -0
  56. package/dist/src/terminal-watch-service.js +6 -1
  57. package/dist/src/terminal-watch-service.js.map +1 -1
  58. package/dist/src/terminal-watch-store.d.ts +2 -0
  59. package/dist/src/terminal-watch-store.js +13 -0
  60. package/dist/src/terminal-watch-store.js.map +1 -1
  61. package/docs/host-bridge-profiles.md +325 -0
  62. package/examples/host-profiles/command-json-starter.json +62 -0
  63. package/package.json +30 -2
  64. package/schemas/host-profile-v1.schema.json +266 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-bridge-mcp.js","sourceRoot":"","sources":["../../src/host-bridge-mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;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AAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,61 @@
1
+ export interface HostBridgeToolContext {
2
+ readonly sessionKey: string;
3
+ readonly sessionId: string;
4
+ }
5
+ export interface HostBridgeToolLogger {
6
+ debug?(message: string): void;
7
+ info(message: string): void;
8
+ warn(message: string): void;
9
+ error?(message: string): void;
10
+ }
11
+ export interface HostBridgeToolContent {
12
+ readonly type: string;
13
+ readonly text?: string;
14
+ readonly [key: string]: unknown;
15
+ }
16
+ export interface HostBridgeToolResult {
17
+ readonly content?: readonly HostBridgeToolContent[];
18
+ readonly details?: unknown;
19
+ readonly isError?: boolean;
20
+ readonly [key: string]: unknown;
21
+ }
22
+ export interface HostBridgeCommandResult {
23
+ readonly text: string;
24
+ readonly isError?: boolean;
25
+ }
26
+ export interface HostBridgeCommandDescriptor {
27
+ readonly name: string;
28
+ readonly description: string;
29
+ readonly acceptsArgs: boolean;
30
+ execute(args: string): Promise<HostBridgeCommandResult>;
31
+ }
32
+ export interface HostBridgeToolDescriptor {
33
+ readonly name: string;
34
+ readonly description: string;
35
+ readonly inputSchema: Readonly<Record<string, unknown>>;
36
+ execute(toolCallId: string, args: Readonly<Record<string, unknown>>): Promise<HostBridgeToolResult>;
37
+ }
38
+ export interface HostBridgeToolRegistry {
39
+ list(): readonly HostBridgeToolDescriptor[];
40
+ get(name: string): HostBridgeToolDescriptor | undefined;
41
+ execute(name: string, toolCallId: string, args: Readonly<Record<string, unknown>>): Promise<HostBridgeToolResult>;
42
+ }
43
+ export interface HostBridgeCommandToolRegistry extends HostBridgeToolRegistry {
44
+ command(): HostBridgeCommandDescriptor;
45
+ }
46
+ export interface CreateHostBridgeToolsOptions {
47
+ readonly relayPath: string;
48
+ readonly relayEnvironment: NodeJS.ProcessEnv;
49
+ readonly pluginConfig: Readonly<Record<string, unknown>>;
50
+ readonly logger: HostBridgeToolLogger;
51
+ readonly context: HostBridgeToolContext;
52
+ }
53
+ /**
54
+ * Capture the established AKK semantic tools behind a host-neutral registry.
55
+ *
56
+ * Tool factories are instantiated exactly once with the trusted controller
57
+ * context. Keeping the same API object and definitions alive also preserves
58
+ * the private-authority state owned by the OpenClaw-compatible implementation.
59
+ */
60
+ export declare function createHostBridgeToolRegistry(options: CreateHostBridgeToolsOptions): HostBridgeCommandToolRegistry;
61
+ export declare function createHostBridgeTools(options: CreateHostBridgeToolsOptions): readonly HostBridgeToolDescriptor[];
@@ -0,0 +1,130 @@
1
+ import { bindHostBridgeAsyncRelay, bindHostBridgeToolPresentation, bindOpenClawRelayEnvironment, bindOpenClawRelayPath, registerOpenClawCommands } from "./openclaw-plugin-command-adapter.js";
2
+ /**
3
+ * Capture the established AKK semantic tools behind a host-neutral registry.
4
+ *
5
+ * Tool factories are instantiated exactly once with the trusted controller
6
+ * context. Keeping the same API object and definitions alive also preserves
7
+ * the private-authority state owned by the OpenClaw-compatible implementation.
8
+ */
9
+ export function createHostBridgeToolRegistry(options) {
10
+ const descriptors = [];
11
+ const descriptorsByName = new Map();
12
+ let commandDescriptor;
13
+ const trustedContext = Object.freeze({
14
+ sessionKey: requiredString(options.context.sessionKey, "context.sessionKey"),
15
+ sessionId: requiredString(options.context.sessionId, "context.sessionId")
16
+ });
17
+ const api = {
18
+ pluginConfig: options.pluginConfig,
19
+ logger: options.logger,
20
+ registerCommand(command) {
21
+ if (commandDescriptor) {
22
+ throw new Error("host bridge registered more than one command");
23
+ }
24
+ const name = requiredString(command.name, "command name");
25
+ if (name !== "akk") {
26
+ throw new Error(`host bridge expected command akk, received ${name}`);
27
+ }
28
+ if (typeof command.description !== "string") {
29
+ throw new Error(`host bridge command ${name} has no description`);
30
+ }
31
+ if (typeof command.handler !== "function") {
32
+ throw new Error(`host bridge command ${name} has no handler`);
33
+ }
34
+ const handler = command.handler.bind(command);
35
+ commandDescriptor = Object.freeze({
36
+ name,
37
+ description: command.description,
38
+ acceptsArgs: command.acceptsArgs === true,
39
+ async execute(args) {
40
+ const result = await handler({
41
+ ...trustedContext,
42
+ args: typeof args === "string" ? args : ""
43
+ });
44
+ if (!isRecord(result) || typeof result.text !== "string") {
45
+ throw new Error(`host bridge command ${name} returned an invalid result`);
46
+ }
47
+ return {
48
+ text: result.text,
49
+ ...(result.isError === true ? { isError: true } : {})
50
+ };
51
+ }
52
+ });
53
+ },
54
+ registerTool(tool, registration) {
55
+ const definition = typeof tool === "function"
56
+ ? tool(trustedContext)
57
+ : tool;
58
+ const name = requiredString(definition.name, "tool name");
59
+ const registeredName = requiredString(registration?.name, `registration name for ${name}`);
60
+ if (registeredName !== name) {
61
+ throw new Error(`host bridge tool registration name ${registeredName} does not match ${name}`);
62
+ }
63
+ if (descriptorsByName.has(name)) {
64
+ throw new Error(`duplicate host bridge tool ${name}`);
65
+ }
66
+ if (typeof definition.description !== "string") {
67
+ throw new Error(`host bridge tool ${name} has no description`);
68
+ }
69
+ if (!isRecord(definition.parameters)) {
70
+ throw new Error(`host bridge tool ${name} has no input schema`);
71
+ }
72
+ if (typeof definition.execute !== "function") {
73
+ throw new Error(`host bridge tool ${name} has no execute function`);
74
+ }
75
+ const execute = definition.execute.bind(definition);
76
+ const descriptor = Object.freeze({
77
+ name,
78
+ description: definition.description,
79
+ inputSchema: definition.parameters,
80
+ async execute(toolCallId, args) {
81
+ const result = await execute(toolCallId, args);
82
+ if (!isRecord(result)) {
83
+ throw new Error(`host bridge tool ${name} returned an invalid result`);
84
+ }
85
+ return result;
86
+ }
87
+ });
88
+ descriptors.push(descriptor);
89
+ descriptorsByName.set(name, descriptor);
90
+ }
91
+ };
92
+ bindOpenClawRelayPath(api, requiredString(options.relayPath, "relayPath"));
93
+ bindOpenClawRelayEnvironment(api, options.relayEnvironment);
94
+ bindHostBridgeToolPresentation(api);
95
+ bindHostBridgeAsyncRelay(api);
96
+ registerOpenClawCommands(api, new Map());
97
+ if (!commandDescriptor) {
98
+ throw new Error("host bridge did not capture the akk command");
99
+ }
100
+ if (descriptors.length !== 16) {
101
+ throw new Error(`host bridge expected 16 semantic tools, received ${descriptors.length}`);
102
+ }
103
+ const listed = Object.freeze([...descriptors]);
104
+ const capturedCommand = commandDescriptor;
105
+ return Object.freeze({
106
+ command: () => capturedCommand,
107
+ list: () => listed,
108
+ get: (name) => descriptorsByName.get(name),
109
+ execute: async (name, toolCallId, args) => {
110
+ const descriptor = descriptorsByName.get(name);
111
+ if (!descriptor) {
112
+ throw new Error(`unknown host bridge tool ${name}`);
113
+ }
114
+ return descriptor.execute(toolCallId, args);
115
+ }
116
+ });
117
+ }
118
+ export function createHostBridgeTools(options) {
119
+ return createHostBridgeToolRegistry(options).list();
120
+ }
121
+ function requiredString(value, label) {
122
+ if (typeof value !== "string" || value.trim().length === 0) {
123
+ throw new Error(`${label} is required`);
124
+ }
125
+ return value;
126
+ }
127
+ function isRecord(value) {
128
+ return typeof value === "object" && value !== null && !Array.isArray(value);
129
+ }
130
+ //# sourceMappingURL=host-bridge-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-bridge-tools.js","sourceRoot":"","sources":["../../src/host-bridge-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,8BAA8B,EAC9B,4BAA4B,EAC5B,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,sCAAsC,CAAC;AA0F9C;;;;;;GAMG;AACH,MAAM,UAAU,4BAA4B,CAC1C,OAAqC;IAErC,MAAM,WAAW,GAA+B,EAAE,CAAC;IACnD,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAoC,CAAC;IACtE,IAAI,iBAA0D,CAAC;IAC/D,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;QACnC,UAAU,EAAE,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,oBAAoB,CAAC;QAC5E,SAAS,EAAE,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,mBAAmB,CAAC;KAC1E,CAAC,CAAC;IAEH,MAAM,GAAG,GAAG;QACV,YAAY,EAAE,OAAO,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AC9E,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { Readable, Writable } from "node:stream";
2
+ export interface HostBridgeCliOptions extends Record<string, unknown> {
3
+ profile?: unknown;
4
+ host?: unknown;
5
+ hostVersion?: unknown;
6
+ storeDir?: unknown;
7
+ }
8
+ export interface RunHostBridgeOptions {
9
+ readonly profile: string;
10
+ readonly host: string;
11
+ readonly hostVersion: string;
12
+ readonly storeDir?: string;
13
+ readonly lifecycleIntervalMs?: number;
14
+ readonly environment?: NodeJS.ProcessEnv;
15
+ readonly cwd?: string;
16
+ readonly relayPath?: string;
17
+ readonly stdin?: Readable;
18
+ readonly stdout?: Writable;
19
+ readonly stderr?: Writable;
20
+ readonly signalSource?: Pick<NodeJS.Process, "on" | "off">;
21
+ }
22
+ /** CLI composition boundary; stdout remains exclusively owned by MCP/stdio. */
23
+ export declare function runHostBridgeCli(options: HostBridgeCliOptions): Promise<void>;
24
+ /**
25
+ * Run one foreground, Host-owned Bridge. It owns no daemon and returns only
26
+ * after stdio closes or the owning Host sends SIGINT/SIGTERM.
27
+ */
28
+ export declare function runHostBridge(options: RunHostBridgeOptions): Promise<void>;
@@ -0,0 +1,156 @@
1
+ import fs from "node:fs";
2
+ import process from "node:process";
3
+ import { fileURLToPath } from "node:url";
4
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
+ import { createHostBridgeMcpServer, drainHostBridgeMcpCalls } from "./host-bridge-mcp.js";
6
+ import { createHostBridgeToolRegistry } from "./host-bridge-tools.js";
7
+ import { bindOpenClawRelayEnvironment, bindOpenClawRelayPath } from "./openclaw-plugin-command-adapter.js";
8
+ import { createMonitorReconciliationService } from "./openclaw-plugin-supervisor.js";
9
+ import { assertHostProfileCallbackExecutableReady } from "./host-profile.js";
10
+ import { createTrustedHostProfileRuntime, hostProfileRelayEnvironment } from "./host-profile-runtime.js";
11
+ import { packageRootDir } from "./cli-command-runtime.js";
12
+ import { cliCwd, cliEnv } from "./cli-runtime-context.js";
13
+ /** CLI composition boundary; stdout remains exclusively owned by MCP/stdio. */
14
+ export async function runHostBridgeCli(options) {
15
+ await runHostBridge({
16
+ profile: requiredString(options.profile, "--profile"),
17
+ host: requiredString(options.host, "--host"),
18
+ hostVersion: requiredString(options.hostVersion, "--host-version"),
19
+ storeDir: optionalString(options.storeDir, "--store-dir"),
20
+ environment: cliEnv(),
21
+ cwd: cliCwd()
22
+ });
23
+ }
24
+ /**
25
+ * Run one foreground, Host-owned Bridge. It owns no daemon and returns only
26
+ * after stdio closes or the owning Host sends SIGINT/SIGTERM.
27
+ */
28
+ export async function runHostBridge(options) {
29
+ const environment = { ...(options.environment ?? process.env) };
30
+ const cwd = options.cwd ?? process.cwd();
31
+ const runtime = createTrustedHostProfileRuntime({
32
+ selection: options.profile,
33
+ host: options.host,
34
+ hostVersion: options.hostVersion,
35
+ environment,
36
+ cwd
37
+ });
38
+ if (runtime.controllerScope === "route_bound_v1") {
39
+ throw new Error("Host Profile controllerContext.scope route_bound_v1 is not supported " +
40
+ "by the standalone Host Bridge; use the Host-native connector");
41
+ }
42
+ assertHostProfileCallbackExecutableReady(runtime.selected.profile.callback.executable, runtime.selected.profile.callback.environment.allow);
43
+ const relayPath = options.relayPath ?? fileURLToPath(new URL("./cli.js", import.meta.url));
44
+ const relayEnvironment = hostProfileRelayEnvironment(runtime, environment);
45
+ const pluginConfig = Object.freeze({
46
+ ...(options.storeDir ? { storeDir: options.storeDir } : {})
47
+ });
48
+ const stderr = options.stderr ?? process.stderr;
49
+ const logger = bridgeLogger(stderr);
50
+ const tools = createHostBridgeToolRegistry({
51
+ relayPath,
52
+ relayEnvironment,
53
+ pluginConfig,
54
+ logger,
55
+ context: {
56
+ sessionKey: runtime.controllerSessionId,
57
+ sessionId: runtime.controllerSessionId
58
+ }
59
+ });
60
+ const lifecycleApi = { pluginConfig, logger };
61
+ bindOpenClawRelayPath(lifecycleApi, relayPath);
62
+ bindOpenClawRelayEnvironment(lifecycleApi, relayEnvironment);
63
+ const lifecycle = createMonitorReconciliationService(lifecycleApi, options.lifecycleIntervalMs ?? 5_000);
64
+ const server = createHostBridgeMcpServer({
65
+ registry: tools,
66
+ version: packageVersion()
67
+ });
68
+ const input = options.stdin ?? process.stdin;
69
+ const output = options.stdout ?? process.stdout;
70
+ const transport = new StdioServerTransport(input, output);
71
+ const signals = options.signalSource ?? process;
72
+ let resolveClosed;
73
+ const closed = new Promise((resolve) => {
74
+ resolveClosed = resolve;
75
+ });
76
+ let shutdownPromise;
77
+ const shutdown = () => shutdownPromise ??= (async () => {
78
+ await settle("MCP transport close", () => server.close(), logger);
79
+ await settle("Host lifecycle drain", () => lifecycle.stop(), logger);
80
+ await settle("MCP tool drain", () => drainHostBridgeMcpCalls(server), logger);
81
+ resolveClosed();
82
+ })();
83
+ const onInputEnd = () => {
84
+ void shutdown();
85
+ };
86
+ const onInputError = (error) => {
87
+ logger.warn(`agent-knock-knock Host Bridge input error: ${error.message}`);
88
+ void shutdown();
89
+ };
90
+ const onSignal = () => {
91
+ void shutdown();
92
+ };
93
+ input.once("end", onInputEnd);
94
+ input.once("close", onInputEnd);
95
+ input.once("error", onInputError);
96
+ signals.on("SIGINT", onSignal);
97
+ signals.on("SIGTERM", onSignal);
98
+ try {
99
+ await server.connect(transport);
100
+ lifecycle.start();
101
+ if (input.readableEnded === true) {
102
+ await shutdown();
103
+ }
104
+ await closed;
105
+ }
106
+ finally {
107
+ input.off("end", onInputEnd);
108
+ input.off("close", onInputEnd);
109
+ input.off("error", onInputError);
110
+ signals.off("SIGINT", onSignal);
111
+ signals.off("SIGTERM", onSignal);
112
+ await shutdown();
113
+ }
114
+ }
115
+ function bridgeLogger(stderr) {
116
+ const write = (level, message) => {
117
+ const line = String(message)
118
+ .replace(/[\u0000-\u001f\u007f]+/gu, " ")
119
+ .replace(/\s+/gu, " ")
120
+ .trim()
121
+ .slice(0, 4_096);
122
+ stderr.write(`[agent-knock-knock:${level}] ${line}\n`);
123
+ };
124
+ return Object.freeze({
125
+ info: (message) => write("info", message),
126
+ warn: (message) => write("warn", message),
127
+ error: (message) => write("error", message)
128
+ });
129
+ }
130
+ async function settle(label, operation, logger) {
131
+ try {
132
+ await operation();
133
+ }
134
+ catch (error) {
135
+ logger.warn(`${label} failed: ${errorMessage(error)}`);
136
+ }
137
+ }
138
+ function packageVersion() {
139
+ const packageJson = JSON.parse(fs.readFileSync(`${packageRootDir()}/package.json`, "utf8"));
140
+ return requiredString(packageJson.version, "package version");
141
+ }
142
+ function optionalString(value, label) {
143
+ if (value === undefined)
144
+ return undefined;
145
+ return requiredString(value, label);
146
+ }
147
+ function requiredString(value, label) {
148
+ if (typeof value !== "string" || value.trim().length === 0) {
149
+ throw new Error(`${label} is required`);
150
+ }
151
+ return value;
152
+ }
153
+ function errorMessage(error) {
154
+ return error instanceof Error ? error.message : String(error);
155
+ }
156
+ //# sourceMappingURL=host-bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-bridge.js","sourceRoot":"","sources":["../../src/host-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,oBAAoB,EAAE,MAC7B,2CAA2C,CAAC;AAE9C,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EACL,4BAA4B,EAC5B,qBAAqB,EACtB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,kCAAkC,EAAE,MAC3C,iCAAiC,CAAC;AACpC,OAAO,EAAE,wCAAwC,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EACL,+BAA+B,EAC/B,2BAA2B,EAC5B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OA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K,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,39 @@
1
+ export declare const HOST_LIFECYCLE_INTERVAL_MS = 5000;
2
+ export type HostLifecycleSweepReason = "startup" | "periodic";
3
+ export interface HostLifecyclePhaseContext {
4
+ reason: HostLifecycleSweepReason;
5
+ }
6
+ export interface HostLifecyclePhase {
7
+ name: string;
8
+ run(context: HostLifecyclePhaseContext): Promise<void> | void;
9
+ }
10
+ export interface HostLifecyclePhaseError {
11
+ phase: string;
12
+ reason: HostLifecycleSweepReason;
13
+ error: unknown;
14
+ }
15
+ /**
16
+ * Schedule one deferred callback and return a function that cancels it.
17
+ *
18
+ * A host may use this seam to choose whether the underlying timer is ref'ed or
19
+ * unref'ed. The default scheduler uses a normal ref'ed Node.js timer.
20
+ */
21
+ export type HostLifecycleSchedule = (callback: () => void, delayMs: number) => () => void;
22
+ export interface HostLifecycleServiceOptions {
23
+ intervalMs?: number;
24
+ phases: readonly HostLifecyclePhase[];
25
+ onPhaseError(error: HostLifecyclePhaseError): void;
26
+ schedule?: HostLifecycleSchedule;
27
+ }
28
+ export interface HostLifecycleService {
29
+ start(): void;
30
+ stop(): Promise<void>;
31
+ }
32
+ /**
33
+ * Run host-owned AKK reconciliation for as long as the embedding host is live.
34
+ *
35
+ * The service owns no process, Store, callback transport, or host configuration.
36
+ * Its phases are compile-time injected by the host adapter and run sequentially
37
+ * with independent error boundaries.
38
+ */
39
+ export declare function createHostLifecycleService(options: HostLifecycleServiceOptions): HostLifecycleService;
@@ -0,0 +1,101 @@
1
+ export const HOST_LIFECYCLE_INTERVAL_MS = 5_000;
2
+ const defaultSchedule = (callback, delayMs) => {
3
+ const timer = setTimeout(callback, delayMs);
4
+ return () => clearTimeout(timer);
5
+ };
6
+ function normalizedIntervalMs(configuredIntervalMs) {
7
+ return Number.isFinite(configuredIntervalMs) && Number(configuredIntervalMs) > 0
8
+ ? Math.max(50, Math.ceil(Number(configuredIntervalMs)))
9
+ : HOST_LIFECYCLE_INTERVAL_MS;
10
+ }
11
+ /**
12
+ * Run host-owned AKK reconciliation for as long as the embedding host is live.
13
+ *
14
+ * The service owns no process, Store, callback transport, or host configuration.
15
+ * Its phases are compile-time injected by the host adapter and run sequentially
16
+ * with independent error boundaries.
17
+ */
18
+ export function createHostLifecycleService(options) {
19
+ const intervalMs = normalizedIntervalMs(options.intervalMs);
20
+ const scheduleAfter = options.schedule ?? defaultSchedule;
21
+ let state = "idle";
22
+ let cancelScheduled;
23
+ let inFlight;
24
+ let stopDrain;
25
+ const runSweep = async (reason) => {
26
+ for (const phase of options.phases) {
27
+ try {
28
+ await phase.run({ reason });
29
+ }
30
+ catch (error) {
31
+ try {
32
+ options.onPhaseError({
33
+ phase: phase.name,
34
+ reason,
35
+ error
36
+ });
37
+ }
38
+ catch {
39
+ // A host logger/reporting failure must not suppress later phases.
40
+ }
41
+ }
42
+ }
43
+ };
44
+ const beginSweep = (reason, after) => {
45
+ let settle;
46
+ let reject;
47
+ const execution = new Promise((resolve, rejectPromise) => {
48
+ settle = resolve;
49
+ reject = rejectPromise;
50
+ });
51
+ const sweep = execution.finally(() => {
52
+ if (inFlight === sweep) {
53
+ inFlight = undefined;
54
+ }
55
+ after();
56
+ });
57
+ // Register before invoking phase code. A phase may synchronously request
58
+ // Host shutdown; stop() must observe and drain the complete sweep while
59
+ // phase startup retains its pre-extraction synchronous ordering.
60
+ inFlight = sweep;
61
+ void runSweep(reason).then(settle, reject);
62
+ };
63
+ const scheduleNext = () => {
64
+ if (state !== "running") {
65
+ return;
66
+ }
67
+ cancelScheduled = scheduleAfter(() => {
68
+ cancelScheduled = undefined;
69
+ beginSweep("periodic", scheduleNext);
70
+ }, intervalMs);
71
+ };
72
+ return {
73
+ start() {
74
+ if (state !== "idle") {
75
+ return;
76
+ }
77
+ state = "running";
78
+ beginSweep("startup", scheduleNext);
79
+ },
80
+ async stop() {
81
+ if (state === "idle") {
82
+ return;
83
+ }
84
+ if (state === "stopping") {
85
+ await stopDrain;
86
+ return;
87
+ }
88
+ state = "stopping";
89
+ cancelScheduled?.();
90
+ cancelScheduled = undefined;
91
+ const activeSweep = inFlight;
92
+ stopDrain = (async () => {
93
+ await activeSweep;
94
+ state = "idle";
95
+ stopDrain = undefined;
96
+ })();
97
+ await stopDrain;
98
+ }
99
+ };
100
+ }
101
+ //# sourceMappingURL=host-lifecycle-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-lifecycle-service.js","sourceRoot":"","sources":["../../src/host-lifecycle-service.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AA4ChD,MAAM,eAAe,GAA0B,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE;IACnE,MAAM,KAAK,GAAG,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC5C,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF,SAAS,oBAAoB,CAAC,oBAAwC;IACpE,OAAO,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAC,IAAI,MAAM,CAAC,oBAAoB,CAAC,GAAG,CAAC;QAC9E,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC;QACvD,CAAC,CAAC,0BAA0B,CAAC;AACjC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAAoC;IAEpC,MAAM,UAAU,GAAG,oBAAoB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC5D,MAAM,aAAa,GAAG,OAAO,CAAC,QAAQ,IAAI,eAAe,CAAC;IAC1D,IAAI,KAAK,GAAuB,MAAM,CAAC;IACvC,IAAI,eAAyC,CAAC;IAC9C,IAAI,QAAmC,CAA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AAO;QACT,CAAC;QACD,eAAe,GAAG,aAAa,CAAC,GAAG,EAAE;YACnC,eAAe,GAAG,SAAS,CAAC;YAC5B,UAAU,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QACvC,CAAC,EAAE,UAAU,CAAC,CAAC;IACjB,CAAC,CAAC;IAEF,OAAO;QACL,KAAK;YACH,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;gBACrB,OAAO;YACT,CAAC;YACD,KAAK,GAAG,SAAS,CAAC;YAClB,UAAU,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QACtC,CAAC;QAED,KAAK,CAAC,IAAI;YACR,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;gBACrB,OAAO;YACT,CAAC;YACD,IAAI,KAAK,KAAK,UAAU,EAAE,CAAC;gBACzB,MAAM,SAAS,CAAC;gBAChB,OAAO;YACT,CAAC;YACD,KAAK,GAAG,UAAU,CAAC;YACnB,eAAe,EAAE,EAAE,CAAC;YACpB,eAAe,GAAG,SAAS,CAAC;YAC5B,MAAM,WAAW,GAAG,QAAQ,CAAC;YAC7B,SAAS,GAAG,CAAC,KAAK,IAAI,EAAE;gBACtB,MAAM,WAAW,CAAC;gBAClB,KAAK,GAAG,MAAM,CAAC;gBACf,SAAS,GAAG,SAAS,CAAC;YACxB,CAAC,CAAC,EAAE,CAAC;YACL,MAAM,SAAS,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { CallbackTransport } from "./callback-transport.js";
2
+ import { type SelectHostProfileOptions } from "./host-profile-runtime.js";
3
+ export declare const HOST_PROFILE_CALLBACK_ROUTER_KIND = "host_profile_callback_router_v1";
4
+ export interface CreateHostProfileCallbackTransportOptions extends SelectHostProfileOptions {
5
+ readonly legacyTransport: CallbackTransport;
6
+ readonly environment: () => NodeJS.ProcessEnv;
7
+ readonly now?: () => Date;
8
+ }
9
+ /**
10
+ * Route legacy OpenClaw callbacks exactly as before and resolve declarative
11
+ * callbacks only through the private Bridge runtime environment. The Store
12
+ * persists route identity, never executable or credential configuration.
13
+ */
14
+ export declare function createHostProfileCallbackTransport(options: CreateHostProfileCallbackTransportOptions): CallbackTransport;
@@ -0,0 +1,70 @@
1
+ import { COMMAND_JSON_CALLBACK_TRANSPORT_KIND, createCommandJsonCallbackTransport } from "./command-json-callback-transport.js";
2
+ import { trustedHostProfileRuntimeFromEnvironment } from "./host-profile-runtime.js";
3
+ export const HOST_PROFILE_CALLBACK_ROUTER_KIND = "host_profile_callback_router_v1";
4
+ /**
5
+ * Route legacy OpenClaw callbacks exactly as before and resolve declarative
6
+ * callbacks only through the private Bridge runtime environment. The Store
7
+ * persists route identity, never executable or credential configuration.
8
+ */
9
+ export function createHostProfileCallbackTransport(options) {
10
+ return Object.freeze({
11
+ kind: HOST_PROFILE_CALLBACK_ROUTER_KIND,
12
+ deliver(input) {
13
+ if (input.route.transport === options.legacyTransport.kind) {
14
+ return options.legacyTransport.deliver(input);
15
+ }
16
+ if (input.route.transport !== COMMAND_JSON_CALLBACK_TRANSPORT_KIND) {
17
+ return permanentFailure("unsupported_callback_transport");
18
+ }
19
+ let runtime;
20
+ try {
21
+ runtime = trustedHostProfileRuntimeFromEnvironment(options.environment(), { cwd: options.cwd, registry: options.registry });
22
+ }
23
+ catch {
24
+ return permanentFailure("host_profile_runtime_invalid");
25
+ }
26
+ if (!runtime) {
27
+ return permanentFailure("host_profile_runtime_missing");
28
+ }
29
+ if (runtime.callbackRoute.transport !== input.route.transport ||
30
+ runtime.callbackRoute.profile_id !== input.route.profile_id ||
31
+ runtime.callbackRoute.profile_revision !== input.route.profile_revision ||
32
+ (runtime.controllerScope === "startup_v1" &&
33
+ runtime.callbackRoute.controller_session_id !==
34
+ input.route.controller_session_id)) {
35
+ return permanentFailure("host_profile_callback_route_mismatch");
36
+ }
37
+ let transport;
38
+ try {
39
+ transport = createCommandJsonCallbackTransport({
40
+ profile: runtime.selected.profile,
41
+ controllerSessionId: runtime.controllerScope === "route_bound_v1"
42
+ ? input.route.controller_session_id
43
+ : runtime.controllerSessionId,
44
+ environment: options.environment,
45
+ now: options.now
46
+ });
47
+ }
48
+ catch {
49
+ return permanentFailure("host_profile_callback_transport_invalid");
50
+ }
51
+ try {
52
+ return transport.deliver(input);
53
+ }
54
+ catch {
55
+ return {
56
+ disposition: "uncertain",
57
+ error_code: "host_profile_callback_transport_threw",
58
+ observed_at: (options.now?.() ?? new Date()).toISOString()
59
+ };
60
+ }
61
+ }
62
+ });
63
+ }
64
+ function permanentFailure(errorCode) {
65
+ return {
66
+ disposition: "permanent_failure",
67
+ error_code: errorCode
68
+ };
69
+ }
70
+ //# sourceMappingURL=host-profile-callback-transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-profile-callback-transport.js","sourceRoot":"","sources":["../../src/host-profile-callback-transport.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oCAAoC,EACpC,kCAAkC,EACnC,MAAM,sCAAsC,CAAC;AAM9C,OAAO,EACL,wCAAwC,EAEzC,MAAM,2BAA2B,CAAC;AAEnC,MAAM,CAAC,MAAM,iCAAiC,GAC5C,iCAAiC,CAAC;AASpC;;;;GAIG;AACH,MAAM,UAAU,kCAAkC,CAChD,OAAkD;IAElD,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,IAAI,EAAE,iCAAiC;QACvC,OAAO,CAAC,KAAoC;YAC1C,IAAI,KAAK,CAAC,KAAK,CAAC,SAAS,KAAK,OAAO,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;gBAC3D,OAAO,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAChD,CAAC;YACD,IAAI,KAAK,CAAC,KAAK,CAAC,SAAS,KAAK,oCAAoC,EAAE,CAAC;gBACnE,OAAO,gBAAgB,CAAC,gCAAgC,CAAC,CAAC;YAC5D,CAAC;YAED,IAAI,OAAO,CAAC;YACZ,IAAI,CAAC;gBACH,OAAO,GAAG,wCAAwC,CAChD,OAAO,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