@henols/vice-mcp 0.2.2 → 0.2.3

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 (77) hide show
  1. package/README.md +2 -2
  2. package/THIRD-PARTY-NOTICES.md +422 -1
  3. package/anno-bank.ts +171 -0
  4. package/anno-cli.ts +1674 -99
  5. package/anno-enum-gen.ts +416 -30
  6. package/anno-export-asm.ts +1175 -89
  7. package/anno-graphics.ts +338 -0
  8. package/anno-hazard-report.ts +1367 -0
  9. package/anno-import.ts +495 -0
  10. package/anno-join.ts +480 -0
  11. package/anno-provenance-ledger.ts +472 -0
  12. package/anno-register.ts +159 -0
  13. package/anno-store-export.ts +661 -0
  14. package/anno-store.ts +518 -2
  15. package/anno-tools.ts +1169 -16
  16. package/anno-types.ts +275 -2
  17. package/backend-detect.mts +124 -312
  18. package/build.ts +3 -1
  19. package/capture-predicate.ts +597 -0
  20. package/channel-lock.ts +349 -0
  21. package/evid-ingest.ts +217 -0
  22. package/evid-reconcile.ts +316 -0
  23. package/host-tool-client.ts +430 -0
  24. package/incident-record.ts +23 -12
  25. package/install-resources.ts +29 -13
  26. package/memmap-lookup.ts +285 -0
  27. package/package.json +27 -8
  28. package/prg-image.ts +1 -2
  29. package/repo-root.ts +87 -3
  30. package/resources/backend-detect.mjs +98 -236
  31. package/resources/broker-control.mjs +189 -16
  32. package/resources/broker-epoch.mjs +1 -1
  33. package/resources/broker-kill.mjs +8 -2
  34. package/resources/broker-launch.mjs +365 -210
  35. package/resources/broker-state.mjs +64 -18
  36. package/resources/container-guard.mjs +1 -1
  37. package/resources/ghidra-project.mjs +790 -0
  38. package/resources/host-tool.mjs +2561 -0
  39. package/resources/vice-broker.mjs +330 -184
  40. package/resources/vice-launcher.sh +127 -9
  41. package/stock-address.ts +1 -1
  42. package/stock-condition.ts +1 -1
  43. package/stock-connect.ts +9 -5
  44. package/stock-derived.ts +29 -37
  45. package/stock-diagnose.ts +200 -36
  46. package/stock-dispatch.ts +179 -77
  47. package/stock-handler.ts +1 -1
  48. package/stock-paths.ts +18 -14
  49. package/stock-petscii.ts +1 -1
  50. package/stock-protocol.ts +1 -1
  51. package/stock-recycle.ts +83 -2
  52. package/stock-reproducible-run.ts +811 -0
  53. package/stock-run-until.ts +100 -1
  54. package/stock-symbols.ts +4 -4
  55. package/stock-timing.ts +1 -1
  56. package/stop-oracle.ts +167 -0
  57. package/text-capability-probe.ts +660 -0
  58. package/text-connect.ts +157 -0
  59. package/text-protocol.ts +810 -0
  60. package/text-tools.ts +778 -0
  61. package/textmon-backtrace.ts +385 -0
  62. package/textmon-cpuhistory.ts +335 -0
  63. package/textmon-memmap.ts +494 -0
  64. package/textmon-profile.ts +458 -0
  65. package/textmon-registers.ts +748 -0
  66. package/tools-manifest.stock.json +864 -3
  67. package/vice-broker-client.ts +189 -42
  68. package/vice-errors.ts +268 -0
  69. package/vice-proxy.ts +339 -2144
  70. package/vsf-slice.ts +640 -0
  71. package/anno-d64.ts +0 -310
  72. package/capability-registry.ts +0 -390
  73. package/refresh-manifest.ts +0 -124
  74. package/tools-manifest.json +0 -1223
  75. package/vice-probe.ts +0 -278
  76. package/vice-sync.ts +0 -336
  77. package/vice.ts +0 -772
@@ -2,17 +2,41 @@
2
2
  // Compiled by `tsc` from broker-state.mts. Edit the TypeScript source and rebuild;
3
3
  // changes made directly to this file are silently overwritten by the next build, and are never
4
4
  // deployed to the host on their own -- install-resources.mjs copies THIS file's on-disk contents
5
- // verbatim to tools/, so an edit made only here reaches the host but is lost on the very next
5
+ // verbatim to .c64-re-tools/bin/, so an edit made only here reaches the host but is lost on the very next
6
6
  // rebuild.
7
7
  import { createServer } from "node:net";
