@autohq/cli 0.1.360 → 0.1.362
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 +130 -13
- package/dist/index.js +140 -14
- package/package.json +1 -1
package/dist/agent-bridge.js
CHANGED
|
@@ -23492,7 +23492,7 @@ Object.assign(lookup, {
|
|
|
23492
23492
|
// package.json
|
|
23493
23493
|
var package_default = {
|
|
23494
23494
|
name: "@autohq/cli",
|
|
23495
|
-
version: "0.1.
|
|
23495
|
+
version: "0.1.362",
|
|
23496
23496
|
license: "SEE LICENSE IN README.md",
|
|
23497
23497
|
publishConfig: {
|
|
23498
23498
|
access: "public"
|
|
@@ -24190,6 +24190,8 @@ var AuthScopeSchema = external_exports.enum([
|
|
|
24190
24190
|
"provider_grants:write",
|
|
24191
24191
|
"provider_grants:use",
|
|
24192
24192
|
"members:read",
|
|
24193
|
+
"billing:read",
|
|
24194
|
+
"billing:write",
|
|
24193
24195
|
"secrets:read",
|
|
24194
24196
|
"secrets:write",
|
|
24195
24197
|
"secrets:use",
|
|
@@ -27877,6 +27879,12 @@ var SessionListItemSchema = external_exports.object({
|
|
|
27877
27879
|
// Additive and optional so older live frames/list payloads that predate the
|
|
27878
27880
|
// projection keep parsing; new projections include null when no reason exists.
|
|
27879
27881
|
failureReason: external_exports.string().nullable().optional(),
|
|
27882
|
+
// Additive and optional so older live frames/list payloads that predate the
|
|
27883
|
+
// projection keep parsing; new projections include null when no selection
|
|
27884
|
+
// exists. Carried so a session-upsert after a selection change keeps the
|
|
27885
|
+
// open-session React Query record in sync without a full refetch.
|
|
27886
|
+
model: ResolvedAgentModelSelectionSchema.nullable().optional(),
|
|
27887
|
+
reasoningEffort: external_exports.string().trim().min(1).nullable().optional(),
|
|
27880
27888
|
agent: SessionListItemAgentSchema,
|
|
27881
27889
|
createdAt: external_exports.string().datetime(),
|
|
27882
27890
|
updatedAt: external_exports.string().datetime(),
|
|
@@ -27929,6 +27937,89 @@ var OrganizationIdentityPolicySchema = external_exports.object({
|
|
|
27929
27937
|
});
|
|
27930
27938
|
var UpdateOrganizationIdentityPolicyRequestSchema = OrganizationIdentityPolicySchema.strict();
|
|
27931
27939
|
|
|
27940
|
+
// ../../packages/schemas/src/billing.ts
|
|
27941
|
+
var FEE_CARD_2026_07_06 = {
|
|
27942
|
+
version: "2026-07-06",
|
|
27943
|
+
effectiveAt: "2026-07-06T00:00:00.000Z",
|
|
27944
|
+
feeRate: 0.05
|
|
27945
|
+
};
|
|
27946
|
+
var BILLING_FEE_CARDS = {
|
|
27947
|
+
[FEE_CARD_2026_07_06.version]: FEE_CARD_2026_07_06
|
|
27948
|
+
};
|
|
27949
|
+
var CURRENT_BILLING_FEE_VERSION = FEE_CARD_2026_07_06.version;
|
|
27950
|
+
var CREDIT_EVENT_TYPES = [
|
|
27951
|
+
"signup_grant",
|
|
27952
|
+
"purchase",
|
|
27953
|
+
"auto_topup",
|
|
27954
|
+
"adjustment"
|
|
27955
|
+
];
|
|
27956
|
+
var CreditEventTypeSchema = external_exports.enum(CREDIT_EVENT_TYPES);
|
|
27957
|
+
var UsdAmountSchema = external_exports.number().finite();
|
|
27958
|
+
var NonNegativeUsdSchema = external_exports.number().finite().nonnegative();
|
|
27959
|
+
var PositiveUsdSchema = external_exports.number().finite().positive();
|
|
27960
|
+
var CreditEventSchema = external_exports.object({
|
|
27961
|
+
organizationId: OrganizationIdSchema,
|
|
27962
|
+
type: CreditEventTypeSchema,
|
|
27963
|
+
amountUsd: UsdAmountSchema,
|
|
27964
|
+
description: external_exports.string().trim().min(1).nullable().default(null),
|
|
27965
|
+
// The acting user for manual purchases/adjustments; null for system-issued
|
|
27966
|
+
// rows (signup grants, auto-top-ups).
|
|
27967
|
+
createdByUserId: external_exports.string().trim().min(1).nullable().default(null)
|
|
27968
|
+
}).refine(
|
|
27969
|
+
(event) => event.type === "adjustment" || event.amountUsd > 0,
|
|
27970
|
+
"Only adjustment credit events may carry a non-positive amount"
|
|
27971
|
+
);
|
|
27972
|
+
var CreditEventRecordSchema = external_exports.object({
|
|
27973
|
+
id: external_exports.string().trim().min(1),
|
|
27974
|
+
organizationId: OrganizationIdSchema,
|
|
27975
|
+
type: CreditEventTypeSchema,
|
|
27976
|
+
amountUsd: UsdAmountSchema,
|
|
27977
|
+
description: external_exports.string().trim().min(1).nullable(),
|
|
27978
|
+
createdByUserId: external_exports.string().trim().min(1).nullable(),
|
|
27979
|
+
createdAt: external_exports.string().datetime()
|
|
27980
|
+
});
|
|
27981
|
+
var SPENDING_LIMIT_WINDOWS = ["hour", "day", "week", "month"];
|
|
27982
|
+
var SpendingLimitWindowSchema = external_exports.enum(SPENDING_LIMIT_WINDOWS);
|
|
27983
|
+
var BilledSpendWindowsSchema = external_exports.object({
|
|
27984
|
+
hourUsd: NonNegativeUsdSchema,
|
|
27985
|
+
dayUsd: NonNegativeUsdSchema,
|
|
27986
|
+
weekUsd: NonNegativeUsdSchema,
|
|
27987
|
+
monthUsd: NonNegativeUsdSchema
|
|
27988
|
+
});
|
|
27989
|
+
var OrganizationBillingSettingsSchema = external_exports.object({
|
|
27990
|
+
organizationId: OrganizationIdSchema,
|
|
27991
|
+
// Null means no limit for that window.
|
|
27992
|
+
spendLimitHourUsd: PositiveUsdSchema.nullable(),
|
|
27993
|
+
spendLimitDayUsd: PositiveUsdSchema.nullable(),
|
|
27994
|
+
spendLimitWeekUsd: PositiveUsdSchema.nullable(),
|
|
27995
|
+
spendLimitMonthUsd: PositiveUsdSchema.nullable(),
|
|
27996
|
+
autoTopUpEnabled: external_exports.boolean(),
|
|
27997
|
+
// Balance at or below the threshold triggers a top-up of the configured
|
|
27998
|
+
// amount. Both must be set for auto-top-up to arm.
|
|
27999
|
+
autoTopUpThresholdUsd: NonNegativeUsdSchema.nullable(),
|
|
28000
|
+
autoTopUpAmountUsd: PositiveUsdSchema.nullable()
|
|
28001
|
+
});
|
|
28002
|
+
var UpdateOrganizationBillingSettingsRequestSchema = external_exports.object({
|
|
28003
|
+
spendLimitHourUsd: PositiveUsdSchema.nullable().optional(),
|
|
28004
|
+
spendLimitDayUsd: PositiveUsdSchema.nullable().optional(),
|
|
28005
|
+
spendLimitWeekUsd: PositiveUsdSchema.nullable().optional(),
|
|
28006
|
+
spendLimitMonthUsd: PositiveUsdSchema.nullable().optional(),
|
|
28007
|
+
autoTopUpEnabled: external_exports.boolean().optional(),
|
|
28008
|
+
autoTopUpThresholdUsd: NonNegativeUsdSchema.nullable().optional(),
|
|
28009
|
+
autoTopUpAmountUsd: PositiveUsdSchema.nullable().optional()
|
|
28010
|
+
}).strict();
|
|
28011
|
+
var OrganizationCreditsResponseSchema = external_exports.object({
|
|
28012
|
+
organizationId: OrganizationIdSchema,
|
|
28013
|
+
balanceUsd: UsdAmountSchema,
|
|
28014
|
+
totalCreditsUsd: UsdAmountSchema,
|
|
28015
|
+
totalBilledUsageUsd: NonNegativeUsdSchema,
|
|
28016
|
+
events: external_exports.array(CreditEventRecordSchema)
|
|
28017
|
+
});
|
|
28018
|
+
var AddOrganizationCreditsRequestSchema = external_exports.object({
|
|
28019
|
+
amountUsd: PositiveUsdSchema.max(1e4),
|
|
28020
|
+
description: external_exports.string().trim().min(1).max(500).optional()
|
|
28021
|
+
}).strict();
|
|
28022
|
+
|
|
27932
28023
|
// ../../packages/schemas/src/pricing.ts
|
|
27933
28024
|
var RATE_CARD_2026_06_23 = {
|
|
27934
28025
|
version: "2026-06-23",
|
|
@@ -36705,7 +36796,7 @@ var ModelCredentialFundingSourceSchema = external_exports.enum([
|
|
|
36705
36796
|
"tenant_provider_grant"
|
|
36706
36797
|
]);
|
|
36707
36798
|
var NonNegativeTokenCountSchema = external_exports.number().int().nonnegative();
|
|
36708
|
-
var
|
|
36799
|
+
var NonNegativeUsdSchema2 = external_exports.number().nonnegative();
|
|
36709
36800
|
var UsageEventSchema = external_exports.object({
|
|
36710
36801
|
// Tenant + lineage attribution. projectId is nullable because a resource can
|
|
36711
36802
|
// belong directly to an organization with no project.
|
|
@@ -36724,11 +36815,16 @@ var UsageEventSchema = external_exports.object({
|
|
|
36724
36815
|
cacheReadTokens: NonNegativeTokenCountSchema,
|
|
36725
36816
|
// The provider's own cost when it reports one, kept only for reconciliation.
|
|
36726
36817
|
// Nullable/absent because it can be 0 or missing — never the billing source.
|
|
36727
|
-
providerCostUsd:
|
|
36818
|
+
providerCostUsd: NonNegativeUsdSchema2.nullable(),
|
|
36728
36819
|
// Platform-derived cost and the rate-card version it was derived under, so a
|
|
36729
36820
|
// later rate-card change never silently rewrites historical cost.
|
|
36730
|
-
derivedCostUsd:
|
|
36821
|
+
derivedCostUsd: NonNegativeUsdSchema2,
|
|
36731
36822
|
pricingVersion: external_exports.string().trim().min(1),
|
|
36823
|
+
// What this call debits from the organization's credit balance, and the fee
|
|
36824
|
+
// card it was derived under (see `./billing`). Required — a writer that
|
|
36825
|
+
// forgets it would silently record unbilled usage, so there is no default.
|
|
36826
|
+
billedCostUsd: NonNegativeUsdSchema2,
|
|
36827
|
+
billingFeeVersion: external_exports.string().trim().min(1),
|
|
36732
36828
|
// Historical funding attribution for the model call. The provider grant id is
|
|
36733
36829
|
// denormalized and nullable for platform-funded usage, matching the ledger's
|
|
36734
36830
|
// no-FK audit-trail contract.
|
|
@@ -36750,7 +36846,7 @@ var UsageTotalsSchema = external_exports.object({
|
|
|
36750
36846
|
cacheCreationTokens: NonNegativeTokenCountSchema,
|
|
36751
36847
|
cacheReadTokens: NonNegativeTokenCountSchema,
|
|
36752
36848
|
totalTokens: NonNegativeTokenCountSchema,
|
|
36753
|
-
|
|
36849
|
+
billedCostUsd: NonNegativeUsdSchema2
|
|
36754
36850
|
});
|
|
36755
36851
|
var SessionUsageModelSummarySchema = UsageTotalsSchema.extend({
|
|
36756
36852
|
model: external_exports.string().trim().min(1)
|
|
@@ -36784,11 +36880,11 @@ var ProjectUsageModelSummarySchema = UsageTotalsSchema.extend({
|
|
|
36784
36880
|
});
|
|
36785
36881
|
var ProjectUsageDayAgentSliceSchema = external_exports.object({
|
|
36786
36882
|
agentResourceId: external_exports.string().trim().min(1),
|
|
36787
|
-
|
|
36883
|
+
billedCostUsd: NonNegativeUsdSchema2
|
|
36788
36884
|
});
|
|
36789
36885
|
var ProjectUsageDayModelSliceSchema = external_exports.object({
|
|
36790
36886
|
model: external_exports.string().trim().min(1),
|
|
36791
|
-
|
|
36887
|
+
billedCostUsd: NonNegativeUsdSchema2
|
|
36792
36888
|
});
|
|
36793
36889
|
var ProjectUsageDayPointSchema = UsageTotalsSchema.extend({
|
|
36794
36890
|
date: UtcDateSchema,
|
|
@@ -66836,7 +66932,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
66836
66932
|
this.input.writeOutput?.(
|
|
66837
66933
|
`agent_bridge_claude_startup_failed duration_ms=${Date.now() - startedAt} error=${error51 instanceof Error ? error51.message : String(error51)}`
|
|
66838
66934
|
);
|
|
66839
|
-
if (this.options.resume !== void 0 && this.state.kind !== "closed") {
|
|
66935
|
+
if (this.options.resume !== void 0 && this.input.allowResumeFallback !== false && this.state.kind !== "closed") {
|
|
66840
66936
|
const { resume, ...optionsWithoutResume } = this.options;
|
|
66841
66937
|
this.options = optionsWithoutResume;
|
|
66842
66938
|
this.input.writeOutput?.(
|
|
@@ -67498,7 +67594,11 @@ var ClaudeCodeCommandHandler = class {
|
|
|
67498
67594
|
context = null;
|
|
67499
67595
|
agentSession = null;
|
|
67500
67596
|
claudeConfig;
|
|
67597
|
+
// Selection-change restarts happen in-process, so prefer the live SDK id even
|
|
67598
|
+
// when the file resume store is stale or temporarily unreadable.
|
|
67599
|
+
lastObservedAgentId = null;
|
|
67501
67600
|
persistedAgentId = null;
|
|
67601
|
+
requireResumeForNextAgentSession = false;
|
|
67502
67602
|
injectedCommands = /* @__PURE__ */ new Set();
|
|
67503
67603
|
// Message commands whose injection has started but not settled. A fresh SDK
|
|
67504
67604
|
// warm inside sendMessage can outlast the bridge's command-ack window, so a
|
|
@@ -67922,14 +68022,19 @@ var ClaudeCodeCommandHandler = class {
|
|
|
67922
68022
|
);
|
|
67923
68023
|
}
|
|
67924
68024
|
persistAgentId(activeContext, message) {
|
|
67925
|
-
|
|
67926
|
-
if (!store) {
|
|
68025
|
+
if (!("session_id" in message) || typeof message.session_id !== "string") {
|
|
67927
68026
|
return;
|
|
67928
68027
|
}
|
|
67929
|
-
if (!
|
|
68028
|
+
if (!message.session_id) {
|
|
67930
68029
|
return;
|
|
67931
68030
|
}
|
|
67932
|
-
|
|
68031
|
+
this.lastObservedAgentId = message.session_id;
|
|
68032
|
+
this.requireResumeForNextAgentSession = false;
|
|
68033
|
+
const store = this.input.sessionResume;
|
|
68034
|
+
if (!store) {
|
|
68035
|
+
return;
|
|
68036
|
+
}
|
|
68037
|
+
if (message.session_id === this.persistedAgentId) {
|
|
67933
68038
|
return;
|
|
67934
68039
|
}
|
|
67935
68040
|
try {
|
|
@@ -67959,13 +68064,24 @@ var ClaudeCodeCommandHandler = class {
|
|
|
67959
68064
|
return void 0;
|
|
67960
68065
|
}
|
|
67961
68066
|
}
|
|
68067
|
+
resumeAgentIdForNextSession() {
|
|
68068
|
+
return this.lastObservedAgentId ?? this.storedResumeAgentId();
|
|
68069
|
+
}
|
|
67962
68070
|
ensureAgentSession() {
|
|
67963
68071
|
if (this.agentSession) {
|
|
67964
68072
|
return this.agentSession;
|
|
67965
68073
|
}
|
|
68074
|
+
const resumeRequired = this.requireResumeForNextAgentSession;
|
|
68075
|
+
const resumeAgentId = this.resumeAgentIdForNextSession();
|
|
68076
|
+
if (resumeRequired && !resumeAgentId) {
|
|
68077
|
+
throw new Error(
|
|
68078
|
+
"Cannot restart Claude Code for a model/effort selection change without a session id to resume"
|
|
68079
|
+
);
|
|
68080
|
+
}
|
|
67966
68081
|
const session = claudeAgentBridgeRuntime.start({
|
|
67967
68082
|
claude: this.claudeConfig,
|
|
67968
|
-
resumeAgentId
|
|
68083
|
+
resumeAgentId,
|
|
68084
|
+
...resumeRequired ? { allowResumeFallback: false } : {},
|
|
67969
68085
|
canUseTool: this.canUseTool,
|
|
67970
68086
|
onMessage: (message, meta3) => this.handleAgentMessage(message, meta3),
|
|
67971
68087
|
onError: (error51) => this.handleAgentError(error51),
|
|
@@ -67995,6 +68111,7 @@ var ClaudeCodeCommandHandler = class {
|
|
|
67995
68111
|
return;
|
|
67996
68112
|
}
|
|
67997
68113
|
this.claudeConfig = next;
|
|
68114
|
+
this.requireResumeForNextAgentSession = this.lastObservedAgentId !== null;
|
|
67998
68115
|
this.agentSession?.close();
|
|
67999
68116
|
this.agentSession = null;
|
|
68000
68117
|
this.settlePendingQuestions("The runtime restarted to change model");
|
package/dist/index.js
CHANGED
|
@@ -15424,6 +15424,8 @@ var init_auth = __esm({
|
|
|
15424
15424
|
"provider_grants:write",
|
|
15425
15425
|
"provider_grants:use",
|
|
15426
15426
|
"members:read",
|
|
15427
|
+
"billing:read",
|
|
15428
|
+
"billing:write",
|
|
15427
15429
|
"secrets:read",
|
|
15428
15430
|
"secrets:write",
|
|
15429
15431
|
"secrets:use",
|
|
@@ -19477,6 +19479,12 @@ var init_sessions = __esm({
|
|
|
19477
19479
|
// Additive and optional so older live frames/list payloads that predate the
|
|
19478
19480
|
// projection keep parsing; new projections include null when no reason exists.
|
|
19479
19481
|
failureReason: external_exports.string().nullable().optional(),
|
|
19482
|
+
// Additive and optional so older live frames/list payloads that predate the
|
|
19483
|
+
// projection keep parsing; new projections include null when no selection
|
|
19484
|
+
// exists. Carried so a session-upsert after a selection change keeps the
|
|
19485
|
+
// open-session React Query record in sync without a full refetch.
|
|
19486
|
+
model: ResolvedAgentModelSelectionSchema.nullable().optional(),
|
|
19487
|
+
reasoningEffort: external_exports.string().trim().min(1).nullable().optional(),
|
|
19480
19488
|
agent: SessionListItemAgentSchema,
|
|
19481
19489
|
createdAt: external_exports.string().datetime(),
|
|
19482
19490
|
updatedAt: external_exports.string().datetime(),
|
|
@@ -19554,6 +19562,97 @@ var init_organization_settings = __esm({
|
|
|
19554
19562
|
}
|
|
19555
19563
|
});
|
|
19556
19564
|
|
|
19565
|
+
// ../../packages/schemas/src/billing.ts
|
|
19566
|
+
var FEE_CARD_2026_07_06, BILLING_FEE_CARDS, CURRENT_BILLING_FEE_VERSION, CREDIT_EVENT_TYPES, CreditEventTypeSchema, UsdAmountSchema, NonNegativeUsdSchema, PositiveUsdSchema, CreditEventSchema, CreditEventRecordSchema, SPENDING_LIMIT_WINDOWS, SpendingLimitWindowSchema, BilledSpendWindowsSchema, OrganizationBillingSettingsSchema, UpdateOrganizationBillingSettingsRequestSchema, OrganizationCreditsResponseSchema, AddOrganizationCreditsRequestSchema;
|
|
19567
|
+
var init_billing = __esm({
|
|
19568
|
+
"../../packages/schemas/src/billing.ts"() {
|
|
19569
|
+
"use strict";
|
|
19570
|
+
init_zod();
|
|
19571
|
+
init_ids();
|
|
19572
|
+
FEE_CARD_2026_07_06 = {
|
|
19573
|
+
version: "2026-07-06",
|
|
19574
|
+
effectiveAt: "2026-07-06T00:00:00.000Z",
|
|
19575
|
+
feeRate: 0.05
|
|
19576
|
+
};
|
|
19577
|
+
BILLING_FEE_CARDS = {
|
|
19578
|
+
[FEE_CARD_2026_07_06.version]: FEE_CARD_2026_07_06
|
|
19579
|
+
};
|
|
19580
|
+
CURRENT_BILLING_FEE_VERSION = FEE_CARD_2026_07_06.version;
|
|
19581
|
+
CREDIT_EVENT_TYPES = [
|
|
19582
|
+
"signup_grant",
|
|
19583
|
+
"purchase",
|
|
19584
|
+
"auto_topup",
|
|
19585
|
+
"adjustment"
|
|
19586
|
+
];
|
|
19587
|
+
CreditEventTypeSchema = external_exports.enum(CREDIT_EVENT_TYPES);
|
|
19588
|
+
UsdAmountSchema = external_exports.number().finite();
|
|
19589
|
+
NonNegativeUsdSchema = external_exports.number().finite().nonnegative();
|
|
19590
|
+
PositiveUsdSchema = external_exports.number().finite().positive();
|
|
19591
|
+
CreditEventSchema = external_exports.object({
|
|
19592
|
+
organizationId: OrganizationIdSchema,
|
|
19593
|
+
type: CreditEventTypeSchema,
|
|
19594
|
+
amountUsd: UsdAmountSchema,
|
|
19595
|
+
description: external_exports.string().trim().min(1).nullable().default(null),
|
|
19596
|
+
// The acting user for manual purchases/adjustments; null for system-issued
|
|
19597
|
+
// rows (signup grants, auto-top-ups).
|
|
19598
|
+
createdByUserId: external_exports.string().trim().min(1).nullable().default(null)
|
|
19599
|
+
}).refine(
|
|
19600
|
+
(event) => event.type === "adjustment" || event.amountUsd > 0,
|
|
19601
|
+
"Only adjustment credit events may carry a non-positive amount"
|
|
19602
|
+
);
|
|
19603
|
+
CreditEventRecordSchema = external_exports.object({
|
|
19604
|
+
id: external_exports.string().trim().min(1),
|
|
19605
|
+
organizationId: OrganizationIdSchema,
|
|
19606
|
+
type: CreditEventTypeSchema,
|
|
19607
|
+
amountUsd: UsdAmountSchema,
|
|
19608
|
+
description: external_exports.string().trim().min(1).nullable(),
|
|
19609
|
+
createdByUserId: external_exports.string().trim().min(1).nullable(),
|
|
19610
|
+
createdAt: external_exports.string().datetime()
|
|
19611
|
+
});
|
|
19612
|
+
SPENDING_LIMIT_WINDOWS = ["hour", "day", "week", "month"];
|
|
19613
|
+
SpendingLimitWindowSchema = external_exports.enum(SPENDING_LIMIT_WINDOWS);
|
|
19614
|
+
BilledSpendWindowsSchema = external_exports.object({
|
|
19615
|
+
hourUsd: NonNegativeUsdSchema,
|
|
19616
|
+
dayUsd: NonNegativeUsdSchema,
|
|
19617
|
+
weekUsd: NonNegativeUsdSchema,
|
|
19618
|
+
monthUsd: NonNegativeUsdSchema
|
|
19619
|
+
});
|
|
19620
|
+
OrganizationBillingSettingsSchema = external_exports.object({
|
|
19621
|
+
organizationId: OrganizationIdSchema,
|
|
19622
|
+
// Null means no limit for that window.
|
|
19623
|
+
spendLimitHourUsd: PositiveUsdSchema.nullable(),
|
|
19624
|
+
spendLimitDayUsd: PositiveUsdSchema.nullable(),
|
|
19625
|
+
spendLimitWeekUsd: PositiveUsdSchema.nullable(),
|
|
19626
|
+
spendLimitMonthUsd: PositiveUsdSchema.nullable(),
|
|
19627
|
+
autoTopUpEnabled: external_exports.boolean(),
|
|
19628
|
+
// Balance at or below the threshold triggers a top-up of the configured
|
|
19629
|
+
// amount. Both must be set for auto-top-up to arm.
|
|
19630
|
+
autoTopUpThresholdUsd: NonNegativeUsdSchema.nullable(),
|
|
19631
|
+
autoTopUpAmountUsd: PositiveUsdSchema.nullable()
|
|
19632
|
+
});
|
|
19633
|
+
UpdateOrganizationBillingSettingsRequestSchema = external_exports.object({
|
|
19634
|
+
spendLimitHourUsd: PositiveUsdSchema.nullable().optional(),
|
|
19635
|
+
spendLimitDayUsd: PositiveUsdSchema.nullable().optional(),
|
|
19636
|
+
spendLimitWeekUsd: PositiveUsdSchema.nullable().optional(),
|
|
19637
|
+
spendLimitMonthUsd: PositiveUsdSchema.nullable().optional(),
|
|
19638
|
+
autoTopUpEnabled: external_exports.boolean().optional(),
|
|
19639
|
+
autoTopUpThresholdUsd: NonNegativeUsdSchema.nullable().optional(),
|
|
19640
|
+
autoTopUpAmountUsd: PositiveUsdSchema.nullable().optional()
|
|
19641
|
+
}).strict();
|
|
19642
|
+
OrganizationCreditsResponseSchema = external_exports.object({
|
|
19643
|
+
organizationId: OrganizationIdSchema,
|
|
19644
|
+
balanceUsd: UsdAmountSchema,
|
|
19645
|
+
totalCreditsUsd: UsdAmountSchema,
|
|
19646
|
+
totalBilledUsageUsd: NonNegativeUsdSchema,
|
|
19647
|
+
events: external_exports.array(CreditEventRecordSchema)
|
|
19648
|
+
});
|
|
19649
|
+
AddOrganizationCreditsRequestSchema = external_exports.object({
|
|
19650
|
+
amountUsd: PositiveUsdSchema.max(1e4),
|
|
19651
|
+
description: external_exports.string().trim().min(1).max(500).optional()
|
|
19652
|
+
}).strict();
|
|
19653
|
+
}
|
|
19654
|
+
});
|
|
19655
|
+
|
|
19557
19656
|
// ../../packages/schemas/src/pricing.ts
|
|
19558
19657
|
function tier(inputUsdPerMtok, outputUsdPerMtok) {
|
|
19559
19658
|
return {
|
|
@@ -28547,7 +28646,7 @@ var init_url_slugs = __esm({
|
|
|
28547
28646
|
});
|
|
28548
28647
|
|
|
28549
28648
|
// ../../packages/schemas/src/usage.ts
|
|
28550
|
-
var UsageHarnessSchema, ModelCredentialFundingSourceSchema, NonNegativeTokenCountSchema,
|
|
28649
|
+
var UsageHarnessSchema, ModelCredentialFundingSourceSchema, NonNegativeTokenCountSchema, NonNegativeUsdSchema2, UsageEventSchema, UsageEventRecordSchema, UsageTotalsSchema, SessionUsageModelSummarySchema, SessionUsageResponseSchema, PROJECT_USAGE_RANGE_KEYS, ProjectUsageRangeKeySchema, UtcDateSchema, ProjectUsageTotalsSchema, ProjectUsageAgentSummarySchema, ProjectUsageModelSummarySchema, ProjectUsageDayAgentSliceSchema, ProjectUsageDayModelSliceSchema, ProjectUsageDayPointSchema, ProjectUsageResponseSchema;
|
|
28551
28650
|
var init_usage = __esm({
|
|
28552
28651
|
"../../packages/schemas/src/usage.ts"() {
|
|
28553
28652
|
"use strict";
|
|
@@ -28560,7 +28659,7 @@ var init_usage = __esm({
|
|
|
28560
28659
|
"tenant_provider_grant"
|
|
28561
28660
|
]);
|
|
28562
28661
|
NonNegativeTokenCountSchema = external_exports.number().int().nonnegative();
|
|
28563
|
-
|
|
28662
|
+
NonNegativeUsdSchema2 = external_exports.number().nonnegative();
|
|
28564
28663
|
UsageEventSchema = external_exports.object({
|
|
28565
28664
|
// Tenant + lineage attribution. projectId is nullable because a resource can
|
|
28566
28665
|
// belong directly to an organization with no project.
|
|
@@ -28579,11 +28678,16 @@ var init_usage = __esm({
|
|
|
28579
28678
|
cacheReadTokens: NonNegativeTokenCountSchema,
|
|
28580
28679
|
// The provider's own cost when it reports one, kept only for reconciliation.
|
|
28581
28680
|
// Nullable/absent because it can be 0 or missing — never the billing source.
|
|
28582
|
-
providerCostUsd:
|
|
28681
|
+
providerCostUsd: NonNegativeUsdSchema2.nullable(),
|
|
28583
28682
|
// Platform-derived cost and the rate-card version it was derived under, so a
|
|
28584
28683
|
// later rate-card change never silently rewrites historical cost.
|
|
28585
|
-
derivedCostUsd:
|
|
28684
|
+
derivedCostUsd: NonNegativeUsdSchema2,
|
|
28586
28685
|
pricingVersion: external_exports.string().trim().min(1),
|
|
28686
|
+
// What this call debits from the organization's credit balance, and the fee
|
|
28687
|
+
// card it was derived under (see `./billing`). Required — a writer that
|
|
28688
|
+
// forgets it would silently record unbilled usage, so there is no default.
|
|
28689
|
+
billedCostUsd: NonNegativeUsdSchema2,
|
|
28690
|
+
billingFeeVersion: external_exports.string().trim().min(1),
|
|
28587
28691
|
// Historical funding attribution for the model call. The provider grant id is
|
|
28588
28692
|
// denormalized and nullable for platform-funded usage, matching the ledger's
|
|
28589
28693
|
// no-FK audit-trail contract.
|
|
@@ -28605,7 +28709,7 @@ var init_usage = __esm({
|
|
|
28605
28709
|
cacheCreationTokens: NonNegativeTokenCountSchema,
|
|
28606
28710
|
cacheReadTokens: NonNegativeTokenCountSchema,
|
|
28607
28711
|
totalTokens: NonNegativeTokenCountSchema,
|
|
28608
|
-
|
|
28712
|
+
billedCostUsd: NonNegativeUsdSchema2
|
|
28609
28713
|
});
|
|
28610
28714
|
SessionUsageModelSummarySchema = UsageTotalsSchema.extend({
|
|
28611
28715
|
model: external_exports.string().trim().min(1)
|
|
@@ -28639,11 +28743,11 @@ var init_usage = __esm({
|
|
|
28639
28743
|
});
|
|
28640
28744
|
ProjectUsageDayAgentSliceSchema = external_exports.object({
|
|
28641
28745
|
agentResourceId: external_exports.string().trim().min(1),
|
|
28642
|
-
|
|
28746
|
+
billedCostUsd: NonNegativeUsdSchema2
|
|
28643
28747
|
});
|
|
28644
28748
|
ProjectUsageDayModelSliceSchema = external_exports.object({
|
|
28645
28749
|
model: external_exports.string().trim().min(1),
|
|
28646
|
-
|
|
28750
|
+
billedCostUsd: NonNegativeUsdSchema2
|
|
28647
28751
|
});
|
|
28648
28752
|
ProjectUsageDayPointSchema = UsageTotalsSchema.extend({
|
|
28649
28753
|
date: UtcDateSchema,
|
|
@@ -28689,6 +28793,7 @@ var init_src = __esm({
|
|
|
28689
28793
|
init_model_selection();
|
|
28690
28794
|
init_mounts();
|
|
28691
28795
|
init_organization_settings();
|
|
28796
|
+
init_billing();
|
|
28692
28797
|
init_pricing();
|
|
28693
28798
|
init_provider_grants();
|
|
28694
28799
|
init_project_config();
|
|
@@ -31450,7 +31555,7 @@ var init_package = __esm({
|
|
|
31450
31555
|
"package.json"() {
|
|
31451
31556
|
package_default = {
|
|
31452
31557
|
name: "@autohq/cli",
|
|
31453
|
-
version: "0.1.
|
|
31558
|
+
version: "0.1.362",
|
|
31454
31559
|
license: "SEE LICENSE IN README.md",
|
|
31455
31560
|
publishConfig: {
|
|
31456
31561
|
access: "public"
|
|
@@ -44498,7 +44603,7 @@ var ClaudeAgentBridgeSessionImpl = class {
|
|
|
44498
44603
|
this.input.writeOutput?.(
|
|
44499
44604
|
`agent_bridge_claude_startup_failed duration_ms=${Date.now() - startedAt} error=${error51 instanceof Error ? error51.message : String(error51)}`
|
|
44500
44605
|
);
|
|
44501
|
-
if (this.options.resume !== void 0 && this.state.kind !== "closed") {
|
|
44606
|
+
if (this.options.resume !== void 0 && this.input.allowResumeFallback !== false && this.state.kind !== "closed") {
|
|
44502
44607
|
const { resume, ...optionsWithoutResume } = this.options;
|
|
44503
44608
|
this.options = optionsWithoutResume;
|
|
44504
44609
|
this.input.writeOutput?.(
|
|
@@ -45160,7 +45265,11 @@ var ClaudeCodeCommandHandler = class {
|
|
|
45160
45265
|
context = null;
|
|
45161
45266
|
agentSession = null;
|
|
45162
45267
|
claudeConfig;
|
|
45268
|
+
// Selection-change restarts happen in-process, so prefer the live SDK id even
|
|
45269
|
+
// when the file resume store is stale or temporarily unreadable.
|
|
45270
|
+
lastObservedAgentId = null;
|
|
45163
45271
|
persistedAgentId = null;
|
|
45272
|
+
requireResumeForNextAgentSession = false;
|
|
45164
45273
|
injectedCommands = /* @__PURE__ */ new Set();
|
|
45165
45274
|
// Message commands whose injection has started but not settled. A fresh SDK
|
|
45166
45275
|
// warm inside sendMessage can outlast the bridge's command-ack window, so a
|
|
@@ -45584,14 +45693,19 @@ var ClaudeCodeCommandHandler = class {
|
|
|
45584
45693
|
);
|
|
45585
45694
|
}
|
|
45586
45695
|
persistAgentId(activeContext, message) {
|
|
45587
|
-
|
|
45588
|
-
if (!store) {
|
|
45696
|
+
if (!("session_id" in message) || typeof message.session_id !== "string") {
|
|
45589
45697
|
return;
|
|
45590
45698
|
}
|
|
45591
|
-
if (!
|
|
45699
|
+
if (!message.session_id) {
|
|
45592
45700
|
return;
|
|
45593
45701
|
}
|
|
45594
|
-
|
|
45702
|
+
this.lastObservedAgentId = message.session_id;
|
|
45703
|
+
this.requireResumeForNextAgentSession = false;
|
|
45704
|
+
const store = this.input.sessionResume;
|
|
45705
|
+
if (!store) {
|
|
45706
|
+
return;
|
|
45707
|
+
}
|
|
45708
|
+
if (message.session_id === this.persistedAgentId) {
|
|
45595
45709
|
return;
|
|
45596
45710
|
}
|
|
45597
45711
|
try {
|
|
@@ -45621,13 +45735,24 @@ var ClaudeCodeCommandHandler = class {
|
|
|
45621
45735
|
return void 0;
|
|
45622
45736
|
}
|
|
45623
45737
|
}
|
|
45738
|
+
resumeAgentIdForNextSession() {
|
|
45739
|
+
return this.lastObservedAgentId ?? this.storedResumeAgentId();
|
|
45740
|
+
}
|
|
45624
45741
|
ensureAgentSession() {
|
|
45625
45742
|
if (this.agentSession) {
|
|
45626
45743
|
return this.agentSession;
|
|
45627
45744
|
}
|
|
45745
|
+
const resumeRequired = this.requireResumeForNextAgentSession;
|
|
45746
|
+
const resumeAgentId = this.resumeAgentIdForNextSession();
|
|
45747
|
+
if (resumeRequired && !resumeAgentId) {
|
|
45748
|
+
throw new Error(
|
|
45749
|
+
"Cannot restart Claude Code for a model/effort selection change without a session id to resume"
|
|
45750
|
+
);
|
|
45751
|
+
}
|
|
45628
45752
|
const session = claudeAgentBridgeRuntime.start({
|
|
45629
45753
|
claude: this.claudeConfig,
|
|
45630
|
-
resumeAgentId
|
|
45754
|
+
resumeAgentId,
|
|
45755
|
+
...resumeRequired ? { allowResumeFallback: false } : {},
|
|
45631
45756
|
canUseTool: this.canUseTool,
|
|
45632
45757
|
onMessage: (message, meta3) => this.handleAgentMessage(message, meta3),
|
|
45633
45758
|
onError: (error51) => this.handleAgentError(error51),
|
|
@@ -45657,6 +45782,7 @@ var ClaudeCodeCommandHandler = class {
|
|
|
45657
45782
|
return;
|
|
45658
45783
|
}
|
|
45659
45784
|
this.claudeConfig = next;
|
|
45785
|
+
this.requireResumeForNextAgentSession = this.lastObservedAgentId !== null;
|
|
45660
45786
|
this.agentSession?.close();
|
|
45661
45787
|
this.agentSession = null;
|
|
45662
45788
|
this.settlePendingQuestions("The runtime restarted to change model");
|