@alva-ai/toolkit 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -21,6 +21,52 @@ interface UserProfile {
21
21
  /** Caller's alfs home directory, e.g. `/alva/home/<username>`. */
22
22
  home_path: string;
23
23
  }
24
+ interface CreditWallet {
25
+ balance: number;
26
+ totalRemaining: number;
27
+ todayUsed: number;
28
+ }
29
+ interface CreditWalletItemsParams {
30
+ /** Inclusive UTC lower bound, Unix milliseconds. */
31
+ startAtMs: number;
32
+ /** Exclusive UTC upper bound, Unix milliseconds. */
33
+ endAtMs: number;
34
+ /** Optional chat/session id to filter consumption records. */
35
+ sessionId?: string;
36
+ /** Page size, defaulted and capped by the gateway. */
37
+ first?: number;
38
+ /** Opaque cursor from a previous page's `pageInfo.endCursor`. */
39
+ after?: string;
40
+ }
41
+ interface CreditWalletItem {
42
+ id: string;
43
+ sessionId: string | null;
44
+ playbookId: string | null;
45
+ feedId: string | null;
46
+ op: string;
47
+ source: string;
48
+ amount: number;
49
+ extras?: unknown;
50
+ /** Creation timestamp, Unix milliseconds. */
51
+ createdAtMs: number;
52
+ }
53
+ interface CreditWalletPageInfo {
54
+ hasNextPage: boolean;
55
+ hasPreviousPage: boolean;
56
+ startCursor: string | null;
57
+ endCursor: string | null;
58
+ }
59
+ interface CreditWalletItemEdge {
60
+ cursor: string;
61
+ node: CreditWalletItem;
62
+ }
63
+ interface CreditWalletItemConnection {
64
+ pageInfo: CreditWalletPageInfo;
65
+ edges: CreditWalletItemEdge[];
66
+ }
67
+ interface CreditWalletItemsResponse extends CreditWallet {
68
+ items: CreditWalletItemConnection;
69
+ }
24
70
  type SubscriptionTier = 'SUBSCRIPTION_TIER_UNSPECIFIED' | 'SUBSCRIPTION_TIER_FREE' | 'SUBSCRIPTION_TIER_PRO';
