@copilotz/team 1.0.0-rc.53 → 1.0.0-rc.55
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/WORDS.md +156 -0
- package/package.json +2 -2
- package/team/actions/agent.d.ts +10 -0
- package/team/actions/agent.js +226 -7
- package/team/actions/define.js +7 -3
- package/team/collections/agent.d.ts +52 -7
- package/team/collections/agent.js +56 -5
- package/team/mod.d.ts +7 -0
- package/team/mod.js +14 -1
- package/team/resources/propose.d.ts +1 -0
- package/team/resources/propose.js +97 -0
- package/team/shared/definition.d.ts +1 -1
- package/team/shared/definition.js +5 -4
- package/team/shared/everywhere.d.ts +11 -0
- package/team/shared/everywhere.js +29 -0
- package/team/views/web/agent-add.js +14 -4
- 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 +3 -1
- package/team/views/web/agent-fields.js +2 -2
- package/team/views/web/agent-known.js +2 -1
- package/team/views/web/agent-new.d.ts +4 -1
- package/team/views/web/agent-new.js +26 -5
- package/team/views/web/agent-org.d.ts +12 -0
- package/team/views/web/agent-org.js +89 -0
- package/team/views/web/agent.d.ts +7 -4
- package/team/views/web/agent.js +81 -28
- package/team/views/web/model-pick.d.ts +3 -1
- package/team/views/web/model-pick.js +4 -1
- package/team/views/web/style.d.ts +1 -1
- package/team/views/web/style.js +5 -0
- package/team/views/web/words.d.ts +1 -1
- package/team/views/web/words.js +28 -0
- package/team/web.js +2 -0
- package/tiers/actions/choose.d.ts +5 -1
- package/tiers/actions/choose.js +247 -66
- package/tiers/actions/model.js +31 -22
- package/tiers/collections/choice.d.ts +17 -10
- package/tiers/collections/choice.js +39 -27
- package/tiers/collections/template.d.ts +90 -0
- package/tiers/collections/template.js +41 -0
- package/tiers/contract.d.ts +10 -8
- package/tiers/mod.d.ts +30 -21
- package/tiers/mod.js +45 -36
- package/tiers/shared/shown.d.ts +131 -49
- package/tiers/shared/shown.js +192 -98
- package/tiers/shared/tiers.d.ts +105 -62
- package/tiers/shared/tiers.js +127 -86
- package/tiers/views/web/composer.d.ts +12 -0
- package/tiers/views/web/composer.js +79 -0
- package/tiers/views/web/org.d.ts +44 -21
- package/tiers/views/web/org.js +231 -84
- package/tiers/views/web/say.d.ts +138 -0
- package/tiers/views/web/say.js +142 -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 +8 -20
- package/tiers/views/web/space.js +30 -59
- package/tiers/views/web/style.d.ts +1 -1
- package/tiers/views/web/style.js +98 -4
- package/tiers/views/web/team.d.ts +38 -0
- package/tiers/views/web/team.js +118 -0
- package/tiers/views/web/words.d.ts +36 -16
- package/tiers/views/web/words.js +102 -35
- package/tiers/web.d.ts +18 -9
- package/tiers/web.js +36 -10
package/tiers/views/web/org.js
CHANGED
|
@@ -1,41 +1,53 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
|
-
* The org's agents
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
3
|
+
* The org's agents (kind `tiers.org`, the org page's Agents section, the web
|
|
4
|
+
* shell's `orgSettings`, at `/org?tab=models`): how hard they think, then who
|
|
5
|
+
* they are.
|
|
6
|
+
*
|
|
7
|
+
* - **The tiers**, as cards side by side: each its name, what it's good for,
|
|
8
|
+
* what a typical message comes to at this org's prices and how far the
|
|
9
|
+
* plan's credits go, and each kind of work's model; the org's default
|
|
10
|
+
* outlined. Owners and admins make one the default in a click (Undo right
|
|
11
|
+
* after), customize one (a dialog: each kind of work's model and what it
|
|
12
|
+
* falls back to, its name), duplicate one into a new tier, make one from
|
|
13
|
+
* nothing, take one away or put it back as it was, and set the highest
|
|
14
|
+
* tier members may choose. On a plan of credits given once, a heavier
|
|
15
|
+
* default says how much faster it spends them.
|
|
16
|
+
* - **The team** (team.tsx): the agents every space starts with.
|
|
17
|
+
*
|
|
18
|
+
* Anyone else reads it, and is told who changes it. Everything shown is a
|
|
19
|
+
* watched read (`modelChoice.offered`), so a change shows at once.
|
|
15
20
|
*/
|
|
16
21
|
import { useEffect, useState } from "react";
|
|
17
|
-
import {
|
|
22
|
+
import { Badge, Button, Card, Dialog, EmptyState, Field, Icon, Input, LazyView, Menu, message, Notice, Select, Skeleton, } from "copilotz/web";
|
|
18
23
|
import { runs } from "copilotz/plugins/interfaces/contract";
|
|
24
|
+
import { say } from "./say.js";
|
|
19
25
|
import { STYLE } from "./style.js";
|
|
20
|
-
import {
|
|
26
|
+
import { Team } from "./team.js";
|
|
27
|
+
import { creditsGo, faster, modelSaid, perReply, providerSaid, shownSaid, unitSaid, } from "./words.js";
|
|
21
28
|
/** How long "Undo" stays after a change. */
|
|
22
29
|
const UNDO_MS = 12_000;
|
|
23
30
|
export const tiersOrgView = (_, ctx) => {
|
|
24
|
-
const shown = ctx.db.collection("modelChoice").query("offered", {}).value;
|
|
31
|
+
const shown = shownSaid(ctx.db.collection("modelChoice").query("offered", {}).value);
|
|
32
|
+
// The org's team (team's), when the app lets people make agents.
|
|
33
|
+
const team = ctx.db.collection("agent").query("team", {}).value;
|
|
25
34
|
const may = runs({
|
|
26
35
|
role: ctx.hints.role ?? null,
|
|
27
36
|
staff: ctx.hints.staff === true,
|
|
28
37
|
});
|
|
29
38
|
const org = ctx.hints.org;
|
|
30
|
-
return (_jsxs(_Fragment, { children: [_jsx("style", { href: "tiers-web", precedence: "copilotz", children: STYLE }), shown
|
|
39
|
+
return (_jsxs(_Fragment, { children: [_jsx("style", { href: "tiers-web", precedence: "copilotz", children: STYLE }), shown
|
|
40
|
+
? (_jsx(OrgAgents, { shown: shown, team: team?.agents, may: may, org: org?.kind === "personal" ? undefined : org?.name, call: ctx.call }))
|
|
41
|
+
: _jsx(Loading, {})] }));
|
|
31
42
|
};
|
|
32
43
|
function Loading() {
|
|
33
44
|
return (_jsxs("div", { className: "tiers", "aria-busy": "true", children: [_jsx(Skeleton, { height: 22, width: "55%" }), _jsx("div", { className: "tiers-cards", children: [0, 1, 2, 3].map((n) => _jsx(Skeleton, { height: 300, radius: "xl" }, n)) }), _jsx(Skeleton, { height: 220, radius: "xl" })] }));
|
|
34
45
|
}
|
|
35
|
-
export function
|
|
46
|
+
export function OrgAgents({ shown, team, may, org, call }) {
|
|
36
47
|
const [busy, setBusy] = useState();
|
|
37
48
|
const [error, setError] = useState();
|
|
38
49
|
const [done, setDone] = useState();
|
|
50
|
+
const [editing, setEditing] = useState();
|
|
39
51
|
useEffect(() => {
|
|
40
52
|
if (!done)
|
|
41
53
|
return;
|
|
@@ -43,23 +55,16 @@ export function OrgModels({ shown, may, org, call }) {
|
|
|
43
55
|
return () => clearTimeout(timer);
|
|
44
56
|
}, [done]);
|
|
45
57
|
if (!shown.tiers.length) {
|
|
46
|
-
return (_jsx(EmptyState, { icon: "bot", title: "
|
|
58
|
+
return (_jsx(EmptyState, { icon: "bot", title: say("emptyTitle"), children: say("emptyBody") }));
|
|
47
59
|
}
|
|
48
|
-
const
|
|
60
|
+
const fallback = shown.tiers.find((t) => t.name === shown.plan) ?? shown.tiers[0];
|
|
61
|
+
const current = shown.org.tier ?? fallback.name;
|
|
49
62
|
const title = (name) => shown.tiers.find((t) => t.name === name)?.title;
|
|
50
|
-
const
|
|
51
|
-
setBusy(
|
|
63
|
+
const act = async (key, work) => {
|
|
64
|
+
setBusy(key);
|
|
52
65
|
setError(undefined);
|
|
53
66
|
try {
|
|
54
|
-
|
|
55
|
-
await call("tiers.choose", { tier });
|
|
56
|
-
const to = tier ? title(tier) : title(shown.plan);
|
|
57
|
-
setDone(undoing ? undefined : {
|
|
58
|
-
said: to
|
|
59
|
-
? `Your agents use ${to} from their next reply.`
|
|
60
|
-
: "Your agents use their own models from their next reply.",
|
|
61
|
-
tier: before,
|
|
62
|
-
});
|
|
67
|
+
await work();
|
|
63
68
|
}
|
|
64
69
|
catch (e) {
|
|
65
70
|
setError(message(e));
|
|
@@ -68,75 +73,217 @@ export function OrgModels({ shown, may, org, call }) {
|
|
|
68
73
|
setBusy(undefined);
|
|
69
74
|
}
|
|
70
75
|
};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
const choose = (tier, undoing = false) => act(tier ?? "plan", async () => {
|
|
77
|
+
const before = shown.org.tier;
|
|
78
|
+
await call("tiers.choose", { tier });
|
|
79
|
+
setDone(undoing ? undefined : {
|
|
80
|
+
said: say("doneSaid", { tier: title(tier ?? shown.plan) ?? "" }),
|
|
81
|
+
tier: before,
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
return (_jsxs("div", { className: "tiers", children: [_jsxs("div", { className: "tiers-now", children: [_jsxs("p", { children: [say.nodes(shown.org.tier ? "nowOrg" : "nowPlan", { tier: _jsx("b", { children: title(current) }) }), " ", say("nowMore")] }), may && shown.org.tier && shown.plan && shown.org.tier !== shown.plan
|
|
85
|
+
? (_jsx(Button, { size: "sm", variant: "ghost", loading: busy === "plan", disabled: !!busy, onClick: () => void choose(null), children: say("backToPlan") }))
|
|
75
86
|
: null] }), done
|
|
76
|
-
? (_jsx(Notice, { tone: "success", role: "status", action: _jsx(Button, { size: "sm", onClick: () => void choose(done.tier, true), disabled: !!busy, children: "
|
|
77
|
-
: null, error ? _jsx(Notice, { tone: "destructive", role: "alert", children: error }) : null, may ? null : (
|
|
87
|
+
? (_jsx(Notice, { tone: "success", role: "status", action: _jsx(Button, { size: "sm", onClick: () => void choose(done.tier, true), disabled: !!busy, children: say("undo") }), children: done.said }))
|
|
88
|
+
: null, error ? _jsx(Notice, { tone: "destructive", role: "alert", children: error }) : null, may ? null : (_jsx(Notice, { tone: "neutral", icon: "lock", children: org ? say("onlyRunners", { org }) : say("onlyRunnersHere") })), _jsxs("ul", { className: "tiers-cards", "aria-label": say("tiersLabel"), children: [shown.tiers.map((tier) => (_jsx(TierCard, { tier: tier, shown: shown, current: tier.name === current, may: may, busy: busy, onChoose: () => void choose(tier.name), onEdit: () => setEditing({ name: tier.name }), onCopy: () => setEditing({ from: tier.name, title: say("copyOf", { tier: tier.title }) }), onRemove: () => void act(tier.name, () => call("tiers.remove", { tier: tier.name })), onRestore: () => void act(tier.name, () => call("tiers.restore", { tier: tier.name })) }, tier.name))), may
|
|
89
|
+
? (_jsx("li", { className: "tier-new", children: _jsxs("button", { type: "button", className: "tier-new-button", onClick: () => setEditing({ from: current, title: "" }), children: [_jsx(Icon, { name: "plus", size: 18 }), _jsx("b", { children: say("newTier") }), _jsx("span", { children: say("newTierAbout") })] }) }))
|
|
90
|
+
: null] }), may && shown.removed.length
|
|
91
|
+
? (_jsxs("p", { className: "tiers-removed", children: [_jsx("span", { children: say("takenAway") }), shown.removed.map((r) => (_jsx(Button, { size: "sm", variant: "ghost", icon: "plus", loading: busy === r.name, onClick: () => void act(r.name, () => call("tiers.restore", { tier: r.name })), children: say("addBackTier", { tier: r.title }) }, r.name)))] }))
|
|
92
|
+
: null, may
|
|
93
|
+
? (_jsxs("div", { className: "tiers-cap", children: [_jsx("label", { htmlFor: "tiers-cap", children: say("capLabel") }), _jsxs(Select, { id: "tiers-cap", size: "sm", value: shown.org.cap ?? "", disabled: busy === "cap", onChange: (e) => void act("cap", () => call("tiers.cap", { tier: e.target.value || null })), children: [_jsx("option", { value: "", children: say("capAny") }), shown.tiers.map((t) => _jsx("option", { value: t.name, children: t.title }, t.name))] }), _jsx("span", { children: say("capNote") })] }))
|
|
94
|
+
: null, _jsx(SpendNote, { shown: shown, tier: current }), _jsx(Team, { shown: shown, team: team, may: may, org: org, tier: current, call: call }), _jsxs("p", { className: "tiers-foot", children: [_jsx(Icon, { name: "info", size: 14 }), _jsxs("span", { children: [shown.per === "message" ? say("footMessage") : say("footReply"), " ", say.nodes("footPrices", { budget: _jsx("a", { href: "/org?tab=billing", children: say("budget") }) })] })] }), editing
|
|
95
|
+
? (_jsx(TierEditor, { shown: shown, team: team, editing: editing, call: call, onClose: () => setEditing(undefined) }))
|
|
96
|
+
: null] }));
|
|
78
97
|
}
|
|
79
|
-
/**
|
|
80
|
-
|
|
98
|
+
/**
|
|
99
|
+
* What the tier in use means for the plan's credits, when it's worth saying: a
|
|
100
|
+
* plan of credits given once (a trial's) spent faster than the cheapest tier
|
|
101
|
+
* would, or a plan that gives none.
|
|
102
|
+
*/
|
|
103
|
+
export function SpendNote({ shown, tier }) {
|
|
104
|
+
const credits = shown.credits;
|
|
105
|
+
if (!credits)
|
|
106
|
+
return null;
|
|
107
|
+
if (!credits.amount) {
|
|
108
|
+
return (_jsxs(Notice, { tone: "warning", icon: "info", action: _jsx(Button, { size: "sm", variant: "outline", href: "/org?tab=billing", children: say("billing") }), children: [_jsx("b", { children: say("noCredits", { plan: credits.title }) }), " ", say("noCreditsMore")] }));
|
|
109
|
+
}
|
|
110
|
+
if (credits.every !== "once")
|
|
111
|
+
return null;
|
|
112
|
+
const using = shown.tiers.find((t) => t.name === (tier ?? shown.now?.tier));
|
|
113
|
+
const cheapest = shown.tiers.reduce((low, t) => t.price !== null && (!low || (low.price ?? Infinity) > t.price) ? t : low, undefined);
|
|
114
|
+
if (!using || !cheapest || using.name === cheapest.name)
|
|
115
|
+
return null;
|
|
116
|
+
const times = faster(using.price, cheapest.price);
|
|
117
|
+
if (!times)
|
|
118
|
+
return null;
|
|
119
|
+
const goes = creditsGo(credits, using.price, shown.per);
|
|
120
|
+
return (_jsxs(Notice, { tone: "warning", icon: "info", className: "tiers-spend", children: [_jsx("b", { children: say("faster", { tier: using.title, times, cheapest: cheapest.title }) }), " ", goes ? `${say("fasterGoes", { goes })} ` : "", say("changeAnyTime")] }));
|
|
121
|
+
}
|
|
122
|
+
/** A tier: what it's for, what a message comes to, each kind of work's model, and choosing it. */
|
|
123
|
+
export function TierCard({ tier, shown, current, may, busy, onChoose, onEdit, onCopy, onRemove, onRestore }) {
|
|
81
124
|
const price = perReply(tier.price);
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
125
|
+
const goes = creditsGo(shown.credits, tier.price, shown.per);
|
|
126
|
+
const kindTitle = (kind) => shown.kinds.find((k) => k.kind === kind)?.title ?? kind;
|
|
127
|
+
const items = [
|
|
128
|
+
{ label: say("customize"), icon: "pencil", onSelect: onEdit },
|
|
129
|
+
{ label: say("duplicate"), icon: "copy", onSelect: onCopy },
|
|
130
|
+
...(tier.changed
|
|
131
|
+
? [{ label: say("backToOriginal"), icon: "restore", onSelect: onRestore }]
|
|
132
|
+
: []),
|
|
133
|
+
...(shown.tiers.length > 1
|
|
134
|
+
? [
|
|
135
|
+
"separator",
|
|
136
|
+
{
|
|
137
|
+
label: tier.made ? say("deleteTier") : say("takeAway"),
|
|
138
|
+
icon: "trash",
|
|
139
|
+
tone: "destructive",
|
|
140
|
+
onSelect: onRemove,
|
|
141
|
+
},
|
|
142
|
+
]
|
|
143
|
+
: []),
|
|
144
|
+
];
|
|
145
|
+
return (_jsxs(Card, { as: "li", className: "tier-card", "data-current": current ? true : undefined, "aria-current": current ? "true" : undefined, "aria-labelledby": `tier-${tier.name}`, children: [_jsxs("div", { className: "tier-card-top", children: [_jsx("h3", { id: `tier-${tier.name}`, children: tier.title }), _jsxs("span", { className: "tier-card-badges", children: [current
|
|
146
|
+
? (_jsxs(Badge, { tone: "primary", children: [_jsx(Icon, { name: "check", size: 12 }), say("badgeDefault")] }))
|
|
147
|
+
: tier.name === shown.plan
|
|
148
|
+
? _jsx(Badge, { variant: "outline", children: say("badgePlan") })
|
|
149
|
+
: null, tier.made ? _jsx(Badge, { variant: "outline", children: say("badgeYours") }) : null, tier.changed ? _jsx(Badge, { variant: "outline", children: say("badgeChanged") }) : null, may
|
|
150
|
+
? _jsx(Menu, { label: say("tierMore", { tier: tier.title }), align: "end", items: items })
|
|
151
|
+
: null] })] }), tier.description ? _jsx("p", { className: "tier-card-for", children: tier.description }) : null, _jsx("p", { className: "tier-card-price", children: price
|
|
152
|
+
? (_jsxs(_Fragment, { children: [_jsx("b", { children: price }), " ", unitSaid(shown.per)] }))
|
|
153
|
+
: say("pricedEach") }), _jsx("p", { className: "tier-card-goes", children: goes ? goes[0].toUpperCase() + goes.slice(1) : null }), _jsx("ul", { className: "tier-card-agents", "aria-label": say("tierModels", { tier: tier.title }), children: tier.kinds.map(({ kind, model }) => (_jsxs("li", { children: [_jsx("span", { className: "tier-who", children: kindTitle(kind) }), _jsxs("span", { className: "tier-model", children: [model.name, thenSaid(model) ? _jsx("small", { children: say("then", { names: thenSaid(model) }) }) : null] })] }, kind))) }), may
|
|
90
154
|
? (_jsx("div", { className: "tier-card-end", children: current
|
|
91
|
-
? (_jsxs("p", { className: "tier-card-using", children: [_jsx(Icon, { name: "check", size: 15 }), "
|
|
92
|
-
: (
|
|
155
|
+
? (_jsxs("p", { className: "tier-card-using", children: [_jsx(Icon, { name: "check", size: 15 }), " ", say("defaultForNew")] }))
|
|
156
|
+
: (_jsx(Button, { loading: busy === tier.name, disabled: !!busy, onClick: onChoose, "aria-describedby": `tier-${tier.name}`, children: say("makeDefault") })) }))
|
|
93
157
|
: null] }));
|
|
94
158
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
159
|
+
const chainOf = (model) => model ? [model.id, ...(model.fallbacks ?? []).map((f) => f.id)] : [];
|
|
160
|
+
/**
|
|
161
|
+
* Customizing a tier, or making one (a dialog): its name and what it's for,
|
|
162
|
+
* then each kind of work, with the agents that do it, its model and what it
|
|
163
|
+
* falls back to (team's picker, `model.pick`), and adding a kind of work of
|
|
164
|
+
* the org's own. Saved at once (`tiers.save`): only the kinds changed.
|
|
165
|
+
*/
|
|
166
|
+
function TierEditor({ shown, team, editing, call, onClose }) {
|
|
167
|
+
const tier = editing.name ? shown.tiers.find((t) => t.name === editing.name) : undefined;
|
|
168
|
+
const base = tier ?? shown.tiers.find((t) => t.name === editing.from) ?? shown.tiers[0];
|
|
169
|
+
const making = !tier;
|
|
170
|
+
const [title, setTitle] = useState(tier?.title ?? editing.title ?? "");
|
|
171
|
+
const [description, setDescription] = useState(tier?.description ?? "");
|
|
172
|
+
const [chains, setChains] = useState({});
|
|
173
|
+
const [busy, setBusy] = useState(false);
|
|
100
174
|
const [error, setError] = useState();
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
175
|
+
const [adding, setAdding] = useState();
|
|
176
|
+
// Names for models chosen here, until the page shows them.
|
|
177
|
+
const [names, setNames] = useState({});
|
|
178
|
+
const known = new Map();
|
|
179
|
+
for (const t of shown.tiers) {
|
|
180
|
+
for (const k of t.kinds) {
|
|
181
|
+
known.set(k.model.id, k.model.name);
|
|
182
|
+
for (const f of k.model.fallbacks ?? [])
|
|
183
|
+
known.set(f.id, f.name);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const nameOf = (id) => known.get(id) ?? names[id] ?? id.slice(id.indexOf("/") + 1);
|
|
187
|
+
const chainFor = (kind) => chains[kind] ?? chainOf(base?.kinds.find((k) => k.kind === kind)?.model);
|
|
188
|
+
const set = (kind, chain) => setChains((had) => ({ ...had, [kind]: chain }));
|
|
189
|
+
const agentsOf = (kind) => [
|
|
190
|
+
...(shown.kinds.find((k) => k.kind === kind)?.agents.map((a) => a.name) ?? []),
|
|
191
|
+
...(team ?? []).filter((a) => !a.off && a.kind === "org" && a.like === kind).map((a) => a.name),
|
|
192
|
+
];
|
|
193
|
+
const save = async () => {
|
|
194
|
+
setBusy(true);
|
|
104
195
|
setError(undefined);
|
|
105
196
|
try {
|
|
106
|
-
await
|
|
197
|
+
await call("tiers.save", {
|
|
198
|
+
...(tier ? { tier: tier.name } : { from: base?.name }),
|
|
199
|
+
...(title.trim() && title.trim() !== tier?.title ? { title: title.trim() } : {}),
|
|
200
|
+
...(description.trim() !== (tier?.description ?? "")
|
|
201
|
+
? { description: description.trim() }
|
|
202
|
+
: {}),
|
|
203
|
+
...(Object.keys(chains).length ? { kinds: chains } : {}),
|
|
204
|
+
});
|
|
205
|
+
onClose();
|
|
206
|
+
}
|
|
207
|
+
catch (e) {
|
|
208
|
+
setError(message(e));
|
|
209
|
+
setBusy(false);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
const addKind = async () => {
|
|
213
|
+
if (!adding?.title.trim())
|
|
214
|
+
return;
|
|
215
|
+
setBusy(true);
|
|
216
|
+
setError(undefined);
|
|
217
|
+
try {
|
|
218
|
+
await call("tiers.kind", { title: adding.title.trim(), base: adding.base });
|
|
219
|
+
setAdding(undefined);
|
|
107
220
|
}
|
|
108
221
|
catch (e) {
|
|
109
222
|
setError(message(e));
|
|
110
223
|
}
|
|
111
224
|
finally {
|
|
112
|
-
setBusy(
|
|
225
|
+
setBusy(false);
|
|
113
226
|
}
|
|
114
227
|
};
|
|
115
|
-
const
|
|
116
|
-
return (
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
228
|
+
const appKinds = shown.kinds.filter((k) => !k.base);
|
|
229
|
+
return (_jsx(Dialog, { open: true, onClose: onClose, size: "lg", title: making ? say("newTierTitle") : say("customizeTitle", { tier: tier.title }), description: making
|
|
230
|
+
? say("newTierStarts", { tier: base?.title ?? "" })
|
|
231
|
+
: say("customizeAbout"), footer: _jsxs(_Fragment, { children: [error ? _jsx("span", { className: "tiers-editor-error", role: "alert", children: error }) : null, _jsx(Button, { variant: "ghost", onClick: onClose, disabled: busy, children: say("cancel") }), _jsx(Button, { variant: "primary", loading: busy, disabled: making && !title.trim(), onClick: () => void save(), children: making ? say("createTier") : say("save") })] }), children: _jsxs("div", { className: "tiers-editor", children: [_jsxs("div", { className: "tiers-editor-names", children: [_jsx(Field, { label: say("name"), children: (control) => (_jsx(Input, { ...control, value: title, maxLength: 40, placeholder: say("namePlaceholder"), autoFocus: making, onChange: (e) => setTitle(e.target.value) })) }), _jsx(Field, { label: say("forLabel"), children: (control) => (_jsx(Input, { ...control, value: description, maxLength: 200, placeholder: say("forPlaceholder"), onChange: (e) => setDescription(e.target.value) })) })] }), _jsx("ol", { className: "tiers-kinds", children: shown.kinds.map((kind) => {
|
|
232
|
+
const chain = chainFor(kind.kind);
|
|
233
|
+
const who = agentsOf(kind.kind);
|
|
234
|
+
return (_jsxs("li", { className: "tiers-kind", children: [_jsxs("div", { className: "tiers-kind-head", children: [_jsx("b", { children: kind.title }), _jsx("span", { children: who.length ? who.join(", ") : say("nobodyYet") }), chains[kind.kind]
|
|
235
|
+
? _jsx(Badge, { variant: "outline", children: say("badgeChanged") })
|
|
236
|
+
: null] }), _jsx(ChainEditor, { chain: chain, nameOf: nameOf, onName: (id, name) => setNames((had) => ({ ...had, [id]: name })), onChange: (next) => set(kind.kind, next) })] }, kind.kind));
|
|
237
|
+
}) }), adding
|
|
238
|
+
? (_jsxs("div", { className: "tiers-kind-new", children: [_jsx(Field, { label: say("newKind"), children: (control) => (_jsx(Input, { ...control, value: adding.title, maxLength: 40, placeholder: say("newKindPlaceholder"), autoFocus: true, onChange: (e) => setAdding({ ...adding, title: e.target.value }) })) }), _jsx(Field, { label: say("startsFrom"), children: (control) => (_jsx(Select, { ...control, value: adding.base, onChange: (e) => setAdding({ ...adding, base: e.target.value }), children: appKinds.map((k) => _jsx("option", { value: k.kind, children: k.title }, k.kind)) })) }), _jsxs("div", { className: "tiers-kind-new-end", children: [_jsx(Button, { size: "sm", variant: "ghost", onClick: () => setAdding(undefined), children: say("cancel") }), _jsx(Button, { size: "sm", variant: "secondary", disabled: !adding.title.trim() || busy, onClick: () => void addKind(), children: say("add") })] })] }))
|
|
239
|
+
: (_jsx(Button, { size: "sm", variant: "ghost", icon: "plus", onClick: () => setAdding({ title: "", base: appKinds[0]?.kind ?? "" }), children: say("addKind") }))] }) }));
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* A model chain: the model (team's picker), then what's tried when it fails,
|
|
243
|
+
* each with Move up, Move down and Remove, and Add a fallback.
|
|
244
|
+
*/
|
|
245
|
+
function ChainEditor({ chain, nameOf, onName, onChange }) {
|
|
246
|
+
const [first, ...rest] = chain;
|
|
247
|
+
const moved = (from, to) => {
|
|
248
|
+
const next = [...rest];
|
|
249
|
+
const [one] = next.splice(from, 1);
|
|
250
|
+
next.splice(to, 0, one);
|
|
251
|
+
return [first, ...next];
|
|
252
|
+
};
|
|
253
|
+
const pick = (onPick) => ({
|
|
254
|
+
onPick: (model) => {
|
|
255
|
+
onName(model, model.slice(model.indexOf("/") + 1));
|
|
256
|
+
onPick(model);
|
|
257
|
+
return Promise.resolve();
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
return (_jsxs("div", { className: "tiers-chain", children: [_jsx(LazyView, { kind: "model.pick", item: { value: first ?? "" }, hints: pick((model) => onChange([model, ...rest.filter((id) => id !== model)])), fallback: _jsx(Skeleton, { height: 54 }) }), _jsxs("div", { className: "tiers-fallbacks", children: [_jsx("p", { className: "tiers-fallbacks-head", children: say("fallbacks") }), rest.length
|
|
261
|
+
? (_jsx("ol", { className: "tiers-fallbacks-list", children: rest.map((id, i) => (_jsxs("li", { children: [_jsxs("span", { className: "tiers-fallback-name", children: [_jsx("b", { children: nameOf(id) }), _jsx("small", { children: providerSaid(id) })] }), _jsx(Menu, { label: say("tierMore", { tier: nameOf(id) }), align: "end", items: [
|
|
262
|
+
...(i > 0
|
|
263
|
+
? [{ label: say("moveUp"), onSelect: () => onChange(moved(i, i - 1)) }]
|
|
264
|
+
: []),
|
|
265
|
+
...(i < rest.length - 1
|
|
266
|
+
? [{ label: say("moveDown"), onSelect: () => onChange(moved(i, i + 1)) }]
|
|
267
|
+
: []),
|
|
268
|
+
{
|
|
269
|
+
label: say("remove"),
|
|
270
|
+
icon: "trash",
|
|
271
|
+
tone: "destructive",
|
|
272
|
+
onSelect: () => onChange([first, ...rest.filter((_, j) => j !== i)]),
|
|
273
|
+
},
|
|
274
|
+
] })] }, `${id}:${i}`))) }))
|
|
275
|
+
: _jsx("p", { className: "tiers-fallbacks-none", children: say("noFallback") }), _jsx(LazyView, { kind: "model.pick", item: { value: "" }, hints: {
|
|
276
|
+
...pick((model) => onChange([first, ...rest.filter((id) => id !== model), model])),
|
|
277
|
+
look: "link",
|
|
278
|
+
label: say("addFallback"),
|
|
279
|
+
disabled: rest.length >= 7,
|
|
280
|
+
}, fallback: null })] })] }));
|
|
132
281
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
return
|
|
138
|
-
? (_jsxs("div", { className: "tiers-row-pick", children: [_jsx(LazyView, { kind: "model.pick", item: { value: now.model.id }, hints: pick, fallback: _jsx(Skeleton, { height: 54 }) }), _jsxs("span", { className: "tiers-row-under", children: [from, price ? _jsxs("span", { children: [price, " a typical reply"] }) : null, picked
|
|
139
|
-
? (_jsx(Button, { variant: "link", size: "sm", className: "tiers-back", disabled: busy, onClick: onBack, children: back }))
|
|
140
|
-
: null] })] }))
|
|
141
|
-
: (_jsxs("p", { className: "tiers-row-model", children: [_jsx("b", { children: now.model.name }), effortSaid(now.model.effort) ? `, ${effortSaid(now.model.effort)}` : "", " \u00B7 ", from, now.model.ownKey ? " · on your key" : ""] }))] }), editing || !price ? null : _jsxs("span", { className: "tiers-row-price", children: [price, " a reply"] })] }));
|
|
282
|
+
/** What a model falls back to, each name once: "GPT-6 Luna, Claude Haiku 5.5". */
|
|
283
|
+
export function thenSaid(model) {
|
|
284
|
+
const names = [...new Set((model.fallbacks ?? []).map((f) => f.name))]
|
|
285
|
+
.filter((name) => name !== model.name);
|
|
286
|
+
return names.length ? names.join(", ") : undefined;
|
|
142
287
|
}
|
|
288
|
+
/** A model as a short line: "Claude Haiku 5.5, low effort, then GPT-6 Luna". */
|
|
289
|
+
export const modelLine = (model) => `${modelSaid(model)}${thenSaid(model) ? `, then ${thenSaid(model)}` : ""}`;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/** Every word tiers' web front end shows, to be changed by the app (`tiers.<key>`). */
|
|
2
|
+
import { type Phrase } from "copilotz/web/words";
|
|
3
|
+
export declare const tiers: {
|
|
4
|
+
perMessage: string;
|
|
5
|
+
perReply: string;
|
|
6
|
+
messages: {
|
|
7
|
+
one: string;
|
|
8
|
+
other: string;
|
|
9
|
+
};
|
|
10
|
+
replies: {
|
|
11
|
+
one: string;
|
|
12
|
+
other: string;
|
|
13
|
+
};
|
|
14
|
+
creditsOnce: string;
|
|
15
|
+
creditsSeat: string;
|
|
16
|
+
creditsMonth: string;
|
|
17
|
+
underTenth: string;
|
|
18
|
+
effortNone: string;
|
|
19
|
+
effortMinimal: string;
|
|
20
|
+
effortLow: string;
|
|
21
|
+
effortMedium: string;
|
|
22
|
+
effortHigh: string;
|
|
23
|
+
effortXhigh: string;
|
|
24
|
+
effortMax: string;
|
|
25
|
+
effortOther: string;
|
|
26
|
+
providerChatgpt: string;
|
|
27
|
+
byThread: string;
|
|
28
|
+
byPerson: string;
|
|
29
|
+
bySpace: string;
|
|
30
|
+
byOrg: string;
|
|
31
|
+
byPlan: string;
|
|
32
|
+
emptyTitle: string;
|
|
33
|
+
emptyBody: string;
|
|
34
|
+
nowOrg: string;
|
|
35
|
+
nowPlan: string;
|
|
36
|
+
nowMore: string;
|
|
37
|
+
backToPlan: string;
|
|
38
|
+
doneSaid: string;
|
|
39
|
+
undo: string;
|
|
40
|
+
onlyRunners: string;
|
|
41
|
+
onlyRunnersHere: string;
|
|
42
|
+
tiersLabel: string;
|
|
43
|
+
newTier: string;
|
|
44
|
+
newTierAbout: string;
|
|
45
|
+
takenAway: string;
|
|
46
|
+
addBackTier: string;
|
|
47
|
+
capLabel: string;
|
|
48
|
+
capAny: string;
|
|
49
|
+
capNote: string;
|
|
50
|
+
noCredits: string;
|
|
51
|
+
noCreditsMore: string;
|
|
52
|
+
billing: string;
|
|
53
|
+
faster: string;
|
|
54
|
+
fasterGoes: string;
|
|
55
|
+
changeAnyTime: string;
|
|
56
|
+
footMessage: string;
|
|
57
|
+
footReply: string;
|
|
58
|
+
footPrices: string;
|
|
59
|
+
budget: string;
|
|
60
|
+
tierMore: string;
|
|
61
|
+
customize: string;
|
|
62
|
+
duplicate: string;
|
|
63
|
+
copyOf: string;
|
|
64
|
+
backToOriginal: string;
|
|
65
|
+
deleteTier: string;
|
|
66
|
+
takeAway: string;
|
|
67
|
+
badgeDefault: string;
|
|
68
|
+
badgePlan: string;
|
|
69
|
+
badgeYours: string;
|
|
70
|
+
badgeChanged: string;
|
|
71
|
+
pricedEach: string;
|
|
72
|
+
tierModels: string;
|
|
73
|
+
then: string;
|
|
74
|
+
defaultForNew: string;
|
|
75
|
+
makeDefault: string;
|
|
76
|
+
newTierTitle: string;
|
|
77
|
+
customizeTitle: string;
|
|
78
|
+
newTierStarts: string;
|
|
79
|
+
customizeAbout: string;
|
|
80
|
+
cancel: string;
|
|
81
|
+
createTier: string;
|
|
82
|
+
save: string;
|
|
83
|
+
name: string;
|
|
84
|
+
namePlaceholder: string;
|
|
85
|
+
forLabel: string;
|
|
86
|
+
forPlaceholder: string;
|
|
87
|
+
nobodyYet: string;
|
|
88
|
+
newKind: string;
|
|
89
|
+
newKindPlaceholder: string;
|
|
90
|
+
startsFrom: string;
|
|
91
|
+
add: string;
|
|
92
|
+
addKind: string;
|
|
93
|
+
fallbacks: string;
|
|
94
|
+
moveUp: string;
|
|
95
|
+
moveDown: string;
|
|
96
|
+
remove: string;
|
|
97
|
+
noFallback: string;
|
|
98
|
+
addFallback: string;
|
|
99
|
+
teamTitle: string;
|
|
100
|
+
teamAbout: string;
|
|
101
|
+
teamAboutMine: string;
|
|
102
|
+
addAgent: string;
|
|
103
|
+
edit: string;
|
|
104
|
+
removeFromTeam: string;
|
|
105
|
+
badgeOrgs: string;
|
|
106
|
+
onTier: string;
|
|
107
|
+
notOnTeam: string;
|
|
108
|
+
addBack: string;
|
|
109
|
+
addAgentTitle: string;
|
|
110
|
+
addAgentAbout: string;
|
|
111
|
+
addAgentAboutMine: string;
|
|
112
|
+
removeTitle: string;
|
|
113
|
+
removeSaid: string;
|
|
114
|
+
removeSaidMine: string;
|
|
115
|
+
removeDeletes: string;
|
|
116
|
+
removeBack: string;
|
|
117
|
+
recommended: string;
|
|
118
|
+
ownersChoose: string;
|
|
119
|
+
spaceStartsOn: string;
|
|
120
|
+
spaceChosen: string;
|
|
121
|
+
spaceAsOrg: string;
|
|
122
|
+
spaceSwitch: string;
|
|
123
|
+
spaceManagers: string;
|
|
124
|
+
spaceSelect: string;
|
|
125
|
+
asOrg: string;
|
|
126
|
+
agentLine: string;
|
|
127
|
+
pickLabel: string;
|
|
128
|
+
pickCap: string;
|
|
129
|
+
backToDefault: string;
|
|
130
|
+
backToOrgDefault: string;
|
|
131
|
+
chatRunsOn: string;
|
|
132
|
+
chatRunsDefault: string;
|
|
133
|
+
newChatsOn: string;
|
|
134
|
+
newChatsDefault: string;
|
|
135
|
+
};
|
|
136
|
+
export declare const say: import("copilotz/web/words").Say<"name" | "then" | "cancel" | "edit" | "namePlaceholder" | "undo" | "add" | "save" | "remove" | "billing" | "fallbacks" | "budget" | "perMessage" | "perReply" | "messages" | "replies" | "creditsOnce" | "creditsSeat" | "creditsMonth" | "underTenth" | "effortNone" | "effortMinimal" | "effortLow" | "effortMedium" | "effortHigh" | "effortXhigh" | "effortMax" | "effortOther" | "providerChatgpt" | "byThread" | "byPerson" | "bySpace" | "byOrg" | "byPlan" | "emptyTitle" | "emptyBody" | "nowOrg" | "nowPlan" | "nowMore" | "backToPlan" | "doneSaid" | "onlyRunners" | "onlyRunnersHere" | "tiersLabel" | "newTier" | "newTierAbout" | "takenAway" | "addBackTier" | "capLabel" | "capAny" | "capNote" | "noCredits" | "noCreditsMore" | "faster" | "fasterGoes" | "changeAnyTime" | "footMessage" | "footReply" | "footPrices" | "tierMore" | "customize" | "duplicate" | "copyOf" | "backToOriginal" | "deleteTier" | "takeAway" | "badgeDefault" | "badgePlan" | "badgeYours" | "badgeChanged" | "pricedEach" | "tierModels" | "defaultForNew" | "makeDefault" | "newTierTitle" | "customizeTitle" | "newTierStarts" | "customizeAbout" | "createTier" | "forLabel" | "forPlaceholder" | "nobodyYet" | "newKind" | "newKindPlaceholder" | "startsFrom" | "addKind" | "moveUp" | "moveDown" | "noFallback" | "addFallback" | "teamTitle" | "teamAbout" | "teamAboutMine" | "addAgent" | "removeFromTeam" | "badgeOrgs" | "onTier" | "notOnTeam" | "addBack" | "addAgentTitle" | "addAgentAbout" | "addAgentAboutMine" | "removeTitle" | "removeSaid" | "removeSaidMine" | "removeDeletes" | "removeBack" | "recommended" | "ownersChoose" | "spaceStartsOn" | "spaceChosen" | "spaceAsOrg" | "spaceSwitch" | "spaceManagers" | "spaceSelect" | "asOrg" | "agentLine" | "pickLabel" | "pickCap" | "backToDefault" | "backToOrgDefault" | "chatRunsOn" | "chatRunsDefault" | "newChatsOn" | "newChatsDefault">;
|
|
137
|
+
/** Every word of tiers' front end, by area (team's WORDS.md lists them). */
|
|
138
|
+
export declare const PHRASES: Record<string, Record<string, Phrase>>;
|