stitchkit 0.110.0 → 0.110.2

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 (142) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/agent-runtime/archive-spill.d.ts +61 -0
  3. package/dist/agent-runtime/archive-spill.d.ts.map +1 -0
  4. package/dist/agent-runtime/branch-contract.d.ts +102 -0
  5. package/dist/agent-runtime/branch-contract.d.ts.map +1 -0
  6. package/dist/agent-runtime/branch-events.d.ts +18 -0
  7. package/dist/agent-runtime/branch-events.d.ts.map +1 -0
  8. package/dist/agent-runtime/branch-identities.d.ts +20 -0
  9. package/dist/agent-runtime/branch-identities.d.ts.map +1 -0
  10. package/dist/agent-runtime/branch-messages.d.ts +32 -0
  11. package/dist/agent-runtime/branch-messages.d.ts.map +1 -0
  12. package/dist/agent-runtime/branch-observations.d.ts +104 -0
  13. package/dist/agent-runtime/branch-observations.d.ts.map +1 -0
  14. package/dist/agent-runtime/branch-provider.d.ts +130 -0
  15. package/dist/agent-runtime/branch-provider.d.ts.map +1 -0
  16. package/dist/agent-runtime/branch-replay.d.ts +426 -0
  17. package/dist/agent-runtime/branch-replay.d.ts.map +1 -0
  18. package/dist/agent-runtime/branch-source.d.ts +16 -0
  19. package/dist/agent-runtime/branch-source.d.ts.map +1 -0
  20. package/dist/agent-runtime/branch-transitions.d.ts +6 -0
  21. package/dist/agent-runtime/branch-transitions.d.ts.map +1 -0
  22. package/dist/agent-runtime/sqlite-history.d.ts.map +1 -1
  23. package/dist/agent-runtime/sqlite-purge.d.ts.map +1 -1
  24. package/dist/agent-runtime/store-archive.d.ts +1 -0
  25. package/dist/agent-runtime/store-archive.d.ts.map +1 -1
  26. package/dist/agent-runtime/store-branch.d.ts +5 -0
  27. package/dist/agent-runtime/store-branch.d.ts.map +1 -0
  28. package/dist/agent-runtime/store-conformance-branch.d.ts +4 -0
  29. package/dist/agent-runtime/store-conformance-branch.d.ts.map +1 -0
  30. package/dist/agent-runtime/store-conformance-lifecycle.d.ts +10 -10
  31. package/dist/agent-runtime/store-conformance.d.ts.map +1 -1
  32. package/dist/agent-runtime/store-create.d.ts +1 -1
  33. package/dist/agent-runtime/store-create.d.ts.map +1 -1
  34. package/dist/agent-runtime/store-driver-contract.d.ts +6 -0
  35. package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
  36. package/dist/agent-runtime/store-events.d.ts +90 -0
  37. package/dist/agent-runtime/store-events.d.ts.map +1 -1
  38. package/dist/agent-runtime/store-memory-archive.d.ts +8 -0
  39. package/dist/agent-runtime/store-memory-archive.d.ts.map +1 -0
  40. package/dist/agent-runtime/store-memory-events.d.ts +7 -0
  41. package/dist/agent-runtime/store-memory-events.d.ts.map +1 -0
  42. package/dist/agent-runtime/store-memory.d.ts +1 -1
  43. package/dist/agent-runtime/store-memory.d.ts.map +1 -1
  44. package/dist/agent-runtime/store-purge.d.ts +2 -0
  45. package/dist/agent-runtime/store-purge.d.ts.map +1 -1
  46. package/dist/agent-runtime/store-reduce-run.d.ts +2 -2
  47. package/dist/agent-runtime/store-reduce-run.d.ts.map +1 -1
  48. package/dist/agent-runtime/store-reduce-shared.d.ts +1 -0
  49. package/dist/agent-runtime/store-reduce-shared.d.ts.map +1 -1
  50. package/dist/agent-runtime/store-reducer.d.ts +2 -2
  51. package/dist/agent-runtime/store-reducer.d.ts.map +1 -1
  52. package/dist/agent-runtime/store.d.ts +3 -0
  53. package/dist/agent-runtime/store.d.ts.map +1 -1
  54. package/dist/browser/socket-io-client.d.ts +6 -0
  55. package/dist/browser/socket-io-client.d.ts.map +1 -0
  56. package/dist/browser/socket-io-contract.d.ts +183 -0
  57. package/dist/browser/socket-io-contract.d.ts.map +1 -0
  58. package/dist/browser/socket-io-default-peer.d.ts +3 -0
  59. package/dist/browser/socket-io-default-peer.d.ts.map +1 -0
  60. package/dist/browser/socket-io-explicit-peer.d.ts +12 -0
  61. package/dist/browser/socket-io-explicit-peer.d.ts.map +1 -0
  62. package/dist/browser/socket-io-peer.d.ts +2 -11
  63. package/dist/browser/socket-io-peer.d.ts.map +1 -1
  64. package/dist/browser/socket-io.d.ts +5 -224
  65. package/dist/browser/socket-io.d.ts.map +1 -1
  66. package/dist/durability/events.d.ts +4 -0
  67. package/dist/durability/events.d.ts.map +1 -1
  68. package/dist/entrypoints/agent-runtime/coding-tools.js +2 -3
  69. package/dist/entrypoints/agent-runtime/harness.js +5 -4
  70. package/dist/entrypoints/agent-runtime/realtime.js +3 -3
  71. package/dist/entrypoints/agent-runtime/sandbox.js +4 -6
  72. package/dist/entrypoints/agent-runtime/sqlite/bun.js +13 -3
  73. package/dist/entrypoints/agent-runtime/sqlite/node.js +13 -3
  74. package/dist/entrypoints/agent-runtime/testing.js +89 -5
  75. package/dist/entrypoints/agent-runtime.d.ts +1 -0
  76. package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
  77. package/dist/entrypoints/agent-runtime.js +28 -18
  78. package/dist/entrypoints/application/directory-inbox.js +6 -6
  79. package/dist/entrypoints/application.js +1 -1
  80. package/dist/entrypoints/cli/publish.js +2 -2
  81. package/dist/entrypoints/cli.js +8 -8
  82. package/dist/entrypoints/contract.js +1 -1
  83. package/dist/entrypoints/files.js +1 -1
  84. package/dist/entrypoints/http.d.ts +1 -0
  85. package/dist/entrypoints/http.d.ts.map +1 -1
  86. package/dist/entrypoints/http.js +6 -2
  87. package/dist/entrypoints/index.js +20 -411
  88. package/dist/entrypoints/node.js +3 -3
  89. package/dist/entrypoints/observability.js +1 -1
  90. package/dist/entrypoints/process.js +1 -1
  91. package/dist/entrypoints/realtime.d.ts +6 -0
  92. package/dist/entrypoints/realtime.d.ts.map +1 -0
  93. package/dist/entrypoints/realtime.js +25 -0
  94. package/dist/entrypoints/remote.js +1 -1
  95. package/dist/entrypoints/server.js +11 -11
  96. package/dist/entrypoints/telegram/screens.js +9 -9
  97. package/dist/entrypoints/telegram.js +3 -3
  98. package/dist/entrypoints/testing.js +2 -2
  99. package/dist/entrypoints/tools/connections.js +3 -3
  100. package/dist/entrypoints/tools/invoker.js +3 -3
  101. package/dist/entrypoints/tools/mcp.js +4 -4
  102. package/dist/entrypoints/tools.js +26 -24
  103. package/dist/{index-61m15a18.js → index-0d8m0kee.js} +1 -1
  104. package/dist/{index-dmfr2cg5.js → index-2tazbwhv.js} +6 -6
  105. package/dist/{index-c17xcx4k.js → index-56yx8dxp.js} +19 -96
  106. package/dist/{index-0gs4ymfj.js → index-6qeqdz0z.js} +7 -1
  107. package/dist/{index-064zxbwj.js → index-79zxnh52.js} +3 -3
  108. package/dist/{index-2pevnh0x.js → index-7c046kxr.js} +4 -4
  109. package/dist/index-86sxnvpr.js +336 -0
  110. package/dist/{index-jyw90rps.js → index-bm180f2d.js} +204 -84
  111. package/dist/{index-mnhtbqrb.js → index-dd1z5kxb.js} +2 -2
  112. package/dist/{index-7a1xhhdx.js → index-e1sjcjfy.js} +31 -11
  113. package/dist/{index-5p55xreg.js → index-e9rbhw1s.js} +67 -29
  114. package/dist/{index-p6mvqcbq.js → index-ghwntn9n.js} +1 -1
  115. package/dist/index-hqsbtvta.js +92 -0
  116. package/dist/{index-73cz22ds.js → index-mha6b4vk.js} +6 -6
  117. package/dist/index-s2bgwsyr.js +2280 -0
  118. package/dist/{index-fnra8n1j.js → index-s2eybn7b.js} +9 -9
  119. package/dist/{index-njs9gvrh.js → index-s6d8zsha.js} +6 -6
  120. package/dist/index-snef22zr.js +94 -0
  121. package/dist/{index-c0hffcmj.js → index-zbssway3.js} +19 -2
  122. package/dist/process/group-presence.d.ts +3 -0
  123. package/dist/process/group-presence.d.ts.map +1 -0
  124. package/dist/process/group-settlement.d.ts.map +1 -1
  125. package/dist/process/group.d.ts.map +1 -1
  126. package/llms/agent-runtime.3.txt +3 -0
  127. package/llms/agent-runtime.txt +60 -0
  128. package/llms/realtime.txt +31 -0
  129. package/llms/stitchkit.txt +1 -0
  130. package/llms-full.txt +85 -0
  131. package/llms.txt +3 -2
  132. package/package.json +5 -1
  133. package/dist/index-8ks9b85e.js +0 -129
  134. package/dist/index-d2h99n7d.js +0 -1071
  135. package/dist/{index-9j2atjte.js → index-2f9r0jgr.js} +3 -3
  136. package/dist/{index-y70v24cw.js → index-8asb62xn.js} +0 -0
  137. package/dist/{index-k7qdkh3n.js → index-h1spd9kv.js} +3 -3
  138. package/dist/{index-zgwkwr1g.js → index-jk44mbqb.js} +0 -0
  139. package/dist/{index-qd8x73e8.js → index-k8fbzggr.js} +0 -0
  140. package/dist/{index-85qve8mq.js → index-pzw0fpek.js} +0 -0
  141. package/dist/{index-y3nemndz.js → index-r6v4mc67.js} +3 -3
  142. package/dist/{index-ktjmgq9p.js → index-s0xbnpfh.js} +3 -3
