stitchkit 0.109.4 → 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.
- package/CHANGELOG.md +28 -0
- package/dist/agent-runtime/store-conformance-support.d.ts +5 -5
- package/dist/application/process-lifecycle-transitions.d.ts +10 -2
- package/dist/application/process-lifecycle-transitions.d.ts.map +1 -1
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/browser/socket-io-client.d.ts +6 -0
- package/dist/browser/socket-io-client.d.ts.map +1 -0
- package/dist/browser/socket-io-contract.d.ts +183 -0
- package/dist/browser/socket-io-contract.d.ts.map +1 -0
- package/dist/browser/socket-io-default-peer.d.ts +3 -0
- package/dist/browser/socket-io-default-peer.d.ts.map +1 -0
- package/dist/browser/socket-io-explicit-peer.d.ts +12 -0
- package/dist/browser/socket-io-explicit-peer.d.ts.map +1 -0
- package/dist/browser/socket-io-peer.d.ts +2 -11
- package/dist/browser/socket-io-peer.d.ts.map +1 -1
- package/dist/browser/socket-io.d.ts +5 -224
- package/dist/browser/socket-io.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/coding-tools.js +3 -3
- package/dist/entrypoints/agent-runtime/harness.js +6 -6
- package/dist/entrypoints/agent-runtime/realtime.js +4 -4
- package/dist/entrypoints/agent-runtime/sandbox.js +3 -3
- package/dist/entrypoints/agent-runtime.js +6 -6
- package/dist/entrypoints/application/directory-inbox.js +6 -6
- package/dist/entrypoints/application.js +17 -9
- package/dist/entrypoints/cli/publish.js +2 -2
- package/dist/entrypoints/cli.js +9 -9
- package/dist/entrypoints/contract.js +2 -2
- package/dist/entrypoints/files.js +1 -1
- package/dist/entrypoints/http.d.ts +6 -0
- package/dist/entrypoints/http.d.ts.map +1 -0
- package/dist/entrypoints/http.js +32 -0
- package/dist/entrypoints/index.js +21 -412
- package/dist/entrypoints/node.js +3 -3
- package/dist/entrypoints/observability.js +1 -1
- package/dist/entrypoints/process/owner-loss.js +1 -1
- package/dist/entrypoints/process.js +2 -2
- package/dist/entrypoints/react.js +1 -1
- package/dist/entrypoints/realtime.d.ts +6 -0
- package/dist/entrypoints/realtime.d.ts.map +1 -0
- package/dist/entrypoints/realtime.js +25 -0
- package/dist/entrypoints/remote.js +2 -2
- package/dist/entrypoints/server.js +8 -8
- package/dist/entrypoints/telegram/screens.js +6 -6
- package/dist/entrypoints/telegram.js +3 -3
- package/dist/entrypoints/testing.js +3 -3
- package/dist/entrypoints/tools/connections.js +3 -3
- package/dist/entrypoints/tools/invoker.js +3 -3
- package/dist/entrypoints/tools/mcp.js +4 -4
- package/dist/entrypoints/tools.js +24 -24
- package/dist/{index-3wm2xp2a.js → index-0d8m0kee.js} +1 -1
- package/dist/{index-5cw390s6.js → index-2tazbwhv.js} +6 -6
- package/dist/{index-hjvje0pf.js → index-506kd458.js} +1 -1
- package/dist/{index-dj1aycxw.js → index-84bf5spd.js} +0 -1
- package/dist/index-86sxnvpr.js +336 -0
- package/dist/{index-68y3n9j3.js → index-8rstkvcf.js} +3 -3
- package/dist/{index-tpk71wqn.js → index-924500c3.js} +1 -1
- package/dist/{index-kvvpw1kq.js → index-dd1z5kxb.js} +2 -2
- package/dist/{index-k3ty2b88.js → index-e1sjcjfy.js} +95 -20
- package/dist/{index-ryv32myz.js → index-ghwntn9n.js} +1 -1
- package/dist/index-hqsbtvta.js +92 -0
- package/dist/{index-e32vy8jw.js → index-jk44mbqb.js} +1 -1
- package/dist/{index-k4v2kq4q.js → index-mha6b4vk.js} +6 -6
- package/dist/{index-00v1qz76.js → index-p6apg0jg.js} +1 -1
- package/dist/{index-x5xs71dw.js → index-s2eybn7b.js} +8 -8
- package/dist/{index-njs9gvrh.js → index-s6d8zsha.js} +6 -6
- package/dist/{index-kc3jqqew.js → index-tjdsyrys.js} +2 -2
- package/dist/process/command-owner.d.ts.map +1 -1
- package/dist/process/group-presence.d.ts +3 -0
- package/dist/process/group-presence.d.ts.map +1 -0
- package/dist/process/group-settlement.d.ts +5 -0
- package/dist/process/group-settlement.d.ts.map +1 -0
- package/dist/process/group.d.ts.map +1 -1
- package/dist/process/output-drain.d.ts +1 -1
- package/dist/process/output-drain.d.ts.map +1 -1
- package/dist/process/owner-loss-control.d.ts.map +1 -1
- package/llms/application.2.txt +8 -5
- package/llms/application.3.txt +3 -0
- package/llms/http.txt +19 -0
- package/llms/realtime.txt +31 -0
- package/llms/stitchkit.txt +5 -3
- package/llms/{upgrading-0.101.0-0.109.0.txt → upgrading-0.101.0-0.110.0.txt} +13 -3
- package/llms/upgrading.txt +1 -1
- package/llms-full.txt +57 -8
- package/llms.txt +5 -3
- package/package.json +9 -1
- package/dist/{index-9j2atjte.js → index-2f9r0jgr.js} +3 -3
- package/dist/{index-299sm5tr.js → index-616xh7f2.js} +0 -0
- package/dist/{index-y70v24cw.js → index-8asb62xn.js} +0 -0
- package/dist/{index-k7qdkh3n.js → index-h1spd9kv.js} +3 -3
- package/dist/{index-qd8x73e8.js → index-k8fbzggr.js} +0 -0
- package/dist/{index-85qve8mq.js → index-pzw0fpek.js} +0 -0
- package/dist/{index-y3nemndz.js → index-r6v4mc67.js} +3 -3
- package/dist/{index-ktjmgq9p.js → index-s0xbnpfh.js} +3 -3
|
@@ -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
|
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
joinRoutePath
|
|
3
3
|
} from "../index-m38ej7e5.js";
|
|
4
4
|
import"../index-h2fhjqy7.js";
|
|
5
|
-
import"../index-
|
|
5
|
+
import"../index-p6apg0jg.js";
|
|
6
6
|
import"../index-q0th8q0z.js";
|
|
7
7
|
import {
|
|
8
8
|
createApplication2
|
|
9
|
-
} from "../index-
|
|
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-
|
|
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-
|
|
7
|
-
import"../../index-
|
|
6
|
+
import"../../index-mha6b4vk.js";
|
|
7
|
+
import"../../index-ghwntn9n.js";
|
|
8
8
|
import {
|
|
9
9
|
createToolInvoker2
|
|
10
|
-
} from "../../index-
|
|
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-
|
|
7
|
-
import"../../index-
|
|
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-
|
|
24
|
-
import"../../index-
|
|
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-
|
|
26
|
+
} from "../index-mha6b4vk.js";
|
|
27
27
|
import {
|
|
28
28
|
collectTools2
|
|
29
|
-
} from "../index-
|
|
29
|
+
} from "../index-ghwntn9n.js";
|
|
30
30
|
import {
|
|
31
31
|
mountAgent2,
|
|
32
32
|
describeToolCatalog2,
|
|
33
33
|
buildToolManifest2
|
|
34
|
-
} from "../index-
|
|
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-
|
|
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-
|
|
75
|
+
} from "../index-2tazbwhv.js";
|
|
76
76
|
import {
|
|
77
77
|
ManagedFilePathSchema2,
|
|
78
78
|
ManagedFileRefSchema2
|
|
79
79
|
} from "../index-xqhede6x.js";
|
|
80
|
-
import {
|
|
81
|
-
ManagedFileError2
|
|
82
|
-
} from "../index-9j2atjte.js";
|
|
83
|
-
import {
|
|
84
|
-
fetchGuarded,
|
|
85
|
-
fetchPinnedDocument,
|
|
86
|
-
readCapped
|
|
87
|
-
} from "../index-3h0ztg0z.js";
|
|
88
80
|
import {
|
|
89
81
|
signJwt2,
|
|
90
82
|
verifyPkce2
|
|
91
|
-
} from "../index-
|
|
83
|
+
} from "../index-h1spd9kv.js";
|
|
92
84
|
import {
|
|
93
85
|
contractOnlyService,
|
|
94
86
|
mediaTypeEssence
|
|
95
|
-
} from "../index-
|
|
96
|
-
import"../index-1bx1xv1k.js";
|
|
87
|
+
} from "../index-pzw0fpek.js";
|
|
97
88
|
import {
|
|
98
|
-
|
|
99
|
-
} from "../index-
|
|
89
|
+
createToolInvoker2
|
|
90
|
+
} from "../index-dd1z5kxb.js";
|
|
100
91
|
import {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
92
|
+
ManagedFileError2
|
|
93
|
+
} from "../index-2f9r0jgr.js";
|
|
94
|
+
import {
|
|
95
|
+
fetchGuarded,
|
|
96
|
+
fetchPinnedDocument,
|
|
97
|
+
readCapped
|
|
98
|
+
} from "../index-3h0ztg0z.js";
|
|
99
|
+
import"../index-1bx1xv1k.js";
|
|
104
100
|
import {
|
|
105
101
|
DEFAULT_CORS_ALLOW_HEADERS2
|
|
106
102
|
} from "../index-yk4g8805.js";
|
|
107
103
|
import {
|
|
108
|
-
|
|
109
|
-
} from "../index-
|
|
104
|
+
collectToolSurface
|
|
105
|
+
} from "../index-0d8m0kee.js";
|
|
110
106
|
import {
|
|
111
107
|
getTraceId2
|
|
112
|
-
} from "../index-
|
|
108
|
+
} from "../index-r6v4mc67.js";
|
|
109
|
+
import {
|
|
110
|
+
defineRuntimeTool2,
|
|
111
|
+
createRuntimeToolFactory2
|
|
112
|
+
} from "../index-636mggad.js";
|
|
113
113
|
import {
|
|
114
114
|
formatZodError2
|
|
115
115
|
} from "../index-1eeqpadm.js";
|
|
@@ -18,11 +18,11 @@ import {
|
|
|
18
18
|
import {
|
|
19
19
|
toolResultFromError,
|
|
20
20
|
toolErrorFromResult
|
|
21
|
-
} from "./index-
|
|
21
|
+
} from "./index-mha6b4vk.js";
|
|
22
22
|
import {
|
|
23
23
|
createToolRunner,
|
|
24
24
|
formatToolError
|
|
25
|
-
} from "./index-
|
|
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-
|
|
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";
|
|
@@ -246,7 +246,6 @@ function attachOwnerLossControl(child, control) {
|
|
|
246
246
|
control.once("end", onMissing);
|
|
247
247
|
control.once("close", onMissing);
|
|
248
248
|
control.once("error", onError);
|
|
249
|
-
child.on("exit", onMissing);
|
|
250
249
|
guards.set(child, { control, started: settled.promise });
|
|
251
250
|
}
|
|
252
251
|
function transferOwnerLossControl(source, target) {
|
|
@@ -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-
|
|
5
|
+
} from "./index-mha6b4vk.js";
|
|
6
6
|
import {
|
|
7
7
|
createToolRunner,
|
|
8
8
|
formatToolError
|
|
9
|
-
} from "./index-
|
|
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-
|
|
16
|
+
} from "./index-0d8m0kee.js";
|
|
17
17
|
import {
|
|
18
18
|
agentPresenterOf
|
|
19
19
|
} from "./index-636mggad.js";
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
} from "./index-q6crhe1n.js";
|
|
4
4
|
import {
|
|
5
5
|
toolErrorFromResult
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-mha6b4vk.js";
|
|
7
7
|
import {
|
|
8
8
|
collectTools2,
|
|
9
9
|
createToolRunner
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-ghwntn9n.js";
|
|
11
11
|
import {
|
|
12
12
|
AppError2
|
|
13
13
|
} from "./index-j9gxbztg.js";
|