@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.
Files changed (74) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +49 -2
  3. package/WORDS.md +200 -0
  4. package/contract.d.ts +8 -0
  5. package/contract.js +8 -0
  6. package/mod.d.ts +25 -0
  7. package/mod.js +25 -0
  8. package/package.json +63 -4
  9. package/team/actions/agent.d.ts +4 -0
  10. package/team/actions/agent.js +179 -0
  11. package/team/actions/define.d.ts +1 -0
  12. package/team/actions/define.js +27 -0
  13. package/team/collections/agent.d.ts +132 -0
  14. package/team/collections/agent.js +75 -0
  15. package/team/contract.d.ts +10 -0
  16. package/team/contract.js +1 -0
  17. package/team/mod.d.ts +21 -0
  18. package/team/mod.js +49 -0
  19. package/team/shared/definition.d.ts +3 -0
  20. package/team/shared/definition.js +10 -0
  21. package/team/views/web/agent-add.d.ts +14 -0
  22. package/team/views/web/agent-add.js +48 -0
  23. package/team/views/web/agent-fields.d.ts +33 -0
  24. package/team/views/web/agent-fields.js +88 -0
  25. package/team/views/web/agent-known.d.ts +22 -0
  26. package/team/views/web/agent-known.js +61 -0
  27. package/team/views/web/agent-new.d.ts +24 -0
  28. package/team/views/web/agent-new.js +129 -0
  29. package/team/views/web/agent-palette.d.ts +19 -0
  30. package/team/views/web/agent-palette.js +203 -0
  31. package/team/views/web/agent-steps.d.ts +23 -0
  32. package/team/views/web/agent-steps.js +56 -0
  33. package/team/views/web/agent.d.ts +17 -0
  34. package/team/views/web/agent.js +257 -0
  35. package/team/views/web/agents.d.ts +48 -0
  36. package/team/views/web/agents.js +59 -0
  37. package/team/views/web/model-pick.d.ts +25 -0
  38. package/team/views/web/model-pick.js +39 -0
  39. package/team/views/web/model-picker.d.ts +57 -0
  40. package/team/views/web/model-picker.js +218 -0
  41. package/team/views/web/places.d.ts +24 -0
  42. package/team/views/web/places.js +10 -0
  43. package/team/views/web/style.d.ts +9 -0
  44. package/team/views/web/style.js +246 -0
  45. package/team/views/web/words.d.ts +5 -0
  46. package/team/views/web/words.js +211 -0
  47. package/team/web.d.ts +22 -0
  48. package/team/web.js +41 -0
  49. package/tiers/actions/choose.d.ts +2 -0
  50. package/tiers/actions/choose.js +98 -0
  51. package/tiers/actions/model.d.ts +1 -0
  52. package/tiers/actions/model.js +36 -0
  53. package/tiers/collections/choice.d.ts +48 -0
  54. package/tiers/collections/choice.js +59 -0
  55. package/tiers/contract.d.ts +19 -0
  56. package/tiers/contract.js +1 -0
  57. package/tiers/mod.d.ts +54 -0
  58. package/tiers/mod.js +92 -0
  59. package/tiers/shared/shown.d.ts +87 -0
  60. package/tiers/shared/shown.js +155 -0
  61. package/tiers/shared/tiers.d.ts +103 -0
  62. package/tiers/shared/tiers.js +129 -0
  63. package/tiers/views/web/org.d.ts +38 -0
  64. package/tiers/views/web/org.js +142 -0
  65. package/tiers/views/web/space.d.ts +43 -0
  66. package/tiers/views/web/space.js +103 -0
  67. package/tiers/views/web/style.d.ts +7 -0
  68. package/tiers/views/web/style.js +87 -0
  69. package/tiers/views/web/words.d.ts +21 -0
  70. package/tiers/views/web/words.js +49 -0
  71. package/tiers/web.d.ts +18 -0
  72. package/tiers/web.js +40 -0
  73. package/web.d.ts +14 -0
  74. package/web.js +14 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Copilotz Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,50 @@
