@tangle-network/agent-app 1.0.24 → 1.0.26

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.
Files changed (47) hide show
  1. package/dist/assistant/index.js +8 -8
  2. package/dist/catalog/index.js +1 -1
  3. package/dist/chat-react/index.js +5 -5
  4. package/dist/chat-routes/index.js +4 -4
  5. package/dist/{chunk-HWWER7G6.js → chunk-2ARZ4Y7D.js} +2 -2
  6. package/dist/{chunk-MM2GG3IX.js → chunk-4W6MDZQH.js} +3 -3
  7. package/dist/{chunk-SLXJZGXE.js → chunk-6CDNITEO.js} +3 -3
  8. package/dist/chunk-6CDNITEO.js.map +1 -0
  9. package/dist/{chunk-GN5JME4V.js → chunk-6VRM2RVY.js} +40 -16
  10. package/dist/chunk-6VRM2RVY.js.map +1 -0
  11. package/dist/{chunk-IQZSV5YG.js → chunk-B2X2GGV5.js} +14 -12
  12. package/dist/{chunk-IQZSV5YG.js.map → chunk-B2X2GGV5.js.map} +1 -1
  13. package/dist/{chunk-VLMXVCDQ.js → chunk-KSLTD4FI.js} +8 -2
  14. package/dist/chunk-KSLTD4FI.js.map +1 -0
  15. package/dist/{chunk-GOPBMDCQ.js → chunk-NZMP7PFG.js} +4 -4
  16. package/dist/chunk-NZMP7PFG.js.map +1 -0
  17. package/dist/{chunk-K7HE6EM4.js → chunk-OVVVGEF6.js} +2 -2
  18. package/dist/{chunk-X7PYE5C5.js → chunk-RTJJYBVV.js} +2 -2
  19. package/dist/{chunk-G37LZ2FN.js → chunk-UN3PDU3M.js} +2 -2
  20. package/dist/{chunk-MK7VUZU7.js → chunk-Z5Y6OYAP.js} +4 -4
  21. package/dist/{mention-editor-HLEB37RK.js → mention-editor-XB4LGO3X.js} +3 -3
  22. package/dist/public-consultation/index.js +3 -3
  23. package/dist/runtime/index.js +5 -3
  24. package/dist/runtime/index.js.map +1 -1
  25. package/dist/runtime/model-catalog.d.ts +5 -0
  26. package/dist/runtime/router-turn.js +2 -2
  27. package/dist/settings-react/index.js +2 -2
  28. package/dist/studio-react/index.js +2 -2
  29. package/dist/web-react/agent-profile-editor.js +5 -5
  30. package/dist/web-react/agent-session-controls.d.ts +6 -4
  31. package/dist/web-react/chat-stream.d.ts +27 -9
  32. package/dist/web-react/effort-picker.d.ts +7 -6
  33. package/dist/web-react/index.js +10 -8
  34. package/dist/web-react/picker-presentation.d.ts +2 -2
  35. package/dist/workspace-react/index.js +4 -4
  36. package/package.json +1 -1
  37. package/dist/chunk-GN5JME4V.js.map +0 -1
  38. package/dist/chunk-GOPBMDCQ.js.map +0 -1
  39. package/dist/chunk-SLXJZGXE.js.map +0 -1
  40. package/dist/chunk-VLMXVCDQ.js.map +0 -1
  41. /package/dist/{chunk-HWWER7G6.js.map → chunk-2ARZ4Y7D.js.map} +0 -0
  42. /package/dist/{chunk-MM2GG3IX.js.map → chunk-4W6MDZQH.js.map} +0 -0
  43. /package/dist/{chunk-K7HE6EM4.js.map → chunk-OVVVGEF6.js.map} +0 -0
  44. /package/dist/{chunk-X7PYE5C5.js.map → chunk-RTJJYBVV.js.map} +0 -0
  45. /package/dist/{chunk-G37LZ2FN.js.map → chunk-UN3PDU3M.js.map} +0 -0
  46. /package/dist/{chunk-MK7VUZU7.js.map → chunk-Z5Y6OYAP.js.map} +0 -0
  47. /package/dist/{mention-editor-HLEB37RK.js.map → mention-editor-XB4LGO3X.js.map} +0 -0
@@ -113,7 +113,7 @@ import {
113
113
  import {
114
114
  composeRouterTurnPromptSections,
115
115
  runRouterTurn
116
- } from "./chunk-HWWER7G6.js";
116
+ } from "./chunk-2ARZ4Y7D.js";
117
117
  import {
118
118
  createIntelligenceTurnTraceSink,
119
119
  createTurnTrace,
@@ -4153,4 +4153,4 @@ export {
4153
4153
  createChatTurnRoutes,
4154
4154
  streamChatRouteAsSandboxEvents
4155
4155
  };
4156
- //# sourceMappingURL=chunk-K7HE6EM4.js.map
4156
+ //# sourceMappingURL=chunk-OVVVGEF6.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runRouterTurn
3
- } from "./chunk-HWWER7G6.js";
3
+ } from "./chunk-2ARZ4Y7D.js";
4
4
 
5
5
  // src/runtime/protected-model.ts
6
6
  var GATEWAY_ORIGIN = "https://candidate-router.tangle.tools";
@@ -217,4 +217,4 @@ export {
217
217
  createRouterProtectedModelPort,
218
218
  runProtectedRouterTurn
219
219
  };
220
- //# sourceMappingURL=chunk-X7PYE5C5.js.map
220
+ //# sourceMappingURL=chunk-RTJJYBVV.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  usePopover
3
- } from "./chunk-SLXJZGXE.js";
3
+ } from "./chunk-6CDNITEO.js";
4
4
 
5
5
  // src/web-react/popover-dialog.ts
6
6
  import { useEffect, useId } from "react";
@@ -45,4 +45,4 @@ function usePopoverDialog(open, onOpenChange) {
45
45
  export {
46
46
  usePopoverDialog
47
47
  };
48
- //# sourceMappingURL=chunk-G37LZ2FN.js.map
48
+ //# sourceMappingURL=chunk-UN3PDU3M.js.map
@@ -7,7 +7,7 @@ import {
7
7
  filterAcceptedFiles,
8
8
  isAcceptedFileType,
9
9
  renamePastedImages
10
- } from "./chunk-IQZSV5YG.js";
10
+ } from "./chunk-B2X2GGV5.js";
11
11
  import {
12
12
  useWorkspacePrewarmHandle
13
13
  } from "./chunk-2HQP2CTA.js";
@@ -15,7 +15,7 @@ import {
15
15
  OVERLAY_SHADOW,
16
16
  POPOVER_OPTION_FOCUS,
17
17
  PopoverSurface
18
- } from "./chunk-SLXJZGXE.js";
18
+ } from "./chunk-6CDNITEO.js";
19
19
  import {
20
20
  filterCommandPaletteItems
21
21
  } from "./chunk-SJWIZT7B.js";
@@ -615,7 +615,7 @@ function MicGlyph({ className }) {
615
615
  // src/web-react/chat-composer.tsx
616
616
  import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
617
617
  function createLazyMentionEditor() {
618
- return lazy2(() => import("./mention-editor-HLEB37RK.js").then((m) => m.loadMentionEditor()));
618
+ return lazy2(() => import("./mention-editor-XB4LGO3X.js").then((m) => m.loadMentionEditor()));
619
619
  }
620
620
  var IS_APPLE_PLATFORM = typeof navigator !== "undefined" && /Mac|iPhone|iPad|iPod/i.test(navigator.platform);
621
621
  var DEFAULT_MAX_HEIGHT = 168;
@@ -1853,4 +1853,4 @@ export {
1853
1853
  ComposerModeControls,
1854
1854
  EntryComposer
1855
1855
  };
1856
- //# sourceMappingURL=chunk-MK7VUZU7.js.map
1856
+ //# sourceMappingURL=chunk-Z5Y6OYAP.js.map
@@ -10,10 +10,10 @@ import {
10
10
  } from "./chunk-L7MB2LLM.js";
11
11
  import {
12
12
  PopoverSurface
13
- } from "./chunk-SLXJZGXE.js";
13
+ } from "./chunk-6CDNITEO.js";
14
14
  import "./chunk-ZAMHLXNS.js";
