@theokit/agents 0.21.2 → 0.23.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/dist/{bridge-entry-CEnpN6oR.d.ts → bridge-entry-DlW7p2I4.d.ts} +81 -3
- package/dist/bridge.d.ts +2 -2
- package/dist/bridge.js +7 -1
- package/dist/{chunk-FRNNQVHX.js → chunk-ZTVXZIBZ.js} +116 -5
- package/dist/chunk-ZTVXZIBZ.js.map +1 -0
- package/dist/decorators.d.ts +2 -2
- package/dist/index.d.ts +18 -4
- package/dist/index.js +7 -1
- package/dist/{skills-CO7vBqHz.d.ts → skills-CTzgfoff.d.ts} +16 -1
- package/package.json +1 -1
- package/dist/chunk-FRNNQVHX.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExecutionContext } from '@theokit/http';
|
|
2
|
-
import { A as AgentOptions, T as ToolOptions, g as MainLoopMeta, a as ApprovalOptions, B as BudgetOptions, f as GatewayOptions, l as MemoryOptions,
|
|
3
|
-
import { SystemPromptResolver, SkillsSettings, ContextSettings, PluginsSettings, Plugin, ProviderRoutingSettings, AgentDefinition, BudgetTracker, ConversationStorageAdapter, CustomTool } from '@theokit/sdk';
|
|
2
|
+
import { A as AgentOptions, T as ToolOptions, g as MainLoopMeta, a as ApprovalOptions, B as BudgetOptions, f as GatewayOptions, l as MemoryOptions, t as SkillsOptions, e as ContextWindowOptions, q as ProjectContextOptions, j as McpServersMap, b as CompactionDecoratorConfig, R as ReasoningEffort } from './skills-CTzgfoff.js';
|
|
3
|
+
import { SystemPromptResolver, SkillsSettings, ContextSettings, PluginsSettings, Plugin, ProviderRoutingSettings, AgentDefinition, BudgetTracker, ConversationStorageAdapter, CustomTool, ModelSelection } from '@theokit/sdk';
|
|
4
4
|
import { RetryOptions } from '@theokit/sdk/retry';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
|
|
@@ -134,6 +134,10 @@ interface CompiledSubAgent {
|
|
|
134
134
|
/** Compiled agent options ready for SDK Agent.create(). */
|
|
135
135
|
interface CompiledAgentOptions {
|
|
136
136
|
model?: string;
|
|
137
|
+
/** Extended-thinking effort declared via `@Agent({ reasoningEffort })`; mapped to SDK ModelSelection.params. */
|
|
138
|
+
reasoningEffort?: ReasoningEffort;
|
|
139
|
+
/** Opt-in `<think>`-tag extraction declared via `@Agent({ parseThinkTags })` (M2); wraps the stream when true. */
|
|
140
|
+
parseThinkTags?: boolean;
|
|
137
141
|
/** Static prompt OR a per-request {@link SystemPromptResolver} (V4-L.1, Axis-B). */
|
|
138
142
|
systemPrompt?: string | SystemPromptResolver;
|
|
139
143
|
tools: CompiledTool[];
|
|
@@ -413,6 +417,16 @@ declare function generateAgentRoutes(ctx: AgentRouteContext): AgentRoute[];
|
|
|
413
417
|
interface RuntimeOverrides {
|
|
414
418
|
/** Overrides the model for this call (`?? compiled.model ?? default`). */
|
|
415
419
|
model?: string;
|
|
420
|
+
/**
|
|
421
|
+
* Per-run extended-thinking effort (`?? compiled.reasoningEffort`). Mapped to the SDK
|
|
422
|
+
* `ModelSelection.params` so the provider produces reasoning (surfaced as `thinking` StreamEvents).
|
|
423
|
+
*/
|
|
424
|
+
reasoningEffort?: ReasoningEffort;
|
|
425
|
+
/**
|
|
426
|
+
* Per-run opt-in (`?? compiled.parseThinkTags`): when true, wrap the event stream with the M2
|
|
427
|
+
* `<think>`-tag extractor so inline `<think>…</think>` text becomes `thinking` StreamEvents.
|
|
428
|
+
*/
|
|
429
|
+
parseThinkTags?: boolean;
|
|
416
430
|
/** Per-run cwd → `Agent.create({ local: { cwd } })` → `SystemPromptContext.cwd`. */
|
|
417
431
|
cwd?: string;
|
|
418
432
|
/**
|
|
@@ -449,6 +463,70 @@ interface RuntimeOverrides {
|
|
|
449
463
|
*/
|
|
450
464
|
declare function createSdkAgentStream(compiled: CompiledAgentOptions, compiledTools: CompiledTool[], apiKey: string, overrides?: RuntimeOverrides): (message: string, sessionId: string) => AsyncIterable<StreamEvent>;
|
|
451
465
|
|
|
466
|
+
/**
|
|
467
|
+
* Model-selection mapping (M1 reasoning-visibility) — the single site that turns a
|
|
468
|
+
* provider-agnostic `ReasoningEffort` into the SDK `ModelSelection`. Kept in its own small module
|
|
469
|
+
* (not inside `sdk-adapter.ts`) so the adapter stays under the G6 500-LoC budget and the helper has
|
|
470
|
+
* a focused home (per the plan's T1.1 "or a small sibling").
|
|
471
|
+
*/
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Build the SDK `ModelSelection` for a model id + optional reasoning effort. With no (or empty)
|
|
475
|
+
* effort it returns the bare `{ id }` — byte-identical to the prior behavior (backward-compat). With
|
|
476
|
+
* an effort it adds the canonical reasoning param `{ id: 'thinking', value: effort }`. Pure.
|
|
477
|
+
*/
|
|
478
|
+
declare function buildModelSelection(modelId: string, effort?: ReasoningEffort): ModelSelection;
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* `<think>`-tag reasoning extractor (M2 reasoning-visibility) — bridge middleware.
|
|
482
|
+
*
|
|
483
|
+
* Converts inline `<think>…</think>` in the assistant TEXT stream into `thinking` segments, so
|
|
484
|
+
* models that emit reasoning as inline tags (qwen3-coder / deepseek-class) surface reasoning the
|
|
485
|
+
* same way native-reasoning providers do (M1's `reasoningEffort`). Two exports:
|
|
486
|
+
* - `createThinkTagExtractor` — the pure incremental splitter (handles a tag straddling a chunk
|
|
487
|
+
* boundary); the testable core.
|
|
488
|
+
* - `extractThinkTagStream` — a StreamEvent transform that applies the extractor to `text_delta`
|
|
489
|
+
* events and passes every other event through unchanged (Phase 2).
|
|
490
|
+
*
|
|
491
|
+
* Opt-in: wired into `createSdkAgentStream` only when `parseThinkTags` is set (Phase 3) — default
|
|
492
|
+
* off, because a code assistant can legitimately emit literal `<think>` in answer/code text.
|
|
493
|
+
*
|
|
494
|
+
* Reference patterns: Aider `reasoning_tags.py`, Vercel AI SDK `extract-reasoning-middleware.ts`
|
|
495
|
+
* (blueprint `code-assistant-reasoning-ux` ADR-3).
|
|
496
|
+
*/
|
|
497
|
+
|
|
498
|
+
/** A typed slice of the text stream: ordinary `text` vs extracted `thinking`. */
|
|
499
|
+
interface Segment {
|
|
500
|
+
kind: 'text' | 'thinking';
|
|
501
|
+
content: string;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* A pure, stateful, incremental `<think>` splitter. Feed it text chunks via `write`; it returns the
|
|
505
|
+
* segments it can resolve so far, holding back only a tail that is still a viable prefix of the
|
|
506
|
+
* active delimiter (so a tag split across two chunks is recognized). Call `end()` once the stream
|
|
507
|
+
* is done to flush any buffered tail (a truncated `<think>` with no close is flushed as `thinking`,
|
|
508
|
+
* so reasoning is never silently dropped).
|
|
509
|
+
*
|
|
510
|
+
* One instance per stream (per round); never shared — there is no cross-instance state.
|
|
511
|
+
*/
|
|
512
|
+
declare function createThinkTagExtractor(): {
|
|
513
|
+
write: (chunk: string) => Segment[];
|
|
514
|
+
end: () => Segment[];
|
|
515
|
+
};
|
|
516
|
+
/**
|
|
517
|
+
* Stream transform: convert inline `<think>…</think>` carried in `text_delta` events into `thinking`
|
|
518
|
+
* events, passing every other event (native `thinking`, `tool_call`, `done`, `error`, …) through
|
|
519
|
+
* unchanged. A fresh extractor per call ⇒ per-stream (per-round) state; the extractor's mode persists
|
|
520
|
+
* across interleaved non-text events (a reasoning block split by a tool call is not corrupted). On
|
|
521
|
+
* source end, the extractor is flushed so a truncated `<think>` is still surfaced (as `thinking`).
|
|
522
|
+
*
|
|
523
|
+
* Non-string `text_delta.content` is passed through untouched (defensive — never throws). The
|
|
524
|
+
* `end()` flush runs in a `finally`, so a buffered unclosed `<think>` is surfaced as `thinking`
|
|
525
|
+
* even when the source errors mid-stream (the flushed segments are delivered before the error
|
|
526
|
+
* re-propagates) — never silently dropped (Unbreakable Rule 8: fail loud, lose nothing).
|
|
527
|
+
*/
|
|
528
|
+
declare function extractThinkTagStream(source: AsyncIterable<StreamEvent>): AsyncGenerator<StreamEvent>;
|
|
529
|
+
|
|
452
530
|
/**
|
|
453
531
|
* Translates @theokit/sdk SDKMessage events → TheoKit AgentStreamEvent.
|
|
454
532
|
*
|
|
@@ -798,4 +876,4 @@ declare function agentsPlugin(opts: AgentsPluginOptions): {
|
|
|
798
876
|
register(app: PluginApp): void;
|
|
799
877
|
};
|
|
800
878
|
|
|
801
|
-
export {
|
|
879
|
+
export { createAgentExecutionContext as $, type AgentExecutionContext as A, BudgetExceededError as B, type CompiledAgentOptions as C, type DelegationResult as D, type ErrorEvent as E, type FileEditEvent as F, type RunStartedEvent as G, type SdkMessage as H, type IterationEvent as I, type Segment as J, type StateUpdateEvent as K, type LoopStrategy as L, type ThinkingEvent as M, type ToolCallEvent as N, type ToolResultEvent as O, type ToolWalkResult as P, type ToolboxWalkResult as Q, type ReflectionStrategy as R, type StreamEvent as S, type TextDeltaEvent as T, agentsPlugin as U, buildModelSelection as V, compileAgent as W, compileContextWindow as X, compileProjectContext as Y, compileSkills as Z, compileTools as _, type CompiledTool as a, createSdkAgentStream as a0, createThinkTagExtractor as a1, delegate as a2, extractThinkTagStream as a3, generateAgentManifest as a4, generateAgentRoutes as a5, isAgentContext as a6, isApprovalRequired as a7, isDone as a8, isError as a9, isTextDelta as aa, isToolCall as ab, isToolResult as ac, ladderReflectionStrategy as ad, loopStrategyConfigSchema as ae, noopReflectionStrategy as af, projectContextMetadataOnlyKnobs as ag, reflectionStrategyConfigSchema as ah, resolveLoopStrategy as ai, streamAgentResponse as aj, translateSdkEvent as ak, validateUniqueRoutes as al, walkAgentMetadata as am, type AgentManifest as b, type AgentManifestEntry as c, type AgentManifestTool as d, type AgentRoute as e, type AgentRouteContext as f, type AgentRunInfo as g, type AgentStreamEvent as h, type AgentWalkResult as i, AgentWarningCode as j, type AgentsPluginOptions as k, type ApprovalRequiredEvent as l, type ArtifactChunkEvent as m, type ArtifactStartEvent as n, type CheckpointSavedEvent as o, type CompiledContextWindow as p, DEFAULT_MAX_ITERATIONS as q, type DelegateOptions as r, DelegationError as s, type DoneEvent as t, type LoopFinishReason as u, type LoopOutcome as v, type LoopStrategyConfig as w, type ReflectionContext as x, type ReflectionResult as y, type ReflectionStrategyConfig as z };
|
package/dist/bridge.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { A as AgentExecutionContext, b as AgentManifest, c as AgentManifestEntry, d as AgentManifestTool, e as AgentRoute, f as AgentRouteContext, g as AgentRunInfo, h as AgentStreamEvent, i as AgentWalkResult, j as AgentWarningCode, k as AgentsPluginOptions, l as ApprovalRequiredEvent, m as ArtifactChunkEvent, n as ArtifactStartEvent, B as BudgetExceededError, o as CheckpointSavedEvent, C as CompiledAgentOptions, p as CompiledContextWindow, a as CompiledTool, r as DelegateOptions, s as DelegationError, D as DelegationResult, t as DoneEvent, E as ErrorEvent, F as FileEditEvent, I as IterationEvent, G as RunStartedEvent, H as SdkMessage, J as StateUpdateEvent, S as StreamEvent, T as TextDeltaEvent,
|
|
1
|
+
export { A as AgentExecutionContext, b as AgentManifest, c as AgentManifestEntry, d as AgentManifestTool, e as AgentRoute, f as AgentRouteContext, g as AgentRunInfo, h as AgentStreamEvent, i as AgentWalkResult, j as AgentWarningCode, k as AgentsPluginOptions, l as ApprovalRequiredEvent, m as ArtifactChunkEvent, n as ArtifactStartEvent, B as BudgetExceededError, o as CheckpointSavedEvent, C as CompiledAgentOptions, p as CompiledContextWindow, a as CompiledTool, r as DelegateOptions, s as DelegationError, D as DelegationResult, t as DoneEvent, E as ErrorEvent, F as FileEditEvent, I as IterationEvent, G as RunStartedEvent, H as SdkMessage, J as Segment, K as StateUpdateEvent, S as StreamEvent, T as TextDeltaEvent, M as ThinkingEvent, N as ToolCallEvent, O as ToolResultEvent, P as ToolWalkResult, Q as ToolboxWalkResult, U as agentsPlugin, V as buildModelSelection, W as compileAgent, X as compileContextWindow, Y as compileProjectContext, Z as compileSkills, _ as compileTools, $ as createAgentExecutionContext, a0 as createSdkAgentStream, a1 as createThinkTagExtractor, a2 as delegate, a3 as extractThinkTagStream, a4 as generateAgentManifest, a5 as generateAgentRoutes, a6 as isAgentContext, a7 as isApprovalRequired, a8 as isDone, a9 as isError, aa as isTextDelta, ab as isToolCall, ac as isToolResult, ag as projectContextMetadataOnlyKnobs, aj as streamAgentResponse, ak as translateSdkEvent, al as validateUniqueRoutes, am as walkAgentMetadata } from './bridge-entry-DlW7p2I4.js';
|
|
2
2
|
import '@theokit/http';
|
|
3
|
-
import './skills-
|
|
3
|
+
import './skills-CTzgfoff.js';
|
|
4
4
|
import '@theokit/sdk';
|
|
5
5
|
import 'zod';
|
|
6
6
|
import '@theokit/sdk/retry';
|
package/dist/bridge.js
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
BudgetExceededError,
|
|
4
4
|
DelegationError,
|
|
5
5
|
agentsPlugin,
|
|
6
|
+
buildModelSelection,
|
|
6
7
|
compileAgent,
|
|
7
8
|
compileContextWindow,
|
|
8
9
|
compileProjectContext,
|
|
@@ -10,7 +11,9 @@ import {
|
|
|
10
11
|
compileTools,
|
|
11
12
|
createAgentExecutionContext,
|
|
12
13
|
createSdkAgentStream,
|
|
14
|
+
createThinkTagExtractor,
|
|
13
15
|
delegate,
|
|
16
|
+
extractThinkTagStream,
|
|
14
17
|
generateAgentManifest,
|
|
15
18
|
generateAgentRoutes,
|
|
16
19
|
isAgentContext,
|
|
@@ -25,7 +28,7 @@ import {
|
|
|
25
28
|
translateSdkEvent,
|
|
26
29
|
validateUniqueRoutes,
|
|
27
30
|
walkAgentMetadata
|
|
28
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-ZTVXZIBZ.js";
|
|
29
32
|
import "./chunk-GVPUUKKE.js";
|
|
30
33
|
import "./chunk-7QVYU63E.js";
|
|
31
34
|
export {
|
|
@@ -33,6 +36,7 @@ export {
|
|
|
33
36
|
BudgetExceededError,
|
|
34
37
|
DelegationError,
|
|
35
38
|
agentsPlugin,
|
|
39
|
+
buildModelSelection,
|
|
36
40
|
compileAgent,
|
|
37
41
|
compileContextWindow,
|
|
38
42
|
compileProjectContext,
|
|
@@ -40,7 +44,9 @@ export {
|
|
|
40
44
|
compileTools,
|
|
41
45
|
createAgentExecutionContext,
|
|
42
46
|
createSdkAgentStream,
|
|
47
|
+
createThinkTagExtractor,
|
|
43
48
|
delegate,
|
|
49
|
+
extractThinkTagStream,
|
|
44
50
|
generateAgentManifest,
|
|
45
51
|
generateAgentRoutes,
|
|
46
52
|
isAgentContext,
|
|
@@ -300,6 +300,8 @@ function compileAgent(walkResult, toolboxInstances = /* @__PURE__ */ new Map())
|
|
|
300
300
|
const agents = compileSubAgents(walkResult.subAgentClasses);
|
|
301
301
|
return {
|
|
302
302
|
model: walkResult.agentConfig.model,
|
|
303
|
+
reasoningEffort: walkResult.agentConfig.reasoningEffort,
|
|
304
|
+
parseThinkTags: walkResult.agentConfig.parseThinkTags,
|
|
303
305
|
systemPrompt: walkResult.agentConfig.systemPrompt,
|
|
304
306
|
tools,
|
|
305
307
|
agents,
|
|
@@ -649,6 +651,108 @@ function translateInteractionUpdate(update) {
|
|
|
649
651
|
}
|
|
650
652
|
__name(translateInteractionUpdate, "translateInteractionUpdate");
|
|
651
653
|
|
|
654
|
+
// src/bridge/model-selection.ts
|
|
655
|
+
function buildModelSelection(modelId, effort) {
|
|
656
|
+
if (!effort) return {
|
|
657
|
+
id: modelId
|
|
658
|
+
};
|
|
659
|
+
return {
|
|
660
|
+
id: modelId,
|
|
661
|
+
params: [
|
|
662
|
+
{
|
|
663
|
+
id: "thinking",
|
|
664
|
+
value: effort
|
|
665
|
+
}
|
|
666
|
+
]
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
__name(buildModelSelection, "buildModelSelection");
|
|
670
|
+
|
|
671
|
+
// src/bridge/think-tag-extractor.ts
|
|
672
|
+
var TAG = "think";
|
|
673
|
+
var OPEN = `<${TAG}>`;
|
|
674
|
+
var CLOSE = `</${TAG}>`;
|
|
675
|
+
function heldPrefixLength(s, delim) {
|
|
676
|
+
const max = Math.min(s.length, delim.length - 1);
|
|
677
|
+
for (let k = max; k >= 1; k--) {
|
|
678
|
+
if (s.slice(s.length - k) === delim.slice(0, k)) return k;
|
|
679
|
+
}
|
|
680
|
+
return 0;
|
|
681
|
+
}
|
|
682
|
+
__name(heldPrefixLength, "heldPrefixLength");
|
|
683
|
+
function createThinkTagExtractor() {
|
|
684
|
+
let mode = "text";
|
|
685
|
+
let buffer = "";
|
|
686
|
+
const write = /* @__PURE__ */ __name((chunk) => {
|
|
687
|
+
buffer += chunk;
|
|
688
|
+
const out = [];
|
|
689
|
+
for (; ; ) {
|
|
690
|
+
const delim = mode === "text" ? OPEN : CLOSE;
|
|
691
|
+
const idx = buffer.indexOf(delim);
|
|
692
|
+
if (idx !== -1) {
|
|
693
|
+
const content = buffer.slice(0, idx);
|
|
694
|
+
if (content) out.push({
|
|
695
|
+
kind: mode,
|
|
696
|
+
content
|
|
697
|
+
});
|
|
698
|
+
buffer = buffer.slice(idx + delim.length);
|
|
699
|
+
mode = mode === "text" ? "thinking" : "text";
|
|
700
|
+
continue;
|
|
701
|
+
}
|
|
702
|
+
const keep = heldPrefixLength(buffer, delim);
|
|
703
|
+
const emit = buffer.slice(0, buffer.length - keep);
|
|
704
|
+
if (emit) out.push({
|
|
705
|
+
kind: mode,
|
|
706
|
+
content: emit
|
|
707
|
+
});
|
|
708
|
+
buffer = buffer.slice(buffer.length - keep);
|
|
709
|
+
break;
|
|
710
|
+
}
|
|
711
|
+
return out;
|
|
712
|
+
}, "write");
|
|
713
|
+
const end = /* @__PURE__ */ __name(() => {
|
|
714
|
+
if (!buffer) return [];
|
|
715
|
+
const seg = {
|
|
716
|
+
kind: mode,
|
|
717
|
+
content: buffer
|
|
718
|
+
};
|
|
719
|
+
buffer = "";
|
|
720
|
+
return [
|
|
721
|
+
seg
|
|
722
|
+
];
|
|
723
|
+
}, "end");
|
|
724
|
+
return {
|
|
725
|
+
write,
|
|
726
|
+
end
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
__name(createThinkTagExtractor, "createThinkTagExtractor");
|
|
730
|
+
function segmentToEvent(seg) {
|
|
731
|
+
return seg.kind === "thinking" ? {
|
|
732
|
+
type: "thinking",
|
|
733
|
+
content: seg.content
|
|
734
|
+
} : {
|
|
735
|
+
type: "text_delta",
|
|
736
|
+
content: seg.content
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
__name(segmentToEvent, "segmentToEvent");
|
|
740
|
+
async function* extractThinkTagStream(source) {
|
|
741
|
+
const extractor = createThinkTagExtractor();
|
|
742
|
+
try {
|
|
743
|
+
for await (const event of source) {
|
|
744
|
+
if (event.type === "text_delta" && typeof event.content === "string") {
|
|
745
|
+
for (const seg of extractor.write(event.content)) yield segmentToEvent(seg);
|
|
746
|
+
} else {
|
|
747
|
+
yield event;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
} finally {
|
|
751
|
+
for (const seg of extractor.end()) yield segmentToEvent(seg);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
__name(extractThinkTagStream, "extractThinkTagStream");
|
|
755
|
+
|
|
652
756
|
// src/bridge/sdk-adapter.ts
|
|
653
757
|
function assembleM8CreateOptions(compiled) {
|
|
654
758
|
const options = {};
|
|
@@ -828,6 +932,8 @@ function createDeltaSink(queue) {
|
|
|
828
932
|
__name(createDeltaSink, "createDeltaSink");
|
|
829
933
|
function createSdkAgentStream(compiled, compiledTools, apiKey, overrides = {}) {
|
|
830
934
|
const model = overrides.model ?? compiled.model ?? "openai/gpt-4o-mini";
|
|
935
|
+
const reasoningEffort = overrides.reasoningEffort ?? compiled.reasoningEffort;
|
|
936
|
+
const parseThinkTags = overrides.parseThinkTags ?? compiled.parseThinkTags ?? false;
|
|
831
937
|
let storage = overrides.conversationStorage;
|
|
832
938
|
return (message, sessionId) => ({
|
|
833
939
|
async *[Symbol.asyncIterator]() {
|
|
@@ -877,9 +983,7 @@ function createSdkAgentStream(compiled, compiledTools, apiKey, overrides = {}) {
|
|
|
877
983
|
}
|
|
878
984
|
agent = await Agent.getOrCreate(sessionId, {
|
|
879
985
|
apiKey,
|
|
880
|
-
model:
|
|
881
|
-
id: model
|
|
882
|
-
},
|
|
986
|
+
model: buildModelSelection(model, reasoningEffort),
|
|
883
987
|
tools: sdkTools,
|
|
884
988
|
...m8,
|
|
885
989
|
...extra,
|
|
@@ -891,7 +995,9 @@ function createSdkAgentStream(compiled, compiledTools, apiKey, overrides = {}) {
|
|
|
891
995
|
onDelta
|
|
892
996
|
});
|
|
893
997
|
const openStream = /* @__PURE__ */ __name(async () => (await sendPromise).stream(), "openStream");
|
|
894
|
-
|
|
998
|
+
const merged = mergeDeltaStream(queue, openStream, runId, state);
|
|
999
|
+
const events = parseThinkTags ? extractThinkTagStream(merged) : merged;
|
|
1000
|
+
for await (const event of events) {
|
|
895
1001
|
yield event;
|
|
896
1002
|
}
|
|
897
1003
|
if (!state.sawError) {
|
|
@@ -1334,6 +1440,8 @@ var AgentRunner = class {
|
|
|
1334
1440
|
const loop = opts.maxIterations != null ? resolveLoopStrategy(this.loopStrategy.name, opts.maxIterations) : this.loopStrategy;
|
|
1335
1441
|
const streamFactory = opts.streamFactory ?? createSdkAgentStream(this.compiled, tools, opts.apiKey, {
|
|
1336
1442
|
model: opts.model,
|
|
1443
|
+
reasoningEffort: opts.reasoningEffort,
|
|
1444
|
+
parseThinkTags: opts.parseThinkTags,
|
|
1337
1445
|
cwd: opts.cwd,
|
|
1338
1446
|
plugins: opts.plugins,
|
|
1339
1447
|
providers: opts.providers,
|
|
@@ -1615,6 +1723,9 @@ export {
|
|
|
1615
1723
|
isApprovalRequired,
|
|
1616
1724
|
generateAgentRoutes,
|
|
1617
1725
|
translateSdkEvent,
|
|
1726
|
+
buildModelSelection,
|
|
1727
|
+
createThinkTagExtractor,
|
|
1728
|
+
extractThinkTagStream,
|
|
1618
1729
|
createSdkAgentStream,
|
|
1619
1730
|
DEFAULT_KEEP_TOKENS,
|
|
1620
1731
|
compactionStrategyConfigSchema,
|
|
@@ -1634,4 +1745,4 @@ export {
|
|
|
1634
1745
|
generateAgentManifest,
|
|
1635
1746
|
agentsPlugin
|
|
1636
1747
|
};
|
|
1637
|
-
//# sourceMappingURL=chunk-
|
|
1748
|
+
//# sourceMappingURL=chunk-ZTVXZIBZ.js.map
|