@loopstack/hitl 0.1.1
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/documents/ask-user-confirm-document.d.ts +11 -0
- package/dist/documents/ask-user-confirm-document.d.ts.map +1 -0
- package/dist/documents/ask-user-confirm-document.js +29 -0
- package/dist/documents/ask-user-confirm-document.js.map +1 -0
- package/dist/documents/ask-user-confirm-document.yaml +6 -0
- package/dist/documents/ask-user-document.d.ts +11 -0
- package/dist/documents/ask-user-document.d.ts.map +1 -0
- package/dist/documents/ask-user-document.js +29 -0
- package/dist/documents/ask-user-document.js.map +1 -0
- package/dist/documents/ask-user-document.yaml +6 -0
- package/dist/documents/ask-user-options-document.d.ts +15 -0
- package/dist/documents/ask-user-options-document.d.ts.map +1 -0
- package/dist/documents/ask-user-options-document.js +33 -0
- package/dist/documents/ask-user-options-document.js.map +1 -0
- package/dist/documents/ask-user-options-document.yaml +6 -0
- package/dist/documents/confirm-user-document.d.ts +9 -0
- package/dist/documents/confirm-user-document.d.ts.map +1 -0
- package/dist/documents/confirm-user-document.js +27 -0
- package/dist/documents/confirm-user-document.js.map +1 -0
- package/dist/documents/confirm-user-document.yaml +16 -0
- package/dist/documents/index.d.ts +5 -0
- package/dist/documents/index.d.ts.map +1 -0
- package/dist/documents/index.js +16 -0
- package/dist/documents/index.js.map +1 -0
- package/dist/hitl.module.d.ts +3 -0
- package/dist/hitl.module.d.ts.map +1 -0
- package/dist/hitl.module.js +24 -0
- package/dist/hitl.module.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/workflows/ask-user/ask-user.ui.yaml +6 -0
- package/dist/workflows/ask-user/ask-user.workflow.d.ts +15 -0
- package/dist/workflows/ask-user/ask-user.workflow.d.ts.map +1 -0
- package/dist/workflows/ask-user/ask-user.workflow.js +99 -0
- package/dist/workflows/ask-user/ask-user.workflow.js.map +1 -0
- package/dist/workflows/confirm-user/confirm-user.ui.yaml +5 -0
- package/dist/workflows/confirm-user/confirm-user.workflow.d.ts +16 -0
- package/dist/workflows/confirm-user/confirm-user.workflow.d.ts.map +1 -0
- package/dist/workflows/confirm-user/confirm-user.workflow.js +56 -0
- package/dist/workflows/confirm-user/confirm-user.workflow.js.map +1 -0
- package/dist/workflows/index.d.ts +3 -0
- package/dist/workflows/index.d.ts.map +1 -0
- package/dist/workflows/index.js +8 -0
- package/dist/workflows/index.js.map +1 -0
- package/package.json +72 -0
- package/src/documents/ask-user-confirm-document.ts +20 -0
- package/src/documents/ask-user-confirm-document.yaml +6 -0
- package/src/documents/ask-user-document.ts +20 -0
- package/src/documents/ask-user-document.yaml +6 -0
- package/src/documents/ask-user-options-document.ts +24 -0
- package/src/documents/ask-user-options-document.yaml +6 -0
- package/src/documents/confirm-user-document.ts +18 -0
- package/src/documents/confirm-user-document.yaml +16 -0
- package/src/documents/index.ts +12 -0
- package/src/hitl.module.ts +11 -0
- package/src/index.ts +3 -0
- package/src/workflows/ask-user/ask-user.ui.yaml +6 -0
- package/src/workflows/ask-user/ask-user.workflow.ts +83 -0
- package/src/workflows/confirm-user/confirm-user.ui.yaml +5 -0
- package/src/workflows/confirm-user/confirm-user.workflow.ts +29 -0
- package/src/workflows/index.ts +2 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const AskUserConfirmDocumentSchema: z.ZodObject<{
|
|
3
|
+
question: z.ZodString;
|
|
4
|
+
answer: z.ZodOptional<z.ZodString>;
|
|
5
|
+
}, z.core.$strict>;
|
|
6
|
+
export type AskUserConfirmDocumentType = z.infer<typeof AskUserConfirmDocumentSchema>;
|
|
7
|
+
export declare class AskUserConfirmDocument {
|
|
8
|
+
question: string;
|
|
9
|
+
answer?: string;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=ask-user-confirm-document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask-user-confirm-document.d.ts","sourceRoot":"","sources":["../../src/documents/ask-user-confirm-document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,4BAA4B;;;kBAK9B,CAAC;AAEZ,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAEtF,qBAIa,sBAAsB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AskUserConfirmDocument = exports.AskUserConfirmDocumentSchema = void 0;
|
|
10
|
+
const zod_1 = require("zod");
|
|
11
|
+
const common_1 = require("@loopstack/common");
|
|
12
|
+
exports.AskUserConfirmDocumentSchema = zod_1.z
|
|
13
|
+
.object({
|
|
14
|
+
question: zod_1.z.string(),
|
|
15
|
+
answer: zod_1.z.string().optional(),
|
|
16
|
+
})
|
|
17
|
+
.strict();
|
|
18
|
+
let AskUserConfirmDocument = class AskUserConfirmDocument {
|
|
19
|
+
question;
|
|
20
|
+
answer;
|
|
21
|
+
};
|
|
22
|
+
exports.AskUserConfirmDocument = AskUserConfirmDocument;
|
|
23
|
+
exports.AskUserConfirmDocument = AskUserConfirmDocument = __decorate([
|
|
24
|
+
(0, common_1.Document)({
|
|
25
|
+
uiConfig: __dirname + '/ask-user-confirm-document.yaml',
|
|
26
|
+
schema: exports.AskUserConfirmDocumentSchema,
|
|
27
|
+
})
|
|
28
|
+
], AskUserConfirmDocument);
|
|
29
|
+
//# sourceMappingURL=ask-user-confirm-document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask-user-confirm-document.js","sourceRoot":"","sources":["../../src/documents/ask-user-confirm-document.ts"],"names":[],"mappings":";;;;;;;;;AAAA,6BAAwB;AACxB,8CAA6C;AAEhC,QAAA,4BAA4B,GAAG,OAAC;KAC1C,MAAM,CAAC;IACN,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;IACpB,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC;KACD,MAAM,EAAE,CAAC;AAQL,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IACjC,QAAQ,CAAS;IACjB,MAAM,CAAU;CACjB,CAAA;AAHY,wDAAsB;iCAAtB,sBAAsB;IAJlC,IAAA,iBAAQ,EAAC;QACR,QAAQ,EAAE,SAAS,GAAG,iCAAiC;QACvD,MAAM,EAAE,oCAA4B;KACrC,CAAC;GACW,sBAAsB,CAGlC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const AskUserDocumentSchema: z.ZodObject<{
|
|
3
|
+
question: z.ZodString;
|
|
4
|
+
answer: z.ZodOptional<z.ZodString>;
|
|
5
|
+
}, z.core.$strict>;
|
|
6
|
+
export type AskUserDocumentType = z.infer<typeof AskUserDocumentSchema>;
|
|
7
|
+
export declare class AskUserDocument {
|
|
8
|
+
question: string;
|
|
9
|
+
answer?: string;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=ask-user-document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask-user-document.d.ts","sourceRoot":"","sources":["../../src/documents/ask-user-document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,qBAAqB;;;kBAKvB,CAAC;AAEZ,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAExE,qBAIa,eAAe;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AskUserDocument = exports.AskUserDocumentSchema = void 0;
|
|
10
|
+
const zod_1 = require("zod");
|
|
11
|
+
const common_1 = require("@loopstack/common");
|
|
12
|
+
exports.AskUserDocumentSchema = zod_1.z
|
|
13
|
+
.object({
|
|
14
|
+
question: zod_1.z.string(),
|
|
15
|
+
answer: zod_1.z.string().optional(),
|
|
16
|
+
})
|
|
17
|
+
.strict();
|
|
18
|
+
let AskUserDocument = class AskUserDocument {
|
|
19
|
+
question;
|
|
20
|
+
answer;
|
|
21
|
+
};
|
|
22
|
+
exports.AskUserDocument = AskUserDocument;
|
|
23
|
+
exports.AskUserDocument = AskUserDocument = __decorate([
|
|
24
|
+
(0, common_1.Document)({
|
|
25
|
+
uiConfig: __dirname + '/ask-user-document.yaml',
|
|
26
|
+
schema: exports.AskUserDocumentSchema,
|
|
27
|
+
})
|
|
28
|
+
], AskUserDocument);
|
|
29
|
+
//# sourceMappingURL=ask-user-document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask-user-document.js","sourceRoot":"","sources":["../../src/documents/ask-user-document.ts"],"names":[],"mappings":";;;;;;;;;AAAA,6BAAwB;AACxB,8CAA6C;AAEhC,QAAA,qBAAqB,GAAG,OAAC;KACnC,MAAM,CAAC;IACN,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;IACpB,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC;KACD,MAAM,EAAE,CAAC;AAQL,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,QAAQ,CAAS;IACjB,MAAM,CAAU;CACjB,CAAA;AAHY,0CAAe;0BAAf,eAAe;IAJ3B,IAAA,iBAAQ,EAAC;QACR,QAAQ,EAAE,SAAS,GAAG,yBAAyB;QAC/C,MAAM,EAAE,6BAAqB;KAC9B,CAAC;GACW,eAAe,CAG3B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const AskUserOptionsDocumentSchema: z.ZodObject<{
|
|
3
|
+
question: z.ZodString;
|
|
4
|
+
options: z.ZodArray<z.ZodString>;
|
|
5
|
+
allowCustomAnswer: z.ZodOptional<z.ZodBoolean>;
|
|
6
|
+
answer: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, z.core.$strict>;
|
|
8
|
+
export type AskUserOptionsDocumentType = z.infer<typeof AskUserOptionsDocumentSchema>;
|
|
9
|
+
export declare class AskUserOptionsDocument {
|
|
10
|
+
question: string;
|
|
11
|
+
options: string[];
|
|
12
|
+
allowCustomAnswer?: boolean;
|
|
13
|
+
answer?: string;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ask-user-options-document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask-user-options-document.d.ts","sourceRoot":"","sources":["../../src/documents/ask-user-options-document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,4BAA4B;;;;;kBAO9B,CAAC;AAEZ,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAEtF,qBAIa,sBAAsB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AskUserOptionsDocument = exports.AskUserOptionsDocumentSchema = void 0;
|
|
10
|
+
const zod_1 = require("zod");
|
|
11
|
+
const common_1 = require("@loopstack/common");
|
|
12
|
+
exports.AskUserOptionsDocumentSchema = zod_1.z
|
|
13
|
+
.object({
|
|
14
|
+
question: zod_1.z.string(),
|
|
15
|
+
options: zod_1.z.array(zod_1.z.string()),
|
|
16
|
+
allowCustomAnswer: zod_1.z.boolean().optional(),
|
|
17
|
+
answer: zod_1.z.string().optional(),
|
|
18
|
+
})
|
|
19
|
+
.strict();
|
|
20
|
+
let AskUserOptionsDocument = class AskUserOptionsDocument {
|
|
21
|
+
question;
|
|
22
|
+
options;
|
|
23
|
+
allowCustomAnswer;
|
|
24
|
+
answer;
|
|
25
|
+
};
|
|
26
|
+
exports.AskUserOptionsDocument = AskUserOptionsDocument;
|
|
27
|
+
exports.AskUserOptionsDocument = AskUserOptionsDocument = __decorate([
|
|
28
|
+
(0, common_1.Document)({
|
|
29
|
+
uiConfig: __dirname + '/ask-user-options-document.yaml',
|
|
30
|
+
schema: exports.AskUserOptionsDocumentSchema,
|
|
31
|
+
})
|
|
32
|
+
], AskUserOptionsDocument);
|
|
33
|
+
//# sourceMappingURL=ask-user-options-document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask-user-options-document.js","sourceRoot":"","sources":["../../src/documents/ask-user-options-document.ts"],"names":[],"mappings":";;;;;;;;;AAAA,6BAAwB;AACxB,8CAA6C;AAEhC,QAAA,4BAA4B,GAAG,OAAC;KAC1C,MAAM,CAAC;IACN,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;IACpB,OAAO,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;IAC5B,iBAAiB,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACzC,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC9B,CAAC;KACD,MAAM,EAAE,CAAC;AAQL,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IACjC,QAAQ,CAAS;IACjB,OAAO,CAAW;IAClB,iBAAiB,CAAW;IAC5B,MAAM,CAAU;CACjB,CAAA;AALY,wDAAsB;iCAAtB,sBAAsB;IAJlC,IAAA,iBAAQ,EAAC;QACR,QAAQ,EAAE,SAAS,GAAG,iCAAiC;QACvD,MAAM,EAAE,oCAA4B;KACrC,CAAC;GACW,sBAAsB,CAKlC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ConfirmUserDocumentSchema: z.ZodObject<{
|
|
3
|
+
markdown: z.ZodString;
|
|
4
|
+
}, z.core.$strict>;
|
|
5
|
+
export type ConfirmUserDocumentType = z.infer<typeof ConfirmUserDocumentSchema>;
|
|
6
|
+
export declare class ConfirmUserDocument {
|
|
7
|
+
markdown: string;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=confirm-user-document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirm-user-document.d.ts","sourceRoot":"","sources":["../../src/documents/confirm-user-document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,yBAAyB;;kBAI3B,CAAC;AAEZ,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAEhF,qBAIa,mBAAmB;IAC9B,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ConfirmUserDocument = exports.ConfirmUserDocumentSchema = void 0;
|
|
10
|
+
const zod_1 = require("zod");
|
|
11
|
+
const common_1 = require("@loopstack/common");
|
|
12
|
+
exports.ConfirmUserDocumentSchema = zod_1.z
|
|
13
|
+
.object({
|
|
14
|
+
markdown: zod_1.z.string(),
|
|
15
|
+
})
|
|
16
|
+
.strict();
|
|
17
|
+
let ConfirmUserDocument = class ConfirmUserDocument {
|
|
18
|
+
markdown;
|
|
19
|
+
};
|
|
20
|
+
exports.ConfirmUserDocument = ConfirmUserDocument;
|
|
21
|
+
exports.ConfirmUserDocument = ConfirmUserDocument = __decorate([
|
|
22
|
+
(0, common_1.Document)({
|
|
23
|
+
uiConfig: __dirname + '/confirm-user-document.yaml',
|
|
24
|
+
schema: exports.ConfirmUserDocumentSchema,
|
|
25
|
+
})
|
|
26
|
+
], ConfirmUserDocument);
|
|
27
|
+
//# sourceMappingURL=confirm-user-document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirm-user-document.js","sourceRoot":"","sources":["../../src/documents/confirm-user-document.ts"],"names":[],"mappings":";;;;;;;;;AAAA,6BAAwB;AACxB,8CAA6C;AAEhC,QAAA,yBAAyB,GAAG,OAAC;KACvC,MAAM,CAAC;IACN,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;CACrB,CAAC;KACD,MAAM,EAAE,CAAC;AAQL,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC9B,QAAQ,CAAS;CAClB,CAAA;AAFY,kDAAmB;8BAAnB,mBAAmB;IAJ/B,IAAA,iBAAQ,EAAC;QACR,QAAQ,EAAE,SAAS,GAAG,6BAA6B;QACnD,MAAM,EAAE,iCAAyB;KAClC,CAAC;GACW,mBAAmB,CAE/B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type: document
|
|
2
|
+
ui:
|
|
3
|
+
widgets:
|
|
4
|
+
- widget: form
|
|
5
|
+
options:
|
|
6
|
+
properties:
|
|
7
|
+
markdown:
|
|
8
|
+
widget: markdown-view
|
|
9
|
+
actions:
|
|
10
|
+
- type: button
|
|
11
|
+
transition: userDenied
|
|
12
|
+
label: 'Deny'
|
|
13
|
+
variant: outline
|
|
14
|
+
- type: button
|
|
15
|
+
transition: userConfirmed
|
|
16
|
+
label: 'Confirm'
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { AskUserDocument, AskUserDocumentSchema, AskUserDocumentType } from './ask-user-document';
|
|
2
|
+
export { AskUserConfirmDocument, AskUserConfirmDocumentSchema, AskUserConfirmDocumentType, } from './ask-user-confirm-document';
|
|
3
|
+
export { AskUserOptionsDocument, AskUserOptionsDocumentSchema, AskUserOptionsDocumentType, } from './ask-user-options-document';
|
|
4
|
+
export { ConfirmUserDocument, ConfirmUserDocumentSchema, ConfirmUserDocumentType } from './confirm-user-document';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/documents/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAClG,OAAO,EACL,sBAAsB,EACtB,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,sBAAsB,EACtB,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfirmUserDocumentSchema = exports.ConfirmUserDocument = exports.AskUserOptionsDocumentSchema = exports.AskUserOptionsDocument = exports.AskUserConfirmDocumentSchema = exports.AskUserConfirmDocument = exports.AskUserDocumentSchema = exports.AskUserDocument = void 0;
|
|
4
|
+
var ask_user_document_1 = require("./ask-user-document");
|
|
5
|
+
Object.defineProperty(exports, "AskUserDocument", { enumerable: true, get: function () { return ask_user_document_1.AskUserDocument; } });
|
|
6
|
+
Object.defineProperty(exports, "AskUserDocumentSchema", { enumerable: true, get: function () { return ask_user_document_1.AskUserDocumentSchema; } });
|
|
7
|
+
var ask_user_confirm_document_1 = require("./ask-user-confirm-document");
|
|
8
|
+
Object.defineProperty(exports, "AskUserConfirmDocument", { enumerable: true, get: function () { return ask_user_confirm_document_1.AskUserConfirmDocument; } });
|
|
9
|
+
Object.defineProperty(exports, "AskUserConfirmDocumentSchema", { enumerable: true, get: function () { return ask_user_confirm_document_1.AskUserConfirmDocumentSchema; } });
|
|
10
|
+
var ask_user_options_document_1 = require("./ask-user-options-document");
|
|
11
|
+
Object.defineProperty(exports, "AskUserOptionsDocument", { enumerable: true, get: function () { return ask_user_options_document_1.AskUserOptionsDocument; } });
|
|
12
|
+
Object.defineProperty(exports, "AskUserOptionsDocumentSchema", { enumerable: true, get: function () { return ask_user_options_document_1.AskUserOptionsDocumentSchema; } });
|
|
13
|
+
var confirm_user_document_1 = require("./confirm-user-document");
|
|
14
|
+
Object.defineProperty(exports, "ConfirmUserDocument", { enumerable: true, get: function () { return confirm_user_document_1.ConfirmUserDocument; } });
|
|
15
|
+
Object.defineProperty(exports, "ConfirmUserDocumentSchema", { enumerable: true, get: function () { return confirm_user_document_1.ConfirmUserDocumentSchema; } });
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/documents/index.ts"],"names":[],"mappings":";;;AAAA,yDAAkG;AAAzF,oHAAA,eAAe,OAAA;AAAE,0HAAA,qBAAqB,OAAA;AAC/C,yEAIqC;AAHnC,mIAAA,sBAAsB,OAAA;AACtB,yIAAA,4BAA4B,OAAA;AAG9B,yEAIqC;AAHnC,mIAAA,sBAAsB,OAAA;AACtB,yIAAA,4BAA4B,OAAA;AAG9B,iEAAkH;AAAzG,4HAAA,mBAAmB,OAAA;AAAE,kIAAA,yBAAyB,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hitl.module.d.ts","sourceRoot":"","sources":["../src/hitl.module.ts"],"names":[],"mappings":"AAKA,qBAKa,UAAU;CAAG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.HitlModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const core_1 = require("@loopstack/core");
|
|
12
|
+
const ask_user_workflow_1 = require("./workflows/ask-user/ask-user.workflow");
|
|
13
|
+
const confirm_user_workflow_1 = require("./workflows/confirm-user/confirm-user.workflow");
|
|
14
|
+
let HitlModule = class HitlModule {
|
|
15
|
+
};
|
|
16
|
+
exports.HitlModule = HitlModule;
|
|
17
|
+
exports.HitlModule = HitlModule = __decorate([
|
|
18
|
+
(0, common_1.Module)({
|
|
19
|
+
imports: [core_1.LoopCoreModule],
|
|
20
|
+
providers: [ask_user_workflow_1.AskUserWorkflow, confirm_user_workflow_1.ConfirmUserWorkflow],
|
|
21
|
+
exports: [ask_user_workflow_1.AskUserWorkflow, confirm_user_workflow_1.ConfirmUserWorkflow],
|
|
22
|
+
})
|
|
23
|
+
], HitlModule);
|
|
24
|
+
//# sourceMappingURL=hitl.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hitl.module.js","sourceRoot":"","sources":["../src/hitl.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,0CAAiD;AACjD,8EAAyE;AACzE,0FAAqF;AAO9E,IAAM,UAAU,GAAhB,MAAM,UAAU;CAAG,CAAA;AAAb,gCAAU;qBAAV,UAAU;IALtB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,qBAAc,CAAC;QACzB,SAAS,EAAE,CAAC,mCAAe,EAAE,2CAAmB,CAAC;QACjD,OAAO,EAAE,CAAC,mCAAe,EAAE,2CAAmB,CAAC;KAChD,CAAC;GACW,UAAU,CAAG"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./documents"), exports);
|
|
18
|
+
__exportStar(require("./workflows"), exports);
|
|
19
|
+
__exportStar(require("./hitl.module"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,8CAA4B;AAC5B,gDAA8B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
title: 'Ask User'
|
|
2
|
+
|
|
3
|
+
description: |
|
|
4
|
+
Generic sub-workflow that presents a question to the user and waits for their answer.
|
|
5
|
+
Used by async tool calls (e.g. askClarification) to interrupt an agent loop for user input.
|
|
6
|
+
Supports three modes: text (default), options (pick from a list), and confirm (yes/no).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseWorkflow } from '@loopstack/common';
|
|
2
|
+
export declare class AskUserWorkflow extends BaseWorkflow {
|
|
3
|
+
start(): void;
|
|
4
|
+
showQuestionOptions(): Promise<void>;
|
|
5
|
+
showQuestionConfirm(): Promise<void>;
|
|
6
|
+
showQuestionText(): Promise<void>;
|
|
7
|
+
userAnswered(payload: {
|
|
8
|
+
answer: string;
|
|
9
|
+
}): Promise<{
|
|
10
|
+
answer: string;
|
|
11
|
+
}>;
|
|
12
|
+
private isOptionsMode;
|
|
13
|
+
private isConfirmMode;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ask-user.workflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask-user.workflow.d.ts","sourceRoot":"","sources":["../../../src/workflows/ask-user/ask-user.workflow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAA+C,MAAM,mBAAmB,CAAC;AAS9F,qBASa,eAAgB,SAAQ,YAAY;IAE/C,KAAK;IAIC,mBAAmB;IAenB,mBAAmB;IAMnB,gBAAgB;IAMhB,YAAY,CAAC,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAuB5E,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,aAAa;CAGtB"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AskUserWorkflow = void 0;
|
|
13
|
+
const zod_1 = require("zod");
|
|
14
|
+
const common_1 = require("@loopstack/common");
|
|
15
|
+
const ask_user_confirm_document_1 = require("../../documents/ask-user-confirm-document");
|
|
16
|
+
const ask_user_document_1 = require("../../documents/ask-user-document");
|
|
17
|
+
const ask_user_options_document_1 = require("../../documents/ask-user-options-document");
|
|
18
|
+
const AskUserAnswerSchema = zod_1.z.object({
|
|
19
|
+
answer: zod_1.z.string(),
|
|
20
|
+
});
|
|
21
|
+
let AskUserWorkflow = class AskUserWorkflow extends common_1.BaseWorkflow {
|
|
22
|
+
start() { }
|
|
23
|
+
async showQuestionOptions() {
|
|
24
|
+
const { question, options, allowCustomAnswer } = this.ctx.args;
|
|
25
|
+
await this.repository.save(ask_user_options_document_1.AskUserOptionsDocument, { question, options: options ?? [], allowCustomAnswer }, { id: 'question' });
|
|
26
|
+
}
|
|
27
|
+
async showQuestionConfirm() {
|
|
28
|
+
const { question } = this.ctx.args;
|
|
29
|
+
await this.repository.save(ask_user_confirm_document_1.AskUserConfirmDocument, { question }, { id: 'question' });
|
|
30
|
+
}
|
|
31
|
+
async showQuestionText() {
|
|
32
|
+
const { question } = this.ctx.args;
|
|
33
|
+
await this.repository.save(ask_user_document_1.AskUserDocument, { question }, { id: 'question' });
|
|
34
|
+
}
|
|
35
|
+
async userAnswered(payload) {
|
|
36
|
+
const { question, mode, options, allowCustomAnswer } = this.ctx.args;
|
|
37
|
+
if (mode === 'options') {
|
|
38
|
+
await this.repository.save(ask_user_options_document_1.AskUserOptionsDocument, { question, options: options ?? [], allowCustomAnswer, answer: payload.answer }, { id: 'question' });
|
|
39
|
+
}
|
|
40
|
+
else if (mode === 'confirm') {
|
|
41
|
+
await this.repository.save(ask_user_confirm_document_1.AskUserConfirmDocument, { question, answer: payload.answer }, { id: 'question' });
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
await this.repository.save(ask_user_document_1.AskUserDocument, { question, answer: payload.answer }, { id: 'question' });
|
|
45
|
+
}
|
|
46
|
+
return { answer: payload.answer };
|
|
47
|
+
}
|
|
48
|
+
isOptionsMode() {
|
|
49
|
+
return this.ctx.args?.mode === 'options';
|
|
50
|
+
}
|
|
51
|
+
isConfirmMode() {
|
|
52
|
+
return this.ctx.args?.mode === 'confirm';
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
exports.AskUserWorkflow = AskUserWorkflow;
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, common_1.Initial)({ to: 'show_question' }),
|
|
58
|
+
__metadata("design:type", Function),
|
|
59
|
+
__metadata("design:paramtypes", []),
|
|
60
|
+
__metadata("design:returntype", void 0)
|
|
61
|
+
], AskUserWorkflow.prototype, "start", null);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, common_1.Transition)({ from: 'show_question', to: 'waiting_for_user', priority: 10 }),
|
|
64
|
+
(0, common_1.Guard)('isOptionsMode'),
|
|
65
|
+
__metadata("design:type", Function),
|
|
66
|
+
__metadata("design:paramtypes", []),
|
|
67
|
+
__metadata("design:returntype", Promise)
|
|
68
|
+
], AskUserWorkflow.prototype, "showQuestionOptions", null);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, common_1.Transition)({ from: 'show_question', to: 'waiting_for_user', priority: 10 }),
|
|
71
|
+
(0, common_1.Guard)('isConfirmMode'),
|
|
72
|
+
__metadata("design:type", Function),
|
|
73
|
+
__metadata("design:paramtypes", []),
|
|
74
|
+
__metadata("design:returntype", Promise)
|
|
75
|
+
], AskUserWorkflow.prototype, "showQuestionConfirm", null);
|
|
76
|
+
__decorate([
|
|
77
|
+
(0, common_1.Transition)({ from: 'show_question', to: 'waiting_for_user' }),
|
|
78
|
+
__metadata("design:type", Function),
|
|
79
|
+
__metadata("design:paramtypes", []),
|
|
80
|
+
__metadata("design:returntype", Promise)
|
|
81
|
+
], AskUserWorkflow.prototype, "showQuestionText", null);
|
|
82
|
+
__decorate([
|
|
83
|
+
(0, common_1.Final)({ from: 'waiting_for_user', wait: true, schema: AskUserAnswerSchema }),
|
|
84
|
+
__metadata("design:type", Function),
|
|
85
|
+
__metadata("design:paramtypes", [Object]),
|
|
86
|
+
__metadata("design:returntype", Promise)
|
|
87
|
+
], AskUserWorkflow.prototype, "userAnswered", null);
|
|
88
|
+
exports.AskUserWorkflow = AskUserWorkflow = __decorate([
|
|
89
|
+
(0, common_1.Workflow)({
|
|
90
|
+
uiConfig: __dirname + '/ask-user.ui.yaml',
|
|
91
|
+
schema: zod_1.z.object({
|
|
92
|
+
question: zod_1.z.string(),
|
|
93
|
+
mode: zod_1.z.enum(['text', 'options', 'confirm']).optional(),
|
|
94
|
+
options: zod_1.z.array(zod_1.z.string()).optional(),
|
|
95
|
+
allowCustomAnswer: zod_1.z.boolean().optional(),
|
|
96
|
+
}),
|
|
97
|
+
})
|
|
98
|
+
], AskUserWorkflow);
|
|
99
|
+
//# sourceMappingURL=ask-user.workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask-user.workflow.js","sourceRoot":"","sources":["../../../src/workflows/ask-user/ask-user.workflow.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseWorkflow } from '@loopstack/common';
|
|
2
|
+
export declare class ConfirmUserWorkflow extends BaseWorkflow {
|
|
3
|
+
markdown?: string;
|
|
4
|
+
showContent(args: {
|
|
5
|
+
markdown: string;
|
|
6
|
+
}): Promise<void>;
|
|
7
|
+
userConfirmed(): Promise<{
|
|
8
|
+
confirmed: boolean;
|
|
9
|
+
markdown: string;
|
|
10
|
+
}>;
|
|
11
|
+
userDenied(): Promise<{
|
|
12
|
+
confirmed: boolean;
|
|
13
|
+
markdown: string;
|
|
14
|
+
}>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=confirm-user.workflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirm-user.workflow.d.ts","sourceRoot":"","sources":["../../../src/workflows/confirm-user/confirm-user.workflow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAA4B,MAAM,mBAAmB,CAAC;AAG3E,qBAMa,mBAAoB,SAAQ,YAAY;IACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGZ,WAAW,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE;IAMtC,aAAa,IAAI,OAAO,CAAC;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAKlE,UAAU,IAAI,OAAO,CAAC;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAGtE"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ConfirmUserWorkflow = void 0;
|
|
13
|
+
const zod_1 = require("zod");
|
|
14
|
+
const common_1 = require("@loopstack/common");
|
|
15
|
+
const confirm_user_document_1 = require("../../documents/confirm-user-document");
|
|
16
|
+
let ConfirmUserWorkflow = class ConfirmUserWorkflow extends common_1.BaseWorkflow {
|
|
17
|
+
markdown;
|
|
18
|
+
async showContent(args) {
|
|
19
|
+
this.markdown = args.markdown;
|
|
20
|
+
await this.repository.save(confirm_user_document_1.ConfirmUserDocument, { markdown: args.markdown }, { id: 'content' });
|
|
21
|
+
}
|
|
22
|
+
async userConfirmed() {
|
|
23
|
+
return Promise.resolve({ confirmed: true, markdown: this.markdown });
|
|
24
|
+
}
|
|
25
|
+
async userDenied() {
|
|
26
|
+
return Promise.resolve({ confirmed: false, markdown: this.markdown });
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
exports.ConfirmUserWorkflow = ConfirmUserWorkflow;
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, common_1.Initial)({ to: 'waiting_for_confirmation' }),
|
|
32
|
+
__metadata("design:type", Function),
|
|
33
|
+
__metadata("design:paramtypes", [Object]),
|
|
34
|
+
__metadata("design:returntype", Promise)
|
|
35
|
+
], ConfirmUserWorkflow.prototype, "showContent", null);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, common_1.Final)({ from: 'waiting_for_confirmation', wait: true }),
|
|
38
|
+
__metadata("design:type", Function),
|
|
39
|
+
__metadata("design:paramtypes", []),
|
|
40
|
+
__metadata("design:returntype", Promise)
|
|
41
|
+
], ConfirmUserWorkflow.prototype, "userConfirmed", null);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, common_1.Final)({ from: 'waiting_for_confirmation', wait: true }),
|
|
44
|
+
__metadata("design:type", Function),
|
|
45
|
+
__metadata("design:paramtypes", []),
|
|
46
|
+
__metadata("design:returntype", Promise)
|
|
47
|
+
], ConfirmUserWorkflow.prototype, "userDenied", null);
|
|
48
|
+
exports.ConfirmUserWorkflow = ConfirmUserWorkflow = __decorate([
|
|
49
|
+
(0, common_1.Workflow)({
|
|
50
|
+
uiConfig: __dirname + '/confirm-user.ui.yaml',
|
|
51
|
+
schema: zod_1.z.object({
|
|
52
|
+
markdown: zod_1.z.string(),
|
|
53
|
+
}),
|
|
54
|
+
})
|
|
55
|
+
], ConfirmUserWorkflow);
|
|
56
|
+
//# sourceMappingURL=confirm-user.workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirm-user.workflow.js","sourceRoot":"","sources":["../../../src/workflows/confirm-user/confirm-user.workflow.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6BAAwB;AACxB,8CAA2E;AAC3E,iFAA4E;AAQrE,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,qBAAY;IACnD,QAAQ,CAAU;IAGZ,AAAN,KAAK,CAAC,WAAW,CAAC,IAA0B;QAC1C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,2CAAmB,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;IAClG,CAAC;IAGK,AAAN,KAAK,CAAC,aAAa;QACjB,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAS,EAAE,CAAC,CAAC;IACxE,CAAC;IAGK,AAAN,KAAK,CAAC,UAAU;QACd,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAS,EAAE,CAAC,CAAC;IACzE,CAAC;CACF,CAAA;AAlBY,kDAAmB;AAIxB;IADL,IAAA,gBAAO,EAAC,EAAE,EAAE,EAAE,0BAA0B,EAAE,CAAC;;;;sDAI3C;AAGK;IADL,IAAA,cAAK,EAAC,EAAE,IAAI,EAAE,0BAA0B,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;;;;wDAGvD;AAGK;IADL,IAAA,cAAK,EAAC,EAAE,IAAI,EAAE,0BAA0B,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;;;;qDAGvD;8BAjBU,mBAAmB;IAN/B,IAAA,iBAAQ,EAAC;QACR,QAAQ,EAAE,SAAS,GAAG,uBAAuB;QAC7C,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC;YACf,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE;SACrB,CAAC;KACH,CAAC;GACW,mBAAmB,CAkB/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/workflows/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfirmUserWorkflow = exports.AskUserWorkflow = void 0;
|
|
4
|
+
var ask_user_workflow_1 = require("./ask-user/ask-user.workflow");
|
|
5
|
+
Object.defineProperty(exports, "AskUserWorkflow", { enumerable: true, get: function () { return ask_user_workflow_1.AskUserWorkflow; } });
|
|
6
|
+
var confirm_user_workflow_1 = require("./confirm-user/confirm-user.workflow");
|
|
7
|
+
Object.defineProperty(exports, "ConfirmUserWorkflow", { enumerable: true, get: function () { return confirm_user_workflow_1.ConfirmUserWorkflow; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workflows/index.ts"],"names":[],"mappings":";;;AAAA,kEAA+D;AAAtD,oHAAA,eAAe,OAAA;AACxB,8EAA2E;AAAlE,4HAAA,mBAAmB,OAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@loopstack/hitl",
|
|
3
|
+
"displayName": "Loopstack Human-in-the-Loop",
|
|
4
|
+
"description": "Human-in-the-loop workflows for Loopstack — ask questions, present options, and request confirmations from users during workflow execution",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"loopstack",
|
|
7
|
+
"hitl",
|
|
8
|
+
"human-in-the-loop",
|
|
9
|
+
"workflow",
|
|
10
|
+
"user-input"
|
|
11
|
+
],
|
|
12
|
+
"version": "0.1.1",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "Jakob Klippel",
|
|
16
|
+
"url": "https://www.linkedin.com/in/jakob-klippel/"
|
|
17
|
+
},
|
|
18
|
+
"main": "dist/index.js",
|
|
19
|
+
"types": "dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": "./dist/index.js",
|
|
22
|
+
"./src/*": "./src/*"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "nest build",
|
|
26
|
+
"compile": "tsc --noEmit",
|
|
27
|
+
"format": "prettier --write .",
|
|
28
|
+
"lint": "eslint .",
|
|
29
|
+
"test": "jest --passWithNoTests",
|
|
30
|
+
"watch": "nest build --watch"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@loopstack/common": "^0.27.0",
|
|
34
|
+
"@loopstack/core": "^0.27.0",
|
|
35
|
+
"@nestjs/common": "^11.1.19",
|
|
36
|
+
"zod": "^4.3.6"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"src"
|
|
41
|
+
],
|
|
42
|
+
"jest": {
|
|
43
|
+
"moduleFileExtensions": [
|
|
44
|
+
"js",
|
|
45
|
+
"json",
|
|
46
|
+
"ts"
|
|
47
|
+
],
|
|
48
|
+
"rootDir": "src",
|
|
49
|
+
"testRegex": ".*\\.spec\\.ts$",
|
|
50
|
+
"transform": {
|
|
51
|
+
"^.+\\.ts$": "ts-jest"
|
|
52
|
+
},
|
|
53
|
+
"collectCoverageFrom": [
|
|
54
|
+
"**/*.(t|j)s"
|
|
55
|
+
],
|
|
56
|
+
"coverageDirectory": "../coverage",
|
|
57
|
+
"testEnvironment": "node",
|
|
58
|
+
"maxWorkers": 1
|
|
59
|
+
},
|
|
60
|
+
"loopstack": {
|
|
61
|
+
"modules": [
|
|
62
|
+
{
|
|
63
|
+
"path": "src/hitl.module.ts",
|
|
64
|
+
"className": "HitlModule"
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"installModes": [
|
|
68
|
+
"add",
|
|
69
|
+
"install"
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Document } from '@loopstack/common';
|
|
3
|
+
|
|
4
|
+
export const AskUserConfirmDocumentSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
question: z.string(),
|
|
7
|
+
answer: z.string().optional(),
|
|
8
|
+
})
|
|
9
|
+
.strict();
|
|
10
|
+
|
|
11
|
+
export type AskUserConfirmDocumentType = z.infer<typeof AskUserConfirmDocumentSchema>;
|
|
12
|
+
|
|
13
|
+
@Document({
|
|
14
|
+
uiConfig: __dirname + '/ask-user-confirm-document.yaml',
|
|
15
|
+
schema: AskUserConfirmDocumentSchema,
|
|
16
|
+
})
|
|
17
|
+
export class AskUserConfirmDocument {
|
|
18
|
+
question: string;
|
|
19
|
+
answer?: string;
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Document } from '@loopstack/common';
|
|
3
|
+
|
|
4
|
+
export const AskUserDocumentSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
question: z.string(),
|
|
7
|
+
answer: z.string().optional(),
|
|
8
|
+
})
|
|
9
|
+
.strict();
|
|
10
|
+
|
|
11
|
+
export type AskUserDocumentType = z.infer<typeof AskUserDocumentSchema>;
|
|
12
|
+
|
|
13
|
+
@Document({
|
|
14
|
+
uiConfig: __dirname + '/ask-user-document.yaml',
|
|
15
|
+
schema: AskUserDocumentSchema,
|
|
16
|
+
})
|
|
17
|
+
export class AskUserDocument {
|
|
18
|
+
question: string;
|
|
19
|
+
answer?: string;
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Document } from '@loopstack/common';
|
|
3
|
+
|
|
4
|
+
export const AskUserOptionsDocumentSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
question: z.string(),
|
|
7
|
+
options: z.array(z.string()),
|
|
8
|
+
allowCustomAnswer: z.boolean().optional(),
|
|
9
|
+
answer: z.string().optional(),
|
|
10
|
+
})
|
|
11
|
+
.strict();
|
|
12
|
+
|
|
13
|
+
export type AskUserOptionsDocumentType = z.infer<typeof AskUserOptionsDocumentSchema>;
|
|
14
|
+
|
|
15
|
+
@Document({
|
|
16
|
+
uiConfig: __dirname + '/ask-user-options-document.yaml',
|
|
17
|
+
schema: AskUserOptionsDocumentSchema,
|
|
18
|
+
})
|
|
19
|
+
export class AskUserOptionsDocument {
|
|
20
|
+
question: string;
|
|
21
|
+
options: string[];
|
|
22
|
+
allowCustomAnswer?: boolean;
|
|
23
|
+
answer?: string;
|
|
24
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Document } from '@loopstack/common';
|
|
3
|
+
|
|
4
|
+
export const ConfirmUserDocumentSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
markdown: z.string(),
|
|
7
|
+
})
|
|
8
|
+
.strict();
|
|
9
|
+
|
|
10
|
+
export type ConfirmUserDocumentType = z.infer<typeof ConfirmUserDocumentSchema>;
|
|
11
|
+
|
|
12
|
+
@Document({
|
|
13
|
+
uiConfig: __dirname + '/confirm-user-document.yaml',
|
|
14
|
+
schema: ConfirmUserDocumentSchema,
|
|
15
|
+
})
|
|
16
|
+
export class ConfirmUserDocument {
|
|
17
|
+
markdown: string;
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type: document
|
|
2
|
+
ui:
|
|
3
|
+
widgets:
|
|
4
|
+
- widget: form
|
|
5
|
+
options:
|
|
6
|
+
properties:
|
|
7
|
+
markdown:
|
|
8
|
+
widget: markdown-view
|
|
9
|
+
actions:
|
|
10
|
+
- type: button
|
|
11
|
+
transition: userDenied
|
|
12
|
+
label: 'Deny'
|
|
13
|
+
variant: outline
|
|
14
|
+
- type: button
|
|
15
|
+
transition: userConfirmed
|
|
16
|
+
label: 'Confirm'
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { AskUserDocument, AskUserDocumentSchema, AskUserDocumentType } from './ask-user-document';
|
|
2
|
+
export {
|
|
3
|
+
AskUserConfirmDocument,
|
|
4
|
+
AskUserConfirmDocumentSchema,
|
|
5
|
+
AskUserConfirmDocumentType,
|
|
6
|
+
} from './ask-user-confirm-document';
|
|
7
|
+
export {
|
|
8
|
+
AskUserOptionsDocument,
|
|
9
|
+
AskUserOptionsDocumentSchema,
|
|
10
|
+
AskUserOptionsDocumentType,
|
|
11
|
+
} from './ask-user-options-document';
|
|
12
|
+
export { ConfirmUserDocument, ConfirmUserDocumentSchema, ConfirmUserDocumentType } from './confirm-user-document';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Module } from '@nestjs/common';
|
|
2
|
+
import { LoopCoreModule } from '@loopstack/core';
|
|
3
|
+
import { AskUserWorkflow } from './workflows/ask-user/ask-user.workflow';
|
|
4
|
+
import { ConfirmUserWorkflow } from './workflows/confirm-user/confirm-user.workflow';
|
|
5
|
+
|
|
6
|
+
@Module({
|
|
7
|
+
imports: [LoopCoreModule],
|
|
8
|
+
providers: [AskUserWorkflow, ConfirmUserWorkflow],
|
|
9
|
+
exports: [AskUserWorkflow, ConfirmUserWorkflow],
|
|
10
|
+
})
|
|
11
|
+
export class HitlModule {}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
title: 'Ask User'
|
|
2
|
+
|
|
3
|
+
description: |
|
|
4
|
+
Generic sub-workflow that presents a question to the user and waits for their answer.
|
|
5
|
+
Used by async tool calls (e.g. askClarification) to interrupt an agent loop for user input.
|
|
6
|
+
Supports three modes: text (default), options (pick from a list), and confirm (yes/no).
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseWorkflow, Final, Guard, Initial, Transition, Workflow } from '@loopstack/common';
|
|
3
|
+
import { AskUserConfirmDocument } from '../../documents/ask-user-confirm-document';
|
|
4
|
+
import { AskUserDocument } from '../../documents/ask-user-document';
|
|
5
|
+
import { AskUserOptionsDocument } from '../../documents/ask-user-options-document';
|
|
6
|
+
|
|
7
|
+
const AskUserAnswerSchema = z.object({
|
|
8
|
+
answer: z.string(),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
@Workflow({
|
|
12
|
+
uiConfig: __dirname + '/ask-user.ui.yaml',
|
|
13
|
+
schema: z.object({
|
|
14
|
+
question: z.string(),
|
|
15
|
+
mode: z.enum(['text', 'options', 'confirm']).optional(),
|
|
16
|
+
options: z.array(z.string()).optional(),
|
|
17
|
+
allowCustomAnswer: z.boolean().optional(),
|
|
18
|
+
}),
|
|
19
|
+
})
|
|
20
|
+
export class AskUserWorkflow extends BaseWorkflow {
|
|
21
|
+
@Initial({ to: 'show_question' })
|
|
22
|
+
start() {}
|
|
23
|
+
|
|
24
|
+
@Transition({ from: 'show_question', to: 'waiting_for_user', priority: 10 })
|
|
25
|
+
@Guard('isOptionsMode')
|
|
26
|
+
async showQuestionOptions() {
|
|
27
|
+
const { question, options, allowCustomAnswer } = this.ctx.args as {
|
|
28
|
+
question: string;
|
|
29
|
+
options?: string[];
|
|
30
|
+
allowCustomAnswer?: boolean;
|
|
31
|
+
};
|
|
32
|
+
await this.repository.save(
|
|
33
|
+
AskUserOptionsDocument,
|
|
34
|
+
{ question, options: options ?? [], allowCustomAnswer },
|
|
35
|
+
{ id: 'question' },
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Transition({ from: 'show_question', to: 'waiting_for_user', priority: 10 })
|
|
40
|
+
@Guard('isConfirmMode')
|
|
41
|
+
async showQuestionConfirm() {
|
|
42
|
+
const { question } = this.ctx.args as { question: string };
|
|
43
|
+
await this.repository.save(AskUserConfirmDocument, { question }, { id: 'question' });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@Transition({ from: 'show_question', to: 'waiting_for_user' })
|
|
47
|
+
async showQuestionText() {
|
|
48
|
+
const { question } = this.ctx.args as { question: string };
|
|
49
|
+
await this.repository.save(AskUserDocument, { question }, { id: 'question' });
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@Final({ from: 'waiting_for_user', wait: true, schema: AskUserAnswerSchema })
|
|
53
|
+
async userAnswered(payload: { answer: string }): Promise<{ answer: string }> {
|
|
54
|
+
const { question, mode, options, allowCustomAnswer } = this.ctx.args as {
|
|
55
|
+
question: string;
|
|
56
|
+
mode?: string;
|
|
57
|
+
options?: string[];
|
|
58
|
+
allowCustomAnswer?: boolean;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
if (mode === 'options') {
|
|
62
|
+
await this.repository.save(
|
|
63
|
+
AskUserOptionsDocument,
|
|
64
|
+
{ question, options: options ?? [], allowCustomAnswer, answer: payload.answer },
|
|
65
|
+
{ id: 'question' },
|
|
66
|
+
);
|
|
67
|
+
} else if (mode === 'confirm') {
|
|
68
|
+
await this.repository.save(AskUserConfirmDocument, { question, answer: payload.answer }, { id: 'question' });
|
|
69
|
+
} else {
|
|
70
|
+
await this.repository.save(AskUserDocument, { question, answer: payload.answer }, { id: 'question' });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return { answer: payload.answer };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private isOptionsMode(): boolean {
|
|
77
|
+
return (this.ctx.args as { mode?: string })?.mode === 'options';
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private isConfirmMode(): boolean {
|
|
81
|
+
return (this.ctx.args as { mode?: string })?.mode === 'confirm';
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseWorkflow, Final, Initial, Workflow } from '@loopstack/common';
|
|
3
|
+
import { ConfirmUserDocument } from '../../documents/confirm-user-document';
|
|
4
|
+
|
|
5
|
+
@Workflow({
|
|
6
|
+
uiConfig: __dirname + '/confirm-user.ui.yaml',
|
|
7
|
+
schema: z.object({
|
|
8
|
+
markdown: z.string(),
|
|
9
|
+
}),
|
|
10
|
+
})
|
|
11
|
+
export class ConfirmUserWorkflow extends BaseWorkflow {
|
|
12
|
+
markdown?: string;
|
|
13
|
+
|
|
14
|
+
@Initial({ to: 'waiting_for_confirmation' })
|
|
15
|
+
async showContent(args: { markdown: string }) {
|
|
16
|
+
this.markdown = args.markdown;
|
|
17
|
+
await this.repository.save(ConfirmUserDocument, { markdown: args.markdown }, { id: 'content' });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@Final({ from: 'waiting_for_confirmation', wait: true })
|
|
21
|
+
async userConfirmed(): Promise<{ confirmed: boolean; markdown: string }> {
|
|
22
|
+
return Promise.resolve({ confirmed: true, markdown: this.markdown! });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@Final({ from: 'waiting_for_confirmation', wait: true })
|
|
26
|
+
async userDenied(): Promise<{ confirmed: boolean; markdown: string }> {
|
|
27
|
+
return Promise.resolve({ confirmed: false, markdown: this.markdown! });
|
|
28
|
+
}
|
|
29
|
+
}
|