@alvera-ai/platform-sdk 0.10.0-rc.8 → 0.11.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.
- package/.agent/AGENTS.md +499 -0
- package/.agent/account_management.md +456 -0
- package/.agent/action_status_updaters.md +264 -0
- package/.agent/ai_agents.md +462 -0
- package/.agent/ai_sandbox.md +265 -0
- package/.agent/async.md +112 -0
- package/.agent/connected_apps.md +408 -0
- package/.agent/cookbook/_fixtures/README.md +106 -0
- package/.agent/cookbook/_fixtures/accounts_receivable/_customers_accounts_receivable_customer.liquid +32 -0
- package/.agent/cookbook/_fixtures/accounts_receivable/_customers_accounts_receivable_mdm.liquid +20 -0
- package/.agent/cookbook/_fixtures/accounts_receivable/stripe_customers_batch1.csv +5 -0
- package/.agent/cookbook/_fixtures/foundation/_lead_submissions_foundation_generic_table.liquid +33 -0
- package/.agent/cookbook/_fixtures/foundation/_lead_submissions_foundation_legal_entity.liquid +88 -0
- package/.agent/cookbook/_fixtures/foundation/_lead_submissions_foundation_mdm.liquid +48 -0
- package/.agent/cookbook/_fixtures/healthcare/_cahps_appointments_healthcare_appointment.liquid +47 -0
- package/.agent/cookbook/_fixtures/healthcare/_cahps_appointments_healthcare_mdm.liquid +24 -0
- package/.agent/cookbook/_fixtures/healthcare/_cahps_appointments_healthcare_patient.liquid +38 -0
- package/.agent/cookbook/_fixtures/healthcare/memorandum-of-association-01.png +0 -0
- package/.agent/cookbook/_fixtures/healthcare/sample_two_page.pdf +43 -0
- package/.agent/cookbook/_fixtures/payment_risk/_compliance_screenings_payment_risk_compliance_screening.liquid +59 -0
- package/.agent/cookbook/_fixtures/payment_risk/_compliance_screenings_payment_risk_mdm.liquid +36 -0
- package/.agent/cookbook/_fixtures/payment_risk/_payment_accounts_payment_risk_mdm.liquid +30 -0
- package/.agent/cookbook/_fixtures/payment_risk/_payment_accounts_payment_risk_payment_account.liquid +55 -0
- package/.agent/cookbook/_setup/accounts_receivable.md +282 -0
- package/.agent/cookbook/_setup/foundation.md +277 -0
- package/.agent/cookbook/_setup/healthcare.md +279 -0
- package/.agent/cookbook/_setup/payment_risk.md +283 -0
- package/.agent/cookbook/action-status-updaters.md +212 -0
- package/.agent/cookbook/ai-agent-invoke.md +243 -0
- package/.agent/cookbook/appointment-review-sms-workflow.md +761 -0
- package/.agent/cookbook/birthday-greeting-sms-trigger.md +656 -0
- package/.agent/cookbook/bulk-ingest.md +254 -0
- package/.agent/cookbook/contact-us-triage-with-llm.md +622 -0
- package/.agent/cookbook/custom-tables.md +201 -0
- package/.agent/cookbook/dunning-sms-for-delinquent.md +619 -0
- package/.agent/cookbook/invite-team.md +194 -0
- package/.agent/cookbook/kyc-notification-on-account-activation.md +619 -0
- package/.agent/cookbook/rest-fetch.md +246 -0
- package/.agent/cookbook/sanctions-screening-with-agent-review.md +733 -0
- package/.agent/cookbook/score-leads-with-llm-categorization.md +624 -0
- package/.agent/cookbook/system-templates.md +129 -0
- package/.agent/cookbook/triage-prospects-by-priority.md +533 -0
- package/.agent/cookbook/welcome-sms-for-customers.md +607 -0
- package/.agent/data_activation_clients.md +559 -0
- package/.agent/data_sources.md +235 -0
- package/.agent/datalakes.md +714 -0
- package/.agent/debugging.md +137 -0
- package/.agent/errors.md +190 -0
- package/.agent/generic_tables.md +351 -0
- package/.agent/interoperability_contracts.md +417 -0
- package/.agent/mdm.md +293 -0
- package/.agent/mutations.md +126 -0
- package/.agent/templates.md +98 -0
- package/.agent/tool-call-configs.md +90 -0
- package/.agent/tools.md +547 -0
- package/.agent/type_naming.md +129 -0
- package/.agent/workflows.md +617 -0
- package/README.md +178 -0
- package/dist/bin/platform-sdk.d.mts +1 -0
- package/dist/bin/platform-sdk.mjs +106 -0
- package/dist/bin/platform-sdk.mjs.map +1 -0
- package/dist/index.d.mts +1310 -44116
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1194 -7344
- package/dist/index.mjs.map +1 -1
- package/package.json +19 -10
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# Action status updaters
|
|
2
|
+
|
|
3
|
+
An **action status updater** is a scheduled job that polls an
|
|
4
|
+
external system (e.g. a cloud-provider log group, a delivery
|
|
5
|
+
provider's API) for status updates on actions the platform
|
|
6
|
+
previously fired, and writes those updates back onto the
|
|
7
|
+
matching message rows.
|
|
8
|
+
|
|
9
|
+
The typical use case: a workflow's SMS action fires through a
|
|
10
|
+
provider (a sender tool), and a status updater periodically
|
|
11
|
+
polls the provider's log group to mark each message as
|
|
12
|
+
`delivered` / `failed` / `bounced` on its tracked record.
|
|
13
|
+
|
|
14
|
+
SDK namespace: `api.actionStatusUpdaters`.
|
|
15
|
+
|
|
16
|
+
Action status updaters are **Datalake-DB-resident** — the
|
|
17
|
+
parent datalake must be `status: 'ready'` and every
|
|
18
|
+
referenced tool must exist before you `create()`.
|
|
19
|
+
|
|
20
|
+
## 1. Wire shape
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import type {
|
|
24
|
+
ActionStatusUpdaterRequestWritable,
|
|
25
|
+
ActionStatusUpdaterResponse,
|
|
26
|
+
} from '@alvera-ai/platform-sdk'
|
|
27
|
+
|
|
28
|
+
const { data: created } = await api.actionStatusUpdaters.create(
|
|
29
|
+
tenantSlug,
|
|
30
|
+
datalakeSlug,
|
|
31
|
+
{
|
|
32
|
+
name: 'SMS Delivery Updater',
|
|
33
|
+
cron_expression: '*/30 * * * *', // every 30 minutes
|
|
34
|
+
updater_type: 'cloud_watch', // polling source family
|
|
35
|
+
updater_tool_id: cloudWatchToolId, // the tool that issues the poll
|
|
36
|
+
sender_tool_ids: [smsToolId], // tools whose sent messages this updater tracks
|
|
37
|
+
datalake_id: datalakeId,
|
|
38
|
+
|
|
39
|
+
// Polymorphic — discriminator: updater_body_type
|
|
40
|
+
updater_body: {
|
|
41
|
+
updater_body_type: 'cloud_watch_request',
|
|
42
|
+
log_group_name: 'sns/us-east-1/...',
|
|
43
|
+
start_time: '{{ now | minutes_ago: 45 }}', // Liquid window
|
|
44
|
+
end_time: '{{ now }}',
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
// Liquid template emitting JSON that maps poll events to message updates
|
|
48
|
+
message_config: {
|
|
49
|
+
type: 'custom',
|
|
50
|
+
body:
|
|
51
|
+
'{% for event in events %}' +
|
|
52
|
+
'{"external_id": "{{ event.message_id }}", "set_params": {"status": "{{ event.status }}"}}' +
|
|
53
|
+
'{% endfor %}',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## 2. Rules the type cannot encode
|
|
60
|
+
|
|
61
|
+
### `updater_body` is polymorphic on `updater_body_type`
|
|
62
|
+
|
|
63
|
+
The body's discriminator selects the polling shape. Each
|
|
64
|
+
variant declares the fields the platform needs to construct
|
|
65
|
+
the poll request:
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
updater_body_type: 'cloud_watch_request'
|
|
69
|
+
log_group_name string — the log group to scan
|
|
70
|
+
start_time string — Liquid template producing a timestamp
|
|
71
|
+
end_time string — Liquid template producing a timestamp
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
(See the SDK type for the full set of body types — others
|
|
75
|
+
follow the same `<verb>_request` naming and carry the fields
|
|
76
|
+
their target API requires.)
|
|
77
|
+
|
|
78
|
+
`start_time` / `end_time` accept Liquid expressions using the
|
|
79
|
+
`now` variable plus relative-time filters (`minutes_ago: N`,
|
|
80
|
+
`hours_ago: N`, ...). A literal ISO 8601 string also works for
|
|
81
|
+
fixed windows.
|
|
82
|
+
|
|
83
|
+
### `message_config.body` emits a JSON event stream
|
|
84
|
+
|
|
85
|
+
The template runs against an `events` array — the parsed
|
|
86
|
+
response from the polling tool. Each iteration must render
|
|
87
|
+
one JSON object with two required fields:
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
external_id string — the message identifier to update (typically
|
|
91
|
+
the provider's id, matching the recipient
|
|
92
|
+
record's external_id column)
|
|
93
|
+
set_params object — fields to update on the matching message row
|
|
94
|
+
(e.g. { status, delivered_at, error_code })
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The platform parses the rendered output, joins each event to a
|
|
98
|
+
message row by `external_id`, and applies `set_params` as the
|
|
99
|
+
update. Events that don't match any message are silently
|
|
100
|
+
discarded.
|
|
101
|
+
|
|
102
|
+
### `cron_expression` is a standard 5-field cron string
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
*/30 * * * * — every 30 minutes
|
|
106
|
+
0 * * * * — every hour on the minute
|
|
107
|
+
0 9 * * 1-5 — 9am Mon-Fri
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Sub-minute cadences are NOT supported. The minimum interval
|
|
111
|
+
the scheduler honors depends on platform-level configuration;
|
|
112
|
+
default minimum is 5 minutes.
|
|
113
|
+
|
|
114
|
+
### `updater_type` and `updater_body.updater_body_type` must correspond
|
|
115
|
+
|
|
116
|
+
The body carries TWO discriminator fields that name the same
|
|
117
|
+
choice from different angles:
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
updater_type outer field on the request body
|
|
121
|
+
(top-level)
|
|
122
|
+
updater_body.updater_body_type inner field on the polymorphic
|
|
123
|
+
body embed
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
They must agree according to a fixed mapping:
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
updater_type: "cloud_watch" ↔ updater_body_type: "cloud_watch_request"
|
|
130
|
+
updater_type: "restapi" ↔ updater_body_type: "restapi_request"
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
A mismatched pair (e.g. `updater_type: "cloud_watch"` +
|
|
134
|
+
`updater_body_type: "restapi_request"`) returns 422 — typically
|
|
135
|
+
on `/updater_type` with a "type / body type mismatch" message.
|
|
136
|
+
The full mapping is exported by the SDK; the `updater_type` enum
|
|
137
|
+
and the `updater_body_type` enum are kept in lockstep by the
|
|
138
|
+
generated types.
|
|
139
|
+
|
|
140
|
+
### `updater_tool_id` and `sender_tool_ids` serve different roles
|
|
141
|
+
|
|
142
|
+
- `updater_tool_id` (single) — the tool the updater uses to
|
|
143
|
+
ISSUE the poll. Must be a tool whose `intent` is
|
|
144
|
+
`status_poller` (e.g. a `cloud_watch_log_group` body type).
|
|
145
|
+
- `sender_tool_ids` (array) — the tools whose sent messages
|
|
146
|
+
this updater is responsible for tracking. The match logic
|
|
147
|
+
joins each polled event back to a message row that was
|
|
148
|
+
sent through one of these tools.
|
|
149
|
+
|
|
150
|
+
A single status updater can track messages from multiple
|
|
151
|
+
sender tools (e.g. an SMS tool plus a voice tool routed
|
|
152
|
+
through the same provider).
|
|
153
|
+
|
|
154
|
+
## 3. Field ownership
|
|
155
|
+
|
|
156
|
+
**Server-derived (Response-only).** Universal set from
|
|
157
|
+
`type_naming.md`.
|
|
158
|
+
|
|
159
|
+
**Caller-supplied (round-trip).**
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
name required string
|
|
163
|
+
cron_expression required string — standard cron
|
|
164
|
+
updater_type required enum — e.g. 'cloud_watch'
|
|
165
|
+
updater_tool_id required UUID — the polling tool
|
|
166
|
+
sender_tool_ids required UUID[] — tools whose messages this updater tracks
|
|
167
|
+
datalake_id required UUID
|
|
168
|
+
updater_body required embed — { updater_body_type, ... }
|
|
169
|
+
message_config required embed — { type, body }
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Write-only (Request-only).** None.
|
|
173
|
+
|
|
174
|
+
## 4. Error envelopes
|
|
175
|
+
|
|
176
|
+
Standard JSON:API envelopes per `errors.md`. Common rejections:
|
|
177
|
+
|
|
178
|
+
| `source.pointer` | Cause |
|
|
179
|
+
|-------------------------------------|----------------------------------------------------|
|
|
180
|
+
| `/cron_expression` | invalid cron syntax or below minimum interval |
|
|
181
|
+
| `/updater_tool_id` | tool's intent isn't `status_poller` |
|
|
182
|
+
| `/sender_tool_ids/0` | tool id doesn't exist or wrong datalake |
|
|
183
|
+
| `/updater_body/updater_body_type` | enum mismatch |
|
|
184
|
+
| `/updater_type` | mismatch with `updater_body.updater_body_type` |
|
|
185
|
+
| `/message_config/body` | empty when `type: 'custom'` |
|
|
186
|
+
| `/base` | `cron_management_failed` — body validated and saved but scheduler registration failed; the row is rolled back |
|
|
187
|
+
|
|
188
|
+
## 5. Lifecycle
|
|
189
|
+
|
|
190
|
+
### Create
|
|
191
|
+
|
|
192
|
+
Synchronous. A successful create registers a scheduled poll
|
|
193
|
+
under the supplied `cron_expression`; the first run fires at
|
|
194
|
+
the next cron slot at-or-after create time.
|
|
195
|
+
|
|
196
|
+
The cron registration is part of the create transaction — if
|
|
197
|
+
the body validates but scheduler registration fails, the
|
|
198
|
+
platform rolls the row back and returns 422 with
|
|
199
|
+
`cron_management_failed` on `/base` (see §4). Conversely, a
|
|
200
|
+
body that fails structural validation never reaches the
|
|
201
|
+
scheduler; cron-job registration only happens on the success
|
|
202
|
+
branch.
|
|
203
|
+
|
|
204
|
+
### Read shapes
|
|
205
|
+
|
|
206
|
+
```
|
|
207
|
+
.list(tenantSlug, datalakeSlug) Paged: { data, meta }
|
|
208
|
+
.get(tenantSlug, datalakeSlug, idOrSlug) One row
|
|
209
|
+
.metadata(tenantSlug, datalakeSlug) Markdown — catalog
|
|
210
|
+
.metadataDetails(tenantSlug, datalakeSlug, Markdown — one updater
|
|
211
|
+
idOrSlug)
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Update
|
|
215
|
+
|
|
216
|
+
`update()` replaces the whole resource — resupply the full
|
|
217
|
+
body; there's no partial update. The polymorphic `updater_body`
|
|
218
|
+
must keep the same `updater_body_type` on update — the
|
|
219
|
+
discriminator can't change on `update()`; to change body type,
|
|
220
|
+
`delete()` and `create()` fresh.
|
|
221
|
+
|
|
222
|
+
### Delete
|
|
223
|
+
|
|
224
|
+
`delete()` removes the row and cancels future scheduled polls.
|
|
225
|
+
In-flight polls complete; their writebacks land normally.
|
|
226
|
+
|
|
227
|
+
The delete is **graceful** with respect to scheduler state: if
|
|
228
|
+
the row exists but its cron-job entry is somehow missing or
|
|
229
|
+
the scheduler raises during cancellation, the row is still
|
|
230
|
+
deleted and the DELETE returns 204. Consumers do not need to
|
|
231
|
+
check or retry for partial-delete states.
|
|
232
|
+
|
|
233
|
+
## 6. Gotchas
|
|
234
|
+
|
|
235
|
+
1. **The polling tool's `intent` must be `status_poller`.**
|
|
236
|
+
A tool with `intent: 'sms'` or any other non-poller intent
|
|
237
|
+
is rejected at create time. The poller intent gates the
|
|
238
|
+
tool's eligibility as an `updater_tool_id`.
|
|
239
|
+
|
|
240
|
+
2. **`message_config.body` must emit valid JSON.** The
|
|
241
|
+
template is rendered against the polling tool's parsed
|
|
242
|
+
response and the output is then JSON-parsed. A render that
|
|
243
|
+
produces malformed JSON (e.g. trailing comma, unquoted
|
|
244
|
+
string) makes the entire poll cycle silently no-op for
|
|
245
|
+
that updater — events stay unprocessed.
|
|
246
|
+
|
|
247
|
+
3. **`external_id` join is exact-match.** Events whose
|
|
248
|
+
`external_id` doesn't match a message row are discarded
|
|
249
|
+
silently. If your provider returns a prefixed id (e.g.
|
|
250
|
+
`provider-prefix/12345`) but your message rows carry
|
|
251
|
+
the bare id, transform inside the Liquid template (string
|
|
252
|
+
filters) so the rendered `external_id` matches.
|
|
253
|
+
|
|
254
|
+
4. **`set_params` keys must be writable columns on the
|
|
255
|
+
message row.** Unknown keys are silently dropped during
|
|
256
|
+
the update. Refer to the message dataset's schema to
|
|
257
|
+
confirm which columns are writable from updater output.
|
|
258
|
+
|
|
259
|
+
5. **Cron windows + polling-window overlap.** Choose
|
|
260
|
+
`start_time` / `end_time` to overlap consecutive cron
|
|
261
|
+
intervals (e.g. cron every 30 min, window of 45 min) so
|
|
262
|
+
transient delivery delays don't fall between two polls.
|
|
263
|
+
The defaults in the wire-shape example illustrate this
|
|
264
|
+
pattern: 30-minute cron, 45-minute window.
|