lua-cli 3.27.0 → 3.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -8
- package/dist/api-exports.d.ts +81 -7
- package/dist/api-exports.js +1065 -478
- package/dist/api-exports.js.map +1 -1
- package/dist/index.js +2870 -1907
- package/dist/index.js.map +1 -1
- package/docs/CLI_REFERENCE.md +5 -1
- package/docs/README.md +2 -3
- package/docs/api/LuaWebhook.md +26 -0
- package/package.json +3 -3
- package/template/package.json +1 -1
package/dist/api-exports.js
CHANGED
|
@@ -16,6 +16,8 @@ var __export = (target, all) => {
|
|
|
16
16
|
|
|
17
17
|
// ../shared-types/dist/index.mjs
|
|
18
18
|
import { z } from "zod";
|
|
19
|
+
import { z as z2 } from "zod";
|
|
20
|
+
import { z as z3 } from "zod";
|
|
19
21
|
function isPersonaTextObject(value) {
|
|
20
22
|
if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
|
|
21
23
|
const obj = value;
|
|
@@ -384,7 +386,99 @@ function normalizeLuaJobExecutionTimeoutSeconds(timeout) {
|
|
|
384
386
|
}
|
|
385
387
|
return Math.min(Math.max(timeout, LUA_JOB_MIN_TIMEOUT_SECONDS), LUA_JOB_MAX_TIMEOUT_SECONDS);
|
|
386
388
|
}
|
|
387
|
-
|
|
389
|
+
function triggerUrlEnvKey(triggerKey) {
|
|
390
|
+
const upper = triggerKey.trim().replace(/[^A-Za-z0-9]+/g, "_").replace(/^_+|_+$/g, "").toUpperCase();
|
|
391
|
+
return `${TEMPLATE_TRIGGER_URL_ENV_PREFIX}${upper}`;
|
|
392
|
+
}
|
|
393
|
+
function deviceCredentialScopes(operations) {
|
|
394
|
+
return [
|
|
395
|
+
...new Set(operations.map((operation) => DEVICE_SCOPE_BY_OPERATION[operation]))
|
|
396
|
+
];
|
|
397
|
+
}
|
|
398
|
+
function parsePrincipalContext(value) {
|
|
399
|
+
const parsed = PrincipalContextSchema.safeParse(value);
|
|
400
|
+
return parsed.success ? parsed.data : void 0;
|
|
401
|
+
}
|
|
402
|
+
function isDeviceCredentialPrincipal(context) {
|
|
403
|
+
return context?.credential.type === "deviceCredential";
|
|
404
|
+
}
|
|
405
|
+
function hasDeviceCredentialType(value) {
|
|
406
|
+
return DeviceCredentialClaimSchema.safeParse(value).success;
|
|
407
|
+
}
|
|
408
|
+
function isTypedApiKeyPrincipal(context) {
|
|
409
|
+
return context?.subject.subjectType === "apiKey" && context.credential.type === "apiKey" && !context.compatibility;
|
|
410
|
+
}
|
|
411
|
+
function typedApiKeyPrincipalId(context) {
|
|
412
|
+
if (!context || !isTypedApiKeyPrincipal(context) || !context.subject.subjectId || context.credential.id !== context.subject.subjectId || context.actor?.actorType !== "apiKey" || context.actor.actorId !== context.subject.subjectId || context.owner?.type !== "user" || !context.owner.id) {
|
|
413
|
+
return void 0;
|
|
414
|
+
}
|
|
415
|
+
return context.subject.subjectId;
|
|
416
|
+
}
|
|
417
|
+
function parseLuaClientHeader(value) {
|
|
418
|
+
if (typeof value !== "string" || value.length > 64) return void 0;
|
|
419
|
+
const match = CLIENT_HEADER_PATTERN.exec(value.trim());
|
|
420
|
+
if (!match) return void 0;
|
|
421
|
+
const app = LUA_CLIENT_APPS.find((candidate) => candidate === match[1]);
|
|
422
|
+
if (!app) return void 0;
|
|
423
|
+
const wireVersion = match[2];
|
|
424
|
+
if (wireVersion === "unversioned") return {
|
|
425
|
+
app,
|
|
426
|
+
version: "unknown",
|
|
427
|
+
attribution: "unknown"
|
|
428
|
+
};
|
|
429
|
+
const semver = SEMVER_PATTERN.exec(wireVersion);
|
|
430
|
+
if (semver) return {
|
|
431
|
+
app,
|
|
432
|
+
version: semver[1],
|
|
433
|
+
attribution: "known"
|
|
434
|
+
};
|
|
435
|
+
if (app === "web" && WEB_RELEASE_PATTERN.test(wireVersion)) {
|
|
436
|
+
return {
|
|
437
|
+
app,
|
|
438
|
+
version: wireVersion.toLowerCase(),
|
|
439
|
+
attribution: "known"
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
return void 0;
|
|
443
|
+
}
|
|
444
|
+
function serializeLuaClientHeader(client) {
|
|
445
|
+
if (!client) return void 0;
|
|
446
|
+
return `${client.app}/${client.version === "unknown" ? "unversioned" : client.version}`;
|
|
447
|
+
}
|
|
448
|
+
function formatLuaClientHeader(app, version) {
|
|
449
|
+
if (typeof version !== "string") return `${app}/unversioned`;
|
|
450
|
+
const normalized = version.trim();
|
|
451
|
+
if (SEMVER_PATTERN.test(normalized)) return `${app}/${normalized}`;
|
|
452
|
+
if (app === "web" && WEB_RELEASE_PATTERN.test(normalized)) return `${app}/${normalized.toLowerCase()}`;
|
|
453
|
+
return `${app}/unversioned`;
|
|
454
|
+
}
|
|
455
|
+
function luaClientMetricLabels(client) {
|
|
456
|
+
const canonical = parseLuaClientHeader(serializeLuaClientHeader(client));
|
|
457
|
+
return {
|
|
458
|
+
client_family: canonical?.app ?? "unknown",
|
|
459
|
+
client_version: canonical?.version ?? "unknown",
|
|
460
|
+
client_attribution: canonical?.attribution ?? "unknown"
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
function parseEffectiveAuthorization(value) {
|
|
464
|
+
const parsed = EffectiveAuthorizationSchema.safeParse(value);
|
|
465
|
+
return parsed.success ? parsed.data : void 0;
|
|
466
|
+
}
|
|
467
|
+
function parseResourcePage(value) {
|
|
468
|
+
const parsed = ResourcePageSchema.safeParse(value);
|
|
469
|
+
return parsed.success ? parsed.data : void 0;
|
|
470
|
+
}
|
|
471
|
+
function capabilitiesFor(profiles, profileId) {
|
|
472
|
+
if (!profileId) return [];
|
|
473
|
+
return profiles[profileId] ?? [];
|
|
474
|
+
}
|
|
475
|
+
function isKnownProfile(profiles, profileId) {
|
|
476
|
+
return profileId !== void 0 && Object.prototype.hasOwnProperty.call(profiles, profileId);
|
|
477
|
+
}
|
|
478
|
+
function hasCapability(profiles, profileId, required) {
|
|
479
|
+
return capabilitiesFor(profiles, profileId).includes(required);
|
|
480
|
+
}
|
|
481
|
+
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, 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;
|
|
388
482
|
var init_dist = __esm({
|
|
389
483
|
"../shared-types/dist/index.mjs"() {
|
|
390
484
|
"use strict";
|
|
@@ -1049,6 +1143,307 @@ This text is who you are for this person. As you learn them, their name, their w
|
|
|
1049
1143
|
__name2(resolveLuaJobTimeoutSeconds, "resolveLuaJobTimeoutSeconds");
|
|
1050
1144
|
__name(normalizeLuaJobExecutionTimeoutSeconds, "normalizeLuaJobExecutionTimeoutSeconds");
|
|
1051
1145
|
__name2(normalizeLuaJobExecutionTimeoutSeconds, "normalizeLuaJobExecutionTimeoutSeconds");
|
|
1146
|
+
TEMPLATE_TRIGGER_URL_ENV_PREFIX = "LUA_TRIGGER_URL__";
|
|
1147
|
+
__name(triggerUrlEnvKey, "triggerUrlEnvKey");
|
|
1148
|
+
__name2(triggerUrlEnvKey, "triggerUrlEnvKey");
|
|
1149
|
+
SUBJECT_TYPES = [
|
|
1150
|
+
"user",
|
|
1151
|
+
"apiKey",
|
|
1152
|
+
"service",
|
|
1153
|
+
"endUser",
|
|
1154
|
+
"staff"
|
|
1155
|
+
];
|
|
1156
|
+
SubjectTypeSchema = z2.enum(SUBJECT_TYPES);
|
|
1157
|
+
CREDENTIAL_TYPES = [
|
|
1158
|
+
"firstPartySession",
|
|
1159
|
+
"apiKey",
|
|
1160
|
+
"deviceCredential",
|
|
1161
|
+
"endUserSession",
|
|
1162
|
+
"staffAssertion",
|
|
1163
|
+
"serviceCredential",
|
|
1164
|
+
"legacyInternalToken"
|
|
1165
|
+
];
|
|
1166
|
+
CredentialTypeSchema = z2.enum(CREDENTIAL_TYPES);
|
|
1167
|
+
DEVICE_OPERATIONS = [
|
|
1168
|
+
"commands",
|
|
1169
|
+
"triggers",
|
|
1170
|
+
"assets.upload"
|
|
1171
|
+
];
|
|
1172
|
+
DeviceOperationSchema = z2.enum(DEVICE_OPERATIONS);
|
|
1173
|
+
DEVICE_SCOPE_BY_OPERATION = {
|
|
1174
|
+
commands: "automations:write",
|
|
1175
|
+
triggers: "automations:write",
|
|
1176
|
+
"assets.upload": "files:write"
|
|
1177
|
+
};
|
|
1178
|
+
__name(deviceCredentialScopes, "deviceCredentialScopes");
|
|
1179
|
+
__name2(deviceCredentialScopes, "deviceCredentialScopes");
|
|
1180
|
+
DeviceBindingSchema = z2.object({
|
|
1181
|
+
agentId: z2.string().min(1).max(256),
|
|
1182
|
+
deviceName: z2.string().min(1).max(256),
|
|
1183
|
+
operations: z2.array(DeviceOperationSchema).min(1).max(DEVICE_OPERATIONS.length)
|
|
1184
|
+
}).strict().superRefine((binding, context) => {
|
|
1185
|
+
if (new Set(binding.operations).size !== binding.operations.length) {
|
|
1186
|
+
context.addIssue({
|
|
1187
|
+
code: z2.ZodIssueCode.custom,
|
|
1188
|
+
path: [
|
|
1189
|
+
"operations"
|
|
1190
|
+
],
|
|
1191
|
+
message: "Device operations must be unique"
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
});
|
|
1195
|
+
IdSchema = z2.string().min(1).max(256);
|
|
1196
|
+
PrincipalDescriptorSchema = z2.object({
|
|
1197
|
+
subjectType: SubjectTypeSchema,
|
|
1198
|
+
subjectId: IdSchema
|
|
1199
|
+
}).strict();
|
|
1200
|
+
ActorDescriptorSchema = z2.object({
|
|
1201
|
+
actorType: SubjectTypeSchema,
|
|
1202
|
+
actorId: IdSchema
|
|
1203
|
+
}).strict();
|
|
1204
|
+
PrincipalOwnerSchema = z2.object({
|
|
1205
|
+
type: z2.enum([
|
|
1206
|
+
"user",
|
|
1207
|
+
"org",
|
|
1208
|
+
"service"
|
|
1209
|
+
]),
|
|
1210
|
+
id: IdSchema
|
|
1211
|
+
}).strict();
|
|
1212
|
+
CredentialLifecycleSchema = {
|
|
1213
|
+
id: IdSchema.optional(),
|
|
1214
|
+
issuedAt: z2.number().int().nonnegative().optional(),
|
|
1215
|
+
expiresAt: z2.number().int().nonnegative().optional()
|
|
1216
|
+
};
|
|
1217
|
+
GeneralCredentialDescriptorSchema = z2.object({
|
|
1218
|
+
type: z2.enum([
|
|
1219
|
+
"firstPartySession",
|
|
1220
|
+
"apiKey",
|
|
1221
|
+
"endUserSession",
|
|
1222
|
+
"staffAssertion",
|
|
1223
|
+
"serviceCredential",
|
|
1224
|
+
"legacyInternalToken"
|
|
1225
|
+
]),
|
|
1226
|
+
...CredentialLifecycleSchema
|
|
1227
|
+
}).strict();
|
|
1228
|
+
DeviceCredentialDescriptorSchema = z2.object({
|
|
1229
|
+
type: z2.literal("deviceCredential"),
|
|
1230
|
+
id: IdSchema,
|
|
1231
|
+
issuedAt: z2.number().int().nonnegative().optional(),
|
|
1232
|
+
expiresAt: z2.number().int().nonnegative().optional(),
|
|
1233
|
+
secretVersion: z2.number().int().positive(),
|
|
1234
|
+
device: DeviceBindingSchema
|
|
1235
|
+
}).strict();
|
|
1236
|
+
GeneralPrincipalContextSchema = z2.object({
|
|
1237
|
+
version: z2.literal(1),
|
|
1238
|
+
subject: PrincipalDescriptorSchema,
|
|
1239
|
+
actor: ActorDescriptorSchema.optional(),
|
|
1240
|
+
credential: GeneralCredentialDescriptorSchema,
|
|
1241
|
+
owner: PrincipalOwnerSchema.optional(),
|
|
1242
|
+
compatibility: z2.object({
|
|
1243
|
+
mode: z2.literal("legacy-owner-delegation")
|
|
1244
|
+
}).strict().optional()
|
|
1245
|
+
}).strict();
|
|
1246
|
+
DeviceCredentialPrincipalContextSchema = z2.object({
|
|
1247
|
+
version: z2.literal(1),
|
|
1248
|
+
subject: z2.object({
|
|
1249
|
+
subjectType: z2.literal("apiKey"),
|
|
1250
|
+
subjectId: IdSchema
|
|
1251
|
+
}).strict(),
|
|
1252
|
+
actor: z2.object({
|
|
1253
|
+
actorType: z2.literal("apiKey"),
|
|
1254
|
+
actorId: IdSchema
|
|
1255
|
+
}).strict(),
|
|
1256
|
+
credential: DeviceCredentialDescriptorSchema,
|
|
1257
|
+
owner: z2.object({
|
|
1258
|
+
type: z2.literal("user"),
|
|
1259
|
+
id: IdSchema
|
|
1260
|
+
}).strict()
|
|
1261
|
+
}).strict().superRefine((context, refinement) => {
|
|
1262
|
+
const credentialId = context.credential.id;
|
|
1263
|
+
if (context.subject.subjectId !== credentialId) {
|
|
1264
|
+
refinement.addIssue({
|
|
1265
|
+
code: z2.ZodIssueCode.custom,
|
|
1266
|
+
path: [
|
|
1267
|
+
"subject",
|
|
1268
|
+
"subjectId"
|
|
1269
|
+
],
|
|
1270
|
+
message: "Device credential subject must match its credential id"
|
|
1271
|
+
});
|
|
1272
|
+
}
|
|
1273
|
+
if (context.actor.actorId !== credentialId) {
|
|
1274
|
+
refinement.addIssue({
|
|
1275
|
+
code: z2.ZodIssueCode.custom,
|
|
1276
|
+
path: [
|
|
1277
|
+
"actor",
|
|
1278
|
+
"actorId"
|
|
1279
|
+
],
|
|
1280
|
+
message: "Device credential actor must match its credential id"
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
1283
|
+
});
|
|
1284
|
+
RawPrincipalContextSchema = z2.union([
|
|
1285
|
+
DeviceCredentialPrincipalContextSchema,
|
|
1286
|
+
GeneralPrincipalContextSchema
|
|
1287
|
+
]);
|
|
1288
|
+
PrincipalContextSchema = z2.custom((value) => RawPrincipalContextSchema.safeParse(value).success, "Invalid principal context");
|
|
1289
|
+
__name(parsePrincipalContext, "parsePrincipalContext");
|
|
1290
|
+
__name2(parsePrincipalContext, "parsePrincipalContext");
|
|
1291
|
+
__name(isDeviceCredentialPrincipal, "isDeviceCredentialPrincipal");
|
|
1292
|
+
__name2(isDeviceCredentialPrincipal, "isDeviceCredentialPrincipal");
|
|
1293
|
+
DeviceCredentialClaimSchema = z2.object({
|
|
1294
|
+
credential: z2.object({
|
|
1295
|
+
type: z2.literal("deviceCredential")
|
|
1296
|
+
}).passthrough()
|
|
1297
|
+
}).passthrough();
|
|
1298
|
+
__name(hasDeviceCredentialType, "hasDeviceCredentialType");
|
|
1299
|
+
__name2(hasDeviceCredentialType, "hasDeviceCredentialType");
|
|
1300
|
+
__name(isTypedApiKeyPrincipal, "isTypedApiKeyPrincipal");
|
|
1301
|
+
__name2(isTypedApiKeyPrincipal, "isTypedApiKeyPrincipal");
|
|
1302
|
+
__name(typedApiKeyPrincipalId, "typedApiKeyPrincipalId");
|
|
1303
|
+
__name2(typedApiKeyPrincipalId, "typedApiKeyPrincipalId");
|
|
1304
|
+
LUA_CLIENT_HEADER = "X-Lua-Client";
|
|
1305
|
+
LUA_CLIENT_APPS = [
|
|
1306
|
+
"desktop",
|
|
1307
|
+
"web",
|
|
1308
|
+
"cli",
|
|
1309
|
+
"mobile",
|
|
1310
|
+
"claude-plugin",
|
|
1311
|
+
"codex-plugin",
|
|
1312
|
+
"cursor-plugin",
|
|
1313
|
+
"platform-mcp",
|
|
1314
|
+
"device-node",
|
|
1315
|
+
"device-python",
|
|
1316
|
+
"device-micropython"
|
|
1317
|
+
];
|
|
1318
|
+
SEMVER_PATTERN = /^(\d{1,3}\.\d{1,3}\.\d{1,3})(?:-[0-9A-Za-z.-]{1,16})?(?:\+[0-9A-Za-z.-]{1,16})?$/;
|
|
1319
|
+
WEB_RELEASE_PATTERN = /^[0-9a-f]{12}$/i;
|
|
1320
|
+
CLIENT_HEADER_PATTERN = /^([^/]+)\/(.+)$/;
|
|
1321
|
+
__name(parseLuaClientHeader, "parseLuaClientHeader");
|
|
1322
|
+
__name2(parseLuaClientHeader, "parseLuaClientHeader");
|
|
1323
|
+
__name(serializeLuaClientHeader, "serializeLuaClientHeader");
|
|
1324
|
+
__name2(serializeLuaClientHeader, "serializeLuaClientHeader");
|
|
1325
|
+
__name(formatLuaClientHeader, "formatLuaClientHeader");
|
|
1326
|
+
__name2(formatLuaClientHeader, "formatLuaClientHeader");
|
|
1327
|
+
__name(luaClientMetricLabels, "luaClientMetricLabels");
|
|
1328
|
+
__name2(luaClientMetricLabels, "luaClientMetricLabels");
|
|
1329
|
+
AUTHZ_PROJECTION_VERSION = 1;
|
|
1330
|
+
ProjectedScopeSchema = z3.string().min(1).max(128);
|
|
1331
|
+
DisplayRoleSchema = z3.object({
|
|
1332
|
+
role: z3.string().min(1).max(128),
|
|
1333
|
+
boundTo: z3.enum([
|
|
1334
|
+
"org",
|
|
1335
|
+
"agent",
|
|
1336
|
+
"platform"
|
|
1337
|
+
]),
|
|
1338
|
+
resourceId: z3.string().min(1).max(256)
|
|
1339
|
+
}).passthrough();
|
|
1340
|
+
AuthorizationPrincipalSchema = z3.object({
|
|
1341
|
+
subjectType: SubjectTypeSchema,
|
|
1342
|
+
subjectId: z3.string().min(1).max(256)
|
|
1343
|
+
}).passthrough();
|
|
1344
|
+
CredentialContextSchema = z3.object({
|
|
1345
|
+
type: CredentialTypeSchema,
|
|
1346
|
+
id: z3.string().min(1).max(256).optional(),
|
|
1347
|
+
owner: z3.object({
|
|
1348
|
+
type: z3.enum([
|
|
1349
|
+
"user",
|
|
1350
|
+
"org",
|
|
1351
|
+
"service"
|
|
1352
|
+
]),
|
|
1353
|
+
id: z3.string().min(1).max(256)
|
|
1354
|
+
}).passthrough().optional(),
|
|
1355
|
+
compatibility: z3.object({
|
|
1356
|
+
mode: z3.literal("legacy-owner-delegation")
|
|
1357
|
+
}).passthrough().optional()
|
|
1358
|
+
}).passthrough();
|
|
1359
|
+
ProjectionAnomalySchema = z3.enum([
|
|
1360
|
+
"grant-without-membership",
|
|
1361
|
+
"live-grant-on-inactive-membership"
|
|
1362
|
+
]);
|
|
1363
|
+
ProjectedOrgSchema = z3.object({
|
|
1364
|
+
orgId: z3.string().min(1).max(256),
|
|
1365
|
+
name: z3.string().optional(),
|
|
1366
|
+
archived: z3.boolean(),
|
|
1367
|
+
/** Key into `capabilityProfiles`. */
|
|
1368
|
+
capabilityProfile: z3.string().min(1).max(64),
|
|
1369
|
+
displayRoles: z3.array(DisplayRoleSchema),
|
|
1370
|
+
/** Product data — notifications, ordering, labels. NEVER an authorization input. */
|
|
1371
|
+
membership: z3.object({
|
|
1372
|
+
rostered: z3.boolean(),
|
|
1373
|
+
active: z3.boolean()
|
|
1374
|
+
}).passthrough(),
|
|
1375
|
+
discoveredVia: z3.enum([
|
|
1376
|
+
"org-grant",
|
|
1377
|
+
"agent-grant-only"
|
|
1378
|
+
]).describe("For user and staff principals, grant provenance: org-grant means a stored org grant produced the row. For owner-ceiling API keys, effective provenance: org-grant means the credential-owner intersection has org-level capability; agent-grant-only means the intersection reaches only an exact agent inside the org."),
|
|
1379
|
+
anomalies: z3.array(ProjectionAnomalySchema).optional()
|
|
1380
|
+
}).passthrough();
|
|
1381
|
+
ProjectedResourceSchema = z3.object({
|
|
1382
|
+
resourceType: z3.literal("agent"),
|
|
1383
|
+
resourceId: z3.string().min(1).max(256),
|
|
1384
|
+
kind: z3.enum([
|
|
1385
|
+
"agent",
|
|
1386
|
+
"space"
|
|
1387
|
+
]),
|
|
1388
|
+
/** `null` for an org-less platform agent. */
|
|
1389
|
+
orgId: z3.string().min(1).max(256).nullable(),
|
|
1390
|
+
name: z3.string().optional(),
|
|
1391
|
+
visibility: z3.enum([
|
|
1392
|
+
"private",
|
|
1393
|
+
"public",
|
|
1394
|
+
"platform"
|
|
1395
|
+
]),
|
|
1396
|
+
capabilityProfile: z3.string().min(1).max(64),
|
|
1397
|
+
displayRoles: z3.array(DisplayRoleSchema),
|
|
1398
|
+
discoveredVia: z3.enum([
|
|
1399
|
+
"org-cascade",
|
|
1400
|
+
"agent-grant",
|
|
1401
|
+
"owner-override",
|
|
1402
|
+
"platform-allowlist"
|
|
1403
|
+
]),
|
|
1404
|
+
/** Product data only. A roster row confers nothing. */
|
|
1405
|
+
rostered: z3.boolean()
|
|
1406
|
+
}).passthrough();
|
|
1407
|
+
CapabilityProfilesSchema = z3.record(z3.string().min(1).max(64), z3.array(ProjectedScopeSchema));
|
|
1408
|
+
RoleCatalogSchema = z3.record(z3.string().min(1).max(128), z3.object({
|
|
1409
|
+
label: z3.string()
|
|
1410
|
+
}).passthrough());
|
|
1411
|
+
EffectiveAuthorizationSchema = z3.object({
|
|
1412
|
+
version: z3.literal(AUTHZ_PROJECTION_VERSION),
|
|
1413
|
+
generatedAt: z3.string().min(1),
|
|
1414
|
+
authorizationPrincipal: AuthorizationPrincipalSchema,
|
|
1415
|
+
credentialContext: CredentialContextSchema.optional(),
|
|
1416
|
+
orgs: z3.array(ProjectedOrgSchema),
|
|
1417
|
+
/**
|
|
1418
|
+
* Present only when the caller holds platform grants. This is what replaces a
|
|
1419
|
+
* client-side staff check: staff-ness is a scope on a resource, not an email
|
|
1420
|
+
* suffix and not a boolean that would read `false` on an ordinary session.
|
|
1421
|
+
*/
|
|
1422
|
+
platform: z3.object({
|
|
1423
|
+
capabilityProfile: z3.string().min(1).max(64)
|
|
1424
|
+
}).passthrough().optional(),
|
|
1425
|
+
capabilityProfiles: CapabilityProfilesSchema,
|
|
1426
|
+
roleCatalog: RoleCatalogSchema.optional()
|
|
1427
|
+
}).passthrough();
|
|
1428
|
+
ResourcePageSchema = z3.object({
|
|
1429
|
+
version: z3.literal(AUTHZ_PROJECTION_VERSION),
|
|
1430
|
+
generatedAt: z3.string().min(1),
|
|
1431
|
+
orgId: z3.string().min(1).max(256),
|
|
1432
|
+
resources: z3.array(ProjectedResourceSchema),
|
|
1433
|
+
capabilityProfiles: CapabilityProfilesSchema,
|
|
1434
|
+
/** `null` = last page. Opaque; do not construct one. */
|
|
1435
|
+
nextCursor: z3.string().nullable().describe("Opaque continuation. A non-null value may accompany a short or empty resource page when the server reaches its per-request scan cap; clients must continue until null.")
|
|
1436
|
+
}).passthrough();
|
|
1437
|
+
__name(parseEffectiveAuthorization, "parseEffectiveAuthorization");
|
|
1438
|
+
__name2(parseEffectiveAuthorization, "parseEffectiveAuthorization");
|
|
1439
|
+
__name(parseResourcePage, "parseResourcePage");
|
|
1440
|
+
__name2(parseResourcePage, "parseResourcePage");
|
|
1441
|
+
__name(capabilitiesFor, "capabilitiesFor");
|
|
1442
|
+
__name2(capabilitiesFor, "capabilitiesFor");
|
|
1443
|
+
__name(isKnownProfile, "isKnownProfile");
|
|
1444
|
+
__name2(isKnownProfile, "isKnownProfile");
|
|
1445
|
+
__name(hasCapability, "hasCapability");
|
|
1446
|
+
__name2(hasCapability, "hasCapability");
|
|
1052
1447
|
}
|
|
1053
1448
|
});
|
|
1054
1449
|
|
|
@@ -1070,7 +1465,7 @@ var init_baskets = __esm({
|
|
|
1070
1465
|
// src/config/constants.ts
|
|
1071
1466
|
import { join } from "path";
|
|
1072
1467
|
import { homedir } from "os";
|
|
1073
|
-
var CLI_CONFIG_DIR, VERSION_CHECK_FILE, TELEMETRY_FILE, CLI_CACHE_FILE, BASE_URLS, CREDENTIALS_FILE, SANDBOX_STORAGE_FILE, AUTH_STORAGE_FILE;
|
|
1468
|
+
var CLI_CONFIG_DIR, VERSION_CHECK_FILE, TELEMETRY_FILE, CLI_CACHE_FILE, BASE_URLS, CREDENTIALS_FILE, FIREBASE_WEB_API_KEY, SANDBOX_STORAGE_FILE, AUTH_STORAGE_FILE;
|
|
1074
1469
|
var init_constants = __esm({
|
|
1075
1470
|
"src/config/constants.ts"() {
|
|
1076
1471
|
"use strict";
|
|
@@ -1086,6 +1481,7 @@ var init_constants = __esm({
|
|
|
1086
1481
|
CDN: "https://cdn.heylua.ai"
|
|
1087
1482
|
};
|
|
1088
1483
|
CREDENTIALS_FILE = join(CLI_CONFIG_DIR, "credentials");
|
|
1484
|
+
FIREBASE_WEB_API_KEY = process.env.LUA_FIREBASE_WEB_API_KEY || "AIzaSyAGI0AxOz6UmtJgwFIA_UNTuYUEgQRRGhw";
|
|
1089
1485
|
SANDBOX_STORAGE_FILE = join(CLI_CONFIG_DIR, "sandbox.json");
|
|
1090
1486
|
AUTH_STORAGE_FILE = join(CLI_CONFIG_DIR, "auth.json");
|
|
1091
1487
|
}
|
|
@@ -1134,24 +1530,465 @@ var init_auth_error = __esm({
|
|
|
1134
1530
|
}
|
|
1135
1531
|
});
|
|
1136
1532
|
|
|
1533
|
+
// src/utils/package-root.ts
|
|
1534
|
+
import { readFileSync, existsSync } from "fs";
|
|
1535
|
+
import { fileURLToPath, pathToFileURL } from "url";
|
|
1536
|
+
import { dirname, join as join2 } from "path";
|
|
1537
|
+
function locate() {
|
|
1538
|
+
if (cachedRoot && cachedPkg) return {
|
|
1539
|
+
root: cachedRoot,
|
|
1540
|
+
pkg: cachedPkg
|
|
1541
|
+
};
|
|
1542
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
1543
|
+
while (true) {
|
|
1544
|
+
const candidate = join2(dir, "package.json");
|
|
1545
|
+
if (existsSync(candidate)) {
|
|
1546
|
+
try {
|
|
1547
|
+
const parsed = JSON.parse(readFileSync(candidate, "utf8"));
|
|
1548
|
+
if (parsed?.name === "lua-cli") {
|
|
1549
|
+
cachedRoot = dir;
|
|
1550
|
+
cachedPkg = parsed;
|
|
1551
|
+
return {
|
|
1552
|
+
root: dir,
|
|
1553
|
+
pkg: parsed
|
|
1554
|
+
};
|
|
1555
|
+
}
|
|
1556
|
+
} catch {
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
const parent = dirname(dir);
|
|
1560
|
+
if (parent === dir) break;
|
|
1561
|
+
dir = parent;
|
|
1562
|
+
}
|
|
1563
|
+
throw new Error("Could not locate lua-cli package root from " + fileURLToPath(import.meta.url));
|
|
1564
|
+
}
|
|
1565
|
+
function getCliVersion() {
|
|
1566
|
+
try {
|
|
1567
|
+
return locate().pkg.version;
|
|
1568
|
+
} catch {
|
|
1569
|
+
return "0.0.0";
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
var cachedRoot, cachedPkg;
|
|
1573
|
+
var init_package_root = __esm({
|
|
1574
|
+
"src/utils/package-root.ts"() {
|
|
1575
|
+
"use strict";
|
|
1576
|
+
cachedRoot = null;
|
|
1577
|
+
cachedPkg = null;
|
|
1578
|
+
__name(locate, "locate");
|
|
1579
|
+
__name(getCliVersion, "getCliVersion");
|
|
1580
|
+
}
|
|
1581
|
+
});
|
|
1582
|
+
|
|
1583
|
+
// src/utils/lua-fetch.ts
|
|
1584
|
+
function luaClientHeaderValue() {
|
|
1585
|
+
return formatLuaClientHeader("cli", getCliVersion());
|
|
1586
|
+
}
|
|
1587
|
+
function headerRecord(headers) {
|
|
1588
|
+
if (!headers) return {};
|
|
1589
|
+
if (headers instanceof Headers) return Object.fromEntries(headers.entries());
|
|
1590
|
+
if (Array.isArray(headers)) return Object.fromEntries(headers);
|
|
1591
|
+
const record = {};
|
|
1592
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
1593
|
+
if (typeof value === "string") record[name] = value;
|
|
1594
|
+
}
|
|
1595
|
+
return record;
|
|
1596
|
+
}
|
|
1597
|
+
function luaFetch(input, init = {}) {
|
|
1598
|
+
const headers = headerRecord(init.headers);
|
|
1599
|
+
for (const name of Object.keys(headers)) {
|
|
1600
|
+
if (name.toLowerCase() === LUA_CLIENT_HEADER.toLowerCase()) delete headers[name];
|
|
1601
|
+
}
|
|
1602
|
+
headers[LUA_CLIENT_HEADER] = luaClientHeaderValue();
|
|
1603
|
+
return fetch(input, {
|
|
1604
|
+
...init,
|
|
1605
|
+
headers
|
|
1606
|
+
});
|
|
1607
|
+
}
|
|
1608
|
+
var init_lua_fetch = __esm({
|
|
1609
|
+
"src/utils/lua-fetch.ts"() {
|
|
1610
|
+
"use strict";
|
|
1611
|
+
init_dist();
|
|
1612
|
+
init_package_root();
|
|
1613
|
+
__name(luaClientHeaderValue, "luaClientHeaderValue");
|
|
1614
|
+
__name(headerRecord, "headerRecord");
|
|
1615
|
+
__name(luaFetch, "luaFetch");
|
|
1616
|
+
}
|
|
1617
|
+
});
|
|
1618
|
+
|
|
1619
|
+
// src/services/firebase-session.ts
|
|
1620
|
+
function requireFirebaseWebApiKey() {
|
|
1621
|
+
if (!FIREBASE_WEB_API_KEY) {
|
|
1622
|
+
throw new Error("Firebase sign-in is not configured for this CLI build.");
|
|
1623
|
+
}
|
|
1624
|
+
return FIREBASE_WEB_API_KEY;
|
|
1625
|
+
}
|
|
1626
|
+
function parseFirebaseSession(json, now = Date.now()) {
|
|
1627
|
+
const idToken = json.idToken ?? json.id_token;
|
|
1628
|
+
const refreshToken = json.refreshToken ?? json.refresh_token;
|
|
1629
|
+
const expiresIn = Number(json.expiresIn ?? json.expires_in);
|
|
1630
|
+
const uid = json.localId ?? json.user_id;
|
|
1631
|
+
if (typeof idToken !== "string" || idToken.length === 0 || typeof refreshToken !== "string" || refreshToken.length === 0 || typeof uid !== "string" || uid.length === 0 || !Number.isFinite(expiresIn) || expiresIn <= 0) {
|
|
1632
|
+
throw new Error("Sign-in failed because Firebase returned an invalid session.");
|
|
1633
|
+
}
|
|
1634
|
+
return {
|
|
1635
|
+
idToken,
|
|
1636
|
+
refreshToken,
|
|
1637
|
+
expiresAt: now + expiresIn * 1e3,
|
|
1638
|
+
uid
|
|
1639
|
+
};
|
|
1640
|
+
}
|
|
1641
|
+
async function parseFirebaseError(response) {
|
|
1642
|
+
try {
|
|
1643
|
+
const body = await response.json();
|
|
1644
|
+
const message = body.error?.message;
|
|
1645
|
+
return typeof message === "string" && message ? message.split(":")[0].trim() : response.statusText;
|
|
1646
|
+
} catch {
|
|
1647
|
+
return response.statusText;
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
async function fetchFirebase(url, init, timeoutMessage) {
|
|
1651
|
+
const controller = new AbortController();
|
|
1652
|
+
let timeoutId;
|
|
1653
|
+
const timeout = new Promise((_resolve, reject) => {
|
|
1654
|
+
timeoutId = setTimeout(() => {
|
|
1655
|
+
reject(new Error(timeoutMessage));
|
|
1656
|
+
controller.abort();
|
|
1657
|
+
}, FIREBASE_REQUEST_TIMEOUT_MS);
|
|
1658
|
+
});
|
|
1659
|
+
try {
|
|
1660
|
+
return await Promise.race([
|
|
1661
|
+
fetch(url, {
|
|
1662
|
+
...init,
|
|
1663
|
+
signal: controller.signal
|
|
1664
|
+
}),
|
|
1665
|
+
timeout
|
|
1666
|
+
]);
|
|
1667
|
+
} finally {
|
|
1668
|
+
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
async function refreshFirebaseSession(session) {
|
|
1672
|
+
const key = requireFirebaseWebApiKey();
|
|
1673
|
+
const response = await fetchFirebase(`${FIREBASE_REFRESH_URL}?key=${encodeURIComponent(key)}`, {
|
|
1674
|
+
method: "POST",
|
|
1675
|
+
headers: {
|
|
1676
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
1677
|
+
},
|
|
1678
|
+
body: new URLSearchParams({
|
|
1679
|
+
grant_type: "refresh_token",
|
|
1680
|
+
refresh_token: session.refreshToken
|
|
1681
|
+
}).toString()
|
|
1682
|
+
}, "Firebase session refresh timed out after 15 seconds.");
|
|
1683
|
+
if (!response.ok) {
|
|
1684
|
+
throw new Error(`Firebase session refresh failed: ${await parseFirebaseError(response)}`);
|
|
1685
|
+
}
|
|
1686
|
+
const refreshed = parseFirebaseSession(await response.json());
|
|
1687
|
+
if (refreshed.uid !== session.uid) throw new Error("Firebase session refresh returned a different identity.");
|
|
1688
|
+
return refreshed;
|
|
1689
|
+
}
|
|
1690
|
+
var FIREBASE_REFRESH_URL, FIREBASE_REQUEST_TIMEOUT_MS;
|
|
1691
|
+
var init_firebase_session = __esm({
|
|
1692
|
+
"src/services/firebase-session.ts"() {
|
|
1693
|
+
"use strict";
|
|
1694
|
+
init_constants();
|
|
1695
|
+
FIREBASE_REFRESH_URL = "https://securetoken.googleapis.com/v1/token";
|
|
1696
|
+
FIREBASE_REQUEST_TIMEOUT_MS = 15e3;
|
|
1697
|
+
__name(requireFirebaseWebApiKey, "requireFirebaseWebApiKey");
|
|
1698
|
+
__name(parseFirebaseSession, "parseFirebaseSession");
|
|
1699
|
+
__name(parseFirebaseError, "parseFirebaseError");
|
|
1700
|
+
__name(fetchFirebase, "fetchFirebase");
|
|
1701
|
+
__name(refreshFirebaseSession, "refreshFirebaseSession");
|
|
1702
|
+
}
|
|
1703
|
+
});
|
|
1704
|
+
|
|
1705
|
+
// src/services/firebase-session-store.ts
|
|
1706
|
+
import { createHash, randomUUID } from "crypto";
|
|
1707
|
+
import { mkdir, open, readFile, rename, unlink } from "fs/promises";
|
|
1708
|
+
import { join as join3 } from "path";
|
|
1709
|
+
import { z as z4 } from "zod";
|
|
1710
|
+
function environmentKey(environment) {
|
|
1711
|
+
return createHash("sha256").update(`${environment.apiUrl}
|
|
1712
|
+
${environment.authUrl}
|
|
1713
|
+
${environment.firebaseWebApiKey}`).digest("hex").slice(0, 16);
|
|
1714
|
+
}
|
|
1715
|
+
function isMissing(error) {
|
|
1716
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
|
|
1717
|
+
}
|
|
1718
|
+
var storedFirebaseSessionSchema, currentFirebaseSessionEnvironment, wait, FirebaseSessionStore;
|
|
1719
|
+
var init_firebase_session_store = __esm({
|
|
1720
|
+
"src/services/firebase-session-store.ts"() {
|
|
1721
|
+
"use strict";
|
|
1722
|
+
init_constants();
|
|
1723
|
+
storedFirebaseSessionSchema = z4.object({
|
|
1724
|
+
version: z4.literal(1),
|
|
1725
|
+
kind: z4.literal("firebase-session"),
|
|
1726
|
+
generation: z4.string().min(1),
|
|
1727
|
+
refreshToken: z4.string().min(1),
|
|
1728
|
+
firebaseUid: z4.string().min(1),
|
|
1729
|
+
apiUrl: z4.string().url(),
|
|
1730
|
+
authUrl: z4.string().url(),
|
|
1731
|
+
firebaseWebApiKey: z4.string().min(1)
|
|
1732
|
+
});
|
|
1733
|
+
currentFirebaseSessionEnvironment = /* @__PURE__ */ __name(() => ({
|
|
1734
|
+
apiUrl: BASE_URLS.API,
|
|
1735
|
+
authUrl: BASE_URLS.AUTH,
|
|
1736
|
+
firebaseWebApiKey: FIREBASE_WEB_API_KEY
|
|
1737
|
+
}), "currentFirebaseSessionEnvironment");
|
|
1738
|
+
__name(environmentKey, "environmentKey");
|
|
1739
|
+
__name(isMissing, "isMissing");
|
|
1740
|
+
wait = /* @__PURE__ */ __name((milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds)), "wait");
|
|
1741
|
+
FirebaseSessionStore = class {
|
|
1742
|
+
static {
|
|
1743
|
+
__name(this, "FirebaseSessionStore");
|
|
1744
|
+
}
|
|
1745
|
+
environment;
|
|
1746
|
+
directory;
|
|
1747
|
+
constructor(root = CLI_CONFIG_DIR, environment = currentFirebaseSessionEnvironment()) {
|
|
1748
|
+
this.environment = environment;
|
|
1749
|
+
this.directory = join3(root, "sessions");
|
|
1750
|
+
}
|
|
1751
|
+
path() {
|
|
1752
|
+
return join3(this.directory, `${environmentKey(this.environment)}.json`);
|
|
1753
|
+
}
|
|
1754
|
+
async read() {
|
|
1755
|
+
let raw;
|
|
1756
|
+
try {
|
|
1757
|
+
raw = await readFile(this.path(), "utf8");
|
|
1758
|
+
} catch (error) {
|
|
1759
|
+
if (isMissing(error)) return null;
|
|
1760
|
+
throw error;
|
|
1761
|
+
}
|
|
1762
|
+
let decoded;
|
|
1763
|
+
try {
|
|
1764
|
+
decoded = JSON.parse(raw);
|
|
1765
|
+
} catch {
|
|
1766
|
+
throw new Error("The stored Lua CLI session is invalid. Run `lua auth configure` again.");
|
|
1767
|
+
}
|
|
1768
|
+
const parsed = storedFirebaseSessionSchema.safeParse(decoded);
|
|
1769
|
+
if (!parsed.success) throw new Error("The stored Lua CLI session is invalid. Run `lua auth configure` again.");
|
|
1770
|
+
if (parsed.data.apiUrl !== this.environment.apiUrl || parsed.data.authUrl !== this.environment.authUrl || parsed.data.firebaseWebApiKey !== this.environment.firebaseWebApiKey) {
|
|
1771
|
+
throw new Error("The stored Lua CLI session belongs to a different environment.");
|
|
1772
|
+
}
|
|
1773
|
+
return parsed.data;
|
|
1774
|
+
}
|
|
1775
|
+
async replace(session) {
|
|
1776
|
+
storedFirebaseSessionSchema.parse(session);
|
|
1777
|
+
if (session.apiUrl !== this.environment.apiUrl || session.authUrl !== this.environment.authUrl || session.firebaseWebApiKey !== this.environment.firebaseWebApiKey) {
|
|
1778
|
+
throw new Error("Cannot store a Lua CLI session for a different environment.");
|
|
1779
|
+
}
|
|
1780
|
+
await this.withLock(async () => this.write(session));
|
|
1781
|
+
}
|
|
1782
|
+
async update(operation) {
|
|
1783
|
+
return this.withLock(async () => {
|
|
1784
|
+
const next = await operation(await this.read());
|
|
1785
|
+
if (next) await this.write(next);
|
|
1786
|
+
else await this.remove();
|
|
1787
|
+
return next;
|
|
1788
|
+
});
|
|
1789
|
+
}
|
|
1790
|
+
async clearIfGeneration(generation) {
|
|
1791
|
+
let cleared = false;
|
|
1792
|
+
await this.update(async (current) => {
|
|
1793
|
+
if (!current || current.generation !== generation) return current;
|
|
1794
|
+
cleared = true;
|
|
1795
|
+
return null;
|
|
1796
|
+
});
|
|
1797
|
+
return cleared;
|
|
1798
|
+
}
|
|
1799
|
+
async write(session) {
|
|
1800
|
+
await mkdir(this.directory, {
|
|
1801
|
+
recursive: true,
|
|
1802
|
+
mode: 448
|
|
1803
|
+
});
|
|
1804
|
+
const temporaryPath = join3(this.directory, `.${environmentKey(this.environment)}.${randomUUID()}.tmp`);
|
|
1805
|
+
const handle = await open(temporaryPath, "wx", 384);
|
|
1806
|
+
try {
|
|
1807
|
+
await handle.writeFile(`${JSON.stringify(session)}
|
|
1808
|
+
`, "utf8");
|
|
1809
|
+
await handle.sync();
|
|
1810
|
+
} finally {
|
|
1811
|
+
await handle.close();
|
|
1812
|
+
}
|
|
1813
|
+
await rename(temporaryPath, this.path());
|
|
1814
|
+
}
|
|
1815
|
+
async remove() {
|
|
1816
|
+
try {
|
|
1817
|
+
await unlink(this.path());
|
|
1818
|
+
} catch (error) {
|
|
1819
|
+
if (!isMissing(error)) throw error;
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
async withLock(operation) {
|
|
1823
|
+
await mkdir(this.directory, {
|
|
1824
|
+
recursive: true,
|
|
1825
|
+
mode: 448
|
|
1826
|
+
});
|
|
1827
|
+
const lockPath = `${this.path()}.lock`;
|
|
1828
|
+
const lockOwner = randomUUID();
|
|
1829
|
+
const deadline = Date.now() + 2e4;
|
|
1830
|
+
while (true) {
|
|
1831
|
+
try {
|
|
1832
|
+
const handle = await open(lockPath, "wx", 384);
|
|
1833
|
+
try {
|
|
1834
|
+
await handle.writeFile(lockOwner, "utf8");
|
|
1835
|
+
await handle.sync();
|
|
1836
|
+
} finally {
|
|
1837
|
+
await handle.close();
|
|
1838
|
+
}
|
|
1839
|
+
break;
|
|
1840
|
+
} catch (error) {
|
|
1841
|
+
const code = typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
|
|
1842
|
+
if (code !== "EEXIST") throw error;
|
|
1843
|
+
if (Date.now() >= deadline) {
|
|
1844
|
+
throw new Error("Timed out waiting for another Lua CLI process to finish updating the session.");
|
|
1845
|
+
}
|
|
1846
|
+
await wait(50);
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
try {
|
|
1850
|
+
return await operation();
|
|
1851
|
+
} finally {
|
|
1852
|
+
try {
|
|
1853
|
+
if (await readFile(lockPath, "utf8") === lockOwner) await unlink(lockPath);
|
|
1854
|
+
} catch (error) {
|
|
1855
|
+
if (!isMissing(error)) throw error;
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
};
|
|
1860
|
+
}
|
|
1861
|
+
});
|
|
1862
|
+
|
|
1863
|
+
// src/services/request-credential.ts
|
|
1864
|
+
import "dotenv/config";
|
|
1865
|
+
import { readFileSync as readFileSync2, unlinkSync } from "fs";
|
|
1866
|
+
function loadStoredApiKey() {
|
|
1867
|
+
try {
|
|
1868
|
+
return readFileSync2(CREDENTIALS_FILE, "utf8").trim() || null;
|
|
1869
|
+
} catch {
|
|
1870
|
+
return null;
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
function isRequestCredential(value) {
|
|
1874
|
+
return typeof value !== "string";
|
|
1875
|
+
}
|
|
1876
|
+
async function bearerFor(credential) {
|
|
1877
|
+
return isRequestCredential(credential) ? credential.bearer() : credential;
|
|
1878
|
+
}
|
|
1879
|
+
async function resolveRequestCredential() {
|
|
1880
|
+
if (process.env.LUA_API_KEY) return new StaticRequestCredential(process.env.LUA_API_KEY, "environment");
|
|
1881
|
+
const store = new FirebaseSessionStore();
|
|
1882
|
+
const session = await store.read();
|
|
1883
|
+
if (session) return new FirebaseRequestCredential(store, session);
|
|
1884
|
+
const storedApiKey = loadStoredApiKey();
|
|
1885
|
+
if (storedApiKey) return new StaticRequestCredential(storedApiKey, "stored");
|
|
1886
|
+
throw new AuthenticationError("No Lua CLI authentication found. Run `lua auth configure` or set LUA_API_KEY.", "invalid_credentials", void 0, true);
|
|
1887
|
+
}
|
|
1888
|
+
var StaticRequestCredential, FirebaseRequestCredential;
|
|
1889
|
+
var init_request_credential = __esm({
|
|
1890
|
+
"src/services/request-credential.ts"() {
|
|
1891
|
+
"use strict";
|
|
1892
|
+
init_constants();
|
|
1893
|
+
init_auth_error();
|
|
1894
|
+
init_lua_fetch();
|
|
1895
|
+
init_firebase_session();
|
|
1896
|
+
init_firebase_session_store();
|
|
1897
|
+
__name(loadStoredApiKey, "loadStoredApiKey");
|
|
1898
|
+
__name(isRequestCredential, "isRequestCredential");
|
|
1899
|
+
__name(bearerFor, "bearerFor");
|
|
1900
|
+
StaticRequestCredential = class StaticRequestCredential2 {
|
|
1901
|
+
static {
|
|
1902
|
+
__name(this, "StaticRequestCredential");
|
|
1903
|
+
}
|
|
1904
|
+
apiKey;
|
|
1905
|
+
descriptor;
|
|
1906
|
+
constructor(apiKey, source) {
|
|
1907
|
+
this.apiKey = apiKey;
|
|
1908
|
+
this.descriptor = {
|
|
1909
|
+
kind: "api-key",
|
|
1910
|
+
source
|
|
1911
|
+
};
|
|
1912
|
+
}
|
|
1913
|
+
async bearer() {
|
|
1914
|
+
return this.apiKey;
|
|
1915
|
+
}
|
|
1916
|
+
};
|
|
1917
|
+
FirebaseRequestCredential = class FirebaseRequestCredential2 {
|
|
1918
|
+
static {
|
|
1919
|
+
__name(this, "FirebaseRequestCredential");
|
|
1920
|
+
}
|
|
1921
|
+
store;
|
|
1922
|
+
descriptor;
|
|
1923
|
+
liveSession;
|
|
1924
|
+
refresh;
|
|
1925
|
+
constructor(store, stored) {
|
|
1926
|
+
this.store = store;
|
|
1927
|
+
this.descriptor = {
|
|
1928
|
+
kind: "first-party-session",
|
|
1929
|
+
source: "stored",
|
|
1930
|
+
uid: stored.firebaseUid
|
|
1931
|
+
};
|
|
1932
|
+
}
|
|
1933
|
+
async bearer() {
|
|
1934
|
+
if (this.liveSession && this.liveSession.expiresAt - Date.now() > 6e4) return this.liveSession.idToken;
|
|
1935
|
+
if (!this.refresh) this.refresh = this.refreshBearer().finally(() => this.refresh = void 0);
|
|
1936
|
+
return this.refresh;
|
|
1937
|
+
}
|
|
1938
|
+
async refreshBearer() {
|
|
1939
|
+
let live;
|
|
1940
|
+
await this.store.update(async (stored) => {
|
|
1941
|
+
if (!stored) {
|
|
1942
|
+
throw new AuthenticationError("Your Lua CLI session has expired. Run `lua auth configure`.", "invalid_credentials");
|
|
1943
|
+
}
|
|
1944
|
+
live = await refreshFirebaseSession({
|
|
1945
|
+
idToken: "",
|
|
1946
|
+
refreshToken: stored.refreshToken,
|
|
1947
|
+
expiresAt: 0,
|
|
1948
|
+
uid: stored.firebaseUid
|
|
1949
|
+
});
|
|
1950
|
+
return {
|
|
1951
|
+
...stored,
|
|
1952
|
+
refreshToken: live.refreshToken,
|
|
1953
|
+
firebaseUid: live.uid
|
|
1954
|
+
};
|
|
1955
|
+
});
|
|
1956
|
+
if (!live) throw new Error("Firebase session refresh did not return a session.");
|
|
1957
|
+
this.liveSession = live;
|
|
1958
|
+
return live.idToken;
|
|
1959
|
+
}
|
|
1960
|
+
};
|
|
1961
|
+
__name(resolveRequestCredential, "resolveRequestCredential");
|
|
1962
|
+
}
|
|
1963
|
+
});
|
|
1964
|
+
|
|
1137
1965
|
// src/api/http.client.ts
|
|
1138
|
-
import { randomUUID } from "crypto";
|
|
1966
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
1967
|
+
function parseRetryAfter(raw) {
|
|
1968
|
+
if (!raw) return void 0;
|
|
1969
|
+
const seconds = Number.parseInt(raw, 10);
|
|
1970
|
+
return Number.isFinite(seconds) && seconds > 0 ? seconds : void 0;
|
|
1971
|
+
}
|
|
1139
1972
|
var HttpClient;
|
|
1140
1973
|
var init_http_client = __esm({
|
|
1141
1974
|
"src/api/http.client.ts"() {
|
|
1142
1975
|
"use strict";
|
|
1143
1976
|
init_auth_error();
|
|
1977
|
+
init_lua_fetch();
|
|
1978
|
+
init_request_credential();
|
|
1144
1979
|
HttpClient = class {
|
|
1145
1980
|
static {
|
|
1146
1981
|
__name(this, "HttpClient");
|
|
1147
1982
|
}
|
|
1148
1983
|
baseUrl;
|
|
1984
|
+
requestCredential;
|
|
1149
1985
|
/**
|
|
1150
1986
|
* Creates an instance of HttpClient
|
|
1151
1987
|
* @param baseUrl - The base URL for all API requests
|
|
1152
1988
|
*/
|
|
1153
|
-
constructor(baseUrl) {
|
|
1989
|
+
constructor(baseUrl, requestCredential) {
|
|
1154
1990
|
this.baseUrl = baseUrl;
|
|
1991
|
+
this.requestCredential = requestCredential;
|
|
1155
1992
|
}
|
|
1156
1993
|
/**
|
|
1157
1994
|
* Makes an HTTP request with standardized error handling
|
|
@@ -1164,12 +2001,16 @@ var init_http_client = __esm({
|
|
|
1164
2001
|
const controller = new AbortController();
|
|
1165
2002
|
const timeoutId = setTimeout(() => controller.abort(), 3e4);
|
|
1166
2003
|
try {
|
|
1167
|
-
const
|
|
2004
|
+
const authorization = this.requestCredential ? `Bearer ${await bearerFor(this.requestCredential)}` : void 0;
|
|
2005
|
+
const response = await luaFetch(url, {
|
|
1168
2006
|
...options,
|
|
1169
2007
|
signal: controller.signal,
|
|
1170
2008
|
headers: {
|
|
1171
2009
|
"Content-Type": "application/json",
|
|
1172
|
-
...options.headers
|
|
2010
|
+
...options.headers,
|
|
2011
|
+
...authorization ? {
|
|
2012
|
+
Authorization: authorization
|
|
2013
|
+
} : {}
|
|
1173
2014
|
}
|
|
1174
2015
|
});
|
|
1175
2016
|
clearTimeout(timeoutId);
|
|
@@ -1188,14 +2029,14 @@ var init_http_client = __esm({
|
|
|
1188
2029
|
const isExplicitCredential = !!serverMessage && /(invalid|expired|missing|no)\s+(api[\s_-]?key|token|credential)/i.test(serverMessage);
|
|
1189
2030
|
const isBareAuthRejection = !serverMessage || /^unauthorized$/i.test(serverMessage);
|
|
1190
2031
|
if (isExplicitCredential || isBareAuthRejection) {
|
|
1191
|
-
throw new AuthenticationError("Authentication failed. Your
|
|
2032
|
+
throw new AuthenticationError("Authentication failed. Your Lua credential may be invalid or expired.", "invalid_credentials", serverMessage);
|
|
1192
2033
|
}
|
|
1193
2034
|
throw new AuthenticationError(`Authentication failed: ${serverMessage}`, "unknown", serverMessage);
|
|
1194
2035
|
}
|
|
1195
2036
|
if (response.status === 403) {
|
|
1196
2037
|
const detail = errorData.message || "You do not have permission to access this resource.";
|
|
1197
2038
|
throw new Error(`Access denied (403): ${detail}
|
|
1198
|
-
Check that your
|
|
2039
|
+
Check that your Lua login has access to this agent or organization.`);
|
|
1199
2040
|
}
|
|
1200
2041
|
return {
|
|
1201
2042
|
success: false,
|
|
@@ -1203,6 +2044,7 @@ Check that your API key has access to this agent/organization.`);
|
|
|
1203
2044
|
message: errorData.message || `HTTP ${response.status}: ${response.statusText}`,
|
|
1204
2045
|
statusCode: response.status,
|
|
1205
2046
|
error: errorData.error,
|
|
2047
|
+
retryAfterSeconds: parseRetryAfter(response.headers.get("retry-after")),
|
|
1206
2048
|
...errorData
|
|
1207
2049
|
}
|
|
1208
2050
|
};
|
|
@@ -1279,7 +2121,7 @@ Check that your API key has access to this agent/organization.`);
|
|
|
1279
2121
|
if (options.method === "POST") {
|
|
1280
2122
|
const headers = options.headers || {};
|
|
1281
2123
|
if (!headers["X-Idempotency-Key"]) {
|
|
1282
|
-
headers["X-Idempotency-Key"] =
|
|
2124
|
+
headers["X-Idempotency-Key"] = randomUUID2();
|
|
1283
2125
|
options = {
|
|
1284
2126
|
...options,
|
|
1285
2127
|
headers: {
|
|
@@ -1301,7 +2143,8 @@ Check that your API key has access to this agent/organization.`);
|
|
|
1301
2143
|
throw error;
|
|
1302
2144
|
}
|
|
1303
2145
|
if (attempt < maxRetries) {
|
|
1304
|
-
const
|
|
2146
|
+
const serverDelay = Number(lastResult?.error?.retryAfterSeconds ?? 0) * 1e3;
|
|
2147
|
+
const backoff = Math.max(this.calculateBackoff(attempt), serverDelay);
|
|
1305
2148
|
await new Promise((resolve) => setTimeout(resolve, backoff));
|
|
1306
2149
|
}
|
|
1307
2150
|
}
|
|
@@ -1336,6 +2179,19 @@ Check that your API key has access to this agent/organization.`);
|
|
|
1336
2179
|
});
|
|
1337
2180
|
}
|
|
1338
2181
|
/**
|
|
2182
|
+
* Performs one HTTP POST attempt.
|
|
2183
|
+
*
|
|
2184
|
+
* Use this only when a successful response contains a one-time secret that
|
|
2185
|
+
* cannot be recovered after an ambiguous network or server failure.
|
|
2186
|
+
*/
|
|
2187
|
+
async httpPostOnce(url, data, headers) {
|
|
2188
|
+
return this.retryableRequest(this.baseUrl + url, {
|
|
2189
|
+
method: "POST",
|
|
2190
|
+
body: data ? JSON.stringify(data) : void 0,
|
|
2191
|
+
headers
|
|
2192
|
+
}, 0);
|
|
2193
|
+
}
|
|
2194
|
+
/**
|
|
1339
2195
|
* Performs an HTTP PUT request
|
|
1340
2196
|
* @param url - The relative URL path to request (will be appended to baseUrl)
|
|
1341
2197
|
* @param data - Optional request body data (will be JSON stringified)
|
|
@@ -1379,6 +2235,7 @@ Check that your API key has access to this agent/organization.`);
|
|
|
1379
2235
|
});
|
|
1380
2236
|
}
|
|
1381
2237
|
};
|
|
2238
|
+
__name(parseRetryAfter, "parseRetryAfter");
|
|
1382
2239
|
}
|
|
1383
2240
|
});
|
|
1384
2241
|
|
|
@@ -1392,25 +2249,12 @@ var init_auth_api_service = __esm({
|
|
|
1392
2249
|
|
|
1393
2250
|
// src/services/auth.ts
|
|
1394
2251
|
import "dotenv/config";
|
|
1395
|
-
import { readFileSync, writeFileSync, mkdirSync, unlinkSync } from "fs";
|
|
1396
|
-
function getToken() {
|
|
1397
|
-
if (process.env.LUA_API_KEY) {
|
|
1398
|
-
return process.env.LUA_API_KEY;
|
|
1399
|
-
}
|
|
1400
|
-
try {
|
|
1401
|
-
const token = readFileSync(CREDENTIALS_FILE, "utf8").trim();
|
|
1402
|
-
if (token) return token;
|
|
1403
|
-
} catch {
|
|
1404
|
-
}
|
|
1405
|
-
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);
|
|
1406
|
-
}
|
|
1407
2252
|
var init_auth = __esm({
|
|
1408
2253
|
"src/services/auth.ts"() {
|
|
1409
2254
|
"use strict";
|
|
1410
2255
|
init_auth_api_service();
|
|
1411
2256
|
init_constants();
|
|
1412
2257
|
init_auth_error();
|
|
1413
|
-
__name(getToken, "getToken");
|
|
1414
2258
|
}
|
|
1415
2259
|
});
|
|
1416
2260
|
|
|
@@ -1482,17 +2326,15 @@ var init_skills_api_service = __esm({
|
|
|
1482
2326
|
static {
|
|
1483
2327
|
__name(this, "SkillApi");
|
|
1484
2328
|
}
|
|
1485
|
-
apiKey;
|
|
1486
2329
|
agentId;
|
|
1487
2330
|
/**
|
|
1488
2331
|
* Creates an instance of SkillApi
|
|
1489
2332
|
* @param baseUrl - The base URL for the API
|
|
1490
|
-
* @param
|
|
2333
|
+
* @param credential - The API key for authentication
|
|
1491
2334
|
* @param agentId - The unique identifier of the agent
|
|
1492
2335
|
*/
|
|
1493
|
-
constructor(baseUrl,
|
|
1494
|
-
super(baseUrl);
|
|
1495
|
-
this.apiKey = apiKey;
|
|
2336
|
+
constructor(baseUrl, credential, agentId) {
|
|
2337
|
+
super(baseUrl, credential);
|
|
1496
2338
|
this.agentId = agentId;
|
|
1497
2339
|
}
|
|
1498
2340
|
/**
|
|
@@ -1501,9 +2343,7 @@ var init_skills_api_service = __esm({
|
|
|
1501
2343
|
* @throws Error if the API request fails or the agent is not found
|
|
1502
2344
|
*/
|
|
1503
2345
|
async getSkills() {
|
|
1504
|
-
return this.httpGet(`/developer/skills/${this.agentId}`, {
|
|
1505
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
1506
|
-
});
|
|
2346
|
+
return this.httpGet(`/developer/skills/${this.agentId}`, {});
|
|
1507
2347
|
}
|
|
1508
2348
|
/**
|
|
1509
2349
|
* Creates a new skill for the agent
|
|
@@ -1512,9 +2352,7 @@ var init_skills_api_service = __esm({
|
|
|
1512
2352
|
* @throws Error if the skill creation fails or validation errors occur
|
|
1513
2353
|
*/
|
|
1514
2354
|
async createSkill(skillData) {
|
|
1515
|
-
return this.httpPost(`/developer/skills/${this.agentId}`, skillData, {
|
|
1516
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
1517
|
-
});
|
|
2355
|
+
return this.httpPost(`/developer/skills/${this.agentId}`, skillData, {});
|
|
1518
2356
|
}
|
|
1519
2357
|
/**
|
|
1520
2358
|
* Pushes a new version of a skill to production
|
|
@@ -1524,9 +2362,7 @@ var init_skills_api_service = __esm({
|
|
|
1524
2362
|
* @throws Error if the skill is not found or the push operation fails
|
|
1525
2363
|
*/
|
|
1526
2364
|
async pushSkill(skillId, versionData) {
|
|
1527
|
-
return this.httpPost(`/developer/skills/${this.agentId}/${skillId}/version`, versionData, {
|
|
1528
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
1529
|
-
});
|
|
2365
|
+
return this.httpPost(`/developer/skills/${this.agentId}/${skillId}/version`, versionData, {});
|
|
1530
2366
|
}
|
|
1531
2367
|
/**
|
|
1532
2368
|
* Pushes a new development/sandbox version of a skill for testing
|
|
@@ -1536,9 +2372,7 @@ var init_skills_api_service = __esm({
|
|
|
1536
2372
|
* @throws Error if the skill is not found or the push operation fails
|
|
1537
2373
|
*/
|
|
1538
2374
|
async pushDevSkill(skillId, versionData) {
|
|
1539
|
-
return this.httpPost(`/developer/skills/${this.agentId}/${skillId}/version/sandbox`, versionData, {
|
|
1540
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
1541
|
-
});
|
|
2375
|
+
return this.httpPost(`/developer/skills/${this.agentId}/${skillId}/version/sandbox`, versionData, {});
|
|
1542
2376
|
}
|
|
1543
2377
|
/**
|
|
1544
2378
|
* Updates an existing development/sandbox version of a skill
|
|
@@ -1549,9 +2383,7 @@ var init_skills_api_service = __esm({
|
|
|
1549
2383
|
* @throws Error if the skill or version is not found or the update fails
|
|
1550
2384
|
*/
|
|
1551
2385
|
async updateDevSkill(skillId, sandboxVersionId, versionData) {
|
|
1552
|
-
return this.httpPut(`/developer/skills/${this.agentId}/${skillId}/version/sandbox/${sandboxVersionId}`, versionData, {
|
|
1553
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
1554
|
-
});
|
|
2386
|
+
return this.httpPut(`/developer/skills/${this.agentId}/${skillId}/version/sandbox/${sandboxVersionId}`, versionData, {});
|
|
1555
2387
|
}
|
|
1556
2388
|
/**
|
|
1557
2389
|
* Retrieves all versions of a specific skill
|
|
@@ -1560,9 +2392,7 @@ var init_skills_api_service = __esm({
|
|
|
1560
2392
|
* @throws Error if the skill is not found or the request fails
|
|
1561
2393
|
*/
|
|
1562
2394
|
async getSkillVersions(skillId) {
|
|
1563
|
-
return this.httpGet(`/developer/skills/${this.agentId}/${skillId}/versions`, {
|
|
1564
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
1565
|
-
});
|
|
2395
|
+
return this.httpGet(`/developer/skills/${this.agentId}/${skillId}/versions`, {});
|
|
1566
2396
|
}
|
|
1567
2397
|
/**
|
|
1568
2398
|
* Publishes a specific version of a skill to production
|
|
@@ -1572,9 +2402,7 @@ var init_skills_api_service = __esm({
|
|
|
1572
2402
|
* @throws Error if the skill or version is not found or the publish operation fails
|
|
1573
2403
|
*/
|
|
1574
2404
|
async publishSkillVersion(skillId, version) {
|
|
1575
|
-
return this.httpPut(`/developer/skills/${this.agentId}/${skillId}/${version}/publish`, void 0, {
|
|
1576
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
1577
|
-
});
|
|
2405
|
+
return this.httpPut(`/developer/skills/${this.agentId}/${skillId}/${version}/publish`, void 0, {});
|
|
1578
2406
|
}
|
|
1579
2407
|
/**
|
|
1580
2408
|
* Deletes a skill and all its versions, or deactivates it if it has versions
|
|
@@ -1585,9 +2413,7 @@ var init_skills_api_service = __esm({
|
|
|
1585
2413
|
* @throws Error if the skill is not found or the delete operation fails
|
|
1586
2414
|
*/
|
|
1587
2415
|
async deleteSkill(skillId) {
|
|
1588
|
-
return this.httpDelete(`/developer/skills/${this.agentId}/${skillId}`, {
|
|
1589
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
1590
|
-
});
|
|
2416
|
+
return this.httpDelete(`/developer/skills/${this.agentId}/${skillId}`, {});
|
|
1591
2417
|
}
|
|
1592
2418
|
/**
|
|
1593
2419
|
* Attach TS source + workspace archive to a skill version. Powers
|
|
@@ -1595,9 +2421,7 @@ var init_skills_api_service = __esm({
|
|
|
1595
2421
|
* source without waiting for the next UI-driven build.
|
|
1596
2422
|
*/
|
|
1597
2423
|
async attachSkillSource(skillId, version, body) {
|
|
1598
|
-
return this.httpPut(`/developer/skills/${this.agentId}/${skillId}/version/${encodeURIComponent(version)}/source`, body, {
|
|
1599
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
1600
|
-
});
|
|
2424
|
+
return this.httpPut(`/developer/skills/${this.agentId}/${skillId}/version/${encodeURIComponent(version)}/source`, body, {});
|
|
1601
2425
|
}
|
|
1602
2426
|
};
|
|
1603
2427
|
}
|
|
@@ -2490,20 +3314,13 @@ var init_version_check = __esm({
|
|
|
2490
3314
|
}
|
|
2491
3315
|
});
|
|
2492
3316
|
|
|
2493
|
-
// src/utils/package-root.ts
|
|
2494
|
-
var init_package_root = __esm({
|
|
2495
|
-
"src/utils/package-root.ts"() {
|
|
2496
|
-
"use strict";
|
|
2497
|
-
}
|
|
2498
|
-
});
|
|
2499
|
-
|
|
2500
3317
|
// src/services/analytics.ts
|
|
2501
3318
|
import { PostHog } from "posthog-node";
|
|
2502
3319
|
var init_analytics = __esm({
|
|
2503
3320
|
"src/services/analytics.ts"() {
|
|
2504
3321
|
"use strict";
|
|
2505
3322
|
init_constants();
|
|
2506
|
-
|
|
3323
|
+
init_request_credential();
|
|
2507
3324
|
init_files();
|
|
2508
3325
|
}
|
|
2509
3326
|
});
|
|
@@ -2537,13 +3354,14 @@ var init_cli = __esm({
|
|
|
2537
3354
|
});
|
|
2538
3355
|
|
|
2539
3356
|
// src/utils/command-utils.ts
|
|
2540
|
-
function requireAuth() {
|
|
2541
|
-
return
|
|
3357
|
+
async function requireAuth() {
|
|
3358
|
+
return resolveRequestCredential();
|
|
2542
3359
|
}
|
|
2543
3360
|
var init_command_utils = __esm({
|
|
2544
3361
|
"src/utils/command-utils.ts"() {
|
|
2545
3362
|
"use strict";
|
|
2546
3363
|
init_auth();
|
|
3364
|
+
init_request_credential();
|
|
2547
3365
|
init_files();
|
|
2548
3366
|
init_cli();
|
|
2549
3367
|
__name(requireAuth, "requireAuth");
|
|
@@ -3026,17 +3844,15 @@ var init_products_api_service = __esm({
|
|
|
3026
3844
|
static {
|
|
3027
3845
|
__name(this, "ProductApi");
|
|
3028
3846
|
}
|
|
3029
|
-
apiKey;
|
|
3030
3847
|
agentId;
|
|
3031
3848
|
/**
|
|
3032
3849
|
* Creates an instance of ProductApi
|
|
3033
3850
|
* @param baseUrl - The base URL for the API
|
|
3034
|
-
* @param
|
|
3851
|
+
* @param credential - The API key for authentication
|
|
3035
3852
|
* @param agentId - The unique identifier of the agent
|
|
3036
3853
|
*/
|
|
3037
|
-
constructor(baseUrl,
|
|
3038
|
-
super(baseUrl);
|
|
3039
|
-
this.apiKey = apiKey;
|
|
3854
|
+
constructor(baseUrl, credential, agentId) {
|
|
3855
|
+
super(baseUrl, credential);
|
|
3040
3856
|
this.agentId = agentId;
|
|
3041
3857
|
}
|
|
3042
3858
|
async get(pageOrOptions, limitArg) {
|
|
@@ -3057,9 +3873,7 @@ var init_products_api_service = __esm({
|
|
|
3057
3873
|
if (filter) {
|
|
3058
3874
|
queryParams.append("filter", JSON.stringify(filter));
|
|
3059
3875
|
}
|
|
3060
|
-
const response = await this.httpGet(`/developer/agents/${this.agentId}/products?${queryParams.toString()}`, {
|
|
3061
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3062
|
-
});
|
|
3876
|
+
const response = await this.httpGet(`/developer/agents/${this.agentId}/products?${queryParams.toString()}`, {});
|
|
3063
3877
|
if (response.success) {
|
|
3064
3878
|
return new ProductPaginationInstance(this, response);
|
|
3065
3879
|
}
|
|
@@ -3072,9 +3886,7 @@ var init_products_api_service = __esm({
|
|
|
3072
3886
|
* @throws Error if the product is not found or the request fails
|
|
3073
3887
|
*/
|
|
3074
3888
|
async getById(productId) {
|
|
3075
|
-
const response = await this.httpGet(`/developer/agents/${this.agentId}/products/${productId}`, {
|
|
3076
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3077
|
-
});
|
|
3889
|
+
const response = await this.httpGet(`/developer/agents/${this.agentId}/products/${productId}`, {});
|
|
3078
3890
|
if (response.success && response.data) {
|
|
3079
3891
|
return new ProductInstance(this, response.data);
|
|
3080
3892
|
}
|
|
@@ -3087,9 +3899,7 @@ var init_products_api_service = __esm({
|
|
|
3087
3899
|
* @throws Error if the product creation fails or validation errors occur
|
|
3088
3900
|
*/
|
|
3089
3901
|
async create(productData) {
|
|
3090
|
-
const response = await this.httpPost(`/developer/agents/${this.agentId}/products`, productData, {
|
|
3091
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3092
|
-
});
|
|
3902
|
+
const response = await this.httpPost(`/developer/agents/${this.agentId}/products`, productData, {});
|
|
3093
3903
|
if (response.success && response.data) {
|
|
3094
3904
|
return new ProductInstance(this, response.data.product);
|
|
3095
3905
|
}
|
|
@@ -3106,9 +3916,7 @@ var init_products_api_service = __esm({
|
|
|
3106
3916
|
const response = await this.httpPut(`/developer/agents/${this.agentId}/products`, {
|
|
3107
3917
|
...productData,
|
|
3108
3918
|
id: productId
|
|
3109
|
-
}, {
|
|
3110
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3111
|
-
});
|
|
3919
|
+
}, {});
|
|
3112
3920
|
if (response.success && response.data) {
|
|
3113
3921
|
return response.data;
|
|
3114
3922
|
}
|
|
@@ -3121,9 +3929,7 @@ var init_products_api_service = __esm({
|
|
|
3121
3929
|
* @throws Error if the product is not found or the deletion fails
|
|
3122
3930
|
*/
|
|
3123
3931
|
async delete(productId) {
|
|
3124
|
-
const response = await this.httpDelete(`/developer/agents/${this.agentId}/products/${productId}`, {
|
|
3125
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3126
|
-
});
|
|
3932
|
+
const response = await this.httpDelete(`/developer/agents/${this.agentId}/products/${productId}`, {});
|
|
3127
3933
|
if (response.success && response.data) {
|
|
3128
3934
|
return response.data;
|
|
3129
3935
|
}
|
|
@@ -3137,9 +3943,7 @@ var init_products_api_service = __esm({
|
|
|
3137
3943
|
* @throws Error if the search fails or the API request is unsuccessful
|
|
3138
3944
|
*/
|
|
3139
3945
|
async search(searchQuery, limit = 5) {
|
|
3140
|
-
const response = await this.httpGet(`/developer/agents/${this.agentId}/products/search?searchQuery=${encodeURIComponent(searchQuery)}&limit=${limit}`, {
|
|
3141
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3142
|
-
});
|
|
3946
|
+
const response = await this.httpGet(`/developer/agents/${this.agentId}/products/search?searchQuery=${encodeURIComponent(searchQuery)}&limit=${limit}`, {});
|
|
3143
3947
|
if (response.success) {
|
|
3144
3948
|
return new ProductSearchInstance(this, response);
|
|
3145
3949
|
}
|
|
@@ -3624,17 +4428,15 @@ var init_order_api_service = __esm({
|
|
|
3624
4428
|
static {
|
|
3625
4429
|
__name(this, "OrderApi");
|
|
3626
4430
|
}
|
|
3627
|
-
apiKey;
|
|
3628
4431
|
agentId;
|
|
3629
4432
|
/**
|
|
3630
4433
|
* Creates an instance of OrderApi
|
|
3631
4434
|
* @param baseUrl - The base URL for the API
|
|
3632
|
-
* @param
|
|
4435
|
+
* @param credential - The API key for authentication
|
|
3633
4436
|
* @param agentId - The unique identifier of the agent
|
|
3634
4437
|
*/
|
|
3635
|
-
constructor(baseUrl,
|
|
3636
|
-
super(baseUrl);
|
|
3637
|
-
this.apiKey = apiKey;
|
|
4438
|
+
constructor(baseUrl, credential, agentId) {
|
|
4439
|
+
super(baseUrl, credential);
|
|
3638
4440
|
this.agentId = agentId;
|
|
3639
4441
|
}
|
|
3640
4442
|
/**
|
|
@@ -3644,9 +4446,7 @@ var init_order_api_service = __esm({
|
|
|
3644
4446
|
* @throws Error if the basket is not found or the order creation fails
|
|
3645
4447
|
*/
|
|
3646
4448
|
async create(orderData) {
|
|
3647
|
-
const response = await this.httpPost(`/developer/agents/${this.agentId}/order`, orderData, {
|
|
3648
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3649
|
-
});
|
|
4449
|
+
const response = await this.httpPost(`/developer/agents/${this.agentId}/order`, orderData, {});
|
|
3650
4450
|
if (response.success && response.data) {
|
|
3651
4451
|
return new OrderInstance(this, response.data);
|
|
3652
4452
|
}
|
|
@@ -3660,9 +4460,7 @@ var init_order_api_service = __esm({
|
|
|
3660
4460
|
* @throws Error if the order is not found or the status update fails
|
|
3661
4461
|
*/
|
|
3662
4462
|
async updateStatus(status, orderId) {
|
|
3663
|
-
const response = await this.httpPut(`/developer/agents/${this.agentId}/order/${orderId}/${status}`, {}, {
|
|
3664
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3665
|
-
});
|
|
4463
|
+
const response = await this.httpPut(`/developer/agents/${this.agentId}/order/${orderId}/${status}`, {}, {});
|
|
3666
4464
|
if (response.success && response.data) {
|
|
3667
4465
|
return response.data;
|
|
3668
4466
|
}
|
|
@@ -3676,9 +4474,7 @@ var init_order_api_service = __esm({
|
|
|
3676
4474
|
* @throws Error if the order is not found or the data update fails
|
|
3677
4475
|
*/
|
|
3678
4476
|
async updateData(data, orderId) {
|
|
3679
|
-
const response = await this.httpPut(`/developer/agents/${this.agentId}/order/${orderId}`, data, {
|
|
3680
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3681
|
-
});
|
|
4477
|
+
const response = await this.httpPut(`/developer/agents/${this.agentId}/order/${orderId}`, data, {});
|
|
3682
4478
|
if (response.success && response.data) {
|
|
3683
4479
|
return response.data;
|
|
3684
4480
|
}
|
|
@@ -3692,9 +4488,7 @@ var init_order_api_service = __esm({
|
|
|
3692
4488
|
*/
|
|
3693
4489
|
async get(status) {
|
|
3694
4490
|
const statusParam = status ? `?status=${status}` : "";
|
|
3695
|
-
const response = await this.httpGet(`/developer/agents/${this.agentId}/order/user${statusParam}`, {
|
|
3696
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3697
|
-
});
|
|
4491
|
+
const response = await this.httpGet(`/developer/agents/${this.agentId}/order/user${statusParam}`, {});
|
|
3698
4492
|
if (response.success && response.data) {
|
|
3699
4493
|
return response.data.map((order) => new OrderInstance(this, order));
|
|
3700
4494
|
}
|
|
@@ -3707,9 +4501,7 @@ var init_order_api_service = __esm({
|
|
|
3707
4501
|
* @throws Error if the order is not found or the request fails
|
|
3708
4502
|
*/
|
|
3709
4503
|
async getById(orderId) {
|
|
3710
|
-
const response = await this.httpGet(`/developer/agents/${this.agentId}/order/${orderId}`, {
|
|
3711
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3712
|
-
});
|
|
4504
|
+
const response = await this.httpGet(`/developer/agents/${this.agentId}/order/${orderId}`, {});
|
|
3713
4505
|
if (response.success && response.data) {
|
|
3714
4506
|
return new OrderInstance(this, response.data);
|
|
3715
4507
|
}
|
|
@@ -3732,17 +4524,17 @@ var init_basket_api_service = __esm({
|
|
|
3732
4524
|
static {
|
|
3733
4525
|
__name(this, "BasketApi");
|
|
3734
4526
|
}
|
|
3735
|
-
|
|
4527
|
+
credential;
|
|
3736
4528
|
agentId;
|
|
3737
4529
|
/**
|
|
3738
4530
|
* Creates an instance of BasketApi
|
|
3739
4531
|
* @param baseUrl - The base URL for the API
|
|
3740
|
-
* @param
|
|
4532
|
+
* @param credential - The API key for authentication
|
|
3741
4533
|
* @param agentId - The unique identifier of the agent
|
|
3742
4534
|
*/
|
|
3743
|
-
constructor(baseUrl,
|
|
3744
|
-
super(baseUrl);
|
|
3745
|
-
this.
|
|
4535
|
+
constructor(baseUrl, credential, agentId) {
|
|
4536
|
+
super(baseUrl, credential);
|
|
4537
|
+
this.credential = credential;
|
|
3746
4538
|
this.agentId = agentId;
|
|
3747
4539
|
}
|
|
3748
4540
|
/**
|
|
@@ -3752,9 +4544,7 @@ var init_basket_api_service = __esm({
|
|
|
3752
4544
|
* @throws Error if the basket creation fails or the API request is unsuccessful
|
|
3753
4545
|
*/
|
|
3754
4546
|
async create(basketData) {
|
|
3755
|
-
const response = await this.httpPost(`/developer/agents/${this.agentId}/basket`, basketData, {
|
|
3756
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3757
|
-
});
|
|
4547
|
+
const response = await this.httpPost(`/developer/agents/${this.agentId}/basket`, basketData, {});
|
|
3758
4548
|
if (response.success && response.data) {
|
|
3759
4549
|
return new BasketInstance(this, response.data);
|
|
3760
4550
|
}
|
|
@@ -3768,9 +4558,7 @@ var init_basket_api_service = __esm({
|
|
|
3768
4558
|
*/
|
|
3769
4559
|
async get(status) {
|
|
3770
4560
|
const statusParam = status ? `?status=${status}` : "";
|
|
3771
|
-
const response = await this.httpGet(`/developer/agents/${this.agentId}/basket/user${statusParam}`, {
|
|
3772
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3773
|
-
});
|
|
4561
|
+
const response = await this.httpGet(`/developer/agents/${this.agentId}/basket/user${statusParam}`, {});
|
|
3774
4562
|
if (response.success && response.data) {
|
|
3775
4563
|
return response.data.map((basket) => new BasketInstance(this, basket));
|
|
3776
4564
|
}
|
|
@@ -3783,9 +4571,7 @@ var init_basket_api_service = __esm({
|
|
|
3783
4571
|
* @throws Error if the basket is not found or the request fails
|
|
3784
4572
|
*/
|
|
3785
4573
|
async getById(basketId) {
|
|
3786
|
-
const response = await this.httpGet(`/developer/agents/${this.agentId}/basket/${basketId}`, {
|
|
3787
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3788
|
-
});
|
|
4574
|
+
const response = await this.httpGet(`/developer/agents/${this.agentId}/basket/${basketId}`, {});
|
|
3789
4575
|
if (response.success && response.data) {
|
|
3790
4576
|
return new BasketInstance(this, response.data);
|
|
3791
4577
|
}
|
|
@@ -3799,9 +4585,7 @@ var init_basket_api_service = __esm({
|
|
|
3799
4585
|
* @throws Error if the basket is not found or the item cannot be added
|
|
3800
4586
|
*/
|
|
3801
4587
|
async addItem(basketId, itemData) {
|
|
3802
|
-
const response = await this.httpPost(`/developer/agents/${this.agentId}/basket/${basketId}/item`, itemData, {
|
|
3803
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3804
|
-
});
|
|
4588
|
+
const response = await this.httpPost(`/developer/agents/${this.agentId}/basket/${basketId}/item`, itemData, {});
|
|
3805
4589
|
if (response.success && response.data) {
|
|
3806
4590
|
return response.data;
|
|
3807
4591
|
}
|
|
@@ -3815,9 +4599,7 @@ var init_basket_api_service = __esm({
|
|
|
3815
4599
|
* @throws Error if the basket or item is not found or the removal fails
|
|
3816
4600
|
*/
|
|
3817
4601
|
async removeItem(basketId, itemId) {
|
|
3818
|
-
const response = await this.httpDelete(`/developer/agents/${this.agentId}/basket/${basketId}/item/${itemId}`, {
|
|
3819
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3820
|
-
});
|
|
4602
|
+
const response = await this.httpDelete(`/developer/agents/${this.agentId}/basket/${basketId}/item/${itemId}`, {});
|
|
3821
4603
|
if (response.success && response.data) {
|
|
3822
4604
|
return response.data;
|
|
3823
4605
|
}
|
|
@@ -3830,9 +4612,7 @@ var init_basket_api_service = __esm({
|
|
|
3830
4612
|
* @throws Error if the basket is not found or the clear operation fails
|
|
3831
4613
|
*/
|
|
3832
4614
|
async clear(basketId) {
|
|
3833
|
-
const response = await this.httpDelete(`/developer/agents/${this.agentId}/basket/${basketId}/clear`, {
|
|
3834
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3835
|
-
});
|
|
4615
|
+
const response = await this.httpDelete(`/developer/agents/${this.agentId}/basket/${basketId}/clear`, {});
|
|
3836
4616
|
if (response.success && response.data) {
|
|
3837
4617
|
return response.data;
|
|
3838
4618
|
}
|
|
@@ -3846,9 +4626,7 @@ var init_basket_api_service = __esm({
|
|
|
3846
4626
|
* @throws Error if the basket is not found or the status update fails
|
|
3847
4627
|
*/
|
|
3848
4628
|
async updateStatus(basketId, status) {
|
|
3849
|
-
const response = await this.httpPut(`/developer/agents/${this.agentId}/basket/${basketId}/${status}`, void 0, {
|
|
3850
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3851
|
-
});
|
|
4629
|
+
const response = await this.httpPut(`/developer/agents/${this.agentId}/basket/${basketId}/${status}`, void 0, {});
|
|
3852
4630
|
if (response.success) {
|
|
3853
4631
|
return status;
|
|
3854
4632
|
}
|
|
@@ -3862,9 +4640,7 @@ var init_basket_api_service = __esm({
|
|
|
3862
4640
|
* @throws Error if the basket is not found or the metadata update fails
|
|
3863
4641
|
*/
|
|
3864
4642
|
async updateMetadata(basketId, metadata) {
|
|
3865
|
-
const response = await this.httpPut(`/developer/agents/${this.agentId}/basket/${basketId}/metadata`, metadata, {
|
|
3866
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3867
|
-
});
|
|
4643
|
+
const response = await this.httpPut(`/developer/agents/${this.agentId}/basket/${basketId}/metadata`, metadata, {});
|
|
3868
4644
|
if (response.success) {
|
|
3869
4645
|
return metadata;
|
|
3870
4646
|
}
|
|
@@ -3881,11 +4657,9 @@ var init_basket_api_service = __esm({
|
|
|
3881
4657
|
const response = await this.httpPost(`/developer/agents/${this.agentId}/order`, {
|
|
3882
4658
|
basketId,
|
|
3883
4659
|
data
|
|
3884
|
-
}, {
|
|
3885
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
3886
|
-
});
|
|
4660
|
+
}, {});
|
|
3887
4661
|
if (response.success && response.data) {
|
|
3888
|
-
const orderApi = new OrderApi(this.baseUrl, this.
|
|
4662
|
+
const orderApi = new OrderApi(this.baseUrl, this.credential, this.agentId);
|
|
3889
4663
|
return new OrderInstance(orderApi, response.data);
|
|
3890
4664
|
}
|
|
3891
4665
|
throw new Error(response.error?.message || "Failed to create order");
|
|
@@ -4124,18 +4898,18 @@ var init_user_data_api_service = __esm({
|
|
|
4124
4898
|
static {
|
|
4125
4899
|
__name(this, "UserDataApi");
|
|
4126
4900
|
}
|
|
4127
|
-
|
|
4901
|
+
credential;
|
|
4128
4902
|
agentId;
|
|
4129
4903
|
targetUserId;
|
|
4130
4904
|
/**
|
|
4131
4905
|
* Creates an instance of UserDataApi
|
|
4132
4906
|
* @param baseUrl - The base URL for the API
|
|
4133
|
-
* @param
|
|
4907
|
+
* @param credential - The API key for authentication
|
|
4134
4908
|
* @param agentId - The unique identifier of the agent
|
|
4135
4909
|
*/
|
|
4136
|
-
constructor(baseUrl,
|
|
4137
|
-
super(baseUrl);
|
|
4138
|
-
this.
|
|
4910
|
+
constructor(baseUrl, credential, agentId, targetUserId) {
|
|
4911
|
+
super(baseUrl, credential);
|
|
4912
|
+
this.credential = credential;
|
|
4139
4913
|
this.agentId = agentId;
|
|
4140
4914
|
this.targetUserId = targetUserId;
|
|
4141
4915
|
}
|
|
@@ -4162,15 +4936,13 @@ var init_user_data_api_service = __esm({
|
|
|
4162
4936
|
if (userId) {
|
|
4163
4937
|
url += `/user/${encodeURIComponent(userId)}`;
|
|
4164
4938
|
}
|
|
4165
|
-
const response = await this.httpGet(url, {
|
|
4166
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4167
|
-
});
|
|
4939
|
+
const response = await this.httpGet(url, {});
|
|
4168
4940
|
if (!response.success) {
|
|
4169
4941
|
throw new Error(response.error?.message || "Failed to get user data");
|
|
4170
4942
|
}
|
|
4171
4943
|
const profile = response.data?._luaProfile;
|
|
4172
4944
|
const { _luaProfile, ...data } = response.data || {};
|
|
4173
|
-
const scopedApi = userId ? new _UserDataApi(this.baseUrl, this.
|
|
4945
|
+
const scopedApi = userId ? new _UserDataApi(this.baseUrl, this.credential, this.agentId, userId) : this;
|
|
4174
4946
|
return new UserDataInstance(scopedApi, data, profile);
|
|
4175
4947
|
}
|
|
4176
4948
|
/**
|
|
@@ -4204,9 +4976,7 @@ var init_user_data_api_service = __esm({
|
|
|
4204
4976
|
* @throws Error if the update fails or the request is unsuccessful
|
|
4205
4977
|
*/
|
|
4206
4978
|
async update(data) {
|
|
4207
|
-
const response = await this.httpPut(this.dataPath, data, {
|
|
4208
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4209
|
-
});
|
|
4979
|
+
const response = await this.httpPut(this.dataPath, data, {});
|
|
4210
4980
|
if (!response.success) {
|
|
4211
4981
|
throw new Error(response.error?.message || "Failed to update user data");
|
|
4212
4982
|
}
|
|
@@ -4214,9 +4984,7 @@ var init_user_data_api_service = __esm({
|
|
|
4214
4984
|
return cleanData;
|
|
4215
4985
|
}
|
|
4216
4986
|
async patch(mutation) {
|
|
4217
|
-
const response = await this.httpPatch(this.dataPath, mutation, {
|
|
4218
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4219
|
-
});
|
|
4987
|
+
const response = await this.httpPatch(this.dataPath, mutation, {});
|
|
4220
4988
|
if (!response.success) {
|
|
4221
4989
|
throw new Error(response.error?.message || "Failed to patch user data");
|
|
4222
4990
|
}
|
|
@@ -4229,9 +4997,7 @@ var init_user_data_api_service = __esm({
|
|
|
4229
4997
|
* @throws Error if the clear operation fails or the request is unsuccessful
|
|
4230
4998
|
*/
|
|
4231
4999
|
async clear() {
|
|
4232
|
-
const response = await this.httpDelete(this.dataPath, {
|
|
4233
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4234
|
-
});
|
|
5000
|
+
const response = await this.httpDelete(this.dataPath, {});
|
|
4235
5001
|
if (!response.success) {
|
|
4236
5002
|
throw new Error(response.error?.message || "Failed to clear user data");
|
|
4237
5003
|
}
|
|
@@ -4244,32 +5010,15 @@ var init_user_data_api_service = __esm({
|
|
|
4244
5010
|
* @throws Error if the message sending fails or the request is unsuccessful
|
|
4245
5011
|
*/
|
|
4246
5012
|
async sendMessage(messages) {
|
|
4247
|
-
const
|
|
4248
|
-
const response = await this.httpPost(`/admin/agents/${this.agentId}/conversations/${user.uid}`, {
|
|
5013
|
+
const response = await this.httpPost(`/admin/agents/${this.agentId}/conversations/me`, {
|
|
4249
5014
|
messages
|
|
4250
|
-
}, {
|
|
4251
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4252
|
-
});
|
|
5015
|
+
}, {});
|
|
4253
5016
|
if (!response.success) {
|
|
4254
5017
|
throw new Error(response.error?.message || "Failed to send message");
|
|
4255
5018
|
}
|
|
4256
5019
|
return response.data;
|
|
4257
5020
|
}
|
|
4258
5021
|
/**
|
|
4259
|
-
* Gets the admin user for the specific agent
|
|
4260
|
-
* @returns Promise resolving to the admin user data
|
|
4261
|
-
* @throws Error if the admin user cannot be retrieved or the request is unsuccessful
|
|
4262
|
-
*/
|
|
4263
|
-
async getAdminUser() {
|
|
4264
|
-
const response = await this.httpGet(`/admin`, {
|
|
4265
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4266
|
-
});
|
|
4267
|
-
if (!response.success) {
|
|
4268
|
-
throw new Error(response.error?.message || "Failed to get admin user");
|
|
4269
|
-
}
|
|
4270
|
-
return response.data;
|
|
4271
|
-
}
|
|
4272
|
-
/**
|
|
4273
5022
|
* Gets the chat history for the current user and agent
|
|
4274
5023
|
* @returns Promise resolving to an array of chat messages
|
|
4275
5024
|
* @throws Error if the chat history cannot be retrieved or the request is unsuccessful
|
|
@@ -4281,9 +5030,7 @@ var init_user_data_api_service = __esm({
|
|
|
4281
5030
|
* ```
|
|
4282
5031
|
*/
|
|
4283
5032
|
async getChatHistory() {
|
|
4284
|
-
const response = await this.httpGet(`/chat/history/${this.agentId}`, {
|
|
4285
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4286
|
-
});
|
|
5033
|
+
const response = await this.httpGet(`/chat/history/${this.agentId}`, {});
|
|
4287
5034
|
if (!response.success) {
|
|
4288
5035
|
throw new Error(response.error?.message || "Failed to get chat history");
|
|
4289
5036
|
}
|
|
@@ -4509,17 +5256,15 @@ var init_custom_data_api_service = __esm({
|
|
|
4509
5256
|
static {
|
|
4510
5257
|
__name(this, "CustomDataApi");
|
|
4511
5258
|
}
|
|
4512
|
-
apiKey;
|
|
4513
5259
|
agentId;
|
|
4514
5260
|
/**
|
|
4515
5261
|
* Creates an instance of CustomDataApi
|
|
4516
5262
|
* @param baseUrl - The base URL for the API
|
|
4517
|
-
* @param
|
|
5263
|
+
* @param credential - The API key for authentication
|
|
4518
5264
|
* @param agentId - The unique identifier of the agent
|
|
4519
5265
|
*/
|
|
4520
|
-
constructor(baseUrl,
|
|
4521
|
-
super(baseUrl);
|
|
4522
|
-
this.apiKey = apiKey;
|
|
5266
|
+
constructor(baseUrl, credential, agentId) {
|
|
5267
|
+
super(baseUrl, credential);
|
|
4523
5268
|
this.agentId = agentId;
|
|
4524
5269
|
}
|
|
4525
5270
|
/**
|
|
@@ -4529,9 +5274,7 @@ var init_custom_data_api_service = __esm({
|
|
|
4529
5274
|
* @returns Promise resolving to the collections listing
|
|
4530
5275
|
*/
|
|
4531
5276
|
async collections() {
|
|
4532
|
-
const response = await this.httpGet(`/developer/agents/${this.agentId}/custom-data`, {
|
|
4533
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4534
|
-
});
|
|
5277
|
+
const response = await this.httpGet(`/developer/agents/${this.agentId}/custom-data`, {});
|
|
4535
5278
|
if (response.success && response.data) {
|
|
4536
5279
|
return response.data;
|
|
4537
5280
|
}
|
|
@@ -4559,9 +5302,7 @@ var init_custom_data_api_service = __esm({
|
|
|
4559
5302
|
data,
|
|
4560
5303
|
searchText: options.searchText,
|
|
4561
5304
|
index: options.index
|
|
4562
|
-
}, {
|
|
4563
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4564
|
-
});
|
|
5305
|
+
}, {});
|
|
4565
5306
|
if (response.success && response.data) {
|
|
4566
5307
|
return new DataEntryInstance(this, response.data, collectionName);
|
|
4567
5308
|
}
|
|
@@ -4582,9 +5323,7 @@ var init_custom_data_api_service = __esm({
|
|
|
4582
5323
|
const encodedFilter = encodeURIComponent(JSON.stringify(filter));
|
|
4583
5324
|
url += `&filter=${encodedFilter}`;
|
|
4584
5325
|
}
|
|
4585
|
-
const response = await this.httpGet(url, {
|
|
4586
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4587
|
-
});
|
|
5326
|
+
const response = await this.httpGet(url, {});
|
|
4588
5327
|
if (response.success && response.data) {
|
|
4589
5328
|
return response.data;
|
|
4590
5329
|
}
|
|
@@ -4598,9 +5337,7 @@ var init_custom_data_api_service = __esm({
|
|
|
4598
5337
|
* @throws Error if the entry is not found or the API request is unsuccessful
|
|
4599
5338
|
*/
|
|
4600
5339
|
async getEntry(collectionName, entryId) {
|
|
4601
|
-
const response = await this.httpGet(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, {
|
|
4602
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4603
|
-
});
|
|
5340
|
+
const response = await this.httpGet(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, {});
|
|
4604
5341
|
if (response.success && response.data) {
|
|
4605
5342
|
return new DataEntryInstance(this, response.data, collectionName);
|
|
4606
5343
|
}
|
|
@@ -4624,18 +5361,14 @@ var init_custom_data_api_service = __esm({
|
|
|
4624
5361
|
data,
|
|
4625
5362
|
searchText: options.searchText,
|
|
4626
5363
|
index: options.index
|
|
4627
|
-
}, {
|
|
4628
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4629
|
-
});
|
|
5364
|
+
}, {});
|
|
4630
5365
|
if (response.success && response.data) {
|
|
4631
5366
|
return response.data;
|
|
4632
5367
|
}
|
|
4633
5368
|
throw new Error(response.error?.message || "Failed to update custom data entry");
|
|
4634
5369
|
}
|
|
4635
5370
|
async patch(collectionName, entryId, mutation) {
|
|
4636
|
-
const response = await this.httpPatch(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, mutation, {
|
|
4637
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4638
|
-
});
|
|
5371
|
+
const response = await this.httpPatch(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, mutation, {});
|
|
4639
5372
|
if (response.success && response.data) {
|
|
4640
5373
|
return response.data;
|
|
4641
5374
|
}
|
|
@@ -4652,9 +5385,7 @@ var init_custom_data_api_service = __esm({
|
|
|
4652
5385
|
*/
|
|
4653
5386
|
async search(collectionName, searchText, limit = 10, scoreThreshold = 0.6) {
|
|
4654
5387
|
const url = `/developer/agents/${this.agentId}/custom-data/${collectionName}/search?searchText=${encodeURIComponent(searchText)}&limit=${limit}&scoreThreshold=${scoreThreshold}`;
|
|
4655
|
-
const response = await this.httpGet(url, {
|
|
4656
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4657
|
-
});
|
|
5388
|
+
const response = await this.httpGet(url, {});
|
|
4658
5389
|
if (response.success && response.data) {
|
|
4659
5390
|
return response.data.data.map((entry) => new DataEntryInstance(this, entry, collectionName));
|
|
4660
5391
|
}
|
|
@@ -4668,9 +5399,7 @@ var init_custom_data_api_service = __esm({
|
|
|
4668
5399
|
* @throws Error if the entry is not found or the deletion fails
|
|
4669
5400
|
*/
|
|
4670
5401
|
async delete(collectionName, entryId) {
|
|
4671
|
-
const response = await this.httpDelete(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, {
|
|
4672
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4673
|
-
});
|
|
5402
|
+
const response = await this.httpDelete(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, {});
|
|
4674
5403
|
if (response.success && response.data) {
|
|
4675
5404
|
return response.data;
|
|
4676
5405
|
}
|
|
@@ -4690,17 +5419,15 @@ var init_webhook_api_service = __esm({
|
|
|
4690
5419
|
static {
|
|
4691
5420
|
__name(this, "WebhookApi");
|
|
4692
5421
|
}
|
|
4693
|
-
apiKey;
|
|
4694
5422
|
agentId;
|
|
4695
5423
|
/**
|
|
4696
5424
|
* Creates an instance of WebhookApi
|
|
4697
5425
|
* @param baseUrl - The base URL for the API
|
|
4698
|
-
* @param
|
|
5426
|
+
* @param credential - The API key for authentication
|
|
4699
5427
|
* @param agentId - The unique identifier of the agent
|
|
4700
5428
|
*/
|
|
4701
|
-
constructor(baseUrl,
|
|
4702
|
-
super(baseUrl);
|
|
4703
|
-
this.apiKey = apiKey;
|
|
5429
|
+
constructor(baseUrl, credential, agentId) {
|
|
5430
|
+
super(baseUrl, credential);
|
|
4704
5431
|
this.agentId = agentId;
|
|
4705
5432
|
}
|
|
4706
5433
|
/**
|
|
@@ -4709,9 +5436,7 @@ var init_webhook_api_service = __esm({
|
|
|
4709
5436
|
* @throws Error if the API request fails or the agent is not found
|
|
4710
5437
|
*/
|
|
4711
5438
|
async getWebhooks() {
|
|
4712
|
-
return this.httpGet(`/developer/webhooks/${this.agentId}`, {
|
|
4713
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4714
|
-
});
|
|
5439
|
+
return this.httpGet(`/developer/webhooks/${this.agentId}`, {});
|
|
4715
5440
|
}
|
|
4716
5441
|
/**
|
|
4717
5442
|
* Creates a new webhook for the agent
|
|
@@ -4720,14 +5445,10 @@ var init_webhook_api_service = __esm({
|
|
|
4720
5445
|
* @throws Error if the webhook creation fails or validation errors occur
|
|
4721
5446
|
*/
|
|
4722
5447
|
async createWebhook(webhookData) {
|
|
4723
|
-
return this.httpPost(`/developer/webhooks/${this.agentId}`, webhookData, {
|
|
4724
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4725
|
-
});
|
|
5448
|
+
return this.httpPost(`/developer/webhooks/${this.agentId}`, webhookData, {});
|
|
4726
5449
|
}
|
|
4727
5450
|
async updateWebhook(webhookId, data) {
|
|
4728
|
-
return this.httpPatch(`/developer/webhooks/${this.agentId}/${webhookId}`, data, {
|
|
4729
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4730
|
-
});
|
|
5451
|
+
return this.httpPatch(`/developer/webhooks/${this.agentId}/${webhookId}`, data, {});
|
|
4731
5452
|
}
|
|
4732
5453
|
/**
|
|
4733
5454
|
* Pushes a new version of a webhook to production
|
|
@@ -4737,9 +5458,7 @@ var init_webhook_api_service = __esm({
|
|
|
4737
5458
|
* @throws Error if the webhook is not found or the push operation fails
|
|
4738
5459
|
*/
|
|
4739
5460
|
async pushWebhook(webhookId, versionData) {
|
|
4740
|
-
return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/version`, versionData, {
|
|
4741
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4742
|
-
});
|
|
5461
|
+
return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/version`, versionData, {});
|
|
4743
5462
|
}
|
|
4744
5463
|
/**
|
|
4745
5464
|
* Pushes a new development/sandbox version of a webhook for testing
|
|
@@ -4749,9 +5468,7 @@ var init_webhook_api_service = __esm({
|
|
|
4749
5468
|
* @throws Error if the webhook is not found or the push operation fails
|
|
4750
5469
|
*/
|
|
4751
5470
|
async pushDevWebhook(webhookId, versionData) {
|
|
4752
|
-
return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/version/sandbox`, versionData, {
|
|
4753
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4754
|
-
});
|
|
5471
|
+
return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/version/sandbox`, versionData, {});
|
|
4755
5472
|
}
|
|
4756
5473
|
/**
|
|
4757
5474
|
* Updates an existing development/sandbox version of a webhook
|
|
@@ -4762,9 +5479,7 @@ var init_webhook_api_service = __esm({
|
|
|
4762
5479
|
* @throws Error if the webhook or version is not found or the update fails
|
|
4763
5480
|
*/
|
|
4764
5481
|
async updateDevWebhook(webhookId, sandboxVersionId, versionData) {
|
|
4765
|
-
return this.httpPut(`/developer/webhooks/${this.agentId}/${webhookId}/version/sandbox/${sandboxVersionId}`, versionData, {
|
|
4766
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4767
|
-
});
|
|
5482
|
+
return this.httpPut(`/developer/webhooks/${this.agentId}/${webhookId}/version/sandbox/${sandboxVersionId}`, versionData, {});
|
|
4768
5483
|
}
|
|
4769
5484
|
/**
|
|
4770
5485
|
* Retrieves all versions of a specific webhook
|
|
@@ -4773,9 +5488,7 @@ var init_webhook_api_service = __esm({
|
|
|
4773
5488
|
* @throws Error if the webhook is not found or the request fails
|
|
4774
5489
|
*/
|
|
4775
5490
|
async getWebhookVersions(webhookId) {
|
|
4776
|
-
return this.httpGet(`/developer/webhooks/${this.agentId}/${webhookId}/versions`, {
|
|
4777
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4778
|
-
});
|
|
5491
|
+
return this.httpGet(`/developer/webhooks/${this.agentId}/${webhookId}/versions`, {});
|
|
4779
5492
|
}
|
|
4780
5493
|
/**
|
|
4781
5494
|
* Publishes a specific version of a webhook to production
|
|
@@ -4785,9 +5498,7 @@ var init_webhook_api_service = __esm({
|
|
|
4785
5498
|
* @throws Error if the webhook or version is not found or the publish operation fails
|
|
4786
5499
|
*/
|
|
4787
5500
|
async publishWebhookVersion(webhookId, version) {
|
|
4788
|
-
return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/${version}/publish`, {}, {
|
|
4789
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4790
|
-
});
|
|
5501
|
+
return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/${version}/publish`, {}, {});
|
|
4791
5502
|
}
|
|
4792
5503
|
/**
|
|
4793
5504
|
* Activates a webhook (enables it to receive requests)
|
|
@@ -4796,9 +5507,7 @@ var init_webhook_api_service = __esm({
|
|
|
4796
5507
|
* @throws Error if the webhook is not found or the operation fails
|
|
4797
5508
|
*/
|
|
4798
5509
|
async activateWebhook(webhookId) {
|
|
4799
|
-
return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/activate`, {}, {
|
|
4800
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4801
|
-
});
|
|
5510
|
+
return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/activate`, {}, {});
|
|
4802
5511
|
}
|
|
4803
5512
|
/**
|
|
4804
5513
|
* Deactivates a webhook (stops it from receiving requests)
|
|
@@ -4807,9 +5516,7 @@ var init_webhook_api_service = __esm({
|
|
|
4807
5516
|
* @throws Error if the webhook is not found or the operation fails
|
|
4808
5517
|
*/
|
|
4809
5518
|
async deactivateWebhook(webhookId) {
|
|
4810
|
-
return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/deactivate`, {}, {
|
|
4811
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4812
|
-
});
|
|
5519
|
+
return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/deactivate`, {}, {});
|
|
4813
5520
|
}
|
|
4814
5521
|
/**
|
|
4815
5522
|
* Deletes a webhook and all its versions, or deactivates it if it has versions
|
|
@@ -4820,9 +5527,7 @@ var init_webhook_api_service = __esm({
|
|
|
4820
5527
|
* @throws Error if the webhook is not found or the delete operation fails
|
|
4821
5528
|
*/
|
|
4822
5529
|
async deleteWebhook(webhookId) {
|
|
4823
|
-
return this.httpDelete(`/developer/webhooks/${this.agentId}/${webhookId}`, {
|
|
4824
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
4825
|
-
});
|
|
5530
|
+
return this.httpDelete(`/developer/webhooks/${this.agentId}/${webhookId}`, {});
|
|
4826
5531
|
}
|
|
4827
5532
|
};
|
|
4828
5533
|
}
|
|
@@ -4855,7 +5560,7 @@ var init_job_instance = __esm({
|
|
|
4855
5560
|
this.activeVersion = jobData.activeVersion;
|
|
4856
5561
|
this.metadata = jobData.metadata || {};
|
|
4857
5562
|
if (jobData.userId && jobData.agentId) {
|
|
4858
|
-
this.userApi = new UserDataApi(BASE_URLS.API, jobApi.
|
|
5563
|
+
this.userApi = new UserDataApi(BASE_URLS.API, jobApi.credential, jobApi.agentId);
|
|
4859
5564
|
}
|
|
4860
5565
|
}
|
|
4861
5566
|
/**
|
|
@@ -5009,17 +5714,17 @@ var init_job_api_service = __esm({
|
|
|
5009
5714
|
static {
|
|
5010
5715
|
__name(this, "JobApi");
|
|
5011
5716
|
}
|
|
5012
|
-
apiKey;
|
|
5013
5717
|
agentId;
|
|
5718
|
+
credential;
|
|
5014
5719
|
/**
|
|
5015
5720
|
* Creates an instance of JobApi
|
|
5016
5721
|
* @param baseUrl - The base URL for the API
|
|
5017
|
-
* @param
|
|
5722
|
+
* @param credential - The API key for authentication
|
|
5018
5723
|
* @param agentId - The unique identifier of the agent
|
|
5019
5724
|
*/
|
|
5020
|
-
constructor(baseUrl,
|
|
5021
|
-
super(baseUrl);
|
|
5022
|
-
this.
|
|
5725
|
+
constructor(baseUrl, credential, agentId) {
|
|
5726
|
+
super(baseUrl, credential);
|
|
5727
|
+
this.credential = credential;
|
|
5023
5728
|
this.agentId = agentId;
|
|
5024
5729
|
}
|
|
5025
5730
|
/**
|
|
@@ -5033,9 +5738,7 @@ var init_job_api_service = __esm({
|
|
|
5033
5738
|
queryParams.append("includeDynamic", "true");
|
|
5034
5739
|
}
|
|
5035
5740
|
const url = `/developer/jobs/${this.agentId}?${queryParams.toString()}`;
|
|
5036
|
-
return this.httpGet(url, {
|
|
5037
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5038
|
-
});
|
|
5741
|
+
return this.httpGet(url, {});
|
|
5039
5742
|
}
|
|
5040
5743
|
/**
|
|
5041
5744
|
* Retrieves all jobs for the agent as JobInstance array
|
|
@@ -5058,9 +5761,7 @@ var init_job_api_service = __esm({
|
|
|
5058
5761
|
* @throws Error if the job is not found or the request fails
|
|
5059
5762
|
*/
|
|
5060
5763
|
async getJob(jobId) {
|
|
5061
|
-
const response = await this.httpGet(`/developer/jobs/${this.agentId}/${jobId}`, {
|
|
5062
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5063
|
-
});
|
|
5764
|
+
const response = await this.httpGet(`/developer/jobs/${this.agentId}/${jobId}`, {});
|
|
5064
5765
|
if (response.success && response.data) {
|
|
5065
5766
|
return new JobInstance(this, response.data);
|
|
5066
5767
|
}
|
|
@@ -5077,9 +5778,7 @@ var init_job_api_service = __esm({
|
|
|
5077
5778
|
* @throws Error if the job creation fails or validation errors occur
|
|
5078
5779
|
*/
|
|
5079
5780
|
async createJob(jobData) {
|
|
5080
|
-
return this.httpPost(`/developer/jobs/${this.agentId}`, jobData, {
|
|
5081
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5082
|
-
});
|
|
5781
|
+
return this.httpPost(`/developer/jobs/${this.agentId}`, jobData, {});
|
|
5083
5782
|
}
|
|
5084
5783
|
/**
|
|
5085
5784
|
* Creates a new job for the agent and returns a JobInstance.
|
|
@@ -5092,9 +5791,7 @@ var init_job_api_service = __esm({
|
|
|
5092
5791
|
* @throws Error if the job creation fails or validation errors occur
|
|
5093
5792
|
*/
|
|
5094
5793
|
async createJobInstance(jobData) {
|
|
5095
|
-
const response = await this.httpPost(`/developer/jobs/${this.agentId}`, jobData, {
|
|
5096
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5097
|
-
});
|
|
5794
|
+
const response = await this.httpPost(`/developer/jobs/${this.agentId}`, jobData, {});
|
|
5098
5795
|
if (response.success && response.data) {
|
|
5099
5796
|
return new JobInstance(this, response.data);
|
|
5100
5797
|
}
|
|
@@ -5108,9 +5805,7 @@ var init_job_api_service = __esm({
|
|
|
5108
5805
|
* @throws Error if the job is not found or the push operation fails
|
|
5109
5806
|
*/
|
|
5110
5807
|
async pushJob(jobId, versionData) {
|
|
5111
|
-
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/version`, versionData, {
|
|
5112
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5113
|
-
});
|
|
5808
|
+
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/version`, versionData, {});
|
|
5114
5809
|
}
|
|
5115
5810
|
/**
|
|
5116
5811
|
* Pushes a new development/sandbox version of a job for testing
|
|
@@ -5120,9 +5815,7 @@ var init_job_api_service = __esm({
|
|
|
5120
5815
|
* @throws Error if the job is not found or the push operation fails
|
|
5121
5816
|
*/
|
|
5122
5817
|
async pushDevJob(jobId, versionData) {
|
|
5123
|
-
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/version/sandbox`, versionData, {
|
|
5124
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5125
|
-
});
|
|
5818
|
+
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/version/sandbox`, versionData, {});
|
|
5126
5819
|
}
|
|
5127
5820
|
/**
|
|
5128
5821
|
* Updates an existing development/sandbox version of a job
|
|
@@ -5133,9 +5826,7 @@ var init_job_api_service = __esm({
|
|
|
5133
5826
|
* @throws Error if the job or version is not found or the update fails
|
|
5134
5827
|
*/
|
|
5135
5828
|
async updateDevJob(jobId, sandboxVersionId, versionData) {
|
|
5136
|
-
return this.httpPut(`/developer/jobs/${this.agentId}/${jobId}/version/sandbox/${sandboxVersionId}`, versionData, {
|
|
5137
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5138
|
-
});
|
|
5829
|
+
return this.httpPut(`/developer/jobs/${this.agentId}/${jobId}/version/sandbox/${sandboxVersionId}`, versionData, {});
|
|
5139
5830
|
}
|
|
5140
5831
|
/**
|
|
5141
5832
|
* Retrieves all versions of a specific job
|
|
@@ -5144,9 +5835,7 @@ var init_job_api_service = __esm({
|
|
|
5144
5835
|
* @throws Error if the job is not found or the request fails
|
|
5145
5836
|
*/
|
|
5146
5837
|
async getJobVersions(jobId) {
|
|
5147
|
-
return this.httpGet(`/developer/jobs/${this.agentId}/${jobId}/versions`, {
|
|
5148
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5149
|
-
});
|
|
5838
|
+
return this.httpGet(`/developer/jobs/${this.agentId}/${jobId}/versions`, {});
|
|
5150
5839
|
}
|
|
5151
5840
|
/**
|
|
5152
5841
|
* Publishes a specific version of a job to production
|
|
@@ -5156,9 +5845,7 @@ var init_job_api_service = __esm({
|
|
|
5156
5845
|
* @throws Error if the job or version is not found or the publish operation fails
|
|
5157
5846
|
*/
|
|
5158
5847
|
async publishJobVersion(jobId, version) {
|
|
5159
|
-
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/${version}/publish`, {}, {
|
|
5160
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5161
|
-
});
|
|
5848
|
+
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/${version}/publish`, {}, {});
|
|
5162
5849
|
}
|
|
5163
5850
|
/**
|
|
5164
5851
|
* Deletes a job and all its versions, or deactivates it if it has versions
|
|
@@ -5169,9 +5856,7 @@ var init_job_api_service = __esm({
|
|
|
5169
5856
|
* @throws Error if the job is not found or the delete operation fails
|
|
5170
5857
|
*/
|
|
5171
5858
|
async deleteJob(jobId) {
|
|
5172
|
-
return this.httpDelete(`/developer/jobs/${this.agentId}/${jobId}`, {
|
|
5173
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5174
|
-
});
|
|
5859
|
+
return this.httpDelete(`/developer/jobs/${this.agentId}/${jobId}`, {});
|
|
5175
5860
|
}
|
|
5176
5861
|
/**
|
|
5177
5862
|
* Activates a job (enables it to run on schedule)
|
|
@@ -5180,9 +5865,7 @@ var init_job_api_service = __esm({
|
|
|
5180
5865
|
* @throws Error if the job is not found or the operation fails
|
|
5181
5866
|
*/
|
|
5182
5867
|
async activateJob(jobId) {
|
|
5183
|
-
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/activate`, {}, {
|
|
5184
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5185
|
-
});
|
|
5868
|
+
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/activate`, {}, {});
|
|
5186
5869
|
}
|
|
5187
5870
|
/**
|
|
5188
5871
|
* Deactivates a job (disables it from running)
|
|
@@ -5191,9 +5874,7 @@ var init_job_api_service = __esm({
|
|
|
5191
5874
|
* @throws Error if the job is not found or the operation fails
|
|
5192
5875
|
*/
|
|
5193
5876
|
async deactivateJob(jobId) {
|
|
5194
|
-
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/deactivate`, {}, {
|
|
5195
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5196
|
-
});
|
|
5877
|
+
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/deactivate`, {}, {});
|
|
5197
5878
|
}
|
|
5198
5879
|
/**
|
|
5199
5880
|
* Manually triggers a job execution (ignores schedule)
|
|
@@ -5206,9 +5887,7 @@ var init_job_api_service = __esm({
|
|
|
5206
5887
|
const body = versionId ? {
|
|
5207
5888
|
versionId
|
|
5208
5889
|
} : {};
|
|
5209
|
-
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/trigger`, body, {
|
|
5210
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5211
|
-
});
|
|
5890
|
+
return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/trigger`, body, {});
|
|
5212
5891
|
}
|
|
5213
5892
|
/**
|
|
5214
5893
|
* Retrieves execution history for a job
|
|
@@ -5218,9 +5897,7 @@ var init_job_api_service = __esm({
|
|
|
5218
5897
|
* @throws Error if the job is not found or the request fails
|
|
5219
5898
|
*/
|
|
5220
5899
|
async getJobExecutions(jobId, limit = 50) {
|
|
5221
|
-
return this.httpGet(`/developer/jobs/${this.agentId}/${jobId}/executions?limit=${limit}`, {
|
|
5222
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5223
|
-
});
|
|
5900
|
+
return this.httpGet(`/developer/jobs/${this.agentId}/${jobId}/executions?limit=${limit}`, {});
|
|
5224
5901
|
}
|
|
5225
5902
|
/**
|
|
5226
5903
|
* Updates the metadata of a job
|
|
@@ -5230,9 +5907,7 @@ var init_job_api_service = __esm({
|
|
|
5230
5907
|
* @throws Error if the job is not found or the metadata update fails
|
|
5231
5908
|
*/
|
|
5232
5909
|
async updateMetadata(jobId, metadata) {
|
|
5233
|
-
return this.httpPut(`/developer/jobs/${this.agentId}/${jobId}/metadata`, metadata, {
|
|
5234
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5235
|
-
});
|
|
5910
|
+
return this.httpPut(`/developer/jobs/${this.agentId}/${jobId}/metadata`, metadata, {});
|
|
5236
5911
|
}
|
|
5237
5912
|
};
|
|
5238
5913
|
}
|
|
@@ -5249,15 +5924,12 @@ var init_ai_api_service = __esm({
|
|
|
5249
5924
|
static {
|
|
5250
5925
|
__name(this, "AiApiService");
|
|
5251
5926
|
}
|
|
5252
|
-
apiKey;
|
|
5253
5927
|
agentId;
|
|
5254
|
-
constructor(baseUrl,
|
|
5255
|
-
super(baseUrl
|
|
5928
|
+
constructor(baseUrl, credential, agentId) {
|
|
5929
|
+
super(baseUrl, credential), this.agentId = agentId;
|
|
5256
5930
|
}
|
|
5257
5931
|
async generate(body) {
|
|
5258
|
-
return this.httpPost(`/developer/ai/${this.agentId}/generate`, body, {
|
|
5259
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5260
|
-
});
|
|
5932
|
+
return this.httpPost(`/developer/ai/${this.agentId}/generate`, body, {});
|
|
5261
5933
|
}
|
|
5262
5934
|
/**
|
|
5263
5935
|
* Handles the simplified-vs-full-options branching for `AI.generate`.
|
|
@@ -5294,15 +5966,12 @@ var init_integrations_api_service = __esm({
|
|
|
5294
5966
|
static {
|
|
5295
5967
|
__name(this, "IntegrationsApiService");
|
|
5296
5968
|
}
|
|
5297
|
-
apiKey;
|
|
5298
5969
|
agentId;
|
|
5299
|
-
constructor(baseUrl,
|
|
5300
|
-
super(baseUrl
|
|
5970
|
+
constructor(baseUrl, credential, agentId) {
|
|
5971
|
+
super(baseUrl, credential), this.agentId = agentId;
|
|
5301
5972
|
}
|
|
5302
5973
|
async passthrough(integrationType, request) {
|
|
5303
|
-
return this.httpPost(`/developer/unifiedto/connections/${encodeURIComponent(this.agentId)}/passthrough/${encodeURIComponent(integrationType)}`, request, {
|
|
5304
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5305
|
-
});
|
|
5974
|
+
return this.httpPost(`/developer/unifiedto/connections/${encodeURIComponent(this.agentId)}/passthrough/${encodeURIComponent(integrationType)}`, request, {});
|
|
5306
5975
|
}
|
|
5307
5976
|
/**
|
|
5308
5977
|
* Sandbox-facing wrapper: returns the raw provider envelope
|
|
@@ -5331,9 +6000,8 @@ var init_agents_api_service = __esm({
|
|
|
5331
6000
|
static {
|
|
5332
6001
|
__name(this, "AgentsApiService");
|
|
5333
6002
|
}
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
super(baseUrl), this.apiKey = apiKey;
|
|
6003
|
+
constructor(baseUrl, credential) {
|
|
6004
|
+
super(baseUrl, credential);
|
|
5337
6005
|
}
|
|
5338
6006
|
async invoke(targetAgentId, body) {
|
|
5339
6007
|
const channel = body.channel ?? "agent-invocation";
|
|
@@ -5342,9 +6010,7 @@ var init_agents_api_service = __esm({
|
|
|
5342
6010
|
});
|
|
5343
6011
|
if (body.identifier) query.set("identifier", body.identifier);
|
|
5344
6012
|
const chatBody = this.toChatGenerateBody(body);
|
|
5345
|
-
return this.httpPost(`/chat/generate/${targetAgentId}?${query.toString()}`, chatBody, {
|
|
5346
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5347
|
-
});
|
|
6013
|
+
return this.httpPost(`/chat/generate/${targetAgentId}?${query.toString()}`, chatBody, {});
|
|
5348
6014
|
}
|
|
5349
6015
|
/**
|
|
5350
6016
|
* Sandbox overload: mirrors the `AI.generate` pattern where the simplified
|
|
@@ -5405,17 +6071,15 @@ var init_whatsapp_templates_api_service = __esm({
|
|
|
5405
6071
|
static {
|
|
5406
6072
|
__name(this, "WhatsAppTemplatesApiService");
|
|
5407
6073
|
}
|
|
5408
|
-
apiKey;
|
|
5409
6074
|
agentId;
|
|
5410
6075
|
/**
|
|
5411
6076
|
* Creates an instance of WhatsAppTemplatesApiService
|
|
5412
6077
|
* @param baseUrl - The base URL for the API
|
|
5413
|
-
* @param
|
|
6078
|
+
* @param credential - The API key for authentication
|
|
5414
6079
|
* @param agentId - The unique identifier of the agent
|
|
5415
6080
|
*/
|
|
5416
|
-
constructor(baseUrl,
|
|
5417
|
-
super(baseUrl);
|
|
5418
|
-
this.apiKey = apiKey;
|
|
6081
|
+
constructor(baseUrl, credential, agentId) {
|
|
6082
|
+
super(baseUrl, credential);
|
|
5419
6083
|
this.agentId = agentId;
|
|
5420
6084
|
}
|
|
5421
6085
|
/**
|
|
@@ -5432,9 +6096,7 @@ var init_whatsapp_templates_api_service = __esm({
|
|
|
5432
6096
|
if (search) {
|
|
5433
6097
|
url += `&search=${encodeURIComponent(search)}`;
|
|
5434
6098
|
}
|
|
5435
|
-
const response = await this.httpGet(url, {
|
|
5436
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5437
|
-
});
|
|
6099
|
+
const response = await this.httpGet(url, {});
|
|
5438
6100
|
if (response.success) {
|
|
5439
6101
|
return response.data;
|
|
5440
6102
|
}
|
|
@@ -5448,9 +6110,7 @@ var init_whatsapp_templates_api_service = __esm({
|
|
|
5448
6110
|
*/
|
|
5449
6111
|
async get(channelId, templateId) {
|
|
5450
6112
|
const url = `/admin/agents/${this.agentId}/channels/${channelId}/whatsapp-templates/${templateId}`;
|
|
5451
|
-
const response = await this.httpGet(url, {
|
|
5452
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5453
|
-
});
|
|
6113
|
+
const response = await this.httpGet(url, {});
|
|
5454
6114
|
if (response.success) {
|
|
5455
6115
|
return response.data;
|
|
5456
6116
|
}
|
|
@@ -5469,9 +6129,7 @@ var init_whatsapp_templates_api_service = __esm({
|
|
|
5469
6129
|
phone_numbers: data.phoneNumbers,
|
|
5470
6130
|
values: data.values
|
|
5471
6131
|
};
|
|
5472
|
-
const response = await this.httpPost(url, body, {
|
|
5473
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5474
|
-
});
|
|
6132
|
+
const response = await this.httpPost(url, body, {});
|
|
5475
6133
|
if (response.success) {
|
|
5476
6134
|
return response.data;
|
|
5477
6135
|
}
|
|
@@ -5486,15 +6144,17 @@ var CdnApi;
|
|
|
5486
6144
|
var init_cdn_api_service = __esm({
|
|
5487
6145
|
"src/api/cdn.api.service.ts"() {
|
|
5488
6146
|
"use strict";
|
|
6147
|
+
init_lua_fetch();
|
|
6148
|
+
init_request_credential();
|
|
5489
6149
|
CdnApi = class {
|
|
5490
6150
|
static {
|
|
5491
6151
|
__name(this, "CdnApi");
|
|
5492
6152
|
}
|
|
5493
6153
|
baseUrl;
|
|
5494
|
-
|
|
5495
|
-
constructor(baseUrl,
|
|
6154
|
+
credential;
|
|
6155
|
+
constructor(baseUrl, credential) {
|
|
5496
6156
|
this.baseUrl = baseUrl;
|
|
5497
|
-
this.
|
|
6157
|
+
this.credential = credential;
|
|
5498
6158
|
}
|
|
5499
6159
|
/**
|
|
5500
6160
|
* Uploads a file to the CDN
|
|
@@ -5504,10 +6164,10 @@ var init_cdn_api_service = __esm({
|
|
|
5504
6164
|
async upload(file) {
|
|
5505
6165
|
const formData = new FormData();
|
|
5506
6166
|
formData.append("file", file, file.name);
|
|
5507
|
-
const response = await
|
|
6167
|
+
const response = await luaFetch(`${this.baseUrl}/upload`, {
|
|
5508
6168
|
method: "POST",
|
|
5509
6169
|
headers: {
|
|
5510
|
-
Authorization: `Bearer ${this.
|
|
6170
|
+
Authorization: `Bearer ${await bearerFor(this.credential)}`
|
|
5511
6171
|
},
|
|
5512
6172
|
body: formData
|
|
5513
6173
|
});
|
|
@@ -5522,7 +6182,7 @@ var init_cdn_api_service = __esm({
|
|
|
5522
6182
|
* Fetches a file from the CDN by its ID
|
|
5523
6183
|
*/
|
|
5524
6184
|
async get(fileId) {
|
|
5525
|
-
const response = await
|
|
6185
|
+
const response = await luaFetch(`${this.baseUrl}/${fileId}`);
|
|
5526
6186
|
if (!response.ok) {
|
|
5527
6187
|
throw new Error(`File not found: ${response.status}`);
|
|
5528
6188
|
}
|
|
@@ -5551,17 +6211,15 @@ var init_developer_api_service = __esm({
|
|
|
5551
6211
|
static {
|
|
5552
6212
|
__name(this, "DeveloperApi");
|
|
5553
6213
|
}
|
|
5554
|
-
apiKey;
|
|
5555
6214
|
agentId;
|
|
5556
6215
|
/**
|
|
5557
6216
|
* Creates an instance of DeveloperApi
|
|
5558
6217
|
* @param baseUrl - The base URL for the API
|
|
5559
|
-
* @param
|
|
6218
|
+
* @param credential - The API key for authentication
|
|
5560
6219
|
* @param agentId - The unique identifier of the agent
|
|
5561
6220
|
*/
|
|
5562
|
-
constructor(baseUrl,
|
|
5563
|
-
super(baseUrl);
|
|
5564
|
-
this.apiKey = apiKey;
|
|
6221
|
+
constructor(baseUrl, credential, agentId) {
|
|
6222
|
+
super(baseUrl, credential);
|
|
5565
6223
|
this.agentId = agentId;
|
|
5566
6224
|
}
|
|
5567
6225
|
/**
|
|
@@ -5571,9 +6229,7 @@ var init_developer_api_service = __esm({
|
|
|
5571
6229
|
* @throws Error if the API request fails or the agent is not found
|
|
5572
6230
|
*/
|
|
5573
6231
|
async getEnvironmentVariables() {
|
|
5574
|
-
return this.httpGet(`/developer/agents/${this.agentId}/env`, {
|
|
5575
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5576
|
-
});
|
|
6232
|
+
return this.httpGet(`/developer/agents/${this.agentId}/env`, {});
|
|
5577
6233
|
}
|
|
5578
6234
|
/**
|
|
5579
6235
|
* Updates all environment variables for the agent in production
|
|
@@ -5583,9 +6239,7 @@ var init_developer_api_service = __esm({
|
|
|
5583
6239
|
* @throws Error if the API request fails or the agent is not found
|
|
5584
6240
|
*/
|
|
5585
6241
|
async updateEnvironmentVariables(envData) {
|
|
5586
|
-
return this.httpPost(`/developer/agents/${this.agentId}/env`, envData, {
|
|
5587
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5588
|
-
});
|
|
6242
|
+
return this.httpPost(`/developer/agents/${this.agentId}/env`, envData, {});
|
|
5589
6243
|
}
|
|
5590
6244
|
/**
|
|
5591
6245
|
* Deletes a specific environment variable by key
|
|
@@ -5594,27 +6248,21 @@ var init_developer_api_service = __esm({
|
|
|
5594
6248
|
* @throws Error if the API request fails, the agent is not found, or the key doesn't exist
|
|
5595
6249
|
*/
|
|
5596
6250
|
async deleteEnvironmentVariable(key) {
|
|
5597
|
-
return this.httpDelete(`/developer/agents/${this.agentId}/env/${key}`, {
|
|
5598
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5599
|
-
});
|
|
6251
|
+
return this.httpDelete(`/developer/agents/${this.agentId}/env/${key}`, {});
|
|
5600
6252
|
}
|
|
5601
6253
|
/**
|
|
5602
6254
|
* Retrieves all MCP server configurations for the agent
|
|
5603
6255
|
* @returns Promise resolving to an ApiResponse containing MCP server configurations
|
|
5604
6256
|
*/
|
|
5605
6257
|
async getMCPServers() {
|
|
5606
|
-
return this.httpGet(`/developer/agents/${this.agentId}/mcp-servers`, {
|
|
5607
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5608
|
-
});
|
|
6258
|
+
return this.httpGet(`/developer/agents/${this.agentId}/mcp-servers`, {});
|
|
5609
6259
|
}
|
|
5610
6260
|
/**
|
|
5611
6261
|
* Retrieves only active MCP server configurations for the agent
|
|
5612
6262
|
* @returns Promise resolving to an ApiResponse containing active MCP server configurations
|
|
5613
6263
|
*/
|
|
5614
6264
|
async getActiveMCPServers() {
|
|
5615
|
-
return this.httpGet(`/developer/agents/${this.agentId}/mcp-servers/active`, {
|
|
5616
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5617
|
-
});
|
|
6265
|
+
return this.httpGet(`/developer/agents/${this.agentId}/mcp-servers/active`, {});
|
|
5618
6266
|
}
|
|
5619
6267
|
/**
|
|
5620
6268
|
* Gets a single MCP server by ID
|
|
@@ -5622,9 +6270,7 @@ var init_developer_api_service = __esm({
|
|
|
5622
6270
|
* @returns Promise resolving to an ApiResponse with the MCP server
|
|
5623
6271
|
*/
|
|
5624
6272
|
async getMCPServer(mcpServerId) {
|
|
5625
|
-
return this.httpGet(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}`, {
|
|
5626
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5627
|
-
});
|
|
6273
|
+
return this.httpGet(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}`, {});
|
|
5628
6274
|
}
|
|
5629
6275
|
/**
|
|
5630
6276
|
* Creates a new MCP server
|
|
@@ -5632,9 +6278,7 @@ var init_developer_api_service = __esm({
|
|
|
5632
6278
|
* @returns Promise resolving to an ApiResponse with the created MCP server
|
|
5633
6279
|
*/
|
|
5634
6280
|
async createMCPServer(mcpServerData) {
|
|
5635
|
-
return this.httpPost(`/developer/agents/${this.agentId}/mcp-servers`, mcpServerData, {
|
|
5636
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5637
|
-
});
|
|
6281
|
+
return this.httpPost(`/developer/agents/${this.agentId}/mcp-servers`, mcpServerData, {});
|
|
5638
6282
|
}
|
|
5639
6283
|
/**
|
|
5640
6284
|
* Updates an existing MCP server
|
|
@@ -5643,9 +6287,7 @@ var init_developer_api_service = __esm({
|
|
|
5643
6287
|
* @returns Promise resolving to an ApiResponse with the updated MCP server
|
|
5644
6288
|
*/
|
|
5645
6289
|
async updateMCPServer(mcpServerId, mcpServerData) {
|
|
5646
|
-
return this.httpPut(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}`, mcpServerData, {
|
|
5647
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5648
|
-
});
|
|
6290
|
+
return this.httpPut(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}`, mcpServerData, {});
|
|
5649
6291
|
}
|
|
5650
6292
|
/**
|
|
5651
6293
|
* Deletes an MCP server
|
|
@@ -5653,9 +6295,7 @@ var init_developer_api_service = __esm({
|
|
|
5653
6295
|
* @returns Promise resolving to an ApiResponse with confirmation
|
|
5654
6296
|
*/
|
|
5655
6297
|
async deleteMCPServer(mcpServerId) {
|
|
5656
|
-
return this.httpDelete(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}`, {
|
|
5657
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5658
|
-
});
|
|
6298
|
+
return this.httpDelete(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}`, {});
|
|
5659
6299
|
}
|
|
5660
6300
|
/**
|
|
5661
6301
|
* Activates an MCP server
|
|
@@ -5663,9 +6303,7 @@ var init_developer_api_service = __esm({
|
|
|
5663
6303
|
* @returns Promise resolving to an ApiResponse with the activated MCP server
|
|
5664
6304
|
*/
|
|
5665
6305
|
async activateMCPServer(mcpServerId) {
|
|
5666
|
-
return this.httpPut(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}/activate`, {}, {
|
|
5667
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5668
|
-
});
|
|
6306
|
+
return this.httpPut(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}/activate`, {}, {});
|
|
5669
6307
|
}
|
|
5670
6308
|
/**
|
|
5671
6309
|
* Deactivates an MCP server
|
|
@@ -5673,9 +6311,7 @@ var init_developer_api_service = __esm({
|
|
|
5673
6311
|
* @returns Promise resolving to an ApiResponse with the deactivated MCP server
|
|
5674
6312
|
*/
|
|
5675
6313
|
async deactivateMCPServer(mcpServerId) {
|
|
5676
|
-
return this.httpPut(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}/deactivate`, {}, {
|
|
5677
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5678
|
-
});
|
|
6314
|
+
return this.httpPut(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}/deactivate`, {}, {});
|
|
5679
6315
|
}
|
|
5680
6316
|
/**
|
|
5681
6317
|
* Creates or updates an MCP server by name (upsert)
|
|
@@ -5683,9 +6319,7 @@ var init_developer_api_service = __esm({
|
|
|
5683
6319
|
* @returns Promise resolving to an ApiResponse with the created/updated MCP server
|
|
5684
6320
|
*/
|
|
5685
6321
|
async upsertMCPServer(mcpServerData) {
|
|
5686
|
-
return this.httpPost(`/developer/agents/${this.agentId}/mcp-servers/upsert`, mcpServerData, {
|
|
5687
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5688
|
-
});
|
|
6322
|
+
return this.httpPost(`/developer/agents/${this.agentId}/mcp-servers/upsert`, mcpServerData, {});
|
|
5689
6323
|
}
|
|
5690
6324
|
/**
|
|
5691
6325
|
* Gets a user profile by email address
|
|
@@ -5695,9 +6329,7 @@ var init_developer_api_service = __esm({
|
|
|
5695
6329
|
async getUserProfileByEmail(email, agentId) {
|
|
5696
6330
|
const path3 = `/developer/user/profile/email/${encodeURIComponent(email)}`;
|
|
5697
6331
|
const scopedPath = agentId ? `${path3}?agentId=${encodeURIComponent(agentId)}` : path3;
|
|
5698
|
-
return this.httpGet(scopedPath, {
|
|
5699
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5700
|
-
});
|
|
6332
|
+
return this.httpGet(scopedPath, {});
|
|
5701
6333
|
}
|
|
5702
6334
|
/**
|
|
5703
6335
|
* Gets a user profile by phone number
|
|
@@ -5708,9 +6340,7 @@ var init_developer_api_service = __esm({
|
|
|
5708
6340
|
const normalizedPhone = phone.replace(/^\+/, "");
|
|
5709
6341
|
const path3 = `/developer/user/profile/phone/${normalizedPhone}`;
|
|
5710
6342
|
const scopedPath = agentId ? `${path3}?agentId=${encodeURIComponent(agentId)}` : path3;
|
|
5711
|
-
return this.httpGet(scopedPath, {
|
|
5712
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5713
|
-
});
|
|
6343
|
+
return this.httpGet(scopedPath, {});
|
|
5714
6344
|
}
|
|
5715
6345
|
};
|
|
5716
6346
|
}
|
|
@@ -5726,42 +6356,28 @@ var init_voice_api_service = __esm({
|
|
|
5726
6356
|
static {
|
|
5727
6357
|
__name(this, "VoiceApi");
|
|
5728
6358
|
}
|
|
5729
|
-
apiKey;
|
|
5730
6359
|
agentId;
|
|
5731
|
-
constructor(baseUrl,
|
|
5732
|
-
super(baseUrl);
|
|
5733
|
-
this.apiKey = apiKey;
|
|
6360
|
+
constructor(baseUrl, credential, agentId) {
|
|
6361
|
+
super(baseUrl, credential);
|
|
5734
6362
|
this.agentId = agentId;
|
|
5735
6363
|
}
|
|
5736
6364
|
async getVoices() {
|
|
5737
|
-
return this.httpGet(`/developer/voice-agents/${this.agentId}`, {
|
|
5738
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5739
|
-
});
|
|
6365
|
+
return this.httpGet(`/developer/voice-agents/${this.agentId}`, {});
|
|
5740
6366
|
}
|
|
5741
6367
|
async createVoice(voiceData) {
|
|
5742
|
-
return this.httpPost(`/developer/voice-agents/${this.agentId}`, voiceData, {
|
|
5743
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5744
|
-
});
|
|
6368
|
+
return this.httpPost(`/developer/voice-agents/${this.agentId}`, voiceData, {});
|
|
5745
6369
|
}
|
|
5746
6370
|
async pushVoice(voiceId, versionData) {
|
|
5747
|
-
return this.httpPost(`/developer/voice-agents/${this.agentId}/${voiceId}/version`, versionData, {
|
|
5748
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5749
|
-
});
|
|
6371
|
+
return this.httpPost(`/developer/voice-agents/${this.agentId}/${voiceId}/version`, versionData, {});
|
|
5750
6372
|
}
|
|
5751
6373
|
async getVoiceVersions(voiceId) {
|
|
5752
|
-
return this.httpGet(`/developer/voice-agents/${this.agentId}/${voiceId}/versions`, {
|
|
5753
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5754
|
-
});
|
|
6374
|
+
return this.httpGet(`/developer/voice-agents/${this.agentId}/${voiceId}/versions`, {});
|
|
5755
6375
|
}
|
|
5756
6376
|
async publishVoiceVersion(voiceId, version) {
|
|
5757
|
-
return this.httpPut(`/developer/voice-agents/${this.agentId}/${voiceId}/${version}/publish`, void 0, {
|
|
5758
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5759
|
-
});
|
|
6377
|
+
return this.httpPut(`/developer/voice-agents/${this.agentId}/${voiceId}/${version}/publish`, void 0, {});
|
|
5760
6378
|
}
|
|
5761
6379
|
async deleteVoice(voiceId) {
|
|
5762
|
-
return this.httpDelete(`/developer/voice-agents/${this.agentId}/${voiceId}`, {
|
|
5763
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5764
|
-
});
|
|
6380
|
+
return this.httpDelete(`/developer/voice-agents/${this.agentId}/${voiceId}`, {});
|
|
5765
6381
|
}
|
|
5766
6382
|
/**
|
|
5767
6383
|
* Place an outbound voice call. Wraps `POST /developer/voice-agents/:agentId/dispatch`
|
|
@@ -5769,9 +6385,7 @@ var init_voice_api_service = __esm({
|
|
|
5769
6385
|
* forwarded to the lua-livekit worker which allocates the room and dials.
|
|
5770
6386
|
*/
|
|
5771
6387
|
async dispatch(input) {
|
|
5772
|
-
return this.httpPost(`/developer/voice-agents/${this.agentId}/dispatch`, input, {
|
|
5773
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5774
|
-
});
|
|
6388
|
+
return this.httpPost(`/developer/voice-agents/${this.agentId}/dispatch`, input, {});
|
|
5775
6389
|
}
|
|
5776
6390
|
/**
|
|
5777
6391
|
* Create a voice room + client access token for a custom frontend
|
|
@@ -5780,9 +6394,7 @@ var init_voice_api_service = __esm({
|
|
|
5780
6394
|
* user. Wraps `POST /developer/voice/:agentId/session`.
|
|
5781
6395
|
*/
|
|
5782
6396
|
async createSession(input = {}) {
|
|
5783
|
-
return this.httpPost(`/developer/voice/${this.agentId}/session`, input, {
|
|
5784
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5785
|
-
});
|
|
6397
|
+
return this.httpPost(`/developer/voice/${this.agentId}/session`, input, {});
|
|
5786
6398
|
}
|
|
5787
6399
|
/**
|
|
5788
6400
|
* Sandbox helper: throws on non-success and returns the unwrapped output.
|
|
@@ -5826,34 +6438,25 @@ var init_channels_send_api_service = __esm({
|
|
|
5826
6438
|
static {
|
|
5827
6439
|
__name(this, "ChannelsSendApiService");
|
|
5828
6440
|
}
|
|
5829
|
-
apiKey;
|
|
5830
6441
|
agentId;
|
|
5831
|
-
constructor(baseUrl,
|
|
5832
|
-
super(baseUrl
|
|
6442
|
+
constructor(baseUrl, credential, agentId) {
|
|
6443
|
+
super(baseUrl, credential), this.agentId = agentId;
|
|
5833
6444
|
}
|
|
5834
6445
|
/** POST /developer/agents/:agentId/channels/send */
|
|
5835
6446
|
async send(input) {
|
|
5836
|
-
return this.httpPost(`/developer/agents/${this.agentId}/channels/send`, input, {
|
|
5837
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5838
|
-
});
|
|
6447
|
+
return this.httpPost(`/developer/agents/${this.agentId}/channels/send`, input, {});
|
|
5839
6448
|
}
|
|
5840
6449
|
/** POST /developer/agents/:agentId/channels/whatsapp/template */
|
|
5841
6450
|
async sendWhatsAppTemplate(input) {
|
|
5842
|
-
return this.httpPost(`/developer/agents/${this.agentId}/channels/whatsapp/template`, input, {
|
|
5843
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5844
|
-
});
|
|
6451
|
+
return this.httpPost(`/developer/agents/${this.agentId}/channels/whatsapp/template`, input, {});
|
|
5845
6452
|
}
|
|
5846
6453
|
/** POST /developer/agents/:agentId/channels/whatsapp/reaction */
|
|
5847
6454
|
async sendWhatsAppReaction(input) {
|
|
5848
|
-
return this.httpPost(`/developer/agents/${this.agentId}/channels/whatsapp/reaction`, input, {
|
|
5849
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5850
|
-
});
|
|
6455
|
+
return this.httpPost(`/developer/agents/${this.agentId}/channels/whatsapp/reaction`, input, {});
|
|
5851
6456
|
}
|
|
5852
6457
|
/** POST /developer/agents/:agentId/channels/email/send */
|
|
5853
6458
|
async sendEmail(input) {
|
|
5854
|
-
return this.httpPost(`/developer/agents/${this.agentId}/channels/email/send`, input, {
|
|
5855
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5856
|
-
});
|
|
6459
|
+
return this.httpPost(`/developer/agents/${this.agentId}/channels/email/send`, input, {});
|
|
5857
6460
|
}
|
|
5858
6461
|
/**
|
|
5859
6462
|
* Sandbox helper: throws on non-success, returns unwrapped output.
|
|
@@ -5916,16 +6519,13 @@ var init_inbox_push_api_service = __esm({
|
|
|
5916
6519
|
static {
|
|
5917
6520
|
__name(this, "InboxPushApiService");
|
|
5918
6521
|
}
|
|
5919
|
-
apiKey;
|
|
5920
6522
|
agentId;
|
|
5921
|
-
constructor(baseUrl,
|
|
5922
|
-
super(baseUrl
|
|
6523
|
+
constructor(baseUrl, credential, agentId) {
|
|
6524
|
+
super(baseUrl, credential), this.agentId = agentId;
|
|
5923
6525
|
}
|
|
5924
6526
|
/** POST /developer/agents/:agentId/inbox/push */
|
|
5925
6527
|
async push(input) {
|
|
5926
|
-
return this.httpPost(`/developer/agents/${this.agentId}/inbox/push`, input, {
|
|
5927
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5928
|
-
});
|
|
6528
|
+
return this.httpPost(`/developer/agents/${this.agentId}/inbox/push`, input, {});
|
|
5929
6529
|
}
|
|
5930
6530
|
};
|
|
5931
6531
|
}
|
|
@@ -5941,18 +6541,15 @@ var init_directory_api_service = __esm({
|
|
|
5941
6541
|
static {
|
|
5942
6542
|
__name(this, "DirectoryApiService");
|
|
5943
6543
|
}
|
|
5944
|
-
apiKey;
|
|
5945
6544
|
agentId;
|
|
5946
|
-
constructor(baseUrl,
|
|
5947
|
-
super(baseUrl
|
|
6545
|
+
constructor(baseUrl, credential, agentId) {
|
|
6546
|
+
super(baseUrl, credential), this.agentId = agentId;
|
|
5948
6547
|
}
|
|
5949
6548
|
/** POST /developer/agents/:agentId/directory/resolve */
|
|
5950
6549
|
async resolve(name) {
|
|
5951
6550
|
return this.httpPost(`/developer/agents/${this.agentId}/directory/resolve`, {
|
|
5952
6551
|
name
|
|
5953
|
-
}, {
|
|
5954
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5955
|
-
});
|
|
6552
|
+
}, {});
|
|
5956
6553
|
}
|
|
5957
6554
|
/** Sandbox helper: throws on non-success, returns unwrapped result. */
|
|
5958
6555
|
async resolveForSandbox(name) {
|
|
@@ -5983,71 +6580,47 @@ var init_device_api_service = __esm({
|
|
|
5983
6580
|
static {
|
|
5984
6581
|
__name(this, "DeviceApi");
|
|
5985
6582
|
}
|
|
5986
|
-
apiKey;
|
|
5987
6583
|
agentId;
|
|
5988
|
-
constructor(baseUrl,
|
|
5989
|
-
super(baseUrl);
|
|
5990
|
-
this.apiKey = apiKey;
|
|
6584
|
+
constructor(baseUrl, credential, agentId) {
|
|
6585
|
+
super(baseUrl, credential);
|
|
5991
6586
|
this.agentId = agentId;
|
|
5992
6587
|
}
|
|
5993
6588
|
async getDevices() {
|
|
5994
|
-
return this.httpGet(`/developer/devices/${this.agentId}`, {
|
|
5995
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
5996
|
-
});
|
|
6589
|
+
return this.httpGet(`/developer/devices/${this.agentId}`, {});
|
|
5997
6590
|
}
|
|
5998
6591
|
async createDevice(deviceData) {
|
|
5999
|
-
return this.httpPost(`/developer/devices/${this.agentId}`, deviceData, {
|
|
6000
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6001
|
-
});
|
|
6592
|
+
return this.httpPost(`/developer/devices/${this.agentId}`, deviceData, {});
|
|
6002
6593
|
}
|
|
6003
6594
|
async pushDevice(deviceId, versionData) {
|
|
6004
|
-
return this.httpPost(`/developer/devices/${this.agentId}/${deviceId}/version`, versionData, {
|
|
6005
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6006
|
-
});
|
|
6595
|
+
return this.httpPost(`/developer/devices/${this.agentId}/${deviceId}/version`, versionData, {});
|
|
6007
6596
|
}
|
|
6008
6597
|
async pushDevDevice(deviceId, versionData) {
|
|
6009
|
-
return this.httpPost(`/developer/devices/${this.agentId}/${deviceId}/version/sandbox`, versionData, {
|
|
6010
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6011
|
-
});
|
|
6598
|
+
return this.httpPost(`/developer/devices/${this.agentId}/${deviceId}/version/sandbox`, versionData, {});
|
|
6012
6599
|
}
|
|
6013
6600
|
async getDeviceVersions(deviceId) {
|
|
6014
|
-
return this.httpGet(`/developer/devices/${this.agentId}/${deviceId}/versions`, {
|
|
6015
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6016
|
-
});
|
|
6601
|
+
return this.httpGet(`/developer/devices/${this.agentId}/${deviceId}/versions`, {});
|
|
6017
6602
|
}
|
|
6018
6603
|
async publishDeviceVersion(deviceId, version) {
|
|
6019
|
-
return this.httpPost(`/developer/devices/${this.agentId}/${deviceId}/${version}/publish`, {}, {
|
|
6020
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6021
|
-
});
|
|
6604
|
+
return this.httpPost(`/developer/devices/${this.agentId}/${deviceId}/${version}/publish`, {}, {});
|
|
6022
6605
|
}
|
|
6023
6606
|
async deleteDevice(deviceId) {
|
|
6024
|
-
return this.httpDelete(`/developer/devices/${this.agentId}/${deviceId}`, {
|
|
6025
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6026
|
-
});
|
|
6607
|
+
return this.httpDelete(`/developer/devices/${this.agentId}/${deviceId}`, {});
|
|
6027
6608
|
}
|
|
6028
6609
|
async sendCommand(deviceName, command, payload, timeout) {
|
|
6029
6610
|
return this.httpPost(`/developer/devices/${this.agentId}/${deviceName}/command`, {
|
|
6030
6611
|
command,
|
|
6031
6612
|
payload,
|
|
6032
6613
|
timeout: timeout || 3e4
|
|
6033
|
-
}, {
|
|
6034
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6035
|
-
});
|
|
6614
|
+
}, {});
|
|
6036
6615
|
}
|
|
6037
6616
|
async getDeviceStatus(deviceName) {
|
|
6038
|
-
return this.httpGet(`/developer/devices/${this.agentId}/${deviceName}/status`, {
|
|
6039
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6040
|
-
});
|
|
6617
|
+
return this.httpGet(`/developer/devices/${this.agentId}/${deviceName}/status`, {});
|
|
6041
6618
|
}
|
|
6042
6619
|
async enableDevice(deviceName) {
|
|
6043
|
-
return this.httpPatch(`/developer/devices/${this.agentId}/${deviceName}/enable`, {}, {
|
|
6044
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6045
|
-
});
|
|
6620
|
+
return this.httpPatch(`/developer/devices/${this.agentId}/${deviceName}/enable`, {}, {});
|
|
6046
6621
|
}
|
|
6047
6622
|
async disableDevice(deviceName) {
|
|
6048
|
-
return this.httpPatch(`/developer/devices/${this.agentId}/${deviceName}/disable`, {}, {
|
|
6049
|
-
Authorization: `Bearer ${this.apiKey}`
|
|
6050
|
-
});
|
|
6623
|
+
return this.httpPatch(`/developer/devices/${this.agentId}/${deviceName}/disable`, {}, {});
|
|
6051
6624
|
}
|
|
6052
6625
|
};
|
|
6053
6626
|
}
|
|
@@ -6484,6 +7057,7 @@ var LuaWebhook = class {
|
|
|
6484
7057
|
querySchema;
|
|
6485
7058
|
headerSchema;
|
|
6486
7059
|
bodySchema;
|
|
7060
|
+
secret;
|
|
6487
7061
|
executeFunction;
|
|
6488
7062
|
/**
|
|
6489
7063
|
* Creates a new LuaWebhook instance.
|
|
@@ -6505,9 +7079,17 @@ var LuaWebhook = class {
|
|
|
6505
7079
|
this.querySchema = config.querySchema;
|
|
6506
7080
|
this.headerSchema = config.headerSchema;
|
|
6507
7081
|
this.bodySchema = config.bodySchema;
|
|
7082
|
+
this.secret = config.secret;
|
|
6508
7083
|
this.executeFunction = config.execute;
|
|
6509
7084
|
}
|
|
6510
7085
|
/**
|
|
7086
|
+
* Gets the webhook's signing key, if one is configured.
|
|
7087
|
+
* Never print this — it is the shared secret callers sign with.
|
|
7088
|
+
*/
|
|
7089
|
+
getSecret() {
|
|
7090
|
+
return this.secret;
|
|
7091
|
+
}
|
|
7092
|
+
/**
|
|
6511
7093
|
* Gets the webhook name.
|
|
6512
7094
|
*/
|
|
6513
7095
|
getName() {
|
|
@@ -6584,12 +7166,16 @@ var LuaTrigger = class {
|
|
|
6584
7166
|
verify;
|
|
6585
7167
|
filter;
|
|
6586
7168
|
transform;
|
|
7169
|
+
tool;
|
|
6587
7170
|
constructor(config) {
|
|
6588
7171
|
if (!config.name || !config.name.trim()) {
|
|
6589
7172
|
throw new Error("LuaTrigger requires a non-empty `name` (used as the server-side identifier).");
|
|
6590
7173
|
}
|
|
6591
|
-
if (!config.verify && !config.filter && !config.transform) {
|
|
6592
|
-
throw new Error("LuaTrigger requires at least one of verify, filter, or
|
|
7174
|
+
if (!config.verify && !config.filter && !config.transform && !config.tool) {
|
|
7175
|
+
throw new Error("LuaTrigger requires at least one of verify, filter, transform, or tool.");
|
|
7176
|
+
}
|
|
7177
|
+
if (config.tool && (!config.tool.name || !config.tool.name.trim())) {
|
|
7178
|
+
throw new Error("LuaTrigger `tool` requires a non-empty `name` (the bare authored tool name).");
|
|
6593
7179
|
}
|
|
6594
7180
|
this.name = config.name;
|
|
6595
7181
|
this.description = config.description;
|
|
@@ -6598,6 +7184,7 @@ var LuaTrigger = class {
|
|
|
6598
7184
|
this.verify = config.verify;
|
|
6599
7185
|
this.filter = config.filter;
|
|
6600
7186
|
this.transform = config.transform;
|
|
7187
|
+
this.tool = config.tool;
|
|
6601
7188
|
}
|
|
6602
7189
|
getName() {
|
|
6603
7190
|
return this.name;
|