Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ jobs:
- uses: astral-sh/setup-uv@v10.2.0
- run: uv sync --project python --locked
- run: bun --no-env-file run test:viewer:notes-browser
- run: bun --no-env-file run test:viewer:waiting-browser

# docs/guide and docs/wg are published on grida.co/docs (a docs source, see
# gridaco/docs); this runs that site's rules on them: links, assets, markdown.
Expand Down Expand Up @@ -242,6 +243,7 @@ jobs:
--command "$PWD/python/src/grida/fx/_bin/grida-fx"
- run: uv run --locked --project python python tools/check_observation.py --command "$PWD/python/src/grida/fx/_bin/grida-fx"
- run: uv run --locked --project python python tools/check_control.py --command "$PWD/python/src/grida/fx/_bin/grida-fx"
- run: uv run --locked --project python python tools/check_waiting.py --command "$PWD/python/src/grida/fx/_bin/grida-fx"

# `grida fx`, as the npm grida command carries it (spec/distribution.md): @grida/fx and this
# machine's engine package, packed from a fresh build, installed beside the host fixture, and
Expand Down
12 changes: 11 additions & 1 deletion AGENT_READINESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Existing tests are starting points for evidence, not proof of every scenario her
| Pause | A future, explicitly defined suspension boundary from which work can continue. There is no pause operation today; cancellation is not a pause acknowledgment. |
| Revise | Change authored inputs or workflow choices and plan again. Today this generally needs a new run folder; valid unchanged work can still be reused from the same cache. |
| Take / reroll / pick | A take identifies an alternative. Reroll selects a later take for the next execution; pick selects a take. Neither command executes it immediately. |
| Waiting step | A workflow requests a schema-defined answer for one concrete occurrence. An exact run and request ID select it from any supported review surface. |
| Observe / inspect | Read execution evidence or inspect a saved run. `--register` saves a viewer catalog entry and returns its route. `--open` launches the default browser. |
| Service | A project-scoped process started by `start`, providing the dashboard, catalog and observation HTTP endpoints. Workflow execution has a separate owner and lifetime. |
| Standalone | Independent inspection with its own available port and foreground owner. It does not mean a fresh cache or different execution semantics. |
Expand All @@ -96,6 +97,7 @@ narrower target rules.

