@copilotz/team 1.0.0-rc.54 → 1.0.0-rc.56

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.
Files changed (66) hide show
  1. package/WORDS.md +156 -0
  2. package/package.json +2 -2
  3. package/team/actions/agent.d.ts +10 -0
  4. package/team/actions/agent.js +226 -7
  5. package/team/actions/define.js +7 -3
  6. package/team/collections/agent.d.ts +52 -7
  7. package/team/collections/agent.js +56 -5
  8. package/team/mod.d.ts +7 -0
  9. package/team/mod.js +14 -1
  10. package/team/resources/propose.d.ts +1 -0
  11. package/team/resources/propose.js +97 -0
  12. package/team/shared/definition.d.ts +1 -1
  13. package/team/shared/definition.js +5 -4
  14. package/team/shared/everywhere.d.ts +11 -0
  15. package/team/shared/everywhere.js +29 -0
  16. package/team/views/web/agent-add.js +14 -4
  17. package/team/views/web/agent-describe.d.ts +38 -0
  18. package/team/views/web/agent-describe.js +44 -0
  19. package/team/views/web/agent-fields.d.ts +3 -1
  20. package/team/views/web/agent-fields.js +2 -2
  21. package/team/views/web/agent-known.js +2 -1
  22. package/team/views/web/agent-new.d.ts +4 -1
  23. package/team/views/web/agent-new.js +26 -5
  24. package/team/views/web/agent-org.d.ts +12 -0
  25. package/team/views/web/agent-org.js +89 -0
  26. package/team/views/web/agent.d.ts +7 -4
  27. package/team/views/web/agent.js +81 -28
  28. package/team/views/web/model-pick.d.ts +3 -1
  29. package/team/views/web/model-pick.js +4 -1
  30. package/team/views/web/style.d.ts +1 -1
  31. package/team/views/web/style.js +5 -0
  32. package/team/views/web/words.d.ts +1 -1
  33. package/team/views/web/words.js +28 -0
  34. package/team/web.js +2 -0
  35. package/tiers/actions/choose.d.ts +5 -1
  36. package/tiers/actions/choose.js +247 -66
  37. package/tiers/actions/model.js +31 -22
  38. package/tiers/collections/choice.d.ts +17 -10
  39. package/tiers/collections/choice.js +39 -27
  40. package/tiers/collections/template.d.ts +90 -0
  41. package/tiers/collections/template.js +41 -0
  42. package/tiers/contract.d.ts +10 -8
  43. package/tiers/mod.d.ts +30 -21
  44. package/tiers/mod.js +45 -36
  45. package/tiers/shared/shown.d.ts +131 -49
  46. package/tiers/shared/shown.js +192 -98
  47. package/tiers/shared/tiers.d.ts +105 -62
  48. package/tiers/shared/tiers.js +127 -86
  49. package/tiers/views/web/composer.d.ts +12 -0
  50. package/tiers/views/web/composer.js +79 -0
  51. package/tiers/views/web/org.d.ts +44 -21
  52. package/tiers/views/web/org.js +231 -84
  53. package/tiers/views/web/say.d.ts +138 -0
  54. package/tiers/views/web/say.js +142 -0
  55. package/tiers/views/web/setup.d.ts +23 -0
  56. package/tiers/views/web/setup.js +80 -0
  57. package/tiers/views/web/space.d.ts +8 -20
  58. package/tiers/views/web/space.js +30 -59
  59. package/tiers/views/web/style.d.ts +1 -1
  60. package/tiers/views/web/style.js +98 -4
  61. package/tiers/views/web/team.d.ts +38 -0
  62. package/tiers/views/web/team.js +118 -0
  63. package/tiers/views/web/words.d.ts +36 -16
  64. package/tiers/views/web/words.js +102 -35
  65. package/tiers/web.d.ts +18 -9
  66. package/tiers/web.js +36 -10
