@qvac/harness 0.7.1 → 1.0.0-rc.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 (201) hide show
  1. package/README.md +224 -0
  2. package/dist-lib/index.d.ts +55 -3
  3. package/dist-lib/index.js +721 -236
  4. package/dist-lib/lib/capabilities/completion-engine/abort-polyfill.d.ts +1 -0
  5. package/dist-lib/lib/capabilities/completion-engine/abort-polyfill.js +10 -0
  6. package/dist-lib/lib/capabilities/completion-engine/actors/answering.d.ts +3 -0
  7. package/dist-lib/lib/capabilities/completion-engine/actors/answering.js +17 -0
  8. package/dist-lib/lib/capabilities/completion-engine/actors/approval.d.ts +4 -0
  9. package/dist-lib/lib/capabilities/completion-engine/actors/approval.js +29 -0
  10. package/dist-lib/lib/capabilities/completion-engine/actors/direct-search.d.ts +4 -0
  11. package/dist-lib/lib/capabilities/completion-engine/actors/direct-search.js +73 -0
  12. package/dist-lib/lib/capabilities/completion-engine/actors/execute.d.ts +41 -0
  13. package/dist-lib/lib/capabilities/completion-engine/actors/execute.js +49 -0
  14. package/dist-lib/lib/capabilities/completion-engine/actors/executing.d.ts +3 -0
  15. package/dist-lib/lib/capabilities/completion-engine/actors/executing.js +102 -0
  16. package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.d.ts +47 -0
  17. package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +87 -0
  18. package/dist-lib/lib/capabilities/completion-engine/actors/finishing.d.ts +2 -0
  19. package/dist-lib/lib/capabilities/completion-engine/actors/finishing.js +32 -0
  20. package/dist-lib/lib/capabilities/completion-engine/actors/inspect-preload.d.ts +3 -0
  21. package/dist-lib/lib/capabilities/completion-engine/actors/inspect-preload.js +75 -0
  22. package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.d.ts +3 -0
  23. package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.js +152 -0
  24. package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.d.ts +3 -0
  25. package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.js +94 -0
  26. package/dist-lib/lib/capabilities/completion-engine/actors/preload-failure.d.ts +9 -0
  27. package/dist-lib/lib/capabilities/completion-engine/actors/preload-failure.js +11 -0
  28. package/dist-lib/lib/capabilities/completion-engine/actors/preloading.d.ts +3 -0
  29. package/dist-lib/lib/capabilities/completion-engine/actors/preloading.js +114 -0
  30. package/dist-lib/lib/capabilities/completion-engine/actors/preparing.d.ts +3 -0
  31. package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +198 -0
  32. package/dist-lib/lib/capabilities/completion-engine/actors/rejecting.d.ts +3 -0
  33. package/dist-lib/lib/capabilities/completion-engine/actors/rejecting.js +71 -0
  34. package/dist-lib/lib/capabilities/completion-engine/actors/rejection.d.ts +18 -0
  35. package/dist-lib/lib/capabilities/completion-engine/actors/rejection.js +70 -0
  36. package/dist-lib/lib/capabilities/completion-engine/actors/resolving.d.ts +3 -0
  37. package/dist-lib/lib/capabilities/completion-engine/actors/resolving.js +60 -0
  38. package/dist-lib/lib/capabilities/completion-engine/actors/stream.d.ts +21 -0
  39. package/dist-lib/lib/capabilities/completion-engine/actors/stream.js +48 -0
  40. package/dist-lib/lib/capabilities/completion-engine/actors/streaming.d.ts +3 -0
  41. package/dist-lib/lib/capabilities/completion-engine/actors/streaming.js +156 -0
  42. package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.d.ts +7 -0
  43. package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +61 -0
  44. package/dist-lib/lib/capabilities/completion-engine/driver.d.ts +25 -0
  45. package/dist-lib/lib/capabilities/completion-engine/driver.js +553 -0
  46. package/dist-lib/lib/capabilities/completion-engine/durable.d.ts +61 -0
  47. package/dist-lib/lib/capabilities/completion-engine/durable.js +150 -0
  48. package/dist-lib/lib/capabilities/completion-engine/operations.d.ts +6 -0
  49. package/dist-lib/lib/capabilities/completion-engine/operations.js +239 -0
  50. package/dist-lib/lib/capabilities/completion-engine/ports.d.ts +3 -0
  51. package/dist-lib/lib/capabilities/completion-engine/ports.js +267 -0
  52. package/dist-lib/lib/capabilities/completion-engine/session.d.ts +76 -0
  53. package/dist-lib/lib/capabilities/completion-engine/session.js +70 -0
  54. package/dist-lib/lib/capabilities/completion-loop/index.d.ts +80 -0
  55. package/dist-lib/lib/capabilities/completion-loop/index.js +158 -0
  56. package/dist-lib/lib/capabilities/completion-loop/metrics.d.ts +5 -0
  57. package/dist-lib/lib/capabilities/completion-loop/metrics.js +29 -0
  58. package/dist-lib/lib/capabilities/completion-loop/round.d.ts +33 -0
  59. package/dist-lib/lib/capabilities/completion-loop/round.js +353 -0
  60. package/dist-lib/lib/capabilities/completion-loop/tool-execution.d.ts +60 -0
  61. package/dist-lib/lib/capabilities/completion-loop/tool-execution.js +270 -0
  62. package/dist-lib/lib/capabilities/completion-loop/turns.d.ts +23 -0
  63. package/dist-lib/lib/capabilities/completion-loop/turns.js +112 -0
  64. package/dist-lib/lib/capabilities/completion-runtime.d.ts +46 -0
  65. package/dist-lib/lib/capabilities/completion-runtime.js +74 -0
  66. package/dist-lib/lib/capabilities/completion.d.ts +18 -335
  67. package/dist-lib/lib/capabilities/completion.js +20 -1301
  68. package/dist-lib/lib/capabilities/download.d.ts +1 -1
  69. package/dist-lib/lib/capabilities/download.js +7 -2
  70. package/dist-lib/lib/capabilities/invoke.js +5 -3
  71. package/dist-lib/lib/capabilities/tool-plan.d.ts +35 -0
  72. package/dist-lib/lib/capabilities/tool-plan.js +66 -0
  73. package/dist-lib/lib/capabilities/tool-turns.d.ts +11 -2
  74. package/dist-lib/lib/capabilities/tool-turns.js +30 -2
  75. package/dist-lib/lib/capabilities/types.d.ts +287 -0
  76. package/dist-lib/lib/capabilities/types.js +1 -0
  77. package/dist-lib/lib/completion-lifecycle.d.ts +14 -0
  78. package/dist-lib/lib/completion-lifecycle.js +126 -0
  79. package/dist-lib/lib/connect.d.ts +10 -3
  80. package/dist-lib/lib/connect.js +329 -23
  81. package/dist-lib/lib/contract-types.d.ts +19 -2
  82. package/dist-lib/lib/harness-lifecycle.d.ts +66 -0
  83. package/dist-lib/lib/harness-lifecycle.js +129 -0
  84. package/dist-lib/lib/helpers/detach-json.d.ts +1 -0
  85. package/dist-lib/lib/helpers/detach-json.js +146 -0
  86. package/dist-lib/lib/helpers/markup-scanner.d.ts +26 -0
  87. package/dist-lib/lib/helpers/markup-scanner.js +156 -0
  88. package/dist-lib/lib/helpers/markup-stream-filter.js +138 -35
  89. package/dist-lib/lib/helpers/race-abort.d.ts +9 -4
  90. package/dist-lib/lib/helpers/race-abort.js +2 -7
  91. package/dist-lib/lib/helpers/recovery-required.d.ts +1 -0
  92. package/dist-lib/lib/helpers/recovery-required.js +1 -0
  93. package/dist-lib/lib/helpers/run-outcome.d.ts +10 -2
  94. package/dist-lib/lib/helpers/run-outcome.js +8 -5
  95. package/dist-lib/lib/helpers/tool-call-markup.d.ts +2 -0
  96. package/dist-lib/lib/helpers/tool-call-markup.js +197 -82
  97. package/dist-lib/lib/hooks/built-in/arg-repair.d.ts +1 -0
  98. package/dist-lib/lib/hooks/built-in/arg-repair.js +1 -0
  99. package/dist-lib/lib/hooks/built-in/egress.d.ts +1 -0
  100. package/dist-lib/lib/hooks/built-in/egress.js +2 -1
  101. package/dist-lib/lib/hooks/built-in/sandbox.d.ts +1 -0
  102. package/dist-lib/lib/hooks/built-in/sandbox.js +6 -1
  103. package/dist-lib/lib/hooks/built-in/skill-catalog.d.ts +1 -0
  104. package/dist-lib/lib/hooks/built-in/skill-catalog.js +2 -1
  105. package/dist-lib/lib/hooks/pipeline.d.ts +4 -1
  106. package/dist-lib/lib/hooks/pipeline.js +24 -2
  107. package/dist-lib/lib/hooks/run.d.ts +2 -1
  108. package/dist-lib/lib/hooks/run.js +19 -7
  109. package/dist-lib/lib/hooks/types.d.ts +17 -6
  110. package/dist-lib/lib/machine/completion/actions/approval.d.ts +3 -0
  111. package/dist-lib/lib/machine/completion/actions/approval.js +16 -0
  112. package/dist-lib/lib/machine/completion/actions/completion.d.ts +23 -0
  113. package/dist-lib/lib/machine/completion/actions/completion.js +142 -0
  114. package/dist-lib/lib/machine/completion/actions/skills.d.ts +9 -0
  115. package/dist-lib/lib/machine/completion/actions/skills.js +83 -0
  116. package/dist-lib/lib/machine/completion/actions/tools.d.ts +16 -0
  117. package/dist-lib/lib/machine/completion/actions/tools.js +173 -0
  118. package/dist-lib/lib/machine/completion/context.d.ts +9 -0
  119. package/dist-lib/lib/machine/completion/context.js +44 -0
  120. package/dist-lib/lib/machine/completion/contract.d.ts +6 -0
  121. package/dist-lib/lib/machine/completion/contract.js +1 -0
  122. package/dist-lib/lib/machine/completion/guards/retry.d.ts +9 -0
  123. package/dist-lib/lib/machine/completion/guards/retry.js +25 -0
  124. package/dist-lib/lib/machine/completion/implementations.d.ts +81 -0
  125. package/dist-lib/lib/machine/completion/implementations.js +152 -0
  126. package/dist-lib/lib/machine/completion/machine.d.ts +375 -0
  127. package/dist-lib/lib/machine/completion/machine.js +511 -0
  128. package/dist-lib/lib/machine/completion/ports.d.ts +65 -0
  129. package/dist-lib/lib/machine/completion/ports.js +224 -0
  130. package/dist-lib/lib/machine/completion/rules.d.ts +39 -0
  131. package/dist-lib/lib/machine/completion/rules.js +115 -0
  132. package/dist-lib/lib/machine/completion/types.d.ts +493 -0
  133. package/dist-lib/lib/machine/completion/types.js +1 -0
  134. package/dist-lib/lib/machine/engine.d.ts +93 -0
  135. package/dist-lib/lib/machine/engine.js +483 -0
  136. package/dist-lib/lib/machine/errors.d.ts +44 -0
  137. package/dist-lib/lib/machine/errors.js +373 -0
  138. package/dist-lib/lib/machine/guards.d.ts +2 -0
  139. package/dist-lib/lib/machine/guards.js +6 -0
  140. package/dist-lib/lib/machine/index.d.ts +20 -0
  141. package/dist-lib/lib/machine/index.js +11 -0
  142. package/dist-lib/lib/machine/replay-output.d.ts +24 -0
  143. package/dist-lib/lib/machine/replay-output.js +50 -0
  144. package/dist-lib/lib/machine/stable-stringify.d.ts +1 -0
  145. package/dist-lib/lib/machine/stable-stringify.js +11 -0
  146. package/dist-lib/lib/models/model-pool.d.ts +14 -6
  147. package/dist-lib/lib/models/model-pool.js +95 -30
  148. package/dist-lib/lib/run-log/history-codec.d.ts +23 -0
  149. package/dist-lib/lib/run-log/history-codec.js +973 -0
  150. package/dist-lib/lib/run-log/patch.d.ts +6 -0
  151. package/dist-lib/lib/run-log/patch.js +93 -0
  152. package/dist-lib/lib/run-log/persisted-actor.d.ts +18 -0
  153. package/dist-lib/lib/run-log/persisted-actor.js +218 -0
  154. package/dist-lib/lib/run-log/protocol-types.d.ts +153 -0
  155. package/dist-lib/lib/run-log/protocol-types.js +1 -0
  156. package/dist-lib/lib/run-log/protocol.d.ts +27 -0
  157. package/dist-lib/lib/run-log/protocol.js +1056 -0
  158. package/dist-lib/lib/run-log/replay.d.ts +25 -0
  159. package/dist-lib/lib/run-log/replay.js +129 -0
  160. package/dist-lib/lib/run-log/run-journal.d.ts +125 -0
  161. package/dist-lib/lib/run-log/run-journal.js +783 -0
  162. package/dist-lib/lib/run-log-inspect.d.ts +25 -0
  163. package/dist-lib/lib/run-log-inspect.js +627 -0
  164. package/dist-lib/lib/run-log-protocol.d.ts +2 -0
  165. package/dist-lib/lib/run-log-protocol.js +1 -0
  166. package/dist-lib/lib/run-log-redact.d.ts +27 -0
  167. package/dist-lib/lib/run-log-redact.js +1107 -0
  168. package/dist-lib/lib/serve.js +307 -11
  169. package/dist-lib/lib/spawn.js +3 -2
  170. package/dist-lib/lib/tool-call-display.d.ts +1 -21
  171. package/dist-lib/lib/tools/exec/adapters/python/wheels.js +2 -1
  172. package/dist-lib/lib/tools/exec.d.ts +2 -1
  173. package/dist-lib/lib/tools/exec.js +57 -2
  174. package/dist-lib/lib/tools/generate-image.js +1 -1
  175. package/dist-lib/lib/tools/generate-music.js +1 -1
  176. package/dist-lib/lib/tools/http-request.d.ts +2 -1
  177. package/dist-lib/lib/tools/http-request.js +2 -1
  178. package/dist-lib/lib/tools/mcp-call.js +8 -1
  179. package/dist-lib/lib/tools/operations/builders.d.ts +1 -0
  180. package/dist-lib/lib/tools/operations/builders.js +1 -0
  181. package/dist-lib/lib/tools/operations/compile.js +11 -1
  182. package/dist-lib/lib/tools/operations/manifest.js +1 -0
  183. package/dist-lib/lib/tools/outbound-guard.d.ts +8 -6
  184. package/dist-lib/lib/tools/outbound-guard.js +25 -8
  185. package/dist-lib/lib/tools/skills/catalog.d.ts +1 -0
  186. package/dist-lib/lib/tools/skills/catalog.js +35 -0
  187. package/dist-lib/lib/tools/skills/cli-schema-types.d.ts +1 -0
  188. package/dist-lib/lib/tools/skills/cli-schema.js +25 -0
  189. package/dist-lib/lib/wire.d.ts +5 -0
  190. package/dist-lib/lib/wire.js +128 -5
  191. package/dist-lib/schema/harness.js +20 -5
  192. package/dist-lib/spec/hrpc/messages.js +95 -15
  193. package/dist-lib/spec/hyperschema/index.js +95 -15
  194. package/dist-lib/spec/hyperschema/schema.json +69 -1
  195. package/dist-lib/spec/hyperschema/types.d.ts +10 -3
  196. package/package.json +20 -2
  197. package/patches/@qvac%2Finference@0.20.0.patch +67 -0
  198. package/patches/bare-stow@0.1.5.patch +68 -0
  199. package/patches/hypercore-blob-server@1.15.0.patch +15 -0
  200. package/patches/localwatch@1.4.3.patch +13 -0
  201. package/patches/pyodide@314.0.2.patch +144 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qvac/harness",
