runcycles 0.1.0 → 0.1.1

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/index.cjs CHANGED
@@ -28,7 +28,6 @@ __export(index_exports, {
28
28
  CyclesError: () => CyclesError,
29
29
  CyclesProtocolError: () => CyclesProtocolError,
30
30
  CyclesResponse: () => CyclesResponse,
31
- CyclesTransportError: () => CyclesTransportError,
32
31
  DebtOutstandingError: () => DebtOutstandingError,
33
32
  Decision: () => Decision,
34
33
  ErrorCode: () => ErrorCode,
@@ -53,7 +52,7 @@ __export(index_exports, {
53
52
  getCyclesContext: () => getCyclesContext,
54
53
  isAllowed: () => isAllowed,
55
54
  isDenied: () => isDenied,
56
- isMetricsEmpty: () => isMetricsEmpty2,
55
+ isMetricsEmpty: () => isMetricsEmpty,
57
56
  isRetryableErrorCode: () => isRetryableErrorCode,
58
57
  isToolAllowed: () => isToolAllowed,
59
58
  metricsToWire: () => metricsToWire,
@@ -76,6 +75,7 @@ module.exports = __toCommonJS(index_exports);
76
75
  // src/constants.ts
77
76
  var API_KEY_HEADER = "X-Cycles-API-Key";
78
77
  var IDEMPOTENCY_KEY_HEADER = "X-Idempotency-Key";
78
+ var DEFAULT_TTL_MS = 6e4;
79
79
  var RESERVATIONS_PATH = "/v1/reservations";
80
80
  var DECIDE_PATH = "/v1/decide";
81
81
  var BALANCES_PATH = "/v1/balances";
@@ -535,6 +535,8 @@ var CyclesClient = class {
535
535
  );
536
536
  }
537
537
  }
538
+ async [Symbol.asyncDispose]() {
539
+ }
538
540
  async _handleResponse(resp) {
539
541
  let body;
540
542
  try {
@@ -720,14 +722,6 @@ var ReservationFinalizedError = class extends CyclesProtocolError {
720
722
  this.name = "ReservationFinalizedError";
721
723
  }
722
724
  };
723
- var CyclesTransportError = class extends CyclesError {
724
- cause;
725
- constructor(message, options) {
726
- super(message);
727
- this.name = "CyclesTransportError";
728
- this.cause = options?.cause;
729
- }
730
- };
731
725
 
732
726
  // src/errors.ts
733
727
  function buildProtocolException(prefix, response) {
@@ -783,6 +777,94 @@ function buildProtocolException(prefix, response) {
783
777
  }
784
778
  }
785
779
 
780
+ // src/models.ts
781
+ var Unit = /* @__PURE__ */ ((Unit2) => {
782
+ Unit2["USD_MICROCENTS"] = "USD_MICROCENTS";
783
+ Unit2["TOKENS"] = "TOKENS";
784
+ Unit2["CREDITS"] = "CREDITS";
785
+ Unit2["RISK_POINTS"] = "RISK_POINTS";
786
+ return Unit2;
787
+ })(Unit || {});
788
+ var CommitOveragePolicy = /* @__PURE__ */ ((CommitOveragePolicy2) => {
789
+ CommitOveragePolicy2["REJECT"] = "REJECT";
790
+ CommitOveragePolicy2["ALLOW_IF_AVAILABLE"] = "ALLOW_IF_AVAILABLE";
791
+ CommitOveragePolicy2["ALLOW_WITH_OVERDRAFT"] = "ALLOW_WITH_OVERDRAFT";
792
+ return CommitOveragePolicy2;
793
+ })(CommitOveragePolicy || {});
794
+ var Decision = /* @__PURE__ */ ((Decision2) => {
795
+ Decision2["ALLOW"] = "ALLOW";
796
+ Decision2["ALLOW_WITH_CAPS"] = "ALLOW_WITH_CAPS";
797
+ Decision2["DENY"] = "DENY";
798
+ return Decision2;
799
+ })(Decision || {});
800
+ var ReservationStatus = /* @__PURE__ */ ((ReservationStatus2) => {
801
+ ReservationStatus2["ACTIVE"] = "ACTIVE";
802
+ ReservationStatus2["COMMITTED"] = "COMMITTED";
803
+ ReservationStatus2["RELEASED"] = "RELEASED";
804
+ ReservationStatus2["EXPIRED"] = "EXPIRED";
805
+ return ReservationStatus2;
806
+ })(ReservationStatus || {});
807
+ var CommitStatus = /* @__PURE__ */ ((CommitStatus2) => {
808
+ CommitStatus2["COMMITTED"] = "COMMITTED";
809
+ return CommitStatus2;
810
+ })(CommitStatus || {});
811
+ var ReleaseStatus = /* @__PURE__ */ ((ReleaseStatus2) => {
812
+ ReleaseStatus2["RELEASED"] = "RELEASED";
813
+ return ReleaseStatus2;
814
+ })(ReleaseStatus || {});
815
+ var ExtendStatus = /* @__PURE__ */ ((ExtendStatus2) => {
816
+ ExtendStatus2["ACTIVE"] = "ACTIVE";
817
+ return ExtendStatus2;
818
+ })(ExtendStatus || {});
819
+ var EventStatus = /* @__PURE__ */ ((EventStatus2) => {
820
+ EventStatus2["APPLIED"] = "APPLIED";
821
+ return EventStatus2;
822
+ })(EventStatus || {});
823
+ var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
824
+ ErrorCode2["INVALID_REQUEST"] = "INVALID_REQUEST";
825
+ ErrorCode2["UNAUTHORIZED"] = "UNAUTHORIZED";
826
+ ErrorCode2["FORBIDDEN"] = "FORBIDDEN";
827
+ ErrorCode2["NOT_FOUND"] = "NOT_FOUND";
828
+ ErrorCode2["BUDGET_EXCEEDED"] = "BUDGET_EXCEEDED";
829
+ ErrorCode2["RESERVATION_EXPIRED"] = "RESERVATION_EXPIRED";
830
+ ErrorCode2["RESERVATION_FINALIZED"] = "RESERVATION_FINALIZED";
831
+ ErrorCode2["IDEMPOTENCY_MISMATCH"] = "IDEMPOTENCY_MISMATCH";
832
+ ErrorCode2["UNIT_MISMATCH"] = "UNIT_MISMATCH";
833
+ ErrorCode2["OVERDRAFT_LIMIT_EXCEEDED"] = "OVERDRAFT_LIMIT_EXCEEDED";
834
+ ErrorCode2["DEBT_OUTSTANDING"] = "DEBT_OUTSTANDING";
835
+ ErrorCode2["INTERNAL_ERROR"] = "INTERNAL_ERROR";
836
+ ErrorCode2["UNKNOWN"] = "UNKNOWN";
837
+ return ErrorCode2;
838
+ })(ErrorCode || {});
839
+ function isAllowed(decision) {
840
+ return decision === "ALLOW" /* ALLOW */ || decision === "ALLOW_WITH_CAPS" /* ALLOW_WITH_CAPS */;
841
+ }
842
+ function isDenied(decision) {
843
+ return decision === "DENY" /* DENY */;
844
+ }
845
+ function isRetryableErrorCode(code) {
846
+ return code === "INTERNAL_ERROR" /* INTERNAL_ERROR */ || code === "UNKNOWN" /* UNKNOWN */;
847
+ }
848
+ function errorCodeFromString(value) {
849
+ if (value === void 0) return void 0;
850
+ if (Object.values(ErrorCode).includes(value)) {
851
+ return value;
852
+ }
853
+ return "UNKNOWN" /* UNKNOWN */;
854
+ }
855
+ function isToolAllowed(caps, tool) {
856
+ if (caps.toolAllowlist && caps.toolAllowlist.length > 0) {
857
+ return caps.toolAllowlist.includes(tool);
858
+ }
859
+ if (caps.toolDenylist && caps.toolDenylist.length > 0) {
860
+ return !caps.toolDenylist.includes(tool);
861
+ }
862
+ return true;
863
+ }
864
+ function isMetricsEmpty(metrics) {
865
+ return metrics.tokensInput === void 0 && metrics.tokensOutput === void 0 && metrics.latencyMs === void 0 && metrics.modelVersion === void 0 && !metrics.custom;
866
+ }
867
+
786
868
  // src/validation.ts
787
869
  function validateSubject(subject) {
788
870
  if (subject === void 0) return;
@@ -837,7 +919,7 @@ function evaluateActual(expr, result, estimate, useEstimateFallback) {
837
919
  }
838
920
  function buildReservationBody(cfg, estimate, defaultSubject) {
839
921
  validateNonNegative(estimate, "estimate");
840
- const ttlMs = cfg.ttlMs ?? 6e4;
922
+ const ttlMs = cfg.ttlMs ?? DEFAULT_TTL_MS;
841
923
  validateTtlMs(ttlMs);
842
924
  const subject = {};
843
925
  for (const field of [
@@ -895,9 +977,6 @@ function buildCommitBody(actual, unit, metrics, metadata) {
895
977
  }
896
978
  return body;
897
979
  }
898
- function isMetricsEmpty(metrics) {
899
- return metrics.tokensInput === void 0 && metrics.tokensOutput === void 0 && metrics.latencyMs === void 0 && metrics.modelVersion === void 0 && !metrics.custom;
900
- }
901
980
  function buildReleaseBody(reason) {
902
981
  return { idempotency_key: (0, import_node_crypto.randomUUID)(), reason };
903
982
  }
@@ -918,7 +997,6 @@ var AsyncCyclesLifecycle = class {
918
997
  async execute(fn, args, cfg) {
919
998
  const estimate = evaluateAmount(cfg.estimate, args);
920
999
  const createBody = buildReservationBody(cfg, estimate, this._defaultSubject);
921
- const resT1 = performance.now();
922
1000
  const resResponse = await this._client.createReservation(createBody);
923
1001
  if (!resResponse.isSuccess) {
924
1002
  throw buildProtocolException("Failed to create reservation", resResponse);
@@ -955,7 +1033,7 @@ var AsyncCyclesLifecycle = class {
955
1033
  );
956
1034
  }
957
1035
  const unit = cfg.unit ?? "USD_MICROCENTS";
958
- const ttlMs = cfg.ttlMs ?? 6e4;
1036
+ const ttlMs = cfg.ttlMs ?? DEFAULT_TTL_MS;
959
1037
  const ctx = {
960
1038
  reservationId,
961
1039
  estimate,
@@ -1016,7 +1094,13 @@ var AsyncCyclesLifecycle = class {
1016
1094
  return;
1017
1095
  }
1018
1096
  const errorResp = response.getErrorResponse();
1019
- const errorCode = errorResp?.error;
1097
+ let errorCode = errorResp?.error;
1098
+ if (errorCode === void 0) {
1099
+ const rawError = response.getBodyAttribute("error");
1100
+ if (typeof rawError === "string") {
1101
+ errorCode = rawError;
1102
+ }
1103
+ }
1020
1104
  if (errorCode === "RESERVATION_FINALIZED" || errorCode === "RESERVATION_EXPIRED") {
1021
1105
  return;
1022
1106
  }
@@ -1026,7 +1110,7 @@ var AsyncCyclesLifecycle = class {
1026
1110
  if (response.isClientError) {
1027
1111
  await this._handleRelease(
1028
1112
  reservationId,
1029
- `commit_rejected_${errorCode}`
1113
+ `commit_rejected_${errorCode ?? "unknown"}`
1030
1114
  );
1031
1115
  return;
1032
1116
  }
@@ -1125,6 +1209,9 @@ var CommitRetryEngine = class {
1125
1209
  } catch {
1126
1210
  }
1127
1211
  }
1212
+ console.warn(
1213
+ `[runcycles] Commit retry exhausted after ${this._maxAttempts} attempts for reservation ${reservationId}`
1214
+ );
1128
1215
  }
1129
1216
  };
1130
1217
 
@@ -1149,24 +1236,26 @@ function getEffectiveClient(explicitClient) {
1149
1236
  );
1150
1237
  }
1151
1238
  function withCycles(options, fn) {
1239
+ let lifecycle;
1240
+ function ensureLifecycle() {
1241
+ if (!lifecycle) {
1242
+ const client = getEffectiveClient(options.client);
1243
+ const config = client.config;
1244
+ const defaultSubject = {
1245
+ tenant: config.tenant,
1246
+ workspace: config.workspace,
1247
+ app: config.app,
1248
+ workflow: config.workflow,
1249
+ agent: config.agent,
1250
+ toolset: config.toolset
1251
+ };
1252
+ const retryEngine = new CommitRetryEngine(config);
1253
+ lifecycle = new AsyncCyclesLifecycle(client, retryEngine, defaultSubject);
1254
+ }
1255
+ return lifecycle;
1256
+ }
1152
1257
  return async (...args) => {
1153
- const client = getEffectiveClient(options.client);
1154
- const config = client.config;
1155
- const defaultSubject = {
1156
- tenant: config.tenant,
1157
- workspace: config.workspace,
1158
- app: config.app,
1159
- workflow: config.workflow,
1160
- agent: config.agent,
1161
- toolset: config.toolset
1162
- };
1163
- const retryEngine = new CommitRetryEngine(config);
1164
- const lifecycle = new AsyncCyclesLifecycle(
1165
- client,
1166
- retryEngine,
1167
- defaultSubject
1168
- );
1169
- return lifecycle.execute(
1258
+ return ensureLifecycle().execute(
1170
1259
  fn,
1171
1260
  args,
1172
1261
  options
@@ -1176,96 +1265,6 @@ function withCycles(options, fn) {
1176
1265
 
1177
1266
  // src/streaming.ts
1178
1267
  var import_node_crypto2 = require("crypto");
1179
-
1180
- // src/models.ts
1181
- var Unit = /* @__PURE__ */ ((Unit2) => {
1182
- Unit2["USD_MICROCENTS"] = "USD_MICROCENTS";
1183
- Unit2["TOKENS"] = "TOKENS";
1184
- Unit2["CREDITS"] = "CREDITS";
1185
- Unit2["RISK_POINTS"] = "RISK_POINTS";
1186
- return Unit2;
1187
- })(Unit || {});
1188
- var CommitOveragePolicy = /* @__PURE__ */ ((CommitOveragePolicy2) => {
1189
- CommitOveragePolicy2["REJECT"] = "REJECT";
1190
- CommitOveragePolicy2["ALLOW_IF_AVAILABLE"] = "ALLOW_IF_AVAILABLE";
1191
- CommitOveragePolicy2["ALLOW_WITH_OVERDRAFT"] = "ALLOW_WITH_OVERDRAFT";
1192
- return CommitOveragePolicy2;
1193
- })(CommitOveragePolicy || {});
1194
- var Decision = /* @__PURE__ */ ((Decision2) => {
1195
- Decision2["ALLOW"] = "ALLOW";
1196
- Decision2["ALLOW_WITH_CAPS"] = "ALLOW_WITH_CAPS";
1197
- Decision2["DENY"] = "DENY";
1198
- return Decision2;
1199
- })(Decision || {});
1200
- var ReservationStatus = /* @__PURE__ */ ((ReservationStatus2) => {
1201
- ReservationStatus2["ACTIVE"] = "ACTIVE";
1202
- ReservationStatus2["COMMITTED"] = "COMMITTED";
1203
- ReservationStatus2["RELEASED"] = "RELEASED";
1204
- ReservationStatus2["EXPIRED"] = "EXPIRED";
1205
- return ReservationStatus2;
1206
- })(ReservationStatus || {});
1207
- var CommitStatus = /* @__PURE__ */ ((CommitStatus2) => {
1208
- CommitStatus2["COMMITTED"] = "COMMITTED";
1209
- return CommitStatus2;
1210
- })(CommitStatus || {});
1211
- var ReleaseStatus = /* @__PURE__ */ ((ReleaseStatus2) => {
1212
- ReleaseStatus2["RELEASED"] = "RELEASED";
1213
- return ReleaseStatus2;
1214
- })(ReleaseStatus || {});
1215
- var ExtendStatus = /* @__PURE__ */ ((ExtendStatus2) => {
1216
- ExtendStatus2["ACTIVE"] = "ACTIVE";
1217
- return ExtendStatus2;
1218
- })(ExtendStatus || {});
1219
- var EventStatus = /* @__PURE__ */ ((EventStatus2) => {
1220
- EventStatus2["APPLIED"] = "APPLIED";
1221
- return EventStatus2;
1222
- })(EventStatus || {});
1223
- var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
1224
- ErrorCode2["INVALID_REQUEST"] = "INVALID_REQUEST";
1225
- ErrorCode2["UNAUTHORIZED"] = "UNAUTHORIZED";
1226
- ErrorCode2["FORBIDDEN"] = "FORBIDDEN";
1227
- ErrorCode2["NOT_FOUND"] = "NOT_FOUND";
1228
- ErrorCode2["BUDGET_EXCEEDED"] = "BUDGET_EXCEEDED";
1229
- ErrorCode2["RESERVATION_EXPIRED"] = "RESERVATION_EXPIRED";
1230
- ErrorCode2["RESERVATION_FINALIZED"] = "RESERVATION_FINALIZED";
1231
- ErrorCode2["IDEMPOTENCY_MISMATCH"] = "IDEMPOTENCY_MISMATCH";
1232
- ErrorCode2["UNIT_MISMATCH"] = "UNIT_MISMATCH";
1233
- ErrorCode2["OVERDRAFT_LIMIT_EXCEEDED"] = "OVERDRAFT_LIMIT_EXCEEDED";
1234
- ErrorCode2["DEBT_OUTSTANDING"] = "DEBT_OUTSTANDING";
1235
- ErrorCode2["INTERNAL_ERROR"] = "INTERNAL_ERROR";
1236
- ErrorCode2["UNKNOWN"] = "UNKNOWN";
1237
- return ErrorCode2;
1238
- })(ErrorCode || {});
1239
- function isAllowed(decision) {
1240
- return decision === "ALLOW" /* ALLOW */ || decision === "ALLOW_WITH_CAPS" /* ALLOW_WITH_CAPS */;
1241
- }
1242
- function isDenied(decision) {
1243
- return decision === "DENY" /* DENY */;
1244
- }
1245
- function isRetryableErrorCode(code) {
1246
- return code === "INTERNAL_ERROR" /* INTERNAL_ERROR */ || code === "UNKNOWN" /* UNKNOWN */;
1247
- }
1248
- function errorCodeFromString(value) {
1249
- if (value === void 0) return void 0;
1250
- if (Object.values(ErrorCode).includes(value)) {
1251
- return value;
1252
- }
1253
- return "UNKNOWN" /* UNKNOWN */;
1254
- }
1255
- function isToolAllowed(caps, tool) {
1256
- if (caps.toolAllowlist && caps.toolAllowlist.length > 0) {
1257
- return caps.toolAllowlist.includes(tool);
1258
- }
1259
- if (caps.toolDenylist && caps.toolDenylist.length > 0) {
1260
- return !caps.toolDenylist.includes(tool);
1261
- }
1262
- return true;
1263
- }
1264
- function isMetricsEmpty2(metrics) {
1265
- return metrics.tokensInput === void 0 && metrics.tokensOutput === void 0 && metrics.latencyMs === void 0 && metrics.modelVersion === void 0 && !metrics.custom;
1266
- }
1267
-
1268
- // src/streaming.ts
1269
1268
  async function reserveForStream(options) {
1270
1269
  const {
1271
1270
  client,
@@ -1274,7 +1273,7 @@ async function reserveForStream(options) {
1274
1273
  actionKind = "unknown",
1275
1274
  actionName = "unknown",
1276
1275
  actionTags,
1277
- ttlMs = 6e4,
1276
+ ttlMs = DEFAULT_TTL_MS,
1278
1277
  gracePeriodMs,
1279
1278
  overagePolicy = "REJECT",
1280
1279
  dimensions
@@ -1370,13 +1369,23 @@ async function reserveForStream(options) {
1370
1369
  idempotency_key: (0, import_node_crypto2.randomUUID)(),
1371
1370
  actual: { unit, amount: actual }
1372
1371
  };
1373
- if (metrics && !isMetricsEmpty2(metrics)) {
1372
+ if (metrics && !isMetricsEmpty(metrics)) {
1374
1373
  commitBody.metrics = metricsToWire(metrics);
1375
1374
  }
1376
1375
  if (metadata) {
1377
1376
  commitBody.metadata = metadata;
1378
1377
  }
1379
- await client.commitReservation(reservationId, commitBody);
1378
+ try {
1379
+ const response2 = await client.commitReservation(reservationId, commitBody);
1380
+ if (!response2.isSuccess) {
1381
+ throw new CyclesError(
1382
+ `Commit failed with status ${response2.status}: ${response2.errorMessage ?? "unknown error"}`
1383
+ );
1384
+ }
1385
+ } catch (err) {
1386
+ finalized = false;
1387
+ throw err;
1388
+ }
1380
1389
  },
1381
1390
  async release(reason) {
1382
1391
  if (finalized) return;
@@ -1405,7 +1414,6 @@ async function reserveForStream(options) {
1405
1414
  CyclesError,
1406
1415
  CyclesProtocolError,
1407
1416
  CyclesResponse,
1408
- CyclesTransportError,
1409
1417
  DebtOutstandingError,
1410
1418
  Decision,
1411
1419
  ErrorCode,
package/dist/index.d.cts CHANGED
@@ -329,6 +329,7 @@ declare class CyclesClient {
329
329
  createEvent(request: Record<string, unknown>): Promise<CyclesResponse>;
330
330
  private _post;
331
331
  private _get;
332
+ [Symbol.asyncDispose](): Promise<void>;
332
333
  private _handleResponse;
333
334
  }
334
335
 
@@ -507,12 +508,6 @@ declare class ReservationExpiredError extends CyclesProtocolError {
507
508
  declare class ReservationFinalizedError extends CyclesProtocolError {
508
509
  constructor(message: string, options?: ConstructorParameters<typeof CyclesProtocolError>[1]);
509
510
  }
510
- declare class CyclesTransportError extends CyclesError {
511
- readonly cause: Error | undefined;
512
- constructor(message: string, options?: {
513
- cause?: Error;
514
- });
515
- }
516
511
 
517
512
  /**
518
513
  * Explicit request/response mappers between camelCase TypeScript interfaces
@@ -548,4 +543,4 @@ declare function reservationExtendRequestToWire(req: ReservationExtendRequest):
548
543
  declare function decisionRequestToWire(req: DecisionRequest): Record<string, unknown>;
549
544
  declare function eventCreateRequestToWire(req: EventCreateRequest): Record<string, unknown>;
550
545
 
551
- export { type Action, type Amount, type Balance, type BalanceResponse, BudgetExceededError, type Caps, CommitOveragePolicy, type CommitRequest, type CommitResponse, CommitStatus, CyclesClient, CyclesConfig, type CyclesContext, CyclesError, type CyclesMetrics, CyclesProtocolError, CyclesResponse, CyclesTransportError, DebtOutstandingError, Decision, type DecisionRequest, type DecisionResponse, type DryRunResult, ErrorCode, type ErrorResponse, type EventCreateRequest, type EventCreateResponse, EventStatus, ExtendStatus, OverdraftLimitExceededError, type ReleaseRequest, type ReleaseResponse, ReleaseStatus, type ReservationCreateRequest, type ReservationCreateResponse, type ReservationDetail, ReservationExpiredError, type ReservationExtendRequest, type ReservationExtendResponse, ReservationFinalizedError, type ReservationListResponse, ReservationStatus, type ReservationSummary, type SignedAmount, type StreamReservation, type StreamReservationOptions, type Subject, Unit, type WithCyclesConfig, balanceResponseFromWire, capsFromWire, commitRequestToWire, commitResponseFromWire, decisionRequestToWire, decisionResponseFromWire, errorCodeFromString, errorResponseFromWire, eventCreateRequestToWire, eventCreateResponseFromWire, getCyclesContext, isAllowed, isDenied, isMetricsEmpty, isRetryableErrorCode, isToolAllowed, metricsToWire, releaseRequestToWire, releaseResponseFromWire, reservationCreateRequestToWire, reservationCreateResponseFromWire, reservationDetailFromWire, reservationExtendRequestToWire, reservationExtendResponseFromWire, reservationListResponseFromWire, reservationSummaryFromWire, reserveForStream, setDefaultClient, setDefaultConfig, withCycles };
546
+ export { type Action, type Amount, type Balance, type BalanceResponse, BudgetExceededError, type Caps, CommitOveragePolicy, type CommitRequest, type CommitResponse, CommitStatus, CyclesClient, CyclesConfig, type CyclesContext, CyclesError, type CyclesMetrics, CyclesProtocolError, CyclesResponse, DebtOutstandingError, Decision, type DecisionRequest, type DecisionResponse, type DryRunResult, ErrorCode, type ErrorResponse, type EventCreateRequest, type EventCreateResponse, EventStatus, ExtendStatus, OverdraftLimitExceededError, type ReleaseRequest, type ReleaseResponse, ReleaseStatus, type ReservationCreateRequest, type ReservationCreateResponse, type ReservationDetail, ReservationExpiredError, type ReservationExtendRequest, type ReservationExtendResponse, ReservationFinalizedError, type ReservationListResponse, ReservationStatus, type ReservationSummary, type SignedAmount, type StreamReservation, type StreamReservationOptions, type Subject, Unit, type WithCyclesConfig, balanceResponseFromWire, capsFromWire, commitRequestToWire, commitResponseFromWire, decisionRequestToWire, decisionResponseFromWire, errorCodeFromString, errorResponseFromWire, eventCreateRequestToWire, eventCreateResponseFromWire, getCyclesContext, isAllowed, isDenied, isMetricsEmpty, isRetryableErrorCode, isToolAllowed, metricsToWire, releaseRequestToWire, releaseResponseFromWire, reservationCreateRequestToWire, reservationCreateResponseFromWire, reservationDetailFromWire, reservationExtendRequestToWire, reservationExtendResponseFromWire, reservationListResponseFromWire, reservationSummaryFromWire, reserveForStream, setDefaultClient, setDefaultConfig, withCycles };
package/dist/index.d.ts CHANGED
@@ -329,6 +329,7 @@ declare class CyclesClient {
329
329
  createEvent(request: Record<string, unknown>): Promise<CyclesResponse>;
330
330
  private _post;
331
331
  private _get;
332
+ [Symbol.asyncDispose](): Promise<void>;
332
333
  private _handleResponse;
333
334
  }
334
335
 
@@ -507,12 +508,6 @@ declare class ReservationExpiredError extends CyclesProtocolError {
507
508
  declare class ReservationFinalizedError extends CyclesProtocolError {
508
509
  constructor(message: string, options?: ConstructorParameters<typeof CyclesProtocolError>[1]);
509
510
  }
510
- declare class CyclesTransportError extends CyclesError {
511
- readonly cause: Error | undefined;
512
- constructor(message: string, options?: {
513
- cause?: Error;
514
- });
515
- }
516
511
 
517
512
  /**
518
513
  * Explicit request/response mappers between camelCase TypeScript interfaces
@@ -548,4 +543,4 @@ declare function reservationExtendRequestToWire(req: ReservationExtendRequest):
548
543
  declare function decisionRequestToWire(req: DecisionRequest): Record<string, unknown>;
549
544
  declare function eventCreateRequestToWire(req: EventCreateRequest): Record<string, unknown>;
550
545
 
551
- export { type Action, type Amount, type Balance, type BalanceResponse, BudgetExceededError, type Caps, CommitOveragePolicy, type CommitRequest, type CommitResponse, CommitStatus, CyclesClient, CyclesConfig, type CyclesContext, CyclesError, type CyclesMetrics, CyclesProtocolError, CyclesResponse, CyclesTransportError, DebtOutstandingError, Decision, type DecisionRequest, type DecisionResponse, type DryRunResult, ErrorCode, type ErrorResponse, type EventCreateRequest, type EventCreateResponse, EventStatus, ExtendStatus, OverdraftLimitExceededError, type ReleaseRequest, type ReleaseResponse, ReleaseStatus, type ReservationCreateRequest, type ReservationCreateResponse, type ReservationDetail, ReservationExpiredError, type ReservationExtendRequest, type ReservationExtendResponse, ReservationFinalizedError, type ReservationListResponse, ReservationStatus, type ReservationSummary, type SignedAmount, type StreamReservation, type StreamReservationOptions, type Subject, Unit, type WithCyclesConfig, balanceResponseFromWire, capsFromWire, commitRequestToWire, commitResponseFromWire, decisionRequestToWire, decisionResponseFromWire, errorCodeFromString, errorResponseFromWire, eventCreateRequestToWire, eventCreateResponseFromWire, getCyclesContext, isAllowed, isDenied, isMetricsEmpty, isRetryableErrorCode, isToolAllowed, metricsToWire, releaseRequestToWire, releaseResponseFromWire, reservationCreateRequestToWire, reservationCreateResponseFromWire, reservationDetailFromWire, reservationExtendRequestToWire, reservationExtendResponseFromWire, reservationListResponseFromWire, reservationSummaryFromWire, reserveForStream, setDefaultClient, setDefaultConfig, withCycles };
546
+ export { type Action, type Amount, type Balance, type BalanceResponse, BudgetExceededError, type Caps, CommitOveragePolicy, type CommitRequest, type CommitResponse, CommitStatus, CyclesClient, CyclesConfig, type CyclesContext, CyclesError, type CyclesMetrics, CyclesProtocolError, CyclesResponse, DebtOutstandingError, Decision, type DecisionRequest, type DecisionResponse, type DryRunResult, ErrorCode, type ErrorResponse, type EventCreateRequest, type EventCreateResponse, EventStatus, ExtendStatus, OverdraftLimitExceededError, type ReleaseRequest, type ReleaseResponse, ReleaseStatus, type ReservationCreateRequest, type ReservationCreateResponse, type ReservationDetail, ReservationExpiredError, type ReservationExtendRequest, type ReservationExtendResponse, ReservationFinalizedError, type ReservationListResponse, ReservationStatus, type ReservationSummary, type SignedAmount, type StreamReservation, type StreamReservationOptions, type Subject, Unit, type WithCyclesConfig, balanceResponseFromWire, capsFromWire, commitRequestToWire, commitResponseFromWire, decisionRequestToWire, decisionResponseFromWire, errorCodeFromString, errorResponseFromWire, eventCreateRequestToWire, eventCreateResponseFromWire, getCyclesContext, isAllowed, isDenied, isMetricsEmpty, isRetryableErrorCode, isToolAllowed, metricsToWire, releaseRequestToWire, releaseResponseFromWire, reservationCreateRequestToWire, reservationCreateResponseFromWire, reservationDetailFromWire, reservationExtendRequestToWire, reservationExtendResponseFromWire, reservationListResponseFromWire, reservationSummaryFromWire, reserveForStream, setDefaultClient, setDefaultConfig, withCycles };