flatagents 2.2.2__tar.gz → 2.4.0__tar.gz

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.
Files changed (36) hide show
  1. {flatagents-2.2.2 → flatagents-2.4.0}/MACHINES.md +11 -2
  2. {flatagents-2.2.2 → flatagents-2.4.0}/PKG-INFO +19 -1
  3. {flatagents-2.2.2 → flatagents-2.4.0}/README.md +18 -0
  4. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/__init__.py +17 -1
  5. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/assets/flatagent.d.ts +17 -1
  6. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/assets/flatagent.schema.json +58 -0
  7. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/assets/flatagent.slim.d.ts +14 -1
  8. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/assets/flatagents-runtime.d.ts +1 -1
  9. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/assets/flatagents-runtime.schema.json +1 -1
  10. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/assets/flatagents-runtime.slim.d.ts +1 -1
  11. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/assets/flatmachine.d.ts +1 -1
  12. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/assets/flatmachine.schema.json +58 -0
  13. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/assets/flatmachine.slim.d.ts +1 -1
  14. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/assets/profiles.d.ts +17 -1
  15. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/assets/profiles.schema.json +44 -0
  16. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/assets/profiles.slim.d.ts +14 -1
  17. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/flatagent.py +75 -6
  18. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/providers/__init__.py +12 -0
  19. flatagents-2.4.0/flatagents/providers/openai_codex_auth.py +250 -0
  20. flatagents-2.4.0/flatagents/providers/openai_codex_client.py +580 -0
  21. flatagents-2.4.0/flatagents/providers/openai_codex_login.py +306 -0
  22. flatagents-2.4.0/flatagents/providers/openai_codex_types.py +40 -0
  23. {flatagents-2.2.2 → flatagents-2.4.0}/pyproject.toml +1 -1
  24. {flatagents-2.2.2 → flatagents-2.4.0}/.gitignore +0 -0
  25. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/assets/README.md +0 -0
  26. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/assets/__init__.py +0 -0
  27. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/baseagent.py +0 -0
  28. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/monitoring.py +0 -0
  29. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/profiles.py +0 -0
  30. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/providers/anthropic.py +0 -0
  31. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/providers/cerebras.py +0 -0
  32. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/providers/openai.py +0 -0
  33. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/tool_loop.py +0 -0
  34. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/tools.py +0 -0
  35. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/utils.py +0 -0
  36. {flatagents-2.2.2 → flatagents-2.4.0}/flatagents/validation.py +0 -0
@@ -72,9 +72,10 @@ Common fields supported by the Python runtime:
72
72
  - `provider`, `name` (combined into `provider/name` if needed)
73
73
  - `temperature`, `max_tokens`, `top_p`, `top_k`
74
74
  - `frequency_penalty`, `presence_penalty`, `seed`
75
- - `base_url` (passed as `api_base` to LiteLLM)
75
+ - `base_url` (passed as `api_base` to LiteLLM, or Codex base URL for `backend: codex`)
76
76
  - `stream` (bool), `stream_options`
77
- - `backend` ("litellm" | "aisuite")
77
+ - `backend` ("litellm" | "aisuite" | "codex")
78
+ - `oauth` (Codex auth config: `auth_file`, `originator`, `refresh`, `timeout_seconds`, `max_retries`, `token_url`, `client_id`)
78
79
 
79
80
  ## Python Runtime Behavior
80
81
 
@@ -114,6 +115,7 @@ print(result.output, result.content)
114
115
  The Python SDK supports:
115
116
  - **LiteLLMBackend** (default; `litellm`)
116
117
  - **AISuiteBackend** (`aisuite`)
118
+ - **Codex OAuth backend** (`codex`)
117
119
  - **LLMBackend** protocol for custom providers
118
120
 
119
121
  Backend selection order:
@@ -122,6 +124,13 @@ Backend selection order:
122
124
  3. `FLATAGENTS_BACKEND` env var ("litellm" or "aisuite")
123
125
  4. Auto-detect installed backend (prefers litellm)
124
126
 
127
+ Codex is never auto-detected; configure it explicitly via `backend: codex`.
128
+
129
+ Codex login helper:
130
+ ```bash
131
+ python -m flatagents.providers.openai_codex_login --auth-file ~/.pi/agent/auth.json
132
+ ```
133
+
125
134
  ## MCP Tooling
126
135
 
127
136
  `FlatAgent` can call MCP tools when `data.mcp` is configured and a `MCPToolProvider` is supplied. The provider must implement:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flatagents
