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

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.
@@ -4,9 +4,13 @@
4
4
  * - `tiers.choose` `{ tier, space?, thread?, mine? }`: the tier for the org
5
5
  * (its owners and admins), a space (its managers), a conversation (anyone
6
6
  * in it) or the person's own default for new chats (`mine`); null: the one
7
- * above. Those who don't run the org can't choose a tier over its `cap`.
8
- * - `tiers.cap` `{ tier }`: the highest tier the org's members may choose
9
- * (null: any), by its owners and admins.
7
+ * above. Those who don't run the org can't choose a tier over its `cap`;
8
+ * where the org uses only its default (`fixed`), nobody chooses below it.
9
+ * - `tiers.cap` `{ tier?, fixed? }`: what the org's members may use, by its
10
+ * owners and admins: every tier (`tier: null`), tiers up to one (`tier`),
11
+ * or only the org's default (`fixed: true`).
12
+ * - `tiers.order` `{ tiers }`: the org's tiers in the order it wants them,
13
+ * lowest first, each once: where a cap stops.
10
14
  * - `tiers.save` `{ tier, title?, description?, kinds?, from? }`: an org's
11
15
  * tier, by its owners and admins: its version of one of the app's, or a
12
16
  * new one (`title`, its chains copied from `from`, else the tier in force).
@@ -19,16 +23,11 @@
19
23
  * - `tiers.restore` `{ tier }`: one of the app's back as the app has it.
20
24
  * - `tiers.kind` `{ kind?, title, base }`: a kind of work of the org's own,
21
25
  * starting from one of the app's (its chain in every tier, until changed).
22
- * - `tiers.harnesses` `{ harnesses }`: the order the person's plans run
23
- * their agents' models in (the app's plans, by provider; the rest after,
24
- * in the app's order); null: the app's. Kept on their own choice, beside
25
- * their tier for new chats.
26
26
  *
27
27
  * A change applies from each conversation's next reply.
28
28
  */
29
29
  import { defineAction, failure, inPerson, invalid } from "pairz";
30
30
  import { must, ORG } from "pairz/plugins/access/contract";
31
- import { harnessesOf } from "../shared/plans.js";
32
31
  import { orgTiersOf } from "../shared/shown.js";
33
32
  import { aboveCap, appKindsOf, appTiersOf, entryOf, ORG_CHOICE, personChoice, settled, spaceChoice, threadChoice, } from "../shared/tiers.js";
34
33
  /** Throws unless the caller runs the org. */
@@ -37,24 +36,32 @@ const runsOrg = (ctx, what) => must(ctx, "manage", ORG, `Only the org's owners a
37
36
  const running = (ctx) => runsOrg(ctx, "do that").then(() => true, () => false);
38
37
  const choices = (ctx) => ctx.as().db.collection("modelChoice");
39
38
  const templates = (ctx) => ctx.as().db.collection("tierTemplate");
40
- /** Keeps a level's choice, or deletes it once it holds nothing (no tier, cap or order). */
39
+ /** Keeps a level's choice, or deletes it once it holds nothing (no tier, nor what members use). */
41
40
  async function keep(ctx, had, next) {
42
- if (!next.tier && !next.cap && !next.harnesses?.length) {
41
+ if (!next.tier && !next.cap && !next.fixed) {
43
42
  if (had)
44
43
  await choices(ctx).deleteOne({ _id: next._id });
45
44
  return;
46
45
  }
47
46
  await choices(ctx).replaceOne({ _id: next._id }, next, { upsert: true });
48
47
  }
49
- /** Sets or clears one level's tier, keeping what else it holds (the org's cap, a person's order). */
48
+ /** A level's choice as it's kept now: a person's old order of their plans goes. */
49
+ async function choiceOf(ctx, id) {
50
+ const found = await choices(ctx).findOne({ _id: id });
51
+ if (!found)
52
+ return null;
53
+ const { harnesses: _, ...kept } = found;
54
+ return kept;
55
+ }
56
+ /** Sets or clears one level's tier, keeping what else it holds (the org's cap). */
50
57
  async function setTier(ctx, id, tier, more) {
51
- const had = await choices(ctx).findOne({ _id: id });
52
- const next = { ...had, ...more, _id: id, at: new Date().toISOString() };
58
+ const before = await choiceOf(ctx, id);
59
+ const next = { ...before, ...more, _id: id, at: new Date().toISOString() };
53
60
  if (tier)
54
61
  next.tier = tier;
55
62
  else
56
63
  delete next.tier;
57
- await keep(ctx, had, next);
64
+ await keep(ctx, before, next);
58
65
  }
59
66
  export const chooseAction = defineAction({
60
67
  description: "Chooses the tier for the org, a space, a conversation or your new chats",
@@ -78,9 +85,14 @@ export const chooseAction = defineAction({
78
85
  const where = [input.space, input.thread, input.mine].filter(Boolean).length;
79
86
  if (where > 1)
80
87
  throw invalid("Choose for one place at a time.");
81
- // Over the cap: only who runs the org.
82
88
  if (input.tier) {
83
- const cap = (await choices(ctx).findOne({ _id: ORG_CHOICE }))?.cap;
89
+ const org = await choices(ctx).findOne({ _id: ORG_CHOICE });
90
+ const cap = org?.cap;
91
+ // Only the default: nobody chooses another below the org.
92
+ if (org?.fixed && where) {
93
+ throw failure("forbidden", "Every chat uses your org's default tier: its owners and admins chose so.", { public: true });
94
+ }
95
+ // Over the cap: only who runs the org.
84
96
  if (aboveCap(tiers, input.tier, cap) && !await running(ctx)) {
85
97
  throw failure("forbidden", `Your org's owners and admins let members use tiers up to ${tiers[cap].title}.`, { public: true });
86
98
  }