25
71
  interface EnsureArraysJwtResponse {
26
72
  expires_at: number;
@@ -226,6 +272,12 @@ interface FeedReleaseRequest {
226
272
  view_json?: Record<string, unknown>;
227
273
  description?: string;
228
274
  changelog?: string;
275
+ /**
276
+ * Agent kind that produces this feed (e.g. "alpi"). Optional. Marks the feed
277
+ * as an agent feed whose prompt is editable; an empty/omitted value means a
278
+ * regular (non-agent) feed. The backend validates it against its catalog.
279
+ */
280
+ agent_type?: string;
229
281
  }
230
282
  interface FeedReleaseResponse {
231
283
  feed_id: number;
@@ -953,8 +1005,10 @@ interface TrendingPlaybookItem {
953
1005
  description: string;
954
1006
  tags: string[];
955
1007
  follow_count: number;
956
- /** Relative web path for opening or citing the playbook. */
1008
+ /** Relative web path for opening or citing the playbook, e.g. `/u/alice/playbooks/btc`. */
957
1009
  url_path: string;
1010
+ /** Absolute, clickable web URL, e.g. `https://alva.ai/u/alice/playbooks/btc`. */
1011
+ url: string;
958
1012
  /** README ALFS path when available. */
959
1013
  readme?: string;
960
1014
  /** Cursor to pass as `cursor` / `current` for pagination. */
@@ -1473,6 +1527,14 @@ declare class FunctionsResource {
1473
1527
  revokeAllowance(params: RevokeAllowanceParams): Promise<RevokeAllowanceResponse>;
1474
1528
  }
1475
1529
 
1530
+ declare class CreditsResource {
1531
+ private client;
1532
+ constructor(client: AlvaClient);
1533
+ wallet(): Promise<CreditWallet>;
1534
+ items(params: CreditWalletItemsParams): Promise<CreditWalletItemsResponse>;
1535
+ private graphql;
1536
+ }
1537
+
1476
1538
  interface RequestOptions {
1477
1539
  query?: Record<string, unknown>;
1478
1540
  body?: unknown;
@@ -1531,6 +1593,7 @@ declare class AlvaClient {
1531
1593
  private _channelGroupSubscriptions?;
1532
1594
  private _feedback?;
1533
1595
  private _functions?;
1596
+ private _credits?;
1534
1597
  constructor(config: AlvaClientConfig);
1535
1598
  get fs(): FsResource;
1536
1599
  get run(): RunResource;
@@ -1555,6 +1618,7 @@ declare class AlvaClient {
1555
1618
  get channelGroupSubscriptions(): ChannelGroupSubscriptionsResource;
1556
1619
  get feedback(): FeedbackResource;
1557
1620
  get functions(): FunctionsResource;
1621
+ get credits(): CreditsResource;
1558
1622
  _requireAuth(): void;
1559
1623
  _request(method: string, path: string, options?: RequestOptions): Promise<unknown>;
1560
1624
  }
@@ -1565,6 +1629,10 @@ declare class AlvaError extends Error {
1565
1629
  readonly details?: unknown;
1566
1630
  constructor(code: string, message: string, status: number, details?: unknown);
1567
1631
  }
1632
+ declare class CliUsageError extends Error {
1633
+ readonly command?: string;
1634
+ constructor(message: string, command?: string);
1635
+ }
1568
1636
 
1569
1637
  type UdfErrorCode = 'PBSV_EXPIRED' | 'PBSV_INVALID' | 'PBSV_PID_MISMATCH' | 'CONSENT_REQUIRED' | 'INSUFFICIENT_CREDITS' | 'FUNCTION_NOT_FOUND' | 'FUNCTION_DISABLED' | 'RESOURCE_EXHAUSTED' | 'EXECUTION_FAILED' | 'UNAUTHENTICATED' | 'PERMISSION_DENIED' | 'INTERNAL';
1570
1638
  type UdfErrorBody = {
@@ -1699,4 +1767,4 @@ declare const installPlaybookRuntime: (targetWindow?: Window) => void;
1699
1767
  /** SDK version, injected at build time from package.json. */
1700
1768
  declare const VERSION: string;
1701
1769
 
1702
- 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 CreateAllowanceParams, type CreateAllowanceResponse, type CreditAllowance, type DeleteFunctionParams, type FeedDeleteRequest, type FeedDeleteResponse, type FeedStatusUpdateRequest, type FeedStatusUpdateResponse, 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 GetAllowanceParams, type InvokeFunctionParams, type InvokeFunctionResponse, type ListAllowancesResponse, type ListFunctionsParams, type ListFunctionsResponse, type NotificationPreference, type NotificationPreferenceKey, type NotificationPreferenceUpdateParams, type NotificationPreferenceUpdateResponse, type NotificationPreferencesResponse, PBSV_UPDATE_MESSAGE, type PlaybookFunction, type PlaybookSkillFile, type PlaybookSkillFileMeta, type PlaybookSkillMeta, type PlaybookSkillSummary, type PlaybookSkillTagEntry, type RegisterFunctionParams, type RegisterFunctionResponse, type RevokeAllowanceParams, type RevokeAllowanceResponse, SUBSCRIBE_PROPOSE_MESSAGE, SUBSCRIBE_RESULT_MESSAGE, type SkillDoc, type SkillEndpointMetadata, type SkillEndpointTier, type SkillMetadata, type SkillSummary, type SubmitFeedbackRequest, type SubmitFeedbackResponse, type SubscribeApi, type SubscribeProposalInput, type SubscribeProposalResult, 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, subscribe, udf };
1770
+ 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, CliUsageError, type CreateAllowanceParams, type CreateAllowanceResponse, type CreditAllowance, type CreditWallet, type CreditWalletItem, type CreditWalletItemConnection, type CreditWalletItemEdge, type CreditWalletItemsParams, type CreditWalletItemsResponse, type CreditWalletPageInfo, type DeleteFunctionParams, type FeedDeleteRequest, type FeedDeleteResponse, type FeedStatusUpdateRequest, type FeedStatusUpdateResponse, 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 GetAllowanceParams, type InvokeFunctionParams, type InvokeFunctionResponse, type ListAllowancesResponse, type ListFunctionsParams, type ListFunctionsResponse, type NotificationPreference, type NotificationPreferenceKey, type NotificationPreferenceUpdateParams, type NotificationPreferenceUpdateResponse, type NotificationPreferencesResponse, PBSV_UPDATE_MESSAGE, type PlaybookFunction, type PlaybookSkillFile, type PlaybookSkillFileMeta, type PlaybookSkillMeta, type PlaybookSkillSummary, type PlaybookSkillTagEntry, type RegisterFunctionParams, type RegisterFunctionResponse, type RevokeAllowanceParams, type RevokeAllowanceResponse, SUBSCRIBE_PROPOSE_MESSAGE, SUBSCRIBE_RESULT_MESSAGE, type SkillDoc, type SkillEndpointMetadata, type SkillEndpointTier, type SkillMetadata, type SkillSummary, type SubmitFeedbackRequest, type SubmitFeedbackResponse, type SubscribeApi, type SubscribeProposalInput, type SubscribeProposalResult, 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, subscribe, udf };
package/dist/index.d.ts CHANGED
@@ -21,6 +21,52 @@ interface UserProfile {
21
21
  /** Caller's alfs home directory, e.g. `/alva/home/<username>`. */
22
22
  home_path: string;
23
23
  }
24
+ interface CreditWallet {
25
+ balance: number;
26
+ totalRemaining: number;
27
+ todayUsed: number;
28
+ }
29
+ interface CreditWalletItemsParams {
30
+ /** Inclusive UTC lower bound, Unix milliseconds. */
31
+ startAtMs: number;
32
+ /** Exclusive UTC upper bound, Unix milliseconds. */
33
+ endAtMs: number;
34
+ /** Optional chat/session id to filter consumption records. */
35
+ sessionId?: string;
36
+ /** Page size, defaulted and capped by the gateway. */
37
+ first?: number;
38
+ /** Opaque cursor from a previous page's `pageInfo.endCursor`. */
39
+ after?: string;
40
+ }
41
+ interface CreditWalletItem {
42
+ id: string;
43
+ sessionId: string | null;
44
+ playbookId: string | null;
45
+ feedId: string | null;
46
+ op: string;
47
+ source: string;
48
+ amount: number;
49
+ extras?: unknown;
50
+ /** Creation timestamp, Unix milliseconds. */
51
+ createdAtMs: number;
52
+ }
53
+ interface CreditWalletPageInfo {
54
+ hasNextPage: boolean;
55
+ hasPreviousPage: boolean;
56
+ startCursor: string | null;
57
+ endCursor: string | null;
58
+ }
59
+ interface CreditWalletItemEdge {
60
+ cursor: string;
61
+ node: CreditWalletItem;
62
+ }
63
+ interface CreditWalletItemConnection {
64
+ pageInfo: CreditWalletPageInfo;
65
+ edges: CreditWalletItemEdge[];
66
+ }
67
+ interface CreditWalletItemsResponse extends CreditWallet {
68
+ items: CreditWalletItemConnection;
69
+ }
24
70
  type SubscriptionTier = 'SUBSCRIPTION_TIER_UNSPECIFIED' | 'SUBSCRIPTION_TIER_FREE' | 'SUBSCRIPTION_TIER_PRO';
25
71
  interface EnsureArraysJwtResponse {
26
72
  expires_at: number;
@@ -226,6 +272,12 @@ interface FeedReleaseRequest {
226
272
  view_json?: Record<string, unknown>;
227
273
  description?: string;
228
274
  changelog?: string;
275
+ /**
276
+ * Agent kind that produces this feed (e.g. "alpi"). Optional. Marks the feed
277
+ * as an agent feed whose prompt is editable; an empty/omitted value means a
278
+ * regular (non-agent) feed. The backend validates it against its catalog.
279
+ */
280
+ agent_type?: string;
229
281
  }
230
282
  interface FeedReleaseResponse {
231
283
  feed_id: number;
@@ -953,8 +1005,10 @@ interface TrendingPlaybookItem {
953
1005
  description: string;
954
1006
  tags: string[];
955
1007
  follow_count: number;
956
- /** Relative web path for opening or citing the playbook. */
1008
+ /** Relative web path for opening or citing the playbook, e.g. `/u/alice/playbooks/btc`. */
957
1009
  url_path: string;
1010
+ /** Absolute, clickable web URL, e.g. `https://alva.ai/u/alice/playbooks/btc`. */
1011
+ url: string;
958
1012
  /** README ALFS path when available. */
959
1013
  readme?: string;
960
1014
  /** Cursor to pass as `cursor` / `current` for pagination. */
@@ -1473,6 +1527,14 @@ declare class FunctionsResource {
1473
1527
  revokeAllowance(params: RevokeAllowanceParams): Promise<RevokeAllowanceResponse>;
1474
1528
  }
1475
1529
 
1530
+ declare class CreditsResource {
1531
+ private client;
1532
+ constructor(client: AlvaClient);
1533
+ wallet(): Promise<CreditWallet>;
1534
+ items(params: CreditWalletItemsParams): Promise<CreditWalletItemsResponse>;
1535
+ private graphql;
1536
+ }
1537
+
1476
1538
  interface RequestOptions {
1477
1539
  query?: Record<string, unknown>;
1478
1540
  body?: unknown;
@@ -1531,6 +1593,7 @@ declare class AlvaClient {
1531
1593
  private _channelGroupSubscriptions?;
1532
1594
  private _feedback?;
1533
1595
  private _functions?;
1596
+ private _credits?;
1534
1597
  constructor(config: AlvaClientConfig);
1535
1598
  get fs(): FsResource;
1536
1599
  get run(): RunResource;
@@ -1555,6 +1618,7 @@ declare class AlvaClient {
1555
1618
  get channelGroupSubscriptions(): ChannelGroupSubscriptionsResource;
1556
1619
  get feedback(): FeedbackResource;
1557
1620
  get functions(): FunctionsResource;
1621
+ get credits(): CreditsResource;
1558
1622
  _requireAuth(): void;
1559
1623
  _request(method: string, path: string, options?: RequestOptions): Promise<unknown>;
1560
1624
  }
@@ -1565,6 +1629,10 @@ declare class AlvaError extends Error {
1565
1629
  readonly details?: unknown;
1566
1630
  constructor(code: string, message: string, status: number, details?: unknown);
1567
1631
  }
1632
+ declare class CliUsageError extends Error {
1633
+ readonly command?: string;
1634
+ constructor(message: string, command?: string);
1635
+ }
1568
1636
 
1569
1637
  type UdfErrorCode = 'PBSV_EXPIRED' | 'PBSV_INVALID' | 'PBSV_PID_MISMATCH' | 'CONSENT_REQUIRED' | 'INSUFFICIENT_CREDITS' | 'FUNCTION_NOT_FOUND' | 'FUNCTION_DISABLED' | 'RESOURCE_EXHAUSTED' | 'EXECUTION_FAILED' | 'UNAUTHENTICATED' | 'PERMISSION_DENIED' | 'INTERNAL';
1570
1638
  type UdfErrorBody = {
@@ -1699,4 +1767,4 @@ declare const installPlaybookRuntime: (targetWindow?: Window) => void;
1699
1767
  /** SDK version, injected at build time from package.json. */
1700
1768
  declare const VERSION: string;
1701
1769
 
1702
- 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 CreateAllowanceParams, type CreateAllowanceResponse, type CreditAllowance, type DeleteFunctionParams, type FeedDeleteRequest, type FeedDeleteResponse, type FeedStatusUpdateRequest, type FeedStatusUpdateResponse, 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 GetAllowanceParams, type InvokeFunctionParams, type InvokeFunctionResponse, type ListAllowancesResponse, type ListFunctionsParams, type ListFunctionsResponse, type NotificationPreference, type NotificationPreferenceKey, type NotificationPreferenceUpdateParams, type NotificationPreferenceUpdateResponse, type NotificationPreferencesResponse, PBSV_UPDATE_MESSAGE, type PlaybookFunction, type PlaybookSkillFile, type PlaybookSkillFileMeta, type PlaybookSkillMeta, type PlaybookSkillSummary, type PlaybookSkillTagEntry, type RegisterFunctionParams, type RegisterFunctionResponse, type RevokeAllowanceParams, type RevokeAllowanceResponse, SUBSCRIBE_PROPOSE_MESSAGE, SUBSCRIBE_RESULT_MESSAGE, type SkillDoc, type SkillEndpointMetadata, type SkillEndpointTier, type SkillMetadata, type SkillSummary, type SubmitFeedbackRequest, type SubmitFeedbackResponse, type SubscribeApi, type SubscribeProposalInput, type SubscribeProposalResult, 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, subscribe, udf };
1770
+ 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, CliUsageError, type CreateAllowanceParams, type CreateAllowanceResponse, type CreditAllowance, type CreditWallet, type CreditWalletItem, type CreditWalletItemConnection, type CreditWalletItemEdge, type CreditWalletItemsParams, type CreditWalletItemsResponse, type CreditWalletPageInfo, type DeleteFunctionParams, type FeedDeleteRequest, type FeedDeleteResponse, type FeedStatusUpdateRequest, type FeedStatusUpdateResponse, 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 GetAllowanceParams, type InvokeFunctionParams, type InvokeFunctionResponse, type ListAllowancesResponse, type ListFunctionsParams, type ListFunctionsResponse, type NotificationPreference, type NotificationPreferenceKey, type NotificationPreferenceUpdateParams, type NotificationPreferenceUpdateResponse, type NotificationPreferencesResponse, PBSV_UPDATE_MESSAGE, type PlaybookFunction, type PlaybookSkillFile, type PlaybookSkillFileMeta, type PlaybookSkillMeta, type PlaybookSkillSummary, type PlaybookSkillTagEntry, type RegisterFunctionParams, type RegisterFunctionResponse, type RevokeAllowanceParams, type RevokeAllowanceResponse, SUBSCRIBE_PROPOSE_MESSAGE, SUBSCRIBE_RESULT_MESSAGE, type SkillDoc, type SkillEndpointMetadata, type SkillEndpointTier, type SkillMetadata, type SkillSummary, type SubmitFeedbackRequest, type SubmitFeedbackResponse, type SubscribeApi, type SubscribeProposalInput, type SubscribeProposalResult, 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, subscribe, udf };
package/dist/index.js CHANGED
@@ -11,6 +11,14 @@ var AlvaError = class extends Error {
11
11
  this.details = details;
12
12
  }
13
13
  };
14
+ var CliUsageError = class extends Error {
15
+ command;
16
+ constructor(message, command) {
17
+ super(message);
18
+ this.name = "CliUsageError";
19
+ this.command = command;
20
+ }
21
+ };
14
22
 
15
23
  // src/resources/fs.ts
16
24
  function isValidUtf8(bytes) {
@@ -305,7 +313,8 @@ var ReleaseResource = class {
305
313
  cronjob_id: params.cronjob_id,
306
314
  view_json: params.view_json,
307
315
  description: params.description,
308
- changelog: params.changelog
316
+ changelog: params.changelog,
317
+ agent_type: params.agent_type
309
318
  }
310
319
  });
311
320
  }
@@ -491,8 +500,11 @@ var PlaybooksResource = class {
491
500
  "/api/v1/playbooks/trending",
492
501
  { query }
493
502
  );
503
+ const webOrigin = webOriginFromApiBase(this.client.baseUrl);
494
504
  return {
495
- playbooks: (raw.playbooks ?? []).map(toAgentPlaybook),
505
+ playbooks: (raw.playbooks ?? []).map(
506
+ (p) => toAgentPlaybook(p, webOrigin)
507
+ ),
496
508
  has_next: raw.has_next ?? false
497
509
  };
498
510
  }
@@ -521,10 +533,23 @@ var PlaybooksResource = class {
521
533
  );
522
534
  }
523
535
  };
524
- function toAgentPlaybook(raw) {
536
+ function webOriginFromApiBase(apiBaseUrl) {
537
+ try {
538
+ const host = new URL(apiBaseUrl).hostname;
539
+ const match = /^api-llm\.([a-z0-9-]+)\.alva\.ai$/i.exec(host);
540
+ if (match) {
541
+ const env = match[1].toLowerCase();
542
+ return env === "prd" ? "https://alva.ai" : `https://${env}.alva.ai`;
543
+ }
544
+ } catch {
545
+ }
546
+ return "https://alva.ai";
547
+ }
548
+ function toAgentPlaybook(raw, webOrigin) {
525
549
  const username = raw.creator?.name ?? "";
526
550
  const name = raw.name ?? "";
527
551
  const ref = username && name ? `${username}/${name}` : name;
552
+ const urlPath = username && name ? `/u/${username}/playbooks/${name}` : "";
528
553
  return {
529
554
  id: raw.id === void 0 ? "" : String(raw.id),
530
555
  ref,
@@ -534,7 +559,8 @@ function toAgentPlaybook(raw) {
534
559
  description: raw.description ?? "",
535
560
  tags: raw.tags ?? [],
536
561
  follow_count: raw.follow_count ?? 0,
537
- url_path: username && name ? `/${username}/playbooks/${name}` : "",
562
+ url_path: urlPath,
563
+ url: urlPath ? `${webOrigin}${urlPath}` : "",
538
564
  ...raw.readme ? { readme: raw.readme } : {},
539
565
  cursor: raw.cursor ?? ""
540
566
  };
@@ -2522,6 +2548,122 @@ function parseResultPayload(result) {
2522
2548
  }
2523
2549
  }
2524
2550
 
2551
+ // src/resources/credits.ts
2552
+ var CREDIT_WALLET_QUERY = `
2553
+ query ToolkitCreditWallet {
2554
+ viewer {
2555
+ creditWallet {
2556
+ balance
2557
+ totalRemaining
2558
+ todayUsed
2559
+ }
2560
+ }
2561
+ }
2562
+ `.trim();
2563
+ var CREDIT_WALLET_ITEMS_QUERY = `
2564
+ query ToolkitCreditWalletItems($input: CreditWalletItemConnectionInput!) {
2565
+ viewer {
2566
+ creditWallet {
2567
+ balance
2568
+ totalRemaining
2569
+ todayUsed
2570
+ items(input: $input) {
2571
+ pageInfo {
2572
+ hasNextPage
2573
+ hasPreviousPage
2574
+ startCursor
2575
+ endCursor
2576
+ }
2577
+ edges {
2578
+ cursor
2579
+ node {
2580
+ id
2581
+ sessionId
2582
+ playbookId
2583
+ feedId
2584
+ op
2585
+ source
2586
+ amount
2587
+ extras
2588
+ createdAtMs
2589
+ }
2590
+ }
2591
+ }
2592
+ }
2593
+ }
2594
+ }
2595
+ `.trim();
2596
+ function graphQLErrorMessage(errors) {
2597
+ const messages = errors.map(
2598
+ (error) => typeof error.message === "string" && error.message ? error.message : void 0
2599
+ ).filter((message) => Boolean(message));
2600
+ return messages.length > 0 ? messages.join("; ") : "GraphQL request failed";
2601
+ }
2602
+ var CreditsResource = class {
2603
+ constructor(client) {
2604
+ this.client = client;
2605
+ }
2606
+ client;
2607
+ async wallet() {
2608
+ this.client._requireAuth();
2609
+ const data = await this.graphql(CREDIT_WALLET_QUERY);
2610
+ const wallet = data.viewer?.creditWallet;
2611
+ if (!wallet) {
2612
+ throw new AlvaError(
2613
+ "GRAPHQL_EMPTY_RESPONSE",
2614
+ "GraphQL response did not include viewer.creditWallet",
2615
+ 502
2616
+ );
2617
+ }
2618
+ return wallet;
2619
+ }
2620
+ async items(params) {
2621
+ this.client._requireAuth();
2622
+ const data = await this.graphql(
2623
+ CREDIT_WALLET_ITEMS_QUERY,
2624
+ {
2625
+ input: {
2626
+ startAtMs: params.startAtMs,
2627
+ endAtMs: params.endAtMs,
2628
+ sessionId: params.sessionId,
2629
+ first: params.first,
2630
+ after: params.after
2631
+ }
2632
+ }
2633
+ );
2634
+ const wallet = data.viewer?.creditWallet;
2635
+ if (!wallet) {
2636
+ throw new AlvaError(
2637
+ "GRAPHQL_EMPTY_RESPONSE",
2638
+ "GraphQL response did not include viewer.creditWallet.items",
2639
+ 502
2640
+ );
2641
+ }
2642
+ return wallet;
2643
+ }
2644
+ async graphql(query, variables) {
2645
+ const response = await this.client._request("POST", "/query", {
2646
+ body: variables === void 0 ? { query } : { query, variables }
2647
+ });
2648
+ if (response.errors && response.errors.length > 0) {
2649
+ throw new AlvaError(
2650
+ "GRAPHQL_ERROR",
2651
+ graphQLErrorMessage(response.errors),
2652
+ 400,
2653
+ { errors: response.errors }
2654
+ );
2655
+ }
2656
+ if (!response.data) {
2657
+ throw new AlvaError(
2658
+ "GRAPHQL_EMPTY_RESPONSE",
2659
+ "GraphQL response did not include data",
2660
+ 502
2661
+ );
2662
+ }
2663
+ return response.data;
2664
+ }
2665
+ };
2666
+
2525
2667
  // src/client.ts
2526
2668
  var DEFAULT_BASE_URL = "https://api-llm.prd.alva.ai";
2527
2669
  var DEFAULT_ARRAYS_BASE_URL = "https://data-tools.prd.space.id";
@@ -2623,6 +2765,7 @@ var AlvaClient = class {
2623
2765
  _channelGroupSubscriptions;
2624
2766
  _feedback;
2625
2767
  _functions;
2768
+ _credits;
2626
2769
  constructor(config) {
2627
2770
  this.baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;
2628
2771
  this.arraysBaseUrl = config.arraysBaseUrl ?? DEFAULT_ARRAYS_BASE_URL;
@@ -2704,6 +2847,9 @@ var AlvaClient = class {
2704
2847
  get functions() {
2705
2848
  return this._functions ??= new FunctionsResource(this);
2706
2849
  }
2850
+ get credits() {
2851
+ return this._credits ??= new CreditsResource(this);
2852
+ }
2707
2853
  _requireAuth() {
2708
2854
  if (!this.pbsvToken && !this.viewer_token && !this.apiKey) {
2709
2855
  throw new AlvaError(
@@ -2871,7 +3017,7 @@ var AlvaClient = class {
2871
3017
  return void 0;
2872
3018
  }
2873
3019
  const contentType = response.headers.get("content-type") ?? "";
2874
- if (contentType.includes("application/octet-stream") || contentType.includes("image/")) {
3020
+ if (contentType.includes("application/octet-stream") || contentType.startsWith("text/") || contentType.includes("image/")) {
2875
3021
  return response.arrayBuffer();
2876
3022
  }
2877
3023
  return response.json();
@@ -3305,10 +3451,11 @@ var installPlaybookRuntime = (targetWindow) => {
3305
3451
  };
3306
3452
 
3307
3453
  // src/index.ts
3308
- var VERSION = true ? "0.13.0" : "dev";
3454
+ var VERSION = true ? "0.14.0" : "dev";
3309
3455
  export {
3310
3456
  AlvaClient,
3311
3457
  AlvaError,
3458
+ CliUsageError,
3312
3459
  PBSV_UPDATE_MESSAGE,
3313
3460
  SUBSCRIBE_PROPOSE_MESSAGE,
3314
3461
  SUBSCRIBE_RESULT_MESSAGE,