copilotz 1.0.0-rc.11 → 1.0.0-rc.12

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/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 1.0.0-rc.12 — 2026-11-01
2
+
3
+ - **An agent can hand work to itself in another space.** "Itself" now means the same agent in the
4
+ same chat: North in Personal and North in Project management are two pieces of work. Whoever a
5
+ space says answers takes what's handed there, even the agent that sent it, instead of being
6
+ skipped for someone else, so a space where only that agent answers can receive work too. It reads
7
+ what it handed over, and the answer back, as input (`You (via delegated "Solo"): …`), not as
8
+ something it said.
9
+ - **Delegated messages name the other space:** "Delegated: Personal" there, "Delegated: Project
10
+ management" back, with an icon of their own.
11
+
1
12
  ## 1.0.0-rc.11 — 2026-10-31
2
13
 
3
14
  - **A routine can run with nobody watching.** What its agent needs a yes for can now be allowed for
package/README.md CHANGED
@@ -22,7 +22,7 @@ bun add copilotz # Bun
22
22
  deno add jsr:@copilotz/copilotz # Deno (or `deno add npm:copilotz`)
23
23
  ```
24
24
 
25
- On Deno, name it `copilotz` in `deno.json` (`"copilotz": "jsr:@copilotz/copilotz@^1.0.0-rc.11"`),
25
+ On Deno, name it `copilotz` in `deno.json` (`"copilotz": "jsr:@copilotz/copilotz@^1.0.0-rc.12"`),
26
26
  and the imports below are the same everywhere. Some pieces need a package of their own, installed
27
27
  beside it: `esbuild` to bundle the web host on Node, `@electric-sql/pglite` for PostgreSQL in the
28
28
  process, and `@types/react` for the front ends' types.
@@ -204,7 +204,7 @@ and an app serves it from there by default:
204
204
  import { computerDownloads } from "copilotz/plugins/compute/downloads";
205
205
 
206
206
  plugins: [...plugins, await computerDownloads()], // this Copilotz's release
207
- plugins: [...plugins, await computerDownloads({ dir: "dist/computer/1.0.0-rc.11" })], // its own: /computer/download/
207
+ plugins: [...plugins, await computerDownloads({ dir: "dist/computer/1.0.0-rc.12" })], // its own: /computer/download/
208
208
  plugins: [...plugins, await computerDownloads({ url: "https://downloads.example.com/computer/" })], // or elsewhere
209
209
  ```
210
210
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "copilotz",
3
- "version": "1.0.0-rc.11",
3
+ "version": "1.0.0-rc.12",
4
4
  "description": "Copilotz: one runtime for Node, Deno, Bun, Cloudflare Workers and the browser.",
