@realtimex/sdk 1.3.4 → 1.3.5-rc.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.
- package/README.md +61 -0
- package/dist/index.d.mts +646 -7
- package/dist/index.d.ts +646 -7
- package/dist/index.js +1899 -31
- package/dist/index.mjs +1859 -30
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -108,6 +108,67 @@ await sdk.webhook.triggerAgent({
|
|
|
108
108
|
});
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
+
### Contract Discovery
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
// Read canonical contract metadata published by Main App
|
|
115
|
+
const contract = await sdk.contract.getLocalAppV1();
|
|
116
|
+
|
|
117
|
+
console.log(contract.version); // local-app-contract/v1
|
|
118
|
+
console.log(contract.supported_events); // task.trigger, task.claimed, ...
|
|
119
|
+
console.log(contract.callback?.signature_header); // x-rtx-contract-signature
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Worker Callback Lifecycle
|
|
123
|
+
|
|
124
|
+
Use this when your worker receives `task_uuid`, `attempt_id`, and callback metadata from RealtimeX task context.
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
sdk.task.configureContract({
|
|
128
|
+
callbackSecret: process.env.RTX_CONTRACT_CALLBACK_SECRET,
|
|
129
|
+
signCallbacksByDefault: true,
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
await sdk.task.claim(taskUuid, {
|
|
133
|
+
callbackUrl,
|
|
134
|
+
machineId,
|
|
135
|
+
attemptId,
|
|
136
|
+
userEmail,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
await sdk.task.start(taskUuid, {
|
|
140
|
+
callbackUrl,
|
|
141
|
+
machineId,
|
|
142
|
+
attemptId,
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
await sdk.task.progress(taskUuid, { percent: 50, message: 'Halfway done' }, {
|
|
146
|
+
callbackUrl,
|
|
147
|
+
machineId,
|
|
148
|
+
attemptId,
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
await sdk.task.complete(taskUuid, { summary: 'Done' }, {
|
|
152
|
+
callbackUrl,
|
|
153
|
+
machineId,
|
|
154
|
+
attemptId,
|
|
155
|
+
});
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
`TaskModule` auto-populates:
|
|
159
|
+
- `event_id` for idempotency
|
|
160
|
+
- canonical `event` names
|
|
161
|
+
- optional HMAC signature header (`x-rtx-contract-signature`) when signing is enabled
|
|
162
|
+
- legacy `action` alongside canonical `event` for compatibility when posting to callback URLs
|
|
163
|
+
|
|
164
|
+
### Contract Compatibility Check
|
|
165
|
+
|
|
166
|
+
Run the cross-language harness (Main App endpoint + TypeScript SDK + Python SDK):
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
RTX_API_KEY=sk-... RTX_CONTRACT_VERIFY_BASE_URL=http://127.0.0.1:3001 npm run contract:verify
|
|
170
|
+
```
|
|
171
|
+
|
|
111
172
|
### Public APIs
|
|
112
173
|
|
|
113
174
|
```typescript
|