15
15
  import "./chunk-RASGKEAL.js";
16
- import "./chunk-VLMXVCDQ.js";
16
+ import "./chunk-KSLTD4FI.js";
17
17
 
18
18
  // src/web-react/mention-editor.tsx
19
19
  import { useEffect as useEffect2, useId, useRef as useRef2, useState as useState2 } from "react";
@@ -564,4 +564,4 @@ export {
564
564
  loadMentionEditor,
565
565
  loadTiptapModules
566
566
  };
567
- //# sourceMappingURL=mention-editor-HLEB37RK.js.map
567
+ //# sourceMappingURL=mention-editor-XB4LGO3X.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createChatTurnRoutes,
3
3
  streamChatRouteAsSandboxEvents
4
- } from "../chunk-K7HE6EM4.js";
4
+ } from "../chunk-OVVVGEF6.js";
5
5
  import "../chunk-SBHFMDR7.js";
6
6
  import "../chunk-H6BRJU5M.js";
7
7
  import "../chunk-4DBHC63F.js";
@@ -33,10 +33,10 @@ import "../chunk-S5SRJJQG.js";
33
33
  import "../chunk-C3JXGK3R.js";
34
34
  import "../chunk-UGWQLQDS.js";
35
35
  import "../chunk-IDRATMRZ.js";
36
- import "../chunk-HWWER7G6.js";
36
+ import "../chunk-2ARZ4Y7D.js";
37
37
  import "../chunk-LPW4UVAZ.js";
38
38
  import "../chunk-DCPOEDPK.js";
39
- import "../chunk-VLMXVCDQ.js";
39
+ import "../chunk-KSLTD4FI.js";
40
40
  import "../chunk-5VE4IDSU.js";
41
41
  import "../chunk-67CSI5PU.js";
42
42
  import "../chunk-RCSAAWOH.js";
@@ -2,7 +2,7 @@ import {
2
2
  ProtectedModelSettlementError,
3
3
  createRouterProtectedModelPort,
4
4
  runProtectedRouterTurn
5
- } from "../chunk-X7PYE5C5.js";
5
+ } from "../chunk-RTJJYBVV.js";
6
6
  import {
7
7
  DURABLE_HOP_BUDGET_MS,
8
8
  asksForLanguage,
@@ -26,7 +26,7 @@ import {
26
26
  turnKnowledgeInstructions,
27
27
  workspaceKnowledgeForTurn,
28
28
  workspaceTurnCheckpoints
29
- } from "../chunk-HWWER7G6.js";
29
+ } from "../chunk-2ARZ4Y7D.js";
30
30
  import {
31
31
  DEFAULT_TANGLE_BILLING_ENFORCEMENT_ENV_VAR,
32
32
  DEFAULT_TANGLE_ROUTER_BASE_URL,
@@ -47,13 +47,14 @@ import {
47
47
  MAX_RECOMMENDED_MODELS,
48
48
  __resetCatalogCache,
49
49
  buildCatalog,
50
+ canonicalRouterModelId,
50
51
  catalogModelForId,
51
52
  fetchModelCatalog,
52
53
  isChatCapableModel,
53
54
  normalizeModelId,
54
55
  resolveCatalogModelId,
55
56
  sortModelsByFreshness
56
- } from "../chunk-VLMXVCDQ.js";
57
+ } from "../chunk-KSLTD4FI.js";
57
58
 
58
59
  // src/runtime/certified-delivery.ts
