Yizuki_Ame e71b00c5c9
fix(agent): preserve generate_scene failure causes (#1316)
* fix(agent): preserve generate_scene failure causes

* test(agent): harden scene failure coverage

* test(agent): isolate warning log format

* test(agent): isolate warning log level

---------

Co-authored-by: wyuc <wang-yc24@mails.tsinghua.edu.cn>
2026-09-03 02:15:53 -04:00
..

@openmaic/generation

Pure generation pipeline contracts and packaged prompt assets for MAIC consumers.

AICallFn is the package's model seam: callers provide a function that accepts system and user prompts and returns model output. The package does not select a provider, read environment configuration, or own persistence.

Prompt templates and their referenced snippets ship as readable Markdown assets under templates/ and snippets/. The loader resolves them relative to the installed package, so it works from both source tests and compiled output.

Scene generation is available as independent content, action, and assembly primitives. A caller can generate one outline, pass it to generateSceneContent and generateSceneActions, then assemble the DSL value with buildCompleteScene. Retrying consumers can supply sceneId to preserve scene identity across replays.

generateSceneContent returns null when a non-PBL content prompt cannot be prepared or the model output cannot be parsed. Callers that need a stable cause may supply onFailure; it receives { code: 'prompt-unavailable' } or { code: 'invalid-model-output' } immediately before that null result. generateWidgetContent accepts the same callback in its options.

PBL scenes use the same AICallFn seam for single-call planning. Hosts that need an agentic fallback may inject pblLoopFallback; provider selection and fallback execution remain caller-owned. The two planner templates ship under prompts-pbl/ and resolve relative to the installed package.