palbase 0.4.0 → 0.5.1

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.
Files changed (61) hide show
  1. package/dist/ai/index.js +10 -10
  2. package/dist/backend/engine.js +2 -2
  3. package/dist/backend/env.js +1 -1
  4. package/dist/backend/index.js +8 -8
  5. package/dist/backend/stack.js +1 -1
  6. package/dist/backend/test.js +2 -2
  7. package/dist/chunks/{TRHIZOIS.js → 32RCJNOH.js} +3 -3
  8. package/dist/chunks/{BJL2FT5W.js → 3AUBDHV2.js} +1 -1
  9. package/dist/chunks/{IVDNNHII.js → 7BA7LGEM.js} +2 -2
  10. package/dist/chunks/A7EL6JKQ.js +20 -0
  11. package/dist/chunks/AWHTWL65.js +2 -0
  12. package/dist/chunks/{2AT72FFB.js → B45UFKBR.js} +2 -2
  13. package/dist/chunks/{ST2NZ4TZ.js → DNHDO6AJ.js} +1 -1
  14. package/dist/chunks/{BHT2IHBE.js → EHJKMDP3.js} +2 -2
  15. package/dist/chunks/{3OIKIBMG.js → FSXD7MN3.js} +2 -2
  16. package/dist/chunks/{SUNHFMDO.js → KSJ6AMCG.js} +2 -2
  17. package/dist/chunks/PALOWH6U.js +6 -0
  18. package/dist/chunks/{RKNVSAGY.js → PFSUOVTB.js} +1 -1
  19. package/dist/chunks/{6JO3UVPT.js → QIN2NQPN.js} +2 -2
  20. package/dist/chunks/{FS222NNP.js → R43DXJZE.js} +2 -2
  21. package/dist/chunks/{ODFLUINN.js → TTZRGQWF.js} +1 -1
  22. package/dist/chunks/{UNTTPATW.js → ZXYDN6NA.js} +1 -1
  23. package/dist/cli.js +133 -129
  24. package/dist/refuse/ai.js +1 -1
  25. package/dist/refuse/backend.js +1 -1
  26. package/dist/refuse/server.js +1 -1
  27. package/dist/server/index.js +2 -2
  28. package/dist/server/testing.js +2 -2
  29. package/dist/web/index.js +2 -2
  30. package/dist/web/palbe.js +2 -2
  31. package/dist/web/paywall.js +2 -2
  32. package/dist/web/vite.js +2 -2
  33. package/package.json +2 -2
  34. package/types/ai/src/ai.d.ts +20 -2
  35. package/types/ai/src/chats.d.ts +75 -1
  36. package/types/ai/src/index.d.ts +2 -2
  37. package/types/ai/src/tools.d.ts +35 -0
  38. package/types/backend/src/channels.d.ts +81 -0
  39. package/types/backend/src/container.d.ts +4 -2
  40. package/types/backend/src/decorators.d.ts +32 -17
  41. package/types/backend/src/engine.d.ts +12 -4
  42. package/types/backend/src/env.d.ts +1 -1
  43. package/types/backend/src/index.d.ts +4 -2
  44. package/types/backend/src/openapi.d.ts +3 -0
  45. package/types/backend/src/rooms.d.ts +10 -0
  46. package/types/backend/src/tasks.d.ts +168 -0
  47. package/types/internal/src/chat.d.ts +17 -1
  48. package/types/internal/src/modules/ai.d.ts +314 -0
  49. package/types/internal/src/modules/auth.d.ts +64 -47
  50. package/types/internal/src/modules/machines.d.ts +320 -79
  51. package/types/internal/src/modules/notify.d.ts +3 -3
  52. package/types/internal/src/modules/purchases.d.ts +562 -3
  53. package/types/internal/src/modules/storage.d.ts +32 -3
  54. package/types/web/src/ai.d.ts +25 -2
  55. package/types/web/src/client.d.ts +7 -0
  56. package/types/web/src/index.d.ts +1 -1
  57. package/types/web/src/paywall/placement.d.ts +2 -0
  58. package/types/web/src/purchases.d.ts +3 -1
  59. package/dist/chunks/CY6B75KF.js +0 -6
  60. package/dist/chunks/EGRDFD5C.js +0 -20
  61. package/dist/chunks/ZFX4BFQR.js +0 -2
