@elevasis/sdk 0.5.12 → 0.5.13
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/dist/cli.cjs +92 -81
- package/dist/index.d.ts +11 -253
- package/dist/index.js +5 -9
- package/dist/templates.js +26 -23
- package/dist/types/worker/adapters/index.d.ts +0 -1
- package/dist/worker/index.js +47 -53
- package/package.json +1 -1
- package/reference/_navigation.md +13 -57
- package/reference/concepts.mdx +203 -0
- package/reference/deployment/{command-center-ui.mdx → command-center.mdx} +229 -151
- package/reference/deployment/index.mdx +158 -153
- package/reference/framework/agent.mdx +168 -151
- package/reference/framework/index.mdx +182 -103
- package/reference/framework/memory.mdx +347 -347
- package/reference/framework/tutorial-system.mdx +253 -0
- package/reference/{getting-started/index.mdx → getting-started.mdx} +4 -4
- package/reference/index.mdx +117 -114
- package/reference/platform-tools/adapters.mdx +175 -32
- package/reference/platform-tools/index.mdx +354 -195
- package/reference/resources/index.mdx +5 -0
- package/reference/{roadmap/index.mdx → roadmap.mdx} +1 -1
- package/reference/{runtime/index.mdx → runtime.mdx} +196 -141
- package/dist/types/worker/adapters/trello.d.ts +0 -14
- package/reference/concepts/index.mdx +0 -203
- package/reference/deployment/command-view.mdx +0 -154
- package/reference/framework/documentation.mdx +0 -92
- package/reference/platform-tools/examples.mdx +0 -170
- package/reference/runtime/limits.mdx +0 -75
- package/reference/security/credentials.mdx +0 -141
- /package/reference/{cli/index.mdx → cli.mdx} +0 -0
- /package/reference/{developer → framework}/interaction-guidance.mdx +0 -0
- /package/reference/{troubleshooting/common-errors.mdx → troubleshooting.mdx} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Typed Adapters
|
|
3
|
-
description: Type-safe wrappers over platform.call() for all integrations and platform tools -- Attio, Stripe, Notion, Google Sheets,
|
|
3
|
+
description: Type-safe wrappers over platform.call() for all integrations and platform tools -- Attio, Stripe, Notion, Google Sheets, and more -- with full autocomplete, compile-time checking, and zero boilerplate
|
|
4
4
|
loadWhen: "Using typed adapters instead of raw platform.call(), or needs to know what adapter methods are available"
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -8,6 +8,8 @@ Typed adapters are ergonomic wrappers over `platform.call()` that provide full T
|
|
|
8
8
|
|
|
9
9
|
Both patterns work simultaneously -- adapters compile down to `platform.call()` with zero runtime overhead.
|
|
10
10
|
|
|
11
|
+
**Coverage:** 11 integration adapters (55 methods) + 9 platform tool adapters (57 methods) = 112 total typed methods.
|
|
12
|
+
|
|
11
13
|
```typescript
|
|
12
14
|
// Before: raw platform.call()
|
|
13
15
|
const records = await platform.call({
|
|
@@ -37,7 +39,6 @@ All adapters are imported from `@elevasis/sdk/worker` -- the same subpath as `pl
|
|
|
37
39
|
| `createStripeAdapter(cred)` | 6 |
|
|
38
40
|
| `createNotionAdapter(cred)` | 8 |
|
|
39
41
|
| `createGoogleSheetsAdapter(cred)` | 13 |
|
|
40
|
-
| `createTrelloAdapter(cred)` | 10 |
|
|
41
42
|
| `createInstantlyAdapter(cred)` | 5 |
|
|
42
43
|
| `createSignatureApiAdapter(cred)` | 4 |
|
|
43
44
|
| `createResendAdapter(cred)` | 2 |
|
|
@@ -70,7 +71,7 @@ All adapters are imported from `@elevasis/sdk/worker` -- the same subpath as `pl
|
|
|
70
71
|
import {
|
|
71
72
|
// Integration adapters
|
|
72
73
|
createAttioAdapter, createStripeAdapter, createNotionAdapter,
|
|
73
|
-
createGoogleSheetsAdapter,
|
|
74
|
+
createGoogleSheetsAdapter, createInstantlyAdapter,
|
|
74
75
|
createSignatureApiAdapter, createResendAdapter, createDropboxAdapter,
|
|
75
76
|
createApifyAdapter, createGmailAdapter, createMailsoAdapter,
|
|
76
77
|
// Platform adapters
|
|
@@ -231,31 +232,6 @@ const sheets = createGoogleSheetsAdapter('my-google-credential')
|
|
|
231
232
|
|
|
232
233
|
---
|
|
233
234
|
|
|
234
|
-
## Trello Adapter
|
|
235
|
-
|
|
236
|
-
Factory pattern -- 10 methods for boards, lists, cards, and checklists.
|
|
237
|
-
|
|
238
|
-
```typescript
|
|
239
|
-
const trello = createTrelloAdapter('my-trello-credential')
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
### Methods
|
|
243
|
-
|
|
244
|
-
| Method | Params | Returns |
|
|
245
|
-
|--------|--------|---------|
|
|
246
|
-
| `getBoard` | `GetBoardParams` | `GetBoardResult` |
|
|
247
|
-
| `getLists` | `GetListsParams` | `GetListsResult` |
|
|
248
|
-
| `getCards` | `GetCardsParams` | `GetCardsResult` |
|
|
249
|
-
| `createCard` | `CreateCardParams` | `CreateCardResult` |
|
|
250
|
-
| `updateCard` | `UpdateCardParams` | `UpdateCardResult` |
|
|
251
|
-
| `createList` | `TrelloCreateListParams` | `TrelloCreateListResult` |
|
|
252
|
-
| `createChecklist` | `CreateChecklistParams` | `CreateChecklistResult` |
|
|
253
|
-
| `addChecklistItem` | `AddChecklistItemParams` | `AddChecklistItemResult` |
|
|
254
|
-
| `updateChecklistItem` | `UpdateChecklistItemParams` | `UpdateChecklistItemResult` |
|
|
255
|
-
| `getCardChecklists` | `GetCardChecklistsParams` | `GetCardChecklistsResult` |
|
|
256
|
-
|
|
257
|
-
---
|
|
258
|
-
|
|
259
235
|
## Instantly Adapter
|
|
260
236
|
|
|
261
237
|
Factory pattern -- 5 methods for email campaign management.
|
|
@@ -846,6 +822,176 @@ Method names are compile-time checked against the type map keys -- misspelling a
|
|
|
846
822
|
|
|
847
823
|
---
|
|
848
824
|
|
|
825
|
+
## Why `platform.call()` Must Stay
|
|
826
|
+
|
|
827
|
+
The postMessage boundary between worker and main thread is load-bearing. Adapters wrap it -- they cannot replace it.
|
|
828
|
+
|
|
829
|
+
- **Multi-tenancy enforcement** -- The main thread overwrites `organizationId` on every tool call from parent-owned JWT context. Workers cannot forge a different org's identity.
|
|
830
|
+
- **Secrets isolation** -- API keys, decrypted OAuth tokens, and Supabase service-role credentials never cross the postMessage boundary. Workers only receive `NODE_ENV`.
|
|
831
|
+
- **Service lifecycle** -- `toolServicesRegistry` is initialized once at API startup. Workers don't have access to `initialize()` or the singleton services.
|
|
832
|
+
- **Bundle boundary** -- Org bundles only import `@elevasis/sdk/worker`. Server-side code is not in the dependency graph.
|
|
833
|
+
- **Crash isolation** -- 256MB heap cap per worker means a runaway workflow kills only its worker, not the API process.
|
|
834
|
+
|
|
835
|
+
Adapters are a pure DX layer on top of this boundary.
|
|
836
|
+
|
|
837
|
+
---
|
|
838
|
+
|
|
839
|
+
## Architecture
|
|
840
|
+
|
|
841
|
+
### Call Flow
|
|
842
|
+
|
|
843
|
+
```
|
|
844
|
+
Developer Code
|
|
845
|
+
|
|
|
846
|
+
v
|
|
847
|
+
attio.listRecords(params) <-- typed adapter (SDK-side)
|
|
848
|
+
|
|
|
849
|
+
v
|
|
850
|
+
createAdapter<AttioToolMap>(...) <-- generic factory (SDK-side)
|
|
851
|
+
|
|
|
852
|
+
v
|
|
853
|
+
platform.call({ tool, method, params, credential }) <-- existing generic proxy
|
|
854
|
+
|
|
|
855
|
+
v
|
|
856
|
+
postMessage boundary <-- unchanged
|
|
857
|
+
|
|
|
858
|
+
v
|
|
859
|
+
tool-dispatcher.ts <-- routing
|
|
860
|
+
|
|
|
861
|
+
v
|
|
862
|
+
integrationService.call() <-- unchanged execution
|
|
863
|
+
|
|
|
864
|
+
v
|
|
865
|
+
AttioAdapter.call() <-- unchanged server adapter
|
|
866
|
+
```
|
|
867
|
+
|
|
868
|
+
### ToolMap Type System
|
|
869
|
+
|
|
870
|
+
Per-tool method maps are defined once in `@repo/core` as pure types (zero runtime code, browser-safe). A generic `createAdapter` factory generates the full typed adapter from these maps.
|
|
871
|
+
|
|
872
|
+
**Before (hand-written, per-method boilerplate):**
|
|
873
|
+
|
|
874
|
+
```typescript
|
|
875
|
+
export function createAttioAdapter(credential: string) {
|
|
876
|
+
return {
|
|
877
|
+
createRecord: (params: CreateRecordParams) =>
|
|
878
|
+
platform.call({ tool: 'attio', method: 'createRecord', params, credential }) as Promise<CreateRecordResult>,
|
|
879
|
+
// ... 12 methods, each with manual type import + literal strings + as cast
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
```
|
|
883
|
+
|
|
884
|
+
**After (ToolMap + factory):**
|
|
885
|
+
|
|
886
|
+
```typescript
|
|
887
|
+
import { createAdapter } from './create-adapter.js'
|
|
888
|
+
import type { AttioToolMap } from '../../types/index.js'
|
|
889
|
+
|
|
890
|
+
export function createAttioAdapter(credential: string) {
|
|
891
|
+
return createAdapter<AttioToolMap>('attio', METHODS, credential)
|
|
892
|
+
}
|
|
893
|
+
```
|
|
894
|
+
|
|
895
|
+
The `methods` array is constrained to `(keyof TMap & string)[]` -- misspelling a method name is a compile error.
|
|
896
|
+
|
|
897
|
+
### Type Sharing Strategy
|
|
898
|
+
|
|
899
|
+
Types are defined once in `@repo/core` and shared across SDK and server:
|
|
900
|
+
|
|
901
|
+
```
|
|
902
|
+
packages/core/src/execution/engine/tools/
|
|
903
|
+
tool-maps.ts <-- 16 ToolMap type definitions (browser-safe)
|
|
904
|
+
integration/types/
|
|
905
|
+
attio.ts, stripe.ts, notion.ts, google-sheets.ts
|
|
906
|
+
instantly.ts, signature-api.ts, resend.ts, dropbox.ts
|
|
907
|
+
apify.ts, gmail.ts, mailso.ts
|
|
908
|
+
index.ts <-- barrel export (all 12 integrations)
|
|
909
|
+
platform/storage/types.ts <-- Storage Zod schemas and inferred types
|
|
910
|
+
```
|
|
911
|
+
|
|
912
|
+
**Export chain:**
|
|
913
|
+
|
|
914
|
+
1. Types defined in `@repo/core` (browser-safe locations)
|
|
915
|
+
2. ToolMaps reference these types in `tools/tool-maps.ts`
|
|
916
|
+
3. Exported via `packages/core/src/execution/engine/index.ts`
|
|
917
|
+
4. Available at `@repo/core/execution` subpath
|
|
918
|
+
5. `packages/sdk/src/types/index.ts` re-exports named types
|
|
919
|
+
6. SDK adapters import from `../../types/index.js`
|
|
920
|
+
|
|
921
|
+
---
|
|
922
|
+
|
|
923
|
+
## Design Decisions
|
|
924
|
+
|
|
925
|
+
### ToolMap + Generic Factory
|
|
926
|
+
|
|
927
|
+
All adapters (except LLM) use `createAdapter<TMap>()` instead of hand-written method objects:
|
|
928
|
+
|
|
929
|
+
- Method names are compile-time checked against ToolMap keys (misspelling = compile error)
|
|
930
|
+
- No manual `as Promise<T>` casts -- `TypedAdapter` mapped type handles it
|
|
931
|
+
- Adding a method = one entry in the ToolMap type + one string in the methods array
|
|
932
|
+
|
|
933
|
+
### Factory with Credential Binding
|
|
934
|
+
|
|
935
|
+
Integration adapters use `createXxxAdapter(credential)` pattern:
|
|
936
|
+
|
|
937
|
+
- Credential is bound once, not repeated on every call
|
|
938
|
+
- Mirrors how `createIntegrationTool(credentialName)` works server-side
|
|
939
|
+
- Multiple adapters for same integration with different credentials work simultaneously
|
|
940
|
+
|
|
941
|
+
### LLM Adapter is Hand-Written
|
|
942
|
+
|
|
943
|
+
The LLM adapter stays hand-written because its `generate()` method uses a generic `<T>` for typed output that cannot be expressed in a static ToolMap:
|
|
944
|
+
|
|
945
|
+
```typescript
|
|
946
|
+
generate: <T = unknown>(params: Omit<LLMGenerateRequest, 'signal'>) =>
|
|
947
|
+
platform.call({ tool: 'llm', method: 'generate', params }) as Promise<LLMGenerateResponse<T>>
|
|
948
|
+
```
|
|
949
|
+
|
|
950
|
+
### Name Collision and Browser Safety
|
|
951
|
+
|
|
952
|
+
- **Gmail/Resend prefix**: Both integrations have `SendEmailParams`/`SendEmailResult`. Gmail types use `Gmail*` prefix, Resend types use `Resend*` prefix.
|
|
953
|
+
- **Mailso prefix**: `Mailso*` prefix for namespace clarity.
|
|
954
|
+
- **Browser safety**: `UploadFileParams.contents` and `DownloadDocumentResult.content` use `Uint8Array` instead of Node.js `Buffer`. Server adapters still use `Buffer` internally.
|
|
955
|
+
- **Snake\_case preservation**: Instantly types preserve snake\_case field names (`lead_email`, `campaign_id`) because the server adapter sends them as-is to the Instantly API.
|
|
956
|
+
- **No server-side changes**: All 11 server adapters keep their local type definitions. Shared types are additive.
|
|
957
|
+
|
|
958
|
+
### `NotificationSDKInput` Derived from Core
|
|
959
|
+
|
|
960
|
+
`NotificationSDKInput` is `Omit<CreateNotificationParams, 'userId' | 'organizationId'>` -- derived from the canonical core type, not a local duplicate. Re-exported as `NotificationInput` for backward compatibility.
|
|
961
|
+
|
|
962
|
+
---
|
|
963
|
+
|
|
964
|
+
## Known Issues
|
|
965
|
+
|
|
966
|
+
### Attio `listRecords` Type Mismatch (Server-Side Only)
|
|
967
|
+
|
|
968
|
+
The server-side `attio-adapter.ts` defines a local `ListRecordsParams` with `filter?: Record<string, unknown>`, which is weaker than the shared `QueryRecordsParams` with `filter?: FilterExpression`. The SDK adapter correctly uses `QueryRecordsParams`. Updating `attio-adapter.ts` to use shared types is separate refactoring work.
|
|
969
|
+
|
|
970
|
+
### Dispatcher Still Untyped
|
|
971
|
+
|
|
972
|
+
`tool-dispatcher.ts` still uses `eslint-disable @typescript-eslint/no-explicit-any`. The same ToolMap types could be used server-side to type the dispatcher's switch cases. Future improvement.
|
|
973
|
+
|
|
974
|
+
### Intentionally Not Migrated
|
|
975
|
+
|
|
976
|
+
- `full-diagnostic.ts` and `integration-test.ts` -- use generic `platform.call()` loops for connectivity testing
|
|
977
|
+
- All `supabase`, `session-memory`, `hitl`, `status`, `http` calls -- no typed adapters exist (platform-internal tools)
|
|
978
|
+
|
|
979
|
+
---
|
|
980
|
+
|
|
981
|
+
## Official SDK Comparison
|
|
982
|
+
|
|
983
|
+
| Adapter | Official SDK | Strategy Used | Mirror Accuracy |
|
|
984
|
+
|---------|-------------|---------------|-----------------|
|
|
985
|
+
| Attio | None exists | Raw HTTP fetch | Exact -- endpoints and body shapes match Attio v2 REST API |
|
|
986
|
+
| Stripe | `stripe` (official) | Official SDK | Exact -- uses `stripe.paymentLinks.*`, `stripe.checkout.sessions.*` |
|
|
987
|
+
| Notion | `@notionhq/client` (official) | Official SDK | High -- uses `notion.pages.*`, `notion.blocks.*`; custom method names |
|
|
988
|
+
| Google Sheets | `@googleapis/sheets` (official) | Official SDK + helpers | High -- adds 7 workflow-friendly helpers on top of raw SDK |
|
|
989
|
+
| Apify | `apify-client` exists, not used | Raw HTTP fetch | N/A -- custom polling loop |
|
|
990
|
+
| Resend | `resend` exists, not used | Raw HTTP fetch | High -- matches REST API surface |
|
|
991
|
+
| Gmail | `@googleapis/gmail` (official) | Official SDK | High -- parallel to Sheets pattern |
|
|
992
|
+
|
|
993
|
+
---
|
|
994
|
+
|
|
849
995
|
## When to Use Adapters vs `platform.call()`
|
|
850
996
|
|
|
851
997
|
| Scenario | Use |
|
|
@@ -869,7 +1015,6 @@ Not all platform tools have typed adapters. Here is the complete list of tools a
|
|
|
869
1015
|
|------|--------------|---------|-----------------|
|
|
870
1016
|
| `attio` | `createAttioAdapter` | 12 (CRUD + schema + notes) | `{ apiKey }` |
|
|
871
1017
|
| `google-sheets` | `createGoogleSheetsAdapter` | 13 (read/write/filter/upsert) | OAuth2 / service account |
|
|
872
|
-
| `trello` | `createTrelloAdapter` | 10 (cards/lists/checklists) | `{ apiKey, token }` |
|
|
873
1018
|
| `notion` | `createNotionAdapter` | 8 (pages + blocks) | `{ token }` |
|
|
874
1019
|
| `stripe` | `createStripeAdapter` | 6 (payment links + checkout) | `{ secretKey }` |
|
|
875
1020
|
| `instantly` | `createInstantlyAdapter` | 5 (email campaigns) | `{ apiKey }` |
|
|
@@ -924,6 +1069,4 @@ Timeouts: LLM calls have a 120s timeout. All other tool calls have a 60s timeout
|
|
|
924
1069
|
|
|
925
1070
|
---
|
|
926
1071
|
|
|
927
|
-
**Last Updated:** 2026-03-
|
|
928
|
-
|
|
929
|
-
|
|
1072
|
+
**Last Updated:** 2026-03-05
|