Skip to content

feat: agent page actions (0.2.0) - #4

Merged
mrgoonie merged 1 commit into
mainfrom
feat/page-actions
Oct 20, 2026
Merged

mrgoonie merged 1 commit into
mainfrom
feat/page-actions

Conversation

@mrgoonie

Copy link
Copy Markdown
Contributor

Summary

Host pages can register typed page actions that the Dewee agent calls from chat. The gateway is unchanged: actions travel as text.

  • Widget: chat.registerActions(actions), chat.unregisterAction(name), options actions, confirm, getPageContext, maxActionRounds (5), actionTimeoutMs (30s); React/Vue actions prop and onAction/@action.
  • Calls: the agent ends its answer with fenced ```dewee-action {"id","name","args"} blocks. The widget hides them, validates args against the action's JSON Schema subset, asks for approval on mutate/destructive (built-in accessible dialog or host confirm hook; only a resolved true approves), runs the handler, shows status chips and sends a hidden ```dewee-action-result follow-up. Automatic turns are bounded per visitor message.
  • Backends (Node + PHP): validate actions (≤32, 16 KB) and pageContext (≤4 KB), prepend a [[dewee-page v1]] block to the gateway message, return actionsHash in start, and skip the full manifest once the widget acknowledges the hash. History hides the block. New errors: 400 invalid_actions, 413 actions_too_large, 413 context_too_large.
  • dewee:action event (start/result) for telemetry.
  • Without actions, the request body, the gateway message and the rendering stay the same as 0.1.x.
  • Docs (docs/http-contract.md#page-actions), README "Agent page actions" with security notes, React example (navigate + confirmed mutate).
  • Version 0.2.0 (npm package + PHP VERSION).

Tests

  • test/page-actions.test.ts: directive parsing (malformed, oversized, unclosed, duplicate, too many), result formatting/truncation, schema validation, the confirmation gate (handler never runs without true), cancel/timeout, registry limits, manifest hashing and page block.
  • test/server.test.ts: message assembly, hash ack, error codes, backward compatibility, history stripping.
  • test/widget-page-actions.test.ts (happy-dom): auto-turn bound, host denial, page context, old wire format without actions.
  • test/php-parity.test.ts: PHP and TS build identical blocks, hashes and errors (runs in CI's php job).

- widget: registerActions/unregisterAction, actions/confirm/getPageContext options and React/Vue props
- agent calls actions with fenced dewee-action blocks; the widget validates args (JSON Schema subset),
  gates mutate/destructive calls behind an accessible confirm dialog or a host hook, shows status
  chips, and sends dewee-action-result follow-ups, bounded by maxActionRounds
- backends (Node and PHP) validate the manifest, prepend a delimited page block to the gateway
  message, and only resend the manifest when its hash changes; history hides the block
- dewee:action event, docs, README section with security notes, React example
- bump to 0.2.0
@mrgoonie
mrgoonie merged commit ff39895 into main Oct 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant