@pairz/team 0.0.1 → 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.
- package/LICENSE +21 -0
- package/README.md +51 -1
- package/WORDS.md +370 -0
- package/contract.d.ts +8 -0
- package/contract.js +8 -0
- package/mod.d.ts +25 -0
- package/mod.js +25 -0
- package/package.json +61 -3
- package/team/actions/agent.d.ts +14 -0
- package/team/actions/agent.js +401 -0
- package/team/actions/define.d.ts +1 -0
- package/team/actions/define.js +45 -0
- package/team/collections/agent.d.ts +170 -0
- package/team/collections/agent.js +126 -0
- package/team/contract.d.ts +11 -0
- package/team/contract.js +1 -0
- package/team/mod.d.ts +28 -0
- package/team/mod.js +64 -0
- package/team/resources/propose.d.ts +1 -0
- package/team/resources/propose.js +102 -0
- package/team/shared/definition.d.ts +3 -0
- package/team/shared/definition.js +11 -0
- package/team/shared/everywhere.d.ts +11 -0
- package/team/shared/everywhere.js +29 -0
- package/team/shared/limits.d.ts +17 -0
- package/team/shared/limits.js +17 -0
- package/team/views/web/agent-add.d.ts +14 -0
- package/team/views/web/agent-add.js +58 -0
- package/team/views/web/agent-describe.d.ts +38 -0
- package/team/views/web/agent-describe.js +44 -0
- package/team/views/web/agent-fields.d.ts +35 -0
- package/team/views/web/agent-fields.js +88 -0
- package/team/views/web/agent-known.d.ts +22 -0
- package/team/views/web/agent-known.js +62 -0
- package/team/views/web/agent-new.d.ts +27 -0
- package/team/views/web/agent-new.js +150 -0
- package/team/views/web/agent-org.d.ts +12 -0
- package/team/views/web/agent-org.js +89 -0
- package/team/views/web/agent-palette.d.ts +19 -0
- package/team/views/web/agent-palette.js +203 -0
- package/team/views/web/agent-steps.d.ts +23 -0
- package/team/views/web/agent-steps.js +56 -0
- package/team/views/web/agent.d.ts +20 -0
- package/team/views/web/agent.js +310 -0
- package/team/views/web/agents.d.ts +48 -0
- package/team/views/web/agents.js +59 -0
- package/team/views/web/model-pick.d.ts +36 -0
- package/team/views/web/model-pick.js +44 -0
- package/team/views/web/model-picker.d.ts +83 -0
- package/team/views/web/model-picker.js +262 -0
- package/team/views/web/places.d.ts +24 -0
- package/team/views/web/places.js +10 -0
- package/team/views/web/style.d.ts +9 -0
- package/team/views/web/style.js +251 -0
- package/team/views/web/words.d.ts +5 -0
- package/team/views/web/words.js +246 -0
- package/team/web.d.ts +22 -0
- package/team/web.js +43 -0
- package/tiers/actions/choose.d.ts +7 -0
- package/tiers/actions/choose.js +336 -0
- package/tiers/actions/model.d.ts +1 -0
- package/tiers/actions/model.js +61 -0
- package/tiers/collections/choice.d.ts +54 -0
- package/tiers/collections/choice.js +81 -0
- package/tiers/collections/template.d.ts +76 -0
- package/tiers/collections/template.js +42 -0
- package/tiers/contract.d.ts +23 -0
- package/tiers/contract.js +1 -0
- package/tiers/mod.d.ts +75 -0
- package/tiers/mod.js +114 -0
- package/tiers/shared/plans.d.ts +61 -0
- package/tiers/shared/plans.js +74 -0
- package/tiers/shared/shown.d.ts +189 -0
- package/tiers/shared/shown.js +284 -0
- package/tiers/shared/tiers.d.ts +157 -0
- package/tiers/shared/tiers.js +179 -0
- package/tiers/views/web/composer.d.ts +15 -0
- package/tiers/views/web/composer.js +87 -0
- package/tiers/views/web/org.d.ts +69 -0
- package/tiers/views/web/org.js +334 -0
- package/tiers/views/web/say.d.ts +146 -0
- package/tiers/views/web/say.js +150 -0
- package/tiers/views/web/setup.d.ts +23 -0
- package/tiers/views/web/setup.js +80 -0
- package/tiers/views/web/space.d.ts +32 -0
- package/tiers/views/web/space.js +78 -0
- package/tiers/views/web/style.d.ts +7 -0
- package/tiers/views/web/style.js +193 -0
- package/tiers/views/web/team.d.ts +38 -0
- package/tiers/views/web/team.js +118 -0
- package/tiers/views/web/words.d.ts +48 -0
- package/tiers/views/web/words.js +122 -0
- package/tiers/web.d.ts +31 -0
- package/tiers/web.js +72 -0
- package/web.d.ts +14 -0
- package/web.js +14 -0
package/tiers/mod.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tiers: how hard an app's agents think, chosen by budget rather than model
|
|
3
|
+
* by model. Agents don't hold models here: each does a **kind of work**, and
|
|
4
|
+
* a **tier** is a template giving each kind a model chain (a model, its
|
|
5
|
+
* effort, and what's tried after it when it fails). Every conversation runs
|
|
6
|
+
* on a tier.
|
|
7
|
+
*
|
|
8
|
+
* - **The app** declares its tiers (`tiers`: each a title, what it's good
|
|
9
|
+
* for, an order, and a chain for each kind, as an agent's `model` takes
|
|
10
|
+
* one) and names its kinds (`tierKinds`: `{ north: { title: "Decides" } }`;
|
|
11
|
+
* the kinds are the tiers' keys, and an app agent of that name does that
|
|
12
|
+
* kind). Any other agent says which kind it does (`like`), else it does the
|
|
13
|
+
* app's first.
|
|
14
|
+
* - **An org** keeps its own version of each tier (kinds' chains changed, a
|
|
15
|
+
* title), takes tiers away, makes new ones (`tiers.save`, `tiers.remove`,
|
|
16
|
+
* `tiers.restore`; `tierTemplate`), and adds kinds of work of its own, each
|
|
17
|
+
* based on one of the app's (`tiers.kind`; `tierKind`). Its owners and
|
|
18
|
+
* admins do; everyone in it reads them.
|
|
19
|
+
* - **Which tier, first that applies:** the conversation's, the person's own
|
|
20
|
+
* default for new chats, the space's, the org's, then the tier the org's
|
|
21
|
+
* plan gives (the `planTier` resource, which credits fills)
|
|
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`).
|
|
27
|
+
* - **Every turn:** chat asks `tiers.model` through its `agentModel` resource,
|
|
28
|
+
* for every agent, with the kind it works like. A change applies from each
|
|
29
|
+
* conversation's next reply.
|
|
30
|
+
* - **Plans first:** where the app has people's plans (providers with
|
|
31
|
+
* `harness`: Claude Code, ChatGPT…), a turn's chain goes with the plans its
|
|
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.
|
|
40
|
+
*
|
|
41
|
+
* Its queries (`modelChoice.offered`, `modelChoice.agent`) show the tiers
|
|
42
|
+
* with what a typical message comes to at the org's prices (the app's
|
|
43
|
+
* `typicalMessage`, measured, else a plain reply), and how far the plan's
|
|
44
|
+
* credits go (`planCredits`).
|
|
45
|
+
*
|
|
46
|
+
* ```ts
|
|
47
|
+
* plugins: [models, chat, ...access, tiers, definePlugin({
|
|
48
|
+
* name: "app",
|
|
49
|
+
* resources: {
|
|
50
|
+
* tierKinds: { north: { title: "Decides" }, east: { title: "Builds" } },
|
|
51
|
+
* tiers: {
|
|
52
|
+
* everyday: {
|
|
53
|
+
* title: "Everyday",
|
|
54
|
+
* description: "Quick answers, routine work, volume",
|
|
55
|
+
* order: 1,
|
|
56
|
+
* agents: { north: "anthropic/claude-haiku-5-5", east: "openai/gpt-6-luna" },
|
|
57
|
+
* },
|
|
58
|
+
* expert: {
|
|
59
|
+
* title: "Expert",
|
|
60
|
+
* description: "Hard problems, decisions that matter",
|
|
61
|
+
* order: 3,
|
|
62
|
+
* agents: {
|
|
63
|
+
* north: [{ model: "anthropic/claude-opus-5-5", effort: "medium" }, "openai/gpt-6.1-sol"],
|
|
64
|
+
* east: { model: "anthropic/claude-sonnet-5-5", effort: "high" },
|
|
65
|
+
* },
|
|
66
|
+
* },
|
|
67
|
+
* },
|
|
68
|
+
* },
|
|
69
|
+
* })]
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
import { type Plugin } from "pairz";
|
|
73
|
+
export * from "./contract.js";
|
|
74
|
+
export declare const tiers: Plugin;
|
|
75
|
+
export default tiers;
|
package/tiers/mod.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tiers: how hard an app's agents think, chosen by budget rather than model
|
|
3
|
+
* by model. Agents don't hold models here: each does a **kind of work**, and
|
|
4
|
+
* a **tier** is a template giving each kind a model chain (a model, its
|
|
5
|
+
* effort, and what's tried after it when it fails). Every conversation runs
|
|
6
|
+
* on a tier.
|
|
7
|
+
*
|
|
8
|
+
* - **The app** declares its tiers (`tiers`: each a title, what it's good
|
|
9
|
+
* for, an order, and a chain for each kind, as an agent's `model` takes
|
|
10
|
+
* one) and names its kinds (`tierKinds`: `{ north: { title: "Decides" } }`;
|
|
11
|
+
* the kinds are the tiers' keys, and an app agent of that name does that
|
|
12
|
+
* kind). Any other agent says which kind it does (`like`), else it does the
|
|
13
|
+
* app's first.
|
|
14
|
+
* - **An org** keeps its own version of each tier (kinds' chains changed, a
|
|
15
|
+
* title), takes tiers away, makes new ones (`tiers.save`, `tiers.remove`,
|
|
16
|
+
* `tiers.restore`; `tierTemplate`), and adds kinds of work of its own, each
|
|
17
|
+
* based on one of the app's (`tiers.kind`; `tierKind`). Its owners and
|
|
18
|
+
* admins do; everyone in it reads them.
|
|
19
|
+
* - **Which tier, first that applies:** the conversation's, the person's own
|
|
20
|
+
* default for new chats, the space's, the org's, then the tier the org's
|
|
21
|
+
* plan gives (the `planTier` resource, which credits fills)
|
|
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`).
|
|
27
|
+
* - **Every turn:** chat asks `tiers.model` through its `agentModel` resource,
|
|
28
|
+
* for every agent, with the kind it works like. A change applies from each
|
|
29
|
+
* conversation's next reply.
|
|
30
|
+
* - **Plans first:** where the app has people's plans (providers with
|
|
31
|
+
* `harness`: Claude Code, ChatGPT…), a turn's chain goes with the plans its
|
|
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.
|
|
40
|
+
*
|
|
41
|
+
* Its queries (`modelChoice.offered`, `modelChoice.agent`) show the tiers
|
|
42
|
+
* with what a typical message comes to at the org's prices (the app's
|
|
43
|
+
* `typicalMessage`, measured, else a plain reply), and how far the plan's
|
|
44
|
+
* credits go (`planCredits`).
|
|
45
|
+
*
|
|
46
|
+
* ```ts
|
|
47
|
+
* plugins: [models, chat, ...access, tiers, definePlugin({
|
|
48
|
+
* name: "app",
|
|
49
|
+
* resources: {
|
|
50
|
+
* tierKinds: { north: { title: "Decides" }, east: { title: "Builds" } },
|
|
51
|
+
* tiers: {
|
|
52
|
+
* everyday: {
|
|
53
|
+
* title: "Everyday",
|
|
54
|
+
* description: "Quick answers, routine work, volume",
|
|
55
|
+
* order: 1,
|
|
56
|
+
* agents: { north: "anthropic/claude-haiku-5-5", east: "openai/gpt-6-luna" },
|
|
57
|
+
* },
|
|
58
|
+
* expert: {
|
|
59
|
+
* title: "Expert",
|
|
60
|
+
* description: "Hard problems, decisions that matter",
|
|
61
|
+
* order: 3,
|
|
62
|
+
* agents: {
|
|
63
|
+
* north: [{ model: "anthropic/claude-opus-5-5", effort: "medium" }, "openai/gpt-6.1-sol"],
|
|
64
|
+
* east: { model: "anthropic/claude-sonnet-5-5", effort: "high" },
|
|
65
|
+
* },
|
|
66
|
+
* },
|
|
67
|
+
* },
|
|
68
|
+
* },
|
|
69
|
+
* })]
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
import { definePlugin } from "pairz";
|
|
73
|
+
import { capAction, chooseAction, kindAction, orderAction, removeAction, restoreAction, saveAction, } from "./actions/choose.js";
|
|
74
|
+
import { modelAction } from "./actions/model.js";
|
|
75
|
+
import { modelChoice } from "./collections/choice.js";
|
|
76
|
+
import { tierKind, tierTemplate } from "./collections/template.js";
|
|
77
|
+
import { appTiersOf } from "./shared/tiers.js";
|
|
78
|
+
export * from "./contract.js";
|
|
79
|
+
export const tiers = definePlugin({
|
|
80
|
+
name: "tiers",
|
|
81
|
+
// Its choices are an org's, its spaces' and its conversations', changed by who runs them.
|
|
82
|
+
requires: ["chat", "spaces"],
|
|
83
|
+
collections: { modelChoice, tierTemplate, tierKind },
|
|
84
|
+
actions: {
|
|
85
|
+
"tiers.model": modelAction,
|
|
86
|
+
"tiers.choose": chooseAction,
|
|
87
|
+
"tiers.cap": capAction,
|
|
88
|
+
"tiers.save": saveAction,
|
|
89
|
+
"tiers.order": orderAction,
|
|
90
|
+
"tiers.remove": removeAction,
|
|
91
|
+
"tiers.restore": restoreAction,
|
|
92
|
+
"tiers.kind": kindAction,
|
|
93
|
+
},
|
|
94
|
+
resources: {
|
|
95
|
+
// Chat asks it which model chain each agent thinks with.
|
|
96
|
+
agentModel: { tiers: { action: "tiers.model" } },
|
|
97
|
+
},
|
|
98
|
+
// Every tier has a title, and models that can be called as configured.
|
|
99
|
+
async check(merged) {
|
|
100
|
+
for (const [name, tier] of Object.entries(appTiersOf(merged))) {
|
|
101
|
+
if (!tier.title)
|
|
102
|
+
throw new Error(`Tier "${name}" has no title`);
|
|
103
|
+
for (const [kind, model] of Object.entries(tier.agents ?? {})) {
|
|
104
|
+
try {
|
|
105
|
+
await merged.call("models.check", { model, port: "llm" });
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
throw new Error(`Tier "${name}", ${kind}: ${error.message}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
export default tiers;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A person's plans, as tiers run them: the app's (providers with `harness`,
|
|
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.
|
|
11
|
+
*/
|
|
12
|
+
import { type ReadContext, type Resources } from "pairz";
|
|
13
|
+
import { type Provider } from "pairz/plugins/models/contract";
|
|
14
|
+
/** One of the app's plans, as Your AI lists them. */
|
|
15
|
+
export type HarnessShown = {
|
|
16
|
+
/** Its provider: `claude-plan`. */
|
|
17
|
+
name: string;
|
|
18
|
+
/** What people call it: "Claude plan". */
|
|
19
|
+
title: string;
|
|
20
|
+
/** The plan it runs on ("ChatGPT"): two ways to run one plan show as one. */
|
|
21
|
+
plan: string;
|
|
22
|
+
/** The person has it now: their account, or signed in on a computer of theirs. */
|
|
23
|
+
connected: boolean;
|
|
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;
|
|
30
|
+
};
|
|
31
|
+
/** The app's plans, by provider name. */
|
|
32
|
+
export declare function harnessesOf(ctx: {
|
|
33
|
+
resources: Resources;
|
|
34
|
+
}): Record<string, Provider>;
|
|
35
|
+
/**
|
|
36
|
+
* A person's plans, as a model list goes with them (`{ model, ...plans }`):
|
|
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.
|
|
39
|
+
*/
|
|
40
|
+
export type Plans = {
|
|
41
|
+
harnesses: string[];
|
|
42
|
+
served?: Record<string, string[]>;
|
|
43
|
+
};
|
|
44
|
+
/** Of `connected` (`connectedOf`'s), the person's plans in the plans' order, with their lists. */
|
|
45
|
+
export declare function plansOf(ctx: {
|
|
46
|
+
resources: Resources;
|
|
47
|
+
}, connected: Map<string, string[] | undefined>): Plans;
|
|
48
|
+
/**
|
|
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 }`).
|
|
52
|
+
*/
|
|
53
|
+
export declare function plansFor(ctx: Pick<ReadContext, "resources" | "call" | "actor">): Promise<Plans>;
|
|
54
|
+
/**
|
|
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.
|
|
60
|
+
*/
|
|
61
|
+
export declare function harnessesShown(ctx: ReadContext): Promise<HarnessShown[]>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A person's plans, as tiers run them: the app's (providers with `harness`,
|
|
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.
|
|
11
|
+
*/
|
|
12
|
+
import { personOf } from "pairz";
|
|
13
|
+
import { connectedOf, plansInOrder } from "pairz/plugins/models/contract";
|
|
14
|
+
import { orgTiersOf } from "./shown.js";
|
|
15
|
+
/** The app's plans, by provider name. */
|
|
16
|
+
export function harnessesOf(ctx) {
|
|
17
|
+
const declared = (ctx.resources.provider ?? {});
|
|
18
|
+
return Object.fromEntries(Object.entries(declared).filter((entry) => !!entry[1]?.harness));
|
|
19
|
+
}
|
|
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));
|
|
23
|
+
const served = Object.fromEntries(harnesses.flatMap((name) => connected.get(name) ? [[name, connected.get(name)]] : []));
|
|
24
|
+
return { harnesses, ...(Object.keys(served).length ? { served } : {}) };
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
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 }`).
|
|
30
|
+
*/
|
|
31
|
+
export async function plansFor(ctx) {
|
|
32
|
+
if (!personOf(ctx.actor) || !Object.keys(harnessesOf(ctx)).length)
|
|
33
|
+
return { harnesses: [] };
|
|
34
|
+
return plansOf(ctx, await connectedOf(ctx));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The app's plans, as Your AI lists them: those that run a model some tier
|
|
38
|
+
* of the org names (each chain, as it would be tried on every plan, by the
|
|
39
|
+
* lists of those they've connected that said one), and those the person has
|
|
40
|
+
* connected, even running none; in the plans' order, each with whether
|
|
41
|
+
* they've connected it now, and the first model it runs.
|
|
42
|
+
*/
|
|
43
|
+
export async function harnessesShown(ctx) {
|
|
44
|
+
const plans = harnessesOf(ctx);
|
|
45
|
+
if (!personOf(ctx.actor) || !Object.keys(plans).length)
|
|
46
|
+
return [];
|
|
47
|
+
const all = plansInOrder(plans);
|
|
48
|
+
const [{ tiers }, connected] = await Promise.all([orgTiersOf(ctx), connectedOf(ctx)]);
|
|
49
|
+
const chains = Object.values(tiers).flatMap((tier) => Object.values(tier.agents));
|
|
50
|
+
// Every plan, those that said which models they run by their lists.
|
|
51
|
+
const { served } = plansOf(ctx, connected);
|
|
52
|
+
const tried = await Promise.all(chains.map((chain) => ctx.call("models.check", {
|
|
53
|
+
model: { model: chain, harnesses: all, ...(served ? { served } : {}) },
|
|
54
|
+
port: "llm",
|
|
55
|
+
}).catch(() => [])));
|
|
56
|
+
// Each plan a chain runs, with the first model it runs there.
|
|
57
|
+
const first = new Map();
|
|
58
|
+
for (const id of tried.flat()) {
|
|
59
|
+
const provider = id.slice(0, id.indexOf("/"));
|
|
60
|
+
if (!first.has(provider))
|
|
61
|
+
first.set(provider, id);
|
|
62
|
+
}
|
|
63
|
+
return all.filter((name) => first.has(name) || connected.has(name)).map((name) => {
|
|
64
|
+
const listed = connected.get(name)?.[0];
|
|
65
|
+
const model = first.get(name) ?? (listed ? `${name}/${listed}` : undefined);
|
|
66
|
+
return {
|
|
67
|
+
name,
|
|
68
|
+
title: plans[name].title ?? name,
|
|
69
|
+
plan: plans[name].harness.plan,
|
|
70
|
+
connected: connected.has(name),
|
|
71
|
+
...(model ? { model } : {}),
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a page shows of tiers, read as the person looking: the org's tiers
|
|
3
|
+
* (the app's as the org keeps them, and those it made), each kind of work's
|
|
4
|
+
* model chain in them by name, and what a typical message comes to at this
|
|
5
|
+
* org's prices; the kinds of work and the app's agents of each; what the org,
|
|
6
|
+
* a space, a conversation and the person chose, and what applies; and what
|
|
7
|
+
* the org's plan gives in credits, so a page can say how far they go.
|
|
8
|
+
*
|
|
9
|
+
* A typical message is what the app measured one takes (its `typicalMessage`
|
|
10
|
+
* resource): each agent's calls per message, and each call's tokens, priced
|
|
11
|
+
* at the agent's model in each tier. A tier's price is the sum. Without one,
|
|
12
|
+
* a plain reply for comparing tiers: 20,000 tokens in, 16,000 of them read
|
|
13
|
+
* from the cache (a conversation's history mostly is), and 1,000 out, each
|
|
14
|
+
* agent's alike, and a tier's price is its agents' average.
|
|
15
|
+
*
|
|
16
|
+
* With the person's plans (`plansFor`: those they can run now, in the plans'
|
|
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
|
+
* first model it would try for them (`models.check`, plans first), one of
|
|
20
|
+
* their plans costing them nothing (`plan`), and a tier's price for them
|
|
21
|
+
* (`yours`) beside the app's (`price`, which pages choosing for others show).
|
|
22
|
+
*/
|
|
23
|
+
import type { ReadContext } from "pairz";
|
|
24
|
+
import { type By, type Kind, type Levels, type OrgTier, type Template } from "./tiers.js";
|
|
25
|
+
/** A typical reply's tokens, where the app measured no message (see above). */
|
|
26
|
+
export declare const REPLY: {
|
|
27
|
+
input: number;
|
|
28
|
+
cached: number;
|
|
29
|
+
output: number;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* A `typicalMessage` resource: what one message of a person's takes of each of
|
|
33
|
+
* the app's agents, on average, measured from what they really did: how many
|
|
34
|
+
* calls (`calls`: 4.05 for the agent who answers, 0.6 for one asked now and
|
|
35
|
+
* then), and each call's tokens: `input` (with what's read from the cache),
|
|
36
|
+
* `cached`, `cacheWrite` and `output`. An agent it doesn't name isn't counted.
|
|
37
|
+
*/
|
|
38
|
+
export type TypicalMessage = Record<string, {
|
|
39
|
+
calls: number;
|
|
40
|
+
input: number;
|
|
41
|
+
cached?: number;
|
|
42
|
+
cacheWrite?: number;
|
|
43
|
+
output: number;
|
|
44
|
+
}>;
|
|
45
|
+
/**
|
|
46
|
+
* A `planCredits` resource: the Action saying what credits the org's plan
|
|
47
|
+
* gives (credits' `billing.credits`), `{}` in, `PlanCredits` or null out.
|
|
48
|
+
*/
|
|
49
|
+
export type PlanCredits = {
|
|
50
|
+
action: string;
|
|
51
|
+
};
|
|
52
|
+
/** What the org's plan gives in credits: once (a trial's), or each month, for the org or a seat. */
|
|
53
|
+
export type CreditsShown = {
|
|
54
|
+
/** The plan's name and title: `free`, "Free". */
|
|
55
|
+
plan: string;
|
|
56
|
+
title: string;
|
|
57
|
+
/** USD. */
|
|
58
|
+
amount: number;
|
|
59
|
+
every: "once" | "month";
|
|
60
|
+
perSeat?: true;
|
|
61
|
+
};
|
|
62
|
+
/** A model as a page shows it: its name, effort, a typical message's part, and what's tried after it. */
|
|
63
|
+
export type ModelShown = {
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
effort?: string;
|
|
67
|
+
/** USD, at this org's prices; null when nothing prices it. */
|
|
68
|
+
price: number | null;
|
|
69
|
+
/** It runs on the org's own key: its provider charges for it, not the app. */
|
|
70
|
+
ownKey?: true;
|
|
71
|
+
/** What's tried after it when it fails, in order. */
|
|
72
|
+
fallbacks?: {
|
|
73
|
+
id: string;
|
|
74
|
+
name: string;
|
|
75
|
+
effort?: string;
|
|
76
|
+
}[];
|
|
77
|
+
/**
|
|
78
|
+
* The plan of the person looking that answers it first, as their turns
|
|
79
|
+
* try it (`"h-chatgpt/gpt-6.2-sol"`): it costs them nothing. `price` stays
|
|
80
|
+
* what it costs on the app's models.
|
|
81
|
+
*/
|
|
82
|
+
plan?: string;
|
|
83
|
+
};
|
|
84
|
+
export type TierShown = {
|
|
85
|
+
name: string;
|
|
86
|
+
title: string;
|
|
87
|
+
description?: string;
|
|
88
|
+
/** A typical message (its kinds' sum), or reply (their average), in USD; null when none is priced. */
|
|
89
|
+
price: number | null;
|
|
90
|
+
/**
|
|
91
|
+
* The same for the person looking, with their plans (0 when plans answer
|
|
92
|
+
* every kind): only when a plan of theirs answers some kind here.
|
|
93
|
+
*/
|
|
94
|
+
yours?: number | null;
|
|
95
|
+
/** The app's (as it is, or `changed` by the org), or one the org `made`. */
|
|
96
|
+
app?: true;
|
|
97
|
+
changed?: true;
|
|
98
|
+
made?: true;
|
|
99
|
+
/** Each kind of work's chain here, in the kinds' order. */
|
|
100
|
+
kinds: {
|
|
101
|
+
kind: string;
|
|
102
|
+
model: ModelShown;
|
|
103
|
+
}[];
|
|
104
|
+
};
|
|
105
|
+
/** A kind of work: its title, and the app's agents that do it. */
|
|
106
|
+
export type KindShown = {
|
|
107
|
+
kind: string;
|
|
108
|
+
title: string;
|
|
109
|
+
description?: string;
|
|
110
|
+
/** For one the org added: the app's kind it starts from. */
|
|
111
|
+
base?: string;
|
|
112
|
+
agents: {
|
|
113
|
+
agent: string;
|
|
114
|
+
name: string;
|
|
115
|
+
icon?: string;
|
|
116
|
+
}[];
|
|
117
|
+
};
|
|
118
|
+
export type Shown = {
|
|
119
|
+
tiers: TierShown[];
|
|
120
|
+
kinds: KindShown[];
|
|
121
|
+
/** The app's tiers the org took away, to put back. */
|
|
122
|
+
removed: {
|
|
123
|
+
name: string;
|
|
124
|
+
title: string;
|
|
125
|
+
}[];
|
|
126
|
+
/** The tier the org's plan gives, when the app has plans that say. */
|
|
127
|
+
plan: string | null;
|
|
128
|
+
/** The org's default, and what its members may use: up to `cap`, or only the default (`fixed`). */
|
|
129
|
+
org: {
|
|
130
|
+
tier: string | null;
|
|
131
|
+
cap: string | null;
|
|
132
|
+
fixed: boolean;
|
|
133
|
+
};
|
|
134
|
+
space?: {
|
|
135
|
+
tier: string | null;
|
|
136
|
+
};
|
|
137
|
+
thread?: {
|
|
138
|
+
tier: string | null;
|
|
139
|
+
};
|
|
140
|
+
/** The person's own default for new chats. */
|
|
141
|
+
person: {
|
|
142
|
+
tier: string | null;
|
|
143
|
+
};
|
|
144
|
+
/** What applies where it was asked: the tier in force and who chose it. */
|
|
145
|
+
now: {
|
|
146
|
+
tier: string;
|
|
147
|
+
by: By;
|
|
148
|
+
} | null;
|
|
149
|
+
/** What prices are for: a typical message the app measured, else a plain reply. */
|
|
150
|
+
per: "message" | "reply";
|
|
151
|
+
reply: typeof REPLY;
|
|
152
|
+
/** What the org's plan gives in credits, when the app has plans that say. */
|
|
153
|
+
credits: CreditsShown | null;
|
|
154
|
+
};
|
|
155
|
+
/** One agent where it works: its kind, the tier in force there, and its chain in it. */
|
|
156
|
+
export type AgentNow = {
|
|
157
|
+
kind: string;
|
|
158
|
+
kindTitle: string;
|
|
159
|
+
tier: string;
|
|
160
|
+
tierTitle: string;
|
|
161
|
+
by: By;
|
|
162
|
+
model: ModelShown;
|
|
163
|
+
};
|
|
164
|
+
/** The org's tiers and kinds, as it keeps them. */
|
|
165
|
+
export declare function orgTiersOf(ctx: ReadContext): Promise<{
|
|
166
|
+
tiers: Record<string, OrgTier>;
|
|
167
|
+
kinds: Record<string, Kind>;
|
|
168
|
+
templates: import("pairz").WithId<Template>[];
|
|
169
|
+
}>;
|
|
170
|
+
/** What each level chose, where asked: the conversation, the person, the space, the org, the plan. */
|
|
171
|
+
export declare function levelsOf(ctx: ReadContext, where: {
|
|
172
|
+
space?: string;
|
|
173
|
+
thread?: string;
|
|
174
|
+
person?: string;
|
|
175
|
+
}): Promise<Levels>;
|
|
176
|
+
/** Everything a page shows, at the org's level, or where asked (a space, a conversation). */
|
|
177
|
+
export declare function shownAt(ctx: ReadContext, where?: {
|
|
178
|
+
space?: string;
|
|
179
|
+
thread?: string;
|
|
180
|
+
}): Promise<Shown>;
|
|
181
|
+
/**
|
|
182
|
+
* One agent where it works (a space, maybe a conversation): its kind of work,
|
|
183
|
+
* the tier in force there and who chose it, and its chain in that tier; null
|
|
184
|
+
* when no tier applies.
|
|
185
|
+
*/
|
|
186
|
+
export declare function agentAt(ctx: ReadContext, agent: string, where: {
|
|
187
|
+
space?: string;
|
|
188
|
+
thread?: string;
|
|
189
|
+
}): Promise<AgentNow | null>;
|