agentsml-lsp 0.2.0__py3-none-any.whl

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,3 @@
1
+ """AgentsML Language Server package."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,104 @@
1
+ """Context-aware completion providers for the AgentsML language server."""
2
+
3
+ from lsprotocol.types import CompletionItem, CompletionItemKind
4
+
5
+
6
+ # Known top-level collection keys in order of the spec
7
+ TOP_LEVEL_KEYS = [
8
+ "agentsml", "kind", "metadata", "profiles",
9
+ "models", "tools", "resources", "prompts",
10
+ "agents", "workflows", "schemas", "policies",
11
+ "deployments", "events", "mcp_servers",
12
+ "a2a_agents", "a2a_server", "ui",
13
+ ]
14
+
15
+ # Profile names from the spec
16
+ VALID_PROFILES = [
17
+ "agentsml-core",
18
+ "agentsml-graph",
19
+ "agentsml-conversation",
20
+ "agentsml-rag",
21
+ "agentsml-mcp",
22
+ "agentsml-a2a",
23
+ "agentsml-ui",
24
+ "agentsml-commerce",
25
+ "agentsml-payments",
26
+ "agentsml-enterprise",
27
+ "agentsml-observability",
28
+ ]
29
+
30
+ # Tool side_effect enum values
31
+ VALID_SIDE_EFFECTS = ["read", "write", "delete", "payment", "browser", "external", "unknown"]
32
+
33
+ # MCP transport enum values
34
+ VALID_TRANSPORTS = ["stdio", "streamable_http", "sse", "http", "websocket"]
35
+
36
+ # Workflow step join modes
37
+ VALID_JOIN_MODES = ["wait_all", "wait_any"]
38
+
39
+ # Draft 0.3 enums
40
+ VALID_BACKOFFS = ["none", "linear", "exponential"]
41
+ VALID_ON_TIMEOUT = ["error", "return_to_model", "fallback"]
42
+ VALID_REASONING_EFFORTS = ["off", "low", "medium", "high"]
43
+ VALID_APPROVAL_MODES = ["always", "once_per_session", "per_arguments"]
44
+
45
+ # Draft 0.3 keys offered by context: (key, detail)
46
+ STEP_KEYS_03 = [
47
+ ("retry", "Retry policy for the step (Draft 0.3)"),
48
+ ("timeout", "Step timeout, e.g. 60s or seconds"),
49
+ ]
50
+ RETRY_KEYS = [
51
+ ("max_attempts", "Maximum attempts including the first"),
52
+ ("backoff", "Backoff strategy: none, linear, exponential"),
53
+ ("initial_interval", "Delay before the first retry"),
54
+ ("max_interval", "Upper bound on the delay between retries"),
55
+ ("on_timeout", "Behavior on timeout: error, return_to_model, fallback"),
56
+ ]
57
+ AGENT_KEYS_03 = [("reasoning", "Reasoning configuration (Draft 0.3)")]
58
+ REASONING_KEYS = [
59
+ ("effort", "Reasoning effort: off, low, medium, high"),
60
+ ("budget_tokens", "Token budget for reasoning"),
61
+ ("expose_trace", "Whether the reasoning trace is exposed"),
62
+ ]
63
+ TOOL_KEYS_03 = [
64
+ ("needs_approval", "Require human approval before the tool runs (Draft 0.3)"),
65
+ ("approval_mode", "When approval is requested: always, once_per_session, per_arguments"),
66
+ ]
67
+ APPROVAL_KEYS_03 = [
68
+ ("required", "Whether approval is required"),
69
+ ("approvers", "Who may approve"),
70
+ ("timeout", "How long to wait for approval"),
71
+ ]
72
+
73
+ # Kind constant
74
+ VALID_KINDS = ["AgentSystem"]
75
+
76
+
77
+ def top_level_completions() -> list[CompletionItem]:
78
+ """Return all known top-level collection keys as completions."""
79
+ return [CompletionItem(label=k, kind=CompletionItemKind.Property) for k in TOP_LEVEL_KEYS]
80
+
81
+
82
+ def profile_completions() -> list[CompletionItem]:
83
+ """Return valid profile names as completions."""
84
+ return [CompletionItem(label=p, kind=CompletionItemKind.Enum) for p in VALID_PROFILES]
85
+
86
+
87
+ def side_effect_completions() -> list[CompletionItem]:
88
+ """Return valid tool side_effect values."""
89
+ return [CompletionItem(label=f'"{v}"', kind=CompletionItemKind.Enum) for v in VALID_SIDE_EFFECTS]
90
+
91
+
92
+ def transport_completions() -> list[CompletionItem]:
93
+ """Return valid MCP server transport values."""
94
+ return [CompletionItem(label=f'"{v}"', kind=CompletionItemKind.Enum) for v in VALID_TRANSPORTS]
95
+
96
+
97
+ def join_mode_completions() -> list[CompletionItem]:
98
+ """Return valid workflow step join modes."""
99
+ return [CompletionItem(label=v, kind=CompletionItemKind.Enum) for v in VALID_JOIN_MODES]
100
+
101
+
102
+ def kind_completion() -> CompletionItem:
103
+ """Return the valid 'kind' constant completion."""
104
+ return CompletionItem(label="AgentSystem", kind=CompletionItemKind.Constant)
@@ -0,0 +1,406 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://agentsml.org/schemas/agentsml.schema.json",
4
+ "title": "AgentsML",
5
+ "type": "object",
6
+ "required": ["agentsml", "kind", "metadata"],
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "agentsml": {
10
+ "type": "string",
11
+ "enum": ["0.1", "0.2", "0.3"]
12
+ },
13
+ "kind": {
14
+ "type": "string",
15
+ "const": "AgentSystem"
16
+ },
17
+ "metadata": {
18
+ "type": "object",
19
+ "required": ["name"],
20
+ "additionalProperties": true,
21
+ "properties": {
22
+ "name": { "type": "string", "minLength": 1 },
23
+ "version": { "type": "string" },
24
+ "description": { "type": "string" },
25
+ "tags": {
26
+ "type": "array",
27
+ "items": { "type": "string" }
28
+ }
29
+ }
30
+ },
31
+ "profiles": {
32
+ "oneOf": [
33
+ {
34
+ "type": "array",
35
+ "items": { "type": "string" }
36
+ },
37
+ {
38
+ "type": "object",
39
+ "additionalProperties": false,
40
+ "properties": {
41
+ "required": {
42
+ "type": "array",
43
+ "items": { "type": "string" }
44
+ },
45
+ "optional": {
46
+ "type": "array",
47
+ "items": { "type": "string" }
48
+ },
49
+ "extensions": {
50
+ "type": "array",
51
+ "items": { "type": "string" }
52
+ }
53
+ }
54
+ }
55
+ ]
56
+ },
57
+ "models": {
58
+ "type": "object",
59
+ "additionalProperties": { "$ref": "#/$defs/model" }
60
+ },
61
+ "tools": {
62
+ "type": "object",
63
+ "additionalProperties": { "$ref": "#/$defs/tool" }
64
+ },
65
+ "resources": {
66
+ "type": "object",
67
+ "additionalProperties": { "$ref": "#/$defs/resource" }
68
+ },
69
+ "prompts": {
70
+ "type": "object",
71
+ "additionalProperties": { "$ref": "#/$defs/prompt" }
72
+ },
73
+ "agents": {
74
+ "type": "object",
75
+ "additionalProperties": { "$ref": "#/$defs/agent" }
76
+ },
77
+ "workflows": {
78
+ "type": "object",
79
+ "additionalProperties": { "$ref": "#/$defs/workflow" }
80
+ },
81
+ "schemas": {
82
+ "type": "object",
83
+ "additionalProperties": { "type": "object" }
84
+ },
85
+ "policies": {
86
+ "type": "object",
87
+ "additionalProperties": { "$ref": "#/$defs/policy" }
88
+ },
89
+ "deployments": {
90
+ "type": "object",
91
+ "additionalProperties": { "type": "object" }
92
+ },
93
+ "events": {
94
+ "$ref": "#/$defs/events_config"
95
+ },
96
+ "mcp_servers": {
97
+ "type": "object",
98
+ "additionalProperties": { "$ref": "#/$defs/mcp_server" }
99
+ },
100
+ "a2a_agents": {
101
+ "type": "object",
102
+ "additionalProperties": { "$ref": "#/$defs/a2a_agent" }
103
+ },
104
+ "a2a_server": {
105
+ "$ref": "#/$defs/a2a_server"
106
+ },
107
+ "ui": {
108
+ "$ref": "#/$defs/ui"
109
+ }
110
+ },
111
+ "$defs": {
112
+ "model": {
113
+ "type": "object",
114
+ "required": ["provider", "name"],
115
+ "additionalProperties": true,
116
+ "properties": {
117
+ "provider": { "type": "string" },
118
+ "name": { "type": "string" },
119
+ "version": { "type": "string" },
120
+ "parameters": { "type": "object" },
121
+ "fallbacks": {
122
+ "type": "array",
123
+ "items": { "type": "string" }
124
+ }
125
+ }
126
+ },
127
+ "tool": {
128
+ "type": "object",
129
+ "required": ["description", "source"],
130
+ "additionalProperties": true,
131
+ "properties": {
132
+ "description": { "type": "string" },
133
+ "source": { "type": "string" },
134
+ "input_schema": { "type": "object" },
135
+ "output_schema": { "type": "object" },
136
+ "auth": { "type": "object" },
137
+ "permissions": { "type": "object" },
138
+ "side_effect": {
139
+ "type": "string",
140
+ "enum": ["read", "write", "delete", "payment", "browser", "external", "unknown"]
141
+ },
142
+ "timeout": { "type": ["number", "string"] },
143
+ "error_policy": { "type": "object" },
144
+ "needs_approval": { "type": "boolean" },
145
+ "approval_mode": { "type": "string", "enum": ["always", "once_per_session", "per_arguments"], "default": "always" }
146
+ }
147
+ },
148
+ "resource": {
149
+ "type": "object",
150
+ "additionalProperties": true,
151
+ "properties": {
152
+ "description": { "type": "string" },
153
+ "source": { "type": "string" },
154
+ "schema": { "type": "object" },
155
+ "auth": { "type": "object" },
156
+ "permissions": { "type": "object" }
157
+ }
158
+ },
159
+ "prompt": {
160
+ "type": "object",
161
+ "required": ["template"],
162
+ "additionalProperties": true,
163
+ "properties": {
164
+ "description": { "type": "string" },
165
+ "template": { "type": "string" },
166
+ "input_schema": { "type": "object" },
167
+ "metadata": { "type": "object" }
168
+ }
169
+ },
170
+ "agent": {
171
+ "type": "object",
172
+ "required": ["model", "instructions"],
173
+ "additionalProperties": true,
174
+ "properties": {
175
+ "description": { "type": "string" },
176
+ "role": { "type": "string" },
177
+ "model": { "type": "string" },
178
+ "instructions": { "type": "string" },
179
+ "tools": {
180
+ "type": "array",
181
+ "items": { "type": "string" }
182
+ },
183
+ "resources": {
184
+ "type": "array",
185
+ "items": { "type": "string" }
186
+ },
187
+ "prompts": {
188
+ "type": "array",
189
+ "items": { "type": "string" }
190
+ },
191
+ "memory": { "type": "object" },
192
+ "knowledge": { "type": "object" },
193
+ "output_schema": { "type": "object" },
194
+ "reasoning": {
195
+ "type": "object",
196
+ "additionalProperties": false,
197
+ "properties": {
198
+ "effort": { "type": "string", "enum": ["off", "low", "medium", "high"] },
199
+ "budget_tokens": { "type": "integer", "minimum": 0 },
200
+ "expose_trace": { "type": "boolean" }
201
+ }
202
+ },
203
+ "policies": {
204
+ "type": "array",
205
+ "items": { "type": "string" }
206
+ }
207
+ }
208
+ },
209
+ "workflow": {
210
+ "type": "object",
211
+ "required": ["steps"],
212
+ "additionalProperties": true,
213
+ "properties": {
214
+ "description": { "type": "string" },
215
+ "input_schema": { "type": "object" },
216
+ "output_schema": { "type": "object" },
217
+ "state": { "type": "object" },
218
+ "steps": {
219
+ "type": "array",
220
+ "items": { "$ref": "#/$defs/step" }
221
+ },
222
+ "edges": {
223
+ "type": "array",
224
+ "items": { "$ref": "#/$defs/edge" }
225
+ },
226
+ "events": { "type": "array" },
227
+ "error_policy": { "type": "object" }
228
+ }
229
+ },
230
+ "step": {
231
+ "type": "object",
232
+ "required": ["id"],
233
+ "additionalProperties": true,
234
+ "properties": {
235
+ "id": { "type": "string" },
236
+ "agent": { "type": "string" },
237
+ "tool": { "type": "string" },
238
+ "workflow": { "type": "string" },
239
+ "a2a_agent": { "type": "string" },
240
+ "skill": { "type": "string" },
241
+ "input": {},
242
+ "output": {},
243
+ "condition": {},
244
+ "depends_on": {
245
+ "type": "array",
246
+ "items": { "type": "string" }
247
+ },
248
+ "join": {
249
+ "type": "string",
250
+ "enum": ["wait_all", "wait_any"]
251
+ },
252
+ "parallel": {
253
+ "oneOf": [
254
+ { "type": "boolean" },
255
+ {
256
+ "type": "array",
257
+ "items": { "type": "string" }
258
+ }
259
+ ]
260
+ },
261
+ "retry": {
262
+ "type": "object",
263
+ "additionalProperties": true,
264
+ "properties": {
265
+ "max_attempts": { "type": "integer", "minimum": 1 },
266
+ "backoff": { "type": "string", "enum": ["none", "linear", "exponential"] },
267
+ "initial_interval": { "type": ["string", "number"] },
268
+ "max_interval": { "type": ["string", "number"] },
269
+ "on_timeout": { "type": "string", "enum": ["error", "return_to_model", "fallback"], "default": "error" }
270
+ }
271
+ },
272
+ "timeout": { "type": ["number", "string"] },
273
+ "fallback": {
274
+ "type": "object",
275
+ "description": "Draft 0.3. Value or model used when retry.on_timeout is 'fallback'. At least one of output or model is required.",
276
+ "additionalProperties": false,
277
+ "properties": {
278
+ "output": { "description": "Static JSON value returned as the step output." },
279
+ "model": { "type": "string", "description": "Key of a declared model used to re-run the step." }
280
+ },
281
+ "anyOf": [ { "required": ["output"] }, { "required": ["model"] } ]
282
+ },
283
+ "approval": {
284
+ "oneOf": [
285
+ { "type": "string" },
286
+ {
287
+ "type": "object",
288
+ "properties": {
289
+ "required": { "type": "boolean" },
290
+ "approvers": { "type": "array", "items": { "type": "string" } },
291
+ "timeout": { "type": ["string", "number"] }
292
+ }
293
+ }
294
+ ]
295
+ },
296
+ "events": {
297
+ "type": "array",
298
+ "items": {
299
+ "oneOf": [
300
+ { "type": "string" },
301
+ { "type": "object" }
302
+ ]
303
+ }
304
+ }
305
+ }
306
+ },
307
+ "edge": {
308
+ "type": "object",
309
+ "required": ["from", "to"],
310
+ "additionalProperties": true,
311
+ "properties": {
312
+ "from": { "type": "string" },
313
+ "to": { "type": "string" },
314
+ "condition": {},
315
+ "label": { "type": "string" }
316
+ }
317
+ },
318
+ "policy": {
319
+ "type": "object",
320
+ "additionalProperties": true,
321
+ "properties": {
322
+ "description": { "type": "string" },
323
+ "applies_to": {
324
+ "type": "array",
325
+ "items": { "type": "string" }
326
+ },
327
+ "permissions": { "type": "object" },
328
+ "guardrails": { "type": "object" },
329
+ "approval": { "type": "object" },
330
+ "audit": { "type": "object" }
331
+ }
332
+ },
333
+ "events_config": {
334
+ "type": "object",
335
+ "additionalProperties": true,
336
+ "properties": {
337
+ "emit": {
338
+ "type": "array",
339
+ "items": { "type": "string" }
340
+ },
341
+ "export": { "type": "object" },
342
+ "redaction": { "type": "object" }
343
+ }
344
+ },
345
+ "mcp_server": {
346
+ "type": "object",
347
+ "additionalProperties": true,
348
+ "properties": {
349
+ "description": { "type": "string" },
350
+ "transport": {
351
+ "type": "string",
352
+ "enum": ["stdio", "streamable_http", "sse", "http", "websocket"]
353
+ },
354
+ "command": { "type": "string" },
355
+ "args": {
356
+ "type": "array",
357
+ "items": { "type": "string" }
358
+ },
359
+ "url": { "type": "string" },
360
+ "capabilities": {
361
+ "type": "array",
362
+ "items": { "type": "string" }
363
+ },
364
+ "auth": { "type": "object" }
365
+ }
366
+ },
367
+ "a2a_agent": {
368
+ "type": "object",
369
+ "additionalProperties": true,
370
+ "properties": {
371
+ "description": { "type": "string" },
372
+ "agent_card_url": { "type": "string" },
373
+ "skills": {
374
+ "type": "array",
375
+ "items": { "type": "string" }
376
+ },
377
+ "auth": { "type": "object" }
378
+ }
379
+ },
380
+ "a2a_server": {
381
+ "type": "object",
382
+ "additionalProperties": true,
383
+ "properties": {
384
+ "name": { "type": "string" },
385
+ "description": { "type": "string" },
386
+ "version": { "type": "string" },
387
+ "skills": {
388
+ "type": "array",
389
+ "items": { "type": "object" }
390
+ },
391
+ "auth": { "type": "object" }
392
+ }
393
+ },
394
+ "ui": {
395
+ "type": "object",
396
+ "additionalProperties": true,
397
+ "properties": {
398
+ "protocol": { "type": "string" },
399
+ "transport": { "type": "string" },
400
+ "session_model": { "type": "string" },
401
+ "events": { "$ref": "#/$defs/events_config" },
402
+ "state_schema": { "type": "object" }
403
+ }
404
+ }
405
+ }
406
+ }