@@ -0,0 +1,92 @@
1
+ import {
2
+ ApiError2
3
+ } from "./index-kfjkb396.js";
4
+ import {
5
+ sleep
6
+ } from "./index-eemvahkc.js";
7
+
8
+ // src/browser/chunked-upload.ts
9
+ function isRetryableUploadFailure(error) {
10
+ if (ApiError2.is(error)) {
11
+ if (error.status === 0)
12
+ return error.code === "UNKNOWN_ERROR" || error.code === "REQUEST_TIMEOUT";
13
+ return error.status === 429 || error.status >= 500;
14
+ }
15
+ return error instanceof TypeError;
16
+ }
17
+ async function uploadInChunks2(config) {
18
+ const { file, chunkBytes, signal } = config;
19
+ if (!Number.isSafeInteger(chunkBytes) || chunkBytes <= 0) {
20
+ throw new TypeError("uploadInChunks: chunkBytes must be a positive integer");
21
+ }
22
+ if (!Number.isSafeInteger(file.size) || file.size < 0) {
23
+ throw new TypeError("uploadInChunks: the file size must be a whole number of bytes");
24
+ }
25
+ if (file.size === 0)
26
+ throw new TypeError("uploadInChunks: the file is empty");
27
+ const totalBytes = file.size;
28
+ const chunkCount = Math.ceil(totalBytes / chunkBytes);
29
+ const uploadId = config.uploadId ?? crypto.randomUUID();
30
+ const retries = config.retries ?? 3;
31
+ const retryDelayMs = config.retryDelayMs ?? 1000;
32
+ const report = (sentBytes, index, attempt) => {
33
+ if (!config.onProgress)
34
+ return;
35
+ try {
36
+ config.onProgress({ sentBytes, totalBytes, index, chunkCount, attempt });
37
+ } catch {}
38
+ };
39
+ throwIfAborted(signal);
40
+ const opened = await repeating(() => config.init({ uploadId, totalBytes, chunkBytes, chunkCount }, { signal }), { retries, retryDelayMs, signal });
41
+ if (opened) {
42
+ report(totalBytes, chunkCount, 1);
43
+ return opened.finished;
44
+ }
45
+ report(0, 0, 1);
46
+ for (let index = 0;index < chunkCount; index += 1) {
47
+ throwIfAborted(signal);
48
+ const start = index * chunkBytes;
49
+ const end = Math.min(totalBytes, start + chunkBytes);
50
+ const partBytes = end - start;
51
+ const bytes = file.slice(start, end);
52
+ await repeating((attempt) => config.chunk({ uploadId, index, bytes }, {
53
+ ...signal && { signal },
54
+ onUploadProgress: (progress) => report(start + fileShare(progress, partBytes), index, attempt)
55
+ }), { retries, retryDelayMs, signal });
56
+ report(end, index + 1, 1);
57
+ }
58
+ throwIfAborted(signal);
59
+ return config.finalize({ uploadId }, { signal });
60
+ }
61
+ function fileShare(progress, partBytes) {
62
+ if (progress.totalBytes === 0)
63
+ return 0;
64
+ return Math.floor(partBytes * progress.sentBytes / progress.totalBytes);
65
+ }
66
+ async function repeating(call, {
67
+ retries,
68
+ retryDelayMs,
69
+ signal
70
+ }) {
71
+ for (let attempt = 1;; attempt += 1) {
72
+ try {
73
+ return await call(attempt);
74
+ } catch (error) {
75
+ if (signal?.aborted || attempt > retries || !isRetryableUploadFailure(error))
76
+ throw error;
77
+ try {
78
+ await sleep(retryDelayMs * 2 ** (attempt - 1), signal);
79
+ } catch (aborted) {
80
+ throwIfAborted(signal);
81
+ throw aborted;
82
+ }
83
+ }
84
+ }
85
+ }
86
+ function throwIfAborted(signal) {
87
+ if (signal?.aborted) {
88
+ throw new ApiError2("REQUEST_ABORTED", { status: 0, message: "Request was aborted" });
89
+ }
90
+ }
91
+
92
+ export { uploadInChunks2 };
@@ -10,13 +10,16 @@ import {
10
10
  projectToolView,
11
11
  objectShapeKeys
12
12
  } from "./index-q6crhe1n.js";
13
+ import {
14
+ runWithRequestContext2,
15
+ getRequestContext2
16
+ } from "./index-r6v4mc67.js";
13
17
  import {
14
18
  projectedToolError
15
19
  } from "./index-556g5hsh.js";
16
20
  import {
17
- runWithRequestContext2,
18
- getRequestContext2
19
- } from "./index-y3nemndz.js";
21
+ isUnsafeKey
22
+ } from "./index-zsarb5xp.js";
20
23
  import {
21
24
  formatZodError2
22
25
  } from "./index-1eeqpadm.js";
@@ -26,9 +29,6 @@ import {
26
29
  isRetryableStatus2,
27
30
  isStitchErrorCode2
28
31
  } from "./index-j9gxbztg.js";
29
- import {
30
- isUnsafeKey
31
- } from "./index-zsarb5xp.js";
32
32
  import {
33
33
  isRecord
34
34
  } from "./index-9jfdm5tg.js";