@@ -0,0 +1,90 @@
1
+ export declare const tierTemplate: {
2
+ schema: {
3
+ readonly type: "object";
4
+ readonly properties: {
5
+ readonly title: {
6
+ readonly type: "string";
7
+ };
8
+ readonly description: {
9
+ readonly type: "string";
10
+ };
11
+ readonly order: {
12
+ readonly type: "number";
13
+ };
14
+ /** Kinds of work's chains, by kind. */
15
+ readonly agents: {
16
+ readonly type: "object";
17
+ };
18
+ readonly off: {
19
+ readonly type: "boolean";
20
+ };
21
+ readonly made: {
22
+ readonly type: "boolean";
23
+ };
24
+ readonly at: {
25
+ readonly type: "string";
26
+ };
27
+ };
28
+ readonly required: readonly ["at"];
29
+ };
30
+ events?: boolean;
31
+ records?: boolean;
32
+ durable?: false;
33
+ indexes?: string[][];
34
+ private?: string[];
35
+ queries?: Record<string, import("copilotz").QueryDef<{
36
+ [x: string]: unknown;
37
+ title?: string | undefined;
38
+ description?: string | undefined;
39
+ off?: boolean | undefined;
40
+ agents?: {
41
+ [x: string]: unknown;
42
+ } | undefined;
43
+ made?: boolean | undefined;
44
+ order?: number | undefined;
45
+ at: string;
46
+ } & {
47
+ _id: string;
48
+ }>> | undefined;
49
+ vectors?: string[];
50
+ };
51
+ /**
52
+ * Kinds of work an org added (`tierKind`, by name): what it's called, and
53
+ * the app's kind it starts from, whose chain it takes in any tier that
54
+ * doesn't name it. Through `tiers.kind`, by owners and admins.
55
+ */
56
+ export declare const tierKind: {
57
+ schema: {
58
+ readonly type: "object";
59
+ readonly properties: {
60
+ readonly title: {
61
+ readonly type: "string";
62
+ };
63
+ readonly description: {
64
+ readonly type: "string";
65
+ };
66
+ readonly base: {
67
+ readonly type: "string";
68
+ };
69
+ readonly at: {
70
+ readonly type: "string";
71
+ };
72
+ };
73
+ readonly required: readonly ["title", "base", "at"];
74
+ };
75
+ events?: boolean;
76
+ records?: boolean;
77
+ durable?: false;
78
+ indexes?: string[][];
79
+ private?: string[];
80
+ queries?: Record<string, import("copilotz").QueryDef<{
81
+ [x: string]: unknown;
82
+ description?: string | undefined;
83
+ at: string;
84
+ title: string;
85
+ base: string;
86
+ } & {
87
+ _id: string;
88
+ }>> | undefined;
89
+ vectors?: string[];
90
+ };
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The org's tiers, as it keeps them (`tierTemplate`, one per tier, by its
3
+ * name): its version of one of the app's (kinds' chains changed, a title, or
4
+ * `off`: taken away), or one it made (`made`, whole). Changed only through
5
+ * `tiers.save`, `tiers.remove` and `tiers.restore`, by the org's owners and
6
+ * admins; everyone in the org reads them, through `modelChoice.offered`.
7
+ */
8
+ import { defineCollection } from "copilotz";
9
+ export const tierTemplate = defineCollection({
10
+ schema: {
11
+ type: "object",
12
+ properties: {
13
+ title: { type: "string" },
14
+ description: { type: "string" },
15
+ order: { type: "number" },
16
+ /** Kinds of work's chains, by kind. */
17
+ agents: { type: "object" },
18
+ off: { type: "boolean" },
19
+ made: { type: "boolean" },
20
+ at: { type: "string" },
21
+ },
22
+ required: ["at"],
23
+ },
24
+ });
25
+ /**
26
+ * Kinds of work an org added (`tierKind`, by name): what it's called, and
27
+ * the app's kind it starts from, whose chain it takes in any tier that
28
+ * doesn't name it. Through `tiers.kind`, by owners and admins.
29
+ */
30
+ export const tierKind = defineCollection({
31
+ schema: {
32
+ type: "object",
33
+ properties: {
34
+ title: { type: "string" },
35
+ description: { type: "string" },
36
+ base: { type: "string" },
37
+ at: { type: "string" },
38
+ },
39
+ required: ["title", "base", "at"],
40
+ },
41
+ });
@@ -1,14 +1,16 @@
1
1
  /**
2
- * The tiers plugin's contract: the shapes of a tier (its `tiers` resource), of
3
- * what an org or a space chose, and of what its queries answer, and the
4
- * resource kind it reads (`planTier`). The rest is reached by name: its
5
- * collection `modelChoice`, its queries (`modelChoice.offered`,
6
- * `modelChoice.agent`) and its Actions (`tiers.model`, `tiers.choose`,
7
- * `tiers.pick`).
2
+ * The tiers plugin's contract: the shapes of a tier (its `tiers` resource), a
3
+ * kind of work (`tierKinds`), what levels chose, and what its queries answer,
4
+ * and the resource kinds it reads (`planTier`, `planCredits`,
5
+ * `typicalMessage`). The rest is reached by name: its collections
6
+ * (`modelChoice`, `tierTemplate`, `tierKind`), its queries
7
+ * (`modelChoice.offered`, `modelChoice.agent`) and its Actions
8
+ * (`tiers.model`, `tiers.choose`, `tiers.cap`, `tiers.save`, `tiers.remove`,
9
+ * `tiers.restore`, `tiers.kind`).
8
10
  */
