@dainprotocol/service-sdk 2.0.50 → 2.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/schemaStructure.js +102 -7
- package/dist/lib/schemaStructure.js.map +1 -1
- package/dist/service/hitl.d.ts +81 -0
- package/dist/service/hitl.js +219 -0
- package/dist/service/hitl.js.map +1 -0
- package/dist/service/index.d.ts +2 -1
- package/dist/service/index.js +4 -1
- package/dist/service/index.js.map +1 -1
- package/dist/service/nodeService.d.ts +3 -1
- package/dist/service/nodeService.js +8 -1
- package/dist/service/nodeService.js.map +1 -1
- package/dist/service/server.js +147 -13
- package/dist/service/server.js.map +1 -1
- package/dist/service/types.d.ts +29 -0
- package/dist/service/webhooks.d.ts +20 -0
- package/dist/service/webhooks.js +39 -7
- package/dist/service/webhooks.js.map +1 -1
- package/package.json +1 -1
|
@@ -56,6 +56,23 @@ function zodToJsonSchema(schema) {
|
|
|
56
56
|
}
|
|
57
57
|
case "ZodUnion": {
|
|
58
58
|
const options = schema.options;
|
|
59
|
+
// Check if all options are simple primitive types (string, number, boolean)
|
|
60
|
+
const allPrimitives = options.every((opt) => {
|
|
61
|
+
const typeName = getSchemaTypeName(opt);
|
|
62
|
+
return typeName === 'ZodString' || typeName === 'ZodNumber' || typeName === 'ZodBoolean';
|
|
63
|
+
});
|
|
64
|
+
if (allPrimitives) {
|
|
65
|
+
// For simple type unions, use type: ["string", "number"] format (AI SDK compatible)
|
|
66
|
+
const types = options.map((opt) => {
|
|
67
|
+
const optSchema = zodToJsonSchema(opt);
|
|
68
|
+
return optSchema.type;
|
|
69
|
+
});
|
|
70
|
+
return {
|
|
71
|
+
type: types,
|
|
72
|
+
...baseInfo,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
// For complex unions, fall back to oneOf
|
|
59
76
|
return {
|
|
60
77
|
oneOf: options.map((opt) => zodToJsonSchema(opt)),
|
|
61
78
|
...baseInfo,
|
|
@@ -65,12 +82,40 @@ function zodToJsonSchema(schema) {
|
|
|
65
82
|
case "ZodNullable":
|
|
66
83
|
case "ZodDefault": {
|
|
67
84
|
const innerType = schema._def.innerType;
|
|
68
|
-
|
|
85
|
+
const innerSchema = zodToJsonSchema(innerType);
|
|
86
|
+
// Preserve description from the wrapper if inner doesn't have one
|
|
87
|
+
if (baseInfo.description && !innerSchema.description) {
|
|
88
|
+
innerSchema.description = baseInfo.description;
|
|
89
|
+
}
|
|
90
|
+
return innerSchema;
|
|
69
91
|
}
|
|
70
92
|
case "ZodString":
|
|
71
93
|
return { type: 'string', ...baseInfo };
|
|
72
|
-
case "ZodNumber":
|
|
73
|
-
|
|
94
|
+
case "ZodNumber": {
|
|
95
|
+
const numSchema = schema;
|
|
96
|
+
const result = { type: 'number', ...baseInfo };
|
|
97
|
+
// Check if it's an integer type (using isInt property)
|
|
98
|
+
if (numSchema.isInt) {
|
|
99
|
+
result.type = 'integer';
|
|
100
|
+
}
|
|
101
|
+
// Extract min/max constraints from checks
|
|
102
|
+
const checks = numSchema._def.checks || [];
|
|
103
|
+
for (const check of checks) {
|
|
104
|
+
// Access check definition from _zod.def property
|
|
105
|
+
const checkDef = check._zod?.def || check;
|
|
106
|
+
const checkType = checkDef.check || check.kind;
|
|
107
|
+
if (checkType === 'greater_than' || checkType === 'min') {
|
|
108
|
+
result.minimum = checkDef.value ?? check.value;
|
|
109
|
+
}
|
|
110
|
+
else if (checkType === 'less_than' || checkType === 'max') {
|
|
111
|
+
result.maximum = checkDef.value ?? check.value;
|
|
112
|
+
}
|
|
113
|
+
else if (checkType === 'number_format' && checkDef.format === 'safeint') {
|
|
114
|
+
result.type = 'integer';
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
74
119
|
case "ZodBoolean":
|
|
75
120
|
return { type: 'boolean', ...baseInfo };
|
|
76
121
|
case "ZodLiteral": {
|
|
@@ -95,17 +140,66 @@ function zodToJsonSchema(schema) {
|
|
|
95
140
|
}
|
|
96
141
|
case "ZodDiscriminatedUnion": {
|
|
97
142
|
const duDef = schema._def;
|
|
143
|
+
const options = Array.isArray(duDef.options)
|
|
144
|
+
? duDef.options
|
|
145
|
+
: Array.from(duDef.options.values());
|
|
146
|
+
// Convert discriminated union to merged object schema for AI SDK compatibility
|
|
147
|
+
// AI SDK doesn't support oneOf/anyOf/allOf at top level, so we merge all properties
|
|
148
|
+
const mergedProperties = {};
|
|
149
|
+
const allRequired = new Set();
|
|
150
|
+
// Add discriminator field as required enum
|
|
151
|
+
mergedProperties[duDef.discriminator] = {
|
|
152
|
+
type: 'string',
|
|
153
|
+
enum: options.map((opt) => {
|
|
154
|
+
const optSchema = zodToJsonSchema(opt);
|
|
155
|
+
return optSchema.properties?.[duDef.discriminator]?.const ||
|
|
156
|
+
optSchema.properties?.[duDef.discriminator]?.enum?.[0];
|
|
157
|
+
}).filter(Boolean),
|
|
158
|
+
description: `Discriminator field for union type`
|
|
159
|
+
};
|
|
160
|
+
allRequired.add(duDef.discriminator);
|
|
161
|
+
// Merge all properties from all options
|
|
162
|
+
for (const option of options) {
|
|
163
|
+
const optSchema = zodToJsonSchema(option);
|
|
164
|
+
if (optSchema.properties) {
|
|
165
|
+
for (const [key, value] of Object.entries(optSchema.properties)) {
|
|
166
|
+
if (key === duDef.discriminator)
|
|
167
|
+
continue; // Skip discriminator, already handled
|
|
168
|
+
// If property already exists, make it optional (could be from different union branch)
|
|
169
|
+
if (!mergedProperties[key]) {
|
|
170
|
+
mergedProperties[key] = value;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// Don't mark properties as required if they're not in all branches
|
|
175
|
+
}
|
|
98
176
|
return {
|
|
99
|
-
|
|
100
|
-
|
|
177
|
+
type: 'object',
|
|
178
|
+
properties: mergedProperties,
|
|
179
|
+
required: Array.from(allRequired),
|
|
101
180
|
...baseInfo,
|
|
102
181
|
};
|
|
103
182
|
}
|
|
183
|
+
case "ZodEffects": {
|
|
184
|
+
// ZodEffects wraps schemas with refinements/transformations
|
|
185
|
+
// We extract the underlying schema and convert that instead
|
|
186
|
+
const innerType = schema._def.schema;
|
|
187
|
+
const innerSchema = zodToJsonSchema(innerType);
|
|
188
|
+
// Preserve description from the wrapper if inner doesn't have one
|
|
189
|
+
if (baseInfo.description && !innerSchema.description) {
|
|
190
|
+
innerSchema.description = baseInfo.description;
|
|
191
|
+
}
|
|
192
|
+
return innerSchema;
|
|
193
|
+
}
|
|
104
194
|
default:
|
|
105
195
|
return baseInfo;
|
|
106
196
|
}
|
|
107
197
|
}
|
|
108
198
|
function getSchemaTypeName(schema) {
|
|
199
|
+
// Check for ZodEffects using _def.typeName (works across Zod versions)
|
|
200
|
+
const typeName = schema._def?.typeName;
|
|
201
|
+
if (typeName === "ZodEffects")
|
|
202
|
+
return "ZodEffects";
|
|
109
203
|
if (schema instanceof zod_1.z.ZodDefault)
|
|
110
204
|
return "ZodDefault";
|
|
111
205
|
if (schema instanceof zod_1.z.ZodOptional)
|
|
@@ -116,6 +210,9 @@ function getSchemaTypeName(schema) {
|
|
|
116
210
|
return "ZodArray";
|
|
117
211
|
if (schema instanceof zod_1.z.ZodEnum)
|
|
118
212
|
return "ZodEnum";
|
|
213
|
+
// Check ZodDiscriminatedUnion before ZodUnion (discriminated unions extend unions)
|
|
214
|
+
if (schema instanceof zod_1.z.ZodDiscriminatedUnion)
|
|
215
|
+
return "ZodDiscriminatedUnion";
|
|
119
216
|
if (schema instanceof zod_1.z.ZodUnion)
|
|
120
217
|
return "ZodUnion";
|
|
121
218
|
if (schema instanceof zod_1.z.ZodObject)
|
|
@@ -132,8 +229,6 @@ function getSchemaTypeName(schema) {
|
|
|
132
229
|
return "ZodTuple";
|
|
133
230
|
if (schema instanceof zod_1.z.ZodIntersection)
|
|
134
231
|
return "ZodIntersection";
|
|
135
|
-
if (schema instanceof zod_1.z.ZodDiscriminatedUnion)
|
|
136
|
-
return "ZodDiscriminatedUnion";
|
|
137
232
|
// Add more type checks as needed
|
|
138
233
|
return "Unknown";
|
|
139
234
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaStructure.js","sourceRoot":"","sources":["../../src/lib/schemaStructure.ts"],"names":[],"mappings":";AAAA,kCAAkC;;AAOlC,
|
|
1
|
+
{"version":3,"file":"schemaStructure.js","sourceRoot":"","sources":["../../src/lib/schemaStructure.ts"],"names":[],"mappings":";AAAA,kCAAkC;;AAOlC,0CAsNC;AAED,8CA2BC;AAED,gEA0GC;AApWD,6BAAiC;AAEjC;;GAEG;AACH,SAAgB,eAAe,CAAC,MAA8B;IAC5D,MAAM,QAAQ,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAE3C,MAAM,QAAQ,GAAQ,EAAE,CAAC;IACzB,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;QACvB,QAAQ,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IAC5C,CAAC;IAED,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,WAAW,CAAC,CAAC,CAAC;YACjB,MAAM,KAAK,GAAI,MAA2B,CAAC,KAAK,CAAC;YACjD,MAAM,UAAU,GAAwB,EAAE,CAAC;YAC3C,MAAM,QAAQ,GAAa,EAAE,CAAC;YAE9B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBACjD,MAAM,WAAW,GAAG,KAA+B,CAAC;gBACpD,UAAU,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;gBAE/C,oDAAoD;gBACpD,MAAM,SAAS,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;gBACjD,IAAI,SAAS,KAAK,aAAa;oBAC3B,SAAS,KAAK,aAAa;oBAC3B,SAAS,KAAK,YAAY,EAAE,CAAC;oBAC/B,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACrB,CAAC;YACH,CAAC;YA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QAAQ;gBACX,IAAI,EAAE,0BAA0B,CAC7B,MAAsC,CAAC,IAAI,CAAC,IAAI,CAClD;gBACD,KAAK,EAAE,0BAA0B,CAC9B,MAAsC,CAAC,IAAI,CAAC,KAAK,CACnD;aACF,CAAC;QACJ,KAAK,uBAAuB,CAAC,CAAC,CAAC;YAK7B,MAAM,KAAK,GAAI,MAA4B,CAAC,IAA6B,CAAC;YAC1E,OAAO;gBACL,GAAG,QAAQ;gBACX,aAAa,EAAE,KAAK,CAAC,aAAa;gBAClC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAC7C,CAAC,MAAe,EAAE,EAAE,CAAC,0BAA0B,CAAC,MAAM,CAAC,CACxD;aACF,CAAC;QACJ,CAAC;QACD,KAAK,YAAY;YACf,OAAO;gBACL,GAAG,QAAQ;gBACX,SAAS,EAAE,0BAA0B,CAClC,MAA4B,CAAC,IAAI,CAAC,SAAS,CAC7C;gBACD,YAAY,EAAG,MAA4B,CAAC,IAAI,CAAC,YAAY;aAC9D,CAAC;QAEJ;YACE,OAAO,QAAQ,CAAC;IACpB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Human-in-the-Loop (HITL) Action Handler
|
|
3
|
+
*
|
|
4
|
+
* Provides automatic routing of action callbacks to automation-core using the
|
|
5
|
+
* Standardized Action Protocol (SAP): scope:id:action[:payload]
|
|
6
|
+
*
|
|
7
|
+
* Example actions:
|
|
8
|
+
* - run:123:approve - Approve automation run
|
|
9
|
+
* - run:123:reject - Reject automation run
|
|
10
|
+
* - user:456:ban - Ban user
|
|
11
|
+
* - payment:789:confirm - Confirm payment
|
|
12
|
+
*/
|
|
13
|
+
import { HITLContext } from './types';
|
|
14
|
+
export type { HITLContext };
|
|
15
|
+
export interface HITLConfig {
|
|
16
|
+
automationApiUrl: string;
|
|
17
|
+
automationApiKey?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface HITLResult {
|
|
20
|
+
success: boolean;
|
|
21
|
+
message: string;
|
|
22
|
+
action?: string;
|
|
23
|
+
scope?: string;
|
|
24
|
+
id?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* HITL Action Handler
|
|
28
|
+
* Routes actions to appropriate handlers based on scope
|
|
29
|
+
*/
|
|
30
|
+
export declare class HITLHandler {
|
|
31
|
+
private automationApiUrl;
|
|
32
|
+
private automationApiKey?;
|
|
33
|
+
constructor(config: HITLConfig);
|
|
34
|
+
/**
|
|
35
|
+
* Parse action data into components
|
|
36
|
+
* Format: scope:id:action[:payload]
|
|
37
|
+
*/
|
|
38
|
+
parseAction(actionData: string): {
|
|
39
|
+
scope: string;
|
|
40
|
+
id: string;
|
|
41
|
+
action: string;
|
|
42
|
+
payload?: string;
|
|
43
|
+
} | null;
|
|
44
|
+
/**
|
|
45
|
+
* Check if action data is valid
|
|
46
|
+
*/
|
|
47
|
+
isValidAction(data: string): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Route action to appropriate handler
|
|
50
|
+
*/
|
|
51
|
+
handleAction(actionData: string, context: HITLContext): Promise<HITLResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Handle run actions (automation approvals)
|
|
54
|
+
* Scope: run:{runId}:{action}
|
|
55
|
+
*/
|
|
56
|
+
private handleRunAction;
|
|
57
|
+
/**
|
|
58
|
+
* Handle user actions (moderation, etc.)
|
|
59
|
+
* Scope: user:{userId}:{action}
|
|
60
|
+
*/
|
|
61
|
+
private handleUserAction;
|
|
62
|
+
/**
|
|
63
|
+
* Handle payment actions
|
|
64
|
+
* Scope: payment:{paymentId}:{action}
|
|
65
|
+
*/
|
|
66
|
+
private handlePaymentAction;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Helper: Route action to HITL endpoint
|
|
70
|
+
*
|
|
71
|
+
* Use this in notification services to forward actions to the SDK's HITL webhook
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const result = await routeActionToService('run:123:approve', {
|
|
76
|
+
* user: { id: '456', username: 'john' },
|
|
77
|
+
* platform: 'telegram',
|
|
78
|
+
* });
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function routeActionToService(actionData: string, context: HITLContext, serviceUrl?: string): Promise<HITLResult>;
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Human-in-the-Loop (HITL) Action Handler
|
|
4
|
+
*
|
|
5
|
+
* Provides automatic routing of action callbacks to automation-core using the
|
|
6
|
+
* Standardized Action Protocol (SAP): scope:id:action[:payload]
|
|
7
|
+
*
|
|
8
|
+
* Example actions:
|
|
9
|
+
* - run:123:approve - Approve automation run
|
|
10
|
+
* - run:123:reject - Reject automation run
|
|
11
|
+
* - user:456:ban - Ban user
|
|
12
|
+
* - payment:789:confirm - Confirm payment
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.HITLHandler = void 0;
|
|
16
|
+
exports.routeActionToService = routeActionToService;
|
|
17
|
+
/**
|
|
18
|
+
* HITL Action Handler
|
|
19
|
+
* Routes actions to appropriate handlers based on scope
|
|
20
|
+
*/
|
|
21
|
+
class HITLHandler {
|
|
22
|
+
automationApiUrl;
|
|
23
|
+
automationApiKey;
|
|
24
|
+
constructor(config) {
|
|
25
|
+
this.automationApiUrl = config.automationApiUrl;
|
|
26
|
+
this.automationApiKey = config.automationApiKey;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Parse action data into components
|
|
30
|
+
* Format: scope:id:action[:payload]
|
|
31
|
+
*/
|
|
32
|
+
parseAction(actionData) {
|
|
33
|
+
const parts = actionData.split(':');
|
|
34
|
+
if (parts.length < 3) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
scope: parts[0],
|
|
39
|
+
id: parts[1],
|
|
40
|
+
action: parts[2],
|
|
41
|
+
payload: parts.length > 3 ? parts.slice(3).join(':') : undefined,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Check if action data is valid
|
|
46
|
+
*/
|
|
47
|
+
isValidAction(data) {
|
|
48
|
+
return this.parseAction(data) !== null;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Route action to appropriate handler
|
|
52
|
+
*/
|
|
53
|
+
async handleAction(actionData, context) {
|
|
54
|
+
const parsed = this.parseAction(actionData);
|
|
55
|
+
if (!parsed) {
|
|
56
|
+
return {
|
|
57
|
+
success: false,
|
|
58
|
+
message: 'Invalid action format. Expected: scope:id:action[:payload]',
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const { scope, id, action, payload } = parsed;
|
|
62
|
+
console.log(`[HITL] Routing action: ${actionData}`, {
|
|
63
|
+
scope,
|
|
64
|
+
id,
|
|
65
|
+
action,
|
|
66
|
+
payload,
|
|
67
|
+
platform: context.platform,
|
|
68
|
+
user: context.user?.username || context.user?.id,
|
|
69
|
+
});
|
|
70
|
+
// Route based on scope
|
|
71
|
+
switch (scope) {
|
|
72
|
+
case 'run':
|
|
73
|
+
return await this.handleRunAction(id, action, payload, context);
|
|
74
|
+
case 'user':
|
|
75
|
+
return await this.handleUserAction(id, action, payload, context);
|
|
76
|
+
case 'payment':
|
|
77
|
+
return await this.handlePaymentAction(id, action, payload, context);
|
|
78
|
+
default:
|
|
79
|
+
return {
|
|
80
|
+
success: false,
|
|
81
|
+
message: `Unknown action scope: ${scope}`,
|
|
82
|
+
scope,
|
|
83
|
+
id,
|
|
84
|
+
action,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Handle run actions (automation approvals)
|
|
90
|
+
* Scope: run:{runId}:{action}
|
|
91
|
+
*/
|
|
92
|
+
async handleRunAction(runId, action, payload, context) {
|
|
93
|
+
try {
|
|
94
|
+
// Call automation-core API to submit input
|
|
95
|
+
const url = `${this.automationApiUrl}/api/runs/${runId}/input`;
|
|
96
|
+
const headers = {
|
|
97
|
+
'Content-Type': 'application/json',
|
|
98
|
+
};
|
|
99
|
+
if (this.automationApiKey) {
|
|
100
|
+
headers['Authorization'] = `Bearer ${this.automationApiKey}`;
|
|
101
|
+
}
|
|
102
|
+
const response = await fetch(url, {
|
|
103
|
+
method: 'POST',
|
|
104
|
+
headers,
|
|
105
|
+
body: JSON.stringify({
|
|
106
|
+
decision: action,
|
|
107
|
+
user: context.user,
|
|
108
|
+
platform: context.platform,
|
|
109
|
+
metadata: context.metadata,
|
|
110
|
+
payload: payload ? JSON.parse(payload) : undefined,
|
|
111
|
+
}),
|
|
112
|
+
});
|
|
113
|
+
if (!response.ok) {
|
|
114
|
+
const error = await response.text();
|
|
115
|
+
console.error(`[HITL] Run action failed:`, error);
|
|
116
|
+
return {
|
|
117
|
+
success: false,
|
|
118
|
+
message: `Failed to ${action} run: ${error}`,
|
|
119
|
+
scope: 'run',
|
|
120
|
+
id: runId,
|
|
121
|
+
action,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const result = await response.json();
|
|
125
|
+
// Format action verb for message (approve -> approved, reject -> rejected)
|
|
126
|
+
const actionVerb = action.endsWith('e') ? `${action}d` : `${action}ed`;
|
|
127
|
+
return {
|
|
128
|
+
success: true,
|
|
129
|
+
message: `Run ${actionVerb} successfully`,
|
|
130
|
+
scope: 'run',
|
|
131
|
+
id: runId,
|
|
132
|
+
action,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
console.error(`[HITL] Run action error:`, error);
|
|
137
|
+
return {
|
|
138
|
+
success: false,
|
|
139
|
+
message: `Error processing run action: ${error.message}`,
|
|
140
|
+
scope: 'run',
|
|
141
|
+
id: runId,
|
|
142
|
+
action,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Handle user actions (moderation, etc.)
|
|
148
|
+
* Scope: user:{userId}:{action}
|
|
149
|
+
*/
|
|
150
|
+
async handleUserAction(userId, action, payload, context) {
|
|
151
|
+
// Placeholder for user action handling
|
|
152
|
+
// This would integrate with a user management API
|
|
153
|
+
console.log(`[HITL] User action not implemented:`, {
|
|
154
|
+
userId,
|
|
155
|
+
action,
|
|
156
|
+
payload,
|
|
157
|
+
});
|
|
158
|
+
return {
|
|
159
|
+
success: false,
|
|
160
|
+
message: 'User actions not yet implemented',
|
|
161
|
+
scope: 'user',
|
|
162
|
+
id: userId,
|
|
163
|
+
action,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Handle payment actions
|
|
168
|
+
* Scope: payment:{paymentId}:{action}
|
|
169
|
+
*/
|
|
170
|
+
async handlePaymentAction(paymentId, action, payload, context) {
|
|
171
|
+
// Placeholder for payment action handling
|
|
172
|
+
// This would integrate with a payment processing API
|
|
173
|
+
console.log(`[HITL] Payment action not implemented:`, {
|
|
174
|
+
paymentId,
|
|
175
|
+
action,
|
|
176
|
+
payload,
|
|
177
|
+
});
|
|
178
|
+
return {
|
|
179
|
+
success: false,
|
|
180
|
+
message: 'Payment actions not yet implemented',
|
|
181
|
+
scope: 'payment',
|
|
182
|
+
id: paymentId,
|
|
183
|
+
action,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
exports.HITLHandler = HITLHandler;
|
|
188
|
+
/**
|
|
189
|
+
* Helper: Route action to HITL endpoint
|
|
190
|
+
*
|
|
191
|
+
* Use this in notification services to forward actions to the SDK's HITL webhook
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```typescript
|
|
195
|
+
* const result = await routeActionToService('run:123:approve', {
|
|
196
|
+
* user: { id: '456', username: 'john' },
|
|
197
|
+
* platform: 'telegram',
|
|
198
|
+
* });
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
async function routeActionToService(actionData, context, serviceUrl = 'http://localhost:3000') {
|
|
202
|
+
console.log(`[HITL] Routing action to service: ${actionData}`, {
|
|
203
|
+
context,
|
|
204
|
+
serviceUrl,
|
|
205
|
+
});
|
|
206
|
+
const response = await fetch(`${serviceUrl}/actions`, {
|
|
207
|
+
method: 'POST',
|
|
208
|
+
headers: { 'Content-Type': 'application/json' },
|
|
209
|
+
body: JSON.stringify({
|
|
210
|
+
action: actionData,
|
|
211
|
+
context,
|
|
212
|
+
}),
|
|
213
|
+
});
|
|
214
|
+
if (!response.ok) {
|
|
215
|
+
throw new Error(`HITL request failed: ${response.statusText}`);
|
|
216
|
+
}
|
|
217
|
+
return response.json();
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=hitl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hitl.js","sourceRoot":"","sources":["../../src/service/hitl.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AA+PH,oDAyBC;AApQD;;;GAGG;AACH,MAAa,WAAW;IACd,gBAAgB,CAAS;IACzB,gBAAgB,CAAU;IAElC,YAAY,MAAkB;QAC5B,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;QAChD,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,CAAC;IAClD,CAAC;IAED;;;OAGG;IACH,WAAW,CAAC,UAAkB;QAM5B,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAEpC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO;YACL,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;YACf,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;YACZ,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;YAChB,OAAO,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAA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YACT,MAAM;YACN,OAAO;SACR,CAAC,CAAC;QAEH,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,qCAAqC;YAC9C,KAAK,EAAE,SAAS;YAChB,EAAE,EAAE,SAAS;YACb,MAAM;SACP,CAAC;IACJ,CAAC;CACF;AAxND,kCAwNC;AAED;;;;;;;;;;;;GAYG;AACI,KAAK,UAAU,oBAAoB,CACxC,UAAkB,EAClB,OAAoB,EACpB,aAAqB,uBAAuB;IAG5C,OAAO,CAAC,GAAG,CAAC,qCAAqC,UAAU,EAAE,EAAE;QAC7D,OAAO;QACP,UAAU;KACX,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,UAAU,UAAU,EAAE;QACpD,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,MAAM,EAAE,UAAU;YAClB,OAAO;SACR,CAAC;KACH,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,wBAAwB,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC"}
|
package/dist/service/index.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ import { ProcessHandler, RedisProcessStore, MemoryProcessStore } from "./process
|
|
|
8
8
|
import { requireScope } from "./server";
|
|
9
9
|
import { hasScope, hasAllScopes, hasAnyScope } from "./auth";
|
|
10
10
|
import { WebhookTriggerRegistry, createWebhookTriggerRegistry, createSimpleTrigger, type WebhookTrigger, type WebhookTriggerDefinition, type WebhookProcessResult } from "./webhooks";
|
|
11
|
+
import { HITLHandler, routeActionToService, type HITLConfig, type HITLResult } from "./hitl";
|
|
11
12
|
export declare const defineDAINService: (config: DAINServiceConfig) => DAINService;
|
|
12
|
-
export { defineNodeService, defineDenoService, defineCloudflareService, createNextDainService, createTool, createService, createToolbox, CoreUtils, createOAuth2Tool, createAgent, ProcessHandler, RedisProcessStore, MemoryProcessStore, requireScope, hasScope, hasAllScopes, hasAnyScope, WebhookTriggerRegistry, createWebhookTriggerRegistry, createSimpleTrigger, type WebhookTrigger, type WebhookTriggerDefinition, type WebhookProcessResult, };
|
|
13
|
+
export { defineNodeService, defineDenoService, defineCloudflareService, createNextDainService, createTool, createService, createToolbox, CoreUtils, createOAuth2Tool, createAgent, ProcessHandler, RedisProcessStore, MemoryProcessStore, requireScope, hasScope, hasAllScopes, hasAnyScope, WebhookTriggerRegistry, createWebhookTriggerRegistry, createSimpleTrigger, type WebhookTrigger, type WebhookTriggerDefinition, type WebhookProcessResult, HITLHandler, routeActionToService, type HITLConfig, type HITLResult, };
|
|
13
14
|
export * from './types';
|
|
14
15
|
export * from './oauth2Store';
|
package/dist/service/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// File: src/service/index.ts
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.createSimpleTrigger = exports.createWebhookTriggerRegistry = exports.WebhookTriggerRegistry = exports.hasAnyScope = exports.hasAllScopes = exports.hasScope = exports.requireScope = exports.MemoryProcessStore = exports.RedisProcessStore = exports.ProcessHandler = exports.createAgent = exports.createOAuth2Tool = exports.CoreUtils = exports.createToolbox = exports.createService = exports.createTool = exports.createNextDainService = exports.defineCloudflareService = exports.defineDenoService = exports.defineNodeService = exports.defineDAINService = void 0;
|
|
4
|
+
exports.routeActionToService = exports.HITLHandler = exports.createSimpleTrigger = exports.createWebhookTriggerRegistry = exports.WebhookTriggerRegistry = exports.hasAnyScope = exports.hasAllScopes = exports.hasScope = exports.requireScope = exports.MemoryProcessStore = exports.RedisProcessStore = exports.ProcessHandler = exports.createAgent = exports.createOAuth2Tool = exports.CoreUtils = exports.createToolbox = exports.createService = exports.createTool = exports.createNextDainService = exports.defineCloudflareService = exports.defineDenoService = exports.defineNodeService = exports.defineDAINService = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const nodeService_1 = require("./nodeService");
|
|
7
7
|
Object.defineProperty(exports, "defineNodeService", { enumerable: true, get: function () { return nodeService_1.defineDAINService; } });
|
|
@@ -32,6 +32,9 @@ const webhooks_1 = require("./webhooks");
|
|
|
32
32
|
Object.defineProperty(exports, "WebhookTriggerRegistry", { enumerable: true, get: function () { return webhooks_1.WebhookTriggerRegistry; } });
|
|
33
33
|
Object.defineProperty(exports, "createWebhookTriggerRegistry", { enumerable: true, get: function () { return webhooks_1.createWebhookTriggerRegistry; } });
|
|
34
34
|
Object.defineProperty(exports, "createSimpleTrigger", { enumerable: true, get: function () { return webhooks_1.createSimpleTrigger; } });
|
|
35
|
+
const hitl_1 = require("./hitl");
|
|
36
|
+
Object.defineProperty(exports, "HITLHandler", { enumerable: true, get: function () { return hitl_1.HITLHandler; } });
|
|
37
|
+
Object.defineProperty(exports, "routeActionToService", { enumerable: true, get: function () { return hitl_1.routeActionToService; } });
|
|
35
38
|
const defineDAINService = (config) => {
|
|
36
39
|
throw new Error("This is a fallback implementation. Use the appropriate runtime-specific import.");
|
|
37
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":";AAAA,6BAA6B;;;;AAG7B,+CAAuE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/service/index.ts"],"names":[],"mappings":";AAAA,6BAA6B;;;;AAG7B,+CAAuE;AA4BrE,kGA5B4B,+BAAiB,OA4B5B;AA3BnB,+CAAuE;AA4BrE,kGA5B4B,+BAAiB,OA4B5B;AA3BnB,2DAAmF;AA4BjF,wGA5B4B,qCAAuB,OA4B5B;AA3BzB,+CAAsD;AA4BpD,sGA5BO,mCAAqB,OA4BP;AA3BvB,iCAA4G;AA4B1G,2FA5BO,iBAAU,OA4BP;AACV,8FA7BmB,oBAAa,OA6BnB;AACb,8FA9BkC,oBAAa,OA8BlC;AACb,0FA/BiD,gBAAS,OA+BjD;AACT,iGAhC4D,uBAAgB,OAgC5D;AAChB,4FAjC8E,kBAAW,OAiC9E;AAhCb,2CAAoF;AAiClF,+FAjCO,0BAAc,OAiCP;AACd,kGAlCuB,6BAAiB,OAkCvB;AACjB,mGAnC0C,8BAAkB,OAmC1C;AAlCpB,qCAAwC;AAmCtC,6FAnCO,qBAAY,OAmCP;AAlCd,iCAA6D;AAmC3D,yFAnCO,eAAQ,OAmCP;AACR,6FApCiB,mBAAY,OAoCjB;AACZ,4FArC+B,kBAAW,OAqC/B;AApCb,yCAOoB;AA+BlB,uGArCA,iCAAsB,OAqCA;AACtB,6GArCA,uCAA4B,OAqCA;AAC5B,oGArCA,8BAAmB,OAqCA;AAhCrB,iCAKgB;AAgCd,4FApCA,kBAAW,OAoCA;AACX,qGApCA,2BAAoB,OAoCA;AA/Bf,MAAM,iBAAiB,GAAG,CAAC,MAAyB,EAAe,EAAE;IAC1E,MAAM,IAAI,KAAK,CAAC,iFAAiF,CAAC,CAAC;AACrG,CAAC,CAAC;AAFW,QAAA,iBAAiB,qBAE5B;AAkCF,sBAAsB;AACtB,kDAAwB;AAExB,wDAA8B"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { DAINServiceConfig, DAINService } from "./types";
|
|
2
2
|
import { createTool, createService, createToolbox, CoreUtils, createOAuth2Tool, createAgent } from "./core";
|
|
3
3
|
import { ProcessHandler, RedisProcessStore, MemoryProcessStore } from "./processes";
|
|
4
|
+
import { WebhookTriggerRegistry, createWebhookTriggerRegistry, createSimpleTrigger } from "./webhooks";
|
|
5
|
+
import { HITLHandler, routeActionToService } from "./hitl";
|
|
4
6
|
export declare function defineDAINService(config: DAINServiceConfig): DAINService;
|
|
5
|
-
export { createTool, createService, createToolbox, CoreUtils, createOAuth2Tool, createAgent, ProcessHandler, RedisProcessStore, MemoryProcessStore, };
|
|
7
|
+
export { createTool, createService, createToolbox, CoreUtils, createOAuth2Tool, createAgent, ProcessHandler, RedisProcessStore, MemoryProcessStore, WebhookTriggerRegistry, createWebhookTriggerRegistry, createSimpleTrigger, HITLHandler, routeActionToService, };
|
|
6
8
|
export * from "./types";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MemoryProcessStore = exports.RedisProcessStore = exports.ProcessHandler = exports.createAgent = exports.createOAuth2Tool = exports.CoreUtils = exports.createToolbox = exports.createService = exports.createTool = void 0;
|
|
3
|
+
exports.routeActionToService = exports.HITLHandler = exports.createSimpleTrigger = exports.createWebhookTriggerRegistry = exports.WebhookTriggerRegistry = exports.MemoryProcessStore = exports.RedisProcessStore = exports.ProcessHandler = exports.createAgent = exports.createOAuth2Tool = exports.CoreUtils = exports.createToolbox = exports.createService = exports.createTool = void 0;
|
|
4
4
|
exports.defineDAINService = defineDAINService;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const service_1 = require("./service");
|
|
@@ -15,6 +15,13 @@ const processes_1 = require("./processes");
|
|
|
15
15
|
Object.defineProperty(exports, "ProcessHandler", { enumerable: true, get: function () { return processes_1.ProcessHandler; } });
|
|
16
16
|
Object.defineProperty(exports, "RedisProcessStore", { enumerable: true, get: function () { return processes_1.RedisProcessStore; } });
|
|
17
17
|
Object.defineProperty(exports, "MemoryProcessStore", { enumerable: true, get: function () { return processes_1.MemoryProcessStore; } });
|
|
18
|
+
const webhooks_1 = require("./webhooks");
|
|
19
|
+
Object.defineProperty(exports, "WebhookTriggerRegistry", { enumerable: true, get: function () { return webhooks_1.WebhookTriggerRegistry; } });
|
|
20
|
+
Object.defineProperty(exports, "createWebhookTriggerRegistry", { enumerable: true, get: function () { return webhooks_1.createWebhookTriggerRegistry; } });
|
|
21
|
+
Object.defineProperty(exports, "createSimpleTrigger", { enumerable: true, get: function () { return webhooks_1.createSimpleTrigger; } });
|
|
22
|
+
const hitl_1 = require("./hitl");
|
|
23
|
+
Object.defineProperty(exports, "HITLHandler", { enumerable: true, get: function () { return hitl_1.HITLHandler; } });
|
|
24
|
+
Object.defineProperty(exports, "routeActionToService", { enumerable: true, get: function () { return hitl_1.routeActionToService; } });
|
|
18
25
|
function defineDAINService(config) {
|
|
19
26
|
const baseService = (0, service_1.createBaseDAINService)(config);
|
|
20
27
|
const startNode = async (options = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeService.js","sourceRoot":"","sources":["../../src/service/nodeService.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"nodeService.js","sourceRoot":"","sources":["../../src/service/nodeService.ts"],"names":[],"mappings":";;;AAeA,8CAqDC;;AAnED,uCAAkD;AAClD,iCAOgB;AA8Dd,2FApEA,iBAAU,OAoEA;AACV,8FApEA,oBAAa,OAoEA;AACb,8FApEA,oBAAa,OAoEA;AACb,0FApEA,gBAAS,OAoEA;AACT,iGApEA,uBAAgB,OAoEA;AAChB,4FApEA,kBAAW,OAoEA;AAjEb,2CAAoF;AAkElF,+FAlEO,0BAAc,OAkEP;AACd,kGAnEuB,6BAAiB,OAmEvB;AACjB,mGApE0C,8BAAkB,OAoE1C;AAnEpB,yCAAuG;AAoErG,uGApEO,iCAAsB,OAoEP;AACtB,6GArE+B,uCAA4B,OAqE/B;AAC5B,oGAtE6D,8BAAmB,OAsE7D;AArErB,iCAA2D;AAsEzD,4FAtEO,kBAAW,OAsEP;AACX,qGAvEoB,2BAAoB,OAuEpB;AArEtB,SAAgB,iBAAiB,CAAC,MAAyB;IACzD,MAAM,WAAW,GAAG,IAAA,+BAAqB,EAAC,MAAM,CAAC,CAAC;IAElD,MAAM,SAAS,GAAG,KAAK,EACrB,UAA6B;QAC3B,IAAI,EAAE,SAAS;KAChB,EACiD,EAAE;QACpD,MAAM,EAAE,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC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