@animalabs/agent-framework 0.29.0 → 0.31.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 +71 -8
- package/dist/src/admission/admit.d.ts +90 -0
- package/dist/src/admission/admit.d.ts.map +1 -0
- package/dist/src/admission/admit.js +43 -0
- package/dist/src/admission/admit.js.map +1 -0
- package/dist/src/agent.d.ts +50 -9
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +125 -23
- package/dist/src/agent.js.map +1 -1
- package/dist/src/api/mcp-server-core.d.ts.map +1 -1
- package/dist/src/api/mcp-server-core.js +10 -3
- package/dist/src/api/mcp-server-core.js.map +1 -1
- package/dist/src/author-presentation.d.ts +50 -0
- package/dist/src/author-presentation.d.ts.map +1 -0
- package/dist/src/author-presentation.js +58 -0
- package/dist/src/author-presentation.js.map +1 -0
- package/dist/src/code-execution/isolate/render.d.ts.map +1 -1
- package/dist/src/code-execution/isolate/render.js +7 -6
- package/dist/src/code-execution/isolate/render.js.map +1 -1
- package/dist/src/code-execution/isolate/scripts.d.ts.map +1 -1
- package/dist/src/code-execution/isolate/scripts.js +5 -4
- package/dist/src/code-execution/isolate/scripts.js.map +1 -1
- package/dist/src/dendrite/index.d.ts +6 -0
- package/dist/src/dendrite/index.d.ts.map +1 -0
- package/dist/src/dendrite/index.js +3 -0
- package/dist/src/dendrite/index.js.map +1 -0
- package/dist/src/dendrite/presets.d.ts +60 -0
- package/dist/src/dendrite/presets.d.ts.map +1 -0
- package/dist/src/dendrite/presets.js +117 -0
- package/dist/src/dendrite/presets.js.map +1 -0
- package/dist/src/dendrite/registry.d.ts +260 -0
- package/dist/src/dendrite/registry.d.ts.map +1 -0
- package/dist/src/dendrite/registry.js +742 -0
- package/dist/src/dendrite/registry.js.map +1 -0
- package/dist/src/dendrite/types.d.ts +392 -0
- package/dist/src/dendrite/types.d.ts.map +1 -0
- package/dist/src/dendrite/types.js +24 -0
- package/dist/src/dendrite/types.js.map +1 -0
- package/dist/src/framework.d.ts +806 -118
- package/dist/src/framework.d.ts.map +1 -1
- package/dist/src/framework.js +4180 -1121
- package/dist/src/framework.js.map +1 -1
- package/dist/src/gate/event-gate.d.ts +36 -21
- package/dist/src/gate/event-gate.d.ts.map +1 -1
- package/dist/src/gate/event-gate.js +223 -149
- package/dist/src/gate/event-gate.js.map +1 -1
- package/dist/src/gate/recipe-reconcile.d.ts.map +1 -1
- package/dist/src/gate/recipe-reconcile.js +6 -5
- package/dist/src/gate/recipe-reconcile.js.map +1 -1
- package/dist/src/host-presentation.d.ts +4 -0
- package/dist/src/host-presentation.d.ts.map +1 -1
- package/dist/src/host-presentation.js +12 -10
- package/dist/src/host-presentation.js.map +1 -1
- package/dist/src/index.d.ts +6 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +7 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/inference-bounds.d.ts +37 -0
- package/dist/src/inference-bounds.d.ts.map +1 -0
- package/dist/src/inference-bounds.js +84 -0
- package/dist/src/inference-bounds.js.map +1 -0
- package/dist/src/line-reader.d.ts +7 -1
- package/dist/src/line-reader.d.ts.map +1 -1
- package/dist/src/line-reader.js +17 -6
- package/dist/src/line-reader.js.map +1 -1
- package/dist/src/mcpl/channel-registry.d.ts +84 -9
- package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
- package/dist/src/mcpl/channel-registry.js +136 -58
- package/dist/src/mcpl/channel-registry.js.map +1 -1
- package/dist/src/mcpl/errors.d.ts +1 -0
- package/dist/src/mcpl/errors.d.ts.map +1 -1
- package/dist/src/mcpl/errors.js +3 -0
- package/dist/src/mcpl/errors.js.map +1 -1
- package/dist/src/mcpl/inbound-source.d.ts +2 -2
- package/dist/src/mcpl/inbound-source.js +2 -2
- package/dist/src/mcpl/inference-router.d.ts +11 -1
- package/dist/src/mcpl/inference-router.d.ts.map +1 -1
- package/dist/src/mcpl/inference-router.js +65 -9
- package/dist/src/mcpl/inference-router.js.map +1 -1
- package/dist/src/mcpl/modern-connection.d.ts +10 -7
- package/dist/src/mcpl/modern-connection.d.ts.map +1 -1
- package/dist/src/mcpl/modern-connection.js +85 -74
- package/dist/src/mcpl/modern-connection.js.map +1 -1
- package/dist/src/mcpl/protocol-family.d.ts +1 -1
- package/dist/src/mcpl/protocol-family.d.ts.map +1 -1
- package/dist/src/mcpl/protocol-family.js +45 -3
- package/dist/src/mcpl/protocol-family.js.map +1 -1
- package/dist/src/mcpl/push-coalescer.d.ts +11 -7
- package/dist/src/mcpl/push-coalescer.d.ts.map +1 -1
- package/dist/src/mcpl/push-coalescer.js +21 -0
- package/dist/src/mcpl/push-coalescer.js.map +1 -1
- package/dist/src/mcpl/references.d.ts +1 -2
- package/dist/src/mcpl/references.d.ts.map +1 -1
- package/dist/src/mcpl/references.js +3 -3
- package/dist/src/mcpl/references.js.map +1 -1
- package/dist/src/mcpl/server-connection.d.ts +14 -0
- package/dist/src/mcpl/server-connection.d.ts.map +1 -1
- package/dist/src/mcpl/server-connection.js +26 -22
- package/dist/src/mcpl/server-connection.js.map +1 -1
- package/dist/src/mcpl/tool-signature.d.ts +1 -0
- package/dist/src/mcpl/tool-signature.d.ts.map +1 -1
- package/dist/src/mcpl/tool-signature.js +16 -11
- package/dist/src/mcpl/tool-signature.js.map +1 -1
- package/dist/src/mcpl/toolsets-module.d.ts.map +1 -1
- package/dist/src/mcpl/toolsets-module.js +7 -0
- package/dist/src/mcpl/toolsets-module.js.map +1 -1
- package/dist/src/mcpl/transport.d.ts +44 -21
- package/dist/src/mcpl/transport.d.ts.map +1 -1
- package/dist/src/mcpl/transport.js +283 -64
- package/dist/src/mcpl/transport.js.map +1 -1
- package/dist/src/mcpl/types.d.ts +17 -1
- package/dist/src/mcpl/types.d.ts.map +1 -1
- package/dist/src/mcpl/types.js.map +1 -1
- package/dist/src/module-registry.d.ts +32 -4
- package/dist/src/module-registry.d.ts.map +1 -1
- package/dist/src/module-registry.js +189 -25
- package/dist/src/module-registry.js.map +1 -1
- package/dist/src/modules/discord/discord-js-client.d.ts.map +1 -1
- package/dist/src/modules/discord/discord-js-client.js +24 -16
- package/dist/src/modules/discord/discord-js-client.js.map +1 -1
- package/dist/src/modules/sender-name.d.ts +5 -4
- package/dist/src/modules/sender-name.d.ts.map +1 -1
- package/dist/src/modules/sender-name.js +7 -5
- package/dist/src/modules/sender-name.js.map +1 -1
- package/dist/src/modules/workspace/disk-agreement.d.ts +16 -8
- package/dist/src/modules/workspace/disk-agreement.d.ts.map +1 -1
- package/dist/src/modules/workspace/disk-agreement.js +33 -12
- package/dist/src/modules/workspace/disk-agreement.js.map +1 -1
- package/dist/src/modules/workspace/index.d.ts +6 -3
- package/dist/src/modules/workspace/index.d.ts.map +1 -1
- package/dist/src/modules/workspace/index.js +61 -15
- package/dist/src/modules/workspace/index.js.map +1 -1
- package/dist/src/modules/workspace/observe.d.ts +9 -1
- package/dist/src/modules/workspace/observe.d.ts.map +1 -1
- package/dist/src/modules/workspace/observe.js +50 -10
- package/dist/src/modules/workspace/observe.js.map +1 -1
- package/dist/src/modules/workspace/reconcile.d.ts +11 -1
- package/dist/src/modules/workspace/reconcile.d.ts.map +1 -1
- package/dist/src/modules/workspace/reconcile.js +19 -8
- package/dist/src/modules/workspace/reconcile.js.map +1 -1
- package/dist/src/modules/workspace/types.d.ts +8 -0
- package/dist/src/modules/workspace/types.d.ts.map +1 -1
- package/dist/src/modules/workspace/types.js.map +1 -1
- package/dist/src/modules/workspace/watcher.d.ts +7 -0
- package/dist/src/modules/workspace/watcher.d.ts.map +1 -1
- package/dist/src/modules/workspace/watcher.js +7 -5
- package/dist/src/modules/workspace/watcher.js.map +1 -1
- package/dist/src/notice-tags.d.ts +2 -0
- package/dist/src/notice-tags.d.ts.map +1 -1
- package/dist/src/notice-tags.js +2 -0
- package/dist/src/notice-tags.js.map +1 -1
- package/dist/src/recovery/discord-awareness-outbox.d.ts.map +1 -1
- package/dist/src/recovery/discord-awareness-outbox.js +1 -9
- package/dist/src/recovery/discord-awareness-outbox.js.map +1 -1
- package/dist/src/silent-heartbeat.d.ts +4 -2
- package/dist/src/silent-heartbeat.d.ts.map +1 -1
- package/dist/src/silent-heartbeat.js +7 -4
- package/dist/src/silent-heartbeat.js.map +1 -1
- package/dist/src/stored-injections.d.ts +4 -0
- package/dist/src/stored-injections.d.ts.map +1 -1
- package/dist/src/stored-injections.js +6 -0
- package/dist/src/stored-injections.js.map +1 -1
- package/dist/src/supplied-text.d.ts +2 -0
- package/dist/src/supplied-text.d.ts.map +1 -1
- package/dist/src/supplied-text.js +16 -7
- package/dist/src/supplied-text.js.map +1 -1
- package/dist/src/tool-result-guard.js +1 -1
- package/dist/src/tool-result-guard.js.map +1 -1
- package/dist/src/tune-out/coordinator.d.ts +368 -16
- package/dist/src/tune-out/coordinator.d.ts.map +1 -1
- package/dist/src/tune-out/coordinator.js +1224 -136
- package/dist/src/tune-out/coordinator.js.map +1 -1
- package/dist/src/tune-out/tools.d.ts +115 -7
- package/dist/src/tune-out/tools.d.ts.map +1 -1
- package/dist/src/tune-out/tools.js +55 -18
- package/dist/src/tune-out/tools.js.map +1 -1
- package/dist/src/types/agent.d.ts +27 -1
- package/dist/src/types/agent.d.ts.map +1 -1
- package/dist/src/types/framework.d.ts +153 -15
- package/dist/src/types/framework.d.ts.map +1 -1
- package/dist/src/types/module.d.ts +42 -3
- package/dist/src/types/module.d.ts.map +1 -1
- package/dist/src/types/trace.d.ts +140 -3
- package/dist/src/types/trace.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/admission/admit.ts +113 -0
- package/src/agent.ts +138 -31
- package/src/api/mcp-server-core.ts +10 -3
- package/src/author-presentation.ts +81 -0
- package/src/code-execution/isolate/render.ts +7 -6
- package/src/code-execution/isolate/scripts.ts +5 -4
- package/src/dendrite/index.ts +32 -0
- package/src/dendrite/presets.ts +149 -0
- package/src/dendrite/registry.ts +808 -0
- package/src/dendrite/types.ts +397 -0
- package/src/framework.ts +4344 -1052
- package/src/gate/event-gate.ts +251 -150
- package/src/gate/recipe-reconcile.ts +7 -5
- package/src/host-presentation.ts +14 -10
- package/src/index.ts +16 -2
- package/src/inference-bounds.ts +111 -0
- package/src/line-reader.ts +22 -5
- package/src/mcpl/channel-registry.ts +170 -60
- package/src/mcpl/errors.ts +4 -0
- package/src/mcpl/inbound-source.ts +2 -2
- package/src/mcpl/inference-router.ts +67 -10
- package/src/mcpl/modern-connection.ts +83 -68
- package/src/mcpl/protocol-family.ts +37 -4
- package/src/mcpl/push-coalescer.ts +21 -7
- package/src/mcpl/references.ts +3 -4
- package/src/mcpl/server-connection.ts +30 -21
- package/src/mcpl/tool-signature.ts +18 -11
- package/src/mcpl/toolsets-module.ts +7 -0
- package/src/mcpl/transport.ts +261 -60
- package/src/mcpl/types.ts +18 -1
- package/src/module-registry.ts +178 -25
- package/src/modules/discord/discord-js-client.ts +33 -29
- package/src/modules/sender-name.ts +8 -5
- package/src/modules/workspace/disk-agreement.ts +39 -15
- package/src/modules/workspace/index.ts +65 -14
- package/src/modules/workspace/observe.ts +51 -10
- package/src/modules/workspace/reconcile.ts +22 -8
- package/src/modules/workspace/types.ts +5 -0
- package/src/modules/workspace/watcher.ts +8 -6
- package/src/notice-tags.ts +2 -0
- package/src/recovery/discord-awareness-outbox.ts +1 -11
- package/src/silent-heartbeat.ts +7 -4
- package/src/stored-injections.ts +7 -0
- package/src/supplied-text.ts +17 -6
- package/src/tool-result-guard.ts +1 -1
- package/src/tune-out/coordinator.ts +1374 -141
- package/src/tune-out/tools.ts +166 -13
- package/src/types/agent.ts +30 -1
- package/src/types/framework.ts +157 -15
- package/src/types/module.ts +42 -3
- package/src/types/trace.ts +154 -3
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentRegistry — the one place that knows which agents exist, what they
|
|
3
|
+
* are for, how they relate and what ends them.
|
|
4
|
+
*
|
|
5
|
+
* Pure bookkeeping: it never touches a stream, a context manager or a
|
|
6
|
+
* channel. Lifecycle methods return what changed (who ended, who was
|
|
7
|
+
* orphaned, which mail became deliverable) and the framework performs the
|
|
8
|
+
* side effects. That split keeps every rule here testable without a store
|
|
9
|
+
* and keeps the framework from re-deriving policy at each call site.
|
|
10
|
+
*/
|
|
11
|
+
import type { AgentEndReason, AgentName, AgentRecord, AgentRef, AgentSpec, EndOutcome, HeldMail, RegistrySnapshot } from './types.js';
|
|
12
|
+
/** Thrown for a spec the registry refuses to load. */
|
|
13
|
+
export declare class AgentSpecError extends Error {
|
|
14
|
+
constructor(agent: string, problem: string);
|
|
15
|
+
}
|
|
16
|
+
export interface AgentRegistryOptions {
|
|
17
|
+
now?: () => number;
|
|
18
|
+
/** Called after every durable mutation with the state to persist. */
|
|
19
|
+
persist?: (snapshot: RegistrySnapshot) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Called once per ended record. Ended records are append-only history,
|
|
22
|
+
* kept out of the snapshot so a mutation never rewrites them.
|
|
23
|
+
*/
|
|
24
|
+
appendEnded?: (record: AgentRecord) => void;
|
|
25
|
+
/** How many ended records stay inspectable in memory (oldest dropped first). */
|
|
26
|
+
endedRetention?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Told when a write that records something that has already happened — a
|
|
29
|
+
* release, a held mark, a message path — fails. The change stays in memory
|
|
30
|
+
* and the next write carries it; the call that made it is not failed, since
|
|
31
|
+
* what it records is done (nissa's #546 review, round 2). Absent, the
|
|
32
|
+
* failure is logged.
|
|
33
|
+
*/
|
|
34
|
+
onRecordWriteFailed?: (what: string, error: unknown) => void;
|
|
35
|
+
/** Told after a change that failed was put back in memory (a requested change, or a hold): the host rewrites what it wrote alongside to match. */
|
|
36
|
+
onRollback?: () => void;
|
|
37
|
+
/**
|
|
38
|
+
* Asked for an ended record no longer in memory (past `endedRetention`):
|
|
39
|
+
* the host reads its durable ended log, so an agent that ended long ago
|
|
40
|
+
* can still be inspected, resumed and named.
|
|
41
|
+
*/
|
|
42
|
+
findEnded?: (name: AgentName) => AgentRecord | undefined;
|
|
43
|
+
}
|
|
44
|
+
/** What a restore found that the previous process left unfinished. */
|
|
45
|
+
export interface RestoreOutcome {
|
|
46
|
+
/** Non-persistent agents that were live when the previous process stopped. */
|
|
47
|
+
interrupted: AgentRecord[];
|
|
48
|
+
}
|
|
49
|
+
/** What boot reconciliation concluded once configuration was applied. */
|
|
50
|
+
export interface ReconcileOutcome {
|
|
51
|
+
/** Persistent agents the previous process ran that this configuration no longer declares. */
|
|
52
|
+
unconfigured: EndOutcome[];
|
|
53
|
+
}
|
|
54
|
+
export declare class AgentRegistry {
|
|
55
|
+
private readonly live;
|
|
56
|
+
/** Ended records, oldest first. */
|
|
57
|
+
private ended;
|
|
58
|
+
/** Persistent records from the previous process, not yet re-declared. */
|
|
59
|
+
private readonly awaiting;
|
|
60
|
+
/**
|
|
61
|
+
* Bounded work the previous process left live, ended by this restart in
|
|
62
|
+
* memory but kept in the snapshot as it was until the host has told each
|
|
63
|
+
* recipient (settleInterrupted), so a crash before then owes the same
|
|
64
|
+
* notices at the next boot rather than none.
|
|
65
|
+
*/
|
|
66
|
+
private readonly interruptedPending;
|
|
67
|
+
private readonly incarnations;
|
|
68
|
+
private mail;
|
|
69
|
+
private readonly now;
|
|
70
|
+
private readonly persistFn?;
|
|
71
|
+
private readonly appendEndedFn?;
|
|
72
|
+
private readonly endedRetention;
|
|
73
|
+
private readonly onRecordWriteFailed;
|
|
74
|
+
private readonly onRollback?;
|
|
75
|
+
private readonly findEnded?;
|
|
76
|
+
/** Above zero while a record of what happened is being written: its writes alert rather than throw. */
|
|
77
|
+
private recordingDepth;
|
|
78
|
+
constructor(options?: AgentRegistryOptions);
|
|
79
|
+
/**
|
|
80
|
+
* Admit an agent. Refuses a spec that breaks a registry invariant — an
|
|
81
|
+
* unbounded task, a second default-delivery owner, a relationship that
|
|
82
|
+
* names nobody — so a malformed agent fails at load, not mid-run.
|
|
83
|
+
*
|
|
84
|
+
* `resume` admits a new incarnation of an identity that ended: where its
|
|
85
|
+
* context came from is then history, so the context source no longer has
|
|
86
|
+
* to be live. Who it reports to still does. A spawner that has ended, and
|
|
87
|
+
* a result route to it, are admitted: the agent registers as that
|
|
88
|
+
* spawner's orphan, as if it had been live when the spawner ended.
|
|
89
|
+
* `after` is the incarnation a resumption continues from: the new one is
|
|
90
|
+
* past it, since the counter of a name that aged out of memory isn't kept.
|
|
91
|
+
*/
|
|
92
|
+
register(spec: AgentSpec, options?: {
|
|
93
|
+
resume?: boolean;
|
|
94
|
+
after?: number;
|
|
95
|
+
}): AgentRecord;
|
|
96
|
+
private registerUnguarded;
|
|
97
|
+
private validate;
|
|
98
|
+
/** A live agent's record. */
|
|
99
|
+
get(name: AgentName): AgentRecord | undefined;
|
|
100
|
+
has(name: AgentName): boolean;
|
|
101
|
+
/** The live record, else the most recent ended one with that name, from memory or the host's ended log. */
|
|
102
|
+
inspect(name: AgentName): AgentRecord | undefined;
|
|
103
|
+
/** Flat list of agents — the discovery surface. Ended ones on request. */
|
|
104
|
+
list(options?: {
|
|
105
|
+
includeEnded?: boolean;
|
|
106
|
+
}): AgentRecord[];
|
|
107
|
+
/**
|
|
108
|
+
* An agent other than `except` whose own context a namespace holds, among
|
|
109
|
+
* the records in memory: live, awaiting re-declaration, or ended. A shared
|
|
110
|
+
* fork's record names its parent's namespace, where it owns only a branch,
|
|
111
|
+
* so it holds none.
|
|
112
|
+
* @internal For the framework's namespace check in
|
|
113
|
+
* `createEphemeralAgent()`; not a host API.
|
|
114
|
+
*/
|
|
115
|
+
namespaceHolder(namespace: string, except: AgentName): AgentName | undefined;
|
|
116
|
+
/** Provenance stamp for a live agent (or its last incarnation). */
|
|
117
|
+
ref(name: AgentName): AgentRef;
|
|
118
|
+
/** The agent that owns default delivery, if any. */
|
|
119
|
+
primary(): AgentName | null;
|
|
120
|
+
/** Recipients of untargeted inbound, in registration order. */
|
|
121
|
+
untargetedRecipients(): AgentName[];
|
|
122
|
+
/** Recipients of host-wide gate fan-out, in registration order. */
|
|
123
|
+
gateRecipients(): AgentName[];
|
|
124
|
+
ownsProviderScheduling(name: AgentName): boolean;
|
|
125
|
+
/** Agents reading the residents' shared message slot. */
|
|
126
|
+
sharedSlotReaders(): AgentName[];
|
|
127
|
+
readsSharedSlot(name: AgentName): boolean;
|
|
128
|
+
/** The channel an agent is bound to, if it has one. */
|
|
129
|
+
homeChannel(name: AgentName): AgentRecord['homeChannel'];
|
|
130
|
+
/** Live agents of one preset label. Discovery only — see {@link AgentKind}. */
|
|
131
|
+
ofKind(kind: string): AgentRecord[];
|
|
132
|
+
private namesWhere;
|
|
133
|
+
/** Live agents this one spawned. */
|
|
134
|
+
children(name: AgentName): AgentRecord[];
|
|
135
|
+
/** Live spawn ancestors, nearest first. */
|
|
136
|
+
ancestors(name: AgentName): AgentName[];
|
|
137
|
+
/** Live agents whose completed work returns to `name`. */
|
|
138
|
+
resultSources(name: AgentName): AgentRecord[];
|
|
139
|
+
/** Record that `from` used an explicit message path to `to`. */
|
|
140
|
+
noteMessagePath(from: AgentName, to: AgentName): void;
|
|
141
|
+
/**
|
|
142
|
+
* End an agent identity. Attention tenants it spawned end with it; task
|
|
143
|
+
* work it spawned is orphaned, with reparenting candidates. Result routes
|
|
144
|
+
* that pointed at it are left in place — delivery holds the mail instead
|
|
145
|
+
* of dropping it, so a later adoption can still receive the result.
|
|
146
|
+
*/
|
|
147
|
+
/**
|
|
148
|
+
* End an agent. A stop a caller asks for is a requested change: a write that
|
|
149
|
+
* fails puts memory back and fails the call. A run's own end or an idle
|
|
150
|
+
* reap (`record: true`) records what has already happened: a write that
|
|
151
|
+
* fails alerts, and the next write carries it (nissa's #546 review, round 3).
|
|
152
|
+
*/
|
|
153
|
+
end(name: AgentName, reason: AgentEndReason, by?: string, options?: {
|
|
154
|
+
record?: boolean;
|
|
155
|
+
}): EndOutcome | null;
|
|
156
|
+
private endUnguarded;
|
|
157
|
+
private endRecursive;
|
|
158
|
+
/** Who could take over an ending agent's children: nearest live ancestor, then the primary. */
|
|
159
|
+
private adoptionCandidates;
|
|
160
|
+
/**
|
|
161
|
+
* Give an agent a new spawner. Clears orphan state. A result route whose
|
|
162
|
+
* recipient is gone follows the new parent, and mail the agent already
|
|
163
|
+
* produced for the lost recipient is re-addressed and returned so the
|
|
164
|
+
* caller can deliver it.
|
|
165
|
+
*/
|
|
166
|
+
reparent(name: AgentName, newParent: AgentName): {
|
|
167
|
+
record: AgentRecord;
|
|
168
|
+
deliverable: HeldMail[];
|
|
169
|
+
};
|
|
170
|
+
private reparentUnguarded;
|
|
171
|
+
/**
|
|
172
|
+
* An ended agent's held mail finds a new recipient: every item it produced
|
|
173
|
+
* for a recipient that is gone (a result or a message, as `reparent`
|
|
174
|
+
* moves for a live agent) is re-addressed to `newParent` and returned for
|
|
175
|
+
* delivery. Its record stays as it ended, since history isn't reparented.
|
|
176
|
+
* @internal For the framework's `reparentAgent()` of an ended agent; not a host API.
|
|
177
|
+
*/
|
|
178
|
+
readdressHeldMail(name: AgentName, newParent: AgentName): {
|
|
179
|
+
record: AgentRecord;
|
|
180
|
+
deliverable: HeldMail[];
|
|
181
|
+
};
|
|
182
|
+
/** Record a communication durably BEFORE attempting delivery. */
|
|
183
|
+
holdMail(mail: Omit<HeldMail, 'id' | 'createdAt'> & {
|
|
184
|
+
id?: string;
|
|
185
|
+
}): HeldMail;
|
|
186
|
+
/** Delivery confirmed: forget the held copy. */
|
|
187
|
+
releaseMail(id: string): void;
|
|
188
|
+
/** Mark why an item is still held (delivery attempted and not possible yet). */
|
|
189
|
+
markMailHeld(id: string, because: NonNullable<HeldMail['heldBecause']>): void;
|
|
190
|
+
listMail(filter?: {
|
|
191
|
+
to?: AgentName;
|
|
192
|
+
from?: AgentName;
|
|
193
|
+
}): HeldMail[];
|
|
194
|
+
snapshot(): RegistrySnapshot;
|
|
195
|
+
/**
|
|
196
|
+
* Load what the previous process persisted. Restart behaviour follows
|
|
197
|
+
* from lifetime: a persistent agent waits to be re-declared by
|
|
198
|
+
* configuration (see {@link reconcile}); every other agent that was live
|
|
199
|
+
* is ended here as interrupted, in memory, and returned so its result
|
|
200
|
+
* recipient can be told. It stays in the snapshot as it was, and its end
|
|
201
|
+
* is written, once the host has told the recipients (settleInterrupted).
|
|
202
|
+
* Held mail is kept for redelivery.
|
|
203
|
+
*
|
|
204
|
+
* A bounded record the ended history already holds, by name and
|
|
205
|
+
* incarnation, ended before the previous process could write the snapshot
|
|
206
|
+
* without it: it is dropped, not ended again. A persistent record waits to
|
|
207
|
+
* be re-declared whatever that history says, since the end there may be one
|
|
208
|
+
* a stop left that failed and was put back (an append can't be taken
|
|
209
|
+
* back); configuration then declares it again or ends it.
|
|
210
|
+
*
|
|
211
|
+
* `endedHistory` is the tail of the ended-record log, oldest first.
|
|
212
|
+
*/
|
|
213
|
+
restore(snapshot: RegistrySnapshot | null | undefined, endedHistory?: AgentRecord[]): RestoreOutcome;
|
|
214
|
+
/**
|
|
215
|
+
* The host has told each interrupted job's recipient (restore's
|
|
216
|
+
* `interrupted`): their ends are written now, and the snapshot no longer
|
|
217
|
+
* lists them. Each pending entry carries its own end, as memory keeps only
|
|
218
|
+
* the newest `endedRetention`. An end whose write fails is reported and
|
|
219
|
+
* stays pending, so the snapshot still lists it and a later settlement (the
|
|
220
|
+
* next boot's) writes it; a failed snapshot write is reported too.
|
|
221
|
+
* @internal For the framework's boot, once the interrupted jobs'
|
|
222
|
+
* recipients are told; not a host API.
|
|
223
|
+
*/
|
|
224
|
+
settleInterrupted(): void;
|
|
225
|
+
/**
|
|
226
|
+
* Call once configuration has declared its agents. A persistent agent the
|
|
227
|
+
* previous process ran but this configuration omits is ended, with the
|
|
228
|
+
* usual consequences for what it spawned.
|
|
229
|
+
*/
|
|
230
|
+
reconcile(): ReconcileOutcome;
|
|
231
|
+
private recordEnded;
|
|
232
|
+
/** Mark a record ended and keep it in memory, without writing the end. */
|
|
233
|
+
private pushEnded;
|
|
234
|
+
/** Write an ended record through the host's append hook. */
|
|
235
|
+
private appendEndedRecord;
|
|
236
|
+
/**
|
|
237
|
+
* Run a change a caller asks for — a registration, an end, a reparent, a
|
|
238
|
+
* hold — so that a write failing on the way puts memory back as it was:
|
|
239
|
+
* the call fails and changes nothing, and a retry does it once (nissa's
|
|
240
|
+
* #546 review, round 2: a stop whose write failed left the agent recorded
|
|
241
|
+
* as stopped while it kept running).
|
|
242
|
+
*/
|
|
243
|
+
private requested;
|
|
244
|
+
/** Memory is as it was before a change that failed: the host rewrites its copies to match. The caller hears why
|
|
245
|
+
* its change failed, not why the put-back did. */
|
|
246
|
+
private putBack;
|
|
247
|
+
/** Run a record of something that has already happened: its writes alert and stay in memory rather than throw. */
|
|
248
|
+
private recording;
|
|
249
|
+
/** The ended records in memory, newest last. */
|
|
250
|
+
endedHistory(): AgentRecord[];
|
|
251
|
+
/** Persist a record of something that has already happened: a failure
|
|
252
|
+
* alerts and leaves the change in memory for the next write to carry. */
|
|
253
|
+
private persistRecord;
|
|
254
|
+
/** Write the snapshot through the host's persist hook. A write that fails
|
|
255
|
+
* fails the change that made it (nissa's #546 finding 2): the change is in
|
|
256
|
+
* memory, and the caller is told it is not durable, rather than told it
|
|
257
|
+
* succeeded while a restart would lose it. */
|
|
258
|
+
private persist;
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/dendrite/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EACV,cAAc,EACd,SAAS,EACT,WAAW,EACX,QAAQ,EACR,SAAS,EACT,UAAU,EACV,QAAQ,EACR,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,sDAAsD;AACtD,qBAAa,cAAe,SAAQ,KAAK;IACvC,YAAY,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAGzC;CACF;AAED,MAAM,WAAW,oBAAoB;IACnC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,qEAAqE;IACrE,OAAO,CAAC,EAAE,CAAC,QAAQ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