@tangle-network/agent-app 0.11.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/DesignCanvas-3JEEIT6Y.js +10 -0
  2. package/dist/DesignCanvas-3JEEIT6Y.js.map +1 -0
  3. package/dist/DesignCanvasEditor-37LPJIIR.js +9 -0
  4. package/dist/DesignCanvasEditor-37LPJIIR.js.map +1 -0
  5. package/dist/TimelineEditor-OXPJZDP2.js +12 -0
  6. package/dist/TimelineEditor-OXPJZDP2.js.map +1 -0
  7. package/dist/apply-Cp8c3K9D.d.ts +249 -0
  8. package/dist/chunk-2Q73HGDI.js +1743 -0
  9. package/dist/chunk-2Q73HGDI.js.map +1 -0
  10. package/dist/chunk-6UOE5CTA.js +1647 -0
  11. package/dist/chunk-6UOE5CTA.js.map +1 -0
  12. package/dist/chunk-7QCIYDGC.js +1119 -0
  13. package/dist/chunk-7QCIYDGC.js.map +1 -0
  14. package/dist/chunk-A76ZHWNF.js +194 -0
  15. package/dist/chunk-A76ZHWNF.js.map +1 -0
  16. package/dist/chunk-ABGSFUJQ.js +111 -0
  17. package/dist/chunk-ABGSFUJQ.js.map +1 -0
  18. package/dist/{chunk-4YTWB5MG.js → chunk-ETX4O4BB.js} +98 -1
  19. package/dist/chunk-ETX4O4BB.js.map +1 -0
  20. package/dist/chunk-F5KTWRO7.js +2276 -0
  21. package/dist/chunk-F5KTWRO7.js.map +1 -0
  22. package/dist/chunk-IHR6K3GF.js +2367 -0
  23. package/dist/chunk-IHR6K3GF.js.map +1 -0
  24. package/dist/chunk-JZAJE3JL.js +990 -0
  25. package/dist/chunk-JZAJE3JL.js.map +1 -0
  26. package/dist/chunk-ZYBWGSAZ.js +130 -0
  27. package/dist/chunk-ZYBWGSAZ.js.map +1 -0
  28. package/dist/design-canvas/drizzle.d.ts +569 -0
  29. package/dist/design-canvas/drizzle.js +183 -0
  30. package/dist/design-canvas/drizzle.js.map +1 -0
  31. package/dist/design-canvas/index.d.ts +261 -0
  32. package/dist/design-canvas/index.js +96 -0
  33. package/dist/design-canvas/index.js.map +1 -0
  34. package/dist/design-canvas-react/index.d.ts +916 -0
  35. package/dist/design-canvas-react/index.js +423 -0
  36. package/dist/design-canvas-react/index.js.map +1 -0
  37. package/dist/export-presets-Dl5Aa5xj.d.ts +284 -0
  38. package/dist/index.d.ts +11 -2
  39. package/dist/index.js +224 -6
  40. package/dist/mcp-CIupfjxV.d.ts +112 -0
  41. package/dist/mcp-rpc-DLw_r9PQ.d.ts +55 -0
  42. package/dist/model-BHLN208Z.d.ts +183 -0
  43. package/dist/runtime/index.d.ts +108 -1
  44. package/dist/runtime/index.js +7 -1
  45. package/dist/sequences/drizzle.d.ts +1244 -0
  46. package/dist/sequences/drizzle.js +368 -0
  47. package/dist/sequences/drizzle.js.map +1 -0
  48. package/dist/sequences/index.d.ts +331 -0
  49. package/dist/sequences/index.js +114 -0
  50. package/dist/sequences/index.js.map +1 -0
  51. package/dist/sequences-react/index.d.ts +752 -0
  52. package/dist/sequences-react/index.js +241 -0
  53. package/dist/sequences-react/index.js.map +1 -0
  54. package/dist/store-CUStmtdH.d.ts +64 -0
  55. package/dist/store-gckrNq-g.d.ts +242 -0
  56. package/dist/tools/index.d.ts +25 -108
  57. package/dist/tools/index.js +16 -6
  58. package/package.json +62 -2
  59. package/dist/chunk-4YTWB5MG.js.map +0 -1
  60. package/dist/chunk-OLCVUGGI.js +0 -137
  61. package/dist/chunk-OLCVUGGI.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,3 +1,108 @@