3
- Version: 2.2.2
3
+ Version: 2.4.0
4
4
  Summary: A lightweight framework for building LLM-powered agents.
5
5
  Project-URL: Homepage, https://github.com/memgrafter/flatagents
6
6
  Project-URL: Repository, https://github.com/memgrafter/flatagents
@@ -120,6 +120,7 @@ Resolution order: default → named profile → inline overrides → override.
120
120
  Built-in backends:
121
121
  - **LiteLLMBackend** (default, `litellm`)
122
122
  - **AISuiteBackend** (`aisuite`)
123
+ - **Codex OAuth backend** (`codex`)
123
124
 
124
125
  Selection order:
125
126
  1. `backend` argument to `FlatAgent(...)`
@@ -127,6 +128,23 @@ Selection order:
127
128
  3. `FLATAGENTS_BACKEND` env var ("litellm" or "aisuite")
128
129
  4. Auto-detect installed backend (prefers litellm)
129
130
 
131
+ Codex is explicit only (not auto-detected):
132
+
133
+ ```yaml
134
+ model:
135
+ provider: openai-codex
136
+ name: gpt-5
137
+ backend: codex
138
+ oauth:
139
+ auth_file: ~/.pi/agent/auth.json
140
+ ```
141
+
142
+ Login helper:
143
+
144
+ ```bash
145
+ python -m flatagents.providers.openai_codex_login --auth-file ~/.pi/agent/auth.json
146
+ ```
147
+
130
148
  ## MCP Tools
131
149
 
132
150
  Configure MCP in `data.mcp` and pass a `MCPToolProvider` implementation. The SDK does not ship a provider; you supply one (e.g., from `aisuite.mcp`). Tool calls are returned in `AgentResponse.tool_calls`.
@@ -77,6 +77,7 @@ Resolution order: default → named profile → inline overrides → override.
77
77
  Built-in backends:
78
78
  - **LiteLLMBackend** (default, `litellm`)
79
79
  - **AISuiteBackend** (`aisuite`)
80
+ - **Codex OAuth backend** (`codex`)
80
81
 
81
82
  Selection order:
82
83
  1. `backend` argument to `FlatAgent(...)`
@@ -84,6 +85,23 @@ Selection order:
84
85
  3. `FLATAGENTS_BACKEND` env var ("litellm" or "aisuite")
85
86
  4. Auto-detect installed backend (prefers litellm)
86
87
 
88
+ Codex is explicit only (not auto-detected):
89
+
90
+ ```yaml
91
+ model:
92
+ provider: openai-codex
93
+ name: gpt-5
94
+ backend: codex
95
+ oauth:
96
+ auth_file: ~/.pi/agent/auth.json
97
+ ```
98
+
99
+ Login helper:
100
+
101
+ ```bash
102
+ python -m flatagents.providers.openai_codex_login --auth-file ~/.pi/agent/auth.json
103
+ ```
104
+
87
105
  ## MCP Tools
88
106
 
89
107
  Configure MCP in `data.mcp` and pass a `MCPToolProvider` implementation. The SDK does not ship a provider; you supply one (e.g., from `aisuite.mcp`). Tool calls are returned in `AgentResponse.tool_calls`.
@@ -1,4 +1,4 @@
1
- __version__ = "2.2.2"
1
+ __version__ = "2.4.0"
2
2
 
