jsworkflow

package
v0.0.1-alpha.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package jsworkflow is the goja-backed adapter that compiles a `.js` workflow into an orchestrate.Workflow (ADR-0009). It is the only package that knows JS exists; the engine, the Workflow/Phase port, and the report shape live in internal/orchestrate and are unchanged.

JS contract (defined by change 0014 — no MiMoCode reference existed to copy):

module.exports = {
  name: "deep-research",        // required: registration key
  maxRetries: 2,                // optional, defaults to 0
  phases: [                     // required, non-empty, ordered
    { name: "query", run: (state) => "output" },
    { name: "go",    run: (state) => { state.set("k","v"); return "..." } },
  ],
};

state shim: { last: string, get(key): string|undefined, set(key, value): void } over the engine's *orchestrate.State. A thrown value is a phase error and retries per maxRetries, like a Go phase. The sandbox binds only module, exports, state, and console.log — no require, fs, or net.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Compiled

type Compiled struct {
	// Name is module.exports.name — the registration key.
	Name string
	// Run is the workflow, runnable through the unchanged engine.
	Run orchestrate.Workflow
	// contains filtered or unexported fields
}

Compiled is a JS workflow ready to run, with its declared name (the key a caller registers it under) and the orchestrate.Workflow that runs it.

func Compile

func Compile(src string, opts ...Option) (Compiled, error)

Compile turns a CommonJS-shaped JS workflow source into a Compiled workflow. The source must export a non-empty name and a non-empty phases array; each phase needs a name and a function run. A malformed source returns an error describing the defect — never an empty workflow.

func LoadFile

func LoadFile(path string, opts ...Option) (Compiled, error)

LoadFile reads a `.js` workflow file and compiles it. Errors name the file so a bad path or a script defect points at its source.

type Option

type Option func(*Compiled)

Option tunes Compile.

func WithLogger

func WithLogger(fn func(string, ...any)) Option

WithLogger routes JS console.log to fn. Default is discard.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL