@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/index.js
CHANGED
|
@@ -23003,8 +23003,239 @@ var init_runtime_restart_diagnostics = __esm({
|
|
|
23003
23003
|
}
|
|
23004
23004
|
});
|
|
23005
23005
|
|
|
23006
|
+
// ../../packages/schemas/src/session-attribution-epochs.ts
|
|
23007
|
+
var ATTRIBUTION_GRADES, AttributionGradeSchema, AttributionRequesterSnapshotSchema, SessionAttributionEpochCreateSchema, SessionAttributionEpochRecordSchema;
|
|
23008
|
+
var init_session_attribution_epochs = __esm({
|
|
23009
|
+
"../../packages/schemas/src/session-attribution-epochs.ts"() {
|
|
23010
|
+
"use strict";
|
|
23011
|
+
init_zod();
|
|
23012
|
+
init_ids();
|
|
23013
|
+
init_model_credential_funding();
|
|
23014
|
+
init_requester();
|
|
23015
|
+
ATTRIBUTION_GRADES = ["derived", "asserted"];
|
|
23016
|
+
AttributionGradeSchema = external_exports.enum(ATTRIBUTION_GRADES);
|
|
23017
|
+
AttributionRequesterSnapshotSchema = external_exports.object({
|
|
23018
|
+
origin: RequesterRootOriginSchema,
|
|
23019
|
+
userId: UserIdSchema.nullable()
|
|
23020
|
+
}).strict();
|
|
23021
|
+
SessionAttributionEpochCreateSchema = external_exports.object({
|
|
23022
|
+
organizationId: OrganizationIdSchema,
|
|
23023
|
+
projectId: ProjectIdSchema.nullable(),
|
|
23024
|
+
sessionId: SessionIdSchema,
|
|
23025
|
+
sourceCommandId: SessionCommandIdSchema,
|
|
23026
|
+
requesterKey: external_exports.string().trim().min(1),
|
|
23027
|
+
requesterSnapshot: AttributionRequesterSnapshotSchema.nullable(),
|
|
23028
|
+
attributionGrade: AttributionGradeSchema,
|
|
23029
|
+
assertedByCommandId: SessionCommandIdSchema.nullable(),
|
|
23030
|
+
assertedBySessionId: SessionIdSchema.nullable(),
|
|
23031
|
+
assertedByAgentResourceId: external_exports.string().trim().min(1).nullable(),
|
|
23032
|
+
fundingSource: ModelCredentialFundingSourceSchema.nullable(),
|
|
23033
|
+
providerGrantId: ProviderGrantIdSchema.nullable(),
|
|
23034
|
+
userModelSubscriptionId: UserSubscriptionCredentialIdSchema.nullable()
|
|
23035
|
+
}).strict();
|
|
23036
|
+
SessionAttributionEpochRecordSchema = SessionAttributionEpochCreateSchema.extend({
|
|
23037
|
+
id: SessionAttributionEpochIdSchema,
|
|
23038
|
+
createdAt: external_exports.string().datetime()
|
|
23039
|
+
}).strict();
|
|
23040
|
+
}
|
|
23041
|
+
});
|
|
23042
|
+
|
|
23043
|
+
// ../../packages/schemas/src/usage.ts
|
|
23044
|
+
var UsageHarnessSchema, NonNegativeTokenCountSchema, NonNegativeUsdSchema2, UsageEventSchema, UsageEventRecordSchema, UsageTotalsSchema, SessionUsageModelSummarySchema, UsageFundingSummarySchema, SessionModelFundingStateSchema, SessionUsageCurrentAttributionSchema, SessionUsageRequesterSummarySchema, SessionUsageResponseSchema, PROJECT_USAGE_RANGE_KEYS, ProjectUsageRangeKeySchema, UtcDateSchema, ProjectUsageTotalsSchema, ProjectUsageAgentSummarySchema, ProjectUsageModelSummarySchema, ProjectUsageSubscriptionSummarySchema, ProjectUsageSubscriptionSliceSchema, ProjectUsageRequesterAttributionSchema, ProjectUsageRequesterSummarySchema, ProjectUsageDayAgentSliceSchema, ProjectUsageDayModelSliceSchema, ProjectUsageDayPointSchema, ProjectUsageResponseSchema;
|
|
23045
|
+
var init_usage = __esm({
|
|
23046
|
+
"../../packages/schemas/src/usage.ts"() {
|
|
23047
|
+
"use strict";
|
|
23048
|
+
init_zod();
|
|
23049
|
+
init_agents();
|
|
23050
|
+
init_ids();
|
|
23051
|
+
init_model_credential_funding();
|
|
23052
|
+
init_session_attribution_epochs();
|
|
23053
|
+
init_model_credential_funding();
|
|
23054
|
+
UsageHarnessSchema = external_exports.enum(AGENT_HARNESSES);
|
|
23055
|
+
NonNegativeTokenCountSchema = external_exports.number().int().nonnegative();
|
|
23056
|
+
NonNegativeUsdSchema2 = external_exports.number().nonnegative();
|
|
23057
|
+
UsageEventSchema = external_exports.object({
|
|
23058
|
+
// Tenant + lineage attribution. projectId is nullable because a resource can
|
|
23059
|
+
// belong directly to an organization with no project.
|
|
23060
|
+
organizationId: OrganizationIdSchema,
|
|
23061
|
+
projectId: ProjectIdSchema.nullable(),
|
|
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(),
|
|
23067
|
+
agentResourceId: external_exports.string().trim().min(1),
|
|
23068
|
+
harness: UsageHarnessSchema,
|
|
23069
|
+
// The concrete model id the call billed against (e.g. "claude-opus-4-8"),
|
|
23070
|
+
// taken from the response rather than any selection layer — a single run can
|
|
23071
|
+
// touch multiple models, so this is per-call, never per-run.
|
|
23072
|
+
model: external_exports.string().trim().min(1),
|
|
23073
|
+
inputTokens: NonNegativeTokenCountSchema,
|
|
23074
|
+
outputTokens: NonNegativeTokenCountSchema,
|
|
23075
|
+
cacheCreationTokens: NonNegativeTokenCountSchema,
|
|
23076
|
+
cacheReadTokens: NonNegativeTokenCountSchema,
|
|
23077
|
+
// The provider's own cost when it reports one, kept only for reconciliation.
|
|
23078
|
+
// Nullable/absent because it can be 0 or missing — never the billing source.
|
|
23079
|
+
providerCostUsd: NonNegativeUsdSchema2.nullable(),
|
|
23080
|
+
// Platform-derived cost and the rate-card version it was derived under, so a
|
|
23081
|
+
// later rate-card change never silently rewrites historical cost.
|
|
23082
|
+
derivedCostUsd: NonNegativeUsdSchema2,
|
|
23083
|
+
pricingVersion: external_exports.string().trim().min(1),
|
|
23084
|
+
// What this call debits from the organization's credit balance, and the fee
|
|
23085
|
+
// card it was derived under (see `./billing`). Required — a writer that
|
|
23086
|
+
// forgets it would silently record unbilled usage, so there is no default.
|
|
23087
|
+
billedCostUsd: NonNegativeUsdSchema2,
|
|
23088
|
+
billingFeeVersion: external_exports.string().trim().min(1),
|
|
23089
|
+
// Historical funding attribution for the model call. The provider grant id is
|
|
23090
|
+
// denormalized and nullable for platform-funded usage, matching the ledger's
|
|
23091
|
+
// no-FK audit-trail contract.
|
|
23092
|
+
fundingSource: ModelCredentialFundingSourceSchema.default("platform"),
|
|
23093
|
+
modelCredentialProviderGrantId: ProviderGrantIdSchema.nullable().default(null),
|
|
23094
|
+
// Optional during the cross-chunk rollout: B1 defines the attribution field
|
|
23095
|
+
// before B3 deploys its persistence column and D3 begins populating it.
|
|
23096
|
+
modelCredentialUserSubscriptionId: UserSubscriptionCredentialIdSchema.nullable().optional(),
|
|
23097
|
+
attributionEpochId: SessionAttributionEpochIdSchema.nullable().optional(),
|
|
23098
|
+
requesterKey: external_exports.string().trim().min(1).nullable().optional(),
|
|
23099
|
+
attributionGrade: AttributionGradeSchema.nullable().optional(),
|
|
23100
|
+
occurredAt: external_exports.string().datetime()
|
|
23101
|
+
});
|
|
23102
|
+
UsageEventRecordSchema = UsageEventSchema.extend({
|
|
23103
|
+
id: external_exports.string().trim().min(1),
|
|
23104
|
+
turnId: SessionCommandIdSchema.nullable().default(null),
|
|
23105
|
+
attributionEpochId: SessionAttributionEpochIdSchema.nullable().default(null),
|
|
23106
|
+
requesterKey: external_exports.string().trim().min(1).nullable().default(null),
|
|
23107
|
+
attributionGrade: AttributionGradeSchema.nullable().default(null),
|
|
23108
|
+
// Set on append-only correction rows: this row replaces the pointed-at row's
|
|
23109
|
+
// amounts, and ledger readers exclude any row another row supersedes.
|
|
23110
|
+
supersedesUsageEventId: external_exports.string().trim().min(1).nullable().default(null),
|
|
23111
|
+
createdAt: external_exports.string().datetime()
|
|
23112
|
+
});
|
|
23113
|
+
UsageTotalsSchema = external_exports.object({
|
|
23114
|
+
eventCount: NonNegativeTokenCountSchema,
|
|
23115
|
+
inputTokens: NonNegativeTokenCountSchema,
|
|
23116
|
+
outputTokens: NonNegativeTokenCountSchema,
|
|
23117
|
+
cacheCreationTokens: NonNegativeTokenCountSchema,
|
|
23118
|
+
cacheReadTokens: NonNegativeTokenCountSchema,
|
|
23119
|
+
totalTokens: NonNegativeTokenCountSchema,
|
|
23120
|
+
billedCostUsd: NonNegativeUsdSchema2
|
|
23121
|
+
});
|
|
23122
|
+
SessionUsageModelSummarySchema = UsageTotalsSchema.extend({
|
|
23123
|
+
model: external_exports.string().trim().min(1)
|
|
23124
|
+
});
|
|
23125
|
+
UsageFundingSummarySchema = UsageTotalsSchema.extend({
|
|
23126
|
+
fundingSource: ModelCredentialFundingSourceSchema,
|
|
23127
|
+
coveredInferenceCostUsd: NonNegativeUsdSchema2
|
|
23128
|
+
});
|
|
23129
|
+
SessionModelFundingStateSchema = external_exports.object({
|
|
23130
|
+
fundingSource: ModelCredentialFundingSourceSchema,
|
|
23131
|
+
provider: external_exports.string().trim().min(1),
|
|
23132
|
+
// The subscription owner's display name for user_subscription funding, so
|
|
23133
|
+
// the session header can say whose key is being used. Optional for old
|
|
23134
|
+
// writers; null when the name cannot resolve.
|
|
23135
|
+
ownerDisplayName: external_exports.string().trim().min(1).nullable().optional()
|
|
23136
|
+
});
|
|
23137
|
+
SessionUsageCurrentAttributionSchema = external_exports.object({
|
|
23138
|
+
requesterKey: external_exports.string().trim().min(1),
|
|
23139
|
+
requesterDisplayName: external_exports.string().trim().min(1).nullable(),
|
|
23140
|
+
attributionGrade: AttributionGradeSchema
|
|
23141
|
+
}).strip();
|
|
23142
|
+
SessionUsageRequesterSummarySchema = external_exports.object({
|
|
23143
|
+
requesterKey: external_exports.string().trim().min(1).nullable(),
|
|
23144
|
+
requesterDisplayName: external_exports.string().trim().min(1).nullable(),
|
|
23145
|
+
billedCostUsd: NonNegativeUsdSchema2,
|
|
23146
|
+
attributionGrades: external_exports.array(AttributionGradeSchema)
|
|
23147
|
+
}).strip();
|
|
23148
|
+
SessionUsageResponseSchema = external_exports.object({
|
|
23149
|
+
sessionId: SessionIdSchema,
|
|
23150
|
+
totals: UsageTotalsSchema,
|
|
23151
|
+
models: external_exports.array(SessionUsageModelSummarySchema),
|
|
23152
|
+
byFundingSource: external_exports.array(UsageFundingSummarySchema),
|
|
23153
|
+
byRequester: external_exports.array(SessionUsageRequesterSummarySchema).optional().default([]),
|
|
23154
|
+
currentAttribution: SessionUsageCurrentAttributionSchema.nullable().optional().default(null),
|
|
23155
|
+
funding: SessionModelFundingStateSchema.nullable(),
|
|
23156
|
+
firstUsageAt: external_exports.string().datetime().nullable(),
|
|
23157
|
+
lastUsageAt: external_exports.string().datetime().nullable()
|
|
23158
|
+
}).strip();
|
|
23159
|
+
PROJECT_USAGE_RANGE_KEYS = ["7d", "30d"];
|
|
23160
|
+
ProjectUsageRangeKeySchema = external_exports.enum(PROJECT_USAGE_RANGE_KEYS);
|
|
23161
|
+
UtcDateSchema = external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/);
|
|
23162
|
+
ProjectUsageTotalsSchema = UsageTotalsSchema.extend({
|
|
23163
|
+
sessionCount: NonNegativeTokenCountSchema,
|
|
23164
|
+
// Share of all tokens served from prompt-cache reads (0..1); 0 when the
|
|
23165
|
+
// window has no tokens at all.
|
|
23166
|
+
cacheReadShare: external_exports.number().min(0).max(1)
|
|
23167
|
+
});
|
|
23168
|
+
ProjectUsageAgentSummarySchema = UsageTotalsSchema.extend({
|
|
23169
|
+
agentResourceId: external_exports.string().trim().min(1),
|
|
23170
|
+
// Resolved from the agent resource (archived agents included); null only
|
|
23171
|
+
// when the agent row no longer exists at all — the ledger deliberately
|
|
23172
|
+
// outlives its attribution targets.
|
|
23173
|
+
agentName: external_exports.string().trim().min(1).nullable(),
|
|
23174
|
+
sessionCount: NonNegativeTokenCountSchema
|
|
23175
|
+
});
|
|
23176
|
+
ProjectUsageModelSummarySchema = UsageTotalsSchema.extend({
|
|
23177
|
+
model: external_exports.string().trim().min(1)
|
|
23178
|
+
});
|
|
23179
|
+
ProjectUsageSubscriptionSummarySchema = UsageTotalsSchema.extend({
|
|
23180
|
+
userSubscriptionId: UserSubscriptionCredentialIdSchema.nullable(),
|
|
23181
|
+
coveredInferenceCostUsd: NonNegativeUsdSchema2
|
|
23182
|
+
});
|
|
23183
|
+
ProjectUsageSubscriptionSliceSchema = external_exports.object({
|
|
23184
|
+
totals: UsageTotalsSchema.extend({
|
|
23185
|
+
coveredInferenceCostUsd: NonNegativeUsdSchema2
|
|
23186
|
+
}),
|
|
23187
|
+
subscriptions: external_exports.array(ProjectUsageSubscriptionSummarySchema)
|
|
23188
|
+
});
|
|
23189
|
+
ProjectUsageRequesterAttributionSchema = external_exports.object({
|
|
23190
|
+
requesterKey: external_exports.string().trim().min(1).nullable(),
|
|
23191
|
+
requesterDisplayName: external_exports.string().trim().min(1).nullable(),
|
|
23192
|
+
attributionEpochIds: external_exports.array(SessionAttributionEpochIdSchema),
|
|
23193
|
+
attributionGrades: external_exports.array(AttributionGradeSchema)
|
|
23194
|
+
});
|
|
23195
|
+
ProjectUsageRequesterSummarySchema = UsageTotalsSchema.extend({
|
|
23196
|
+
...ProjectUsageRequesterAttributionSchema.shape,
|
|
23197
|
+
sessionCount: NonNegativeTokenCountSchema
|
|
23198
|
+
});
|
|
23199
|
+
ProjectUsageDayAgentSliceSchema = external_exports.object({
|
|
23200
|
+
agentResourceId: external_exports.string().trim().min(1),
|
|
23201
|
+
billedCostUsd: NonNegativeUsdSchema2
|
|
23202
|
+
});
|
|
23203
|
+
ProjectUsageDayModelSliceSchema = external_exports.object({
|
|
23204
|
+
model: external_exports.string().trim().min(1),
|
|
23205
|
+
billedCostUsd: NonNegativeUsdSchema2
|
|
23206
|
+
});
|
|
23207
|
+
ProjectUsageDayPointSchema = UsageTotalsSchema.extend({
|
|
23208
|
+
date: UtcDateSchema,
|
|
23209
|
+
byAgent: external_exports.array(ProjectUsageDayAgentSliceSchema),
|
|
23210
|
+
byModel: external_exports.array(ProjectUsageDayModelSliceSchema)
|
|
23211
|
+
});
|
|
23212
|
+
ProjectUsageResponseSchema = external_exports.object({
|
|
23213
|
+
organizationId: OrganizationIdSchema,
|
|
23214
|
+
projectId: ProjectIdSchema,
|
|
23215
|
+
range: external_exports.object({
|
|
23216
|
+
key: ProjectUsageRangeKeySchema,
|
|
23217
|
+
since: external_exports.string().datetime(),
|
|
23218
|
+
until: external_exports.string().datetime()
|
|
23219
|
+
}),
|
|
23220
|
+
totals: ProjectUsageTotalsSchema,
|
|
23221
|
+
taskThroughput: external_exports.object({
|
|
23222
|
+
created: external_exports.number().int().nonnegative(),
|
|
23223
|
+
completed: external_exports.number().int().nonnegative(),
|
|
23224
|
+
dropped: external_exports.number().int().nonnegative(),
|
|
23225
|
+
costPerCompletedTaskUsd: NonNegativeUsdSchema2.nullable()
|
|
23226
|
+
}).optional(),
|
|
23227
|
+
byAgent: external_exports.array(ProjectUsageAgentSummarySchema),
|
|
23228
|
+
byModel: external_exports.array(ProjectUsageModelSummarySchema),
|
|
23229
|
+
byFundingSource: external_exports.array(UsageFundingSummarySchema),
|
|
23230
|
+
subscriptionUsage: ProjectUsageSubscriptionSliceSchema,
|
|
23231
|
+
byRequester: external_exports.array(ProjectUsageRequesterSummarySchema),
|
|
23232
|
+
daily: external_exports.array(ProjectUsageDayPointSchema)
|
|
23233
|
+
});
|
|
23234
|
+
}
|
|
23235
|
+
});
|
|
23236
|
+
|
|
23006
23237
|
// ../../packages/schemas/src/session-introspection.ts
|
|
23007
|
-
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, 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;
|
|
23008
23239
|
var init_session_introspection = __esm({
|
|
23009
23240
|
"../../packages/schemas/src/session-introspection.ts"() {
|
|
23010
23241
|
"use strict";
|
|
@@ -23017,6 +23248,7 @@ var init_session_introspection = __esm({
|
|
|
23017
23248
|
init_runtime_restart_diagnostics();
|
|
23018
23249
|
init_session_bindings();
|
|
23019
23250
|
init_sessions();
|
|
23251
|
+
init_usage();
|
|
23020
23252
|
init_work_provenance();
|
|
23021
23253
|
TruncatedValueSchema = external_exports.object({
|
|
23022
23254
|
truncated: external_exports.literal(true),
|
|
@@ -23169,6 +23401,62 @@ var init_session_introspection = __esm({
|
|
|
23169
23401
|
activatedAt: external_exports.string().datetime().nullable(),
|
|
23170
23402
|
fallbackModelId: external_exports.string().nullable()
|
|
23171
23403
|
});
|
|
23404
|
+
RUN_USAGE_BREAKDOWN_LIMIT = 8;
|
|
23405
|
+
RUN_USAGE_TURN_LIMIT = 50;
|
|
23406
|
+
RunUsageTotalsSchema = external_exports.object({
|
|
23407
|
+
eventCount: external_exports.number().int().nonnegative(),
|
|
23408
|
+
inputTokens: external_exports.number().int().nonnegative(),
|
|
23409
|
+
outputTokens: external_exports.number().int().nonnegative(),
|
|
23410
|
+
cacheCreationTokens: external_exports.number().int().nonnegative(),
|
|
23411
|
+
cacheReadTokens: external_exports.number().int().nonnegative(),
|
|
23412
|
+
/**
|
|
23413
|
+
* Stored rate-card-derived model cost; never recomputed by this read.
|
|
23414
|
+
* Omitted when the caller lacks `billing:read`.
|
|
23415
|
+
*/
|
|
23416
|
+
derivedCostUsd: external_exports.number().nonnegative().optional(),
|
|
23417
|
+
/**
|
|
23418
|
+
* Sum of provider-reported costs only when every included event reported
|
|
23419
|
+
* one; null for empty, legacy, or partially reported groups, and omitted
|
|
23420
|
+
* when the caller lacks `billing:read`.
|
|
23421
|
+
*/
|
|
23422
|
+
providerCostUsd: external_exports.number().nonnegative().nullable().optional()
|
|
23423
|
+
});
|
|
23424
|
+
RunUsageHarnessModelSchema = RunUsageTotalsSchema.extend({
|
|
23425
|
+
harness: UsageHarnessSchema,
|
|
23426
|
+
model: external_exports.string().trim().min(1)
|
|
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
|
+
});
|
|
23437
|
+
RunUsageSummarySchema = external_exports.object({
|
|
23438
|
+
totals: RunUsageTotalsSchema,
|
|
23439
|
+
/**
|
|
23440
|
+
* Cache reads divided by prompt-side tokens: input + cache creation/write +
|
|
23441
|
+
* cache read. Output tokens are excluded; value is null when the exposed
|
|
23442
|
+
* denominator is zero.
|
|
23443
|
+
*/
|
|
23444
|
+
cacheReadRatio: external_exports.object({
|
|
23445
|
+
denominatorTokens: external_exports.number().int().nonnegative(),
|
|
23446
|
+
value: external_exports.number().min(0).max(1).nullable()
|
|
23447
|
+
}),
|
|
23448
|
+
/** Highest derived-cost harness/model groups, in descending spend order. */
|
|
23449
|
+
byHarnessModel: external_exports.array(RunUsageHarnessModelSchema).max(RUN_USAGE_BREAKDOWN_LIMIT),
|
|
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
|
|
23459
|
+
});
|
|
23172
23460
|
RunSummarySchema = external_exports.object({
|
|
23173
23461
|
session: external_exports.object({
|
|
23174
23462
|
id: SessionIdSchema,
|
|
@@ -23284,7 +23572,9 @@ var init_session_introspection = __esm({
|
|
|
23284
23572
|
recent: external_exports.array(RunRuntimeRestartSchema)
|
|
23285
23573
|
}),
|
|
23286
23574
|
/** Latest same-provider model-fallback activation for the session, if any. */
|
|
23287
|
-
modelFallback: RunModelFallbackSchema
|
|
23575
|
+
modelFallback: RunModelFallbackSchema,
|
|
23576
|
+
/** Current unsuperseded model usage for the session. */
|
|
23577
|
+
usage: RunUsageSummarySchema
|
|
23288
23578
|
});
|
|
23289
23579
|
}
|
|
23290
23580
|
});
|
|
@@ -23630,43 +23920,6 @@ var init_runtimes = __esm({
|
|
|
23630
23920
|
}
|
|
23631
23921
|
});
|
|
23632
23922
|
|
|
23633
|
-
// ../../packages/schemas/src/session-attribution-epochs.ts
|
|
23634
|
-
var ATTRIBUTION_GRADES, AttributionGradeSchema, AttributionRequesterSnapshotSchema, SessionAttributionEpochCreateSchema, SessionAttributionEpochRecordSchema;
|
|
23635
|
-
var init_session_attribution_epochs = __esm({
|
|
23636
|
-
"../../packages/schemas/src/session-attribution-epochs.ts"() {
|
|
23637
|
-
"use strict";
|
|
23638
|
-
init_zod();
|
|
23639
|
-
init_ids();
|
|
23640
|
-
init_model_credential_funding();
|
|
23641
|
-
init_requester();
|
|
23642
|
-
ATTRIBUTION_GRADES = ["derived", "asserted"];
|
|
23643
|
-
AttributionGradeSchema = external_exports.enum(ATTRIBUTION_GRADES);
|
|
23644
|
-
AttributionRequesterSnapshotSchema = external_exports.object({
|
|
23645
|
-
origin: RequesterRootOriginSchema,
|
|
23646
|
-
userId: UserIdSchema.nullable()
|
|
23647
|
-
}).strict();
|
|
23648
|
-
SessionAttributionEpochCreateSchema = external_exports.object({
|
|
23649
|
-
organizationId: OrganizationIdSchema,
|
|
23650
|
-
projectId: ProjectIdSchema.nullable(),
|
|
23651
|
-
sessionId: SessionIdSchema,
|
|
23652
|
-
sourceCommandId: SessionCommandIdSchema,
|
|
23653
|
-
requesterKey: external_exports.string().trim().min(1),
|
|
23654
|
-
requesterSnapshot: AttributionRequesterSnapshotSchema.nullable(),
|
|
23655
|
-
attributionGrade: AttributionGradeSchema,
|
|
23656
|
-
assertedByCommandId: SessionCommandIdSchema.nullable(),
|
|
23657
|
-
assertedBySessionId: SessionIdSchema.nullable(),
|
|
23658
|
-
assertedByAgentResourceId: external_exports.string().trim().min(1).nullable(),
|
|
23659
|
-
fundingSource: ModelCredentialFundingSourceSchema.nullable(),
|
|
23660
|
-
providerGrantId: ProviderGrantIdSchema.nullable(),
|
|
23661
|
-
userModelSubscriptionId: UserSubscriptionCredentialIdSchema.nullable()
|
|
23662
|
-
}).strict();
|
|
23663
|
-
SessionAttributionEpochRecordSchema = SessionAttributionEpochCreateSchema.extend({
|
|
23664
|
-
id: SessionAttributionEpochIdSchema,
|
|
23665
|
-
createdAt: external_exports.string().datetime()
|
|
23666
|
-
}).strict();
|
|
23667
|
-
}
|
|
23668
|
-
});
|
|
23669
|
-
|
|
23670
23923
|
// ../../packages/schemas/src/spend-cap-runtime.ts
|
|
23671
23924
|
var SpendCapOverrideStateSchema, SpendCapOverrideUpdateRequestSchema, SPEND_CAP_LIMIT_KINDS, SpendCapLimitKindSchema, EffectiveSpendCapHitSchema, SessionSpendCapRuntimeStatusSchema, AgentSpendCapRuntimeStatusSchema, SessionCreationSpendCapDecisionSchema, SPEND_CAP_RUNTIME_ERROR_CODES, SpendCapRuntimeErrorResponseSchema;
|
|
23672
23925
|
var init_spend_cap_runtime = __esm({
|
|
@@ -57955,6 +58208,23 @@ triggers:
|
|
|
57955
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"
|
|
57956
58209
|
}
|
|
57957
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
|
+
]
|
|
57958
58228
|
}
|
|
57959
58229
|
],
|
|
57960
58230
|
"@auto/slopbusters": [
|
|
@@ -81718,195 +81988,6 @@ var init_temporal = __esm({
|
|
|
81718
81988
|
}
|
|
81719
81989
|
});
|
|
81720
81990
|
|
|
81721
|
-
// ../../packages/schemas/src/usage.ts
|
|
81722
|
-
var UsageHarnessSchema, NonNegativeTokenCountSchema, NonNegativeUsdSchema2, UsageEventSchema, UsageEventRecordSchema, UsageTotalsSchema, SessionUsageModelSummarySchema, UsageFundingSummarySchema, SessionModelFundingStateSchema, SessionUsageCurrentAttributionSchema, SessionUsageRequesterSummarySchema, SessionUsageResponseSchema, PROJECT_USAGE_RANGE_KEYS, ProjectUsageRangeKeySchema, UtcDateSchema, ProjectUsageTotalsSchema, ProjectUsageAgentSummarySchema, ProjectUsageModelSummarySchema, ProjectUsageSubscriptionSummarySchema, ProjectUsageSubscriptionSliceSchema, ProjectUsageRequesterAttributionSchema, ProjectUsageRequesterSummarySchema, ProjectUsageDayAgentSliceSchema, ProjectUsageDayModelSliceSchema, ProjectUsageDayPointSchema, ProjectUsageResponseSchema;
|
|
81723
|
-
var init_usage = __esm({
|
|
81724
|
-
"../../packages/schemas/src/usage.ts"() {
|
|
81725
|
-
"use strict";
|
|
81726
|
-
init_zod();
|
|
81727
|
-
init_agents();
|
|
81728
|
-
init_ids();
|
|
81729
|
-
init_model_credential_funding();
|
|
81730
|
-
init_session_attribution_epochs();
|
|
81731
|
-
init_model_credential_funding();
|
|
81732
|
-
UsageHarnessSchema = external_exports.enum(AGENT_HARNESSES);
|
|
81733
|
-
NonNegativeTokenCountSchema = external_exports.number().int().nonnegative();
|
|
81734
|
-
NonNegativeUsdSchema2 = external_exports.number().nonnegative();
|
|
81735
|
-
UsageEventSchema = external_exports.object({
|
|
81736
|
-
// Tenant + lineage attribution. projectId is nullable because a resource can
|
|
81737
|
-
// belong directly to an organization with no project.
|
|
81738
|
-
organizationId: OrganizationIdSchema,
|
|
81739
|
-
projectId: ProjectIdSchema.nullable(),
|
|
81740
|
-
sessionId: SessionIdSchema,
|
|
81741
|
-
agentResourceId: external_exports.string().trim().min(1),
|
|
81742
|
-
harness: UsageHarnessSchema,
|
|
81743
|
-
// The concrete model id the call billed against (e.g. "claude-opus-4-8"),
|
|
81744
|
-
// taken from the response rather than any selection layer — a single run can
|
|
81745
|
-
// touch multiple models, so this is per-call, never per-run.
|
|
81746
|
-
model: external_exports.string().trim().min(1),
|
|
81747
|
-
inputTokens: NonNegativeTokenCountSchema,
|
|
81748
|
-
outputTokens: NonNegativeTokenCountSchema,
|
|
81749
|
-
cacheCreationTokens: NonNegativeTokenCountSchema,
|
|
81750
|
-
cacheReadTokens: NonNegativeTokenCountSchema,
|
|
81751
|
-
// The provider's own cost when it reports one, kept only for reconciliation.
|
|
81752
|
-
// Nullable/absent because it can be 0 or missing — never the billing source.
|
|
81753
|
-
providerCostUsd: NonNegativeUsdSchema2.nullable(),
|
|
81754
|
-
// Platform-derived cost and the rate-card version it was derived under, so a
|
|
81755
|
-
// later rate-card change never silently rewrites historical cost.
|
|
81756
|
-
derivedCostUsd: NonNegativeUsdSchema2,
|
|
81757
|
-
pricingVersion: external_exports.string().trim().min(1),
|
|
81758
|
-
// What this call debits from the organization's credit balance, and the fee
|
|
81759
|
-
// card it was derived under (see `./billing`). Required — a writer that
|
|
81760
|
-
// forgets it would silently record unbilled usage, so there is no default.
|
|
81761
|
-
billedCostUsd: NonNegativeUsdSchema2,
|
|
81762
|
-
billingFeeVersion: external_exports.string().trim().min(1),
|
|
81763
|
-
// Historical funding attribution for the model call. The provider grant id is
|
|
81764
|
-
// denormalized and nullable for platform-funded usage, matching the ledger's
|
|
81765
|
-
// no-FK audit-trail contract.
|
|
81766
|
-
fundingSource: ModelCredentialFundingSourceSchema.default("platform"),
|
|
81767
|
-
modelCredentialProviderGrantId: ProviderGrantIdSchema.nullable().default(null),
|
|
81768
|
-
// Optional during the cross-chunk rollout: B1 defines the attribution field
|
|
81769
|
-
// before B3 deploys its persistence column and D3 begins populating it.
|
|
81770
|
-
modelCredentialUserSubscriptionId: UserSubscriptionCredentialIdSchema.nullable().optional(),
|
|
81771
|
-
attributionEpochId: SessionAttributionEpochIdSchema.nullable().optional(),
|
|
81772
|
-
requesterKey: external_exports.string().trim().min(1).nullable().optional(),
|
|
81773
|
-
attributionGrade: AttributionGradeSchema.nullable().optional(),
|
|
81774
|
-
occurredAt: external_exports.string().datetime()
|
|
81775
|
-
});
|
|
81776
|
-
UsageEventRecordSchema = UsageEventSchema.extend({
|
|
81777
|
-
id: external_exports.string().trim().min(1),
|
|
81778
|
-
attributionEpochId: SessionAttributionEpochIdSchema.nullable().default(null),
|
|
81779
|
-
requesterKey: external_exports.string().trim().min(1).nullable().default(null),
|
|
81780
|
-
attributionGrade: AttributionGradeSchema.nullable().default(null),
|
|
81781
|
-
// Set on append-only correction rows: this row replaces the pointed-at row's
|
|
81782
|
-
// amounts, and ledger readers exclude any row another row supersedes.
|
|
81783
|
-
supersedesUsageEventId: external_exports.string().trim().min(1).nullable().default(null),
|
|
81784
|
-
createdAt: external_exports.string().datetime()
|
|
81785
|
-
});
|
|
81786
|
-
UsageTotalsSchema = external_exports.object({
|
|
81787
|
-
eventCount: NonNegativeTokenCountSchema,
|
|
81788
|
-
inputTokens: NonNegativeTokenCountSchema,
|
|
81789
|
-
outputTokens: NonNegativeTokenCountSchema,
|
|
81790
|
-
cacheCreationTokens: NonNegativeTokenCountSchema,
|
|
81791
|
-
cacheReadTokens: NonNegativeTokenCountSchema,
|
|
81792
|
-
totalTokens: NonNegativeTokenCountSchema,
|
|
81793
|
-
billedCostUsd: NonNegativeUsdSchema2
|
|
81794
|
-
});
|
|
81795
|
-
SessionUsageModelSummarySchema = UsageTotalsSchema.extend({
|
|
81796
|
-
model: external_exports.string().trim().min(1)
|
|
81797
|
-
});
|
|
81798
|
-
UsageFundingSummarySchema = UsageTotalsSchema.extend({
|
|
81799
|
-
fundingSource: ModelCredentialFundingSourceSchema,
|
|
81800
|
-
coveredInferenceCostUsd: NonNegativeUsdSchema2
|
|
81801
|
-
});
|
|
81802
|
-
SessionModelFundingStateSchema = external_exports.object({
|
|
81803
|
-
fundingSource: ModelCredentialFundingSourceSchema,
|
|
81804
|
-
provider: external_exports.string().trim().min(1),
|
|
81805
|
-
// The subscription owner's display name for user_subscription funding, so
|
|
81806
|
-
// the session header can say whose key is being used. Optional for old
|
|
81807
|
-
// writers; null when the name cannot resolve.
|
|
81808
|
-
ownerDisplayName: external_exports.string().trim().min(1).nullable().optional()
|
|
81809
|
-
});
|
|
81810
|
-
SessionUsageCurrentAttributionSchema = external_exports.object({
|
|
81811
|
-
requesterKey: external_exports.string().trim().min(1),
|
|
81812
|
-
requesterDisplayName: external_exports.string().trim().min(1).nullable(),
|
|
81813
|
-
attributionGrade: AttributionGradeSchema
|
|
81814
|
-
}).strip();
|
|
81815
|
-
SessionUsageRequesterSummarySchema = external_exports.object({
|
|
81816
|
-
requesterKey: external_exports.string().trim().min(1).nullable(),
|
|
81817
|
-
requesterDisplayName: external_exports.string().trim().min(1).nullable(),
|
|
81818
|
-
billedCostUsd: NonNegativeUsdSchema2,
|
|
81819
|
-
attributionGrades: external_exports.array(AttributionGradeSchema)
|
|
81820
|
-
}).strip();
|
|
81821
|
-
SessionUsageResponseSchema = external_exports.object({
|
|
81822
|
-
sessionId: SessionIdSchema,
|
|
81823
|
-
totals: UsageTotalsSchema,
|
|
81824
|
-
models: external_exports.array(SessionUsageModelSummarySchema),
|
|
81825
|
-
byFundingSource: external_exports.array(UsageFundingSummarySchema),
|
|
81826
|
-
byRequester: external_exports.array(SessionUsageRequesterSummarySchema).optional().default([]),
|
|
81827
|
-
currentAttribution: SessionUsageCurrentAttributionSchema.nullable().optional().default(null),
|
|
81828
|
-
funding: SessionModelFundingStateSchema.nullable(),
|
|
81829
|
-
firstUsageAt: external_exports.string().datetime().nullable(),
|
|
81830
|
-
lastUsageAt: external_exports.string().datetime().nullable()
|
|
81831
|
-
}).strip();
|
|
81832
|
-
PROJECT_USAGE_RANGE_KEYS = ["7d", "30d"];
|
|
81833
|
-
ProjectUsageRangeKeySchema = external_exports.enum(PROJECT_USAGE_RANGE_KEYS);
|
|
81834
|
-
UtcDateSchema = external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/);
|
|
81835
|
-
ProjectUsageTotalsSchema = UsageTotalsSchema.extend({
|
|
81836
|
-
sessionCount: NonNegativeTokenCountSchema,
|
|
81837
|
-
// Share of all tokens served from prompt-cache reads (0..1); 0 when the
|
|
81838
|
-
// window has no tokens at all.
|
|
81839
|
-
cacheReadShare: external_exports.number().min(0).max(1)
|
|
81840
|
-
});
|
|
81841
|
-
ProjectUsageAgentSummarySchema = UsageTotalsSchema.extend({
|
|
81842
|
-
agentResourceId: external_exports.string().trim().min(1),
|
|
81843
|
-
// Resolved from the agent resource (archived agents included); null only
|
|
81844
|
-
// when the agent row no longer exists at all — the ledger deliberately
|
|
81845
|
-
// outlives its attribution targets.
|
|
81846
|
-
agentName: external_exports.string().trim().min(1).nullable(),
|
|
81847
|
-
sessionCount: NonNegativeTokenCountSchema
|
|
81848
|
-
});
|
|
81849
|
-
ProjectUsageModelSummarySchema = UsageTotalsSchema.extend({
|
|
81850
|
-
model: external_exports.string().trim().min(1)
|
|
81851
|
-
});
|
|
81852
|
-
ProjectUsageSubscriptionSummarySchema = UsageTotalsSchema.extend({
|
|
81853
|
-
userSubscriptionId: UserSubscriptionCredentialIdSchema.nullable(),
|
|
81854
|
-
coveredInferenceCostUsd: NonNegativeUsdSchema2
|
|
81855
|
-
});
|
|
81856
|
-
ProjectUsageSubscriptionSliceSchema = external_exports.object({
|
|
81857
|
-
totals: UsageTotalsSchema.extend({
|
|
81858
|
-
coveredInferenceCostUsd: NonNegativeUsdSchema2
|
|
81859
|
-
}),
|
|
81860
|
-
subscriptions: external_exports.array(ProjectUsageSubscriptionSummarySchema)
|
|
81861
|
-
});
|
|
81862
|
-
ProjectUsageRequesterAttributionSchema = external_exports.object({
|
|
81863
|
-
requesterKey: external_exports.string().trim().min(1).nullable(),
|
|
81864
|
-
requesterDisplayName: external_exports.string().trim().min(1).nullable(),
|
|
81865
|
-
attributionEpochIds: external_exports.array(SessionAttributionEpochIdSchema),
|
|
81866
|
-
attributionGrades: external_exports.array(AttributionGradeSchema)
|
|
81867
|
-
});
|
|
81868
|
-
ProjectUsageRequesterSummarySchema = UsageTotalsSchema.extend({
|
|
81869
|
-
...ProjectUsageRequesterAttributionSchema.shape,
|
|
81870
|
-
sessionCount: NonNegativeTokenCountSchema
|
|
81871
|
-
});
|
|
81872
|
-
ProjectUsageDayAgentSliceSchema = external_exports.object({
|
|
81873
|
-
agentResourceId: external_exports.string().trim().min(1),
|
|
81874
|
-
billedCostUsd: NonNegativeUsdSchema2
|
|
81875
|
-
});
|
|
81876
|
-
ProjectUsageDayModelSliceSchema = external_exports.object({
|
|
81877
|
-
model: external_exports.string().trim().min(1),
|
|
81878
|
-
billedCostUsd: NonNegativeUsdSchema2
|
|
81879
|
-
});
|
|
81880
|
-
ProjectUsageDayPointSchema = UsageTotalsSchema.extend({
|
|
81881
|
-
date: UtcDateSchema,
|
|
81882
|
-
byAgent: external_exports.array(ProjectUsageDayAgentSliceSchema),
|
|
81883
|
-
byModel: external_exports.array(ProjectUsageDayModelSliceSchema)
|
|
81884
|
-
});
|
|
81885
|
-
ProjectUsageResponseSchema = external_exports.object({
|
|
81886
|
-
organizationId: OrganizationIdSchema,
|
|
81887
|
-
projectId: ProjectIdSchema,
|
|
81888
|
-
range: external_exports.object({
|
|
81889
|
-
key: ProjectUsageRangeKeySchema,
|
|
81890
|
-
since: external_exports.string().datetime(),
|
|
81891
|
-
until: external_exports.string().datetime()
|
|
81892
|
-
}),
|
|
81893
|
-
totals: ProjectUsageTotalsSchema,
|
|
81894
|
-
taskThroughput: external_exports.object({
|
|
81895
|
-
created: external_exports.number().int().nonnegative(),
|
|
81896
|
-
completed: external_exports.number().int().nonnegative(),
|
|
81897
|
-
dropped: external_exports.number().int().nonnegative(),
|
|
81898
|
-
costPerCompletedTaskUsd: NonNegativeUsdSchema2.nullable()
|
|
81899
|
-
}).optional(),
|
|
81900
|
-
byAgent: external_exports.array(ProjectUsageAgentSummarySchema),
|
|
81901
|
-
byModel: external_exports.array(ProjectUsageModelSummarySchema),
|
|
81902
|
-
byFundingSource: external_exports.array(UsageFundingSummarySchema),
|
|
81903
|
-
subscriptionUsage: ProjectUsageSubscriptionSliceSchema,
|
|
81904
|
-
byRequester: external_exports.array(ProjectUsageRequesterSummarySchema),
|
|
81905
|
-
daily: external_exports.array(ProjectUsageDayPointSchema)
|
|
81906
|
-
});
|
|
81907
|
-
}
|
|
81908
|
-
});
|
|
81909
|
-
|
|
81910
81991
|
// ../../packages/schemas/src/user-subscriptions.ts
|
|
81911
81992
|
var ATTRIBUTION_COLD_BOUNDARY_IDLE_MS, USER_SUBSCRIPTION_PROVIDERS, UserSubscriptionProviderSchema, USER_SUBSCRIPTION_CREDENTIAL_STATUSES, UserSubscriptionCredentialStatusSchema, OpenAiUserSubscriptionCredentialSecretSchema, UserSubscriptionCredentialSchema, USER_SUBSCRIPTION_POLICY_MODES, UserSubscriptionPolicyModeSchema, USER_SUBSCRIPTION_POLICY_ORIGINS, UserSubscriptionPolicyOriginSchema, UserSubscriptionPolicySchema, UserSubscriptionFundingCandidateSchema, UserSubscriptionFundingDecisionInputSchema, USER_SUBSCRIPTION_REJECTION_REASONS, UserSubscriptionRejectionReasonSchema, USER_SUBSCRIPTION_SELECTION_REASONS, UserSubscriptionSelectionReasonSchema, UserSubscriptionFundingDecisionSchema;
|
|
81912
81993
|
var init_user_subscriptions = __esm({
|
|
@@ -84895,7 +84976,7 @@ var init_package = __esm({
|
|
|
84895
84976
|
"package.json"() {
|
|
84896
84977
|
package_default = {
|
|
84897
84978
|
name: "@autohq/cli",
|
|
84898
|
-
version: "0.1.
|
|
84979
|
+
version: "0.1.566",
|
|
84899
84980
|
license: "SEE LICENSE IN README.md",
|
|
84900
84981
|
publishConfig: {
|
|
84901
84982
|
access: "public"
|
|
@@ -96097,13 +96178,23 @@ var RuntimeBridgeOutputLivenessEnvelopeSchema = external_exports.object({
|
|
|
96097
96178
|
intervalMs: external_exports.number().int().positive(),
|
|
96098
96179
|
createdAt: external_exports.string().datetime()
|
|
96099
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
|
+
});
|
|
96100
96190
|
var RuntimeBridgeOutputEnvelopeSchema = external_exports.union([
|
|
96101
96191
|
RuntimeBridgeOutputEntryEnvelopeSchema,
|
|
96102
96192
|
RuntimeBridgeOutputDeltaEnvelopeSchema,
|
|
96103
96193
|
RuntimeBridgeOutputUiMessageChunkEnvelopeSchema,
|
|
96104
96194
|
RuntimeBridgeOutputUiMessagePartEnvelopeSchema,
|
|
96105
96195
|
RuntimeBridgeOutputUiMessageCompletedEnvelopeSchema,
|
|
96106
|
-
RuntimeBridgeOutputLivenessEnvelopeSchema
|
|
96196
|
+
RuntimeBridgeOutputLivenessEnvelopeSchema,
|
|
96197
|
+
RuntimeBridgeOutputUsageTurnEnvelopeSchema
|
|
96107
96198
|
]);
|
|
96108
96199
|
function isLiveOnlyRuntimeOutputEnvelope(envelope) {
|
|
96109
96200
|
return envelope.type === "ui.message.chunk" || envelope.type === "conversation.delta";
|
|
@@ -97750,6 +97841,9 @@ function replacePayloadWithMarker(envelope, originalBytes) {
|
|
|
97750
97841
|
parts: [{ type: "text", text, state: "done" }]
|
|
97751
97842
|
}
|
|
97752
97843
|
};
|
|
97844
|
+
case "runtime.liveness":
|
|
97845
|
+
case "runtime.usage_turn":
|
|
97846
|
+
return envelope;
|
|
97753
97847
|
}
|
|
97754
97848
|
}
|
|
97755
97849
|
|
|
@@ -98183,6 +98277,23 @@ var AgentBridgeOutputBuffer = class {
|
|
|
98183
98277
|
);
|
|
98184
98278
|
await this.drainPendingOutputs();
|
|
98185
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
|
+
}
|
|
98186
98297
|
async emitUiMessageChunk(context, projection) {
|
|
98187
98298
|
await this.flushPendingDelta();
|
|
98188
98299
|
await this.emitLiveUiMessageChunk(context, projection.chunk);
|
|
@@ -98963,6 +99074,18 @@ function buildLivenessOutputEnvelope(input) {
|
|
|
98963
99074
|
createdAt: input.createdAt
|
|
98964
99075
|
});
|
|
98965
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
|
+
}
|
|
98966
99089
|
function buildUiMessagePartOutputEnvelope(input) {
|
|
98967
99090
|
const { context, snapshot } = input;
|
|
98968
99091
|
return RuntimeBridgeOutputEnvelopeSchema.parse({
|
|
@@ -100254,7 +100377,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
100254
100377
|
return;
|
|
100255
100378
|
}
|
|
100256
100379
|
await this.awaitMcpRegistration();
|
|
100257
|
-
this.enqueueUserMessage(message, commandIds);
|
|
100380
|
+
await this.enqueueUserMessage(message, commandIds);
|
|
100258
100381
|
this.input.runtimeLogger?.info("agent_bridge_claude_send_message_queued", {
|
|
100259
100382
|
delivery_mode: mode,
|
|
100260
100383
|
duration_ms: Date.now() - startedAt,
|
|
@@ -100360,6 +100483,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
100360
100483
|
}
|
|
100361
100484
|
this.openTurnCommandIds.length = 0;
|
|
100362
100485
|
this.publishActiveTurnCommandIds();
|
|
100486
|
+
void this.input.onUsageTurnChanged?.(null);
|
|
100363
100487
|
this.stderr.flush();
|
|
100364
100488
|
this.inputQueue.close();
|
|
100365
100489
|
if (previousState.kind === "started") {
|
|
@@ -100453,6 +100577,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
100453
100577
|
consumedCommandIds: this.openTurnCommandIds.shift() ?? []
|
|
100454
100578
|
};
|
|
100455
100579
|
this.publishActiveTurnCommandIds();
|
|
100580
|
+
await this.input.onUsageTurnChanged?.(null);
|
|
100456
100581
|
this.pendingToolUses.clear();
|
|
100457
100582
|
this.interruptSettling = false;
|
|
100458
100583
|
this.turnResultCount += 1;
|
|
@@ -100464,7 +100589,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
100464
100589
|
consumed_command_ids: meta3.consumedCommandIds
|
|
100465
100590
|
});
|
|
100466
100591
|
if (this.activeTurnCount === 0) {
|
|
100467
|
-
this.flushDeferredMessages();
|
|
100592
|
+
await this.flushDeferredMessages();
|
|
100468
100593
|
}
|
|
100469
100594
|
if (this.deferredMessages.length === 0) {
|
|
100470
100595
|
this.cancelledToolRuns = [];
|
|
@@ -100494,6 +100619,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
100494
100619
|
this.activeTurnCount = 0;
|
|
100495
100620
|
this.openTurnCommandIds.length = 0;
|
|
100496
100621
|
this.publishActiveTurnCommandIds();
|
|
100622
|
+
await this.input.onUsageTurnChanged?.(null);
|
|
100497
100623
|
this.pendingToolUses.clear();
|
|
100498
100624
|
this.interruptSettling = false;
|
|
100499
100625
|
this.disarmToolBoundaryWait();
|
|
@@ -100506,7 +100632,8 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
100506
100632
|
// lets injection work while the SDK session is still starting; the queue
|
|
100507
100633
|
// drains once the query attaches. Startup failures surface through onError
|
|
100508
100634
|
// instead of failing injection.
|
|
100509
|
-
enqueueUserMessage(message, commandIds) {
|
|
100635
|
+
async enqueueUserMessage(message, commandIds) {
|
|
100636
|
+
await this.input.onUsageTurnChanged?.(commandIds[0] ?? null);
|
|
100510
100637
|
this.inputQueue.push(claudeAgentUserMessage(message));
|
|
100511
100638
|
this.activeTurnCount += 1;
|
|
100512
100639
|
this.openTurnCommandIds.push(commandIds);
|
|
@@ -100614,7 +100741,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
100614
100741
|
clearTimeout(this.toolBoundaryWait.timer);
|
|
100615
100742
|
this.toolBoundaryWait = null;
|
|
100616
100743
|
}
|
|
100617
|
-
flushDeferredMessages() {
|
|
100744
|
+
async flushDeferredMessages() {
|
|
100618
100745
|
if (this.deferredMessages.length === 0) {
|
|
100619
100746
|
return;
|
|
100620
100747
|
}
|
|
@@ -100625,7 +100752,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
100625
100752
|
`agent_bridge_claude_deferred_flush count=${pending.length} cancelled_tool_count=${cancelledToolRuns.length}`
|
|
100626
100753
|
);
|
|
100627
100754
|
const text = pending.map((entry) => entry.text).join("\n\n");
|
|
100628
|
-
this.enqueueUserMessage(
|
|
100755
|
+
await this.enqueueUserMessage(
|
|
100629
100756
|
cancelledToolRuns.length > 0 ? `${text}
|
|
100630
100757
|
|
|
100631
100758
|
${cancelledToolPlatformNotice(cancelledToolRuns)}` : text,
|
|
@@ -101542,6 +101669,13 @@ var ClaudeCodeCommandHandler = class {
|
|
|
101542
101669
|
RUNTIME_LIVENESS_INTERVAL_MS
|
|
101543
101670
|
);
|
|
101544
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
|
+
}
|
|
101545
101679
|
async emitBridgeOutput(activeContext, projection) {
|
|
101546
101680
|
try {
|
|
101547
101681
|
await this.outputBuffer.emitProjection(activeContext, projection);
|
|
@@ -101709,6 +101843,7 @@ var ClaudeCodeCommandHandler = class {
|
|
|
101709
101843
|
}
|
|
101710
101844
|
},
|
|
101711
101845
|
onActiveTurnCommandIds: (commandIds) => this.autoMcpShim.setActiveTurnCommandIds(commandIds),
|
|
101846
|
+
onUsageTurnChanged: (turnId) => this.emitUsageTurn(turnId),
|
|
101712
101847
|
canUseTool: this.canUseTool,
|
|
101713
101848
|
onMessage: (message, meta3) => this.handleAgentMessage(message, meta3),
|
|
101714
101849
|
onError: (error51) => this.handleAgentError(error51),
|
|
@@ -102922,6 +103057,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
102922
103057
|
this.pendingCommandIds = [...commandIds];
|
|
102923
103058
|
this.publishActiveTurnCommandIds(commandIds);
|
|
102924
103059
|
try {
|
|
103060
|
+
await this.input.onUsageTurnChanged?.(commandIds[0] ?? null);
|
|
102925
103061
|
await this.request("turn/start", {
|
|
102926
103062
|
threadId,
|
|
102927
103063
|
input: [userTextInput(message)]
|
|
@@ -102929,6 +103065,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
102929
103065
|
} catch (error51) {
|
|
102930
103066
|
this.pendingCommandIds = [];
|
|
102931
103067
|
this.publishActiveTurnCommandIds();
|
|
103068
|
+
await this.input.onUsageTurnChanged?.(null);
|
|
102932
103069
|
throw error51;
|
|
102933
103070
|
}
|
|
102934
103071
|
}
|
|
@@ -102936,6 +103073,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
102936
103073
|
this.pendingCommandIds = [...commandIds];
|
|
102937
103074
|
this.publishActiveTurnCommandIds(commandIds);
|
|
102938
103075
|
try {
|
|
103076
|
+
await this.input.onUsageTurnChanged?.(commandIds[0] ?? null);
|
|
102939
103077
|
await this.request("turn/start", {
|
|
102940
103078
|
threadId,
|
|
102941
103079
|
input: []
|
|
@@ -102943,6 +103081,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
102943
103081
|
} catch (error51) {
|
|
102944
103082
|
this.pendingCommandIds = [];
|
|
102945
103083
|
this.publishActiveTurnCommandIds();
|
|
103084
|
+
await this.input.onUsageTurnChanged?.(null);
|
|
102946
103085
|
throw error51;
|
|
102947
103086
|
}
|
|
102948
103087
|
}
|
|
@@ -103306,6 +103445,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
103306
103445
|
this.activeTurnId = null;
|
|
103307
103446
|
this.activeCommandIds = [];
|
|
103308
103447
|
this.publishActiveTurnCommandIds();
|
|
103448
|
+
void this.input.onUsageTurnChanged?.(null);
|
|
103309
103449
|
}
|
|
103310
103450
|
this.pendingToolItemIds.clear();
|
|
103311
103451
|
this.resolveSettlement();
|
|
@@ -103321,6 +103461,7 @@ var CodexAgentBridgeSessionImpl = class {
|
|
|
103321
103461
|
this.activeCommandIds = [];
|
|
103322
103462
|
this.pendingCommandIds = [];
|
|
103323
103463
|
this.publishActiveTurnCommandIds();
|
|
103464
|
+
void this.input.onUsageTurnChanged?.(null);
|
|
103324
103465
|
this.pendingToolItemIds.clear();
|
|
103325
103466
|
this.resolveSettlement();
|
|
103326
103467
|
this.input.writeOutput?.(`agent_bridge_codex_exited code=${code ?? ""}`);
|
|
@@ -103716,6 +103857,13 @@ var CodexCommandHandler = class {
|
|
|
103716
103857
|
RUNTIME_LIVENESS_INTERVAL_MS
|
|
103717
103858
|
);
|
|
103718
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
|
+
}
|
|
103719
103867
|
async emit(activeContext, projection) {
|
|
103720
103868
|
try {
|
|
103721
103869
|
await this.outputBuffer.emitProjection(activeContext, projection);
|
|
@@ -103738,6 +103886,7 @@ var CodexCommandHandler = class {
|
|
|
103738
103886
|
onServerRequest: (request) => this.handleServerRequest(request),
|
|
103739
103887
|
onThreadId: (threadId) => this.persistThreadId(threadId),
|
|
103740
103888
|
onActiveTurnCommandIds: (commandIds) => this.autoMcpShim.setActiveTurnCommandIds(commandIds),
|
|
103889
|
+
onUsageTurnChanged: (turnId) => this.emitUsageTurn(turnId),
|
|
103741
103890
|
onError: (error51) => this.handleSessionError(error51),
|
|
103742
103891
|
onExit: () => {
|
|
103743
103892
|
if (this.session === session) {
|