@prometheus-ai/agent-core 0.5.4 → 0.5.8

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.
@@ -1,10 +1,17 @@
1
- import type { AssistantMessage, AssistantMessageEvent, AssistantMessageEventStream, Effort, ImageContent, Message, Model, SimpleStreamOptions, Static, streamSimple, TextContent, Tool, ToolChoice, ToolResultMessage, TSchema } from "@prometheus-ai/ai";
1
+ import type { ApiKeyResolveContext, AssistantMessage, AssistantMessageEvent, AssistantMessageEventStream, Context, Effort, ImageContent, Message, Model, SimpleStreamOptions, Static, streamSimple, TextContent, Tool, ToolChoice, ToolResultMessage, TSchema } from "@prometheus-ai/ai";
2
2
  import type { AppendOnlyContextManager } from "./append-only-context";
3
3
  import type { HarmonyAuditEvent } from "./harmony-leak";
4
4
  import type { AgentRunCoverage, AgentRunSummary } from "./run-collector";
5
5
  import type { AgentTelemetryConfig } from "./telemetry";
6
6
  /** Stream function - can return sync or Promise for async config lookup */
7
7
  export type StreamFn = (...args: Parameters<typeof streamSimple>) => AssistantMessageEventStream | Promise<AssistantMessageEventStream>;
8
+ /**
9
+ * An aside entry: a ready {@link AgentMessage}, or a sync thunk evaluated at
10
+ * injection time that returns the message to inject or `null` to skip it. Thunks
11
+ * let the producer make the final inject-or-drop decision against current state
12
+ * (e.g. dropping late diagnostics a newer edit superseded).
13
+ */
14
+ export type AsideMessage = AgentMessage | (() => AgentMessage | null);
8
15
  /**
9
16
  * Configuration for the agent loop.
10
17
  */
@@ -16,13 +23,6 @@ export interface AgentLoopConfig extends SimpleStreamOptions {
16
23
  * - "wait" = defer steering until the current turn completes
17
24
  */
18
25
  interruptMode?: "immediate" | "wait";
19
- /**
20
- * Maximum completed tool calls to accept from one streamed assistant turn before
21
- * cutting the provider stream and executing that batch. The cap is enforced on
22
- * `toolcall_end` so every executed call has complete arguments. Undefined disables
23
- * batching.
24
- */
25
- maxToolCallsPerTurn?: number;
26
26
  /**
27
27
  * Optional session identifier forwarded to LLM providers.
28
28
  * Used by providers that support session-based caching (e.g., OpenAI Codex).
@@ -79,21 +79,42 @@ export interface AgentLoopConfig extends SimpleStreamOptions {
79
79
  * ```
80
80
  */
81
81
  transformContext?: (messages: AgentMessage[], signal?: AbortSignal) => Promise<AgentMessage[]>;
82
+ /**
83
+ * Optional transform applied to the final provider context after conversion,
84
+ * normalization, and append-only context handling, but before telemetry capture
85
+ * and provider send.
86
+ */
87
+ transformProviderContext?: (context: Context, model: Model) => Context;
82
88
  /**
83
89
  * Resolves an API key dynamically for each LLM call.
84
90
  *
85
91
  * Useful for short-lived OAuth tokens (e.g., GitHub Copilot) that may expire
86
92
  * during long-running tool execution phases.
87
93
  */
88
- getApiKey?: (provider: string) => Promise<string | undefined> | string | undefined;
94
+ getApiKey?: (provider: string, ctx?: ApiKeyResolveContext) => Promise<string | undefined> | string | undefined;
89
95
  /**
90
96
  * Returns steering messages to inject into the conversation mid-run.
91
97
  *
92
- * Called after each tool execution to check for user interruptions unless interruptMode is "wait".
93
- * If messages are returned, remaining tool calls are skipped and
94
- * these messages are added to the context before the next LLM call.
98
+ * Called at injection boundaries only (loop start and after a tool batch
99
+ * fully settles), so dequeued messages are immediately injected. The
100
+ * mid-batch interrupt poll uses {@link hasSteeringMessages} instead and
101
+ * never consumes the queue.
95
102
  */
96
103
  getSteeringMessages?: () => Promise<AgentMessage[]>;
104
+ /**
105
+ * Peeks whether steering messages are queued, without consuming them.
106
+ *
107
+ * Called after each tool execution (unless interruptMode is "wait") to decide
108
+ * whether to skip the remaining tool calls in the batch. The queue keeps
109
+ * owning its messages until the loop reaches the next injection boundary and
110
+ * dequeues via {@link getSteeringMessages} — so callers can still cancel or
111
+ * restore queued messages while in-flight tools settle, and an external
112
+ * abort in that window leaves the queue intact for a post-abort continue.
113
+ *
114
+ * When omitted, steering never interrupts a running tool batch; queued
115
+ * messages are still delivered at the next injection boundary.
116
+ */
117
+ hasSteeringMessages?: () => boolean | Promise<boolean>;
97
118
  /**
98
119
  * Returns follow-up messages to process after the agent would otherwise stop.
99
120
  *
@@ -102,6 +123,17 @@ export interface AgentLoopConfig extends SimpleStreamOptions {
102
123
  * continues with another turn.
103
124
  */
104
125
  getFollowUpMessages?: () => Promise<AgentMessage[]>;
126
+ /**
127
+ * Returns non-interrupting "aside" messages to inject at a step boundary.
128
+ *
129
+ * Polled after each tool batch (before the next LLM call) AND at the yield
130
+ * check. Unlike steering, these NEVER abort in-flight tools — they are passive
131
+ * notifications (e.g. background-job completions, late LSP diagnostics) that
132
+ * should reach the model between requests without waiting for the agent to
133
+ * fully stop. Returned messages are appended to the context with normal
134
+ * message events and keep the loop running so the model can react.
135
+ */
136
+ getAsideMessages?: () => Promise<AsideMessage[]>;
105
137
  /**
106
138
  * Hook fired right before the loop would exit.
107
139
  *
@@ -160,6 +192,14 @@ export interface AgentLoopConfig extends SimpleStreamOptions {
160
192
  * the next model call instead of waiting for the next prompt.
161
193
  */
162
194
  getReasoning?: () => Effort | undefined;
195
+ /**
196
+ * Dynamic reasoning-disable override, resolved per LLM call. When set,
197
+ * its return value overrides the static `disableReasoning` from
198
+ * `SimpleStreamOptions` for that request. Pair with `getReasoning` so
199
+ * mid-run transitions into and out of the explicit `off` state propagate
200
+ * to the next provider call.
201
+ */
202
+ getDisableReasoning?: () => boolean | undefined;
163
203
  /**
164
204
  * Called after a tool call has been validated and is about to execute.
165
205
  *
@@ -237,6 +277,8 @@ export interface AfterToolCallResult {
237
277
  details?: unknown;
238
278
  /** If provided, replaces the error flag carried with the tool result. */
239
279
  isError?: boolean;
280
+ /** If provided, replaces the contextually-useless flag carried with the tool result. */
281
+ useless?: boolean;
240
282
  }
