@tangle-network/agent-app 0.43.24 → 0.43.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/app-auth/index.d.ts +163 -0
  2. package/dist/app-auth/index.js +166 -0
  3. package/dist/app-auth/index.js.map +1 -0
  4. package/dist/assets/index.d.ts +2 -2
  5. package/dist/assistant/index.d.ts +2 -0
  6. package/dist/assistant/index.js +3 -1
  7. package/dist/assistant/index.js.map +1 -1
  8. package/dist/chat-routes/index.d.ts +276 -0
  9. package/dist/chat-routes/index.js +564 -0
  10. package/dist/chat-routes/index.js.map +1 -0
  11. package/dist/chat-store/index.d.ts +194 -0
  12. package/dist/chat-store/index.js +198 -0
  13. package/dist/chat-store/index.js.map +1 -0
  14. package/dist/chunk-4TXDD6P2.js +163 -0
  15. package/dist/chunk-4TXDD6P2.js.map +1 -0
  16. package/dist/chunk-5EQCITY3.js +20 -0
  17. package/dist/chunk-5EQCITY3.js.map +1 -0
  18. package/dist/chunk-5SV5PSU7.js +80 -0
  19. package/dist/chunk-5SV5PSU7.js.map +1 -0
  20. package/dist/chunk-7LNGJDNA.js +1 -0
  21. package/dist/chunk-7LNGJDNA.js.map +1 -0
  22. package/dist/{chunk-77RLNLFP.js → chunk-ATRJULKZ.js} +41 -5
  23. package/dist/chunk-ATRJULKZ.js.map +1 -0
  24. package/dist/{chunk-VMY4TKMN.js → chunk-FCQP75JT.js} +936 -436
  25. package/dist/chunk-FCQP75JT.js.map +1 -0
  26. package/dist/chunk-I2R2XT4M.js +62 -0
  27. package/dist/chunk-I2R2XT4M.js.map +1 -0
  28. package/dist/{chunk-3PK3T4KD.js → chunk-JJGZ54EB.js} +44 -1
  29. package/dist/chunk-JJGZ54EB.js.map +1 -0
  30. package/dist/chunk-TKVJE63N.js +304 -0
  31. package/dist/chunk-TKVJE63N.js.map +1 -0
  32. package/dist/{chunk-SAOAAA3S.js → chunk-UHXQ3KNX.js} +1 -22
  33. package/dist/chunk-UHXQ3KNX.js.map +1 -0
  34. package/dist/chunk-Y4QHNQ75.js +203 -0
  35. package/dist/chunk-Y4QHNQ75.js.map +1 -0
  36. package/dist/contract-DYbTzEDf.d.ts +122 -0
  37. package/dist/core-7qIM7svy.d.ts +21 -0
  38. package/dist/index.d.ts +6 -2
  39. package/dist/index.js +179 -92
  40. package/dist/interactions/index.d.ts +141 -0
  41. package/dist/interactions/index.js +60 -0
  42. package/dist/interactions/index.js.map +1 -0
  43. package/dist/parts-BcbitSNp.d.ts +176 -0
  44. package/dist/platform/index.d.ts +2 -270
  45. package/dist/platform/index.js +14 -278
  46. package/dist/platform/index.js.map +1 -1
  47. package/dist/preset-cloudflare/index.d.ts +0 -10
  48. package/dist/preset-cloudflare/index.js +1 -1
  49. package/dist/profile/index.d.ts +33 -2
  50. package/dist/profile/index.js +37 -1
  51. package/dist/profile/index.js.map +1 -1
  52. package/dist/sandbox/index.d.ts +47 -1
  53. package/dist/sandbox/index.js +11 -1
  54. package/dist/sso-CNOsARMJ.d.ts +285 -0
  55. package/dist/stream/index.js +1 -1
  56. package/dist/teams/index.js +9 -9
  57. package/dist/teams/invitations-api.js +3 -3
  58. package/dist/web-react/index.d.ts +229 -99
  59. package/dist/web-react/index.js +72 -22
  60. package/dist/wire-BaUF66AS.d.ts +61 -0
  61. package/package.json +25 -1
  62. package/dist/chunk-3PK3T4KD.js.map +0 -1
  63. package/dist/chunk-77RLNLFP.js.map +0 -1
  64. package/dist/chunk-SAOAAA3S.js.map +0 -1
  65. package/dist/chunk-VMY4TKMN.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,10 +1,66 @@
