@autohq/cli 0.1.564 → 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 +343 -212
- package/dist/index.js +384 -235
- 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"
|
|
@@ -38656,6 +38666,215 @@ var RuntimeRestartDiagnosticRecordSchema = external_exports.object({
|
|
|
38656
38666
|
createdAt: external_exports.string().datetime()
|
|
38657
38667
|
});
|
|
38658
38668
|
|
|
38669
|
+
// ../../packages/schemas/src/session-attribution-epochs.ts
|
|
38670
|
+
var ATTRIBUTION_GRADES = ["derived", "asserted"];
|
|
38671
|
+
var AttributionGradeSchema = external_exports.enum(ATTRIBUTION_GRADES);
|
|
38672
|
+
var AttributionRequesterSnapshotSchema = external_exports.object({
|
|
38673
|
+
origin: RequesterRootOriginSchema,
|
|
38674
|
+
userId: UserIdSchema.nullable()
|
|
38675
|
+
}).strict();
|
|
38676
|
+
var SessionAttributionEpochCreateSchema = external_exports.object({
|
|
38677
|
+
organizationId: OrganizationIdSchema,
|
|
38678
|
+
projectId: ProjectIdSchema.nullable(),
|
|
38679
|
+
sessionId: SessionIdSchema2,
|
|
38680
|
+
sourceCommandId: SessionCommandIdSchema2,
|
|
38681
|
+
requesterKey: external_exports.string().trim().min(1),
|
|
38682
|
+
requesterSnapshot: AttributionRequesterSnapshotSchema.nullable(),
|
|
38683
|
+
attributionGrade: AttributionGradeSchema,
|
|
38684
|
+
assertedByCommandId: SessionCommandIdSchema2.nullable(),
|
|
38685
|
+
assertedBySessionId: SessionIdSchema2.nullable(),
|
|
38686
|
+
assertedByAgentResourceId: external_exports.string().trim().min(1).nullable(),
|
|
38687
|
+
fundingSource: ModelCredentialFundingSourceSchema.nullable(),
|
|
38688
|
+
providerGrantId: ProviderGrantIdSchema.nullable(),
|
|
38689
|
+
userModelSubscriptionId: UserSubscriptionCredentialIdSchema.nullable()
|
|
38690
|
+
}).strict();
|
|
38691
|
+
var SessionAttributionEpochRecordSchema = SessionAttributionEpochCreateSchema.extend({
|
|
38692
|
+
id: SessionAttributionEpochIdSchema,
|
|
38693
|
+
createdAt: external_exports.string().datetime()
|
|
38694
|
+
}).strict();
|
|
38695
|
+
|
|
38696
|
+
// ../../packages/schemas/src/usage.ts
|
|
38697
|
+
var UsageHarnessSchema = external_exports.enum(AGENT_HARNESSES);
|
|
38698
|
+
var NonNegativeTokenCountSchema = external_exports.number().int().nonnegative();
|
|
38699
|
+
var NonNegativeUsdSchema2 = external_exports.number().nonnegative();
|
|
38700
|
+
var UsageEventSchema = external_exports.object({
|
|
38701
|
+
// Tenant + lineage attribution. projectId is nullable because a resource can
|
|
38702
|
+
// belong directly to an organization with no project.
|
|
38703
|
+
organizationId: OrganizationIdSchema,
|
|
38704
|
+
projectId: ProjectIdSchema.nullable(),
|
|
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(),
|
|
38710
|
+
agentResourceId: external_exports.string().trim().min(1),
|
|
38711
|
+
harness: UsageHarnessSchema,
|
|
38712
|
+
// The concrete model id the call billed against (e.g. "claude-opus-4-8"),
|
|
38713
|
+
// taken from the response rather than any selection layer — a single run can
|
|
38714
|
+
// touch multiple models, so this is per-call, never per-run.
|
|
38715
|
+
model: external_exports.string().trim().min(1),
|
|
38716
|
+
inputTokens: NonNegativeTokenCountSchema,
|
|
38717
|
+
outputTokens: NonNegativeTokenCountSchema,
|
|
38718
|
+
cacheCreationTokens: NonNegativeTokenCountSchema,
|
|
38719
|
+
cacheReadTokens: NonNegativeTokenCountSchema,
|
|
38720
|
+
// The provider's own cost when it reports one, kept only for reconciliation.
|
|
38721
|
+
// Nullable/absent because it can be 0 or missing — never the billing source.
|
|
38722
|
+
providerCostUsd: NonNegativeUsdSchema2.nullable(),
|
|
38723
|
+
// Platform-derived cost and the rate-card version it was derived under, so a
|
|
38724
|
+
// later rate-card change never silently rewrites historical cost.
|
|
38725
|
+
derivedCostUsd: NonNegativeUsdSchema2,
|
|
38726
|
+
pricingVersion: external_exports.string().trim().min(1),
|
|
38727
|
+
// What this call debits from the organization's credit balance, and the fee
|
|
38728
|
+
// card it was derived under (see `./billing`). Required — a writer that
|
|
38729
|
+
// forgets it would silently record unbilled usage, so there is no default.
|
|
38730
|
+
billedCostUsd: NonNegativeUsdSchema2,
|
|
38731
|
+
billingFeeVersion: external_exports.string().trim().min(1),
|
|
38732
|
+
// Historical funding attribution for the model call. The provider grant id is
|
|
38733
|
+
// denormalized and nullable for platform-funded usage, matching the ledger's
|
|
38734
|
+
// no-FK audit-trail contract.
|
|
38735
|
+
fundingSource: ModelCredentialFundingSourceSchema.default("platform"),
|
|
38736
|
+
modelCredentialProviderGrantId: ProviderGrantIdSchema.nullable().default(null),
|
|
38737
|
+
// Optional during the cross-chunk rollout: B1 defines the attribution field
|
|
38738
|
+
// before B3 deploys its persistence column and D3 begins populating it.
|
|
38739
|
+
modelCredentialUserSubscriptionId: UserSubscriptionCredentialIdSchema.nullable().optional(),
|
|
38740
|
+
attributionEpochId: SessionAttributionEpochIdSchema.nullable().optional(),
|
|
38741
|
+
requesterKey: external_exports.string().trim().min(1).nullable().optional(),
|
|
38742
|
+
attributionGrade: AttributionGradeSchema.nullable().optional(),
|
|
38743
|
+
occurredAt: external_exports.string().datetime()
|
|
38744
|
+
});
|
|
38745
|
+
var UsageEventRecordSchema = UsageEventSchema.extend({
|
|
38746
|
+
id: external_exports.string().trim().min(1),
|
|
38747
|
+
turnId: SessionCommandIdSchema2.nullable().default(null),
|
|
38748
|
+
attributionEpochId: SessionAttributionEpochIdSchema.nullable().default(null),
|
|
38749
|
+
requesterKey: external_exports.string().trim().min(1).nullable().default(null),
|
|
38750
|
+
attributionGrade: AttributionGradeSchema.nullable().default(null),
|
|
38751
|
+
// Set on append-only correction rows: this row replaces the pointed-at row's
|
|
38752
|
+
// amounts, and ledger readers exclude any row another row supersedes.
|
|
38753
|
+
supersedesUsageEventId: external_exports.string().trim().min(1).nullable().default(null),
|
|
38754
|
+
createdAt: external_exports.string().datetime()
|
|
38755
|
+
});
|
|
38756
|
+
var UsageTotalsSchema = external_exports.object({
|
|
38757
|
+
eventCount: NonNegativeTokenCountSchema,
|
|
38758
|
+
inputTokens: NonNegativeTokenCountSchema,
|
|
38759
|
+
outputTokens: NonNegativeTokenCountSchema,
|
|
38760
|
+
cacheCreationTokens: NonNegativeTokenCountSchema,
|
|
38761
|
+
cacheReadTokens: NonNegativeTokenCountSchema,
|
|
38762
|
+
totalTokens: NonNegativeTokenCountSchema,
|
|
38763
|
+
billedCostUsd: NonNegativeUsdSchema2
|
|
38764
|
+
});
|
|
38765
|
+
var SessionUsageModelSummarySchema = UsageTotalsSchema.extend({
|
|
38766
|
+
model: external_exports.string().trim().min(1)
|
|
38767
|
+
});
|
|
38768
|
+
var UsageFundingSummarySchema = UsageTotalsSchema.extend({
|
|
38769
|
+
fundingSource: ModelCredentialFundingSourceSchema,
|
|
38770
|
+
coveredInferenceCostUsd: NonNegativeUsdSchema2
|
|
38771
|
+
});
|
|
38772
|
+
var SessionModelFundingStateSchema = external_exports.object({
|
|
38773
|
+
fundingSource: ModelCredentialFundingSourceSchema,
|
|
38774
|
+
provider: external_exports.string().trim().min(1),
|
|
38775
|
+
// The subscription owner's display name for user_subscription funding, so
|
|
38776
|
+
// the session header can say whose key is being used. Optional for old
|
|
38777
|
+
// writers; null when the name cannot resolve.
|
|
38778
|
+
ownerDisplayName: external_exports.string().trim().min(1).nullable().optional()
|
|
38779
|
+
});
|
|
38780
|
+
var SessionUsageCurrentAttributionSchema = external_exports.object({
|
|
38781
|
+
requesterKey: external_exports.string().trim().min(1),
|
|
38782
|
+
requesterDisplayName: external_exports.string().trim().min(1).nullable(),
|
|
38783
|
+
attributionGrade: AttributionGradeSchema
|
|
38784
|
+
}).strip();
|
|
38785
|
+
var SessionUsageRequesterSummarySchema = external_exports.object({
|
|
38786
|
+
requesterKey: external_exports.string().trim().min(1).nullable(),
|
|
38787
|
+
requesterDisplayName: external_exports.string().trim().min(1).nullable(),
|
|
38788
|
+
billedCostUsd: NonNegativeUsdSchema2,
|
|
38789
|
+
attributionGrades: external_exports.array(AttributionGradeSchema)
|
|
38790
|
+
}).strip();
|
|
38791
|
+
var SessionUsageResponseSchema = external_exports.object({
|
|
38792
|
+
sessionId: SessionIdSchema2,
|
|
38793
|
+
totals: UsageTotalsSchema,
|
|
38794
|
+
models: external_exports.array(SessionUsageModelSummarySchema),
|
|
38795
|
+
byFundingSource: external_exports.array(UsageFundingSummarySchema),
|
|
38796
|
+
byRequester: external_exports.array(SessionUsageRequesterSummarySchema).optional().default([]),
|
|
38797
|
+
currentAttribution: SessionUsageCurrentAttributionSchema.nullable().optional().default(null),
|
|
38798
|
+
funding: SessionModelFundingStateSchema.nullable(),
|
|
38799
|
+
firstUsageAt: external_exports.string().datetime().nullable(),
|
|
38800
|
+
lastUsageAt: external_exports.string().datetime().nullable()
|
|
38801
|
+
}).strip();
|
|
38802
|
+
var PROJECT_USAGE_RANGE_KEYS = ["7d", "30d"];
|
|
38803
|
+
var ProjectUsageRangeKeySchema = external_exports.enum(PROJECT_USAGE_RANGE_KEYS);
|
|
38804
|
+
var UtcDateSchema = external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/);
|
|
38805
|
+
var ProjectUsageTotalsSchema = UsageTotalsSchema.extend({
|
|
38806
|
+
sessionCount: NonNegativeTokenCountSchema,
|
|
38807
|
+
// Share of all tokens served from prompt-cache reads (0..1); 0 when the
|
|
38808
|
+
// window has no tokens at all.
|
|
38809
|
+
cacheReadShare: external_exports.number().min(0).max(1)
|
|
38810
|
+
});
|
|
38811
|
+
var ProjectUsageAgentSummarySchema = UsageTotalsSchema.extend({
|
|
38812
|
+
agentResourceId: external_exports.string().trim().min(1),
|
|
38813
|
+
// Resolved from the agent resource (archived agents included); null only
|
|
38814
|
+
// when the agent row no longer exists at all — the ledger deliberately
|
|
38815
|
+
// outlives its attribution targets.
|
|
38816
|
+
agentName: external_exports.string().trim().min(1).nullable(),
|
|
38817
|
+
sessionCount: NonNegativeTokenCountSchema
|
|
38818
|
+
});
|
|
38819
|
+
var ProjectUsageModelSummarySchema = UsageTotalsSchema.extend({
|
|
38820
|
+
model: external_exports.string().trim().min(1)
|
|
38821
|
+
});
|
|
38822
|
+
var ProjectUsageSubscriptionSummarySchema = UsageTotalsSchema.extend({
|
|
38823
|
+
userSubscriptionId: UserSubscriptionCredentialIdSchema.nullable(),
|
|
38824
|
+
coveredInferenceCostUsd: NonNegativeUsdSchema2
|
|
38825
|
+
});
|
|
38826
|
+
var ProjectUsageSubscriptionSliceSchema = external_exports.object({
|
|
38827
|
+
totals: UsageTotalsSchema.extend({
|
|
38828
|
+
coveredInferenceCostUsd: NonNegativeUsdSchema2
|
|
38829
|
+
}),
|
|
38830
|
+
subscriptions: external_exports.array(ProjectUsageSubscriptionSummarySchema)
|
|
38831
|
+
});
|
|
38832
|
+
var ProjectUsageRequesterAttributionSchema = external_exports.object({
|
|
38833
|
+
requesterKey: external_exports.string().trim().min(1).nullable(),
|
|
38834
|
+
requesterDisplayName: external_exports.string().trim().min(1).nullable(),
|
|
38835
|
+
attributionEpochIds: external_exports.array(SessionAttributionEpochIdSchema),
|
|
38836
|
+
attributionGrades: external_exports.array(AttributionGradeSchema)
|
|
38837
|
+
});
|
|
38838
|
+
var ProjectUsageRequesterSummarySchema = UsageTotalsSchema.extend({
|
|
38839
|
+
...ProjectUsageRequesterAttributionSchema.shape,
|
|
38840
|
+
sessionCount: NonNegativeTokenCountSchema
|
|
38841
|
+
});
|
|
38842
|
+
var ProjectUsageDayAgentSliceSchema = external_exports.object({
|
|
38843
|
+
agentResourceId: external_exports.string().trim().min(1),
|
|
38844
|
+
billedCostUsd: NonNegativeUsdSchema2
|
|
38845
|
+
});
|
|
38846
|
+
var ProjectUsageDayModelSliceSchema = external_exports.object({
|
|
38847
|
+
model: external_exports.string().trim().min(1),
|
|
38848
|
+
billedCostUsd: NonNegativeUsdSchema2
|
|
38849
|
+
});
|
|
38850
|
+
var ProjectUsageDayPointSchema = UsageTotalsSchema.extend({
|
|
38851
|
+
date: UtcDateSchema,
|
|
38852
|
+
byAgent: external_exports.array(ProjectUsageDayAgentSliceSchema),
|
|
38853
|
+
byModel: external_exports.array(ProjectUsageDayModelSliceSchema)
|
|
38854
|
+
});
|
|
38855
|
+
var ProjectUsageResponseSchema = external_exports.object({
|
|
38856
|
+
organizationId: OrganizationIdSchema,
|
|
38857
|
+
projectId: ProjectIdSchema,
|
|
38858
|
+
range: external_exports.object({
|
|
38859
|
+
key: ProjectUsageRangeKeySchema,
|
|
38860
|
+
since: external_exports.string().datetime(),
|
|
38861
|
+
until: external_exports.string().datetime()
|
|
38862
|
+
}),
|
|
38863
|
+
totals: ProjectUsageTotalsSchema,
|
|
38864
|
+
taskThroughput: external_exports.object({
|
|
38865
|
+
created: external_exports.number().int().nonnegative(),
|
|
38866
|
+
completed: external_exports.number().int().nonnegative(),
|
|
38867
|
+
dropped: external_exports.number().int().nonnegative(),
|
|
38868
|
+
costPerCompletedTaskUsd: NonNegativeUsdSchema2.nullable()
|
|
38869
|
+
}).optional(),
|
|
38870
|
+
byAgent: external_exports.array(ProjectUsageAgentSummarySchema),
|
|
38871
|
+
byModel: external_exports.array(ProjectUsageModelSummarySchema),
|
|
38872
|
+
byFundingSource: external_exports.array(UsageFundingSummarySchema),
|
|
38873
|
+
subscriptionUsage: ProjectUsageSubscriptionSliceSchema,
|
|
38874
|
+
byRequester: external_exports.array(ProjectUsageRequesterSummarySchema),
|
|
38875
|
+
daily: external_exports.array(ProjectUsageDayPointSchema)
|
|
38876
|
+
});
|
|
38877
|
+
|
|
38659
38878
|
// ../../packages/schemas/src/session-introspection.ts
|
|
38660
38879
|
var TruncatedValueSchema = external_exports.object({
|
|
38661
38880
|
truncated: external_exports.literal(true),
|
|
@@ -38808,6 +39027,62 @@ var RunModelFallbackSchema = external_exports.object({
|
|
|
38808
39027
|
activatedAt: external_exports.string().datetime().nullable(),
|
|
38809
39028
|
fallbackModelId: external_exports.string().nullable()
|
|
38810
39029
|
});
|
|
39030
|
+
var RUN_USAGE_BREAKDOWN_LIMIT = 8;
|
|
39031
|
+
var RUN_USAGE_TURN_LIMIT = 50;
|
|
39032
|
+
var RunUsageTotalsSchema = external_exports.object({
|
|
39033
|
+
eventCount: external_exports.number().int().nonnegative(),
|
|
39034
|
+
inputTokens: external_exports.number().int().nonnegative(),
|
|
39035
|
+
outputTokens: external_exports.number().int().nonnegative(),
|
|
39036
|
+
cacheCreationTokens: external_exports.number().int().nonnegative(),
|
|
39037
|
+
cacheReadTokens: external_exports.number().int().nonnegative(),
|
|
39038
|
+
/**
|
|
39039
|
+
* Stored rate-card-derived model cost; never recomputed by this read.
|
|
39040
|
+
* Omitted when the caller lacks `billing:read`.
|
|
39041
|
+
*/
|
|
39042
|
+
derivedCostUsd: external_exports.number().nonnegative().optional(),
|
|
39043
|
+
/**
|
|
39044
|
+
* Sum of provider-reported costs only when every included event reported
|
|
39045
|
+
* one; null for empty, legacy, or partially reported groups, and omitted
|
|
39046
|
+
* when the caller lacks `billing:read`.
|
|
39047
|
+
*/
|
|
39048
|
+
providerCostUsd: external_exports.number().nonnegative().nullable().optional()
|
|
39049
|
+
});
|
|
39050
|
+
var RunUsageHarnessModelSchema = RunUsageTotalsSchema.extend({
|
|
39051
|
+
harness: UsageHarnessSchema,
|
|
39052
|
+
model: external_exports.string().trim().min(1)
|
|
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
|
+
});
|
|
39063
|
+
var RunUsageSummarySchema = external_exports.object({
|
|
39064
|
+
totals: RunUsageTotalsSchema,
|
|
39065
|
+
/**
|
|
39066
|
+
* Cache reads divided by prompt-side tokens: input + cache creation/write +
|
|
39067
|
+
* cache read. Output tokens are excluded; value is null when the exposed
|
|
39068
|
+
* denominator is zero.
|
|
39069
|
+
*/
|
|
39070
|
+
cacheReadRatio: external_exports.object({
|
|
39071
|
+
denominatorTokens: external_exports.number().int().nonnegative(),
|
|
39072
|
+
value: external_exports.number().min(0).max(1).nullable()
|
|
39073
|
+
}),
|
|
39074
|
+
/** Highest derived-cost harness/model groups, in descending spend order. */
|
|
39075
|
+
byHarnessModel: external_exports.array(RunUsageHarnessModelSchema).max(RUN_USAGE_BREAKDOWN_LIMIT),
|
|
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
|
|
39085
|
+
});
|
|
38811
39086
|
var RunSummarySchema = external_exports.object({
|
|
38812
39087
|
session: external_exports.object({
|
|
38813
39088
|
id: SessionIdSchema2,
|
|
@@ -38923,7 +39198,9 @@ var RunSummarySchema = external_exports.object({
|
|
|
38923
39198
|
recent: external_exports.array(RunRuntimeRestartSchema)
|
|
38924
39199
|
}),
|
|
38925
39200
|
/** Latest same-provider model-fallback activation for the session, if any. */
|
|
38926
|
-
modelFallback: RunModelFallbackSchema
|
|
39201
|
+
modelFallback: RunModelFallbackSchema,
|
|
39202
|
+
/** Current unsuperseded model usage for the session. */
|
|
39203
|
+
usage: RunUsageSummarySchema
|
|
38927
39204
|
});
|
|
38928
39205
|
|
|
38929
39206
|
// ../../packages/schemas/src/session-turns.ts
|
|
@@ -39220,33 +39497,6 @@ var SessionCommandDebounceRevertInputSchema = external_exports.object({
|
|
|
39220
39497
|
}).strip();
|
|
39221
39498
|
var RealtimeRunCursorSchema = external_exports.string().regex(/^rt:(0|[1-9]\d*)$/);
|
|
39222
39499
|
|
|
39223
|
-
// ../../packages/schemas/src/session-attribution-epochs.ts
|
|
39224
|
-
var ATTRIBUTION_GRADES = ["derived", "asserted"];
|
|
39225
|
-
var AttributionGradeSchema = external_exports.enum(ATTRIBUTION_GRADES);
|
|
39226
|
-
var AttributionRequesterSnapshotSchema = external_exports.object({
|
|
39227
|
-
origin: RequesterRootOriginSchema,
|
|
39228
|
-
userId: UserIdSchema.nullable()
|
|
39229
|
-
}).strict();
|
|
39230
|
-
var SessionAttributionEpochCreateSchema = external_exports.object({
|
|
39231
|
-
organizationId: OrganizationIdSchema,
|
|
39232
|
-
projectId: ProjectIdSchema.nullable(),
|
|
39233
|
-
sessionId: SessionIdSchema2,
|
|
39234
|
-
sourceCommandId: SessionCommandIdSchema2,
|
|
39235
|
-
requesterKey: external_exports.string().trim().min(1),
|
|
39236
|
-
requesterSnapshot: AttributionRequesterSnapshotSchema.nullable(),
|
|
39237
|
-
attributionGrade: AttributionGradeSchema,
|
|
39238
|
-
assertedByCommandId: SessionCommandIdSchema2.nullable(),
|
|
39239
|
-
assertedBySessionId: SessionIdSchema2.nullable(),
|
|
39240
|
-
assertedByAgentResourceId: external_exports.string().trim().min(1).nullable(),
|
|
39241
|
-
fundingSource: ModelCredentialFundingSourceSchema.nullable(),
|
|
39242
|
-
providerGrantId: ProviderGrantIdSchema.nullable(),
|
|
39243
|
-
userModelSubscriptionId: UserSubscriptionCredentialIdSchema.nullable()
|
|
39244
|
-
}).strict();
|
|
39245
|
-
var SessionAttributionEpochRecordSchema = SessionAttributionEpochCreateSchema.extend({
|
|
39246
|
-
id: SessionAttributionEpochIdSchema,
|
|
39247
|
-
createdAt: external_exports.string().datetime()
|
|
39248
|
-
}).strict();
|
|
39249
|
-
|
|
39250
39500
|
// ../../packages/schemas/src/spend-cap-runtime.ts
|
|
39251
39501
|
var SpendCapOverrideStateSchema = external_exports.object({
|
|
39252
39502
|
active: external_exports.boolean(),
|
|
@@ -39398,183 +39648,6 @@ var ResourceReconciliationScopeSchema = external_exports.object({
|
|
|
39398
39648
|
projectId: external_exports.string().trim().min(1).nullable()
|
|
39399
39649
|
}).strict();
|
|
39400
39650
|
|
|
39401
|
-
// ../../packages/schemas/src/usage.ts
|
|
39402
|
-
var UsageHarnessSchema = external_exports.enum(AGENT_HARNESSES);
|
|
39403
|
-
var NonNegativeTokenCountSchema = external_exports.number().int().nonnegative();
|
|
39404
|
-
var NonNegativeUsdSchema2 = external_exports.number().nonnegative();
|
|
39405
|
-
var UsageEventSchema = external_exports.object({
|
|
39406
|
-
// Tenant + lineage attribution. projectId is nullable because a resource can
|
|
39407
|
-
// belong directly to an organization with no project.
|
|
39408
|
-
organizationId: OrganizationIdSchema,
|
|
39409
|
-
projectId: ProjectIdSchema.nullable(),
|
|
39410
|
-
sessionId: SessionIdSchema2,
|
|
39411
|
-
agentResourceId: external_exports.string().trim().min(1),
|
|
39412
|
-
harness: UsageHarnessSchema,
|
|
39413
|
-
// The concrete model id the call billed against (e.g. "claude-opus-4-8"),
|
|
39414
|
-
// taken from the response rather than any selection layer — a single run can
|
|
39415
|
-
// touch multiple models, so this is per-call, never per-run.
|
|
39416
|
-
model: external_exports.string().trim().min(1),
|
|
39417
|
-
inputTokens: NonNegativeTokenCountSchema,
|
|
39418
|
-
outputTokens: NonNegativeTokenCountSchema,
|
|
39419
|
-
cacheCreationTokens: NonNegativeTokenCountSchema,
|
|
39420
|
-
cacheReadTokens: NonNegativeTokenCountSchema,
|
|
39421
|
-
// The provider's own cost when it reports one, kept only for reconciliation.
|
|
39422
|
-
// Nullable/absent because it can be 0 or missing — never the billing source.
|
|
39423
|
-
providerCostUsd: NonNegativeUsdSchema2.nullable(),
|
|
39424
|
-
// Platform-derived cost and the rate-card version it was derived under, so a
|
|
39425
|
-
// later rate-card change never silently rewrites historical cost.
|
|
39426
|
-
derivedCostUsd: NonNegativeUsdSchema2,
|
|
39427
|
-
pricingVersion: external_exports.string().trim().min(1),
|
|
39428
|
-
// What this call debits from the organization's credit balance, and the fee
|
|
39429
|
-
// card it was derived under (see `./billing`). Required — a writer that
|
|
39430
|
-
// forgets it would silently record unbilled usage, so there is no default.
|
|
39431
|
-
billedCostUsd: NonNegativeUsdSchema2,
|
|
39432
|
-
billingFeeVersion: external_exports.string().trim().min(1),
|
|
39433
|
-
// Historical funding attribution for the model call. The provider grant id is
|
|
39434
|
-
// denormalized and nullable for platform-funded usage, matching the ledger's
|
|
39435
|
-
// no-FK audit-trail contract.
|
|
39436
|
-
fundingSource: ModelCredentialFundingSourceSchema.default("platform"),
|
|
39437
|
-
modelCredentialProviderGrantId: ProviderGrantIdSchema.nullable().default(null),
|
|
39438
|
-
// Optional during the cross-chunk rollout: B1 defines the attribution field
|
|
39439
|
-
// before B3 deploys its persistence column and D3 begins populating it.
|
|
39440
|
-
modelCredentialUserSubscriptionId: UserSubscriptionCredentialIdSchema.nullable().optional(),
|
|
39441
|
-
attributionEpochId: SessionAttributionEpochIdSchema.nullable().optional(),
|
|
39442
|
-
requesterKey: external_exports.string().trim().min(1).nullable().optional(),
|
|
39443
|
-
attributionGrade: AttributionGradeSchema.nullable().optional(),
|
|
39444
|
-
occurredAt: external_exports.string().datetime()
|
|
39445
|
-
});
|
|
39446
|
-
var UsageEventRecordSchema = UsageEventSchema.extend({
|
|
39447
|
-
id: external_exports.string().trim().min(1),
|
|
39448
|
-
attributionEpochId: SessionAttributionEpochIdSchema.nullable().default(null),
|
|
39449
|
-
requesterKey: external_exports.string().trim().min(1).nullable().default(null),
|
|
39450
|
-
attributionGrade: AttributionGradeSchema.nullable().default(null),
|
|
39451
|
-
// Set on append-only correction rows: this row replaces the pointed-at row's
|
|
39452
|
-
// amounts, and ledger readers exclude any row another row supersedes.
|
|
39453
|
-
supersedesUsageEventId: external_exports.string().trim().min(1).nullable().default(null),
|
|
39454
|
-
createdAt: external_exports.string().datetime()
|
|
39455
|
-
});
|
|
39456
|
-
var UsageTotalsSchema = external_exports.object({
|
|
39457
|
-
eventCount: NonNegativeTokenCountSchema,
|
|
39458
|
-
inputTokens: NonNegativeTokenCountSchema,
|
|
39459
|
-
outputTokens: NonNegativeTokenCountSchema,
|
|
39460
|
-
cacheCreationTokens: NonNegativeTokenCountSchema,
|
|
39461
|
-
cacheReadTokens: NonNegativeTokenCountSchema,
|
|
39462
|
-
totalTokens: NonNegativeTokenCountSchema,
|
|
39463
|
-
billedCostUsd: NonNegativeUsdSchema2
|
|
39464
|
-
});
|
|
39465
|
-
var SessionUsageModelSummarySchema = UsageTotalsSchema.extend({
|
|
39466
|
-
model: external_exports.string().trim().min(1)
|
|
39467
|
-
});
|
|
39468
|
-
var UsageFundingSummarySchema = UsageTotalsSchema.extend({
|
|
39469
|
-
fundingSource: ModelCredentialFundingSourceSchema,
|
|
39470
|
-
coveredInferenceCostUsd: NonNegativeUsdSchema2
|
|
39471
|
-
});
|
|
39472
|
-
var SessionModelFundingStateSchema = external_exports.object({
|
|
39473
|
-
fundingSource: ModelCredentialFundingSourceSchema,
|
|
39474
|
-
provider: external_exports.string().trim().min(1),
|
|
39475
|
-
// The subscription owner's display name for user_subscription funding, so
|
|
39476
|
-
// the session header can say whose key is being used. Optional for old
|
|
39477
|
-
// writers; null when the name cannot resolve.
|
|
39478
|
-
ownerDisplayName: external_exports.string().trim().min(1).nullable().optional()
|
|
39479
|
-
});
|
|
39480
|
-
var SessionUsageCurrentAttributionSchema = external_exports.object({
|
|
39481
|
-
requesterKey: external_exports.string().trim().min(1),
|
|
39482
|
-
requesterDisplayName: external_exports.string().trim().min(1).nullable(),
|
|
39483
|
-
attributionGrade: AttributionGradeSchema
|
|
39484
|
-
}).strip();
|
|
39485
|
-
var SessionUsageRequesterSummarySchema = external_exports.object({
|
|
39486
|
-
requesterKey: external_exports.string().trim().min(1).nullable(),
|
|
39487
|
-
requesterDisplayName: external_exports.string().trim().min(1).nullable(),
|
|
39488
|
-
billedCostUsd: NonNegativeUsdSchema2,
|
|
39489
|
-
attributionGrades: external_exports.array(AttributionGradeSchema)
|
|
39490
|
-
}).strip();
|
|
39491
|
-
var SessionUsageResponseSchema = external_exports.object({
|
|
39492
|
-
sessionId: SessionIdSchema2,
|
|
39493
|
-
totals: UsageTotalsSchema,
|
|
39494
|
-
models: external_exports.array(SessionUsageModelSummarySchema),
|
|
39495
|
-
byFundingSource: external_exports.array(UsageFundingSummarySchema),
|
|
39496
|
-
byRequester: external_exports.array(SessionUsageRequesterSummarySchema).optional().default([]),
|
|
39497
|
-
currentAttribution: SessionUsageCurrentAttributionSchema.nullable().optional().default(null),
|
|
39498
|
-
funding: SessionModelFundingStateSchema.nullable(),
|
|
39499
|
-
firstUsageAt: external_exports.string().datetime().nullable(),
|
|
39500
|
-
lastUsageAt: external_exports.string().datetime().nullable()
|
|
39501
|
-
}).strip();
|
|
39502
|
-
var PROJECT_USAGE_RANGE_KEYS = ["7d", "30d"];
|
|
39503
|
-
var ProjectUsageRangeKeySchema = external_exports.enum(PROJECT_USAGE_RANGE_KEYS);
|
|
39504
|
-
var UtcDateSchema = external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/);
|
|
39505
|
-
var ProjectUsageTotalsSchema = UsageTotalsSchema.extend({
|
|
39506
|
-
sessionCount: NonNegativeTokenCountSchema,
|
|
39507
|
-
// Share of all tokens served from prompt-cache reads (0..1); 0 when the
|
|
39508
|
-
// window has no tokens at all.
|
|
39509
|
-
cacheReadShare: external_exports.number().min(0).max(1)
|
|
39510
|
-
});
|
|
39511
|
-
var ProjectUsageAgentSummarySchema = UsageTotalsSchema.extend({
|
|
39512
|
-
agentResourceId: external_exports.string().trim().min(1),
|
|
39513
|
-
// Resolved from the agent resource (archived agents included); null only
|
|
39514
|
-
// when the agent row no longer exists at all — the ledger deliberately
|
|
39515
|
-
// outlives its attribution targets.
|
|
39516
|
-
agentName: external_exports.string().trim().min(1).nullable(),
|
|
39517
|
-
sessionCount: NonNegativeTokenCountSchema
|
|
39518
|
-
});
|
|
39519
|
-
var ProjectUsageModelSummarySchema = UsageTotalsSchema.extend({
|
|
39520
|
-
model: external_exports.string().trim().min(1)
|
|
39521
|
-
});
|
|
39522
|
-
var ProjectUsageSubscriptionSummarySchema = UsageTotalsSchema.extend({
|
|
39523
|
-
userSubscriptionId: UserSubscriptionCredentialIdSchema.nullable(),
|
|
39524
|
-
coveredInferenceCostUsd: NonNegativeUsdSchema2
|
|
39525
|
-
});
|
|
39526
|
-
var ProjectUsageSubscriptionSliceSchema = external_exports.object({
|
|
39527
|
-
totals: UsageTotalsSchema.extend({
|
|
39528
|
-
coveredInferenceCostUsd: NonNegativeUsdSchema2
|
|
39529
|
-
}),
|
|
39530
|
-
subscriptions: external_exports.array(ProjectUsageSubscriptionSummarySchema)
|
|
39531
|
-
});
|
|
39532
|
-
var ProjectUsageRequesterAttributionSchema = external_exports.object({
|
|
39533
|
-
requesterKey: external_exports.string().trim().min(1).nullable(),
|
|
39534
|
-
requesterDisplayName: external_exports.string().trim().min(1).nullable(),
|
|
39535
|
-
attributionEpochIds: external_exports.array(SessionAttributionEpochIdSchema),
|
|
39536
|
-
attributionGrades: external_exports.array(AttributionGradeSchema)
|
|
39537
|
-
});
|
|
39538
|
-
var ProjectUsageRequesterSummarySchema = UsageTotalsSchema.extend({
|
|
39539
|
-
...ProjectUsageRequesterAttributionSchema.shape,
|
|
39540
|
-
sessionCount: NonNegativeTokenCountSchema
|
|
39541
|
-
});
|
|
39542
|
-
var ProjectUsageDayAgentSliceSchema = external_exports.object({
|
|
39543
|
-
agentResourceId: external_exports.string().trim().min(1),
|
|
39544
|
-
billedCostUsd: NonNegativeUsdSchema2
|
|
39545
|
-
});
|
|
39546
|
-
var ProjectUsageDayModelSliceSchema = external_exports.object({
|
|
39547
|
-
model: external_exports.string().trim().min(1),
|
|
39548
|
-
billedCostUsd: NonNegativeUsdSchema2
|
|
39549
|
-
});
|
|
39550
|
-
var ProjectUsageDayPointSchema = UsageTotalsSchema.extend({
|
|
39551
|
-
date: UtcDateSchema,
|
|
39552
|
-
byAgent: external_exports.array(ProjectUsageDayAgentSliceSchema),
|
|
39553
|
-
byModel: external_exports.array(ProjectUsageDayModelSliceSchema)
|
|
39554
|
-
});
|
|
39555
|
-
var ProjectUsageResponseSchema = external_exports.object({
|
|
39556
|
-
organizationId: OrganizationIdSchema,
|
|
39557
|
-
projectId: ProjectIdSchema,
|
|
39558
|
-
range: external_exports.object({
|
|
39559
|
-
key: ProjectUsageRangeKeySchema,
|
|
39560
|
-
since: external_exports.string().datetime(),
|
|
39561
|
-
until: external_exports.string().datetime()
|
|
39562
|
-
}),
|
|
39563
|
-
totals: ProjectUsageTotalsSchema,
|
|
39564
|
-
taskThroughput: external_exports.object({
|
|
39565
|
-
created: external_exports.number().int().nonnegative(),
|
|
39566
|
-
completed: external_exports.number().int().nonnegative(),
|
|
39567
|
-
dropped: external_exports.number().int().nonnegative(),
|
|
39568
|
-
costPerCompletedTaskUsd: NonNegativeUsdSchema2.nullable()
|
|
39569
|
-
}).optional(),
|
|
39570
|
-
byAgent: external_exports.array(ProjectUsageAgentSummarySchema),
|
|
39571
|
-
byModel: external_exports.array(ProjectUsageModelSummarySchema),
|
|
39572
|
-
byFundingSource: external_exports.array(UsageFundingSummarySchema),
|
|
39573
|
-
subscriptionUsage: ProjectUsageSubscriptionSliceSchema,
|
|
39574
|
-
byRequester: external_exports.array(ProjectUsageRequesterSummarySchema),
|
|
39575
|
-
daily: external_exports.array(ProjectUsageDayPointSchema)
|
|
39576
|
-
});
|
|
39577
|
-
|
|
39578
39651
|
// ../../packages/schemas/src/user-subscriptions.ts
|
|
39579
39652
|
var ATTRIBUTION_COLD_BOUNDARY_IDLE_MS = 5 * 6e4;
|
|
39580
39653
|
var USER_SUBSCRIPTION_PROVIDERS = ["openai"];
|
|
@@ -71868,6 +71941,9 @@ function replacePayloadWithMarker(envelope, originalBytes) {
|
|
|
71868
71941
|
parts: [{ type: "text", text: text2, state: "done" }]
|
|
71869
71942
|
}
|
|
71870
71943
|
};
|
|
71944
|
+
case "runtime.liveness":
|
|
71945
|
+
case "runtime.usage_turn":
|
|
71946
|
+
return envelope;
|
|
71871
71947
|
}
|
|
71872
71948
|
}
|
|
71873
71949
|
|
|
@@ -72300,6 +72376,23 @@ var AgentBridgeOutputBuffer = class {
|
|
|
72300
72376
|
);
|
|
72301
72377
|
await this.drainPendingOutputs();
|
|
72302
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
|
+
}
|
|
72303
72396
|
async emitUiMessageChunk(context, projection) {
|
|
72304
72397
|
await this.flushPendingDelta();
|
|
72305
72398
|
await this.emitLiveUiMessageChunk(context, projection.chunk);
|
|
@@ -73080,6 +73173,18 @@ function buildLivenessOutputEnvelope(input) {
|
|
|
73080
73173
|
createdAt: input.createdAt
|
|
73081
73174
|
});
|
|
73082
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
|
+
}
|
|
73083
73188
|
function buildUiMessagePartOutputEnvelope(input) {
|
|
73084
73189
|
const { context, snapshot } = input;
|
|
73085
73190
|
return RuntimeBridgeOutputEnvelopeSchema.parse({
|
|
@@ -74364,7 +74469,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
74364
74469
|
return;
|
|
74365
74470
|
}
|
|
74366
74471
|
await this.awaitMcpRegistration();
|
|
74367
|
-
this.enqueueUserMessage(message, commandIds);
|
|
74472
|
+
await this.enqueueUserMessage(message, commandIds);
|
|
74368
74473
|
this.input.runtimeLogger?.info("agent_bridge_claude_send_message_queued", {
|
|
74369
74474
|
delivery_mode: mode,
|
|
74370
74475
|
duration_ms: Date.now() - startedAt,
|
|
@@ -74470,6 +74575,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
74470
74575
|
}
|
|
74471
74576
|
this.openTurnCommandIds.length = 0;
|
|
74472
74577
|
this.publishActiveTurnCommandIds();
|
|
74578
|
+
void this.input.onUsageTurnChanged?.(null);
|
|
74473
74579
|
this.stderr.flush();
|
|
74474
74580
|
this.inputQueue.close();
|
|
74475
74581
|
if (previousState.kind === "started") {
|
|
@@ -74563,6 +74669,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
74563
74669
|
consumedCommandIds: this.openTurnCommandIds.shift() ?? []
|
|
74564
74670
|
};
|
|
74565
74671
|
this.publishActiveTurnCommandIds();
|
|
74672
|
+
await this.input.onUsageTurnChanged?.(null);
|
|
74566
74673
|
this.pendingToolUses.clear();
|
|
74567
74674
|
this.interruptSettling = false;
|
|
74568
74675
|
this.turnResultCount += 1;
|
|
@@ -74574,7 +74681,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
74574
74681
|
consumed_command_ids: meta3.consumedCommandIds
|
|
74575
74682
|
});
|
|
74576
74683
|
if (this.activeTurnCount === 0) {
|
|
74577
|
-
this.flushDeferredMessages();
|
|
74684
|
+
await this.flushDeferredMessages();
|
|
74578
74685
|
}
|
|
74579
74686
|
if (this.deferredMessages.length === 0) {
|
|
74580
74687
|
this.cancelledToolRuns = [];
|
|
@@ -74604,6 +74711,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
74604
74711
|
this.activeTurnCount = 0;
|
|
74605
74712
|
this.openTurnCommandIds.length = 0;
|
|
74606
74713
|
this.publishActiveTurnCommandIds();
|
|
74714
|
+
await this.input.onUsageTurnChanged?.(null);
|
|
74607
74715
|
this.pendingToolUses.clear();
|
|
74608
74716
|
this.interruptSettling = false;
|
|
74609
74717
|
this.disarmToolBoundaryWait();
|
|
@@ -74616,7 +74724,8 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
74616
74724
|
// lets injection work while the SDK session is still starting; the queue
|
|
74617
74725
|
// drains once the query attaches. Startup failures surface through onError
|
|
74618
74726
|
// instead of failing injection.
|
|
74619
|
-
enqueueUserMessage(message, commandIds) {
|
|
74727
|
+
async enqueueUserMessage(message, commandIds) {
|
|
74728
|
+
await this.input.onUsageTurnChanged?.(commandIds[0] ?? null);
|
|
74620
74729
|
this.inputQueue.push(claudeAgentUserMessage(message));
|
|
74621
74730
|
this.activeTurnCount += 1;
|
|
74622
74731
|
this.openTurnCommandIds.push(commandIds);
|
|
@@ -74724,7 +74833,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
74724
74833
|
clearTimeout(this.toolBoundaryWait.timer);
|
|
74725
74834
|
this.toolBoundaryWait = null;
|
|
74726
74835
|
}
|
|
74727
|
-
flushDeferredMessages() {
|
|
74836
|
+
async flushDeferredMessages() {
|
|
74728
74837
|
if (this.deferredMessages.length === 0) {
|
|
74729
74838
|
return;
|
|
74730
74839
|
}
|
|
@@ -74735,7 +74844,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
74735
74844
|
`agent_bridge_claude_deferred_flush count=${pending.length} cancelled_tool_count=${cancelledToolRuns.length}`
|
|
74736
74845
|
);
|
|
74737
74846
|
const text2 = pending.map((entry) => entry.text).join("\n\n");
|
|
74738
|
-
this.enqueueUserMessage(
|
|
74847
|
+
await this.enqueueUserMessage(
|
|
74739
74848
|
cancelledToolRuns.length > 0 ? `${text2}
|
|
74740
74849
|
|
|
74741
74850
|
${cancelledToolPlatformNotice(cancelledToolRuns)}` : text2,
|
|
@@ -75652,6 +75761,13 @@ var ClaudeCodeCommandHandler = class {
|
|
|
75652
75761
|
RUNTIME_LIVENESS_INTERVAL_MS
|
|
75653
75762
|
);
|
|
75654
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
|
+
}
|
|
75655
75771
|
async emitBridgeOutput(activeContext, projection) {
|
|
75656
75772
|
try {
|
|
75657
75773
|
await this.outputBuffer.emitProjection(activeContext, projection);
|
|
@@ -75819,6 +75935,7 @@ var ClaudeCodeCommandHandler = class {
|
|
|
75819
75935
|
}
|
|
75820
75936
|
},
|
|
75821
75937
|
onActiveTurnCommandIds: (commandIds) => this.autoMcpShim.setActiveTurnCommandIds(commandIds),
|
|
75938
|
+
onUsageTurnChanged: (turnId) => this.emitUsageTurn(turnId),
|
|
75822
75939
|
canUseTool: this.canUseTool,
|
|
75823
75940
|
onMessage: (message, meta3) => this.handleAgentMessage(message, meta3),
|
|
75824
75941
|
onError: (error51) => this.handleAgentError(error51),
|
|
@@ -77027,6 +77144,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
77027
77144
|
this.pendingCommandIds = [...commandIds];
|
|
77028
77145
|
this.publishActiveTurnCommandIds(commandIds);
|
|
77029
77146
|
try {
|
|
77147
|
+
await this.input.onUsageTurnChanged?.(commandIds[0] ?? null);
|
|
77030
77148
|
await this.request("turn/start", {
|
|
77031
77149
|
threadId,
|
|
77032
77150
|
input: [userTextInput(message)]
|
|
@@ -77034,6 +77152,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
77034
77152
|
} catch (error51) {
|
|
77035
77153
|
this.pendingCommandIds = [];
|
|
77036
77154
|
this.publishActiveTurnCommandIds();
|
|
77155
|
+
await this.input.onUsageTurnChanged?.(null);
|
|
77037
77156
|
throw error51;
|
|
77038
77157
|
}
|
|
77039
77158
|
}
|
|
@@ -77041,6 +77160,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
77041
77160
|
this.pendingCommandIds = [...commandIds];
|
|
77042
77161
|
this.publishActiveTurnCommandIds(commandIds);
|
|
77043
77162
|
try {
|
|
77163
|
+
await this.input.onUsageTurnChanged?.(commandIds[0] ?? null);
|
|
77044
77164
|
await this.request("turn/start", {
|
|
77045
77165
|
threadId,
|
|
77046
77166
|
input: []
|
|
@@ -77048,6 +77168,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
77048
77168
|
} catch (error51) {
|
|
77049
77169
|
this.pendingCommandIds = [];
|
|
77050
77170
|
this.publishActiveTurnCommandIds();
|
|
77171
|
+
await this.input.onUsageTurnChanged?.(null);
|
|
77051
77172
|
throw error51;
|
|
77052
77173
|
}
|
|
77053
77174
|
}
|
|
@@ -77411,6 +77532,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
77411
77532
|
this.activeTurnId = null;
|
|
77412
77533
|
this.activeCommandIds = [];
|
|
77413
77534
|
this.publishActiveTurnCommandIds();
|
|
77535
|
+
void this.input.onUsageTurnChanged?.(null);
|
|
77414
77536
|
}
|
|
77415
77537
|
this.pendingToolItemIds.clear();
|
|
77416
77538
|
this.resolveSettlement();
|
|
@@ -77426,6 +77548,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
77426
77548
|
this.activeCommandIds = [];
|
|
77427
77549
|
this.pendingCommandIds = [];
|
|
77428
77550
|
this.publishActiveTurnCommandIds();
|
|
77551
|
+
void this.input.onUsageTurnChanged?.(null);
|
|
77429
77552
|
this.pendingToolItemIds.clear();
|
|
77430
77553
|
this.resolveSettlement();
|
|
77431
77554
|
this.input.writeOutput?.(`agent_bridge_codex_exited code=${code ?? ""}`);
|
|
@@ -77821,6 +77944,13 @@ var CodexCommandHandler = class {
|
|
|
77821
77944
|
RUNTIME_LIVENESS_INTERVAL_MS
|
|
77822
77945
|
);
|
|
77823
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
|
+
}
|
|
77824
77954
|
async emit(activeContext, projection) {
|
|
77825
77955
|
try {
|
|
77826
77956
|
await this.outputBuffer.emitProjection(activeContext, projection);
|
|
@@ -77843,6 +77973,7 @@ var CodexCommandHandler = class {
|
|
|
77843
77973
|
onServerRequest: (request) => this.handleServerRequest(request),
|
|
77844
77974
|
onThreadId: (threadId) => this.persistThreadId(threadId),
|
|
77845
77975
|
onActiveTurnCommandIds: (commandIds) => this.autoMcpShim.setActiveTurnCommandIds(commandIds),
|
|
77976
|
+
onUsageTurnChanged: (turnId) => this.emitUsageTurn(turnId),
|
|
77846
77977
|
onError: (error51) => this.handleSessionError(error51),
|
|
77847
77978
|
onExit: () => {
|
|
77848
77979
|
if (this.session === session) {
|