copilotz 1.0.0-rc.13 → 1.0.0-rc.14
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/CHANGELOG.md +16 -0
- package/README.md +2 -2
- package/hosts/orgs/mod.d.ts +3 -1
- package/hosts/orgs/mod.js +20 -0
- package/hosts/web/mod.d.ts +1 -1
- package/hosts/web/mod.js +1 -1
- package/hosts/web/orgs.d.ts +34 -0
- package/hosts/web/orgs.js +19 -1
- package/package.json +3 -3
- package/plugins/access/directory/actions/code.d.ts +4 -0
- package/plugins/access/directory/actions/code.js +135 -0
- package/plugins/access/directory/collections/credit-code.d.ts +114 -0
- package/plugins/access/directory/collections/credit-code.js +28 -0
- package/plugins/access/directory/mod.d.ts +1 -0
- package/plugins/access/directory/mod.js +7 -1
- package/plugins/access/spaces/actions/org.d.ts +1 -0
- package/plugins/access/spaces/actions/org.js +7 -0
- package/plugins/access/spaces/mod.js +2 -1
- package/plugins/agents/chat/contract.d.ts +3 -3
- package/plugins/agents/chat/processors/failed.js +6 -0
- package/plugins/agents/chat/shared/types.d.ts +11 -0
- package/plugins/agents/chat/views/web/composer.d.ts +7 -2
- package/plugins/agents/chat/views/web/composer.js +9 -1
- package/plugins/agents/chat/views/web/conversation.d.ts +3 -2
- package/plugins/agents/chat/views/web/conversation.js +1 -1
- package/plugins/agents/chat/views/web/home.d.ts +3 -2
- package/plugins/agents/chat/views/web/home.js +1 -1
- package/plugins/agents/chat/views/web/message.d.ts +9 -1
- package/plugins/agents/chat/views/web/message.js +9 -1
- package/plugins/agents/chat/views/web/style.d.ts +1 -1
- package/plugins/agents/chat/views/web/style.js +8 -0
- package/plugins/agents/chat/web.d.ts +5 -1
- package/plugins/agents/chat/web.js +5 -1
- package/plugins/agents/team/views/web/model-picker.js +9 -4
- package/plugins/billing/credits/actions/check.d.ts +4 -0
- package/plugins/billing/credits/actions/check.js +83 -0
- package/plugins/billing/credits/actions/manage.d.ts +9 -0
- package/plugins/billing/credits/actions/manage.js +266 -0
- package/plugins/billing/credits/actions/state.d.ts +2 -0
- package/plugins/billing/credits/actions/state.js +148 -0
- package/plugins/billing/credits/collections/credit.d.ts +110 -0
- package/plugins/billing/credits/collections/credit.js +31 -0
- package/plugins/billing/credits/collections/payment.d.ts +139 -0
- package/plugins/billing/credits/collections/payment.js +32 -0
- package/plugins/billing/credits/collections/plan.d.ts +408 -0
- package/plugins/billing/credits/collections/plan.js +93 -0
- package/plugins/billing/credits/collections/room.d.ts +85 -0
- package/plugins/billing/credits/collections/room.js +24 -0
- package/plugins/billing/credits/contract.d.ts +15 -0
- package/plugins/billing/credits/contract.js +11 -0
- package/plugins/billing/credits/mod.d.ts +30 -0
- package/plugins/billing/credits/mod.js +61 -0
- package/plugins/billing/credits/shared/apply.d.ts +66 -0
- package/plugins/billing/credits/shared/apply.js +102 -0
- package/plugins/billing/credits/shared/settings.d.ts +51 -0
- package/plugins/billing/credits/shared/settings.js +14 -0
- package/plugins/billing/credits/shared/standing.d.ts +71 -0
- package/plugins/billing/credits/shared/standing.js +235 -0
- package/plugins/billing/credits/shared/walk.d.ts +50 -0
- package/plugins/billing/credits/shared/walk.js +127 -0
- package/plugins/billing/credits/views/web/add.d.ts +25 -0
- package/plugins/billing/credits/views/web/add.js +92 -0
- package/plugins/billing/credits/views/web/budget.d.ts +16 -0
- package/plugins/billing/credits/views/web/budget.js +62 -0
- package/plugins/billing/credits/views/web/composer.d.ts +13 -0
- package/plugins/billing/credits/views/web/composer.js +64 -0
- package/plugins/billing/credits/views/web/history.d.ts +12 -0
- package/plugins/billing/credits/views/web/history.js +55 -0
- package/plugins/billing/credits/views/web/numbers.d.ts +224 -0
- package/plugins/billing/credits/views/web/numbers.js +250 -0
- package/plugins/billing/credits/views/web/org.d.ts +31 -0
- package/plugins/billing/credits/views/web/org.js +238 -0
- package/plugins/billing/credits/views/web/plan.d.ts +22 -0
- package/plugins/billing/credits/views/web/plan.js +65 -0
- package/plugins/billing/credits/views/web/staff.d.ts +20 -0
- package/plugins/billing/credits/views/web/staff.js +265 -0
- package/plugins/billing/credits/views/web/style.d.ts +9 -0
- package/plugins/billing/credits/views/web/style.js +186 -0
- package/plugins/billing/credits/views/web/types.d.ts +17 -0
- package/plugins/billing/credits/views/web/types.js +32 -0
- package/plugins/billing/credits/web.d.ts +12 -0
- package/plugins/billing/credits/web.js +33 -0
- package/plugins/billing/mod.d.ts +8 -3
- package/plugins/billing/mod.js +7 -3
- package/plugins/billing/stripe/actions/checkout.d.ts +3 -0
- package/plugins/billing/stripe/actions/checkout.js +171 -0
- package/plugins/billing/stripe/mod.d.ts +17 -0
- package/plugins/billing/stripe/mod.js +27 -0
- package/plugins/billing/stripe/shared/api.d.ts +14 -0
- package/plugins/billing/stripe/shared/api.js +42 -0
- package/plugins/billing/stripe/shared/events.d.ts +42 -0
- package/plugins/billing/stripe/shared/events.js +226 -0
- package/plugins/billing/stripe/shared/settings.d.ts +34 -0
- package/plugins/billing/stripe/shared/settings.js +10 -0
- package/plugins/billing/stripe/webhook.d.ts +17 -0
- package/plugins/billing/stripe/webhook.js +45 -0
- package/plugins/billing/usage/actions/quote.d.ts +6 -0
- package/plugins/billing/usage/actions/quote.js +45 -1
- package/plugins/billing/usage/actions/rerate.js +1 -0
- package/plugins/billing/usage/mod.d.ts +2 -0
- package/plugins/billing/usage/mod.js +4 -1
- package/plugins/billing/usage/shared/rate.d.ts +10 -3
- package/plugins/billing/usage/shared/rate.js +18 -3
- package/plugins/billing/usage/shared/settings.d.ts +11 -1
- package/plugins/billing/usage/shared/use.js +5 -0
- package/plugins/billing/usage/views/web/org.d.ts +10 -1
- package/plugins/billing/usage/views/web/org.js +16 -4
- package/plugins/billing/web.d.ts +3 -0
- package/plugins/billing/web.js +3 -0
- package/plugins/compute/apps/shared/publish.d.ts +0 -4
- package/plugins/compute/apps/shared/publish.js +12 -0
- package/plugins/compute/cloud/actions/create.js +6 -8
- package/plugins/compute/cloud/actions/pool-tick.js +2 -2
- package/plugins/compute/cloud/actions/tick.js +13 -3
- package/plugins/compute/cloud/actions/vms.d.ts +0 -2
- package/plugins/compute/cloud/actions/vms.js +1 -3
- package/plugins/compute/cloud/actions/wake.js +6 -0
- package/plugins/compute/cloud/mod.d.ts +2 -2
- package/plugins/compute/cloud/mod.js +2 -2
- package/plugins/compute/cloud/shared/may.d.ts +15 -7
- package/plugins/compute/cloud/shared/may.js +19 -20
- package/plugins/compute/cloud/shared/meter.d.ts +3 -0
- package/plugins/compute/cloud/shared/meter.js +8 -3
- package/plugins/compute/cloud/shared/settings.d.ts +0 -5
- package/plugins/compute/cloud/shared/settings.js +0 -1
- package/plugins/compute/cloud/shared/time.d.ts +2 -0
- package/plugins/compute/cloud/shared/time.js +2 -0
- package/plugins/compute/cloud/views/web/cloud.d.ts +4 -3
- package/plugins/compute/cloud/views/web/cloud.js +4 -3
- package/plugins/compute/cloud/views/web/new.d.ts +2 -2
- package/plugins/compute/cloud/views/web/new.js +19 -10
- package/plugins/compute/cloud/web.js +3 -2
- package/plugins/compute/computers/program/version.d.ts +1 -1
- package/plugins/compute/computers/program/version.js +1 -1
- package/plugins/compute/computers/resources/downloads.js +1 -1
- package/plugins/interfaces/web/shared/codes.d.ts +31 -0
- package/plugins/interfaces/web/shared/codes.js +44 -0
- package/plugins/interfaces/web/shared/style.d.ts +1 -1
- package/plugins/interfaces/web/shared/style.js +1 -0
- package/plugins/interfaces/web/views/console-codes.d.ts +14 -0
- package/plugins/interfaces/web/views/console-codes.js +159 -0
- package/plugins/interfaces/web/views/console.d.ts +4 -2
- package/plugins/interfaces/web/views/console.js +16 -5
- package/plugins/interfaces/web/views/org.js +8 -2
- package/plugins/models/actions/offered.d.ts +2 -0
- package/plugins/models/actions/offered.js +52 -6
- package/plugins/models/shared/generate.d.ts +2 -1
- package/plugins/models/shared/generate.js +26 -4
- package/plugins/models/shared/use.d.ts +6 -2
- package/plugins/models/shared/use.js +15 -5
- package/runtime/owner.js +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## 1.0.0-rc.14 — 2026-11-02
|
|
2
|
+
|
|
3
|
+
- **Credits** (`plugins/billing/credits`): what an org can spend. Plans, credits and payments are
|
|
4
|
+
its own rows, the balance is walked from them and the ledger, and one check stops model calls,
|
|
5
|
+
computers and builds at the limit, in plain words. Staff set plans, give credits, waive usage or
|
|
6
|
+
seats, and record payments; gift codes wait in the directory.
|
|
7
|
+
- **Stripe** (`plugins/billing/stripe`): Checkout, the customer portal and signed webhooks, for one
|
|
8
|
+
or more accounts. A subscription's credits come with its paid invoice.
|
|
9
|
+
- **Prices:** a use on an org's own key costs nothing; a plan can name a price list; `usage.quotes`;
|
|
10
|
+
the model picker shows the org's real price.
|
|
11
|
+
- **Removed:** the cloud plugin's `create` and `budgetUsd` settings. Anyone in an org but its guests
|
|
12
|
+
makes a computer; what the org can spend keeps the cost.
|
|
13
|
+
- **Fixed:** model use listeners are awaited, so a late record isn't lost; a VM's seconds stop at
|
|
14
|
+
its lease, so an org closed for days isn't charged for a VM long gone.
|
|
15
|
+
- `composerNotes`, a note above the composer from another front end.
|
|
16
|
+
|
|
1
17
|
## 1.0.0-rc.13 — 2026-11-01
|
|
2
18
|
|
|
3
19
|
- **Choose an agent's model from the catalog, with your own key.** The agent editor searches every
|
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ bun add copilotz # Bun
|
|
|
22
22
|
deno add jsr:@copilotz/copilotz # Deno (or `deno add npm:copilotz`)
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
On Deno, name it `copilotz` in `deno.json` (`"copilotz": "jsr:@copilotz/copilotz@^1.0.0-rc.
|
|
25
|
+
On Deno, name it `copilotz` in `deno.json` (`"copilotz": "jsr:@copilotz/copilotz@^1.0.0-rc.14"`),
|
|
26
26
|
and the imports below are the same everywhere. Some pieces need a package of their own, installed
|
|
27
27
|
beside it: `esbuild` to bundle the web host on Node, `@electric-sql/pglite` for PostgreSQL in the
|
|
28
28
|
process, and `@types/react` for the front ends' types.
|
|
@@ -204,7 +204,7 @@ and an app serves it from there by default:
|
|
|
204
204
|
import { computerDownloads } from "copilotz/plugins/compute/downloads";
|
|
205
205
|
|
|
206
206
|
plugins: [...plugins, await computerDownloads()], // this Copilotz's release
|
|
207
|
-
plugins: [...plugins, await computerDownloads({ dir: "dist/computer/1.0.0-rc.
|
|
207
|
+
plugins: [...plugins, await computerDownloads({ dir: "dist/computer/1.0.0-rc.14" })], // its own: /computer/download/
|
|
208
208
|
plugins: [...plugins, await computerDownloads({ url: "https://downloads.example.com/computer/" })], // or elsewhere
|
|
209
209
|
```
|
|
210
210
|
|
package/hosts/orgs/mod.d.ts
CHANGED
|
@@ -26,7 +26,9 @@
|
|
|
26
26
|
* `{ suspended?, name? }`; `POST …/<id>/move` `{ schema }` (its rows to
|
|
27
27
|
* another schema); `GET …/<id>/export` (its rows, as SQL); `POST
|
|
28
28
|
* …/<id>/delete` `{ confirm: <its name> }`. The app does the rows'
|
|
29
|
-
* part (`operations`). Staff enter any org with `/orgs/enter`.
|
|
29
|
+
* part (`operations`). Staff enter any org with `/orgs/enter`. Gift codes:
|
|
30
|
+
* `GET /console/codes`; `POST /console/codes` `{ amount, expires?, until?,
|
|
31
|
+
* note? }` (the code, shown this once); `POST /console/codes/revoke` `{ id }`.
|
|
30
32
|
* - Hosts orgs claimed (`claimHost` in an org's `directory` resource: a
|
|
31
33
|
* preview's `<id>-preview.copilotz.app`, an app's): with the app's own
|
|
32
34
|
* hosts named (`hosts`), a request to any other host is the org's that
|
package/hosts/orgs/mod.js
CHANGED
|
@@ -88,6 +88,8 @@ export function orgsHost(options) {
|
|
|
88
88
|
});
|
|
89
89
|
claims.delete(name);
|
|
90
90
|
},
|
|
91
|
+
/** A gift code's credits, for this org. */
|
|
92
|
+
claimCode: (code, person) => directory.call("code.claim", { code, org: org.id, person }),
|
|
91
93
|
/** The host is no longer the org's. */
|
|
92
94
|
releaseHost: async (host) => {
|
|
93
95
|
const name = plainHost(host);
|
|
@@ -488,6 +490,24 @@ export function orgsHost(options) {
|
|
|
488
490
|
return json({ error: "Staff only" }, { status: 403 });
|
|
489
491
|
return json(await directory.call("org.list", {}));
|
|
490
492
|
}
|
|
493
|
+
case "GET /console/codes": {
|
|
494
|
+
if (!await staffOnly(request))
|
|
495
|
+
return json({ error: "Staff only" }, { status: 403 });
|
|
496
|
+
return json(await directory.call("code.list", {}));
|
|
497
|
+
}
|
|
498
|
+
case "POST /console/codes": {
|
|
499
|
+
const who = await staffOnly(request);
|
|
500
|
+
if (!who)
|
|
501
|
+
return json({ error: "Staff only" }, { status: 403 });
|
|
502
|
+
const body = await request.json().catch(() => ({}));
|
|
503
|
+
return await directory.call("code.create", { ...body, by: who.person }).then((made) => json(made), (error) => json({ error: error.message }, { status: 400 }));
|
|
504
|
+
}
|
|
505
|
+
case "POST /console/codes/revoke": {
|
|
506
|
+
if (!await staffOnly(request))
|
|
507
|
+
return json({ error: "Staff only" }, { status: 403 });
|
|
508
|
+
const body = await request.json().catch(() => ({}));
|
|
509
|
+
return await directory.call("code.revoke", { id: body.id }).then(() => json({}), (error) => json({ error: error.message }, { status: 400 }));
|
|
510
|
+
}
|
|
491
511
|
}
|
|
492
512
|
if (url.pathname.startsWith("/console/orgs/")) {
|
|
493
513
|
if (!await staffOnly(request))
|
package/hosts/web/mod.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
export { go, signOut, web, type WebOptions, type Where } from "./host.js";
|
|
14
14
|
export { appBase } from "./base.js";
|
|
15
|
-
export { answerOrgInvite, arrived, asStaff, type ConsoleOrg, consoleOrgs, createOrg, currentOrg, deleteOrg, enterOrg, exportOrgUrl, moveOrg, type Org, type OrgInvite, orgName, type Orgs, type OrgsState, refreshOrgs, type Switching, updateOrg, useOrgs, useSwitching, } from "./orgs.js";
|
|
15
|
+
export { answerOrgInvite, arrived, asStaff, type ConsoleOrg, consoleOrgs, createGiftCode, createOrg, currentOrg, deleteOrg, enterOrg, exportOrgUrl, type GiftCode, giftCodes, moveOrg, type Org, type OrgInvite, orgName, type Orgs, type OrgsState, refreshOrgs, revokeGiftCode, type Switching, updateOrg, useOrgs, useSwitching, } from "./orgs.js";
|
|
16
16
|
export { message, node, Part } from "./part.js";
|
|
17
17
|
export { LazyView } from "./lazy.js";
|
|
18
18
|
export { Palette } from "./palette/palette.js";
|
package/hosts/web/mod.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
export { go, signOut, web } from "./host.js";
|
|
14
14
|
export { appBase } from "./base.js";
|
|
15
15
|
// Orgs, when the server serves many (`hosts/orgs`): the person's, and going between them.
|
|
16
|
-
export { answerOrgInvite, arrived, asStaff, consoleOrgs, createOrg, currentOrg, deleteOrg, enterOrg, exportOrgUrl, moveOrg, orgName, refreshOrgs, updateOrg, useOrgs, useSwitching, } from "./orgs.js";
|
|
16
|
+
export { answerOrgInvite, arrived, asStaff, consoleOrgs, createGiftCode, createOrg, currentOrg, deleteOrg, enterOrg, exportOrgUrl, giftCodes, moveOrg, orgName, refreshOrgs, revokeGiftCode, updateOrg, useOrgs, useSwitching, } from "./orgs.js";
|
|
17
17
|
export { message, node, Part } from "./part.js";
|
|
18
18
|
export { LazyView } from "./lazy.js";
|
|
19
19
|
// The command palette: the page's (the shell shows it), and opening it at a step from anywhere.
|
package/hosts/web/orgs.d.ts
CHANGED
|
@@ -110,3 +110,37 @@ export declare function moveOrg(org: string, schema: string): Promise<{
|
|
|
110
110
|
export declare const exportOrgUrl: (org: string) => string;
|
|
111
111
|
/** Deletes an org for good: `name`, its exact name, confirms it. */
|
|
112
112
|
export declare function deleteOrg(org: string, name: string): Promise<void>;
|
|
113
|
+
/** A gift code as staff's console lists it: never the code itself, which is only kept hashed. */
|
|
114
|
+
export type GiftCode = {
|
|
115
|
+
id: string;
|
|
116
|
+
/** Enough to tell them apart: it can't be claimed with this. */
|
|
117
|
+
short: string;
|
|
118
|
+
/** USD. */
|
|
119
|
+
amount: number;
|
|
120
|
+
/** The first day its credits no longer count (`YYYY-MM-DD`); none: they don't lapse. */
|
|
121
|
+
expires?: string;
|
|
122
|
+
/** The last moment it can be claimed (ISO); none: until it is. */
|
|
123
|
+
until?: string;
|
|
124
|
+
note?: string;
|
|
125
|
+
by: string;
|
|
126
|
+
at: string;
|
|
127
|
+
/** Who took it, for which org, and when. */
|
|
128
|
+
org?: string;
|
|
129
|
+
person?: string;
|
|
130
|
+
claimed?: string;
|
|
131
|
+
revoked?: string;
|
|
132
|
+
};
|
|
133
|
+
/** Gift codes, newest first, for staff's console. */
|
|
134
|
+
export declare function giftCodes(): Promise<GiftCode[]>;
|
|
135
|
+
/** Makes a gift code: the answer's `code` is the only time it's ever shown. */
|
|
136
|
+
export declare const createGiftCode: (code: {
|
|
137
|
+
amount: number;
|
|
138
|
+
expires?: string;
|
|
139
|
+
until?: string;
|
|
140
|
+
note?: string;
|
|
141
|
+
}) => Promise<{
|
|
142
|
+
code: string;
|
|
143
|
+
id: string;
|
|
144
|
+
}>;
|
|
145
|
+
/** Takes back a gift code nobody has claimed. */
|
|
146
|
+
export declare function revokeGiftCode(id: string): Promise<void>;
|
package/hosts/web/orgs.js
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
* - Staff's console: `consoleOrgs()`, `updateOrg(id, { suspended?, name? })`,
|
|
14
14
|
* `moveOrg(id, schema)`, `exportOrgUrl(id)` (its rows, as SQL, to save)
|
|
15
15
|
* and `deleteOrg(id, name)` (its exact name confirms it). An app that
|
|
16
|
-
* doesn't do one says so (`unsupported`).
|
|
16
|
+
* doesn't do one says so (`unsupported`). Gift codes: `giftCodes()`,
|
|
17
|
+
* `createGiftCode(...)` (the code itself, this once) and `revokeGiftCode(id)`.
|
|
17
18
|
*
|
|
18
19
|
* It's the page's own HTTP, same origin, with the cookies the server set.
|
|
19
20
|
*/
|
|
@@ -223,3 +224,20 @@ export const exportOrgUrl = (org) => `/console/orgs/${encodeURIComponent(org)}/e
|
|
|
223
224
|
export async function deleteOrg(org, name) {
|
|
224
225
|
await post(`/console/orgs/${encodeURIComponent(org)}/delete`, { confirm: name });
|
|
225
226
|
}
|
|
227
|
+
/** Gift codes, newest first, for staff's console. */
|
|
228
|
+
export async function giftCodes() {
|
|
229
|
+
const response = await fetch("/console/codes", { headers: { accept: "application/json" } });
|
|
230
|
+
const answer = await response.json().catch(() => ({}));
|
|
231
|
+
if (!response.ok) {
|
|
232
|
+
throw Object.assign(new Error(answer.error ?? response.statusText), {
|
|
233
|
+
code: codeOf(response.status),
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
return answer.codes;
|
|
237
|
+
}
|
|
238
|
+
/** Makes a gift code: the answer's `code` is the only time it's ever shown. */
|
|
239
|
+
export const createGiftCode = (code) => post("/console/codes", code);
|
|
240
|
+
/** Takes back a gift code nobody has claimed. */
|
|
241
|
+
export async function revokeGiftCode(id) {
|
|
242
|
+
await post("/console/codes/revoke", { id });
|
|
243
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "copilotz",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.14",
|
|
4
4
|
"description": "Copilotz: one runtime for Node, Deno, Bun, Cloudflare Workers and the browser.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agents",
|
|
@@ -87,8 +87,8 @@
|
|
|
87
87
|
"default": "./plugins/billing/mod.js"
|
|
88
88
|
},
|
|
89
89
|
"./plugins/billing/web": {
|
|
90
|
-
"types": "./plugins/billing/
|
|
91
|
-
"default": "./plugins/billing/
|
|
90
|
+
"types": "./plugins/billing/web.d.ts",
|
|
91
|
+
"default": "./plugins/billing/web.js"
|
|
92
92
|
},
|
|
93
93
|
"./plugins/billing/terminal": {
|
|
94
94
|
"types": "./plugins/billing/terminal.d.ts",
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const createCodeAction: import("../../../../runtime/define.js").ActionDef;
|
|
2
|
+
export declare const claimCodeAction: import("../../../../runtime/define.js").ActionDef;
|
|
3
|
+
export declare const listCodesAction: import("../../../../runtime/define.js").ActionDef;
|
|
4
|
+
export declare const revokeCodeAction: import("../../../../runtime/define.js").ActionDef;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gift codes (see collections/credit-code.ts). All the system's: staff ask
|
|
3
|
+
* through the console, orgs through their `directory` resource. None is
|
|
4
|
+
* recorded, so a code is in no event.
|
|
5
|
+
*
|
|
6
|
+
* - `code.create` `{ amount, expires?, until?, note?, by }`: a new code, shown
|
|
7
|
+
* this once;
|
|
8
|
+
* - `code.claim` `{ code, org, person }`: its credits, for that org. Claimed
|
|
9
|
+
* already by the same org, it answers the same, so a grant that failed can be
|
|
10
|
+
* tried again; by another, it's refused;
|
|
11
|
+
* - `code.list` `{}`, newest first, and `code.revoke` `{ id }`, while unclaimed.
|
|
12
|
+
*/
|
|
13
|
+
import { defineAction, failure, invalid } from "../../../../runtime/mod.js";
|
|
14
|
+
const ALPHABET = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
|
15
|
+
/** 130 random bits, as people can read and type them. */
|
|
16
|
+
function newCode() {
|
|
17
|
+
const bytes = crypto.getRandomValues(new Uint8Array(26));
|
|
18
|
+
const chars = [...bytes].map((byte) => ALPHABET[byte % 32]).join("");
|
|
19
|
+
return `GIFT-${chars.match(/.{1,5}/g).join("-")}`;
|
|
20
|
+
}
|
|
21
|
+
/** How it's kept: typed in any case, with or without its dashes. */
|
|
22
|
+
async function hashOf(code) {
|
|
23
|
+
const plain = code.toUpperCase().replace(/[^0-9A-Z]/g, "");
|
|
24
|
+
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(plain));
|
|
25
|
+
return [...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
26
|
+
}
|
|
27
|
+
const shown = (doc) => ({
|
|
28
|
+
id: doc._id,
|
|
29
|
+
// Enough to tell them apart: it can't be claimed with this.
|
|
30
|
+
short: doc._id.slice(0, 8),
|
|
31
|
+
amount: doc.amount,
|
|
32
|
+
...(doc.expires ? { expires: doc.expires } : {}),
|
|
33
|
+
...(doc.until ? { until: doc.until } : {}),
|
|
34
|
+
...(doc.note ? { note: doc.note } : {}),
|
|
35
|
+
by: doc.by,
|
|
36
|
+
at: doc.at,
|
|
37
|
+
...(doc.org ? { org: doc.org, person: doc.person, claimed: doc.claimed } : {}),
|
|
38
|
+
...(doc.revoked ? { revoked: doc.revoked } : {}),
|
|
39
|
+
});
|
|
40
|
+
export const createCodeAction = defineAction({
|
|
41
|
+
description: "Makes a gift code of credits; it's shown this once",
|
|
42
|
+
record: false,
|
|
43
|
+
input: {
|
|
44
|
+
type: "object",
|
|
45
|
+
properties: {
|
|
46
|
+
amount: { type: "number", exclusiveMinimum: 0 },
|
|
47
|
+
expires: { type: "string", pattern: "^\\d{4}-\\d{2}-\\d{2}$" },
|
|
48
|
+
until: { type: "string" },
|
|
49
|
+
note: { type: "string", maxLength: 200 },
|
|
50
|
+
by: { type: "string" },
|
|
51
|
+
},
|
|
52
|
+
required: ["amount", "by"],
|
|
53
|
+
additionalProperties: false,
|
|
54
|
+
},
|
|
55
|
+
run: async (ctx, input) => {
|
|
56
|
+
const code = newCode();
|
|
57
|
+
const _id = await hashOf(code);
|
|
58
|
+
await ctx.db.collection("creditCode").insertOne({
|
|
59
|
+
_id,
|
|
60
|
+
...input,
|
|
61
|
+
at: new Date().toISOString(),
|
|
62
|
+
});
|
|
63
|
+
return { code, id: _id };
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
export const claimCodeAction = defineAction({
|
|
67
|
+
description: "Claims a gift code for an org",
|
|
68
|
+
record: false,
|
|
69
|
+
input: {
|
|
70
|
+
type: "object",
|
|
71
|
+
properties: {
|
|
72
|
+
code: { type: "string" },
|
|
73
|
+
org: { type: "string" },
|
|
74
|
+
person: { type: "string" },
|
|
75
|
+
},
|
|
76
|
+
required: ["code", "org", "person"],
|
|
77
|
+
additionalProperties: false,
|
|
78
|
+
},
|
|
79
|
+
run: async (ctx, input) => {
|
|
80
|
+
const codes = ctx.db.collection("creditCode");
|
|
81
|
+
const _id = await hashOf(input.code);
|
|
82
|
+
const invalidCode = () => failure("invalid_code", "That code isn't valid. Check it and try again.");
|
|
83
|
+
const answer = (doc) => ({
|
|
84
|
+
id: _id.slice(0, 16),
|
|
85
|
+
amount: doc.amount,
|
|
86
|
+
...(doc.expires ? { expires: doc.expires } : {}),
|
|
87
|
+
...(doc.note ? { note: doc.note } : {}),
|
|
88
|
+
});
|
|
89
|
+
const doc = await codes.findOne({ _id });
|
|
90
|
+
if (!doc || doc.revoked)
|
|
91
|
+
throw invalidCode();
|
|
92
|
+
if (doc.org === input.org)
|
|
93
|
+
return answer(doc);
|
|
94
|
+
if (doc.org)
|
|
95
|
+
throw failure("used_code", "That code has already been used.");
|
|
96
|
+
const now = new Date().toISOString();
|
|
97
|
+
if (doc.until && doc.until <= now)
|
|
98
|
+
throw failure("expired_code", "That code has expired.");
|
|
99
|
+
// One writer: only one claim finds it unclaimed.
|
|
100
|
+
const { modifiedCount } = await codes.updateOne({ _id, org: { $exists: false }, revoked: { $exists: false } }, { $set: { org: input.org, person: input.person, claimed: now } });
|
|
101
|
+
if (modifiedCount)
|
|
102
|
+
return answer(doc);
|
|
103
|
+
const now2 = await codes.findOne({ _id });
|
|
104
|
+
if (now2?.org === input.org)
|
|
105
|
+
return answer(now2);
|
|
106
|
+
throw failure("used_code", "That code has already been used.");
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
export const listCodesAction = defineAction({
|
|
110
|
+
description: "Gift codes, newest first",
|
|
111
|
+
record: false,
|
|
112
|
+
input: { type: "object", additionalProperties: false },
|
|
113
|
+
run: async (ctx) => ({
|
|
114
|
+
codes: (await ctx.db.collection("creditCode").find({}, {
|
|
115
|
+
sort: { at: -1 },
|
|
116
|
+
limit: 200,
|
|
117
|
+
})).map(shown),
|
|
118
|
+
}),
|
|
119
|
+
});
|
|
120
|
+
export const revokeCodeAction = defineAction({
|
|
121
|
+
description: "Takes back a gift code nobody has claimed",
|
|
122
|
+
record: false,
|
|
123
|
+
input: {
|
|
124
|
+
type: "object",
|
|
125
|
+
properties: { id: { type: "string" } },
|
|
126
|
+
required: ["id"],
|
|
127
|
+
additionalProperties: false,
|
|
128
|
+
},
|
|
129
|
+
run: async (ctx, input) => {
|
|
130
|
+
const { modifiedCount } = await ctx.db.collection("creditCode").updateOne({ _id: input.id, org: { $exists: false } }, { $set: { revoked: new Date().toISOString() } });
|
|
131
|
+
if (!modifiedCount)
|
|
132
|
+
throw invalid("It's been claimed, or there's no such code.");
|
|
133
|
+
return {};
|
|
134
|
+
},
|
|
135
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gift codes: credits waiting to be claimed into an org, which may not exist
|
|
3
|
+
* yet. Kept here because they aren't any org's until someone claims one. Only a
|
|
4
|
+
* code's hash is kept (`_id`), and the code is shown once. A purchase made
|
|
5
|
+
* outside the app can wait the same way.
|
|
6
|
+
*/
|
|
7
|
+
import { type Infer } from "../../../../runtime/mod.js";
|
|
8
|
+
declare const creditCodeSchema: {
|
|
9
|
+
readonly type: "object";
|
|
10
|
+
readonly properties: {
|
|
11
|
+
/** USD, and the first day the credits no longer count (`YYYY-MM-DD`); none: they don't lapse. */
|
|
12
|
+
readonly amount: {
|
|
13
|
+
readonly type: "number";
|
|
14
|
+
};
|
|
15
|
+
readonly expires: {
|
|
16
|
+
readonly type: "string";
|
|
17
|
+
};
|
|
18
|
+
/** The last moment it can be claimed; none: until it is. */
|
|
19
|
+
readonly until: {
|
|
20
|
+
readonly type: "string";
|
|
21
|
+
};
|
|
22
|
+
/** What it's for, as the credits will say. */
|
|
23
|
+
readonly note: {
|
|
24
|
+
readonly type: "string";
|
|
25
|
+
};
|
|
26
|
+
readonly by: {
|
|
27
|
+
readonly type: "string";
|
|
28
|
+
};
|
|
29
|
+
readonly at: {
|
|
30
|
+
readonly type: "string";
|
|
31
|
+
};
|
|
32
|
+
/** Who took it, and when; or that it was taken back. */
|
|
33
|
+
readonly org: {
|
|
34
|
+
readonly type: "string";
|
|
35
|
+
};
|
|
36
|
+
readonly person: {
|
|
37
|
+
readonly type: "string";
|
|
38
|
+
};
|
|
39
|
+
readonly claimed: {
|
|
40
|
+
readonly type: "string";
|
|
41
|
+
};
|
|
42
|
+
readonly revoked: {
|
|
43
|
+
readonly type: "string";
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
readonly required: readonly ["amount", "by", "at"];
|
|
47
|
+
};
|
|
48
|
+
export declare const creditCode: {
|
|
49
|
+
schema: {
|
|
50
|
+
readonly type: "object";
|
|
51
|
+
readonly properties: {
|
|
52
|
+
/** USD, and the first day the credits no longer count (`YYYY-MM-DD`); none: they don't lapse. */
|
|
53
|
+
readonly amount: {
|
|
54
|
+
readonly type: "number";
|
|
55
|
+
};
|
|
56
|
+
readonly expires: {
|
|
57
|
+
readonly type: "string";
|
|
58
|
+
};
|
|
59
|
+
/** The last moment it can be claimed; none: until it is. */
|
|
60
|
+
readonly until: {
|
|
61
|
+
readonly type: "string";
|
|
62
|
+
};
|
|
63
|
+
/** What it's for, as the credits will say. */
|
|
64
|
+
readonly note: {
|
|
65
|
+
readonly type: "string";
|
|
66
|
+
};
|
|
67
|
+
readonly by: {
|
|
68
|
+
readonly type: "string";
|
|
69
|
+
};
|
|
70
|
+
readonly at: {
|
|
71
|
+
readonly type: "string";
|
|
72
|
+
};
|
|
73
|
+
/** Who took it, and when; or that it was taken back. */
|
|
74
|
+
readonly org: {
|
|
75
|
+
readonly type: "string";
|
|
76
|
+
};
|
|
77
|
+
readonly person: {
|
|
78
|
+
readonly type: "string";
|
|
79
|
+
};
|
|
80
|
+
readonly claimed: {
|
|
81
|
+
readonly type: "string";
|
|
82
|
+
};
|
|
83
|
+
readonly revoked: {
|
|
84
|
+
readonly type: "string";
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
readonly required: readonly ["amount", "by", "at"];
|
|
88
|
+
};
|
|
89
|
+
events?: boolean;
|
|
90
|
+
records?: boolean;
|
|
91
|
+
durable?: false;
|
|
92
|
+
indexes?: string[][];
|
|
93
|
+
private?: string[];
|
|
94
|
+
queries?: Record<string, import("../../../../runtime/define.js").QueryDef<{
|
|
95
|
+
[x: string]: unknown;
|
|
96
|
+
until?: string | undefined;
|
|
97
|
+
person?: string | undefined;
|
|
98
|
+
note?: string | undefined;
|
|
99
|
+
org?: string | undefined;
|
|
100
|
+
expires?: string | undefined;
|
|
101
|
+
revoked?: string | undefined;
|
|
102
|
+
claimed?: string | undefined;
|
|
103
|
+
at: string;
|
|
104
|
+
by: string;
|
|
105
|
+
amount: number;
|
|
106
|
+
} & {
|
|
107
|
+
_id: string;
|
|
108
|
+
}>> | undefined;
|
|
109
|
+
vectors?: string[];
|
|
110
|
+
};
|
|
111
|
+
export type CreditCode = Infer<typeof creditCodeSchema> & {
|
|
112
|
+
_id: string;
|
|
113
|
+
};
|
|
114
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gift codes: credits waiting to be claimed into an org, which may not exist
|
|
3
|
+
* yet. Kept here because they aren't any org's until someone claims one. Only a
|
|
4
|
+
* code's hash is kept (`_id`), and the code is shown once. A purchase made
|
|
5
|
+
* outside the app can wait the same way.
|
|
6
|
+
*/
|
|
7
|
+
import { defineCollection } from "../../../../runtime/mod.js";
|
|
8
|
+
const creditCodeSchema = {
|
|
9
|
+
type: "object",
|
|
10
|
+
properties: {
|
|
11
|
+
/** USD, and the first day the credits no longer count (`YYYY-MM-DD`); none: they don't lapse. */
|
|
12
|
+
amount: { type: "number" },
|
|
13
|
+
expires: { type: "string" },
|
|
14
|
+
/** The last moment it can be claimed; none: until it is. */
|
|
15
|
+
until: { type: "string" },
|
|
16
|
+
/** What it's for, as the credits will say. */
|
|
17
|
+
note: { type: "string" },
|
|
18
|
+
by: { type: "string" },
|
|
19
|
+
at: { type: "string" },
|
|
20
|
+
/** Who took it, and when; or that it was taken back. */
|
|
21
|
+
org: { type: "string" },
|
|
22
|
+
person: { type: "string" },
|
|
23
|
+
claimed: { type: "string" },
|
|
24
|
+
revoked: { type: "string" },
|
|
25
|
+
},
|
|
26
|
+
required: ["amount", "by", "at"],
|
|
27
|
+
};
|
|
28
|
+
export const creditCode = defineCollection({ schema: creditCodeSchema });
|
|
@@ -18,6 +18,7 @@ export type { Org } from "./collections/org.js";
|
|
|
18
18
|
export type { Membership } from "./collections/membership.js";
|
|
19
19
|
export type { Invite } from "./collections/invite.js";
|
|
20
20
|
export type { OrgHost } from "./collections/org-host.js";
|
|
21
|
+
export type { CreditCode } from "./collections/credit-code.js";
|
|
21
22
|
export type { DirectorySettings } from "./shared/settings.js";
|
|
22
23
|
export declare const directory: Plugin;
|
|
23
24
|
export default directory;
|
|
@@ -17,6 +17,8 @@ import { definePlugin } from "../../../runtime/mod.js";
|
|
|
17
17
|
import { createOrgAction, deleteOrgAction, enterOrgAction, getOrgAction, leaveOrgAction, listOrgsAction, myOrgsAction, placeOrgAction, renameOrgAction, reportOrgAction, suspendOrgAction, } from "./actions/org.js";
|
|
18
18
|
import { answerInviteAction, cancelInviteAction, myInvitesAction, orgInvitesAction, sendInviteAction, } from "./actions/invite.js";
|
|
19
19
|
import { claimHostAction, releaseHostAction } from "./actions/host.js";
|
|
20
|
+
import { claimCodeAction, createCodeAction, listCodesAction, revokeCodeAction, } from "./actions/code.js";
|
|
21
|
+
import { creditCode } from "./collections/credit-code.js";
|
|
20
22
|
import { invite } from "./collections/invite.js";
|
|
21
23
|
import { membership } from "./collections/membership.js";
|
|
22
24
|
import { org } from "./collections/org.js";
|
|
@@ -25,7 +27,7 @@ import { staff } from "./collections/staff.js";
|
|
|
25
27
|
export const directory = definePlugin({
|
|
26
28
|
name: "directory",
|
|
27
29
|
requires: ["identity"],
|
|
28
|
-
collections: { org, membership, invite, staff, orgHost },
|
|
30
|
+
collections: { org, membership, invite, staff, orgHost, creditCode },
|
|
29
31
|
actions: {
|
|
30
32
|
"org.create": createOrgAction,
|
|
31
33
|
"org.mine": myOrgsAction,
|
|
@@ -45,6 +47,10 @@ export const directory = definePlugin({
|
|
|
45
47
|
"invite.cancel": cancelInviteAction,
|
|
46
48
|
"host.claim": claimHostAction,
|
|
47
49
|
"host.release": releaseHostAction,
|
|
50
|
+
"code.create": createCodeAction,
|
|
51
|
+
"code.claim": claimCodeAction,
|
|
52
|
+
"code.list": listCodesAction,
|
|
53
|
+
"code.revoke": revokeCodeAction,
|
|
48
54
|
},
|
|
49
55
|
});
|
|
50
56
|
export default directory;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const joinOrgAction: import("../../../../runtime/define.js").ActionDef;
|
|
2
2
|
export declare const orgRoleAction: import("../../../../runtime/define.js").ActionDef;
|
|
3
3
|
export declare const removeFromOrgAction: import("../../../../runtime/define.js").ActionDef;
|
|
4
|
+
export declare const orgSeatsAction: import("../../../../runtime/define.js").ActionDef;
|
|
4
5
|
export declare const orgMeAction: import("../../../../runtime/define.js").ActionDef;
|
|
5
6
|
/**
|
|
6
7
|
* The `directory` resource, which a host serving many orgs gives each org
|
|
@@ -121,6 +121,13 @@ export const removeFromOrgAction = defineAction({
|
|
|
121
121
|
return { handed };
|
|
122
122
|
},
|
|
123
123
|
});
|
|
124
|
+
export const orgSeatsAction = defineAction({
|
|
125
|
+
description: "How many people count as the org's seats: everyone but its guests",
|
|
126
|
+
record: false,
|
|
127
|
+
input: { type: "object", additionalProperties: false },
|
|
128
|
+
run: async (ctx) => (await ctx.as().db.collection("member").find({ space: ORG }))
|
|
129
|
+
.filter((m) => m.role !== "guest").length,
|
|
130
|
+
});
|
|
124
131
|
export const orgMeAction = defineAction({
|
|
125
132
|
description: "Your standing in the org: your role, whether you're platform staff, and the org (in an app " +
|
|
126
133
|
"serving many)",
|
|
@@ -52,7 +52,7 @@ import { canAction } from "./actions/can.js";
|
|
|
52
52
|
import { leaveAction } from "./actions/leave.js";
|
|
53
53
|
import { acceptInvitationAction, declineInvitationAction, sendInvitationAction, } from "./actions/invitation.js";
|
|
54
54
|
import { removeMemberAction, setMemberAction } from "./actions/member.js";
|
|
55
|
-
import { inviteToOrgAction, joinOrgAction, orgInvitesAction, orgMeAction, orgPeopleAction, orgRoleAction, orgSummaryAction, removeFromOrgAction, renameOrgAction, uninviteAction, } from "./actions/org.js";
|
|
55
|
+
import { inviteToOrgAction, joinOrgAction, orgInvitesAction, orgMeAction, orgPeopleAction, orgRoleAction, orgSeatsAction, orgSummaryAction, removeFromOrgAction, renameOrgAction, uninviteAction, } from "./actions/org.js";
|
|
56
56
|
import { personalAction } from "./actions/personal.js";
|
|
57
57
|
import { renameAction } from "./actions/rename.js";
|
|
58
58
|
import { shareAction } from "./actions/share.js";
|
|
@@ -94,6 +94,7 @@ export const spaces = definePlugin({
|
|
|
94
94
|
"org.remove": removeFromOrgAction,
|
|
95
95
|
"org.me": orgMeAction,
|
|
96
96
|
"org.people": orgPeopleAction,
|
|
97
|
+
"org.seats": orgSeatsAction,
|
|
97
98
|
"org.invite": inviteToOrgAction,
|
|
98
99
|
"org.invites": orgInvitesAction,
|
|
99
100
|
"org.uninvite": uninviteAction,
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* The chat plugin's contract: what plugins built on chat (memory, history,
|
|
3
3
|
* spaces, computers) may import from it: the shapes of its documents and of
|
|
4
4
|
* the resource kinds it reads (`agents`, `tools`, `context`, `roster`,
|
|
5
|
-
* `agentSources`; on the web, `conversation`, `home`, `toolViews
|
|
6
|
-
* `refusals`),
|
|
5
|
+
* `agentSources`; on the web, `conversation`, `home`, `toolViews`,
|
|
6
|
+
* `refusals` and `composerNotes`),
|
|
7
7
|
* `tool()` to declare a tool, and what knowing agents takes (`agentsOf`,
|
|
8
8
|
* `defaults`, `modelOf`, `agentsNamed`, `agentsShown`, `SEND`).
|
|
9
9
|
* Everything else they reach through the runtime: its collections by name
|
|
@@ -16,7 +16,7 @@ export type { Live, LiveCall } from "./collections/live.js";
|
|
|
16
16
|
export type { Message } from "./collections/message.js";
|
|
17
17
|
export type { Thread } from "./collections/thread.js";
|
|
18
18
|
export type { Wait } from "./collections/wait.js";
|
|
19
|
-
export type { Agent, ChatSettings, ContextEntry, ConversationView, HomeView, Offer, Prompt, RefusalView, ShownCall, Step, Tool, ToolContext, ToolViews, Turn, } from "./shared/types.js";
|
|
19
|
+
export type { Agent, ChatSettings, ComposerNote, ContextEntry, ConversationView, HomeView, Offer, Prompt, RefusalView, ShownCall, Step, Tool, ToolContext, ToolViews, Turn, } from "./shared/types.js";
|
|
20
20
|
export { tool } from "./shared/types.js";
|
|
21
21
|
export { principalOf } from "./shared/send.js";
|
|
22
22
|
export { type Origin, originKey, originOf } from "./shared/origin.js";
|
|
@@ -20,6 +20,12 @@ const failed = async (ctx, event) => {
|
|
|
20
20
|
const text = written?.text ? `${written.text} (stopped)` : "(stopped)";
|
|
21
21
|
return await answer(ctx, t, run, text, { stopped: true });
|
|
22
22
|
}
|
|
23
|
+
// The org's limit isn't the agent failing: it says what happened, and who can change it.
|
|
24
|
+
if (error.code === "credits" || error.code === "budget") {
|
|
25
|
+
return await answer(ctx, t, run, error.message ?? "This org can't spend right now.", {
|
|
26
|
+
failed: true,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
23
29
|
await answer(ctx, t, run, `${t.agent} failed: ${error.message ?? "unknown error"}`, {
|
|
24
30
|
failed: true,
|
|
25
31
|
});
|
|
@@ -117,6 +117,17 @@ export type HomeView = {
|
|
|
117
117
|
export type RefusalView = {
|
|
118
118
|
view: string;
|
|
119
119
|
};
|
|
120
|
+
/**
|
|
121
|
+
* A `composerNotes` resource: by key, a View shown over the box where you
|
|
122
|
+
* type, in a conversation and on home, with hints `{ thread?, in?, working }`
|
|
123
|
+
* (the chat, none from home; its space; whether agents are at work): what to
|
|
124
|
+
* know before sending. Lowest `order` first; a View with nothing to say
|
|
125
|
+
* returns null, and takes no room.
|
|
126
|
+
*/
|
|
127
|
+
export type ComposerNote = {
|
|
128
|
+
view: string;
|
|
129
|
+
order?: number;
|
|
130
|
+
};
|
|
120
131
|
/**
|
|
121
132
|
* A `toolViews` resource: by a tool's name, the View kind that shows a call
|
|
122
133
|
* to it in a conversation, in place of chat's own (what it was given and
|
|
@@ -13,10 +13,13 @@
|
|
|
13
13
|
* another front end can help with (`refusals`, by its code: `not_here`, it
|
|
14
14
|
* named agents that don't answer here) shows that front end's View over the
|
|
15
15
|
* box, with what was typed and a way to send it again: nothing went, and
|
|
16
|
-
* what was typed stays.
|
|
16
|
+
* what was typed stays. What other front ends want known before sending
|
|
17
|
+
* (`notes`, the `composerNotes` resource: the org is out of credits) shows
|
|
18
|
+
* over the box too, each its own View, taking no room until it has something
|
|
19
|
+
* to say.
|
|
17
20
|
*/
|
|
18
21
|
import { type ReactNode } from "react";
|
|
19
|
-
import type { RefusalView } from "../../shared/types.js";
|
|
22
|
+
import type { ComposerNote, RefusalView } from "../../shared/types.js";
|
|
20
23
|
import { type Mentionable } from "./agents.js";
|
|
21
24
|
/** A file as `chat.send` takes it; a voice message's says how long it runs, and its peaks. */
|
|
22
25
|
export type Sent = {
|
|
@@ -50,6 +53,8 @@ export declare function Composer(props: {
|
|
|
50
53
|
where?: string;
|
|
51
54
|
/** By the code a send is refused with, the View to show over the box (`refusals`). */
|
|
52
55
|
refusals?: Record<string, RefusalView | null>;
|
|
56
|
+
/** What to know before sending, each a View over the box (`composerNotes`), with `place`. */
|
|
57
|
+
notes?: Record<string, ComposerNote | null>;
|
|
53
58
|
/** Where it sends, for those Views: the chat (none from home) and its space. */
|
|
54
59
|
place?: {
|
|
55
60
|
thread?: string;
|