@alva-ai/toolkit 0.9.3 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/cli.js +85 -11
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +73 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +39 -2
- package/dist/index.d.ts +39 -2
- package/dist/index.js +72 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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;
|
|
@@ -779,6 +785,18 @@ declare class FeedResource {
|
|
|
779
785
|
delete(params: FeedDeleteRequest): Promise<FeedDeleteResponse>;
|
|
780
786
|
}
|
|
781
787
|
|
|
788
|
+
/** Playbook visibility states understood by the gateway. */
|
|
789
|
+
type PlaybookVisibility = 'public' | 'private' | 'paid';
|
|
790
|
+
interface SetVisibilityParams {
|
|
791
|
+
/** URL-safe playbook name. The owner is derived server-side from auth. */
|
|
792
|
+
name: string;
|
|
793
|
+
/** Target visibility: public, private, or paid. */
|
|
794
|
+
visibility: PlaybookVisibility;
|
|
795
|
+
}
|
|
796
|
+
interface SetVisibilityResponse {
|
|
797
|
+
/** ALFS-style "<owner>/<name>" path echoed back by the gateway. */
|
|
798
|
+
playbook_path: string;
|
|
799
|
+
}
|
|
782
800
|
type TrendingPlaybooksSort = 'FOLLOWS' | 'RECENT';
|
|
783
801
|
type TrendingPlaybooksDir = 'FORWARD' | 'BACKWARD';
|
|
784
802
|
interface TrendingPlaybooksParams {
|
|
@@ -836,6 +854,16 @@ declare class PlaybooksResource {
|
|
|
836
854
|
* it into a smaller, agent-friendly shape.
|
|
837
855
|
*/
|
|
838
856
|
trending(params?: TrendingPlaybooksParams): Promise<TrendingPlaybooksResponse>;
|
|
857
|
+
/**
|
|
858
|
+
* Set a playbook's visibility. Requires authentication; the owner is
|
|
859
|
+
* resolved server-side from the authenticated user, so only the playbook
|
|
860
|
+
* `name` is needed.
|
|
861
|
+
*
|
|
862
|
+
* Note: `private` and `paid` are paid-tier capabilities. A free-tier user
|
|
863
|
+
* receives a `PERMISSION_DENIED` error from the gateway, which is surfaced
|
|
864
|
+
* here unchanged.
|
|
865
|
+
*/
|
|
866
|
+
setVisibility(params: SetVisibilityParams): Promise<SetVisibilityResponse>;
|
|
839
867
|
}
|
|
840
868
|
|
|
841
869
|
declare class SecretsResource {
|
|
@@ -1232,6 +1260,13 @@ type UdfDescriptor = {
|
|
|
1232
1260
|
name: string;
|
|
1233
1261
|
params_schema: unknown | null;
|
|
1234
1262
|
};
|
|
1263
|
+
type UdfInvokeResponse<TResult = unknown> = {
|
|
1264
|
+
result: TResult;
|
|
1265
|
+
logs?: unknown;
|
|
1266
|
+
credits_used_total?: number;
|
|
1267
|
+
credits_charged_owner?: number;
|
|
1268
|
+
credits_charged_consumer?: number;
|
|
1269
|
+
};
|
|
1235
1270
|
type UdfButtonOptions = {
|
|
1236
1271
|
functionName: string;
|
|
1237
1272
|
params?: unknown;
|
|
@@ -1245,9 +1280,10 @@ type UdfButtonEventDetail<TResult = unknown> = {
|
|
|
1245
1280
|
error?: unknown;
|
|
1246
1281
|
};
|
|
1247
1282
|
type UdfApi = {
|
|
1248
|
-
call: <TResult = unknown>(functionName: string, params: unknown) => Promise<TResult
|
|
1283
|
+
call: <TResult = unknown>(functionName: string, params: unknown) => Promise<UdfInvokeResponse<TResult>>;
|
|
1249
1284
|
list: () => Promise<UdfDescriptor[]>;
|
|
1250
1285
|
getViewerToken: () => string | null;
|
|
1286
|
+
isAuthenticated: () => boolean;
|
|
1251
1287
|
renderButton: (target: HTMLElement | string, options: UdfButtonOptions) => HTMLButtonElement;
|
|
1252
1288
|
UdfError: typeof UdfError;
|
|
1253
1289
|
UdfAuthRequiredError: typeof UdfAuthRequiredError;
|
|
@@ -1314,6 +1350,7 @@ declare class UdfTransportError extends UdfError {
|
|
|
1314
1350
|
declare const PBSV_UPDATE_MESSAGE = "alva:pbsv:update";
|
|
1315
1351
|
declare const UDF_CONSENT_REQUEST_MESSAGE = "alva:udf:consent-request";
|
|
1316
1352
|
declare const UDF_CONSENT_RESPONSE_MESSAGE = "alva:udf:consent-response";
|
|
1353
|
+
declare const UDF_AUTH_REQUIRED_MESSAGE = "alva:udf:auth-required";
|
|
1317
1354
|
declare const playbookIdFromToken: (token: string | null) => string | null;
|
|
1318
1355
|
declare const getViewerToken: () => string | null;
|
|
1319
1356
|
declare const mapUdfErrorResponse: (body: UdfErrorBody, status?: number) => UdfError;
|
|
@@ -1323,4 +1360,4 @@ declare const installPlaybookRuntime: (targetWindow?: Window) => void;
|
|
|
1323
1360
|
/** SDK version, injected at build time from package.json. */
|
|
1324
1361
|
declare const VERSION: string;
|
|
1325
1362
|
|
|
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 };
|
|
1363
|
+
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;
|
|
@@ -779,6 +785,18 @@ declare class FeedResource {
|
|
|
779
785
|
delete(params: FeedDeleteRequest): Promise<FeedDeleteResponse>;
|
|
780
786
|
}
|
|
781
787
|
|
|
788
|
+
/** Playbook visibility states understood by the gateway. */
|
|
789
|
+
type PlaybookVisibility = 'public' | 'private' | 'paid';
|
|
790
|
+
interface SetVisibilityParams {
|
|
791
|
+
/** URL-safe playbook name. The owner is derived server-side from auth. */
|
|
792
|
+
name: string;
|
|
793
|
+
/** Target visibility: public, private, or paid. */
|
|
794
|
+
visibility: PlaybookVisibility;
|
|
795
|
+
}
|
|
796
|
+
interface SetVisibilityResponse {
|
|
797
|
+
/** ALFS-style "<owner>/<name>" path echoed back by the gateway. */
|
|
798
|
+
playbook_path: string;
|
|
799
|
+
}
|
|
782
800
|
type TrendingPlaybooksSort = 'FOLLOWS' | 'RECENT';
|
|
783
801
|
type TrendingPlaybooksDir = 'FORWARD' | 'BACKWARD';
|
|
784
802
|
interface TrendingPlaybooksParams {
|
|
@@ -836,6 +854,16 @@ declare class PlaybooksResource {
|
|
|
836
854
|
* it into a smaller, agent-friendly shape.
|
|
837
855
|
*/
|
|
838
856
|
trending(params?: TrendingPlaybooksParams): Promise<TrendingPlaybooksResponse>;
|
|
857
|
+
/**
|
|
858
|
+
* Set a playbook's visibility. Requires authentication; the owner is
|
|
859
|
+
* resolved server-side from the authenticated user, so only the playbook
|
|
860
|
+
* `name` is needed.
|
|
861
|
+
*
|
|
862
|
+
* Note: `private` and `paid` are paid-tier capabilities. A free-tier user
|
|
863
|
+
* receives a `PERMISSION_DENIED` error from the gateway, which is surfaced
|
|
864
|
+
* here unchanged.
|
|
865
|
+
*/
|
|
866
|
+
setVisibility(params: SetVisibilityParams): Promise<SetVisibilityResponse>;
|
|
839
867
|
}
|
|
840
868
|
|
|
841
869
|
declare class SecretsResource {
|
|
@@ -1232,6 +1260,13 @@ type UdfDescriptor = {
|
|
|
1232
1260
|
name: string;
|
|
1233
1261
|
params_schema: unknown | null;
|
|
1234
1262
|
};
|
|
1263
|
+
type UdfInvokeResponse<TResult = unknown> = {
|
|
1264
|
+
result: TResult;
|
|
1265
|
+
logs?: unknown;
|
|
1266
|
+
credits_used_total?: number;
|
|
1267
|
+
credits_charged_owner?: number;
|
|
1268
|
+
credits_charged_consumer?: number;
|
|
1269
|
+
};
|
|
1235
1270
|
type UdfButtonOptions = {
|
|
1236
1271
|
functionName: string;
|
|
1237
1272
|
params?: unknown;
|
|
@@ -1245,9 +1280,10 @@ type UdfButtonEventDetail<TResult = unknown> = {
|
|
|
1245
1280
|
error?: unknown;
|
|
1246
1281
|
};
|
|
1247
1282
|
type UdfApi = {
|
|
1248
|
-
call: <TResult = unknown>(functionName: string, params: unknown) => Promise<TResult
|
|
1283
|
+
call: <TResult = unknown>(functionName: string, params: unknown) => Promise<UdfInvokeResponse<TResult>>;
|
|
1249
1284
|
list: () => Promise<UdfDescriptor[]>;
|
|
1250
1285
|
getViewerToken: () => string | null;
|
|
1286
|
+
isAuthenticated: () => boolean;
|
|
1251
1287
|
renderButton: (target: HTMLElement | string, options: UdfButtonOptions) => HTMLButtonElement;
|
|
1252
1288
|
UdfError: typeof UdfError;
|
|
1253
1289
|
UdfAuthRequiredError: typeof UdfAuthRequiredError;
|
|
@@ -1314,6 +1350,7 @@ declare class UdfTransportError extends UdfError {
|
|
|
1314
1350
|
declare const PBSV_UPDATE_MESSAGE = "alva:pbsv:update";
|
|
1315
1351
|
declare const UDF_CONSENT_REQUEST_MESSAGE = "alva:udf:consent-request";
|
|
1316
1352
|
declare const UDF_CONSENT_RESPONSE_MESSAGE = "alva:udf:consent-response";
|
|
1353
|
+
declare const UDF_AUTH_REQUIRED_MESSAGE = "alva:udf:auth-required";
|
|
1317
1354
|
declare const playbookIdFromToken: (token: string | null) => string | null;
|
|
1318
1355
|
declare const getViewerToken: () => string | null;
|
|
1319
1356
|
declare const mapUdfErrorResponse: (body: UdfErrorBody, status?: number) => UdfError;
|
|
@@ -1323,4 +1360,4 @@ declare const installPlaybookRuntime: (targetWindow?: Window) => void;
|
|
|
1323
1360
|
/** SDK version, injected at build time from package.json. */
|
|
1324
1361
|
declare const VERSION: string;
|
|
1325
1362
|
|
|
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 };
|
|
1363
|
+
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
|
}
|
|
@@ -322,6 +323,11 @@ var FeedResource = class {
|
|
|
322
323
|
};
|
|
323
324
|
|
|
324
325
|
// src/resources/playbooks.ts
|
|
326
|
+
var PLAYBOOK_VISIBILITIES = [
|
|
327
|
+
"public",
|
|
328
|
+
"private",
|
|
329
|
+
"paid"
|
|
330
|
+
];
|
|
325
331
|
var PlaybooksResource = class {
|
|
326
332
|
constructor(client) {
|
|
327
333
|
this.client = client;
|
|
@@ -355,6 +361,30 @@ var PlaybooksResource = class {
|
|
|
355
361
|
has_next: raw.has_next ?? false
|
|
356
362
|
};
|
|
357
363
|
}
|
|
364
|
+
/**
|
|
365
|
+
* Set a playbook's visibility. Requires authentication; the owner is
|
|
366
|
+
* resolved server-side from the authenticated user, so only the playbook
|
|
367
|
+
* `name` is needed.
|
|
368
|
+
*
|
|
369
|
+
* Note: `private` and `paid` are paid-tier capabilities. A free-tier user
|
|
370
|
+
* receives a `PERMISSION_DENIED` error from the gateway, which is surfaced
|
|
371
|
+
* here unchanged.
|
|
372
|
+
*/
|
|
373
|
+
async setVisibility(params) {
|
|
374
|
+
if (!PLAYBOOK_VISIBILITIES.includes(params.visibility)) {
|
|
375
|
+
throw new AlvaError(
|
|
376
|
+
"INVALID_ARGUMENT",
|
|
377
|
+
`Invalid visibility "${params.visibility}". Expected one of: ${PLAYBOOK_VISIBILITIES.join(", ")}.`,
|
|
378
|
+
400
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
this.client._requireAuth();
|
|
382
|
+
return await this.client._request(
|
|
383
|
+
"POST",
|
|
384
|
+
`/api/v1/playbook/${encodeURIComponent(params.name)}/visibility`,
|
|
385
|
+
{ body: { visibility: params.visibility } }
|
|
386
|
+
);
|
|
387
|
+
}
|
|
358
388
|
};
|
|
359
389
|
function toAgentPlaybook(raw) {
|
|
360
390
|
const username = raw.creator?.name ?? "";
|
|
@@ -2383,6 +2413,7 @@ var UdfTransportError = class extends UdfError {
|
|
|
2383
2413
|
var PBSV_UPDATE_MESSAGE = "alva:pbsv:update";
|
|
2384
2414
|
var UDF_CONSENT_REQUEST_MESSAGE = "alva:udf:consent-request";
|
|
2385
2415
|
var UDF_CONSENT_RESPONSE_MESSAGE = "alva:udf:consent-response";
|
|
2416
|
+
var UDF_AUTH_REQUIRED_MESSAGE = "alva:udf:auth-required";
|
|
2386
2417
|
var DEFAULT_API_ORIGIN = "https://api-llm.prd.alva.ai";
|
|
2387
2418
|
var CONSENT_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
2388
2419
|
var cachedToken = null;
|
|
@@ -2411,6 +2442,7 @@ var playbookIdFromToken = (token) => {
|
|
|
2411
2442
|
return null;
|
|
2412
2443
|
};
|
|
2413
2444
|
var getViewerToken = () => cachedToken;
|
|
2445
|
+
var isAuthenticated = () => !!getViewerToken();
|
|
2414
2446
|
var stripPbsvFromUrl = (targetWindow) => {
|
|
2415
2447
|
const url = new URL(targetWindow.location.href);
|
|
2416
2448
|
url.searchParams.delete("_pbsv");
|
|
@@ -2438,6 +2470,21 @@ var safeJson = async (response) => {
|
|
|
2438
2470
|
return {};
|
|
2439
2471
|
}
|
|
2440
2472
|
};
|
|
2473
|
+
var parseResultPayload = (result) => {
|
|
2474
|
+
if (typeof result !== "string") return result;
|
|
2475
|
+
try {
|
|
2476
|
+
return JSON.parse(result);
|
|
2477
|
+
} catch {
|
|
2478
|
+
return result;
|
|
2479
|
+
}
|
|
2480
|
+
};
|
|
2481
|
+
var normalizeInvokeResponse = (body) => {
|
|
2482
|
+
const envelope = body;
|
|
2483
|
+
return {
|
|
2484
|
+
...envelope,
|
|
2485
|
+
result: parseResultPayload(envelope.result)
|
|
2486
|
+
};
|
|
2487
|
+
};
|
|
2441
2488
|
var errorMetadata = (body) => body.error?.metadata || body.details?.metadata || {};
|
|
2442
2489
|
var mapUdfErrorResponse = (body, status) => {
|
|
2443
2490
|
const code = body.error?.code || "TRANSPORT";
|
|
@@ -2519,6 +2566,16 @@ var requestConsent = async (playbookId, minAllowance) => {
|
|
|
2519
2566
|
);
|
|
2520
2567
|
});
|
|
2521
2568
|
};
|
|
2569
|
+
var requestAuthentication = (functionName) => {
|
|
2570
|
+
if (!runtimeWindow || !expectedParentOrigin) return;
|
|
2571
|
+
runtimeWindow.parent.postMessage(
|
|
2572
|
+
{
|
|
2573
|
+
type: UDF_AUTH_REQUIRED_MESSAGE,
|
|
2574
|
+
function_name: functionName
|
|
2575
|
+
},
|
|
2576
|
+
expectedParentOrigin
|
|
2577
|
+
);
|
|
2578
|
+
};
|
|
2522
2579
|
var call = async (functionName, params, retried = false) => {
|
|
2523
2580
|
const token = getViewerToken();
|
|
2524
2581
|
if (!token) throw new UdfAuthRequiredError();
|
|
@@ -2555,7 +2612,7 @@ var call = async (functionName, params, retried = false) => {
|
|
|
2555
2612
|
}
|
|
2556
2613
|
const body = await safeJson(response);
|
|
2557
2614
|
if (response.ok) {
|
|
2558
|
-
return body
|
|
2615
|
+
return normalizeInvokeResponse(body);
|
|
2559
2616
|
}
|
|
2560
2617
|
if (body.error?.code === "CONSENT_REQUIRED" && !retried) {
|
|
2561
2618
|
const metadata = errorMetadata(body);
|
|
@@ -2610,11 +2667,15 @@ var renderButton = (target, options) => {
|
|
|
2610
2667
|
const disabledLabel = options.disabledLabel || "Sign in to run";
|
|
2611
2668
|
button.type = "button";
|
|
2612
2669
|
button.className = "alva-udf-button";
|
|
2613
|
-
button.textContent =
|
|
2614
|
-
button.disabled =
|
|
2670
|
+
button.textContent = isAuthenticated() ? label : disabledLabel;
|
|
2671
|
+
button.disabled = false;
|
|
2615
2672
|
button.setAttribute("data-function-name", options.functionName);
|
|
2616
|
-
if (
|
|
2673
|
+
if (!isAuthenticated()) button.setAttribute("aria-disabled", "true");
|
|
2617
2674
|
button.addEventListener("click", async () => {
|
|
2675
|
+
if (!isAuthenticated()) {
|
|
2676
|
+
requestAuthentication(options.functionName);
|
|
2677
|
+
return;
|
|
2678
|
+
}
|
|
2618
2679
|
if (button.disabled) return;
|
|
2619
2680
|
button.disabled = true;
|
|
2620
2681
|
button.textContent = loadingLabel;
|
|
@@ -2633,8 +2694,9 @@ var renderButton = (target, options) => {
|
|
|
2633
2694
|
error
|
|
2634
2695
|
});
|
|
2635
2696
|
} finally {
|
|
2636
|
-
button.disabled =
|
|
2637
|
-
button.textContent =
|
|
2697
|
+
button.disabled = false;
|
|
2698
|
+
button.textContent = isAuthenticated() ? label : disabledLabel;
|
|
2699
|
+
if (!isAuthenticated()) button.setAttribute("aria-disabled", "true");
|
|
2638
2700
|
}
|
|
2639
2701
|
});
|
|
2640
2702
|
container.appendChild(button);
|
|
@@ -2644,6 +2706,7 @@ var udf = {
|
|
|
2644
2706
|
call,
|
|
2645
2707
|
list,
|
|
2646
2708
|
getViewerToken,
|
|
2709
|
+
isAuthenticated,
|
|
2647
2710
|
renderButton,
|
|
2648
2711
|
UdfError,
|
|
2649
2712
|
UdfAuthRequiredError,
|
|
@@ -2676,11 +2739,12 @@ var installPlaybookRuntime = (targetWindow) => {
|
|
|
2676
2739
|
};
|
|
2677
2740
|
|
|
2678
2741
|
// src/index.ts
|
|
2679
|
-
var VERSION = true ? "0.9.
|
|
2742
|
+
var VERSION = true ? "0.9.5" : "dev";
|
|
2680
2743
|
export {
|
|
2681
2744
|
AlvaClient,
|
|
2682
2745
|
AlvaError,
|
|
2683
2746
|
PBSV_UPDATE_MESSAGE,
|
|
2747
|
+
UDF_AUTH_REQUIRED_MESSAGE,
|
|
2684
2748
|
UDF_CONSENT_REQUEST_MESSAGE,
|
|
2685
2749
|
UDF_CONSENT_RESPONSE_MESSAGE,
|
|
2686
2750
|
UdfAuthRequiredError,
|