@datalayer/agent-runtimes 1.0.3 → 1.0.4

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 (73) hide show
  1. package/README.md +13 -131
  2. package/lib/chat/Chat.d.ts +3 -1
  3. package/lib/chat/Chat.js +2 -2
  4. package/lib/chat/base/ChatBase.js +52 -1
  5. package/lib/chat/messages/ChatMessageList.js +17 -4
  6. package/lib/client/AgentsMixin.d.ts +48 -1
  7. package/lib/client/AgentsMixin.js +109 -0
  8. package/lib/components/NotificationEventCard.js +51 -26
  9. package/lib/components/OutputCard.js +21 -7
  10. package/lib/components/ToolApprovalCard.js +20 -2
  11. package/lib/examples/AgentCheckpointsExample.js +2 -8
  12. package/lib/examples/AgentCodemodeExample.js +3 -9
  13. package/lib/examples/AgentEvalsExample.js +3 -9
  14. package/lib/examples/AgentGuardrailsExample.js +3 -9
  15. package/lib/examples/AgentMemoryExample.js +3 -9
  16. package/lib/examples/AgentMonitoringExample.js +3 -9
  17. package/lib/examples/AgentNotificationsExample.js +2 -8
  18. package/lib/examples/AgentOutputsExample.js +3 -9
  19. package/lib/examples/AgentSandboxExample.js +3 -9
  20. package/lib/examples/AgentSkillsExample.js +3 -9
  21. package/lib/examples/AgentToolApprovalsExample.js +89 -24
  22. package/lib/examples/AgentTriggersExample.js +604 -37
  23. package/lib/examples/ChatExample.js +2 -10
  24. package/lib/examples/components/ErrorView.d.ts +14 -0
  25. package/lib/examples/components/ErrorView.js +20 -0
  26. package/lib/examples/components/index.d.ts +2 -0
  27. package/lib/examples/components/index.js +1 -0
  28. package/lib/examples/main.d.ts +1 -0
  29. package/lib/examples/main.js +1 -0
  30. package/lib/protocols/VercelAIAdapter.d.ts +2 -0
  31. package/lib/protocols/VercelAIAdapter.js +86 -20
  32. package/lib/shims/json5.d.ts +4 -0
  33. package/lib/shims/json5.js +8 -0
  34. package/lib/specs/agents/agents.js +241 -1390
  35. package/lib/specs/agents/index.js +1 -3
  36. package/lib/specs/envvars.js +20 -27
  37. package/lib/specs/evals.js +6 -6
  38. package/lib/specs/events.d.ts +10 -2
  39. package/lib/specs/events.js +84 -126
  40. package/lib/specs/frontendTools.js +2 -2
  41. package/lib/specs/guardrails.d.ts +7 -0
  42. package/lib/specs/guardrails.js +159 -240
  43. package/lib/specs/mcpServers.js +6 -35
  44. package/lib/specs/memory.d.ts +2 -0
  45. package/lib/specs/memory.js +17 -4
  46. package/lib/specs/models.js +5 -25
  47. package/lib/specs/notifications.js +18 -102
  48. package/lib/specs/outputs.js +9 -15
  49. package/lib/specs/skills.js +18 -18
  50. package/lib/specs/teams/index.js +1 -3
  51. package/lib/specs/teams/teams.js +348 -468
  52. package/lib/specs/tools.js +6 -3
  53. package/lib/specs/triggers.js +11 -61
  54. package/lib/types/tools.d.ts +2 -0
  55. package/package.json +1 -1
  56. package/scripts/codegen/__pycache__/versioning.cpython-313.pyc +0 -0
  57. package/scripts/codegen/generate_agents.py +4 -1
  58. package/scripts/codegen/generate_events.py +12 -4
  59. package/scripts/codegen/generate_tools.py +20 -0
  60. package/style/primer-primitives.css +1 -6
  61. package/scripts/codegen/__pycache__/generate_agents.cpython-313.pyc +0 -0
  62. package/scripts/codegen/__pycache__/generate_envvars.cpython-313.pyc +0 -0
  63. package/scripts/codegen/__pycache__/generate_evals.cpython-313.pyc +0 -0
  64. package/scripts/codegen/__pycache__/generate_guardrails.cpython-313.pyc +0 -0
  65. package/scripts/codegen/__pycache__/generate_mcp_servers.cpython-313.pyc +0 -0
  66. package/scripts/codegen/__pycache__/generate_memory.cpython-313.pyc +0 -0
  67. package/scripts/codegen/__pycache__/generate_models.cpython-313.pyc +0 -0
  68. package/scripts/codegen/__pycache__/generate_notifications.cpython-313.pyc +0 -0
  69. package/scripts/codegen/__pycache__/generate_outputs.cpython-313.pyc +0 -0
  70. package/scripts/codegen/__pycache__/generate_skills.cpython-313.pyc +0 -0
  71. package/scripts/codegen/__pycache__/generate_teams.cpython-313.pyc +0 -0
  72. package/scripts/codegen/__pycache__/generate_tools.cpython-313.pyc +0 -0
  73. package/scripts/codegen/__pycache__/generate_triggers.cpython-313.pyc +0 -0
