@cloudflare/think 0.8.0 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  i as ExtensionManifest,
3
3
  t as ExtensionManager
4
- } from "./manager-C1zjft70.js";
4
+ } from "./manager-dOcdCX4u.js";
5
5
  import {
6
6
  D as createWorkspaceTools,
7
7
  h as WorkspaceLike
8
- } from "./workspace-Bri0ANBX.js";
8
+ } from "./workspace-BZXdZcuw.js";
9
9
  import {
10
10
  LanguageModel,
11
11
  ModelMessage,
@@ -682,12 +682,14 @@ declare class Think<
682
682
  /**
683
683
  * Normalize a tool part's `input` into something the provider will accept.
684
684
  *
685
- * Two malformed shapes 400 modern providers (and persist forever once
686
- * written): a stringified-JSON `input` (e.g. `'{"prompt":"a cat"}'` instead
687
- * of the object) and a missing/`null` `input` on a settled or interrupted
688
- * tool call (Anthropic rejects a `tool_use` block whose `input` is absent).
689
- * We parse the former and default the latter to an empty object so the
690
- * tool-call/tool-result pair stays valid. Any other value is left untouched.
685
+ * Malformed shapes 400 modern providers and persist forever once written:
686
+ * a stringified-JSON `input` (e.g. `'{"prompt":"a cat"}'` instead of the
687
+ * object), and any non-object `input` — `null`, `undefined`, `""`, an array,
688
+ * or a primitive — on a settled or interrupted tool call (Anthropic rejects
689
+ * a `tool_use` block whose `input` is not an object). We parse the former and
690
+ * default the latter to an empty object so the tool-call/tool-result pair
691
+ * stays valid. Delegates to the shared `normalizeToolInput` so the read-side
692
+ * repair and the write-side accumulator guard enforce the same invariant.
691
693
  */
692
694
  private _normalizeToolInput;
693
695
  /**
@@ -776,6 +778,8 @@ declare class Think<
776
778
  private _insideResponseHook;
777
779
  private _insideInferenceLoop;
778
780
  private _pendingInteractionPromise;
781
+ private _interactionApplyTail;
782
+ private _streamingAssistant;
779
783
  private _submitConcurrency;
780
784
  private static MESSAGE_DEBOUNCE_MS;
781
785
  private _agentToolForwarders;
@@ -1322,6 +1326,7 @@ declare class Think<
1322
1326
  private _insertWorkflowNotification;
1323
1327
  private _recoverWorkflowNotifications;
1324
1328
  private _startWorkflowNotificationDrain;
1329
+ private _hasPendingWorkflowNotifications;
1325
1330
  private _drainWorkflowNotifications;
1326
1331
  private _scheduleWorkflowNotificationAlarm;
1327
1332
  inspectSubmission(
@@ -1341,6 +1346,7 @@ declare class Think<
1341
1346
  ): Promise<SubmitMessagesResult>;
1342
1347
  private _scheduleSubmissionDrain;
1343
1348
  private _startSubmissionDrain;
1349
+ private _hasPendingSubmissions;
1344
1350
  _drainThinkSubmissions(): Promise<void>;
1345
1351
  private _drainSubmissions;
1346
1352
  private _runSubmission;
@@ -1519,6 +1525,27 @@ declare class Think<
1519
1525
  private _restoreClientTools;
1520
1526
  private _persistBody;
1521
1527
  private _restoreBody;
1528
+ /**
1529
+ * Serialize a client-tool result/approval apply behind any in-flight apply
1530
+ * (#1649). Parallel tool results arrive as independent WebSocket messages,
1531
+ * and each apply is a read-modify-write of the full message in durable
1532
+ * storage. Running them concurrently means every apply reads the same
1533
+ * snapshot (all siblings still `input-available`), patches only its own part,
1534
+ * and writes the whole message back — so the last write clobbers the others
1535
+ * back to `input-available`, and the auto-continuation barrier later times
1536
+ * out and the transcript-repair backstop errors the lost siblings.
1537
+ *
1538
+ * Chaining each apply off `_interactionApplyTail` makes the read-modify-write
1539
+ * atomic per result and in arrival order. `_pendingInteractionPromise` is set
1540
+ * to the newest link so the barrier's single-slot wake-up still observes the
1541
+ * latest apply; because the chain is serial, awaiting it transitively waits
1542
+ * for every predecessor.
1543
+ *
1544
+ * @internal
1545
+ */
1546
+ protected _enqueueInteractionApply(
1547
+ apply: () => Promise<void>
1548
+ ): Promise<boolean>;
1522
1549
  private _applyToolResult;
1523
1550
  private _applyToolApproval;
1524
1551
  private _applyToolUpdateToMessages;
@@ -1526,6 +1553,38 @@ declare class Think<
1526
1553
  protected waitUntilStable(options?: { timeout?: number }): Promise<boolean>;
1527
1554
  private _awaitWithDeadline;
1528
1555
  private _messageHasPendingInteraction;
1556
+ /**
1557
+ * Names of the tools whose interrupted `input-available` part can still be
1558
+ * resolved by the CLIENT after a restart — i.e. the client tools (no server
1559
+ * `execute`) from the last request, which the SPA answers by replaying a
1560
+ * `tool-result` over the WebSocket. A server tool is intentionally absent:
1561
+ * its `execute()` promise died with the evicted isolate, so nothing will
1562
+ * ever post its result.
1563
+ */
1564
+ private _clientResolvableToolNames;
1565
+ /** Extract a tool part's name from its `tool-<name>` / `dynamic-tool` shape. */
1566
+ private _toolPartName;
1567
+ /**
1568
+ * Whether a part is still awaiting a CLIENT interaction that can genuinely
1569
+ * arrive after a restart, so `waitUntilStable` must keep waiting for it:
1570
+ * - `approval-requested`: a reconnecting client can replay the approval.
1571
+ * - `input-available` for a CLIENT tool: the SPA can replay the
1572
+ * `tool-result` (this is why client-tool recovery works — see the
1573
+ * `tool-result` handler, which sets `_pendingInteractionPromise`).
1574
+ *
1575
+ * A SERVER tool's `input-available` is deliberately NOT pending. After an
1576
+ * eviction its `execute()` promise is gone and no interaction will ever
1577
+ * resolve it, so treating it as pending wedges `waitUntilStable` forever:
1578
+ * the recovery continuation times out every attempt, burns the attempt
1579
+ * budget on a wait that can never converge, and — if any transient
1580
+ * storage/schedule error throws on the way — the one-shot recovery alarm row
1581
+ * is swallowed and deleted with no terminal `onExhausted` (the half-finished
1582
+ * message wedges silently). Excluding it lets `waitUntilStable` converge so
1583
+ * `continueLastTurn` runs, where the existing transcript-repair pass
1584
+ * (`_repairTranscriptForProvider`) flips the orphan to an errored result and
1585
+ * the model proceeds.
1586
+ */
1587
+ private _partAwaitsClientInteraction;
1529
1588
  private _resolveChatRecoveryConfig;
1530
1589
  private _chatRecoveryIncidentId;
1531
1590
  private _chatRecoveryIncidentKey;
@@ -1626,19 +1685,26 @@ declare class Think<
1626
1685
  */
1627
1686
  private _resolveRecoveryStreamId;
1628
1687
  /**
1629
- * Terminalize a recovery turn that has run out of stable-state-timeout retry
1630
- * budget — or whose incident record has vanished — by routing through the
1631
- * SAME `_exhaustChatRecovery` path as deploy-recovery and stall exhaustion
1688
+ * Terminalize a recovery turn that is giving up — whether because the
1689
+ * stable-state-timeout retry budget drained, or because the recovery
1690
+ * continuation threw a non-recoverable error — by routing through the SAME
1691
+ * `_exhaustChatRecovery` path as deploy-recovery and stall exhaustion
1632
1692
  * (#1626/#1631). It fires `onExhausted`, emits `chat:recovery:exhausted`,
1633
1693
  * marks the durable submission interrupted, records the terminal chat status,
1634
- * and delivers the configured `terminalMessage`.
1694
+ * and delivers the configured `terminalMessage`. `reason` carries the cause
1695
+ * (`stable_timeout` for a budget give-up, `recovery_error` for a thrown
1696
+ * error) through to `onExhausted` / `chat:recovery:exhausted`.
1635
1697
  *
1636
1698
  * This replaces the older give-up that only set the incident to `failed` and
1637
1699
  * completed the recovered submission as `error`, which bypassed
1638
1700
  * `_exhaustChatRecovery` entirely — so an app relying on `onExhausted` for the
1639
1701
  * terminal banner regressed to an eternal spinner when recovery gave up under
1640
- * extreme churn (the stable-state wait timing out every attempt until the
1641
- * budget drained). Shared by `_chatRecoveryRetry` and `_chatRecoveryContinue`.
1702
+ * extreme churn. The error path matters just as much: a non-reset throw in a
1703
+ * recovery callback is SWALLOWED by `Agent._executeScheduleCallback` (only a
1704
+ * code-update reset is re-thrown to preserve the one-shot row), so without
1705
+ * routing it here the alarm row is deleted with no terminal UX at all — the
1706
+ * half-finished message wedges silently. Shared by `_chatRecoveryRetry` and
1707
+ * `_chatRecoveryContinue`.
1642
1708
  *
1643
1709
  * Exactly-once terminalization is defended by two independent guards:
1644
1710
  * 1. The `stored?.status === "exhausted"` re-entry guard below — once an
@@ -1659,7 +1725,48 @@ declare class Think<
1659
1725
  * • The record is swept AGAIN between two alarms (guard #1 re-persists on the
1660
1726
  * first, so this needs a second independent sweep) — vanishingly unlikely.
1661
1727
  */
1728
+ private _exhaustRecoveryGiveUp;
1729
+ /**
1730
+ * Give-up after the stable-state-timeout retry budget drained. Thin wrapper
1731
+ * over `_exhaustRecoveryGiveUp` so the give-up cause is recorded as
1732
+ * `stable_timeout`.
1733
+ */
1662
1734
  private _exhaustRecoveryAfterStableTimeout;
1735
+ /**
1736
+ * Whether an error is a transient "superseded isolate" failure — a deploy /
1737
+ * code update replaced the isolate mid-invocation. Mirrors the base `Agent`
1738
+ * check (`isDurableObjectCodeUpdateReset`) and MUST stay in lockstep with it:
1739
+ * the base `_executeScheduleCallback` re-throws this class for a one-shot row
1740
+ * (preserving it so the platform re-runs on the new code), so a recovery
1741
+ * callback must also re-throw — NOT terminalize — since recovery will re-run
1742
+ * and succeed on the fresh isolate. The matched family (kept identical to the
1743
+ * base):
1744
+ * - "Durable Object reset because its code was updated." (deploy bounce)
1745
+ * - "This script has been upgraded. Please send a new request to connect to
1746
+ * the new version." (a stub/connection to a superseded script)
1747
+ * "Network connection lost." is intentionally excluded (a connection error,
1748
+ * not an isolate replacement — see the base helper's note). The match stays
1749
+ * close to the verbatim platform strings so an ordinary error mentioning
1750
+ * those words isn't misclassified as a supersede.
1751
+ */
1752
+ private _isDeployCodeUpdateReset;
1753
+ /**
1754
+ * Handle an error thrown by `_chatRecoveryContinue` / `_chatRecoveryRetry`
1755
+ * after the incident was opened.
1756
+ *
1757
+ * - A deploy code-update reset is re-thrown (after marking the incident
1758
+ * `failed` for observability) so `Agent._executeScheduleCallback` preserves
1759
+ * the one-shot alarm row and the platform re-runs recovery on the fresh
1760
+ * isolate — the turn can still recover, so it must NOT terminalize.
1761
+ * - Any OTHER error is terminalized through the give-up path
1762
+ * (`onExhausted` + the `terminalMessage` banner) and NOT re-thrown. This is
1763
+ * the fix for the silent-seal failure mode: `_executeScheduleCallback`
1764
+ * swallows a non-reset throw and then `alarm()` deletes the one-shot row, so
1765
+ * without terminalizing here the half-finished turn is dropped with no
1766
+ * terminal event and no banner (the user stares at a frozen message until
1767
+ * they send something new).
1768
+ */
1769
+ private _handleRecoveryCallbackError;
1663
1770
  _chatRecoveryRetry(data?: ChatRecoveryRetryData): Promise<void>;
1664
1771
  private _hasRunningSubmission;
1665
1772
  private _readRunningSubmissionByRequestId;
@@ -1675,6 +1782,33 @@ declare class Think<
1675
1782
  private _completeSkippedRequest;
1676
1783
  private _rollbackDroppedSubmit;
1677
1784
  private _scheduleAutoContinuation;
1785
+ /**
1786
+ * Re-arm the barrier for a tool result/approval that arrived WITHOUT
1787
+ * `autoContinue` (#1650). The client sends `autoContinue: false` for an
1788
+ * errored tool result (it declines to auto-continue a standalone error), but
1789
+ * in a parallel batch a SIBLING may already have requested continuation — and
1790
+ * this result can be the one that completes the batch. In that case we must
1791
+ * re-run the barrier check so the continuation the sibling requested still
1792
+ * fires once the batch is whole.
1793
+ *
1794
+ * Unlike `_scheduleAutoContinuation` this never CREATES a pending
1795
+ * continuation: a standalone errored tool (no opted-in sibling, so no pending)
1796
+ * must not auto-continue. It also no-ops once the continuation is running
1797
+ * (`pastCoalesce`) — a late result then defers/applies through the normal
1798
+ * path rather than re-arming.
1799
+ */
1800
+ private _rearmPendingAutoContinuationForBatch;
1801
+ /**
1802
+ * Called when a streaming assistant turn finalizes (its message, with ALL
1803
+ * tool parts, is now persisted). Clears the in-flight accumulator and re-runs
1804
+ * the auto-continuation barrier for a continuation the stream-active gate held
1805
+ * (#1650). This is essential for an all-fast parallel batch whose every result
1806
+ * landed mid-stream: once the stream ends there is no further tool-result
1807
+ * event to re-arm the barrier, so without this re-check the held continuation
1808
+ * would never fire. A slow batch is also re-checked here and simply continues
1809
+ * to hold (event-driven) until its remaining siblings answer.
1810
+ */
1811
+ private _onStreamingTurnFinalized;
1678
1812
  private _resetAutoContinuationTimer;
1679
1813
  /**
1680
1814
  * Fire an auto-continuation, but only once the model's parallel tool-call
@@ -1683,20 +1817,37 @@ declare class Think<
1683
1817
  * arrives while slower siblings are still `input-available`. Continuing then
1684
1818
  * would feed the provider an incomplete tool-result set
1685
1819
  * (`MissingToolResultsError`) or, via the transcript-repair backstop, silently
1686
- * error the in-flight sibling and run a spurious extra continuation. We hold
1687
- * the continuation on a barrier until the batch settles. The wait is bounded
1688
- * (`AUTO_CONTINUATION_PENDING_TOOL_TIMEOUT_MS`) so a genuinely orphaned tool
1689
- * call — e.g. the client disconnected mid-batch — still falls through to the
1690
- * repair backstop rather than pinning the continuation open forever.
1820
+ * error the in-flight sibling and run a spurious extra continuation.
1821
+ *
1822
+ * The barrier is event-driven (#1650). Auto-continuation is only ever
1823
+ * triggered by a tool-result/approval event, so rather than wait on a fixed
1824
+ * timer we drain the in-flight applies, re-check, and — if the batch is still
1825
+ * incomplete — return WITHOUT firing and WITHOUT holding the isolate, leaving
1826
+ * `_continuation.pending` in place. The next sibling's result re-arms the
1827
+ * coalesce timer (`_scheduleAutoContinuation`) and re-runs this check; the
1828
+ * continuation fires once the final sibling lands. If the in-memory pending
1829
+ * state is lost to eviction between siblings, the final result re-creates it
1830
+ * from the persisted transcript and fires with a complete batch — self-healing.
1831
+ * A true orphan (a sibling that never arrives) simply never auto-continues,
1832
+ * which is correct: there is nothing valid to continue, and a later user turn
1833
+ * / chat recovery repairs the transcript.
1834
+ *
1835
+ * The barrier also holds while the assistant turn is still streaming (the
1836
+ * stream-active gate below): mid-stream the batch can still grow with tool
1837
+ * calls the model hasn't emitted yet, so no completeness check is meaningful.
1838
+ * `_onStreamingTurnFinalized` re-runs the check once the stream ends.
1691
1839
  */
1692
1840
  private _fireAutoContinuationWhenStable;
1693
1841
  /**
1694
- * Block until the latest assistant step's parallel tool batch is fully
1695
- * answered, or `AUTO_CONTINUATION_PENDING_TOOL_TIMEOUT_MS` elapses. Awaits the
1696
- * in-flight tool-result apply when one exists (so a sibling that lands
1697
- * mid-wait is observed promptly) and polls otherwise.
1842
+ * Drain every in-flight tool-result/approval apply, including any enqueued
1843
+ * while we wait, so the subsequent `_hasIncompleteToolBatch()` re-check sees
1844
+ * every result that has ALREADY arrived. Bounded by real apply activity (a
1845
+ * storage write each), never by a fixed timer: a batch with no further
1846
+ * results drains in the time its pending applies take and then returns. The
1847
+ * loop re-reads `_interactionApplyTail` after each await because a sibling can
1848
+ * extend the tail mid-drain; we stop once the tail stops advancing.
1698
1849
  */
1699
- private _awaitToolBatch;
1850
+ private _drainInteractionApplies;
1700
1851
  /**
1701
1852
  * `true` when the latest assistant message is mid-batch: it carries at least
1702
1853
  * one settled tool result AND at least one tool call/approval still awaiting a
@@ -2199,4 +2350,4 @@ export {
2199
2350
  messengerReplySnapshot as z,
2200
2351
  ThinkScheduledTasks as zt
2201
2352
  };
2202
- //# sourceMappingURL=index-CYp8VDIe.d.ts.map
2353
+ //# sourceMappingURL=index-CKAMYQXB.d.ts.map
@@ -1,4 +1,4 @@
1
- import { a as _checkPrivateRedeclaration, i as _classPrivateFieldInitSpec, n as _classPrivateFieldSet2, r as _assertClassBrand, t as _classPrivateFieldGet2 } from "./classPrivateFieldGet2-BP1jgEfY.js";
1
+ import { a as _checkPrivateRedeclaration, i as _classPrivateFieldInitSpec, n as _classPrivateFieldSet2, r as _assertClassBrand, t as _classPrivateFieldGet2 } from "./classPrivateFieldGet2-D_obpP6O.js";
2
2
  import { jsonSchema, tool } from "ai";
3
3
  //#region \0rolldown/runtime.js
4
4
  var __defProp = Object.defineProperty;
@@ -12,7 +12,7 @@ var __exportAll = (all, no_symbols) => {
12
12
  return target;
13
13
  };
14
14
  //#endregion
15
- //#region \0@oxc-project+runtime@0.130.0/helpers/classPrivateMethodInitSpec.js
15
+ //#region \0@oxc-project+runtime@0.133.0/helpers/esm/classPrivateMethodInitSpec.js
16
16
  function _classPrivateMethodInitSpec(e, a) {
17
17
  _checkPrivateRedeclaration(e, a), a.add(e);
18
18
  }
@@ -326,4 +326,4 @@ export default class Extension extends WorkerEntrypoint {
326
326
  //#endregion
327
327
  export { _classPrivateMethodInitSpec as i, manager_exports as n, sanitizeName as r, ExtensionManager as t };
328
328
 
329
- //# sourceMappingURL=manager-px912SoZ.js.map
329
+ //# sourceMappingURL=manager-DnCkoyVo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"manager-px912SoZ.js","names":[],"sources":["../src/extensions/manager.ts"],"sourcesContent":["/**\n * ExtensionManager — loads, manages, and exposes tools from extension Workers.\n *\n * Extensions are sandboxed Workers created via WorkerLoader. Each extension\n * declares tools (with JSON Schema inputs) and permissions. The manager:\n *\n * 1. Wraps extension source in a Worker module with describe/execute RPC\n * 2. Loads it via WorkerLoader with permission-gated bindings\n * 3. Discovers tools via describe() RPC call\n * 4. Exposes them as AI SDK tools via getTools()\n *\n * Extension source format — a JS object expression defining tools:\n *\n * ```js\n * ({\n * greet: {\n * description: \"Greet someone\",\n * parameters: { name: { type: \"string\" } },\n * required: [\"name\"],\n * execute: async (args, host) => `Hello, ${args.name}!`\n * }\n * })\n * ```\n *\n * The `host` parameter in execute is provided via `env.host` — a loopback\n * binding that resolves the parent agent and delegates workspace operations\n * (gated by permissions). See HostBridgeLoopback.\n */\n\nimport { tool, jsonSchema } from \"ai\";\nimport type { ToolSet } from \"ai\";\nimport type {\n ExtensionManifest,\n ExtensionPermissions,\n ExtensionInfo,\n ExtensionToolDescriptor\n} from \"./types\";\n\n/**\n * Sanitize a name for use as a tool name prefix.\n * Replaces any non-alphanumeric characters with underscores and\n * collapses consecutive underscores.\n */\nexport function sanitizeName(name: string): string {\n if (!name || name.trim().length === 0) {\n throw new Error(\"Extension name must not be empty\");\n }\n return name\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n}\n\ninterface ExtensionEntrypoint {\n describe(): Promise<string>;\n manifest(): Promise<string>;\n execute(toolName: string, argsJson: string): Promise<string>;\n hook(name: string, ctxProxy: unknown): Promise<string>;\n}\n\ninterface LoadedExtension {\n manifest: ExtensionManifest;\n tools: ExtensionToolDescriptor[];\n hooks: string[];\n entrypoint: ExtensionEntrypoint;\n}\n\n/** Shape persisted to DO storage for each extension. */\ninterface PersistedExtension {\n manifest: ExtensionManifest;\n source: string;\n}\n\nconst STORAGE_PREFIX = \"ext:\";\n\nexport interface ExtensionManagerOptions {\n /** WorkerLoader binding for creating sandboxed extension Workers. */\n loader: WorkerLoader;\n /**\n * Durable Object storage for persisting extensions across hibernation.\n * If provided, loaded extensions survive DO restarts. Call `restore()`\n * on each turn to rebuild in-memory state from storage.\n */\n storage?: DurableObjectStorage;\n /**\n * Factory that creates a loopback Fetcher for workspace access, given\n * an extension's declared permissions. The returned binding is injected\n * into the extension worker's `env.host`.\n *\n * If not provided, extensions receive no host binding (workspace tools\n * will get `null` for the host parameter).\n *\n * Typically wired up using HostBridgeLoopback via `ctx.exports`:\n * ```typescript\n * createHostBinding: (permissions, ownContextLabels) =>\n * ctx.exports.HostBridgeLoopback({\n * props: { agentClassName: \"ChatSession\", agentId: ctx.id.toString(), permissions, ownContextLabels }\n * })\n * ```\n */\n createHostBinding?: (\n permissions: ExtensionPermissions,\n ownContextLabels: string[]\n ) => Fetcher;\n}\n\nexport class ExtensionManager {\n #loader: WorkerLoader;\n #storage: DurableObjectStorage | null;\n #createHostBinding:\n | ((\n permissions: ExtensionPermissions,\n ownContextLabels: string[]\n ) => Fetcher)\n | null;\n #extensions = new Map<string, LoadedExtension>();\n #restored = false;\n #onUnload:\n | ((name: string, contextLabels: string[]) => void | Promise<void>)\n | null = null;\n\n constructor(options: ExtensionManagerOptions) {\n this.#loader = options.loader;\n this.#storage = options.storage ?? null;\n this.#createHostBinding = options.createHostBinding ?? null;\n }\n\n /**\n * Load an extension from source code.\n *\n * The source is a JS object expression defining tools. Each tool has\n * `description`, `parameters` (JSON Schema properties), optional\n * `required` array, and an `execute` async function.\n *\n * @returns Summary of the loaded extension including discovered tools.\n */\n /**\n * Restore extensions from DO storage after hibernation.\n *\n * Idempotent — skips extensions already in memory. Call this at the\n * start of each chat turn (e.g. in onChatMessage before getTools).\n */\n async restore(): Promise<void> {\n if (this.#restored || !this.#storage) return;\n this.#restored = true;\n\n const entries = await this.#storage.list<PersistedExtension>({\n prefix: STORAGE_PREFIX\n });\n\n for (const persisted of entries.values()) {\n if (this.#extensions.has(persisted.manifest.name)) continue;\n await this.#loadInternal(persisted.manifest, persisted.source);\n }\n }\n\n async load(\n manifest: ExtensionManifest,\n source: string\n ): Promise<ExtensionInfo> {\n if (this.#extensions.has(manifest.name)) {\n throw new Error(\n `Extension \"${manifest.name}\" is already loaded. Unload it first.`\n );\n }\n\n const info = await this.#loadInternal(manifest, source);\n\n // Persist to storage so it survives hibernation\n if (this.#storage) {\n await this.#storage.put<PersistedExtension>(\n `${STORAGE_PREFIX}${manifest.name}`,\n { manifest, source }\n );\n }\n\n return info;\n }\n\n async #loadInternal(\n manifest: ExtensionManifest,\n source: string\n ): Promise<ExtensionInfo> {\n const workerModule = wrapExtensionSource(source);\n const permissions = manifest.permissions ?? {};\n\n // Build env bindings for the dynamic worker. Inject a loopback\n // Fetcher as env.host when the extension declares ANY permission\n // that requires host access (workspace, context, messages, session).\n const workerEnv: Record<string, Fetcher> = {};\n const needsHost =\n (permissions.workspace ?? \"none\") !== \"none\" ||\n permissions.context?.read !== undefined ||\n permissions.context?.write !== undefined ||\n (permissions.messages ?? \"none\") !== \"none\" ||\n permissions.session?.sendMessage ||\n permissions.session?.metadata;\n if (this.#createHostBinding && needsHost) {\n const prefix = sanitizeName(manifest.name);\n const ownLabels = (manifest.context ?? []).map(\n (c) => `${prefix}_${c.label}`\n );\n workerEnv.host = this.#createHostBinding(permissions, ownLabels);\n }\n\n const worker = this.#loader.get(\n `ext-${manifest.name}-${manifest.version}-${Date.now()}`,\n () => ({\n compatibilityDate: \"2025-06-01\",\n compatibilityFlags: [\"nodejs_compat\"],\n mainModule: \"extension.js\",\n modules: { \"extension.js\": workerModule },\n globalOutbound: permissions.network?.length ? undefined : null,\n ...(Object.keys(workerEnv).length > 0 ? { env: workerEnv } : {})\n })\n );\n\n const entrypoint = worker.getEntrypoint() as unknown as ExtensionEntrypoint;\n\n // Discover tools and hooks via RPC\n const descriptorsJson = await entrypoint.describe();\n const tools = JSON.parse(descriptorsJson) as ExtensionToolDescriptor[];\n\n let hooks: string[] = [];\n try {\n const manifestJson = await entrypoint.manifest();\n const runtimeManifest = JSON.parse(manifestJson) as {\n hooks?: string[];\n };\n hooks = runtimeManifest.hooks ?? [];\n } catch {\n // Legacy extensions may not have manifest() — treat as no hooks\n }\n\n this.#extensions.set(manifest.name, {\n manifest,\n tools,\n hooks,\n entrypoint\n });\n\n return toExtensionInfo(manifest, tools);\n }\n\n /**\n * Unload an extension, removing its tools from the agent.\n * If an onUnload callback is registered, it fires with the\n * extension's namespaced context labels so the caller can\n * remove context blocks from the Session.\n */\n async unload(name: string): Promise<boolean> {\n const ext = this.#extensions.get(name);\n if (!ext) return false;\n\n const removed = this.#extensions.delete(name);\n if (removed && this.#storage) {\n await this.#storage.delete(`${STORAGE_PREFIX}${name}`);\n }\n\n if (removed && this.#onUnload) {\n const prefix = sanitizeName(name);\n const contextLabels = (ext.manifest.context ?? []).map(\n (c) => `${prefix}_${c.label}`\n );\n await this.#onUnload(name, contextLabels);\n }\n\n return removed;\n }\n\n /**\n * Register a callback invoked when an extension is unloaded.\n * Think uses this to remove the extension's context blocks from Session.\n */\n onUnload(\n cb: (name: string, contextLabels: string[]) => void | Promise<void>\n ): void {\n this.#onUnload = cb;\n }\n\n /**\n * Get the namespaced context labels for all loaded extensions\n * that declare context blocks in their manifests.\n */\n getContextLabels(): Array<{ extName: string; label: string }> {\n const result: Array<{ extName: string; label: string }> = [];\n for (const ext of this.#extensions.values()) {\n if (!ext.manifest.context) continue;\n const prefix = sanitizeName(ext.manifest.name);\n for (const ctx of ext.manifest.context) {\n result.push({\n extName: ext.manifest.name,\n label: `${prefix}_${ctx.label}`\n });\n }\n }\n return result;\n }\n\n /**\n * Get extension manifest by name.\n */\n getManifest(name: string): ExtensionManifest | null {\n return this.#extensions.get(name)?.manifest ?? null;\n }\n\n /**\n * Get extensions that subscribe to a specific hook, in load order.\n */\n getHookSubscribers(\n hookName: string\n ): Array<{ name: string; entrypoint: ExtensionEntrypoint }> {\n const result: Array<{ name: string; entrypoint: ExtensionEntrypoint }> = [];\n for (const ext of this.#extensions.values()) {\n if (ext.hooks.includes(hookName)) {\n result.push({ name: ext.manifest.name, entrypoint: ext.entrypoint });\n }\n }\n return result;\n }\n\n /**\n * List all loaded extensions.\n */\n list(): ExtensionInfo[] {\n return [...this.#extensions.values()].map((ext) =>\n toExtensionInfo(ext.manifest, ext.tools)\n );\n }\n\n /**\n * Get AI SDK tools from all loaded extensions.\n *\n * Tool names are prefixed with the sanitized extension name to avoid\n * collisions: e.g. extension \"github\" with tool \"create_pr\" → \"github_create_pr\".\n */\n getTools(): ToolSet {\n const tools: ToolSet = {};\n\n for (const ext of this.#extensions.values()) {\n const prefix = sanitizeName(ext.manifest.name);\n\n for (const descriptor of ext.tools) {\n const toolName = `${prefix}_${descriptor.name}`;\n\n tools[toolName] = tool({\n description: `[${ext.manifest.name}] ${descriptor.description}`,\n inputSchema: jsonSchema(\n descriptor.inputSchema as Record<string, unknown>\n ),\n execute: async (args: Record<string, unknown>) => {\n if (!this.#extensions.has(ext.manifest.name)) {\n throw new Error(\n `Extension \"${ext.manifest.name}\" has been unloaded. Tool \"${toolName}\" is no longer available.`\n );\n }\n const resultJson = await ext.entrypoint.execute(\n descriptor.name,\n JSON.stringify(args)\n );\n const parsed = JSON.parse(resultJson) as {\n result?: unknown;\n error?: string;\n };\n if (parsed.error) throw new Error(parsed.error);\n return parsed.result;\n }\n });\n }\n }\n\n return tools;\n }\n}\n\nfunction toExtensionInfo(\n manifest: ExtensionManifest,\n tools: ExtensionToolDescriptor[]\n): ExtensionInfo {\n const prefix = sanitizeName(manifest.name);\n return {\n name: manifest.name,\n version: manifest.version,\n description: manifest.description,\n tools: tools.map((t) => `${prefix}_${t.name}`),\n contextLabels: (manifest.context ?? []).map((c) => `${prefix}_${c.label}`),\n permissions: manifest.permissions ?? {}\n };\n}\n\n/**\n * Wrap an extension source in a Worker module that exposes\n * describe(), execute(), manifest(), and hook RPC methods.\n *\n * Source format: `({ tools: {...}, hooks: {...} })`\n * Both `tools` and `hooks` are optional.\n */\nfunction wrapExtensionSource(source: string): string {\n return `import { WorkerEntrypoint } from \"cloudflare:workers\";\n\nconst __ext = (${source});\nif (__ext && typeof __ext === \"object\" && !(\"tools\" in __ext) && !(\"hooks\" in __ext)) {\n throw new Error(\n \"Invalid extension source format. Expected { tools: {...}, hooks: {...} } \" +\n \"but got a flat object. Wrap your tools in a 'tools' key.\"\n );\n}\nconst __tools = __ext.tools || {};\nconst __hooks = __ext.hooks || {};\n\nexport default class Extension extends WorkerEntrypoint {\n describe() {\n const descriptors = [];\n for (const [name, def] of Object.entries(__tools)) {\n descriptors.push({\n name,\n description: def.description || name,\n inputSchema: {\n type: \"object\",\n properties: def.parameters || {},\n required: def.required || []\n }\n });\n }\n return JSON.stringify(descriptors);\n }\n\n manifest() {\n return JSON.stringify({\n hooks: Object.keys(__hooks)\n });\n }\n\n async execute(toolName, argsJson) {\n const def = __tools[toolName];\n if (!def || !def.execute) {\n return JSON.stringify({ error: \"Unknown tool: \" + toolName });\n }\n try {\n const args = JSON.parse(argsJson);\n const result = await def.execute(args, this.env.host ?? null);\n return JSON.stringify({ result });\n } catch (err) {\n return JSON.stringify({ error: err.message || String(err) });\n }\n }\n\n async hook(name, ctxSnapshot) {\n const fn = __hooks[name];\n if (!fn) return JSON.stringify({ skipped: true });\n try {\n // Hook handlers receive (ctxSnapshot, host) — symmetric with tool\n // executes. \\`host\\` is null when the extension was loaded without\n // host-requiring permissions or when the worker entry point doesn't\n // re-export HostBridgeLoopback.\n const result = await fn(ctxSnapshot, this.env.host ?? null);\n return JSON.stringify({ result: result ?? {} });\n } catch (err) {\n return JSON.stringify({ error: err.message || String(err) });\n }\n }\n}\n`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,aAAa,MAAsB;CACjD,IAAI,CAAC,QAAQ,KAAK,KAAK,EAAE,WAAW,GAClC,MAAM,IAAI,MAAM,kCAAkC;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;;;;;;;;;;;;;;;;AA+DxB"}
1
+ {"version":3,"file":"manager-DnCkoyVo.js","names":[],"sources":["../src/extensions/manager.ts"],"sourcesContent":["/**\n * ExtensionManager — loads, manages, and exposes tools from extension Workers.\n *\n * Extensions are sandboxed Workers created via WorkerLoader. Each extension\n * declares tools (with JSON Schema inputs) and permissions. The manager:\n *\n * 1. Wraps extension source in a Worker module with describe/execute RPC\n * 2. Loads it via WorkerLoader with permission-gated bindings\n * 3. Discovers tools via describe() RPC call\n * 4. Exposes them as AI SDK tools via getTools()\n *\n * Extension source format — a JS object expression defining tools:\n *\n * ```js\n * ({\n * greet: {\n * description: \"Greet someone\",\n * parameters: { name: { type: \"string\" } },\n * required: [\"name\"],\n * execute: async (args, host) => `Hello, ${args.name}!`\n * }\n * })\n * ```\n *\n * The `host` parameter in execute is provided via `env.host` — a loopback\n * binding that resolves the parent agent and delegates workspace operations\n * (gated by permissions). See HostBridgeLoopback.\n */\n\nimport { tool, jsonSchema } from \"ai\";\nimport type { ToolSet } from \"ai\";\nimport type {\n ExtensionManifest,\n ExtensionPermissions,\n ExtensionInfo,\n ExtensionToolDescriptor\n} from \"./types\";\n\n/**\n * Sanitize a name for use as a tool name prefix.\n * Replaces any non-alphanumeric characters with underscores and\n * collapses consecutive underscores.\n */\nexport function sanitizeName(name: string): string {\n if (!name || name.trim().length === 0) {\n throw new Error(\"Extension name must not be empty\");\n }\n return name\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n}\n\ninterface ExtensionEntrypoint {\n describe(): Promise<string>;\n manifest(): Promise<string>;\n execute(toolName: string, argsJson: string): Promise<string>;\n hook(name: string, ctxProxy: unknown): Promise<string>;\n}\n\ninterface LoadedExtension {\n manifest: ExtensionManifest;\n tools: ExtensionToolDescriptor[];\n hooks: string[];\n entrypoint: ExtensionEntrypoint;\n}\n\n/** Shape persisted to DO storage for each extension. */\ninterface PersistedExtension {\n manifest: ExtensionManifest;\n source: string;\n}\n\nconst STORAGE_PREFIX = \"ext:\";\n\nexport interface ExtensionManagerOptions {\n /** WorkerLoader binding for creating sandboxed extension Workers. */\n loader: WorkerLoader;\n /**\n * Durable Object storage for persisting extensions across hibernation.\n * If provided, loaded extensions survive DO restarts. Call `restore()`\n * on each turn to rebuild in-memory state from storage.\n */\n storage?: DurableObjectStorage;\n /**\n * Factory that creates a loopback Fetcher for workspace access, given\n * an extension's declared permissions. The returned binding is injected\n * into the extension worker's `env.host`.\n *\n * If not provided, extensions receive no host binding (workspace tools\n * will get `null` for the host parameter).\n *\n * Typically wired up using HostBridgeLoopback via `ctx.exports`:\n * ```typescript\n * createHostBinding: (permissions, ownContextLabels) =>\n * ctx.exports.HostBridgeLoopback({\n * props: { agentClassName: \"ChatSession\", agentId: ctx.id.toString(), permissions, ownContextLabels }\n * })\n * ```\n */\n createHostBinding?: (\n permissions: ExtensionPermissions,\n ownContextLabels: string[]\n ) => Fetcher;\n}\n\nexport class ExtensionManager {\n #loader: WorkerLoader;\n #storage: DurableObjectStorage | null;\n #createHostBinding:\n | ((\n permissions: ExtensionPermissions,\n ownContextLabels: string[]\n ) => Fetcher)\n | null;\n #extensions = new Map<string, LoadedExtension>();\n #restored = false;\n #onUnload:\n | ((name: string, contextLabels: string[]) => void | Promise<void>)\n | null = null;\n\n constructor(options: ExtensionManagerOptions) {\n this.#loader = options.loader;\n this.#storage = options.storage ?? null;\n this.#createHostBinding = options.createHostBinding ?? null;\n }\n\n /**\n * Load an extension from source code.\n *\n * The source is a JS object expression defining tools. Each tool has\n * `description`, `parameters` (JSON Schema properties), optional\n * `required` array, and an `execute` async function.\n *\n * @returns Summary of the loaded extension including discovered tools.\n */\n /**\n * Restore extensions from DO storage after hibernation.\n *\n * Idempotent — skips extensions already in memory. Call this at the\n * start of each chat turn (e.g. in onChatMessage before getTools).\n */\n async restore(): Promise<void> {\n if (this.#restored || !this.#storage) return;\n this.#restored = true;\n\n const entries = await this.#storage.list<PersistedExtension>({\n prefix: STORAGE_PREFIX\n });\n\n for (const persisted of entries.values()) {\n if (this.#extensions.has(persisted.manifest.name)) continue;\n await this.#loadInternal(persisted.manifest, persisted.source);\n }\n }\n\n async load(\n manifest: ExtensionManifest,\n source: string\n ): Promise<ExtensionInfo> {\n if (this.#extensions.has(manifest.name)) {\n throw new Error(\n `Extension \"${manifest.name}\" is already loaded. Unload it first.`\n );\n }\n\n const info = await this.#loadInternal(manifest, source);\n\n // Persist to storage so it survives hibernation\n if (this.#storage) {\n await this.#storage.put<PersistedExtension>(\n `${STORAGE_PREFIX}${manifest.name}`,\n { manifest, source }\n );\n }\n\n return info;\n }\n\n async #loadInternal(\n manifest: ExtensionManifest,\n source: string\n ): Promise<ExtensionInfo> {\n const workerModule = wrapExtensionSource(source);\n const permissions = manifest.permissions ?? {};\n\n // Build env bindings for the dynamic worker. Inject a loopback\n // Fetcher as env.host when the extension declares ANY permission\n // that requires host access (workspace, context, messages, session).\n const workerEnv: Record<string, Fetcher> = {};\n const needsHost =\n (permissions.workspace ?? \"none\") !== \"none\" ||\n permissions.context?.read !== undefined ||\n permissions.context?.write !== undefined ||\n (permissions.messages ?? \"none\") !== \"none\" ||\n permissions.session?.sendMessage ||\n permissions.session?.metadata;\n if (this.#createHostBinding && needsHost) {\n const prefix = sanitizeName(manifest.name);\n const ownLabels = (manifest.context ?? []).map(\n (c) => `${prefix}_${c.label}`\n );\n workerEnv.host = this.#createHostBinding(permissions, ownLabels);\n }\n\n const worker = this.#loader.get(\n `ext-${manifest.name}-${manifest.version}-${Date.now()}`,\n () => ({\n compatibilityDate: \"2025-06-01\",\n compatibilityFlags: [\"nodejs_compat\"],\n mainModule: \"extension.js\",\n modules: { \"extension.js\": workerModule },\n globalOutbound: permissions.network?.length ? undefined : null,\n ...(Object.keys(workerEnv).length > 0 ? { env: workerEnv } : {})\n })\n );\n\n const entrypoint = worker.getEntrypoint() as unknown as ExtensionEntrypoint;\n\n // Discover tools and hooks via RPC\n const descriptorsJson = await entrypoint.describe();\n const tools = JSON.parse(descriptorsJson) as ExtensionToolDescriptor[];\n\n let hooks: string[] = [];\n try {\n const manifestJson = await entrypoint.manifest();\n const runtimeManifest = JSON.parse(manifestJson) as {\n hooks?: string[];\n };\n hooks = runtimeManifest.hooks ?? [];\n } catch {\n // Legacy extensions may not have manifest() — treat as no hooks\n }\n\n this.#extensions.set(manifest.name, {\n manifest,\n tools,\n hooks,\n entrypoint\n });\n\n return toExtensionInfo(manifest, tools);\n }\n\n /**\n * Unload an extension, removing its tools from the agent.\n * If an onUnload callback is registered, it fires with the\n * extension's namespaced context labels so the caller can\n * remove context blocks from the Session.\n */\n async unload(name: string): Promise<boolean> {\n const ext = this.#extensions.get(name);\n if (!ext) return false;\n\n const removed = this.#extensions.delete(name);\n if (removed && this.#storage) {\n await this.#storage.delete(`${STORAGE_PREFIX}${name}`);\n }\n\n if (removed && this.#onUnload) {\n const prefix = sanitizeName(name);\n const contextLabels = (ext.manifest.context ?? []).map(\n (c) => `${prefix}_${c.label}`\n );\n await this.#onUnload(name, contextLabels);\n }\n\n return removed;\n }\n\n /**\n * Register a callback invoked when an extension is unloaded.\n * Think uses this to remove the extension's context blocks from Session.\n */\n onUnload(\n cb: (name: string, contextLabels: string[]) => void | Promise<void>\n ): void {\n this.#onUnload = cb;\n }\n\n /**\n * Get the namespaced context labels for all loaded extensions\n * that declare context blocks in their manifests.\n */\n getContextLabels(): Array<{ extName: string; label: string }> {\n const result: Array<{ extName: string; label: string }> = [];\n for (const ext of this.#extensions.values()) {\n if (!ext.manifest.context) continue;\n const prefix = sanitizeName(ext.manifest.name);\n for (const ctx of ext.manifest.context) {\n result.push({\n extName: ext.manifest.name,\n label: `${prefix}_${ctx.label}`\n });\n }\n }\n return result;\n }\n\n /**\n * Get extension manifest by name.\n */\n getManifest(name: string): ExtensionManifest | null {\n return this.#extensions.get(name)?.manifest ?? null;\n }\n\n /**\n * Get extensions that subscribe to a specific hook, in load order.\n */\n getHookSubscribers(\n hookName: string\n ): Array<{ name: string; entrypoint: ExtensionEntrypoint }> {\n const result: Array<{ name: string; entrypoint: ExtensionEntrypoint }> = [];\n for (const ext of this.#extensions.values()) {\n if (ext.hooks.includes(hookName)) {\n result.push({ name: ext.manifest.name, entrypoint: ext.entrypoint });\n }\n }\n return result;\n }\n\n /**\n * List all loaded extensions.\n */\n list(): ExtensionInfo[] {\n return [...this.#extensions.values()].map((ext) =>\n toExtensionInfo(ext.manifest, ext.tools)\n );\n }\n\n /**\n * Get AI SDK tools from all loaded extensions.\n *\n * Tool names are prefixed with the sanitized extension name to avoid\n * collisions: e.g. extension \"github\" with tool \"create_pr\" → \"github_create_pr\".\n */\n getTools(): ToolSet {\n const tools: ToolSet = {};\n\n for (const ext of this.#extensions.values()) {\n const prefix = sanitizeName(ext.manifest.name);\n\n for (const descriptor of ext.tools) {\n const toolName = `${prefix}_${descriptor.name}`;\n\n tools[toolName] = tool({\n description: `[${ext.manifest.name}] ${descriptor.description}`,\n inputSchema: jsonSchema(\n descriptor.inputSchema as Record<string, unknown>\n ),\n execute: async (args: Record<string, unknown>) => {\n if (!this.#extensions.has(ext.manifest.name)) {\n throw new Error(\n `Extension \"${ext.manifest.name}\" has been unloaded. Tool \"${toolName}\" is no longer available.`\n );\n }\n const resultJson = await ext.entrypoint.execute(\n descriptor.name,\n JSON.stringify(args)\n );\n const parsed = JSON.parse(resultJson) as {\n result?: unknown;\n error?: string;\n };\n if (parsed.error) throw new Error(parsed.error);\n return parsed.result;\n }\n });\n }\n }\n\n return tools;\n }\n}\n\nfunction toExtensionInfo(\n manifest: ExtensionManifest,\n tools: ExtensionToolDescriptor[]\n): ExtensionInfo {\n const prefix = sanitizeName(manifest.name);\n return {\n name: manifest.name,\n version: manifest.version,\n description: manifest.description,\n tools: tools.map((t) => `${prefix}_${t.name}`),\n contextLabels: (manifest.context ?? []).map((c) => `${prefix}_${c.label}`),\n permissions: manifest.permissions ?? {}\n };\n}\n\n/**\n * Wrap an extension source in a Worker module that exposes\n * describe(), execute(), manifest(), and hook RPC methods.\n *\n * Source format: `({ tools: {...}, hooks: {...} })`\n * Both `tools` and `hooks` are optional.\n */\nfunction wrapExtensionSource(source: string): string {\n return `import { WorkerEntrypoint } from \"cloudflare:workers\";\n\nconst __ext = (${source});\nif (__ext && typeof __ext === \"object\" && !(\"tools\" in __ext) && !(\"hooks\" in __ext)) {\n throw new Error(\n \"Invalid extension source format. Expected { tools: {...}, hooks: {...} } \" +\n \"but got a flat object. Wrap your tools in a 'tools' key.\"\n );\n}\nconst __tools = __ext.tools || {};\nconst __hooks = __ext.hooks || {};\n\nexport default class Extension extends WorkerEntrypoint {\n describe() {\n const descriptors = [];\n for (const [name, def] of Object.entries(__tools)) {\n descriptors.push({\n name,\n description: def.description || name,\n inputSchema: {\n type: \"object\",\n properties: def.parameters || {},\n required: def.required || []\n }\n });\n }\n return JSON.stringify(descriptors);\n }\n\n manifest() {\n return JSON.stringify({\n hooks: Object.keys(__hooks)\n });\n }\n\n async execute(toolName, argsJson) {\n const def = __tools[toolName];\n if (!def || !def.execute) {\n return JSON.stringify({ error: \"Unknown tool: \" + toolName });\n }\n try {\n const args = JSON.parse(argsJson);\n const result = await def.execute(args, this.env.host ?? null);\n return JSON.stringify({ result });\n } catch (err) {\n return JSON.stringify({ error: err.message || String(err) });\n }\n }\n\n async hook(name, ctxSnapshot) {\n const fn = __hooks[name];\n if (!fn) return JSON.stringify({ skipped: true });\n try {\n // Hook handlers receive (ctxSnapshot, host) — symmetric with tool\n // executes. \\`host\\` is null when the extension was loaded without\n // host-requiring permissions or when the worker entry point doesn't\n // re-export HostBridgeLoopback.\n const result = await fn(ctxSnapshot, this.env.host ?? null);\n return JSON.stringify({ result: result ?? {} });\n } catch (err) {\n return JSON.stringify({ error: err.message || String(err) });\n }\n }\n}\n`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,aAAa,MAAsB;CACjD,IAAI,CAAC,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,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DxB"}
@@ -233,4 +233,4 @@ export {
233
233
  ExtensionInfo as r,
234
234
  ExtensionManager as t
235
235
  };
236
- //# sourceMappingURL=manager-C1zjft70.d.ts.map
236
+ //# sourceMappingURL=manager-dOcdCX4u.d.ts.map
@@ -52,7 +52,7 @@ import {
52
52
  x as toMessengerAuthor,
53
53
  y as normalizeMessengers,
54
54
  z as messengerReplySnapshot
55
- } from "../index-CYp8VDIe.js";
55
+ } from "../index-CKAMYQXB.js";
56
56
  export {
57
57
  type ChatSdkMessengerEventInput,
58
58
  type ChatSdkMessengerOptions,
@@ -1,2 +1,2 @@
1
- import { C as textDeltaFromStreamChunk, E as toMessengerUserMessage, S as parseMessengerReplySnapshot, T as serializableMessengerEvent, _ as TextStreamCallback, a as defaultConversationName, b as messengerReplyRecoveryMode, c as normalizeMessengers, d as toMessengerMessage, f as toMessengerThread, g as MESSENGER_REPLY_FIBER_NAME, h as INTERRUPTED_MESSENGER_RESPONSE, i as defaultChatSdkEvent, l as toMessengerAttachment, m as ERROR_MESSENGER_RESPONSE, n as ThinkMessengerStateAgent, o as defineMessengers, p as EMPTY_MESSENGER_RESPONSE, r as chatSdkMessenger, s as idempotencyKeyForEvent, t as ThinkMessengerRuntime, u as toMessengerAuthor, v as deliverMessengerReply, w as messengerContextFromEvent, x as messengerReplySnapshot, y as messengerReplyFailureMode } from "../chat-sdk-CJwYlbp9.js";
1
+ import { C as textDeltaFromStreamChunk, E as toMessengerUserMessage, S as parseMessengerReplySnapshot, T as serializableMessengerEvent, _ as TextStreamCallback, a as defaultConversationName, b as messengerReplyRecoveryMode, c as normalizeMessengers, d as toMessengerMessage, f as toMessengerThread, g as MESSENGER_REPLY_FIBER_NAME, h as INTERRUPTED_MESSENGER_RESPONSE, i as defaultChatSdkEvent, l as toMessengerAttachment, m as ERROR_MESSENGER_RESPONSE, n as ThinkMessengerStateAgent, o as defineMessengers, p as EMPTY_MESSENGER_RESPONSE, r as chatSdkMessenger, s as idempotencyKeyForEvent, t as ThinkMessengerRuntime, u as toMessengerAuthor, v as deliverMessengerReply, w as messengerContextFromEvent, x as messengerReplySnapshot, y as messengerReplyFailureMode } from "../chat-sdk-Bb93yaZh.js";
2
2
  export { EMPTY_MESSENGER_RESPONSE, ERROR_MESSENGER_RESPONSE, INTERRUPTED_MESSENGER_RESPONSE, MESSENGER_REPLY_FIBER_NAME, TextStreamCallback, ThinkMessengerRuntime, ThinkMessengerStateAgent, chatSdkMessenger, defaultChatSdkEvent, defaultConversationName, defineMessengers, deliverMessengerReply, idempotencyKeyForEvent, messengerContextFromEvent, messengerReplyFailureMode, messengerReplyRecoveryMode, messengerReplySnapshot, normalizeMessengers, parseMessengerReplySnapshot, serializableMessengerEvent, textDeltaFromStreamChunk, toMessengerAttachment, toMessengerAuthor, toMessengerMessage, toMessengerThread, toMessengerUserMessage };
@@ -2,7 +2,7 @@ import {
2
2
  P as TextStreamCallback,
3
3
  n as ChatSdkMessengerOptions,
4
4
  o as MessengerDefinition
5
- } from "../index-CYp8VDIe.js";
5
+ } from "../index-CKAMYQXB.js";
6
6
  import { TelegramAdapterConfig } from "@chat-adapter/telegram";
7
7
 
8
8
  //#region src/messengers/telegram.d.ts
@@ -1,4 +1,4 @@
1
- import { r as chatSdkMessenger } from "../chat-sdk-CJwYlbp9.js";
1
+ import { r as chatSdkMessenger } from "../chat-sdk-Bb93yaZh.js";
2
2
  import { createTelegramAdapter } from "@chat-adapter/telegram";
3
3
  //#region src/messengers/telegram.ts
4
4
  const TELEGRAM_STREAM_SOFT_LIMIT = 3400;
package/dist/think.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { h as WorkspaceLike } from "./workspace-Bri0ANBX.js";
1
+ import { h as WorkspaceLike } from "./workspace-BZXdZcuw.js";
2
2
  import {
3
3
  $t as defineScheduledTasks,
4
4
  At as StreamableResult,
@@ -55,7 +55,7 @@ import {
55
55
  xt as SaveMessagesResult,
56
56
  yt as ResolvedChatRecoveryConfig,
57
57
  zt as ThinkScheduledTasks
58
- } from "./index-CYp8VDIe.js";
58
+ } from "./index-CKAMYQXB.js";
59
59
  export {
60
60
  ChatErrorContext,
61
61
  ChatOptions,