@autohq/cli 0.1.224 → 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 +104 -15
- package/dist/index.js +105 -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"
|
|
@@ -23847,6 +23847,7 @@ var AuthScopeSchema = external_exports.enum([
|
|
|
23847
23847
|
"github:mcp",
|
|
23848
23848
|
"github:credentials",
|
|
23849
23849
|
"mcp:connection",
|
|
23850
|
+
"runtime-logs:write",
|
|
23850
23851
|
"projects:admin",
|
|
23851
23852
|
"org:admin"
|
|
23852
23853
|
]);
|
|
@@ -27281,20 +27282,24 @@ var SetupOnboardingPullRequestStatusResponseSchema = external_exports.object({
|
|
|
27281
27282
|
ready: external_exports.boolean()
|
|
27282
27283
|
});
|
|
27283
27284
|
|
|
27284
|
-
// ../../packages/schemas/src/e2b-webhook.ts
|
|
27285
|
-
var E2bLifecycleWebhookEventSchema = external_exports.object({
|
|
27286
|
-
type: external_exports.string().min(1),
|
|
27287
|
-
sandbox_id: external_exports.string().min(1),
|
|
27288
|
-
sandbox_execution_id: external_exports.string().optional(),
|
|
27289
|
-
timestamp: external_exports.string().optional()
|
|
27290
|
-
}).passthrough();
|
|
27291
|
-
|
|
27292
27285
|
// ../../packages/schemas/src/runtime-log.ts
|
|
27293
27286
|
var RUNTIME_LOG_LEVELS = ["debug", "info", "warn", "error"];
|
|
27294
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";
|
|
27295
27290
|
var DEFAULT_RUNTIME_LOG_LEVEL = "info";
|
|
27296
27291
|
var SANDBOX_RUNTIME_LOG_DIR = "/home/user/.auto-runtime";
|
|
27297
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();
|
|
27298
27303
|
var LEVEL_SEVERITY = {
|
|
27299
27304
|
debug: 10,
|
|
27300
27305
|
info: 20,
|
|
@@ -48494,14 +48499,27 @@ function resolveHarnessConfig(bootstrap) {
|
|
|
48494
48499
|
|
|
48495
48500
|
// src/commands/agent-bridge/runtime-log.ts
|
|
48496
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;
|
|
48497
48505
|
function createRuntimeLogger(env = process.env) {
|
|
48498
48506
|
const level = parseRuntimeLogLevel(env.AUTO_RUNTIME_LOG_LEVEL);
|
|
48507
|
+
const ingest = createRuntimeLogIngest(env);
|
|
48508
|
+
let nextLogSeq = 1;
|
|
48499
48509
|
const emit = (lineLevel) => {
|
|
48500
48510
|
return (message, context) => {
|
|
48501
48511
|
if (!runtimeLogLevelEnabled(level, lineLevel)) {
|
|
48502
48512
|
return;
|
|
48503
48513
|
}
|
|
48504
|
-
|
|
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);
|
|
48505
48523
|
};
|
|
48506
48524
|
};
|
|
48507
48525
|
return {
|
|
@@ -48512,17 +48530,88 @@ function createRuntimeLogger(env = process.env) {
|
|
|
48512
48530
|
error: emit("error")
|
|
48513
48531
|
};
|
|
48514
48532
|
}
|
|
48515
|
-
function
|
|
48516
|
-
|
|
48533
|
+
function runtimeLogLine(input) {
|
|
48534
|
+
return {
|
|
48535
|
+
...input.context ?? {},
|
|
48536
|
+
logSeq: input.logSeq,
|
|
48517
48537
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
48518
|
-
level,
|
|
48538
|
+
level: input.level,
|
|
48519
48539
|
component: RUNTIME_LOG_COMPONENT,
|
|
48520
|
-
message
|
|
48521
|
-
...context ?? {}
|
|
48540
|
+
message: input.message
|
|
48522
48541
|
};
|
|
48542
|
+
}
|
|
48543
|
+
function writeRuntimeLogLine(payload) {
|
|
48523
48544
|
process.stderr.write(`${JSON.stringify(payload, replaceErrors)}
|
|
48524
48545
|
`);
|
|
48525
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
|
+
}
|
|
48526
48615
|
function replaceErrors(_key, value2) {
|
|
48527
48616
|
if (value2 instanceof Error) {
|
|
48528
48617
|
return { name: value2.name, message: value2.message, stack: value2.stack };
|
package/dist/index.js
CHANGED
|
@@ -15261,6 +15261,7 @@ var init_auth = __esm({
|
|
|
15261
15261
|
"github:mcp",
|
|
15262
15262
|
"github:credentials",
|
|
15263
15263
|
"mcp:connection",
|
|
15264
|
+
"runtime-logs:write",
|
|
15264
15265
|
"projects:admin",
|
|
15265
15266
|
"org:admin"
|
|
15266
15267
|
]);
|
|
@@ -19112,21 +19113,6 @@ var init_setup = __esm({
|
|
|
19112
19113
|
}
|
|
19113
19114
|
});
|
|
19114
19115
|
|
|
19115
|
-
// ../../packages/schemas/src/e2b-webhook.ts
|
|
19116
|
-
var E2bLifecycleWebhookEventSchema;
|
|
19117
|
-
var init_e2b_webhook = __esm({
|
|
19118
|
-
"../../packages/schemas/src/e2b-webhook.ts"() {
|
|
19119
|
-
"use strict";
|
|
19120
|
-
init_zod();
|
|
19121
|
-
E2bLifecycleWebhookEventSchema = external_exports.object({
|
|
19122
|
-
type: external_exports.string().min(1),
|
|
19123
|
-
sandbox_id: external_exports.string().min(1),
|
|
19124
|
-
sandbox_execution_id: external_exports.string().optional(),
|
|
19125
|
-
timestamp: external_exports.string().optional()
|
|
19126
|
-
}).passthrough();
|
|
19127
|
-
}
|
|
19128
|
-
});
|
|
19129
|
-
|
|
19130
19116
|
// ../../packages/schemas/src/runtime-log.ts
|
|
19131
19117
|
function parseRuntimeLogLevel(value) {
|
|
19132
19118
|
const parsed = RuntimeLogLevelSchema.safeParse(value?.trim());
|
|
@@ -19135,16 +19121,28 @@ function parseRuntimeLogLevel(value) {
|
|
|
19135
19121
|
function runtimeLogLevelEnabled(configured, lineLevel) {
|
|
19136
19122
|
return LEVEL_SEVERITY[lineLevel] >= LEVEL_SEVERITY[configured];
|
|
19137
19123
|
}
|
|
19138
|
-
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;
|
|
19139
19125
|
var init_runtime_log = __esm({
|
|
19140
19126
|
"../../packages/schemas/src/runtime-log.ts"() {
|
|
19141
19127
|
"use strict";
|
|
19142
19128
|
init_zod();
|
|
19143
19129
|
RUNTIME_LOG_LEVELS = ["debug", "info", "warn", "error"];
|
|
19144
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";
|
|
19145
19133
|
DEFAULT_RUNTIME_LOG_LEVEL = "info";
|
|
19146
19134
|
SANDBOX_RUNTIME_LOG_DIR = "/home/user/.auto-runtime";
|
|
19147
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();
|
|
19148
19146
|
LEVEL_SEVERITY = {
|
|
19149
19147
|
debug: 10,
|
|
19150
19148
|
info: 20,
|
|
@@ -19303,7 +19301,6 @@ var init_src = __esm({
|
|
|
19303
19301
|
init_secrets();
|
|
19304
19302
|
init_session_commands();
|
|
19305
19303
|
init_setup();
|
|
19306
|
-
init_e2b_webhook();
|
|
19307
19304
|
init_runtime_log();
|
|
19308
19305
|
init_runtime_log_tailer();
|
|
19309
19306
|
init_runtimes();
|
|
@@ -21997,7 +21994,7 @@ var init_package = __esm({
|
|
|
21997
21994
|
"package.json"() {
|
|
21998
21995
|
package_default = {
|
|
21999
21996
|
name: "@autohq/cli",
|
|
22000
|
-
version: "0.1.
|
|
21997
|
+
version: "0.1.225",
|
|
22001
21998
|
license: "SEE LICENSE IN README.md",
|
|
22002
21999
|
publishConfig: {
|
|
22003
22000
|
access: "public"
|
|
@@ -33634,14 +33631,27 @@ function resolveHarnessConfig(bootstrap) {
|
|
|
33634
33631
|
// src/commands/agent-bridge/runtime-log.ts
|
|
33635
33632
|
init_src();
|
|
33636
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;
|
|
33637
33637
|
function createRuntimeLogger(env = process.env) {
|
|
33638
33638
|
const level = parseRuntimeLogLevel(env.AUTO_RUNTIME_LOG_LEVEL);
|
|
33639
|
+
const ingest = createRuntimeLogIngest(env);
|
|
33640
|
+
let nextLogSeq = 1;
|
|
33639
33641
|
const emit = (lineLevel) => {
|
|
33640
33642
|
return (message, context) => {
|
|
33641
33643
|
if (!runtimeLogLevelEnabled(level, lineLevel)) {
|
|
33642
33644
|
return;
|
|
33643
33645
|
}
|
|
33644
|
-
|
|
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);
|
|
33645
33655
|
};
|
|
33646
33656
|
};
|
|
33647
33657
|
return {
|
|
@@ -33652,17 +33662,88 @@ function createRuntimeLogger(env = process.env) {
|
|
|
33652
33662
|
error: emit("error")
|
|
33653
33663
|
};
|
|
33654
33664
|
}
|
|
33655
|
-
function
|
|
33656
|
-
|
|
33665
|
+
function runtimeLogLine(input) {
|
|
33666
|
+
return {
|
|
33667
|
+
...input.context ?? {},
|
|
33668
|
+
logSeq: input.logSeq,
|
|
33657
33669
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
33658
|
-
level,
|
|
33670
|
+
level: input.level,
|
|
33659
33671
|
component: RUNTIME_LOG_COMPONENT,
|
|
33660
|
-
message
|
|
33661
|
-
...context ?? {}
|
|
33672
|
+
message: input.message
|
|
33662
33673
|
};
|
|
33674
|
+
}
|
|
33675
|
+
function writeRuntimeLogLine(payload) {
|
|
33663
33676
|
process.stderr.write(`${JSON.stringify(payload, replaceErrors)}
|
|
33664
33677
|
`);
|
|
33665
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
|
+
}
|
|
33666
33747
|
function replaceErrors(_key, value) {
|
|
33667
33748
|
if (value instanceof Error) {
|
|
33668
33749
|
return { name: value.name, message: value.message, stack: value.stack };
|