@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.
Files changed (160) hide show
  1. package/dist/src/agent.d.ts +11 -1
  2. package/dist/src/agent.d.ts.map +1 -1
  3. package/dist/src/agent.js +60 -4
  4. package/dist/src/agent.js.map +1 -1
  5. package/dist/src/framework.d.ts +72 -1
  6. package/dist/src/framework.d.ts.map +1 -1
  7. package/dist/src/framework.js +873 -123
  8. package/dist/src/framework.js.map +1 -1
  9. package/dist/src/gate/event-gate.d.ts +7 -1
  10. package/dist/src/gate/event-gate.d.ts.map +1 -1
  11. package/dist/src/gate/event-gate.js +15 -1
  12. package/dist/src/gate/event-gate.js.map +1 -1
  13. package/dist/src/kv-unified-wire.d.ts +16 -0
  14. package/dist/src/kv-unified-wire.d.ts.map +1 -0
  15. package/dist/src/kv-unified-wire.js +2 -0
  16. package/dist/src/kv-unified-wire.js.map +1 -0
  17. package/dist/src/mcpl/channel-registry.d.ts +84 -1
  18. package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
  19. package/dist/src/mcpl/channel-registry.js +188 -5
  20. package/dist/src/mcpl/channel-registry.js.map +1 -1
  21. package/dist/src/mcpl/hook-orchestrator.d.ts.map +1 -1
  22. package/dist/src/mcpl/hook-orchestrator.js +28 -2
  23. package/dist/src/mcpl/hook-orchestrator.js.map +1 -1
  24. package/dist/src/mcpl/push-handler.d.ts +6 -1
  25. package/dist/src/mcpl/push-handler.d.ts.map +1 -1
  26. package/dist/src/mcpl/push-handler.js +29 -2
  27. package/dist/src/mcpl/push-handler.js.map +1 -1
  28. package/dist/src/mcpl/reference-fetcher.d.ts +59 -0
  29. package/dist/src/mcpl/reference-fetcher.d.ts.map +1 -0
  30. package/dist/src/mcpl/reference-fetcher.js +240 -0
  31. package/dist/src/mcpl/reference-fetcher.js.map +1 -0
  32. package/dist/src/mcpl/references.d.ts +125 -0
  33. package/dist/src/mcpl/references.d.ts.map +1 -0
  34. package/dist/src/mcpl/references.js +262 -0
  35. package/dist/src/mcpl/references.js.map +1 -0
  36. package/dist/src/mcpl/types.d.ts +32 -0
  37. package/dist/src/mcpl/types.d.ts.map +1 -1
  38. package/dist/src/mcpl/types.js.map +1 -1
  39. package/dist/src/modules/index.d.ts +2 -1
  40. package/dist/src/modules/index.d.ts.map +1 -1
  41. package/dist/src/modules/index.js +1 -1
  42. package/dist/src/modules/index.js.map +1 -1
  43. package/dist/src/modules/workspace/index.d.ts +125 -2
  44. package/dist/src/modules/workspace/index.d.ts.map +1 -1
  45. package/dist/src/modules/workspace/index.js +354 -58
  46. package/dist/src/modules/workspace/index.js.map +1 -1
  47. package/dist/src/modules/workspace/types.d.ts +7 -0
  48. package/dist/src/modules/workspace/types.d.ts.map +1 -1
  49. package/dist/src/modules/workspace/types.js.map +1 -1
  50. package/dist/src/tool-result-history.d.ts.map +1 -1
  51. package/dist/src/tool-result-history.js +14 -0
  52. package/dist/src/tool-result-history.js.map +1 -1
  53. package/dist/src/tool-wrapper-prose-guard.d.ts +8 -0
  54. package/dist/src/tool-wrapper-prose-guard.d.ts.map +1 -0
  55. package/dist/src/tool-wrapper-prose-guard.js +37 -0
  56. package/dist/src/tool-wrapper-prose-guard.js.map +1 -0
  57. package/dist/src/tune-out/coordinator.d.ts +144 -0
  58. package/dist/src/tune-out/coordinator.d.ts.map +1 -0
  59. package/dist/src/tune-out/coordinator.js +444 -0
  60. package/dist/src/tune-out/coordinator.js.map +1 -0
  61. package/dist/src/tune-out/tools.d.ts +43 -0
  62. package/dist/src/tune-out/tools.d.ts.map +1 -0
  63. package/dist/src/tune-out/tools.js +93 -0
  64. package/dist/src/tune-out/tools.js.map +1 -0
  65. package/dist/src/types/agent.d.ts +15 -0
  66. package/dist/src/types/agent.d.ts.map +1 -1
  67. package/dist/src/types/framework.d.ts +6 -0
  68. package/dist/src/types/framework.d.ts.map +1 -1
  69. package/dist/src/usage-accounting.d.ts +5 -0
  70. package/dist/src/usage-accounting.d.ts.map +1 -0
  71. package/dist/src/usage-accounting.js +11 -0
  72. package/dist/src/usage-accounting.js.map +1 -0
  73. package/dist/test/channel-incoming-targeting.test.d.ts +2 -0
  74. package/dist/test/channel-incoming-targeting.test.d.ts.map +1 -0
  75. package/dist/test/channel-incoming-targeting.test.js +81 -0
  76. package/dist/test/channel-incoming-targeting.test.js.map +1 -0
  77. package/dist/test/conversation-routing.test.js +39 -0
  78. package/dist/test/conversation-routing.test.js.map +1 -1
  79. package/dist/test/kv-unified-wiring.test.d.ts +2 -0
  80. package/dist/test/kv-unified-wiring.test.d.ts.map +1 -0
  81. package/dist/test/kv-unified-wiring.test.js +56 -0
  82. package/dist/test/kv-unified-wiring.test.js.map +1 -0
  83. package/dist/test/mcpl-push-convert.test.d.ts +2 -0
  84. package/dist/test/mcpl-push-convert.test.d.ts.map +1 -0
  85. package/dist/test/mcpl-push-convert.test.js +42 -0
  86. package/dist/test/mcpl-push-convert.test.js.map +1 -0
  87. package/dist/test/mcpl-reference-fetcher.test.d.ts +2 -0
  88. package/dist/test/mcpl-reference-fetcher.test.d.ts.map +1 -0
  89. package/dist/test/mcpl-reference-fetcher.test.js +199 -0
  90. package/dist/test/mcpl-reference-fetcher.test.js.map +1 -0
  91. package/dist/test/per-agent-delivery.test.d.ts +2 -0
  92. package/dist/test/per-agent-delivery.test.d.ts.map +1 -0
  93. package/dist/test/per-agent-delivery.test.js +108 -0
  94. package/dist/test/per-agent-delivery.test.js.map +1 -0
  95. package/dist/test/present-while-acting.test.js +64 -0
  96. package/dist/test/present-while-acting.test.js.map +1 -1
  97. package/dist/test/tool-result-history.test.js +78 -0
  98. package/dist/test/tool-result-history.test.js.map +1 -1
  99. package/dist/test/tool-wrapper-prose-guard-integration.test.d.ts +2 -0
  100. package/dist/test/tool-wrapper-prose-guard-integration.test.d.ts.map +1 -0
  101. package/dist/test/tool-wrapper-prose-guard-integration.test.js +485 -0
  102. package/dist/test/tool-wrapper-prose-guard-integration.test.js.map +1 -0
  103. package/dist/test/tool-wrapper-prose-guard.test.d.ts +2 -0
  104. package/dist/test/tool-wrapper-prose-guard.test.d.ts.map +1 -0
  105. package/dist/test/tool-wrapper-prose-guard.test.js +34 -0
  106. package/dist/test/tool-wrapper-prose-guard.test.js.map +1 -0
  107. package/dist/test/tune-out-e2e.test.d.ts +2 -0
  108. package/dist/test/tune-out-e2e.test.d.ts.map +1 -0
  109. package/dist/test/tune-out-e2e.test.js +142 -0
  110. package/dist/test/tune-out-e2e.test.js.map +1 -0
  111. package/dist/test/tune-out-gate-composition.test.d.ts +2 -0
  112. package/dist/test/tune-out-gate-composition.test.d.ts.map +1 -0
  113. package/dist/test/tune-out-gate-composition.test.js +221 -0
  114. package/dist/test/tune-out-gate-composition.test.js.map +1 -0
  115. package/dist/test/tune-out-lifecycle.test.d.ts +2 -0
  116. package/dist/test/tune-out-lifecycle.test.d.ts.map +1 -0
  117. package/dist/test/tune-out-lifecycle.test.js +121 -0
  118. package/dist/test/tune-out-lifecycle.test.js.map +1 -0
  119. package/dist/test/turn-trigger-provenance.test.d.ts +2 -0
  120. package/dist/test/turn-trigger-provenance.test.d.ts.map +1 -0
  121. package/dist/test/turn-trigger-provenance.test.js +85 -0
  122. package/dist/test/turn-trigger-provenance.test.js.map +1 -0
  123. package/dist/test/usage-accounting.test.d.ts +2 -0
  124. package/dist/test/usage-accounting.test.d.ts.map +1 -0
  125. package/dist/test/usage-accounting.test.js +13 -0
  126. package/dist/test/usage-accounting.test.js.map +1 -0
  127. package/dist/test/workspace-branch-continuation.test.d.ts +15 -0
  128. package/dist/test/workspace-branch-continuation.test.d.ts.map +1 -0
  129. package/dist/test/workspace-branch-continuation.test.js +183 -0
  130. package/dist/test/workspace-branch-continuation.test.js.map +1 -0
  131. package/dist/test/workspace-read-file-from-disk.test.d.ts +17 -0
  132. package/dist/test/workspace-read-file-from-disk.test.d.ts.map +1 -0
  133. package/dist/test/workspace-read-file-from-disk.test.js +174 -0
  134. package/dist/test/workspace-read-file-from-disk.test.js.map +1 -0
  135. package/dist/test/workspace-read-image.test.js +8 -0
  136. package/dist/test/workspace-read-image.test.js.map +1 -1
  137. package/dist/test/workspace-restore-order.test.js +1 -1
  138. package/dist/test/workspace-restore-order.test.js.map +1 -1
  139. package/dist/tsconfig.tsbuildinfo +1 -1
  140. package/package.json +2 -2
  141. package/src/agent.ts +77 -4
  142. package/src/framework.ts +953 -128
  143. package/src/gate/event-gate.ts +28 -3
  144. package/src/kv-unified-wire.ts +12 -0
  145. package/src/mcpl/channel-registry.ts +264 -8
  146. package/src/mcpl/hook-orchestrator.ts +29 -2
  147. package/src/mcpl/push-handler.ts +30 -2
  148. package/src/mcpl/reference-fetcher.ts +240 -0
  149. package/src/mcpl/references.ts +292 -0
  150. package/src/mcpl/types.ts +29 -0
  151. package/src/modules/index.ts +2 -1
  152. package/src/modules/workspace/index.ts +425 -66
  153. package/src/modules/workspace/types.ts +7 -0
  154. package/src/tool-result-history.ts +11 -0
  155. package/src/tool-wrapper-prose-guard.ts +38 -0
  156. package/src/tune-out/coordinator.ts +548 -0
  157. package/src/tune-out/tools.ts +129 -0
  158. package/src/types/agent.ts +16 -0
  159. package/src/types/framework.ts +7 -0
  160. 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
+ }
@@ -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
  }
@@ -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
+ }