@alva-ai/toolkit 0.9.3 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -130,6 +130,8 @@ interface CronjobCreateRequest {
130
130
  name: string;
131
131
  args?: Record<string, unknown>;
132
132
  push_notify?: boolean;
133
+ /** Override per-cronjob V8 heap limit (MB). Valid range 1–2046. */
134
+ max_heap_size_mb?: number;
133
135
  }
134
136
  interface Cronjob {
135
137
  id: number;
@@ -139,6 +141,8 @@ interface Cronjob {
139
141
  status: string;
140
142
  args: Record<string, unknown>;
141
143
  push_notify: boolean;
144
+ /** Per-cronjob V8 heap cap (MB). null when using the server default. */
145
+ max_heap_size_mb: number | null;
142
146
  created_at: string;
143
147
  updated_at: string;
144
148
  }
@@ -156,6 +160,8 @@ interface CronjobUpdateRequest {
156
160
  cron_expression?: string;
157
161
  args?: Record<string, unknown>;
158
162
  push_notify?: boolean;
163
+ /** Override per-cronjob V8 heap limit (MB). Valid range 1–2046. */
164
+ max_heap_size_mb?: number;
159
165
  }
160
166
  interface CronjobRunsListParams {
161
167
  cronjob_id: number;
@@ -1232,6 +1238,13 @@ type UdfDescriptor = {
1232
1238
  name: string;
1233
1239
  params_schema: unknown | null;
1234
1240
  };
1241
+ type UdfInvokeResponse<TResult = unknown> = {
1242
+ result: TResult;
1243
+ logs?: unknown;
1244
+ credits_used_total?: number;
1245
+ credits_charged_owner?: number;
1246
+ credits_charged_consumer?: number;
1247
+ };
1235
1248
  type UdfButtonOptions = {
1236
1249
  functionName: string;
1237
1250
  params?: unknown;
@@ -1245,9 +1258,10 @@ type UdfButtonEventDetail<TResult = unknown> = {
1245
1258
  error?: unknown;
1246
1259
  };
1247
1260
  type UdfApi = {
1248
- call: <TResult = unknown>(functionName: string, params: unknown) => Promise<TResult>;
1261
+ call: <TResult = unknown>(functionName: string, params: unknown) => Promise<UdfInvokeResponse<TResult>>;
1249
1262
  list: () => Promise<UdfDescriptor[]>;
1250
1263
  getViewerToken: () => string | null;
1264
+ isAuthenticated: () => boolean;
1251
1265
  renderButton: (target: HTMLElement | string, options: UdfButtonOptions) => HTMLButtonElement;
1252
1266
  UdfError: typeof UdfError;
1253
1267
  UdfAuthRequiredError: typeof UdfAuthRequiredError;
@@ -1314,6 +1328,7 @@ declare class UdfTransportError extends UdfError {
1314
1328
  declare const PBSV_UPDATE_MESSAGE = "alva:pbsv:update";
1315
1329
  declare const UDF_CONSENT_REQUEST_MESSAGE = "alva:udf:consent-request";
1316
1330
  declare const UDF_CONSENT_RESPONSE_MESSAGE = "alva:udf:consent-response";
1331
+ declare const UDF_AUTH_REQUIRED_MESSAGE = "alva:udf:auth-required";
1317
1332
  declare const playbookIdFromToken: (token: string | null) => string | null;
1318
1333
  declare const getViewerToken: () => string | null;
1319
1334
  declare const mapUdfErrorResponse: (body: UdfErrorBody, status?: number) => UdfError;
@@ -1323,4 +1338,4 @@ declare const installPlaybookRuntime: (targetWindow?: Window) => void;
1323
1338
  /** SDK version, injected at build time from package.json. */
1324
1339
  declare const VERSION: string;
1325
1340
 
1326
- export { AlvaClient, type AlvaClientConfig, AlvaError, type ChannelGroupAdminInfo, type ChannelGroupCallerInfo, type ChannelGroupSubscription, type ChannelGroupSubscriptionContextResponse, type ChannelGroupSubscriptionListResponse, type ChannelGroupSubscriptionMutationParams, type ChannelGroupSubscriptionMutationResponse, type ChannelGroupSubscriptionSessionParams, type ChannelGroupSubscriptionTarget, type ChannelGroupSubscriptionTargetType, type FeedDeleteRequest, type FeedDeleteResponse, type FsChmodParams, type FsCopyParams, type FsEntry, type FsGrantParams, type FsMkdirParams, type FsRawWriteParams, type FsReadParams, type FsReaddirParams, type FsReaddirResponse, type FsReadlinkParams, type FsRemoveParams, type FsRenameParams, type FsRevokeParams, type FsStat, type FsSymlinkParams, type FsWriteParams, type FsWriteResponse, type NotificationPreference, type NotificationPreferenceKey, type NotificationPreferenceUpdateParams, type NotificationPreferenceUpdateResponse, type NotificationPreferencesResponse, PBSV_UPDATE_MESSAGE, type SkillDoc, type SkillEndpointMetadata, type SkillEndpointTier, type SkillMetadata, type SkillSummary, type TrendingPlaybookItem, type TrendingPlaybooksDir, type TrendingPlaybooksParams, type TrendingPlaybooksResponse, type TrendingPlaybooksSort, UDF_CONSENT_REQUEST_MESSAGE, UDF_CONSENT_RESPONSE_MESSAGE, type UdfApi, UdfAuthRequiredError, type UdfButtonEventDetail, type UdfButtonOptions, UdfConsentDeniedError, UdfConsentRequiredError, UdfConsentTimeoutError, type UdfDescriptor, UdfError, UdfExecutionError, UdfFunctionDisabledError, UdfFunctionNotFoundError, UdfInsufficientCredits, UdfPidMismatchError, UdfRateLimitedError, UdfTokenExpiredError, UdfTokenInvalidError, UdfTransportError, VERSION, getViewerToken, installPlaybookRuntime, mapUdfErrorResponse, playbookIdFromToken, udf };
1341
+ export { AlvaClient, type AlvaClientConfig, AlvaError, type ChannelGroupAdminInfo, type ChannelGroupCallerInfo, type ChannelGroupSubscription, type ChannelGroupSubscriptionContextResponse, type ChannelGroupSubscriptionListResponse, type ChannelGroupSubscriptionMutationParams, type ChannelGroupSubscriptionMutationResponse, type ChannelGroupSubscriptionSessionParams, type ChannelGroupSubscriptionTarget, type ChannelGroupSubscriptionTargetType, type FeedDeleteRequest, type FeedDeleteResponse, type FsChmodParams, type FsCopyParams, type FsEntry, type FsGrantParams, type FsMkdirParams, type FsRawWriteParams, type FsReadParams, type FsReaddirParams, type FsReaddirResponse, type FsReadlinkParams, type FsRemoveParams, type FsRenameParams, type FsRevokeParams, type FsStat, type FsSymlinkParams, type FsWriteParams, type FsWriteResponse, type NotificationPreference, type NotificationPreferenceKey, type NotificationPreferenceUpdateParams, type NotificationPreferenceUpdateResponse, type NotificationPreferencesResponse, PBSV_UPDATE_MESSAGE, type SkillDoc, type SkillEndpointMetadata, type SkillEndpointTier, type SkillMetadata, type SkillSummary, type TrendingPlaybookItem, type TrendingPlaybooksDir, type TrendingPlaybooksParams, type TrendingPlaybooksResponse, type TrendingPlaybooksSort, UDF_AUTH_REQUIRED_MESSAGE, UDF_CONSENT_REQUEST_MESSAGE, UDF_CONSENT_RESPONSE_MESSAGE, type UdfApi, UdfAuthRequiredError, type UdfButtonEventDetail, type UdfButtonOptions, UdfConsentDeniedError, UdfConsentRequiredError, UdfConsentTimeoutError, type UdfDescriptor, UdfError, UdfExecutionError, UdfFunctionDisabledError, UdfFunctionNotFoundError, UdfInsufficientCredits, type UdfInvokeResponse, UdfPidMismatchError, UdfRateLimitedError, UdfTokenExpiredError, UdfTokenInvalidError, UdfTransportError, VERSION, getViewerToken, installPlaybookRuntime, mapUdfErrorResponse, playbookIdFromToken, udf };
package/dist/index.d.ts CHANGED
@@ -130,6 +130,8 @@ interface CronjobCreateRequest {
130
130
  name: string;
131
131
  args?: Record<string, unknown>;
132
132
  push_notify?: boolean;
133
+ /** Override per-cronjob V8 heap limit (MB). Valid range 1–2046. */
134
+ max_heap_size_mb?: number;
133
135
  }
134
136
  interface Cronjob {
135
137
  id: number;
@@ -139,6 +141,8 @@ interface Cronjob {
139
141
  status: string;
140
142
  args: Record<string, unknown>;
141
143
  push_notify: boolean;
144
+ /** Per-cronjob V8 heap cap (MB). null when using the server default. */
145
+ max_heap_size_mb: number | null;
142
146
  created_at: string;
143
147
  updated_at: string;
144
148
  }
@@ -156,6 +160,8 @@ interface CronjobUpdateRequest {
156
160
  cron_expression?: string;
157
161
  args?: Record<string, unknown>;
158
162
  push_notify?: boolean;
163
+ /** Override per-cronjob V8 heap limit (MB). Valid range 1–2046. */
164
+ max_heap_size_mb?: number;
159
165
  }
160
166
  interface CronjobRunsListParams {
161
167
  cronjob_id: number;
@@ -1232,6 +1238,13 @@ type UdfDescriptor = {
1232
1238
  name: string;
1233
1239
  params_schema: unknown | null;
1234
1240
  };
1241
+ type UdfInvokeResponse<TResult = unknown> = {
1242
+ result: TResult;
1243
+ logs?: unknown;
1244
+ credits_used_total?: number;
1245
+ credits_charged_owner?: number;
1246
+ credits_charged_consumer?: number;
1247
+ };
1235
1248
  type UdfButtonOptions = {
1236
1249
  functionName: string;
1237
1250
  params?: unknown;
@@ -1245,9 +1258,10 @@ type UdfButtonEventDetail<TResult = unknown> = {
1245
1258
  error?: unknown;
1246
1259
  };
1247
1260
  type UdfApi = {
1248
- call: <TResult = unknown>(functionName: string, params: unknown) => Promise<TResult>;
1261
+ call: <TResult = unknown>(functionName: string, params: unknown) => Promise<UdfInvokeResponse<TResult>>;
1249
1262
  list: () => Promise<UdfDescriptor[]>;
1250
1263
  getViewerToken: () => string | null;
1264
+ isAuthenticated: () => boolean;
1251
1265
  renderButton: (target: HTMLElement | string, options: UdfButtonOptions) => HTMLButtonElement;
1252
1266
  UdfError: typeof UdfError;
1253
1267
  UdfAuthRequiredError: typeof UdfAuthRequiredError;
@@ -1314,6 +1328,7 @@ declare class UdfTransportError extends UdfError {
1314
1328
  declare const PBSV_UPDATE_MESSAGE = "alva:pbsv:update";
1315
1329
  declare const UDF_CONSENT_REQUEST_MESSAGE = "alva:udf:consent-request";
1316
1330
  declare const UDF_CONSENT_RESPONSE_MESSAGE = "alva:udf:consent-response";
1331
+ declare const UDF_AUTH_REQUIRED_MESSAGE = "alva:udf:auth-required";
1317
1332
  declare const playbookIdFromToken: (token: string | null) => string | null;
1318
1333
  declare const getViewerToken: () => string | null;
1319
1334
  declare const mapUdfErrorResponse: (body: UdfErrorBody, status?: number) => UdfError;
@@ -1323,4 +1338,4 @@ declare const installPlaybookRuntime: (targetWindow?: Window) => void;
1323
1338
  /** SDK version, injected at build time from package.json. */
1324
1339
  declare const VERSION: string;
1325
1340
 
1326
- export { AlvaClient, type AlvaClientConfig, AlvaError, type ChannelGroupAdminInfo, type ChannelGroupCallerInfo, type ChannelGroupSubscription, type ChannelGroupSubscriptionContextResponse, type ChannelGroupSubscriptionListResponse, type ChannelGroupSubscriptionMutationParams, type ChannelGroupSubscriptionMutationResponse, type ChannelGroupSubscriptionSessionParams, type ChannelGroupSubscriptionTarget, type ChannelGroupSubscriptionTargetType, type FeedDeleteRequest, type FeedDeleteResponse, type FsChmodParams, type FsCopyParams, type FsEntry, type FsGrantParams, type FsMkdirParams, type FsRawWriteParams, type FsReadParams, type FsReaddirParams, type FsReaddirResponse, type FsReadlinkParams, type FsRemoveParams, type FsRenameParams, type FsRevokeParams, type FsStat, type FsSymlinkParams, type FsWriteParams, type FsWriteResponse, type NotificationPreference, type NotificationPreferenceKey, type NotificationPreferenceUpdateParams, type NotificationPreferenceUpdateResponse, type NotificationPreferencesResponse, PBSV_UPDATE_MESSAGE, type SkillDoc, type SkillEndpointMetadata, type SkillEndpointTier, type SkillMetadata, type SkillSummary, type TrendingPlaybookItem, type TrendingPlaybooksDir, type TrendingPlaybooksParams, type TrendingPlaybooksResponse, type TrendingPlaybooksSort, UDF_CONSENT_REQUEST_MESSAGE, UDF_CONSENT_RESPONSE_MESSAGE, type UdfApi, UdfAuthRequiredError, type UdfButtonEventDetail, type UdfButtonOptions, UdfConsentDeniedError, UdfConsentRequiredError, UdfConsentTimeoutError, type UdfDescriptor, UdfError, UdfExecutionError, UdfFunctionDisabledError, UdfFunctionNotFoundError, UdfInsufficientCredits, UdfPidMismatchError, UdfRateLimitedError, UdfTokenExpiredError, UdfTokenInvalidError, UdfTransportError, VERSION, getViewerToken, installPlaybookRuntime, mapUdfErrorResponse, playbookIdFromToken, udf };
1341
+ export { AlvaClient, type AlvaClientConfig, AlvaError, type ChannelGroupAdminInfo, type ChannelGroupCallerInfo, type ChannelGroupSubscription, type ChannelGroupSubscriptionContextResponse, type ChannelGroupSubscriptionListResponse, type ChannelGroupSubscriptionMutationParams, type ChannelGroupSubscriptionMutationResponse, type ChannelGroupSubscriptionSessionParams, type ChannelGroupSubscriptionTarget, type ChannelGroupSubscriptionTargetType, type FeedDeleteRequest, type FeedDeleteResponse, type FsChmodParams, type FsCopyParams, type FsEntry, type FsGrantParams, type FsMkdirParams, type FsRawWriteParams, type FsReadParams, type FsReaddirParams, type FsReaddirResponse, type FsReadlinkParams, type FsRemoveParams, type FsRenameParams, type FsRevokeParams, type FsStat, type FsSymlinkParams, type FsWriteParams, type FsWriteResponse, type NotificationPreference, type NotificationPreferenceKey, type NotificationPreferenceUpdateParams, type NotificationPreferenceUpdateResponse, type NotificationPreferencesResponse, PBSV_UPDATE_MESSAGE, type SkillDoc, type SkillEndpointMetadata, type SkillEndpointTier, type SkillMetadata, type SkillSummary, type TrendingPlaybookItem, type TrendingPlaybooksDir, type TrendingPlaybooksParams, type TrendingPlaybooksResponse, type TrendingPlaybooksSort, UDF_AUTH_REQUIRED_MESSAGE, UDF_CONSENT_REQUEST_MESSAGE, UDF_CONSENT_RESPONSE_MESSAGE, type UdfApi, UdfAuthRequiredError, type UdfButtonEventDetail, type UdfButtonOptions, UdfConsentDeniedError, UdfConsentRequiredError, UdfConsentTimeoutError, type UdfDescriptor, UdfError, UdfExecutionError, UdfFunctionDisabledError, UdfFunctionNotFoundError, UdfInsufficientCredits, type UdfInvokeResponse, UdfPidMismatchError, UdfRateLimitedError, UdfTokenExpiredError, UdfTokenInvalidError, UdfTransportError, VERSION, getViewerToken, installPlaybookRuntime, mapUdfErrorResponse, playbookIdFromToken, udf };
package/dist/index.js CHANGED
@@ -168,7 +168,8 @@ var DeployResource = class {
168
168
  path: params.path,
169
169
  cron_expression: params.cron_expression,
170
170
  args: params.args,
171
- push_notify: params.push_notify
171
+ push_notify: params.push_notify,
172
+ max_heap_size_mb: params.max_heap_size_mb
172
173
  }
173
174
  });
174
175
  }
@@ -2383,6 +2384,7 @@ var UdfTransportError = class extends UdfError {
2383
2384
  var PBSV_UPDATE_MESSAGE = "alva:pbsv:update";
2384
2385
  var UDF_CONSENT_REQUEST_MESSAGE = "alva:udf:consent-request";
2385
2386
  var UDF_CONSENT_RESPONSE_MESSAGE = "alva:udf:consent-response";
2387
+ var UDF_AUTH_REQUIRED_MESSAGE = "alva:udf:auth-required";
2386
2388
  var DEFAULT_API_ORIGIN = "https://api-llm.prd.alva.ai";
2387
2389
  var CONSENT_TIMEOUT_MS = 5 * 60 * 1e3;
2388
2390
  var cachedToken = null;
@@ -2411,6 +2413,7 @@ var playbookIdFromToken = (token) => {
2411
2413
  return null;
2412
2414
  };
2413
2415
  var getViewerToken = () => cachedToken;
2416
+ var isAuthenticated = () => !!getViewerToken();
2414
2417
  var stripPbsvFromUrl = (targetWindow) => {
2415
2418
  const url = new URL(targetWindow.location.href);
2416
2419
  url.searchParams.delete("_pbsv");
@@ -2438,6 +2441,21 @@ var safeJson = async (response) => {
2438
2441
  return {};
2439
2442
  }
2440
2443
  };
2444
+ var parseResultPayload = (result) => {
2445
+ if (typeof result !== "string") return result;
2446
+ try {
2447
+ return JSON.parse(result);
2448
+ } catch {
2449
+ return result;
2450
+ }
2451
+ };
2452
+ var normalizeInvokeResponse = (body) => {
2453
+ const envelope = body;
2454
+ return {
2455
+ ...envelope,
2456
+ result: parseResultPayload(envelope.result)
2457
+ };
2458
+ };
2441
2459
  var errorMetadata = (body) => body.error?.metadata || body.details?.metadata || {};
2442
2460
  var mapUdfErrorResponse = (body, status) => {
2443
2461
  const code = body.error?.code || "TRANSPORT";
@@ -2519,6 +2537,16 @@ var requestConsent = async (playbookId, minAllowance) => {
2519
2537
  );
2520
2538
  });
2521
2539
  };
2540
+ var requestAuthentication = (functionName) => {
2541
+ if (!runtimeWindow || !expectedParentOrigin) return;
2542
+ runtimeWindow.parent.postMessage(
2543
+ {
2544
+ type: UDF_AUTH_REQUIRED_MESSAGE,
2545
+ function_name: functionName
2546
+ },
2547
+ expectedParentOrigin
2548
+ );
2549
+ };
2522
2550
  var call = async (functionName, params, retried = false) => {
2523
2551
  const token = getViewerToken();
2524
2552
  if (!token) throw new UdfAuthRequiredError();
@@ -2555,7 +2583,7 @@ var call = async (functionName, params, retried = false) => {
2555
2583
  }
2556
2584
  const body = await safeJson(response);
2557
2585
  if (response.ok) {
2558
- return body.result;
2586
+ return normalizeInvokeResponse(body);
2559
2587
  }
2560
2588
  if (body.error?.code === "CONSENT_REQUIRED" && !retried) {
2561
2589
  const metadata = errorMetadata(body);
@@ -2610,11 +2638,15 @@ var renderButton = (target, options) => {
2610
2638
  const disabledLabel = options.disabledLabel || "Sign in to run";
2611
2639
  button.type = "button";
2612
2640
  button.className = "alva-udf-button";
2613
- button.textContent = getViewerToken() ? label : disabledLabel;
2614
- button.disabled = !getViewerToken();
2641
+ button.textContent = isAuthenticated() ? label : disabledLabel;
2642
+ button.disabled = false;
2615
2643
  button.setAttribute("data-function-name", options.functionName);
2616
- if (button.disabled) button.setAttribute("aria-disabled", "true");
2644
+ if (!isAuthenticated()) button.setAttribute("aria-disabled", "true");
2617
2645
  button.addEventListener("click", async () => {
2646
+ if (!isAuthenticated()) {
2647
+ requestAuthentication(options.functionName);
2648
+ return;
2649
+ }
2618
2650
  if (button.disabled) return;
2619
2651
  button.disabled = true;
2620
2652
  button.textContent = loadingLabel;
@@ -2633,8 +2665,9 @@ var renderButton = (target, options) => {
2633
2665
  error
2634
2666
  });
2635
2667
  } finally {
2636
- button.disabled = !getViewerToken();
2637
- button.textContent = button.disabled ? disabledLabel : label;
2668
+ button.disabled = false;
2669
+ button.textContent = isAuthenticated() ? label : disabledLabel;
2670
+ if (!isAuthenticated()) button.setAttribute("aria-disabled", "true");
2638
2671
  }
2639
2672
  });
2640
2673
  container.appendChild(button);
@@ -2644,6 +2677,7 @@ var udf = {
2644
2677
  call,
2645
2678
  list,
2646
2679
  getViewerToken,
2680
+ isAuthenticated,
2647
2681
  renderButton,
2648
2682
  UdfError,
2649
2683
  UdfAuthRequiredError,
@@ -2676,11 +2710,12 @@ var installPlaybookRuntime = (targetWindow) => {
2676
2710
  };
2677
2711
 
2678
2712
  // src/index.ts
2679
- var VERSION = true ? "0.9.3" : "dev";
2713
+ var VERSION = true ? "0.9.4" : "dev";
2680
2714
  export {
2681
2715
  AlvaClient,
2682
2716
  AlvaError,
2683
2717
  PBSV_UPDATE_MESSAGE,
2718
+ UDF_AUTH_REQUIRED_MESSAGE,
2684
2719
  UDF_CONSENT_REQUEST_MESSAGE,
2685
2720
  UDF_CONSENT_RESPONSE_MESSAGE,
2686
2721
  UdfAuthRequiredError,