@lssm/example.agent-console 0.0.0-canary-20251215234340 → 0.0.0-canary-20251216024228

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 (100) hide show
  1. package/.turbo/turbo-build.log +38 -28
  2. package/CHANGELOG.md +6 -6
  3. package/dist/agent/agent.contracts.js +1 -0
  4. package/dist/{entities/agent.js → agent/agent.entity.js} +1 -1
  5. package/dist/agent/agent.enum.js +1 -0
  6. package/dist/agent/agent.event.js +1 -0
  7. package/dist/agent/agent.handler.js +1 -0
  8. package/dist/agent/agent.presentation.js +1 -0
  9. package/dist/agent/agent.schema.js +1 -0
  10. package/dist/agent/index.js +1 -0
  11. package/dist/handlers/index.js +1 -1
  12. package/dist/index.js +1 -1
  13. package/dist/presentations/index.js +1 -1
  14. package/dist/run/index.js +1 -0
  15. package/dist/run/run.contracts.js +1 -0
  16. package/dist/run/run.entity.js +1 -0
  17. package/dist/run/run.enum.js +1 -0
  18. package/dist/run/run.event.js +1 -0
  19. package/dist/run/run.handler.js +1 -0
  20. package/dist/run/run.presentation.js +1 -0
  21. package/dist/run/run.schema.js +1 -0
  22. package/dist/shared/index.js +1 -0
  23. package/dist/shared/mock-agents.js +1 -0
  24. package/dist/shared/mock-runs.js +1 -0
  25. package/dist/shared/mock-tools.js +1 -0
  26. package/dist/tool/index.js +1 -0
  27. package/dist/tool/tool.contracts.js +1 -0
  28. package/dist/tool/tool.entity.js +1 -0
  29. package/dist/tool/tool.enum.js +1 -0
  30. package/dist/tool/tool.event.js +1 -0
  31. package/dist/tool/tool.handler.js +1 -0
  32. package/dist/tool/tool.presentation.js +1 -0
  33. package/dist/tool/tool.schema.js +1 -0
  34. package/package.json +59 -39
  35. package/src/agent/agent.contracts.ts +275 -0
  36. package/src/agent/agent.entity.ts +84 -0
  37. package/src/agent/agent.enum.ts +31 -0
  38. package/src/agent/agent.event.ts +109 -0
  39. package/src/{handlers/agent.handlers.ts → agent/agent.handler.ts} +23 -78
  40. package/src/{presentations/agent-list.ts → agent/agent.presentation.ts} +26 -14
  41. package/src/agent/agent.schema.ts +147 -0
  42. package/src/agent/index.ts +65 -0
  43. package/src/handlers/index.ts +17 -44
  44. package/src/index.ts +6 -15
  45. package/src/presentations/index.ts +13 -34
  46. package/src/run/index.ts +65 -0
  47. package/src/run/run.contracts.ts +266 -0
  48. package/src/run/run.entity.ts +126 -0
  49. package/src/run/run.enum.ts +45 -0
  50. package/src/run/run.event.ts +211 -0
  51. package/src/run/run.handler.ts +103 -0
  52. package/src/run/run.presentation.ts +47 -0
  53. package/src/run/run.schema.ts +139 -0
  54. package/src/shared/index.ts +6 -0
  55. package/src/shared/mock-agents.ts +83 -0
  56. package/src/shared/mock-runs.ts +108 -0
  57. package/src/shared/mock-tools.ts +146 -0
  58. package/src/tool/index.ts +35 -0
  59. package/src/tool/tool.contracts.ts +180 -0
  60. package/src/tool/tool.entity.ts +66 -0
  61. package/src/tool/tool.enum.ts +34 -0
  62. package/src/tool/tool.event.ts +84 -0
  63. package/src/tool/tool.handler.ts +107 -0
  64. package/src/{presentations/tool-registry.ts → tool/tool.presentation.ts} +12 -17
  65. package/src/tool/tool.schema.ts +134 -0
  66. package/tsconfig.tsbuildinfo +1 -1
  67. package/dist/contracts/agent.js +0 -1
  68. package/dist/contracts/index.js +0 -1
  69. package/dist/contracts/run.js +0 -1
  70. package/dist/contracts/tool.js +0 -1
  71. package/dist/entities/index.js +0 -1
  72. package/dist/entities/log.js +0 -1
  73. package/dist/entities/run.js +0 -1
  74. package/dist/entities/tool.js +0 -1
  75. package/dist/events.js +0 -1
  76. package/dist/handlers/agent.handlers.js +0 -1
  77. package/dist/handlers/mock-data.js +0 -1
  78. package/dist/handlers/run.handlers.js +0 -1
  79. package/dist/handlers/tool.handlers.js +0 -1
  80. package/dist/presentations/agent-list.js +0 -1
  81. package/dist/presentations/dashboard.js +0 -1
  82. package/dist/presentations/run-list.js +0 -1
  83. package/dist/presentations/tool-registry.js +0 -1
  84. package/src/contracts/agent.ts +0 -501
  85. package/src/contracts/index.ts +0 -29
  86. package/src/contracts/run.ts +0 -561
  87. package/src/contracts/tool.ts +0 -392
  88. package/src/entities/agent.ts +0 -151
  89. package/src/entities/index.ts +0 -20
  90. package/src/entities/log.ts +0 -76
  91. package/src/entities/run.ts +0 -240
  92. package/src/entities/tool.ts +0 -105
  93. package/src/events.ts +0 -419
  94. package/src/handlers/mock-data.ts +0 -413
  95. package/src/handlers/run.handlers.ts +0 -331
  96. package/src/handlers/tool.handlers.ts +0 -188
  97. package/src/presentations/dashboard.ts +0 -29
  98. package/src/presentations/run-list.ts +0 -76
  99. /package/dist/{feature.js → agent.feature.js} +0 -0
  100. /package/src/{feature.ts → agent.feature.ts} +0 -0
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Mock handlers for Run contracts.
3
+ */
4
+ import { MOCK_RUNS } from '../shared/mock-runs';
5
+ import { MOCK_AGENTS } from '../shared/mock-agents';
6
+
7
+ export interface ListRunsInput {
8
+ organizationId?: string;
9
+ agentId?: string;
10
+ userId?: string;
11
+ sessionId?: string;
12
+ status?: 'QUEUED' | 'IN_PROGRESS' | 'COMPLETED' | 'FAILED' | 'CANCELLED' | 'EXPIRED';
13
+ startDate?: Date;
14
+ endDate?: Date;
15
+ limit?: number;
16
+ offset?: number;
17
+ }
18
+
19
+ export interface RunSummary {
20
+ id: string;
21
+ agentId: string;
22
+ agentName: string;
23
+ status: 'QUEUED' | 'IN_PROGRESS' | 'COMPLETED' | 'FAILED' | 'CANCELLED' | 'EXPIRED';
24
+ totalTokens: number;
25
+ durationMs?: number;
26
+ estimatedCostUsd?: number;
27
+ queuedAt: Date;
28
+ completedAt?: Date;
29
+ }
30
+
31
+ export interface ListRunsOutput {
32
+ items: RunSummary[];
33
+ total: number;
34
+ hasMore: boolean;
35
+ }
36
+
37
+ /**
38
+ * Mock handler for ListRunsQuery.
39
+ */
40
+ export async function mockListRunsHandler(input: ListRunsInput): Promise<ListRunsOutput> {
41
+ const { agentId, status, limit = 20, offset = 0 } = input;
42
+
43
+ let filtered = [...MOCK_RUNS];
44
+ if (agentId) filtered = filtered.filter((r) => r.agentId === agentId);
45
+ if (status) filtered = filtered.filter((r) => r.status === status);
46
+
47
+ const total = filtered.length;
48
+ const items = filtered.slice(offset, offset + limit).map((r) => {
49
+ const agent = MOCK_AGENTS.find((a) => a.id === r.agentId);
50
+ return {
51
+ id: r.id,
52
+ agentId: r.agentId,
53
+ agentName: agent?.name ?? 'Unknown',
54
+ status: r.status,
55
+ totalTokens: r.totalTokens,
56
+ durationMs: r.durationMs,
57
+ estimatedCostUsd: r.estimatedCostUsd,
58
+ queuedAt: r.queuedAt,
59
+ completedAt: r.completedAt,
60
+ };
61
+ });
62
+
63
+ return { items, total, hasMore: offset + limit < total };
64
+ }
65
+
66
+ /**
67
+ * Mock handler for GetRunQuery.
68
+ */
69
+ export async function mockGetRunHandler(input: { runId: string; includeSteps?: boolean; includeLogs?: boolean }) {
70
+ const run = MOCK_RUNS.find((r) => r.id === input.runId);
71
+ if (!run) throw new Error('RUN_NOT_FOUND');
72
+
73
+ const agent = MOCK_AGENTS.find((a) => a.id === run.agentId);
74
+ return {
75
+ ...run,
76
+ agent: agent ? { id: agent.id, name: agent.name, modelProvider: agent.modelProvider, modelName: agent.modelName } : undefined,
77
+ steps: input.includeSteps ? run.steps : undefined,
78
+ logs: input.includeLogs ? run.logs : undefined,
79
+ };
80
+ }
81
+
82
+ /**
83
+ * Mock handler for ExecuteAgentCommand.
84
+ */
85
+ export async function mockExecuteAgentHandler(input: { agentId: string; input: { message: string; context?: Record<string, unknown> } }) {
86
+ const agent = MOCK_AGENTS.find((a) => a.id === input.agentId);
87
+ if (!agent) throw new Error('AGENT_NOT_FOUND');
88
+ if (agent.status !== 'ACTIVE') throw new Error('AGENT_NOT_ACTIVE');
89
+
90
+ return { runId: `run-${Date.now()}`, status: 'QUEUED' as const, estimatedWaitMs: 500 };
91
+ }
92
+
93
+ /**
94
+ * Mock handler for CancelRunCommand.
95
+ */
96
+ export async function mockCancelRunHandler(input: { runId: string; reason?: string }) {
97
+ const run = MOCK_RUNS.find((r) => r.id === input.runId);
98
+ if (!run) throw new Error('RUN_NOT_FOUND');
99
+ if (!['QUEUED', 'IN_PROGRESS'].includes(run.status)) throw new Error('RUN_NOT_CANCELLABLE');
100
+
101
+ return { success: true, status: 'CANCELLED' as const };
102
+ }
103
+
@@ -0,0 +1,47 @@
1
+ import type { PresentationDescriptorV2 } from '@lssm/lib.contracts';
2
+ import { RunSummaryModel } from './run.schema';
3
+
4
+ /**
5
+ * Presentation for displaying a list of agent runs.
6
+ */
7
+ export const RunListPresentation: PresentationDescriptorV2 = {
8
+ meta: {
9
+ name: 'agent-console.run.list',
10
+ version: 1,
11
+ description: 'List view of agent runs with status, tokens, and duration info',
12
+ domain: 'agent-console',
13
+ owners: ['agent-console-team'],
14
+ tags: ['run', 'list', 'dashboard'],
15
+ },
16
+ source: {
17
+ type: 'component',
18
+ framework: 'react',
19
+ componentKey: 'RunListView',
20
+ props: RunSummaryModel,
21
+ },
22
+ targets: ['react', 'markdown', 'application/json'],
23
+ policy: { flags: ['agent-console.enabled'] },
24
+ };
25
+
26
+ /**
27
+ * Presentation for run detail view.
28
+ */
29
+ export const RunDetailPresentation: PresentationDescriptorV2 = {
30
+ meta: {
31
+ name: 'agent-console.run.detail',
32
+ version: 1,
33
+ description: 'Detailed view of an agent run with steps, logs, and metrics',
34
+ domain: 'agent-console',
35
+ owners: ['agent-console-team'],
36
+ tags: ['run', 'detail'],
37
+ },
38
+ source: {
39
+ type: 'component',
40
+ framework: 'react',
41
+ componentKey: 'RunDetailView',
42
+ },
43
+ targets: ['react', 'markdown'],
44
+ policy: { flags: ['agent-console.enabled'] },
45
+ };
46
+
47
+
@@ -0,0 +1,139 @@
1
+ import { defineSchemaModel, ScalarTypeEnum } from '@lssm/lib.schema';
2
+ import { RunStatusEnum, RunStepTypeEnum, LogLevelEnum } from './run.enum';
3
+
4
+ /**
5
+ * Input data for agent execution.
6
+ */
7
+ export const RunInputModel = defineSchemaModel({
8
+ name: 'RunInput',
9
+ description: 'Input data for agent execution',
10
+ fields: {
11
+ message: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
12
+ context: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
13
+ },
14
+ });
15
+
16
+ /**
17
+ * Individual step within a run.
18
+ */
19
+ export const RunStepModel = defineSchemaModel({
20
+ name: 'RunStep',
21
+ description: 'Individual step within a run',
22
+ fields: {
23
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
24
+ stepNumber: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
25
+ type: { type: RunStepTypeEnum, isOptional: false },
26
+ toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
27
+ toolName: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
28
+ input: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
29
+ output: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
30
+ status: { type: RunStatusEnum, isOptional: false },
31
+ errorMessage: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
32
+ tokensUsed: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false, defaultValue: 0 },
33
+ durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
34
+ startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
35
+ completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
36
+ },
37
+ });
38
+
39
+ /**
40
+ * Execution log entry.
41
+ */
42
+ export const RunLogModel = defineSchemaModel({
43
+ name: 'RunLog',
44
+ description: 'Execution log entry',
45
+ fields: {
46
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
47
+ stepId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
48
+ level: { type: LogLevelEnum, isOptional: false },
49
+ message: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
50
+ data: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
51
+ source: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
52
+ traceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
53
+ spanId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
54
+ timestamp: { type: ScalarTypeEnum.DateTime(), isOptional: false },
55
+ },
56
+ });
57
+
58
+ /**
59
+ * Agent reference in a run.
60
+ */
61
+ export const RunAgentRefModel = defineSchemaModel({
62
+ name: 'RunAgentRef',
63
+ description: 'Agent reference in a run',
64
+ fields: {
65
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
66
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
67
+ modelProvider: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
68
+ modelName: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
69
+ },
70
+ });
71
+
72
+ /**
73
+ * Agent execution instance.
74
+ */
75
+ export const RunModel = defineSchemaModel({
76
+ name: 'Run',
77
+ description: 'Agent execution instance',
78
+ fields: {
79
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
80
+ organizationId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
81
+ agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
82
+ userId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
83
+ sessionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
84
+ input: { type: ScalarTypeEnum.JSONObject(), isOptional: false },
85
+ output: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
86
+ status: { type: RunStatusEnum, isOptional: false },
87
+ errorMessage: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
88
+ errorCode: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
89
+ totalTokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false, defaultValue: 0 },
90
+ promptTokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false, defaultValue: 0 },
91
+ completionTokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false, defaultValue: 0 },
92
+ totalIterations: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false, defaultValue: 0 },
93
+ durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
94
+ estimatedCostUsd: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },
95
+ queuedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
96
+ startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
97
+ completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
98
+ metadata: { type: ScalarTypeEnum.JSONObject(), isOptional: true },
99
+ steps: { type: RunStepModel, isArray: true, isOptional: true },
100
+ logs: { type: RunLogModel, isArray: true, isOptional: true },
101
+ agent: { type: RunAgentRefModel, isOptional: true },
102
+ },
103
+ });
104
+
105
+ /**
106
+ * Summary of a run for list views.
107
+ */
108
+ export const RunSummaryModel = defineSchemaModel({
109
+ name: 'RunSummary',
110
+ description: 'Summary of a run for list views',
111
+ fields: {
112
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
113
+ agentId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
114
+ agentName: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
115
+ status: { type: RunStatusEnum, isOptional: false },
116
+ totalTokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
117
+ durationMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
118
+ estimatedCostUsd: { type: ScalarTypeEnum.Float_unsecure(), isOptional: true },
119
+ queuedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
120
+ completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
121
+ },
122
+ });
123
+
124
+ /**
125
+ * Timeline data point for metrics.
126
+ */
127
+ export const TimelineDataPointModel = defineSchemaModel({
128
+ name: 'TimelineDataPoint',
129
+ description: 'Timeline data point for metrics',
130
+ fields: {
131
+ period: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
132
+ runs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
133
+ tokens: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
134
+ costUsd: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
135
+ avgDurationMs: { type: ScalarTypeEnum.Float_unsecure(), isOptional: false },
136
+ },
137
+ });
138
+
139
+
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Shared utilities and mock data.
3
+ */
4
+ export { MOCK_AGENTS } from './mock-agents';
5
+ export { MOCK_TOOLS } from './mock-tools';
6
+ export { MOCK_RUNS } from './mock-runs';
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Mock agent data for testing and demos.
3
+ */
4
+ export const MOCK_AGENTS = [
5
+ {
6
+ id: 'agent-1',
7
+ organizationId: 'demo-org',
8
+ name: 'Customer Support Bot',
9
+ slug: 'customer-support-bot',
10
+ description: 'Handles tier-1 customer inquiries and routes complex issues.',
11
+ status: 'ACTIVE' as const,
12
+ modelProvider: 'OPENAI' as const,
13
+ modelName: 'gpt-4o-mini',
14
+ modelConfig: { temperature: 0.7 },
15
+ systemPrompt: 'You are a helpful customer support assistant.',
16
+ toolChoice: 'auto' as const,
17
+ maxIterations: 10,
18
+ timeoutMs: 120000,
19
+ version: '1.0.0',
20
+ tags: ['support', 'tier-1'],
21
+ createdAt: new Date('2024-01-15T10:00:00Z'),
22
+ updatedAt: new Date('2024-03-20T14:30:00Z'),
23
+ },
24
+ {
25
+ id: 'agent-2',
26
+ organizationId: 'demo-org',
27
+ name: 'Code Review Assistant',
28
+ slug: 'code-review-assistant',
29
+ description: 'Reviews pull requests and provides actionable feedback.',
30
+ status: 'ACTIVE' as const,
31
+ modelProvider: 'ANTHROPIC' as const,
32
+ modelName: 'claude-sonnet-4-20250514',
33
+ modelConfig: { temperature: 0.3 },
34
+ systemPrompt: 'You are a code review expert.',
35
+ toolChoice: 'auto' as const,
36
+ maxIterations: 15,
37
+ timeoutMs: 180000,
38
+ version: '2.1.0',
39
+ tags: ['code', 'review', 'dev'],
40
+ createdAt: new Date('2024-02-10T09:00:00Z'),
41
+ updatedAt: new Date('2024-04-05T11:15:00Z'),
42
+ },
43
+ {
44
+ id: 'agent-3',
45
+ organizationId: 'demo-org',
46
+ name: 'Data Analyst',
47
+ slug: 'data-analyst',
48
+ description: 'Queries databases and generates insights from data.',
49
+ status: 'PAUSED' as const,
50
+ modelProvider: 'OPENAI' as const,
51
+ modelName: 'gpt-4o',
52
+ modelConfig: { temperature: 0.5 },
53
+ systemPrompt: 'You are a data analyst expert in SQL and analytics.',
54
+ toolChoice: 'required' as const,
55
+ maxIterations: 20,
56
+ timeoutMs: 300000,
57
+ version: '1.2.0',
58
+ tags: ['data', 'analytics', 'sql'],
59
+ createdAt: new Date('2024-03-01T08:00:00Z'),
60
+ updatedAt: new Date('2024-04-10T16:45:00Z'),
61
+ },
62
+ {
63
+ id: 'agent-4',
64
+ organizationId: 'demo-org',
65
+ name: 'Meeting Scheduler',
66
+ slug: 'meeting-scheduler',
67
+ description: 'Schedules meetings and manages calendar conflicts.',
68
+ status: 'DRAFT' as const,
69
+ modelProvider: 'GOOGLE' as const,
70
+ modelName: 'gemini-2.0-flash',
71
+ modelConfig: { temperature: 0.2 },
72
+ systemPrompt: 'You help schedule and organize meetings efficiently.',
73
+ toolChoice: 'auto' as const,
74
+ maxIterations: 5,
75
+ timeoutMs: 60000,
76
+ version: '0.1.0',
77
+ tags: ['calendar', 'scheduling'],
78
+ createdAt: new Date('2024-04-01T12:00:00Z'),
79
+ updatedAt: new Date('2024-04-01T12:00:00Z'),
80
+ },
81
+ ];
82
+
83
+
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Mock run data for testing and demos.
3
+ */
4
+ export const MOCK_RUNS = [
5
+ {
6
+ id: 'run-1',
7
+ organizationId: 'demo-org',
8
+ agentId: 'agent-1',
9
+ agentName: 'Customer Support Bot',
10
+ userId: 'user-1',
11
+ sessionId: 'session-1',
12
+ input: { message: 'How do I reset my password?', context: {} },
13
+ output: { response: 'You can reset your password by clicking...' },
14
+ status: 'COMPLETED' as const,
15
+ totalTokens: 1250,
16
+ promptTokens: 800,
17
+ completionTokens: 450,
18
+ totalIterations: 3,
19
+ durationMs: 4500,
20
+ estimatedCostUsd: 0.0025,
21
+ queuedAt: new Date('2024-04-15T10:00:00Z'),
22
+ startedAt: new Date('2024-04-15T10:00:01Z'),
23
+ completedAt: new Date('2024-04-15T10:00:05Z'),
24
+ steps: [],
25
+ logs: [],
26
+ },
27
+ {
28
+ id: 'run-2',
29
+ organizationId: 'demo-org',
30
+ agentId: 'agent-2',
31
+ agentName: 'Code Review Assistant',
32
+ userId: 'user-2',
33
+ input: { message: 'Review PR #123', context: { prNumber: 123 } },
34
+ status: 'IN_PROGRESS' as const,
35
+ totalTokens: 3500,
36
+ promptTokens: 3000,
37
+ completionTokens: 500,
38
+ totalIterations: 5,
39
+ queuedAt: new Date('2024-04-15T10:30:00Z'),
40
+ startedAt: new Date('2024-04-15T10:30:02Z'),
41
+ steps: [],
42
+ logs: [],
43
+ },
44
+ {
45
+ id: 'run-3',
46
+ organizationId: 'demo-org',
47
+ agentId: 'agent-1',
48
+ agentName: 'Customer Support Bot',
49
+ userId: 'user-1',
50
+ input: { message: 'What are your business hours?' },
51
+ output: { response: 'Our business hours are 9 AM to 5 PM EST...' },
52
+ status: 'COMPLETED' as const,
53
+ totalTokens: 800,
54
+ promptTokens: 500,
55
+ completionTokens: 300,
56
+ totalIterations: 2,
57
+ durationMs: 2100,
58
+ estimatedCostUsd: 0.0012,
59
+ queuedAt: new Date('2024-04-15T09:00:00Z'),
60
+ startedAt: new Date('2024-04-15T09:00:01Z'),
61
+ completedAt: new Date('2024-04-15T09:00:03Z'),
62
+ steps: [],
63
+ logs: [],
64
+ },
65
+ {
66
+ id: 'run-4',
67
+ organizationId: 'demo-org',
68
+ agentId: 'agent-3',
69
+ agentName: 'Data Analyst',
70
+ userId: 'user-3',
71
+ input: { message: 'Generate sales report for Q1' },
72
+ status: 'FAILED' as const,
73
+ errorMessage: 'Database connection timeout',
74
+ errorCode: 'DB_TIMEOUT',
75
+ totalTokens: 2000,
76
+ promptTokens: 1500,
77
+ completionTokens: 500,
78
+ totalIterations: 8,
79
+ durationMs: 45000,
80
+ queuedAt: new Date('2024-04-14T15:00:00Z'),
81
+ startedAt: new Date('2024-04-14T15:00:05Z'),
82
+ completedAt: new Date('2024-04-14T15:00:50Z'),
83
+ steps: [],
84
+ logs: [],
85
+ },
86
+ {
87
+ id: 'run-5',
88
+ organizationId: 'demo-org',
89
+ agentId: 'agent-2',
90
+ agentName: 'Code Review Assistant',
91
+ userId: 'user-2',
92
+ input: { message: 'Review PR #120' },
93
+ output: { response: 'Code review complete. 3 suggestions...' },
94
+ status: 'COMPLETED' as const,
95
+ totalTokens: 5200,
96
+ promptTokens: 4000,
97
+ completionTokens: 1200,
98
+ totalIterations: 7,
99
+ durationMs: 15000,
100
+ estimatedCostUsd: 0.0156,
101
+ queuedAt: new Date('2024-04-14T11:00:00Z'),
102
+ startedAt: new Date('2024-04-14T11:00:03Z'),
103
+ completedAt: new Date('2024-04-14T11:00:18Z'),
104
+ steps: [],
105
+ logs: [],
106
+ },
107
+ ];
108
+
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Mock tool data for testing and demos.
3
+ */
4
+ export const MOCK_TOOLS = [
5
+ {
6
+ id: 'tool-1',
7
+ organizationId: 'demo-org',
8
+ name: 'Web Search',
9
+ slug: 'web-search',
10
+ description: 'Search the web for real-time information using Brave API.',
11
+ category: 'RETRIEVAL' as const,
12
+ status: 'ACTIVE' as const,
13
+ parametersSchema: {
14
+ type: 'object',
15
+ properties: {
16
+ query: { type: 'string', description: 'Search query' },
17
+ numResults: { type: 'number', default: 10 },
18
+ },
19
+ required: ['query'],
20
+ },
21
+ outputSchema: { type: 'array', items: { type: 'object' } },
22
+ implementationType: 'http' as const,
23
+ implementationConfig: {
24
+ url: 'https://api.brave.com/search',
25
+ method: 'GET',
26
+ },
27
+ maxInvocationsPerMinute: 60,
28
+ timeoutMs: 30000,
29
+ version: '1.0.0',
30
+ tags: ['search', 'web'],
31
+ createdAt: new Date('2024-01-01T00:00:00Z'),
32
+ updatedAt: new Date('2024-02-15T10:00:00Z'),
33
+ },
34
+ {
35
+ id: 'tool-2',
36
+ organizationId: 'demo-org',
37
+ name: 'SQL Query',
38
+ slug: 'sql-query',
39
+ description: 'Execute read-only SQL queries against the data warehouse.',
40
+ category: 'RETRIEVAL' as const,
41
+ status: 'ACTIVE' as const,
42
+ parametersSchema: {
43
+ type: 'object',
44
+ properties: {
45
+ query: { type: 'string', description: 'SQL query' },
46
+ maxRows: { type: 'number', default: 100 },
47
+ },
48
+ required: ['query'],
49
+ },
50
+ outputSchema: { type: 'object' },
51
+ implementationType: 'function' as const,
52
+ implementationConfig: { handler: 'executeSqlQuery' },
53
+ maxInvocationsPerMinute: 30,
54
+ timeoutMs: 60000,
55
+ version: '1.1.0',
56
+ tags: ['sql', 'database'],
57
+ createdAt: new Date('2024-01-05T00:00:00Z'),
58
+ updatedAt: new Date('2024-03-10T14:00:00Z'),
59
+ },
60
+ {
61
+ id: 'tool-3',
62
+ organizationId: 'demo-org',
63
+ name: 'Email Sender',
64
+ slug: 'email-sender',
65
+ description: 'Send emails via SMTP or API.',
66
+ category: 'COMMUNICATION' as const,
67
+ status: 'ACTIVE' as const,
68
+ parametersSchema: {
69
+ type: 'object',
70
+ properties: {
71
+ to: { type: 'string' },
72
+ subject: { type: 'string' },
73
+ body: { type: 'string' },
74
+ },
75
+ required: ['to', 'subject', 'body'],
76
+ },
77
+ implementationType: 'http' as const,
78
+ implementationConfig: { url: '/api/send-email', method: 'POST' },
79
+ maxInvocationsPerMinute: 10,
80
+ timeoutMs: 30000,
81
+ version: '1.0.0',
82
+ tags: ['email', 'communication'],
83
+ createdAt: new Date('2024-02-01T00:00:00Z'),
84
+ updatedAt: new Date('2024-02-01T00:00:00Z'),
85
+ },
86
+ {
87
+ id: 'tool-4',
88
+ organizationId: 'demo-org',
89
+ name: 'GitHub Integration',
90
+ slug: 'github-integration',
91
+ description: 'Interact with GitHub repositories, PRs, and issues.',
92
+ category: 'INTEGRATION' as const,
93
+ status: 'ACTIVE' as const,
94
+ parametersSchema: {
95
+ type: 'object',
96
+ properties: {
97
+ action: {
98
+ type: 'string',
99
+ enum: ['list_prs', 'get_pr', 'create_comment'],
100
+ },
101
+ repo: { type: 'string' },
102
+ params: { type: 'object' },
103
+ },
104
+ required: ['action', 'repo'],
105
+ },
106
+ implementationType: 'http' as const,
107
+ implementationConfig: { url: 'https://api.github.com', auth: 'token' },
108
+ maxInvocationsPerMinute: 100,
109
+ timeoutMs: 15000,
110
+ version: '2.0.0',
111
+ tags: ['github', 'integration', 'code'],
112
+ createdAt: new Date('2024-02-20T00:00:00Z'),
113
+ updatedAt: new Date('2024-04-01T09:00:00Z'),
114
+ },
115
+ {
116
+ id: 'tool-5',
117
+ organizationId: 'demo-org',
118
+ name: 'Calculator',
119
+ slug: 'calculator',
120
+ description: 'Perform mathematical calculations.',
121
+ category: 'COMPUTATION' as const,
122
+ status: 'ACTIVE' as const,
123
+ parametersSchema: {
124
+ type: 'object',
125
+ properties: {
126
+ expression: {
127
+ type: 'string',
128
+ description: 'Math expression to evaluate',
129
+ },
130
+ },
131
+ required: ['expression'],
132
+ },
133
+ outputSchema: {
134
+ type: 'object',
135
+ properties: { result: { type: 'number' } },
136
+ },
137
+ implementationType: 'function' as const,
138
+ implementationConfig: { handler: 'evaluateMath' },
139
+ timeoutMs: 5000,
140
+ version: '1.0.0',
141
+ tags: ['math', 'utility'],
142
+ createdAt: new Date('2024-01-10T00:00:00Z'),
143
+ updatedAt: new Date('2024-01-10T00:00:00Z'),
144
+ },
145
+ ];
146
+
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Tool domain - AI tool definitions and management.
3
+ */
4
+
5
+ // Enums
6
+ export { ToolCategoryEnum, ToolStatusEnum, ImplementationTypeEnum } from './tool.enum';
7
+
8
+ // Schema models
9
+ export { ToolModel, ToolSummaryModel, CreateToolInputModel, UpdateToolInputModel } from './tool.schema';
10
+
11
+ // Contracts
12
+ export { CreateToolCommand, UpdateToolCommand, GetToolQuery, ListToolsQuery, TestToolCommand } from './tool.contracts';
13
+
14
+ // Events
15
+ export { ToolCreatedEvent, ToolUpdatedEvent, ToolStatusChangedEvent } from './tool.event';
16
+
17
+ // Entities
18
+ export { ToolCategoryEntityEnum, ToolStatusEntityEnum, ImplementationTypeEntityEnum, ToolEntity } from './tool.entity';
19
+
20
+ // Presentations
21
+ export { ToolListPresentation, ToolDetailPresentation } from './tool.presentation';
22
+
23
+ // Handlers
24
+ export {
25
+ mockListToolsHandler,
26
+ mockGetToolHandler,
27
+ mockCreateToolHandler,
28
+ mockUpdateToolHandler,
29
+ mockTestToolHandler,
30
+ type ListToolsInput,
31
+ type ToolSummary,
32
+ type ListToolsOutput,
33
+ } from './tool.handler';
34
+
35
+