Summary
Add app.onEvent() / app.onSchedule() sugar helpers on the TypeScript SDK Agent, plus test helpers and a captured-fixture library so reasoners can be unit-tested without spinning up a control plane.
Part of the epic #507.
Scope
Modified Files
| File |
Change |
sdk/typescript/src/Agent.ts |
app.onEvent(opts, handler) and app.onSchedule(expression, handler) — pure forwards to app.reasoner({ triggers: [...] }, handler) so the registration goes through the same code path |
New Files
| File |
Purpose |
sdk/typescript/src/triggers/testing.ts |
simulateTrigger(handler, fixture) and simulateSchedule(handler, options) — synchronous helpers that build a TriggerContext from a fixture and invoke the handler in the same shape the dispatch path uses |
sdk/typescript/src/triggers/fixtures/*.json |
Captured payload library — copied from sdk/python/agentfield/fixtures/triggers/ so the two SDKs prove behavioural parity against the same JSON files |
Interface
import { simulateTrigger } from "@agentfield/sdk/triggers/testing";
import paymentSucceeded from "@agentfield/sdk/triggers/fixtures/stripe.payment_intent.succeeded.json";
it("records a stripe payment", async () => {
const result = await simulateTrigger(handlePayment, paymentSucceeded);
expect(result.kind).toBe("payment");
});
Acceptance
References
Summary
Add
app.onEvent()/app.onSchedule()sugar helpers on the TypeScript SDK Agent, plus test helpers and a captured-fixture library so reasoners can be unit-tested without spinning up a control plane.Part of the epic #507.
Scope
Modified Files
sdk/typescript/src/Agent.tsapp.onEvent(opts, handler)andapp.onSchedule(expression, handler)— pure forwards toapp.reasoner({ triggers: [...] }, handler)so the registration goes through the same code pathNew Files
sdk/typescript/src/triggers/testing.tssimulateTrigger(handler, fixture)andsimulateSchedule(handler, options)— synchronous helpers that build aTriggerContextfrom a fixture and invoke the handler in the same shape the dispatch path usessdk/typescript/src/triggers/fixtures/*.jsonsdk/python/agentfield/fixtures/triggers/so the two SDKs prove behavioural parity against the same JSON filesInterface
Acceptance
app.onEvent()andapp.onSchedule()produce reasoners equivalent to the long-formapp.reasoner({ triggers: [...] }, ...)— same registration payload sent to the CPsimulateTriggerruns the handler against each of the six fixture files (Stripe, GitHub, Slack, generic_hmac, generic_bearer, cron) and returns the same shape the live dispatch path wouldsdk/typescript/src/triggers/__tests__/cover all six fixturesReferences
sdk/python/agentfield/testing.pyand the fixtures undersdk/python/agentfield/fixtures/triggers/