@@ -93,6 +93,7 @@ export type Chat = {
93
93
  * Its title.
94
94
  */
95
95
  title: string;
96
+ workspace?: ChatWorkspace;
96
97
  };
97
98
  /**
98
99
  * Chats, the newest first (100 at most).
@@ -152,6 +153,19 @@ export type ChatMessage = {
152
153
  */
153
154
  text: string;
154
155
  };
156
+ /**
157
+ * One repository of a chat's workspace.
158
+ */
159
+ export type ChatRepo = {
160
+ /**
161
+ * The branch it is checked out at and pushed to (the repository's default unless said).
162
+ */
163
+ branch?: string;
164
+ /**
165
+ * The project's name for the repository (PUT /ai/repos/{name}).
166
+ */
167
+ repo: string;
168
+ };
155
169
  /**
156
170
  * A chat to start.
157
171
  */
@@ -179,6 +193,20 @@ export type ChatRequest = {
179
193
  * Its title (256 bytes at most).
180
194
  */
181
195
  title?: string;
196
+ workspace?: ChatWorkspace;
197
+ };
198
+ /**
199
+ * The project's repositories a chat works in, each at a branch: its turns run on a machine of the platform's with them checked out, and what its agent commits is pushed to that branch.
200
+ */
201
+ export type ChatWorkspace = {
202
+ /**
203
+ * Lets the agent push its commits to the branches without a person's yes — the server's choice for the chat: its members' messages then reach the repository. Without it a push waits for a member's approval.
204
+ */
205
+ auto_push?: boolean;
206
+ /**
207
+ * 1 to 8 of the project's repositories, each once.
208
+ */
209
+ repos: ChatRepo[];
182
210
  };
183
211
  /**
184
212
  * A decision made.
@@ -609,6 +637,7 @@ export type MessageRequest = {
609
637
  * The member the server writes as (the server's alone).
610
638
  */
611
639
  as?: string;
640
+ budget?: TurnBudget;
612
641
  /**
613
642
  * The writer's own id for it: sent again — a retry, a second tab — it is the same message, delivered once.
614
643
  */
@@ -687,6 +716,54 @@ export type ProviderList = {
687
716
  */
688
717
  providers: Provider[];
689
718
  };
719
+ /**
720
+ * A GitHub repository the project's chats work in, by the project's name for it; the project's backend gives its tokens (the framework's ai.repo), asked at each clone and each push.
721
+ */
722
+ export type Repo = {
723
+ /**
724
+ * The project's machine that gives its tokens.
725
+ */
726
+ backend: string;
727
+ /**
728
+ * When it was put first.
729
+ */
730
+ created_at: string;
731
+ /**
732
+ * The branch a workspace takes when it names none.
733
+ */
734
+ default_branch: string;
735
+ /**
736
+ * The project's name for it.
737
+ */
738
+ name: string;
739
+ /**
740
+ * The GitHub repository, owner/name.
741
+ */
742
+ repository: string;
743
+ };
744
+ /**
745
+ * The project's repositories.
746
+ */
747
+ export type RepoPage = {
748
+ repos: Repo[];
749
+ };
750
+ /**
751
+ * A repository the project's chats work in.
752
+ */
753
+ export type RepoRequest = {
754
+ /**
755
+ * The project's machine whose framework gives the repository's tokens (backend unless said).
756
+ */
757
+ backend?: string;
758
+ /**
759
+ * The branch a workspace takes when it names none (main unless said).
760
+ */
761
+ default_branch?: string;
762
+ /**
763
+ * The GitHub repository, owner/name.
764
+ */
765
+ repository: string;
766
+ };
690
767
  /**
691
768
  * A response.
692
769
  */
