stitchkit 0.110.0 → 0.110.1

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 (75) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/agent-runtime/store-conformance-lifecycle.d.ts +10 -10
  3. package/dist/agent-runtime/store-conformance-support.d.ts +5 -5
  4. package/dist/browser/socket-io-client.d.ts +6 -0
  5. package/dist/browser/socket-io-client.d.ts.map +1 -0
  6. package/dist/browser/socket-io-contract.d.ts +183 -0
  7. package/dist/browser/socket-io-contract.d.ts.map +1 -0
  8. package/dist/browser/socket-io-default-peer.d.ts +3 -0
  9. package/dist/browser/socket-io-default-peer.d.ts.map +1 -0
  10. package/dist/browser/socket-io-explicit-peer.d.ts +12 -0
  11. package/dist/browser/socket-io-explicit-peer.d.ts.map +1 -0
  12. package/dist/browser/socket-io-peer.d.ts +2 -11
  13. package/dist/browser/socket-io-peer.d.ts.map +1 -1
  14. package/dist/browser/socket-io.d.ts +5 -224
  15. package/dist/browser/socket-io.d.ts.map +1 -1
  16. package/dist/entrypoints/agent-runtime/coding-tools.js +2 -2
  17. package/dist/entrypoints/agent-runtime/harness.js +2 -2
  18. package/dist/entrypoints/agent-runtime/realtime.js +3 -3
  19. package/dist/entrypoints/agent-runtime/sandbox.js +2 -2
  20. package/dist/entrypoints/agent-runtime.js +5 -5
  21. package/dist/entrypoints/application/directory-inbox.js +6 -6
  22. package/dist/entrypoints/application.js +1 -1
  23. package/dist/entrypoints/cli/publish.js +2 -2
  24. package/dist/entrypoints/cli.js +8 -8
  25. package/dist/entrypoints/contract.js +1 -1
  26. package/dist/entrypoints/files.js +1 -1
  27. package/dist/entrypoints/http.d.ts +1 -0
  28. package/dist/entrypoints/http.d.ts.map +1 -1
  29. package/dist/entrypoints/http.js +6 -2
  30. package/dist/entrypoints/index.js +20 -411
  31. package/dist/entrypoints/node.js +3 -3
  32. package/dist/entrypoints/observability.js +1 -1
  33. package/dist/entrypoints/process.js +1 -1
  34. package/dist/entrypoints/realtime.d.ts +6 -0
  35. package/dist/entrypoints/realtime.d.ts.map +1 -0
  36. package/dist/entrypoints/realtime.js +25 -0
  37. package/dist/entrypoints/remote.js +1 -1
  38. package/dist/entrypoints/server.js +11 -11
  39. package/dist/entrypoints/telegram/screens.js +9 -9
  40. package/dist/entrypoints/telegram.js +3 -3
  41. package/dist/entrypoints/testing.js +2 -2
  42. package/dist/entrypoints/tools/connections.js +3 -3
  43. package/dist/entrypoints/tools/invoker.js +3 -3
  44. package/dist/entrypoints/tools/mcp.js +4 -4
  45. package/dist/entrypoints/tools.js +22 -22
  46. package/dist/{index-61m15a18.js → index-0d8m0kee.js} +1 -1
  47. package/dist/{index-dmfr2cg5.js → index-2tazbwhv.js} +6 -6
  48. package/dist/index-86sxnvpr.js +336 -0
  49. package/dist/{index-2pevnh0x.js → index-8rstkvcf.js} +3 -3
  50. package/dist/{index-064zxbwj.js → index-924500c3.js} +1 -1
  51. package/dist/{index-mnhtbqrb.js → index-dd1z5kxb.js} +2 -2
  52. package/dist/{index-7a1xhhdx.js → index-e1sjcjfy.js} +31 -11
  53. package/dist/{index-p6mvqcbq.js → index-ghwntn9n.js} +1 -1
  54. package/dist/index-hqsbtvta.js +92 -0
  55. package/dist/{index-73cz22ds.js → index-mha6b4vk.js} +6 -6
  56. package/dist/{index-fnra8n1j.js → index-s2eybn7b.js} +9 -9
  57. package/dist/{index-njs9gvrh.js → index-s6d8zsha.js} +6 -6
  58. package/dist/{index-jyw90rps.js → index-tjdsyrys.js} +1 -1
  59. package/dist/process/group-presence.d.ts +3 -0
  60. package/dist/process/group-presence.d.ts.map +1 -0
  61. package/dist/process/group-settlement.d.ts.map +1 -1
  62. package/dist/process/group.d.ts.map +1 -1
  63. package/llms/realtime.txt +31 -0
  64. package/llms/stitchkit.txt +1 -0
  65. package/llms-full.txt +22 -0
  66. package/llms.txt +2 -1
  67. package/package.json +5 -1
  68. package/dist/{index-9j2atjte.js → index-2f9r0jgr.js} +3 -3
  69. package/dist/{index-y70v24cw.js → index-8asb62xn.js} +0 -0
  70. package/dist/{index-k7qdkh3n.js → index-h1spd9kv.js} +3 -3
  71. package/dist/{index-zgwkwr1g.js → index-jk44mbqb.js} +0 -0
  72. package/dist/{index-qd8x73e8.js → index-k8fbzggr.js} +0 -0
  73. package/dist/{index-85qve8mq.js → index-pzw0fpek.js} +0 -0
  74. package/dist/{index-y3nemndz.js → index-r6v4mc67.js} +3 -3
  75. package/dist/{index-ktjmgq9p.js → index-s0xbnpfh.js} +3 -3
