@oneharness/sdk 0.21.3 → 0.22.0

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.
@@ -17603,6 +17603,169 @@
17603
17603
  }
17604
17604
  ]
17605
17605
  },
17606
+ "ResetCredit": {
17607
+ "description": "One listed reset credit. `status` and `reset_type` are the harness's own\nwords, **verbatim** like [`UsageIdentity::plan`], so a value this release\nhas never seen is reported as itself rather than refused.",
17608
+ "type": "object",
17609
+ "properties": {
17610
+ "description": {
17611
+ "type": [
17612
+ "string",
17613
+ "null"
17614
+ ]
17615
+ },
17616
+ "expires_at": {
17617
+ "description": "When the credit expires. Absent when the harness said it does not.",
17618
+ "anyOf": [
17619
+ {
17620
+ "$ref": "#/$defs/UtcInstant"
17621
+ },
17622
+ {
17623
+ "type": "null"
17624
+ }
17625
+ ]
17626
+ },
17627
+ "granted_at": {
17628
+ "$ref": "#/$defs/UtcInstant"
17629
+ },
17630
+ "id": {
17631
+ "description": "The harness's opaque identifier for this credit.",
17632
+ "type": "string"
17633
+ },
17634
+ "reset_type": {
17635
+ "description": "What the credit resets, as the harness spells it (codex:\n`codexRateLimits`).",
17636
+ "type": "string"
17637
+ },
17638
+ "status": {
17639
+ "description": "The credit's status as the harness spells it (codex: `available`,\n`redeeming`, `redeemed`, `unknown`).",
17640
+ "type": "string"
17641
+ },
17642
+ "title": {
17643
+ "type": [
17644
+ "string",
17645
+ "null"
17646
+ ]
17647
+ }
17648
+ },
17649
+ "required": [
17650
+ "id",
17651
+ "status",
17652
+ "reset_type",
17653
+ "granted_at"
17654
+ ]
17655
+ },
17656
+ "ResetCredits": {
17657
+ "description": "The banked rate-limit **reset credits** an identity holds — capacity a window\nat 100% used does not show. Harness-neutral: codex fills it from its\n`rateLimitResetCredits` summary, and a harness with no reader says so.\n\nLike [`UsageAvailability`], `unknown` means only that nothing was learned and\nis never zero: \"no credits\" is exactly `reported` with an `available_count`\nof 0.",
17658
+ "oneOf": [
17659
+ {
17660
+ "description": "The harness answered with a credits summary.",
17661
+ "type": "object",
17662
+ "properties": {
17663
+ "available_count": {
17664
+ "description": "The harness's own count, and the authoritative total — never derived\nfrom `credits`, which the harness may cap below it.",
17665
+ "type": "integer",
17666
+ "format": "uint64",
17667
+ "minimum": 0
17668
+ },
17669
+ "credits": {
17670
+ "description": "The credits the harness listed. Absent when it reported only the\ncount; present — possibly empty, possibly shorter than\n`available_count` — when it listed them.",
17671
+ "type": [
17672
+ "array",
17673
+ "null"
17674
+ ],
17675
+ "items": {
17676
+ "$ref": "#/$defs/ResetCredit"
17677
+ }
17678
+ },
17679
+ "state": {
17680
+ "type": "string",
17681
+ "const": "reported"
17682
+ }
17683
+ },
17684
+ "required": [
17685
+ "state",
17686
+ "available_count"
17687
+ ]
17688
+ },
17689
+ {
17690
+ "description": "Nothing was learned about this identity's credits.",
17691
+ "type": "object",
17692
+ "properties": {
17693
+ "reason": {
17694
+ "$ref": "#/$defs/ResetCreditsUnknown"
17695
+ },
17696
+ "state": {
17697
+ "type": "string",
17698
+ "const": "unknown"
17699
+ }
17700
+ },
17701
+ "required": [
17702
+ "state",
17703
+ "reason"
17704
+ ]
17705
+ }
17706
+ ]
17707
+ },
17708
+ "ResetCreditsUnknown": {
17709
+ "description": "Why an identity's reset credits are unknown.",
17710
+ "oneOf": [
17711
+ {
17712
+ "description": "This oneharness reads no reset credits for this harness.",
17713
+ "type": "object",
17714
+ "properties": {
17715
+ "kind": {
17716
+ "type": "string",
17717
+ "const": "no_reader"
17718
+ }
17719
+ },
17720
+ "required": [
17721
+ "kind"
17722
+ ]
17723
+ },
17724
+ {
17725
+ "description": "The probe produced no rate-limit answer to read credits from — the\nidentity's `availability` says why.",
17726
+ "type": "object",
17727
+ "properties": {
17728
+ "kind": {
17729
+ "type": "string",
17730
+ "const": "no_answer"
17731
+ }
17732
+ },
17733
+ "required": [
17734
+ "kind"
17735
+ ]
17736
+ },
17737
+ {
17738
+ "description": "The harness answered, but its answer carried no credits summary.",
17739
+ "type": "object",
17740
+ "properties": {
17741
+ "kind": {
17742
+ "type": "string",
17743
+ "const": "not_reported"
17744
+ }
17745
+ },
17746
+ "required": [
17747
+ "kind"
17748
+ ]
17749
+ },
17750
+ {
17751
+ "description": "A summary was present but structurally malformed.",
17752
+ "type": "object",
17753
+ "properties": {
17754
+ "kind": {
17755
+ "type": "string",
17756
+ "const": "unreadable"
17757
+ },
17758
+ "message": {
17759
+ "type": "string"
17760
+ }
17761
+ },
17762
+ "required": [
17763
+ "kind",
17764
+ "message"
17765
+ ]
17766
+ }
17767
+ ]
17768
+ },
17606
17769
  "UnavailableReason": {
17607
17770
  "description": "Why an identity affirmatively has no plan headroom. Distinct from\n[`UnknownReason`]: these are answers, not absences of one.",
17608
17771
  "oneOf": [
@@ -17762,6 +17925,10 @@
17762
17925
  "null"
17763
17926
  ]
17764
17927
  },