9
- export type { Choice, From, Tier } from "./shared/tiers.js";
11
+ export type { By, Choice, Kind, Tier } from "./shared/tiers.js";
10
12
  export type { ModelChoice } from "./collections/choice.js";
11
- export type { AgentNow, ChoiceShown, ModelShown, Shown, TierShown } from "./shared/shown.js";
13
+ export type { AgentNow, CreditsShown, KindShown, ModelShown, PlanCredits, Shown, TierShown, TypicalMessage, } from "./shared/shown.js";
12
14
  /**
13
15
  * A `planTier` resource: the Action saying which tier the org's plan gives its
14
16
  * agents while the org hasn't chosen (credits' `billing.tier`), `{}` in, a
package/tiers/mod.d.ts CHANGED
@@ -1,32 +1,41 @@
1
1
  /**
2
- * Tiers: which models the app's agents think with, chosen by what the work
3
- * needs rather than model by model. The app declares its tiers (its `tiers`
4
- * resource): each a title, what it's good for, and a model for each of its
5
- * agents, as an agent's `model` takes one (one, settings around one, or a list
6
- * tried in order). An org chooses one, and a space can choose another:
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
7
  *
8
- * - **Who chooses, first that applies:** a model picked for the agent in the
9
- * space, the space's tier, a model picked for it by the org, the org's tier,
10
- * then the tier the org's plan gives (the `planTier` resource, which credits
11
- * fills); else the agent's own model. A tier that doesn't name an agent
12
- * leaves it on its own. A pick keeps the tier's list behind it, so a model
13
- * that fails falls back as before, and the `maxTokens` of the entry it
14
- * replaces, with its `effort` when the picked model takes it.
15
- * - **Names, never copies:** an org or a space keeps a tier's name
16
- * (`modelChoice`), so retuning a tier moves everyone on it.
17
- * - **Who may:** the org's owners and admins choose for the org, a space's
18
- * managers for the space (`tiers.choose`, `tiers.pick`); everyone who
19
- * reaches them sees what was chosen (`modelChoice.offered`,
20
- * `modelChoice.agent`). Which tier a space takes isn't limited: the org's
21
- * budget bounds what it spends.
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 can cap
23
+ * what its members choose (`tiers.cap`); its owners and admins aren't
24
+ * bound by it, and its budget bounds what anyone spends.
22
25
  * - **Every turn:** chat asks `tiers.model` through its `agentModel` resource,
23
- * for the app's agents only; agents people make keep their own model. A
24
- * change applies from each conversation's next reply.
26
+ * for every agent, with the kind it works like. A change applies from each
27
+ * conversation's next reply.
28
+ *
29
+ * Its queries (`modelChoice.offered`, `modelChoice.agent`) show the tiers
30
+ * with what a typical message comes to at the org's prices (the app's
31
+ * `typicalMessage`, measured, else a plain reply), and how far the plan's
32
+ * credits go (`planCredits`).
25
33
  *
26
34
  * ```ts
27
35
  * plugins: [models, chat, ...access, tiers, definePlugin({
28
36
  * name: "app",
29
37
  * resources: {
38
+ * tierKinds: { north: { title: "Decides" }, east: { title: "Builds" } },
30
39
  * tiers: {
31
40
  * everyday: {
32
41
  * title: "Everyday",
package/tiers/mod.js CHANGED
@@ -1,32 +1,41 @@
1
1
  /**
2
- * Tiers: which models the app's agents think with, chosen by what the work
3
- * needs rather than model by model. The app declares its tiers (its `tiers`
4
- * resource): each a title, what it's good for, and a model for each of its
5
- * agents, as an agent's `model` takes one (one, settings around one, or a list
6
- * tried in order). An org chooses one, and a space can choose another:
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
7
  *
8
- * - **Who chooses, first that applies:** a model picked for the agent in the
9
- * space, the space's tier, a model picked for it by the org, the org's tier,
10
- * then the tier the org's plan gives (the `planTier` resource, which credits
11
- * fills); else the agent's own model. A tier that doesn't name an agent
12
- * leaves it on its own. A pick keeps the tier's list behind it, so a model
13
- * that fails falls back as before, and the `maxTokens` of the entry it
14
- * replaces, with its `effort` when the picked model takes it.
15
- * - **Names, never copies:** an org or a space keeps a tier's name
16
- * (`modelChoice`), so retuning a tier moves everyone on it.
17
- * - **Who may:** the org's owners and admins choose for the org, a space's
18
- * managers for the space (`tiers.choose`, `tiers.pick`); everyone who
19
- * reaches them sees what was chosen (`modelChoice.offered`,
20
- * `modelChoice.agent`). Which tier a space takes isn't limited: the org's
21
- * budget bounds what it spends.
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 can cap
23
+ * what its members choose (`tiers.cap`); its owners and admins aren't
24
+ * bound by it, and its budget bounds what anyone spends.
22
25
  * - **Every turn:** chat asks `tiers.model` through its `agentModel` resource,
23
- * for the app's agents only; agents people make keep their own model. A
24
- * change applies from each conversation's next reply.
26
+ * for every agent, with the kind it works like. A change applies from each
27
+ * conversation's next reply.
28
+ *
29
+ * Its queries (`modelChoice.offered`, `modelChoice.agent`) show the tiers
30
+ * with what a typical message comes to at the org's prices (the app's
31
+ * `typicalMessage`, measured, else a plain reply), and how far the plan's
32
+ * credits go (`planCredits`).
25
33
  *
26
34
  * ```ts
27
35
  * plugins: [models, chat, ...access, tiers, definePlugin({
28
36
  * name: "app",
29
37
  * resources: {
38
+ * tierKinds: { north: { title: "Decides" }, east: { title: "Builds" } },
30
39
  * tiers: {
31
40
  * everyday: {
32
41
  * title: "Everyday",
@@ -49,41 +58,41 @@
49
58
  * ```
50
59
  */
