@cloudflare/think 0.11.1 → 0.13.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 +9 -14
- package/dist/{chat-sdk-D6cUghsQ.js → chat-sdk-iuBa-CGM.js} +62 -7
- package/dist/chat-sdk-iuBa-CGM.js.map +1 -0
- package/dist/cli/index.js +6 -15
- package/dist/cli/index.js.map +1 -1
- package/dist/{index-CR4-ffm_.d.ts → index-Cm0jriTY.d.ts} +332 -141
- package/dist/messengers/index.d.ts +44 -38
- package/dist/messengers/index.js +2 -2
- package/dist/messengers/telegram.d.ts +2 -2
- package/dist/messengers/telegram.js +1 -1
- package/dist/studio/assets/{angular-html-D27LthTc.js → angular-html--XgCyfPu.js} +1 -1
- package/dist/studio/assets/{angular-ts-DtNL2gQ7.js → angular-ts-Dt-feQIe.js} +1 -1
- package/dist/studio/assets/{apl-BgEcDqM0.js → apl-B7ymkyp4.js} +1 -1
- package/dist/studio/assets/{astro-CstbRF9e.js → astro-Ce5cw2JI.js} +1 -1
- package/dist/studio/assets/{blade-CLG-7epG.js → blade-DL-aXwjv.js} +1 -1
- package/dist/studio/assets/{c-CssQqwxO.js → c-CFfr09UF.js} +1 -1
- package/dist/studio/assets/{cobol-CjmzHCjg.js → cobol-Ba1f5ZqR.js} +1 -1
- package/dist/studio/assets/{coffee-B_rqYPkp.js → coffee-BG2_viYI.js} +1 -1
- package/dist/studio/assets/{cpp-5YyZJlb7.js → cpp-pU5HgBva.js} +1 -1
- package/dist/studio/assets/{crystal-D7uKze0i.js → crystal-Dlm_uR4r.js} +1 -1
- package/dist/studio/assets/{css-k9oPgg7G.js → css-tUC4TMTn.js} +1 -1
- package/dist/studio/assets/{edge-CGgsSt0x.js → edge-CQuSKMUt.js} +1 -1
- package/dist/studio/assets/{elixir-BX_d5Evo.js → elixir-BmIB-Wi1.js} +1 -1
- package/dist/studio/assets/{elm-DENxDm5e.js → elm-ByVNCtDB.js} +1 -1
- package/dist/studio/assets/{erb-DvYOup03.js → erb-DO4uDxTq.js} +1 -1
- package/dist/studio/assets/{git-rebase-BsAdTS5A.js → git-rebase-CT8LXapC.js} +1 -1
- package/dist/studio/assets/{glimmer-js-e0h98Z67.js → glimmer-js-DzIT0v-m.js} +1 -1
- package/dist/studio/assets/{glimmer-ts-C9s5Kv8m.js → glimmer-ts-znG2j9R4.js} +1 -1
- package/dist/studio/assets/{glsl-CCiyeTRs.js → glsl-C1p8U_gW.js} +1 -1
- package/dist/studio/assets/{graphql-BRtHwsqk.js → graphql-CFqegryf.js} +1 -1
- package/dist/studio/assets/{hack-Dnt0QXHh.js → hack-BfVsNhqs.js} +1 -1
- package/dist/studio/assets/{haml-EXGmzuB1.js → haml-DVcEksY5.js} +1 -1
- package/dist/studio/assets/{handlebars-CzyBIDJE.js → handlebars-DSWgWCJ4.js} +1 -1
- package/dist/studio/assets/{highlighted-body-OFNGDK62-CQUFKLNu.js → highlighted-body-OFNGDK62-BIm4UpTS.js} +1 -1
- package/dist/studio/assets/{html-BAT8b_VM.js → html-C-lP7-T4.js} +1 -1
- package/dist/studio/assets/{html-derivative-7tkS-r6F.js → html-derivative-ByukJopb.js} +1 -1
- package/dist/studio/assets/{http-Cgka02Qq.js → http-Bax2fYIk.js} +1 -1
- package/dist/studio/assets/{hurl-Cbkh8WEw.js → hurl-BrI2qfvy.js} +1 -1
- package/dist/studio/assets/{index-D6n8vpkp.js → index-DNSTOyBe.js} +5 -5
- package/dist/studio/assets/{java-DrRKiUno.js → java-ZiR-uym-.js} +1 -1
- package/dist/studio/assets/{javascript-9LAnHOxD.js → javascript-Dhhw85Vr.js} +1 -1
- package/dist/studio/assets/{jinja-CqRt4prs.js → jinja-DqSGkgE4.js} +1 -1
- package/dist/studio/assets/{jison-BX-IOQpJ.js → jison-CwQ0BO-q.js} +1 -1
- package/dist/studio/assets/{json-dOrE-En8.js → json-Je3YfUTE.js} +1 -1
- package/dist/studio/assets/{jsx-BSTPfqWX.js → jsx-Da-dLbW1.js} +1 -1
- package/dist/studio/assets/{julia-Dvz-BPmf.js → julia-CBJ0H-0z.js} +1 -1
- package/dist/studio/assets/{just-BHQm0Atq.js → just-CnuRC_nd.js} +1 -1
- package/dist/studio/assets/{latex-CxdhxuXv.js → latex-gZANCito.js} +1 -1
- package/dist/studio/assets/{liquid-D-hM-Q_F.js → liquid-0U9aXoFI.js} +1 -1
- package/dist/studio/assets/{lua-5qtqjLHq.js → lua-CX_TqMxt.js} +1 -1
- package/dist/studio/assets/{marko-5FJaM2co.js → marko-StSURz0o.js} +1 -1
- package/dist/studio/assets/{mdc-BhYW7lCG.js → mdc-CXZpf9k1.js} +1 -1
- package/dist/studio/assets/mermaid-GHXKKRXX-CqDQH2-r.js +1 -0
- package/dist/studio/assets/{nginx-rtAXrRye.js → nginx-3Q2L4366.js} +1 -1
- package/dist/studio/assets/{nim-DQSmaN9U.js → nim-CqX_5eXP.js} +1 -1
- package/dist/studio/assets/{perl-B54AdcaE.js → perl-CLOu1GnZ.js} +1 -1
- package/dist/studio/assets/{php-DpvTxCny.js → php-C1vkiu4h.js} +1 -1
- package/dist/studio/assets/{pug-Cyffw0Ho.js → pug-Cg3cFp5y.js} +1 -1
- package/dist/studio/assets/{qml-CxRetSkO.js → qml-DhKeHMwt.js} +1 -1
- package/dist/studio/assets/{r-CXWRxrXc.js → r--Lg2-Sir.js} +1 -1
- package/dist/studio/assets/{razor-BJzI-zc9.js → razor-Cjptf146.js} +1 -1
- package/dist/studio/assets/{regexp-dqxdfrnE.js → regexp-fS0DAwei.js} +1 -1
- package/dist/studio/assets/{rst-BW7eKYj4.js → rst-BBajBzk-.js} +1 -1
- package/dist/studio/assets/{ruby-D5Npyj8-.js → ruby-KvFedogM.js} +1 -1
- package/dist/studio/assets/{sas-DZLppjul.js → sas-D6p27LWr.js} +1 -1
- package/dist/studio/assets/{scss-CbqoxyAe.js → scss-6jXfJVsd.js} +1 -1
- package/dist/studio/assets/{shellscript-CFHqBeXu.js → shellscript-BK0Qbt1B.js} +1 -1
- package/dist/studio/assets/{shellsession-CbZDA4Bf.js → shellsession-BsXmVRU4.js} +1 -1
- package/dist/studio/assets/{soy-PImjtV58.js → soy-BKtGCXkJ.js} +1 -1
- package/dist/studio/assets/{sql-DhGo8urW.js → sql-vSUKslBj.js} +1 -1
- package/dist/studio/assets/{stata-CjHWbU2v.js → stata-BQ0iXcs9.js} +1 -1
- package/dist/studio/assets/{surrealql-o8Qr4t56.js → surrealql-v5pXHIwP.js} +1 -1
- package/dist/studio/assets/{svelte-DlSIyEV1.js → svelte-BMFjqgJb.js} +1 -1
- package/dist/studio/assets/{templ-qizfwU1w.js → templ-DYMTOmIJ.js} +1 -1
- package/dist/studio/assets/{tex-Ca7T661H.js → tex-BoQem9gj.js} +1 -1
- package/dist/studio/assets/{ts-tags-DUmjLkgl.js → ts-tags-Kp2pAlsd.js} +1 -1
- package/dist/studio/assets/{tsx-CfwgIqHW.js → tsx-DaB2J5uo.js} +1 -1
- package/dist/studio/assets/{twig-D7NAYUBY.js → twig-DohCGJPH.js} +1 -1
- package/dist/studio/assets/{typescript-Bbz9oX-P.js → typescript-BGG-5I-T.js} +1 -1
- package/dist/studio/assets/{vue-vYpz06zQ.js → vue-CCDLUl9R.js} +1 -1
- package/dist/studio/assets/{vue-html-CcxTb_Jn.js → vue-html-et9GYlaF.js} +1 -1
- package/dist/studio/assets/{vue-vine-DW4RqCKF.js → vue-vine-C561z6bx.js} +1 -1
- package/dist/studio/assets/{xml-R4LZ_u4f.js → xml-CJBA1ZPm.js} +1 -1
- package/dist/studio/assets/{xsl-CS-xzp3L.js → xsl-De-lf9XG.js} +1 -1
- package/dist/studio/assets/{yaml-CqDWbYXd.js → yaml-BcMKxf75.js} +1 -1
- package/dist/studio/index.html +1 -1
- package/dist/think.d.ts +2 -2
- package/dist/think.js +176 -44
- package/dist/think.js.map +1 -1
- package/dist/workflows.d.ts +1 -1
- package/docs/getting-started.md +11 -11
- package/docs/index.md +10 -13
- package/docs/lifecycle-hooks.md +14 -12
- package/docs/messengers.md +52 -0
- package/package.json +8 -7
- package/dist/chat-sdk-D6cUghsQ.js.map +0 -1
- package/dist/studio/assets/mermaid-GHXKKRXX-CWM2EB-u.js +0 -1
|
@@ -309,6 +309,20 @@ interface ChatOptions {
|
|
|
309
309
|
onClientToolCall?: ClientToolExecutor;
|
|
310
310
|
/** Channel id this turn belongs to. See {@link RunTurnBase.channel}. */
|
|
311
311
|
channel?: string;
|
|
312
|
+
/**
|
|
313
|
+
* Server-supplied metadata for this turn. Persisted on the turn's user
|
|
314
|
+
* message alongside {@link ChatOptions.channel} (as `metadata.turnMetadata`)
|
|
315
|
+
* so a recovered/continued turn re-resolves it from durable history, and
|
|
316
|
+
* readable during the turn via {@link Think.activeTurnMetadata}.
|
|
317
|
+
*
|
|
318
|
+
* Trust contract mirrors the channel stamp: only server-side callers can set
|
|
319
|
+
* it — reserved metadata keys on client-supplied messages are stripped at
|
|
320
|
+
* intake. This gives messenger/RPC entry points (e.g.
|
|
321
|
+
* {@link Think.chatWithMessengerContext}) a per-turn, recovery-safe carrier
|
|
322
|
+
* for facts like "which authenticated principal initiated this turn" without
|
|
323
|
+
* resorting to mutable agent-wide state.
|
|
324
|
+
*/
|
|
325
|
+
metadata?: Record<string, unknown>;
|
|
312
326
|
}
|
|
313
327
|
/** Input accepted by {@link Think.runTurn}. */
|
|
314
328
|
type TurnInputMessages =
|
|
@@ -745,8 +759,12 @@ interface TurnContext {
|
|
|
745
759
|
* All fields are optional — return only what you want to change.
|
|
746
760
|
*/
|
|
747
761
|
interface TurnConfig {
|
|
748
|
-
/**
|
|
749
|
-
|
|
762
|
+
/**
|
|
763
|
+
* Override the model for this turn (e.g. cheap model for continuations).
|
|
764
|
+
* Accepts a model id string (resolved via the built-in provider, same rules
|
|
765
|
+
* as {@link Think.getModel}) or a `LanguageModel`.
|
|
766
|
+
*/
|
|
767
|
+
model?: ThinkModel;
|
|
750
768
|
/** Override the assembled system prompt. */
|
|
751
769
|
system?: string;
|
|
752
770
|
/** Override the assembled messages. */
|
|
@@ -973,8 +991,17 @@ type PrepareStepContext<TOOLS extends ToolSet = ToolSet> = Parameters<
|
|
|
973
991
|
* return only the fields you want to override (`model`, `toolChoice`,
|
|
974
992
|
* `activeTools`, `system`, `messages`, `experimental_context`,
|
|
975
993
|
* `providerOptions`).
|
|
994
|
+
*
|
|
995
|
+
* `model` is widened to {@link ThinkModel}: like {@link Think.getModel}, you
|
|
996
|
+
* can return a model id string (resolved via the built-in provider) instead of
|
|
997
|
+
* a `LanguageModel`. Think resolves it before handing the step to the AI SDK.
|
|
976
998
|
*/
|
|
977
|
-
type StepConfig<TOOLS extends ToolSet = ToolSet> =
|
|
999
|
+
type StepConfig<TOOLS extends ToolSet = ToolSet> = Omit<
|
|
1000
|
+
PrepareStepResult<TOOLS>,
|
|
1001
|
+
"model"
|
|
1002
|
+
> & {
|
|
1003
|
+
model?: ThinkModel;
|
|
1004
|
+
};
|
|
978
1005
|
/**
|
|
979
1006
|
* Context passed to the `beforeToolCall` hook **before** the tool's
|
|
980
1007
|
* `execute` function runs.
|
|
@@ -1168,6 +1195,36 @@ interface ExtensionConfig {
|
|
|
1168
1195
|
*
|
|
1169
1196
|
* @experimental The API surface may change before stabilizing.
|
|
1170
1197
|
*/
|
|
1198
|
+
/**
|
|
1199
|
+
* Keys of the global `AiModels` interface (from `@cloudflare/workers-types`)
|
|
1200
|
+
* whose model type extends `T`. Mirrors the derivation `workers-ai-provider`
|
|
1201
|
+
* uses, so the set stays in sync with the installed workers-types version.
|
|
1202
|
+
*/
|
|
1203
|
+
type WorkersAIModelIdsExtending<T> = {
|
|
1204
|
+
[K in keyof AiModels]: AiModels[K] extends T ? K : never;
|
|
1205
|
+
}[keyof AiModels];
|
|
1206
|
+
/**
|
|
1207
|
+
* A model id accepted by {@link Think.getModel}.
|
|
1208
|
+
*
|
|
1209
|
+
* Provides editor autocomplete for the Workers AI text-generation catalog
|
|
1210
|
+
* (`@cf/...`) while still accepting **any** string — including
|
|
1211
|
+
* `"<provider>/<model>"` AI Gateway slugs like `"openai/gpt-5.5"`, whose
|
|
1212
|
+
* validity is only known at runtime (the catalog is server-side and changes
|
|
1213
|
+
* independently of these types). The `(string & {})` arm is what keeps
|
|
1214
|
+
* arbitrary strings assignable without collapsing the autocomplete union.
|
|
1215
|
+
*/
|
|
1216
|
+
type ThinkModelId =
|
|
1217
|
+
| Exclude<
|
|
1218
|
+
WorkersAIModelIdsExtending<BaseAiTextGeneration>,
|
|
1219
|
+
WorkersAIModelIdsExtending<BaseAiTextToImage>
|
|
1220
|
+
>
|
|
1221
|
+
| (string & {});
|
|
1222
|
+
/**
|
|
1223
|
+
* What {@link Think.getModel} may return: either a fully-constructed AI SDK
|
|
1224
|
+
* `LanguageModel`, or a {@link ThinkModelId} string resolved through Think's
|
|
1225
|
+
* built-in `workers-ai-provider`. Also the input type of {@link Think.resolveModel}.
|
|
1226
|
+
*/
|
|
1227
|
+
type ThinkModel = LanguageModel | ThinkModelId;
|
|
1171
1228
|
declare class Think<
|
|
1172
1229
|
Env extends Cloudflare.Env = Cloudflare.Env,
|
|
1173
1230
|
State = unknown,
|
|
@@ -1707,10 +1764,69 @@ declare class Think<
|
|
|
1707
1764
|
private _configGet;
|
|
1708
1765
|
private _configDelete;
|
|
1709
1766
|
/**
|
|
1710
|
-
* Return the
|
|
1711
|
-
*
|
|
1767
|
+
* Return the model to use for inference. Must be overridden by subclasses.
|
|
1768
|
+
*
|
|
1769
|
+
* The return value can be either:
|
|
1770
|
+
*
|
|
1771
|
+
* - A **string** model id, resolved through the built-in
|
|
1772
|
+
* {@link https://www.npmjs.com/package/workers-ai-provider | workers-ai-provider}
|
|
1773
|
+
* off your `AI` binding (see {@link getAIBinding}). A `@cf/...` id hits
|
|
1774
|
+
* Workers AI directly; any other `"<provider>/<model>"` slug — e.g.
|
|
1775
|
+
* `"openai/gpt-5.5"`, `"anthropic/claude-sonnet-4-5"`, `"google/gemini-2.5-pro"`
|
|
1776
|
+
* — is routed through AI Gateway with resumable streaming on by default.
|
|
1777
|
+
* This is the common case: no extra package to install, no provider to wire.
|
|
1778
|
+
* - A fully-constructed AI SDK `LanguageModel`, for any other provider or for
|
|
1779
|
+
* full control over provider/gateway options.
|
|
1780
|
+
*
|
|
1781
|
+
* @example String (Workers AI)
|
|
1782
|
+
* ```typescript
|
|
1783
|
+
* getModel() {
|
|
1784
|
+
* return "@cf/moonshotai/kimi-k2.7-code";
|
|
1785
|
+
* }
|
|
1786
|
+
* ```
|
|
1787
|
+
*
|
|
1788
|
+
* @example String (third-party via AI Gateway)
|
|
1789
|
+
* ```typescript
|
|
1790
|
+
* getModel() {
|
|
1791
|
+
* return "openai/gpt-5.5";
|
|
1792
|
+
* }
|
|
1793
|
+
* ```
|
|
1794
|
+
*
|
|
1795
|
+
* @example Bring your own provider
|
|
1796
|
+
* ```typescript
|
|
1797
|
+
* import { createOpenAI } from "@ai-sdk/openai";
|
|
1798
|
+
* getModel() {
|
|
1799
|
+
* return createOpenAI({ apiKey: this.env.OPENAI_API_KEY })("gpt-5.5");
|
|
1800
|
+
* }
|
|
1801
|
+
* ```
|
|
1802
|
+
*/
|
|
1803
|
+
getModel(): ThinkModel;
|
|
1804
|
+
/**
|
|
1805
|
+
* Return the Workers AI binding used by the built-in default provider when
|
|
1806
|
+
* {@link getModel} returns a string. Defaults to `this.env.AI`. Override if
|
|
1807
|
+
* your binding is named something other than `AI`.
|
|
1712
1808
|
*/
|
|
1713
|
-
|
|
1809
|
+
getAIBinding(): Ai;
|
|
1810
|
+
/**
|
|
1811
|
+
* Lazily-constructed, instance-cached default provider. Bundles the `openai`
|
|
1812
|
+
* and `anthropic` wire-format plugins so a `"<provider>/<model>"` slug routes
|
|
1813
|
+
* through AI Gateway out of the box (covers OpenAI, Anthropic, Google,
|
|
1814
|
+
* xAI/Grok, Groq, and the OpenAI-compatible long tail).
|
|
1815
|
+
*
|
|
1816
|
+
* Cached per instance, which assumes {@link getAIBinding} is stable for the
|
|
1817
|
+
* lifetime of the agent (the default `this.env.AI` always is).
|
|
1818
|
+
*/
|
|
1819
|
+
private _defaultProvider?;
|
|
1820
|
+
/**
|
|
1821
|
+
* Resolve a model value into a concrete AI SDK `LanguageModel`.
|
|
1822
|
+
*
|
|
1823
|
+
* Defaults to resolving {@link getModel}. A `LanguageModel` is returned as-is;
|
|
1824
|
+
* a string is built through the bundled default provider (see {@link getModel}
|
|
1825
|
+
* for the slug rules). Use this whenever you need a usable model outside the
|
|
1826
|
+
* main turn — e.g. a side `generateText` call for summarization/compaction —
|
|
1827
|
+
* since `getModel()` may return a bare string.
|
|
1828
|
+
*/
|
|
1829
|
+
resolveModel(model?: ThinkModel): LanguageModel;
|
|
1714
1830
|
/**
|
|
1715
1831
|
* Return the system prompt for the assistant.
|
|
1716
1832
|
* Used as fallback when no context blocks are configured via `configureSession`.
|
|
@@ -1750,6 +1866,14 @@ declare class Think<
|
|
|
1750
1866
|
* Readable from tools/hooks during a turn (e.g. to branch on `kind`).
|
|
1751
1867
|
*/
|
|
1752
1868
|
get activeChannel(): ChannelContext | undefined;
|
|
1869
|
+
/**
|
|
1870
|
+
* The server-supplied metadata stamped on the active turn's user message
|
|
1871
|
+
* ({@link ChatOptions.metadata}). Like the channel stamp, it is persisted on
|
|
1872
|
+
* the durable user message, so recovered/continued turns re-resolve the same
|
|
1873
|
+
* value; client-supplied message metadata can never populate it (reserved
|
|
1874
|
+
* keys are stripped at intake). `undefined` when the turn carried none.
|
|
1875
|
+
*/
|
|
1876
|
+
get activeTurnMetadata(): Record<string, unknown> | undefined;
|
|
1753
1877
|
/** Resolve a channel id to a turn-scoped {@link ChannelContext}, if registered. */
|
|
1754
1878
|
private _resolveChannelContext;
|
|
1755
1879
|
/**
|
|
@@ -1759,12 +1883,17 @@ declare class Think<
|
|
|
1759
1883
|
*/
|
|
1760
1884
|
private _withChannelContext;
|
|
1761
1885
|
/**
|
|
1762
|
-
* Stamp the channel id
|
|
1763
|
-
* re-resolve
|
|
1886
|
+
* Stamp the channel id — and, when supplied, the caller's turn metadata —
|
|
1887
|
+
* onto user messages so a recovered/continued turn can re-resolve both from
|
|
1888
|
+
* durable history.
|
|
1764
1889
|
*/
|
|
1765
1890
|
private _stampChannel;
|
|
1891
|
+
/** Metadata of the latest user message in the given list, if any. */
|
|
1892
|
+
private _latestUserMessageMetadata;
|
|
1766
1893
|
/** The channel stamped on the latest user message in the given list, if any. */
|
|
1767
1894
|
private _channelFromMessages;
|
|
1895
|
+
/** The turn metadata stamped on the latest user message, if any. */
|
|
1896
|
+
private _turnMetadataFromMessages;
|
|
1768
1897
|
/** Re-resolve the channel for a continuation from the latest user message. */
|
|
1769
1898
|
private _channelFromLatestUserMessage;
|
|
1770
1899
|
/**
|
|
@@ -3011,6 +3140,13 @@ declare class Think<
|
|
|
3011
3140
|
* instead of inserting an orphan duplicate.
|
|
3012
3141
|
*/
|
|
3013
3142
|
private _persistIncomingMessage;
|
|
3143
|
+
/**
|
|
3144
|
+
* Strip {@link RESERVED_MESSAGE_METADATA_KEYS} from a client-supplied message
|
|
3145
|
+
* at intake. Those keys are server-written turn context (stamped by
|
|
3146
|
+
* `_stampChannel`) that hooks and recovery re-resolve and trust, so a client
|
|
3147
|
+
* must never be able to forge them.
|
|
3148
|
+
*/
|
|
3149
|
+
private _stripReservedMessageMetadata;
|
|
3014
3150
|
private _persistClientTools;
|
|
3015
3151
|
private _restoreClientTools;
|
|
3016
3152
|
private _persistBody;
|
|
@@ -3697,6 +3833,14 @@ interface MessengerAuthor {
|
|
|
3697
3833
|
interface MessengerAttachment {
|
|
3698
3834
|
data?: ArrayBuffer;
|
|
3699
3835
|
fetch?: () => Promise<ArrayBuffer>;
|
|
3836
|
+
/**
|
|
3837
|
+
* Platform-specific metadata needed to re-fetch the attachment after the
|
|
3838
|
+
* event has been serialized (e.g. across a sub-agent Durable Object hop).
|
|
3839
|
+
* Adapters store identifiers here — Telegram `fileId`, WhatsApp `mediaId`,
|
|
3840
|
+
* etc. — that survive serialization even when `fetch`, `data`, and `raw`
|
|
3841
|
+
* cannot, so a downstream agent can reconstruct the download closure.
|
|
3842
|
+
*/
|
|
3843
|
+
fetchMetadata?: Record<string, string>;
|
|
3700
3844
|
id?: string;
|
|
3701
3845
|
mediaType?: string;
|
|
3702
3846
|
name?: string;
|
|
@@ -3757,7 +3901,23 @@ declare function messengerContextFromEvent(
|
|
|
3757
3901
|
declare function serializableMessengerEvent(
|
|
3758
3902
|
event: MessengerEvent
|
|
3759
3903
|
): MessengerEvent;
|
|
3760
|
-
|
|
3904
|
+
/**
|
|
3905
|
+
* Customizes how channel (non-DM) speaker names are prefixed onto model-facing
|
|
3906
|
+
* text. By default, speaker labels use `fullName || userName || userId`.
|
|
3907
|
+
* Direct messages never get a speaker prefix, regardless of this setting.
|
|
3908
|
+
* Return `null`/empty to suppress the prefix for that author.
|
|
3909
|
+
*/
|
|
3910
|
+
type ChannelSpeakerLabel = (
|
|
3911
|
+
author: MessengerAuthor
|
|
3912
|
+
) => string | null | undefined;
|
|
3913
|
+
declare function resolveChannelSpeakerLabel(
|
|
3914
|
+
author: MessengerAuthor | undefined,
|
|
3915
|
+
channelSpeakerLabel?: ChannelSpeakerLabel
|
|
3916
|
+
): string | undefined;
|
|
3917
|
+
declare function toMessengerUserMessage(
|
|
3918
|
+
event: MessengerEvent,
|
|
3919
|
+
channelSpeakerLabel?: ChannelSpeakerLabel
|
|
3920
|
+
): UIMessage;
|
|
3761
3921
|
//#endregion
|
|
3762
3922
|
//#region src/messengers/delivery.d.ts
|
|
3763
3923
|
declare const MESSENGER_REPLY_FIBER_NAME = "think:messenger-reply";
|
|
@@ -3933,6 +4093,14 @@ interface MessengerDefinition {
|
|
|
3933
4093
|
adapter: Adapter;
|
|
3934
4094
|
adapterName: string;
|
|
3935
4095
|
capabilities?: MessengerCapabilities;
|
|
4096
|
+
/**
|
|
4097
|
+
* Customizes how non-DM channel messages are labelled for the model.
|
|
4098
|
+
*
|
|
4099
|
+
* Channel (group) messages use `fullName || userName || userId` by default and
|
|
4100
|
+
* are rendered as `SpeakerName: text` so the model can attribute multi-user
|
|
4101
|
+
* traffic. Direct messages never get a prefix.
|
|
4102
|
+
*/
|
|
4103
|
+
channelSpeakerLabel?: ChannelSpeakerLabel;
|
|
3936
4104
|
conversation?: MessengerConversationMode | MessengerConversationResolver;
|
|
3937
4105
|
delivery?: MessengerDeliveryPolicy;
|
|
3938
4106
|
keyShard?: ChatSdkStateAdapterOptions["keyShard"];
|
|
@@ -4061,6 +4229,24 @@ declare function defaultChatSdkEvent(
|
|
|
4061
4229
|
definition: NormalizedMessengerDefinition,
|
|
4062
4230
|
input: ChatSdkMessengerEventInput
|
|
4063
4231
|
): MessengerEvent;
|
|
4232
|
+
/**
|
|
4233
|
+
* Rewrite the bot's own unresolved self-mention to `@<userName>`.
|
|
4234
|
+
*
|
|
4235
|
+
* Adapters resolve every user's `<@id>` mention to a readable `@DisplayName`
|
|
4236
|
+
* except the bot's own, which is deliberately left as a raw id token so mention
|
|
4237
|
+
* detection can still find it. That raw id is therefore the only unresolved
|
|
4238
|
+
* mention that can survive in the text, so once it has served its purpose we
|
|
4239
|
+
* replace it with the bot's configured handle before the model sees it —
|
|
4240
|
+
* reconstructing the readable `@handle` the sender originally typed. Handles
|
|
4241
|
+
* both the angle-bracket form (`<@U123>` / `<@!U123>`, Slack/Discord) and the
|
|
4242
|
+
* bare `@U123` form some adapters normalize to. No-op when the adapter does not
|
|
4243
|
+
* expose a `botUserId`.
|
|
4244
|
+
*/
|
|
4245
|
+
declare function resolveSelfMention(
|
|
4246
|
+
text: string,
|
|
4247
|
+
botUserId: string | undefined,
|
|
4248
|
+
userName: string
|
|
4249
|
+
): string;
|
|
4064
4250
|
declare function toMessengerThread(thread: Thread): MessengerThread;
|
|
4065
4251
|
declare function toMessengerMessage(message: Message): MessengerMessage;
|
|
4066
4252
|
declare function toMessengerAuthor(author: Author): MessengerAuthor;
|
|
@@ -4069,154 +4255,159 @@ declare function toMessengerAttachment(
|
|
|
4069
4255
|
): MessengerAttachment;
|
|
4070
4256
|
//#endregion
|
|
4071
4257
|
export {
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
MessengerAuthor as
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
ChannelContext as
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
defaultContextOverflowClassifier as
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4258
|
+
MessengerMessage as $,
|
|
4259
|
+
SkillSource$1 as $t,
|
|
4260
|
+
MESSENGER_REPLY_FIBER_NAME as A,
|
|
4261
|
+
TypedToolResult as An,
|
|
4262
|
+
DeliverNoticeOptions as At,
|
|
4263
|
+
messengerReplyFailureMode as B,
|
|
4264
|
+
ChannelDeliverySurface as Bn,
|
|
4265
|
+
PrepareStepResult$1 as Bt,
|
|
4266
|
+
toMessengerThread as C,
|
|
4267
|
+
ToolCallResultContext as Cn,
|
|
4268
|
+
ChatRecoveryProgressContext as Ct,
|
|
4269
|
+
EMPTY_MESSENGER_RESPONSE as D,
|
|
4270
|
+
TurnInputMessages as Dn,
|
|
4271
|
+
ChunkPart as Dt,
|
|
4272
|
+
DeliveryTag as E,
|
|
4273
|
+
TurnInput as En,
|
|
4274
|
+
ChunkContext as Et,
|
|
4275
|
+
MessengerReplyStage as F,
|
|
4276
|
+
skills as Fn,
|
|
4277
|
+
MessageConcurrency$1 as Ft,
|
|
4278
|
+
ChannelSpeakerLabel as G,
|
|
4279
|
+
messengerChannel as Gn,
|
|
4280
|
+
RunTurnStream as Gt,
|
|
4281
|
+
messengerReplySnapshot as H,
|
|
4282
|
+
ChannelKind as Hn,
|
|
4283
|
+
ResolvedChatRecoveryConfig as Ht,
|
|
4284
|
+
TextStreamCallback as I,
|
|
4285
|
+
ChannelCapabilities as In,
|
|
4286
|
+
OnStartDegradation as It,
|
|
4287
|
+
MessengerAuthor as J,
|
|
4288
|
+
SaveMessagesOptions$1 as Jt,
|
|
4289
|
+
MessengerAction as K,
|
|
4290
|
+
MediaEvictionConfig as Kn,
|
|
4291
|
+
RunTurnSubmit as Kt,
|
|
4292
|
+
TextStreamCallbackOptions as L,
|
|
4293
|
+
ChannelContext as Ln,
|
|
4294
|
+
PendingApproval as Lt,
|
|
4295
|
+
MessengerDeliverySurface as M,
|
|
4296
|
+
action as Mn,
|
|
4297
|
+
FiberContext$1 as Mt,
|
|
4298
|
+
MessengerDeliveryTarget as N,
|
|
4299
|
+
defaultContextOverflowClassifier as Nn,
|
|
4300
|
+
FiberRecoveryContext$1 as Nt,
|
|
4301
|
+
ERROR_MESSENGER_RESPONSE as O,
|
|
4302
|
+
TurnResult as On,
|
|
4303
|
+
ContextOverflowConfig as Ot,
|
|
4304
|
+
MessengerReplySnapshot as P,
|
|
4305
|
+
isAction as Pn,
|
|
4306
|
+
ListSubmissionsOptions as Pt,
|
|
4307
|
+
MessengerEventKind as Q,
|
|
4308
|
+
SkillRunContext as Qt,
|
|
4309
|
+
defaultDeliveryTag as R,
|
|
4310
|
+
ChannelDefinition as Rn,
|
|
4311
|
+
PrepareStepContext as Rt,
|
|
4312
|
+
toMessengerMessage as S,
|
|
4313
|
+
ToolCallDecision as Sn,
|
|
4314
|
+
ChatRecoveryOptions$1 as St,
|
|
4315
|
+
DeliveryKind as T,
|
|
4316
|
+
TurnContext as Tn,
|
|
4317
|
+
ChatStartEvent as Tt,
|
|
4318
|
+
parseMessengerReplySnapshot as U,
|
|
4319
|
+
NormalizedChannelDefinition as Un,
|
|
4320
|
+
RunTurnBase as Ut,
|
|
4321
|
+
messengerReplyRecoveryMode as V,
|
|
4322
|
+
ChannelIngress as Vn,
|
|
4323
|
+
ReplyAttachment as Vt,
|
|
4324
|
+
textDeltaFromStreamChunk as W,
|
|
4325
|
+
ThinkChannels as Wn,
|
|
4326
|
+
RunTurnOptions as Wt,
|
|
4327
|
+
MessengerContext as X,
|
|
4328
|
+
Session$1 as Xt,
|
|
4329
|
+
MessengerCapabilities as Y,
|
|
4330
|
+
SaveMessagesResult$1 as Yt,
|
|
4331
|
+
MessengerEvent as Z,
|
|
4332
|
+
SessionMessage$1 as Zt,
|
|
4142
4333
|
idempotencyKeyForEvent as _,
|
|
4143
|
-
|
|
4144
|
-
|
|
4334
|
+
ThinkSubmissionInspection as _n,
|
|
4335
|
+
ChatErrorContext as _t,
|
|
4145
4336
|
MessengerConversationTarget as a,
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4337
|
+
StreamableResult as an,
|
|
4338
|
+
Action as at,
|
|
4339
|
+
toMessengerAttachment as b,
|
|
4340
|
+
ThinkWallClockSchedule as bn,
|
|
4341
|
+
ChatRecoveryContext$1 as bt,
|
|
4151
4342
|
MessengerThinkHost as c,
|
|
4152
|
-
|
|
4153
|
-
|
|
4343
|
+
TextStreamPart as cn,
|
|
4344
|
+
ActionAuthorizationContext as ct,
|
|
4154
4345
|
ThinkMessengerRuntime as d,
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4346
|
+
ThinkModel as dn,
|
|
4347
|
+
ActionContext as dt,
|
|
4348
|
+
StepConfig as en,
|
|
4349
|
+
MessengerThread as et,
|
|
4159
4350
|
ThinkMessengerStateAgent as f,
|
|
4160
|
-
|
|
4161
|
-
|
|
4351
|
+
ThinkModelId as fn,
|
|
4352
|
+
ActionIdempotencyKey as ft,
|
|
4162
4353
|
defaultConversationName as g,
|
|
4163
|
-
|
|
4164
|
-
|
|
4354
|
+
ThinkScheduledTasks as gn,
|
|
4355
|
+
ChatErrorClassification as gt,
|
|
4165
4356
|
defaultChatSdkEvent as h,
|
|
4166
|
-
|
|
4167
|
-
|
|
4357
|
+
ThinkScheduledTaskSchedule as hn,
|
|
4358
|
+
AddMessagesOptions as ht,
|
|
4168
4359
|
MessengerConversationResolver as i,
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4360
|
+
StreamCallback as in,
|
|
4361
|
+
toMessengerUserMessage as it,
|
|
4362
|
+
MessengerDeliveryPolicy as j,
|
|
4363
|
+
Workspace$1 as jn,
|
|
4364
|
+
ExtensionConfig as jt,
|
|
4365
|
+
INTERRUPTED_MESSENGER_RESPONSE as k,
|
|
4366
|
+
TypedToolCall$1 as kn,
|
|
4367
|
+
DeleteSubmissionsOptions as kt,
|
|
4177
4368
|
MessengerThinkTarget as l,
|
|
4178
|
-
|
|
4179
|
-
|
|
4369
|
+
Think as ln,
|
|
4370
|
+
ActionAuthorizationDecision as lt,
|
|
4180
4371
|
chatSdkMessenger as m,
|
|
4181
|
-
|
|
4182
|
-
|
|
4372
|
+
ThinkScheduledTaskContext as mn,
|
|
4373
|
+
ActionPermissionSpec as mt,
|
|
4183
4374
|
ChatSdkMessengerOptions as n,
|
|
4184
|
-
|
|
4185
|
-
|
|
4375
|
+
StepResult as nn,
|
|
4376
|
+
resolveChannelSpeakerLabel as nt,
|
|
4186
4377
|
MessengerDefinition as o,
|
|
4187
|
-
|
|
4188
|
-
|
|
4378
|
+
SubmitMessagesOptions as on,
|
|
4379
|
+
ActionApprovalDescriptor as ot,
|
|
4189
4380
|
ThinkMessengers as p,
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4381
|
+
ThinkScheduledTask as pn,
|
|
4382
|
+
ActionKind as pt,
|
|
4383
|
+
MessengerAttachment as q,
|
|
4384
|
+
RunTurnWait as qt,
|
|
4194
4385
|
MessengerConversationMode as r,
|
|
4195
|
-
|
|
4196
|
-
|
|
4386
|
+
StopCondition$1 as rn,
|
|
4387
|
+
serializableMessengerEvent as rt,
|
|
4197
4388
|
MessengerRespondTo as s,
|
|
4198
|
-
|
|
4199
|
-
|
|
4389
|
+
SubmitMessagesResult as sn,
|
|
4390
|
+
ActionApprovalPolicy as st,
|
|
4200
4391
|
ChatSdkMessengerEventInput as t,
|
|
4201
|
-
|
|
4202
|
-
|
|
4392
|
+
StepContext as tn,
|
|
4393
|
+
messengerContextFromEvent as tt,
|
|
4203
4394
|
NormalizedMessengerDefinition as u,
|
|
4204
|
-
|
|
4205
|
-
|
|
4395
|
+
ThinkIntervalSchedule as un,
|
|
4396
|
+
ActionConfig as ut,
|
|
4206
4397
|
normalizeMessengers as v,
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4398
|
+
ThinkSubmissionStatus as vn,
|
|
4399
|
+
ChatOptions as vt,
|
|
4400
|
+
DeliverMessengerReplyOptions as w,
|
|
4401
|
+
TurnConfig as wn,
|
|
4402
|
+
ChatResponseResult$1 as wt,
|
|
4403
|
+
toMessengerAuthor as x,
|
|
4404
|
+
ToolCallContext as xn,
|
|
4405
|
+
ChatRecoveryExhaustedContext as xt,
|
|
4406
|
+
resolveSelfMention as y,
|
|
4407
|
+
ThinkTime as yn,
|
|
4408
|
+
ChatRecoveryConfig$1 as yt,
|
|
4409
|
+
deliverMessengerReply as z,
|
|
4410
|
+
ChannelDeliveryPolicy as zn,
|
|
4411
|
+
PrepareStepFunction$1 as zt
|
|
4221
4412
|
};
|
|
4222
|
-
//# sourceMappingURL=index-
|
|
4413
|
+
//# sourceMappingURL=index-Cm0jriTY.d.ts.map
|