@copilotz/team 1.0.0-rc.54 → 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
|
@@ -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
|
+
});
|
package/tiers/contract.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The tiers plugin's contract: the shapes of a tier (its `tiers` resource),
|
|
3
|
-
*
|
|
4
|
-
* resource
|
|
5
|
-
*
|
|
6
|
-
* `modelChoice
|
|
7
|
-
* `
|
|
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,
|
|
11
|
+
export type { By, Choice, Kind, Tier } from "./shared/tiers.js";
|
|
10
12
|
export type { ModelChoice } from "./collections/choice.js";
|
|
11
|
-
export type { AgentNow,
|
|
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:
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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
|
-
* - **
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
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
|
|
24
|
-
*
|
|
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:
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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
|
-
* - **
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
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
|
|
24
|
-
*
|
|
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 {
|
|
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 {
|
|
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
|
|
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.
|
|
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
|
|
82
|
+
// Chat asks it which model chain each agent thinks with.
|
|
70
83
|
agentModel: { tiers: { action: "tiers.model" } },
|
|
71
84
|
},
|
|
72
|
-
// Every tier
|
|
85
|
+
// Every tier has a title, and models that can be called as configured.
|
|
73
86
|
async check(merged) {
|
|
74
|
-
const
|
|
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 [
|
|
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}", ${
|
|
95
|
+
throw new Error(`Tier "${name}", ${kind}: ${error.message}`);
|
|
87
96
|
}
|
|
88
97
|
}
|
|
89
98
|
}
|
package/tiers/shared/shown.d.ts
CHANGED
|
@@ -1,24 +1,58 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* What a page shows of tiers, read as the person looking: the tiers
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
|
|
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
|
-
/**
|
|
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
|
|
75
|
+
/** A typical message (its kinds' sum), or reply (their average), in USD; null when none is priced. */
|
|
36
76
|
price: number | null;
|
|
37
|
-
|
|
38
|
-
|
|
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
|
|
43
|
-
export type
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
|
|
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:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
/**
|
|
77
|
-
export declare function
|
|
78
|
-
|
|
79
|
-
|
|
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
|
|
82
|
-
*
|
|
83
|
-
*
|
|
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,
|
|
86
|
-
|
|
87
|
-
|
|
166
|
+
export declare function agentAt(ctx: ReadContext, agent: string, where: {
|
|
167
|
+
space?: string;
|
|
168
|
+
thread?: string;
|
|
169
|
+
}): Promise<AgentNow | null>;
|