@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.
- package/README.md +9 -4
- package/WORDS.md +23 -2
- package/package.json +2 -2
- package/team/actions/agent.js +12 -4
- package/team/collections/agent.d.ts +70 -15
- package/team/collections/agent.js +29 -7
- package/team/shared/definition.d.ts +15 -0
- package/team/shared/definition.js +17 -1
- package/team/views/web/model-pick.d.ts +10 -1
- package/team/views/web/model-pick.js +4 -2
- package/team/views/web/model-picker.d.ts +31 -5
- package/team/views/web/model-picker.js +74 -30
- package/team/views/web/words.d.ts +1 -1
- package/team/views/web/words.js +7 -0
- package/tiers/actions/choose.d.ts +48 -1
- package/tiers/actions/choose.js +143 -57
- package/tiers/actions/model.js +14 -9
- package/tiers/collections/choice.d.ts +15 -8
- package/tiers/collections/choice.js +22 -12
- package/tiers/collections/template.d.ts +6 -1
- package/tiers/collections/template.js +8 -4
- package/tiers/contract.d.ts +2 -2
- package/tiers/mod.d.ts +17 -9
- package/tiers/mod.js +26 -12
- package/tiers/shared/plans.d.ts +31 -33
- package/tiers/shared/plans.js +39 -54
- package/tiers/shared/shown.d.ts +16 -3
- package/tiers/shared/shown.js +43 -15
- package/tiers/shared/tiers.d.ts +38 -5
- package/tiers/shared/tiers.js +29 -3
- package/tiers/views/web/composer.d.ts +2 -1
- package/tiers/views/web/composer.js +8 -2
- package/tiers/views/web/org.d.ts +46 -11
- package/tiers/views/web/org.js +144 -61
- package/tiers/views/web/say.d.ts +17 -2
- package/tiers/views/web/say.js +17 -2
- package/tiers/views/web/space.d.ts +2 -1
- package/tiers/views/web/space.js +8 -4
- package/tiers/views/web/style.d.ts +1 -1
- package/tiers/views/web/style.js +5 -0
- package/tiers/web.d.ts +6 -5
- package/tiers/web.js +9 -8
package/tiers/actions/model.js
CHANGED
|
@@ -10,16 +10,20 @@
|
|
|
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
|
|
14
|
-
* those that said so run: `{ model: chain, harnesses, served? }`
|
|
15
|
-
* turn that's nobody's), and the models plugin runs each model
|
|
16
|
-
* (see shared/plans.ts).
|
|
17
|
-
*
|
|
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 before its API, model by model (see shared/plans.ts). Where the
|
|
17
|
+
* org uses members' subscriptions whenever possible (its `plansFirst`),
|
|
18
|
+
* every model on their plans first, then the tier's `fallbacks` on their
|
|
19
|
+
* plans only: `{ …, plansFirst: true, planFallbacks? }`. Asking which they
|
|
20
|
+
* have is one read per plugin that keeps plans, beside the rest.
|
|
18
21
|
*/
|
|
19
22
|
import { defineAction, personOf } from "pairz";
|
|
20
|
-
import { connectedOf
|
|
23
|
+
import { connectedOf } from "pairz/plugins/models/contract";
|
|
24
|
+
import { harnessesOf, plansOf } from "../shared/plans.js";
|
|
21
25
|
import { levelsOf, orgTiersOf } from "../shared/shown.js";
|
|
22
|
-
import { entryOf, kindOf, tierIn } from "../shared/tiers.js";
|
|
26
|
+
import { entryOf, kindOf, onPlans, tierIn } from "../shared/tiers.js";
|
|
23
27
|
export const modelAction = defineAction({
|
|
24
28
|
description: "The model chain an agent thinks with in a conversation",
|
|
25
29
|
record: false,
|
|
@@ -49,12 +53,13 @@ export const modelAction = defineAction({
|
|
|
49
53
|
plans && person ? connectedOf(ctx) : new Map(),
|
|
50
54
|
]);
|
|
51
55
|
const inForce = tierIn(tiers, levels);
|
|
56
|
+
const tier = inForce ? tiers[inForce.tier] : undefined;
|
|
52
57
|
const kind = kindOf(ctx, input.agent, undefined, kinds);
|
|
53
|
-
const chain = entryOf(
|
|
58
|
+
const chain = entryOf(tier, kind, kinds);
|
|
54
59
|
if (chain === undefined)
|
|
55
60
|
return null;
|
|
56
61
|
if (!plans)
|
|
57
62
|
return chain;
|
|
58
|
-
return { model: chain, ...plansOf(ctx, connected, levels.
|
|
63
|
+
return { model: chain, ...plansOf(ctx, connected), ...onPlans(levels.org, tier) };
|
|
59
64
|
},
|
|
60
65
|
});
|
|
@@ -5,17 +5,19 @@ export type ModelChoice = {
|
|
|
5
5
|
person?: string;
|
|
6
6
|
tier?: string;
|
|
7
7
|
cap?: string;
|
|
8
|
-
|
|
8
|
+
fixed?: boolean;
|
|
9
|
+
plansFirst?: boolean;
|
|
9
10
|
at: string;
|
|
10
11
|
};
|
|
11
12
|
export declare const modelChoice: Omit<import("pairz").CollectionDef, "schema" | "queries"> & {
|
|
12
13
|
queries?: Record<string, import("pairz").QueryDef<import("pairz").WithId<{
|
|
13
14
|
[x: string]: unknown;
|
|
15
|
+
fixed?: boolean | undefined;
|
|
14
16
|
space?: string | undefined;
|
|
15
17
|
thread?: string | undefined;
|
|
16
18
|
person?: string | undefined;
|
|
17
19
|
tier?: string | undefined;
|
|
18
|
-
|
|
20
|
+
plansFirst?: boolean | undefined;
|
|
19
21
|
cap?: string | undefined;
|
|
20
22
|
at: string;
|
|
21
23
|
}>>> | undefined;
|
|
@@ -41,12 +43,17 @@ export declare const modelChoice: Omit<import("pairz").CollectionDef, "schema" |
|
|
|
41
43
|
readonly cap: {
|
|
42
44
|
readonly type: "string";
|
|
43
45
|
};
|
|
44
|
-
/**
|
|
45
|
-
readonly
|
|
46
|
-
readonly type: "
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
/** The org's: its members use only its default; no space, conversation or person chooses. */
|
|
47
|
+
readonly fixed: {
|
|
48
|
+
readonly type: "boolean";
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* The org's: every model of a chain on a member's plans before any on
|
|
52
|
+
* credits, then the tier's fallbacks on their plans; none: model by
|
|
53
|
+
* model, in the tier's order.
|
|
54
|
+
*/
|
|
55
|
+
readonly plansFirst: {
|
|
56
|
+
readonly type: "boolean";
|
|
50
57
|
};
|
|
51
58
|
readonly at: {
|
|
52
59
|
readonly type: "string";
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Which tier applies where (`modelChoice`): the org's (`_id: "org"`, with
|
|
3
|
-
* `cap`, the highest tier
|
|
4
|
-
*
|
|
5
|
-
* (`
|
|
6
|
-
* (`
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
3
|
+
* what its members may use: `cap`, the highest tier they may choose, or
|
|
4
|
+
* `fixed`, only its default; and `plansFirst`, their subscriptions used
|
|
5
|
+
* whenever possible), a space's (`space:<id>`), a conversation's
|
|
6
|
+
* (`thread:<id>`) and a person's own default for new chats (`person:<id>`).
|
|
7
|
+
* Each a tier by its name, never a copy: changing a tier moves everyone on
|
|
8
|
+
* it. Changed only through `tiers.choose`, `tiers.cap` and
|
|
9
|
+
* `tiers.plansFirst`, which say who
|
|
10
|
+
* may; read by `_id`, so a turn's asking costs what the owner has cached. A
|
|
11
|
+
* person's choice saved when people ordered their plans may still hold
|
|
12
|
+
* `harnesses`: nothing reads it, and their next choice drops it.
|
|
10
13
|
*
|
|
11
14
|
* Queries, for front ends, as the person looking:
|
|
12
15
|
* - `offered` `{ space?, thread? }`: the org's tiers with each kind of
|
|
@@ -16,9 +19,10 @@
|
|
|
16
19
|
* conversation's, those who reach them.
|
|
17
20
|
* - `agent` `{ agent, space?, thread? }`: one agent there: its kind, the tier
|
|
18
21
|
* in force and its chain in it.
|
|
19
|
-
* - `harnesses` `{}`: the app's plans the person looking
|
|
20
|
-
* tier's model runs on
|
|
21
|
-
*
|
|
22
|
+
* - `harnesses` `{}`: the app's plans that pay for the person looking (those
|
|
23
|
+
* a tier's model runs on, and those they've connected), in the plans'
|
|
24
|
+
* order, each with whether they have it and the first model, in tier
|
|
25
|
+
* order, it runs (what a test of it tries).
|
|
22
26
|
*/
|
|
23
27
|
import { defineCollection, forbidden, people } from "pairz";
|
|
24
28
|
import { harnessesShown } from "../shared/plans.js";
|
|
@@ -34,8 +38,14 @@ const choiceSchema = {
|
|
|
34
38
|
tier: { type: "string" },
|
|
35
39
|
/** The org's: the highest tier its members may choose; none: any. */
|
|
36
40
|
cap: { type: "string" },
|
|
37
|
-
/**
|
|
38
|
-
|
|
41
|
+
/** The org's: its members use only its default; no space, conversation or person chooses. */
|
|
42
|
+
fixed: { type: "boolean" },
|
|
43
|
+
/**
|
|
44
|
+
* The org's: every model of a chain on a member's plans before any on
|
|
45
|
+
* credits, then the tier's fallbacks on their plans; none: model by
|
|
46
|
+
* model, in the tier's order.
|
|
47
|
+
*/
|
|
48
|
+
plansFirst: { type: "boolean" },
|
|
39
49
|
at: { type: "string" },
|
|
40
50
|
},
|
|
41
51
|
required: ["at"],
|
|
@@ -7,8 +7,9 @@ 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
|
+
fallbacks?: unknown[] | undefined;
|
|
12
|
+
made?: boolean | undefined;
|
|
12
13
|
at: string;
|
|
13
14
|
}>>> | undefined;
|
|
14
15
|
} & {
|
|
@@ -28,6 +29,10 @@ export declare const tierTemplate: Omit<import("pairz").CollectionDef, "schema"
|
|
|
28
29
|
readonly agents: {
|
|
29
30
|
readonly type: "object";
|
|
30
31
|
};
|
|
32
|
+
/** Models tried on members' plans after any chain, where the org says (`plansFirst`). */
|
|
33
|
+
readonly fallbacks: {
|
|
34
|
+
readonly type: "array";
|
|
35
|
+
};
|
|
31
36
|
readonly off: {
|
|
32
37
|
readonly type: "boolean";
|
|
33
38
|
};
|
|
@@ -1,9 +1,11 @@
|
|
|
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,
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* name): its version of one of the app's (kinds' chains changed, its
|
|
4
|
+
* fallbacks on members' plans, a title, its place among them, or `off`: taken
|
|
5
|
+
* away), or one it made (`made`, whole).
|
|
6
|
+
* Changed only through `tiers.save`, `tiers.order`, `tiers.remove` and
|
|
7
|
+
* `tiers.restore`, by the org's owners and admins; everyone in the org reads
|
|
8
|
+
* them, through `modelChoice.offered`.
|
|
7
9
|
*/
|
|
8
10
|
import { defineCollection } from "pairz";
|
|
9
11
|
export const tierTemplate = defineCollection({
|
|
@@ -15,6 +17,8 @@ export const tierTemplate = defineCollection({
|
|
|
15
17
|
order: { type: "number" },
|
|
16
18
|
/** Kinds of work's chains, by kind. */
|
|
17
19
|
agents: { type: "object" },
|
|
20
|
+
/** Models tried on members' plans after any chain, where the org says (`plansFirst`). */
|
|
21
|
+
fallbacks: { type: "array" },
|
|
18
22
|
off: { type: "boolean" },
|
|
19
23
|
made: { type: "boolean" },
|
|
20
24
|
at: { type: "string" },
|
package/tiers/contract.d.ts
CHANGED
|
@@ -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.
|
|
10
|
-
* `tiers.
|
|
9
|
+
* `tiers.cap`, `tiers.plansFirst`, `tiers.save`, `tiers.order`,
|
|
10
|
+
* `tiers.remove`, `tiers.restore`, `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,19 +19,25 @@
|
|
|
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
|
|
23
|
-
* what its members
|
|
24
|
-
* bound by
|
|
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
|
+
* - **On people's plans:** 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
|
|
31
|
-
* order (
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
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), by the models a plan said it runs,
|
|
35
|
+
* where it said (`served`). The tier's models run in its order, each on
|
|
36
|
+
* their plans that run it, then on credits. An org that wants members'
|
|
37
|
+
* subscriptions used whenever possible says so (`tiers.plansFirst`): every
|
|
38
|
+
* model on their plans before any on credits, then the tier's `fallbacks`
|
|
39
|
+
* (one model per maker) on their plans only. A tier names models; an
|
|
40
|
+
* entry naming a plan (`claude-plan/…`) stands for its model on plans
|
|
35
41
|
* only. `plansFor` (shared/plans.ts) is what a turn goes with, and
|
|
36
42
|
* `models.check` what a chain would try.
|
|
37
43
|
*
|
|
@@ -60,6 +66,8 @@
|
|
|
60
66
|
* north: [{ model: "anthropic/claude-opus-5-5", effort: "medium" }, "openai/gpt-6.1-sol"],
|
|
61
67
|
* east: { model: "anthropic/claude-sonnet-5-5", effort: "high" },
|
|
62
68
|
* },
|
|
69
|
+
* // On members' plans only, where the org uses them whenever possible.
|
|
70
|
+
* fallbacks: ["anthropic/claude-opus-5-5", "openai/gpt-6.2-sol"],
|
|
63
71
|
* },
|
|
64
72
|
* },
|
|
65
73
|
* },
|
package/tiers/mod.js
CHANGED
|
@@ -19,19 +19,25 @@
|
|
|
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
|
|
23
|
-
* what its members
|
|
24
|
-
* bound by
|
|
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
|
+
* - **On people's plans:** 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
|
|
31
|
-
* order (
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
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), by the models a plan said it runs,
|
|
35
|
+
* where it said (`served`). The tier's models run in its order, each on
|
|
36
|
+
* their plans that run it, then on credits. An org that wants members'
|
|
37
|
+
* subscriptions used whenever possible says so (`tiers.plansFirst`): every
|
|
38
|
+
* model on their plans before any on credits, then the tier's `fallbacks`
|
|
39
|
+
* (one model per maker) on their plans only. A tier names models; an
|
|
40
|
+
* entry naming a plan (`claude-plan/…`) stands for its model on plans
|
|
35
41
|
* only. `plansFor` (shared/plans.ts) is what a turn goes with, and
|
|
36
42
|
* `models.check` what a chain would try.
|
|
37
43
|
*
|
|
@@ -60,6 +66,8 @@
|
|
|
60
66
|
* north: [{ model: "anthropic/claude-opus-5-5", effort: "medium" }, "openai/gpt-6.1-sol"],
|
|
61
67
|
* east: { model: "anthropic/claude-sonnet-5-5", effort: "high" },
|
|
62
68
|
* },
|
|
69
|
+
* // On members' plans only, where the org uses them whenever possible.
|
|
70
|
+
* fallbacks: ["anthropic/claude-opus-5-5", "openai/gpt-6.2-sol"],
|
|
63
71
|
* },
|
|
64
72
|
* },
|
|
65
73
|
* },
|
|
@@ -67,7 +75,7 @@
|
|
|
67
75
|
* ```
|
|
68
76
|
*/
|
|
69
77
|
import { definePlugin } from "pairz";
|
|
70
|
-
import { capAction,
|
|
78
|
+
import { capAction, checkFallback, chooseAction, kindAction, orderAction, plansFirstAction, removeAction, restoreAction, saveAction, } from "./actions/choose.js";
|
|
71
79
|
import { modelAction } from "./actions/model.js";
|
|
72
80
|
import { modelChoice } from "./collections/choice.js";
|
|
73
81
|
import { tierKind, tierTemplate } from "./collections/template.js";
|
|
@@ -82,17 +90,18 @@ export const tiers = definePlugin({
|
|
|
82
90
|
"tiers.model": modelAction,
|
|
83
91
|
"tiers.choose": chooseAction,
|
|
84
92
|
"tiers.cap": capAction,
|
|
93
|
+
"tiers.plansFirst": plansFirstAction,
|
|
85
94
|
"tiers.save": saveAction,
|
|
95
|
+
"tiers.order": orderAction,
|
|
86
96
|
"tiers.remove": removeAction,
|
|
87
97
|
"tiers.restore": restoreAction,
|
|
88
98
|
"tiers.kind": kindAction,
|
|
89
|
-
"tiers.harnesses": harnessesAction,
|
|
90
99
|
},
|
|
91
100
|
resources: {
|
|
92
101
|
// Chat asks it which model chain each agent thinks with.
|
|
93
102
|
agentModel: { tiers: { action: "tiers.model" } },
|
|
94
103
|
},
|
|
95
|
-
// Every tier has a title,
|
|
104
|
+
// Every tier has a title, models that can be called as configured, and fallbacks a plan runs.
|
|
96
105
|
async check(merged) {
|
|
97
106
|
for (const [name, tier] of Object.entries(appTiersOf(merged))) {
|
|
98
107
|
if (!tier.title)
|
|
@@ -105,6 +114,11 @@ export const tiers = definePlugin({
|
|
|
105
114
|
throw new Error(`Tier "${name}", ${kind}: ${error.message}`);
|
|
106
115
|
}
|
|
107
116
|
}
|
|
117
|
+
for (const fallback of tier.fallbacks ?? []) {
|
|
118
|
+
await checkFallback(merged, fallback).catch((error) => {
|
|
119
|
+
throw new Error(`Tier "${name}", fallbacks: ${error.message}`);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
108
122
|
}
|
|
109
123
|
},
|
|
110
124
|
});
|
package/tiers/shared/plans.d.ts
CHANGED
|
@@ -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
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* order, is `models.check`'s
|
|
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
|
|
13
|
-
/** One of the app's plans, as
|
|
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,43 @@ 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
|
-
/**
|
|
24
|
-
|
|
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
|
|
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
|
|
47
|
+
}, connected: Map<string, string[] | undefined>): Plans;
|
|
52
48
|
/**
|
|
53
|
-
* The plans the person a call is for can run now, in
|
|
54
|
-
*
|
|
55
|
-
*
|
|
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"
|
|
53
|
+
export declare function plansFor(ctx: Pick<ReadContext, "resources" | "call" | "actor">): Promise<Plans>;
|
|
58
54
|
/**
|
|
59
|
-
* The app's plans, as
|
|
60
|
-
*
|
|
61
|
-
* the
|
|
62
|
-
*
|
|
63
|
-
*
|
|
55
|
+
* The app's plans, as Your AI lists them: every one, since any model can go
|
|
56
|
+
* in a tier (connecting Grok's plan is what makes Grok free in the picker);
|
|
57
|
+
* in the plans' order, each with whether they've connected it now, and the
|
|
58
|
+
* first model, in tier order, it runs (each chain, as it would be tried on
|
|
59
|
+
* every plan, by the lists of those they've connected that said one): what
|
|
60
|
+
* its test tries. One that runs none of the tiers' models is tested on the
|
|
61
|
+
* first its list has, or not at all.
|
|
64
62
|
*/
|
|
65
63
|
export declare function harnessesShown(ctx: ReadContext): Promise<HarnessShown[]>;
|
package/tiers/shared/plans.js
CHANGED
|
@@ -1,73 +1,54 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A person's plans, as tiers run them: the app's (providers with `harness`,
|
|
3
|
-
* the models plugin's), in
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* order, is `models.check`'s
|
|
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 { personOf } from "pairz";
|
|
13
|
+
import { connectedOf, plansInOrder } from "pairz/plugins/models/contract";
|
|
12
14
|
import { orgTiersOf } from "./shown.js";
|
|
13
|
-
import { personChoice } from "./tiers.js";
|
|
14
15
|
/** The app's plans, by provider name. */
|
|
15
16
|
export function harnessesOf(ctx) {
|
|
16
17
|
const declared = (ctx.resources.provider ?? {});
|
|
17
18
|
return Object.fromEntries(Object.entries(declared).filter((entry) => !!entry[1]?.harness));
|
|
18
19
|
}
|
|
19
|
-
/**
|
|
20
|
-
export function
|
|
21
|
-
const
|
|
22
|
-
const byDefault = Object.keys(plans).sort((a, b) => plans[a].harness.order - plans[b].harness.order || a.localeCompare(b));
|
|
23
|
-
const theirs = mine.filter((name, i) => plans[name] && mine.indexOf(name) === i);
|
|
24
|
-
return [...theirs, ...byDefault.filter((name) => !theirs.includes(name))];
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* The plans the person a call is for has connected now, as each source says
|
|
28
|
-
* (as them), each with the models it said it runs, when it said.
|
|
29
|
-
*/
|
|
30
|
-
export async function connectedOf(ctx) {
|
|
31
|
-
const sources = Object.values((ctx.resources.connectedPlans ?? {})).filter((source) => !!source?.action);
|
|
32
|
-
const said = await Promise.all(sources.map((source) => ctx.call(source.action, {}).catch(() => [])));
|
|
33
|
-
return new Map(said.flat().map((plan) => typeof plan === "string" ? [plan, undefined] : [plan.plan, plan.models]));
|
|
34
|
-
}
|
|
35
|
-
/** Of `connected` (connectedOf's), the person's plans in their order (`mine`), with their lists. */
|
|
36
|
-
export function plansOf(ctx, connected, mine) {
|
|
37
|
-
const harnesses = orderOf(ctx, mine).filter((name) => connected.has(name));
|
|
20
|
+
/** Of `connected` (`connectedOf`'s), the person's plans in the plans' order, with their lists. */
|
|
21
|
+
export function plansOf(ctx, connected) {
|
|
22
|
+
const harnesses = plansInOrder(harnessesOf(ctx)).filter((name) => connected.has(name));
|
|
38
23
|
const served = Object.fromEntries(harnesses.flatMap((name) => connected.get(name) ? [[name, connected.get(name)]] : []));
|
|
39
24
|
return { harnesses, ...(Object.keys(served).length ? { served } : {}) };
|
|
40
25
|
}
|
|
41
26
|
/**
|
|
42
|
-
* The plans the person a call is for can run now, in
|
|
43
|
-
*
|
|
44
|
-
*
|
|
27
|
+
* The plans the person a call is for can run now, in the plans' order, with
|
|
28
|
+
* the models those that said so run: what a model list goes with
|
|
29
|
+
* (`{ model, ...plans }`).
|
|
45
30
|
*/
|
|
46
|
-
export async function plansFor(ctx
|
|
31
|
+
export async function plansFor(ctx) {
|
|
47
32
|
if (!personOf(ctx.actor) || !Object.keys(harnessesOf(ctx)).length)
|
|
48
33
|
return { harnesses: [] };
|
|
49
|
-
return plansOf(ctx, await connectedOf(ctx)
|
|
34
|
+
return plansOf(ctx, await connectedOf(ctx));
|
|
50
35
|
}
|
|
51
36
|
/**
|
|
52
|
-
* The app's plans, as
|
|
53
|
-
*
|
|
54
|
-
* the
|
|
55
|
-
*
|
|
56
|
-
*
|
|
37
|
+
* The app's plans, as Your AI lists them: every one, since any model can go
|
|
38
|
+
* in a tier (connecting Grok's plan is what makes Grok free in the picker);
|
|
39
|
+
* in the plans' order, each with whether they've connected it now, and the
|
|
40
|
+
* first model, in tier order, it runs (each chain, as it would be tried on
|
|
41
|
+
* every plan, by the lists of those they've connected that said one): what
|
|
42
|
+
* its test tries. One that runs none of the tiers' models is tested on the
|
|
43
|
+
* first its list has, or not at all.
|
|
57
44
|
*/
|
|
58
45
|
export async function harnessesShown(ctx) {
|
|
59
46
|
const plans = harnessesOf(ctx);
|
|
60
|
-
|
|
61
|
-
if (!person || !Object.keys(plans).length)
|
|
47
|
+
if (!personOf(ctx.actor) || !Object.keys(plans).length)
|
|
62
48
|
return [];
|
|
63
|
-
const all =
|
|
64
|
-
const [{ tiers },
|
|
65
|
-
|
|
66
|
-
ctx.db.collection("modelChoice").findOne({ _id: personChoice(person) }),
|
|
67
|
-
connectedOf(ctx),
|
|
68
|
-
]);
|
|
69
|
-
const chains = Object.values(tiers).sort((a, b) => (a.order ?? 0) - (b.order ?? 0))
|
|
70
|
-
.flatMap((tier) => Object.values(tier.agents));
|
|
49
|
+
const all = plansInOrder(plans);
|
|
50
|
+
const [{ tiers }, connected] = await Promise.all([orgTiersOf(ctx), connectedOf(ctx)]);
|
|
51
|
+
const chains = Object.values(tiers).flatMap((tier) => Object.values(tier.agents));
|
|
71
52
|
// Every plan, those that said which models they run by their lists.
|
|
72
53
|
const { served } = plansOf(ctx, connected);
|
|
73
54
|
const tried = await Promise.all(chains.map((chain) => ctx.call("models.check", {
|
|
@@ -81,11 +62,15 @@ export async function harnessesShown(ctx) {
|
|
|
81
62
|
if (!first.has(provider))
|
|
82
63
|
first.set(provider, id);
|
|
83
64
|
}
|
|
84
|
-
return
|
|
85
|
-
name
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
65
|
+
return all.map((name) => {
|
|
66
|
+
const listed = connected.get(name)?.[0];
|
|
67
|
+
const model = first.get(name) ?? (listed ? `${name}/${listed}` : undefined);
|
|
68
|
+
return {
|
|
69
|
+
name,
|
|
70
|
+
title: plans[name].title ?? name,
|
|
71
|
+
plan: plans[name].harness.plan,
|
|
72
|
+
connected: connected.has(name),
|
|
73
|
+
...(model ? { model } : {}),
|
|
74
|
+
};
|
|
75
|
+
});
|
|
91
76
|
}
|
package/tiers/shared/shown.d.ts
CHANGED
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
* from the cache (a conversation's history mostly is), and 1,000 out, each
|
|
14
14
|
* agent's alike, and a tier's price is its agents' average.
|
|
15
15
|
*
|
|
16
|
-
* With the person's plans (`plansFor`: those they can run now, in
|
|
16
|
+
* With the person's plans (`plansFor`: those they can run now, in the plans'
|
|
17
17
|
* order, and the models those that said so run), each chain is also priced
|
|
18
|
-
* as their turns would run it: at the
|
|
19
|
-
*
|
|
18
|
+
* as their turns would run it: at the first model it would try for them
|
|
19
|
+
* (`models.check`, as the org has members' plans used: `onPlans`), one of
|
|
20
20
|
* their plans costing them nothing (`plan`), and a tier's price for them
|
|
21
21
|
* (`yours`) beside the app's (`price`, which pages choosing for others show).
|
|
22
22
|
*/
|
|
@@ -101,6 +101,12 @@ export type TierShown = {
|
|
|
101
101
|
kind: string;
|
|
102
102
|
model: ModelShown;
|
|
103
103
|
}[];
|
|
104
|
+
/** Its fallbacks on members' plans, in order: where the org uses them whenever possible. */
|
|
105
|
+
fallbacks?: {
|
|
106
|
+
id: string;
|
|
107
|
+
name: string;
|
|
108
|
+
effort?: string;
|
|
109
|
+
}[];
|
|
104
110
|
};
|
|
105
111
|
/** A kind of work: its title, and the app's agents that do it. */
|
|
106
112
|
export type KindShown = {
|
|
@@ -125,9 +131,16 @@ export type Shown = {
|
|
|
125
131
|
}[];
|
|
126
132
|
/** The tier the org's plan gives, when the app has plans that say. */
|
|
127
133
|
plan: string | null;
|
|
134
|
+
/**
|
|
135
|
+
* The org's default, and what its members may use: up to `cap`, or only the
|
|
136
|
+
* default (`fixed`); where the app has plans, whether members'
|
|
137
|
+
* subscriptions are used whenever possible (`plansFirst`).
|
|
138
|
+
*/
|
|
128
139
|
org: {
|
|
129
140
|
tier: string | null;
|
|
130
141
|
cap: string | null;
|
|
142
|
+
fixed: boolean;
|
|
143
|
+
plansFirst?: boolean;
|
|
131
144
|
};
|
|
132
145
|
space?: {
|
|
133
146
|
tier: string | null;
|