@llblab/pi-actors 0.42.2 → 0.43.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/AGENTS.md +121 -175
- package/CHANGELOG.md +16 -0
- package/README.md +113 -276
- package/dist/fixtures/protocol/control-endpoint.json +6 -0
- package/dist/fixtures/protocol/control-record.json +9 -0
- package/dist/fixtures/protocol/recipe-summary.json +4 -12
- package/dist/fixtures/protocol/trace-event.json +9 -0
- package/dist/lib/async-runs.d.ts +14 -38
- package/dist/lib/async-runs.js +158 -108
- package/dist/lib/control.d.ts +12 -0
- package/dist/lib/control.js +84 -0
- package/dist/lib/execution-sessions.d.ts +17 -0
- package/dist/lib/execution-sessions.js +85 -0
- package/dist/lib/file-state.d.ts +1 -0
- package/dist/lib/file-state.js +17 -5
- package/dist/lib/inspector-actions.d.ts +2 -2
- package/dist/lib/inspector-actions.js +2 -2
- package/dist/lib/inspector-command.js +3 -3
- package/dist/lib/inspector-overlay.d.ts +52 -70
- package/dist/lib/inspector-overlay.js +532 -905
- package/dist/lib/inspector.d.ts +3 -71
- package/dist/lib/inspector.js +19 -665
- package/dist/lib/limits.d.ts +4 -2
- package/dist/lib/limits.js +4 -2
- package/dist/lib/observability.d.ts +17 -17
- package/dist/lib/observability.js +45 -84
- package/dist/lib/pi.d.ts +1 -1
- package/dist/lib/prompts.d.ts +1 -1
- package/dist/lib/prompts.js +2 -2
- package/dist/lib/recipe-control.d.ts +7 -0
- package/dist/lib/recipe-control.js +39 -0
- package/dist/lib/recipes-discovery.js +2 -0
- package/dist/lib/recipes-references.d.ts +1 -14
- package/dist/lib/recipes-references.js +6 -21
- package/dist/lib/review-projection.js +1 -5
- package/dist/lib/run-ui-runtime.js +2 -2
- package/dist/lib/runs-control-delivery.d.ts +21 -0
- package/dist/lib/runs-control-delivery.js +127 -0
- package/dist/lib/runs-controls.d.ts +35 -0
- package/dist/lib/runs-controls.js +144 -0
- package/dist/lib/runs-retention.d.ts +7 -0
- package/dist/lib/runs-retention.js +27 -3
- package/dist/lib/runs-start.js +4 -2
- package/dist/lib/runs-status.js +11 -6
- package/dist/lib/runs-trace.d.ts +24 -0
- package/dist/lib/runs-trace.js +98 -0
- package/dist/lib/runtime-notifier.d.ts +1 -1
- package/dist/lib/runtime-notifier.js +1 -1
- package/dist/lib/tools-inspect.d.ts +3 -3
- package/dist/lib/tools-inspect.js +203 -708
- package/dist/lib/tools-local.js +2 -10
- package/dist/lib/tools-message.d.ts +7 -7
- package/dist/lib/tools-message.js +95 -396
- package/dist/lib/tools-response.d.ts +1 -4
- package/dist/lib/tools-response.js +5 -39
- package/dist/lib/tools-spawn.js +16 -28
- package/dist/lib/tools.js +1 -2
- package/dist/lib/trace-projection.d.ts +22 -0
- package/dist/lib/trace-projection.js +165 -0
- package/dist/recipes/draft-review.json +0 -10
- package/dist/recipes/lens-swarm.json +0 -14
- package/dist/recipes/music-player.json +10 -19
- package/dist/recipes/pipeline-architect-coordinator.json +0 -11
- package/dist/recipes/pipeline-artifact-bundle.json +1 -22
- package/dist/recipes/pipeline-artifact-report.json +1 -18
- package/dist/recipes/pipeline-artifact-write.json +1 -18
- package/dist/recipes/pipeline-async-run-ops.json +0 -12
- package/dist/recipes/pipeline-checkpoint-continuation.json +0 -14
- package/dist/recipes/pipeline-development-tasking.json +0 -12
- package/dist/recipes/pipeline-docs-maintenance.json +0 -12
- package/dist/recipes/pipeline-media-library.json +0 -12
- package/dist/recipes/pipeline-quorum-review.json +0 -12
- package/dist/recipes/pipeline-release-readiness.json +0 -12
- package/dist/recipes/pipeline-release-summary.json +0 -12
- package/dist/recipes/pipeline-repo-health.json +0 -12
- package/dist/recipes/pipeline-research-synthesis.json +0 -11
- package/dist/recipes/pipeline-review-readiness.json +0 -12
- package/dist/recipes/resource-locker.json +27 -0
- package/dist/recipes/subagent-artifact.json +0 -9
- package/dist/recipes/subagent-checkpoint.json +0 -10
- package/dist/recipes/subagent-conflict-report.json +0 -11
- package/dist/recipes/subagent-contradiction-map.json +0 -11
- package/dist/recipes/subagent-critic.json +0 -11
- package/dist/recipes/subagent-evidence-map.json +0 -11
- package/dist/recipes/subagent-followup.json +0 -10
- package/dist/recipes/subagent-judge.json +0 -11
- package/dist/recipes/subagent-merge.json +0 -11
- package/dist/recipes/subagent-normalize.json +0 -11
- package/dist/recipes/subagent-plan.json +0 -11
- package/dist/recipes/subagent-preflight.json +0 -11
- package/dist/recipes/subagent-prompt.json +0 -10
- package/dist/recipes/subagent-quorum.json +0 -10
- package/dist/recipes/subagent-review-coordinator.json +0 -14
- package/dist/recipes/subagent-review.json +0 -11
- package/dist/recipes/subagent-task-card.json +0 -11
- package/dist/recipes/subagent-tools.json +0 -10
- package/dist/recipes/subagent-verify.json +0 -11
- package/dist/recipes/subagents-prompts.json +0 -10
- package/dist/recipes/tool-review.json +0 -10
- package/dist/scripts/async-runner.mjs +25 -25
- package/dist/scripts/conformance.mjs +4 -2
- package/dist/scripts/locker.mjs +200 -66
- package/dist/scripts/music-player.mjs +159 -150
- package/dist/scripts/recipe-utils.mjs +6 -96
- package/dist/scripts/release-gates.mjs +60 -0
- package/dist/scripts/validate-recipe.mjs +3 -53
- package/dist/skills/actors/SKILL.md +53 -266
- package/dist/skills/swarm/SKILL.md +11 -33
- package/docs/0.43-baseline.md +44 -0
- package/docs/README.md +3 -3
- package/docs/actor-inspector.md +26 -64
- package/docs/actors-deep-reference.md +92 -50
- package/docs/async-runs.md +81 -328
- package/docs/command-templates.md +2 -2
- package/docs/component-recipes.md +30 -133
- package/docs/recipe-library.md +57 -182
- package/docs/task-first-recipes.md +10 -12
- package/docs/template-recipes.md +76 -289
- package/docs/tool-registry.md +41 -161
- package/fixtures/protocol/control-endpoint.json +6 -0
- package/fixtures/protocol/control-record.json +9 -0
- package/fixtures/protocol/recipe-summary.json +4 -12
- package/fixtures/protocol/trace-event.json +9 -0
- package/lib/async-runs.ts +202 -201
- package/lib/control.ts +102 -0
- package/lib/execution-sessions.ts +111 -0
- package/lib/file-state.ts +17 -4
- package/lib/inspector-actions.ts +2 -2
- package/lib/inspector-command.ts +3 -3
- package/lib/inspector-overlay.ts +577 -1121
- package/lib/inspector.ts +46 -979
- package/lib/limits.ts +4 -2
- package/lib/observability.ts +63 -104
- package/lib/pi.ts +1 -1
- package/lib/prompts.ts +2 -2
- package/lib/recipe-control.ts +45 -0
- package/lib/recipes-discovery.ts +2 -0
- package/lib/recipes-references.ts +9 -45
- package/lib/review-projection.ts +1 -5
- package/lib/run-ui-runtime.ts +2 -2
- package/lib/runs-control-delivery.ts +181 -0
- package/lib/runs-controls.ts +204 -0
- package/lib/runs-retention.ts +38 -3
- package/lib/runs-start.ts +4 -2
- package/lib/runs-status.ts +11 -6
- package/lib/runs-trace.ts +132 -0
- package/lib/runtime-notifier.ts +1 -1
- package/lib/tools-inspect.ts +240 -901
- package/lib/tools-local.ts +2 -12
- package/lib/tools-message.ts +112 -519
- package/lib/tools-response.ts +5 -52
- package/lib/tools-spawn.ts +16 -32
- package/lib/tools.ts +1 -2
- package/lib/trace-projection.ts +221 -0
- package/package.json +2 -1
- package/recipes/draft-review.json +0 -10
- package/recipes/lens-swarm.json +0 -14
- package/recipes/music-player.json +10 -19
- package/recipes/pipeline-architect-coordinator.json +0 -11
- package/recipes/pipeline-artifact-bundle.json +1 -22
- package/recipes/pipeline-artifact-report.json +1 -18
- package/recipes/pipeline-artifact-write.json +1 -18
- package/recipes/pipeline-async-run-ops.json +0 -12
- package/recipes/pipeline-checkpoint-continuation.json +0 -14
- package/recipes/pipeline-development-tasking.json +0 -12
- package/recipes/pipeline-docs-maintenance.json +0 -12
- package/recipes/pipeline-media-library.json +0 -12
- package/recipes/pipeline-quorum-review.json +0 -12
- package/recipes/pipeline-release-readiness.json +0 -12
- package/recipes/pipeline-release-summary.json +0 -12
- package/recipes/pipeline-repo-health.json +0 -12
- package/recipes/pipeline-research-synthesis.json +0 -11
- package/recipes/pipeline-review-readiness.json +0 -12
- package/recipes/resource-locker.json +27 -0
- package/recipes/subagent-artifact.json +0 -9
- package/recipes/subagent-checkpoint.json +0 -10
- package/recipes/subagent-conflict-report.json +0 -11
- package/recipes/subagent-contradiction-map.json +0 -11
- package/recipes/subagent-critic.json +0 -11
- package/recipes/subagent-evidence-map.json +0 -11
- package/recipes/subagent-followup.json +0 -10
- package/recipes/subagent-judge.json +0 -11
- package/recipes/subagent-merge.json +0 -11
- package/recipes/subagent-normalize.json +0 -11
- package/recipes/subagent-plan.json +0 -11
- package/recipes/subagent-preflight.json +0 -11
- package/recipes/subagent-prompt.json +0 -10
- package/recipes/subagent-quorum.json +0 -10
- package/recipes/subagent-review-coordinator.json +0 -14
- package/recipes/subagent-review.json +0 -11
- package/recipes/subagent-task-card.json +0 -11
- package/recipes/subagent-tools.json +0 -10
- package/recipes/subagent-verify.json +0 -11
- package/recipes/subagents-prompts.json +0 -10
- package/recipes/tool-review.json +0 -10
- package/scripts/async-runner.mjs +25 -25
- package/scripts/conformance.mjs +4 -2
- package/scripts/locker.mjs +200 -66
- package/scripts/music-player.mjs +159 -150
- package/scripts/recipe-utils.mjs +6 -96
- package/scripts/release-gates.mjs +60 -0
- package/scripts/validate-recipe.mjs +3 -53
- package/skills/actors/SKILL.md +53 -266
- package/skills/swarm/SKILL.md +11 -33
- package/dist/fixtures/protocol/actor-message-branch.json +0 -13
- package/dist/fixtures/protocol/mailbox-contract.json +0 -15
- package/dist/fixtures/protocol/room-message.json +0 -11
- package/dist/fixtures/protocol/room-roster.json +0 -11
- package/dist/fixtures/protocol/run-inbox-message.json +0 -9
- package/dist/fixtures/protocol/run-outbox-event.json +0 -9
- package/dist/lib/mailbox-loop.d.ts +0 -41
- package/dist/lib/mailbox-loop.js +0 -60
- package/dist/lib/messages.d.ts +0 -25
- package/dist/lib/messages.js +0 -122
- package/dist/lib/rooms.d.ts +0 -104
- package/dist/lib/rooms.js +0 -647
- package/dist/lib/runs-mailbox.d.ts +0 -25
- package/dist/lib/runs-mailbox.js +0 -146
- package/dist/lib/runs-messages.d.ts +0 -15
- package/dist/lib/runs-messages.js +0 -179
- package/dist/lib/runs-outbox.d.ts +0 -41
- package/dist/lib/runs-outbox.js +0 -87
- package/dist/lib/tools-mailbox.d.ts +0 -8
- package/dist/lib/tools-mailbox.js +0 -48
- package/dist/recipes/actor-worker.json +0 -39
- package/dist/recipes/coordinator-locker.json +0 -45
- package/dist/recipes/locker.json +0 -45
- package/dist/recipes/pipeline-room-swarm.json +0 -50
- package/dist/recipes/subagent-message.json +0 -32
- package/dist/recipes/utility-actor-message.json +0 -23
- package/dist/scripts/actor-worker.mjs +0 -214
- package/dist/scripts/coordinator.mjs +0 -799
- package/docs/actor-messages.md +0 -225
- package/fixtures/protocol/actor-message-branch.json +0 -13
- package/fixtures/protocol/mailbox-contract.json +0 -15
- package/fixtures/protocol/room-message.json +0 -11
- package/fixtures/protocol/room-roster.json +0 -11
- package/fixtures/protocol/run-inbox-message.json +0 -9
- package/fixtures/protocol/run-outbox-event.json +0 -9
- package/lib/mailbox-loop.ts +0 -144
- package/lib/messages.ts +0 -151
- package/lib/rooms.ts +0 -939
- package/lib/runs-mailbox.ts +0 -208
- package/lib/runs-messages.ts +0 -252
- package/lib/runs-outbox.ts +0 -144
- package/lib/tools-mailbox.ts +0 -56
- package/recipes/actor-worker.json +0 -39
- package/recipes/coordinator-locker.json +0 -45
- package/recipes/locker.json +0 -45
- package/recipes/pipeline-room-swarm.json +0 -50
- package/recipes/subagent-message.json +0 -32
- package/recipes/utility-actor-message.json +0 -23
- package/scripts/actor-worker.mjs +0 -214
- package/scripts/coordinator.mjs +0 -799
package/dist/lib/mailbox-loop.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mailbox worker loop primitives.
|
|
3
|
-
* Zones: mailbox-consuming actors, run/branch inbox claiming, handler status transitions
|
|
4
|
-
* Owns reusable claim/handle/drain behavior across run and branch inboxes; scheduling and task policy stay outside.
|
|
5
|
-
*/
|
|
6
|
-
import { claimBranchInboxMessage, updateBranchInboxMessageStatus, } from "./rooms.js";
|
|
7
|
-
import { claimRunInboxMessage, updateRunInboxMessageStatus, } from "./async-runs.js";
|
|
8
|
-
export function isMailboxLoopStopMessage(message) {
|
|
9
|
-
const type = message && typeof message === "object" && "type" in message
|
|
10
|
-
? message.type
|
|
11
|
-
: undefined;
|
|
12
|
-
return type === "control.kill";
|
|
13
|
-
}
|
|
14
|
-
function messageId(message) {
|
|
15
|
-
return typeof message?.id === "string" ? message.id : undefined;
|
|
16
|
-
}
|
|
17
|
-
export function claimMailboxLoopMessage(target, options = {}) {
|
|
18
|
-
const owner = options.owner ?? "mailbox-loop";
|
|
19
|
-
const statuses = options.statuses ?? ["queued"];
|
|
20
|
-
return target.kind === "run"
|
|
21
|
-
? claimRunInboxMessage(target.runOrDir, owner, statuses)
|
|
22
|
-
: claimBranchInboxMessage(target.stateDir, target.run, target.address, owner, statuses);
|
|
23
|
-
}
|
|
24
|
-
export function updateMailboxLoopMessageStatus(target, id, status, metadata = {}) {
|
|
25
|
-
return target.kind === "run"
|
|
26
|
-
? updateRunInboxMessageStatus(target.runOrDir, id, status, metadata)
|
|
27
|
-
: updateBranchInboxMessageStatus(target.stateDir, target.run, target.address, id, status, metadata);
|
|
28
|
-
}
|
|
29
|
-
export async function handleMailboxLoopOnce(target, handler, options = {}) {
|
|
30
|
-
const message = claimMailboxLoopMessage(target, options);
|
|
31
|
-
const id = messageId(message);
|
|
32
|
-
if (!message || !id)
|
|
33
|
-
return { handled: false, target };
|
|
34
|
-
try {
|
|
35
|
-
await handler(message);
|
|
36
|
-
updateMailboxLoopMessageStatus(target, id, "handled");
|
|
37
|
-
return { handled: true, id, message, target };
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
updateMailboxLoopMessageStatus(target, id, "failed", {
|
|
41
|
-
error: error instanceof Error ? error.message : String(error),
|
|
42
|
-
});
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
export async function drainMailboxLoopMessages(target, handler, options = {}) {
|
|
47
|
-
const maxMessages = Math.max(1, Math.floor(options.maxMessages ?? 100));
|
|
48
|
-
let handled = 0;
|
|
49
|
-
for (; handled < maxMessages; handled += 1) {
|
|
50
|
-
const result = await handleMailboxLoopOnce(target, handler, options);
|
|
51
|
-
if (!result.handled || !result.message) {
|
|
52
|
-
return { handled, stopped: false, target };
|
|
53
|
-
}
|
|
54
|
-
if (options.stopOnControl !== false &&
|
|
55
|
-
isMailboxLoopStopMessage(result.message)) {
|
|
56
|
-
return { handled: handled + 1, stopped: true, target };
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return { handled, stopped: false, target };
|
|
60
|
-
}
|
package/dist/lib/messages.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Actor message protocol.
|
|
3
|
-
* Zones: addressed envelopes, address parsing, route normalization
|
|
4
|
-
* Owns pure validation/normalization for semantic actor messages; transport routing stays in adapters.
|
|
5
|
-
*/
|
|
6
|
-
export type ActorAddressKind = "branch" | "coordinator" | "room" | "run" | "session" | "tool";
|
|
7
|
-
export interface ActorAddress {
|
|
8
|
-
kind: ActorAddressKind;
|
|
9
|
-
value?: string;
|
|
10
|
-
branch?: string;
|
|
11
|
-
room?: string;
|
|
12
|
-
}
|
|
13
|
-
export interface ActorMessage {
|
|
14
|
-
to: string;
|
|
15
|
-
type: string;
|
|
16
|
-
body?: unknown;
|
|
17
|
-
correlation_id?: string;
|
|
18
|
-
from?: string;
|
|
19
|
-
metadata?: Record<string, unknown>;
|
|
20
|
-
reply_to?: string;
|
|
21
|
-
summary?: string;
|
|
22
|
-
}
|
|
23
|
-
export declare function parseActorAddress(address: string): ActorAddress;
|
|
24
|
-
export declare function formatActorAddress(address: ActorAddress): string;
|
|
25
|
-
export declare function normalizeActorMessage(input: unknown): ActorMessage;
|
package/dist/lib/messages.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Actor message protocol.
|
|
3
|
-
* Zones: addressed envelopes, address parsing, route normalization
|
|
4
|
-
* Owns pure validation/normalization for semantic actor messages; transport routing stays in adapters.
|
|
5
|
-
*/
|
|
6
|
-
const ADDRESS_PATTERN = /^[A-Za-z0-9_.-]+$/;
|
|
7
|
-
const MESSAGE_TYPE_PATTERN = /^[A-Za-z][A-Za-z0-9_.:-]*$/;
|
|
8
|
-
function assertToken(value, label) {
|
|
9
|
-
const normalized = value.trim();
|
|
10
|
-
if (!normalized)
|
|
11
|
-
throw new Error(`${label} is required`);
|
|
12
|
-
if (!ADDRESS_PATTERN.test(normalized)) {
|
|
13
|
-
throw new Error(`${label} contains unsupported characters: ${value}`);
|
|
14
|
-
}
|
|
15
|
-
return normalized;
|
|
16
|
-
}
|
|
17
|
-
export function parseActorAddress(address) {
|
|
18
|
-
const value = address.trim();
|
|
19
|
-
if (value === "coordinator")
|
|
20
|
-
return { kind: "coordinator" };
|
|
21
|
-
const separator = value.indexOf(":");
|
|
22
|
-
if (separator < 0)
|
|
23
|
-
throw new Error(`Actor address must include kind: ${address}`);
|
|
24
|
-
const kind = value.slice(0, separator);
|
|
25
|
-
const rest = value.slice(separator + 1);
|
|
26
|
-
switch (kind) {
|
|
27
|
-
case "branch": {
|
|
28
|
-
const [run, branch, ...extra] = rest.split("/");
|
|
29
|
-
if (extra.length > 0)
|
|
30
|
-
throw new Error(`Branch address has too many parts: ${address}`);
|
|
31
|
-
return {
|
|
32
|
-
kind,
|
|
33
|
-
value: assertToken(run || "", "branch run"),
|
|
34
|
-
branch: assertToken(branch || "", "branch id"),
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
case "room": {
|
|
38
|
-
const [run, room, ...extra] = rest.split("/");
|
|
39
|
-
if (extra.length > 0)
|
|
40
|
-
throw new Error(`Room address has too many parts: ${address}`);
|
|
41
|
-
if (room && room !== "main") {
|
|
42
|
-
throw new Error("Task rooms do not support named subrooms; use room:<run>.");
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
kind,
|
|
46
|
-
value: assertToken(run || "", "room run"),
|
|
47
|
-
room: "main",
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
case "run":
|
|
51
|
-
case "session":
|
|
52
|
-
case "tool":
|
|
53
|
-
return { kind, value: assertToken(rest, `${kind} address`) };
|
|
54
|
-
default:
|
|
55
|
-
throw new Error(`Unsupported actor address kind: ${kind}`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
export function formatActorAddress(address) {
|
|
59
|
-
if (address.kind === "coordinator")
|
|
60
|
-
return "coordinator";
|
|
61
|
-
if (address.kind === "branch") {
|
|
62
|
-
return `branch:${assertToken(address.value || "", "branch run")}/${assertToken(address.branch || "", "branch id")}`;
|
|
63
|
-
}
|
|
64
|
-
if (address.kind === "room") {
|
|
65
|
-
return `room:${assertToken(address.value || "", "room run")}`;
|
|
66
|
-
}
|
|
67
|
-
return `${address.kind}:${assertToken(address.value || "", `${address.kind} address`)}`;
|
|
68
|
-
}
|
|
69
|
-
function normalizeOptionalString(value, label) {
|
|
70
|
-
if (value === undefined || value === null)
|
|
71
|
-
return undefined;
|
|
72
|
-
if (typeof value !== "string")
|
|
73
|
-
throw new Error(`${label} must be a string`);
|
|
74
|
-
const normalized = value.trim();
|
|
75
|
-
return normalized || undefined;
|
|
76
|
-
}
|
|
77
|
-
function normalizeMetadata(value) {
|
|
78
|
-
if (value === undefined || value === null)
|
|
79
|
-
return undefined;
|
|
80
|
-
if (typeof value !== "object" || Array.isArray(value)) {
|
|
81
|
-
throw new Error("message metadata must be an object");
|
|
82
|
-
}
|
|
83
|
-
return value;
|
|
84
|
-
}
|
|
85
|
-
export function normalizeActorMessage(input) {
|
|
86
|
-
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
87
|
-
throw new Error("actor message must be an object");
|
|
88
|
-
}
|
|
89
|
-
const record = input;
|
|
90
|
-
const to = normalizeOptionalString(record.to, "message.to");
|
|
91
|
-
if (!to)
|
|
92
|
-
throw new Error("message.to is required");
|
|
93
|
-
const parsedTo = parseActorAddress(to);
|
|
94
|
-
const type = normalizeOptionalString(record.type, "message.type");
|
|
95
|
-
if (!type)
|
|
96
|
-
throw new Error("message.type is required");
|
|
97
|
-
if (!MESSAGE_TYPE_PATTERN.test(type)) {
|
|
98
|
-
throw new Error(`message.type contains unsupported characters: ${type}`);
|
|
99
|
-
}
|
|
100
|
-
const from = normalizeOptionalString(record.from, "message.from");
|
|
101
|
-
if (from)
|
|
102
|
-
parseActorAddress(from);
|
|
103
|
-
const normalizedTo = formatActorAddress(parsedTo);
|
|
104
|
-
return {
|
|
105
|
-
to: normalizedTo,
|
|
106
|
-
type,
|
|
107
|
-
...(record.body !== undefined ? { body: record.body } : {}),
|
|
108
|
-
...(record.correlation_id !== undefined
|
|
109
|
-
? { correlation_id: String(record.correlation_id) }
|
|
110
|
-
: {}),
|
|
111
|
-
...(from ? { from: formatActorAddress(parseActorAddress(from)) } : {}),
|
|
112
|
-
...(record.metadata !== undefined
|
|
113
|
-
? { metadata: normalizeMetadata(record.metadata) }
|
|
114
|
-
: {}),
|
|
115
|
-
...(record.reply_to !== undefined
|
|
116
|
-
? { reply_to: String(record.reply_to) }
|
|
117
|
-
: {}),
|
|
118
|
-
...(record.summary !== undefined
|
|
119
|
-
? { summary: String(record.summary) }
|
|
120
|
-
: {}),
|
|
121
|
-
};
|
|
122
|
-
}
|
package/dist/lib/rooms.d.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Actor room persistence.
|
|
3
|
-
* Zones: room timelines, rosters, branch inboxes, cross-branch discovery state
|
|
4
|
-
* Owns file-backed room and branch-mailbox state; routing policy stays in tools/runtime adapters.
|
|
5
|
-
*/
|
|
6
|
-
import type { ActorMessage } from "./messages.ts";
|
|
7
|
-
export interface RoomMember {
|
|
8
|
-
address: string;
|
|
9
|
-
caps?: unknown;
|
|
10
|
-
claim?: unknown;
|
|
11
|
-
display?: unknown;
|
|
12
|
-
joined_at: string;
|
|
13
|
-
last_seen: string;
|
|
14
|
-
parent?: unknown;
|
|
15
|
-
role?: unknown;
|
|
16
|
-
status?: string;
|
|
17
|
-
}
|
|
18
|
-
export interface RoomTimelineEntry extends ActorMessage {
|
|
19
|
-
received_at: string;
|
|
20
|
-
}
|
|
21
|
-
export interface RoomAppendResult {
|
|
22
|
-
room: string;
|
|
23
|
-
message_count: number;
|
|
24
|
-
roster_count: number;
|
|
25
|
-
sent: true;
|
|
26
|
-
}
|
|
27
|
-
export interface RoomMessagePreview {
|
|
28
|
-
body_preview?: string;
|
|
29
|
-
from?: string;
|
|
30
|
-
summary?: string;
|
|
31
|
-
timestamp: string;
|
|
32
|
-
to: string;
|
|
33
|
-
type: string;
|
|
34
|
-
}
|
|
35
|
-
export interface RoomCompactionInfo {
|
|
36
|
-
compacted_at: string;
|
|
37
|
-
dropped_count: number;
|
|
38
|
-
first_kept_at?: string;
|
|
39
|
-
last_kept_at?: string;
|
|
40
|
-
max_messages: number;
|
|
41
|
-
}
|
|
42
|
-
export interface RoomStatus {
|
|
43
|
-
room: string;
|
|
44
|
-
message_count: number;
|
|
45
|
-
roster_count: number;
|
|
46
|
-
compaction?: RoomCompactionInfo;
|
|
47
|
-
diagnostics?: string[];
|
|
48
|
-
diagnostics_count?: number;
|
|
49
|
-
last_message_at?: string;
|
|
50
|
-
last_message_from?: string;
|
|
51
|
-
last_message_summary?: string;
|
|
52
|
-
last_message_type?: string;
|
|
53
|
-
}
|
|
54
|
-
export interface RoomContact {
|
|
55
|
-
address: string;
|
|
56
|
-
caps?: unknown;
|
|
57
|
-
claim?: unknown;
|
|
58
|
-
parent?: unknown;
|
|
59
|
-
role?: unknown;
|
|
60
|
-
status?: string;
|
|
61
|
-
}
|
|
62
|
-
export interface ActorCommunicationSnapshot {
|
|
63
|
-
contacts?: RoomContact[];
|
|
64
|
-
parent?: string;
|
|
65
|
-
root: string;
|
|
66
|
-
self: string;
|
|
67
|
-
rooms: Array<{
|
|
68
|
-
address: string;
|
|
69
|
-
members?: RoomMember[];
|
|
70
|
-
name: string;
|
|
71
|
-
}>;
|
|
72
|
-
updated_at: string;
|
|
73
|
-
}
|
|
74
|
-
export declare function readRoomRoster(stateDir: string, room: string): Record<string, RoomMember>;
|
|
75
|
-
export interface BranchInboxRecord extends ActorMessage {
|
|
76
|
-
claimed_at?: string;
|
|
77
|
-
claimed_by?: string;
|
|
78
|
-
error?: string;
|
|
79
|
-
failed_at?: string;
|
|
80
|
-
handled_at?: string;
|
|
81
|
-
id?: string;
|
|
82
|
-
queued_at?: string;
|
|
83
|
-
status?: string;
|
|
84
|
-
}
|
|
85
|
-
export interface BranchInboxReadResult {
|
|
86
|
-
corrupted: number;
|
|
87
|
-
messages: BranchInboxRecord[];
|
|
88
|
-
}
|
|
89
|
-
export declare function readBranchInboxMessages(stateDir: string, run: string, address: string, limit?: number): BranchInboxRecord[];
|
|
90
|
-
export declare function readBranchInboxDiagnostics(stateDir: string, run: string, address: string, limit?: number): BranchInboxReadResult;
|
|
91
|
-
export declare function getBranchInboxTerminalRetainLimit(): number;
|
|
92
|
-
export declare function appendBranchInboxMessage(stateDir: string, run: string, address: string, message: ActorMessage): void;
|
|
93
|
-
export declare function claimBranchInboxMessage(stateDir: string, run: string, address: string, owner?: string, statuses?: string[]): BranchInboxRecord | undefined;
|
|
94
|
-
export declare function updateBranchInboxMessageStatus(stateDir: string, run: string, address: string, id: string, status: "claimed" | "handled" | "failed", metadata?: Record<string, unknown>): boolean;
|
|
95
|
-
export declare function appendRoomMessage(stateDir: string, room: string, message: ActorMessage): RoomAppendResult;
|
|
96
|
-
export declare function readRoomMessages(stateDir: string, room: string, limit?: number): RoomTimelineEntry[];
|
|
97
|
-
export declare function readRoomMessagePreviews(stateDir: string, room: string, limit?: number): RoomMessagePreview[];
|
|
98
|
-
export declare function getRoomStatus(stateDir: string, room: string): RoomStatus;
|
|
99
|
-
export declare function ensureRoomMember(stateDir: string, run: string, room: string, address: string, body: Record<string, unknown>, summary: string): RoomAppendResult;
|
|
100
|
-
export declare function ensureDefaultRoom(stateDir: string, run: string): RoomAppendResult;
|
|
101
|
-
export declare function readCommunicationSnapshot(stateDir: string): ActorCommunicationSnapshot | undefined;
|
|
102
|
-
export declare function readRoomContacts(stateDir: string, room: string, self?: string): RoomContact[];
|
|
103
|
-
export declare function writeCommunicationSnapshot(stateDir: string, run: string): ActorCommunicationSnapshot;
|
|
104
|
-
export declare function writeBranchCommunicationSnapshot(stateDir: string, run: string, self: string): ActorCommunicationSnapshot;
|