@pairz/team 1.0.0-rc.81 → 1.0.0-rc.83

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 (42) hide show
  1. package/README.md +9 -4
  2. package/WORDS.md +23 -2
  3. package/package.json +2 -2
  4. package/team/actions/agent.js +12 -4
  5. package/team/collections/agent.d.ts +70 -15
  6. package/team/collections/agent.js +29 -7
  7. package/team/shared/definition.d.ts +15 -0
  8. package/team/shared/definition.js +17 -1
  9. package/team/views/web/model-pick.d.ts +10 -1
  10. package/team/views/web/model-pick.js +4 -2
  11. package/team/views/web/model-picker.d.ts +31 -5
  12. package/team/views/web/model-picker.js +74 -30
  13. package/team/views/web/words.d.ts +1 -1
  14. package/team/views/web/words.js +7 -0
  15. package/tiers/actions/choose.d.ts +48 -1
  16. package/tiers/actions/choose.js +143 -57
  17. package/tiers/actions/model.js +14 -9
  18. package/tiers/collections/choice.d.ts +15 -8
  19. package/tiers/collections/choice.js +22 -12
  20. package/tiers/collections/template.d.ts +6 -1
  21. package/tiers/collections/template.js +8 -4
  22. package/tiers/contract.d.ts +2 -2
  23. package/tiers/mod.d.ts +17 -9
  24. package/tiers/mod.js +26 -12
  25. package/tiers/shared/plans.d.ts +31 -33
  26. package/tiers/shared/plans.js +39 -54
  27. package/tiers/shared/shown.d.ts +16 -3
  28. package/tiers/shared/shown.js +43 -15
  29. package/tiers/shared/tiers.d.ts +38 -5
  30. package/tiers/shared/tiers.js +29 -3
  31. package/tiers/views/web/composer.d.ts +2 -1
  32. package/tiers/views/web/composer.js +8 -2
  33. package/tiers/views/web/org.d.ts +46 -11
  34. package/tiers/views/web/org.js +144 -61
  35. package/tiers/views/web/say.d.ts +17 -2
  36. package/tiers/views/web/say.js +17 -2
  37. package/tiers/views/web/space.d.ts +2 -1
  38. package/tiers/views/web/space.js +8 -4
  39. package/tiers/views/web/style.d.ts +1 -1
  40. package/tiers/views/web/style.js +5 -0
  41. package/tiers/web.d.ts +6 -5
  42. package/tiers/web.js +9 -8
package/README.md CHANGED
@@ -35,13 +35,18 @@ import { teamWeb, tiersWeb } from "@pairz/team/web";
35
35
  - **`team`**: agents people make where they belong (a space), with their instructions, tools and
36
36
  model, added to other spaces by those who've met them, changed only by who manage the space they
37
37
  belong to; removed, one leaves every space it worked in. Its collection is `agent`; chat asks it
38
- what an agent not in the app's code is (the `agentSources` resource).
38
+ what an agent not in the app's code is (the `agentSources` resource). The org's version of one of
39
+ the app's agents keeps only what the org changed of its tools (`{ add, remove }`), so tools the
40
+ app gives its agents later reach it.
39
41
  - **`tiers`**: which model each of the app's agents thinks with, by tier ("Everyday", "Expert"): the
40
42
  first that applies of a space's pick, the space's tier, the org's pick, the org's tier and its
41
43
  plan's (the `planTier` resource, which `@pairz/billing`'s credits fill). Its collection is
42
- `modelChoice`; chat asks it through the `agentModel` resource. Where the app has people's plans
43
- (Claude Code, ChatGPT…), each turn's chain runs on its person's plans first, in their order
44
- (`tiers.harnesses`).
44
+ `modelChoice`; chat asks it through the `agentModel` resource. An org puts its tiers in its own
45
+ order (`tiers.order`), and says what members can use: all tiers, up to one, or only the default
46
+ (`tiers.cap`). Where the app has people's plans (Claude Code, ChatGPT…), each turn's chain runs in
47
+ the tier's order, each model on its person's plans that run it, then on credits; an org that turns
48
+ on members' subscriptions whenever possible (`tiers.plansFirst`) has every model run on their
49
+ plans before any on credits, then the tier's `fallbacks` on their plans only.
45
50
 