3
3
  from .baseagent import (
4
4
  # Base agent (abstract, for multi-step agents)
@@ -71,6 +71,14 @@ from .providers import (
71
71
  extract_anthropic_rate_limits,
72
72
  OpenAIRateLimits,
73
73
  extract_openai_rate_limits,
74
+ CodexAuthError,
75
+ CodexClient,
76
+ CodexClientError,
77
+ CodexHTTPError,
78
+ CodexOAuthCredential,
79
+ CodexResult,
80
+ CodexToolCall,
81
+ CodexUsage,
74
82
  )
75
83
 
76
84
  __all__ = [
@@ -113,6 +121,14 @@ __all__ = [
113
121
  "extract_anthropic_rate_limits",
114
122
  "OpenAIRateLimits",
115
123
  "extract_openai_rate_limits",
124
+ "CodexAuthError",
125
+ "CodexClient",
126
+ "CodexClientError",
127
+ "CodexHTTPError",
128
+ "CodexOAuthCredential",
129
+ "CodexResult",
130
+ "CodexToolCall",
131
+ "CodexUsage",
116
132
  # Validation
117
133
  "validate_flatagent_config",
118
134
  "get_flatagent_schema",
@@ -46,6 +46,8 @@
46
46
  * presence_penalty - Presence penalty (-2.0 to 2.0)
47
47
  * seed - Random seed for reproducibility
48
48
  * base_url - Custom API base URL (for local models/proxies)
49
+ * backend - Runtime backend override (litellm, aisuite, codex)
50
+ * oauth - OAuth settings (used by codex backend)
49
51
  *
50
52
  * MODEL PROFILES:
51
53
  * ---------------
@@ -149,7 +151,7 @@
149
151
  * The profile field specifies which profile name to use as base.
150
152
  */
151
153
 
152
- export const SPEC_VERSION = "2.2.2";
154
+ export const SPEC_VERSION = "2.4.0";
153
155
 
154
156
  export interface AgentWrapper {
155
157
  spec: "flatagent";
@@ -198,6 +200,17 @@ export interface ToolFilter {
198
200
  deny?: string[];
199
201
  }
200
202
 
203
+ export interface OAuthConfig {
204
+ provider?: "openai-codex" | string;
205
+ auth_file?: string;
206
+ refresh?: boolean;
207
+ originator?: string;
208
+ timeout_seconds?: number;
209
+ max_retries?: number;
210
+ token_url?: string;
211
+ client_id?: string;
212
+ }
213
+
201
214
  export interface ModelConfig {
202
215
  name: string;
203
216
  provider?: string;
@@ -209,6 +222,9 @@ export interface ModelConfig {
209
222
  presence_penalty?: number;
210
223
  seed?: number;
211
224
  base_url?: string;
225
+ backend?: "litellm" | "aisuite" | "codex";
226
+ api?: string;
227
+ oauth?: OAuthConfig;
212
228
  }
213
229
 
214
230
  export interface ProfiledModelConfig extends Partial<ModelConfig> {
@@ -106,6 +106,20 @@
106
106
  },
107
107
  "base_url": {
108
108
  "type": "string"
109
+ },
110
+ "backend": {
111
+ "type": "string",
112
+ "enum": [
113
+ "litellm",
114
+ "aisuite",
115
+ "codex"
116
+ ]
117
+ },
118
+ "api": {
119
+ "type": "string"
120
+ },
121
+ "oauth": {
122
+ "$ref": "#/definitions/OAuthConfig"
109
123
  }
110
124
  },
111
125
  "required": [
@@ -113,6 +127,36 @@
113
127
  ],
114
128
  "additionalProperties": false
115
129
  },
130
+ "OAuthConfig": {
131
+ "type": "object",
132
+ "properties": {
133
+ "provider": {
134
+ "type": "string"
135
+ },
136
+ "auth_file": {
137
+ "type": "string"
138
+ },
139
+ "refresh": {
140
+ "type": "boolean"
141
+ },
142
+ "originator": {
143
+ "type": "string"
144
+ },
145
+ "timeout_seconds": {
146
+ "type": "number"
147
+ },
148
+ "max_retries": {
149
+ "type": "number"
150
+ },
151
+ "token_url": {
152
+ "type": "string"
153
+ },
154
+ "client_id": {
155
+ "type": "string"
156
+ }
157
+ },
158
+ "additionalProperties": false
159
+ },
116
160
  "ProfiledModelConfig": {
117
161
  "type": "object",
118
162
  "properties": {
@@ -146,6 +190,20 @@
146
190
  "base_url": {
147
191
  "type": "string"
148
192
  },
193
+ "backend": {
194
+ "type": "string",
195
+ "enum": [
196
+ "litellm",
197
+ "aisuite",
198
+ "codex"
199
+ ]
200
+ },
201
+ "api": {
202
+ "type": "string"
203
+ },
204
+ "oauth": {
205
+ "$ref": "#/definitions/OAuthConfig"
206
+ },
149
207
  "profile": {
150
208
  "type": "string"
151
209
  }
@@ -1,4 +1,4 @@
1
- export const SPEC_VERSION = "2.2.2";
1
+ export const SPEC_VERSION = "2.4.0";
2
2
  export interface AgentWrapper {
3
3
  spec: "flatagent";
4
4
  spec_version: string;
@@ -40,6 +40,16 @@ export interface ToolFilter {
40
40
  allow?: string[];
41
41
  deny?: string[];
42
42
  }
43
+ export interface OAuthConfig {
44
+ provider?: "openai-codex" | string;
45
+ auth_file?: string;
46
+ refresh?: boolean;
47
+ originator?: string;
48
+ timeout_seconds?: number;
49
+ max_retries?: number;
50
+ token_url?: string;
51
+ client_id?: string;
52
+ }
43
53
  export interface ModelConfig {
44
54
  name: string;
45
55
  provider?: string;
@@ -51,6 +61,9 @@ export interface ModelConfig {
51
61
  presence_penalty?: number;
52
62
  seed?: number;
53
63
  base_url?: string;
64
+ backend?: "litellm" | "aisuite" | "codex";
65
+ api?: string;
66
+ oauth?: OAuthConfig;
54
67
  }
55
68
  export interface ProfiledModelConfig extends Partial<ModelConfig> {
56
69
  profile: string;
@@ -800,7 +800,7 @@ export interface BackendConfig {
800
800
  aws_region?: string;
801
801
  }
802
802
 
803
- export const SPEC_VERSION = "2.2.2";
803
+ export const SPEC_VERSION = "2.4.0";
804
804
 
805
805
  export interface SDKRuntimeWrapper {
806
806
  spec: "flatagents-runtime";
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "spec_version": {
13
13
  "type": "string",
14
- "const": "2.2.2"
14
+ "const": "2.4.0"
15
15
  },
16
16
  "execution_lock": {
17
17
  "$ref": "#/definitions/ExecutionLock"
@@ -252,7 +252,7 @@ export interface BackendConfig {
252
252
  dynamodb_table?: string;
253
253
  aws_region?: string;
254
254
  }
255
- export const SPEC_VERSION = "2.2.2";
255
+ export const SPEC_VERSION = "2.4.0";
256
256
  export interface SDKRuntimeWrapper {
257
257
  spec: "flatagents-runtime";
258
258
  spec_version: typeof SPEC_VERSION;
@@ -319,7 +319,7 @@
319
319
  * config_hash - Content-addressed machine config key for cross-SDK resume (v2.1.0)
320
320
  */
321
321
 
322
- export const SPEC_VERSION = "2.2.2";
322
+ export const SPEC_VERSION = "2.4.0";
323
323
 
324
324
  export interface MachineWrapper {
325
325
  spec: "flatmachine";
@@ -245,6 +245,20 @@
245
245
  },
246
246
  "base_url": {
247
247
  "type": "string"
248
+ },
249
+ "backend": {
250
+ "type": "string",
251
+ "enum": [
252
+ "litellm",
253
+ "aisuite",
254
+ "codex"
255
+ ]
256
+ },
257
+ "api": {
258
+ "type": "string"
259
+ },
260
+ "oauth": {
261
+ "$ref": "#/definitions/OAuthConfig"
248
262
  }
249
263
  },
250
264
  "required": [
@@ -252,6 +266,36 @@
252
266
  ],
253
267
  "additionalProperties": false
254
268
  },
269
+ "OAuthConfig": {
270
+ "type": "object",
271
+ "properties": {
272
+ "provider": {
273
+ "type": "string"
274
+ },
275
+ "auth_file": {
276
+ "type": "string"
277
+ },
278
+ "refresh": {
279
+ "type": "boolean"
280
+ },
281
+ "originator": {
282
+ "type": "string"
283
+ },
284
+ "timeout_seconds": {
285
+ "type": "number"
286
+ },
287
+ "max_retries": {
288
+ "type": "number"
289
+ },
290
+ "token_url": {
291
+ "type": "string"
292
+ },
293
+ "client_id": {
294
+ "type": "string"
295
+ }
296
+ },
297
+ "additionalProperties": false
298
+ },
255
299
  "ProfiledModelConfig": {
256
300
  "type": "object",
257
301
  "properties": {
@@ -285,6 +329,20 @@
285
329
  "base_url": {
286
330
  "type": "string"
287
331
  },
332
+ "backend": {
333
+ "type": "string",
334
+ "enum": [
335
+ "litellm",
336
+ "aisuite",
337
+ "codex"
338
+ ]
339
+ },
340
+ "api": {
341
+ "type": "string"
342
+ },
343
+ "oauth": {
344
+ "$ref": "#/definitions/OAuthConfig"
345
+ },
288
346
  "profile": {
289
347
  "type": "string"
290
348
  }
@@ -1,4 +1,4 @@
1
- export const SPEC_VERSION = "2.2.2";
1
+ export const SPEC_VERSION = "2.4.0";
2
2
  export interface MachineWrapper {
3
3
  spec: "flatmachine";
4
4
  spec_version: string;
@@ -106,9 +106,11 @@
106
106
  * seed - Random seed for reproducibility
107
107
  * base_url - Custom base URL for the API (e.g., for local models or proxies)
108
108
  * stream - Enable streaming responses (default: false)
109
+ * backend - Runtime backend override (litellm, aisuite, codex)
110
+ * oauth - OAuth settings (used by codex backend)
109
111
  */
110
112
 
111
- export const SPEC_VERSION = "2.2.2";
113
+ export const SPEC_VERSION = "2.4.0";
112
114
 
113
115
  export interface ProfilesWrapper {
114
116
  spec: "flatprofiles";
@@ -123,6 +125,17 @@ export interface ProfilesData {
123
125
  override?: string;
124
126
  }
125
127
 
128
+ export interface OAuthConfig {
129
+ provider?: "openai-codex" | string;
130
+ auth_file?: string;
131
+ refresh?: boolean;
132
+ originator?: string;
133
+ timeout_seconds?: number;
134
+ max_retries?: number;
135
+ token_url?: string;
136
+ client_id?: string;
137
+ }
138
+
126
139
  export interface ModelProfileConfig {
127
140
  name: string;
128
141
  provider?: string;
@@ -135,6 +148,9 @@ export interface ModelProfileConfig {
135
148
  seed?: number;
136
149
  base_url?: string;
137
150
  stream?: boolean;
151
+ backend?: "litellm" | "aisuite" | "codex";
152
+ api?: string;
153
+ oauth?: OAuthConfig;
138
154
  }
139
155
 
140
156
  export type FlatprofilesConfig = ProfilesWrapper;
@@ -82,12 +82,56 @@
82
82
  },
83
83
  "stream": {
84
84
  "type": "boolean"
85
+ },
86
+ "backend": {
87
+ "type": "string",
88
+ "enum": [
89
+ "litellm",
90
+ "aisuite",
91
+ "codex"
92
+ ]
93
+ },
94
+ "api": {
95
+ "type": "string"
96
+ },
97
+ "oauth": {
98
+ "$ref": "#/definitions/OAuthConfig"
85
99
  }
86
100
  },
87
101
  "required": [
88
102
  "name"
89
103
  ],
90
104
  "additionalProperties": false
105
+ },
106
+ "OAuthConfig": {
107
+ "type": "object",
108
+ "properties": {
109
+ "provider": {
110
+ "type": "string"
111
+ },
112
+ "auth_file": {
113
+ "type": "string"
114
+ },
115
+ "refresh": {
116
+ "type": "boolean"
117
+ },
118
+ "originator": {
119
+ "type": "string"
120
+ },
121
+ "timeout_seconds": {
122
+ "type": "number"
123
+ },
124
+ "max_retries": {
125
+ "type": "number"
126
+ },
127
+ "token_url": {
128
+ "type": "string"
129
+ },
130
+ "client_id": {
131
+ "type": "string"
132
+ }
133
+ },
134
+ "additionalProperties": false
91
135
  }
92
136
  }
93
137
  }
@@ -1,4 +1,4 @@
1
- export const SPEC_VERSION = "2.2.2";
1
+ export const SPEC_VERSION = "2.4.0";
2
2
  export interface ProfilesWrapper {
3
3
  spec: "flatprofiles";
4
4
  spec_version: string;
@@ -10,6 +10,16 @@ export interface ProfilesData {
10
10
  default?: string;
11
11
  override?: string;
12
12
  }
13
+ export interface OAuthConfig {
14
+ provider?: "openai-codex" | string;
15
+ auth_file?: string;
16
+ refresh?: boolean;
17
+ originator?: string;
18
+ timeout_seconds?: number;
19
+ max_retries?: number;
20
+ token_url?: string;
21
+ client_id?: string;
22
+ }
13
23
  export interface ModelProfileConfig {
14
24
  name: string;
15
25
  provider?: string;
@@ -22,5 +32,8 @@ export interface ModelProfileConfig {
22
32
  seed?: number;
23
33
  base_url?: string;
24
34
  stream?: boolean;
35
+ backend?: "litellm" | "aisuite" | "codex";
36
+ api?: string;
37
+ oauth?: OAuthConfig;
25
38
  }
26
39
  export type FlatprofilesConfig = ProfilesWrapper;