@warmhub/sdk-ts 0.49.1 → 0.51.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.
- package/dist/{chunk-3JTVLMFV.js → chunk-ZTDMTDJ6.js} +86 -52
- package/dist/chunk-ZTDMTDJ6.js.map +1 -0
- package/dist/index.d.ts +128 -55
- package/dist/index.js +1 -1
- package/dist/react.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-3JTVLMFV.js.map +0 -1
|
@@ -1724,11 +1724,6 @@ async function submitOperationsViaStream(client, args) {
|
|
|
1724
1724
|
"At least one operation is required for stream submission."
|
|
1725
1725
|
);
|
|
1726
1726
|
}
|
|
1727
|
-
if ((args.allocatedTokens?.length ?? 0) > 0 && args.streamId === void 0) {
|
|
1728
|
-
throw new StreamValidationError(
|
|
1729
|
-
"Manual stream resume with allocatedTokens requires the original streamId."
|
|
1730
|
-
);
|
|
1731
|
-
}
|
|
1732
1727
|
const operations = args.operations.map((operation, index) => {
|
|
1733
1728
|
let streamOperation;
|
|
1734
1729
|
try {
|
|
@@ -1746,9 +1741,8 @@ async function submitOperationsViaStream(client, args) {
|
|
|
1746
1741
|
});
|
|
1747
1742
|
const chunkSize = normalizeChunkSize(args.chunkSize);
|
|
1748
1743
|
let streamId = args.streamId ?? createStreamId();
|
|
1749
|
-
const
|
|
1750
|
-
|
|
1751
|
-
let allocatedTokens = args.allocatedTokens ?? [];
|
|
1744
|
+
const policy = args.streamId !== void 0 ? false : resolveRetryPolicy(args.retry);
|
|
1745
|
+
let allocatedTokenRanges = [];
|
|
1752
1746
|
let createdByEmail;
|
|
1753
1747
|
const chunkResults = [];
|
|
1754
1748
|
let sawAmbiguousAttempt = false;
|
|
@@ -1763,7 +1757,7 @@ async function submitOperationsViaStream(client, args) {
|
|
|
1763
1757
|
while (true) {
|
|
1764
1758
|
try {
|
|
1765
1759
|
const appendResult = await client.stream.append({
|
|
1766
|
-
|
|
1760
|
+
allocatedTokenRanges,
|
|
1767
1761
|
orgName: args.orgName,
|
|
1768
1762
|
repoName: args.repoName,
|
|
1769
1763
|
streamId,
|
|
@@ -1772,7 +1766,7 @@ async function submitOperationsViaStream(client, args) {
|
|
|
1772
1766
|
message: args.message,
|
|
1773
1767
|
operations: chunk
|
|
1774
1768
|
});
|
|
1775
|
-
|
|
1769
|
+
allocatedTokenRanges = appendResult.allocatedTokenRanges;
|
|
1776
1770
|
if (appendResult.createdByEmail !== void 0) {
|
|
1777
1771
|
createdByEmail = appendResult.createdByEmail;
|
|
1778
1772
|
}
|
|
@@ -1790,7 +1784,7 @@ async function submitOperationsViaStream(client, args) {
|
|
|
1790
1784
|
priorAttemptAmbiguous = true;
|
|
1791
1785
|
sawAmbiguousAttempt = true;
|
|
1792
1786
|
streamId = createStreamId();
|
|
1793
|
-
|
|
1787
|
+
allocatedTokenRanges = [];
|
|
1794
1788
|
continue;
|
|
1795
1789
|
}
|
|
1796
1790
|
const completedOperations = completedOperationsFrom(
|
|
@@ -2425,7 +2419,6 @@ var OperationBuilder = class {
|
|
|
2425
2419
|
* @param params.committer Optional wref identifying the actor on whose behalf the write is made.
|
|
2426
2420
|
* @param params.chunkSize Maximum operations per stream append.
|
|
2427
2421
|
* @param params.streamId Advanced continuation hook for caller-managed streams.
|
|
2428
|
-
* @param params.allocatedTokens Advanced continuation hook for `$N` / `#N` token allocation state.
|
|
2429
2422
|
* @param params.retry Retry policy for transient first-chunk failures, or `false` to disable automatic retry.
|
|
2430
2423
|
*/
|
|
2431
2424
|
async commit(params) {
|
|
@@ -2448,7 +2441,6 @@ var OperationBuilder = class {
|
|
|
2448
2441
|
message: params.message,
|
|
2449
2442
|
chunkSize: params.chunkSize,
|
|
2450
2443
|
streamId: params.streamId,
|
|
2451
|
-
allocatedTokens: params.allocatedTokens,
|
|
2452
2444
|
retry: params.retry,
|
|
2453
2445
|
operations
|
|
2454
2446
|
});
|
|
@@ -2652,7 +2644,30 @@ function preflightCheckRevise(kind, name, data) {
|
|
|
2652
2644
|
function normalizeWref(wref) {
|
|
2653
2645
|
return wref.replace(/@(?:v\d+|HEAD|ALL)$/i, "");
|
|
2654
2646
|
}
|
|
2655
|
-
var
|
|
2647
|
+
var WARMHUB_CLIENT_OPTION_NAMES = [
|
|
2648
|
+
"apiUrl",
|
|
2649
|
+
"fetch",
|
|
2650
|
+
"accessToken",
|
|
2651
|
+
"auth",
|
|
2652
|
+
"functionLogs"
|
|
2653
|
+
];
|
|
2654
|
+
var WARMHUB_CLIENT_OPTION_NAME_SET = new Set(
|
|
2655
|
+
WARMHUB_CLIENT_OPTION_NAMES
|
|
2656
|
+
);
|
|
2657
|
+
var ACCESS_TOKEN_OPTION_ALIASES = /* @__PURE__ */ new Set(["token", "apiKey", "bearer"]);
|
|
2658
|
+
function validateWarmHubClientOptions(options) {
|
|
2659
|
+
if (!options) {
|
|
2660
|
+
return;
|
|
2661
|
+
}
|
|
2662
|
+
for (const key of Object.keys(options)) {
|
|
2663
|
+
if (WARMHUB_CLIENT_OPTION_NAME_SET.has(key)) {
|
|
2664
|
+
continue;
|
|
2665
|
+
}
|
|
2666
|
+
const hint = ACCESS_TOKEN_OPTION_ALIASES.has(key) ? '; did you mean "accessToken"?' : `. Valid options are: ${WARMHUB_CLIENT_OPTION_NAMES.join(", ")}.`;
|
|
2667
|
+
throw new TypeError(`Unknown WarmHubClient option "${key}"${hint}`);
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
var SDK_VERSION = "0.51.0" ;
|
|
2656
2671
|
var DEFAULT_API_URL = "https://api.warmhub.ai";
|
|
2657
2672
|
var UNBATCHED_TRPC_PATHS = /* @__PURE__ */ new Set([
|
|
2658
2673
|
"repo.shapeInstanceCounts",
|
|
@@ -2777,12 +2792,17 @@ var WarmHubError = class extends Error {
|
|
|
2777
2792
|
*/
|
|
2778
2793
|
retryAfter;
|
|
2779
2794
|
/**
|
|
2780
|
-
*
|
|
2795
|
+
* Canonical domain error code from the response body. Set iff the backend wire
|
|
2781
2796
|
* carried a structured `error.code` string. Use this when the question is
|
|
2782
2797
|
* "did the backend specifically say this?". For best-effort labelling that
|
|
2783
2798
|
* also covers SDK-local transport codes (`NETWORK`, `CANCELLED`, the
|
|
2784
2799
|
* generic `BACKEND` fallback), branch on {@link code} or {@link kind}.
|
|
2785
2800
|
*/
|
|
2801
|
+
errorCode;
|
|
2802
|
+
/**
|
|
2803
|
+
* @deprecated Use {@link errorCode}. Retained during the GH-3533 migration
|
|
2804
|
+
* window for callers that already branch on the old field.
|
|
2805
|
+
*/
|
|
2786
2806
|
backendCode;
|
|
2787
2807
|
/**
|
|
2788
2808
|
* Structured backend error details, when the response carried them. Branch on
|
|
@@ -2793,14 +2813,15 @@ var WarmHubError = class extends Error {
|
|
|
2793
2813
|
* backend wire carried `data.warmhub.details`. See {@link WarmHubErrorDetails}.
|
|
2794
2814
|
*/
|
|
2795
2815
|
details;
|
|
2796
|
-
constructor(code, message, status, hint, retryAfter,
|
|
2816
|
+
constructor(code, message, status, hint, retryAfter, errorCode, details) {
|
|
2797
2817
|
super(message);
|
|
2798
2818
|
this.name = "WarmHubError";
|
|
2799
2819
|
this.code = code;
|
|
2800
2820
|
this.status = status;
|
|
2801
2821
|
this.hint = hint;
|
|
2802
2822
|
this.retryAfter = retryAfter;
|
|
2803
|
-
this.
|
|
2823
|
+
this.errorCode = errorCode;
|
|
2824
|
+
this.backendCode = errorCode;
|
|
2804
2825
|
this.details = details;
|
|
2805
2826
|
}
|
|
2806
2827
|
get kind() {
|
|
@@ -2843,7 +2864,7 @@ function toWarmHubError(error) {
|
|
|
2843
2864
|
typeof warmhubLike.status === "number" ? warmhubLike.status : void 0,
|
|
2844
2865
|
typeof warmhubLike.hint === "string" ? warmhubLike.hint : void 0,
|
|
2845
2866
|
typeof warmhubLike.retryAfter === "number" ? warmhubLike.retryAfter : void 0,
|
|
2846
|
-
typeof warmhubLike.backendCode === "string" ? warmhubLike.backendCode : void 0,
|
|
2867
|
+
typeof warmhubLike.errorCode === "string" ? warmhubLike.errorCode : typeof warmhubLike.backendCode === "string" ? warmhubLike.backendCode : void 0,
|
|
2847
2868
|
warmhubLike.details
|
|
2848
2869
|
);
|
|
2849
2870
|
}
|
|
@@ -3313,7 +3334,6 @@ var WarmHubClient = class _WarmHubClient {
|
|
|
3313
3334
|
* @param opts.chunkSize Maximum operations per stream append. Values are clamped by the SDK.
|
|
3314
3335
|
* @param opts.skipExisting Return `noop` for add operations whose target already exists.
|
|
3315
3336
|
* @param opts.streamId Advanced continuation hook for caller-managed streams.
|
|
3316
|
-
* @param opts.allocatedTokens Advanced continuation hook for `$N` / `#N` token allocation state.
|
|
3317
3337
|
* @param opts.retry Retry policy for transient first-chunk failures, or `false` to disable automatic retry.
|
|
3318
3338
|
*/
|
|
3319
3339
|
apply: async (orgName, repoName, message, operations, opts) => {
|
|
@@ -3327,7 +3347,6 @@ var WarmHubClient = class _WarmHubClient {
|
|
|
3327
3347
|
chunkSize: opts?.chunkSize,
|
|
3328
3348
|
skipExisting: opts?.skipExisting,
|
|
3329
3349
|
streamId: opts?.streamId,
|
|
3330
|
-
allocatedTokens: opts?.allocatedTokens,
|
|
3331
3350
|
retry: opts?.retry,
|
|
3332
3351
|
operations
|
|
3333
3352
|
});
|
|
@@ -3853,28 +3872,34 @@ var WarmHubClient = class _WarmHubClient {
|
|
|
3853
3872
|
}
|
|
3854
3873
|
},
|
|
3855
3874
|
/**
|
|
3856
|
-
*
|
|
3875
|
+
* List the caller's repositories across every org they belong to, ordered
|
|
3876
|
+
* for recency by default (most recently written first), capped at `limit`.
|
|
3857
3877
|
*
|
|
3858
|
-
*
|
|
3878
|
+
* Unlike `listPage`, this is user-level and resolves the caller's orgs
|
|
3879
|
+
* server-side, so you don't fan out one request per org to build an
|
|
3880
|
+
* account-wide view. Membership is the access filter and per-token
|
|
3881
|
+
* `allowedMatches` narrowing is not applied, so this requires an
|
|
3882
|
+
* interactive session — PAT and component-token callers are rejected. Use
|
|
3883
|
+
* the org-scoped `listPage` from token-authenticated contexts.
|
|
3859
3884
|
*/
|
|
3860
|
-
|
|
3885
|
+
listForCaller: async (opts) => {
|
|
3861
3886
|
try {
|
|
3862
|
-
return await this.trpc.repo.
|
|
3863
|
-
|
|
3864
|
-
|
|
3887
|
+
return await this.trpc.repo.listForCaller.query({
|
|
3888
|
+
limit: opts?.limit,
|
|
3889
|
+
sort: opts?.sort
|
|
3865
3890
|
});
|
|
3866
3891
|
} catch (error) {
|
|
3867
3892
|
throw toWarmHubError(error);
|
|
3868
3893
|
}
|
|
3869
3894
|
},
|
|
3870
3895
|
/**
|
|
3871
|
-
*
|
|
3896
|
+
* Fetch a repository's `Content/Readme` markdown record.
|
|
3872
3897
|
*
|
|
3873
|
-
*
|
|
3898
|
+
* The SDK contract allows `null`; current backend behavior returns a synthesized empty stub for repositories that have not committed README content yet. Callers should still null-check defensively.
|
|
3874
3899
|
*/
|
|
3875
|
-
|
|
3900
|
+
getReadme: async (orgName, repoName) => {
|
|
3876
3901
|
try {
|
|
3877
|
-
return await this.trpc.repo.
|
|
3902
|
+
return await this.trpc.repo.getReadme.query({
|
|
3878
3903
|
orgName,
|
|
3879
3904
|
repoName
|
|
3880
3905
|
});
|
|
@@ -3929,21 +3954,6 @@ var WarmHubClient = class _WarmHubClient {
|
|
|
3929
3954
|
throw toWarmHubError(error);
|
|
3930
3955
|
}
|
|
3931
3956
|
},
|
|
3932
|
-
/**
|
|
3933
|
-
* Generate an AGENTS.md draft from the repository's current content and schema.
|
|
3934
|
-
*
|
|
3935
|
-
* This does not commit the draft. Save returned content with `setAgents` after review.
|
|
3936
|
-
*/
|
|
3937
|
-
generateAgents: async (orgName, repoName) => {
|
|
3938
|
-
try {
|
|
3939
|
-
return await this.trpc.repo.generateAgents.mutate({
|
|
3940
|
-
orgName,
|
|
3941
|
-
repoName
|
|
3942
|
-
});
|
|
3943
|
-
} catch (error) {
|
|
3944
|
-
throw toWarmHubError(error);
|
|
3945
|
-
}
|
|
3946
|
-
},
|
|
3947
3957
|
/**
|
|
3948
3958
|
* Fetch the synthesized `Content/LlmsTxt` sitemap for a repository.
|
|
3949
3959
|
*
|
|
@@ -4388,6 +4398,24 @@ var WarmHubClient = class _WarmHubClient {
|
|
|
4388
4398
|
throw toWarmHubError(error);
|
|
4389
4399
|
}
|
|
4390
4400
|
},
|
|
4401
|
+
/**
|
|
4402
|
+
* Aggregate run counts (total + per-status) for a repo or one subscription.
|
|
4403
|
+
*
|
|
4404
|
+
* Computed server-side over an optional `since` window — not bounded by the
|
|
4405
|
+
* `listRuns` row cap, so it reflects the full window regardless of volume.
|
|
4406
|
+
*/
|
|
4407
|
+
runStats: async (orgName, repoName, opts) => {
|
|
4408
|
+
try {
|
|
4409
|
+
return await this.trpc.action.runStats.query({
|
|
4410
|
+
orgName,
|
|
4411
|
+
repoName,
|
|
4412
|
+
subscriptionName: opts?.subscriptionName,
|
|
4413
|
+
since: opts?.since
|
|
4414
|
+
});
|
|
4415
|
+
} catch (error) {
|
|
4416
|
+
throw toWarmHubError(error);
|
|
4417
|
+
}
|
|
4418
|
+
},
|
|
4391
4419
|
/**
|
|
4392
4420
|
* List delivery attempts for one action run.
|
|
4393
4421
|
*/
|
|
@@ -5032,10 +5060,15 @@ var WarmHubClient = class _WarmHubClient {
|
|
|
5032
5060
|
},
|
|
5033
5061
|
/**
|
|
5034
5062
|
* List personal access tokens for the authenticated user.
|
|
5063
|
+
*
|
|
5064
|
+
* By default only active tokens are returned. Pass
|
|
5065
|
+
* `{ includeInactive: true }` to also include expired and revoked tokens.
|
|
5035
5066
|
*/
|
|
5036
|
-
list: async () => {
|
|
5067
|
+
list: async (opts) => {
|
|
5037
5068
|
try {
|
|
5038
|
-
return await this.trpc.token.list.query(
|
|
5069
|
+
return await this.trpc.token.list.query(
|
|
5070
|
+
opts?.includeInactive ? { includeInactive: true } : void 0
|
|
5071
|
+
);
|
|
5039
5072
|
} catch (error) {
|
|
5040
5073
|
throw toWarmHubError(error);
|
|
5041
5074
|
}
|
|
@@ -5225,6 +5258,7 @@ var WarmHubClient = class _WarmHubClient {
|
|
|
5225
5258
|
credentials = this.credential;
|
|
5226
5259
|
constructor(apiUrlOrOptions, maybeOptions) {
|
|
5227
5260
|
const options = typeof apiUrlOrOptions === "string" ? maybeOptions : apiUrlOrOptions;
|
|
5261
|
+
validateWarmHubClientOptions(options);
|
|
5228
5262
|
const apiUrl = typeof apiUrlOrOptions === "string" ? apiUrlOrOptions : apiUrlOrOptions?.apiUrl ?? DEFAULT_API_URL;
|
|
5229
5263
|
this.apiUrl = apiUrl;
|
|
5230
5264
|
this.fetchImpl = options?.fetch;
|
|
@@ -5382,7 +5416,7 @@ var WarmHubClient = class _WarmHubClient {
|
|
|
5382
5416
|
if (!response.ok) {
|
|
5383
5417
|
let message = `Request failed with status ${response.status}`;
|
|
5384
5418
|
let code = httpStatusToWarmHubCode(response.status);
|
|
5385
|
-
let
|
|
5419
|
+
let errorCode;
|
|
5386
5420
|
let hint;
|
|
5387
5421
|
let retryAfter;
|
|
5388
5422
|
try {
|
|
@@ -5392,7 +5426,7 @@ var WarmHubClient = class _WarmHubClient {
|
|
|
5392
5426
|
}
|
|
5393
5427
|
if (typeof body.error?.code === "string") {
|
|
5394
5428
|
code = body.error.code;
|
|
5395
|
-
|
|
5429
|
+
errorCode = body.error.code;
|
|
5396
5430
|
}
|
|
5397
5431
|
if (typeof body.error?.hint === "string") {
|
|
5398
5432
|
hint = body.error.hint;
|
|
@@ -5408,7 +5442,7 @@ var WarmHubClient = class _WarmHubClient {
|
|
|
5408
5442
|
response.status,
|
|
5409
5443
|
hint,
|
|
5410
5444
|
retryAfter,
|
|
5411
|
-
|
|
5445
|
+
errorCode
|
|
5412
5446
|
);
|
|
5413
5447
|
}
|
|
5414
5448
|
return response;
|
|
@@ -5524,5 +5558,5 @@ function isAbortError(error) {
|
|
|
5524
5558
|
}
|
|
5525
5559
|
|
|
5526
5560
|
export { AllStreamOperationsFailedError, CLI_INSTALL_REPO_HEADER, CLI_SIGNATURE_HEADER, CLI_TIMESTAMP_HEADER, CONTENT_FIELD_LIMIT_ERROR, CliCallVerificationError, DEFAULT_API_URL, DEFAULT_STREAM_CHUNK_SIZE, MAX_CONTENT_FIELD_BYTES, MAX_STREAM_APPEND_OPERATION_COUNT2 as MAX_STREAM_APPEND_OPERATION_COUNT, OperationBuilder, PartialStreamSubmissionError, SDK_VERSION, WarmHubClient, WarmHubError, connectionErrorMessage, contentFieldLimitError, countStreamAppendResultStatuses, isConnectionError, isRetryable, isWarmHubError, normalizeWref, resolveFunctionLogMode, sanitizeErrorMessage, sdkVersionIsBelowMinimum, streamAppendResultStatus, submitOperationsViaStream, toWarmHubError, validateAgainstShape, verifyCliCall };
|
|
5527
|
-
//# sourceMappingURL=chunk-
|
|
5528
|
-
//# sourceMappingURL=chunk-
|
|
5561
|
+
//# sourceMappingURL=chunk-ZTDMTDJ6.js.map
|
|
5562
|
+
//# sourceMappingURL=chunk-ZTDMTDJ6.js.map
|