@amaster.ai/workflow-client 1.0.0-alpha.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Amaster Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # @amaster.ai/workflow-client
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ 'use strict';var httpClient=require('@amaster.ai/http-client');function l(e){if(!e)return {inputs:{},response_mode:"blocking",user:"anonymous"};if(typeof e=="object"&&("inputs"in e||"response_mode"in e||"user"in e||"files"in e||"trace_id"in e)){let t=e;return {inputs:t.inputs||{},response_mode:t.response_mode||"blocking",user:t.user||"anonymous",files:t.files,trace_id:t.trace_id}}return {inputs:e,response_mode:"blocking",user:"anonymous"}}function i(e=httpClient.createHttpClient()){return {async run(t,n){if(!t||t.includes("/"))return {data:null,error:{status:400,message:"Invalid workflowName: use workflow YAML filename without extension (no subpaths)"},status:400};let s=l(n),o=await e.request({url:`/api/runworkflow/${t}`,method:"post",headers:{"Content-Type":"application/json"},data:s});if(o.data?.data){let r=o.data.data;return {...o,data:{task_id:o.data.task_id||"",workflow_run_id:o.data.workflow_run_id||"",status:r.status||"unknown",outputs:r.outputs||{},error:r.error||null,elapsed_time:r.elapsed_time||0,total_tokens:r.total_tokens||0,total_steps:r.total_steps||0,created_at:r.created_at||0,finished_at:r.finished_at||0}}}return {data:null,error:o.error||{status:o.status,message:"Invalid workflow response structure"},status:o.status}}}}exports.createWorkflowClient=i;//# sourceMappingURL=index.cjs.map
2
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/workflow-client.ts"],"names":["normalizeRunRequest","inputs","req","createWorkflowClient","http","createHttpClient","workflowName","normalizedRequest","response","innerData"],"mappings":"+DAmDA,SAASA,EACPC,CAAAA,CACoB,CACpB,GAAI,CAACA,CAAAA,CACH,OAAO,CAAE,MAAA,CAAQ,GAAI,aAAA,CAAe,UAAA,CAAY,KAAM,WAAY,CAAA,CAGpE,GACE,OAAOA,CAAAA,EAAW,QAAA,GACjB,WAAYA,CAAAA,EACX,eAAA,GAAmBA,GACnB,MAAA,GAAUA,CAAAA,EACV,UAAWA,CAAAA,EACX,UAAA,GAAcA,CAAAA,CAAAA,CAChB,CACA,IAAMC,CAAAA,CAAMD,EACZ,OAAO,CACL,MAAA,CAAQC,CAAAA,CAAI,MAAA,EAAU,GACtB,aAAA,CAAeA,CAAAA,CAAI,aAAA,EAAiB,UAAA,CACpC,IAAA,CAAMA,CAAAA,CAAI,MAAQ,WAAA,CAClB,KAAA,CAAOA,EAAI,KAAA,CACX,QAAA,CAAUA,EAAI,QAChB,CACF,CAEA,OAAO,CACL,MAAA,CAAQD,EACR,aAAA,CAAe,UAAA,CACf,IAAA,CAAM,WACR,CACF,CAEO,SAASE,CAAAA,CAAqBC,CAAAA,CAAmBC,2BAAAA,EAAiB,CAAmB,CAC1F,OAAO,CACL,MAAM,GAAA,CACJC,EACAL,CAAAA,CACqD,CACrD,GAAI,CAACK,CAAAA,EAAgBA,CAAAA,CAAa,QAAA,CAAS,GAAG,CAAA,CAC5C,OAAO,CACL,IAAA,CAAM,IAAA,CACN,KAAA,CAAO,CACL,MAAA,CAAQ,IACR,OAAA,CACE,kFACJ,CAAA,CACA,MAAA,CAAQ,GACV,CAAA,CAGF,IAAMC,CAAAA,CAAoBP,CAAAA,CAAoBC,CAAM,CAAA,CAS9CO,CAAAA,CAAW,MAAMJ,CAAAA,CAAK,OAAA,CAazB,CACD,GAAA,CAAK,CAAA,iBAAA,EAAoBE,CAAY,GACrC,MAAA,CAAQ,MAAA,CACR,OAAA,CAAS,CAAE,cAAA,CAAgB,kBAAmB,EAC9C,IAAA,CAAMC,CACR,CAAC,CAAA,CAED,GAAIC,CAAAA,CAAS,MAAM,IAAA,CAAM,CACvB,IAAMC,CAAAA,CAAYD,CAAAA,CAAS,KAAK,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,UAC5B,OAAA,CAASA,CAAAA,CAAU,SAAY,EAAC,CAChC,MAAOA,CAAAA,CAAU,KAAA,EAAS,IAAA,CAC1B,YAAA,CAAcA,CAAAA,CAAU,YAAA,EAAgB,EACxC,YAAA,CAAcA,CAAAA,CAAU,YAAA,EAAgB,CAAA,CACxC,WAAA,CAAaA,CAAAA,CAAU,aAAe,CAAA,CACtC,UAAA,CAAYA,CAAAA,CAAU,UAAA,EAAc,CAAA,CACpC,WAAA,CAAaA,EAAU,WAAA,EAAe,CACxC,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,OAAQA,CAAAA,CAAS,MACnB,CACF,CACF,CACF","file":"index.cjs","sourcesContent":["import { type ClientResult, createHttpClient, type HttpClient } from \"@amaster.ai/http-client\";\n\n// extractAppIdFromUrl removed — app_id now injected by Traefik middleware (X-App-ID header)\n// via scheduler's dynamic route creation in etcd\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};\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};\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\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\" in inputs ||\n \"response_mode\" in inputs ||\n \"user\" in inputs ||\n \"files\" in inputs ||\n \"trace_id\" in inputs)\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 };\n }\n\n return {\n inputs: inputs as Record<string, WorkflowInputValue>,\n response_mode: \"blocking\",\n user: \"anonymous\",\n };\n}\n\nexport function createWorkflowClient(http: HttpClient = createHttpClient()): WorkflowClient {\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 // app_id is now injected by Traefik middleware via X-App-ID header,\n // no longer extracted from URL (which incorrectly included env suffix).\n // const appId = extractAppIdFromUrl();\n // if (appId && normalizedRequest.inputs) {\n // normalizedRequest.inputs.app_id = appId;\n // }\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 };\n task_id: string;\n workflow_run_id: string;\n }>({\n url: `/api/runworkflow/${workflowName}`,\n method: \"post\",\n headers: { \"Content-Type\": \"application/json\" },\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 },\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"]}
@@ -0,0 +1,35 @@
1
+ import { ClientResult, HttpClient } from '@amaster.ai/http-client';
2
+
3
+ type WorkflowResponseMode = "blocking" | "streaming";
4
+ type WorkflowInputValue = string | number | boolean | null | undefined | Record<string, unknown> | unknown[];
5
+ type WorkflowFile = {
6
+ name?: string;
7
+ type?: string;
8
+ url?: string;
9
+ [key: string]: unknown;
10
+ };
11
+ type WorkflowRunRequest = {
12
+ inputs?: Record<string, WorkflowInputValue>;
13
+ response_mode?: WorkflowResponseMode;
14
+ user?: string;
15
+ files?: WorkflowFile[];
16
+ trace_id?: string;
17
+ };
18
+ type WorkflowRunResponse<TOutput = Record<string, unknown>> = {
19
+ task_id: string;
20
+ workflow_run_id: string;
21
+ status: string;
22
+ outputs: TOutput;
23
+ error: string | null;
24
+ elapsed_time: number;
25
+ total_tokens: number;
26
+ total_steps: number;
27
+ created_at: number;
28
+ finished_at: number;
29
+ };
30
+ type WorkflowClient = {
31
+ run<TOutput = Record<string, unknown>>(workflowName: string, inputs?: Record<string, WorkflowInputValue> | WorkflowRunRequest): Promise<ClientResult<WorkflowRunResponse<TOutput>>>;
32
+ };
33
+ declare function createWorkflowClient(http?: HttpClient): WorkflowClient;
34
+
35
+ export { type WorkflowClient, type WorkflowFile, type WorkflowInputValue, type WorkflowResponseMode, type WorkflowRunRequest, type WorkflowRunResponse, createWorkflowClient };
@@ -0,0 +1,35 @@
1
+ import { ClientResult, HttpClient } from '@amaster.ai/http-client';
2
+
3
+ type WorkflowResponseMode = "blocking" | "streaming";
4
+ type WorkflowInputValue = string | number | boolean | null | undefined | Record<string, unknown> | unknown[];
5
+ type WorkflowFile = {
6
+ name?: string;
7
+ type?: string;
8
+ url?: string;
9
+ [key: string]: unknown;
10
+ };
11
+ type WorkflowRunRequest = {
12
+ inputs?: Record<string, WorkflowInputValue>;
13
+ response_mode?: WorkflowResponseMode;
14
+ user?: string;
15
+ files?: WorkflowFile[];
16
+ trace_id?: string;
17
+ };
18
+ type WorkflowRunResponse<TOutput = Record<string, unknown>> = {
19
+ task_id: string;
20
+ workflow_run_id: string;
21
+ status: string;
22
+ outputs: TOutput;
23
+ error: string | null;
24
+ elapsed_time: number;
25
+ total_tokens: number;
26
+ total_steps: number;
27
+ created_at: number;
28
+ finished_at: number;
29
+ };
30
+ type WorkflowClient = {
31
+ run<TOutput = Record<string, unknown>>(workflowName: string, inputs?: Record<string, WorkflowInputValue> | WorkflowRunRequest): Promise<ClientResult<WorkflowRunResponse<TOutput>>>;
32
+ };
33
+ declare function createWorkflowClient(http?: HttpClient): WorkflowClient;
34
+
35
+ export { type WorkflowClient, type WorkflowFile, type WorkflowInputValue, type WorkflowResponseMode, type WorkflowRunRequest, type WorkflowRunResponse, createWorkflowClient };
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import {createHttpClient}from'@amaster.ai/http-client';function l(e){if(!e)return {inputs:{},response_mode:"blocking",user:"anonymous"};if(typeof e=="object"&&("inputs"in e||"response_mode"in e||"user"in e||"files"in e||"trace_id"in e)){let t=e;return {inputs:t.inputs||{},response_mode:t.response_mode||"blocking",user:t.user||"anonymous",files:t.files,trace_id:t.trace_id}}return {inputs:e,response_mode:"blocking",user:"anonymous"}}function i(e=createHttpClient()){return {async run(t,n){if(!t||t.includes("/"))return {data:null,error:{status:400,message:"Invalid workflowName: use workflow YAML filename without extension (no subpaths)"},status:400};let s=l(n),o=await e.request({url:`/api/runworkflow/${t}`,method:"post",headers:{"Content-Type":"application/json"},data:s});if(o.data?.data){let r=o.data.data;return {...o,data:{task_id:o.data.task_id||"",workflow_run_id:o.data.workflow_run_id||"",status:r.status||"unknown",outputs:r.outputs||{},error:r.error||null,elapsed_time:r.elapsed_time||0,total_tokens:r.total_tokens||0,total_steps:r.total_steps||0,created_at:r.created_at||0,finished_at:r.finished_at||0}}}return {data:null,error:o.error||{status:o.status,message:"Invalid workflow response structure"},status:o.status}}}}export{i as createWorkflowClient};//# sourceMappingURL=index.js.map
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/workflow-client.ts"],"names":["normalizeRunRequest","inputs","req","createWorkflowClient","http","createHttpClient","workflowName","normalizedRequest","response","innerData"],"mappings":"uDAmDA,SAASA,EACPC,CAAAA,CACoB,CACpB,GAAI,CAACA,CAAAA,CACH,OAAO,CAAE,MAAA,CAAQ,GAAI,aAAA,CAAe,UAAA,CAAY,KAAM,WAAY,CAAA,CAGpE,GACE,OAAOA,CAAAA,EAAW,QAAA,GACjB,WAAYA,CAAAA,EACX,eAAA,GAAmBA,GACnB,MAAA,GAAUA,CAAAA,EACV,UAAWA,CAAAA,EACX,UAAA,GAAcA,CAAAA,CAAAA,CAChB,CACA,IAAMC,CAAAA,CAAMD,EACZ,OAAO,CACL,MAAA,CAAQC,CAAAA,CAAI,MAAA,EAAU,GACtB,aAAA,CAAeA,CAAAA,CAAI,aAAA,EAAiB,UAAA,CACpC,IAAA,CAAMA,CAAAA,CAAI,MAAQ,WAAA,CAClB,KAAA,CAAOA,EAAI,KAAA,CACX,QAAA,CAAUA,EAAI,QAChB,CACF,CAEA,OAAO,CACL,MAAA,CAAQD,EACR,aAAA,CAAe,UAAA,CACf,IAAA,CAAM,WACR,CACF,CAEO,SAASE,CAAAA,CAAqBC,CAAAA,CAAmBC,gBAAAA,EAAiB,CAAmB,CAC1F,OAAO,CACL,MAAM,GAAA,CACJC,EACAL,CAAAA,CACqD,CACrD,GAAI,CAACK,CAAAA,EAAgBA,CAAAA,CAAa,QAAA,CAAS,GAAG,CAAA,CAC5C,OAAO,CACL,IAAA,CAAM,IAAA,CACN,KAAA,CAAO,CACL,MAAA,CAAQ,IACR,OAAA,CACE,kFACJ,CAAA,CACA,MAAA,CAAQ,GACV,CAAA,CAGF,IAAMC,CAAAA,CAAoBP,CAAAA,CAAoBC,CAAM,CAAA,CAS9CO,CAAAA,CAAW,MAAMJ,CAAAA,CAAK,OAAA,CAazB,CACD,GAAA,CAAK,CAAA,iBAAA,EAAoBE,CAAY,GACrC,MAAA,CAAQ,MAAA,CACR,OAAA,CAAS,CAAE,cAAA,CAAgB,kBAAmB,EAC9C,IAAA,CAAMC,CACR,CAAC,CAAA,CAED,GAAIC,CAAAA,CAAS,MAAM,IAAA,CAAM,CACvB,IAAMC,CAAAA,CAAYD,CAAAA,CAAS,KAAK,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,UAC5B,OAAA,CAASA,CAAAA,CAAU,SAAY,EAAC,CAChC,MAAOA,CAAAA,CAAU,KAAA,EAAS,IAAA,CAC1B,YAAA,CAAcA,CAAAA,CAAU,YAAA,EAAgB,EACxC,YAAA,CAAcA,CAAAA,CAAU,YAAA,EAAgB,CAAA,CACxC,WAAA,CAAaA,CAAAA,CAAU,aAAe,CAAA,CACtC,UAAA,CAAYA,CAAAA,CAAU,UAAA,EAAc,CAAA,CACpC,WAAA,CAAaA,EAAU,WAAA,EAAe,CACxC,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,OAAQA,CAAAA,CAAS,MACnB,CACF,CACF,CACF","file":"index.js","sourcesContent":["import { type ClientResult, createHttpClient, type HttpClient } from \"@amaster.ai/http-client\";\n\n// extractAppIdFromUrl removed — app_id now injected by Traefik middleware (X-App-ID header)\n// via scheduler's dynamic route creation in etcd\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};\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};\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\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\" in inputs ||\n \"response_mode\" in inputs ||\n \"user\" in inputs ||\n \"files\" in inputs ||\n \"trace_id\" in inputs)\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 };\n }\n\n return {\n inputs: inputs as Record<string, WorkflowInputValue>,\n response_mode: \"blocking\",\n user: \"anonymous\",\n };\n}\n\nexport function createWorkflowClient(http: HttpClient = createHttpClient()): WorkflowClient {\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 // app_id is now injected by Traefik middleware via X-App-ID header,\n // no longer extracted from URL (which incorrectly included env suffix).\n // const appId = extractAppIdFromUrl();\n // if (appId && normalizedRequest.inputs) {\n // normalizedRequest.inputs.app_id = appId;\n // }\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 };\n task_id: string;\n workflow_run_id: string;\n }>({\n url: `/api/runworkflow/${workflowName}`,\n method: \"post\",\n headers: { \"Content-Type\": \"application/json\" },\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 },\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 ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@amaster.ai/workflow-client",
3
+ "version": "1.0.0-alpha.2",
4
+ "description": "Workflow execution client",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs",
13
+ "types": "./dist/index.d.ts"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "README.md"
19
+ ],
20
+ "keywords": [
21
+ "workflow",
22
+ "automation",
23
+ "api",
24
+ "typescript"
25
+ ],
26
+ "author": "Amaster Team",
27
+ "license": "MIT",
28
+ "publishConfig": {
29
+ "access": "public",
30
+ "registry": "https://registry.npmjs.org/"
31
+ },
32
+ "dependencies": {
33
+ "@amaster.ai/http-client": "1.0.0-alpha.2"
34
+ },
35
+ "peerDependencies": {
36
+ "axios": "^1.11.0"
37
+ },
38
+ "devDependencies": {
39
+ "axios": "^1.11.0",
40
+ "tsup": "^8.3.5",
41
+ "typescript": "~5.7.2"
42
+ },
43
+ "scripts": {
44
+ "build": "tsup",
45
+ "dev": "tsup --watch",
46
+ "clean": "rm -rf dist *.tsbuildinfo",
47
+ "type-check": "tsc --noEmit"
48
+ }
49
+ }