@autohq/cli 0.1.223 → 0.1.225
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/agent-bridge.js +105 -15
- package/dist/index.js +106 -24
- package/package.json +1 -1
package/dist/agent-bridge.js
CHANGED
|
@@ -23319,7 +23319,7 @@ Object.assign(lookup, {
|
|
|
23319
23319
|
// package.json
|
|
23320
23320
|
var package_default = {
|
|
23321
23321
|
name: "@autohq/cli",
|
|
23322
|
-
version: "0.1.
|
|
23322
|
+
version: "0.1.225",
|
|
23323
23323
|
license: "SEE LICENSE IN README.md",
|
|
23324
23324
|
publishConfig: {
|
|
23325
23325
|
access: "public"
|
|
@@ -23846,6 +23846,8 @@ var AuthScopeSchema = external_exports.enum([
|
|
|
23846
23846
|
"secret-values:read",
|
|
23847
23847
|
"github:mcp",
|
|
23848
23848
|
"github:credentials",
|
|
23849
|
+
"mcp:connection",
|
|
23850
|
+
"runtime-logs:write",
|
|
23849
23851
|
"projects:admin",
|
|
23850
23852
|
"org:admin"
|
|
23851
23853
|
]);
|
|
@@ -27280,20 +27282,24 @@ var SetupOnboardingPullRequestStatusResponseSchema = external_exports.object({
|
|
|
27280
27282
|
ready: external_exports.boolean()
|
|
27281
27283
|
});
|
|
27282
27284
|
|
|
27283
|
-
// ../../packages/schemas/src/e2b-webhook.ts
|
|
27284
|
-
var E2bLifecycleWebhookEventSchema = external_exports.object({
|
|
27285
|
-
type: external_exports.string().min(1),
|
|
27286
|
-
sandbox_id: external_exports.string().min(1),
|
|
27287
|
-
sandbox_execution_id: external_exports.string().optional(),
|
|
27288
|
-
timestamp: external_exports.string().optional()
|
|
27289
|
-
}).passthrough();
|
|
27290
|
-
|
|
27291
27285
|
// ../../packages/schemas/src/runtime-log.ts
|
|
27292
27286
|
var RUNTIME_LOG_LEVELS = ["debug", "info", "warn", "error"];
|
|
27293
27287
|
var RuntimeLogLevelSchema = external_exports.enum(RUNTIME_LOG_LEVELS);
|
|
27288
|
+
var RUNTIME_LOG_INGEST_URL_ENV = "AUTO_RUNTIME_LOG_INGEST_URL";
|
|
27289
|
+
var RUNTIME_LOG_INGEST_TOKEN_ENV = "AUTO_RUNTIME_LOG_INGEST_TOKEN";
|
|
27294
27290
|
var DEFAULT_RUNTIME_LOG_LEVEL = "info";
|
|
27295
27291
|
var SANDBOX_RUNTIME_LOG_DIR = "/home/user/.auto-runtime";
|
|
27296
27292
|
var SANDBOX_RUNTIME_LOG_PATH = `${SANDBOX_RUNTIME_LOG_DIR}/agent-bridge.log`;
|
|
27293
|
+
var RuntimeLogIngestLineSchema = external_exports.object({
|
|
27294
|
+
logSeq: external_exports.number().int().positive(),
|
|
27295
|
+
timestamp: external_exports.string().datetime(),
|
|
27296
|
+
level: RuntimeLogLevelSchema,
|
|
27297
|
+
component: external_exports.string().trim().min(1),
|
|
27298
|
+
message: external_exports.string()
|
|
27299
|
+
}).passthrough();
|
|
27300
|
+
var RuntimeLogIngestRequestSchema = external_exports.object({
|
|
27301
|
+
lines: external_exports.array(RuntimeLogIngestLineSchema).min(1).max(100)
|
|
27302
|
+
}).strict();
|
|
27297
27303
|
var LEVEL_SEVERITY = {
|
|
27298
27304
|
debug: 10,
|
|
27299
27305
|
info: 20,
|
|
@@ -48493,14 +48499,27 @@ function resolveHarnessConfig(bootstrap) {
|
|
|
48493
48499
|
|
|
48494
48500
|
// src/commands/agent-bridge/runtime-log.ts
|
|
48495
48501
|
var RUNTIME_LOG_COMPONENT = "runtime-cli";
|
|
48502
|
+
var INGEST_BATCH_SIZE = 50;
|
|
48503
|
+
var INGEST_FLUSH_DELAY_MS = 1e3;
|
|
48504
|
+
var INGEST_MAX_QUEUED_LINES = 1e3;
|
|
48496
48505
|
function createRuntimeLogger(env = process.env) {
|
|
48497
48506
|
const level = parseRuntimeLogLevel(env.AUTO_RUNTIME_LOG_LEVEL);
|
|
48507
|
+
const ingest = createRuntimeLogIngest(env);
|
|
48508
|
+
let nextLogSeq = 1;
|
|
48498
48509
|
const emit = (lineLevel) => {
|
|
48499
48510
|
return (message, context) => {
|
|
48500
48511
|
if (!runtimeLogLevelEnabled(level, lineLevel)) {
|
|
48501
48512
|
return;
|
|
48502
48513
|
}
|
|
48503
|
-
|
|
48514
|
+
const line = runtimeLogLine({
|
|
48515
|
+
context,
|
|
48516
|
+
level: lineLevel,
|
|
48517
|
+
logSeq: nextLogSeq,
|
|
48518
|
+
message
|
|
48519
|
+
});
|
|
48520
|
+
nextLogSeq += 1;
|
|
48521
|
+
writeRuntimeLogLine(line);
|
|
48522
|
+
ingest?.enqueue(line);
|
|
48504
48523
|
};
|
|
48505
48524
|
};
|
|
48506
48525
|
return {
|
|
@@ -48511,17 +48530,88 @@ function createRuntimeLogger(env = process.env) {
|
|
|
48511
48530
|
error: emit("error")
|
|
48512
48531
|
};
|
|
48513
48532
|
}
|
|
48514
|
-
function
|
|
48515
|
-
|
|
48533
|
+
function runtimeLogLine(input) {
|
|
48534
|
+
return {
|
|
48535
|
+
...input.context ?? {},
|
|
48536
|
+
logSeq: input.logSeq,
|
|
48516
48537
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
48517
|
-
level,
|
|
48538
|
+
level: input.level,
|
|
48518
48539
|
component: RUNTIME_LOG_COMPONENT,
|
|
48519
|
-
message
|
|
48520
|
-
...context ?? {}
|
|
48540
|
+
message: input.message
|
|
48521
48541
|
};
|
|
48542
|
+
}
|
|
48543
|
+
function writeRuntimeLogLine(payload) {
|
|
48522
48544
|
process.stderr.write(`${JSON.stringify(payload, replaceErrors)}
|
|
48523
48545
|
`);
|
|
48524
48546
|
}
|
|
48547
|
+
function createRuntimeLogIngest(env) {
|
|
48548
|
+
const url3 = env[RUNTIME_LOG_INGEST_URL_ENV]?.trim();
|
|
48549
|
+
const token = env[RUNTIME_LOG_INGEST_TOKEN_ENV]?.trim();
|
|
48550
|
+
if (!url3 || !token) {
|
|
48551
|
+
return void 0;
|
|
48552
|
+
}
|
|
48553
|
+
const queue = [];
|
|
48554
|
+
let flushTimer;
|
|
48555
|
+
let inFlight = false;
|
|
48556
|
+
const scheduleFlush = () => {
|
|
48557
|
+
if (flushTimer || inFlight) {
|
|
48558
|
+
return;
|
|
48559
|
+
}
|
|
48560
|
+
flushTimer = setTimeout(() => {
|
|
48561
|
+
flushTimer = void 0;
|
|
48562
|
+
void flush();
|
|
48563
|
+
}, INGEST_FLUSH_DELAY_MS);
|
|
48564
|
+
flushTimer.unref?.();
|
|
48565
|
+
};
|
|
48566
|
+
const flush = async () => {
|
|
48567
|
+
if (inFlight || queue.length === 0) {
|
|
48568
|
+
return;
|
|
48569
|
+
}
|
|
48570
|
+
inFlight = true;
|
|
48571
|
+
const batch = queue.splice(0, INGEST_BATCH_SIZE);
|
|
48572
|
+
try {
|
|
48573
|
+
const response = await fetch(url3, {
|
|
48574
|
+
method: "POST",
|
|
48575
|
+
headers: {
|
|
48576
|
+
authorization: `Bearer ${token}`,
|
|
48577
|
+
"content-type": "application/json"
|
|
48578
|
+
},
|
|
48579
|
+
body: JSON.stringify({ lines: batch }, replaceErrors)
|
|
48580
|
+
});
|
|
48581
|
+
if (!response.ok) {
|
|
48582
|
+
if (shouldRetryIngestResponse(response)) {
|
|
48583
|
+
requeue(batch);
|
|
48584
|
+
}
|
|
48585
|
+
}
|
|
48586
|
+
} catch {
|
|
48587
|
+
requeue(batch);
|
|
48588
|
+
} finally {
|
|
48589
|
+
inFlight = false;
|
|
48590
|
+
if (queue.length > 0) {
|
|
48591
|
+
scheduleFlush();
|
|
48592
|
+
}
|
|
48593
|
+
}
|
|
48594
|
+
};
|
|
48595
|
+
const requeue = (batch) => {
|
|
48596
|
+
queue.unshift(...batch);
|
|
48597
|
+
trimQueue();
|
|
48598
|
+
};
|
|
48599
|
+
const trimQueue = () => {
|
|
48600
|
+
if (queue.length > INGEST_MAX_QUEUED_LINES) {
|
|
48601
|
+
queue.splice(0, queue.length - INGEST_MAX_QUEUED_LINES);
|
|
48602
|
+
}
|
|
48603
|
+
};
|
|
48604
|
+
return {
|
|
48605
|
+
enqueue(line) {
|
|
48606
|
+
queue.push(line);
|
|
48607
|
+
trimQueue();
|
|
48608
|
+
scheduleFlush();
|
|
48609
|
+
}
|
|
48610
|
+
};
|
|
48611
|
+
}
|
|
48612
|
+
function shouldRetryIngestResponse(response) {
|
|
48613
|
+
return response.status === 429 || response.status >= 500;
|
|
48614
|
+
}
|
|
48525
48615
|
function replaceErrors(_key, value2) {
|
|
48526
48616
|
if (value2 instanceof Error) {
|
|
48527
48617
|
return { name: value2.name, message: value2.message, stack: value2.stack };
|
package/dist/index.js
CHANGED
|
@@ -15260,6 +15260,8 @@ var init_auth = __esm({
|
|
|
15260
15260
|
"secret-values:read",
|
|
15261
15261
|
"github:mcp",
|
|
15262
15262
|
"github:credentials",
|
|
15263
|
+
"mcp:connection",
|
|
15264
|
+
"runtime-logs:write",
|
|
15263
15265
|
"projects:admin",
|
|
15264
15266
|
"org:admin"
|
|
15265
15267
|
]);
|
|
@@ -19111,21 +19113,6 @@ var init_setup = __esm({
|
|
|
19111
19113
|
}
|
|
19112
19114
|
});
|
|
19113
19115
|
|
|
19114
|
-
// ../../packages/schemas/src/e2b-webhook.ts
|
|
19115
|
-
var E2bLifecycleWebhookEventSchema;
|
|
19116
|
-
var init_e2b_webhook = __esm({
|
|
19117
|
-
"../../packages/schemas/src/e2b-webhook.ts"() {
|
|
19118
|
-
"use strict";
|
|
19119
|
-
init_zod();
|
|
19120
|
-
E2bLifecycleWebhookEventSchema = external_exports.object({
|
|
19121
|
-
type: external_exports.string().min(1),
|
|
19122
|
-
sandbox_id: external_exports.string().min(1),
|
|
19123
|
-
sandbox_execution_id: external_exports.string().optional(),
|
|
19124
|
-
timestamp: external_exports.string().optional()
|
|
19125
|
-
}).passthrough();
|
|
19126
|
-
}
|
|
19127
|
-
});
|
|
19128
|
-
|
|
19129
19116
|
// ../../packages/schemas/src/runtime-log.ts
|
|
19130
19117
|
function parseRuntimeLogLevel(value) {
|
|
19131
19118
|
const parsed = RuntimeLogLevelSchema.safeParse(value?.trim());
|
|
@@ -19134,16 +19121,28 @@ function parseRuntimeLogLevel(value) {
|
|
|
19134
19121
|
function runtimeLogLevelEnabled(configured, lineLevel) {
|
|
19135
19122
|
return LEVEL_SEVERITY[lineLevel] >= LEVEL_SEVERITY[configured];
|
|
19136
19123
|
}
|
|
19137
|
-
var RUNTIME_LOG_LEVELS, RuntimeLogLevelSchema, DEFAULT_RUNTIME_LOG_LEVEL, SANDBOX_RUNTIME_LOG_DIR, SANDBOX_RUNTIME_LOG_PATH, LEVEL_SEVERITY;
|
|
19124
|
+
var RUNTIME_LOG_LEVELS, RuntimeLogLevelSchema, RUNTIME_LOG_INGEST_URL_ENV, RUNTIME_LOG_INGEST_TOKEN_ENV, DEFAULT_RUNTIME_LOG_LEVEL, SANDBOX_RUNTIME_LOG_DIR, SANDBOX_RUNTIME_LOG_PATH, RuntimeLogIngestLineSchema, RuntimeLogIngestRequestSchema, LEVEL_SEVERITY;
|
|
19138
19125
|
var init_runtime_log = __esm({
|
|
19139
19126
|
"../../packages/schemas/src/runtime-log.ts"() {
|
|
19140
19127
|
"use strict";
|
|
19141
19128
|
init_zod();
|
|
19142
19129
|
RUNTIME_LOG_LEVELS = ["debug", "info", "warn", "error"];
|
|
19143
19130
|
RuntimeLogLevelSchema = external_exports.enum(RUNTIME_LOG_LEVELS);
|
|
19131
|
+
RUNTIME_LOG_INGEST_URL_ENV = "AUTO_RUNTIME_LOG_INGEST_URL";
|
|
19132
|
+
RUNTIME_LOG_INGEST_TOKEN_ENV = "AUTO_RUNTIME_LOG_INGEST_TOKEN";
|
|
19144
19133
|
DEFAULT_RUNTIME_LOG_LEVEL = "info";
|
|
19145
19134
|
SANDBOX_RUNTIME_LOG_DIR = "/home/user/.auto-runtime";
|
|
19146
19135
|
SANDBOX_RUNTIME_LOG_PATH = `${SANDBOX_RUNTIME_LOG_DIR}/agent-bridge.log`;
|
|
19136
|
+
RuntimeLogIngestLineSchema = external_exports.object({
|
|
19137
|
+
logSeq: external_exports.number().int().positive(),
|
|
19138
|
+
timestamp: external_exports.string().datetime(),
|
|
19139
|
+
level: RuntimeLogLevelSchema,
|
|
19140
|
+
component: external_exports.string().trim().min(1),
|
|
19141
|
+
message: external_exports.string()
|
|
19142
|
+
}).passthrough();
|
|
19143
|
+
RuntimeLogIngestRequestSchema = external_exports.object({
|
|
19144
|
+
lines: external_exports.array(RuntimeLogIngestLineSchema).min(1).max(100)
|
|
19145
|
+
}).strict();
|
|
19147
19146
|
LEVEL_SEVERITY = {
|
|
19148
19147
|
debug: 10,
|
|
19149
19148
|
info: 20,
|
|
@@ -19302,7 +19301,6 @@ var init_src = __esm({
|
|
|
19302
19301
|
init_secrets();
|
|
19303
19302
|
init_session_commands();
|
|
19304
19303
|
init_setup();
|
|
19305
|
-
init_e2b_webhook();
|
|
19306
19304
|
init_runtime_log();
|
|
19307
19305
|
init_runtime_log_tailer();
|
|
19308
19306
|
init_runtimes();
|
|
@@ -21996,7 +21994,7 @@ var init_package = __esm({
|
|
|
21996
21994
|
"package.json"() {
|
|
21997
21995
|
package_default = {
|
|
21998
21996
|
name: "@autohq/cli",
|
|
21999
|
-
version: "0.1.
|
|
21997
|
+
version: "0.1.225",
|
|
22000
21998
|
license: "SEE LICENSE IN README.md",
|
|
22001
21999
|
publishConfig: {
|
|
22002
22000
|
access: "public"
|
|
@@ -33633,14 +33631,27 @@ function resolveHarnessConfig(bootstrap) {
|
|
|
33633
33631
|
// src/commands/agent-bridge/runtime-log.ts
|
|
33634
33632
|
init_src();
|
|
33635
33633
|
var RUNTIME_LOG_COMPONENT = "runtime-cli";
|
|
33634
|
+
var INGEST_BATCH_SIZE = 50;
|
|
33635
|
+
var INGEST_FLUSH_DELAY_MS = 1e3;
|
|
33636
|
+
var INGEST_MAX_QUEUED_LINES = 1e3;
|
|
33636
33637
|
function createRuntimeLogger(env = process.env) {
|
|
33637
33638
|
const level = parseRuntimeLogLevel(env.AUTO_RUNTIME_LOG_LEVEL);
|
|
33639
|
+
const ingest = createRuntimeLogIngest(env);
|
|
33640
|
+
let nextLogSeq = 1;
|
|
33638
33641
|
const emit = (lineLevel) => {
|
|
33639
33642
|
return (message, context) => {
|
|
33640
33643
|
if (!runtimeLogLevelEnabled(level, lineLevel)) {
|
|
33641
33644
|
return;
|
|
33642
33645
|
}
|
|
33643
|
-
|
|
33646
|
+
const line = runtimeLogLine({
|
|
33647
|
+
context,
|
|
33648
|
+
level: lineLevel,
|
|
33649
|
+
logSeq: nextLogSeq,
|
|
33650
|
+
message
|
|
33651
|
+
});
|
|
33652
|
+
nextLogSeq += 1;
|
|
33653
|
+
writeRuntimeLogLine(line);
|
|
33654
|
+
ingest?.enqueue(line);
|
|
33644
33655
|
};
|
|
33645
33656
|
};
|
|
33646
33657
|
return {
|
|
@@ -33651,17 +33662,88 @@ function createRuntimeLogger(env = process.env) {
|
|
|
33651
33662
|
error: emit("error")
|
|
33652
33663
|
};
|
|
33653
33664
|
}
|
|
33654
|
-
function
|
|
33655
|
-
|
|
33665
|
+
function runtimeLogLine(input) {
|
|
33666
|
+
return {
|
|
33667
|
+
...input.context ?? {},
|
|
33668
|
+
logSeq: input.logSeq,
|
|
33656
33669
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
33657
|
-
level,
|
|
33670
|
+
level: input.level,
|
|
33658
33671
|
component: RUNTIME_LOG_COMPONENT,
|
|
33659
|
-
message
|
|
33660
|
-
...context ?? {}
|
|
33672
|
+
message: input.message
|
|
33661
33673
|
};
|
|
33674
|
+
}
|
|
33675
|
+
function writeRuntimeLogLine(payload) {
|
|
33662
33676
|
process.stderr.write(`${JSON.stringify(payload, replaceErrors)}
|
|
33663
33677
|
`);
|
|
33664
33678
|
}
|
|
33679
|
+
function createRuntimeLogIngest(env) {
|
|
33680
|
+
const url2 = env[RUNTIME_LOG_INGEST_URL_ENV]?.trim();
|
|
33681
|
+
const token2 = env[RUNTIME_LOG_INGEST_TOKEN_ENV]?.trim();
|
|
33682
|
+
if (!url2 || !token2) {
|
|
33683
|
+
return void 0;
|
|
33684
|
+
}
|
|
33685
|
+
const queue = [];
|
|
33686
|
+
let flushTimer;
|
|
33687
|
+
let inFlight = false;
|
|
33688
|
+
const scheduleFlush = () => {
|
|
33689
|
+
if (flushTimer || inFlight) {
|
|
33690
|
+
return;
|
|
33691
|
+
}
|
|
33692
|
+
flushTimer = setTimeout(() => {
|
|
33693
|
+
flushTimer = void 0;
|
|
33694
|
+
void flush();
|
|
33695
|
+
}, INGEST_FLUSH_DELAY_MS);
|
|
33696
|
+
flushTimer.unref?.();
|
|
33697
|
+
};
|
|
33698
|
+
const flush = async () => {
|
|
33699
|
+
if (inFlight || queue.length === 0) {
|
|
33700
|
+
return;
|
|
33701
|
+
}
|
|
33702
|
+
inFlight = true;
|
|
33703
|
+
const batch = queue.splice(0, INGEST_BATCH_SIZE);
|
|
33704
|
+
try {
|
|
33705
|
+
const response = await fetch(url2, {
|
|
33706
|
+
method: "POST",
|
|
33707
|
+
headers: {
|
|
33708
|
+
authorization: `Bearer ${token2}`,
|
|
33709
|
+
"content-type": "application/json"
|
|
33710
|
+
},
|
|
33711
|
+
body: JSON.stringify({ lines: batch }, replaceErrors)
|
|
33712
|
+
});
|
|
33713
|
+
if (!response.ok) {
|
|
33714
|
+
if (shouldRetryIngestResponse(response)) {
|
|
33715
|
+
requeue(batch);
|
|
33716
|
+
}
|
|
33717
|
+
}
|
|
33718
|
+
} catch {
|
|
33719
|
+
requeue(batch);
|
|
33720
|
+
} finally {
|
|
33721
|
+
inFlight = false;
|
|
33722
|
+
if (queue.length > 0) {
|
|
33723
|
+
scheduleFlush();
|
|
33724
|
+
}
|
|
33725
|
+
}
|
|
33726
|
+
};
|
|
33727
|
+
const requeue = (batch) => {
|
|
33728
|
+
queue.unshift(...batch);
|
|
33729
|
+
trimQueue();
|
|
33730
|
+
};
|
|
33731
|
+
const trimQueue = () => {
|
|
33732
|
+
if (queue.length > INGEST_MAX_QUEUED_LINES) {
|
|
33733
|
+
queue.splice(0, queue.length - INGEST_MAX_QUEUED_LINES);
|
|
33734
|
+
}
|
|
33735
|
+
};
|
|
33736
|
+
return {
|
|
33737
|
+
enqueue(line) {
|
|
33738
|
+
queue.push(line);
|
|
33739
|
+
trimQueue();
|
|
33740
|
+
scheduleFlush();
|
|
33741
|
+
}
|
|
33742
|
+
};
|
|
33743
|
+
}
|
|
33744
|
+
function shouldRetryIngestResponse(response) {
|
|
33745
|
+
return response.status === 429 || response.status >= 500;
|
|
33746
|
+
}
|
|
33665
33747
|
function replaceErrors(_key, value) {
|
|
33666
33748
|
if (value instanceof Error) {
|
|
33667
33749
|
return { name: value.name, message: value.message, stack: value.stack };
|