@animalabs/agent-framework 0.12.0 → 0.14.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 (106) hide show
  1. package/dist/src/agent.d.ts +2 -0
  2. package/dist/src/agent.d.ts.map +1 -1
  3. package/dist/src/agent.js +3 -0
  4. package/dist/src/agent.js.map +1 -1
  5. package/dist/src/framework.d.ts +76 -4
  6. package/dist/src/framework.d.ts.map +1 -1
  7. package/dist/src/framework.js +933 -151
  8. package/dist/src/framework.js.map +1 -1
  9. package/dist/src/gate/event-gate.d.ts +62 -2
  10. package/dist/src/gate/event-gate.d.ts.map +1 -1
  11. package/dist/src/gate/event-gate.js +56 -2
  12. package/dist/src/gate/event-gate.js.map +1 -1
  13. package/dist/src/gate/index.d.ts +1 -1
  14. package/dist/src/gate/index.d.ts.map +1 -1
  15. package/dist/src/gate/index.js +1 -1
  16. package/dist/src/gate/index.js.map +1 -1
  17. package/dist/src/index.d.ts +1 -1
  18. package/dist/src/index.d.ts.map +1 -1
  19. package/dist/src/index.js.map +1 -1
  20. package/dist/src/mcpl/channel-registry.d.ts +84 -1
  21. package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
  22. package/dist/src/mcpl/channel-registry.js +160 -4
  23. package/dist/src/mcpl/channel-registry.js.map +1 -1
  24. package/dist/src/modules/workspace/index.d.ts.map +1 -1
  25. package/dist/src/modules/workspace/index.js +5 -1
  26. package/dist/src/modules/workspace/index.js.map +1 -1
  27. package/dist/src/tool-image-ledger.d.ts +175 -0
  28. package/dist/src/tool-image-ledger.d.ts.map +1 -0
  29. package/dist/src/tool-image-ledger.js +257 -0
  30. package/dist/src/tool-image-ledger.js.map +1 -0
  31. package/dist/src/tool-result-history.d.ts +15 -2
  32. package/dist/src/tool-result-history.d.ts.map +1 -1
  33. package/dist/src/tool-result-history.js +16 -9
  34. package/dist/src/tool-result-history.js.map +1 -1
  35. package/dist/src/tool-wrapper-prose-guard.d.ts +8 -0
  36. package/dist/src/tool-wrapper-prose-guard.d.ts.map +1 -0
  37. package/dist/src/tool-wrapper-prose-guard.js +37 -0
  38. package/dist/src/tool-wrapper-prose-guard.js.map +1 -0
  39. package/dist/src/tune-out/coordinator.d.ts +144 -0
  40. package/dist/src/tune-out/coordinator.d.ts.map +1 -0
  41. package/dist/src/tune-out/coordinator.js +444 -0
  42. package/dist/src/tune-out/coordinator.js.map +1 -0
  43. package/dist/src/tune-out/tools.d.ts +43 -0
  44. package/dist/src/tune-out/tools.d.ts.map +1 -0
  45. package/dist/src/tune-out/tools.js +93 -0
  46. package/dist/src/tune-out/tools.js.map +1 -0
  47. package/dist/src/types/agent.d.ts +17 -0
  48. package/dist/src/types/agent.d.ts.map +1 -1
  49. package/dist/src/types/framework.d.ts +6 -0
  50. package/dist/src/types/framework.d.ts.map +1 -1
  51. package/dist/test/channel-incoming-targeting.test.d.ts +2 -0
  52. package/dist/test/channel-incoming-targeting.test.d.ts.map +1 -0
  53. package/dist/test/channel-incoming-targeting.test.js +81 -0
  54. package/dist/test/channel-incoming-targeting.test.js.map +1 -0
  55. package/dist/test/event-gate.test.js +84 -1
  56. package/dist/test/event-gate.test.js.map +1 -1
  57. package/dist/test/per-agent-delivery.test.d.ts +2 -0
  58. package/dist/test/per-agent-delivery.test.d.ts.map +1 -0
  59. package/dist/test/per-agent-delivery.test.js +108 -0
  60. package/dist/test/per-agent-delivery.test.js.map +1 -0
  61. package/dist/test/puppet-tool-call.test.js +1 -0
  62. package/dist/test/puppet-tool-call.test.js.map +1 -1
  63. package/dist/test/save-recent-image.test.d.ts +26 -0
  64. package/dist/test/save-recent-image.test.d.ts.map +1 -0
  65. package/dist/test/save-recent-image.test.js +707 -0
  66. package/dist/test/save-recent-image.test.js.map +1 -0
  67. package/dist/test/tool-wrapper-prose-guard-integration.test.d.ts +2 -0
  68. package/dist/test/tool-wrapper-prose-guard-integration.test.d.ts.map +1 -0
  69. package/dist/test/tool-wrapper-prose-guard-integration.test.js +485 -0
  70. package/dist/test/tool-wrapper-prose-guard-integration.test.js.map +1 -0
  71. package/dist/test/tool-wrapper-prose-guard.test.d.ts +2 -0
  72. package/dist/test/tool-wrapper-prose-guard.test.d.ts.map +1 -0
  73. package/dist/test/tool-wrapper-prose-guard.test.js +34 -0
  74. package/dist/test/tool-wrapper-prose-guard.test.js.map +1 -0
  75. package/dist/test/tune-out-e2e.test.d.ts +2 -0
  76. package/dist/test/tune-out-e2e.test.d.ts.map +1 -0
  77. package/dist/test/tune-out-e2e.test.js +142 -0
  78. package/dist/test/tune-out-e2e.test.js.map +1 -0
  79. package/dist/test/tune-out-gate-composition.test.d.ts +2 -0
  80. package/dist/test/tune-out-gate-composition.test.d.ts.map +1 -0
  81. package/dist/test/tune-out-gate-composition.test.js +221 -0
  82. package/dist/test/tune-out-gate-composition.test.js.map +1 -0
  83. package/dist/test/tune-out-lifecycle.test.d.ts +2 -0
  84. package/dist/test/tune-out-lifecycle.test.d.ts.map +1 -0
  85. package/dist/test/tune-out-lifecycle.test.js +121 -0
  86. package/dist/test/tune-out-lifecycle.test.js.map +1 -0
  87. package/dist/test/turn-trigger-provenance.test.js +17 -0
  88. package/dist/test/turn-trigger-provenance.test.js.map +1 -1
  89. package/dist/test/workspace-read-image.test.js +8 -0
  90. package/dist/test/workspace-read-image.test.js.map +1 -1
  91. package/dist/tsconfig.tsbuildinfo +1 -1
  92. package/package.json +2 -2
  93. package/src/agent.ts +3 -0
  94. package/src/framework.ts +1051 -154
  95. package/src/gate/event-gate.ts +99 -6
  96. package/src/gate/index.ts +1 -1
  97. package/src/index.ts +1 -1
  98. package/src/mcpl/channel-registry.ts +235 -7
  99. package/src/modules/workspace/index.ts +5 -1
  100. package/src/tool-image-ledger.ts +334 -0
  101. package/src/tool-result-history.ts +30 -9
  102. package/src/tool-wrapper-prose-guard.ts +38 -0
  103. package/src/tune-out/coordinator.ts +548 -0
  104. package/src/tune-out/tools.ts +129 -0
  105. package/src/types/agent.ts +18 -0
  106. package/src/types/framework.ts +7 -0