1
+ import {
2
+ DEFAULT_SEQUENCES_MCP_DESCRIPTION,
3
+ MAX_CAPTION_BATCH,
4
+ SEQUENCES_MCP_PROTOCOL_VERSIONS,
5
+ SEQUENCE_EXPORT_FORMATS,
6
+ SEQUENCE_MCP_TOOLS,
7
+ SEQUENCE_MEDIA_KINDS,
8
+ SEQUENCE_OPERATION_TYPES,
9
+ SEQUENCE_TRACK_KINDS,
10
+ applySequenceOperation,
11
+ applySequenceOperations,
12
+ assertSequenceMediaUrl,
13
+ buildCaptionChunks,
14
+ buildContactSheetManifest,
15
+ buildEdl,
16
+ buildOtio,
17
+ buildSequencesMcpServerEntry,
18
+ buildSrt,
19
+ buildVtt,
20
+ captionCoverage,
21
+ captionTrackNameForLanguage,
22
+ createSequencesMcpHandler,
23
+ findSequenceMcpTool,
24
+ lastClipEndFrame,
25
+ normalizeLanguageTag,
26
+ parseSequenceOperations,
27
+ planLanguageFanout,
28
+ resolveCaptionPlacement,
29
+ resolveCaptionTarget,
30
+ resolvePlaceClipTrack,
31
+ validateAddCaption,
32
+ validateCreateTrack,
33
+ validateDeleteClip,
34
+ validateExtendSequence,
35
+ validateMoveClip,
36
+ validatePlaceClip,
37
+ validateQueueExport,
38
+ validateSequenceOperation,
39
+ validateSequenceOperations,
40
+ validateSetClipDisabled,
41
+ validateSetClipText,
42
+ validateSplitClip,
43
+ validateTrimClip
44
+ } from "./chunk-6UOE5CTA.js";
45
+ import {
46
+ CANVAS_ELEMENT_KINDS,
47
+ CANVAS_MCP_TOOLS,
48
+ CANVAS_MCP_TOOL_NAMES,
49
+ DEFAULT_DESIGN_CANVAS_MCP_DESCRIPTION,
50
+ SCENE_OPERATION_TYPES,
51
+ applyBindingsToDocument,
52
+ buildDesignCanvasMcpServerEntry,
53
+ createDesignCanvasMcpHandler,
54
+ findCanvasMcpTool,
55
+ instantiateTemplate,
56
+ listTemplateSlots,
57
+ validateBindings
58
+ } from "./chunk-7QCIYDGC.js";
59
+ import {
60
+ MIN_SEQUENCE_CLIP_FRAMES,
61
+ assertClipFitsSequence,
62
+ chooseCaptionPlacement,
63
+ clampClipDuration,
64
+ clampClipStart,
65
+ formatSeconds,
66
+ formatTimecode,
67
+ framesToSeconds,
68
+ secondsToFrames,
69
+ snapshotFrame,
70
+ trackIntervals
71
+ } from "./chunk-ZYBWGSAZ.js";
72
+ import {
73
+ CHANNEL_PRESETS,
74
+ EXPORT_PRESETS,
75
+ SCENE_ELEMENT_KINDS,
76
+ SCENE_SCHEMA_VERSION,
77
+ SIZE_PRESETS,
78
+ applySceneOperation,
79
+ applySceneOperations,
80
+ assertColor,
81
+ assertFinite,
82
+ assertPositiveFinite,
83
+ assertSceneMediaSrc,
84
+ bleedAwareExportBounds,
85
+ bleedAwareExportRect,
86
+ boundsIntersect,
87
+ collectSlots,
88
+ createEmptyDocument,
89
+ createPage,
90
+ elementAabb,
91
+ elementExtent,
92
+ estimateTextHeight,
93
+ findElement,
94
+ findPreset,
95
+ matchPreset,
96
+ requireChannelPreset,
97
+ requireElement,
98
+ requirePage,
99
+ scaleForPreset,
100
+ scalePageForChannelPreset,
101
+ storeApplyScenePlan,
102
+ validateSceneOperation,
103
+ validateSceneOperations,
104
+ validateSlotValue
105
+ } from "./chunk-JZAJE3JL.js";
1
106
  import {
2
107
  DEFAULT_MISSION_STEP_KINDS,
3
108
  MISSION_CONTROL_CHANNEL_ID,
@@ -136,17 +241,23 @@ import {
136
241
  invokeIntegrationHub,
137
242
  resolveIntegrationAction
138
243
  } from "./chunk-L2TG5DBW.js";
244
+ import {
245
+ createCapabilityToken,
246
+ createExpiringCapabilityToken,
247
+ handleAppToolRequest,
248
+ verifyCapabilityToken,
249
+ verifyExpiringCapabilityToken
250
+ } from "./chunk-ABGSFUJQ.js";
139
251
  import {
140
252
  DEFAULT_APP_TOOL_PATHS,
141
253
  DEFAULT_HEADER_NAMES,
254
+ MCP_PROTOCOL_VERSIONS,
142
255
  authenticateToolRequest,
143
256
  buildAppToolMcpServer,
144
257
  buildHttpMcpServer,
145
- createCapabilityToken,
146
- handleAppToolRequest,
147
- readToolArgs,
148
- verifyCapabilityToken
149
- } from "./chunk-OLCVUGGI.js";
258
+ createMcpToolHandler,
259
+ readToolArgs
260
+ } from "./chunk-A76ZHWNF.js";
150
261
  import {
151
262
  DELEGATION_MCP_SERVER_KEY,
152
263
  DELEGATION_TOOLS,
@@ -162,12 +273,15 @@ import {
162
273
  buildCatalog,
163
274
  createAgentRuntime,
164
275
  createOpenAICompatStreamTurn,
276
+ createSurfaceRegistry,
277
+ defineSurfaceKind,
165
278
  fetchModelCatalog,
279
+ mergeSurfaceOverlay,
166
280
  normalizeModelId,
167
281
  runAppToolLoop,
168
282
  streamAppToolLoop,
169
283
  toLoopEvents
170
- } from "./chunk-4YTWB5MG.js";
284
+ } from "./chunk-ETX4O4BB.js";
171
285
  import {
172
286
  DEFAULT_TANGLE_BILLING_ENFORCEMENT_ENV_VAR,
173
287
  DEFAULT_TANGLE_ROUTER_BASE_URL,
@@ -206,26 +320,46 @@ export {
206
320
  APP_TOOL_NAMES,
207
321
  ApprovalEventSchema,
208
322
  BrandTokensSchema,
323
+ CANVAS_ELEMENT_KINDS,
324
+ CANVAS_MCP_TOOLS,
325
+ CANVAS_MCP_TOOL_NAMES,
326
+ CHANNEL_PRESETS,
209
327
  ConversionMetricsSchema,
210
328
  CopyContentSchema,
211
329
  DEFAULT_APP_TOOL_PATHS,
330
+ DEFAULT_DESIGN_CANVAS_MCP_DESCRIPTION,
212
331
  DEFAULT_HARNESS,
213
332
  DEFAULT_HEADER_NAMES,
214
333
  DEFAULT_MISSION_STEP_KINDS,
215
334
  DEFAULT_REDACTION_PATTERNS,
335
+ DEFAULT_SEQUENCES_MCP_DESCRIPTION,
216
336
  DEFAULT_TANGLE_BILLING_ENFORCEMENT_ENV_VAR,
217
337
  DEFAULT_TANGLE_ROUTER_BASE_URL,
218
338
  DELEGATION_MCP_SERVER_KEY,
219
339
  DELEGATION_TOOLS,
340
+ EXPORT_PRESETS,
220
341
  EmailContentSchema,
221
342
  HubExecClient,
222
343
  ImageContentSchema,
223
344
  KNOWN_HARNESSES,
345
+ MAX_CAPTION_BATCH,
346
+ MCP_PROTOCOL_VERSIONS,
347
+ MIN_SEQUENCE_CLIP_FRAMES,
224
348
  MISSION_CONTROL_CHANNEL_ID,
225
349
  MissionConcurrencyError,
226
350
  PRESET_MIGRATION_SQL,
227
351
  PRESET_TABLES,
228
352
  RetryableStepError,
353
+ SCENE_ELEMENT_KINDS,
354
+ SCENE_OPERATION_TYPES,
355
+ SCENE_SCHEMA_VERSION,
356
+ SEQUENCES_MCP_PROTOCOL_VERSIONS,
357
+ SEQUENCE_EXPORT_FORMATS,
358
+ SEQUENCE_MCP_TOOLS,
359
+ SEQUENCE_MEDIA_KINDS,
360
+ SEQUENCE_OPERATION_TYPES,
361
+ SEQUENCE_TRACK_KINDS,
362
+ SIZE_PRESETS,
229
363
  TURN_EVENTS_MIGRATION_SQL,
230
364
  TangleExecutionKeyError,
231
365
  ToolInputError,
@@ -233,28 +367,56 @@ export {
233
367
  __resetCatalogCache,
234
368
  addSecurityHeaders,
235
369
  agentAppConfigJsonSchema,
370
+ applyBindingsToDocument,
236
371
  applyMissionEvent,
372
+ applySceneOperation,
373
+ applySceneOperations,
374
+ applySequenceOperation,
375
+ applySequenceOperations,
237
376
  asMissionStreamEvent,
238
377
  asRecord,
239
378
  asString,
379
+ assertClipFitsSequence,
380
+ assertColor,
381
+ assertFinite,
382
+ assertPositiveFinite,
383
+ assertSceneMediaSrc,
384
+ assertSequenceMediaUrl,
240
385
  authenticateToolRequest,
386
+ bleedAwareExportBounds,
387
+ bleedAwareExportRect,
388
+ boundsIntersect,
241
389
  budgetGateProposalId,
242
390
  buildAgentMissionPlan,
243
391
  buildAppToolMcpServer,
244
392
  buildAppToolOpenAITools,
393
+ buildCaptionChunks,
245
394
  buildCatalog,
246
395
  buildConsentUrl,
396
+ buildContactSheetManifest,
247
397
  buildDelegationMcpServer,
398
+ buildDesignCanvasMcpServerEntry,
399
+ buildEdl,
248
400
  buildFlowTrace,
249
401
  buildHttpMcpServer,
250
402
  buildKnowledgeRequirements,
403
+ buildOtio,
251
404
  buildRedactedDocument,
405
+ buildSequencesMcpServerEntry,
406
+ buildSrt,
252
407
  buildUserTextParts,
408
+ buildVtt,
409
+ captionCoverage,
410
+ captionTrackNameForLanguage,
253
411
  checkRateLimit,
254
412
  childSpanContext,
413
+ chooseCaptionPlacement,
414
+ clampClipDuration,
415
+ clampClipStart,
255
416
  clearCookieHeader,
256
417
  coalesceDeltas,
257
418
  coerceHarness,
419
+ collectSlots,
258
420
  composeMissionFlowTrace,
259
421
  createAgentRuntime,
260
422
  createAppToolRuntimeExecutor,
@@ -262,15 +424,20 @@ export {
262
424
  createCapabilityToken,
263
425
  createD1KnowledgeStateAccessor,
264
426
  createD1TurnEventStore,
427
+ createDesignCanvasMcpHandler,
428
+ createEmptyDocument,
429
+ createExpiringCapabilityToken,
265
430
  createFieldCrypto,
266
431
  createInMemoryMissionStore,
267
432
  createKnowledgeLoop,
268
433
  createLlmCorrectnessChecker,
434
+ createMcpToolHandler,
269
435
  createMemoryTurnEventStore,
270
436
  createMissionEngine,
271
437
  createMissionService,
272
438
  createMissionTraceContext,
273
439
  createOpenAICompatStreamTurn,
440
+ createPage,
274
441
  createPlatformBalanceManager,
275
442
  createPresetDrizzleSchema,
276
443
  createPresetFieldCrypto,
@@ -278,6 +445,8 @@ export {
278
445
  createPresetWorkspaceKeyManager,
279
446
  createPresetWorkspaceKeyStore,
280
447
  createReviewerDecider,
448
+ createSequencesMcpHandler,
449
+ createSurfaceRegistry,
281
450
  createTangleRouterModelConfig,
282
451
  createTcloudKeyProvisioner,
283
452
  createTokenRecallChecker,
@@ -287,22 +456,34 @@ export {
287
456
  decryptBytes,
288
457
  decryptWithKey,
289
458
  defineAgentApp,
459
+ defineSurfaceKind,
290
460
  delegationActivityToFlowSpans,
291
461
  delegationMcpForConfig,
292
462
  deriveKey,
293
463
  deriveSignals,
294
464
  detectSpans,
295
465
  dispatchAppTool,
466
+ elementAabb,
467
+ elementExtent,
296
468
  encodeEvent,
297
469
  encryptAesGcm,
298
470
  encryptBytes,
299
471
  encryptWithKey,
472
+ estimateTextHeight,
300
473
  extractProducedState,
301
474
  extractRequestContext,
302
475
  fetchModelCatalog,
303
476
  finalizeAssistantParts,
477
+ findCanvasMcpTool,
478
+ findElement,
479
+ findPreset,
480
+ findSequenceMcpTool,
481
+ formatSeconds,
482
+ formatTimecode,
483
+ framesToSeconds,
304
484
  getPartKey,
305
485
  handleAppToolRequest,
486
+ instantiateTemplate,
306
487
  invokeIntegrationHub,
307
488
  isAppToolName,
308
489
  isHarness,
@@ -310,13 +491,18 @@ export {
310
491
  isMissionTerminal,
311
492
  isTangleBillingEnforcementDisabled,
312
493
  isTangleExecutionKeyError,
494
+ lastClipEndFrame,
495
+ listTemplateSlots,
313
496
  loopTraceEventsToFlowSpans,
314
497
  maskSpans,
498
+ matchPreset,
315
499
  mergeMissionState,
316
500
  mergePersistedPart,
501
+ mergeSurfaceOverlay,
317
502
  messageHasTurnId,
318
503
  noopEventSink,
319
504
  normalizeClientTurnId,
505
+ normalizeLanguageTag,
320
506
  normalizeModelId,
321
507
  normalizePersistedPart,
322
508
  normalizeTime,
@@ -325,7 +511,9 @@ export {
325
511
  parseAssetSpec,
326
512
  parseJsonObjectBody,
327
513
  parseMissionBlocks,
514
+ parseSequenceOperations,
328
515
  parseSessionStreamEnvelope,
516
+ planLanguageFanout,
329
517
  producedFromToolEvents,
330
518
  pumpBufferedTurn,
331
519
  readCookieValue,
@@ -335,9 +523,15 @@ export {
335
523
  renderHistogram,
336
524
  renderWaterfall,
337
525
  replayTurnEvents,
526
+ requireChannelPreset,
527
+ requireElement,
528
+ requirePage,
338
529
  requireString,
530
+ resolveCaptionPlacement,
531
+ resolveCaptionTarget,
339
532
  resolveChatTurn,
340
533
  resolveIntegrationAction,
534
+ resolvePlaceClipTrack,
341
535
  resolveSessionHarness,
342
536
  resolveTangleExecutionEnvironment,
343
537
  resolveTangleModelConfig,
@@ -349,18 +543,42 @@ export {
349
543
  reviewCandidate,
350
544
  runAppToolLoop,
351
545
  safeParseAssetSpec,
546
+ scaleForPreset,
547
+ scalePageForChannelPreset,
548
+ secondsToFrames,
352
549
  serializeCookie,
550
+ snapshotFrame,
353
551
  stepActivityFlowTrace,
354
552
  stepAgentActivity,
355
553
  stepGateProposalId,
554
+ storeApplyScenePlan,
356
555
  streamAppToolLoop,
357
556
  summarize,
358
557
  tangleExecutionKeyHttpError,
359
558
  timedEventsFromLines,
360
559
  toLoopEvents,
361
560
  traceEnv,
561
+ trackIntervals,
562
+ validateAddCaption,
563
+ validateBindings,
564
+ validateCreateTrack,
565
+ validateDeleteClip,
566
+ validateExtendSequence,
567
+ validateMoveClip,
568
+ validatePlaceClip,
569
+ validateQueueExport,
570
+ validateSceneOperation,
571
+ validateSceneOperations,
572
+ validateSequenceOperation,
573
+ validateSequenceOperations,
574
+ validateSetClipDisabled,
575
+ validateSetClipText,
576
+ validateSlotValue,
577
+ validateSplitClip,
578
+ validateTrimClip,
362
579
  verifyCapabilityToken,
363
580
  verifyCompletion,
581
+ verifyExpiringCapabilityToken,
364
582
  volumeGateProposalId,
365
583
  weightedComposite
366
584
  };
@@ -0,0 +1,112 @@
1
+ import { f as AppToolTaxonomy, b as AppToolContext } from './types-By4B3K37.js';
2
+
3
+ /** The four canonical app-tool names. Stable identifiers the model calls in
4
+ * both the sandbox (MCP server name) and runtime (function-tool name) paths. */
5
+ declare const APP_TOOL_NAMES: readonly ["submit_proposal", "schedule_followup", "render_ui", "add_citation"];
6
+ type AppToolName = (typeof APP_TOOL_NAMES)[number];
7
+ declare function isAppToolName(name: string): name is AppToolName;
8
+ /** A minimal OpenAI Chat Completions function-tool shape — structurally
9
+ * compatible with `@tangle-network/agent-runtime`'s `OpenAIChatTool` without
10
+ * importing it (keeps this package runtime-free). */
11
+ interface OpenAIFunctionTool {
12
+ type: 'function';
13
+ function: {
14
+ name: string;
15
+ description: string;
16
+ parameters: Record<string, unknown>;
17
+ };
18
+ }
19
+ /**
20
+ * Build the four app tools in OpenAI function-tool shape. `submit_proposal`'s
21
+ * `type` enum is the product's {@link AppToolTaxonomy.proposalTypes}; the other
22
+ * three are fixed. Pass the result to the agent-runtime backend's `tools`.
23
+ */
24
+ declare function buildAppToolOpenAITools(taxonomy: AppToolTaxonomy): OpenAIFunctionTool[];
25
+
26
+ /**
27
+ * Header names carrying the server-set per-turn context + the capability token.
28
+ * Defaults are product-neutral (`X-Agent-App-*`); a product that already ships
29
+ * a header convention (e.g. `X-Acme-User-Id`) passes its own.
30
+ */
31
+ interface ToolHeaderNames {
32
+ userId: string;
33
+ workspaceId: string;
34
+ threadId: string;
35
+ }
36
+ declare const DEFAULT_HEADER_NAMES: ToolHeaderNames;
37
+ interface AuthenticateOptions {
38
+ /** Verify the bearer capability token belongs to `userId`. The product's
39
+ * HMAC/JWT impl — the seam that keeps token crypto out of this package. */
40
+ verifyToken: (userId: string, bearer: string) => Promise<boolean>;
41
+ headerNames?: ToolHeaderNames;
42
+ }
43
+ type ToolAuthResult = {
44
+ ok: true;
45
+ ctx: AppToolContext;
46
+ } | {
47
+ ok: false;
48
+ response: Response;
49
+ };
50
+ /**
51
+ * Recover + verify the trusted context for a tool request. The user comes from
52
+ * a server-set header and the bearer token MUST verify against THAT user; the
53
+ * workspace comes from a header too — never from tool args — so the model can
54
+ * neither forge identity nor target another workspace. Fail-closed: any missing
55
+ * credential or a token minted for another user yields a 401/400 Response.
56
+ */
57
+ declare function authenticateToolRequest(request: Request, opts: AuthenticateOptions): Promise<ToolAuthResult>;
58
+ /** Read a tool's argument object from the request body, tolerant of MCP host
59
+ * aliases (`args` / `arguments`) or a bare body. Returns null on non-JSON. */
60
+ declare function readToolArgs<T>(request: Request): Promise<T | null>;
61
+
62
+ /** Default route path each app tool is served at. A product mounts its routes
63
+ * at these paths (or supplies its own via {@link BuildMcpServerOptions.paths}). */
64
+ declare const DEFAULT_APP_TOOL_PATHS: Record<AppToolName, string>;
65
+ /** The portable MCP server entry the sandbox SDK accepts (transport + url +
66
+ * headers). Matches `AgentProfileMcpServer` structurally without importing the
67
+ * sandbox SDK — products spread it into their profile's `mcp` map. */
68
+ interface AppToolMcpServer {
69
+ transport: 'http';
70
+ url: string;
71
+ headers: Record<string, string>;
72
+ enabled: true;
73
+ metadata: {
74
+ description: string;
75
+ };
76
+ }
77
+ interface BuildHttpMcpServerOptions {
78
+ /** Route path on the app the sandbox POSTs to (e.g. `/api/tools/propose`). */
79
+ path: string;
80
+ /** App base URL the sandbox reaches back to (no trailing slash required). */
81
+ baseUrl: string;
82
+ /** Per-user capability token, baked into the Authorization header. */
83
+ token: string;
84
+ ctx: AppToolContext;
85
+ /** Tool description the model sees. */
86
+ description: string;
87
+ headerNames?: ToolHeaderNames;
88
+ }
89
+ /**
90
+ * Build ONE HTTP MCP server entry — the generic agent→app bridge. The
91
+ * capability token + the user/workspace/thread ids ride in server-set headers
92
+ * (never tool args), so the model can't forge identity or target another
93
+ * workspace. Workspace/thread headers are omitted when their `ctx` value is
94
+ * empty/null (e.g. an integration-invoke bridge that's user-scoped only). Used
95
+ * directly for non-app-tool bridges (integration_invoke) and via
96
+ * {@link buildAppToolMcpServer} for the four app tools.
97
+ */
98
+ declare function buildHttpMcpServer(opts: BuildHttpMcpServerOptions): AppToolMcpServer;
99
+ interface BuildMcpServerOptions {
100
+ tool: AppToolName;
101
+ baseUrl: string;
102
+ token: string;
103
+ ctx: AppToolContext;
104
+ description: string;
105
+ headerNames?: ToolHeaderNames;
106
+ paths?: Partial<Record<AppToolName, string>>;
107
+ }
108
+ /** Build one of the four app-tool MCP servers — a thin wrapper over
109
+ * {@link buildHttpMcpServer} that maps the tool name to its route path. */
110
+ declare function buildAppToolMcpServer(opts: BuildMcpServerOptions): AppToolMcpServer;
111
+
112
+ export { APP_TOOL_NAMES as A, type BuildHttpMcpServerOptions as B, DEFAULT_APP_TOOL_PATHS as D, type OpenAIFunctionTool as O, type ToolAuthResult as T, type AppToolMcpServer as a, type AppToolName as b, type AuthenticateOptions as c, type BuildMcpServerOptions as d, DEFAULT_HEADER_NAMES as e, type ToolHeaderNames as f, authenticateToolRequest as g, buildAppToolMcpServer as h, buildAppToolOpenAITools as i, buildHttpMcpServer as j, isAppToolName as k, readToolArgs as r };
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Generic streamable-HTTP JSON-RPC 2.0 envelope for a tools-only MCP server.
3
+ * Stateless, Workers-compatible: no session table, no SSE — every request gets
4
+ * a single `application/json` response, which the streamable-HTTP transport
5
+ * explicitly permits for tools-only servers.
6
+ *
7
+ * Protocol surface:
8
+ * initialize → echo client's protocolVersion if supported, else latest
9
+ * ping → empty result {}
10
+ * notifications/* (no `id`) → 202 with no body
11
+ * tools/list → tool manifest
12
+ * tools/call → run + surface execution failures as isError text results
13
+ * anything else → -32601
14
+ *
15
+ * Execution failures (argument shape, validation, store throws) become `isError`
16
+ * tool results carrying the thrown message verbatim — the model reads WHY and
17
+ * retries. Protocol misuse becomes a JSON-RPC error object.
18
+ */
19
+ declare const MCP_PROTOCOL_VERSIONS: readonly ["2025-06-18", "2025-03-26", "2024-11-05"];
20
+ type McpProtocolVersion = (typeof MCP_PROTOCOL_VERSIONS)[number];
21
+ interface McpServerInfo {
22
+ name: string;
23
+ version: string;
24
+ }
25
+ /** One tool entry in the registry the handler owns. */
26
+ interface McpToolDefinition<TEnv = Record<string, never>> {
27
+ name: string;
28
+ description: string;
29
+ /** JSON Schema for the `params.arguments` object. */
30
+ inputSchema: Record<string, unknown>;
31
+ /** Receive validated (Record) args + the env the handler threaded; throw to
32
+ * surface an isError result — never throw for protocol/framing issues. */
33
+ run(args: Record<string, unknown>, env: TEnv): Promise<unknown>;
34
+ }
35
+ interface CreateMcpToolHandlerOptions<TEnv = Record<string, never>> {
36
+ serverInfo: McpServerInfo;
37
+ /** Full tool list; order IS the tools/list order. */
38
+ tools: McpToolDefinition<TEnv>[];
39
+ /** Per-request environment threaded into every `run` call. If your tools are
40
+ * stateless (or carry state through closure) pass an empty builder:
41
+ * `() => ({} as TEnv)`. */
42
+ buildEnv(request: Request): TEnv | Promise<TEnv>;
43
+ }
44
+ /**
45
+ * Build a request handler for a tools-only MCP server. The returned function
46
+ * accepts a standard `Request` and resolves to a `Response` — mount it on any
47
+ * Cloudflare Worker route or Remix `loader`.
48
+ *
49
+ * The handler calls `buildEnv` exactly ONCE per `tools/call` request (after
50
+ * the tool is found, before `run`) — non-`tools/call` paths skip it entirely
51
+ * so metadata requests do not pay env-build cost.
52
+ */
53
+ declare function createMcpToolHandler<TEnv = Record<string, never>>(opts: CreateMcpToolHandlerOptions<TEnv>): (request: Request) => Promise<Response>;
54
+
55
+ export { type CreateMcpToolHandlerOptions as C, MCP_PROTOCOL_VERSIONS as M, type McpProtocolVersion as a, type McpServerInfo as b, type McpToolDefinition as c, createMcpToolHandler as d };