@dudousxd/nestjs-agent-core 0.16.0 → 0.18.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 +2 -0
- package/dist/guardrails/index.d.cts +1 -1
- package/dist/guardrails/index.d.ts +1 -1
- package/dist/index.cjs +124 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -102
- package/dist/index.d.ts +41 -102
- package/dist/index.js +122 -5
- package/dist/index.js.map +1 -1
- package/dist/{tool-CL9oEytW.d.cts → tool-CHIw-aTx.d.cts} +202 -1
- package/dist/{tool-CL9oEytW.d.ts → tool-CHIw-aTx.d.ts} +202 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as ModelMessage, a as ToolDefinition, b as ToolCallRequest, c as MessageUsage,
|
|
2
|
-
export {
|
|
1
|
+
import { M as ModelMessage, a as ToolDefinition, b as ToolCallRequest, c as MessageUsage, d as AgentUiComponent, A as Actor, e as ThreadSummary, f as ThreadDetail, S as StoredMessage, g as ToolResult, h as MessageAttachment, i as ToolCallStatus, U as UsagePurpose, j as ToolSpec, Q as QuotaState, k as AgentRunInput, H as HumanReply, T as ToolHandler, l as HistoryPolicy, O as OutputProcessor, P as ProcessorContext, I as InputProcessor, m as ProcessedPrompt, n as ModelAnswer, o as PageContext, p as AgentDefinition, q as AgentDelegation, D as DetachedDelivery, r as AiToolCtx, s as PromptBuilder, t as PromptContributor, u as ToolTransientRetrySetting, v as AgentIntake, w as Decision, E as ElicitationRequest, L as LlmStepEnvelope, x as ToolStepEnvelope } from './tool-CHIw-aTx.cjs';
|
|
2
|
+
export { y as ASK_TOOL_DESCRIPTION, z as ASK_TOOL_NAME, B as AgentApprovalRequest, C as AgentCatalogEntry, F as AgentHistoryWindow, G as AgentStreamEvent, J as AskToolInput, K as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, N as DEFAULT_INTAKE_PREAMBLE, R as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, V as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, W as ElicitationOption, X as ElicitationOutcome, Y as ElicitationQuestion, Z as ElicitationReply, _ as ElicitationResult, $ as HistoryPolicyContext, a0 as HistorySelection, a1 as HistorySummary, a2 as IncrementalGating, a3 as InvokeWithTransientRetryOptions, a4 as MAX_ASK_QUESTIONS, a5 as MessageRole, a6 as OutputRejectedError, a7 as OutputVerdict, a8 as ProcessorFailedError, a9 as PromptContext, aa as QuotaView, ab as ToolKind, ac as ToolStepCtx, ad as ToolTransientRetryNumbers, ae as ToolTransientRetryOptions, af as askInputSchema, ag as askToolDefinition, ah as decodeStreamEvent, ai as encodeStreamEvent, aj as invokeWithTransientRetry, ak as isTransientToolError, al as normalizeElicitationReply, am as renderElicitationAnswers, an as resolveElicitation, ao as resolveToolTransientRetryNumbers, ap as settleElicitation } from './tool-CHIw-aTx.cjs';
|
|
3
3
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
4
4
|
import { ChannelRegistry } from '@dudousxd/nestjs-diagnostics';
|
|
5
5
|
|
|
@@ -160,6 +160,16 @@ interface ModelTurnResult {
|
|
|
160
160
|
* the JSON out of `text`) is always correct.
|
|
161
161
|
*/
|
|
162
162
|
object?: unknown;
|
|
163
|
+
/**
|
|
164
|
+
* The model's thinking this turn, as streamed. Optional: the loop derives it from the `reasoning`
|
|
165
|
+
* frames the provider wrote to the sink (see `observeTurnFrames`), so a provider only sets it to
|
|
166
|
+
* override that — e.g. one that receives reasoning it does not stream.
|
|
167
|
+
*/
|
|
168
|
+
reasoning?: string;
|
|
169
|
+
/** Time spent thinking this turn, in ms. Derived like {@link reasoning} when omitted. */
|
|
170
|
+
reasoningMs?: number;
|
|
171
|
+
/** Components pushed during this turn (`ui` frames). Derived like {@link reasoning} when omitted. */
|
|
172
|
+
ui?: AgentUiComponent[];
|
|
163
173
|
}
|
|
164
174
|
/**
|
|
165
175
|
* A model turn whose live frames were HELD instead of streamed, because an output processor has to
|
|
@@ -201,110 +211,33 @@ interface ModelProvider {
|
|
|
201
211
|
runTurn(args: ModelTurnArgs): Promise<ModelTurnResult>;
|
|
202
212
|
}
|
|
203
213
|
|
|
204
|
-
/**
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
* the adapter owns model-parts → event, the transport owns event → UI-chunk.
|
|
216
|
-
*/
|
|
217
|
-
|
|
218
|
-
type AgentStreamEvent = {
|
|
219
|
-
kind: 'step-start';
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Closes the step opened by the matching `step-start`. Carries the model call's token usage and
|
|
223
|
-
* `costUsd` (an estimate from the bound pricing store, or `null` when unpriced/unbound — never a
|
|
224
|
-
* fabricated `0`) so a live client can render running cost without waiting for a thread re-fetch.
|
|
225
|
-
*/
|
|
226
|
-
| {
|
|
227
|
-
kind: 'step-finish';
|
|
228
|
-
usage?: MessageUsage;
|
|
229
|
-
costUsd?: number | null;
|
|
230
|
-
} | {
|
|
231
|
-
kind: 'text';
|
|
232
|
-
text: string;
|
|
233
|
-
} | {
|
|
234
|
-
kind: 'reasoning';
|
|
235
|
-
text: string;
|
|
236
|
-
}
|
|
237
|
-
/** `toolKind` collapses `ToolKind`'s `'agent'` into `'read'` — delegation tools auto-execute like a read tool. */
|
|
238
|
-
| {
|
|
239
|
-
kind: 'tool-input-start';
|
|
240
|
-
id: string;
|
|
241
|
-
name: string;
|
|
242
|
-
toolKind: 'read' | 'action';
|
|
243
|
-
} | {
|
|
244
|
-
kind: 'tool-input-delta';
|
|
245
|
-
id: string;
|
|
246
|
-
delta: string;
|
|
247
|
-
} | {
|
|
248
|
-
kind: 'tool-input-available';
|
|
249
|
-
id: string;
|
|
250
|
-
name: string;
|
|
251
|
-
input: unknown;
|
|
252
|
-
toolKind: 'read' | 'action';
|
|
253
|
-
} | {
|
|
254
|
-
kind: 'tool-output';
|
|
255
|
-
id: string;
|
|
256
|
-
output: unknown;
|
|
257
|
-
} | {
|
|
258
|
-
kind: 'tool-output-error';
|
|
259
|
-
id: string;
|
|
260
|
-
error: string;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* A person was asked to approve an action tool and declined it. Its own frame, NOT
|
|
264
|
-
* `tool-output-error`: a refusal is a decision with a known outcome — nothing ran — while a
|
|
265
|
-
* failure is an outcome nobody chose and whose effects are unknown. Rendering them the same way
|
|
266
|
-
* tells an operator their own "no" was a malfunction. Maps onto the SDK's `output-denied` tool
|
|
267
|
-
* part state, which a client reads without knowing any tool's name.
|
|
268
|
-
*/
|
|
269
|
-
| {
|
|
270
|
-
kind: 'tool-output-denied';
|
|
271
|
-
id: string;
|
|
272
|
-
reason?: string;
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* The run has put a question set to the user and is parked until someone answers it (or skips).
|
|
276
|
-
* Written by the LOOP for both elicitation surfaces — the configured intake and the model's `ask`
|
|
277
|
-
* tool — so a client renders one form either way rather than learning to recognise a tool name.
|
|
278
|
-
* The matching `tool-output` frame, under the same `id`, carries the settled answers.
|
|
279
|
-
*/
|
|
280
|
-
| {
|
|
281
|
-
kind: 'elicitation';
|
|
282
|
-
id: string;
|
|
283
|
-
request: ElicitationRequest;
|
|
214
|
+
/** What a model turn streamed that the persisted message keeps, beyond its text and tool calls. */
|
|
215
|
+
interface TurnFrameSummary {
|
|
216
|
+
reasoning?: string;
|
|
217
|
+
reasoningMs?: number;
|
|
218
|
+
ui?: AgentUiComponent[];
|
|
219
|
+
}
|
|
220
|
+
interface ObservedTurnFrames {
|
|
221
|
+
/** Hand THIS to the provider: every write passes through to the wrapped writer unchanged. */
|
|
222
|
+
writer: SinkWriter;
|
|
223
|
+
/** What was seen so far. Closes an open thinking burst at the moment it is called. */
|
|
224
|
+
summary(): TurnFrameSummary;
|
|
284
225
|
}
|
|
285
226
|
/**
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
* error and a client that retries on a failed stream must not retry this.
|
|
227
|
+
* Watch the frames a model turn writes, to learn what the stream showed that the provider's result
|
|
228
|
+
* does not carry: the model's thinking (text and how long it took) and any pushed UI components.
|
|
289
229
|
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
|
|
294
|
-
| {
|
|
295
|
-
kind: 'cancelled';
|
|
296
|
-
};
|
|
297
|
-
/** Encode one event as an NDJSON line (`{...}\n`) for {@link SinkWriter.write}. */
|
|
298
|
-
declare function encodeStreamEvent(event: AgentStreamEvent): Uint8Array;
|
|
299
|
-
/**
|
|
300
|
-
* Read one NDJSON line back, or `null` when the line is not a stream event at all.
|
|
230
|
+
* Derived from the FRAMES rather than asked of each provider, so every provider that streams the
|
|
231
|
+
* vocabulary gets reasoning persisted without implementing anything. Thinking time is the sum of
|
|
232
|
+
* each burst of consecutive `reasoning` frames — from the first one to the next frame that is not
|
|
233
|
+
* reasoning (or the end of the turn) — which is what a reader watched as "thinking".
|
|
301
234
|
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
* CLASSIFY a chunk — the output gate, which may only forward what it can prove is not the answer —
|
|
305
|
-
* treats an unreadable frame as unclassifiable rather than guessing.
|
|
235
|
+
* Call it inside the step that runs the model, so the summary rides that step's journaled result
|
|
236
|
+
* and a replay reads the same numbers back instead of re-measuring a turn that is not happening.
|
|
306
237
|
*/
|
|
307
|
-
declare function
|
|
238
|
+
declare function observeTurnFrames(writer: SinkWriter, now?: () => number): ObservedTurnFrames;
|
|
239
|
+
/** Fill what a provider did not report from what its frames showed. A provider's own value wins. */
|
|
240
|
+
declare function withTurnFrames<T extends ModelTurnResult>(result: T, frames: TurnFrameSummary): T;
|
|
308
241
|
|
|
309
242
|
interface CreateThreadInput {
|
|
310
243
|
actor: Actor;
|
|
@@ -331,6 +264,12 @@ interface AppendMessageInput {
|
|
|
331
264
|
* run) can omit it; the store persists it as `null` when absent.
|
|
332
265
|
*/
|
|
333
266
|
runId?: string;
|
|
267
|
+
/** The step's streamed thinking. See {@link StoredMessage.reasoning}. */
|
|
268
|
+
reasoning?: string;
|
|
269
|
+
/** Time spent thinking in this step, in ms. See {@link StoredMessage.reasoningMs}. */
|
|
270
|
+
reasoningMs?: number;
|
|
271
|
+
/** Components pushed during this step. See {@link StoredMessage.ui}. */
|
|
272
|
+
ui?: AgentUiComponent[];
|
|
334
273
|
}
|
|
335
274
|
interface RecordToolCallInput {
|
|
336
275
|
toolCallId: string;
|
|
@@ -3202,4 +3141,4 @@ type AgentDiagnosticKey = `agent:${AgentDiagnosticEvent}`;
|
|
|
3202
3141
|
*/
|
|
3203
3142
|
declare function agentDiagnosticKey(event: AgentDiagnosticEvent): AgentDiagnosticKey;
|
|
3204
3143
|
|
|
3205
|
-
export { AGENT_ACTOR_DIRECTORY, AGENT_ACTOR_RESOLVER, AGENT_APPROVAL_PORT, AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY, AGENT_DIAGNOSTIC_EVENTS, AGENT_DURABLE_RUNNER, AGENT_EMBEDDING_PROVIDER, AGENT_GOVERNANCE_QUERIES, AGENT_MEMORY, AGENT_MODEL, AGENT_OPTIONS, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_QUOTA_STORE, AGENT_REGISTRY, AGENT_RETRIEVER, AGENT_ROLES_POLICY, AGENT_RUNNER, AGENT_SINK, AGENT_SKILLS, AGENT_SKILL_SOURCES, AGENT_SPAN_EVENTS, AGENT_STORE, AGENT_TOOL_REGISTRY, Actor, type ActorDirectory, type ActorResolver, type ActorSpendRow, type AgentApprovalPort, AgentDefinition, type AgentDelegated, AgentDelegation, type AgentDiagnosticEvent, type AgentDiagnosticKey, type AgentFollowUpsSpan, type AgentGovernanceQueries, AgentIntake, type AgentLlmTurnSpan, type AgentLoopDeps, type AgentLoopHooks, type AgentLoopResult, type AgentMemoryResolved, type AgentMemoryWritten, type AgentMessageEvent, type AgentPricingStore, type AgentQuotaExceeded, AgentRegistry, type AgentRetrievalSpan, type AgentRetrieved, type AgentRunFailed, type AgentRunFinished, AgentRunInput, type AgentRunStarted, type AgentRunner, type AgentSkillsResolved, type AgentSpanEvent, type AgentStore, AgentStreamError, type
|
|
3144
|
+
export { AGENT_ACTOR_DIRECTORY, AGENT_ACTOR_RESOLVER, AGENT_APPROVAL_PORT, AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY, AGENT_DIAGNOSTIC_EVENTS, AGENT_DURABLE_RUNNER, AGENT_EMBEDDING_PROVIDER, AGENT_GOVERNANCE_QUERIES, AGENT_MEMORY, AGENT_MODEL, AGENT_OPTIONS, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_QUOTA_STORE, AGENT_REGISTRY, AGENT_RETRIEVER, AGENT_ROLES_POLICY, AGENT_RUNNER, AGENT_SINK, AGENT_SKILLS, AGENT_SKILL_SOURCES, AGENT_SPAN_EVENTS, AGENT_STORE, AGENT_TOOL_REGISTRY, Actor, type ActorDirectory, type ActorResolver, type ActorSpendRow, type AgentApprovalPort, AgentDefinition, type AgentDelegated, AgentDelegation, type AgentDiagnosticEvent, type AgentDiagnosticKey, type AgentFollowUpsSpan, type AgentGovernanceQueries, AgentIntake, type AgentLlmTurnSpan, type AgentLoopDeps, type AgentLoopHooks, type AgentLoopResult, type AgentMemoryResolved, type AgentMemoryWritten, type AgentMessageEvent, type AgentPricingStore, type AgentQuotaExceeded, AgentRegistry, type AgentRetrievalSpan, type AgentRetrieved, type AgentRunFailed, type AgentRunFinished, AgentRunInput, type AgentRunStarted, type AgentRunner, type AgentSkillsResolved, type AgentSpanEvent, type AgentStore, AgentStreamError, type AgentStructuredOutputSpan, type AgentToolCallEvent, type AgentToolExecutionSpan, type AgentToolRetry, AgentUiComponent, AiToolCtx, type AppendMessageInput, type ApprovalWhere, type AttachmentRef, type AttachmentStagingStore, type BufferedModelTurnResult, type BuildMemoryBlockInput, type CostUsage, type CreateThreadInput, type CurrentModelPrice, DEFAULT_HISTORY_SUMMARY_INSTRUCTION, DEFAULT_MAX_FACT_CHARS, DEFAULT_MAX_MEMORIES, DEFAULT_MAX_SKILLS, DEFAULT_REFUSAL_REASON, DEFAULT_STRUCTURED_OUTPUT_INSTRUCTION, Decision, DefaultRolesPolicy, type DetachedDelegationOutcome, type DetachedDelegationReceipt, DetachedDelivery, type DetailThreadRef, ElicitationRequest, type EmbeddingProvider, type ForgetMemoryInput, type FrameBuffer, GLOBAL_SCOPE, type GovernancePage, type GovernancePageQuery, type GovernanceRange, type GovernanceRunDetail, type GovernanceThreadDetail, type GovernanceThreadDetailQuery, type GovernanceUsageInput, HistoryPolicy, HumanReply, type IncrementalGate, InputProcessor, type ListMemoriesInput, type ListSkillsInput, type ListStagedAttachmentsInput, LlmStepEnvelope, type LoadSkillInput, type MemoryAuthor, type MemoryConfig, type MemoryDigest, type MemoryDigestEntry, type MemoryFact, type MemoryForgetRequest, type MemoryOrigin, type MemoryProvider, type MemoryRecord, type MemoryVerdict, type MemoryWriteOutcome, type MemoryWriteRequest, MessageAttachment, MessageUsage, ModelAnswer, ModelMessage, type ModelPrice, type ModelPriceInput, type ModelProvider, type ModelSpendRow, type ModelTurnArgs, type ModelTurnResult, type ObservedTurnFrames, type OfferMemoriesInput, type OutputGateMode, type OutputGateResult, OutputProcessor, type OverriddenMemory, PageContext, type Passage, type PendingApprovalRow, ProcessedPrompt, ProcessorContext, PromptBuilder, PromptContributor, QuotaExceededError, QuotaState, type QuotaStore, REMEMBER_TOOL_DESCRIPTION, REMEMBER_TOOL_NAME, type RecentRunRow, type RecordRunEndInput, type RecordRunStartInput, type RecordToolCallInput, type RecordUsageInput, type RememberToolInput, type RerankOptions, type Reranker, type ResolveAttachmentInput, type ResolveMemoryDigestInput, type ResolvedDelegation, type RetrieveOptions, type Retriever, type RolesPolicy, type RunAgentBreakdownRow, RunCancelledError, type RunErrorBreakdownRow, type RunMetrics, type RunToolCallRow, type RunTrendPoint, type RunWhere, SKILL_TOOL_DESCRIPTION, SKILL_TOOL_NAME, type ScopeContext, type ScopeResolver, type SearchMemoriesInput, type SettledTask, type SinkWriter, type Skill, type SkillAuthor, type SkillCatalogEntry, type SkillContext, type SkillLoadOutcome, type SkillOffer, type SkillProvider, type SkillSummary, type SkillToolInput, type SkillWriteRequest, type SkillWriteVerdict, type SkillsConfig, type StageAttachmentInput, type StagedAttachment, type StoreMemoryInput, StoredMessage, type StreamError, type StructuredOutcome, StructuredOutputError, THREAD_DETAIL_CONTENT_CHARS, type ThreadActivityRow, ThreadDetail, type ThreadMessageRow, type ThreadMeta, type ThreadSpendRow, ThreadSummary, type ThreadTurnPage, type ThreadTurnQuery, type ThreadTurnReader, type ThreadUsageRollup, type ThreadWhere, type TokenStreamSink, type ToolCallActivityRow, ToolCallRequest, ToolCallStatus, type ToolCallWhere, ToolDefinition, ToolDisabledError, ToolForbiddenError, ToolHandler, ToolInputInvalidError, type ToolKindDeps, ToolNotFoundError, ToolRegistry, ToolResult, ToolSpec, type ToolStatRow, ToolStepEnvelope, ToolTransientRetrySetting, type TurnFrameSummary, type UpdateThreadInput, type UpdateToolCallInput, UsagePurpose, type UsageTrendPoint, type WindowHistoryOptions, type WithMemoryToolInput, type WriteMemoryInput, actorScope, agentDiagnosticKey, agentFailureCode, bucketByActor, bucketByModel, bucketByThread, bucketUsageTrend, buildMemoryBlock, buildSkillsBlock, canActorUseTool, compositeSkillProvider, createFrameBuffer, createIncrementalGate, dayBoundsUtc, defaultScopeResolver, detachedDelivered, detachedStarted, detachedUnsettled, estimateCost, estimateMessageTokens, extractJson, filterToolsByAllowList, filterToolsByCanUse, filterToolsByEnabled, filterToolsByRole, gateFollowUps, gateTail, isControlFlowSignal, isReplayIntegrityError, isToolEnabled, loadSkill, memoryForgetVerdict, memoryWriteVerdict, normalizeDelegation, observeTurnFrames, offerMemories, offerSkills, publishAgentDelegated, publishAgentMemoryResolved, publishAgentMemoryWritten, publishAgentMessage, publishAgentQuotaExceeded, publishAgentRetrieved, publishAgentRunFailed, publishAgentRunFinished, publishAgentRunStarted, publishAgentSkillsResolved, publishAgentToolCall, publishAgentToolRetry, releaseGatedFrames, rememberInputSchema, rememberToolDefinition, repairInstruction, resolveGateLookback, resolveMemoryDigest, resolveOutputGateMode, resolveSkillCatalog, rollupThreadUsage, runAgentLoop, runInputProcessors, runOutputProcessors, seedModelPrices, settleAll, settleUnsettledDelegation, skillInputSchema, skillToolDefinition, skillWriteVerdict, stampToolKinds, staticSkillProvider, summarizeWithModel, tenantScope, traceLlmTurn, traceToolExecution, truncateDetailContent, validateStructured, windowHistory, withAskTool, withMemoryTool, withSkillTool, withToolTimeout, withTurnFrames, writeMemory };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as ModelMessage, a as ToolDefinition, b as ToolCallRequest, c as MessageUsage,
|
|
2
|
-
export {
|
|
1
|
+
import { M as ModelMessage, a as ToolDefinition, b as ToolCallRequest, c as MessageUsage, d as AgentUiComponent, A as Actor, e as ThreadSummary, f as ThreadDetail, S as StoredMessage, g as ToolResult, h as MessageAttachment, i as ToolCallStatus, U as UsagePurpose, j as ToolSpec, Q as QuotaState, k as AgentRunInput, H as HumanReply, T as ToolHandler, l as HistoryPolicy, O as OutputProcessor, P as ProcessorContext, I as InputProcessor, m as ProcessedPrompt, n as ModelAnswer, o as PageContext, p as AgentDefinition, q as AgentDelegation, D as DetachedDelivery, r as AiToolCtx, s as PromptBuilder, t as PromptContributor, u as ToolTransientRetrySetting, v as AgentIntake, w as Decision, E as ElicitationRequest, L as LlmStepEnvelope, x as ToolStepEnvelope } from './tool-CHIw-aTx.js';
|
|
2
|
+
export { y as ASK_TOOL_DESCRIPTION, z as ASK_TOOL_NAME, B as AgentApprovalRequest, C as AgentCatalogEntry, F as AgentHistoryWindow, G as AgentStreamEvent, J as AskToolInput, K as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, N as DEFAULT_INTAKE_PREAMBLE, R as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, V as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, W as ElicitationOption, X as ElicitationOutcome, Y as ElicitationQuestion, Z as ElicitationReply, _ as ElicitationResult, $ as HistoryPolicyContext, a0 as HistorySelection, a1 as HistorySummary, a2 as IncrementalGating, a3 as InvokeWithTransientRetryOptions, a4 as MAX_ASK_QUESTIONS, a5 as MessageRole, a6 as OutputRejectedError, a7 as OutputVerdict, a8 as ProcessorFailedError, a9 as PromptContext, aa as QuotaView, ab as ToolKind, ac as ToolStepCtx, ad as ToolTransientRetryNumbers, ae as ToolTransientRetryOptions, af as askInputSchema, ag as askToolDefinition, ah as decodeStreamEvent, ai as encodeStreamEvent, aj as invokeWithTransientRetry, ak as isTransientToolError, al as normalizeElicitationReply, am as renderElicitationAnswers, an as resolveElicitation, ao as resolveToolTransientRetryNumbers, ap as settleElicitation } from './tool-CHIw-aTx.js';
|
|
3
3
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
4
4
|
import { ChannelRegistry } from '@dudousxd/nestjs-diagnostics';
|
|
5
5
|
|
|
@@ -160,6 +160,16 @@ interface ModelTurnResult {
|
|
|
160
160
|
* the JSON out of `text`) is always correct.
|
|
161
161
|
*/
|
|
162
162
|
object?: unknown;
|
|
163
|
+
/**
|
|
164
|
+
* The model's thinking this turn, as streamed. Optional: the loop derives it from the `reasoning`
|
|
165
|
+
* frames the provider wrote to the sink (see `observeTurnFrames`), so a provider only sets it to
|
|
166
|
+
* override that — e.g. one that receives reasoning it does not stream.
|
|
167
|
+
*/
|
|
168
|
+
reasoning?: string;
|
|
169
|
+
/** Time spent thinking this turn, in ms. Derived like {@link reasoning} when omitted. */
|
|
170
|
+
reasoningMs?: number;
|
|
171
|
+
/** Components pushed during this turn (`ui` frames). Derived like {@link reasoning} when omitted. */
|
|
172
|
+
ui?: AgentUiComponent[];
|
|
163
173
|
}
|
|
164
174
|
/**
|
|
165
175
|
* A model turn whose live frames were HELD instead of streamed, because an output processor has to
|
|
@@ -201,110 +211,33 @@ interface ModelProvider {
|
|
|
201
211
|
runTurn(args: ModelTurnArgs): Promise<ModelTurnResult>;
|
|
202
212
|
}
|
|
203
213
|
|
|
204
|
-
/**
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
* the adapter owns model-parts → event, the transport owns event → UI-chunk.
|
|
216
|
-
*/
|
|
217
|
-
|
|
218
|
-
type AgentStreamEvent = {
|
|
219
|
-
kind: 'step-start';
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Closes the step opened by the matching `step-start`. Carries the model call's token usage and
|
|
223
|
-
* `costUsd` (an estimate from the bound pricing store, or `null` when unpriced/unbound — never a
|
|
224
|
-
* fabricated `0`) so a live client can render running cost without waiting for a thread re-fetch.
|
|
225
|
-
*/
|
|
226
|
-
| {
|
|
227
|
-
kind: 'step-finish';
|
|
228
|
-
usage?: MessageUsage;
|
|
229
|
-
costUsd?: number | null;
|
|
230
|
-
} | {
|
|
231
|
-
kind: 'text';
|
|
232
|
-
text: string;
|
|
233
|
-
} | {
|
|
234
|
-
kind: 'reasoning';
|
|
235
|
-
text: string;
|
|
236
|
-
}
|
|
237
|
-
/** `toolKind` collapses `ToolKind`'s `'agent'` into `'read'` — delegation tools auto-execute like a read tool. */
|
|
238
|
-
| {
|
|
239
|
-
kind: 'tool-input-start';
|
|
240
|
-
id: string;
|
|
241
|
-
name: string;
|
|
242
|
-
toolKind: 'read' | 'action';
|
|
243
|
-
} | {
|
|
244
|
-
kind: 'tool-input-delta';
|
|
245
|
-
id: string;
|
|
246
|
-
delta: string;
|
|
247
|
-
} | {
|
|
248
|
-
kind: 'tool-input-available';
|
|
249
|
-
id: string;
|
|
250
|
-
name: string;
|
|
251
|
-
input: unknown;
|
|
252
|
-
toolKind: 'read' | 'action';
|
|
253
|
-
} | {
|
|
254
|
-
kind: 'tool-output';
|
|
255
|
-
id: string;
|
|
256
|
-
output: unknown;
|
|
257
|
-
} | {
|
|
258
|
-
kind: 'tool-output-error';
|
|
259
|
-
id: string;
|
|
260
|
-
error: string;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* A person was asked to approve an action tool and declined it. Its own frame, NOT
|
|
264
|
-
* `tool-output-error`: a refusal is a decision with a known outcome — nothing ran — while a
|
|
265
|
-
* failure is an outcome nobody chose and whose effects are unknown. Rendering them the same way
|
|
266
|
-
* tells an operator their own "no" was a malfunction. Maps onto the SDK's `output-denied` tool
|
|
267
|
-
* part state, which a client reads without knowing any tool's name.
|
|
268
|
-
*/
|
|
269
|
-
| {
|
|
270
|
-
kind: 'tool-output-denied';
|
|
271
|
-
id: string;
|
|
272
|
-
reason?: string;
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* The run has put a question set to the user and is parked until someone answers it (or skips).
|
|
276
|
-
* Written by the LOOP for both elicitation surfaces — the configured intake and the model's `ask`
|
|
277
|
-
* tool — so a client renders one form either way rather than learning to recognise a tool name.
|
|
278
|
-
* The matching `tool-output` frame, under the same `id`, carries the settled answers.
|
|
279
|
-
*/
|
|
280
|
-
| {
|
|
281
|
-
kind: 'elicitation';
|
|
282
|
-
id: string;
|
|
283
|
-
request: ElicitationRequest;
|
|
214
|
+
/** What a model turn streamed that the persisted message keeps, beyond its text and tool calls. */
|
|
215
|
+
interface TurnFrameSummary {
|
|
216
|
+
reasoning?: string;
|
|
217
|
+
reasoningMs?: number;
|
|
218
|
+
ui?: AgentUiComponent[];
|
|
219
|
+
}
|
|
220
|
+
interface ObservedTurnFrames {
|
|
221
|
+
/** Hand THIS to the provider: every write passes through to the wrapped writer unchanged. */
|
|
222
|
+
writer: SinkWriter;
|
|
223
|
+
/** What was seen so far. Closes an open thinking burst at the moment it is called. */
|
|
224
|
+
summary(): TurnFrameSummary;
|
|
284
225
|
}
|
|
285
226
|
/**
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
* error and a client that retries on a failed stream must not retry this.
|
|
227
|
+
* Watch the frames a model turn writes, to learn what the stream showed that the provider's result
|
|
228
|
+
* does not carry: the model's thinking (text and how long it took) and any pushed UI components.
|
|
289
229
|
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
293
|
-
|
|
294
|
-
| {
|
|
295
|
-
kind: 'cancelled';
|
|
296
|
-
};
|
|
297
|
-
/** Encode one event as an NDJSON line (`{...}\n`) for {@link SinkWriter.write}. */
|
|
298
|
-
declare function encodeStreamEvent(event: AgentStreamEvent): Uint8Array;
|
|
299
|
-
/**
|
|
300
|
-
* Read one NDJSON line back, or `null` when the line is not a stream event at all.
|
|
230
|
+
* Derived from the FRAMES rather than asked of each provider, so every provider that streams the
|
|
231
|
+
* vocabulary gets reasoning persisted without implementing anything. Thinking time is the sum of
|
|
232
|
+
* each burst of consecutive `reasoning` frames — from the first one to the next frame that is not
|
|
233
|
+
* reasoning (or the end of the turn) — which is what a reader watched as "thinking".
|
|
301
234
|
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
* CLASSIFY a chunk — the output gate, which may only forward what it can prove is not the answer —
|
|
305
|
-
* treats an unreadable frame as unclassifiable rather than guessing.
|
|
235
|
+
* Call it inside the step that runs the model, so the summary rides that step's journaled result
|
|
236
|
+
* and a replay reads the same numbers back instead of re-measuring a turn that is not happening.
|
|
306
237
|
*/
|
|
307
|
-
declare function
|
|
238
|
+
declare function observeTurnFrames(writer: SinkWriter, now?: () => number): ObservedTurnFrames;
|
|
239
|
+
/** Fill what a provider did not report from what its frames showed. A provider's own value wins. */
|
|
240
|
+
declare function withTurnFrames<T extends ModelTurnResult>(result: T, frames: TurnFrameSummary): T;
|
|
308
241
|
|
|
309
242
|
interface CreateThreadInput {
|
|
310
243
|
actor: Actor;
|
|
@@ -331,6 +264,12 @@ interface AppendMessageInput {
|
|
|
331
264
|
* run) can omit it; the store persists it as `null` when absent.
|
|
332
265
|
*/
|
|
333
266
|
runId?: string;
|
|
267
|
+
/** The step's streamed thinking. See {@link StoredMessage.reasoning}. */
|
|
268
|
+
reasoning?: string;
|
|
269
|
+
/** Time spent thinking in this step, in ms. See {@link StoredMessage.reasoningMs}. */
|
|
270
|
+
reasoningMs?: number;
|
|
271
|
+
/** Components pushed during this step. See {@link StoredMessage.ui}. */
|
|
272
|
+
ui?: AgentUiComponent[];
|
|
334
273
|
}
|
|
335
274
|
interface RecordToolCallInput {
|
|
336
275
|
toolCallId: string;
|
|
@@ -3202,4 +3141,4 @@ type AgentDiagnosticKey = `agent:${AgentDiagnosticEvent}`;
|
|
|
3202
3141
|
*/
|
|
3203
3142
|
declare function agentDiagnosticKey(event: AgentDiagnosticEvent): AgentDiagnosticKey;
|
|
3204
3143
|
|
|
3205
|
-
export { AGENT_ACTOR_DIRECTORY, AGENT_ACTOR_RESOLVER, AGENT_APPROVAL_PORT, AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY, AGENT_DIAGNOSTIC_EVENTS, AGENT_DURABLE_RUNNER, AGENT_EMBEDDING_PROVIDER, AGENT_GOVERNANCE_QUERIES, AGENT_MEMORY, AGENT_MODEL, AGENT_OPTIONS, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_QUOTA_STORE, AGENT_REGISTRY, AGENT_RETRIEVER, AGENT_ROLES_POLICY, AGENT_RUNNER, AGENT_SINK, AGENT_SKILLS, AGENT_SKILL_SOURCES, AGENT_SPAN_EVENTS, AGENT_STORE, AGENT_TOOL_REGISTRY, Actor, type ActorDirectory, type ActorResolver, type ActorSpendRow, type AgentApprovalPort, AgentDefinition, type AgentDelegated, AgentDelegation, type AgentDiagnosticEvent, type AgentDiagnosticKey, type AgentFollowUpsSpan, type AgentGovernanceQueries, AgentIntake, type AgentLlmTurnSpan, type AgentLoopDeps, type AgentLoopHooks, type AgentLoopResult, type AgentMemoryResolved, type AgentMemoryWritten, type AgentMessageEvent, type AgentPricingStore, type AgentQuotaExceeded, AgentRegistry, type AgentRetrievalSpan, type AgentRetrieved, type AgentRunFailed, type AgentRunFinished, AgentRunInput, type AgentRunStarted, type AgentRunner, type AgentSkillsResolved, type AgentSpanEvent, type AgentStore, AgentStreamError, type
|
|
3144
|
+
export { AGENT_ACTOR_DIRECTORY, AGENT_ACTOR_RESOLVER, AGENT_APPROVAL_PORT, AGENT_ATTACHMENT_STAGING, AGENT_DEPS_FACTORY, AGENT_DIAGNOSTIC_EVENTS, AGENT_DURABLE_RUNNER, AGENT_EMBEDDING_PROVIDER, AGENT_GOVERNANCE_QUERIES, AGENT_MEMORY, AGENT_MODEL, AGENT_OPTIONS, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_QUOTA_STORE, AGENT_REGISTRY, AGENT_RETRIEVER, AGENT_ROLES_POLICY, AGENT_RUNNER, AGENT_SINK, AGENT_SKILLS, AGENT_SKILL_SOURCES, AGENT_SPAN_EVENTS, AGENT_STORE, AGENT_TOOL_REGISTRY, Actor, type ActorDirectory, type ActorResolver, type ActorSpendRow, type AgentApprovalPort, AgentDefinition, type AgentDelegated, AgentDelegation, type AgentDiagnosticEvent, type AgentDiagnosticKey, type AgentFollowUpsSpan, type AgentGovernanceQueries, AgentIntake, type AgentLlmTurnSpan, type AgentLoopDeps, type AgentLoopHooks, type AgentLoopResult, type AgentMemoryResolved, type AgentMemoryWritten, type AgentMessageEvent, type AgentPricingStore, type AgentQuotaExceeded, AgentRegistry, type AgentRetrievalSpan, type AgentRetrieved, type AgentRunFailed, type AgentRunFinished, AgentRunInput, type AgentRunStarted, type AgentRunner, type AgentSkillsResolved, type AgentSpanEvent, type AgentStore, AgentStreamError, type AgentStructuredOutputSpan, type AgentToolCallEvent, type AgentToolExecutionSpan, type AgentToolRetry, AgentUiComponent, AiToolCtx, type AppendMessageInput, type ApprovalWhere, type AttachmentRef, type AttachmentStagingStore, type BufferedModelTurnResult, type BuildMemoryBlockInput, type CostUsage, type CreateThreadInput, type CurrentModelPrice, DEFAULT_HISTORY_SUMMARY_INSTRUCTION, DEFAULT_MAX_FACT_CHARS, DEFAULT_MAX_MEMORIES, DEFAULT_MAX_SKILLS, DEFAULT_REFUSAL_REASON, DEFAULT_STRUCTURED_OUTPUT_INSTRUCTION, Decision, DefaultRolesPolicy, type DetachedDelegationOutcome, type DetachedDelegationReceipt, DetachedDelivery, type DetailThreadRef, ElicitationRequest, type EmbeddingProvider, type ForgetMemoryInput, type FrameBuffer, GLOBAL_SCOPE, type GovernancePage, type GovernancePageQuery, type GovernanceRange, type GovernanceRunDetail, type GovernanceThreadDetail, type GovernanceThreadDetailQuery, type GovernanceUsageInput, HistoryPolicy, HumanReply, type IncrementalGate, InputProcessor, type ListMemoriesInput, type ListSkillsInput, type ListStagedAttachmentsInput, LlmStepEnvelope, type LoadSkillInput, type MemoryAuthor, type MemoryConfig, type MemoryDigest, type MemoryDigestEntry, type MemoryFact, type MemoryForgetRequest, type MemoryOrigin, type MemoryProvider, type MemoryRecord, type MemoryVerdict, type MemoryWriteOutcome, type MemoryWriteRequest, MessageAttachment, MessageUsage, ModelAnswer, ModelMessage, type ModelPrice, type ModelPriceInput, type ModelProvider, type ModelSpendRow, type ModelTurnArgs, type ModelTurnResult, type ObservedTurnFrames, type OfferMemoriesInput, type OutputGateMode, type OutputGateResult, OutputProcessor, type OverriddenMemory, PageContext, type Passage, type PendingApprovalRow, ProcessedPrompt, ProcessorContext, PromptBuilder, PromptContributor, QuotaExceededError, QuotaState, type QuotaStore, REMEMBER_TOOL_DESCRIPTION, REMEMBER_TOOL_NAME, type RecentRunRow, type RecordRunEndInput, type RecordRunStartInput, type RecordToolCallInput, type RecordUsageInput, type RememberToolInput, type RerankOptions, type Reranker, type ResolveAttachmentInput, type ResolveMemoryDigestInput, type ResolvedDelegation, type RetrieveOptions, type Retriever, type RolesPolicy, type RunAgentBreakdownRow, RunCancelledError, type RunErrorBreakdownRow, type RunMetrics, type RunToolCallRow, type RunTrendPoint, type RunWhere, SKILL_TOOL_DESCRIPTION, SKILL_TOOL_NAME, type ScopeContext, type ScopeResolver, type SearchMemoriesInput, type SettledTask, type SinkWriter, type Skill, type SkillAuthor, type SkillCatalogEntry, type SkillContext, type SkillLoadOutcome, type SkillOffer, type SkillProvider, type SkillSummary, type SkillToolInput, type SkillWriteRequest, type SkillWriteVerdict, type SkillsConfig, type StageAttachmentInput, type StagedAttachment, type StoreMemoryInput, StoredMessage, type StreamError, type StructuredOutcome, StructuredOutputError, THREAD_DETAIL_CONTENT_CHARS, type ThreadActivityRow, ThreadDetail, type ThreadMessageRow, type ThreadMeta, type ThreadSpendRow, ThreadSummary, type ThreadTurnPage, type ThreadTurnQuery, type ThreadTurnReader, type ThreadUsageRollup, type ThreadWhere, type TokenStreamSink, type ToolCallActivityRow, ToolCallRequest, ToolCallStatus, type ToolCallWhere, ToolDefinition, ToolDisabledError, ToolForbiddenError, ToolHandler, ToolInputInvalidError, type ToolKindDeps, ToolNotFoundError, ToolRegistry, ToolResult, ToolSpec, type ToolStatRow, ToolStepEnvelope, ToolTransientRetrySetting, type TurnFrameSummary, type UpdateThreadInput, type UpdateToolCallInput, UsagePurpose, type UsageTrendPoint, type WindowHistoryOptions, type WithMemoryToolInput, type WriteMemoryInput, actorScope, agentDiagnosticKey, agentFailureCode, bucketByActor, bucketByModel, bucketByThread, bucketUsageTrend, buildMemoryBlock, buildSkillsBlock, canActorUseTool, compositeSkillProvider, createFrameBuffer, createIncrementalGate, dayBoundsUtc, defaultScopeResolver, detachedDelivered, detachedStarted, detachedUnsettled, estimateCost, estimateMessageTokens, extractJson, filterToolsByAllowList, filterToolsByCanUse, filterToolsByEnabled, filterToolsByRole, gateFollowUps, gateTail, isControlFlowSignal, isReplayIntegrityError, isToolEnabled, loadSkill, memoryForgetVerdict, memoryWriteVerdict, normalizeDelegation, observeTurnFrames, offerMemories, offerSkills, publishAgentDelegated, publishAgentMemoryResolved, publishAgentMemoryWritten, publishAgentMessage, publishAgentQuotaExceeded, publishAgentRetrieved, publishAgentRunFailed, publishAgentRunFinished, publishAgentRunStarted, publishAgentSkillsResolved, publishAgentToolCall, publishAgentToolRetry, releaseGatedFrames, rememberInputSchema, rememberToolDefinition, repairInstruction, resolveGateLookback, resolveMemoryDigest, resolveOutputGateMode, resolveSkillCatalog, rollupThreadUsage, runAgentLoop, runInputProcessors, runOutputProcessors, seedModelPrices, settleAll, settleUnsettledDelegation, skillInputSchema, skillToolDefinition, skillWriteVerdict, stampToolKinds, staticSkillProvider, summarizeWithModel, tenantScope, traceLlmTurn, traceToolExecution, truncateDetailContent, validateStructured, windowHistory, withAskTool, withMemoryTool, withSkillTool, withToolTimeout, withTurnFrames, writeMemory };
|
package/dist/index.js
CHANGED
|
@@ -58,6 +58,105 @@ function decodeStreamEvent(line) {
|
|
|
58
58
|
}
|
|
59
59
|
__name(decodeStreamEvent, "decodeStreamEvent");
|
|
60
60
|
|
|
61
|
+
// src/turn-frames.ts
|
|
62
|
+
function observeTurnFrames(writer, now = Date.now) {
|
|
63
|
+
const decoder2 = new TextDecoder();
|
|
64
|
+
let pending = "";
|
|
65
|
+
let reasoning = "";
|
|
66
|
+
let reasoningMs = 0;
|
|
67
|
+
let burstStartedAt;
|
|
68
|
+
const ui = /* @__PURE__ */ new Map();
|
|
69
|
+
function closeBurst() {
|
|
70
|
+
if (burstStartedAt !== void 0) {
|
|
71
|
+
reasoningMs += Math.max(0, now() - burstStartedAt);
|
|
72
|
+
burstStartedAt = void 0;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
__name(closeBurst, "closeBurst");
|
|
76
|
+
function observeLine(line) {
|
|
77
|
+
if (line.trim().length === 0) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const event = decodeStreamEvent(line);
|
|
81
|
+
if (event === null) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (event.kind === "reasoning") {
|
|
85
|
+
burstStartedAt ??= now();
|
|
86
|
+
reasoning += event.text;
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
closeBurst();
|
|
90
|
+
if (event.kind === "ui") {
|
|
91
|
+
ui.set(event.id, {
|
|
92
|
+
id: event.id,
|
|
93
|
+
component: event.component,
|
|
94
|
+
props: event.props,
|
|
95
|
+
...event.version !== void 0 ? {
|
|
96
|
+
version: event.version
|
|
97
|
+
} : {}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
__name(observeLine, "observeLine");
|
|
102
|
+
function observe(chunk) {
|
|
103
|
+
pending += decoder2.decode(chunk, {
|
|
104
|
+
stream: true
|
|
105
|
+
});
|
|
106
|
+
let newline = pending.indexOf("\n");
|
|
107
|
+
while (newline !== -1) {
|
|
108
|
+
observeLine(pending.slice(0, newline));
|
|
109
|
+
pending = pending.slice(newline + 1);
|
|
110
|
+
newline = pending.indexOf("\n");
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
__name(observe, "observe");
|
|
114
|
+
return {
|
|
115
|
+
writer: {
|
|
116
|
+
write(chunk) {
|
|
117
|
+
observe(chunk);
|
|
118
|
+
return writer.write(chunk);
|
|
119
|
+
},
|
|
120
|
+
end: /* @__PURE__ */ __name(() => writer.end(), "end"),
|
|
121
|
+
fail: /* @__PURE__ */ __name((error) => writer.fail(error), "fail")
|
|
122
|
+
},
|
|
123
|
+
summary() {
|
|
124
|
+
if (pending.length > 0) {
|
|
125
|
+
observeLine(pending);
|
|
126
|
+
pending = "";
|
|
127
|
+
}
|
|
128
|
+
closeBurst();
|
|
129
|
+
return {
|
|
130
|
+
...reasoning.length > 0 ? {
|
|
131
|
+
reasoning,
|
|
132
|
+
reasoningMs: Math.round(reasoningMs)
|
|
133
|
+
} : {},
|
|
134
|
+
...ui.size > 0 ? {
|
|
135
|
+
ui: [
|
|
136
|
+
...ui.values()
|
|
137
|
+
]
|
|
138
|
+
} : {}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
__name(observeTurnFrames, "observeTurnFrames");
|
|
144
|
+
function withTurnFrames(result, frames) {
|
|
145
|
+
return {
|
|
146
|
+
...result,
|
|
147
|
+
...result.reasoning === void 0 && frames.reasoning !== void 0 ? {
|
|
148
|
+
reasoning: frames.reasoning
|
|
149
|
+
} : {},
|
|
150
|
+
...result.reasoningMs === void 0 && frames.reasoningMs !== void 0 ? {
|
|
151
|
+
reasoningMs: frames.reasoningMs
|
|
152
|
+
} : {},
|
|
153
|
+
...result.ui === void 0 && frames.ui !== void 0 ? {
|
|
154
|
+
ui: frames.ui
|
|
155
|
+
} : {}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
__name(withTurnFrames, "withTurnFrames");
|
|
159
|
+
|
|
61
160
|
// src/spi/pricing-store.ts
|
|
62
161
|
async function seedModelPrices(store, prices) {
|
|
63
162
|
for (const price of prices) {
|
|
@@ -3363,12 +3462,13 @@ ${block}`;
|
|
|
3363
3462
|
writer
|
|
3364
3463
|
}) : void 0;
|
|
3365
3464
|
const buffer = gateMode === "whole" ? createFrameBuffer() : void 0;
|
|
3366
|
-
const
|
|
3465
|
+
const frames = observeTurnFrames(incremental?.writer ?? buffer?.writer ?? writer);
|
|
3466
|
+
const result = stampToolKinds(withTurnFrames(await traceLlmTurn(hooks.runId, i, () => deps.model.runTurn({
|
|
3367
3467
|
system: prompt.system,
|
|
3368
3468
|
messages: prompt.messages,
|
|
3369
3469
|
tools,
|
|
3370
|
-
sink:
|
|
3371
|
-
})), deps);
|
|
3470
|
+
sink: frames.writer
|
|
3471
|
+
})), frames.summary()), deps);
|
|
3372
3472
|
if (incremental !== void 0) {
|
|
3373
3473
|
await incremental.settled();
|
|
3374
3474
|
const refusal = incremental.rejection();
|
|
@@ -3556,6 +3656,15 @@ ${block}`;
|
|
|
3556
3656
|
...input.agentName !== void 0 ? {
|
|
3557
3657
|
agentName: input.agentName
|
|
3558
3658
|
} : {},
|
|
3659
|
+
...turn.reasoning !== void 0 ? {
|
|
3660
|
+
reasoning: turn.reasoning
|
|
3661
|
+
} : {},
|
|
3662
|
+
...turn.reasoningMs !== void 0 ? {
|
|
3663
|
+
reasoningMs: turn.reasoningMs
|
|
3664
|
+
} : {},
|
|
3665
|
+
...turn.ui !== void 0 && turn.ui.length > 0 ? {
|
|
3666
|
+
ui: turn.ui
|
|
3667
|
+
} : {},
|
|
3559
3668
|
...messageCalls.length > 0 ? {
|
|
3560
3669
|
toolCalls: messageCalls
|
|
3561
3670
|
} : {},
|
|
@@ -3613,7 +3722,10 @@ ${block}`;
|
|
|
3613
3722
|
await writer.write(encodeStreamEvent({
|
|
3614
3723
|
kind: "step-finish",
|
|
3615
3724
|
usage: turn.usage,
|
|
3616
|
-
costUsd
|
|
3725
|
+
costUsd,
|
|
3726
|
+
...turn.reasoningMs !== void 0 ? {
|
|
3727
|
+
reasoningMs: turn.reasoningMs
|
|
3728
|
+
} : {}
|
|
3617
3729
|
}));
|
|
3618
3730
|
});
|
|
3619
3731
|
break;
|
|
@@ -3666,7 +3778,10 @@ ${block}`;
|
|
|
3666
3778
|
await writer.write(encodeStreamEvent({
|
|
3667
3779
|
kind: "step-finish",
|
|
3668
3780
|
usage: turn.usage,
|
|
3669
|
-
costUsd
|
|
3781
|
+
costUsd,
|
|
3782
|
+
...turn.reasoningMs !== void 0 ? {
|
|
3783
|
+
reasoningMs: turn.reasoningMs
|
|
3784
|
+
} : {}
|
|
3670
3785
|
}));
|
|
3671
3786
|
});
|
|
3672
3787
|
}
|
|
@@ -3820,6 +3935,7 @@ export {
|
|
|
3820
3935
|
memoryWriteVerdict,
|
|
3821
3936
|
normalizeDelegation,
|
|
3822
3937
|
normalizeElicitationReply,
|
|
3938
|
+
observeTurnFrames,
|
|
3823
3939
|
offerMemories,
|
|
3824
3940
|
offerSkills,
|
|
3825
3941
|
publishAgentDelegated,
|
|
@@ -3869,6 +3985,7 @@ export {
|
|
|
3869
3985
|
withMemoryTool,
|
|
3870
3986
|
withSkillTool,
|
|
3871
3987
|
withToolTimeout,
|
|
3988
|
+
withTurnFrames,
|
|
3872
3989
|
writeMemory
|
|
3873
3990
|
};
|
|
3874
3991
|
//# sourceMappingURL=index.js.map
|