3
- "version": "0.7.1",
3
+ "version": "1.0.0-rc.1",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "bare": ">=1.34.0"
@@ -23,6 +23,14 @@
23
23
  "types": "./dist-lib/lib/dns-lookup.d.ts",
24
24
  "default": "./dist-lib/lib/dns-lookup.js"
25
25
  },
26
+ "./lib/connect.ts": {
27
+ "types": "./dist-lib/lib/connect.d.ts",
28
+ "default": "./dist-lib/lib/connect.js"
29
+ },
30
+ "./lib/contract-types.ts": {
31
+ "types": "./dist-lib/lib/contract-types.d.ts",
32
+ "default": "./dist-lib/lib/contract-types.js"
33
+ },
26
34
  "./lib/helpers/race-abort.ts": {
27
35
  "types": "./dist-lib/lib/helpers/race-abort.d.ts",
28
36
  "default": "./dist-lib/lib/helpers/race-abort.js"
@@ -155,6 +163,14 @@
155
163
  "types": "./dist-lib/lib/sdk-storage.d.ts",
156
164
  "default": "./dist-lib/lib/sdk-storage.js"
157
165
  },
166
+ "./run-log": {
167
+ "types": "./dist-lib/lib/run-log-protocol.d.ts",
168
+ "default": "./dist-lib/lib/run-log-protocol.js"
169
+ },
170
+ "./run-log-inspect": {
171
+ "types": "./dist-lib/lib/run-log-inspect.d.ts",
172
+ "default": "./dist-lib/lib/run-log-inspect.js"
173
+ },
158
174
  "./model-progress": {
159
175
  "types": "./dist-lib/lib/model-download-progress.d.ts",
160
176
  "default": "./dist-lib/lib/model-download-progress.js"
@@ -619,6 +635,7 @@
619
635
  "build:schema": "bare schema/build.ts",
620
636
  "test": "npm run vendor:wheels && npm run test:bare && npm run test:addons",
621
637
  "test:bare": "QVAC_NO_SKILL_BIN_PROBE=1 brittle-jobs 'test/{,!(helpers)/}*.ts'",
638
+ "machine:graph": "bun scripts/generate-completion-graph.ts",
622
639
  "format": "prettier . --write",
623
640
  "lint": "prettier . --check && lunte && tsc --noEmit",
624
641
  "build:bundle": "node scripts/build-bundle.mjs",
@@ -692,7 +709,7 @@
692
709
  },
