@autohq/cli 0.1.207 → 0.1.209
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 +146 -21
- package/dist/index.js +165 -21
- package/package.json +1 -1
package/dist/agent-bridge.js
CHANGED
|
@@ -19469,6 +19469,11 @@ var ConversationEntryStatusSchema = external_exports.enum([
|
|
|
19469
19469
|
"completed",
|
|
19470
19470
|
"failed"
|
|
19471
19471
|
]);
|
|
19472
|
+
var RuntimeTurnStatusSchema = external_exports.enum([
|
|
19473
|
+
"waiting_for_input",
|
|
19474
|
+
"completed",
|
|
19475
|
+
"failed"
|
|
19476
|
+
]);
|
|
19472
19477
|
var ConversationTextContentPartSchema = external_exports.object({
|
|
19473
19478
|
type: external_exports.literal("text"),
|
|
19474
19479
|
text: external_exports.string()
|
|
@@ -19622,7 +19627,7 @@ var RuntimeBridgeCommandDeliveryAcceptedSchema = external_exports.object({
|
|
|
19622
19627
|
result: external_exports.enum(["injected", "duplicate"]),
|
|
19623
19628
|
at: external_exports.string().datetime()
|
|
19624
19629
|
}).strict();
|
|
19625
|
-
var
|
|
19630
|
+
var RuntimeBridgeOutputEntryEnvelopeWireSchema = external_exports.object({
|
|
19626
19631
|
type: external_exports.literal("conversation.entry"),
|
|
19627
19632
|
sessionId: SessionIdSchema,
|
|
19628
19633
|
runtimeId: RuntimeIdSchema,
|
|
@@ -19635,8 +19640,18 @@ var RuntimeBridgeOutputEntryEnvelopeSchema = external_exports.object({
|
|
|
19635
19640
|
content: ConversationEntryContentSchema,
|
|
19636
19641
|
createdAt: external_exports.string().datetime(),
|
|
19637
19642
|
completedAt: external_exports.string().datetime().nullable(),
|
|
19638
|
-
|
|
19643
|
+
turnStatus: RuntimeTurnStatusSchema.optional()
|
|
19639
19644
|
}).strict();
|
|
19645
|
+
var LegacyRuntimeBridgeOutputEntryEnvelopeSchema = RuntimeBridgeOutputEntryEnvelopeWireSchema.omit({ turnStatus: true }).extend({
|
|
19646
|
+
sessionStatusAfter: external_exports.enum(["awaiting", "failed"])
|
|
19647
|
+
}).strict().transform(({ sessionStatusAfter, ...entry }) => ({
|
|
19648
|
+
...entry,
|
|
19649
|
+
turnStatus: legacyRuntimeTurnStatus(entry, sessionStatusAfter)
|
|
19650
|
+
}));
|
|
19651
|
+
var RuntimeBridgeOutputEntryEnvelopeSchema = external_exports.union([
|
|
19652
|
+
RuntimeBridgeOutputEntryEnvelopeWireSchema,
|
|
19653
|
+
LegacyRuntimeBridgeOutputEntryEnvelopeSchema
|
|
19654
|
+
]);
|
|
19640
19655
|
var RuntimeBridgeOutputDeltaEnvelopeSchema = external_exports.object({
|
|
19641
19656
|
type: external_exports.literal("conversation.delta"),
|
|
19642
19657
|
sessionId: SessionIdSchema,
|
|
@@ -19650,10 +19665,16 @@ var RuntimeBridgeOutputDeltaEnvelopeSchema = external_exports.object({
|
|
|
19650
19665
|
delta: ConversationTextDeltaSchema,
|
|
19651
19666
|
createdAt: external_exports.string().datetime()
|
|
19652
19667
|
}).strict();
|
|
19653
|
-
var RuntimeBridgeOutputEnvelopeSchema = external_exports.
|
|
19668
|
+
var RuntimeBridgeOutputEnvelopeSchema = external_exports.union([
|
|
19654
19669
|
RuntimeBridgeOutputEntryEnvelopeSchema,
|
|
19655
19670
|
RuntimeBridgeOutputDeltaEnvelopeSchema
|
|
19656
19671
|
]);
|
|
19672
|
+
function legacyRuntimeTurnStatus(entry, sessionStatusAfter) {
|
|
19673
|
+
if (sessionStatusAfter === "failed" || entry.status === "failed") {
|
|
19674
|
+
return "failed";
|
|
19675
|
+
}
|
|
19676
|
+
return entry.kind === "question" ? "waiting_for_input" : "completed";
|
|
19677
|
+
}
|
|
19657
19678
|
var RuntimeBridgeOutputAckSchema = external_exports.object({
|
|
19658
19679
|
type: external_exports.literal("runtime.output.ack"),
|
|
19659
19680
|
sessionId: SessionIdSchema,
|
|
@@ -22691,6 +22712,40 @@ var RunSummarySchema = external_exports.object({
|
|
|
22691
22712
|
)
|
|
22692
22713
|
});
|
|
22693
22714
|
|
|
22715
|
+
// ../../packages/schemas/src/session-turns.ts
|
|
22716
|
+
var SESSION_TURN_STATUSES = [
|
|
22717
|
+
"accepted",
|
|
22718
|
+
"in_progress",
|
|
22719
|
+
"waiting_for_input",
|
|
22720
|
+
"completed",
|
|
22721
|
+
"failed",
|
|
22722
|
+
"stale"
|
|
22723
|
+
];
|
|
22724
|
+
var SESSION_TURN_FAILURE_SCOPES = ["turn", "session"];
|
|
22725
|
+
var SessionTurnStatusSchema = external_exports.enum(SESSION_TURN_STATUSES);
|
|
22726
|
+
var SessionTurnFailureScopeSchema = external_exports.enum(
|
|
22727
|
+
SESSION_TURN_FAILURE_SCOPES
|
|
22728
|
+
);
|
|
22729
|
+
var SessionTurnRecordSchema = external_exports.object({
|
|
22730
|
+
id: external_exports.string().trim().min(1),
|
|
22731
|
+
sessionId: SessionIdSchema2,
|
|
22732
|
+
commandId: SessionCommandIdSchema2,
|
|
22733
|
+
runtimeId: RuntimeIdSchema2.nullable(),
|
|
22734
|
+
bridgeLeaseId: RuntimeBridgeLeaseIdSchema2.nullable(),
|
|
22735
|
+
status: SessionTurnStatusSchema,
|
|
22736
|
+
failureScope: SessionTurnFailureScopeSchema.nullable(),
|
|
22737
|
+
lastOutputSeq: external_exports.number().int().positive().nullable(),
|
|
22738
|
+
acceptedAt: external_exports.string().datetime().nullable(),
|
|
22739
|
+
startedAt: external_exports.string().datetime().nullable(),
|
|
22740
|
+
lastProgressAt: external_exports.string().datetime().nullable(),
|
|
22741
|
+
completedAt: external_exports.string().datetime().nullable(),
|
|
22742
|
+
failedAt: external_exports.string().datetime().nullable(),
|
|
22743
|
+
staleAt: external_exports.string().datetime().nullable(),
|
|
22744
|
+
error: JsonValueSchema2.nullable(),
|
|
22745
|
+
createdAt: external_exports.string().datetime(),
|
|
22746
|
+
updatedAt: external_exports.string().datetime()
|
|
22747
|
+
});
|
|
22748
|
+
|
|
22694
22749
|
// ../../packages/schemas/src/session-commands.ts
|
|
22695
22750
|
var SESSION_COMMAND_KINDS = [
|
|
22696
22751
|
"message",
|
|
@@ -23016,6 +23071,24 @@ var SetupOnboardingPullRequestStatusResponseSchema = external_exports.object({
|
|
|
23016
23071
|
ready: external_exports.boolean()
|
|
23017
23072
|
});
|
|
23018
23073
|
|
|
23074
|
+
// ../../packages/schemas/src/runtime-log.ts
|
|
23075
|
+
var RUNTIME_LOG_LEVELS = ["debug", "info", "warn", "error"];
|
|
23076
|
+
var RuntimeLogLevelSchema = external_exports.enum(RUNTIME_LOG_LEVELS);
|
|
23077
|
+
var DEFAULT_RUNTIME_LOG_LEVEL = "info";
|
|
23078
|
+
var LEVEL_SEVERITY = {
|
|
23079
|
+
debug: 10,
|
|
23080
|
+
info: 20,
|
|
23081
|
+
warn: 30,
|
|
23082
|
+
error: 40
|
|
23083
|
+
};
|
|
23084
|
+
function parseRuntimeLogLevel(value2) {
|
|
23085
|
+
const parsed = RuntimeLogLevelSchema.safeParse(value2?.trim());
|
|
23086
|
+
return parsed.success ? parsed.data : DEFAULT_RUNTIME_LOG_LEVEL;
|
|
23087
|
+
}
|
|
23088
|
+
function runtimeLogLevelEnabled(configured, lineLevel) {
|
|
23089
|
+
return LEVEL_SEVERITY[lineLevel] >= LEVEL_SEVERITY[configured];
|
|
23090
|
+
}
|
|
23091
|
+
|
|
23019
23092
|
// ../../packages/schemas/src/runtimes.ts
|
|
23020
23093
|
var RuntimeRecordSchema = external_exports.object({
|
|
23021
23094
|
id: RuntimeIdSchema2,
|
|
@@ -26676,7 +26749,7 @@ Object.assign(lookup, {
|
|
|
26676
26749
|
// package.json
|
|
26677
26750
|
var package_default = {
|
|
26678
26751
|
name: "@autohq/cli",
|
|
26679
|
-
version: "0.1.
|
|
26752
|
+
version: "0.1.209",
|
|
26680
26753
|
license: "SEE LICENSE IN README.md",
|
|
26681
26754
|
publishConfig: {
|
|
26682
26755
|
access: "public"
|
|
@@ -27100,7 +27173,7 @@ function buildOutputEnvelope(context, outputSeq, projection) {
|
|
|
27100
27173
|
content: entry.content,
|
|
27101
27174
|
createdAt,
|
|
27102
27175
|
completedAt: entry.status === "in_progress" ? null : createdAt,
|
|
27103
|
-
...entry.
|
|
27176
|
+
...entry.turnStatus ? { turnStatus: entry.turnStatus } : {}
|
|
27104
27177
|
});
|
|
27105
27178
|
}
|
|
27106
27179
|
function isSuccessfulOutputAck(ack) {
|
|
@@ -27133,9 +27206,9 @@ var ClaudeCodeProjector = class {
|
|
|
27133
27206
|
const outputs = parsed.projections.map(
|
|
27134
27207
|
(entry) => ({
|
|
27135
27208
|
type: "entry",
|
|
27136
|
-
// A question
|
|
27137
|
-
// for an operator answer
|
|
27138
|
-
entry: entry.kind === "question" ? { ...entry,
|
|
27209
|
+
// A question means the delivered turn is parked on AskUserQuestion
|
|
27210
|
+
// waiting for an operator answer.
|
|
27211
|
+
entry: entry.kind === "question" ? { ...entry, turnStatus: "waiting_for_input" } : entry
|
|
27139
27212
|
})
|
|
27140
27213
|
);
|
|
27141
27214
|
if (parsed.result) {
|
|
@@ -27145,14 +27218,13 @@ var ClaudeCodeProjector = class {
|
|
|
27145
27218
|
}
|
|
27146
27219
|
};
|
|
27147
27220
|
function projectClaudeCodeResult(result) {
|
|
27148
|
-
const failedButRecoverable = isRecoverableToolUseDiagnostic(result);
|
|
27149
27221
|
return {
|
|
27150
27222
|
type: "entry",
|
|
27151
27223
|
entry: {
|
|
27152
27224
|
role: "system",
|
|
27153
27225
|
kind: "status",
|
|
27154
27226
|
status: result.isError ? "failed" : "completed",
|
|
27155
|
-
|
|
27227
|
+
turnStatus: result.isError ? "failed" : "completed",
|
|
27156
27228
|
content: {
|
|
27157
27229
|
parts: [
|
|
27158
27230
|
{
|
|
@@ -27164,13 +27236,6 @@ function projectClaudeCodeResult(result) {
|
|
|
27164
27236
|
}
|
|
27165
27237
|
};
|
|
27166
27238
|
}
|
|
27167
|
-
function isRecoverableToolUseDiagnostic(result) {
|
|
27168
|
-
if (!result.isError) {
|
|
27169
|
-
return false;
|
|
27170
|
-
}
|
|
27171
|
-
const message = result.errorMessage ?? "";
|
|
27172
|
-
return message.startsWith("[ede_diagnostic]") && message.includes("stop_reason=tool_use");
|
|
27173
|
-
}
|
|
27174
27239
|
function anthropicMessageIdFromStreamStart(message) {
|
|
27175
27240
|
const event = message.event;
|
|
27176
27241
|
if (event.type !== "message_start") {
|
|
@@ -47907,13 +47972,61 @@ function deliveryMode(delivery) {
|
|
|
47907
47972
|
return "interrupt";
|
|
47908
47973
|
}
|
|
47909
47974
|
|
|
47975
|
+
// src/commands/agent-bridge/runtime-log.ts
|
|
47976
|
+
var RUNTIME_LOG_COMPONENT = "runtime-cli";
|
|
47977
|
+
function createRuntimeLogger(env = process.env) {
|
|
47978
|
+
const level = parseRuntimeLogLevel(env.AUTO_RUNTIME_LOG_LEVEL);
|
|
47979
|
+
const emit = (lineLevel) => {
|
|
47980
|
+
return (message, context) => {
|
|
47981
|
+
if (!runtimeLogLevelEnabled(level, lineLevel)) {
|
|
47982
|
+
return;
|
|
47983
|
+
}
|
|
47984
|
+
writeRuntimeLogLine(lineLevel, message, context);
|
|
47985
|
+
};
|
|
47986
|
+
};
|
|
47987
|
+
return {
|
|
47988
|
+
level,
|
|
47989
|
+
debug: emit("debug"),
|
|
47990
|
+
info: emit("info"),
|
|
47991
|
+
warn: emit("warn"),
|
|
47992
|
+
error: emit("error")
|
|
47993
|
+
};
|
|
47994
|
+
}
|
|
47995
|
+
function writeRuntimeLogLine(level, message, context) {
|
|
47996
|
+
const payload = {
|
|
47997
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
47998
|
+
level,
|
|
47999
|
+
component: RUNTIME_LOG_COMPONENT,
|
|
48000
|
+
message,
|
|
48001
|
+
...context ?? {}
|
|
48002
|
+
};
|
|
48003
|
+
process.stderr.write(`${JSON.stringify(payload, replaceErrors)}
|
|
48004
|
+
`);
|
|
48005
|
+
}
|
|
48006
|
+
function replaceErrors(_key, value2) {
|
|
48007
|
+
if (value2 instanceof Error) {
|
|
48008
|
+
return { name: value2.name, message: value2.message, stack: value2.stack };
|
|
48009
|
+
}
|
|
48010
|
+
return value2;
|
|
48011
|
+
}
|
|
48012
|
+
|
|
47910
48013
|
// src/commands/agent-bridge/entrypoint.ts
|
|
47911
48014
|
async function runAgentBridgeProcess(input) {
|
|
47912
48015
|
const runAgentBridge = input.runAgentBridge ?? runAgentBridgeClaudeCode;
|
|
47913
|
-
|
|
47914
|
-
|
|
47915
|
-
|
|
48016
|
+
const log = createRuntimeLogger(input.env);
|
|
48017
|
+
log.info("agent bridge process starting", {
|
|
48018
|
+
bridge_url_host: bridgeUrlHost(input.env.AUTO_BRIDGE_URL),
|
|
48019
|
+
log_level: log.level
|
|
47916
48020
|
});
|
|
48021
|
+
try {
|
|
48022
|
+
await runAgentBridge({
|
|
48023
|
+
...agentBridgeOptionsFromEnv(input),
|
|
48024
|
+
onBootstrap: createGitCredentialRelayStarter(input.writeOutput, log)
|
|
48025
|
+
});
|
|
48026
|
+
} catch (error51) {
|
|
48027
|
+
log.error("agent bridge process failed", { error: error51 });
|
|
48028
|
+
throw error51;
|
|
48029
|
+
}
|
|
47917
48030
|
}
|
|
47918
48031
|
function agentBridgeOptionsFromEnv(input) {
|
|
47919
48032
|
return {
|
|
@@ -47922,7 +48035,7 @@ function agentBridgeOptionsFromEnv(input) {
|
|
|
47922
48035
|
writeOutput: input.writeOutput
|
|
47923
48036
|
};
|
|
47924
48037
|
}
|
|
47925
|
-
function createGitCredentialRelayStarter(writeOutput) {
|
|
48038
|
+
function createGitCredentialRelayStarter(writeOutput, log) {
|
|
47926
48039
|
let relay;
|
|
47927
48040
|
let startup;
|
|
47928
48041
|
return async (bootstrap) => {
|
|
@@ -47942,12 +48055,14 @@ function createGitCredentialRelayStarter(writeOutput) {
|
|
|
47942
48055
|
startup = startGitCredentialRelay(gitCredentials).then((started) => {
|
|
47943
48056
|
relay = started;
|
|
47944
48057
|
writeOutput?.(`agent_bridge_git_credential_relay port=${started.port}`);
|
|
48058
|
+
log?.info("git credential relay started", { port: started.port });
|
|
47945
48059
|
return started;
|
|
47946
48060
|
}).catch((error51) => {
|
|
47947
48061
|
startup = void 0;
|
|
47948
48062
|
writeOutput?.(
|
|
47949
48063
|
`agent_bridge_git_credential_relay_failed error=${error51 instanceof Error ? error51.message : String(error51)}`
|
|
47950
48064
|
);
|
|
48065
|
+
log?.warn("git credential relay failed to start", { error: error51 });
|
|
47951
48066
|
return void 0;
|
|
47952
48067
|
});
|
|
47953
48068
|
await startup;
|
|
@@ -47960,6 +48075,16 @@ function requiredEnv(env, key) {
|
|
|
47960
48075
|
}
|
|
47961
48076
|
return value2;
|
|
47962
48077
|
}
|
|
48078
|
+
function bridgeUrlHost(bridgeUrl) {
|
|
48079
|
+
if (!bridgeUrl) {
|
|
48080
|
+
return void 0;
|
|
48081
|
+
}
|
|
48082
|
+
try {
|
|
48083
|
+
return new URL(bridgeUrl).host;
|
|
48084
|
+
} catch {
|
|
48085
|
+
return void 0;
|
|
48086
|
+
}
|
|
48087
|
+
}
|
|
47963
48088
|
|
|
47964
48089
|
// src/lib/entrypoint.ts
|
|
47965
48090
|
import { realpathSync as realpathSync2 } from "fs";
|
package/dist/index.js
CHANGED
|
@@ -18589,6 +18589,49 @@ var init_session_introspection = __esm({
|
|
|
18589
18589
|
}
|
|
18590
18590
|
});
|
|
18591
18591
|
|
|
18592
|
+
// ../../packages/schemas/src/session-turns.ts
|
|
18593
|
+
var SESSION_TURN_STATUSES, SESSION_TURN_FAILURE_SCOPES, SessionTurnStatusSchema, SessionTurnFailureScopeSchema, SessionTurnRecordSchema;
|
|
18594
|
+
var init_session_turns = __esm({
|
|
18595
|
+
"../../packages/schemas/src/session-turns.ts"() {
|
|
18596
|
+
"use strict";
|
|
18597
|
+
init_zod();
|
|
18598
|
+
init_ids();
|
|
18599
|
+
init_primitives();
|
|
18600
|
+
SESSION_TURN_STATUSES = [
|
|
18601
|
+
"accepted",
|
|
18602
|
+
"in_progress",
|
|
18603
|
+
"waiting_for_input",
|
|
18604
|
+
"completed",
|
|
18605
|
+
"failed",
|
|
18606
|
+
"stale"
|
|
18607
|
+
];
|
|
18608
|
+
SESSION_TURN_FAILURE_SCOPES = ["turn", "session"];
|
|
18609
|
+
SessionTurnStatusSchema = external_exports.enum(SESSION_TURN_STATUSES);
|
|
18610
|
+
SessionTurnFailureScopeSchema = external_exports.enum(
|
|
18611
|
+
SESSION_TURN_FAILURE_SCOPES
|
|
18612
|
+
);
|
|
18613
|
+
SessionTurnRecordSchema = external_exports.object({
|
|
18614
|
+
id: external_exports.string().trim().min(1),
|
|
18615
|
+
sessionId: SessionIdSchema,
|
|
18616
|
+
commandId: SessionCommandIdSchema,
|
|
18617
|
+
runtimeId: RuntimeIdSchema.nullable(),
|
|
18618
|
+
bridgeLeaseId: RuntimeBridgeLeaseIdSchema.nullable(),
|
|
18619
|
+
status: SessionTurnStatusSchema,
|
|
18620
|
+
failureScope: SessionTurnFailureScopeSchema.nullable(),
|
|
18621
|
+
lastOutputSeq: external_exports.number().int().positive().nullable(),
|
|
18622
|
+
acceptedAt: external_exports.string().datetime().nullable(),
|
|
18623
|
+
startedAt: external_exports.string().datetime().nullable(),
|
|
18624
|
+
lastProgressAt: external_exports.string().datetime().nullable(),
|
|
18625
|
+
completedAt: external_exports.string().datetime().nullable(),
|
|
18626
|
+
failedAt: external_exports.string().datetime().nullable(),
|
|
18627
|
+
staleAt: external_exports.string().datetime().nullable(),
|
|
18628
|
+
error: JsonValueSchema.nullable(),
|
|
18629
|
+
createdAt: external_exports.string().datetime(),
|
|
18630
|
+
updatedAt: external_exports.string().datetime()
|
|
18631
|
+
});
|
|
18632
|
+
}
|
|
18633
|
+
});
|
|
18634
|
+
|
|
18592
18635
|
// ../../packages/schemas/src/session-commands.ts
|
|
18593
18636
|
var SESSION_COMMAND_KINDS, SESSION_DISPATCH_COMMAND_KINDS, SESSION_PERSISTED_COMMAND_KINDS, SESSION_LIFECYCLE_COMMAND_KINDS, SESSION_COMMAND_STATUSES, SESSION_DISPATCH_COMMAND_STATUSES, SessionCommandKindSchema, SessionPersistedCommandKindSchema, SessionDispatchCommandKindSchema, RunLifecycleCommandKindSchema, SessionCommandStatusSchema, SessionDispatchCommandStatusSchema, SessionCommandSenderSchema, MESSAGE_DELIVERY_MODES, MessageDeliveryModeSchema, TRIGGER_INJECTION_MODALITIES, TriggerInjectionModalitySchema, RunMessageCommandPayloadSchema, RunAnswerCommandPayloadSchema, RunLifecycleCommandPayloadSchema, SessionCommandPayloadSchema, CreateRunMessageCommandRequestSchema, CreateRunAnswerCommandRequestSchema, CreateRunLifecycleCommandRequestSchema, CreateSessionCommandRequestSchema, RunResolutionPolicySchema, AgentAddressedCommandTargetSchema, SessionCommandRecordBaseSchema, RunStartCommandPayloadSchema, RunStartWithMessageCommandPayloadSchema, SessionPersistedCommandPayloadSchema, SessionCommandRecordSchema, SessionDispatchMessageCommandPayloadSchema, SessionDispatchAnswerCommandPayloadSchema, SessionDispatchStopCommandPayloadSchema, SessionDispatchCommandPayloadSchema, SessionDispatchCommandRecordBaseSchema, SessionDispatchCommandRecordSchema;
|
|
18594
18637
|
var init_session_commands = __esm({
|
|
@@ -18932,6 +18975,31 @@ var init_setup = __esm({
|
|
|
18932
18975
|
}
|
|
18933
18976
|
});
|
|
18934
18977
|
|
|
18978
|
+
// ../../packages/schemas/src/runtime-log.ts
|
|
18979
|
+
function parseRuntimeLogLevel(value) {
|
|
18980
|
+
const parsed = RuntimeLogLevelSchema.safeParse(value?.trim());
|
|
18981
|
+
return parsed.success ? parsed.data : DEFAULT_RUNTIME_LOG_LEVEL;
|
|
18982
|
+
}
|
|
18983
|
+
function runtimeLogLevelEnabled(configured, lineLevel) {
|
|
18984
|
+
return LEVEL_SEVERITY[lineLevel] >= LEVEL_SEVERITY[configured];
|
|
18985
|
+
}
|
|
18986
|
+
var RUNTIME_LOG_LEVELS, RuntimeLogLevelSchema, DEFAULT_RUNTIME_LOG_LEVEL, LEVEL_SEVERITY;
|
|
18987
|
+
var init_runtime_log = __esm({
|
|
18988
|
+
"../../packages/schemas/src/runtime-log.ts"() {
|
|
18989
|
+
"use strict";
|
|
18990
|
+
init_zod();
|
|
18991
|
+
RUNTIME_LOG_LEVELS = ["debug", "info", "warn", "error"];
|
|
18992
|
+
RuntimeLogLevelSchema = external_exports.enum(RUNTIME_LOG_LEVELS);
|
|
18993
|
+
DEFAULT_RUNTIME_LOG_LEVEL = "info";
|
|
18994
|
+
LEVEL_SEVERITY = {
|
|
18995
|
+
debug: 10,
|
|
18996
|
+
info: 20,
|
|
18997
|
+
warn: 30,
|
|
18998
|
+
error: 40
|
|
18999
|
+
};
|
|
19000
|
+
}
|
|
19001
|
+
});
|
|
19002
|
+
|
|
18935
19003
|
// ../../packages/schemas/src/runtimes.ts
|
|
18936
19004
|
var RuntimeRecordSchema, SessionCommandDispatchWorkflowInputSchema, SessionCommandDispatchSignalPayloadSchema, RealtimeRunCursorSchema;
|
|
18937
19005
|
var init_runtimes = __esm({
|
|
@@ -18996,9 +19064,11 @@ var init_src = __esm({
|
|
|
18996
19064
|
init_resources();
|
|
18997
19065
|
init_session_diagnostics();
|
|
18998
19066
|
init_session_introspection();
|
|
19067
|
+
init_session_turns();
|
|
18999
19068
|
init_secrets();
|
|
19000
19069
|
init_session_commands();
|
|
19001
19070
|
init_setup();
|
|
19071
|
+
init_runtime_log();
|
|
19002
19072
|
init_runtimes();
|
|
19003
19073
|
init_sessions();
|
|
19004
19074
|
init_agents();
|
|
@@ -21689,7 +21759,7 @@ var init_package = __esm({
|
|
|
21689
21759
|
"package.json"() {
|
|
21690
21760
|
package_default = {
|
|
21691
21761
|
name: "@autohq/cli",
|
|
21692
|
-
version: "0.1.
|
|
21762
|
+
version: "0.1.209",
|
|
21693
21763
|
license: "SEE LICENSE IN README.md",
|
|
21694
21764
|
publishConfig: {
|
|
21695
21765
|
access: "public"
|
|
@@ -31095,6 +31165,11 @@ var ConversationEntryStatusSchema2 = external_exports.enum([
|
|
|
31095
31165
|
"completed",
|
|
31096
31166
|
"failed"
|
|
31097
31167
|
]);
|
|
31168
|
+
var RuntimeTurnStatusSchema = external_exports.enum([
|
|
31169
|
+
"waiting_for_input",
|
|
31170
|
+
"completed",
|
|
31171
|
+
"failed"
|
|
31172
|
+
]);
|
|
31098
31173
|
var ConversationTextContentPartSchema2 = external_exports.object({
|
|
31099
31174
|
type: external_exports.literal("text"),
|
|
31100
31175
|
text: external_exports.string()
|
|
@@ -31248,7 +31323,7 @@ var RuntimeBridgeCommandDeliveryAcceptedSchema = external_exports.object({
|
|
|
31248
31323
|
result: external_exports.enum(["injected", "duplicate"]),
|
|
31249
31324
|
at: external_exports.string().datetime()
|
|
31250
31325
|
}).strict();
|
|
31251
|
-
var
|
|
31326
|
+
var RuntimeBridgeOutputEntryEnvelopeWireSchema = external_exports.object({
|
|
31252
31327
|
type: external_exports.literal("conversation.entry"),
|
|
31253
31328
|
sessionId: SessionIdSchema2,
|
|
31254
31329
|
runtimeId: RuntimeIdSchema2,
|
|
@@ -31261,8 +31336,18 @@ var RuntimeBridgeOutputEntryEnvelopeSchema = external_exports.object({
|
|
|
31261
31336
|
content: ConversationEntryContentSchema2,
|
|
31262
31337
|
createdAt: external_exports.string().datetime(),
|
|
31263
31338
|
completedAt: external_exports.string().datetime().nullable(),
|
|
31264
|
-
|
|
31339
|
+
turnStatus: RuntimeTurnStatusSchema.optional()
|
|
31265
31340
|
}).strict();
|
|
31341
|
+
var LegacyRuntimeBridgeOutputEntryEnvelopeSchema = RuntimeBridgeOutputEntryEnvelopeWireSchema.omit({ turnStatus: true }).extend({
|
|
31342
|
+
sessionStatusAfter: external_exports.enum(["awaiting", "failed"])
|
|
31343
|
+
}).strict().transform(({ sessionStatusAfter, ...entry }) => ({
|
|
31344
|
+
...entry,
|
|
31345
|
+
turnStatus: legacyRuntimeTurnStatus(entry, sessionStatusAfter)
|
|
31346
|
+
}));
|
|
31347
|
+
var RuntimeBridgeOutputEntryEnvelopeSchema = external_exports.union([
|
|
31348
|
+
RuntimeBridgeOutputEntryEnvelopeWireSchema,
|
|
31349
|
+
LegacyRuntimeBridgeOutputEntryEnvelopeSchema
|
|
31350
|
+
]);
|
|
31266
31351
|
var RuntimeBridgeOutputDeltaEnvelopeSchema = external_exports.object({
|
|
31267
31352
|
type: external_exports.literal("conversation.delta"),
|
|
31268
31353
|
sessionId: SessionIdSchema2,
|
|
@@ -31276,10 +31361,16 @@ var RuntimeBridgeOutputDeltaEnvelopeSchema = external_exports.object({
|
|
|
31276
31361
|
delta: ConversationTextDeltaSchema2,
|
|
31277
31362
|
createdAt: external_exports.string().datetime()
|
|
31278
31363
|
}).strict();
|
|
31279
|
-
var RuntimeBridgeOutputEnvelopeSchema = external_exports.
|
|
31364
|
+
var RuntimeBridgeOutputEnvelopeSchema = external_exports.union([
|
|
31280
31365
|
RuntimeBridgeOutputEntryEnvelopeSchema,
|
|
31281
31366
|
RuntimeBridgeOutputDeltaEnvelopeSchema
|
|
31282
31367
|
]);
|
|
31368
|
+
function legacyRuntimeTurnStatus(entry, sessionStatusAfter) {
|
|
31369
|
+
if (sessionStatusAfter === "failed" || entry.status === "failed") {
|
|
31370
|
+
return "failed";
|
|
31371
|
+
}
|
|
31372
|
+
return entry.kind === "question" ? "waiting_for_input" : "completed";
|
|
31373
|
+
}
|
|
31283
31374
|
var RuntimeBridgeOutputAckSchema = external_exports.object({
|
|
31284
31375
|
type: external_exports.literal("runtime.output.ack"),
|
|
31285
31376
|
sessionId: SessionIdSchema2,
|
|
@@ -31746,7 +31837,7 @@ function buildOutputEnvelope(context, outputSeq, projection) {
|
|
|
31746
31837
|
content: entry.content,
|
|
31747
31838
|
createdAt,
|
|
31748
31839
|
completedAt: entry.status === "in_progress" ? null : createdAt,
|
|
31749
|
-
...entry.
|
|
31840
|
+
...entry.turnStatus ? { turnStatus: entry.turnStatus } : {}
|
|
31750
31841
|
});
|
|
31751
31842
|
}
|
|
31752
31843
|
function isSuccessfulOutputAck(ack) {
|
|
@@ -31780,9 +31871,9 @@ var ClaudeCodeProjector = class {
|
|
|
31780
31871
|
const outputs = parsed.projections.map(
|
|
31781
31872
|
(entry) => ({
|
|
31782
31873
|
type: "entry",
|
|
31783
|
-
// A question
|
|
31784
|
-
// for an operator answer
|
|
31785
|
-
entry: entry.kind === "question" ? { ...entry,
|
|
31874
|
+
// A question means the delivered turn is parked on AskUserQuestion
|
|
31875
|
+
// waiting for an operator answer.
|
|
31876
|
+
entry: entry.kind === "question" ? { ...entry, turnStatus: "waiting_for_input" } : entry
|
|
31786
31877
|
})
|
|
31787
31878
|
);
|
|
31788
31879
|
if (parsed.result) {
|
|
@@ -31792,14 +31883,13 @@ var ClaudeCodeProjector = class {
|
|
|
31792
31883
|
}
|
|
31793
31884
|
};
|
|
31794
31885
|
function projectClaudeCodeResult(result) {
|
|
31795
|
-
const failedButRecoverable = isRecoverableToolUseDiagnostic(result);
|
|
31796
31886
|
return {
|
|
31797
31887
|
type: "entry",
|
|
31798
31888
|
entry: {
|
|
31799
31889
|
role: "system",
|
|
31800
31890
|
kind: "status",
|
|
31801
31891
|
status: result.isError ? "failed" : "completed",
|
|
31802
|
-
|
|
31892
|
+
turnStatus: result.isError ? "failed" : "completed",
|
|
31803
31893
|
content: {
|
|
31804
31894
|
parts: [
|
|
31805
31895
|
{
|
|
@@ -31811,13 +31901,6 @@ function projectClaudeCodeResult(result) {
|
|
|
31811
31901
|
}
|
|
31812
31902
|
};
|
|
31813
31903
|
}
|
|
31814
|
-
function isRecoverableToolUseDiagnostic(result) {
|
|
31815
|
-
if (!result.isError) {
|
|
31816
|
-
return false;
|
|
31817
|
-
}
|
|
31818
|
-
const message = result.errorMessage ?? "";
|
|
31819
|
-
return message.startsWith("[ede_diagnostic]") && message.includes("stop_reason=tool_use");
|
|
31820
|
-
}
|
|
31821
31904
|
function anthropicMessageIdFromStreamStart(message) {
|
|
31822
31905
|
const event = message.event;
|
|
31823
31906
|
if (event.type !== "message_start") {
|
|
@@ -32982,13 +33065,62 @@ function deliveryMode(delivery) {
|
|
|
32982
33065
|
return "interrupt";
|
|
32983
33066
|
}
|
|
32984
33067
|
|
|
33068
|
+
// src/commands/agent-bridge/runtime-log.ts
|
|
33069
|
+
init_src();
|
|
33070
|
+
var RUNTIME_LOG_COMPONENT = "runtime-cli";
|
|
33071
|
+
function createRuntimeLogger(env = process.env) {
|
|
33072
|
+
const level = parseRuntimeLogLevel(env.AUTO_RUNTIME_LOG_LEVEL);
|
|
33073
|
+
const emit = (lineLevel) => {
|
|
33074
|
+
return (message, context) => {
|
|
33075
|
+
if (!runtimeLogLevelEnabled(level, lineLevel)) {
|
|
33076
|
+
return;
|
|
33077
|
+
}
|
|
33078
|
+
writeRuntimeLogLine(lineLevel, message, context);
|
|
33079
|
+
};
|
|
33080
|
+
};
|
|
33081
|
+
return {
|
|
33082
|
+
level,
|
|
33083
|
+
debug: emit("debug"),
|
|
33084
|
+
info: emit("info"),
|
|
33085
|
+
warn: emit("warn"),
|
|
33086
|
+
error: emit("error")
|
|
33087
|
+
};
|
|
33088
|
+
}
|
|
33089
|
+
function writeRuntimeLogLine(level, message, context) {
|
|
33090
|
+
const payload = {
|
|
33091
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
33092
|
+
level,
|
|
33093
|
+
component: RUNTIME_LOG_COMPONENT,
|
|
33094
|
+
message,
|
|
33095
|
+
...context ?? {}
|
|
33096
|
+
};
|
|
33097
|
+
process.stderr.write(`${JSON.stringify(payload, replaceErrors)}
|
|
33098
|
+
`);
|
|
33099
|
+
}
|
|
33100
|
+
function replaceErrors(_key, value) {
|
|
33101
|
+
if (value instanceof Error) {
|
|
33102
|
+
return { name: value.name, message: value.message, stack: value.stack };
|
|
33103
|
+
}
|
|
33104
|
+
return value;
|
|
33105
|
+
}
|
|
33106
|
+
|
|
32985
33107
|
// src/commands/agent-bridge/entrypoint.ts
|
|
32986
33108
|
async function runAgentBridgeProcess(input) {
|
|
32987
33109
|
const runAgentBridge = input.runAgentBridge ?? runAgentBridgeClaudeCode;
|
|
32988
|
-
|
|
32989
|
-
|
|
32990
|
-
|
|
33110
|
+
const log = createRuntimeLogger(input.env);
|
|
33111
|
+
log.info("agent bridge process starting", {
|
|
33112
|
+
bridge_url_host: bridgeUrlHost(input.env.AUTO_BRIDGE_URL),
|
|
33113
|
+
log_level: log.level
|
|
32991
33114
|
});
|
|
33115
|
+
try {
|
|
33116
|
+
await runAgentBridge({
|
|
33117
|
+
...agentBridgeOptionsFromEnv(input),
|
|
33118
|
+
onBootstrap: createGitCredentialRelayStarter(input.writeOutput, log)
|
|
33119
|
+
});
|
|
33120
|
+
} catch (error51) {
|
|
33121
|
+
log.error("agent bridge process failed", { error: error51 });
|
|
33122
|
+
throw error51;
|
|
33123
|
+
}
|
|
32992
33124
|
}
|
|
32993
33125
|
function agentBridgeOptionsFromEnv(input) {
|
|
32994
33126
|
return {
|
|
@@ -32997,7 +33129,7 @@ function agentBridgeOptionsFromEnv(input) {
|
|
|
32997
33129
|
writeOutput: input.writeOutput
|
|
32998
33130
|
};
|
|
32999
33131
|
}
|
|
33000
|
-
function createGitCredentialRelayStarter(writeOutput) {
|
|
33132
|
+
function createGitCredentialRelayStarter(writeOutput, log) {
|
|
33001
33133
|
let relay;
|
|
33002
33134
|
let startup;
|
|
33003
33135
|
return async (bootstrap) => {
|
|
@@ -33017,12 +33149,14 @@ function createGitCredentialRelayStarter(writeOutput) {
|
|
|
33017
33149
|
startup = startGitCredentialRelay(gitCredentials).then((started) => {
|
|
33018
33150
|
relay = started;
|
|
33019
33151
|
writeOutput?.(`agent_bridge_git_credential_relay port=${started.port}`);
|
|
33152
|
+
log?.info("git credential relay started", { port: started.port });
|
|
33020
33153
|
return started;
|
|
33021
33154
|
}).catch((error51) => {
|
|
33022
33155
|
startup = void 0;
|
|
33023
33156
|
writeOutput?.(
|
|
33024
33157
|
`agent_bridge_git_credential_relay_failed error=${error51 instanceof Error ? error51.message : String(error51)}`
|
|
33025
33158
|
);
|
|
33159
|
+
log?.warn("git credential relay failed to start", { error: error51 });
|
|
33026
33160
|
return void 0;
|
|
33027
33161
|
});
|
|
33028
33162
|
await startup;
|
|
@@ -33035,6 +33169,16 @@ function requiredEnv(env, key) {
|
|
|
33035
33169
|
}
|
|
33036
33170
|
return value;
|
|
33037
33171
|
}
|
|
33172
|
+
function bridgeUrlHost(bridgeUrl) {
|
|
33173
|
+
if (!bridgeUrl) {
|
|
33174
|
+
return void 0;
|
|
33175
|
+
}
|
|
33176
|
+
try {
|
|
33177
|
+
return new URL(bridgeUrl).host;
|
|
33178
|
+
} catch {
|
|
33179
|
+
return void 0;
|
|
33180
|
+
}
|
|
33181
|
+
}
|
|
33038
33182
|
|
|
33039
33183
|
// src/commands/agent-bridge/commands.ts
|
|
33040
33184
|
function registerAgentBridgeCommands(program, context) {
|