@copilotz/team 0.0.0-stage → 1.0.0-rc.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +49 -2
- package/WORDS.md +200 -0
- package/contract.d.ts +8 -0
- package/contract.js +8 -0
- package/mod.d.ts +25 -0
- package/mod.js +25 -0
- package/package.json +63 -4
- package/team/actions/agent.d.ts +4 -0
- package/team/actions/agent.js +179 -0
- package/team/actions/define.d.ts +1 -0
- package/team/actions/define.js +27 -0
- package/team/collections/agent.d.ts +132 -0
- package/team/collections/agent.js +75 -0
- package/team/contract.d.ts +10 -0
- package/team/contract.js +1 -0
- package/team/mod.d.ts +21 -0
- package/team/mod.js +49 -0
- package/team/shared/definition.d.ts +3 -0
- package/team/shared/definition.js +10 -0
- package/team/views/web/agent-add.d.ts +14 -0
- package/team/views/web/agent-add.js +48 -0
- package/team/views/web/agent-fields.d.ts +33 -0
- package/team/views/web/agent-fields.js +88 -0
- package/team/views/web/agent-known.d.ts +22 -0
- package/team/views/web/agent-known.js +61 -0
- package/team/views/web/agent-new.d.ts +24 -0
- package/team/views/web/agent-new.js +129 -0
- package/team/views/web/agent-palette.d.ts +19 -0
- package/team/views/web/agent-palette.js +203 -0
- package/team/views/web/agent-steps.d.ts +23 -0
- package/team/views/web/agent-steps.js +56 -0
- package/team/views/web/agent.d.ts +17 -0
- package/team/views/web/agent.js +257 -0
- package/team/views/web/agents.d.ts +48 -0
- package/team/views/web/agents.js +59 -0
- package/team/views/web/model-pick.d.ts +25 -0
- package/team/views/web/model-pick.js +39 -0
- package/team/views/web/model-picker.d.ts +57 -0
- package/team/views/web/model-picker.js +218 -0
- package/team/views/web/places.d.ts +24 -0
- package/team/views/web/places.js +10 -0
- package/team/views/web/style.d.ts +9 -0
- package/team/views/web/style.js +246 -0
- package/team/views/web/words.d.ts +5 -0
- package/team/views/web/words.js +211 -0
- package/team/web.d.ts +22 -0
- package/team/web.js +41 -0
- package/tiers/actions/choose.d.ts +2 -0
- package/tiers/actions/choose.js +98 -0
- package/tiers/actions/model.d.ts +1 -0
- package/tiers/actions/model.js +36 -0
- package/tiers/collections/choice.d.ts +48 -0
- package/tiers/collections/choice.js +59 -0
- package/tiers/contract.d.ts +19 -0
- package/tiers/contract.js +1 -0
- package/tiers/mod.d.ts +54 -0
- package/tiers/mod.js +92 -0
- package/tiers/shared/shown.d.ts +87 -0
- package/tiers/shared/shown.js +155 -0
- package/tiers/shared/tiers.d.ts +103 -0
- package/tiers/shared/tiers.js +129 -0
- package/tiers/views/web/org.d.ts +38 -0
- package/tiers/views/web/org.js +142 -0
- package/tiers/views/web/space.d.ts +43 -0
- package/tiers/views/web/space.js +103 -0
- package/tiers/views/web/style.d.ts +7 -0
- package/tiers/views/web/style.js +87 -0
- package/tiers/views/web/words.d.ts +21 -0
- package/tiers/views/web/words.js +49 -0
- package/tiers/web.d.ts +18 -0
- package/tiers/web.js +40 -0
- package/web.d.ts +14 -0
- package/web.js +14 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Making an agent in a space, for those who manage it: one calm form (its
|
|
4
|
+
* fields: `AgentFields`), what it may start from (one of the app's agents,
|
|
5
|
+
* `from`: its words, model and tools filled in), and the role it works in
|
|
6
|
+
* there. Made (`agent.create` there, then `member.set`), it says so, with
|
|
7
|
+
* what's next: have it answer new chats, open its page, or make another.
|
|
8
|
+
*/
|
|
9
|
+
import { useId, useState } from "react";
|
|
10
|
+
import { Avatar, Button, Field, Icon, message, Select } from "copilotz/web";
|
|
11
|
+
import { AGENT_ROLES } from "copilotz/plugins/access/contract";
|
|
12
|
+
import { AgentFields } from "./agent-fields.js";
|
|
13
|
+
import { agentPath, handleOf, shownAs, usualTools } from "./agents.js";
|
|
14
|
+
import { placeName } from "./places.js";
|
|
15
|
+
import { say } from "./words.js";
|
|
16
|
+
/** A link in a dialog closes it as it's followed: the page it opens is behind. */
|
|
17
|
+
const leaving = (event) => event.currentTarget.closest("dialog")?.close();
|
|
18
|
+
export function NewAgent({ space, known, options, call, from: first, onBack }) {
|
|
19
|
+
const id = useId();
|
|
20
|
+
const offered = options.tools.map((t) => t.name);
|
|
21
|
+
const app = Object.entries(known).filter(([, agent]) => !agent.in);
|
|
22
|
+
const blank = () => ({
|
|
23
|
+
name: "",
|
|
24
|
+
icon: "",
|
|
25
|
+
description: "",
|
|
26
|
+
instructions: "",
|
|
27
|
+
model: options.models[0] ?? "",
|
|
28
|
+
tools: usualTools(known, offered),
|
|
29
|
+
});
|
|
30
|
+
const like = (base) => {
|
|
31
|
+
const agent = known[base];
|
|
32
|
+
const model = typeof agent.model === "string" ? agent.model : undefined;
|
|
33
|
+
return {
|
|
34
|
+
name: "",
|
|
35
|
+
icon: agent.icon ?? "",
|
|
36
|
+
description: agent.description ?? "",
|
|
37
|
+
instructions: agent.instructions,
|
|
38
|
+
model: model && options.models.includes(model) ? model : options.models[0] ?? "",
|
|
39
|
+
tools: (agent.tools ?? []).filter((tool) => offered.includes(tool)),
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
const [from, setFrom] = useState(first && known[first] && !known[first].in ? first : "");
|
|
43
|
+
const [draft, setDraft] = useState(() => from ? like(from) : blank());
|
|
44
|
+
const [role, setRole] = useState("editor");
|
|
45
|
+
const [busy, setBusy] = useState(false);
|
|
46
|
+
const [error, setError] = useState();
|
|
47
|
+
const [made, setMade] = useState();
|
|
48
|
+
const name = draft.name.trim();
|
|
49
|
+
const handle = name ? handleOf(name, (taken) => taken in known) : "";
|
|
50
|
+
const where = placeName(space);
|
|
51
|
+
if (made) {
|
|
52
|
+
return (_jsx(Done, { made: made, space: space, call: call, again: () => {
|
|
53
|
+
setMade(undefined);
|
|
54
|
+
setFrom("");
|
|
55
|
+
setDraft(blank());
|
|
56
|
+
} }));
|
|
57
|
+
}
|
|
58
|
+
return (_jsxs("form", { className: "agent-new", "aria-label": say("newAgentForm"), onSubmit: async (event) => {
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
if (!name || !draft.model || busy)
|
|
61
|
+
return;
|
|
62
|
+
setBusy(true);
|
|
63
|
+
setError(undefined);
|
|
64
|
+
try {
|
|
65
|
+
const { agent } = await call("agent.create", {
|
|
66
|
+
in: space._id,
|
|
67
|
+
name,
|
|
68
|
+
...(draft.description.trim() ? { description: draft.description.trim() } : {}),
|
|
69
|
+
...(draft.instructions.trim() ? { instructions: draft.instructions.trim() } : {}),
|
|
70
|
+
model: draft.model,
|
|
71
|
+
tools: draft.tools,
|
|
72
|
+
...(draft.icon ? { icon: draft.icon } : {}),
|
|
73
|
+
...(from ? { from } : {}),
|
|
74
|
+
});
|
|
75
|
+
await call("member.set", {
|
|
76
|
+
space: space._id,
|
|
77
|
+
member: { kind: "agent", id: agent },
|
|
78
|
+
role,
|
|
79
|
+
});
|
|
80
|
+
setMade({ id: agent, ...shownAs(agent, { name, icon: draft.icon || undefined }), role });
|
|
81
|
+
}
|
|
82
|
+
catch (e) {
|
|
83
|
+
setError(message(e));
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
setBusy(false);
|
|
87
|
+
}
|
|
88
|
+
}, children: [onBack || app.length
|
|
89
|
+
? (_jsxs("div", { className: "agent-new-top", children: [onBack
|
|
90
|
+
? (_jsx(Button, { size: "sm", variant: "ghost", icon: "chevron-left", onClick: onBack, children: say("agentsYouKnow") }))
|
|
91
|
+
: _jsx("span", {}), app.length
|
|
92
|
+
? (_jsxs("label", { className: "agent-new-from", children: [_jsx("span", { children: say("startFrom") }), _jsxs(Select, { size: "sm", value: from, onChange: (event) => {
|
|
93
|
+
const next = event.target.value;
|
|
94
|
+
setFrom(next);
|
|
95
|
+
setDraft((now) => ({ ...(next ? like(next) : blank()), name: now.name }));
|
|
96
|
+
}, children: [_jsx("option", { value: "", children: say("startBlank") }), app.map(([key, agent]) => (_jsx("option", { value: key, children: shownAs(key, agent).name }, key)))] })] }))
|
|
97
|
+
: null] }))
|
|
98
|
+
: null, _jsx(AgentFields, { value: draft, onChange: (patch) => setDraft((now) => ({ ...now, ...patch })), options: options, handle: handle, call: call, autoFocus: true }), _jsx(Field, { label: say("worksInAs", { place: where }), hint: say("belongsHint", {
|
|
99
|
+
lets: AGENT_ROLES.find((r) => r.value === role)?.lets ?? "",
|
|
100
|
+
place: where,
|
|
101
|
+
}), children: (control) => (_jsx(Select, { ...control, value: role, onChange: (event) => setRole(event.target.value), children: AGENT_ROLES.map((r) => _jsx("option", { value: r.value, children: r.label }, r.value)) })) }), _jsxs("div", { className: "agent-new-end", children: [_jsx("p", { id: `${id}-said`, className: "agent-form-note", "aria-live": "polite", children: error ? _jsx("span", { className: "agent-error", role: "alert", children: error }) : null }), _jsx(Button, { type: "submit", variant: "primary", icon: "plus", loading: busy, disabled: !name || !draft.model, "aria-describedby": `${id}-said`, children: name ? say("createNamed", { name }) : say("createAgent") })] })] }));
|
|
102
|
+
}
|
|
103
|
+
/** Made: what it is now, and what's next. */
|
|
104
|
+
function Done({ made, space, call, again }) {
|
|
105
|
+
const [answers, setAnswers] = useState(false);
|
|
106
|
+
const [busy, setBusy] = useState(false);
|
|
107
|
+
const [error, setError] = useState();
|
|
108
|
+
const where = placeName(space);
|
|
109
|
+
return (_jsxs("div", { className: "agent-made", role: "status", children: [_jsxs("span", { className: "agent-made-face", children: [_jsx(Avatar, { name: made.name, kind: "agent", icon: made.icon, size: 48 }), _jsx("span", { className: "agent-made-check", children: _jsx(Icon, { name: "check", size: 12 }) })] }), _jsxs("div", { className: "agent-made-text", children: [_jsx("h3", { children: say("worksNow", { name: made.name, place: where }) }), _jsx("p", { children: error ?? (made.role === "editor"
|
|
110
|
+
? (say.nodes("askHandle", {
|
|
111
|
+
handle: _jsxs("b", { className: "agent-handle", children: ["@", made.id] }),
|
|
112
|
+
}))
|
|
113
|
+
: say("readsOnly")) }), _jsxs("div", { className: "agent-made-actions", children: [made.role === "editor"
|
|
114
|
+
? (_jsx(Button, { size: "sm", icon: answers ? "check" : "chat", loading: busy, disabled: answers, onClick: async () => {
|
|
115
|
+
setBusy(true);
|
|
116
|
+
setError(undefined);
|
|
117
|
+
try {
|
|
118
|
+
await call("space.agent", { space: space._id, agent: made.id });
|
|
119
|
+
setAnswers(true);
|
|
120
|
+
}
|
|
121
|
+
catch (e) {
|
|
122
|
+
setError(message(e));
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
setBusy(false);
|
|
126
|
+
}
|
|
127
|
+
}, children: answers ? say("answersNewChats") : say("makeAnswer") }))
|
|
128
|
+
: null, _jsx(Button, { size: "sm", href: agentPath(made.id), onClick: leaving, children: say("openPage") }), _jsx(Button, { size: "sm", variant: "ghost", icon: "plus", onClick: again, children: say("makeAnother") })] })] })] }));
|
|
129
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What agents offer in the command palette (kind `agent.palette`, the web
|
|
3
|
+
* shell's `palette` resource), for where the person is and what's typed:
|
|
4
|
+
*
|
|
5
|
+
* - **This agent**, on an agent's page: ask it, have it answer new chats
|
|
6
|
+
* where the person is, add it to another space they manage, change it
|
|
7
|
+
* or delete it (those who manage where it belongs).
|
|
8
|
+
* - **This space:** add an agent to it (the invite surface's Agents, in a
|
|
9
|
+
* dialog), for those who manage it; while searching, have one of its
|
|
10
|
+
* agents answer its new chats.
|
|
11
|
+
* - **Agents** to go to (their pages): those working where the person is;
|
|
12
|
+
* while searching, every agent they've met.
|
|
13
|
+
* - **Create:** a new agent, where they are if they manage it, or in a
|
|
14
|
+
* space they pick.
|
|
15
|
+
*/
|
|
16
|
+
import type { ReactNode } from "react";
|
|
17
|
+
import type { ViewContext } from "copilotz";
|
|
18
|
+
import { type PaletteGroup } from "copilotz/web";
|
|
19
|
+
export declare const agentPaletteView: (_: unknown, ctx: ViewContext<ReactNode>) => PaletteGroup[] | null;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Avatar, go } from "copilotz/web";
|
|
3
|
+
import { deleteStep, spaceStep } from "./agent-steps.js";
|
|
4
|
+
import { agentPath, shownAs } from "./agents.js";
|
|
5
|
+
import { managed, manages, placeName, placePath } from "./places.js";
|
|
6
|
+
import { say } from "./words.js";
|
|
7
|
+
/** How many agents show with nothing typed, and while searching. */
|
|
8
|
+
const SHOWN = { idle: 4, searching: 8 };
|
|
9
|
+
export const agentPaletteView = (_, ctx) => {
|
|
10
|
+
const searching = !!String(ctx.hints.search ?? "").trim();
|
|
11
|
+
const space = typeof ctx.hints.in === "string" ? ctx.hints.in : undefined;
|
|
12
|
+
const page = (ctx.hints.page ?? {});
|
|
13
|
+
const open = page.kind === "agent" ? page.id : undefined;
|
|
14
|
+
const places = ctx.db.collection("space").query("reached", {}).value;
|
|
15
|
+
const known = ctx.db.collection("agent").query("known", {}).value;
|
|
16
|
+
const roster = space
|
|
17
|
+
? ctx.db.collection("thread").query("agents", { in: space }).value
|
|
18
|
+
: { here: [], default: [], agents: {} };
|
|
19
|
+
const seats = open
|
|
20
|
+
? ctx.db.collection("member").find({ member: `agent:${open}` }).value
|
|
21
|
+
: [];
|
|
22
|
+
if (!places || !known || !roster || !seats)
|
|
23
|
+
return null;
|
|
24
|
+
const call = ctx.call;
|
|
25
|
+
const here = places.find((p) => p._id === space);
|
|
26
|
+
const mine = managed(places);
|
|
27
|
+
const groups = [];
|
|
28
|
+
const leading = (id, agent) => {
|
|
29
|
+
const { name, icon } = shownAs(id, agent);
|
|
30
|
+
return _jsx(Avatar, { name: name, kind: "agent", icon: icon, size: 26 });
|
|
31
|
+
};
|
|
32
|
+
// A new agent in a space: a dialog with its form.
|
|
33
|
+
const make = (place, palette, from) => palette.dialog({
|
|
34
|
+
title: say("newAgentIn", { place: placeName(place) }),
|
|
35
|
+
...(from
|
|
36
|
+
? { description: say("startingFrom", { name: shownAs(from, known[from]).name }) }
|
|
37
|
+
: {}),
|
|
38
|
+
view: "agent.add",
|
|
39
|
+
item: { _id: place._id },
|
|
40
|
+
hints: { in: place._id, mode: "new", ...(from ? { from } : {}) },
|
|
41
|
+
});
|
|
42
|
+
if (open && known[open]) {
|
|
43
|
+
const agent = known[open];
|
|
44
|
+
const { name } = shownAs(open, agent);
|
|
45
|
+
const home = agent.in ? places.find((p) => p._id === agent.in) : undefined;
|
|
46
|
+
const working = seats.filter((s) => !s.on);
|
|
47
|
+
const seatHere = here && working.find((s) => s.space === here._id);
|
|
48
|
+
const elsewhere = mine.filter((p) => !working.some((s) => s.space === p._id));
|
|
49
|
+
const items = [];
|
|
50
|
+
if (here && seatHere?.role === "editor" && manages(here) && here.agent !== open) {
|
|
51
|
+
items.push({
|
|
52
|
+
key: "agent:answers",
|
|
53
|
+
label: say("makeNamedAnswerIn", { name, place: placeName(here) }),
|
|
54
|
+
icon: "chat",
|
|
55
|
+
keywords: [say("keywordDefault"), say("keywordAnswer"), say("keywordNewChats")],
|
|
56
|
+
run: () => call("space.agent", { space: here._id, agent: open }),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (elsewhere.length) {
|
|
60
|
+
items.push({
|
|
61
|
+
key: "agent:add-to",
|
|
62
|
+
label: say("addNamedTo", { name }),
|
|
63
|
+
icon: "plus",
|
|
64
|
+
keywords: [say("keywordMember"), say("keywordJoin"), say("keywordWork")],
|
|
65
|
+
step: spaceStep({
|
|
66
|
+
title: say("addToTitle", { name }),
|
|
67
|
+
note: say("addNamedNote"),
|
|
68
|
+
places: elsewhere,
|
|
69
|
+
pick: (place) => call("member.set", {
|
|
70
|
+
space: place._id,
|
|
71
|
+
member: { kind: "agent", id: open },
|
|
72
|
+
role: "editor",
|
|
73
|
+
}),
|
|
74
|
+
}),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
if (home && manages(home)) {
|
|
78
|
+
items.push({
|
|
79
|
+
key: "agent:edit",
|
|
80
|
+
label: say("editNamed", { name }),
|
|
81
|
+
icon: "pencil",
|
|
82
|
+
keywords: [say("keywordChange"), say("keywordInstructions"), say("keywordRename")],
|
|
83
|
+
href: agentPath(open, true),
|
|
84
|
+
});
|
|
85
|
+
items.push({
|
|
86
|
+
key: "agent:delete",
|
|
87
|
+
label: say("deleteMenu", { name }),
|
|
88
|
+
icon: "trash",
|
|
89
|
+
tone: "destructive",
|
|
90
|
+
step: deleteStep({
|
|
91
|
+
agent: open,
|
|
92
|
+
name,
|
|
93
|
+
call,
|
|
94
|
+
after: () => go(placePath(home._id, "members")),
|
|
95
|
+
}),
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (!agent.in && mine.length) {
|
|
99
|
+
items.push({
|
|
100
|
+
key: "agent:from",
|
|
101
|
+
label: say("startNewFrom", { name }),
|
|
102
|
+
icon: "sparkles",
|
|
103
|
+
keywords: [say("keywordCopy"), say("keywordLike"), say("keywordCreate")],
|
|
104
|
+
step: spaceStep({
|
|
105
|
+
title: say("newLikeTitle", { name }),
|
|
106
|
+
places: mine,
|
|
107
|
+
pick: (place, palette) => make(place, palette, open),
|
|
108
|
+
}),
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (items.length)
|
|
112
|
+
groups.push({ title: say("paletteThisAgent"), order: 10, items });
|
|
113
|
+
}
|
|
114
|
+
if (here && manages(here) && !here.archived && !open) {
|
|
115
|
+
const name = placeName(here);
|
|
116
|
+
const items = [{
|
|
117
|
+
key: "agent:add",
|
|
118
|
+
label: say("addAnAgentTo", { place: name }),
|
|
119
|
+
icon: "bot",
|
|
120
|
+
keywords: [say("keywordMember"), say("keywordInvite"), say("keywordAgent")],
|
|
121
|
+
run: (palette) => palette.dialog({
|
|
122
|
+
title: say("addAnAgentTitle", { place: name }),
|
|
123
|
+
description: say("addAnAgentNote"),
|
|
124
|
+
view: "agent.add",
|
|
125
|
+
item: { _id: here._id },
|
|
126
|
+
hints: { in: here._id },
|
|
127
|
+
}),
|
|
128
|
+
}];
|
|
129
|
+
if (searching) {
|
|
130
|
+
for (const id of roster.here) {
|
|
131
|
+
if (roster.default.includes(id))
|
|
132
|
+
continue;
|
|
133
|
+
const { name: agent } = shownAs(id, roster.agents[id]);
|
|
134
|
+
items.push({
|
|
135
|
+
key: `agent:answers:${id}`,
|
|
136
|
+
label: say("makeNamedAnswer", { name: agent }),
|
|
137
|
+
leading: leading(id, roster.agents[id]),
|
|
138
|
+
description: name,
|
|
139
|
+
keywords: [say("keywordDefault"), say("keywordAnswer"), id],
|
|
140
|
+
run: () => call("space.agent", { space: here._id, agent: id }),
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
groups.push({ title: say("paletteThisSpace"), order: 10, items });
|
|
145
|
+
}
|
|
146
|
+
// Agents to go to: those here first (who answers new chats first), then, searching, all met.
|
|
147
|
+
const ids = [
|
|
148
|
+
...roster.here,
|
|
149
|
+
...(searching ? Object.keys(known).filter((id) => !roster.here.includes(id)) : []),
|
|
150
|
+
].filter((id) => id !== open);
|
|
151
|
+
groups.push({
|
|
152
|
+
title: say("paletteAgents"),
|
|
153
|
+
order: 25,
|
|
154
|
+
limit: searching ? SHOWN.searching : SHOWN.idle,
|
|
155
|
+
items: ids.map((id) => {
|
|
156
|
+
const agent = roster.agents[id] ?? known[id];
|
|
157
|
+
const { name } = shownAs(id, agent);
|
|
158
|
+
return {
|
|
159
|
+
key: `agent:${id}`,
|
|
160
|
+
label: name,
|
|
161
|
+
leading: leading(id, agent),
|
|
162
|
+
description: roster.default.includes(id)
|
|
163
|
+
? say("answersNewChatsHere")
|
|
164
|
+
: roster.here.includes(id)
|
|
165
|
+
? say("worksHere", { id })
|
|
166
|
+
: `@${id}`,
|
|
167
|
+
keywords: [id, agent?.description ?? "", say("keywordAgent")].filter(Boolean),
|
|
168
|
+
href: agentPath(id),
|
|
169
|
+
};
|
|
170
|
+
}),
|
|
171
|
+
});
|
|
172
|
+
if (mine.length) {
|
|
173
|
+
const inHere = here && manages(here) && !here.archived ? here : undefined;
|
|
174
|
+
groups.push({
|
|
175
|
+
title: say("paletteCreate"),
|
|
176
|
+
order: 40,
|
|
177
|
+
items: [
|
|
178
|
+
inHere
|
|
179
|
+
? {
|
|
180
|
+
key: "agent:new",
|
|
181
|
+
label: say("newAgent"),
|
|
182
|
+
icon: "bot",
|
|
183
|
+
description: say("newAgentInHere", { place: placeName(inHere) }),
|
|
184
|
+
keywords: [say("keywordCreate"), say("keywordMake"), say("keywordAgent")],
|
|
185
|
+
run: (palette) => make(inHere, palette),
|
|
186
|
+
}
|
|
187
|
+
: {
|
|
188
|
+
key: "agent:new",
|
|
189
|
+
label: say("newAgentInStep"),
|
|
190
|
+
icon: "bot",
|
|
191
|
+
keywords: [say("keywordCreate"), say("keywordMake"), say("keywordAgent")],
|
|
192
|
+
step: spaceStep({
|
|
193
|
+
title: say("newAgentInStep"),
|
|
194
|
+
note: say("newAgentInNote"),
|
|
195
|
+
places: mine,
|
|
196
|
+
pick: (place, palette) => make(place, palette),
|
|
197
|
+
}),
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
return groups;
|
|
203
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agents' steps in the command palette: picking one of the spaces the
|
|
3
|
+
* person manages (to add an agent there, or make one there), and deleting
|
|
4
|
+
* an agent, a question that says what it means before it's done.
|
|
5
|
+
*/
|
|
6
|
+
import { type PaletteControl, type PaletteStep } from "copilotz/web";
|
|
7
|
+
import { type Place } from "./places.js";
|
|
8
|
+
type Call = <R = unknown>(action: string, input?: unknown) => Promise<R>;
|
|
9
|
+
/** A space they manage, picked: what happens there is `pick`'s. */
|
|
10
|
+
export declare function spaceStep({ title, note, places, pick }: {
|
|
11
|
+
title: string;
|
|
12
|
+
note?: string;
|
|
13
|
+
places: Place[];
|
|
14
|
+
pick(place: Place, palette: PaletteControl): unknown;
|
|
15
|
+
}): PaletteStep;
|
|
16
|
+
/** Deleting an agent, once they've read what it means; then `after`. */
|
|
17
|
+
export declare function deleteStep({ agent, name, call, after }: {
|
|
18
|
+
agent: string;
|
|
19
|
+
name: string;
|
|
20
|
+
call: Call;
|
|
21
|
+
after(): void;
|
|
22
|
+
}): PaletteStep;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Agents' steps in the command palette: picking one of the spaces the
|
|
4
|
+
* person manages (to add an agent there, or make one there), and deleting
|
|
5
|
+
* an agent, a question that says what it means before it's done.
|
|
6
|
+
*/
|
|
7
|
+
import { Avatar } from "copilotz/web";
|
|
8
|
+
import { placeName } from "./places.js";
|
|
9
|
+
import { say } from "./words.js";
|
|
10
|
+
/** A space they manage, picked: what happens there is `pick`'s. */
|
|
11
|
+
export function spaceStep({ title, note, places, pick }) {
|
|
12
|
+
return {
|
|
13
|
+
title,
|
|
14
|
+
placeholder: say("findSpace"),
|
|
15
|
+
...(note ? { note } : {}),
|
|
16
|
+
items: () => [{
|
|
17
|
+
title: say("spacesYouManage"),
|
|
18
|
+
items: places.map((place) => ({
|
|
19
|
+
key: `agent-space:${place._id}`,
|
|
20
|
+
label: placeName(place),
|
|
21
|
+
...(place.kind === "personal"
|
|
22
|
+
? {
|
|
23
|
+
icon: "person",
|
|
24
|
+
description: say("justYou"),
|
|
25
|
+
keywords: [say("keywordPersonal")],
|
|
26
|
+
}
|
|
27
|
+
: { leading: _jsx(Avatar, { name: place.name, kind: "space", size: 26 }) }),
|
|
28
|
+
run: (palette) => pick(place, palette),
|
|
29
|
+
})),
|
|
30
|
+
}],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Deleting an agent, once they've read what it means; then `after`. */
|
|
34
|
+
export function deleteStep({ agent, name, call, after }) {
|
|
35
|
+
return {
|
|
36
|
+
title: say("deleteTitle", { name }),
|
|
37
|
+
confirm: true,
|
|
38
|
+
note: say("deleteStepNote"),
|
|
39
|
+
items: () => [{
|
|
40
|
+
title: "",
|
|
41
|
+
items: [
|
|
42
|
+
{
|
|
43
|
+
key: "agent:delete",
|
|
44
|
+
label: say("deleteButton", { name }),
|
|
45
|
+
icon: "trash",
|
|
46
|
+
tone: "destructive",
|
|
47
|
+
run: async () => {
|
|
48
|
+
await call("agent.delete", { agent });
|
|
49
|
+
after();
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
{ key: "agent:keep", label: say("deleteStepKeep"), icon: "close", run: (p) => p.back() },
|
|
53
|
+
],
|
|
54
|
+
}],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An agent's page (kind `agent`, at `/agent/<id>`): who it is (its emoji,
|
|
3
|
+
* its name and what it's called by, what it does, where it belongs), where
|
|
4
|
+
* it works among the person's spaces (its role there, and where it answers
|
|
5
|
+
* new chats), and what it's told: its instructions, model and tools. "Ask"
|
|
6
|
+
* starts a chat where it works, `@name` ready. Those who manage where it
|
|
7
|
+
* belongs change it in place (`?edit=1` opens it so) and delete it, after
|
|
8
|
+
* a question that says it leaves every space it works in. The app's own
|
|
9
|
+
* agents are read only; a manager starts a new agent from one. Its menu
|
|
10
|
+
* adds it to another space they manage, and has it answer new chats where
|
|
11
|
+
* the person is.
|
|
12
|
+
*/
|
|
13
|
+
import { type ReactNode } from "react";
|
|
14
|
+
import type { ViewContext } from "copilotz";
|
|
15
|
+
export declare const agentView: (item: {
|
|
16
|
+
_id?: string;
|
|
17
|
+
}, ctx: ViewContext<ReactNode>) => ReactNode;
|