@@ -107,58 +119,57 @@ export const chooseAction = defineAction({
107
119
  },
108
120
  });
109
121
  export const capAction = defineAction({
110
- description: "Sets the highest tier the org's members may choose",
122
+ description: "Sets what the org's members may use: every tier, tiers up to one, or only the default",
111
123
  input: {
112
124
  type: "object",
113
- properties: { tier: { type: ["string", "null"] } },
114
- required: ["tier"],
125
+ properties: {
126
+ /** The highest tier they may choose; null: any. */
127
+ tier: { type: ["string", "null"] },
128
+ /** Only the org's default: no space, conversation or person chooses another. */
129
+ fixed: { type: "boolean" },
130
+ },
115
131
  additionalProperties: false,
116
132
  },
117
133
  allow: inPerson,
118
134
  run: async (ctx, input) => {
119
135
  await runsOrg(ctx, "set what members may use");
120
136
  const { tiers } = await orgTiersOf(ctx.as());
121
- if (input.tier !== null && !tiers[input.tier]) {
122
- throw invalid(`There's no tier "${input.tier}".`);
123
- }
124
- const had = await choices(ctx).findOne({ _id: ORG_CHOICE });
125
- const next = { ...had, _id: ORG_CHOICE, at: new Date().toISOString() };
126
- if (input.tier)
127
- next.cap = input.tier;
128
- else
129
- delete next.cap;
130
- await keep(ctx, had, next);
131
- return { cap: input.tier };
137
+ const cap = input.fixed ? null : input.tier ?? null;
138
+ if (cap !== null && !tiers[cap])
139
+ throw invalid(`There's no tier "${cap}".`);
140
+ const before = await choiceOf(ctx, ORG_CHOICE);
141
+ const next = { ...before, _id: ORG_CHOICE, at: new Date().toISOString() };
142
+ delete next.cap;
143
+ delete next.fixed;
144
+ if (input.fixed)
145
+ next.fixed = true;
146
+ else if (cap)
147
+ next.cap = cap;
148
+ await keep(ctx, before, next);
149
+ return { cap, fixed: !!input.fixed };
132
150
  },
133
151
  });