@@ -10,9 +10,10 @@ export const RUNTIME_ECHO_TOOL_SPEC_0_0_1 = {
10
10
  version: '0.0.1',
11
11
  name: 'Runtime Echo',
12
12
  description: 'Echo text back to the caller for quick runtime verification.',
13
- tags: ['runtime', 'utility'],
13
+ tags: ["runtime", "utility"],
14
14
  enabled: true,
15
15
  approval: 'auto',
16
+ timeout: undefined,
16
17
  requiresApproval: false,
17
18
  runtime: {
18
19
  language: 'python',
@@ -27,9 +28,10 @@ export const RUNTIME_SEND_MAIL_TOOL_SPEC_0_0_1 = {
27
28
  version: '0.0.1',
28
29
  name: 'Runtime Send Mail (Fake)',
29
30
  description: 'Fake mail sender for tool approval demos; returns a simulated send receipt.',
30
- tags: ['runtime', 'approval', 'mail'],
31
+ tags: ["runtime", "approval", "mail"],
31
32
  enabled: true,
32
33
  approval: 'manual',
34
+ timeout: undefined,
33
35
  requiresApproval: true,
34
36
  runtime: {
35
37
  language: 'python',
@@ -44,9 +46,10 @@ export const RUNTIME_SENSITIVE_ECHO_TOOL_SPEC_0_0_1 = {
44
46
  version: '0.0.1',
45
47
  name: 'Runtime Sensitive Echo',
46
48
  description: 'Echo text with a manual approval checkpoint before execution.',
47
- tags: ['runtime', 'approval'],
49
+ tags: ["runtime", "approval"],
48
50
  enabled: true,
49
51
  approval: 'manual',
52
+ timeout: '5h0m0s',
50
53
  requiresApproval: true,
51
54
  runtime: {
52
55
  language: 'python',
@@ -12,35 +12,10 @@ export const EVENT_TRIGGER_SPEC_0_0_1 = {
12
12
  description: 'Trigger on specific events such as a webhook call, API request, database change, file upload, or email arrival.',
13
13
  type: 'event',
14
14
  fields: [
15
- {
16
- name: 'event_source',
17
- label: 'Event Source URL',
18
- type: 'string',
19
- required: false,
20
- placeholder: 'https://helpdesk.example.com/webhooks',
21
- help: 'Allowed event source URL (leave empty to allow any source)',
22
- },
23
- {
24
- name: 'event',
25
- label: 'Event Name',
26
- type: 'string',
27
- required: false,
28
- placeholder: 'email_received',
29
- },
30
- {
31
- name: 'description',
32
- label: 'Description',
33
- type: 'string',
34
- required: false,
35
- placeholder: "Description (e.g. 'Triggered on incoming email')",
36
- },
37
- {
38
- name: 'prompt',
39
- label: 'Trigger Prompt',
40
- type: 'string',
41
- required: false,
42
- placeholder: 'Handle the incoming event and execute the agent end-to-end.',
43
- },
15
+ { name: 'event_source', label: 'Event Source URL', type: 'string', required: false, placeholder: 'https://helpdesk.example.com/webhooks', help: 'Allowed event source URL (leave empty to allow any source)' },
16
+ { name: 'event', label: 'Event Name', type: 'string', required: false, placeholder: 'email_received' },
17
+ { name: 'description', label: 'Description', type: 'string', required: false, placeholder: 'Description (e.g. \'Triggered on incoming email\')' },
18
+ { name: 'prompt', label: 'Trigger Prompt', type: 'string', required: false, placeholder: 'Handle the incoming event and execute the agent end-to-end.' },
44
19
  ],
45
20
  };
46
21
  export const ONCE_TRIGGER_SPEC_0_0_1 = {
@@ -50,13 +25,7 @@ export const ONCE_TRIGGER_SPEC_0_0_1 = {
50
25
  description: 'Execute agent immediately after deployment.',
51
26
  type: 'once',
52
27
  fields: [
53
- {
54
- name: 'prompt',
55
- label: 'Trigger Prompt',
56
- type: 'string',
57
- required: false,
58
- placeholder: 'Start when requested by a user and complete the agent once.',
59
- },
28
+ { name: 'prompt', label: 'Trigger Prompt', type: 'string', required: false, placeholder: 'Start when requested by a user and complete the agent once.' },
60
29
  ],
61
30
  };
62
31
  export const SCHEDULE_TRIGGER_SPEC_0_0_1 = {
@@ -66,37 +35,18 @@ export const SCHEDULE_TRIGGER_SPEC_0_0_1 = {
66
35
  description: 'Run on a recurring schedule using a cron expression (e.g. daily at 9 AM, every Monday, monthly on the 1st).',
67
36
  type: 'schedule',
68
37
  fields: [
69
- {
70
- name: 'cron',
71
- label: 'Cron Expression',
72
- type: 'string',
73
- required: true,
74
- placeholder: '0 9 * * * (every day at 9 AM)',
75
- font: 'mono',
76
- },
77
- {
78
- name: 'description',
79
- label: 'Description',
80
- type: 'string',
81
- required: false,
82
- placeholder: "Description (e.g. 'Monthly sales report')",
83
- },
84
- {
85
- name: 'prompt',
86
- label: 'Trigger Prompt',
87
- type: 'string',
88
- required: false,
89
- placeholder: 'Run the scheduled agent and produce the configured deliverable.',
90
- },
38
+ { name: 'cron', label: 'Cron Expression', type: 'string', required: true, placeholder: '0 9 * * * (every day at 9 AM)', font: 'mono' },
39
+ { name: 'description', label: 'Description', type: 'string', required: false, placeholder: 'Description (e.g. \'Monthly sales report\')' },
40
+ { name: 'prompt', label: 'Trigger Prompt', type: 'string', required: false, placeholder: 'Run the scheduled agent and produce the configured deliverable.' },
91
41
  ],
92
42
  };
93
43
  // ============================================================================
94
44
  // Trigger Catalog
95
45
  // ============================================================================
96
46
  export const TRIGGER_CATALOG = {
97
- event: EVENT_TRIGGER_SPEC_0_0_1,
98
- once: ONCE_TRIGGER_SPEC_0_0_1,
99
- schedule: SCHEDULE_TRIGGER_SPEC_0_0_1,
47
+ 'event': EVENT_TRIGGER_SPEC_0_0_1,
48
+ 'once': ONCE_TRIGGER_SPEC_0_0_1,
49
+ 'schedule': SCHEDULE_TRIGGER_SPEC_0_0_1,
100
50
  };
101
51
  export function getTriggerSpecs() {
102
52
  return Object.values(TRIGGER_CATALOG);
@@ -27,6 +27,8 @@ export interface ToolSpec {
27
27
  enabled: boolean;
28
28
  /** Approval policy for this tool */
29
29
  approval: 'auto' | 'manual';
30
+ /** Approval timeout duration (e.g. 0h5m0s, 2d6h, 1mo2d3h4m5s) */
31
+ timeout?: string;
30
32
  /** Whether tool requires human approval before execution */
31
33
  requiresApproval?: boolean;
32
34
  /** Runtime binding metadata */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/agent-runtimes",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "workspaces": [
6
6
  ".",
@@ -192,7 +192,10 @@ from agent_runtimes.types import AgentSpec
192
192
 
193
193
  # Clean description for Python (single line)
194
194
  description = (
195
- spec["description"].replace("\n", " ").replace(" ", " ").strip()
195
+ spec["description"]
196
+ .replace("\n", " ")
197
+ .replace(" ", " ")
198
+ .strip()
196
199
  .replace('"', '\\"')
197
200
  )
198
201
 
@@ -100,7 +100,9 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
100
100
  for spec in specs:
101
101
  event_id = spec["id"]
102
102
  version = spec["version"]
103
- const_name = f"{event_id.upper().replace('-', '_')}_EVENT_SPEC{version_suffix(version)}"
103
+ const_name = (
104
+ f"{event_id.upper().replace('-', '_')}_EVENT_SPEC{version_suffix(version)}"
105
+ )
104
106
  desc = _esc_dq(spec.get("description", "").strip().replace("\n", " "))
105
107
  kind = spec.get("kind", event_id)
106
108
  fields = spec.get("fields", [])
@@ -135,7 +137,9 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
135
137
  for spec in specs:
136
138
  event_id = spec["id"]
137
139
  version = spec["version"]
138
- const_name = f"{event_id.upper().replace('-', '_')}_EVENT_SPEC{version_suffix(version)}"
140
+ const_name = (
141
+ f"{event_id.upper().replace('-', '_')}_EVENT_SPEC{version_suffix(version)}"
142
+ )
139
143
  lines.append(f' "{event_id}": {const_name},')
140
144
  lines.extend(
141
145
  [
@@ -201,7 +205,9 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
201
205
  for spec in specs:
202
206
  event_id = spec["id"]
203
207
  version = spec["version"]
204
- const_name = f"{event_id.upper().replace('-', '_')}_EVENT_SPEC{version_suffix(version)}"
208
+ const_name = (
209
+ f"{event_id.upper().replace('-', '_')}_EVENT_SPEC{version_suffix(version)}"
210
+ )
205
211
  desc = _esc(spec.get("description", "").strip().replace("\n", " "))
206
212
  kind = spec.get("kind", event_id)
207
213
  fields = spec.get("fields", [])
@@ -246,7 +252,9 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
246
252
  for spec in specs:
247
253
  event_id = spec["id"]
248
254
  version = spec["version"]
249
- const_name = f"{event_id.upper().replace('-', '_')}_EVENT_SPEC{version_suffix(version)}"
255
+ const_name = (
256
+ f"{event_id.upper().replace('-', '_')}_EVENT_SPEC{version_suffix(version)}"
257
+ )
250
258
  lines.append(f" '{event_id}': {const_name},")
251
259
  lines.extend(
252
260
  [
@@ -7,6 +7,7 @@ Generate Python and TypeScript code from YAML tool specifications.
7
7
  """
8
8
 
9
9
  import argparse
10
+ import re
10
11
  import sys
11
12
  from pathlib import Path
12
13
  from typing import Any
@@ -57,6 +58,19 @@ def _requires_approval(spec: dict[str, Any]) -> bool:
57
58
  return str(spec.get("approval", "auto")).lower() == "manual"
58
59
 
59
60
 
61
+ def _timeout_hms(spec: dict[str, Any]) -> str | None:
62
+ raw = spec.get("timeout")
63
+ if raw in (None, ""):
64
+ return None
65
+ value = str(raw).strip()
66
+ if not re.fullmatch(r"(?i)(?:\d+mo|\d+d|\d+h|\d+m|\d+s)+", value):
67
+ raise ValueError(
68
+ f"Tool '{spec.get('id', '<unknown>')}' has invalid timeout '{raw}'. "
69
+ "Expected duration format like '0h5m0s', '2d6h', or '1mo2d3h4m5s'."
70
+ )
71
+ return value
72
+
73
+
60
74
  def load_tool_specs(specs_dir: Path) -> list[dict[str, Any]]:
61
75
  specs: list[dict[str, Any]] = []
62
76
  for yaml_file in sorted(specs_dir.glob("*.yaml")):
@@ -99,8 +113,10 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
99
113
  )
100
114
  runtime = _require_runtime(spec)
101
115
  requires_approval = _requires_approval(spec)
116
+ timeout = _timeout_hms(spec)
102
117
  icon = f'"{spec.get("icon")}"' if spec.get("icon") else "None"
103
118
  emoji = f'"{spec.get("emoji")}"' if spec.get("emoji") else "None"
119
+ timeout_py = f'"{timeout}"' if timeout else "None"
104
120
 
105
121
  lines.extend(
106
122
  [
@@ -112,6 +128,7 @@ def generate_python_code(specs: list[dict[str, Any]]) -> str:
112
128
  f" tags={_fmt_list(spec.get('tags', []))},",
113
129
  f" enabled={spec.get('enabled', True)},",
114
130
  f' approval="{spec.get("approval", "auto")}",',
131
+ f" timeout={timeout_py},",
115
132
  f" requires_approval={requires_approval},",
116
133
  " runtime=ToolRuntimeSpec(",
117
134
  f' language="{runtime["language"]}",',
@@ -201,9 +218,11 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
201
218
  )
202
219
  runtime = _require_runtime(spec)
203
220
  requires_approval = _requires_approval(spec)
221
+ timeout = _timeout_hms(spec)
204
222
  tags_json = str(spec.get("tags", [])).replace("'", '"')
205
223
  icon = f"'{spec.get('icon')}'" if spec.get("icon") else "undefined"
206
224
  emoji = f"'{spec.get('emoji')}'" if spec.get("emoji") else "undefined"
225
+ timeout_ts = f"'{timeout}'" if timeout else "undefined"
207
226
 
208
227
  lines.extend(
209
228
  [
@@ -215,6 +234,7 @@ def generate_typescript_code(specs: list[dict[str, Any]]) -> str:
215
234
  f" tags: {tags_json},",
216
235
  f" enabled: {str(spec.get('enabled', True)).lower()},",
217
236
  f" approval: '{spec.get('approval', 'auto')}',",
237
+ f" timeout: {timeout_ts},",
218
238
  f" requiresApproval: {str(requires_approval).lower()},",
219
239
  " runtime: {",
220
240
  f" language: '{runtime['language']}',",
@@ -3,14 +3,9 @@
3
3
  * Distributed under the terms of the Modified BSD License.
4
4
  */
5
5
 
6
- /*
7
- * Copyright (c) 2021-2024 Datalayer, Inc.
8
- *
9
- * Datalayer License
10
- */
11
-
12
6
  @import url('~@primer/primitives/dist/css/base/size/size.css');
13
7
  @import url('~@primer/primitives/dist/css/base/typography/typography.css');
8
+ @import url('~@primer/primitives/dist/css/base/motion/motion.css');
14
9
  @import url('~@primer/primitives/dist/css/functional/size/border.css');
15
10
  @import url('~@primer/primitives/dist/css/functional/size/breakpoints.css');
16
11
  @import url('~@primer/primitives/dist/css/functional/size/size-coarse.css');