@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/email.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Email-related types for agent communication and routing.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// ================= User Communication Channels ====================
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Email channel configuration with threading support.
|
|
9
|
+
* Used for email-based agent communication.
|
|
10
|
+
*/
|
|
11
|
+
export interface EmailChannel {
|
|
12
|
+
type: "email";
|
|
13
|
+
/** Email address to send agent messages to */
|
|
14
|
+
to_email: string;
|
|
15
|
+
/** Subject for the email thread (without "Re:" prefix) */
|
|
16
|
+
thread_subject?: string;
|
|
17
|
+
/** Message ID for In-Reply-To header (most recent message) */
|
|
18
|
+
in_reply_to?: string;
|
|
19
|
+
/** Chain of message IDs for References header */
|
|
20
|
+
references?: string[];
|
|
21
|
+
/** Short routing key for reply emails (8-char alphanumeric, stored in Redis) */
|
|
22
|
+
route_key?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Interactive (UI chat) channel configuration.
|
|
27
|
+
* Used for real-time chat interface communication.
|
|
28
|
+
*/
|
|
29
|
+
export interface InteractiveChannel {
|
|
30
|
+
type: "interactive";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Union of all supported user communication channel types.
|
|
35
|
+
*/
|
|
36
|
+
export type UserChannel = EmailChannel | InteractiveChannel;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Type guard for email channels
|
|
40
|
+
*/
|
|
41
|
+
export function isEmailChannel(channel: UserChannel): channel is EmailChannel {
|
|
42
|
+
return channel.type === "email";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Type guard for interactive channels
|
|
47
|
+
*/
|
|
48
|
+
export function isInteractiveChannel(channel: UserChannel): channel is InteractiveChannel {
|
|
49
|
+
return channel.type === "interactive";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ================= Email Routing ====================
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Data stored in Redis for email route keys.
|
|
56
|
+
* Used to map short route keys (8-char) to workflow context for email replies.
|
|
57
|
+
*
|
|
58
|
+
* Short keys are used instead of full UUIDs in reply email addresses to avoid
|
|
59
|
+
* Gmail flagging emails as unsafe due to long random-looking strings.
|
|
60
|
+
*
|
|
61
|
+
* Pattern: r+{routeKey}@{domain} instead of r+{32-char-uuid}@{domain}
|
|
62
|
+
*/
|
|
63
|
+
export interface EmailRouteData {
|
|
64
|
+
/** The workflow run ID */
|
|
65
|
+
runId: string;
|
|
66
|
+
/** Account ID for quick project lookup */
|
|
67
|
+
accountId: string;
|
|
68
|
+
/** Project ID for quick config lookup */
|
|
69
|
+
projectId: string;
|
|
70
|
+
/** Email thread subject (without "Re:" prefix) */
|
|
71
|
+
threadSubject?: string;
|
|
72
|
+
/** Message ID for In-Reply-To header (last message in thread) */
|
|
73
|
+
inReplyTo?: string;
|
|
74
|
+
/** Chain of message IDs for References header */
|
|
75
|
+
references?: string[];
|
|
76
|
+
/** User's email address (recipient of agent emails, sender of replies) */
|
|
77
|
+
userEmail: string;
|
|
78
|
+
/** Inbound domain for filtering (e.g., inbound.vertesia.io) */
|
|
79
|
+
inboundDomain: string;
|
|
80
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -2,12 +2,16 @@ export * from './access-control.js';
|
|
|
2
2
|
export * from './analytics.js';
|
|
3
3
|
export * from './apikey.js';
|
|
4
4
|
export * from './apps.js';
|
|
5
|
+
export * from './ask-user.js';
|
|
6
|
+
export * from './channels.js';
|
|
5
7
|
export * from './common.js';
|
|
8
|
+
export * from './data-platform.js';
|
|
6
9
|
export * from './environment.js';
|
|
7
10
|
export * from "./facets.js";
|
|
8
11
|
export * from './group.js';
|
|
9
12
|
export * from './integrations.js';
|
|
10
13
|
export * from './interaction.js';
|
|
14
|
+
export * from './pending-asks.js';
|
|
11
15
|
export * from './json-schema.js';
|
|
12
16
|
export * from './json.js';
|
|
13
17
|
export * from './meters.js';
|
|
@@ -22,13 +26,15 @@ export * from './refs.js';
|
|
|
22
26
|
export * from './runs.js';
|
|
23
27
|
export * from './skill.js';
|
|
24
28
|
export * from "./store/index.js";
|
|
29
|
+
export * from './sts-token-types.js';
|
|
25
30
|
export * from './tenant.js';
|
|
31
|
+
export * from './tool-execution.js';
|
|
26
32
|
export * from "./training.js";
|
|
27
33
|
export * from './transient-tokens.js';
|
|
28
34
|
export * from './user.js';
|
|
29
35
|
export * from './utils/auth.js';
|
|
30
36
|
export * from './utils/schemas.js';
|
|
31
37
|
export type * from './utils/type-helpers.js';
|
|
32
|
-
export * from './sts-token-types.js';
|
|
33
38
|
export * from './versions.js';
|
|
39
|
+
export * from './workflow-analytics.js';
|
|
34
40
|
|
package/src/integrations.ts
CHANGED
|
@@ -29,10 +29,44 @@ export interface SerperConfiguration extends IntegrationConfigurationBase {
|
|
|
29
29
|
url?: string;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
export interface ResendConfiguration extends IntegrationConfigurationBase {
|
|
33
|
+
/** Resend API key for sending emails */
|
|
34
|
+
api_key: string;
|
|
35
|
+
/** Domain for email (both sending and receiving). Must be verified in Resend. */
|
|
36
|
+
email_domain: string;
|
|
37
|
+
/** Default display name for outgoing emails (e.g., "Vertesia - Project Name") */
|
|
38
|
+
default_from_name?: string;
|
|
39
|
+
/** Webhook secret for validating inbound email webhooks (required for receiving emails) */
|
|
40
|
+
webhook_secret: string;
|
|
41
|
+
/** Domains allowed to send emails TO start agents (for inbound validation) */
|
|
42
|
+
allowed_sender_domains?: string[];
|
|
43
|
+
/** Require sender to have project access to start agents via email (default: true) */
|
|
44
|
+
require_project_access?: boolean;
|
|
45
|
+
/** Require DKIM/SPF authentication to pass for inbound emails (default: true) */
|
|
46
|
+
require_email_auth?: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Configuration for ask_user webhook notifications.
|
|
51
|
+
* Sends webhooks when agents call ask_user and when users respond.
|
|
52
|
+
*/
|
|
53
|
+
export interface AskUserWebhookConfiguration extends IntegrationConfigurationBase {
|
|
54
|
+
/** Webhook URL to receive ask_user events */
|
|
55
|
+
webhook_url: string;
|
|
56
|
+
/** Secret for signing webhook payloads (HMAC-SHA256) */
|
|
57
|
+
webhook_secret?: string;
|
|
58
|
+
/** Which events to send: ['requested', 'resolved'] or subset (default: both) */
|
|
59
|
+
events?: ('requested' | 'resolved')[];
|
|
60
|
+
/** Custom headers to include in webhook requests */
|
|
61
|
+
custom_headers?: Record<string, string>;
|
|
62
|
+
}
|
|
63
|
+
|
|
32
64
|
export enum SupportedIntegrations {
|
|
33
65
|
gladia = "gladia",
|
|
34
66
|
github = "github",
|
|
35
67
|
aws = "aws",
|
|
36
68
|
magic_pdf = "magic_pdf",
|
|
37
69
|
serper = "serper",
|
|
70
|
+
resend = "resend",
|
|
71
|
+
ask_user_webhook = "ask_user_webhook",
|
|
38
72
|
}
|
package/src/interaction.ts
CHANGED
|
@@ -24,7 +24,9 @@ import {
|
|
|
24
24
|
TemplateType,
|
|
25
25
|
} from "./prompt.js";
|
|
26
26
|
import { ExecutionRunDocRef } from "./runs.js";
|
|
27
|
+
import { ConversationState } from "./store/conversation-state.js";
|
|
27
28
|
import { AccountRef } from "./user.js";
|
|
29
|
+
import { LlmCallType } from "./workflow-analytics.js";
|
|
28
30
|
|
|
29
31
|
export interface InteractionExecutionError {
|
|
30
32
|
code: string;
|
|
@@ -32,6 +34,27 @@ export interface InteractionExecutionError {
|
|
|
32
34
|
data?: any;
|
|
33
35
|
}
|
|
34
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Configuration for stripping large data from conversation history
|
|
39
|
+
* to prevent JSON serialization issues and reduce storage bloat.
|
|
40
|
+
*/
|
|
41
|
+
export interface ConversationStripOptions {
|
|
42
|
+
/**
|
|
43
|
+
* Number of turns to keep images before stripping them.
|
|
44
|
+
* - 0: Strip images immediately after each turn (default)
|
|
45
|
+
* - N > 0: Keep images for N turns before stripping
|
|
46
|
+
* - Infinity: Never strip images
|
|
47
|
+
*/
|
|
48
|
+
images_after_turns?: number;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Maximum tokens for text content before truncation.
|
|
52
|
+
* Text content exceeding this limit will be truncated with a marker.
|
|
53
|
+
* Uses ~4 characters per token estimate.
|
|
54
|
+
*/
|
|
55
|
+
text_max_tokens?: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
35
58
|
|
|
36
59
|
// ------------------ in code interactions -----------------
|
|
37
60
|
/**
|
|
@@ -496,6 +519,12 @@ export interface InteractionExecutionPayload {
|
|
|
496
519
|
* These are temporary interactions using "tmp:" suffix.
|
|
497
520
|
*/
|
|
498
521
|
prompts?: InCodePrompt[];
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Options for async completion and/or streaming LLM response chunks to Redis.
|
|
525
|
+
* Used by agent workflows for async activity completion and real-time streaming.
|
|
526
|
+
*/
|
|
527
|
+
asyncCompletion?: AsyncCompletionOptions;
|
|
499
528
|
}
|
|
500
529
|
|
|
501
530
|
export interface NamedInteractionExecutionPayload extends InteractionExecutionPayload {
|
|
@@ -609,6 +638,22 @@ export interface AgentRunnerOptions {
|
|
|
609
638
|
collection_id?: string;
|
|
610
639
|
}
|
|
611
640
|
|
|
641
|
+
// ================= User Communication Channels ====================
|
|
642
|
+
// Import for local use
|
|
643
|
+
import type { UserChannel } from "./email.js";
|
|
644
|
+
// Re-exported from email.ts for backwards compatibility
|
|
645
|
+
export type {
|
|
646
|
+
EmailChannel,
|
|
647
|
+
InteractiveChannel,
|
|
648
|
+
UserChannel,
|
|
649
|
+
EmailRouteData,
|
|
650
|
+
} from "./email.js";
|
|
651
|
+
export {
|
|
652
|
+
isEmailChannel,
|
|
653
|
+
isInteractiveChannel,
|
|
654
|
+
} from "./email.js";
|
|
655
|
+
// ================= end user communication channels ====================
|
|
656
|
+
|
|
612
657
|
export interface AsyncConversationExecutionPayload extends AsyncExecutionPayloadBase {
|
|
613
658
|
type: "conversation";
|
|
614
659
|
|
|
@@ -634,6 +679,13 @@ export interface AsyncConversationExecutionPayload extends AsyncExecutionPayload
|
|
|
634
679
|
*/
|
|
635
680
|
interactive?: boolean;
|
|
636
681
|
|
|
682
|
+
/**
|
|
683
|
+
* Array of channels to use for user communication.
|
|
684
|
+
* Multiple channels can be active simultaneously (e.g., both email and interactive).
|
|
685
|
+
* Each channel contains its own configuration and state (e.g., email threading info).
|
|
686
|
+
*/
|
|
687
|
+
user_channels?: UserChannel[];
|
|
688
|
+
|
|
637
689
|
/**
|
|
638
690
|
* Whether to disable the generation of interaction tools or not.
|
|
639
691
|
*/
|
|
@@ -657,6 +709,12 @@ export interface AsyncConversationExecutionPayload extends AsyncExecutionPayload
|
|
|
657
709
|
*/
|
|
658
710
|
checkpoint_tokens?: number;
|
|
659
711
|
|
|
712
|
+
/**
|
|
713
|
+
* Configuration for stripping large data (images, text) from conversation history
|
|
714
|
+
* to prevent JSON serialization issues and reduce storage bloat.
|
|
715
|
+
*/
|
|
716
|
+
strip_options?: ConversationStripOptions;
|
|
717
|
+
|
|
660
718
|
/** In child execution workflow, this is the curent task_id */
|
|
661
719
|
task_id?: string;
|
|
662
720
|
|
|
@@ -666,6 +724,14 @@ export interface AsyncConversationExecutionPayload extends AsyncExecutionPayload
|
|
|
666
724
|
/** Maximum depth for nested conversations to prevent infinite recursion (default: 5) */
|
|
667
725
|
max_nested_conversation_depth?: number;
|
|
668
726
|
|
|
727
|
+
/**
|
|
728
|
+
* Metadata inherited from parent workflow.
|
|
729
|
+
* Used to propagate context (e.g., apiKey, session info) to child workflows/workstreams.
|
|
730
|
+
* When a workstream is spawned, the parent's `data` is preserved here so that
|
|
731
|
+
* child tools can access it via metadata.parent_metadata.
|
|
732
|
+
*/
|
|
733
|
+
parent_metadata?: Record<string, any>;
|
|
734
|
+
|
|
669
735
|
}
|
|
670
736
|
|
|
671
737
|
export interface AsyncInteractionExecutionPayload extends AsyncExecutionPayloadBase {
|
|
@@ -680,12 +746,99 @@ export interface AsyncInteractionExecutionPayload extends AsyncExecutionPayloadB
|
|
|
680
746
|
|
|
681
747
|
export type AsyncExecutionPayload = AsyncConversationExecutionPayload | AsyncInteractionExecutionPayload;
|
|
682
748
|
|
|
749
|
+
/**
|
|
750
|
+
* Telemetry context for streaming mode.
|
|
751
|
+
* Contains info not available in current_state needed to send LlmCallEvent.
|
|
752
|
+
*/
|
|
753
|
+
export interface StreamingTelemetryContext {
|
|
754
|
+
/** Workflow ID for ingestEvents API call */
|
|
755
|
+
workflowId: string;
|
|
756
|
+
/** Type of LLM call: start, resume after user message, or resume after tool results */
|
|
757
|
+
callType: LlmCallType;
|
|
758
|
+
/** Activity retry attempt number */
|
|
759
|
+
attemptNumber?: number;
|
|
760
|
+
/** Timestamp when inference started (for duration calculation) */
|
|
761
|
+
inferenceStartTime: number;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
/**
|
|
765
|
+
* Options for storing inference results to cloud storage
|
|
766
|
+
*/
|
|
767
|
+
export interface ResultStorageOptions {
|
|
768
|
+
/** Full storage path for the result (e.g., "pages/doc123/page-1.md") */
|
|
769
|
+
path: string;
|
|
770
|
+
// Note: content_type is inferred from execution context:
|
|
771
|
+
// - If result_schema → application/json
|
|
772
|
+
// - Otherwise → text/markdown or text/plain
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* Streaming-specific options (only needed when stream=true)
|
|
777
|
+
*/
|
|
778
|
+
export interface StreamingOptions {
|
|
779
|
+
/** Redis channel to publish streaming chunks to */
|
|
780
|
+
redis_channel: string;
|
|
781
|
+
/** Optional workstream ID for multi-workstream agents */
|
|
782
|
+
workstream_id?: string;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* Options for async completion and/or streaming LLM responses
|
|
787
|
+
*/
|
|
788
|
+
export interface AsyncCompletionOptions {
|
|
789
|
+
/** Workflow run ID for message context */
|
|
790
|
+
run_id: string;
|
|
791
|
+
/** Whether to stream chunks to Redis */
|
|
792
|
+
stream?: boolean;
|
|
793
|
+
/** Streaming-specific options (required if stream=true) */
|
|
794
|
+
streaming?: StreamingOptions;
|
|
795
|
+
/**
|
|
796
|
+
* Temporal task token for async activity completion (base64url encoded).
|
|
797
|
+
* When provided, Studio will complete the activity after execution finishes,
|
|
798
|
+
* allowing the worker to release the activity slot immediately.
|
|
799
|
+
*/
|
|
800
|
+
task_token?: string;
|
|
801
|
+
/**
|
|
802
|
+
* Activity ID for idempotency metadata when storing conversation.
|
|
803
|
+
* Required when task_token is provided.
|
|
804
|
+
*/
|
|
805
|
+
activity_id?: string;
|
|
806
|
+
/**
|
|
807
|
+
* Current conversation state to merge with execution result.
|
|
808
|
+
* Studio will store the conversation and complete the activity with merged state.
|
|
809
|
+
* Required when task_token is provided.
|
|
810
|
+
*/
|
|
811
|
+
current_state?: ConversationState;
|
|
812
|
+
/**
|
|
813
|
+
* Interval in milliseconds for sending heartbeats to Temporal during streaming.
|
|
814
|
+
* When provided, Studio will send periodic heartbeats to keep the activity alive.
|
|
815
|
+
* Recommended: 10000 (10 seconds). Activity heartbeat timeout should be ~3x this value.
|
|
816
|
+
*/
|
|
817
|
+
heartbeat_interval_ms?: number;
|
|
818
|
+
/**
|
|
819
|
+
* Telemetry context for sending LlmCallEvent after streaming completes.
|
|
820
|
+
* Studio will use this to send token usage telemetry since the activity
|
|
821
|
+
* exits before the response is available in async completion mode.
|
|
822
|
+
*/
|
|
823
|
+
telemetry?: StreamingTelemetryContext;
|
|
824
|
+
/**
|
|
825
|
+
* Storage options for inference result.
|
|
826
|
+
* When provided, Studio will store the result to the specified path
|
|
827
|
+
* after inference completes (before completing the Temporal activity).
|
|
828
|
+
*/
|
|
829
|
+
result_storage?: ResultStorageOptions;
|
|
830
|
+
}
|
|
831
|
+
|
|
683
832
|
interface ResumeConversationPayload {
|
|
684
833
|
run: ExecutionRunDocRef; // the run created by the first execution.
|
|
685
834
|
environment: string; // the environment ID
|
|
686
835
|
options: StatelessExecutionOptions; // the options used on the first execution
|
|
687
836
|
conversation: unknown; // the conversation state
|
|
688
837
|
tools: ToolDefinition[]; // the tools to be used
|
|
838
|
+
/** Configuration for stripping large data from conversation history */
|
|
839
|
+
strip_options?: ConversationStripOptions;
|
|
840
|
+
/** Options for async completion and/or streaming LLM response chunks to Redis */
|
|
841
|
+
asyncCompletion?: AsyncCompletionOptions;
|
|
689
842
|
}
|
|
690
843
|
|
|
691
844
|
|
|
@@ -693,6 +846,12 @@ export interface ToolResultContent {
|
|
|
693
846
|
content: string;
|
|
694
847
|
is_error: boolean;
|
|
695
848
|
files?: string[];
|
|
849
|
+
/**
|
|
850
|
+
* Optional message to display in the UI instead of the content.
|
|
851
|
+
* Use this when the content is large or technical (e.g., document text)
|
|
852
|
+
* and you want to show a friendly message to the user.
|
|
853
|
+
*/
|
|
854
|
+
display_message?: string;
|
|
696
855
|
/**
|
|
697
856
|
* Can contain metadata returned by the tool executor.
|
|
698
857
|
*/
|
|
@@ -701,6 +860,11 @@ export interface ToolResultContent {
|
|
|
701
860
|
|
|
702
861
|
export interface ToolResult extends ToolResultContent {
|
|
703
862
|
tool_use_id: string;
|
|
863
|
+
/**
|
|
864
|
+
* Gemini thinking models require thought_signature to be passed back with tool results.
|
|
865
|
+
* Copy this from the ToolUse.thought_signature that requested this tool call.
|
|
866
|
+
*/
|
|
867
|
+
thought_signature?: string;
|
|
704
868
|
}
|
|
705
869
|
|
|
706
870
|
/**
|
|
@@ -760,7 +924,7 @@ export interface BaseExecutionRun<P = any> {
|
|
|
760
924
|
interaction?: string | Interaction;
|
|
761
925
|
// only set when the target interaction is an in-code interaction
|
|
762
926
|
interaction_code?: string; // Interaction code name in case of in-code interaction (not stored in the DB as an Interaction document)
|
|
763
|
-
|
|
927
|
+
/** Environment reference - populated with full object in API responses */
|
|
764
928
|
environment: ExecutionEnvironmentRef;
|
|
765
929
|
modelId: string;
|
|
766
930
|
result_schema: JSONSchema4;
|
|
@@ -907,4 +1071,119 @@ export interface RateLimitRequestPayload {
|
|
|
907
1071
|
|
|
908
1072
|
export interface RateLimitRequestResponse {
|
|
909
1073
|
delay_ms: number;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
/**
|
|
1077
|
+
* Source of the resolved model configuration
|
|
1078
|
+
*/
|
|
1079
|
+
export enum ModelSource {
|
|
1080
|
+
/** Model was explicitly provided in the execution config */
|
|
1081
|
+
config = "config",
|
|
1082
|
+
/** Model comes from the interaction definition */
|
|
1083
|
+
interaction = "interaction",
|
|
1084
|
+
/** Model comes from environment's default_model */
|
|
1085
|
+
environmentDefault = "environmentDefault",
|
|
1086
|
+
/** Model comes from project system interaction defaults */
|
|
1087
|
+
projectSystemDefault = "projectSystemDefault",
|
|
1088
|
+
/** Model comes from project base defaults */
|
|
1089
|
+
projectBaseDefault = "projectBaseDefault",
|
|
1090
|
+
/** Model comes from project modality-specific defaults */
|
|
1091
|
+
projectModalityDefault = "projectModalityDefault",
|
|
1092
|
+
/** Model comes from legacy project defaults */
|
|
1093
|
+
projectLegacyDefault = "projectLegacyDefault",
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
/**
|
|
1097
|
+
* Resolved environment information
|
|
1098
|
+
*/
|
|
1099
|
+
export interface ResolvedEnvironmentInfo {
|
|
1100
|
+
id: string;
|
|
1101
|
+
name: string;
|
|
1102
|
+
provider: string;
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
/**
|
|
1106
|
+
* Resolved runtime configuration for an interaction
|
|
1107
|
+
*/
|
|
1108
|
+
export interface ResolvedRuntimeConfig {
|
|
1109
|
+
environment: ResolvedEnvironmentInfo;
|
|
1110
|
+
model?: string;
|
|
1111
|
+
model_source: ModelSource;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
/**
|
|
1115
|
+
* Resolved execution info for an interaction.
|
|
1116
|
+
* Contains the interaction ID, basic metadata, and the resolved runtime configuration
|
|
1117
|
+
* (environment, model) that would be used at execution time.
|
|
1118
|
+
*/
|
|
1119
|
+
export interface ResolvedInteractionExecutionInfo {
|
|
1120
|
+
/**
|
|
1121
|
+
* The resolved interaction ID
|
|
1122
|
+
*/
|
|
1123
|
+
id: string;
|
|
1124
|
+
|
|
1125
|
+
/**
|
|
1126
|
+
* The interaction endpoint name
|
|
1127
|
+
*/
|
|
1128
|
+
name: string;
|
|
1129
|
+
|
|
1130
|
+
/**
|
|
1131
|
+
* The interaction version number
|
|
1132
|
+
*/
|
|
1133
|
+
version: number;
|
|
1134
|
+
|
|
1135
|
+
/**
|
|
1136
|
+
* The interaction status (draft or published)
|
|
1137
|
+
*/
|
|
1138
|
+
status: InteractionStatus;
|
|
1139
|
+
|
|
1140
|
+
/**
|
|
1141
|
+
* The interaction tags (can include version tags like "production", "staging")
|
|
1142
|
+
*/
|
|
1143
|
+
tags: string[];
|
|
1144
|
+
|
|
1145
|
+
/**
|
|
1146
|
+
* The resolved runtime configuration
|
|
1147
|
+
*/
|
|
1148
|
+
resolved: ResolvedRuntimeConfig;
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
/**
|
|
1152
|
+
* A builtin tool definition from the tools catalog
|
|
1153
|
+
*/
|
|
1154
|
+
export interface BuiltinToolDefinition {
|
|
1155
|
+
/**
|
|
1156
|
+
* The unique tool name
|
|
1157
|
+
*/
|
|
1158
|
+
name: string;
|
|
1159
|
+
|
|
1160
|
+
/**
|
|
1161
|
+
* Human-readable description of what the tool does
|
|
1162
|
+
*/
|
|
1163
|
+
description: string;
|
|
1164
|
+
|
|
1165
|
+
/**
|
|
1166
|
+
* JSON schema for the tool's parameters
|
|
1167
|
+
*/
|
|
1168
|
+
params: JSONSchema;
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
/**
|
|
1172
|
+
* Response from the builtin tools catalog endpoint
|
|
1173
|
+
*/
|
|
1174
|
+
export interface BuiltinToolsCatalogResponse {
|
|
1175
|
+
/**
|
|
1176
|
+
* List of available builtin tools
|
|
1177
|
+
*/
|
|
1178
|
+
tools: BuiltinToolDefinition[];
|
|
1179
|
+
|
|
1180
|
+
/**
|
|
1181
|
+
* When the catalog was generated
|
|
1182
|
+
*/
|
|
1183
|
+
generated_at: string;
|
|
1184
|
+
|
|
1185
|
+
/**
|
|
1186
|
+
* Total number of tools in the catalog
|
|
1187
|
+
*/
|
|
1188
|
+
total_tools: number;
|
|
910
1189
|
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for tracking pending ask_user requests and webhook notifications.
|
|
3
|
+
* Used to notify external systems when agents are waiting for user input.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { UserChannel } from "./email.js";
|
|
7
|
+
|
|
8
|
+
// ================= Pending Ask Data ====================
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Status of a pending ask request.
|
|
12
|
+
*/
|
|
13
|
+
export type PendingAskStatus = 'pending' | 'resolved' | 'expired';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Data stored in Redis for pending ask_user requests.
|
|
17
|
+
* Tracks which agents are waiting for user input and enables
|
|
18
|
+
* both webhook notifications and portal views.
|
|
19
|
+
*/
|
|
20
|
+
export interface PendingAskData {
|
|
21
|
+
/** Unique identifier for this ask (10-char alphanumeric) */
|
|
22
|
+
askId: string;
|
|
23
|
+
/** Temporal workflow run ID */
|
|
24
|
+
runId: string;
|
|
25
|
+
/** Temporal workflow ID */
|
|
26
|
+
workflowId: string;
|
|
27
|
+
/** Project ID */
|
|
28
|
+
projectId: string;
|
|
29
|
+
/** Account ID */
|
|
30
|
+
accountId: string;
|
|
31
|
+
/** Name of the agent/interaction that asked */
|
|
32
|
+
agentName: string;
|
|
33
|
+
/** Questions asked by the agent */
|
|
34
|
+
questions: string[];
|
|
35
|
+
/** Timeout in hours (default 48) */
|
|
36
|
+
timeoutHours: number;
|
|
37
|
+
/** Communication channels configured for the conversation */
|
|
38
|
+
userChannels: UserChannel[];
|
|
39
|
+
/** Timestamp when the ask was created (ms since epoch) */
|
|
40
|
+
createdAt: number;
|
|
41
|
+
/** Timestamp when the ask expires (ms since epoch) */
|
|
42
|
+
expiresAt: number;
|
|
43
|
+
/** Current status of the ask */
|
|
44
|
+
status: PendingAskStatus;
|
|
45
|
+
/** Timestamp when resolved (ms since epoch) */
|
|
46
|
+
resolvedAt?: number;
|
|
47
|
+
/** User's response (after resolution) */
|
|
48
|
+
response?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// ================= Webhook Events ====================
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Event types for ask_user webhooks.
|
|
55
|
+
*/
|
|
56
|
+
export type AskUserWebhookEventType = 'ask_user.requested' | 'ask_user.resolved';
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Simplified channel info for webhook payloads.
|
|
60
|
+
*/
|
|
61
|
+
export interface WebhookChannelInfo {
|
|
62
|
+
type: 'email' | 'interactive';
|
|
63
|
+
/** Email address (only for email channels) */
|
|
64
|
+
email?: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Webhook payload sent when ask_user events occur.
|
|
69
|
+
* Sent to configured webhook endpoints when agents request user input
|
|
70
|
+
* or when users respond.
|
|
71
|
+
*/
|
|
72
|
+
export interface AskUserWebhookEvent {
|
|
73
|
+
/** Event type */
|
|
74
|
+
event: AskUserWebhookEventType;
|
|
75
|
+
/** Timestamp of the event (ms since epoch) */
|
|
76
|
+
timestamp: number;
|
|
77
|
+
/** Unique identifier for this ask */
|
|
78
|
+
askId: string;
|
|
79
|
+
/** Temporal workflow run ID */
|
|
80
|
+
runId: string;
|
|
81
|
+
/** Temporal workflow ID */
|
|
82
|
+
workflowId: string;
|
|
83
|
+
/** Project ID */
|
|
84
|
+
projectId: string;
|
|
85
|
+
/** Name of the agent/interaction */
|
|
86
|
+
agentName: string;
|
|
87
|
+
/** Questions asked by the agent */
|
|
88
|
+
questions: string[];
|
|
89
|
+
/** Communication channels available */
|
|
90
|
+
userChannels: WebhookChannelInfo[];
|
|
91
|
+
/** User's response (only for resolved events) */
|
|
92
|
+
response?: string;
|
|
93
|
+
/** Timestamp when resolved (only for resolved events) */
|
|
94
|
+
resolvedAt?: number;
|
|
95
|
+
/** How long the agent waited for response in ms (only for resolved events) */
|
|
96
|
+
waitDurationMs?: number;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// ================= API Types ====================
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Response from listing pending asks.
|
|
103
|
+
*/
|
|
104
|
+
export interface ListPendingAsksResponse {
|
|
105
|
+
asks: PendingAskData[];
|
|
106
|
+
}
|