simple-agents-wasm 0.2.35 → 0.3.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/index.d.ts +24 -0
- package/index.js +54 -0
- package/package.json +1 -1
- package/pkg/simple_agents_wasm.d.ts +2 -2
- package/pkg/simple_agents_wasm.js +7 -7
- package/pkg/simple_agents_wasm_bg.wasm +0 -0
- package/pkg/simple_agents_wasm_bg.wasm.d.ts +2 -2
- package/rust/Cargo.toml +1 -1
package/index.d.ts
CHANGED
|
@@ -103,6 +103,7 @@ export interface ClientConfig {
|
|
|
103
103
|
export interface WorkflowRunOptions {
|
|
104
104
|
telemetry?: Record<string, unknown>;
|
|
105
105
|
trace?: Record<string, unknown>;
|
|
106
|
+
model?: string;
|
|
106
107
|
onEvent?: (event: Record<string, unknown>) => void;
|
|
107
108
|
functions?: Record<
|
|
108
109
|
string,
|
|
@@ -126,6 +127,23 @@ export interface WorkflowRunResult {
|
|
|
126
127
|
events: WorkflowRunEvent[];
|
|
127
128
|
}
|
|
128
129
|
|
|
130
|
+
export interface WorkflowExecutionFlags {
|
|
131
|
+
model?: string;
|
|
132
|
+
healing?: boolean;
|
|
133
|
+
workflow_streaming?: boolean;
|
|
134
|
+
node_llm_streaming?: boolean;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface WorkflowExecutionRequest {
|
|
138
|
+
workflow_yaml: string;
|
|
139
|
+
messages: MessageInput[];
|
|
140
|
+
context?: Record<string, unknown>;
|
|
141
|
+
media?: Record<string, unknown>;
|
|
142
|
+
input?: Record<string, unknown>;
|
|
143
|
+
execution?: WorkflowExecutionFlags;
|
|
144
|
+
workflow_options?: WorkflowRunOptions;
|
|
145
|
+
}
|
|
146
|
+
|
|
129
147
|
export declare class Client {
|
|
130
148
|
constructor(provider: string, config: ClientConfig);
|
|
131
149
|
complete(
|
|
@@ -154,6 +172,12 @@ export declare class Client {
|
|
|
154
172
|
workflowPath: string,
|
|
155
173
|
workflowInput: Record<string, unknown>
|
|
156
174
|
): Promise<never>;
|
|
175
|
+
run(request: WorkflowExecutionRequest): Promise<WorkflowRunResult>;
|
|
176
|
+
runAsync(request: WorkflowExecutionRequest): Promise<WorkflowRunResult>;
|
|
177
|
+
streamWorkflow(
|
|
178
|
+
request: WorkflowExecutionRequest,
|
|
179
|
+
onEvent?: (event: Record<string, unknown>) => void
|
|
180
|
+
): Promise<WorkflowRunResult>;
|
|
157
181
|
}
|
|
158
182
|
|
|
159
183
|
export declare function hasRustBackend(): Promise<boolean>;
|
package/index.js
CHANGED
|
@@ -30,6 +30,43 @@ function toMessages(promptOrMessages) {
|
|
|
30
30
|
return promptOrMessages;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
function buildWorkflowInputFromExecutionRequest(request) {
|
|
34
|
+
if (!request || typeof request !== "object") {
|
|
35
|
+
throw configError("workflow request must be an object");
|
|
36
|
+
}
|
|
37
|
+
if (typeof request.workflow_yaml !== "string" || request.workflow_yaml.trim().length === 0) {
|
|
38
|
+
throw configError("workflow_yaml must be a non-empty string");
|
|
39
|
+
}
|
|
40
|
+
if (!Array.isArray(request.messages) || request.messages.length === 0) {
|
|
41
|
+
throw configError("messages must be a non-empty array");
|
|
42
|
+
}
|
|
43
|
+
const input = request.input && typeof request.input === "object" ? { ...request.input } : {};
|
|
44
|
+
input.messages = request.messages;
|
|
45
|
+
if (request.context && typeof request.context === "object") {
|
|
46
|
+
input.context = request.context;
|
|
47
|
+
}
|
|
48
|
+
if (request.media && typeof request.media === "object") {
|
|
49
|
+
input.media = request.media;
|
|
50
|
+
}
|
|
51
|
+
return input;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function buildWorkflowOptionsFromExecutionRequest(request, onEvent) {
|
|
55
|
+
const execution = request.execution && typeof request.execution === "object"
|
|
56
|
+
? request.execution
|
|
57
|
+
: {};
|
|
58
|
+
const options = request.workflow_options && typeof request.workflow_options === "object"
|
|
59
|
+
? { ...request.workflow_options }
|
|
60
|
+
: {};
|
|
61
|
+
if (typeof execution.model === "string" && execution.model.trim().length > 0) {
|
|
62
|
+
options.model = execution.model;
|
|
63
|
+
}
|
|
64
|
+
if (typeof onEvent === "function") {
|
|
65
|
+
options.onEvent = onEvent;
|
|
66
|
+
}
|
|
67
|
+
return options;
|
|
68
|
+
}
|
|
69
|
+
|
|
33
70
|
function toUsage(usage) {
|
|
34
71
|
if (!usage || typeof usage !== "object") {
|
|
35
72
|
return {
|
|
@@ -1272,6 +1309,23 @@ export class Client {
|
|
|
1272
1309
|
const result = await this.fallbackClient.runWorkflowYaml(workflowPath, workflowInput);
|
|
1273
1310
|
return assertWorkflowResultShape(normalizeWorkflowResult(result));
|
|
1274
1311
|
}
|
|
1312
|
+
|
|
1313
|
+
async run(request) {
|
|
1314
|
+
const workflowInput = buildWorkflowInputFromExecutionRequest(request);
|
|
1315
|
+
const workflowOptions = buildWorkflowOptionsFromExecutionRequest(request, undefined);
|
|
1316
|
+
return this.runWorkflowYamlString(request.workflow_yaml, workflowInput, workflowOptions);
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
async runAsync(request) {
|
|
1320
|
+
return this.run(request);
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
// Workflow-streaming surface (completion streaming already uses `stream`).
|
|
1324
|
+
async streamWorkflow(request, onEvent) {
|
|
1325
|
+
const workflowInput = buildWorkflowInputFromExecutionRequest(request);
|
|
1326
|
+
const workflowOptions = buildWorkflowOptionsFromExecutionRequest(request, onEvent);
|
|
1327
|
+
return this.runWorkflowYamlString(request.workflow_yaml, workflowInput, workflowOptions);
|
|
1328
|
+
}
|
|
1275
1329
|
}
|
|
1276
1330
|
|
|
1277
1331
|
export async function hasRustBackend() {
|
package/package.json
CHANGED
|
@@ -27,8 +27,8 @@ export interface InitOutput {
|
|
|
27
27
|
readonly wasmclient_runWorkflowYaml: (a: number, b: number, c: number, d: any) => [number, number, number];
|
|
28
28
|
readonly wasmclient_runWorkflowYamlString: (a: number, b: number, c: number, d: any, e: number) => any;
|
|
29
29
|
readonly wasmclient_streamEvents: (a: number, b: number, c: number, d: any, e: any, f: number) => any;
|
|
30
|
-
readonly
|
|
31
|
-
readonly
|
|
30
|
+
readonly wasm_bindgen__convert__closures_____invoke__h327a4c82efcf6931: (a: number, b: number, c: any) => [number, number];
|
|
31
|
+
readonly wasm_bindgen__convert__closures_____invoke__h67e61867e7d8792e: (a: number, b: number, c: any, d: any) => void;
|
|
32
32
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
33
33
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
34
34
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
@@ -314,7 +314,7 @@ function __wbg_get_imports() {
|
|
|
314
314
|
const a = state0.a;
|
|
315
315
|
state0.a = 0;
|
|
316
316
|
try {
|
|
317
|
-
return
|
|
317
|
+
return wasm_bindgen__convert__closures_____invoke__h67e61867e7d8792e(a, state0.b, arg0, arg1);
|
|
318
318
|
} finally {
|
|
319
319
|
state0.a = a;
|
|
320
320
|
}
|
|
@@ -394,8 +394,8 @@ function __wbg_get_imports() {
|
|
|
394
394
|
return ret;
|
|
395
395
|
},
|
|
396
396
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
397
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
398
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
397
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 147, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
398
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h327a4c82efcf6931);
|
|
399
399
|
return ret;
|
|
400
400
|
},
|
|
401
401
|
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
@@ -434,15 +434,15 @@ function __wbg_get_imports() {
|
|
|
434
434
|
};
|
|
435
435
|
}
|
|
436
436
|
|
|
437
|
-
function
|
|
438
|
-
const ret = wasm.
|
|
437
|
+
function wasm_bindgen__convert__closures_____invoke__h327a4c82efcf6931(arg0, arg1, arg2) {
|
|
438
|
+
const ret = wasm.wasm_bindgen__convert__closures_____invoke__h327a4c82efcf6931(arg0, arg1, arg2);
|
|
439
439
|
if (ret[1]) {
|
|
440
440
|
throw takeFromExternrefTable0(ret[0]);
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
443
|
|
|
444
|
-
function
|
|
445
|
-
wasm.
|
|
444
|
+
function wasm_bindgen__convert__closures_____invoke__h67e61867e7d8792e(arg0, arg1, arg2, arg3) {
|
|
445
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h67e61867e7d8792e(arg0, arg1, arg2, arg3);
|
|
446
446
|
}
|
|
447
447
|
|
|
448
448
|
const WasmClientFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
Binary file
|
|
@@ -9,8 +9,8 @@ export const wasmclient_new: (a: number, b: number, c: any) => [number, number,
|
|
|
9
9
|
export const wasmclient_runWorkflowYaml: (a: number, b: number, c: number, d: any) => [number, number, number];
|
|
10
10
|
export const wasmclient_runWorkflowYamlString: (a: number, b: number, c: number, d: any, e: number) => any;
|
|
11
11
|
export const wasmclient_streamEvents: (a: number, b: number, c: number, d: any, e: any, f: number) => any;
|
|
12
|
-
export const
|
|
13
|
-
export const
|
|
12
|
+
export const wasm_bindgen__convert__closures_____invoke__h327a4c82efcf6931: (a: number, b: number, c: any) => [number, number];
|
|
13
|
+
export const wasm_bindgen__convert__closures_____invoke__h67e61867e7d8792e: (a: number, b: number, c: any, d: any) => void;
|
|
14
14
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
15
15
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
16
16
|
export const __wbindgen_exn_store: (a: number) => void;
|