@happyvertical/smrt-agents 0.30.0
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.
- package/AGENTS.md +96 -0
- package/CLAUDE.md +1 -0
- package/LICENSE +7 -0
- package/README.md +139 -0
- package/dist/__smrt-register__.d.ts +2 -0
- package/dist/__smrt-register__.d.ts.map +1 -0
- package/dist/agent.d.ts +545 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/ai-config.d.ts +27 -0
- package/dist/ai-config.d.ts.map +1 -0
- package/dist/chunks/config-BYbOxt24.js +179 -0
- package/dist/chunks/config-BYbOxt24.js.map +1 -0
- package/dist/chunks/manifest-utils-DLXfTOq0.js +69 -0
- package/dist/chunks/manifest-utils-DLXfTOq0.js.map +1 -0
- package/dist/config.d.ts +117 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/identity.d.ts +19 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1477 -0
- package/dist/index.js.map +1 -0
- package/dist/interests.d.ts +291 -0
- package/dist/interests.d.ts.map +1 -0
- package/dist/manifest.json +2012 -0
- package/dist/playground.d.ts +2 -0
- package/dist/playground.d.ts.map +1 -0
- package/dist/playground.js +156 -0
- package/dist/playground.js.map +1 -0
- package/dist/schedule.d.ts +168 -0
- package/dist/schedule.d.ts.map +1 -0
- package/dist/server/action-types.d.ts +65 -0
- package/dist/server/action-types.d.ts.map +1 -0
- package/dist/server/action-types.js +2 -0
- package/dist/server/action-types.js.map +1 -0
- package/dist/server/api-routes.d.ts +57 -0
- package/dist/server/api-routes.d.ts.map +1 -0
- package/dist/server/config-loader.d.ts +17 -0
- package/dist/server/config-loader.d.ts.map +1 -0
- package/dist/server/index.d.ts +34 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/manifest-utils.d.ts +63 -0
- package/dist/server/manifest-utils.d.ts.map +1 -0
- package/dist/server/serialization.d.ts +58 -0
- package/dist/server/serialization.d.ts.map +1 -0
- package/dist/server.js +105 -0
- package/dist/server.js.map +1 -0
- package/dist/smrt-knowledge.json +983 -0
- package/dist/summary-article.d.ts +30 -0
- package/dist/summary-article.d.ts.map +1 -0
- package/dist/summary-article.js +2 -0
- package/dist/summary-article.js.map +1 -0
- package/dist/svelte/components/AgentDashboard.svelte +250 -0
- package/dist/svelte/components/AgentDashboard.svelte.d.ts +21 -0
- package/dist/svelte/components/AgentDashboard.svelte.d.ts.map +1 -0
- package/dist/svelte/components/AgentRunHistory.svelte +225 -0
- package/dist/svelte/components/AgentRunHistory.svelte.d.ts +16 -0
- package/dist/svelte/components/AgentRunHistory.svelte.d.ts.map +1 -0
- package/dist/svelte/components/AgentScheduleForm.svelte +381 -0
- package/dist/svelte/components/AgentScheduleForm.svelte.d.ts +19 -0
- package/dist/svelte/components/AgentScheduleForm.svelte.d.ts.map +1 -0
- package/dist/svelte/components/AgentScheduleList.svelte +370 -0
- package/dist/svelte/components/AgentScheduleList.svelte.d.ts +24 -0
- package/dist/svelte/components/AgentScheduleList.svelte.d.ts.map +1 -0
- package/dist/svelte/components/ScheduleStatusBadge.svelte +23 -0
- package/dist/svelte/components/ScheduleStatusBadge.svelte.d.ts +9 -0
- package/dist/svelte/components/ScheduleStatusBadge.svelte.d.ts.map +1 -0
- package/dist/svelte/i18n.d.ts +33 -0
- package/dist/svelte/i18n.d.ts.map +1 -0
- package/dist/svelte/i18n.js +37 -0
- package/dist/svelte/index.d.ts +23 -0
- package/dist/svelte/index.d.ts.map +1 -0
- package/dist/svelte/index.js +26 -0
- package/dist/svelte/playground.d.ts +196 -0
- package/dist/svelte/playground.d.ts.map +1 -0
- package/dist/svelte/playground.js +151 -0
- package/dist/svelte/types.d.ts +155 -0
- package/dist/svelte/types.d.ts.map +1 -0
- package/dist/svelte/types.js +116 -0
- package/dist/tenant-agent.d.ts +106 -0
- package/dist/tenant-agent.d.ts.map +1 -0
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/ui.d.ts +298 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +133 -0
- package/dist/ui.js.map +1 -0
- package/dist/vite-plugin.d.ts +61 -0
- package/dist/vite-plugin.d.ts.map +1 -0
- package/dist/vite-plugin.js +173 -0
- package/dist/vite-plugin.js.map +1 -0
- package/package.json +104 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playground.d.ts","sourceRoot":"","sources":["../src/playground.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { AGENTS_MODULE_META } from "./ui.js";
|
|
2
|
+
const noop = () => {
|
|
3
|
+
};
|
|
4
|
+
const sampleSchedules = [
|
|
5
|
+
{
|
|
6
|
+
id: "schedule-digest",
|
|
7
|
+
agentType: "DailyDigestAgent",
|
|
8
|
+
agentId: "digest-western",
|
|
9
|
+
agentConfig: { region: "western-canada" },
|
|
10
|
+
cron: "0 7 * * *",
|
|
11
|
+
timezone: "America/Edmonton",
|
|
12
|
+
enabled: true,
|
|
13
|
+
status: "active",
|
|
14
|
+
lastRun: "2026-03-21T13:00:00.000Z",
|
|
15
|
+
nextRun: "2026-03-22T13:00:00.000Z",
|
|
16
|
+
lastStatus: "success",
|
|
17
|
+
lastError: null,
|
|
18
|
+
runCount: 184,
|
|
19
|
+
successCount: 179,
|
|
20
|
+
failureCount: 5,
|
|
21
|
+
maxConcurrent: 1,
|
|
22
|
+
runningCount: 0,
|
|
23
|
+
timeout: 18e5,
|
|
24
|
+
method: "run",
|
|
25
|
+
methodArgs: {},
|
|
26
|
+
createdAt: "2026-01-04T17:00:00.000Z",
|
|
27
|
+
updatedAt: "2026-03-21T13:02:00.000Z"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "schedule-governance",
|
|
31
|
+
agentType: "GovernanceWatchAgent",
|
|
32
|
+
agentId: null,
|
|
33
|
+
agentConfig: { profileKey: "publication" },
|
|
34
|
+
cron: "*/30 * * * *",
|
|
35
|
+
timezone: "UTC",
|
|
36
|
+
enabled: true,
|
|
37
|
+
status: "error",
|
|
38
|
+
lastRun: "2026-03-21T16:00:00.000Z",
|
|
39
|
+
nextRun: "2026-03-21T16:30:00.000Z",
|
|
40
|
+
lastStatus: "failed",
|
|
41
|
+
lastError: "Readiness sync failed for one assignment.",
|
|
42
|
+
runCount: 928,
|
|
43
|
+
successCount: 901,
|
|
44
|
+
failureCount: 27,
|
|
45
|
+
maxConcurrent: 2,
|
|
46
|
+
runningCount: 1,
|
|
47
|
+
timeout: 9e5,
|
|
48
|
+
method: "reconcile",
|
|
49
|
+
methodArgs: { backfill: false },
|
|
50
|
+
createdAt: "2026-02-09T10:10:00.000Z",
|
|
51
|
+
updatedAt: "2026-03-21T16:01:11.000Z"
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
const sampleHistory = [
|
|
55
|
+
{
|
|
56
|
+
id: "run-1",
|
|
57
|
+
scheduleId: "schedule-governance",
|
|
58
|
+
agentType: "GovernanceWatchAgent",
|
|
59
|
+
status: "failed",
|
|
60
|
+
startedAt: "2026-03-21T16:00:00.000Z",
|
|
61
|
+
completedAt: "2026-03-21T16:01:11.000Z",
|
|
62
|
+
duration: 71e3,
|
|
63
|
+
error: "One assignment was missing readiness metadata."
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: "run-2",
|
|
67
|
+
scheduleId: "schedule-digest",
|
|
68
|
+
agentType: "DailyDigestAgent",
|
|
69
|
+
status: "success",
|
|
70
|
+
startedAt: "2026-03-21T13:00:00.000Z",
|
|
71
|
+
completedAt: "2026-03-21T13:00:18.000Z",
|
|
72
|
+
duration: 18e3,
|
|
73
|
+
error: null
|
|
74
|
+
}
|
|
75
|
+
];
|
|
76
|
+
const loadAgentDashboard = () => import("./svelte/components/AgentDashboard.svelte");
|
|
77
|
+
const loadAgentRunHistory = () => import("./svelte/components/AgentRunHistory.svelte");
|
|
78
|
+
const loadAgentScheduleForm = () => import("./svelte/components/AgentScheduleForm.svelte");
|
|
79
|
+
const playground = {
|
|
80
|
+
packageName: "@happyvertical/smrt-agents",
|
|
81
|
+
displayName: AGENTS_MODULE_META.displayName,
|
|
82
|
+
description: AGENTS_MODULE_META.description,
|
|
83
|
+
moduleMeta: AGENTS_MODULE_META,
|
|
84
|
+
entries: [
|
|
85
|
+
{
|
|
86
|
+
id: "agent-dashboard",
|
|
87
|
+
title: "Agent Dashboard",
|
|
88
|
+
description: "Overview of active schedules, run health, and recent execution history.",
|
|
89
|
+
loadComponent: loadAgentDashboard,
|
|
90
|
+
order: 1,
|
|
91
|
+
props: {
|
|
92
|
+
schedules: sampleSchedules,
|
|
93
|
+
recentHistory: sampleHistory,
|
|
94
|
+
onScheduleClick: noop,
|
|
95
|
+
onEnable: noop,
|
|
96
|
+
onDisable: noop,
|
|
97
|
+
onDelete: noop,
|
|
98
|
+
onRunNow: noop,
|
|
99
|
+
onCreateSchedule: noop,
|
|
100
|
+
onHistoryEntryClick: noop
|
|
101
|
+
},
|
|
102
|
+
modes: {
|
|
103
|
+
mock: {
|
|
104
|
+
label: "Mock"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: "agent-schedule-form",
|
|
110
|
+
title: "Agent Schedule Form",
|
|
111
|
+
description: "Configuration form for a scheduled agent run, with presets and execution controls.",
|
|
112
|
+
loadComponent: loadAgentScheduleForm,
|
|
113
|
+
order: 2,
|
|
114
|
+
props: {
|
|
115
|
+
initialData: {
|
|
116
|
+
agentType: "GovernanceWatchAgent",
|
|
117
|
+
cron: "*/30 * * * *",
|
|
118
|
+
timezone: "UTC",
|
|
119
|
+
enabled: true,
|
|
120
|
+
maxConcurrent: 2,
|
|
121
|
+
timeout: 9e5,
|
|
122
|
+
method: "reconcile"
|
|
123
|
+
},
|
|
124
|
+
agentTypes: ["DailyDigestAgent", "GovernanceWatchAgent", "ExportAgent"],
|
|
125
|
+
onSubmit: noop,
|
|
126
|
+
onCancel: noop,
|
|
127
|
+
editMode: true
|
|
128
|
+
},
|
|
129
|
+
modes: {
|
|
130
|
+
mock: {
|
|
131
|
+
label: "Mock"
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
id: "agent-run-history",
|
|
137
|
+
title: "Agent Run History",
|
|
138
|
+
description: "Execution history table for recent schedule runs and failures.",
|
|
139
|
+
loadComponent: loadAgentRunHistory,
|
|
140
|
+
order: 3,
|
|
141
|
+
props: {
|
|
142
|
+
history: sampleHistory,
|
|
143
|
+
onEntryClick: noop
|
|
144
|
+
},
|
|
145
|
+
modes: {
|
|
146
|
+
mock: {
|
|
147
|
+
label: "Mock"
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
};
|
|
153
|
+
export {
|
|
154
|
+
playground as default
|
|
155
|
+
};
|
|
156
|
+
//# sourceMappingURL=playground.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playground.js","sources":["../src/svelte/playground.ts"],"sourcesContent":["import { AGENTS_MODULE_META } from '../ui.js';\n\nconst noop = () => {};\n\nconst sampleSchedules = [\n {\n id: 'schedule-digest',\n agentType: 'DailyDigestAgent',\n agentId: 'digest-western',\n agentConfig: { region: 'western-canada' },\n cron: '0 7 * * *',\n timezone: 'America/Edmonton',\n enabled: true,\n status: 'active',\n lastRun: '2026-03-21T13:00:00.000Z',\n nextRun: '2026-03-22T13:00:00.000Z',\n lastStatus: 'success',\n lastError: null,\n runCount: 184,\n successCount: 179,\n failureCount: 5,\n maxConcurrent: 1,\n runningCount: 0,\n timeout: 1800000,\n method: 'run',\n methodArgs: {},\n createdAt: '2026-01-04T17:00:00.000Z',\n updatedAt: '2026-03-21T13:02:00.000Z',\n },\n {\n id: 'schedule-governance',\n agentType: 'GovernanceWatchAgent',\n agentId: null,\n agentConfig: { profileKey: 'publication' },\n cron: '*/30 * * * *',\n timezone: 'UTC',\n enabled: true,\n status: 'error',\n lastRun: '2026-03-21T16:00:00.000Z',\n nextRun: '2026-03-21T16:30:00.000Z',\n lastStatus: 'failed',\n lastError: 'Readiness sync failed for one assignment.',\n runCount: 928,\n successCount: 901,\n failureCount: 27,\n maxConcurrent: 2,\n runningCount: 1,\n timeout: 900000,\n method: 'reconcile',\n methodArgs: { backfill: false },\n createdAt: '2026-02-09T10:10:00.000Z',\n updatedAt: '2026-03-21T16:01:11.000Z',\n },\n];\n\nconst sampleHistory = [\n {\n id: 'run-1',\n scheduleId: 'schedule-governance',\n agentType: 'GovernanceWatchAgent',\n status: 'failed',\n startedAt: '2026-03-21T16:00:00.000Z',\n completedAt: '2026-03-21T16:01:11.000Z',\n duration: 71000,\n error: 'One assignment was missing readiness metadata.',\n },\n {\n id: 'run-2',\n scheduleId: 'schedule-digest',\n agentType: 'DailyDigestAgent',\n status: 'success',\n startedAt: '2026-03-21T13:00:00.000Z',\n completedAt: '2026-03-21T13:00:18.000Z',\n duration: 18000,\n error: null,\n },\n];\n\nconst loadAgentDashboard = () => import('./components/AgentDashboard.svelte');\nconst loadAgentRunHistory = () => import('./components/AgentRunHistory.svelte');\nconst loadAgentScheduleForm = () =>\n import('./components/AgentScheduleForm.svelte');\n\nexport default {\n packageName: '@happyvertical/smrt-agents',\n displayName: AGENTS_MODULE_META.displayName,\n description: AGENTS_MODULE_META.description,\n moduleMeta: AGENTS_MODULE_META,\n entries: [\n {\n id: 'agent-dashboard',\n title: 'Agent Dashboard',\n description:\n 'Overview of active schedules, run health, and recent execution history.',\n loadComponent: loadAgentDashboard,\n order: 1,\n props: {\n schedules: sampleSchedules,\n recentHistory: sampleHistory,\n onScheduleClick: noop,\n onEnable: noop,\n onDisable: noop,\n onDelete: noop,\n onRunNow: noop,\n onCreateSchedule: noop,\n onHistoryEntryClick: noop,\n },\n modes: {\n mock: {\n label: 'Mock',\n },\n },\n },\n {\n id: 'agent-schedule-form',\n title: 'Agent Schedule Form',\n description:\n 'Configuration form for a scheduled agent run, with presets and execution controls.',\n loadComponent: loadAgentScheduleForm,\n order: 2,\n props: {\n initialData: {\n agentType: 'GovernanceWatchAgent',\n cron: '*/30 * * * *',\n timezone: 'UTC',\n enabled: true,\n maxConcurrent: 2,\n timeout: 900000,\n method: 'reconcile',\n },\n agentTypes: ['DailyDigestAgent', 'GovernanceWatchAgent', 'ExportAgent'],\n onSubmit: noop,\n onCancel: noop,\n editMode: true,\n },\n modes: {\n mock: {\n label: 'Mock',\n },\n },\n },\n {\n id: 'agent-run-history',\n title: 'Agent Run History',\n description:\n 'Execution history table for recent schedule runs and failures.',\n loadComponent: loadAgentRunHistory,\n order: 3,\n props: {\n history: sampleHistory,\n onEntryClick: noop,\n },\n modes: {\n mock: {\n label: 'Mock',\n },\n },\n },\n ],\n};\n"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { SmrtCollection, SmrtObject } from '@happyvertical/smrt-core';
|
|
2
|
+
/**
|
|
3
|
+
* Status of a scheduled agent
|
|
4
|
+
*/
|
|
5
|
+
export type ScheduleStatus = 'active' | 'paused' | 'disabled' | 'error';
|
|
6
|
+
/**
|
|
7
|
+
* AgentSchedule model for cron-based agent scheduling
|
|
8
|
+
*
|
|
9
|
+
* This extends SmrtObject to store schedule metadata in the SMRT database.
|
|
10
|
+
* Schedules are processed by the TaskRunner which creates jobs at scheduled times.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const schedule = new AgentSchedule({
|
|
15
|
+
* agentType: 'Praeco',
|
|
16
|
+
* agentId: 'praeco-main',
|
|
17
|
+
* cron: '0 2 * * *', // Run at 2 AM daily
|
|
18
|
+
* enabled: true,
|
|
19
|
+
* });
|
|
20
|
+
* await schedule.initialize();
|
|
21
|
+
* await schedule.save();
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare class AgentSchedule extends SmrtObject {
|
|
25
|
+
/**
|
|
26
|
+
* Tenant ID for multi-tenant isolation
|
|
27
|
+
* Nullable to support both tenant-scoped and global schedules
|
|
28
|
+
*/
|
|
29
|
+
tenantId: string | null;
|
|
30
|
+
/** Canonical agent type to run (qualified name when available) */
|
|
31
|
+
agentType: string;
|
|
32
|
+
/** Optional agent instance ID (for running specific instances) */
|
|
33
|
+
agentId: string | null;
|
|
34
|
+
/**
|
|
35
|
+
* Agent configuration to pass when running.
|
|
36
|
+
*
|
|
37
|
+
* Sensitive (#1540): may carry API keys/credentials, so it is excluded from
|
|
38
|
+
* generated API/MCP responses and rejected as a `where` filter key.
|
|
39
|
+
*/
|
|
40
|
+
agentConfig: Record<string, unknown>;
|
|
41
|
+
/** Cron expression (e.g., '0 2 * * *' for 2 AM daily) */
|
|
42
|
+
cron: string;
|
|
43
|
+
/** Timezone for cron interpretation (default: UTC) */
|
|
44
|
+
timezone: string;
|
|
45
|
+
/** Whether the schedule is enabled */
|
|
46
|
+
enabled: boolean;
|
|
47
|
+
/** Current schedule status */
|
|
48
|
+
status: ScheduleStatus;
|
|
49
|
+
/** Last time the agent was run */
|
|
50
|
+
lastRun: Date | null;
|
|
51
|
+
/** Next scheduled run time */
|
|
52
|
+
nextRun: Date | null;
|
|
53
|
+
/** Status of the last run */
|
|
54
|
+
lastStatus: 'success' | 'failed' | null;
|
|
55
|
+
/** Error message from last failed run */
|
|
56
|
+
lastError: string | null;
|
|
57
|
+
/** Total number of runs */
|
|
58
|
+
runCount: number;
|
|
59
|
+
/** Total number of successful runs */
|
|
60
|
+
successCount: number;
|
|
61
|
+
/** Total number of failed runs */
|
|
62
|
+
failureCount: number;
|
|
63
|
+
/** Maximum concurrent runs (prevent overlapping) */
|
|
64
|
+
maxConcurrent: number;
|
|
65
|
+
/** Current number of running instances */
|
|
66
|
+
runningCount: number;
|
|
67
|
+
/** Timeout for agent execution in milliseconds (default: 1 hour) */
|
|
68
|
+
timeout: number;
|
|
69
|
+
/** Method to call on the agent (default: 'run') */
|
|
70
|
+
method: string;
|
|
71
|
+
/** Arguments to pass to the method */
|
|
72
|
+
methodArgs: Record<string, unknown>;
|
|
73
|
+
/**
|
|
74
|
+
* Enable the schedule
|
|
75
|
+
*/
|
|
76
|
+
enable(): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Disable the schedule
|
|
79
|
+
*/
|
|
80
|
+
disable(): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Pause the schedule temporarily
|
|
83
|
+
*/
|
|
84
|
+
pause(): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Resume a paused schedule
|
|
87
|
+
*/
|
|
88
|
+
resume(): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Record a successful run
|
|
91
|
+
*/
|
|
92
|
+
recordSuccess(): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Record a failed run
|
|
95
|
+
*/
|
|
96
|
+
recordFailure(error: string): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Check if the schedule is due to run
|
|
99
|
+
*/
|
|
100
|
+
isDue(): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Calculate the next run time based on cron expression
|
|
103
|
+
*/
|
|
104
|
+
calculateNextRun(): void;
|
|
105
|
+
/**
|
|
106
|
+
* Get a human-readable description of the schedule
|
|
107
|
+
*/
|
|
108
|
+
getDescription(): string;
|
|
109
|
+
/**
|
|
110
|
+
* Lifecycle hook - calculate next run on save
|
|
111
|
+
*/
|
|
112
|
+
beforeSave(): Promise<void>;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Collection for managing AgentSchedule objects
|
|
116
|
+
*/
|
|
117
|
+
export declare class AgentScheduleCollection extends SmrtCollection<AgentSchedule> {
|
|
118
|
+
static readonly _itemClass: typeof AgentSchedule;
|
|
119
|
+
/**
|
|
120
|
+
* Find all schedules for a specific tenant
|
|
121
|
+
* @param tenantId - Tenant ID to filter by
|
|
122
|
+
* @returns Array of AgentSchedule objects for the tenant
|
|
123
|
+
*/
|
|
124
|
+
findByTenant(tenantId: string): Promise<AgentSchedule[]>;
|
|
125
|
+
/**
|
|
126
|
+
* Find all global schedules (not associated with any tenant)
|
|
127
|
+
* @returns Array of global AgentSchedule objects
|
|
128
|
+
*/
|
|
129
|
+
findGlobal(): Promise<AgentSchedule[]>;
|
|
130
|
+
/**
|
|
131
|
+
* Find schedules for a tenant including global schedules
|
|
132
|
+
* @param tenantId - Tenant ID to include
|
|
133
|
+
* @returns Array of AgentSchedule objects for the tenant and global schedules
|
|
134
|
+
*/
|
|
135
|
+
findWithGlobals(tenantId: string): Promise<AgentSchedule[]>;
|
|
136
|
+
/**
|
|
137
|
+
* List schedules by status
|
|
138
|
+
*/
|
|
139
|
+
listByStatus(status: ScheduleStatus | ScheduleStatus[], options?: {
|
|
140
|
+
limit?: number;
|
|
141
|
+
}): Promise<AgentSchedule[]>;
|
|
142
|
+
/**
|
|
143
|
+
* List schedules that are due to run
|
|
144
|
+
*/
|
|
145
|
+
listDue(options?: {
|
|
146
|
+
limit?: number;
|
|
147
|
+
}): Promise<AgentSchedule[]>;
|
|
148
|
+
/**
|
|
149
|
+
* List schedules for a specific agent type
|
|
150
|
+
*/
|
|
151
|
+
listByAgentType(agentType: string, options?: {
|
|
152
|
+
limit?: number;
|
|
153
|
+
includeDisabled?: boolean;
|
|
154
|
+
}): Promise<AgentSchedule[]>;
|
|
155
|
+
/**
|
|
156
|
+
* Get schedule statistics
|
|
157
|
+
*/
|
|
158
|
+
stats(): Promise<{
|
|
159
|
+
total: number;
|
|
160
|
+
active: number;
|
|
161
|
+
paused: number;
|
|
162
|
+
disabled: number;
|
|
163
|
+
error: number;
|
|
164
|
+
dueNow: number;
|
|
165
|
+
}>;
|
|
166
|
+
}
|
|
167
|
+
export default AgentSchedule;
|
|
168
|
+
//# sourceMappingURL=schedule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../src/schedule.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Action Handler Types
|
|
3
|
+
*
|
|
4
|
+
* Types for agent-specific action handlers that packages export via
|
|
5
|
+
* their `/actions` subpath. The dashboard dynamically imports these
|
|
6
|
+
* handlers and dispatches requests to them.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // In an agent package (e.g., @happyvertical/histrio/actions)
|
|
11
|
+
* import type { AgentActionMap, AgentActionContext } from '@happyvertical/smrt-agents/server';
|
|
12
|
+
*
|
|
13
|
+
* const referenceImage: AgentActionHandler = async (ctx) => {
|
|
14
|
+
* const formData = await ctx.request.formData();
|
|
15
|
+
* // ... process the upload
|
|
16
|
+
* return Response.json({ data: result });
|
|
17
|
+
* };
|
|
18
|
+
*
|
|
19
|
+
* export const actions: AgentActionMap = {
|
|
20
|
+
* 'performers/reference-image': referenceImage,
|
|
21
|
+
* };
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @module @happyvertical/smrt-agents/server
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Context passed to an agent action handler.
|
|
28
|
+
*
|
|
29
|
+
* Handlers receive the raw Request and return a standard Response,
|
|
30
|
+
* so they can handle any content type (JSON, multipart, streaming)
|
|
31
|
+
* without the dashboard needing to know.
|
|
32
|
+
*/
|
|
33
|
+
export interface AgentActionContext {
|
|
34
|
+
/** Raw HTTP request (may be multipart, JSON, etc.) */
|
|
35
|
+
request: Request;
|
|
36
|
+
/** Resource path segment (e.g., 'performers') */
|
|
37
|
+
resourcePath: string;
|
|
38
|
+
/** Resource ID from URL */
|
|
39
|
+
id: string;
|
|
40
|
+
/** Action name from URL (e.g., 'reference-image') */
|
|
41
|
+
action: string;
|
|
42
|
+
/** Database configuration */
|
|
43
|
+
db: {
|
|
44
|
+
type: string;
|
|
45
|
+
url: string;
|
|
46
|
+
};
|
|
47
|
+
/** Current tenant ID */
|
|
48
|
+
tenantId: string;
|
|
49
|
+
/** Authenticated user ID */
|
|
50
|
+
userId?: string;
|
|
51
|
+
/** Agent instance UUID (from URL path) */
|
|
52
|
+
agentId: string;
|
|
53
|
+
/** Lazy-loaded service config from agent_configs table (slotId='services'). Cached per request. */
|
|
54
|
+
getServiceConfig: () => Promise<Record<string, unknown>>;
|
|
55
|
+
/** Retrieve a per-tenant encrypted secret by name */
|
|
56
|
+
getSecret: (name: string) => Promise<string | null>;
|
|
57
|
+
}
|
|
58
|
+
/** A single action handler function */
|
|
59
|
+
export type AgentActionHandler = (ctx: AgentActionContext) => Promise<Response>;
|
|
60
|
+
/**
|
|
61
|
+
* Map of action keys to handlers.
|
|
62
|
+
* Keys use the format '{resourcePath}/{action}' (e.g., 'performers/reference-image').
|
|
63
|
+
*/
|
|
64
|
+
export type AgentActionMap = Record<string, AgentActionHandler>;
|
|
65
|
+
//# sourceMappingURL=action-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-types.d.ts","sourceRoot":"","sources":["../../src/server/action-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,sDAAsD;IACtD,OAAO,EAAE,OAAO,CAAC;IACjB,iDAAiD;IACjD,YAAY,EAAE,MAAM,CAAC;IACrB,2BAA2B;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,qDAAqD;IACrD,MAAM,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAClC,wBAAwB;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,mGAAmG;IACnG,gBAAgB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACzD,qDAAqD;IACrD,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACrD;AAED,uCAAuC;AACvC,MAAM,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,kBAAkB,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEhF;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { PackageManifest } from './manifest-utils.js';
|
|
2
|
+
/**
|
|
3
|
+
* Info about a single API route (one SmrtObject with api.include)
|
|
4
|
+
*/
|
|
5
|
+
export interface AgentAPIRouteInfo {
|
|
6
|
+
/** SmrtObject class name (e.g., 'Performer') */
|
|
7
|
+
className: string;
|
|
8
|
+
/** Allowed CRUD actions (e.g., ['list', 'get', 'create', 'update', 'delete']) */
|
|
9
|
+
allowedActions: string[];
|
|
10
|
+
/** Package that owns this resource */
|
|
11
|
+
packageName?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Result of resolving a URL path against the route map
|
|
15
|
+
*/
|
|
16
|
+
export interface ResolvedAPIRoute {
|
|
17
|
+
/** The matched route info */
|
|
18
|
+
route: AgentAPIRouteInfo;
|
|
19
|
+
/** Resource ID if path includes one (e.g., 'performers/abc-123') */
|
|
20
|
+
id?: string;
|
|
21
|
+
/** Custom action name if path includes one (e.g., 'performers/abc-123/generate-image') */
|
|
22
|
+
action?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Build a route map from loaded package manifests.
|
|
26
|
+
*
|
|
27
|
+
* Iterates all objects in each manifest, and for any object with a
|
|
28
|
+
* `decoratorConfig.api.include` array, registers a route. The route
|
|
29
|
+
* path is derived from `decoratorConfig.api.path` if set, otherwise
|
|
30
|
+
* from the table name with underscores converted to hyphens.
|
|
31
|
+
*
|
|
32
|
+
* @param manifests - Array of parsed package manifest JSON objects
|
|
33
|
+
* @returns Map of resource path -> route info
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const manifests = [histrioManifest, praecoManifest];
|
|
38
|
+
* const routes = buildRouteMap(manifests);
|
|
39
|
+
* // routes.get('performers') => { className: 'Performer', allowedActions: ['list', 'get', 'create', 'update', 'delete'] }
|
|
40
|
+
* // routes.get('video-contents') => { className: 'VideoShot', allowedActions: ['list', 'get', 'create', 'update'] }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function buildRouteMap(manifests: PackageManifest[]): Map<string, AgentAPIRouteInfo>;
|
|
44
|
+
/**
|
|
45
|
+
* Resolve a URL resource path against a route map.
|
|
46
|
+
*
|
|
47
|
+
* Handles three URL patterns:
|
|
48
|
+
* - `performers` → list/create (no id)
|
|
49
|
+
* - `performers/abc-123` → get/update/delete (with id)
|
|
50
|
+
* - `performers/abc-123/generate-image` → custom action
|
|
51
|
+
*
|
|
52
|
+
* @param urlPath - The resource portion of the URL (after `/api/agents/{agentId}/`)
|
|
53
|
+
* @param routes - Route map from {@link buildRouteMap}
|
|
54
|
+
* @returns Resolved route with optional id/action, or null if no match
|
|
55
|
+
*/
|
|
56
|
+
export declare function resolveAPIRoute(urlPath: string, routes: Map<string, AgentAPIRouteInfo>): ResolvedAPIRoute | null;
|
|
57
|
+
//# sourceMappingURL=api-routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-routes.d.ts","sourceRoot":"","sources":["../../src/server/api-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,iFAAiF;IACjF,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,6BAA6B;IAC7B,KAAK,EAAE,iBAAiB,CAAC;IACzB,oEAAoE;IACpE,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,0FAA0F;IAC1F,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAC3B,SAAS,EAAE,eAAe,EAAE,GAC3B,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAgChC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,GACrC,gBAAgB,GAAG,IAAI,CA6BzB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SmrtClassOptions } from '@happyvertical/smrt-core';
|
|
2
|
+
/**
|
|
3
|
+
* Load slot configs for multiple agents from the agent_configs table.
|
|
4
|
+
*
|
|
5
|
+
* Returns a nested map: agentId -> slotId -> configData.
|
|
6
|
+
* Agent-specific tables (e.g., praeco_sources, praeco_reports)
|
|
7
|
+
* are NOT loaded here — those stay in the host application.
|
|
8
|
+
*
|
|
9
|
+
* @param agents - Array of agent identifiers (id + agentClass)
|
|
10
|
+
* @param dbOptions - Database options for SmrtCollection.create()
|
|
11
|
+
* @returns Map of agentId -> slotId -> config data
|
|
12
|
+
*/
|
|
13
|
+
export declare function loadSlotConfigs(agents: Array<{
|
|
14
|
+
id: string;
|
|
15
|
+
agentClass: string;
|
|
16
|
+
}>, dbOptions: SmrtClassOptions): Promise<Record<string, Record<string, unknown>>>;
|
|
17
|
+
//# sourceMappingURL=config-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-loader.d.ts","sourceRoot":"","sources":["../../src/server/config-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGjE;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,EACjD,SAAS,EAAE,gBAAgB,GAC1B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CA6BlD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side utilities for SMRT agents
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions for server-side agent operations:
|
|
5
|
+
* - Manifest loading and registration (replacing manual per-package imports)
|
|
6
|
+
* - Agent serialization for client transport
|
|
7
|
+
* - Config loading from the database
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import {
|
|
12
|
+
* loadManifestsFromConfig,
|
|
13
|
+
* serializeResolvedAgent,
|
|
14
|
+
* loadSlotConfigs,
|
|
15
|
+
* } from '@happyvertical/smrt-agents/server';
|
|
16
|
+
*
|
|
17
|
+
* // One-call manifest setup (replaces manual per-package registration)
|
|
18
|
+
* loadManifestsFromConfig();
|
|
19
|
+
*
|
|
20
|
+
* // Serialize resolved agents for the UI
|
|
21
|
+
* const serialized = resolved.map(serializeResolvedAgent);
|
|
22
|
+
*
|
|
23
|
+
* // Load slot configs from database
|
|
24
|
+
* const configs = await loadSlotConfigs(agents, { db: dbConfig });
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @module @happyvertical/smrt-agents/server
|
|
28
|
+
*/
|
|
29
|
+
export type { AgentActionContext, AgentActionHandler, AgentActionMap, } from './action-types.js';
|
|
30
|
+
export { type AgentAPIRouteInfo, buildRouteMap, type ResolvedAPIRoute, resolveAPIRoute, } from './api-routes.js';
|
|
31
|
+
export { loadSlotConfigs } from './config-loader.js';
|
|
32
|
+
export { extractAgentManifest, extractAgentPackagesFromConfig, loadManifestsFromConfig, loadManifestsFromPackages, type PackageManifest, } from './manifest-utils.js';
|
|
33
|
+
export { type SerializedAgent, serializeResolvedAgent, } from './serialization.js';
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,GACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,iBAAiB,EACtB,aAAa,EACb,KAAK,gBAAgB,EACrB,eAAe,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EACL,oBAAoB,EACpB,8BAA8B,EAC9B,uBAAuB,EACvB,yBAAyB,EACzB,KAAK,eAAe,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,KAAK,eAAe,EACpB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { AgentManifestInfo } from '../ui.js';
|
|
2
|
+
/**
|
|
3
|
+
* Shape of a package manifest's `objects` entry
|
|
4
|
+
*/
|
|
5
|
+
interface ManifestObject {
|
|
6
|
+
className: string;
|
|
7
|
+
agent?: AgentManifestInfo;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Shape of a package manifest JSON file
|
|
12
|
+
*/
|
|
13
|
+
export interface PackageManifest {
|
|
14
|
+
objects: Record<string, ManifestObject>;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Extract the AgentManifestInfo from a package manifest by class name.
|
|
19
|
+
*
|
|
20
|
+
* Iterates `manifest.objects` looking for the entry whose `className` matches
|
|
21
|
+
* and has an `agent` metadata block.
|
|
22
|
+
*
|
|
23
|
+
* @param manifest - Parsed manifest JSON from a package
|
|
24
|
+
* @param agentClass - Agent class name to search for (e.g., 'Praeco')
|
|
25
|
+
* @returns The agent manifest info, or null if not found
|
|
26
|
+
*/
|
|
27
|
+
export declare function extractAgentManifest(manifest: PackageManifest, agentClass: string): AgentManifestInfo | null;
|
|
28
|
+
/**
|
|
29
|
+
* Load and register agent manifests from a list of package names.
|
|
30
|
+
*
|
|
31
|
+
* For each package, resolves its `<package>/manifest` export via `createRequire`,
|
|
32
|
+
* reads the manifest JSON, extracts the agent class and metadata, and registers
|
|
33
|
+
* with `AgentUIRegistry`.
|
|
34
|
+
*
|
|
35
|
+
* @param packages - Array of package names (e.g., ['@happyvertical/praeco'])
|
|
36
|
+
* @param projectRoot - Absolute path to the project root (for require resolution)
|
|
37
|
+
* @returns Map of agentClass -> AgentManifestInfo for successfully loaded agents
|
|
38
|
+
*/
|
|
39
|
+
export declare function loadManifestsFromPackages(packages: string[], projectRoot: string): Map<string, AgentManifestInfo>;
|
|
40
|
+
/**
|
|
41
|
+
* Extract agent package names from a smrt.config.js file.
|
|
42
|
+
*
|
|
43
|
+
* Reads the file, finds the `agents: [...]` array, strips comments,
|
|
44
|
+
* and extracts quoted package names. Same logic as the Vite plugin.
|
|
45
|
+
*
|
|
46
|
+
* @param configPath - Absolute path to smrt.config.js
|
|
47
|
+
* @returns Array of package name strings
|
|
48
|
+
*/
|
|
49
|
+
export declare function extractAgentPackagesFromConfig(configPath: string): string[];
|
|
50
|
+
/**
|
|
51
|
+
* Load and register agent manifests by reading smrt.config.js.
|
|
52
|
+
*
|
|
53
|
+
* One-call setup: reads the config file to discover agent packages,
|
|
54
|
+
* then loads and registers manifests for each. Idempotent — safe to
|
|
55
|
+
* call from multiple server load functions.
|
|
56
|
+
*
|
|
57
|
+
* @param configPath - Path to smrt.config.js (default: `<projectRoot>/smrt.config.js`)
|
|
58
|
+
* @param projectRoot - Project root for require resolution (default: `process.cwd()`)
|
|
59
|
+
* @returns Map of agentClass -> AgentManifestInfo
|
|
60
|
+
*/
|
|
61
|
+
export declare function loadManifestsFromConfig(configPath?: string, projectRoot?: string): Map<string, AgentManifestInfo>;
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=manifest-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-utils.d.ts","sourceRoot":"","sources":["../../src/server/manifest-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,EAAE,KAAK,iBAAiB,EAAmB,MAAM,UAAU,CAAC;AAEnE;;GAEG;AACH,UAAU,cAAc;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACxC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,eAAe,EACzB,UAAU,EAAE,MAAM,GACjB,iBAAiB,GAAG,IAAI,CAO1B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAAE,EAClB,WAAW,EAAE,MAAM,GAClB,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CA2BhC;AAED;;;;;;;;GAQG;AACH,wBAAgB,8BAA8B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAQ3E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,CAAC,EAAE,MAAM,EACnB,WAAW,CAAC,EAAE,MAAM,GACnB,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAoBhC"}
|