@animalabs/agent-framework 0.22.0 → 0.22.1

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 (147) hide show
  1. package/README.md +11 -4
  2. package/dist/src/agent.d.ts.map +1 -1
  3. package/dist/src/agent.js +3 -1
  4. package/dist/src/agent.js.map +1 -1
  5. package/dist/src/api/server.d.ts.map +1 -1
  6. package/dist/src/api/server.js +41 -4
  7. package/dist/src/api/server.js.map +1 -1
  8. package/dist/src/framework.d.ts +319 -20
  9. package/dist/src/framework.d.ts.map +1 -1
  10. package/dist/src/framework.js +1500 -182
  11. package/dist/src/framework.js.map +1 -1
  12. package/dist/src/index.d.ts +2 -2
  13. package/dist/src/index.d.ts.map +1 -1
  14. package/dist/src/index.js.map +1 -1
  15. package/dist/src/mcpl/index.d.ts +2 -0
  16. package/dist/src/mcpl/index.d.ts.map +1 -1
  17. package/dist/src/mcpl/index.js.map +1 -1
  18. package/dist/src/mcpl/reference-fetcher.d.ts +2 -1
  19. package/dist/src/mcpl/reference-fetcher.d.ts.map +1 -1
  20. package/dist/src/mcpl/reference-fetcher.js +20 -9
  21. package/dist/src/mcpl/reference-fetcher.js.map +1 -1
  22. package/dist/src/mcpl/references.d.ts +29 -6
  23. package/dist/src/mcpl/references.d.ts.map +1 -1
  24. package/dist/src/mcpl/references.js +57 -16
  25. package/dist/src/mcpl/references.js.map +1 -1
  26. package/dist/src/mcpl/server-connection.d.ts +28 -1
  27. package/dist/src/mcpl/server-connection.d.ts.map +1 -1
  28. package/dist/src/mcpl/server-connection.js +32 -4
  29. package/dist/src/mcpl/server-connection.js.map +1 -1
  30. package/dist/src/module-registry.d.ts +9 -3
  31. package/dist/src/module-registry.d.ts.map +1 -1
  32. package/dist/src/module-registry.js +3 -2
  33. package/dist/src/module-registry.js.map +1 -1
  34. package/dist/src/modules/workspace/index.d.ts.map +1 -1
  35. package/dist/src/modules/workspace/index.js +46 -4
  36. package/dist/src/modules/workspace/index.js.map +1 -1
  37. package/dist/src/modules/workspace/observe.d.ts +13 -3
  38. package/dist/src/modules/workspace/observe.d.ts.map +1 -1
  39. package/dist/src/modules/workspace/observe.js +24 -4
  40. package/dist/src/modules/workspace/observe.js.map +1 -1
  41. package/dist/src/modules/workspace/reconcile.d.ts +14 -0
  42. package/dist/src/modules/workspace/reconcile.d.ts.map +1 -1
  43. package/dist/src/modules/workspace/reconcile.js +10 -2
  44. package/dist/src/modules/workspace/reconcile.js.map +1 -1
  45. package/dist/src/operator-log.d.ts +41 -0
  46. package/dist/src/operator-log.d.ts.map +1 -1
  47. package/dist/src/operator-log.js.map +1 -1
  48. package/dist/src/provider-waits.d.ts +216 -0
  49. package/dist/src/provider-waits.d.ts.map +1 -0
  50. package/dist/src/provider-waits.js +482 -0
  51. package/dist/src/provider-waits.js.map +1 -0
  52. package/dist/src/refusal-reactions.d.ts +14 -12
  53. package/dist/src/refusal-reactions.d.ts.map +1 -1
  54. package/dist/src/refusal-reactions.js +14 -12
  55. package/dist/src/refusal-reactions.js.map +1 -1
  56. package/dist/src/tool-result-guard.d.ts +30 -13
  57. package/dist/src/tool-result-guard.d.ts.map +1 -1
  58. package/dist/src/tool-result-guard.js +71 -25
  59. package/dist/src/tool-result-guard.js.map +1 -1
  60. package/dist/src/types/events.d.ts +12 -0
  61. package/dist/src/types/events.d.ts.map +1 -1
  62. package/dist/src/types/module.d.ts +12 -4
  63. package/dist/src/types/module.d.ts.map +1 -1
  64. package/dist/src/types/trace.d.ts +14 -3
  65. package/dist/src/types/trace.d.ts.map +1 -1
  66. package/dist/test/discord-awareness-outbox.test.js +3 -0
  67. package/dist/test/discord-awareness-outbox.test.js.map +1 -1
  68. package/dist/test/explicit-prose-routing.test.js +0 -2
  69. package/dist/test/explicit-prose-routing.test.js.map +1 -1
  70. package/dist/test/framework.test.js +160 -1
  71. package/dist/test/framework.test.js.map +1 -1
  72. package/dist/test/helpers/coalescing-fixture.d.ts.map +1 -1
  73. package/dist/test/helpers/coalescing-fixture.js +3 -2
  74. package/dist/test/helpers/coalescing-fixture.js.map +1 -1
  75. package/dist/test/inference-exhaustion-rewind.test.js +142 -14
  76. package/dist/test/inference-exhaustion-rewind.test.js.map +1 -1
  77. package/dist/test/inference-failure-bounds.test.d.ts +2 -0
  78. package/dist/test/inference-failure-bounds.test.d.ts.map +1 -0
  79. package/dist/test/inference-failure-bounds.test.js +1201 -0
  80. package/dist/test/inference-failure-bounds.test.js.map +1 -0
  81. package/dist/test/late-events-after-stop.test.d.ts +2 -0
  82. package/dist/test/late-events-after-stop.test.d.ts.map +1 -0
  83. package/dist/test/late-events-after-stop.test.js +122 -0
  84. package/dist/test/late-events-after-stop.test.js.map +1 -0
  85. package/dist/test/mcpl-awareness-barrier.test.js +141 -0
  86. package/dist/test/mcpl-awareness-barrier.test.js.map +1 -1
  87. package/dist/test/mcpl-coalescing.test.js +78 -16
  88. package/dist/test/mcpl-coalescing.test.js.map +1 -1
  89. package/dist/test/mcpl-config-diagnostics.test.js +6 -3
  90. package/dist/test/mcpl-config-diagnostics.test.js.map +1 -1
  91. package/dist/test/mcpl-manifest-changed.test.js +2 -1
  92. package/dist/test/mcpl-manifest-changed.test.js.map +1 -1
  93. package/dist/test/mcpl-reference-fetcher.test.js +232 -4
  94. package/dist/test/mcpl-reference-fetcher.test.js.map +1 -1
  95. package/dist/test/mcpl-reference-fields.test.js +69 -2
  96. package/dist/test/mcpl-reference-fields.test.js.map +1 -1
  97. package/dist/test/mcpl-ws-transport.test.js +103 -0
  98. package/dist/test/mcpl-ws-transport.test.js.map +1 -1
  99. package/dist/test/ops-alert.test.js +2 -1
  100. package/dist/test/ops-alert.test.js.map +1 -1
  101. package/dist/test/placed-reaction-baseline.test.d.ts +2 -0
  102. package/dist/test/placed-reaction-baseline.test.d.ts.map +1 -0
  103. package/dist/test/placed-reaction-baseline.test.js +312 -0
  104. package/dist/test/placed-reaction-baseline.test.js.map +1 -0
  105. package/dist/test/provider-acceleration-cooldown.test.js +5 -1
  106. package/dist/test/provider-acceleration-cooldown.test.js.map +1 -1
  107. package/dist/test/provider-waits.test.d.ts +2 -0
  108. package/dist/test/provider-waits.test.d.ts.map +1 -0
  109. package/dist/test/provider-waits.test.js +2196 -0
  110. package/dist/test/provider-waits.test.js.map +1 -0
  111. package/dist/test/reaction-baseline-platform.test.d.ts +2 -0
  112. package/dist/test/reaction-baseline-platform.test.d.ts.map +1 -0
  113. package/dist/test/reaction-baseline-platform.test.js +124 -0
  114. package/dist/test/reaction-baseline-platform.test.js.map +1 -0
  115. package/dist/test/refusal-reaction-baseline.test.js +10 -3
  116. package/dist/test/refusal-reaction-baseline.test.js.map +1 -1
  117. package/dist/test/save-recent-image.test.js +138 -2
  118. package/dist/test/save-recent-image.test.js.map +1 -1
  119. package/dist/test/surgery-marks-receipt.test.d.ts +2 -0
  120. package/dist/test/surgery-marks-receipt.test.d.ts.map +1 -0
  121. package/dist/test/surgery-marks-receipt.test.js +540 -0
  122. package/dist/test/surgery-marks-receipt.test.js.map +1 -0
  123. package/dist/test/tool-result-guard.test.js +221 -7
  124. package/dist/test/tool-result-guard.test.js.map +1 -1
  125. package/dist/test/workspace-three-way.test.js +115 -0
  126. package/dist/test/workspace-three-way.test.js.map +1 -1
  127. package/dist/tsconfig.tsbuildinfo +1 -1
  128. package/package.json +1 -1
  129. package/src/agent.ts +4 -1
  130. package/src/api/server.ts +43 -4
  131. package/src/framework.ts +1538 -189
  132. package/src/index.ts +7 -2
  133. package/src/mcpl/index.ts +2 -0
  134. package/src/mcpl/reference-fetcher.ts +18 -8
  135. package/src/mcpl/references.ts +57 -13
  136. package/src/mcpl/server-connection.ts +55 -4
  137. package/src/module-registry.ts +17 -9
  138. package/src/modules/workspace/index.ts +44 -4
  139. package/src/modules/workspace/observe.ts +31 -5
  140. package/src/modules/workspace/reconcile.ts +23 -2
  141. package/src/operator-log.ts +30 -0
  142. package/src/provider-waits.ts +523 -0
  143. package/src/refusal-reactions.ts +14 -12
  144. package/src/tool-result-guard.ts +72 -24
  145. package/src/types/events.ts +12 -0
  146. package/src/types/module.ts +12 -4
  147. package/src/types/trace.ts +14 -3