693
710
  "#pyodide-worker-entry": "./dist-lib/lib/tools/exec/adapters/python/worker/entry.js",
694
711
  "#pyodide-interrupt-deadline": "./dist-lib/lib/tools/exec/adapters/python/worker/interrupt-deadline.js",
695
- "#pyodide-wheels": "./wheels/",
712
+ "#pyodide-wheels": "./wheels/manifest.json",
696
713
  "worker_threads": {
697
714
  "bare": "bare-worker"
698
715
  },
@@ -765,6 +782,7 @@
765
782
  "streamx": "^2.28.0",
766
783
  "watch-drive": "^2.0.3",
767
784
  "which-runtime": "^1.4.0",
785
+ "xstate": "~5.33.1",
768
786
  "zod": "^4.3.6"
769
787
  },
770
788
  "devDependencies": {
@@ -0,0 +1,67 @@
1
+ diff --git a/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.js b/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.js
2
+ index 9eab782f56a8cf18065470a17d2d82a9d123bec8..3439075affeded6d818286a67bb296da3b60a605 100644
3
+ --- a/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.js
4
+ +++ b/dist/plugins/builtin/llamacpp-completion/ops/completion-stream.js
5
+ @@ -267,7 +267,10 @@ export async function* completion(params, opts) {
6
+ const transformedHistory = transformMessages(historyWithTools);
7
+ logCacheDisabled();
8
+ logMessagesToAddon(transformedHistory, 'NO_CACHE');
9
+ - return yield* processModelResponse(model, transformedHistory, tools, mergedGenerationParams, undefined, dialect, setActiveResponse);
10
+ + // qvac-app patch: see the PROMPT_SEND path below
11
+ + const uncached = yield* processModelResponse(model, transformedHistory, tools, mergedGenerationParams, undefined, dialect, setActiveResponse);
12
+ + if (uncached?.stats) uncached.stats.sentMessages = transformedHistory;
13
+ + return uncached;
14
+ }
15
+ // ---- KV-cache path. The session owns every bookkeeping layer; the handler
16
+ // registers one deferred unwind that `commitTurn` short-circuits on the happy
17
+ @@ -340,6 +343,9 @@ export async function* completion(params, opts) {
18
+ preserveCacheOnUnwind = !addonRunSettled;
19
+ throw error;
20
+ }
21
+ + // qvac-app patch: the messages the cache slice actually pushed, for the prompt inspector.
22
+ + // Rides the call's own result, so it needs no correlation back to the request.
23
+ + if (result?.stats) result.stats.sentMessages = messagesToSend;
24
+ const shouldCommitTurn = shouldCommitCachedTurn({
25
+ aborted: signal.aborted,
26
+ producedTokens: result.producedTokens,
27
+ diff --git a/dist/schemas/completion-event.d.ts b/dist/schemas/completion-event.d.ts
28
+ index 535792ffeedc7f8bcd8fec53b9c9486a76e935e0..737c14b11ed7c2a13d612fae1cd06f7655e84870 100644
29
+ --- a/dist/schemas/completion-event.d.ts
30
+ +++ b/dist/schemas/completion-event.d.ts
31
+ @@ -5,6 +5,7 @@ export declare const completionStatsSchema: z.ZodObject<{
32
+ timeToFirstToken: z.ZodOptional<z.ZodNumber>;
33
+ tokensPerSecond: z.ZodOptional<z.ZodNumber>;
34
+ promptTokensPerSecond: z.ZodOptional<z.ZodNumber>;
35
+ + sentMessages: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
36
+ cacheTokens: z.ZodOptional<z.ZodNumber>;
37
+ promptTokens: z.ZodOptional<z.ZodNumber>;
38
+ generatedTokens: z.ZodOptional<z.ZodNumber>;
39
+ @@ -63,6 +64,7 @@ export declare const statsEventSchema: z.ZodObject<{
40
+ timeToFirstToken: z.ZodOptional<z.ZodNumber>;
41
+ tokensPerSecond: z.ZodOptional<z.ZodNumber>;
42
+ promptTokensPerSecond: z.ZodOptional<z.ZodNumber>;
43
+ + sentMessages: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
44
+ cacheTokens: z.ZodOptional<z.ZodNumber>;
45
+ promptTokens: z.ZodOptional<z.ZodNumber>;
46
+ generatedTokens: z.ZodOptional<z.ZodNumber>;
47
+ @@ -147,6 +149,7 @@ export declare const completionEventSchema: z.ZodUnion<readonly [z.ZodObject<{
48
+ timeToFirstToken: z.ZodOptional<z.ZodNumber>;
49
+ tokensPerSecond: z.ZodOptional<z.ZodNumber>;
50
+ promptTokensPerSecond: z.ZodOptional<z.ZodNumber>;
51
+ + sentMessages: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
52
+ cacheTokens: z.ZodOptional<z.ZodNumber>;
53
+ promptTokens: z.ZodOptional<z.ZodNumber>;
54
+ generatedTokens: z.ZodOptional<z.ZodNumber>;
55
+ diff --git a/dist/schemas/completion-event.js b/dist/schemas/completion-event.js
56
+ index 1ef0d68a9a8cf6f590988272e114ac54ea093614..1d110710d476eed33ed5118f6f32f605f8ea5be8 100644
57
+ --- a/dist/schemas/completion-event.js
58
+ +++ b/dist/schemas/completion-event.js
59
+ @@ -4,6 +4,8 @@ export const completionStatsSchema = z.object({
60
+ timeToFirstToken: z.number().optional(),
61
+ tokensPerSecond: z.number().optional(),
62
+ promptTokensPerSecond: z.number().optional(),
63
+ + // qvac-harness patch: the post-cache messages the SDK pushed to the addon
64
+ + sentMessages: z.array(z.unknown()).optional(),
65
+ cacheTokens: z.number().optional(),
66
+ promptTokens: z.number().optional(),
67
+ // Decode count (`llama_perf` `n_eval`) — length / KV-cache budget decisions.
@@ -0,0 +1,68 @@
1
+ diff --git a/lib/host.d.ts b/lib/host.d.ts
2
+ index dacda847a9efbeab6991bbd7adf3ee644aad1523..82d3a1e11cef3c449ec00e2dc11908ed081f0aed 100644
3
+ --- a/lib/host.d.ts
4
+ +++ b/lib/host.d.ts
5
+ @@ -12,8 +12,4 @@ declare class IPC {
6
+
7
+ declare function wrap(stream: Duplex): IPC
8
+
9
+ -declare namespace wrap {
10
+ - export { IPC }
11
+ -}
12
+ -
13
+ -export = wrap
14
+ +export { type IPC, wrap }
15
+ diff --git a/lib/host.js b/lib/host.js
16
+ index 7e62e044374ffa5db7dd3f8bd231e8cd0b973d70..1233405a9e437c6ff1b28a7db968b65dc8f6cd58 100644
17
+ --- a/lib/host.js
18
+ +++ b/lib/host.js
19
+ @@ -5,17 +5,27 @@ class IPC extends Protocol {
20
+ super(stream)
21
+
22
+ this._ready = new Promise((resolve, reject) => {
23
+ + const cleanup = () => {
24
+ + this.off('ready', onready)
25
+ + .off('error', onerror)
26
+ + .off('close', onclose)
27
+ + .off('exit', onexit)
28
+ + }
29
+ +
30
+ const onready = () => {
31
+ - this.off('ready', onready).off('error', onerror)
32
+ + cleanup()
33
+ resolve()
34
+ }
35
+
36
+ const onerror = (err) => {
37
+ - this.off('ready', onready).off('error', onerror)
38
+ + cleanup()
39
+ reject(err)
40
+ }
41
+
42
+ - this.on('ready', onready).on('error', onerror)
43
+ + const onclose = () => onerror(new Error('Worker IPC closed before ready'))
44
+ + const onexit = (code) => onerror(new Error(`Worker exited (${code}) before ready`))
45
+ +
46
+ + this.on('ready', onready).on('error', onerror).on('close', onclose).on('exit', onexit)
47
+ })
48
+
49
+ this._ready.catch(() => {})
50
+ @@ -50,8 +60,16 @@ class IPC extends Protocol {
51
+ _destroy(err, cb) {
52
+ if (this._stream.destroyed) return cb(null)
53
+
54
+ - this.send('terminate')
55
+ - this._stream.once('close', () => cb(null))
56
+ + let finished = false
57
+ + const finish = () => {
58
+ + if (finished) return
59
+ + finished = true
60
+ + if (!this._stream.destroyed) this._stream.destroy()
61
+ + cb(null)
62
+ + }
63
+ +
64
+ + this.send('terminate').then(finish, finish)
65
+ + this._stream.once('close', finish)
66
+ }
67
+ }
68
+
@@ -0,0 +1,15 @@
1
+ diff --git a/index.js b/index.js
2
+ index b69385ddadfa23e5fe1bbdbe8e2c92a6c2d65e97..a230bae8496fca54c476f2810a6e985377dc3d12 100644
3
+ --- a/index.js
4
+ +++ b/index.js
5
+ @@ -478,7 +478,9 @@ module.exports = class HypercoreBlobServer {
6
+ if (this.listening) await this.listening
7
+ if (this.resuming) await this.resuming
8
+ this.resuming = null
9
+ - await this._closeAll(false)
10
+ + // _closeAll(false) drops the server reference without closing the socket, so the
11
+ + // orphan keeps the port and resume rebinds elsewhere, invalidating every link
12
+ + await this._closeAll(true)
13
+ }
14
+
15
+ resume () {
@@ -0,0 +1,13 @@
1
+ diff --git a/index.js b/index.js
2
+ index 385cd0ec3ebc88c0394d25056e4872f43a3b78ca..4fecd4b6bbb7b2d9568b2355dea8c5e3bbe9af03 100644
3
+ --- a/index.js
4
+ +++ b/index.js
5
+ @@ -58,7 +58,7 @@ class TreeEntry {
6
+ for (const [entryFilename, node] of this.list(filename)) {
7
+ if (node.watcher) node.watcher.close()
8
+ node.watcher = null
9
+ - if (node.entries || node.stat.isDirectory()) continue
10
+ + if (node.entries || node.stat?.isDirectory()) continue
11
+ if (!node.ignore) diff.push({ type: 'delete', filename: entryFilename })
12
+ }
13
+ this.entries = null
@@ -0,0 +1,144 @@
1
+ diff --git a/node_modules/pyodide/.bun-tag-92a0f2d2814ec5f7 b/.bun-tag-92a0f2d2814ec5f7
2
+ new file mode 100644
3
+ index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
4
+ diff --git a/node_modules/pyodide/.bun-tag-eaec348535ef2447 b/.bun-tag-eaec348535ef2447
5
+ new file mode 100644
6
+ index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
7
+ diff --git a/node_modules/pyodide/child-process-stub.cjs b/child-process-stub.cjs
8
+ new file mode 100644
9
+ index 0000000000000000000000000000000000000000..80e5c648355e432f4752fe92b384fbf287bdfedb
10
+ --- /dev/null
11
+ +++ b/child-process-stub.cjs
12
+ @@ -0,0 +1,9 @@
13
+ +// Pyodide puts this in the globalThis.require map it hands to the interpreter;
14
+ +// the real module would give in-interpreter Python code subprocess spawn.
15
+ +// spawnSync fails soft (127, command not found) rather than being absent: a
16
+ +// throw out of __emscripten_system is a fatal Pyodide error that bricks the
17
+ +// interpreter for the rest of the process, so os.system must get an error
18
+ +// status back, never an exception.
19
+ +module.exports = {
20
+ + spawnSync: () => ({ status: 127, signal: null })
21
+ +}
22
+ diff --git a/node_modules/pyodide/module-stub.cjs b/module-stub.cjs
23
+ new file mode 100644
24
+ index 0000000000000000000000000000000000000000..5faa9356939a2c5a4c7cb17f63adb1641eddc9b7
25
+ --- /dev/null
26
+ +++ b/module-stub.cjs
27
+ @@ -0,0 +1,22 @@
28
+ +// Emscripten's Node glue loads these through createRequire(import.meta.url).
29
+ +// bare-module's createRequire reads them off disk, which a Bare >= 1.33 thread
30
+ +// cannot, so each is required here, in sight of whatever bundles the graph.
31
+ +const modules = {
32
+ + 'node:child_process': () => require('node:child_process'),
33
+ + 'node:crypto': () => require('node:crypto'),
34
+ + 'node:fs': () => require('node:fs'),
35
+ + 'node:fs/promises': () => require('node:fs/promises'),
36
+ + 'node:net': () => require('node:net'),
37
+ + 'node:path': () => require('node:path'),
38
+ + 'node:stream': () => require('node:stream'),
39
+ + 'node:tls': () => require('node:tls'),
40
+ + 'node:tty': () => require('node:tty'),
41
+ + 'node:url': () => require('node:url'),
42
+ + 'node:vm': () => require('node:vm'),
43
+ + ws: () => require('ws')
44
+ +}
45
+ +
46
+ +exports.createRequire = () => (name) => {
47
+ + if (name in modules) return modules[name]()
48
+ + throw new Error(`Cannot find module '${name}'`)
49
+ +}
50
+ diff --git a/package.json b/package.json
51
+ index 96dd5878bc375dae28e8fe61489c522a8ccb70a6..0596466e27b01c4f03ddb8a7b8abcef611a8c3b1 100644
52
+ --- a/package.json
53
+ +++ b/package.json
54
+ @@ -121,5 +121,59 @@
55
+ "types": "./pyodide.d.ts",
56
+ "engines": {
57
+ "node": ">=18.0.0"
58
+ + },
59
+ + "imports": {
60
+ + "node:url": {
61
+ + "bare": "bare-url",
62
+ + "default": "node:url"
63
+ + },
64
+ + "node:fs": {
65
+ + "bare": "bare-fs",
66
+ + "default": "node:fs"
67
+ + },
68
+ + "node:fs/promises": {
69
+ + "bare": "bare-fs/promises",
70
+ + "default": "node:fs/promises"
71
+ + },
72
+ + "node:path": {
73
+ + "bare": "bare-path",
74
+ + "default": "node:path"
75
+ + },
76
+ + "node:crypto": {
77
+ + "bare": "bare-crypto",
78
+ + "default": "node:crypto"
79
+ + },
80
+ + "node:child_process": {
81
+ + "bare": "./child-process-stub.cjs",
82
+ + "default": "./child-process-stub.cjs"
83
+ + },
84
+ + "node:module": {
85
+ + "bare": "./module-stub.cjs",
86
+ + "default": "node:module"
87
+ + },
88
+ + "node:tty": {
89
+ + "bare": "./tty-stub.cjs",
90
+ + "default": "node:tty"
91
+ + },
92
+ + "node:net": {
93
+ + "bare": "bare-net",
94
+ + "default": "node:net"
95
+ + },
96
+ + "node:tls": {
97
+ + "bare": "bare-tls",
98
+ + "default": "node:tls"
99
+ + },
100
+ + "node:stream": {
101
+ + "bare": "bare-stream",
102
+ + "default": "node:stream"
103
+ + },
104
+ + "node:vm": {
105
+ + "bare": "./vm-stub.cjs",
106
+ + "default": "node:vm"
107
+ + },
108
+ + "ws": {
109
+ + "bare": "./ws-stub.cjs",
110
+ + "default": "./ws-stub.cjs"
111
+ + }
112
+ }
113
+ }
114
+ diff --git a/node_modules/pyodide/tty-stub.cjs b/tty-stub.cjs
115
+ new file mode 100644
116
+ index 0000000000000000000000000000000000000000..9d76ff4984bb153f6eca45d215cecdad610283a2
117
+ --- /dev/null
118
+ +++ b/tty-stub.cjs
119
+ @@ -0,0 +1,7 @@
120
+ +// Pyodide only needs isatty() for stdin/stdout shape detection. Headless
121
+ +// python-pptx runs never have a TTY; return false so the Node writer path
122
+ +// does not require bare-tty (which bare-pack often ships as a prebuild-only
123
+ +// shell that cannot be resolved from a deferred import).
124
+ +module.exports = {
125
+ + isatty: () => false
126
+ +}
127
+ diff --git a/node_modules/pyodide/vm-stub.cjs b/vm-stub.cjs
128
+ new file mode 100644
129
+ index 0000000000000000000000000000000000000000..daf730b0788fe050e844b737eb5b3a6337ccb26c
130
+ --- /dev/null
131
+ +++ b/vm-stub.cjs
132
+ @@ -0,0 +1,2 @@
133
+ +// Bare has no vm; Pyodide imports node:vm but never uses the result.
134
+ +module.exports = {}
135
+ diff --git a/node_modules/pyodide/ws-stub.cjs b/ws-stub.cjs
136
+ new file mode 100644
137
+ index 0000000000000000000000000000000000000000..b376ec679ec769c3e6951acf5ddf15227acbdb89
138
+ --- /dev/null
139
+ +++ b/ws-stub.cjs
140
+ @@ -0,0 +1,4 @@
141
+ +// Pyodide imports this into the globalThis.require map it hands to the
142
+ +// interpreter but never calls into it; upstream itself maps "ws": false for
143
+ +// browsers. Stubbed to close the outbound network path.
144
+ +module.exports = {}