Commit graph

5 commits

Author SHA1 Message Date
a9b315a1a0 feat: declare consumes: llm.chat@^0 (advisory)
Some checks failed
CI / Linux x86_64 (Forgejo) (push) Failing after 2s
Plans this module emits typically dispatch llm.chat steps
for downstream LLM-driven work. A flow that runs an
unmodified plan needs an llm.chat provider installed; the
hub now surfaces this as a 'consumes-advisory' warning at
install time so operators see the dependency hint without
the install being blocked.

See fai/platform commit e5ba892 for the platform-side
consumes: schema.

Signed-off-by: flemming-it <sf@flemming.it>
2026-06-01 21:05:38 +02:00
8ce52c775e chore(module): schema_version 2 + explicit provider
Some checks failed
CI / Linux x86_64 (Forgejo) (push) Failing after 2s
Brings module.yaml in line with F∆I 0.12.0's capability naming
convention. The legacy schema_version 1 (with implicit provider)
still loads in 0.12.0 via the grace-period default, but this
bump makes the publisher identity explicit and unblocks
storage-layout migration via 'fai migrate'.

See fai/platform docs/reference/capability-namespaces.yaml +
docs/operations/migration-to-0.12.md.

Signed-off-by: flemming-it <sf@flemming.it>
2026-05-28 11:48:25 +02:00
86eb72154e feat: probe Ollama model digest, emit as model_digest output (v0.3.1)
Some checks failed
CI / Linux x86_64 (Forgejo) (push) Failing after 1m36s
Closes Compliance Gap 1 from fai/platform :: docs/advanced/
compliance-gaps.md. The module now probes the LLM endpoint's
/api/show on every successful chat invocation and surfaces
the model's SHA-256 digest as a separate output field.

The probe is strictly best-effort:

  - derive_show_url returns None unless the configured endpoint
    ends in /api/chat, so non-Ollama deployments (OpenAI,
    Anthropic) skip the probe entirely.
  - probe_model_digest swallows every failure path (network
    error, non-200 status, malformed JSON, missing digest field)
    and yields None. The plan generation succeeds either way.
  - extract_show_digest looks for digest at top level, then
    details.digest, then model_info.digest — the fields shift
    across Ollama versions, so the lookup is tolerant.

A new generate_plan_with_identity returns a PlanWithIdentity
struct ({plan_json, model_digest}). The original generate_plan
remains as a #[allow(dead_code)] convenience wrapper that
returns just the plan JSON.

The invoke entry point in lib.rs now emits four outputs:
  plan          (json)   — unchanged
  model_endpoint (text)  — unchanged
  model_name    (text)   — unchanged
  model_digest  (text)   — NEW; empty for non-Ollama or stub paths

module.yaml documents the new output and bumps the orchestrator
capability version to 0.3.0 (additive minor; downstream flows
that referenced @^0 keep working).

Eight new tests in src/llm.rs cover the new code paths:
  - URL transform (/api/chat → /api/show)
  - URL transform skipped for non-Ollama endpoints
  - Digest extraction at all three documented JSON locations
  - Digest extraction graceful failure (missing, empty, bad JSON)
  - End-to-end probe success
  - End-to-end probe skipped for non-Ollama
  - End-to-end probe failure swallowed without breaking plan

Total tests: 26 (was 18). Wasm artifact builds with v1.0
imports baked in. Platform-side integration tests in
fai/platform :: orchestrator_llm_path.rs pass against the
new module unchanged.

Bumps the module to 0.3.1 (patch — output schema additively
extended, behaviour unchanged for existing flows).

Signed-off-by: flemming-it <sf@flemming.it>
2026-05-03 23:06:27 +02:00
7d07937913 feat: real LLM call via wasi-http (Ollama adapter) — v0.2.0
The orchestrator now calls a configured Ollama-compatible LLM
endpoint over wasi-http and emits the LLM-generated plan back
to the hub. When llm_endpoint is empty, the v0.1.0 deterministic
stub is preserved as fallback (useful for tests and air-gapped
environments).

- module.yaml: bump to 0.2.0; new inputs llm_endpoint,
  llm_model, llm_api_key; net: permissions for OpenAI,
  Anthropic, localhost, 127.0.0.1 (Ollama defaults)
- src/llm.rs: LlmClient trait, OllamaParams, build_user_prompt,
  build_ollama_body, extract_ollama_content, generate_plan;
  9 unit tests for prompt-building and response-parsing
- src/plan.rs: tagged enum with Explain/SaveFlow/RunFlow/
  InstallModule variants; parse_and_validate; build_stub_plan
  (renamed from build_plan); validate(); 6 unit tests
- src/lib.rs: WakiClient implementing LlmClient over the waki
  WASI-0.2 HTTP crate (wasm32-only); empty endpoint → stub
- Cargo.toml: 0.2.0; thiserror dep; waki dep gated on wasm32

17 host-side tests pass. WASM bundle is 386KB (was 74KB; the
delta is wasi-http via waki, expected). The deny path is
exercised by the platform-side integration test in
fai_platform/crates/fai_hub/tests/orchestrator_llm_path.rs.

Signed-off-by: flemming-it <sf@flemming.it>
2026-04-29 21:27:07 +02:00
3bb8fc9e70 feat: deterministic stub orchestrator (v0.1.0)
The orchestrator-llm module turns a goal text into a Plan JSON
that the F∆I hub can apply. v0.1.0 is a deterministic stub —
it always emits a three-step plan (explain, explain-stub-notice,
save_flow with debug.echo) regardless of the goal.

Why ship a stub: it validates the module → plan → apply pipeline
end-to-end before adding LLM integration. The output is a
structurally valid Plan that round-trips cleanly through
fai_hub::plan::Plan deserialization.

v0.2.0 will replace the stub body with an actual LLM call once
the F∆I platform exposes outbound HTTP to permitted modules via
wasi-http.

Files:
- module.yaml — capability orchestrator.plan@0.1.0, no permissions
- wit/world.wit — copy of fai:platform@0.1.0
- src/lib.rs — wit_bindgen Guest impl that delegates to plan.rs
- src/plan.rs — pure plan-builder (host + WASM compatible)
- tests/plan_compatibility.rs — plan JSON shape assertions
- rust-toolchain.toml — pin to Rust 1.86 with wasm32-wasip2 target
- README.md — usage and status

Signed-off-by: flemming-it <sf@flemming.it>
2026-04-29 17:43:46 +02:00