@@ -2,12 +2,12 @@ import {
2
2
  joinRoutePath,
3
3
  parseRoutePattern
4
4
  } from "../../index-m38ej7e5.js";
5
- import {
6
- checkTelegramHtml2
7
- } from "../../index-rz3z13e9.js";
8
5
  import {
9
6
  classifyTelegramEditRefusal
10
7
  } from "../../index-xvj9h8yh.js";
8
+ import {
9
+ checkTelegramHtml2
10
+ } from "../../index-rz3z13e9.js";
11
11
  import {
12
12
  TELEGRAM_TEXT_LIMIT2,
13
13
  TELEGRAM_CAPTION_LIMIT2,
@@ -16,22 +16,22 @@ import {
16
16
  import {
17
17
  createMutationQueue
18
18
  } from "../../index-sykb5ag7.js";
19
- import {
20
- MAX_TIMER_MS
21
- } from "../../index-eemvahkc.js";
22
19
  import {
23
20
  bytesToBase64Url,
24
21
  base64UrlToBytes
25
22
  } from "../../index-dwfv9a85.js";
23
+ import {
24
+ MAX_TIMER_MS
25
+ } from "../../index-eemvahkc.js";
26
+ import {
27
+ isUnsafeKey
28
+ } from "../../index-zsarb5xp.js";
26
29
  import {
27
30
  argumentsDigest
28
31
  } from "../../index-r7a7r7ha.js";
29
32
  import {
30
33
  compareCodeUnits
31
34
  } from "../../index-zsvzhjtk.js";
32
- import {
33
- isUnsafeKey
34
- } from "../../index-zsarb5xp.js";
35
35
  import {
36
36
  isRecord,
37
37
  transportResult
@@ -19,12 +19,12 @@ import {
19
19
  import {
20
20
  untilAborted
21
21
  } from "../index-a5qr2rj6.js";
22
- import {
23
- raceAbort
24
- } from "../index-b0kddvzw.js";
25
22
  import {
26
23
  writeFileAtomic2
27
24
  } from "../index-07dcf2yn.js";
25
+ import {
26
+ raceAbort
27
+ } from "../index-b0kddvzw.js";
28
28
  import {
29
29
  MAX_TIMER_MS,
30
30
  sleep
@@ -6,7 +6,7 @@ import"../index-p6apg0jg.js";
6
6
  import"../index-q0th8q0z.js";
7
7
  import {
8
8
  createApplication2
9
- } from "../index-y70v24cw.js";
9
+ } from "../index-8asb62xn.js";
10
10
  import"../index-w5s3xftz.js";
11
11
  import {
12
12
  RealtimeRequestTimeoutError2,
@@ -35,7 +35,7 @@ import"../index-fynr93w4.js";
35
35
  import {
36
36
  createClient2,
37
37
  createClients2
38
- } from "../index-zgwkwr1g.js";
38
+ } from "../index-jk44mbqb.js";
39
39
  import {
40
40
  assertPositiveSafeInteger
41
41
  } from "../index-0s4xebbg.js";
@@ -25,14 +25,14 @@ import {
25
25
  import {
26
26
  TOOL_ERROR_PROJECTION
27
27
  } from "../../index-556g5hsh.js";
28
+ import {
29
+ safeJsonParse
30
+ } from "../../index-zsarb5xp.js";
28
31
  import {
29
32
  AppError2,
30
33
  STITCH_ERROR_STATUS2,
31
34
  isRetryableStatus2
32
35
  } from "../../index-j9gxbztg.js";
33
- import {
34
- safeJsonParse
35
- } from "../../index-zsarb5xp.js";
36
36
  import {
37
37
  isRecord
38
38
  } from "../../index-9jfdm5tg.js";
@@ -3,11 +3,11 @@ import"../../index-t5sjh517.js";
3
3
  import"../../index-cykxpxz5.js";
4
4
  import"../../index-ct75c3at.js";
5
5
  import"../../index-q6crhe1n.js";
6
- import"../../index-73cz22ds.js";
7
- import"../../index-p6mvqcbq.js";
6
+ import"../../index-mha6b4vk.js";
7
+ import"../../index-ghwntn9n.js";
8
8
  import {
9
9
  createToolInvoker2
10
- } from "../../index-mnhtbqrb.js";
10
+ } from "../../index-dd1z5kxb.js";
11
11
  export {
12
12
  createToolInvoker2 as createToolInvoker
13
13
  };
@@ -3,8 +3,8 @@ import"../../index-fynr93w4.js";
3
3
  import"../../index-t5sjh517.js";
4
4
  import"../../index-cykxpxz5.js";
5
5
  import"../../index-q6crhe1n.js";
6
- import"../../index-73cz22ds.js";
7
- import"../../index-p6mvqcbq.js";
6
+ import"../../index-mha6b4vk.js";
7
+ import"../../index-ghwntn9n.js";
8
8
  import {
9
9
  RESOURCE_MIME_TYPE2,
10
10
  EXT_APPS_BUNDLE_PLACEHOLDER2,
@@ -20,8 +20,8 @@ import {
20
20
  createMcpHttpRoute2,
21
21
  createStdioMcpServer2,
22
22
  bindStdioProcessSignals2
23
- } from "../../index-fnra8n1j.js";
24
- import"../../index-61m15a18.js";
23
+ } from "../../index-s2eybn7b.js";
24
+ import"../../index-0d8m0kee.js";
25
25
  import"../../index-636mggad.js";
26
26
  export {
27
27
  EXT_APPS_BUNDLE_PLACEHOLDER2 as EXT_APPS_BUNDLE_PLACEHOLDER,
@@ -23,15 +23,15 @@ import {
23
23
  import {
24
24
  ToolExecutionControlError2,
25
25
  isToolExecutionControlError2
26
- } from "../index-73cz22ds.js";
26
+ } from "../index-mha6b4vk.js";
27
27
  import {
28
28
  collectTools2
29
- } from "../index-p6mvqcbq.js";
29
+ } from "../index-ghwntn9n.js";
30
30
  import {
31
31
  mountAgent2,
32
32
  describeToolCatalog2,
33
33
  buildToolManifest2
34
- } from "../index-2pevnh0x.js";
34
+ } from "../index-8rstkvcf.js";
35
35
  import"../index-m38ej7e5.js";
36
36
  import {
37
37
  ALL_TRANSPORTS2,
@@ -58,7 +58,7 @@ import {
58
58
  createMcpHttpRoute2,
59
59
  createStdioMcpServer2,
60
60
  bindStdioProcessSignals2
61
- } from "../index-fnra8n1j.js";
61
+ } from "../index-s2eybn7b.js";
62
62
  import {
63
63
  AsyncOperationCancelResultSchema2,
64
64
  createAsyncOperationSnapshotSchema2,
@@ -72,44 +72,44 @@ import {
72
72
  WaitTimeoutError,
73
73
  runWaitOperation,
74
74
  createCli2
75
- } from "../index-dmfr2cg5.js";
75
+ } from "../index-2tazbwhv.js";
76
76
  import {
77
77
  ManagedFilePathSchema2,
78
78
  ManagedFileRefSchema2
79
79
  } from "../index-xqhede6x.js";
80
+ import {
81
+ signJwt2,
82
+ verifyPkce2
83
+ } from "../index-h1spd9kv.js";
84
+ import {
85
+ contractOnlyService,
86
+ mediaTypeEssence
87
+ } from "../index-pzw0fpek.js";
80
88
  import {
81
89
  createToolInvoker2
82
- } from "../index-mnhtbqrb.js";
90
+ } from "../index-dd1z5kxb.js";
83
91
  import {
84
92
  ManagedFileError2
85
- } from "../index-9j2atjte.js";
93
+ } from "../index-2f9r0jgr.js";
86
94
  import {
87
95
  fetchGuarded,
88
96
  fetchPinnedDocument,
89
97
  readCapped
90
98
  } from "../index-3h0ztg0z.js";
91
- import {
92
- signJwt2,
93
- verifyPkce2
94
- } from "../index-k7qdkh3n.js";
95
- import {
96
- contractOnlyService,
97
- mediaTypeEssence
98
- } from "../index-85qve8mq.js";
99
99
  import"../index-1bx1xv1k.js";
100
+ import {
101
+ DEFAULT_CORS_ALLOW_HEADERS2
102
+ } from "../index-yk4g8805.js";
100
103
  import {
101
104
  collectToolSurface
102
- } from "../index-61m15a18.js";
105
+ } from "../index-0d8m0kee.js";
106
+ import {
107
+ getTraceId2
108
+ } from "../index-r6v4mc67.js";
103
109
  import {
104
110
  defineRuntimeTool2,
105
111
  createRuntimeToolFactory2
106
112
  } from "../index-636mggad.js";
