@personize/sdk 0.2.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/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2025 Personize AI
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,295 @@
1
+ # Personize SDK
2
+
3
+ The official Node.js/TypeScript SDK for the Personize Product API. Authenticate with your secret key to access variables, smart context, RAG memory, prompt execution, and agents.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @personize/sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { Personize } from '@personize/sdk';
15
+
16
+ const client = new Personize({
17
+ secretKey: 'sk_live_...',
18
+ // baseURL: 'http://localhost:3000' // Optional: for local development
19
+ });
20
+
21
+ // Verify auth and read plan limits
22
+ const me = await client.me();
23
+ console.log(me.data.plan.name);
24
+ console.log(me.data.plan.limits);
25
+ ```
26
+
27
+ ## API Endpoints
28
+
29
+ | Method | Path | SDK Method |
30
+ | :--- | :--- | :--- |
31
+ | GET | `/api/v1/me` | `client.me()` |
32
+ | GET | `/api/v1/variables` | `client.variables.list()` |
33
+ | GET | `/api/v1/variables/:id/structure` | `client.variables.getStructure(id)` |
34
+ | GET | `/api/v1/variables/:id/section` | `client.variables.getSection(id, opts)` |
35
+ | PATCH | `/api/v1/variables/:id` | `client.variables.update(id, payload)` |
36
+ | POST | `/api/v1/variables` | `client.variables.create(payload)` |
37
+ | DELETE | `/api/v1/variables/:id` | `client.variables.delete(id)` |
38
+ | GET | `/api/v1/collections` | `client.collections.list()` |
39
+ | POST | `/api/v1/ai/smart-context` | `client.ai.smartContext(opts)` |
40
+ | POST | `/api/v1/prompt` | `client.ai.prompt(opts)` |
41
+ | GET | `/api/v1/agents` | `client.agents.list()` |
42
+ | POST | `/api/v1/agents/:id/run` | `client.agents.run(id, opts)` |
43
+ | POST | `/api/v1/memorize_pro` | `client.memory.memorize(opts)` |
44
+ | POST | `/api/v1/batch-memorize` | `client.memory.memorizeBatch(opts)` |
45
+ | POST | `/api/v1/recall_pro` | `client.memory.recall(opts)` |
46
+ | POST | `/api/v1/export` | `client.memory.export(opts)` |
47
+ | POST | `/api/v1/smart-memory-digest` | `client.memory.smartDigest(opts)` |
48
+ | POST | `/api/v1/upsert` | `client.memory.upsert(opts)` |
49
+ | POST | `/api/v1/upsert` | `client.memory.upsertBatch(opts)` |
50
+
51
+ All endpoints require `Authorization: Bearer sk_live_...` and count against your plan limits.
52
+
53
+ ## Usage
54
+
55
+ ### Variables
56
+
57
+ ```typescript
58
+ // List all variables
59
+ const vars = await client.variables.list();
60
+
61
+ // Create a variable
62
+ await client.variables.create({ name: 'ICP', value: '...', tags: ['sales'] });
63
+
64
+ // Update a variable
65
+ await client.variables.update(variableId, { value: 'new content' });
66
+
67
+ // Get variable structure (headings)
68
+ const structure = await client.variables.getStructure(variableId);
69
+
70
+ // Get a specific section
71
+ const section = await client.variables.getSection(variableId, { header: '## Pricing' });
72
+
73
+ // Delete a variable
74
+ await client.variables.delete(variableId);
75
+ ```
76
+
77
+ ### Smart Context
78
+
79
+ ```typescript
80
+ const ctx = await client.ai.smartContext({
81
+ message: 'Write a sales sequence for our top 3 ICPs',
82
+ tags: ['sales'],
83
+ excludeTags: ['internal'],
84
+ });
85
+ console.log(ctx.data.compiledContext);
86
+ ```
87
+
88
+ ### Prompt Execution
89
+
90
+ ```typescript
91
+ // Simple prompt
92
+ const response = await client.ai.prompt({
93
+ prompt: 'Summarize our Q4 sales strategy',
94
+ });
95
+
96
+ // Multi-step instructions with evaluation
97
+ const result = await client.ai.prompt({
98
+ instructions: [
99
+ { prompt: 'Analyze the data', maxSteps: 5 },
100
+ { prompt: 'Write a summary based on the analysis', maxSteps: 3 },
101
+ ],
102
+ evaluate: { criteria: 'sales', serverSide: true },
103
+ });
104
+
105
+ // Output extraction + auto-memorize
106
+ const research = await client.ai.prompt({
107
+ instructions: [
108
+ { prompt: 'Research the company using search tools', maxSteps: 5 },
109
+ { prompt: 'Write a personalized outreach email', maxSteps: 3 },
110
+ ],
111
+ outputs: [
112
+ { name: 'company_profile' },
113
+ { name: 'outreach_email' },
114
+ ],
115
+ memorize: {
116
+ email: 'john@acme.com',
117
+ websiteUrl: 'acme.com',
118
+ type: 'Company',
119
+ captureToolResults: true,
120
+ },
121
+ evaluate: { criteria: 'sales', serverSide: true },
122
+ });
123
+
124
+ console.log(research.data?.outputs?.company_profile);
125
+ console.log(research.data?.evaluation?.finalScore);
126
+ ```
127
+
128
+ ### Memory (RAG)
129
+
130
+ ```typescript
131
+ // Memorize content
132
+ await client.memory.memorize({
133
+ content: 'Meeting notes: John prefers email contact.',
134
+ speaker: 'Sales Rep',
135
+ enhanced: true,
136
+ tags: ['meetings'],
137
+ email: 'john@example.com',
138
+ });
139
+
140
+ // Recall memories
141
+ const results = await client.memory.recall({
142
+ query: 'What does John prefer?',
143
+ limit: 5,
144
+ minScore: 0.7,
145
+ });
146
+
147
+ // Export/filter records
148
+ const exported = await client.memory.export({
149
+ groups: [{
150
+ id: 'g1',
151
+ logic: 'AND',
152
+ conditions: [{ field: 'Company', operator: 'EQ', value: 'Acme Corp' }],
153
+ }],
154
+ returnRecords: true,
155
+ pageSize: 50,
156
+ });
157
+
158
+ // Batch sync — unified call with per-property extractMemories flag
159
+ await client.memory.memorizeBatch({
160
+ source: 'Hubspot',
161
+ mapping: {
162
+ entityType: 'contact',
163
+ email: 'email',
164
+ properties: {
165
+ email: { sourceField: 'email', collectionId: 'col_std', collectionName: 'Standard' },
166
+ full_name: { sourceField: 'fullname', collectionId: 'col_std', collectionName: 'Standard' },
167
+ notes: { sourceField: 'notes', collectionId: 'col_gen', collectionName: 'Generated', extractMemories: true },
168
+ },
169
+ },
170
+ rows: [
171
+ { email: 'john@acme.com', fullname: 'John Smith', notes: 'VP Sales, interested in enterprise plan' },
172
+ ],
173
+ });
174
+
175
+ // Smart memory digest — compiled context for an entity
176
+ const digest = await client.memory.smartDigest({
177
+ email: 'john@acme.com',
178
+ type: 'Contact',
179
+ token_budget: 1000,
180
+ });
181
+ console.log(digest.data?.compiledContext); // ready-to-use markdown for LLM prompts
182
+
183
+ // Structured upsert — legacy, no AI extraction
184
+ await client.memory.upsert({
185
+ type: 'Contact',
186
+ properties: {
187
+ email: { value: 'john@acme.com', collectionId: 'col_123' },
188
+ company: { value: 'Acme Corp' },
189
+ },
190
+ matchKeys: { email: 'john@acme.com' },
191
+ source: 'crm-sync',
192
+ });
193
+ ```
194
+
195
+ ### Agents
196
+
197
+ ```typescript
198
+ const agents = await client.agents.list();
199
+
200
+ const result = await client.agents.run(agentId, {
201
+ inputs: { userMessage: 'Help with onboarding' },
202
+ email: 'customer@example.com',
203
+ });
204
+ ```
205
+
206
+ ### Collections
207
+
208
+ ```typescript
209
+ const collections = await client.collections.list();
210
+ ```
211
+
212
+ ## Configuration
213
+
214
+ | Option | Type | Required | Description |
215
+ | :--- | :--- | :--- | :--- |
216
+ | `secretKey` | string | Yes | Your secret key (`sk_live_...`). |
217
+ | `baseURL` | string | No | Custom API endpoint (default: `https://api.personize.ai`). |
218
+
219
+ ## Test Key (Local Development)
220
+
221
+ ```typescript
222
+ const client = new Personize({
223
+ secretKey: 'sk_live_TEST_KEY_00000000000000000000000000000000000000000000000000000000',
224
+ baseURL: 'http://localhost:3000',
225
+ });
226
+ ```
227
+
228
+ ## Skills
229
+
230
+ The SDK ships with AI-assistant skills in `skills/` that teach Claude Code, Codex, and Cursor how to use the SDK for common workflows.
231
+
232
+ ### Integration Builder (`skills/integrations/`)
233
+
234
+ Build CRM/database sync integrations. Connect Salesforce, HubSpot, Postgres, or any data source to Personize memory with batch memorization and scheduled deployment.
235
+
236
+ ```
237
+ skills/integrations/
238
+ ├── CLAUDE.md # Main skill instructions
239
+ ├── templates/
240
+ │ ├── salesforce.md # Salesforce connector pattern
241
+ │ ├── hubspot.md # HubSpot connector pattern
242
+ │ └── postgres.md # Postgres/MySQL pattern
243
+ └── deploy/
244
+ ├── Dockerfile # Container deployment
245
+ ├── render.yaml # Render cron service
246
+ └── github-action.yml # GitHub Actions schedule
247
+ ```
248
+
249
+ ### Governance (`skills/governance/`)
250
+
251
+ Manage variables as code — maintain a `governance/variables/` folder of `.md` files and sync them to the Personize API.
252
+
253
+ ```
254
+ skills/governance/
255
+ ├── CLAUDE.md # Main skill instructions
256
+ ├── sync.ts # CLI sync script
257
+ └── github-action.yml # CI sync on push
258
+ ```
259
+
260
+ ### AI Content Pipelines (`skills/content-pipelines/`)
261
+
262
+ Build intelligent, memory-powered AI systems that follow a 10-step agentic loop: **Observe → Remember → Recall → Reason → Plan → Decide → Generate → Act → Update → Repeat**. Includes ready-to-run recipe scripts for product intelligence memorization, smart notifications, web page personalization, cold outreach, and more — plus channel delivery templates for SendGrid, Slack, Twilio, and generic webhooks.
263
+
264
+ ```
265
+ skills/content-pipelines/
266
+ ├── CLAUDE.md # Main skill instructions (10-step loop)
267
+ ├── recipes/
268
+ │ ├── product-intelligence.ts # Memorize everything: usage, ML, searches, content, uploads, telemetry
269
+ │ ├── smart-notification.ts # Uniquely personalized alerts via smartDigest
270
+ │ ├── web-personalization.ts # AI generates UI variable values for personalized web pages
271
+ │ ├── cold-outreach-sequence.ts # 3-email cold outreach with sequence tracking
272
+ │ ├── meeting-prep-brief.ts # On-demand meeting prep brief generator
273
+ │ ├── product-usage-alert.ts # Usage monitoring + smart alerts
274
+ │ ├── health-check-message.ts # Customer health assessment + check-in
275
+ │ └── batch-pipeline.ts # Configurable generic batch pipeline
276
+ └── channels/
277
+ ├── sendgrid.md # Email delivery (SendGrid, SES, Resend)
278
+ ├── slack.md # Slack webhooks + Web API
279
+ ├── twilio.md # SMS + WhatsApp via Twilio
280
+ └── webhook.md # Generic HTTP POST (in-app, CRM, Zapier)
281
+ ```
282
+
283
+ ### n8n Workflow Builder (`skills/n8n-workflows/`)
284
+
285
+ Generate importable n8n workflow JSON files that sync data between Personize and 400+ apps — no code required. Supports batch sync in (source → Personize), sync out (Personize → destination), webhook-triggered real-time ingestion, and per-record AI enrichment.
286
+
287
+ ```
288
+ skills/n8n-workflows/
289
+ ├── CLAUDE.md # Main skill instructions
290
+ └── templates/
291
+ ├── hubspot-to-personize.json # HubSpot contacts → Personize
292
+ ├── gsheets-to-personize.json # Google Sheets → Personize
293
+ ├── webhook-to-personize.json # Webhook → Personize (real-time)
294
+ └── personize-to-slack.json # Personize → Slack digest
295
+ ```
@@ -0,0 +1,129 @@
1
+ import { PersonizeConfig, ApiResponse, MeResponse, ListOptions, VariablesResponse, VariableSectionOptions, VariableUpdatePayload, VariableCreatePayload, VariableHistoryResponse, VariableHistoryOptions, CollectionsResponse, CollectionCreatePayload, CollectionUpdatePayload, CollectionHistoryOptions, CollectionHistoryResponse, SmartContextOptions, SmartContextResponse, PromptOptions, PromptResponse, AgentRunOptions, MemorizeProOptions, RecallProOptions, ExportOptions, ExportResponse, UpsertOptions, UpsertBatchOptions, BatchMemorizeOptions, SmartDigestOptions, SmartDigestResponse } from './types';
2
+ export declare class Personize {
3
+ private client;
4
+ private _organizationId?;
5
+ private _userId?;
6
+ private maxRetries;
7
+ private retryDelay;
8
+ constructor(config: PersonizeConfig);
9
+ private resolveIdentity;
10
+ private getOrganizationId;
11
+ /**
12
+ * GET /api/v1/me — Current context (org, user, plan)
13
+ */
14
+ me(): Promise<ApiResponse<MeResponse>>;
15
+ variables: {
16
+ /**
17
+ * GET /api/v1/variables — List variables for the organization (paginated).
18
+ * Pass `limit` and `nextToken` for cursor-based pagination.
19
+ */
20
+ list: (options?: ListOptions) => Promise<ApiResponse<VariablesResponse>>;
21
+ /**
22
+ * GET /api/v1/variables/:id/structure — Get variable headings
23
+ */
24
+ getStructure: (id: string) => Promise<ApiResponse>;
25
+ /**
26
+ * GET /api/v1/variables/:id/section — Get a section of a variable by header
27
+ */
28
+ getSection: (id: string, options: VariableSectionOptions) => Promise<ApiResponse>;
29
+ /**
30
+ * PATCH /api/v1/variables/:id — Partial update to a variable
31
+ */
32
+ update: (id: string, payload: VariableUpdatePayload) => Promise<ApiResponse>;
33
+ /**
34
+ * POST /api/v1/variables — Create a new variable
35
+ */
36
+ create: (payload: VariableCreatePayload) => Promise<ApiResponse>;
37
+ /**
38
+ * DELETE /api/v1/variables/:id — Delete a variable
39
+ */
40
+ delete: (id: string) => Promise<ApiResponse>;
41
+ /**
42
+ * GET /api/v1/actions/:id/history — Get version history for a variable
43
+ */
44
+ history: (id: string, options?: VariableHistoryOptions) => Promise<ApiResponse<VariableHistoryResponse>>;
45
+ };
46
+ collections: {
47
+ /**
48
+ * GET /api/v1/collections — List property collections (paginated).
49
+ * Pass `limit` and `nextToken` for cursor-based pagination.
50
+ */
51
+ list: (options?: ListOptions) => Promise<ApiResponse<CollectionsResponse>>;
52
+ /**
53
+ * POST /api/v1/collections — Create a new property collection
54
+ */
55
+ create: (payload: CollectionCreatePayload) => Promise<ApiResponse>;
56
+ /**
57
+ * PATCH /api/v1/collections/:id — Update a property collection (smart merge for properties array)
58
+ */
59
+ update: (id: string, payload: CollectionUpdatePayload) => Promise<ApiResponse>;
60
+ /**
61
+ * DELETE /api/v1/collections/:id — Delete a property collection
62
+ */
63
+ delete: (id: string) => Promise<ApiResponse>;
64
+ /**
65
+ * GET /api/v1/collections/:id/history — Version history for a collection.
66
+ * Use mode='diff' for token-efficient diffs (~80% fewer tokens than full snapshots).
67
+ */
68
+ history: (id: string, options?: CollectionHistoryOptions) => Promise<ApiResponse<CollectionHistoryResponse>>;
69
+ };
70
+ ai: {
71
+ /**
72
+ * POST /api/v1/ai/smart-context — Semantic context routing
73
+ */
74
+ smartContext: (options: SmartContextOptions) => Promise<ApiResponse<SmartContextResponse>>;
75
+ /**
76
+ * POST /api/v1/prompt — Execute a prompt with tools, output extraction, and evaluation.
77
+ *
78
+ * Supports simple mode (single prompt) and advanced mode (multi-step instructions).
79
+ * Use `outputs` for server-side structured output extraction via `<output>` markers.
80
+ * Use `evaluate` for server-side auto-evaluation.
81
+ * Use `memorize` to auto-save outputs and tool results to memory.
82
+ */
83
+ prompt: (options: PromptOptions) => Promise<ApiResponse<PromptResponse>>;
84
+ };
85
+ agents: {
86
+ /**
87
+ * GET /api/v1/agents — List available agents (paginated).
88
+ * Pass `limit` and `nextToken` for cursor-based pagination.
89
+ */
90
+ list: (options?: ListOptions) => Promise<ApiResponse>;
91
+ /**
92
+ * POST /api/v1/agents/:id/run — Run an agent
93
+ */
94
+ run: (id: string, options?: AgentRunOptions) => Promise<ApiResponse>;
95
+ };
96
+ memory: {
97
+ /**
98
+ * POST /api/v1/memorize_pro — Advanced memorization (RAG)
99
+ */
100
+ memorize: (data: MemorizeProOptions) => Promise<ApiResponse>;
101
+ /**
102
+ * POST /api/v1/recall_pro — Advanced recall with reflection (RAG)
103
+ */
104
+ recall: (data: RecallProOptions) => Promise<ApiResponse>;
105
+ /**
106
+ * POST /api/v1/export — Filter and export records
107
+ */
108
+ export: (data: ExportOptions) => Promise<ApiResponse<ExportResponse>>;
109
+ /**
110
+ * POST /api/v1/upsert — Structured upsert (no AI extraction)
111
+ */
112
+ upsert: (data: UpsertOptions) => Promise<ApiResponse>;
113
+ /**
114
+ * POST /api/v1/upsert — Batch upsert (memories array format)
115
+ */
116
+ upsertBatch: (data: UpsertBatchOptions) => Promise<ApiResponse>;
117
+ /**
118
+ * POST /api/v1/batch-memorize — Unified batch sync with per-property extractMemories flag.
119
+ * Properties with extractMemories: true go through AI extraction + vectors.
120
+ * Properties without it (or false) are stored as structured data only.
121
+ */
122
+ memorizeBatch: (data: BatchMemorizeOptions) => Promise<ApiResponse>;
123
+ /**
124
+ * POST /api/v1/smart-memory-digest — Get compiled context bundle for an entity.
125
+ * Combines DynamoDB properties + LanceDB memories into a token-budgeted markdown block.
126
+ */
127
+ smartDigest: (data: SmartDigestOptions) => Promise<ApiResponse<SmartDigestResponse>>;
128
+ };
129
+ }