@alva-ai/toolkit 0.11.2 → 0.11.3-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/cli.js CHANGED
@@ -7373,6 +7373,7 @@ var init_fallback_bundle = __esm({
7373
7373
  --chart-grey-2: #b7b7b7; /* \u26A0 Only When chart has \u2265 3 series */
7374
7374
 
7375
7375
  /* \u2500\u2500 Spacing \u2500\u2500 */
7376
+ --spacing-min: 0px;
7376
7377
  --spacing-xxxs: 2px;
7377
7378
  --spacing-xxs: 4px;
7378
7379
  --spacing-xs: 8px;
@@ -7387,21 +7388,25 @@ var init_fallback_bundle = __esm({
7387
7388
  --spacing-xxxxxxl: 56px;
7388
7389
 
7389
7390
  /* \u2500\u2500 Radius \u2500\u2500 */
7390
- --radius-ct-xs: 2px;
7391
+ --radius-ct-min: 2px;
7391
7392
  --radius-ct-s: 4px;
7392
7393
  --radius-ct-m: 6px;
7393
7394
  --radius-ct-l: 8px;
7394
7395
  --radius-ct-xl: 12px;
7395
- --radius-pop-dialog: 12px;
7396
- --radius-pop-action-sheets: 12px;
7397
- --radius-pop-dropdown: 8px;
7398
- --radius-pop-popover: 8px;
7399
- --radius-pop-toast: 8px;
7400
- --radius-pop-tips: 8px;
7401
- --radius-btn-xs: 4px;
7402
- --radius-btn-s: 6px;
7403
- --radius-btn-m: 8px;
7404
- --radius-btn-l: 12px;
7396
+ --radius-ct-xxl: 16px;
7397
+ --radius-ct-xxxl: 20px;
7398
+ --radius-ct-max: 960px;
7399
+ --radius-pop-dialog: 8px;
7400
+ --radius-pop-action-sheets: 8px;
7401
+ --radius-pop-dropdown: 6px;
7402
+ --radius-pop-popover: 6px;
7403
+ --radius-pop-toast: 4px;
7404
+ --radius-pop-tips: 4px;
7405
+ --radius-btn-min: 0px;
7406
+ --radius-btn-xs: 2px;
7407
+ --radius-btn-s: 4px;
7408
+ --radius-btn-m: 6px;
7409
+ --radius-btn-l: 8px;
7405
7410
  }
7406
7411
  }
7407
7412
 
@@ -7420,12 +7425,17 @@ var init_fallback_bundle = __esm({
7420
7425
  --b0-page: #ffffff;
7421
7426
  --b0-container: #ffffff;
7422
7427
  --b0-sidebar: #2a2a38;
7423
- --b0-sidebar-select: rgba(255, 255, 255, 0.03);
7428
+ --b0-sidebar-select: rgba(255, 255, 255, 0.05);
7429
+ --b0-special: #375454;
7424
7430
  --grey-g01: #fafafa; /* Dashboard Card */
7425
7431
  --grey-g02: #f5f5f5;
7426
7432
  --grey-g03: #f0f0f0;
7427
7433
  --grey-g05: #eaeaea;
7428
7434
  --grey-g1: #dedede;
7435
+ --grey-g2: #c5c5c5;
7436
+ --grey-g3: #acacac;
7437
+ --grey-g5: #7b7b7b;
7438
+ --grey-g7: #4a4a4a;
7429
7439
  --b-r02: rgba(0, 0, 0, 0.02); /* Content Block */
7430
7440
  --b-r03: rgba(0, 0, 0, 0.03); /* Darker Block */
7431
7441
  --b-r05: rgba(0, 0, 0, 0.05);
@@ -7575,6 +7585,7 @@ body {
7575
7585
  position: relative;
7576
7586
  width: 100%;
7577
7587
  cursor: pointer;
7588
+ border-radius: var(--radius-ct-s);
7578
7589
  transition: background-color 0.12s ease;
7579
7590
  }
7580
7591
 
@@ -7583,10 +7594,6 @@ body {
7583
7594
  background-color: rgba(73,163,166,0.08);
7584
7595
  }
7585
7596
 
7586
- .list-item.selected {
7587
- border-radius: var(--radius-ct-m);
7588
- }
7589
-
7590
7597
  .list-item.selected .list-item-text {
7591
7598
  color: var(--main-m1);
7592
7599
  }
@@ -7615,6 +7622,13 @@ body {
7615
7622
  text-overflow: ellipsis;
7616
7623
  }
7617
7624
 
7625
+ /* Size S \u2014 width follows the Select trigger; only typography shrinks */
7626
+ .dropdown.size-s .list-item-text {
7627
+ font-size: 12px;
7628
+ line-height: 20px;
7629
+ letter-spacing: 0.12px;
7630
+ }
7631
+
7618
7632
  /* \u2500\u2500 Container \u2500\u2500 */
7619
7633
  .markdown-container {
7620
7634
  width: 100%;
@@ -7740,7 +7754,7 @@ body {
7740
7754
  .markdown-container code,
7741
7755
  .markdown-container pre {
7742
7756
  background: var(--b-r02);
7743
- border-radius: var(--radius-ct-xs);
7757
+ border-radius: var(--radius-ct-min);
7744
7758
  font-family: "JetBrains Mono", monospace;
7745
7759
  color: var(--text-n7);
7746
7760
  }
@@ -7777,8 +7791,8 @@ body {
7777
7791
 
7778
7792
  /* \u2500\u2500 Divider \u2500\u2500 */
7779
7793
  .markdown-container hr {
7780
- height: 1px;
7781
- background: var(--line-l07);
7794
+ height: 0.5px;
7795
+ background: var(--line-l12);
7782
7796
  border: none;
7783
7797
  margin: var(--spacing-xxs) 0;
7784
7798
  }
@@ -7806,7 +7820,7 @@ body {
7806
7820
  min-height: 176px;
7807
7821
  }
7808
7822
  .markdown-container tr {
7809
- border-bottom: 1px solid var(--line-l07);
7823
+ border-bottom: 0.5px solid var(--line-l12);
7810
7824
  }
7811
7825
  .markdown-container tr:last-child {
7812
7826
  border-bottom: none;
@@ -8165,7 +8179,7 @@ body {
8165
8179
  outline-offset: 2px;
8166
8180
  }
8167
8181
 
8168
- /* Base (default size = Small) */
8182
+ /* Base (default size) */
8169
8183
  .tag {
8170
8184
  display: inline-flex;
8171
8185
  align-items: center;
@@ -8199,14 +8213,24 @@ body {
8199
8213
  letter-spacing: 0.14px;
8200
8214
  }
8201
8215
 
8216
+ /* Size \u2014 Small */
8217
+ .tag-sm {
8218
+ height: 20px;
8219
+ padding: 1px 4px;
8220
+ font-size: 11px;
8221
+ line-height: 18px;
8222
+ letter-spacing: 0.11px;
8223
+ border-radius: var(--radius-ct-min);
8224
+ }
8225
+
8202
8226
  /* Size \u2014 Extra Small */
8203
8227
  .tag-xs {
8204
8228
  height: 18px;
8205
- padding: 1px 6px;
8229
+ padding: 1px 4px;
8206
8230
  font-size: 10px;
8207
8231
  line-height: 16px;
8208
8232
  letter-spacing: 0.1px;
8209
- border-radius: var(--radius-ct-xs);
8233
+ border-radius: var(--radius-ct-min);
8210
8234
  }
8211
8235
 
8212
8236
  /*
@@ -8348,8 +8372,10 @@ body {
8348
8372
  transition: border-color 0.12s ease;
8349
8373
  }
8350
8374
 
8351
- .select:hover .select-border {
8375
+ /* Activated (dropdown open) \u2014 color + 1px border. Hover does not change color. */
8376
+ .select.open .select-border {
8352
8377
  border-color: var(--line-l9);
8378
+ border-width: 1px;
8353
8379
  }
8354
8380
 
8355
8381
  .select-text {
@@ -8365,7 +8391,7 @@ body {
8365
8391
  color: var(--text-n9);
8366
8392
  }
8367
8393
 
8368
- .select:hover .select-text {
8394
+ .select.open .select-text {
8369
8395
  color: var(--text-n9);
8370
8396
  }
8371
8397
 
@@ -8397,6 +8423,17 @@ body {
8397
8423
 
8398
8424
  /* Size \u2014 Small */
8399
8425
  .select-sm {
8426
+ height: 32px;
8427
+ padding: 6px var(--spacing-s);
8428
+ gap: var(--spacing-xxs);
8429
+ border-radius: var(--radius-btn-s);
8430
+ font-size: 12px;
8431
+ line-height: 20px;
8432
+ letter-spacing: 0.12px;
8433
+ }
8434
+
8435
+ /* Size \u2014 Extra Small */
8436
+ .select-xs {
8400
8437
  height: 28px;
8401
8438
  padding: var(--spacing-xxs) var(--spacing-xs);
8402
8439
  gap: var(--spacing-xxs);
@@ -8405,22 +8442,25 @@ body {
8405
8442
  line-height: 20px;
8406
8443
  letter-spacing: 0.12px;
8407
8444
  }
8408
- .select-sm .select-text {
8409
- width: 70px;
8410
- flex: none;
8411
- }
8412
8445
 
8413
- /* Arrow Icon */
8446
+ /* Arrow Icon \u2014 14px for L/M, 12px for S/XS */
8414
8447
  .select-icon {
8415
8448
  flex-shrink: 0;
8416
8449
  display: flex;
8417
8450
  align-items: center;
8418
8451
  justify-content: center;
8452
+ width: 14px;
8453
+ height: 14px;
8419
8454
  opacity: 0.22;
8420
8455
  transition: opacity 0.12s ease;
8421
8456
  }
8422
8457
 
8423
- .select:hover .select-icon,
8458
+ .select-sm .select-icon,
8459
+ .select-xs .select-icon {
8460
+ width: 12px;
8461
+ height: 12px;
8462
+ }
8463
+
8424
8464
  .select.open .select-icon {
8425
8465
  opacity: 1;
8426
8466
  }
@@ -8454,9 +8494,10 @@ body {
8454
8494
  transition: border-color 0.12s ease;
8455
8495
  }
8456
8496
 
8457
- .input:hover .input-border,
8497
+ /* Activated (focused/typing) \u2014 color + 1px border. Hover does not change color. */
8458
8498
  .input:focus-within .input-border {
8459
8499
  border-color: var(--line-l9);
8500
+ border-width: 1px;
8460
8501
  }
8461
8502
 
8462
8503
  .input-field {
@@ -8496,6 +8537,16 @@ body {
8496
8537
 
8497
8538
  /* Size \u2014 Small */
8498
8539
  .input-sm {
8540
+ height: 32px;
8541
+ padding: 6px var(--spacing-s);
8542
+ border-radius: var(--radius-btn-s);
8543
+ font-size: 12px;
8544
+ line-height: 20px;
8545
+ letter-spacing: 0.12px;
8546
+ }
8547
+
8548
+ /* Size \u2014 Extra Small */
8549
+ .input-xs {
8499
8550
  height: 28px;
8500
8551
  padding: var(--spacing-xxs) var(--spacing-xs);
8501
8552
  border-radius: var(--radius-btn-s);
@@ -8531,10 +8582,13 @@ body {
8531
8582
  overflow: hidden;
8532
8583
  }
8533
8584
 
8534
- /* \u2500\u2500 Underline \u2500\u2500 */
8585
+ /* \u2500\u2500 Underline \u2500\u2500 divider + active bar are bottom-anchored overlays (both bottom:0,
8586
+ so bottoms align); bar covers divider via z-index. Do not refactor to a border. */
8535
8587
  .tab-underline {
8588
+ position: relative;
8589
+ width: 100%;
8590
+ align-items: flex-end;
8536
8591
  gap: var(--spacing-m);
8537
- border-bottom: 1px solid var(--line-l07);
8538
8592
  flex-wrap: nowrap;
8539
8593
  overflow-x: auto;
8540
8594
  scrollbar-width: none; /* Firefox */
@@ -8542,19 +8596,37 @@ body {
8542
8596
  .tab-underline::-webkit-scrollbar {
8543
8597
  display: none;
8544
8598
  }
8599
+ .tab-underline::after {
8600
+ content: "";
8601
+ position: absolute;
8602
+ left: 0;
8603
+ right: 0;
8604
+ bottom: 0;
8605
+ height: 0.5px;
8606
+ background: var(--line-l12);
8607
+ z-index: 0;
8608
+ }
8545
8609
  .tab-underline .tab-item {
8546
8610
  padding-bottom: var(--spacing-xxs);
8547
- margin-bottom: -1px;
8548
8611
  font-size: 14px;
8549
8612
  line-height: 22px;
8550
8613
  letter-spacing: 0.14px;
8551
8614
  color: var(--text-n7);
8552
- border-bottom: 2px solid transparent;
8553
8615
  }
8554
8616
  .tab-underline .tab-item.active {
8617
+ position: relative;
8618
+ z-index: 1;
8555
8619
  color: var(--text-n9);
8556
8620
  font-weight: 500;
8557
- border-bottom-color: var(--main-m1);
8621
+ }
8622
+ .tab-underline .tab-item.active::before {
8623
+ content: "";
8624
+ position: absolute;
8625
+ left: 0;
8626
+ right: 0;
8627
+ bottom: 0;
8628
+ height: 2px;
8629
+ background: var(--main-m1);
8558
8630
  }
8559
8631
 
8560
8632
  /* Underline \u2014 Size L */
@@ -8584,7 +8656,7 @@ body {
8584
8656
  }
8585
8657
  .tab-underline.tab-xl .tab-item {
8586
8658
  padding-top: var(--spacing-s);
8587
- padding-bottom: 10px; /* 12 \u2212 2px border = matches inactive py-12 */
8659
+ padding-bottom: 10px;
8588
8660
  font-size: 18px;
8589
8661
  line-height: 28px;
8590
8662
  letter-spacing: 0.18px;
@@ -8629,7 +8701,7 @@ body {
8629
8701
  }
8630
8702
  .tab-segmented.tab-s .tab-item {
8631
8703
  padding: var(--spacing-xxs) 10px;
8632
- border-radius: var(--radius-ct-xs); /* 2px */
8704
+ border-radius: var(--radius-ct-min); /* 2px */
8633
8705
  font-size: 12px;
8634
8706
  line-height: 20px;
8635
8707
  letter-spacing: 0.12px;
@@ -8642,7 +8714,7 @@ body {
8642
8714
  }
8643
8715
  .tab-pill .tab-item {
8644
8716
  padding: 6px var(--spacing-s);
8645
- border-radius: 999px; /* capsule */
8717
+ border-radius: var(--radius-ct-max); /* capsule */
8646
8718
  font-size: 14px;
8647
8719
  line-height: 22px;
8648
8720
  letter-spacing: 0.14px;
@@ -8677,7 +8749,7 @@ body {
8677
8749
  .tooltip {
8678
8750
  background-color: var(--b0-container);
8679
8751
  position: absolute;
8680
- border-radius: var(--radius-ct-m);
8752
+ border-radius: var(--radius-pop-tips);
8681
8753
  box-shadow: var(--shadow-s);
8682
8754
  padding: var(--spacing-m);
8683
8755
  width: fit-content;
@@ -8690,7 +8762,7 @@ body {
8690
8762
  .tooltip-border {
8691
8763
  position: absolute;
8692
8764
  border: 0.5px solid var(--line-l2);
8693
- border-radius: var(--radius-ct-m);
8765
+ border-radius: var(--radius-pop-tips);
8694
8766
  inset: 0;
8695
8767
  pointer-events: none;
8696
8768
  }
@@ -8779,16 +8851,16 @@ body {
8779
8851
 
8780
8852
  /* \u2500\u2500 Dividers \u2500\u2500 */
8781
8853
  .divider-v {
8782
- width: 1px;
8854
+ width: 0.5px;
8783
8855
  flex-shrink: 0;
8784
8856
  margin-block: var(--spacing-l);
8785
- background-color: var(--line-l05);
8857
+ background-color: var(--line-l07);
8786
8858
  }
8787
8859
 
8788
8860
  .divider-h {
8789
- height: 1px;
8861
+ height: 0.5px;
8790
8862
  margin-inline: var(--spacing-l);
8791
- background-color: var(--line-l05);
8863
+ background-color: var(--line-l07);
8792
8864
  }
8793
8865
 
8794
8866
  /* \u2500\u2500 Equal Height Fill \u2500\u2500 */
@@ -8962,7 +9034,7 @@ body {
8962
9034
  display: flex;
8963
9035
  width: 100%;
8964
9036
  gap: var(--spacing-m); /* column spacing between cells */
8965
- border-bottom: 1px solid var(--line-l07); /* row divider \u2014 on the row, not cells */
9037
+ border-bottom: 0.5px solid var(--line-l12); /* row divider \u2014 on the row, not cells */
8966
9038
  /* min-width is set by initTableAlignment JS \u2014 do NOT use CSS min-width here */
8967
9039
  }
8968
9040
  .table-row:last-child {
@@ -9012,8 +9084,8 @@ body {
9012
9084
  bottom: 0;
9013
9085
  left: var(--spacing-m);
9014
9086
  right: var(--spacing-m);
9015
- height: 1px;
9016
- background: var(--line-l05);
9087
+ height: 0.5px;
9088
+ background: var(--line-l07);
9017
9089
  }
9018
9090
 
9019
9091
  .feed-item:last-child::after {
@@ -9274,7 +9346,7 @@ body {
9274
9346
  letter-spacing: 0.12px;
9275
9347
  color: var(--text-n5);
9276
9348
  padding-left: 8px;
9277
- border-left: 1px solid var(--line-l07);
9349
+ border-left: 0.5px solid var(--line-l12);
9278
9350
  }
9279
9351
  `;
9280
9352
  }
@@ -10995,6 +11067,36 @@ var SKILL_ENDPOINT_METADATA = [
10995
11067
  required_subscription_tier: "pro",
10996
11068
  access: "pro_only",
10997
11069
  pro_required: true
11070
+ },
11071
+ {
11072
+ skill: "arrays-data-api-equity-fundamentals",
11073
+ file: "company-detail-non-us",
11074
+ method: "GET",
11075
+ path: "/api/v1/stocks/non-us/company/detail",
11076
+ tier: "public",
11077
+ required_subscription_tier: "free",
11078
+ access: "free_and_pro",
11079
+ pro_required: false
11080
+ },
11081
+ {
11082
+ skill: "arrays-data-api-social-feeds",
11083
+ file: "x-search",
11084
+ method: "GET",
11085
+ path: "/api/v1/social-feeds/x/search",
11086
+ tier: "alternative",
11087
+ required_subscription_tier: "pro",
11088
+ access: "pro_only",
11089
+ pro_required: true
11090
+ },
11091
+ {
11092
+ skill: "arrays-data-api-spot-market-price-and-volume",
11093
+ file: "stocks-non-us-kline",
11094
+ method: "GET",
11095
+ path: "/api/v1/stocks/non-us/kline",
11096
+ tier: "public",
11097
+ required_subscription_tier: "free",
11098
+ access: "free_and_pro",
11099
+ pro_required: false
10998
11100
  }
10999
11101
  ];
11000
11102
  function getSkillEndpointMetadata(skill, file) {
@@ -11605,6 +11707,160 @@ var FeedbackResource = class {
11605
11707
  }
11606
11708
  };
11607
11709
 
11710
+ // src/resources/functions.ts
11711
+ var FunctionsResource = class {
11712
+ constructor(client) {
11713
+ this.client = client;
11714
+ }
11715
+ client;
11716
+ async register(params) {
11717
+ this.client._requireAuth();
11718
+ return this.client._request("POST", "/api/v1/service/functions", {
11719
+ body: {
11720
+ playbook_id: params.playbook_id,
11721
+ function_name: params.function_name,
11722
+ entry_script_path: params.entry_script_path,
11723
+ params_schema: params.params_schema,
11724
+ allow_charges: params.allow_charges
11725
+ }
11726
+ });
11727
+ }
11728
+ async list(params) {
11729
+ this.client._requireAuth();
11730
+ return this.client._request("GET", "/api/v1/service/functions", {
11731
+ query: {
11732
+ playbook_id: params.playbook_id
11733
+ }
11734
+ });
11735
+ }
11736
+ async delete(params) {
11737
+ this.client._requireAuth();
11738
+ await this.client._request("DELETE", "/api/v1/service/functions", {
11739
+ query: {
11740
+ playbook_id: params.playbook_id,
11741
+ function_name: params.function_name
11742
+ }
11743
+ });
11744
+ }
11745
+ async invoke(params) {
11746
+ this.client._requireAuth();
11747
+ const response = await this.client._request(
11748
+ "POST",
11749
+ "/api/v1/service/invoke",
11750
+ {
11751
+ body: {
11752
+ playbook_id: params.playbook_id,
11753
+ function_name: params.function_name,
11754
+ parameters_json: JSON.stringify(params.parameters ?? {})
11755
+ }
11756
+ }
11757
+ );
11758
+ return {
11759
+ ...response,
11760
+ result: parseResultPayload(response.result)
11761
+ };
11762
+ }
11763
+ async getAllowance(params) {
11764
+ this.client._requireAuth();
11765
+ const response = await this.client._request(
11766
+ "GET",
11767
+ "/api/v1/service/allowance",
11768
+ {
11769
+ query: {
11770
+ playbook_id: params.playbook_id
11771
+ }
11772
+ }
11773
+ );
11774
+ return normalizeAllowance(response.allowance);
11775
+ }
11776
+ async listAllowances() {
11777
+ this.client._requireAuth();
11778
+ const response = await this.client._request(
11779
+ "GET",
11780
+ "/api/v1/service/allowances"
11781
+ );
11782
+ return {
11783
+ allowances: (response.allowances ?? []).map((allowance) => normalizeAllowance(allowance)).filter(
11784
+ (allowance) => allowance !== null
11785
+ )
11786
+ };
11787
+ }
11788
+ async createAllowance(params) {
11789
+ this.client._requireAuth();
11790
+ const response = await this.client._request(
11791
+ "POST",
11792
+ "/api/v1/service/allowance",
11793
+ {
11794
+ body: {
11795
+ playbook_id: params.playbook_id,
11796
+ amount: params.amount
11797
+ }
11798
+ }
11799
+ );
11800
+ return { allowance: requireAllowance(response.allowance) };
11801
+ }
11802
+ async revokeAllowance(params) {
11803
+ this.client._requireAuth();
11804
+ await this.client._request("DELETE", "/api/v1/service/allowance", {
11805
+ query: {
11806
+ playbook_id: params.playbook_id
11807
+ }
11808
+ });
11809
+ return { ok: true };
11810
+ }
11811
+ };
11812
+ function normalizeAllowance(raw) {
11813
+ if (!raw) return null;
11814
+ const allowance = {
11815
+ id: raw.id ?? "",
11816
+ consumer_uid: raw.consumer_uid ?? raw.consumerUid ?? "",
11817
+ playbook_id: raw.playbook_id ?? raw.playbookId ?? "",
11818
+ amount: raw.amount ?? 0,
11819
+ used: raw.used ?? 0,
11820
+ remaining: raw.remaining ?? 0
11821
+ };
11822
+ const createdAtMs = timestampMs(
11823
+ raw.created_at_ms ?? raw.createdAtMs ?? raw.created_at ?? raw.createdAt
11824
+ );
11825
+ const updatedAtMs = timestampMs(
11826
+ raw.updated_at_ms ?? raw.updatedAtMs ?? raw.updated_at ?? raw.updatedAt
11827
+ );
11828
+ if (createdAtMs !== void 0) allowance.created_at_ms = createdAtMs;
11829
+ if (updatedAtMs !== void 0) allowance.updated_at_ms = updatedAtMs;
11830
+ return allowance;
11831
+ }
11832
+ function requireAllowance(raw) {
11833
+ const allowance = normalizeAllowance(raw);
11834
+ if (!allowance) {
11835
+ throw new Error("allowance response missing allowance");
11836
+ }
11837
+ return allowance;
11838
+ }
11839
+ function timestampMs(value) {
11840
+ if (value === void 0 || value === null) return void 0;
11841
+ if (typeof value === "number" && Number.isFinite(value)) return value;
11842
+ if (typeof value === "string") {
11843
+ const numeric = Number(value);
11844
+ if (Number.isFinite(numeric)) return numeric;
11845
+ const parsed = Date.parse(value);
11846
+ return Number.isNaN(parsed) ? void 0 : parsed;
11847
+ }
11848
+ if (typeof value !== "object") return void 0;
11849
+ const ts = value;
11850
+ const seconds = typeof ts.seconds === "number" ? ts.seconds : typeof ts.seconds === "string" ? Number(ts.seconds) : void 0;
11851
+ const nanos = typeof ts.nanos === "number" ? ts.nanos : typeof ts.nanos === "string" ? Number(ts.nanos) : 0;
11852
+ if (seconds === void 0 || !Number.isFinite(seconds)) return void 0;
11853
+ return seconds * 1e3 + Math.floor((Number.isFinite(nanos) ? nanos : 0) / 1e6);
11854
+ }
11855
+ function parseResultPayload(result) {
11856
+ if (typeof result !== "string") return result;
11857
+ try {
11858
+ return JSON.parse(result);
11859
+ } catch {
11860
+ return result;
11861
+ }
11862
+ }
11863
+
11608
11864
  // src/client.ts
11609
11865
  var DEFAULT_BASE_URL = "https://api-llm.prd.alva.ai";
11610
11866
  var DEFAULT_ARRAYS_BASE_URL = "https://data-tools.prd.space.id";
@@ -11639,6 +11895,7 @@ var AlvaClient = class {
11639
11895
  _subscriptions;
11640
11896
  _channelGroupSubscriptions;
11641
11897
  _feedback;
11898
+ _functions;
11642
11899
  constructor(config) {
11643
11900
  this.baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;
11644
11901
  this.arraysBaseUrl = config.arraysBaseUrl ?? DEFAULT_ARRAYS_BASE_URL;
@@ -11715,6 +11972,9 @@ var AlvaClient = class {
11715
11972
  get feedback() {
11716
11973
  return this._feedback ??= new FeedbackResource(this);
11717
11974
  }
11975
+ get functions() {
11976
+ return this._functions ??= new FunctionsResource(this);
11977
+ }
11718
11978
  _requireAuth() {
11719
11979
  if (!this.pbsvToken && !this.viewer_token && !this.apiKey) {
11720
11980
  throw new AlvaError(
@@ -12568,7 +12828,7 @@ function formatPlaybookSkillFile(file) {
12568
12828
  import * as fs2 from "fs";
12569
12829
  import * as os2 from "os";
12570
12830
  import * as fsPromises2 from "fs/promises";
12571
- var CLI_VERSION = true ? "0.11.2" : "dev";
12831
+ var CLI_VERSION = true ? "0.11.3-beta.0" : "dev";
12572
12832
  function isVersionOlderThan(a, b) {
12573
12833
  const parse4 = (v) => {
12574
12834
  if (!v) return null;
@@ -12599,6 +12859,7 @@ Commands:
12599
12859
  lint Design-system lint (playbook)
12600
12860
  feed Feed lifecycle management (delete)
12601
12861
  playbooks Playbook discovery (trending) and visibility
12862
+ functions Playbook UDF function management (register, list, delete, invoke, allowance)
12602
12863
  secrets Secret management (create, list, get, update, delete)
12603
12864
  sdk SDK documentation (doc, partitions, partition-summary)
12604
12865
  skillhub Playbook skills (list, tags, get, file)
@@ -12705,6 +12966,7 @@ Response fields:
12705
12966
  username Username (used in ALFS paths and playbook URLs)
12706
12967
  subscription_tier "free" or "pro" \u2014 determines release flow and feature gates
12707
12968
  telegram_username Telegram username if connected, null otherwise
12969
+ slack_username Slack display name if connected, null otherwise
12708
12970
 
12709
12971
  Examples:
12710
12972
  alva user me`,
@@ -12961,6 +13223,66 @@ Examples:
12961
13223
  alva playbooks trending --tag btc --cursor abc
12962
13224
  alva playbooks set-visibility --name my-scanner --visibility private
12963
13225
  alva playbooks set-visibility --name my-scanner --visibility public`,
13226
+ functions: `Usage: alva functions <subcommand> [options]
13227
+
13228
+ Register and manage playbook UDF functions. These are creator-owned functions
13229
+ that released playbook HTML invokes through window.alva.udf.
13230
+
13231
+ Subcommands:
13232
+ register Register or update a function on a playbook
13233
+ list List registered functions for a playbook
13234
+ delete Delete a registered function
13235
+ invoke Invoke a registered function with creator/session auth
13236
+ allowance Manage your viewer credit allowance for a playbook
13237
+
13238
+ Register flags:
13239
+ --playbook-id <id> Numeric playbook id (required)
13240
+ --function-name <name> Function name exposed to window.alva.udf (required)
13241
+ --entry-script-path <path> Absolute ALFS path to a .js entry script (required)
13242
+ --params-schema <json> JSON Schema object/string for parameters_json
13243
+ --params-schema-file <path> Read JSON Schema from a local file
13244
+ --allow-charges Allow this function to charge viewer allowance
13245
+ --no-allow-charges Explicitly register as no-charge
13246
+
13247
+ List flags:
13248
+ --playbook-id <id> Numeric playbook id (required)
13249
+
13250
+ Delete flags:
13251
+ --playbook-id <id> Numeric playbook id (required)
13252
+ --function-name <name> Function name to delete (required)
13253
+
13254
+ Invoke flags:
13255
+ --playbook-id <id> Numeric playbook id (required)
13256
+ --function-name <name> Function name to invoke (required)
13257
+ --params <json> Parameters object passed as parameters_json
13258
+
13259
+ Allowance subcommands:
13260
+ allowance get Get your allowance for a playbook
13261
+ allowance list List your allowances
13262
+ allowance create Create or update your allowance for a playbook
13263
+ allowance revoke Revoke your allowance for a playbook
13264
+
13265
+ Allowance flags:
13266
+ --playbook-id <id> Numeric playbook id (required for get/create/revoke)
13267
+ --amount <credits> Positive integer allowance amount (required for create)
13268
+
13269
+ Notes:
13270
+ entry_script_path must be an absolute ALFS path under your home, such as
13271
+ /alva/home/alice/playbooks/my-playbook/udf/analyze.js. Use alva whoami to
13272
+ discover home_path. Use the browser runtime window.alva.udf for released
13273
+ playbook UI; this CLI is mainly for creator-side setup and smoke tests.
13274
+ Allowance commands use the gateway GraphQL session-user surface and reject
13275
+ playbook-scoped viewer tokens.
13276
+
13277
+ Examples:
13278
+ alva functions register --playbook-id 123 --function-name analyze --entry-script-path /alva/home/alice/playbooks/my-playbook/udf/analyze.js --params-schema-file ./schema.json --no-allow-charges
13279
+ alva functions list --playbook-id 123
13280
+ alva functions delete --playbook-id 123 --function-name analyze
13281
+ alva functions invoke --playbook-id 123 --function-name analyze --params '{"ticker":"AAPL"}'
13282
+ alva functions allowance create --playbook-id 123 --amount 25
13283
+ alva functions allowance get --playbook-id 123
13284
+ alva functions allowance list
13285
+ alva functions allowance revoke --playbook-id 123`,
12964
13286
  release: `Usage: alva release <subcommand> [options]
12965
13287
 
12966
13288
  Publish feeds and playbooks to the Alva platform. The typical workflow:
@@ -13466,6 +13788,7 @@ var BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
13466
13788
  "help",
13467
13789
  "execute-latest",
13468
13790
  "dry-run",
13791
+ "allow-charges",
13469
13792
  "json",
13470
13793
  "compress",
13471
13794
  "bypass-lint",
@@ -13531,6 +13854,17 @@ function requireNumericFlag(flags, name, command) {
13531
13854
  }
13532
13855
  return n;
13533
13856
  }
13857
+ function requirePositiveIntegerFlag(flags, name, command) {
13858
+ const val = requireFlag(flags, name, command);
13859
+ if (!/^[1-9]\d*$/.test(val)) {
13860
+ const group = command.split(" ")[0];
13861
+ throw new CliUsageError(
13862
+ `--${name} must be a positive integer for '${command}', got '${val}'`,
13863
+ group
13864
+ );
13865
+ }
13866
+ return Number(val);
13867
+ }
13534
13868
  function requirePositiveIntegerStringFlag(flags, name, command) {
13535
13869
  const val = requireFlag(flags, name, command);
13536
13870
  if (!/^[1-9]\d*$/.test(val)) {
@@ -13620,6 +13954,39 @@ function jsonObjectFlag(flags, name, command) {
13620
13954
  }
13621
13955
  return parsed;
13622
13956
  }
13957
+ function jsonRequiredFlag(flags, name, command) {
13958
+ const raw = requireFlag(flags, name, command);
13959
+ try {
13960
+ return JSON.parse(raw);
13961
+ } catch {
13962
+ throw new CliUsageError(
13963
+ `--${name} must be valid JSON for '${command}'`,
13964
+ command.split(" ")[0]
13965
+ );
13966
+ }
13967
+ }
13968
+ function jsonSchemaStringFlag(flags, command) {
13969
+ const inlineSchema = flags["params-schema"];
13970
+ const schemaFile = flags["params-schema-file"];
13971
+ if (inlineSchema !== void 0 && schemaFile !== void 0) {
13972
+ throw new CliUsageError(
13973
+ "--params-schema and --params-schema-file are mutually exclusive",
13974
+ command.split(" ")[0]
13975
+ );
13976
+ }
13977
+ const raw = schemaFile !== void 0 ? fs2.readFileSync(schemaFile, "utf-8") : inlineSchema;
13978
+ if (raw === void 0) return void 0;
13979
+ try {
13980
+ JSON.parse(raw);
13981
+ } catch {
13982
+ const flag = schemaFile !== void 0 ? "params-schema-file" : "params-schema";
13983
+ throw new CliUsageError(
13984
+ `--${flag} must contain valid JSON for '${command}'`,
13985
+ command.split(" ")[0]
13986
+ );
13987
+ }
13988
+ return raw;
13989
+ }
13623
13990
  async function dispatch(client, args, meta) {
13624
13991
  const group = args[0];
13625
13992
  if (!group || group === "--help" || group === "-h") {
@@ -13910,6 +14277,119 @@ async function dispatch(client, args, meta) {
13910
14277
  );
13911
14278
  }
13912
14279
  }
14280
+ case "functions": {
14281
+ if (!subcommand)
14282
+ throw new CliUsageError(
14283
+ "Missing subcommand for functions",
14284
+ "functions"
14285
+ );
14286
+ switch (subcommand) {
14287
+ case "allowance": {
14288
+ const leaf = args[2];
14289
+ if (!leaf || leaf === "--help" || leaf === "-h") {
14290
+ return { _help: true, text: COMMAND_HELP.functions };
14291
+ }
14292
+ switch (leaf) {
14293
+ case "get":
14294
+ return client.functions.getAllowance({
14295
+ playbook_id: requireNumericFlag(
14296
+ flags,
14297
+ "playbook-id",
14298
+ "functions allowance get"
14299
+ )
14300
+ });
14301
+ case "list":
14302
+ return client.functions.listAllowances();
14303
+ case "create":
14304
+ return client.functions.createAllowance({
14305
+ playbook_id: requireNumericFlag(
14306
+ flags,
14307
+ "playbook-id",
14308
+ "functions allowance create"
14309
+ ),
14310
+ amount: requirePositiveIntegerFlag(
14311
+ flags,
14312
+ "amount",
14313
+ "functions allowance create"
14314
+ )
14315
+ });
14316
+ case "revoke":
14317
+ return client.functions.revokeAllowance({
14318
+ playbook_id: requireNumericFlag(
14319
+ flags,
14320
+ "playbook-id",
14321
+ "functions allowance revoke"
14322
+ )
14323
+ });
14324
+ default:
14325
+ throw new CliUsageError(
14326
+ `Unknown subcommand: functions allowance ${leaf}`,
14327
+ "functions"
14328
+ );
14329
+ }
14330
+ }
14331
+ case "register":
14332
+ return client.functions.register({
14333
+ playbook_id: requireNumericFlag(
14334
+ flags,
14335
+ "playbook-id",
14336
+ "functions register"
14337
+ ),
14338
+ function_name: requireFlag(
14339
+ flags,
14340
+ "function-name",
14341
+ "functions register"
14342
+ ),
14343
+ entry_script_path: requireFlag(
14344
+ flags,
14345
+ "entry-script-path",
14346
+ "functions register"
14347
+ ),
14348
+ params_schema: jsonSchemaStringFlag(flags, "functions register"),
14349
+ allow_charges: boolFlag(flags["allow-charges"])
14350
+ });
14351
+ case "list":
14352
+ return client.functions.list({
14353
+ playbook_id: requireNumericFlag(
14354
+ flags,
14355
+ "playbook-id",
14356
+ "functions list"
14357
+ )
14358
+ });
14359
+ case "delete":
14360
+ return client.functions.delete({
14361
+ playbook_id: requireNumericFlag(
14362
+ flags,
14363
+ "playbook-id",
14364
+ "functions delete"
14365
+ ),
14366
+ function_name: requireFlag(
14367
+ flags,
14368
+ "function-name",
14369
+ "functions delete"
14370
+ )
14371
+ });
14372
+ case "invoke":
14373
+ return client.functions.invoke({
14374
+ playbook_id: requireNumericFlag(
14375
+ flags,
14376
+ "playbook-id",
14377
+ "functions invoke"
14378
+ ),
14379
+ function_name: requireFlag(
14380
+ flags,
14381
+ "function-name",
14382
+ "functions invoke"
14383
+ ),
14384
+ parameters: flags["params"] === void 0 ? void 0 : jsonRequiredFlag(flags, "params", "functions invoke")
14385
+ });
14386
+ default:
14387
+ throw new CliUsageError(
14388
+ `Unknown subcommand: functions ${subcommand}`,
14389
+ "functions"
14390
+ );
14391
+ }
14392
+ }
13913
14393
  case "release": {
13914
14394
  if (!subcommand)
13915
14395
  throw new CliUsageError("Missing subcommand for release", "release");