@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,309 @@
|
|
|
1
|
+
// Agent tools for pinned values (src/model/pin.js) and the run log
|
|
2
|
+
// (src/model/runlog.js). createTools (src/webmcp/tools.js) adds these
|
|
3
|
+
// specs to its own; `t` is its helpers. The run log tools are read-only and
|
|
4
|
+
// marked untrusted: what they return was computed by canvas code.
|
|
5
|
+
import { capturePin, makePin, parsePinText, checkPinSize, pinsBytes, describePin, pinStale, isPinnable, PINNABLE } from "../../model/pin.js";
|
|
6
|
+
import { stepOf, flatSteps, runCounts, jsonDiff, pinnableSteps, pinBlockers } from "../../model/runlog.js";
|
|
7
|
+
import { whyNoValue } from "../../model/retention.js";
|
|
8
|
+
import { collectHolds } from "../../model/wait-clock.js";
|
|
9
|
+
import { aggregateRuns, attachHolds, costReport, SORTS } from "../../model/cost.js";
|
|
10
|
+
import { previewToText } from "../text.js";
|
|
11
|
+
import { hiddenPanes } from "../hidden.js";
|
|
12
|
+
import { diffAgentRuns, isAgentValue } from "../../agent/diff.js";
|
|
13
|
+
import { forkSource } from "../../agent/fork.js";
|
|
14
|
+
import { listWords } from "../../panes/fields.js";
|
|
15
|
+
import { guardWrite } from "./shared.js";
|
|
16
|
+
|
|
17
|
+
const iso = (ms) => (Number.isFinite(ms) ? new Date(ms).toISOString() : undefined);
|
|
18
|
+
const round = (ms) => (Number.isFinite(ms) ? Math.round(ms * 10) / 10 : undefined);
|
|
19
|
+
const runRef = { oneOf: [{ type: "integer", minimum: 1 }, { type: "string", minLength: 1 }], description: "A run: 1 is the most recent, 2 the one before, …; or a run id from mallory_list_runs. Default 1." };
|
|
20
|
+
|
|
21
|
+
/** What a pin is, for an agent. */
|
|
22
|
+
export function pinInfo(pane) {
|
|
23
|
+
if (!pane?.pin) return undefined;
|
|
24
|
+
return { at: iso(pane.pin.at), source: pane.pin.source ?? "run", holds: describePin(pane.pin), ...(pinStale(pane) ? { codeChanged: true } : {}) };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** A run, briefly. */
|
|
28
|
+
function runSummary(run, position) {
|
|
29
|
+
return { run: position, id: run.id, cause: run.cause, startedAt: iso(run.startedAt), ...(run.end !== undefined ? { ms: round(run.end - run.start) } : { running: true }), status: run.status, counts: runCounts(run) };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** A value kept in the log, as text: its full JSON when kept, else its preview. */
|
|
33
|
+
function valueText(output, maxLength = 4000) {
|
|
34
|
+
if (!output) return undefined;
|
|
35
|
+
if ("json" in output) {
|
|
36
|
+
const text = JSON.stringify(output.json);
|
|
37
|
+
return text.length > maxLength ? `${text.slice(0, maxLength - 1)}…` : text;
|
|
38
|
+
}
|
|
39
|
+
return output.preview ? previewToText(output.preview, { maxLength }) : undefined;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** A step, for an agent (`full`: inputs' values, logs and inner steps too). */
|
|
43
|
+
function stepText(step, run, nameOf, { full = false, hidden = new Map() } = {}) {
|
|
44
|
+
const out = { pane: nameOf(step.pane), status: step.status, offsetMs: round(step.start - run.start), ms: round(step.ms) };
|
|
45
|
+
// Hidden (src/webmcp/hidden.js): that it ran and how it ended, never what it made, an error or skip reason that quotes it, a log or an input.
|
|
46
|
+
if (hidden.has(step.pane)) return { ...out, value: hidden.get(step.pane) };
|
|
47
|
+
if (step.output) {
|
|
48
|
+
out.value = valueText(step.output, full ? 4000 : 300);
|
|
49
|
+
if (step.output.pinned) out.pinned = true;
|
|
50
|
+
if (step.output.withheld) out.note = `Value not retained: ${whyNoValue(step)}. (The person's run log retention policy; it can't be read or changed from here.)`;
|
|
51
|
+
if (full && step.output.tooBig) out.note = "Only a preview was kept: the value is over the run log's size limit.";
|
|
52
|
+
if (full && step.output.notJSON) out.note = `Only a preview was kept: it isn't JSON (${step.output.notJSON}).`;
|
|
53
|
+
}
|
|
54
|
+
if (step.error) out.error = `${step.error.name && step.error.name !== "Error" ? `${step.error.name}: ` : ""}${step.error.message}${step.error.line ? ` (line ${step.error.line})` : ""}`;
|
|
55
|
+
if (step.skip) out.skip = { ...(step.skip.reason !== undefined ? { reason: step.skip.reason } : {}), ...(step.skip.source && step.skip.source !== step.pane ? { from: nameOf(step.skip.source) } : {}) };
|
|
56
|
+
if (step.each) out.each = { count: step.each.count, done: step.each.done, failed: step.each.failed, ...(step.each.keyed ? { reused: step.each.reused } : {}), ...(step.each.note ? { note: step.each.note } : {}) };
|
|
57
|
+
if (step.changes) out.changes = step.changes; // a state pane's keyed changes: { list: [{ op, key, at?, to? }…], count }
|
|
58
|
+
if (step.waits) out.waiting = step.waits; // ms of the step spent waiting, not working: a breakpoint, a debounce, a retry's back-off
|
|
59
|
+
if (step.attempts) out.attempts = step.attempts;
|
|
60
|
+
if (step.fallback !== undefined) out.fallback = `the error policy's fallback value, after: ${step.fallback}`;
|
|
61
|
+
if (step.caught) out.caughtBy = step.caught;
|
|
62
|
+
if (full) {
|
|
63
|
+
out.inputs = (step.inputs ?? []).map((i) => (i.setter !== undefined ? { name: i.name, from: nameOf(i.source), setter: `✎ ${i.setter}'s setter (write-only)` } : { name: i.name, from: nameOf(i.source), version: i.sourceVersion, ...(i.preview ? { value: hidden.get(i.source) ?? hidden.get(step.pane) ?? previewToText(i.preview, { maxLength: 1000 }) } : {}) }));
|
|
64
|
+
if (step.logs?.length) out.logs = step.logs.map((l) => (l.level === "log" ? l.text : `[${l.level}] ${l.text}`));
|
|
65
|
+
if (step.steps?.length) out.inside = step.steps.map((s) => stepText(s, run, (id) => s.name || id));
|
|
66
|
+
}
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @param {{ canvas: () => object, find: (c: object, ref: string) => object, nameOf: (c: object, id: string) => string,
|
|
72
|
+
* afterChange: (c: object, id: string, args: object) => Promise<object>, requireTrusted: (c: object, verb: string) => void }} t
|
|
73
|
+
*/
|
|
74
|
+
export function pinAndRunLogTools(t) {
|
|
75
|
+
const { canvas, find, nameOf, afterChange, requireTrusted } = t;
|
|
76
|
+
|
|
77
|
+
function runOf(c, ref = 1) {
|
|
78
|
+
const log = c.runLog;
|
|
79
|
+
if (!log?.runs.length) throw new Error("Nothing has run on this canvas yet (this session).");
|
|
80
|
+
const n = typeof ref === "string" && /^\d+$/.test(ref) ? Number(ref) : ref;
|
|
81
|
+
const run = log.get(n);
|
|
82
|
+
if (!run) throw new Error(`No run ${JSON.stringify(ref)}: the log has ${log.runs.length} (1 is the most recent; see mallory_list_runs).`);
|
|
83
|
+
return run;
|
|
84
|
+
}
|
|
85
|
+
const positionOf = (c, run) => c.runLog.runs.length - c.runLog.runs.indexOf(run);
|
|
86
|
+
/** An item key as agents read and write it: the key's own text (the run log's keys carry a type letter in front). */
|
|
87
|
+
const plainKey = (key) => String(key).slice(1);
|
|
88
|
+
|
|
89
|
+
return [
|
|
90
|
+
{
|
|
91
|
+
name: "pin_pane",
|
|
92
|
+
title: "Pin a pane's value",
|
|
93
|
+
description: [
|
|
94
|
+
"Pin a pane: it stops running and its pinned value goes downstream instead, so you can work on the panes below an expensive or flaky step (a model call, an API) without calling it again.",
|
|
95
|
+
"action pin: pin its current value (or, with `run`, the value it had in that run of the run log); unpin: run it for real again; set: pin `value` (any JSON; { \"$skip\": reason } pins a skip), which also works on a pane that never ran (sample data); unpin-all: unpin every pane on this canvas.",
|
|
96
|
+
`Only ${listWords(PINNABLE)} panes can be pinned, and only values JSON can hold (not functions, modules or class instances); at most 1 MB a pane. Pins are saved with the canvas; share links leave them out unless the person includes them. Panes that read it rerun once.`,
|
|
97
|
+
],
|
|
98
|
+
input: {
|
|
99
|
+
type: "object",
|
|
100
|
+
properties: {
|
|
101
|
+
pane: { type: "string", minLength: 1, description: "The pane: its name or id (see mallory_list_panes). Not for unpin-all." },
|
|
102
|
+
action: { type: "string", enum: ["pin", "unpin", "set", "unpin-all"] },
|
|
103
|
+
value: { description: "set: the value to pin (any JSON)." },
|
|
104
|
+
run: runRef,
|
|
105
|
+
wait: { type: "boolean", description: "Wait for the panes that read it to rerun (default true)." },
|
|
106
|
+
timeoutMs: { type: "integer", minimum: 0, maximum: 120000, description: "How long to wait, in ms (default 10000)." },
|
|
107
|
+
},
|
|
108
|
+
required: ["action"],
|
|
109
|
+
additionalProperties: false,
|
|
110
|
+
},
|
|
111
|
+
async run(args) {
|
|
112
|
+
const c = canvas();
|
|
113
|
+
const { action } = args;
|
|
114
|
+
if (action === "unpin-all") {
|
|
115
|
+
const pinned = c.order().filter((id) => c.panes.get(id).pin);
|
|
116
|
+
for (const id of pinned) c.setPin(id, null);
|
|
117
|
+
return { unpinned: pinned.map((id) => nameOf(c, id)) };
|
|
118
|
+
}
|
|
119
|
+
if (!args.pane) throw new Error(`Name the pane to ${action}.`);
|
|
120
|
+
const pane = find(c, args.pane);
|
|
121
|
+
guardWrite(pane, "pin or unpin");
|
|
122
|
+
if (action === "unpin") {
|
|
123
|
+
if (!pane.pin) throw new Error(`${pane.name || pane.id} isn't pinned.`);
|
|
124
|
+
c.setPin(pane.id, null);
|
|
125
|
+
return afterChange(c, pane.id, args);
|
|
126
|
+
}
|
|
127
|
+
if (action === "pin" && hiddenPanes(c).has(pane.id)) throw new Error(`${pane.name || pane.id} holds, or is computed from, something agents don't read as a value (${hiddenPanes(c).get(pane.id)}): it can't be pinned from here, since a pin holds the value in the canvas.`);
|
|
128
|
+
if (!isPinnable(pane.type)) throw new Error(`${pane.type === "import" ? "An import pane holds a module, which" : `A ${pane.type} pane`} can't be pinned (only ${listWords(PINNABLE)} panes).`);
|
|
129
|
+
let pin;
|
|
130
|
+
if (action === "set") {
|
|
131
|
+
if (!("value" in args)) throw new Error("set needs `value`: the JSON value to pin.");
|
|
132
|
+
pin = makePin(parsePinText(JSON.stringify(args.value ?? null)), { pane, source: "edited" });
|
|
133
|
+
} else if (args.run !== undefined) {
|
|
134
|
+
const run = runOf(c, args.run);
|
|
135
|
+
const [step] = pinnableSteps(run, { ids: [pane.id] });
|
|
136
|
+
if (!step) {
|
|
137
|
+
const [blocked] = pinBlockers(run, { ids: [pane.id] });
|
|
138
|
+
throw new Error(blocked ? `That run kept no value of ${pane.name || pane.id} to pin: ${blocked.reason}.` : `That run kept no value of ${pane.name || pane.id} to pin (it didn't run then, failed, or its value was too big or not JSON).`);
|
|
139
|
+
}
|
|
140
|
+
pin = makePin(step.status === "skipped" ? { skip: step.skip?.reason ?? null } : { value: step.output.json }, { pane, source: "run", now: step.startedAt });
|
|
141
|
+
} else {
|
|
142
|
+
pin = await capturePin(c, pane.id);
|
|
143
|
+
}
|
|
144
|
+
checkPinSize(pin, pinsBytes([...c.panes.values()].filter((p) => c.attached.has(p.id)), pane.id));
|
|
145
|
+
c.setPin(pane.id, pin);
|
|
146
|
+
return afterChange(c, pane.id, args);
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: "retry_failed",
|
|
151
|
+
title: "Retry a for-each pane's failed items",
|
|
152
|
+
description: [
|
|
153
|
+
"Run a keyed for-each pane's failed items again, only those: the completed ones are reused from the checkpoint its failed run left in the run log, never run again, and nothing upstream runs. Like the person's \"Retry the failed items\", with no approval card; a retry is a new attempt of that run (the run log links them).",
|
|
154
|
+
"It needs the pane's for-each to keep a recovery checkpoint (each.recover) before it runs, and it can only resend what the person's run log retention kept: a pane or source whose policy keeps summaries, redacts, or was purged has no checkpoint to retry from, and the refusal says why. A changed code, key or wiring makes the checkpoint stale (run the pane with mallory_run_pane instead). Whatever a completed item sent outside mallory was sent then: there is no exactly-once promise.",
|
|
155
|
+
"dryRun: what a retry would do (the failed items' keys, errors and kept payloads as JSON text, one element per iterated input, and how many completed), running nothing. edits: { key: JSON text } replaces failed items' payloads first (only failed ones, keeping their key). Returns the attempt, its status, how many items ran and were reused, and the pane's value or error.",
|
|
156
|
+
],
|
|
157
|
+
input: {
|
|
158
|
+
type: "object",
|
|
159
|
+
properties: {
|
|
160
|
+
pane: { type: "string", minLength: 1, description: "The for-each pane: its name or id (see mallory_list_panes)." },
|
|
161
|
+
run: { ...runRef, description: "The failed run to retry: 1 is the most recent run, or a run id from mallory_list_runs. Default: the pane's latest failed run." },
|
|
162
|
+
dryRun: { type: "boolean", description: "Only say what would be retried; nothing runs." },
|
|
163
|
+
edits: { type: "object", additionalProperties: { type: "string" }, description: "Failed items' payloads to replace, by item key (as dryRun lists them): JSON text, one element of the iterated input, with the same key." },
|
|
164
|
+
acceptRerun: { type: "boolean", description: "Also run completed items whose result can't be restored (not JSON, or after a reload) instead of refusing." },
|
|
165
|
+
timeoutMs: { type: "integer", minimum: 0, maximum: 120000, description: "How long to wait for the retry, in ms (default 30000)." },
|
|
166
|
+
},
|
|
167
|
+
required: ["pane"],
|
|
168
|
+
additionalProperties: false,
|
|
169
|
+
},
|
|
170
|
+
async run({ pane, run: ref, dryRun = false, edits, acceptRerun = false, timeoutMs = 30000 }) {
|
|
171
|
+
const c = canvas();
|
|
172
|
+
const p = find(c, pane);
|
|
173
|
+
if (edits && Object.keys(edits).length && !dryRun) guardWrite(p, "edit the failed items of");
|
|
174
|
+
const label = p.name || p.id;
|
|
175
|
+
if (!p.each?.on) {
|
|
176
|
+
const reason = `${label} isn't a for-each pane: only a keyed for-each pane's items can be retried (rerun a pane with mallory_run_pane)`;
|
|
177
|
+
if (dryRun) return { pane: label, retryable: false, reason };
|
|
178
|
+
throw new Error(`${reason}.`);
|
|
179
|
+
}
|
|
180
|
+
if (!dryRun) requireTrusted(c, "retry items");
|
|
181
|
+
const runId = ref === undefined ? undefined : runOf(c, ref).id;
|
|
182
|
+
const offer = c.retryOffer(p.id, runId);
|
|
183
|
+
if (dryRun) {
|
|
184
|
+
if (!offer.ok) return { pane: label, retryable: false, reason: offer.reason };
|
|
185
|
+
return {
|
|
186
|
+
pane: label,
|
|
187
|
+
retryable: true,
|
|
188
|
+
run: positionOf(c, c.runLog.runs.find((r) => r.id === offer.run)),
|
|
189
|
+
completed: offer.completed,
|
|
190
|
+
failed: offer.failed.map((f) => ({ key: plainKey(f.key), index: f.index, message: f.message, ...(f.given !== undefined ? { given: String(f.given).length > 4000 ? `${String(f.given).slice(0, 3999)}…` : String(f.given) } : {}), ...(f.unsupported !== undefined ? { unsupported: f.unsupported } : {}) })),
|
|
191
|
+
...(offer.unsupported.length ? { cantRestore: offer.unsupported.map((u) => ({ key: plainKey(u.key), why: u.why })), note: "Those completed items' results can't be restored: a retry refuses unless acceptRerun runs them again." } : {}),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
if (!offer.ok) throw new Error(`Can't retry ${label}: ${offer.reason}.`);
|
|
195
|
+
// Edits by the key as dryRun shows it (or the run log's own key).
|
|
196
|
+
let keyed;
|
|
197
|
+
if (edits && Object.keys(edits).length) {
|
|
198
|
+
const checkpointKeys = (offer.checkpoint?.items ?? []).map((i) => i.key);
|
|
199
|
+
keyed = {};
|
|
200
|
+
for (const [k, text] of Object.entries(edits)) {
|
|
201
|
+
const key = checkpointKeys.includes(k) ? k : (offer.failed.find((f) => plainKey(f.key) === k) ?? offer.checkpoint?.items?.find((i) => plainKey(i.key) === k))?.key;
|
|
202
|
+
if (!key) throw new Error(`No item with the key ${JSON.stringify(k)} in that run (the failed ones: ${offer.failed.map((f) => JSON.stringify(plainKey(f.key))).join(", ")}).`);
|
|
203
|
+
keyed[key] = text;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
let timer;
|
|
207
|
+
const timeout = new Promise((resolve) => (timer = setTimeout(() => resolve({ timedOut: true }), timeoutMs)));
|
|
208
|
+
let out;
|
|
209
|
+
try {
|
|
210
|
+
out = await Promise.race([c.retryFailedItems(p.id, { run: offer.run, edits: keyed, acceptRerun }), timeout]);
|
|
211
|
+
} finally {
|
|
212
|
+
clearTimeout(timer);
|
|
213
|
+
}
|
|
214
|
+
if (out.timedOut) return { pane: label, retried: true, note: `Still running after ${timeoutMs} ms; check again with mallory_get_pane or mallory_get_run.` };
|
|
215
|
+
if (!out.ok) throw new Error(`Can't retry ${label}: ${out.reason}.`);
|
|
216
|
+
const after = await afterChange(c, p.id, { wait: false });
|
|
217
|
+
return { ...after, pane: label, retried: true, attempt: out.attempt, status: out.status, ran: out.ran, reused: out.reused, failed: out.failed };
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
name: "list_runs",
|
|
222
|
+
title: "The canvas's recent runs (the run log)",
|
|
223
|
+
description:
|
|
224
|
+
"The run log of the open canvas, newest first: each canvas run (from the moment something started until everything settled), what started it (an edit, an input, run-all, an agent's tool), when, how long, its status (the worst of its panes: error, skipped or done) and how many panes finished, failed or were skipped. Read one with mallory_get_run. With `cost`: instead, the cost of the runs added up per pane (how often it ran, total and p50/p95 runtime, time spent waiting apart from working, queueing, critical path; for wait, decision and gate panes `held`: how long their instances waited, start to outcome, kept apart from runtime and waiting); wall-clock time, not CPU or GPU time; time stopped at a breakpoint, in a debounce or retry back-off, in a wait or decision pane and in queues is waiting, never runtime; skipped, cancelled and reused runs are counted but not timed; a pane without timing says \"unknown\". `since`, `until` or `lastSeconds` choose the runs by when they started; `instances` adds each repeater instance's numbers under its pane; `warm` leaves cold starts (a pane's first run since the sandbox started) out of p50 and p95.",
|
|
225
|
+
readOnly: true,
|
|
226
|
+
untrusted: true,
|
|
227
|
+
input: {
|
|
228
|
+
type: "object",
|
|
229
|
+
properties: {
|
|
230
|
+
cost: {
|
|
231
|
+
type: "object",
|
|
232
|
+
description: "Add the runs up per pane instead of listing them. Default window: every run the log keeps.",
|
|
233
|
+
properties: {
|
|
234
|
+
last: { type: "integer", minimum: 1, maximum: 200, description: "Only the newest n runs." },
|
|
235
|
+
run: runRef,
|
|
236
|
+
within: { type: "string", minLength: 1, description: "Only the panes inside this subgraph pane or repeater (name or id)." },
|
|
237
|
+
since: { type: "string", format: "date-time", description: "Only runs that started at or after this time (ISO 8601)." },
|
|
238
|
+
until: { type: "string", format: "date-time", description: "Only runs that started at or before this time (ISO 8601)." },
|
|
239
|
+
lastSeconds: { type: "number", exclusiveMinimum: 0, description: "Only runs that started in the last n seconds." },
|
|
240
|
+
instances: { type: "boolean", description: "Add, under each repeater pane, its numbers per instance (costliest first)." },
|
|
241
|
+
warm: { type: "boolean", description: "p50, p95 and the longest leave a pane's cold starts out (the totals keep them)." },
|
|
242
|
+
sort: { type: "string", enum: SORTS, description: "Biggest first (name: A to Z). Default runtime." },
|
|
243
|
+
limit: { type: "integer", minimum: 1, maximum: 200, description: "At most this many panes (default 30)." },
|
|
244
|
+
},
|
|
245
|
+
additionalProperties: false,
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
additionalProperties: false,
|
|
249
|
+
},
|
|
250
|
+
run({ cost } = {}) {
|
|
251
|
+
const c = canvas();
|
|
252
|
+
if (cost) {
|
|
253
|
+
if (!c.runLog?.runs.length) return { rows: [], note: "Nothing has run on this canvas yet (this session)." };
|
|
254
|
+
const options = { last: cost.last, warm: cost.warm === true };
|
|
255
|
+
const when = (name, text) => {
|
|
256
|
+
const ms = Date.parse(text);
|
|
257
|
+
if (!Number.isFinite(ms)) throw new Error(`${name} must be a date and time like 2026-10-14T09:00:00Z (got "${text}").`);
|
|
258
|
+
return ms;
|
|
259
|
+
};
|
|
260
|
+
if (cost.since !== undefined) options.since = when("since", cost.since);
|
|
261
|
+
if (cost.until !== undefined) options.until = when("until", cost.until);
|
|
262
|
+
if (cost.lastSeconds !== undefined) options.since = Math.max(options.since ?? -Infinity, c.runLog.clock() - cost.lastSeconds * 1000);
|
|
263
|
+
if (cost.run !== undefined) options.run = runOf(c, cost.run).id;
|
|
264
|
+
if (cost.within !== undefined) options.within = find(c, cost.within).id;
|
|
265
|
+
// A wait, decision or gate pane's held time (start to outcome) from the wait clock, apart from runtime, inside subgraphs and repeaters too.
|
|
266
|
+
const holds = collectHolds(c);
|
|
267
|
+
const res = attachHolds(aggregateRuns(c.runLog.list(), options), (row) => holds[row.key], { scope: "Held time covers the holds each pane remembers (its newest 1000), not only the chosen runs." });
|
|
268
|
+
return costReport(res, { sort: cost.sort, limit: cost.limit, instances: cost.instances === true });
|
|
269
|
+
}
|
|
270
|
+
const runs = c.runLog?.list() ?? [];
|
|
271
|
+
return runs.length ? { runs: runs.map((r, i) => runSummary(r, i + 1)) } : { runs: [], note: "Nothing has run on this canvas yet (this session)." };
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
name: "get_run",
|
|
276
|
+
title: "One run from the run log",
|
|
277
|
+
description:
|
|
278
|
+
"One canvas run from the run log: every pane that ran, in the order they started, with its status, timing and value (or error, or skip reason). With `pane`: that pane in that run in full: what each input was (the source's value then), its value (its full JSON when the log kept it), its error, console lines, for-each cells and, for a subgraph, the panes inside; with `compareWith`, what changed in its value since another run (an agent pane: where its two traces first diverge, a table of steps, calls and tokens, and how its final answers differ; one made by forking another run says which, and at which step).",
|
|
279
|
+
readOnly: true,
|
|
280
|
+
untrusted: true,
|
|
281
|
+
input: { type: "object", properties: { run: runRef, pane: { type: "string", minLength: 1, description: "A pane (name or id) to read in full." }, compareWith: { ...runRef, description: "Another run to compare the pane's value with (needs `pane`)." } }, additionalProperties: false },
|
|
282
|
+
run({ run: ref = 1, pane, compareWith }) {
|
|
283
|
+
const c = canvas();
|
|
284
|
+
if (compareWith !== undefined && !pane) throw new Error("compareWith needs `pane`: the pane whose value to compare.");
|
|
285
|
+
const run = runOf(c, ref);
|
|
286
|
+
const name = (id) => nameOf(c, id);
|
|
287
|
+
const head = runSummary(run, positionOf(c, run));
|
|
288
|
+
const hidden = hiddenPanes(c);
|
|
289
|
+
if (!pane) return { ...head, steps: run.steps.filter((s) => s.status !== "superseded" && s.status !== "cancelled").map((s) => stepText(s, run, name, { hidden })) };
|
|
290
|
+
const p = find(c, pane);
|
|
291
|
+
const step = stepOf(run, p.id) ?? flatSteps(run.steps).find((s) => s.pane === p.id);
|
|
292
|
+
if (!step) return { ...head, pane: p.name || p.id, note: "It didn't run in that run." };
|
|
293
|
+
const out = { ...head, step: stepText(step, run, name, { full: true, hidden }) };
|
|
294
|
+
if (step.fork) {
|
|
295
|
+
const parent = forkSource(c.runLog.runs, p.id, step);
|
|
296
|
+
out.step.forkedFrom = { ...(parent ? { run: positionOf(c, parent) } : { note: "that run is no longer in the log" }), step: step.fork.at + 1, edited: step.fork.edited };
|
|
297
|
+
}
|
|
298
|
+
if (compareWith !== undefined) {
|
|
299
|
+
const other = runOf(c, compareWith);
|
|
300
|
+
const before = stepOf(other, p.id);
|
|
301
|
+
if (!before?.output || !("json" in before.output) || !step.output || !("json" in step.output)) out.compare = { note: `One of the two runs kept no full value of this pane${[whyNoValue(before), whyNoValue(step)].filter(Boolean).length ? ` (${[...new Set([whyNoValue(before), whyNoValue(step)].filter(Boolean))].join("; ")})` : ""}.` };
|
|
302
|
+
else if (isAgentValue(before.output.json) && isAgentValue(step.output.json)) out.compare = { run: positionOf(c, other), agent: diffAgentRuns(before.output.json, step.output.json) };
|
|
303
|
+
else out.compare = { run: positionOf(c, other), changes: jsonDiff(before.output.json, step.output.json) };
|
|
304
|
+
}
|
|
305
|
+
return out;
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
];
|
|
309
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// The runs tool group (src/webmcp/groups.js): its tools, as specs for createTools (src/webmcp/tools.js).
|
|
2
|
+
import { previewToText } from "../text.js";
|
|
3
|
+
import { hiddenText, hiddenPanes } from "../hidden.js";
|
|
4
|
+
import { replaySteps } from "../../model/history.js";
|
|
5
|
+
import { pinAndRunLogTools } from "./run-tools.js";
|
|
6
|
+
import { wireTools } from "./wire-tools.js";
|
|
7
|
+
import { filterEntries, LEVELS as DEBUG_LEVELS } from "../../model/debug-log.js";
|
|
8
|
+
import { rootName } from "../../model/value-path.js";
|
|
9
|
+
import { paneRef, round, runText, hiddenRunText } from "./shared.js";
|
|
10
|
+
|
|
11
|
+
/** The runs group's tool specs. `ctx` is the helpers createTools builds (the canvas, finding panes, summaries, waiting). */
|
|
12
|
+
export function runsTools(ctx) {
|
|
13
|
+
const { host, canvas, find, nameOf, requireTrusted, afterChange } = ctx;
|
|
14
|
+
return [
|
|
15
|
+
{
|
|
16
|
+
name: "get_debug_log",
|
|
17
|
+
title: "Read the debug log",
|
|
18
|
+
description: [
|
|
19
|
+
"The debug panel's stream for the open canvas, oldest first: every pane's console lines, values logged with log(label, value) (as text, with `path` to drill in from the label), errors, skips, network or API key requests that were refused (host and pane; never a key's value), and GPU context warnings (the page nearing the browser's cap on WebGL contexts, a pane whose context was taken back; kind `gpu`).",
|
|
20
|
+
"Each entry has `seq`: pass the last one you saw as `since` to read only newer ones. Memory only, the last 500 entries; a pane muted in the panel is still here.",
|
|
21
|
+
],
|
|
22
|
+
readOnly: true,
|
|
23
|
+
untrusted: true,
|
|
24
|
+
input: {
|
|
25
|
+
type: "object",
|
|
26
|
+
properties: {
|
|
27
|
+
panes: { type: "array", minItems: 1, items: paneRef("A pane"), description: "Only these panes (a subgraph pane includes the panes inside it)." },
|
|
28
|
+
level: { type: "string", enum: DEBUG_LEVELS, description: "Only entries at least this severe: error, warn, info, log, debug (default: all)." },
|
|
29
|
+
since: { type: "integer", minimum: 0, description: "Only entries after this seq." },
|
|
30
|
+
limit: { type: "integer", minimum: 1, maximum: 500, description: "At most this many, the newest (default 100)." },
|
|
31
|
+
},
|
|
32
|
+
additionalProperties: false,
|
|
33
|
+
},
|
|
34
|
+
run({ panes, level, since, limit = 100 }) {
|
|
35
|
+
const c = canvas();
|
|
36
|
+
const stream = host.debugLog?.();
|
|
37
|
+
if (!stream) throw new Error("The debug log is kept by the mallory page; it isn't available here.");
|
|
38
|
+
const prefix = c.prefix ?? "";
|
|
39
|
+
const ids = panes?.map((ref) => `${prefix}${find(c, ref).id}`);
|
|
40
|
+
const levels = level ? DEBUG_LEVELS.slice(0, DEBUG_LEVELS.indexOf(level) + 1) : undefined;
|
|
41
|
+
const all = filterEntries(stream.entries(), { canvas: stream.canvasId, panes: ids, under: ids ? (p) => ids.some((id) => p.startsWith(`${id}/`)) : undefined, levels, since });
|
|
42
|
+
const shown = all.slice(-limit);
|
|
43
|
+
// What a hidden pane (or a pane inside a hidden host) logged is not read: src/webmcp/hidden.js.
|
|
44
|
+
const hid = [...hiddenPanes(c)].map(([id, text]) => [`${prefix}${id}`, text]);
|
|
45
|
+
const hiddenFor = (pane) => (pane ? hid.find(([id]) => pane === id || pane.startsWith(`${id}/`))?.[1] : undefined);
|
|
46
|
+
return {
|
|
47
|
+
entries: shown.map((e) => hiddenFor(e.pane) ? { seq: e.seq, at: new Date(e.at).toISOString(), pane: stream.nameOf(e.pane), level: e.level, kind: e.kind, text: hiddenFor(e.pane) } : ({
|
|
48
|
+
seq: e.seq,
|
|
49
|
+
at: new Date(e.at).toISOString(),
|
|
50
|
+
pane: e.pane ? stream.nameOf(e.pane) : "sandbox",
|
|
51
|
+
level: e.level,
|
|
52
|
+
kind: e.kind,
|
|
53
|
+
text: e.preview ? `${e.label !== undefined ? `${e.label}: ` : ""}${previewToText(e.preview, { maxLength: 2000 })}` : e.text,
|
|
54
|
+
...(e.preview ? { path: rootName(e.label, e.pane ? stream.nameOf(e.pane).split(" › ").at(-1) : undefined) } : {}),
|
|
55
|
+
})),
|
|
56
|
+
...(all.length > shown.length ? { omitted: all.length - shown.length } : {}),
|
|
57
|
+
last: stream.lastSeq(),
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
...wireTools({ canvas, find, nameOf, paneRef, host }), // get_wire: what the wire inspector shows (src/webmcp/tools/wire-tools.js)
|
|
62
|
+
|
|
63
|
+
// ── pinned values and the run log (src/webmcp/tools/run-tools.js) ──
|
|
64
|
+
|
|
65
|
+
...pinAndRunLogTools({ canvas, find, nameOf, afterChange, requireTrusted }), // pin_pane, retry_failed, list_runs, get_run
|
|
66
|
+
|
|
67
|
+
// ── run history and replay (src/model/history.js), read-only ──
|
|
68
|
+
|
|
69
|
+
{
|
|
70
|
+
name: "get_run_history",
|
|
71
|
+
title: "A pane's recent runs",
|
|
72
|
+
description: "A pane's last runs in this session, newest first: when each started, how long it took, how it ended (done, error, skipped, superseded by a newer run, or cancelled) and a one-line preview of its value or its error. The same as its \"Run history…\".",
|
|
73
|
+
readOnly: true,
|
|
74
|
+
untrusted: true,
|
|
75
|
+
input: { type: "object", properties: { pane: paneRef() }, required: ["pane"], additionalProperties: false },
|
|
76
|
+
run({ pane }) {
|
|
77
|
+
const c = canvas();
|
|
78
|
+
const p = find(c, pane);
|
|
79
|
+
const hide = hiddenText(c, p.id); // a live capture's, or a capture log the person has not let agents read
|
|
80
|
+
return { pane: p.name || p.id, runs: (c.runs?.runsOf(p.id) ?? []).map((r) => (hide ? hiddenRunText(r, hide) : runText(r))) };
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "get_last_run",
|
|
85
|
+
title: "The canvas's last run, step by step",
|
|
86
|
+
description: "The steps of the canvas's most recent run (everything from the moment something started while nothing was running until it all settled), in the order the panes started: each pane, its start offset and duration in ms, and its value or error. What \"Replay the last run\" steps through; superseded runs are left out.",
|
|
87
|
+
readOnly: true,
|
|
88
|
+
untrusted: true,
|
|
89
|
+
input: { type: "object", properties: {}, additionalProperties: false },
|
|
90
|
+
run() {
|
|
91
|
+
const c = canvas();
|
|
92
|
+
const burst = c.runs?.lastBurst();
|
|
93
|
+
if (!burst) return { steps: [], note: "Nothing has run on this canvas yet (this session)." };
|
|
94
|
+
return {
|
|
95
|
+
running: burst.end === undefined,
|
|
96
|
+
steps: replaySteps(burst).map((s) => ({ step: s.step + 1, pane: nameOf(c, s.id), offsetMs: round(s.offset), ...(hiddenText(c, s.id) ? hiddenRunText(s, hiddenText(c, s.id)) : runText(s)) })),
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
];
|
|
101
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// The function scaffold tool (src/model/function-scaffold.js): what the
|
|
2
|
+
// "Scaffold a function from this pane…" and "Edit function scaffold…" dialogs
|
|
3
|
+
// do, as one tool. With `apply` left out it only previews: the inputs a
|
|
4
|
+
// signature proposes (names, types, widgets, control metadata), the typed
|
|
5
|
+
// outputs and the call pane's code. Nothing is executed to read a signature
|
|
6
|
+
// (the text is parsed), and a module's code never reaches the page, so an
|
|
7
|
+
// import pane needs `signature`. Applying makes ordinary panes in one undo
|
|
8
|
+
// step, and editing a scaffold shows what a change does to its ports before
|
|
9
|
+
// `apply`.
|
|
10
|
+
import { proposeScaffold, applyScaffold, editedPlan, previewUpdate, updateScaffold, scaffoldOf, livePane, sourceOf } from "../../model/function-scaffold.js";
|
|
11
|
+
import { typeText } from "../../model/types.js";
|
|
12
|
+
import { guardWrite } from "./shared.js";
|
|
13
|
+
|
|
14
|
+
const WIDGET = {
|
|
15
|
+
type: "object",
|
|
16
|
+
description: "kind (number, range, text, checkbox, select, color, date, json, form, xy, curve), value, min, max, step, options (select: comma separated; numeric: true for a select of numbers).",
|
|
17
|
+
properties: { kind: { type: "string" }, value: {}, min: { type: "number" }, max: { type: "number" }, step: { type: "number" }, options: { type: "string" }, numeric: { type: "boolean" }, fields: { type: "string" }, xMin: { type: "number" }, xMax: { type: "number" }, yMin: { type: "number" }, yMax: { type: "number" } },
|
|
18
|
+
additionalProperties: false,
|
|
19
|
+
};
|
|
20
|
+
const INPUT_EDIT = {
|
|
21
|
+
type: "object",
|
|
22
|
+
properties: {
|
|
23
|
+
name: { type: "string", description: "The input's name: a variable in the call pane's code." },
|
|
24
|
+
type: { type: ["string", "object", "null"], description: "A port type (number, array<string>, media:image, …) or a JSON Schema; null or \"any\" for none." },
|
|
25
|
+
widget: WIDGET,
|
|
26
|
+
description: { type: "string" },
|
|
27
|
+
include: { type: "boolean", description: "false leaves the parameter out (the call passes undefined)." },
|
|
28
|
+
useDefault: { type: "boolean", description: "true: null in the widget means 'use the function's own default'." },
|
|
29
|
+
group: { type: ["string", "null"] },
|
|
30
|
+
label: { type: ["string", "null"] },
|
|
31
|
+
help: { type: ["string", "null"] },
|
|
32
|
+
unit: { type: ["string", "null"] },
|
|
33
|
+
order: { type: "number" },
|
|
34
|
+
},
|
|
35
|
+
additionalProperties: false,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** An edit as the plan takes it: the control fields under `control`. */
|
|
39
|
+
function editOf(e) {
|
|
40
|
+
const { group, label, help, unit, order, ...rest } = e;
|
|
41
|
+
const control = {};
|
|
42
|
+
for (const [k, v] of Object.entries({ group, label, help, unit, order })) if (v !== undefined) control[k] = v;
|
|
43
|
+
if (help !== undefined && rest.description === undefined) rest.description = help ?? "";
|
|
44
|
+
return { ...rest, ...(Object.keys(control).length ? { control } : {}) };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const rowOf = (i) => ({
|
|
48
|
+
key: i.key,
|
|
49
|
+
name: i.name,
|
|
50
|
+
type: i.type === undefined ? "any" : typeof i.type === "string" ? i.type : typeText(i.type),
|
|
51
|
+
widget: i.widget,
|
|
52
|
+
...(i.control && Object.keys(i.control).length ? { control: i.control } : {}),
|
|
53
|
+
...(i.description ? { description: i.description } : {}),
|
|
54
|
+
include: i.include,
|
|
55
|
+
...(i.useDefault ? { useDefault: true } : {}),
|
|
56
|
+
...(i.notes?.length ? { notes: i.notes } : {}),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @param {{ canvas: () => object, find: (c: object, ref: string) => object, paneRef: (what?: string) => object,
|
|
61
|
+
* afterChange: (c: object, id: string, args: object) => Promise<object>, waitArg: object, timeoutArg: object, host: object }} t
|
|
62
|
+
*/
|
|
63
|
+
export function scaffoldTools({ canvas, find, paneRef, afterChange, waitArg, timeoutArg, host }) {
|
|
64
|
+
return [
|
|
65
|
+
{
|
|
66
|
+
name: "scaffold_function",
|
|
67
|
+
title: "Scaffold a function",
|
|
68
|
+
description: [
|
|
69
|
+
"Turn a function's signature into typed input widgets and a call pane: an ordinary, editable function canvas (a subgraph pane, or plain panes with `as: \"panes\"`). The signature is parsed as text: the function is never run, and a module's code stays in the Worker, so an import pane needs `signature` (a function, `name(a, b = 2)`, a parameter list or JSDoc). Inferred names, types and widgets are suggestions: review `inputs` and correct them with `inputs` (keyed by input name or key).",
|
|
70
|
+
"Without `apply` it only previews: `inputs` (name, type, widget, control group/order/label/help/unit), `outputs` (typed from the return type), `code` and `problems`. With `apply: true` it makes the panes (one undo step). `pane`: an eval pane (its code is the signature; `from: \"inline\"` copies the function in, `\"wire\"` reads it from the pane's value, `member` its exported name) or an import pane. Give a scaffold's own subgraph pane (or, for one made with `as: \"panes\"`, its call pane) as `pane` to edit it: the preview adds `changes` (renamed, retyped, added, removed ports and the wires and parameters they touch) before `apply` updates it. Returns the plan, and the new pane when applied.",
|
|
71
|
+
].join(" "),
|
|
72
|
+
input: {
|
|
73
|
+
type: "object",
|
|
74
|
+
properties: {
|
|
75
|
+
pane: paneRef("The pane the function comes from (eval or import), or an existing scaffold subgraph to edit"),
|
|
76
|
+
signature: { type: "string", maxLength: 200000, description: "The function's source or signature text. Default: an eval pane's code." },
|
|
77
|
+
function: { type: "string", description: "Which function in the text (default: the first; the preview lists the names)." },
|
|
78
|
+
from: { type: "string", enum: ["inline", "wire"], description: "inline: copy the function into the call pane; wire: read it from the source pane's value." },
|
|
79
|
+
member: { type: "string", description: "wire: the exported name; \"\" for the value itself or a default export." },
|
|
80
|
+
as: { type: "string", enum: ["subgraph", "panes"], description: "A function canvas (default) or plain panes on this canvas." },
|
|
81
|
+
name: { type: "string", description: "The new pane's name." },
|
|
82
|
+
inputs: { type: "object", additionalProperties: INPUT_EDIT, description: "Edits by input name or key (p0, p1.field)." },
|
|
83
|
+
outputs: { type: ["array", "null"], items: { type: "object", properties: { name: { type: "string" }, type: { type: "string" }, description: { type: "string" } }, required: ["name"], additionalProperties: false }, description: "Replace the typed outputs found from the return type; null for none." },
|
|
84
|
+
apply: { type: "boolean", description: "Make (or update) the panes. Default: preview only." },
|
|
85
|
+
wait: waitArg,
|
|
86
|
+
timeoutMs: timeoutArg,
|
|
87
|
+
},
|
|
88
|
+
additionalProperties: false,
|
|
89
|
+
},
|
|
90
|
+
async run(args) {
|
|
91
|
+
const c = canvas();
|
|
92
|
+
const pane = args.pane ? find(c, args.pane) : undefined;
|
|
93
|
+
if (pane && args.apply === true) guardWrite(pane, "scaffold");
|
|
94
|
+
const editing = Boolean(pane && scaffoldOf(pane));
|
|
95
|
+
const key = (plan, ref) => plan.inputs.find((i) => i.key === ref || i.suggested === ref || i.name === ref)?.key;
|
|
96
|
+
const edits = (plan, given = {}) => {
|
|
97
|
+
const out = {};
|
|
98
|
+
for (const [ref, e] of Object.entries(given)) {
|
|
99
|
+
const k = key(plan, ref);
|
|
100
|
+
if (!k) throw new Error(`There is no input "${ref}". Inputs: ${plan.inputs.map((i) => `${i.name} (${i.key})`).join(", ") || "none"}.`);
|
|
101
|
+
out[k] = editOf(e);
|
|
102
|
+
}
|
|
103
|
+
return out;
|
|
104
|
+
};
|
|
105
|
+
let plan;
|
|
106
|
+
let changes;
|
|
107
|
+
if (editing) {
|
|
108
|
+
if (pane.ref) throw new Error("A linked subgraph follows its canvas: edit the scaffold in that canvas.");
|
|
109
|
+
const base = editedPlan(livePane(c, pane.id), {}, { canvas: c });
|
|
110
|
+
plan = editedPlan(livePane(c, pane.id), edits(base, args.inputs), { canvas: c, ...(args.outputs === undefined ? {} : { outputs: args.outputs }) });
|
|
111
|
+
changes = previewUpdate(c, pane.id, plan);
|
|
112
|
+
} else {
|
|
113
|
+
let text = args.signature;
|
|
114
|
+
const source = sourceOf(pane);
|
|
115
|
+
if (text === undefined) {
|
|
116
|
+
if (!pane) throw new Error("Give a pane (an eval pane's code is read) or a signature.");
|
|
117
|
+
if (source.kind === "import") throw new Error(`"${pane.name}" is an import pane: its module runs in the Worker, so its signature can't be read here. Pass signature (a function, \`name(a, b = 2)\`, a parameter list or JSDoc); nothing is called to find out.`);
|
|
118
|
+
if (source.kind !== "eval") throw new Error(`A ${pane.type} pane has no function to read: pass signature.`);
|
|
119
|
+
text = source.text;
|
|
120
|
+
}
|
|
121
|
+
const base = proposeScaffold(text, { fn: args.function, from: args.from, member: args.member, sourceName: pane?.name, as: args.as, name: args.name });
|
|
122
|
+
if (!base.ok) throw new Error(base.problem);
|
|
123
|
+
plan = proposeScaffold(text, {
|
|
124
|
+
fn: args.function,
|
|
125
|
+
from: args.from,
|
|
126
|
+
member: args.member ?? (source.kind === "eval" && source.expression && args.from === "wire" ? "" : undefined),
|
|
127
|
+
sourceName: pane?.name,
|
|
128
|
+
as: args.as,
|
|
129
|
+
name: args.name,
|
|
130
|
+
inputs: edits(base, args.inputs),
|
|
131
|
+
...(args.outputs === null ? { outputs: null } : args.outputs ? { outputs: { outputs: args.outputs } } : {}),
|
|
132
|
+
});
|
|
133
|
+
if (!plan.ok) throw new Error(plan.problem);
|
|
134
|
+
}
|
|
135
|
+
const report = {
|
|
136
|
+
function: plan.fn.name,
|
|
137
|
+
async: plan.fn.async,
|
|
138
|
+
...(editing ? {} : { functions: plan.names, from: plan.from, ...(plan.from === "wire" ? { member: plan.member, port: plan.lib } : {}), as: plan.as, name: plan.name }),
|
|
139
|
+
inputs: plan.inputs.map(rowOf),
|
|
140
|
+
outputs: plan.outputs.map((o) => ({ name: o.name, type: o.type === undefined ? "any" : typeText(o.type), ...(o.description ? { description: o.description } : {}) })),
|
|
141
|
+
code: plan.code,
|
|
142
|
+
problems: plan.problems,
|
|
143
|
+
warnings: plan.warnings,
|
|
144
|
+
...(plan.notes?.length ? { notes: plan.notes } : {}),
|
|
145
|
+
...(changes ? { changes: { ports: changes.ports, wiresFlagged: changes.flagged, parametersDropped: changes.params, callEditedByHand: changes.handEdited } } : {}),
|
|
146
|
+
applied: false,
|
|
147
|
+
};
|
|
148
|
+
if (!args.apply) return { ...report, next: plan.problems.length ? "Fix the problems, then apply." : "Review the inputs, then call again with apply: true." };
|
|
149
|
+
if (plan.problems.length) throw new Error(`Not applied: ${plan.problems.join(" ")}`);
|
|
150
|
+
if (editing) {
|
|
151
|
+
updateScaffold(c, pane.id, plan);
|
|
152
|
+
host.refresh?.(pane.id, pane.type === "subgraph" ? ["graph", "inputs"] : ["code", "inputs", "outputs"]);
|
|
153
|
+
return { ...report, applied: true, ...(await afterChange(c, pane.id, args)), undo: "mallory_undo puts the scaffold back." };
|
|
154
|
+
}
|
|
155
|
+
const made = applyScaffold(c, plan, { source: pane?.id });
|
|
156
|
+
host.select?.(made.id);
|
|
157
|
+
return { ...report, applied: true, pane: await afterChange(c, made.id, args), undo: "mallory_undo takes the panes away (one step)." };
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
];
|
|
161
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// The serial tool (src/serial/config.js): agents READ the canvas's serial settings
|
|
2
|
+
// and recordings. They cannot connect a port, choose or open a device, accept the browser's
|
|
3
|
+
// permission, send to a device or see its data: Web Serial is a hardware permission that
|
|
4
|
+
// needs the person's click (WHY_NOT.HARDWARE on the serial.* commands). The settings are
|
|
5
|
+
// plain canvas data (baud rate, framing, channel, USB make/model filters): no port ids.
|
|
6
|
+
import { effective, fixtureBytes, portSettings } from "../../serial/config.js";
|
|
7
|
+
import { LIMITS, PANE_LIMITS } from "../../serial/broker.js";
|
|
8
|
+
// Pane write permissions (#384, src/serial/grants.js) are never read or changed here: not imported, not reported.
|
|
9
|
+
|
|
10
|
+
/** @param {{ canvas: () => object }} t */
|
|
11
|
+
export function serialTools({ canvas }) {
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
name: "serial",
|
|
15
|
+
title: "Serial settings",
|
|
16
|
+
description: [
|
|
17
|
+
"Read the canvas's serial port settings (read-only): baud rate and line settings, how bytes are framed (lines, delimiter, length-prefixed, COBS, SLIP) and decoded (text, json, binary), the event channel packets are sent on, USB make/model filters, and the recorded byte streams saved with the canvas (name and size).",
|
|
18
|
+
"A pane with receive: { channel } gets { type: 'packet', seq, time, format, length, text | value | bytes } per frame and { type: 'error', reason, message } for a frame that couldn't be read.",
|
|
19
|
+
"Extra ports (ports: name and settings) send packets with port: <name>. Pane code may write with serial.write(data, { port }) and serial.signals({ dataTerminalReady, requestToSend }); each write needs the port open and the person's permission for this canvas and port, asked in the page, which you can neither see nor change.",
|
|
20
|
+
"You cannot connect, pick a port, send to a device or see live data: a serial port is a hardware permission the person grants with a click in the page's serial panel. To test a pane, use mallory_send_event with a packet on that channel.",
|
|
21
|
+
].join(" "),
|
|
22
|
+
input: { type: "object", properties: {}, additionalProperties: false },
|
|
23
|
+
run() {
|
|
24
|
+
const c = canvas();
|
|
25
|
+
const root = c.root ?? c;
|
|
26
|
+
const cfg = effective(root.serial);
|
|
27
|
+
const { fixtures, ...rest } = cfg;
|
|
28
|
+
const ports = (root.serial?.ports ?? []).map((p) => {
|
|
29
|
+
const { fixtures: _none, ...settings } = effective(portSettings(root.serial, p.name));
|
|
30
|
+
return { name: p.name, ...settings };
|
|
31
|
+
});
|
|
32
|
+
return { ...rest, ports, recordings: fixtures.map((f) => ({ name: f.name, bytes: fixtureBytes(f).length })), sendLimits: LIMITS, paneWriteLimits: PANE_LIMITS, note: "Read-only. Serial settings are the person's device setup; whether panes may write is the person's, in this browser." };
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
}
|