134
- export const harnessesAction = defineAction({
135
- description: "Sets the order your plans run your agents' models in",
152
+ export const orderAction = defineAction({
153
+ description: "Puts the org's tiers in order, lowest first",
154
+ transaction: true,
136
155
  input: {
137
156
  type: "object",
138
- properties: {
139
- /** Plans by provider name, first first; null: the app's order. */
140
- harnesses: { type: ["array", "null"], items: { type: "string" }, maxItems: 32 },
141
- },
142
- required: ["harnesses"],
157
+ properties: { tiers: { type: "array", items: { type: "string" }, maxItems: 64 } },
158
+ required: ["tiers"],
143
159
  additionalProperties: false,
144
160
  },
145
161
  allow: inPerson,
146
162
  run: async (ctx, input) => {
147
- const plans = harnessesOf(ctx);
148
- const order = [...new Set(input.harnesses ?? [])];
149
- const unknown = order.find((name) => !plans[name]);
150
- if (unknown)
151
- throw invalid(`There's no plan "${unknown}".`);
152
- const person = ctx.actor.id;
153
- const id = personChoice(person);
154
- const had = await choices(ctx).findOne({ _id: id });
155
- const next = { ...had, _id: id, person, at: new Date().toISOString() };
156
- if (order.length)
157
- next.harnesses = order;
158
- else
159
- delete next.harnesses;
160
- await keep(ctx, had, next);
161
- return { harnesses: order.length ? order : null };
163
+ await runsOrg(ctx, "change its tiers");
164
+ const { tiers } = await orgTiersOf(ctx.as());
165
+ const names = Object.keys(tiers);
166
+ if (input.tiers.length !== names.length || names.some((name) => !input.tiers.includes(name)))
167
+ throw invalid("Put each of the org's tiers in the order, once.");
168
+ const at = new Date().toISOString();
169
+ for (const [i, name] of input.tiers.entries()) {
170
+ await templates(ctx).updateOne({ _id: name }, { $set: { order: i + 1, at } }, { upsert: true });
171
+ }
172
+ return { tiers: input.tiers };
162
173
  },
163
174
  });
164
175
  /** A name for a new tier from its title: `balanced`, `balanced-2`. */
@@ -276,7 +287,17 @@ export const restoreAction = defineAction({
276
287
  if (!appTiersOf(ctx)[input.tier]) {
277
288
  throw invalid(`"${input.tier}" isn't one of the app's tiers.`);
278
289
  }
279
- await templates(ctx).deleteOne({ _id: input.tier });
290
+ // As the app has it, in the place the org gave it.
291
+ const order = (await templates(ctx).findOne({ _id: input.tier }))?.order;
292
+ if (order === undefined)
293
+ await templates(ctx).deleteOne({ _id: input.tier });
294
+ else {
295
+ await templates(ctx).replaceOne({ _id: input.tier }, {
296
+ _id: input.tier,
297
+ order,
298
+ at: new Date().toISOString(),
299
+ });
300
+ }
280
301
  return { tier: input.tier };
281
302
  },
282
303
  });
@@ -10,14 +10,15 @@
10
10
  * cached.
11
11
  *
12
12
  * Where the app has plans (providers with `harness`), the chain goes with
13
- * the plans its person has connected now, in their order, and the models
14
- * those that said so run: `{ model: chain, harnesses, served? }` (none for a
15
- * turn that's nobody's), and the models plugin runs each model on them first
16
- * (see shared/plans.ts). Asking which they have is one read per plugin that
17
- * keeps plans, beside the rest.
13
+ * the plans its person has connected now, in the plans' order, and the
14
+ * models those that said so run: `{ model: chain, harnesses, served? }`
15
+ * (none for a turn that's nobody's), and the models plugin runs each model
16
+ * on them first (see shared/plans.ts). Asking which they have is one read
17
+ * per plugin that keeps plans, beside the rest.
18
18
  */
19
19
  import { defineAction, personOf } from "pairz";
20
- import { connectedOf, harnessesOf, plansOf } from "../shared/plans.js";
20
+ import { connectedOf } from "pairz/plugins/models/contract";
21
+ import { harnessesOf, plansOf } from "../shared/plans.js";
21
22
  import { levelsOf, orgTiersOf } from "../shared/shown.js";
22
23
  import { entryOf, kindOf, tierIn } from "../shared/tiers.js";
23
24
  export const modelAction = defineAction({
@@ -55,6 +56,6 @@ export const modelAction = defineAction({
55
56
  return null;
56
57
  if (!plans)
57
58
  return chain;
58
- return { model: chain, ...plansOf(ctx, connected, levels.person?.harnesses) };
59
+ return { model: chain, ...plansOf(ctx, connected) };
59
60
  },
60
61
  });
@@ -5,17 +5,17 @@ export type ModelChoice = {
5
5
  person?: string;
6
6
  tier?: string;
7
7
  cap?: string;
8
- harnesses?: string[];
8
+ fixed?: boolean;
9
9
  at: string;
10
10
  };
11
11
  export declare const modelChoice: Omit<import("pairz").CollectionDef, "schema" | "queries"> & {
12
12
  queries?: Record<string, import("pairz").QueryDef<import("pairz").WithId<{
13
13
  [x: string]: unknown;
14
+ fixed?: boolean | undefined;
14
15
  space?: string | undefined;
15
16
  thread?: string | undefined;
16
17
  person?: string | undefined;
17
18
  tier?: string | undefined;
18
- harnesses?: string[] | undefined;
19
19
  cap?: string | undefined;
20
20
  at: string;
21
21
  }>>> | undefined;
@@ -41,12 +41,9 @@ export declare const modelChoice: Omit<import("pairz").CollectionDef, "schema" |
41
41
  readonly cap: {
42
42
  readonly type: "string";
43
43
  };
44
- /** A person's: the order their plans run in (providers with `harness`); none: the app's. */
45
- readonly harnesses: {
46
- readonly type: "array";
47
- readonly items: {
48
- readonly type: "string";
49
- };
44
+ /** The org's: its members use only its default; no space, conversation or person chooses. */
45
+ readonly fixed: {
46
+ readonly type: "boolean";
50
47
  };
51
48
  readonly at: {
52
49
  readonly type: "string";
@@ -1,12 +1,13 @@
1
1
  /**
2
2
  * Which tier applies where (`modelChoice`): the org's (`_id: "org"`, with
3
- * `cap`, the highest tier its members may choose), a space's (`space:<id>`),
4
- * a conversation's (`thread:<id>`) and a person's own default for new chats
5
- * (`person:<id>`), which also keeps the order their plans run in
6
- * (`harnesses`). Each a tier by its name, never a copy: changing a tier
7
- * moves everyone on it. Changed only through `tiers.choose`, `tiers.cap` and
8
- * `tiers.harnesses`, which say who may; read by `_id`, so a turn's asking costs what the owner
9
- * has cached.
3
+ * what its members may use: `cap`, the highest tier they may choose, or
4
+ * `fixed`, only its default), a space's (`space:<id>`), a conversation's
5
+ * (`thread:<id>`) and a person's own default for new chats (`person:<id>`).
6
+ * Each a tier by its name, never a copy: changing a tier moves everyone on
7
+ * it. Changed only through `tiers.choose` and `tiers.cap`, which say who
8
+ * may; read by `_id`, so a turn's asking costs what the owner has cached. A
9
+ * person's choice saved when people ordered their plans may still hold
10
+ * `harnesses`: nothing reads it, and their next choice drops it.
10
11
  *
11
12
  * Queries, for front ends, as the person looking:
12
13
  * - `offered` `{ space?, thread? }`: the org's tiers with each kind of
@@ -16,9 +17,10 @@
16
17
  * conversation's, those who reach them.
17
18
  * - `agent` `{ agent, space?, thread? }`: one agent there: its kind, the tier
18
19
  * in force and its chain in it.
19
- * - `harnesses` `{}`: the app's plans the person looking orders (those a
20
- * tier's model runs on), in their order, each with whether they have it
21
- * and the first model, in tier order, it runs (what a test of it tries).
20
+ * - `harnesses` `{}`: the app's plans that pay for the person looking (those
21
+ * a tier's model runs on, and those they've connected), in the plans'
22
+ * order, each with whether they have it and the first model, in tier
23
+ * order, it runs (what a test of it tries).
22
24
  */
23
25
  import { defineCollection, forbidden, people } from "pairz";
24
26
  import { harnessesShown } from "../shared/plans.js";
@@ -34,8 +36,8 @@ const choiceSchema = {
34
36
  tier: { type: "string" },
35
37
  /** The org's: the highest tier its members may choose; none: any. */
36
38
  cap: { type: "string" },
37
- /** A person's: the order their plans run in (providers with `harness`); none: the app's. */
38
- harnesses: { type: "array", items: { type: "string" } },
39
+ /** The org's: its members use only its default; no space, conversation or person chooses. */
40
+ fixed: { type: "boolean" },
39
41
  at: { type: "string" },
40
42
  },
41
43
  required: ["at"],
@@ -7,8 +7,8 @@ export declare const tierTemplate: Omit<import("pairz").CollectionDef, "schema"
7
7
  agents?: {
8
8
  [x: string]: unknown;
9
9
  } | undefined;
10
- made?: boolean | undefined;
11
10
  order?: number | undefined;
11
+ made?: boolean | undefined;
12
12
  at: string;
13
13
  }>>> | undefined;
14
14
  } & {
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * The org's tiers, as it keeps them (`tierTemplate`, one per tier, by its
3
- * name): its version of one of the app's (kinds' chains changed, a title, or
4
- * `off`: taken away), or one it made (`made`, whole). Changed only through
5
- * `tiers.save`, `tiers.remove` and `tiers.restore`, by the org's owners and
6
- * admins; everyone in the org reads them, through `modelChoice.offered`.
3
+ * name): its version of one of the app's (kinds' chains changed, a title, its
4
+ * place among them, or `off`: taken away), or one it made (`made`, whole).
5
+ * Changed only through `tiers.save`, `tiers.order`, `tiers.remove` and
6
+ * `tiers.restore`, by the org's owners and admins; everyone in the org reads
7
+ * them, through `modelChoice.offered`.
7
8
  */
