@tangle-network/agent-app 0.40.0 → 0.41.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 (43) hide show
  1. package/dist/auth-DuptSkWh.d.ts +39 -0
  2. package/dist/{chunk-TQ5M7BFV.js → chunk-2A7STBX7.js} +2 -2
  3. package/dist/{chunk-FDJ6JQCI.js → chunk-3II3AWHY.js} +6 -4
  4. package/dist/{chunk-FDJ6JQCI.js.map → chunk-3II3AWHY.js.map} +1 -1
  5. package/dist/{chunk-RH74YJIK.js → chunk-7EVZUIHW.js} +7 -2
  6. package/dist/chunk-7EVZUIHW.js.map +1 -0
  7. package/dist/{chunk-DBIG2PHS.js → chunk-IZAH45W2.js} +3 -3
  8. package/dist/{chunk-PPSZNVKT.js → chunk-MFRCM32T.js} +29 -3
  9. package/dist/chunk-MFRCM32T.js.map +1 -0
  10. package/dist/{chunk-BUUJ7TEQ.js → chunk-NEOV2NQ3.js} +2 -2
  11. package/dist/{chunk-CPI3RILI.js → chunk-ULZEF45E.js} +49 -7
  12. package/dist/chunk-ULZEF45E.js.map +1 -0
  13. package/dist/{chunk-2FDTJIU4.js → chunk-WFMUDX5J.js} +2 -2
  14. package/dist/design-canvas/index.d.ts +3 -3
  15. package/dist/design-canvas/index.js +2 -2
  16. package/dist/eval/index.d.ts +1 -1
  17. package/dist/index.d.ts +4 -4
  18. package/dist/index.js +18 -8
  19. package/dist/{mcp-4I_RHhNa.d.ts → mcp-BHfIoGLW.d.ts} +10 -6
  20. package/dist/preset-cloudflare/index.d.ts +1 -1
  21. package/dist/runtime/index.d.ts +3 -3
  22. package/dist/runtime/index.js +2 -2
  23. package/dist/sandbox/index.d.ts +2 -2
  24. package/dist/sandbox/index.js +4 -4
  25. package/dist/sequences/index.d.ts +3 -3
  26. package/dist/sequences/index.js +2 -2
  27. package/dist/stream/index.d.ts +37 -3
  28. package/dist/stream/index.js +5 -1
  29. package/dist/tools/index.d.ts +13 -8
  30. package/dist/tools/index.js +9 -3
  31. package/dist/{types-wHs0rmtu.d.ts → types-BEOvc_ue.d.ts} +68 -1
  32. package/dist/web-react/index.d.ts +58 -1
  33. package/dist/web-react/index.js +241 -137
  34. package/dist/web-react/index.js.map +1 -1
  35. package/package.json +1 -1
  36. package/dist/auth-DcK5ERaL.d.ts +0 -65
  37. package/dist/chunk-CPI3RILI.js.map +0 -1
  38. package/dist/chunk-PPSZNVKT.js.map +0 -1
  39. package/dist/chunk-RH74YJIK.js.map +0 -1
  40. /package/dist/{chunk-TQ5M7BFV.js.map → chunk-2A7STBX7.js.map} +0 -0
  41. /package/dist/{chunk-DBIG2PHS.js.map → chunk-IZAH45W2.js.map} +0 -0
  42. /package/dist/{chunk-BUUJ7TEQ.js.map → chunk-NEOV2NQ3.js.map} +0 -0
  43. /package/dist/{chunk-2FDTJIU4.js.map → chunk-WFMUDX5J.js.map} +0 -0
@@ -9,7 +9,7 @@ import {
9
9
  import {
10
10
  buildScopedMcpServerEntry,
11
11
  createMcpToolHandler
12
- } from "./chunk-RH74YJIK.js";
12
+ } from "./chunk-7EVZUIHW.js";
13
13
 
14
14
  // src/design-canvas/operations.ts
