@autohq/cli 0.1.551 → 0.1.552
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 +67 -10
- package/dist/index.js +67 -10
- package/package.json +1 -1
package/dist/agent-bridge.js
CHANGED
|
@@ -30870,7 +30870,7 @@ Object.assign(lookup, {
|
|
|
30870
30870
|
// package.json
|
|
30871
30871
|
var package_default = {
|
|
30872
30872
|
name: "@autohq/cli",
|
|
30873
|
-
version: "0.1.
|
|
30873
|
+
version: "0.1.552",
|
|
30874
30874
|
license: "SEE LICENSE IN README.md",
|
|
30875
30875
|
publishConfig: {
|
|
30876
30876
|
access: "public"
|
|
@@ -71964,7 +71964,9 @@ var AgentBridgeOutputBuffer = class {
|
|
|
71964
71964
|
uiDeltaFlushTimer = null;
|
|
71965
71965
|
activeUiMessageAssembler = null;
|
|
71966
71966
|
uiMessagePartTracker = new UiMessagePartTracker();
|
|
71967
|
+
discardOnFailureOutputSeqs = /* @__PURE__ */ new Set();
|
|
71967
71968
|
drainBlocked = false;
|
|
71969
|
+
drainBlockedError = null;
|
|
71968
71970
|
drainPromise = null;
|
|
71969
71971
|
// Sequence of the most recent liveness beat, for the skip-while-pending
|
|
71970
71972
|
// gate in emitLivenessBeat.
|
|
@@ -71975,7 +71977,7 @@ var AgentBridgeOutputBuffer = class {
|
|
|
71975
71977
|
// ---------------------------------------------------------------------------
|
|
71976
71978
|
// Public API
|
|
71977
71979
|
// ---------------------------------------------------------------------------
|
|
71978
|
-
async emitProjection(context, projection) {
|
|
71980
|
+
async emitProjection(context, projection, options = {}) {
|
|
71979
71981
|
if (projection.type === "ui_message_chunk") {
|
|
71980
71982
|
const coalescible = coalescibleUiDeltaChunk(projection);
|
|
71981
71983
|
if (coalescible) {
|
|
@@ -71992,7 +71994,7 @@ var AgentBridgeOutputBuffer = class {
|
|
|
71992
71994
|
}
|
|
71993
71995
|
await this.flushPendingUiDelta();
|
|
71994
71996
|
await this.flushPendingDelta();
|
|
71995
|
-
await this.enqueueProjectionAndDrain(context, projection);
|
|
71997
|
+
await this.enqueueProjectionAndDrain(context, projection, options);
|
|
71996
71998
|
}
|
|
71997
71999
|
async replayPendingOutputs() {
|
|
71998
72000
|
await this.materializePendingUiDelta();
|
|
@@ -72131,15 +72133,22 @@ var AgentBridgeOutputBuffer = class {
|
|
|
72131
72133
|
// Transport emit
|
|
72132
72134
|
// ---------------------------------------------------------------------------
|
|
72133
72135
|
async drainPendingOutputs(options = {}) {
|
|
72136
|
+
let previousDrainFailed = false;
|
|
72134
72137
|
if (this.drainPromise && options.force) {
|
|
72135
72138
|
try {
|
|
72136
72139
|
await this.drainPromise;
|
|
72137
72140
|
} catch {
|
|
72141
|
+
previousDrainFailed = true;
|
|
72138
72142
|
}
|
|
72139
72143
|
this.drainBlocked = false;
|
|
72144
|
+
this.drainBlockedError = null;
|
|
72145
|
+
}
|
|
72146
|
+
if (previousDrainFailed) {
|
|
72147
|
+
this.discardFailureSensitiveOutputs();
|
|
72140
72148
|
}
|
|
72141
72149
|
if (options.force) {
|
|
72142
72150
|
this.drainBlocked = false;
|
|
72151
|
+
this.drainBlockedError = null;
|
|
72143
72152
|
this.input.runtimeLogger?.info(
|
|
72144
72153
|
"agent_bridge_output_buffer_replay_started",
|
|
72145
72154
|
{ pending_count: this.pendingOutputs.size }
|
|
@@ -72150,6 +72159,9 @@ var AgentBridgeOutputBuffer = class {
|
|
|
72150
72159
|
"agent_bridge_output_buffer_drain_blocked",
|
|
72151
72160
|
{ pending_count: this.pendingOutputs.size }
|
|
72152
72161
|
);
|
|
72162
|
+
if (options.failIfBlocked) {
|
|
72163
|
+
throw outputDrainBlockedError(this.drainBlockedError);
|
|
72164
|
+
}
|
|
72153
72165
|
return;
|
|
72154
72166
|
}
|
|
72155
72167
|
this.drainPromise ??= (async () => {
|
|
@@ -72167,6 +72179,7 @@ var AgentBridgeOutputBuffer = class {
|
|
|
72167
72179
|
}
|
|
72168
72180
|
})().catch((error51) => {
|
|
72169
72181
|
this.drainBlocked = true;
|
|
72182
|
+
this.drainBlockedError = error51;
|
|
72170
72183
|
throw error51;
|
|
72171
72184
|
}).finally(() => {
|
|
72172
72185
|
this.drainPromise = null;
|
|
@@ -72363,6 +72376,7 @@ var AgentBridgeOutputBuffer = class {
|
|
|
72363
72376
|
const ack = await this.input.emitOutput(output);
|
|
72364
72377
|
if (isSuccessfulOutputAck(ack)) {
|
|
72365
72378
|
this.pendingOutputs.delete(output.outputSeq);
|
|
72379
|
+
this.discardOnFailureOutputSeqs.delete(output.outputSeq);
|
|
72366
72380
|
this.input.runtimeLogger?.info(
|
|
72367
72381
|
"agent_bridge_output_buffer_emit_ready",
|
|
72368
72382
|
this.outputLogContext(output, {
|
|
@@ -72390,12 +72404,33 @@ var AgentBridgeOutputBuffer = class {
|
|
|
72390
72404
|
(left, right) => left.outputSeq - right.outputSeq
|
|
72391
72405
|
)[0] ?? null;
|
|
72392
72406
|
}
|
|
72393
|
-
async enqueueProjectionAndDrain(context, projection) {
|
|
72407
|
+
async enqueueProjectionAndDrain(context, projection, options = {}) {
|
|
72394
72408
|
this.outputSeq += 1;
|
|
72395
|
-
this.
|
|
72396
|
-
|
|
72397
|
-
)
|
|
72398
|
-
|
|
72409
|
+
const outputSeq = this.outputSeq;
|
|
72410
|
+
this.enqueueOutput(buildOutputEnvelope(context, outputSeq, projection));
|
|
72411
|
+
if (options.discardOnFailure) {
|
|
72412
|
+
this.discardOnFailureOutputSeqs.add(outputSeq);
|
|
72413
|
+
}
|
|
72414
|
+
try {
|
|
72415
|
+
await this.drainPendingOutputs({
|
|
72416
|
+
failIfBlocked: options.requireDrain
|
|
72417
|
+
});
|
|
72418
|
+
this.discardOnFailureOutputSeqs.delete(outputSeq);
|
|
72419
|
+
} catch (error51) {
|
|
72420
|
+
if (options.discardOnFailure) {
|
|
72421
|
+
this.pendingOutputs.delete(outputSeq);
|
|
72422
|
+
this.discardOnFailureOutputSeqs.delete(outputSeq);
|
|
72423
|
+
this.ackExhaustsBySeq.delete(outputSeq);
|
|
72424
|
+
}
|
|
72425
|
+
throw error51;
|
|
72426
|
+
}
|
|
72427
|
+
}
|
|
72428
|
+
discardFailureSensitiveOutputs() {
|
|
72429
|
+
for (const outputSeq of this.discardOnFailureOutputSeqs) {
|
|
72430
|
+
this.pendingOutputs.delete(outputSeq);
|
|
72431
|
+
this.discardOnFailureOutputSeqs.delete(outputSeq);
|
|
72432
|
+
this.ackExhaustsBySeq.delete(outputSeq);
|
|
72433
|
+
}
|
|
72399
72434
|
}
|
|
72400
72435
|
enqueueOutput(output) {
|
|
72401
72436
|
const sanitized = isLiveOnlyRuntimeOutputEnvelope(output) ? output : sanitizeUnstorableStrings(output);
|
|
@@ -72821,6 +72856,10 @@ function buildUiMessageCompletedOutputEnvelope(input) {
|
|
|
72821
72856
|
function isSuccessfulOutputAck(ack) {
|
|
72822
72857
|
return ack.status === "persisted" || ack.status === "duplicate" || ack.status === "published";
|
|
72823
72858
|
}
|
|
72859
|
+
function outputDrainBlockedError(cause) {
|
|
72860
|
+
const detail = cause instanceof Error ? `: ${cause.message}` : "";
|
|
72861
|
+
return new Error(`Bridge output drain is blocked${detail}`);
|
|
72862
|
+
}
|
|
72824
72863
|
function now2() {
|
|
72825
72864
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
72826
72865
|
}
|
|
@@ -75178,7 +75217,7 @@ var ClaudeCodeCommandHandler = class {
|
|
|
75178
75217
|
"agent_bridge_claude_command_user_entry_emit_started",
|
|
75179
75218
|
commandLogContext(delivery, { socket_id: socketId })
|
|
75180
75219
|
);
|
|
75181
|
-
await this.
|
|
75220
|
+
await this.emitRequiredBridgeOutput(activeContext, {
|
|
75182
75221
|
type: "entry",
|
|
75183
75222
|
entry: {
|
|
75184
75223
|
messageId: delivery.commandId,
|
|
@@ -75279,7 +75318,7 @@ var ClaudeCodeCommandHandler = class {
|
|
|
75279
75318
|
return;
|
|
75280
75319
|
}
|
|
75281
75320
|
const message = answerFallbackMessage(answer);
|
|
75282
|
-
await this.
|
|
75321
|
+
await this.emitRequiredBridgeOutput(activeContext, {
|
|
75283
75322
|
type: "entry",
|
|
75284
75323
|
entry: {
|
|
75285
75324
|
messageId: delivery.commandId,
|
|
@@ -75359,6 +75398,24 @@ var ClaudeCodeCommandHandler = class {
|
|
|
75359
75398
|
);
|
|
75360
75399
|
}
|
|
75361
75400
|
}
|
|
75401
|
+
async emitRequiredBridgeOutput(activeContext, projection) {
|
|
75402
|
+
const options = {
|
|
75403
|
+
discardOnFailure: true,
|
|
75404
|
+
requireDrain: true
|
|
75405
|
+
};
|
|
75406
|
+
try {
|
|
75407
|
+
await this.outputBuffer.emitProjection(
|
|
75408
|
+
activeContext,
|
|
75409
|
+
projection,
|
|
75410
|
+
options
|
|
75411
|
+
);
|
|
75412
|
+
} catch (error51) {
|
|
75413
|
+
this.input.writeOutput?.(
|
|
75414
|
+
`agent_bridge_output_emit_failed error=${error51 instanceof Error ? error51.message : String(error51)}`
|
|
75415
|
+
);
|
|
75416
|
+
throw error51;
|
|
75417
|
+
}
|
|
75418
|
+
}
|
|
75362
75419
|
async handleAgentMessage(message, meta3) {
|
|
75363
75420
|
const activeContext = this.context;
|
|
75364
75421
|
if (!activeContext) {
|
package/dist/index.js
CHANGED
|
@@ -82927,7 +82927,7 @@ var init_package = __esm({
|
|
|
82927
82927
|
"package.json"() {
|
|
82928
82928
|
package_default = {
|
|
82929
82929
|
name: "@autohq/cli",
|
|
82930
|
-
version: "0.1.
|
|
82930
|
+
version: "0.1.552",
|
|
82931
82931
|
license: "SEE LICENSE IN README.md",
|
|
82932
82932
|
publishConfig: {
|
|
82933
82933
|
access: "public"
|
|
@@ -96105,7 +96105,9 @@ var AgentBridgeOutputBuffer = class {
|
|
|
96105
96105
|
uiDeltaFlushTimer = null;
|
|
96106
96106
|
activeUiMessageAssembler = null;
|
|
96107
96107
|
uiMessagePartTracker = new UiMessagePartTracker();
|
|
96108
|
+
discardOnFailureOutputSeqs = /* @__PURE__ */ new Set();
|
|
96108
96109
|
drainBlocked = false;
|
|
96110
|
+
drainBlockedError = null;
|
|
96109
96111
|
drainPromise = null;
|
|
96110
96112
|
// Sequence of the most recent liveness beat, for the skip-while-pending
|
|
96111
96113
|
// gate in emitLivenessBeat.
|
|
@@ -96116,7 +96118,7 @@ var AgentBridgeOutputBuffer = class {
|
|
|
96116
96118
|
// ---------------------------------------------------------------------------
|
|
96117
96119
|
// Public API
|
|
96118
96120
|
// ---------------------------------------------------------------------------
|
|
96119
|
-
async emitProjection(context, projection) {
|
|
96121
|
+
async emitProjection(context, projection, options = {}) {
|
|
96120
96122
|
if (projection.type === "ui_message_chunk") {
|
|
96121
96123
|
const coalescible = coalescibleUiDeltaChunk(projection);
|
|
96122
96124
|
if (coalescible) {
|
|
@@ -96133,7 +96135,7 @@ var AgentBridgeOutputBuffer = class {
|
|
|
96133
96135
|
}
|
|
96134
96136
|
await this.flushPendingUiDelta();
|
|
96135
96137
|
await this.flushPendingDelta();
|
|
96136
|
-
await this.enqueueProjectionAndDrain(context, projection);
|
|
96138
|
+
await this.enqueueProjectionAndDrain(context, projection, options);
|
|
96137
96139
|
}
|
|
96138
96140
|
async replayPendingOutputs() {
|
|
96139
96141
|
await this.materializePendingUiDelta();
|
|
@@ -96272,15 +96274,22 @@ var AgentBridgeOutputBuffer = class {
|
|
|
96272
96274
|
// Transport emit
|
|
96273
96275
|
// ---------------------------------------------------------------------------
|
|
96274
96276
|
async drainPendingOutputs(options = {}) {
|
|
96277
|
+
let previousDrainFailed = false;
|
|
96275
96278
|
if (this.drainPromise && options.force) {
|
|
96276
96279
|
try {
|
|
96277
96280
|
await this.drainPromise;
|
|
96278
96281
|
} catch {
|
|
96282
|
+
previousDrainFailed = true;
|
|
96279
96283
|
}
|
|
96280
96284
|
this.drainBlocked = false;
|
|
96285
|
+
this.drainBlockedError = null;
|
|
96286
|
+
}
|
|
96287
|
+
if (previousDrainFailed) {
|
|
96288
|
+
this.discardFailureSensitiveOutputs();
|
|
96281
96289
|
}
|
|
96282
96290
|
if (options.force) {
|
|
96283
96291
|
this.drainBlocked = false;
|
|
96292
|
+
this.drainBlockedError = null;
|
|
96284
96293
|
this.input.runtimeLogger?.info(
|
|
96285
96294
|
"agent_bridge_output_buffer_replay_started",
|
|
96286
96295
|
{ pending_count: this.pendingOutputs.size }
|
|
@@ -96291,6 +96300,9 @@ var AgentBridgeOutputBuffer = class {
|
|
|
96291
96300
|
"agent_bridge_output_buffer_drain_blocked",
|
|
96292
96301
|
{ pending_count: this.pendingOutputs.size }
|
|
96293
96302
|
);
|
|
96303
|
+
if (options.failIfBlocked) {
|
|
96304
|
+
throw outputDrainBlockedError(this.drainBlockedError);
|
|
96305
|
+
}
|
|
96294
96306
|
return;
|
|
96295
96307
|
}
|
|
96296
96308
|
this.drainPromise ??= (async () => {
|
|
@@ -96308,6 +96320,7 @@ var AgentBridgeOutputBuffer = class {
|
|
|
96308
96320
|
}
|
|
96309
96321
|
})().catch((error51) => {
|
|
96310
96322
|
this.drainBlocked = true;
|
|
96323
|
+
this.drainBlockedError = error51;
|
|
96311
96324
|
throw error51;
|
|
96312
96325
|
}).finally(() => {
|
|
96313
96326
|
this.drainPromise = null;
|
|
@@ -96504,6 +96517,7 @@ var AgentBridgeOutputBuffer = class {
|
|
|
96504
96517
|
const ack = await this.input.emitOutput(output);
|
|
96505
96518
|
if (isSuccessfulOutputAck(ack)) {
|
|
96506
96519
|
this.pendingOutputs.delete(output.outputSeq);
|
|
96520
|
+
this.discardOnFailureOutputSeqs.delete(output.outputSeq);
|
|
96507
96521
|
this.input.runtimeLogger?.info(
|
|
96508
96522
|
"agent_bridge_output_buffer_emit_ready",
|
|
96509
96523
|
this.outputLogContext(output, {
|
|
@@ -96531,12 +96545,33 @@ var AgentBridgeOutputBuffer = class {
|
|
|
96531
96545
|
(left, right) => left.outputSeq - right.outputSeq
|
|
96532
96546
|
)[0] ?? null;
|
|
96533
96547
|
}
|
|
96534
|
-
async enqueueProjectionAndDrain(context, projection) {
|
|
96548
|
+
async enqueueProjectionAndDrain(context, projection, options = {}) {
|
|
96535
96549
|
this.outputSeq += 1;
|
|
96536
|
-
this.
|
|
96537
|
-
|
|
96538
|
-
)
|
|
96539
|
-
|
|
96550
|
+
const outputSeq = this.outputSeq;
|
|
96551
|
+
this.enqueueOutput(buildOutputEnvelope(context, outputSeq, projection));
|
|
96552
|
+
if (options.discardOnFailure) {
|
|
96553
|
+
this.discardOnFailureOutputSeqs.add(outputSeq);
|
|
96554
|
+
}
|
|
96555
|
+
try {
|
|
96556
|
+
await this.drainPendingOutputs({
|
|
96557
|
+
failIfBlocked: options.requireDrain
|
|
96558
|
+
});
|
|
96559
|
+
this.discardOnFailureOutputSeqs.delete(outputSeq);
|
|
96560
|
+
} catch (error51) {
|
|
96561
|
+
if (options.discardOnFailure) {
|
|
96562
|
+
this.pendingOutputs.delete(outputSeq);
|
|
96563
|
+
this.discardOnFailureOutputSeqs.delete(outputSeq);
|
|
96564
|
+
this.ackExhaustsBySeq.delete(outputSeq);
|
|
96565
|
+
}
|
|
96566
|
+
throw error51;
|
|
96567
|
+
}
|
|
96568
|
+
}
|
|
96569
|
+
discardFailureSensitiveOutputs() {
|
|
96570
|
+
for (const outputSeq of this.discardOnFailureOutputSeqs) {
|
|
96571
|
+
this.pendingOutputs.delete(outputSeq);
|
|
96572
|
+
this.discardOnFailureOutputSeqs.delete(outputSeq);
|
|
96573
|
+
this.ackExhaustsBySeq.delete(outputSeq);
|
|
96574
|
+
}
|
|
96540
96575
|
}
|
|
96541
96576
|
enqueueOutput(output) {
|
|
96542
96577
|
const sanitized = isLiveOnlyRuntimeOutputEnvelope(output) ? output : sanitizeUnstorableStrings(output);
|
|
@@ -96962,6 +96997,10 @@ function buildUiMessageCompletedOutputEnvelope(input) {
|
|
|
96962
96997
|
function isSuccessfulOutputAck(ack) {
|
|
96963
96998
|
return ack.status === "persisted" || ack.status === "duplicate" || ack.status === "published";
|
|
96964
96999
|
}
|
|
97000
|
+
function outputDrainBlockedError(cause) {
|
|
97001
|
+
const detail = cause instanceof Error ? `: ${cause.message}` : "";
|
|
97002
|
+
return new Error(`Bridge output drain is blocked${detail}`);
|
|
97003
|
+
}
|
|
96965
97004
|
function now2() {
|
|
96966
97005
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
96967
97006
|
}
|
|
@@ -99326,7 +99365,7 @@ var ClaudeCodeCommandHandler = class {
|
|
|
99326
99365
|
"agent_bridge_claude_command_user_entry_emit_started",
|
|
99327
99366
|
commandLogContext(delivery, { socket_id: socketId })
|
|
99328
99367
|
);
|
|
99329
|
-
await this.
|
|
99368
|
+
await this.emitRequiredBridgeOutput(activeContext, {
|
|
99330
99369
|
type: "entry",
|
|
99331
99370
|
entry: {
|
|
99332
99371
|
messageId: delivery.commandId,
|
|
@@ -99427,7 +99466,7 @@ var ClaudeCodeCommandHandler = class {
|
|
|
99427
99466
|
return;
|
|
99428
99467
|
}
|
|
99429
99468
|
const message = answerFallbackMessage(answer);
|
|
99430
|
-
await this.
|
|
99469
|
+
await this.emitRequiredBridgeOutput(activeContext, {
|
|
99431
99470
|
type: "entry",
|
|
99432
99471
|
entry: {
|
|
99433
99472
|
messageId: delivery.commandId,
|
|
@@ -99507,6 +99546,24 @@ var ClaudeCodeCommandHandler = class {
|
|
|
99507
99546
|
);
|
|
99508
99547
|
}
|
|
99509
99548
|
}
|
|
99549
|
+
async emitRequiredBridgeOutput(activeContext, projection) {
|
|
99550
|
+
const options = {
|
|
99551
|
+
discardOnFailure: true,
|
|
99552
|
+
requireDrain: true
|
|
99553
|
+
};
|
|
99554
|
+
try {
|
|
99555
|
+
await this.outputBuffer.emitProjection(
|
|
99556
|
+
activeContext,
|
|
99557
|
+
projection,
|
|
99558
|
+
options
|
|
99559
|
+
);
|
|
99560
|
+
} catch (error51) {
|
|
99561
|
+
this.input.writeOutput?.(
|
|
99562
|
+
`agent_bridge_output_emit_failed error=${error51 instanceof Error ? error51.message : String(error51)}`
|
|
99563
|
+
);
|
|
99564
|
+
throw error51;
|
|
99565
|
+
}
|
|
99566
|
+
}
|
|
99510
99567
|
async handleAgentMessage(message, meta3) {
|
|
99511
99568
|
const activeContext = this.context;
|
|
99512
99569
|
if (!activeContext) {
|