lua-cli 3.28.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.
@@ -390,10 +390,21 @@ function triggerUrlEnvKey(triggerKey) {
390
390
  const upper = triggerKey.trim().replace(/[^A-Za-z0-9]+/g, "_").replace(/^_+|_+$/g, "").toUpperCase();
391
391
  return `${TEMPLATE_TRIGGER_URL_ENV_PREFIX}${upper}`;
392
392
  }
393
+ function deviceCredentialScopes(operations) {
394
+ return [
395
+ ...new Set(operations.map((operation) => DEVICE_SCOPE_BY_OPERATION[operation]))
396
+ ];
397
+ }
393
398
  function parsePrincipalContext(value) {
394
399
  const parsed = PrincipalContextSchema.safeParse(value);
395
400
  return parsed.success ? parsed.data : void 0;
396
401
  }
402
+ function isDeviceCredentialPrincipal(context) {
403
+ return context?.credential.type === "deviceCredential";
404
+ }
405
+ function hasDeviceCredentialType(value) {
406
+ return DeviceCredentialClaimSchema.safeParse(value).success;
407
+ }
397
408
  function isTypedApiKeyPrincipal(context) {
398
409
  return context?.subject.subjectType === "apiKey" && context.credential.type === "apiKey" && !context.compatibility;
399
410
  }
