@addai/node 0.30.13 → 0.30.15

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 (143) hide show
  1. package/dist/auto-update.d.ts +3 -0
  2. package/dist/auto-update.js +15 -0
  3. package/dist/capabilities.d.ts +17 -3
  4. package/dist/capabilities.js +18 -8
  5. package/dist/claude-models.d.ts +4 -12
  6. package/dist/claude-models.js +12 -88
  7. package/dist/claude-print.d.ts +15 -0
  8. package/dist/claude-print.js +16 -0
  9. package/dist/codex-models.d.ts +81 -0
  10. package/dist/codex-models.js +385 -0
  11. package/dist/codex-spawn.d.ts +19 -8
  12. package/dist/codex-spawn.js +68 -16
  13. package/dist/command-runner.js +31 -9
  14. package/dist/desktop/docker.js +2 -0
  15. package/dist/desktop/manager.d.ts +2 -1
  16. package/dist/desktop/manager.js +51 -1
  17. package/dist/desktop/provider.d.ts +1 -1
  18. package/dist/desktop/provider.js +2 -0
  19. package/dist/desktop/relay-client.js +7 -0
  20. package/dist/desktop/spec.d.ts +2 -0
  21. package/dist/direct/aios-bridge.d.ts +13 -0
  22. package/dist/direct/aios-bridge.js +177 -0
  23. package/dist/direct/aios-mcp.d.ts +2 -0
  24. package/dist/direct/aios-mcp.js +132 -0
  25. package/dist/direct/aios-tools.d.ts +351 -0
  26. package/dist/direct/aios-tools.js +120 -0
  27. package/dist/direct/board-chat-provider.d.ts +64 -0
  28. package/dist/direct/board-chat-provider.js +154 -0
  29. package/dist/direct/board-chat.d.ts +40 -0
  30. package/dist/direct/board-chat.js +414 -0
  31. package/dist/direct/config.d.ts +2 -0
  32. package/dist/direct/config.js +60 -0
  33. package/dist/direct/launch.d.ts +14 -0
  34. package/dist/direct/launch.js +121 -0
  35. package/dist/direct/protocol.d.ts +46 -0
  36. package/dist/direct/protocol.js +84 -0
  37. package/dist/direct/relay-main.d.ts +1 -0
  38. package/dist/direct/relay-main.js +21 -0
  39. package/dist/direct/relay.d.ts +26 -0
  40. package/dist/direct/relay.js +334 -0
  41. package/dist/direct/sessions.d.ts +61 -0
  42. package/dist/direct/sessions.js +368 -0
  43. package/dist/direct/supervisor.d.ts +9 -0
  44. package/dist/direct/supervisor.js +137 -0
  45. package/dist/direct/terminal.d.ts +1 -0
  46. package/dist/direct/terminal.js +106 -0
  47. package/dist/direct/worker.d.ts +1 -0
  48. package/dist/direct/worker.js +278 -0
  49. package/dist/entitybox/container-action.cjs +85 -0
  50. package/dist/entitybox/container-watchdog.cjs +70 -0
  51. package/dist/entitybox/model-entry.d.ts +3 -0
  52. package/dist/entitybox/model-entry.js +233 -0
  53. package/dist/entitybox/model-mcp-proxy.d.ts +3 -0
  54. package/dist/entitybox/model-mcp-proxy.js +85 -0
  55. package/dist/entitybox-application-boundary.d.ts +59 -0
  56. package/dist/entitybox-application-boundary.js +161 -0
  57. package/dist/entitybox-application-guard-core.d.ts +44 -0
  58. package/dist/entitybox-application-guard-core.js +164 -0
  59. package/dist/entitybox-application-guard-process.d.ts +1 -0
  60. package/dist/entitybox-application-guard-process.js +83 -0
  61. package/dist/entitybox-application-guard.d.ts +46 -0
  62. package/dist/entitybox-application-guard.js +239 -0
  63. package/dist/entitybox-capacity-health-host.d.ts +12 -0
  64. package/dist/entitybox-capacity-health-host.js +80 -0
  65. package/dist/entitybox-capacity-health-worker.d.ts +22 -0
  66. package/dist/entitybox-capacity-health-worker.js +168 -0
  67. package/dist/entitybox-capacity-host.d.ts +17 -0
  68. package/dist/entitybox-capacity-host.js +155 -0
  69. package/dist/entitybox-capacity-owner-process.d.ts +1 -0
  70. package/dist/entitybox-capacity-owner-process.js +32 -0
  71. package/dist/entitybox-capacity-owner.d.ts +16 -0
  72. package/dist/entitybox-capacity-owner.js +90 -0
  73. package/dist/entitybox-capacity-programs.d.ts +7 -0
  74. package/dist/entitybox-capacity-programs.js +49 -0
  75. package/dist/entitybox-capacity-provisioner.d.ts +82 -0
  76. package/dist/entitybox-capacity-provisioner.js +404 -0
  77. package/dist/entitybox-capacity-publication.d.ts +29 -0
  78. package/dist/entitybox-capacity-publication.js +199 -0
  79. package/dist/entitybox-capacity-registration.d.ts +36 -0
  80. package/dist/entitybox-capacity-registration.js +75 -0
  81. package/dist/entitybox-capacity-worker.d.ts +29 -0
  82. package/dist/entitybox-capacity-worker.js +113 -0
  83. package/dist/entitybox-computer-task.d.ts +69 -0
  84. package/dist/entitybox-computer-task.js +176 -0
  85. package/dist/entitybox-controller-recovery.d.ts +40 -0
  86. package/dist/entitybox-controller-recovery.js +156 -0
  87. package/dist/entitybox-desktop-action-server.d.ts +34 -0
  88. package/dist/entitybox-desktop-action-server.js +176 -0
  89. package/dist/entitybox-desktop-admission.d.ts +32 -0
  90. package/dist/entitybox-desktop-admission.js +79 -0
  91. package/dist/entitybox-display-binding.d.ts +13 -0
  92. package/dist/entitybox-display-binding.js +31 -0
  93. package/dist/entitybox-execution-container.d.ts +82 -0
  94. package/dist/entitybox-execution-container.js +450 -0
  95. package/dist/entitybox-execution-host.d.ts +40 -0
  96. package/dist/entitybox-execution-host.js +168 -0
  97. package/dist/entitybox-execution-lease.d.ts +81 -0
  98. package/dist/entitybox-execution-lease.js +332 -0
  99. package/dist/entitybox-file-inputs.d.ts +51 -0
  100. package/dist/entitybox-file-inputs.js +182 -0
  101. package/dist/entitybox-file-session.d.ts +38 -0
  102. package/dist/entitybox-file-session.js +82 -0
  103. package/dist/entitybox-host-process.d.ts +12 -0
  104. package/dist/entitybox-host-process.js +120 -0
  105. package/dist/entitybox-install.d.ts +10 -0
  106. package/dist/entitybox-install.js +40 -0
  107. package/dist/entitybox-mcp-broker.d.ts +77 -0
  108. package/dist/entitybox-mcp-broker.js +420 -0
  109. package/dist/entitybox-mcp-contract.d.ts +10 -0
  110. package/dist/entitybox-mcp-contract.js +24 -0
  111. package/dist/entitybox-mcp-guard.d.ts +3 -0
  112. package/dist/entitybox-mcp-guard.js +167 -0
  113. package/dist/entitybox-model-artifact.d.ts +9 -0
  114. package/dist/entitybox-model-artifact.js +83 -0
  115. package/dist/entitybox-native-services.d.ts +33 -0
  116. package/dist/entitybox-native-services.js +172 -0
  117. package/dist/entitybox-operation.d.ts +4 -0
  118. package/dist/entitybox-operation.js +34 -0
  119. package/dist/entitybox-provider-broker.d.ts +41 -0
  120. package/dist/entitybox-provider-broker.js +149 -0
  121. package/dist/entitybox-queue-request.d.ts +32 -0
  122. package/dist/entitybox-queue-request.js +141 -0
  123. package/dist/entitybox-recovery-host.d.ts +12 -0
  124. package/dist/entitybox-recovery-host.js +80 -0
  125. package/dist/entitybox-recovery-store.d.ts +33 -0
  126. package/dist/entitybox-recovery-store.js +150 -0
  127. package/dist/entitybox-recovery-worker.d.ts +30 -0
  128. package/dist/entitybox-recovery-worker.js +134 -0
  129. package/dist/entitybox-vault-provider.d.ts +27 -0
  130. package/dist/entitybox-vault-provider.js +127 -0
  131. package/dist/harness-registry.js +3 -1
  132. package/dist/index.js +72 -38
  133. package/dist/install.d.ts +14 -2
  134. package/dist/install.js +115 -10
  135. package/dist/model-cache.d.ts +38 -0
  136. package/dist/model-cache.js +137 -0
  137. package/dist/request-pump.d.ts +3 -0
  138. package/dist/request-pump.js +21 -7
  139. package/dist/session-runner.d.ts +8 -1
  140. package/dist/session-runner.js +56 -3
  141. package/dist/supabase-client.js +4 -1
  142. package/package.json +5 -1
  143. package/scripts/copy-assets.js +4 -2