@@ -0,0 +1,482 @@
1
+ /**
2
+ * Provider waits: a provider's stated `retry-after`, kept as a deadline that
3
+ * outlives the process.
4
+ *
5
+ * When a provider answers "retry after N", calling the same model again
6
+ * before then adds traffic the provider has said will fail. The framework
7
+ * therefore records the wait per (agent, model) and admits no call to that
8
+ * model for that agent until it passes. The wait is a fact about the provider,
9
+ * not about the conversation, so it is kept in typed Chronicle records
10
+ * (RecordJournal): a restart honours it, and a branch switch or rollback
11
+ * does not rewind it.
12
+ *
13
+ * - A later, shorter wait for the same (agent, model) never shortens an
14
+ * outstanding longer one: the binding deadline is the maximum. Requests
15
+ * that finish at different times can carry different hints.
16
+ * - A negative wait is already over (a provider's "retry now", or an HTTP
17
+ * date already past), -Infinity included: it binds nothing, the same as 0.
18
+ * - A wait that cannot be represented as an instant (NaN, +Infinity, or past
19
+ * the last instant a Date can hold) becomes an indefinite wait rather than
20
+ * a shorter one, held until explicitly released.
21
+ * - A wait ends when its instant passes (nothing is written), or when an
22
+ * operator releases it (recorded). Selecting a different model is not a
23
+ * release: that model proceeds, and the old model's wait still applies if it
24
+ * is selected again before the wait passes.
25
+ *
26
+ * One writer per record type (RecordJournal's contract): the framework that
27
+ * owns the store.
28
+ */
29
+ import { RecordJournal } from './record-journal.js';
30
+ import { safeSlice } from './safe-slice.js';
31
+ export const PROVIDER_WAIT_RECORD_TYPE = 'framework/provider-wait';
32
+ /** Checkpoint the reduced waits after this many entries, bounding replay at open. */
33
+ const CHECKPOINT_EVERY = 64;
34
+ /** The last instant a JavaScript Date can represent (ECMA-262 time value range). */
35
+ const MAX_DATE_MS = 8.64e15;
36
+ /**
37
+ * The instant a stated wait ends, or null when it cannot be represented:
38
+ * the wait is then held until released, never shortened. A negative wait
39
+ * ends at `now`: it is already over, never indefinite.
40
+ */
41
+ export function waitDeadline(retryAfterMs, now) {
42
+ if (typeof retryAfterMs !== 'number' || Number.isNaN(retryAfterMs))
43
+ return null;
44
+ // Over before it can't be represented: -Infinity is as negative as any.
45
+ if (retryAfterMs <= 0)
46
+ return Math.ceil(now);
47
+ if (!Number.isFinite(retryAfterMs))
48
+ return null;
49
+ const until = Math.ceil(now + Math.max(0, retryAfterMs));
50
+ if (!Number.isSafeInteger(until) || until > MAX_DATE_MS)
51
+ return null;
52
+ return until;
53
+ }
54
+ const keyOf = (agent, model) => `${agent}\u0000${model}`;
55
+ /** Whether `next` binds longer than `current` (null is longer than any instant). */
56
+ function outlasts(next, current) {
57
+ if (current === null)
58
+ return false;
59
+ if (next === null)
60
+ return true;
61
+ return next > current;
62
+ }
63
+ function reduce(waits, entry) {
64
+ if (entry.kind === 'set') {
65
+ const key = keyOf(entry.agent, entry.model);
66
+ const current = waits.get(key);
67
+ if (current && !outlasts(entry.until, current.until))
68
+ return;
69
+ waits.set(key, { agent: entry.agent, model: entry.model, until: entry.until, reason: entry.reason, setAt: entry.at });
70
+ return;
71
+ }
72
+ for (const [key, wait] of waits) {
73
+ if (wait.agent === entry.agent && (entry.model === null || wait.model === entry.model))
74
+ waits.delete(key);
75
+ }
76
+ }
77
+ /** How often a binding act this process could not record is offered to the journal again, absent another act. */
78
+ const RETRY_WRITE_MS = 30_000;
79
+ /** How often unreadable recorded waits are read again, by default (`retryReadMs`). */
80
+ const RETRY_READ_MS = 30_000;
81
+ /**
82
+ * The model that stands for every model: how list() shows the hold for
83
+ * unreadable records, and what release() takes as "every model" (the same as
84
+ * omitting it). No provider model is named that.
85
+ */
86
+ export const EVERY_MODEL = '*';
87
+ /** A control character (C0, C1, U+2028, U+2029): in a log line, one can start
88
+ * a line that reads as the framework's own. */
89
+ const CONTROL_CHARACTER = /[\u0000-\u001f\u007f-\u009f\u2028\u2029]/;
90
+ /** Text from a caller or a provider, with each control character a space, so
91
+ * it can't forge a log line where it is printed. */
92
+ export function withoutControls(text) {
93
+ return text.replace(new RegExp(CONTROL_CHARACTER.source, 'g'), ' ');
94
+ }
95
+ /**
96
+ * Whether a release's `model`, as an operator surface receives it, names a
97
+ * scope: omitted or EVERY_MODEL for every model, any other nonempty string
98
+ * without a control character for that model. Anything else is malformed and
99
+ * is refused, never taken as "every model" (and never logged).
100
+ */
101
+ export function isReleaseModel(model) {
102
+ return model === undefined || (typeof model === 'string' && model !== '' && !CONTROL_CHARACTER.test(model));
103
+ }
104
+ const errorText = (error) => (error instanceof Error ? error.message : String(error));
105
+ const live = (wait, now) => wait && (wait.until === null || wait.until > now) ? wait : undefined;
106
+ // What a record must hold to be read as provider waits: every field the
107
+ // reduction, or a reader of its waits, uses. A record that parses but lacks
108
+ // one is unreadable (fail closed), never read as "no waits".
109
+ const fieldsOf = (value) => typeof value === 'object' && value !== null && !Array.isArray(value) ? value : undefined;
110
+ const isText = (value) => typeof value === 'string';
111
+ /** A number a Date can hold (NaN and the infinities fail the comparison). */
112
+ const isInstant = (value) => typeof value === 'number' && Math.abs(value) <= MAX_DATE_MS;
113
+ const isDeadline = (value) => value === null || isInstant(value);
114
+ function isWait(value) {
115
+ const wait = fieldsOf(value);
116
+ return wait !== undefined && isText(wait.agent) && isText(wait.model) && isDeadline(wait.until) &&
117
+ isText(wait.reason) && isInstant(wait.setAt);
118
+ }
119
+ /** A release's `by` and `at` are never read back, so they are not required. */
120
+ function isEntry(value) {
121
+ const entry = fieldsOf(value);
122
+ if (entry === undefined || !isText(entry.agent))
123
+ return false;
124
+ if (entry.kind === 'set') {
125
+ return isText(entry.model) && isDeadline(entry.until) && isText(entry.reason) && isInstant(entry.at);
126
+ }
127
+ return entry.kind === 'released' && (entry.model === null || isText(entry.model));
128
+ }
129
+ function isSnapshot(value) {
130
+ const waits = fieldsOf(value)?.waits;
131
+ if (!Array.isArray(waits) || !waits.every(isWait))
132
+ return false;
133
+ // The writer keeps one wait per (agent, model). A repeated key has no
134
+ // reading that is sure to keep the longer wait.
135
+ return new Set(waits.map((wait) => keyOf(wait.agent, wait.model))).size === waits.length;
136
+ }
137
+ export class ProviderWaits {
138
+ /**
139
+ * The reduction of exactly what the journal holds: its latest checkpoint and
140
+ * every entry after it, as loaded or as appended and synced. A checkpoint
141
+ * records this, so it covers the same ordered acts the journal does.
142
+ */
143
+ durable = new Map();
144
+ /**
145
+ * Acts of this process not yet known to be durably recorded, in the order
146
+ * they were made. They bind here from the moment they are made, and are
147
+ * offered to the journal, in order, at every later act until one lands.
148
+ * Once the journal can't be written again (an append that threw inside the
149
+ * store: RecordJournal.needsReopen), they are offered no more: the act that
150
+ * threw may still be in the store's log, where the next start finds it,
151
+ * and every later one holds in this process only.
152
+ */
153
+ pending = [];
154
+ /** What binds in this process: `durable` with `pending` applied in order. */
155
+ view = new Map();
156
+ /**
157
+ * Set while the recorded waits cannot be read. Their absence is then
158
+ * unknown, not "no waits": every (agent, model) is held (fail closed) until
159
+ * they can be read or an operator releases the agent's waits. Releases made
160
+ * meanwhile are kept in `waived` (agent, model or EVERY_MODEL) for this
161
+ * process; a restart that still cannot read them holds again.
162
+ */
163
+ unreadable = null;
164
+ lastWriteTry = 0;
165
+ /**
166
+ * How often unreadable recorded waits are read again. The hold that stands
167
+ * for them ends without any act (the records read again), so whoever holds
168
+ * on a wait with no deadline asks active() again this often.
169
+ */
170
+ retryReadMs;
171
+ store;
172
+ journal;
173
+ now;
174
+ log;
175
+ onUnreadable;
176
+ /**
177
+ * `store` null keeps waits in memory only (a framework without a store has
178
+ * no restart to survive). `onUnreadable` hears each time the recorded waits
179
+ * become unreadable, once per episode (a restart that still cannot read them
180
+ * is a new one): every (agent, model) is then held until they read again or
181
+ * an operator releases, and a cause that persists (a malformed or newer
182
+ * record) never reads again, so a person has to hear of it.
183
+ */
184
+ constructor(store, opts = {}) {
185
+ this.now = opts.now ?? Date.now;
186
+ this.log = opts.log ?? ((line) => console.error(line));
187
+ this.onUnreadable = opts.onUnreadable ?? (() => { });
188
+ this.retryReadMs = opts.retryReadMs ?? RETRY_READ_MS;
189
+ this.store = store;
190
+ this.journal = store ? new RecordJournal(store, { type: PROVIDER_WAIT_RECORD_TYPE }) : null;
191
+ this.load();
192
+ }
193
+ /**
194
+ * The wait binding (agent, model) now, if any. While the recorded waits
195
+ * cannot be read, an indefinite wait saying so, unless an operator released
196
+ * this agent's waits since.
197
+ */
198
+ active(agent, model) {
199
+ this.retry();
200
+ if (this.unreadable && !this.waived(agent, model))
201
+ return this.unreadableWait(agent, model);
202
+ const wait = live(this.view.get(keyOf(agent, model)), this.now());
203
+ return wait ? { ...wait } : undefined;
204
+ }
205
+ /**
206
+ * Whether a recorded wait binds this agent now, unreadable history aside:
207
+ * the agent of a wait the listing shows, even one the framework no longer
208
+ * has (a disposed conversation fork), which a release can then name.
209
+ */
210
+ recorded(agent) {
211
+ const now = this.now();
212
+ for (const wait of this.view.values())
213
+ if (wait.agent === agent && live(wait, now))
214
+ return true;
215
+ return false;
216
+ }
217
+ /**
218
+ * Every wait binding now, for one agent or all. While the recorded waits
219
+ * cannot be read, it leads with an indefinite wait on EVERY_MODEL saying
220
+ * so (for the agent asked about, or for EVERY_MODEL agents).
221
+ */
222
+ list(agent) {
223
+ this.retry();
224
+ const result = [];
225
+ if (this.unreadable && (agent === undefined || !this.waived(agent, EVERY_MODEL))) {
226
+ result.push(this.unreadableWait(agent ?? EVERY_MODEL, EVERY_MODEL));
227
+ }
228
+ const now = this.now();
229
+ for (const wait of this.view.values()) {
230
+ if (agent !== undefined && wait.agent !== agent)
231
+ continue;
232
+ if (live(wait, now))
233
+ result.push({ ...wait });
234
+ }
235
+ return result;
236
+ }
237
+ /** Record a provider's stated wait for (agent, model). */
238
+ set(agent, model, retryAfterMs, reason) {
239
+ const at = this.now();
240
+ // Decide against what the journal now holds: an earlier ambiguous write
241
+ // is reconciled first.
242
+ this.reconcile();
243
+ const entry = { kind: 'set', agent, model, until: waitDeadline(retryAfterMs, at), reason, at };
244
+ const before = live(this.view.get(keyOf(agent, model)), at);
245
+ // A wait already over (0, or a "retry now") binds nothing: with nothing
246
+ // binding either, there is nothing to record.
247
+ if (before === undefined && entry.until !== null && entry.until <= at) {
248
+ this.flush();
249
+ return { wait: { agent, model, until: entry.until, reason, setAt: at }, changed: false };
250
+ }
251
+ const changed = before === undefined || outlasts(entry.until, before.until);
252
+ if (changed)
253
+ this.apply(entry);
254
+ // An unchanged binding is not proof it was recorded: offer what is pending.
255
+ this.flush();
256
+ return { wait: { ...this.view.get(keyOf(agent, model)) }, changed };
257
+ }
258
+ /**
259
+ * Release (agent, model)'s wait, or every wait of the agent when `model` is
260
+ * omitted; recorded. While the recorded waits cannot be read, it also lifts
261
+ * the hold that stands for them, exactly as far as the release names (that
262
+ * model, or every model), in this process only. Each lifted wait says how
263
+ * far its release reaches (ProviderWaitRelease). A release that finds
264
+ * nothing binding lifts and records nothing, and lists nothing. That
265
+ * includes a replay of an earlier release. It still offers this process's
266
+ * unrecorded acts to the journal again.
267
+ */
268
+ release(agent, model, by) {
269
+ // EVERY_MODEL, as list() shows it, names every model: the same release
270
+ // as omitting the model, in this process and in the record alike.
271
+ if (model === EVERY_MODEL)
272
+ model = undefined;
273
+ this.reconcile();
274
+ const now = this.now();
275
+ const released = [...this.view.values()]
276
+ .filter((wait) => wait.agent === agent && (model === undefined || wait.model === model) && live(wait, now))
277
+ .map((wait) => ({ ...wait }));
278
+ const target = model ?? EVERY_MODEL;
279
+ let override;
280
+ if (this.unreadable && !this.waived(agent, target)) {
281
+ override = this.unreadableWait(agent, target);
282
+ this.unreadable.waived.add(keyOf(agent, target));
283
+ }
284
+ if (released.length === 0 && !override) {
285
+ // Nothing binds to lift, so this release lists nothing. It may be a
286
+ // replay of one whose record hasn't landed ('pending'): offer this
287
+ // process's unrecorded acts to the journal again now.
288
+ this.flush();
289
+ return [];
290
+ }
291
+ const entry = { kind: 'released', agent, model: model ?? null, by, at: now };
292
+ this.apply(entry);
293
+ this.flush();
294
+ const recorded = !this.pending.includes(entry);
295
+ return [
296
+ ...(override ? [{ wait: override, release: 'in-process override' }] : []),
297
+ ...released.map((wait) => ({ wait, release: recorded ? 'recorded' : 'pending' })),
298
+ ];
299
+ }
300
+ waived(agent, model) {
301
+ const waived = this.unreadable?.waived;
302
+ return waived !== undefined && (waived.has(keyOf(agent, EVERY_MODEL)) || waived.has(keyOf(agent, model)));
303
+ }
304
+ unreadableWait(agent, model) {
305
+ return {
306
+ agent, model, until: null, setAt: this.unreadable.at,
307
+ reason: `recorded provider waits could not be read (${this.unreadable.error}); held until they can be read or an operator releases this agent's waits`,
308
+ };
309
+ }
310
+ /** Make an act bind in this process, ahead of its record. */
311
+ apply(entry) {
312
+ this.pending.push(entry);
313
+ reduce(this.view, entry);
314
+ }
315
+ /** Rebuild what binds from the journal's reduction and this process's pending acts, in order. */
316
+ rebuildView() {
317
+ const view = new Map();
318
+ for (const [key, wait] of this.durable)
319
+ view.set(key, { ...wait });
320
+ for (const entry of this.pending)
321
+ reduce(view, entry);
322
+ this.view = view;
323
+ }
324
+ /**
325
+ * Read the journal into `durable`. A failure leaves the history unreadable
326
+ * (fail closed, reported once), never empty. So does a record that parses
327
+ * but cannot be read as provider waits: a checkpoint also stands for every
328
+ * entry before it, so a malformed one read as empty would drop them all.
329
+ */
330
+ load() {
331
+ if (!this.journal)
332
+ return true;
333
+ const now = this.now();
334
+ try {
335
+ const { snapshot, entries } = this.journal.load();
336
+ // RecordJournal shows a checkpoint whose snapshot is null as no
337
+ // checkpoint at all (it still skips the entries it covers); this writer
338
+ // never writes one, so finding such a record means it is malformed.
339
+ const malformedCheckpoint = snapshot === null
340
+ ? this.store.getRecordIdsByType(this.journal.checkpointType).length > 0
341
+ : !isSnapshot(snapshot);
342
+ if (malformedCheckpoint)
343
+ throw new Error('a provider-wait checkpoint is malformed');
344
+ for (const { id, entry } of entries) {
345
+ if (!isEntry(entry))
346
+ throw new Error(`provider-wait record ${id} is malformed`);
347
+ }
348
+ const loaded = new Map();
349
+ for (const wait of snapshot?.waits ?? [])
350
+ loaded.set(keyOf(wait.agent, wait.model), { ...wait });
351
+ for (const { entry } of entries)
352
+ reduce(loaded, entry);
353
+ this.durable = loaded;
354
+ }
355
+ catch (error) {
356
+ if (this.unreadable) {
357
+ this.unreadable.lastTry = now;
358
+ }
359
+ else {
360
+ this.unreadable = { error: safeSlice(errorText(error), 0, 300), at: now, lastTry: now, waived: new Set() };
361
+ this.log(`[provider-wait] recorded provider waits could not be read (${this.unreadable.error}): ` +
362
+ 'no provider call is admitted until they can be read or an operator releases an agent\'s waits ' +
363
+ '(release-provider-wait); inspection is unaffected');
364
+ try {
365
+ this.onUnreadable(this.unreadable.error);
366
+ }
367
+ catch { /* reporting never changes the hold */ }
368
+ }
369
+ return false;
370
+ }
371
+ const wasUnreadable = this.unreadable !== null;
372
+ this.unreadable = null;
373
+ this.rebuildView();
374
+ // What binds is the journal's reduction with this process's unrecorded
375
+ // acts applied after it: a release made meanwhile lifts what it names.
376
+ if (wasUnreadable)
377
+ this.log(`[provider-wait] recorded provider waits are readable again; ${loaded(this.view, now)} bind`);
378
+ return true;
379
+ }
380
+ /** Reconcile an ambiguous write before deciding anything against the journal. */
381
+ reconcile() {
382
+ if (this.journal?.needsReconcile)
383
+ this.load();
384
+ }
385
+ /** Offer unrecorded acts and unreadable history again, at most every so often, absent other acts. */
386
+ retry() {
387
+ const now = this.now();
388
+ if (this.unreadable && now - this.unreadable.lastTry >= this.retryReadMs)
389
+ this.load();
390
+ if (this.pending.length > 0 && now - this.lastWriteTry >= RETRY_WRITE_MS) {
391
+ this.reconcile();
392
+ this.flush();
393
+ }
394
+ }
395
+ /**
396
+ * Record pending acts in order, each durable before the next: a lost wait
397
+ * would admit an early call after a crash. The first that fails stays
398
+ * pending with every act after it (they still bind in this process) and is
399
+ * reported; an ambiguous one is reconciled before the next attempt, so an
400
+ * act may be recorded twice, which reduces the same. An append or
401
+ * checkpoint that throws inside the store leaves the journal unwritable
402
+ * until the store is reopened (RecordJournal.needsReopen), so nothing is
403
+ * written after it: that is said once, where it happens, and the acts stay
404
+ * pending, binding in this process. A checkpoint records the
405
+ * journal's own reduction, never this process's unrecorded acts, and never
406
+ * while the history is unreadable (it would cover entries that were never
407
+ * reduced).
408
+ */
409
+ flush() {
410
+ if (!this.journal) {
411
+ for (const entry of this.pending.splice(0))
412
+ reduce(this.durable, entry);
413
+ return;
414
+ }
415
+ this.lastWriteTry = this.now();
416
+ while (this.pending.length > 0) {
417
+ if (this.journal.needsReconcile && !this.load())
418
+ return;
419
+ if (this.journal.needsReconcile)
420
+ return;
421
+ // Offering again would only fail again; reportUnwritable said so when
422
+ // the write threw.
423
+ if (this.journal.needsReopen)
424
+ return;
425
+ const entry = this.pending[0];
426
+ try {
427
+ this.journal.append(entry, { durable: true });
428
+ }
429
+ catch (error) {
430
+ if (this.journal.needsReopen) {
431
+ this.reportUnwritable(error, `${entry.kind === 'set' ? 'a wait' : 'a release'} for agent=${entry.agent} model=${entry.model ?? EVERY_MODEL}`);
432
+ return;
433
+ }
434
+ this.log(`[provider-wait] could not record ${entry.kind} for agent=${entry.agent} model=${entry.model ?? EVERY_MODEL} ` +
435
+ `(${this.pending.length} act(s) pending); it holds in this process and is offered again at the next act: ${safeSlice(errorText(error), 0, 300)}`);
436
+ return;
437
+ }
438
+ this.pending.shift();
439
+ reduce(this.durable, entry);
440
+ }
441
+ if (this.unreadable || this.journal.needsReopen || this.journal.entriesSinceCheckpoint < CHECKPOINT_EVERY)
442
+ return;
443
+ const now = this.now();
444
+ try {
445
+ this.journal.checkpoint({ waits: [...this.durable.values()].filter((wait) => live(wait, now)) }, { durable: true });
446
+ }
447
+ catch (error) {
448
+ if (this.journal.needsReopen) {
449
+ this.reportUnwritable(error, 'a checkpoint');
450
+ return;
451
+ }
452
+ this.log(`[provider-wait] could not checkpoint provider waits; the journal still replays in full: ${safeSlice(errorText(error), 0, 300)}`);
453
+ }
454
+ }
455
+ /**
456
+ * Say that the journal can't be written again: the store's append threw
457
+ * inside the store, and only a reopen (as at the next start) reads its log
458
+ * back. Called where that first happens; flush() writes nothing after it,
459
+ * so it is said once for the journal's life. What `writing` names may still
460
+ * be in the store's log, and the next start loads it if so. A stated wait
461
+ * still holds here, which is always safe; a later act loses only its
462
+ * record, so after a restart the agent's next call goes to the provider,
463
+ * and a wait it states again starts a new hold. No alert: a failed write
464
+ * is log-only.
465
+ */
466
+ reportUnwritable(error, writing) {
467
+ this.log(`[provider-wait] nothing more is written to the provider-wait journal until the store is reopened, ` +
468
+ `as at the next start: the store's append of ${writing} failed (${safeSlice(errorText(error), 0, 300)}), and that ` +
469
+ `record may still be in the store's log, where the next start finds it. Every wait and release after it holds ` +
470
+ `in this process only (${this.pending.length} act(s) pending now). After a restart, such a wait no longer binds: ` +
471
+ 'the agent\'s next call to that model goes to the provider, and a wait the provider states again starts a new hold. ' +
472
+ 'Such a release no longer lifts its wait');
473
+ }
474
+ }
475
+ function loaded(waits, now) {
476
+ let count = 0;
477
+ for (const wait of waits.values())
478
+ if (live(wait, now))
479
+ count++;
480
+ return count;
481
+ }
482
+ //# sourceMappingURL=provider-waits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-waits.js","sourceRoot":"","sources":["../../src/provider-waits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,CAAC,MAAM,yBAAyB,GAAG,yBAAyB,CAAC;AAEnE,qFAAqF;AACrF,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,oFAAoF;AACpF,MAAM,WAAW,GAAG,OAAO,CAAC;AAqB5B;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,YAAqB,EAAE,GAAW;IAC7D,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC;QAAE,OAAO,IAAI,CAAC;IAChF,wEAAwE;IACxE,IAAI,YAAY,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC,IAAI,CA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I,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACtH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;gBAC7B,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;gBAC7C,OAAO;YACT,CAAC;YACD,IAAI,CAAC,GAAG,CAAC,2FAA2F,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QAC7I,CAAC;IACH,CAAC;IAED;;;;;;;;;;OAUG;IACK,gBAAgB,CAAC,KAAc,EAAE,OAAe;QACtD,IAAI,CAAC,GAAG,CAAC,oGAAoG;YAC3G,+CAA+C,OAAO,YAAY,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,cAAc;YACnH,+GAA+G;YAC/G,yBAAyB,IAAI,CAAC,OAAO,CAAC,MAAM,sEAAsE;YAClH,qHAAqH;YACrH,yCAAyC,CAAC,CAAC;IAC/C,CAAC;CACF;AAED,SAAS,MAAM,CAAC,KAAgC,EAAE,GAAW;IAC3D,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,MAAM,EAAE;QAAE,IAAI,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC;YAAE,KAAK,EAAE,CAAC;IAChE,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1,27 +1,29 @@
1
1
  /**
2
2
  * Refusal-reaction markers — the single source of truth for the emoji the
3
3
  * framework places on a message when inference is refused (see
4
- * AgentFramework.reactToRefusal), exported so host composition can derive
5
- * a protective suppression baseline from the exact set the framework emits.
4
+ * AgentFramework.reactToRefusal).
6
5
  *
7
6
  * These annotations are placed by the framework on the resident's account
8
7
  * and must never re-enter a resident's context as reaction events — that is
9
8
  * the self-amplifying loop behind the 8/3 Mythos incident. The Discord
10
- * adapter suppresses them when its operator config or the host-injected
11
- * `DISCORD_SUPPRESSED_REACTIONS_BASELINE` names them; keeping the emitted
12
- * set and the exported baseline as one constant is what makes drift between
13
- * "what we stamp" and "what we suppress" structurally impossible, rather
14
- * than a promise kept in two files.
9
+ * adapter suppresses them when its operator config or
10
+ * `DISCORD_SUPPRESSED_REACTIONS_BASELINE` names them. That variable's
11
+ * protective default, which the framework injects into stdio children, is
12
+ * `framework.getPlacedReactionBaseline()` on an instance: these refusal
13
+ * markers plus the awareness markers. REFUSAL_REACTION_BASELINE below is the
14
+ * refusal set only. Keeping the emitted refusal set and the exported one as
15
+ * one constant is what makes drift between "what we stamp" and "what we
16
+ * suppress" structurally impossible, rather than a promise kept in two
17
+ * files.
15
18
  */