8
9
  import { defineCollection } from "pairz";
9
10
  export const tierTemplate = defineCollection({
@@ -6,8 +6,8 @@
6
6
  * reached by name: its collections (`modelChoice`, `tierTemplate`,
7
7
  * `tierKind`), its queries (`modelChoice.offered`, `modelChoice.agent`,
8
8
  * `modelChoice.harnesses`) and its Actions (`tiers.model`, `tiers.choose`,
9
- * `tiers.cap`, `tiers.save`, `tiers.remove`, `tiers.restore`, `tiers.kind`,
10
- * `tiers.harnesses`).
9
+ * `tiers.cap`, `tiers.save`, `tiers.order`, `tiers.remove`, `tiers.restore`,
10
+ * `tiers.kind`).
11
11
  */
12
12
  export type { By, Choice, Kind, Tier } from "./shared/tiers.js";
13
13
  export type { HarnessShown } from "./shared/plans.js";
package/tiers/mod.d.ts CHANGED
@@ -19,21 +19,24 @@
19
19
  * - **Which tier, first that applies:** the conversation's, the person's own
20
20
  * default for new chats, the space's, the org's, then the tier the org's
21
21
  * plan gives (the `planTier` resource, which credits fills)
22
- * (`tiers.choose`; `modelChoice`, by name, never copies). The org can cap
23
- * what its members choose (`tiers.cap`); its owners and admins aren't
24
- * bound by it, and its budget bounds what anyone spends.
22
+ * (`tiers.choose`; `modelChoice`, by name, never copies). The org says
23
+ * what its members may use (`tiers.cap`): every tier, tiers up to one
24
+ * (its owners and admins aren't bound by that), or only its default
25
+ * (every chat runs on it). Its budget bounds what anyone spends. Its
26
+ * tiers' order is its own to change (`tiers.order`).
25
27
  * - **Every turn:** chat asks `tiers.model` through its `agentModel` resource,
26
28
  * for every agent, with the kind it works like. A change applies from each
27
29
  * conversation's next reply.
28
30
  * - **Plans first:** where the app has people's plans (providers with
29
31
  * `harness`: Claude Code, ChatGPT…), a turn's chain goes with the plans its
30
- * person has connected now (each `connectedPlans` source says), in their
31
- * order (`tiers.harnesses`; `modelChoice.harnesses` lists them), and each
32
- * model runs on those that serve it before any API: by the models a plan
33
- * said it runs, where it said (`served`). A tier names models;
34
- * an entry naming a plan (`claude-plan/…`) stands for its model on plans
35
- * only. `plansFor` (shared/plans.ts) is what a turn goes with, and
36
- * `models.check` what a chain would try.
32
+ * person has connected now (each `connectedPlans` source says), in one
33
+ * order for everyone (theirs: a maker's own plan before Cursor;
34
+ * `modelChoice.harnesses` lists them), and each model runs on those that
35
+ * serve it before any API, so a subscription pays for every model it runs,
36
+ * before credits: by the models a plan said it runs, where it said
37
+ * (`served`). A tier names models; an entry naming a plan (`claude-plan/…`)
38
+ * stands for its model on plans only. `plansFor` (shared/plans.ts) is what
39
+ * a turn goes with, and `models.check` what a chain would try.
37
40
  *
38
41
  * Its queries (`modelChoice.offered`, `modelChoice.agent`) show the tiers
39
42
  * with what a typical message comes to at the org's prices (the app's
package/tiers/mod.js CHANGED
@@ -19,21 +19,24 @@
19
19
  * - **Which tier, first that applies:** the conversation's, the person's own
20
20
  * default for new chats, the space's, the org's, then the tier the org's
21
21
  * plan gives (the `planTier` resource, which credits fills)
22
- * (`tiers.choose`; `modelChoice`, by name, never copies). The org can cap
23
- * what its members choose (`tiers.cap`); its owners and admins aren't
24
- * bound by it, and its budget bounds what anyone spends.
22
+ * (`tiers.choose`; `modelChoice`, by name, never copies). The org says
23
+ * what its members may use (`tiers.cap`): every tier, tiers up to one
24
+ * (its owners and admins aren't bound by that), or only its default
25
+ * (every chat runs on it). Its budget bounds what anyone spends. Its
26
+ * tiers' order is its own to change (`tiers.order`).
25
27
  * - **Every turn:** chat asks `tiers.model` through its `agentModel` resource,
26
28
  * for every agent, with the kind it works like. A change applies from each
27
29
  * conversation's next reply.
28
30
  * - **Plans first:** where the app has people's plans (providers with
29
31
  * `harness`: Claude Code, ChatGPT…), a turn's chain goes with the plans its
30
- * person has connected now (each `connectedPlans` source says), in their
31
- * order (`tiers.harnesses`; `modelChoice.harnesses` lists them), and each
32
- * model runs on those that serve it before any API: by the models a plan
33
- * said it runs, where it said (`served`). A tier names models;
34
- * an entry naming a plan (`claude-plan/…`) stands for its model on plans
35
- * only. `plansFor` (shared/plans.ts) is what a turn goes with, and
36
- * `models.check` what a chain would try.
32
+ * person has connected now (each `connectedPlans` source says), in one
33
+ * order for everyone (theirs: a maker's own plan before Cursor;
34
+ * `modelChoice.harnesses` lists them), and each model runs on those that
35
+ * serve it before any API, so a subscription pays for every model it runs,
36
+ * before credits: by the models a plan said it runs, where it said
37
+ * (`served`). A tier names models; an entry naming a plan (`claude-plan/…`)
38
+ * stands for its model on plans only. `plansFor` (shared/plans.ts) is what
39
+ * a turn goes with, and `models.check` what a chain would try.
37
40
  *
38
41
  * Its queries (`modelChoice.offered`, `modelChoice.agent`) show the tiers
39
42
  * with what a typical message comes to at the org's prices (the app's
@@ -67,7 +70,7 @@
67
70
  * ```
68
71
  */
69
72
  import { definePlugin } from "pairz";
70
- import { capAction, chooseAction, harnessesAction, kindAction, removeAction, restoreAction, saveAction, } from "./actions/choose.js";
73
+ import { capAction, chooseAction, kindAction, orderAction, removeAction, restoreAction, saveAction, } from "./actions/choose.js";
71
74
  import { modelAction } from "./actions/model.js";
72
75
  import { modelChoice } from "./collections/choice.js";
73
76
  import { tierKind, tierTemplate } from "./collections/template.js";
@@ -83,10 +86,10 @@ export const tiers = definePlugin({
83
86
  "tiers.choose": chooseAction,
84
87
  "tiers.cap": capAction,
85
88
  "tiers.save": saveAction,
89
+ "tiers.order": orderAction,
86
90
  "tiers.remove": removeAction,
87
91
  "tiers.restore": restoreAction,
88
92
  "tiers.kind": kindAction,
89
- "tiers.harnesses": harnessesAction,
90
93
  },
91
94
  resources: {
92
95
  // Chat asks it which model chain each agent thinks with.
@@ -1,16 +1,17 @@
1
1
  /**
2
2
  * A person's plans, as tiers run them: the app's (providers with `harness`,
3
- * the models plugin's), in the person's order (`harnesses` on their
4
- * `person:<id>` choice: theirs first, then the rest in the app's), and
5
- * those they've connected now (each `connectedPlans` source, asked as them
6
- * on every turn, never kept here), with the models those that said so run.
7
- * A turn's chain goes with them (`{ model, harnesses, served }`), and the
8
- * models plugin runs each model on them first. What a chain would try, in
9
- * order, is `models.check`'s answer.
3
+ * the models plugin's), in one order for everyone (their `order`: a maker's
4
+ * own plan before Cursor), those they've connected now (each
5
+ * `connectedPlans` source, asked as them on every turn, never kept here),
6
+ * with the models those that said so run. A turn's chain goes with them
7
+ * (`{ model, harnesses, served }`), and the models plugin runs each model on
8
+ * them first: whichever subscription of theirs runs a model pays for it,
9
+ * before any credits. What a chain would try, in order, is `models.check`'s
10
+ * answer.
10
11
  */
11
12
  import { type ReadContext, type Resources } from "pairz";
12
- import type { Provider } from "pairz/plugins/models/contract";
13
- /** One of the app's plans, as a person orders them. */
13
+ import { type Provider } from "pairz/plugins/models/contract";
14
+ /** One of the app's plans, as Your AI lists them. */
14
15
  export type HarnessShown = {
15
16
  /** Its provider: `claude-plan`. */
16
17
  name: string;
@@ -20,46 +21,41 @@ export type HarnessShown = {
20
21
  plan: string;
21
22
  /** The person has it now: their account, or signed in on a computer of theirs. */
22
23
  connected: boolean;
23
- /** The first model, in tier order, it runs (`claude-plan/claude-haiku-5-5`): what a test tries. */
24
- model: string;
24
+ /**
25
+ * The first model, in tier order, it runs (`claude-plan/claude-haiku-5-5`):
26
+ * what a test tries. For a connected plan that runs none of the tiers'
27
+ * models, the first its list has; none when it said no list.
28
+ */
29
+ model?: string;
25
30
  };
26
31
  /** The app's plans, by provider name. */
27
32
  export declare function harnessesOf(ctx: {
28
33
  resources: Resources;
29
34
  }): Record<string, Provider>;
30
- /** The app's plans in a person's order: theirs first (`mine`), then the rest, lowest `order` first. */
31
- export declare function orderOf(ctx: {
32
- resources: Resources;
33
- }, mine?: string[]): string[];
34
35
  /**
35
36
  * A person's plans, as a model list goes with them (`{ model, ...plans }`):
36
- * those they can run now, in their order, and the models those that said so
37
- * run (`served`, by plan), when any did.
37
+ * those they can run now, in the plans' order, and the models those that
38
+ * said so run (`served`, by plan), when any did.
38
39
  */
39
40
  export type Plans = {
40
41
  harnesses: string[];
41
42
  served?: Record<string, string[]>;
42
43
  };
43
- /**
44
- * The plans the person a call is for has connected now, as each source says
45
- * (as them), each with the models it said it runs, when it said.
46
- */
47
- export declare function connectedOf(ctx: Pick<ReadContext, "resources" | "call">): Promise<Map<string, string[] | undefined>>;
48
- /** Of `connected` (connectedOf's), the person's plans in their order (`mine`), with their lists. */
44
+ /** Of `connected` (`connectedOf`'s), the person's plans in the plans' order, with their lists. */
49
45
  export declare function plansOf(ctx: {
50
46
  resources: Resources;
51
- }, connected: Map<string, string[] | undefined>, mine?: string[]): Plans;
47
+ }, connected: Map<string, string[] | undefined>): Plans;
52
48
  /**
53
- * The plans the person a call is for can run now, in their order (`mine`:
54
- * their `harnesses`), with the models those that said so run: what a model
55
- * list goes with (`{ model, ...plans }`).
49
+ * The plans the person a call is for can run now, in the plans' order, with
50
+ * the models those that said so run: what a model list goes with
51
+ * (`{ model, ...plans }`).
56
52
  */
57
- export declare function plansFor(ctx: Pick<ReadContext, "resources" | "call" | "actor">, mine?: string[]): Promise<Plans>;
53
+ export declare function plansFor(ctx: Pick<ReadContext, "resources" | "call" | "actor">): Promise<Plans>;
58
54
  /**
59
- * The app's plans, as a person orders them: those that run a model some
60
- * tier of the org names (each chain, as it would be tried on every plan, by
61
- * the lists of those they've connected that said one), in their order, each
62
- * with whether they've connected it now, and the first model, in tier order,
63
- * it runs.
55
+ * The app's plans, as Your AI lists them: those that run a model some tier
56
+ * of the org names (each chain, as it would be tried on every plan, by the
57
+ * lists of those they've connected that said one), and those the person has
58
+ * connected, even running none; in the plans' order, each with whether
59
+ * they've connected it now, and the first model it runs.
64
60
  */
65
61
  export declare function harnessesShown(ctx: ReadContext): Promise<HarnessShown[]>;