59
60
  import {
@@ -174,6 +175,7 @@ export {
174
175
  asksForLanguage,
175
176
  budgetTurnKnowledge,
176
177
  buildCatalog,
178
+ canonicalRouterModelId,
177
179
  catalogModelForId,
178
180
  composeRouterTurnPrompt,
179
181
  composeRouterTurnPromptSections,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/runtime/certified-delivery.ts","../../src/runtime/surface-profile.ts"],"sourcesContent":["/**\n * Application profile composition using Runtime's certified-guidance source.\n *\n * The shell adapts the prompt source to the application's resolved profile;\n * Runtime owns pulling, cache lifetime, concurrent refresh and retained guidance.\n * Only prompt-compatible guidance is folded here. Tool definitions, execution\n * permissions, MCP servers and files are not installed from certified material.\n * The complete profile remains available through `current()` for inspection and\n * the product's separately authorized materialization path.\n */\nimport {\n createCertifiedPromptSource,\n type CertifiedProfile,\n type CertifiedPromptSourceOptions,\n} from '@tangle-network/agent-runtime/intelligence'\nimport type { ResolvedAgentProfile } from './agent'\n\n/** Pull coordinates, refresh cadence and timeout owned by the shared source. */\nexport type CertifiedDeliveryConfig = CertifiedPromptSourceOptions\n\n/** Adapt certified prompt guidance without granting execution authority. */\nexport interface CertifiedDelivery {\n /** Refresh on the source's cadence and compose the current prompt guidance.\n * Other resolved profile fields pass through unchanged. */\n composeProfile(base: ResolvedAgentProfile): Promise<ResolvedAgentProfile>\n /** Force a pull now, coalescing with an in-flight pull. Best-effort; not a\n * post-activation revision barrier or a permission-revocation protocol. */\n refresh(): Promise<void>\n /** Last successfully pulled profile, or null before a successful pull. */\n current(): CertifiedProfile | null\n}\n\nexport function createCertifiedDelivery(config: CertifiedDeliveryConfig): CertifiedDelivery {\n const source = createCertifiedPromptSource(config)\n return {\n async composeProfile(base) {\n return { ...base, systemPrompt: await source.compose(base.systemPrompt) }\n },\n refresh: () => source.refresh({ force: true }),\n current: source.current,\n }\n}\n","/**\n * Surface-scoped profile overlay — the seam letting any product page (a\n * sequence editor, a brief composer, a dataset view) add MCP servers, a prompt\n * addendum, and permission tightening to the workspace agent profile for turns\n * initiated FROM that surface, without the chat orchestrator knowing any\n * surface's specifics. The orchestrator resolves `(kind, ctx)` through a\n * registry the REQUEST HANDLER constructs per request (construction is a Map\n * build — cheap) and merges the result into the base profile it was about to\n * send to the sandbox. Per-request construction is the trust mechanism, not an\n * optimization target: each `build()` closes over server-trusted request state\n * (env bindings, secrets, the AUTHENTICATED user/workspace), which on Workers\n * exists only per request — a startup-built registry would force identity\n * through the untrusted client `ctx`.\n *\n * SECURITY INVARIANT: the surface `kind` and the ids inside `ctx` arrive on\n * the client request and are pure ROUTING data — never trusted content, never\n * identity. Identity comes from the closure (see above). The registered\n * `build()` runs server-side only: it validates the routing ids against the\n * product's access control, then mints its own URLs from server configuration\n * (`buildHttpMcpServer` in ../tools). A client can therefore never inject an\n * arbitrary MCP url, header, or credential into the agent profile: the\n * overlay's `mcp` values are typed as {@link SurfaceMcpServer} (= the\n * server-built `AppToolMcpServer` entry shape), and only build() constructs\n * them.\n *\n * The credential itself never appears in the overlay. Since the tagged-config\n * contract (`agent-interface` 0.38.0) the `Authorization` header is a\n * `secret-ref` naming a box-environment variable, which the sandbox resolves\n * privately; `build()` supplies that key NAME from server configuration and the\n * product writes the value through `SandboxRuntimeConfig.env` at creation or\n * refreshes it through `SandboxRuntimeConfig.runtimeEnv` before retained-box\n * bootstrap. The value remains workspace-scoped because every member and turn\n * shares the box; runtime renewal does not create a per-user secret channel.\n */\n\nimport type { AppToolMcpServer } from '../tools/mcp'\n\n/** Sandbox permission posture values, ranked deny > ask > allow for merging. */\nexport type SurfacePermissionValue = 'allow' | 'ask' | 'deny'\n\n/** The only MCP entry shape an overlay may carry: the server-built bridge\n * entry from ../tools/mcp (transport, url, headers, and capability token all\n * assembled server-side). The alias exists so overlay authors reach for the\n * builders in ../tools rather than hand-rolling `{ url: ctx.url }` shapes\n * that would let request data become a dialable endpoint. */\nexport type SurfaceMcpServer = AppToolMcpServer\n\n/** What one surface contributes to the agent profile for a single turn. */\nexport interface SurfaceOverlay {\n /** MCP servers to mount for this turn, keyed by tool-routing name. Names\n * must not collide with the base profile's — see {@link mergeSurfaceOverlay}. */\n mcp?: Record<string, SurfaceMcpServer>\n /** Appended to the base system-prompt addendum with a blank-line separator. */\n promptAddendum?: string\n /** Per-key posture the surface wants for its turns. Merging is monotone\n * fail-closed: the stricter of base/overlay wins, so a surface can tighten\n * the workspace posture but never relax it. */\n permissions?: Record<string, SurfacePermissionValue>\n}\n\n/**\n * One registered surface kind. `TCtx` is the shape build() expects — a CLAIM\n * about the client payload, not a guarantee: the registry hands build() the\n * request's `ctx` unvalidated, so build() must treat every field as an\n * untrusted id (resolve it through access control that throws on a bad or\n * foreign id) before minting anything from it.\n */\nexport interface SurfaceKindDefinition<TCtx> {\n kind: string\n build: (ctx: TCtx) => SurfaceOverlay | Promise<SurfaceOverlay>\n}\n\n/** The variance-erased form a registry accepts (`build` is contravariant in\n * `TCtx`, so every concrete definition is assignable to this). */\nexport type AnySurfaceKind = SurfaceKindDefinition<never>\n\n/**\n * Declare one surface kind. The `kind` string is the client-visible routing\n * key (e.g. `'sequences'`); `build` is the server-side factory that turns a\n * validated ctx into the overlay for one turn.\n */\nexport function defineSurfaceKind<TCtx>(opts: {\n kind: string\n build: (ctx: TCtx) => SurfaceOverlay | Promise<SurfaceOverlay>\n}): SurfaceKindDefinition<TCtx> {\n if (typeof opts.kind !== 'string' || opts.kind.length === 0 || /\\s/.test(opts.kind)) {\n throw new Error(`surface kind must be a non-empty string without whitespace (got ${JSON.stringify(opts.kind)})`)\n }\n if (typeof opts.build !== 'function') {\n throw new Error(`surface kind '${opts.kind}' requires a build function`)\n }\n return { kind: opts.kind, build: opts.build }\n}\n\n/** Resolve and build the overlay for a given surface kind within a turn context */\nexport interface SurfaceRegistry {\n /** Build the overlay for one turn. Throws on an unknown kind — an unknown\n * surface is a routing bug (client and server registries drifted), and\n * silently returning an empty overlay would strip the surface's tools from\n * the turn with no signal anywhere. Build errors propagate unwrapped. */\n resolve(kind: string, ctx: unknown): Promise<SurfaceOverlay>\n}\n\n/**\n * Assemble the product's surface registry from its registered kinds. Duplicate\n * kinds throw at construction: two builders behind one routing key would make\n * the mounted toolset depend on registration order.\n */\nexport function createSurfaceRegistry(kinds: readonly AnySurfaceKind[]): SurfaceRegistry {\n const byKind = new Map<string, AnySurfaceKind>()\n for (const definition of kinds) {\n if (byKind.has(definition.kind)) {\n throw new Error(`duplicate surface kind '${definition.kind}' — each kind must be registered exactly once`)\n }\n byKind.set(definition.kind, definition)\n }\n\n return {\n async resolve(kind, ctx) {\n const definition = byKind.get(kind)\n if (!definition) {\n const known = [...byKind.keys()].join(', ') || '(none)'\n throw new Error(\n `unknown surface kind '${kind}' — registered kinds: ${known}. ` +\n 'An unknown surface is a routing bug: register the kind via defineSurfaceKind before clients can reference it.',\n )\n }\n // The trust boundary where static ctx typing ends: the request payload is\n // handed to build() as-is, and build() validates it (see SurfaceKindDefinition).\n const overlay = await definition.build(ctx as never)\n assertSurfaceOverlay(overlay, `surface kind '${kind}'`)\n return overlay\n },\n }\n}\n\n/** Base-profile slice the merge reads/writes. Real callers pass their full\n * profile object; every field outside this slice passes through untouched. */\nexport interface SurfaceMergeBase {\n mcp?: Record<string, unknown>\n systemPromptAddendum?: string\n permissions?: Record<string, SurfacePermissionValue>\n}\n\nconst PERMISSION_SEVERITY: Record<SurfacePermissionValue, number> = { allow: 0, ask: 1, deny: 2 }\n\n/**\n * Merge one surface overlay into a base profile, returning a new object\n * (the base is never mutated; untouched nested records are shared by\n * reference).\n *\n * - `mcp`: overlay servers are added under their own names. A name already\n * present on the base THROWS — a collision is two servers claiming one\n * routing name, and renaming either silently would corrupt tool routing for\n * whichever caller expected the original binding.\n * - `systemPromptAddendum`: the overlay's `promptAddendum` appends after a\n * blank-line separator (no separator when the base has no addendum).\n * - `permissions`: per key the STRICTER value wins (deny > ask > allow). A\n * surface can tighten the base posture for its turns; a base 'deny' survives\n * any overlay.\n */\nexport function mergeSurfaceOverlay<TBase extends SurfaceMergeBase>(\n base: TBase,\n overlay: SurfaceOverlay,\n): TBase & SurfaceMergeBase {\n assertSurfaceOverlay(overlay, 'surface overlay')\n const merged: SurfaceMergeBase = { ...base }\n\n if (overlay.mcp && Object.keys(overlay.mcp).length > 0) {\n const baseMcp = base.mcp ?? {}\n const collisions = Object.keys(overlay.mcp).filter((name) => name in baseMcp)\n if (collisions.length > 0) {\n throw new Error(\n `surface overlay MCP name collision: ${collisions.map((n) => `'${n}'`).join(', ')} already exist on the base profile. ` +\n 'Two servers cannot claim one name — give the surface server a distinct name.',\n )\n }\n merged.mcp = { ...baseMcp, ...overlay.mcp }\n }\n\n if (overlay.promptAddendum !== undefined) {\n merged.systemPromptAddendum = base.systemPromptAddendum\n ? `${base.systemPromptAddendum}\\n\\n${overlay.promptAddendum}`\n : overlay.promptAddendum\n }\n\n if (overlay.permissions && Object.keys(overlay.permissions).length > 0) {\n const permissions: Record<string, SurfacePermissionValue> = { ...(base.permissions ?? {}) }\n for (const [key, value] of Object.entries(overlay.permissions)) {\n const existing = permissions[key]\n permissions[key] =\n existing === undefined || PERMISSION_SEVERITY[value] > PERMISSION_SEVERITY[existing] ? value : existing\n }\n merged.permissions = permissions\n }\n\n // merged began as a shallow copy of base; only the three slice fields were\n // replaced, so the intersection type is the true shape.\n return merged as TBase & SurfaceMergeBase\n}\n\n/** Reject overlays a build() (or hand-rolled caller) malformed, with the exact\n * field named: a relative MCP url, a blank addendum, or an off-vocabulary\n * permission would otherwise surface only as an opaque sandbox failure. */\nfunction assertSurfaceOverlay(overlay: SurfaceOverlay, label: string): void {\n if (overlay.promptAddendum !== undefined) {\n if (typeof overlay.promptAddendum !== 'string' || overlay.promptAddendum.trim().length === 0) {\n throw new Error(`${label}: promptAddendum must be a non-blank string when provided`)\n }\n }\n if (overlay.mcp !== undefined) {\n for (const [name, server] of Object.entries(overlay.mcp)) {\n if (name.trim().length === 0) throw new Error(`${label}: MCP server names must be non-empty`)\n if (server.transport !== 'http') {\n throw new Error(`${label}: MCP server '${name}' must use transport 'http' (got ${JSON.stringify((server as { transport?: unknown }).transport)})`)\n }\n let parsed: URL\n try {\n parsed = new URL(server.url)\n } catch {\n throw new Error(`${label}: MCP server '${name}' url must be an absolute URL (got ${JSON.stringify(server.url)})`)\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n throw new Error(`${label}: MCP server '${name}' url must be http(s) (got ${JSON.stringify(server.url)})`)\n }\n }\n }\n if (overlay.permissions !== undefined) {\n for (const [key, value] of Object.entries(overlay.permissions)) {\n if (!(value in PERMISSION_SEVERITY)) {\n throw new Error(`${label}: permission '${key}' must be 'allow' | 'ask' | 'deny' (got ${JSON.stringify(value)})`)\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA;AAAA,EACE;AAAA,OAGK;AAkBA,SAAS,wBAAwB,QAAoD;AAC1F,QAAM,SAAS,4BAA4B,MAAM;AACjD,SAAO;AAAA,IACL,MAAM,eAAe,MAAM;AACzB,aAAO,EAAE,GAAG,MAAM,cAAc,MAAM,OAAO,QAAQ,KAAK,YAAY,EAAE;AAAA,IAC1E;AAAA,IACA,SAAS,MAAM,OAAO,QAAQ,EAAE,OAAO,KAAK,CAAC;AAAA,IAC7C,SAAS,OAAO;AAAA,EAClB;AACF;;;ACwCO,SAAS,kBAAwB,MAGR;AAC9B,MAAI,OAAO,KAAK,SAAS,YAAY,KAAK,KAAK,WAAW,KAAK,KAAK,KAAK,KAAK,IAAI,GAAG;AACnF,UAAM,IAAI,MAAM,mEAAmE,KAAK,UAAU,KAAK,IAAI,CAAC,GAAG;AAAA,EACjH;AACA,MAAI,OAAO,KAAK,UAAU,YAAY;AACpC,UAAM,IAAI,MAAM,iBAAiB,KAAK,IAAI,6BAA6B;AAAA,EACzE;AACA,SAAO,EAAE,MAAM,KAAK,MAAM,OAAO,KAAK,MAAM;AAC9C;AAgBO,SAAS,sBAAsB,OAAmD;AACvF,QAAM,SAAS,oBAAI,IAA4B;AAC/C,aAAW,cAAc,OAAO;AAC9B,QAAI,OAAO,IAAI,WAAW,IAAI,GAAG;AAC/B,YAAM,IAAI,MAAM,2BAA2B,WAAW,IAAI,oDAA+C;AAAA,IAC3G;AACA,WAAO,IAAI,WAAW,MAAM,UAAU;AAAA,EACxC;AAEA,SAAO;AAAA,IACL,MAAM,QAAQ,MAAM,KAAK;AACvB,YAAM,aAAa,OAAO,IAAI,IAAI;AAClC,UAAI,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AG,2CAA2C,KAAK,UAAU,KAAK,CAAC,GAAG;AAAA,MACjH;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/runtime/certified-delivery.ts","../../src/runtime/surface-profile.ts"],"sourcesContent":["/**\n * Application profile composition using Runtime's certified-guidance source.\n *\n * The shell adapts the prompt source to the application's resolved profile;\n * Runtime owns pulling, cache lifetime, concurrent refresh and retained guidance.\n * Only prompt-compatible guidance is folded here. Tool definitions, execution\n * permissions, MCP servers and files are not installed from certified material.\n * The complete profile remains available through `current()` for inspection and\n * the product's separately authorized materialization path.\n */\nimport {\n createCertifiedPromptSource,\n type CertifiedProfile,\n type CertifiedPromptSourceOptions,\n} from '@tangle-network/agent-runtime/intelligence'\nimport type { ResolvedAgentProfile } from './agent'\n\n/** Pull coordinates, refresh cadence and timeout owned by the shared source. */\nexport type CertifiedDeliveryConfig = CertifiedPromptSourceOptions\n\n/** Adapt certified prompt guidance without granting execution authority. */\nexport interface CertifiedDelivery {\n /** Refresh on the source's cadence and compose the current prompt guidance.\n * Other resolved profile fields pass through unchanged. */\n composeProfile(base: ResolvedAgentProfile): Promise<ResolvedAgentProfile>\n /** Force a pull now, coalescing with an in-flight pull. Best-effort; not a\n * post-activation revision barrier or a permission-revocation protocol. */\n refresh(): Promise<void>\n /** Last successfully pulled profile, or null before a successful pull. */\n current(): CertifiedProfile | null\n}\n\nexport function createCertifiedDelivery(config: CertifiedDeliveryConfig): CertifiedDelivery {\n const source = createCertifiedPromptSource(config)\n return {\n async composeProfile(base) {\n return { ...base, systemPrompt: await source.compose(base.systemPrompt) }\n },\n refresh: () => source.refresh({ force: true }),\n current: source.current,\n }\n}\n","/**\n * Surface-scoped profile overlay — the seam letting any product page (a\n * sequence editor, a brief composer, a dataset view) add MCP servers, a prompt\n * addendum, and permission tightening to the workspace agent profile for turns\n * initiated FROM that surface, without the chat orchestrator knowing any\n * surface's specifics. The orchestrator resolves `(kind, ctx)` through a\n * registry the REQUEST HANDLER constructs per request (construction is a Map\n * build — cheap) and merges the result into the base profile it was about to\n * send to the sandbox. Per-request construction is the trust mechanism, not an\n * optimization target: each `build()` closes over server-trusted request state\n * (env bindings, secrets, the AUTHENTICATED user/workspace), which on Workers\n * exists only per request — a startup-built registry would force identity\n * through the untrusted client `ctx`.\n *\n * SECURITY INVARIANT: the surface `kind` and the ids inside `ctx` arrive on\n * the client request and are pure ROUTING data — never trusted content, never\n * identity. Identity comes from the closure (see above). The registered\n * `build()` runs server-side only: it validates the routing ids against the\n * product's access control, then mints its own URLs from server configuration\n * (`buildHttpMcpServer` in ../tools). A client can therefore never inject an\n * arbitrary MCP url, header, or credential into the agent profile: the\n * overlay's `mcp` values are typed as {@link SurfaceMcpServer} (= the\n * server-built `AppToolMcpServer` entry shape), and only build() constructs\n * them.\n *\n * The credential itself never appears in the overlay. Since the tagged-config\n * contract (`agent-interface` 0.38.0) the `Authorization` header is a\n * `secret-ref` naming a box-environment variable, which the sandbox resolves\n * privately; `build()` supplies that key NAME from server configuration and the\n * product writes the value through `SandboxRuntimeConfig.env` at creation or\n * refreshes it through `SandboxRuntimeConfig.runtimeEnv` before retained-box\n * bootstrap. The value remains workspace-scoped because every member and turn\n * shares the box; runtime renewal does not create a per-user secret channel.\n */\n\nimport type { AppToolMcpServer } from '../tools/mcp'\n\n/** Sandbox permission posture values, ranked deny > ask > allow for merging. */\nexport type SurfacePermissionValue = 'allow' | 'ask' | 'deny'\n\n/** The only MCP entry shape an overlay may carry: the server-built bridge\n * entry from ../tools/mcp (transport, url, headers, and capability token all\n * assembled server-side). The alias exists so overlay authors reach for the\n * builders in ../tools rather than hand-rolling `{ url: ctx.url }` shapes\n * that would let request data become a dialable endpoint. */\nexport type SurfaceMcpServer = AppToolMcpServer\n\n/** What one surface contributes to the agent profile for a single turn. */\nexport interface SurfaceOverlay {\n /** MCP servers to mount for this turn, keyed by tool-routing name. Names\n * must not collide with the base profile's — see {@link mergeSurfaceOverlay}. */\n mcp?: Record<string, SurfaceMcpServer>\n /** Appended to the base system-prompt addendum with a blank-line separator. */\n promptAddendum?: string\n /** Per-key posture the surface wants for its turns. Merging is monotone\n * fail-closed: the stricter of base/overlay wins, so a surface can tighten\n * the workspace posture but never relax it. */\n permissions?: Record<string, SurfacePermissionValue>\n}\n\n/**\n * One registered surface kind. `TCtx` is the shape build() expects — a CLAIM\n * about the client payload, not a guarantee: the registry hands build() the\n * request's `ctx` unvalidated, so build() must treat every field as an\n * untrusted id (resolve it through access control that throws on a bad or\n * foreign id) before minting anything from it.\n */\nexport interface SurfaceKindDefinition<TCtx> {\n kind: string\n build: (ctx: TCtx) => SurfaceOverlay | Promise<SurfaceOverlay>\n}\n\n/** The variance-erased form a registry accepts (`build` is contravariant in\n * `TCtx`, so every concrete definition is assignable to this). */\nexport type AnySurfaceKind = SurfaceKindDefinition<never>\n\n/**\n * Declare one surface kind. The `kind` string is the client-visible routing\n * key (e.g. `'sequences'`); `build` is the server-side factory that turns a\n * validated ctx into the overlay for one turn.\n */\nexport function defineSurfaceKind<TCtx>(opts: {\n kind: string\n build: (ctx: TCtx) => SurfaceOverlay | Promise<SurfaceOverlay>\n}): SurfaceKindDefinition<TCtx> {\n if (typeof opts.kind !== 'string' || opts.kind.length === 0 || /\\s/.test(opts.kind)) {\n throw new Error(`surface kind must be a non-empty string without whitespace (got ${JSON.stringify(opts.kind)})`)\n }\n if (typeof opts.build !== 'function') {\n throw new Error(`surface kind '${opts.kind}' requires a build function`)\n }\n return { kind: opts.kind, build: opts.build }\n}\n\n/** Resolve and build the overlay for a given surface kind within a turn context */\nexport interface SurfaceRegistry {\n /** Build the overlay for one turn. Throws on an unknown kind — an unknown\n * surface is a routing bug (client and server registries drifted), and\n * silently returning an empty overlay would strip the surface's tools from\n * the turn with no signal anywhere. Build errors propagate unwrapped. */\n resolve(kind: string, ctx: unknown): Promise<SurfaceOverlay>\n}\n\n/**\n * Assemble the product's surface registry from its registered kinds. Duplicate\n * kinds throw at construction: two builders behind one routing key would make\n * the mounted toolset depend on registration order.\n */\nexport function createSurfaceRegistry(kinds: readonly AnySurfaceKind[]): SurfaceRegistry {\n const byKind = new Map<string, AnySurfaceKind>()\n for (const definition of kinds) {\n if (byKind.has(definition.kind)) {\n throw new Error(`duplicate surface kind '${definition.kind}' — each kind must be registered exactly once`)\n }\n byKind.set(definition.kind, definition)\n }\n\n return {\n async resolve(kind, ctx) {\n const definition = byKind.get(kind)\n if (!definition) {\n const known = [...byKind.keys()].join(', ') || '(none)'\n throw new Error(\n `unknown surface kind '${kind}' — registered kinds: ${known}. ` +\n 'An unknown surface is a routing bug: register the kind via defineSurfaceKind before clients can reference it.',\n )\n }\n // The trust boundary where static ctx typing ends: the request payload is\n // handed to build() as-is, and build() validates it (see SurfaceKindDefinition).\n const overlay = await definition.build(ctx as never)\n assertSurfaceOverlay(overlay, `surface kind '${kind}'`)\n return overlay\n },\n }\n}\n\n/** Base-profile slice the merge reads/writes. Real callers pass their full\n * profile object; every field outside this slice passes through untouched. */\nexport interface SurfaceMergeBase {\n mcp?: Record<string, unknown>\n systemPromptAddendum?: string\n permissions?: Record<string, SurfacePermissionValue>\n}\n\nconst PERMISSION_SEVERITY: Record<SurfacePermissionValue, number> = { allow: 0, ask: 1, deny: 2 }\n\n/**\n * Merge one surface overlay into a base profile, returning a new object\n * (the base is never mutated; untouched nested records are shared by\n * reference).\n *\n * - `mcp`: overlay servers are added under their own names. A name already\n * present on the base THROWS — a collision is two servers claiming one\n * routing name, and renaming either silently would corrupt tool routing for\n * whichever caller expected the original binding.\n * - `systemPromptAddendum`: the overlay's `promptAddendum` appends after a\n * blank-line separator (no separator when the base has no addendum).\n * - `permissions`: per key the STRICTER value wins (deny > ask > allow). A\n * surface can tighten the base posture for its turns; a base 'deny' survives\n * any overlay.\n */\nexport function mergeSurfaceOverlay<TBase extends SurfaceMergeBase>(\n base: TBase,\n overlay: SurfaceOverlay,\n): TBase & SurfaceMergeBase {\n assertSurfaceOverlay(overlay, 'surface overlay')\n const merged: SurfaceMergeBase = { ...base }\n\n if (overlay.mcp && Object.keys(overlay.mcp).length > 0) {\n const baseMcp = base.mcp ?? {}\n const collisions = Object.keys(overlay.mcp).filter((name) => name in baseMcp)\n if (collisions.length > 0) {\n throw new Error(\n `surface overlay MCP name collision: ${collisions.map((n) => `'${n}'`).join(', ')} already exist on the base profile. ` +\n 'Two servers cannot claim one name — give the surface server a distinct name.',\n )\n }\n merged.mcp = { ...baseMcp, ...overlay.mcp }\n }\n\n if (overlay.promptAddendum !== undefined) {\n merged.systemPromptAddendum = base.systemPromptAddendum\n ? `${base.systemPromptAddendum}\\n\\n${overlay.promptAddendum}`\n : overlay.promptAddendum\n }\n\n if (overlay.permissions && Object.keys(overlay.permissions).length > 0) {\n const permissions: Record<string, SurfacePermissionValue> = { ...(base.permissions ?? {}) }\n for (const [key, value] of Object.entries(overlay.permissions)) {\n const existing = permissions[key]\n permissions[key] =\n existing === undefined || PERMISSION_SEVERITY[value] > PERMISSION_SEVERITY[existing] ? value : existing\n }\n merged.permissions = permissions\n }\n\n // merged began as a shallow copy of base; only the three slice fields were\n // replaced, so the intersection type is the true shape.\n return merged as TBase & SurfaceMergeBase\n}\n\n/** Reject overlays a build() (or hand-rolled caller) malformed, with the exact\n * field named: a relative MCP url, a blank addendum, or an off-vocabulary\n * permission would otherwise surface only as an opaque sandbox failure. */\nfunction assertSurfaceOverlay(overlay: SurfaceOverlay, label: string): void {\n if (overlay.promptAddendum !== undefined) {\n if (typeof overlay.promptAddendum !== 'string' || overlay.promptAddendum.trim().length === 0) {\n throw new Error(`${label}: promptAddendum must be a non-blank string when provided`)\n }\n }\n if (overlay.mcp !== undefined) {\n for (const [name, server] of Object.entries(overlay.mcp)) {\n if (name.trim().length === 0) throw new Error(`${label}: MCP server names must be non-empty`)\n if (server.transport !== 'http') {\n throw new Error(`${label}: MCP server '${name}' must use transport 'http' (got ${JSON.stringify((server as { transport?: unknown }).transport)})`)\n }\n let parsed: URL\n try {\n parsed = new URL(server.url)\n } catch {\n throw new Error(`${label}: MCP server '${name}' url must be an absolute URL (got ${JSON.stringify(server.url)})`)\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n throw new Error(`${label}: MCP server '${name}' url must be http(s) (got ${JSON.stringify(server.url)})`)\n }\n }\n }\n if (overlay.permissions !== undefined) {\n for (const [key, value] of Object.entries(overlay.permissions)) {\n if (!(value in PERMISSION_SEVERITY)) {\n throw new Error(`${label}: permission '${key}' must be 'allow' | 'ask' | 'deny' (got ${JSON.stringify(value)})`)\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA;AAAA,EACE;AAAA,OAGK;AAkBA,SAAS,wBAAwB,QAAoD;AAC1F,QAAM,SAAS,4BAA4B,MAAM;AACjD,SAAO;AAAA,IACL,MAAM,eAAe,MAAM;AACzB,aAAO,EAAE,GAAG,MAAM,cAAc,MAAM,OAAO,QAAQ,KAAK,YAAY,EAAE;AAAA,IAC1E;AAAA,IACA,SAAS,MAAM,OAAO,QAAQ,EAAE,OAAO,KAAK,CAAC;AAAA,IAC7C,SAAS,OAAO;AAAA,EAClB;AACF;;;ACwCO,SAAS,kBAAwB,MAGR;AAC9B,MAAI,OAAO,KAAK,SAAS,YAAY,KAAK,KAAK,WAAW,KAAK,KAAK,KAAK,KAAK,IAAI,GAAG;AACnF,UAAM,IAAI,MAAM,mEAAmE,KAAK,UAAU,KAAK,IAAI,CAAC,GAAG;AAAA,EACjH;AACA,MAAI,OAAO,KAAK,UAAU,YAAY;AACpC,UAAM,IAAI,MAAM,iBAAiB,KAAK,IAAI,6BAA6B;AAAA,EACzE;AACA,SAAO,EAAE,MAAM,KAAK,MAAM,OAAO,KAAK,MAAM;AAC9C;AAgBO,SAAS,sBAAsB,OAAmD;AACvF,QAAM,SAAS,oBAAI,IAA4B;AAC/C,aAAW,cAAc,OAAO;AAC9B,QAAI,OAAO,IAAI,WAAW,IAAI,GAAG;AAC/B,Y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AAA,IACF;AAAA,EACF;AACA,MAAI,QAAQ,gBAAgB,QAAW;AACrC,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,QAAQ,WAAW,GAAG;AAC9D,UAAI,EAAE,SAAS,sBAAsB;AACnC,cAAM,IAAI,MAAM,GAAG,KAAK,iBAAiB,GAAG,2CAA2C,KAAK,UAAU,KAAK,CAAC,GAAG;AAAA,MACjH;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -83,6 +83,11 @@ export interface ModelCatalog {
83
83
  fetchedAt: string;
84
84
  models: CatalogModel[];
85
85
  }
86
+ /** Canonical router-facing id: "provider/model". Pickers display, products
87
+ * persist, and turns send this form. The prefix is the RAW router provider
88
+ * ('moonshotai/kimi-k2'), never the normalized display alias, so the id is a
89
+ * live router entry that validation admits. */
90
+ export declare function canonicalRouterModelId(model: Pick<RouterModel, 'id' | '_provider' | 'provider' | 'routeability'>): string;
86
91
  /** A short, varied first screen. All other routeable entries remain searchable. */
87
92
  export declare const MAX_RECOMMENDED_MODELS = 8;
88
93
  /** Strip provider prefix, :free suffix, and trailing date stamps. */
@@ -13,10 +13,10 @@ import {
13
13
  turnKnowledgeInstructions,
14
14
  workspaceKnowledgeForTurn,
15
15
  workspaceTurnCheckpoints
16
- } from "../chunk-HWWER7G6.js";
16
+ } from "../chunk-2ARZ4Y7D.js";
17
17
  import "../chunk-LPW4UVAZ.js";
18
18
  import "../chunk-DCPOEDPK.js";
19
- import "../chunk-VLMXVCDQ.js";
19
+ import "../chunk-KSLTD4FI.js";
20
20
  export {
21
21
  DURABLE_HOP_BUDGET_MS,
22
22
  asksForLanguage,
@@ -20,7 +20,7 @@ import {
20
20
  fieldPickerTriggerClass,
21
21
  useBrowserLayoutEffect,
22
22
  usePopover
23
- } from "../chunk-SLXJZGXE.js";
23
+ } from "../chunk-6CDNITEO.js";
24
24
  import {
25
25
  bindSearchPickerNavigation
26
26
  } from "../chunk-ZAMHLXNS.js";
@@ -33,7 +33,7 @@ import {
33
33
  import {
34
34
  useWorkspaceExport
35
35
  } from "../chunk-EZFBGW23.js";
36
- import "../chunk-VLMXVCDQ.js";
36
+ import "../chunk-KSLTD4FI.js";
37
37
 
38
38
  // src/settings-react/settings-layout.tsx
39
39
  import { Button, PageHeader, PageShell } from "@tangle-network/ui/primitives";
@@ -26,14 +26,14 @@ import {
26
26
  POPOVER_SURFACE_ATTR,
27
27
  PopoverSurface,
28
28
  usePopover
29
- } from "../chunk-SLXJZGXE.js";
29
+ } from "../chunk-6CDNITEO.js";
30
30
  import {
31
31
  containDialogTab
32
32
  } from "../chunk-ZAMHLXNS.js";
33
33
  import {
34
34
  ProviderLogo
35
35
  } from "../chunk-RASGKEAL.js";
36
- import "../chunk-VLMXVCDQ.js";
36
+ import "../chunk-KSLTD4FI.js";
37
37
  import {
38
38
  GENERATION_TYPES,
39
39
  aspectRatioFromOptions,
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  AGENT_PROFILE_EDITOR_SECTIONS,
3
3
  AgentProfileEditor
4
- } from "../chunk-GOPBMDCQ.js";
5
- import "../chunk-IQZSV5YG.js";
6
- import "../chunk-G37LZ2FN.js";
7
- import "../chunk-SLXJZGXE.js";
4
+ } from "../chunk-NZMP7PFG.js";
5
+ import "../chunk-B2X2GGV5.js";
6
+ import "../chunk-UN3PDU3M.js";
7
+ import "../chunk-6CDNITEO.js";
8
8
  import "../chunk-ZAMHLXNS.js";
9
9
  import "../chunk-RASGKEAL.js";
10
10
  import "../chunk-B7CL7ENS.js";
11
- import "../chunk-VLMXVCDQ.js";
11
+ import "../chunk-KSLTD4FI.js";
12
12
  import "../chunk-PV33JZKV.js";
13
13
  import "../chunk-RCSAAWOH.js";
14
14
  export {
@@ -21,9 +21,9 @@
21
21
  * - `layout="inline"` (default): model, harness, and effort sit side by side as
22
22
  * pills. This is the original arrangement; existing call sites that mounted
23
23
  * `ModelPicker` + a harness picker + `EffortPicker` in a row get the same UI.
24
- * - `layout="compact"`: the model picker stays inline and visible; the agent
25
- * backend ("harness") and reasoning-effort controls — internal jargon a user
26
- * rarely needs — tuck behind a single gear popover with plain-English copy.
24
+ * - `layout="compact"`: the model picker stays inline and visible; the
25
+ * harness and reasoning-effort controls — settings a user rarely needs —
26
+ * tuck behind a single gear popover with plain-English copy.
27
27
  *
28
28
  * Two trigger treatments, also additive (`variant`, see `PickerVariant` in
29
29
  * `./controls`): `chip` (default) is the bordered pill every child draws
@@ -106,7 +106,9 @@ export interface AgentSessionControlsProps {
106
106
  /** Current harness; harness↔model coherence is enforced on every change. */
107
107
  harness: Harness;
108
108
  onHarnessChange(harness: Harness): void;
109
- /** Harnesses to offer; defaults to the labeled set. */
109
+ /** Harnesses to offer; defaults to the labeled set. Intersected with the
110
+ * harnesses the capability table allows for the selected model — the
111
+ * current harness always stays listed. */
110
112
  availableHarnesses?: ReadonlyArray<Harness>;
111
113
  /** Reasoning-effort value + setter. Shown only when the selected model
112
114
  * `supportsReasoning`, matching `EffortPicker`'s guidance. */
@@ -8,9 +8,9 @@
8
8
  * {type:'turn'|'metadata'|'error'|'turn_status', ...} (route-level)
9
9
  * {type:'interaction', data:{request}} (sidecar ask)
10
10
  *
11
- * Replayed lines carry an extra `seq` — transparently ignored. Works for
12
- * router-backed and sandbox-backed chats alike: anything producing these
13
- * lines (live pump, queued follow, resume replay) feeds the same callbacks.
11
+ * Replayed lines carry an extra `seq` — `consumeChatStream` tracks the last
12
+ * one so `streamChatTurn` can resume a dropped replay from the tail instead of
13
+ * replaying the whole turn.
14
14
  */
15
15
  import { type ChatInteraction, type InteractionCancelData } from './chat-interactions.js';
16
16
  import { type ChatPlan } from '../plans/index.js';
@@ -149,15 +149,23 @@ export interface ConsumeChatStreamResult {
149
149
  turnId: string | null;
150
150
  /** True when any text/reasoning/tool activity was received. */
151
151
  receivedContent: boolean;
152
+ /** The last `seq` a replayed line stamped (0 when none did): a resume after
153
+ * a replay continues from here; after a live stream it starts from 0. */
154
+ lastSeq: number;
152
155
  }
153
156
  /** Parse one NDJSON line into the callbacks. Exposed for tests. */
154
157
  export declare function dispatchChatStreamLine(line: string, cb: ChatStreamCallbacks): {
155
158
  turnId?: string;
156
159
  receivedContent: boolean;
160
+ /** The line's stamped buffer ordinal, when it carried a positive one. */
161
+ seq?: number;
157
162
  };
158
163
  /** Drain one NDJSON body into the callbacks. Throws on transport failure
159
- * (caller decides whether to resume). */
160
- export declare function consumeChatStream(body: ReadableStream<Uint8Array>, cb: ChatStreamCallbacks): Promise<ConsumeChatStreamResult>;
164
+ * (caller decides whether to resume). `seen` accumulates the last stamped seq
165
+ * as lines arrive so it survives this stream dropping. */
166
+ export declare function consumeChatStream(body: ReadableStream<Uint8Array>, cb: ChatStreamCallbacks, seen?: {
167
+ lastSeq: number;
168
+ }): Promise<ConsumeChatStreamResult>;
161
169
  /** Define options for managing and resuming streaming chat interactions with callbacks */
162
170
  export interface StreamChatOptions {
163
171
  /** Start the turn (POST the chat request); must return a streaming Response. */
@@ -166,12 +174,22 @@ export interface StreamChatOptions {
166
174
  resume?: (turnId: string, fromSeq: number) => Promise<Response>;
167
175
  callbacks: ChatStreamCallbacks;
168
176
  /** Called before a resume replays from 0 so the UI can reset accumulated
169
- * turn state (text, reasoning, tool chips). */
177
+ * turn state. A tail resume (fromSeq > 0) keeps it and does not call this. */
170
178
  onResetForResume?: () => void;
179
+ /** Automatic reconnects after transport drops before the turn fails with the
180
+ * last transport error. Default 5. */
181
+ maxReconnects?: number;
182
+ /** Milliseconds to wait before reconnect attempt N (0-based); default
183
+ * {@link defaultReconnectDelayMs}. */
184
+ reconnectDelayMs?: (attempt: number) => number;
171
185
  }
186
+ /** The default reconnect schedule: exponential from 500ms with ±50% jitter, capped at 8s. */
187
+ export declare function defaultReconnectDelayMs(attempt: number, rand?: () => number): number;
172
188
  /**
173
- * Run one chat turn with automatic single-shot resume: if the transport drops
174
- * mid-turn and the server announced a turnId, reset and replay the buffered
175
- * turn. Server-side the turn keeps running either way (queued runner).
189
+ * Run one chat turn with bounded automatic resume: reconnect with backoff and
190
+ * resume from the last stamped seq — a live drop resets and replays from 0, a
191
+ * replay drop resumes the tail only, one reasoning tracker across all of it.
192
+ * The turn keeps running server-side (queued runner); once the reconnect
193
+ * budget is spent the last transport error surfaces.
176
194
  */
177
195
  export declare function streamChatTurn(opts: StreamChatOptions): Promise<ConsumeChatStreamResult>;
@@ -67,8 +67,8 @@ export interface EffortPickerProps {
67
67
  value: string;
68
68
  onChange: (id: string) => void;
69
69
  /** Selectable levels (engine id + user-facing label). Defaults to the plain
70
- * "Thinking" vocabulary; override to relabel without changing the ids the
71
- * runtime receives.
70
+ * reasoning-effort vocabulary; override to relabel without changing the ids
71
+ * the runtime receives.
72
72
  *
73
73
  * A list that omits the current `value` is not a rendering error the picker
74
74
  * papers over: `value` is reconciled INTO the rendered list under its own
@@ -76,7 +76,8 @@ export interface EffortPickerProps {
76
76
  * the depth the session is running at and never some other list entry. */
77
77
  levels?: readonly EffortLevel[];
78
78
  /** Prefix shown before the active level on the pill — the "what is this"
79
- * context the bare value lacked. Default "Thinking". Pass '' to hide it. */
79
+ * context the bare value lacked. Default "Reasoning effort". Pass '' to
80
+ * hide it. */
80
81
  label?: string;
81
82
  /** Fill the container instead of shrink-wrapping — opt-in, default `false`;
82
83
  * see {@link pickerRootClass} for when and why. */
@@ -89,9 +90,9 @@ export interface EffortPickerProps {
89
90
  id?: string;
90
91
  'aria-describedby'?: string;
91
92
  }
92
- /** Thinking-budget selector pill, styled to match {@link ModelPicker}. Show
93
- * it only when the selected model `supportsReasoning`. "Thinking" is the
94
- * plain-English name for what was internally called "effort".
93
+ /** Reasoning-effort selector pill, styled to match {@link ModelPicker}. Show
94
+ * it only when the selected model `supportsReasoning`. "Reasoning effort" is
95
+ * the plain-English name for what was internally called "effort".
95
96
  *
96
97
  * The CANONICAL ecosystem effort picker — sandbox-ui's reasoning menu (inside
97
98
  * its `chat/AgentSessionControls`) is legacy and frozen. */
@@ -57,6 +57,7 @@ import {
57
57
  createInteractionAnswerSubmitter,
58
58
  createMemoryInteractionAttemptStore,
59
59
  createSessionInteractionAttemptStore,
60
+ defaultReconnectDelayMs,
60
61
  describeProvenance,
61
62
  describeProvenanceSourceStatus,
62
63
  diffRecordGridProposal,
@@ -151,7 +152,7 @@ import {
151
152
  withoutRecordGridCreated,
152
153
  withoutRecordGridRemoved,
153
154
  withoutRecordGridUpdate
154
- } from "../chunk-GN5JME4V.js";
155
+ } from "../chunk-6VRM2RVY.js";
155
156
  import {
156
157
  useInfiniteScroll
157
158
  } from "../chunk-UHSUY6H6.js";
@@ -168,7 +169,7 @@ import {
168
169
  AGENT_PROFILE_EDITOR_SECTIONS,
169
170
  AgentProfileEditor,
170
171
  AgentProfileRegistryError
171
- } from "../chunk-GOPBMDCQ.js";
172
+ } from "../chunk-NZMP7PFG.js";
172
173
  import {
173
174
  EvidenceLineageTable,
174
175
  ExceptionList,
@@ -197,7 +198,7 @@ import {
197
198
  preloadWhenIdle,
198
199
  useComposerAttachments,
199
200
  useDictation
200
- } from "../chunk-MK7VUZU7.js";
201
+ } from "../chunk-Z5Y6OYAP.js";
201
202
  import "../chunk-L7MB2LLM.js";
202
203
  import {
203
204
  AgentSessionControls,
@@ -208,18 +209,18 @@ import {
208
209
  filterAcceptedFiles,
209
210
  isAcceptedFileType,
210
211
  renamePastedImages
211
- } from "../chunk-IQZSV5YG.js";
212
+ } from "../chunk-B2X2GGV5.js";
212
213
  import {
213
214
  WorkspaceInitial,
214
215
  WorkspaceSwitcher
215
- } from "../chunk-MM2GG3IX.js";
216
+ } from "../chunk-4W6MDZQH.js";
216
217
  import {
217
218
  WorkspacePrewarmContext,
218
219
  requestWorkspacePrewarm,
219
220
  useWorkspacePrewarm,
220
221
  useWorkspacePrewarmHandle
221
222
  } from "../chunk-2HQP2CTA.js";
222
- import "../chunk-G37LZ2FN.js";
223
+ import "../chunk-UN3PDU3M.js";
223
224
  import {
224
225
  DEFAULT_EFFORT_LEVELS,
225
226
  EFFORT_METER_SEGMENTS,
@@ -237,7 +238,7 @@ import {
237
238
  reconcileEffortLevels,
238
239
  usePending,
239
240
  usePopover
240
- } from "../chunk-SLXJZGXE.js";
241
+ } from "../chunk-6CDNITEO.js";
241
242
  import "../chunk-ZAMHLXNS.js";
242
243
  import "../chunk-SJWIZT7B.js";
243
244
  import {
@@ -317,7 +318,7 @@ import {
317
318
  mentionKindForPath,
318
319
  settleTurnResponse
319
320
  } from "../chunk-K2JPSXKI.js";
320
- import "../chunk-VLMXVCDQ.js";
321
+ import "../chunk-KSLTD4FI.js";
321
322
  import "../chunk-PV33JZKV.js";
322
323
  import "../chunk-RCSAAWOH.js";
323
324
  import "../chunk-4PIN6QYQ.js";
@@ -446,6 +447,7 @@ export {
446
447
  createMemoryInteractionAttemptStore,
447
448
  createSessionInteractionAttemptStore,
448
449
  dedupeQuestionInteractionsByContent,
450
+ defaultReconnectDelayMs,
449
451
  describeProvenance,
450
452
  describeProvenanceSourceStatus,
451
453
  dictationErrorMessage,
@@ -34,8 +34,8 @@ export declare const OVERLAY_SHADOW = "shadow-[var(--shadow-overlay)]";
34
34
  * panel wants the opposite — the compact `AgentSessionControls` gear popover
35
35
  * lays its controls out in a column, and a shrink-wrapped root there makes a
36
36
  * trigger's own `w-full` a no-op, since it fills a box the trigger itself
37
- * sized. That is what left Agent backend short of the panel edge and Thinking
38
- * narrower still.
37
+ * sized. That is what left the harness trigger short of the panel edge and
38
+ * the effort picker narrower still.
39
39
  *
40
40
  * The panel is portaled ({@link PopoverSurface}), so widening the root widens
41
41
  * the TRIGGER only. A menu that should follow it declares `matchTriggerWidth`.
@@ -3,20 +3,20 @@ import {
3
3
  ActionDialogButton,
4
4
  WorkspaceInitial,
5
5
  WorkspaceSwitcher
6
- } from "../chunk-MM2GG3IX.js";
6
+ } from "../chunk-4W6MDZQH.js";
7
7
  import {
8
8
  WorkspacePrewarmContext,
9
9
  useWorkspacePrewarm
10
10
  } from "../chunk-2HQP2CTA.js";
11
11
  import {
12
12
  usePopoverDialog
13
- } from "../chunk-G37LZ2FN.js";
13
+ } from "../chunk-UN3PDU3M.js";
14
14
  import {
15
15
  CheckGlyph,
16
16
  OVERLAY_SHADOW,
17
17
  PopoverSurface,
18
18
  usePopover
19
- } from "../chunk-SLXJZGXE.js";
19
+ } from "../chunk-6CDNITEO.js";
20
20
  import "../chunk-ZAMHLXNS.js";
21
21
  import {
22
22
  buildSessionNavItem,
@@ -24,7 +24,7 @@ import {
24
24
  resolveActiveNavId
25
25
  } from "../chunk-SJWIZT7B.js";
26
26
  import "../chunk-RASGKEAL.js";
27
- import "../chunk-VLMXVCDQ.js";
27
+ import "../chunk-KSLTD4FI.js";
28
28
 
29
29
  // src/workspace-react/index.tsx
30
30
  import { SidebarLayout } from "@tangle-network/sandbox-ui/dashboard";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-app",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "packageManager": "pnpm@11.28.8",
5
5
  "description": "Build agent applications with typed chat, tools, sandboxes, integrations, billing, and evaluation.",
6
6
  "keywords": [