@alva-ai/toolkit 0.13.1 → 0.14.1-beta.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/browser.global.js +43 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/cli.d.ts +65 -1
- package/dist/cli.js +375 -27
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +147 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +66 -2
- package/dist/index.d.ts +66 -2
- package/dist/index.js +147 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
}
|
|
@@ -1703,4 +1767,4 @@ declare const installPlaybookRuntime: (targetWindow?: Window) => void;
|
|
|
1703
1767
|
/** SDK version, injected at build time from package.json. */
|
|
1704
1768
|
declare const VERSION: string;
|
|
1705
1769
|
|
|
1706
|
-
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 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
|
}
|
|
@@ -1703,4 +1767,4 @@ declare const installPlaybookRuntime: (targetWindow?: Window) => void;
|
|
|
1703
1767
|
/** SDK version, injected at build time from package.json. */
|
|
1704
1768
|
declare const VERSION: string;
|
|
1705
1769
|
|
|
1706
|
-
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 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
|
@@ -313,7 +313,8 @@ var ReleaseResource = class {
|
|
|
313
313
|
cronjob_id: params.cronjob_id,
|
|
314
314
|
view_json: params.view_json,
|
|
315
315
|
description: params.description,
|
|
316
|
-
changelog: params.changelog
|
|
316
|
+
changelog: params.changelog,
|
|
317
|
+
agent_type: params.agent_type
|
|
317
318
|
}
|
|
318
319
|
});
|
|
319
320
|
}
|
|
@@ -499,8 +500,11 @@ var PlaybooksResource = class {
|
|
|
499
500
|
"/api/v1/playbooks/trending",
|
|
500
501
|
{ query }
|
|
501
502
|
);
|
|
503
|
+
const webOrigin = webOriginFromApiBase(this.client.baseUrl);
|
|
502
504
|
return {
|
|
503
|
-
playbooks: (raw.playbooks ?? []).map(
|
|
505
|
+
playbooks: (raw.playbooks ?? []).map(
|
|
506
|
+
(p) => toAgentPlaybook(p, webOrigin)
|
|
507
|
+
),
|
|
504
508
|
has_next: raw.has_next ?? false
|
|
505
509
|
};
|
|
506
510
|
}
|
|
@@ -529,10 +533,23 @@ var PlaybooksResource = class {
|
|
|
529
533
|
);
|
|
530
534
|
}
|
|
531
535
|
};
|
|
532
|
-
function
|
|
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) {
|
|
533
549
|
const username = raw.creator?.name ?? "";
|
|
534
550
|
const name = raw.name ?? "";
|
|
535
551
|
const ref = username && name ? `${username}/${name}` : name;
|
|
552
|
+
const urlPath = username && name ? `/u/${username}/playbooks/${name}` : "";
|
|
536
553
|
return {
|
|
537
554
|
id: raw.id === void 0 ? "" : String(raw.id),
|
|
538
555
|
ref,
|
|
@@ -542,7 +559,8 @@ function toAgentPlaybook(raw) {
|
|
|
542
559
|
description: raw.description ?? "",
|
|
543
560
|
tags: raw.tags ?? [],
|
|
544
561
|
follow_count: raw.follow_count ?? 0,
|
|
545
|
-
url_path:
|
|
562
|
+
url_path: urlPath,
|
|
563
|
+
url: urlPath ? `${webOrigin}${urlPath}` : "",
|
|
546
564
|
...raw.readme ? { readme: raw.readme } : {},
|
|
547
565
|
cursor: raw.cursor ?? ""
|
|
548
566
|
};
|
|
@@ -2530,6 +2548,122 @@ function parseResultPayload(result) {
|
|
|
2530
2548
|
}
|
|
2531
2549
|
}
|
|
2532
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
|
+
|
|
2533
2667
|
// src/client.ts
|
|
2534
2668
|
var DEFAULT_BASE_URL = "https://api-llm.prd.alva.ai";
|
|
2535
2669
|
var DEFAULT_ARRAYS_BASE_URL = "https://data-tools.prd.space.id";
|
|
@@ -2631,6 +2765,7 @@ var AlvaClient = class {
|
|
|
2631
2765
|
_channelGroupSubscriptions;
|
|
2632
2766
|
_feedback;
|
|
2633
2767
|
_functions;
|
|
2768
|
+
_credits;
|
|
2634
2769
|
constructor(config) {
|
|
2635
2770
|
this.baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;
|
|
2636
2771
|
this.arraysBaseUrl = config.arraysBaseUrl ?? DEFAULT_ARRAYS_BASE_URL;
|
|
@@ -2712,6 +2847,9 @@ var AlvaClient = class {
|
|
|
2712
2847
|
get functions() {
|
|
2713
2848
|
return this._functions ??= new FunctionsResource(this);
|
|
2714
2849
|
}
|
|
2850
|
+
get credits() {
|
|
2851
|
+
return this._credits ??= new CreditsResource(this);
|
|
2852
|
+
}
|
|
2715
2853
|
_requireAuth() {
|
|
2716
2854
|
if (!this.pbsvToken && !this.viewer_token && !this.apiKey) {
|
|
2717
2855
|
throw new AlvaError(
|
|
@@ -2878,11 +3016,11 @@ var AlvaClient = class {
|
|
|
2878
3016
|
if (response.status === 204) {
|
|
2879
3017
|
return void 0;
|
|
2880
3018
|
}
|
|
2881
|
-
const contentType = response.headers.get("content-type") ?? "";
|
|
2882
|
-
if (contentType.includes("application/
|
|
2883
|
-
return response.
|
|
3019
|
+
const contentType = (response.headers.get("content-type") ?? "").toLowerCase();
|
|
3020
|
+
if (contentType.includes("application/json") || contentType.includes("+json")) {
|
|
3021
|
+
return response.json();
|
|
2884
3022
|
}
|
|
2885
|
-
return response.
|
|
3023
|
+
return response.arrayBuffer();
|
|
2886
3024
|
}
|
|
2887
3025
|
};
|
|
2888
3026
|
|
|
@@ -3313,7 +3451,7 @@ var installPlaybookRuntime = (targetWindow) => {
|
|
|
3313
3451
|
};
|
|
3314
3452
|
|
|
3315
3453
|
// src/index.ts
|
|
3316
|
-
var VERSION = true ? "0.
|
|
3454
|
+
var VERSION = true ? "0.14.1-beta.0" : "dev";
|
|
3317
3455
|
export {
|
|
3318
3456
|
AlvaClient,
|
|
3319
3457
|
AlvaError,
|