@fabric-harness/sdk 2.1.1 → 2.1.2

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.
@@ -0,0 +1,61 @@
1
+ <!-- Canonical Fabric Harness channel connector contract. Shipped with @fabric-harness/sdk. -->
2
+
3
+ # Fabric Harness Channel Connector Spec
4
+
5
+ A channel turns an authenticated provider event into a durable dispatch to a persistent agent. Produce a TypeScript module under `.fabricharness/channels/<provider>.ts` that exports a `Channel` created with `defineChannel()`.
6
+
7
+ ## Required shape
8
+
9
+ ```ts
10
+ import { conversationKey, defineChannel, parseConversationKey } from '@fabric-harness/sdk';
11
+
12
+ export const channel = defineChannel({
13
+ name: '<provider>',
14
+ routes: [{
15
+ method: 'POST',
16
+ path: '/events',
17
+ async handler(request, context) {
18
+ // 1. Read the exact body bytes once.
19
+ // 2. Verify the provider signature and timestamp before parsing/dispatching.
20
+ // 3. Normalize the event and ignore provider-owned bot messages.
21
+ // 4. Dispatch with stable instance, dedupe, tenant, and actor identity.
22
+ const receipt = await context.dispatch('<agent>', {
23
+ instanceId: conversationKey('<provider>', 'v1', '<conversation-id>'),
24
+ message: { kind: 'signal', signal: '<provider>.event', data: {} },
25
+ dedupeKey: '<provider-event-id>',
26
+ tenantId: '<workspace-or-account-id>',
27
+ actor: { id: '<provider-user-id>', type: 'user' },
28
+ });
29
+ return Response.json(receipt, { status: 202 });
30
+ },
31
+ }],
32
+ conversationKey(ref) {
33
+ const value = ref as { id: string };
34
+ return conversationKey('<provider>', 'v1', value.id);
35
+ },
36
+ parseConversationKey(id) {
37
+ return { id: parseConversationKey(id).segments[0] };
38
+ },
39
+ });
40
+ ```
41
+
42
+ ## Security requirements
43
+
44
+ 1. Fail closed when the signing secret, public key, OAuth configuration, or expected bearer token is absent.
45
+ 2. Verify the exact request bytes. Use `readJsonBody()` when an HMAC provider requires both raw bytes and parsed JSON.
46
+ 3. Enforce the provider timestamp window or challenge protocol to prevent replay attacks.
47
+ 4. Use constant-time signature verification. Prefer Fabric's `verifyHmacSha256()` when the provider uses HMAC-SHA256.
48
+ 5. Use the provider event/delivery ID as `dedupeKey`. Do not invent a random value.
49
+ 6. Derive `instanceId` from the stable thread, conversation, ticket, order, or resource identifier.
50
+ 7. Propagate organization/account identity as `tenantId` and the initiating user as `actor`.
51
+ 8. Ignore messages/actions created by the integration itself to prevent response loops.
52
+ 9. Keep credentials in environment variables or a secret manager. Never put secrets in dispatch input, model context, errors, logs, or session artifacts.
53
+ 10. Apply a `CapabilityPolicy` to outbound write tools. Require approval for destructive, financial, public-posting, or customer-data mutations.
54
+
55
+ ## Outbound tools
56
+
57
+ Expose provider writes through `defineTool()` with `effect: 'write'`. Bind tools to the addressed conversation/resource at persistent-agent initialization, and restrict OAuth scopes to the exact actions required. Include idempotency keys when the provider supports them.
58
+
59
+ ## Tests
60
+
61
+ Add unit tests for valid and invalid signatures, stale timestamps, duplicate event IDs, bot-loop suppression, tenant/actor propagation, stable conversation keys, body-size limits, and outbound policy classification. Add an opt-in live test for provider webhook and permission changes.
@@ -0,0 +1,14 @@
1
+ # Fabric Harness Tooling Connector Spec
2
+
3
+ A tooling connector observes Fabric events, traces, metrics, or eval results without changing agent behavior. Produce a project-local module that uses public Fabric event, telemetry, or eval APIs.
4
+
5
+ ## Requirements
6
+
7
+ 1. Initialize the vendor SDK before Fabric runtime construction and dispose/flush it during graceful shutdown.
8
+ 2. Integrate from `onEvent`, `TelemetryExporter`, `createOpenTelemetryObserver()`, `runEvalSuite()`, or another documented public boundary. Do not monkey-patch model providers or session internals.
9
+ 3. Keep API keys in environment variables or a secret manager. Never add them to event attributes, errors, model context, or artifacts.
10
+ 4. Disable prompt, output, reasoning, tool argument/result, attachment, and customer-content capture by default. Require an explicit redaction/retention policy to enable any of it.
11
+ 5. Use stable low-cardinality job, agent, model, environment, and outcome attributes. Do not use session, submission, tenant, or user IDs as metric dimensions.
12
+ 6. Bound queues, retries, payload size, and shutdown time so telemetry failure cannot block agent execution indefinitely.
13
+ 7. Keep evaluation datasets and grading outputs separate from production session storage and apply access/retention controls.
14
+ 8. Add tests for redaction, exporter failure, flush behavior, disabled-content defaults, and correlation fields.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabric-harness/sdk",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "Headless TypeScript framework for building durable, deployable autonomous agents — core SDK.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Fabric",