5
5
  "keywords": [
6
6
  "agents",
@@ -22,10 +22,7 @@ export const elsewhereView = (thread, ctx) => {
22
22
  const others = spaces.filter((s) => !near.has(s._id) && !s.archived)
23
23
  .sort((a, b) => Number(b.kind === "personal") - Number(a.kind === "personal"));
24
24
  const hands = (agent[name]?.tools ?? []).includes(SEND)
25
- ? handoffs.flatMap((s) => {
26
- const there = s.agents.filter((a) => a !== name);
27
- return s._id !== thread.in && there.length ? [{ ...s, agents: there }] : [];
28
- })
25
+ ? handoffs.filter((s) => s._id !== thread.in && s.agents.length)
29
26
  : [];
30
27
  if (!others.length && !hands.length)
31
28
  return undefined;
@@ -47,7 +44,7 @@ export const elsewhereView = (thread, ctx) => {
47
44
  ? [
48
45
  `Spaces you can hand work to for ${who}, with send_message's \`space\`, when it belongs ` +
49
46
  `to their team:`,
50
- ...hands.slice(0, LISTED).map((s) => `- ${s.kind === "personal" ? "Personal" : s.name} [space: ${s._id}]: ${s.agents.join(", ")}`),
47
+ ...hands.slice(0, LISTED).map((s) => `- ${s.kind === "personal" ? "Personal" : s.name} [space: ${s._id}]: ${s.agents.map((a) => a === name ? `${a} (you, working there)` : a).join(", ")}`),
51
48
  ]
52
49
  : []),
53
50
  ].join("\n");
@@ -18,6 +18,9 @@ export declare const delivery: (ctx: Context, m: {
18
18
  to: string[];
19
19
  replyTo?: string;
20
20
  hops: number;
21
+ via?: {
22
+ kind: string;
23
+ };
21
24
  },
22
25
  /** Where the turns it starts run: its thread, or the subthread hanging from it. */
23
26
  where?: string,
@@ -1,6 +1,6 @@
1
1
  import { agentsNamed, NO_ANSWER, now } from "./agents.js";
2
2
  import { noted } from "./summary.js";
3
- import { settingsOf } from "./types.js";
3
+ import { DELEGATED, settingsOf } from "./types.js";
4
4
  /** Whether a message after `hops` agent messages in a row may still start a turn. */
5
5
  export const starts = (ctx, hops) => {
6
6
  const { maxHops } = settingsOf(ctx);
@@ -20,7 +20,8 @@ start = true) => {
20
20
  const waits = ctx.db.collection("wait");
21
21
  const steps = [];
22
22
  for (const name of m.to) {
23
- if (!agents[name] || name === m.from)
23
+ // An agent doesn't start itself, where it is; handed between spaces, it's other work.
24
+ if (!agents[name] || (name === m.from && m.via?.kind !== DELEGATED))
24
25
  continue;
25
26
  // An agent's open waits: one query per agent, which the owner keeps cached.
26
27
  const waiting = m.replyTo
@@ -80,7 +81,7 @@ known) => {
80
81
  ...(back.in ? { in: back.in } : {}),
81
82
  to: [trigger.from],
82
83
  via: {
83
- kind: "delegated",
84
+ kind: DELEGATED,
84
85
  name: (back.from ?? "Another space").slice(0, 120),
85
86
  path: `/thread/${encodeURIComponent(t.thread)}${thread?.in ? `?in=${encodeURIComponent(thread.in)}` : ""}`,
86
87
  },
@@ -1,6 +1,6 @@
1
1
  import { agentsNamed, now, rosterOf, SEND } from "./agents.js";
2
2
  import { starts } from "./delivery.js";
3
- import { settingsOf } from "./types.js";
3
+ import { DELEGATED, settingsOf } from "./types.js";
4
4
  /** Whom work is for: the person found along `for` and `via`, carrying any limit or origin of theirs. */
5
5
  export function principalOf(actor) {
6
6
  for (let a = actor, hops = 0; a && hops < 4; hops++) {
@@ -12,9 +12,10 @@ export function principalOf(actor) {
12
12
  }
13
13
  /**
14
14
  * Hands work to an agent of another space, in a new chat there that its members
15
- * see, for the same person, who must be able to write there. The agent need
16
- * not work there itself: its person sends it. The answer comes back to the chat
17
- * it was sent from (`back`).
15
+ * see, for the same person, who must be able to write there. The sender need
16
+ * not work there; and it may be who answers there, which is other work than
17
+ * this, in another chat. The answer comes back to the chat it was sent from
18
+ * (`back`).
18
19
  */
19
20
  async function handOver(ctx, t, step, id, input, space, where) {
20
21
  const fail = (why) => ({ output: `Not sent: ${why}` });
@@ -27,12 +28,11 @@ async function handOver(ctx, t, step, id, input, space, where) {
27
28
  if (!can)
28
29
  return fail(`the person you work for can't write in the space "${space}".`);
29
30
  const roster = await rosterOf(as, space);
30
- const others = roster.here.filter((name) => name !== t.agent);
31
- const to = String(input.to ?? "") || roster.default.find((name) => name !== t.agent) || others[0];
31
+ const to = String(input.to ?? "") || roster.default[0] || roster.here[0];
32
32
  if (!to)
33
- return fail("no other agent answers in that space.");
34
- if (!others.includes(to)) {
35
- return fail(`nobody called "${to}" answers there. You can message: ${others.join(", ")}.`);
33
+ return fail("no agent answers in that space.");
34
+ if (!roster.here.includes(to)) {
35
+ return fail(`nobody called "${to}" answers there. You can message: ${roster.here.join(", ")}.`);
36
36
  }
37
37
  if (!starts(ctx, t.hops + 1)) {
38
38
  return fail(`this conversation reached its limit of ${settingsOf(ctx).maxHops} agent messages in a row.`);
@@ -44,10 +44,12 @@ async function handOver(ctx, t, step, id, input, space, where) {
44
44
  const fresh = `${id}:thread`;
45
45
  const chat = `/thread/${encodeURIComponent(fresh)}?in=${encodeURIComponent(space)}`;
46
46
  const from = `/thread/${encodeURIComponent(t.thread)}${where ? `?in=${encodeURIComponent(where)}` : ""}`;
47
- const named = (await agentsNamed(ctx, [t.agent]))[t.agent]?.name || t.agent;
48
- // What the chat it comes back to calls where it went.
49
- const called = (await as.db.collection("space").findOne({ _id: space }))?.name ??
50
- "another space";
47
+ // Each end says which space the other is.
48
+ const spaces = as.db.collection("space");
49
+ const called = async (id) => {
50
+ const found = id ? await spaces.findOne({ _id: id }) : null;
51
+ return found?.kind === "personal" ? "Personal" : found?.name ?? "another space";
52
+ };
51
53
  return {
52
54
  output: `Sent to ${to} in a new chat in that space (${chat})${input.expectReply === false ? "." : "; you'll have the reply before you continue."}`,
53
55
  across: true,
@@ -59,8 +61,8 @@ async function handOver(ctx, t, step, id, input, space, where) {
59
61
  to: [to],
60
62
  text,
61
63
  hops: t.hops + 1,
62
- via: { kind: "delegated", name: named, path: from },
63
- back: { thread: t.thread, ...(where ? { in: where } : {}), from: called },
64
+ via: { kind: DELEGATED, name: (await called(where)).slice(0, 120), path: from },
65
+ back: { thread: t.thread, ...(where ? { in: where } : {}), from: await called(space) },
64
66
  ...(input.expectReply === false ? { expectReply: false } : {}),
65
67
  at,
66
68
  },
@@ -83,6 +85,8 @@ where) => {
83
85
  const space = typeof input.space === "string" ? input.space : undefined;
84
86
  if (space && space !== where)
85
87
  return await handOver(ctx, t, step, id, input, space, where);
88
+ if (space && !input.to)
89
+ return { output: "Not sent: you're working in that space already." };
86
90
  const team = await here();
87
91
  const to = String(input.to ?? "");
88
92
  const agents = team.open && !team.agents[to]
@@ -163,9 +167,11 @@ export function sendTool(others, people) {
163
167
  "in: thread (here, for everyone), subthread (a side conversation hanging from your " +
164
168
  "message, where the recipient also sees this conversation so far), new_thread (a " +
165
169
  "separate conversation that starts from your message alone).",
166
- "space: to hand work to another space's agents, the id of one your context lists: a new " +
167
- "chat opens there, which its members see, and to is optional (who answers there). Say " +
168
- "everything they need: they don't see this conversation, and whoever is there can read it.",
170
+ "space: to hand work that belongs to another space to who answers there, the id of one " +
171
+ "your context lists: a new chat opens there, which its members see. to is optional, and " +
172
+ "that may be you: you then work there as anyone there would, with that space's memories " +
173
+ "and tools. Either way, say everything needed: this conversation doesn't go along, and " +
174
+ "whoever is there can read it. Don't hand work back where it came from: answer it.",
169
175
  ...(agents.length ? ["Agents:", ...agents] : []),
170
176
  ...(people.length ? [`People: ${people.join(", ")}`] : []),
171
177
  ].join("\n"),
@@ -41,6 +41,8 @@ export type Tool<I = Record<string, unknown>> = {
41
41
  /** Whom a tool is offered to: everyone, these agents, or decided per agent and thread. */
42
42
  export type Offer = true | string[] | ((agent: string, thread: Thread, ctx: ViewContext) => boolean);
43
43
  /** What a tool's code reaches: the runtime, and whose turn it runs in. */
44
+ /** A message's `via` when it's handed from one space to another, either way. */
45
+ export declare const DELEGATED = "delegated";
44
46
  export type ToolContext = Context & {
45
47
  /** The agent calling it, the thread it works in, and the message it answers. */
46
48
  agent: string;
@@ -1,3 +1,6 @@
1
+ /** What a tool's code reaches: the runtime, and whose turn it runs in. */
2
+ /** A message's `via` when it's handed from one space to another, either way. */
3
+ export const DELEGATED = "delegated";
1
4
  /** A tool whose `run` input type comes from its JSON Schema. */
2
5
  export const tool = (def) => def;
3
6
  /** Chat's settings, as configured. */
@@ -3,6 +3,7 @@ import type { LlmMessage } from "../../../models/contract.js";
3
3
  import type { Message } from "../collections/message.js";
4
4
  /**
5
5
  * A message as the viewing agent sees it: its own as its turns (after what it
6
- * was told then), others' as labelled input.
6
+ * was told then), others' as labelled input. So is what it handed between
7
+ * spaces itself: that was other work, in another chat, not this turn's.
7
8
  */
8
9
  export declare function messageView(m: Message, ctx: ViewContext): LlmMessage[];
@@ -1,4 +1,5 @@
1
1
  import { text, textual } from "../collections/file.js";
2
+ import { DELEGATED } from "../shared/types.js";
2
3
  import { nameOf, namesIn } from "../../../access/spaces/contract.js";
3
4
  /** How much of a text file an agent is sent. */
4
5
  const FILE_CHARS = 20_000;
@@ -37,11 +38,13 @@ function attached(m, ctx) {
37
38
  }
38
39
  /**
39
40
  * A message as the viewing agent sees it: its own as its turns (after what it
40
- * was told then), others' as labelled input.
41
+ * was told then), others' as labelled input. So is what it handed between
42
+ * spaces itself: that was other work, in another chat, not this turn's.
41
43
  */
42
44
  export function messageView(m, ctx) {
43
45
  const me = ctx.viewer?.name;
44
- if (m.from !== me) {
46
+ const handed = m.via?.kind === DELEGATED;
47
+ if (m.from !== me || handed) {
45
48
  // People by name (an agent's own name is as it is).
46
49
  const names = namesIn(ctx, [m.from, ...m.to]);
47
50
  const to = !me || m.to.includes(me) || !m.to.length
@@ -52,7 +55,7 @@ export function messageView(m, ctx) {
52
55
  const via = m.via ? ` (via ${m.via.kind} "${m.via.name}")` : "";
53
56
  return [{
54
57
  role: "user",
55
- text: `${nameOf(m.from, names)}${via}${to}: ${m.text ?? ""}${notes}`,
58
+ text: `${m.from === me ? "You" : nameOf(m.from, names)}${via}${to}: ${m.text ?? ""}${notes}`,
56
59
  ...(files.length ? { files } : {}),
57
60
  }];
58
61
  }
@@ -10,6 +10,7 @@ import { Transcript } from "./transcript.js";
10
10
  import { waitingOn } from "./waiting.js";
11
11
  import { byAgent, names } from "./who.js";
12
12
  import { nameOf, namesIn } from "../../../../access/spaces/contract.js";
13
+ import { DELEGATED } from "../../shared/types.js";
13
14
  /** Messages this close after the one before, from the same author, go under its name. */
14
15
  const GROUP_MS = 5 * 60_000;
15
16
  export const conversationView = (t, ctx) => {
@@ -100,8 +101,10 @@ export const conversationView = (t, ctx) => {
100
101
  const before = said[i - 1];
101
102
  // Yours, while an agent it's to finishes an earlier one: it waits its turn.
102
103
  const queued = m.from === me && !byAgent(m) ? waitingOn(m, live, said) : [];
104
+ // What's handed between spaces stands apart, or an agent's hand-off and answer read as one.
103
105
  const follows = !!before && before.from === m.from && before.thread === m.thread &&
104
- !before.failed && Date.parse(m.at) - Date.parse(before.at) < GROUP_MS;
106
+ !before.failed && before.via?.kind !== DELEGATED && m.via?.kind !== DELEGATED &&
107
+ Date.parse(m.at) - Date.parse(before.at) < GROUP_MS;
105
108
  return ctx.show("message", m, {
106
109
  thread: t._id,
107
110
  who: shown,
@@ -37,7 +37,11 @@ export const messageView = (m, ctx) => {
37
37
  ? (_jsxs("header", { className: "msg-head msg-head-again", children: [addressees, aside ? _jsx(Badge, { children: "side thread" }) : null] }))
38
38
  : null)
39
39
  : head, m.via
40
- ? (_jsxs(Chip, { size: "sm", icon: "refresh", className: "msg-via", ...(m.via.path ? { href: m.via.path } : {}), children: [m.via.kind[0].toUpperCase() + m.via.kind.slice(1), ": ", m.via.name] }))
40
+ ? (_jsxs(Chip, { size: "sm", icon: m.via.kind === "routine"
41
+ ? "refresh"
42
+ : m.via.kind === "answer"
43
+ ? "check"
44
+ : "share", className: "msg-via", ...(m.via.path ? { href: m.via.path } : {}), children: [m.via.kind[0].toUpperCase() + m.via.kind.slice(1), ": ", m.via.name] }))
41
45
  : null, m.toolCalls
42
46
  ? (_jsx(Steps, { calls: m.toolCalls, text: m.text, me: me, named: named, shown: m.toolCalls.map((c) => toolView(ctx, c, m.thread)) }))
43
47
  : agent
@@ -1,2 +1,2 @@
1
1
  /** The computer program's version, as `computer.info` and `--version` say it, and its builds are named. */
2
- export declare const VERSION = "1.0.0-rc.11";
2
+ export declare const VERSION = "1.0.0-rc.12";
@@ -1,2 +1,2 @@
1
1
  /** The computer program's version, as `computer.info` and `--version` say it, and its builds are named. */
2
- export const VERSION = "1.0.0-rc.11";
2
+ export const VERSION = "1.0.0-rc.12";
@@ -14,7 +14,7 @@
14
14
  *
15
15
  * ```ts
16
16
  * plugins: [...plugins, await computerDownloads()]
17
- * plugins: [...plugins, await computerDownloads({ dir: "dist/computer/1.0.0-rc.11" })]
17
+ * plugins: [...plugins, await computerDownloads({ dir: "dist/computer/1.0.0-rc.12" })]
18
18
  * plugins: [...plugins, await computerDownloads({ url: "https://downloads.example.com/computer/" })]
19
19
  * ```
20
20
  */