@@ -0,0 +1,38 @@
1
+ import { type EntityboxFileBlock } from './entitybox-file-inputs';
2
+ interface Request {
3
+ id: string;
4
+ runtime_id: string;
5
+ agent: string;
6
+ mode: string;
7
+ entitybox_file_request?: boolean;
8
+ entitybox_computer_request?: boolean;
9
+ }
10
+ interface Io {
11
+ rpc: <T>(name: string, args: Record<string, unknown>) => Promise<T>;
12
+ pairing: () => {
13
+ runtimeId: string;
14
+ daemonToken: string;
15
+ } | null;
16
+ fetch?: typeof fetch;
17
+ }
18
+ export declare function entityboxFileSessionConfiguration(request: Request, env?: NodeJS.ProcessEnv): string | undefined;
19
+ /** Ordinary native chat keeps its existing identity and Claude launcher. Only
20
+ * explicitly marked file requests enter this strict path; legacy attachments
21
+ * and all unmarked requests retain their existing behavior. */
22
+ export declare function prepareEntityboxSessionFiles(request: Request, io: Io, signal: AbortSignal, env?: NodeJS.ProcessEnv): Promise<readonly EntityboxFileBlock[] | undefined>;
23
+ /** Reuse the native heartbeat rather than inventing a second presence system.
24
+ * Only explicit, valid configuration and a verified usable Claude binary can
25
+ * advertise chat support. The URL/credentials are never capability metadata. */
26
+ export declare function entityboxFileCapabilities(claude: {
27
+ available: boolean;
28
+ authed?: boolean;
29
+ version?: string;
30
+ }, env?: NodeJS.ProcessEnv): {
31
+ version: number;
32
+ chat: boolean;
33
+ computer: boolean;
34
+ maxFiles: number;
35
+ maxImageBytes: number;
36
+ maxTotalBytes: number;
37
+ } | undefined;
38
+ export {};
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.entityboxFileSessionConfiguration = entityboxFileSessionConfiguration;
4
+ exports.prepareEntityboxSessionFiles = prepareEntityboxSessionFiles;
5
+ exports.entityboxFileCapabilities = entityboxFileCapabilities;
6
+ const entitybox_file_inputs_1 = require("./entitybox-file-inputs");
7
+ const entitybox_operation_1 = require("./entitybox-operation");
8
+ const entitybox_execution_host_1 = require("./entitybox-execution-host");
9
+ function entityboxFileSessionConfiguration(request, env = process.env) {
10
+ if (request.entitybox_file_request !== true)
11
+ return undefined;
12
+ if (request.entitybox_computer_request === true || request.agent !== 'claude' || request.mode !== 'print' || env.AINODE_ENTITYBOX_FILE_INPUTS_ENABLED !== '1')
13
+ throw new entitybox_file_inputs_1.EntityboxFileInputError();
14
+ return (0, entitybox_file_inputs_1.entityboxFileGatewayUrl)(env.AINODE_ENTITYBOX_FILE_GATEWAY_URL ?? '');
15
+ }
16
+ /** Ordinary native chat keeps its existing identity and Claude launcher. Only
17
+ * explicitly marked file requests enter this strict path; legacy attachments
18
+ * and all unmarked requests retain their existing behavior. */
19
+ async function prepareEntityboxSessionFiles(request, io, signal, env = process.env) {
20
+ const gateway = entityboxFileSessionConfiguration(request, env);
21
+ if (!gateway)
22
+ return undefined;
23
+ const token = () => { const p = io.pairing(); if (signal.aborted || !p || p.runtimeId !== request.runtime_id || !p.daemonToken)
24
+ throw new entitybox_file_inputs_1.EntityboxFileInputError(); return p.daemonToken; };
25
+ const inputs = new entitybox_file_inputs_1.EntityboxFileInputs({ requestId: request.id, signal, requireFiles: true,
26
+ manifest: async (active) => { if (active.aborted)
27
+ throw new Error(); const value = await io.rpc('entitybox_file_manifest', { p_token: token(), p_request_id: request.id }); token(); if (active.aborted)
28
+ throw new Error(); return value; },
29
+ download: async (fileId, active) => {
30
+ if (active.aborted)
31
+ throw new Error();
32
+ const response = await (io.fetch ?? fetch)(gateway, { method: 'POST', redirect: 'error', credentials: 'omit', signal: active, headers: { authorization: 'Bearer ' + token(), 'content-type': 'application/json' }, body: JSON.stringify({ requestId: request.id, fileId }) });
33
+ try {
34
+ token();
35
+ if (active.aborted)
36
+ throw new Error();
37
+ return response;
38
+ }
39
+ catch {
40
+ void response.body?.cancel().catch(() => { });
41
+ throw new Error();
42
+ }
43
+ },
44
+ });
45
+ try {
46
+ const blocks = await inputs.blocks(signal);
47
+ if (!blocks.length)
48
+ throw new Error();
49
+ // A canceled task cannot start a CLI from a completed download. Missing
50
+ // status/transport evidence also prevents spawn rather than guessing.
51
+ const status = await (0, entitybox_operation_1.entityboxOperation)([signal], 4500, () => io.rpc('runtime_get_request_status', { p_token: token(), p_request_id: request.id }));
52
+ token();
53
+ if (!['starting', 'running'].includes(status))
54
+ throw new Error();
55
+ return blocks;
56
+ }
57
+ catch {
58
+ throw new entitybox_file_inputs_1.EntityboxFileInputError();
59
+ }
60
+ }
61
+ /** Reuse the native heartbeat rather than inventing a second presence system.
62
+ * Only explicit, valid configuration and a verified usable Claude binary can
63
+ * advertise chat support. The URL/credentials are never capability metadata. */
64
+ function entityboxFileCapabilities(claude, env = process.env) {
65
+ try {
66
+ if (env.AINODE_ENTITYBOX_FILE_INPUTS_ENABLED !== '1')
67
+ return undefined;
68
+ (0, entitybox_file_inputs_1.entityboxFileGatewayUrl)(env.AINODE_ENTITYBOX_FILE_GATEWAY_URL ?? '');
69
+ const match = /^(\d+)\.(\d+)\.(\d+)/.exec(claude.version ?? '');
70
+ const compatible = !!match && (Number(match[1]) > 2 || Number(match[1]) === 2 && (Number(match[2]) > 1 || Number(match[2]) === 1 && Number(match[3]) >= 263));
71
+ const chat = claude.available && claude.authed === true && compatible;
72
+ let computer = false;
73
+ try {
74
+ computer = !!(0, entitybox_execution_host_1.entityboxExecutionEnvironment)(env);
75
+ }
76
+ catch { }
77
+ return { version: 1, chat, computer, maxFiles: 6, maxImageBytes: 7 * 1024 * 1024, maxTotalBytes: 18 * 1024 * 1024 };
78
+ }
79
+ catch {
80
+ return undefined;
81
+ }
82
+ }
@@ -0,0 +1,12 @@
1
+ export interface EntityboxHostProcess {
2
+ platform: 'win32' | 'linux';
3
+ pid: number;
4
+ start: string;
5
+ domain: string;
6
+ }
7
+ export declare function parseEntityboxHostProcess(value: unknown): Readonly<EntityboxHostProcess>;
8
+ export declare function sameEntityboxHostProcess(a: EntityboxHostProcess, b: EntityboxHostProcess): boolean;
9
+ export declare function parseEntityboxLinuxStat(raw: string, pid: number, domain: string): Readonly<EntityboxHostProcess> | null;
10
+ /** Read OS birth identity; never kill, focus, inspect environment or capture UI. */
11
+ export declare function readEntityboxHostProcess(pid?: number): Promise<Readonly<EntityboxHostProcess> | null>;
12
+ export declare function assertEntityboxHostProcessGone(value: EntityboxHostProcess): Promise<void>;
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.parseEntityboxHostProcess = parseEntityboxHostProcess;
37
+ exports.sameEntityboxHostProcess = sameEntityboxHostProcess;
38
+ exports.parseEntityboxLinuxStat = parseEntityboxLinuxStat;
39
+ exports.readEntityboxHostProcess = readEntityboxHostProcess;
40
+ exports.assertEntityboxHostProcessGone = assertEntityboxHostProcessGone;
41
+ const child_process_1 = require("child_process");
42
+ const util_1 = require("util");
43
+ const fs = __importStar(require("fs/promises"));
44
+ const path = __importStar(require("path"));
45
+ const entitybox_execution_lease_1 = require("./entitybox-execution-lease");
46
+ const exec = (0, util_1.promisify)(child_process_1.execFile), uuid = '[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}';
47
+ const failure = () => new entitybox_execution_lease_1.EntityboxExecutionError('Native process identity could not be verified');
48
+ function parseEntityboxHostProcess(value) {
49
+ const p = value;
50
+ if (!p || Object.keys(p).sort().join(',') !== 'domain,pid,platform,start' || !Number.isSafeInteger(p.pid) || p.pid < 1 || p.pid > 2147483647 || typeof p.start !== 'string' || !/^[0-9]{1,20}$/.test(p.start) || typeof p.domain !== 'string'
51
+ || !(p.platform === 'win32' && p.domain === 'win32' || p.platform === 'linux' && new RegExp('^' + uuid + '/[0-9]{1,20}$').test(p.domain)))
52
+ throw failure();
53
+ return Object.freeze({ ...p });
54
+ }
55
+ function sameEntityboxHostProcess(a, b) { return a.platform === b.platform && a.pid === b.pid && a.start === b.start && a.domain === b.domain; }
56
+ async function linuxDomain() { const boot = (await fs.readFile('/proc/sys/kernel/random/boot_id', 'utf8')).trim(), ns = await fs.stat('/proc/self/ns/pid', { bigint: true }); return boot + '/' + ns.ino.toString(); }
57
+ function parseEntityboxLinuxStat(raw, pid, domain) {
58
+ if (!raw.startsWith(pid + ' ('))
59
+ throw failure();
60
+ const close = raw.lastIndexOf(')'), parts = raw.slice(close + 2).trim().split(/\s+/);
61
+ if (close < 0 || parts.length < 20)
62
+ throw failure();
63
+ const identity = parseEntityboxHostProcess({ platform: 'linux', pid, start: parts[19], domain });
64
+ return ['Z', 'X'].includes(parts[0]) ? null : identity;
65
+ }
66
+ /** Read OS birth identity; never kill, focus, inspect environment or capture UI. */
67
+ async function readEntityboxHostProcess(pid = process.pid) {
68
+ if (!Number.isSafeInteger(pid) || pid < 1 || pid > 2147483647)
69
+ throw failure();
70
+ try {
71
+ if (process.platform === 'linux') {
72
+ const domain = await linuxDomain();
73
+ let raw;
74
+ try {
75
+ raw = await fs.readFile('/proc/' + pid + '/stat', 'utf8');
76
+ }
77
+ catch (e) {
78
+ if (e.code === 'ENOENT')
79
+ return null;
80
+ throw e;
81
+ }
82
+ return parseEntityboxLinuxStat(raw, pid, domain);
83
+ }
84
+ if (process.platform === 'win32') {
85
+ const shell = path.join(process.env.SystemRoot || 'C:\\Windows', 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe');
86
+ const script = "$ErrorActionPreference='Stop'; $targetProcess=Get-Process -Id " + pid + " -ErrorAction SilentlyContinue; if($null -eq $targetProcess){'null'; exit 0}; try {if($targetProcess.HasExited){'null'}else{@{platform='win32';domain='win32';pid=$targetProcess.Id;start=$targetProcess.StartTime.ToUniversalTime().Ticks.ToString([Globalization.CultureInfo]::InvariantCulture)}|ConvertTo-Json -Compress}}catch{exit 3}";
87
+ const env = {};
88
+ for (const key of ['SystemRoot', 'WINDIR', 'Path', 'PATH', 'TEMP', 'TMP'])
89
+ if (process.env[key] !== undefined)
90
+ env[key] = process.env[key];
91
+ const raw = (await exec(shell, ['-NoProfile', '-NonInteractive', '-Command', script], { env, windowsHide: true, timeout: 5000, maxBuffer: 4096 })).stdout.trim(), value = JSON.parse(raw);
92
+ if (value === null)
93
+ return null;
94
+ const identity = parseEntityboxHostProcess(value);
95
+ if (identity.pid !== pid)
96
+ throw failure();
97
+ return identity;
98
+ }
99
+ throw failure();
100
+ }
101
+ catch {
102
+ throw failure();
103
+ }
104
+ }
105
+ async function assertEntityboxHostProcessGone(value) {
106
+ const expected = parseEntityboxHostProcess(value);
107
+ if (expected.platform !== process.platform)
108
+ throw failure();
109
+ if (expected.platform === 'linux') {
110
+ const domain = await linuxDomain();
111
+ if (domain.split('/')[0] !== expected.domain.split('/')[0])
112
+ return;
113
+ // A different PID namespace cannot establish whether the old process died.
114
+ if (domain !== expected.domain)
115
+ throw failure();
116
+ }
117
+ const current = await readEntityboxHostProcess(expected.pid);
118
+ if (current && sameEntityboxHostProcess(current, expected))
119
+ throw new entitybox_execution_lease_1.EntityboxExecutionError('The previous native controller or guard is still present');
120
+ }
@@ -0,0 +1,10 @@
1
+ /** EntityBox's opt-in installation restriction. Public identifiers are not
2
+ * credentials; the native resolver and desktop MCP still authorize access. */
3
+ export declare class EntityboxInstallError extends Error {
4
+ }
5
+ export declare function entityboxInstallScope(overrides: Record<string, Record<string, string>> | undefined, requestId: string | undefined): string | null;
6
+ export declare function assertEntityboxDesktopMcp(mcps: Array<{
7
+ slug: string;
8
+ command: string;
9
+ env: Record<string, string> | null;
10
+ }>, scope: string): void;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EntityboxInstallError = void 0;
4
+ exports.entityboxInstallScope = entityboxInstallScope;
5
+ exports.assertEntityboxDesktopMcp = assertEntityboxDesktopMcp;
6
+ /** EntityBox's opt-in installation restriction. Public identifiers are not
7
+ * credentials; the native resolver and desktop MCP still authorize access. */
8
+ class EntityboxInstallError extends Error {
9
+ }
10
+ exports.EntityboxInstallError = EntityboxInstallError;
11
+ function entityboxInstallScope(overrides, requestId) {
12
+ const env = overrides?.['entity-desktop-mcp'];
13
+ if (!env || !Object.prototype.hasOwnProperty.call(env, 'ENTITYBOX_DESKTOP_SCOPE'))
14
+ return null;
15
+ const value = env.ENTITYBOX_DESKTOP_SCOPE;
16
+ const uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
17
+ try {
18
+ if (!requestId || !uuid.test(requestId) || typeof value !== 'string' || value.length > 512)
19
+ throw new Error();
20
+ const scope = JSON.parse(value);
21
+ if (!scope || Array.isArray(scope) || scope.version !== 1
22
+ || Object.keys(scope).sort().join(',') !== 'desktopId,runId,runtimeId,version'
23
+ || !['runId', 'desktopId', 'runtimeId'].every(key => typeof scope[key] === 'string' && uuid.test(scope[key])))
24
+ throw new Error();
25
+ return value;
26
+ }
27
+ catch {
28
+ throw new EntityboxInstallError('The computer task has an invalid execution scope. Start a new task.');
29
+ }
30
+ }
31
+ function assertEntityboxDesktopMcp(mcps, scope) {
32
+ const rows = mcps.filter(m => m.slug === 'entity-desktop-mcp');
33
+ if (rows.length !== 1 || !rows[0].command?.trim() || ['http', 'sse', 'streamable-http'].includes(rows[0].command.toLowerCase())) {
34
+ throw new EntityboxInstallError('The required native desktop connection could not be installed.');
35
+ }
36
+ const env = rows[0].env;
37
+ if (env?.ENTITYBOX_DESKTOP_SCOPE !== scope || !env?.ENTITY_API_KEY?.trim()) {
38
+ throw new EntityboxInstallError('The computer connection credentials or execution scope are unavailable.');
39
+ }
40
+ }
@@ -0,0 +1,77 @@
1
+ import { type EntityboxExecutionLease } from './entitybox-execution-lease';
2
+ import { type EntityboxMcpScope } from './entitybox-mcp-contract';
3
+ import type { EntityboxBrokerEmit } from './entitybox-provider-broker';
4
+ /** Trusted runtime resource owner, never supplied by the task/model. It must
5
+ * cover ALL dispatched desktop actions, including detached/background work
6
+ * and periodic MCP captures. MCP process exit is not this proof. There is no
7
+ * production implementation for legacy native desktops yet. */
8
+ export interface EntityboxDesktopActionOwner {
9
+ readonly scope: EntityboxMcpScope;
10
+ readonly transport?: {
11
+ configuration: string;
12
+ token: string;
13
+ capability: {
14
+ version: number;
15
+ requestId: string;
16
+ attemptId: string;
17
+ scope: EntityboxMcpScope;
18
+ };
19
+ };
20
+ assertActive(): Promise<void>;
21
+ stopAndVerify(): Promise<void>;
22
+ }
23
+ interface Config {
24
+ /** Actual request-scoped descriptor returned by the native installer. */
25
+ connection: {
26
+ command: string;
27
+ args: string[];
28
+ env: Record<string, string>;
29
+ };
30
+ allowedTools: readonly string[];
31
+ actions: EntityboxDesktopActionOwner;
32
+ /** Additional resolved credentials to scrub; never public task input. */
33
+ secrets?: readonly string[];
34
+ /** Trusted test/runtime deadline, bounded at two minutes. */
35
+ requestTimeoutMs?: number;
36
+ }
37
+ /** One required, scoped native MCP connection per isolated task. The model
38
+ * receives a small MCP facade over the existing broker pipe, not this process,
39
+ * command line, configuration, entity key, pairing token or lease nonce. */
40
+ export declare class EntityboxMcpBroker {
41
+ private readonly lease;
42
+ private readonly proc;
43
+ private readonly closed;
44
+ private didClose;
45
+ private childPid?;
46
+ private buffer;
47
+ private diagnostics;
48
+ private readonly pending;
49
+ private readonly allowed;
50
+ private readonly secrets;
51
+ private readonly timeout;
52
+ private readonly actions;
53
+ private catalog;
54
+ private ready;
55
+ private closing;
56
+ private stopping?;
57
+ private clientPhase;
58
+ private serial;
59
+ private queued;
60
+ failureCode?: 'entitybox_mcp_connection_failed';
61
+ private constructor();
62
+ static connect(lease: EntityboxExecutionLease, config: Config): Promise<EntityboxMcpBroker>;
63
+ /** Public process identity for the owning runtime's resource ledger. */
64
+ get processId(): number | undefined;
65
+ private active;
66
+ private rejectPending;
67
+ private fail;
68
+ private consume;
69
+ private rpc;
70
+ private notify;
71
+ handle(raw: unknown, signal: AbortSignal, emit: EntityboxBrokerEmit): Promise<void>;
72
+ /** Aggregate this with the isolated model owner's stop proof before calling
73
+ * lease.acknowledgeStopped. Never acknowledge on MCP/container exit alone. */
74
+ stopAndVerify(): Promise<void>;
75
+ private closeOwnedConnection;
76
+ }
77
+ export {};