1
1
  import "./chunk-UAKFCMWK.js";
2
+ import {
3
+ CANVAS_ELEMENT_KINDS,
4
+ CANVAS_MCP_TOOLS,
5
+ CANVAS_MCP_TOOL_NAMES,
6
+ DEFAULT_DESIGN_CANVAS_MCP_DESCRIPTION,
7
+ SCENE_OPERATION_TYPES,
8
+ applyBindingsToDocument,
9
+ buildDesignCanvasMcpServerEntry,
10
+ createDesignCanvasMcpHandler,
11
+ findCanvasMcpTool,
12
+ instantiateTemplate,
13
+ listTemplateSlots,
14
+ validateBindings
15
+ } from "./chunk-WFMUDX5J.js";
2
16
  import {
3
17
  darkTheme,
4
18
  lightTheme,
5
19
  themeColor,
6
20
  themeToCssVars
7
21
  } from "./chunk-47C6PJCW.js";
22
+ import {
23
+ CHANNEL_PRESETS,
24
+ EXPORT_PRESETS,
25
+ SCENE_ELEMENT_KINDS,
26
+ SCENE_SCHEMA_VERSION,
27
+ SIZE_PRESETS,
28
+ applySceneOperation,
29
+ applySceneOperations,
30
+ assertColor,
31
+ assertFinite,
32
+ assertPositiveFinite,
33
+ assertSceneMediaSrc,
34
+ bleedAwareExportBounds,
35
+ bleedAwareExportRect,
36
+ boundsIntersect,
37
+ collectSlots,
38
+ createEmptyDocument,
39
+ createPage,
40
+ elementAabb,
41
+ elementExtent,
42
+ estimateTextHeight,
43
+ findElement,
44
+ findPreset,
45
+ matchPreset,
46
+ requireChannelPreset,
47
+ requireElement,
48
+ requirePage,
49
+ scaleForPreset,
50
+ scalePageForChannelPreset,
51
+ storeApplyScenePlan,
52
+ validateSceneOperation,
53
+ validateSceneOperations,
54
+ validateSlotValue
55
+ } from "./chunk-M2EBUDZ7.js";
56
+ import {
57
+ DEFAULT_REDACTION_PATTERNS,
58
+ buildRedactedDocument,
59
+ detectSpans,
60
+ maskSpans,
61
+ redactForIngestion,
62
+ revealSpan
63
+ } from "./chunk-5RMIUJDI.js";
8
64
  import {
9
65
  buildFlowTrace,
10
66
  childSpanContext,
@@ -82,68 +138,36 @@ import {
82
138
  snapshotFrame,
83
139
  trackIntervals
84
140
  } from "./chunk-ZYBWGSAZ.js";
141
+ import "./chunk-7LNGJDNA.js";
85
142
  import {
86
- CANVAS_ELEMENT_KINDS,
87
- CANVAS_MCP_TOOLS,
88
- CANVAS_MCP_TOOL_NAMES,
89
- DEFAULT_DESIGN_CANVAS_MCP_DESCRIPTION,
90
- SCENE_OPERATION_TYPES,
91
- applyBindingsToDocument,
92
- buildDesignCanvasMcpServerEntry,
93
- createDesignCanvasMcpHandler,
94
- findCanvasMcpTool,
95
- instantiateTemplate,
96
- listTemplateSlots,
97
- validateBindings
98
- } from "./chunk-WFMUDX5J.js";
99
- import {
100
- CHANNEL_PRESETS,
101
- EXPORT_PRESETS,
102
- SCENE_ELEMENT_KINDS,
103
- SCENE_SCHEMA_VERSION,
104
- SIZE_PRESETS,
105
- applySceneOperation,
106
- applySceneOperations,
107
- assertColor,
108
- assertFinite,
109
- assertPositiveFinite,
110
- assertSceneMediaSrc,
111
- bleedAwareExportBounds,
112
- bleedAwareExportRect,
113
- boundsIntersect,
114
- collectSlots,
115
- createEmptyDocument,
116
- createPage,
117
- elementAabb,
118
- elementExtent,
119
- estimateTextHeight,
120
- findElement,
121
- findPreset,
122
- matchPreset,
123
- requireChannelPreset,
124
- requireElement,
125
- requirePage,
126
- scaleForPreset,
127
- scalePageForChannelPreset,
128
- storeApplyScenePlan,
129
- validateSceneOperation,
130
- validateSceneOperations,
131
- validateSlotValue
132
- } from "./chunk-M2EBUDZ7.js";
143
+ DEFAULT_MISSION_STEP_KINDS,
144
+ MISSION_CONTROL_CHANNEL_ID,
145
+ MissionConcurrencyError,
146
+ RetryableStepError,
147
+ applyMissionEvent,
148
+ asMissionStreamEvent,
149
+ budgetGateProposalId,
150
+ buildAgentMissionPlan,
151
+ createInMemoryMissionStore,
152
+ createMissionEngine,
153
+ createMissionService,
154
+ isMissionStopRequested,
155
+ isMissionTerminal,
156
+ mergeMissionState,
157
+ noopEventSink,
158
+ parseMissionBlocks,
159
+ parseSessionStreamEnvelope,
160
+ reduceMissionEvents,
161
+ stepAgentActivity,
162
+ stepGateProposalId,
163
+ volumeGateProposalId
164
+ } from "./chunk-YNALYIQ3.js";
133
165
  import {
134
166
  composeMissionFlowTrace,
135
167
  delegationActivityToFlowSpans,
136
168
  loopTraceEventsToFlowSpans,
137
169
  stepActivityFlowTrace
138
170
  } from "./chunk-2QI7XV2T.js";
