@tangle-network/agent-app 0.44.60 → 0.45.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.
Files changed (38) hide show
  1. package/dist/assistant/index.js +3 -3
  2. package/dist/chat-routes/index.js +4 -4
  3. package/dist/{chunk-CQZSAR77.js → chunk-73F3CKVK.js} +28 -18
  4. package/dist/chunk-73F3CKVK.js.map +1 -0
  5. package/dist/{chunk-APFJITYT.js → chunk-AOQ4FCSH.js} +5 -343
  6. package/dist/chunk-AOQ4FCSH.js.map +1 -0
  7. package/dist/{chunk-S4YW2Y52.js → chunk-BATKJP3P.js} +1 -1
  8. package/dist/chunk-BATKJP3P.js.map +1 -0
  9. package/dist/{chunk-ICOHEZK6.js → chunk-ITCINLSU.js} +2 -2
  10. package/dist/{chunk-3EJ6SFJI.js → chunk-IVEKCOM7.js} +68 -26
  11. package/dist/chunk-IVEKCOM7.js.map +1 -0
  12. package/dist/{chunk-WXWU2FEB.js → chunk-RDK3CN7Y.js} +2 -2
  13. package/dist/design-canvas/index.d.ts +2 -1
  14. package/dist/design-canvas/index.js +1 -1
  15. package/dist/harness/index.d.ts +25 -8
  16. package/dist/harness/index.js +1 -1
  17. package/dist/mcp-BOgNWSED.d.ts +174 -0
  18. package/dist/run/index.js +1 -1
  19. package/dist/runtime/index.d.ts +17 -7
  20. package/dist/runtime/index.js.map +1 -1
  21. package/dist/sandbox/index.d.ts +42 -503
  22. package/dist/sandbox/index.js +4 -38
  23. package/dist/sequences/index.d.ts +2 -1
  24. package/dist/sequences/index.js +1 -1
  25. package/dist/skills-placement/index.js +1 -1
  26. package/dist/tools/index.d.ts +2 -1
  27. package/dist/tools/index.js +5 -3
  28. package/dist/web-react/index.js +3 -3
  29. package/dist/web-react/terminal.d.ts +9 -13
  30. package/dist/web-react/terminal.js +1 -1
  31. package/package.json +3 -3
  32. package/dist/chunk-3EJ6SFJI.js.map +0 -1
  33. package/dist/chunk-APFJITYT.js.map +0 -1
  34. package/dist/chunk-CQZSAR77.js.map +0 -1
  35. package/dist/chunk-S4YW2Y52.js.map +0 -1
  36. package/dist/mcp-Dt4V4ZLT.d.ts +0 -95
  37. /package/dist/{chunk-ICOHEZK6.js.map → chunk-ITCINLSU.js.map} +0 -0
  38. /package/dist/{chunk-WXWU2FEB.js.map → chunk-RDK3CN7Y.js.map} +0 -0
