@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,360 @@
|
|
|
1
|
+
// The subgraphs tool group (src/webmcp/groups.js): its tools, as specs for createTools (src/webmcp/tools.js).
|
|
2
|
+
import { groupPanes, ungroupPane, groupToSubgraph } from "../../model/subgraph.js";
|
|
3
|
+
import { createGroup, updateGroup, deleteGroup, removeFromGroup, dropInGroup, groupStyle, pasteGroupStyle } from "../../model/groups.js";
|
|
4
|
+
import { COLORS, isColor } from "../../panes/colors.js";
|
|
5
|
+
import { insertSaved, linksByDefault, linkSource, planUpdate, acceptUpdate, detachLinked } from "../../model/links.js";
|
|
6
|
+
import { repeatOn, instancesOf } from "../../model/repeater.js";
|
|
7
|
+
import { paneSignature } from "../../packages/package.js";
|
|
8
|
+
import { deprecationOf } from "../../packages/deprecation.js";
|
|
9
|
+
import { formatDiff, diffCanvases } from "../../model/diff.js";
|
|
10
|
+
import { paneRef, timeoutArg, waitArg, guardWrite, guardWriteAll } from "./shared.js";
|
|
11
|
+
import { paneKindError } from "../../util/text.js";
|
|
12
|
+
|
|
13
|
+
/** The subgraphs group's tool specs. `ctx` is the helpers createTools builds (the canvas, finding panes, summaries, waiting). */
|
|
14
|
+
export function subgraphsTools(ctx) {
|
|
15
|
+
const { host, canvas, find, nameOf, requireTrusted, noticeWithReplacement, linkWhere, summary, groupSummary, findGroup, waitForAll, afterChange, placeNear, replaceDeprecatedTemplate, updateTemplate, replaceDeprecated, savedCanvases, findSaved } = ctx;
|
|
16
|
+
return [
|
|
17
|
+
{
|
|
18
|
+
name: "group_panes",
|
|
19
|
+
title: "Group panes into a subgraph",
|
|
20
|
+
description:
|
|
21
|
+
"Replace panes with one subgraph pane that holds them (a function pane). Inputs from outside become the subgraph's inputs, named as the panes inside called them; panes outside that used a grouped pane keep their inputs, now wired from the subgraph pane. Its value is its last pane's (several: an object keyed by name). One undo step (mallory_undo); mallory_ungroup_pane reverses it.",
|
|
22
|
+
input: {
|
|
23
|
+
type: "object",
|
|
24
|
+
properties: { panes: { type: "array", minItems: 1, items: paneRef("A pane to group"), description: "The panes to group." }, name: { type: "string", description: "The subgraph pane's name (default \"group\")." }, wait: waitArg, timeoutMs: timeoutArg },
|
|
25
|
+
required: ["panes"],
|
|
26
|
+
additionalProperties: false,
|
|
27
|
+
},
|
|
28
|
+
async run(args) {
|
|
29
|
+
const c = canvas();
|
|
30
|
+
const ids = args.panes.map((ref) => (guardWrite(find(c, ref), "group"), find(c, ref).id));
|
|
31
|
+
const id = groupPanes(c, ids, args.name ? { name: args.name.trim() } : {});
|
|
32
|
+
host.select?.(id);
|
|
33
|
+
return { ...(await afterChange(c, id, args)), grouped: ids.map((g) => nameOf(c, g)) };
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "ungroup_pane",
|
|
38
|
+
title: "Ungroup a subgraph pane",
|
|
39
|
+
description: "Put a subgraph pane's panes back on the canvas where it is (the inverse of mallory_group_panes): its inputs are wired straight to the panes inside again. One undo step.",
|
|
40
|
+
input: { type: "object", properties: { pane: paneRef("The subgraph pane") }, required: ["pane"], additionalProperties: false },
|
|
41
|
+
run({ pane }) {
|
|
42
|
+
const c = canvas();
|
|
43
|
+
const p = find(c, pane);
|
|
44
|
+
guardWrite(p, "ungroup");
|
|
45
|
+
if (p.type !== "subgraph") throw new Error(paneKindError(`"${p.name || p.id}" is`, p.type, "subgraph", ".", { typeArticle: "a", wantNoun: "" }));
|
|
46
|
+
const made = ungroupPane(c, p.id);
|
|
47
|
+
return { ungrouped: p.name || p.id, panes: made.map((id) => nameOf(c, id)), undo: "mallory_undo groups them again." };
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "group",
|
|
52
|
+
title: "Group panes in a frame",
|
|
53
|
+
description: [
|
|
54
|
+
"Groups (frames): a named, colored rectangle around panes that moves them together. Groups nest one level (a group inside another holds some of its panes); two groups otherwise share no pane.",
|
|
55
|
+
'`action`: "create" (a group of `panes`, with `name`, `color`, `description`), "update" (a group\'s `name`, `color`, `description`, `disabled` to deactivate every pane in it, or `collapsed` to collapse or expand its panes), "delete" (remove the frame; the panes stay), "add" / "remove" (`panes` into or out of the group, as dropping them in or dragging them out of its frame does: added panes leave their other groups; a group left with no panes is deleted), "run" (run its panes now), "arrange" (tidy its panes by their dataflow), "paste_style" (give the groups `to` the style, the color, of the group `from`; nothing else changes) or "to_subgraph" (replace its panes with one subgraph pane).',
|
|
56
|
+
"Name the group with `group` (its name or id, from mallory_list_panes). Creating, changing, deleting, adding and removing are undoable (mallory_undo), as is to_subgraph. Returns the group, or what changed.",
|
|
57
|
+
],
|
|
58
|
+
input: {
|
|
59
|
+
type: "object",
|
|
60
|
+
properties: {
|
|
61
|
+
action: { type: "string", enum: ["create", "update", "delete", "add", "remove", "run", "arrange", "paste_style", "to_subgraph"], description: "What to do." },
|
|
62
|
+
group: { type: "string", minLength: 1, description: "The group: its name or id (not for create)." },
|
|
63
|
+
panes: { type: "array", minItems: 1, items: paneRef("A pane"), description: "create, add, remove: the panes." },
|
|
64
|
+
name: { type: "string", minLength: 1, description: "create, update: the group's name." },
|
|
65
|
+
color: { type: "string", description: `create, update: ${COLORS.join(", ")}, or "#rrggbb".` },
|
|
66
|
+
description: { type: "string", description: "create, update: what the group does (Markdown)." },
|
|
67
|
+
disabled: { type: "boolean", description: 'update: deactivate every pane in the group (they skip with "deactivated"), or reactivate them.' },
|
|
68
|
+
collapsed: { type: "boolean", description: "update: collapse every pane in the group to its header, or expand them." },
|
|
69
|
+
from: { type: "string", minLength: 1, description: "paste_style: the group whose style is copied (its name or id)." },
|
|
70
|
+
to: { type: "array", minItems: 1, items: { type: "string", minLength: 1, description: "A group's name or id." }, description: "paste_style: the groups that get the style. One undo step." },
|
|
71
|
+
wait: waitArg,
|
|
72
|
+
timeoutMs: timeoutArg,
|
|
73
|
+
},
|
|
74
|
+
required: ["action"],
|
|
75
|
+
additionalProperties: false,
|
|
76
|
+
},
|
|
77
|
+
async run(args) {
|
|
78
|
+
const c = canvas();
|
|
79
|
+
const live = (id) => c.attached.has(id);
|
|
80
|
+
const ids = (args.panes ?? []).map((ref) => find(c, ref).id);
|
|
81
|
+
const needPanes = () => {
|
|
82
|
+
if (!ids.length) throw new Error(`"${args.action}" needs \`panes\`.`);
|
|
83
|
+
};
|
|
84
|
+
if (args.action === "create") {
|
|
85
|
+
needPanes();
|
|
86
|
+
if (args.color !== undefined && !isColor(args.color)) throw new Error(`A group's color is one of ${COLORS.join(", ")}, or "#rrggbb".`);
|
|
87
|
+
const made = createGroup(c.groups, ids, { name: args.name?.trim() || "group", ...(args.color !== undefined ? { color: args.color } : {}), description: args.description ?? "", live });
|
|
88
|
+
c.setGroups(made.groups);
|
|
89
|
+
return { created: groupSummary(c, c.groups.find((g) => g.id === made.id)), undo: "mallory_undo removes it." };
|
|
90
|
+
}
|
|
91
|
+
if (args.action === "paste_style") {
|
|
92
|
+
if (!args.from) throw new Error('"paste_style" needs `from` (the group whose style to copy: its name or id).');
|
|
93
|
+
if (!args.to?.length) throw new Error('"paste_style" needs `to` (the groups that get the style).');
|
|
94
|
+
const style = groupStyle(findGroup(c, args.from));
|
|
95
|
+
const targets = [...new Map(args.to.map((ref) => findGroup(c, ref)).map((t) => [t.id, t])).values()];
|
|
96
|
+
c.setGroups(pasteGroupStyle(c.groups, targets.map((t) => t.id), style));
|
|
97
|
+
return { updated: targets.map((t) => groupSummary(c, c.groups.find((o) => o.id === t.id))), style, undo: "mallory_undo puts the colors back." };
|
|
98
|
+
}
|
|
99
|
+
if (!args.group) throw new Error(`"${args.action}" needs \`group\` (its name or id).`);
|
|
100
|
+
const g = findGroup(c, args.group);
|
|
101
|
+
const members = () => c.groups.find((o) => o.id === g.id)?.panes.filter(live) ?? [];
|
|
102
|
+
switch (args.action) {
|
|
103
|
+
case "update": {
|
|
104
|
+
if (args.disabled !== undefined || args.collapsed !== undefined) guardWriteAll(c, g.panes, "deactivate or collapse");
|
|
105
|
+
const patch = Object.fromEntries(["name", "color", "description", "disabled"].filter((k) => args[k] !== undefined).map((k) => [k, k === "name" ? args.name.trim() : args[k]]));
|
|
106
|
+
if (!Object.keys(patch).length && args.collapsed === undefined) throw new Error("Nothing to change: pass name, color, description, disabled or collapsed.");
|
|
107
|
+
if (Object.keys(patch).length) c.setGroups(updateGroup(c.groups, g.id, patch));
|
|
108
|
+
if (args.collapsed !== undefined) {
|
|
109
|
+
for (const id of members()) c.update(id, { collapsed: args.collapsed });
|
|
110
|
+
for (const id of members()) host.refresh?.(id, ["collapsed"]);
|
|
111
|
+
}
|
|
112
|
+
if (args.disabled !== undefined) await waitForAll(c, args.wait === false ? 0 : (args.timeoutMs ?? 10000));
|
|
113
|
+
return { updated: groupSummary(c, c.groups.find((o) => o.id === g.id)), ...(args.disabled !== undefined ? { panes: members().map((id) => summary(c, id)) } : {}) };
|
|
114
|
+
}
|
|
115
|
+
case "delete":
|
|
116
|
+
c.setGroups(deleteGroup(c.groups, g.id));
|
|
117
|
+
return { deleted: g.name, undo: "mallory_undo brings the frame back." };
|
|
118
|
+
case "add": {
|
|
119
|
+
// Like dropping the panes in its frame: they leave any other group they are in (one emptied goes away).
|
|
120
|
+
needPanes();
|
|
121
|
+
const made = dropInGroup(c.groups, ids.filter((id) => !g.panes.includes(id)), g.id, live); // those in it already stay as they are
|
|
122
|
+
c.setGroups(made.groups);
|
|
123
|
+
const left = made.left.map((l) => `${l.group.name}${made.emptied.includes(l.group) ? " (no panes left: deleted)" : ""}`);
|
|
124
|
+
return { updated: groupSummary(c, c.groups.find((o) => o.id === g.id)), ...(left.length ? { left } : {}) };
|
|
125
|
+
}
|
|
126
|
+
case "remove": {
|
|
127
|
+
needPanes();
|
|
128
|
+
const next = removeFromGroup(c.groups, g.id, ids, live);
|
|
129
|
+
c.setGroups(next);
|
|
130
|
+
const left = next.find((o) => o.id === g.id);
|
|
131
|
+
return left ? { updated: groupSummary(c, left) } : { deleted: g.name, note: "It had no panes left." };
|
|
132
|
+
}
|
|
133
|
+
case "run": {
|
|
134
|
+
requireTrusted(c, "run panes");
|
|
135
|
+
c.runSelected(members().filter((id) => c.flow.ids().includes(id)));
|
|
136
|
+
const settled = await waitForAll(c, args.wait === false ? 0 : (args.timeoutMs ?? 10000));
|
|
137
|
+
return { ran: g.name, panes: members().map((id) => summary(c, id)), ...(settled ? {} : { note: "Still running; check again with mallory_list_panes." }) };
|
|
138
|
+
}
|
|
139
|
+
case "arrange": {
|
|
140
|
+
if (!host.arrangeGroup) throw new Error("Arranging isn't available here (it needs the page).");
|
|
141
|
+
const moved = host.arrangeGroup(members());
|
|
142
|
+
return { arranged: g.name, moved, undo: "mallory_undo puts them back." };
|
|
143
|
+
}
|
|
144
|
+
case "to_subgraph": {
|
|
145
|
+
guardWriteAll(c, g.panes, "group");
|
|
146
|
+
const id = groupToSubgraph(c, g.id);
|
|
147
|
+
host.select?.(id);
|
|
148
|
+
return { ...(await afterChange(c, id, args)), from: g.name, undo: "mallory_undo puts the panes and the frame back." };
|
|
149
|
+
}
|
|
150
|
+
default:
|
|
151
|
+
throw new Error(`Unknown action "${args.action}".`);
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
// ── subgraphs: open one, go back out, save one as a canvas, insert a saved canvas ──
|
|
157
|
+
|
|
158
|
+
{
|
|
159
|
+
name: "open_subgraph",
|
|
160
|
+
title: "Open a subgraph pane",
|
|
161
|
+
description:
|
|
162
|
+
"Show the canvas inside a subgraph pane, as its \"Open subgraph\" does: from then on every tool acts on the panes inside (its input panes are its inputs, its last pane its value) until mallory_leave_subgraph. The person sees it too. Returns the panes inside.",
|
|
163
|
+
input: {
|
|
164
|
+
type: "object",
|
|
165
|
+
properties: {
|
|
166
|
+
pane: paneRef("The subgraph pane"),
|
|
167
|
+
instance: { type: ["string", "number", "boolean", "array", "object"], description: "A repeater's instance (a subgraph pane with for each), by its item's key as mallory_get_pane lists them: a view of that instance, running with its own state. Edits there aren't kept (the template is what to change: open the pane without instance)." },
|
|
168
|
+
},
|
|
169
|
+
required: ["pane"],
|
|
170
|
+
additionalProperties: false,
|
|
171
|
+
},
|
|
172
|
+
run({ pane, instance }) {
|
|
173
|
+
const c = canvas();
|
|
174
|
+
const p = find(c, pane);
|
|
175
|
+
if (p.type !== "subgraph") throw new Error(paneKindError(`"${p.name || p.id}" is`, p.type, "subgraph", ".", { wantNoun: "" }));
|
|
176
|
+
requireTrusted(c, "open subgraphs");
|
|
177
|
+
if (instance !== undefined) {
|
|
178
|
+
if (!repeatOn(p)) throw new Error(`"${p.name || p.id}" isn't a repeater (for each is off), so it has no instances.`);
|
|
179
|
+
const list = instancesOf(c, p.id);
|
|
180
|
+
const same = (i) => JSON.stringify(i.key) === JSON.stringify(instance) || String(i.key) === String(instance) || i.label === String(instance);
|
|
181
|
+
const hit = list.find(same);
|
|
182
|
+
if (!hit) throw new Error(`"${p.name || p.id}" has no instance with the key ${JSON.stringify(instance)}. Keys: ${list.slice(0, 20).map((i) => i.label).join(", ") || "none yet"}.`);
|
|
183
|
+
if (!host.openInstance) throw new Error("Opening instances isn't available here.");
|
|
184
|
+
host.openInstance(p.id, hit.seg);
|
|
185
|
+
const inner = canvas();
|
|
186
|
+
if (inner === c) throw new Error(`Couldn't open that instance of "${p.name || p.id}".`);
|
|
187
|
+
return { opened: `${p.name || p.id} · ${hit.label}`, instance: hit.key, path: host.subgraphPath?.() ?? [], panes: inner.order().map((id) => summary(inner, id)), note: "A view of one instance: edits here aren't kept.", leave: "mallory_leave_subgraph goes back out." };
|
|
188
|
+
}
|
|
189
|
+
if (p.ref) throw new Error(`"${p.name || p.id}" is linked to the canvas "${p.ref.name}": edit that canvas (mallory_open_canvas "${p.ref.canvas}"; every pane linked to it then offers the update), or make this one a copy first (mallory_update_linked with detach: true).`);
|
|
190
|
+
if (!host.openSubgraph) throw new Error("Opening subgraphs isn't available here.");
|
|
191
|
+
host.openSubgraph(p.id);
|
|
192
|
+
const inner = canvas();
|
|
193
|
+
if (inner === c) throw new Error(`Couldn't open "${p.name || p.id}".`);
|
|
194
|
+
return { opened: p.name || p.id, path: host.subgraphPath?.() ?? [], panes: inner.order().map((id) => summary(inner, id)), leave: "mallory_leave_subgraph goes back out." };
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: "leave_subgraph",
|
|
199
|
+
title: "Leave the open subgraph",
|
|
200
|
+
description: "Go back out of the subgraph opened with mallory_open_subgraph (or by the person) to the canvas around it; all: true goes back to the outermost canvas. Edits inside are kept in the subgraph pane.",
|
|
201
|
+
input: { type: "object", properties: { all: { type: "boolean", description: "Leave every open subgraph (default: one level)." } }, additionalProperties: false },
|
|
202
|
+
run({ all = false }) {
|
|
203
|
+
const path = host.subgraphPath?.() ?? [];
|
|
204
|
+
if (!path.length) throw new Error("No subgraph is open: the tools act on the canvas itself.");
|
|
205
|
+
if (!host.leaveSubgraph) throw new Error("Leaving subgraphs isn't available here.");
|
|
206
|
+
host.leaveSubgraph(all);
|
|
207
|
+
const c = canvas();
|
|
208
|
+
return { canvas: c.name.value, path: host.subgraphPath?.() ?? [], panes: c.order().map((id) => summary(c, id)) };
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
name: "save_subgraph",
|
|
213
|
+
title: "Save a subgraph pane as a canvas",
|
|
214
|
+
description: "Save a copy of the canvas inside a subgraph pane as a canvas of its own in this browser (later edits to either don't carry over), as its \"Save subgraph as a canvas\" does. Returns the new canvas's id and name (mallory_open_canvas opens it).",
|
|
215
|
+
input: { type: "object", properties: { pane: paneRef("The subgraph pane") }, required: ["pane"], additionalProperties: false },
|
|
216
|
+
run({ pane }) {
|
|
217
|
+
const c = canvas();
|
|
218
|
+
const p = find(c, pane);
|
|
219
|
+
if (p.type !== "subgraph") throw new Error(paneKindError(`"${p.name || p.id}" is`, p.type, "subgraph", ".", { wantNoun: "" }));
|
|
220
|
+
if (!host.saveSubgraph) throw new Error("Saving canvases isn't available here.");
|
|
221
|
+
const id = host.saveSubgraph(p.id);
|
|
222
|
+
if (!id) throw new Error("Couldn't save to this browser's storage.");
|
|
223
|
+
return { saved: { id, name: host.loadCanvas?.(id)?.name ?? p.name } };
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
name: "insert_canvas",
|
|
228
|
+
title: "Insert a saved canvas as a subgraph",
|
|
229
|
+
description:
|
|
230
|
+
"Add a saved canvas (see mallory_list_canvases) to the open canvas as a subgraph pane, run like a function: its input panes become the subgraph's inputs (wire panes into it with mallory_connect, matched by name, or set unwired ones with mallory_update_pane's params) and its last pane is its value. link: true links it (it follows that canvas: when it changes, the pane offers the update, see mallory_update_linked); false embeds a copy. By default a canvas marked as a function is linked and others copied. A canvas can't contain itself, directly or through canvases it links to, and one that came from a link or file and was never run (\"Run it\") can't be inserted. Undoable.",
|
|
231
|
+
input: {
|
|
232
|
+
type: "object",
|
|
233
|
+
properties: {
|
|
234
|
+
canvas: { type: "string", minLength: 1, description: "The saved canvas: its id or name." },
|
|
235
|
+
link: { type: "boolean", description: "Link it (true) or embed a copy (false). Default: linked for a function canvas, else a copy." },
|
|
236
|
+
x: { type: "number" },
|
|
237
|
+
y: { type: "number" },
|
|
238
|
+
wait: waitArg,
|
|
239
|
+
timeoutMs: timeoutArg,
|
|
240
|
+
},
|
|
241
|
+
required: ["canvas"],
|
|
242
|
+
additionalProperties: false,
|
|
243
|
+
},
|
|
244
|
+
async run(args) {
|
|
245
|
+
const c = canvas();
|
|
246
|
+
const entry = findSaved(args.canvas);
|
|
247
|
+
const doc = host.loadCanvas?.(entry.id);
|
|
248
|
+
if (!doc) throw new Error("That canvas isn't saved in this browser.");
|
|
249
|
+
if (doc.trusted === false) throw new Error(`"${doc.name}" came from a link or file and hasn't been run: open it (mallory_open_canvas) and ask the person to review it and press "Run it" first.`);
|
|
250
|
+
const at = args.x !== undefined && args.y !== undefined ? { x: args.x, y: args.y } : placeNear(c, []);
|
|
251
|
+
const link = args.link ?? linksByDefault(doc);
|
|
252
|
+
const id = insertSaved(c, doc, at, { link }); // refuses a canvas that would contain itself
|
|
253
|
+
host.select?.(id);
|
|
254
|
+
const out = await afterChange(c, id, args);
|
|
255
|
+
return { inserted: doc.name, as: link ? "linked" : "copy", ...out };
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
name: "update_linked",
|
|
260
|
+
title: "Update a linked subgraph pane",
|
|
261
|
+
description: [
|
|
262
|
+
"A linked subgraph pane (see mallory_insert_canvas with link: true) follows a saved canvas. Without accept or detach, this says whether that canvas changed since the pane last took it, and what changed: the panes inside as a diff, its inputs (added, removed, renamed, retyped; a wire into a removed input stays, flagged) and its named outputs the new version no longer makes.",
|
|
263
|
+
"Then choose by argument (each is described there): `accept` uses the new version, `detach` makes the pane a copy, `replace` moves a deprecated package pane to its replacement (with `templateKey`, a repeater's template), `templateKey` reviews a repeater's linked template instead of the pane's own link.",
|
|
264
|
+
].join(" "),
|
|
265
|
+
input: {
|
|
266
|
+
type: "object",
|
|
267
|
+
properties: {
|
|
268
|
+
pane: paneRef("The linked subgraph pane (or the repeater, with templateKey)"),
|
|
269
|
+
templateKey: { type: "string", description: "A repeater's linked template, by its key in each.templates (the value of its template field; see mallory_get_pane repeater.templateUpdates), instead of the pane's own link: the same review, and accept: true updates every instance in place. A template can't be detached: remove it with mallory_update_pane each.templates." },
|
|
270
|
+
accept: { type: "boolean", description: "Use the new version, as \"use new version\" does: a snapshot first (mallory_list_versions), the panes inside are replaced, wires and parameters stay by input name, and it reruns. A version that came with a file or link (the canvas's library, or a saved canvas never run) is refused: the person accepts those. With replace: do the replacement." },
|
|
271
|
+
replace: { type: "boolean", description: "Preview moving a deprecated package pane (mallory_get_pane linked.deprecated) to the replacement its author names, inputs matched by name and type, nothing rewired. With accept: true it does it (snapshot first) only if that replacement is already installed: installing is the person's. With templateKey it is that template's move (every instance follows in place)." },
|
|
272
|
+
detach: { type: "boolean", description: "\"Edit just this one\": make the pane a copy instead (it stops following the canvas), which mallory_open_subgraph can edit. To change the canvas for every linked pane, open it (mallory_open_canvas) and edit that." },
|
|
273
|
+
wait: waitArg,
|
|
274
|
+
timeoutMs: timeoutArg,
|
|
275
|
+
},
|
|
276
|
+
required: ["pane"],
|
|
277
|
+
additionalProperties: false,
|
|
278
|
+
},
|
|
279
|
+
async run(args) {
|
|
280
|
+
const c = canvas();
|
|
281
|
+
const p = find(c, args.pane);
|
|
282
|
+
guardWrite(p, "update, replace or detach");
|
|
283
|
+
if (p.type !== "subgraph") throw new Error(paneKindError(`"${p.name || p.id}" is`, p.type, "subgraph", ".", { wantNoun: "" }));
|
|
284
|
+
if (args.templateKey !== undefined) {
|
|
285
|
+
if (args.replace) {
|
|
286
|
+
return await replaceDeprecatedTemplate(c, p, args);
|
|
287
|
+
}
|
|
288
|
+
return await updateTemplate(c, p, args);
|
|
289
|
+
}
|
|
290
|
+
if (!p.ref) throw new Error(`"${p.name || p.id}" isn't linked to a canvas${p.from ? ` (it is a copy of "${p.from.name}")` : ""}.`);
|
|
291
|
+
if (args.accept && args.detach) throw new Error("Pass accept or detach, not both.");
|
|
292
|
+
if (args.replace) {
|
|
293
|
+
if (args.detach) throw new Error("Pass replace or detach, not both.");
|
|
294
|
+
return await replaceDeprecated(c, p, args);
|
|
295
|
+
}
|
|
296
|
+
if (args.detach) {
|
|
297
|
+
const ref = detachLinked(c, p.id);
|
|
298
|
+
return { detached: p.name || p.id, copyOf: ref.name, note: "It is a copy now: mallory_open_subgraph edits it." };
|
|
299
|
+
}
|
|
300
|
+
const source = linkSource(p.ref, linkWhere(c));
|
|
301
|
+
if (!source) return { pane: p.name || p.id, linkedTo: p.ref.name, update: false, note: `"${p.ref.name}" isn't saved in this browser and the canvas carries no other version: the pane runs its own copy.` };
|
|
302
|
+
if (source.hash === p.ref.hash) return { pane: p.name || p.id, linkedTo: source.doc.name, update: false, note: "It uses the latest version." };
|
|
303
|
+
const plan = planUpdate(p, source.doc, { rootId: c.root.id });
|
|
304
|
+
const diff = diffCanvases({ panes: p.graph?.panes ?? [] }, { panes: plan.graph.panes });
|
|
305
|
+
const changes = { from: source.from === "canvas" ? "the saved canvas" : "this canvas's library (it came with its file or link)", inputs: plan.ports, ...(plan.followed?.length ? { inputsFollowed: plan.followed } : {}), ...(plan.flagged.length ? { wiresToNoInput: plan.flagged.map((f) => f.name) } : {}), ...(plan.lostOutputs?.length ? { outputsNoLongerMade: plan.lostOutputs.map((o) => o.name) } : {}), diff: formatDiff(diff) };
|
|
306
|
+
if (!args.accept) return { pane: p.name || p.id, linkedTo: source.doc.name, update: true, changes, accept: "mallory_update_linked with accept: true uses it." };
|
|
307
|
+
// Code that came with a file or link (the canvas's library, or a saved canvas never run) is the person's to accept.
|
|
308
|
+
if (!["canvas", "package"].includes(source.from) || !source.trusted) throw new Error(source.flagged ? `The installed ${p.ref.package} is flagged (${source.flagged}): ask the person to reinstall it.` : `This version of "${source.doc.name}" came with a file or link and hasn't been run: ask the person to review it and press "use new version" on the pane.`);
|
|
309
|
+
await host.beforeLinkUpdate?.(); // a snapshot of the canvas as it was
|
|
310
|
+
acceptUpdate(c, p.id, source.doc);
|
|
311
|
+
const out = await afterChange(c, p.id, args);
|
|
312
|
+
return { updated: p.name || p.id, linkedTo: source.doc.name, changes, ...out };
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
name: "set_function_canvas",
|
|
317
|
+
title: "Mark the canvas as a function",
|
|
318
|
+
description: "Mark the open canvas as a function canvas (function: true) or not. A function canvas is offered in the + add menu's library and the palette, and mallory_insert_canvas links it by default: canvases that use it follow its updates.",
|
|
319
|
+
input: { type: "object", properties: { function: { type: "boolean", description: "true marks it, false unmarks it." } }, required: ["function"], additionalProperties: false },
|
|
320
|
+
run(args) {
|
|
321
|
+
const root = host.rootCanvas?.() ?? canvas();
|
|
322
|
+
guardWriteAll(root, [...root.panes.keys()], "mark this canvas as a function (or not), while they are on it,");
|
|
323
|
+
root.isFunction = Boolean(args.function);
|
|
324
|
+
host.saveCanvas?.();
|
|
325
|
+
return { canvas: root.name.value, function: root.isFunction };
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
name: "list_library",
|
|
330
|
+
title: "List the library",
|
|
331
|
+
description:
|
|
332
|
+
'What can be inserted by reference: the function canvases saved in this browser (insert one with mallory_insert_canvas) and the pane packages installed in it, each with its panes ("<package>/<pane>", its title, description, typed inputs (its parameters: name, type, default) and outputs, and the hosts it says it uses; add one with mallory_add_pane { library }). A package or pane its author deprecated has a "deprecated" notice (message, since, removal and a replacement with whether it is installed): inert text, you may read it and tell the person. Read-only: installing, updating and removing packages are the person\'s ("Pane packages…").',
|
|
333
|
+
readOnly: true,
|
|
334
|
+
untrusted: true,
|
|
335
|
+
input: { type: "object", properties: {}, additionalProperties: false },
|
|
336
|
+
run() {
|
|
337
|
+
const open = (host.rootCanvas?.() ?? host.getCanvas())?.id;
|
|
338
|
+
const functions = savedCanvases()
|
|
339
|
+
.filter((e) => e.function && e.id !== open)
|
|
340
|
+
.map((e) => ({ id: e.id, name: e.name, panes: e.panes }));
|
|
341
|
+
const packages = (host.listPackages?.() ?? []).map((entry) => ({
|
|
342
|
+
name: entry.name,
|
|
343
|
+
version: entry.version,
|
|
344
|
+
...(entry.pkg?.license ? { license: entry.pkg.license } : {}),
|
|
345
|
+
...(entry.pkg?.description ? { description: entry.pkg.description } : {}),
|
|
346
|
+
...(entry.flagged ? { flagged: entry.flagged } : {}),
|
|
347
|
+
...(entry.pkg?.assets?.length ? { assets: entry.pkg.assets.map(({ name, type, size }) => ({ name, type, bytes: size })) } : {}), // the files its panes read as assets.<name>: names and sizes, never the bytes
|
|
348
|
+
...(entry.pkg?.module ? { module: { name: entry.pkg.module.name, bytes: new TextEncoder().encode(entry.pkg.module.source).length, integrity: entry.pkg.module.integrity } } : {}), // its shared module (pkg.module): name, size and hash, never the source
|
|
349
|
+
...(entry.pkg?.deprecated ? { deprecated: noticeWithReplacement(entry.pkg.deprecated) } : {}),
|
|
350
|
+
panes: (entry.pkg?.panes ?? []).map((pane) => {
|
|
351
|
+
const { inputs, outputs } = paneSignature(pane); // typed ports: its parameters and what it gives back
|
|
352
|
+
const dep = deprecationOf(entry.pkg, pane); // the author's notice: inert text; reading it installs nothing
|
|
353
|
+
return { library: `${entry.name}/${pane.id}`, title: pane.title, ...(pane.description ? { description: pane.description } : {}), inputs, outputs, ...(pane.hosts?.length ? { usesHosts: pane.hosts } : {}), tests: pane.tests?.length ?? 0, ...(dep ? { deprecated: noticeWithReplacement(dep, pane.id) } : {}) };
|
|
354
|
+
}),
|
|
355
|
+
}));
|
|
356
|
+
return { functionCanvases: functions, packages };
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
];
|
|
360
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// The tests tool group (src/webmcp/groups.js): its tools, as specs for createTools (src/webmcp/tools.js).
|
|
2
|
+
import { hiddenPanes } from "../hidden.js";
|
|
3
|
+
import { typesWhere } from "../../panes/registry.js";
|
|
4
|
+
import { listWords } from "../../panes/fields.js";
|
|
5
|
+
import { captureTest, checkablePanes, defaultChecks } from "../../tests/capture.js";
|
|
6
|
+
import { isEvaluation } from "../../tests/evaluate.js";
|
|
7
|
+
import { withCompare } from "../../tests/compare.js";
|
|
8
|
+
import { validateTests } from "../../tests/matchers.js";
|
|
9
|
+
import { inputLogTools } from "./input-log-tools.js";
|
|
10
|
+
import { testFromRun } from "../../model/runlog.js";
|
|
11
|
+
import { rowsFromRuns, evaluationFromRuns } from "../../tests/from-runs.js";
|
|
12
|
+
import { paneRef, timeoutArg, waitArg, fail, compareText, resultText } from "./shared.js";
|
|
13
|
+
|
|
14
|
+
/** The tests group's tool specs. `ctx` is the helpers createTools builds (the canvas, finding panes, summaries, waiting). */
|
|
15
|
+
export function testsTools(ctx) {
|
|
16
|
+
const { host, canvas, find, requireTrusted, summary, afterChange, placeNear, lastResult } = ctx;
|
|
17
|
+
return [
|
|
18
|
+
...inputLogTools({ canvas, find, paneRef, requireTrusted, placeNear, afterChange, waitArg, timeoutArg, host }), // input_log: read, compare, branch and replay input logs (src/webmcp/tools/input-log-tools.js)
|
|
19
|
+
|
|
20
|
+
// ── canvas tests (src/tests/) ──
|
|
21
|
+
|
|
22
|
+
{
|
|
23
|
+
name: "list_tests",
|
|
24
|
+
title: "List the canvas's tests",
|
|
25
|
+
description: [
|
|
26
|
+
"The open canvas's tests: each one's name, the inputs it sets and the values it expects (by pane name), and its last result in this session when it has run. Run them with mallory_run_tests.",
|
|
27
|
+
"A test with a dataset is an evaluation: it lists its row count, metrics and pass thresholds instead of its rows, and the summary of its last evaluation kept in this browser (`lastEvaluation`).",
|
|
28
|
+
],
|
|
29
|
+
readOnly: true,
|
|
30
|
+
untrusted: true,
|
|
31
|
+
input: { type: "object", properties: {}, additionalProperties: false },
|
|
32
|
+
async run() {
|
|
33
|
+
const c = canvas();
|
|
34
|
+
const tests = await Promise.all(
|
|
35
|
+
c.tests.map(async (t, i) => {
|
|
36
|
+
const base = { name: t.name || `test ${i + 1}`, inputs: t.inputs ?? {}, expect: t.expect ?? {} };
|
|
37
|
+
if (!isEvaluation(t)) return { ...base, ...lastResult(t) };
|
|
38
|
+
const stored = await host.lastEvaluation?.(t).catch(() => undefined);
|
|
39
|
+
const dataset = Array.isArray(t.dataset.rows) ? { rows: t.dataset.rows.length } : { pane: t.dataset.pane };
|
|
40
|
+
return { ...base, evaluation: true, dataset, metrics: t.metrics ?? [], ...(t.compare ? { compare: compareText(t.compare) } : {}), ...(t.pass ? { pass: t.pass } : {}), ...lastResult(t), ...(stored ? { lastEvaluation: stored } : {}) };
|
|
41
|
+
}),
|
|
42
|
+
);
|
|
43
|
+
return { tests, checkable: checkablePanes(c).map((p) => p.name) };
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "run_tests",
|
|
48
|
+
title: "Run the canvas's tests",
|
|
49
|
+
description: [
|
|
50
|
+
"Run the open canvas's tests (all, or the ones named) in a separate sandbox, as the Tests dialog does: the canvas itself isn't touched.",
|
|
51
|
+
`Each sets its inputs, runs the canvas headlessly (${listWords(typesWhere((r) => r.headless !== "run"))} panes are skipped) and checks the expected panes.`,
|
|
52
|
+
"Returns pass/fail with each failing check, and the id of each test's run (an evaluation's failed rows': theirs) in the run log, to read with mallory_get_run.",
|
|
53
|
+
"An evaluation (a test with a dataset) runs once per row and returns each metric's mean and pass rate, its pass thresholds, and the first rows that failed.",
|
|
54
|
+
"An agent evaluation matrix runs only its recorded columns here (a column that calls a model provider with the person's key is skipped), and returns each cell's status, steps and cost.",
|
|
55
|
+
],
|
|
56
|
+
input: { type: "object", properties: { tests: { type: "array", items: { type: "string", minLength: 1 }, description: "Test names (default: every test)." } }, additionalProperties: false },
|
|
57
|
+
async run({ tests: names }) {
|
|
58
|
+
const c = canvas();
|
|
59
|
+
requireTrusted(c, "run its tests");
|
|
60
|
+
if (!c.tests.length) throw new Error("This canvas has no tests yet: save one with mallory_save_test.");
|
|
61
|
+
const label = (t) => t.name || `test ${c.tests.indexOf(t) + 1}`;
|
|
62
|
+
const chosen = names?.length ? names.map((n) => c.tests.find((t) => label(t) === n) ?? fail(`No test "${n}". Tests: ${c.tests.map(label).join(", ")}.`)) : c.tests;
|
|
63
|
+
if (!host.runTests) throw new Error("Running tests isn't available here.");
|
|
64
|
+
// `live: false`: an agent starts no run that calls a model provider with the person's key (a matrix's live columns are skipped).
|
|
65
|
+
const results = await host.runTests(chosen, { live: false });
|
|
66
|
+
if (!results) throw new Error("The tests are already running (the Tests dialog started them): try again when they finish.");
|
|
67
|
+
const passed = results.filter((r) => r?.pass).length;
|
|
68
|
+
return { passed, failed: results.length - passed, results: results.map(resultText) };
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "save_test",
|
|
73
|
+
title: "Save the canvas as it is now as a test",
|
|
74
|
+
description:
|
|
75
|
+
"Add a test to the open canvas from its current state (\"Save current inputs and outputs as a test\"): the input panes' values now as its inputs, and the current values of the panes named in `panes` (default: the named panes nothing else reads) as what it expects. Set the inputs first (mallory_set_input) and let the panes run. Saved with the canvas. With `runs`, an evaluation (a dataset row per run in the run log) instead, or rows added to one. With `compare`, an existing evaluation's candidate comparison is set (or removed).",
|
|
76
|
+
input: {
|
|
77
|
+
type: "object",
|
|
78
|
+
properties: {
|
|
79
|
+
name: { type: "string", minLength: 1, description: "The test's name (unique on this canvas)." },
|
|
80
|
+
panes: { type: "array", minItems: 1, items: paneRef("A pane to check"), description: "The panes whose values it expects." },
|
|
81
|
+
run: { oneOf: [{ type: "integer", minimum: 1 }, { type: "string", minLength: 1 }], description: "Make it from a run in the run log instead (mallory_list_runs: 1 is the most recent): that run's input values and the panes' values then." },
|
|
82
|
+
runs: {
|
|
83
|
+
type: "array",
|
|
84
|
+
minItems: 1,
|
|
85
|
+
maxItems: 500,
|
|
86
|
+
items: { oneOf: [{ type: "integer", minimum: 1 }, { type: "string", minLength: 1 }] },
|
|
87
|
+
description:
|
|
88
|
+
"Make an evaluation (a test with a dataset) from runs in the run log (mallory_list_runs), a row per run: its input panes' values and the values of `panes` (from the first run) become `$row` columns. When `name` is an evaluation with inline rows, the runs are added to it as rows instead. A run that didn't keep every value the evaluation reads is left out (the result says which).",
|
|
89
|
+
},
|
|
90
|
+
compare: {
|
|
91
|
+
oneOf: [
|
|
92
|
+
{
|
|
93
|
+
type: "object",
|
|
94
|
+
properties: {
|
|
95
|
+
keyColumn: { type: "string", minLength: 1, description: "The dataset column that names a row (like \"id\")." },
|
|
96
|
+
expected: { description: "The label each row should get: a value or \"$row.column\"." },
|
|
97
|
+
candidates: {
|
|
98
|
+
type: "array",
|
|
99
|
+
minItems: 2,
|
|
100
|
+
maxItems: 8,
|
|
101
|
+
items: { type: "object", properties: { name: { type: "string", minLength: 1 }, pane: paneRef("A pane run on every row"), path: { type: "string", description: "A dotted path into the pane's value." } }, additionalProperties: false },
|
|
102
|
+
description: "Two or more panes to compare. An entry that is only the name of a saved-predictions candidate already there keeps it.",
|
|
103
|
+
},
|
|
104
|
+
positive: { description: "The class a binary headline is about." },
|
|
105
|
+
average: { type: "string", enum: ["macro", "micro", "binary"] },
|
|
106
|
+
},
|
|
107
|
+
required: ["keyColumn", "candidates"],
|
|
108
|
+
additionalProperties: false,
|
|
109
|
+
},
|
|
110
|
+
{ type: "null" },
|
|
111
|
+
],
|
|
112
|
+
description: "Set (or with null remove) the `compare` block of the existing evaluation `name`: candidates lined up on the same rows by key, with confusion counts, precision, recall and F1 (docs/guide/cli-and-serving.md: Comparing candidates). Not with panes, run or runs.",
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
required: ["name"],
|
|
116
|
+
additionalProperties: false,
|
|
117
|
+
},
|
|
118
|
+
async run({ name, panes, run: runRef, runs: runRefs, compare }) {
|
|
119
|
+
const c = canvas();
|
|
120
|
+
// A test keeps the values it expects in the canvas: not those of a pane agents don't read as a value (src/webmcp/hidden.js).
|
|
121
|
+
const held = (panes ?? []).map((ref) => find(c, ref)).filter((p) => hiddenPanes(c).has(p.id));
|
|
122
|
+
if (held.length) throw new Error(`${held.map((p) => p.name || p.id).join(", ")}: holds, or is computed from, something agents don't read as a value (a live capture or a capture log), so a test can't expect it from here.`);
|
|
123
|
+
if (compare !== undefined) {
|
|
124
|
+
if (panes !== undefined || runRef !== undefined || runRefs !== undefined) throw new Error("`compare` edits an existing evaluation: not with `panes`, `run` or `runs`.");
|
|
125
|
+
const existing = c.tests.find((t) => t.name === name.trim());
|
|
126
|
+
if (!existing) throw new Error(`No evaluation called "${name.trim()}" (mallory_list_tests).`);
|
|
127
|
+
if (!isEvaluation(existing)) throw new Error(`"${existing.name}" isn't an evaluation (a test with a dataset): a comparison needs one.`);
|
|
128
|
+
const next = withCompare(existing, compare === null ? null : { ...compare, key: compare.keyColumn }, { panes: checkablePanes(c).map((p) => p.name) });
|
|
129
|
+
validateTests([next]);
|
|
130
|
+
c.tests = c.tests.map((t) => (t === existing ? next : t));
|
|
131
|
+
host.testsChanged?.();
|
|
132
|
+
return { name: next.name, compare: next.compare ?? null, ...(next.compare ? { note: "Run the test to see the comparison." } : {}) };
|
|
133
|
+
}
|
|
134
|
+
if (runRefs?.length) {
|
|
135
|
+
if (runRef !== undefined) throw new Error("Give `run` (a test from one run) or `runs` (an evaluation from several), not both.");
|
|
136
|
+
const log = c.runLog;
|
|
137
|
+
const chosen = [...new Set(runRefs.map((ref) => log?.get(typeof ref === "string" && /^\d+$/.test(ref) ? Number(ref) : ref) ?? fail(`No run ${JSON.stringify(ref)} in the run log (see mallory_list_runs).`)))].sort((a, b) => (a.startedAt ?? 0) - (b.startedAt ?? 0));
|
|
138
|
+
const outputOf = (pane, version) => log.outputOf(pane, version);
|
|
139
|
+
const left = (missing) => missing.map((m) => ({ run: m.run.id, missing: m.columns }));
|
|
140
|
+
const existing = c.tests.find((t) => t.name === name.trim());
|
|
141
|
+
if (existing) {
|
|
142
|
+
if (!isEvaluation(existing) || !Array.isArray(existing.dataset.rows)) throw new Error(`"${existing.name}" ${isEvaluation(existing) ? "reads its rows from a pane" : "isn't an evaluation"}: rows from runs go in an evaluation with inline rows (or give a new name).`);
|
|
143
|
+
const { rows, missing } = rowsFromRuns(existing, chosen, c.panes, { outputOf });
|
|
144
|
+
if (!rows.length) throw new Error(`None of those runs kept every value "${existing.name}" reads.`);
|
|
145
|
+
const next = { ...existing, dataset: { ...existing.dataset, rows: [...existing.dataset.rows, ...rows] } };
|
|
146
|
+
c.tests = c.tests.map((t) => (t === existing ? next : t));
|
|
147
|
+
host.testsChanged?.();
|
|
148
|
+
return { added: rows.length, rows: next.dataset.rows.length, ...(missing.length ? { leftOut: left(missing) } : {}) };
|
|
149
|
+
}
|
|
150
|
+
const ids = panes?.length ? panes.map((ref) => find(c, ref).id) : defaultChecks(c).map((p) => p.id);
|
|
151
|
+
const { evaluation, missing } = evaluationFromRuns(chosen, { name: name.trim(), panes: c.panes, expect: ids, outputOf });
|
|
152
|
+
if (!evaluation.dataset.rows.length) throw new Error("None of those runs kept every value the evaluation reads.");
|
|
153
|
+
c.tests = [...c.tests, evaluation];
|
|
154
|
+
host.testsChanged?.();
|
|
155
|
+
return { saved: evaluation, tests: c.tests.length, ...(missing.length ? { leftOut: left(missing) } : {}) };
|
|
156
|
+
}
|
|
157
|
+
const checkable = new Set(checkablePanes(c).map((p) => p.id));
|
|
158
|
+
const ids = panes?.length ? panes.map((ref) => find(c, ref)).map((p) => (checkable.has(p.id) ? p.id : fail(`${p.name || p.id} can't be checked by a test (${p.type === "input" ? "it is an input" : !p.name ? "it has no name" : "headless runs skip it"}).`))) : defaultChecks(c).map((p) => p.id);
|
|
159
|
+
if (!ids.length) throw new Error("No pane to check: name the panes with `panes`.");
|
|
160
|
+
if (runRef !== undefined && c.tests.some((t) => t.name === name.trim())) throw new Error(`There is already a test called "${name.trim()}".`);
|
|
161
|
+
const run = runRef === undefined ? undefined : c.runLog?.get(typeof runRef === "string" && /^\d+$/.test(runRef) ? Number(runRef) : runRef);
|
|
162
|
+
if (runRef !== undefined && !run) throw new Error(`No run ${JSON.stringify(runRef)} in the run log (see mallory_list_runs).`);
|
|
163
|
+
const test = run ? testFromRun(run, { name: name.trim(), panes: c.panes, expect: ids }) : await captureTest(c, { name, ids });
|
|
164
|
+
c.tests = [...c.tests, test];
|
|
165
|
+
host.testsChanged?.();
|
|
166
|
+
return { saved: test, tests: c.tests.length };
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
];
|
|
170
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// The capture-log tool (wave P-H; docs/design/traffic.md, "Wave P-H"): mallory_traffic reads a traffic pane's entries, read-only and redacted,
|
|
2
|
+
// through src/model/traffic-agent.js, and only for a pane the person has let agents read (the pane's own box, kept in this browser). It reads
|
|
3
|
+
// what the pane's runner already stored (the same redacted entries as the pane's value): never the person's saved history, never the served
|
|
4
|
+
// log, never a tap's raw store. It changes nothing and cannot approve a change: a suggestion goes in a pane, and a person decides.
|
|
5
|
+
import { trait } from "../../panes/registry.js";
|
|
6
|
+
import { cleanTraffic } from "../../model/traffic.js";
|
|
7
|
+
import { trafficOf } from "../../model/traffic-store.js";
|
|
8
|
+
import { AGENT_FORMS, AGENT_LIMITS, AGENT_MODES, readTraffic } from "../../model/traffic-agent.js";
|
|
9
|
+
import { logAllowed, upstreamProblem } from "../hidden.js";
|
|
10
|
+
import { paneRef } from "./shared.js";
|
|
11
|
+
|
|
12
|
+
const RESULTS = ["response", "captured", "request", "refused", "failed"];
|
|
13
|
+
|
|
14
|
+
/** The traffic group's tool specs (src/webmcp/groups.js). `ctx` is the helpers createTools builds. */
|
|
15
|
+
export function trafficTools({ canvas, find, nameOf }) {
|
|
16
|
+
const logPanes = (c) => [...c.panes.values()].filter((p) => trait(p.type, "captureLog"));
|
|
17
|
+
return [
|
|
18
|
+
{
|
|
19
|
+
name: "traffic",
|
|
20
|
+
title: "Read a capture log",
|
|
21
|
+
description: [
|
|
22
|
+
"Read a traffic pane's captured requests and responses (this canvas's own requests from an http tap, a webhook's raw capture, a HAR): read-only, redacted, and only for a pane the person has let agents read (a box in the pane you cannot tick; until then its value is withheld everywhere). mode `summary` (counts by status class and method, bytes, slowest), `list` (default; newest first; filters method, status such as 2xx, 404, refused or failed, domain, path, text, result; limit, offset) or `entry` (an id from a list; form json, curl, fetch, raw, har or http).",
|
|
23
|
+
`You never see credentials (Authorization, cookies, token-like headers, key-shaped URL parts and body fields read "[redacted]"), a key's value, the network rules' reasons, bodies the source did not keep (an http tap keeps them only if the person ticks it; each is cut at ${AGENT_LIMITS.bodyChars} characters), saved history or a served log (refused).`,
|
|
24
|
+
"You cannot change a rule, key or permission. To suggest a change, write it in a text pane; the person decides in a decision pane.",
|
|
25
|
+
],
|
|
26
|
+
readOnly: true,
|
|
27
|
+
untrusted: true,
|
|
28
|
+
agentOnly: "the traffic pane's own list, filters, detail tabs and exports",
|
|
29
|
+
input: {
|
|
30
|
+
type: "object",
|
|
31
|
+
properties: {
|
|
32
|
+
pane: paneRef("The traffic pane (optional when the canvas has exactly one)"),
|
|
33
|
+
mode: { type: "string", enum: AGENT_MODES, description: "summary, list (default) or entry." },
|
|
34
|
+
method: { type: "string", description: "list: only this method." },
|
|
35
|
+
status: { type: "string", description: "list: 2xx, 404, refused, failed or none." },
|
|
36
|
+
domain: { type: "string", description: "list: the request's domain contains this text." },
|
|
37
|
+
path: { type: "string", description: "list: the path and query contain this literal text; a leading ^ anchors it to the start, a trailing $ to the end." },
|
|
38
|
+
text: { type: "string", description: "list: contains this text (case-insensitive) in the redacted request line, headers or bodies." },
|
|
39
|
+
result: { type: "string", enum: RESULTS, description: "list: only entries that ended this way." },
|
|
40
|
+
limit: { type: "integer", minimum: 1, maximum: AGENT_LIMITS.list, description: `list: at most this many (default ${AGENT_LIMITS.defaultList}).` },
|
|
41
|
+
offset: { type: "integer", minimum: 0, description: "list: skip this many (the `next` of the last page)." },
|
|
42
|
+
id: { type: "string", description: "entry: an id from a list." },
|
|
43
|
+
form: { type: "string", enum: AGENT_FORMS, description: "entry: the form of the result (default json)." },
|
|
44
|
+
},
|
|
45
|
+
additionalProperties: false,
|
|
46
|
+
},
|
|
47
|
+
async run(args) {
|
|
48
|
+
const c = canvas();
|
|
49
|
+
let p;
|
|
50
|
+
if (args.pane !== undefined) p = find(c, args.pane);
|
|
51
|
+
else {
|
|
52
|
+
const all = logPanes(c);
|
|
53
|
+
if (all.length !== 1) throw new Error(all.length ? `Name the pane: ${all.map((x) => x.name || x.id).join(", ")}.` : "This canvas has no traffic pane.");
|
|
54
|
+
p = all[0];
|
|
55
|
+
}
|
|
56
|
+
const name = p.name || p.id;
|
|
57
|
+
if (!trait(p.type, "captureLog")) throw new Error(`${name} is not a traffic pane.`);
|
|
58
|
+
const source = cleanTraffic(p.traffic).source;
|
|
59
|
+
if (source === "history" || source === "served") throw new Error(`${name} shows ${source === "history" ? "the person's saved history" : "the log of a served canvas"}: agents can't read it.`);
|
|
60
|
+
if (!logAllowed(c, p)) throw new Error(`The person has not let agents read ${name}'s log. Only they can: the box in the pane ("let agents read this log"). Until then its value is withheld too.`);
|
|
61
|
+
const upstream = upstreamProblem(c, p);
|
|
62
|
+
if (upstream) throw new Error(`${name}'s log can't be read by agents while ${upstream}: the person's box covers only a pane that takes its entries from plain sources and the http panes that record this canvas's requests.`);
|
|
63
|
+
const read = trafficOf(c, p.id);
|
|
64
|
+
if (!read) return { pane: name, mode: args.mode ?? "list", count: 0, entries: [], note: "The pane has not read anything yet (wire a source in and run it)." };
|
|
65
|
+
const out = await readTraffic(read.entries, { ...args, host: args.domain }, { source: read.source, dropped: read.dropped, problems: read.problems });
|
|
66
|
+
return { pane: nameOf(c, p.id), ...out };
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
}
|