@vertesia/common 0.81.1 → 1.0.0-dev.20260203.130115Z
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/package.json +5 -5
- package/src/analytics.ts +5 -2
- package/src/apikey.ts +20 -1
- package/src/apps.ts +269 -4
- package/src/ask-user.ts +35 -0
- package/src/channels.ts +70 -0
- package/src/data-platform.ts +976 -0
- package/src/email.ts +80 -0
- package/src/index.ts +7 -1
- package/src/integrations.ts +34 -0
- package/src/interaction.ts +280 -1
- package/src/pending-asks.ts +106 -0
- package/src/project.ts +90 -1
- package/src/prompt.ts +2 -1
- package/src/skill.ts +1 -0
- package/src/store/conversation-state.ts +152 -0
- package/src/store/dsl-workflow.ts +12 -0
- package/src/store/hive-memory.ts +167 -0
- package/src/store/index.ts +3 -0
- package/src/store/schedule.ts +238 -0
- package/src/store/signals.ts +20 -0
- package/src/store/store.ts +124 -0
- package/src/store/workflow.test.ts +578 -0
- package/src/store/workflow.ts +612 -53
- package/src/tool-execution.ts +47 -0
- package/src/user.ts +14 -1
- package/src/workflow-analytics.ts +925 -0
- package/lib/cjs/Progress.js +0 -61
- package/lib/cjs/Progress.js.map +0 -1
- package/lib/cjs/access-control.js +0 -56
- package/lib/cjs/access-control.js.map +0 -1
- package/lib/cjs/analytics.js +0 -3
- package/lib/cjs/analytics.js.map +0 -1
- package/lib/cjs/apikey.js +0 -16
- package/lib/cjs/apikey.js.map +0 -1
- package/lib/cjs/apps.js +0 -3
- package/lib/cjs/apps.js.map +0 -1
- package/lib/cjs/common.js +0 -3
- package/lib/cjs/common.js.map +0 -1
- package/lib/cjs/environment.js +0 -44
- package/lib/cjs/environment.js.map +0 -1
- package/lib/cjs/facets.js +0 -3
- package/lib/cjs/facets.js.map +0 -1
- package/lib/cjs/group.js +0 -5
- package/lib/cjs/group.js.map +0 -1
- package/lib/cjs/index.js +0 -49
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/integrations.js +0 -12
- package/lib/cjs/integrations.js.map +0 -1
- package/lib/cjs/interaction.js +0 -74
- package/lib/cjs/interaction.js.map +0 -1
- package/lib/cjs/json-schema.js +0 -3
- package/lib/cjs/json-schema.js.map +0 -1
- package/lib/cjs/json.js +0 -3
- package/lib/cjs/json.js.map +0 -1
- package/lib/cjs/meters.js +0 -13
- package/lib/cjs/meters.js.map +0 -1
- package/lib/cjs/model_utility.js +0 -6
- package/lib/cjs/model_utility.js.map +0 -1
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/payload.js +0 -3
- package/lib/cjs/payload.js.map +0 -1
- package/lib/cjs/project.js +0 -107
- package/lib/cjs/project.js.map +0 -1
- package/lib/cjs/prompt.js +0 -20
- package/lib/cjs/prompt.js.map +0 -1
- package/lib/cjs/query.js +0 -3
- package/lib/cjs/query.js.map +0 -1
- package/lib/cjs/rate-limiter.js +0 -6
- package/lib/cjs/rate-limiter.js.map +0 -1
- package/lib/cjs/refs.js +0 -14
- package/lib/cjs/refs.js.map +0 -1
- package/lib/cjs/runs.js +0 -3
- package/lib/cjs/runs.js.map +0 -1
- package/lib/cjs/skill.js +0 -14
- package/lib/cjs/skill.js.map +0 -1
- package/lib/cjs/store/activity-catalog.js +0 -3
- package/lib/cjs/store/activity-catalog.js.map +0 -1
- package/lib/cjs/store/collections.js +0 -9
- package/lib/cjs/store/collections.js.map +0 -1
- package/lib/cjs/store/common.js +0 -3
- package/lib/cjs/store/common.js.map +0 -1
- package/lib/cjs/store/doc-analyzer.js +0 -3
- package/lib/cjs/store/doc-analyzer.js.map +0 -1
- package/lib/cjs/store/dsl-workflow.js +0 -5
- package/lib/cjs/store/dsl-workflow.js.map +0 -1
- package/lib/cjs/store/index.js +0 -28
- package/lib/cjs/store/index.js.map +0 -1
- package/lib/cjs/store/object-types.js +0 -98
- package/lib/cjs/store/object-types.js.map +0 -1
- package/lib/cjs/store/signals.js +0 -3
- package/lib/cjs/store/signals.js.map +0 -1
- package/lib/cjs/store/store.js +0 -55
- package/lib/cjs/store/store.js.map +0 -1
- package/lib/cjs/store/temporalio.js +0 -44
- package/lib/cjs/store/temporalio.js.map +0 -1
- package/lib/cjs/store/worker.js +0 -3
- package/lib/cjs/store/worker.js.map +0 -1
- package/lib/cjs/store/workflow.js +0 -49
- package/lib/cjs/store/workflow.js.map +0 -1
- package/lib/cjs/sts-token-types.js +0 -32
- package/lib/cjs/sts-token-types.js.map +0 -1
- package/lib/cjs/tenant.js +0 -3
- package/lib/cjs/tenant.js.map +0 -1
- package/lib/cjs/training.js +0 -14
- package/lib/cjs/training.js.map +0 -1
- package/lib/cjs/transient-tokens.js +0 -9
- package/lib/cjs/transient-tokens.js.map +0 -1
- package/lib/cjs/user.js +0 -25
- package/lib/cjs/user.js.map +0 -1
- package/lib/cjs/utils/auth.js +0 -15
- package/lib/cjs/utils/auth.js.map +0 -1
- package/lib/cjs/utils/schemas.js +0 -114
- package/lib/cjs/utils/schemas.js.map +0 -1
- package/lib/cjs/utils/type-helpers.js +0 -3
- package/lib/cjs/utils/type-helpers.js.map +0 -1
- package/lib/cjs/versions.js +0 -8
- package/lib/cjs/versions.js.map +0 -1
- package/lib/esm/Progress.js +0 -57
- package/lib/esm/Progress.js.map +0 -1
- package/lib/esm/access-control.js +0 -53
- package/lib/esm/access-control.js.map +0 -1
- package/lib/esm/analytics.js +0 -2
- package/lib/esm/analytics.js.map +0 -1
- package/lib/esm/apikey.js +0 -13
- package/lib/esm/apikey.js.map +0 -1
- package/lib/esm/apps.js +0 -2
- package/lib/esm/apps.js.map +0 -1
- package/lib/esm/common.js +0 -2
- package/lib/esm/common.js.map +0 -1
- package/lib/esm/environment.js +0 -41
- package/lib/esm/environment.js.map +0 -1
- package/lib/esm/facets.js +0 -2
- package/lib/esm/facets.js.map +0 -1
- package/lib/esm/group.js +0 -2
- package/lib/esm/group.js.map +0 -1
- package/lib/esm/index.js +0 -33
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/integrations.js +0 -9
- package/lib/esm/integrations.js.map +0 -1
- package/lib/esm/interaction.js +0 -71
- package/lib/esm/interaction.js.map +0 -1
- package/lib/esm/json-schema.js +0 -2
- package/lib/esm/json-schema.js.map +0 -1
- package/lib/esm/json.js +0 -2
- package/lib/esm/json.js.map +0 -1
- package/lib/esm/meters.js +0 -10
- package/lib/esm/meters.js.map +0 -1
- package/lib/esm/model_utility.js +0 -2
- package/lib/esm/model_utility.js.map +0 -1
- package/lib/esm/payload.js +0 -2
- package/lib/esm/payload.js.map +0 -1
- package/lib/esm/project.js +0 -102
- package/lib/esm/project.js.map +0 -1
- package/lib/esm/prompt.js +0 -17
- package/lib/esm/prompt.js.map +0 -1
- package/lib/esm/query.js +0 -2
- package/lib/esm/query.js.map +0 -1
- package/lib/esm/rate-limiter.js +0 -5
- package/lib/esm/rate-limiter.js.map +0 -1
- package/lib/esm/refs.js +0 -11
- package/lib/esm/refs.js.map +0 -1
- package/lib/esm/runs.js +0 -2
- package/lib/esm/runs.js.map +0 -1
- package/lib/esm/skill.js +0 -13
- package/lib/esm/skill.js.map +0 -1
- package/lib/esm/store/activity-catalog.js +0 -2
- package/lib/esm/store/activity-catalog.js.map +0 -1
- package/lib/esm/store/collections.js +0 -6
- package/lib/esm/store/collections.js.map +0 -1
- package/lib/esm/store/common.js +0 -2
- package/lib/esm/store/common.js.map +0 -1
- package/lib/esm/store/doc-analyzer.js +0 -2
- package/lib/esm/store/doc-analyzer.js.map +0 -1
- package/lib/esm/store/dsl-workflow.js +0 -2
- package/lib/esm/store/dsl-workflow.js.map +0 -1
- package/lib/esm/store/index.js +0 -12
- package/lib/esm/store/index.js.map +0 -1
- package/lib/esm/store/object-types.js +0 -95
- package/lib/esm/store/object-types.js.map +0 -1
- package/lib/esm/store/signals.js +0 -2
- package/lib/esm/store/signals.js.map +0 -1
- package/lib/esm/store/store.js +0 -52
- package/lib/esm/store/store.js.map +0 -1
- package/lib/esm/store/temporalio.js +0 -41
- package/lib/esm/store/temporalio.js.map +0 -1
- package/lib/esm/store/worker.js +0 -2
- package/lib/esm/store/worker.js.map +0 -1
- package/lib/esm/store/workflow.js +0 -45
- package/lib/esm/store/workflow.js.map +0 -1
- package/lib/esm/sts-token-types.js +0 -24
- package/lib/esm/sts-token-types.js.map +0 -1
- package/lib/esm/tenant.js +0 -2
- package/lib/esm/tenant.js.map +0 -1
- package/lib/esm/training.js +0 -11
- package/lib/esm/training.js.map +0 -1
- package/lib/esm/transient-tokens.js +0 -6
- package/lib/esm/transient-tokens.js.map +0 -1
- package/lib/esm/user.js +0 -22
- package/lib/esm/user.js.map +0 -1
- package/lib/esm/utils/auth.js +0 -11
- package/lib/esm/utils/auth.js.map +0 -1
- package/lib/esm/utils/schemas.js +0 -107
- package/lib/esm/utils/schemas.js.map +0 -1
- package/lib/esm/utils/type-helpers.js +0 -2
- package/lib/esm/utils/type-helpers.js.map +0 -1
- package/lib/esm/versions.js +0 -5
- package/lib/esm/versions.js.map +0 -1
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/lib/types/Progress.d.ts +0 -21
- package/lib/types/Progress.d.ts.map +0 -1
- package/lib/types/access-control.d.ts +0 -73
- package/lib/types/access-control.d.ts.map +0 -1
- package/lib/types/analytics.d.ts +0 -85
- package/lib/types/analytics.d.ts.map +0 -1
- package/lib/types/apikey.d.ts +0 -80
- package/lib/types/apikey.d.ts.map +0 -1
- package/lib/types/apps.d.ts +0 -102
- package/lib/types/apps.d.ts.map +0 -1
- package/lib/types/common.d.ts +0 -31
- package/lib/types/common.d.ts.map +0 -1
- package/lib/types/environment.d.ts +0 -106
- package/lib/types/environment.d.ts.map +0 -1
- package/lib/types/facets.d.ts +0 -34
- package/lib/types/facets.d.ts.map +0 -1
- package/lib/types/group.d.ts +0 -21
- package/lib/types/group.d.ts.map +0 -1
- package/lib/types/index.d.ts +0 -33
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/integrations.d.ts +0 -28
- package/lib/types/integrations.d.ts.map +0 -1
- package/lib/types/interaction.d.ts +0 -727
- package/lib/types/interaction.d.ts.map +0 -1
- package/lib/types/json-schema.d.ts +0 -1
- package/lib/types/json-schema.d.ts.map +0 -1
- package/lib/types/json.d.ts +0 -1
- package/lib/types/json.d.ts.map +0 -1
- package/lib/types/meters.d.ts +0 -23
- package/lib/types/meters.d.ts.map +0 -1
- package/lib/types/model_utility.d.ts +0 -1
- package/lib/types/model_utility.d.ts.map +0 -1
- package/lib/types/payload.d.ts +0 -60
- package/lib/types/payload.d.ts.map +0 -1
- package/lib/types/project.d.ts +0 -173
- package/lib/types/project.d.ts.map +0 -1
- package/lib/types/prompt.d.ts +0 -77
- package/lib/types/prompt.d.ts.map +0 -1
- package/lib/types/query.d.ts +0 -118
- package/lib/types/query.d.ts.map +0 -1
- package/lib/types/rate-limiter.d.ts +0 -28
- package/lib/types/rate-limiter.d.ts.map +0 -1
- package/lib/types/refs.d.ts +0 -22
- package/lib/types/refs.d.ts.map +0 -1
- package/lib/types/runs.d.ts +0 -32
- package/lib/types/runs.d.ts.map +0 -1
- package/lib/types/skill.d.ts +0 -78
- package/lib/types/skill.d.ts.map +0 -1
- package/lib/types/store/activity-catalog.d.ts +0 -26
- package/lib/types/store/activity-catalog.d.ts.map +0 -1
- package/lib/types/store/collections.d.ts +0 -78
- package/lib/types/store/collections.d.ts.map +0 -1
- package/lib/types/store/common.d.ts +0 -22
- package/lib/types/store/common.d.ts.map +0 -1
- package/lib/types/store/doc-analyzer.d.ts +0 -140
- package/lib/types/store/doc-analyzer.d.ts.map +0 -1
- package/lib/types/store/dsl-workflow.d.ts +0 -238
- package/lib/types/store/dsl-workflow.d.ts.map +0 -1
- package/lib/types/store/index.d.ts +0 -11
- package/lib/types/store/index.d.ts.map +0 -1
- package/lib/types/store/object-types.d.ts +0 -23
- package/lib/types/store/object-types.d.ts.map +0 -1
- package/lib/types/store/signals.d.ts +0 -5
- package/lib/types/store/signals.d.ts.map +0 -1
- package/lib/types/store/store.d.ts +0 -358
- package/lib/types/store/store.d.ts.map +0 -1
- package/lib/types/store/temporalio.d.ts +0 -16
- package/lib/types/store/temporalio.d.ts.map +0 -1
- package/lib/types/store/worker.d.ts +0 -18
- package/lib/types/store/worker.d.ts.map +0 -1
- package/lib/types/store/workflow.d.ts +0 -439
- package/lib/types/store/workflow.d.ts.map +0 -1
- package/lib/types/sts-token-types.d.ts +0 -72
- package/lib/types/sts-token-types.d.ts.map +0 -1
- package/lib/types/tenant.d.ts +0 -10
- package/lib/types/tenant.d.ts.map +0 -1
- package/lib/types/training.d.ts +0 -38
- package/lib/types/training.d.ts.map +0 -1
- package/lib/types/transient-tokens.d.ts +0 -24
- package/lib/types/transient-tokens.d.ts.map +0 -1
- package/lib/types/user.d.ts +0 -116
- package/lib/types/user.d.ts.map +0 -1
- package/lib/types/utils/auth.d.ts +0 -3
- package/lib/types/utils/auth.d.ts.map +0 -1
- package/lib/types/utils/schemas.d.ts +0 -9
- package/lib/types/utils/schemas.d.ts.map +0 -1
- package/lib/types/utils/type-helpers.d.ts +0 -3
- package/lib/types/utils/type-helpers.d.ts.map +0 -1
- package/lib/types/versions.d.ts +0 -3
- package/lib/types/versions.d.ts.map +0 -1
- package/lib/vertesia-common.js +0 -2
- package/lib/vertesia-common.js.map +0 -1
package/src/store/workflow.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JSONSchema4 } from "json-schema";
|
|
2
|
-
import { ConversationVisibility, InteractionRef } from "../interaction.js";
|
|
2
|
+
import { ConversationVisibility, InteractionRef, UserChannel } from "../interaction.js";
|
|
3
3
|
|
|
4
4
|
export enum ContentEventName {
|
|
5
5
|
create = "create",
|
|
@@ -19,6 +19,15 @@ export interface Queue {
|
|
|
19
19
|
queue_full_name?: string; // full name
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
export interface WorkflowAncestor {
|
|
23
|
+
run_id: string;
|
|
24
|
+
workflow_id: string;
|
|
25
|
+
/**
|
|
26
|
+
* the depth of nested parent workflows
|
|
27
|
+
*/
|
|
28
|
+
run_depth: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
22
31
|
export interface WorkflowExecutionBaseParams<T = Record<string, any>> {
|
|
23
32
|
/**
|
|
24
33
|
* The ref of the user who initiated the workflow.
|
|
@@ -69,14 +78,20 @@ export interface WorkflowExecutionBaseParams<T = Record<string, any>> {
|
|
|
69
78
|
notify_endpoints?: (string | WebHookSpec)[];
|
|
70
79
|
|
|
71
80
|
/** If this is a child workflow, parent contains parent's ids */
|
|
72
|
-
parent?:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
parent?: WorkflowAncestor;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Full ancestry chain from root to immediate parent (for hierarchical aggregation)
|
|
85
|
+
*/
|
|
86
|
+
ancestors?: WorkflowAncestor[]
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* If true, copy workspace artifacts (scripts/, files/, skills/, docs/, out/)
|
|
90
|
+
* from parent workflow to this workflow on startup.
|
|
91
|
+
* Defaults to true when spawning child workflows.
|
|
92
|
+
* conversation.json and tools.json are never copied.
|
|
93
|
+
*/
|
|
94
|
+
inherit_artifacts?: boolean;
|
|
80
95
|
|
|
81
96
|
/**
|
|
82
97
|
* List of enabled processing queues. Managed by the application.
|
|
@@ -185,6 +200,13 @@ export interface ExecuteWorkflowPayload {
|
|
|
185
200
|
* Timeout for the workflow execution to complete, in seconds.
|
|
186
201
|
*/
|
|
187
202
|
timeout?: number; //timeout in seconds
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Schedule the workflow to run at a specific time (ISO 8601 datetime).
|
|
206
|
+
* Example: "2024-02-15T16:00:00Z"
|
|
207
|
+
* If in the past or not provided, workflow runs immediately.
|
|
208
|
+
*/
|
|
209
|
+
run_at?: string;
|
|
188
210
|
}
|
|
189
211
|
|
|
190
212
|
export interface ListWorkflowRunsPayload {
|
|
@@ -251,11 +273,44 @@ export interface ListWorkflowRunsPayload {
|
|
|
251
273
|
* The page token for Temporal pagination.
|
|
252
274
|
*/
|
|
253
275
|
next_page_token?: string;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Filter by whether the workflow has reported errors (TemporalReportedProblems).
|
|
279
|
+
*/
|
|
280
|
+
has_reported_errors?: boolean;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Signal event properties for workflow events
|
|
285
|
+
*/
|
|
286
|
+
export interface SignalEventProperties {
|
|
287
|
+
direction: 'receiving' | 'sending';
|
|
288
|
+
signalName?: string;
|
|
289
|
+
input?: any;
|
|
290
|
+
sender?: {
|
|
291
|
+
workflowId?: string;
|
|
292
|
+
runId?: string;
|
|
293
|
+
};
|
|
294
|
+
recipient?: {
|
|
295
|
+
workflowId?: string;
|
|
296
|
+
runId?: string;
|
|
297
|
+
};
|
|
298
|
+
initiatedEventId?: string;
|
|
254
299
|
}
|
|
255
300
|
|
|
256
|
-
|
|
301
|
+
/**
|
|
302
|
+
* Error information from failed workflow events
|
|
303
|
+
*/
|
|
304
|
+
export interface EventError {
|
|
305
|
+
message?: string;
|
|
306
|
+
source?: string;
|
|
307
|
+
stacktrace?: string;
|
|
308
|
+
type?: string;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
export interface WorkflowRunEvent {
|
|
257
312
|
event_id: number;
|
|
258
|
-
event_time:
|
|
313
|
+
event_time: string | null;
|
|
259
314
|
event_type: string;
|
|
260
315
|
task_id?: string;
|
|
261
316
|
attempt: number;
|
|
@@ -278,31 +333,90 @@ interface WorkflowRunEvent {
|
|
|
278
333
|
result?: any,
|
|
279
334
|
};
|
|
280
335
|
|
|
281
|
-
signal?:
|
|
282
|
-
direction: "receiving" | "sending";
|
|
283
|
-
signalName?: string,
|
|
284
|
-
input?: any,
|
|
285
|
-
sender?: {
|
|
286
|
-
workflowId?: string,
|
|
287
|
-
runId?: string
|
|
288
|
-
}
|
|
289
|
-
recipient?: {
|
|
290
|
-
workflowId?: string,
|
|
291
|
-
runId?: string
|
|
292
|
-
},
|
|
293
|
-
initiatedEventId?: string,
|
|
294
|
-
}
|
|
336
|
+
signal?: SignalEventProperties;
|
|
295
337
|
|
|
296
|
-
error?:
|
|
297
|
-
message?: string;
|
|
298
|
-
source?: string;
|
|
299
|
-
stacktrace?: string;
|
|
300
|
-
type?: string;
|
|
301
|
-
};
|
|
338
|
+
error?: EventError;
|
|
302
339
|
|
|
303
340
|
result?: any;
|
|
304
341
|
}
|
|
305
342
|
|
|
343
|
+
// Task status enum for processed history
|
|
344
|
+
export enum TaskStatus {
|
|
345
|
+
SCHEDULED = 'scheduled',
|
|
346
|
+
RUNNING = 'running',
|
|
347
|
+
COMPLETED = 'completed',
|
|
348
|
+
FAILED = 'failed',
|
|
349
|
+
CANCELED = 'canceled',
|
|
350
|
+
TIMED_OUT = 'timed_out',
|
|
351
|
+
TERMINATED = 'terminated',
|
|
352
|
+
SENT = 'sent', // for signals
|
|
353
|
+
RECEIVED = 'received', // for signals
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// Task type enum
|
|
357
|
+
export enum TaskType {
|
|
358
|
+
ACTIVITY = 'activity',
|
|
359
|
+
CHILD_WORKFLOW = 'childWorkflow',
|
|
360
|
+
SIGNAL = 'signal',
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// Base task interface
|
|
364
|
+
interface TaskBase {
|
|
365
|
+
type: TaskType;
|
|
366
|
+
activityId: string;
|
|
367
|
+
activityName?: string;
|
|
368
|
+
input?: any;
|
|
369
|
+
scheduled: string | null;
|
|
370
|
+
status: TaskStatus;
|
|
371
|
+
attempts: number;
|
|
372
|
+
started: string | null;
|
|
373
|
+
completed: string | null;
|
|
374
|
+
error: string | null;
|
|
375
|
+
result: any;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// Activity-specific task
|
|
379
|
+
export interface ActivityTask extends TaskBase {
|
|
380
|
+
type: TaskType.ACTIVITY;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// Child workflow-specific task
|
|
384
|
+
export interface ChildWorkflowTask extends TaskBase {
|
|
385
|
+
type: TaskType.CHILD_WORKFLOW;
|
|
386
|
+
workflowType?: string;
|
|
387
|
+
runId?: string;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// Signal-specific task
|
|
391
|
+
export interface SignalTask extends TaskBase {
|
|
392
|
+
type: TaskType.SIGNAL;
|
|
393
|
+
signalName?: string;
|
|
394
|
+
direction?: 'sending' | 'receiving';
|
|
395
|
+
sender?: {
|
|
396
|
+
workflowId?: string;
|
|
397
|
+
runId?: string;
|
|
398
|
+
};
|
|
399
|
+
recipient?: {
|
|
400
|
+
workflowId?: string;
|
|
401
|
+
runId?: string;
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// Union type for all processed tasks
|
|
406
|
+
export type WorkflowTask =
|
|
407
|
+
| ActivityTask
|
|
408
|
+
| ChildWorkflowTask
|
|
409
|
+
| SignalTask;
|
|
410
|
+
|
|
411
|
+
// History format discriminated union
|
|
412
|
+
export type WorkflowHistory =
|
|
413
|
+
| { type: 'events'; events: WorkflowRunEvent[] }
|
|
414
|
+
| { type: 'tasks'; tasks: WorkflowTask[] }
|
|
415
|
+
| { type: 'agent'; data: any }; // Placeholder for future agent format
|
|
416
|
+
|
|
417
|
+
// History format query parameter type
|
|
418
|
+
export type HistoryFormat = 'events' | 'tasks' | 'agent';
|
|
419
|
+
|
|
306
420
|
export interface WorkflowRun {
|
|
307
421
|
status?: WorkflowExecutionStatus | string;
|
|
308
422
|
/**
|
|
@@ -311,8 +425,8 @@ export interface WorkflowRun {
|
|
|
311
425
|
* @see https://docs.temporal.io/workflows
|
|
312
426
|
*/
|
|
313
427
|
type?: string;
|
|
314
|
-
started_at
|
|
315
|
-
closed_at
|
|
428
|
+
started_at: string | null;
|
|
429
|
+
closed_at: string | null;
|
|
316
430
|
execution_duration?: number;
|
|
317
431
|
run_id?: string;
|
|
318
432
|
workflow_id?: string;
|
|
@@ -321,6 +435,7 @@ export interface WorkflowRun {
|
|
|
321
435
|
input?: any;
|
|
322
436
|
result?: any;
|
|
323
437
|
error?: any,
|
|
438
|
+
has_reported_errors?: boolean;
|
|
324
439
|
raw?: any;
|
|
325
440
|
/**
|
|
326
441
|
* The Vertesia Workflow Type of this Workflow Run.
|
|
@@ -345,19 +460,21 @@ export interface WorkflowRun {
|
|
|
345
460
|
topic?: string;
|
|
346
461
|
}
|
|
347
462
|
|
|
463
|
+
export interface PendingActivity {
|
|
464
|
+
activityId?: string;
|
|
465
|
+
activityType?: string;
|
|
466
|
+
attempt: number;
|
|
467
|
+
maximumAttempts: number;
|
|
468
|
+
lastFailure?: string;
|
|
469
|
+
lastStartedTime: string | null;
|
|
470
|
+
}
|
|
471
|
+
|
|
348
472
|
export interface WorkflowRunWithDetails extends WorkflowRun {
|
|
349
|
-
history?:
|
|
473
|
+
history?: WorkflowHistory;
|
|
350
474
|
memo?: {
|
|
351
475
|
[key: string]: any;
|
|
352
476
|
} | null;
|
|
353
|
-
pendingActivities?:
|
|
354
|
-
activityId?: string;
|
|
355
|
-
activityType?: string;
|
|
356
|
-
attempt: number;
|
|
357
|
-
maximumAttempts: number;
|
|
358
|
-
lastFailure?: string;
|
|
359
|
-
lastStartedTime?: number;
|
|
360
|
-
}[];
|
|
477
|
+
pendingActivities?: PendingActivity[];
|
|
361
478
|
}
|
|
362
479
|
export interface ListWorkflowRunsResponse {
|
|
363
480
|
runs: WorkflowRun[];
|
|
@@ -376,6 +493,11 @@ export interface WorkflowInteractionVars {
|
|
|
376
493
|
interaction: string,
|
|
377
494
|
interactive: boolean,
|
|
378
495
|
debug_mode?: boolean,
|
|
496
|
+
/**
|
|
497
|
+
* Array of channels to use for user communication.
|
|
498
|
+
* Multiple channels can be active simultaneously.
|
|
499
|
+
*/
|
|
500
|
+
user_channels?: UserChannel[],
|
|
379
501
|
data?: Record<string, any>,
|
|
380
502
|
tool_names: string[],
|
|
381
503
|
config: {
|
|
@@ -442,18 +564,369 @@ export interface AgentMessage {
|
|
|
442
564
|
}
|
|
443
565
|
|
|
444
566
|
export enum AgentMessageType {
|
|
445
|
-
SYSTEM =
|
|
446
|
-
THOUGHT =
|
|
447
|
-
PLAN =
|
|
448
|
-
UPDATE =
|
|
449
|
-
COMPLETE =
|
|
450
|
-
WARNING =
|
|
567
|
+
SYSTEM = 0,
|
|
568
|
+
THOUGHT = 1,
|
|
569
|
+
PLAN = 2,
|
|
570
|
+
UPDATE = 3,
|
|
571
|
+
COMPLETE = 4,
|
|
572
|
+
WARNING = 5,
|
|
573
|
+
ERROR = 6,
|
|
574
|
+
ANSWER = 7,
|
|
575
|
+
QUESTION = 8,
|
|
576
|
+
REQUEST_INPUT = 9,
|
|
577
|
+
IDLE = 10,
|
|
578
|
+
TERMINATED = 11,
|
|
579
|
+
STREAMING_CHUNK = 12,
|
|
580
|
+
BATCH_PROGRESS = 13,
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Details for STREAMING_CHUNK messages used for real-time LLM response streaming
|
|
585
|
+
* @deprecated Use CompactMessage with f field for streaming chunks
|
|
586
|
+
*/
|
|
587
|
+
export interface StreamingChunkDetails {
|
|
588
|
+
/** Unique identifier grouping chunks from the same stream */
|
|
589
|
+
streaming_id: string;
|
|
590
|
+
/** Order of this chunk within the stream (0-indexed) */
|
|
591
|
+
chunk_index: number;
|
|
592
|
+
/** True if this is the final chunk of the stream */
|
|
593
|
+
is_final: boolean;
|
|
594
|
+
/** Activity ID for deduplication with final THOUGHT/ANSWER message */
|
|
595
|
+
activity_id?: string;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
// ============================================
|
|
599
|
+
// COMPACT MESSAGE FORMAT
|
|
600
|
+
// ============================================
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Compact message format for efficient wire transfer.
|
|
604
|
+
* Primary type used throughout the system.
|
|
605
|
+
* ~85% smaller than legacy AgentMessage format.
|
|
606
|
+
*/
|
|
607
|
+
export interface CompactMessage {
|
|
608
|
+
/** Message type (integer enum) */
|
|
609
|
+
t: AgentMessageType;
|
|
610
|
+
/** Message content */
|
|
611
|
+
m?: string;
|
|
612
|
+
/** Workstream ID (only when not "main") */
|
|
613
|
+
w?: string;
|
|
614
|
+
/** Type-specific details */
|
|
615
|
+
d?: unknown;
|
|
616
|
+
/** Is final chunk (only for STREAMING_CHUNK, 0 or 1) */
|
|
617
|
+
f?: 0 | 1;
|
|
618
|
+
/** Timestamp (only for stored/persisted messages) */
|
|
619
|
+
ts?: number;
|
|
620
|
+
/** Activity ID for deduplication between streaming chunks and final messages */
|
|
621
|
+
i?: string;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* Legacy message format for backward compatibility.
|
|
626
|
+
* @deprecated Use CompactMessage instead
|
|
627
|
+
*/
|
|
628
|
+
export type LegacyAgentMessage = AgentMessage;
|
|
629
|
+
|
|
630
|
+
// ============================================
|
|
631
|
+
// TYPE GUARDS
|
|
632
|
+
// ============================================
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Check if a message is in compact format
|
|
636
|
+
*/
|
|
637
|
+
export function isCompactMessage(msg: unknown): msg is CompactMessage {
|
|
638
|
+
return typeof msg === 'object' && msg !== null && 't' in msg;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* Check if a message is in legacy format
|
|
643
|
+
*/
|
|
644
|
+
export function isLegacyMessage(msg: unknown): msg is LegacyAgentMessage {
|
|
645
|
+
return typeof msg === 'object' && msg !== null && 'type' in msg && !('t' in msg);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
// ============================================
|
|
649
|
+
// CONVERTERS
|
|
650
|
+
// ============================================
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Map old string enum values to AgentMessageType
|
|
654
|
+
*/
|
|
655
|
+
const STRING_TO_TYPE_MAP: Record<string, AgentMessageType> = {
|
|
656
|
+
'system': AgentMessageType.SYSTEM,
|
|
657
|
+
'thought': AgentMessageType.THOUGHT,
|
|
658
|
+
'plan': AgentMessageType.PLAN,
|
|
659
|
+
'update': AgentMessageType.UPDATE,
|
|
660
|
+
'complete': AgentMessageType.COMPLETE,
|
|
661
|
+
'warning': AgentMessageType.WARNING,
|
|
662
|
+
'error': AgentMessageType.ERROR,
|
|
663
|
+
'answer': AgentMessageType.ANSWER,
|
|
664
|
+
'question': AgentMessageType.QUESTION,
|
|
665
|
+
'request_input': AgentMessageType.REQUEST_INPUT,
|
|
666
|
+
'idle': AgentMessageType.IDLE,
|
|
667
|
+
'terminated': AgentMessageType.TERMINATED,
|
|
668
|
+
'streaming_chunk': AgentMessageType.STREAMING_CHUNK,
|
|
669
|
+
'batch_progress': AgentMessageType.BATCH_PROGRESS,
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* Map integer values to AgentMessageType (primary format)
|
|
674
|
+
*/
|
|
675
|
+
const INT_TO_TYPE_MAP: Record<number, AgentMessageType> = {
|
|
676
|
+
0: AgentMessageType.SYSTEM,
|
|
677
|
+
1: AgentMessageType.THOUGHT,
|
|
678
|
+
2: AgentMessageType.PLAN,
|
|
679
|
+
3: AgentMessageType.UPDATE,
|
|
680
|
+
4: AgentMessageType.COMPLETE,
|
|
681
|
+
5: AgentMessageType.WARNING,
|
|
682
|
+
6: AgentMessageType.ERROR,
|
|
683
|
+
7: AgentMessageType.ANSWER,
|
|
684
|
+
8: AgentMessageType.QUESTION,
|
|
685
|
+
9: AgentMessageType.REQUEST_INPUT,
|
|
686
|
+
10: AgentMessageType.IDLE,
|
|
687
|
+
11: AgentMessageType.TERMINATED,
|
|
688
|
+
12: AgentMessageType.STREAMING_CHUNK,
|
|
689
|
+
13: AgentMessageType.BATCH_PROGRESS,
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* Normalize message type from string or number to AgentMessageType
|
|
694
|
+
*/
|
|
695
|
+
export function normalizeMessageType(type: string | number | AgentMessageType): AgentMessageType {
|
|
696
|
+
// Handle integer type (current format and AgentMessageType enum values)
|
|
697
|
+
if (typeof type === 'number') {
|
|
698
|
+
return INT_TO_TYPE_MAP[type] ?? AgentMessageType.UPDATE;
|
|
699
|
+
}
|
|
700
|
+
// Handle string type (legacy messages from Redis with 90-day TTL)
|
|
701
|
+
if (typeof type === 'string') {
|
|
702
|
+
return STRING_TO_TYPE_MAP[type] ?? AgentMessageType.UPDATE;
|
|
703
|
+
}
|
|
704
|
+
return AgentMessageType.UPDATE;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* Convert legacy AgentMessage to CompactMessage
|
|
709
|
+
*/
|
|
710
|
+
export function toCompactMessage(legacy: LegacyAgentMessage): CompactMessage {
|
|
711
|
+
const compact: CompactMessage = {
|
|
712
|
+
t: normalizeMessageType(legacy.type),
|
|
713
|
+
};
|
|
714
|
+
|
|
715
|
+
if (legacy.message) compact.m = legacy.message;
|
|
716
|
+
if (legacy.workstream_id && legacy.workstream_id !== 'main') compact.w = legacy.workstream_id;
|
|
717
|
+
if (legacy.timestamp) compact.ts = legacy.timestamp;
|
|
718
|
+
|
|
719
|
+
// Handle legacy streaming chunk details
|
|
720
|
+
if (compact.t === AgentMessageType.STREAMING_CHUNK && legacy.details) {
|
|
721
|
+
const d = legacy.details as StreamingChunkDetails;
|
|
722
|
+
if (d.is_final) compact.f = 1;
|
|
723
|
+
// streaming_id and chunk_index are no longer needed
|
|
724
|
+
} else if (legacy.details) {
|
|
725
|
+
compact.d = legacy.details;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
return compact;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* Parse any message format (compact or legacy) into CompactMessage.
|
|
733
|
+
* Use this as the entry point for all received messages.
|
|
734
|
+
*/
|
|
735
|
+
export function parseMessage(data: string | object): CompactMessage {
|
|
736
|
+
const parsed = typeof data === 'string' ? JSON.parse(data) : data;
|
|
737
|
+
if (isCompactMessage(parsed)) return parsed;
|
|
738
|
+
if (isLegacyMessage(parsed)) return toCompactMessage(parsed);
|
|
739
|
+
throw new Error('Unknown message format');
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* Create a compact message (convenience function for server-side)
|
|
744
|
+
*/
|
|
745
|
+
export function createCompactMessage(
|
|
746
|
+
type: AgentMessageType,
|
|
747
|
+
options: {
|
|
748
|
+
message?: string;
|
|
749
|
+
workstreamId?: string;
|
|
750
|
+
details?: unknown;
|
|
751
|
+
isFinal?: boolean;
|
|
752
|
+
timestamp?: number;
|
|
753
|
+
} = {}
|
|
754
|
+
): CompactMessage {
|
|
755
|
+
const compact: CompactMessage = { t: type };
|
|
756
|
+
|
|
757
|
+
if (options.message) compact.m = options.message;
|
|
758
|
+
if (options.workstreamId && options.workstreamId !== 'main') compact.w = options.workstreamId;
|
|
759
|
+
if (options.details) compact.d = options.details;
|
|
760
|
+
if (options.isFinal) compact.f = 1;
|
|
761
|
+
if (options.timestamp) compact.ts = options.timestamp;
|
|
762
|
+
|
|
763
|
+
return compact;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* Convert CompactMessage back to AgentMessage (for UI components).
|
|
768
|
+
* This allows UI to continue using familiar field names while wire format is compact.
|
|
769
|
+
* @param compact The compact message to convert
|
|
770
|
+
* @param workflowRunId Optional workflow_run_id (known from SSE context, not in compact format)
|
|
771
|
+
*/
|
|
772
|
+
export function toAgentMessage(compact: CompactMessage, workflowRunId: string = ''): AgentMessage {
|
|
773
|
+
const message: AgentMessage = {
|
|
774
|
+
type: compact.t,
|
|
775
|
+
timestamp: compact.ts || Date.now(),
|
|
776
|
+
workflow_run_id: workflowRunId,
|
|
777
|
+
message: compact.m || '',
|
|
778
|
+
workstream_id: compact.w || 'main',
|
|
779
|
+
};
|
|
780
|
+
|
|
781
|
+
if (compact.d !== undefined) message.details = compact.d;
|
|
782
|
+
|
|
783
|
+
// For streaming chunks, restore is_final and streaming_id in details
|
|
784
|
+
// (streaming_id removed from wire format, use workstream_id as grouping key)
|
|
785
|
+
if (compact.t === AgentMessageType.STREAMING_CHUNK) {
|
|
786
|
+
message.details = {
|
|
787
|
+
...(typeof compact.d === 'object' ? compact.d : {}),
|
|
788
|
+
streaming_id: compact.w || 'main', // Use workstream_id as streaming_id
|
|
789
|
+
is_final: compact.f === 1,
|
|
790
|
+
activity_id: compact.i, // For deduplication with final THOUGHT/ANSWER
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
return message;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* Status of a single item in a batch execution
|
|
799
|
+
*/
|
|
800
|
+
export interface BatchItemStatus {
|
|
801
|
+
/** Unique identifier for this batch item */
|
|
802
|
+
id: string;
|
|
803
|
+
/** Current status of the item */
|
|
804
|
+
status: "pending" | "running" | "success" | "error";
|
|
805
|
+
/** Optional message (e.g., error message or result summary) */
|
|
806
|
+
message?: string;
|
|
807
|
+
/** Execution duration in milliseconds (when completed) */
|
|
808
|
+
duration_ms?: number;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* Details for BATCH_PROGRESS messages used for batch tool execution progress
|
|
813
|
+
*/
|
|
814
|
+
export interface BatchProgressDetails {
|
|
815
|
+
/** Unique identifier for this batch execution */
|
|
816
|
+
batch_id: string;
|
|
817
|
+
/** Name of the tool being batch executed */
|
|
818
|
+
tool_name: string;
|
|
819
|
+
/** Total number of items in the batch */
|
|
820
|
+
total: number;
|
|
821
|
+
/** Number of items completed */
|
|
822
|
+
completed: number;
|
|
823
|
+
/** Number of items that succeeded */
|
|
824
|
+
succeeded: number;
|
|
825
|
+
/** Number of items that failed */
|
|
826
|
+
failed: number;
|
|
827
|
+
/** Status of individual items */
|
|
828
|
+
items: BatchItemStatus[];
|
|
829
|
+
/** Timestamp when batch started */
|
|
830
|
+
started_at: number;
|
|
831
|
+
/** Timestamp when batch completed (if done) */
|
|
832
|
+
completed_at?: number;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* Status of a file being processed for conversation use.
|
|
837
|
+
*/
|
|
838
|
+
export enum FileProcessingStatus {
|
|
839
|
+
/** File is being uploaded to artifact storage */
|
|
840
|
+
UPLOADING = "uploading",
|
|
841
|
+
/** File uploaded, text extraction in progress */
|
|
842
|
+
PROCESSING = "processing",
|
|
843
|
+
/** File is ready for use in conversation */
|
|
844
|
+
READY = "ready",
|
|
845
|
+
/** File processing failed */
|
|
451
846
|
ERROR = "error",
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
/**
|
|
850
|
+
* Represents a file being processed in a conversation workflow.
|
|
851
|
+
*/
|
|
852
|
+
export interface ConversationFile {
|
|
853
|
+
/** Unique ID for tracking this file (generated client-side) */
|
|
854
|
+
id: string;
|
|
855
|
+
/** Original filename */
|
|
856
|
+
name: string;
|
|
857
|
+
/** MIME type */
|
|
858
|
+
content_type: string;
|
|
859
|
+
/** Size in bytes */
|
|
860
|
+
size: number;
|
|
861
|
+
/** Current processing status */
|
|
862
|
+
status: FileProcessingStatus;
|
|
863
|
+
/** Artifact path (e.g., "files/document.pdf") - set after upload */
|
|
864
|
+
artifact_path?: string;
|
|
865
|
+
/** Full artifact reference URI (e.g., "artifact:files/document.pdf") */
|
|
866
|
+
reference?: string;
|
|
867
|
+
/** Path to extracted text markdown (e.g., "files/document.pdf.md") */
|
|
868
|
+
md_path?: string;
|
|
869
|
+
/** Whether text extraction completed successfully */
|
|
870
|
+
text_extracted?: boolean;
|
|
871
|
+
/** Error message if status is ERROR */
|
|
872
|
+
error?: string;
|
|
873
|
+
/** Timestamp when upload started */
|
|
874
|
+
started_at: number;
|
|
875
|
+
/** Timestamp when processing completed */
|
|
876
|
+
completed_at?: number;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* Details for file processing SYSTEM messages.
|
|
881
|
+
* Used when type is AgentMessageType.SYSTEM with system_type: 'file_processing'.
|
|
882
|
+
*/
|
|
883
|
+
export interface FileProcessingDetails {
|
|
884
|
+
/** Discriminator for SYSTEM message subtypes */
|
|
885
|
+
system_type: 'file_processing';
|
|
886
|
+
/** Batch ID for grouping related file operations */
|
|
887
|
+
batch_id: string;
|
|
888
|
+
/** All files in this batch with their current status */
|
|
889
|
+
files: ConversationFile[];
|
|
890
|
+
/** Number of files still being processed */
|
|
891
|
+
pending_count: number;
|
|
892
|
+
/** Number of files ready for use */
|
|
893
|
+
ready_count: number;
|
|
894
|
+
/** Number of files that failed */
|
|
895
|
+
error_count: number;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* Reference to a file uploaded via the UI for conversation use.
|
|
900
|
+
*/
|
|
901
|
+
export interface ConversationFileRef {
|
|
902
|
+
/** Client-generated unique ID */
|
|
903
|
+
id: string;
|
|
904
|
+
/** Original filename */
|
|
905
|
+
name: string;
|
|
906
|
+
/** MIME type */
|
|
907
|
+
content_type: string;
|
|
908
|
+
/** Artifact reference (e.g., "artifact:files/document.pdf") */
|
|
909
|
+
reference: string;
|
|
910
|
+
/** Artifact path without prefix (e.g., "files/document.pdf") */
|
|
911
|
+
artifact_path: string;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
/**
|
|
915
|
+
* Get the Redis pub/sub channel name for workflow messages.
|
|
916
|
+
* Used by both publishers (workflow activities, studio-server) and subscribers (zeno-server, clients).
|
|
917
|
+
* @param workflowRunId - The Temporal workflow run ID (NOT the interaction execution run ID)
|
|
918
|
+
*/
|
|
919
|
+
export function getWorkflowChannel(workflowRunId: string): string {
|
|
920
|
+
return `workflow:${workflowRunId}:channel`;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
* Get the Redis list key for storing workflow message history.
|
|
925
|
+
* Messages are stored here for retrieval by reconnecting clients.
|
|
926
|
+
* @param workflowRunId - The Temporal workflow run ID (NOT the interaction execution run ID)
|
|
927
|
+
*/
|
|
928
|
+
export function getWorkflowUpdatesKey(workflowRunId: string): string {
|
|
929
|
+
return `workflow:${workflowRunId}:updates`;
|
|
457
930
|
}
|
|
458
931
|
|
|
459
932
|
export interface PlanTask {
|
|
@@ -519,3 +992,89 @@ export interface WorkflowActionPayload {
|
|
|
519
992
|
*/
|
|
520
993
|
reason?: string;
|
|
521
994
|
}
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
* Parameters for the AgentIntakeWorkflow.
|
|
998
|
+
* This workflow uses an intelligent agent to process documents:
|
|
999
|
+
* - Select or create appropriate content types
|
|
1000
|
+
* - Extract properties using schema-enforced interactions
|
|
1001
|
+
* - File documents into relevant collections
|
|
1002
|
+
*/
|
|
1003
|
+
export interface AgentIntakeWorkflowParams {
|
|
1004
|
+
/**
|
|
1005
|
+
* The interaction to use for document intake agent.
|
|
1006
|
+
* Defaults to "sys:DocumentIntakeAgent" if not specified.
|
|
1007
|
+
* Can be overridden with a project-level interaction.
|
|
1008
|
+
*/
|
|
1009
|
+
intakeInteraction?: string;
|
|
1010
|
+
|
|
1011
|
+
/**
|
|
1012
|
+
* The interaction to use for property extraction.
|
|
1013
|
+
* Defaults to "sys:ExtractInformation" if not specified.
|
|
1014
|
+
* Can be overridden with a project-level interaction.
|
|
1015
|
+
*/
|
|
1016
|
+
extractionInteraction?: string;
|
|
1017
|
+
|
|
1018
|
+
/**
|
|
1019
|
+
* Whether to generate table of contents for documents.
|
|
1020
|
+
* Defaults to true for documents, false for images/videos.
|
|
1021
|
+
*/
|
|
1022
|
+
generateTableOfContents?: boolean;
|
|
1023
|
+
|
|
1024
|
+
/**
|
|
1025
|
+
* Whether to generate embeddings after processing.
|
|
1026
|
+
* Defaults to true.
|
|
1027
|
+
*/
|
|
1028
|
+
generateEmbeddings?: boolean;
|
|
1029
|
+
|
|
1030
|
+
/**
|
|
1031
|
+
* Max iterations for the agent workflow.
|
|
1032
|
+
* Defaults to 50.
|
|
1033
|
+
*/
|
|
1034
|
+
maxIterations?: number;
|
|
1035
|
+
|
|
1036
|
+
/**
|
|
1037
|
+
* Environment ID for LLM execution.
|
|
1038
|
+
*/
|
|
1039
|
+
environment?: string;
|
|
1040
|
+
|
|
1041
|
+
/**
|
|
1042
|
+
* Model to use for the agent.
|
|
1043
|
+
*/
|
|
1044
|
+
model?: string;
|
|
1045
|
+
|
|
1046
|
+
/**
|
|
1047
|
+
* Additional model options.
|
|
1048
|
+
*/
|
|
1049
|
+
model_options?: Record<string, unknown>;
|
|
1050
|
+
|
|
1051
|
+
/**
|
|
1052
|
+
* Whether to use semantic layer (MagicPDF) for PDF processing.
|
|
1053
|
+
*/
|
|
1054
|
+
useSemanticLayer?: boolean;
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* Whether to use vision for image-based extraction.
|
|
1058
|
+
*/
|
|
1059
|
+
useVision?: boolean;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
/**
|
|
1063
|
+
* Result of the AgentIntakeWorkflow
|
|
1064
|
+
*/
|
|
1065
|
+
export interface AgentIntakeWorkflowResult {
|
|
1066
|
+
/** The object ID that was processed */
|
|
1067
|
+
objectId: string;
|
|
1068
|
+
/** Whether text was extracted */
|
|
1069
|
+
hasText: boolean;
|
|
1070
|
+
/** Whether table of contents was generated */
|
|
1071
|
+
hasTableOfContents: boolean;
|
|
1072
|
+
/** The type ID assigned to the document */
|
|
1073
|
+
typeId?: string;
|
|
1074
|
+
/** Whether properties were extracted */
|
|
1075
|
+
hasProperties: boolean;
|
|
1076
|
+
/** Collection IDs the document was added to */
|
|
1077
|
+
collectionIds?: string[];
|
|
1078
|
+
/** Whether embeddings were generated */
|
|
1079
|
+
hasEmbeddings: boolean;
|
|
1080
|
+
}
|