@@ -13,10 +13,7 @@ import {
13
13
  assertEnvWithinLimits,
14
14
  assertProvisionPayloadWithinCap,
15
15
  attachReasoningEffort,
16
- bearerSubprotocolToken,
17
- bearerToken,
18
16
  buildAppToolMcpServers,
19
- buildSandboxRuntimeProxyHeaders,
20
17
  buildSandboxToolFileMounts,
21
18
  buildSandboxToolPathSetupScript,
22
19
  classifySeveredStream,
@@ -24,26 +21,18 @@ import {
24
21
  createD1PrewarmClaimStore,
25
22
  createSandboxPrewarmer,
26
23
  createSandboxTerminalConnectionRoute,
27
- createSandboxTerminalToken,
28
- createWorkspaceSandboxConnectionHandler,
29
24
  createWorkspaceSandboxManager,
30
- createWorkspaceSandboxRuntimeProxyHandler,
31
- createWorkspaceSandboxTerminalUpgradeHandler,
32
25
  deferredCorpusHash,
33
26
  deleteSecret,
34
27
  detectInteractiveQuestion,
35
28
  driveSandboxTurn,
36
- encodeSandboxRuntimePath,
37
29
  ensureWorkspaceSandbox,
38
30
  flattenHistory,
39
31
  getClient,
40
- isSandboxTerminalWsUpgrade,
41
32
  isTerminalPromptEvent,
42
- matchSandboxTerminalWsPath,
43
33
  mergeExtraMcp,
44
34
  mergeHistoryIntoParts,
45
35
  mintSandboxScopedToken,
46
- mintTerminalProxyToken,
47
36
  peekWorkspaceSandbox,
48
37
  readSandboxBinaryBytes,
49
38
  readSecret,
@@ -54,12 +43,10 @@ import {
54
43
  resolveSandboxClientCredentials,
55
44
  runSandboxPrompt,
56
45
  runSandboxToolPathSetup,
57
- sandboxSidecarProxyUrl,
58
46
  sandboxToolBinDir,
59
47
  sandboxToolPath,
60
48
  sandboxToolRootDir,
61
49
  secretStoreFromClient,
62
- selectedBearerSubprotocol,
63
50
  shellQuote,
64
51
  splitDeferredProfileFiles,
65
52
  statSandboxFileSize,
@@ -68,16 +55,12 @@ import {
68
55
  syncSandboxMemberAdd,
69
56
  syncSandboxMemberRemove,
70
57
  syncSandboxMemberRole,
71
- terminalTokenFromRequest,
72
- terminalUpgradeSubprotocolEcho,
73
- verifySandboxTerminalToken,
74
- verifyTerminalProxyToken,
75
58
  writeProfileFilesToBox
76
- } from "../chunk-APFJITYT.js";
59
+ } from "../chunk-AOQ4FCSH.js";
77
60
  import "../chunk-LWSJK546.js";
78
- import "../chunk-CQZSAR77.js";
79
- import "../chunk-ICOHEZK6.js";
80
- import "../chunk-3EJ6SFJI.js";
61
+ import "../chunk-73F3CKVK.js";
62
+ import "../chunk-ITCINLSU.js";
63
+ import "../chunk-IVEKCOM7.js";
81
64
  import "../chunk-YEFFHORB.js";
82
65
  import "../chunk-S5SRJJQG.js";
83
66
  import "../chunk-JML7WKWU.js";
@@ -96,10 +79,7 @@ export {
96
79
  assertEnvWithinLimits,
97
80
  assertProvisionPayloadWithinCap,
98
81
  attachReasoningEffort,
99
- bearerSubprotocolToken,
100
- bearerToken,
101
82
  buildAppToolMcpServers,
102
- buildSandboxRuntimeProxyHeaders,
103
83
  buildSandboxToolFileMounts,
104
84
  buildSandboxToolPathSetupScript,
105
85
  classifySeveredStream,
@@ -107,26 +87,18 @@ export {
107
87
  createD1PrewarmClaimStore,
108
88
  createSandboxPrewarmer,
109
89
  createSandboxTerminalConnectionRoute,
110
- createSandboxTerminalToken,
111
- createWorkspaceSandboxConnectionHandler,
112
90
  createWorkspaceSandboxManager,
113
- createWorkspaceSandboxRuntimeProxyHandler,
114
- createWorkspaceSandboxTerminalUpgradeHandler,
115
91
  deferredCorpusHash,
116
92
  deleteSecret,
117
93
  detectInteractiveQuestion,
118
94
  driveSandboxTurn,
119
- encodeSandboxRuntimePath,
120
95
  ensureWorkspaceSandbox,
121
96
  flattenHistory,
122
97
  getClient,
123
- isSandboxTerminalWsUpgrade,
124
98
  isTerminalPromptEvent,
125
- matchSandboxTerminalWsPath,
126
99
  mergeExtraMcp,
127
100
  mergeHistoryIntoParts,
128
101
  mintSandboxScopedToken,
129
- mintTerminalProxyToken,
130
102
  peekWorkspaceSandbox,
131
103
  readSandboxBinaryBytes,
132
104
  readSecret,
@@ -137,12 +109,10 @@ export {
137
109
  resolveSandboxClientCredentials,
138
110
  runSandboxPrompt,
139
111
  runSandboxToolPathSetup,
140
- sandboxSidecarProxyUrl,
141
112
  sandboxToolBinDir,
142
113
  sandboxToolPath,
143
114
  sandboxToolRootDir,
144
115
  secretStoreFromClient,
145
- selectedBearerSubprotocol,
146
116
  shellQuote,
147
117
  splitDeferredProfileFiles,
148
118
  statSandboxFileSize,
@@ -151,10 +121,6 @@ export {
151
121
  syncSandboxMemberAdd,
152
122
  syncSandboxMemberRemove,
153
123
  syncSandboxMemberRole,
154
- terminalTokenFromRequest,
155
- terminalUpgradeSubprotocolEcho,
156
- verifySandboxTerminalToken,
157
- verifyTerminalProxyToken,
158
124
  writeProfileFilesToBox
159
125
  };
160
126
  //# sourceMappingURL=index.js.map
@@ -1,8 +1,9 @@
1
1
  import { j as SequenceMediaKind, f as SequenceTimeline, k as TimelineInterval, b as SequenceStore } from '../store-B7LLlk9p.js';
2
2
  export { M as MIN_SEQUENCE_CLIP_FRAMES, N as NewSequenceClip, l as NewSequenceDecision, m as NewSequenceTrack, g as SequenceClip, a as SequenceClipMedia, n as SequenceClipPatch, o as SequenceDecision, d as SequenceExportFormat, h as SequenceExportRecord, p as SequenceExportStatus, q as SequenceFrameSnapshot, i as SequenceMeta, r as SequenceStatus, S as SequenceStoreScope, e as SequenceTrack, c as SequenceTrackKind, T as TimelineClipBounds, s as assertClipFitsSequence, t as chooseCaptionPlacement, u as clampClipDuration, v as clampClipStart, w as formatSeconds, x as formatTimecode, y as framesToSeconds, z as secondsToFrames, A as snapshotFrame, B as trackIntervals } from '../store-B7LLlk9p.js';
3
3
  export { A as AddCaptionOperation, C as CaptionTargetResolution, a as CreateTrackOperation, D as DeleteClipOperation, E as ExtendSequenceOperation, M as MoveClipOperation, P as PlaceClipOperation, Q as QueueExportOperation, S as SEQUENCE_OPERATION_TYPES, b as SequenceApplyResult, c as SequenceOperation, d as SequenceOperationContext, e as SequenceOperationType, f as SequencePlan, g as SetClipDisabledOperation, h as SetClipTextOperation, i as SplitClipOperation, T as TrimClipOperation, j as applySequenceOperation, k as applySequenceOperations, l as assertSequenceMediaUrl, m as captionTrackNameForLanguage, n as lastClipEndFrame, p as parseSequenceOperations, r as resolveCaptionPlacement, o as resolveCaptionTarget, q as resolvePlaceClipTrack, v as validateAddCaption, s as validateCreateTrack, t as validateDeleteClip, u as validateExtendSequence, w as validateMoveClip, x as validatePlaceClip, y as validateQueueExport, z as validateSequenceOperation, B as validateSequenceOperations, F as validateSetClipDisabled, G as validateSetClipText, H as validateSplitClip, I as validateTrimClip } from '../apply-6wlMOLf8.js';
4
- import { S as ScopedMcpServerEntryOptions, A as AppToolMcpServer } from '../mcp-Dt4V4ZLT.js';
4
+ import { S as ScopedMcpServerEntryOptions, A as AppToolMcpServer } from '../mcp-BOgNWSED.js';
5
5
  export { M as SEQUENCES_MCP_PROTOCOL_VERSIONS } from '../mcp-rpc-CzU5LWWT.js';
6
+ import '@tangle-network/agent-interface';
6
7
  import '../types-DbU-oO5h.js';
7
8
  import '../auth-DJs6lfAs.js';
8
9
 
@@ -18,7 +18,7 @@ import {
18
18
  MCP_PROTOCOL_VERSIONS,
19
19
  buildScopedMcpServerEntry,
20
20
  createMcpToolHandler
21
- } from "../chunk-3EJ6SFJI.js";
21
+ } from "../chunk-IVEKCOM7.js";
22
22
 
23
23
  // src/sequences/operations.ts
24
24
  var SEQUENCE_OPERATION_TYPES = [
@@ -4,7 +4,7 @@ import {
4
4
  } from "../chunk-M3UFMQ7D.js";
5
5
  import {
6
6
  KNOWN_HARNESSES
7
- } from "../chunk-CQZSAR77.js";
7
+ } from "../chunk-73F3CKVK.js";
8
8
 
9
9
  // src/skills-placement/index.ts
10
10
  import { skillDirForHarness } from "@tangle-network/agent-profile-materialize";
@@ -2,8 +2,9 @@ import { T as ToolHeaderNames } from '../auth-DJs6lfAs.js';
2
2
  export { A as AuthenticateOptions, D as DEFAULT_HEADER_NAMES, a as ToolAuthResult, b as authenticateToolRequest, r as readToolArgs } from '../auth-DJs6lfAs.js';
3
3
  import { e as AppToolTaxonomy, d as AppToolHandlers, b as AppToolDefinition, A as AppToolContext, c as AppToolProducedEvent, f as AppToolOutcome, a as AppToolName } from '../types-DbU-oO5h.js';
4
4
  export { g as APP_TOOL_NAMES, h as AddCitationArgs, i as AddCitationResult, B as BuildAppToolsOptions, O as OpenAIFunctionTool, R as RenderUiArgs, j as RenderUiResult, S as ScheduleFollowupArgs, k as ScheduleFollowupResult, l as SubmitProposalArgs, m as SubmitProposalResult, n as buildAppToolOpenAITools, o as customToolToOpenAI, p as defineAppTool, q as findCustomTool, r as isAppToolName } from '../types-DbU-oO5h.js';
5
- export { A as AppToolMcpServer, B as BuildHttpMcpServerOptions, a as BuildMcpServerOptions, D as DEFAULT_APP_TOOL_PATHS, S as ScopedMcpServerEntryOptions, b as buildAppToolMcpServer, c as buildHttpMcpServer, d as buildScopedMcpServerEntry } from '../mcp-Dt4V4ZLT.js';
5
+ export { A as AppToolMcpServer, B as BuildHttpMcpServerOptions, a as BuildMcpServerOptions, D as DEFAULT_APP_TOOL_PATHS, S as ScopedMcpServerEntryOptions, b as buildAppToolMcpServer, c as buildHttpMcpServer, d as buildScopedMcpServerEntry, u as unresolvableSurfaceCredential } from '../mcp-BOgNWSED.js';
6
6
  export { C as CreateMcpToolHandlerOptions, M as MCP_PROTOCOL_VERSIONS, b as McpProtocolVersion, c as McpServerInfo, a as McpToolDefinition, d as createMcpToolHandler } from '../mcp-rpc-CzU5LWWT.js';
7
+ import '@tangle-network/agent-interface';
7
8
 
8
9
  /** A correctable bad-input error a tool handler throws; the HTTP layer maps it
9
10
  * to a 4xx with the code, the runtime layer to a failed tool_result. So the
@@ -9,7 +9,7 @@ import {
9
9
  restrictTaxonomy,
10
10
  verifyCapabilityToken,
11
11
  verifyExpiringCapabilityToken
12
- } from "../chunk-ICOHEZK6.js";
12
+ } from "../chunk-ITCINLSU.js";
13
13
  import {
14
14
  DEFAULT_APP_TOOL_PATHS,
15
15
  DEFAULT_HEADER_NAMES,
@@ -19,8 +19,9 @@ import {
19
19
  buildHttpMcpServer,
20
20
  buildScopedMcpServerEntry,
21
21
  createMcpToolHandler,
22
- readToolArgs
23
- } from "../chunk-3EJ6SFJI.js";
22
+ readToolArgs,
23
+ unresolvableSurfaceCredential
24
+ } from "../chunk-IVEKCOM7.js";
24
25
  import {
25
26
  APP_TOOL_NAMES,
26
27
  ToolInputError,
@@ -56,6 +57,7 @@ export {
56
57
  readToolArgs,
57
58
  resolveToolCapabilities,
58
59
  restrictTaxonomy,
60
+ unresolvableSurfaceCredential,
59
61
  verifyCapabilityToken,
60
62
  verifyExpiringCapabilityToken
61
63
  };
@@ -78,7 +78,7 @@ import {
78
78
  useSmoothText,
79
79
  useThinkingSeconds,
80
80
  waterfallLayout
81
- } from "../chunk-WXWU2FEB.js";
81
+ } from "../chunk-RDK3CN7Y.js";
82
82
  import "../chunk-FBVLEGEG.js";
83
83
  import "../chunk-GINKOZFD.js";
84
84
  import {
@@ -102,7 +102,7 @@ import {
102
102
  import {
103
103
  tabTerminalConnectionId,
104
104
  useSandboxTerminalConnection
105
- } from "../chunk-S4YW2Y52.js";
105
+ } from "../chunk-BATKJP3P.js";
106
106
  import "../chunk-QY4BRKRJ.js";
107
107
  import {
108
108
  ATTACHMENT_ACCEPT
@@ -157,7 +157,7 @@ import {
157
157
  stampInteractionAnswers
158
158
  } from "../chunk-3ZK5IJSW.js";
159
159
  import "../chunk-YJMCRXQQ.js";
160
- import "../chunk-CQZSAR77.js";
160
+ import "../chunk-73F3CKVK.js";
161
161
  export {
162
162
  ATTACHMENT_ACCEPT,
163
163
  AgentActivityPanel,
@@ -13,13 +13,10 @@ interface SandboxTerminalConnection {
13
13
  /**
14
14
  * Define the response structure for a sandbox terminal connection including URLs, token, status, and errors
15
15
  *
16
- * Transport-agnostic by construction (#341/#349): the browser-direct
17
- * scoped-token route (`createSandboxTerminalConnectionRoute`,
18
- * `src/sandbox/terminal-connection.ts`) returns `sidecarUrl` only no
19
- * `runtimeUrl` while the (now `@deprecated`) same-origin proxy route
20
- * returns both. `useSandboxTerminalConnection` below resolves
21
- * `runtimeUrl ?? sidecarUrl` so either shape lands on the same connection
22
- * state without a hook change.
16
+ * The browser-direct scoped-token route (`createSandboxTerminalConnectionRoute`,
17
+ * `src/sandbox/terminal-connection.ts`) returns `sidecarUrl`. The hook also
18
+ * exposes that URL through the historical `runtimeUrl` state field so existing
19
+ * terminal panels do not need transport-specific branching.
23
20
  *
24
21
  * `connectionId` is the id the route's minted token's `sid` is bound to
25
22
  * (echoed back from the `connectionId` the hook sent) — pass it straight
@@ -63,12 +60,11 @@ interface UseSandboxTerminalConnectionResult extends SandboxTerminalConnection {
63
60
  /**
64
61
  * Manage and maintain a sandbox terminal connection with automatic polling and token refresh handling
65
62
  *
66
- * Transport-agnostic (#341/#349): this hook does not care whether
67
- * `connectionUrl` is backed by the fleet-default browser-direct
68
- * scoped-token route (`createSandboxTerminalConnectionRoute`,
69
- * `src/sandbox/terminal-connection.ts`, `sidecarUrl` only) or the
70
- * `@deprecated` same-origin proxy route (`runtimeUrl` + `sidecarUrl`) — it
71
- * resolves `runtimeUrl ?? sidecarUrl` either way.
63
+ * `connectionUrl` is backed by the browser-direct scoped-token route
64
+ * (`createSandboxTerminalConnectionRoute`,
65
+ * `src/sandbox/terminal-connection.ts`). The route returns `sidecarUrl`; the
66
+ * hook normalizes it into both URL fields for compatibility with existing
67
+ * terminal panels.
72
68
  *
73
69
  * Pass `tabTerminalConnectionId()` as `opts.connectionId` — the hook forwards
74
70
  * it as the `connectionId` query parameter the browser-direct route requires
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  tabTerminalConnectionId,
3
3
  useSandboxTerminalConnection
4
- } from "../chunk-S4YW2Y52.js";
4
+ } from "../chunk-BATKJP3P.js";
5
5
  export {
6
6
  tabTerminalConnectionId,
7
7
  useSandboxTerminalConnection
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-app",
3
- "version": "0.44.60",
3
+ "version": "0.45.2",
4
4
  "packageManager": "pnpm@11.17.0",
5
5
  "description": "Build agent applications with typed chat, tools, sandboxes, integrations, billing, and evaluation.",
6
6
  "keywords": [
@@ -438,7 +438,7 @@
438
438
  "@tangle-network/agent-docs": "0.2.1",
439
439
  "@tangle-network/agent-eval": "0.135.2",
440
440
  "@tangle-network/agent-integrations": "^0.52.0",
441
- "@tangle-network/agent-interface": "0.36.0",
441
+ "@tangle-network/agent-interface": "0.40.0",
442
442
  "@tangle-network/agent-knowledge": "6.1.11",
443
443
  "@tangle-network/agent-profile-materialize": "0.9.2",
444
444
  "@tangle-network/agent-runtime": "0.109.2",
@@ -483,7 +483,7 @@
483
483
  "@radix-ui/react-dialog": ">=1.1",
484
484
  "@tangle-network/agent-eval": ">=0.135.2",
485
485
  "@tangle-network/agent-integrations": ">=0.52.0",
486
- "@tangle-network/agent-interface": ">=0.36.0",
486
+ "@tangle-network/agent-interface": ">=0.38.0 <0.41.0",
487
487
  "@tangle-network/agent-knowledge": ">=6.1.11",
488
488
  "@tangle-network/agent-profile-materialize": ">=0.9.2",
489
489
  "@tangle-network/agent-runtime": ">=0.109.2",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/tools/auth.ts","../src/tools/mcp.ts","../src/tools/mcp-rpc.ts"],"sourcesContent":["import type { AppToolContext } from './types'\n\n/**\n * Header names carrying the server-set per-turn context + the capability token.\n * Defaults are product-neutral (`X-Agent-App-*`); a product that already ships\n * a header convention (e.g. `X-Acme-User-Id`) passes its own.\n */\nexport interface ToolHeaderNames {\n userId: string\n workspaceId: string\n threadId: string\n}\n\n/** Provide default HTTP header names for user, workspace, and thread identification */\nexport const DEFAULT_HEADER_NAMES: ToolHeaderNames = {\n userId: 'X-Agent-App-User-Id',\n workspaceId: 'X-Agent-App-Workspace-Id',\n threadId: 'X-Agent-App-Thread-Id',\n}\n\n/** Define options to verify bearer tokens and customize authentication header names */\nexport interface AuthenticateOptions {\n /** Verify the bearer capability token belongs to `userId`. The product's\n * HMAC/JWT impl — the seam that keeps token crypto out of this package. */\n verifyToken: (userId: string, bearer: string) => Promise<boolean>\n headerNames?: ToolHeaderNames\n}\n\n/** Represent the result of tool authentication with success context or failure response */\nexport type ToolAuthResult =\n | { ok: true; ctx: AppToolContext }\n | { ok: false; response: Response }\n\n/**\n * Recover + verify the trusted context for a tool request. The user comes from\n * a server-set header and the bearer token MUST verify against THAT user; the\n * workspace comes from a header too — never from tool args — so the model can\n * neither forge identity nor target another workspace. Fail-closed: any missing\n * credential or a token minted for another user yields a 401/400 Response.\n */\nexport async function authenticateToolRequest(request: Request, opts: AuthenticateOptions): Promise<ToolAuthResult> {\n const h = opts.headerNames ?? DEFAULT_HEADER_NAMES\n const userId = request.headers.get(h.userId)?.trim()\n const workspaceId = request.headers.get(h.workspaceId)?.trim()\n const threadId = request.headers.get(h.threadId)?.trim() || null\n const bearer = request.headers.get('authorization')?.match(/^Bearer\\s+(.+)$/i)?.[1]\n\n if (!userId || !bearer) {\n return { ok: false, response: Response.json({ error: 'Missing capability credentials' }, { status: 401 }) }\n }\n if (!(await opts.verifyToken(userId, bearer))) {\n return { ok: false, response: Response.json({ error: 'Invalid capability token' }, { status: 401 }) }\n }\n if (!workspaceId) {\n return { ok: false, response: Response.json({ error: 'Missing workspace context' }, { status: 400 }) }\n }\n return { ok: true, ctx: { userId, workspaceId, threadId } }\n}\n\n/** Read a tool's argument object from the request body, tolerant of MCP host\n * aliases (`args` / `arguments`) or a bare body. Returns null on non-JSON. */\nexport async function readToolArgs<T>(request: Request): Promise<T | null> {\n let body: { args?: T; arguments?: T }\n try {\n body = (await request.json()) as typeof body\n } catch {\n return null\n }\n return (body.args ?? body.arguments ?? (body as T)) as T\n}\n","import type { AppToolContext } from './types'\nimport type { AppToolName } from './openai'\nimport type { AppToolDefinition } from './registry'\nimport type { ToolHeaderNames } from './auth'\nimport { DEFAULT_HEADER_NAMES } from './auth'\n\n/** Default route path each app tool is served at. A product mounts its routes\n * at these paths (or supplies its own via {@link BuildMcpServerOptions.paths}). */\nexport const DEFAULT_APP_TOOL_PATHS: Record<AppToolName, string> = {\n submit_proposal: '/api/tools/propose',\n schedule_followup: '/api/tools/followup',\n render_ui: '/api/tools/render-ui',\n add_citation: '/api/tools/citation',\n}\n\n/** The portable MCP server entry the sandbox SDK accepts (transport + url +\n * headers). Matches `AgentProfileMcpServer` structurally without importing the\n * sandbox SDK — products spread it into their profile's `mcp` map. */\nexport interface AppToolMcpServer {\n transport: 'http'\n url: string\n headers: Record<string, string>\n enabled: true\n metadata: { description: string }\n}\n\n/** Define configuration options for building an HTTP MCP server including path, baseUrl, token, context, and description */\nexport interface BuildHttpMcpServerOptions {\n /** Route path on the app the sandbox POSTs to (e.g. `/api/tools/propose`). */\n path: string\n /** App base URL the sandbox reaches back to (no trailing slash required). */\n baseUrl: string\n /** Per-user capability token, baked into the Authorization header. */\n token: string\n ctx: AppToolContext\n /** Tool description the model sees. */\n description: string\n headerNames?: ToolHeaderNames\n}\n\n/**\n * Build ONE HTTP MCP server entry — the generic agent→app bridge. The\n * capability token + the user/workspace/thread ids ride in server-set headers\n * (never tool args), so the model can't forge identity or target another\n * workspace. Workspace/thread headers are omitted when their `ctx` value is\n * empty/null (e.g. an integration-invoke bridge that's user-scoped only). Used\n * directly for non-app-tool bridges (integration_invoke) and via\n * {@link buildAppToolMcpServer} for the four app tools.\n */\nexport function buildHttpMcpServer(opts: BuildHttpMcpServerOptions): AppToolMcpServer {\n const base = opts.baseUrl.replace(/\\/+$/, '')\n const h = opts.headerNames ?? DEFAULT_HEADER_NAMES\n return {\n transport: 'http',\n url: `${base}${opts.path}`,\n headers: {\n Authorization: `Bearer ${opts.token}`,\n [h.userId]: opts.ctx.userId,\n ...(opts.ctx.workspaceId ? { [h.workspaceId]: opts.ctx.workspaceId } : {}),\n ...(opts.ctx.threadId ? { [h.threadId]: opts.ctx.threadId } : {}),\n 'Content-Type': 'application/json',\n },\n enabled: true,\n metadata: { description: opts.description },\n }\n}\n\n/** Options for a per-document/scoped MCP channel entry (design-canvas,\n * sequences, …). The capability token + path scope ONE resource; the document\n * id lives in the path, never a tool argument. */\nexport interface ScopedMcpServerEntryOptions {\n /** App base URL the sandbox reaches back to (trailing slash tolerated). */\n baseUrl: string\n /** Product route serving the resource's MCP handler — id is part of the path. */\n path: string\n /** Capability token the product minted for this (user, resource) scope. With\n * no token there is no entry to build — omit the server instead. */\n token: string\n /** Override the channel's default tool-server description. */\n description?: string\n /** Identity headers for products whose route recovers the user via\n * `authenticateToolRequest`. Omit when the bearer token is self-contained. */\n ctx?: AppToolContext\n headerNames?: ToolHeaderNames\n}\n\n/**\n * Build the `AgentProfileMcpServer`-shaped entry for a scoped, per-resource MCP\n * channel. The shared mechanism behind the per-domain entry builders\n * (`buildDesignCanvasMcpServerEntry`, `buildSequencesMcpServerEntry`): same\n * token/path guards, same description default, same ctx-vs-self-contained-token\n * branching. The domain is two parameters — `label` (for guard messages) and\n * `defaultDescription` — never baked.\n *\n * The no-`ctx` branch is a GENUINE behavioral path, not a shortcut: it emits a\n * self-contained-token entry with ONLY `Authorization` + `Content-Type`.\n * Routing it through {@link buildHttpMcpServer} would unconditionally write a\n * `userId` identity header (here `undefined`), so it stays a distinct branch.\n */\nexport function buildScopedMcpServerEntry(\n opts: ScopedMcpServerEntryOptions & { label: string; defaultDescription: string },\n): AppToolMcpServer {\n if (opts.token.trim().length === 0) {\n throw new Error(`${opts.label} requires a capability token — omit the MCP server when none is available`)\n }\n if (!opts.path.startsWith('/')) {\n throw new Error(`${opts.label} path must start with \"/\" (got \"${opts.path}\")`)\n }\n const description = opts.description ?? opts.defaultDescription\n\n if (opts.ctx) {\n return buildHttpMcpServer({\n path: opts.path,\n baseUrl: opts.baseUrl,\n token: opts.token,\n ctx: opts.ctx,\n description,\n headerNames: opts.headerNames ?? DEFAULT_HEADER_NAMES,\n })\n }\n\n return {\n transport: 'http',\n url: `${opts.baseUrl.replace(/\\/+$/, '')}${opts.path}`,\n headers: {\n Authorization: `Bearer ${opts.token}`,\n 'Content-Type': 'application/json',\n },\n enabled: true,\n metadata: { description },\n }\n}\n\n/** Define configuration options required to build an MCP server including tool, baseUrl, token, and context */\nexport interface BuildMcpServerOptions {\n /** A built-in app tool name, or a product-registered {@link AppToolDefinition}.\n * A custom tool supplies its route via `AppToolDefinition.path` (or `paths`). */\n tool: AppToolName | AppToolDefinition\n baseUrl: string\n token: string\n ctx: AppToolContext\n description: string\n headerNames?: ToolHeaderNames\n paths?: Partial<Record<string, string>>\n}\n\n/** Build one app-tool MCP server entry — a thin wrapper over\n * {@link buildHttpMcpServer} that resolves the tool's route path. Built-ins map\n * through {@link DEFAULT_APP_TOOL_PATHS}; a custom tool uses its own `path`\n * (or a `paths` override). */\nexport function buildAppToolMcpServer(opts: BuildMcpServerOptions): AppToolMcpServer {\n const path =\n typeof opts.tool === 'string'\n ? opts.paths?.[opts.tool] ?? DEFAULT_APP_TOOL_PATHS[opts.tool]\n : opts.paths?.[opts.tool.name] ?? opts.tool.path\n if (!path) {\n const name = typeof opts.tool === 'string' ? opts.tool : opts.tool.name\n throw new Error(`buildAppToolMcpServer: tool \"${name}\" has no route path — set AppToolDefinition.path or pass it via opts.paths`)\n }\n return buildHttpMcpServer({\n path,\n baseUrl: opts.baseUrl,\n token: opts.token,\n ctx: opts.ctx,\n description: opts.description,\n headerNames: opts.headerNames,\n })\n}\n","/**\n * Generic streamable-HTTP JSON-RPC 2.0 envelope for a tools-only MCP server.\n * Stateless, Workers-compatible: no session table, no SSE — every request gets\n * a single `application/json` response, which the streamable-HTTP transport\n * explicitly permits for tools-only servers.\n *\n * Protocol surface:\n * initialize → echo client's protocolVersion if supported, else latest\n * ping → empty result {}\n * notifications/* (no `id`) → 202 with no body\n * tools/list → tool manifest\n * tools/call → run + surface execution failures as isError text results\n * anything else → -32601\n *\n * Execution failures (argument shape, validation, store throws) become `isError`\n * tool results carrying the thrown message verbatim — the model reads WHY and\n * retries. Protocol misuse becomes a JSON-RPC error object.\n */\n\nexport const MCP_PROTOCOL_VERSIONS = ['2025-06-18', '2025-03-26', '2024-11-05'] as const\n/** Resolve a valid protocol version from the predefined MCP_PROTOCOL_VERSIONS array */\nexport type McpProtocolVersion = (typeof MCP_PROTOCOL_VERSIONS)[number]\n\nconst LATEST_PROTOCOL_VERSION: McpProtocolVersion = MCP_PROTOCOL_VERSIONS[0]\n\n/** Describe the structure of server information including name and version */\nexport interface McpServerInfo {\n name: string\n version: string\n}\n\n/** One tool entry in the registry the handler owns. */\nexport interface McpToolDefinition<TEnv = Record<string, never>> {\n name: string\n description: string\n /** JSON Schema for the `params.arguments` object. */\n inputSchema: Record<string, unknown>\n /** Receive validated (Record) args + the env the handler threaded; throw to\n * surface an isError result — never throw for protocol/framing issues. */\n run(args: Record<string, unknown>, env: TEnv): Promise<unknown>\n}\n\n/** Define options for creating a handler that manages MCP tools with environment support */\nexport interface CreateMcpToolHandlerOptions<TEnv = Record<string, never>> {\n serverInfo: McpServerInfo\n /** Full tool list; order IS the tools/list order. */\n tools: McpToolDefinition<TEnv>[]\n /** Per-request environment threaded into every `run` call. If your tools are\n * stateless (or carry state through closure) pass an empty builder:\n * `() => ({} as TEnv)`. */\n buildEnv(request: Request): TEnv | Promise<TEnv>\n}\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\ntype JsonRpcId = string | number | null\n\ninterface ToolCallContent {\n content: Array<{ type: 'text'; text: string }>\n isError?: true\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction rpcResult(id: JsonRpcId, result: unknown): Response {\n return Response.json({ jsonrpc: '2.0', id, result })\n}\n\nfunction rpcError(id: JsonRpcId, code: number, message: string, status = 200): Response {\n return Response.json({ jsonrpc: '2.0', id, error: { code, message } }, { status })\n}\n\n// ---------------------------------------------------------------------------\n// Factory\n// ---------------------------------------------------------------------------\n\n/**\n * Build a request handler for a tools-only MCP server. The returned function\n * accepts a standard `Request` and resolves to a `Response` — mount it on any\n * Cloudflare Worker route or Remix `loader`.\n *\n * The handler calls `buildEnv` exactly ONCE per `tools/call` request (after\n * the tool is found, before `run`) — non-`tools/call` paths skip it entirely\n * so metadata requests do not pay env-build cost.\n */\nexport function createMcpToolHandler<TEnv = Record<string, never>>(\n opts: CreateMcpToolHandlerOptions<TEnv>,\n): (request: Request) => Promise<Response> {\n const toolMap = new Map<string, McpToolDefinition<TEnv>>()\n for (const tool of opts.tools) {\n if (toolMap.has(tool.name)) throw new Error(`duplicate MCP tool name: ${tool.name}`)\n toolMap.set(tool.name, tool)\n }\n\n return async (request: Request): Promise<Response> => {\n if (request.method !== 'POST') {\n return new Response('MCP server accepts JSON-RPC 2.0 over POST only', {\n status: 405,\n headers: { Allow: 'POST' },\n })\n }\n\n let body: unknown\n try {\n body = await request.json()\n } catch {\n return rpcError(null, -32700, 'Parse error: request body is not valid JSON', 400)\n }\n\n if (Array.isArray(body)) {\n return rpcError(null, -32600, 'Invalid request: JSON-RPC batching is not supported', 400)\n }\n if (!isRecord(body) || body.jsonrpc !== '2.0' || typeof body.method !== 'string') {\n return rpcError(\n null,\n -32600,\n 'Invalid request: expected a JSON-RPC 2.0 object with jsonrpc \"2.0\" and a string method',\n 400,\n )\n }\n\n const method = body.method\n const params = isRecord(body.params) ? body.params : {}\n\n // Notifications have no `id` — acknowledge without a JSON-RPC body.\n if (!('id' in body) || body.id === undefined) {\n return new Response(null, { status: 202 })\n }\n const id = body.id as JsonRpcId\n\n switch (method) {\n case 'initialize': {\n const requested = typeof params.protocolVersion === 'string' ? params.protocolVersion : undefined\n const protocolVersion =\n requested !== undefined && (MCP_PROTOCOL_VERSIONS as readonly string[]).includes(requested)\n ? requested\n : LATEST_PROTOCOL_VERSION\n return rpcResult(id, {\n protocolVersion,\n capabilities: { tools: { listChanged: false } },\n serverInfo: opts.serverInfo,\n })\n }\n\n case 'ping':\n return rpcResult(id, {})\n\n case 'tools/list':\n return rpcResult(id, {\n tools: opts.tools.map((tool) => ({\n name: tool.name,\n description: tool.description,\n inputSchema: tool.inputSchema,\n })),\n })\n\n case 'tools/call': {\n const name = params.name\n if (typeof name !== 'string' || name.length === 0) {\n return rpcError(id, -32602, 'tools/call requires params.name (string)')\n }\n const tool = toolMap.get(name)\n if (!tool) {\n return rpcError(\n id,\n -32602,\n `Unknown tool: ${name}. Available tools: ${opts.tools.map((t) => t.name).join(', ')}`,\n )\n }\n if (params.arguments !== undefined && !isRecord(params.arguments)) {\n return rpcError(id, -32602, 'tools/call params.arguments must be an object when provided')\n }\n const args = isRecord(params.arguments) ? params.arguments : {}\n let env: TEnv\n try {\n env = await opts.buildEnv(request)\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n const payload: ToolCallContent = {\n content: [{ type: 'text', text: `${name} failed to build env: ${message}` }],\n isError: true,\n }\n return rpcResult(id, payload)\n }\n try {\n const result = await tool.run(args, env)\n const payload: ToolCallContent = { content: [{ type: 'text', text: JSON.stringify(result) }] }\n return rpcResult(id, payload)\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n const payload: ToolCallContent = {\n content: [{ type: 'text', text: `${name} failed: ${message}` }],\n isError: true,\n }\n return rpcResult(id, payload)\n }\n }\n\n default:\n return rpcError(id, -32601, `Method not found: ${method}`)\n }\n }\n}\n"],"mappings":";AAcO,IAAM,uBAAwC;AAAA,EACnD,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,UAAU;AACZ;AAsBA,eAAsB,wBAAwB,SAAkB,MAAoD;AAClH,QAAM,IAAI,KAAK,eAAe;AAC9B,QAAM,SAAS,QAAQ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