@@ -467,7 +478,7 @@ function isKnownProfile(profiles, profileId) {
467
478
  function hasCapability(profiles, profileId, required) {
468
479
  return capabilitiesFor(profiles, profileId).includes(required);
469
480
  }
470
- var __defProp2, __name2, CHANNEL_SEND_CHANNELS, REVIEWABLE_ACTION_EXECUTE_TOOL_ALLOWLIST, REVIEWABLE_MCP_SEND_TOOL_SUFFIX, MCP_TOOL_READ_VERB_RE, MCP_DRAFT_CREATE_VERBS, NON_INTERACTIVE_CHANNELS, RICH_PARTS_MESSAGE_ID_PREFIX, SCREENSHOT_MESSAGE_ID_PREFIX, BROWSER_COMMANDS, BROWSER_COMMAND_NAMES, DESKTOP_FILE_COMMANDS, DESKTOP_FILE_COMMAND_SET, REASONING_EFFORT_VALUES, IMPLICIT_MODEL_SELECTION_SOURCES, AGENT_NAME_TOKEN, DEFAULT_PERSONA_GUIDE, PERSONAL_SPACE_STARTING_PERSONA, VoiceNameSchema, PluginProviderSchema, RealtimeProviderSchema, PluginClassSchema, ModelDescriptorSchema, InferenceModelSchema, PluginModelSchema, RealtimeModelSchema, LuaVoiceModelSchema, TurnDetectionSchema, InterruptionSchema, BuiltinAudioClipSchema, AudioConfigSchema, BackgroundAudioEntrySchema, BackgroundAudioSchema, LuaVoiceConfigInnerSchema, LuaVoiceConfigSchema, LuaVoiceRefSchema, LUA_JOB_DEFAULT_TIMEOUT_SECONDS, LUA_JOB_MIN_TIMEOUT_SECONDS, LUA_JOB_MAX_TIMEOUT_SECONDS, TEMPLATE_TRIGGER_URL_ENV_PREFIX, SUBJECT_TYPES, SubjectTypeSchema, CREDENTIAL_TYPES, CredentialTypeSchema, PrincipalContextSchema, LUA_CLIENT_HEADER, LUA_CLIENT_APPS, SEMVER_PATTERN, WEB_RELEASE_PATTERN, CLIENT_HEADER_PATTERN, AUTHZ_PROJECTION_VERSION, ProjectedScopeSchema, DisplayRoleSchema, AuthorizationPrincipalSchema, CredentialContextSchema, ProjectionAnomalySchema, ProjectedOrgSchema, ProjectedResourceSchema, CapabilityProfilesSchema, RoleCatalogSchema, EffectiveAuthorizationSchema, ResourcePageSchema;
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;
471
482
  var init_dist = __esm({
472
483
  "../shared-types/dist/index.mjs"() {
473
484
  "use strict";
@@ -1153,36 +1164,139 @@ This text is who you are for this person. As you learn them, their name, their w
1153
1164
  "legacyInternalToken"
1154
1165
  ];
1155
1166
  CredentialTypeSchema = z2.enum(CREDENTIAL_TYPES);
1156
- PrincipalContextSchema = z2.object({
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({
1157
1247
  version: z2.literal(1),
1158
1248
  subject: z2.object({
1159
- subjectType: SubjectTypeSchema,
1160
- subjectId: z2.string().min(1).max(256)
1249
+ subjectType: z2.literal("apiKey"),
1250
+ subjectId: IdSchema
1161
1251
  }).strict(),
1162
1252
  actor: z2.object({
1163
- actorType: SubjectTypeSchema,
1164
- actorId: z2.string().min(1).max(256)
1165
- }).strict().optional(),
1166
- credential: z2.object({
1167
- type: CredentialTypeSchema,
1168
- id: z2.string().min(1).max(256).optional(),
1169
- issuedAt: z2.number().int().nonnegative().optional(),
1170
- expiresAt: z2.number().int().nonnegative().optional()
1253
+ actorType: z2.literal("apiKey"),
1254
+ actorId: IdSchema
1171
1255
  }).strict(),
1256
+ credential: DeviceCredentialDescriptorSchema,
1172
1257
  owner: z2.object({
1173
- type: z2.enum([
1174
- "user",
1175
- "org",
1176
- "service"
1177
- ]),
1178
- id: z2.string().min(1).max(256)
1179
- }).strict().optional(),
1180
- compatibility: z2.object({
1181
- mode: z2.literal("legacy-owner-delegation")
1182
- }).strict().optional()
1183
- }).strict();
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");
1184
1289
  __name(parsePrincipalContext, "parsePrincipalContext");
1185
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");
1186
1300
  __name(isTypedApiKeyPrincipal, "isTypedApiKeyPrincipal");
1187
1301
  __name2(isTypedApiKeyPrincipal, "isTypedApiKeyPrincipal");
1188
1302
  __name(typedApiKeyPrincipalId, "typedApiKeyPrincipalId");
@@ -1196,7 +1310,10 @@ This text is who you are for this person. As you learn them, their name, their w
1196
1310
  "claude-plugin",
1197
1311
  "codex-plugin",
1198
1312
  "cursor-plugin",
1199
- "platform-mcp"
1313
+ "platform-mcp",
1314
+ "device-node",
1315
+ "device-python",
1316
+ "device-micropython"
1200
1317
  ];
1201
1318
  SEMVER_PATTERN = /^(\d{1,3}\.\d{1,3}\.\d{1,3})(?:-[0-9A-Za-z.-]{1,16})?(?:\+[0-9A-Za-z.-]{1,16})?$/;
1202
1319
  WEB_RELEASE_PATTERN = /^[0-9a-f]{12}$/i;
@@ -1499,8 +1616,354 @@ var init_lua_fetch = __esm({
1499
1616
  }
1500
1617
  });
1501
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
+
1502
1965
  // src/api/http.client.ts
1503
- import { randomUUID } from "crypto";
1966
+ import { randomUUID as randomUUID2 } from "crypto";
1504
1967
  function parseRetryAfter(raw) {
1505
1968
  if (!raw) return void 0;
1506
1969
  const seconds = Number.parseInt(raw, 10);
@@ -1512,17 +1975,20 @@ var init_http_client = __esm({
1512
1975
  "use strict";
1513
1976
  init_auth_error();
1514
1977
  init_lua_fetch();
1978
+ init_request_credential();
1515
1979
  HttpClient = class {
1516
1980
  static {
1517
1981
  __name(this, "HttpClient");
1518
1982
  }
1519
1983
  baseUrl;
1984
+ requestCredential;
1520
1985
  /**
1521
1986
  * Creates an instance of HttpClient
1522
1987
  * @param baseUrl - The base URL for all API requests
1523
1988
  */
1524
- constructor(baseUrl) {
1989
+ constructor(baseUrl, requestCredential) {
1525
1990
  this.baseUrl = baseUrl;
1991
+ this.requestCredential = requestCredential;
1526
1992
  }
1527
1993
  /**
1528
1994
  * Makes an HTTP request with standardized error handling
@@ -1535,12 +2001,16 @@ var init_http_client = __esm({
1535
2001
  const controller = new AbortController();
1536
2002
  const timeoutId = setTimeout(() => controller.abort(), 3e4);
1537
2003
  try {
2004
+ const authorization = this.requestCredential ? `Bearer ${await bearerFor(this.requestCredential)}` : void 0;
1538
2005
  const response = await luaFetch(url, {
1539
2006
  ...options,
1540
2007
  signal: controller.signal,
1541
2008
  headers: {
1542
2009
  "Content-Type": "application/json",
1543
- ...options.headers
2010
+ ...options.headers,
2011
+ ...authorization ? {
2012
+ Authorization: authorization
2013
+ } : {}
1544
2014
  }
1545
2015
  });
1546
2016
  clearTimeout(timeoutId);
@@ -1559,14 +2029,14 @@ var init_http_client = __esm({
1559
2029
  const isExplicitCredential = !!serverMessage && /(invalid|expired|missing|no)\s+(api[\s_-]?key|token|credential)/i.test(serverMessage);
1560
2030
  const isBareAuthRejection = !serverMessage || /^unauthorized$/i.test(serverMessage);
1561
2031
  if (isExplicitCredential || isBareAuthRejection) {
1562
- throw new AuthenticationError("Authentication failed. Your API key may be invalid or expired.", "invalid_credentials", serverMessage);
2032
+ throw new AuthenticationError("Authentication failed. Your Lua credential may be invalid or expired.", "invalid_credentials", serverMessage);
1563
2033
  }
1564
2034
  throw new AuthenticationError(`Authentication failed: ${serverMessage}`, "unknown", serverMessage);
1565
2035
  }
1566
2036
  if (response.status === 403) {
1567
2037
  const detail = errorData.message || "You do not have permission to access this resource.";
1568
2038
  throw new Error(`Access denied (403): ${detail}
1569
- Check that your API key has access to this agent/organization.`);
2039
+ Check that your Lua login has access to this agent or organization.`);
1570
2040
  }
1571
2041
  return {
1572
2042
  success: false,
@@ -1651,7 +2121,7 @@ Check that your API key has access to this agent/organization.`);
1651
2121
  if (options.method === "POST") {
1652
2122
  const headers = options.headers || {};
1653
2123
  if (!headers["X-Idempotency-Key"]) {
1654
- headers["X-Idempotency-Key"] = randomUUID();
2124
+ headers["X-Idempotency-Key"] = randomUUID2();
1655
2125
  options = {
1656
2126
  ...options,
1657
2127
  headers: {
@@ -1779,25 +2249,12 @@ var init_auth_api_service = __esm({
1779
2249
 
1780
2250
  // src/services/auth.ts
1781
2251
  import "dotenv/config";
1782
- import { readFileSync as readFileSync2, writeFileSync, mkdirSync, unlinkSync } from "fs";
1783
- function getToken() {
1784
- if (process.env.LUA_API_KEY) {
1785
- return process.env.LUA_API_KEY;
1786
- }
1787
- try {
1788
- const token = readFileSync2(CREDENTIALS_FILE, "utf8").trim();
1789
- if (token) return token;
1790
- } catch {
1791
- }
1792
- throw new AuthenticationError('No API key found.\n\n Authenticate using one of these methods:\n\n \u279C lua auth configure\n \u279C export LUA_API_KEY="your-api-key-here"\n \u279C Add LUA_API_KEY=... to a .env file\n\n \u{1F511} Get your API key at https://admin.heylua.ai', "invalid_credentials", void 0, true);
1793
- }
1794
2252
  var init_auth = __esm({
1795
2253
  "src/services/auth.ts"() {
1796
2254
  "use strict";
1797
2255
  init_auth_api_service();
1798
2256
  init_constants();
1799
2257
  init_auth_error();
1800
- __name(getToken, "getToken");
1801
2258
  }
1802
2259
  });
1803
2260
 
@@ -1869,17 +2326,15 @@ var init_skills_api_service = __esm({
1869
2326
  static {
1870
2327
  __name(this, "SkillApi");
1871
2328
  }
1872
- apiKey;
1873
2329
  agentId;
1874
2330
  /**
1875
2331
  * Creates an instance of SkillApi
1876
2332
  * @param baseUrl - The base URL for the API
1877
- * @param apiKey - The API key for authentication
2333
+ * @param credential - The API key for authentication
1878
2334
  * @param agentId - The unique identifier of the agent
1879
2335
  */
1880
- constructor(baseUrl, apiKey, agentId) {
1881
- super(baseUrl);
1882
- this.apiKey = apiKey;
2336
+ constructor(baseUrl, credential, agentId) {
2337
+ super(baseUrl, credential);
1883
2338
  this.agentId = agentId;
1884
2339
  }
1885
2340
  /**
@@ -1888,9 +2343,7 @@ var init_skills_api_service = __esm({
1888
2343
  * @throws Error if the API request fails or the agent is not found
1889
2344
  */
1890
2345
  async getSkills() {
1891
- return this.httpGet(`/developer/skills/${this.agentId}`, {
1892
- Authorization: `Bearer ${this.apiKey}`
1893
- });
2346
+ return this.httpGet(`/developer/skills/${this.agentId}`, {});
1894
2347
  }
1895
2348
  /**
1896
2349
  * Creates a new skill for the agent
@@ -1899,9 +2352,7 @@ var init_skills_api_service = __esm({
1899
2352
  * @throws Error if the skill creation fails or validation errors occur
1900
2353
  */
1901
2354
  async createSkill(skillData) {
1902
- return this.httpPost(`/developer/skills/${this.agentId}`, skillData, {
1903
- Authorization: `Bearer ${this.apiKey}`
1904
- });
2355
+ return this.httpPost(`/developer/skills/${this.agentId}`, skillData, {});
1905
2356
  }
1906
2357
  /**
1907
2358
  * Pushes a new version of a skill to production
@@ -1911,9 +2362,7 @@ var init_skills_api_service = __esm({
1911
2362
  * @throws Error if the skill is not found or the push operation fails
1912
2363
  */
1913
2364
  async pushSkill(skillId, versionData) {
1914
- return this.httpPost(`/developer/skills/${this.agentId}/${skillId}/version`, versionData, {
1915
- Authorization: `Bearer ${this.apiKey}`
1916
- });
2365
+ return this.httpPost(`/developer/skills/${this.agentId}/${skillId}/version`, versionData, {});
1917
2366
  }
1918
2367
  /**
1919
2368
  * Pushes a new development/sandbox version of a skill for testing
@@ -1923,9 +2372,7 @@ var init_skills_api_service = __esm({
1923
2372
  * @throws Error if the skill is not found or the push operation fails
1924
2373
  */
1925
2374
  async pushDevSkill(skillId, versionData) {
1926
- return this.httpPost(`/developer/skills/${this.agentId}/${skillId}/version/sandbox`, versionData, {
1927
- Authorization: `Bearer ${this.apiKey}`
1928
- });
2375
+ return this.httpPost(`/developer/skills/${this.agentId}/${skillId}/version/sandbox`, versionData, {});
1929
2376
  }
1930
2377
  /**
1931
2378
  * Updates an existing development/sandbox version of a skill
@@ -1936,9 +2383,7 @@ var init_skills_api_service = __esm({
1936
2383
  * @throws Error if the skill or version is not found or the update fails
1937
2384
  */
1938
2385
  async updateDevSkill(skillId, sandboxVersionId, versionData) {
1939
- return this.httpPut(`/developer/skills/${this.agentId}/${skillId}/version/sandbox/${sandboxVersionId}`, versionData, {
1940
- Authorization: `Bearer ${this.apiKey}`
1941
- });
2386
+ return this.httpPut(`/developer/skills/${this.agentId}/${skillId}/version/sandbox/${sandboxVersionId}`, versionData, {});
1942
2387
  }
1943
2388
  /**
1944
2389
  * Retrieves all versions of a specific skill
@@ -1947,9 +2392,7 @@ var init_skills_api_service = __esm({
1947
2392
  * @throws Error if the skill is not found or the request fails
1948
2393
  */
1949
2394
  async getSkillVersions(skillId) {
1950
- return this.httpGet(`/developer/skills/${this.agentId}/${skillId}/versions`, {
1951
- Authorization: `Bearer ${this.apiKey}`
1952
- });
2395
+ return this.httpGet(`/developer/skills/${this.agentId}/${skillId}/versions`, {});
1953
2396
  }
1954
2397
  /**
1955
2398
  * Publishes a specific version of a skill to production
@@ -1959,9 +2402,7 @@ var init_skills_api_service = __esm({
1959
2402
  * @throws Error if the skill or version is not found or the publish operation fails
1960
2403
  */
1961
2404
  async publishSkillVersion(skillId, version) {
1962
- return this.httpPut(`/developer/skills/${this.agentId}/${skillId}/${version}/publish`, void 0, {
1963
- Authorization: `Bearer ${this.apiKey}`
1964
- });
2405
+ return this.httpPut(`/developer/skills/${this.agentId}/${skillId}/${version}/publish`, void 0, {});
1965
2406
  }
1966
2407
  /**
1967
2408
  * Deletes a skill and all its versions, or deactivates it if it has versions
@@ -1972,9 +2413,7 @@ var init_skills_api_service = __esm({
1972
2413
  * @throws Error if the skill is not found or the delete operation fails
1973
2414
  */
1974
2415
  async deleteSkill(skillId) {
1975
- return this.httpDelete(`/developer/skills/${this.agentId}/${skillId}`, {
1976
- Authorization: `Bearer ${this.apiKey}`
1977
- });
2416
+ return this.httpDelete(`/developer/skills/${this.agentId}/${skillId}`, {});
1978
2417
  }
1979
2418
  /**
1980
2419
  * Attach TS source + workspace archive to a skill version. Powers
@@ -1982,9 +2421,7 @@ var init_skills_api_service = __esm({
1982
2421
  * source without waiting for the next UI-driven build.
1983
2422
  */
1984
2423
  async attachSkillSource(skillId, version, body) {
1985
- return this.httpPut(`/developer/skills/${this.agentId}/${skillId}/version/${encodeURIComponent(version)}/source`, body, {
1986
- Authorization: `Bearer ${this.apiKey}`
1987
- });
2424
+ return this.httpPut(`/developer/skills/${this.agentId}/${skillId}/version/${encodeURIComponent(version)}/source`, body, {});
1988
2425
  }
1989
2426
  };
1990
2427
  }
@@ -2883,7 +3320,7 @@ var init_analytics = __esm({
2883
3320
  "src/services/analytics.ts"() {
2884
3321
  "use strict";
2885
3322
  init_constants();
2886
- init_auth();
3323
+ init_request_credential();
2887
3324
  init_files();
2888
3325
  }
2889
3326
  });
@@ -2917,13 +3354,14 @@ var init_cli = __esm({
2917
3354
  });
2918
3355
 
2919
3356
  // src/utils/command-utils.ts
2920
- function requireAuth() {
2921
- return getToken();
3357
+ async function requireAuth() {
3358
+ return resolveRequestCredential();
2922
3359
  }
2923
3360
  var init_command_utils = __esm({
2924
3361
  "src/utils/command-utils.ts"() {
2925
3362
  "use strict";
2926
3363
  init_auth();
3364
+ init_request_credential();
2927
3365
  init_files();
2928
3366
  init_cli();
2929
3367
  __name(requireAuth, "requireAuth");
@@ -3406,17 +3844,15 @@ var init_products_api_service = __esm({
3406
3844
  static {
3407
3845
  __name(this, "ProductApi");
3408
3846
  }
3409
- apiKey;
3410
3847
  agentId;
3411
3848
  /**
3412
3849
  * Creates an instance of ProductApi
3413
3850
  * @param baseUrl - The base URL for the API
3414
- * @param apiKey - The API key for authentication
3851
+ * @param credential - The API key for authentication
3415
3852
  * @param agentId - The unique identifier of the agent
3416
3853
  */
3417
- constructor(baseUrl, apiKey, agentId) {
3418
- super(baseUrl);
3419
- this.apiKey = apiKey;
3854
+ constructor(baseUrl, credential, agentId) {
3855
+ super(baseUrl, credential);
3420
3856
  this.agentId = agentId;
3421
3857
  }
3422
3858
  async get(pageOrOptions, limitArg) {
@@ -3437,9 +3873,7 @@ var init_products_api_service = __esm({
3437
3873
  if (filter) {
3438
3874
  queryParams.append("filter", JSON.stringify(filter));
3439
3875
  }
3440
- const response = await this.httpGet(`/developer/agents/${this.agentId}/products?${queryParams.toString()}`, {
3441
- Authorization: `Bearer ${this.apiKey}`
3442
- });
3876
+ const response = await this.httpGet(`/developer/agents/${this.agentId}/products?${queryParams.toString()}`, {});
3443
3877
  if (response.success) {
3444
3878
  return new ProductPaginationInstance(this, response);
3445
3879
  }
@@ -3452,9 +3886,7 @@ var init_products_api_service = __esm({
3452
3886
  * @throws Error if the product is not found or the request fails
3453
3887
  */
3454
3888
  async getById(productId) {
3455
- const response = await this.httpGet(`/developer/agents/${this.agentId}/products/${productId}`, {
3456
- Authorization: `Bearer ${this.apiKey}`
3457
- });
3889
+ const response = await this.httpGet(`/developer/agents/${this.agentId}/products/${productId}`, {});
3458
3890
  if (response.success && response.data) {
3459
3891
  return new ProductInstance(this, response.data);
3460
3892
  }
@@ -3467,9 +3899,7 @@ var init_products_api_service = __esm({
3467
3899
  * @throws Error if the product creation fails or validation errors occur
3468
3900
  */
3469
3901
  async create(productData) {
3470
- const response = await this.httpPost(`/developer/agents/${this.agentId}/products`, productData, {
3471
- Authorization: `Bearer ${this.apiKey}`
3472
- });
3902
+ const response = await this.httpPost(`/developer/agents/${this.agentId}/products`, productData, {});
3473
3903
  if (response.success && response.data) {
3474
3904
  return new ProductInstance(this, response.data.product);
3475
3905
  }
@@ -3486,9 +3916,7 @@ var init_products_api_service = __esm({
3486
3916
  const response = await this.httpPut(`/developer/agents/${this.agentId}/products`, {
3487
3917
  ...productData,
3488
3918
  id: productId
3489
- }, {
3490
- Authorization: `Bearer ${this.apiKey}`
3491
- });
3919
+ }, {});
3492
3920
  if (response.success && response.data) {
3493
3921
  return response.data;
3494
3922
  }
@@ -3501,9 +3929,7 @@ var init_products_api_service = __esm({
3501
3929
  * @throws Error if the product is not found or the deletion fails
3502
3930
  */
3503
3931
  async delete(productId) {
3504
- const response = await this.httpDelete(`/developer/agents/${this.agentId}/products/${productId}`, {
3505
- Authorization: `Bearer ${this.apiKey}`
3506
- });
3932
+ const response = await this.httpDelete(`/developer/agents/${this.agentId}/products/${productId}`, {});
3507
3933
  if (response.success && response.data) {
3508
3934
  return response.data;
3509
3935
  }
@@ -3517,9 +3943,7 @@ var init_products_api_service = __esm({
3517
3943
  * @throws Error if the search fails or the API request is unsuccessful
3518
3944
  */
3519
3945
  async search(searchQuery, limit = 5) {
3520
- const response = await this.httpGet(`/developer/agents/${this.agentId}/products/search?searchQuery=${encodeURIComponent(searchQuery)}&limit=${limit}`, {
3521
- Authorization: `Bearer ${this.apiKey}`
3522
- });
3946
+ const response = await this.httpGet(`/developer/agents/${this.agentId}/products/search?searchQuery=${encodeURIComponent(searchQuery)}&limit=${limit}`, {});
3523
3947
  if (response.success) {
3524
3948
  return new ProductSearchInstance(this, response);
3525
3949
  }
@@ -4004,17 +4428,15 @@ var init_order_api_service = __esm({
4004
4428
  static {
4005
4429
  __name(this, "OrderApi");
4006
4430
  }
4007
- apiKey;
4008
4431
  agentId;
4009
4432
  /**
4010
4433
  * Creates an instance of OrderApi
4011
4434
  * @param baseUrl - The base URL for the API
4012
- * @param apiKey - The API key for authentication
4435
+ * @param credential - The API key for authentication
4013
4436
  * @param agentId - The unique identifier of the agent
4014
4437
  */
4015
- constructor(baseUrl, apiKey, agentId) {
4016
- super(baseUrl);
4017
- this.apiKey = apiKey;
4438
+ constructor(baseUrl, credential, agentId) {
4439
+ super(baseUrl, credential);
4018
4440
  this.agentId = agentId;
4019
4441
  }
4020
4442
  /**
@@ -4024,9 +4446,7 @@ var init_order_api_service = __esm({
4024
4446
  * @throws Error if the basket is not found or the order creation fails
4025
4447
  */
4026
4448
  async create(orderData) {
4027
- const response = await this.httpPost(`/developer/agents/${this.agentId}/order`, orderData, {
4028
- Authorization: `Bearer ${this.apiKey}`
4029
- });
4449
+ const response = await this.httpPost(`/developer/agents/${this.agentId}/order`, orderData, {});
4030
4450
  if (response.success && response.data) {
4031
4451
  return new OrderInstance(this, response.data);
4032
4452
  }
@@ -4040,9 +4460,7 @@ var init_order_api_service = __esm({
4040
4460
  * @throws Error if the order is not found or the status update fails
4041
4461
  */
4042
4462
  async updateStatus(status, orderId) {
4043
- const response = await this.httpPut(`/developer/agents/${this.agentId}/order/${orderId}/${status}`, {}, {
4044
- Authorization: `Bearer ${this.apiKey}`
4045
- });
4463
+ const response = await this.httpPut(`/developer/agents/${this.agentId}/order/${orderId}/${status}`, {}, {});
4046
4464
  if (response.success && response.data) {
4047
4465
  return response.data;
4048
4466
  }
@@ -4056,9 +4474,7 @@ var init_order_api_service = __esm({
4056
4474
  * @throws Error if the order is not found or the data update fails
4057
4475
  */
4058
4476
  async updateData(data, orderId) {
4059
- const response = await this.httpPut(`/developer/agents/${this.agentId}/order/${orderId}`, data, {
4060
- Authorization: `Bearer ${this.apiKey}`
4061
- });
4477
+ const response = await this.httpPut(`/developer/agents/${this.agentId}/order/${orderId}`, data, {});
4062
4478
  if (response.success && response.data) {
4063
4479
  return response.data;
4064
4480
  }
@@ -4072,9 +4488,7 @@ var init_order_api_service = __esm({
4072
4488
  */
4073
4489
  async get(status) {
4074
4490
  const statusParam = status ? `?status=${status}` : "";
4075
- const response = await this.httpGet(`/developer/agents/${this.agentId}/order/user${statusParam}`, {
4076
- Authorization: `Bearer ${this.apiKey}`
4077
- });
4491
+ const response = await this.httpGet(`/developer/agents/${this.agentId}/order/user${statusParam}`, {});
4078
4492
  if (response.success && response.data) {
4079
4493
  return response.data.map((order) => new OrderInstance(this, order));
4080
4494
  }
@@ -4087,9 +4501,7 @@ var init_order_api_service = __esm({
4087
4501
  * @throws Error if the order is not found or the request fails
4088
4502
  */
4089
4503
  async getById(orderId) {
4090
- const response = await this.httpGet(`/developer/agents/${this.agentId}/order/${orderId}`, {
4091
- Authorization: `Bearer ${this.apiKey}`
4092
- });
4504
+ const response = await this.httpGet(`/developer/agents/${this.agentId}/order/${orderId}`, {});
4093
4505
  if (response.success && response.data) {
4094
4506
  return new OrderInstance(this, response.data);
4095
4507
  }
@@ -4112,17 +4524,17 @@ var init_basket_api_service = __esm({
4112
4524
  static {
4113
4525
  __name(this, "BasketApi");
4114
4526
  }
4115
- apiKey;
4527
+ credential;
4116
4528
  agentId;
4117
4529
  /**
4118
4530
  * Creates an instance of BasketApi
4119
4531
  * @param baseUrl - The base URL for the API
4120
- * @param apiKey - The API key for authentication
4532
+ * @param credential - The API key for authentication
4121
4533
  * @param agentId - The unique identifier of the agent
4122
4534
  */
4123
- constructor(baseUrl, apiKey, agentId) {
4124
- super(baseUrl);
4125
- this.apiKey = apiKey;
4535
+ constructor(baseUrl, credential, agentId) {
4536
+ super(baseUrl, credential);
4537
+ this.credential = credential;
4126
4538
  this.agentId = agentId;
4127
4539
  }
4128
4540
  /**
@@ -4132,9 +4544,7 @@ var init_basket_api_service = __esm({
4132
4544
  * @throws Error if the basket creation fails or the API request is unsuccessful
4133
4545
  */
4134
4546
  async create(basketData) {
4135
- const response = await this.httpPost(`/developer/agents/${this.agentId}/basket`, basketData, {
4136
- Authorization: `Bearer ${this.apiKey}`
4137
- });
4547
+ const response = await this.httpPost(`/developer/agents/${this.agentId}/basket`, basketData, {});
4138
4548
  if (response.success && response.data) {
4139
4549
  return new BasketInstance(this, response.data);
4140
4550
  }
@@ -4148,9 +4558,7 @@ var init_basket_api_service = __esm({
4148
4558
  */
4149
4559
  async get(status) {
4150
4560
  const statusParam = status ? `?status=${status}` : "";
4151
- const response = await this.httpGet(`/developer/agents/${this.agentId}/basket/user${statusParam}`, {
4152
- Authorization: `Bearer ${this.apiKey}`
4153
- });
4561
+ const response = await this.httpGet(`/developer/agents/${this.agentId}/basket/user${statusParam}`, {});
4154
4562
  if (response.success && response.data) {
4155
4563
  return response.data.map((basket) => new BasketInstance(this, basket));
4156
4564
  }
@@ -4163,9 +4571,7 @@ var init_basket_api_service = __esm({
4163
4571
  * @throws Error if the basket is not found or the request fails
4164
4572
  */
4165
4573
  async getById(basketId) {
4166
- const response = await this.httpGet(`/developer/agents/${this.agentId}/basket/${basketId}`, {
4167
- Authorization: `Bearer ${this.apiKey}`
4168
- });
4574
+ const response = await this.httpGet(`/developer/agents/${this.agentId}/basket/${basketId}`, {});
4169
4575
  if (response.success && response.data) {
4170
4576
  return new BasketInstance(this, response.data);
4171
4577
  }
@@ -4179,9 +4585,7 @@ var init_basket_api_service = __esm({
4179
4585
  * @throws Error if the basket is not found or the item cannot be added
4180
4586
  */
4181
4587
  async addItem(basketId, itemData) {
4182
- const response = await this.httpPost(`/developer/agents/${this.agentId}/basket/${basketId}/item`, itemData, {
4183
- Authorization: `Bearer ${this.apiKey}`
4184
- });
4588
+ const response = await this.httpPost(`/developer/agents/${this.agentId}/basket/${basketId}/item`, itemData, {});
4185
4589
  if (response.success && response.data) {
4186
4590
  return response.data;
4187
4591
  }
@@ -4195,9 +4599,7 @@ var init_basket_api_service = __esm({
4195
4599
  * @throws Error if the basket or item is not found or the removal fails
4196
4600
  */
4197
4601
  async removeItem(basketId, itemId) {
4198
- const response = await this.httpDelete(`/developer/agents/${this.agentId}/basket/${basketId}/item/${itemId}`, {
4199
- Authorization: `Bearer ${this.apiKey}`
4200
- });
4602
+ const response = await this.httpDelete(`/developer/agents/${this.agentId}/basket/${basketId}/item/${itemId}`, {});
4201
4603
  if (response.success && response.data) {
4202
4604
  return response.data;
4203
4605
  }
@@ -4210,9 +4612,7 @@ var init_basket_api_service = __esm({
4210
4612
  * @throws Error if the basket is not found or the clear operation fails
4211
4613
  */
4212
4614
  async clear(basketId) {
4213
- const response = await this.httpDelete(`/developer/agents/${this.agentId}/basket/${basketId}/clear`, {
4214
- Authorization: `Bearer ${this.apiKey}`
4215
- });
4615
+ const response = await this.httpDelete(`/developer/agents/${this.agentId}/basket/${basketId}/clear`, {});
4216
4616
  if (response.success && response.data) {
4217
4617
  return response.data;
4218
4618
  }
@@ -4226,9 +4626,7 @@ var init_basket_api_service = __esm({
4226
4626
  * @throws Error if the basket is not found or the status update fails
4227
4627
  */
4228
4628
  async updateStatus(basketId, status) {
4229
- const response = await this.httpPut(`/developer/agents/${this.agentId}/basket/${basketId}/${status}`, void 0, {
4230
- Authorization: `Bearer ${this.apiKey}`
4231
- });
4629
+ const response = await this.httpPut(`/developer/agents/${this.agentId}/basket/${basketId}/${status}`, void 0, {});
4232
4630
  if (response.success) {
4233
4631
  return status;
4234
4632
  }
@@ -4242,9 +4640,7 @@ var init_basket_api_service = __esm({
4242
4640
  * @throws Error if the basket is not found or the metadata update fails
4243
4641
  */
4244
4642
  async updateMetadata(basketId, metadata) {
4245
- const response = await this.httpPut(`/developer/agents/${this.agentId}/basket/${basketId}/metadata`, metadata, {
4246
- Authorization: `Bearer ${this.apiKey}`
4247
- });
4643
+ const response = await this.httpPut(`/developer/agents/${this.agentId}/basket/${basketId}/metadata`, metadata, {});
4248
4644
  if (response.success) {
4249
4645
  return metadata;
4250
4646
  }
@@ -4261,11 +4657,9 @@ var init_basket_api_service = __esm({
4261
4657
  const response = await this.httpPost(`/developer/agents/${this.agentId}/order`, {
4262
4658
  basketId,
4263
4659
  data
4264
- }, {
4265
- Authorization: `Bearer ${this.apiKey}`
4266
- });
4660
+ }, {});
4267
4661
  if (response.success && response.data) {
4268
- const orderApi = new OrderApi(this.baseUrl, this.apiKey, this.agentId);
4662
+ const orderApi = new OrderApi(this.baseUrl, this.credential, this.agentId);
4269
4663
  return new OrderInstance(orderApi, response.data);
4270
4664
  }
4271
4665
  throw new Error(response.error?.message || "Failed to create order");
@@ -4504,18 +4898,18 @@ var init_user_data_api_service = __esm({
4504
4898
  static {
4505
4899
  __name(this, "UserDataApi");
4506
4900
  }
4507
- apiKey;
4901
+ credential;
4508
4902
  agentId;
4509
4903
  targetUserId;
4510
4904
  /**
4511
4905
  * Creates an instance of UserDataApi
4512
4906
  * @param baseUrl - The base URL for the API
4513
- * @param apiKey - The API key for authentication
4907
+ * @param credential - The API key for authentication
4514
4908
  * @param agentId - The unique identifier of the agent
4515
4909
  */
4516
- constructor(baseUrl, apiKey, agentId, targetUserId) {
4517
- super(baseUrl);
4518
- this.apiKey = apiKey;
4910
+ constructor(baseUrl, credential, agentId, targetUserId) {
4911
+ super(baseUrl, credential);
4912
+ this.credential = credential;
4519
4913
  this.agentId = agentId;
4520
4914
  this.targetUserId = targetUserId;
4521
4915
  }
@@ -4542,15 +4936,13 @@ var init_user_data_api_service = __esm({
4542
4936
  if (userId) {
4543
4937
  url += `/user/${encodeURIComponent(userId)}`;
4544
4938
  }
4545
- const response = await this.httpGet(url, {
4546
- Authorization: `Bearer ${this.apiKey}`
4547
- });
4939
+ const response = await this.httpGet(url, {});
4548
4940
  if (!response.success) {
4549
4941
  throw new Error(response.error?.message || "Failed to get user data");
4550
4942
  }
4551
4943
  const profile = response.data?._luaProfile;
4552
4944
  const { _luaProfile, ...data } = response.data || {};
4553
- const scopedApi = userId ? new _UserDataApi(this.baseUrl, this.apiKey, this.agentId, userId) : this;
4945
+ const scopedApi = userId ? new _UserDataApi(this.baseUrl, this.credential, this.agentId, userId) : this;
4554
4946
  return new UserDataInstance(scopedApi, data, profile);
4555
4947
  }
4556
4948
  /**
@@ -4584,9 +4976,7 @@ var init_user_data_api_service = __esm({
4584
4976
  * @throws Error if the update fails or the request is unsuccessful
4585
4977
  */
4586
4978
  async update(data) {
4587
- const response = await this.httpPut(this.dataPath, data, {
4588
- Authorization: `Bearer ${this.apiKey}`
4589
- });
4979
+ const response = await this.httpPut(this.dataPath, data, {});
4590
4980
  if (!response.success) {
4591
4981
  throw new Error(response.error?.message || "Failed to update user data");
4592
4982
  }
@@ -4594,9 +4984,7 @@ var init_user_data_api_service = __esm({
4594
4984
  return cleanData;
4595
4985
  }
4596
4986
  async patch(mutation) {
4597
- const response = await this.httpPatch(this.dataPath, mutation, {
4598
- Authorization: `Bearer ${this.apiKey}`
4599
- });
4987
+ const response = await this.httpPatch(this.dataPath, mutation, {});
4600
4988
  if (!response.success) {
4601
4989
  throw new Error(response.error?.message || "Failed to patch user data");
4602
4990
  }
@@ -4609,9 +4997,7 @@ var init_user_data_api_service = __esm({
4609
4997
  * @throws Error if the clear operation fails or the request is unsuccessful
4610
4998
  */
4611
4999
  async clear() {
4612
- const response = await this.httpDelete(this.dataPath, {
4613
- Authorization: `Bearer ${this.apiKey}`
4614
- });
5000
+ const response = await this.httpDelete(this.dataPath, {});
4615
5001
  if (!response.success) {
4616
5002
  throw new Error(response.error?.message || "Failed to clear user data");
4617
5003
  }
@@ -4626,9 +5012,7 @@ var init_user_data_api_service = __esm({
4626
5012
  async sendMessage(messages) {
4627
5013
  const response = await this.httpPost(`/admin/agents/${this.agentId}/conversations/me`, {
4628
5014
  messages
4629
- }, {
4630
- Authorization: `Bearer ${this.apiKey}`
4631
- });
5015
+ }, {});
4632
5016
  if (!response.success) {
4633
5017
  throw new Error(response.error?.message || "Failed to send message");
4634
5018
  }
@@ -4646,9 +5030,7 @@ var init_user_data_api_service = __esm({
4646
5030
  * ```
4647
5031
  */
4648
5032
  async getChatHistory() {
4649
- const response = await this.httpGet(`/chat/history/${this.agentId}`, {
4650
- Authorization: `Bearer ${this.apiKey}`
4651
- });
5033
+ const response = await this.httpGet(`/chat/history/${this.agentId}`, {});
4652
5034
  if (!response.success) {
4653
5035
  throw new Error(response.error?.message || "Failed to get chat history");
4654
5036
  }
@@ -4874,17 +5256,15 @@ var init_custom_data_api_service = __esm({
4874
5256
  static {
4875
5257
  __name(this, "CustomDataApi");
4876
5258
  }
4877
- apiKey;
4878
5259
  agentId;
4879
5260
  /**
4880
5261
  * Creates an instance of CustomDataApi
4881
5262
  * @param baseUrl - The base URL for the API
4882
- * @param apiKey - The API key for authentication
5263
+ * @param credential - The API key for authentication
4883
5264
  * @param agentId - The unique identifier of the agent
4884
5265
  */
4885
- constructor(baseUrl, apiKey, agentId) {
4886
- super(baseUrl);
4887
- this.apiKey = apiKey;
5266
+ constructor(baseUrl, credential, agentId) {
5267
+ super(baseUrl, credential);
4888
5268
  this.agentId = agentId;
4889
5269
  }
4890
5270
  /**
@@ -4894,9 +5274,7 @@ var init_custom_data_api_service = __esm({
4894
5274
  * @returns Promise resolving to the collections listing
4895
5275
  */
4896
5276
  async collections() {
4897
- const response = await this.httpGet(`/developer/agents/${this.agentId}/custom-data`, {
4898
- Authorization: `Bearer ${this.apiKey}`
4899
- });
5277
+ const response = await this.httpGet(`/developer/agents/${this.agentId}/custom-data`, {});
4900
5278
  if (response.success && response.data) {
4901
5279
  return response.data;
4902
5280
  }
@@ -4924,9 +5302,7 @@ var init_custom_data_api_service = __esm({
4924
5302
  data,
4925
5303
  searchText: options.searchText,
4926
5304
  index: options.index
4927
- }, {
4928
- Authorization: `Bearer ${this.apiKey}`
4929
- });
5305
+ }, {});
4930
5306
  if (response.success && response.data) {
4931
5307
  return new DataEntryInstance(this, response.data, collectionName);
4932
5308
  }
@@ -4947,9 +5323,7 @@ var init_custom_data_api_service = __esm({
4947
5323
  const encodedFilter = encodeURIComponent(JSON.stringify(filter));
4948
5324
  url += `&filter=${encodedFilter}`;
4949
5325
  }
4950
- const response = await this.httpGet(url, {
4951
- Authorization: `Bearer ${this.apiKey}`
4952
- });
5326
+ const response = await this.httpGet(url, {});
4953
5327
  if (response.success && response.data) {
4954
5328
  return response.data;
4955
5329
  }
@@ -4963,9 +5337,7 @@ var init_custom_data_api_service = __esm({
4963
5337
  * @throws Error if the entry is not found or the API request is unsuccessful
4964
5338
  */
4965
5339
  async getEntry(collectionName, entryId) {
4966
- const response = await this.httpGet(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, {
4967
- Authorization: `Bearer ${this.apiKey}`
4968
- });
5340
+ const response = await this.httpGet(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, {});
4969
5341
  if (response.success && response.data) {
4970
5342
  return new DataEntryInstance(this, response.data, collectionName);
4971
5343
  }
@@ -4989,18 +5361,14 @@ var init_custom_data_api_service = __esm({
4989
5361
  data,
4990
5362
  searchText: options.searchText,
4991
5363
  index: options.index
4992
- }, {
4993
- Authorization: `Bearer ${this.apiKey}`
4994
- });
5364
+ }, {});
4995
5365
  if (response.success && response.data) {
4996
5366
  return response.data;
4997
5367
  }
4998
5368
  throw new Error(response.error?.message || "Failed to update custom data entry");
4999
5369
  }
5000
5370
  async patch(collectionName, entryId, mutation) {
5001
- const response = await this.httpPatch(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, mutation, {
5002
- Authorization: `Bearer ${this.apiKey}`
5003
- });
5371
+ const response = await this.httpPatch(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, mutation, {});
5004
5372
  if (response.success && response.data) {
5005
5373
  return response.data;
5006
5374
  }
@@ -5017,9 +5385,7 @@ var init_custom_data_api_service = __esm({
5017
5385
  */
5018
5386
  async search(collectionName, searchText, limit = 10, scoreThreshold = 0.6) {
5019
5387
  const url = `/developer/agents/${this.agentId}/custom-data/${collectionName}/search?searchText=${encodeURIComponent(searchText)}&limit=${limit}&scoreThreshold=${scoreThreshold}`;
5020
- const response = await this.httpGet(url, {
5021
- Authorization: `Bearer ${this.apiKey}`
5022
- });
5388
+ const response = await this.httpGet(url, {});
5023
5389
  if (response.success && response.data) {
5024
5390
  return response.data.data.map((entry) => new DataEntryInstance(this, entry, collectionName));
5025
5391
  }
@@ -5033,9 +5399,7 @@ var init_custom_data_api_service = __esm({
5033
5399
  * @throws Error if the entry is not found or the deletion fails
5034
5400
  */
5035
5401
  async delete(collectionName, entryId) {
5036
- const response = await this.httpDelete(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, {
5037
- Authorization: `Bearer ${this.apiKey}`
5038
- });
5402
+ const response = await this.httpDelete(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, {});
5039
5403
  if (response.success && response.data) {
5040
5404
  return response.data;
5041
5405
  }
@@ -5055,17 +5419,15 @@ var init_webhook_api_service = __esm({
5055
5419
  static {
5056
5420
  __name(this, "WebhookApi");
5057
5421
  }
5058
- apiKey;
5059
5422
  agentId;
5060
5423
  /**
5061
5424
  * Creates an instance of WebhookApi
5062
5425
  * @param baseUrl - The base URL for the API
5063
- * @param apiKey - The API key for authentication
5426
+ * @param credential - The API key for authentication
5064
5427
  * @param agentId - The unique identifier of the agent
5065
5428
  */
5066
- constructor(baseUrl, apiKey, agentId) {
5067
- super(baseUrl);
5068
- this.apiKey = apiKey;
5429
+ constructor(baseUrl, credential, agentId) {
5430
+ super(baseUrl, credential);
5069
5431
  this.agentId = agentId;
5070
5432
  }
5071
5433
  /**
@@ -5074,9 +5436,7 @@ var init_webhook_api_service = __esm({
5074
5436
  * @throws Error if the API request fails or the agent is not found
5075
5437
  */
5076
5438
  async getWebhooks() {
5077
- return this.httpGet(`/developer/webhooks/${this.agentId}`, {
5078
- Authorization: `Bearer ${this.apiKey}`
5079
- });
5439
+ return this.httpGet(`/developer/webhooks/${this.agentId}`, {});
5080
5440
  }
5081
5441
  /**
5082
5442
  * Creates a new webhook for the agent
@@ -5085,14 +5445,10 @@ var init_webhook_api_service = __esm({
5085
5445
  * @throws Error if the webhook creation fails or validation errors occur
5086
5446
  */
5087
5447
  async createWebhook(webhookData) {
5088
- return this.httpPost(`/developer/webhooks/${this.agentId}`, webhookData, {
5089
- Authorization: `Bearer ${this.apiKey}`
5090
- });
5448
+ return this.httpPost(`/developer/webhooks/${this.agentId}`, webhookData, {});
5091
5449
  }
5092
5450
  async updateWebhook(webhookId, data) {
5093
- return this.httpPatch(`/developer/webhooks/${this.agentId}/${webhookId}`, data, {
5094
- Authorization: `Bearer ${this.apiKey}`
5095
- });
5451
+ return this.httpPatch(`/developer/webhooks/${this.agentId}/${webhookId}`, data, {});
5096
5452
  }
5097
5453
  /**
5098
5454
  * Pushes a new version of a webhook to production
@@ -5102,9 +5458,7 @@ var init_webhook_api_service = __esm({
5102
5458
  * @throws Error if the webhook is not found or the push operation fails
5103
5459
  */
5104
5460
  async pushWebhook(webhookId, versionData) {
5105
- return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/version`, versionData, {
5106
- Authorization: `Bearer ${this.apiKey}`
5107
- });
5461
+ return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/version`, versionData, {});
5108
5462
  }
5109
5463
  /**
5110
5464
  * Pushes a new development/sandbox version of a webhook for testing
@@ -5114,9 +5468,7 @@ var init_webhook_api_service = __esm({
5114
5468
  * @throws Error if the webhook is not found or the push operation fails
5115
5469
  */
5116
5470
  async pushDevWebhook(webhookId, versionData) {
5117
- return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/version/sandbox`, versionData, {
5118
- Authorization: `Bearer ${this.apiKey}`
5119
- });
5471
+ return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/version/sandbox`, versionData, {});
5120
5472
  }
5121
5473
  /**
5122
5474
  * Updates an existing development/sandbox version of a webhook
@@ -5127,9 +5479,7 @@ var init_webhook_api_service = __esm({
5127
5479
  * @throws Error if the webhook or version is not found or the update fails
5128
5480
  */
5129
5481
  async updateDevWebhook(webhookId, sandboxVersionId, versionData) {
5130
- return this.httpPut(`/developer/webhooks/${this.agentId}/${webhookId}/version/sandbox/${sandboxVersionId}`, versionData, {
5131
- Authorization: `Bearer ${this.apiKey}`
5132
- });
5482
+ return this.httpPut(`/developer/webhooks/${this.agentId}/${webhookId}/version/sandbox/${sandboxVersionId}`, versionData, {});
5133
5483
  }
5134
5484
  /**
5135
5485
  * Retrieves all versions of a specific webhook
@@ -5138,9 +5488,7 @@ var init_webhook_api_service = __esm({
5138
5488
  * @throws Error if the webhook is not found or the request fails
5139
5489
  */
5140
5490
  async getWebhookVersions(webhookId) {
5141
- return this.httpGet(`/developer/webhooks/${this.agentId}/${webhookId}/versions`, {
5142
- Authorization: `Bearer ${this.apiKey}`
5143
- });
5491
+ return this.httpGet(`/developer/webhooks/${this.agentId}/${webhookId}/versions`, {});
5144
5492
  }
5145
5493
  /**
5146
5494
  * Publishes a specific version of a webhook to production
@@ -5150,9 +5498,7 @@ var init_webhook_api_service = __esm({
5150
5498
  * @throws Error if the webhook or version is not found or the publish operation fails
5151
5499
  */
5152
5500
  async publishWebhookVersion(webhookId, version) {
5153
- return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/${version}/publish`, {}, {
5154
- Authorization: `Bearer ${this.apiKey}`
5155
- });
5501
+ return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/${version}/publish`, {}, {});
5156
5502
  }
5157
5503
  /**
5158
5504
  * Activates a webhook (enables it to receive requests)
@@ -5161,9 +5507,7 @@ var init_webhook_api_service = __esm({
5161
5507
  * @throws Error if the webhook is not found or the operation fails
5162
5508
  */
5163
5509
  async activateWebhook(webhookId) {
5164
- return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/activate`, {}, {
5165
- Authorization: `Bearer ${this.apiKey}`
5166
- });
5510
+ return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/activate`, {}, {});
5167
5511
  }
5168
5512
  /**
5169
5513
  * Deactivates a webhook (stops it from receiving requests)
@@ -5172,9 +5516,7 @@ var init_webhook_api_service = __esm({
5172
5516
  * @throws Error if the webhook is not found or the operation fails
5173
5517
  */
5174
5518
  async deactivateWebhook(webhookId) {
5175
- return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/deactivate`, {}, {
5176
- Authorization: `Bearer ${this.apiKey}`
5177
- });
5519
+ return this.httpPost(`/developer/webhooks/${this.agentId}/${webhookId}/deactivate`, {}, {});
5178
5520
  }
5179
5521
  /**
5180
5522
  * Deletes a webhook and all its versions, or deactivates it if it has versions
@@ -5185,9 +5527,7 @@ var init_webhook_api_service = __esm({
5185
5527
  * @throws Error if the webhook is not found or the delete operation fails
5186
5528
  */
5187
5529
  async deleteWebhook(webhookId) {
5188
- return this.httpDelete(`/developer/webhooks/${this.agentId}/${webhookId}`, {
5189
- Authorization: `Bearer ${this.apiKey}`
5190
- });
5530
+ return this.httpDelete(`/developer/webhooks/${this.agentId}/${webhookId}`, {});
5191
5531
  }
5192
5532
  };
5193
5533
  }
@@ -5220,7 +5560,7 @@ var init_job_instance = __esm({
5220
5560
  this.activeVersion = jobData.activeVersion;
5221
5561
  this.metadata = jobData.metadata || {};
5222
5562
  if (jobData.userId && jobData.agentId) {
5223
- this.userApi = new UserDataApi(BASE_URLS.API, jobApi.apiKey, jobApi.agentId);
5563
+ this.userApi = new UserDataApi(BASE_URLS.API, jobApi.credential, jobApi.agentId);
5224
5564
  }
5225
5565
  }
5226
5566
  /**
@@ -5374,17 +5714,17 @@ var init_job_api_service = __esm({
5374
5714
  static {
5375
5715
  __name(this, "JobApi");
5376
5716
  }
5377
- apiKey;
5378
5717
  agentId;
5718
+ credential;
5379
5719
  /**
5380
5720
  * Creates an instance of JobApi
5381
5721
  * @param baseUrl - The base URL for the API
5382
- * @param apiKey - The API key for authentication
5722
+ * @param credential - The API key for authentication
5383
5723
  * @param agentId - The unique identifier of the agent
5384
5724
  */
5385
- constructor(baseUrl, apiKey, agentId) {
5386
- super(baseUrl);
5387
- this.apiKey = apiKey;
5725
+ constructor(baseUrl, credential, agentId) {
5726
+ super(baseUrl, credential);
5727
+ this.credential = credential;
5388
5728
  this.agentId = agentId;
5389
5729
  }
5390
5730
  /**
@@ -5398,9 +5738,7 @@ var init_job_api_service = __esm({
5398
5738
  queryParams.append("includeDynamic", "true");
5399
5739
  }
5400
5740
  const url = `/developer/jobs/${this.agentId}?${queryParams.toString()}`;
5401
- return this.httpGet(url, {
5402
- Authorization: `Bearer ${this.apiKey}`
5403
- });
5741
+ return this.httpGet(url, {});
5404
5742
  }
5405
5743
  /**
5406
5744
  * Retrieves all jobs for the agent as JobInstance array
@@ -5423,9 +5761,7 @@ var init_job_api_service = __esm({
5423
5761
  * @throws Error if the job is not found or the request fails
5424
5762
  */
5425
5763
  async getJob(jobId) {
5426
- const response = await this.httpGet(`/developer/jobs/${this.agentId}/${jobId}`, {
5427
- Authorization: `Bearer ${this.apiKey}`
5428
- });
5764
+ const response = await this.httpGet(`/developer/jobs/${this.agentId}/${jobId}`, {});
5429
5765
  if (response.success && response.data) {
5430
5766
  return new JobInstance(this, response.data);
5431
5767
  }
@@ -5442,9 +5778,7 @@ var init_job_api_service = __esm({
5442
5778
  * @throws Error if the job creation fails or validation errors occur
5443
5779
  */
5444
5780
  async createJob(jobData) {
5445
- return this.httpPost(`/developer/jobs/${this.agentId}`, jobData, {
5446
- Authorization: `Bearer ${this.apiKey}`
5447
- });
5781
+ return this.httpPost(`/developer/jobs/${this.agentId}`, jobData, {});
5448
5782
  }
5449
5783
  /**
5450
5784
  * Creates a new job for the agent and returns a JobInstance.
@@ -5457,9 +5791,7 @@ var init_job_api_service = __esm({
5457
5791
  * @throws Error if the job creation fails or validation errors occur
5458
5792
  */
5459
5793
  async createJobInstance(jobData) {
5460
- const response = await this.httpPost(`/developer/jobs/${this.agentId}`, jobData, {
5461
- Authorization: `Bearer ${this.apiKey}`
5462
- });
5794
+ const response = await this.httpPost(`/developer/jobs/${this.agentId}`, jobData, {});
5463
5795
  if (response.success && response.data) {
5464
5796
  return new JobInstance(this, response.data);
5465
5797
  }
@@ -5473,9 +5805,7 @@ var init_job_api_service = __esm({
5473
5805
  * @throws Error if the job is not found or the push operation fails
5474
5806
  */
5475
5807
  async pushJob(jobId, versionData) {
5476
- return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/version`, versionData, {
5477
- Authorization: `Bearer ${this.apiKey}`
5478
- });
5808
+ return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/version`, versionData, {});
5479
5809
  }
5480
5810
  /**
5481
5811
  * Pushes a new development/sandbox version of a job for testing
@@ -5485,9 +5815,7 @@ var init_job_api_service = __esm({
5485
5815
  * @throws Error if the job is not found or the push operation fails
5486
5816
  */
5487
5817
  async pushDevJob(jobId, versionData) {
5488
- return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/version/sandbox`, versionData, {
5489
- Authorization: `Bearer ${this.apiKey}`
5490
- });
5818
+ return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/version/sandbox`, versionData, {});
5491
5819
  }
5492
5820
  /**
5493
5821
  * Updates an existing development/sandbox version of a job
@@ -5498,9 +5826,7 @@ var init_job_api_service = __esm({
5498
5826
  * @throws Error if the job or version is not found or the update fails
5499
5827
  */
5500
5828
  async updateDevJob(jobId, sandboxVersionId, versionData) {
5501
- return this.httpPut(`/developer/jobs/${this.agentId}/${jobId}/version/sandbox/${sandboxVersionId}`, versionData, {
5502
- Authorization: `Bearer ${this.apiKey}`
5503
- });
5829
+ return this.httpPut(`/developer/jobs/${this.agentId}/${jobId}/version/sandbox/${sandboxVersionId}`, versionData, {});
5504
5830
  }
5505
5831
  /**
5506
5832
  * Retrieves all versions of a specific job
@@ -5509,9 +5835,7 @@ var init_job_api_service = __esm({
5509
5835
  * @throws Error if the job is not found or the request fails
5510
5836
  */
5511
5837
  async getJobVersions(jobId) {
5512
- return this.httpGet(`/developer/jobs/${this.agentId}/${jobId}/versions`, {
5513
- Authorization: `Bearer ${this.apiKey}`
5514
- });
5838
+ return this.httpGet(`/developer/jobs/${this.agentId}/${jobId}/versions`, {});
5515
5839
  }
5516
5840
  /**
5517
5841
  * Publishes a specific version of a job to production
@@ -5521,9 +5845,7 @@ var init_job_api_service = __esm({
5521
5845
  * @throws Error if the job or version is not found or the publish operation fails
5522
5846
  */
5523
5847
  async publishJobVersion(jobId, version) {
5524
- return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/${version}/publish`, {}, {
5525
- Authorization: `Bearer ${this.apiKey}`
5526
- });
5848
+ return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/${version}/publish`, {}, {});
5527
5849
  }
5528
5850
  /**
5529
5851
  * Deletes a job and all its versions, or deactivates it if it has versions
@@ -5534,9 +5856,7 @@ var init_job_api_service = __esm({
5534
5856
  * @throws Error if the job is not found or the delete operation fails
5535
5857
  */
5536
5858
  async deleteJob(jobId) {
5537
- return this.httpDelete(`/developer/jobs/${this.agentId}/${jobId}`, {
5538
- Authorization: `Bearer ${this.apiKey}`
5539
- });
5859
+ return this.httpDelete(`/developer/jobs/${this.agentId}/${jobId}`, {});
5540
5860
  }
5541
5861
  /**
5542
5862
  * Activates a job (enables it to run on schedule)
@@ -5545,9 +5865,7 @@ var init_job_api_service = __esm({
5545
5865
  * @throws Error if the job is not found or the operation fails
5546
5866
  */
5547
5867
  async activateJob(jobId) {
5548
- return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/activate`, {}, {
5549
- Authorization: `Bearer ${this.apiKey}`
5550
- });
5868
+ return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/activate`, {}, {});
5551
5869
  }
5552
5870
  /**
5553
5871
  * Deactivates a job (disables it from running)
@@ -5556,9 +5874,7 @@ var init_job_api_service = __esm({
5556
5874
  * @throws Error if the job is not found or the operation fails
5557
5875
  */
5558
5876
  async deactivateJob(jobId) {
5559
- return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/deactivate`, {}, {
5560
- Authorization: `Bearer ${this.apiKey}`
5561
- });
5877
+ return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/deactivate`, {}, {});
5562
5878
  }
5563
5879
  /**
5564
5880
  * Manually triggers a job execution (ignores schedule)
@@ -5571,9 +5887,7 @@ var init_job_api_service = __esm({
5571
5887
  const body = versionId ? {
5572
5888
  versionId
5573
5889
  } : {};
5574
- return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/trigger`, body, {
5575
- Authorization: `Bearer ${this.apiKey}`
5576
- });
5890
+ return this.httpPost(`/developer/jobs/${this.agentId}/${jobId}/trigger`, body, {});
5577
5891
  }
5578
5892
  /**
5579
5893
  * Retrieves execution history for a job
@@ -5583,9 +5897,7 @@ var init_job_api_service = __esm({
5583
5897
  * @throws Error if the job is not found or the request fails
5584
5898
  */
5585
5899
  async getJobExecutions(jobId, limit = 50) {
5586
- return this.httpGet(`/developer/jobs/${this.agentId}/${jobId}/executions?limit=${limit}`, {
5587
- Authorization: `Bearer ${this.apiKey}`
5588
- });
5900
+ return this.httpGet(`/developer/jobs/${this.agentId}/${jobId}/executions?limit=${limit}`, {});
5589
5901
  }
5590
5902
  /**
5591
5903
  * Updates the metadata of a job
@@ -5595,9 +5907,7 @@ var init_job_api_service = __esm({
5595
5907
  * @throws Error if the job is not found or the metadata update fails
5596
5908
  */
5597
5909
  async updateMetadata(jobId, metadata) {
5598
- return this.httpPut(`/developer/jobs/${this.agentId}/${jobId}/metadata`, metadata, {
5599
- Authorization: `Bearer ${this.apiKey}`
5600
- });
5910
+ return this.httpPut(`/developer/jobs/${this.agentId}/${jobId}/metadata`, metadata, {});
5601
5911
  }
5602
5912
  };
5603
5913
  }
@@ -5614,15 +5924,12 @@ var init_ai_api_service = __esm({
5614
5924
  static {
5615
5925
  __name(this, "AiApiService");
5616
5926
  }
5617
- apiKey;
5618
5927
  agentId;
5619
- constructor(baseUrl, apiKey, agentId) {
5620
- super(baseUrl), this.apiKey = apiKey, this.agentId = agentId;
5928
+ constructor(baseUrl, credential, agentId) {
5929
+ super(baseUrl, credential), this.agentId = agentId;
5621
5930
  }
5622
5931
  async generate(body) {
5623
- return this.httpPost(`/developer/ai/${this.agentId}/generate`, body, {
5624
- Authorization: `Bearer ${this.apiKey}`
5625
- });
5932
+ return this.httpPost(`/developer/ai/${this.agentId}/generate`, body, {});
5626
5933
  }
5627
5934
  /**
5628
5935
  * Handles the simplified-vs-full-options branching for `AI.generate`.
@@ -5659,15 +5966,12 @@ var init_integrations_api_service = __esm({
5659
5966
  static {
5660
5967
  __name(this, "IntegrationsApiService");
5661
5968
  }
5662
- apiKey;
5663
5969
  agentId;
5664
- constructor(baseUrl, apiKey, agentId) {
5665
- super(baseUrl), this.apiKey = apiKey, this.agentId = agentId;
5970
+ constructor(baseUrl, credential, agentId) {
5971
+ super(baseUrl, credential), this.agentId = agentId;
5666
5972
  }
5667
5973
  async passthrough(integrationType, request) {
5668
- return this.httpPost(`/developer/unifiedto/connections/${encodeURIComponent(this.agentId)}/passthrough/${encodeURIComponent(integrationType)}`, request, {
5669
- Authorization: `Bearer ${this.apiKey}`
5670
- });
5974
+ return this.httpPost(`/developer/unifiedto/connections/${encodeURIComponent(this.agentId)}/passthrough/${encodeURIComponent(integrationType)}`, request, {});
5671
5975
  }
5672
5976
  /**
5673
5977
  * Sandbox-facing wrapper: returns the raw provider envelope
@@ -5696,9 +6000,8 @@ var init_agents_api_service = __esm({
5696
6000
  static {
5697
6001
  __name(this, "AgentsApiService");
5698
6002
  }
5699
- apiKey;
5700
- constructor(baseUrl, apiKey) {
5701
- super(baseUrl), this.apiKey = apiKey;
6003
+ constructor(baseUrl, credential) {
6004
+ super(baseUrl, credential);
5702
6005
  }
5703
6006
  async invoke(targetAgentId, body) {
5704
6007
  const channel = body.channel ?? "agent-invocation";
@@ -5707,9 +6010,7 @@ var init_agents_api_service = __esm({
5707
6010
  });
5708
6011
  if (body.identifier) query.set("identifier", body.identifier);
5709
6012
  const chatBody = this.toChatGenerateBody(body);
5710
- return this.httpPost(`/chat/generate/${targetAgentId}?${query.toString()}`, chatBody, {
5711
- Authorization: `Bearer ${this.apiKey}`
5712
- });
6013
+ return this.httpPost(`/chat/generate/${targetAgentId}?${query.toString()}`, chatBody, {});
5713
6014
  }
5714
6015
  /**
5715
6016
  * Sandbox overload: mirrors the `AI.generate` pattern where the simplified
@@ -5770,17 +6071,15 @@ var init_whatsapp_templates_api_service = __esm({
5770
6071
  static {
5771
6072
  __name(this, "WhatsAppTemplatesApiService");
5772
6073
  }
5773
- apiKey;
5774
6074
  agentId;
5775
6075
  /**
5776
6076
  * Creates an instance of WhatsAppTemplatesApiService
5777
6077
  * @param baseUrl - The base URL for the API
5778
- * @param apiKey - The API key for authentication
6078
+ * @param credential - The API key for authentication
5779
6079
  * @param agentId - The unique identifier of the agent
5780
6080
  */
5781
- constructor(baseUrl, apiKey, agentId) {
5782
- super(baseUrl);
5783
- this.apiKey = apiKey;
6081
+ constructor(baseUrl, credential, agentId) {
6082
+ super(baseUrl, credential);
5784
6083
  this.agentId = agentId;
5785
6084
  }
5786
6085
  /**
@@ -5797,9 +6096,7 @@ var init_whatsapp_templates_api_service = __esm({
5797
6096
  if (search) {
5798
6097
  url += `&search=${encodeURIComponent(search)}`;
5799
6098
  }
5800
- const response = await this.httpGet(url, {
5801
- Authorization: `Bearer ${this.apiKey}`
5802
- });
6099
+ const response = await this.httpGet(url, {});
5803
6100
  if (response.success) {
5804
6101
  return response.data;
5805
6102
  }
@@ -5813,9 +6110,7 @@ var init_whatsapp_templates_api_service = __esm({
5813
6110
  */
5814
6111
  async get(channelId, templateId) {
5815
6112
  const url = `/admin/agents/${this.agentId}/channels/${channelId}/whatsapp-templates/${templateId}`;
5816
- const response = await this.httpGet(url, {
5817
- Authorization: `Bearer ${this.apiKey}`
5818
- });
6113
+ const response = await this.httpGet(url, {});
5819
6114
  if (response.success) {
5820
6115
  return response.data;
5821
6116
  }
@@ -5834,9 +6129,7 @@ var init_whatsapp_templates_api_service = __esm({
5834
6129
  phone_numbers: data.phoneNumbers,
5835
6130
  values: data.values
5836
6131
  };
5837
- const response = await this.httpPost(url, body, {
5838
- Authorization: `Bearer ${this.apiKey}`
5839
- });
6132
+ const response = await this.httpPost(url, body, {});
5840
6133
  if (response.success) {
5841
6134
  return response.data;
5842
6135
  }
@@ -5852,15 +6145,16 @@ var init_cdn_api_service = __esm({
5852
6145
  "src/api/cdn.api.service.ts"() {
5853
6146
  "use strict";
5854
6147
  init_lua_fetch();
6148
+ init_request_credential();
5855
6149
  CdnApi = class {
5856
6150
  static {
5857
6151
  __name(this, "CdnApi");
5858
6152
  }
5859
6153
  baseUrl;
5860
- apiKey;
5861
- constructor(baseUrl, apiKey) {
6154
+ credential;
6155
+ constructor(baseUrl, credential) {
5862
6156
  this.baseUrl = baseUrl;
5863
- this.apiKey = apiKey;
6157
+ this.credential = credential;
5864
6158
  }
5865
6159
  /**
5866
6160
  * Uploads a file to the CDN
@@ -5873,7 +6167,7 @@ var init_cdn_api_service = __esm({
5873
6167
  const response = await luaFetch(`${this.baseUrl}/upload`, {
5874
6168
  method: "POST",
5875
6169
  headers: {
5876
- Authorization: `Bearer ${this.apiKey}`
6170
+ Authorization: `Bearer ${await bearerFor(this.credential)}`
5877
6171
  },
5878
6172
  body: formData
5879
6173
  });
@@ -5917,17 +6211,15 @@ var init_developer_api_service = __esm({
5917
6211
  static {
5918
6212
  __name(this, "DeveloperApi");
5919
6213
  }
5920
- apiKey;
5921
6214
  agentId;
5922
6215
  /**
5923
6216
  * Creates an instance of DeveloperApi
5924
6217
  * @param baseUrl - The base URL for the API
5925
- * @param apiKey - The API key for authentication
6218
+ * @param credential - The API key for authentication
5926
6219
  * @param agentId - The unique identifier of the agent
5927
6220
  */
5928
- constructor(baseUrl, apiKey, agentId) {
5929
- super(baseUrl);
5930
- this.apiKey = apiKey;
6221
+ constructor(baseUrl, credential, agentId) {
6222
+ super(baseUrl, credential);
5931
6223
  this.agentId = agentId;
5932
6224
  }
5933
6225
  /**
@@ -5937,9 +6229,7 @@ var init_developer_api_service = __esm({
5937
6229
  * @throws Error if the API request fails or the agent is not found
5938
6230
  */
5939
6231
  async getEnvironmentVariables() {
5940
- return this.httpGet(`/developer/agents/${this.agentId}/env`, {
5941
- Authorization: `Bearer ${this.apiKey}`
5942
- });
6232
+ return this.httpGet(`/developer/agents/${this.agentId}/env`, {});
5943
6233
  }
5944
6234
  /**
5945
6235
  * Updates all environment variables for the agent in production
@@ -5949,9 +6239,7 @@ var init_developer_api_service = __esm({
5949
6239
  * @throws Error if the API request fails or the agent is not found
5950
6240
  */
5951
6241
  async updateEnvironmentVariables(envData) {
5952
- return this.httpPost(`/developer/agents/${this.agentId}/env`, envData, {
5953
- Authorization: `Bearer ${this.apiKey}`
5954
- });
6242
+ return this.httpPost(`/developer/agents/${this.agentId}/env`, envData, {});
5955
6243
  }
5956
6244
  /**
5957
6245
  * Deletes a specific environment variable by key
@@ -5960,27 +6248,21 @@ var init_developer_api_service = __esm({
5960
6248
  * @throws Error if the API request fails, the agent is not found, or the key doesn't exist
5961
6249
  */
5962
6250
  async deleteEnvironmentVariable(key) {
5963
- return this.httpDelete(`/developer/agents/${this.agentId}/env/${key}`, {
5964
- Authorization: `Bearer ${this.apiKey}`
5965
- });
6251
+ return this.httpDelete(`/developer/agents/${this.agentId}/env/${key}`, {});
5966
6252
  }
5967
6253
  /**
5968
6254
  * Retrieves all MCP server configurations for the agent
5969
6255
  * @returns Promise resolving to an ApiResponse containing MCP server configurations
5970
6256
  */
5971
6257
  async getMCPServers() {
5972
- return this.httpGet(`/developer/agents/${this.agentId}/mcp-servers`, {
5973
- Authorization: `Bearer ${this.apiKey}`
5974
- });
6258
+ return this.httpGet(`/developer/agents/${this.agentId}/mcp-servers`, {});
5975
6259
  }
5976
6260
  /**
5977
6261
  * Retrieves only active MCP server configurations for the agent
5978
6262
  * @returns Promise resolving to an ApiResponse containing active MCP server configurations
5979
6263
  */
5980
6264
  async getActiveMCPServers() {
5981
- return this.httpGet(`/developer/agents/${this.agentId}/mcp-servers/active`, {
5982
- Authorization: `Bearer ${this.apiKey}`
5983
- });
6265
+ return this.httpGet(`/developer/agents/${this.agentId}/mcp-servers/active`, {});
5984
6266
  }
5985
6267
  /**
5986
6268
  * Gets a single MCP server by ID
@@ -5988,9 +6270,7 @@ var init_developer_api_service = __esm({
5988
6270
  * @returns Promise resolving to an ApiResponse with the MCP server
5989
6271
  */
5990
6272
  async getMCPServer(mcpServerId) {
5991
- return this.httpGet(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}`, {
5992
- Authorization: `Bearer ${this.apiKey}`
5993
- });
6273
+ return this.httpGet(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}`, {});
5994
6274
  }
5995
6275
  /**
5996
6276
  * Creates a new MCP server
@@ -5998,9 +6278,7 @@ var init_developer_api_service = __esm({
5998
6278
  * @returns Promise resolving to an ApiResponse with the created MCP server
5999
6279
  */
6000
6280
  async createMCPServer(mcpServerData) {
6001
- return this.httpPost(`/developer/agents/${this.agentId}/mcp-servers`, mcpServerData, {
6002
- Authorization: `Bearer ${this.apiKey}`
6003
- });
6281
+ return this.httpPost(`/developer/agents/${this.agentId}/mcp-servers`, mcpServerData, {});
6004
6282
  }
6005
6283
  /**
6006
6284
  * Updates an existing MCP server
@@ -6009,9 +6287,7 @@ var init_developer_api_service = __esm({
6009
6287
  * @returns Promise resolving to an ApiResponse with the updated MCP server
6010
6288
  */
6011
6289
  async updateMCPServer(mcpServerId, mcpServerData) {
6012
- return this.httpPut(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}`, mcpServerData, {
6013
- Authorization: `Bearer ${this.apiKey}`
6014
- });
6290
+ return this.httpPut(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}`, mcpServerData, {});
6015
6291
  }
6016
6292
  /**
6017
6293
  * Deletes an MCP server
@@ -6019,9 +6295,7 @@ var init_developer_api_service = __esm({
6019
6295
  * @returns Promise resolving to an ApiResponse with confirmation
6020
6296
  */
6021
6297
  async deleteMCPServer(mcpServerId) {
6022
- return this.httpDelete(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}`, {
6023
- Authorization: `Bearer ${this.apiKey}`
6024
- });
6298
+ return this.httpDelete(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}`, {});
6025
6299
  }
6026
6300
  /**
6027
6301
  * Activates an MCP server
@@ -6029,9 +6303,7 @@ var init_developer_api_service = __esm({
6029
6303
  * @returns Promise resolving to an ApiResponse with the activated MCP server
6030
6304
  */
6031
6305
  async activateMCPServer(mcpServerId) {
6032
- return this.httpPut(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}/activate`, {}, {
6033
- Authorization: `Bearer ${this.apiKey}`
6034
- });
6306
+ return this.httpPut(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}/activate`, {}, {});
6035
6307
  }
6036
6308
  /**
6037
6309
  * Deactivates an MCP server
@@ -6039,9 +6311,7 @@ var init_developer_api_service = __esm({
6039
6311
  * @returns Promise resolving to an ApiResponse with the deactivated MCP server
6040
6312
  */
6041
6313
  async deactivateMCPServer(mcpServerId) {
6042
- return this.httpPut(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}/deactivate`, {}, {
6043
- Authorization: `Bearer ${this.apiKey}`
6044
- });
6314
+ return this.httpPut(`/developer/agents/${this.agentId}/mcp-servers/${mcpServerId}/deactivate`, {}, {});
6045
6315
  }
6046
6316
  /**
6047
6317
  * Creates or updates an MCP server by name (upsert)
@@ -6049,9 +6319,7 @@ var init_developer_api_service = __esm({
6049
6319
  * @returns Promise resolving to an ApiResponse with the created/updated MCP server
6050
6320
  */
6051
6321
  async upsertMCPServer(mcpServerData) {
6052
- return this.httpPost(`/developer/agents/${this.agentId}/mcp-servers/upsert`, mcpServerData, {
6053
- Authorization: `Bearer ${this.apiKey}`
6054
- });
6322
+ return this.httpPost(`/developer/agents/${this.agentId}/mcp-servers/upsert`, mcpServerData, {});
6055
6323
  }
6056
6324
  /**
6057
6325
  * Gets a user profile by email address
@@ -6061,9 +6329,7 @@ var init_developer_api_service = __esm({
6061
6329
  async getUserProfileByEmail(email, agentId) {
6062
6330
  const path3 = `/developer/user/profile/email/${encodeURIComponent(email)}`;
6063
6331
  const scopedPath = agentId ? `${path3}?agentId=${encodeURIComponent(agentId)}` : path3;
6064
- return this.httpGet(scopedPath, {
6065
- Authorization: `Bearer ${this.apiKey}`
6066
- });
6332
+ return this.httpGet(scopedPath, {});
6067
6333
  }
6068
6334
  /**
6069
6335
  * Gets a user profile by phone number
@@ -6074,9 +6340,7 @@ var init_developer_api_service = __esm({
6074
6340
  const normalizedPhone = phone.replace(/^\+/, "");
6075
6341
  const path3 = `/developer/user/profile/phone/${normalizedPhone}`;
6076
6342
  const scopedPath = agentId ? `${path3}?agentId=${encodeURIComponent(agentId)}` : path3;
6077
- return this.httpGet(scopedPath, {
6078
- Authorization: `Bearer ${this.apiKey}`
6079
- });
6343
+ return this.httpGet(scopedPath, {});
6080
6344
  }
6081
6345
  };
6082
6346
  }
@@ -6092,42 +6356,28 @@ var init_voice_api_service = __esm({
6092
6356
  static {
6093
6357
  __name(this, "VoiceApi");
6094
6358
  }
6095
- apiKey;
6096
6359
  agentId;
6097
- constructor(baseUrl, apiKey, agentId) {
6098
- super(baseUrl);
6099
- this.apiKey = apiKey;
6360
+ constructor(baseUrl, credential, agentId) {
6361
+ super(baseUrl, credential);
6100
6362
  this.agentId = agentId;
6101
6363
  }
6102
6364
  async getVoices() {
6103
- return this.httpGet(`/developer/voice-agents/${this.agentId}`, {
6104
- Authorization: `Bearer ${this.apiKey}`
6105
- });
6365
+ return this.httpGet(`/developer/voice-agents/${this.agentId}`, {});
6106
6366
  }
6107
6367
  async createVoice(voiceData) {
6108
- return this.httpPost(`/developer/voice-agents/${this.agentId}`, voiceData, {
6109
- Authorization: `Bearer ${this.apiKey}`
6110
- });
6368
+ return this.httpPost(`/developer/voice-agents/${this.agentId}`, voiceData, {});
6111
6369
  }
6112
6370
  async pushVoice(voiceId, versionData) {
6113
- return this.httpPost(`/developer/voice-agents/${this.agentId}/${voiceId}/version`, versionData, {
6114
- Authorization: `Bearer ${this.apiKey}`
6115
- });
6371
+ return this.httpPost(`/developer/voice-agents/${this.agentId}/${voiceId}/version`, versionData, {});
6116
6372
  }
6117
6373
  async getVoiceVersions(voiceId) {
6118
- return this.httpGet(`/developer/voice-agents/${this.agentId}/${voiceId}/versions`, {
6119
- Authorization: `Bearer ${this.apiKey}`
6120
- });
6374
+ return this.httpGet(`/developer/voice-agents/${this.agentId}/${voiceId}/versions`, {});
6121
6375
  }
6122
6376
  async publishVoiceVersion(voiceId, version) {
6123
- return this.httpPut(`/developer/voice-agents/${this.agentId}/${voiceId}/${version}/publish`, void 0, {
6124
- Authorization: `Bearer ${this.apiKey}`
6125
- });
6377
+ return this.httpPut(`/developer/voice-agents/${this.agentId}/${voiceId}/${version}/publish`, void 0, {});
6126
6378
  }
6127
6379
  async deleteVoice(voiceId) {
6128
- return this.httpDelete(`/developer/voice-agents/${this.agentId}/${voiceId}`, {
6129
- Authorization: `Bearer ${this.apiKey}`
6130
- });
6380
+ return this.httpDelete(`/developer/voice-agents/${this.agentId}/${voiceId}`, {});
6131
6381
  }
6132
6382
  /**
6133
6383
  * Place an outbound voice call. Wraps `POST /developer/voice-agents/:agentId/dispatch`
@@ -6135,9 +6385,7 @@ var init_voice_api_service = __esm({
6135
6385
  * forwarded to the lua-livekit worker which allocates the room and dials.
6136
6386
  */
6137
6387
  async dispatch(input) {
6138
- return this.httpPost(`/developer/voice-agents/${this.agentId}/dispatch`, input, {
6139
- Authorization: `Bearer ${this.apiKey}`
6140
- });
6388
+ return this.httpPost(`/developer/voice-agents/${this.agentId}/dispatch`, input, {});
6141
6389
  }
6142
6390
  /**
6143
6391
  * Create a voice room + client access token for a custom frontend
@@ -6146,9 +6394,7 @@ var init_voice_api_service = __esm({
6146
6394
  * user. Wraps `POST /developer/voice/:agentId/session`.
6147
6395
  */
6148
6396
  async createSession(input = {}) {
6149
- return this.httpPost(`/developer/voice/${this.agentId}/session`, input, {
6150
- Authorization: `Bearer ${this.apiKey}`
6151
- });
6397
+ return this.httpPost(`/developer/voice/${this.agentId}/session`, input, {});
6152
6398
  }
6153
6399
  /**
6154
6400
  * Sandbox helper: throws on non-success and returns the unwrapped output.
@@ -6192,34 +6438,25 @@ var init_channels_send_api_service = __esm({
6192
6438
  static {
6193
6439
  __name(this, "ChannelsSendApiService");
6194
6440
  }
6195
- apiKey;
6196
6441
  agentId;
6197
- constructor(baseUrl, apiKey, agentId) {
6198
- super(baseUrl), this.apiKey = apiKey, this.agentId = agentId;
6442
+ constructor(baseUrl, credential, agentId) {
6443
+ super(baseUrl, credential), this.agentId = agentId;
6199
6444
  }
6200
6445
  /** POST /developer/agents/:agentId/channels/send */
6201
6446
  async send(input) {
6202
- return this.httpPost(`/developer/agents/${this.agentId}/channels/send`, input, {
6203
- Authorization: `Bearer ${this.apiKey}`
6204
- });
6447
+ return this.httpPost(`/developer/agents/${this.agentId}/channels/send`, input, {});
6205
6448
  }
6206
6449
  /** POST /developer/agents/:agentId/channels/whatsapp/template */
6207
6450
  async sendWhatsAppTemplate(input) {
6208
- return this.httpPost(`/developer/agents/${this.agentId}/channels/whatsapp/template`, input, {
6209
- Authorization: `Bearer ${this.apiKey}`
6210
- });
6451
+ return this.httpPost(`/developer/agents/${this.agentId}/channels/whatsapp/template`, input, {});
6211
6452
  }
6212
6453
  /** POST /developer/agents/:agentId/channels/whatsapp/reaction */
6213
6454
  async sendWhatsAppReaction(input) {
6214
- return this.httpPost(`/developer/agents/${this.agentId}/channels/whatsapp/reaction`, input, {
6215
- Authorization: `Bearer ${this.apiKey}`
6216
- });
6455
+ return this.httpPost(`/developer/agents/${this.agentId}/channels/whatsapp/reaction`, input, {});
6217
6456
  }
6218
6457
  /** POST /developer/agents/:agentId/channels/email/send */
6219
6458
  async sendEmail(input) {
6220
- return this.httpPost(`/developer/agents/${this.agentId}/channels/email/send`, input, {
6221
- Authorization: `Bearer ${this.apiKey}`
6222
- });
6459
+ return this.httpPost(`/developer/agents/${this.agentId}/channels/email/send`, input, {});
6223
6460
  }
6224
6461
  /**
6225
6462
  * Sandbox helper: throws on non-success, returns unwrapped output.
@@ -6282,16 +6519,13 @@ var init_inbox_push_api_service = __esm({
6282
6519
  static {
6283
6520
  __name(this, "InboxPushApiService");
6284
6521
  }
6285
- apiKey;
6286
6522
  agentId;
6287
- constructor(baseUrl, apiKey, agentId) {
6288
- super(baseUrl), this.apiKey = apiKey, this.agentId = agentId;
6523
+ constructor(baseUrl, credential, agentId) {
6524
+ super(baseUrl, credential), this.agentId = agentId;
6289
6525
  }
6290
6526
  /** POST /developer/agents/:agentId/inbox/push */
6291
6527
  async push(input) {
6292
- return this.httpPost(`/developer/agents/${this.agentId}/inbox/push`, input, {
6293
- Authorization: `Bearer ${this.apiKey}`
6294
- });
6528
+ return this.httpPost(`/developer/agents/${this.agentId}/inbox/push`, input, {});
6295
6529
  }
6296
6530
  };
6297
6531
  }
@@ -6307,18 +6541,15 @@ var init_directory_api_service = __esm({
6307
6541
  static {
6308
6542
  __name(this, "DirectoryApiService");
6309
6543
  }
6310
- apiKey;
6311
6544
  agentId;
6312
- constructor(baseUrl, apiKey, agentId) {
6313
- super(baseUrl), this.apiKey = apiKey, this.agentId = agentId;
6545
+ constructor(baseUrl, credential, agentId) {
6546
+ super(baseUrl, credential), this.agentId = agentId;
6314
6547
  }
6315
6548
  /** POST /developer/agents/:agentId/directory/resolve */
6316
6549
  async resolve(name) {
6317
6550
  return this.httpPost(`/developer/agents/${this.agentId}/directory/resolve`, {
6318
6551
  name
6319
- }, {
6320
- Authorization: `Bearer ${this.apiKey}`
6321
- });
6552
+ }, {});
6322
6553
  }
6323
6554
  /** Sandbox helper: throws on non-success, returns unwrapped result. */
6324
6555
  async resolveForSandbox(name) {
@@ -6349,71 +6580,47 @@ var init_device_api_service = __esm({
6349
6580
  static {
6350
6581
  __name(this, "DeviceApi");
6351
6582
  }
6352
- apiKey;
6353
6583
  agentId;
6354
- constructor(baseUrl, apiKey, agentId) {
6355
- super(baseUrl);
6356
- this.apiKey = apiKey;
6584
+ constructor(baseUrl, credential, agentId) {
6585
+ super(baseUrl, credential);
6357
6586
  this.agentId = agentId;
6358
6587
  }
6359
6588
  async getDevices() {
6360
- return this.httpGet(`/developer/devices/${this.agentId}`, {
6361
- Authorization: `Bearer ${this.apiKey}`
6362
- });
6589
+ return this.httpGet(`/developer/devices/${this.agentId}`, {});
6363
6590
  }
6364
6591
  async createDevice(deviceData) {
6365
- return this.httpPost(`/developer/devices/${this.agentId}`, deviceData, {
6366
- Authorization: `Bearer ${this.apiKey}`
6367
- });
6592
+ return this.httpPost(`/developer/devices/${this.agentId}`, deviceData, {});
6368
6593
  }
6369
6594
  async pushDevice(deviceId, versionData) {
6370
- return this.httpPost(`/developer/devices/${this.agentId}/${deviceId}/version`, versionData, {
6371
- Authorization: `Bearer ${this.apiKey}`
6372
- });
6595
+ return this.httpPost(`/developer/devices/${this.agentId}/${deviceId}/version`, versionData, {});
6373
6596
  }
6374
6597
  async pushDevDevice(deviceId, versionData) {
6375
- return this.httpPost(`/developer/devices/${this.agentId}/${deviceId}/version/sandbox`, versionData, {
6376
- Authorization: `Bearer ${this.apiKey}`
6377
- });
6598
+ return this.httpPost(`/developer/devices/${this.agentId}/${deviceId}/version/sandbox`, versionData, {});
6378
6599
  }
6379
6600
  async getDeviceVersions(deviceId) {
6380
- return this.httpGet(`/developer/devices/${this.agentId}/${deviceId}/versions`, {
6381
- Authorization: `Bearer ${this.apiKey}`
6382
- });
6601
+ return this.httpGet(`/developer/devices/${this.agentId}/${deviceId}/versions`, {});
6383
6602
  }
6384
6603
  async publishDeviceVersion(deviceId, version) {
6385
- return this.httpPost(`/developer/devices/${this.agentId}/${deviceId}/${version}/publish`, {}, {
6386
- Authorization: `Bearer ${this.apiKey}`
6387
- });
6604
+ return this.httpPost(`/developer/devices/${this.agentId}/${deviceId}/${version}/publish`, {}, {});
6388
6605
  }
6389
6606
  async deleteDevice(deviceId) {
6390
- return this.httpDelete(`/developer/devices/${this.agentId}/${deviceId}`, {
6391
- Authorization: `Bearer ${this.apiKey}`
6392
- });
6607
+ return this.httpDelete(`/developer/devices/${this.agentId}/${deviceId}`, {});
6393
6608
  }
6394
6609
  async sendCommand(deviceName, command, payload, timeout) {
6395
6610
  return this.httpPost(`/developer/devices/${this.agentId}/${deviceName}/command`, {
6396
6611
  command,
6397
6612
  payload,
6398
6613
  timeout: timeout || 3e4
6399
- }, {
6400
- Authorization: `Bearer ${this.apiKey}`
6401
- });
6614
+ }, {});
6402
6615
  }
6403
6616
  async getDeviceStatus(deviceName) {
6404
- return this.httpGet(`/developer/devices/${this.agentId}/${deviceName}/status`, {
6405
- Authorization: `Bearer ${this.apiKey}`
6406
- });
6617
+ return this.httpGet(`/developer/devices/${this.agentId}/${deviceName}/status`, {});
6407
6618
  }
6408
6619
  async enableDevice(deviceName) {
6409
- return this.httpPatch(`/developer/devices/${this.agentId}/${deviceName}/enable`, {}, {
6410
- Authorization: `Bearer ${this.apiKey}`
6411
- });
6620
+ return this.httpPatch(`/developer/devices/${this.agentId}/${deviceName}/enable`, {}, {});
6412
6621
  }
6413
6622
  async disableDevice(deviceName) {
6414
- return this.httpPatch(`/developer/devices/${this.agentId}/${deviceName}/disable`, {}, {
6415
- Authorization: `Bearer ${this.apiKey}`
6416
- });
6623
+ return this.httpPatch(`/developer/devices/${this.agentId}/${deviceName}/disable`, {}, {});
6417
6624
  }
6418
6625
  };
6419
6626
  }