107
- import {
108
- DEFAULT_CORS_ALLOW_HEADERS2
109
- } from "../index-yk4g8805.js";
110
- import {
111
- getTraceId2
112
- } from "../index-y3nemndz.js";
113
113
  import {
114
114
  formatZodError2
115
115
  } from "../index-1eeqpadm.js";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./index-q6crhe1n.js";
4
4
  import {
5
5
  contractToolMountable
6
- } from "./index-p6mvqcbq.js";
6
+ } from "./index-ghwntn9n.js";
7
7
  import {
8
8
  runtimeToolMountable
9
9
  } from "./index-636mggad.js";
@@ -18,11 +18,11 @@ import {
18
18
  import {
19
19
  toolResultFromError,
20
20
  toolErrorFromResult
21
- } from "./index-73cz22ds.js";
21
+ } from "./index-mha6b4vk.js";
22
22
  import {
23
23
  createToolRunner,
24
24
  formatToolError
25
- } from "./index-p6mvqcbq.js";
25
+ } from "./index-ghwntn9n.js";
26
26
  import {
27
27
  fetchGuarded,
28
28
  readCapped
@@ -35,14 +35,14 @@ import {
35
35
  } from "./index-eemvahkc.js";
36
36
  import {
37
37
  collectToolSurface
38
- } from "./index-61m15a18.js";
39
- import {
40
- formatZodError2
41
- } from "./index-1eeqpadm.js";
38
+ } from "./index-0d8m0kee.js";
42
39
  import {
43
40
  isUnsafeKey,
44
41
  safeJsonParse
45
42
  } from "./index-zsarb5xp.js";
