@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,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Presets — the historical agent kinds expressed as {@link AgentSpec}
|
|
3
|
+
* values. They are configurations of the common machinery, not engines:
|
|
4
|
+
* everything a preset decides is visible in the spec it returns, and a host
|
|
5
|
+
* may register a spec that matches none of them.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { AgentName, AgentSpec, ContextInheritance, ResultRoute } from './types.js';
|
|
9
|
+
|
|
10
|
+
/** Default idle bound for a bounded job with no explicit deadline (matches the run watchdog). */
|
|
11
|
+
export const DEFAULT_TASK_IDLE_TIMEOUT_MS = 15 * 60_000;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A resident: persistent, declared in configuration, reads the residents'
|
|
15
|
+
* shared message slot. The first one declared owns default delivery.
|
|
16
|
+
*/
|
|
17
|
+
export function residentSpec(name: AgentName, options: { primary: boolean }): AgentSpec {
|
|
18
|
+
return {
|
|
19
|
+
name,
|
|
20
|
+
kind: 'resident',
|
|
21
|
+
roles: {
|
|
22
|
+
defaultDelivery: options.primary,
|
|
23
|
+
receivesUntargeted: true,
|
|
24
|
+
receivesGateWakes: true,
|
|
25
|
+
ownsProviderScheduling: true,
|
|
26
|
+
},
|
|
27
|
+
lifetime: { kind: 'persistent' },
|
|
28
|
+
readsSharedSlot: true,
|
|
29
|
+
namespace: `agents/${name}`,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The subconscious: a persistent attention tenant of the resident it
|
|
35
|
+
* serves. It persists across policy epochs (cancelling a tune-out ends a
|
|
36
|
+
* channel's cadence, not this agent), observes the residents' slot with
|
|
37
|
+
* held traffic included, is never a broadcast recipient, and ends with its
|
|
38
|
+
* resident.
|
|
39
|
+
*/
|
|
40
|
+
export function subconsciousSpec(name: AgentName, serves: AgentName): AgentSpec {
|
|
41
|
+
return {
|
|
42
|
+
name,
|
|
43
|
+
kind: 'subconscious',
|
|
44
|
+
roles: {
|
|
45
|
+
defaultDelivery: false,
|
|
46
|
+
receivesUntargeted: false,
|
|
47
|
+
receivesGateWakes: false,
|
|
48
|
+
ownsProviderScheduling: true,
|
|
49
|
+
},
|
|
50
|
+
lifetime: { kind: 'persistent' },
|
|
51
|
+
spawnedBy: serves,
|
|
52
|
+
onParentEnd: 'end',
|
|
53
|
+
observes: [{ includeHeld: true }],
|
|
54
|
+
resultTo: { to: serves, as: 'message' },
|
|
55
|
+
readsSharedSlot: true,
|
|
56
|
+
namespace: `subconscious/${serves}`,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* A conversation fork: derived from a template agent's context at bind
|
|
62
|
+
* time, bound to one channel, independent continuation, ends on idle.
|
|
63
|
+
*/
|
|
64
|
+
export function conversationForkSpec(
|
|
65
|
+
name: AgentName,
|
|
66
|
+
options: {
|
|
67
|
+
template: AgentName;
|
|
68
|
+
/** The channel it's bound to, on its server. */
|
|
69
|
+
homeChannel: { serverId: string; channelId: string };
|
|
70
|
+
idleTtlMs: number;
|
|
71
|
+
inherit?: Partial<ContextInheritance>;
|
|
72
|
+
},
|
|
73
|
+
): AgentSpec {
|
|
74
|
+
return {
|
|
75
|
+
name,
|
|
76
|
+
kind: 'conversation-fork',
|
|
77
|
+
roles: {
|
|
78
|
+
defaultDelivery: false,
|
|
79
|
+
receivesUntargeted: false,
|
|
80
|
+
// Woken by its own channel's debounced traffic through the host-wide gate.
|
|
81
|
+
receivesGateWakes: true,
|
|
82
|
+
ownsProviderScheduling: false,
|
|
83
|
+
},
|
|
84
|
+
lifetime: { kind: 'idle', idleTtlMs: options.idleTtlMs },
|
|
85
|
+
spawnedBy: options.template,
|
|
86
|
+
onParentEnd: 'orphan',
|
|
87
|
+
inherit: { from: options.template, mode: 'copy', ...options.inherit },
|
|
88
|
+
// A copy renames the template's turns as it copies them. A shared
|
|
89
|
+
// inheritance has no copy step, so the mapping is declared instead.
|
|
90
|
+
...(options.inherit?.mode === 'shared' ? { selfParticipants: [options.template] } : {}),
|
|
91
|
+
homeChannel: { serverId: options.homeChannel.serverId, channelId: options.homeChannel.channelId },
|
|
92
|
+
namespace: `conversations/${name}`,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface BoundedJobOptions {
|
|
97
|
+
/** Who created it. Absent for an independent job driven by the host. */
|
|
98
|
+
spawnedBy?: AgentName;
|
|
99
|
+
/** Where its completion returns. */
|
|
100
|
+
resultTo?: ResultRoute;
|
|
101
|
+
deadlineMs?: number;
|
|
102
|
+
idleTimeoutMs?: number;
|
|
103
|
+
maxTurns?: number;
|
|
104
|
+
namespace?: string;
|
|
105
|
+
metadata?: Record<string, unknown>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function boundedJob(name: AgentName, options: BoundedJobOptions): Omit<AgentSpec, 'kind'> {
|
|
109
|
+
return {
|
|
110
|
+
name,
|
|
111
|
+
roles: {
|
|
112
|
+
defaultDelivery: false,
|
|
113
|
+
receivesUntargeted: false,
|
|
114
|
+
receivesGateWakes: false,
|
|
115
|
+
ownsProviderScheduling: false,
|
|
116
|
+
},
|
|
117
|
+
lifetime: {
|
|
118
|
+
kind: 'task',
|
|
119
|
+
...(options.deadlineMs !== undefined ? { deadlineMs: options.deadlineMs } : {}),
|
|
120
|
+
idleTimeoutMs: options.idleTimeoutMs ?? DEFAULT_TASK_IDLE_TIMEOUT_MS,
|
|
121
|
+
...(options.maxTurns !== undefined ? { maxTurns: options.maxTurns } : {}),
|
|
122
|
+
},
|
|
123
|
+
...(options.spawnedBy ? { spawnedBy: options.spawnedBy, onParentEnd: 'orphan' as const } : {}),
|
|
124
|
+
...(options.resultTo ? { resultTo: options.resultTo } : {}),
|
|
125
|
+
namespace: options.namespace ?? `subagent/${name}`,
|
|
126
|
+
...(options.metadata ? { metadata: options.metadata } : {}),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** A fresh worker: new identity and context, one bounded job, a result route. */
|
|
131
|
+
export function workerSpec(name: AgentName, options: BoundedJobOptions = {}): AgentSpec {
|
|
132
|
+
return { ...boundedJob(name, options), kind: 'worker' };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* A task fork: the parent's context at a checkpoint, a private
|
|
137
|
+
* continuation, one bounded job, a return.
|
|
138
|
+
*/
|
|
139
|
+
export function taskForkSpec(
|
|
140
|
+
name: AgentName,
|
|
141
|
+
options: BoundedJobOptions & { parent: AgentName; inherit?: Partial<ContextInheritance> },
|
|
142
|
+
): AgentSpec {
|
|
143
|
+
return {
|
|
144
|
+
...boundedJob(name, { ...options, spawnedBy: options.spawnedBy ?? options.parent }),
|
|
145
|
+
kind: 'task-fork',
|
|
146
|
+
inherit: { from: options.parent, mode: 'copy', ...options.inherit },
|
|
147
|
+
...(options.inherit?.mode === 'shared' ? { selfParticipants: [options.parent] } : {}),
|
|
148
|
+
};
|
|
149
|
+
}
|