@cloudflare/think 0.15.0 → 0.15.1
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/think.js +9 -15
- package/dist/think.js.map +1 -1
- package/package.json +4 -4
package/dist/think.js
CHANGED
|
@@ -5,14 +5,14 @@ import { truncatePausedExecutionOutput } from "./tools/execute.js";
|
|
|
5
5
|
import { t as ThinkMessengerRuntime } from "./chat-sdk-iuBa-CGM.js";
|
|
6
6
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
7
7
|
import * as aiSdk from "ai";
|
|
8
|
-
import { convertToModelMessages, hasToolCall, jsonSchema, stepCountIs,
|
|
9
|
-
import {
|
|
8
|
+
import { convertToModelMessages, hasToolCall, jsonSchema, stepCountIs, tool } from "ai";
|
|
9
|
+
import { wrapAISDK } from "agents/observability/ai";
|
|
10
10
|
import { createWorkersAI } from "workers-ai-provider";
|
|
11
11
|
import { anthropic } from "workers-ai-provider/anthropic";
|
|
12
12
|
import { openai } from "workers-ai-provider/openai";
|
|
13
13
|
import * as skills from "agents/skills";
|
|
14
14
|
import { SkillRegistry } from "agents/skills";
|
|
15
|
-
import { Agent, __DO_NOT_USE_WILL_BREAK__agentContext, callable, getCurrentAgent, isDurableObjectMemoryLimitReset, isPlatformTransientError } from "agents";
|
|
15
|
+
import { Agent, __DO_NOT_USE_WILL_BREAK__agentContext, __DO_NOT_USE_WILL_BREAK__withInvocationScope, callable, getCurrentAgent, isDurableObjectMemoryLimitReset, isPlatformTransientError } from "agents";
|
|
16
16
|
import { AbortRegistry, AgentToolProgressEmitter, AgentToolStreamProgressThrottle, AutoContinuationController, CHAT_MESSAGE_TYPES, ChatRecoveryEngine, ChatStreamStalledError, ContinuationState, MAX_BOUND_PARAMS, PreStreamTurns, ResumableStream, ResumeHandshake, STREAM_CLEANUP_DELAY_SECONDS, StreamAccumulator, StreamProgressCreditThrottle, SubmitConcurrencyController, TIMED_OUT, TurnQueue, aiSdkRecoveryCodec, applyToolUpdate, awaitWithDeadline, buildChatRecoveringFrame, buildInClauseStrings, bumpChatRecoveryProgress, chatRecoverySchedulePolicy, classifyAgentToolChildRecovery, cleanupStreamBuffers, clearChatTerminal, clientResolvableToolNames, createChatFiberSnapshot, createToolsFromClientSchemas, crossMessageToolResultUpdate, drainInteractionApplies, enforceRowSizeLimit, hasIncompleteToolBatch, interceptAgentToolBroadcast, iterateWithStallWatchdog, listActiveChatRecoveryIncidents, normalizeToolInput, parseProtocolMessage, partAwaitsClientInteraction, pausedExecutionUpdate, pendingChatTerminal, persistReconstructedOrphan, readChatRecoveryProgress, reconcileMessages, recordChatTerminal, repairInterruptedToolParts, resolveChatRecoveryConfig, resolveToolMergeId, runChatRecoveryExhaustion, sanitizeMessage, setChatRecovering, shouldCreditStreamProgress, sweepStaleChatRecoveryIncidents, toolApprovalUpdate, toolPartHasSettledResult, toolResultUpdate, unwrapChatFiberSnapshot, wrapChatFiberSnapshot } from "agents/chat";
|
|
17
17
|
import { Session, Session as Session$1 } from "agents/experimental/memory/session";
|
|
18
18
|
import { truncateOlderMessages } from "agents/experimental/memory/utils";
|
|
@@ -297,7 +297,7 @@ function resolveChannels(configured, messengers) {
|
|
|
297
297
|
* ```
|
|
298
298
|
*/
|
|
299
299
|
const agentToolChunkEncoder = new TextEncoder();
|
|
300
|
-
const
|
|
300
|
+
const agentsAISDKInvocationBounded = Symbol.for("cloudflare.agents.ai-sdk.invocation-bounded");
|
|
301
301
|
const usesAISDKV7Telemetry = "registerTelemetry" in aiSdk;
|
|
302
302
|
/**
|
|
303
303
|
* The recent-message span the model sees at FULL fidelity each turn —
|
|
@@ -2581,10 +2581,6 @@ var Think = class Think extends Agent {
|
|
|
2581
2581
|
const localIntegrations = settings.integrations;
|
|
2582
2582
|
const globalIntegrations = globalThis.AI_SDK_TELEMETRY_INTEGRATIONS;
|
|
2583
2583
|
const integrations = [...localIntegrations !== void 0 ? Array.isArray(localIntegrations) ? localIntegrations : [localIntegrations] : globalIntegrations ?? []];
|
|
2584
|
-
if (!integrations.some((integration) => typeof integration === "object" && integration !== null && agentsAISDKTelemetryBrand in integration)) integrations.push(createAISDKTelemetry({
|
|
2585
|
-
storeMessages: this.storeMessages,
|
|
2586
|
-
storeTools: this.storeTools
|
|
2587
|
-
}));
|
|
2588
2584
|
const options = {
|
|
2589
2585
|
...settings,
|
|
2590
2586
|
functionId: typeof settings.functionId === "string" ? settings.functionId : this.constructor.name,
|
|
@@ -2820,17 +2816,15 @@ var Think = class Think extends Agent {
|
|
|
2820
2816
|
});
|
|
2821
2817
|
})
|
|
2822
2818
|
};
|
|
2819
|
+
const crossMajorOptions = streamTextOptions;
|
|
2823
2820
|
if (usesAISDKV7Telemetry) {
|
|
2824
2821
|
const { options, runtimeContext } = this._turnTelemetryV7(turnTelemetry);
|
|
2825
|
-
const crossMajorOptions = streamTextOptions;
|
|
2826
2822
|
delete crossMajorOptions.experimental_telemetry;
|
|
2827
2823
|
crossMajorOptions.telemetry = options;
|
|
2828
2824
|
crossMajorOptions.runtimeContext = runtimeContext;
|
|
2829
2825
|
}
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
wrapLanguageModel
|
|
2833
|
-
}, {
|
|
2826
|
+
if (admittedTurnContext.getStore()?.trigger === "ws-chat") crossMajorOptions[agentsAISDKInvocationBounded] = true;
|
|
2827
|
+
const inferenceStreamText = wrapAISDK(aiSdk, {
|
|
2834
2828
|
storeMessages: this.storeMessages,
|
|
2835
2829
|
storeTools: this.storeTools
|
|
2836
2830
|
}).streamText;
|
|
@@ -3554,7 +3548,7 @@ var Think = class Think extends Agent {
|
|
|
3554
3548
|
throw new Error(`Think turn admission (${trigger}) cannot be called from inside an active turn; use runTurn({ mode: "submit" }) or addMessages() instead`);
|
|
3555
3549
|
}
|
|
3556
3550
|
async _runInsideAdmittedTurnBody(spec) {
|
|
3557
|
-
return withAgentSpan(this, "chat_turn", "turn", {
|
|
3551
|
+
return __DO_NOT_USE_WILL_BREAK__withInvocationScope(() => withAgentSpan(this, "chat_turn", "turn", {
|
|
3558
3552
|
"cloudflare.agents.component": "think",
|
|
3559
3553
|
"cloudflare.agents.turn.request_id": spec.requestId,
|
|
3560
3554
|
"cloudflare.agents.turn.trigger": spec.trigger,
|
|
@@ -3610,7 +3604,7 @@ var Think = class Think extends Agent {
|
|
|
3610
3604
|
update({ "cloudflare.agents.turn.status": "error" });
|
|
3611
3605
|
throw error;
|
|
3612
3606
|
}
|
|
3613
|
-
}));
|
|
3607
|
+
})), { detached: true });
|
|
3614
3608
|
}
|
|
3615
3609
|
/**
|
|
3616
3610
|
* Run a chat turn: persist the user message, run the agentic loop,
|