@autohq/cli 0.1.565 → 0.1.566
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 +99 -8
- package/dist/index.js +117 -9
- package/package.json +1 -1
package/dist/agent-bridge.js
CHANGED
|
@@ -27222,13 +27222,23 @@ var RuntimeBridgeOutputLivenessEnvelopeSchema = external_exports.object({
|
|
|
27222
27222
|
intervalMs: external_exports.number().int().positive(),
|
|
27223
27223
|
createdAt: external_exports.string().datetime()
|
|
27224
27224
|
});
|
|
27225
|
+
var RuntimeBridgeOutputUsageTurnEnvelopeSchema = external_exports.object({
|
|
27226
|
+
type: external_exports.literal("runtime.usage_turn"),
|
|
27227
|
+
sessionId: SessionIdSchema,
|
|
27228
|
+
runtimeId: RuntimeIdSchema,
|
|
27229
|
+
bridgeLeaseId: RuntimeBridgeLeaseIdSchema,
|
|
27230
|
+
outputSeq: external_exports.number().int().positive(),
|
|
27231
|
+
turnId: SessionCommandIdSchema.nullable(),
|
|
27232
|
+
createdAt: external_exports.string().datetime()
|
|
27233
|
+
});
|
|
27225
27234
|
var RuntimeBridgeOutputEnvelopeSchema = external_exports.union([
|
|
27226
27235
|
RuntimeBridgeOutputEntryEnvelopeSchema,
|
|
27227
27236
|
RuntimeBridgeOutputDeltaEnvelopeSchema,
|
|
27228
27237
|
RuntimeBridgeOutputUiMessageChunkEnvelopeSchema,
|
|
27229
27238
|
RuntimeBridgeOutputUiMessagePartEnvelopeSchema,
|
|
27230
27239
|
RuntimeBridgeOutputUiMessageCompletedEnvelopeSchema,
|
|
27231
|
-
RuntimeBridgeOutputLivenessEnvelopeSchema
|
|
27240
|
+
RuntimeBridgeOutputLivenessEnvelopeSchema,
|
|
27241
|
+
RuntimeBridgeOutputUsageTurnEnvelopeSchema
|
|
27232
27242
|
]);
|
|
27233
27243
|
function isLiveOnlyRuntimeOutputEnvelope(envelope) {
|
|
27234
27244
|
return envelope.type === "ui.message.chunk" || envelope.type === "conversation.delta";
|
|
@@ -30870,7 +30880,7 @@ Object.assign(lookup, {
|
|
|
30870
30880
|
// package.json
|
|
30871
30881
|
var package_default = {
|
|
30872
30882
|
name: "@autohq/cli",
|
|
30873
|
-
version: "0.1.
|
|
30883
|
+
version: "0.1.566",
|
|
30874
30884
|
license: "SEE LICENSE IN README.md",
|
|
30875
30885
|
publishConfig: {
|
|
30876
30886
|
access: "public"
|
|
@@ -38693,6 +38703,10 @@ var UsageEventSchema = external_exports.object({
|
|
|
38693
38703
|
organizationId: OrganizationIdSchema,
|
|
38694
38704
|
projectId: ProjectIdSchema.nullable(),
|
|
38695
38705
|
sessionId: SessionIdSchema2,
|
|
38706
|
+
// Authoritative platform turn association. Null/absent is an explicit
|
|
38707
|
+
// compatibility state for legacy writers and usage outside a model turn;
|
|
38708
|
+
// readers must never infer it from timestamps or ledger order.
|
|
38709
|
+
turnId: SessionCommandIdSchema2.nullable().optional(),
|
|
38696
38710
|
agentResourceId: external_exports.string().trim().min(1),
|
|
38697
38711
|
harness: UsageHarnessSchema,
|
|
38698
38712
|
// The concrete model id the call billed against (e.g. "claude-opus-4-8"),
|
|
@@ -38730,6 +38744,7 @@ var UsageEventSchema = external_exports.object({
|
|
|
38730
38744
|
});
|
|
38731
38745
|
var UsageEventRecordSchema = UsageEventSchema.extend({
|
|
38732
38746
|
id: external_exports.string().trim().min(1),
|
|
38747
|
+
turnId: SessionCommandIdSchema2.nullable().default(null),
|
|
38733
38748
|
attributionEpochId: SessionAttributionEpochIdSchema.nullable().default(null),
|
|
38734
38749
|
requesterKey: external_exports.string().trim().min(1).nullable().default(null),
|
|
38735
38750
|
attributionGrade: AttributionGradeSchema.nullable().default(null),
|
|
@@ -39013,6 +39028,7 @@ var RunModelFallbackSchema = external_exports.object({
|
|
|
39013
39028
|
fallbackModelId: external_exports.string().nullable()
|
|
39014
39029
|
});
|
|
39015
39030
|
var RUN_USAGE_BREAKDOWN_LIMIT = 8;
|
|
39031
|
+
var RUN_USAGE_TURN_LIMIT = 50;
|
|
39016
39032
|
var RunUsageTotalsSchema = external_exports.object({
|
|
39017
39033
|
eventCount: external_exports.number().int().nonnegative(),
|
|
39018
39034
|
inputTokens: external_exports.number().int().nonnegative(),
|
|
@@ -39035,6 +39051,15 @@ var RunUsageHarnessModelSchema = RunUsageTotalsSchema.extend({
|
|
|
39035
39051
|
harness: UsageHarnessSchema,
|
|
39036
39052
|
model: external_exports.string().trim().min(1)
|
|
39037
39053
|
});
|
|
39054
|
+
var RunUsageTurnSchema = RunUsageTotalsSchema.extend({
|
|
39055
|
+
/** Immutable platform-issued session turn identity. */
|
|
39056
|
+
turnId: SessionCommandIdSchema2,
|
|
39057
|
+
/**
|
|
39058
|
+
* Immutable turn creation time. The series is ordered oldest-to-newest by
|
|
39059
|
+
* this field, then turnId, within the bounded most-recent window.
|
|
39060
|
+
*/
|
|
39061
|
+
turnCreatedAt: external_exports.string().datetime()
|
|
39062
|
+
});
|
|
39038
39063
|
var RunUsageSummarySchema = external_exports.object({
|
|
39039
39064
|
totals: RunUsageTotalsSchema,
|
|
39040
39065
|
/**
|
|
@@ -39048,7 +39073,15 @@ var RunUsageSummarySchema = external_exports.object({
|
|
|
39048
39073
|
}),
|
|
39049
39074
|
/** Highest derived-cost harness/model groups, in descending spend order. */
|
|
39050
39075
|
byHarnessModel: external_exports.array(RunUsageHarnessModelSchema).max(RUN_USAGE_BREAKDOWN_LIMIT),
|
|
39051
|
-
breakdownTruncated: external_exports.boolean()
|
|
39076
|
+
breakdownTruncated: external_exports.boolean(),
|
|
39077
|
+
/** Most recent authoritative turn aggregates, returned oldest-to-newest. */
|
|
39078
|
+
byTurn: external_exports.array(RunUsageTurnSchema).max(RUN_USAGE_TURN_LIMIT),
|
|
39079
|
+
turnBreakdownTruncated: external_exports.boolean(),
|
|
39080
|
+
/**
|
|
39081
|
+
* Current events with no authoritative turn id. These remain in session
|
|
39082
|
+
* totals but are excluded from byTurn rather than guessed into a turn.
|
|
39083
|
+
*/
|
|
39084
|
+
unassociated: RunUsageTotalsSchema
|
|
39052
39085
|
});
|
|
39053
39086
|
var RunSummarySchema = external_exports.object({
|
|
39054
39087
|
session: external_exports.object({
|
|
@@ -71908,6 +71941,9 @@ function replacePayloadWithMarker(envelope, originalBytes) {
|
|
|
71908
71941
|
parts: [{ type: "text", text: text2, state: "done" }]
|
|
71909
71942
|
}
|
|
71910
71943
|
};
|
|
71944
|
+
case "runtime.liveness":
|
|
71945
|
+
case "runtime.usage_turn":
|
|
71946
|
+
return envelope;
|
|
71911
71947
|
}
|
|
71912
71948
|
}
|
|
71913
71949
|
|
|
@@ -72340,6 +72376,23 @@ var AgentBridgeOutputBuffer = class {
|
|
|
72340
72376
|
);
|
|
72341
72377
|
await this.drainPendingOutputs();
|
|
72342
72378
|
}
|
|
72379
|
+
/**
|
|
72380
|
+
* Publish and await the active immutable platform turn before model work.
|
|
72381
|
+
* Unlike liveness, every transition is retained and replayed: skipping one
|
|
72382
|
+
* could attribute a billed call to the preceding turn.
|
|
72383
|
+
*/
|
|
72384
|
+
async emitUsageTurn(context, turnId) {
|
|
72385
|
+
this.outputSeq += 1;
|
|
72386
|
+
this.enqueueOutput(
|
|
72387
|
+
buildUsageTurnOutputEnvelope({
|
|
72388
|
+
context,
|
|
72389
|
+
outputSeq: this.outputSeq,
|
|
72390
|
+
turnId,
|
|
72391
|
+
createdAt: now2()
|
|
72392
|
+
})
|
|
72393
|
+
);
|
|
72394
|
+
await this.drainPendingOutputs({ failIfBlocked: true });
|
|
72395
|
+
}
|
|
72343
72396
|
async emitUiMessageChunk(context, projection) {
|
|
72344
72397
|
await this.flushPendingDelta();
|
|
72345
72398
|
await this.emitLiveUiMessageChunk(context, projection.chunk);
|
|
@@ -73120,6 +73173,18 @@ function buildLivenessOutputEnvelope(input) {
|
|
|
73120
73173
|
createdAt: input.createdAt
|
|
73121
73174
|
});
|
|
73122
73175
|
}
|
|
73176
|
+
function buildUsageTurnOutputEnvelope(input) {
|
|
73177
|
+
const { context } = input;
|
|
73178
|
+
return RuntimeBridgeOutputEnvelopeSchema.parse({
|
|
73179
|
+
type: "runtime.usage_turn",
|
|
73180
|
+
sessionId: context.sessionId,
|
|
73181
|
+
runtimeId: context.runtimeId,
|
|
73182
|
+
bridgeLeaseId: context.bridgeLeaseId,
|
|
73183
|
+
outputSeq: input.outputSeq,
|
|
73184
|
+
turnId: input.turnId,
|
|
73185
|
+
createdAt: input.createdAt
|
|
73186
|
+
});
|
|
73187
|
+
}
|
|
73123
73188
|
function buildUiMessagePartOutputEnvelope(input) {
|
|
73124
73189
|
const { context, snapshot } = input;
|
|
73125
73190
|
return RuntimeBridgeOutputEnvelopeSchema.parse({
|
|
@@ -74404,7 +74469,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
74404
74469
|
return;
|
|
74405
74470
|
}
|
|
74406
74471
|
await this.awaitMcpRegistration();
|
|
74407
|
-
this.enqueueUserMessage(message, commandIds);
|
|
74472
|
+
await this.enqueueUserMessage(message, commandIds);
|
|
74408
74473
|
this.input.runtimeLogger?.info("agent_bridge_claude_send_message_queued", {
|
|
74409
74474
|
delivery_mode: mode,
|
|
74410
74475
|
duration_ms: Date.now() - startedAt,
|
|
@@ -74510,6 +74575,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
74510
74575
|
}
|
|
74511
74576
|
this.openTurnCommandIds.length = 0;
|
|
74512
74577
|
this.publishActiveTurnCommandIds();
|
|
74578
|
+
void this.input.onUsageTurnChanged?.(null);
|
|
74513
74579
|
this.stderr.flush();
|
|
74514
74580
|
this.inputQueue.close();
|
|
74515
74581
|
if (previousState.kind === "started") {
|
|
@@ -74603,6 +74669,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
74603
74669
|
consumedCommandIds: this.openTurnCommandIds.shift() ?? []
|
|
74604
74670
|
};
|
|
74605
74671
|
this.publishActiveTurnCommandIds();
|
|
74672
|
+
await this.input.onUsageTurnChanged?.(null);
|
|
74606
74673
|
this.pendingToolUses.clear();
|
|
74607
74674
|
this.interruptSettling = false;
|
|
74608
74675
|
this.turnResultCount += 1;
|
|
@@ -74614,7 +74681,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
74614
74681
|
consumed_command_ids: meta3.consumedCommandIds
|
|
74615
74682
|
});
|
|
74616
74683
|
if (this.activeTurnCount === 0) {
|
|
74617
|
-
this.flushDeferredMessages();
|
|
74684
|
+
await this.flushDeferredMessages();
|
|
74618
74685
|
}
|
|
74619
74686
|
if (this.deferredMessages.length === 0) {
|
|
74620
74687
|
this.cancelledToolRuns = [];
|
|
@@ -74644,6 +74711,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
74644
74711
|
this.activeTurnCount = 0;
|
|
74645
74712
|
this.openTurnCommandIds.length = 0;
|
|
74646
74713
|
this.publishActiveTurnCommandIds();
|
|
74714
|
+
await this.input.onUsageTurnChanged?.(null);
|
|
74647
74715
|
this.pendingToolUses.clear();
|
|
74648
74716
|
this.interruptSettling = false;
|
|
74649
74717
|
this.disarmToolBoundaryWait();
|
|
@@ -74656,7 +74724,8 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
74656
74724
|
// lets injection work while the SDK session is still starting; the queue
|
|
74657
74725
|
// drains once the query attaches. Startup failures surface through onError
|
|
74658
74726
|
// instead of failing injection.
|
|
74659
|
-
enqueueUserMessage(message, commandIds) {
|
|
74727
|
+
async enqueueUserMessage(message, commandIds) {
|
|
74728
|
+
await this.input.onUsageTurnChanged?.(commandIds[0] ?? null);
|
|
74660
74729
|
this.inputQueue.push(claudeAgentUserMessage(message));
|
|
74661
74730
|
this.activeTurnCount += 1;
|
|
74662
74731
|
this.openTurnCommandIds.push(commandIds);
|
|
@@ -74764,7 +74833,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
74764
74833
|
clearTimeout(this.toolBoundaryWait.timer);
|
|
74765
74834
|
this.toolBoundaryWait = null;
|
|
74766
74835
|
}
|
|
74767
|
-
flushDeferredMessages() {
|
|
74836
|
+
async flushDeferredMessages() {
|
|
74768
74837
|
if (this.deferredMessages.length === 0) {
|
|
74769
74838
|
return;
|
|
74770
74839
|
}
|
|
@@ -74775,7 +74844,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
74775
74844
|
`agent_bridge_claude_deferred_flush count=${pending.length} cancelled_tool_count=${cancelledToolRuns.length}`
|
|
74776
74845
|
);
|
|
74777
74846
|
const text2 = pending.map((entry) => entry.text).join("\n\n");
|
|
74778
|
-
this.enqueueUserMessage(
|
|
74847
|
+
await this.enqueueUserMessage(
|
|
74779
74848
|
cancelledToolRuns.length > 0 ? `${text2}
|
|
74780
74849
|
|
|
74781
74850
|
${cancelledToolPlatformNotice(cancelledToolRuns)}` : text2,
|
|
@@ -75692,6 +75761,13 @@ var ClaudeCodeCommandHandler = class {
|
|
|
75692
75761
|
RUNTIME_LIVENESS_INTERVAL_MS
|
|
75693
75762
|
);
|
|
75694
75763
|
}
|
|
75764
|
+
async emitUsageTurn(turnId) {
|
|
75765
|
+
const activeContext = this.context;
|
|
75766
|
+
if (!activeContext) {
|
|
75767
|
+
throw new Error("Cannot publish usage turn without bridge context");
|
|
75768
|
+
}
|
|
75769
|
+
await this.outputBuffer.emitUsageTurn(activeContext, turnId);
|
|
75770
|
+
}
|
|
75695
75771
|
async emitBridgeOutput(activeContext, projection) {
|
|
75696
75772
|
try {
|
|
75697
75773
|
await this.outputBuffer.emitProjection(activeContext, projection);
|
|
@@ -75859,6 +75935,7 @@ var ClaudeCodeCommandHandler = class {
|
|
|
75859
75935
|
}
|
|
75860
75936
|
},
|
|
75861
75937
|
onActiveTurnCommandIds: (commandIds) => this.autoMcpShim.setActiveTurnCommandIds(commandIds),
|
|
75938
|
+
onUsageTurnChanged: (turnId) => this.emitUsageTurn(turnId),
|
|
75862
75939
|
canUseTool: this.canUseTool,
|
|
75863
75940
|
onMessage: (message, meta3) => this.handleAgentMessage(message, meta3),
|
|
75864
75941
|
onError: (error51) => this.handleAgentError(error51),
|
|
@@ -77067,6 +77144,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
77067
77144
|
this.pendingCommandIds = [...commandIds];
|
|
77068
77145
|
this.publishActiveTurnCommandIds(commandIds);
|
|
77069
77146
|
try {
|
|
77147
|
+
await this.input.onUsageTurnChanged?.(commandIds[0] ?? null);
|
|
77070
77148
|
await this.request("turn/start", {
|
|
77071
77149
|
threadId,
|
|
77072
77150
|
input: [userTextInput(message)]
|
|
@@ -77074,6 +77152,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
77074
77152
|
} catch (error51) {
|
|
77075
77153
|
this.pendingCommandIds = [];
|
|
77076
77154
|
this.publishActiveTurnCommandIds();
|
|
77155
|
+
await this.input.onUsageTurnChanged?.(null);
|
|
77077
77156
|
throw error51;
|
|
77078
77157
|
}
|
|
77079
77158
|
}
|
|
@@ -77081,6 +77160,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
77081
77160
|
this.pendingCommandIds = [...commandIds];
|
|
77082
77161
|
this.publishActiveTurnCommandIds(commandIds);
|
|
77083
77162
|
try {
|
|
77163
|
+
await this.input.onUsageTurnChanged?.(commandIds[0] ?? null);
|
|
77084
77164
|
await this.request("turn/start", {
|
|
77085
77165
|
threadId,
|
|
77086
77166
|
input: []
|
|
@@ -77088,6 +77168,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
77088
77168
|
} catch (error51) {
|
|
77089
77169
|
this.pendingCommandIds = [];
|
|
77090
77170
|
this.publishActiveTurnCommandIds();
|
|
77171
|
+
await this.input.onUsageTurnChanged?.(null);
|
|
77091
77172
|
throw error51;
|
|
77092
77173
|
}
|
|
77093
77174
|
}
|
|
@@ -77451,6 +77532,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
77451
77532
|
this.activeTurnId = null;
|
|
77452
77533
|
this.activeCommandIds = [];
|
|
77453
77534
|
this.publishActiveTurnCommandIds();
|
|
77535
|
+
void this.input.onUsageTurnChanged?.(null);
|
|
77454
77536
|
}
|
|
77455
77537
|
this.pendingToolItemIds.clear();
|
|
77456
77538
|
this.resolveSettlement();
|
|
@@ -77466,6 +77548,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
77466
77548
|
this.activeCommandIds = [];
|
|
77467
77549
|
this.pendingCommandIds = [];
|
|
77468
77550
|
this.publishActiveTurnCommandIds();
|
|
77551
|
+
void this.input.onUsageTurnChanged?.(null);
|
|
77469
77552
|
this.pendingToolItemIds.clear();
|
|
77470
77553
|
this.resolveSettlement();
|
|
77471
77554
|
this.input.writeOutput?.(`agent_bridge_codex_exited code=${code ?? ""}`);
|
|
@@ -77861,6 +77944,13 @@ var CodexCommandHandler = class {
|
|
|
77861
77944
|
RUNTIME_LIVENESS_INTERVAL_MS
|
|
77862
77945
|
);
|
|
77863
77946
|
}
|
|
77947
|
+
async emitUsageTurn(turnId) {
|
|
77948
|
+
const activeContext = this.context;
|
|
77949
|
+
if (!activeContext) {
|
|
77950
|
+
throw new Error("Cannot publish usage turn without bridge context");
|
|
77951
|
+
}
|
|
77952
|
+
await this.outputBuffer.emitUsageTurn(activeContext, turnId);
|
|
77953
|
+
}
|
|
77864
77954
|
async emit(activeContext, projection) {
|
|
77865
77955
|
try {
|
|
77866
77956
|
await this.outputBuffer.emitProjection(activeContext, projection);
|
|
@@ -77883,6 +77973,7 @@ var CodexCommandHandler = class {
|
|
|
77883
77973
|
onServerRequest: (request) => this.handleServerRequest(request),
|
|
77884
77974
|
onThreadId: (threadId) => this.persistThreadId(threadId),
|
|
77885
77975
|
onActiveTurnCommandIds: (commandIds) => this.autoMcpShim.setActiveTurnCommandIds(commandIds),
|
|
77976
|
+
onUsageTurnChanged: (turnId) => this.emitUsageTurn(turnId),
|
|
77886
77977
|
onError: (error51) => this.handleSessionError(error51),
|
|
77887
77978
|
onExit: () => {
|
|
77888
77979
|
if (this.session === session) {
|
package/dist/index.js
CHANGED
|
@@ -23060,6 +23060,10 @@ var init_usage = __esm({
|
|
|
23060
23060
|
organizationId: OrganizationIdSchema,
|
|
23061
23061
|
projectId: ProjectIdSchema.nullable(),
|
|
23062
23062
|
sessionId: SessionIdSchema,
|
|
23063
|
+
// Authoritative platform turn association. Null/absent is an explicit
|
|
23064
|
+
// compatibility state for legacy writers and usage outside a model turn;
|
|
23065
|
+
// readers must never infer it from timestamps or ledger order.
|
|
23066
|
+
turnId: SessionCommandIdSchema.nullable().optional(),
|
|
23063
23067
|
agentResourceId: external_exports.string().trim().min(1),
|
|
23064
23068
|
harness: UsageHarnessSchema,
|
|
23065
23069
|
// The concrete model id the call billed against (e.g. "claude-opus-4-8"),
|
|
@@ -23097,6 +23101,7 @@ var init_usage = __esm({
|
|
|
23097
23101
|
});
|
|
23098
23102
|
UsageEventRecordSchema = UsageEventSchema.extend({
|
|
23099
23103
|
id: external_exports.string().trim().min(1),
|
|
23104
|
+
turnId: SessionCommandIdSchema.nullable().default(null),
|
|
23100
23105
|
attributionEpochId: SessionAttributionEpochIdSchema.nullable().default(null),
|
|
23101
23106
|
requesterKey: external_exports.string().trim().min(1).nullable().default(null),
|
|
23102
23107
|
attributionGrade: AttributionGradeSchema.nullable().default(null),
|
|
@@ -23230,7 +23235,7 @@ var init_usage = __esm({
|
|
|
23230
23235
|
});
|
|
23231
23236
|
|
|
23232
23237
|
// ../../packages/schemas/src/session-introspection.ts
|
|
23233
|
-
var TruncatedValueSchema, RunConversationSearchSnippetSchema, RunConversationSearchMatchSchema, RunConversationSearchResponseSchema, SessionToolExchangeSchema, SessionToolExchangesResponseSchema, SESSION_TRIGGER_DELIVERY_ACTIONS, SessionTriggerDeliveryActionSchema, SESSION_EVENT_ORIGIN_KINDS, SessionEventOriginKindSchema, SessionTriggerDeliveryRecordSchema, SessionTriggersResponseSchema, RunBindingRecordSchema, RunBindingsResponseSchema, RunTurnSchema, SessionToolStatSchema, RunRuntimeRestartSchema, RunModelFallbackSchema, RUN_USAGE_BREAKDOWN_LIMIT, RunUsageTotalsSchema, RunUsageHarnessModelSchema, RunUsageSummarySchema, RunSummarySchema;
|
|
23238
|
+
var TruncatedValueSchema, RunConversationSearchSnippetSchema, RunConversationSearchMatchSchema, RunConversationSearchResponseSchema, SessionToolExchangeSchema, SessionToolExchangesResponseSchema, SESSION_TRIGGER_DELIVERY_ACTIONS, SessionTriggerDeliveryActionSchema, SESSION_EVENT_ORIGIN_KINDS, SessionEventOriginKindSchema, SessionTriggerDeliveryRecordSchema, SessionTriggersResponseSchema, RunBindingRecordSchema, RunBindingsResponseSchema, RunTurnSchema, SessionToolStatSchema, RunRuntimeRestartSchema, RunModelFallbackSchema, RUN_USAGE_BREAKDOWN_LIMIT, RUN_USAGE_TURN_LIMIT, RunUsageTotalsSchema, RunUsageHarnessModelSchema, RunUsageTurnSchema, RunUsageSummarySchema, RunSummarySchema;
|
|
23234
23239
|
var init_session_introspection = __esm({
|
|
23235
23240
|
"../../packages/schemas/src/session-introspection.ts"() {
|
|
23236
23241
|
"use strict";
|
|
@@ -23397,6 +23402,7 @@ var init_session_introspection = __esm({
|
|
|
23397
23402
|
fallbackModelId: external_exports.string().nullable()
|
|
23398
23403
|
});
|
|
23399
23404
|
RUN_USAGE_BREAKDOWN_LIMIT = 8;
|
|
23405
|
+
RUN_USAGE_TURN_LIMIT = 50;
|
|
23400
23406
|
RunUsageTotalsSchema = external_exports.object({
|
|
23401
23407
|
eventCount: external_exports.number().int().nonnegative(),
|
|
23402
23408
|
inputTokens: external_exports.number().int().nonnegative(),
|
|
@@ -23419,6 +23425,15 @@ var init_session_introspection = __esm({
|
|
|
23419
23425
|
harness: UsageHarnessSchema,
|
|
23420
23426
|
model: external_exports.string().trim().min(1)
|
|
23421
23427
|
});
|
|
23428
|
+
RunUsageTurnSchema = RunUsageTotalsSchema.extend({
|
|
23429
|
+
/** Immutable platform-issued session turn identity. */
|
|
23430
|
+
turnId: SessionCommandIdSchema,
|
|
23431
|
+
/**
|
|
23432
|
+
* Immutable turn creation time. The series is ordered oldest-to-newest by
|
|
23433
|
+
* this field, then turnId, within the bounded most-recent window.
|
|
23434
|
+
*/
|
|
23435
|
+
turnCreatedAt: external_exports.string().datetime()
|
|
23436
|
+
});
|
|
23422
23437
|
RunUsageSummarySchema = external_exports.object({
|
|
23423
23438
|
totals: RunUsageTotalsSchema,
|
|
23424
23439
|
/**
|
|
@@ -23432,7 +23447,15 @@ var init_session_introspection = __esm({
|
|
|
23432
23447
|
}),
|
|
23433
23448
|
/** Highest derived-cost harness/model groups, in descending spend order. */
|
|
23434
23449
|
byHarnessModel: external_exports.array(RunUsageHarnessModelSchema).max(RUN_USAGE_BREAKDOWN_LIMIT),
|
|
23435
|
-
breakdownTruncated: external_exports.boolean()
|
|
23450
|
+
breakdownTruncated: external_exports.boolean(),
|
|
23451
|
+
/** Most recent authoritative turn aggregates, returned oldest-to-newest. */
|
|
23452
|
+
byTurn: external_exports.array(RunUsageTurnSchema).max(RUN_USAGE_TURN_LIMIT),
|
|
23453
|
+
turnBreakdownTruncated: external_exports.boolean(),
|
|
23454
|
+
/**
|
|
23455
|
+
* Current events with no authoritative turn id. These remain in session
|
|
23456
|
+
* totals but are excluded from byTurn rather than guessed into a turn.
|
|
23457
|
+
*/
|
|
23458
|
+
unassociated: RunUsageTotalsSchema
|
|
23436
23459
|
});
|
|
23437
23460
|
RunSummarySchema = external_exports.object({
|
|
23438
23461
|
session: external_exports.object({
|
|
@@ -58185,6 +58208,23 @@ triggers:
|
|
|
58185
58208
|
content: "# Source: https://www.auto.sh/api/v1/templates/%40auto/self-improvement/1.6.0/fragments/environments/agent-runtime.yaml\nharness: claude-code\nenvironment:\n name: agent-runtime\n image:\n kind: preset\n name: node24\n resources:\n memoryMB: 8192\n"
|
|
58186
58209
|
}
|
|
58187
58210
|
]
|
|
58211
|
+
},
|
|
58212
|
+
{
|
|
58213
|
+
version: "1.7.0",
|
|
58214
|
+
files: [
|
|
58215
|
+
{
|
|
58216
|
+
path: "agents/self-improvement-slack.yaml",
|
|
58217
|
+
content: '# Source: https://www.auto.sh/api/v1/templates/%40auto/self-improvement/1.7.0/agents/self-improvement-slack.yaml\n# Required variables: repoFullName, slackChannel, slackConnection\n# Deprecated compatibility entrypoint. New installs should import\n# agents/self-improvement.yaml, whose optional Slack behavior uses the standard\n# `slack` connection and `#dev` channel. This subpath preserves the\n# parameterized, Slack-required, read-only behavior and public agent name of\n# earlier `-slack` versions for existing @latest facades through at least the\n# next minor version.\nimports:\n - ./self-improvement.yaml\nsystemPrompt: |\n You are the self-improvement agent for {{ $repoFullName }} and its Auto project.\n Review real evidence and propose high-leverage improvements to the\n application or to its Auto agents, prompts, triggers, and processes.\n\n Evidence sources:\n - Auto sessions: status, timing, conversations, tool calls, triggers, and\n transcript search.\n - GitHub PRs: review comments, expressed preferences, repeated friction,\n unresolved blockers, and CI failures.\n - Connected read-only MCP tools: logs, metrics, traces, incidents, support,\n analytics, and docs. Do not mutate external systems from this workflow.\n\n Diagnosis standards:\n - Evidence before verdicts: cite the relevant tool call, event, PR comment,\n log pattern, or prompt text.\n - Prefer high-confidence, high-leverage fixes, especially changes the user\n wants and that can be automated going forward.\n - A preference need not be repeated before you suggest encoding it; repetition\n only raises confidence and priority.\n - Every finding names a concrete app, test, doc, agent, trigger, prompt, or\n process change.\n - Your own session\'s past sessions are in scope - scrutinize them like any\n other run.\n\n Report format (your final message, every run):\n 1. Verdict - one line: top opportunity, closures, or why more data is needed.\n 2. Findings - each with evidence, affected surface, and the proposed fix.\n 3. Closures - previously reported problems now resolved.\n 4. Deferred - promising leads skipped because they need more evidence.\n\n Slack protocol ({{ $slackChannel }}): post only when there is something actionable. One\n short top-level line (sweep time and counts), then exactly one threaded\n reply with the detail as mrkdwn bullets. Use the threadId returned by\n chat.send for the reply; never guess thread ids. Links are\n <https://url|text>.\ninitialPrompt: |\n A scheduled heartbeat spawned this run (scheduled at\n "{{heartbeat.scheduledAt}}") to sweep the project\'s recent sessions\n for failures, anomalies, PR feedback, and improvement opportunities.\n\n Sweep protocol:\n - Find your previous report with auto.sessions.list/conversation. Avoid\n re-reporting old findings; close resolved ones and escalate recurring ones.\n - Triage recent sessions, PR feedback, and relevant read-only data sources.\n - Deep-dive at most three evidence clusters. Prefer one well-evidenced,\n automatable improvement over many shallow observations.\n\n Deliver per your profile instructions and always end with the four-section\n report.\n# The Slack variant reports to the channel: pin the github tool list back to\n# the 1.0.0 read-only surface (the base widens it for its tracking issue).\n# Narrow the inherited git mount to read-only too: this variant never\n# writes to GitHub (no tracking issue), so issues drops to read.\nmounts:\n - mountPath: /workspace/auto\n auth:\n capabilities:\n contents: read\n pullRequests: read\n issues: read\n checks: read\n actions: read\ntools:\n github:\n kind: github\n tools:\n - search_pull_requests\n - pull_request_read\n - actions_list\n - actions_get\n chat:\n kind: local\n implementation: chat\n auth:\n kind: connection\n provider: slack\n connection: "{{ $slackConnection }}"\n optional: false\ntriggers:\n - name: mention\n event: chat.message.mentioned\n connection: "{{ $slackConnection }}"\n optional: false\n where:\n $.chat.provider: slack\n $.auto.authored: false\n message: |\n {{message.author.userName}} mentioned you on Slack:\n\n {{message.text}}\n\n Channel: {{chat.channelId}}\n Thread: {{chat.threadId}}\n\n Reply in that thread with chat.send. If the user clearly asks for a\n sweep, run it. If required context is missing, ask for the time window,\n target agents, PRs, or data source. Otherwise, briefly explain that you\n review PR feedback, read-only data sources, and Auto session history,\n then propose concrete improvements when something is actionable.\n routing:\n kind: spawn\n'
|
|
58218
|
+
},
|
|
58219
|
+
{
|
|
58220
|
+
path: "agents/self-improvement.yaml",
|
|
58221
|
+
content: '# Source: https://www.auto.sh/api/v1/templates/%40auto/self-improvement/1.7.0/agents/self-improvement.yaml\n# Required variables: repoFullName\nname: self-improvement\nmodel:\n provider: anthropic\n id: claude-opus-4-8\nidentity:\n displayName: Self Improvement\n username: self-improvement\n avatar:\n asset: .auto/assets/self-improvement.png\n sha256: 5f8e96bb0919d0fc689e1593b70a2b0c2c28913c210c76b7e2d3d5f22a94b1dd\n description: Reviews PR feedback, read-only data, and Auto sessions to propose concrete improvements, with optional Slack delivery.\nimports:\n - ../fragments/environments/agent-runtime.yaml\nbindings:\n slack.thread:\n continuity: agent\nsystemPrompt: |\n You are the self-improvement agent for {{ $repoFullName }} and its Auto project.\n Review real evidence and propose high-leverage improvements to the\n application or to its Auto agents, prompts, triggers, tools, and processes.\n Treat the repository\'s committed `.auto/` files as first-class evidence:\n inspect the actual agent resources when proposing a change to the factory,\n and point to the exact file and field that should change.\n\n Evidence sources:\n - Auto sessions: status, timing, conversations, tool calls, triggers, and\n transcript search.\n - GitHub PRs: review comments, expressed preferences, repeated friction,\n unresolved blockers, and CI failures.\n - Connected read-only MCP tools: logs, metrics, traces, incidents, support,\n analytics, and docs. Do not mutate external systems from this workflow.\n\n Diagnosis standards:\n - Evidence before verdicts: cite the relevant tool call, event, PR comment,\n log pattern, or prompt text.\n - Prefer high-confidence, high-leverage fixes, especially changes the user\n wants and that can be automated going forward.\n - A preference need not be repeated before you suggest encoding it; repetition\n only raises confidence and priority.\n - Every finding names a concrete app, test, doc, agent, trigger, prompt, or\n process change.\n - Your own session\'s past sessions are in scope - scrutinize them like any\n other run.\n\n Report format (your final message, every run):\n 1. Verdict - one line: top opportunity, closures, or why more data is needed.\n 2. Findings - each with evidence, affected surface, and the proposed fix.\n 3. Closures - previously reported problems now resolved.\n 4. Deferred - promising leads skipped because they need more evidence.\n\n Delivery: the report is this run\'s final message. Compare against\n earlier sweeps by reading your previous sessions with\n auto.sessions.list/conversation - the session history is the report\n history. Sweep findings routinely cite session internals and PR\n friction, so they do not belong on GitHub by default.\n\n Fallback (only when the team has explicitly asked for tracking-issue\n delivery, and never on a public repository): keep a single tracking\n issue titled "Self-improvement sweep reports" - find it with\n search_issues, create it with issue_write only if it is missing, and\n add exactly one comment per sweep with add_issue_comment: one short\n first line (sweep time and counts), then the detail as Markdown\n bullets. Never open a new issue per finding, and post only when there\n is something actionable.\n\n Slack delivery is optional and uses the standard `slack` connection and\n `#dev` channel. When the chat tool is available, post only when there is\n something actionable: one short top-level line with the sweep time and\n counts, then exactly one threaded reply with the detail as mrkdwn bullets.\n Use the threadId returned by chat.send for the reply; never guess thread ids.\n When the tool is unavailable, do not treat Slack delivery as a failure; the\n run report remains the complete sweep. If a user asks for Slack delivery\n while it is unavailable, offer to connect the standard `slack` connection\n and explain that a fresh apply and session make the capability available.\n\n Scheduled sweep closure:\n - Finish the final four-section report/reply and, for actionable findings,\n every required Slack or Chief handoff. Only after every owed delivery is\n complete, call `auto.sessions.complete_current` exactly once with a compact\n one-line handoff.\n - This applies to actionable and no-action sweeps. A no-findings sweep with\n Verdict "Nothing actionable." completes after its final four-section report;\n it owes no Slack or Chief handoff.\n - Never call `auto.sessions.archive_current` to close a sweep. Do not call\n `auto.unbind`, `auto.chat.unsubscribe`, or otherwise release a Slack\n thread binding during closure. The configured agent-continuity\n `slack.thread` binding survives completion while lifecycle remains manual.\n `chat_send` stamps that continuity from this spec. It routes a human reply\n back to this completed holder and reopens this session.\ninitialPrompt: |\n A scheduled heartbeat spawned this run (scheduled at\n "{{heartbeat.scheduledAt}}") to sweep the project\'s recent sessions\n for failures, anomalies, PR feedback, and improvement opportunities.\n\n Sweep protocol:\n - Find your previous report with auto.sessions.list/conversation. Avoid\n re-reporting old findings; close resolved ones and escalate recurring ones.\n - Triage recent sessions, PR feedback, and relevant read-only data sources.\n - Deep-dive at most three evidence clusters. Prefer one well-evidenced,\n automatable improvement over many shallow observations.\n\n Deliver per your profile instructions and always end with the four-section\n report.\nmounts:\n # GitHub App git mount provisions the GitHub MCP proxy (the github\n # tools below are broken without a githubApp mount) and stages a\n # read-only checkout the sweep can ground findings in. Capabilities\n # line up with the declared tools: pullRequests/issues read for PR\n # comment and tracking-issue inspection, issues: write for the opt-in\n # tracking-issue fallback (issue_write/add_issue_comment), actions/checks\n # read for CI. No merge/secrets/workflows.\n - kind: git\n repository: "{{ $repoFullName }}"\n mountPath: /workspace/auto\n ref: main\n auth:\n kind: githubApp\n capabilities:\n contents: read\n pullRequests: read\n issues: write\n checks: read\n actions: read\ntools:\n auto:\n kind: local\n implementation: auto\n github:\n kind: github\n tools:\n - search_pull_requests\n - pull_request_read\n - actions_list\n - actions_get\n - search_issues\n - issue_read\n - issue_write\n - add_issue_comment\n chat:\n kind: local\n implementation: chat\n auth:\n kind: connection\n provider: slack\n connection: slack\n optional: true\ntriggers:\n - name: sweep-heartbeat\n kind: heartbeat\n cron: 0 */2 * * *\n timezone: UTC\n routing:\n kind: spawn\n - name: mention\n event: chat.message.mentioned\n connection: slack\n optional: true\n where:\n $.chat.provider: slack\n $.auto.authored: false\n message: |\n {{message.author.userName}} mentioned you on Slack:\n\n {{message.text}}\n\n Channel: {{chat.channelId}}\n Thread: {{chat.threadId}}\n\n Reply in that thread with chat.send. If the user clearly asks for a\n sweep, run it. If required context is missing, ask for the time window,\n target agents, PRs, or data source. Otherwise, briefly explain that you\n review PR feedback, read-only data sources, and Auto session history,\n then propose concrete improvements when something is actionable.\n routing:\n kind: spawn\n'
|
|
58222
|
+
},
|
|
58223
|
+
{
|
|
58224
|
+
path: "fragments/environments/agent-runtime.yaml",
|
|
58225
|
+
content: "# Source: https://www.auto.sh/api/v1/templates/%40auto/self-improvement/1.7.0/fragments/environments/agent-runtime.yaml\nharness: claude-code\nenvironment:\n name: agent-runtime\n image:\n kind: preset\n name: node24\n resources:\n memoryMB: 8192\n"
|
|
58226
|
+
}
|
|
58227
|
+
]
|
|
58188
58228
|
}
|
|
58189
58229
|
],
|
|
58190
58230
|
"@auto/slopbusters": [
|
|
@@ -84936,7 +84976,7 @@ var init_package = __esm({
|
|
|
84936
84976
|
"package.json"() {
|
|
84937
84977
|
package_default = {
|
|
84938
84978
|
name: "@autohq/cli",
|
|
84939
|
-
version: "0.1.
|
|
84979
|
+
version: "0.1.566",
|
|
84940
84980
|
license: "SEE LICENSE IN README.md",
|
|
84941
84981
|
publishConfig: {
|
|
84942
84982
|
access: "public"
|
|
@@ -96138,13 +96178,23 @@ var RuntimeBridgeOutputLivenessEnvelopeSchema = external_exports.object({
|
|
|
96138
96178
|
intervalMs: external_exports.number().int().positive(),
|
|
96139
96179
|
createdAt: external_exports.string().datetime()
|
|
96140
96180
|
});
|
|
96181
|
+
var RuntimeBridgeOutputUsageTurnEnvelopeSchema = external_exports.object({
|
|
96182
|
+
type: external_exports.literal("runtime.usage_turn"),
|
|
96183
|
+
sessionId: SessionIdSchema2,
|
|
96184
|
+
runtimeId: RuntimeIdSchema2,
|
|
96185
|
+
bridgeLeaseId: RuntimeBridgeLeaseIdSchema2,
|
|
96186
|
+
outputSeq: external_exports.number().int().positive(),
|
|
96187
|
+
turnId: SessionCommandIdSchema2.nullable(),
|
|
96188
|
+
createdAt: external_exports.string().datetime()
|
|
96189
|
+
});
|
|
96141
96190
|
var RuntimeBridgeOutputEnvelopeSchema = external_exports.union([
|
|
96142
96191
|
RuntimeBridgeOutputEntryEnvelopeSchema,
|
|
96143
96192
|
RuntimeBridgeOutputDeltaEnvelopeSchema,
|
|
96144
96193
|
RuntimeBridgeOutputUiMessageChunkEnvelopeSchema,
|
|
96145
96194
|
RuntimeBridgeOutputUiMessagePartEnvelopeSchema,
|
|
96146
96195
|
RuntimeBridgeOutputUiMessageCompletedEnvelopeSchema,
|
|
96147
|
-
RuntimeBridgeOutputLivenessEnvelopeSchema
|
|
96196
|
+
RuntimeBridgeOutputLivenessEnvelopeSchema,
|
|
96197
|
+
RuntimeBridgeOutputUsageTurnEnvelopeSchema
|
|
96148
96198
|
]);
|
|
96149
96199
|
function isLiveOnlyRuntimeOutputEnvelope(envelope) {
|
|
96150
96200
|
return envelope.type === "ui.message.chunk" || envelope.type === "conversation.delta";
|
|
@@ -97791,6 +97841,9 @@ function replacePayloadWithMarker(envelope, originalBytes) {
|
|
|
97791
97841
|
parts: [{ type: "text", text, state: "done" }]
|
|
97792
97842
|
}
|
|
97793
97843
|
};
|
|
97844
|
+
case "runtime.liveness":
|
|
97845
|
+
case "runtime.usage_turn":
|
|
97846
|
+
return envelope;
|
|
97794
97847
|
}
|
|
97795
97848
|
}
|
|
97796
97849
|
|
|
@@ -98224,6 +98277,23 @@ var AgentBridgeOutputBuffer = class {
|
|
|
98224
98277
|
);
|
|
98225
98278
|
await this.drainPendingOutputs();
|
|
98226
98279
|
}
|
|
98280
|
+
/**
|
|
98281
|
+
* Publish and await the active immutable platform turn before model work.
|
|
98282
|
+
* Unlike liveness, every transition is retained and replayed: skipping one
|
|
98283
|
+
* could attribute a billed call to the preceding turn.
|
|
98284
|
+
*/
|
|
98285
|
+
async emitUsageTurn(context, turnId) {
|
|
98286
|
+
this.outputSeq += 1;
|
|
98287
|
+
this.enqueueOutput(
|
|
98288
|
+
buildUsageTurnOutputEnvelope({
|
|
98289
|
+
context,
|
|
98290
|
+
outputSeq: this.outputSeq,
|
|
98291
|
+
turnId,
|
|
98292
|
+
createdAt: now2()
|
|
98293
|
+
})
|
|
98294
|
+
);
|
|
98295
|
+
await this.drainPendingOutputs({ failIfBlocked: true });
|
|
98296
|
+
}
|
|
98227
98297
|
async emitUiMessageChunk(context, projection) {
|
|
98228
98298
|
await this.flushPendingDelta();
|
|
98229
98299
|
await this.emitLiveUiMessageChunk(context, projection.chunk);
|
|
@@ -99004,6 +99074,18 @@ function buildLivenessOutputEnvelope(input) {
|
|
|
99004
99074
|
createdAt: input.createdAt
|
|
99005
99075
|
});
|
|
99006
99076
|
}
|
|
99077
|
+
function buildUsageTurnOutputEnvelope(input) {
|
|
99078
|
+
const { context } = input;
|
|
99079
|
+
return RuntimeBridgeOutputEnvelopeSchema.parse({
|
|
99080
|
+
type: "runtime.usage_turn",
|
|
99081
|
+
sessionId: context.sessionId,
|
|
99082
|
+
runtimeId: context.runtimeId,
|
|
99083
|
+
bridgeLeaseId: context.bridgeLeaseId,
|
|
99084
|
+
outputSeq: input.outputSeq,
|
|
99085
|
+
turnId: input.turnId,
|
|
99086
|
+
createdAt: input.createdAt
|
|
99087
|
+
});
|
|
99088
|
+
}
|
|
99007
99089
|
function buildUiMessagePartOutputEnvelope(input) {
|
|
99008
99090
|
const { context, snapshot } = input;
|
|
99009
99091
|
return RuntimeBridgeOutputEnvelopeSchema.parse({
|
|
@@ -100295,7 +100377,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
100295
100377
|
return;
|
|
100296
100378
|
}
|
|
100297
100379
|
await this.awaitMcpRegistration();
|
|
100298
|
-
this.enqueueUserMessage(message, commandIds);
|
|
100380
|
+
await this.enqueueUserMessage(message, commandIds);
|
|
100299
100381
|
this.input.runtimeLogger?.info("agent_bridge_claude_send_message_queued", {
|
|
100300
100382
|
delivery_mode: mode,
|
|
100301
100383
|
duration_ms: Date.now() - startedAt,
|
|
@@ -100401,6 +100483,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
100401
100483
|
}
|
|
100402
100484
|
this.openTurnCommandIds.length = 0;
|
|
100403
100485
|
this.publishActiveTurnCommandIds();
|
|
100486
|
+
void this.input.onUsageTurnChanged?.(null);
|
|
100404
100487
|
this.stderr.flush();
|
|
100405
100488
|
this.inputQueue.close();
|
|
100406
100489
|
if (previousState.kind === "started") {
|
|
@@ -100494,6 +100577,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
100494
100577
|
consumedCommandIds: this.openTurnCommandIds.shift() ?? []
|
|
100495
100578
|
};
|
|
100496
100579
|
this.publishActiveTurnCommandIds();
|
|
100580
|
+
await this.input.onUsageTurnChanged?.(null);
|
|
100497
100581
|
this.pendingToolUses.clear();
|
|
100498
100582
|
this.interruptSettling = false;
|
|
100499
100583
|
this.turnResultCount += 1;
|
|
@@ -100505,7 +100589,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
100505
100589
|
consumed_command_ids: meta3.consumedCommandIds
|
|
100506
100590
|
});
|
|
100507
100591
|
if (this.activeTurnCount === 0) {
|
|
100508
|
-
this.flushDeferredMessages();
|
|
100592
|
+
await this.flushDeferredMessages();
|
|
100509
100593
|
}
|
|
100510
100594
|
if (this.deferredMessages.length === 0) {
|
|
100511
100595
|
this.cancelledToolRuns = [];
|
|
@@ -100535,6 +100619,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
100535
100619
|
this.activeTurnCount = 0;
|
|
100536
100620
|
this.openTurnCommandIds.length = 0;
|
|
100537
100621
|
this.publishActiveTurnCommandIds();
|
|
100622
|
+
await this.input.onUsageTurnChanged?.(null);
|
|
100538
100623
|
this.pendingToolUses.clear();
|
|
100539
100624
|
this.interruptSettling = false;
|
|
100540
100625
|
this.disarmToolBoundaryWait();
|
|
@@ -100547,7 +100632,8 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
100547
100632
|
// lets injection work while the SDK session is still starting; the queue
|
|
100548
100633
|
// drains once the query attaches. Startup failures surface through onError
|
|
100549
100634
|
// instead of failing injection.
|
|
100550
|
-
enqueueUserMessage(message, commandIds) {
|
|
100635
|
+
async enqueueUserMessage(message, commandIds) {
|
|
100636
|
+
await this.input.onUsageTurnChanged?.(commandIds[0] ?? null);
|
|
100551
100637
|
this.inputQueue.push(claudeAgentUserMessage(message));
|
|
100552
100638
|
this.activeTurnCount += 1;
|
|
100553
100639
|
this.openTurnCommandIds.push(commandIds);
|
|
@@ -100655,7 +100741,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
100655
100741
|
clearTimeout(this.toolBoundaryWait.timer);
|
|
100656
100742
|
this.toolBoundaryWait = null;
|
|
100657
100743
|
}
|
|
100658
|
-
flushDeferredMessages() {
|
|
100744
|
+
async flushDeferredMessages() {
|
|
100659
100745
|
if (this.deferredMessages.length === 0) {
|
|
100660
100746
|
return;
|
|
100661
100747
|
}
|
|
@@ -100666,7 +100752,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
100666
100752
|
`agent_bridge_claude_deferred_flush count=${pending.length} cancelled_tool_count=${cancelledToolRuns.length}`
|
|
100667
100753
|
);
|
|
100668
100754
|
const text = pending.map((entry) => entry.text).join("\n\n");
|
|
100669
|
-
this.enqueueUserMessage(
|
|
100755
|
+
await this.enqueueUserMessage(
|
|
100670
100756
|
cancelledToolRuns.length > 0 ? `${text}
|
|
100671
100757
|
|
|
100672
100758
|
${cancelledToolPlatformNotice(cancelledToolRuns)}` : text,
|
|
@@ -101583,6 +101669,13 @@ var ClaudeCodeCommandHandler = class {
|
|
|
101583
101669
|
RUNTIME_LIVENESS_INTERVAL_MS
|
|
101584
101670
|
);
|
|
101585
101671
|
}
|
|
101672
|
+
async emitUsageTurn(turnId) {
|
|
101673
|
+
const activeContext = this.context;
|
|
101674
|
+
if (!activeContext) {
|
|
101675
|
+
throw new Error("Cannot publish usage turn without bridge context");
|
|
101676
|
+
}
|
|
101677
|
+
await this.outputBuffer.emitUsageTurn(activeContext, turnId);
|
|
101678
|
+
}
|
|
101586
101679
|
async emitBridgeOutput(activeContext, projection) {
|
|
101587
101680
|
try {
|
|
101588
101681
|
await this.outputBuffer.emitProjection(activeContext, projection);
|
|
@@ -101750,6 +101843,7 @@ var ClaudeCodeCommandHandler = class {
|
|
|
101750
101843
|
}
|
|
101751
101844
|
},
|
|
101752
101845
|
onActiveTurnCommandIds: (commandIds) => this.autoMcpShim.setActiveTurnCommandIds(commandIds),
|
|
101846
|
+
onUsageTurnChanged: (turnId) => this.emitUsageTurn(turnId),
|
|
101753
101847
|
canUseTool: this.canUseTool,
|
|
101754
101848
|
onMessage: (message, meta3) => this.handleAgentMessage(message, meta3),
|
|
101755
101849
|
onError: (error51) => this.handleAgentError(error51),
|
|
@@ -102963,6 +103057,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
102963
103057
|
this.pendingCommandIds = [...commandIds];
|
|
102964
103058
|
this.publishActiveTurnCommandIds(commandIds);
|
|
102965
103059
|
try {
|
|
103060
|
+
await this.input.onUsageTurnChanged?.(commandIds[0] ?? null);
|
|
102966
103061
|
await this.request("turn/start", {
|
|
102967
103062
|
threadId,
|
|
102968
103063
|
input: [userTextInput(message)]
|
|
@@ -102970,6 +103065,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
102970
103065
|
} catch (error51) {
|
|
102971
103066
|
this.pendingCommandIds = [];
|
|
102972
103067
|
this.publishActiveTurnCommandIds();
|
|
103068
|
+
await this.input.onUsageTurnChanged?.(null);
|
|
102973
103069
|
throw error51;
|
|
102974
103070
|
}
|
|
102975
103071
|
}
|
|
@@ -102977,6 +103073,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
102977
103073
|
this.pendingCommandIds = [...commandIds];
|
|
102978
103074
|
this.publishActiveTurnCommandIds(commandIds);
|
|
102979
103075
|
try {
|
|
103076
|
+
await this.input.onUsageTurnChanged?.(commandIds[0] ?? null);
|
|
102980
103077
|
await this.request("turn/start", {
|
|
102981
103078
|
threadId,
|
|
102982
103079
|
input: []
|
|
@@ -102984,6 +103081,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
102984
103081
|
} catch (error51) {
|
|
102985
103082
|
this.pendingCommandIds = [];
|
|
102986
103083
|
this.publishActiveTurnCommandIds();
|
|
103084
|
+
await this.input.onUsageTurnChanged?.(null);
|
|
102987
103085
|
throw error51;
|
|
102988
103086
|
}
|
|
102989
103087
|
}
|
|
@@ -103347,6 +103445,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
103347
103445
|
this.activeTurnId = null;
|
|
103348
103446
|
this.activeCommandIds = [];
|
|
103349
103447
|
this.publishActiveTurnCommandIds();
|
|
103448
|
+
void this.input.onUsageTurnChanged?.(null);
|
|
103350
103449
|
}
|
|
103351
103450
|
this.pendingToolItemIds.clear();
|
|
103352
103451
|
this.resolveSettlement();
|
|
@@ -103362,6 +103461,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
103362
103461
|
this.activeCommandIds = [];
|
|
103363
103462
|
this.pendingCommandIds = [];
|
|
103364
103463
|
this.publishActiveTurnCommandIds();
|
|
103464
|
+
void this.input.onUsageTurnChanged?.(null);
|
|
103365
103465
|
this.pendingToolItemIds.clear();
|
|
103366
103466
|
this.resolveSettlement();
|
|
103367
103467
|
this.input.writeOutput?.(`agent_bridge_codex_exited code=${code ?? ""}`);
|
|
@@ -103757,6 +103857,13 @@ var CodexCommandHandler = class {
|
|
|
103757
103857
|
RUNTIME_LIVENESS_INTERVAL_MS
|
|
103758
103858
|
);
|
|
103759
103859
|
}
|
|
103860
|
+
async emitUsageTurn(turnId) {
|
|
103861
|
+
const activeContext = this.context;
|
|
103862
|
+
if (!activeContext) {
|
|
103863
|
+
throw new Error("Cannot publish usage turn without bridge context");
|
|
103864
|
+
}
|
|
103865
|
+
await this.outputBuffer.emitUsageTurn(activeContext, turnId);
|
|
103866
|
+
}
|
|
103760
103867
|
async emit(activeContext, projection) {
|
|
103761
103868
|
try {
|
|
103762
103869
|
await this.outputBuffer.emitProjection(activeContext, projection);
|
|
@@ -103779,6 +103886,7 @@ var CodexCommandHandler = class {
|
|
|
103779
103886
|
onServerRequest: (request) => this.handleServerRequest(request),
|
|
103780
103887
|
onThreadId: (threadId) => this.persistThreadId(threadId),
|
|
103781
103888
|
onActiveTurnCommandIds: (commandIds) => this.autoMcpShim.setActiveTurnCommandIds(commandIds),
|
|
103889
|
+
onUsageTurnChanged: (turnId) => this.emitUsageTurn(turnId),
|
|
103782
103890
|
onError: (error51) => this.handleSessionError(error51),
|
|
103783
103891
|
onExit: () => {
|
|
103784
103892
|
if (this.session === session) {
|