17928
+ "reset_credits": {
17929
+ "description": "The banked reset credits this identity holds, always serialized so its\nabsence is never read as \"none\". A report written before the field\nexisted reads it as `unknown` / `no_reader`.",
17930
+ "$ref": "#/$defs/ResetCredits"
17931
+ },
17765
17932
  "selector": {
17766
17933
  "description": "How this identity was selected — never the credential itself.",
17767
17934
  "$ref": "#/$defs/IdentitySelector"
@@ -17778,7 +17945,8 @@
17778
17945
  "harness",
17779
17946
  "selector",
17780
17947
  "auth_mode",
17781
- "availability"
17948
+ "availability",
17949
+ "reset_credits"
17782
17950
  ]
17783
17951
  },
17784
17952
  "UsageWindow": {
@@ -139,6 +139,23 @@ export type UnknownReason = {
139
139
  kind: "binary_missing";
140
140
  [k: string]: unknown;
141
141
  };
142
+ /**
143
+ * Why an identity's reset credits are unknown.
144
+ */
145
+ export type ResetCreditsUnknown = {
146
+ kind: "no_reader";
147
+ [k: string]: unknown;
148
+ } | {
149
+ kind: "no_answer";
150
+ [k: string]: unknown;
151
+ } | {
152
+ kind: "not_reported";
153
+ [k: string]: unknown;
154
+ } | {
155
+ kind: "unreadable";
156
+ message: string;
157
+ [k: string]: unknown;
158
+ };
142
159
  /**
143
160
  * One usage report: every probed identity, stamped with a single observation
144
161
  * time supplied by the caller (this module reads no clock).
@@ -179,6 +196,30 @@ export interface UsageIdentity {
179
196
  * enum. Absent when the harness reports no plan (an API-key session).
180
197
  */
181
198
  plan?: string | null | undefined;
199
+ /**
200
+ * The banked reset credits this identity holds, always serialized so its
201
+ * absence is never read as "none". A report written before the field
202
+ * existed reads it as `unknown` / `no_reader`.
203
+ */
204
+ reset_credits: {
205
+ /**
206
+ * The harness's own count, and the authoritative total — never derived
207
+ * from `credits`, which the harness may cap below it.
208
+ */
209
+ available_count: number;
210
+ /**
211
+ * The credits the harness listed. Absent when it reported only the
212
+ * count; present — possibly empty, possibly shorter than
213
+ * `available_count` — when it listed them.
214
+ */
215
+ credits?: ResetCredit[] | null | undefined;
216
+ state: "reported";
217
+ [k: string]: unknown;
218
+ } | {
219
+ reason: ResetCreditsUnknown;
220
+ state: "unknown";
221
+ [k: string]: unknown;
222
+ };
182
223
  /**
183
224
  * How this identity was selected — never the credential itself.
184
225
  */
@@ -239,3 +280,32 @@ export interface QuotaCounters {
239
280
  used: QuotaAmount;
240
281
  [k: string]: unknown;
241
282
  }
283
+ /**
284
+ * One listed reset credit. `status` and `reset_type` are the harness's own
285
+ * words, **verbatim** like [`UsageIdentity::plan`], so a value this release
286
+ * has never seen is reported as itself rather than refused.
287
+ */
288
+ export interface ResetCredit {
289
+ description?: string | null | undefined;
290
+ /**
291
+ * When the credit expires. Absent when the harness said it does not.
292
+ */
293
+ expires_at?: UtcInstant | null | undefined;
294
+ granted_at: UtcInstant;
295
+ /**
296
+ * The harness's opaque identifier for this credit.
297
+ */
298
+ id: string;
299
+ /**
300
+ * What the credit resets, as the harness spells it (codex:
301
+ * `codexRateLimits`).
302
+ */
303
+ reset_type: string;
304
+ /**
305
+ * The credit's status as the harness spells it (codex: `available`,
306
+ * `redeeming`, `redeemed`, `unknown`).
307
+ */
308
+ status: string;
309
+ title?: string | null | undefined;
310
+ [k: string]: unknown;
311
+ }
@@ -31,13 +31,14 @@ import type { RunStreamEnvelope } from "./run-stream-envelope.js";
31
31
  import type { SyncOptions } from "./sync-options.js";
32
32
  import type { FileStatus, HookFileResult, RuleChange, RuleList, SyncReport, SyncResult, SyncStatus, UnmappedRule } from "./sync-report.js";
33
33
  import type { UsageOptions } from "./usage-options.js";
34
- import type { AuthMode, QuotaAmount, QuotaCounters, QuotaUnit, UnavailableReason, UnknownReason, UsageAvailability, UsageIdentity, UsageReport, UsageWindow, WindowUsage, Windows } from "./usage-report.js";
34
+ import type { AuthMode, QuotaAmount, QuotaCounters, QuotaUnit, ResetCredit, ResetCreditsUnknown, UnavailableReason, UnknownReason, UsageAvailability, UsageIdentity, UsageReport, UsageWindow, WindowUsage, Windows } from "./usage-report.js";
35
35
  export type AbsolutePath = ControlReport["socket"];
36
36
  export type BatchStrategy = BatchReport["strategy"];
37
37
  export type ControlShape = ControlReport["mechanism"];
38
38
  export type IdentitySelector = UsageIdentity["selector"];
39
39
  export type IncompleteRunType = IncompleteHistoryRun["type"];
40
40
  export type ModeHeadless = ModeInfo["headless"];
41
+ export type ResetCredits = UsageIdentity["reset_credits"];
41
42
  export type SessionPhase = SessionReport["phase"];
42
43
  export type UsedPercent = number;
43
44
  export declare const AbsolutePathSchema: z.ZodType<AbsolutePath>;
@@ -118,6 +119,9 @@ export declare const PermissionModeSchema: z.ZodType<PermissionMode>;
118
119
  export declare const QuotaAmountSchema: z.ZodType<QuotaAmount>;
119
120
  export declare const QuotaCountersSchema: z.ZodType<QuotaCounters>;
120
121
  export declare const QuotaUnitSchema: z.ZodType<QuotaUnit>;
122
+ export declare const ResetCreditSchema: z.ZodType<ResetCredit>;
123
+ export declare const ResetCreditsSchema: z.ZodType<ResetCredits>;
124
+ export declare const ResetCreditsUnknownSchema: z.ZodType<ResetCreditsUnknown>;
121
125
  export declare const RuleChangeSchema: z.ZodType<RuleChange>;
122
126
  export declare const RuleListSchema: z.ZodType<RuleList>;
123
127
  export declare const RunModeSchema: z.ZodType<RunMode>;
@@ -2465,6 +2465,44 @@ export const QuotaCountersSchema = z.looseObject({
2465
2465
  used: z.lazy(() => QuotaAmountSchema).refine((value) => value !== undefined, { message: "Required" }),
2466
2466
  });
2467
2467
  export const QuotaUnitSchema = z.union([z.literal("ai_credits"), z.literal("unspecified")]);
2468
+ export const ResetCreditSchema = z.looseObject({
2469
+ description: z.union([z.string(), z.null()]).optional(),
2470
+ expires_at: z.union([z.lazy(() => UtcInstantSchema), z.null()]).optional(),
2471
+ granted_at: z.lazy(() => UtcInstantSchema).refine((value) => value !== undefined, { message: "Required" }),
2472
+ id: z.string().refine((value) => value !== undefined, { message: "Required" }),
2473
+ reset_type: z.string().refine((value) => value !== undefined, { message: "Required" }),
2474
+ status: z.string().refine((value) => value !== undefined, { message: "Required" }),
2475
+ title: z.union([z.string(), z.null()]).optional(),
2476
+ });
2477
+ export const ResetCreditsSchema = z.union([
2478
+ z.looseObject({
2479
+ available_count: z
2480
+ .int()
2481
+ .gte(0)
2482
+ .refine((value) => value !== undefined, { message: "Required" }),
2483
+ credits: z.union([z.array(z.lazy(() => ResetCreditSchema)), z.null()]).optional(),
2484
+ state: z.literal("reported").refine((value) => value !== undefined, { message: "Required" }),
2485
+ }),
2486
+ z.looseObject({
2487
+ reason: z.lazy(() => ResetCreditsUnknownSchema).refine((value) => value !== undefined, { message: "Required" }),
2488
+ state: z.literal("unknown").refine((value) => value !== undefined, { message: "Required" }),
2489
+ }),
2490
+ ]);
2491
+ export const ResetCreditsUnknownSchema = z.union([
2492
+ z.looseObject({
2493
+ kind: z.literal("no_reader").refine((value) => value !== undefined, { message: "Required" }),
2494
+ }),
2495
+ z.looseObject({
2496
+ kind: z.literal("no_answer").refine((value) => value !== undefined, { message: "Required" }),
2497
+ }),
2498
+ z.looseObject({
2499
+ kind: z.literal("not_reported").refine((value) => value !== undefined, { message: "Required" }),
2500
+ }),
2501
+ z.looseObject({
2502
+ kind: z.literal("unreadable").refine((value) => value !== undefined, { message: "Required" }),
2503
+ message: z.string().refine((value) => value !== undefined, { message: "Required" }),
2504
+ }),
2505
+ ]);
2468
2506
  export const RuleChangeSchema = z.looseObject({
2469
2507
  list: z.union([z.lazy(() => RuleListSchema), z.null()]).optional(),
2470
2508
  rule: z.string().refine((value) => value !== undefined, { message: "Required" }),
@@ -2730,6 +2768,7 @@ export const UsageIdentitySchema = z.looseObject({
2730
2768
  availability: z.lazy(() => UsageAvailabilitySchema).refine((value) => value !== undefined, { message: "Required" }),
2731
2769
  harness: z.string().refine((value) => value !== undefined, { message: "Required" }),
2732
2770
  plan: z.union([z.string(), z.null()]).optional(),
2771
+ reset_credits: z.lazy(() => ResetCreditsSchema).refine((value) => value !== undefined, { message: "Required" }),
2733
2772
  selector: z.lazy(() => IdentitySelectorSchema).refine((value) => value !== undefined, { message: "Required" }),
2734
2773
  variant: z.union([z.string(), z.null()]).optional(),
2735
2774
  });
package/dist/index.js CHANGED
@@ -315,6 +315,8 @@ function capabilityArguments(method, options) {
315
315
  args.push(binding.flag, String(value));
316
316
  break;
317
317
  case "repeated":
318
+ // Zod validated this option against the contract, which types every
319
+ // `repeated` binding as an array.
318
320
  pushMany(args, binding.flag, value.map(String));
319
321
  break;
320
322
  case "switch":
@@ -322,10 +324,14 @@ function capabilityArguments(method, options) {
322
324
  args.push(binding.flag);
323
325
  break;
324
326
  case "key-value":
327
+ // Zod validated this option against the contract, which types every
328
+ // `key-value` binding as an object.
325
329
  for (const [key, item] of Object.entries(value))
326
330
  args.push(binding.flag, `${key}=${String(item)}`);
327
331
  break;
328
332
  case "trailing":
333
+ // Zod validated this option against the contract, which types every
334
+ // `trailing` binding as an array.
329
335
  trailing.push(...value.map(String));
330
336
  break;
331
337
  case "window":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneharness/sdk",
3
- "version": "0.21.3",
3
+ "version": "0.22.0",
4
4
  "description": "Typed Node.js SDK for oneharness",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -19,7 +19,7 @@
19
19
  "node": ">=20"
20
20
  },
21
21
  "dependencies": {
22
- "oneharness-cli": "0.21.3",
22
+ "oneharness-cli": "0.22.0",
23
23
  "zod": "^4.4.3"
24
24
  }
25
25
  }