@fabric-harness/sdk 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/agent-definition.d.ts +8 -0
  2. package/dist/agent-definition.d.ts.map +1 -1
  3. package/dist/agent-definition.js.map +1 -1
  4. package/dist/agent.d.ts.map +1 -1
  5. package/dist/agent.js +3 -0
  6. package/dist/agent.js.map +1 -1
  7. package/dist/cost-budget.d.ts +59 -0
  8. package/dist/cost-budget.d.ts.map +1 -0
  9. package/dist/cost-budget.js +51 -0
  10. package/dist/cost-budget.js.map +1 -0
  11. package/dist/error.d.ts +1 -1
  12. package/dist/error.d.ts.map +1 -1
  13. package/dist/error.js.map +1 -1
  14. package/dist/events.d.ts +15 -0
  15. package/dist/events.d.ts.map +1 -1
  16. package/dist/events.js.map +1 -1
  17. package/dist/index.d.ts +4 -0
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +2 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/loop.d.ts +9 -0
  22. package/dist/loop.d.ts.map +1 -1
  23. package/dist/loop.js +21 -0
  24. package/dist/loop.js.map +1 -1
  25. package/dist/policy.d.ts +25 -0
  26. package/dist/policy.d.ts.map +1 -1
  27. package/dist/policy.js +18 -0
  28. package/dist/policy.js.map +1 -1
  29. package/dist/session.d.ts +2 -0
  30. package/dist/session.d.ts.map +1 -1
  31. package/dist/session.js +21 -0
  32. package/dist/session.js.map +1 -1
  33. package/dist/strict.d.ts +4 -0
  34. package/dist/strict.d.ts.map +1 -1
  35. package/dist/strict.js +2 -0
  36. package/dist/strict.js.map +1 -1
  37. package/dist/types.d.ts +19 -2
  38. package/dist/types.d.ts.map +1 -1
  39. package/dist/types.js.map +1 -1
  40. package/dist/webhook-subscription.d.ts +54 -0
  41. package/dist/webhook-subscription.d.ts.map +1 -0
  42. package/dist/webhook-subscription.js +30 -0
  43. package/dist/webhook-subscription.js.map +1 -0
  44. package/package.json +1 -1
@@ -0,0 +1,54 @@
1
+ import type { JsonObject } from './types.js';
2
+ /**
3
+ * Generic webhook subscription primitive — wakes an agent on inbound events
4
+ * from any external system (event bus, queue, scheduler, third-party SaaS
5
+ * webhook, your own application's domain events). fabric-harness consumes a
6
+ * JSON payload and dispatches to the user-provided handler. The host event
7
+ * system decides which payloads land here; fabric-harness has no opinion on
8
+ * event taxonomy or producer.
9
+ */
10
+ export interface WebhookSubscriptionContext<TPayload> {
11
+ /** Validated payload (or raw, if no schema was supplied). */
12
+ payload: TPayload;
13
+ /** Inbound HTTP headers (lowercased keys). */
14
+ headers: Record<string, string>;
15
+ /** Aborts when the request is cancelled (client disconnect, timeout). */
16
+ signal: AbortSignal;
17
+ /** Echoed event-pattern hint when supplied by the producer. */
18
+ eventType?: string;
19
+ /** Optional idempotency key from the inbound request. */
20
+ idempotencyKey?: string;
21
+ }
22
+ export interface WebhookSubscriptionDefinition<TPayload> {
23
+ id: string;
24
+ events?: string[];
25
+ schema?: unknown;
26
+ description?: string;
27
+ handler: (ctx: WebhookSubscriptionContext<TPayload>) => Promise<unknown>;
28
+ }
29
+ /**
30
+ * Helper that returns the definition unchanged. Useful for type inference and
31
+ * to keep agent files declarative.
32
+ *
33
+ * ```ts
34
+ * import { agent, defineWebhookSubscription } from '@fabric-harness/sdk';
35
+ *
36
+ * export default agent({
37
+ * name: 'data-validator',
38
+ * triggers: { webhook: true },
39
+ * subscriptions: [
40
+ * defineWebhookSubscription<{ recordId: string }>({
41
+ * id: 'on-record-created',
42
+ * events: ['record.created'],
43
+ * schema: { type: 'object', properties: { recordId: { type: 'string' } }, required: ['recordId'] },
44
+ * handler: async ({ payload }) => {
45
+ * // ...invoke whatever your host application exposes.
46
+ * },
47
+ * }),
48
+ * ],
49
+ * async run() { ... },
50
+ * });
51
+ * ```
52
+ */
53
+ export declare function defineWebhookSubscription<TPayload = JsonObject>(definition: WebhookSubscriptionDefinition<TPayload>): WebhookSubscriptionDefinition<TPayload>;
54
+ //# sourceMappingURL=webhook-subscription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook-subscription.d.ts","sourceRoot":"","sources":["../src/webhook-subscription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;GAOG;AAEH,MAAM,WAAW,0BAA0B,CAAC,QAAQ;IAClD,6DAA6D;IAC7D,OAAO,EAAE,QAAQ,CAAC;IAClB,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,yEAAyE;IACzE,MAAM,EAAE,WAAW,CAAC;IACpB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,6BAA6B,CAAC,QAAQ;IACrD,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,CAAC,GAAG,EAAE,0BAA0B,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1E;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,GAAG,UAAU,EAC7D,UAAU,EAAE,6BAA6B,CAAC,QAAQ,CAAC,GAClD,6BAA6B,CAAC,QAAQ,CAAC,CAGzC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Helper that returns the definition unchanged. Useful for type inference and
3
+ * to keep agent files declarative.
4
+ *
5
+ * ```ts
6
+ * import { agent, defineWebhookSubscription } from '@fabric-harness/sdk';
7
+ *
8
+ * export default agent({
9
+ * name: 'data-validator',
10
+ * triggers: { webhook: true },
11
+ * subscriptions: [
12
+ * defineWebhookSubscription<{ recordId: string }>({
13
+ * id: 'on-record-created',
14
+ * events: ['record.created'],
15
+ * schema: { type: 'object', properties: { recordId: { type: 'string' } }, required: ['recordId'] },
16
+ * handler: async ({ payload }) => {
17
+ * // ...invoke whatever your host application exposes.
18
+ * },
19
+ * }),
20
+ * ],
21
+ * async run() { ... },
22
+ * });
23
+ * ```
24
+ */
25
+ export function defineWebhookSubscription(definition) {
26
+ if (!definition.id)
27
+ throw new Error('defineWebhookSubscription: id is required.');
28
+ return definition;
29
+ }
30
+ //# sourceMappingURL=webhook-subscription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook-subscription.js","sourceRoot":"","sources":["../src/webhook-subscription.ts"],"names":[],"mappings":"AAgCA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,yBAAyB,CACvC,UAAmD;IAEnD,IAAI,CAAC,UAAU,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAClF,OAAO,UAAU,CAAC;AACpB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabric-harness/sdk",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Headless TypeScript framework for building durable, deployable autonomous agents — core SDK.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Fabric",