pi-fabric 0.9.0 → 0.10.0
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/README.md +30 -2
- package/dist/actors/global-registry.d.ts +47 -0
- package/dist/actors/global-registry.d.ts.map +1 -0
- package/dist/actors/global-registry.js +308 -0
- package/dist/actors/global-registry.js.map +1 -0
- package/dist/actors/manager.d.ts +30 -0
- package/dist/actors/manager.d.ts.map +1 -1
- package/dist/actors/manager.js +63 -0
- package/dist/actors/manager.js.map +1 -1
- package/dist/actors/types.d.ts +19 -0
- package/dist/actors/types.d.ts.map +1 -1
- package/dist/commands/fabric.d.ts.map +1 -1
- package/dist/commands/fabric.js +96 -3
- package/dist/commands/fabric.js.map +1 -1
- package/dist/fabric-state.d.ts +2 -0
- package/dist/fabric-state.d.ts.map +1 -1
- package/dist/fabric-state.js +10 -1
- package/dist/fabric-state.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/providers/agents-provider.d.ts +3 -1
- package/dist/providers/agents-provider.d.ts.map +1 -1
- package/dist/providers/agents-provider.js +104 -10
- package/dist/providers/agents-provider.js.map +1 -1
- package/dist/ui/controller.d.ts.map +1 -1
- package/dist/ui/controller.js +45 -0
- package/dist/ui/controller.js.map +1 -1
- package/dist/ui/dashboard.d.ts +22 -0
- package/dist/ui/dashboard.d.ts.map +1 -1
- package/dist/ui/dashboard.js +177 -3
- package/dist/ui/dashboard.js.map +1 -1
- package/dist/ui/snapshot.d.ts.map +1 -1
- package/dist/ui/snapshot.js +2 -0
- package/dist/ui/snapshot.js.map +1 -1
- package/dist/ui/types.d.ts +5 -1
- package/dist/ui/types.d.ts.map +1 -1
- package/dist/ui/types.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -320,6 +320,34 @@ Two response modes are available:
|
|
|
320
320
|
|
|
321
321
|
Delivery can remain in `mailbox` or enter the main session as `steer`, `followUp`, or `nextTurn`. The creator fixes delivery policy; an actor cannot escalate it in a response. Use `agents.ask()` for a blocking exchange, `agents.tell()` for fire-and-forget mail, `agents.messages()` for history, and `agents.remove()` for cleanup.
|
|
322
322
|
|
|
323
|
+
### Global actor templates
|
|
324
|
+
|
|
325
|
+
Persistent actors live in a project mesh, but a persona worth reusing across projects belongs in a project-independent **template library** stored in your agent dir (`~/.pi/agent/fabric/actors/`). Templates carry only an actor definition — name, instructions, subscriptions, and run settings — never any history (mailbox, session transcript, or run logs). They are not live; you stamp one into a project to make it run.
|
|
326
|
+
|
|
327
|
+
```ts
|
|
328
|
+
// Save a reusable persona to the global registry (not a live actor).
|
|
329
|
+
return agents.create({
|
|
330
|
+
name: "security-reviewer",
|
|
331
|
+
instructions: "Review changes for security defects. Reply with a directive only for material drift.",
|
|
332
|
+
events: ["agent_settled"],
|
|
333
|
+
responseMode: "directive",
|
|
334
|
+
scope: "global",
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
// List templates, then stamp one into the current project as a fresh actor.
|
|
338
|
+
const [template] = agents.actors({ scope: "global" });
|
|
339
|
+
return agents.import({ name: template.name }); // fresh: no inherited history
|
|
340
|
+
return agents.import({ name: "security-reviewer", as: "security-reviewer-2" }); // rename on collision
|
|
341
|
+
|
|
342
|
+
// Promote a tuned project actor back to the global library (no history).
|
|
343
|
+
return agents.export({ id: actorId, overwrite: true });
|
|
344
|
+
|
|
345
|
+
// Refine a template's default instruction (the persona / system-prompt body).
|
|
346
|
+
return agents.setInstructions({ id: template.id, instructions: "Be brief.", scope: "global" });
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
`agents.setInstructions` also edits a live project actor (`scope: "project"`, the default); the new instruction takes effect on the actor's next queued message. History never crosses the project⇄global boundary — import and export move only the definition. Slash commands mirror the API: `/fabric global` lists templates, `/fabric import <name> [as <new>]` stamps one into the project, and `/fabric export <id> [--overwrite]` promotes a project actor. The dashboard lists global templates alongside live actors and lets you import, export, delete, and edit instructions without writing code.
|
|
350
|
+
|
|
323
351
|
### Durable mesh coordination
|
|
324
352
|
|
|
325
353
|
The `mesh` API is a project-scoped, event-sourced coordination substrate:
|
|
@@ -397,9 +425,9 @@ Supervisor and advisor are deliberately skills rather than hard-coded host servi
|
|
|
397
425
|
Fabric also owns a general-purpose, theme-aware activity surface for any agent setup:
|
|
398
426
|
|
|
399
427
|
- A compact widget above the chat (like `pi-supervisor`) follows the current phase and shows active agents, actors, tools, custom items, shared tasks, token use, and elapsed time. It disappears after ordinary runs become quiet, while persistent actors remain visible as a compact ambient row.
|
|
400
|
-
- `/fabric dashboard` opens a responsive interactive overlay. Wide terminals use a Claude-workflow-style phase pane beside agents and work items; narrow terminals stack the same panels. Agent detail includes task, model, current tool, usage, result, worktree, and attach metadata. Actor mailboxes, mesh state, and recent mesh events use the same view rather than role-specific screens. In an actor's detail view, press `m` to open the model picker and change that actor's model, or press `e` to open the thinking (reasoning effort) picker and change that actor's `thinking` level (or pick Inherit to fall back to the Fabric default); both changes persist to the actor registry and take effect on the actor's next run.
|
|
428
|
+
- `/fabric dashboard` opens a responsive interactive overlay. Wide terminals use a Claude-workflow-style phase pane beside agents and work items; narrow terminals stack the same panels. Agent detail includes task, model, current tool, usage, result, worktree, and attach metadata. Actor mailboxes, mesh state, and recent mesh events use the same view rather than role-specific screens. In an actor's detail view, press `m` to open the model picker and change that actor's model, or press `e` to open the thinking (reasoning effort) picker and change that actor's `thinking` level (or pick Inherit to fall back to the Fabric default); both changes persist to the actor registry and take effect on the actor's next run. Global actor templates (project-independent personas) appear in the same view; in any actor's detail, press `i` to edit its default instruction (Enter submits, Shift+Enter inserts a line), `x` to export a project actor to the global library, `p` to import a global template as a fresh project actor, and `d` to delete a global template.
|
|
401
429
|
- `/fabric settings` opens an inline settings view that mirrors Pi core's `/settings` (top and bottom borders, fuzzy search, section submenus) and writes changes to `fabric.json`. Trusted projects write to `<project>/.pi/fabric.json`; untrusted sessions write to the global `~/.pi/agent/fabric.json`. Full code mode, capture, executor, approvals, and UI changes apply immediately; mesh, subagent, and MCP changes persist and take effect on the next `/fabric reload`. List editors for `subagents.defaultTools` and `capture.keepVisible` toggle known tools on and off; `keepVisible` candidates include `fabric_exec` plus every captured extension tool.
|
|
402
|
-
- `↑`/`↓` or `j`/`k` select, `←`/`→` or Tab switch panes, Enter drills into details, `f` cycles status filters, `[`/`]` switches retained runs, `m` changes an actor's model
|
|
430
|
+
- `↑`/`↓` or `j`/`k` select, `←`/`→` or Tab switch panes, Enter drills into details, `f` cycles status filters, `[`/`]` switches retained runs, `m` changes an actor's model, `e` its thinking level, `i` its default instruction, `x` exports to global, `p` imports from global, and `d` deletes a global template from the detail view, and Esc backs out or closes.
|
|
403
431
|
|
|
404
432
|
The surface is data-driven. Fabric automatically instruments nested provider calls, subagents, persistent actors, and task-shaped mesh entries. A workflow can add domain-specific labels and arbitrary progress without adding extension UI code:
|
|
405
433
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { FabricActorRequest, GlobalActorDefinition } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* A project-independent library of actor templates. Templates carry only an
|
|
4
|
+
* actor definition (name, instructions, subscriptions, and run settings) plus
|
|
5
|
+
* identity/timestamps — never any history. They are not live actors: importing
|
|
6
|
+
* a template into a project creates a fresh live actor with no inherited
|
|
7
|
+
* session, mailbox, or run logs.
|
|
8
|
+
*
|
|
9
|
+
* The registry lives in the user's agent dir (machine-global), independent of
|
|
10
|
+
* any project or mesh, so the same templates are available across every
|
|
11
|
+
* project. Operations are pure file I/O and do not require the mesh to be
|
|
12
|
+
* enabled; only importing (which creates a live actor via ActorManager) does.
|
|
13
|
+
* The registry is read into memory once at construction; run `/fabric reload`
|
|
14
|
+
* to pick up templates added by other Pi sessions. Writes are atomic (write
|
|
15
|
+
* to a temp file then rename) so concurrent sessions cannot corrupt the
|
|
16
|
+
* store, though truly simultaneous edits are last-write-wins.
|
|
17
|
+
*/
|
|
18
|
+
export declare class GlobalActorRegistry {
|
|
19
|
+
#private;
|
|
20
|
+
constructor(agentDir: string, maxInstructionsBytes: number);
|
|
21
|
+
list(): GlobalActorDefinition[];
|
|
22
|
+
resolve(idOrName: string): GlobalActorDefinition | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Save a definition to the global registry. If a template with the same name
|
|
25
|
+
* already exists, throws unless `overwrite` is true (in which case the
|
|
26
|
+
* existing template is updated in place, keeping its id). Returns the stored
|
|
27
|
+
* definition.
|
|
28
|
+
*/
|
|
29
|
+
create(def: FabricActorRequest, overwrite?: boolean): GlobalActorDefinition;
|
|
30
|
+
/**
|
|
31
|
+
* Apply a partial patch to a stored template (e.g. new instructions). Only
|
|
32
|
+
* the supplied fields are replaced; the rest are preserved. Re-validates any
|
|
33
|
+
* changed field.
|
|
34
|
+
*/
|
|
35
|
+
update(idOrName: string, patch: Partial<FabricActorRequest>): GlobalActorDefinition;
|
|
36
|
+
remove(idOrName: string): {
|
|
37
|
+
removed: boolean;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Strip identity/timestamps from a stored template to produce the request
|
|
41
|
+
* shape ActorManager.create expects. Optionally rename the imported actor so
|
|
42
|
+
* a template can be stamped into a project under a different name (e.g. to
|
|
43
|
+
* avoid a collision with a live actor).
|
|
44
|
+
*/
|
|
45
|
+
toRequest(def: GlobalActorDefinition, as?: string): FabricActorRequest;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=global-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-registry.d.ts","sourceRoot":"","sources":["../../src/actors/global-registry.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAGV,kBAAkB,EAElB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAkDpB;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,mBAAmB;;gBAKlB,QAAQ,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM;IAM1D,IAAI,IAAI,qBAAqB,EAAE;IAI/B,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS;IAK5D;;;;;OAKG;IACH,MAAM,CAAC,GAAG,EAAE,kBAAkB,EAAE,SAAS,UAAQ,GAAG,qBAAqB;IA6BzE;;;;OAIG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG,qBAAqB;IAsCnF,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE;IAQ9C;;;;;OAKG;IACH,SAAS,CAAC,GAAG,EAAE,qBAAqB,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,kBAAkB;CAkJvE"}
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { isFabricThinking } from "../thinking.js";
|
|
5
|
+
const ACTOR_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9 _.-]{0,59}$/;
|
|
6
|
+
const TOPIC_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._:/-]{0,127}$/;
|
|
7
|
+
const HOST_EVENTS = new Set([
|
|
8
|
+
"input",
|
|
9
|
+
"turn_end",
|
|
10
|
+
"agent_settled",
|
|
11
|
+
"tool_error",
|
|
12
|
+
"session_compact",
|
|
13
|
+
]);
|
|
14
|
+
const DELIVERIES = new Set(["mailbox", "steer", "followUp", "nextTurn"]);
|
|
15
|
+
const RESPONSE_MODES = new Set(["text", "directive"]);
|
|
16
|
+
const TRANSPORTS = new Set(["auto", "process", "tmux", "screen", "localterm"]);
|
|
17
|
+
const atomicWrite = (filePath, value) => {
|
|
18
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true, mode: 0o700 });
|
|
19
|
+
const temporaryPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
|
|
20
|
+
fs.writeFileSync(temporaryPath, JSON.stringify(value, null, 2), {
|
|
21
|
+
encoding: "utf8",
|
|
22
|
+
mode: 0o600,
|
|
23
|
+
});
|
|
24
|
+
fs.renameSync(temporaryPath, filePath);
|
|
25
|
+
};
|
|
26
|
+
const clone = (value) => structuredClone(value);
|
|
27
|
+
/**
|
|
28
|
+
* Resolve a partial id (unique prefix) or an exact name to a definition.
|
|
29
|
+
* Returns undefined when nothing matches, and throws on an ambiguous prefix.
|
|
30
|
+
*/
|
|
31
|
+
const resolveDefinition = (actors, idOrName) => {
|
|
32
|
+
const exact = actors.get(idOrName);
|
|
33
|
+
if (exact)
|
|
34
|
+
return exact;
|
|
35
|
+
const matches = [...actors.values()].filter((actor) => actor.id.startsWith(idOrName) || actor.name === idOrName);
|
|
36
|
+
if (matches.length === 1 && matches[0])
|
|
37
|
+
return matches[0];
|
|
38
|
+
if (matches.length > 1)
|
|
39
|
+
throw new Error(`Ambiguous global actor: ${idOrName}`);
|
|
40
|
+
return undefined;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* A project-independent library of actor templates. Templates carry only an
|
|
44
|
+
* actor definition (name, instructions, subscriptions, and run settings) plus
|
|
45
|
+
* identity/timestamps — never any history. They are not live actors: importing
|
|
46
|
+
* a template into a project creates a fresh live actor with no inherited
|
|
47
|
+
* session, mailbox, or run logs.
|
|
48
|
+
*
|
|
49
|
+
* The registry lives in the user's agent dir (machine-global), independent of
|
|
50
|
+
* any project or mesh, so the same templates are available across every
|
|
51
|
+
* project. Operations are pure file I/O and do not require the mesh to be
|
|
52
|
+
* enabled; only importing (which creates a live actor via ActorManager) does.
|
|
53
|
+
* The registry is read into memory once at construction; run `/fabric reload`
|
|
54
|
+
* to pick up templates added by other Pi sessions. Writes are atomic (write
|
|
55
|
+
* to a temp file then rename) so concurrent sessions cannot corrupt the
|
|
56
|
+
* store, though truly simultaneous edits are last-write-wins.
|
|
57
|
+
*/
|
|
58
|
+
export class GlobalActorRegistry {
|
|
59
|
+
#actors = new Map();
|
|
60
|
+
#path;
|
|
61
|
+
#maxBytes;
|
|
62
|
+
constructor(agentDir, maxInstructionsBytes) {
|
|
63
|
+
this.#path = path.join(agentDir, "fabric", "actors", "global-actors.json");
|
|
64
|
+
this.#maxBytes = maxInstructionsBytes;
|
|
65
|
+
this.#load();
|
|
66
|
+
}
|
|
67
|
+
list() {
|
|
68
|
+
return [...this.#actors.values()].map(clone);
|
|
69
|
+
}
|
|
70
|
+
resolve(idOrName) {
|
|
71
|
+
const found = resolveDefinition(this.#actors, idOrName);
|
|
72
|
+
return found ? clone(found) : undefined;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Save a definition to the global registry. If a template with the same name
|
|
76
|
+
* already exists, throws unless `overwrite` is true (in which case the
|
|
77
|
+
* existing template is updated in place, keeping its id). Returns the stored
|
|
78
|
+
* definition.
|
|
79
|
+
*/
|
|
80
|
+
create(def, overwrite = false) {
|
|
81
|
+
const validated = this.#validate(def);
|
|
82
|
+
const existing = [...this.#actors.values()].find((actor) => actor.name === validated.name);
|
|
83
|
+
if (existing) {
|
|
84
|
+
if (!overwrite) {
|
|
85
|
+
throw new Error(`A global actor named ${validated.name} already exists (${existing.id})`);
|
|
86
|
+
}
|
|
87
|
+
const updated = {
|
|
88
|
+
...existing,
|
|
89
|
+
...validated,
|
|
90
|
+
id: existing.id,
|
|
91
|
+
createdAt: existing.createdAt,
|
|
92
|
+
updatedAt: Date.now(),
|
|
93
|
+
};
|
|
94
|
+
this.#actors.set(existing.id, updated);
|
|
95
|
+
this.#save();
|
|
96
|
+
return clone(updated);
|
|
97
|
+
}
|
|
98
|
+
const created = {
|
|
99
|
+
...validated,
|
|
100
|
+
id: randomUUID().replaceAll("-", ""),
|
|
101
|
+
createdAt: Date.now(),
|
|
102
|
+
updatedAt: Date.now(),
|
|
103
|
+
};
|
|
104
|
+
this.#actors.set(created.id, created);
|
|
105
|
+
this.#save();
|
|
106
|
+
return clone(created);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Apply a partial patch to a stored template (e.g. new instructions). Only
|
|
110
|
+
* the supplied fields are replaced; the rest are preserved. Re-validates any
|
|
111
|
+
* changed field.
|
|
112
|
+
*/
|
|
113
|
+
update(idOrName, patch) {
|
|
114
|
+
const existing = resolveDefinition(this.#actors, idOrName);
|
|
115
|
+
if (!existing)
|
|
116
|
+
throw new Error(`Unknown global actor: ${idOrName}`);
|
|
117
|
+
const merged = {
|
|
118
|
+
name: patch.name ?? existing.name,
|
|
119
|
+
instructions: patch.instructions ?? existing.instructions,
|
|
120
|
+
events: patch.events ?? existing.events,
|
|
121
|
+
topics: patch.topics ?? existing.topics,
|
|
122
|
+
delivery: patch.delivery ?? existing.delivery,
|
|
123
|
+
responseMode: patch.responseMode ?? existing.responseMode,
|
|
124
|
+
triggerTurn: patch.triggerTurn ?? existing.triggerTurn,
|
|
125
|
+
coalesce: patch.coalesce ?? existing.coalesce,
|
|
126
|
+
...(patch.model !== undefined ? { model: patch.model } : existing.model ? { model: existing.model } : {}),
|
|
127
|
+
...(patch.thinking !== undefined ? { thinking: patch.thinking } : existing.thinking ? { thinking: existing.thinking } : {}),
|
|
128
|
+
...(patch.tools !== undefined ? { tools: patch.tools } : existing.tools ? { tools: existing.tools } : {}),
|
|
129
|
+
...(patch.transport !== undefined ? { transport: patch.transport } : existing.transport ? { transport: existing.transport } : {}),
|
|
130
|
+
...(patch.timeoutMs !== undefined ? { timeoutMs: patch.timeoutMs } : existing.timeoutMs ? { timeoutMs: existing.timeoutMs } : {}),
|
|
131
|
+
};
|
|
132
|
+
const validated = this.#validate(merged);
|
|
133
|
+
if (validated.name !== existing.name) {
|
|
134
|
+
const clash = [...this.#actors.values()].find((actor) => actor.id !== existing.id && actor.name === validated.name);
|
|
135
|
+
if (clash) {
|
|
136
|
+
throw new Error(`A global actor named ${validated.name} already exists (${clash.id})`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const updated = {
|
|
140
|
+
...validated,
|
|
141
|
+
id: existing.id,
|
|
142
|
+
createdAt: existing.createdAt,
|
|
143
|
+
updatedAt: Date.now(),
|
|
144
|
+
};
|
|
145
|
+
this.#actors.set(existing.id, updated);
|
|
146
|
+
this.#save();
|
|
147
|
+
return clone(updated);
|
|
148
|
+
}
|
|
149
|
+
remove(idOrName) {
|
|
150
|
+
const existing = resolveDefinition(this.#actors, idOrName);
|
|
151
|
+
if (!existing)
|
|
152
|
+
return { removed: false };
|
|
153
|
+
this.#actors.delete(existing.id);
|
|
154
|
+
this.#save();
|
|
155
|
+
return { removed: true };
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Strip identity/timestamps from a stored template to produce the request
|
|
159
|
+
* shape ActorManager.create expects. Optionally rename the imported actor so
|
|
160
|
+
* a template can be stamped into a project under a different name (e.g. to
|
|
161
|
+
* avoid a collision with a live actor).
|
|
162
|
+
*/
|
|
163
|
+
toRequest(def, as) {
|
|
164
|
+
const name = as?.trim() || def.name;
|
|
165
|
+
const request = {
|
|
166
|
+
name,
|
|
167
|
+
instructions: def.instructions,
|
|
168
|
+
events: [...def.events],
|
|
169
|
+
topics: [...def.topics],
|
|
170
|
+
delivery: def.delivery,
|
|
171
|
+
responseMode: def.responseMode,
|
|
172
|
+
triggerTurn: def.triggerTurn,
|
|
173
|
+
coalesce: def.coalesce,
|
|
174
|
+
...(def.model ? { model: def.model } : {}),
|
|
175
|
+
...(def.thinking ? { thinking: def.thinking } : {}),
|
|
176
|
+
...(def.tools ? { tools: [...def.tools] } : {}),
|
|
177
|
+
...(def.transport ? { transport: def.transport } : {}),
|
|
178
|
+
...(def.timeoutMs ? { timeoutMs: def.timeoutMs } : {}),
|
|
179
|
+
};
|
|
180
|
+
return request;
|
|
181
|
+
}
|
|
182
|
+
#validate(def) {
|
|
183
|
+
const name = def.name.trim();
|
|
184
|
+
if (!ACTOR_NAME_PATTERN.test(name))
|
|
185
|
+
throw new Error(`Invalid global actor name: ${def.name}`);
|
|
186
|
+
const instructions = def.instructions;
|
|
187
|
+
if (!instructions.trim())
|
|
188
|
+
throw new Error("Global actor instructions must not be empty");
|
|
189
|
+
if (Buffer.byteLength(instructions, "utf8") > this.#maxBytes) {
|
|
190
|
+
throw new Error(`Global actor instructions exceed ${this.#maxBytes} bytes`);
|
|
191
|
+
}
|
|
192
|
+
const events = [...new Set(def.events ?? [])];
|
|
193
|
+
for (const event of events) {
|
|
194
|
+
if (!HOST_EVENTS.has(event))
|
|
195
|
+
throw new Error(`Unsupported global actor event: ${event}`);
|
|
196
|
+
}
|
|
197
|
+
const topics = [...new Set(def.topics ?? [])];
|
|
198
|
+
for (const topic of topics) {
|
|
199
|
+
if (!TOPIC_PATTERN.test(topic))
|
|
200
|
+
throw new Error(`Invalid global actor topic: ${topic}`);
|
|
201
|
+
}
|
|
202
|
+
const delivery = def.delivery ?? "mailbox";
|
|
203
|
+
if (!DELIVERIES.has(delivery))
|
|
204
|
+
throw new Error(`Invalid global actor delivery: ${def.delivery}`);
|
|
205
|
+
const responseMode = def.responseMode ?? "text";
|
|
206
|
+
if (!RESPONSE_MODES.has(responseMode)) {
|
|
207
|
+
throw new Error(`Invalid global actor response mode: ${def.responseMode}`);
|
|
208
|
+
}
|
|
209
|
+
const triggerTurn = def.triggerTurn ?? false;
|
|
210
|
+
const coalesce = def.coalesce ?? true;
|
|
211
|
+
const model = typeof def.model === "string" && def.model.trim() ? def.model.trim() : undefined;
|
|
212
|
+
const thinking = def.thinking !== undefined && isFabricThinking(def.thinking) ? def.thinking : undefined;
|
|
213
|
+
const tools = Array.isArray(def.tools)
|
|
214
|
+
? [...new Set(def.tools.filter((tool) => typeof tool === "string"))]
|
|
215
|
+
: undefined;
|
|
216
|
+
const transport = def.transport !== undefined && TRANSPORTS.has(def.transport) ? def.transport : undefined;
|
|
217
|
+
const timeoutMs = typeof def.timeoutMs === "number" ? def.timeoutMs : undefined;
|
|
218
|
+
return {
|
|
219
|
+
name,
|
|
220
|
+
instructions,
|
|
221
|
+
events,
|
|
222
|
+
topics,
|
|
223
|
+
delivery,
|
|
224
|
+
responseMode,
|
|
225
|
+
triggerTurn,
|
|
226
|
+
coalesce,
|
|
227
|
+
...(model ? { model } : {}),
|
|
228
|
+
...(thinking ? { thinking } : {}),
|
|
229
|
+
...(tools ? { tools } : {}),
|
|
230
|
+
...(transport ? { transport } : {}),
|
|
231
|
+
...(timeoutMs ? { timeoutMs } : {}),
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
#load() {
|
|
235
|
+
let parsed;
|
|
236
|
+
try {
|
|
237
|
+
parsed = JSON.parse(fs.readFileSync(this.#path, "utf8"));
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT")
|
|
241
|
+
return;
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
245
|
+
return;
|
|
246
|
+
const records = parsed.actors;
|
|
247
|
+
if (!Array.isArray(records))
|
|
248
|
+
return;
|
|
249
|
+
for (const value of records) {
|
|
250
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
251
|
+
continue;
|
|
252
|
+
const record = value;
|
|
253
|
+
if (typeof record.id !== "string" ||
|
|
254
|
+
!/^[a-f0-9]{32}$/.test(record.id) ||
|
|
255
|
+
typeof record.name !== "string" ||
|
|
256
|
+
!ACTOR_NAME_PATTERN.test(record.name) ||
|
|
257
|
+
typeof record.instructions !== "string" ||
|
|
258
|
+
Buffer.byteLength(record.instructions, "utf8") > this.#maxBytes ||
|
|
259
|
+
typeof record.createdAt !== "number") {
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
const events = Array.isArray(record.events)
|
|
263
|
+
? record.events.filter((event) => HOST_EVENTS.has(event))
|
|
264
|
+
: [];
|
|
265
|
+
const topics = Array.isArray(record.topics)
|
|
266
|
+
? record.topics.filter((topic) => typeof topic === "string" && TOPIC_PATTERN.test(topic))
|
|
267
|
+
: [];
|
|
268
|
+
const delivery = record.delivery === "steer" || record.delivery === "followUp" || record.delivery === "nextTurn"
|
|
269
|
+
? record.delivery
|
|
270
|
+
: "mailbox";
|
|
271
|
+
const responseMode = record.responseMode === "directive" ? "directive" : "text";
|
|
272
|
+
const triggerTurn = record.triggerTurn === true;
|
|
273
|
+
const coalesce = record.coalesce !== false;
|
|
274
|
+
const thinking = isFabricThinking(record.thinking)
|
|
275
|
+
? record.thinking
|
|
276
|
+
: undefined;
|
|
277
|
+
const tools = Array.isArray(record.tools)
|
|
278
|
+
? record.tools.filter((tool) => typeof tool === "string")
|
|
279
|
+
: undefined;
|
|
280
|
+
const transport = record.transport !== undefined && TRANSPORTS.has(record.transport) ? record.transport : undefined;
|
|
281
|
+
const timeoutMs = typeof record.timeoutMs === "number" ? record.timeoutMs : undefined;
|
|
282
|
+
const def = {
|
|
283
|
+
id: record.id,
|
|
284
|
+
name: record.name,
|
|
285
|
+
instructions: record.instructions,
|
|
286
|
+
events,
|
|
287
|
+
topics,
|
|
288
|
+
delivery,
|
|
289
|
+
responseMode,
|
|
290
|
+
triggerTurn,
|
|
291
|
+
coalesce,
|
|
292
|
+
createdAt: record.createdAt,
|
|
293
|
+
updatedAt: typeof record.updatedAt === "number" ? record.updatedAt : record.createdAt,
|
|
294
|
+
...(typeof record.model === "string" && record.model ? { model: record.model } : {}),
|
|
295
|
+
...(thinking ? { thinking } : {}),
|
|
296
|
+
...(tools ? { tools } : {}),
|
|
297
|
+
...(transport ? { transport } : {}),
|
|
298
|
+
...(timeoutMs ? { timeoutMs } : {}),
|
|
299
|
+
};
|
|
300
|
+
this.#actors.set(def.id, def);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
#save() {
|
|
304
|
+
const file = { format: 1, actors: [...this.#actors.values()] };
|
|
305
|
+
atomicWrite(this.#path, file);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
//# sourceMappingURL=global-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-registry.js","sourceRoot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AK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpF,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACjC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC3B,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACnC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACpC,CAAC;YACF,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAED,KAAK;QACH,MAAM,IAAI,GAAiB,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC;QAC7E,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAChC,CAAC;CACF"}
|
package/dist/actors/manager.d.ts
CHANGED
|
@@ -46,12 +46,34 @@ export declare class ActorManager {
|
|
|
46
46
|
* from the dashboard without stopping the actor.
|
|
47
47
|
*/
|
|
48
48
|
clearMessages(id: string): Promise<FabricActorInfo>;
|
|
49
|
+
/**
|
|
50
|
+
* Replace an existing actor's default instruction (its persona / system-prompt
|
|
51
|
+
* body). Takes effect on the actor's next queued message: #runRequest builds
|
|
52
|
+
* the system prompt from actor.instructions at run start, so an in-flight run
|
|
53
|
+
* keeps the instructions it was launched with. Lets a steering user refine an
|
|
54
|
+
* actor's role from the dashboard without recreating it.
|
|
55
|
+
*/
|
|
56
|
+
setInstructions(id: string, instructions: string): Promise<FabricActorInfo>;
|
|
49
57
|
tell(id: string, message: string, data?: unknown): {
|
|
50
58
|
queued: true;
|
|
51
59
|
messageId: string;
|
|
52
60
|
};
|
|
53
61
|
ask(id: string, message: string, data?: unknown, signal?: AbortSignal): Promise<FabricActorMessage>;
|
|
54
62
|
messages(id: string, limit?: number): FabricActorMessage[];
|
|
63
|
+
/**
|
|
64
|
+
* Read an actor's default instruction (its persona / system-prompt body).
|
|
65
|
+
* Used by the dashboard to prefill the instructions editor; deliberately not
|
|
66
|
+
* part of the mesh-presence FabricActorInfo to keep the persona text off the
|
|
67
|
+
* shared mesh state.
|
|
68
|
+
*/
|
|
69
|
+
instructions(id: string): string;
|
|
70
|
+
/**
|
|
71
|
+
* Read an actor's portable definition — the fields that cross the
|
|
72
|
+
* global⇄project boundary (name, instructions, subscriptions, run settings).
|
|
73
|
+
* Excludes all history (messages, session transcript, run logs) so export
|
|
74
|
+
* can save a project actor to the global registry with a clean slate.
|
|
75
|
+
*/
|
|
76
|
+
definition(id: string): FabricActorRequest;
|
|
55
77
|
readLog(id: string, opts?: {
|
|
56
78
|
type?: "session" | "run" | "all";
|
|
57
79
|
lines?: number;
|
|
@@ -59,6 +81,14 @@ export declare class ActorManager {
|
|
|
59
81
|
}): FabricActorLog;
|
|
60
82
|
dispatchHostEvent(event: FabricActorHostEvent, payload: unknown): number;
|
|
61
83
|
stop(id: string): Promise<FabricActorInfo>;
|
|
84
|
+
/**
|
|
85
|
+
* Whether the stop-the-world gate is currently armed. haltAll() arms it
|
|
86
|
+
* (ESC stop-the-world) and the "input" host event lifts it when the user
|
|
87
|
+
* resumes with a new message. Read-only view of the private gate so the
|
|
88
|
+
* ESC handler can treat a repeated lone Esc while already halted as a
|
|
89
|
+
* no-op rather than re-arming and re-notifying.
|
|
90
|
+
*/
|
|
91
|
+
get halted(): boolean;
|
|
62
92
|
/**
|
|
63
93
|
* Interrupt every non-stopped actor: abort its in-flight run (if any) and
|
|
64
94
|
* reject every queued message so subsequent execution is cancelled. Unlike
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager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,MAAM;IAwBlE,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAmBhD;;;;;;OAMG;IACH,IAAI,MAAM,IAAI,OAAO,CAEpB;IAED;;;;;;;;OAQG;IACH,OAAO,IAAI;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE;IA+BvB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAajD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAskB7B"}
|
package/dist/actors/manager.js
CHANGED
|
@@ -272,6 +272,26 @@ export class ActorManager {
|
|
|
272
272
|
await this.#publishPresence(actor);
|
|
273
273
|
return this.#publicInfo(actor);
|
|
274
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* Replace an existing actor's default instruction (its persona / system-prompt
|
|
277
|
+
* body). Takes effect on the actor's next queued message: #runRequest builds
|
|
278
|
+
* the system prompt from actor.instructions at run start, so an in-flight run
|
|
279
|
+
* keeps the instructions it was launched with. Lets a steering user refine an
|
|
280
|
+
* actor's role from the dashboard without recreating it.
|
|
281
|
+
*/
|
|
282
|
+
async setInstructions(id, instructions) {
|
|
283
|
+
const actor = this.#requireActor(id);
|
|
284
|
+
if (!instructions.trim())
|
|
285
|
+
throw new Error("Actor instructions must not be empty");
|
|
286
|
+
if (Buffer.byteLength(instructions, "utf8") > this.meshConfig.maxEventBytes) {
|
|
287
|
+
throw new Error(`Actor instructions exceed ${this.meshConfig.maxEventBytes} bytes`);
|
|
288
|
+
}
|
|
289
|
+
actor.instructions = instructions;
|
|
290
|
+
actor.updatedAt = Date.now();
|
|
291
|
+
this.#saveActors();
|
|
292
|
+
await this.#publishPresence(actor);
|
|
293
|
+
return this.#publicInfo(actor);
|
|
294
|
+
}
|
|
275
295
|
tell(id, message, data) {
|
|
276
296
|
this.#validateDirectMessage(message, data);
|
|
277
297
|
const actor = this.#requireActiveActor(id);
|
|
@@ -334,6 +354,39 @@ export class ActorManager {
|
|
|
334
354
|
const bounded = Math.max(1, Math.min(Math.floor(limit), MESSAGE_HISTORY_LIMIT));
|
|
335
355
|
return actor.messages.slice(-bounded).map((message) => structuredClone(message));
|
|
336
356
|
}
|
|
357
|
+
/**
|
|
358
|
+
* Read an actor's default instruction (its persona / system-prompt body).
|
|
359
|
+
* Used by the dashboard to prefill the instructions editor; deliberately not
|
|
360
|
+
* part of the mesh-presence FabricActorInfo to keep the persona text off the
|
|
361
|
+
* shared mesh state.
|
|
362
|
+
*/
|
|
363
|
+
instructions(id) {
|
|
364
|
+
return this.#requireActor(id).instructions;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Read an actor's portable definition — the fields that cross the
|
|
368
|
+
* global⇄project boundary (name, instructions, subscriptions, run settings).
|
|
369
|
+
* Excludes all history (messages, session transcript, run logs) so export
|
|
370
|
+
* can save a project actor to the global registry with a clean slate.
|
|
371
|
+
*/
|
|
372
|
+
definition(id) {
|
|
373
|
+
const actor = this.#requireActor(id);
|
|
374
|
+
return {
|
|
375
|
+
name: actor.name,
|
|
376
|
+
instructions: actor.instructions,
|
|
377
|
+
events: [...actor.events],
|
|
378
|
+
topics: [...actor.topics],
|
|
379
|
+
delivery: actor.delivery,
|
|
380
|
+
responseMode: actor.responseMode,
|
|
381
|
+
triggerTurn: actor.triggerTurn,
|
|
382
|
+
coalesce: actor.coalesce,
|
|
383
|
+
...(actor.model ? { model: actor.model } : {}),
|
|
384
|
+
...(actor.thinking ? { thinking: actor.thinking } : {}),
|
|
385
|
+
...(actor.tools ? { tools: [...actor.tools] } : {}),
|
|
386
|
+
...(actor.transport ? { transport: actor.transport } : {}),
|
|
387
|
+
...(actor.timeoutMs ? { timeoutMs: actor.timeoutMs } : {}),
|
|
388
|
+
};
|
|
389
|
+
}
|
|
337
390
|
readLog(id, opts = {}) {
|
|
338
391
|
const actor = this.#requireActor(id);
|
|
339
392
|
const type = opts.type ?? "session";
|
|
@@ -410,6 +463,16 @@ export class ActorManager {
|
|
|
410
463
|
.catch(() => undefined);
|
|
411
464
|
return this.#publicInfo(actor);
|
|
412
465
|
}
|
|
466
|
+
/**
|
|
467
|
+
* Whether the stop-the-world gate is currently armed. haltAll() arms it
|
|
468
|
+
* (ESC stop-the-world) and the "input" host event lifts it when the user
|
|
469
|
+
* resumes with a new message. Read-only view of the private gate so the
|
|
470
|
+
* ESC handler can treat a repeated lone Esc while already halted as a
|
|
471
|
+
* no-op rather than re-arming and re-notifying.
|
|
472
|
+
*/
|
|
473
|
+
get halted() {
|
|
474
|
+
return this.#halted;
|
|
475
|
+
}
|
|
413
476
|
/**
|
|
414
477
|
* Interrupt every non-stopped actor: abort its in-flight run (if any) and
|
|
415
478
|
* reject every queued message so subsequent execution is cancelled. Unlike
|