@amaster.ai/workflow-client 1.1.41 → 1.1.43-beta.0
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/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -1
- package/dist/index.d.ts +33 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var httpClient=require('@amaster.ai/http-client');function
|
|
1
|
+
'use strict';var httpClient=require('@amaster.ai/http-client');function l(n){if(!n)return {inputs:{},response_mode:"blocking",user:"anonymous"};if(typeof n=="object"&&(["inputs","response_mode","user","files","trace_id"].some(e=>e in n)||"usage"in n&&Object.keys(n).length===1)){let e=n;return {inputs:e.inputs||{},response_mode:e.response_mode||"blocking",user:e.user||"anonymous",files:e.files,trace_id:e.trace_id,usage:e.usage}}return {inputs:n,response_mode:"blocking",user:"anonymous"}}function p(n=httpClient.createHttpClient(),e={}){let{env:s}=e;return {async run(u,i){if(!u||u.includes("/"))return {data:null,error:{status:400,message:"Invalid workflowName: use workflow YAML filename without extension (no subpaths)"},status:400};let r=l(i);r.inputs||(r.inputs={}),s&&r.inputs.env===void 0&&(r.inputs.env=s);let o=await n.request({url:`/api/runworkflow/${u}`,method:"post",headers:{"Content-Type":"application/json",...s?{"x-env":s}:{}},data:r});if(o.data?.data){let t=o.data.data;return {...o,data:{task_id:o.data.task_id||"",workflow_run_id:o.data.workflow_run_id||"",status:t.status||"unknown",outputs:t.outputs||{},error:t.error||null,elapsed_time:t.elapsed_time||0,total_tokens:t.total_tokens||0,total_steps:t.total_steps||0,created_at:t.created_at||0,finished_at:t.finished_at||0,...t.usage?{usage:t.usage}:{}}}}return {data:null,error:o.error||{status:o.status,message:"Invalid workflow response structure"},status:o.status}}}}exports.createWorkflowClient=p;//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/workflow-client.ts"],"names":["normalizeRunRequest","inputs","req","createWorkflowClient","http","createHttpClient","options","env","workflowName","normalizedRequest","response","innerData"],"mappings":"+
|
|
1
|
+
{"version":3,"sources":["../src/workflow-client.ts"],"names":["normalizeRunRequest","inputs","key","req","createWorkflowClient","http","createHttpClient","options","env","workflowName","normalizedRequest","response","innerData"],"mappings":"+DAuFA,SAASA,CAAAA,CACPC,CAAAA,CACoB,CACpB,GAAI,CAACA,CAAAA,CACH,OAAO,CAAE,MAAA,CAAQ,EAAC,CAAG,aAAA,CAAe,UAAA,CAAY,IAAA,CAAM,WAAY,CAAA,CAGpE,GACE,OAAOA,CAAAA,EAAW,QAAA,GACjB,CAAC,QAAA,CAAU,eAAA,CAAiB,MAAA,CAAQ,QAAS,UAAU,CAAA,CAAE,IAAA,CAAMC,CAAAA,EAAQA,CAAAA,IAAOD,CAAM,CAAA,EAClF,OAAA,GAAWA,CAAAA,EAAU,MAAA,CAAO,IAAA,CAAKA,CAAM,CAAA,CAAE,MAAA,GAAW,CAAA,CAAA,CACvD,CACA,IAAME,CAAAA,CAAMF,CAAAA,CACZ,OAAO,CACL,MAAA,CAAQE,CAAAA,CAAI,MAAA,EAAU,EAAC,CACvB,aAAA,CAAeA,CAAAA,CAAI,aAAA,EAAiB,UAAA,CACpC,IAAA,CAAMA,CAAAA,CAAI,IAAA,EAAQ,YAClB,KAAA,CAAOA,CAAAA,CAAI,KAAA,CACX,QAAA,CAAUA,CAAAA,CAAI,QAAA,CACd,KAAA,CAAOA,CAAAA,CAAI,KACb,CACF,CAEA,OAAO,CACL,MAAA,CAAQF,CAAAA,CACR,aAAA,CAAe,WACf,IAAA,CAAM,WACR,CACF,CAEO,SAASG,CAAAA,CACdC,CAAAA,CAAmBC,2BAAAA,EAAiB,CACpCC,CAAAA,CAAiC,EAAC,CAClB,CAChB,GA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AY,EAAC,CAChC,KAAA,CAAOA,CAAAA,CAAU,KAAA,EAAS,IAAA,CAC1B,aAAcA,CAAAA,CAAU,YAAA,EAAgB,CAAA,CACxC,YAAA,CAAcA,CAAAA,CAAU,YAAA,EAAgB,CAAA,CACxC,WAAA,CAAaA,CAAAA,CAAU,WAAA,EAAe,CAAA,CACtC,UAAA,CAAYA,CAAAA,CAAU,UAAA,EAAc,CAAA,CACpC,WAAA,CAAaA,EAAU,WAAA,EAAe,CAAA,CACtC,GAAIA,CAAAA,CAAU,KAAA,CAAQ,CAAE,KAAA,CAAOA,CAAAA,CAAU,KAAM,CAAA,CAAI,EACrD,CACF,CACF,CAEA,OAAO,CACL,IAAA,CAAM,IAAA,CACN,KAAA,CAAOD,CAAAA,CAAS,KAAA,EAAS,CACvB,MAAA,CAAQA,CAAAA,CAAS,MAAA,CACjB,OAAA,CAAS,qCACX,CAAA,CACA,MAAA,CAAQA,CAAAA,CAAS,MACnB,CACF,CACF,CACF","file":"index.cjs","sourcesContent":["import { type ClientResult, createHttpClient, type HttpClient } from \"@amaster.ai/http-client\";\n\nexport type WorkflowResponseMode = \"blocking\" | \"streaming\";\n\nexport type WorkflowInputValue =\n | string\n | number\n | boolean\n | null\n | undefined\n | Record<string, unknown>\n | unknown[];\n\nexport type WorkflowFile = {\n name?: string;\n type?: string;\n url?: string;\n [key: string]: unknown;\n};\n\nexport type WorkflowRunRequest = {\n inputs?: Record<string, WorkflowInputValue>;\n response_mode?: WorkflowResponseMode;\n user?: string;\n files?: WorkflowFile[];\n trace_id?: string;\n usage?: boolean;\n};\n\nexport type WorkflowUsageSummary = {\n workflow_run_id: string;\n status: string;\n total_tokens: number;\n total_steps: number;\n elapsed_time: number;\n created_at: number | null;\n finished_at: number | null;\n is_finished: boolean;\n};\n\nexport type WorkflowNodeUsage = {\n id: string;\n node_execution_id: string | null;\n index: number;\n node_id: string;\n node_type: string;\n title: string;\n status: string;\n error: string | null;\n elapsed_time: number;\n created_at: number | null;\n finished_at: number | null;\n usage: Record<string, unknown>;\n execution_metadata: Record<string, unknown>;\n};\n\nexport type WorkflowRunUsage = {\n summary: WorkflowUsageSummary;\n estimated_price_by_currency: Record<string, string>;\n nodes: WorkflowNodeUsage[];\n};\n\nexport type WorkflowRunResponse<TOutput = Record<string, unknown>> = {\n task_id: string;\n workflow_run_id: string;\n status: string;\n outputs: TOutput;\n error: string | null;\n elapsed_time: number;\n total_tokens: number;\n total_steps: number;\n created_at: number;\n finished_at: number;\n usage?: WorkflowRunUsage;\n};\n\nexport type WorkflowClient = {\n run<TOutput = Record<string, unknown>>(\n workflowName: string,\n inputs?: Record<string, WorkflowInputValue> | WorkflowRunRequest\n ): Promise<ClientResult<WorkflowRunResponse<TOutput>>>;\n};\n\nexport type WorkflowClientOptions = {\n env?: string;\n};\n\nfunction normalizeRunRequest(\n inputs?: Record<string, WorkflowInputValue> | WorkflowRunRequest\n): WorkflowRunRequest {\n if (!inputs) {\n return { inputs: {}, response_mode: \"blocking\", user: \"anonymous\" };\n }\n\n if (\n typeof inputs === \"object\" &&\n ([\"inputs\", \"response_mode\", \"user\", \"files\", \"trace_id\"].some((key) => key in inputs) ||\n (\"usage\" in inputs && Object.keys(inputs).length === 1))\n ) {\n const req = inputs as WorkflowRunRequest;\n return {\n inputs: req.inputs || {},\n response_mode: req.response_mode || \"blocking\",\n user: req.user || \"anonymous\",\n files: req.files,\n trace_id: req.trace_id,\n usage: req.usage,\n };\n }\n\n return {\n inputs: inputs as Record<string, WorkflowInputValue>,\n response_mode: \"blocking\",\n user: \"anonymous\",\n };\n}\n\nexport function createWorkflowClient(\n http: HttpClient = createHttpClient(),\n options: WorkflowClientOptions = {}\n): WorkflowClient {\n const { env } = options;\n\n return {\n async run<TOutput = Record<string, unknown>>(\n workflowName: string,\n inputs?: Record<string, WorkflowInputValue> | WorkflowRunRequest\n ): Promise<ClientResult<WorkflowRunResponse<TOutput>>> {\n if (!workflowName || workflowName.includes(\"/\")) {\n return {\n data: null,\n error: {\n status: 400,\n message:\n \"Invalid workflowName: use workflow YAML filename without extension (no subpaths)\",\n },\n status: 400,\n };\n }\n\n const normalizedRequest = normalizeRunRequest(inputs);\n\n if (!normalizedRequest.inputs) {\n normalizedRequest.inputs = {};\n }\n\n if (env && normalizedRequest.inputs.env === undefined) {\n normalizedRequest.inputs.env = env;\n }\n\n // Workflow callers can now provide env through createWorkflowClient so\n // downstream workflows can wire environment-aware behavior directly from\n // the runtime context.\n\n const response = await http.request<{\n data: {\n status: string;\n outputs: TOutput;\n error: string | null;\n elapsed_time: number;\n total_tokens: number;\n total_steps: number;\n created_at: number;\n finished_at: number;\n usage?: WorkflowRunUsage;\n };\n task_id: string;\n workflow_run_id: string;\n }>({\n url: `/api/runworkflow/${workflowName}`,\n method: \"post\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...(env ? { \"x-env\": env } : {}),\n },\n data: normalizedRequest,\n });\n\n if (response.data?.data) {\n const innerData = response.data.data;\n return {\n ...response,\n data: {\n task_id: response.data.task_id || \"\",\n workflow_run_id: response.data.workflow_run_id || \"\",\n status: innerData.status || \"unknown\",\n outputs: innerData.outputs || ({} as TOutput),\n error: innerData.error || null,\n elapsed_time: innerData.elapsed_time || 0,\n total_tokens: innerData.total_tokens || 0,\n total_steps: innerData.total_steps || 0,\n created_at: innerData.created_at || 0,\n finished_at: innerData.finished_at || 0,\n ...(innerData.usage ? { usage: innerData.usage } : {}),\n },\n };\n }\n\n return {\n data: null,\n error: response.error || {\n status: response.status,\n message: \"Invalid workflow response structure\",\n },\n status: response.status,\n };\n },\n };\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -14,6 +14,37 @@ type WorkflowRunRequest = {
|
|
|
14
14
|
user?: string;
|
|
15
15
|
files?: WorkflowFile[];
|
|
16
16
|
trace_id?: string;
|
|
17
|
+
usage?: boolean;
|
|
18
|
+
};
|
|
19
|
+
type WorkflowUsageSummary = {
|
|
20
|
+
workflow_run_id: string;
|
|
21
|
+
status: string;
|
|
22
|
+
total_tokens: number;
|
|
23
|
+
total_steps: number;
|
|
24
|
+
elapsed_time: number;
|
|
25
|
+
created_at: number | null;
|
|
26
|
+
finished_at: number | null;
|
|
27
|
+
is_finished: boolean;
|
|
28
|
+
};
|
|
29
|
+
type WorkflowNodeUsage = {
|
|
30
|
+
id: string;
|
|
31
|
+
node_execution_id: string | null;
|
|
32
|
+
index: number;
|
|
33
|
+
node_id: string;
|
|
34
|
+
node_type: string;
|
|
35
|
+
title: string;
|
|
36
|
+
status: string;
|
|
37
|
+
error: string | null;
|
|
38
|
+
elapsed_time: number;
|
|
39
|
+
created_at: number | null;
|
|
40
|
+
finished_at: number | null;
|
|
41
|
+
usage: Record<string, unknown>;
|
|
42
|
+
execution_metadata: Record<string, unknown>;
|
|
43
|
+
};
|
|
44
|
+
type WorkflowRunUsage = {
|
|
45
|
+
summary: WorkflowUsageSummary;
|
|
46
|
+
estimated_price_by_currency: Record<string, string>;
|
|
47
|
+
nodes: WorkflowNodeUsage[];
|
|
17
48
|
};
|
|
18
49
|
type WorkflowRunResponse<TOutput = Record<string, unknown>> = {
|
|
19
50
|
task_id: string;
|
|
@@ -26,6 +57,7 @@ type WorkflowRunResponse<TOutput = Record<string, unknown>> = {
|
|
|
26
57
|
total_steps: number;
|
|
27
58
|
created_at: number;
|
|
28
59
|
finished_at: number;
|
|
60
|
+
usage?: WorkflowRunUsage;
|
|
29
61
|
};
|
|
30
62
|
type WorkflowClient = {
|
|
31
63
|
run<TOutput = Record<string, unknown>>(workflowName: string, inputs?: Record<string, WorkflowInputValue> | WorkflowRunRequest): Promise<ClientResult<WorkflowRunResponse<TOutput>>>;
|
|
@@ -35,4 +67,4 @@ type WorkflowClientOptions = {
|
|
|
35
67
|
};
|
|
36
68
|
declare function createWorkflowClient(http?: HttpClient, options?: WorkflowClientOptions): WorkflowClient;
|
|
37
69
|
|
|
38
|
-
export { type WorkflowClient, type WorkflowClientOptions, type WorkflowFile, type WorkflowInputValue, type WorkflowResponseMode, type WorkflowRunRequest, type WorkflowRunResponse, createWorkflowClient };
|
|
70
|
+
export { type WorkflowClient, type WorkflowClientOptions, type WorkflowFile, type WorkflowInputValue, type WorkflowNodeUsage, type WorkflowResponseMode, type WorkflowRunRequest, type WorkflowRunResponse, type WorkflowRunUsage, type WorkflowUsageSummary, createWorkflowClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,37 @@ type WorkflowRunRequest = {
|
|
|
14
14
|
user?: string;
|
|
15
15
|
files?: WorkflowFile[];
|
|
16
16
|
trace_id?: string;
|
|
17
|
+
usage?: boolean;
|
|
18
|
+
};
|
|
19
|
+
type WorkflowUsageSummary = {
|
|
20
|
+
workflow_run_id: string;
|
|
21
|
+
status: string;
|
|
22
|
+
total_tokens: number;
|
|
23
|
+
total_steps: number;
|
|
24
|
+
elapsed_time: number;
|
|
25
|
+
created_at: number | null;
|
|
26
|
+
finished_at: number | null;
|
|
27
|
+
is_finished: boolean;
|
|
28
|
+
};
|
|
29
|
+
type WorkflowNodeUsage = {
|
|
30
|
+
id: string;
|
|
31
|
+
node_execution_id: string | null;
|
|
32
|
+
index: number;
|
|
33
|
+
node_id: string;
|
|
34
|
+
node_type: string;
|
|
35
|
+
title: string;
|
|
36
|
+
status: string;
|
|
37
|
+
error: string | null;
|
|
38
|
+
elapsed_time: number;
|
|
39
|
+
created_at: number | null;
|
|
40
|
+
finished_at: number | null;
|
|
41
|
+
usage: Record<string, unknown>;
|
|
42
|
+
execution_metadata: Record<string, unknown>;
|
|
43
|
+
};
|
|
44
|
+
type WorkflowRunUsage = {
|
|
45
|
+
summary: WorkflowUsageSummary;
|
|
46
|
+
estimated_price_by_currency: Record<string, string>;
|
|
47
|
+
nodes: WorkflowNodeUsage[];
|
|
17
48
|
};
|
|
18
49
|
type WorkflowRunResponse<TOutput = Record<string, unknown>> = {
|
|
19
50
|
task_id: string;
|
|
@@ -26,6 +57,7 @@ type WorkflowRunResponse<TOutput = Record<string, unknown>> = {
|
|
|
26
57
|
total_steps: number;
|
|
27
58
|
created_at: number;
|
|
28
59
|
finished_at: number;
|
|
60
|
+
usage?: WorkflowRunUsage;
|
|
29
61
|
};
|
|
30
62
|
type WorkflowClient = {
|
|
31
63
|
run<TOutput = Record<string, unknown>>(workflowName: string, inputs?: Record<string, WorkflowInputValue> | WorkflowRunRequest): Promise<ClientResult<WorkflowRunResponse<TOutput>>>;
|
|
@@ -35,4 +67,4 @@ type WorkflowClientOptions = {
|
|
|
35
67
|
};
|
|
36
68
|
declare function createWorkflowClient(http?: HttpClient, options?: WorkflowClientOptions): WorkflowClient;
|
|
37
69
|
|
|
38
|
-
export { type WorkflowClient, type WorkflowClientOptions, type WorkflowFile, type WorkflowInputValue, type WorkflowResponseMode, type WorkflowRunRequest, type WorkflowRunResponse, createWorkflowClient };
|
|
70
|
+
export { type WorkflowClient, type WorkflowClientOptions, type WorkflowFile, type WorkflowInputValue, type WorkflowNodeUsage, type WorkflowResponseMode, type WorkflowRunRequest, type WorkflowRunResponse, type WorkflowRunUsage, type WorkflowUsageSummary, createWorkflowClient };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {createHttpClient}from'@amaster.ai/http-client';function
|
|
1
|
+
import {createHttpClient}from'@amaster.ai/http-client';function l(n){if(!n)return {inputs:{},response_mode:"blocking",user:"anonymous"};if(typeof n=="object"&&(["inputs","response_mode","user","files","trace_id"].some(e=>e in n)||"usage"in n&&Object.keys(n).length===1)){let e=n;return {inputs:e.inputs||{},response_mode:e.response_mode||"blocking",user:e.user||"anonymous",files:e.files,trace_id:e.trace_id,usage:e.usage}}return {inputs:n,response_mode:"blocking",user:"anonymous"}}function p(n=createHttpClient(),e={}){let{env:s}=e;return {async run(u,i){if(!u||u.includes("/"))return {data:null,error:{status:400,message:"Invalid workflowName: use workflow YAML filename without extension (no subpaths)"},status:400};let r=l(i);r.inputs||(r.inputs={}),s&&r.inputs.env===void 0&&(r.inputs.env=s);let o=await n.request({url:`/api/runworkflow/${u}`,method:"post",headers:{"Content-Type":"application/json",...s?{"x-env":s}:{}},data:r});if(o.data?.data){let t=o.data.data;return {...o,data:{task_id:o.data.task_id||"",workflow_run_id:o.data.workflow_run_id||"",status:t.status||"unknown",outputs:t.outputs||{},error:t.error||null,elapsed_time:t.elapsed_time||0,total_tokens:t.total_tokens||0,total_steps:t.total_steps||0,created_at:t.created_at||0,finished_at:t.finished_at||0,...t.usage?{usage:t.usage}:{}}}}return {data:null,error:o.error||{status:o.status,message:"Invalid workflow response structure"},status:o.status}}}}export{p as createWorkflowClient};//# sourceMappingURL=index.js.map
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/workflow-client.ts"],"names":["normalizeRunRequest","inputs","req","createWorkflowClient","http","createHttpClient","options","env","workflowName","normalizedRequest","response","innerData"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/workflow-client.ts"],"names":["normalizeRunRequest","inputs","key","req","createWorkflowClient","http","createHttpClient","options","env","workflowName","normalizedRequest","response","innerData"],"mappings":"uDAuFA,SAASA,CAAAA,CACPC,CAAAA,CACoB,CACpB,GAAI,CAACA,CAAAA,CACH,OAAO,CAAE,MAAA,CAAQ,EAAC,CAAG,aAAA,CAAe,UAAA,CAAY,IAAA,CAAM,WAAY,CAAA,CAGpE,GACE,OAAOA,CAAAA,EAAW,QAAA,GACjB,CAAC,QAAA,CAAU,eAAA,CAAiB,MAAA,CAAQ,QAAS,UAAU,CAAA,CAAE,IAAA,CAAMC,CAAAA,EAAQA,CAAAA,IAAOD,CAAM,CAAA,EAClF,OAAA,GAAWA,CAAAA,EAAU,MAAA,CAAO,IAAA,CAAKA,CAAM,CAAA,CAAE,MAAA,GAAW,CAAA,CAAA,CACvD,CACA,IAAME,CAAAA,CAAMF,CAAAA,CACZ,OAAO,CACL,MAAA,CAAQE,CAAAA,CAAI,MAAA,EAAU,EAAC,CACvB,aAAA,CAAeA,CAAAA,CAAI,aA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IC,CAAAA,CAAS,IAAA,EAAM,IAAA,CAAM,CACvB,IAAMC,CAAAA,CAAYD,CAAAA,CAAS,IAAA,CAAK,IAAA,CAChC,OAAO,CACL,GAAGA,CAAAA,CACH,IAAA,CAAM,CACJ,OAAA,CAASA,CAAAA,CAAS,IAAA,CAAK,OAAA,EAAW,EAAA,CAClC,eAAA,CAAiBA,EAAS,IAAA,CAAK,eAAA,EAAmB,EAAA,CAClD,MAAA,CAAQC,CAAAA,CAAU,MAAA,EAAU,SAAA,CAC5B,OAAA,CAASA,CAAAA,CAAU,OAAA,EAAY,EAAC,CAChC,KAAA,CAAOA,CAAAA,CAAU,KAAA,EAAS,IAAA,CAC1B,aAAcA,CAAAA,CAAU,YAAA,EAAgB,CAAA,CACxC,YAAA,CAAcA,CAAAA,CAAU,YAAA,EAAgB,CAAA,CACxC,WAAA,CAAaA,CAAAA,CAAU,WAAA,EAAe,CAAA,CACtC,UAAA,CAAYA,CAAAA,CAAU,UAAA,EAAc,CAAA,CACpC,WAAA,CAAaA,EAAU,WAAA,EAAe,CAAA,CACtC,GAAIA,CAAAA,CAAU,KAAA,CAAQ,CAAE,KAAA,CAAOA,CAAAA,CAAU,KAAM,CAAA,CAAI,EACrD,CACF,CACF,CAEA,OAAO,CACL,IAAA,CAAM,IAAA,CACN,KAAA,CAAOD,CAAAA,CAAS,KAAA,EAAS,CACvB,MAAA,CAAQA,CAAAA,CAAS,MAAA,CACjB,OAAA,CAAS,qCACX,CAAA,CACA,MAAA,CAAQA,CAAAA,CAAS,MACnB,CACF,CACF,CACF","file":"index.js","sourcesContent":["import { type ClientResult, createHttpClient, type HttpClient } from \"@amaster.ai/http-client\";\n\nexport type WorkflowResponseMode = \"blocking\" | \"streaming\";\n\nexport type WorkflowInputValue =\n | string\n | number\n | boolean\n | null\n | undefined\n | Record<string, unknown>\n | unknown[];\n\nexport type WorkflowFile = {\n name?: string;\n type?: string;\n url?: string;\n [key: string]: unknown;\n};\n\nexport type WorkflowRunRequest = {\n inputs?: Record<string, WorkflowInputValue>;\n response_mode?: WorkflowResponseMode;\n user?: string;\n files?: WorkflowFile[];\n trace_id?: string;\n usage?: boolean;\n};\n\nexport type WorkflowUsageSummary = {\n workflow_run_id: string;\n status: string;\n total_tokens: number;\n total_steps: number;\n elapsed_time: number;\n created_at: number | null;\n finished_at: number | null;\n is_finished: boolean;\n};\n\nexport type WorkflowNodeUsage = {\n id: string;\n node_execution_id: string | null;\n index: number;\n node_id: string;\n node_type: string;\n title: string;\n status: string;\n error: string | null;\n elapsed_time: number;\n created_at: number | null;\n finished_at: number | null;\n usage: Record<string, unknown>;\n execution_metadata: Record<string, unknown>;\n};\n\nexport type WorkflowRunUsage = {\n summary: WorkflowUsageSummary;\n estimated_price_by_currency: Record<string, string>;\n nodes: WorkflowNodeUsage[];\n};\n\nexport type WorkflowRunResponse<TOutput = Record<string, unknown>> = {\n task_id: string;\n workflow_run_id: string;\n status: string;\n outputs: TOutput;\n error: string | null;\n elapsed_time: number;\n total_tokens: number;\n total_steps: number;\n created_at: number;\n finished_at: number;\n usage?: WorkflowRunUsage;\n};\n\nexport type WorkflowClient = {\n run<TOutput = Record<string, unknown>>(\n workflowName: string,\n inputs?: Record<string, WorkflowInputValue> | WorkflowRunRequest\n ): Promise<ClientResult<WorkflowRunResponse<TOutput>>>;\n};\n\nexport type WorkflowClientOptions = {\n env?: string;\n};\n\nfunction normalizeRunRequest(\n inputs?: Record<string, WorkflowInputValue> | WorkflowRunRequest\n): WorkflowRunRequest {\n if (!inputs) {\n return { inputs: {}, response_mode: \"blocking\", user: \"anonymous\" };\n }\n\n if (\n typeof inputs === \"object\" &&\n ([\"inputs\", \"response_mode\", \"user\", \"files\", \"trace_id\"].some((key) => key in inputs) ||\n (\"usage\" in inputs && Object.keys(inputs).length === 1))\n ) {\n const req = inputs as WorkflowRunRequest;\n return {\n inputs: req.inputs || {},\n response_mode: req.response_mode || \"blocking\",\n user: req.user || \"anonymous\",\n files: req.files,\n trace_id: req.trace_id,\n usage: req.usage,\n };\n }\n\n return {\n inputs: inputs as Record<string, WorkflowInputValue>,\n response_mode: \"blocking\",\n user: \"anonymous\",\n };\n}\n\nexport function createWorkflowClient(\n http: HttpClient = createHttpClient(),\n options: WorkflowClientOptions = {}\n): WorkflowClient {\n const { env } = options;\n\n return {\n async run<TOutput = Record<string, unknown>>(\n workflowName: string,\n inputs?: Record<string, WorkflowInputValue> | WorkflowRunRequest\n ): Promise<ClientResult<WorkflowRunResponse<TOutput>>> {\n if (!workflowName || workflowName.includes(\"/\")) {\n return {\n data: null,\n error: {\n status: 400,\n message:\n \"Invalid workflowName: use workflow YAML filename without extension (no subpaths)\",\n },\n status: 400,\n };\n }\n\n const normalizedRequest = normalizeRunRequest(inputs);\n\n if (!normalizedRequest.inputs) {\n normalizedRequest.inputs = {};\n }\n\n if (env && normalizedRequest.inputs.env === undefined) {\n normalizedRequest.inputs.env = env;\n }\n\n // Workflow callers can now provide env through createWorkflowClient so\n // downstream workflows can wire environment-aware behavior directly from\n // the runtime context.\n\n const response = await http.request<{\n data: {\n status: string;\n outputs: TOutput;\n error: string | null;\n elapsed_time: number;\n total_tokens: number;\n total_steps: number;\n created_at: number;\n finished_at: number;\n usage?: WorkflowRunUsage;\n };\n task_id: string;\n workflow_run_id: string;\n }>({\n url: `/api/runworkflow/${workflowName}`,\n method: \"post\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...(env ? { \"x-env\": env } : {}),\n },\n data: normalizedRequest,\n });\n\n if (response.data?.data) {\n const innerData = response.data.data;\n return {\n ...response,\n data: {\n task_id: response.data.task_id || \"\",\n workflow_run_id: response.data.workflow_run_id || \"\",\n status: innerData.status || \"unknown\",\n outputs: innerData.outputs || ({} as TOutput),\n error: innerData.error || null,\n elapsed_time: innerData.elapsed_time || 0,\n total_tokens: innerData.total_tokens || 0,\n total_steps: innerData.total_steps || 0,\n created_at: innerData.created_at || 0,\n finished_at: innerData.finished_at || 0,\n ...(innerData.usage ? { usage: innerData.usage } : {}),\n },\n };\n }\n\n return {\n data: null,\n error: response.error || {\n status: response.status,\n message: \"Invalid workflow response structure\",\n },\n status: response.status,\n };\n },\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amaster.ai/workflow-client",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.43-beta.0",
|
|
4
4
|
"description": "Workflow execution client",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"registry": "https://registry.npmjs.org/"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@amaster.ai/http-client": "1.1.
|
|
33
|
+
"@amaster.ai/http-client": "1.1.43-beta.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"axios": "^1.11.0"
|