51
60
  import { definePlugin } from "copilotz";
52
- import { agentsOf } from "copilotz/plugins/agents/contract";
53
- import { chooseAction, pickAction } from "./actions/choose.js";
61
+ import { capAction, chooseAction, kindAction, removeAction, restoreAction, saveAction, } from "./actions/choose.js";
54
62
  import { modelAction } from "./actions/model.js";
55
63
  import { modelChoice } from "./collections/choice.js";
56
- import { tiersOf } from "./shared/tiers.js";
64
+ import { tierKind, tierTemplate } from "./collections/template.js";
65
+ import { appTiersOf } from "./shared/tiers.js";
57
66
  export * from "./contract.js";
58
67
  export const tiers = definePlugin({
59
68
  name: "tiers",
60
- // Its choices are an org's and its spaces', changed by who runs them.
69
+ // Its choices are an org's, its spaces' and its conversations', changed by who runs them.
61
70
  requires: ["chat", "spaces"],
62
- collections: { modelChoice },
71
+ collections: { modelChoice, tierTemplate, tierKind },
63
72
  actions: {
64
73
  "tiers.model": modelAction,
65
74
  "tiers.choose": chooseAction,
66
- "tiers.pick": pickAction,
75
+ "tiers.cap": capAction,
76
+ "tiers.save": saveAction,
77
+ "tiers.remove": removeAction,
78
+ "tiers.restore": restoreAction,
79
+ "tiers.kind": kindAction,
67
80
  },
68
81
  resources: {
69
- // Chat asks it which model each of the app's agents thinks with.
82
+ // Chat asks it which model chain each agent thinks with.
70
83
  agentModel: { tiers: { action: "tiers.model" } },
71
84
  },
72
- // Every tier names only the app's agents, with models that can be called as configured.
85
+ // Every tier has a title, and models that can be called as configured.
73
86
  async check(merged) {
74
- const agents = agentsOf(merged);
75
- for (const [name, tier] of Object.entries(tiersOf(merged))) {
87
+ for (const [name, tier] of Object.entries(appTiersOf(merged))) {
76
88
  if (!tier.title)
77
89
  throw new Error(`Tier "${name}" has no title`);
78
- for (const [agent, model] of Object.entries(tier.agents ?? {})) {
79
- if (!agents[agent]) {
80
- throw new Error(`Tier "${name}" names "${agent}", which isn't one of the app's agents`);
81
- }
90
+ for (const [kind, model] of Object.entries(tier.agents ?? {})) {
82
91
  try {
83
92
  await merged.call("models.check", { model, port: "llm" });
84
93
  }
85
94
  catch (error) {
86
- throw new Error(`Tier "${name}", ${agent}: ${error.message}`);
95
+ throw new Error(`Tier "${name}", ${kind}: ${error.message}`);
87
96
  }
88
97
  }
89
98
  }
@@ -1,24 +1,58 @@
1
1
  /**
2
- * What a page shows of tiers, read as the person looking: the tiers on offer,
3
- * each agent's model in them by name, and what a typical reply comes to at
4
- * this org's prices; what the org and a space chose, and what applies, with
5
- * where it comes from.
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.
6
8
  *
7
- * A typical reply, for now: 20,000 tokens in, 16,000 of them read from the
8
- * cache (a conversation's history mostly is), and 1,000 out. One plain profile
9
- * for every agent, to compare tiers by; it's to be calibrated from the ledger
10
- * (what replies really take, by agent and effort) once there's enough of it.
11
- * A tier's price is its agents' average.
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.
12
15
  */
13
16
  import type { ReadContext } from "copilotz";
14
- import { type From, type Levels } from "./tiers.js";
15
- /** A typical reply's tokens (see above). */
17
+ import { type By, type Kind, type Levels, type OrgTier, type Template } from "./tiers.js";
18
+ /** A typical reply's tokens, where the app measured no message (see above). */
16
19
  export declare const REPLY: {
17
20
  input: number;
18
21
  cached: number;
19
22
  output: number;
20
23
  };
21
- /** A model as a page shows it: its name, the effort it's asked for, and a typical reply's price. */
24
+ /**
25
+ * A `typicalMessage` resource: what one message of a person's takes of each of
26
+ * the app's agents, on average, measured from what they really did: how many
27
+ * calls (`calls`: 4.05 for the agent who answers, 0.6 for one asked now and
28
+ * then), and each call's tokens: `input` (with what's read from the cache),
29
+ * `cached`, `cacheWrite` and `output`. An agent it doesn't name isn't counted.
30
+ */
31
+ export type TypicalMessage = Record<string, {
32
+ calls: number;
33
+ input: number;
34
+ cached?: number;
35
+ cacheWrite?: number;
36
+ output: number;
37
+ }>;
38
+ /**
39
+ * A `planCredits` resource: the Action saying what credits the org's plan
40
+ * gives (credits' `billing.credits`), `{}` in, `PlanCredits` or null out.
41
+ */
42
+ export type PlanCredits = {
43
+ action: string;
44
+ };
45
+ /** What the org's plan gives in credits: once (a trial's), or each month, for the org or a seat. */
46
+ export type CreditsShown = {
47
+ /** The plan's name and title: `free`, "Free". */
48
+ plan: string;
49
+ title: string;
50
+ /** USD. */
51
+ amount: number;
52
+ every: "once" | "month";
53
+ perSeat?: true;
54
+ };
55
+ /** A model as a page shows it: its name, effort, a typical message's part, and what's tried after it. */
22
56
  export type ModelShown = {
23
57
  id: string;
24
58
  name: string;
@@ -27,61 +61,109 @@ export type ModelShown = {
27
61
  price: number | null;
28
62
  /** It runs on the org's own key: its provider charges for it, not the app. */
29
63
  ownKey?: true;
64
+ /** What's tried after it when it fails, in order. */
65
+ fallbacks?: {
66
+ id: string;
67
+ name: string;
68
+ effort?: string;
69
+ }[];
30
70
  };
31
71
  export type TierShown = {
32
72
  name: string;
33
73
  title: string;
34
74
  description?: string;
35
- /** A typical reply, its agents' average (USD); null when none is priced. */
75
+ /** A typical message (its kinds' sum), or reply (their average), in USD; null when none is priced. */
36
76
  price: number | null;
37
- agents: {
38
- agent: string;
77
+ /** The app's (as it is, or `changed` by the org), or one the org `made`. */
78
+ app?: true;
79
+ changed?: true;
80
+ made?: true;
81
+ /** Each kind of work's chain here, in the kinds' order. */
82
+ kinds: {
83
+ kind: string;
39
84
  model: ModelShown;
40
85
  }[];
41
86
  };
42
- /** A choice as a page shows it: the tier by name, and each agent's pick. */
43
- export type ChoiceShown = {
44
- tier: string | null;
45
- custom: Record<string, ModelShown>;
46
- };
47
- /** One agent's model where it works, and where it comes from (a tier with its title). */
48
- export type AgentNow = {
49
- model: ModelShown;
50
- from: From & {
51
- title?: string;
52
- };
53
- };
54
- export type Shown = {
55
- tiers: TierShown[];
56
- /** The app's agents, as they're declared. */
87
+ /** A kind of work: its title, and the app's agents that do it. */
88
+ export type KindShown = {
89
+ kind: string;
90
+ title: string;
91
+ description?: string;
92
+ /** For one the org added: the app's kind it starts from. */
93
+ base?: string;
57
94
  agents: {
58
95
  agent: string;
59
96
  name: string;
60
97
  icon?: string;
61
98
  }[];
99
+ };
100
+ export type Shown = {
101
+ tiers: TierShown[];
102
+ kinds: KindShown[];
103
+ /** The app's tiers the org took away, to put back. */
104
+ removed: {
105
+ name: string;
106
+ title: string;
107
+ }[];
62
108
  /** The tier the org's plan gives, when the app has plans that say. */
63
109
  plan: string | null;
64
- org: ChoiceShown;
65
- space?: ChoiceShown;
66
- /** What applies here: the tier in force and who chose it, and each agent's model. */
67
- now: {
68
- tier: {
69
- name: string;
70
- by: "space" | "org" | "plan";
71
- } | null;
72
- agents: Record<string, AgentNow>;
110
+ org: {
111
+ tier: string | null;
112
+ cap: string | null;
113
+ };
114
+ space?: {
115
+ tier: string | null;
116
+ };
117
+ thread?: {
118
+ tier: string | null;
119
+ };
120
+ /** The person's own default for new chats. */
121
+ person: {
122
+ tier: string | null;
73
123
  };
124
+ /** What applies where it was asked: the tier in force and who chose it. */
125
+ now: {
126
+ tier: string;
127
+ by: By;
128
+ } | null;
129
+ /** What prices are for: a typical message the app measured, else a plain reply. */
130
+ per: "message" | "reply";
74
131
  reply: typeof REPLY;
132
+ /** What the org's plan gives in credits, when the app has plans that say. */
133
+ credits: CreditsShown | null;
134
+ };
135
+ /** One agent where it works: its kind, the tier in force there, and its chain in it. */
136
+ export type AgentNow = {
137
+ kind: string;
138
+ kindTitle: string;
139
+ tier: string;
140
+ tierTitle: string;
141
+ by: By;
142
+ model: ModelShown;
75
143
  };
76
- /** What applies at a level: the org's and the plan's, and the space's when there is one. */
77
- export declare function levelsOf(ctx: ReadContext, space?: string): Promise<Levels>;
78
- /** Everything a page shows, at the org's level, or a space's. */
79
- export declare function shownAt(ctx: ReadContext, space?: string): Promise<Shown>;
144
+ /** The org's tiers and kinds, as it keeps them. */
145
+ export declare function orgTiersOf(ctx: ReadContext): Promise<{
146
+ tiers: Record<string, OrgTier>;
147
+ kinds: Record<string, Kind>;
148
+ templates: import("copilotz").WithId<Template>[];
149
+ }>;
150
+ /** What each level chose, where asked: the conversation, the person, the space, the org, the plan. */
151
+ export declare function levelsOf(ctx: ReadContext, where: {
152
+ space?: string;
153
+ thread?: string;
154
+ person?: string;
155
+ }): Promise<Levels>;
156
+ /** Everything a page shows, at the org's level, or where asked (a space, a conversation). */
157
+ export declare function shownAt(ctx: ReadContext, where?: {
158
+ space?: string;
159
+ thread?: string;
160
+ }): Promise<Shown>;
80
161
  /**
81
- * One of the app's agents where it works in a space: its model, where that
82
- * comes from, and, when it's picked for the space, what it would be without
83
- * (`without`: where taking the pick back leaves it).
162
+ * One agent where it works (a space, maybe a conversation): its kind of work,
163
+ * the tier in force there and who chose it, and its chain in that tier; null
164
+ * when no tier applies.
84
165
  */
85
- export declare function agentAt(ctx: ReadContext, agent: string, space: string): Promise<AgentNow & {
86
- without?: AgentNow;
87
- } | null>;
166
+ export declare function agentAt(ctx: ReadContext, agent: string, where: {
167
+ space?: string;
168
+ thread?: string;
169
+ }): Promise<AgentNow | null>;