15
15
  var SCENE_OPERATION_TYPES = [
@@ -1089,4 +1089,4 @@ export {
1089
1089
  DEFAULT_DESIGN_CANVAS_MCP_DESCRIPTION,
1090
1090
  buildDesignCanvasMcpServerEntry
1091
1091
  };
1092
- //# sourceMappingURL=chunk-2FDTJIU4.js.map
1092
+ //# sourceMappingURL=chunk-WFMUDX5J.js.map
@@ -6,9 +6,9 @@ import { d as SceneStore, N as NewSceneDecision, a as SceneDocumentRecord } from
6
6
  export { S as SceneDecision, b as SceneExportFormat, c as SceneExportRecord, e as SceneStoreScope } from '../store-CFyxgTlD.js';
7
7
  export { C as CHANNEL_PRESETS, a as ChannelPreset, b as ChannelPresetId, c as ChannelScaleResult, E as EXPORT_PRESETS, d as ExportCropRect, e as ExportFormat, f as ExportPreset, S as SIZE_PRESETS, g as SizePreset, h as bleedAwareExportBounds, i as bleedAwareExportRect, j as findPreset, m as matchPreset, r as requireChannelPreset, s as scaleForPreset, k as scalePageForChannelPreset } from '../export-presets-DAsU5Wal.js';
8
8
  import { c as McpToolDefinition } from '../mcp-rpc-DLw_r9PQ.js';
9
- import { S as ScopedMcpServerEntryOptions, A as AppToolMcpServer } from '../mcp-4I_RHhNa.js';
10
- import '../types-wHs0rmtu.js';
11
- import '../auth-DcK5ERaL.js';
9
+ import { S as ScopedMcpServerEntryOptions, A as AppToolMcpServer } from '../mcp-BHfIoGLW.js';
10
+ import '../types-BEOvc_ue.js';
11
+ import '../auth-DuptSkWh.js';
12
12
 
13
13
  /**
14
14
  * Pre-write validation for scene operations. Every rule runs against a
@@ -11,7 +11,7 @@ import {
11
11
  instantiateTemplate,
12
12
  listTemplateSlots,
13
13
  validateBindings
14
- } from "../chunk-2FDTJIU4.js";
14
+ } from "../chunk-WFMUDX5J.js";
15
15
  import {
16
16
  CHANNEL_PRESETS,
17
17
  EXPORT_PRESETS,
@@ -47,7 +47,7 @@ import {
47
47
  validateSlotValue
48
48
  } from "../chunk-M2EBUDZ7.js";
49
49
  import "../chunk-HFC4BTWJ.js";
50
- import "../chunk-RH74YJIK.js";
50
+ import "../chunk-7EVZUIHW.js";
51
51
  export {
52
52
  CANVAS_ELEMENT_KINDS,
53
53
  CANVAS_MCP_TOOLS,
@@ -1,6 +1,6 @@
1
1
  import { CompletionRequirement, RuntimeEventLike } from '@tangle-network/agent-eval';
2
2
  export { CompletionRequirement, CompletionVerdict, CorrectnessChecker, ProducedState, RuntimeEventLike, SatisfiedBy, TaskGold, createLlmCorrectnessChecker, extractProducedState, verifyCompletion, weightedComposite } from '@tangle-network/agent-eval';
3
- import { e as AppToolProducedEvent } from '../types-wHs0rmtu.js';
3
+ import { h as AppToolProducedEvent } from '../types-BEOvc_ue.js';
4
4
 
5
5
  /**
6
6
  * Eval — the app-shell BRIDGE to `@tangle-network/agent-eval`, not a reimpl.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export { AppToolRuntimeExecutor, CapabilityTokenOptions, DispatchOptions, ExpiringCapabilityTokenOptions, HandleToolRequestOptions, ResolveToolCapabilitiesOptions, ResolvedToolCapabilities, RuntimeExecutorOptions, ToolCapability, ToolInputError, createAppToolRuntimeExecutor, createCapabilityToken, createExpiringCapabilityToken, dispatchAppTool, handleAppToolRequest, outcomeStatus, resolveToolCapabilities, restrictTaxonomy, verifyCapabilityToken, verifyExpiringCapabilityToken } from './tools/index.js';
2
- export { A as APP_TOOL_NAMES, a as AppToolName, b as AuthenticateOptions, D as DEFAULT_HEADER_NAMES, O as OpenAIFunctionTool, T as ToolAuthResult, c as ToolHeaderNames, d as authenticateToolRequest, e as buildAppToolOpenAITools, i as isAppToolName, r as readToolArgs } from './auth-DcK5ERaL.js';
3
- 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-4I_RHhNa.js';
2
+ export { A as AuthenticateOptions, D as DEFAULT_HEADER_NAMES, T as ToolAuthResult, a as ToolHeaderNames, b as authenticateToolRequest, r as readToolArgs } from './auth-DuptSkWh.js';
3
+ export { A as APP_TOOL_NAMES, a as AddCitationArgs, b as AddCitationResult, c as AppToolContext, d as AppToolDefinition, e as AppToolHandlers, f as AppToolName, g as AppToolOutcome, h as AppToolProducedEvent, i as AppToolTaxonomy, 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-BEOvc_ue.js';
4
+ 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-BHfIoGLW.js';
4
5
  export { C as CreateMcpToolHandlerOptions, M as MCP_PROTOCOL_VERSIONS, a as McpProtocolVersion, b as McpServerInfo, c as McpToolDefinition, M as SEQUENCES_MCP_PROTOCOL_VERSIONS, d as createMcpToolHandler } from './mcp-rpc-DLw_r9PQ.js';
5
- export { A as AddCitationArgs, a as AddCitationResult, b as AppToolContext, c as AppToolHandlers, d as AppToolOutcome, e as AppToolProducedEvent, f as AppToolTaxonomy, B as BuildAppToolsOptions, R as RenderUiArgs, g as RenderUiResult, S as ScheduleFollowupArgs, h as ScheduleFollowupResult, i as SubmitProposalArgs, j as SubmitProposalResult } from './types-wHs0rmtu.js';
6
6
  export { BuildDelegationOptions, DELEGATION_MCP_SERVER_KEY, DELEGATION_TOOLS, DelegationMcpServer, buildDelegationMcpServer, delegationMcpForConfig } from './delegation/index.js';
7
7
  export { BrokerToken, BrokerTokenMinter, BrokerTokenProvider, BrokerTokenProviderOptions, ConsentUrlInput, buildConsentUrl, createBrokerTokenProvider } from './tangle/index.js';
8
8
  export { C as CatalogModel, M as ModelCatalog, R as RouterModel, _ as __resetCatalogCache, b as buildCatalog, f as fetchModelCatalog, n as normalizeModelId } from './model-catalog-BEAEVDaa.js';
@@ -16,7 +16,7 @@ export { AgentAppConfig, AgentDelegationConfig, AgentIdentityConfig, AgentIntegr
16
16
  export { D1Like, D1PreparedLike, DrizzleColumnLike, DrizzleSqliteCoreLike, PRESET_MIGRATION_SQL, PRESET_TABLES, PresetBillingOptions, PresetKnowledgeAccessorOptions, PresetToolHandlerOptions, VaultKv, createD1KnowledgeStateAccessor, createPresetDrizzleSchema, createPresetFieldCrypto, createPresetToolHandlers, createPresetWorkspaceKeyManager, createPresetWorkspaceKeyStore } from './preset-cloudflare/index.js';
17
17
  export { KeyCrypto, KeyProvisioner, PlanLimit, PlatformBalanceInfo, PlatformBalanceManager, PlatformBalanceManagerOptions, PlatformBillingClient, PlatformIdentity, PlatformProductUsage, SharedBillingState, TcloudKeyClient, WorkspaceKeyManager, WorkspaceKeyManagerOptions, WorkspaceKeyRecord, WorkspaceKeyStore, WorkspaceModelKeyUsage, createPlatformBalanceManager, createTcloudKeyProvisioner, createWorkspaceKeyManager } from './billing/index.js';
18
18
  export { DeriveKeyOptions, createFieldCrypto, decodeHexKey, decryptAesGcm, decryptBytes, decryptWithKey, deriveKey, encryptAesGcm, encryptBytes, encryptWithKey } from './crypto/index.js';
19
- export { BufferedTurnEvent, D1LikeForTurns, JsonRecord, PersistedChatMessageForTurn, PumpBufferedTurnOptions, ReplayTurnEventsOptions, ResolvedChatTurn, StreamEvent, TURN_EVENTS_MIGRATION_SQL, TurnEventStore, TurnStatus, asRecord, asString, buildUserTextParts, coalesceDeltas, createD1TurnEventStore, createMemoryTurnEventStore, encodeEvent, finalizeAssistantParts, getPartKey, mergePersistedPart, messageHasTurnId, normalizeClientTurnId, normalizePersistedPart, normalizeTime, normalizeToolEvent, pumpBufferedTurn, replayTurnEvents, resolveChatTurn, resolveToolId, resolveToolName } from './stream/index.js';
19
+ export { BufferedTurnEvent, D1LikeForTurns, JsonRecord, PersistedChatMessageForTurn, PumpBufferedTurnOptions, ReplayTurnEventsOptions, ResolvedChatTurn, StreamEvent, TURN_EVENTS_MIGRATION_SQL, TURN_STATUS_SCOPE_MIGRATION_SQL, TurnEventStore, TurnStatus, asRecord, asString, buildUserTextParts, coalesceChatStreamEvents, coalesceDeltas, createD1TurnEventStore, createMemoryTurnEventStore, encodeEvent, finalizeAssistantParts, getPartKey, mergePersistedPart, messageHasTurnId, normalizeClientTurnId, normalizePersistedPart, normalizeTime, normalizeToolEvent, pumpBufferedTurn, replayTurnEvents, resolveChatTurn, resolveToolId, resolveToolName } from './stream/index.js';
20
20
  export { HubExecClient, HubExecClientOptions, HubExecErrorCode, HubExecResult, HubInvokeDeps, HubInvokeInput, HubInvokeOutcome, ParsedIntegrationAction, invokeIntegrationHub, resolveIntegrationAction } from './integrations/index.js';
21
21
  export { CompleteMissionInput, CreateMissionInput, DEFAULT_MISSION_STEP_KINDS, InMemoryMissionStore, MISSION_CONTROL_CHANNEL_ID, MissionApprovalsPort, MissionAuditEvent, MissionConcurrencyError, MissionCostLedger, MissionEngine, MissionEngineOptions, MissionEventSink, MissionGateKind, MissionGateOptions, MissionGateProposal, MissionOutcome, MissionPlanRunOptions, MissionProposalResolution, MissionRecord, MissionService, MissionServiceOptions, MissionState, MissionStatus, MissionStep, MissionStepState, MissionStepStatus, MissionStorePort, MissionStreamEvent, MissionStreamStatus, MissionStreamStep, MissionStreamStepStatus, MissionUpdateGuard, MissionUpdatePatch, ParseMissionBlocksOptions, ParsedMission, ParsedMissionStep, PlanOutcome, RetryableStepError, SandboxDispatch, SandboxDispatchDoneResult, SandboxDispatchInProgressResult, SandboxDispatchInput, SandboxDispatchResult, SetStepStatusPatch, StepGateClassification, StepOutcome, applyMissionEvent, asMissionStreamEvent, budgetGateProposalId, buildAgentMissionPlan, createInMemoryMissionStore, createMissionEngine, createMissionService, isMissionStopRequested, isMissionTerminal, mergeMissionState, noopEventSink, parseMissionBlocks, parseSessionStreamEnvelope, reduceMissionEvents, stepGateProposalId, volumeGateProposalId } from './missions/index.js';
22
22
  export { S as StepAgentActivity, W as WithAgentActivity, s as stepAgentActivity } from './agent-activity-C8ZG0F0M.js';
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  instantiateTemplate,
13
13
  listTemplateSlots,
14
14
  validateBindings
15
- } from "./chunk-2FDTJIU4.js";
15
+ } from "./chunk-WFMUDX5J.js";
16
16
  import {
17
17
  darkTheme,
18
18
  lightTheme,
@@ -130,7 +130,7 @@ import {
130
130
  validateSetClipText,
131
131
  validateSplitClip,
132
132
  validateTrimClip
133
- } from "./chunk-BUUJ7TEQ.js";
133
+ } from "./chunk-NEOV2NQ3.js";
134
134
  import {
135
135
  MIN_SEQUENCE_CLIP_FRAMES,
136
136
  assertClipFitsSequence,
@@ -176,9 +176,11 @@ import {
176
176
  } from "./chunk-TA5Q4I2K.js";
177
177
  import {
178
178
  TURN_EVENTS_MIGRATION_SQL,
179
+ TURN_STATUS_SCOPE_MIGRATION_SQL,
179
180
  asRecord,
180
181
  asString,
181
182
  buildUserTextParts,
183
+ coalesceChatStreamEvents,
182
184
  coalesceDeltas,
183
185
  createD1TurnEventStore,
184
186
  createMemoryTurnEventStore,
@@ -196,7 +198,7 @@ import {
196
198
  resolveChatTurn,
197
199
  resolveToolId,
198
200
  resolveToolName
199
- } from "./chunk-CPI3RILI.js";
201
+ } from "./chunk-ULZEF45E.js";
200
202
  import {
201
203
  HubExecClient,
202
204
  invokeIntegrationHub,
@@ -290,7 +292,7 @@ import {
290
292
  verifySandboxTerminalToken,
291
293
  verifyTerminalProxyToken,
292
294
  writeProfileFilesToBox
293
- } from "./chunk-DBIG2PHS.js";
295
+ } from "./chunk-IZAH45W2.js";
294
296
  import {
295
297
  DEFAULT_HARNESS,
296
298
  HARNESS_MODEL_POLICIES,
@@ -313,7 +315,7 @@ import {
313
315
  restrictTaxonomy,
314
316
  verifyCapabilityToken,
315
317
  verifyExpiringCapabilityToken
316
- } from "./chunk-FDJ6JQCI.js";
318
+ } from "./chunk-3II3AWHY.js";
317
319
  import {
318
320
  DEFAULT_APP_TOOL_PATHS,
319
321
  DEFAULT_HEADER_NAMES,
@@ -324,7 +326,7 @@ import {
324
326
  buildScopedMcpServerEntry,
325
327
  createMcpToolHandler,
326
328
  readToolArgs
327
- } from "./chunk-RH74YJIK.js";
329
+ } from "./chunk-7EVZUIHW.js";
328
330
  import {
329
331
  DELEGATION_MCP_SERVER_KEY,
330
332
  DELEGATION_TOOLS,
@@ -349,7 +351,7 @@ import {
349
351
  runToolLoop,
350
352
  streamToolLoop,
351
353
  toLoopEvents
352
- } from "./chunk-TQ5M7BFV.js";
354
+ } from "./chunk-2A7STBX7.js";
353
355
  import {
354
356
  DEFAULT_TANGLE_BILLING_ENFORCEMENT_ENV_VAR,
355
357
  DEFAULT_TANGLE_ROUTER_BASE_URL,
@@ -370,10 +372,13 @@ import {
370
372
  ToolInputError,
371
373
  buildAppToolOpenAITools,
372
374
  createAppToolRuntimeExecutor,
375
+ customToolToOpenAI,
376
+ defineAppTool,
373
377
  dispatchAppTool,
378
+ findCustomTool,
374
379
  isAppToolName,
375
380
  outcomeStatus
376
- } from "./chunk-PPSZNVKT.js";
381
+ } from "./chunk-MFRCM32T.js";
377
382
  import {
378
383
  createLlmCorrectnessChecker,
379
384
  createTokenRecallChecker,
@@ -435,6 +440,7 @@ export {
435
440
  SIZE_PRESETS,
436
441
  SandboxRuntimeAuthRefreshError,
437
442
  TURN_EVENTS_MIGRATION_SQL,
443
+ TURN_STATUS_SCOPE_MIGRATION_SQL,
438
444
  TangleExecutionKeyError,
439
445
  ToolInputError,
440
446
  VideoContentSchema,
@@ -499,6 +505,7 @@ export {
499
505
  clampClipStart,
500
506
  classifySeveredStream,
501
507
  clearCookieHeader,
508
+ coalesceChatStreamEvents,
502
509
  coalesceDeltas,
503
510
  coerceHarness,
504
511
  collectSlots,
@@ -542,12 +549,14 @@ export {
542
549
  createWorkspaceSandboxManager,
543
550
  createWorkspaceSandboxRuntimeProxyHandler,
544
551
  createWorkspaceSandboxTerminalUpgradeHandler,
552
+ customToolToOpenAI,
545
553
  darkTheme,
546
554
  decodeHexKey,
547
555
  decryptAesGcm,
548
556
  decryptBytes,
549
557
  decryptWithKey,
550
558
  defineAgentApp,
559
+ defineAppTool,
551
560
  defineSurfaceKind,
552
561
  delegationActivityToFlowSpans,
553
562
  delegationMcpForConfig,
@@ -572,6 +581,7 @@ export {
572
581
  fetchModelCatalog,
573
582
  finalizeAssistantParts,
574
583
  findCanvasMcpTool,
584
+ findCustomTool,
575
585
  findElement,
576
586
  findPreset,
577
587
  findSequenceMcpTool,
@@ -1,5 +1,5 @@
1
- import { b as AppToolContext } from './types-wHs0rmtu.js';
2
- import { c as ToolHeaderNames, a as AppToolName } from './auth-DcK5ERaL.js';
1
+ import { c as AppToolContext, f as AppToolName, d as AppToolDefinition } from './types-BEOvc_ue.js';
2
+ import { a as ToolHeaderNames } from './auth-DuptSkWh.js';
3
3
 
4
4
  /** Default route path each app tool is served at. A product mounts its routes
5
5
  * at these paths (or supplies its own via {@link BuildMcpServerOptions.paths}). */
@@ -74,16 +74,20 @@ declare function buildScopedMcpServerEntry(opts: ScopedMcpServerEntryOptions & {
74
74
  defaultDescription: string;
75
75
  }): AppToolMcpServer;
76
76
  interface BuildMcpServerOptions {
77
- tool: AppToolName;
77
+ /** A built-in app tool name, or a product-registered {@link AppToolDefinition}.
78
+ * A custom tool supplies its route via `AppToolDefinition.path` (or `paths`). */
79
+ tool: AppToolName | AppToolDefinition;
78
80
  baseUrl: string;
79
81
  token: string;
80
82
  ctx: AppToolContext;
81
83
  description: string;
82
84
  headerNames?: ToolHeaderNames;
83
- paths?: Partial<Record<AppToolName, string>>;
85
+ paths?: Partial<Record<string, string>>;
84
86
  }
85
- /** Build one of the four app-tool MCP servers — a thin wrapper over
86
- * {@link buildHttpMcpServer} that maps the tool name to its route path. */
87
+ /** Build one app-tool MCP server entry — a thin wrapper over
88
+ * {@link buildHttpMcpServer} that resolves the tool's route path. Built-ins map
89
+ * through {@link DEFAULT_APP_TOOL_PATHS}; a custom tool uses its own `path`
90
+ * (or a `paths` override). */
87
91
  declare function buildAppToolMcpServer(opts: BuildMcpServerOptions): AppToolMcpServer;
88
92
 
89
93
  export { type AppToolMcpServer as A, type BuildHttpMcpServerOptions as B, DEFAULT_APP_TOOL_PATHS as D, type ScopedMcpServerEntryOptions as S, type BuildMcpServerOptions as a, buildAppToolMcpServer as b, buildHttpMcpServer as c, buildScopedMcpServerEntry as d };
@@ -1,6 +1,6 @@
1
1
  import { KeyProvisioner, KeyCrypto, WorkspaceKeyManager, WorkspaceKeyStore } from '../billing/index.js';
2
2
  import { KnowledgeStateAccessor } from '../knowledge/index.js';
3
- import { c as AppToolHandlers } from '../types-wHs0rmtu.js';
3
+ import { e as AppToolHandlers } from '../types-BEOvc_ue.js';
4
4
  import { KvLike } from '../web/index.js';
5
5
  import '@tangle-network/agent-eval';
6
6
 
@@ -3,10 +3,10 @@ export { C as CreateTangleRouterModelConfigOptions, D as DEFAULT_TANGLE_BILLING_
3
3
  import * as _tangle_network_agent_runtime from '@tangle-network/agent-runtime';
4
4
  import { ToolLoopMessage, ToolLoopResult, StreamToolLoopYield, ToolLoopCall } from '@tangle-network/agent-runtime';
5
5
  export { RunToolLoopOptions as AppToolLoopOptions, ToolLoopAssistantToolCall as LoopAssistantToolCall, ToolLoopMessage as LoopMessage, ToolLoopCall as LoopToolCall, StreamToolLoopOptions as StreamAppToolLoopOptions, StreamToolLoopYield as StreamLoopYield, ToolLoopEvent, ToolLoopResult, ToolLoopStopReason, runToolLoop as runAppToolLoop, streamToolLoop as streamAppToolLoop } from '@tangle-network/agent-runtime';
6
- import { b as AppToolContext, e as AppToolProducedEvent, f as AppToolTaxonomy, c as AppToolHandlers, d as AppToolOutcome } from '../types-wHs0rmtu.js';
6
+ import { c as AppToolContext, h as AppToolProducedEvent, i as AppToolTaxonomy, e as AppToolHandlers, g as AppToolOutcome } from '../types-BEOvc_ue.js';
7
7
  import { CertifiedProfile } from '@tangle-network/agent-runtime/intelligence';
8
- import { A as AppToolMcpServer } from '../mcp-4I_RHhNa.js';
9
- import '../auth-DcK5ERaL.js';
8
+ import { A as AppToolMcpServer } from '../mcp-BHfIoGLW.js';
9
+ import '../auth-DuptSkWh.js';
10
10
 
11
11
  /**
12
12
  * Events the app's OpenAI-compat stream adapter ({@link toLoopEvents}) yields.
@@ -12,7 +12,7 @@ import {
12
12
  runToolLoop,
13
13
  streamToolLoop,
14
14
  toLoopEvents
15
- } from "../chunk-TQ5M7BFV.js";
15
+ } from "../chunk-2A7STBX7.js";
16
16
  import {
17
17
  DEFAULT_TANGLE_BILLING_ENFORCEMENT_ENV_VAR,
18
18
  DEFAULT_TANGLE_ROUTER_BASE_URL,
@@ -28,7 +28,7 @@ import {
28
28
  tangleExecutionKeyHttpError,
29
29
  trimOrNull
30
30
  } from "../chunk-7W5XSTUF.js";
31
- import "../chunk-PPSZNVKT.js";
31
+ import "../chunk-MFRCM32T.js";
32
32
  export {
33
33
  DEFAULT_TANGLE_BILLING_ENFORCEMENT_ENV_VAR,
34
34
  DEFAULT_TANGLE_ROUTER_BASE_URL,
@@ -1,7 +1,7 @@
1
1
  import { AgentProfileFileMount, AgentProfileMcpServer, AgentProfile, StorageConfig, SandboxInstance, ScopedTokenScope, PromptResult, Sandbox } from '@tangle-network/sandbox';
2
2
  export { StorageConfig } from '@tangle-network/sandbox';
3
- import { a as AppToolName, c as ToolHeaderNames } from '../auth-DcK5ERaL.js';
4
- import { b as AppToolContext } from '../types-wHs0rmtu.js';
3
+ import { a as ToolHeaderNames } from '../auth-DuptSkWh.js';
4
+ import { f as AppToolName, c as AppToolContext } from '../types-BEOvc_ue.js';
5
5
  import { Harness } from '../harness/index.js';
6
6
  import { f as TangleExecutionEnvironment } from '../model-dF2h4xT9.js';
7
7
 
@@ -47,12 +47,12 @@ import {
47
47
  verifySandboxTerminalToken,
48
48
  verifyTerminalProxyToken,
49
49
  writeProfileFilesToBox
50
- } from "../chunk-DBIG2PHS.js";
50
+ } from "../chunk-IZAH45W2.js";
51
51
  import "../chunk-5VXPDXZJ.js";
52
- import "../chunk-FDJ6JQCI.js";
53
- import "../chunk-RH74YJIK.js";
52
+ import "../chunk-3II3AWHY.js";
53
+ import "../chunk-7EVZUIHW.js";
54
54
  import "../chunk-7W5XSTUF.js";
55
- import "../chunk-PPSZNVKT.js";
55
+ import "../chunk-MFRCM32T.js";
56
56
  export {
57
57
  DEFAULT_SANDBOX_RESOURCES,
58
58
  SandboxRuntimeAuthRefreshError,
@@ -1,10 +1,10 @@
1
1
  import { j as SequenceMediaKind, o as SequenceTimeline, r as TimelineInterval, m as SequenceStore } from '../store-gckrNq-g.js';
2
2
  export { M as MIN_SEQUENCE_CLIP_FRAMES, N as NewSequenceClip, a as NewSequenceDecision, b as NewSequenceTrack, S as SequenceClip, c as SequenceClipMedia, d as SequenceClipPatch, e as SequenceDecision, f as SequenceExportFormat, g as SequenceExportRecord, h as SequenceExportStatus, i as SequenceFrameSnapshot, k as SequenceMeta, l as SequenceStatus, n as SequenceStoreScope, p as SequenceTrack, q 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-gckrNq-g.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-Gk4raT2j.js';
4
- import { S as ScopedMcpServerEntryOptions, A as AppToolMcpServer } from '../mcp-4I_RHhNa.js';
4
+ import { S as ScopedMcpServerEntryOptions, A as AppToolMcpServer } from '../mcp-BHfIoGLW.js';
5
5
  export { M as SEQUENCES_MCP_PROTOCOL_VERSIONS } from '../mcp-rpc-DLw_r9PQ.js';
6
- import '../types-wHs0rmtu.js';
7
- import '../auth-DcK5ERaL.js';
6
+ import '../types-BEOvc_ue.js';
7
+ import '../auth-DuptSkWh.js';
8
8
 
9
9
  /**
10
10
  * Pure interchange-format builders over `SequenceTimeline` — SRT, WebVTT,
@@ -40,7 +40,7 @@ import {
40
40
  validateSetClipText,
41
41
  validateSplitClip,
42
42
  validateTrimClip
43
- } from "../chunk-BUUJ7TEQ.js";
43
+ } from "../chunk-NEOV2NQ3.js";
44
44
  import {
45
45
  MIN_SEQUENCE_CLIP_FRAMES,
46
46
  assertClipFitsSequence,
@@ -57,7 +57,7 @@ import {
57
57
  import "../chunk-HFC4BTWJ.js";
58
58
  import {
59
59
  MCP_PROTOCOL_VERSIONS
60
- } from "../chunk-RH74YJIK.js";
60
+ } from "../chunk-7EVZUIHW.js";
61
61
  export {
62
62
  DEFAULT_SEQUENCES_MCP_DESCRIPTION,
63
63
  MAX_CAPTION_BATCH,
@@ -62,13 +62,35 @@ interface BufferedTurnEvent {
62
62
  interface TurnEventStore {
63
63
  append(turnId: string, events: BufferedTurnEvent[]): Promise<void>;
64
64
  read(turnId: string, fromSeq: number): Promise<BufferedTurnEvent[]>;
65
- setStatus(turnId: string, status: TurnStatus): Promise<void>;
65
+ /** Record turn lifecycle. `scopeId` (a thread/session id) is optional and lets
66
+ * {@link TurnEventStore.listRunning} rediscover this turn after a client reload
67
+ * loses the turnId; stores that don't track scope ignore it. */
68
+ setStatus(turnId: string, status: TurnStatus, scopeId?: string): Promise<void>;
66
69
  getStatus(turnId: string): Promise<TurnStatus | null>;
70
+ /** Running turnIds for a scope, newest first — so a reloaded client (clientRunId
71
+ * lost) can find and resume the in-flight turn. Optional: a store records it
72
+ * only if `setStatus` was given a `scopeId`. */
73
+ listRunning?(scopeId: string): Promise<string[]>;
67
74
  }
68
75
  /** Merge consecutive text/reasoning deltas of the same type into one event.
69
76
  * Concatenation-preserving: replaying the coalesced stream produces the same
70
77
  * accumulated text as the original. */
71
78
  declare function coalesceDeltas(events: unknown[]): unknown[];
79
+ /**
80
+ * Coalesce consecutive `message.part.updated` deltas for the SAME part into one
81
+ * event. agent-runtime products stream `ChatStreamEvent` NDJSON
82
+ * (`{type:'message.part.updated', data:{part, delta}}`); pumped through the
83
+ * buffer with the default tool-loop coalescer, every per-token delta persists as
84
+ * its own row because that coalescer never recognizes the shape. Pass this as
85
+ * {@link PumpBufferedTurnOptions.coalesce} instead.
86
+ *
87
+ * Concatenation-preserving for BOTH consumer styles: the merged event keeps the
88
+ * LATEST event's `data.part` (already the cumulative accumulation) and sets
89
+ * `data.delta` to the concatenation of the merged deltas, so a client that
90
+ * appends `delta` and one that reads the cumulative `part` both reconstruct the
91
+ * identical final text.
92
+ */
93
+ declare function coalesceChatStreamEvents(events: unknown[]): unknown[];
72
94
  interface PumpBufferedTurnOptions {
73
95
  source: AsyncIterable<unknown>;
74
96
  store: TurnEventStore;
@@ -78,6 +100,14 @@ interface PumpBufferedTurnOptions {
78
100
  write?: (line: string) => Promise<void> | void;
79
101
  /** Flush buffered events to the store at most this often. Default 400ms. */
80
102
  flushIntervalMs?: number;
103
+ /** Per-flush coalescer. Default {@link coalesceDeltas} (tool-loop text/reasoning
104
+ * deltas). agent-runtime products streaming `ChatStreamEvent` pass
105
+ * {@link coalesceChatStreamEvents} so per-token deltas don't each persist as a
106
+ * row. Must be concatenation-preserving. */
107
+ coalesce?: (events: unknown[]) => unknown[];
108
+ /** Optional scope (thread/session id) recorded with the turn status, so
109
+ * {@link TurnEventStore.listRunning} can find this turn after a reload. */
110
+ scopeId?: string;
81
111
  }
82
112
  /**
83
113
  * Drive a turn to completion regardless of the live client: every source
@@ -118,9 +148,13 @@ interface D1LikeForTurns {
118
148
  };
119
149
  }
120
150
  /** Schema for the D1 store — append to the product's migrations. */
121
- declare const TURN_EVENTS_MIGRATION_SQL = "\nCREATE TABLE IF NOT EXISTS turn_events (\n turnId TEXT NOT NULL,\n seq INTEGER NOT NULL,\n event TEXT NOT NULL,\n PRIMARY KEY (turnId, seq)\n);\nCREATE TABLE IF NOT EXISTS turn_status (\n turnId TEXT PRIMARY KEY,\n status TEXT NOT NULL,\n updatedAt TEXT NOT NULL\n);\n";
151
+ declare const TURN_EVENTS_MIGRATION_SQL = "\nCREATE TABLE IF NOT EXISTS turn_events (\n turnId TEXT NOT NULL,\n seq INTEGER NOT NULL,\n event TEXT NOT NULL,\n PRIMARY KEY (turnId, seq)\n);\nCREATE TABLE IF NOT EXISTS turn_status (\n turnId TEXT PRIMARY KEY,\n status TEXT NOT NULL,\n scopeId TEXT,\n updatedAt TEXT NOT NULL\n);\nCREATE INDEX IF NOT EXISTS idx_turn_status_scope ON turn_status (scopeId, status);\n";
152
+ /** For deployments whose `turn_status` table predates `scopeId`/`listRunning` —
153
+ * run once to add the column (the CREATE above already includes it for new
154
+ * deployments). SQLite ignores a duplicate-add error if already applied. */
155
+ declare const TURN_STATUS_SCOPE_MIGRATION_SQL = "ALTER TABLE turn_status ADD COLUMN scopeId TEXT;";
122
156
  declare function createD1TurnEventStore(db: D1LikeForTurns): TurnEventStore;
123
157
  /** In-memory store for tests and keyless local dev. */
124
158
  declare function createMemoryTurnEventStore(): TurnEventStore;
125
159
 
126
- export { type BufferedTurnEvent, type D1LikeForTurns, type JsonRecord, type PersistedChatMessageForTurn, type PumpBufferedTurnOptions, type ReplayTurnEventsOptions, type ResolvedChatTurn, type StreamEvent, TURN_EVENTS_MIGRATION_SQL, type TurnEventStore, type TurnStatus, asRecord, asString, buildUserTextParts, coalesceDeltas, createD1TurnEventStore, createMemoryTurnEventStore, encodeEvent, finalizeAssistantParts, getPartKey, mergePersistedPart, messageHasTurnId, normalizeClientTurnId, normalizePersistedPart, normalizeTime, normalizeToolEvent, pumpBufferedTurn, replayTurnEvents, resolveChatTurn, resolveToolId, resolveToolName };
160
+ export { type BufferedTurnEvent, type D1LikeForTurns, type JsonRecord, type PersistedChatMessageForTurn, type PumpBufferedTurnOptions, type ReplayTurnEventsOptions, type ResolvedChatTurn, type StreamEvent, TURN_EVENTS_MIGRATION_SQL, TURN_STATUS_SCOPE_MIGRATION_SQL, type TurnEventStore, type TurnStatus, asRecord, asString, buildUserTextParts, coalesceChatStreamEvents, coalesceDeltas, createD1TurnEventStore, createMemoryTurnEventStore, encodeEvent, finalizeAssistantParts, getPartKey, mergePersistedPart, messageHasTurnId, normalizeClientTurnId, normalizePersistedPart, normalizeTime, normalizeToolEvent, pumpBufferedTurn, replayTurnEvents, resolveChatTurn, resolveToolId, resolveToolName };
@@ -1,8 +1,10 @@
1
1
  import {
2
2
  TURN_EVENTS_MIGRATION_SQL,
3
+ TURN_STATUS_SCOPE_MIGRATION_SQL,
3
4
  asRecord,
4
5
  asString,
5
6
  buildUserTextParts,
7
+ coalesceChatStreamEvents,
6
8
  coalesceDeltas,
7
9
  createD1TurnEventStore,
8
10
  createMemoryTurnEventStore,
@@ -20,12 +22,14 @@ import {
20
22
  resolveChatTurn,
21
23
  resolveToolId,
22
24
  resolveToolName
23
- } from "../chunk-CPI3RILI.js";
25
+ } from "../chunk-ULZEF45E.js";
24
26
  export {
25
27
  TURN_EVENTS_MIGRATION_SQL,
28
+ TURN_STATUS_SCOPE_MIGRATION_SQL,
26
29
  asRecord,
27
30
  asString,
28
31
  buildUserTextParts,
32
+ coalesceChatStreamEvents,
29
33
  coalesceDeltas,
30
34
  createD1TurnEventStore,
31
35
  createMemoryTurnEventStore,
@@ -1,8 +1,8 @@
1
- import { a as AppToolName, c as ToolHeaderNames } from '../auth-DcK5ERaL.js';
2
- export { A as APP_TOOL_NAMES, b as AuthenticateOptions, D as DEFAULT_HEADER_NAMES, O as OpenAIFunctionTool, T as ToolAuthResult, d as authenticateToolRequest, e as buildAppToolOpenAITools, i as isAppToolName, r as readToolArgs } from '../auth-DcK5ERaL.js';
3
- import { f as AppToolTaxonomy, c as AppToolHandlers, b as AppToolContext, e as AppToolProducedEvent, d as AppToolOutcome } from '../types-wHs0rmtu.js';
4
- export { A as AddCitationArgs, a as AddCitationResult, B as BuildAppToolsOptions, R as RenderUiArgs, g as RenderUiResult, S as ScheduleFollowupArgs, h as ScheduleFollowupResult, i as SubmitProposalArgs, j as SubmitProposalResult } from '../types-wHs0rmtu.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-4I_RHhNa.js';
1
+ import { a as ToolHeaderNames } from '../auth-DuptSkWh.js';
2
+ export { A as AuthenticateOptions, D as DEFAULT_HEADER_NAMES, T as ToolAuthResult, b as authenticateToolRequest, r as readToolArgs } from '../auth-DuptSkWh.js';
3
+ import { i as AppToolTaxonomy, e as AppToolHandlers, d as AppToolDefinition, c as AppToolContext, h as AppToolProducedEvent, g as AppToolOutcome, f as AppToolName } from '../types-BEOvc_ue.js';
4
+ export { A as APP_TOOL_NAMES, a as AddCitationArgs, b 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-BEOvc_ue.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-BHfIoGLW.js';
6
6
  export { C as CreateMcpToolHandlerOptions, M as MCP_PROTOCOL_VERSIONS, a as McpProtocolVersion, b as McpServerInfo, c as McpToolDefinition, d as createMcpToolHandler } from '../mcp-rpc-DLw_r9PQ.js';
7
7
 
8
8
  /** A correctable bad-input error a tool handler throws; the HTTP layer maps it
@@ -131,6 +131,10 @@ declare function restrictTaxonomy(taxonomy: AppToolTaxonomy, allowed: readonly s
131
131
  interface DispatchOptions {
132
132
  handlers: AppToolHandlers;
133
133
  taxonomy: AppToolTaxonomy;
134
+ /** Product-registered tools beyond the four built-ins. A called name that is
135
+ * not a built-in is dispatched to the matching {@link AppToolDefinition.execute}
136
+ * through this same validation/outcome path. */
137
+ customTools?: readonly AppToolDefinition[];
134
138
  /** Per-call approval policy. When provided it OVERRIDES the static
135
139
  * `taxonomy.regulatedTypes` membership check, so products can gate by
136
140
  * cost threshold, environment, or first-use instead of always/never.
@@ -180,8 +184,9 @@ interface RuntimeExecutorOptions extends DispatchOptions {
180
184
  declare function createAppToolRuntimeExecutor(opts: RuntimeExecutorOptions): AppToolRuntimeExecutor;
181
185
 
182
186
  interface HandleToolRequestOptions extends DispatchOptions {
183
- /** Which app tool this route serves. */
184
- tool: AppToolName;
187
+ /** Which app tool this route serves — a built-in name or a product-registered
188
+ * {@link AppToolDefinition} (auto-added to `customTools` for dispatch). */
189
+ tool: AppToolName | AppToolDefinition;
185
190
  /** Verify the bearer capability token belongs to the header user. */
186
191
  verifyToken: (userId: string, bearer: string) => Promise<boolean>;
187
192
  headerNames?: ToolHeaderNames;
@@ -197,4 +202,4 @@ interface HandleToolRequestOptions extends DispatchOptions {
197
202
  */
198
203
  declare function handleAppToolRequest(request: Request, opts: HandleToolRequestOptions): Promise<Response>;
199
204
 
200
- export { AppToolContext, AppToolHandlers, AppToolName, AppToolOutcome, AppToolProducedEvent, type AppToolRuntimeExecutor, AppToolTaxonomy, type CapabilityTokenOptions, type DispatchOptions, type ExpiringCapabilityTokenOptions, type HandleToolRequestOptions, type ResolveToolCapabilitiesOptions, type ResolvedToolCapabilities, type RuntimeExecutorOptions, type ToolCapability, ToolHeaderNames, ToolInputError, createAppToolRuntimeExecutor, createCapabilityToken, createExpiringCapabilityToken, dispatchAppTool, handleAppToolRequest, outcomeStatus, resolveToolCapabilities, restrictTaxonomy, verifyCapabilityToken, verifyExpiringCapabilityToken };
205
+ export { AppToolContext, AppToolDefinition, AppToolHandlers, AppToolName, AppToolOutcome, AppToolProducedEvent, type AppToolRuntimeExecutor, AppToolTaxonomy, type CapabilityTokenOptions, type DispatchOptions, type ExpiringCapabilityTokenOptions, type HandleToolRequestOptions, type ResolveToolCapabilitiesOptions, type ResolvedToolCapabilities, type RuntimeExecutorOptions, type ToolCapability, ToolHeaderNames, ToolInputError, createAppToolRuntimeExecutor, createCapabilityToken, createExpiringCapabilityToken, dispatchAppTool, handleAppToolRequest, outcomeStatus, resolveToolCapabilities, restrictTaxonomy, verifyCapabilityToken, verifyExpiringCapabilityToken };
@@ -6,7 +6,7 @@ import {
6
6
  restrictTaxonomy,
7
7
  verifyCapabilityToken,
8
8
  verifyExpiringCapabilityToken
9
- } from "../chunk-FDJ6JQCI.js";
9
+ } from "../chunk-3II3AWHY.js";
10
10
  import {
11
11
  DEFAULT_APP_TOOL_PATHS,
12
12
  DEFAULT_HEADER_NAMES,
@@ -17,16 +17,19 @@ import {
17
17
  buildScopedMcpServerEntry,
18
18
  createMcpToolHandler,
19
19
  readToolArgs
20
- } from "../chunk-RH74YJIK.js";
20
+ } from "../chunk-7EVZUIHW.js";
21
21
  import {
22
22
  APP_TOOL_NAMES,
23
23
  ToolInputError,
24
24
  buildAppToolOpenAITools,
25
25
  createAppToolRuntimeExecutor,
26
+ customToolToOpenAI,
27
+ defineAppTool,
26
28
  dispatchAppTool,
29
+ findCustomTool,
27
30
  isAppToolName,
28
31
  outcomeStatus
29
- } from "../chunk-PPSZNVKT.js";
32
+ } from "../chunk-MFRCM32T.js";
30
33
  export {
31
34
  APP_TOOL_NAMES,
32
35
  DEFAULT_APP_TOOL_PATHS,
@@ -42,7 +45,10 @@ export {
42
45
  createCapabilityToken,
43
46
  createExpiringCapabilityToken,
44
47
  createMcpToolHandler,
48
+ customToolToOpenAI,
49
+ defineAppTool,
45
50
  dispatchAppTool,
51
+ findCustomTool,
46
52
  handleAppToolRequest,
47
53
  isAppToolName,
48
54
  outcomeStatus,
@@ -1,3 +1,67 @@
1
+ /** The four canonical app-tool names. Stable identifiers the model calls in
2
+ * both the sandbox (MCP server name) and runtime (function-tool name) paths. */
3
+ declare const APP_TOOL_NAMES: readonly ["submit_proposal", "schedule_followup", "render_ui", "add_citation"];
4
+ type AppToolName = (typeof APP_TOOL_NAMES)[number];
5
+ declare function isAppToolName(name: string): name is AppToolName;
6
+ /** A minimal OpenAI Chat Completions function-tool shape — structurally
7
+ * compatible with `@tangle-network/agent-runtime`'s `OpenAIChatTool` without
8
+ * importing it (keeps this package runtime-free). */
9
+ interface OpenAIFunctionTool {
10
+ type: 'function';
11
+ function: {
12
+ name: string;
13
+ description: string;
14
+ parameters: Record<string, unknown>;
15
+ };
16
+ }
17
+ /**
18
+ * Build the four app tools in OpenAI function-tool shape. `submit_proposal`'s
19
+ * `type` enum is the product's {@link AppToolTaxonomy.proposalTypes}; the
20
+ * model-facing descriptions and the follow-up priority enum default to the
21
+ * Tangle reference vocabulary and can be retuned via {@link BuildAppToolsOptions}
22
+ * (the tool names + JSON-Schema shapes stay fixed — they are mechanism). Pass
23
+ * the result to the agent-runtime backend's `tools`.
24
+ */
25
+ declare function buildAppToolOpenAITools(taxonomy: AppToolTaxonomy, opts?: BuildAppToolsOptions): OpenAIFunctionTool[];
26
+
27
+ /**
28
+ * A product-defined app tool — the open registration seam.
29
+ *
30
+ * The four built-ins (`submit_proposal`/`schedule_followup`/`render_ui`/
31
+ * `add_citation`) are mechanism and stay hard-typed. This is how a product adds
32
+ * a fifth+ tool (e.g. gtm-agent's `set_config`) WITHOUT forking the shell: the
33
+ * `name` + JSON-Schema `parameters` are what the model sees, and `execute` is
34
+ * dispatched through the SAME validation/outcome path as the built-ins — a
35
+ * thrown {@link ToolInputError} becomes a correctable 4xx, any other throw an
36
+ * internal error, and a tool call never silently "succeeds" without its effect.
37
+ */
38
+ interface AppToolDefinition<Args = Record<string, unknown>> {
39
+ /** Stable identifier the model calls (and the MCP server name). Must not
40
+ * collide with a built-in app tool. */
41
+ name: string;
42
+ /** Model-facing description. */
43
+ description: string;
44
+ /** JSON-Schema for the parameters (the OpenAI `function.parameters` object). */
45
+ parameters: Record<string, unknown>;
46
+ /** Default route path the per-turn MCP server / HTTP handler is mounted at.
47
+ * Overridable per call via `paths`/`buildHttpMcpServer`. */
48
+ path?: string;
49
+ /** Fulfil the call; the return value is the tool result the model sees.
50
+ * `ctx` is the trusted per-turn identity (never from tool args). */
51
+ execute: (args: Args, ctx: AppToolContext) => Promise<unknown> | unknown;
52
+ }
53
+ /**
54
+ * Validate + brand a product tool definition. Throws when the name is empty or
55
+ * collides with a built-in (those are reserved mechanism). Identity otherwise —
56
+ * call it at module scope so a bad definition fails at boot, not first use.
57
+ */
58
+ declare function defineAppTool<Args = Record<string, unknown>>(def: AppToolDefinition<Args>): AppToolDefinition<Args>;
59
+ /** The OpenAI function-tool def for a custom tool — appended to the built-ins by
60
+ * `buildAppToolOpenAITools`. */
61
+ declare function customToolToOpenAI(def: AppToolDefinition): OpenAIFunctionTool;
62
+ /** Find a registered custom tool by the name the model called. */
63
+ declare function findCustomTool(name: string, tools: readonly AppToolDefinition[] | undefined): AppToolDefinition | undefined;
64
+
1
65
  /**
2
66
  * The structured agent→app tool side channel, domain-seamed.
3
67
  *
@@ -47,6 +111,9 @@ interface BuildAppToolsOptions {
47
111
  descriptions?: Partial<Record<'submit_proposal' | 'schedule_followup' | 'render_ui' | 'add_citation', string>>;
48
112
  /** The `schedule_followup.priority` enum (defaults to `['low','medium','high']`). */
49
113
  priorityValues?: readonly string[];
114
+ /** Product-registered tools to advertise to the model alongside the four
115
+ * built-ins (appended in order, after the built-ins). */
116
+ customTools?: readonly AppToolDefinition[];
50
117
  }
51
118
  interface SubmitProposalArgs {
52
119
  type: string;
@@ -142,4 +209,4 @@ type AppToolOutcome = {
142
209
  status?: number;
143
210
  };
144
211
 
145
- export type { AddCitationArgs as A, BuildAppToolsOptions as B, RenderUiArgs as R, ScheduleFollowupArgs as S, AddCitationResult as a, AppToolContext as b, AppToolHandlers as c, AppToolOutcome as d, AppToolProducedEvent as e, AppToolTaxonomy as f, RenderUiResult as g, ScheduleFollowupResult as h, SubmitProposalArgs as i, SubmitProposalResult as j };
212
+ export { APP_TOOL_NAMES as A, type BuildAppToolsOptions as B, type OpenAIFunctionTool as O, type RenderUiArgs as R, type ScheduleFollowupArgs as S, type AddCitationArgs as a, type AddCitationResult as b, type AppToolContext as c, type AppToolDefinition as d, type AppToolHandlers as e, type AppToolName as f, type AppToolOutcome as g, type AppToolProducedEvent as h, type AppToolTaxonomy as i, type RenderUiResult as j, type ScheduleFollowupResult as k, type SubmitProposalArgs as l, type SubmitProposalResult as m, buildAppToolOpenAITools as n, customToolToOpenAI as o, defineAppTool as p, findCustomTool as q, isAppToolName as r };