@companyhelm/runner 0.0.17 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/commands/root.js
CHANGED
|
@@ -42,7 +42,6 @@ exports.isNoActiveTurnSteerError = isNoActiveTurnSteerError;
|
|
|
42
42
|
exports.isNoRunningTurnInterruptError = isNoRunningTurnInterruptError;
|
|
43
43
|
exports.normalizeThreadAgentApiUrlForRuntime = normalizeThreadAgentApiUrlForRuntime;
|
|
44
44
|
exports.extractThreadNameUpdateFromNotification = extractThreadNameUpdateFromNotification;
|
|
45
|
-
exports.extractServerMessageRequestId = extractServerMessageRequestId;
|
|
46
45
|
exports.runCommandLoop = runCommandLoop;
|
|
47
46
|
exports.isInternalDaemonChildProcess = isInternalDaemonChildProcess;
|
|
48
47
|
exports.runDetachedDaemonProcess = runDetachedDaemonProcess;
|
|
@@ -445,80 +444,6 @@ function extractThreadNameUpdateFromNotification(notification) {
|
|
|
445
444
|
normalizeNonEmptyString(params.thread_name);
|
|
446
445
|
return { sdkThreadId, threadName };
|
|
447
446
|
}
|
|
448
|
-
function isByte(value) {
|
|
449
|
-
return typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 255;
|
|
450
|
-
}
|
|
451
|
-
function decodeLengthDelimitedPayload(bytes) {
|
|
452
|
-
let index = 0;
|
|
453
|
-
let shift = 0;
|
|
454
|
-
let length = 0;
|
|
455
|
-
while (index < bytes.length) {
|
|
456
|
-
const current = bytes[index];
|
|
457
|
-
length |= (current & 0x7f) << shift;
|
|
458
|
-
index += 1;
|
|
459
|
-
if ((current & 0x80) === 0) {
|
|
460
|
-
break;
|
|
461
|
-
}
|
|
462
|
-
shift += 7;
|
|
463
|
-
if (shift > 28) {
|
|
464
|
-
return null;
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
if (index === 0) {
|
|
468
|
-
return null;
|
|
469
|
-
}
|
|
470
|
-
if (index + length !== bytes.length) {
|
|
471
|
-
return null;
|
|
472
|
-
}
|
|
473
|
-
return bytes.subarray(index);
|
|
474
|
-
}
|
|
475
|
-
function toUint8Array(data) {
|
|
476
|
-
if (data instanceof Uint8Array) {
|
|
477
|
-
return data;
|
|
478
|
-
}
|
|
479
|
-
if (Buffer.isBuffer(data)) {
|
|
480
|
-
return new Uint8Array(data);
|
|
481
|
-
}
|
|
482
|
-
if (Array.isArray(data) && data.every(isByte)) {
|
|
483
|
-
return Uint8Array.from(data);
|
|
484
|
-
}
|
|
485
|
-
if (data &&
|
|
486
|
-
typeof data === "object" &&
|
|
487
|
-
"type" in data &&
|
|
488
|
-
data.type === "Buffer" &&
|
|
489
|
-
"data" in data &&
|
|
490
|
-
Array.isArray(data.data)) {
|
|
491
|
-
const values = data.data;
|
|
492
|
-
if (values.every(isByte)) {
|
|
493
|
-
return Uint8Array.from(values);
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
return null;
|
|
497
|
-
}
|
|
498
|
-
function extractServerMessageRequestId(serverMessage) {
|
|
499
|
-
if (!serverMessage || typeof serverMessage !== "object") {
|
|
500
|
-
return undefined;
|
|
501
|
-
}
|
|
502
|
-
const typedMessage = serverMessage;
|
|
503
|
-
if (typeof typedMessage.requestId === "string" && typedMessage.requestId.length > 0) {
|
|
504
|
-
return typedMessage.requestId;
|
|
505
|
-
}
|
|
506
|
-
if (!Array.isArray(typedMessage.$unknown)) {
|
|
507
|
-
return undefined;
|
|
508
|
-
}
|
|
509
|
-
for (const field of typedMessage.$unknown) {
|
|
510
|
-
if (field?.no !== 1 || field.wireType !== 2) {
|
|
511
|
-
continue;
|
|
512
|
-
}
|
|
513
|
-
const bytes = toUint8Array(field.data);
|
|
514
|
-
if (!bytes || bytes.length === 0) {
|
|
515
|
-
continue;
|
|
516
|
-
}
|
|
517
|
-
const payload = decodeLengthDelimitedPayload(bytes) ?? bytes;
|
|
518
|
-
return Buffer.from(payload).toString("utf8");
|
|
519
|
-
}
|
|
520
|
-
return undefined;
|
|
521
|
-
}
|
|
522
447
|
function isGrpcServiceError(error) {
|
|
523
448
|
return Boolean(error && typeof error === "object" && "code" in error);
|
|
524
449
|
}
|
|
@@ -2006,18 +1931,18 @@ async function deleteThreadWithCleanup(cfg, request) {
|
|
|
2006
1931
|
}
|
|
2007
1932
|
return { kind: "deleted" };
|
|
2008
1933
|
}
|
|
2009
|
-
async function handleDeleteThreadRequest(cfg, commandChannel, request, logger) {
|
|
1934
|
+
async function handleDeleteThreadRequest(cfg, commandChannel, request, requestId, logger) {
|
|
2010
1935
|
const deleteResult = await deleteThreadWithCleanup(cfg, request);
|
|
2011
1936
|
if (deleteResult.kind === "not_found") {
|
|
2012
1937
|
logger.warn(`Delete requested for missing thread '${request.threadId}'. Treating as deleted.`);
|
|
2013
|
-
await sendThreadUpdate(commandChannel, request.threadId, protos_1.ThreadStatus.DELETED);
|
|
1938
|
+
await sendThreadUpdate(commandChannel, request.threadId, protos_1.ThreadStatus.DELETED, requestId);
|
|
2014
1939
|
return;
|
|
2015
1940
|
}
|
|
2016
1941
|
if (deleteResult.kind === "error") {
|
|
2017
|
-
await sendRequestError(commandChannel, deleteResult.message);
|
|
1942
|
+
await sendRequestError(commandChannel, deleteResult.message, requestId);
|
|
2018
1943
|
return;
|
|
2019
1944
|
}
|
|
2020
|
-
await sendThreadUpdate(commandChannel, request.threadId, protos_1.ThreadStatus.DELETED);
|
|
1945
|
+
await sendThreadUpdate(commandChannel, request.threadId, protos_1.ThreadStatus.DELETED, requestId);
|
|
2021
1946
|
}
|
|
2022
1947
|
async function reportNoRunningInterruptAsReady(cfg, commandChannel, request, threadState, logger, logMessage) {
|
|
2023
1948
|
try {
|
|
@@ -2415,13 +2340,13 @@ async function handleCodexConfigurationRequest(cfg, commandChannel, request, req
|
|
|
2415
2340
|
}
|
|
2416
2341
|
async function runCommandLoop(cfg, commandChannel, commandMessageSink, apiClient, apiCallOptions, logger) {
|
|
2417
2342
|
for await (const serverMessage of commandChannel) {
|
|
2418
|
-
const requestId =
|
|
2343
|
+
const requestId = serverMessage.requestId ?? undefined;
|
|
2419
2344
|
switch (serverMessage.request.case) {
|
|
2420
2345
|
case "createThreadRequest":
|
|
2421
2346
|
await handleCreateThreadRequest(cfg, commandMessageSink, serverMessage.request.value, requestId, apiClient, apiCallOptions, logger);
|
|
2422
2347
|
break;
|
|
2423
2348
|
case "deleteThreadRequest":
|
|
2424
|
-
await handleDeleteThreadRequest(cfg, commandMessageSink, serverMessage.request.value, logger);
|
|
2349
|
+
await handleDeleteThreadRequest(cfg, commandMessageSink, serverMessage.request.value, requestId, logger);
|
|
2425
2350
|
break;
|
|
2426
2351
|
case "createUserMessageRequest":
|
|
2427
2352
|
void handleCreateUserMessageRequest(cfg, commandMessageSink, serverMessage.request.value, requestId, logger).catch((error) => {
|
|
@@ -216,6 +216,7 @@ class AppServerContainerService {
|
|
|
216
216
|
const hostInfo = (0, host_js_1.getHostInfo)(cfg.codex.codex_auth_path);
|
|
217
217
|
const containerHome = cfg.agent_home_directory;
|
|
218
218
|
const containerAuthPath = resolveContainerPath(cfg.codex.codex_auth_path, containerHome);
|
|
219
|
+
const hostAuthPath = (0, path_js_1.expandHome)(cfg.codex.codex_auth_path);
|
|
219
220
|
const hostDedicatedAuthPath = `${(0, path_js_1.expandHome)(cfg.config_directory)}/${cfg.codex.codex_auth_file_path}`;
|
|
220
221
|
const mountArgs = [];
|
|
221
222
|
if (codexAuthMode === "dedicated") {
|
|
@@ -224,6 +225,12 @@ class AppServerContainerService {
|
|
|
224
225
|
}
|
|
225
226
|
mountArgs.push("--mount", `type=bind,src=${hostDedicatedAuthPath},dst=${containerAuthPath}`);
|
|
226
227
|
}
|
|
228
|
+
else if (codexAuthMode === "host") {
|
|
229
|
+
if (!hostInfo.codexAuthExists) {
|
|
230
|
+
throw new Error(`Codex host auth file was not found at ${hostAuthPath}`);
|
|
231
|
+
}
|
|
232
|
+
mountArgs.push("--mount", `type=bind,src=${hostAuthPath},dst=${containerAuthPath}`);
|
|
233
|
+
}
|
|
227
234
|
this.containerName = `companyhelm-codex-app-server-${Date.now()}`;
|
|
228
235
|
const bootstrapTemplate = (0, node_fs_1.readFileSync)(resolveTemplatePath(), "utf8");
|
|
229
236
|
const bootstrapScript = renderJinjaTemplate(bootstrapTemplate, {
|
|
@@ -108,7 +108,7 @@ function buildSharedThreadMounts(options) {
|
|
|
108
108
|
mounts.push({
|
|
109
109
|
Type: "bind",
|
|
110
110
|
Source: hostAuthPath,
|
|
111
|
-
Target:
|
|
111
|
+
Target: resolveContainerPath(options.codexAuthPath, options.containerHomeDirectory),
|
|
112
112
|
});
|
|
113
113
|
return mounts;
|
|
114
114
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@companyhelm/runner",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"description": "Run the CompanyHelm runner in fully isolated Docker sandboxes.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@bufbuild/protobuf": "^2.11.0",
|
|
34
34
|
"@clack/prompts": "^1.0.1",
|
|
35
|
-
"@companyhelm/protos": "^0.5.
|
|
35
|
+
"@companyhelm/protos": "^0.5.20",
|
|
36
36
|
"@grpc/grpc-js": "^1.14.3",
|
|
37
37
|
"@libsql/client": "^0.17.0",
|
|
38
38
|
"commander": "^14.0.0",
|