46
51
  Its front end's words are `team.<key>`: see
47
52
  [WORDS.md](https://github.com/pairzhq/pairz/blob/main/packages/team/WORDS.md).
package/WORDS.md CHANGED
@@ -49,6 +49,7 @@ Generated: `deno run -A packages/team/tests/words.ts`.
49
49
  | `team.createNamed` | Create {name} |
50
50
  | `team.createNewAgent` | Create a new agent |
51
51
  | `team.createNewAgentBody` | Say what it should do; it can write its own instructions. |
52
+ | `team.credits` | Credits |
52
53
  | `team.deleteButton` | Delete {name} |
53
54
  | `team.deleteChats` | {bold} with what it said. |
54
55
  | `team.deleteChatsBold` | Chats it was in stay as they are, |
@@ -158,6 +159,10 @@ Generated: `deno run -A packages/team/tests/words.ts`.
158
159
  | `team.orgKey` | This org's key {hint} |
159
160
  | `team.orgsTeam` | Your org's team |
160
161
  | `team.otherEmoji` | Other |
162
+ | `team.paidConnect` | Connect {plans} to use |
163
+ | `team.paidCredits` | Credits · {price} |
164
+ | `team.paidFallBack` | Members without {plans} fall back to the next model |
165
+ | `team.paidYours` | Your {plan} · $0 |
161
166
  | `team.paletteAgents` | Agents |
162
167
  | `team.paletteCreate` | Create |
163
168
  | `team.paletteThisAgent` | This agent |
@@ -224,6 +229,7 @@ Generated: `deno run -A packages/team/tests/words.ts`.
224
229
  | `team.youAreDefaultName` | Maya |
225
230
  | `team.youArePlaceholder` | You are {name}. You… |
226
231
  | `team.yourKey` | Your key |
232
+ | `team.yourPlan` | Your {plan} |
227
233
 
228
234
  ## tiers
229
235
 
@@ -238,6 +244,7 @@ Generated: `deno run -A packages/team/tests/words.ts`.
238
244
  | `tiers.addBackTier` | Add back {tier} |
239
245
  | `tiers.addFallback` | Add a fallback |
240
246
  | `tiers.addKind` | Add a kind of work |
247
+ | `tiers.addPlanFallback` | Add a model |
241
248
  | `tiers.agentLine` | {model} · {kind} · on {tier} |
242
249
  | `tiers.asOrg` | As the org: {tier} |
243
250
  | `tiers.backToDefault` | Back to the default |
@@ -257,9 +264,12 @@ Generated: `deno run -A packages/team/tests/words.ts`.
257
264
  | `tiers.bySpace` | this space's default |
258
265
  | `tiers.byThread` | chosen for this chat |
259
266
  | `tiers.cancel` | Cancel |
260
- | `tiers.capAny` | Any tier |
261
- | `tiers.capLabel` | Members can choose up to |
267
+ | `tiers.capAll` | All tiers |
268
+ | `tiers.capDefault` | Only the default |
269
+ | `tiers.capDefaultNote` | Every chat runs on the default: nobody switches a chat's or a space's tier. |
270
+ | `tiers.capLabel` | Members can use |
262
271
  | `tiers.capNote` | Owners and admins can always use any of them. |
272
+ | `tiers.capUpTo` | Up to {tier} |
263
273
  | `tiers.changeAnyTime` | You can change it any time. |
264
274
  | `tiers.chatRunsDefault` | This chat runs on its default. |
265
275
  | `tiers.chatRunsOn` | This chat runs on {tier} from its next reply. |
@@ -296,6 +306,8 @@ Generated: `deno run -A packages/team/tests/words.ts`.
296
306
  | `tiers.forPlaceholder` | Strong judgment, quick checks. |
297
307
  | `tiers.makeDefault` | Make it the default |
298
308
  | `tiers.messages` | one: {count} message / other: {count} messages |
309
+ | `tiers.moveAfter` | Move after {tier} |
310
+ | `tiers.moveBefore` | Move before {tier} |
299
311
  | `tiers.moveDown` | Move down |
300
312
  | `tiers.moveUp` | Move up |
301
313
  | `tiers.name` | Name |
@@ -312,11 +324,13 @@ Generated: `deno run -A packages/team/tests/words.ts`.
312
324
  | `tiers.noCredits` | {plan} gives this org no credits. |
313
325
  | `tiers.noCreditsMore` | Choose a plan or add credits for your agents to start working. |
314
326
  | `tiers.noFallback` | Nothing: if it fails, the reply fails. |
327
+ | `tiers.noPlanFallback` | None: the agent's own models on credits. |
315
328
  | `tiers.notOnTeam` | Not on your team |
316
329
  | `tiers.nowMore` | Anyone can switch a chat's tier as they write, and spaces can set their own. |
317
330
  | `tiers.nowOrg` | New chats use {tier}, your org's default. |
318
331
  | `tiers.nowPlan` | New chats use {tier}, your plan's default. |
319
332
  | `tiers.onlyRunners` | Only {org}'s owners and admins change these. You can switch a chat's tier as you write. |
333
+ | `tiers.onlyRunnersFixed` | Only the org's owners and admins change these, and every chat runs on the default. |
320
334
  | `tiers.onlyRunnersHere` | Only the org's owners and admins change these. You can switch a chat's tier as you write. |
321
335
  | `tiers.onPlans` | on your plans · model $0 |
322
336
  | `tiers.onTier` | {model} on {tier} |
@@ -325,6 +339,12 @@ Generated: `deno run -A packages/team/tests/words.ts`.
325
339
  | `tiers.perReply` | a reply |
326
340
  | `tiers.pickCap` | Members can use up to {cap}. |
327
341
  | `tiers.pickLabel` | Tier: {tier}, {by} |
342
+ | `tiers.planFallbacks` | When a member's subscriptions run none of these |
343
+ | `tiers.planFallbacksAbout` | Tried after any agent's models, on members' subscriptions only, never on credits, while subscriptions are used whenever possible. One model per maker covers every subscription. |
344
+ | `tiers.plansFirstLabel` | Use members' subscriptions whenever possible |
345
+ | `tiers.plansFirstOff` | Off: each agent tries its models in the tier's order, on a member's subscription where one runs it, else on credits. |
346
+ | `tiers.plansFirstOn` | On: any of an agent's models a member's subscription runs comes before credits, then the tier's fallbacks on their subscriptions. |
347
+ | `tiers.plansFirstWarning` | Agents may end up on the same model and lose what makes them complementary: one that checks the others' work, for example, does it best on another maker's model. |
328
348
  | `tiers.pricedEach` | Priced as each model is |
329
349
  | `tiers.providerChatgpt` | your ChatGPT plan |
330
350
  | `tiers.recommended` | Recommended |
@@ -353,5 +373,6 @@ Generated: `deno run -A packages/team/tests/words.ts`.
353
373
  | `tiers.tierModels` | {tier}'s models |
354
374
  | `tiers.tierMore` | {tier}: more |
355
375
  | `tiers.tiersLabel` | Tiers |
376
+ | `tiers.tryFirst` | Try it first |
356
377
  | `tiers.underTenth` | under 0.1¢ |
357
378
  | `tiers.undo` | Undo |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pairz/team",
3
- "version": "1.0.0-rc.81",
3
+ "version": "1.0.0-rc.83",
4
4
  "description": "Agents people make, and the models an org's agents think with (tiers). A Pairz plugin.",
5
5
  "keywords": [
6
6
  "pairz",
@@ -53,7 +53,7 @@
53
53
  "dependencies": {},
54
54
  "peerDependencies": {
55
55
  "@types/react": "^19.3.0",
56
- "pairz": "1.0.0-rc.81",
56
+ "pairz": "1.0.0-rc.83",
57
57
  "react": "^19.3.1",
58
58
  "react-dom": "^19.3.1"
59
59
  },
@@ -12,14 +12,17 @@
12
12
  * joins every space in use, and new ones as they're made; it can work `like`
13
13
  * one of the app's agents (that one's model, where the app chooses). One of
14
14
  * the app's agents changed (`agent.update`) is the org's version of it, its
15
- * model still the app's to choose; deleted (`agent.delete`), it's off the
16
- * team: it leaves every space and joins no new one. `agent.restore` puts it
17
- * back, as the org had it; `agent.reset` drops the org's changes, back to
18
- * the app's, on the team.
15
+ * model still the app's to choose, and its `tools` (the whole list, as for
16
+ * any agent) kept as what they change of the app's, so tools the app adds
17
+ * later reach it; deleted (`agent.delete`), it's off the team: it leaves
18
+ * every space and joins no new one. `agent.restore` puts it back, as the
19
+ * org had it; `agent.reset` drops the org's changes, back to the app's, on
20
+ * the team.
19
21
  */