@@ -1027,6 +1104,83 @@ export type ToolRef = {
1027
1104
  */
1028
1105
  source: "backend" | "https" | "mcp" | "client";
1029
1106
  };
1107
+ /**
1108
+ * One artifact a turn's agent published.
1109
+ */
1110
+ export type TurnArtifact = {
1111
+ /**
1112
+ * Its digest (sha256:<hex>).
1113
+ */
1114
+ checksum: string;
1115
+ /**
1116
+ * When it was published.
1117
+ */
1118
+ created_at: string;
1119
+ /**
1120
+ * The artifact.
1121
+ */
1122
+ id: string;
1123
+ /**
1124
+ * What it is to the engine, when it says.
1125
+ */
1126
+ logical_type?: string;
1127
+ /**
1128
+ * Its media type, as published.
1129
+ */
1130
+ media_type: string;
1131
+ /**
1132
+ * Its size.
1133
+ */
1134
+ size_bytes: number;
1135
+ };
1136
+ /**
1137
+ * A turn's artifacts.
1138
+ */
1139
+ export type TurnArtifacts = {
1140
+ artifacts: TurnArtifact[];
1141
+ };
1142
+ /**
1143
+ * What the turn a message starts may cost at most, its subagents' spend counted (the server's alone): past it the engine stops the turn. A message delivered into a turn already running takes that turn's.
1144
+ */
1145
+ export type TurnBudget = {
1146
+ /**
1147
+ * US dollars, more than 0 and at most 100000; rounded up to the cent.
1148
+ */
1149
+ max_cost_usd: number;
1150
+ };
1151
+ /**
1152
+ * What one turn of a chat cost so far: its model calls and its subagents', at the engine's frozen rates.
1153
+ */
1154
+ export type TurnCost = {
1155
+ /**
1156
+ * The chat.
1157
+ */
1158
+ chat_id: string;
1159
+ /**
1160
+ * What they cost, in billionths of a US dollar.
1161
+ */
1162
+ cost_nano_usd: number;
1163
+ /**
1164
+ * Nothing more of the turn's use can be settled: false while it or a subagent of it runs.
1165
+ */
1166
+ final: boolean;
1167
+ /**
1168
+ * Input tokens of the turn and its subagents.
1169
+ */
1170
+ input_tokens: number;
1171
+ /**
1172
+ * Output tokens of the turn and its subagents.
1173
+ */
1174
+ output_tokens: number;
1175
+ /**
1176
+ * The turn.
1177
+ */
1178
+ response_id: string;
1179
+ /**
1180
+ * A model of the turn has no price: the cost is a lower bound.
1181
+ */
1182
+ unpriced: boolean;
1183
+ };
1030
1184
  /**
1031
1185
  * A page of uses.
1032
1186
  */
@@ -1089,6 +1243,61 @@ export type Use = {
1089
1243
  */
1090
1244
  response_id: string | null;
1091
1245
  };
1246
+ /**
1247
+ * Text for the voice.
1248
+ */
1249
+ export type VoiceCommand = {
1250
+ /**
1251
+ * The delegated voice part this answers (speak).
1252
+ */
1253
+ delegation_id?: string;
1254
+ /**
1255
+ * What it is given (16 KiB at most).
1256
+ */
1257
+ text: string;
1258
+ /**
1259
+ * speak (say this), know (keep it in mind) or instruct (behave so).
1260
+ */
1261
+ type: "speak" | "know" | "instruct";
1262
+ };
1263
+ /**
1264
+ * Starts the chat's live voice.
1265
+ */
1266
+ export type VoiceRequest = {
1267
+ /**
1268
+ * The app's WebRTC offer (an SDP).
1269
+ */
1270
+ sdp: string;
1271
+ /**
1272
+ * The voice (the provider's default unless said).
1273
+ */
1274
+ voice?: string;
1275
+ };
1276
+ /**
1277
+ * A chat's live voice.
1278
+ */
1279
+ export type VoiceSession = {
1280
+ /**
1281
+ * The chat.
1282
+ */
1283
+ chat_id: string;
1284
+ /**
1285
+ * The voice session.
1286
+ */
1287
+ id: string;
1288
+ /**
1289
+ * The provider's WebRTC answer, for the app's peer connection (on start).
1290
+ */
1291
+ sdp?: string;
1292
+ /**
1293
+ * How long it lasted (on close).
1294
+ */
1295
+ seconds: number;
1296
+ /**
1297
+ * active, or closed.
1298
+ */
1299
+ status?: string;
1300
+ };
1092
1301
  /** The events this module sends the project's webhooks (x-palbase-events), by type: each one's payload, the event's data. */
