operon-agents-core 0.1.0-alpha.19 → 0.1.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/context-report.d.ts +1 -1
- package/dist/agent/runner.js +12 -6
- package/dist/agent/session.d.ts +2 -1
- package/dist/agent/session.js +4 -3
- package/dist/loop/run-turn.d.ts +2 -0
- package/dist/loop/run-turn.js +1 -0
- package/dist/loop/turn-step.d.ts +2 -0
- package/dist/loop/turn-step.js +1 -0
- package/package.json +1 -1
|
@@ -42,7 +42,7 @@ export interface ContextBreakdown {
|
|
|
42
42
|
readonly compactBuffer: ContextSlice;
|
|
43
43
|
/** contextWindow − used − compactBuffer, clamped at 0. */
|
|
44
44
|
readonly free: ContextSlice;
|
|
45
|
-
/** Epoch ms the snapshot was taken (turn boundary). */
|
|
45
|
+
/** Epoch ms the snapshot was taken (turn boundary, then each step's request). */
|
|
46
46
|
readonly capturedAt: number;
|
|
47
47
|
}
|
|
48
48
|
export interface ComputeContextBreakdownInput {
|
package/dist/agent/runner.js
CHANGED
|
@@ -616,17 +616,18 @@ class Engine {
|
|
|
616
616
|
const hooks = buildRunHooks(current, state, context, () => permissionTools);
|
|
617
617
|
// The same projection the first step will send (announcements are that step's job).
|
|
618
618
|
const visibleTools = prepareToolCatalog(context, toolset, { announce: false }).schemas.map((schema) => ({ schema }));
|
|
619
|
-
// Stamp a context-window breakdown snapshot
|
|
620
|
-
//
|
|
621
|
-
|
|
619
|
+
// Stamp a context-window breakdown snapshot, so `session.getContextBreakdown()` (and the
|
|
620
|
+
// app-server RPC) can report where tokens go: here from the projection the first step will
|
|
621
|
+
// send, then again from every step's final request — an extension's `model.request` hook may
|
|
622
|
+
// rewrite it (Code Mode takes the MCP catalog out), and the report must show what was sent.
|
|
623
|
+
const stampBreakdown = (snapshot) => state.session.recordContextBreakdown(computeContextBreakdown({
|
|
622
624
|
model,
|
|
623
|
-
|
|
624
|
-
tools: visibleTools,
|
|
625
|
-
messages: context.messages,
|
|
625
|
+
...snapshot,
|
|
626
626
|
injectionTokens,
|
|
627
627
|
compactBufferTokens: state.session.compactionView?.reservedContextTokens ?? 0,
|
|
628
628
|
capturedAt: Date.now(),
|
|
629
629
|
}));
|
|
630
|
+
stampBreakdown({ system, tools: visibleTools, messages: context.messages });
|
|
630
631
|
const turnId = state.currentTurnId ?? `${state.sessionId}-t${state.turns}`;
|
|
631
632
|
const outputGuardrails = current.guardrails.output ?? [];
|
|
632
633
|
if (resume === undefined)
|
|
@@ -653,6 +654,11 @@ class Engine {
|
|
|
653
654
|
deferredToolNames: toolset.deferredToolNames,
|
|
654
655
|
deferEnabled: toolset.deferEnabled,
|
|
655
656
|
onToolsPrepared: (tools) => { permissionTools = tools; },
|
|
657
|
+
onRequestPrepared: (request) => stampBreakdown({
|
|
658
|
+
system: request.system,
|
|
659
|
+
tools: (request.tools ?? []).map((schema) => ({ schema })),
|
|
660
|
+
messages: request.messages,
|
|
661
|
+
}),
|
|
656
662
|
refreshTools: () => buildRunTools(current, state, (agent, childContext, childState, childResume) => this.run(agent, childContext, childState, childResume), model),
|
|
657
663
|
hooks,
|
|
658
664
|
answers: state.answers,
|
package/dist/agent/session.d.ts
CHANGED
|
@@ -371,7 +371,8 @@ export declare class Session implements SessionPort {
|
|
|
371
371
|
*/
|
|
372
372
|
get background(): BackgroundManager | undefined;
|
|
373
373
|
/** The most-recent context-window breakdown (system/tools/messages/injections/free), stamped
|
|
374
|
-
* by the Runner at each turn boundary
|
|
374
|
+
* by the Runner at each turn boundary and again from every step's request as sent, after every
|
|
375
|
+
* hook (an extension may rewrite it) — or undefined if no turn has assembled a request yet.
|
|
375
376
|
* A read-only snapshot: it reflects the last turn sent, not a fresh recomputation. */
|
|
376
377
|
getContextBreakdown(): ContextBreakdown | undefined;
|
|
377
378
|
/** Runner-internal: record the breakdown assembled for the turn about to be sent. */
|
package/dist/agent/session.js
CHANGED
|
@@ -109,8 +109,8 @@ export class Session {
|
|
|
109
109
|
pendingChanges = [];
|
|
110
110
|
/** Serializes applied changes, and lets `close()` wait for the one in progress. */
|
|
111
111
|
changeChain = Promise.resolve();
|
|
112
|
-
// Most-recent
|
|
113
|
-
// Undefined until the first turn assembles a request.
|
|
112
|
+
// Most-recent context-window breakdown, stamped by the Runner at each turn boundary and from
|
|
113
|
+
// each step's final request. Undefined until the first turn assembles a request.
|
|
114
114
|
lastContextBreakdown;
|
|
115
115
|
/** Built at the end of `open`, once every capability's policies are in. */
|
|
116
116
|
permissionManager;
|
|
@@ -698,7 +698,8 @@ export class Session {
|
|
|
698
698
|
return this.service("background");
|
|
699
699
|
}
|
|
700
700
|
/** The most-recent context-window breakdown (system/tools/messages/injections/free), stamped
|
|
701
|
-
* by the Runner at each turn boundary
|
|
701
|
+
* by the Runner at each turn boundary and again from every step's request as sent, after every
|
|
702
|
+
* hook (an extension may rewrite it) — or undefined if no turn has assembled a request yet.
|
|
702
703
|
* A read-only snapshot: it reflects the last turn sent, not a fresh recomputation. */
|
|
703
704
|
getContextBreakdown() {
|
|
704
705
|
return this.lastContextBreakdown;
|
package/dist/loop/run-turn.d.ts
CHANGED
|
@@ -39,6 +39,8 @@ export interface RunTurnInput {
|
|
|
39
39
|
/** Snapshot after beforeStep, so a connection completed during a turn is seen next step. */
|
|
40
40
|
readonly refreshTools?: () => Promise<ToolCatalogSnapshot>;
|
|
41
41
|
readonly onToolsPrepared?: (tools: readonly Tool[]) => void;
|
|
42
|
+
/** Each step's request as it goes to the model, after every hook. */
|
|
43
|
+
readonly onRequestPrepared?: (request: LlmRequest) => void;
|
|
42
44
|
readonly hooks?: LoopHooks;
|
|
43
45
|
/** Per-step optimistic output guardrail adapter supplied by the active agent layer. */
|
|
44
46
|
readonly createOutputGuardrailMonitor?: OutputGuardrailMonitorFactory;
|
package/dist/loop/run-turn.js
CHANGED
|
@@ -90,6 +90,7 @@ export async function runTurn(input) {
|
|
|
90
90
|
deferEnabled: input.deferEnabled,
|
|
91
91
|
refreshTools: input.refreshTools,
|
|
92
92
|
onToolsPrepared: input.onToolsPrepared,
|
|
93
|
+
onRequestPrepared: input.onRequestPrepared,
|
|
93
94
|
hooks: input.hooks,
|
|
94
95
|
createOutputGuardrailMonitor: input.createOutputGuardrailMonitor,
|
|
95
96
|
currentStep: steps,
|
package/dist/loop/turn-step.d.ts
CHANGED
|
@@ -44,6 +44,8 @@ export interface ExecuteStepDeps {
|
|
|
44
44
|
readonly deferEnabled?: boolean;
|
|
45
45
|
readonly refreshTools?: () => Promise<ToolCatalogSnapshot>;
|
|
46
46
|
readonly onToolsPrepared?: (tools: readonly Tool[]) => void;
|
|
47
|
+
/** The request exactly as it goes to the model, after every hook (an extension may rewrite it). */
|
|
48
|
+
readonly onRequestPrepared?: (request: LlmRequest) => void;
|
|
47
49
|
readonly hooks?: LoopHooks;
|
|
48
50
|
readonly createOutputGuardrailMonitor?: OutputGuardrailMonitorFactory;
|
|
49
51
|
readonly currentStep: number;
|
package/dist/loop/turn-step.js
CHANGED
|
@@ -70,6 +70,7 @@ export async function executeStep(deps) {
|
|
|
70
70
|
request = beforeModel.request;
|
|
71
71
|
}
|
|
72
72
|
signal.throwIfAborted();
|
|
73
|
+
deps.onRequestPrepared?.(request);
|
|
73
74
|
const stepId = `${turnId}.${currentStep}`;
|
|
74
75
|
const outputGuardrail = deps.createOutputGuardrailMonitor?.({
|
|
75
76
|
turnId,
|