lua-cli 3.28.0 → 3.29.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/README.md +18 -8
- package/dist/api-exports.d.ts +24 -7
- package/dist/api-exports.js +810 -472
- package/dist/api-exports.js.map +1 -1
- package/dist/index.js +1547 -1783
- package/dist/index.js.map +1 -1
- package/docs/README.md +4 -5
- package/package.json +1 -1
- package/template/package.json +1 -1
package/dist/api-exports.js
CHANGED
|
@@ -370,6 +370,64 @@ function buildDefaultPersona(agentName) {
|
|
|
370
370
|
function buildPersonalSpaceStartingPersona(agentName) {
|
|
371
371
|
return PERSONAL_SPACE_STARTING_PERSONA.replace(new RegExp(AGENT_NAME_TOKEN.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), () => agentName || "Your assistant");
|
|
372
372
|
}
|
|
373
|
+
function isRecord(value) {
|
|
374
|
+
return typeof value === "object" && value !== null;
|
|
375
|
+
}
|
|
376
|
+
function isCoreDrainingErrorResponse(value) {
|
|
377
|
+
if (!isRecord(value) || !isRecord(value.error)) return false;
|
|
378
|
+
return value.error.code === CORE_DRAINING_CODE && typeof value.error.message === "string" && value.error.retryable === true;
|
|
379
|
+
}
|
|
380
|
+
function coreDrainingRetryDelayMs(retryAfter, nowMs = Date.now()) {
|
|
381
|
+
if (retryAfter === null) return CORE_DRAINING_DEFAULT_RETRY_MS;
|
|
382
|
+
const seconds = /^\d+$/.test(retryAfter.trim()) ? Number(retryAfter) : Number.NaN;
|
|
383
|
+
const delayMs = Number.isFinite(seconds) ? seconds * 1e3 : Date.parse(retryAfter) - nowMs;
|
|
384
|
+
if (!Number.isFinite(delayMs)) return CORE_DRAINING_DEFAULT_RETRY_MS;
|
|
385
|
+
return Math.min(Math.max(0, delayMs), CORE_DRAINING_MAX_RETRY_MS);
|
|
386
|
+
}
|
|
387
|
+
async function readCoreDrainingRetryDelayMs(response) {
|
|
388
|
+
if (response.status !== 503) return null;
|
|
389
|
+
try {
|
|
390
|
+
const payload = await response.clone().json();
|
|
391
|
+
if (!isCoreDrainingErrorResponse(payload)) return null;
|
|
392
|
+
} catch {
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
return coreDrainingRetryDelayMs(response.headers.get("Retry-After"));
|
|
396
|
+
}
|
|
397
|
+
function waitForCoreDrain(delayMs, signal) {
|
|
398
|
+
return new Promise((resolve, reject) => {
|
|
399
|
+
if (signal?.aborted) {
|
|
400
|
+
reject(signal.reason ?? new DOMException("Aborted", "AbortError"));
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
const timer = setTimeout(() => {
|
|
404
|
+
signal?.removeEventListener("abort", onAbort);
|
|
405
|
+
resolve();
|
|
406
|
+
}, delayMs);
|
|
407
|
+
function onAbort() {
|
|
408
|
+
clearTimeout(timer);
|
|
409
|
+
reject(signal?.reason ?? new DOMException("Aborted", "AbortError"));
|
|
410
|
+
}
|
|
411
|
+
__name(onAbort, "onAbort");
|
|
412
|
+
__name2(onAbort, "onAbort");
|
|
413
|
+
signal?.addEventListener("abort", onAbort, {
|
|
414
|
+
once: true
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
async function fetchWithCoreDrainRetry(run, options = {}) {
|
|
419
|
+
const first = await run();
|
|
420
|
+
const delayMs = await readCoreDrainingRetryDelayMs(first);
|
|
421
|
+
if (delayMs === null) return first;
|
|
422
|
+
options.onRetry?.({
|
|
423
|
+
attempt: 1,
|
|
424
|
+
maxAttempts: 2,
|
|
425
|
+
delayMs
|
|
426
|
+
});
|
|
427
|
+
await first.body?.cancel();
|
|
428
|
+
await waitForCoreDrain(delayMs, options.signal);
|
|
429
|
+
return run();
|
|
430
|
+
}
|
|
373
431
|
function resolveLuaJobTimeoutSeconds(timeout) {
|
|
374
432
|
const resolved = timeout ?? LUA_JOB_DEFAULT_TIMEOUT_SECONDS;
|
|
375
433
|
if (!Number.isInteger(resolved)) {
|
|
@@ -390,10 +448,21 @@ function triggerUrlEnvKey(triggerKey) {
|
|
|
390
448
|
const upper = triggerKey.trim().replace(/[^A-Za-z0-9]+/g, "_").replace(/^_+|_+$/g, "").toUpperCase();
|
|
391
449
|
return `${TEMPLATE_TRIGGER_URL_ENV_PREFIX}${upper}`;
|
|
392
450
|
}
|
|
451
|
+
function deviceCredentialScopes(operations) {
|
|
452
|
+
return [
|
|
453
|
+
...new Set(operations.map((operation) => DEVICE_SCOPE_BY_OPERATION[operation]))
|
|
454
|
+
];
|
|
455
|
+
}
|
|
393
456
|
function parsePrincipalContext(value) {
|
|
394
457
|
const parsed = PrincipalContextSchema.safeParse(value);
|
|
395
458
|
return parsed.success ? parsed.data : void 0;
|
|
396
459
|
}
|
|
460
|
+
function isDeviceCredentialPrincipal(context) {
|
|
461
|
+
return context?.credential.type === "deviceCredential";
|
|
462
|
+
}
|
|
463
|
+
function hasDeviceCredentialType(value) {
|
|
464
|
+
return DeviceCredentialClaimSchema.safeParse(value).success;
|
|
465
|
+
}
|
|
397
466
|
function isTypedApiKeyPrincipal(context) {
|
|
398
467
|
return context?.subject.subjectType === "apiKey" && context.credential.type === "apiKey" && !context.compatibility;
|
|
399
468
|
}
|
|
@@ -467,7 +536,7 @@ function isKnownProfile(profiles, profileId) {
|
|
|
467
536
|
function hasCapability(profiles, profileId, required) {
|
|
468
537
|
return capabilitiesFor(profiles, profileId).includes(required);
|
|
469
538
|
}
|
|
470
|
-
var __defProp2, __name2, CHANNEL_SEND_CHANNELS, REVIEWABLE_ACTION_EXECUTE_TOOL_ALLOWLIST, REVIEWABLE_MCP_SEND_TOOL_SUFFIX, MCP_TOOL_READ_VERB_RE, MCP_DRAFT_CREATE_VERBS, NON_INTERACTIVE_CHANNELS, RICH_PARTS_MESSAGE_ID_PREFIX, SCREENSHOT_MESSAGE_ID_PREFIX, BROWSER_COMMANDS, BROWSER_COMMAND_NAMES, DESKTOP_FILE_COMMANDS, DESKTOP_FILE_COMMAND_SET, REASONING_EFFORT_VALUES, IMPLICIT_MODEL_SELECTION_SOURCES, AGENT_NAME_TOKEN, DEFAULT_PERSONA_GUIDE, PERSONAL_SPACE_STARTING_PERSONA, VoiceNameSchema, PluginProviderSchema, RealtimeProviderSchema, PluginClassSchema, ModelDescriptorSchema, InferenceModelSchema, PluginModelSchema, RealtimeModelSchema, LuaVoiceModelSchema, TurnDetectionSchema, InterruptionSchema, BuiltinAudioClipSchema, AudioConfigSchema, BackgroundAudioEntrySchema, BackgroundAudioSchema, LuaVoiceConfigInnerSchema, LuaVoiceConfigSchema, LuaVoiceRefSchema, LUA_JOB_DEFAULT_TIMEOUT_SECONDS, LUA_JOB_MIN_TIMEOUT_SECONDS, LUA_JOB_MAX_TIMEOUT_SECONDS, TEMPLATE_TRIGGER_URL_ENV_PREFIX, SUBJECT_TYPES, SubjectTypeSchema, CREDENTIAL_TYPES, CredentialTypeSchema, PrincipalContextSchema, LUA_CLIENT_HEADER, LUA_CLIENT_APPS, SEMVER_PATTERN, WEB_RELEASE_PATTERN, CLIENT_HEADER_PATTERN, AUTHZ_PROJECTION_VERSION, ProjectedScopeSchema, DisplayRoleSchema, AuthorizationPrincipalSchema, CredentialContextSchema, ProjectionAnomalySchema, ProjectedOrgSchema, ProjectedResourceSchema, CapabilityProfilesSchema, RoleCatalogSchema, EffectiveAuthorizationSchema, ResourcePageSchema;
|
|
539
|
+
var __defProp2, __name2, CHANNEL_SEND_CHANNELS, REVIEWABLE_ACTION_EXECUTE_TOOL_ALLOWLIST, REVIEWABLE_MCP_SEND_TOOL_SUFFIX, MCP_TOOL_READ_VERB_RE, MCP_DRAFT_CREATE_VERBS, NON_INTERACTIVE_CHANNELS, RICH_PARTS_MESSAGE_ID_PREFIX, SCREENSHOT_MESSAGE_ID_PREFIX, BROWSER_COMMANDS, BROWSER_COMMAND_NAMES, DESKTOP_FILE_COMMANDS, DESKTOP_FILE_COMMAND_SET, REASONING_EFFORT_VALUES, IMPLICIT_MODEL_SELECTION_SOURCES, AGENT_NAME_TOKEN, DEFAULT_PERSONA_GUIDE, PERSONAL_SPACE_STARTING_PERSONA, CORE_DRAINING_CODE, CORE_DRAINING_DEFAULT_RETRY_MS, CORE_DRAINING_MAX_RETRY_MS, VoiceNameSchema, PluginProviderSchema, RealtimeProviderSchema, PluginClassSchema, ModelDescriptorSchema, InferenceModelSchema, PluginModelSchema, RealtimeModelSchema, LuaVoiceModelSchema, TurnDetectionSchema, InterruptionSchema, BuiltinAudioClipSchema, AudioConfigSchema, BackgroundAudioEntrySchema, BackgroundAudioSchema, LuaVoiceConfigInnerSchema, LuaVoiceConfigSchema, LuaVoiceRefSchema, LUA_JOB_DEFAULT_TIMEOUT_SECONDS, LUA_JOB_MIN_TIMEOUT_SECONDS, LUA_JOB_MAX_TIMEOUT_SECONDS, TEMPLATE_TRIGGER_URL_ENV_PREFIX, SUBJECT_TYPES, SubjectTypeSchema, CREDENTIAL_TYPES, CredentialTypeSchema, DEVICE_OPERATIONS, DeviceOperationSchema, DEVICE_SCOPE_BY_OPERATION, DeviceBindingSchema, IdSchema, PrincipalDescriptorSchema, ActorDescriptorSchema, PrincipalOwnerSchema, CredentialLifecycleSchema, GeneralCredentialDescriptorSchema, DeviceCredentialDescriptorSchema, GeneralPrincipalContextSchema, DeviceCredentialPrincipalContextSchema, RawPrincipalContextSchema, PrincipalContextSchema, DeviceCredentialClaimSchema, LUA_CLIENT_HEADER, LUA_CLIENT_APPS, SEMVER_PATTERN, WEB_RELEASE_PATTERN, CLIENT_HEADER_PATTERN, AUTHZ_PROJECTION_VERSION, ProjectedScopeSchema, DisplayRoleSchema, AuthorizationPrincipalSchema, CredentialContextSchema, ProjectionAnomalySchema, ProjectedOrgSchema, ProjectedResourceSchema, CapabilityProfilesSchema, RoleCatalogSchema, EffectiveAuthorizationSchema, ResourcePageSchema;
|
|
471
540
|
var init_dist = __esm({
|
|
472
541
|
"../shared-types/dist/index.mjs"() {
|
|
473
542
|
"use strict";
|
|
@@ -881,6 +950,21 @@ This text is who you are for this person. As you learn them, their name, their w
|
|
|
881
950
|
`;
|
|
882
951
|
__name(buildPersonalSpaceStartingPersona, "buildPersonalSpaceStartingPersona");
|
|
883
952
|
__name2(buildPersonalSpaceStartingPersona, "buildPersonalSpaceStartingPersona");
|
|
953
|
+
CORE_DRAINING_CODE = "CORE_DRAINING";
|
|
954
|
+
CORE_DRAINING_DEFAULT_RETRY_MS = 1e3;
|
|
955
|
+
CORE_DRAINING_MAX_RETRY_MS = 5e3;
|
|
956
|
+
__name(isRecord, "isRecord");
|
|
957
|
+
__name2(isRecord, "isRecord");
|
|
958
|
+
__name(isCoreDrainingErrorResponse, "isCoreDrainingErrorResponse");
|
|
959
|
+
__name2(isCoreDrainingErrorResponse, "isCoreDrainingErrorResponse");
|
|
960
|
+
__name(coreDrainingRetryDelayMs, "coreDrainingRetryDelayMs");
|
|
961
|
+
__name2(coreDrainingRetryDelayMs, "coreDrainingRetryDelayMs");
|
|
962
|
+
__name(readCoreDrainingRetryDelayMs, "readCoreDrainingRetryDelayMs");
|
|
963
|
+
__name2(readCoreDrainingRetryDelayMs, "readCoreDrainingRetryDelayMs");
|
|
964
|
+
__name(waitForCoreDrain, "waitForCoreDrain");
|
|
965
|
+
__name2(waitForCoreDrain, "waitForCoreDrain");
|
|
966
|
+
__name(fetchWithCoreDrainRetry, "fetchWithCoreDrainRetry");
|
|
967
|
+
__name2(fetchWithCoreDrainRetry, "fetchWithCoreDrainRetry");
|
|
884
968
|
VoiceNameSchema = z.string().regex(/^[a-zA-Z0-9_-]+$/, "Voice name must contain only alphanumeric characters, underscores, or hyphens").min(1).max(64);
|
|
885
969
|
PluginProviderSchema = z.enum([
|
|
886
970
|
"deepgram",
|
|
@@ -1153,36 +1237,139 @@ This text is who you are for this person. As you learn them, their name, their w
|
|
|
1153
1237
|
"legacyInternalToken"
|
|
1154
1238
|
];
|
|
1155
1239
|
CredentialTypeSchema = z2.enum(CREDENTIAL_TYPES);
|
|
1156
|
-
|
|
1240
|
+
DEVICE_OPERATIONS = [
|
|
1241
|
+
"commands",
|
|
1242
|
+
"triggers",
|
|
1243
|
+
"assets.upload"
|
|
1244
|
+
];
|
|
1245
|
+
DeviceOperationSchema = z2.enum(DEVICE_OPERATIONS);
|
|
1246
|
+
DEVICE_SCOPE_BY_OPERATION = {
|
|
1247
|
+
commands: "automations:write",
|
|
1248
|
+
triggers: "automations:write",
|
|
1249
|
+
"assets.upload": "files:write"
|
|
1250
|
+
};
|
|
1251
|
+
__name(deviceCredentialScopes, "deviceCredentialScopes");
|
|
1252
|
+
__name2(deviceCredentialScopes, "deviceCredentialScopes");
|
|
1253
|
+
DeviceBindingSchema = z2.object({
|
|
1254
|
+
agentId: z2.string().min(1).max(256),
|
|
1255
|
+
deviceName: z2.string().min(1).max(256),
|
|
1256
|
+
operations: z2.array(DeviceOperationSchema).min(1).max(DEVICE_OPERATIONS.length)
|
|
1257
|
+
}).strict().superRefine((binding, context) => {
|
|
1258
|
+
if (new Set(binding.operations).size !== binding.operations.length) {
|
|
1259
|
+
context.addIssue({
|
|
1260
|
+
code: z2.ZodIssueCode.custom,
|
|
1261
|
+
path: [
|
|
1262
|
+
"operations"
|
|
1263
|
+
],
|
|
1264
|
+
message: "Device operations must be unique"
|
|
1265
|
+
});
|
|
1266
|
+
}
|
|
1267
|
+
});
|
|
1268
|
+
IdSchema = z2.string().min(1).max(256);
|
|
1269
|
+
PrincipalDescriptorSchema = z2.object({
|
|
1270
|
+
subjectType: SubjectTypeSchema,
|
|
1271
|
+
subjectId: IdSchema
|
|
1272
|
+
}).strict();
|
|
1273
|
+
ActorDescriptorSchema = z2.object({
|
|
1274
|
+
actorType: SubjectTypeSchema,
|
|
1275
|
+
actorId: IdSchema
|
|
1276
|
+
}).strict();
|
|
1277
|
+
PrincipalOwnerSchema = z2.object({
|
|
1278
|
+
type: z2.enum([
|
|
1279
|
+
"user",
|
|
1280
|
+
"org",
|
|
1281
|
+
"service"
|
|
1282
|
+
]),
|
|
1283
|
+
id: IdSchema
|
|
1284
|
+
}).strict();
|
|
1285
|
+
CredentialLifecycleSchema = {
|
|
1286
|
+
id: IdSchema.optional(),
|
|
1287
|
+
issuedAt: z2.number().int().nonnegative().optional(),
|
|
1288
|
+
expiresAt: z2.number().int().nonnegative().optional()
|
|
1289
|
+
};
|
|
1290
|
+
GeneralCredentialDescriptorSchema = z2.object({
|
|
1291
|
+
type: z2.enum([
|
|
1292
|
+
"firstPartySession",
|
|
1293
|
+
"apiKey",
|
|
1294
|
+
"endUserSession",
|
|
1295
|
+
"staffAssertion",
|
|
1296
|
+
"serviceCredential",
|
|
1297
|
+
"legacyInternalToken"
|
|
1298
|
+
]),
|
|
1299
|
+
...CredentialLifecycleSchema
|
|
1300
|
+
}).strict();
|
|
1301
|
+
DeviceCredentialDescriptorSchema = z2.object({
|
|
1302
|
+
type: z2.literal("deviceCredential"),
|
|
1303
|
+
id: IdSchema,
|
|
1304
|
+
issuedAt: z2.number().int().nonnegative().optional(),
|
|
1305
|
+
expiresAt: z2.number().int().nonnegative().optional(),
|
|
1306
|
+
secretVersion: z2.number().int().positive(),
|
|
1307
|
+
device: DeviceBindingSchema
|
|
1308
|
+
}).strict();
|
|
1309
|
+
GeneralPrincipalContextSchema = z2.object({
|
|
1310
|
+
version: z2.literal(1),
|
|
1311
|
+
subject: PrincipalDescriptorSchema,
|
|
1312
|
+
actor: ActorDescriptorSchema.optional(),
|
|
1313
|
+
credential: GeneralCredentialDescriptorSchema,
|
|
1314
|
+
owner: PrincipalOwnerSchema.optional(),
|
|
1315
|
+
compatibility: z2.object({
|
|
1316
|
+
mode: z2.literal("legacy-owner-delegation")
|
|
1317
|
+
}).strict().optional()
|
|
1318
|
+
}).strict();
|
|
1319
|
+
DeviceCredentialPrincipalContextSchema = z2.object({
|
|
1157
1320
|
version: z2.literal(1),
|
|
1158
1321
|
subject: z2.object({
|
|
1159
|
-
subjectType:
|
|
1160
|
-
subjectId:
|
|
1322
|
+
subjectType: z2.literal("apiKey"),
|
|
1323
|
+
subjectId: IdSchema
|
|
1161
1324
|
}).strict(),
|
|
1162
1325
|
actor: z2.object({
|
|
1163
|
-
actorType:
|
|
1164
|
-
actorId:
|
|
1165
|
-
}).strict().optional(),
|
|
1166
|
-
credential: z2.object({
|
|
1167
|
-
type: CredentialTypeSchema,
|
|
1168
|
-
id: z2.string().min(1).max(256).optional(),
|
|
1169
|
-
issuedAt: z2.number().int().nonnegative().optional(),
|
|
1170
|
-
expiresAt: z2.number().int().nonnegative().optional()
|
|
1326
|
+
actorType: z2.literal("apiKey"),
|
|
1327
|
+
actorId: IdSchema
|
|
1171
1328
|
}).strict(),
|
|
1329
|
+
credential: DeviceCredentialDescriptorSchema,
|
|
1172
1330
|
owner: z2.object({
|
|
1173
|
-
type: z2.
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1331
|
+
type: z2.literal("user"),
|
|
1332
|
+
id: IdSchema
|
|
1333
|
+
}).strict()
|
|
1334
|
+
}).strict().superRefine((context, refinement) => {
|
|
1335
|
+
const credentialId = context.credential.id;
|
|
1336
|
+
if (context.subject.subjectId !== credentialId) {
|
|
1337
|
+
refinement.addIssue({
|
|
1338
|
+
code: z2.ZodIssueCode.custom,
|
|
1339
|
+
path: [
|
|
1340
|
+
"subject",
|
|
1341
|
+
"subjectId"
|
|
1342
|
+
],
|
|
1343
|
+
message: "Device credential subject must match its credential id"
|
|
1344
|
+
});
|
|
1345
|
+
}
|
|
1346
|
+
if (context.actor.actorId !== credentialId) {
|
|
1347
|
+
refinement.addIssue({
|
|
1348
|
+
code: z2.ZodIssueCode.custom,
|
|
1349
|
+
path: [
|
|
1350
|
+
"actor",
|
|
1351
|
+
"actorId"
|
|
1352
|
+
],
|
|
1353
|
+
message: "Device credential actor must match its credential id"
|
|
1354
|
+
});
|
|
1355
|
+
}
|
|
1356
|
+
});
|
|
1357
|
+
RawPrincipalContextSchema = z2.union([
|
|
1358
|
+
DeviceCredentialPrincipalContextSchema,
|
|
1359
|
+
GeneralPrincipalContextSchema
|
|
1360
|
+
]);
|
|
1361
|
+
PrincipalContextSchema = z2.custom((value) => RawPrincipalContextSchema.safeParse(value).success, "Invalid principal context");
|
|
1184
1362
|
__name(parsePrincipalContext, "parsePrincipalContext");
|
|
1185
1363
|
__name2(parsePrincipalContext, "parsePrincipalContext");
|
|
1364
|
+
__name(isDeviceCredentialPrincipal, "isDeviceCredentialPrincipal");
|
|
1365
|
+
__name2(isDeviceCredentialPrincipal, "isDeviceCredentialPrincipal");
|
|
1366
|
+
DeviceCredentialClaimSchema = z2.object({
|
|
1367
|
+
credential: z2.object({
|
|
1368
|
+
type: z2.literal("deviceCredential")
|
|
1369
|
+
}).passthrough()
|
|
1370
|
+
}).passthrough();
|
|
1371
|
+
__name(hasDeviceCredentialType, "hasDeviceCredentialType");
|
|
1372
|
+
__name2(hasDeviceCredentialType, "hasDeviceCredentialType");
|
|
1186
1373
|
__name(isTypedApiKeyPrincipal, "isTypedApiKeyPrincipal");
|
|
1187
1374
|
__name2(isTypedApiKeyPrincipal, "isTypedApiKeyPrincipal");
|
|
1188
1375
|
__name(typedApiKeyPrincipalId, "typedApiKeyPrincipalId");
|
|
@@ -1196,7 +1383,10 @@ This text is who you are for this person. As you learn them, their name, their w
|
|
|
1196
1383
|
"claude-plugin",
|
|
1197
1384
|
"codex-plugin",
|
|
1198
1385
|
"cursor-plugin",
|
|
1199
|
-
"platform-mcp"
|
|
1386
|
+
"platform-mcp",
|
|
1387
|
+
"device-node",
|
|
1388
|
+
"device-python",
|
|
1389
|
+
"device-micropython"
|
|
1200
1390
|
];
|
|
1201
1391
|
SEMVER_PATTERN = /^(\d{1,3}\.\d{1,3}\.\d{1,3})(?:-[0-9A-Za-z.-]{1,16})?(?:\+[0-9A-Za-z.-]{1,16})?$/;
|
|
1202
1392
|
WEB_RELEASE_PATTERN = /^[0-9a-f]{12}$/i;
|
|
@@ -1499,30 +1689,429 @@ var init_lua_fetch = __esm({
|
|
|
1499
1689
|
}
|
|
1500
1690
|
});
|
|
1501
1691
|
|
|
1692
|
+
// src/services/firebase-session.ts
|
|
1693
|
+
import { z as z4 } from "zod";
|
|
1694
|
+
function requireFirebaseWebApiKey() {
|
|
1695
|
+
if (!FIREBASE_WEB_API_KEY) {
|
|
1696
|
+
throw new Error("Firebase sign-in is not configured for this CLI build.");
|
|
1697
|
+
}
|
|
1698
|
+
return FIREBASE_WEB_API_KEY;
|
|
1699
|
+
}
|
|
1700
|
+
function uidFromFirebaseIdToken(idToken) {
|
|
1701
|
+
const segments = idToken.split(".");
|
|
1702
|
+
if (segments.length !== 3 || !segments[1]) throw new Error(INVALID_FIREBASE_SESSION);
|
|
1703
|
+
let payload;
|
|
1704
|
+
try {
|
|
1705
|
+
payload = JSON.parse(Buffer.from(segments[1], "base64url").toString("utf8"));
|
|
1706
|
+
} catch {
|
|
1707
|
+
throw new Error(INVALID_FIREBASE_SESSION);
|
|
1708
|
+
}
|
|
1709
|
+
const parsed = firebaseIdTokenPayloadSchema.safeParse(payload);
|
|
1710
|
+
if (parsed.success) return parsed.data.sub;
|
|
1711
|
+
throw new Error(INVALID_FIREBASE_SESSION);
|
|
1712
|
+
}
|
|
1713
|
+
function parseFirebaseSession(json, now = Date.now()) {
|
|
1714
|
+
const customTokenResponse = customTokenResponseSchema.safeParse(json);
|
|
1715
|
+
if (customTokenResponse.success) {
|
|
1716
|
+
const { idToken: idToken2, refreshToken: refreshToken2, expiresIn: expiresIn2, localId } = customTokenResponse.data;
|
|
1717
|
+
return {
|
|
1718
|
+
idToken: idToken2,
|
|
1719
|
+
refreshToken: refreshToken2,
|
|
1720
|
+
expiresAt: now + expiresIn2 * 1e3,
|
|
1721
|
+
uid: localId ?? uidFromFirebaseIdToken(idToken2)
|
|
1722
|
+
};
|
|
1723
|
+
}
|
|
1724
|
+
const refreshResponse = refreshResponseSchema.safeParse(json);
|
|
1725
|
+
if (!refreshResponse.success) throw new Error(INVALID_FIREBASE_SESSION);
|
|
1726
|
+
const { id_token: idToken, refresh_token: refreshToken, expires_in: expiresIn, user_id: uid } = refreshResponse.data;
|
|
1727
|
+
return {
|
|
1728
|
+
idToken,
|
|
1729
|
+
refreshToken,
|
|
1730
|
+
expiresAt: now + expiresIn * 1e3,
|
|
1731
|
+
uid
|
|
1732
|
+
};
|
|
1733
|
+
}
|
|
1734
|
+
async function parseFirebaseError(response) {
|
|
1735
|
+
try {
|
|
1736
|
+
const body = await response.json();
|
|
1737
|
+
const message = body.error?.message;
|
|
1738
|
+
return typeof message === "string" && message ? message.split(":")[0].trim() : response.statusText;
|
|
1739
|
+
} catch {
|
|
1740
|
+
return response.statusText;
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
async function fetchFirebase(url, init, timeoutMessage) {
|
|
1744
|
+
const controller = new AbortController();
|
|
1745
|
+
let timeoutId;
|
|
1746
|
+
const timeout = new Promise((_resolve, reject) => {
|
|
1747
|
+
timeoutId = setTimeout(() => {
|
|
1748
|
+
reject(new Error(timeoutMessage));
|
|
1749
|
+
controller.abort();
|
|
1750
|
+
}, FIREBASE_REQUEST_TIMEOUT_MS);
|
|
1751
|
+
});
|
|
1752
|
+
try {
|
|
1753
|
+
return await Promise.race([
|
|
1754
|
+
fetch(url, {
|
|
1755
|
+
...init,
|
|
1756
|
+
signal: controller.signal
|
|
1757
|
+
}),
|
|
1758
|
+
timeout
|
|
1759
|
+
]);
|
|
1760
|
+
} finally {
|
|
1761
|
+
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
async function refreshFirebaseSession(session) {
|
|
1765
|
+
const key = requireFirebaseWebApiKey();
|
|
1766
|
+
const response = await fetchFirebase(`${FIREBASE_REFRESH_URL}?key=${encodeURIComponent(key)}`, {
|
|
1767
|
+
method: "POST",
|
|
1768
|
+
headers: {
|
|
1769
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
1770
|
+
},
|
|
1771
|
+
body: new URLSearchParams({
|
|
1772
|
+
grant_type: "refresh_token",
|
|
1773
|
+
refresh_token: session.refreshToken
|
|
1774
|
+
}).toString()
|
|
1775
|
+
}, "Firebase session refresh timed out after 15 seconds.");
|
|
1776
|
+
if (!response.ok) {
|
|
1777
|
+
throw new Error(`Firebase session refresh failed: ${await parseFirebaseError(response)}`);
|
|
1778
|
+
}
|
|
1779
|
+
const refreshed = parseFirebaseSession(await response.json());
|
|
1780
|
+
if (refreshed.uid !== session.uid) throw new Error("Firebase session refresh returned a different identity.");
|
|
1781
|
+
return refreshed;
|
|
1782
|
+
}
|
|
1783
|
+
var FIREBASE_REFRESH_URL, FIREBASE_REQUEST_TIMEOUT_MS, INVALID_FIREBASE_SESSION, customTokenResponseSchema, refreshResponseSchema, firebaseIdTokenPayloadSchema;
|
|
1784
|
+
var init_firebase_session = __esm({
|
|
1785
|
+
"src/services/firebase-session.ts"() {
|
|
1786
|
+
"use strict";
|
|
1787
|
+
init_constants();
|
|
1788
|
+
FIREBASE_REFRESH_URL = "https://securetoken.googleapis.com/v1/token";
|
|
1789
|
+
FIREBASE_REQUEST_TIMEOUT_MS = 15e3;
|
|
1790
|
+
INVALID_FIREBASE_SESSION = "Sign-in failed because Firebase returned an invalid session.";
|
|
1791
|
+
customTokenResponseSchema = z4.object({
|
|
1792
|
+
idToken: z4.string().min(1),
|
|
1793
|
+
refreshToken: z4.string().min(1),
|
|
1794
|
+
expiresIn: z4.coerce.number().positive().finite(),
|
|
1795
|
+
localId: z4.string().min(1).optional()
|
|
1796
|
+
});
|
|
1797
|
+
refreshResponseSchema = z4.object({
|
|
1798
|
+
id_token: z4.string().min(1),
|
|
1799
|
+
refresh_token: z4.string().min(1),
|
|
1800
|
+
expires_in: z4.coerce.number().positive().finite(),
|
|
1801
|
+
user_id: z4.string().min(1)
|
|
1802
|
+
});
|
|
1803
|
+
firebaseIdTokenPayloadSchema = z4.object({
|
|
1804
|
+
sub: z4.string().min(1)
|
|
1805
|
+
});
|
|
1806
|
+
__name(requireFirebaseWebApiKey, "requireFirebaseWebApiKey");
|
|
1807
|
+
__name(uidFromFirebaseIdToken, "uidFromFirebaseIdToken");
|
|
1808
|
+
__name(parseFirebaseSession, "parseFirebaseSession");
|
|
1809
|
+
__name(parseFirebaseError, "parseFirebaseError");
|
|
1810
|
+
__name(fetchFirebase, "fetchFirebase");
|
|
1811
|
+
__name(refreshFirebaseSession, "refreshFirebaseSession");
|
|
1812
|
+
}
|
|
1813
|
+
});
|
|
1814
|
+
|
|
1815
|
+
// src/services/firebase-session-store.ts
|
|
1816
|
+
import { createHash, randomUUID } from "crypto";
|
|
1817
|
+
import { mkdir, open, readFile, rename, unlink } from "fs/promises";
|
|
1818
|
+
import { join as join3 } from "path";
|
|
1819
|
+
import { z as z5 } from "zod";
|
|
1820
|
+
function environmentKey(environment) {
|
|
1821
|
+
return createHash("sha256").update(`${environment.apiUrl}
|
|
1822
|
+
${environment.authUrl}
|
|
1823
|
+
${environment.firebaseWebApiKey}`).digest("hex").slice(0, 16);
|
|
1824
|
+
}
|
|
1825
|
+
function isMissing(error) {
|
|
1826
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
1827
|
+
}
|
|
1828
|
+
var storedFirebaseSessionSchema, currentFirebaseSessionEnvironment, wait, FirebaseSessionStore;
|
|
1829
|
+
var init_firebase_session_store = __esm({
|
|
1830
|
+
"src/services/firebase-session-store.ts"() {
|
|
1831
|
+
"use strict";
|
|
1832
|
+
init_constants();
|
|
1833
|
+
storedFirebaseSessionSchema = z5.object({
|
|
1834
|
+
version: z5.literal(1),
|
|
1835
|
+
kind: z5.literal("firebase-session"),
|
|
1836
|
+
generation: z5.string().min(1),
|
|
1837
|
+
refreshToken: z5.string().min(1),
|
|
1838
|
+
firebaseUid: z5.string().min(1),
|
|
1839
|
+
apiUrl: z5.string().url(),
|
|
1840
|
+
authUrl: z5.string().url(),
|
|
1841
|
+
firebaseWebApiKey: z5.string().min(1)
|
|
1842
|
+
});
|
|
1843
|
+
currentFirebaseSessionEnvironment = /* @__PURE__ */ __name(() => ({
|
|
1844
|
+
apiUrl: BASE_URLS.API,
|
|
1845
|
+
authUrl: BASE_URLS.AUTH,
|
|
1846
|
+
firebaseWebApiKey: FIREBASE_WEB_API_KEY
|
|
1847
|
+
}), "currentFirebaseSessionEnvironment");
|
|
1848
|
+
__name(environmentKey, "environmentKey");
|
|
1849
|
+
__name(isMissing, "isMissing");
|
|
1850
|
+
wait = /* @__PURE__ */ __name((milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds)), "wait");
|
|
1851
|
+
FirebaseSessionStore = class {
|
|
1852
|
+
static {
|
|
1853
|
+
__name(this, "FirebaseSessionStore");
|
|
1854
|
+
}
|
|
1855
|
+
environment;
|
|
1856
|
+
directory;
|
|
1857
|
+
constructor(root = CLI_CONFIG_DIR, environment = currentFirebaseSessionEnvironment()) {
|
|
1858
|
+
this.environment = environment;
|
|
1859
|
+
this.directory = join3(root, "sessions");
|
|
1860
|
+
}
|
|
1861
|
+
path() {
|
|
1862
|
+
return join3(this.directory, `${environmentKey(this.environment)}.json`);
|
|
1863
|
+
}
|
|
1864
|
+
async read() {
|
|
1865
|
+
let raw;
|
|
1866
|
+
try {
|
|
1867
|
+
raw = await readFile(this.path(), "utf8");
|
|
1868
|
+
} catch (error) {
|
|
1869
|
+
if (isMissing(error)) return null;
|
|
1870
|
+
throw error;
|
|
1871
|
+
}
|
|
1872
|
+
let decoded;
|
|
1873
|
+
try {
|
|
1874
|
+
decoded = JSON.parse(raw);
|
|
1875
|
+
} catch {
|
|
1876
|
+
throw new Error("The stored Lua CLI session is invalid. Run `lua auth configure` again.");
|
|
1877
|
+
}
|
|
1878
|
+
const parsed = storedFirebaseSessionSchema.safeParse(decoded);
|
|
1879
|
+
if (!parsed.success) throw new Error("The stored Lua CLI session is invalid. Run `lua auth configure` again.");
|
|
1880
|
+
if (parsed.data.apiUrl !== this.environment.apiUrl || parsed.data.authUrl !== this.environment.authUrl || parsed.data.firebaseWebApiKey !== this.environment.firebaseWebApiKey) {
|
|
1881
|
+
throw new Error("The stored Lua CLI session belongs to a different environment.");
|
|
1882
|
+
}
|
|
1883
|
+
return parsed.data;
|
|
1884
|
+
}
|
|
1885
|
+
async replace(session) {
|
|
1886
|
+
storedFirebaseSessionSchema.parse(session);
|
|
1887
|
+
if (session.apiUrl !== this.environment.apiUrl || session.authUrl !== this.environment.authUrl || session.firebaseWebApiKey !== this.environment.firebaseWebApiKey) {
|
|
1888
|
+
throw new Error("Cannot store a Lua CLI session for a different environment.");
|
|
1889
|
+
}
|
|
1890
|
+
await this.withLock(async () => this.write(session));
|
|
1891
|
+
}
|
|
1892
|
+
async update(operation) {
|
|
1893
|
+
return this.withLock(async () => {
|
|
1894
|
+
const next = await operation(await this.read());
|
|
1895
|
+
if (next) await this.write(next);
|
|
1896
|
+
else await this.remove();
|
|
1897
|
+
return next;
|
|
1898
|
+
});
|
|
1899
|
+
}
|
|
1900
|
+
async clearIfGeneration(generation) {
|
|
1901
|
+
let cleared = false;
|
|
1902
|
+
await this.update(async (current) => {
|
|
1903
|
+
if (!current || current.generation !== generation) return current;
|
|
1904
|
+
cleared = true;
|
|
1905
|
+
return null;
|
|
1906
|
+
});
|
|
1907
|
+
return cleared;
|
|
1908
|
+
}
|
|
1909
|
+
async write(session) {
|
|
1910
|
+
await mkdir(this.directory, {
|
|
1911
|
+
recursive: true,
|
|
1912
|
+
mode: 448
|
|
1913
|
+
});
|
|
1914
|
+
const temporaryPath = join3(this.directory, `.${environmentKey(this.environment)}.${randomUUID()}.tmp`);
|
|
1915
|
+
const handle = await open(temporaryPath, "wx", 384);
|
|
1916
|
+
try {
|
|
1917
|
+
await handle.writeFile(`${JSON.stringify(session)}
|
|
1918
|
+
`, "utf8");
|
|
1919
|
+
await handle.sync();
|
|
1920
|
+
} finally {
|
|
1921
|
+
await handle.close();
|
|
1922
|
+
}
|
|
1923
|
+
await rename(temporaryPath, this.path());
|
|
1924
|
+
}
|
|
1925
|
+
async remove() {
|
|
1926
|
+
try {
|
|
1927
|
+
await unlink(this.path());
|
|
1928
|
+
} catch (error) {
|
|
1929
|
+
if (!isMissing(error)) throw error;
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
async withLock(operation) {
|
|
1933
|
+
await mkdir(this.directory, {
|
|
1934
|
+
recursive: true,
|
|
1935
|
+
mode: 448
|
|
1936
|
+
});
|
|
1937
|
+
const lockPath = `${this.path()}.lock`;
|
|
1938
|
+
const lockOwner = randomUUID();
|
|
1939
|
+
const deadline = Date.now() + 2e4;
|
|
1940
|
+
while (true) {
|
|
1941
|
+
try {
|
|
1942
|
+
const handle = await open(lockPath, "wx", 384);
|
|
1943
|
+
try {
|
|
1944
|
+
await handle.writeFile(lockOwner, "utf8");
|
|
1945
|
+
await handle.sync();
|
|
1946
|
+
} finally {
|
|
1947
|
+
await handle.close();
|
|
1948
|
+
}
|
|
1949
|
+
break;
|
|
1950
|
+
} catch (error) {
|
|
1951
|
+
const code = typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
|
|
1952
|
+
if (code !== "EEXIST") throw error;
|
|
1953
|
+
if (Date.now() >= deadline) {
|
|
1954
|
+
throw new Error("Timed out waiting for another Lua CLI process to finish updating the session.");
|
|
1955
|
+
}
|
|
1956
|
+
await wait(50);
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
try {
|
|
1960
|
+
return await operation();
|
|
1961
|
+
} finally {
|
|
1962
|
+
try {
|
|
1963
|
+
if (await readFile(lockPath, "utf8") === lockOwner) await unlink(lockPath);
|
|
1964
|
+
} catch (error) {
|
|
1965
|
+
if (!isMissing(error)) throw error;
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
};
|
|
1970
|
+
}
|
|
1971
|
+
});
|
|
1972
|
+
|
|
1973
|
+
// src/services/request-credential.ts
|
|
1974
|
+
import "dotenv/config";
|
|
1975
|
+
import { readFileSync as readFileSync2, unlinkSync } from "fs";
|
|
1976
|
+
function loadStoredApiKey() {
|
|
1977
|
+
try {
|
|
1978
|
+
return readFileSync2(CREDENTIALS_FILE, "utf8").trim() || null;
|
|
1979
|
+
} catch {
|
|
1980
|
+
return null;
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
function isRequestCredential(value) {
|
|
1984
|
+
return typeof value !== "string";
|
|
1985
|
+
}
|
|
1986
|
+
async function bearerFor(credential) {
|
|
1987
|
+
return isRequestCredential(credential) ? credential.bearer() : credential;
|
|
1988
|
+
}
|
|
1989
|
+
async function resolveRequestCredential() {
|
|
1990
|
+
if (process.env.LUA_API_KEY) return new StaticRequestCredential(process.env.LUA_API_KEY, "environment");
|
|
1991
|
+
const store = new FirebaseSessionStore();
|
|
1992
|
+
const session = await store.read();
|
|
1993
|
+
if (session) return new FirebaseRequestCredential(store, session);
|
|
1994
|
+
const storedApiKey = loadStoredApiKey();
|
|
1995
|
+
if (storedApiKey) return new StaticRequestCredential(storedApiKey, "stored");
|
|
1996
|
+
throw new AuthenticationError("No Lua CLI authentication found. Run `lua auth configure` or set LUA_API_KEY.", "invalid_credentials", void 0, true);
|
|
1997
|
+
}
|
|
1998
|
+
var StaticRequestCredential, FirebaseRequestCredential;
|
|
1999
|
+
var init_request_credential = __esm({
|
|
2000
|
+
"src/services/request-credential.ts"() {
|
|
2001
|
+
"use strict";
|
|
2002
|
+
init_constants();
|
|
2003
|
+
init_auth_error();
|
|
2004
|
+
init_lua_fetch();
|
|
2005
|
+
init_firebase_session();
|
|
2006
|
+
init_firebase_session_store();
|
|
2007
|
+
__name(loadStoredApiKey, "loadStoredApiKey");
|
|
2008
|
+
__name(isRequestCredential, "isRequestCredential");
|
|
2009
|
+
__name(bearerFor, "bearerFor");
|
|
2010
|
+
StaticRequestCredential = class StaticRequestCredential2 {
|
|
2011
|
+
static {
|
|
2012
|
+
__name(this, "StaticRequestCredential");
|
|
2013
|
+
}
|
|
2014
|
+
apiKey;
|
|
2015
|
+
descriptor;
|
|
2016
|
+
constructor(apiKey, source) {
|
|
2017
|
+
this.apiKey = apiKey;
|
|
2018
|
+
this.descriptor = {
|
|
2019
|
+
kind: "api-key",
|
|
2020
|
+
source
|
|
2021
|
+
};
|
|
2022
|
+
}
|
|
2023
|
+
async bearer() {
|
|
2024
|
+
return this.apiKey;
|
|
2025
|
+
}
|
|
2026
|
+
};
|
|
2027
|
+
FirebaseRequestCredential = class FirebaseRequestCredential2 {
|
|
2028
|
+
static {
|
|
2029
|
+
__name(this, "FirebaseRequestCredential");
|
|
2030
|
+
}
|
|
2031
|
+
store;
|
|
2032
|
+
descriptor;
|
|
2033
|
+
liveSession;
|
|
2034
|
+
refresh;
|
|
2035
|
+
constructor(store, stored) {
|
|
2036
|
+
this.store = store;
|
|
2037
|
+
this.descriptor = {
|
|
2038
|
+
kind: "first-party-session",
|
|
2039
|
+
source: "stored",
|
|
2040
|
+
uid: stored.firebaseUid
|
|
2041
|
+
};
|
|
2042
|
+
}
|
|
2043
|
+
async bearer() {
|
|
2044
|
+
if (this.liveSession && this.liveSession.expiresAt - Date.now() > 6e4) return this.liveSession.idToken;
|
|
2045
|
+
if (!this.refresh) this.refresh = this.refreshBearer().finally(() => this.refresh = void 0);
|
|
2046
|
+
return this.refresh;
|
|
2047
|
+
}
|
|
2048
|
+
async refreshBearer() {
|
|
2049
|
+
let live;
|
|
2050
|
+
await this.store.update(async (stored) => {
|
|
2051
|
+
if (!stored) {
|
|
2052
|
+
throw new AuthenticationError("Your Lua CLI session has expired. Run `lua auth configure`.", "invalid_credentials");
|
|
2053
|
+
}
|
|
2054
|
+
live = await refreshFirebaseSession({
|
|
2055
|
+
idToken: "",
|
|
2056
|
+
refreshToken: stored.refreshToken,
|
|
2057
|
+
expiresAt: 0,
|
|
2058
|
+
uid: stored.firebaseUid
|
|
2059
|
+
});
|
|
2060
|
+
return {
|
|
2061
|
+
...stored,
|
|
2062
|
+
refreshToken: live.refreshToken,
|
|
2063
|
+
firebaseUid: live.uid
|
|
2064
|
+
};
|
|
2065
|
+
});
|
|
2066
|
+
if (!live) throw new Error("Firebase session refresh did not return a session.");
|
|
2067
|
+
this.liveSession = live;
|
|
2068
|
+
return live.idToken;
|
|
2069
|
+
}
|
|
2070
|
+
};
|
|
2071
|
+
__name(resolveRequestCredential, "resolveRequestCredential");
|
|
2072
|
+
}
|
|
2073
|
+
});
|
|
2074
|
+
|
|
1502
2075
|
// src/api/http.client.ts
|
|
1503
|
-
import { randomUUID } from "crypto";
|
|
2076
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
1504
2077
|
function parseRetryAfter(raw) {
|
|
1505
2078
|
if (!raw) return void 0;
|
|
1506
2079
|
const seconds = Number.parseInt(raw, 10);
|
|
1507
|
-
return Number.isFinite(seconds) && seconds
|
|
2080
|
+
return Number.isFinite(seconds) && seconds >= 0 ? seconds : void 0;
|
|
2081
|
+
}
|
|
2082
|
+
function isCoreDrainApiError(error) {
|
|
2083
|
+
if (!error || error.statusCode !== 503) return false;
|
|
2084
|
+
return isCoreDrainingErrorResponse({
|
|
2085
|
+
error: error.error
|
|
2086
|
+
});
|
|
2087
|
+
}
|
|
2088
|
+
function coreDrainApiRetryDelayMs(error) {
|
|
2089
|
+
const retryAfterSeconds = error?.retryAfterSeconds;
|
|
2090
|
+
if (retryAfterSeconds === void 0) return CORE_DRAINING_DEFAULT_RETRY_MS;
|
|
2091
|
+
const delayMs = retryAfterSeconds * 1e3;
|
|
2092
|
+
return Math.min(Math.max(0, delayMs), CORE_DRAINING_MAX_RETRY_MS);
|
|
1508
2093
|
}
|
|
1509
2094
|
var HttpClient;
|
|
1510
2095
|
var init_http_client = __esm({
|
|
1511
2096
|
"src/api/http.client.ts"() {
|
|
1512
2097
|
"use strict";
|
|
2098
|
+
init_dist();
|
|
1513
2099
|
init_auth_error();
|
|
1514
2100
|
init_lua_fetch();
|
|
2101
|
+
init_request_credential();
|
|
1515
2102
|
HttpClient = class {
|
|
1516
2103
|
static {
|
|
1517
2104
|
__name(this, "HttpClient");
|
|
1518
2105
|
}
|
|
1519
2106
|
baseUrl;
|
|
2107
|
+
requestCredential;
|
|
1520
2108
|
/**
|
|
1521
2109
|
* Creates an instance of HttpClient
|
|
1522
2110
|
* @param baseUrl - The base URL for all API requests
|
|
1523
2111
|
*/
|
|
1524
|
-
constructor(baseUrl) {
|
|
2112
|
+
constructor(baseUrl, requestCredential) {
|
|
1525
2113
|
this.baseUrl = baseUrl;
|
|
2114
|
+
this.requestCredential = requestCredential;
|
|
1526
2115
|
}
|
|
1527
2116
|
/**
|
|
1528
2117
|
* Makes an HTTP request with standardized error handling
|
|
@@ -1535,12 +2124,16 @@ var init_http_client = __esm({
|
|
|
1535
2124
|
const controller = new AbortController();
|
|
1536
2125
|
const timeoutId = setTimeout(() => controller.abort(), 3e4);
|
|
1537
2126
|
try {
|
|
2127
|
+
const authorization = this.requestCredential ? `Bearer ${await bearerFor(this.requestCredential)}` : void 0;
|
|
1538
2128
|
const response = await luaFetch(url, {
|
|
1539
2129
|
...options,
|
|
1540
2130
|
signal: controller.signal,
|
|
1541
2131
|
headers: {
|
|
1542
2132
|
"Content-Type": "application/json",
|
|
1543
|
-
...options.headers
|
|
2133
|
+
...options.headers,
|
|
2134
|
+
...authorization ? {
|
|
2135
|
+
Authorization: authorization
|
|
2136
|
+
} : {}
|
|
1544
2137
|
}
|
|
1545
2138
|
});
|
|
1546
2139
|
clearTimeout(timeoutId);
|
|
@@ -1559,14 +2152,14 @@ var init_http_client = __esm({
|
|
|
1559
2152
|
const isExplicitCredential = !!serverMessage && /(invalid|expired|missing|no)\s+(api[\s_-]?key|token|credential)/i.test(serverMessage);
|
|
1560
2153
|
const isBareAuthRejection = !serverMessage || /^unauthorized$/i.test(serverMessage);
|
|
1561
2154
|
if (isExplicitCredential || isBareAuthRejection) {
|
|
1562
|
-
throw new AuthenticationError("Authentication failed. Your
|
|
2155
|
+
throw new AuthenticationError("Authentication failed. Your Lua credential may be invalid or expired.", "invalid_credentials", serverMessage);
|
|
1563
2156
|
}
|
|
1564
2157
|
throw new AuthenticationError(`Authentication failed: ${serverMessage}`, "unknown", serverMessage);
|
|
1565
2158
|
}
|
|
1566
2159
|
if (response.status === 403) {
|
|
1567
2160
|
const detail = errorData.message || "You do not have permission to access this resource.";
|
|
1568
2161
|
throw new Error(`Access denied (403): ${detail}
|
|
1569
|
-
Check that your
|
|
2162
|
+
Check that your Lua login has access to this agent or organization.`);
|
|
1570
2163
|
}
|
|
1571
2164
|
return {
|
|
1572
2165
|
success: false,
|
|
@@ -1651,7 +2244,7 @@ Check that your API key has access to this agent/organization.`);
|
|
|
1651
2244
|
if (options.method === "POST") {
|
|
1652
2245
|
const headers = options.headers || {};
|
|
1653
2246
|
if (!headers["X-Idempotency-Key"]) {
|
|
1654
|
-
headers["X-Idempotency-Key"] =
|
|
2247
|
+
headers["X-Idempotency-Key"] = randomUUID2();
|
|
1655
2248
|
options = {
|
|
1656
2249
|
...options,
|
|
1657
2250
|
headers: {
|
|
@@ -1721,6 +2314,12 @@ Check that your API key has access to this agent/organization.`);
|
|
|
1721
2314
|
headers
|
|
1722
2315
|
}, 0);
|
|
1723
2316
|
}
|
|
2317
|
+
async httpPostCoreDrainRetry(url, data, headers) {
|
|
2318
|
+
const first = await this.httpPostOnce(url, data, headers);
|
|
2319
|
+
if (!isCoreDrainApiError(first.error)) return first;
|
|
2320
|
+
await new Promise((resolve) => setTimeout(resolve, coreDrainApiRetryDelayMs(first.error)));
|
|
2321
|
+
return this.httpPostOnce(url, data, headers);
|
|
2322
|
+
}
|
|
1724
2323
|
/**
|
|
1725
2324
|
* Performs an HTTP PUT request
|
|
1726
2325
|
* @param url - The relative URL path to request (will be appended to baseUrl)
|
|
@@ -1766,6 +2365,8 @@ Check that your API key has access to this agent/organization.`);
|
|
|
1766
2365
|
}
|
|
1767
2366
|
};
|
|
1768
2367
|
__name(parseRetryAfter, "parseRetryAfter");
|
|
2368
|
+
__name(isCoreDrainApiError, "isCoreDrainApiError");
|
|
2369
|
+
__name(coreDrainApiRetryDelayMs, "coreDrainApiRetryDelayMs");
|
|
1769
2370
|
}
|
|
1770
2371
|
});
|
|
1771
2372
|
|
|
@@ -1779,25 +2380,12 @@ var init_auth_api_service = __esm({
|
|
|
1779
2380
|
|
|
1780
2381
|
// src/services/auth.ts
|
|
1781
2382
|
import "dotenv/config";
|
|
1782
|
-
import { readFileSync as readFileSync2, writeFileSync, mkdirSync, unlinkSync } from "fs";
|
|
1783
|
-
function getToken() {
|
|
1784
|
-
if (process.env.LUA_API_KEY) {
|
|
1785
|
-
return process.env.LUA_API_KEY;
|
|
1786
|
-
}
|
|
1787
|
-
try {
|
|
1788
|
-
const token = readFileSync2(CREDENTIALS_FILE, "utf8").trim();
|
|
1789
|
-
if (token) return token;
|
|
1790
|
-
} catch {
|
|
1791
|
-
}
|
|
1792
|
-
throw new AuthenticationError('No API key found.\n\n Authenticate using one of these methods:\n\n \u279C lua auth configure\n \u279C export LUA_API_KEY="your-api-key-here"\n \u279C Add LUA_API_KEY=... to a .env file\n\n \u{1F511} Get your API key at https://admin.heylua.ai', "invalid_credentials", void 0, true);
|
|
1793
|
-
}
|
|
1794
2383
|
var init_auth = __esm({
|
|
1795
2384
|
"src/services/auth.ts"() {
|
|
1796
2385
|
"use strict";
|
|
1797
2386
|
init_auth_api_service();
|
|
1798
2387
|
init_constants();
|
|
1799
2388
|
init_auth_error();
|
|
1800
|
-
__name(getToken, "getToken");
|
|
1801
2389
|
}
|
|
1802
2390
|
});
|
|
1803
2391
|
|
|
@@ -1869,17 +2457,15 @@ var init_skills_api_service = __esm({
|
|
|
1869
2457
|
static {
|
|
1870
2458
|
__name(this, "SkillApi");
|
|
1871
2459
|
}
|
|
1872
|
-
apiKey;
|
|
1873
2460
|
agentId;
|
|
1874
2461
|
/**
|
|
1875
2462
|
* Creates an instance of SkillApi
|
|
1876
2463
|
* @param baseUrl - The base URL for the API
|
|
1877
|
-
* @param
|
|
2464
|
+
* @param credential - The API key for authentication
|
|
1878
2465
|
* @param agentId - The unique identifier of the agent
|
|
1879
2466
|
*/
|
|
1880
|
-
constructor(baseUrl,
|
|
1881
|
-
super(baseUrl);
|
|
1882
|
-
this.apiKey = apiKey;
|
|
2467
|
+
constructor(baseUrl, credential, agentId) {
|
|
2468
|
+
super(baseUrl, credential);
|
|
1883
2469
|
this.agentId = agentId;
|
|
1884
2470
|
}
|
|
1885
2471
|
/**
|
|
@@ -1888,9 +2474,7 @@ var init_skills_api_service = __esm({
|
|
|
1888
2474
|
* @throws Error if the API request fails or the agent is not found
|
|
1889
2475
|
*/
|
|
1890
2476
|
async getSkills() {
|
|
1891
|
-
return this.httpGet(`/developer/skills/${this.agentId}`, {
|
|
1892
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
1893
|
-
});
|
|
2477
|
+
return this.httpGet(`/developer/skills/${this.agentId}`, {});
|
|
1894
2478
|
}
|
|
1895
2479
|
/**
|
|
1896
2480
|
* Creates a new skill for the agent
|
|
@@ -1899,9 +2483,7 @@ var init_skills_api_service = __esm({
|
|
|
1899
2483
|
* @throws Error if the skill creation fails or validation errors occur
|
|
1900
2484
|
*/
|
|
1901
2485
|
async createSkill(skillData) {
|
|
1902
|
-
return this.httpPost(`/developer/skills/${this.agentId}`, skillData, {
|
|
1903
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
1904
|
-
});
|
|
2486
|
+
return this.httpPost(`/developer/skills/${this.agentId}`, skillData, {});
|
|
1905
2487
|
}
|
|
1906
2488
|
/**
|
|
1907
2489
|
* Pushes a new version of a skill to production
|
|
@@ -1911,9 +2493,7 @@ var init_skills_api_service = __esm({
|
|
|
1911
2493
|
* @throws Error if the skill is not found or the push operation fails
|
|
1912
2494
|
*/
|
|
1913
2495
|
async pushSkill(skillId, versionData) {
|
|
1914
|
-
return this.httpPost(`/developer/skills/${this.agentId}/${skillId}/version`, versionData, {
|
|
1915
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
1916
|
-
});
|
|
2496
|
+
return this.httpPost(`/developer/skills/${this.agentId}/${skillId}/version`, versionData, {});
|
|
1917
2497
|
}
|
|
1918
2498
|
/**
|
|
1919
2499
|
* Pushes a new development/sandbox version of a skill for testing
|
|
@@ -1923,9 +2503,7 @@ var init_skills_api_service = __esm({
|
|
|
1923
2503
|
* @throws Error if the skill is not found or the push operation fails
|
|
1924
2504
|
*/
|
|
1925
2505
|
async pushDevSkill(skillId, versionData) {
|
|
1926
|
-
return this.httpPost(`/developer/skills/${this.agentId}/${skillId}/version/sandbox`, versionData, {
|
|
1927
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
1928
|
-
});
|
|
2506
|
+
return this.httpPost(`/developer/skills/${this.agentId}/${skillId}/version/sandbox`, versionData, {});
|
|
1929
2507
|
}
|
|
1930
2508
|
/**
|
|
1931
2509
|
* Updates an existing development/sandbox version of a skill
|
|
@@ -1936,9 +2514,7 @@ var init_skills_api_service = __esm({
|
|
|
1936
2514
|
* @throws Error if the skill or version is not found or the update fails
|
|
1937
2515
|
*/
|
|
1938
2516
|
async updateDevSkill(skillId, sandboxVersionId, versionData) {
|
|
1939
|
-
return this.httpPut(`/developer/skills/${this.agentId}/${skillId}/version/sandbox/${sandboxVersionId}`, versionData, {
|
|
1940
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
1941
|
-
});
|
|
2517
|
+
return this.httpPut(`/developer/skills/${this.agentId}/${skillId}/version/sandbox/${sandboxVersionId}`, versionData, {});
|
|
1942
2518
|
}
|
|
1943
2519
|
/**
|
|
1944
2520
|
* Retrieves all versions of a specific skill
|
|
@@ -1947,9 +2523,7 @@ var init_skills_api_service = __esm({
|
|
|
1947
2523
|
* @throws Error if the skill is not found or the request fails
|
|
1948
2524
|
*/
|
|
1949
2525
|
async getSkillVersions(skillId) {
|
|
1950
|
-
return this.httpGet(`/developer/skills/${this.agentId}/${skillId}/versions`, {
|
|
1951
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
1952
|
-
});
|
|
2526
|
+
return this.httpGet(`/developer/skills/${this.agentId}/${skillId}/versions`, {});
|
|
1953
2527
|
}
|
|
1954
2528
|
/**
|
|
1955
2529
|
* Publishes a specific version of a skill to production
|
|
@@ -1959,9 +2533,7 @@ var init_skills_api_service = __esm({
|
|
|
1959
2533
|
* @throws Error if the skill or version is not found or the publish operation fails
|
|
1960
2534
|
*/
|
|
1961
2535
|
async publishSkillVersion(skillId, version) {
|
|
1962
|
-
return this.httpPut(`/developer/skills/${this.agentId}/${skillId}/${version}/publish`, void 0, {
|
|
1963
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
1964
|
-
});
|
|
2536
|
+
return this.httpPut(`/developer/skills/${this.agentId}/${skillId}/${version}/publish`, void 0, {});
|
|
1965
2537
|
}
|
|
1966
2538
|
/**
|
|
1967
2539
|
* Deletes a skill and all its versions, or deactivates it if it has versions
|
|
@@ -1972,9 +2544,7 @@ var init_skills_api_service = __esm({
|
|
|
1972
2544
|
* @throws Error if the skill is not found or the delete operation fails
|
|
1973
2545
|
*/
|
|
1974
2546
|
async deleteSkill(skillId) {
|
|
1975
|
-
return this.httpDelete(`/developer/skills/${this.agentId}/${skillId}`, {
|
|
1976
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
1977
|
-
});
|
|
2547
|
+
return this.httpDelete(`/developer/skills/${this.agentId}/${skillId}`, {});
|
|
1978
2548
|
}
|
|
1979
2549
|
/**
|
|
1980
2550
|
* Attach TS source + workspace archive to a skill version. Powers
|
|
@@ -1982,9 +2552,7 @@ var init_skills_api_service = __esm({
|
|
|
1982
2552
|
* source without waiting for the next UI-driven build.
|
|
1983
2553
|
*/
|
|
1984
2554
|
async attachSkillSource(skillId, version, body) {
|
|
1985
|
-
return this.httpPut(`/developer/skills/${this.agentId}/${skillId}/version/${encodeURIComponent(version)}/source`, body, {
|
|
1986
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
1987
|
-
});
|
|
2555
|
+
return this.httpPut(`/developer/skills/${this.agentId}/${skillId}/version/${encodeURIComponent(version)}/source`, body, {});
|
|
1988
2556
|
}
|
|
1989
2557
|
};
|
|
1990
2558
|
}
|
|
@@ -2883,7 +3451,7 @@ var init_analytics = __esm({
|
|
|
2883
3451
|
"src/services/analytics.ts"() {
|
|
2884
3452
|
"use strict";
|
|
2885
3453
|
init_constants();
|
|
2886
|
-
|
|
3454
|
+
init_request_credential();
|
|
2887
3455
|
init_files();
|
|
2888
3456
|
}
|
|
2889
3457
|
});
|
|
@@ -2917,13 +3485,14 @@ var init_cli = __esm({
|
|
|
2917
3485
|
});
|
|
2918
3486
|
|
|
2919
3487
|
// src/utils/command-utils.ts
|
|
2920
|
-
function requireAuth() {
|
|
2921
|
-
return
|
|
3488
|
+
async function requireAuth() {
|
|
3489
|
+
return resolveRequestCredential();
|
|
2922
3490
|
}
|
|
2923
3491
|
var init_command_utils = __esm({
|
|
2924
3492
|
"src/utils/command-utils.ts"() {
|
|
2925
3493
|
"use strict";
|
|
2926
3494
|
init_auth();
|
|
3495
|
+
init_request_credential();
|
|
2927
3496
|
init_files();
|
|
2928
3497
|
init_cli();
|
|
2929
3498
|
__name(requireAuth, "requireAuth");
|
|
@@ -3406,17 +3975,15 @@ var init_products_api_service = __esm({
|
|
|
3406
3975
|
static {
|
|
3407
3976
|
__name(this, "ProductApi");
|
|
3408
3977
|
}
|
|
3409
|
-
apiKey;
|
|
3410
3978
|
agentId;
|
|
3411
3979
|
/**
|
|
3412
3980
|
* Creates an instance of ProductApi
|
|
3413
3981
|
* @param baseUrl - The base URL for the API
|
|
3414
|
-
* @param
|
|
3982
|
+
* @param credential - The API key for authentication
|
|
3415
3983
|
* @param agentId - The unique identifier of the agent
|
|
3416
3984
|
*/
|
|
3417
|
-
constructor(baseUrl,
|
|
3418
|
-
super(baseUrl);
|
|
3419
|
-
this.apiKey = apiKey;
|
|
3985
|
+
constructor(baseUrl, credential, agentId) {
|
|
3986
|
+
super(baseUrl, credential);
|
|
3420
3987
|
this.agentId = agentId;
|
|
3421
3988
|
}
|
|
3422
3989
|
async get(pageOrOptions, limitArg) {
|
|
@@ -3437,9 +4004,7 @@ var init_products_api_service = __esm({
|
|
|
3437
4004
|
if (filter) {
|
|
3438
4005
|
queryParams.append("filter", JSON.stringify(filter));
|
|
3439
4006
|
}
|
|
3440
|
-
const response = await this.httpGet(`/developer/agents/${this.agentId}/products?${queryParams.toString()}`, {
|
|
3441
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3442
|
-
});
|
|
4007
|
+
const response = await this.httpGet(`/developer/agents/${this.agentId}/products?${queryParams.toString()}`, {});
|
|
3443
4008
|
if (response.success) {
|
|
3444
4009
|
return new ProductPaginationInstance(this, response);
|
|
3445
4010
|
}
|
|
@@ -3452,9 +4017,7 @@ var init_products_api_service = __esm({
|
|
|
3452
4017
|
* @throws Error if the product is not found or the request fails
|
|
3453
4018
|
*/
|
|
3454
4019
|
async getById(productId) {
|
|
3455
|
-
const response = await this.httpGet(`/developer/agents/${this.agentId}/products/${productId}`, {
|
|
3456
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3457
|
-
});
|
|
4020
|
+
const response = await this.httpGet(`/developer/agents/${this.agentId}/products/${productId}`, {});
|
|
3458
4021
|
if (response.success && response.data) {
|
|
3459
4022
|
return new ProductInstance(this, response.data);
|
|
3460
4023
|
}
|
|
@@ -3467,9 +4030,7 @@ var init_products_api_service = __esm({
|
|
|
3467
4030
|
* @throws Error if the product creation fails or validation errors occur
|
|
3468
4031
|
*/
|
|
3469
4032
|
async create(productData) {
|
|
3470
|
-
const response = await this.httpPost(`/developer/agents/${this.agentId}/products`, productData, {
|
|
3471
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3472
|
-
});
|
|
4033
|
+
const response = await this.httpPost(`/developer/agents/${this.agentId}/products`, productData, {});
|
|
3473
4034
|
if (response.success && response.data) {
|
|
3474
4035
|
return new ProductInstance(this, response.data.product);
|
|
3475
4036
|
}
|
|
@@ -3486,9 +4047,7 @@ var init_products_api_service = __esm({
|
|
|
3486
4047
|
const response = await this.httpPut(`/developer/agents/${this.agentId}/products`, {
|
|
3487
4048
|
...productData,
|
|
3488
4049
|
id: productId
|
|
3489
|
-
}, {
|
|
3490
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3491
|
-
});
|
|
4050
|
+
}, {});
|
|
3492
4051
|
if (response.success && response.data) {
|
|
3493
4052
|
return response.data;
|
|
3494
4053
|
}
|
|
@@ -3501,9 +4060,7 @@ var init_products_api_service = __esm({
|
|
|
3501
4060
|
* @throws Error if the product is not found or the deletion fails
|
|
3502
4061
|
*/
|
|
3503
4062
|
async delete(productId) {
|
|
3504
|
-
const response = await this.httpDelete(`/developer/agents/${this.agentId}/products/${productId}`, {
|
|
3505
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3506
|
-
});
|
|
4063
|
+
const response = await this.httpDelete(`/developer/agents/${this.agentId}/products/${productId}`, {});
|
|
3507
4064
|
if (response.success && response.data) {
|
|
3508
4065
|
return response.data;
|
|
3509
4066
|
}
|
|
@@ -3517,9 +4074,7 @@ var init_products_api_service = __esm({
|
|
|
3517
4074
|
* @throws Error if the search fails or the API request is unsuccessful
|
|
3518
4075
|
*/
|
|
3519
4076
|
async search(searchQuery, limit = 5) {
|
|
3520
|
-
const response = await this.httpGet(`/developer/agents/${this.agentId}/products/search?searchQuery=${encodeURIComponent(searchQuery)}&limit=${limit}`, {
|
|
3521
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3522
|
-
});
|
|
4077
|
+
const response = await this.httpGet(`/developer/agents/${this.agentId}/products/search?searchQuery=${encodeURIComponent(searchQuery)}&limit=${limit}`, {});
|
|
3523
4078
|
if (response.success) {
|
|
3524
4079
|
return new ProductSearchInstance(this, response);
|
|
3525
4080
|
}
|
|
@@ -4004,17 +4559,15 @@ var init_order_api_service = __esm({
|
|
|
4004
4559
|
static {
|
|
4005
4560
|
__name(this, "OrderApi");
|
|
4006
4561
|
}
|
|
4007
|
-
apiKey;
|
|
4008
4562
|
agentId;
|
|
4009
4563
|
/**
|
|
4010
4564
|
* Creates an instance of OrderApi
|
|
4011
4565
|
* @param baseUrl - The base URL for the API
|
|
4012
|
-
* @param
|
|
4566
|
+
* @param credential - The API key for authentication
|
|
4013
4567
|
* @param agentId - The unique identifier of the agent
|
|
4014
4568
|
*/
|
|
4015
|
-
constructor(baseUrl,
|
|
4016
|
-
super(baseUrl);
|
|
4017
|
-
this.apiKey = apiKey;
|
|
4569
|
+
constructor(baseUrl, credential, agentId) {
|
|
4570
|
+
super(baseUrl, credential);
|
|
4018
4571
|
this.agentId = agentId;
|
|
4019
4572
|
}
|
|
4020
4573
|
/**
|
|
@@ -4024,9 +4577,7 @@ var init_order_api_service = __esm({
|
|
|
4024
4577
|
* @throws Error if the basket is not found or the order creation fails
|
|
4025
4578
|
*/
|
|
4026
4579
|
async create(orderData) {
|
|
4027
|
-
const response = await this.httpPost(`/developer/agents/${this.agentId}/order`, orderData, {
|
|
4028
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4029
|
-
});
|
|
4580
|
+
const response = await this.httpPost(`/developer/agents/${this.agentId}/order`, orderData, {});
|
|
4030
4581
|
if (response.success && response.data) {
|
|
4031
4582
|
return new OrderInstance(this, response.data);
|
|
4032
4583
|
}
|
|
@@ -4040,9 +4591,7 @@ var init_order_api_service = __esm({
|
|
|
4040
4591
|
* @throws Error if the order is not found or the status update fails
|
|
4041
4592
|
*/
|
|
4042
4593
|
async updateStatus(status, orderId) {
|
|
4043
|
-
const response = await this.httpPut(`/developer/agents/${this.agentId}/order/${orderId}/${status}`, {}, {
|
|
4044
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4045
|
-
});
|
|
4594
|
+
const response = await this.httpPut(`/developer/agents/${this.agentId}/order/${orderId}/${status}`, {}, {});
|
|
4046
4595
|
if (response.success && response.data) {
|
|
4047
4596
|
return response.data;
|
|
4048
4597
|
}
|
|
@@ -4056,9 +4605,7 @@ var init_order_api_service = __esm({
|
|
|
4056
4605
|
* @throws Error if the order is not found or the data update fails
|
|
4057
4606
|
*/
|
|
4058
4607
|
async updateData(data, orderId) {
|
|
4059
|
-
const response = await this.httpPut(`/developer/agents/${this.agentId}/order/${orderId}`, data, {
|
|
4060
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4061
|
-
});
|
|
4608
|
+
const response = await this.httpPut(`/developer/agents/${this.agentId}/order/${orderId}`, data, {});
|
|
4062
4609
|
if (response.success && response.data) {
|
|
4063
4610
|
return response.data;
|
|
4064
4611
|
}
|
|
@@ -4072,9 +4619,7 @@ var init_order_api_service = __esm({
|
|
|
4072
4619
|
*/
|
|
4073
4620
|
async get(status) {
|
|
4074
4621
|
const statusParam = status ? `?status=${status}` : "";
|
|
4075
|
-
const response = await this.httpGet(`/developer/agents/${this.agentId}/order/user${statusParam}`, {
|
|
4076
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4077
|
-
});
|
|
4622
|
+
const response = await this.httpGet(`/developer/agents/${this.agentId}/order/user${statusParam}`, {});
|
|
4078
4623
|
if (response.success && response.data) {
|
|
4079
4624
|
return response.data.map((order) => new OrderInstance(this, order));
|
|
4080
4625
|
}
|
|
@@ -4087,9 +4632,7 @@ var init_order_api_service = __esm({
|
|
|
4087
4632
|
* @throws Error if the order is not found or the request fails
|
|
4088
4633
|
*/
|
|
4089
4634
|
async getById(orderId) {
|
|
4090
|
-
const response = await this.httpGet(`/developer/agents/${this.agentId}/order/${orderId}`, {
|
|
4091
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4092
|
-
});
|
|
4635
|
+
const response = await this.httpGet(`/developer/agents/${this.agentId}/order/${orderId}`, {});
|
|
4093
4636
|
if (response.success && response.data) {
|
|
4094
4637
|
return new OrderInstance(this, response.data);
|
|
4095
4638
|
}
|
|
@@ -4112,17 +4655,17 @@ var init_basket_api_service = __esm({
|
|
|
4112
4655
|
static {
|
|
4113
4656
|
__name(this, "BasketApi");
|
|
4114
4657
|
}
|
|
4115
|
-
|
|
4658
|
+
credential;
|
|
4116
4659
|
agentId;
|
|
4117
4660
|
/**
|
|
4118
4661
|
* Creates an instance of BasketApi
|
|
4119
4662
|
* @param baseUrl - The base URL for the API
|
|
4120
|
-
* @param
|
|
4663
|
+
* @param credential - The API key for authentication
|
|
4121
4664
|
* @param agentId - The unique identifier of the agent
|
|
4122
4665
|
*/
|
|
4123
|
-
constructor(baseUrl,
|
|
4124
|
-
super(baseUrl);
|
|
4125
|
-
this.
|
|
4666
|
+
constructor(baseUrl, credential, agentId) {
|
|
4667
|
+
super(baseUrl, credential);
|
|
4668
|
+
this.credential = credential;
|
|
4126
4669
|
this.agentId = agentId;
|
|
4127
4670
|
}
|
|
4128
4671
|
/**
|
|
@@ -4132,9 +4675,7 @@ var init_basket_api_service = __esm({
|
|
|
4132
4675
|
* @throws Error if the basket creation fails or the API request is unsuccessful
|
|
4133
4676
|
*/
|
|
4134
4677
|
async create(basketData) {
|
|
4135
|
-
const response = await this.httpPost(`/developer/agents/${this.agentId}/basket`, basketData, {
|
|
4136
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4137
|
-
});
|
|
4678
|
+
const response = await this.httpPost(`/developer/agents/${this.agentId}/basket`, basketData, {});
|
|
4138
4679
|
if (response.success && response.data) {
|
|
4139
4680
|
return new BasketInstance(this, response.data);
|
|
4140
4681
|
}
|
|
@@ -4148,9 +4689,7 @@ var init_basket_api_service = __esm({
|
|
|
4148
4689
|
*/
|
|
4149
4690
|
async get(status) {
|
|
4150
4691
|
const statusParam = status ? `?status=${status}` : "";
|
|
4151
|
-
const response = await this.httpGet(`/developer/agents/${this.agentId}/basket/user${statusParam}`, {
|
|
4152
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4153
|
-
});
|
|
4692
|
+
const response = await this.httpGet(`/developer/agents/${this.agentId}/basket/user${statusParam}`, {});
|
|
4154
4693
|
if (response.success && response.data) {
|
|
4155
4694
|
return response.data.map((basket) => new BasketInstance(this, basket));
|
|
4156
4695
|
}
|
|
@@ -4163,9 +4702,7 @@ var init_basket_api_service = __esm({
|
|
|
4163
4702
|
* @throws Error if the basket is not found or the request fails
|
|
4164
4703
|
*/
|
|
4165
4704
|
async getById(basketId) {
|
|
4166
|
-
const response = await this.httpGet(`/developer/agents/${this.agentId}/basket/${basketId}`, {
|
|
4167
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4168
|
-
});
|
|
4705
|
+
const response = await this.httpGet(`/developer/agents/${this.agentId}/basket/${basketId}`, {});
|
|
4169
4706
|
if (response.success && response.data) {
|
|
4170
4707
|
return new BasketInstance(this, response.data);
|
|
4171
4708
|
}
|
|
@@ -4179,9 +4716,7 @@ var init_basket_api_service = __esm({
|
|
|
4179
4716
|
* @throws Error if the basket is not found or the item cannot be added
|
|
4180
4717
|
*/
|
|
4181
4718
|
async addItem(basketId, itemData) {
|
|
4182
|
-
const response = await this.httpPost(`/developer/agents/${this.agentId}/basket/${basketId}/item`, itemData, {
|
|
4183
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4184
|
-
});
|
|
4719
|
+
const response = await this.httpPost(`/developer/agents/${this.agentId}/basket/${basketId}/item`, itemData, {});
|
|
4185
4720
|
if (response.success && response.data) {
|
|
4186
4721
|
return response.data;
|
|
4187
4722
|
}
|
|
@@ -4195,9 +4730,7 @@ var init_basket_api_service = __esm({
|
|
|
4195
4730
|
* @throws Error if the basket or item is not found or the removal fails
|
|
4196
4731
|
*/
|
|
4197
4732
|
async removeItem(basketId, itemId) {
|
|
4198
|
-
const response = await this.httpDelete(`/developer/agents/${this.agentId}/basket/${basketId}/item/${itemId}`, {
|
|
4199
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4200
|
-
});
|
|
4733
|
+
const response = await this.httpDelete(`/developer/agents/${this.agentId}/basket/${basketId}/item/${itemId}`, {});
|
|
4201
4734
|
if (response.success && response.data) {
|
|
4202
4735
|
return response.data;
|
|
4203
4736
|
}
|
|
@@ -4210,9 +4743,7 @@ var init_basket_api_service = __esm({
|
|
|
4210
4743
|
* @throws Error if the basket is not found or the clear operation fails
|
|
4211
4744
|
*/
|
|
4212
4745
|
async clear(basketId) {
|
|
4213
|
-
const response = await this.httpDelete(`/developer/agents/${this.agentId}/basket/${basketId}/clear`, {
|
|
4214
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4215
|
-
});
|
|
4746
|
+
const response = await this.httpDelete(`/developer/agents/${this.agentId}/basket/${basketId}/clear`, {});
|
|
4216
4747
|
if (response.success && response.data) {
|
|
4217
4748
|
return response.data;
|
|
4218
4749
|
}
|
|
@@ -4226,9 +4757,7 @@ var init_basket_api_service = __esm({
|
|
|
4226
4757
|
* @throws Error if the basket is not found or the status update fails
|
|
4227
4758
|
*/
|
|
4228
4759
|
async updateStatus(basketId, status) {
|
|
4229
|
-
const response = await this.httpPut(`/developer/agents/${this.agentId}/basket/${basketId}/${status}`, void 0, {
|
|
4230
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4231
|
-
});
|
|
4760
|
+
const response = await this.httpPut(`/developer/agents/${this.agentId}/basket/${basketId}/${status}`, void 0, {});
|
|
4232
4761
|
if (response.success) {
|
|
4233
4762
|
return status;
|
|
4234
4763
|
}
|
|
@@ -4242,9 +4771,7 @@ var init_basket_api_service = __esm({
|
|
|
4242
4771
|
* @throws Error if the basket is not found or the metadata update fails
|
|
4243
4772
|
*/
|
|
4244
4773
|
async updateMetadata(basketId, metadata) {
|
|
4245
|
-
const response = await this.httpPut(`/developer/agents/${this.agentId}/basket/${basketId}/metadata`, metadata, {
|
|
4246
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4247
|
-
});
|
|
4774
|
+
const response = await this.httpPut(`/developer/agents/${this.agentId}/basket/${basketId}/metadata`, metadata, {});
|
|
4248
4775
|
if (response.success) {
|
|
4249
4776
|
return metadata;
|
|
4250
4777
|
}
|
|
@@ -4261,11 +4788,9 @@ var init_basket_api_service = __esm({
|
|
|
4261
4788
|
const response = await this.httpPost(`/developer/agents/${this.agentId}/order`, {
|
|
4262
4789
|
basketId,
|
|
4263
4790
|
data
|
|
4264
|
-
}, {
|
|
4265
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4266
|
-
});
|
|
4791
|
+
}, {});
|
|
4267
4792
|
if (response.success && response.data) {
|
|
4268
|
-
const orderApi = new OrderApi(this.baseUrl, this.
|
|
4793
|
+
const orderApi = new OrderApi(this.baseUrl, this.credential, this.agentId);
|
|
4269
4794
|
return new OrderInstance(orderApi, response.data);
|
|
4270
4795
|
}
|
|
4271
4796
|
throw new Error(response.error?.message || "Failed to create order");
|
|
@@ -4504,18 +5029,18 @@ var init_user_data_api_service = __esm({
|
|
|
4504
5029
|
static {
|
|
4505
5030
|
__name(this, "UserDataApi");
|
|
4506
5031
|
}
|
|
4507
|
-
|
|
5032
|
+
credential;
|
|
4508
5033
|
agentId;
|
|
4509
5034
|
targetUserId;
|
|
4510
5035
|
/**
|
|
4511
5036
|
* Creates an instance of UserDataApi
|
|
4512
5037
|
* @param baseUrl - The base URL for the API
|
|
4513
|
-
* @param
|
|
5038
|
+
* @param credential - The API key for authentication
|
|
4514
5039
|
* @param agentId - The unique identifier of the agent
|
|
4515
5040
|
*/
|
|
4516
|
-
constructor(baseUrl,
|
|
4517
|
-
super(baseUrl);
|
|
4518
|
-
this.
|
|
5041
|
+
constructor(baseUrl, credential, agentId, targetUserId) {
|
|
5042
|
+
super(baseUrl, credential);
|
|
5043
|
+
this.credential = credential;
|
|
4519
5044
|
this.agentId = agentId;
|
|
4520
5045
|
this.targetUserId = targetUserId;
|
|
4521
5046
|
}
|
|
@@ -4542,15 +5067,13 @@ var init_user_data_api_service = __esm({
|
|
|
4542
5067
|
if (userId) {
|
|
4543
5068
|
url += `/user/${encodeURIComponent(userId)}`;
|
|
4544
5069
|
}
|
|
4545
|
-
const response = await this.httpGet(url, {
|
|
4546
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4547
|
-
});
|
|
5070
|
+
const response = await this.httpGet(url, {});
|
|
4548
5071
|
if (!response.success) {
|
|
4549
5072
|
throw new Error(response.error?.message || "Failed to get user data");
|
|
4550
5073
|
}
|
|
4551
5074
|
const profile = response.data?._luaProfile;
|
|
4552
5075
|
const { _luaProfile, ...data } = response.data || {};
|
|
4553
|
-
const scopedApi = userId ? new _UserDataApi(this.baseUrl, this.
|
|
5076
|
+
const scopedApi = userId ? new _UserDataApi(this.baseUrl, this.credential, this.agentId, userId) : this;
|
|
4554
5077
|
return new UserDataInstance(scopedApi, data, profile);
|
|
4555
5078
|
}
|
|
4556
5079
|
/**
|
|
@@ -4584,9 +5107,7 @@ var init_user_data_api_service = __esm({
|
|
|
4584
5107
|
* @throws Error if the update fails or the request is unsuccessful
|
|
4585
5108
|
*/
|
|
4586
5109
|
async update(data) {
|
|
4587
|
-
const response = await this.httpPut(this.dataPath, data, {
|
|
4588
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4589
|
-
});
|
|
5110
|
+
const response = await this.httpPut(this.dataPath, data, {});
|
|
4590
5111
|
if (!response.success) {
|
|
4591
5112
|
throw new Error(response.error?.message || "Failed to update user data");
|
|
4592
5113
|
}
|
|
@@ -4594,9 +5115,7 @@ var init_user_data_api_service = __esm({
|
|
|
4594
5115
|
return cleanData;
|
|
4595
5116
|
}
|
|
4596
5117
|
async patch(mutation) {
|
|
4597
|
-
const response = await this.httpPatch(this.dataPath, mutation, {
|
|
4598
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4599
|
-
});
|
|
5118
|
+
const response = await this.httpPatch(this.dataPath, mutation, {});
|
|
4600
5119
|
if (!response.success) {
|
|
4601
5120
|
throw new Error(response.error?.message || "Failed to patch user data");
|
|
4602
5121
|
}
|
|
@@ -4609,9 +5128,7 @@ var init_user_data_api_service = __esm({
|
|
|
4609
5128
|
* @throws Error if the clear operation fails or the request is unsuccessful
|
|
4610
5129
|
*/
|
|
4611
5130
|
async clear() {
|
|
4612
|
-
const response = await this.httpDelete(this.dataPath, {
|
|
4613
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4614
|
-
});
|
|
5131
|
+
const response = await this.httpDelete(this.dataPath, {});
|
|
4615
5132
|
if (!response.success) {
|
|
4616
5133
|
throw new Error(response.error?.message || "Failed to clear user data");
|
|
4617
5134
|
}
|
|
@@ -4626,9 +5143,7 @@ var init_user_data_api_service = __esm({
|
|
|
4626
5143
|
async sendMessage(messages) {
|
|
4627
5144
|
const response = await this.httpPost(`/admin/agents/${this.agentId}/conversations/me`, {
|
|
4628
5145
|
messages
|
|
4629
|
-
}, {
|
|
4630
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4631
|
-
});
|
|
5146
|
+
}, {});
|
|
4632
5147
|
if (!response.success) {
|
|
4633
5148
|
throw new Error(response.error?.message || "Failed to send message");
|
|
4634
5149
|
}
|
|
@@ -4646,9 +5161,7 @@ var init_user_data_api_service = __esm({
|
|
|
4646
5161
|
* ```
|
|
4647
5162
|
*/
|
|
4648
5163
|
async getChatHistory() {
|
|
4649
|
-
const response = await this.httpGet(`/chat/history/${this.agentId}`, {
|
|
4650
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4651
|
-
});
|
|
5164
|
+
const response = await this.httpGet(`/chat/history/${this.agentId}`, {});
|
|
4652
5165
|
if (!response.success) {
|
|
4653
5166
|
throw new Error(response.error?.message || "Failed to get chat history");
|
|
4654
5167
|
}
|
|
@@ -4874,17 +5387,15 @@ var init_custom_data_api_service = __esm({
|
|
|
4874
5387
|
static {
|
|
4875
5388
|
__name(this, "CustomDataApi");
|
|
4876
5389
|
}
|
|
4877
|
-
apiKey;
|
|
4878
5390
|
agentId;
|
|
4879
5391
|
/**
|
|
4880
5392
|
* Creates an instance of CustomDataApi
|
|
4881
5393
|
* @param baseUrl - The base URL for the API
|
|
4882
|
-
* @param
|
|
5394
|
+
* @param credential - The API key for authentication
|
|
4883
5395
|
* @param agentId - The unique identifier of the agent
|
|
4884
5396
|
*/
|
|
4885
|
-
constructor(baseUrl,
|
|
4886
|
-
super(baseUrl);
|
|
4887
|
-
this.apiKey = apiKey;
|
|
5397
|
+
constructor(baseUrl, credential, agentId) {
|
|
5398
|
+
super(baseUrl, credential);
|
|
4888
5399
|
this.agentId = agentId;
|
|
4889
5400
|
}
|
|
4890
5401
|
/**
|
|
@@ -4894,9 +5405,7 @@ var init_custom_data_api_service = __esm({
|
|
|
4894
5405
|
* @returns Promise resolving to the collections listing
|
|
4895
5406
|
*/
|
|
4896
5407
|
async collections() {
|
|
4897
|
-
const response = await this.httpGet(`/developer/agents/${this.agentId}/custom-data`, {
|
|
4898
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4899
|
-
});
|
|
5408
|
+
const response = await this.httpGet(`/developer/agents/${this.agentId}/custom-data`, {});
|
|
4900
5409
|
if (response.success && response.data) {
|
|
4901
5410
|
return response.data;
|
|
4902
5411
|
}
|
|
@@ -4924,9 +5433,7 @@ var init_custom_data_api_service = __esm({
|
|
|
4924
5433
|
data,
|
|
4925
5434
|
searchText: options.searchText,
|
|
4926
5435
|
index: options.index
|
|
4927
|
-
}, {
|
|
4928
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4929
|
-
});
|
|
5436
|
+
}, {});
|
|
4930
5437
|
if (response.success && response.data) {
|
|
4931
5438
|
return new DataEntryInstance(this, response.data, collectionName);
|
|
4932
5439
|
}
|
|
@@ -4947,9 +5454,7 @@ var init_custom_data_api_service = __esm({
|
|
|
4947
5454
|
const encodedFilter = encodeURIComponent(JSON.stringify(filter));
|
|
4948
5455
|
url += `&filter=${encodedFilter}`;
|
|
4949
5456
|
}
|
|
4950
|
-
const response = await this.httpGet(url, {
|
|
4951
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4952
|
-
});
|
|
5457
|
+
const response = await this.httpGet(url, {});
|
|
4953
5458
|
if (response.success && response.data) {
|
|
4954
5459
|
return response.data;
|
|
4955
5460
|
}
|
|
@@ -4963,9 +5468,7 @@ var init_custom_data_api_service = __esm({
|
|
|
4963
5468
|
* @throws Error if the entry is not found or the API request is unsuccessful
|
|
4964
5469
|
*/
|
|
4965
5470
|
async getEntry(collectionName, entryId) {
|
|
4966
|
-
const response = await this.httpGet(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, {
|
|
4967
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4968
|
-
});
|
|
5471
|
+
const response = await this.httpGet(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, {});
|
|
4969
5472
|
if (response.success && response.data) {
|
|
4970
5473
|
return new DataEntryInstance(this, response.data, collectionName);
|
|
4971
5474
|
}
|
|
@@ -4989,18 +5492,14 @@ var init_custom_data_api_service = __esm({
|
|
|
4989
5492
|
data,
|
|
4990
5493
|
searchText: options.searchText,
|
|
4991
5494
|
index: options.index
|
|
4992
|
-
}, {
|
|
4993
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4994
|
-
});
|
|
5495
|
+
}, {});
|
|
4995
5496
|
if (response.success && response.data) {
|
|
4996
5497
|
return response.data;
|
|
4997
5498
|
}
|
|
4998
5499
|
throw new Error(response.error?.message || "Failed to update custom data entry");
|
|
4999
5500
|
}
|
|
5000
5501
|
async patch(collectionName, entryId, mutation) {
|
|
5001
|
-
const response = await this.httpPatch(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, mutation, {
|
|
5002
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5003
|
-
});
|
|
5502
|
+
const response = await this.httpPatch(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, mutation, {});
|
|
5004
5503
|
if (response.success && response.data) {
|
|
5005
5504
|
return response.data;
|
|
5006
5505
|
}
|
|
@@ -5017,9 +5516,7 @@ var init_custom_data_api_service = __esm({
|
|
|
5017
5516
|
*/
|
|
5018
5517
|
async search(collectionName, searchText, limit = 10, scoreThreshold = 0.6) {
|
|
5019
5518
|
const url = `/developer/agents/${this.agentId}/custom-data/${collectionName}/search?searchText=${encodeURIComponent(searchText)}&limit=${limit}&scoreThreshold=${scoreThreshold}`;
|
|
5020
|
-
const response = await this.httpGet(url, {
|
|
5021
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5022
|
-
});
|
|
5519
|
+
const response = await this.httpGet(url, {});
|
|
5023
5520
|
if (response.success && response.data) {
|
|
5024
5521
|
return response.data.data.map((entry) => new DataEntryInstance(this, entry, collectionName));
|
|
5025
5522
|
}
|
|
@@ -5033,9 +5530,7 @@ var init_custom_data_api_service = __esm({
|
|
|
5033
5530
|
* @throws Error if the entry is not found or the deletion fails
|
|
5034
5531
|
*/
|
|
5035
5532
|
async delete(collectionName, entryId) {
|
|
5036
|
-
const response = await this.httpDelete(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, {
|
|
5037
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5038
|
-
});
|
|
5533
|
+
const response = await this.httpDelete(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, {});
|
|
5039
5534
|
if (response.success && response.data) {
|
|
5040
5535
|
return response.data;
|
|
5041
5536
|
}
|
|
@@ -5055,17 +5550,15 @@ var init_webhook_api_service = __esm({
|
|
|
5055
5550
|
static {
|
|
5056
5551
|
__name(this, "WebhookApi");
|
|
5057
5552
|
}
|
|
5058
|
-
apiKey;
|
|
5059
5553
|
agentId;
|
|
5060
5554
|
/**
|
|
5061
5555
|
* Creates an instance of WebhookApi
|
|
5062
5556
|
* @param baseUrl - The base URL for the API
|
|
5063
|
-
* @param
|
|
5557
|
+
* @param credential - The API key for authentication
|
|
5064
5558
|
* @param agentId - The unique identifier of the agent
|
|
5065
5559
|
*/
|
|
5066
|
-
constructor(baseUrl,
|
|
5067
|
-
super(baseUrl);
|
|
5068
|
-
this.apiKey = apiKey;
|
|
5560
|
+
constructor(baseUrl, credential, agentId) {
|
|
5561
|
+
super(baseUrl, credential);
|
|
5069
5562
|
this.agentId = agentId;
|
|
5070
5563
|
}
|
|
5071
5564
|
/**
|
|
@@ -5074,9 +5567,7 @@ var init_webhook_api_service = __esm({
|
|
|
5074
5567
|
* @throws Error if the API request fails or the agent is not found
|
|
5075
5568
|
*/
|
|
5076
5569
|
async getWebhooks() {
|
|
5077
|
-
return this.httpGet(`/developer/webhooks/${this.agentId}`, {
|
|
5078
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5079
|
-
});
|
|
5570
|
+
return this.httpGet(`/developer/webhooks/${this.agentId}`, {});
|
|
5080
5571
|
}
|
|
5081
5572
|
/**
|
|
5082
5573
|
* Creates a new webhook for the agent
|
|
@@ -5085,14 +5576,10 @@ var init_webhook_api_service = __esm({
|
|
|
5085
5576
|
* @throws Error if the webhook creation fails or validation errors occur
|
|
5086
5577
|
*/
|
|
5087
5578
|
async createWebhook(webhookData) {
|
|
5088
|
-
return this.httpPost(`/developer/webhooks/${this.agentId}`, webhookData, {
|
|
5089
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5090
|
-
});
|
|
5579
|
+
return this.httpPost(`/developer/webhooks/${this.agentId}`, webhookData, {});
|
|
5091
5580
|
}
|
|
5092
5581
|
async updateWebhook(webhookId, data) {
|
|
5093
|
-
return this.httpPatch(`/developer/webhooks/${this.agentId}/${webhookId}`, data, {
|
|
5094
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5095
|
-
});
|
|
5582
|
+
return this.httpPatch(`/developer/webhooks/${this.agentId}/${webhookId}`, data, {});
|
|
5096
5583
|
}
|
|
5097
5584
|
/**
|
|
5098
5585
|
* Pushes a new version of a webhook to production
|
|
@@ -5102,9 +5589,7 @@ var init_webhook_api_service = __esm({
|
|
|
5102
5589
|
* @throws Error if the webhook is not found or the push operation fails
|
|
5103
5590
|
*/
|
|
5104
5591
|
async pushWebhook(webhookId, versionData) {
|
|
5105
|
-
return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/version`, versionData, {
|
|
5106
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5107
|
-
});
|
|
5592
|
+
return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/version`, versionData, {});
|
|
5108
5593
|
}
|
|
5109
5594
|
/**
|
|
5110
5595
|
* Pushes a new development/sandbox version of a webhook for testing
|
|
@@ -5114,9 +5599,7 @@ var init_webhook_api_service = __esm({
|
|
|
5114
5599
|
* @throws Error if the webhook is not found or the push operation fails
|
|
5115
5600
|
*/
|
|
5116
5601
|
async pushDevWebhook(webhookId, versionData) {
|
|
5117
|
-
return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/version/sandbox`, versionData, {
|
|
5118
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5119
|
-
});
|
|
5602
|
+
return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/version/sandbox`, versionData, {});
|
|
5120
5603
|
}
|
|
5121
5604
|
/**
|
|
5122
5605
|
* Updates an existing development/sandbox version of a webhook
|
|
@@ -5127,9 +5610,7 @@ var init_webhook_api_service = __esm({
|
|
|
5127
5610
|
* @throws Error if the webhook or version is not found or the update fails
|
|
5128
5611
|
*/
|
|
5129
5612
|
async updateDevWebhook(webhookId, sandboxVersionId, versionData) {
|
|
5130
|
-
return this.httpPut(`/developer/webhooks/${this.agentId}/${webhookId}/version/sandbox/${sandboxVersionId}`, versionData, {
|
|
5131
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5132
|
-
});
|
|
5613
|
+
return this.httpPut(`/developer/webhooks/${this.agentId}/${webhookId}/version/sandbox/${sandboxVersionId}`, versionData, {});
|
|
5133
5614
|
}
|
|
5134
5615
|
/**
|
|
5135
5616
|
* Retrieves all versions of a specific webhook
|
|
@@ -5138,9 +5619,7 @@ var init_webhook_api_service = __esm({
|
|
|
5138
5619
|
* @throws Error if the webhook is not found or the request fails
|
|
5139
5620
|
*/
|
|
5140
5621
|
async getWebhookVersions(webhookId) {
|
|
5141
|
-
return this.httpGet(`/developer/webhooks/${this.agentId}/${webhookId}/versions`, {
|
|
5142
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5143
|
-
});
|
|
5622
|
+
return this.httpGet(`/developer/webhooks/${this.agentId}/${webhookId}/versions`, {});
|
|
5144
5623
|
}
|
|
5145
5624
|
/**
|
|
5146
5625
|
* Publishes a specific version of a webhook to production
|
|
@@ -5150,9 +5629,7 @@ var init_webhook_api_service = __esm({
|
|
|
5150
5629
|
* @throws Error if the webhook or version is not found or the publish operation fails
|
|
5151
5630
|
*/
|
|
5152
5631
|
async publishWebhookVersion(webhookId, version) {
|
|
5153
|
-
return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/${version}/publish`, {}, {
|
|
5154
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5155
|
-
});
|
|
5632
|
+
return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/${version}/publish`, {}, {});
|
|
5156
5633
|
}
|
|
5157
5634
|
/**
|
|
5158
5635
|
* Activates a webhook (enables it to receive requests)
|
|
@@ -5161,9 +5638,7 @@ var init_webhook_api_service = __esm({
|
|
|
5161
5638
|
* @throws Error if the webhook is not found or the operation fails
|
|
5162
5639
|
*/
|
|
5163
5640
|
async activateWebhook(webhookId) {
|
|
5164
|
-
return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/activate`, {}, {
|
|
5165
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5166
|
-
});
|
|
5641
|
+
return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/activate`, {}, {});
|
|
5167
5642
|
}
|
|
5168
5643
|
/**
|
|
5169
5644
|
* Deactivates a webhook (stops it from receiving requests)
|
|
@@ -5172,9 +5647,7 @@ var init_webhook_api_service = __esm({
|
|
|
5172
5647
|
* @throws Error if the webhook is not found or the operation fails
|
|
5173
5648
|
*/
|
|
5174
5649
|
async deactivateWebhook(webhookId) {
|
|
5175
|
-
return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/deactivate`, {}, {
|
|
5176
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5177
|
-
});
|
|
5650
|
+
return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/deactivate`, {}, {});
|
|
5178
5651
|
}
|
|
5179
5652
|
/**
|
|
5180
5653
|
* Deletes a webhook and all its versions, or deactivates it if it has versions
|
|
@@ -5185,9 +5658,7 @@ var init_webhook_api_service = __esm({
|
|
|
5185
5658
|
* @throws Error if the webhook is not found or the delete operation fails
|
|
5186
5659
|
*/
|
|
5187
5660
|
async deleteWebhook(webhookId) {
|
|
5188
|
-
return this.httpDelete(`/developer/webhooks/${this.agentId}/${webhookId}`, {
|
|
5189
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5190
|
-
});
|
|
5661
|
+
return this.httpDelete(`/developer/webhooks/${this.agentId}/${webhookId}`, {});
|
|
5191
5662
|
}
|
|
5192
5663
|
};
|
|
5193
5664
|
}
|
|
@@ -5220,7 +5691,7 @@ var init_job_instance = __esm({
|
|
|
5220
5691
|
this.activeVersion = jobData.activeVersion;
|
|
5221
5692
|
this.metadata = jobData.metadata || {};
|
|
5222
5693
|
if (jobData.userId && jobData.agentId) {
|
|
5223
|
-
this.userApi = new UserDataApi(BASE_URLS.API, jobApi.
|
|
5694
|
+
this.userApi = new UserDataApi(BASE_URLS.API, jobApi.credential, jobApi.agentId);
|
|
5224
5695
|
}
|
|
5225
5696
|
}
|
|
5226
5697
|
/**
|
|
@@ -5374,17 +5845,17 @@ var init_job_api_service = __esm({
|
|
|
5374
5845
|
static {
|
|
5375
5846
|
__name(this, "JobApi");
|
|
5376
5847
|
}
|
|
5377
|
-
apiKey;
|
|
5378
5848
|
agentId;
|
|
5849
|
+
credential;
|
|
5379
5850
|
/**
|
|
5380
5851
|
* Creates an instance of JobApi
|
|
5381
5852
|
* @param baseUrl - The base URL for the API
|
|
5382
|
-
* @param
|
|
5853
|
+
* @param credential - The API key for authentication
|
|
5383
5854
|
* @param agentId - The unique identifier of the agent
|
|
5384
5855
|
*/
|
|
5385
|
-
constructor(baseUrl,
|
|
5386
|
-
super(baseUrl);
|
|
5387
|
-
this.
|
|
5856
|
+
constructor(baseUrl, credential, agentId) {
|
|
5857
|
+
super(baseUrl, credential);
|
|
5858
|
+
this.credential = credential;
|
|
5388
5859
|
this.agentId = agentId;
|
|
5389
5860
|
}
|
|
5390
5861
|
/**
|
|
@@ -5398,9 +5869,7 @@ var init_job_api_service = __esm({
|
|
|
5398
5869
|
queryParams.append("includeDynamic", "true");
|
|
5399
5870
|
}
|
|
5400
5871
|
const url = `/developer/jobs/${this.agentId}?${queryParams.toString()}`;
|
|
5401
|
-
return this.httpGet(url, {
|
|
5402
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5403
|
-
});
|
|
5872
|
+
return this.httpGet(url, {});
|
|
5404
5873
|
}
|
|
5405
5874
|
/**
|
|
5406
5875
|
* Retrieves all jobs for the agent as JobInstance array
|
|
@@ -5423,9 +5892,7 @@ var init_job_api_service = __esm({
|
|
|
5423
5892
|
* @throws Error if the job is not found or the request fails
|
|
5424
5893
|
*/
|
|
5425
5894
|
async getJob(jobId) {
|
|
5426
|
-
const response = await this.httpGet(`/developer/jobs/${this.agentId}/${jobId}`, {
|
|
5427
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5428
|
-
});
|
|
5895
|
+
const response = await this.httpGet(`/developer/jobs/${this.agentId}/${jobId}`, {});
|
|
5429
5896
|
if (response.success && response.data) {
|
|
5430
5897
|
return new JobInstance(this, response.data);
|
|
5431
5898
|
}
|
|
@@ -5442,9 +5909,7 @@ var init_job_api_service = __esm({
|
|
|
5442
5909
|
* @throws Error if the job creation fails or validation errors occur
|
|
5443
5910
|
*/
|
|
5444
5911
|
async createJob(jobData) {
|
|
5445
|
-
return this.httpPost(`/developer/jobs/${this.agentId}`, jobData, {
|
|
5446
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5447
|
-
});
|
|
5912
|
+
return this.httpPost(`/developer/jobs/${this.agentId}`, jobData, {});
|
|
5448
5913
|
}
|
|
5449
5914
|
/**
|
|
5450
5915
|
* Creates a new job for the agent and returns a JobInstance.
|
|
@@ -5457,9 +5922,7 @@ var init_job_api_service = __esm({
|
|
|
5457
5922
|
* @throws Error if the job creation fails or validation errors occur
|
|
5458
5923
|
*/
|
|
5459
5924
|
async createJobInstance(jobData) {
|
|
5460
|
-
const response = await this.httpPost(`/developer/jobs/${this.agentId}`, jobData, {
|
|
5461
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5462
|
-
});
|
|
5925
|
+
const response = await this.httpPost(`/developer/jobs/${this.agentId}`, jobData, {});
|
|
5463
5926
|
if (response.success && response.data) {
|
|
5464
5927
|
return new JobInstance(this, response.data);
|
|
5465
5928
|
}
|
|
@@ -5473,9 +5936,7 @@ var init_job_api_service = __esm({
|
|
|
5473
5936
|
* @throws Error if the job is not found or the push operation fails
|
|
5474
5937
|
*/
|
|
5475
5938
|
async pushJob(jobId, versionData) {
|
|
5476
|
-
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/version`, versionData, {
|
|
5477
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5478
|
-
});
|
|
5939
|
+
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/version`, versionData, {});
|
|
5479
5940
|
}
|
|
5480
5941
|
/**
|
|
5481
5942
|
* Pushes a new development/sandbox version of a job for testing
|
|
@@ -5485,9 +5946,7 @@ var init_job_api_service = __esm({
|
|
|
5485
5946
|
* @throws Error if the job is not found or the push operation fails
|
|
5486
5947
|
*/
|
|
5487
5948
|
async pushDevJob(jobId, versionData) {
|
|
5488
|
-
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/version/sandbox`, versionData, {
|
|
5489
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5490
|
-
});
|
|
5949
|
+
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/version/sandbox`, versionData, {});
|
|
5491
5950
|
}
|
|
5492
5951
|
/**
|
|
5493
5952
|
* Updates an existing development/sandbox version of a job
|
|
@@ -5498,9 +5957,7 @@ var init_job_api_service = __esm({
|
|
|
5498
5957
|
* @throws Error if the job or version is not found or the update fails
|
|
5499
5958
|
*/
|
|
5500
5959
|
async updateDevJob(jobId, sandboxVersionId, versionData) {
|
|
5501
|
-
return this.httpPut(`/developer/jobs/${this.agentId}/${jobId}/version/sandbox/${sandboxVersionId}`, versionData, {
|
|
5502
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5503
|
-
});
|
|
5960
|
+
return this.httpPut(`/developer/jobs/${this.agentId}/${jobId}/version/sandbox/${sandboxVersionId}`, versionData, {});
|
|
5504
5961
|
}
|
|
5505
5962
|
/**
|
|
5506
5963
|
* Retrieves all versions of a specific job
|
|
@@ -5509,9 +5966,7 @@ var init_job_api_service = __esm({
|
|
|
5509
5966
|
* @throws Error if the job is not found or the request fails
|
|
5510
5967
|
*/
|
|
5511
5968
|
async getJobVersions(jobId) {
|
|
5512
|
-
return this.httpGet(`/developer/jobs/${this.agentId}/${jobId}/versions`, {
|
|
5513
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5514
|
-
});
|
|
5969
|
+
return this.httpGet(`/developer/jobs/${this.agentId}/${jobId}/versions`, {});
|
|
5515
5970
|
}
|
|
5516
5971
|
/**
|
|
5517
5972
|
* Publishes a specific version of a job to production
|
|
@@ -5521,9 +5976,7 @@ var init_job_api_service = __esm({
|
|
|
5521
5976
|
* @throws Error if the job or version is not found or the publish operation fails
|
|
5522
5977
|
*/
|
|
5523
5978
|
async publishJobVersion(jobId, version) {
|
|
5524
|
-
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/${version}/publish`, {}, {
|
|
5525
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5526
|
-
});
|
|
5979
|
+
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/${version}/publish`, {}, {});
|
|
5527
5980
|
}
|
|
5528
5981
|
/**
|
|
5529
5982
|
* Deletes a job and all its versions, or deactivates it if it has versions
|
|
@@ -5534,9 +5987,7 @@ var init_job_api_service = __esm({
|
|
|
5534
5987
|
* @throws Error if the job is not found or the delete operation fails
|
|
5535
5988
|
*/
|
|
5536
5989
|
async deleteJob(jobId) {
|
|
5537
|
-
return this.httpDelete(`/developer/jobs/${this.agentId}/${jobId}`, {
|
|
5538
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5539
|
-
});
|
|
5990
|
+
return this.httpDelete(`/developer/jobs/${this.agentId}/${jobId}`, {});
|
|
5540
5991
|
}
|
|
5541
5992
|
/**
|
|
5542
5993
|
* Activates a job (enables it to run on schedule)
|
|
@@ -5545,9 +5996,7 @@ var init_job_api_service = __esm({
|
|
|
5545
5996
|
* @throws Error if the job is not found or the operation fails
|
|
5546
5997
|
*/
|
|
5547
5998
|
async activateJob(jobId) {
|
|
5548
|
-
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/activate`, {}, {
|
|
5549
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5550
|
-
});
|
|
5999
|
+
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/activate`, {}, {});
|
|
5551
6000
|
}
|
|
5552
6001
|
/**
|
|
5553
6002
|
* Deactivates a job (disables it from running)
|
|
@@ -5556,9 +6005,7 @@ var init_job_api_service = __esm({
|
|
|
5556
6005
|
* @throws Error if the job is not found or the operation fails
|
|
5557
6006
|
*/
|
|
5558
6007
|
async deactivateJob(jobId) {
|
|
5559
|
-
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/deactivate`, {}, {
|
|
5560
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5561
|
-
});
|
|
6008
|
+
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/deactivate`, {}, {});
|
|
5562
6009
|
}
|
|
5563
6010
|
/**
|
|
5564
6011
|
* Manually triggers a job execution (ignores schedule)
|
|
@@ -5571,9 +6018,7 @@ var init_job_api_service = __esm({
|
|
|
5571
6018
|
const body = versionId ? {
|
|
5572
6019
|
versionId
|
|
5573
6020
|
} : {};
|
|
5574
|
-
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/trigger`, body, {
|
|
5575
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5576
|
-
});
|
|
6021
|
+
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/trigger`, body, {});
|
|
5577
6022
|
}
|
|
5578
6023
|
/**
|
|
5579
6024
|
* Retrieves execution history for a job
|
|
@@ -5583,9 +6028,7 @@ var init_job_api_service = __esm({
|
|
|
5583
6028
|
* @throws Error if the job is not found or the request fails
|
|
5584
6029
|
*/
|
|
5585
6030
|
async getJobExecutions(jobId, limit = 50) {
|
|
5586
|
-
return this.httpGet(`/developer/jobs/${this.agentId}/${jobId}/executions?limit=${limit}`, {
|
|
5587
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5588
|
-
});
|
|
6031
|
+
return this.httpGet(`/developer/jobs/${this.agentId}/${jobId}/executions?limit=${limit}`, {});
|
|
5589
6032
|
}
|
|
5590
6033
|
/**
|
|
5591
6034
|
* Updates the metadata of a job
|
|
@@ -5595,9 +6038,7 @@ var init_job_api_service = __esm({
|
|
|
5595
6038
|
* @throws Error if the job is not found or the metadata update fails
|
|
5596
6039
|
*/
|
|
5597
6040
|
async updateMetadata(jobId, metadata) {
|
|
5598
|
-
return this.httpPut(`/developer/jobs/${this.agentId}/${jobId}/metadata`, metadata, {
|
|
5599
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5600
|
-
});
|
|
6041
|
+
return this.httpPut(`/developer/jobs/${this.agentId}/${jobId}/metadata`, metadata, {});
|
|
5601
6042
|
}
|
|
5602
6043
|
};
|
|
5603
6044
|
}
|
|
@@ -5614,15 +6055,12 @@ var init_ai_api_service = __esm({
|
|
|
5614
6055
|
static {
|
|
5615
6056
|
__name(this, "AiApiService");
|
|
5616
6057
|
}
|
|
5617
|
-
apiKey;
|
|
5618
6058
|
agentId;
|
|
5619
|
-
constructor(baseUrl,
|
|
5620
|
-
super(baseUrl
|
|
6059
|
+
constructor(baseUrl, credential, agentId) {
|
|
6060
|
+
super(baseUrl, credential), this.agentId = agentId;
|
|
5621
6061
|
}
|
|
5622
6062
|
async generate(body) {
|
|
5623
|
-
return this.httpPost(`/developer/ai/${this.agentId}/generate`, body, {
|
|
5624
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5625
|
-
});
|
|
6063
|
+
return this.httpPost(`/developer/ai/${this.agentId}/generate`, body, {});
|
|
5626
6064
|
}
|
|
5627
6065
|
/**
|
|
5628
6066
|
* Handles the simplified-vs-full-options branching for `AI.generate`.
|
|
@@ -5659,15 +6097,12 @@ var init_integrations_api_service = __esm({
|
|
|
5659
6097
|
static {
|
|
5660
6098
|
__name(this, "IntegrationsApiService");
|
|
5661
6099
|
}
|
|
5662
|
-
apiKey;
|
|
5663
6100
|
agentId;
|
|
5664
|
-
constructor(baseUrl,
|
|
5665
|
-
super(baseUrl
|
|
6101
|
+
constructor(baseUrl, credential, agentId) {
|
|
6102
|
+
super(baseUrl, credential), this.agentId = agentId;
|
|
5666
6103
|
}
|
|
5667
6104
|
async passthrough(integrationType, request) {
|
|
5668
|
-
return this.httpPost(`/developer/unifiedto/connections/${encodeURIComponent(this.agentId)}/passthrough/${encodeURIComponent(integrationType)}`, request, {
|
|
5669
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5670
|
-
});
|
|
6105
|
+
return this.httpPost(`/developer/unifiedto/connections/${encodeURIComponent(this.agentId)}/passthrough/${encodeURIComponent(integrationType)}`, request, {});
|
|
5671
6106
|
}
|
|
5672
6107
|
/**
|
|
5673
6108
|
* Sandbox-facing wrapper: returns the raw provider envelope
|
|
@@ -5696,9 +6131,8 @@ var init_agents_api_service = __esm({
|
|
|
5696
6131
|
static {
|
|
5697
6132
|
__name(this, "AgentsApiService");
|
|
5698
6133
|
}
|
|
5699
|
-
|
|
5700
|
-
|
|
5701
|
-
super(baseUrl), this.apiKey = apiKey;
|
|
6134
|
+
constructor(baseUrl, credential) {
|
|
6135
|
+
super(baseUrl, credential);
|
|
5702
6136
|
}
|
|
5703
6137
|
async invoke(targetAgentId, body) {
|
|
5704
6138
|
const channel = body.channel ?? "agent-invocation";
|
|
@@ -5707,9 +6141,7 @@ var init_agents_api_service = __esm({
|
|
|
5707
6141
|
});
|
|
5708
6142
|
if (body.identifier) query.set("identifier", body.identifier);
|
|
5709
6143
|
const chatBody = this.toChatGenerateBody(body);
|
|
5710
|
-
return this.
|
|
5711
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5712
|
-
});
|
|
6144
|
+
return this.httpPostCoreDrainRetry(`/chat/generate/${targetAgentId}?${query.toString()}`, chatBody, {});
|
|
5713
6145
|
}
|
|
5714
6146
|
/**
|
|
5715
6147
|
* Sandbox overload: mirrors the `AI.generate` pattern where the simplified
|
|
@@ -5770,17 +6202,15 @@ var init_whatsapp_templates_api_service = __esm({
|
|
|
5770
6202
|
static {
|
|
5771
6203
|
__name(this, "WhatsAppTemplatesApiService");
|
|
5772
6204
|
}
|
|
5773
|
-
apiKey;
|
|
5774
6205
|
agentId;
|
|
5775
6206
|
/**
|
|
5776
6207
|
* Creates an instance of WhatsAppTemplatesApiService
|
|
5777
6208
|
* @param baseUrl - The base URL for the API
|
|
5778
|
-
* @param
|
|
6209
|
+
* @param credential - The API key for authentication
|
|
5779
6210
|
* @param agentId - The unique identifier of the agent
|
|
5780
6211
|
*/
|
|
5781
|
-
constructor(baseUrl,
|
|
5782
|
-
super(baseUrl);
|
|
5783
|
-
this.apiKey = apiKey;
|
|
6212
|
+
constructor(baseUrl, credential, agentId) {
|
|
6213
|
+
super(baseUrl, credential);
|
|
5784
6214
|
this.agentId = agentId;
|
|
5785
6215
|
}
|
|
5786
6216
|
/**
|
|
@@ -5797,9 +6227,7 @@ var init_whatsapp_templates_api_service = __esm({
|
|
|
5797
6227
|
if (search) {
|
|
5798
6228
|
url += `&search=${encodeURIComponent(search)}`;
|
|
5799
6229
|
}
|
|
5800
|
-
const response = await this.httpGet(url, {
|
|
5801
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5802
|
-
});
|
|
6230
|
+
const response = await this.httpGet(url, {});
|
|
5803
6231
|
if (response.success) {
|
|
5804
6232
|
return response.data;
|
|
5805
6233
|
}
|
|
@@ -5813,9 +6241,7 @@ var init_whatsapp_templates_api_service = __esm({
|
|
|
5813
6241
|
*/
|
|
5814
6242
|
async get(channelId, templateId) {
|
|
5815
6243
|
const url = `/admin/agents/${this.agentId}/channels/${channelId}/whatsapp-templates/${templateId}`;
|
|
5816
|
-
const response = await this.httpGet(url, {
|
|
5817
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5818
|
-
});
|
|
6244
|
+
const response = await this.httpGet(url, {});
|
|
5819
6245
|
if (response.success) {
|
|
5820
6246
|
return response.data;
|
|
5821
6247
|
}
|
|
@@ -5834,9 +6260,7 @@ var init_whatsapp_templates_api_service = __esm({
|
|
|
5834
6260
|
phone_numbers: data.phoneNumbers,
|
|
5835
6261
|
values: data.values
|
|
5836
6262
|
};
|
|
5837
|
-
const response = await this.httpPost(url, body, {
|
|
5838
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5839
|
-
});
|
|
6263
|
+
const response = await this.httpPost(url, body, {});
|
|
5840
6264
|
if (response.success) {
|
|
5841
6265
|
return response.data;
|
|
5842
6266
|
}
|
|
@@ -5852,15 +6276,16 @@ var init_cdn_api_service = __esm({
|
|
|
5852
6276
|
"src/api/cdn.api.service.ts"() {
|
|
5853
6277
|
"use strict";
|
|
5854
6278
|
init_lua_fetch();
|
|
6279
|
+
init_request_credential();
|
|
5855
6280
|
CdnApi = class {
|
|
5856
6281
|
static {
|
|
5857
6282
|
__name(this, "CdnApi");
|
|
5858
6283
|
}
|
|
5859
6284
|
baseUrl;
|
|
5860
|
-
|
|
5861
|
-
constructor(baseUrl,
|
|
6285
|
+
credential;
|
|
6286
|
+
constructor(baseUrl, credential) {
|
|
5862
6287
|
this.baseUrl = baseUrl;
|
|
5863
|
-
this.
|
|
6288
|
+
this.credential = credential;
|
|
5864
6289
|
}
|
|
5865
6290
|
/**
|
|
5866
6291
|
* Uploads a file to the CDN
|
|
@@ -5873,7 +6298,7 @@ var init_cdn_api_service = __esm({
|
|
|
5873
6298
|
const response = await luaFetch(`${this.baseUrl}/upload`, {
|
|
5874
6299
|
method: "POST",
|
|
5875
6300
|
headers: {
|
|
5876
|
-
Authorization: `Bearer ${this.
|
|
6301
|
+
Authorization: `Bearer ${await bearerFor(this.credential)}`
|
|
5877
6302
|
},
|
|
5878
6303
|
body: formData
|
|
5879
6304
|
});
|
|
@@ -5917,17 +6342,15 @@ var init_developer_api_service = __esm({
|
|
|
5917
6342
|
static {
|
|
5918
6343
|
__name(this, "DeveloperApi");
|
|
5919
6344
|
}
|
|
5920
|
-
apiKey;
|
|
5921
6345
|
agentId;
|
|
5922
6346
|
/**
|
|
5923
6347
|
* Creates an instance of DeveloperApi
|
|
5924
6348
|
* @param baseUrl - The base URL for the API
|
|
5925
|
-
* @param
|
|
6349
|
+
* @param credential - The API key for authentication
|
|
5926
6350
|
* @param agentId - The unique identifier of the agent
|
|
5927
6351
|
*/
|
|
5928
|
-
constructor(baseUrl,
|
|
5929
|
-
super(baseUrl);
|
|
5930
|
-
this.apiKey = apiKey;
|
|
6352
|
+
constructor(baseUrl, credential, agentId) {
|
|
6353
|
+
super(baseUrl, credential);
|
|
5931
6354
|
this.agentId = agentId;
|
|
5932
6355
|
}
|
|
5933
6356
|
/**
|
|
@@ -5937,9 +6360,7 @@ var init_developer_api_service = __esm({
|
|
|
5937
6360
|
* @throws Error if the API request fails or the agent is not found
|
|
5938
6361
|
*/
|
|
5939
6362
|
async getEnvironmentVariables() {
|
|
5940
|
-
return this.httpGet(`/developer/agents/${this.agentId}/env`, {
|
|
5941
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5942
|
-
});
|
|
6363
|
+
return this.httpGet(`/developer/agents/${this.agentId}/env`, {});
|
|
5943
6364
|
}
|
|
5944
6365
|
/**
|
|
5945
6366
|
* Updates all environment variables for the agent in production
|
|
@@ -5949,9 +6370,7 @@ var init_developer_api_service = __esm({
|
|
|
5949
6370
|
* @throws Error if the API request fails or the agent is not found
|
|
5950
6371
|
*/
|
|
5951
6372
|
async updateEnvironmentVariables(envData) {
|
|
5952
|
-
return this.httpPost(`/developer/agents/${this.agentId}/env`, envData, {
|
|
5953
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5954
|
-
});
|
|
6373
|
+
return this.httpPost(`/developer/agents/${this.agentId}/env`, envData, {});
|
|
5955
6374
|
}
|
|
5956
6375
|
/**
|
|
5957
6376
|
* Deletes a specific environment variable by key
|
|
@@ -5960,27 +6379,21 @@ var init_developer_api_service = __esm({
|
|
|
5960
6379
|
* @throws Error if the API request fails, the agent is not found, or the key doesn't exist
|
|
5961
6380
|
*/
|
|
5962
6381
|
async deleteEnvironmentVariable(key) {
|
|
5963
|
-
return this.httpDelete(`/developer/agents/${this.agentId}/env/${key}`, {
|
|
5964
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5965
|
-
});
|
|
6382
|
+
return this.httpDelete(`/developer/agents/${this.agentId}/env/${key}`, {});
|
|
5966
6383
|
}
|
|
5967
6384
|
/**
|
|
5968
6385
|
* Retrieves all MCP server configurations for the agent
|
|
5969
6386
|
* @returns Promise resolving to an ApiResponse containing MCP server configurations
|
|
5970
6387
|
*/
|
|
5971
6388
|
async getMCPServers() {
|
|
5972
|
-
return this.httpGet(`/developer/agents/${this.agentId}/mcp-servers`, {
|
|
5973
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5974
|
-
});
|
|
6389
|
+
return this.httpGet(`/developer/agents/${this.agentId}/mcp-servers`, {});
|
|
5975
6390
|
}
|
|
5976
6391
|
/**
|
|
5977
6392
|
* Retrieves only active MCP server configurations for the agent
|
|
5978
6393
|
* @returns Promise resolving to an ApiResponse containing active MCP server configurations
|
|
5979
6394
|
*/
|
|
5980
6395
|
async getActiveMCPServers() {
|
|
5981
|
-
return this.httpGet(`/developer/agents/${this.agentId}/mcp-servers/active`, {
|
|
5982
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5983
|
-
});
|
|
6396
|
+
return this.httpGet(`/developer/agents/${this.agentId}/mcp-servers/active`, {});
|
|
5984
6397
|
}
|
|
5985
6398
|
/**
|
|
5986
6399
|
* Gets a single MCP server by ID
|
|
@@ -5988,9 +6401,7 @@ var init_developer_api_service = __esm({
|
|
|
5988
6401
|
* @returns Promise resolving to an ApiResponse with the MCP server
|
|
5989
6402
|
*/
|
|
5990
6403
|
async getMCPServer(mcpServerId) {
|
|
5991
|
-
return this.httpGet(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}`, {
|
|
5992
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5993
|
-
});
|
|
6404
|
+
return this.httpGet(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}`, {});
|
|
5994
6405
|
}
|
|
5995
6406
|
/**
|
|
5996
6407
|
* Creates a new MCP server
|
|
@@ -5998,9 +6409,7 @@ var init_developer_api_service = __esm({
|
|
|
5998
6409
|
* @returns Promise resolving to an ApiResponse with the created MCP server
|
|
5999
6410
|
*/
|
|
6000
6411
|
async createMCPServer(mcpServerData) {
|
|
6001
|
-
return this.httpPost(`/developer/agents/${this.agentId}/mcp-servers`, mcpServerData, {
|
|
6002
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6003
|
-
});
|
|
6412
|
+
return this.httpPost(`/developer/agents/${this.agentId}/mcp-servers`, mcpServerData, {});
|
|
6004
6413
|
}
|
|
6005
6414
|
/**
|
|
6006
6415
|
* Updates an existing MCP server
|
|
@@ -6009,9 +6418,7 @@ var init_developer_api_service = __esm({
|
|
|
6009
6418
|
* @returns Promise resolving to an ApiResponse with the updated MCP server
|
|
6010
6419
|
*/
|
|
6011
6420
|
async updateMCPServer(mcpServerId, mcpServerData) {
|
|
6012
|
-
return this.httpPut(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}`, mcpServerData, {
|
|
6013
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6014
|
-
});
|
|
6421
|
+
return this.httpPut(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}`, mcpServerData, {});
|
|
6015
6422
|
}
|
|
6016
6423
|
/**
|
|
6017
6424
|
* Deletes an MCP server
|
|
@@ -6019,9 +6426,7 @@ var init_developer_api_service = __esm({
|
|
|
6019
6426
|
* @returns Promise resolving to an ApiResponse with confirmation
|
|
6020
6427
|
*/
|
|
6021
6428
|
async deleteMCPServer(mcpServerId) {
|
|
6022
|
-
return this.httpDelete(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}`, {
|
|
6023
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6024
|
-
});
|
|
6429
|
+
return this.httpDelete(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}`, {});
|
|
6025
6430
|
}
|
|
6026
6431
|
/**
|
|
6027
6432
|
* Activates an MCP server
|
|
@@ -6029,9 +6434,7 @@ var init_developer_api_service = __esm({
|
|
|
6029
6434
|
* @returns Promise resolving to an ApiResponse with the activated MCP server
|
|
6030
6435
|
*/
|
|
6031
6436
|
async activateMCPServer(mcpServerId) {
|
|
6032
|
-
return this.httpPut(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}/activate`, {}, {
|
|
6033
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6034
|
-
});
|
|
6437
|
+
return this.httpPut(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}/activate`, {}, {});
|
|
6035
6438
|
}
|
|
6036
6439
|
/**
|
|
6037
6440
|
* Deactivates an MCP server
|
|
@@ -6039,9 +6442,7 @@ var init_developer_api_service = __esm({
|
|
|
6039
6442
|
* @returns Promise resolving to an ApiResponse with the deactivated MCP server
|
|
6040
6443
|
*/
|
|
6041
6444
|
async deactivateMCPServer(mcpServerId) {
|
|
6042
|
-
return this.httpPut(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}/deactivate`, {}, {
|
|
6043
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6044
|
-
});
|
|
6445
|
+
return this.httpPut(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}/deactivate`, {}, {});
|
|
6045
6446
|
}
|
|
6046
6447
|
/**
|
|
6047
6448
|
* Creates or updates an MCP server by name (upsert)
|
|
@@ -6049,9 +6450,7 @@ var init_developer_api_service = __esm({
|
|
|
6049
6450
|
* @returns Promise resolving to an ApiResponse with the created/updated MCP server
|
|
6050
6451
|
*/
|
|
6051
6452
|
async upsertMCPServer(mcpServerData) {
|
|
6052
|
-
return this.httpPost(`/developer/agents/${this.agentId}/mcp-servers/upsert`, mcpServerData, {
|
|
6053
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6054
|
-
});
|
|
6453
|
+
return this.httpPost(`/developer/agents/${this.agentId}/mcp-servers/upsert`, mcpServerData, {});
|
|
6055
6454
|
}
|
|
6056
6455
|
/**
|
|
6057
6456
|
* Gets a user profile by email address
|
|
@@ -6061,9 +6460,7 @@ var init_developer_api_service = __esm({
|
|
|
6061
6460
|
async getUserProfileByEmail(email, agentId) {
|
|
6062
6461
|
const path3 = `/developer/user/profile/email/${encodeURIComponent(email)}`;
|
|
6063
6462
|
const scopedPath = agentId ? `${path3}?agentId=${encodeURIComponent(agentId)}` : path3;
|
|
6064
|
-
return this.httpGet(scopedPath, {
|
|
6065
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6066
|
-
});
|
|
6463
|
+
return this.httpGet(scopedPath, {});
|
|
6067
6464
|
}
|
|
6068
6465
|
/**
|
|
6069
6466
|
* Gets a user profile by phone number
|
|
@@ -6074,9 +6471,7 @@ var init_developer_api_service = __esm({
|
|
|
6074
6471
|
const normalizedPhone = phone.replace(/^\+/, "");
|
|
6075
6472
|
const path3 = `/developer/user/profile/phone/${normalizedPhone}`;
|
|
6076
6473
|
const scopedPath = agentId ? `${path3}?agentId=${encodeURIComponent(agentId)}` : path3;
|
|
6077
|
-
return this.httpGet(scopedPath, {
|
|
6078
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6079
|
-
});
|
|
6474
|
+
return this.httpGet(scopedPath, {});
|
|
6080
6475
|
}
|
|
6081
6476
|
};
|
|
6082
6477
|
}
|
|
@@ -6092,42 +6487,28 @@ var init_voice_api_service = __esm({
|
|
|
6092
6487
|
static {
|
|
6093
6488
|
__name(this, "VoiceApi");
|
|
6094
6489
|
}
|
|
6095
|
-
apiKey;
|
|
6096
6490
|
agentId;
|
|
6097
|
-
constructor(baseUrl,
|
|
6098
|
-
super(baseUrl);
|
|
6099
|
-
this.apiKey = apiKey;
|
|
6491
|
+
constructor(baseUrl, credential, agentId) {
|
|
6492
|
+
super(baseUrl, credential);
|
|
6100
6493
|
this.agentId = agentId;
|
|
6101
6494
|
}
|
|
6102
6495
|
async getVoices() {
|
|
6103
|
-
return this.httpGet(`/developer/voice-agents/${this.agentId}`, {
|
|
6104
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6105
|
-
});
|
|
6496
|
+
return this.httpGet(`/developer/voice-agents/${this.agentId}`, {});
|
|
6106
6497
|
}
|
|
6107
6498
|
async createVoice(voiceData) {
|
|
6108
|
-
return this.httpPost(`/developer/voice-agents/${this.agentId}`, voiceData, {
|
|
6109
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6110
|
-
});
|
|
6499
|
+
return this.httpPost(`/developer/voice-agents/${this.agentId}`, voiceData, {});
|
|
6111
6500
|
}
|
|
6112
6501
|
async pushVoice(voiceId, versionData) {
|
|
6113
|
-
return this.httpPost(`/developer/voice-agents/${this.agentId}/${voiceId}/version`, versionData, {
|
|
6114
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6115
|
-
});
|
|
6502
|
+
return this.httpPost(`/developer/voice-agents/${this.agentId}/${voiceId}/version`, versionData, {});
|
|
6116
6503
|
}
|
|
6117
6504
|
async getVoiceVersions(voiceId) {
|
|
6118
|
-
return this.httpGet(`/developer/voice-agents/${this.agentId}/${voiceId}/versions`, {
|
|
6119
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6120
|
-
});
|
|
6505
|
+
return this.httpGet(`/developer/voice-agents/${this.agentId}/${voiceId}/versions`, {});
|
|
6121
6506
|
}
|
|
6122
6507
|
async publishVoiceVersion(voiceId, version) {
|
|
6123
|
-
return this.httpPut(`/developer/voice-agents/${this.agentId}/${voiceId}/${version}/publish`, void 0, {
|
|
6124
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6125
|
-
});
|
|
6508
|
+
return this.httpPut(`/developer/voice-agents/${this.agentId}/${voiceId}/${version}/publish`, void 0, {});
|
|
6126
6509
|
}
|
|
6127
6510
|
async deleteVoice(voiceId) {
|
|
6128
|
-
return this.httpDelete(`/developer/voice-agents/${this.agentId}/${voiceId}`, {
|
|
6129
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6130
|
-
});
|
|
6511
|
+
return this.httpDelete(`/developer/voice-agents/${this.agentId}/${voiceId}`, {});
|
|
6131
6512
|
}
|
|
6132
6513
|
/**
|
|
6133
6514
|
* Place an outbound voice call. Wraps `POST /developer/voice-agents/:agentId/dispatch`
|
|
@@ -6135,9 +6516,7 @@ var init_voice_api_service = __esm({
|
|
|
6135
6516
|
* forwarded to the lua-livekit worker which allocates the room and dials.
|
|
6136
6517
|
*/
|
|
6137
6518
|
async dispatch(input) {
|
|
6138
|
-
return this.httpPost(`/developer/voice-agents/${this.agentId}/dispatch`, input, {
|
|
6139
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6140
|
-
});
|
|
6519
|
+
return this.httpPost(`/developer/voice-agents/${this.agentId}/dispatch`, input, {});
|
|
6141
6520
|
}
|
|
6142
6521
|
/**
|
|
6143
6522
|
* Create a voice room + client access token for a custom frontend
|
|
@@ -6146,9 +6525,7 @@ var init_voice_api_service = __esm({
|
|
|
6146
6525
|
* user. Wraps `POST /developer/voice/:agentId/session`.
|
|
6147
6526
|
*/
|
|
6148
6527
|
async createSession(input = {}) {
|
|
6149
|
-
return this.httpPost(`/developer/voice/${this.agentId}/session`, input, {
|
|
6150
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6151
|
-
});
|
|
6528
|
+
return this.httpPost(`/developer/voice/${this.agentId}/session`, input, {});
|
|
6152
6529
|
}
|
|
6153
6530
|
/**
|
|
6154
6531
|
* Sandbox helper: throws on non-success and returns the unwrapped output.
|
|
@@ -6192,34 +6569,25 @@ var init_channels_send_api_service = __esm({
|
|
|
6192
6569
|
static {
|
|
6193
6570
|
__name(this, "ChannelsSendApiService");
|
|
6194
6571
|
}
|
|
6195
|
-
apiKey;
|
|
6196
6572
|
agentId;
|
|
6197
|
-
constructor(baseUrl,
|
|
6198
|
-
super(baseUrl
|
|
6573
|
+
constructor(baseUrl, credential, agentId) {
|
|
6574
|
+
super(baseUrl, credential), this.agentId = agentId;
|
|
6199
6575
|
}
|
|
6200
6576
|
/** POST /developer/agents/:agentId/channels/send */
|
|
6201
6577
|
async send(input) {
|
|
6202
|
-
return this.httpPost(`/developer/agents/${this.agentId}/channels/send`, input, {
|
|
6203
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6204
|
-
});
|
|
6578
|
+
return this.httpPost(`/developer/agents/${this.agentId}/channels/send`, input, {});
|
|
6205
6579
|
}
|
|
6206
6580
|
/** POST /developer/agents/:agentId/channels/whatsapp/template */
|
|
6207
6581
|
async sendWhatsAppTemplate(input) {
|
|
6208
|
-
return this.httpPost(`/developer/agents/${this.agentId}/channels/whatsapp/template`, input, {
|
|
6209
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6210
|
-
});
|
|
6582
|
+
return this.httpPost(`/developer/agents/${this.agentId}/channels/whatsapp/template`, input, {});
|
|
6211
6583
|
}
|
|
6212
6584
|
/** POST /developer/agents/:agentId/channels/whatsapp/reaction */
|
|
6213
6585
|
async sendWhatsAppReaction(input) {
|
|
6214
|
-
return this.httpPost(`/developer/agents/${this.agentId}/channels/whatsapp/reaction`, input, {
|
|
6215
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6216
|
-
});
|
|
6586
|
+
return this.httpPost(`/developer/agents/${this.agentId}/channels/whatsapp/reaction`, input, {});
|
|
6217
6587
|
}
|
|
6218
6588
|
/** POST /developer/agents/:agentId/channels/email/send */
|
|
6219
6589
|
async sendEmail(input) {
|
|
6220
|
-
return this.httpPost(`/developer/agents/${this.agentId}/channels/email/send`, input, {
|
|
6221
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6222
|
-
});
|
|
6590
|
+
return this.httpPost(`/developer/agents/${this.agentId}/channels/email/send`, input, {});
|
|
6223
6591
|
}
|
|
6224
6592
|
/**
|
|
6225
6593
|
* Sandbox helper: throws on non-success, returns unwrapped output.
|
|
@@ -6282,16 +6650,13 @@ var init_inbox_push_api_service = __esm({
|
|
|
6282
6650
|
static {
|
|
6283
6651
|
__name(this, "InboxPushApiService");
|
|
6284
6652
|
}
|
|
6285
|
-
apiKey;
|
|
6286
6653
|
agentId;
|
|
6287
|
-
constructor(baseUrl,
|
|
6288
|
-
super(baseUrl
|
|
6654
|
+
constructor(baseUrl, credential, agentId) {
|
|
6655
|
+
super(baseUrl, credential), this.agentId = agentId;
|
|
6289
6656
|
}
|
|
6290
6657
|
/** POST /developer/agents/:agentId/inbox/push */
|
|
6291
6658
|
async push(input) {
|
|
6292
|
-
return this.httpPost(`/developer/agents/${this.agentId}/inbox/push`, input, {
|
|
6293
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6294
|
-
});
|
|
6659
|
+
return this.httpPost(`/developer/agents/${this.agentId}/inbox/push`, input, {});
|
|
6295
6660
|
}
|
|
6296
6661
|
};
|
|
6297
6662
|
}
|
|
@@ -6307,18 +6672,15 @@ var init_directory_api_service = __esm({
|
|
|
6307
6672
|
static {
|
|
6308
6673
|
__name(this, "DirectoryApiService");
|
|
6309
6674
|
}
|
|
6310
|
-
apiKey;
|
|
6311
6675
|
agentId;
|
|
6312
|
-
constructor(baseUrl,
|
|
6313
|
-
super(baseUrl
|
|
6676
|
+
constructor(baseUrl, credential, agentId) {
|
|
6677
|
+
super(baseUrl, credential), this.agentId = agentId;
|
|
6314
6678
|
}
|
|
6315
6679
|
/** POST /developer/agents/:agentId/directory/resolve */
|
|
6316
6680
|
async resolve(name) {
|
|
6317
6681
|
return this.httpPost(`/developer/agents/${this.agentId}/directory/resolve`, {
|
|
6318
6682
|
name
|
|
6319
|
-
}, {
|
|
6320
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6321
|
-
});
|
|
6683
|
+
}, {});
|
|
6322
6684
|
}
|
|
6323
6685
|
/** Sandbox helper: throws on non-success, returns unwrapped result. */
|
|
6324
6686
|
async resolveForSandbox(name) {
|
|
@@ -6349,71 +6711,47 @@ var init_device_api_service = __esm({
|
|
|
6349
6711
|
static {
|
|
6350
6712
|
__name(this, "DeviceApi");
|
|
6351
6713
|
}
|
|
6352
|
-
apiKey;
|
|
6353
6714
|
agentId;
|
|
6354
|
-
constructor(baseUrl,
|
|
6355
|
-
super(baseUrl);
|
|
6356
|
-
this.apiKey = apiKey;
|
|
6715
|
+
constructor(baseUrl, credential, agentId) {
|
|
6716
|
+
super(baseUrl, credential);
|
|
6357
6717
|
this.agentId = agentId;
|
|
6358
6718
|
}
|
|
6359
6719
|
async getDevices() {
|
|
6360
|
-
return this.httpGet(`/developer/devices/${this.agentId}`, {
|
|
6361
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6362
|
-
});
|
|
6720
|
+
return this.httpGet(`/developer/devices/${this.agentId}`, {});
|
|
6363
6721
|
}
|
|
6364
6722
|
async createDevice(deviceData) {
|
|
6365
|
-
return this.httpPost(`/developer/devices/${this.agentId}`, deviceData, {
|
|
6366
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6367
|
-
});
|
|
6723
|
+
return this.httpPost(`/developer/devices/${this.agentId}`, deviceData, {});
|
|
6368
6724
|
}
|
|
6369
6725
|
async pushDevice(deviceId, versionData) {
|
|
6370
|
-
return this.httpPost(`/developer/devices/${this.agentId}/${deviceId}/version`, versionData, {
|
|
6371
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6372
|
-
});
|
|
6726
|
+
return this.httpPost(`/developer/devices/${this.agentId}/${deviceId}/version`, versionData, {});
|
|
6373
6727
|
}
|
|
6374
6728
|
async pushDevDevice(deviceId, versionData) {
|
|
6375
|
-
return this.httpPost(`/developer/devices/${this.agentId}/${deviceId}/version/sandbox`, versionData, {
|
|
6376
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6377
|
-
});
|
|
6729
|
+
return this.httpPost(`/developer/devices/${this.agentId}/${deviceId}/version/sandbox`, versionData, {});
|
|
6378
6730
|
}
|
|
6379
6731
|
async getDeviceVersions(deviceId) {
|
|
6380
|
-
return this.httpGet(`/developer/devices/${this.agentId}/${deviceId}/versions`, {
|
|
6381
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6382
|
-
});
|
|
6732
|
+
return this.httpGet(`/developer/devices/${this.agentId}/${deviceId}/versions`, {});
|
|
6383
6733
|
}
|
|
6384
6734
|
async publishDeviceVersion(deviceId, version) {
|
|
6385
|
-
return this.httpPost(`/developer/devices/${this.agentId}/${deviceId}/${version}/publish`, {}, {
|
|
6386
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6387
|
-
});
|
|
6735
|
+
return this.httpPost(`/developer/devices/${this.agentId}/${deviceId}/${version}/publish`, {}, {});
|
|
6388
6736
|
}
|
|
6389
6737
|
async deleteDevice(deviceId) {
|
|
6390
|
-
return this.httpDelete(`/developer/devices/${this.agentId}/${deviceId}`, {
|
|
6391
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6392
|
-
});
|
|
6738
|
+
return this.httpDelete(`/developer/devices/${this.agentId}/${deviceId}`, {});
|
|
6393
6739
|
}
|
|
6394
6740
|
async sendCommand(deviceName, command, payload, timeout) {
|
|
6395
6741
|
return this.httpPost(`/developer/devices/${this.agentId}/${deviceName}/command`, {
|
|
6396
6742
|
command,
|
|
6397
6743
|
payload,
|
|
6398
6744
|
timeout: timeout || 3e4
|
|
6399
|
-
}, {
|
|
6400
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6401
|
-
});
|
|
6745
|
+
}, {});
|
|
6402
6746
|
}
|
|
6403
6747
|
async getDeviceStatus(deviceName) {
|
|
6404
|
-
return this.httpGet(`/developer/devices/${this.agentId}/${deviceName}/status`, {
|
|
6405
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6406
|
-
});
|
|
6748
|
+
return this.httpGet(`/developer/devices/${this.agentId}/${deviceName}/status`, {});
|
|
6407
6749
|
}
|
|
6408
6750
|
async enableDevice(deviceName) {
|
|
6409
|
-
return this.httpPatch(`/developer/devices/${this.agentId}/${deviceName}/enable`, {}, {
|
|
6410
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6411
|
-
});
|
|
6751
|
+
return this.httpPatch(`/developer/devices/${this.agentId}/${deviceName}/enable`, {}, {});
|
|
6412
6752
|
}
|
|
6413
6753
|
async disableDevice(deviceName) {
|
|
6414
|
-
return this.httpPatch(`/developer/devices/${this.agentId}/${deviceName}/disable`, {}, {
|
|
6415
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6416
|
-
});
|
|
6754
|
+
return this.httpPatch(`/developer/devices/${this.agentId}/${deviceName}/disable`, {}, {});
|
|
6417
6755
|
}
|
|
6418
6756
|
};
|
|
6419
6757
|
}
|