1
- # Temporary Holding Version
1
+ # @copilotz/team
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Agents people make, and the models an org's agents think with, for
4
+ [Copilotz](https://github.com/copilotzhq/copilotz): two plugins beside its `chat`, whose agents are
5
+ the app's own, in its code.
6
+
7
+ ```sh
8
+ npm install @copilotz/team copilotz # Node 24+, Bun
9
+ deno add jsr:@copilotz/team jsr:@copilotz/copilotz
10
+ ```
11
+
12
+ It goes with Copilotz at the same version (they're released together): `@copilotz/team@x.y.z` with
13
+ `copilotz@x.y.z`.
14
+
15
+ ```ts
16
+ import { team, tiers } from "@copilotz/team";
17
+
18
+ const runtime = await createRuntime({
19
+ store,
20
+ plugins: [models, chat, ...access, team, tiers, app],
21
+ });
22
+ ```
23
+
24
+ ```ts
25
+ // In the browser, beside the web shell's and spaces' front ends:
26
+ import { teamWeb, tiersWeb } from "@copilotz/team/web";
27
+ ```
28
+
29
+ | Import | What it has |
30
+ | ------------------------- | ----------------------------------------------------------------------------- |
31
+ | `@copilotz/team` | `team`, `tiers` |
32
+ | `@copilotz/team/web` | `teamWeb` (an agent's page, making one, adding one to a space), `tiersWeb` |
33
+ | `@copilotz/team/contract` | their shapes (`AgentDoc`, `ModelPick`, `Tier`, `Shown`…), for plugins on them |
34
+
35
+ - **`team`**: agents people make where they belong (a space), with their instructions, tools and
36
+ model, added to other spaces by those who've met them, changed only by who manage the space they
37
+ belong to; removed, one leaves every space it worked in. Its collection is `agent`; chat asks it
38
+ what an agent not in the app's code is (the `agentSources` resource).
39
+ - **`tiers`**: which model each of the app's agents thinks with, by tier ("Everyday", "Expert"): the
40
+ first that applies of a space's pick, the space's tier, the org's pick, the org's tier and its
41
+ plan's (the `planTier` resource, which `@copilotz/billing`'s credits fill). Its collection is
42
+ `modelChoice`; chat asks it through the `agentModel` resource.
43
+
44
+ Its front end's words are `team.<key>`: see
45
+ [WORDS.md](https://github.com/copilotzhq/copilotz/blob/main/packages/team/WORDS.md).
46
+
47
+ Through 1.0.0-rc.32 these were `team` and `tiers` in `copilotz/plugins/agents`, and `teamWeb` and
48
+ `tiersWeb` in `copilotz/plugins/agents/web`. Their names (collections, Actions, events, Views,
49
+ resources) are the same, so an app's data stays as it is: only its imports change. See
50
+ [design/plugins.md](https://github.com/copilotzhq/copilotz/blob/main/design/plugins.md).
package/WORDS.md ADDED
@@ -0,0 +1,200 @@
1
+ # @copilotz/team's words
2
+
3
+ Every word team's and tiers' web front ends show, by key, with its English. An app changes any
4
+ of them with a `words` resource (see Copilotz's README, "Words"). `{name}` is a blank; a phrase
5
+ in braces `{one, other}` has plural forms, chosen by the `{count}` blank.
6
+
7
+ Generated: `deno run -A packages/team/tests/words.ts`.
8
+
9
+
10
+ ## team
11
+
12
+ | Key | English |
13
+ |---|---|
14
+ | `team.add` | Add |
15
+ | `team.addAgentTo` | Add {name} to {place} |
16
+ | `team.addAnAgentNote` | Agents work for whoever asks them, and reach only what that person can. |
17
+ | `team.addAnAgentTitle` | Add an agent to {place} |
18
+ | `team.addAnAgentTo` | Add an agent to {place}… |
19
+ | `team.addNamedNote` | It works there at once, as an editor. |
20
+ | `team.addNamedTo` | Add {name} to a space… |
21
+ | `team.addsAs` | Adds as |
22
+ | `team.addToNote` | It works there at once, as an editor: it answers chats there and adds to them. |
23
+ | `team.addToSpace` | Add to a space |
24
+ | `team.addToSpaceMenu` | Add to a space… |
25
+ | `team.addToTitle` | Add {name} to… |
26
+ | `team.agentsYouKnow` | Agents you know |
27
+ | `team.allProviders` | All providers |
28
+ | `team.allWorkHere` | Every agent you know works in {place} already. |
29
+ | `team.anotherEmoji` | Another emoji |
30
+ | `team.answersNewChats` | Answers new chats |
31
+ | `team.answersNewChatsHere` | Answers new chats here |
32
+ | `team.apiKeyLabel` | Your {provider} API key |
33
+ | `team.appAgentNotice` | Part of the app: it's set up in code, so it isn't changed here. To have one of your own like it, start a new agent from it. |
34
+ | `team.archivedSpace` | {place} is archived: restore it to add agents. |
35
+ | `team.askAgent` | Ask {name} |
36
+ | `team.askHandle` | Ask {handle} in any chat here. |
37
+ | `team.belongsHint` | {lets}. It belongs to {place}: those who manage it change it. |
38
+ | `team.calledIn` | Called {handle} in chats |
39
+ | `team.cancel` | Cancel |
40
+ | `team.change` | Change |
41
+ | `team.changeAgent` | Change {name} |
42
+ | `team.chooseModel` | Choose a model |
43
+ | `team.contextSize` | {size} context |
44
+ | `team.createAgent` | Create agent |
45
+ | `team.createNamed` | Create {name} |
46
+ | `team.createNewAgent` | Create a new agent |
47
+ | `team.createNewAgentBody` | Say what it should do; it can write its own instructions. |
48
+ | `team.deleteButton` | Delete {name} |
49
+ | `team.deleteChats` | {bold} with what it said. |
50
+ | `team.deleteChatsBold` | Chats it was in stay as they are, |
51
+ | `team.deleteGone` | {bold} and it can't be brought back. |
52
+ | `team.deleteGoneBold` | Nobody can ask it anything again, |
53
+ | `team.deleteLeaves` | {bold}. Where it answered new chats, another agent there does. |
54
+ | `team.deleteLeavesBold` | It leaves every space it works in |
55
+ | `team.deleteLeavesNamed` | {bold}, {spaces} among them. Where it answered new chats, another agent there does. |
56
+ | `team.deleteMenu` | Delete {name}… |
57
+ | `team.deleteStepKeep` | Keep it |
58
+ | `team.deleteStepNote` | It leaves every space it works in, and nobody can ask it anything again. Chats it was in stay as they are. |
59
+ | `team.deleteTitle` | Delete {name}? |
60
+ | `team.doesHint` | A line or two, for people, and for other agents deciding whom to ask. |
61
+ | `team.doesPlaceholder` | Writes launch copy in our voice, and checks facts with the researcher. |
62
+ | `team.draftNote` | Written for you from what it should do: read them through, and change what you like. |
63
+ | `team.edit` | Edit |
64
+ | `team.editAgent` | Edit {name} |
65
+ | `team.editNamed` | Edit {name} |
66
+ | `team.effort` | {effort} effort |
67
+ | `team.emoji` | Emoji |
68
+ | `team.fieldDoes` | What should it do? |
69
+ | `team.fieldName` | Name |
70
+ | `team.findAgent` | Find an agent |
71
+ | `team.findAgentKnown` | Find an agent you know |
72
+ | `team.findSpace` | Find a space |
73
+ | `team.goHome` | Go home |
74
+ | `team.instructions` | Instructions |
75
+ | `team.instructionsEmptyHint` | Say its name and what it should do, and it can write them for you. |
76
+ | `team.instructionsHint` | What it's told every time it works: who it is, what it does, and how it answers. |
77
+ | `team.justYou` | Just you |
78
+ | `team.keepsHandle` | It keeps its name in chats, @{handle}, whatever it's shown as. |
79
+ | `team.keyNote` | Encrypted, and never shown again. All of this org's agents use it for {provider}, and {provider} charges your account. |
80
+ | `team.keywordAgent` | agent |
81
+ | `team.keywordAnswer` | answer |
82
+ | `team.keywordChange` | change |
83
+ | `team.keywordCopy` | copy |
84
+ | `team.keywordCreate` | create |
85
+ | `team.keywordDefault` | default |
86
+ | `team.keywordInstructions` | instructions |
87
+ | `team.keywordInvite` | invite |
88
+ | `team.keywordJoin` | join |
89
+ | `team.keywordLike` | like |
90
+ | `team.keywordMake` | make |
91
+ | `team.keywordMember` | member |
92
+ | `team.keywordNewChats` | new chats |
93
+ | `team.keywordPersonal` | personal |
94
+ | `team.keywordRename` | rename |
95
+ | `team.keywordWork` | work |
96
+ | `team.knownIntro` | Agents you know, from the app and your spaces |
97
+ | `team.listEnd` | {rest} and {last} |
98
+ | `team.listJoin` | , |
99
+ | `team.madeElsewhere` | Made elsewhere |
100
+ | `team.madeIn` | Made in {place} |
101
+ | `team.madeInOther` | Made in another space |
102
+ | `team.makeAnother` | Make another |
103
+ | `team.makeAnswer` | Make it answer new chats |
104
+ | `team.makeAnswerIn` | Make it answer new chats in {place} |
105
+ | `team.makeNamedAnswer` | Make {name} answer new chats |
106
+ | `team.makeNamedAnswerIn` | Make {name} answer new chats in {place} |
107
+ | `team.managersAdd` | Those who manage {place} add agents to it. |
108
+ | `team.managersChangeIt` | Those who manage {place} change it. |
109
+ | `team.managersChangeItElsewhere` | Those who manage the space it belongs to change it. |
110
+ | `team.mediaAudio` | Audio |
111
+ | `team.mediaImage` | Images |
112
+ | `team.mediaPdf` | PDFs |
113
+ | `team.mediaVideo` | Video |
114
+ | `team.model` | Model |
115
+ | `team.modelAndTools` | Model and tools |
116
+ | `team.modelHint` | What it thinks with. |
117
+ | `team.models` | Models |
118
+ | `team.modelsThenJoin` | , then |
119
+ | `team.moreMenu` | {name}: more |
120
+ | `team.nameHint` | What people call it: Maya is @maya in chats. |
121
+ | `team.namePlaceholder` | Maya |
122
+ | `team.needsKey` | Needs a key |
123
+ | `team.newAgent` | New agent… |
124
+ | `team.newAgentForm` | A new agent |
125
+ | `team.newAgentIn` | New agent in {place} |
126
+ | `team.newAgentInHere` | In {place} |
127
+ | `team.newAgentInNote` | It belongs to the space you pick: those who manage it change it. |
128
+ | `team.newAgentInStep` | New agent in… |
129
+ | `team.newLikeNote` | It starts with its words, model and tools; it belongs to the space you pick. |
130
+ | `team.newLikeTitle` | New agent like {name}, in… |
131
+ | `team.noCreditsUsed` | No credits used |
132
+ | `team.noEmoji` | None: its initial |
133
+ | `team.noKeyForProvider` | This org has no key for {provider}. Its owners and admins can add one. |
134
+ | `team.noneCalled` | No agent you know is called “{search}”. |
135
+ | `team.noSuchAgent` | No agent here by that name |
136
+ | `team.noSuchAgentBody` | It may have been deleted, or it works only in spaces you're not in. |
137
+ | `team.noSuchAgentTitle` | No such agent |
138
+ | `team.nothingMatches` | Nothing matches that. |
139
+ | `team.noTools` | None: it only talks. |
140
+ | `team.notYourSpace` | This space isn't one of yours. |
141
+ | `team.oneOfApps` | One of the app's agents |
142
+ | `team.openPage` | Open its page |
143
+ | `team.orgKey` | This org's key {hint} |
144
+ | `team.otherEmoji` | Other |
145
+ | `team.paletteAgents` | Agents |
146
+ | `team.paletteCreate` | Create |
147
+ | `team.paletteThisAgent` | This agent |
148
+ | `team.paletteThisSpace` | This space |
149
+ | `team.partOfApp` | Part of the app |
150
+ | `team.pasteIt` | Paste it here |
151
+ | `team.personalSpace` | Personal |
152
+ | `team.priceLine` | {input} in · {output} out per 1M tokens |
153
+ | `team.priceOwnKey` | No credits used: your key, at {price} |
154
+ | `team.providerModels` | one: {count} model / other: {count} models |
155
+ | `team.providers` | Providers |
156
+ | `team.readsOnly` | It reads what's here for chats where it's an editor; it doesn't answer here. |
157
+ | `team.readyToUse` | Ready to use |
158
+ | `team.reasoning` | Reasoning |
159
+ | `team.remove` | Remove |
160
+ | `team.replace` | Replace |
161
+ | `team.rewriteForMe` | Rewrite them for me |
162
+ | `team.roleEditor` | Editor |
163
+ | `team.roleViewer` | Viewer |
164
+ | `team.save` | Save |
165
+ | `team.saveChanges` | Save changes |
166
+ | `team.sayNameFirst` | Say its name and what it should do first |
167
+ | `team.searchModels` | Search providers and models |
168
+ | `team.showAll` | Show all {count} |
169
+ | `team.showFewer` | Show fewer |
170
+ | `team.spacesYouManage` | Spaces you manage |
171
+ | `team.startBlank` | Nothing: a blank agent |
172
+ | `team.startFrom` | Start from |
173
+ | `team.startFromIt` | Start a new agent from it… |
174
+ | `team.startFromShort` | Start from it |
175
+ | `team.startingFrom` | Starting from {name}. |
176
+ | `team.startNewFrom` | Start a new agent from {name}… |
177
+ | `team.thinks` | Thinks |
178
+ | `team.tools` | Tools |
179
+ | `team.toolsAll` | All |
180
+ | `team.toolsChoose` | Choose |
181
+ | `team.toolsChooseDone` | Done |
182
+ | `team.toolsLabel` | Tools {count} |
183
+ | `team.toolsMore` | +{count} more |
184
+ | `team.toolsNone` | None |
185
+ | `team.toolsOf` | {chosen} of {offered} |
186
+ | `team.undo` | Undo |
187
+ | `team.useOwnKey` | Use your own key |
188
+ | `team.usesAppKey` | Uses the app's key |
189
+ | `team.withOwnKey` | With your own key |
190
+ | `team.worksHere` | @{id} · works here |
191
+ | `team.worksIn` | Works in {count} |
192
+ | `team.worksInAs` | Works in {place} as |
193
+ | `team.worksNow` | {name} works in {place} now |
194
+ | `team.worksNowhere` | It doesn't work in any of your spaces. |
195
+ | `team.worksNowNames` | one: {names} works in {place} now. / other: {names} work in {place} now. |
196
+ | `team.writeForMe` | Write them for me |
197
+ | `team.writingFor` | Writing {name}'s instructions… |
198
+ | `team.youAreDefaultName` | Maya |
199
+ | `team.youArePlaceholder` | You are {name}. You… |
200
+ | `team.yourKey` | Your key |
package/contract.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Team's contract (`@copilotz/team/contract`): team's and tiers', the shapes
3
+ * of an agent people made, a model pick, a tier and what a page shows of it,
4
+ * for plugins built on them. The rest is reached by name, through the
5
+ * runtime (`agent.create`, `tiers.choose`…).
6
+ */
7
+ export * from "./team/contract.js";
8
+ export * from "./tiers/contract.js";
package/contract.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Team's contract (`@copilotz/team/contract`): team's and tiers', the shapes
3
+ * of an agent people made, a model pick, a tier and what a page shows of it,
4
+ * for plugins built on them. The rest is reached by name, through the
5
+ * runtime (`agent.create`, `tiers.choose`…).
6
+ */
7
+ export * from "./team/contract.js";
8
+ export * from "./tiers/contract.js";
package/mod.d.ts ADDED
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Team (`@copilotz/team`): agents people make, and the models the app's
3
+ * agents think with, as an org and its spaces choose them. Two plugins
4
+ * beside Copilotz's `chat` (whose agents are the app's, in its code):
5
+ *
6
+ * - `team`: agents people make where they belong (a space), with their
7
+ * instructions, tools and model, added to other spaces by those who met
8
+ * them, changed only by who manage the space they belong to. Chat asks it
9
+ * what an agent not in the app's code is (`agentSources`).
10
+ * - `tiers`: which model each of the app's agents thinks with, by tier
11
+ * ("Everyday", "Expert"), the first that applies of a space's pick, the
12
+ * space's tier, the org's pick, the org's tier and its plan's (the
13
+ * `planTier` resource: `@copilotz/billing`'s credits fill it).
14
+ *
15
+ * ```ts
16
+ * import { team, tiers } from "@copilotz/team";
17
+ *
18
+ * plugins: [models, chat, ...access, team, tiers, app]
19
+ * ```
20
+ *
21
+ * Their front ends are `@copilotz/team/web` (`teamWeb`, `tiersWeb`); their
22
+ * shapes, `@copilotz/team/contract`.
23
+ */
24
+ export * from "./team/mod.js";
25
+ export * from "./tiers/mod.js";
package/mod.js ADDED
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Team (`@copilotz/team`): agents people make, and the models the app's
3
+ * agents think with, as an org and its spaces choose them. Two plugins
4
+ * beside Copilotz's `chat` (whose agents are the app's, in its code):
5
+ *
6
+ * - `team`: agents people make where they belong (a space), with their
7
+ * instructions, tools and model, added to other spaces by those who met
8
+ * them, changed only by who manage the space they belong to. Chat asks it
9
+ * what an agent not in the app's code is (`agentSources`).
10
+ * - `tiers`: which model each of the app's agents thinks with, by tier
11
+ * ("Everyday", "Expert"), the first that applies of a space's pick, the
12
+ * space's tier, the org's pick, the org's tier and its plan's (the
13
+ * `planTier` resource: `@copilotz/billing`'s credits fill it).
14
+ *
15
+ * ```ts
16
+ * import { team, tiers } from "@copilotz/team";
17
+ *
18
+ * plugins: [models, chat, ...access, team, tiers, app]
19
+ * ```
20
+ *
21
+ * Their front ends are `@copilotz/team/web` (`teamWeb`, `tiersWeb`); their
22
+ * shapes, `@copilotz/team/contract`.
23
+ */
24
+ export * from "./team/mod.js";
25
+ export * from "./tiers/mod.js";
package/package.json CHANGED
@@ -1,6 +1,65 @@
1
1
  {
2
2
  "name": "@copilotz/team",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0-rc.34",
4
+ "description": "Agents people make, and the models an org's agents think with (tiers). A Copilotz plugin.",
5
+ "keywords": [
6
+ "copilotz",
7
+ "agents",
8
+ "ai",
9
+ "plugin"
10
+ ],
11
+ "homepage": "https://github.com/copilotzhq/copilotz/tree/main/packages/team#readme",
12
+ "bugs": "https://github.com/copilotzhq/copilotz/issues",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/copilotzhq/copilotz.git",
16
+ "directory": "packages/team"
17
+ },
18
+ "license": "MIT",
19
+ "type": "module",
20
+ "engines": {
21
+ "node": ">=24"
22
+ },
23
+ "sideEffects": false,
24
+ "types": "./mod.d.ts",
25
+ "exports": {
26
+ ".": {
27
+ "types": "./mod.d.ts",
28
+ "default": "./mod.js"
29
+ },
30
+ "./web": {
31
+ "types": "./web.d.ts",
32
+ "default": "./web.js"
33
+ },
34
+ "./contract": {
35
+ "types": "./contract.d.ts",
36
+ "default": "./contract.js"
37
+ },
38
+ "./package.json": "./package.json"
39
+ },
40
+ "files": [
41
+ "LICENSE",
42
+ "README.md",
43
+ "WORDS.md",
44
+ "contract.d.ts",
45
+ "contract.js",
46
+ "mod.d.ts",
47
+ "mod.js",
48
+ "team",
49
+ "tiers",
50
+ "web.d.ts",
51
+ "web.js"
52
+ ],
53
+ "dependencies": {},
54
+ "peerDependencies": {
55
+ "@types/react": "^19.3.0",
56
+ "copilotz": "1.0.0-rc.34",
57
+ "react": "^19.3.1",
58
+ "react-dom": "^19.3.1"
59
+ },
60
+ "peerDependenciesMeta": {
61
+ "@types/react": {
62
+ "optional": true
63
+ }
64
+ }
65
+ }
@@ -0,0 +1,4 @@
1
+ export declare const createAgentAction: import("copilotz").ActionDef;
2
+ export declare const updateAgentAction: import("copilotz").ActionDef;
3
+ export declare const deleteAgentAction: import("copilotz").ActionDef;
4
+ export declare const draftAgentAction: import("copilotz").ActionDef;
@@ -0,0 +1,179 @@
1
+ /**
2
+ * Agents people make: `agent.create` makes one where they say (`in`), named
3
+ * after what it's shown as (`Maya` is called `maya`; `maya-2` when that's
4
+ * taken), from the app's tools and models, or from one the app declares
5
+ * (`from`, to start from what it is); `agent.update` changes it,
6
+ * `agent.delete` removes it; `agent.draft` writes instructions from what
7
+ * it should do, for a person to read before making it. Who may make or
8
+ * change one where it belongs is the rules' business (with the access
9
+ * plugin: those who manage that space).
10
+ */
11
+ import { defineAction, inPerson, invalid, people } from "copilotz";
12
+ import { agentsOf, defaults, modelOf, SEND } from "copilotz/plugins/agents/contract";
13
+ const forbidden = (agent) => Object.assign(new Error(`Only those who manage where "${agent}" belongs change it.`), {
14
+ code: "forbidden",
15
+ });
16
+ const fields = {
17
+ name: { type: "string", minLength: 1, maxLength: 60 },
18
+ description: { type: "string", maxLength: 500 },
19
+ instructions: { type: "string", maxLength: 20_000 },
20
+ model: { type: "string", minLength: 1 },
21
+ effort: { type: "string" },
22
+ tools: { type: "array", items: { type: "string" }, maxItems: 64 },
23
+ icon: { type: "string", maxLength: 16 },
24
+ };
25
+ /** The model agents are made with unless someone says: the app's first default agent's. */
26
+ function usualModel(ctx) {
27
+ const declared = agentsOf(ctx);
28
+ const model = declared[defaults(declared)[0]]?.model;
29
+ return typeof model === "string" ? model : undefined;
30
+ }
31
+ /** Throws unless every tool is the app's (or `send_message`) and the model can be called. */
32
+ async function checked(ctx, given) {
33
+ const tools = (ctx.resources.tools ?? {});
34
+ const unknown = (given.tools ?? []).filter((name) => name !== SEND && !tools[name]);
35
+ if (unknown.length)
36
+ throw invalid(`No tool ${unknown.map((t) => `"${t}"`).join(", ")}.`);
37
+ if (given.model) {
38
+ await ctx.call("models.check", {
39
+ model: modelOf({ instructions: "", model: given.model, effort: given.effort }),
40
+ port: "llm",
41
+ }).catch((error) => {
42
+ throw invalid(error.message);
43
+ });
44
+ }
45
+ }
46
+ /** What `name` is called by: lowercase, dashes, unique among agents (`maya`, `maya-2`). */
47
+ async function handleFor(ctx, name) {
48
+ const base = name.normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase()
49
+ .replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 32) || "agent";
50
+ const declared = agentsOf(ctx);
51
+ const made = ctx.as().db.collection("agent");
52
+ for (let n = 1;; n++) {
53
+ const handle = n === 1 ? base : `${base}-${n}`;
54
+ if (!declared[handle] && !await made.findOne({ _id: handle }))
55
+ return handle;
56
+ }
57
+ }
58
+ export const createAgentAction = defineAction({
59
+ description: "Makes an agent, where you say; it's called by a name made from what it's shown as",
60
+ input: {
61
+ type: "object",
62
+ properties: {
63
+ in: { type: "string" },
64
+ /** One the app declares, to start from what it is. */
65
+ from: { type: "string" },
66
+ ...fields,
67
+ },
68
+ required: ["name"],
69
+ additionalProperties: false,
70
+ },
71
+ allow: inPerson,
72
+ run: async (ctx, input) => {
73
+ const base = input.from ? agentsOf(ctx)[input.from] : undefined;
74
+ if (input.from && !base)
75
+ throw invalid(`No agent "${input.from}" to start from.`);
76
+ const model = input.model ??
77
+ (typeof base?.model === "string" ? base.model : undefined) ?? usualModel(ctx);
78
+ if (!model)
79
+ throw invalid("Say which model it uses.");
80
+ const description = input.description ?? base?.description;
81
+ const tools = input.tools ?? base?.tools;
82
+ const effort = input.effort ?? base?.effort;
83
+ await checked(ctx, { ...input, model, tools, effort });
84
+ const agent = await handleFor(ctx, input.name);
85
+ await ctx.db.collection("agent").insertOne({
86
+ _id: agent,
87
+ name: input.name.trim(),
88
+ ...(description ? { description } : {}),
89
+ instructions: input.instructions ?? base?.instructions ??
90
+ `You are ${input.name.trim()}.${description ? ` ${description}` : ""}`,
91
+ model,
92
+ ...(effort ? { effort } : {}),
93
+ ...(tools ? { tools } : {}),
94
+ ...(input.icon ? { icon: input.icon } : {}),
95
+ ...(input.in ? { in: input.in } : {}),
96
+ by: `${ctx.actor.kind}:${ctx.actor.id}`,
97
+ at: new Date().toISOString(),
98
+ });
99
+ return { agent };
100
+ },
101
+ });
102
+ export const updateAgentAction = defineAction({
103
+ description: "Changes an agent people made: what it's shown as, does, is told, uses",
104
+ input: {
105
+ type: "object",
106
+ properties: { agent: { type: "string" }, ...fields },
107
+ required: ["agent"],
108
+ additionalProperties: false,
109
+ },
110
+ allow: inPerson,
111
+ run: async (ctx, input) => {
112
+ const { agent, ...given } = input;
113
+ const found = await ctx.db.collection("agent").findOne({ _id: agent });
114
+ if (!found)
115
+ throw invalid(`No agent "${agent}" to change.`);
116
+ await checked(ctx, { ...given, effort: given.effort ?? found.effort });
117
+ const cleared = ["description", "icon", "effort"].filter((f) => given[f] === "");
118
+ const set = Object.fromEntries(Object.entries(given).filter(([field, value]) => value !== undefined && !cleared.includes(field)));
119
+ const changed = await ctx.db.collection("agent").updateOne({ _id: agent }, {
120
+ ...(Object.keys(set).length ? { $set: set } : {}),
121
+ ...(cleared.length ? { $unset: Object.fromEntries(cleared.map((f) => [f, ""])) } : {}),
122
+ });
123
+ if (!changed.matchedCount)
124
+ throw forbidden(agent);
125
+ return { agent };
126
+ },
127
+ });
128
+ export const deleteAgentAction = defineAction({
129
+ description: "Removes an agent people made, from everywhere it works",
130
+ input: {
131
+ type: "object",
132
+ properties: { agent: { type: "string" } },
133
+ required: ["agent"],
134
+ additionalProperties: false,
135
+ },
136
+ allow: inPerson,
137
+ run: async (ctx, input) => {
138
+ const known = await ctx.db.collection("agent").findOne({ _id: input.agent });
139
+ if (!known)
140
+ throw invalid(`No agent "${input.agent}" to remove.`);
141
+ const gone = await ctx.db.collection("agent").deleteOne({ _id: input.agent });
142
+ if (!gone.deletedCount)
143
+ throw forbidden(input.agent);
144
+ return { deleted: input.agent };
145
+ },
146
+ });
147
+ const DRAFT = "You write the instructions an AI agent works by, in a team where people and " +
148
+ "agents talk in conversations. From its name and what it should do, write its instructions " +
149
+ 'in the second person ("You are…"): who it is, what it does and doesn\'t, how it works and ' +
150
+ "answers. Plain prose, under 200 words. Reply with the instructions alone.";
151
+ export const draftAgentAction = defineAction({
152
+ description: "Writes instructions for an agent from its name and what it should do",
153
+ input: {
154
+ type: "object",
155
+ properties: {
156
+ name: fields.name,
157
+ description: { type: "string", minLength: 1, maxLength: 500 },
158
+ model: fields.model,
159
+ },
160
+ required: ["name", "description"],
161
+ additionalProperties: false,
162
+ },
163
+ allow: people,
164
+ run: async (ctx, input) => {
165
+ const model = input.model ?? usualModel(ctx);
166
+ if (!model)
167
+ throw invalid("Say which model writes it.");
168
+ const { text } = await ctx.call("llm.generate", {
169
+ model,
170
+ instructions: DRAFT,
171
+ messages: [{
172
+ role: "user",
173
+ text: `Name: ${input.name}\nWhat it should do: ${input.description}`,
174
+ }],
175
+ tags: { purpose: "agent.draft" },
176
+ });
177
+ return { instructions: text.trim() };
178
+ },
179
+ });
@@ -0,0 +1 @@
1
+ export declare const defineAgentsAction: import("copilotz").ActionDef;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * `agent.define`: what agents people made are, by name, for chat (its
3
+ * `agentSources` resource): those the asker meets (the rules say: where
4
+ * they belong, or work in a space the asker reaches). Unrecorded, so
5
+ * chat's queries and Views ask it too.
6
+ */
7
+ import { defineAction } from "copilotz";
8
+ import { definitionOf } from "../shared/definition.js";
9
+ export const defineAgentsAction = defineAction({
10
+ description: "What agents people made are, by name: those the asker meets",
11
+ input: {
12
+ type: "object",
13
+ properties: { names: { type: "array", items: { type: "string" } } },
14
+ required: ["names"],
15
+ additionalProperties: false,
16
+ },
17
+ record: false,
18
+ run: async (ctx, input) => {
19
+ const found = {};
20
+ if (!input.names.length)
21
+ return found;
22
+ const made = await ctx.db.collection("agent").find({ _id: { $in: input.names } });
23
+ for (const doc of made)
24
+ found[doc._id] = definitionOf(doc);
25
+ return found;
26
+ },
27
+ });