8
- /** Clears `monitorClient` as a side effect of release, recycle, or the
9
- * instance's own process exit (see InstanceRecord.monitorClient's own header
10
- * comment for the three call sites) -- so a dead or torn-down client can
11
- * never hold this lock forever. A no-op when no monitor client is currently
12
- * recorded (idempotent, matching monitor_release's own tolerance for an
13
- * already-cleared record). */
14
- export function clearMonitorClient(record) {
15
- record.monitorClient = undefined;
8
+ // ---------------------------------------------------------------------------
9
+ // MonitorChannel (plan 41-03, D-14): exactly two channels exist -- stock VICE
10
+ // exposes precisely the binary monitor and the `-remotemonitor` text
11
+ // channel -- and this project has no plan to add a third. Frozen so a
12
+ // consumer cannot accidentally push a third value onto it at runtime.
13
+ //
14
+ // Declared here a SECOND time in channel-lock.ts (and a third time, as a
15
+ // local literal union, in vice-broker-client.ts) rather than imported from a
16
+ // single shared home: channel-lock.ts is a container-side module and this
17
+ // module is host-bound and compiled into resources/*.mjs, so neither can
18
+ // import the other at runtime. The shared thing between the declarations is
19
+ // the two-value CONTRACT ("binary" | "text"), not the declaration itself.
20
+ // ---------------------------------------------------------------------------
21
+ export const MONITOR_CHANNELS = Object.freeze(["binary", "text"]);
22
+ /** Clears ONE channel's entry when `channel` is passed (an explicit
23
+ * `monitor_release` for that channel), or EVERY channel's entry when it is
24
+ * omitted (the whole record's ownership is going away -- recycle, release,
25
+ * or the instance's own process exit; see InstanceRecord.monitorClients'
26
+ * own header comment for the exact call sites of each case) -- so a dead or
27
+ * torn-down client can never hold this lock forever, on any channel. The
28
+ * ONE place a holder entry is cleared, apart from broker-launch.mts's
29
+ * handleExit(), which assigns `{}` directly for a documented reason (see
30
+ * that function's own comment). A no-op when the targeted channel (or, with
31
+ * no channel, every channel) is not currently held -- idempotent, matching
32
+ * monitor_release's own tolerance for an already-cleared record. */
33
+ export function clearMonitorClient(record, channel) {
34
+ if (channel !== undefined) {
35
+ delete record.monitorClients[channel];
36
+ return;
37
+ }
38
+ for (const ch of MONITOR_CHANNELS)
39
+ delete record.monitorClients[ch];
16
40
  }
17
41
  export function createBrokerState() {
18
42
  return { instances: new Map(), grants: new Map(), blockedPorts: new Set() };
@@ -23,7 +47,20 @@ export function createBrokerState() {
23
47
  * trip. */
24
48
  export function _snapshotState(state) {
25
49
  return {
26
- instances: Array.from(state.instances.values()).map((r) => ({ ...r, viceArgs: [...r.viceArgs] })),
50
+ // Phase 33, plan 33-06: `profile` is the SECOND nested object on an
51
+ // InstanceRecord (after `viceArgs`), so it needs its own copy for this
52
+ // function's documented "deep, plain-object copy" contract to stay true --
53
+ // a spread alone would hand a caller a reference into live broker state,
54
+ // and this file's own snapshot test asserts that mutating a nested value
55
+ // in the result leaves the broker's state unchanged. The key is
56
+ // reproduced only when present, so an absent profile stays absent in the
57
+ // snapshot (absent means profile-less, and a snapshot must not invent a
58
+ // `profile: undefined` key that the record itself does not carry).
59
+ instances: Array.from(state.instances.values()).map((r) => ({
60
+ ...r,
61
+ viceArgs: [...r.viceArgs],
62
+ ...(r.profile === undefined ? {} : { profile: { ...r.profile } }),
63
+ })),
27
64
  grants: Array.from(state.grants.values()).map((g) => ({ ...g })),
28
65
  blockedPorts: Array.from(state.blockedPorts).sort((a, b) => a - b),
29
66
  };
@@ -149,14 +186,23 @@ export function countReady(state) {
149
186
  export function countTotal(state) {
150
187
  return state.instances.size;
151
188
  }
152
- /** Counts instances currently "launching" -- THE single counter both launch
153
- * paths (a cold acquire, via handleAcquire in vice-broker.mts, and warm
154
- * floor maintenance, via maintainWarmFloor in broker-launch.mts) consult
155
- * before starting a new launch. Two counters that could ever disagree about
156
- * whether a boot is already under way is exactly how the two bash launch
157
- * paths raced each other into the 2026-08-01 outage (three simultaneous
158
- * x64sc launches: one SEGV, one exit 1, one exit 0 at the identical spawn
159
- * second) -- there is now exactly one, read here and nowhere else. */
189
+ /** Counts instances currently "launching". Plan 41-05 (folded todo) retired
190
+ * the warm floor and its own maintainWarmFloor() -- the SECOND launch path
191
+ * that used to read this counter as a pre-check before starting a new
192
+ * launch, alongside the cold-acquire arm's own equivalent check. With only
193
+ * one launch path left (vice-broker.mts's handleAcquire(), guarded by
194
+ * acquirePortAndLaunch()'s own single-owner `inFlight` boolean in
195
+ * broker-launch.mts -- a SEPARATE, synchronous primitive, not this
196
+ * function), nothing in production calls this counter today; it remains
197
+ * exported alongside countReady()/countTotal() as status-shaped
198
+ * infrastructure. It is named here, and its history preserved, because it
199
+ * is why a SINGLE counter -- not two, one per launch path -- was the fix
200
+ * for the 2026-08-01 outage (three simultaneous x64sc launches: one SEGV,
201
+ * one exit 1, one exit 0 at the identical spawn second): two counters that
202
+ * could ever disagree about whether a boot was already under way is exactly
203
+ * how that outage happened, and the discipline of reading exactly one is
204
+ * what this function's own existence still documents, even with one launch
205
+ * path left to (potentially) consult it. */
160
206
  export function countLaunching(state) {
161
207
  let n = 0;
162
208
  for (const record of state.instances.values()) {
@@ -2,7 +2,7 @@
2
2
  // Compiled by `tsc` from container-guard.mts. Edit the TypeScript source and rebuild;
3
3
  // changes made directly to this file are silently overwritten by the next build, and are never
4
4
  // deployed to the host on their own -- install-resources.mjs copies THIS file's on-disk contents
5
- // verbatim to tools/, so an edit made only here reaches the host but is lost on the very next
5
+ // verbatim to .c64-re-tools/bin/, so an edit made only here reaches the host but is lost on the very next
6
6
  // rebuild.
7
7
  // container-guard.mts
8
8
  //