@acosmi/sdk-ts 1.5.1 → 1.9.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/CHANGELOG.md +168 -1
- package/README.md +20 -1
- package/dist/browser/index.mjs +426 -6
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.mjs +426 -6
- package/dist/index.mjs.map +1 -1
- package/dist/node/adapters/anthropic.cjs +11 -2
- package/dist/node/adapters/anthropic.cjs.map +1 -1
- package/dist/node/adapters/anthropic.d.cts +1 -1
- package/dist/node/adapters/anthropic.d.ts +1 -1
- package/dist/node/adapters/anthropic.mjs +11 -2
- package/dist/node/adapters/anthropic.mjs.map +1 -1
- package/dist/node/adapters/openai.cjs +3 -0
- package/dist/node/adapters/openai.cjs.map +1 -1
- package/dist/node/adapters/openai.d.cts +2 -2
- package/dist/node/adapters/openai.d.ts +2 -2
- package/dist/node/adapters/openai.mjs +3 -0
- package/dist/node/adapters/openai.mjs.map +1 -1
- package/dist/node/{index-nvLKgCm9.d.cts → index-Bah9A83R.d.cts} +1 -1
- package/dist/node/{index-nvLKgCm9.d.ts → index-Bah9A83R.d.ts} +1 -1
- package/dist/node/{index-DEA6LXw6.d.cts → index-C9X5Yuyk.d.cts} +10 -1
- package/dist/node/{index-DEA6LXw6.d.ts → index-C9X5Yuyk.d.ts} +10 -1
- package/dist/node/index.cjs +432 -5
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +644 -7
- package/dist/node/index.d.ts +644 -7
- package/dist/node/index.mjs +426 -6
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/{openai-vfUUgdvL.d.ts → openai-BqKAhbSc.d.ts} +2 -2
- package/dist/node/{openai-BDodfhsG.d.cts → openai-C_UKadSX.d.cts} +2 -2
- package/dist/node/sanitize/index.d.cts +1 -1
- package/dist/node/sanitize/index.d.ts +1 -1
- package/package.json +2 -2
package/dist/browser/index.mjs
CHANGED
|
@@ -365,8 +365,17 @@ var init_anthropic = __esm({
|
|
|
365
365
|
body["effort"] = req.effort;
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
|
-
if (req.metadata) {
|
|
369
|
-
|
|
368
|
+
if (req.metadata || req.endUserId && req.endUserId !== "") {
|
|
369
|
+
const meta = {};
|
|
370
|
+
if (req.metadata) {
|
|
371
|
+
for (const [k, v] of Object.entries(req.metadata)) {
|
|
372
|
+
meta[k] = v;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
if (req.endUserId && req.endUserId !== "" && meta["user_id"] === void 0) {
|
|
376
|
+
meta["user_id"] = req.endUserId;
|
|
377
|
+
}
|
|
378
|
+
body["metadata"] = meta;
|
|
370
379
|
}
|
|
371
380
|
const allTools = [];
|
|
372
381
|
if (req.tools != null) {
|
|
@@ -710,6 +719,9 @@ var init_openai = __esm({
|
|
|
710
719
|
body[k] = v;
|
|
711
720
|
}
|
|
712
721
|
}
|
|
722
|
+
if (req.endUserId && req.endUserId !== "") {
|
|
723
|
+
body["user_id"] = req.endUserId;
|
|
724
|
+
}
|
|
713
725
|
if (req.stream === true) {
|
|
714
726
|
body["stream_options"] = { include_usage: true };
|
|
715
727
|
}
|
|
@@ -1773,6 +1785,30 @@ function extractAnthropicBlockMeta(eventType, data, blockTypeMap) {
|
|
|
1773
1785
|
// src/core/client.ts
|
|
1774
1786
|
init_openai();
|
|
1775
1787
|
|
|
1788
|
+
// src/models/enduser.ts
|
|
1789
|
+
var maxEndUserIdLength = 512;
|
|
1790
|
+
function validateEndUserId(s) {
|
|
1791
|
+
if (!s) return null;
|
|
1792
|
+
if (s.length > maxEndUserIdLength) {
|
|
1793
|
+
return `endUserId length ${s.length} > ${maxEndUserIdLength}`;
|
|
1794
|
+
}
|
|
1795
|
+
for (let i = 0; i < s.length; i++) {
|
|
1796
|
+
const c = s.charCodeAt(i);
|
|
1797
|
+
const ok = c >= 97 && c <= 122 || // a-z
|
|
1798
|
+
c >= 65 && c <= 90 || // A-Z
|
|
1799
|
+
c >= 48 && c <= 57 || // 0-9
|
|
1800
|
+
c === 95 || // _
|
|
1801
|
+
c === 45;
|
|
1802
|
+
if (!ok) {
|
|
1803
|
+
return `endUserId contains invalid char code 0x${c.toString(16)} at offset ${i} (allowed: [a-zA-Z0-9_-])`;
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
return null;
|
|
1807
|
+
}
|
|
1808
|
+
function isSSECommentLine(line) {
|
|
1809
|
+
return line.length > 0 && line.charCodeAt(0) === 58;
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1776
1812
|
// src/core/http.ts
|
|
1777
1813
|
init_errors();
|
|
1778
1814
|
var maxDownloadSize = 50 * 1024 * 1024;
|
|
@@ -1963,6 +1999,7 @@ var FilterStatusUnknown = "";
|
|
|
1963
1999
|
var ErrOAuthCORSBlocked = "oauth_cors_blocked";
|
|
1964
2000
|
var ErrRefreshProxyFailed = "refresh_proxy_failed";
|
|
1965
2001
|
var ErrTokenExpired = "token_expired";
|
|
2002
|
+
var CHAT_REQUEST_TIMEOUT_MS = 11 * 60 * 1e3;
|
|
1966
2003
|
function newDeferred() {
|
|
1967
2004
|
let resolve;
|
|
1968
2005
|
let reject;
|
|
@@ -2556,7 +2593,7 @@ var Client = class _Client {
|
|
|
2556
2593
|
*/
|
|
2557
2594
|
async chat(modelID, req, signal) {
|
|
2558
2595
|
req.stream = false;
|
|
2559
|
-
const ctl = withRequestTimeout(
|
|
2596
|
+
const ctl = withRequestTimeout(CHAT_REQUEST_TIMEOUT_MS, signal);
|
|
2560
2597
|
try {
|
|
2561
2598
|
const { body, adapter } = await this.buildChatRequest(modelID, req, ctl.signal);
|
|
2562
2599
|
const endpoint = `/managed-models/${encodeURIComponent(modelID)}${adapter.endpointSuffix()}`;
|
|
@@ -2603,7 +2640,7 @@ var Client = class _Client {
|
|
|
2603
2640
|
}
|
|
2604
2641
|
async chatMessagesAnthropic(modelID, req, adapter, signal) {
|
|
2605
2642
|
req.stream = false;
|
|
2606
|
-
const ctl = withRequestTimeout(
|
|
2643
|
+
const ctl = withRequestTimeout(CHAT_REQUEST_TIMEOUT_MS, signal);
|
|
2607
2644
|
try {
|
|
2608
2645
|
const caps = this.getCachedCapabilities(modelID) ?? zeroModelCapabilities();
|
|
2609
2646
|
const body = adapter.buildRequestBody(caps, req);
|
|
@@ -2640,7 +2677,7 @@ var Client = class _Client {
|
|
|
2640
2677
|
}
|
|
2641
2678
|
async chatMessagesOpenAI(modelID, req, adapter, signal) {
|
|
2642
2679
|
req.stream = false;
|
|
2643
|
-
const ctl = withRequestTimeout(
|
|
2680
|
+
const ctl = withRequestTimeout(CHAT_REQUEST_TIMEOUT_MS, signal);
|
|
2644
2681
|
try {
|
|
2645
2682
|
const caps = this.getCachedCapabilities(modelID) ?? zeroModelCapabilities();
|
|
2646
2683
|
const body = adapter.buildRequestBody(caps, req);
|
|
@@ -2721,6 +2758,7 @@ var Client = class _Client {
|
|
|
2721
2758
|
}
|
|
2722
2759
|
let currentEvent = "";
|
|
2723
2760
|
for await (const line of iterSSELines(resp.body)) {
|
|
2761
|
+
if (isSSECommentLine(line)) continue;
|
|
2724
2762
|
if (line.startsWith("event:")) {
|
|
2725
2763
|
currentEvent = line.slice("event:".length).trim();
|
|
2726
2764
|
} else if (line.startsWith("data:")) {
|
|
@@ -2786,6 +2824,7 @@ var Client = class _Client {
|
|
|
2786
2824
|
if (adapter.format() === 1 /* OpenAI */) {
|
|
2787
2825
|
const converter = newOpenAIStreamConverter();
|
|
2788
2826
|
for await (const line of iterSSELines(resp.body)) {
|
|
2827
|
+
if (isSSECommentLine(line)) continue;
|
|
2789
2828
|
if (line.startsWith("event:")) {
|
|
2790
2829
|
line.slice("event:".length).trim();
|
|
2791
2830
|
} else if (line.startsWith("data:")) {
|
|
@@ -2799,6 +2838,7 @@ var Client = class _Client {
|
|
|
2799
2838
|
const blockTypeMap = /* @__PURE__ */ new Map();
|
|
2800
2839
|
let currentEvent = "";
|
|
2801
2840
|
for await (const line of iterSSELines(resp.body)) {
|
|
2841
|
+
if (isSSECommentLine(line)) continue;
|
|
2802
2842
|
if (line.startsWith("event:")) {
|
|
2803
2843
|
currentEvent = line.slice("event:".length).trim();
|
|
2804
2844
|
} else if (line.startsWith("data:")) {
|
|
@@ -6086,6 +6126,386 @@ Client.prototype.getBugReport = async function(bugID, signal) {
|
|
|
6086
6126
|
return resp.data;
|
|
6087
6127
|
};
|
|
6088
6128
|
|
|
6089
|
-
|
|
6129
|
+
// src/subscription/client.ts
|
|
6130
|
+
Client.prototype.listPlans = async function(audience, signal) {
|
|
6131
|
+
const query = audience ? `?audience=${encodeURIComponent(audience)}` : "";
|
|
6132
|
+
const resp = await this.doJSON(
|
|
6133
|
+
"GET",
|
|
6134
|
+
`/distribution/public/pricing/plans${query}`,
|
|
6135
|
+
null,
|
|
6136
|
+
signal
|
|
6137
|
+
);
|
|
6138
|
+
return Array.isArray(resp.data) ? resp.data : [];
|
|
6139
|
+
};
|
|
6140
|
+
Client.prototype.listUserSubscriptions = async function(signal) {
|
|
6141
|
+
const resp = await this.doJSON(
|
|
6142
|
+
"GET",
|
|
6143
|
+
"/distribution/user/subscriptions",
|
|
6144
|
+
null,
|
|
6145
|
+
signal
|
|
6146
|
+
);
|
|
6147
|
+
return Array.isArray(resp.data) ? resp.data : [];
|
|
6148
|
+
};
|
|
6149
|
+
|
|
6150
|
+
// src/pricing/client.ts
|
|
6151
|
+
Client.prototype.getPricingConfig = async function(key, signal) {
|
|
6152
|
+
const query = key ? `?key=${encodeURIComponent(key)}` : "";
|
|
6153
|
+
const resp = await this.doJSON(
|
|
6154
|
+
"GET",
|
|
6155
|
+
`/distribution/public/pricing/config${query}`,
|
|
6156
|
+
null,
|
|
6157
|
+
signal
|
|
6158
|
+
);
|
|
6159
|
+
return resp.data ?? {};
|
|
6160
|
+
};
|
|
6161
|
+
Client.prototype.listPublicModels = async function(signal) {
|
|
6162
|
+
const resp = await this.doJSON(
|
|
6163
|
+
"GET",
|
|
6164
|
+
"/distribution/public/pricing/models",
|
|
6165
|
+
null,
|
|
6166
|
+
signal
|
|
6167
|
+
);
|
|
6168
|
+
return Array.isArray(resp.data) ? resp.data : [];
|
|
6169
|
+
};
|
|
6170
|
+
Client.prototype.listComplianceSkus = async function(region, signal) {
|
|
6171
|
+
const query = region ? `?region=${encodeURIComponent(region)}` : "";
|
|
6172
|
+
const resp = await this.doJSON(
|
|
6173
|
+
"GET",
|
|
6174
|
+
`/distribution/public/compliance/skus${query}`,
|
|
6175
|
+
null,
|
|
6176
|
+
signal
|
|
6177
|
+
);
|
|
6178
|
+
return Array.isArray(resp.data) ? resp.data : [];
|
|
6179
|
+
};
|
|
6180
|
+
Client.prototype.quoteCompliance = async function(skuCode, quantity, region, signal) {
|
|
6181
|
+
if (!skuCode) {
|
|
6182
|
+
throw new Error("quoteCompliance: skuCode is required");
|
|
6183
|
+
}
|
|
6184
|
+
const params = [`skuCode=${encodeURIComponent(skuCode)}`];
|
|
6185
|
+
if (quantity != null) params.push(`quantity=${quantity}`);
|
|
6186
|
+
if (region) params.push(`region=${encodeURIComponent(region)}`);
|
|
6187
|
+
const resp = await this.doJSON(
|
|
6188
|
+
"GET",
|
|
6189
|
+
`/distribution/public/compliance/quote?${params.join("&")}`,
|
|
6190
|
+
null,
|
|
6191
|
+
signal
|
|
6192
|
+
);
|
|
6193
|
+
return resp.data ?? { skuCode, available: false };
|
|
6194
|
+
};
|
|
6195
|
+
|
|
6196
|
+
// src/products/types.ts
|
|
6197
|
+
var ProductFamilyEnum = {
|
|
6198
|
+
MODEL_MEMBERSHIP: "MODEL_MEMBERSHIP",
|
|
6199
|
+
TOKEN_PACK: "TOKEN_PACK",
|
|
6200
|
+
COMPLIANCE: "COMPLIANCE",
|
|
6201
|
+
LEGAL: "LEGAL",
|
|
6202
|
+
DESIGN_AGENT: "DESIGN_AGENT",
|
|
6203
|
+
ENTERPRISE: "ENTERPRISE"
|
|
6204
|
+
};
|
|
6205
|
+
var AudienceEnum = {
|
|
6206
|
+
PERSONAL: "PERSONAL",
|
|
6207
|
+
ENTERPRISE: "ENTERPRISE",
|
|
6208
|
+
DEVELOPER: "DEVELOPER"
|
|
6209
|
+
};
|
|
6210
|
+
var BillingModeEnum = {
|
|
6211
|
+
ONE_TIME: "ONE_TIME",
|
|
6212
|
+
SUBSCRIPTION: "SUBSCRIPTION",
|
|
6213
|
+
METERED: "METERED",
|
|
6214
|
+
HYBRID: "HYBRID"
|
|
6215
|
+
};
|
|
6216
|
+
var RegionScopeEnum = {
|
|
6217
|
+
CN: "CN",
|
|
6218
|
+
OS: "OS",
|
|
6219
|
+
GLOBAL: "GLOBAL"
|
|
6220
|
+
};
|
|
6221
|
+
|
|
6222
|
+
// src/products/client.ts
|
|
6223
|
+
Client.prototype.listProductsByFamily = async function(family, audience, region, signal) {
|
|
6224
|
+
const params = [];
|
|
6225
|
+
if (family) params.push(`family=${encodeURIComponent(family)}`);
|
|
6226
|
+
if (audience) params.push(`audience=${encodeURIComponent(audience)}`);
|
|
6227
|
+
if (region) params.push(`region=${encodeURIComponent(region)}`);
|
|
6228
|
+
const query = params.length > 0 ? `?${params.join("&")}` : "";
|
|
6229
|
+
const resp = await this.doJSON(
|
|
6230
|
+
"GET",
|
|
6231
|
+
`/distribution/public/products/by-family${query}`,
|
|
6232
|
+
null,
|
|
6233
|
+
signal
|
|
6234
|
+
);
|
|
6235
|
+
return Array.isArray(resp.data) ? resp.data : [];
|
|
6236
|
+
};
|
|
6237
|
+
Client.prototype.getProductBySlug = async function(slug, region, signal) {
|
|
6238
|
+
if (!slug) {
|
|
6239
|
+
throw new Error("getProductBySlug: slug is required");
|
|
6240
|
+
}
|
|
6241
|
+
const query = region ? `?region=${encodeURIComponent(region)}` : "";
|
|
6242
|
+
const resp = await this.doJSON(
|
|
6243
|
+
"GET",
|
|
6244
|
+
`/distribution/public/products/by-slug/${encodeURIComponent(slug)}${query}`,
|
|
6245
|
+
null,
|
|
6246
|
+
signal
|
|
6247
|
+
);
|
|
6248
|
+
if (!resp.data) {
|
|
6249
|
+
throw new Error(`getProductBySlug: product not found (slug=${slug})`);
|
|
6250
|
+
}
|
|
6251
|
+
return resp.data;
|
|
6252
|
+
};
|
|
6253
|
+
|
|
6254
|
+
// src/casehall/client.ts
|
|
6255
|
+
Client.prototype.listLawyers = async function(params, signal) {
|
|
6256
|
+
const qs = new URLSearchParams();
|
|
6257
|
+
if (params?.practiceArea) qs.set("practiceArea", params.practiceArea);
|
|
6258
|
+
if (params?.location) qs.set("location", params.location);
|
|
6259
|
+
if (params?.pageNo != null) qs.set("pageNo", String(params.pageNo));
|
|
6260
|
+
if (params?.pageSize != null) qs.set("pageSize", String(params.pageSize));
|
|
6261
|
+
const q = qs.toString() ? `?${qs.toString()}` : "";
|
|
6262
|
+
const resp = await this.doJSON(
|
|
6263
|
+
"GET",
|
|
6264
|
+
`/casehall/app/lawyers${q}`,
|
|
6265
|
+
null,
|
|
6266
|
+
signal
|
|
6267
|
+
);
|
|
6268
|
+
return resp.data ?? [];
|
|
6269
|
+
};
|
|
6270
|
+
Client.prototype.getLawyer = async function(id, signal) {
|
|
6271
|
+
const resp = await this.doJSON(
|
|
6272
|
+
"GET",
|
|
6273
|
+
`/casehall/app/lawyers/${id}`,
|
|
6274
|
+
null,
|
|
6275
|
+
signal
|
|
6276
|
+
);
|
|
6277
|
+
if (!resp.data) throw new Error(`lawyer ${id} not found`);
|
|
6278
|
+
return resp.data;
|
|
6279
|
+
};
|
|
6280
|
+
Client.prototype.submitCaseLead = async function(req, signal) {
|
|
6281
|
+
const resp = await this.doJSON(
|
|
6282
|
+
"POST",
|
|
6283
|
+
`/casehall/me/case-leads`,
|
|
6284
|
+
req,
|
|
6285
|
+
signal
|
|
6286
|
+
);
|
|
6287
|
+
return resp.data ?? { id: 0 };
|
|
6288
|
+
};
|
|
6289
|
+
Client.prototype.listMyCaseLeads = async function(signal) {
|
|
6290
|
+
const resp = await this.doJSON(
|
|
6291
|
+
"GET",
|
|
6292
|
+
`/casehall/me/case-leads`,
|
|
6293
|
+
null,
|
|
6294
|
+
signal
|
|
6295
|
+
);
|
|
6296
|
+
return resp.data ?? [];
|
|
6297
|
+
};
|
|
6298
|
+
Client.prototype.getMyCases = async function(signal) {
|
|
6299
|
+
const resp = await this.doJSON(
|
|
6300
|
+
"GET",
|
|
6301
|
+
`/casehall/me/cases`,
|
|
6302
|
+
null,
|
|
6303
|
+
signal
|
|
6304
|
+
);
|
|
6305
|
+
return resp.data ?? [];
|
|
6306
|
+
};
|
|
6307
|
+
Client.prototype.bookConsultation = async function(req, signal) {
|
|
6308
|
+
const resp = await this.doJSON(
|
|
6309
|
+
"POST",
|
|
6310
|
+
`/casehall/me/consultations`,
|
|
6311
|
+
req,
|
|
6312
|
+
signal
|
|
6313
|
+
);
|
|
6314
|
+
return resp.data ?? { consultationId: 0 };
|
|
6315
|
+
};
|
|
6316
|
+
Client.prototype.listMyConsultations = async function(signal) {
|
|
6317
|
+
const resp = await this.doJSON(
|
|
6318
|
+
"GET",
|
|
6319
|
+
`/casehall/me/consultations`,
|
|
6320
|
+
null,
|
|
6321
|
+
signal
|
|
6322
|
+
);
|
|
6323
|
+
return resp.data ?? [];
|
|
6324
|
+
};
|
|
6325
|
+
Client.prototype.listMyLegalOrders = async function(signal) {
|
|
6326
|
+
const resp = await this.doJSON(
|
|
6327
|
+
"GET",
|
|
6328
|
+
`/casehall/me/orders`,
|
|
6329
|
+
null,
|
|
6330
|
+
signal
|
|
6331
|
+
);
|
|
6332
|
+
return resp.data ?? [];
|
|
6333
|
+
};
|
|
6334
|
+
Client.prototype.listLegalSKUs = async function(region, signal) {
|
|
6335
|
+
const q = region ? `?region=${encodeURIComponent(region)}&benefitType=LEGAL_SERVICE` : `?benefitType=LEGAL_SERVICE`;
|
|
6336
|
+
const resp = await this.doJSON(
|
|
6337
|
+
"GET",
|
|
6338
|
+
`/casehall/app/legal-skus${q}`,
|
|
6339
|
+
null,
|
|
6340
|
+
signal
|
|
6341
|
+
);
|
|
6342
|
+
return resp.data ?? [];
|
|
6343
|
+
};
|
|
6344
|
+
|
|
6345
|
+
// src/enterprise/client.ts
|
|
6346
|
+
Client.prototype.listMyEnterprises = async function(signal) {
|
|
6347
|
+
const resp = await this.doJSON(
|
|
6348
|
+
"GET",
|
|
6349
|
+
`/me/enterprises`,
|
|
6350
|
+
null,
|
|
6351
|
+
signal
|
|
6352
|
+
);
|
|
6353
|
+
return resp.data ?? [];
|
|
6354
|
+
};
|
|
6355
|
+
Client.prototype.getEnterprise = async function(id, signal) {
|
|
6356
|
+
const resp = await this.doJSON(
|
|
6357
|
+
"GET",
|
|
6358
|
+
`/api/admin/enterprises/${id}`,
|
|
6359
|
+
null,
|
|
6360
|
+
signal
|
|
6361
|
+
);
|
|
6362
|
+
if (!resp.data) throw new Error(`enterprise ${id} not found`);
|
|
6363
|
+
return resp.data;
|
|
6364
|
+
};
|
|
6365
|
+
Client.prototype.inviteMember = async function(req, signal) {
|
|
6366
|
+
const resp = await this.doJSON(
|
|
6367
|
+
"POST",
|
|
6368
|
+
`/api/admin/enterprise-members`,
|
|
6369
|
+
req,
|
|
6370
|
+
signal
|
|
6371
|
+
);
|
|
6372
|
+
if (!resp.data) throw new Error("invite member failed");
|
|
6373
|
+
return resp.data;
|
|
6374
|
+
};
|
|
6375
|
+
Client.prototype.listEnterpriseMembers = async function(enterpriseId, signal) {
|
|
6376
|
+
const resp = await this.doJSON(
|
|
6377
|
+
"GET",
|
|
6378
|
+
`/api/admin/enterprise-members/by-enterprise/${enterpriseId}`,
|
|
6379
|
+
null,
|
|
6380
|
+
signal
|
|
6381
|
+
);
|
|
6382
|
+
return resp.data ?? [];
|
|
6383
|
+
};
|
|
6384
|
+
Client.prototype.listOrgSubscriptions = async function(enterpriseId, signal) {
|
|
6385
|
+
const resp = await this.doJSON(
|
|
6386
|
+
"GET",
|
|
6387
|
+
`/api/admin/org-subscriptions/by-enterprise/${enterpriseId}`,
|
|
6388
|
+
null,
|
|
6389
|
+
signal
|
|
6390
|
+
);
|
|
6391
|
+
return resp.data ?? [];
|
|
6392
|
+
};
|
|
6393
|
+
Client.prototype.listSeats = async function(orgSubscriptionId, signal) {
|
|
6394
|
+
const resp = await this.doJSON(
|
|
6395
|
+
"GET",
|
|
6396
|
+
`/api/admin/org-seats/by-subscription/${orgSubscriptionId}`,
|
|
6397
|
+
null,
|
|
6398
|
+
signal
|
|
6399
|
+
);
|
|
6400
|
+
return resp.data ?? [];
|
|
6401
|
+
};
|
|
6402
|
+
Client.prototype.assignSeat = async function(req, signal) {
|
|
6403
|
+
const resp = await this.doJSON(
|
|
6404
|
+
"POST",
|
|
6405
|
+
`/api/admin/org-seats/assign`,
|
|
6406
|
+
req,
|
|
6407
|
+
signal
|
|
6408
|
+
);
|
|
6409
|
+
if (!resp.data) throw new Error("assign seat failed");
|
|
6410
|
+
return resp.data;
|
|
6411
|
+
};
|
|
6412
|
+
Client.prototype.revokeSeat = async function(seatId, note, signal) {
|
|
6413
|
+
const qs = note ? `?note=${encodeURIComponent(note)}` : "";
|
|
6414
|
+
await this.doJSON(
|
|
6415
|
+
"POST",
|
|
6416
|
+
`/api/admin/org-seats/${seatId}/revoke${qs}`,
|
|
6417
|
+
null,
|
|
6418
|
+
signal
|
|
6419
|
+
);
|
|
6420
|
+
};
|
|
6421
|
+
Client.prototype.getOrgConsumeReport = async function(enterpriseId, signal) {
|
|
6422
|
+
const resp = await this.doJSON(
|
|
6423
|
+
"GET",
|
|
6424
|
+
`/api/admin/enterprise-settlements/overview/${enterpriseId}`,
|
|
6425
|
+
null,
|
|
6426
|
+
signal
|
|
6427
|
+
);
|
|
6428
|
+
if (!resp.data) {
|
|
6429
|
+
return {
|
|
6430
|
+
enterpriseId,
|
|
6431
|
+
subscriptionCount: 0,
|
|
6432
|
+
totalPoolTk: 0,
|
|
6433
|
+
totalUsedTk: 0,
|
|
6434
|
+
totalPriceFen: 0
|
|
6435
|
+
};
|
|
6436
|
+
}
|
|
6437
|
+
return resp.data;
|
|
6438
|
+
};
|
|
6439
|
+
|
|
6440
|
+
// src/finance/client.ts
|
|
6441
|
+
Client.prototype.requestRefund = async function(req, signal) {
|
|
6442
|
+
const resp = await this.doJSON(
|
|
6443
|
+
"POST",
|
|
6444
|
+
`/api/distribution/finance/refund/request`,
|
|
6445
|
+
req,
|
|
6446
|
+
signal
|
|
6447
|
+
);
|
|
6448
|
+
if (!resp.data) throw new Error("refund/request: empty response");
|
|
6449
|
+
return resp.data;
|
|
6450
|
+
};
|
|
6451
|
+
Client.prototype.listMyRefunds = async function(signal) {
|
|
6452
|
+
const resp = await this.doJSON(
|
|
6453
|
+
"GET",
|
|
6454
|
+
`/api/distribution/finance/refund/my`,
|
|
6455
|
+
null,
|
|
6456
|
+
signal
|
|
6457
|
+
);
|
|
6458
|
+
return resp.data ?? [];
|
|
6459
|
+
};
|
|
6460
|
+
Client.prototype.requestInvoice = async function(req, signal) {
|
|
6461
|
+
const resp = await this.doJSON(
|
|
6462
|
+
"POST",
|
|
6463
|
+
`/api/distribution/finance/invoice/request`,
|
|
6464
|
+
req,
|
|
6465
|
+
signal
|
|
6466
|
+
);
|
|
6467
|
+
if (!resp.data) throw new Error("invoice/request: empty response");
|
|
6468
|
+
return resp.data;
|
|
6469
|
+
};
|
|
6470
|
+
Client.prototype.listMyInvoices = async function(signal) {
|
|
6471
|
+
const resp = await this.doJSON(
|
|
6472
|
+
"GET",
|
|
6473
|
+
`/api/distribution/finance/invoice/my`,
|
|
6474
|
+
null,
|
|
6475
|
+
signal
|
|
6476
|
+
);
|
|
6477
|
+
return resp.data ?? [];
|
|
6478
|
+
};
|
|
6479
|
+
Client.prototype.initiateCorporateTransfer = async function(req, signal) {
|
|
6480
|
+
const resp = await this.doJSON(
|
|
6481
|
+
"POST",
|
|
6482
|
+
`/api/distribution/finance/corporate-transfer/initiate`,
|
|
6483
|
+
req,
|
|
6484
|
+
signal
|
|
6485
|
+
);
|
|
6486
|
+
if (!resp.data) throw new Error("corporate-transfer/initiate: empty response");
|
|
6487
|
+
return resp.data;
|
|
6488
|
+
};
|
|
6489
|
+
Client.prototype.uploadCorporateTransferProof = async function(id, proofUrl, signal) {
|
|
6490
|
+
const qs = new URLSearchParams({ proofUrl });
|
|
6491
|
+
const resp = await this.doJSON(
|
|
6492
|
+
"POST",
|
|
6493
|
+
`/api/distribution/finance/corporate-transfer/${id}/upload-proof?${qs.toString()}`,
|
|
6494
|
+
null,
|
|
6495
|
+
signal
|
|
6496
|
+
);
|
|
6497
|
+
return resp.data ?? false;
|
|
6498
|
+
};
|
|
6499
|
+
Client.prototype.listMyCorporateTransfers = async function(signal) {
|
|
6500
|
+
const resp = await this.doJSON(
|
|
6501
|
+
"GET",
|
|
6502
|
+
`/api/distribution/finance/corporate-transfer/my`,
|
|
6503
|
+
null,
|
|
6504
|
+
signal
|
|
6505
|
+
);
|
|
6506
|
+
return resp.data ?? [];
|
|
6507
|
+
};
|
|
6508
|
+
|
|
6509
|
+
export { AgentRunStreamError, AgentRunsClient, AnthropicAdapter, AudienceEnum, BillingModeEnum, BucketClassCommercial, BucketClassGeneric, BusinessError, Client, ComplianceClient, CompliancePollError, LocalStorageTokenStore as DefaultBrowserTokenStore, DefaultRetryPolicy, ErrAuthDenied, ErrBillingCallbackCannotCommit, ErrBillingCommitRequiresLocalVerify, ErrBillingS2sForbidden, ErrBrowserOpen, ErrComplianceStepUpRequired, ErrDiscovery, ErrEnvelopeGateClosed, ErrOAuthCORSBlocked, ErrProviderNotConfigured, ErrProviderUnknownNoRetry, ErrRefreshProxyFailed, ErrRegistration, ErrSSLProxy, ErrSealApprovalContractHashMismatch, ErrSealApprovalExpired, ErrSealApprovalLocationMismatch, ErrSealApprovalNonceUsed, ErrSealApprovalNotApproved, ErrSealApprovalSealMismatch, ErrSealApprovalTransactorMismatch, ErrSealUseAlreadyConsumed, ErrStateMismatch, ErrTimeout, ErrTokenExchange, ErrTokenExpired, EventAuthURL, EventComplete, EventError, FileTokenStore, FilterStatusAdminBypass, FilterStatusDisabledByFlag, FilterStatusFallbackMissingUser, FilterStatusFallbackNoBuckets, FilterStatusFallbackTkdistError, FilterStatusFallbackTkdistSkew, FilterStatusInternalBypass, FilterStatusOK, FilterStatusUnknown, HTTPError, IdempotencyKeyHeader, InMemoryTokenStore, LocalStorageTokenStore, ModelNotFoundError, NetworkError, OpenAIAdapter, OrderTerminalError, ProductFamilyEnum, ProviderFormat, RETRY_ADVICE_REASONS, RateLimitError, RegionScopeEnum, ScopeAI, ScopeAccount, ScopeComplianceContractSigningRead, ScopeComplianceContractSigningWrite, ScopeComplianceContractTemplateRead, ScopeComplianceContractTemplateWrite, ScopeComplianceEvidenceRead, ScopeComplianceEvidenceWrite, ScopeComplianceReportsPublish, ScopeComplianceReportsRead, ScopeComplianceReportsWrite, ScopeComplianceSealApprovalApprove, ScopeComplianceSealApprovalRequest, ScopeComplianceSealManage, ScopeComplianceSealUseExecute, ScopeComplianceTimestampIssue, ScopeComplianceTimestampVerify, ScopeEntitlements, ScopeModels, ScopeModelsChat, ScopeProfile, ScopeSkillStore, ScopeSkills, ScopeTokenPackages, ScopeTools, ScopeToolsExecute, ScopeWallet, ScopeWalletReadonly, ServerToolTypeWebSearch, StreamError, ThinkingHigh, ThinkingHighMinMaxTokens, ThinkingMax, ThinkingMaxFallbackMaxTokens, ThinkingOff, allScopes, anthropicResponseTextContent, anthropicResponseThinkingContent, anthropicResponseToolUseBlocks, apiResponseBusinessError, apiResponseGetMessage, authorize, bucketInfoIsCommercial, bucketRowIsCommercial, buildBetas, classifyComplianceError, commerceScopes, completeWebAuthorizationRequest, complianceErrorToRetryAdvice, complianceScopes, computeBackoff, createWebAuthorizationRequest, defaultRetryable, defaultSafeToRetry, discover, discoverWebOAuthMetadata, discoverWithProfile, effectivePolicy, exchangeCode, extractAnthropicBlockMeta, fileLockDefaults, findDesktopVisualUnderstandingModel, findFirstModelByInputModality, generateState, getAdapter, getAdapterForModel, isBillingConfirmable, isComplianceBusinessError, isComplianceTerminalError, isSSECommentLine, isSSLError, maxEndUserIdLength, modelScopes, modelSupportsImageInput, modelSupportsInputModality, newFileTokenStore, newThinkingConfig, newTokenSet, newWebSearchTool, parseNotificationEvent, parseSettlement, parseSourcesEvent, refreshToken, register, registerWebOAuthClient, retryReasonForComplianceKey, retryReasonForOAuthError, revokeToken, sanitize_exports as sanitize, skillScopes, tokenSetIsExpired, uniqueMerge, validateEndUserId };
|
|
6090
6510
|
//# sourceMappingURL=index.mjs.map
|
|
6091
6511
|
//# sourceMappingURL=index.mjs.map
|