| Intent / tool | What an agent receives | Conditions and effects |
|---|---|---|
| Supply external input: `inspect RUN --requests --json`, `respond RUN REQUEST --json JSON` | Schema, optional message, frozen choices, deadline and receipt | Listing reads request state independently of viewer discovery. A valid answer commits without launching a runner or authorizing spending. Explicit `--viewer-url` or `--register` supports handoff. |
| Discover: `--version`, `--help`, `<verb> --help` | Installed version and human-readable command help | No common machine-readable capability manifest yet. |
| Establish project: `init [directory] [--template NAME] --json`; `init --list-templates --json` | Resolved project, the files it wrote and the template it started from; the templates on offer | A new or empty directory gets the starter project (`fx.yaml`, `README.md`, `AGENTS.md`, `.gitignore`, `.env.example`, `workflows/icon.yaml`, and every FX skill under `.agents/skills/`), with no route set, or a named template: an example read from the release's source archive, with the starter's agent files added. Never asks a question under `--json`, without a terminal or in CI. An existing `fx.yaml` is validated and nothing is written. Any other non-empty directory is refused (exit 2): to add FX to an existing folder, write `fx.yaml` (`fx: project/v1`). Never overwrites; no dependencies, service, credentials or execution. |
| Install a starter: `add NAME [DESTINATION] --json`; `add OWNER/REPO@REF [DESTINATION] [--workflow NAME] [--github-auth] --json` | Local project root, exact workflow entry, bundled preset when declared, missing inputs and declared prerequisites | A listed template with `workflow_entry` or a GitHub repository at an explicit tag or full commit gets its own fresh project folder. For a private template, `--github-auth` uses the user's configured GitHub CLI authentication. The destination must be absent and its parent must already be a directory. A GitHub repository must have a root `fx.yaml`. It can choose a starter in an optional root `fx-template.json` or supply a YAML workflow under `workflows/` or `fx/`. An agent can select a unique file stem with `--workflow`. Use the returned entry with the returned root. Setup validates copied source and requires network access for the archive. Diagnose runtime readiness separately with `doctor`. |
Expand Down Expand Up @@ -428,7 +430,7 @@ promise through documentation alone.
| AR-07 | "Pause and wait for me." | Proposed; cancellation and later-phase thresholds only cover narrower intents. | Explicit request/acknowledgment/boundary semantics; active work and reservations accounted for; resume survives the documented lifetime. |
| AR-08 | "Change what has not started yet." | Partial: revise/replan/new run with cache reuse. Active mutation proposed. | Unchanged work is retained where identities match; an edit racing dispatch cannot silently change already accepted work; history and cost remain attributable. |
| AR-09 | "Keep this result; try another there." | Current takes, reroll and pick; their `next` line repeats the run from its record (conformance `run-repeat`). | Selected recorded instance is addressed exactly; no command implies immediate execution; next-plan impact and possible cost are visible. |
| AR-10 | "Ask before the next expensive part." | Current later-phase `--yes-up-to`, within a separate ceiling. | Incomplete run can continue with an approved threshold; no claim of a general human-approval/pause system. |
| AR-10 | "Ask before the next expensive part." | Current later-phase `--yes-up-to`, within a separate ceiling. | Incomplete run can continue with an approved threshold; workflow-authored human decisions are covered separately in AR-31. |
| AR-11 | "You disconnected; catch up." | Current in source: opaque cursors, bounded replay and snapshot reattachment; process liveness remains unknown. | Retained events can be read from a valid cursor; duplicates, unknown liveness and later invocations are handled without launching another run. |
| AR-12 | "Put the result in my project." | Current output delivery and file verification. | Exact output destinations and missing/partial results are reported; immutable stored files remain intact. |
| AR-13 | "Do it from Python or JavaScript." | Current: planning, named execution/resume, result files, saved RunRecord inspection, snapshot/batch/async following, exact-target control, portable evidence export and in-process stand-ins; node bodies, builders and stand-in files in Python or TypeScript, the TypeScript ones hosted by `@grida/fx` on Node 24+ with the Python host's whole protocol, and both in one project when needed. Built-in local types still need Python; Bun cannot host nodes. Only the TypeScript host checks param values against their schemas before a body runs and ends a body's programs when the node is cancelled or its run ends; the Python host does neither yet. | Each claimed job preserves engine semantics with native ergonomics. Recorded folders stay pinned; cursor attachment, bounded catch-up, errors, later resumes and observer cancellation have provider-free tests. A TypeScript project does every job a Python one does (describe, run, cache, build, judge, time out and cancel, run agents with tools, answer with a stand-in), with the guarantees [protocol.md](spec/protocol.md) §1 and §5 state, and its declarations refuse mistyped bodies at compile time; the evidence below names the tests. Execution readiness/browser lifetime and CLI maintenance are intentionally excluded. |
Expand All @@ -449,6 +451,14 @@ promise through documentation alone.
| AR-28 | "Start from this template and keep my edits for the next message." | CLI implemented in source for [#87](https://github.com/gridaco/fx/issues/87). [CLI listing and install](spec/service.md#21-templates) expose the authored workflow and preset for indexed examples and a starter from a pinned GitHub repository. Private sources can opt in to existing GitHub CLI authentication ([#151](https://github.com/gridaco/fx/issues/151)). Host reuse for delivery retries and follow-up messages is pending in [Grida #1160](https://github.com/gridaco/grida/issues/1160). | Discover an eligible template, install from a release-shaped or repository-shaped archive and plan the returned starter offline. Verify explicit workflow selection, ambiguous names, and refusal of an unpinned repository. Exercise opt-in authentication with a GitHub CLI stand-in, check failures leave the destination absent, and verify ordinary `add` never calls the stand-in. Repeats preserve edits and concurrent installs publish one complete folder. Report declared missing inputs and prerequisites without launching template code. |
| AR-29 | "Generate one image on this route and give me the PNG." | [One-shot call](spec/call.md) for [#149](https://github.com/gridaco/fx/issues/149) exposes image generation directly in the CLI. Python and JavaScript callers can build a one-step workflow, run it, and resolve or deliver its output. Native one-shot SDK entry points and a `--fresh` equivalent on that API are deferred. | Exercise project discovery from a child directory, explicit override, empty override refusal and projectless selection. Dry-run never generates. Prove request, output and cache behavior with a stand-in, including fresh execution and ordinary replay. Verify budget and live admission, reject output names that cannot be reported as UTF-8, and preserve the saved image on delivery failure or interruption. An opt-in signed-in Codex invocation is the live smoke test. |
| AR-30 | "Retrieve the result I already paid for." | Implemented in source for [#116](https://github.com/gridaco/fx/issues/116). A live resume collects a known completed task. CLI, Python and JavaScript expose recovery-only resume and recorded recovery events. | A charged success followed by download or answer validation failure retains the task. A repeat collects and publishes the original result with one generation and one charge. Concurrent invocations sharing a long-job call key serialize submission and collection. A settled handle from an older engine or an ambiguous project adapter outcome requires explicit recovery. Original bookings require task-specific evidence. Terminal generation failure and unavailable retention produce distinct next steps. Pruning preserves recovery candidates. |
| AR-31 | "Let my build supply its revision and let me choose a generated image." | [Durable workflow requests](spec/waiting.md) in CLI, Python, JavaScript and the live local viewer. | An SDK lists and answers a promptless revision. A reviewer chooses a frozen image through the viewer or CLI in the same run. Verify both values downstream, the winner on conflict and the exact selected file on resume. Timeout fallback follows normal spending rules. |

The [waiting fixture](fixtures/waiting/workflow.yaml) synthesizes three PNGs,
provides a deterministic fallback and writes the revision and delivered image
digest into a build manifest. The [public-interface check](tools/check_waiting.py)
checks those outputs, attached and detached execution, validation, retries and expiry.
The [browser test](tools/check_waiting_browser.mjs) submits through both review surfaces
in both winning orders, reloads the viewer, and resumes a review with the agent disconnected.

AR-25 uses the [notes fixture](fixtures/viewer/README.md#try-workflow-notes),
[engine acceptance](tools/check_notes.py), browser acceptance and builder/core/viewer tests.
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ with the tagged commit date for the lightweight `v0.4.0` tag.

## [Unreleased]

### Added

- Workflows can request external input with `fx/await@1` and `with.schema`. An SDK can supply a promptless value, or a person can review a question and select an exact file. The viewer renders scalar enums as pickers, marks pending requests on the run and project home, and counts down to an optional deadline. The CLI and SDKs can list and answer requests without a viewer. [#62](https://github.com/gridaco/fx/issues/62)
- Waiting steps stand out on the canvas and open their form from a **Review** button. Resolved steps show the outcome and open a receipt with the answer, submission time, and channel.

### Changed

- Made `llms.txt` a shorter starting point for agents, with an introduction to FX, runnable recipes, and links organized by task.
- The FX Viewer favicon pulses green during active execution and stays steady with reduced motion. [#158](https://github.com/gridaco/fx/issues/158)
- A run awaiting answers shows a steady amber favicon and its pending review count in the tab title.

### Fixed

Expand Down
57 changes: 57 additions & 0 deletions crates/grida-fx-core/src/builtins/catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,63 @@
"retry": "service",
"body": "none"
},
{
"uses": "fx/await@1",
"name": "await",
"major": 1,
"version": 1,
"description": "Request a schema-validated external input for this run and step.",
"inputs": {},
"params": {
"message": {
"type": "string",
"minLength": 1,
"x-fx-optional": true
},
"schema": {
"type": [
"object",
"boolean"
]
},
"choices": {
"type": "object",
"x-fx-optional": true
},
"choice_field": {
"type": "string",
"minLength": 1,
"x-fx-optional": true
},
"show": {
"x-fx-optional": true
},
"timeout_seconds": {
"type": "integer",
"minimum": 1,
"x-fx-optional": true
},
"on_timeout": {
"type": "string",
"enum": [
"fail",
"continue"
],
"default": "fail"
}
},
"outputs": {
"answer": "json?",
"selected": "value?"
},
"judge": false,
"capability": null,
"calls": {},
"resources": [],
"tools": [],
"retry": "service",
"body": "engine"
},
{
"uses": "fx/select@1",
"name": "select",
Expand Down
32 changes: 26 additions & 6 deletions crates/grida-fx-core/src/builtins/mod.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
//! The built-in node types (`fx/<name>@<major>`), embedded as data: `catalog.json`, the 37
//! The built-in node types (`fx/<name>@<major>`), embedded as data: `catalog.json`, the 38
//! standard types.
//!
//! `catalog.json` is `{"kind": "fx-std-catalog-v1", "types": [...]}`; each type has `uses`,
//! `name`, `major`, `version`, `description` (optional), `inputs`, `params`, `outputs`, `judge`,
//! `capability`, `calls`, `resources`, `tools`, `retry`, and `body` (`capability`, `python`,
//! `engine` or `none`), in declaration order. A built-in's identity is
//! `fx/<name>@<major>.<version>` (identity.md §6). The engine owns the capability types and
//! `fx/select@1` (protocol.md §4 "Engine types"); the Python host runs the `python` bodies.
//! the native `select` and `await` types (protocol.md §4 "Engine types"); the Python host runs the `python` bodies.
//!
//! The catalog is read once, with FX's JSON reader (one number type), and every spec is
//! validated through [`crate::spec::NodeSpec::from_type_spec`] with its capability. `nodes`
//! kinds are 11 paid, 5 judge, 21 free.
//! validated with its capability and its engine-native output notation when applicable. `nodes`
//! kinds are 11 paid, 5 judge, 22 free.

pub mod waiting;

use crate::spec::{BodyKind, NodeSpec};
use grida_fx_protocol::TypeSpec;
Expand Down Expand Up @@ -133,7 +135,7 @@ fn parse_catalog(text: &str) -> Result<Vec<BuiltinType>, String> {
version: Some(entry.version),
retry: entry.retry,
};
let spec = NodeSpec::from_type_spec(&wire, entry.capability)
let spec = NodeSpec::read_type_spec(&wire, entry.capability, body == BodyKind::Engine)
.map_err(|reason| format!("{uses}: {reason}"))?;
types.push(BuiltinType {
uses,
Expand All @@ -152,7 +154,16 @@ mod tests {

#[test]
fn the_catalog_parses() {
assert_eq!(builtins().len(), 37);
assert_eq!(builtins().len(), 38);
for builtin in builtins() {
let wire = builtin.spec.to_type_spec();
let restored = NodeSpec::read_type_spec(
&wire,
builtin.spec.capability.clone(),
builtin.body == BodyKind::Engine,
);
assert_eq!(restored.as_ref(), Ok(&builtin.spec), "{}", builtin.uses);
}
let generate = builtin("image.generate", 1).unwrap();
assert_eq!(generate.uses, "fx/image.generate@1");
assert_eq!(generate.identity(), "fx/image.generate@1.1");
Expand All @@ -161,6 +172,15 @@ mod tests {
assert!(builtin("image.generate", 2).is_none());
assert!(builtin("nope", 1).is_none());
assert_eq!(builtin("select", 1).unwrap().body, BodyKind::Engine);
let review = &builtin("await", 1).unwrap().spec;
assert_eq!(review.outputs["selected"].notation(), "value?");
assert_eq!(review.to_type_spec().outputs["selected"], "value?");
for notation in ["value", "value?"] {
let mut host_spec = review.to_type_spec();
host_spec.outputs.insert("selected".into(), notation.into());
let error = NodeSpec::from_type_spec(&host_spec, None).unwrap_err();
assert!(error.contains("port kind 'value'"), "{error}");
}
assert_eq!(builtin("image.resize", 1).unwrap().body, BodyKind::Python);
assert_eq!(builtin("image.key", 1).unwrap().body, BodyKind::None);
}
Expand Down
Loading
Loading