@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,219 @@
1
+ /**
2
+ * FlatAgents Configuration Schema
3
+ * ===============================
4
+ *
5
+ * An agent is a single LLM call: model + prompts + output schema.
6
+ * Workflows handle composition, branching, and loops.
7
+ *
8
+ * STRUCTURE:
9
+ * ----------
10
+ * spec - Fixed string "flatagents"
11
+ * spec_version - Semver string
12
+ * data - The agent configuration
13
+ * metadata - Extensibility layer (runners ignore unrecognized keys)
14
+ *
15
+ * DERIVED SCHEMAS:
16
+ * ----------------
17
+ * This file (/flatagent.d.ts) is the SOURCE OF TRUTH for all FlatAgent schemas.
18
+ * Other schemas (JSON Schema, etc.) are DERIVED from this file using scripts.
19
+ * See: /scripts/generate-spec-assets.ts
20
+ *
21
+ * DATA FIELDS:
22
+ * ------------
23
+ * name - Agent identifier (inferred from filename if omitted)
24
+ * model - LLM configuration
25
+ * system - System prompt (Jinja2 template)
26
+ * user - User prompt template (Jinja2)
27
+ * instruction_suffix - Optional instruction appended after user prompt
28
+ * output - Output schema (what fields we want)
29
+ * mcp - Optional MCP (Model Context Protocol) configuration
30
+ *
31
+ * MCP FIELDS:
32
+ * -----------
33
+ * servers - Map of server name to MCPServerDef
34
+ * tool_filter - Optional allow/deny lists using "server:tool" format
35
+ * tool_prompt - Jinja2 template for tool prompt (uses {{ tools }} variable)
36
+ *
37
+ * MODEL FIELDS:
38
+ * -------------
39
+ * name - Model name (e.g., "gpt-4", "zai-glm-4.6")
40
+ * provider - Provider name (e.g., "openai", "anthropic", "cerebras")
41
+ * temperature - Sampling temperature (0.0 to 2.0)
42
+ * max_tokens - Maximum tokens to generate
43
+ * top_p - Nucleus sampling parameter
44
+ * top_k - Top-k sampling parameter
45
+ * frequency_penalty - Frequency penalty (-2.0 to 2.0)
46
+ * presence_penalty - Presence penalty (-2.0 to 2.0)
47
+ * seed - Random seed for reproducibility
48
+ * base_url - Custom API base URL (for local models/proxies)
49
+ *
50
+ * MODEL PROFILES:
51
+ * ---------------
52
+ * Agents can reference model profiles from profiles.yml:
53
+ * model: "fast-cheap" # String = profile lookup
54
+ * model: { profile: "fast-cheap" } # Profile with optional overrides
55
+ * model: { provider: x, name: y, ... } # Inline config (no profile)
56
+ *
57
+ * OUTPUT FIELD DEFINITION:
58
+ * ------------------------
59
+ * type - Field type: str, int, float, bool, json, list, object
60
+ * description - Description (used for structured output / tool calls)
61
+ * enum - Allowed values (for enum-like fields)
62
+ * required - Whether the field is required (default: true)
63
+ * items - For list type: the type of items
64
+ * properties - For object type: nested properties
65
+ *
66
+ * TEMPLATE SYNTAX:
67
+ * ----------------
68
+ * Prompts use Jinja2 templating. Available variables:
69
+ * - input.* - Values passed to the agent at runtime
70
+ *
71
+ * Example: "Question: {{ input.question }}"
72
+ *
73
+ * EXAMPLE CONFIGURATION:
74
+ * ----------------------
75
+ *
76
+ * spec: flatagents
77
+ * spec_version: "0.7.0"
78
+ *
79
+ * data:
80
+ * name: critic
81
+ *
82
+ * model:
83
+ * provider: cerebras
84
+ * name: zai-glm-4.6
85
+ * temperature: 0.5
86
+ *
87
+ * system: |
88
+ * Act as a ruthless critic. Analyze drafts for errors.
89
+ * Rate severity as: High, Medium, or Low.
90
+ *
91
+ * user: |
92
+ * Question: {{ input.question }}
93
+ * Draft: {{ input.draft }}
94
+ *
95
+ * output:
96
+ * critique:
97
+ * type: str
98
+ * description: "Specific errors found in the draft"
99
+ * severity:
100
+ * type: str
101
+ * description: "Error severity"
102
+ * enum: ["High", "Medium", "Low"]
103
+ *
104
+ * metadata:
105
+ * description: "Critiques draft answers"
106
+ * tags: ["reflection", "qa"]
107
+ *
108
+ * MCPCONFIG:
109
+ * ----------
110
+ * MCP (Model Context Protocol) configuration.
111
+ * Defines MCP servers and tool filtering rules.
112
+ * servers - MCP server definitions, keyed by server name
113
+ * tool_filter - Optional tool filtering rules
114
+ * tool_prompt - Jinja2 template for tool prompt injection.
115
+ * Available variables: tools (list of discovered tools)
116
+ * Example: "{% for tool in tools %}{{ tool.name }}: {{ tool.description }}{% endfor %}"
117
+ *
118
+ * MCPSERVERDEF:
119
+ * -------------
120
+ * MCP server definition.
121
+ * Supports stdio transport (command) or HTTP transport (server_url).
122
+ * Stdio transport:
123
+ * command - Command to start the MCP server (e.g., "npx", "python")
124
+ * args - Arguments for the command
125
+ * env - Environment variables for the server process
126
+ * HTTP transport:
127
+ * server_url - Base URL of the MCP server (e.g., "http://localhost:8000")
128
+ * headers - HTTP headers (e.g., for authentication)
129
+ * timeout - Request timeout in seconds
130
+ *
131
+ * TOOLFILTER:
132
+ * -----------
133
+ * Tool filtering rules using "server:tool" format.
134
+ * Supports wildcards: "server:*" matches all tools from a server.
135
+ * allow - Tools to allow (if specified, only these are included)
136
+ * deny - Tools to deny (takes precedence over allow)
137
+ *
138
+ * AGENTDATA MODEL FIELD:
139
+ * ----------------------
140
+ * Model configuration accepts three forms:
141
+ * - String: Profile name lookup (e.g., "fast-cheap")
142
+ * - ModelConfig: Inline config with name, provider, etc.
143
+ * - ProfiledModelConfig: Profile reference with optional overrides
144
+ *
145
+ * PROFILEDMODELCONFIG:
146
+ * --------------------
147
+ * Model config that references a profile with optional overrides.
148
+ * Example: { profile: "fast-cheap", temperature: 0.8 }
149
+ * The profile field specifies which profile name to use as base.
150
+ */
151
+
152
+ export const SPEC_VERSION = "0.8.3";
153
+
154
+ export interface AgentWrapper {
155
+ spec: "flatagent";
156
+ spec_version: string;
157
+ data: AgentData;
158
+ metadata?: Record<string, any>;
159
+ }
160
+
161
+ export interface AgentData {
162
+ name?: string;
163
+ model: string | ModelConfig | ProfiledModelConfig;
164
+ system: string;
165
+ user: string;
166
+ instruction_suffix?: string;
167
+ output?: OutputSchema;
168
+ mcp?: MCPConfig;
169
+ }
170
+
171
+ export interface MCPConfig {
172
+ servers: Record<string, MCPServerDef>;
173
+ tool_filter?: ToolFilter;
174
+ tool_prompt: string;
175
+ }
176
+
177
+ export interface MCPServerDef {
178
+ command?: string;
179
+ args?: string[];
180
+ env?: Record<string, string>;
181
+ server_url?: string;
182
+ headers?: Record<string, string>;
183
+ timeout?: number;
184
+ }
185
+
186
+ export interface ToolFilter {
187
+ allow?: string[];
188
+ deny?: string[];
189
+ }
190
+
191
+ export interface ModelConfig {
192
+ name: string;
193
+ provider?: string;
194
+ temperature?: number;
195
+ max_tokens?: number;
196
+ top_p?: number;
197
+ top_k?: number;
198
+ frequency_penalty?: number;
199
+ presence_penalty?: number;
200
+ seed?: number;
201
+ base_url?: string;
202
+ }
203
+
204
+ export interface ProfiledModelConfig extends Partial<ModelConfig> {
205
+ profile: string;
206
+ }
207
+
208
+ export type OutputSchema = Record<string, OutputFieldDef>;
209
+
210
+ export interface OutputFieldDef {
211
+ type: "str" | "int" | "float" | "bool" | "json" | "list" | "object";
212
+ description?: string;
213
+ enum?: string[];
214
+ required?: boolean;
215
+ items?: OutputFieldDef;
216
+ properties?: OutputSchema;
217
+ }
218
+
219
+ export type FlatagentsConfig = AgentWrapper;
@@ -0,0 +1,271 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$ref": "#/definitions/AgentWrapper",
4
+ "definitions": {
5
+ "AgentWrapper": {
6
+ "type": "object",
7
+ "properties": {
8
+ "spec": {
9
+ "type": "string",
10
+ "const": "flatagent"
11
+ },
12
+ "spec_version": {
13
+ "type": "string"
14
+ },
15
+ "data": {
16
+ "$ref": "#/definitions/AgentData"
17
+ },
18
+ "metadata": {
19
+ "type": "object"
20
+ }
21
+ },
22
+ "required": [
23
+ "spec",
24
+ "spec_version",
25
+ "data"
26
+ ],
27
+ "additionalProperties": false
28
+ },
29
+ "AgentData": {
30
+ "type": "object",
31
+ "properties": {
32
+ "name": {
33
+ "type": "string"
34
+ },
35
+ "model": {
36
+ "anyOf": [
37
+ {
38
+ "type": "string"
39
+ },
40
+ {
41
+ "$ref": "#/definitions/ModelConfig"
42
+ },
43
+ {
44
+ "$ref": "#/definitions/ProfiledModelConfig"
45
+ }
46
+ ]
47
+ },
48
+ "system": {
49
+ "type": "string"
50
+ },
51
+ "user": {
52
+ "type": "string"
53
+ },
54
+ "instruction_suffix": {
55
+ "type": "string"
56
+ },
57
+ "output": {
58
+ "$ref": "#/definitions/OutputSchema"
59
+ },
60
+ "mcp": {
61
+ "$ref": "#/definitions/MCPConfig"
62
+ }
63
+ },
64
+ "required": [
65
+ "model",
66
+ "system",
67
+ "user"
68
+ ],
69
+ "additionalProperties": false
70
+ },
71
+ "ModelConfig": {
72
+ "type": "object",
73
+ "properties": {
74
+ "name": {
75
+ "type": "string"
76
+ },
77
+ "provider": {
78
+ "type": "string"
79
+ },
80
+ "temperature": {
81
+ "type": "number"
82
+ },
83
+ "max_tokens": {
84
+ "type": "number"
85
+ },
86
+ "top_p": {
87
+ "type": "number"
88
+ },
89
+ "top_k": {
90
+ "type": "number"
91
+ },
92
+ "frequency_penalty": {
93
+ "type": "number"
94
+ },
95
+ "presence_penalty": {
96
+ "type": "number"
97
+ },
98
+ "seed": {
99
+ "type": "number"
100
+ },
101
+ "base_url": {
102
+ "type": "string"
103
+ }
104
+ },
105
+ "required": [
106
+ "name"
107
+ ],
108
+ "additionalProperties": false
109
+ },
110
+ "ProfiledModelConfig": {
111
+ "type": "object",
112
+ "properties": {
113
+ "name": {
114
+ "type": "string"
115
+ },
116
+ "provider": {
117
+ "type": "string"
118
+ },
119
+ "temperature": {
120
+ "type": "number"
121
+ },
122
+ "max_tokens": {
123
+ "type": "number"
124
+ },
125
+ "top_p": {
126
+ "type": "number"
127
+ },
128
+ "top_k": {
129
+ "type": "number"
130
+ },
131
+ "frequency_penalty": {
132
+ "type": "number"
133
+ },
134
+ "presence_penalty": {
135
+ "type": "number"
136
+ },
137
+ "seed": {
138
+ "type": "number"
139
+ },
140
+ "base_url": {
141
+ "type": "string"
142
+ },
143
+ "profile": {
144
+ "type": "string"
145
+ }
146
+ },
147
+ "required": [
148
+ "profile"
149
+ ],
150
+ "additionalProperties": false
151
+ },
152
+ "OutputSchema": {
153
+ "type": "object",
154
+ "additionalProperties": {
155
+ "$ref": "#/definitions/OutputFieldDef"
156
+ }
157
+ },
158
+ "OutputFieldDef": {
159
+ "type": "object",
160
+ "properties": {
161
+ "type": {
162
+ "type": "string",
163
+ "enum": [
164
+ "str",
165
+ "int",
166
+ "float",
167
+ "bool",
168
+ "json",
169
+ "list",
170
+ "object"
171
+ ]
172
+ },
173
+ "description": {
174
+ "type": "string"
175
+ },
176
+ "enum": {
177
+ "type": "array",
178
+ "items": {
179
+ "type": "string"
180
+ }
181
+ },
182
+ "required": {
183
+ "type": "boolean"
184
+ },
185
+ "items": {
186
+ "$ref": "#/definitions/OutputFieldDef"
187
+ },
188
+ "properties": {
189
+ "$ref": "#/definitions/OutputSchema"
190
+ }
191
+ },
192
+ "required": [
193
+ "type"
194
+ ],
195
+ "additionalProperties": false
196
+ },
197
+ "MCPConfig": {
198
+ "type": "object",
199
+ "properties": {
200
+ "servers": {
201
+ "type": "object",
202
+ "additionalProperties": {
203
+ "$ref": "#/definitions/MCPServerDef"
204
+ }
205
+ },
206
+ "tool_filter": {
207
+ "$ref": "#/definitions/ToolFilter"
208
+ },
209
+ "tool_prompt": {
210
+ "type": "string"
211
+ }
212
+ },
213
+ "required": [
214
+ "servers",
215
+ "tool_prompt"
216
+ ],
217
+ "additionalProperties": false
218
+ },
219
+ "MCPServerDef": {
220
+ "type": "object",
221
+ "properties": {
222
+ "command": {
223
+ "type": "string"
224
+ },
225
+ "args": {
226
+ "type": "array",
227
+ "items": {
228
+ "type": "string"
229
+ }
230
+ },
231
+ "env": {
232
+ "type": "object",
233
+ "additionalProperties": {
234
+ "type": "string"
235
+ }
236
+ },
237
+ "server_url": {
238
+ "type": "string"
239
+ },
240
+ "headers": {
241
+ "type": "object",
242
+ "additionalProperties": {
243
+ "type": "string"
244
+ }
245
+ },
246
+ "timeout": {
247
+ "type": "number"
248
+ }
249
+ },
250
+ "additionalProperties": false
251
+ },
252
+ "ToolFilter": {
253
+ "type": "object",
254
+ "properties": {
255
+ "allow": {
256
+ "type": "array",
257
+ "items": {
258
+ "type": "string"
259
+ }
260
+ },
261
+ "deny": {
262
+ "type": "array",
263
+ "items": {
264
+ "type": "string"
265
+ }
266
+ }
267
+ },
268
+ "additionalProperties": false
269
+ }
270
+ }
271
+ }
@@ -0,0 +1,58 @@
1
+ export const SPEC_VERSION = "0.8.3";
2
+ export interface AgentWrapper {
3
+ spec: "flatagent";
4
+ spec_version: string;
5
+ data: AgentData;
6
+ metadata?: Record<string, any>;
7
+ }
8
+ export interface AgentData {
9
+ name?: string;
10
+ model: string | ModelConfig | ProfiledModelConfig;
11
+ system: string;
12
+ user: string;
13
+ instruction_suffix?: string;
14
+ output?: OutputSchema;
15
+ mcp?: MCPConfig;
16
+ }
17
+ export interface MCPConfig {
18
+ servers: Record<string, MCPServerDef>;
19
+ tool_filter?: ToolFilter;
20
+ tool_prompt: string;
21
+ }
22
+ export interface MCPServerDef {
23
+ command?: string;
24
+ args?: string[];
25
+ env?: Record<string, string>;
26
+ server_url?: string;
27
+ headers?: Record<string, string>;
28
+ timeout?: number;
29
+ }
30
+ export interface ToolFilter {
31
+ allow?: string[];
32
+ deny?: string[];
33
+ }
34
+ export interface ModelConfig {
35
+ name: string;
36
+ provider?: string;
37
+ temperature?: number;
38
+ max_tokens?: number;
39
+ top_p?: number;
40
+ top_k?: number;
41
+ frequency_penalty?: number;
42
+ presence_penalty?: number;
43
+ seed?: number;
44
+ base_url?: string;
45
+ }
46
+ export interface ProfiledModelConfig extends Partial<ModelConfig> {
47
+ profile: string;
48
+ }
49
+ export type OutputSchema = Record<string, OutputFieldDef>;
50
+ export interface OutputFieldDef {
51
+ type: "str" | "int" | "float" | "bool" | "json" | "list" | "object";
52
+ description?: string;
53
+ enum?: string[];
54
+ required?: boolean;
55
+ items?: OutputFieldDef;
56
+ properties?: OutputSchema;
57
+ }
58
+ export type FlatagentsConfig = AgentWrapper;