@johnhenry/mallory-cli 0.0.0-stage → 0.1.0
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/README.md +60 -2
- package/bin/mallory.mjs +51 -0
- package/package.json +51 -4
- package/src/a2a/client.js +511 -0
- package/src/a2a/demo-agent.js +396 -0
- package/src/a2a/hub.js +578 -0
- package/src/a2a/settings.js +88 -0
- package/src/a2a/task.js +358 -0
- package/src/acp/client.js +573 -0
- package/src/acp/demo-agent.js +332 -0
- package/src/acp/hub.js +632 -0
- package/src/acp/settings.js +78 -0
- package/src/actions/map.js +524 -0
- package/src/agent/cloud.js +77 -0
- package/src/agent/compact.js +84 -0
- package/src/agent/constants.js +39 -0
- package/src/agent/diff.js +101 -0
- package/src/agent/fork.js +159 -0
- package/src/agent/grounding.js +73 -0
- package/src/agent/guards.js +129 -0
- package/src/agent/local-transport.js +152 -0
- package/src/agent/loop.js +479 -0
- package/src/agent/park-store.js +77 -0
- package/src/agent/park.js +76 -0
- package/src/agent/ports.js +28 -0
- package/src/agent/providers.js +591 -0
- package/src/agent/restart.js +51 -0
- package/src/agent/router.js +380 -0
- package/src/agent/run.js +861 -0
- package/src/agent/tools.js +247 -0
- package/src/agent-library/engine.js +43 -0
- package/src/ai/bridge.js +155 -0
- package/src/ai/policy.js +131 -0
- package/src/aimatey/vendor.js +18 -0
- package/src/audio/container-duration.js +35 -0
- package/src/audio/instruments.js +776 -0
- package/src/audio/lanes.js +230 -0
- package/src/audio/patch.js +1410 -0
- package/src/audio/plan.js +276 -0
- package/src/audio/rack.js +1006 -0
- package/src/audio/sample-trim.js +293 -0
- package/src/audio/soundfont.js +243 -0
- package/src/audio/take-store.js +87 -0
- package/src/audio/takes.js +129 -0
- package/src/audio/wav.js +170 -0
- package/src/audio/zzfx.js +333 -0
- package/src/autonomy/bundle.js +207 -0
- package/src/autonomy/confine.js +61 -0
- package/src/autonomy/enforce.js +155 -0
- package/src/autonomy/file-kv.js +88 -0
- package/src/autonomy/ledger.js +203 -0
- package/src/autonomy/pins.js +50 -0
- package/src/autonomy/psl/index.js +32 -0
- package/src/autonomy/psl/suffixes.json +1 -0
- package/src/autonomy/record.js +28 -0
- package/src/autonomy/routines.js +107 -0
- package/src/autonomy/server.js +175 -0
- package/src/autonomy/signer-node.js +167 -0
- package/src/autonomy/store.js +43 -0
- package/src/autonomy/unattended.js +13 -0
- package/src/bytes/bytes.js +378 -0
- package/src/calc/syntax.js +125 -0
- package/src/calc/tex.js +28 -0
- package/src/calendar/vendor.js +2 -0
- package/src/clipboard.js +130 -0
- package/src/clsh/clsh.js +3417 -0
- package/src/codec/capnp.js +1804 -0
- package/src/codec/core.js +2043 -0
- package/src/codec/vendor/avro.js +136 -0
- package/src/codec/vendor/cbor.js +25 -0
- package/src/codec/vendor/flatbuffers.js +206 -0
- package/src/codec/vendor/msgpack.js +9 -0
- package/src/codec/vendor/protobuf.js +53 -0
- package/src/delegation/caps.js +60 -0
- package/src/delegation/config.js +32 -0
- package/src/device/model.js +246 -0
- package/src/device/recording.js +198 -0
- package/src/device/stream-model.js +151 -0
- package/src/documents/documents.js +1224 -0
- package/src/effects/catalog.js +63 -0
- package/src/effects/extras.js +133 -0
- package/src/effects/parse.js +339 -0
- package/src/embed/protocol.js +131 -0
- package/src/env/env.js +159 -0
- package/src/exact/vendor.js +45 -0
- package/src/example-meta.js +164 -0
- package/src/examples.js +94 -0
- package/src/export/canvas-image.js +217 -0
- package/src/export/expr-latex-lazy.js +8 -0
- package/src/export/formats.js +322 -0
- package/src/export/latex.js +183 -0
- package/src/export/pane.js +184 -0
- package/src/export/value.js +452 -0
- package/src/export/zip.js +214 -0
- package/src/ext/access.js +58 -0
- package/src/ext/btasks.js +225 -0
- package/src/ext/client.js +209 -0
- package/src/ext/tools.js +69 -0
- package/src/ext/view.js +105 -0
- package/src/ext/webmcp-tabs.js +299 -0
- package/src/files/archive.js +232 -0
- package/src/files/files.js +317 -0
- package/src/formats/json.js +24 -0
- package/src/formats/jupyter.js +188 -0
- package/src/formats/markdown.js +254 -0
- package/src/formats/n8n.js +276 -0
- package/src/formats/node-red.js +363 -0
- package/src/formats/registry.js +177 -0
- package/src/formats/rivet.js +259 -0
- package/src/formats/shared.js +98 -0
- package/src/formats/structure.js +182 -0
- package/src/formats/yaml.js +127 -0
- package/src/frame/frame.js +962 -0
- package/src/frame/vendor.js +1484 -0
- package/src/gate/audit.js +116 -0
- package/src/gate/gate.js +365 -0
- package/src/gate/policy.js +295 -0
- package/src/gate/scripted.js +110 -0
- package/src/gate/seams.js +32 -0
- package/src/gate/store.js +66 -0
- package/src/geometry/model.js +533 -0
- package/src/grant-key.js +149 -0
- package/src/graph/model.js +381 -0
- package/src/headless/a2a-push.js +123 -0
- package/src/headless/channels/config.js +142 -0
- package/src/headless/channels/connectors.js +283 -0
- package/src/headless/channels/index.js +257 -0
- package/src/headless/channels/mail.js +197 -0
- package/src/headless/channels/mailnet.js +223 -0
- package/src/headless/channels/platforms.js +194 -0
- package/src/headless/channels/replay.js +49 -0
- package/src/headless/cli.js +1397 -0
- package/src/headless/companion-client.js +182 -0
- package/src/headless/cost-cli.js +177 -0
- package/src/headless/deprecations-cli.js +102 -0
- package/src/headless/examples.js +48 -0
- package/src/headless/ffmpeg-exec.js +217 -0
- package/src/headless/gateways/config.js +213 -0
- package/src/headless/gateways/homeassistant.js +159 -0
- package/src/headless/gateways/index.js +121 -0
- package/src/headless/gateways/matter.js +150 -0
- package/src/headless/gateways/mqtt-client.js +177 -0
- package/src/headless/gateways/mqtt.js +70 -0
- package/src/headless/gateways/netway.js +226 -0
- package/src/headless/gateways/serverpod-worker.mjs +16 -0
- package/src/headless/gateways/serverpod.js +71 -0
- package/src/headless/gateways/util.js +27 -0
- package/src/headless/grant-cli.js +208 -0
- package/src/headless/guard.js +125 -0
- package/src/headless/guards.js +124 -0
- package/src/headless/machine-cli.js +853 -0
- package/src/headless/mcp-endpoint.js +287 -0
- package/src/headless/mcp-roots.js +38 -0
- package/src/headless/model-endpoint.js +88 -0
- package/src/headless/net.js +151 -0
- package/src/headless/node.js +263 -0
- package/src/headless/npm-tarball.js +29 -0
- package/src/headless/operator-page.js +112 -0
- package/src/headless/operator.js +242 -0
- package/src/headless/people.js +34 -0
- package/src/headless/pkg-cli.js +1103 -0
- package/src/headless/pkg-serve.js +138 -0
- package/src/headless/process-worker.js +88 -0
- package/src/headless/runner-remote.js +477 -0
- package/src/headless/sandbox-child.mjs +21 -0
- package/src/headless/scheduled.js +557 -0
- package/src/headless/serve-stream.js +97 -0
- package/src/headless/serve.js +2238 -0
- package/src/headless/short-links.js +158 -0
- package/src/headless/static-dirs.js +207 -0
- package/src/headless/trust-file.js +51 -0
- package/src/headless/watch.js +291 -0
- package/src/headless/ws-connect.js +65 -0
- package/src/headless/ws-connections.js +44 -0
- package/src/headless/ws-echo.js +150 -0
- package/src/headless/ws-proxy.js +354 -0
- package/src/headless/ws-ticket.js +48 -0
- package/src/hooks/config.js +50 -0
- package/src/hooks/engine.js +189 -0
- package/src/input/log.js +613 -0
- package/src/input/player.js +217 -0
- package/src/input/replay.js +209 -0
- package/src/jth/vendor.js +28 -0
- package/src/ledger/tx.js +94 -0
- package/src/machine/apply.js +193 -0
- package/src/machine/diff.js +168 -0
- package/src/machine/drive.js +296 -0
- package/src/machine/engine.js +478 -0
- package/src/machine/files-tool.js +76 -0
- package/src/machine/lint.js +139 -0
- package/src/machine/llmtm-trace.js +117 -0
- package/src/machine/llmtm.js +475 -0
- package/src/machine/otel.js +80 -0
- package/src/machine/pane-provider.js +51 -0
- package/src/machine/propose.js +159 -0
- package/src/machine/random.js +52 -0
- package/src/machine/risk.js +107 -0
- package/src/machine/session.js +1017 -0
- package/src/machine/shell-tool.js +45 -0
- package/src/machine/tape.js +349 -0
- package/src/machine/templates.js +104 -0
- package/src/machine/trace.js +664 -0
- package/src/machine/view.js +73 -0
- package/src/machine/vm-tool.js +47 -0
- package/src/machine/watchdog.js +46 -0
- package/src/mcp/app-args.js +51 -0
- package/src/mcp/app-run.js +56 -0
- package/src/mcp/apps.js +468 -0
- package/src/mcp/cache.js +232 -0
- package/src/mcp/client.js +507 -0
- package/src/mcp/demo-app.js +183 -0
- package/src/mcp/demo-server.js +602 -0
- package/src/mcp/elicitation.js +116 -0
- package/src/mcp/hub.js +1326 -0
- package/src/mcp/roots.js +139 -0
- package/src/mcp/sampling.js +105 -0
- package/src/mcp/settings.js +125 -0
- package/src/mcp/tape.js +292 -0
- package/src/mcp/uri-template.js +156 -0
- package/src/mcp/wsh-client.js +164 -0
- package/src/media/animated-codec.js +7 -0
- package/src/media/animated.js +623 -0
- package/src/media/compare-agent.js +70 -0
- package/src/media/compare-job.js +63 -0
- package/src/media/compare-page.js +296 -0
- package/src/media/compare-worker.js +14 -0
- package/src/media/compare.js +600 -0
- package/src/media/contract.js +62 -0
- package/src/media/decode-frame.js +57 -0
- package/src/media/decode-pool.js +188 -0
- package/src/media/ffmpeg-edit.js +344 -0
- package/src/media/ffmpeg-wasm-client.js +121 -0
- package/src/media/ffmpeg-wasm-session.js +79 -0
- package/src/media/ffmpeg-wasm.js +139 -0
- package/src/media/ffmpeg-worker.js +23 -0
- package/src/media/ffmpeg.js +903 -0
- package/src/media/helpers.js +419 -0
- package/src/media/keep.js +108 -0
- package/src/media/metadata-worker.js +16 -0
- package/src/media/metadata.js +2518 -0
- package/src/media/mime.js +102 -0
- package/src/media/page-decode.js +74 -0
- package/src/media/persist.js +114 -0
- package/src/media/png.js +226 -0
- package/src/media/sample-input.js +67 -0
- package/src/media/store.js +86 -0
- package/src/media/wav.js +109 -0
- package/src/midi/mappings.js +250 -0
- package/src/midi/message.js +125 -0
- package/src/model/action-hub.js +143 -0
- package/src/model/adapters.js +284 -0
- package/src/model/agent-runs.js +12 -0
- package/src/model/arrange.js +308 -0
- package/src/model/automation-clock.js +494 -0
- package/src/model/automation.js +653 -0
- package/src/model/batches.js +78 -0
- package/src/model/binary-view.js +195 -0
- package/src/model/breakpoints.js +392 -0
- package/src/model/calc-settings.js +65 -0
- package/src/model/calendar.js +254 -0
- package/src/model/canvas-id.js +5 -0
- package/src/model/canvas.js +5048 -0
- package/src/model/channel-names.js +29 -0
- package/src/model/channels.js +692 -0
- package/src/model/chart-clock.js +631 -0
- package/src/model/chart-code.js +69 -0
- package/src/model/codecs.js +60 -0
- package/src/model/companion-access.js +271 -0
- package/src/model/companion-pane.js +50 -0
- package/src/model/composite.js +324 -0
- package/src/model/context.js +380 -0
- package/src/model/controls.js +231 -0
- package/src/model/converter-presets.js +368 -0
- package/src/model/cost.js +580 -0
- package/src/model/curve-transform.js +122 -0
- package/src/model/cycles.js +176 -0
- package/src/model/debug-log.js +168 -0
- package/src/model/decision-clock.js +100 -0
- package/src/model/decisions.js +265 -0
- package/src/model/desk.js +87 -0
- package/src/model/device-hub.js +400 -0
- package/src/model/diff.js +445 -0
- package/src/model/emit-events.js +179 -0
- package/src/model/errors.js +238 -0
- package/src/model/event-presets.js +297 -0
- package/src/model/events.js +1303 -0
- package/src/model/explicit-setters.js +139 -0
- package/src/model/field-mapping.js +623 -0
- package/src/model/files-pane.js +263 -0
- package/src/model/flow-idle.js +89 -0
- package/src/model/foreach.js +549 -0
- package/src/model/frame-loop.js +71 -0
- package/src/model/frame-pressure.js +180 -0
- package/src/model/function-scaffold.js +1000 -0
- package/src/model/geometry-settings.js +54 -0
- package/src/model/goals.js +176 -0
- package/src/model/graph-settings.js +76 -0
- package/src/model/grid-widget.js +175 -0
- package/src/model/groups.js +332 -0
- package/src/model/hash.js +21 -0
- package/src/model/history.js +259 -0
- package/src/model/http-copy.js +88 -0
- package/src/model/http-send-companion.js +110 -0
- package/src/model/http-send.js +163 -0
- package/src/model/http-tap.js +521 -0
- package/src/model/http-tools.js +1138 -0
- package/src/model/import-lock.js +78 -0
- package/src/model/imports.js +258 -0
- package/src/model/infer-outputs.js +822 -0
- package/src/model/ink-connect.js +150 -0
- package/src/model/ink-diff.js +75 -0
- package/src/model/ink-gone.js +71 -0
- package/src/model/ink-route.js +120 -0
- package/src/model/ink-svg.js +206 -0
- package/src/model/ink.js +739 -0
- package/src/model/input-log-hub.js +456 -0
- package/src/model/input-split.js +69 -0
- package/src/model/json-schema-host.js +9 -0
- package/src/model/json-schema.js +368 -0
- package/src/model/jth.js +78 -0
- package/src/model/latex-expr.js +528 -0
- package/src/model/layout-history.js +120 -0
- package/src/model/lazy-map.js +88 -0
- package/src/model/ledger-pane.js +101 -0
- package/src/model/legacy-viaframe.js +90 -0
- package/src/model/lessons.js +448 -0
- package/src/model/links.js +981 -0
- package/src/model/live.js +411 -0
- package/src/model/math-widget.js +53 -0
- package/src/model/memory-settings.js +33 -0
- package/src/model/midi-controls.js +350 -0
- package/src/model/nl-time.js +408 -0
- package/src/model/notebook.js +137 -0
- package/src/model/pane-view-store.js +15 -0
- package/src/model/partial.js +115 -0
- package/src/model/pause-clock.js +53 -0
- package/src/model/peer-pane.js +32 -0
- package/src/model/persist-state.js +290 -0
- package/src/model/person-only.js +122 -0
- package/src/model/pin.js +209 -0
- package/src/model/plot-3d.js +213 -0
- package/src/model/plot-series.js +157 -0
- package/src/model/plot-settings.js +531 -0
- package/src/model/ports.js +312 -0
- package/src/model/presentation.js +222 -0
- package/src/model/preset-apply.js +316 -0
- package/src/model/preset-banks.js +335 -0
- package/src/model/preset-morph.js +263 -0
- package/src/model/preset-ops.js +205 -0
- package/src/model/preset-player.js +283 -0
- package/src/model/preset-states.js +172 -0
- package/src/model/profile-settings.js +109 -0
- package/src/model/promote.js +103 -0
- package/src/model/protected.js +10 -0
- package/src/model/proxy-log.js +230 -0
- package/src/model/proxy.js +367 -0
- package/src/model/quantity-widget.js +61 -0
- package/src/model/queue-book.js +359 -0
- package/src/model/quick-add.js +224 -0
- package/src/model/rate-limit.js +313 -0
- package/src/model/rate.js +95 -0
- package/src/model/recovery.js +216 -0
- package/src/model/rename-follow.js +113 -0
- package/src/model/repeater.js +1126 -0
- package/src/model/retention.js +664 -0
- package/src/model/route-edit.js +132 -0
- package/src/model/router.js +155 -0
- package/src/model/runaway.js +232 -0
- package/src/model/runlog.js +1033 -0
- package/src/model/runners/a2a.js +2 -0
- package/src/model/runners/acp.js +2 -0
- package/src/model/runners/actions.js +4 -0
- package/src/model/runners/agent.js +4 -0
- package/src/model/runners/audio.js +21 -0
- package/src/model/runners/automation.js +2 -0
- package/src/model/runners/calc.js +23 -0
- package/src/model/runners/catch.js +10 -0
- package/src/model/runners/codec.js +24 -0
- package/src/model/runners/companion-run.js +2 -0
- package/src/model/runners/device.js +7 -0
- package/src/model/runners/dom.js +13 -0
- package/src/model/runners/effects.js +2 -0
- package/src/model/runners/embed.js +11 -0
- package/src/model/runners/eval.js +2 -0
- package/src/model/runners/files.js +19 -0
- package/src/model/runners/geometry.js +23 -0
- package/src/model/runners/goals.js +18 -0
- package/src/model/runners/graph.js +23 -0
- package/src/model/runners/html.js +2 -0
- package/src/model/runners/http-proxy.js +185 -0
- package/src/model/runners/http-send.js +61 -0
- package/src/model/runners/http-static.js +83 -0
- package/src/model/runners/http-tap.js +26 -0
- package/src/model/runners/http.js +40 -0
- package/src/model/runners/import.js +2 -0
- package/src/model/runners/index.js +74 -0
- package/src/model/runners/input.js +14 -0
- package/src/model/runners/inputlog.js +7 -0
- package/src/model/runners/ledger.js +15 -0
- package/src/model/runners/machine.js +4 -0
- package/src/model/runners/mcp.js +2 -0
- package/src/model/runners/mcpapp.js +2 -0
- package/src/model/runners/media.js +18 -0
- package/src/model/runners/memory.js +28 -0
- package/src/model/runners/mesh-inspect.js +13 -0
- package/src/model/runners/peer.js +14 -0
- package/src/model/runners/plot.js +22 -0
- package/src/model/runners/render.js +14 -0
- package/src/model/runners/respond.js +2 -0
- package/src/model/runners/sample-soundfont.js +85 -0
- package/src/model/runners/sample.js +159 -0
- package/src/model/runners/scene.js +8 -0
- package/src/model/runners/score.js +24 -0
- package/src/model/runners/secret.js +10 -0
- package/src/model/runners/select.js +2 -0
- package/src/model/runners/shared.js +4 -0
- package/src/model/runners/shares.js +15 -0
- package/src/model/runners/shell.js +7 -0
- package/src/model/runners/skill.js +26 -0
- package/src/model/runners/state.js +2 -0
- package/src/model/runners/statechart.js +4 -0
- package/src/model/runners/subgraph.js +9 -0
- package/src/model/runners/tabs.js +25 -0
- package/src/model/runners/terminal.js +5 -0
- package/src/model/runners/text.js +4 -0
- package/src/model/runners/timer.js +7 -0
- package/src/model/runners/traffic.js +65 -0
- package/src/model/runners/trigger.js +2 -0
- package/src/model/runners/verdict.js +29 -0
- package/src/model/runners/vm.js +7 -0
- package/src/model/runners/wait.js +4 -0
- package/src/model/runners/ws-client.js +57 -0
- package/src/model/safe-regex.js +719 -0
- package/src/model/sample-settings.js +43 -0
- package/src/model/sample-source.js +47 -0
- package/src/model/saved-mapping.js +153 -0
- package/src/model/score-controllers.js +87 -0
- package/src/model/score-edit.js +399 -0
- package/src/model/score-instruments.js +300 -0
- package/src/model/score-library.js +407 -0
- package/src/model/score-markup.js +235 -0
- package/src/model/score-mix.js +248 -0
- package/src/model/score-patterns.js +276 -0
- package/src/model/score-selection.js +34 -0
- package/src/model/score-time.js +139 -0
- package/src/model/score-transforms.js +336 -0
- package/src/model/score-transport.js +192 -0
- package/src/model/selection.js +351 -0
- package/src/model/serial-controls.js +328 -0
- package/src/model/shares-pane.js +17 -0
- package/src/model/shell-pane.js +106 -0
- package/src/model/signature.js +1122 -0
- package/src/model/size-hints.js +106 -0
- package/src/model/size-ratio.js +12 -0
- package/src/model/skill-settings.js +23 -0
- package/src/model/snapping.js +466 -0
- package/src/model/split.js +375 -0
- package/src/model/spring-player.js +222 -0
- package/src/model/statecharts.js +1369 -0
- package/src/model/states-preset.js +208 -0
- package/src/model/static-route.js +100 -0
- package/src/model/step-words.js +45 -0
- package/src/model/subgraph.js +1042 -0
- package/src/model/switch.js +98 -0
- package/src/model/tabs-store.js +10 -0
- package/src/model/tensor-view.js +146 -0
- package/src/model/timer-clock.js +361 -0
- package/src/model/timers.js +422 -0
- package/src/model/timing.js +212 -0
- package/src/model/traffic-agent.js +111 -0
- package/src/model/traffic-store.js +20 -0
- package/src/model/traffic.js +665 -0
- package/src/model/transport.js +364 -0
- package/src/model/turns.js +86 -0
- package/src/model/types.js +425 -0
- package/src/model/value-path.js +138 -0
- package/src/model/versions.js +535 -0
- package/src/model/view-outputs.js +144 -0
- package/src/model/viewport-bookmarks.js +194 -0
- package/src/model/virtual-clock.js +85 -0
- package/src/model/vm-pane.js +258 -0
- package/src/model/wait-clock.js +715 -0
- package/src/model/wait-persist.js +248 -0
- package/src/model/waits.js +431 -0
- package/src/model/watch.js +80 -0
- package/src/model/webhook.js +496 -0
- package/src/model/when.js +48 -0
- package/src/model/widget-values.js +392 -0
- package/src/model/window-commands.js +278 -0
- package/src/model/windows.js +348 -0
- package/src/model/wire-inspect.js +343 -0
- package/src/model/wire-ops.js +324 -0
- package/src/model/wire-pipeline.js +378 -0
- package/src/model/wire-route.js +637 -0
- package/src/model/workspaces.js +122 -0
- package/src/model/ws-client.js +155 -0
- package/src/model/ws-demo.js +31 -0
- package/src/model/ws-frames.js +141 -0
- package/src/model/ws-hub.js +219 -0
- package/src/model/ws-served.js +13 -0
- package/src/model/xstate.js +374 -0
- package/src/narrative/narrative.js +1557 -0
- package/src/network/auth.js +224 -0
- package/src/network/csp-frame.js +197 -0
- package/src/network/declarative-shadow.js +27 -0
- package/src/network/frame-net-shim.js +962 -0
- package/src/network/hosts.js +157 -0
- package/src/network/policy.js +520 -0
- package/src/network/rtc-shim.js +418 -0
- package/src/network/secret-gate.js +78 -0
- package/src/network/secrets.js +261 -0
- package/src/network/sockets.js +287 -0
- package/src/network/store.js +186 -0
- package/src/network/streams.js +99 -0
- package/src/packages/asset-values.js +50 -0
- package/src/packages/assets.js +99 -0
- package/src/packages/deprecation.js +203 -0
- package/src/packages/fetch.js +152 -0
- package/src/packages/function-canvas.js +73 -0
- package/src/packages/module.js +120 -0
- package/src/packages/package.js +474 -0
- package/src/packages/published.js +27 -0
- package/src/packages/requires.js +83 -0
- package/src/packages/signing.js +145 -0
- package/src/packages/trust.js +107 -0
- package/src/panes/a2a.js +51 -0
- package/src/panes/acp.js +60 -0
- package/src/panes/actions.js +54 -0
- package/src/panes/agent.js +83 -0
- package/src/panes/audio.js +103 -0
- package/src/panes/automation.js +112 -0
- package/src/panes/calc.js +67 -0
- package/src/panes/catch.js +52 -0
- package/src/panes/codec.js +59 -0
- package/src/panes/colors.js +12 -0
- package/src/panes/companion.js +54 -0
- package/src/panes/decision.js +65 -0
- package/src/panes/device.js +56 -0
- package/src/panes/dom.js +37 -0
- package/src/panes/effects.js +118 -0
- package/src/panes/embed.js +30 -0
- package/src/panes/eval.js +186 -0
- package/src/panes/fields.js +299 -0
- package/src/panes/files.js +45 -0
- package/src/panes/gate.js +70 -0
- package/src/panes/geometry.js +64 -0
- package/src/panes/goals.js +75 -0
- package/src/panes/graph.js +66 -0
- package/src/panes/html.js +54 -0
- package/src/panes/http.js +82 -0
- package/src/panes/import.js +38 -0
- package/src/panes/input.js +124 -0
- package/src/panes/inputlog.js +66 -0
- package/src/panes/ledger.js +56 -0
- package/src/panes/machine.js +138 -0
- package/src/panes/mcp.js +85 -0
- package/src/panes/mcpapp.js +64 -0
- package/src/panes/media.js +38 -0
- package/src/panes/memory.js +46 -0
- package/src/panes/mesh-inspect.js +49 -0
- package/src/panes/note.js +38 -0
- package/src/panes/peer.js +44 -0
- package/src/panes/plot.js +196 -0
- package/src/panes/registry.js +475 -0
- package/src/panes/render.js +87 -0
- package/src/panes/respond.js +44 -0
- package/src/panes/router.js +84 -0
- package/src/panes/sample.js +75 -0
- package/src/panes/scene.js +55 -0
- package/src/panes/score.js +87 -0
- package/src/panes/secret.js +38 -0
- package/src/panes/select.js +67 -0
- package/src/panes/shader.js +166 -0
- package/src/panes/shared.js +33 -0
- package/src/panes/shares.js +43 -0
- package/src/panes/shell.js +47 -0
- package/src/panes/skill.js +44 -0
- package/src/panes/state.js +91 -0
- package/src/panes/statechart.js +63 -0
- package/src/panes/story.js +33 -0
- package/src/panes/subgraph.js +94 -0
- package/src/panes/tabs.js +52 -0
- package/src/panes/terminal.js +57 -0
- package/src/panes/text.js +36 -0
- package/src/panes/timer.js +55 -0
- package/src/panes/traffic.js +59 -0
- package/src/panes/verdict.js +62 -0
- package/src/panes/vm.js +46 -0
- package/src/panes/wait.js +61 -0
- package/src/panes/watch.js +57 -0
- package/src/panes/webhook.js +67 -0
- package/src/panes/ws-client.js +67 -0
- package/src/persist.js +281 -0
- package/src/plot/tex.js +19 -0
- package/src/plot/vendor.js +59 -0
- package/src/plot/view-vendor.js +5 -0
- package/src/privacy/levels.js +108 -0
- package/src/protocol/devtools.js +116 -0
- package/src/protocol/inspector.js +368 -0
- package/src/render/time.js +381 -0
- package/src/rooms/mesh-metrics.js +162 -0
- package/src/run/companion.js +355 -0
- package/src/run/describe.js +114 -0
- package/src/run/local-model.js +150 -0
- package/src/run/monitor.js +208 -0
- package/src/run/publish.js +360 -0
- package/src/run/respond-outcome.js +12 -0
- package/src/run/run.js +820 -0
- package/src/run/runner-pairing.js +243 -0
- package/src/run/values.js +122 -0
- package/src/runtime/compile.js +122 -0
- package/src/runtime/console-tag.js +64 -0
- package/src/runtime/frame-signals.js +126 -0
- package/src/runtime/iteration-push.js +19 -0
- package/src/runtime/keys.js +474 -0
- package/src/runtime/midi-input.js +170 -0
- package/src/runtime/person-waits.js +140 -0
- package/src/runtime/resource-timing.js +56 -0
- package/src/runtime/runtime.js +2150 -0
- package/src/runtime/sandbox-modules.js +163 -0
- package/src/runtime/spring.js +246 -0
- package/src/runtime/strict.js +215 -0
- package/src/runtime/transfer.js +75 -0
- package/src/runtime/tween.js +158 -0
- package/src/runtime/wasm-fuel.js +596 -0
- package/src/runtime/worker/00-prelude.js +88 -0
- package/src/runtime/worker/10-helpers.js +295 -0
- package/src/runtime/worker/20-io.js +645 -0
- package/src/runtime/worker/30-previews.js +210 -0
- package/src/runtime/worker/40-profile-lineage.js +278 -0
- package/src/runtime/worker/50-own-worker.js +233 -0
- package/src/runtime/worker/60-timers.js +172 -0
- package/src/runtime/worker/70-state-keyed.js +193 -0
- package/src/runtime/worker/80-each-compile-generators.js +619 -0
- package/src/runtime/worker/90-events-operators.js +655 -0
- package/src/runtime/worker/95-agents-batches.js +1820 -0
- package/src/runtime/worker/96-plot.js +47 -0
- package/src/runtime/worker/97-calc.js +28 -0
- package/src/runtime/worker/98-geometry.js +24 -0
- package/src/runtime/worker/99-graph.js +30 -0
- package/src/runtime/worker/99-shell.js +30 -0
- package/src/safety/config.js +57 -0
- package/src/safety/engine.js +324 -0
- package/src/scene/pixi-scene.js +806 -0
- package/src/scene/scene-assets.js +241 -0
- package/src/scene/scene-edit.js +319 -0
- package/src/secret/settings.js +41 -0
- package/src/security/multipart.js +257 -0
- package/src/security/redact.js +261 -0
- package/src/serial/broker.js +473 -0
- package/src/serial/config.js +185 -0
- package/src/serial/framers.js +389 -0
- package/src/serial/packets.js +64 -0
- package/src/shader/audio-texture.js +87 -0
- package/src/shader/channels.js +496 -0
- package/src/shader/common.js +90 -0
- package/src/shader/model.js +867 -0
- package/src/shader/passes.js +150 -0
- package/src/shader/shadertoy.js +198 -0
- package/src/shell/hub.js +287 -0
- package/src/sim/checkpoints.js +850 -0
- package/src/sim/compile.js +37 -0
- package/src/sim/fixed.js +377 -0
- package/src/sim/headless.js +205 -0
- package/src/sim/physics.js +399 -0
- package/src/smf-helper/vendor.js +2 -0
- package/src/sources/config.js +435 -0
- package/src/storage.js +153 -0
- package/src/table/table-geo.js +2344 -0
- package/src/table/table-lineage.js +808 -0
- package/src/table/table-quality.js +355 -0
- package/src/table/table-schema.js +392 -0
- package/src/table/table-sql.js +1650 -0
- package/src/table/table-stats.js +480 -0
- package/src/table/table.js +2102 -0
- package/src/tensor/tensor.js +1153 -0
- package/src/terminal/hub.js +715 -0
- package/src/terminal/screen.js +516 -0
- package/src/tests/capture.js +88 -0
- package/src/tests/compare.js +480 -0
- package/src/tests/dataset.js +170 -0
- package/src/tests/evaluate.js +286 -0
- package/src/tests/from-runs.js +99 -0
- package/src/tests/judge.js +134 -0
- package/src/tests/matchers.js +263 -0
- package/src/tests/matrix-spec.js +87 -0
- package/src/tests/matrix.js +397 -0
- package/src/tests/metrics.js +369 -0
- package/src/tests/no-value.js +42 -0
- package/src/tests/pane-check.js +45 -0
- package/src/tests/report.js +124 -0
- package/src/tests/reporters.js +140 -0
- package/src/tests/run.js +155 -0
- package/src/tilemap/tilemap.js +1122 -0
- package/src/units/units.js +3 -0
- package/src/util/bytes-text.js +21 -0
- package/src/util/num.js +10 -0
- package/src/util/regexp.js +2 -0
- package/src/util/text.js +38 -0
- package/src/verdict/engine.js +154 -0
- package/src/vm/guest-wsh.js +108 -0
- package/src/vm/hub.js +457 -0
- package/src/vm/image-files.js +4 -0
- package/src/vm/image.js +33 -0
- package/src/vm/image.lock.json +13 -0
- package/src/vm/link.js +266 -0
- package/src/vm/mount.js +212 -0
- package/src/vm/net.js +85 -0
- package/src/vm/pipe-ws.js +187 -0
- package/src/vm/v86-loader.js +11 -0
- package/src/webmcp/args.js +212 -0
- package/src/webmcp/hidden.js +218 -0
- package/src/webmcp/text.js +250 -0
- package/src/webmcp/tools/bookmark-tools.js +106 -0
- package/src/webmcp/tools/breakpoint-tools.js +48 -0
- package/src/webmcp/tools/canvases.js +208 -0
- package/src/webmcp/tools/context-tools.js +84 -0
- package/src/webmcp/tools/core.js +170 -0
- package/src/webmcp/tools/devices.js +41 -0
- package/src/webmcp/tools/edit.js +357 -0
- package/src/webmcp/tools/event-tools.js +145 -0
- package/src/webmcp/tools/image-tools.js +173 -0
- package/src/webmcp/tools/ink-tools.js +247 -0
- package/src/webmcp/tools/input-log-tools.js +163 -0
- package/src/webmcp/tools/live.js +166 -0
- package/src/webmcp/tools/machine-tools.js +74 -0
- package/src/webmcp/tools/media.js +161 -0
- package/src/webmcp/tools/midi-tools.js +32 -0
- package/src/webmcp/tools/preset-tools.js +184 -0
- package/src/webmcp/tools/quick-add-tools.js +95 -0
- package/src/webmcp/tools/reshape.js +152 -0
- package/src/webmcp/tools/run-tools.js +309 -0
- package/src/webmcp/tools/runs.js +101 -0
- package/src/webmcp/tools/scaffold-tools.js +161 -0
- package/src/webmcp/tools/serial-tools.js +36 -0
- package/src/webmcp/tools/shared.js +338 -0
- package/src/webmcp/tools/subgraphs.js +360 -0
- package/src/webmcp/tools/tests.js +170 -0
- package/src/webmcp/tools/traffic-tools.js +70 -0
- package/src/webmcp/tools/transport-tools.js +65 -0
- package/src/webmcp/tools/version-tools.js +126 -0
- package/src/webmcp/tools/versions.js +11 -0
- package/src/webmcp/tools/wire-tools.js +90 -0
- package/src/webmcp/tools/workspace-tools.js +93 -0
- package/src/webmcp/tools.js +1323 -0
- package/src/wsh/connect.js +347 -0
- package/src/wsh/demo-host.js +361 -0
- package/src/wsh/e2e.js +27 -0
- package/src/wsh/keys.js +154 -0
- package/src/wsh/known-hosts.js +39 -0
- package/src/wsh/private-key.js +95 -0
- package/src/wsh/reverse.js +34 -0
- package/src/wsh/settings.js +118 -0
- package/src/wsh/transfer.js +62 -0
- package/src/wsh/vendor.js +5 -0
- package/src/x402/challenge.js +171 -0
- package/src/x402/demo-server.js +127 -0
- package/src/x402/pay.js +125 -0
- package/src/x402/retry.js +95 -0
- package/src/x402/store.js +76 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
// A WebSocket client over a byte pipe (docs/guide/settings-and-storage.md: VM pane, "Terminal into the guest"). The machine's hvc0 link (src/vm/link.js) is a plain byte pipe; the wsh server in the guest
|
|
2
|
+
// (`wsh-server --plain-ws 127.0.0.1:<port>`, vm-image/) speaks WebSocket on a loopback socket that `nc` in the guest joins to that pipe. This is the page's end: the HTTP upgrade, then masked
|
|
3
|
+
// binary frames, giving `send(bytes)` / `onmessage(bytes)` messages, which is what `connectWshOverDuplex` (@johnhenry/wsh/duplex) wants. It is a client only, binary only, and bounded: a header past
|
|
4
|
+
// MAX_HEAD, a frame past maxMessageBytes, a text frame, an unmasked-by-us rule broken by the server (a MASKED server frame), a bad accept key, or an extension all end the socket (fail closed).
|
|
5
|
+
// Everything the guest sends is untrusted bytes: nothing here is run, and the session above it is sealed and bound to a pinned host key, so a guest process that is not the wsh server learns nothing.
|
|
6
|
+
|
|
7
|
+
export const MAX_HEAD = 8192;
|
|
8
|
+
export const MAX_MESSAGE = 1 << 20;
|
|
9
|
+
const GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
|
10
|
+
const enc = new TextEncoder();
|
|
11
|
+
const dec = new TextDecoder("latin1");
|
|
12
|
+
|
|
13
|
+
const b64 = (bytes) => {
|
|
14
|
+
let s = "";
|
|
15
|
+
for (const b of bytes) s += String.fromCharCode(b);
|
|
16
|
+
return btoa(s);
|
|
17
|
+
};
|
|
18
|
+
const concat = (a, b) => {
|
|
19
|
+
if (!a.byteLength) return b;
|
|
20
|
+
const out = new Uint8Array(a.byteLength + b.byteLength);
|
|
21
|
+
out.set(a, 0);
|
|
22
|
+
out.set(b, a.byteLength);
|
|
23
|
+
return out;
|
|
24
|
+
};
|
|
25
|
+
const acceptFor = async (key) => b64(new Uint8Array(await crypto.subtle.digest("SHA-1", enc.encode(key + GUID))));
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* `write(bytes)` puts bytes on the pipe. Feed what comes back with `feed(bytes)`. `open()` sends the upgrade and resolves when the server accepted it (rejects otherwise).
|
|
29
|
+
* `send(bytes)` is one binary message (cut into frames of at most 16 KiB); `onmessage`, `onclose(reason)` are set by the caller. `close()` sends a close frame.
|
|
30
|
+
*/
|
|
31
|
+
export function createPipeWebSocket({ write, host = "127.0.0.1", path = "/", maxMessage = MAX_MESSAGE } = {}) {
|
|
32
|
+
let state = "connecting"; // connecting | open | closed
|
|
33
|
+
let head = new Uint8Array(0);
|
|
34
|
+
let buf = new Uint8Array(0);
|
|
35
|
+
let message = []; // the pieces of a fragmented message
|
|
36
|
+
let messageSize = 0;
|
|
37
|
+
let expected = "";
|
|
38
|
+
let settle;
|
|
39
|
+
const opened = new Promise((resolve, reject) => (settle = { resolve, reject }));
|
|
40
|
+
opened.catch(() => {});
|
|
41
|
+
const early = [];
|
|
42
|
+
const api = {
|
|
43
|
+
onmessage: null,
|
|
44
|
+
onclose: null,
|
|
45
|
+
get state() {
|
|
46
|
+
return state;
|
|
47
|
+
},
|
|
48
|
+
async open() {
|
|
49
|
+
const raw = new Uint8Array(16);
|
|
50
|
+
crypto.getRandomValues(raw);
|
|
51
|
+
const key = b64(raw);
|
|
52
|
+
expected = await acceptFor(key);
|
|
53
|
+
write(enc.encode(`GET ${path} HTTP/1.1\r\nHost: ${host}\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Key: ${key}\r\nSec-WebSocket-Version: 13\r\n\r\n`));
|
|
54
|
+
return opened;
|
|
55
|
+
},
|
|
56
|
+
feed(bytes) {
|
|
57
|
+
if (state === "closed") return;
|
|
58
|
+
if (state === "connecting") {
|
|
59
|
+
head = concat(head, bytes);
|
|
60
|
+
const text = dec.decode(head);
|
|
61
|
+
const end = text.indexOf("\r\n\r\n");
|
|
62
|
+
if (end < 0) {
|
|
63
|
+
if (head.byteLength > MAX_HEAD) fail("the guest's answer to the upgrade is too long");
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const lines = text.slice(0, end).split("\r\n");
|
|
67
|
+
const rest = head.slice(end + 4);
|
|
68
|
+
head = new Uint8Array(0);
|
|
69
|
+
if (!/^HTTP\/1\.1 101\b/.test(lines[0])) return fail(`the guest did not accept the upgrade (${lines[0].slice(0, 60)})`);
|
|
70
|
+
const h = new Map(lines.slice(1).map((l) => [l.slice(0, l.indexOf(":")).trim().toLowerCase(), l.slice(l.indexOf(":") + 1).trim()]));
|
|
71
|
+
if ((h.get("upgrade") ?? "").toLowerCase() !== "websocket") return fail("the guest's answer is not a WebSocket upgrade");
|
|
72
|
+
if (h.get("sec-websocket-accept") !== expected) return fail("the guest's accept key is wrong");
|
|
73
|
+
if (h.has("sec-websocket-extensions") || h.has("sec-websocket-protocol")) return fail("the guest offered an extension that was not asked for");
|
|
74
|
+
state = "open";
|
|
75
|
+
settle.resolve();
|
|
76
|
+
if (rest.byteLength) api.feed(rest);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
buf = concat(buf, bytes);
|
|
80
|
+
for (;;) {
|
|
81
|
+
if (state !== "open" || buf.byteLength < 2) return;
|
|
82
|
+
const b0 = buf[0];
|
|
83
|
+
const b1 = buf[1];
|
|
84
|
+
if (b0 & 0x70) return fail("a frame with reserved bits set");
|
|
85
|
+
if (b1 & 0x80) return fail("the guest masked a frame");
|
|
86
|
+
let len = b1 & 0x7f;
|
|
87
|
+
let at = 2;
|
|
88
|
+
if (len === 126) {
|
|
89
|
+
if (buf.byteLength < 4) return;
|
|
90
|
+
len = (buf[2] << 8) | buf[3];
|
|
91
|
+
at = 4;
|
|
92
|
+
} else if (len === 127) {
|
|
93
|
+
if (buf.byteLength < 10) return;
|
|
94
|
+
if (buf[2] || buf[3] || buf[4] || buf[5] || buf[6] > 0) return fail("a frame is too large");
|
|
95
|
+
len = buf[6] * 2 ** 24 + ((buf[7] << 16) | (buf[8] << 8) | buf[9]);
|
|
96
|
+
at = 10;
|
|
97
|
+
}
|
|
98
|
+
if (len > maxMessage) return fail("a frame is larger than the limit");
|
|
99
|
+
if (buf.byteLength < at + len) return;
|
|
100
|
+
const op = b0 & 0x0f;
|
|
101
|
+
const fin = (b0 & 0x80) !== 0;
|
|
102
|
+
const payload = buf.slice(at, at + len);
|
|
103
|
+
buf = buf.slice(at + len);
|
|
104
|
+
if (op >= 8) {
|
|
105
|
+
if (!fin || len > 125) return fail("a bad control frame");
|
|
106
|
+
if (op === 8) return finish("the guest closed the connection");
|
|
107
|
+
if (op === 9) frame(0x0a, payload);
|
|
108
|
+
else if (op !== 10) return fail("an unknown control frame");
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (op === 1) return fail("a text frame (wsh is binary)");
|
|
112
|
+
if (op === 2) {
|
|
113
|
+
if (message.length) return fail("a new message in the middle of one");
|
|
114
|
+
} else if (op === 0) {
|
|
115
|
+
if (!message.length) return fail("a continuation with nothing to continue");
|
|
116
|
+
} else return fail("an unknown frame type");
|
|
117
|
+
messageSize += payload.byteLength;
|
|
118
|
+
if (messageSize > maxMessage) return fail("a message is larger than the limit");
|
|
119
|
+
message.push(payload);
|
|
120
|
+
if (fin) {
|
|
121
|
+
const whole = message.length === 1 ? message[0] : message.reduce(concat, new Uint8Array(0));
|
|
122
|
+
message = [];
|
|
123
|
+
messageSize = 0;
|
|
124
|
+
if (api.onmessage) api.onmessage(whole);
|
|
125
|
+
else early.push(whole);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
send(bytes) {
|
|
130
|
+
if (state !== "open") throw new Error("the guest connection is not open");
|
|
131
|
+
const data = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
|
|
132
|
+
if (data.byteLength > maxMessage) throw new Error("a message is larger than the limit");
|
|
133
|
+
for (let at = 0, first = true; at < data.byteLength || first; first = false) {
|
|
134
|
+
const piece = data.subarray(at, at + 16384);
|
|
135
|
+
at += piece.byteLength;
|
|
136
|
+
frame((first ? 0x2 : 0x0) | (at >= data.byteLength ? 0x80 : 0), piece, true);
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
/** Messages that arrived before `onmessage` was set. */
|
|
140
|
+
takeEarly() {
|
|
141
|
+
return early.splice(0);
|
|
142
|
+
},
|
|
143
|
+
close() {
|
|
144
|
+
if (state === "closed") return;
|
|
145
|
+
if (state === "open") {
|
|
146
|
+
try {
|
|
147
|
+
frame(0x08, new Uint8Array([0x03, 0xe8]));
|
|
148
|
+
} catch {}
|
|
149
|
+
}
|
|
150
|
+
finish("closed here");
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
function frame(opByte, payload, rawOp = false) {
|
|
155
|
+
const op = rawOp ? opByte : 0x80 | opByte;
|
|
156
|
+
const len = payload.byteLength;
|
|
157
|
+
const headLen = len < 126 ? 2 : 4;
|
|
158
|
+
const out = new Uint8Array(headLen + 4 + len);
|
|
159
|
+
out[0] = op;
|
|
160
|
+
if (len < 126) out[1] = 0x80 | len;
|
|
161
|
+
else {
|
|
162
|
+
out[1] = 0x80 | 126;
|
|
163
|
+
out[2] = len >> 8;
|
|
164
|
+
out[3] = len & 255;
|
|
165
|
+
}
|
|
166
|
+
const mask = new Uint8Array(4);
|
|
167
|
+
crypto.getRandomValues(mask);
|
|
168
|
+
out.set(mask, headLen);
|
|
169
|
+
for (let i = 0; i < len; i++) out[headLen + 4 + i] = payload[i] ^ mask[i & 3];
|
|
170
|
+
write(out);
|
|
171
|
+
}
|
|
172
|
+
function finish(reason) {
|
|
173
|
+
if (state === "closed") return;
|
|
174
|
+
const was = state;
|
|
175
|
+
state = "closed";
|
|
176
|
+
if (was === "connecting") settle.reject(new Error(reason));
|
|
177
|
+
api.onclose?.(reason);
|
|
178
|
+
}
|
|
179
|
+
function fail(reason) {
|
|
180
|
+
if (state === "closed") return;
|
|
181
|
+
try {
|
|
182
|
+
if (state === "open") frame(0x08, new Uint8Array([0x03, 0xea]));
|
|
183
|
+
} catch {}
|
|
184
|
+
finish(`ended: ${reason}`);
|
|
185
|
+
}
|
|
186
|
+
return api;
|
|
187
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// The vm pane's emulator, loaded only when a vm pane starts a machine (src/vm/hub.js imports this file lazily, so a canvas without a started vm never fetches a byte of it).
|
|
2
|
+
// Everything comes from this app's own build: the v86 package (BSD-2-Clause), its WebAssembly and the two BIOS images beside this file (src/vm/bios/README.md). Never a CDN, never another host.
|
|
3
|
+
import wasmPath from "v86/build/v86.wasm?url";
|
|
4
|
+
import biosPath from "./bios/seabios.bin?url";
|
|
5
|
+
import vgaBiosPath from "./bios/vgabios.bin?url";
|
|
6
|
+
|
|
7
|
+
/** `{ V86, assets }`: the emulator's class and where its own files are served from (this page's origin). */
|
|
8
|
+
export async function loadV86() {
|
|
9
|
+
const { V86 } = await import("v86");
|
|
10
|
+
return { V86, assets: { wasm_path: wasmPath, bios: { url: biosPath }, vga_bios: { url: vgaBiosPath } } };
|
|
11
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
// Checking tool arguments against the (small) JSON Schema subset mallory's tools
|
|
2
|
+
// use, and finding panes by name or id. Pure: testable under Node.
|
|
3
|
+
import { padProblem, padValue, defaultPadValue, numericSelectProblem } from "../model/widget-values.js";
|
|
4
|
+
import { checkSchema } from "../model/json-schema-host.js";
|
|
5
|
+
import { readWhen, storedWhen } from "../model/when.js";
|
|
6
|
+
import { quantityProblem, storedQuantity, DEFAULT_QUANTITY } from "../model/quantity-widget.js";
|
|
7
|
+
import { storedMath, DEFAULT_MATH } from "../model/math-widget.js";
|
|
8
|
+
import { storedGrid, gridSizeProblem } from "../model/grid-widget.js";
|
|
9
|
+
|
|
10
|
+
const typeOf = (v) => (v === null ? "null" : Array.isArray(v) ? "array" : Number.isInteger(v) ? "integer" : typeof v);
|
|
11
|
+
|
|
12
|
+
/** A problem from the shared validator (src/model/json-schema.js) in the words tool errors use. `at` is the value's path prefix. */
|
|
13
|
+
function argText(p, at) {
|
|
14
|
+
const where = !p.path ? at : p.path.startsWith("[") ? `${at}${p.path}` : `${at}.${p.path}`;
|
|
15
|
+
const schema = p.schema ?? {};
|
|
16
|
+
switch (p.keyword) {
|
|
17
|
+
case "type":
|
|
18
|
+
return `${where} should be ${[].concat(schema.type).join(" or ")}, got ${typeOf(p.value)}`;
|
|
19
|
+
case "enum":
|
|
20
|
+
return `${where} should be one of ${schema.enum.map((e) => JSON.stringify(e)).join(", ")}`;
|
|
21
|
+
case "minimum":
|
|
22
|
+
return `${where} should be at least ${schema.minimum}`;
|
|
23
|
+
case "maximum":
|
|
24
|
+
return `${where} should be at most ${schema.maximum}`;
|
|
25
|
+
case "minLength":
|
|
26
|
+
return `${where} shouldn't be empty`;
|
|
27
|
+
case "required":
|
|
28
|
+
return `${where} is required`;
|
|
29
|
+
case "additionalProperties":
|
|
30
|
+
return `${where} isn't a known argument (expected: ${Object.keys(schema.properties ?? {}).join(", ") || "none"})`;
|
|
31
|
+
case "anyOf":
|
|
32
|
+
case "oneOf": {
|
|
33
|
+
if (!Array.isArray(schema[p.keyword]) || p.message.startsWith("matches ") && /^matches \d+ of/.test(p.message)) return `${where}: ${p.message}`;
|
|
34
|
+
const tries = schema[p.keyword].map((alt) => checkArgs(alt, p.value, where));
|
|
35
|
+
return `${where}: ${schema.description ?? "doesn't match any allowed form"} (${tries.map((t) => t[0]).join("; or ")})`;
|
|
36
|
+
}
|
|
37
|
+
default:
|
|
38
|
+
return `${where}: ${p.message}`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Problems with `value` against `schema`, as messages; empty means valid. The checking is
|
|
44
|
+
* the shared JSON Schema validator's (src/model/json-schema.js: type, enum, required,
|
|
45
|
+
* properties, additionalProperties, items, bounds, formats, oneOf/anyOf, …); this only
|
|
46
|
+
* words the problems the way tool errors always have been, `path` naming the value.
|
|
47
|
+
*/
|
|
48
|
+
export function checkArgs(schema, value, path = "arguments") {
|
|
49
|
+
if (!schema || typeof schema !== "object") return [];
|
|
50
|
+
const found = checkSchema(schema, value, { limit: 50 });
|
|
51
|
+
const wrongType = new Set(found.filter((p) => p.keyword === "type").map((p) => p.path));
|
|
52
|
+
return found.filter((p) => p.keyword === "type" || !wrongType.has(p.path)).map((p) => argText(p, path));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Find one pane by id, else by name (exact, then case-insensitive), among
|
|
57
|
+
* `panes` ({ id, name, type }[]). Throws a message that lists what exists.
|
|
58
|
+
*/
|
|
59
|
+
export function resolvePane(panes, ref) {
|
|
60
|
+
const key = String(ref ?? "").trim();
|
|
61
|
+
if (!key) throw new Error("No pane given. Use a pane's name or id from mallory_list_panes.");
|
|
62
|
+
const byId = panes.find((p) => p.id === key);
|
|
63
|
+
if (byId) return byId;
|
|
64
|
+
const exact = panes.filter((p) => p.name === key);
|
|
65
|
+
if (exact.length === 1) return exact[0];
|
|
66
|
+
const loose = exact.length ? exact : panes.filter((p) => (p.name ?? "").toLowerCase() === key.toLowerCase());
|
|
67
|
+
if (loose.length === 1) return loose[0];
|
|
68
|
+
const list = panes.map((p) => (p.name ? `${p.name} (${p.id})` : p.id)).join(", ") || "none";
|
|
69
|
+
if (loose.length > 1) throw new Error(`More than one pane is called "${key}": ${loose.map((p) => p.id).join(", ")}. Use an id.`);
|
|
70
|
+
throw new Error(`No pane "${key}". Panes on this canvas: ${list}.`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Normalize an `inputs` argument: each entry is a pane name or id, or
|
|
75
|
+
* `{ from, as }` (`as` renames the variable). Returns `[{ source, name? }]`.
|
|
76
|
+
*/
|
|
77
|
+
export function resolveInputs(panes, inputs = []) {
|
|
78
|
+
return inputs.map((entry) => {
|
|
79
|
+
const ref = typeof entry === "string" ? entry : entry?.from;
|
|
80
|
+
const pane = resolvePane(panes, ref);
|
|
81
|
+
const as = typeof entry === "object" && entry?.as ? String(entry.as) : undefined;
|
|
82
|
+
// A named output of the source, and the input's port: its type, convert, description (src/model/ports.js).
|
|
83
|
+
const port = typeof entry === "object" && entry ? Object.fromEntries(["output", "type", "convert", "description", "operators"].filter((k) => entry[k] !== undefined).map((k) => [k, entry[k]])) : {};
|
|
84
|
+
return { source: pane.id, ...(as ? { name: as } : {}), ...port };
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The stored widget value for an input pane, from the value an agent passed.
|
|
90
|
+
* Throws when it doesn't suit the widget's kind.
|
|
91
|
+
*/
|
|
92
|
+
export function widgetValueFrom(widget, value, now = Date.now()) {
|
|
93
|
+
const kind = widget?.kind ?? "number";
|
|
94
|
+
switch (kind) {
|
|
95
|
+
case "number":
|
|
96
|
+
case "range": {
|
|
97
|
+
const n = typeof value === "string" && value.trim() !== "" ? Number(value) : value;
|
|
98
|
+
if (typeof n !== "number" || !Number.isFinite(n)) throw new Error(`This ${kind} input needs a number.`);
|
|
99
|
+
if (kind === "range" && ((widget.min !== undefined && n < widget.min) || (widget.max !== undefined && n > widget.max))) {
|
|
100
|
+
throw new Error(`This range input goes from ${widget.min} to ${widget.max}.`);
|
|
101
|
+
}
|
|
102
|
+
return n;
|
|
103
|
+
}
|
|
104
|
+
case "checkbox":
|
|
105
|
+
if (typeof value === "boolean") return value;
|
|
106
|
+
if (value === "true" || value === "false") return value === "true";
|
|
107
|
+
throw new Error("This checkbox input needs true or false.");
|
|
108
|
+
case "select": {
|
|
109
|
+
const options = String(widget.options ?? "a,b,c").split(",").map((s) => s.trim()).filter(Boolean);
|
|
110
|
+
const v = String(value);
|
|
111
|
+
const notNumbers = widget.numeric ? numericSelectProblem({ ...widget, value: undefined }) : "";
|
|
112
|
+
if (notNumbers) throw new Error(`This select input is numeric, but ${notNumbers}.`);
|
|
113
|
+
if (!options.includes(v)) throw new Error(`This select input's options are: ${options.join(", ")}.`);
|
|
114
|
+
return v;
|
|
115
|
+
}
|
|
116
|
+
case "json":
|
|
117
|
+
case "form": {
|
|
118
|
+
// A string is taken as JSON text (it must parse); anything else is stored as its JSON.
|
|
119
|
+
if (typeof value === "string") {
|
|
120
|
+
try {
|
|
121
|
+
JSON.parse(value);
|
|
122
|
+
} catch {
|
|
123
|
+
throw new Error(`This ${kind} input needs valid JSON text (or a JSON value).`);
|
|
124
|
+
}
|
|
125
|
+
return value;
|
|
126
|
+
}
|
|
127
|
+
return JSON.stringify(value ?? null);
|
|
128
|
+
}
|
|
129
|
+
case "xy":
|
|
130
|
+
case "curve": {
|
|
131
|
+
// Plain JSON: { x, y }, or { interpolation, points: [{ x, y }, …] } (a JSON string of one is taken too).
|
|
132
|
+
let given = value;
|
|
133
|
+
if (typeof given === "string") {
|
|
134
|
+
try {
|
|
135
|
+
given = JSON.parse(given);
|
|
136
|
+
} catch {
|
|
137
|
+
throw new Error(`This ${kind} input needs ${kind === "xy" ? "{ x, y }" : "{ interpolation, points: [{ x, y }, …] }"}.`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const rangeIssue = padProblem({ ...widget, value: undefined });
|
|
141
|
+
if (rangeIssue) throw new Error(`This ${kind} input: ${rangeIssue}.`);
|
|
142
|
+
if (given === undefined) return defaultPadValue(kind, widget);
|
|
143
|
+
const problem = padProblem({ ...widget, value: given });
|
|
144
|
+
if (problem) throw new Error(`This ${kind} input: ${problem}.`);
|
|
145
|
+
return padValue({ ...widget, value: given });
|
|
146
|
+
}
|
|
147
|
+
case "when": {
|
|
148
|
+
// A time in words, read now and stored as an instant (src/model/when.js). The stored form (kept when only the zone or
|
|
149
|
+
// the kind changes) stays as it is unless the zone it was read in changed: then the phrase is read again.
|
|
150
|
+
if (value === undefined || value === null || value === "") return "";
|
|
151
|
+
const zone = String(widget.zone ?? "");
|
|
152
|
+
const stored = storedWhen(value);
|
|
153
|
+
if (stored && stored.zone === zone) return value;
|
|
154
|
+
const text = stored ? stored.text : value !== null && typeof value === "object" ? value.text : value;
|
|
155
|
+
const read = readWhen(typeof text === "string" ? text : "", { zone, now });
|
|
156
|
+
if (!read.ok) throw new Error(`This when input: ${read.error}.`);
|
|
157
|
+
return read.value;
|
|
158
|
+
}
|
|
159
|
+
case "quantity": {
|
|
160
|
+
// Text such as "5 km", or { value, unit }: kept as text, read against the widget's dimension and unit (src/model/quantity-widget.js).
|
|
161
|
+
const problem = quantityProblem(widget);
|
|
162
|
+
if (problem) throw new Error(`This quantity input: ${problem}.`);
|
|
163
|
+
if (value === undefined) return DEFAULT_QUANTITY;
|
|
164
|
+
try {
|
|
165
|
+
return storedQuantity(value, widget);
|
|
166
|
+
} catch (error) {
|
|
167
|
+
throw new Error(`This quantity input ${/^needs /.test(error.message) ? "" : "can't take that: "}${error.message}.`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
case "grid": {
|
|
171
|
+
// Grid text (WxH:bits), rows of 0 and 1, a list of live cells, or JSON text of one of those: kept as the canonical text, in the widget's size.
|
|
172
|
+
const sizeIssue = gridSizeProblem(widget);
|
|
173
|
+
if (sizeIssue) throw new Error(`This grid input: ${sizeIssue}.`);
|
|
174
|
+
try {
|
|
175
|
+
let given = value;
|
|
176
|
+
if (typeof given === "string" && /^\s*\[/.test(given)) given = JSON.parse(given);
|
|
177
|
+
return storedGrid(given, widget);
|
|
178
|
+
} catch (error) {
|
|
179
|
+
throw new Error(`This grid input can't take that: ${error.message}.`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
case "math": {
|
|
183
|
+
// LaTeX text, or { latex }: kept as text, checked by the adapter that reads it as an expression (src/model/math-widget.js).
|
|
184
|
+
if (value === undefined) return DEFAULT_MATH;
|
|
185
|
+
try {
|
|
186
|
+
return storedMath(value);
|
|
187
|
+
} catch (error) {
|
|
188
|
+
throw new Error(`This math input ${/^needs /.test(error.message) ? "" : "can't take that: "}${error.message}.`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
case "color":
|
|
192
|
+
if (typeof value !== "string" || !/^#[0-9a-f]{6}$/i.test(value)) throw new Error('This color input needs a "#rrggbb" string.');
|
|
193
|
+
return value;
|
|
194
|
+
case "date":
|
|
195
|
+
if (typeof value !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(value)) throw new Error('This date input needs a "YYYY-MM-DD" string.');
|
|
196
|
+
return value;
|
|
197
|
+
default:
|
|
198
|
+
if (value !== null && typeof value === "object") throw new Error(`This ${kind} input needs text.`);
|
|
199
|
+
return String(value ?? "");
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* A new pane's corner on the person's grid, as the page snaps a dragged pane
|
|
205
|
+
* : `host.snapRect` puts it on the square grid or its centre on the
|
|
206
|
+
* polar one; without a page (headless, tests) it stays where it is.
|
|
207
|
+
*/
|
|
208
|
+
export function placeOnGrid(host, c, p, size = {}) {
|
|
209
|
+
const rect = { x: p.x, y: p.y, width: size.width ?? 300, height: size.height ?? 160 };
|
|
210
|
+
const at = host.snapRect?.(rect, c) ?? rect;
|
|
211
|
+
return { x: Math.round(at.x), y: Math.round(at.y) };
|
|
212
|
+
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
// The one place that says which panes' values an agent never reads, and what it reads in their place (wave P-H). Every WebMCP output that can carry
|
|
2
|
+
// something a pane computed goes through `hiddenText` / `hiddenPanes` (src/webmcp/tools.js summary and detail, wire-tools.js, run-tools.js, runs.js,
|
|
3
|
+
// canvases.js, test-tools and the pin tool): test/webmcp-hidden.test.mjs walks every tool against it.
|
|
4
|
+
//
|
|
5
|
+
// A pane is hidden when it holds, or is computed from:
|
|
6
|
+
// - a live camera, microphone or screen capture (src/model/device-hub.js captured()), or
|
|
7
|
+
// - a capture log: a traffic pane, or an http pane in tap or proxy mode (their entries carry the network policy's verdict and its reasons). An agent
|
|
8
|
+
// reads a log through mallory_traffic only, which is narrower than the entries and gated by the person's box.
|
|
9
|
+
// - a ws-client pane, in either mode: its value is a socket's frames (what a server sent, or what a served socket relayed). A frame is not a traffic entry
|
|
10
|
+
// (the tool reads no frames), so it is read by no agent at all; the person reads it in the pane.
|
|
11
|
+
// "Computed from" follows every edge a value can take, and where the walk can't be exact it is conservative:
|
|
12
|
+
// - wires (value, event and setter wires), a setter's target and the state panes sharing its key;
|
|
13
|
+
// - a subgraph or repeater pane that holds a log anywhere inside it, and every pane of a canvas opened inside a hidden host or an instance of one;
|
|
14
|
+
// - contexts: a pane reading a context whose provider is hidden;
|
|
15
|
+
// - named channels: once a canvas holds a log, every pane that receives a channel is hidden (a send can come from any hidden pane's code).
|
|
16
|
+
// Residual, said in docs/design/traffic.md: code that moves a value by a path that isn't an edge (a shared global the sandbox doesn't give panes) is not followed.
|
|
17
|
+
import { trait, paneType } from "../panes/registry.js";
|
|
18
|
+
import { PORT_SEP } from "../model/ports.js";
|
|
19
|
+
import { CAPTURE_HIDDEN, capturedPanes } from "./text.js";
|
|
20
|
+
import { contextNames, subgraphNeeds, providerOf, isContextNode } from "../model/context.js";
|
|
21
|
+
import { channelsOf, channelsInside } from "../model/channels.js";
|
|
22
|
+
|
|
23
|
+
/** In place of the value of a capture log the person has not let agents read (the pane's own box; the grant is kept in the browser, never in the canvas). */
|
|
24
|
+
export const TRAFFIC_WITHHELD = "(withheld: a capture log. Only the person can let agents read it, in the pane's own box.)";
|
|
25
|
+
/** In place of the value of an allowed capture log: agents read it with the tool, which leaves out the network rules' reasons. */
|
|
26
|
+
export const TRAFFIC_VIA_TOOL = "(a capture log: read it with mallory_traffic)";
|
|
27
|
+
/** In place of the value of an http pane that records this canvas's requests. */
|
|
28
|
+
export const TRAFFIC_SOURCE = "(a record of this canvas's requests, with the network rules' reasons: agents read it through a traffic pane the person has allowed, with mallory_traffic)";
|
|
29
|
+
/** In place of the value of a pane computed from a capture log. */
|
|
30
|
+
export const TRAFFIC_DERIVED = "(hidden: computed from a capture log. Read the log with mallory_traffic, once the person has allowed it.)";
|
|
31
|
+
|
|
32
|
+
/** Does this pane (a live pane or its saved content) hold a capture log? */
|
|
33
|
+
export const isLogSource = (pane) => Boolean(pane && (trait(pane.type, "captureLog") || paneType(pane.type)?.captureLogWhen?.(pane)));
|
|
34
|
+
|
|
35
|
+
const isObject = (v) => v !== null && typeof v === "object";
|
|
36
|
+
|
|
37
|
+
/** Is a log anywhere inside this pane's saved content (a subgraph's graph, a repeater's templates), at any depth? */
|
|
38
|
+
export function containsLog(pane) {
|
|
39
|
+
const inner = [...(pane?.graph?.panes ?? []), ...Object.values(isObject(pane?.each?.templates) ? pane.each.templates : {}).flatMap((t) => t?.graph?.panes ?? [])];
|
|
40
|
+
return inner.some((p) => isObject(p) && (isLogSource(p) || containsLog(p)));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Has the person let agents read this traffic pane? Only a pane of the root canvas can be allowed; a page without the adapter allows nothing. */
|
|
44
|
+
export function logAllowed(c, pane) {
|
|
45
|
+
const root = c?.root ?? c;
|
|
46
|
+
return Boolean(pane && trait(pane.type, "captureLog") && root === c && root.trafficAccess?.granted?.(root.id, pane));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const logText = (c, pane) => (paneType(pane.type)?.captureLogFrames ?? (trait(pane.type, "captureLog") ? (logAllowed(c, pane) ? TRAFFIC_VIA_TOOL : TRAFFIC_WITHHELD) : TRAFFIC_SOURCE));
|
|
50
|
+
|
|
51
|
+
/** Does this pane receive a named channel, or hold a pane that does? */
|
|
52
|
+
const receivesChannel = (pane) => Boolean(channelsOf(pane).receives) || channelsInside(pane).receives.length > 0;
|
|
53
|
+
|
|
54
|
+
const idOf = (node) => String(node).split(PORT_SEP)[0];
|
|
55
|
+
|
|
56
|
+
/** Is there a log anywhere in this canvas, or in one it is inside or holds? */
|
|
57
|
+
function treeHasLog(c) {
|
|
58
|
+
const root = c.root ?? c;
|
|
59
|
+
return [...root.panes.values()].some((p) => isLogSource(p) || containsLog(p));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Every hidden pane of `c` with what an agent reads instead of its value (a Map: `.has`, `.get`). Worked out afresh each time: a tool that adds a pane and then describes it must see it. */
|
|
63
|
+
export function hiddenOf(c) {
|
|
64
|
+
const out = new Map();
|
|
65
|
+
if (c?.panes) compute(c, out);
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function compute(c, out) {
|
|
70
|
+
for (const id of capturedPanes(c)) out.set(id, CAPTURE_HIDDEN);
|
|
71
|
+
// Inside a hidden host (or an instance of one) every pane is read as computed from it.
|
|
72
|
+
if (c.parent && c.subgraphId !== undefined && hiddenOf(c.parent).has(c.subgraphId)) {
|
|
73
|
+
for (const id of c.panes.keys()) if (!out.has(id)) out.set(id, TRAFFIC_DERIVED);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const taint = new Set(out.keys());
|
|
77
|
+
for (const [id, pane] of c.panes) {
|
|
78
|
+
if (out.has(id)) continue;
|
|
79
|
+
if (isLogSource(pane)) out.set(id, logText(c, pane));
|
|
80
|
+
else if (containsLog(pane) || pane.http?.fromLog === true) out.set(id, TRAFFIC_DERIVED); // (a replay pane copied its fields from a log entry)
|
|
81
|
+
else continue;
|
|
82
|
+
taint.add(id);
|
|
83
|
+
}
|
|
84
|
+
if (!taint.size && !treeHasLog(c)) return;
|
|
85
|
+
const anyLog = taint.size > 0 || treeHasLog(c);
|
|
86
|
+
const add = (id) => {
|
|
87
|
+
if (!c.panes.has(id) || taint.has(id)) return false;
|
|
88
|
+
taint.add(id);
|
|
89
|
+
if (!out.has(id)) out.set(id, TRAFFIC_DERIVED);
|
|
90
|
+
return true;
|
|
91
|
+
};
|
|
92
|
+
let grew = true;
|
|
93
|
+
while (grew) {
|
|
94
|
+
grew = false;
|
|
95
|
+
// Wires, read from the panes' own inputs (a pane just added has no node in the dataflow yet), and from the dataflow too.
|
|
96
|
+
for (const [id, pane] of c.panes) {
|
|
97
|
+
if (taint.has(id)) continue;
|
|
98
|
+
if ((pane.inputs ?? []).some((i) => i?.source !== undefined && (taint.has(idOf(i.source)) || taint.has(idOf(c.homeOf?.(i.source)?.node ?? i.source))))) if (add(id)) grew = true;
|
|
99
|
+
}
|
|
100
|
+
const stack = [...taint];
|
|
101
|
+
const walked = new Set(stack);
|
|
102
|
+
while (stack.length) {
|
|
103
|
+
for (const dep of c.flow?.dependents?.(stack.pop()) ?? []) {
|
|
104
|
+
if (walked.has(dep)) continue;
|
|
105
|
+
walked.add(dep);
|
|
106
|
+
stack.push(dep); // an output's own node (`id#output`) has readers of its own
|
|
107
|
+
if (add(idOf(dep))) grew = true;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
for (const id of [...taint]) for (const s of c.settersOf?.(id) ?? []) if (add(idOf(s.source))) grew = true; // a setter writes a state pane
|
|
111
|
+
const keys = new Set([...taint].map((id) => c.panes.get(id)?.key).filter((k) => typeof k === "string" && k));
|
|
112
|
+
if (keys.size) for (const [id, pane] of c.panes) if (typeof pane.key === "string" && keys.has(pane.key) && add(id)) grew = true; // state panes that share a key share the value
|
|
113
|
+
if (anyLog) for (const [id, pane] of c.panes) if (receivesChannel(pane) && add(id)) grew = true; // a channel can carry any hidden pane's send
|
|
114
|
+
// A context whose provider is hidden: every subgraph that needs it (a pane that reads a context by an input is inside such a subgraph, so it is hidden with it: the canvas opened
|
|
115
|
+
// inside a hidden host hides every pane, above), however the dataflow is wired right now.
|
|
116
|
+
const hiddenNames = new Set();
|
|
117
|
+
for (const name of contextNames(c)) {
|
|
118
|
+
const found = providerOf(c, name);
|
|
119
|
+
if (found && (found.canvas === c ? taint.has(found.id) : hiddenOf(found.canvas).has(found.id))) hiddenNames.add(name);
|
|
120
|
+
}
|
|
121
|
+
if (hiddenNames.size) {
|
|
122
|
+
for (const [id, pane] of c.panes) {
|
|
123
|
+
if ([...subgraphNeeds(pane)].some((n) => hiddenNames.has(n))) if (add(id)) grew = true;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** What replaces a pane's value for an agent, or undefined when the agent may read it. */
|
|
130
|
+
export const hiddenText = (c, id) => hiddenOf(c).get(id);
|
|
131
|
+
|
|
132
|
+
/** Every hidden pane id with its text, for the tools that read many panes. */
|
|
133
|
+
export const hiddenPanes = (c) => hiddenOf(c);
|
|
134
|
+
|
|
135
|
+
/** The capture-log panes and what is computed from them (not live captures). */
|
|
136
|
+
export const logHidden = (c) => new Map([...hiddenOf(c)].filter(([, text]) => text !== CAPTURE_HIDDEN));
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Why `pane`'s own log can't be read as the person's grant: a traffic pane that takes anything from another capture log, or from a pane computed from
|
|
140
|
+
* one, would carry that pane's entries (or a hidden value shaped like an entry) out through a box the person ticked for this pane only. Its upstream
|
|
141
|
+
* may hold only plain sources and the http panes that record this canvas's requests. Returns text, or "".
|
|
142
|
+
*/
|
|
143
|
+
export function upstreamProblem(c, pane) {
|
|
144
|
+
const seen = new Set([pane.id]);
|
|
145
|
+
const stack = [pane.id];
|
|
146
|
+
const hidden = hiddenOf(c);
|
|
147
|
+
while (stack.length) {
|
|
148
|
+
const here = c.panes.get(stack.pop());
|
|
149
|
+
for (const input of here?.inputs ?? []) {
|
|
150
|
+
const { node } = c.homeOf(input.source);
|
|
151
|
+
if (isContextNode(node)) return "it reads a context";
|
|
152
|
+
const id = idOf(node);
|
|
153
|
+
if (seen.has(id)) continue;
|
|
154
|
+
seen.add(id);
|
|
155
|
+
const upstream = c.panes.get(id);
|
|
156
|
+
if (!upstream) continue;
|
|
157
|
+
if (paneType(upstream.type)?.captureLogFrames) return `it takes frames from a socket (${upstream.name || id})`;
|
|
158
|
+
if (trait(upstream.type, "captureLog")) return `it takes entries from another capture log (${upstream.name || id})`;
|
|
159
|
+
if (hidden.has(id) && !isLogSource(upstream)) return `it takes a value computed from a capture log (${upstream.name || id})`;
|
|
160
|
+
stack.push(id);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return "";
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const hiddenPin = (pin, text) => ({ ...(pin?.at !== undefined ? { at: pin.at } : {}), ...(pin?.source !== undefined ? { source: pin.source } : {}), hidden: text });
|
|
167
|
+
|
|
168
|
+
/** A pane's saved content without what it copied from a log: a replay pane's address, headers and body. */
|
|
169
|
+
function withoutLogFields(pane) {
|
|
170
|
+
const out = { ...pane };
|
|
171
|
+
if (out.http?.fromLog === true) out.http = { ...out.http, compose: { method: "GET", url: "(withheld)", headers: [], query: [], body: "" } };
|
|
172
|
+
if (out.graph?.panes) out.graph = { ...out.graph, panes: out.graph.panes.map(withoutLogFields) };
|
|
173
|
+
if (isObject(out.each?.templates)) out.each = { ...out.each, templates: Object.fromEntries(Object.entries(out.each.templates).map(([k, t]) => [k, t?.graph?.panes ? { ...t, graph: { ...t.graph, panes: t.graph.panes.map(withoutLogFields) } } : t])) };
|
|
174
|
+
return out;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** A pane's saved content with every pin inside it (a hidden host's inner panes') replaced: a pin keeps a value in the document. */
|
|
178
|
+
function withoutPins(pane, text) {
|
|
179
|
+
const out = { ...pane };
|
|
180
|
+
if (out.pin) out.pin = hiddenPin(out.pin, text);
|
|
181
|
+
if (out.graph?.panes) out.graph = { ...out.graph, panes: out.graph.panes.map((p) => withoutPins(p, text)) };
|
|
182
|
+
if (isObject(out.each?.templates)) out.each = { ...out.each, templates: Object.fromEntries(Object.entries(out.each.templates).map(([k, t]) => [k, t?.graph?.panes ? { ...t, graph: { ...t.graph, panes: t.graph.panes.map((p) => withoutPins(p, text)) } } : t])) };
|
|
183
|
+
return out;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* A saved or restored document that is not the open canvas (so `hiddenOf` knows nothing of it): what a pane copied from a log is left out, and the pins of a
|
|
188
|
+
* log or of what holds one are hidden, by the panes' own settings. Conservative: it hides by what a pane is, not by what is wired to it.
|
|
189
|
+
*/
|
|
190
|
+
export function agentDocOf(doc) {
|
|
191
|
+
if (!Array.isArray(doc?.panes)) return doc;
|
|
192
|
+
const one = (p) => withoutServing(withoutLogFields(isObject(p) && (isLogSource(p) || containsLog(p)) ? withoutPins(p, TRAFFIC_DERIVED) : p));
|
|
193
|
+
return { ...doc, panes: doc.panes.map(one) };
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** A pane without the person's `serveMcp` mark (`mallory serve --mcp`, src/headless/mcp-endpoint.js): which panes are served is the person's, and an agent neither sets nor reads it (inside subgraphs too). */
|
|
197
|
+
function withoutServing(p) {
|
|
198
|
+
if (!isObject(p)) return p;
|
|
199
|
+
const { serveMcp, ...rest } = p;
|
|
200
|
+
return Array.isArray(rest.graph?.panes) ? { ...rest, graph: { ...rest.graph, panes: rest.graph.panes.map(withoutServing) } } : rest;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** Settings of pane `id` as a tool may echo them back (a "previous" value): a hidden pane's pin, and what a replay pane copied from a log, are left out. */
|
|
204
|
+
export function agentFields(c, id, fields) {
|
|
205
|
+
const hidden = hiddenOf(c).get(id);
|
|
206
|
+
const out = withoutLogFields({ ...fields });
|
|
207
|
+
return hidden && out.pin ? withoutPins(out, hidden) : out;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* A canvas document (or a list of panes' content) as an agent may read it: the pins of hidden panes hold a value in the document, so they read as
|
|
212
|
+
* "hidden". Everything else in a document is what its author wrote, which an agent reads anyway.
|
|
213
|
+
*/
|
|
214
|
+
export function agentDoc(c, doc) {
|
|
215
|
+
const hid = hiddenOf(c);
|
|
216
|
+
if (!Array.isArray(doc?.panes)) return doc;
|
|
217
|
+
return { ...doc, panes: doc.panes.map((p) => withoutServing(withoutLogFields(hid.has(p.id) ? withoutPins(p, hid.get(p.id)) : p))) };
|
|
218
|
+
}
|