@memgrafter/flatagents 0.8.0 → 0.8.3

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.
@@ -0,0 +1,596 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$ref": "#/definitions/MachineWrapper",
4
+ "definitions": {
5
+ "MachineWrapper": {
6
+ "type": "object",
7
+ "properties": {
8
+ "spec": {
9
+ "type": "string",
10
+ "const": "flatmachine"
11
+ },
12
+ "spec_version": {
13
+ "type": "string"
14
+ },
15
+ "data": {
16
+ "$ref": "#/definitions/MachineData"
17
+ },
18
+ "metadata": {
19
+ "type": "object"
20
+ }
21
+ },
22
+ "required": [
23
+ "spec",
24
+ "spec_version",
25
+ "data"
26
+ ],
27
+ "additionalProperties": false
28
+ },
29
+ "MachineData": {
30
+ "type": "object",
31
+ "properties": {
32
+ "name": {
33
+ "type": "string"
34
+ },
35
+ "expression_engine": {
36
+ "type": "string",
37
+ "enum": [
38
+ "simple",
39
+ "cel"
40
+ ]
41
+ },
42
+ "context": {
43
+ "type": "object"
44
+ },
45
+ "agents": {
46
+ "type": "object",
47
+ "additionalProperties": {
48
+ "anyOf": [
49
+ {
50
+ "type": "string"
51
+ },
52
+ {
53
+ "$ref": "#/definitions/AgentWrapper"
54
+ }
55
+ ]
56
+ }
57
+ },
58
+ "machines": {
59
+ "type": "object",
60
+ "additionalProperties": {
61
+ "anyOf": [
62
+ {
63
+ "type": "string"
64
+ },
65
+ {
66
+ "$ref": "#/definitions/MachineWrapper"
67
+ }
68
+ ]
69
+ }
70
+ },
71
+ "states": {
72
+ "type": "object",
73
+ "additionalProperties": {
74
+ "$ref": "#/definitions/StateDefinition"
75
+ }
76
+ },
77
+ "settings": {
78
+ "$ref": "#/definitions/MachineSettings"
79
+ },
80
+ "persistence": {
81
+ "$ref": "#/definitions/PersistenceConfig"
82
+ },
83
+ "hooks": {
84
+ "$ref": "#/definitions/HooksConfig"
85
+ }
86
+ },
87
+ "required": [
88
+ "states"
89
+ ],
90
+ "additionalProperties": false
91
+ },
92
+ "AgentWrapper": {
93
+ "type": "object",
94
+ "properties": {
95
+ "spec": {
96
+ "type": "string",
97
+ "const": "flatagent"
98
+ },
99
+ "spec_version": {
100
+ "type": "string"
101
+ },
102
+ "data": {
103
+ "$ref": "#/definitions/AgentData"
104
+ },
105
+ "metadata": {
106
+ "type": "object"
107
+ }
108
+ },
109
+ "required": [
110
+ "spec",
111
+ "spec_version",
112
+ "data"
113
+ ],
114
+ "additionalProperties": false
115
+ },
116
+ "AgentData": {
117
+ "type": "object",
118
+ "properties": {
119
+ "name": {
120
+ "type": "string"
121
+ },
122
+ "model": {
123
+ "anyOf": [
124
+ {
125
+ "type": "string"
126
+ },
127
+ {
128
+ "$ref": "#/definitions/ModelConfig"
129
+ },
130
+ {
131
+ "$ref": "#/definitions/ProfiledModelConfig"
132
+ }
133
+ ]
134
+ },
135
+ "system": {
136
+ "type": "string"
137
+ },
138
+ "user": {
139
+ "type": "string"
140
+ },
141
+ "instruction_suffix": {
142
+ "type": "string"
143
+ },
144
+ "output": {
145
+ "$ref": "#/definitions/OutputSchema"
146
+ },
147
+ "mcp": {
148
+ "$ref": "#/definitions/MCPConfig"
149
+ }
150
+ },
151
+ "required": [
152
+ "model",
153
+ "system",
154
+ "user"
155
+ ],
156
+ "additionalProperties": false
157
+ },
158
+ "ModelConfig": {
159
+ "type": "object",
160
+ "properties": {
161
+ "name": {
162
+ "type": "string"
163
+ },
164
+ "provider": {
165
+ "type": "string"
166
+ },
167
+ "temperature": {
168
+ "type": "number"
169
+ },
170
+ "max_tokens": {
171
+ "type": "number"
172
+ },
173
+ "top_p": {
174
+ "type": "number"
175
+ },
176
+ "top_k": {
177
+ "type": "number"
178
+ },
179
+ "frequency_penalty": {
180
+ "type": "number"
181
+ },
182
+ "presence_penalty": {
183
+ "type": "number"
184
+ },
185
+ "seed": {
186
+ "type": "number"
187
+ },
188
+ "base_url": {
189
+ "type": "string"
190
+ }
191
+ },
192
+ "required": [
193
+ "name"
194
+ ],
195
+ "additionalProperties": false
196
+ },
197
+ "ProfiledModelConfig": {
198
+ "type": "object",
199
+ "properties": {
200
+ "name": {
201
+ "type": "string"
202
+ },
203
+ "provider": {
204
+ "type": "string"
205
+ },
206
+ "temperature": {
207
+ "type": "number"
208
+ },
209
+ "max_tokens": {
210
+ "type": "number"
211
+ },
212
+ "top_p": {
213
+ "type": "number"
214
+ },
215
+ "top_k": {
216
+ "type": "number"
217
+ },
218
+ "frequency_penalty": {
219
+ "type": "number"
220
+ },
221
+ "presence_penalty": {
222
+ "type": "number"
223
+ },
224
+ "seed": {
225
+ "type": "number"
226
+ },
227
+ "base_url": {
228
+ "type": "string"
229
+ },
230
+ "profile": {
231
+ "type": "string"
232
+ }
233
+ },
234
+ "required": [
235
+ "profile"
236
+ ],
237
+ "additionalProperties": false
238
+ },
239
+ "OutputSchema": {
240
+ "type": "object",
241
+ "additionalProperties": {
242
+ "$ref": "#/definitions/OutputFieldDef"
243
+ }
244
+ },
245
+ "OutputFieldDef": {
246
+ "type": "object",
247
+ "properties": {
248
+ "type": {
249
+ "type": "string",
250
+ "enum": [
251
+ "str",
252
+ "int",
253
+ "float",
254
+ "bool",
255
+ "json",
256
+ "list",
257
+ "object"
258
+ ]
259
+ },
260
+ "description": {
261
+ "type": "string"
262
+ },
263
+ "enum": {
264
+ "type": "array",
265
+ "items": {
266
+ "type": "string"
267
+ }
268
+ },
269
+ "required": {
270
+ "type": "boolean"
271
+ },
272
+ "items": {
273
+ "$ref": "#/definitions/OutputFieldDef"
274
+ },
275
+ "properties": {
276
+ "$ref": "#/definitions/OutputSchema"
277
+ }
278
+ },
279
+ "required": [
280
+ "type"
281
+ ],
282
+ "additionalProperties": false
283
+ },
284
+ "MCPConfig": {
285
+ "type": "object",
286
+ "properties": {
287
+ "servers": {
288
+ "type": "object",
289
+ "additionalProperties": {
290
+ "$ref": "#/definitions/MCPServerDef"
291
+ }
292
+ },
293
+ "tool_filter": {
294
+ "$ref": "#/definitions/ToolFilter"
295
+ },
296
+ "tool_prompt": {
297
+ "type": "string"
298
+ }
299
+ },
300
+ "required": [
301
+ "servers",
302
+ "tool_prompt"
303
+ ],
304
+ "additionalProperties": false
305
+ },
306
+ "MCPServerDef": {
307
+ "type": "object",
308
+ "properties": {
309
+ "command": {
310
+ "type": "string"
311
+ },
312
+ "args": {
313
+ "type": "array",
314
+ "items": {
315
+ "type": "string"
316
+ }
317
+ },
318
+ "env": {
319
+ "type": "object",
320
+ "additionalProperties": {
321
+ "type": "string"
322
+ }
323
+ },
324
+ "server_url": {
325
+ "type": "string"
326
+ },
327
+ "headers": {
328
+ "type": "object",
329
+ "additionalProperties": {
330
+ "type": "string"
331
+ }
332
+ },
333
+ "timeout": {
334
+ "type": "number"
335
+ }
336
+ },
337
+ "additionalProperties": false
338
+ },
339
+ "ToolFilter": {
340
+ "type": "object",
341
+ "properties": {
342
+ "allow": {
343
+ "type": "array",
344
+ "items": {
345
+ "type": "string"
346
+ }
347
+ },
348
+ "deny": {
349
+ "type": "array",
350
+ "items": {
351
+ "type": "string"
352
+ }
353
+ }
354
+ },
355
+ "additionalProperties": false
356
+ },
357
+ "StateDefinition": {
358
+ "type": "object",
359
+ "properties": {
360
+ "type": {
361
+ "type": "string",
362
+ "enum": [
363
+ "initial",
364
+ "final"
365
+ ]
366
+ },
367
+ "agent": {
368
+ "type": "string"
369
+ },
370
+ "machine": {
371
+ "anyOf": [
372
+ {
373
+ "type": "string"
374
+ },
375
+ {
376
+ "type": "array",
377
+ "items": {
378
+ "type": "string"
379
+ }
380
+ },
381
+ {
382
+ "type": "array",
383
+ "items": {
384
+ "$ref": "#/definitions/MachineInput"
385
+ }
386
+ }
387
+ ]
388
+ },
389
+ "action": {
390
+ "type": "string"
391
+ },
392
+ "execution": {
393
+ "$ref": "#/definitions/ExecutionConfig"
394
+ },
395
+ "on_error": {
396
+ "anyOf": [
397
+ {
398
+ "type": "string"
399
+ },
400
+ {
401
+ "type": "object",
402
+ "additionalProperties": {
403
+ "type": "string"
404
+ }
405
+ }
406
+ ]
407
+ },
408
+ "input": {
409
+ "type": "object"
410
+ },
411
+ "output_to_context": {
412
+ "type": "object"
413
+ },
414
+ "output": {
415
+ "type": "object"
416
+ },
417
+ "transitions": {
418
+ "type": "array",
419
+ "items": {
420
+ "$ref": "#/definitions/Transition"
421
+ }
422
+ },
423
+ "tool_loop": {
424
+ "type": "boolean"
425
+ },
426
+ "sampling": {
427
+ "type": "string",
428
+ "enum": [
429
+ "single",
430
+ "multi"
431
+ ]
432
+ },
433
+ "foreach": {
434
+ "type": "string"
435
+ },
436
+ "as": {
437
+ "type": "string"
438
+ },
439
+ "key": {
440
+ "type": "string"
441
+ },
442
+ "mode": {
443
+ "type": "string",
444
+ "enum": [
445
+ "settled",
446
+ "any"
447
+ ]
448
+ },
449
+ "timeout": {
450
+ "type": "number"
451
+ },
452
+ "launch": {
453
+ "anyOf": [
454
+ {
455
+ "type": "string"
456
+ },
457
+ {
458
+ "type": "array",
459
+ "items": {
460
+ "type": "string"
461
+ }
462
+ }
463
+ ]
464
+ },
465
+ "launch_input": {
466
+ "type": "object"
467
+ }
468
+ },
469
+ "additionalProperties": false
470
+ },
471
+ "MachineInput": {
472
+ "type": "object",
473
+ "properties": {
474
+ "name": {
475
+ "type": "string"
476
+ },
477
+ "input": {
478
+ "type": "object"
479
+ }
480
+ },
481
+ "required": [
482
+ "name"
483
+ ],
484
+ "additionalProperties": false
485
+ },
486
+ "ExecutionConfig": {
487
+ "type": "object",
488
+ "properties": {
489
+ "type": {
490
+ "type": "string",
491
+ "enum": [
492
+ "default",
493
+ "retry",
494
+ "parallel",
495
+ "mdap_voting"
496
+ ]
497
+ },
498
+ "backoffs": {
499
+ "type": "array",
500
+ "items": {
501
+ "type": "number"
502
+ }
503
+ },
504
+ "jitter": {
505
+ "type": "number"
506
+ },
507
+ "n_samples": {
508
+ "type": "number"
509
+ },
510
+ "k_margin": {
511
+ "type": "number"
512
+ },
513
+ "max_candidates": {
514
+ "type": "number"
515
+ }
516
+ },
517
+ "required": [
518
+ "type"
519
+ ],
520
+ "additionalProperties": false
521
+ },
522
+ "Transition": {
523
+ "type": "object",
524
+ "properties": {
525
+ "condition": {
526
+ "type": "string"
527
+ },
528
+ "to": {
529
+ "type": "string"
530
+ }
531
+ },
532
+ "required": [
533
+ "to"
534
+ ],
535
+ "additionalProperties": false
536
+ },
537
+ "MachineSettings": {
538
+ "type": "object",
539
+ "properties": {
540
+ "max_steps": {
541
+ "type": "number"
542
+ },
543
+ "parallel_fallback": {
544
+ "type": "string",
545
+ "enum": [
546
+ "sequential",
547
+ "error"
548
+ ]
549
+ }
550
+ }
551
+ },
552
+ "PersistenceConfig": {
553
+ "type": "object",
554
+ "properties": {
555
+ "enabled": {
556
+ "type": "boolean"
557
+ },
558
+ "backend": {
559
+ "type": "string"
560
+ },
561
+ "checkpoint_on": {
562
+ "type": "array",
563
+ "items": {
564
+ "type": "string"
565
+ }
566
+ }
567
+ },
568
+ "required": [
569
+ "enabled",
570
+ "backend"
571
+ ]
572
+ },
573
+ "HooksConfig": {
574
+ "type": "object",
575
+ "properties": {
576
+ "file": {
577
+ "type": "string"
578
+ },
579
+ "module": {
580
+ "type": "string"
581
+ },
582
+ "class": {
583
+ "type": "string"
584
+ },
585
+ "args": {
586
+ "type": "object"
587
+ }
588
+ },
589
+ "required": [
590
+ "class"
591
+ ],
592
+ "additionalProperties": false,
593
+ "description": "Configuration for loading hooks from file or module.\n\nFile-based (preferred for self-contained skills): hooks: file: \"./hooks.py\" class: \"MyHooks\" args: working_dir: \".\"\n\nModule-based (for installed packages): hooks: module: \"mypackage.hooks\" class: \"MyHooks\" args: api_key: \"{{ input.api_key }}\"\n\nFields: file - Path to Python file containing hooks class (relative to machine.yml) module - Python module path to import class - Class name to instantiate (required) args - Arguments to pass to hooks constructor"
594
+ }
595
+ }
596
+ }
@@ -0,0 +1,100 @@
1
+ export const SPEC_VERSION = "0.8.3";
2
+ export interface MachineWrapper {
3
+ spec: "flatmachine";
4
+ spec_version: string;
5
+ data: MachineData;
6
+ metadata?: Record<string, any>;
7
+ }
8
+ export interface MachineData {
9
+ name?: string;
10
+ expression_engine?: "simple" | "cel";
11
+ context?: Record<string, any>;
12
+ agents?: Record<string, string | AgentWrapper>;
13
+ machines?: Record<string, string | MachineWrapper>;
14
+ states: Record<string, StateDefinition>;
15
+ settings?: MachineSettings;
16
+ persistence?: PersistenceConfig;
17
+ hooks?: HooksConfig;
18
+ }
19
+ export interface HooksConfig {
20
+ file?: string;
21
+ module?: string;
22
+ class: string;
23
+ args?: Record<string, any>;
24
+ }
25
+ export interface MachineSettings {
26
+ max_steps?: number;
27
+ parallel_fallback?: "sequential" | "error";
28
+ [key: string]: any;
29
+ }
30
+ export interface StateDefinition {
31
+ type?: "initial" | "final";
32
+ agent?: string;
33
+ machine?: string | string[] | MachineInput[];
34
+ action?: string;
35
+ execution?: ExecutionConfig;
36
+ on_error?: string | Record<string, string>;
37
+ input?: Record<string, any>;
38
+ output_to_context?: Record<string, any>;
39
+ output?: Record<string, any>;
40
+ transitions?: Transition[];
41
+ tool_loop?: boolean;
42
+ sampling?: "single" | "multi";
43
+ foreach?: string;
44
+ as?: string;
45
+ key?: string;
46
+ mode?: "settled" | "any";
47
+ timeout?: number;
48
+ launch?: string | string[];
49
+ launch_input?: Record<string, any>;
50
+ }
51
+ export interface MachineInput {
52
+ name: string;
53
+ input?: Record<string, any>;
54
+ }
55
+ export interface ExecutionConfig {
56
+ type: "default" | "retry" | "parallel" | "mdap_voting";
57
+ backoffs?: number[];
58
+ jitter?: number;
59
+ n_samples?: number;
60
+ k_margin?: number;
61
+ max_candidates?: number;
62
+ }
63
+ export interface Transition {
64
+ condition?: string;
65
+ to: string;
66
+ }
67
+ import { AgentWrapper, OutputSchema, ModelConfig } from "./flatagent";
68
+ export { AgentWrapper, OutputSchema };
69
+ export type FlatmachineConfig = MachineWrapper;
70
+ export interface LaunchIntent {
71
+ execution_id: string;
72
+ machine: string;
73
+ input: Record<string, any>;
74
+ launched: boolean;
75
+ }
76
+ export interface MachineSnapshot {
77
+ execution_id: string;
78
+ machine_name: string;
79
+ spec_version: string;
80
+ current_state: string;
81
+ context: Record<string, any>;
82
+ step: number;
83
+ created_at: string;
84
+ event?: string;
85
+ output?: Record<string, any>;
86
+ total_api_calls?: number;
87
+ total_cost?: number;
88
+ parent_execution_id?: string;
89
+ pending_launches?: LaunchIntent[];
90
+ }
91
+ export interface PersistenceConfig {
92
+ enabled: boolean;
93
+ backend: "local" | "redis" | "memory" | string;
94
+ checkpoint_on?: string[];
95
+ [key: string]: any;
96
+ }
97
+ export interface MachineReference {
98
+ path?: string;
99
+ inline?: MachineWrapper;
100
+ }