139
- import {
140
- DEFAULT_REDACTION_PATTERNS,
141
- buildRedactedDocument,
142
- detectSpans,
143
- maskSpans,
144
- redactForIngestion,
145
- revealSpan
146
- } from "./chunk-5RMIUJDI.js";
147
171
  import {
148
172
  agentAppConfigJsonSchema,
149
173
  defineAgentApp
@@ -157,12 +181,65 @@ import {
157
181
  createPresetToolHandlers,
158
182
  createPresetWorkspaceKeyManager,
159
183
  createPresetWorkspaceKeyStore
160
- } from "./chunk-SAOAAA3S.js";
184
+ } from "./chunk-UHXQ3KNX.js";
161
185
  import {
162
186
  createPlatformBalanceManager,
163
187
  createTcloudKeyProvisioner,
164
188
  createWorkspaceKeyManager
165
189
  } from "./chunk-G3HCU7TA.js";
190
+ import {
191
+ BULK_DELETE_MAX_THREADS,
192
+ ChatStoreInputError,
193
+ threadTitleFromMessage
194
+ } from "./chunk-5EQCITY3.js";
195
+ import {
196
+ createInteractionAnswerRoute,
197
+ listSessionInteractions,
198
+ mapInteractionRespondFailure,
199
+ respondToSessionInteraction,
200
+ validateInteractionAnswerBody
201
+ } from "./chunk-Y4QHNQ75.js";
202
+ import {
203
+ addSecurityHeaders,
204
+ assertMediaUrl,
205
+ checkRateLimit,
206
+ clearCookieHeader,
207
+ extractRequestContext,
208
+ parseJsonObjectBody,
209
+ readCookieValue,
210
+ requireString,
211
+ serializeCookie
212
+ } from "./chunk-HFC4BTWJ.js";
213
+ import {
214
+ INTERACTION_CANCEL_EVENT,
215
+ INTERACTION_EVENT,
216
+ INTERACTION_RESOLVED_EVENT,
217
+ canTransitionInteractionStatus,
218
+ cancelStatusFor,
219
+ composerAnswerData,
220
+ composerAnswerDeliveries,
221
+ dedupeQuestionInteractionsByContent,
222
+ fieldAcceptsFreeText,
223
+ interactionFromWireRequest,
224
+ interactionPartKey,
225
+ interactionToPersistedPart,
226
+ isRenderableInteractionKind,
227
+ isSafeInteractionFieldKey,
228
+ isTerminalInteractionStatus,
229
+ noticePart,
230
+ noticePartKey,
231
+ parseInteractionCancel,
232
+ parseInteractionRequest,
233
+ persistedPartToInteraction,
234
+ questionInteractionContentSignature
235
+ } from "./chunk-4TXDD6P2.js";
236
+ import {
237
+ isChatInteractionPart,
238
+ isChatStepFinishPart,
239
+ isChatTextPart,
240
+ isChatToolPart,
241
+ toChatMessageParts
242
+ } from "./chunk-I2R2XT4M.js";
166
243
  import {
167
244
  createFieldCrypto,
168
245
  decodeHexKey,
@@ -199,46 +276,12 @@ import {
199
276
  resolveChatTurn,
200
277
  resolveToolId,
201
278
  resolveToolName
202
- } from "./chunk-77RLNLFP.js";
279
+ } from "./chunk-ATRJULKZ.js";
203
280
  import {
204
281
  HubExecClient,
205
282
  invokeIntegrationHub,
206
283
  resolveIntegrationAction
207
284
  } from "./chunk-L2TG5DBW.js";
