@pairz/team 1.0.0-rc.82 → 1.0.0-rc.84
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 +7 -3
- package/WORDS.md +8 -0
- 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/words.d.ts +1 -1
- package/tiers/actions/choose.d.ts +47 -0
- package/tiers/actions/choose.js +74 -9
- package/tiers/actions/model.js +9 -5
- package/tiers/collections/choice.d.ts +10 -0
- package/tiers/collections/choice.js +10 -2
- package/tiers/collections/template.d.ts +5 -0
- package/tiers/collections/template.js +5 -2
- package/tiers/contract.d.ts +2 -2
- package/tiers/mod.d.ts +12 -7
- package/tiers/mod.js +20 -9
- package/tiers/shared/plans.d.ts +7 -5
- package/tiers/shared/plans.js +8 -6
- package/tiers/shared/shown.d.ts +14 -3
- package/tiers/shared/shown.js +36 -12
- package/tiers/shared/tiers.d.ts +27 -1
- package/tiers/shared/tiers.js +18 -1
- package/tiers/views/web/org.d.ts +29 -2
- package/tiers/views/web/org.js +85 -47
- package/tiers/views/web/say.d.ts +9 -1
- package/tiers/views/web/say.js +8 -0
- package/tiers/views/web/style.d.ts +1 -1
- package/tiers/views/web/style.js +3 -0
package/README.md
CHANGED
|
@@ -35,14 +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
44
|
`modelChoice`; chat asks it through the `agentModel` resource. An org puts its tiers in its own
|
|
43
45
|
order (`tiers.order`), and says what members can use: all tiers, up to one, or only the default
|
|
44
|
-
(`tiers.cap`). Where the app has people's plans (Claude Code, ChatGPT…), each turn's chain runs
|
|
45
|
-
|
|
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.
|
|
46
50
|
|
|
47
51
|
Its front end's words are `team.<key>`: see
|
|
48
52
|
[WORDS.md](https://github.com/pairzhq/pairz/blob/main/packages/team/WORDS.md).
|
package/WORDS.md
CHANGED
|
@@ -244,6 +244,7 @@ Generated: `deno run -A packages/team/tests/words.ts`.
|
|
|
244
244
|
| `tiers.addBackTier` | Add back {tier} |
|
|
245
245
|
| `tiers.addFallback` | Add a fallback |
|
|
246
246
|
| `tiers.addKind` | Add a kind of work |
|
|
247
|
+
| `tiers.addPlanFallback` | Add a model |
|
|
247
248
|
| `tiers.agentLine` | {model} · {kind} · on {tier} |
|
|
248
249
|
| `tiers.asOrg` | As the org: {tier} |
|
|
249
250
|
| `tiers.backToDefault` | Back to the default |
|
|
@@ -323,6 +324,7 @@ Generated: `deno run -A packages/team/tests/words.ts`.
|
|
|
323
324
|
| `tiers.noCredits` | {plan} gives this org no credits. |
|
|
324
325
|
| `tiers.noCreditsMore` | Choose a plan or add credits for your agents to start working. |
|
|
325
326
|
| `tiers.noFallback` | Nothing: if it fails, the reply fails. |
|
|
327
|
+
| `tiers.noPlanFallback` | None: the agent's own models on credits. |
|
|
326
328
|
| `tiers.notOnTeam` | Not on your team |
|
|
327
329
|
| `tiers.nowMore` | Anyone can switch a chat's tier as they write, and spaces can set their own. |
|
|
328
330
|
| `tiers.nowOrg` | New chats use {tier}, your org's default. |
|
|
@@ -337,6 +339,12 @@ Generated: `deno run -A packages/team/tests/words.ts`.
|
|
|
337
339
|
| `tiers.perReply` | a reply |
|
|
338
340
|
| `tiers.pickCap` | Members can use up to {cap}. |
|
|
339
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. |
|
|
340
348
|
| `tiers.pricedEach` | Priced as each model is |
|
|
341
349
|
| `tiers.providerChatgpt` | your ChatGPT plan |
|
|
342
350
|
| `tiers.recommended` | Recommended |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pairz/team",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.84",
|
|
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.
|
|
56
|
+
"pairz": "1.0.0-rc.84",
|
|
57
57
|
"react": "^19.3.1",
|
|
58
58
|
"react-dom": "^19.3.1"
|
|
59
59
|
},
|
package/team/actions/agent.js
CHANGED
|
@@ -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
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
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
|
|
12
|
-
*
|
|
13
|
-
*
|
|
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
|
-
/**
|
|
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
|
|
49
|
-
|
|
50
|
-
readonly
|
|
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[] |
|
|
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
|
-
/**
|
|
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
|
|
120
|
-
|
|
121
|
-
readonly
|
|
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
|
|
12
|
-
*
|
|
13
|
-
*
|
|
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
|
-
/**
|
|
40
|
-
|
|
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
|
|
82
|
+
const declared = agentsOf(ctx);
|
|
83
|
+
const known = { ...declared };
|
|
63
84
|
for (const doc of await agents.find({}, { sort: { name: 1 } })) {
|
|
64
|
-
|
|
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 } : {}),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Every word Team's web front end shows, to be changed by the app (`team.<key>`). */
|
|
2
2
|
import { type Phrase } from "pairz/web/words";
|
|
3
|
-
export declare const say: import("pairz/web/words").Say<"instructions" | "model" | "effort" | "tools" | "replace" | "cancel" | "change" | "listJoin" | "listEnd" | "personalSpace" | "noSuchAgentTitle" | "noSuchAgent" | "noSuchAgentBody" | "goHome" | "partOfApp" | "madeIn" | "madeElsewhere" | "answersNewChatsHere" | "askAgent" | "edit" | "editAgent" | "moreMenu" | "makeAnswerIn" | "addToSpaceMenu" | "startFromIt" | "deleteMenu" | "addToTitle" | "addToNote" | "newLikeTitle" | "newLikeNote" | "newAgentIn" | "startingFrom" | "appAgentNotice" | "startFromShort" | "managersChangeIt" | "managersChangeItElsewhere" | "worksIn" | "addToSpace" | "answersNewChats" | "roleViewer" | "roleEditor" | "worksNowhere" | "modelAndTools" | "thinks" | "toolsLabel" | "noTools" | "showFewer" | "showAll" | "modelsThenJoin" | "changeAgent" | "keepsHandle" | "saveChanges" | "deleteTitle" | "deleteButton" | "deleteLeavesBold" | "deleteLeavesNamed" | "deleteLeaves" | "deleteGoneBold" | "deleteGone" | "deleteChatsBold" | "deleteChats" | "findSpace" | "spacesYouManage" | "justYou" | "keywordPersonal" | "deleteStepNote" | "deleteStepKeep" | "fieldName" | "calledIn" | "nameHint" | "namePlaceholder" | "emoji" | "noEmoji" | "anotherEmoji" | "otherEmoji" | "fieldDoes" | "doesHint" | "doesPlaceholder" | "modelHint" | "rewriteForMe" | "writeForMe" | "sayNameFirst" | "youArePlaceholder" | "youAreDefaultName" | "writingFor" | "draftNote" | "undo" | "instructionsHint" | "instructionsEmptyHint" | "toolsOf" | "toolsChooseDone" | "toolsChoose" | "toolsAll" | "toolsNone" | "toolsMore" | "newAgentForm" | "agentsYouKnow" | "startFrom" | "startBlank" | "worksInAs" | "belongsHint" | "createNamed" | "createAgent" | "worksNow" | "askHandle" | "readsOnly" | "makeAnswer" | "openPage" | "makeAnother" | "notYourSpace" | "archivedSpace" | "managersAdd" | "addAnAgentTitle" | "addAnAgentNote" | "oneOfApps" | "madeInOther" | "findAgent" | "findAgentKnown" | "knownIntro" | "addsAs" | "createNewAgent" | "createNewAgentBody" | "addAgentTo" | "
|
|
3
|
+
export declare const say: import("pairz/web/words").Say<"add" | "remove" | "instructions" | "model" | "effort" | "tools" | "replace" | "cancel" | "change" | "listJoin" | "listEnd" | "personalSpace" | "noSuchAgentTitle" | "noSuchAgent" | "noSuchAgentBody" | "goHome" | "partOfApp" | "madeIn" | "madeElsewhere" | "answersNewChatsHere" | "askAgent" | "edit" | "editAgent" | "moreMenu" | "makeAnswerIn" | "addToSpaceMenu" | "startFromIt" | "deleteMenu" | "addToTitle" | "addToNote" | "newLikeTitle" | "newLikeNote" | "newAgentIn" | "startingFrom" | "appAgentNotice" | "startFromShort" | "managersChangeIt" | "managersChangeItElsewhere" | "worksIn" | "addToSpace" | "answersNewChats" | "roleViewer" | "roleEditor" | "worksNowhere" | "modelAndTools" | "thinks" | "toolsLabel" | "noTools" | "showFewer" | "showAll" | "modelsThenJoin" | "changeAgent" | "keepsHandle" | "saveChanges" | "deleteTitle" | "deleteButton" | "deleteLeavesBold" | "deleteLeavesNamed" | "deleteLeaves" | "deleteGoneBold" | "deleteGone" | "deleteChatsBold" | "deleteChats" | "findSpace" | "spacesYouManage" | "justYou" | "keywordPersonal" | "deleteStepNote" | "deleteStepKeep" | "fieldName" | "calledIn" | "nameHint" | "namePlaceholder" | "emoji" | "noEmoji" | "anotherEmoji" | "otherEmoji" | "fieldDoes" | "doesHint" | "doesPlaceholder" | "modelHint" | "rewriteForMe" | "writeForMe" | "sayNameFirst" | "youArePlaceholder" | "youAreDefaultName" | "writingFor" | "draftNote" | "undo" | "instructionsHint" | "instructionsEmptyHint" | "toolsOf" | "toolsChooseDone" | "toolsChoose" | "toolsAll" | "toolsNone" | "toolsMore" | "newAgentForm" | "agentsYouKnow" | "startFrom" | "startBlank" | "worksInAs" | "belongsHint" | "createNamed" | "createAgent" | "worksNow" | "askHandle" | "readsOnly" | "makeAnswer" | "openPage" | "makeAnother" | "notYourSpace" | "archivedSpace" | "managersAdd" | "addAnAgentTitle" | "addAnAgentNote" | "oneOfApps" | "madeInOther" | "findAgent" | "findAgentKnown" | "knownIntro" | "addsAs" | "createNewAgent" | "createNewAgentBody" | "addAgentTo" | "noneCalled" | "allWorkHere" | "worksNowNames" | "paletteThisAgent" | "paletteThisSpace" | "paletteAgents" | "paletteCreate" | "makeNamedAnswerIn" | "makeNamedAnswer" | "keywordDefault" | "keywordAnswer" | "keywordNewChats" | "addNamedTo" | "addNamedNote" | "keywordMember" | "keywordJoin" | "keywordWork" | "editNamed" | "keywordChange" | "keywordInstructions" | "keywordRename" | "startNewFrom" | "keywordCopy" | "keywordLike" | "keywordCreate" | "addAnAgentTo" | "keywordInvite" | "keywordAgent" | "worksHere" | "newAgent" | "newAgentInHere" | "keywordMake" | "newAgentInStep" | "newAgentInNote" | "chooseModel" | "needsKey" | "yourKey" | "providerModels" | "searchModels" | "readyToUse" | "withOwnKey" | "providers" | "models" | "nothingMatches" | "allProviders" | "noKeyForProvider" | "apiKeyLabel" | "pasteIt" | "save" | "keyNote" | "orgKey" | "usesAppKey" | "useOwnKey" | "noCreditsUsed" | "priceLine" | "priceOwnKey" | "paidYours" | "paidCredits" | "credits" | "paidFallBack" | "paidConnect" | "yourPlan" | "contextSize" | "mediaImage" | "mediaPdf" | "mediaAudio" | "mediaVideo" | "reasoning" | "describeHint" | "describePlaceholder" | "fillMyself" | "draftIt" | "drafting" | "draftingWait" | "kindLabel" | "kindHint" | "kindLike" | "orgForm" | "orgJoins" | "back" | "addToTeamNamed" | "addToTeam" | "removeFromTeamMenu" | "changedForOrg" | "orgsTeam" | "tierModel" | "tierModelPlace" | "removeTeamTitle" | "removeButton" | "teamLeaves" | "teamLeavesBold" | "teamSaidStays" | "teamAddBack" | "teamDeleted">;
|
|
4
4
|
/** Every word of team's front end, by area (WORDS.md lists them). */
|
|
5
5
|
export declare const PHRASES: Record<string, Record<string, Phrase>>;
|
|
@@ -1,5 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Choosing tiers, and the org's own: all in person.
|
|
3
|
+
*
|
|
4
|
+
* - `tiers.choose` `{ tier, space?, thread?, mine? }`: the tier for the org
|
|
5
|
+
* (its owners and admins), a space (its managers), a conversation (anyone
|
|
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
|
+
* 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.plansFirst` `{ on }`: whether members' subscriptions are used
|
|
13
|
+
* whenever possible, by the org's owners and admins. Off (the default), a
|
|
14
|
+
* turn runs the tier's models in order, each on the member's plans that
|
|
15
|
+
* run it, then on credits. On, every model on their plans before any on
|
|
16
|
+
* credits, then the tier's `fallbacks` on their plans only.
|
|
17
|
+
* - `tiers.order` `{ tiers }`: the org's tiers in the order it wants them,
|
|
18
|
+
* lowest first, each once: where a cap stops.
|
|
19
|
+
* - `tiers.save` `{ tier, title?, description?, kinds?, fallbacks?, from? }`:
|
|
20
|
+
* an org's tier, by its owners and admins: its version of one of the
|
|
21
|
+
* app's, or a new one (`title`, its chains copied from `from`, else the
|
|
22
|
+
* tier in force). `kinds`: chains by kind of work (a list of models, tried
|
|
23
|
+
* in order; null: back to the app's there), each checked as an agent's
|
|
24
|
+
* model is, and each given the `maxTokens` and `effort` of the chain it
|
|
25
|
+
* replaces, where it takes it. `fallbacks`: the models tried on members'
|
|
26
|
+
* plans after any chain (null: back to the app's), each one a plan of the
|
|
27
|
+
* app's runs; one it had keeps its settings.
|
|
28
|
+
* - `tiers.remove` `{ tier }`: takes one of the app's away, or deletes one
|
|
29
|
+
* the org made; not the last. Wherever it was chosen, what's above applies.
|
|
30
|
+
* - `tiers.restore` `{ tier }`: one of the app's back as the app has it.
|
|
31
|
+
* - `tiers.kind` `{ kind?, title, base }`: a kind of work of the org's own,
|
|
32
|
+
* starting from one of the app's (its chain in every tier, until changed).
|
|
33
|
+
*
|
|
34
|
+
* A change applies from each conversation's next reply.
|
|
35
|
+
*/
|
|
36
|
+
import { type Resources } from "pairz";
|
|
37
|
+
import { type ModelRef } from "pairz/plugins/models/contract";
|
|
1
38
|
export declare const chooseAction: import("pairz").ActionDef;
|
|
2
39
|
export declare const capAction: import("pairz").ActionDef;
|
|
40
|
+
export declare const plansFirstAction: import("pairz").ActionDef;
|
|
41
|
+
/**
|
|
42
|
+
* Throws unless a plan of the app's runs `fallback` (a tier's fallbacks run
|
|
43
|
+
* on members' plans only), at the settings it's given. An app without plans
|
|
44
|
+
* never runs one: nothing to check.
|
|
45
|
+
*/
|
|
46
|
+
export declare function checkFallback(ctx: {
|
|
47
|
+
resources: Resources;
|
|
48
|
+
call<R>(action: string, input?: unknown): Promise<R>;
|
|
49
|
+
}, fallback: ModelRef): Promise<void>;
|
|
3
50
|
export declare const orderAction: import("pairz").ActionDef;
|
|
4
51
|
export declare const saveAction: import("pairz").ActionDef;
|
|
5
52
|
export declare const removeAction: import("pairz").ActionDef;
|
package/tiers/actions/choose.js
CHANGED
|
@@ -9,15 +9,22 @@
|
|
|
9
9
|
* - `tiers.cap` `{ tier?, fixed? }`: what the org's members may use, by its
|
|
10
10
|
* owners and admins: every tier (`tier: null`), tiers up to one (`tier`),
|
|
11
11
|
* or only the org's default (`fixed: true`).
|
|
12
|
+
* - `tiers.plansFirst` `{ on }`: whether members' subscriptions are used
|
|
13
|
+
* whenever possible, by the org's owners and admins. Off (the default), a
|
|
14
|
+
* turn runs the tier's models in order, each on the member's plans that
|
|
15
|
+
* run it, then on credits. On, every model on their plans before any on
|
|
16
|
+
* credits, then the tier's `fallbacks` on their plans only.
|
|
12
17
|
* - `tiers.order` `{ tiers }`: the org's tiers in the order it wants them,
|
|
13
18
|
* lowest first, each once: where a cap stops.
|
|
14
|
-
* - `tiers.save` `{ tier, title?, description?, kinds?, from? }`:
|
|
15
|
-
* tier, by its owners and admins: its version of one of the
|
|
16
|
-
* new one (`title`, its chains copied from `from`, else the
|
|
17
|
-
* `kinds`: chains by kind of work (a list of models, tried
|
|
18
|
-
* back to the app's there), each checked as an agent's
|
|
19
|
-
* given the `maxTokens` and `effort` of the chain it
|
|
20
|
-
* takes it.
|
|
19
|
+
* - `tiers.save` `{ tier, title?, description?, kinds?, fallbacks?, from? }`:
|
|
20
|
+
* an org's tier, by its owners and admins: its version of one of the
|
|
21
|
+
* app's, or a new one (`title`, its chains copied from `from`, else the
|
|
22
|
+
* tier in force). `kinds`: chains by kind of work (a list of models, tried
|
|
23
|
+
* in order; null: back to the app's there), each checked as an agent's
|
|
24
|
+
* model is, and each given the `maxTokens` and `effort` of the chain it
|
|
25
|
+
* replaces, where it takes it. `fallbacks`: the models tried on members'
|
|
26
|
+
* plans after any chain (null: back to the app's), each one a plan of the
|
|
27
|
+
* app's runs; one it had keeps its settings.
|
|
21
28
|
* - `tiers.remove` `{ tier }`: takes one of the app's away, or deletes one
|
|
22
29
|
* the org made; not the last. Wherever it was chosen, what's above applies.
|
|
23
30
|
* - `tiers.restore` `{ tier }`: one of the app's back as the app has it.
|
|
@@ -28,8 +35,10 @@
|
|
|
28
35
|
*/
|
|
29
36
|
import { defineAction, failure, inPerson, invalid } from "pairz";
|
|
30
37
|
import { must, ORG } from "pairz/plugins/access/contract";
|
|
38
|
+
import { plansInOrder } from "pairz/plugins/models/contract";
|
|
39
|
+
import { harnessesOf } from "../shared/plans.js";
|
|
31
40
|
import { orgTiersOf } from "../shared/shown.js";
|
|
32
|
-
import { aboveCap, appKindsOf, appTiersOf, entryOf, ORG_CHOICE, personChoice, settled, spaceChoice, threadChoice, } from "../shared/tiers.js";
|
|
41
|
+
import { aboveCap, appKindsOf, appTiersOf, entryOf, ORG_CHOICE, personChoice, primaryOf, settled, spaceChoice, threadChoice, } from "../shared/tiers.js";
|
|
33
42
|
/** Throws unless the caller runs the org. */
|
|
34
43
|
const runsOrg = (ctx, what) => must(ctx, "manage", ORG, `Only the org's owners and admins ${what}.`);
|
|
35
44
|
/** Whether the caller runs the org, without throwing. */
|
|
@@ -38,7 +47,7 @@ const choices = (ctx) => ctx.as().db.collection("modelChoice");
|
|
|
38
47
|
const templates = (ctx) => ctx.as().db.collection("tierTemplate");
|
|
39
48
|
/** Keeps a level's choice, or deletes it once it holds nothing (no tier, nor what members use). */
|
|
40
49
|
async function keep(ctx, had, next) {
|
|
41
|
-
if (!next.tier && !next.cap && !next.fixed) {
|
|
50
|
+
if (!next.tier && !next.cap && !next.fixed && !next.plansFirst) {
|
|
42
51
|
if (had)
|
|
43
52
|
await choices(ctx).deleteOne({ _id: next._id });
|
|
44
53
|
return;
|
|
@@ -149,6 +158,49 @@ export const capAction = defineAction({
|
|
|
149
158
|
return { cap, fixed: !!input.fixed };
|
|
150
159
|
},
|
|
151
160
|
});
|
|
161
|
+
export const plansFirstAction = defineAction({
|
|
162
|
+
description: "Sets whether members' subscriptions are used whenever possible",
|
|
163
|
+
input: {
|
|
164
|
+
type: "object",
|
|
165
|
+
properties: {
|
|
166
|
+
/** Every model on a member's plans before any on credits, then the tier's fallbacks. */
|
|
167
|
+
on: { type: "boolean" },
|
|
168
|
+
},
|
|
169
|
+
required: ["on"],
|
|
170
|
+
additionalProperties: false,
|
|
171
|
+
},
|
|
172
|
+
allow: inPerson,
|
|
173
|
+
run: async (ctx, input) => {
|
|
174
|
+
await runsOrg(ctx, "choose how members' subscriptions are used");
|
|
175
|
+
const before = await choiceOf(ctx, ORG_CHOICE);
|
|
176
|
+
const next = { ...before, _id: ORG_CHOICE, at: new Date().toISOString() };
|
|
177
|
+
if (input.on)
|
|
178
|
+
next.plansFirst = true;
|
|
179
|
+
else
|
|
180
|
+
delete next.plansFirst;
|
|
181
|
+
await keep(ctx, before, next);
|
|
182
|
+
return { on: input.on };
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
/**
|
|
186
|
+
* Throws unless a plan of the app's runs `fallback` (a tier's fallbacks run
|
|
187
|
+
* on members' plans only), at the settings it's given. An app without plans
|
|
188
|
+
* never runs one: nothing to check.
|
|
189
|
+
*/
|
|
190
|
+
export async function checkFallback(ctx, fallback) {
|
|
191
|
+
const harnesses = plansInOrder(harnessesOf(ctx));
|
|
192
|
+
if (!harnesses.length)
|
|
193
|
+
return;
|
|
194
|
+
await ctx.call("models.check", {
|
|
195
|
+
model: { model: [], harnesses, planFallbacks: [fallback] },
|
|
196
|
+
port: "llm",
|
|
197
|
+
}).catch((error) => {
|
|
198
|
+
const named = primaryOf(ctx, fallback)?.id ?? JSON.stringify(fallback);
|
|
199
|
+
throw invalid(/No model chosen/.test(error.message)
|
|
200
|
+
? `No plan of the app's runs ${named}: a tier's fallbacks run on members' plans only.`
|
|
201
|
+
: error.message);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
152
204
|
export const orderAction = defineAction({
|
|
153
205
|
description: "Puts the org's tiers in order, lowest first",
|
|
154
206
|
transaction: true,
|
|
@@ -192,6 +244,8 @@ export const saveAction = defineAction({
|
|
|
192
244
|
description: { type: "string", maxLength: 200 },
|
|
193
245
|
/** Chains by kind of work: models in order; null, back to the app's. */
|
|
194
246
|
kinds: { type: "object", additionalProperties: { type: ["array", "null"], maxItems: 8 } },
|
|
247
|
+
/** Models tried on members' plans after any chain, in order; null, back to the app's. */
|
|
248
|
+
fallbacks: { type: ["array", "null"], maxItems: 8 },
|
|
195
249
|
/** A new tier's chains, copied from this one. */
|
|
196
250
|
from: { type: "string" },
|
|
197
251
|
},
|
|
@@ -232,6 +286,16 @@ export const saveAction = defineAction({
|
|
|
232
286
|
await ctx.call("models.check", { model, port: "llm" });
|
|
233
287
|
chains[kind] = await settled(ctx, list, entryOf(base, kind, kinds) ?? undefined);
|
|
234
288
|
}
|
|
289
|
+
let fallbacks = making ? base?.fallbacks : had?.fallbacks;
|
|
290
|
+
if (input.fallbacks !== undefined) {
|
|
291
|
+
// One it had keeps its settings (its effort); a new one is as given.
|
|
292
|
+
const kept = new Map((tiers[name]?.fallbacks ?? []).map((f) => [primaryOf(ctx, f)?.id, f]));
|
|
293
|
+
fallbacks = input.fallbacks === null
|
|
294
|
+
? undefined
|
|
295
|
+
: input.fallbacks.map((f) => typeof f === "string" ? kept.get(f) ?? f : f);
|
|
296
|
+
for (const fallback of fallbacks ?? [])
|
|
297
|
+
await checkFallback(ctx, fallback);
|
|
298
|
+
}
|
|
235
299
|
const order = making
|
|
236
300
|
? Math.max(0, ...Object.values(tiers).map((t) => t.order ?? 0)) + 1
|
|
237
301
|
: had?.order;
|
|
@@ -243,6 +307,7 @@ export const saveAction = defineAction({
|
|
|
243
307
|
: {}),
|
|
244
308
|
...(order !== undefined ? { order } : {}),
|
|
245
309
|
...(Object.keys(chains).length ? { agents: chains } : {}),
|
|
310
|
+
...(fallbacks ? { fallbacks } : {}),
|
|
246
311
|
...(making || had?.made ? { made: true } : {}),
|
|
247
312
|
at: new Date().toISOString(),
|
|
248
313
|
}, { upsert: true });
|
package/tiers/actions/model.js
CHANGED
|
@@ -13,14 +13,17 @@
|
|
|
13
13
|
* the plans its person has connected now, in the plans' order, and the
|
|
14
14
|
* models those that said so run: `{ model: chain, harnesses, served? }`
|
|
15
15
|
* (none for a turn that's nobody's), and the models plugin runs each model
|
|
16
|
-
* on them
|
|
17
|
-
*
|
|
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
23
|
import { connectedOf } from "pairz/plugins/models/contract";
|
|
21
24
|
import { harnessesOf, plansOf } from "../shared/plans.js";
|
|
22
25
|
import { levelsOf, orgTiersOf } from "../shared/shown.js";
|
|
23
|
-
import { entryOf, kindOf, tierIn } from "../shared/tiers.js";
|
|
26
|
+
import { entryOf, kindOf, onPlans, tierIn } from "../shared/tiers.js";
|
|
24
27
|
export const modelAction = defineAction({
|
|
25
28
|
description: "The model chain an agent thinks with in a conversation",
|
|
26
29
|
record: false,
|
|
@@ -50,12 +53,13 @@ export const modelAction = defineAction({
|
|
|
50
53
|
plans && person ? connectedOf(ctx) : new Map(),
|
|
51
54
|
]);
|
|
52
55
|
const inForce = tierIn(tiers, levels);
|
|
56
|
+
const tier = inForce ? tiers[inForce.tier] : undefined;
|
|
53
57
|
const kind = kindOf(ctx, input.agent, undefined, kinds);
|
|
54
|
-
const chain = entryOf(
|
|
58
|
+
const chain = entryOf(tier, kind, kinds);
|
|
55
59
|
if (chain === undefined)
|
|
56
60
|
return null;
|
|
57
61
|
if (!plans)
|
|
58
62
|
return chain;
|
|
59
|
-
return { model: chain, ...plansOf(ctx, connected) };
|
|
63
|
+
return { model: chain, ...plansOf(ctx, connected), ...onPlans(levels.org, tier) };
|
|
60
64
|
},
|
|
61
65
|
});
|
|
@@ -6,6 +6,7 @@ export type ModelChoice = {
|
|
|
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"> & {
|
|
@@ -16,6 +17,7 @@ export declare const modelChoice: Omit<import("pairz").CollectionDef, "schema" |
|
|
|
16
17
|
thread?: string | undefined;
|
|
17
18
|
person?: string | undefined;
|
|
18
19
|
tier?: string | undefined;
|
|
20
|
+
plansFirst?: boolean | undefined;
|
|
19
21
|
cap?: string | undefined;
|
|
20
22
|
at: string;
|
|
21
23
|
}>>> | undefined;
|
|
@@ -45,6 +47,14 @@ export declare const modelChoice: Omit<import("pairz").CollectionDef, "schema" |
|
|
|
45
47
|
readonly fixed: {
|
|
46
48
|
readonly type: "boolean";
|
|
47
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";
|
|
57
|
+
};
|
|
48
58
|
readonly at: {
|
|
49
59
|
readonly type: "string";
|
|
50
60
|
};
|