lua-cli 3.42.0 → 3.44.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/dist/api-exports.d.ts +117 -25
- package/dist/api-exports.js +129 -8
- package/dist/api-exports.js.map +1 -1
- package/dist/index.js +420 -169
- package/dist/index.js.map +1 -1
- package/dist/voice/test/index.d.ts +18 -18
- package/dist/workflow-builder.d.ts +4 -1
- package/dist/workflow-builder.js.map +1 -1
- package/docs/README.md +2 -2
- package/docs/api/Agents.md +7 -0
- package/docs/api/LuaJob.md +117 -87
- package/docs/api/PostProcessor.md +73 -42
- package/docs/api/User.md +104 -74
- package/docs/workflows/workspaces-and-long-steps.md +1 -1
- package/package.json +4 -4
- package/template/examples/postprocessors/modifyResponse.ts +4 -3
- package/template/package.json +1 -1
package/dist/api-exports.d.ts
CHANGED
|
@@ -809,9 +809,14 @@ export declare interface AgentsApi {
|
|
|
809
809
|
size?: number;
|
|
810
810
|
}[];
|
|
811
811
|
}>;
|
|
812
|
+
/**
|
|
813
|
+
* The file's text. A file that is not valid UTF-8 (an image, an archive) comes back base64 with
|
|
814
|
+
* `encoding: 'base64'` — never decoded as text. Absent `encoding` ⇒ `content` is the UTF-8 text.
|
|
815
|
+
*/
|
|
812
816
|
get(path: string): Promise<{
|
|
813
817
|
path: string;
|
|
814
818
|
content: string;
|
|
819
|
+
encoding?: 'base64';
|
|
815
820
|
}>;
|
|
816
821
|
};
|
|
817
822
|
/** Environment variable NAMES only — values are never returned (`supervision:observe`). */
|
|
@@ -1251,6 +1256,27 @@ export declare interface AiApi {
|
|
|
1251
1256
|
* ```
|
|
1252
1257
|
*/
|
|
1253
1258
|
generate(options: AiGenerateInput): Promise<AiGenerateOutput>;
|
|
1259
|
+
/**
|
|
1260
|
+
* Generate ONE image from a prompt and return its hosted CDN url. The image sibling of `generate`:
|
|
1261
|
+
* proxied to the API (server-side provider + CDN upload + org billing), not the agent chat pipeline.
|
|
1262
|
+
* Returns a public `https://cdn.heylua.ai/…` url ready to embed (e.g. in a deck or a message).
|
|
1263
|
+
*
|
|
1264
|
+
* @example
|
|
1265
|
+
* ```typescript
|
|
1266
|
+
* const url = await AI.image('A sunrise over a calm sea, minimal, no text');
|
|
1267
|
+
* const wide = await AI.image('A clean product hero shot', { size: '1536x1024', quality: 'high' });
|
|
1268
|
+
* ```
|
|
1269
|
+
*/
|
|
1270
|
+
image(prompt: string, options?: Omit<AiImageInput, 'prompt'>): Promise<string>;
|
|
1271
|
+
/**
|
|
1272
|
+
* Generate one image with full options. Returns the full `{ url, model, provider }`.
|
|
1273
|
+
*
|
|
1274
|
+
* @example
|
|
1275
|
+
* ```typescript
|
|
1276
|
+
* const { url, model } = await AI.image({ prompt: 'A minimal abstract cover', size: '1536x1024' });
|
|
1277
|
+
* ```
|
|
1278
|
+
*/
|
|
1279
|
+
image(options: AiImageInput): Promise<AiImageOutput>;
|
|
1254
1280
|
}
|
|
1255
1281
|
|
|
1256
1282
|
/**
|
|
@@ -1392,6 +1418,34 @@ export declare interface AiGenerateToolResult {
|
|
|
1392
1418
|
isError?: boolean;
|
|
1393
1419
|
}
|
|
1394
1420
|
|
|
1421
|
+
/**
|
|
1422
|
+
* Wire-format types for sandbox `AI.image` / `POST developer/ai/:agentId/image` (JSON-serializable).
|
|
1423
|
+
* The image sibling of `AI.generate`: generates ONE image from a prompt, hosts it on the CDN, bills the
|
|
1424
|
+
* agent's org, and returns the public URL. Not the agent chat pipeline. DTOs live in `@lua/shared-dto`.
|
|
1425
|
+
*/
|
|
1426
|
+
declare interface AiImageInput {
|
|
1427
|
+
/** Plain-language description of the image to draw (3–4000 chars). */
|
|
1428
|
+
prompt: string;
|
|
1429
|
+
/** Provider-prefixed image model, e.g. "openai/gpt-image-2". Defaults to the agent/platform image model. */
|
|
1430
|
+
model?: string;
|
|
1431
|
+
/** Image size, e.g. "1024x1024", "1536x1024", "1024x1536" (provider-dependent). */
|
|
1432
|
+
size?: string;
|
|
1433
|
+
/** Render quality. */
|
|
1434
|
+
quality?: 'low' | 'medium' | 'high';
|
|
1435
|
+
/** Output image format. */
|
|
1436
|
+
outputFormat?: 'png' | 'jpeg' | 'webp';
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
/** Result from the image-generation surface. `url` is a public, hosted CDN link. */
|
|
1440
|
+
declare interface AiImageOutput {
|
|
1441
|
+
/** Public CDN URL of the generated image. */
|
|
1442
|
+
url: string;
|
|
1443
|
+
/** The model that produced the image. */
|
|
1444
|
+
model: string;
|
|
1445
|
+
/** The provider that produced the image. */
|
|
1446
|
+
provider: string;
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1395
1449
|
export declare const and: (...args: LuaPredicate[]) => LuaPredicate;
|
|
1396
1450
|
|
|
1397
1451
|
/**
|
|
@@ -3657,6 +3711,12 @@ declare abstract class HttpClient {
|
|
|
3657
3711
|
* @private
|
|
3658
3712
|
*/
|
|
3659
3713
|
private request;
|
|
3714
|
+
/**
|
|
3715
|
+
* A backoff wait the caller's signal can cut short (BAC-1097): resolves at `ms` or on abort, whichever is
|
|
3716
|
+
* first, and never leaves the timer or the listener behind. The caller re-checks `signal.aborted` afterwards.
|
|
3717
|
+
* @private
|
|
3718
|
+
*/
|
|
3719
|
+
private sleep;
|
|
3660
3720
|
/**
|
|
3661
3721
|
* Non-2xx classification shared by `request` and `httpStream` (WF-204): 401s become
|
|
3662
3722
|
* `AuthenticationError` (ownership vs credential), 403s throw, everything else returns the
|
|
@@ -5799,14 +5859,14 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
5799
5859
|
*/
|
|
5800
5860
|
options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
5801
5861
|
}, "strip", z.ZodTypeAny, {
|
|
5802
|
-
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
5803
5862
|
kind?: "plugin";
|
|
5804
5863
|
provider?: "deepgram" | "elevenlabs";
|
|
5864
|
+
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
5805
5865
|
options?: Record<string, unknown>;
|
|
5806
5866
|
}, {
|
|
5807
|
-
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
5808
5867
|
kind?: "plugin";
|
|
5809
5868
|
provider?: "deepgram" | "elevenlabs";
|
|
5869
|
+
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
5810
5870
|
options?: Record<string, unknown>;
|
|
5811
5871
|
}>, z.ZodObject<{
|
|
5812
5872
|
kind: z.ZodLiteral<"realtime">;
|
|
@@ -5865,14 +5925,14 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
5865
5925
|
*/
|
|
5866
5926
|
options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
5867
5927
|
}, "strip", z.ZodTypeAny, {
|
|
5868
|
-
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
5869
5928
|
kind?: "plugin";
|
|
5870
5929
|
provider?: "deepgram" | "elevenlabs";
|
|
5930
|
+
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
5871
5931
|
options?: Record<string, unknown>;
|
|
5872
5932
|
}, {
|
|
5873
|
-
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
5874
5933
|
kind?: "plugin";
|
|
5875
5934
|
provider?: "deepgram" | "elevenlabs";
|
|
5935
|
+
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
5876
5936
|
options?: Record<string, unknown>;
|
|
5877
5937
|
}>, z.ZodObject<{
|
|
5878
5938
|
kind: z.ZodLiteral<"realtime">;
|
|
@@ -5931,14 +5991,14 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
5931
5991
|
*/
|
|
5932
5992
|
options: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
5933
5993
|
}, "strip", z.ZodTypeAny, {
|
|
5934
|
-
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
5935
5994
|
kind?: "plugin";
|
|
5936
5995
|
provider?: "deepgram" | "elevenlabs";
|
|
5996
|
+
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
5937
5997
|
options?: Record<string, unknown>;
|
|
5938
5998
|
}, {
|
|
5939
|
-
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
5940
5999
|
kind?: "plugin";
|
|
5941
6000
|
provider?: "deepgram" | "elevenlabs";
|
|
6001
|
+
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
5942
6002
|
options?: Record<string, unknown>;
|
|
5943
6003
|
}>, z.ZodObject<{
|
|
5944
6004
|
kind: z.ZodLiteral<"realtime">;
|
|
@@ -6123,9 +6183,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
6123
6183
|
model?: string;
|
|
6124
6184
|
options?: Record<string, unknown>;
|
|
6125
6185
|
} | {
|
|
6126
|
-
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6127
6186
|
kind?: "plugin";
|
|
6128
6187
|
provider?: "deepgram" | "elevenlabs";
|
|
6188
|
+
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6129
6189
|
options?: Record<string, unknown>;
|
|
6130
6190
|
} | {
|
|
6131
6191
|
kind?: "realtime";
|
|
@@ -6139,9 +6199,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
6139
6199
|
model?: string;
|
|
6140
6200
|
options?: Record<string, unknown>;
|
|
6141
6201
|
} | {
|
|
6142
|
-
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6143
6202
|
kind?: "plugin";
|
|
6144
6203
|
provider?: "deepgram" | "elevenlabs";
|
|
6204
|
+
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6145
6205
|
options?: Record<string, unknown>;
|
|
6146
6206
|
} | {
|
|
6147
6207
|
kind?: "realtime";
|
|
@@ -6154,9 +6214,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
6154
6214
|
model?: string;
|
|
6155
6215
|
options?: Record<string, unknown>;
|
|
6156
6216
|
} | {
|
|
6157
|
-
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6158
6217
|
kind?: "plugin";
|
|
6159
6218
|
provider?: "deepgram" | "elevenlabs";
|
|
6219
|
+
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6160
6220
|
options?: Record<string, unknown>;
|
|
6161
6221
|
} | {
|
|
6162
6222
|
kind?: "realtime";
|
|
@@ -6217,9 +6277,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
6217
6277
|
model?: string;
|
|
6218
6278
|
options?: Record<string, unknown>;
|
|
6219
6279
|
} | {
|
|
6220
|
-
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6221
6280
|
kind?: "plugin";
|
|
6222
6281
|
provider?: "deepgram" | "elevenlabs";
|
|
6282
|
+
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6223
6283
|
options?: Record<string, unknown>;
|
|
6224
6284
|
} | {
|
|
6225
6285
|
kind?: "realtime";
|
|
@@ -6233,9 +6293,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
6233
6293
|
model?: string;
|
|
6234
6294
|
options?: Record<string, unknown>;
|
|
6235
6295
|
} | {
|
|
6236
|
-
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6237
6296
|
kind?: "plugin";
|
|
6238
6297
|
provider?: "deepgram" | "elevenlabs";
|
|
6298
|
+
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6239
6299
|
options?: Record<string, unknown>;
|
|
6240
6300
|
} | {
|
|
6241
6301
|
kind?: "realtime";
|
|
@@ -6248,9 +6308,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
6248
6308
|
model?: string;
|
|
6249
6309
|
options?: Record<string, unknown>;
|
|
6250
6310
|
} | {
|
|
6251
|
-
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6252
6311
|
kind?: "plugin";
|
|
6253
6312
|
provider?: "deepgram" | "elevenlabs";
|
|
6313
|
+
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6254
6314
|
options?: Record<string, unknown>;
|
|
6255
6315
|
} | {
|
|
6256
6316
|
kind?: "realtime";
|
|
@@ -6311,9 +6371,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
6311
6371
|
model?: string;
|
|
6312
6372
|
options?: Record<string, unknown>;
|
|
6313
6373
|
} | {
|
|
6314
|
-
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6315
6374
|
kind?: "plugin";
|
|
6316
6375
|
provider?: "deepgram" | "elevenlabs";
|
|
6376
|
+
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6317
6377
|
options?: Record<string, unknown>;
|
|
6318
6378
|
} | {
|
|
6319
6379
|
kind?: "realtime";
|
|
@@ -6327,9 +6387,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
6327
6387
|
model?: string;
|
|
6328
6388
|
options?: Record<string, unknown>;
|
|
6329
6389
|
} | {
|
|
6330
|
-
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6331
6390
|
kind?: "plugin";
|
|
6332
6391
|
provider?: "deepgram" | "elevenlabs";
|
|
6392
|
+
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6333
6393
|
options?: Record<string, unknown>;
|
|
6334
6394
|
} | {
|
|
6335
6395
|
kind?: "realtime";
|
|
@@ -6342,9 +6402,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
6342
6402
|
model?: string;
|
|
6343
6403
|
options?: Record<string, unknown>;
|
|
6344
6404
|
} | {
|
|
6345
|
-
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6346
6405
|
kind?: "plugin";
|
|
6347
6406
|
provider?: "deepgram" | "elevenlabs";
|
|
6407
|
+
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6348
6408
|
options?: Record<string, unknown>;
|
|
6349
6409
|
} | {
|
|
6350
6410
|
kind?: "realtime";
|
|
@@ -6405,9 +6465,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
6405
6465
|
model?: string;
|
|
6406
6466
|
options?: Record<string, unknown>;
|
|
6407
6467
|
} | {
|
|
6408
|
-
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6409
6468
|
kind?: "plugin";
|
|
6410
6469
|
provider?: "deepgram" | "elevenlabs";
|
|
6470
|
+
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6411
6471
|
options?: Record<string, unknown>;
|
|
6412
6472
|
} | {
|
|
6413
6473
|
kind?: "realtime";
|
|
@@ -6421,9 +6481,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
6421
6481
|
model?: string;
|
|
6422
6482
|
options?: Record<string, unknown>;
|
|
6423
6483
|
} | {
|
|
6424
|
-
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6425
6484
|
kind?: "plugin";
|
|
6426
6485
|
provider?: "deepgram" | "elevenlabs";
|
|
6486
|
+
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6427
6487
|
options?: Record<string, unknown>;
|
|
6428
6488
|
} | {
|
|
6429
6489
|
kind?: "realtime";
|
|
@@ -6436,9 +6496,9 @@ declare const LuaVoiceConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
|
6436
6496
|
model?: string;
|
|
6437
6497
|
options?: Record<string, unknown>;
|
|
6438
6498
|
} | {
|
|
6439
|
-
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6440
6499
|
kind?: "plugin";
|
|
6441
6500
|
provider?: "deepgram" | "elevenlabs";
|
|
6501
|
+
class?: "LLM" | "STT" | "STTv2" | "TTS";
|
|
6442
6502
|
options?: Record<string, unknown>;
|
|
6443
6503
|
} | {
|
|
6444
6504
|
kind?: "realtime";
|
|
@@ -6985,7 +7045,10 @@ export declare interface LuaWorkflowConfig {
|
|
|
6985
7045
|
* marketplace template freezes from this schedule: `'installer'` (the default when absent — every install's
|
|
6986
7046
|
* fires run as the person who installed, who gets the run card in their inbox) or `'system'` (the frozen copy
|
|
6987
7047
|
* runs user-less and unwatched — no inbox card for its runs; the install response says so). On this agent the
|
|
6988
|
-
* schedule runs as you
|
|
7048
|
+
* schedule runs as you, unless the platform has enabled author system schedules: then `'system'` makes this
|
|
7049
|
+
* agent's own schedule run as the agent (`system:<agentId>`), like a template copy's, with you recorded as the
|
|
7050
|
+
* deployer who scheduled it (the schedule stops if you lose access to the agent). A manual run ("Run now")
|
|
7051
|
+
* always runs as the person who starts it.
|
|
6989
7052
|
*/
|
|
6990
7053
|
schedule?: JobSchedule & {
|
|
6991
7054
|
runAs?: 'installer' | 'system';
|
|
@@ -7208,6 +7271,13 @@ export declare type MCPTransport = 'sse' | 'streamable-http';
|
|
|
7208
7271
|
|
|
7209
7272
|
declare type Message = TextMessage_2 | ImageMessage_2 | FileMessage_2;
|
|
7210
7273
|
|
|
7274
|
+
/**
|
|
7275
|
+
* The text of a postprocessor's `message`, whichever shape it arrived in: a string as is,
|
|
7276
|
+
* parts as their `text` parts joined with a newline (image and file parts are skipped).
|
|
7277
|
+
* Anything else yields `''`.
|
|
7278
|
+
*/
|
|
7279
|
+
export declare function messageText(message: PostProcessorMessage | null | undefined): string;
|
|
7280
|
+
|
|
7211
7281
|
export declare const Metrics: MetricsApi;
|
|
7212
7282
|
|
|
7213
7283
|
/**
|
|
@@ -7564,7 +7634,7 @@ declare class PostProcessor {
|
|
|
7564
7634
|
getName(): string;
|
|
7565
7635
|
getDescription(): string;
|
|
7566
7636
|
getPriority(): number;
|
|
7567
|
-
execute(user: UserDataInstance, message:
|
|
7637
|
+
execute(user: UserDataInstance, message: PostProcessorMessage, response: string, channel: string): Promise<PostProcessorResponse>;
|
|
7568
7638
|
}
|
|
7569
7639
|
export { PostProcessor as LuaPostprocessor }
|
|
7570
7640
|
export { PostProcessor }
|
|
@@ -7585,10 +7655,18 @@ export declare interface PostProcessorConfig {
|
|
|
7585
7655
|
/**
|
|
7586
7656
|
* Function that processes the agent's response before sending to user.
|
|
7587
7657
|
* MUST return { modifiedResponse: string } - the formatted response text.
|
|
7658
|
+
* `message` is the user's message: a string or its parts — read it with `messageText(message)`.
|
|
7588
7659
|
*/
|
|
7589
|
-
execute: (user: UserDataInstance, message:
|
|
7660
|
+
execute: (user: UserDataInstance, message: PostProcessorMessage, response: string, channel: string) => Promise<PostProcessorResponse>;
|
|
7590
7661
|
}
|
|
7591
7662
|
|
|
7663
|
+
/**
|
|
7664
|
+
* The user's message as a postprocessor receives it (LUA-1075).
|
|
7665
|
+
* lua-core passes the turn's user content unchanged: a plain string, or the message parts
|
|
7666
|
+
* (`[{ type: 'text', text }, { type: 'image', ... }]`). Use {@link messageText} for its text.
|
|
7667
|
+
*/
|
|
7668
|
+
export declare type PostProcessorMessage = string | ChatMessage[];
|
|
7669
|
+
|
|
7592
7670
|
/**
|
|
7593
7671
|
* PostProcessor override for sandbox testing.
|
|
7594
7672
|
* Maps production postprocessor ID to sandbox version ID.
|
|
@@ -8252,13 +8330,19 @@ declare type RequestCredentialDescriptor = {
|
|
|
8252
8330
|
declare type RequestCredentialInput = string | RequestCredential;
|
|
8253
8331
|
|
|
8254
8332
|
/**
|
|
8255
|
-
* Optional per-request overrides (WF-202, 03 §3.7 client-deadline rule).
|
|
8256
|
-
* `timeoutMs`: `WorkflowApi.startRun` long-polls with `waitSeconds ≤ 55` and raises
|
|
8257
|
-
*
|
|
8258
|
-
*
|
|
8333
|
+
* Optional per-request overrides (WF-202, 03 §3.7 client-deadline rule).
|
|
8334
|
+
* - `timeoutMs`: `WorkflowApi.startRun` long-polls with `waitSeconds ≤ 55` and raises
|
|
8335
|
+
* its deadline to `(waitSeconds + 10) s` so the 30 s default abort never races the
|
|
8336
|
+
* server. Every other call site is untouched (undefined ⇒ the 30 s default).
|
|
8337
|
+
* - `signal` (BAC-1097): a caller's AbortSignal. It is linked to the request's own
|
|
8338
|
+
* AbortController (which still owns the `timeoutMs` deadline — one controller, no
|
|
8339
|
+
* double-cancel), so aborting closes the in-flight fetch, stops any retry / Core-drain
|
|
8340
|
+
* backoff, and answers the `REQUEST_ABORTED` envelope. `AgentsApiService.invoke` passes
|
|
8341
|
+
* `AgentInvocationInput.signal` here; the signal is never serialized.
|
|
8259
8342
|
*/
|
|
8260
8343
|
declare interface RequestOverrides {
|
|
8261
8344
|
timeoutMs?: number;
|
|
8345
|
+
signal?: AbortSignal;
|
|
8262
8346
|
}
|
|
8263
8347
|
|
|
8264
8348
|
/**
|
|
@@ -8969,6 +9053,14 @@ declare interface SupervisionLogRow {
|
|
|
8969
9053
|
logSource?: string;
|
|
8970
9054
|
primitiveName?: string;
|
|
8971
9055
|
toolName?: string;
|
|
9056
|
+
/**
|
|
9057
|
+
* LUA-1076 — the agent version that served the row (string form of the version number / id), when the writer
|
|
9058
|
+
* stamped it. Lets a supervisor tell a staged version's errors from the live version's. Filter with
|
|
9059
|
+
* `{ agentVersion }` on the `logs` op.
|
|
9060
|
+
*/
|
|
9061
|
+
agentVersion?: string;
|
|
9062
|
+
/** 'production' for the promoted (live) version; 'sandbox' for previews, practice and dev. Filter with `{ environment }`. */
|
|
9063
|
+
environment?: string;
|
|
8972
9064
|
/**
|
|
8973
9065
|
* A non-identifying conversation key: the same value for every row of one conversation (thread) on this target,
|
|
8974
9066
|
* never the thread id itself (which embeds the end user's id), and different on another target. Present on rows
|
package/dist/api-exports.js
CHANGED
|
@@ -11694,6 +11694,19 @@ var init_request_credential = __esm({
|
|
|
11694
11694
|
|
|
11695
11695
|
// src/api/http.client.ts
|
|
11696
11696
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
11697
|
+
function abortedResponse() {
|
|
11698
|
+
return {
|
|
11699
|
+
success: false,
|
|
11700
|
+
error: {
|
|
11701
|
+
message: "Request aborted",
|
|
11702
|
+
code: REQUEST_ABORTED_CODE,
|
|
11703
|
+
statusCode: 0
|
|
11704
|
+
}
|
|
11705
|
+
};
|
|
11706
|
+
}
|
|
11707
|
+
function isAborted(signal) {
|
|
11708
|
+
return !!signal && signal.aborted === true;
|
|
11709
|
+
}
|
|
11697
11710
|
async function classifyErrorResponse(response) {
|
|
11698
11711
|
let errorData;
|
|
11699
11712
|
try {
|
|
@@ -11826,7 +11839,7 @@ function coreDrainApiRetryDelayMs(error) {
|
|
|
11826
11839
|
const delayMs = retryAfterSeconds * 1e3;
|
|
11827
11840
|
return Math.min(Math.max(0, delayMs), CORE_DRAINING_MAX_RETRY_MS);
|
|
11828
11841
|
}
|
|
11829
|
-
var DEFAULT_REQUEST_TIMEOUT_MS, HttpClient;
|
|
11842
|
+
var DEFAULT_REQUEST_TIMEOUT_MS, REQUEST_ABORTED_CODE, HttpClient;
|
|
11830
11843
|
var init_http_client = __esm({
|
|
11831
11844
|
"src/api/http.client.ts"() {
|
|
11832
11845
|
"use strict";
|
|
@@ -11837,6 +11850,9 @@ var init_http_client = __esm({
|
|
|
11837
11850
|
init_lua_fetch();
|
|
11838
11851
|
init_request_credential();
|
|
11839
11852
|
DEFAULT_REQUEST_TIMEOUT_MS = 3e4;
|
|
11853
|
+
REQUEST_ABORTED_CODE = "REQUEST_ABORTED";
|
|
11854
|
+
__name(abortedResponse, "abortedResponse");
|
|
11855
|
+
__name(isAborted, "isAborted");
|
|
11840
11856
|
HttpClient = class {
|
|
11841
11857
|
static {
|
|
11842
11858
|
__name(this, "HttpClient");
|
|
@@ -11859,9 +11875,17 @@ var init_http_client = __esm({
|
|
|
11859
11875
|
* @private
|
|
11860
11876
|
*/
|
|
11861
11877
|
async request(url, options = {}, overrides) {
|
|
11878
|
+
const callerSignal = overrides?.signal;
|
|
11879
|
+
if (isAborted(callerSignal)) return abortedResponse();
|
|
11862
11880
|
const controller = new AbortController();
|
|
11863
11881
|
const timeoutMs = overrides?.timeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
11864
11882
|
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
|
11883
|
+
const onCallerAbort = /* @__PURE__ */ __name(() => controller.abort(), "onCallerAbort");
|
|
11884
|
+
if (typeof callerSignal?.addEventListener === "function") {
|
|
11885
|
+
callerSignal.addEventListener("abort", onCallerAbort, {
|
|
11886
|
+
once: true
|
|
11887
|
+
});
|
|
11888
|
+
}
|
|
11865
11889
|
try {
|
|
11866
11890
|
const authorization = this.requestCredential ? `Bearer ${await bearerFor(this.requestCredential)}` : void 0;
|
|
11867
11891
|
const response = await luaFetch(url, {
|
|
@@ -11883,6 +11907,7 @@ var init_http_client = __esm({
|
|
|
11883
11907
|
try {
|
|
11884
11908
|
data = await response.json();
|
|
11885
11909
|
} catch (jsonError) {
|
|
11910
|
+
if (isAborted(callerSignal)) throw jsonError;
|
|
11886
11911
|
data = {};
|
|
11887
11912
|
}
|
|
11888
11913
|
if (typeof data === "object" && data !== null && "success" in data) {
|
|
@@ -11900,6 +11925,9 @@ var init_http_client = __esm({
|
|
|
11900
11925
|
if (isAccessDeniedError(error)) {
|
|
11901
11926
|
throw error;
|
|
11902
11927
|
}
|
|
11928
|
+
if (isAborted(callerSignal)) {
|
|
11929
|
+
return abortedResponse();
|
|
11930
|
+
}
|
|
11903
11931
|
if (error instanceof DOMException && error.name === "AbortError") {
|
|
11904
11932
|
return {
|
|
11905
11933
|
success: false,
|
|
@@ -11916,9 +11944,36 @@ var init_http_client = __esm({
|
|
|
11916
11944
|
statusCode: 0
|
|
11917
11945
|
}
|
|
11918
11946
|
};
|
|
11947
|
+
} finally {
|
|
11948
|
+
clearTimeout(timeoutId);
|
|
11949
|
+
if (typeof callerSignal?.removeEventListener === "function") {
|
|
11950
|
+
callerSignal.removeEventListener("abort", onCallerAbort);
|
|
11951
|
+
}
|
|
11919
11952
|
}
|
|
11920
11953
|
}
|
|
11921
11954
|
/**
|
|
11955
|
+
* A backoff wait the caller's signal can cut short (BAC-1097): resolves at `ms` or on abort, whichever is
|
|
11956
|
+
* first, and never leaves the timer or the listener behind. The caller re-checks `signal.aborted` afterwards.
|
|
11957
|
+
* @private
|
|
11958
|
+
*/
|
|
11959
|
+
sleep(ms, signal) {
|
|
11960
|
+
if (isAborted(signal)) return Promise.resolve();
|
|
11961
|
+
const listenable = typeof signal?.addEventListener === "function";
|
|
11962
|
+
return new Promise((resolve3) => {
|
|
11963
|
+
const onAbort = /* @__PURE__ */ __name(() => {
|
|
11964
|
+
clearTimeout(timer);
|
|
11965
|
+
resolve3();
|
|
11966
|
+
}, "onAbort");
|
|
11967
|
+
const timer = setTimeout(() => {
|
|
11968
|
+
if (listenable) signal.removeEventListener("abort", onAbort);
|
|
11969
|
+
resolve3();
|
|
11970
|
+
}, ms);
|
|
11971
|
+
if (listenable) signal.addEventListener("abort", onAbort, {
|
|
11972
|
+
once: true
|
|
11973
|
+
});
|
|
11974
|
+
});
|
|
11975
|
+
}
|
|
11976
|
+
/**
|
|
11922
11977
|
* Non-2xx classification shared by `request` and `httpStream` (WF-204): 401s become
|
|
11923
11978
|
* `AuthenticationError` (ownership vs credential), 403s throw, everything else returns the
|
|
11924
11979
|
* `{ success:false, error }` envelope with the server body spread in.
|
|
@@ -11986,19 +12041,22 @@ var init_http_client = __esm({
|
|
|
11986
12041
|
}
|
|
11987
12042
|
}
|
|
11988
12043
|
let lastResult = null;
|
|
12044
|
+
const signal = overrides?.signal;
|
|
11989
12045
|
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
12046
|
+
if (isAborted(signal)) return abortedResponse();
|
|
11990
12047
|
try {
|
|
11991
12048
|
const result = await this.request(url, options, overrides);
|
|
11992
12049
|
if (result.success || !result.error || !this.isRetryableStatus(result.error.statusCode || 0)) {
|
|
11993
12050
|
return result;
|
|
11994
12051
|
}
|
|
12052
|
+
if (isAborted(signal)) return result;
|
|
11995
12053
|
lastResult = result;
|
|
11996
12054
|
} catch (error) {
|
|
11997
12055
|
throw error;
|
|
11998
12056
|
}
|
|
11999
12057
|
if (attempt < maxRetries) {
|
|
12000
12058
|
const backoff = this.retryDelayMs(attempt, lastResult?.error, options.method);
|
|
12001
|
-
await
|
|
12059
|
+
await this.sleep(backoff, signal);
|
|
12002
12060
|
}
|
|
12003
12061
|
}
|
|
12004
12062
|
return lastResult;
|
|
@@ -12047,7 +12105,8 @@ var init_http_client = __esm({
|
|
|
12047
12105
|
async httpPostCoreDrainRetry(url, data, headers, overrides) {
|
|
12048
12106
|
const first = await this.httpPostOnce(url, data, headers, overrides);
|
|
12049
12107
|
if (!isCoreDrainApiError(first.error)) return first;
|
|
12050
|
-
await
|
|
12108
|
+
await this.sleep(coreDrainApiRetryDelayMs(first.error), overrides?.signal);
|
|
12109
|
+
if (isAborted(overrides?.signal)) return abortedResponse();
|
|
12051
12110
|
return this.httpPostOnce(url, data, headers, overrides);
|
|
12052
12111
|
}
|
|
12053
12112
|
/**
|
|
@@ -20897,10 +20956,15 @@ var init_basket_api_service = __esm({
|
|
|
20897
20956
|
});
|
|
20898
20957
|
|
|
20899
20958
|
// src/instances/user.instance.ts
|
|
20959
|
+
function omit(source, key) {
|
|
20960
|
+
const { [key]: _dropped, ...rest } = source;
|
|
20961
|
+
return rest;
|
|
20962
|
+
}
|
|
20900
20963
|
var UserDataInstance;
|
|
20901
20964
|
var init_user_instance = __esm({
|
|
20902
20965
|
"src/instances/user.instance.ts"() {
|
|
20903
20966
|
"use strict";
|
|
20967
|
+
__name(omit, "omit");
|
|
20904
20968
|
UserDataInstance = class {
|
|
20905
20969
|
static {
|
|
20906
20970
|
__name(this, "UserDataInstance");
|
|
@@ -20916,7 +20980,12 @@ var init_user_instance = __esm({
|
|
|
20916
20980
|
* @returns Proxied instance that allows direct access to data properties
|
|
20917
20981
|
*/
|
|
20918
20982
|
constructor(api, data, profile) {
|
|
20919
|
-
this
|
|
20983
|
+
Object.defineProperty(this, "data", {
|
|
20984
|
+
value: data && typeof data === "object" ? data : {},
|
|
20985
|
+
writable: true,
|
|
20986
|
+
enumerable: false,
|
|
20987
|
+
configurable: true
|
|
20988
|
+
});
|
|
20920
20989
|
Object.defineProperty(this, "userAPI", {
|
|
20921
20990
|
value: api,
|
|
20922
20991
|
writable: true,
|
|
@@ -21028,7 +21097,8 @@ var init_user_instance = __esm({
|
|
|
21028
21097
|
*/
|
|
21029
21098
|
async update(data) {
|
|
21030
21099
|
try {
|
|
21031
|
-
const
|
|
21100
|
+
const payload = data && data.data === this.data ? omit(data, "data") : data;
|
|
21101
|
+
const response = await this.userAPI.update(payload);
|
|
21032
21102
|
this.data = response;
|
|
21033
21103
|
return this.data;
|
|
21034
21104
|
} catch (error) {
|
|
@@ -22279,6 +22349,29 @@ var init_ai_api_service = __esm({
|
|
|
22279
22349
|
}
|
|
22280
22350
|
return result.data;
|
|
22281
22351
|
}
|
|
22352
|
+
async image(body) {
|
|
22353
|
+
return this.httpPost(`/developer/ai/${this.agentId}/image`, body, {});
|
|
22354
|
+
}
|
|
22355
|
+
/**
|
|
22356
|
+
* Handles the simplified-vs-full-options branching for `AI.image`.
|
|
22357
|
+
* Simplified (`AI.image(prompt, options?)`) returns the hosted CDN url string; the options overload
|
|
22358
|
+
* (`AI.image({ prompt, ... })`) returns the full `{ url, model, provider }`.
|
|
22359
|
+
*/
|
|
22360
|
+
async imageForSandbox(promptOrOptions, options) {
|
|
22361
|
+
const simplified = typeof promptOrOptions === "string";
|
|
22362
|
+
const body = simplified ? {
|
|
22363
|
+
prompt: promptOrOptions,
|
|
22364
|
+
...options
|
|
22365
|
+
} : promptOrOptions;
|
|
22366
|
+
const result = await this.image(body);
|
|
22367
|
+
if (!result.success) {
|
|
22368
|
+
throw new Error(result.error?.message || "AI image generation failed");
|
|
22369
|
+
}
|
|
22370
|
+
if (!result.data) {
|
|
22371
|
+
throw new Error("AI image generation failed: empty response");
|
|
22372
|
+
}
|
|
22373
|
+
return simplified ? result.data.url : result.data;
|
|
22374
|
+
}
|
|
22282
22375
|
};
|
|
22283
22376
|
}
|
|
22284
22377
|
});
|
|
@@ -22389,6 +22482,12 @@ var init_integrations_api_service = __esm({
|
|
|
22389
22482
|
});
|
|
22390
22483
|
|
|
22391
22484
|
// src/api/agents.api.service.ts
|
|
22485
|
+
function isAborted2(signal) {
|
|
22486
|
+
return !!signal && signal.aborted === true;
|
|
22487
|
+
}
|
|
22488
|
+
function abortReason(signal) {
|
|
22489
|
+
return signal.reason ?? new DOMException("The operation was aborted", "AbortError");
|
|
22490
|
+
}
|
|
22392
22491
|
function toInvocationOutput(data, callerThreadId) {
|
|
22393
22492
|
const toolNames = /* @__PURE__ */ new Set();
|
|
22394
22493
|
for (const step3 of Array.isArray(data.steps) ? data.steps : []) {
|
|
@@ -22474,9 +22573,15 @@ var init_agents_api_service = __esm({
|
|
|
22474
22573
|
});
|
|
22475
22574
|
if (body.identifier) query.set("identifier", body.identifier);
|
|
22476
22575
|
const chatBody = this.toChatGenerateBody(body);
|
|
22477
|
-
|
|
22478
|
-
|
|
22479
|
-
|
|
22576
|
+
const overrides = {
|
|
22577
|
+
...typeof body.timeoutMs === "number" ? {
|
|
22578
|
+
timeoutMs: body.timeoutMs
|
|
22579
|
+
} : {},
|
|
22580
|
+
...body.signal ? {
|
|
22581
|
+
signal: body.signal
|
|
22582
|
+
} : {}
|
|
22583
|
+
};
|
|
22584
|
+
return this.httpPostCoreDrainRetry(`/chat/generate/${targetAgentId}?${query.toString()}`, chatBody, {}, Object.keys(overrides).length > 0 ? overrides : void 0);
|
|
22480
22585
|
}
|
|
22481
22586
|
/**
|
|
22482
22587
|
* Sandbox overload: mirrors the `AI.generate` pattern where the simplified
|
|
@@ -22487,8 +22592,10 @@ var init_agents_api_service = __esm({
|
|
|
22487
22592
|
const input = typeof promptOrInput === "string" ? {
|
|
22488
22593
|
prompt: promptOrInput
|
|
22489
22594
|
} : promptOrInput;
|
|
22595
|
+
if (isAborted2(input.signal)) throw abortReason(input.signal);
|
|
22490
22596
|
const result = await this.invoke(targetAgentId, input);
|
|
22491
22597
|
if (!result.success) {
|
|
22598
|
+
if (isAborted2(input.signal)) throw abortReason(input.signal);
|
|
22492
22599
|
throw new Error(result.error?.message || "Agent invocation failed");
|
|
22493
22600
|
}
|
|
22494
22601
|
if (!result.data) {
|
|
@@ -22734,6 +22841,8 @@ var init_agents_api_service = __esm({
|
|
|
22734
22841
|
};
|
|
22735
22842
|
}
|
|
22736
22843
|
};
|
|
22844
|
+
__name(isAborted2, "isAborted");
|
|
22845
|
+
__name(abortReason, "abortReason");
|
|
22737
22846
|
__name(toInvocationOutput, "toInvocationOutput");
|
|
22738
22847
|
__name(runSummary, "runSummary");
|
|
22739
22848
|
__name(supervisedCheck, "supervisedCheck");
|
|
@@ -25189,6 +25298,12 @@ var PreProcessor = class {
|
|
|
25189
25298
|
return this.executeFunction(user, messages, channel);
|
|
25190
25299
|
}
|
|
25191
25300
|
};
|
|
25301
|
+
function messageText2(message) {
|
|
25302
|
+
if (typeof message === "string") return message;
|
|
25303
|
+
if (!Array.isArray(message)) return "";
|
|
25304
|
+
return message.filter((p) => !!p && p.type === "text" && typeof p.text === "string").map((p) => p.text).join("\n");
|
|
25305
|
+
}
|
|
25306
|
+
__name(messageText2, "messageText");
|
|
25192
25307
|
var PostProcessor = class {
|
|
25193
25308
|
static {
|
|
25194
25309
|
__name(this, "PostProcessor");
|
|
@@ -26291,6 +26406,11 @@ var AI = {
|
|
|
26291
26406
|
const { getAiInstance: getAiInstance2 } = await Promise.resolve().then(() => (init_lazy_instances(), lazy_instances_exports));
|
|
26292
26407
|
const ai = await getAiInstance2();
|
|
26293
26408
|
return ai.generateForSandbox(promptOrOptions, content);
|
|
26409
|
+
},
|
|
26410
|
+
async image(promptOrOptions, options) {
|
|
26411
|
+
const { getAiInstance: getAiInstance2 } = await Promise.resolve().then(() => (init_lazy_instances(), lazy_instances_exports));
|
|
26412
|
+
const ai = await getAiInstance2();
|
|
26413
|
+
return ai.imageForSandbox(promptOrOptions, options);
|
|
26294
26414
|
}
|
|
26295
26415
|
};
|
|
26296
26416
|
var Integrations = {
|
|
@@ -26634,6 +26754,7 @@ export {
|
|
|
26634
26754
|
log,
|
|
26635
26755
|
lt2 as lt,
|
|
26636
26756
|
lte2 as lte,
|
|
26757
|
+
messageText2 as messageText,
|
|
26637
26758
|
ne2 as ne,
|
|
26638
26759
|
not2 as not,
|
|
26639
26760
|
notExists2 as notExists,
|