@animalabs/agent-framework 0.11.0 → 0.13.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/dist/src/agent.d.ts +11 -1
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +60 -4
- package/dist/src/agent.js.map +1 -1
- package/dist/src/framework.d.ts +72 -1
- package/dist/src/framework.d.ts.map +1 -1
- package/dist/src/framework.js +873 -123
- package/dist/src/framework.js.map +1 -1
- package/dist/src/gate/event-gate.d.ts +7 -1
- package/dist/src/gate/event-gate.d.ts.map +1 -1
- package/dist/src/gate/event-gate.js +15 -1
- package/dist/src/gate/event-gate.js.map +1 -1
- package/dist/src/kv-unified-wire.d.ts +16 -0
- package/dist/src/kv-unified-wire.d.ts.map +1 -0
- package/dist/src/kv-unified-wire.js +2 -0
- package/dist/src/kv-unified-wire.js.map +1 -0
- package/dist/src/mcpl/channel-registry.d.ts +84 -1
- package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
- package/dist/src/mcpl/channel-registry.js +188 -5
- package/dist/src/mcpl/channel-registry.js.map +1 -1
- package/dist/src/mcpl/hook-orchestrator.d.ts.map +1 -1
- package/dist/src/mcpl/hook-orchestrator.js +28 -2
- package/dist/src/mcpl/hook-orchestrator.js.map +1 -1
- package/dist/src/mcpl/push-handler.d.ts +6 -1
- package/dist/src/mcpl/push-handler.d.ts.map +1 -1
- package/dist/src/mcpl/push-handler.js +29 -2
- package/dist/src/mcpl/push-handler.js.map +1 -1
- package/dist/src/mcpl/reference-fetcher.d.ts +59 -0
- package/dist/src/mcpl/reference-fetcher.d.ts.map +1 -0
- package/dist/src/mcpl/reference-fetcher.js +240 -0
- package/dist/src/mcpl/reference-fetcher.js.map +1 -0
- package/dist/src/mcpl/references.d.ts +125 -0
- package/dist/src/mcpl/references.d.ts.map +1 -0
- package/dist/src/mcpl/references.js +262 -0
- package/dist/src/mcpl/references.js.map +1 -0
- package/dist/src/mcpl/types.d.ts +32 -0
- package/dist/src/mcpl/types.d.ts.map +1 -1
- package/dist/src/mcpl/types.js.map +1 -1
- package/dist/src/modules/index.d.ts +2 -1
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +1 -1
- package/dist/src/modules/index.js.map +1 -1
- package/dist/src/modules/workspace/index.d.ts +125 -2
- package/dist/src/modules/workspace/index.d.ts.map +1 -1
- package/dist/src/modules/workspace/index.js +354 -58
- package/dist/src/modules/workspace/index.js.map +1 -1
- package/dist/src/modules/workspace/types.d.ts +7 -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/tool-result-history.d.ts.map +1 -1
- package/dist/src/tool-result-history.js +14 -0
- package/dist/src/tool-result-history.js.map +1 -1
- package/dist/src/tool-wrapper-prose-guard.d.ts +8 -0
- package/dist/src/tool-wrapper-prose-guard.d.ts.map +1 -0
- package/dist/src/tool-wrapper-prose-guard.js +37 -0
- package/dist/src/tool-wrapper-prose-guard.js.map +1 -0
- package/dist/src/tune-out/coordinator.d.ts +144 -0
- package/dist/src/tune-out/coordinator.d.ts.map +1 -0
- package/dist/src/tune-out/coordinator.js +444 -0
- package/dist/src/tune-out/coordinator.js.map +1 -0
- package/dist/src/tune-out/tools.d.ts +43 -0
- package/dist/src/tune-out/tools.d.ts.map +1 -0
- package/dist/src/tune-out/tools.js +93 -0
- package/dist/src/tune-out/tools.js.map +1 -0
- package/dist/src/types/agent.d.ts +15 -0
- package/dist/src/types/agent.d.ts.map +1 -1
- package/dist/src/types/framework.d.ts +6 -0
- package/dist/src/types/framework.d.ts.map +1 -1
- package/dist/src/usage-accounting.d.ts +5 -0
- package/dist/src/usage-accounting.d.ts.map +1 -0
- package/dist/src/usage-accounting.js +11 -0
- package/dist/src/usage-accounting.js.map +1 -0
- package/dist/test/channel-incoming-targeting.test.d.ts +2 -0
- package/dist/test/channel-incoming-targeting.test.d.ts.map +1 -0
- package/dist/test/channel-incoming-targeting.test.js +81 -0
- package/dist/test/channel-incoming-targeting.test.js.map +1 -0
- package/dist/test/conversation-routing.test.js +39 -0
- package/dist/test/conversation-routing.test.js.map +1 -1
- package/dist/test/kv-unified-wiring.test.d.ts +2 -0
- package/dist/test/kv-unified-wiring.test.d.ts.map +1 -0
- package/dist/test/kv-unified-wiring.test.js +56 -0
- package/dist/test/kv-unified-wiring.test.js.map +1 -0
- package/dist/test/mcpl-push-convert.test.d.ts +2 -0
- package/dist/test/mcpl-push-convert.test.d.ts.map +1 -0
- package/dist/test/mcpl-push-convert.test.js +42 -0
- package/dist/test/mcpl-push-convert.test.js.map +1 -0
- package/dist/test/mcpl-reference-fetcher.test.d.ts +2 -0
- package/dist/test/mcpl-reference-fetcher.test.d.ts.map +1 -0
- package/dist/test/mcpl-reference-fetcher.test.js +199 -0
- package/dist/test/mcpl-reference-fetcher.test.js.map +1 -0
- package/dist/test/per-agent-delivery.test.d.ts +2 -0
- package/dist/test/per-agent-delivery.test.d.ts.map +1 -0
- package/dist/test/per-agent-delivery.test.js +108 -0
- package/dist/test/per-agent-delivery.test.js.map +1 -0
- package/dist/test/present-while-acting.test.js +64 -0
- package/dist/test/present-while-acting.test.js.map +1 -1
- package/dist/test/tool-result-history.test.js +78 -0
- package/dist/test/tool-result-history.test.js.map +1 -1
- package/dist/test/tool-wrapper-prose-guard-integration.test.d.ts +2 -0
- package/dist/test/tool-wrapper-prose-guard-integration.test.d.ts.map +1 -0
- package/dist/test/tool-wrapper-prose-guard-integration.test.js +485 -0
- package/dist/test/tool-wrapper-prose-guard-integration.test.js.map +1 -0
- package/dist/test/tool-wrapper-prose-guard.test.d.ts +2 -0
- package/dist/test/tool-wrapper-prose-guard.test.d.ts.map +1 -0
- package/dist/test/tool-wrapper-prose-guard.test.js +34 -0
- package/dist/test/tool-wrapper-prose-guard.test.js.map +1 -0
- package/dist/test/tune-out-e2e.test.d.ts +2 -0
- package/dist/test/tune-out-e2e.test.d.ts.map +1 -0
- package/dist/test/tune-out-e2e.test.js +142 -0
- package/dist/test/tune-out-e2e.test.js.map +1 -0
- package/dist/test/tune-out-gate-composition.test.d.ts +2 -0
- package/dist/test/tune-out-gate-composition.test.d.ts.map +1 -0
- package/dist/test/tune-out-gate-composition.test.js +221 -0
- package/dist/test/tune-out-gate-composition.test.js.map +1 -0
- package/dist/test/tune-out-lifecycle.test.d.ts +2 -0
- package/dist/test/tune-out-lifecycle.test.d.ts.map +1 -0
- package/dist/test/tune-out-lifecycle.test.js +121 -0
- package/dist/test/tune-out-lifecycle.test.js.map +1 -0
- package/dist/test/turn-trigger-provenance.test.d.ts +2 -0
- package/dist/test/turn-trigger-provenance.test.d.ts.map +1 -0
- package/dist/test/turn-trigger-provenance.test.js +85 -0
- package/dist/test/turn-trigger-provenance.test.js.map +1 -0
- package/dist/test/usage-accounting.test.d.ts +2 -0
- package/dist/test/usage-accounting.test.d.ts.map +1 -0
- package/dist/test/usage-accounting.test.js +13 -0
- package/dist/test/usage-accounting.test.js.map +1 -0
- package/dist/test/workspace-branch-continuation.test.d.ts +15 -0
- package/dist/test/workspace-branch-continuation.test.d.ts.map +1 -0
- package/dist/test/workspace-branch-continuation.test.js +183 -0
- package/dist/test/workspace-branch-continuation.test.js.map +1 -0
- package/dist/test/workspace-read-file-from-disk.test.d.ts +17 -0
- package/dist/test/workspace-read-file-from-disk.test.d.ts.map +1 -0
- package/dist/test/workspace-read-file-from-disk.test.js +174 -0
- package/dist/test/workspace-read-file-from-disk.test.js.map +1 -0
- package/dist/test/workspace-read-image.test.js +8 -0
- package/dist/test/workspace-read-image.test.js.map +1 -1
- package/dist/test/workspace-restore-order.test.js +1 -1
- package/dist/test/workspace-restore-order.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/agent.ts +77 -4
- package/src/framework.ts +953 -128
- package/src/gate/event-gate.ts +28 -3
- package/src/kv-unified-wire.ts +12 -0
- package/src/mcpl/channel-registry.ts +264 -8
- package/src/mcpl/hook-orchestrator.ts +29 -2
- package/src/mcpl/push-handler.ts +30 -2
- package/src/mcpl/reference-fetcher.ts +240 -0
- package/src/mcpl/references.ts +292 -0
- package/src/mcpl/types.ts +29 -0
- package/src/modules/index.ts +2 -1
- package/src/modules/workspace/index.ts +425 -66
- package/src/modules/workspace/types.ts +7 -0
- package/src/tool-result-history.ts +11 -0
- package/src/tool-wrapper-prose-guard.ts +38 -0
- package/src/tune-out/coordinator.ts +548 -0
- package/src/tune-out/tools.ts +129 -0
- package/src/types/agent.ts +16 -0
- package/src/types/framework.ts +7 -0
- package/src/usage-accounting.ts +8 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The subconscious's tool surface (issue #77).
|
|
3
|
+
*
|
|
4
|
+
* Deliberately small and channel-scoped: the subconscious observes the
|
|
5
|
+
* merged timeline, judges wakes, and reports — it is not a general agent.
|
|
6
|
+
* Names and results carry no credential/config vocabulary; everything it
|
|
7
|
+
* says to the resident is its own text (never host-templated), delivered
|
|
8
|
+
* under its own participant name. Prose is never auto-routed
|
|
9
|
+
* (proseRouting: 'explicit' on its AgentConfig): speaking into a channel
|
|
10
|
+
* happens only through speak_in_channel, so a timer-triggered turn can
|
|
11
|
+
* never leak bare prose to the default locus.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { ToolDefinition } from '../types/index.js';
|
|
15
|
+
|
|
16
|
+
export const SUBCONSCIOUS_TOOL_NAMES = [
|
|
17
|
+
'deliver_summary',
|
|
18
|
+
'cancel_tuneout',
|
|
19
|
+
'note_disposition',
|
|
20
|
+
'speak_in_channel',
|
|
21
|
+
] as const;
|
|
22
|
+
|
|
23
|
+
export type SubconsciousToolName = (typeof SUBCONSCIOUS_TOOL_NAMES)[number];
|
|
24
|
+
|
|
25
|
+
export const SUBCONSCIOUS_TOOLS: ToolDefinition[] = [
|
|
26
|
+
{
|
|
27
|
+
name: 'deliver_summary',
|
|
28
|
+
description:
|
|
29
|
+
'Deliver a summary into the resident\'s context, in your own voice, ' +
|
|
30
|
+
'addressed to them (second person). Use at cadence when the diverted ' +
|
|
31
|
+
'traffic merits it; staying silent is always allowed — an empty ' +
|
|
32
|
+
'period needs no report.',
|
|
33
|
+
inputSchema: {
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: {
|
|
36
|
+
text: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
description: 'The summary, verbatim as the resident will read it.',
|
|
39
|
+
},
|
|
40
|
+
channelId: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
description: 'The tuned-out channel this summary covers.',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
required: ['text', 'channelId'],
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'cancel_tuneout',
|
|
50
|
+
description:
|
|
51
|
+
'End the tune-out on a channel now — use when something needs the ' +
|
|
52
|
+
'resident\'s full attention. The diverted backlog is delivered to ' +
|
|
53
|
+
'them (capped), and normal attention resumes. Add your own note in ' +
|
|
54
|
+
'`text`; it arrives alongside the backlog, in your voice.',
|
|
55
|
+
inputSchema: {
|
|
56
|
+
type: 'object',
|
|
57
|
+
properties: {
|
|
58
|
+
channelId: { type: 'string' },
|
|
59
|
+
text: {
|
|
60
|
+
type: 'string',
|
|
61
|
+
description: 'Your accompanying note to the resident (optional).',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
required: ['channelId'],
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'note_disposition',
|
|
69
|
+
description:
|
|
70
|
+
'Record a standing disposition for yourself — a durable note that ' +
|
|
71
|
+
'shapes how you treat future traffic ("antra\'s pings always ' +
|
|
72
|
+
'escalate", "ignore release-bot"). Replaces any previous note under ' +
|
|
73
|
+
'the same key.',
|
|
74
|
+
inputSchema: {
|
|
75
|
+
type: 'object',
|
|
76
|
+
properties: {
|
|
77
|
+
key: { type: 'string', description: 'Short stable identifier.' },
|
|
78
|
+
text: {
|
|
79
|
+
type: 'string',
|
|
80
|
+
description: 'The disposition. Empty string deletes the key.',
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
required: ['key', 'text'],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'speak_in_channel',
|
|
88
|
+
description:
|
|
89
|
+
'Post a message into a tuned-out channel, clearly as yourself (not ' +
|
|
90
|
+
'as the resident). Use sparingly — e.g. to tell someone the resident ' +
|
|
91
|
+
'is tuned out and when to expect them. Disabled unless the resident\'s ' +
|
|
92
|
+
'configuration allows it.',
|
|
93
|
+
inputSchema: {
|
|
94
|
+
type: 'object',
|
|
95
|
+
properties: {
|
|
96
|
+
channelId: { type: 'string' },
|
|
97
|
+
text: { type: 'string' },
|
|
98
|
+
},
|
|
99
|
+
required: ['channelId', 'text'],
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Configuration for the subconscious resident (FrameworkConfig.subconscious).
|
|
106
|
+
*/
|
|
107
|
+
export interface SubconsciousConfig {
|
|
108
|
+
/** Master switch. */
|
|
109
|
+
enabled: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Registry + participant name. Default 'Subconscious' — following the
|
|
112
|
+
* Context Manager precedent: a title-case functional voice, not an
|
|
113
|
+
* agent-prefixed identifier.
|
|
114
|
+
*/
|
|
115
|
+
name?: string;
|
|
116
|
+
/** Model id; defaults to the primary agent's (same-model side-process). */
|
|
117
|
+
model?: string;
|
|
118
|
+
/**
|
|
119
|
+
* The voice/criteria mode block — recipe-side and co-authored with the
|
|
120
|
+
* resident (it is an aspect of their attention). Report-shaped, second
|
|
121
|
+
* person toward the resident. Canary before fleet use (issue #77).
|
|
122
|
+
*/
|
|
123
|
+
systemPrompt: string;
|
|
124
|
+
/** Allow speak_in_channel. Default false until the voice block has
|
|
125
|
+
* passed its canary round. */
|
|
126
|
+
allowChannelSpeech?: boolean;
|
|
127
|
+
/** WindowedPassthroughStrategy re-anchor fraction (default 0.5). */
|
|
128
|
+
reAnchorFraction?: number;
|
|
129
|
+
}
|
package/src/types/agent.ts
CHANGED
|
@@ -184,6 +184,14 @@ export interface AgentConfig {
|
|
|
184
184
|
* send externally; prose remains in Chronicle with a private suppression receipt.
|
|
185
185
|
*/
|
|
186
186
|
proseRouting?: 'locus' | 'explicit' | 'hybrid' | 'disabled';
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Fail-closed containment for a text response whose entire visible prose is
|
|
190
|
+
* an invocation-shaped wrapper naming a tool registered on that exact turn.
|
|
191
|
+
* The wrapper is neither executed nor stored as assistant continuity; a
|
|
192
|
+
* content-free system receipt is stored instead. Default false.
|
|
193
|
+
*/
|
|
194
|
+
toolWrapperProseGuard?: boolean;
|
|
187
195
|
}
|
|
188
196
|
|
|
189
197
|
/** The intentionally small set of agent settings that may change in-process. */
|
|
@@ -310,4 +318,12 @@ export interface InferenceRequest {
|
|
|
310
318
|
* not capture the agent's voice just by being newest.
|
|
311
319
|
*/
|
|
312
320
|
addressed?: boolean;
|
|
321
|
+
/**
|
|
322
|
+
* Who spoke the message that triggered this inference, as an adapter-
|
|
323
|
+
* namespaced opaque id (`<serverId>:user:<authorId>`) — never a display
|
|
324
|
+
* name. Undefined for wakes without an author (heartbeat, timers, module
|
|
325
|
+
* events). Read by the host to stamp gateway telemetry (x-gate-counterparty)
|
|
326
|
+
* so a household ledger can say who woke whom; carries no content.
|
|
327
|
+
*/
|
|
328
|
+
counterparty?: string;
|
|
313
329
|
}
|
package/src/types/framework.ts
CHANGED
|
@@ -71,6 +71,13 @@ export interface CodeExecutionConfig {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
export interface FrameworkConfig {
|
|
74
|
+
/**
|
|
75
|
+
* The subconscious resident (issue #77): a persistent side-agent that
|
|
76
|
+
* receives diverted traffic from tuned-out channels and reports to the
|
|
77
|
+
* resident in its own voice. See src/tune-out/tools.ts.
|
|
78
|
+
*/
|
|
79
|
+
subconscious?: import('../tune-out/tools.js').SubconsciousConfig;
|
|
80
|
+
|
|
74
81
|
/**
|
|
75
82
|
* IANA zone used only when rendering wall-clock times for the agent.
|
|
76
83
|
* Stored/protocol timestamps remain epoch/UTC. Defaults to AGENT_TIMEZONE,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Convert a cumulative usage counter into the contribution of this call.
|
|
2
|
+
* A counter reset (provider/stream implementation change) is treated as an
|
|
3
|
+
* already-per-call sample rather than producing a negative value. */
|
|
4
|
+
export function cumulativeDelta(current: number, previous: number): number {
|
|
5
|
+
if (!Number.isFinite(current) || current < 0) return 0;
|
|
6
|
+
if (!Number.isFinite(previous) || previous < 0 || current < previous) return current;
|
|
7
|
+
return current - previous;
|
|
8
|
+
}
|