@tangle-network/agent-app 0.46.49 → 0.46.51

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.
@@ -155,6 +155,36 @@ async function readSandboxBinaryBytes(box, absolutePath, expectedSize, options)
155
155
  return { succeeded: true, value: { bytes, size: expectedSize } };
156
156
  }
157
157
 
158
+ // src/sandbox/session-turn.ts
159
+ function stableId(value, field) {
160
+ const normalized = value.trim();
161
+ if (!normalized) throw new Error(`Sandbox session turn requires a non-empty ${field}`);
162
+ return normalized;
163
+ }
164
+ async function admitSandboxSessionTurn(options) {
165
+ const sessionId = stableId(options.sessionId, "sessionId");
166
+ const turnId = stableId(options.turnId, "turnId");
167
+ if (options.message.parts.length === 0) {
168
+ throw new Error("Sandbox session turn requires at least one message part");
169
+ }
170
+ const created = await options.box.createSession({
171
+ sessionId,
172
+ backend: options.backend,
173
+ ...options.title !== void 0 ? { title: options.title } : {}
174
+ });
175
+ if (!isExpectedSession(created, sessionId)) {
176
+ throw new Error(`Sandbox returned a different session for ${sessionId}`);
177
+ }
178
+ const receipt = await created.session.sendMessage(
179
+ { ...options.message, turnId },
180
+ options.sendOptions
181
+ );
182
+ return { sessionId, turnId, receipt };
183
+ }
184
+ function isExpectedSession(created, sessionId) {
185
+ return created.info.id === sessionId && created.session.id === sessionId;
186
+ }
187
+
158
188
  // src/sandbox/recovery.ts
159
189
  var EGRESS_PROXY_RECOVERY_REQUIRED = "EGRESS_PROXY_RECOVERY_REQUIRED";
160
190
  var EGRESS_PROXY_RECOVERY_PHASE = "egress_proxy_recovery";
@@ -2735,6 +2765,7 @@ export {
2735
2765
  shellQuote,
2736
2766
  statSandboxFileSize,
2737
2767
  readSandboxBinaryBytes,
2768
+ admitSandboxSessionTurn,
2738
2769
  EGRESS_PROXY_RECOVERY_REQUIRED,
2739
2770
  EGRESS_PROXY_RECOVERY_PHASE,
2740
2771
  WORKSPACE_SANDBOX_MISSING,
@@ -2829,4 +2860,4 @@ export {
2829
2860
  isTerminalPromptEvent,
2830
2861
  detectInteractiveQuestion
2831
2862
  };
2832
- //# sourceMappingURL=chunk-FS6YF4ZV.js.map
2863
+ //# sourceMappingURL=chunk-TCNH6XDK.js.map