@leaflow/sdk 0.182.0 → 0.184.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.
Files changed (22) hide show
  1. package/dist/assistant/v1/generated/models.d.ts +90 -3
  2. package/dist/assistant/v1/generated/models.js +3 -0
  3. package/dist/assistant/v1/generated/schemas.zod.d.ts +14 -0
  4. package/dist/assistant/v1/generated/validators/createTaskRequestBody.zod.d.ts +7 -0
  5. package/dist/assistant/v1/generated/validators/searchTasksRequestBody.zod.d.ts +1 -0
  6. package/dist/assistant/v1/generated/validators/searchTasksRequestBody.zod.js +1 -1
  7. package/dist/assistant/v1/generated/validators/taskListResponseBody.zod.d.ts +20 -0
  8. package/dist/assistant/v1/generated/validators/taskResource.zod.d.ts +20 -0
  9. package/dist/assistant/v1/generated/validators/taskResource.zod.js +7 -0
  10. package/dist/assistant/v1/generated/validators/taskRunEvent.zod.d.ts +37 -0
  11. package/dist/assistant/v1/generated/validators/taskRunEvent.zod.js +40 -0
  12. package/dist/assistant/v1/generated/validators/taskRunListResponseBody.zod.d.ts +11 -0
  13. package/dist/assistant/v1/generated/validators/taskRunResource.zod.d.ts +11 -0
  14. package/dist/assistant/v1/generated/validators/taskRunResource.zod.js +10 -2
  15. package/dist/assistant/v1/generated/validators/taskTrigger.zod.d.ts +12 -0
  16. package/dist/assistant/v1/generated/validators/taskTrigger.zod.js +36 -2
  17. package/dist/assistant/v1/generated/validators/updateTaskRequestBody.zod.d.ts +7 -0
  18. package/dist/canopy/v1/generated/models.d.ts +2 -0
  19. package/dist/canopy/v1/generated/validators/cursorPageRequestResource.zod.d.ts +1 -0
  20. package/dist/canopy/v1/generated/validators/requestResource.zod.d.ts +1 -0
  21. package/dist/canopy/v1/generated/validators/requestResource.zod.js +4 -0
  22. package/package.json +1 -1
@@ -1177,6 +1177,7 @@ export declare const TaskTriggerType: {
1177
1177
  readonly at: "at";
1178
1178
  readonly interval: "interval";
1179
1179
  readonly cron: "cron";
1180
+ readonly event: "event";
1180
1181
  };
1181
1182
  /**
1182
1183
  * What happens when a run is due while the previous one is still going.
@@ -1187,7 +1188,10 @@ export declare const TaskTriggerOverlapPolicy: {
1187
1188
  readonly buffer_one: "buffer_one";
1188
1189
  };
1189
1190
  /**
1190
- * When the task runs. `type` determines which fields apply.
1191
+ * When the task runs. `type` determines which fields apply. An `event` task runs when a matching
1192
+ * event message arrives. Messages are delivered as they happen and are not stored: a message
1193
+ * published while delivery is interrupted does not start a run, and a message can arrive late or
1194
+ * more than once.
1191
1195
  */