@@ -0,0 +1,444 @@
1
+ /**
2
+ * TuneOutCoordinator (issue #77) — the host-side machinery between a
3
+ * tuned-out channel and the subconscious resident.
4
+ *
5
+ * Responsibilities: classify diverted traffic (stamp everything, wake on
6
+ * addressed), acknowledge suppressed mentions deterministically, run the
7
+ * per-channel summary cadence, count wakes durably with max-wakes
8
+ * auto-cancel, and deliver the cancel dump.
9
+ *
10
+ * Voice doctrine ("no words in models' mouths"): everything the resident
11
+ * reads from the subconscious is the subconscious's verbatim text under its
12
+ * own participant name. Host-authored framing is system-styled and never
13
+ * voiced: `<tuned-out-backlog …>` wraps raw diverted messages (the
14
+ * <backscroll> precedent), and `[Tune-out: …]` bracket notices carry
15
+ * lifecycle facts (the [Gate: …] precedent).
16
+ */
17
+ import { randomUUID } from 'node:crypto';
18
+ import { CapabilityGrant } from '../mcpl/capability-grant.js';
19
+ /** Defaults for tune_out tool params. */
20
+ export const TUNE_OUT_DEFAULTS = {
21
+ cadenceSeconds: 1800,
22
+ backlogCap: 200,
23
+ maxWakes: 5,
24
+ };
25
+ /** Coalescing window for wake invocations: a mention storm becomes one
26
+ * subconscious turn, and max-wakes counts invocations, not messages. */
27
+ const WAKE_COALESCE_MS = 2_000;
28
+ export class TuneOutCoordinator {
29
+ channelRegistry;
30
+ serverRegistry;
31
+ hooks;
32
+ cadenceTimers = new Map();
33
+ /** Duration-expiry timers (params.expiresAtMs); cleared on any cancel. */
34
+ expiryTimers = new Map();
35
+ /** Channels with a wake invocation pending inside the coalescing window. */
36
+ pendingWakes = new Map();
37
+ /** Diverted-message tallies since the last subconscious invocation, per channel key. */
38
+ divertedSinceInvocation = new Map();
39
+ constructor(channelRegistry, serverRegistry, hooks) {
40
+ this.channelRegistry = channelRegistry;
41
+ this.serverRegistry = serverRegistry;
42
+ this.hooks = hooks;
43
+ }
44
+ key(serverId, channelId) {
45
+ return `${serverId}\0${channelId}`;
46
+ }
47
+ /** Restart cadence + expiry timers and re-anchor after a process restart. */
48
+ resumeActiveEpochs() {
49
+ let oldestAnchor = null;
50
+ for (const { serverId, channelId, params } of this.listActive()) {
51
+ // An epoch whose deadline passed while the process was down cancels
52
+ // immediately — the resident gets their backlog on the schedule they
53
+ // committed to, not whenever the host happened to restart.
54
+ if (params.expiresAtMs !== undefined && params.expiresAtMs <= Date.now()) {
55
+ this.cancel(serverId, channelId, 'duration', 'duration elapsed');
56
+ continue;
57
+ }
58
+ this.startCadence(serverId, channelId, params.cadenceSeconds);
59
+ this.armExpiry(serverId, channelId, params);
60
+ if (oldestAnchor === null || params.startedAtSequence < oldestAnchor) {
61
+ oldestAnchor = params.startedAtSequence;
62
+ }
63
+ }
64
+ if (oldestAnchor !== null) {
65
+ this.hooks.setSubconsciousAnchor(oldestAnchor);
66
+ }
67
+ }
68
+ armExpiry(serverId, channelId, params) {
69
+ if (params.expiresAtMs === undefined)
70
+ return;
71
+ const key = this.key(serverId, channelId);
72
+ const existing = this.expiryTimers.get(key);
73
+ if (existing)
74
+ clearTimeout(existing);
75
+ const remaining = Math.max(0, params.expiresAtMs - Date.now());
76
+ this.expiryTimers.set(key, setTimeout(() => {
77
+ this.expiryTimers.delete(key);
78
+ this.cancel(serverId, channelId, 'duration', 'duration elapsed');
79
+ }, remaining));
80
+ }
81
+ listActive() {
82
+ const active = [];
83
+ for (const entry of this.channelRegistry.listChannelsRaw()) {
84
+ const state = this.channelRegistry.getTuneOutState(entry.serverId, entry.descriptor.id);
85
+ if (state) {
86
+ active.push({ serverId: entry.serverId, channelId: entry.descriptor.id, params: state.params });
87
+ }
88
+ }
89
+ return active;
90
+ }
91
+ // ==========================================================================
92
+ // Enter / cancel
93
+ // ==========================================================================
94
+ enter(serverId, channelId, opts, source) {
95
+ if (!this.hooks.subconsciousName()) {
96
+ return { ok: false, error: 'tune-out requires the subconscious resident (framework config `subconscious`)' };
97
+ }
98
+ if (this.hooks.isForkBound(channelId)) {
99
+ return { ok: false, error: `channel ${channelId} is bound to a conversation fork; tune-out and fork routing are mutually exclusive` };
100
+ }
101
+ if (this.channelRegistry.getTuneOutState(serverId, channelId)) {
102
+ return { ok: false, error: `channel ${channelId} is already tuned out (cancel first to change params)` };
103
+ }
104
+ const params = {
105
+ epochId: randomUUID(),
106
+ cadenceSeconds: Math.max(30, opts.cadenceSeconds ?? TUNE_OUT_DEFAULTS.cadenceSeconds),
107
+ backlogCap: Math.max(0, opts.backlogCap ?? TUNE_OUT_DEFAULTS.backlogCap),
108
+ maxWakes: Math.max(1, opts.maxWakes ?? TUNE_OUT_DEFAULTS.maxWakes),
109
+ startedAtSequence: this.hooks.currentSequence(),
110
+ ...(opts.durationSeconds !== undefined
111
+ ? { expiresAtMs: Date.now() + Math.max(60, opts.durationSeconds) * 1000 }
112
+ : {}),
113
+ };
114
+ this.channelRegistry.enterTuneOut(serverId, channelId, params, source);
115
+ this.armExpiry(serverId, channelId, params);
116
+ // Window anchor: start of the OLDEST active tune-out. Never move the
117
+ // anchor forward here — an older active epoch owns it.
118
+ const oldest = this.listActive().reduce((min, e) => Math.min(min, e.params.startedAtSequence), params.startedAtSequence);
119
+ this.hooks.setSubconsciousAnchor(oldest);
120
+ this.divertedSinceInvocation.set(this.key(serverId, channelId), 0);
121
+ this.startCadence(serverId, channelId, params.cadenceSeconds);
122
+ this.hooks.emitTrace({ type: 'tune-out:entered', serverId, channelId, epochId: params.epochId });
123
+ return { ok: true, params };
124
+ }
125
+ /**
126
+ * End a tune-out: durable flip, system-framed backlog dump into the
127
+ * resident's window (capped), lifecycle notice, one wake for the
128
+ * resident. `subconsciousNote` is the subconscious's own text (from its
129
+ * cancel_tuneout call) — delivered verbatim under its name, never
130
+ * synthesized here.
131
+ */
132
+ cancel(serverId, channelId, source, reason, subconsciousNote) {
133
+ const ended = this.channelRegistry.cancelTuneOut(serverId, channelId, 'open', source);
134
+ if (!ended) {
135
+ return { ok: false, error: `channel ${channelId} is not tuned out` };
136
+ }
137
+ this.stopCadence(serverId, channelId);
138
+ const expiry = this.expiryTimers.get(this.key(serverId, channelId));
139
+ if (expiry) {
140
+ clearTimeout(expiry);
141
+ this.expiryTimers.delete(this.key(serverId, channelId));
142
+ }
143
+ const pending = this.pendingWakes.get(this.key(serverId, channelId));
144
+ if (pending) {
145
+ clearTimeout(pending.timer);
146
+ this.pendingWakes.delete(this.key(serverId, channelId));
147
+ }
148
+ this.divertedSinceInvocation.delete(this.key(serverId, channelId));
149
+ // Backlog: every message stamped with this epoch, oldest first.
150
+ const epochId = ended.params.epochId;
151
+ const backlog = this.hooks.getStoredMessages().filter((m) => m.metadata?.tuneOut?.epochId === epochId);
152
+ const cap = ended.params.backlogCap;
153
+ const shown = cap > 0 ? backlog.slice(-cap) : [];
154
+ const truncated = backlog.length - shown.length;
155
+ const lines = shown.map((m) => {
156
+ const author = m.metadata?.author?.name ?? m.participant;
157
+ const text = m.content
158
+ .filter((b) => b.type === 'text')
159
+ .map((b) => b.text)
160
+ .join('\n');
161
+ return `${author}: ${text}`;
162
+ });
163
+ const attrs = [
164
+ `channel="${channelId}"`,
165
+ `messages=${backlog.length}`,
166
+ ...(truncated > 0 ? [`truncated=${truncated} (oldest; fetch_history covers the rest)`] : []),
167
+ ];
168
+ const dump = `<tuned-out-backlog ${attrs.join(' ')}>\n${lines.join('\n')}\n</tuned-out-backlog>`;
169
+ // Host-framed system artifacts — never voiced as anyone.
170
+ this.hooks.addMessage('user', [{ type: 'text', text: `[Tune-out: ${channelId} cancelled — ${reason}, ${ended.wakeCount} wake${ended.wakeCount === 1 ? '' : 's'}]\n\n${dump}` }], { system: true, kind: 'tune-out-cancel', channelId, epochId });
171
+ // The subconscious's own words, under its own name, verbatim.
172
+ const subName = this.hooks.subconsciousName();
173
+ if (subconsciousNote && subName) {
174
+ this.hooks.addMessage(subName, [{ type: 'text', text: subconsciousNote }], { kind: 'subconscious-note', channelId, epochId });
175
+ }
176
+ const primary = this.hooks.primaryName();
177
+ if (primary) {
178
+ this.hooks.requestInference(primary, `tune-out cancelled (${reason})`, 'tune-out');
179
+ }
180
+ // The subconscious gets one cancel turn of its own (unless it initiated
181
+ // the cancel — its note already carries its words): the issue's cancel
182
+ // shape is dump + a report from the subconscious, and when the cap
183
+ // truncated the raw dump, its summary is what covers the tail.
184
+ if (source !== 'subconscious' && subName) {
185
+ const truncNote = truncated > 0
186
+ ? ` ${truncated} of ${backlog.length} diverted messages were above the cap and not delivered raw.`
187
+ : '';
188
+ this.hooks.addMessage('user', [{ type: 'text', text: `[Tune-out cancelled: ${channelId} — ${reason}.${truncNote}]` }], { system: true, kind: 'tune-out-cancel-report', channelId }, subName);
189
+ this.hooks.requestInference(subName, `tune-out cancelled: ${channelId}`, 'tune-out');
190
+ }
191
+ this.hooks.emitTrace({ type: 'tune-out:cancelled', serverId, channelId, epochId, reason, wakeCount: ended.wakeCount });
192
+ return { ok: true };
193
+ }
194
+ // ==========================================================================
195
+ // Ingestion: divert, stamp, classify
196
+ // ==========================================================================
197
+ /**
198
+ * Consulted by the framework for every incoming channel message BEFORE
199
+ * storage. Null = channel not tuned out (proceed normally). Otherwise the
200
+ * caller stamps `metadata.tuneOut = { epochId }`, stores the message
201
+ * without waking the residents, and this coordinator has already handled
202
+ * wake bookkeeping (coalesced subconscious invocation, durable count,
203
+ * suppression ack, possible auto-cancel).
204
+ */
205
+ onIncoming(serverId, channelId, messageId, tags, authorId, gatePass = true) {
206
+ const state = this.channelRegistry.getTuneOutState(serverId, channelId);
207
+ if (!state)
208
+ return null;
209
+ const key = this.key(serverId, channelId);
210
+ this.divertedSinceInvocation.set(key, (this.divertedSinceInvocation.get(key) ?? 0) + 1);
211
+ // Wake classification: the resident's wake gate composes as a
212
+ // PRECONDITION (antra, #tuneout-talk: the subconscious is affected BY
213
+ // main's wake gate, it does not replace it) — an event the gate would
214
+ // suppress for the resident (muted author, rate-limit) must not wake
215
+ // the subconscious either; it diverts silently into the backlog and
216
+ // surfaces in cadence summaries. On top of the gate: addressed
217
+ // mentions and gate-privileged authors wake, per the issue.
218
+ const addressed = Array.isArray(tags) && tags.includes('chat:addressed');
219
+ const privileged = this.hooks.isPrivilegedAuthor(authorId);
220
+ if (gatePass && addressed) {
221
+ // The mention-er always gets a deterministic signal, independent of
222
+ // what the subconscious later decides (grant-gated; decline
223
+ // precedent). Gate-suppressed mentions get NO reaction: main would
224
+ // not have signaled either, and reacting would leak the resident's
225
+ // standing mute to its subject.
226
+ void this.acknowledgeSuppressed(serverId, channelId, messageId);
227
+ }
228
+ if (gatePass && (addressed || privileged)) {
229
+ this.scheduleWakeInvocation(serverId, channelId);
230
+ }
231
+ return { epochId: state.params.epochId };
232
+ }
233
+ async acknowledgeSuppressed(serverId, channelId, messageId) {
234
+ try {
235
+ const server = this.serverRegistry.getServer(serverId);
236
+ if (!server || !CapabilityGrant.of(server).has('channels.acknowledge'))
237
+ return;
238
+ await server.sendChannelsAcknowledge({
239
+ channelId,
240
+ messageId,
241
+ intent: 'suppressed-tuned-out',
242
+ });
243
+ }
244
+ catch (err) {
245
+ this.hooks.emitTrace({
246
+ type: 'tune-out:ack-failed',
247
+ serverId,
248
+ channelId,
249
+ error: err.message,
250
+ });
251
+ }
252
+ }
253
+ // ==========================================================================
254
+ // Subconscious invocation (cadence + coalesced wakes)
255
+ // ==========================================================================
256
+ startCadence(serverId, channelId, cadenceSeconds) {
257
+ this.stopCadence(serverId, channelId);
258
+ const key = this.key(serverId, channelId);
259
+ const tick = () => {
260
+ const state = this.channelRegistry.getTuneOutState(serverId, channelId);
261
+ if (!state)
262
+ return; // cancelled meanwhile
263
+ const diverted = this.divertedSinceInvocation.get(key) ?? 0;
264
+ // An empty period needs no turn at all — skip silently.
265
+ if (diverted > 0) {
266
+ this.invokeSubconscious(serverId, channelId, 'cadence', diverted);
267
+ }
268
+ this.cadenceTimers.set(key, setTimeout(tick, cadenceSeconds * 1000));
269
+ };
270
+ this.cadenceTimers.set(key, setTimeout(tick, cadenceSeconds * 1000));
271
+ }
272
+ stopCadence(serverId, channelId) {
273
+ const key = this.key(serverId, channelId);
274
+ const timer = this.cadenceTimers.get(key);
275
+ if (timer)
276
+ clearTimeout(timer);
277
+ this.cadenceTimers.delete(key);
278
+ }
279
+ scheduleWakeInvocation(serverId, channelId) {
280
+ const key = this.key(serverId, channelId);
281
+ const pending = this.pendingWakes.get(key);
282
+ if (pending) {
283
+ pending.count++;
284
+ return;
285
+ }
286
+ const timer = setTimeout(() => {
287
+ const entry = this.pendingWakes.get(key);
288
+ this.pendingWakes.delete(key);
289
+ // Count ONE durable wake per coalesced invocation.
290
+ const counted = this.channelRegistry.recordTuneOutWake(serverId, channelId);
291
+ if (!counted)
292
+ return; // cancelled inside the window
293
+ if (counted.wakeCount > counted.params.maxWakes) {
294
+ this.cancel(serverId, channelId, 'tune-out-max-wakes', `wake budget exhausted (${counted.params.maxWakes})`);
295
+ return;
296
+ }
297
+ this.invokeSubconscious(serverId, channelId, 'wake', entry?.count ?? 1);
298
+ }, WAKE_COALESCE_MS);
299
+ this.pendingWakes.set(key, { count: 1, timer });
300
+ }
301
+ /**
302
+ * One subconscious turn: a system-framed trigger notice (bracket style —
303
+ * what happened, never what to say) plus standing dispositions, then an
304
+ * inference request. The merged view supplies the actual traffic.
305
+ */
306
+ invokeSubconscious(serverId, channelId, trigger, count) {
307
+ const subName = this.hooks.subconsciousName();
308
+ if (!subName)
309
+ return;
310
+ const key = this.key(serverId, channelId);
311
+ this.divertedSinceInvocation.set(key, 0);
312
+ const notice = trigger === 'wake'
313
+ ? `[Tune-out wake: ${channelId} — ${count} addressed message${count === 1 ? '' : 's'}]`
314
+ : `[Tune-out cadence: ${channelId} — ${count} diverted message${count === 1 ? '' : 's'} since your last look]`;
315
+ this.hooks.addMessage('user', [{ type: 'text', text: notice }], { system: true, kind: `tune-out-${trigger}`, channelId }, subName);
316
+ this.hooks.requestInference(subName, `tune-out ${trigger}: ${channelId}`, 'tune-out');
317
+ }
318
+ // ==========================================================================
319
+ // Dispositions (standing notes, snapshot slot)
320
+ // ==========================================================================
321
+ dispositionsCache = null;
322
+ get dispositionsStateId() {
323
+ return `subconscious/${this.hooks.primaryName() ?? 'default'}/dispositions`;
324
+ }
325
+ /**
326
+ * The dispositions as a fixed system-position ContextInjection for the
327
+ * subconscious's compiles (antra: deliver changes, never let them wash
328
+ * away — it has no long-term memory, so they must not live in window
329
+ * content). Bytes change only when a disposition changes: KV-friendly.
330
+ */
331
+ getDispositionsInjection() {
332
+ const dispositions = this.readDispositions();
333
+ const entries = Object.entries(dispositions);
334
+ if (entries.length === 0)
335
+ return null;
336
+ return {
337
+ namespace: 'dispositions',
338
+ position: 'system',
339
+ content: [{
340
+ type: 'text',
341
+ text: `[Standing dispositions]\n${entries.map(([k, v]) => `- ${k}: ${v}`).join('\n')}`,
342
+ }],
343
+ };
344
+ }
345
+ readDispositions() {
346
+ if (this.dispositionsCache)
347
+ return this.dispositionsCache;
348
+ try {
349
+ const raw = this.channelRegistry.readCoordinatorState(this.dispositionsStateId);
350
+ this.dispositionsCache = (raw && typeof raw === 'object') ? raw : {};
351
+ }
352
+ catch {
353
+ this.dispositionsCache = {};
354
+ }
355
+ return this.dispositionsCache;
356
+ }
357
+ noteDisposition(key, text) {
358
+ const dispositions = { ...this.readDispositions() };
359
+ if (text === '') {
360
+ delete dispositions[key];
361
+ }
362
+ else {
363
+ dispositions[key] = text;
364
+ }
365
+ this.dispositionsCache = dispositions;
366
+ this.channelRegistry.writeCoordinatorState(this.dispositionsStateId, dispositions);
367
+ }
368
+ // ==========================================================================
369
+ // Subconscious tool dispatch
370
+ // ==========================================================================
371
+ async handleSubconsciousTool(name, input) {
372
+ switch (name) {
373
+ case 'deliver_summary': {
374
+ const text = String(input.text ?? '').trim();
375
+ const channelId = String(input.channelId ?? '');
376
+ if (!text)
377
+ return { success: false, error: 'empty summary', isError: false };
378
+ const subName = this.hooks.subconsciousName();
379
+ if (!subName)
380
+ return { success: false, error: 'subconscious not configured', isError: true };
381
+ // Verbatim, under its own participant name, into the resident's window.
382
+ this.hooks.addMessage(subName, [{ type: 'text', text }], {
383
+ kind: 'subconscious-summary',
384
+ channelId,
385
+ });
386
+ return { success: true, data: { delivered: true } };
387
+ }
388
+ case 'cancel_tuneout': {
389
+ const channelId = String(input.channelId ?? '');
390
+ const located = this.findByChannel(channelId);
391
+ if (!located)
392
+ return { success: false, error: `channel ${channelId} is not tuned out`, isError: false };
393
+ const note = typeof input.text === 'string' && input.text.trim() ? input.text.trim() : undefined;
394
+ const result = this.cancel(located.serverId, channelId, 'subconscious', 'subconscious judgment', note);
395
+ return result.ok
396
+ ? { success: true, data: { cancelled: true } }
397
+ : { success: false, error: result.error, isError: false };
398
+ }
399
+ case 'note_disposition': {
400
+ const key = String(input.key ?? '').trim();
401
+ if (!key)
402
+ return { success: false, error: 'key required', isError: false };
403
+ this.noteDisposition(key, String(input.text ?? ''));
404
+ return { success: true, data: { noted: key } };
405
+ }
406
+ case 'speak_in_channel': {
407
+ if (!this.hooks.allowChannelSpeech()) {
408
+ return {
409
+ success: false,
410
+ isError: false,
411
+ error: 'channel speech is disabled for the subconscious (recipe: subconscious.allowChannelSpeech)',
412
+ };
413
+ }
414
+ const channelId = String(input.channelId ?? '');
415
+ const text = String(input.text ?? '').trim();
416
+ if (!text)
417
+ return { success: false, error: 'empty message', isError: false };
418
+ return this.channelRegistry.publishForAgent(channelId, text, this.hooks.subconsciousName() ?? 'Subconscious');
419
+ }
420
+ default:
421
+ return { success: false, error: `unknown subconscious tool: ${name}`, isError: true };
422
+ }
423
+ }
424
+ findByChannel(channelId) {
425
+ for (const entry of this.listActive()) {
426
+ if (entry.channelId === channelId)
427
+ return { serverId: entry.serverId };
428
+ }
429
+ return null;
430
+ }
431
+ /** Stop all timers (framework shutdown). */
432
+ stop() {
433
+ for (const timer of this.cadenceTimers.values())
434
+ clearTimeout(timer);
435
+ this.cadenceTimers.clear();
436
+ for (const timer of this.expiryTimers.values())
437
+ clearTimeout(timer);
438
+ this.expiryTimers.clear();
439
+ for (const { timer } of this.pendingWakes.values())
440
+ clearTimeout(timer);
441
+ this.pendingWakes.clear();
442
+ }
443
+ }
444
+ //# sourceMappingURL=coordinator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coordinator.js","sourceRoot":"","sources":["../../../src/tune-out/coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAKzC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,yCAAyC;AACzC,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,cAAc,EAAE,IAAI;IACpB,UAAU,EAAE,GAAG;IACf,QAAQ,EAAE,CAAC;CACH,CAAC;AAEX;yEACyE;AACzE,MAAM,gBAAgB,GAAG,KAAK,CAAC;AA+B/B,MAAM,OAAO,kBAAkB;IAUV;IACA;IACA;IAXX,aAAa,GAAG,IAAI,GAAG,EAAyC,CAAC;IACzE,0EAA0E;IAClE,YAAY,GAAG,IAAI,GAAG,EAAyC,CAAC;IACxE,4EAA4E;IACpE,YAAY,GAAG,IAAI,GAAG,EAAmE,CAAC;IAClG,wFAAwF;IAChF,uBAAuB,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE5D,YACmB,eAAgC,EAChC,cAAkC,EAClC,KAA4B;QAF5B,oBAAe,GAAf,eAAe,CAAiB;QAChC,mBAAc,GAAd,cAAc,CAAoB;QAClC,UAAK,GAAL,KAAK,CAAuB;IAC5C,CAAC;IAEI,GAAG,CAAC,QAAgB,EAAE,SAAiB;QAC7C,OAAO,GAAG,QAAQ,KAAK,SAAS,EAAE,CAAC;IACrC,CAAC;IAED,6EAA6E;IAC7E,kBAAkB;QAChB,IAAI,YAAY,GAAkB,IAAI,CAAC;QACvC,KAAK,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC;YAChE,oEAAoE;YACpE,qEAAqE;YACrE,2DAA2D;YAC3D,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS,IAAI,MAAM,CAAC,WAA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EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;QACzE,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,4CAA4C;IAC5C,IAAI;QACF,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QACrE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAC3B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QACpE,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC1B,KAAK,MAAM,EAAE,KAAK,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QACxE,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF"}
@@ -0,0 +1,43 @@
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
+ import type { ToolDefinition } from '../types/index.js';
14
+ export declare const SUBCONSCIOUS_TOOL_NAMES: readonly ["deliver_summary", "cancel_tuneout", "note_disposition", "speak_in_channel"];
15
+ export type SubconsciousToolName = (typeof SUBCONSCIOUS_TOOL_NAMES)[number];
16
+ export declare const SUBCONSCIOUS_TOOLS: ToolDefinition[];
17
+ /**
18
+ * Configuration for the subconscious resident (FrameworkConfig.subconscious).
19
+ */
20
+ export interface SubconsciousConfig {
21
+ /** Master switch. */
22
+ enabled: boolean;
23
+ /**
24
+ * Registry + participant name. Default 'Subconscious' — following the
25
+ * Context Manager precedent: a title-case functional voice, not an
26
+ * agent-prefixed identifier.
27
+ */
28
+ name?: string;
29
+ /** Model id; defaults to the primary agent's (same-model side-process). */
30
+ model?: string;
31
+ /**
32
+ * The voice/criteria mode block — recipe-side and co-authored with the
33
+ * resident (it is an aspect of their attention). Report-shaped, second
34
+ * person toward the resident. Canary before fleet use (issue #77).
35
+ */
36
+ systemPrompt: string;
37
+ /** Allow speak_in_channel. Default false until the voice block has
38
+ * passed its canary round. */
39
+ allowChannelSpeech?: boolean;
40
+ /** WindowedPassthroughStrategy re-anchor fraction (default 0.5). */
41
+ reAnchorFraction?: number;
42
+ }
43
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/tune-out/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,eAAO,MAAM,uBAAuB,wFAK1B,CAAC;AAEX,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5E,eAAO,MAAM,kBAAkB,EAAE,cAAc,EA6E9C,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,qBAAqB;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;mCAC+B;IAC/B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,oEAAoE;IACpE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B"}
@@ -0,0 +1,93 @@
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
+ export const SUBCONSCIOUS_TOOL_NAMES = [
14
+ 'deliver_summary',
15
+ 'cancel_tuneout',
16
+ 'note_disposition',
17
+ 'speak_in_channel',
18
+ ];
19
+ export const SUBCONSCIOUS_TOOLS = [
20
+ {
21
+ name: 'deliver_summary',
22
+ description: 'Deliver a summary into the resident\'s context, in your own voice, ' +
23
+ 'addressed to them (second person). Use at cadence when the diverted ' +
24
+ 'traffic merits it; staying silent is always allowed — an empty ' +
25
+ 'period needs no report.',
26
+ inputSchema: {
27
+ type: 'object',
28
+ properties: {
29
+ text: {
30
+ type: 'string',
31
+ description: 'The summary, verbatim as the resident will read it.',
32
+ },
33
+ channelId: {
34
+ type: 'string',
35
+ description: 'The tuned-out channel this summary covers.',
36
+ },
37
+ },
38
+ required: ['text', 'channelId'],
39
+ },
40
+ },
41
+ {
42
+ name: 'cancel_tuneout',
43
+ description: 'End the tune-out on a channel now — use when something needs the ' +
44
+ 'resident\'s full attention. The diverted backlog is delivered to ' +
45
+ 'them (capped), and normal attention resumes. Add your own note in ' +
46
+ '`text`; it arrives alongside the backlog, in your voice.',
47
+ inputSchema: {
48
+ type: 'object',
49
+ properties: {
50
+ channelId: { type: 'string' },
51
+ text: {
52
+ type: 'string',
53
+ description: 'Your accompanying note to the resident (optional).',
54
+ },
55
+ },
56
+ required: ['channelId'],
57
+ },
58
+ },
59
+ {
60
+ name: 'note_disposition',
61
+ description: 'Record a standing disposition for yourself — a durable note that ' +
62
+ 'shapes how you treat future traffic ("antra\'s pings always ' +
63
+ 'escalate", "ignore release-bot"). Replaces any previous note under ' +
64
+ 'the same key.',
65
+ inputSchema: {
66
+ type: 'object',
67
+ properties: {
68
+ key: { type: 'string', description: 'Short stable identifier.' },
69
+ text: {
70
+ type: 'string',
71
+ description: 'The disposition. Empty string deletes the key.',
72
+ },
73
+ },
74
+ required: ['key', 'text'],
75
+ },
76
+ },
77
+ {
78
+ name: 'speak_in_channel',
79
+ description: 'Post a message into a tuned-out channel, clearly as yourself (not ' +
80
+ 'as the resident). Use sparingly — e.g. to tell someone the resident ' +
81
+ 'is tuned out and when to expect them. Disabled unless the resident\'s ' +
82
+ 'configuration allows it.',
83
+ inputSchema: {
84
+ type: 'object',
85
+ properties: {
86
+ channelId: { type: 'string' },
87
+ text: { type: 'string' },
88
+ },
89
+ required: ['channelId', 'text'],
90
+ },
91
+ },
92
+ ];
93
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/tune-out/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,iBAAiB;IACjB,gBAAgB;IAChB,kBAAkB;IAClB,kBAAkB;CACV,CAAC;AAIX,MAAM,CAAC,MAAM,kBAAkB,GAAqB;IAClD;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EACT,qEAAqE;YACrE,sEAAsE;YACtE,iEAAiE;YACjE,yBAAyB;QAC3B,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,qDAAqD;iBACnE;gBACD,SAAS,EAAE;oBACT,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,4CAA4C;iBAC1D;aACF;YACD,QAAQ,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC;SAChC;KACF;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,WAAW,EACT,mEAAmE;YACnE,mEAAmE;YACnE,oEAAoE;YACpE,0DAA0D;QAC5D,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC7B,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,oDAAoD;iBAClE;aACF;YACD,QAAQ,EAAE,CAAC,WAAW,CAAC;SACxB;KACF;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,WAAW,EACT,mEAAmE;YACnE,8DAA8D;YAC9D,qEAAqE;YACrE,eAAe;QACjB,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,0BAA0B,EAAE;gBAChE,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,gDAAgD;iBAC9D;aACF;YACD,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;SAC1B;KACF;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,WAAW,EACT,oEAAoE;YACpE,sEAAsE;YACtE,wEAAwE;YACxE,0BAA0B;QAC5B,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC7B,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;aACzB;YACD,QAAQ,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC;SAChC;KACF;CACF,CAAC"}
@@ -164,6 +164,13 @@ export interface AgentConfig {
164
164
  * send externally; prose remains in Chronicle with a private suppression receipt.
165
165
  */
166
166
  proseRouting?: 'locus' | 'explicit' | 'hybrid' | 'disabled';
167
+ /**
168
+ * Fail-closed containment for a text response whose entire visible prose is
169
+ * an invocation-shaped wrapper naming a tool registered on that exact turn.
170
+ * The wrapper is neither executed nor stored as assistant continuity; a
171
+ * content-free system receipt is stored instead. Default false.
172
+ */
173
+ toolWrapperProseGuard?: boolean;
167
174
  }
168
175
  /** The intentionally small set of agent settings that may change in-process. */
169
176
  export interface AgentRuntimeSettingsPatch {
@@ -302,5 +309,15 @@ export interface InferenceRequest {
302
309
  * so a household ledger can say who woke whom; carries no content.
303
310
  */
304
311
  counterparty?: string;
312
+ /**
313
+ * Where the wake came from, for telemetry ONLY — never a speech locus.
314
+ * Set by the EventGate for batched wakes (composite channel id of the
315
+ * chosen event when the event carried one; push-event raw ids are not
316
+ * used). Routing keeps reading `channelId`, which only the direct channel
317
+ * paths set from normalized ids — a gate wake leaves it unset, as before.
318
+ */
319
+ wakeChannelId?: string;
320
+ /** Timestamp of the event the wake provenance was taken from (ms). */
321
+ wakeAt?: number;
305
322
  }
306
323
  //# sourceMappingURL=agent.d.ts.map