16
19
  /** Refusal category → Discord reaction emoji. Unknown categories get the
17
20
  * fallback marker. */
18
21
  export declare const REFUSAL_REACTIONS: Readonly<Record<string, string>>;
19
22
  /** Marker used when the refusal category has no dedicated emoji. */
20
23
  export declare const REFUSAL_REACTION_FALLBACK = "\uD83D\uDED1";
21
- /** Every marker the framework can emit — the category map plus the
22
- * fallback, deduplicated, in stable declaration order. This IS the
23
- * protective baseline: host composition serializes it (comma-joined) into
24
- * `DISCORD_SUPPRESSED_REACTIONS_BASELINE` for adapters that render
25
- * reactions. */
24
+ /** Every refusal marker the framework can emit: the category map plus the
25
+ * fallback, deduplicated in stable declaration order. For the deployment's
26
+ * complete protective default, including awareness markers, use
27
+ * `framework.getPlacedReactionBaseline()` on an instance. */
26
28
  export declare const REFUSAL_REACTION_BASELINE: readonly string[];
27
29
  //# sourceMappingURL=refusal-reactions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"refusal-reactions.d.ts","sourceRoot":"","sources":["../../src/refusal-reactions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;uBACuB;AACvB,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAM9D,CAAC;AAEF,oEAAoE;AACpE,eAAO,MAAM,yBAAyB,iBAAO,CAAC;AAE9C;;;;iBAIiB;AACjB,eAAO,MAAM,yBAAyB,EAAE,SAAS,MAAM,EAEtD,CAAC"}