208
- import {
209
- DEFAULT_MISSION_STEP_KINDS,
210
- MISSION_CONTROL_CHANNEL_ID,
211
- MissionConcurrencyError,
212
- RetryableStepError,
213
- applyMissionEvent,
214
- asMissionStreamEvent,
215
- budgetGateProposalId,
216
- buildAgentMissionPlan,
217
- createInMemoryMissionStore,
218
- createMissionEngine,
219
- createMissionService,
220
- isMissionStopRequested,
221
- isMissionTerminal,
222
- mergeMissionState,
223
- noopEventSink,
224
- parseMissionBlocks,
225
- parseSessionStreamEnvelope,
226
- reduceMissionEvents,
227
- stepAgentActivity,
228
- stepGateProposalId,
229
- volumeGateProposalId
230
- } from "./chunk-YNALYIQ3.js";
231
- import {
232
- addSecurityHeaders,
233
- assertMediaUrl,
234
- checkRateLimit,
235
- clearCookieHeader,
236
- extractRequestContext,
237
- parseJsonObjectBody,
238
- readCookieValue,
239
- requireString,
240
- serializeCookie
241
- } from "./chunk-HFC4BTWJ.js";
242
285
  import {
243
286
  createKnowledgeLoop,
244
287
  createReviewerDecider,
@@ -246,7 +289,12 @@ import {
246
289
  } from "./chunk-EEPJGZJW.js";
247
290
  import {
248
291
  DEFAULT_SANDBOX_RESOURCES,
292
+ ENV_TOTAL_MAX_BYTES,
293
+ ENV_VALUE_MAX_BYTES,
294
+ PROVISION_PAYLOAD_MAX_BYTES,
249
295
  SandboxRuntimeAuthRefreshError,
296
+ assertEnvWithinLimits,
297
+ assertProvisionPayloadWithinCap,
250
298
  attachReasoningEffort,
251
299
  bearerSubprotocolToken,
252
300
  bearerToken,
@@ -294,7 +342,7 @@ import {
294
342
  verifySandboxTerminalToken,
295
343
  verifyTerminalProxyToken,
296
344
  writeProfileFilesToBox
297
- } from "./chunk-3PK3T4KD.js";
345
+ } from "./chunk-JJGZ54EB.js";
298
346
  import {
299
347
  DEFAULT_HARNESS,
300
348
  KNOWN_HARNESSES,
@@ -390,11 +438,13 @@ import {
390
438
  export {
391
439
  APP_TOOL_NAMES,
392
440
  ApprovalEventSchema,
441
+ BULK_DELETE_MAX_THREADS,
393
442
  BrandTokensSchema,
394
443
  CANVAS_ELEMENT_KINDS,
395
444
  CANVAS_MCP_TOOLS,
396
445
  CANVAS_MCP_TOOL_NAMES,
397
446
  CHANNEL_PRESETS,
447
+ ChatStoreInputError,
398
448
  ConversionMetricsSchema,
399
449
  CopyContentSchema,
400
450
  DEFAULT_APP_TOOL_PATHS,
@@ -407,9 +457,14 @@ export {
407
457
  DEFAULT_SEQUENCES_MCP_DESCRIPTION,
408
458
  DEFAULT_TANGLE_BILLING_ENFORCEMENT_ENV_VAR,
409
459
  DEFAULT_TANGLE_ROUTER_BASE_URL,
460
+ ENV_TOTAL_MAX_BYTES,
461
+ ENV_VALUE_MAX_BYTES,
410
462
  EXPORT_PRESETS,
411
463
  EmailContentSchema,
412
464
  HubExecClient,
465
+ INTERACTION_CANCEL_EVENT,
466
+ INTERACTION_EVENT,
467
+ INTERACTION_RESOLVED_EVENT,
413
468
  ImageContentSchema,
414
469
  KNOWN_HARNESSES,
415
470
  MAX_CAPTION_BATCH,
@@ -419,6 +474,7 @@ export {
419
474
  MissionConcurrencyError,
420
475
  PRESET_MIGRATION_SQL,
421
476
  PRESET_TABLES,
477
+ PROVISION_PAYLOAD_MAX_BYTES,
422
478
  RetryableStepError,
423
479
  SCENE_ELEMENT_KINDS,
424
480
  SCENE_OPERATION_TYPES,
@@ -450,10 +506,12 @@ export {
450
506
  asString,
451
507
  assertClipFitsSequence,
452
508
  assertColor,
509
+ assertEnvWithinLimits,
453
510
  assertFinite,
454
511
  assertHarnessModelCompatible,
455
512
  assertMediaUrl,
456
513
  assertPositiveFinite,
514
+ assertProvisionPayloadWithinCap,
457
515
  assertSceneMediaSrc,
458
516
  assertSequenceMediaUrl,
459
517
  attachReasoningEffort,
@@ -487,6 +545,8 @@ export {
487
545
  buildSrt,
488
546
  buildUserTextParts,
489
547
  buildVtt,
548
+ canTransitionInteractionStatus,
549
+ cancelStatusFor,
490
550
  captionCoverage,
491
551
  captionTrackNameForLanguage,
492
552
  checkRateLimit,
@@ -501,6 +561,8 @@ export {
501
561
  coerceHarness,
502
562
  collectSlots,
503
563
  composeMissionFlowTrace,
564
+ composerAnswerData,
565
+ composerAnswerDeliveries,
504
566
  createAgentRuntime,
505
567
  createAppToolRuntimeExecutor,
506
568
  createBrokerTokenProvider,
@@ -514,6 +576,7 @@ export {
514
576
  createExpiringCapabilityToken,
515
577
  createFieldCrypto,
516
578
  createInMemoryMissionStore,
579
+ createInteractionAnswerRoute,
517
580
  createKnowledgeLoop,
518
581
  createLlmCorrectnessChecker,
519
582
  createMcpToolHandler,
@@ -547,6 +610,7 @@ export {
547
610
  decryptAesGcm,
548
611
  decryptBytes,
549
612
  decryptWithKey,
613
+ dedupeQuestionInteractionsByContent,
550
614
  defineAgentApp,
551
615
  defineAppTool,
552
616
  defineSurfaceKind,
@@ -570,6 +634,7 @@ export {
570
634
  extractProducedState,
571
635
  extractRequestContext,
572
636
  fetchModelCatalog,
637
+ fieldAcceptsFreeText,
573
638
  finalizeAssistantParts,
574
639
  findCanvasMcpTool,
575
640
  findCustomTool,
@@ -584,20 +649,32 @@ export {
584
649
  getPartKey,
585
650
  handleAppToolRequest,
586
651
  instantiateTemplate,
652
+ interactionFromWireRequest,
653
+ interactionPartKey,
654
+ interactionToPersistedPart,
587
655
  invokeIntegrationHub,
588
656
  isAppToolName,
657
+ isChatInteractionPart,
658
+ isChatStepFinishPart,
659
+ isChatTextPart,
660
+ isChatToolPart,
589
661
  isHarness,
590
662
  isMissionStopRequested,
591
663
  isMissionTerminal,
592
664
  isModelCompatibleWithHarness,
665
+ isRenderableInteractionKind,
666
+ isSafeInteractionFieldKey,
593
667
  isSandboxTerminalWsUpgrade,
594
668
  isTangleBillingEnforcementDisabled,
595
669
  isTangleExecutionKeyError,
670
+ isTerminalInteractionStatus,
596
671
  isTerminalPromptEvent,
597
672
  lastClipEndFrame,
598
673
  lightTheme,
674
+ listSessionInteractions,
599
675
  listTemplateSlots,
600
676
  loopTraceEventsToFlowSpans,
677
+ mapInteractionRespondFailure,
601
678
  maskSpans,
602
679
  matchPreset,
603
680
  matchSandboxTerminalWsPath,
@@ -617,15 +694,21 @@ export {
617
694
  normalizePersistedPart,
618
695
  normalizeTime,
619
696
  normalizeToolEvent,
697
+ noticePart,
698
+ noticePartKey,
620
699
  outcomeStatus,
621
700
  parseAssetSpec,
701
+ parseInteractionCancel,
702
+ parseInteractionRequest,
622
703
  parseJsonObjectBody,
623
704
  parseMissionBlocks,
624
705
  parseSequenceOperations,
625
706
  parseSessionStreamEnvelope,
707
+ persistedPartToInteraction,
626
708
  planLanguageFanout,
627
709
  producedFromToolEvents,
628
710
  pumpBufferedTurn,
711
+ questionInteractionContentSignature,
629
712
  readCookieValue,
630
713
  readSecret,
631
714
  readToolArgs,
@@ -655,6 +738,7 @@ export {
655
738
  resolveToolName,
656
739
  resolveUserTangleExecutionKey,
657
740
  resolveUserTangleExecutionKeyForUser,
741
+ respondToSessionInteraction,
658
742
  restrictTaxonomy,
659
743
  revealSpan,
660
744
  reviewCandidate,
@@ -689,7 +773,9 @@ export {
689
773
  terminalTokenFromRequest,
690
774
  themeColor,
691
775
  themeToCssVars,
776
+ threadTitleFromMessage,
692
777
  timedEventsFromLines,
778
+ toChatMessageParts,
693
779
  toLoopEvents,
694
780
  traceEnv,
695
781
  trackIntervals,
@@ -699,6 +785,7 @@ export {
699
785
  validateCreateTrack,
700
786
  validateDeleteClip,
701
787
  validateExtendSequence,
788
+ validateInteractionAnswerBody,
702
789
  validateMoveClip,
703
790
  validatePlaceClip,
704
791
  validateQueueExport,
@@ -0,0 +1,141 @@
1
+ import { i as InteractionRequestWire } from '../contract-DYbTzEDf.js';
2
+ export { C as ChatInteraction, a as ChatInteractionField, b as ChatInteractionStatus, c as ChatSelectField, d as ComposerAnswerDelivery, I as INTERACTION_CANCEL_EVENT, e as INTERACTION_EVENT, f as INTERACTION_RESOLVED_EVENT, g as InteractionCancelData, h as InteractionPersistedPart, N as NoticeKind, j as NoticePersistedPart, P as ParseInteractionResult, k as canTransitionInteractionStatus, l as cancelStatusFor, m as composerAnswerData, n as composerAnswerDeliveries, o as dedupeQuestionInteractionsByContent, p as fieldAcceptsFreeText, q as interactionFromWireRequest, r as interactionPartKey, s as interactionToPersistedPart, t as isRenderableInteractionKind, u as isSafeInteractionFieldKey, v as isTerminalInteractionStatus, w as noticePart, x as noticePartKey, y as parseInteractionCancel, z as parseInteractionRequest, A as persistedPartToInteraction, B as questionInteractionContentSignature } from '../contract-DYbTzEDf.js';
3
+ import { InteractionOutcome, InteractionData } from '@tangle-network/agent-interface';
4
+ export { InteractionData, InteractionOutcome, InteractionRequest } from '@tangle-network/agent-interface';
5
+
6
+ /**
7
+ * Server-side client for the sandbox sidecar's generic interaction routes
8
+ * (`GET/POST {runtimeUrl}/agents/sessions/{sessionId}/interactions`). The
9
+ * pinned sandbox SDK exposes only the question-specific `session().answer()`
10
+ * convenience; these raw calls are backend-agnostic (question/permission/plan,
11
+ * any harness) and carry explicit outcomes (accepted/declined).
12
+ *
13
+ * Server-only: the sidecar bearer must never reach browser code. The caller
14
+ * supplies the connection as a structural value (runtime URL + bearer +
15
+ * session id) — no sandbox-SDK import, so any box-resolution strategy works.
16
+ */
17
+
18
+ interface SidecarInteractionsError {
19
+ code: string;
20
+ message: string;
21
+ /** Upstream HTTP status; 0 when the sidecar was unreachable. */
22
+ status: number;
23
+ }
24
+ type SidecarInteractionsResult<T> = {
25
+ succeeded: true;
26
+ value: T;
27
+ } | {
28
+ succeeded: false;
29
+ error: SidecarInteractionsError;
30
+ };
31
+ /** Where and how to reach one session's interaction registry. */
32
+ interface SidecarInteractionsConnection {
33
+ runtimeUrl: string;
34
+ authToken?: string;
35
+ /** The sidecar agent-session id (the chat thread's session). */
36
+ sessionId: string;
37
+ /** Request deadline. A pending interaction means the box is up and the
38
+ * sidecar responsive; a short default keeps a wedged runtime from stalling
39
+ * the answering request. */
40
+ timeoutMs?: number;
41
+ /** Injection seam for tests; defaults to global fetch. */
42
+ fetchImpl?: typeof fetch;
43
+ }
44
+ /** Outstanding (unanswered) interactions for the session — the sidecar's
45
+ * registry is authoritative, so this is the reconnect/reload source of truth. */
46
+ declare function listSessionInteractions(connection: SidecarInteractionsConnection): Promise<SidecarInteractionsResult<InteractionRequestWire[]>>;
47
+ /** Resolves one interaction. `data` is required by the sidecar only for
48
+ * `accepted` outcomes and is validated fail-closed against the answerSpec
49
+ * (400 INVALID_INTERACTION_ANSWER on mismatch). */
50
+ declare function respondToSessionInteraction(connection: SidecarInteractionsConnection, response: {
51
+ id: string;
52
+ outcome: InteractionOutcome;
53
+ data?: InteractionData;
54
+ }): Promise<SidecarInteractionsResult<void>>;
55
+
56
+ /**
57
+ * Framework-neutral interaction-answer endpoints, lifted out of the per-app
58
+ * route files (gtm `api.chat.interactions`, legal `api.chat.interactions`,
59
+ * tax `api.sessions.$id.interactions` — three byte-similar forks):
60
+ *
61
+ * list(request) — GET: outstanding asks for a live turn (reload restore)
62
+ * answer(request) — POST `{ id, outcome, data? }`: resolve one ask
63
+ *
64
+ * The product supplies ONE seam, `resolveConnection`: authenticate the caller,
65
+ * authorize the thread/session, and resolve the sidecar connection. Everything
66
+ * behind the seam is mechanism the forks kept re-fixing:
67
+ *
68
+ * - body validation (safe field keys, typed values),
69
+ * - sidecar error → client contract mapping (every "the ask is gone" shape
70
+ * becomes 410 so the card flips to its expired state),
71
+ * - duplicate resolution: after answering, every other outstanding ask with
72
+ * the same content signature (a re-emitted duplicate) gets the same answer,
73
+ * - unblock verification: re-list and fail loud (503 INTERACTION_STILL_PENDING)
74
+ * when the sidecar accepted the POST but the ask is still open,
75
+ * - best-effort list: sidecar failures return `{ interactions: [],
76
+ * unavailable }` so a reload restore never breaks the live stream.
77
+ *
78
+ * Handlers return web-standard `Response`s (Workers, Node 18+, Deno) — no
79
+ * router import anywhere.
80
+ */
81
+
82
+ type InteractionClientOutcome = 'accepted' | 'declined';
83
+ type InteractionAnswerBodyValidation = {
84
+ ok: true;
85
+ id: string;
86
+ outcome: InteractionClientOutcome;
87
+ data?: InteractionData;
88
+ } | {
89
+ ok: false;
90
+ error: string;
91
+ };
92
+ /** Validates the client POST body: `{ id, outcome, data? }` with
93
+ * identifier-safe field keys and primitive/string-array values only. */
94
+ declare function validateInteractionAnswerBody(body: Record<string, unknown>): InteractionAnswerBodyValidation;
95
+ type InteractionRouteLogger = Pick<Console, 'warn' | 'error'>;
96
+ /** Sidecar error → the client-actionable contract. Every "the ask is gone"
97
+ * shape maps to 410 so the card flips to its expired state — a raw 404/409
98
+ * must never surface. */
99
+ declare function mapInteractionRespondFailure(error: SidecarInteractionsError, logger?: InteractionRouteLogger): Response;
100
+ /** The product seam's verdict for one request. `response` short-circuits with
101
+ * a product-authored Response (401/404/429…); `unavailable` means the caller
102
+ * is fine but the sandbox runtime is not reachable — the factory shapes that
103
+ * per intent (empty list for `list`, 503 for `answer`). */
104
+ type InteractionConnectionResolution = {
105
+ ok: true;
106
+ connection: SidecarInteractionsConnection;
107
+ } | {
108
+ ok: false;
109
+ response: Response;
110
+ } | {
111
+ ok: false;
112
+ unavailable: string;
113
+ };
114
+ interface ResolveInteractionConnectionArgs {
115
+ request: Request;
116
+ intent: 'list' | 'answer';
117
+ /** The parsed, validated POST body (answer intent only) so the resolver can
118
+ * read product routing fields (workspaceId/threadId) without re-parsing. */
119
+ body?: Record<string, unknown>;
120
+ }
121
+ interface InteractionAnswerRouteOptions {
122
+ /** Authenticate + authorize the caller and resolve the sidecar connection.
123
+ * This is the only product-supplied step: session auth, workspace/thread
124
+ * access, rate limiting, and box resolution all live here. */
125
+ resolveConnection: (args: ResolveInteractionConnectionArgs) => Promise<InteractionConnectionResolution>;
126
+ logger?: InteractionRouteLogger;
127
+ }
128
+ interface InteractionAnswerRoute {
129
+ /** GET — outstanding interactions for a live turn. Failures return an empty
130
+ * list with an explicit `unavailable` code: the caller is a best-effort
131
+ * reload restore, and the live/replayed stream must stay untouched when the
132
+ * sidecar cannot answer. */
133
+ list: (request: Request) => Promise<Response>;
134
+ /** POST `{ id, outcome, data?, ...productFields }` — resolve one ask, answer
135
+ * content-identical duplicates the same way, then re-list to prove the run
136
+ * actually unblocked. */
137
+ answer: (request: Request) => Promise<Response>;
138
+ }
139
+ declare function createInteractionAnswerRoute(options: InteractionAnswerRouteOptions): InteractionAnswerRoute;
140
+
141
+ export { type InteractionAnswerBodyValidation, type InteractionAnswerRoute, type InteractionAnswerRouteOptions, type InteractionClientOutcome, type InteractionConnectionResolution, InteractionRequestWire, type InteractionRouteLogger, type ResolveInteractionConnectionArgs, type SidecarInteractionsConnection, type SidecarInteractionsError, type SidecarInteractionsResult, createInteractionAnswerRoute, listSessionInteractions, mapInteractionRespondFailure, respondToSessionInteraction, validateInteractionAnswerBody };
@@ -0,0 +1,60 @@
1
+ import "../chunk-7LNGJDNA.js";
2
+ import {
3
+ createInteractionAnswerRoute,
4
+ listSessionInteractions,
5
+ mapInteractionRespondFailure,
6
+ respondToSessionInteraction,
7
+ validateInteractionAnswerBody
8
+ } from "../chunk-Y4QHNQ75.js";
9
+ import {
10
+ INTERACTION_CANCEL_EVENT,
11
+ INTERACTION_EVENT,
12
+ INTERACTION_RESOLVED_EVENT,
13
+ canTransitionInteractionStatus,
14
+ cancelStatusFor,
15
+ composerAnswerData,
16
+ composerAnswerDeliveries,
17
+ dedupeQuestionInteractionsByContent,
18
+ fieldAcceptsFreeText,
19
+ interactionFromWireRequest,
20
+ interactionPartKey,
21
+ interactionToPersistedPart,
22
+ isRenderableInteractionKind,
23
+ isSafeInteractionFieldKey,
24
+ isTerminalInteractionStatus,
25
+ noticePart,
26
+ noticePartKey,
27
+ parseInteractionCancel,
28
+ parseInteractionRequest,
29
+ persistedPartToInteraction,
30
+ questionInteractionContentSignature
31
+ } from "../chunk-4TXDD6P2.js";
32
+ export {
33
+ INTERACTION_CANCEL_EVENT,
34
+ INTERACTION_EVENT,
35
+ INTERACTION_RESOLVED_EVENT,
36
+ canTransitionInteractionStatus,
37
+ cancelStatusFor,
38
+ composerAnswerData,
39
+ composerAnswerDeliveries,
40
+ createInteractionAnswerRoute,
41
+ dedupeQuestionInteractionsByContent,
42
+ fieldAcceptsFreeText,
43
+ interactionFromWireRequest,
44
+ interactionPartKey,
45
+ interactionToPersistedPart,
46
+ isRenderableInteractionKind,
47
+ isSafeInteractionFieldKey,
48
+ isTerminalInteractionStatus,
49
+ listSessionInteractions,
50
+ mapInteractionRespondFailure,
51
+ noticePart,
52
+ noticePartKey,
53
+ parseInteractionCancel,
54
+ parseInteractionRequest,
55
+ persistedPartToInteraction,
56
+ questionInteractionContentSignature,
57
+ respondToSessionInteraction,
58
+ validateInteractionAnswerBody
59
+ };
60
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}