@animalabs/agent-framework 0.27.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -15
- package/dist/src/agent.d.ts +29 -2
- package/dist/src/agent.d.ts.map +1 -1
- package/dist/src/agent.js +69 -11
- package/dist/src/agent.js.map +1 -1
- package/dist/src/api/server.d.ts.map +1 -1
- package/dist/src/api/server.js +4 -2
- package/dist/src/api/server.js.map +1 -1
- package/dist/src/auto-continue.d.ts +3 -2
- package/dist/src/auto-continue.d.ts.map +1 -1
- package/dist/src/auto-continue.js +4 -3
- package/dist/src/auto-continue.js.map +1 -1
- package/dist/src/cut-off-round.d.ts +24 -0
- package/dist/src/cut-off-round.d.ts.map +1 -0
- package/dist/src/cut-off-round.js +87 -0
- package/dist/src/cut-off-round.js.map +1 -0
- package/dist/src/framework.d.ts +304 -89
- package/dist/src/framework.d.ts.map +1 -1
- package/dist/src/framework.js +2577 -678
- package/dist/src/framework.js.map +1 -1
- package/dist/src/gate/event-gate.d.ts +99 -3
- package/dist/src/gate/event-gate.d.ts.map +1 -1
- package/dist/src/gate/event-gate.js +538 -13
- package/dist/src/gate/event-gate.js.map +1 -1
- package/dist/src/gate/index.d.ts +2 -1
- package/dist/src/gate/index.d.ts.map +1 -1
- package/dist/src/gate/index.js +1 -0
- package/dist/src/gate/index.js.map +1 -1
- package/dist/src/gate/reply-judge.d.ts +116 -0
- package/dist/src/gate/reply-judge.d.ts.map +1 -0
- package/dist/src/gate/reply-judge.js +467 -0
- package/dist/src/gate/reply-judge.js.map +1 -0
- package/dist/src/gate/types.d.ts +161 -0
- package/dist/src/gate/types.d.ts.map +1 -1
- package/dist/src/heartbeat/heartbeat.d.ts +184 -0
- package/dist/src/heartbeat/heartbeat.d.ts.map +1 -0
- package/dist/src/heartbeat/heartbeat.js +752 -0
- package/dist/src/heartbeat/heartbeat.js.map +1 -0
- package/dist/src/heartbeat/reminder-time.d.ts +5 -0
- package/dist/src/heartbeat/reminder-time.d.ts.map +1 -0
- package/dist/src/heartbeat/reminder-time.js +107 -0
- package/dist/src/heartbeat/reminder-time.js.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcpl/capability-mask.d.ts.map +1 -1
- package/dist/src/mcpl/capability-mask.js +3 -2
- package/dist/src/mcpl/capability-mask.js.map +1 -1
- package/dist/src/mcpl/channel-registry.d.ts.map +1 -1
- package/dist/src/mcpl/channel-registry.js +2 -1
- package/dist/src/mcpl/channel-registry.js.map +1 -1
- package/dist/src/mcpl/inbound-source.d.ts +26 -10
- package/dist/src/mcpl/inbound-source.d.ts.map +1 -1
- package/dist/src/mcpl/inbound-source.js +40 -69
- package/dist/src/mcpl/inbound-source.js.map +1 -1
- package/dist/src/mcpl/server-connection.d.ts +18 -8
- package/dist/src/mcpl/server-connection.d.ts.map +1 -1
- package/dist/src/mcpl/server-connection.js +50 -10
- package/dist/src/mcpl/server-connection.js.map +1 -1
- package/dist/src/mcpl/tags.d.ts +9 -2
- package/dist/src/mcpl/tags.d.ts.map +1 -1
- package/dist/src/mcpl/tags.js +12 -2
- package/dist/src/mcpl/tags.js.map +1 -1
- package/dist/src/mcpl/tool-presence.d.ts +66 -14
- package/dist/src/mcpl/tool-presence.d.ts.map +1 -1
- package/dist/src/mcpl/tool-presence.js +134 -65
- package/dist/src/mcpl/tool-presence.js.map +1 -1
- package/dist/src/mcpl/tool-signature.d.ts +10 -3
- package/dist/src/mcpl/tool-signature.d.ts.map +1 -1
- package/dist/src/mcpl/tool-signature.js +47 -18
- package/dist/src/mcpl/tool-signature.js.map +1 -1
- package/dist/src/mcpl/toolset-host.d.ts +88 -37
- package/dist/src/mcpl/toolset-host.d.ts.map +1 -1
- package/dist/src/mcpl/toolset-host.js +207 -108
- package/dist/src/mcpl/toolset-host.js.map +1 -1
- package/dist/src/mcpl/toolsets-module.d.ts +14 -11
- package/dist/src/mcpl/toolsets-module.d.ts.map +1 -1
- package/dist/src/mcpl/toolsets-module.js +141 -49
- package/dist/src/mcpl/toolsets-module.js.map +1 -1
- package/dist/src/mcpl/types.d.ts +3 -1
- package/dist/src/mcpl/types.d.ts.map +1 -1
- package/dist/src/mcpl/types.js.map +1 -1
- package/dist/src/module-registry.d.ts +4 -1
- package/dist/src/module-registry.d.ts.map +1 -1
- package/dist/src/module-registry.js +9 -2
- package/dist/src/module-registry.js.map +1 -1
- package/dist/src/modules/history/index.d.ts.map +1 -1
- package/dist/src/modules/history/index.js +22 -11
- package/dist/src/modules/history/index.js.map +1 -1
- package/dist/src/modules/workspace/answers.d.ts +22 -0
- package/dist/src/modules/workspace/answers.d.ts.map +1 -0
- package/dist/src/modules/workspace/answers.js +123 -0
- package/dist/src/modules/workspace/answers.js.map +1 -0
- package/dist/src/modules/workspace/branch-intent.d.ts +5 -3
- package/dist/src/modules/workspace/branch-intent.d.ts.map +1 -1
- package/dist/src/modules/workspace/branch-intent.js +6 -2
- package/dist/src/modules/workspace/branch-intent.js.map +1 -1
- package/dist/src/modules/workspace/direct-write.d.ts +3 -0
- package/dist/src/modules/workspace/direct-write.d.ts.map +1 -1
- package/dist/src/modules/workspace/direct-write.js +57 -24
- package/dist/src/modules/workspace/direct-write.js.map +1 -1
- package/dist/src/modules/workspace/disk-agreement.d.ts +33 -11
- package/dist/src/modules/workspace/disk-agreement.d.ts.map +1 -1
- package/dist/src/modules/workspace/disk-agreement.js +48 -17
- package/dist/src/modules/workspace/disk-agreement.js.map +1 -1
- package/dist/src/modules/workspace/edit-text.d.ts +2 -1
- package/dist/src/modules/workspace/edit-text.d.ts.map +1 -1
- package/dist/src/modules/workspace/edit-text.js +4 -2
- package/dist/src/modules/workspace/edit-text.js.map +1 -1
- package/dist/src/modules/workspace/effects.d.ts.map +1 -1
- package/dist/src/modules/workspace/effects.js +20 -13
- package/dist/src/modules/workspace/effects.js.map +1 -1
- package/dist/src/modules/workspace/index.d.ts +62 -51
- package/dist/src/modules/workspace/index.d.ts.map +1 -1
- package/dist/src/modules/workspace/index.js +934 -531
- package/dist/src/modules/workspace/index.js.map +1 -1
- package/dist/src/modules/workspace/observe.d.ts +75 -63
- package/dist/src/modules/workspace/observe.d.ts.map +1 -1
- package/dist/src/modules/workspace/observe.js +366 -180
- package/dist/src/modules/workspace/observe.js.map +1 -1
- package/dist/src/modules/workspace/read-page.d.ts.map +1 -1
- package/dist/src/modules/workspace/read-page.js +7 -1
- package/dist/src/modules/workspace/read-page.js.map +1 -1
- package/dist/src/modules/workspace/reconcile.d.ts.map +1 -1
- package/dist/src/modules/workspace/reconcile.js +26 -16
- package/dist/src/modules/workspace/reconcile.js.map +1 -1
- package/dist/src/modules/workspace/result-text.d.ts +1 -0
- package/dist/src/modules/workspace/result-text.d.ts.map +1 -1
- package/dist/src/modules/workspace/result-text.js.map +1 -1
- package/dist/src/modules/workspace/sync.d.ts +9 -0
- package/dist/src/modules/workspace/sync.d.ts.map +1 -1
- package/dist/src/modules/workspace/sync.js +14 -0
- package/dist/src/modules/workspace/sync.js.map +1 -1
- package/dist/src/modules/workspace/types.d.ts +96 -43
- package/dist/src/modules/workspace/types.d.ts.map +1 -1
- package/dist/src/modules/workspace/types.js.map +1 -1
- package/dist/src/modules/workspace/watcher.d.ts.map +1 -1
- package/dist/src/modules/workspace/watcher.js +8 -3
- package/dist/src/modules/workspace/watcher.js.map +1 -1
- package/dist/src/prose-drafts.d.ts +4 -3
- package/dist/src/prose-drafts.d.ts.map +1 -1
- package/dist/src/prose-drafts.js +3 -2
- package/dist/src/prose-drafts.js.map +1 -1
- package/dist/src/reasoning-loss-notice.d.ts +23 -0
- package/dist/src/reasoning-loss-notice.d.ts.map +1 -0
- package/dist/src/reasoning-loss-notice.js +50 -0
- package/dist/src/reasoning-loss-notice.js.map +1 -0
- package/dist/src/reasoning-loss.d.ts +24 -0
- package/dist/src/reasoning-loss.d.ts.map +1 -0
- package/dist/src/reasoning-loss.js +102 -0
- package/dist/src/reasoning-loss.js.map +1 -0
- package/dist/src/send-tools.d.ts +3 -2
- package/dist/src/send-tools.d.ts.map +1 -1
- package/dist/src/send-tools.js +3 -2
- package/dist/src/send-tools.js.map +1 -1
- package/dist/src/sent-rows.js +1 -1
- package/dist/src/thinking-drops.d.ts +4 -11
- package/dist/src/thinking-drops.d.ts.map +1 -1
- package/dist/src/thinking-drops.js +7 -14
- package/dist/src/thinking-drops.js.map +1 -1
- package/dist/src/tool-args.d.ts +12 -0
- package/dist/src/tool-args.d.ts.map +1 -1
- package/dist/src/tool-args.js +35 -1
- package/dist/src/tool-args.js.map +1 -1
- package/dist/src/tool-result-guard.d.ts +8 -4
- package/dist/src/tool-result-guard.d.ts.map +1 -1
- package/dist/src/tool-result-guard.js +23 -11
- package/dist/src/tool-result-guard.js.map +1 -1
- package/dist/src/tune-out/tools.d.ts +4 -1
- package/dist/src/tune-out/tools.d.ts.map +1 -1
- package/dist/src/types/agent.d.ts +40 -9
- package/dist/src/types/agent.d.ts.map +1 -1
- package/dist/src/types/events.d.ts +18 -8
- package/dist/src/types/events.d.ts.map +1 -1
- package/dist/src/types/framework.d.ts +15 -0
- package/dist/src/types/framework.d.ts.map +1 -1
- package/dist/src/types/module.d.ts +5 -2
- package/dist/src/types/module.d.ts.map +1 -1
- package/dist/src/types/trace.d.ts +34 -1
- package/dist/src/types/trace.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/agent.ts +72 -11
- package/src/api/server.ts +4 -2
- package/src/auto-continue.ts +4 -3
- package/src/cut-off-round.ts +98 -0
- package/src/framework.ts +2694 -700
- package/src/gate/event-gate.ts +579 -15
- package/src/gate/index.ts +8 -0
- package/src/gate/reply-judge.ts +512 -0
- package/src/gate/types.ts +164 -1
- package/src/heartbeat/heartbeat.ts +804 -0
- package/src/heartbeat/reminder-time.ts +107 -0
- package/src/index.ts +4 -0
- package/src/mcpl/capability-mask.ts +3 -2
- package/src/mcpl/channel-registry.ts +2 -1
- package/src/mcpl/inbound-source.ts +42 -69
- package/src/mcpl/server-connection.ts +56 -16
- package/src/mcpl/tags.ts +13 -2
- package/src/mcpl/tool-presence.ts +133 -67
- package/src/mcpl/tool-signature.ts +51 -20
- package/src/mcpl/toolset-host.ts +197 -107
- package/src/mcpl/toolsets-module.ts +143 -49
- package/src/mcpl/types.ts +3 -1
- package/src/module-registry.ts +8 -2
- package/src/modules/history/index.ts +22 -12
- package/src/modules/workspace/answers.ts +133 -0
- package/src/modules/workspace/branch-intent.ts +10 -5
- package/src/modules/workspace/direct-write.ts +58 -23
- package/src/modules/workspace/disk-agreement.ts +52 -21
- package/src/modules/workspace/edit-text.ts +7 -5
- package/src/modules/workspace/effects.ts +21 -12
- package/src/modules/workspace/index.ts +927 -541
- package/src/modules/workspace/observe.ts +381 -177
- package/src/modules/workspace/read-page.ts +7 -1
- package/src/modules/workspace/reconcile.ts +27 -15
- package/src/modules/workspace/result-text.ts +2 -0
- package/src/modules/workspace/sync.ts +16 -0
- package/src/modules/workspace/types.ts +96 -43
- package/src/modules/workspace/watcher.ts +8 -3
- package/src/prose-drafts.ts +4 -3
- package/src/reasoning-loss-notice.ts +62 -0
- package/src/reasoning-loss.ts +120 -0
- package/src/send-tools.ts +3 -2
- package/src/sent-rows.ts +1 -1
- package/src/thinking-drops.ts +10 -16
- package/src/tool-args.ts +34 -1
- package/src/tool-result-guard.ts +26 -11
- package/src/tune-out/tools.ts +4 -1
- package/src/types/agent.ts +40 -9
- package/src/types/events.ts +18 -8
- package/src/types/framework.ts +15 -0
- package/src/types/module.ts +5 -2
- package/src/types/trace.ts +36 -1
package/dist/src/framework.d.ts
CHANGED
|
@@ -88,11 +88,15 @@ export interface HostModeStatus {
|
|
|
88
88
|
* is false until it has. A parked continuation of a turn is counted here
|
|
89
89
|
* and, as a turn alive, in `activeTurns` and `activeTurnAgents`. */
|
|
90
90
|
parkedAdmissions: number;
|
|
91
|
-
/** Inference requests parked by the quiesce wake
|
|
92
|
-
*
|
|
93
|
-
* scheduler's
|
|
94
|
-
*
|
|
95
|
-
*
|
|
91
|
+
/** Inference requests waiting to start: queued (parked by the quiesce wake
|
|
92
|
+
* gate while quiesced, or, while serving, until the scheduler's next pass
|
|
93
|
+
* takes them), in a scheduler pass's hands, or held by a provider hold (an
|
|
94
|
+
* acceleration or host hold, or a provider's stated wait). There, a start
|
|
95
|
+
* that carries a turn on counts as the wakes merged into it. A start parked
|
|
96
|
+
* on provider admission behind an auxiliary call counts once in
|
|
97
|
+
* `parkedAdmissions` instead, however many wakes are merged into it.
|
|
98
|
+
* Continuations of a turn (budget restart, tool results) and a held turn's
|
|
99
|
+
* retry, which a quiesce lets through, are never counted. */
|
|
96
100
|
gatedRequests: number;
|
|
97
101
|
/** code_execution scripts still running that no call is waiting on: left
|
|
98
102
|
* running after a yield, outside any turn. Quiesce does NOT stop them —
|
|
@@ -106,11 +110,12 @@ export interface HostModeStatus {
|
|
|
106
110
|
* turn token held with no stream to cancel and no check ahead to stop it
|
|
107
111
|
* at (a puppet tool turn, a store surgery's reservation, a turn finishing
|
|
108
112
|
* its last delivery), or a turn with no stream that hasn't reached its
|
|
109
|
-
* next check, such as one in a hook that hasn't returned
|
|
110
|
-
* stream
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
113
|
+
* next check, such as one in a hook that hasn't returned, or a turn whose
|
|
114
|
+
* stream's cancel threw with no check ahead, so that its stream goes on.
|
|
115
|
+
* A turn whose stream the abandon cancelled isn't listed, even one still
|
|
116
|
+
* running when the grace runs out, as one whose tool-result guard waits on
|
|
117
|
+
* its speech may be. Present only after an abandon that left such turns
|
|
118
|
+
* behind, while the host stays quiesced. */
|
|
114
119
|
unabandonable?: string[];
|
|
115
120
|
}
|
|
116
121
|
/**
|
|
@@ -168,25 +173,27 @@ interface InferenceToolSnapshot {
|
|
|
168
173
|
* this policy after one send, and the framework is the one retry layer: each
|
|
169
174
|
* retry is a fresh compile, a stop cancels its wait, and the wait is seen.
|
|
170
175
|
* The decision is membrane's (`@animalabs/membrane/retry`), on the settings
|
|
171
|
-
* given
|
|
172
|
-
* recipe's retry config)
|
|
176
|
+
* given: membrane's, with the two changes below for the turn path, unless a
|
|
177
|
+
* host passes its own (e.g. from a recipe's retry config), which are taken as
|
|
178
|
+
* they are:
|
|
173
179
|
* - not retryable (400 invalid_request, 401 auth, context_length, safety,
|
|
174
180
|
* a caller-code error): terminal on the first failure. Retrying them burns
|
|
175
181
|
* API quota without any chance of success; production traces showed clerk +
|
|
176
182
|
* reviewer wasting 4 inferences on each 400 due to blind retries.
|
|
177
183
|
* - overloaded (a 529, or an overloaded error mid-stream): the overloaded
|
|
178
|
-
* schedule, jittered
|
|
184
|
+
* schedule, jittered, 10 s doubling to 5 min (by default 13 tries, where
|
|
185
|
+
* membrane's settings have 7: about 30 min).
|
|
179
186
|
* - rate limited (429): the base schedule with at least 5 tries.
|
|
180
187
|
* - any other retryable failure, a stream deadline on a sent request
|
|
181
188
|
* included (membrane leaves those to its caller): the base schedule (by
|
|
182
189
|
* default 3 tries, 1 s then 2 s).
|
|
183
190
|
* A provider's stated wait (`retryAfterMs`) is waited when it is longer than
|
|
184
|
-
* the backoff, up to the
|
|
185
|
-
*
|
|
186
|
-
* turn ends here.
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
* nonOwningProviderWait.)
|
|
191
|
+
* the backoff, up to the schedule's ceiling, which by default is at least the
|
|
192
|
+
* framework's own cap (PROVIDER_ACCELERATION_MAX_COOLDOWN_MS, ten minutes);
|
|
193
|
+
* past it the turn ends here. A host's own settings keep their ceilings.
|
|
194
|
+
* (Before this policy runs, the framework holds a resident for a stated wait
|
|
195
|
+
* or an acceleration 429 itself, and ends an ephemeral run on a wait past
|
|
196
|
+
* that cap; see holdProviderAcceleration and nonOwningProviderWait.)
|
|
190
197
|
* An error that isn't a MembraneError is retried as a retryable failure, on
|
|
191
198
|
* the base schedule.
|
|
192
199
|
*/
|
|
@@ -197,6 +204,40 @@ export declare class DefaultErrorPolicy implements ErrorPolicy {
|
|
|
197
204
|
constructor(settings?: RetrySettings);
|
|
198
205
|
onInferenceError(error: Error, _agentName: string, attempt: number): ErrorAction;
|
|
199
206
|
}
|
|
207
|
+
export interface ReinitAlertText {
|
|
208
|
+
opening: string;
|
|
209
|
+
message: string;
|
|
210
|
+
}
|
|
211
|
+
export declare const REINIT_MOVES: readonly ['undo', 'redo', 'rollback', 'suppression', 'branch switch'];
|
|
212
|
+
export type ReinitMove = (typeof REINIT_MOVES)[number];
|
|
213
|
+
export declare function refusedWorkAlert(move: ReinitMove, cause: string): ReinitAlertText;
|
|
214
|
+
export declare function restoreAlert(restore: {
|
|
215
|
+
source: string;
|
|
216
|
+
now: string;
|
|
217
|
+
selected: boolean;
|
|
218
|
+
cause: string;
|
|
219
|
+
} & ({
|
|
220
|
+
move: 'rollback';
|
|
221
|
+
managerCurrent?: false;
|
|
222
|
+
} | {
|
|
223
|
+
move: 'suppression';
|
|
224
|
+
managerCurrent: boolean;
|
|
225
|
+
})): ReinitAlertText;
|
|
226
|
+
export declare function disposalAlert(disposal: {
|
|
227
|
+
move: ReinitMove;
|
|
228
|
+
heldWrites?: number;
|
|
229
|
+
reinitFailed?: string;
|
|
230
|
+
cleanupFailed?: string;
|
|
231
|
+
}): ReinitAlertText;
|
|
232
|
+
export declare function longHoldAlert(hold: {
|
|
233
|
+
move: string;
|
|
234
|
+
agentName: string;
|
|
235
|
+
heldSeconds: number;
|
|
236
|
+
queued: number;
|
|
237
|
+
reinitializing?: string;
|
|
238
|
+
waitingForMaintenance: boolean;
|
|
239
|
+
}): ReinitAlertText;
|
|
240
|
+
export declare function opsWebhookText(message: string): string;
|
|
200
241
|
/**
|
|
201
242
|
* Whether the poison-history breaker may shed the newest exchange for a
|
|
202
243
|
* failure: an `invalid_request` at HTTP 400, 413 or 422 or with no status, or
|
|
@@ -287,6 +328,7 @@ export declare class AgentFramework {
|
|
|
287
328
|
private stopPromise;
|
|
288
329
|
private stopCompleted;
|
|
289
330
|
private ownedStoreClosed;
|
|
331
|
+
private ownedStoreManagersClosed;
|
|
290
332
|
/** Whether the latest stop() got through its teardown with nothing failed:
|
|
291
333
|
* every step and every wait up to and including the one on awareness
|
|
292
334
|
* drains, whatever failed after that, in the storage work that finishes
|
|
@@ -314,6 +356,8 @@ export declare class AgentFramework {
|
|
|
314
356
|
private inferencePolicy;
|
|
315
357
|
private errorPolicy;
|
|
316
358
|
private pendingRequests;
|
|
359
|
+
private readonly exhaustedTurns;
|
|
360
|
+
private readonly roundTurns;
|
|
317
361
|
private running;
|
|
318
362
|
private loopPromise;
|
|
319
363
|
/** Quiesce/maintenance mode (issue #122). DELIBERATELY separate from
|
|
@@ -365,6 +409,7 @@ export declare class AgentFramework {
|
|
|
365
409
|
private providerWaits;
|
|
366
410
|
/** Wakers for error-policy retry waits in progress: stop() ends them. */
|
|
367
411
|
private retryWaitWakers;
|
|
412
|
+
private waitingTraceEveryMs;
|
|
368
413
|
private providerAdmissionClosed;
|
|
369
414
|
/** Invalidates framework turns still assembling when stop begins. */
|
|
370
415
|
private lifecycleGeneration;
|
|
@@ -379,6 +424,7 @@ export declare class AgentFramework {
|
|
|
379
424
|
* framework, and tests set it by cast. */
|
|
380
425
|
private inboundAcceptanceObserver?;
|
|
381
426
|
private streamBoundaryEnds;
|
|
427
|
+
private streamCarries;
|
|
382
428
|
/** A tool boundary injected fresh CONVERSATIONAL input (a real message,
|
|
383
429
|
* or an edit the coalescer marks as the agent's first view; not a system
|
|
384
430
|
* marker or a reaction, reaction removal, edit or deletion marker) into
|
|
@@ -409,6 +455,7 @@ export declare class AgentFramework {
|
|
|
409
455
|
* next turn.
|
|
410
456
|
*/
|
|
411
457
|
private turnRouting;
|
|
458
|
+
private readonly reasoningLoss;
|
|
412
459
|
/**
|
|
413
460
|
* The latest link of each agent's chain of queued prose deliveries. Every
|
|
414
461
|
* stream queues its own behind it, a fresh turn's included, so the agent's
|
|
@@ -707,6 +754,11 @@ export declare class AgentFramework {
|
|
|
707
754
|
* queued, and clears them. While a name is here, no other flush drains
|
|
708
755
|
* its queue (drainDeferredFor). */
|
|
709
756
|
private readonly releasesAfterResume;
|
|
757
|
+
private readonly managerReleases;
|
|
758
|
+
private readonly releasedByCleanup;
|
|
759
|
+
private readonly openManagers;
|
|
760
|
+
private readonly openManagerRefs;
|
|
761
|
+
private readonly collectedManagers;
|
|
710
762
|
/** The coalescing commit in flight, if any (see commitCoalescingDurable). */
|
|
711
763
|
private coalescingCommit;
|
|
712
764
|
private inferenceRouter;
|
|
@@ -743,12 +795,13 @@ export declare class AgentFramework {
|
|
|
743
795
|
private readonly thinkingLossIncidents;
|
|
744
796
|
/** Per live stream that can be noted, its rows so far after the compiled messages (noteRoundSent). */
|
|
745
797
|
private readonly streamRequestNotes;
|
|
798
|
+
private readonly streamCarried;
|
|
746
799
|
/** Per pending round's blocks (pendingAssistantBlocks' value), what membrane held as that round's reply
|
|
747
800
|
* (`roundContent`, its results left out); null where the round has no `roundContent` (XML or fallback). Keyed by
|
|
748
801
|
* the blocks themselves, so it goes wherever they go. */
|
|
749
802
|
private readonly pendingRoundSent;
|
|
750
|
-
/** Per agent, a round that called code_execution and waits for
|
|
751
|
-
* results before its prose is routed (ScriptRound). */
|
|
803
|
+
/** Per agent, a round that called code_execution or sent, and waits for
|
|
804
|
+
* those calls' results before its prose is routed (ScriptRound). */
|
|
752
805
|
private scriptRounds;
|
|
753
806
|
/** Each code_execution result, by the round that dispatched its call: it
|
|
754
807
|
* settles only that round, even if a newer round reuses its call id. */
|
|
@@ -852,6 +905,9 @@ export declare class AgentFramework {
|
|
|
852
905
|
* scheduler, ephemeral admission and puppet entry points.
|
|
853
906
|
*/
|
|
854
907
|
private surgeryHold;
|
|
908
|
+
private readonly conversationSpawnsInFlight;
|
|
909
|
+
private syncMoveReinit;
|
|
910
|
+
private holdAlertMs;
|
|
855
911
|
/** Serialize per-server drains so reconnect and an online undo cannot race. */
|
|
856
912
|
private discordAwarenessDrains;
|
|
857
913
|
/** The servers whose running pass a later trigger joined
|
|
@@ -859,9 +915,10 @@ export declare class AgentFramework {
|
|
|
859
915
|
* more what it had already tried. */
|
|
860
916
|
private discordAwarenessDrainsJoined;
|
|
861
917
|
private eventGate;
|
|
918
|
+
private judgeWired;
|
|
919
|
+
/** The heartbeat (FrameworkConfig.heartbeat), when the host turns it on. */
|
|
920
|
+
private heartbeat;
|
|
862
921
|
private usageTracker;
|
|
863
|
-
/** Explicit-send or private suppression carried into a tool-result-guard retry. */
|
|
864
|
-
private guardRetryTurnSilenced;
|
|
865
922
|
/** Presentation-only wall-clock zone; persistence remains UTC/epoch. */
|
|
866
923
|
private readonly timeZone;
|
|
867
924
|
private constructor();
|
|
@@ -879,8 +936,9 @@ export declare class AgentFramework {
|
|
|
879
936
|
/**
|
|
880
937
|
* The error a failed create() rejects with, once what it acquired is
|
|
881
938
|
* released: the framework it had begun is stopped, with
|
|
882
|
-
* FAILED_CREATE_TEARDOWN_TIMEOUT_MS as stop()'s teardownTimeoutMs,
|
|
883
|
-
*
|
|
939
|
+
* FAILED_CREATE_TEARDOWN_TIMEOUT_MS as stop()'s teardownTimeoutMs, the
|
|
940
|
+
* context managers it opened are closed, and a store create() opened is
|
|
941
|
+
* closed even when that stop failed or timed out.
|
|
884
942
|
* stop() keeps an owned store open when any of its waits fails or times
|
|
885
943
|
* out, so that it can be called again, but no one can call it on a
|
|
886
944
|
* framework that create() never returned. When the release doesn't finish
|
|
@@ -979,8 +1037,9 @@ export declare class AgentFramework {
|
|
|
979
1037
|
/** What start() and addModule() pass before either begins work of a
|
|
980
1038
|
* lifecycle. A stop() still running refuses both, from the moment it
|
|
981
1039
|
* claims its attempt until that attempt settles. A failed stop() has
|
|
982
|
-
* cleared its attempt, unless it closed an owned store,
|
|
983
|
-
*
|
|
1040
|
+
* cleared its attempt, unless it closed an owned store, or the context
|
|
1041
|
+
* managers it closes before that store, which are refused first. A
|
|
1042
|
+
* completed stop() is cleared, and the call goes on as before;
|
|
984
1043
|
* whether a lifecycle should begin after a stop() is #315's question. */
|
|
985
1044
|
private resetCompletedStop;
|
|
986
1045
|
/** Register before invoking the body, so the set holds the operation for
|
|
@@ -1052,7 +1111,56 @@ export declare class AgentFramework {
|
|
|
1052
1111
|
* under a surgery's hold, and no failure is reported for it.
|
|
1053
1112
|
*/
|
|
1054
1113
|
private withdrawMaintenanceWhenStopping;
|
|
1114
|
+
/**
|
|
1115
|
+
* Wakes the framework holds for `agentName` that need no new event: a
|
|
1116
|
+
* request already queued for it (it runs as soon as the agent is free) and
|
|
1117
|
+
* turns a provider cooldown holds until its end. The reply judge is told of
|
|
1118
|
+
* them beside the gate's own timers, so it can weigh what waiting costs.
|
|
1119
|
+
*/
|
|
1120
|
+
private upcomingWakesFor;
|
|
1121
|
+
/** The agents the heartbeat wakes: the residents, not conversation forks,
|
|
1122
|
+
* ephemeral runs or the subconscious, which keep windows of their own. */
|
|
1123
|
+
private heartbeatTargets;
|
|
1124
|
+
/**
|
|
1125
|
+
* The event a heartbeat wake is to the gate: a push from the server id
|
|
1126
|
+
* `heartbeat`, as heartbeat-mcpl's ticks and reminders were. So the
|
|
1127
|
+
* agent's rules govern it as they governed those (a rule matching
|
|
1128
|
+
* `source: "heartbeat"`, a `defer` default), and its sleep lets it through,
|
|
1129
|
+
* as it lets that server id through.
|
|
1130
|
+
*/
|
|
1131
|
+
private heartbeatGateEvent;
|
|
1132
|
+
/**
|
|
1133
|
+
* Deliver one of the heartbeat's wakes, as heartbeat-mcpl's push events
|
|
1134
|
+
* were: a message-mode tick's or a reminder's text is stored, and the gate
|
|
1135
|
+
* decides the wake by the agent's rules (heartbeatGateEvent), a sleep
|
|
1136
|
+
* letting it through as it lets that server's pushes through. A silent
|
|
1137
|
+
* tick stores no prompt: its turn, when the gate triggers one, is a silent
|
|
1138
|
+
* heartbeat (silent-heartbeat.ts), prose suppressed. As for a stored push,
|
|
1139
|
+
* the wake of the agent the text was delivered to is dropped once a
|
|
1140
|
+
* request of its own has carried and answered the text (readsWriteFor);
|
|
1141
|
+
* another resident's isn't tied to it.
|
|
1142
|
+
*/
|
|
1143
|
+
private deliverHeartbeat;
|
|
1144
|
+
/** Handle a call to one of the heartbeat's tools. */
|
|
1145
|
+
private dispatchHeartbeatToolCall;
|
|
1146
|
+
/**
|
|
1147
|
+
* Why `agentName` may not make this heartbeat call, or null when it may.
|
|
1148
|
+
* The heartbeat is the agent's, and wakes its residents: a conversation
|
|
1149
|
+
* fork, an ephemeral run or the subconscious may look at it, but not
|
|
1150
|
+
* change it or set a reminder that would wake someone else. Refused before
|
|
1151
|
+
* the tool runs, as a fork's sleep is.
|
|
1152
|
+
*/
|
|
1153
|
+
private heartbeatRefusal;
|
|
1154
|
+
/** Run a heartbeat call, its throw an error result. */
|
|
1155
|
+
private runHeartbeatTool;
|
|
1055
1156
|
private auxiliaryMembraneFor;
|
|
1157
|
+
/**
|
|
1158
|
+
* The reply judge's calls. None waits: under the agent's holds a call is
|
|
1159
|
+
* refused without being made, and the agent's turn stops the judge. A call
|
|
1160
|
+
* that fails records the wait its provider states, if any, and holds
|
|
1161
|
+
* nothing else.
|
|
1162
|
+
*/
|
|
1163
|
+
private judgeMembraneFor;
|
|
1056
1164
|
/**
|
|
1057
1165
|
* A conversation agent's auxiliary calls (its context manager's
|
|
1058
1166
|
* compression). A conversation agent takes no provider gate: admission
|
|
@@ -1061,13 +1169,20 @@ export declare class AgentFramework {
|
|
|
1061
1169
|
* as a resident's are, so they bind its auxiliary calls too: a held model
|
|
1062
1170
|
* is refused without a call, and an auxiliary call's own stated wait is
|
|
1063
1171
|
* recorded for it. (An ephemeral run records nothing, its name being
|
|
1064
|
-
* single-use, so its context manager
|
|
1172
|
+
* single-use, so its context manager's calls are only withdrawn, as below,
|
|
1173
|
+
* through ephemeralAuxiliaryMembraneFor.) Its
|
|
1065
1174
|
* compression is the background work a resident's is, whether a
|
|
1066
1175
|
* maintenance tick or a drain after a message starts it, so it is withdrawn
|
|
1067
1176
|
* as a resident's is: a call made while a surgery holds the store, or once
|
|
1068
1177
|
* stop() has closed provider admission, is withdrawn without being sent.
|
|
1069
1178
|
*/
|
|
1070
1179
|
private conversationAuxiliaryMembraneFor;
|
|
1180
|
+
private ephemeralAuxiliaryMembraneFor;
|
|
1181
|
+
private withdrawnOnceReleased;
|
|
1182
|
+
private releaseManager;
|
|
1183
|
+
private trackManager;
|
|
1184
|
+
private closeManager;
|
|
1185
|
+
private closeOpenManagers;
|
|
1071
1186
|
/** The framework's membrane, with each complete() call passed through
|
|
1072
1187
|
* `admit` along with the model it names. */
|
|
1073
1188
|
private membraneAdmitting;
|
|
@@ -1108,7 +1223,8 @@ export declare class AgentFramework {
|
|
|
1108
1223
|
* - An ephemeral run's name is single-use, so a wait recorded for it would
|
|
1109
1224
|
* bind nothing, and its caller is waiting on it. A retryable stated wait
|
|
1110
1225
|
* up to PROVIDER_ACCELERATION_MAX_COOLDOWN_MS is left to the error policy,
|
|
1111
|
-
*
|
|
1226
|
+
* which sleeps and retries it unless it declines, as a host's own ceiling
|
|
1227
|
+
* can. A longer one, or one that can't be represented, ends
|
|
1112
1228
|
* the run now ('fail'): it is never retried before the provider's time,
|
|
1113
1229
|
* and the caller hears why at once.
|
|
1114
1230
|
* Anything else is the error policy's.
|
|
@@ -1552,6 +1668,7 @@ export declare class AgentFramework {
|
|
|
1552
1668
|
cancelAgentRuntimeSettingsTransition(agentName: string, opts?: {
|
|
1553
1669
|
requester?: OperatorRequester;
|
|
1554
1670
|
}): AgentRuntimeSettingsSnapshot;
|
|
1671
|
+
private refuseRuntimeSettingsChangeUnderHold;
|
|
1555
1672
|
/**
|
|
1556
1673
|
* Wakes that passed the scheduler and now own provider admission while
|
|
1557
1674
|
* waiting for an in-flight auxiliary call to settle — no turn token yet,
|
|
@@ -1991,7 +2108,7 @@ export declare class AgentFramework {
|
|
|
1991
2108
|
private readAgentRuntimeSettings;
|
|
1992
2109
|
private validatePersistedAgentRuntimeSettings;
|
|
1993
2110
|
/** Load resident-set inline caps from framework state, dropping (loudly)
|
|
1994
|
-
* anything
|
|
2111
|
+
* anything Number() doesn't read as a finite number of at least 1000. A
|
|
1995
2112
|
* failed read is logged and boot goes on without them: nothing is lost,
|
|
1996
2113
|
* since persistToolResultInlineCap reads the stored caps again before it
|
|
1997
2114
|
* writes one. */
|
|
@@ -2076,7 +2193,13 @@ export declare class AgentFramework {
|
|
|
2076
2193
|
* `{namespace}/messages`, context log to `{namespace}/context`.
|
|
2077
2194
|
*
|
|
2078
2195
|
* Data persists after cleanup for investigation and cross-revert.
|
|
2079
|
-
* Call cleanup() when done
|
|
2196
|
+
* Call cleanup() when done with the agent: the agent can't run again. From
|
|
2197
|
+
* the run's end, or from cleanup(), its ContextManager makes no provider
|
|
2198
|
+
* call, and the calls it has out are aborted. It starts no new call while a
|
|
2199
|
+
* surgery holds the store or once stop() has begun, either; one already out
|
|
2200
|
+
* then runs on until stop(), with a store the framework owns, closes the
|
|
2201
|
+
* ContextManager, before the store. Until then the ContextManager stays
|
|
2202
|
+
* open.
|
|
2080
2203
|
*/
|
|
2081
2204
|
createEphemeralAgent(config: AgentConfig): Promise<{
|
|
2082
2205
|
agent: Agent;
|
|
@@ -2114,8 +2237,9 @@ export declare class AgentFramework {
|
|
|
2114
2237
|
* framework drives the stream (emitting traces, logging, dispatching tools).
|
|
2115
2238
|
* Returns the agent's speech output when it finishes (no more tool calls).
|
|
2116
2239
|
* Rejects with ProviderWaitNotSleptError when the run ends rather than sleep
|
|
2117
|
-
* a retryable failure's stated wait
|
|
2118
|
-
*
|
|
2240
|
+
* a retryable failure's stated wait longer than the framework's ten-minute
|
|
2241
|
+
* cap, or one it can't represent, and with a plain Error for any other
|
|
2242
|
+
* ending, a stated wait its error policy declines among them.
|
|
2119
2243
|
*
|
|
2120
2244
|
* The caller provides a pre-created agent + contextManager (from createEphemeralAgent).
|
|
2121
2245
|
* The task message should already be in the context manager.
|
|
@@ -2146,6 +2270,7 @@ export declare class AgentFramework {
|
|
|
2146
2270
|
* hot-reloaded gate.json (same validation as load), so a rule takes effect
|
|
2147
2271
|
* immediately and survives restart. */
|
|
2148
2272
|
private static readonly WAKE_RULE_TOOLS;
|
|
2273
|
+
private static readonly JUDGED_WAKE_RULE_TOOLS;
|
|
2149
2274
|
/** Discoverability for event tags (MCPL RFC-001): the reserved chat:* core,
|
|
2150
2275
|
* each connected server's declared tag ontology, and gate.js status. */
|
|
2151
2276
|
private static readonly EVENT_TAGS_TOOL;
|
|
@@ -2179,26 +2304,13 @@ export declare class AgentFramework {
|
|
|
2179
2304
|
* Mark an inference refusal visibly: react on the message that holds the
|
|
2180
2305
|
* refused agent's conversational locus (the most recent incoming channel
|
|
2181
2306
|
* message that isn't a reaction, reaction removal, edit or deletion
|
|
2182
|
-
* marker, apart from an edit the coalescer delivers on acceptance as the
|
|
2307
|
+
* marker or a chat:system notice, apart from an edit the coalescer delivers on acceptance as the
|
|
2183
2308
|
* agent's first view; an ephemeral run has none, so a subagent's refusal
|
|
2184
2309
|
* marks no message) with a category-specific emoji. Best-effort —
|
|
2185
2310
|
* failures are logged, never thrown, and non-Discord loci are silently
|
|
2186
2311
|
* skipped.
|
|
2187
2312
|
*/
|
|
2188
2313
|
private reactToRefusal;
|
|
2189
|
-
/**
|
|
2190
|
-
* Shed the newest turn: remove the newest message that isn't a system
|
|
2191
|
-
* message, whoever wrote it, with the rest of its exchange (the tool_use
|
|
2192
|
-
* turn paired with a tool result, and the whole of a body stored in
|
|
2193
|
-
* shards). It adds no marker; the caller keeps one consolidated marker for
|
|
2194
|
-
* the episode (updateRewindMarker). The returned record's descriptor says
|
|
2195
|
-
* what was removed and its size, never the content, while the raw record
|
|
2196
|
-
* survives in the chronicle log for forensics. Returns null when only
|
|
2197
|
-
* system messages remain.
|
|
2198
|
-
*
|
|
2199
|
-
* Shared by the refusal rewind, automatic or forced by `/unstick`, and by
|
|
2200
|
-
* the shed after inference exhaustion (quarantinePoisonedHistory).
|
|
2201
|
-
*/
|
|
2202
2314
|
private shedNewestTurn;
|
|
2203
2315
|
/**
|
|
2204
2316
|
* Maintain exactly ONE consolidated marker for the current rewind episode,
|
|
@@ -2242,8 +2354,11 @@ export declare class AgentFramework {
|
|
|
2242
2354
|
ok: boolean;
|
|
2243
2355
|
error?: string;
|
|
2244
2356
|
agentName?: string;
|
|
2245
|
-
/** Agent state at queue time — 'idle' means
|
|
2246
|
-
*
|
|
2357
|
+
/** Agent state at queue time — 'idle' means no turn holds the agent, so
|
|
2358
|
+
* the turn starts on the next scheduler pass unless a provider hold (a
|
|
2359
|
+
* provider's stated wait, or a capacity cooldown) holds it until the hold
|
|
2360
|
+
* ends, or a start of the agent's that waits for an auxiliary call to
|
|
2361
|
+
* finish goes first; anything else means it runs after the current turn. */
|
|
2247
2362
|
agentStatus?: string;
|
|
2248
2363
|
/** True when the host is quiesced: the wake is PARKED, not running, until resume(). */
|
|
2249
2364
|
quiesced?: boolean;
|
|
@@ -2271,7 +2386,7 @@ export declare class AgentFramework {
|
|
|
2271
2386
|
* return the snapshot; the operator lever for draining quarantine or
|
|
2272
2387
|
* advancing merges during a quiesce window.
|
|
2273
2388
|
*
|
|
2274
|
-
* host-status — report the quiesce state (drained /
|
|
2389
|
+
* host-status — report the quiesce state (drained / waiting wakes /
|
|
2275
2390
|
* scripts left running).
|
|
2276
2391
|
*
|
|
2277
2392
|
* release-provider-wait — end an agent's provider wait (a provider's
|
|
@@ -2326,6 +2441,14 @@ export declare class AgentFramework {
|
|
|
2326
2441
|
* turn alive (no continuation or held retry of one on its way), or it is
|
|
2327
2442
|
* refused (OperatorActionError 'agent-busy'), and no turn starts until the
|
|
2328
2443
|
* switch is done.
|
|
2444
|
+
*
|
|
2445
|
+
* Every agent's context manager is re-initialized for the branch before
|
|
2446
|
+
* the store is released (reinitializeManagers). One whose
|
|
2447
|
+
* re-initialization fails raises an ops alert naming its agent
|
|
2448
|
+
* (`context-reinit-failed`), and the switch still resolves. A switch to the
|
|
2449
|
+
* branch the store is already on re-initializes them too, which is how a
|
|
2450
|
+
* manager left refusing by a failed re-initialization is recovered without
|
|
2451
|
+
* a restart.
|
|
2329
2452
|
*/
|
|
2330
2453
|
switchBranch(name: string): Promise<void>;
|
|
2331
2454
|
/**
|
|
@@ -2337,12 +2460,30 @@ export declare class AgentFramework {
|
|
|
2337
2460
|
*
|
|
2338
2461
|
* The undone branch is saved so `redo()` can restore it.
|
|
2339
2462
|
* Returns the checkpoint that was undone, or null if nothing to undo.
|
|
2463
|
+
*
|
|
2464
|
+
* The branch moves under every agent sharing the store, so an undo
|
|
2465
|
+
* reserves the store as a surgery does: every agent must be idle, or it is
|
|
2466
|
+
* refused (OperatorActionError 'agent-busy'). It returns once the store has
|
|
2467
|
+
* moved, and the store stays reserved until every agent's context manager
|
|
2468
|
+
* is re-initialized for the new branch, so no turn starts before then. One
|
|
2469
|
+
* whose re-initialization fails raises an ops alert naming its agent
|
|
2470
|
+
* (`context-reinit-failed`). An undo or redo made before the managers are
|
|
2471
|
+
* done moves the store again under the same reservation, and they are
|
|
2472
|
+
* re-initialized for the branch the last one leaves.
|
|
2473
|
+
*
|
|
2474
|
+
* `settled`, present when the store moved, settles once that reservation
|
|
2475
|
+
* is released, every manager re-initialized or its failure alerted, and
|
|
2476
|
+
* never rejects. Await it before work that needs the store free: a
|
|
2477
|
+
* compile on an agent's own context manager, or a write meant to land at
|
|
2478
|
+
* once, which the reservation would defer. An undo or redo that moves the
|
|
2479
|
+
* store again under the same reservation settles with it.
|
|
2340
2480
|
*/
|
|
2341
2481
|
undoLastTurn(agentName: string, requester?: OperatorRequester): {
|
|
2342
2482
|
undone: boolean;
|
|
2343
2483
|
turnIndex?: number;
|
|
2344
2484
|
fromBranch?: string;
|
|
2345
2485
|
toBranch?: string;
|
|
2486
|
+
settled?: Promise<void>;
|
|
2346
2487
|
};
|
|
2347
2488
|
/** undoLastTurn's work, for a host/command undo already admitted: a stop()
|
|
2348
2489
|
* begun by a trace of one of its turns doesn't refuse the next. */
|
|
@@ -2352,11 +2493,15 @@ export declare class AgentFramework {
|
|
|
2352
2493
|
*
|
|
2353
2494
|
* Switches back to the branch that was active before the last undo.
|
|
2354
2495
|
* Returns false if there's nothing to redo.
|
|
2496
|
+
*
|
|
2497
|
+
* It reserves the store and re-initializes every agent's context manager
|
|
2498
|
+
* as undoLastTurn() does, and its result's `settled` is undoLastTurn()'s.
|
|
2355
2499
|
*/
|
|
2356
2500
|
redo(agentName: string, requester?: OperatorRequester): {
|
|
2357
2501
|
redone: boolean;
|
|
2358
2502
|
fromBranch?: string;
|
|
2359
2503
|
toBranch?: string;
|
|
2504
|
+
settled?: Promise<void>;
|
|
2360
2505
|
};
|
|
2361
2506
|
/**
|
|
2362
2507
|
* Append a record to the operator action log and broadcast it as an
|
|
@@ -2396,6 +2541,13 @@ export declare class AgentFramework {
|
|
|
2396
2541
|
* does. Always release in `finally`: a token nobody clears wedges the fleet.
|
|
2397
2542
|
*/
|
|
2398
2543
|
private reserveStoreForSurgery;
|
|
2544
|
+
private reinitializeManagers;
|
|
2545
|
+
private reportLongHold;
|
|
2546
|
+
private disposeEmptiedForks;
|
|
2547
|
+
private reportReinitFailures;
|
|
2548
|
+
private reportReinitFailure;
|
|
2549
|
+
private beginSyncMove;
|
|
2550
|
+
private reinitializeAfterSyncMove;
|
|
2399
2551
|
/**
|
|
2400
2552
|
* A surgery's marker batch, recorded before its body change. If it can't
|
|
2401
2553
|
* be recorded, the surgery doesn't start, and the error says what the
|
|
@@ -2704,6 +2856,7 @@ export declare class AgentFramework {
|
|
|
2704
2856
|
* the template ("trunk") is a dormant warm checkpoint, not a listener.
|
|
2705
2857
|
*/
|
|
2706
2858
|
private routeConversationIncoming;
|
|
2859
|
+
private writeToFork;
|
|
2707
2860
|
/**
|
|
2708
2861
|
* Spawn a persistent per-channel conversation agent ("fork") from the
|
|
2709
2862
|
* template agent: own ContextManager under `conversations/{name}`, seeded
|
|
@@ -2736,13 +2889,15 @@ export declare class AgentFramework {
|
|
|
2736
2889
|
* Store the router's counters with the spawn's generation, create the fork
|
|
2737
2890
|
* the decision names and bind its channel to it, registered in
|
|
2738
2891
|
* conversationSpawns under the channel until it settles. The store runs
|
|
2739
|
-
* inside the spawn's promise,
|
|
2740
|
-
*
|
|
2741
|
-
*
|
|
2742
|
-
* the
|
|
2743
|
-
*
|
|
2744
|
-
*
|
|
2745
|
-
*
|
|
2892
|
+
* inside the spawn's promise, after it waits out a move's hold, so the
|
|
2893
|
+
* counter lands on the branch the fork is created on; with no hold up, it
|
|
2894
|
+
* runs in routeConversation's synchronous step. Either way a store that
|
|
2895
|
+
* throws rejects the spawn, which each caller reports as a failed spawn,
|
|
2896
|
+
* rather than throwing out of routeConversation before the caller's try.
|
|
2897
|
+
* routeConversation registers a spawn only when none is in flight for the
|
|
2898
|
+
* channel, and only this spawn's settlement removes it, so the entry it
|
|
2899
|
+
* removes is its own. It's removed before anyone waiting on it resumes, so
|
|
2900
|
+
* a waiter that decides again doesn't find it.
|
|
2746
2901
|
*
|
|
2747
2902
|
* It binds only while the fork it created is still the agent registered
|
|
2748
2903
|
* under its name. stop() ends each live fork and unbinds the channels
|
|
@@ -3053,7 +3208,10 @@ export declare class AgentFramework {
|
|
|
3053
3208
|
/** Record plain-prose segments this turn suppressed without drafts (proseRouting=disabled, or a round withheld before its scripts returned). */
|
|
3054
3209
|
private recordProseSuppression;
|
|
3055
3210
|
/**
|
|
3056
|
-
* Silenced plain speech: an explicit send
|
|
3211
|
+
* Silenced plain speech: an explicit send that may have posted where it was
|
|
3212
|
+
* going holds it as resendable drafts (in a round that calls `drafts` and
|
|
3213
|
+
* sends nothing else, 'kept', its plain speech is kept and counted
|
|
3214
|
+
* instead); a
|
|
3057
3215
|
* deliberate silence (skip_reply, a silent turn, or a private think in
|
|
3058
3216
|
* the same native round, where that policy applies: an XML-mode round has
|
|
3059
3217
|
* no verbatim content to route live, so its prose is routed at the turn's
|
|
@@ -3061,9 +3219,12 @@ export declare class AgentFramework {
|
|
|
3061
3219
|
* counted for the receipt, never drafted. `segments` are the runs exactly
|
|
3062
3220
|
* as written (splitProseRuns), so a draft keeps the resident's words byte
|
|
3063
3221
|
* for byte. What it holds, keeps or moves is the round's turn's
|
|
3064
|
-
* (round.routing), whenever the hold runs.
|
|
3222
|
+
* (round.routing), whenever the hold runs. Hybrid speech under a send goes
|
|
3223
|
+
* through routeSilencedHybrid.
|
|
3065
3224
|
*/
|
|
3066
3225
|
private holdSilencedProse;
|
|
3226
|
+
private routeSilencedHybrid;
|
|
3227
|
+
private sendHoldText;
|
|
3067
3228
|
/**
|
|
3068
3229
|
* Hold plain speech as drafts (src/prose-drafts.ts) instead of
|
|
3069
3230
|
* letting it vanish: journaled durably and recorded for the receipt of the
|
|
@@ -3188,6 +3349,8 @@ export declare class AgentFramework {
|
|
|
3188
3349
|
* ([discord-send-failed]); this is the success half.
|
|
3189
3350
|
*/
|
|
3190
3351
|
private appendProseDeliveryReceipt;
|
|
3352
|
+
private nameUnpostedSpeech;
|
|
3353
|
+
private noteFailedTurnEnd;
|
|
3191
3354
|
/**
|
|
3192
3355
|
* The closed-channel note alone, in a send's words, at explicit mode's turn
|
|
3193
3356
|
* end, which has no `[delivered]` receipt since the agent named every
|
|
@@ -3340,6 +3503,7 @@ export declare class AgentFramework {
|
|
|
3340
3503
|
* left running when it handed the turn on.
|
|
3341
3504
|
*/
|
|
3342
3505
|
private showTurnTyping;
|
|
3506
|
+
private heardSince;
|
|
3343
3507
|
/**
|
|
3344
3508
|
* The channel of the turn's newest arrival whose message is still in the
|
|
3345
3509
|
* agent's store (TurnRouting.arrivals). A message removed since it was
|
|
@@ -3387,6 +3551,7 @@ export declare class AgentFramework {
|
|
|
3387
3551
|
* locus-eligible.
|
|
3388
3552
|
*/
|
|
3389
3553
|
private recordChannelAutoOpenNotice;
|
|
3554
|
+
private tellReasoningLoss;
|
|
3390
3555
|
/**
|
|
3391
3556
|
* Write a builder's channel notices in order, each on its own: one that
|
|
3392
3557
|
* can't be written is logged, and the rest are still written. A reader's
|
|
@@ -3637,6 +3802,7 @@ export declare class AgentFramework {
|
|
|
3637
3802
|
private draftStateNow;
|
|
3638
3803
|
/** Locus-preserving explicit publication. Source remains byte-identical in Chronicle. */
|
|
3639
3804
|
private deliverHybridProse;
|
|
3805
|
+
private deliverHybridEnvelope;
|
|
3640
3806
|
/** `>>skip_reply {{unsent}}` and its hybrid form: set the latest bounce
|
|
3641
3807
|
* draft aside — unless it is being sent right now, which a dismissal
|
|
3642
3808
|
* can't call back: the resident is told instead. So are a dismissal whose
|
|
@@ -3693,7 +3859,8 @@ export declare class AgentFramework {
|
|
|
3693
3859
|
* abandon or a stop of a registered agent settles the turn as it settles a
|
|
3694
3860
|
* turn's start (endStoppedStart: one inference:aborted, the turn settled,
|
|
3695
3861
|
* the gate released). Any other drop ends it as a start dropped before it
|
|
3696
|
-
* sends anything ends
|
|
3862
|
+
* sends anything ends, and settles a registered ephemeral run's turn with
|
|
3863
|
+
* the drop's reason. That frame, if it hasn't let go of its token yet,
|
|
3697
3864
|
* ends on its own and settles nothing. What was deferred for the agent
|
|
3698
3865
|
* lands now, or at that frame's end.
|
|
3699
3866
|
*/
|
|
@@ -3703,8 +3870,9 @@ export declare class AgentFramework {
|
|
|
3703
3870
|
* admission, the hold installs nothing (holdForProviderWait,
|
|
3704
3871
|
* holdProviderAcceleration), so no retry follows the turn's
|
|
3705
3872
|
* inference:failed, and the turn ends as a retry a stop cancelled ends, with
|
|
3706
|
-
* an inference:aborted saying so. Nothing is written
|
|
3707
|
-
* the turn.
|
|
3873
|
+
* an inference:aborted saying so. Nothing is written but the
|
|
3874
|
+
* [speech-not-posted] notice, for speech the turn's rounds left unposted.
|
|
3875
|
+
* True when it ended the turn.
|
|
3708
3876
|
*/
|
|
3709
3877
|
private endFailureAtStop;
|
|
3710
3878
|
/**
|
|
@@ -3739,6 +3907,42 @@ export declare class AgentFramework {
|
|
|
3739
3907
|
* terminal, and the caller's goes with it.
|
|
3740
3908
|
*/
|
|
3741
3909
|
private takeStartStop;
|
|
3910
|
+
/**
|
|
3911
|
+
* Cancel a stream the framework stops, under `kind`, the mark that tells
|
|
3912
|
+
* the stream's end apart from a caller's stop (frameworkCancelledStreams).
|
|
3913
|
+
* A mark records a cancel that happened, so a cancel that throws takes its
|
|
3914
|
+
* mark back, leaving an earlier mark of the same stream as it was, and the
|
|
3915
|
+
* throw goes on to the caller. With no `kind` (the agent holds no stream),
|
|
3916
|
+
* nothing is marked.
|
|
3917
|
+
*/
|
|
3918
|
+
private cancelUnderMark;
|
|
3919
|
+
/**
|
|
3920
|
+
* Cancel a live stream the framework ends at a tool boundary (`site` says
|
|
3921
|
+
* where), under its mark. A cancel that throws leaves the stream going: its
|
|
3922
|
+
* mark is taken back (cancelUnderMark), `onFailed` undoes what the site
|
|
3923
|
+
* did ahead of the cancel, and the failure is logged. The stream waits for
|
|
3924
|
+
* the round's results, which the boundary doesn't send, and the turn holds
|
|
3925
|
+
* its token until the stream ends, as an abort does when its own cancel
|
|
3926
|
+
* goes through. Only an operator's abort or stop, or an ephemeral run's
|
|
3927
|
+
* idle watchdog, comes back to it, so an operator alert says so too.
|
|
3928
|
+
* Returns whether the cancel went through.
|
|
3929
|
+
*/
|
|
3930
|
+
private cancelLiveStream;
|
|
3931
|
+
/**
|
|
3932
|
+
* Cancel a stream a start compiled and won't send (`site` says why).
|
|
3933
|
+
* Membrane's yielding stream starts its request when it is first iterated,
|
|
3934
|
+
* and this one never is, so it has sent nothing: a cancel that throws is
|
|
3935
|
+
* logged, and the start's cleanup goes on as if it had worked.
|
|
3936
|
+
*/
|
|
3937
|
+
private cancelUnsentStream;
|
|
3938
|
+
/**
|
|
3939
|
+
* Cancel a stream that no longer owns its agent: the agent was replaced or
|
|
3940
|
+
* removed, or a newer stream took it. Its frame settles nothing and is
|
|
3941
|
+
* leaving, so a cancel that throws is logged and the frame leaves all the
|
|
3942
|
+
* same. Thrown on, it would reject driveStream's promise, which nothing
|
|
3943
|
+
* awaits but stop().
|
|
3944
|
+
*/
|
|
3945
|
+
private cancelSupersededStream;
|
|
3742
3946
|
/**
|
|
3743
3947
|
* End a start that a stop reached before it sent anything, through the
|
|
3744
3948
|
* terminal the same stop gets on a live stream: a caller's stop as
|
|
@@ -3830,6 +4034,11 @@ export declare class AgentFramework {
|
|
|
3830
4034
|
* assembled field by field (as unit tests do) needs no setup for it.
|
|
3831
4035
|
*/
|
|
3832
4036
|
private toolsetActCalls?;
|
|
4037
|
+
private puppetChanges?;
|
|
4038
|
+
/** RFC-014 §6.1: a change reaches the agent once, so it goes with a result
|
|
4039
|
+
* only where the result is stored in an agent's window (the puppet's) or
|
|
4040
|
+
* handed to an agent awaiting it; null where it may not reach one. */
|
|
4041
|
+
private changeTaker;
|
|
3833
4042
|
/** A toolsets--act call resolved (resolveAct) to the call of the server's
|
|
3834
4043
|
* tool it makes, under that tool's model-facing name and with its
|
|
3835
4044
|
* arguments, its id kept; or the reason it can't be sent. */
|
|
@@ -3845,27 +4054,26 @@ export declare class AgentFramework {
|
|
|
3845
4054
|
* before anything is sent.
|
|
3846
4055
|
*/
|
|
3847
4056
|
private dispatchToolsetAct;
|
|
3848
|
-
/**
|
|
3849
|
-
* RFC-014 §6.2: a tool result that goes to the agent, with the tool change
|
|
3850
|
-
* its hints made (applied as the result was read) told after the server's
|
|
3851
|
-
* content; taking it means it isn't told again as a notice. The result
|
|
3852
|
-
* itself when there's none, as for every server without toolHints.
|
|
3853
|
-
*/
|
|
3854
|
-
private withToolsetChange;
|
|
3855
4057
|
/** A programmatic call of an MCPL tool: `serverId` and `prefix` as
|
|
3856
4058
|
* resolveMcplTool matched them, or as toolsets--act resolved them
|
|
3857
|
-
* (toolsetActCalls). Its RFC-014 tool change
|
|
3858
|
-
*
|
|
3859
|
-
*
|
|
4059
|
+
* (toolsetActCalls). Its RFC-014 tool change goes with its result only
|
|
4060
|
+
* where the result is stored in an agent's window or handed to an agent
|
|
4061
|
+
* awaiting it (changeTaker); any other caller's
|
|
4062
|
+
* result may never reach one, so its change is told as a notice
|
|
4063
|
+
* (ToolsetController.tellUnlessClaimed). */
|
|
3860
4064
|
private executeMcplToolCall;
|
|
4065
|
+
private withWholeChange;
|
|
4066
|
+
private withActStateHint;
|
|
3861
4067
|
/** Event-pushing wrapper for the model-driven dispatch path. */
|
|
3862
4068
|
private dispatchCodeExecutionToolCall;
|
|
4069
|
+
private decideWaitingRound;
|
|
3863
4070
|
/**
|
|
3864
4071
|
* A model-issued tool's result has arrived. When it answers the last of
|
|
3865
|
-
* the code_execution calls a round waits on (ScriptRound), the
|
|
3866
|
-
* prose is routed now, its scripts' calls counted.
|
|
4072
|
+
* the code_execution calls and sends a round waits on (ScriptRound), the
|
|
4073
|
+
* round's prose is routed now, its scripts' calls counted.
|
|
3867
4074
|
*/
|
|
3868
4075
|
private settleScriptRound;
|
|
4076
|
+
private sendReachOf;
|
|
3869
4077
|
/**
|
|
3870
4078
|
* Whether a code_execution call watches a script that can change its
|
|
3871
4079
|
* round's routing, so the round waits for the call (ScriptRound): a run's
|
|
@@ -4169,8 +4377,9 @@ export declare class AgentFramework {
|
|
|
4169
4377
|
}>;
|
|
4170
4378
|
/**
|
|
4171
4379
|
* Find the MCPL server for a tool: [serverId, prefix], or null.
|
|
4172
|
-
* The tool listing decides: the server whose tools/list
|
|
4173
|
-
*
|
|
4380
|
+
* The tool listing decides: the server whose tools/list listed the name
|
|
4381
|
+
* (offered to the model, or an RFC-014 dynamic tool, which dispatch then
|
|
4382
|
+
* refuses by that name unless the published list or the server's latest tools/list puts it as static), after its tool policy, as of the last tool refresh (a server that
|
|
4174
4383
|
* closed since keeps its names until the next one). A name the listing
|
|
4175
4384
|
* doesn't hold (invented by the model, or no longer listed) goes to the
|
|
4176
4385
|
* longest matching prefix. Prefixes that meet, such as `foo` and
|
|
@@ -4183,10 +4392,13 @@ export declare class AgentFramework {
|
|
|
4183
4392
|
* while unregistered. Genuine legacy caller names retain their surface. */
|
|
4184
4393
|
private canAgentUseTool;
|
|
4185
4394
|
private agentToolPermissionFailure;
|
|
4395
|
+
private markedInputFailure;
|
|
4396
|
+
private cutOffResults;
|
|
4186
4397
|
/**
|
|
4187
|
-
* A
|
|
4188
|
-
*
|
|
4189
|
-
*
|
|
4398
|
+
* A call answered without running its tool: one the dispatcher refused, or
|
|
4399
|
+
* one in the last round of a response the output limit cut off. RFC-007's
|
|
4400
|
+
* lifecycle forgets it, and its result says it was refused
|
|
4401
|
+
* (`ToolResult.refused`), both from here, so the two can't disagree.
|
|
4190
4402
|
*/
|
|
4191
4403
|
private refusedResult;
|
|
4192
4404
|
/**
|
|
@@ -4207,7 +4419,8 @@ export declare class AgentFramework {
|
|
|
4207
4419
|
* A call as its round's routing counts it, made directly, or by a script
|
|
4208
4420
|
* and reaching the host while a run or wait call of the round watches it
|
|
4209
4421
|
* (ScriptRound). A skip_reply refused, because the agent's allowedTools
|
|
4210
|
-
* doesn't name it
|
|
4422
|
+
* doesn't name it, because its arguments are refused (markedInputRefusal)
|
|
4423
|
+
* or because this host can't set the wake it asks for, is
|
|
4211
4424
|
* marked refused: it keeps its own round private and silences nothing after
|
|
4212
4425
|
* it. A refusal withholds the call's effect, not the model's choice to keep
|
|
4213
4426
|
* its words private. Any other call the list refuses posted nothing, so it
|
|
@@ -4804,12 +5017,9 @@ export declare class AgentFramework {
|
|
|
4804
5017
|
* nothing new costs less than a write no wake brings the agent to read
|
|
4805
5018
|
* or answer. */
|
|
4806
5019
|
private deferredWriteDone;
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
* that reads it. The scheduler drops the wake once the write needs
|
|
4811
|
-
* nothing more of the agent (deferredWriteDone). */
|
|
4812
|
-
private readsDeferredFor;
|
|
5020
|
+
private storedMessageDone;
|
|
5021
|
+
private writeAnswered;
|
|
5022
|
+
private readsWriteFor;
|
|
4813
5023
|
private editMessage;
|
|
4814
5024
|
private removeMessage;
|
|
4815
5025
|
private getMessage;
|
|
@@ -5496,7 +5706,9 @@ export declare class AgentFramework {
|
|
|
5496
5706
|
*/
|
|
5497
5707
|
private refreshMcplTools;
|
|
5498
5708
|
/**
|
|
5499
|
-
* Report operator tool-name patterns that match no
|
|
5709
|
+
* Report operator tool-name patterns that match no tool name: one the
|
|
5710
|
+
* model is offered, or an RFC-014 dynamic tool's listed name, which its
|
|
5711
|
+
* class rules and lifecycle selectors match as a direct call's would:
|
|
5500
5712
|
* `toolClassOverrides` keys and each server's `toolLifecycle.observe.tools`
|
|
5501
5713
|
* / `toolLifecycle.inputs.tools`. These match `<toolPrefix>--<tool>`, and
|
|
5502
5714
|
* the default prefix is `mcpl--<serverId>`, so a pattern written against
|
|
@@ -5511,8 +5723,9 @@ export declare class AgentFramework {
|
|
|
5511
5723
|
private checkToolPatterns;
|
|
5512
5724
|
/** Every tool name the framework offers to anyone: the shared board plus
|
|
5513
5725
|
* each agent's own surface, before presentation visibility (a hidden tool
|
|
5514
|
-
* is still callable, so classes and lifecycle still apply to it)
|
|
5515
|
-
|
|
5726
|
+
* is still callable, so classes and lifecycle still apply to it), and
|
|
5727
|
+
* every name an MCPL server lists, a dynamic tool's included. */
|
|
5728
|
+
private patternableToolNames;
|
|
5516
5729
|
/**
|
|
5517
5730
|
* Handle a tools/list_changed notification with collapse logic.
|
|
5518
5731
|
* At most 2 refresh cycles can be in-flight: one running and one pending.
|
|
@@ -5652,6 +5865,8 @@ export declare class AgentFramework {
|
|
|
5652
5865
|
* through callTool. */
|
|
5653
5866
|
private handleUtilsToolCall;
|
|
5654
5867
|
private dispatchUtilsToolCall;
|
|
5868
|
+
private readAgentSettings;
|
|
5869
|
+
private settingsChangedSince;
|
|
5655
5870
|
private dispatchAgentSettingsToolCall;
|
|
5656
5871
|
/** Aggregate the event-tag vocabulary: reserved chat:* core + each connected
|
|
5657
5872
|
* server's declared tag ontology + gate.js status. */
|