1
+ {"version":3,"file":"refusal-reactions.d.ts","sourceRoot":"","sources":["../../src/refusal-reactions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;uBACuB;AACvB,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAM9D,CAAC;AAEF,oEAAoE;AACpE,eAAO,MAAM,yBAAyB,iBAAO,CAAC;AAE9C;;;8DAG8D;AAC9D,eAAO,MAAM,yBAAyB,EAAE,SAAS,MAAM,EAEtD,CAAC"}
@@ -1,17 +1,20 @@
1
1
  /**
2
2
  * Refusal-reaction markers — the single source of truth for the emoji the
3
3
  * framework places on a message when inference is refused (see
4
- * AgentFramework.reactToRefusal), exported so host composition can derive
5
- * a protective suppression baseline from the exact set the framework emits.
4
+ * AgentFramework.reactToRefusal).
6
5
  *
7
6
  * These annotations are placed by the framework on the resident's account
8
7
  * and must never re-enter a resident's context as reaction events — that is
9
8
  * the self-amplifying loop behind the 8/3 Mythos incident. The Discord
10
- * adapter suppresses them when its operator config or the host-injected
11
- * `DISCORD_SUPPRESSED_REACTIONS_BASELINE` names them; keeping the emitted
12
- * set and the exported baseline as one constant is what makes drift between
13
- * "what we stamp" and "what we suppress" structurally impossible, rather
14
- * than a promise kept in two files.
9
+ * adapter suppresses them when its operator config or
10
+ * `DISCORD_SUPPRESSED_REACTIONS_BASELINE` names them. That variable's
11
+ * protective default, which the framework injects into stdio children, is
12
+ * `framework.getPlacedReactionBaseline()` on an instance: these refusal
13
+ * markers plus the awareness markers. REFUSAL_REACTION_BASELINE below is the
14
+ * refusal set only. Keeping the emitted refusal set and the exported one as
15
+ * one constant is what makes drift between "what we stamp" and "what we
16
+ * suppress" structurally impossible, rather than a promise kept in two
17
+ * files.
15
18
  */
16
19
  /** Refusal category → Discord reaction emoji. Unknown categories get the
17
20
  * fallback marker. */
@@ -24,11 +27,10 @@ export const REFUSAL_REACTIONS = {
24
27
  };
25
28
  /** Marker used when the refusal category has no dedicated emoji. */
26
29
  export const REFUSAL_REACTION_FALLBACK = '🛑';
27
- /** Every marker the framework can emit — the category map plus the
28
- * fallback, deduplicated, in stable declaration order. This IS the
29
- * protective baseline: host composition serializes it (comma-joined) into
30
- * `DISCORD_SUPPRESSED_REACTIONS_BASELINE` for adapters that render
31
- * reactions. */
30
+ /** Every refusal marker the framework can emit: the category map plus the
31
+ * fallback, deduplicated in stable declaration order. For the deployment's
32
+ * complete protective default, including awareness markers, use
33
+ * `framework.getPlacedReactionBaseline()` on an instance. */
32
34
  export const REFUSAL_REACTION_BASELINE = [
33
35
  ...new Set([...Object.values(REFUSAL_REACTIONS), REFUSAL_REACTION_FALLBACK]),
34
36
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"refusal-reactions.js","sourceRoot":"","sources":["../../src/refusal-reactions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;uBACuB;AACvB,MAAM,CAAC,MAAM,iBAAiB,GAAqC;IACjE,GAAG,EAAE,IAAI;IACT,IAAI,EAAE,IAAI;IACV,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,IAAI;IACX,oBAAoB,EAAE,IAAI;CAC3B,CAAC;AAEF,oEAAoE;AACpE,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAE9C;;;;iBAIiB;AACjB,MAAM,CAAC,MAAM,yBAAyB,GAAsB;IAC1D,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE,yBAAyB,CAAC,CAAC;CAC7E,CAAC"}
1
+ {"version":3,"file":"refusal-reactions.js","sourceRoot":"","sources":["../../src/refusal-reactions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;uBACuB;AACvB,MAAM,CAAC,MAAM,iBAAiB,GAAqC;IACjE,GAAG,EAAE,IAAI;IACT,IAAI,EAAE,IAAI;IACV,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,IAAI;IACX,oBAAoB,EAAE,IAAI;CAC3B,CAAC;AAEF,oEAAoE;AACpE,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAE9C;;;8DAG8D;AAC9D,MAAM,CAAC,MAAM,yBAAyB,GAAsB;IAC1D,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE,yBAAyB,CAAC,CAAC;CAC7E,CAAC"}