@alva-ai/toolkit 0.4.1 → 0.4.3
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 +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/cli.js +194 -5
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +75 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +68 -1
- package/dist/index.d.ts +68 -1
- package/dist/index.js +75 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -637,7 +637,7 @@ var PushSubscriptionsResource = class {
|
|
|
637
637
|
*/
|
|
638
638
|
async subscribePlaybook(params) {
|
|
639
639
|
this.client._requireAuth();
|
|
640
|
-
const path = `/api/v1/playbook/${encodeURIComponent(params.username)}/${encodeURIComponent(params.name)}
|
|
640
|
+
const path = `/api/v1/push-subscriptions/playbook/${encodeURIComponent(params.username)}/${encodeURIComponent(params.name)}`;
|
|
641
641
|
return this.client._request(
|
|
642
642
|
"POST",
|
|
643
643
|
path
|
|
@@ -649,7 +649,7 @@ var PushSubscriptionsResource = class {
|
|
|
649
649
|
*/
|
|
650
650
|
async unsubscribePlaybook(params) {
|
|
651
651
|
this.client._requireAuth();
|
|
652
|
-
const path = `/api/v1/playbook/${encodeURIComponent(params.username)}/${encodeURIComponent(params.name)}
|
|
652
|
+
const path = `/api/v1/push-subscriptions/playbook/${encodeURIComponent(params.username)}/${encodeURIComponent(params.name)}`;
|
|
653
653
|
return this.client._request(
|
|
654
654
|
"DELETE",
|
|
655
655
|
path
|
|
@@ -663,7 +663,7 @@ var PushSubscriptionsResource = class {
|
|
|
663
663
|
*/
|
|
664
664
|
async subscribeFeed(params) {
|
|
665
665
|
this.client._requireAuth();
|
|
666
|
-
const path = `/api/v1/feed/${encodeURIComponent(params.username)}/${encodeURIComponent(params.name)}
|
|
666
|
+
const path = `/api/v1/push-subscriptions/feed/${encodeURIComponent(params.username)}/${encodeURIComponent(params.name)}`;
|
|
667
667
|
return this.client._request(
|
|
668
668
|
"POST",
|
|
669
669
|
path
|
|
@@ -675,7 +675,7 @@ var PushSubscriptionsResource = class {
|
|
|
675
675
|
*/
|
|
676
676
|
async unsubscribeFeed(params) {
|
|
677
677
|
this.client._requireAuth();
|
|
678
|
-
const path = `/api/v1/feed/${encodeURIComponent(params.username)}/${encodeURIComponent(params.name)}
|
|
678
|
+
const path = `/api/v1/push-subscriptions/feed/${encodeURIComponent(params.username)}/${encodeURIComponent(params.name)}`;
|
|
679
679
|
return this.client._request(
|
|
680
680
|
"DELETE",
|
|
681
681
|
path
|
|
@@ -698,6 +698,69 @@ var PushSubscriptionsResource = class {
|
|
|
698
698
|
}
|
|
699
699
|
};
|
|
700
700
|
|
|
701
|
+
// src/resources/channelGroupSubscriptions.ts
|
|
702
|
+
var ChannelGroupSubscriptionsResource = class {
|
|
703
|
+
constructor(client) {
|
|
704
|
+
this.client = client;
|
|
705
|
+
}
|
|
706
|
+
client;
|
|
707
|
+
async context(params) {
|
|
708
|
+
this.client._requireAuth();
|
|
709
|
+
return this.client._request(
|
|
710
|
+
"GET",
|
|
711
|
+
"/api/v1/channel/group-subscriptions/context",
|
|
712
|
+
{
|
|
713
|
+
query: { session_id: params.session_id }
|
|
714
|
+
}
|
|
715
|
+
);
|
|
716
|
+
}
|
|
717
|
+
async list(params) {
|
|
718
|
+
this.client._requireAuth();
|
|
719
|
+
return this.client._request("GET", "/api/v1/channel/group-subscriptions", {
|
|
720
|
+
query: { session_id: params.session_id }
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
async subscribe(params) {
|
|
724
|
+
this.client._requireAuth();
|
|
725
|
+
return this.client._request("POST", "/api/v1/channel/group-subscriptions", {
|
|
726
|
+
jsonBody: mutationBody(params)
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
async unsubscribe(params) {
|
|
730
|
+
this.client._requireAuth();
|
|
731
|
+
return this.client._request(
|
|
732
|
+
"DELETE",
|
|
733
|
+
"/api/v1/channel/group-subscriptions",
|
|
734
|
+
{
|
|
735
|
+
jsonBody: mutationBody(params)
|
|
736
|
+
}
|
|
737
|
+
);
|
|
738
|
+
}
|
|
739
|
+
};
|
|
740
|
+
function mutationBody(params) {
|
|
741
|
+
return `{"session_id":${idLiteral(params.session_id)},"target_type":${JSON.stringify(params.target_type)},"target_id":${idLiteral(params.target_id)}}`;
|
|
742
|
+
}
|
|
743
|
+
function idLiteral(value) {
|
|
744
|
+
if (typeof value === "number") {
|
|
745
|
+
if (!Number.isInteger(value) || value <= 0 || !Number.isSafeInteger(value)) {
|
|
746
|
+
throw new AlvaError(
|
|
747
|
+
"INVALID_ARGUMENT",
|
|
748
|
+
"channel group subscription ids must be positive safe integers; pass large int64 ids as strings",
|
|
749
|
+
0
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
return String(value);
|
|
753
|
+
}
|
|
754
|
+
if (!/^[1-9]\d*$/.test(value)) {
|
|
755
|
+
throw new AlvaError(
|
|
756
|
+
"INVALID_ARGUMENT",
|
|
757
|
+
"channel group subscription ids must be positive integer strings",
|
|
758
|
+
0
|
|
759
|
+
);
|
|
760
|
+
}
|
|
761
|
+
return value;
|
|
762
|
+
}
|
|
763
|
+
|
|
701
764
|
// src/client.ts
|
|
702
765
|
var DEFAULT_BASE_URL = "https://api-llm.prd.alva.ai";
|
|
703
766
|
var DEFAULT_ARRAYS_BASE_URL = "https://data-tools.prd.space.id";
|
|
@@ -721,6 +784,7 @@ var AlvaClient = class {
|
|
|
721
784
|
_arraysJwt;
|
|
722
785
|
_notifications;
|
|
723
786
|
_pushSubscriptions;
|
|
787
|
+
_channelGroupSubscriptions;
|
|
724
788
|
constructor(config) {
|
|
725
789
|
this.baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;
|
|
726
790
|
this.arraysBaseUrl = config.arraysBaseUrl ?? DEFAULT_ARRAYS_BASE_URL;
|
|
@@ -772,6 +836,9 @@ var AlvaClient = class {
|
|
|
772
836
|
get pushSubscriptions() {
|
|
773
837
|
return this._pushSubscriptions ??= new PushSubscriptionsResource(this);
|
|
774
838
|
}
|
|
839
|
+
get channelGroupSubscriptions() {
|
|
840
|
+
return this._channelGroupSubscriptions ??= new ChannelGroupSubscriptionsResource(this);
|
|
841
|
+
}
|
|
775
842
|
_requireAuth() {
|
|
776
843
|
if (!this.viewer_token && !this.apiKey) {
|
|
777
844
|
throw new AlvaError(
|
|
@@ -808,6 +875,9 @@ var AlvaClient = class {
|
|
|
808
875
|
if (options?.rawBody !== void 0) {
|
|
809
876
|
headers["Content-Type"] = "application/octet-stream";
|
|
810
877
|
fetchBody = options.rawBody;
|
|
878
|
+
} else if (options?.jsonBody !== void 0) {
|
|
879
|
+
headers["Content-Type"] = "application/json";
|
|
880
|
+
fetchBody = options.jsonBody;
|
|
811
881
|
} else if (options?.body !== void 0) {
|
|
812
882
|
headers["Content-Type"] = "application/json";
|
|
813
883
|
fetchBody = JSON.stringify(options.body);
|
|
@@ -1131,7 +1201,7 @@ async function runPostConfigureHooks(client, deps) {
|
|
|
1131
1201
|
import * as fs from "fs";
|
|
1132
1202
|
import * as os2 from "os";
|
|
1133
1203
|
import * as fsPromises2 from "fs/promises";
|
|
1134
|
-
var CLI_VERSION = true ? "0.4.
|
|
1204
|
+
var CLI_VERSION = true ? "0.4.3" : "dev";
|
|
1135
1205
|
function isVersionOlderThan(a, b) {
|
|
1136
1206
|
const parse = (v) => {
|
|
1137
1207
|
if (!v) return null;
|
|
@@ -1164,6 +1234,7 @@ Commands:
|
|
|
1164
1234
|
skills Data-skill documentation from the Arrays backend (list, summary, endpoint)
|
|
1165
1235
|
comments Playbook comments (create, pin, unpin)
|
|
1166
1236
|
push-subscriptions Personal push opt-in (subscribe-playbook, unsubscribe-playbook, subscribe-feed, unsubscribe-feed, list)
|
|
1237
|
+
channel Channel group operations (group-subscriptions context, list, subscribe, unsubscribe)
|
|
1167
1238
|
remix Save playbook remix lineage
|
|
1168
1239
|
trading Trading operations (accounts, portfolio, orders, subscriptions, equity-history, risk-rules, subscribe, unsubscribe, execute, update-risk-rules)
|
|
1169
1240
|
auth Authentication (login)
|
|
@@ -1597,6 +1668,31 @@ Examples:
|
|
|
1597
1668
|
alva push-subscriptions subscribe-feed --username alice --name btc-ema-cross
|
|
1598
1669
|
alva push-subscriptions unsubscribe-feed --username alice --name btc-ema-cross
|
|
1599
1670
|
alva push-subscriptions list --include-history`,
|
|
1671
|
+
channel: `Usage: alva channel group-subscriptions <subcommand> [options]
|
|
1672
|
+
|
|
1673
|
+
Manage push notifications delivered into the external group chat attached
|
|
1674
|
+
to a channel session. The group can subscribe to public feeds and playbooks.
|
|
1675
|
+
Subscribe/unsubscribe are idempotent no-ops unless the authenticated caller
|
|
1676
|
+
is that group's Alva admin.
|
|
1677
|
+
|
|
1678
|
+
Subcommands:
|
|
1679
|
+
context Show group admin status and current subscriptions
|
|
1680
|
+
list List active subscriptions for the group
|
|
1681
|
+
subscribe Subscribe the group to a public feed or playbook
|
|
1682
|
+
unsubscribe Unsubscribe the group from a feed or playbook
|
|
1683
|
+
|
|
1684
|
+
Common flags:
|
|
1685
|
+
--session-id <id> Channel session id for the group (required)
|
|
1686
|
+
|
|
1687
|
+
Subscribe/unsubscribe flags:
|
|
1688
|
+
--target-type <type> feed or playbook (required)
|
|
1689
|
+
--target-id <id> Numeric feed_id or playbook_id (required)
|
|
1690
|
+
|
|
1691
|
+
Examples:
|
|
1692
|
+
alva channel group-subscriptions context --session-id 123
|
|
1693
|
+
alva channel group-subscriptions list --session-id 123
|
|
1694
|
+
alva channel group-subscriptions subscribe --session-id 123 --target-type feed --target-id 8169
|
|
1695
|
+
alva channel group-subscriptions unsubscribe --session-id 123 --target-type playbook --target-id 42`,
|
|
1600
1696
|
remix: `Usage: alva remix --child-username <u> --child-name <n> --parents <json>
|
|
1601
1697
|
|
|
1602
1698
|
Record remix lineage when creating a playbook based on existing playbooks.
|
|
@@ -1798,6 +1894,25 @@ function requireNumericFlag(flags, name, command) {
|
|
|
1798
1894
|
}
|
|
1799
1895
|
return n;
|
|
1800
1896
|
}
|
|
1897
|
+
function requirePositiveIntegerStringFlag(flags, name, command) {
|
|
1898
|
+
const val = requireFlag(flags, name, command);
|
|
1899
|
+
if (!/^[1-9]\d*$/.test(val)) {
|
|
1900
|
+
const group = command.split(" ")[0];
|
|
1901
|
+
throw new CliUsageError(
|
|
1902
|
+
`--${name} must be a positive integer for '${command}', got '${val}'`,
|
|
1903
|
+
group
|
|
1904
|
+
);
|
|
1905
|
+
}
|
|
1906
|
+
return val;
|
|
1907
|
+
}
|
|
1908
|
+
function requireGroupSubscriptionTargetType(flags, command) {
|
|
1909
|
+
const val = requireFlag(flags, "target-type", command).trim().toLowerCase();
|
|
1910
|
+
if (val === "feed" || val === "playbook") return val;
|
|
1911
|
+
throw new CliUsageError(
|
|
1912
|
+
`--target-type must be feed or playbook for '${command}', got '${val}'`,
|
|
1913
|
+
command.split(" ")[0]
|
|
1914
|
+
);
|
|
1915
|
+
}
|
|
1801
1916
|
function num(val) {
|
|
1802
1917
|
if (val === void 0) return void 0;
|
|
1803
1918
|
const n = Number(val);
|
|
@@ -2240,6 +2355,80 @@ async function dispatch(client, args, meta) {
|
|
|
2240
2355
|
);
|
|
2241
2356
|
}
|
|
2242
2357
|
}
|
|
2358
|
+
case "channel": {
|
|
2359
|
+
if (!subcommand || subcommand === "--help" || subcommand === "-h") {
|
|
2360
|
+
return { _help: true, text: COMMAND_HELP.channel };
|
|
2361
|
+
}
|
|
2362
|
+
if (subcommand !== "group-subscriptions") {
|
|
2363
|
+
throw new CliUsageError(
|
|
2364
|
+
`Unknown subcommand: channel ${subcommand}`,
|
|
2365
|
+
"channel"
|
|
2366
|
+
);
|
|
2367
|
+
}
|
|
2368
|
+
const leaf = args[2];
|
|
2369
|
+
if (!leaf || leaf === "--help" || leaf === "-h") {
|
|
2370
|
+
return { _help: true, text: COMMAND_HELP.channel };
|
|
2371
|
+
}
|
|
2372
|
+
const channelFlags = parseFlags2(args.slice(3));
|
|
2373
|
+
const commandName = `channel group-subscriptions ${leaf}`;
|
|
2374
|
+
switch (leaf) {
|
|
2375
|
+
case "context":
|
|
2376
|
+
return client.channelGroupSubscriptions.context({
|
|
2377
|
+
session_id: requirePositiveIntegerStringFlag(
|
|
2378
|
+
channelFlags,
|
|
2379
|
+
"session-id",
|
|
2380
|
+
commandName
|
|
2381
|
+
)
|
|
2382
|
+
});
|
|
2383
|
+
case "list":
|
|
2384
|
+
return client.channelGroupSubscriptions.list({
|
|
2385
|
+
session_id: requirePositiveIntegerStringFlag(
|
|
2386
|
+
channelFlags,
|
|
2387
|
+
"session-id",
|
|
2388
|
+
commandName
|
|
2389
|
+
)
|
|
2390
|
+
});
|
|
2391
|
+
case "subscribe":
|
|
2392
|
+
return client.channelGroupSubscriptions.subscribe({
|
|
2393
|
+
session_id: requirePositiveIntegerStringFlag(
|
|
2394
|
+
channelFlags,
|
|
2395
|
+
"session-id",
|
|
2396
|
+
commandName
|
|
2397
|
+
),
|
|
2398
|
+
target_type: requireGroupSubscriptionTargetType(
|
|
2399
|
+
channelFlags,
|
|
2400
|
+
commandName
|
|
2401
|
+
),
|
|
2402
|
+
target_id: requirePositiveIntegerStringFlag(
|
|
2403
|
+
channelFlags,
|
|
2404
|
+
"target-id",
|
|
2405
|
+
commandName
|
|
2406
|
+
)
|
|
2407
|
+
});
|
|
2408
|
+
case "unsubscribe":
|
|
2409
|
+
return client.channelGroupSubscriptions.unsubscribe({
|
|
2410
|
+
session_id: requirePositiveIntegerStringFlag(
|
|
2411
|
+
channelFlags,
|
|
2412
|
+
"session-id",
|
|
2413
|
+
commandName
|
|
2414
|
+
),
|
|
2415
|
+
target_type: requireGroupSubscriptionTargetType(
|
|
2416
|
+
channelFlags,
|
|
2417
|
+
commandName
|
|
2418
|
+
),
|
|
2419
|
+
target_id: requirePositiveIntegerStringFlag(
|
|
2420
|
+
channelFlags,
|
|
2421
|
+
"target-id",
|
|
2422
|
+
commandName
|
|
2423
|
+
)
|
|
2424
|
+
});
|
|
2425
|
+
default:
|
|
2426
|
+
throw new CliUsageError(
|
|
2427
|
+
`Unknown subcommand: channel group-subscriptions ${leaf}`,
|
|
2428
|
+
"channel"
|
|
2429
|
+
);
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2243
2432
|
case "remix":
|
|
2244
2433
|
return client.remix.save({
|
|
2245
2434
|
child: {
|