241
283
  /** Context passed to `beforeToolCall`. */
242
284
  export interface BeforeToolCallContext {
@@ -273,7 +315,7 @@ export interface AfterToolCallContext {
273
315
  *
274
316
  * @example
275
317
  * ```typescript
276
- * declare module "@prometheus-ai/agent-core" {
318
+ * declare module "@prometheus-ai/agent" {
277
319
  * interface CustomAgentMessages {
278
320
  * artifact: ArtifactMessage;
279
321
  * notification: NotificationMessage;
@@ -296,6 +338,7 @@ export interface AgentState {
296
338
  systemPrompt: string[];
297
339
  model: Model;
298
340
  thinkingLevel?: Effort;
341
+ disableReasoning?: boolean;
299
342
  tools: AgentTool<any>[];
300
343
  messages: AgentMessage[];
301
344
  isStreaming: boolean;
@@ -307,6 +350,8 @@ export interface AgentToolResult<T = any, _TInput = unknown> {
307
350
  content: (TextContent | ImageContent)[];
308
351
  details?: T;
309
352
  isError?: boolean;
353
+ /** Marks the result as contextually useless: safe for compaction to elide once consumed (e.g. zero matches, wait timeout). Ignored when isError is set. */
354
+ useless?: boolean;
310
355
  }
311
356
  export type AgentToolUpdateCallback<T = any, TInput = unknown> = (partialResult: AgentToolResult<T, TInput>) => void;
312
357
  /** Options passed to renderResult */
@@ -352,14 +397,13 @@ export interface AgentTool<TParameters extends TSchema = TSchema, TDetails = any
352
397
  loadMode?: "essential" | "discoverable";
353
398
  /** Short one-line summary used for tool discovery indexes. */
354
399
  summary?: string;
355
- /** If true, tool execution ignores abort signals (runs to completion) */
356
- nonAbortable?: boolean;
357
400
  /**
358
401
  * Concurrency mode for tool scheduling when multiple calls are in one turn.
359
402
  * - "shared": can run alongside other shared tools (default)
360
403
  * - "exclusive": runs alone; other tools wait until it finishes
404
+ * - function: resolved per call from the (raw, pre-validation) arguments
361
405
  */
362
- concurrency?: "shared" | "exclusive";
406
+ concurrency?: "shared" | "exclusive" | ((args: Partial<Static<TParameters>>) => "shared" | "exclusive");
363
407
  /** If true, argument validation errors are non-fatal: raw args are passed to execute() instead of returning an error to the LLM. */
364
408
  lenientArgValidation?: boolean;
365
409
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@prometheus-ai/agent-core",
4
- "version": "0.5.4",
4
+ "version": "0.5.8",
5
5
  "description": "General-purpose agent with transport abstraction, state management, and attachment support",
6
6
  "homepage": "https://prometheus.trivlab.com",
7
7
  "author": "Uttam Trivedi",
@@ -32,9 +32,11 @@
32
32
  "fmt": "biome format --write ."
33
33
  },
34
34
  "dependencies": {
35
- "@prometheus-ai/ai": "0.5.4",
36
- "@prometheus-ai/natives": "0.5.4",
37
- "@prometheus-ai/utils": "0.5.4",
35
+ "@prometheus-ai/ai": "0.5.8",
36
+ "@prometheus-ai/catalog": "0.5.8",
37
+ "@prometheus-ai/natives": "0.5.8",
38
+ "@prometheus-ai/snapcompact": "0.5.8",
39
+ "@prometheus-ai/utils": "0.5.8",
38
40
  "@opentelemetry/api": "^1.9.1"
39
41
  },
40
42
  "devDependencies": {