Skip to content

Repository files navigation

SCSessionBridge

SuperCollider Quarks cover

Release Validate License Quark

SCSessionBridge is a portable sclang-only Quark for controlling a live SuperCollider language session over OSC.

It is built for trusted local and LAN workflows.

Quick Start

SCSessionBridge.start((
    port: 31731,
    replyHost: "127.0.0.1",
    replyPort: 31732,
    token: "optional-token",
    localOnly: true,
    maxCodeBytes: 60000
));
SCSessionBridge.status;
SCSessionBridge.eval("1 + 1", ());
SCSessionBridge.stop;

Install

Quarks.install("https://github.com/ramonsesma/SCSessionBridge");

For local development, clone into ~/AppData/Local/SuperCollider/downloaded-quarks/SCSessionBridge (Windows) or ~/.local/share/SuperCollider/downloaded-quarks/SCSessionBridge (Linux/macOS) and add the path to sclang_conf.yaml.

OSC Commands

Incoming commands:

  • /scsession/ping token
  • /scsession/status token
  • /scsession/eval evalId token code
  • /scsession/stop token [requestId]

In SCSessionBridge 0.1.0, ping and status keep a token slot in the packet shape for wire compatibility, but they do not enforce it. eval and stop do enforce policy. /scsession/stop accepts an optional request id so authorization failures can be correlated in replies. /scsession/eval preserves the remote request evalId, while SCSessionBridge.eval runs the same validation path locally in-process and generates its own local evalId.

Outgoing commands:

  • /scsession/ready port
  • /scsession/pong timestamp
  • /scsession/status running port replyHost replyPort
  • /scsession/start evalId
  • /scsession/error evalId message
  • /scsession/finish evalId ok

Policy Defaults

SCBridgePolicy.normalize keeps the policy surface canonical: it retains only the public keys below and ignores unknown config keys.

  • port: 31731
  • replyHost: "127.0.0.1"
  • replyPort: 31732
  • token: nil
  • localOnly: true
  • allowedHosts: nil
  • allowEval: true
  • maxCodeBytes: 60000
  • denyPatterns: Array.new

Allow and deny helpers use a narrow rule shape:

  • SCSessionBridge.allow((host: "127.0.0.1"))
  • SCSessionBridge.allow((eval: true))
  • SCSessionBridge.deny((pattern: "File.delete"))
  • SCSessionBridge.deny((eval: true))

Example:

SCSessionBridge.start((
    denyPatterns: ["File.delete", "unixCmd"]
));

Security

Scope: trusted local and LAN only. Boundary: SCSessionBridge is not a sandbox; do not expose it directly to the public internet.

Test

Run from the repository root:

& 'C:\Program Files\SuperCollider-3.14.1\sclang.exe' -D -r -s --include-path 'Classes' --include-path 'tests' 'tests\RunSCSessionBridge.scd'

Or inside sclang after loading the Quark classes:

TestSCSessionBridge.run;

License: MIT.

About

Portable sclang-only Quark for controlling a live SuperCollider language session over OSC. It is built for trusted local and LAN workflows.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages