@workglow/tasks 0.2.8 → 0.2.9
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/browser.d.ts +1 -1
- package/dist/browser.js +162 -173
- package/dist/browser.js.map +5 -5
- package/dist/bun.d.ts +1 -1
- package/dist/bun.js +162 -173
- package/dist/bun.js.map +5 -5
- package/dist/common.d.ts +1 -1
- package/dist/electron.d.ts +1 -1
- package/dist/electron.js +162 -173
- package/dist/electron.js.map +5 -5
- package/dist/node.d.ts +1 -1
- package/dist/node.js +162 -173
- package/dist/node.js.map +5 -5
- package/dist/task/HumanApprovalTask.d.ts +1 -1
- package/dist/task/HumanApprovalTask.d.ts.map +1 -1
- package/dist/task/HumanInputTask.d.ts +1 -100
- package/dist/task/HumanInputTask.d.ts.map +1 -1
- package/dist/task/McpElicitationConnector.d.ts +3 -2
- package/dist/task/McpElicitationConnector.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { IExecuteContext } from "@workglow/task-graph";
|
|
7
7
|
import { CreateWorkflow, Task, TaskConfig } from "@workglow/task-graph";
|
|
8
|
+
import type { HumanResponseAction } from "@workglow/util";
|
|
8
9
|
import type { DataPortSchema, FromSchema } from "@workglow/util/schema";
|
|
9
|
-
import type { HumanResponseAction } from "./HumanInputTask";
|
|
10
10
|
export type HumanApprovalTaskConfig = TaskConfig & {
|
|
11
11
|
/** Target human identifier — defaults to "default" */
|
|
12
12
|
targetHumanId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HumanApprovalTask.d.ts","sourceRoot":"","sources":["../../src/task/HumanApprovalTask.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EACL,cAAc,EACd,IAAI,EAEJ,UAAU,EAGX,MAAM,sBAAsB,CAAC;AAE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,EACtB,uBAAuB,EACvB,uBAAuB,CACxB;IACC,gBAAyB,IAAI,uBAAuB;IACpD,gBAAyB,QAAQ,kBAAkB;IACnD,OAAuB,KAAK,SAAoB;IAChD,OAAuB,WAAW,SACuD;IACzF,gBAAyB,SAAS,SAAS;IAE3C,OAAuB,YAAY,IAAI,cAAc,CAEpD;IAED,OAAgB,WAAW,IAAI,cAAc,CAE5C;IAED,OAAgB,YAAY,IAAI,cAAc,CAE7C;IAEc,OAAO,CACpB,KAAK,EAAE,sBAAsB,EAC7B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,uBAAuB,CAAC,CAwDlC;CACF;AAED,OAAO,QAAQ,sBAAsB,CAAC,CAAC;IACrC,UAAU,QAAQ;QAChB,aAAa,EAAE,cAAc,CAC3B,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,CACxB,CAAC;KACH;CACF"}
|
|
@@ -6,101 +6,7 @@
|
|
|
6
6
|
import { CreateWorkflow, Task, TaskConfig } from "@workglow/task-graph";
|
|
7
7
|
import type { IExecuteContext } from "@workglow/task-graph";
|
|
8
8
|
import type { DataPortSchema } from "@workglow/util/schema";
|
|
9
|
-
|
|
10
|
-
* The kind of interaction being requested.
|
|
11
|
-
*
|
|
12
|
-
* - "notify": One-way message, no response expected. Fire-and-forget.
|
|
13
|
-
* - "display": Present rich content (markdown, data, visualization hints).
|
|
14
|
-
* Response optional (acknowledgment).
|
|
15
|
-
* - "elicit": Request structured input via a form schema (MCP elicitation).
|
|
16
|
-
* Response expected with user-submitted data.
|
|
17
|
-
*/
|
|
18
|
-
export type HumanInteractionKind = "notify" | "display" | "elicit";
|
|
19
|
-
/** User action in response to an interaction (MCP-aligned for "elicit" kind) */
|
|
20
|
-
export type HumanResponseAction = "accept" | "decline" | "cancel";
|
|
21
|
-
/**
|
|
22
|
-
* A unified request sent to a human via an IHumanConnector.
|
|
23
|
-
*
|
|
24
|
-
* The `kind` field determines the interaction pattern. The `content` schema
|
|
25
|
-
* describes WHAT to render — the UI layer interprets it based on `kind`.
|
|
26
|
-
*/
|
|
27
|
-
export interface IHumanRequest {
|
|
28
|
-
/** Unique identifier for this request (used to correlate responses) */
|
|
29
|
-
readonly requestId: string;
|
|
30
|
-
/** Target human identifier — "default" for the main user, or a specific user/role ID */
|
|
31
|
-
readonly targetHumanId: string;
|
|
32
|
-
/** What kind of interaction this is */
|
|
33
|
-
readonly kind: HumanInteractionKind;
|
|
34
|
-
/** Explanatory message shown to the human */
|
|
35
|
-
readonly message: string;
|
|
36
|
-
/**
|
|
37
|
-
* Content schema — describes what to render.
|
|
38
|
-
*
|
|
39
|
-
* For "notify": Describes notification content (may be empty, message suffices).
|
|
40
|
-
* For "display": Describes the data/visualization to present. Properties contain
|
|
41
|
-
* the actual data to render. Use x-ui-viewer annotations for hints.
|
|
42
|
-
* For "elicit": Describes the form fields for user input (MCP requestedSchema).
|
|
43
|
-
*/
|
|
44
|
-
readonly contentSchema: DataPortSchema;
|
|
45
|
-
/**
|
|
46
|
-
* Concrete data to display (for "notify" and "display" kinds).
|
|
47
|
-
* For "elicit", this is typically empty — the human provides the data.
|
|
48
|
-
*/
|
|
49
|
-
readonly contentData: Record<string, unknown> | undefined;
|
|
50
|
-
/** Whether a response is expected. Default: true for "elicit", false for "notify"/"display". */
|
|
51
|
-
readonly expectsResponse: boolean;
|
|
52
|
-
/** Interaction mode: single request-response or multi-turn conversation */
|
|
53
|
-
readonly mode: "single" | "multi-turn";
|
|
54
|
-
/** Arbitrary context data passed through to the connector */
|
|
55
|
-
readonly metadata: Record<string, unknown> | undefined;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* A response from a human, collected by the IHumanConnector.
|
|
59
|
-
* For "notify"/"display" interactions, this may just be an acknowledgment.
|
|
60
|
-
*/
|
|
61
|
-
export interface IHumanResponse {
|
|
62
|
-
/** Correlates to the IHumanRequest.requestId */
|
|
63
|
-
readonly requestId: string;
|
|
64
|
-
/**
|
|
65
|
-
* The human's action:
|
|
66
|
-
* - "accept": user submitted data or acknowledged
|
|
67
|
-
* - "decline": user explicitly refused
|
|
68
|
-
* - "cancel": user dismissed without choosing
|
|
69
|
-
*/
|
|
70
|
-
readonly action: HumanResponseAction;
|
|
71
|
-
/** The human's response data (present when action is "accept" and kind is "elicit") */
|
|
72
|
-
readonly content: Record<string, unknown> | undefined;
|
|
73
|
-
/** Whether the conversation is complete. Always true for "single" mode. */
|
|
74
|
-
readonly done: boolean;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Interface for reaching a human and sending interactions.
|
|
78
|
-
*
|
|
79
|
-
* Unified schema-driven: the `kind` field in IHumanRequest determines the
|
|
80
|
-
* interaction pattern. The connector renders accordingly — a notification
|
|
81
|
-
* toast, a data visualization, or an input form.
|
|
82
|
-
*
|
|
83
|
-
* The primary MCP-backed implementation is McpElicitationConnector.
|
|
84
|
-
*/
|
|
85
|
-
export interface IHumanConnector {
|
|
86
|
-
/**
|
|
87
|
-
* Send an interaction to a human.
|
|
88
|
-
*
|
|
89
|
-
* For "notify" and "display" kinds that don't expect a response, the
|
|
90
|
-
* connector may resolve immediately with action "accept" and no content.
|
|
91
|
-
*
|
|
92
|
-
* For "elicit" kind, blocks until the human submits, declines, or cancels.
|
|
93
|
-
* Must respect the AbortSignal for cancellation.
|
|
94
|
-
*/
|
|
95
|
-
send(request: IHumanRequest, signal: AbortSignal): Promise<IHumanResponse>;
|
|
96
|
-
/**
|
|
97
|
-
* Send a follow-up in a multi-turn conversation.
|
|
98
|
-
* Only called when mode is "multi-turn" and the previous response had done=false.
|
|
99
|
-
*/
|
|
100
|
-
followUp?(request: IHumanRequest, previousResponse: IHumanResponse, signal: AbortSignal): Promise<IHumanResponse>;
|
|
101
|
-
}
|
|
102
|
-
/** Service token for resolving the IHumanConnector from ServiceRegistry */
|
|
103
|
-
export declare const HUMAN_CONNECTOR: import("@workglow/util").ServiceToken<IHumanConnector>;
|
|
9
|
+
import type { HumanInteractionKind, HumanResponseAction } from "@workglow/util";
|
|
104
10
|
export type HumanInputTaskConfig = TaskConfig & {
|
|
105
11
|
/** Target human identifier — defaults to "default" */
|
|
106
12
|
targetHumanId?: string;
|
|
@@ -151,11 +57,6 @@ export declare class HumanInputTask extends Task<HumanInputTaskInput, HumanInput
|
|
|
151
57
|
outputSchema(): DataPortSchema;
|
|
152
58
|
execute(input: HumanInputTaskInput, context: IExecuteContext): Promise<HumanInputTaskOutput>;
|
|
153
59
|
}
|
|
154
|
-
/**
|
|
155
|
-
* Resolves the IHumanConnector from the execution context's ServiceRegistry.
|
|
156
|
-
* Shared by HumanInputTask and HumanApprovalTask.
|
|
157
|
-
*/
|
|
158
|
-
export declare function resolveHumanConnector(context: IExecuteContext): IHumanConnector;
|
|
159
60
|
declare module "@workglow/task-graph" {
|
|
160
61
|
interface Workflow {
|
|
161
62
|
humanInput: CreateWorkflow<HumanInputTaskInput, HumanInputTaskOutput, HumanInputTaskConfig>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HumanInputTask.d.ts","sourceRoot":"","sources":["../../src/task/HumanInputTask.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,cAAc,EACd,IAAI,EAEJ,UAAU,EAIX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"HumanInputTask.d.ts","sourceRoot":"","sources":["../../src/task/HumanInputTask.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,cAAc,EACd,IAAI,EAEJ,UAAU,EAIX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAkB,MAAM,uBAAuB,CAAC;AAE5E,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EA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;IAEc,OAAO,CACpB,KAAK,EAAE,mBAAmB,EAC1B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,oBAAoB,CAAC,CAsE/B;CACF;AAED,OAAO,QAAQ,sBAAsB,CAAC,CAAC;IACrC,UAAU,QAAQ;QAChB,UAAU,EAAE,cAAc,CAAC,mBAAmB,EAAE,oBAAoB,EAAE,oBAAoB,CAAC,CAAC;KAC7F;CACF"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import type { Server } from "@modelcontextprotocol/sdk/server";
|
|
7
|
-
import type { IHumanConnector, IHumanRequest, IHumanResponse } from "
|
|
7
|
+
import type { IHumanConnector, IHumanRequest, IHumanResponse } from "@workglow/util";
|
|
8
8
|
/**
|
|
9
9
|
* IHumanConnector implementation that delegates to MCP Server.elicitInput().
|
|
10
10
|
*
|
|
@@ -16,7 +16,8 @@ import type { IHumanConnector, IHumanRequest, IHumanResponse } from "./HumanInpu
|
|
|
16
16
|
* Usage:
|
|
17
17
|
* ```ts
|
|
18
18
|
* import { Server } from "@modelcontextprotocol/sdk/server";
|
|
19
|
-
* import { McpElicitationConnector
|
|
19
|
+
* import { McpElicitationConnector } from "@workglow/tasks";
|
|
20
|
+
* import { HUMAN_CONNECTOR } from "@workglow/util";
|
|
20
21
|
*
|
|
21
22
|
* const mcpServer: Server = ...; // your MCP server instance
|
|
22
23
|
* const connector = new McpElicitationConnector(mcpServer);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"McpElicitationConnector.d.ts","sourceRoot":"","sources":["../../src/task/McpElicitationConnector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAE/D,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"McpElicitationConnector.d.ts","sourceRoot":"","sources":["../../src/task/McpElicitationConnector.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAE/D,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AA2BrF;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,uBAAwB,YAAW,eAAe;IACjD,OAAO,CAAC,QAAQ,CAAC,MAAM;IAAnC,YAA6B,MAAM,EAAE,MAAM,EAAI;IAEzC,IAAI,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAc/E;IAED;;;OAGG;IACG,QAAQ,CACZ,OAAO,EAAE,aAAa,EACtB,iBAAiB,EAAE,cAAc,EACjC,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,cAAc,CAAC,CAEzB;YAMa,YAAY;YA4BZ,aAAa;YAgCb,YAAY;CAkB3B"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workglow/tasks",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.9",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/workglow-dev/workglow.git",
|
|
@@ -62,10 +62,10 @@
|
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
65
|
-
"@workglow/task-graph": "0.2.
|
|
66
|
-
"@workglow/util": "0.2.
|
|
67
|
-
"@workglow/job-queue": "0.2.
|
|
68
|
-
"@workglow/storage": "0.2.
|
|
65
|
+
"@workglow/task-graph": "0.2.9",
|
|
66
|
+
"@workglow/util": "0.2.9",
|
|
67
|
+
"@workglow/job-queue": "0.2.9",
|
|
68
|
+
"@workglow/storage": "0.2.9"
|
|
69
69
|
},
|
|
70
70
|
"peerDependenciesMeta": {
|
|
71
71
|
"@modelcontextprotocol/sdk": {
|
|
@@ -87,10 +87,10 @@
|
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
89
89
|
"@types/papaparse": "^5.5.2",
|
|
90
|
-
"@workglow/job-queue": "0.2.
|
|
91
|
-
"@workglow/storage": "0.2.
|
|
92
|
-
"@workglow/task-graph": "0.2.
|
|
93
|
-
"@workglow/util": "0.2.
|
|
90
|
+
"@workglow/job-queue": "0.2.9",
|
|
91
|
+
"@workglow/storage": "0.2.9",
|
|
92
|
+
"@workglow/task-graph": "0.2.9",
|
|
93
|
+
"@workglow/util": "0.2.9"
|
|
94
94
|
},
|
|
95
95
|
"optionalDependencies": {
|
|
96
96
|
"papaparse": "^5.5.3",
|