20
22
  import { defineAction, inPerson, invalid, people } from "pairz";
21
23
  import { agentsOf, defaults, modelOf, SEND, } from "pairz/plugins/agents/contract";
22
24
  import { must, ORG } from "pairz/plugins/access/contract";
25
+ import { toolChanges, toolsOf } from "../shared/definition.js";
23
26
  import { joinEverywhere, leaveEverywhere } from "../shared/everywhere.js";
24
27
  import { checkInstructions } from "../shared/limits.js";
25
28
  const forbidden = (agent) => Object.assign(new Error(`Only those who manage where "${agent}" belongs change it.`), {
@@ -193,6 +196,11 @@ export const updateAgentAction = defineAction({
193
196
  await checked(ctx, { ...given, effort: given.effort ?? found.effort });
194
197
  const cleared = ["description", "icon", "effort", "like"].filter((f) => given[f] === "");
195
198
  const set = Object.fromEntries(Object.entries(given).filter(([field, value]) => value !== undefined && !cleared.includes(field)));
199
+ // One of the app's keeps only what changes the app's tools; a whole list from before rc.83
200
+ // becomes that too.
201
+ if (app && (given.tools || Array.isArray(found.tools))) {
202
+ set.tools = toolChanges(given.tools ?? toolsOf(found.tools, app.tools), app.tools);
203
+ }
196
204
  const changed = await ctx.db.collection("agent").updateOne({ _id: agent }, {
197
205
  ...(Object.keys(set).length ? { $set: set } : {}),
198
206
  ...(cleared.length ? { $unset: Object.fromEntries(cleared.map((f) => [f, ""])) } : {}),
@@ -8,9 +8,11 @@
8
8
  * The org's team: one that belongs to the org itself (`in: "*"`) is the
9
9
  * org's own, its owners and admins change it, and it works in every space;
10
10
  * one with the name of one of the app's agents is the org's version of it
11
- * (what the org changed of it), and `off` there, the org took it off its
12
- * team. One the org made can work `like` one of the app's agents: it takes
13
- * that one's model, where the app chooses models (tiers).
11
+ * (what the org changed of it: of its tools, only those added and taken
12
+ * away, `{ add, remove }`, so tools the app adds later reach it), and `off`
13
+ * there, the org took it off its team. One the org made can work `like` one
14
+ * of the app's agents: it takes that one's model, where the app chooses
15
+ * models (tiers).
14
16
  *
15
17
  * Its queries:
16
18
  *
@@ -43,12 +45,37 @@ declare const agentSchema: {
43
45
  readonly effort: {
44
46
  readonly type: "string";
45
47
  };
46
- /** Names of `tools` resources it may call, and `send_message` to talk to others. */
48
+ /**
49
+ * Names of `tools` resources it may call, and `send_message` to talk to
50
+ * others. The org's version of one of the app's keeps what it changed of
51
+ * the app's: those it added and took away (`{ add, remove }`); a whole
52
+ * list there, saved before rc.83, reads as the app's plus what it has
53
+ * beyond them, and is kept as changes when it's next saved.
54
+ */
47
55
  readonly tools: {
48
- readonly type: "array";
49
- readonly items: {
50
- readonly type: "string";
51
- };
56
+ readonly anyOf: readonly [{
57
+ readonly type: "array";
58
+ readonly items: {
59
+ readonly type: "string";
60
+ };
61
+ }, {
62
+ readonly type: "object";
63
+ readonly properties: {
64
+ readonly add: {
65
+ readonly type: "array";
66
+ readonly items: {
67
+ readonly type: "string";
68
+ };
69
+ };
70
+ readonly remove: {
71
+ readonly type: "array";
72
+ readonly items: {
73
+ readonly type: "string";
74
+ };
75
+ };
76
+ };
77
+ readonly additionalProperties: false;
78
+ }];
52
79
  };
53
80
  /** An emoji it's shown with. */
54
81
  readonly icon: {
@@ -82,15 +109,18 @@ export declare const agent: Omit<import("pairz").CollectionDef, "schema" | "quer
82
109
  description?: string | undefined;
83
110
  model?: string | undefined;
84
111
  effort?: string | undefined;
85
- tools?: string[] | undefined;
112
+ tools?: string[] | {
113
+ add?: string[] | undefined;
114
+ remove?: string[] | undefined;
115
+ } | undefined;
86
116
  icon?: string | undefined;
87
117
  in?: string | undefined;
88
118
  off?: boolean | undefined;
89
119
  like?: string | undefined;
90
120
  by?: string | undefined;
121
+ at: string;
91
122
  name: string;
92
123
  instructions: string;
93
- at: string;
94
124
  }>>> | undefined;
95
125
  } & {
96
126
  schema: {
@@ -114,12 +144,37 @@ export declare const agent: Omit<import("pairz").CollectionDef, "schema" | "quer
114
144
  readonly effort: {
115
145
  readonly type: "string";
116
146
  };
117
- /** Names of `tools` resources it may call, and `send_message` to talk to others. */
147
+ /**
148
+ * Names of `tools` resources it may call, and `send_message` to talk to
149
+ * others. The org's version of one of the app's keeps what it changed of
150
+ * the app's: those it added and took away (`{ add, remove }`); a whole
151
+ * list there, saved before rc.83, reads as the app's plus what it has
152
+ * beyond them, and is kept as changes when it's next saved.
153
+ */
118
154
  readonly tools: {
119
- readonly type: "array";
120
- readonly items: {
121
- readonly type: "string";
122
- };
155
+ readonly anyOf: readonly [{
156
+ readonly type: "array";
157
+ readonly items: {
158
+ readonly type: "string";
159
+ };
160
+ }, {
161
+ readonly type: "object";
162
+ readonly properties: {
163
+ readonly add: {
164
+ readonly type: "array";
165
+ readonly items: {
166
+ readonly type: "string";
167
+ };
168
+ };
169
+ readonly remove: {
170
+ readonly type: "array";
171
+ readonly items: {
172
+ readonly type: "string";
173
+ };
174
+ };
175
+ };
176
+ readonly additionalProperties: false;
177
+ }];
123
178
  };
124
179
  /** An emoji it's shown with. */
125
180
  readonly icon: {
@@ -8,9 +8,11 @@
8
8
  * The org's team: one that belongs to the org itself (`in: "*"`) is the
9
9
  * org's own, its owners and admins change it, and it works in every space;
10
10
  * one with the name of one of the app's agents is the org's version of it
11
- * (what the org changed of it), and `off` there, the org took it off its
12
- * team. One the org made can work `like` one of the app's agents: it takes
13
- * that one's model, where the app chooses models (tiers).
11
+ * (what the org changed of it: of its tools, only those added and taken
12
+ * away, `{ add, remove }`, so tools the app adds later reach it), and `off`
13
+ * there, the org took it off its team. One the org made can work `like` one
14
+ * of the app's agents: it takes that one's model, where the app chooses
15
+ * models (tiers).
14
16
  *
15
17
  * Its queries:
16
18
  *
@@ -36,8 +38,26 @@ const agentSchema = {
36
38
  /** `"provider/model"` or an alias (see the models plugin). */
37
39
  model: { type: "string" },
38
40
  effort: { type: "string" },
39
- /** Names of `tools` resources it may call, and `send_message` to talk to others. */
40
- tools: { type: "array", items: { type: "string" } },
41
+ /**
42
+ * Names of `tools` resources it may call, and `send_message` to talk to
43
+ * others. The org's version of one of the app's keeps what it changed of
44
+ * the app's: those it added and took away (`{ add, remove }`); a whole
45
+ * list there, saved before rc.83, reads as the app's plus what it has
46
+ * beyond them, and is kept as changes when it's next saved.
47
+ */
48
+ tools: {
49
+ anyOf: [
50
+ { type: "array", items: { type: "string" } },
51
+ {
52
+ type: "object",
53
+ properties: {
54
+ add: { type: "array", items: { type: "string" } },
55
+ remove: { type: "array", items: { type: "string" } },
56
+ },
57
+ additionalProperties: false,
58
+ },
59
+ ],
60
+ },
41
61
  /** An emoji it's shown with. */
42
62
  icon: { type: "string" },
43
63
  /** Where it was made: who manage that space change it; `*`, the org's own. */
@@ -59,9 +79,11 @@ export const agent = defineCollection({
59
79
  known: {
60
80
  allow: people,
61
81
  run: async (agents, _, ctx) => {
62
- const known = { ...agentsOf(ctx) };
82
+ const declared = agentsOf(ctx);
83
+ const known = { ...declared };
63
84
  for (const doc of await agents.find({}, { sort: { name: 1 } })) {
64
- known[doc._id] = definitionOf(doc);
85
+ // The org's version of one of the app's, over the app's.
86
+ known[doc._id] = { ...declared[doc._id], ...definitionOf(doc, declared[doc._id]) };
65
87
  }
66
88
  return known;
67
89
  },
@@ -1,3 +1,18 @@
1
1
  import type { Agent } from "pairz/plugins/agents/contract";
2
2
  import type { AgentDoc } from "../collections/agent.js";
3
+ /** What the org's version of one of the app's agents changed of its tools: added, taken away. */
4
+ export type ToolChanges = {
5
+ add?: string[];
6
+ remove?: string[];
7
+ };
8
+ /**
9
+ * The tools an agent has: the app's (`defaults`, for the org's version of
10
+ * one of its agents) without those taken away, then those added. A whole
11
+ * list kept as it was before rc.83 reads as the app's plus what the list
12
+ * has beyond them: nothing's taken away, since which were on purpose can't
13
+ * be told. One people made keeps its own list (no defaults).
14
+ */
15
+ export declare function toolsOf(saved: string[] | ToolChanges, defaults?: string[]): string[];
16
+ /** What `tools` changes of the app's (`defaults`): as the org's version of an agent keeps it. */
17
+ export declare const toolChanges: (tools: string[], defaults?: string[]) => ToolChanges;
3
18
  export declare const definitionOf: (doc: AgentDoc, base?: Agent) => Agent;
@@ -1,8 +1,24 @@
1
+ /**
2
+ * The tools an agent has: the app's (`defaults`, for the org's version of
3
+ * one of its agents) without those taken away, then those added. A whole
4
+ * list kept as it was before rc.83 reads as the app's plus what the list
5
+ * has beyond them: nothing's taken away, since which were on purpose can't
6
+ * be told. One people made keeps its own list (no defaults).
7
+ */
8
+ export function toolsOf(saved, defaults = []) {
9
+ const { add = [], remove = [] } = Array.isArray(saved) ? { add: saved } : saved;
10
+ return [...new Set([...defaults.filter((tool) => !remove.includes(tool)), ...add])];
11
+ }
12
+ /** What `tools` changes of the app's (`defaults`): as the org's version of an agent keeps it. */
13
+ export const toolChanges = (tools, defaults = []) => ({
14
+ add: tools.filter((tool) => !defaults.includes(tool)),
15
+ remove: defaults.filter((tool) => !tools.includes(tool)),
16
+ });
1
17
  export const definitionOf = (doc, base) => ({
2
18
  instructions: doc.instructions,
3
19
  ...(base ? {} : { model: doc.model ?? "" }),
4
20
  ...(doc.effort && !base ? { effort: doc.effort } : {}),
5
- ...(doc.tools ? { tools: doc.tools } : {}),
21
+ ...(doc.tools ? { tools: toolsOf(doc.tools, base?.tools) } : {}),
6
22
  ...(doc.description ? { description: doc.description } : {}),
7
23
  ...(doc.name !== doc._id || base ? { name: doc.name } : {}),
8
24
  ...(doc.icon ? { icon: doc.icon } : {}),
@@ -5,7 +5,9 @@
5
5
  * look?, label?, disabled? }`: choosing one calls `action` with `input` and
6
6
  * the `model` chosen, and says so if that fails. What changes shows where it's
7
7
  * read (a watched read), so it hands nothing back. `look`: the picker's field
8
- * (the default), or a small button saying `label` ("Change").
8
+ * (the default), or a small button saying `label` ("Change"). `plans`: for a
9
+ * model people's turns run on their plans first (a tier's), every model the
10
+ * org can run, each saying how it's paid for (see model-picker.tsx).
9
11
  *
10
12
  * ```tsx
11
13
  * <LazyView kind="model.pick" item={{ value }} hints={{ action: "tiers.pick", input: { agent } }} />
@@ -13,6 +15,7 @@
13
15
  */
14
16
  import { type ReactNode } from "react";
15
17
  import type { ViewContext } from "pairz";
18
+ import { type Paid } from "./model-picker.js";
16
19
  export type ModelPick = {
17
20
  action?: string;
18
21
  input?: Record<string, unknown>;
@@ -21,6 +24,12 @@ export type ModelPick = {
21
24
  look?: "field" | "link";
22
25
  label?: string;
23
26
  disabled?: boolean;
27
+ /**
28
+ * For a model that runs on people's plans first: `members` (an org's
29
+ * tier), a model only a plan runs is theirs to fall back from; `mine` (a
30
+ * person's own), it needs their plan.
31
+ */
32
+ plans?: Paid;
24
33
  };
25
34
  export declare const modelPickView: (item: {
26
35
  value?: string;
@@ -6,7 +6,9 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
6
6
  * look?, label?, disabled? }`: choosing one calls `action` with `input` and
7
7
  * the `model` chosen, and says so if that fails. What changes shows where it's
8
8
  * read (a watched read), so it hands nothing back. `look`: the picker's field
9
- * (the default), or a small button saying `label` ("Change").
9
+ * (the default), or a small button saying `label` ("Change"). `plans`: for a
10
+ * model people's turns run on their plans first (a tier's), every model the
11
+ * org can run, each saying how it's paid for (see model-picker.tsx).
10
12
  *
11
13
  * ```tsx
12
14
  * <LazyView kind="model.pick" item={{ value }} hints={{ action: "tiers.pick", input: { agent } }} />
@@ -38,5 +40,5 @@ function Pick({ value, pick, call }) {
38
40
  setBusy(false);
39
41
  }
40
42
  };
41
- return (_jsxs("span", { className: "model-pick", "data-look": pick.look ?? "field", "aria-busy": busy || undefined, children: [_jsx(ModelPicker, { value: value, call: call, look: pick.look, label: pick.label, disabled: busy || pick.disabled, onChange: (model) => void choose(model) }), error ? _jsx("span", { className: "model-pick-error", role: "alert", children: error }) : null] }));
43
+ return (_jsxs("span", { className: "model-pick", "data-look": pick.look ?? "field", "aria-busy": busy || undefined, children: [_jsx(ModelPicker, { value: value, call: call, look: pick.look, label: pick.label, plans: pick.plans, disabled: busy || pick.disabled, onChange: (model) => void choose(model) }), error ? _jsx("span", { className: "model-pick-error", role: "alert", children: error }) : null] }));
42
44
  }
@@ -7,11 +7,32 @@
7
7
  * then one's models, newest first, with what each costs and can do. A provider
8
8
  * without a key asks for one: the org's owners and admins add it here
9
9
  * (`modelKey.set`), and it's never shown again; anyone else is told whom to ask.
10
+ *
11
+ * For a model people's turns run on their plans first (a tier's, `plans`),
12
+ * it offers every model the org can run, each saying how it's paid for the
13
+ * person looking: "Your Claude · $0" where a subscription of theirs runs it,
14
+ * "Credits" where a key covers it, and for a model only plans run, "Members
15
+ * without Claude fall back to the next model" (`members`: an org's tier, so
16
+ * it can be chosen) or "Connect Claude to use" (`mine`: their own).
10
17
  */
11
18
  import { type ReactNode } from "react";
12
19
  import type { OfferedModel, OfferedProvider } from "pairz/plugins/models/contract";
13
20
  type Call = <R = unknown>(action: string, input?: unknown) => Promise<R>;
14
- export declare function ModelPicker({ value, onChange, call, disabled, id, look, label }: {
21
+ /**
22
+ * Whose model it is, where turns run on people's plans first: `members` (an
23
+ * org's tier, whose members without a model's plan fall back from it), or
24
+ * `mine` (the person's own, which needs their plan).
25
+ */
26
+ export type Paid = "members" | "mine";
27
+ /** Whether a model can be chosen: a key covers it, or a plan runs it that's theirs, or members'. */
28
+ export declare const choosable: (model: OfferedModel, plans?: Paid) => boolean;
29
+ /**
30
+ * How a model is paid for, for the person looking, where turns run on plans
31
+ * first: their subscription ("Your Claude · $0"), else credits, at its price,
32
+ * else, for a model only plans run, who falls back or what to connect.
33
+ */
34
+ export declare function paidSaid(model: OfferedModel, plans: Paid): string | undefined;
35
+ export declare function ModelPicker({ value, onChange, call, disabled, id, look, label, plans }: {
15
36
  value: string;
16
37
  onChange(model: string): void;
17
38
  call: Call;
@@ -20,6 +41,8 @@ export declare function ModelPicker({ value, onChange, call, disabled, id, look,
20
41
  /** A field showing what's chosen (the default), or a small button saying `label` ("Change"). */
21
42
  look?: "field" | "link";
22
43
  label?: string;
44
+ /** Turns run on people's plans first: whose model it is (see the module's doc). */
45
+ plans?: Paid;
23
46
  }): ReactNode;
24
47
  type Listing = {
25
48
  providers: OfferedProvider[];
@@ -29,21 +52,24 @@ type Found = {
29
52
  providers: OfferedProvider[];
30
53
  models: OfferedModel[];
31
54
  };
32
- /** The providers: those that can be used now, then those that take a key. */
33
- export declare function Providers({ listing, onProvider }: {
55
+ /** The providers: those that can be used now (a key, or a plan), then those that take a key. */
56
+ export declare function Providers({ listing, plans, onProvider }: {
34
57
  listing?: Listing;
58
+ plans?: Paid;
35
59
  onProvider(id: string): void;
36
60
  }): ReactNode;
37
- export declare function ModelRow({ model, value, withProvider, onChoose }: {
61
+ export declare function ModelRow({ model, value, withProvider, plans, onChoose }: {
38
62
  model: OfferedModel;
39
63
  value: string;
40
64
  /** Who it's from, where several providers' are listed. */
41
65
  withProvider?: string;
66
+ plans?: Paid;
42
67
  onChoose(): void;
43
68
  }): ReactNode;
44
- export declare function Results({ found, value, onProvider, onChoose }: {
69
+ export declare function Results({ found, value, plans, onProvider, onChoose }: {
45
70
  found?: Found;
46
71
  value: string;
72
+ plans?: Paid;
47
73
  onProvider(id: string): void;
48
74
  onChoose(model: string): void;
49
75
  }): ReactNode;