1093
1302
  export interface Events {
1094
1303
  /**
@@ -1293,6 +1502,80 @@ export declare function client(t: Transport): {
1293
1502
  body: ToolOutput; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1294
1503
  signal?: AbortSignal;
1295
1504
  }): Promise<Reply<200, ToolOutputAccepted>>;
1505
+ /**
1506
+ * A turn's artifacts
1507
+ *
1508
+ * What the turn's agent published as its output (palai.artifact.publish) — a build's product from the workspace's Mac, a screenshot, a report — kept in the project's own storage. The chat's members and the project's server read it, as they read the chat.
1509
+ */
1510
+ listChatTurnArtifacts(input: {
1511
+ path: {
1512
+ chat_id: string; /** The turn: a message's response_id, or a turn event's. */
1513
+ response_id: string;
1514
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1515
+ signal?: AbortSignal;
1516
+ }): Promise<Reply<200, TurnArtifacts>>;
1517
+ /**
1518
+ * An artifact of a turn
1519
+ *
1520
+ * One artifact of the turn, its bytes as the agent published them (an attachment, never a page). One the turn did not publish is not found (404 artifact_not_found).
1521
+ */
1522
+ getChatTurnArtifact(input: {
1523
+ path: {
1524
+ chat_id: string; /** The turn: a message's response_id, or a turn event's. */
1525
+ response_id: string; /** The artifact: an id of the turn's artifacts. */
1526
+ artifact_id: string;
1527
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1528
+ signal?: AbortSignal;
1529
+ }): Promise<Reply<200, Response>>;
1530
+ /**
1531
+ * What a turn of a chat cost
1532
+ *
1533
+ * What a turn of the chat cost so far, its subagents' calls counted — while it runs too (final false) — or what one subagent's work in it cost (an agent event's response_id). The project's server's: a member's key is refused (403 server_only).
1534
+ */
1535
+ getChatTurnCost(input: {
1536
+ path: {
1537
+ chat_id: string; /** The turn: a message's response_id, or a turn event's. */
1538
+ response_id: string;
1539
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1540
+ signal?: AbortSignal;
1541
+ }): Promise<Reply<200, TurnCost>>;
1542
+ /**
1543
+ * Start a chat's voice
1544
+ *
1545
+ * Starts the chat's live voice: the app's WebRTC offer in, the answer out — the audio then goes between the app and the platform's voice provider. What is said either way is in the chat's stream as voice parts (transcripts); a task the voice hands over is a voice part of kind delegated. One voice a chat at a time (409 voice_active). A user starts at most 5 voices an hour in the project's chats (429 too_many_voices, with Retry-After) — each is the project's spend while it lasts; the server's starts are not counted.
1546
+ */
1547
+ startChatVoice(input: {
1548
+ path: {
1549
+ chat_id: string;
1550
+ };
1551
+ body: VoiceRequest; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1552
+ signal?: AbortSignal;
1553
+ }): Promise<Reply<201, VoiceSession>>;
1554
+ /**
1555
+ * Close a chat's voice
1556
+ *
1557
+ * Ends the chat's voice; the answer says how long it lasted.
1558
+ */
1559
+ closeChatVoice(input: {
1560
+ path: {
1561
+ chat_id: string; /** The voice session. */
1562
+ voice_id: string;
1563
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1564
+ signal?: AbortSignal;
1565
+ }): Promise<Reply<200, VoiceSession>>;
1566
+ /**
1567
+ * Tell a chat's voice
1568
+ *
1569
+ * The server's alone (a member is answered 403 server_only): a member's words would be the agent's own to every other member of the chat. Gives the chat's voice text: speak says it, know keeps it in mind, instruct changes how it behaves — speak with a delegation_id answers a task it handed over.
1570
+ */
1571
+ commandChatVoice(input: {
1572
+ path: {
1573
+ chat_id: string; /** The voice session. */
1574
+ voice_id: string;
1575
+ };
1576
+ body: VoiceCommand; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1577
+ signal?: AbortSignal;
1578
+ }): Promise<Reply<202, VoiceSession>>;
1296
1579
  /**
1297
1580
  * Turn texts into vectors
1298
1581
  *
@@ -1407,6 +1690,37 @@ export declare function client(t: Transport): {
1407
1690
  }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1408
1691
  signal?: AbortSignal;
1409
1692
  }): Promise<Reply<204, undefined>>;
1693
+ /**
1694
+ * The project's repositories
1695
+ *
1696
+ * The repositories the project's chats work in.
1697
+ */
1698
+ listRepos(input?: {
1699
+ signal?: AbortSignal;
1700
+ }): Promise<Reply<200, RepoPage>>;
1701
+ /**
1702
+ * Put a repository
1703
+ *
1704
+ * Puts a GitHub repository the project's chats work in. Its tokens come from the project's backend (the framework's ai.repo), asked at each clone and each push — none is kept.
1705
+ */
1706
+ putRepo(input: {
1707
+ path: {
1708
+ name: string;
1709
+ };
1710
+ body: RepoRequest; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1711
+ signal?: AbortSignal;
1712
+ }): Promise<Reply<200, Repo>>;
1713
+ /**
1714
+ * Delete a repository
1715
+ *
1716
+ * A chat's workspace checks it out no more.
1717
+ */
1718
+ deleteRepo(input: {
1719
+ path: {
1720
+ name: string;
1721
+ }; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
1722
+ signal?: AbortSignal;
1723
+ }): Promise<Reply<204, undefined>>;
1410
1724
  /**
1411
1725
  * Ask a model
1412
1726
  *
@@ -797,6 +797,28 @@ export type AppleWebCredentials = {
797
797
  export type ApproveRecoveryRequest = {
798
798
  token: string;
799
799
  };
800
+ export type AssetLinkStatement = {
801
+ /**
802
+ * `delegate_permission/common.get_login_creds`
803
+ */
804
+ relation: string[];
805
+ target: AssetLinkTarget;
806
+ };
807
+ export type AssetLinkTarget = {
808
+ namespace: "android_app";
809
+ /**
810
+ * The app's application ID
811
+ */
812
+ package_name: string;
813
+ /**
814
+ * The SHA-256 of each certificate the app is signed with, as Play Console prints it
815
+ */
816
+ sha256_cert_fingerprints: string[];
817
+ };
818
+ /**
819
+ * Digital Asset Links statements, one per Android app with a signing certificate.
820
+ */
821
+ export type AssetLinks = AssetLinkStatement[];
800
822
  /**
801
823
  * One request's App Attest evidence and the request it claims to be bound to.
802
824
  */
@@ -1428,6 +1450,10 @@ export type ErrorResponse = {
1428
1450
  * Human-readable explanation
1429
1451
  */
1430
1452
  error_description: string;
1453
+ /**
1454
+ * On a refused configuration (invalid_auth_config): each field refused, by its JSON Pointer in the request body, and why.
1455
+ */
1456
+ field_errors?: FieldError[];
1431
1457
  /**
1432
1458
  * Correlation ID for log/audit lookup
1433
1459
  */
@@ -1444,6 +1470,19 @@ export type ErrorResponse = {
1444
1470
  export type ExchangeCustomTokenRequest = {
1445
1471
  custom_token: string;
1446
1472
  };
1473
+ /**
1474
+ * A field the request body was refused for.
1475
+ */
1476
+ export type FieldError = {
1477
+ /**
1478
+ * Why the field was refused.
1479
+ */
1480
+ message: string;
1481
+ /**
1482
+ * The field, as a JSON Pointer into the request body (/providers/google/client_id).
1483
+ */
1484
+ pointer: string;
1485
+ };
1447
1486
  export type ForbiddenOrPowRequired = PowRequiredResponse | ErrorResponse;
1448
1487
  /**
1449
1488
  * A blocking hook: for its before.* event, auth calls the URL and waits for the verdict.
@@ -2078,6 +2117,31 @@ export type OIDCDiscovery = {
2078
2117
  token_endpoint_auth_signing_alg_values_supported?: string[];
2079
2118
  userinfo_endpoint: string;
2080
2119
  };
2120
+ /**
2121
+ * Where the page sends the browser: the CLI's listener, with the one-time code and the state. The CLI redeems the code at /oauth/token with its verifier and the same redirect_uri.
2122
+ */
2123
+ export type OwnerCLICode = {
2124
+ redirect_to: string;
2125
+ expires_in: number;
2126
+ };
2127
+ /**
2128
+ * The CLI's PKCE challenge (RFC 7636 §4.2).
2129
+ */
2130
+ export type OwnerCLICodeRequest = {
2131
+ /**
2132
+ * base64url of the SHA-256 of the CLI's verifier
2133
+ */
2134
+ code_challenge: string;
2135
+ code_challenge_method: "S256";
2136
+ /**
2137
+ * The CLI's listener (RFC 8252 §7.3): a loopback IP literal and a port from 1024 to 65535.
2138
+ */
2139
+ redirect_uri: string;
2140
+ /**
2141
+ * The CLI's state, sent back to its listener.
2142
+ */
2143
+ state: string;
2144
+ };
2081
2145
  /**
2082
2146
  * Form-encoded RFC 9126 PAR parameters. Additional fields are passed through to the AS.
2083
2147
  */
@@ -3371,53 +3435,6 @@ export type WebAuthnSignupBeginResponse = {
3371
3435
  */
3372
3436
  user_id: string;
3373
3437
  };
3374
- /**
3375
- * The CLI's PKCE challenge (RFC 7636 §4.2).
3376
- */
3377
- export type OwnerCLICodeRequest = {
3378
- /**
3379
- * base64url of the SHA-256 of the CLI's verifier
3380
- */
3381
- code_challenge: string;
3382
- code_challenge_method: "S256";
3383
- /**
3384
- * The CLI's listener (RFC 8252 §7.3): a loopback IP literal and a port from 1024 to 65535.
3385
- */
3386
- redirect_uri: string;
3387
- /**
3388
- * The CLI's state, sent back to its listener.
3389
- */
3390
- state: string;
3391
- };
3392
- /**
3393
- * Where the page sends the browser: the CLI's listener, with the one-time code and the state. The CLI redeems the code at /oauth/token with its verifier and the same redirect_uri.
3394
- */
3395
- export type OwnerCLICode = {
3396
- redirect_to: string;
3397
- expires_in: number;
3398
- };
3399
- /**
3400
- * Digital Asset Links statements, one per Android app with a signing certificate.
3401
- */
3402
- export type AssetLinks = AssetLinkStatement[];
3403
- export type AssetLinkStatement = {
3404
- /**
3405
- * `delegate_permission/common.get_login_creds`
3406
- */
3407
- relation: string[];
3408
- target: AssetLinkTarget;
3409
- };
3410
- export type AssetLinkTarget = {
3411
- namespace: "android_app";
3412
- /**
3413
- * The app's application ID
3414
- */
3415
- package_name: string;
3416
- /**
3417
- * The SHA-256 of each certificate the app is signed with, as Play Console prints it
3418
- */
3419
- sha256_cert_fingerprints: string[];
3420
- };
3421
3438
  /** Palbase Auth API */
3422
3439
  export declare function client(t: Transport): {
3423
3440
  /**