@trayai/helix-sdk 1.15.0 → 1.16.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.
@@ -1,911 +0,0 @@
1
- import { z, ZodType } from 'zod';
2
- import { P as PlatformContext } from './types-BSbvztCi.js';
3
-
4
- interface SdkRuntimeConfig {
5
- /**
6
- * Execution mode. `"lambda"` is set via `setSdkConfig({ mode: "lambda", ... })`
7
- * before the first handler invocation. `"dev"` is the default for `helix dev`
8
- * and local invocations.
9
- */
10
- mode: "lambda" | "dev";
11
- /**
12
- * Execution ID for the current invocation. Set via `setSdkConfig(...)` at
13
- * handler entry in lambda mode. In `dev` mode, define-function falls back to
14
- * the `x-tray-execution-id` header (or a random UUID).
15
- */
16
- executionId?: string;
17
- /**
18
- * User ID for the current invocation. Set via `setSdkConfig(...)` at handler
19
- * entry in lambda mode. In `dev` mode, define-function reads from the
20
- * `x-tray-user-id` header.
21
- */
22
- userId?: string;
23
- /**
24
- * Email of the calling user for the current invocation. Set via
25
- * `setSdkConfig(...)` at handler entry in lambda mode. In `dev` mode,
26
- * define-function reads from the `x-tray-user-email` header. Only exposed
27
- * on `ctx.identity` when `userId` is also set.
28
- */
29
- userEmail?: string;
30
- /**
31
- * Display name of the calling user for the current invocation. Set via
32
- * `setSdkConfig(...)` at handler entry in lambda mode. In `dev` mode,
33
- * define-function reads from the `x-tray-user-name` header. Only exposed
34
- * on `ctx.identity` when `userId` is also set.
35
- */
36
- userName?: string;
37
- /**
38
- * Deployment ID for the current invocation. Set via `setSdkConfig(...)` at
39
- * handler entry. Only meaningful in `lambda` mode; `dev` mode has no
40
- * deployment concept yet.
41
- */
42
- deploymentId?: string | null;
43
- /**
44
- * Running dev server's own base URL (e.g. `http://localhost:3000`). Set by
45
- * the CLI's `sdk-context` Nitro plugin in `dev` mode so `ctx.files()` can
46
- * build local signed URLs pointing at `/_helix/files/**`. Absent in `lambda`
47
- * mode — production signed URLs point at the platform API host instead.
48
- */
49
- devServerUrl?: string;
50
- /**
51
- * Absolute path to the project root in `dev` mode, set by the CLI's
52
- * `sdk-context` Nitro plugin. Used by `ctx.files()`'s local dev store to
53
- * resolve `.helix/files/` on disk. Absent in `lambda` mode.
54
- */
55
- projectRoot?: string;
56
- /**
57
- * The calling execution's id, set via `setSdkConfig(...)` only for a
58
- * function-call-triggered invocation (`ctx.callFunctionAsync`, SUR-929).
59
- * The shim explicitly clears this (passes `undefined`) on every other
60
- * invocation kind so a warm container never leaks a prior call's parentage.
61
- */
62
- parentExecutionId?: string | null;
63
- }
64
- interface BrokerSecrets {
65
- internalJwt?: string;
66
- helixExecutionJwt?: string;
67
- devToken?: string;
68
- }
69
- interface SdkConfigInput extends Partial<SdkRuntimeConfig>, BrokerSecrets {
70
- }
71
- declare function setSdkConfig(options: SdkConfigInput): void;
72
- declare function getSdkConfig(): Readonly<SdkRuntimeConfig>;
73
-
74
- declare const projectIdSchema: z.ZodString;
75
- declare const workspaceIdSchema: z.ZodString;
76
- /**
77
- * Agent session storage (helix-spec 14 → Sessions & Memory → Pluggable
78
- * Backend). v1 supports only the bring-your-own-DynamoDB backend — the
79
- * managed Helix session store does not exist yet, so `store: "dynamodb"` is
80
- * currently the only durable option (in-memory otherwise). The table is
81
- * accessed through the credentials broker with the named authentication's
82
- * AWS credentials; no keys in the runtime.
83
- */
84
- declare const agentSessionsSchema: z.ZodDiscriminatedUnion<"store", [z.ZodObject<{
85
- store: z.ZodLiteral<"managed">;
86
- }, "strip", z.ZodTypeAny, {
87
- store: "managed";
88
- }, {
89
- store: "managed";
90
- }>, z.ZodObject<{
91
- store: z.ZodLiteral<"dynamodb">;
92
- /** Authentication alias (from `authentications`) holding AWS credentials. */
93
- auth: z.ZodString;
94
- table: z.ZodString;
95
- region: z.ZodString;
96
- }, "strip", z.ZodTypeAny, {
97
- auth: string;
98
- store: "dynamodb";
99
- table: string;
100
- region: string;
101
- }, {
102
- auth: string;
103
- store: "dynamodb";
104
- table: string;
105
- region: string;
106
- }>]>;
107
- type AgentSessionsConfig = z.infer<typeof agentSessionsSchema>;
108
- /**
109
- * AI provider declaration (helix-spec 11). The Vercel AI SDK builds
110
- * provider-native requests client-side, so `ctx.ai(alias)` must know which
111
- * `@ai-sdk/*` package serves the alias BEFORE any request exists — and
112
- * platform authentications carry no service identifier, so the project
113
- * declares it here: `aiProviders: { <authAlias>: "<service>" }`. The
114
- * `openai-compatible` service (self-hosted vLLM, Ollama, …) additionally
115
- * needs the endpoint base URL, so it uses the object form. `bedrock` likewise
116
- * needs the object form: the provider package derives the regional runtime
117
- * endpoint (`bedrock-runtime.<region>.amazonaws.com`) from `region`, or takes
118
- * `baseUrl` verbatim for VPC / custom endpoints.
119
- *
120
- * `baseUrl` must be https: every `ctx.ai` request egresses through the
121
- * credentials broker's raw forward proxy, and `createBrokerFetch` rejects
122
- * non-https destinations unconditionally (no dev/local exception) — so an
123
- * http endpoint (a bare local Ollama/vLLM instance, say) would load fine here
124
- * and then fail on every request. Catching it in the schema turns that into
125
- * one clear config error instead of a confusing first-call failure.
126
- */
127
- declare const AI_SERVICES: readonly ["openai", "anthropic", "google", "mistral", "cohere", "bedrock", "openai-compatible"];
128
- type AiService = (typeof AI_SERVICES)[number];
129
- declare const aiProviderEntrySchema: z.ZodUnion<[z.ZodEnum<["openai", "anthropic", "google", "mistral", "cohere"]>, z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObject<{
130
- service: z.ZodEnum<["openai", "anthropic", "google", "mistral", "cohere", "bedrock", "openai-compatible"]>;
131
- baseUrl: z.ZodOptional<z.ZodString>;
132
- region: z.ZodOptional<z.ZodString>;
133
- }, "strip", z.ZodTypeAny, {
134
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
135
- region?: string | undefined;
136
- baseUrl?: string | undefined;
137
- }, {
138
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
139
- region?: string | undefined;
140
- baseUrl?: string | undefined;
141
- }>, {
142
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
143
- region?: string | undefined;
144
- baseUrl?: string | undefined;
145
- }, {
146
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
147
- region?: string | undefined;
148
- baseUrl?: string | undefined;
149
- }>, {
150
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
151
- region?: string | undefined;
152
- baseUrl?: string | undefined;
153
- }, {
154
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
155
- region?: string | undefined;
156
- baseUrl?: string | undefined;
157
- }>, {
158
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
159
- region?: string | undefined;
160
- baseUrl?: string | undefined;
161
- }, {
162
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
163
- region?: string | undefined;
164
- baseUrl?: string | undefined;
165
- }>, {
166
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
167
- region?: string | undefined;
168
- baseUrl?: string | undefined;
169
- }, {
170
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
171
- region?: string | undefined;
172
- baseUrl?: string | undefined;
173
- }>]>;
174
- type AiProviderEntry = z.infer<typeof aiProviderEntrySchema>;
175
- declare const trayConfigSchema: z.ZodEffects<z.ZodObject<{
176
- name: z.ZodString;
177
- projectId: z.ZodOptional<z.ZodString>;
178
- workspaceId: z.ZodOptional<z.ZodString>;
179
- region: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
180
- /**
181
- * @deprecated Renamed to `region` (SUR-1069). `env`'s only legal value,
182
- * pre-rename, was `"production"` (the sole environment before regions
183
- * existed) — which is exactly the same physical region as `region`'s
184
- * default, `"us1"`. So `env`'s value never needs translating: its mere
185
- * presence (validated below) is enough to keep old configs building;
186
- * the transform below defaults `region` to `"us1"` whether `env` was
187
- * `"production"` or simply absent. Kept for one release cycle.
188
- */
189
- env: z.ZodOptional<z.ZodLiteral<"production">>;
190
- authentications: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>>;
191
- config: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
192
- agentSessions: z.ZodOptional<z.ZodDiscriminatedUnion<"store", [z.ZodObject<{
193
- store: z.ZodLiteral<"managed">;
194
- }, "strip", z.ZodTypeAny, {
195
- store: "managed";
196
- }, {
197
- store: "managed";
198
- }>, z.ZodObject<{
199
- store: z.ZodLiteral<"dynamodb">;
200
- /** Authentication alias (from `authentications`) holding AWS credentials. */
201
- auth: z.ZodString;
202
- table: z.ZodString;
203
- region: z.ZodString;
204
- }, "strip", z.ZodTypeAny, {
205
- auth: string;
206
- store: "dynamodb";
207
- table: string;
208
- region: string;
209
- }, {
210
- auth: string;
211
- store: "dynamodb";
212
- table: string;
213
- region: string;
214
- }>]>>;
215
- aiProviders: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodEnum<["openai", "anthropic", "google", "mistral", "cohere"]>, z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObject<{
216
- service: z.ZodEnum<["openai", "anthropic", "google", "mistral", "cohere", "bedrock", "openai-compatible"]>;
217
- baseUrl: z.ZodOptional<z.ZodString>;
218
- region: z.ZodOptional<z.ZodString>;
219
- }, "strip", z.ZodTypeAny, {
220
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
221
- region?: string | undefined;
222
- baseUrl?: string | undefined;
223
- }, {
224
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
225
- region?: string | undefined;
226
- baseUrl?: string | undefined;
227
- }>, {
228
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
229
- region?: string | undefined;
230
- baseUrl?: string | undefined;
231
- }, {
232
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
233
- region?: string | undefined;
234
- baseUrl?: string | undefined;
235
- }>, {
236
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
237
- region?: string | undefined;
238
- baseUrl?: string | undefined;
239
- }, {
240
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
241
- region?: string | undefined;
242
- baseUrl?: string | undefined;
243
- }>, {
244
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
245
- region?: string | undefined;
246
- baseUrl?: string | undefined;
247
- }, {
248
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
249
- region?: string | undefined;
250
- baseUrl?: string | undefined;
251
- }>, {
252
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
253
- region?: string | undefined;
254
- baseUrl?: string | undefined;
255
- }, {
256
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
257
- region?: string | undefined;
258
- baseUrl?: string | undefined;
259
- }>]>>>;
260
- }, "strip", z.ZodTypeAny, {
261
- name: string;
262
- authentications: Record<string, string>;
263
- config: Record<string, unknown>;
264
- region?: string | undefined;
265
- projectId?: string | undefined;
266
- workspaceId?: string | undefined;
267
- env?: "production" | undefined;
268
- agentSessions?: {
269
- store: "managed";
270
- } | {
271
- auth: string;
272
- store: "dynamodb";
273
- table: string;
274
- region: string;
275
- } | undefined;
276
- aiProviders?: Record<string, "openai" | "anthropic" | "google" | "mistral" | "cohere" | {
277
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
278
- region?: string | undefined;
279
- baseUrl?: string | undefined;
280
- }> | undefined;
281
- }, {
282
- name: string;
283
- region?: string | undefined;
284
- projectId?: string | undefined;
285
- workspaceId?: string | undefined;
286
- env?: "production" | undefined;
287
- authentications?: Record<string, string> | undefined;
288
- config?: Record<string, unknown> | undefined;
289
- agentSessions?: {
290
- store: "managed";
291
- } | {
292
- auth: string;
293
- store: "dynamodb";
294
- table: string;
295
- region: string;
296
- } | undefined;
297
- aiProviders?: Record<string, "openai" | "anthropic" | "google" | "mistral" | "cohere" | {
298
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
299
- region?: string | undefined;
300
- baseUrl?: string | undefined;
301
- }> | undefined;
302
- }>, {
303
- region: string;
304
- name: string;
305
- authentications: Record<string, string>;
306
- config: Record<string, unknown>;
307
- projectId?: string | undefined;
308
- workspaceId?: string | undefined;
309
- agentSessions?: {
310
- store: "managed";
311
- } | {
312
- auth: string;
313
- store: "dynamodb";
314
- table: string;
315
- region: string;
316
- } | undefined;
317
- aiProviders?: Record<string, "openai" | "anthropic" | "google" | "mistral" | "cohere" | {
318
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
319
- region?: string | undefined;
320
- baseUrl?: string | undefined;
321
- }> | undefined;
322
- }, {
323
- name: string;
324
- region?: string | undefined;
325
- projectId?: string | undefined;
326
- workspaceId?: string | undefined;
327
- env?: "production" | undefined;
328
- authentications?: Record<string, string> | undefined;
329
- config?: Record<string, unknown> | undefined;
330
- agentSessions?: {
331
- store: "managed";
332
- } | {
333
- auth: string;
334
- store: "dynamodb";
335
- table: string;
336
- region: string;
337
- } | undefined;
338
- aiProviders?: Record<string, "openai" | "anthropic" | "google" | "mistral" | "cohere" | {
339
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
340
- region?: string | undefined;
341
- baseUrl?: string | undefined;
342
- }> | undefined;
343
- }>;
344
- /** User-facing config type — auth/config optional; Zod defaults fill at load time. */
345
- type TrayConfig = z.input<typeof trayConfigSchema>;
346
- /**
347
- * Runtime validator for the LoadedTrayConfig discriminated union.
348
- * Used to validate BroadcastChannel payloads before calling setActiveConfig —
349
- * prevents malformed cross-channel data from corrupting the worker-local
350
- * config slot.
351
- */
352
- declare const loadedTrayConfigSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
353
- name: z.ZodString;
354
- workspaceId: z.ZodOptional<z.ZodString>;
355
- region: z.ZodEffects<z.ZodString, string, string>;
356
- authentications: z.ZodRecord<z.ZodString, z.ZodString>;
357
- config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
358
- agentSessions: z.ZodOptional<z.ZodDiscriminatedUnion<"store", [z.ZodObject<{
359
- store: z.ZodLiteral<"managed">;
360
- }, "strip", z.ZodTypeAny, {
361
- store: "managed";
362
- }, {
363
- store: "managed";
364
- }>, z.ZodObject<{
365
- store: z.ZodLiteral<"dynamodb">;
366
- /** Authentication alias (from `authentications`) holding AWS credentials. */
367
- auth: z.ZodString;
368
- table: z.ZodString;
369
- region: z.ZodString;
370
- }, "strip", z.ZodTypeAny, {
371
- auth: string;
372
- store: "dynamodb";
373
- table: string;
374
- region: string;
375
- }, {
376
- auth: string;
377
- store: "dynamodb";
378
- table: string;
379
- region: string;
380
- }>]>>;
381
- aiProviders: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodEnum<["openai", "anthropic", "google", "mistral", "cohere"]>, z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObject<{
382
- service: z.ZodEnum<["openai", "anthropic", "google", "mistral", "cohere", "bedrock", "openai-compatible"]>;
383
- baseUrl: z.ZodOptional<z.ZodString>;
384
- region: z.ZodOptional<z.ZodString>;
385
- }, "strip", z.ZodTypeAny, {
386
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
387
- region?: string | undefined;
388
- baseUrl?: string | undefined;
389
- }, {
390
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
391
- region?: string | undefined;
392
- baseUrl?: string | undefined;
393
- }>, {
394
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
395
- region?: string | undefined;
396
- baseUrl?: string | undefined;
397
- }, {
398
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
399
- region?: string | undefined;
400
- baseUrl?: string | undefined;
401
- }>, {
402
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
403
- region?: string | undefined;
404
- baseUrl?: string | undefined;
405
- }, {
406
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
407
- region?: string | undefined;
408
- baseUrl?: string | undefined;
409
- }>, {
410
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
411
- region?: string | undefined;
412
- baseUrl?: string | undefined;
413
- }, {
414
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
415
- region?: string | undefined;
416
- baseUrl?: string | undefined;
417
- }>, {
418
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
419
- region?: string | undefined;
420
- baseUrl?: string | undefined;
421
- }, {
422
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
423
- region?: string | undefined;
424
- baseUrl?: string | undefined;
425
- }>]>>>;
426
- } & {
427
- kind: z.ZodLiteral<"provisioned">;
428
- projectId: z.ZodString;
429
- }, "strip", z.ZodTypeAny, {
430
- kind: "provisioned";
431
- region: string;
432
- name: string;
433
- projectId: string;
434
- authentications: Record<string, string>;
435
- config: Record<string, unknown>;
436
- workspaceId?: string | undefined;
437
- agentSessions?: {
438
- store: "managed";
439
- } | {
440
- auth: string;
441
- store: "dynamodb";
442
- table: string;
443
- region: string;
444
- } | undefined;
445
- aiProviders?: Record<string, "openai" | "anthropic" | "google" | "mistral" | "cohere" | {
446
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
447
- region?: string | undefined;
448
- baseUrl?: string | undefined;
449
- }> | undefined;
450
- }, {
451
- kind: "provisioned";
452
- region: string;
453
- name: string;
454
- projectId: string;
455
- authentications: Record<string, string>;
456
- config: Record<string, unknown>;
457
- workspaceId?: string | undefined;
458
- agentSessions?: {
459
- store: "managed";
460
- } | {
461
- auth: string;
462
- store: "dynamodb";
463
- table: string;
464
- region: string;
465
- } | undefined;
466
- aiProviders?: Record<string, "openai" | "anthropic" | "google" | "mistral" | "cohere" | {
467
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
468
- region?: string | undefined;
469
- baseUrl?: string | undefined;
470
- }> | undefined;
471
- }>, z.ZodObject<{
472
- name: z.ZodString;
473
- workspaceId: z.ZodOptional<z.ZodString>;
474
- region: z.ZodEffects<z.ZodString, string, string>;
475
- authentications: z.ZodRecord<z.ZodString, z.ZodString>;
476
- config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
477
- agentSessions: z.ZodOptional<z.ZodDiscriminatedUnion<"store", [z.ZodObject<{
478
- store: z.ZodLiteral<"managed">;
479
- }, "strip", z.ZodTypeAny, {
480
- store: "managed";
481
- }, {
482
- store: "managed";
483
- }>, z.ZodObject<{
484
- store: z.ZodLiteral<"dynamodb">;
485
- /** Authentication alias (from `authentications`) holding AWS credentials. */
486
- auth: z.ZodString;
487
- table: z.ZodString;
488
- region: z.ZodString;
489
- }, "strip", z.ZodTypeAny, {
490
- auth: string;
491
- store: "dynamodb";
492
- table: string;
493
- region: string;
494
- }, {
495
- auth: string;
496
- store: "dynamodb";
497
- table: string;
498
- region: string;
499
- }>]>>;
500
- aiProviders: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodEnum<["openai", "anthropic", "google", "mistral", "cohere"]>, z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObject<{
501
- service: z.ZodEnum<["openai", "anthropic", "google", "mistral", "cohere", "bedrock", "openai-compatible"]>;
502
- baseUrl: z.ZodOptional<z.ZodString>;
503
- region: z.ZodOptional<z.ZodString>;
504
- }, "strip", z.ZodTypeAny, {
505
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
506
- region?: string | undefined;
507
- baseUrl?: string | undefined;
508
- }, {
509
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
510
- region?: string | undefined;
511
- baseUrl?: string | undefined;
512
- }>, {
513
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
514
- region?: string | undefined;
515
- baseUrl?: string | undefined;
516
- }, {
517
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
518
- region?: string | undefined;
519
- baseUrl?: string | undefined;
520
- }>, {
521
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
522
- region?: string | undefined;
523
- baseUrl?: string | undefined;
524
- }, {
525
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
526
- region?: string | undefined;
527
- baseUrl?: string | undefined;
528
- }>, {
529
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
530
- region?: string | undefined;
531
- baseUrl?: string | undefined;
532
- }, {
533
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
534
- region?: string | undefined;
535
- baseUrl?: string | undefined;
536
- }>, {
537
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
538
- region?: string | undefined;
539
- baseUrl?: string | undefined;
540
- }, {
541
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
542
- region?: string | undefined;
543
- baseUrl?: string | undefined;
544
- }>]>>>;
545
- } & {
546
- kind: z.ZodLiteral<"unprovisioned">;
547
- }, "strip", z.ZodTypeAny, {
548
- kind: "unprovisioned";
549
- region: string;
550
- name: string;
551
- authentications: Record<string, string>;
552
- config: Record<string, unknown>;
553
- workspaceId?: string | undefined;
554
- agentSessions?: {
555
- store: "managed";
556
- } | {
557
- auth: string;
558
- store: "dynamodb";
559
- table: string;
560
- region: string;
561
- } | undefined;
562
- aiProviders?: Record<string, "openai" | "anthropic" | "google" | "mistral" | "cohere" | {
563
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
564
- region?: string | undefined;
565
- baseUrl?: string | undefined;
566
- }> | undefined;
567
- }, {
568
- kind: "unprovisioned";
569
- region: string;
570
- name: string;
571
- authentications: Record<string, string>;
572
- config: Record<string, unknown>;
573
- workspaceId?: string | undefined;
574
- agentSessions?: {
575
- store: "managed";
576
- } | {
577
- auth: string;
578
- store: "dynamodb";
579
- table: string;
580
- region: string;
581
- } | undefined;
582
- aiProviders?: Record<string, "openai" | "anthropic" | "google" | "mistral" | "cohere" | {
583
- service: "openai" | "anthropic" | "google" | "mistral" | "cohere" | "bedrock" | "openai-compatible";
584
- region?: string | undefined;
585
- baseUrl?: string | undefined;
586
- }> | undefined;
587
- }>]>;
588
- /** Base fields on all config variants — schema output minus projectId. */
589
- type LoadedTrayConfigBase = Omit<z.output<typeof trayConfigSchema>, "projectId">;
590
- /**
591
- * Discriminated union returned by loadConfig / ConfigService#get.
592
- * - "provisioned" — projectId present, no optional-chaining needed.
593
- * - "unprovisioned" — `projectId?: never` structurally excludes it.
594
- * workspaceId is optional on both variants — independent of provisioning.
595
- */
596
- type LoadedTrayConfig = ({
597
- kind: "provisioned";
598
- projectId: string;
599
- } & LoadedTrayConfigBase) | ({
600
- kind: "unprovisioned";
601
- projectId?: never;
602
- } & LoadedTrayConfigBase);
603
- type ProvisionedTrayConfig = Extract<LoadedTrayConfig, {
604
- kind: "provisioned";
605
- }>;
606
- type UnprovisionedTrayConfig = Extract<LoadedTrayConfig, {
607
- kind: "unprovisioned";
608
- }>;
609
- /**
610
- * Env var naming an alternate config file (relative paths resolve against cwd).
611
- * Sits between the explicit `configFile` option (the CLI's `--config` flag) and
612
- * the `helix.config.ts` default in resolution precedence.
613
- */
614
- declare const HELIX_CONFIG_ENV = "HELIX_CONFIG";
615
- /** Options accepted by every config entry point that resolves the config file. */
616
- interface ConfigFileOptions {
617
- /**
618
- * Explicit config file path (the CLI's `--config` flag). Resolution
619
- * precedence: this option → `HELIX_CONFIG` env var → `helix.config.ts`
620
- * (then legacy `tray.config.*`) in cwd.
621
- */
622
- configFile?: string;
623
- }
624
- /**
625
- * The effective config-file override, if any: the explicit `configFile` option
626
- * (CLI `--config` flag) wins over the `HELIX_CONFIG` env var. Returns the raw
627
- * (possibly relative) path — callers resolve it against their cwd.
628
- */
629
- declare function resolveConfigOverride(configFile?: string): string | undefined;
630
- /**
631
- * Absolute path of the project config file in `cwd`, preferring `helix.config.*`
632
- * and falling back to a legacy `tray.config.*`. Returns undefined when neither exists.
633
- * A config-file override (option or HELIX_CONFIG) replaces the default search
634
- * entirely: only the named file is considered.
635
- */
636
- declare function resolveConfigFile(cwd: string, options?: ConfigFileOptions): string | undefined;
637
- /**
638
- * One-shot stateless read of the project config. NO caching — every call hits disk.
639
- * Reads `helix.config.ts` (legacy `tray.config.*` fallback) unless an override
640
- * names another file — `options.configFile` (CLI `--config` flag) first, then
641
- * the `HELIX_CONFIG` env var. For hot-reload or stable snapshot, use
642
- * {@link createConfigService} instead.
643
- */
644
- declare function loadConfig(cwd?: string, options?: ConfigFileOptions): Promise<LoadedTrayConfig>;
645
- /** Phase that surfaced an error inside ConfigService watcher. */
646
- type WatchErrorPhase = "attach" | "reload" | "validation";
647
- /** Stable code on errors thrown by {@link requireWorkspaceId}. Narrow by this, not instanceof. */
648
- declare const WORKSPACE_ID_REQUIRED_CODE: "WORKSPACE_ID_REQUIRED";
649
- /**
650
- * Shape of errors thrown by {@link requireWorkspaceId}.
651
- * Type alias — no class hierarchy; callers narrow via `error.code === WORKSPACE_ID_REQUIRED_CODE`.
652
- *
653
- * The thrown message references CLI (`helix workspace select` / `helix workspace set`)
654
- * and MCP (`tray_list_workspaces` / `tray_set_workspace_id`) commands — keep those
655
- * names in sync with the message literal in requireWorkspaceId.
656
- */
657
- type WorkspaceIdRequiredError = Error & {
658
- readonly code: typeof WORKSPACE_ID_REQUIRED_CODE;
659
- };
660
- /**
661
- * Returns workspaceId from config, or throws a plain Error with code WORKSPACE_ID_REQUIRED.
662
- * Pure, no I/O. workspaceId is independent of provisioning state.
663
- */
664
- declare function requireWorkspaceId(config: LoadedTrayConfig): string;
665
-
666
- /**
667
- * `defineTool` (helix-spec 12) — the subset agents consume (helix-spec 14).
668
- *
669
- * A tool is a *definition*: name, description, input schema, approval policy,
670
- * and handler together in one default export. Tools are:
671
- *
672
- * - invoked **in-process** by importing the definition and calling it — the
673
- * handler runs inside the current execution with the caller's context (via
674
- * getContext()), input validated against the schema;
675
- * - given to agents via `defineAgent({ tools: [...] })`, where the agent
676
- * runtime compiles them to AI SDK tools (the same validation + handler,
677
- * `needsApproval` compiled to the loop's native approval mechanism).
678
- *
679
- * MCP exposure (spec 12's `mcp.tools`) is not built yet — tools exist today
680
- * for in-process use and agents.
681
- */
682
- declare const TOOL_DEFINITION_KIND = "helix-tool";
683
- interface DefineToolConfig<TSchema extends ZodType = ZodType> {
684
- /** Tool name (snake_case convention). */
685
- name: string;
686
- /** Human-readable description for AI agents. */
687
- description: string;
688
- /** Input schema (Zod), validated before the handler runs. */
689
- input: TSchema;
690
- /**
691
- * Require human approval before an agent may execute this tool — boolean,
692
- * or an (optionally async) predicate of the validated input. Enforced in
693
- * agent loops (the loop pauses; see ctx.agent). Direct in-process
694
- * invocation is not gated — calling the tool yourself is the confirmation.
695
- */
696
- needsApproval?: boolean | ((input: z.infer<TSchema>) => boolean | Promise<boolean>);
697
- /** Handler — receives the caller's ctx with `input` validated and typed. */
698
- handler: (ctx: PlatformContext & {
699
- input: z.infer<TSchema>;
700
- }) => Promise<unknown> | unknown;
701
- }
702
- interface HelixTool<TSchema extends ZodType = ZodType> {
703
- /** In-process invocation: validate input, run handler with the caller's ctx. */
704
- (input: z.infer<TSchema>): Promise<unknown>;
705
- readonly kind: typeof TOOL_DEFINITION_KIND;
706
- readonly name: string;
707
- readonly description: string;
708
- readonly inputSchema: TSchema;
709
- readonly needsApproval?: DefineToolConfig<TSchema>["needsApproval"];
710
- /** Validate + execute with an explicit ctx (used by the agent runtime). */
711
- readonly execute: (input: unknown, ctx: PlatformContext) => Promise<unknown>;
712
- }
713
- /**
714
- * Type-erased view of a tool definition — what agent definitions accept.
715
- * (HelixTool<TSchema> is invariant in its schema because of the callable's
716
- * input position; this structural view is what `tools: [...]` is typed as.)
717
- */
718
- interface HelixToolLike {
719
- readonly kind: typeof TOOL_DEFINITION_KIND;
720
- readonly name: string;
721
- readonly description: string;
722
- readonly inputSchema: ZodType;
723
- readonly needsApproval?: boolean | ((input: never) => boolean | Promise<boolean>);
724
- readonly execute: (input: unknown, ctx: PlatformContext) => Promise<unknown>;
725
- }
726
- /**
727
- * Define a tool an agent can call (or that your code can invoke in-process).
728
- */
729
- declare function defineTool<TSchema extends ZodType>(config: DefineToolConfig<TSchema>): HelixTool<TSchema>;
730
- /** Structural check for defineTool output — see TOOL_DEFINITION_KIND. */
731
- declare function isToolDefinition(value: unknown): value is HelixTool;
732
-
733
- /**
734
- * `defineAgent` (helix-spec 14) — one file per agent under
735
- * `functions/_agents/`, definitions in code, the file system as the source of
736
- * truth.
737
- *
738
- * Like `defineSchedule`, the SDK owns the definition + runtime and the
739
- * host (dev server, lambda router) owns discovery: importing the module
740
- * registers the agent by name.
741
- *
742
- * v1 deviations from the spec, both enforced with clear errors:
743
- * - `name` is required (filename defaulting needs build-time discovery, which
744
- * arrives with the deploy-side scan);
745
- * - `instructionsFile` resolution requires the host to record the agent
746
- * file's directory (the dev server does; direct imports in tests should use
747
- * inline `instructions`).
748
- */
749
- declare const AGENT_DEFINITION_KIND = "helix-agent";
750
- declare const agentConfigSchema: z.ZodEffects<z.ZodObject<{
751
- name: z.ZodString;
752
- description: z.ZodString;
753
- model: z.ZodString;
754
- auth: z.ZodString;
755
- fallbacks: z.ZodOptional<z.ZodArray<z.ZodObject<{
756
- model: z.ZodString;
757
- auth: z.ZodString;
758
- }, "strip", z.ZodTypeAny, {
759
- auth: string;
760
- model: string;
761
- }, {
762
- auth: string;
763
- model: string;
764
- }>, "many">>;
765
- instructions: z.ZodOptional<z.ZodString>;
766
- instructionsFile: z.ZodOptional<z.ZodString>;
767
- tools: z.ZodOptional<z.ZodArray<z.ZodType<HelixToolLike, z.ZodTypeDef, HelixToolLike>, "many">>;
768
- agents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
769
- memory: z.ZodOptional<z.ZodObject<{
770
- /**
771
- * Cap on the messages the MODEL is sent each turn (default 200) — the
772
- * latest stretch of the conversation, always starting on a user
773
- * message so no turn is cut in half. It does not limit what is
774
- * stored: the session keeps the whole conversation.
775
- */
776
- maxSessionMessages: z.ZodOptional<z.ZodNumber>;
777
- /**
778
- * Opt-in idle retention, in seconds: a session untouched for this
779
- * long expires. Omitted (the default) = sessions never expire, so a
780
- * user can always return to an earlier conversation.
781
- */
782
- ttl: z.ZodOptional<z.ZodNumber>;
783
- /**
784
- * `"user"` declares the agent is executed BY a user: sessions are
785
- * keyed by (and only visible to) the `ctx.userId` of the invoking
786
- * execution, and `agent.sessions()` lists the calling user's recent
787
- * sessions. Invoking a user-scoped agent without a user identity
788
- * (schedules) is a caller error. Default `"project"`: sessions are
789
- * shared across the project's executions.
790
- */
791
- scope: z.ZodOptional<z.ZodEnum<["user", "project"]>>;
792
- }, "strip", z.ZodTypeAny, {
793
- scope?: "user" | "project" | undefined;
794
- ttl?: number | undefined;
795
- maxSessionMessages?: number | undefined;
796
- }, {
797
- scope?: "user" | "project" | undefined;
798
- ttl?: number | undefined;
799
- maxSessionMessages?: number | undefined;
800
- }>>;
801
- limits: z.ZodOptional<z.ZodObject<{
802
- maxIterations: z.ZodOptional<z.ZodNumber>;
803
- maxToolCalls: z.ZodOptional<z.ZodNumber>;
804
- }, "strip", z.ZodTypeAny, {
805
- maxIterations?: number | undefined;
806
- maxToolCalls?: number | undefined;
807
- }, {
808
- maxIterations?: number | undefined;
809
- maxToolCalls?: number | undefined;
810
- }>>;
811
- }, "strip", z.ZodTypeAny, {
812
- auth: string;
813
- name: string;
814
- model: string;
815
- description: string;
816
- instructions?: string | undefined;
817
- tools?: HelixToolLike[] | undefined;
818
- fallbacks?: {
819
- auth: string;
820
- model: string;
821
- }[] | undefined;
822
- instructionsFile?: string | undefined;
823
- agents?: string[] | undefined;
824
- memory?: {
825
- scope?: "user" | "project" | undefined;
826
- ttl?: number | undefined;
827
- maxSessionMessages?: number | undefined;
828
- } | undefined;
829
- limits?: {
830
- maxIterations?: number | undefined;
831
- maxToolCalls?: number | undefined;
832
- } | undefined;
833
- }, {
834
- auth: string;
835
- name: string;
836
- model: string;
837
- description: string;
838
- instructions?: string | undefined;
839
- tools?: HelixToolLike[] | undefined;
840
- fallbacks?: {
841
- auth: string;
842
- model: string;
843
- }[] | undefined;
844
- instructionsFile?: string | undefined;
845
- agents?: string[] | undefined;
846
- memory?: {
847
- scope?: "user" | "project" | undefined;
848
- ttl?: number | undefined;
849
- maxSessionMessages?: number | undefined;
850
- } | undefined;
851
- limits?: {
852
- maxIterations?: number | undefined;
853
- maxToolCalls?: number | undefined;
854
- } | undefined;
855
- }>, {
856
- auth: string;
857
- name: string;
858
- model: string;
859
- description: string;
860
- instructions?: string | undefined;
861
- tools?: HelixToolLike[] | undefined;
862
- fallbacks?: {
863
- auth: string;
864
- model: string;
865
- }[] | undefined;
866
- instructionsFile?: string | undefined;
867
- agents?: string[] | undefined;
868
- memory?: {
869
- scope?: "user" | "project" | undefined;
870
- ttl?: number | undefined;
871
- maxSessionMessages?: number | undefined;
872
- } | undefined;
873
- limits?: {
874
- maxIterations?: number | undefined;
875
- maxToolCalls?: number | undefined;
876
- } | undefined;
877
- }, {
878
- auth: string;
879
- name: string;
880
- model: string;
881
- description: string;
882
- instructions?: string | undefined;
883
- tools?: HelixToolLike[] | undefined;
884
- fallbacks?: {
885
- auth: string;
886
- model: string;
887
- }[] | undefined;
888
- instructionsFile?: string | undefined;
889
- agents?: string[] | undefined;
890
- memory?: {
891
- scope?: "user" | "project" | undefined;
892
- ttl?: number | undefined;
893
- maxSessionMessages?: number | undefined;
894
- } | undefined;
895
- limits?: {
896
- maxIterations?: number | undefined;
897
- maxToolCalls?: number | undefined;
898
- } | undefined;
899
- }>;
900
- type AgentDefinitionConfig = z.input<typeof agentConfigSchema>;
901
- interface AgentDefinition extends z.output<typeof agentConfigSchema> {
902
- kind: typeof AGENT_DEFINITION_KIND;
903
- }
904
- /**
905
- * Define an agent (default export of a file under `functions/_agents/`).
906
- */
907
- declare function defineAgent(config: AgentDefinitionConfig): AgentDefinition;
908
- /** Structural check for defineAgent output — see AGENT_DEFINITION_KIND. */
909
- declare function isAgentDefinition(value: unknown): value is AgentDefinition;
910
-
911
- export { AGENT_DEFINITION_KIND as A, setSdkConfig as B, type ConfigFileOptions as C, type DefineToolConfig as D, HELIX_CONFIG_ENV as H, type LoadedTrayConfig as L, type ProvisionedTrayConfig as P, type SdkRuntimeConfig as S, type TrayConfig as T, type UnprovisionedTrayConfig as U, type WatchErrorPhase as W, AI_SERVICES as a, type AgentDefinition as b, type AgentDefinitionConfig as c, type AgentSessionsConfig as d, type AiProviderEntry as e, type AiService as f, type HelixTool as g, type HelixToolLike as h, TOOL_DEFINITION_KIND as i, WORKSPACE_ID_REQUIRED_CODE as j, type WorkspaceIdRequiredError as k, agentSessionsSchema as l, aiProviderEntrySchema as m, defineAgent as n, defineTool as o, getSdkConfig as p, isAgentDefinition as q, isToolDefinition as r, loadConfig as s, loadedTrayConfigSchema as t, projectIdSchema as u, requireWorkspaceId as v, resolveConfigFile as w, resolveConfigOverride as x, workspaceIdSchema as y, type SdkConfigInput as z };