1192
1196
  export interface TaskTrigger {
1193
1197
  type: TaskTriggerType;
@@ -1222,6 +1226,46 @@ export interface TaskTrigger {
1222
1226
  * @minimum 10
1223
1227
  */
1224
1228
  catchupSeconds?: number;
1229
+ /**
1230
+ * For `event`. The full name of the event to listen for.
1231
+ * @maxLength 128
1232
+ * @nullable
1233
+ */
1234
+ event?: string | null;
1235
+ /**
1236
+ * For `event`. A filter on the message key: layers separated by `/`, `+` matching exactly one
1237
+ * layer, and `#` as the last layer matching that layer and every layer below it. Null matches
1238
+ * every key.
1239
+ * @maxLength 512
1240
+ * @nullable
1241
+ */
1242
+ eventKey?: string | null;
1243
+ /**
1244
+ * For `event`. A CEL expression that must be true for a message to count, over `data` (the
1245
+ * payload) and `event` (`name`, `version`, `key`, `sender_id` and `created_at`). Reading a field
1246
+ * the payload does not carry counts as false; use `has()` for optional fields. Null counts every
1247
+ * message.
1248
+ * @maxLength 2048
1249
+ * @nullable
1250
+ */
1251
+ eventCondition?: string | null;
1252
+ /**
1253
+ * For `event`. The number of event-triggered runs after which the task completes. Null means no limit.
1254
+ * @minimum 1
1255
+ * @nullable
1256
+ */
1257
+ maxRuns?: number | null;
1258
+ /**
1259
+ * For `event`. The task stops listening and completes at this time.
1260
+ * @nullable
1261
+ */
1262
+ expiresAt?: string | null;
1263
+ /**
1264
+ * For `event`. The least time between the starts of two event-triggered runs. Messages that
1265
+ * match in between are delivered with the next run.
1266
+ * @minimum 10
1267
+ */
1268
+ cooldownSeconds?: number;
1225
1269
  }
1226
1270
  export type TaskActionType = (typeof TaskActionType)[keyof typeof TaskActionType];
1227
1271
  export declare const TaskActionType: {
@@ -1268,14 +1312,39 @@ export declare const TaskRunResourceStatus: {
1268
1312
  };
1269
1313
  /**
1270
1314
  * How the run started: `schedule` by the task's own trigger, including a task set to run now;
1271
- * `manual` by a person running it outside its schedule; `assistant` by the assistant.
1315
+ * `manual` by a person running it outside its schedule; `assistant` by the assistant; `event` by
1316
+ * matching event messages.
1272
1317
  */
1273
1318
  export type TaskRunResourceTrigger = (typeof TaskRunResourceTrigger)[keyof typeof TaskRunResourceTrigger];
1274
1319
  export declare const TaskRunResourceTrigger: {
1275
1320
  readonly schedule: "schedule";
1276
1321
  readonly manual: "manual";
1277
1322
  readonly assistant: "assistant";
1323
+ readonly event: "event";
1278
1324
  };
1325
+ /**
1326
+ * The payload as published. Null when it was larger than 4 KiB; see dataBytes.
1327
+ * @nullable
1328
+ */
1329
+ export type TaskRunEventData = {
1330
+ [key: string]: unknown;
1331
+ } | null;
1332
+ /**
1333
+ * An event message that started a run.
1334
+ */
1335
+ export interface TaskRunEvent {
1336
+ id: string;
1337
+ event: string;
1338
+ version: number;
1339
+ key: string;
1340
+ createdAt: string;
1341
+ /**
1342
+ * The payload as published. Null when it was larger than 4 KiB; see dataBytes.
1343
+ * @nullable
1344
+ */
1345
+ data: TaskRunEventData;
1346
+ dataBytes: number;
1347
+ }
1279
1348
  export interface TaskRunResource {
1280
1349
  id: string;
1281
1350
  taskId: string;
@@ -1301,9 +1370,17 @@ export interface TaskRunResource {
1301
1370
  errorCode: string | null;
1302
1371
  /**
1303
1372
  * How the run started: `schedule` by the task's own trigger, including a task set to run now;
1304
- * `manual` by a person running it outside its schedule; `assistant` by the assistant.
1373
+ * `manual` by a person running it outside its schedule; `assistant` by the assistant; `event` by
1374
+ * matching event messages.
1305
1375
  */
1306
1376
  trigger: TaskRunResourceTrigger;
1377
+ /** For runs started by events, the number of matching messages the run covers. */
1378
+ eventCount: number;
1379
+ /**
1380
+ * For runs started by events, up to 20 of the messages the run covers. Null in lists; read the run for it.
1381
+ * @nullable
1382
+ */
1383
+ events: TaskRunEvent[] | null;
1307
1384
  }
1308
1385
  export interface TaskResource {
1309
1386
  id: string;
@@ -1319,6 +1396,15 @@ export interface TaskResource {
1319
1396
  * @nullable
1320
1397
  */
1321
1398
  nextRunAt: string | null;
1399
+ /**
1400
+ * For `event`. The event version the condition was checked against. It advances when the event
1401
+ * gains a newer version that the condition still fits; when it no longer fits, the task is
1402
+ * paused and a failed run records TASK_EVENT_VERSION_INCOMPATIBLE.
1403
+ * @nullable
1404
+ */
1405
+ eventVersion: number | null;
1406
+ /** For `event`. The event-triggered runs started under the current trigger. */
1407
+ eventRunCount: number;
1322
1408
  lastRun: TaskRunResource | null;
1323
1409
  createdAt: string;
1324
1410
  updatedAt: string;
@@ -1359,6 +1445,7 @@ export declare const SearchTasksRequestBodyTriggerType: {
1359
1445
  readonly at: "at";
1360
1446
  readonly interval: "interval";
1361
1447
  readonly cron: "cron";
1448
+ readonly event: "event";
1362
1449
  };
1363
1450
  export type SearchTasksRequestBodyActionType = (typeof SearchTasksRequestBodyActionType)[keyof typeof SearchTasksRequestBodyActionType];
1364
1451
  export declare const SearchTasksRequestBodyActionType: {
@@ -130,6 +130,7 @@ export const TaskTriggerType = {
130
130
  at: "at",
131
131
  interval: "interval",
132
132
  cron: "cron",
133
+ event: "event",
133
134
  };
134
135
  export const TaskTriggerOverlapPolicy = {
135
136
  skip: "skip",
@@ -151,6 +152,7 @@ export const TaskRunResourceTrigger = {
151
152
  schedule: "schedule",
152
153
  manual: "manual",
153
154
  assistant: "assistant",
155
+ event: "event",
154
156
  };
155
157
  export const SearchTasksRequestBodyStatus = {
156
158
  active: "active",
@@ -163,6 +165,7 @@ export const SearchTasksRequestBodyTriggerType = {
163
165
  at: "at",
164
166
  interval: "interval",
165
167
  cron: "cron",
168
+ event: "event",
166
169
  };
167
170
  export const SearchTasksRequestBodyActionType = {
168
171
  prompt: "prompt",
@@ -466,6 +466,7 @@ export declare const CreateTaskBody: zod.ZodObject<{
466
466
  now: "now";
467
467
  interval: "interval";
468
468
  cron: "cron";
469
+ event: "event";
469
470
  }>;
470
471
  runAt: zod.ZodOptional<zod.ZodNullable<zod.z.ZodISODateTime>>;
471
472
  intervalSeconds: zod.ZodOptional<zod.ZodNullable<zod.ZodInt>>;
@@ -477,6 +478,12 @@ export declare const CreateTaskBody: zod.ZodObject<{
477
478
  buffer_one: "buffer_one";
478
479
  }>>;
479
480
  catchupSeconds: zod.ZodDefault<zod.ZodInt>;
481
+ event: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
482
+ eventKey: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
483
+ eventCondition: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
484
+ maxRuns: zod.ZodOptional<zod.ZodNullable<zod.ZodInt>>;
485
+ expiresAt: zod.ZodOptional<zod.ZodNullable<zod.z.ZodISODateTime>>;
486
+ cooldownSeconds: zod.ZodDefault<zod.ZodInt>;
480
487
  }, zod.z.core.$strict>;
481
488
  action: zod.ZodObject<{
482
489
  type: zod.ZodEnum<{
@@ -513,6 +520,7 @@ export declare const UpdateTaskBody: zod.ZodObject<{
513
520
  now: "now";
514
521
  interval: "interval";
515
522
  cron: "cron";
523
+ event: "event";
516
524
  }>;
517
525
  runAt: zod.ZodOptional<zod.ZodNullable<zod.z.ZodISODateTime>>;
518
526
  intervalSeconds: zod.ZodOptional<zod.ZodNullable<zod.ZodInt>>;
@@ -524,6 +532,12 @@ export declare const UpdateTaskBody: zod.ZodObject<{
524
532
  buffer_one: "buffer_one";
525
533
  }>>;
526
534
  catchupSeconds: zod.ZodDefault<zod.ZodInt>;
535
+ event: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
536
+ eventKey: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
537
+ eventCondition: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
538
+ maxRuns: zod.ZodOptional<zod.ZodNullable<zod.ZodInt>>;
539
+ expiresAt: zod.ZodOptional<zod.ZodNullable<zod.z.ZodISODateTime>>;
540
+ cooldownSeconds: zod.ZodDefault<zod.ZodInt>;
527
541
  }, zod.z.core.$strict>>;
528
542
  action: zod.ZodOptional<zod.ZodObject<{
529
543
  type: zod.ZodEnum<{
@@ -35,6 +35,7 @@ export declare const CreateTaskRequestBody: zod.ZodObject<{
35
35
  now: "now";
36
36
  interval: "interval";
37
37
  cron: "cron";
38
+ event: "event";
38
39
  }>;
39
40
  runAt: zod.ZodOptional<zod.ZodNullable<zod.z.ZodISODateTime>>;
40
41
  intervalSeconds: zod.ZodOptional<zod.ZodNullable<zod.ZodInt>>;
@@ -46,6 +47,12 @@ export declare const CreateTaskRequestBody: zod.ZodObject<{
46
47
  buffer_one: "buffer_one";
47
48
  }>>;
48
49
  catchupSeconds: zod.ZodDefault<zod.ZodInt>;
50
+ event: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
51
+ eventKey: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
52
+ eventCondition: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
53
+ maxRuns: zod.ZodOptional<zod.ZodNullable<zod.ZodInt>>;
54
+ expiresAt: zod.ZodOptional<zod.ZodNullable<zod.z.ZodISODateTime>>;
55
+ cooldownSeconds: zod.ZodDefault<zod.ZodInt>;
49
56
  }, zod.z.core.$strict>;
50
57
  action: zod.ZodObject<{
51
58
  type: zod.ZodEnum<{
@@ -41,6 +41,7 @@ export declare const SearchTasksRequestBody: zod.ZodObject<{
41
41
  now: "now";
42
42
  interval: "interval";
43
43
  cron: "cron";
44
+ event: "event";
44
45
  }>>;
45
46
  actionType: zod.ZodOptional<zod.ZodEnum<{
46
47
  prompt: "prompt";
@@ -35,7 +35,7 @@ export const SearchTasksRequestBody = zod.strictObject({
35
35
  .optional()
36
36
  .describe("Only the tasks that report to this conversation."),
37
37
  status: zod.enum(["active", "paused", "completed", "cancelled"]).optional(),
38
- triggerType: zod.enum(["now", "at", "interval", "cron"]).optional(),
38
+ triggerType: zod.enum(["now", "at", "interval", "cron", "event"]).optional(),
39
39
  actionType: zod.enum(["prompt", "command"]).optional(),
40
40
  cursor: zod.string().max(searchTasksRequestBodyCursorMax).optional(),
41
41
  limit: zod
@@ -41,6 +41,7 @@ export declare const TaskListResponseBody: zod.ZodObject<{
41
41
  now: "now";
42
42
  interval: "interval";
43
43
  cron: "cron";
44
+ event: "event";
44
45
  }>;
45
46
  runAt: zod.ZodOptional<zod.ZodNullable<zod.z.ZodISODateTime>>;
46
47
  intervalSeconds: zod.ZodOptional<zod.ZodNullable<zod.ZodInt>>;
@@ -52,6 +53,12 @@ export declare const TaskListResponseBody: zod.ZodObject<{
52
53
  buffer_one: "buffer_one";
53
54
  }>>;
54
55
  catchupSeconds: zod.ZodDefault<zod.ZodInt>;
56
+ event: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
57
+ eventKey: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
58
+ eventCondition: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
59
+ maxRuns: zod.ZodOptional<zod.ZodNullable<zod.ZodInt>>;
60
+ expiresAt: zod.ZodOptional<zod.ZodNullable<zod.z.ZodISODateTime>>;
61
+ cooldownSeconds: zod.ZodDefault<zod.ZodInt>;
55
62
  }, zod.z.core.$strict>;
56
63
  action: zod.ZodObject<{
57
64
  type: zod.ZodEnum<{
@@ -64,6 +71,8 @@ export declare const TaskListResponseBody: zod.ZodObject<{
64
71
  timeoutSeconds: zod.ZodDefault<zod.ZodInt>;
65
72
  }, zod.z.core.$strict>;
66
73
  nextRunAt: zod.ZodNullable<zod.z.ZodISODateTime>;
74
+ eventVersion: zod.ZodNullable<zod.ZodInt>;
75
+ eventRunCount: zod.ZodInt;
67
76
  lastRun: zod.ZodUnion<readonly [zod.ZodObject<{
68
77
  id: zod.ZodString;
69
78
  taskId: zod.ZodString;
@@ -82,9 +91,20 @@ export declare const TaskListResponseBody: zod.ZodObject<{
82
91
  errorCode: zod.ZodNullable<zod.ZodString>;
83
92
  trigger: zod.ZodEnum<{
84
93
  manual: "manual";
94
+ event: "event";
85
95
  schedule: "schedule";
86
96
  assistant: "assistant";
87
97
  }>;
98
+ eventCount: zod.ZodInt;
99
+ events: zod.ZodNullable<zod.ZodArray<zod.ZodObject<{
100
+ id: zod.ZodString;
101
+ event: zod.ZodString;
102
+ version: zod.ZodInt;
103
+ key: zod.ZodString;
104
+ createdAt: zod.z.ZodISODateTime;
105
+ data: zod.ZodNullable<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
106
+ dataBytes: zod.ZodInt;
107
+ }, zod.z.core.$strict>>>;
88
108
  }, zod.z.core.$strict>, zod.ZodNull]>;
89
109
  createdAt: zod.z.ZodISODateTime;
90
110
  updatedAt: zod.z.ZodISODateTime;
@@ -40,6 +40,7 @@ export declare const TaskResource: zod.ZodObject<{
40
40
  now: "now";
41
41
  interval: "interval";
42
42
  cron: "cron";
43
+ event: "event";
43
44
  }>;
44
45
  runAt: zod.ZodOptional<zod.ZodNullable<zod.z.ZodISODateTime>>;
45
46
  intervalSeconds: zod.ZodOptional<zod.ZodNullable<zod.ZodInt>>;
@@ -51,6 +52,12 @@ export declare const TaskResource: zod.ZodObject<{
51
52
  buffer_one: "buffer_one";
52
53
  }>>;
53
54
  catchupSeconds: zod.ZodDefault<zod.ZodInt>;
55
+ event: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
56
+ eventKey: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
57
+ eventCondition: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
58
+ maxRuns: zod.ZodOptional<zod.ZodNullable<zod.ZodInt>>;
59
+ expiresAt: zod.ZodOptional<zod.ZodNullable<zod.z.ZodISODateTime>>;
60
+ cooldownSeconds: zod.ZodDefault<zod.ZodInt>;
54
61
  }, zod.z.core.$strict>;
55
62
  action: zod.ZodObject<{
56
63
  type: zod.ZodEnum<{
@@ -63,6 +70,8 @@ export declare const TaskResource: zod.ZodObject<{
63
70
  timeoutSeconds: zod.ZodDefault<zod.ZodInt>;
64
71
  }, zod.z.core.$strict>;
65
72
  nextRunAt: zod.ZodNullable<zod.z.ZodISODateTime>;
73
+ eventVersion: zod.ZodNullable<zod.ZodInt>;
74
+ eventRunCount: zod.ZodInt;
66
75
  lastRun: zod.ZodUnion<readonly [zod.ZodObject<{
67
76
  id: zod.ZodString;
68
77
  taskId: zod.ZodString;
@@ -81,9 +90,20 @@ export declare const TaskResource: zod.ZodObject<{
81
90
  errorCode: zod.ZodNullable<zod.ZodString>;
82
91
  trigger: zod.ZodEnum<{
83
92
  manual: "manual";
93
+ event: "event";
84
94
  schedule: "schedule";
85
95
  assistant: "assistant";
86
96
  }>;
97
+ eventCount: zod.ZodInt;
98
+ events: zod.ZodNullable<zod.ZodArray<zod.ZodObject<{
99
+ id: zod.ZodString;
100
+ event: zod.ZodString;
101
+ version: zod.ZodInt;
102
+ key: zod.ZodString;
103
+ createdAt: zod.z.ZodISODateTime;
104
+ data: zod.ZodNullable<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
105
+ dataBytes: zod.ZodInt;
106
+ }, zod.z.core.$strict>>>;
87
107
  }, zod.z.core.$strict>, zod.ZodNull]>;
88
108
  createdAt: zod.z.ZodISODateTime;
89
109
  updatedAt: zod.z.ZodISODateTime;
@@ -40,6 +40,13 @@ export const TaskResource = zod.strictObject({
40
40
  .datetime({ offset: true })
41
41
  .nullable()
42
42
  .describe("When the trigger starts the next run. Null when it will not."),
43
+ eventVersion: zod
44
+ .int()
45
+ .nullable()
46
+ .describe("For `event`. The event version the condition was checked against. It advances when the event\ngains a newer version that the condition still fits; when it no longer fits, the task is\npaused and a failed run records TASK_EVENT_VERSION_INCOMPATIBLE."),
47
+ eventRunCount: zod
48
+ .int()
49
+ .describe("For `event`. The event-triggered runs started under the current trigger."),
43
50
  lastRun: zod.union([TaskRunResource, zod.null()]),
44
51
  createdAt: zod.iso.datetime({ offset: true }),
45
52
  updatedAt: zod.iso.datetime({ offset: true }),
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Leaflow Assistant API
5
+ * Conversations with agents that operate the Leaflow platform, plus their folders, tasks, files and
6
+ * chat-app channels.
7
+ *
8
+ * A conversation is a thread. A person talks to the main thread; the agent in it can start subagents,
9
+ * which are threads too and run on their own: stopping the main thread does not stop them, and each
10
+ * subagent tells its parent when it ends. A thread runs in turns; each turn records the model and
11
+ * reasoning effort it used and its token usage.
12
+ *
13
+ * Models come from the Canopy catalogue. A new thread uses the model it names, the caller's default
14
+ * from /api/v1/settings, or the first catalogue model that can run an agent. Reasoning models take one
15
+ * of three efforts — low, medium or high — which are sent to the model unchanged.
16
+ *
17
+ * Read a thread's state with get-thread and its transcript with list-thread-items. Follow both live
18
+ * through EventBus by subscribing to assistant.thread.frame and assistant.resource.updated; after a
19
+ * reconnection or an assistant.workspace.invalidated message, read them again. list-thread-messages
20
+ * outlines the person's messages for navigating a long conversation.
21
+ *
22
+ * Upload large files with /api/v1/uploads: read /api/v1/upload-configuration first, send exact-sized
23
+ * parts, then complete the upload and send its attachment id in a message.
24
+ * OpenAPI spec version: 2.0.0
25
+ */
26
+ import * as zod from "zod";
27
+ export declare const TaskRunEvent: zod.ZodObject<{
28
+ id: zod.ZodString;
29
+ event: zod.ZodString;
30
+ version: zod.ZodInt;
31
+ key: zod.ZodString;
32
+ createdAt: zod.z.ZodISODateTime;
33
+ data: zod.ZodNullable<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
34
+ dataBytes: zod.ZodInt;
35
+ }, zod.z.core.$strict>;
36
+ export type TaskRunEvent = zod.input<typeof TaskRunEvent>;
37
+ export type TaskRunEventOutput = zod.output<typeof TaskRunEvent>;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Leaflow Assistant API
5
+ * Conversations with agents that operate the Leaflow platform, plus their folders, tasks, files and
6
+ * chat-app channels.
7
+ *
8
+ * A conversation is a thread. A person talks to the main thread; the agent in it can start subagents,
9
+ * which are threads too and run on their own: stopping the main thread does not stop them, and each
10
+ * subagent tells its parent when it ends. A thread runs in turns; each turn records the model and
11
+ * reasoning effort it used and its token usage.
12
+ *
13
+ * Models come from the Canopy catalogue. A new thread uses the model it names, the caller's default
14
+ * from /api/v1/settings, or the first catalogue model that can run an agent. Reasoning models take one
15
+ * of three efforts — low, medium or high — which are sent to the model unchanged.
16
+ *
17
+ * Read a thread's state with get-thread and its transcript with list-thread-items. Follow both live
18
+ * through EventBus by subscribing to assistant.thread.frame and assistant.resource.updated; after a
19
+ * reconnection or an assistant.workspace.invalidated message, read them again. list-thread-messages
20
+ * outlines the person's messages for navigating a long conversation.
21
+ *
22
+ * Upload large files with /api/v1/uploads: read /api/v1/upload-configuration first, send exact-sized
23
+ * parts, then complete the upload and send its attachment id in a message.
24
+ * OpenAPI spec version: 2.0.0
25
+ */
26
+ import * as zod from "zod";
27
+ export const TaskRunEvent = zod
28
+ .strictObject({
29
+ id: zod.string(),
30
+ event: zod.string(),
31
+ version: zod.int(),
32
+ key: zod.string(),
33
+ createdAt: zod.iso.datetime({ offset: true }),
34
+ data: zod
35
+ .record(zod.string(), zod.unknown())
36
+ .nullable()
37
+ .describe("The payload as published. Null when it was larger than 4 KiB; see dataBytes."),
38
+ dataBytes: zod.int(),
39
+ })
40
+ .describe("An event message that started a run.");
@@ -43,9 +43,20 @@ export declare const TaskRunListResponseBody: zod.ZodObject<{
43
43
  errorCode: zod.ZodNullable<zod.ZodString>;
44
44
  trigger: zod.ZodEnum<{
45
45
  manual: "manual";
46
+ event: "event";
46
47
  schedule: "schedule";
47
48
  assistant: "assistant";
48
49
  }>;
50
+ eventCount: zod.ZodInt;
51
+ events: zod.ZodNullable<zod.ZodArray<zod.ZodObject<{
52
+ id: zod.ZodString;
53
+ event: zod.ZodString;
54
+ version: zod.ZodInt;
55
+ key: zod.ZodString;
56
+ createdAt: zod.z.ZodISODateTime;
57
+ data: zod.ZodNullable<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
58
+ dataBytes: zod.ZodInt;
59
+ }, zod.z.core.$strict>>>;
49
60
  }, zod.z.core.$strict>>;
50
61
  nextCursor: zod.ZodNullable<zod.ZodString>;
51
62
  }, zod.z.core.$strict>;
@@ -42,9 +42,20 @@ export declare const TaskRunResource: zod.ZodObject<{
42
42
  errorCode: zod.ZodNullable<zod.ZodString>;
43
43
  trigger: zod.ZodEnum<{
44
44
  manual: "manual";
45
+ event: "event";
45
46
  schedule: "schedule";
46
47
  assistant: "assistant";
47
48
  }>;
49
+ eventCount: zod.ZodInt;
50
+ events: zod.ZodNullable<zod.ZodArray<zod.ZodObject<{
51
+ id: zod.ZodString;
52
+ event: zod.ZodString;
53
+ version: zod.ZodInt;
54
+ key: zod.ZodString;
55
+ createdAt: zod.z.ZodISODateTime;
56
+ data: zod.ZodNullable<zod.ZodRecord<zod.ZodString, zod.ZodUnknown>>;
57
+ dataBytes: zod.ZodInt;
58
+ }, zod.z.core.$strict>>>;
48
59
  }, zod.z.core.$strict>;
49
60
  export type TaskRunResource = zod.input<typeof TaskRunResource>;
50
61
  export type TaskRunResourceOutput = zod.output<typeof TaskRunResource>;
@@ -24,6 +24,7 @@
24
24
  * OpenAPI spec version: 2.0.0
25
25
  */
26
26
  import * as zod from "zod";
27
+ import { TaskRunEvent } from "./taskRunEvent.zod.js";
27
28
  export const TaskRunResource = zod.strictObject({
28
29
  id: zod.string(),
29
30
  taskId: zod.string(),
@@ -37,6 +38,13 @@ export const TaskRunResource = zod.strictObject({
37
38
  .describe("The last 16 KiB of a command's output. Empty for prompts; null in lists, read the run for it."),
38
39
  errorCode: zod.string().nullable().describe("Why the run failed. Null unless status is failed."),
39
40
  trigger: zod
40
- .enum(["schedule", "manual", "assistant"])
41
- .describe("How the run started: `schedule` by the task's own trigger, including a task set to run now;\n`manual` by a person running it outside its schedule; `assistant` by the assistant."),
41
+ .enum(["schedule", "manual", "assistant", "event"])
42
+ .describe("How the run started: `schedule` by the task's own trigger, including a task set to run now;\n`manual` by a person running it outside its schedule; `assistant` by the assistant; `event` by\nmatching event messages."),
43
+ eventCount: zod
44
+ .int()
45
+ .describe("For runs started by events, the number of matching messages the run covers."),
46
+ events: zod
47
+ .array(TaskRunEvent)
48
+ .nullable()
49
+ .describe("For runs started by events, up to 20 of the messages the run covers. Null in lists; read the run for it."),
42
50
  });
@@ -30,12 +30,18 @@ export declare const taskTriggerTimezoneDefault = "UTC";
30
30
  export declare const taskTriggerOverlapPolicyDefault = "buffer_one";
31
31
  export declare const taskTriggerCatchupSecondsDefault = 300;
32
32
  export declare const taskTriggerCatchupSecondsMin = 10;
33
+ export declare const taskTriggerEventMax = 128;
34
+ export declare const taskTriggerEventKeyMax = 512;
35
+ export declare const taskTriggerEventConditionMax = 2048;
36
+ export declare const taskTriggerCooldownSecondsDefault = 60;
37
+ export declare const taskTriggerCooldownSecondsMin = 10;
33
38
  export declare const TaskTrigger: zod.ZodObject<{
34
39
  type: zod.ZodEnum<{
35
40
  at: "at";
36
41
  now: "now";
37
42
  interval: "interval";
38
43
  cron: "cron";
44
+ event: "event";
39
45
  }>;
40
46
  runAt: zod.ZodOptional<zod.ZodNullable<zod.z.ZodISODateTime>>;
41
47
  intervalSeconds: zod.ZodOptional<zod.ZodNullable<zod.ZodInt>>;
@@ -47,6 +53,12 @@ export declare const TaskTrigger: zod.ZodObject<{
47
53
  buffer_one: "buffer_one";
48
54
  }>>;
49
55
  catchupSeconds: zod.ZodDefault<zod.ZodInt>;
56
+ event: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
57
+ eventKey: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
58
+ eventCondition: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
59
+ maxRuns: zod.ZodOptional<zod.ZodNullable<zod.ZodInt>>;
60
+ expiresAt: zod.ZodOptional<zod.ZodNullable<zod.z.ZodISODateTime>>;
61
+ cooldownSeconds: zod.ZodDefault<zod.ZodInt>;
50
62
  }, zod.z.core.$strict>;
51
63
  export type TaskTrigger = zod.input<typeof TaskTrigger>;
52
64
  export type TaskTriggerOutput = zod.output<typeof TaskTrigger>;
@@ -30,9 +30,14 @@ export const taskTriggerTimezoneDefault = `UTC`;
30
30
  export const taskTriggerOverlapPolicyDefault = `buffer_one`;
31
31
  export const taskTriggerCatchupSecondsDefault = 300;
32
32
  export const taskTriggerCatchupSecondsMin = 10;
33
+ export const taskTriggerEventMax = 128;
34
+ export const taskTriggerEventKeyMax = 512;
35
+ export const taskTriggerEventConditionMax = 2048;
36
+ export const taskTriggerCooldownSecondsDefault = 60;
37
+ export const taskTriggerCooldownSecondsMin = 10;
33
38
  export const TaskTrigger = zod
34
39
  .strictObject({
35
- type: zod.enum(["now", "at", "interval", "cron"]),
40
+ type: zod.enum(["now", "at", "interval", "cron", "event"]),
36
41
  runAt: zod.iso.datetime({ offset: true }).nullish().describe("For `at`."),
37
42
  intervalSeconds: zod
38
43
  .int()
@@ -61,5 +66,34 @@ export const TaskTrigger = zod
61
66
  .min(taskTriggerCatchupSecondsMin)
62
67
  .default(taskTriggerCatchupSecondsDefault)
63
68
  .describe("How late a missed run may still start, for example after a pause or an outage."),
69
+ event: zod
70
+ .string()
71
+ .max(taskTriggerEventMax)
72
+ .nullish()
73
+ .describe("For `event`. The full name of the event to listen for."),
74
+ eventKey: zod
75
+ .string()
76
+ .max(taskTriggerEventKeyMax)
77
+ .nullish()
78
+ .describe("For `event`. A filter on the message key: layers separated by `/`, `+` matching exactly one\nlayer, and `#` as the last layer matching that layer and every layer below it. Null matches\nevery key."),
79
+ eventCondition: zod
80
+ .string()
81
+ .max(taskTriggerEventConditionMax)
82
+ .nullish()
83
+ .describe("For `event`. A CEL expression that must be true for a message to count, over `data` (the\npayload) and `event` (`name`, `version`, `key`, `sender_id` and `created_at`). Reading a field\nthe payload does not carry counts as false; use `has()` for optional fields. Null counts every\nmessage."),
84
+ maxRuns: zod
85
+ .int()
86
+ .min(1)
87
+ .nullish()
88
+ .describe("For `event`. The number of event-triggered runs after which the task completes. Null means no limit."),
89
+ expiresAt: zod.iso
90
+ .datetime({ offset: true })
91
+ .nullish()
92
+ .describe("For `event`. The task stops listening and completes at this time."),
93
+ cooldownSeconds: zod
94
+ .int()
95
+ .min(taskTriggerCooldownSecondsMin)
96
+ .default(taskTriggerCooldownSecondsDefault)
97
+ .describe("For `event`. The least time between the starts of two event-triggered runs. Messages that\nmatch in between are delivered with the next run."),
64
98
  })
65
- .describe("When the task runs. `type` determines which fields apply.");
99
+ .describe("When the task runs. `type` determines which fields apply. An `event` task runs when a matching\nevent message arrives. Messages are delivered as they happen and are not stored: a message\npublished while delivery is interrupted does not start a run, and a message can arrive late or\nmore than once.");
@@ -33,6 +33,7 @@ export declare const UpdateTaskRequestBody: zod.ZodObject<{
33
33
  now: "now";
34
34
  interval: "interval";
35
35
  cron: "cron";
36
+ event: "event";
36
37
  }>;
37
38
  runAt: zod.ZodOptional<zod.ZodNullable<zod.z.ZodISODateTime>>;
38
39
  intervalSeconds: zod.ZodOptional<zod.ZodNullable<zod.ZodInt>>;
@@ -44,6 +45,12 @@ export declare const UpdateTaskRequestBody: zod.ZodObject<{
44
45
  buffer_one: "buffer_one";
45
46
  }>>;
46
47
  catchupSeconds: zod.ZodDefault<zod.ZodInt>;
48
+ event: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
49
+ eventKey: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
50
+ eventCondition: zod.ZodOptional<zod.ZodNullable<zod.ZodString>>;
51
+ maxRuns: zod.ZodOptional<zod.ZodNullable<zod.ZodInt>>;
52
+ expiresAt: zod.ZodOptional<zod.ZodNullable<zod.z.ZodISODateTime>>;
53
+ cooldownSeconds: zod.ZodDefault<zod.ZodInt>;
47
54
  }, zod.z.core.$strict>>;
48
55
  action: zod.ZodOptional<zod.ZodObject<{
49
56
  type: zod.ZodEnum<{
@@ -661,6 +661,8 @@ export interface RequestResource {
661
661
  input_tokens: number;
662
662
  /** The model named in the request */
663
663
  model_id: string;
664
+ /** The request operation, such as video_create or video_retrieve. Absent for historical requests where it was not recorded. */
665
+ operation?: string;
664
666
  output_tokens: number;
665
667
  reasoning_tokens: number;
666
668
  retries: number;
@@ -50,6 +50,7 @@ export declare const CursorPageRequestResource: zod.ZodObject<{
50
50
  id: zod.ZodString;
51
51
  input_tokens: zod.ZodInt;
52
52
  model_id: zod.ZodString;
53
+ operation: zod.ZodOptional<zod.ZodString>;
53
54
  output_tokens: zod.ZodInt;
54
55
  reasoning_tokens: zod.ZodInt;
55
56
  retries: zod.ZodInt;
@@ -50,6 +50,7 @@ export declare const RequestResource: zod.ZodObject<{
50
50
  id: zod.ZodString;
51
51
  input_tokens: zod.ZodInt;
52
52
  model_id: zod.ZodString;
53
+ operation: zod.ZodOptional<zod.ZodString>;
53
54
  output_tokens: zod.ZodInt;
54
55
  reasoning_tokens: zod.ZodInt;
55
56
  retries: zod.ZodInt;
@@ -59,6 +59,10 @@ export const RequestResource = zod.strictObject({
59
59
  .describe("A typed request id such as `req_01j...`. Legacy rows may still be returned as a bare UUID."),
60
60
  input_tokens: zod.int(),
61
61
  model_id: zod.string().describe("The model named in the request"),
62
+ operation: zod
63
+ .string()
64
+ .optional()
65
+ .describe("The request operation, such as video_create or video_retrieve. Absent for historical requests where it was not recorded."),
62
66
  output_tokens: zod.int(),
63
67
  reasoning_tokens: zod.int(),
64
68
  retries: zod.int(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leaflow/sdk",
3
- "version": "0.182.0",
3
+ "version": "0.184.0",
4
4
  "description": "Leaflow 平台 API 的 TypeScript SDK",
5
5
  "license": "MIT",
6
6
  "repository": {