43
+ import {
44
+ formatZodError2
45
+ } from "./index-1eeqpadm.js";
46
46
  import {
47
47
  isRecord
48
48
  } from "./index-9jfdm5tg.js";
@@ -0,0 +1,336 @@
1
+ import {
2
+ RealtimeRequestTimeoutError2,
3
+ RealtimeRequestDisconnectedError2
4
+ } from "./index-4s0fep5q.js";
5
+ import {
6
+ isModuleNotFound
7
+ } from "./index-srs8hj9c.js";
8
+ import {
9
+ realtimeRequestTraces,
10
+ createRequestTracer,
11
+ bindRealtimeClient2
12
+ } from "./index-pvh3z03x.js";
13
+
14
+ // src/browser/retained.ts
15
+ function createRetainedTopics2() {
16
+ const last = {};
17
+ return {
18
+ record(topic, payload) {
19
+ last[topic] = payload;
20
+ },
21
+ replay(topic, handler) {
22
+ const value = last[topic];
23
+ if (value !== undefined)
24
+ handler(value);
25
+ },
26
+ get(topic) {
27
+ return last[topic];
28
+ },
29
+ clear(topic) {
30
+ if (topic !== undefined) {
31
+ delete last[topic];
32
+ return;
33
+ }
34
+ for (const key of Object.keys(last))
35
+ Reflect.deleteProperty(last, key);
36
+ }
37
+ };
38
+ }
39
+
40
+ // src/browser/socket-io-connection.ts
41
+ function toIoAuth(auth) {
42
+ if (typeof auth !== "function")
43
+ return auth;
44
+ return (cb) => {
45
+ Promise.resolve().then(auth).then(cb, () => cb({}));
46
+ };
47
+ }
48
+ function ioOptions(config) {
49
+ return {
50
+ path: config.path ?? "/socket.io/",
51
+ withCredentials: config.withCredentials ?? true,
52
+ auth: toIoAuth(config.auth),
53
+ ...config.query && { query: config.query },
54
+ ...config.extraHeaders && { extraHeaders: config.extraHeaders },
55
+ transports: config.transports ?? ["websocket", "polling"],
56
+ autoConnect: false,
57
+ reconnection: true,
58
+ reconnectionAttempts: config.reconnectionAttempts ?? Infinity,
59
+ reconnectionDelay: config.reconnectionDelay ?? 1000,
60
+ reconnectionDelayMax: config.reconnectionDelayMax ?? 5000,
61
+ timeout: config.timeout ?? 20000
62
+ };
63
+ }
64
+ function reportPeerFailure(config, error) {
65
+ if (!config.onConnectError)
66
+ throw error;
67
+ config.onConnectError({
68
+ message: error instanceof Error ? error.message : String(error),
69
+ data: error,
70
+ terminal: true
71
+ });
72
+ }
73
+ function awaitAcknowledgement(input) {
74
+ const { active, event } = input;
75
+ return new Promise((resolve, reject) => {
76
+ let settled = false;
77
+ const finish = (result) => {
78
+ if (settled)
79
+ return;
80
+ settled = true;
81
+ input.pendingRequestDisconnects.delete(onDisconnect);
82
+ active.off("disconnect", onDisconnect);
83
+ result();
84
+ };
85
+ const onDisconnect = () => {
86
+ finish(() => {
87
+ input.closeTrace("disconnected");
88
+ reject(new RealtimeRequestDisconnectedError2(event));
89
+ });
90
+ };
91
+ input.pendingRequestDisconnects.add(onDisconnect);
92
+ active.on("disconnect", onDisconnect);
93
+ const acknowledgement = input.emit();
94
+ acknowledgement.then((value) => finish(() => resolve(value)), () => {
95
+ finish(() => {
96
+ const connected = active.connected;
97
+ input.closeTrace(connected ? "timeout" : "disconnected");
98
+ reject(connected ? new RealtimeRequestTimeoutError2(event, input.timeoutMs) : new RealtimeRequestDisconnectedError2(event));
99
+ });
100
+ });
101
+ });
102
+ }
103
+ function createStickyEvents(retain) {
104
+ const names = retain ? retain.map(String) : [];
105
+ const known = new Set(names);
106
+ const retained = names.length > 0 ? createRetainedTopics2() : null;
107
+ return {
108
+ record(socket) {
109
+ if (!retained)
110
+ return;
111
+ for (const name of names) {
112
+ socket.on(name, (payload) => retained.record(name, payload));
113
+ }
114
+ },
115
+ replay(name, handler) {
116
+ if (retained && known.has(name))
117
+ retained.replay(name, (payload) => handler(payload));
118
+ }
119
+ };
120
+ }
121
+ function createRecycle(delay) {
122
+ let timer = null;
123
+ const clear = () => {
124
+ if (timer === null)
125
+ return;
126
+ clearTimeout(timer);
127
+ timer = null;
128
+ };
129
+ return {
130
+ clear,
131
+ schedule(run) {
132
+ if (delay === false)
133
+ return;
134
+ clear();
135
+ timer = setTimeout(() => {
136
+ timer = null;
137
+ run();
138
+ }, delay);
139
+ }
140
+ };
141
+ }
142
+ function connectErrorReport(error, socket) {
143
+ return {
144
+ message: error.message,
145
+ data: Reflect.get(error, "data"),
146
+ terminal: socket !== null && !socket.active
147
+ };
148
+ }
149
+
150
+ // src/browser/socket-io-peer.ts
151
+ function isIoModule(module) {
152
+ if (typeof module !== "object" || module === null)
153
+ return false;
154
+ return typeof Reflect.get(module, "io") === "function";
155
+ }
156
+ function createIoResolver(injected, defaultIo) {
157
+ if (!injected)
158
+ return defaultIo;
159
+ let pending = null;
160
+ return () => {
161
+ if (!pending) {
162
+ pending = Promise.resolve().then(injected).then((module) => {
163
+ const io = isIoModule(module) ? module.io : null;
164
+ if (!io) {
165
+ pending = null;
166
+ throw new Error("stitchkit: the loader passed in `peers.client` did not return the \"socket.io-client\" module — it must resolve to the module itself, as `() => import('socket.io-client')`.");
167
+ }
168
+ return io;
169
+ }, (cause) => {
170
+ pending = null;
171
+ if (!isModuleNotFound(cause))
172
+ throw cause;
173
+ throw new Error('stitchkit: createSocketIOClient could not load "socket.io-client" through the loader passed in `peers` — the artifact does not contain it. Check that the loader is a literal `import(\'socket.io-client\')` your bundler can follow, and that "socket.io-client" is a dependency of the package being bundled.', { cause });
174
+ });
175
+ }
176
+ return pending;
177
+ };
178
+ }
179
+
180
+ // src/browser/socket-io-client.ts
181
+ function createRealtimeClientWithPeer(contract, { onRejected, logger, onRequestPhase, ...config }, defaultIo) {
182
+ const transport = createSocketIOClientInternal(config, defaultIo, onRequestPhase);
183
+ const bound = bindRealtimeClient2(contract, transport, { onRejected, logger });
184
+ return {
185
+ ...bound,
186
+ get connected() {
187
+ return bound.connected;
188
+ },
189
+ connect: transport.connect,
190
+ disconnect: transport.disconnect
191
+ };
192
+ }
193
+ function createSocketIOClientWithPeer(config, defaultIo) {
194
+ return createSocketIOClientInternal(config, defaultIo);
195
+ }
196
+ function createSocketIOClientInternal(config, defaultIo, onRequestPhase) {
197
+ let socket = null;
198
+ const resolveIo = createIoResolver(config.peers?.client, defaultIo);
199
+ let desiredConnected = false;
200
+ let loadingPeer = false;
201
+ const recycle = createRecycle(config.reconnectOnServerDisconnect ?? 1000);
202
+ const pendingRequestDisconnects = new Set;
203
+ const tracer = createRequestTracer(onRequestPhase);
204
+ const connectionListeners = new Set;
205
+ const subscriptions = new Set;
206
+ const sticky = createStickyEvents(config.retain);
207
+ function notifyConnection(connected, reason) {
208
+ for (const listener of connectionListeners)
209
+ listener(connected, reason);
210
+ }
211
+ function openSocket(io) {
212
+ if (!desiredConnected || socket)
213
+ return;
214
+ socket = io(config.url, ioOptions(config));
215
+ tracer.observeEachOpen(socket, () => socket);
216
+ socket.on("connect", () => notifyConnection(true));
217
+ socket.on("disconnect", (reason) => {
218
+ notifyConnection(false, reason);
219
+ if (reason === "io server disconnect") {
220
+ const current = socket;
221
+ recycle.schedule(() => {
222
+ if (socket === current && current && !current.connected)
223
+ current.connect();
224
+ });
225
+ }
226
+ });
227
+ socket.io.on("reconnect_failed", () => {
228
+ desiredConnected = false;
229
+ });
230
+ socket.on("connect_error", (error) => {
231
+ const report = connectErrorReport(error, socket);
232
+ if (report.terminal)
233
+ desiredConnected = false;
234
+ config.onConnectError?.(report);
235
+ });
236
+ sticky.record(socket);
237
+ for (const attach of subscriptions)
238
+ attach(socket);
239
+ socket.connect();
240
+ }
241
+ return {
242
+ get connected() {
243
+ return socket?.connected ?? false;
244
+ },
245
+ connect() {
246
+ if (socket?.connected || desiredConnected)
247
+ return;
248
+ desiredConnected = true;
249
+ if (socket) {
250
+ socket.connect();
251
+ return;
252
+ }
253
+ if (loadingPeer)
254
+ return;
255
+ loadingPeer = true;
256
+ resolveIo().then((io) => {
257
+ loadingPeer = false;
258
+ openSocket(io);
259
+ }, (error) => {
260
+ loadingPeer = false;
261
+ desiredConnected = false;
262
+ reportPeerFailure(config, error);
263
+ });
264
+ },
265
+ disconnect() {
266
+ desiredConnected = false;
267
+ recycle.clear();
268
+ for (const reject of [...pendingRequestDisconnects])
269
+ reject();
270
+ if (!socket)
271
+ return;
272
+ const wasConnected = socket.connected;
273
+ socket.removeAllListeners();
274
+ socket.disconnect();
275
+ socket = null;
276
+ if (wasConnected)
277
+ notifyConnection(false);
278
+ },
279
+ on(event, handler) {
280
+ const name = event;
281
+ const attach = (s) => {
282
+ s.on(name, handler);
283
+ };
284
+ subscriptions.add(attach);
285
+ if (socket)
286
+ attach(socket);
287
+ const fn = handler;
288
+ sticky.replay(name, fn);
289
+ return () => {
290
+ subscriptions.delete(attach);
291
+ socket?.off(name, handler);
292
+ };
293
+ },
294
+ emit(event, ...args) {
295
+ const name = event;
296
+ if (!socket?.connected) {
297
+ config.onDroppedEmit?.({ event: name, args });
298
+ return false;
299
+ }
300
+ socket.emit(name, ...args);
301
+ return true;
302
+ },
303
+ emitWithAck(event, args, options) {
304
+ const trace = tracer.start(event, options.onPhase);
305
+ const closeTrace = (phase) => tracer.close(trace, phase);
306
+ const active = socket;
307
+ if (!active?.connected) {
308
+ const pending = Promise.reject(new RealtimeRequestDisconnectedError2(event));
309
+ closeTrace("disconnected");
310
+ if (trace)
311
+ realtimeRequestTraces.set(pending, trace);
312
+ return pending;
313
+ }
314
+ if (trace)
315
+ tracer.observe(active);
316
+ const pending = awaitAcknowledgement({
317
+ active,
318
+ event,
319
+ args,
320
+ timeoutMs: options.timeoutMs,
321
+ pendingRequestDisconnects,
322
+ closeTrace,
323
+ emit: () => tracer.starting(trace, () => active.timeout(options.timeoutMs).emitWithAck(event, ...args))
324
+ });
325
+ if (trace)
326
+ realtimeRequestTraces.set(pending, trace);
327
+ return pending;
328
+ },
329
+ onConnectionChange(listener) {
330
+ connectionListeners.add(listener);
331
+ return () => connectionListeners.delete(listener);
332
+ }
333
+ };
334
+ }
335
+
336
+ export { createRetainedTopics2, createRealtimeClientWithPeer, createSocketIOClientWithPeer };
@@ -2,18 +2,18 @@ import {
2
2
  toolResultFromError,
3
3
  toolCauseFromResult,
4
4
  isToolExecutionControlError2
5
- } from "./index-73cz22ds.js";
5
+ } from "./index-mha6b4vk.js";
6
6
  import {
7
7
  createToolRunner,
8
8
  formatToolError
9
- } from "./index-p6mvqcbq.js";
9
+ } from "./index-ghwntn9n.js";
10
10
  import {
11
11
  AgentToolError2,
12
12
  resolveToolDurability
13
13
  } from "./index-c17xcx4k.js";
14
14
  import {
15
15
  collectToolSurface
16
- } from "./index-61m15a18.js";
16
+ } from "./index-0d8m0kee.js";
17
17
  import {
18
18
  agentPresenterOf
19
19
  } from "./index-636mggad.js";
@@ -14,7 +14,7 @@ import {
14
14
  import {
15
15
  ToolExecutionControlError2,
16
16
  isToolExecutionControlError2
17
- } from "./index-73cz22ds.js";
17
+ } from "./index-mha6b4vk.js";
18
18
  import {
19
19
  agentDurableEventId2
20
20
  } from "./index-mnkk1ffz.js";
@@ -3,11 +3,11 @@ import {
3
3
  } from "./index-q6crhe1n.js";
4
4
  import {
5
5
  toolErrorFromResult
6
- } from "./index-73cz22ds.js";
6
+ } from "./index-mha6b4vk.js";
7
7
  import {
8
8
  collectTools2,
9
9
  createToolRunner
10
- } from "./index-p6mvqcbq.js";
10
+ } from "./index-ghwntn9n.js";
11
11
  import {
12
12
  AppError2
13
13
  } from "./index-j9gxbztg.js";