Skip to content

[TypeScript SDK] onEvent / onSchedule sugar + test helpers + fixtures #511

@santoshkumarradha

Description

@santoshkumarradha

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

  • app.onEvent() and app.onSchedule() produce reasoners equivalent to the long-form app.reasoner({ triggers: [...] }, ...) — same registration payload sent to the CP
  • simulateTrigger runs 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 would
  • Tests under sdk/typescript/src/triggers/__tests__/ cover all six fixtures

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-friendlyWell-documented task suitable for AI-assisted developmentarea:sdkCross-SDK (Python + Go + TS) parity workenhancementNew feature or requesthelp wantedExtra attention is neededsdk:typescriptTypeScript SDK related

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions