DummyConnector currently has hard-coded demo paths (/genui-weather, /genui-form, etc.). Make those declarative so the sandbox — and any third party using DummyConnector for demos / e2e tests — can configure response behavior without forking the connector.
Motivation
- Backend-less demos. "When the user says 'cancel', show this card with two buttons."
- E2E test fixtures. Replay deterministic conversations without spinning up a real bot.
- Customer presentations. Show a tailored flow before the real backend exists.
- Pairs naturally with the sandbox's
ChativaSettings JSON paste-load: rule sets travel as part of the same config blob.
Proposed shape (v1)
type DummyRule = {
/** Predicate over the user's outgoing message. */
when: {
type?: string; // match by message type
textMatches?: string; // regex string applied to data.text
};
/** Static response, OR a GenUI chunk script. */
then:
| IncomingMessage
| { kind: "genui"; chunks: AIChunk[] };
/** Optional delay before emitting `then`. Defaults to `replyDelay`. */
delay?: number;
};
new DummyConnector({
replyDelay: 500,
rules: [
{
when: { textMatches: "^/(help|yardım)$" },
then: { id: "x", type: "buttons", from: "bot", data: { buttons: [{ label: "Order status" }, { label: "Talk to a human" }] } },
},
{
when: { textMatches: "(cancel|iptal)" },
then: { kind: "genui", chunks: [/* text + form */] },
},
],
});
Rules evaluated in order; first match wins. No match → fall through to the default echo.
Hard rules
- No custom JS execution. Pattern matching only —
textMatches is a regex string, not arbitrary code.
- All rule output passes through the existing
IncomingMessage / AIChunk types (no new schemas needed besides updating connector option schema).
Sandbox integration
A new "Rules" tab in apps/sandbox/src/sandbox/sections/:
- Add / edit / remove rules in a list.
- "Apply" rebuilds the DummyConnector instance via the existing Connector tab swap path.
- Rules serialise into the Config tab's JSON output as a
dummy.rules field of chativaSettings.connector.
Schema impact
Update schemas/connectors/dummy.schema.json to include the rules field. Add a drift test for it (also covered by #4 / schema-coverage).
Acceptance criteria
Spun out of todos.md.
DummyConnector currently has hard-coded demo paths (
/genui-weather,/genui-form, etc.). Make those declarative so the sandbox — and any third party using DummyConnector for demos / e2e tests — can configure response behavior without forking the connector.Motivation
ChativaSettingsJSON paste-load: rule sets travel as part of the same config blob.Proposed shape (v1)
Rules evaluated in order; first match wins. No match → fall through to the default echo.
Hard rules
textMatchesis a regex string, not arbitrary code.IncomingMessage/AIChunktypes (no new schemas needed besides updating connector option schema).Sandbox integration
A new "Rules" tab in
apps/sandbox/src/sandbox/sections/:dummy.rulesfield ofchativaSettings.connector.Schema impact
Update
schemas/connectors/dummy.schema.jsonto include therulesfield. Add a drift test for it (also covered by #4 / schema-coverage).Acceptance criteria
rulesin its constructor options.textMatchesregex match outgoing messages and emit the configuredthen.genUIChunkHandler.triggerGenUI,injectMessage) keep working.connector-dummytests for rule matching, ordering, and fall-through.schemas/connectors/dummy.schema.jsonupdated and drift-tested.Spun out of
todos.md.