@lssm/example.agent-console 0.0.0-canary-20251216031832 → 0.0.0-canary-20251216033905

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.
@@ -143,4 +143,3 @@ export const MOCK_TOOLS = [
143
143
  updatedAt: new Date('2024-01-10T00:00:00Z'),
144
144
  },
145
145
  ];
146
-
package/src/tool/index.ts CHANGED
@@ -3,22 +3,49 @@
3
3
  */
4
4
 
5
5
  // Enums
6
- export { ToolCategoryEnum, ToolStatusEnum, ImplementationTypeEnum } from './tool.enum';
6
+ export {
7
+ ToolCategoryEnum,
8
+ ToolStatusEnum,
9
+ ImplementationTypeEnum,
10
+ } from './tool.enum';
7
11
 
8
12
  // Schema models
9
- export { ToolModel, ToolSummaryModel, CreateToolInputModel, UpdateToolInputModel } from './tool.schema';
13
+ export {
14
+ ToolModel,
15
+ ToolSummaryModel,
16
+ CreateToolInputModel,
17
+ UpdateToolInputModel,
18
+ } from './tool.schema';
10
19
 
11
20
  // Contracts
12
- export { CreateToolCommand, UpdateToolCommand, GetToolQuery, ListToolsQuery, TestToolCommand } from './tool.contracts';
21
+ export {
22
+ CreateToolCommand,
23
+ UpdateToolCommand,
24
+ GetToolQuery,
25
+ ListToolsQuery,
26
+ TestToolCommand,
27
+ } from './tool.contracts';
13
28
 
14
29
  // Events
15
- export { ToolCreatedEvent, ToolUpdatedEvent, ToolStatusChangedEvent } from './tool.event';
30
+ export {
31
+ ToolCreatedEvent,
32
+ ToolUpdatedEvent,
33
+ ToolStatusChangedEvent,
34
+ } from './tool.event';
16
35
 
17
36
  // Entities
18
- export { ToolCategoryEntityEnum, ToolStatusEntityEnum, ImplementationTypeEntityEnum, ToolEntity } from './tool.entity';
37
+ export {
38
+ ToolCategoryEntityEnum,
39
+ ToolStatusEntityEnum,
40
+ ImplementationTypeEntityEnum,
41
+ ToolEntity,
42
+ } from './tool.entity';
19
43
 
20
44
  // Presentations
21
- export { ToolListPresentation, ToolDetailPresentation } from './tool.presentation';
45
+ export {
46
+ ToolListPresentation,
47
+ ToolDetailPresentation,
48
+ } from './tool.presentation';
22
49
 
23
50
  // Handlers
24
51
  export {
@@ -31,5 +58,3 @@ export {
31
58
  type ToolSummary,
32
59
  type ListToolsOutput,
33
60
  } from './tool.handler';
34
-
35
-
@@ -1,7 +1,12 @@
1
1
  import { defineCommand, defineQuery } from '@lssm/lib.contracts/spec';
2
2
  import { defineSchemaModel, ScalarTypeEnum } from '@lssm/lib.schema';
3
3
  import { ToolCategoryEnum, ToolStatusEnum } from './tool.enum';
4
- import { ToolModel, ToolSummaryModel, CreateToolInputModel, UpdateToolInputModel } from './tool.schema';
4
+ import {
5
+ ToolModel,
6
+ ToolSummaryModel,
7
+ CreateToolInputModel,
8
+ UpdateToolInputModel,
9
+ } from './tool.schema';
5
10
 
6
11
  const OWNERS = ['agent-console-team'] as const;
7
12
 
@@ -31,12 +36,24 @@ export const CreateToolCommand = defineCommand({
31
36
  },
32
37
  }),
33
38
  errors: {
34
- SLUG_EXISTS: { description: 'A tool with this slug already exists in the organization', http: 409, gqlCode: 'SLUG_EXISTS', when: 'Slug is already taken' },
39
+ SLUG_EXISTS: {
40
+ description: 'A tool with this slug already exists in the organization',
41
+ http: 409,
42
+ gqlCode: 'SLUG_EXISTS',
43
+ when: 'Slug is already taken',
44
+ },
35
45
  },
36
46
  },
37
47
  policy: { auth: 'user' },
38
48
  sideEffects: {
39
- emits: [{ name: 'tool.created', version: 1, when: 'Tool is successfully created', payload: ToolSummaryModel }],
49
+ emits: [
50
+ {
51
+ name: 'tool.created',
52
+ version: 1,
53
+ when: 'Tool is successfully created',
54
+ payload: ToolSummaryModel,
55
+ },
56
+ ],
40
57
  audit: ['tool.created'],
41
58
  },
42
59
  });
@@ -67,12 +84,24 @@ export const UpdateToolCommand = defineCommand({
67
84
  },
68
85
  }),
69
86
  errors: {
70
- TOOL_NOT_FOUND: { description: 'The specified tool does not exist', http: 404, gqlCode: 'TOOL_NOT_FOUND', when: 'Tool ID is invalid' },
87
+ TOOL_NOT_FOUND: {
88
+ description: 'The specified tool does not exist',
89
+ http: 404,
90
+ gqlCode: 'TOOL_NOT_FOUND',
91
+ when: 'Tool ID is invalid',
92
+ },
71
93
  },
72
94
  },
73
95
  policy: { auth: 'user' },
74
96
  sideEffects: {
75
- emits: [{ name: 'tool.updated', version: 1, when: 'Tool is updated', payload: ToolSummaryModel }],
97
+ emits: [
98
+ {
99
+ name: 'tool.updated',
100
+ version: 1,
101
+ when: 'Tool is updated',
102
+ payload: ToolSummaryModel,
103
+ },
104
+ ],
76
105
  audit: ['tool.updated'],
77
106
  },
78
107
  });
@@ -92,9 +121,21 @@ export const GetToolQuery = defineQuery({
92
121
  context: 'Called when viewing tool details or editing.',
93
122
  },
94
123
  io: {
95
- input: defineSchemaModel({ name: 'GetToolInput', fields: { toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false } } }),
124
+ input: defineSchemaModel({
125
+ name: 'GetToolInput',
126
+ fields: {
127
+ toolId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
128
+ },
129
+ }),
96
130
  output: ToolModel,
97
- errors: { TOOL_NOT_FOUND: { description: 'The specified tool does not exist', http: 404, gqlCode: 'TOOL_NOT_FOUND', when: 'Tool ID is invalid' } },
131
+ errors: {
132
+ TOOL_NOT_FOUND: {
133
+ description: 'The specified tool does not exist',
134
+ http: 404,
135
+ gqlCode: 'TOOL_NOT_FOUND',
136
+ when: 'Tool ID is invalid',
137
+ },
138
+ },
98
139
  },
99
140
  policy: { auth: 'user' },
100
141
  });
@@ -117,12 +158,23 @@ export const ListToolsQuery = defineQuery({
117
158
  input: defineSchemaModel({
118
159
  name: 'ListToolsInput',
119
160
  fields: {
120
- organizationId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
161
+ organizationId: {
162
+ type: ScalarTypeEnum.String_unsecure(),
163
+ isOptional: false,
164
+ },
121
165
  category: { type: ToolCategoryEnum, isOptional: true },
122
166
  status: { type: ToolStatusEnum, isOptional: true },
123
167
  search: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
124
- limit: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true, defaultValue: 20 },
125
- offset: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true, defaultValue: 0 },
168
+ limit: {
169
+ type: ScalarTypeEnum.Int_unsecure(),
170
+ isOptional: true,
171
+ defaultValue: 20,
172
+ },
173
+ offset: {
174
+ type: ScalarTypeEnum.Int_unsecure(),
175
+ isOptional: true,
176
+ defaultValue: 0,
177
+ },
126
178
  },
127
179
  }),
128
180
  output: defineSchemaModel({
@@ -169,12 +221,20 @@ export const TestToolCommand = defineCommand({
169
221
  },
170
222
  }),
171
223
  errors: {
172
- TOOL_NOT_FOUND: { description: 'The specified tool does not exist', http: 404, gqlCode: 'TOOL_NOT_FOUND', when: 'Tool ID is invalid' },
173
- TOOL_EXECUTION_ERROR: { description: 'Tool execution failed', http: 500, gqlCode: 'TOOL_EXECUTION_ERROR', when: 'Tool returns an error' },
224
+ TOOL_NOT_FOUND: {
225
+ description: 'The specified tool does not exist',
226
+ http: 404,
227
+ gqlCode: 'TOOL_NOT_FOUND',
228
+ when: 'Tool ID is invalid',
229
+ },
230
+ TOOL_EXECUTION_ERROR: {
231
+ description: 'Tool execution failed',
232
+ http: 500,
233
+ gqlCode: 'TOOL_EXECUTION_ERROR',
234
+ when: 'Tool returns an error',
235
+ },
174
236
  },
175
237
  },
176
238
  policy: { auth: 'user' },
177
239
  sideEffects: { audit: ['tool.tested'] },
178
240
  });
179
-
180
-
@@ -1,11 +1,23 @@
1
- import { defineEntity, defineEntityEnum, field, index } from '@lssm/lib.schema/entity';
1
+ import {
2
+ defineEntity,
3
+ defineEntityEnum,
4
+ field,
5
+ index,
6
+ } from '@lssm/lib.schema/entity';
2
7
 
3
8
  /**
4
9
  * Tool category enum for entities.
5
10
  */
6
11
  export const ToolCategoryEntityEnum = defineEntityEnum({
7
12
  name: 'ToolCategory',
8
- values: ['RETRIEVAL', 'COMPUTATION', 'COMMUNICATION', 'INTEGRATION', 'UTILITY', 'CUSTOM'],
13
+ values: [
14
+ 'RETRIEVAL',
15
+ 'COMPUTATION',
16
+ 'COMMUNICATION',
17
+ 'INTEGRATION',
18
+ 'UTILITY',
19
+ 'CUSTOM',
20
+ ],
9
21
  description: 'Category of tool',
10
22
  });
11
23
 
@@ -36,23 +48,42 @@ export const ToolEntity = defineEntity({
36
48
  description: 'An AI tool that can be used by agents.',
37
49
  fields: {
38
50
  id: field.id(),
39
- organizationId: field.string({ description: 'Organization that owns this tool' }),
51
+ organizationId: field.string({
52
+ description: 'Organization that owns this tool',
53
+ }),
40
54
  name: field.string({ description: 'Tool name' }),
41
55
  slug: field.string({ description: 'URL-safe identifier' }),
42
56
  description: field.string({ description: 'Tool description' }),
43
57
  category: field.enum('ToolCategory', { default: 'CUSTOM' }),
44
58
  status: field.enum('ToolStatus', { default: 'DRAFT' }),
45
- parametersSchema: field.json({ description: 'JSON Schema for tool parameters' }),
46
- outputSchema: field.json({ isOptional: true, description: 'JSON Schema for tool output' }),
59
+ parametersSchema: field.json({
60
+ description: 'JSON Schema for tool parameters',
61
+ }),
62
+ outputSchema: field.json({
63
+ isOptional: true,
64
+ description: 'JSON Schema for tool output',
65
+ }),
47
66
  implementationType: field.enum('ImplementationType'),
48
- implementationConfig: field.json({ description: 'Implementation configuration' }),
49
- maxInvocationsPerMinute: field.int({ isOptional: true, description: 'Rate limit' }),
67
+ implementationConfig: field.json({
68
+ description: 'Implementation configuration',
69
+ }),
70
+ maxInvocationsPerMinute: field.int({
71
+ isOptional: true,
72
+ description: 'Rate limit',
73
+ }),
50
74
  timeoutMs: field.int({ default: 30000, description: 'Execution timeout' }),
51
75
  version: field.string({ default: '1.0.0', description: 'Tool version' }),
52
- tags: field.string({ isArray: true, isOptional: true, description: 'Tags for categorization' }),
76
+ tags: field.string({
77
+ isArray: true,
78
+ isOptional: true,
79
+ description: 'Tags for categorization',
80
+ }),
53
81
  createdAt: field.createdAt(),
54
82
  updatedAt: field.updatedAt(),
55
- createdById: field.string({ isOptional: true, description: 'User who created this tool' }),
83
+ createdById: field.string({
84
+ isOptional: true,
85
+ description: 'User who created this tool',
86
+ }),
56
87
  agents: field.hasMany('Agent', { description: 'Agents using this tool' }),
57
88
  },
58
89
  indexes: [
@@ -60,7 +91,9 @@ export const ToolEntity = defineEntity({
60
91
  index.on(['organizationId', 'category']),
61
92
  index.on(['organizationId', 'status']),
62
93
  ],
63
- enums: [ToolCategoryEntityEnum, ToolStatusEntityEnum, ImplementationTypeEntityEnum],
94
+ enums: [
95
+ ToolCategoryEntityEnum,
96
+ ToolStatusEntityEnum,
97
+ ImplementationTypeEntityEnum,
98
+ ],
64
99
  });
65
-
66
-
@@ -30,5 +30,3 @@ export const ImplementationTypeEnum = defineEnum('ImplementationType', [
30
30
  'function',
31
31
  'workflow',
32
32
  ]);
33
-
34
-
@@ -9,11 +9,17 @@ const ToolCreatedPayload = defineSchemaModel({
9
9
  description: 'Payload for tool created event',
10
10
  fields: {
11
11
  id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
12
- organizationId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
12
+ organizationId: {
13
+ type: ScalarTypeEnum.String_unsecure(),
14
+ isOptional: false,
15
+ },
13
16
  name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
14
17
  slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
15
18
  category: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
16
- implementationType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
19
+ implementationType: {
20
+ type: ScalarTypeEnum.String_unsecure(),
21
+ isOptional: false,
22
+ },
17
23
  createdById: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
18
24
  createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
19
25
  },
@@ -37,10 +43,17 @@ const ToolUpdatedPayload = defineSchemaModel({
37
43
  description: 'Payload for tool updated event',
38
44
  fields: {
39
45
  id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
40
- organizationId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
46
+ organizationId: {
47
+ type: ScalarTypeEnum.String_unsecure(),
48
+ isOptional: false,
49
+ },
41
50
  name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
42
51
  status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
43
- updatedFields: { type: ScalarTypeEnum.String_unsecure(), isArray: true, isOptional: false },
52
+ updatedFields: {
53
+ type: ScalarTypeEnum.String_unsecure(),
54
+ isArray: true,
55
+ isOptional: false,
56
+ },
44
57
  updatedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
45
58
  },
46
59
  });
@@ -63,9 +76,15 @@ const ToolStatusChangedPayload = defineSchemaModel({
63
76
  description: 'Payload for tool status changed event',
64
77
  fields: {
65
78
  id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
66
- organizationId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
79
+ organizationId: {
80
+ type: ScalarTypeEnum.String_unsecure(),
81
+ isOptional: false,
82
+ },
67
83
  name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
68
- previousStatus: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
84
+ previousStatus: {
85
+ type: ScalarTypeEnum.String_unsecure(),
86
+ isOptional: false,
87
+ },
69
88
  newStatus: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
70
89
  changedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false },
71
90
  },
@@ -77,8 +96,7 @@ const ToolStatusChangedPayload = defineSchemaModel({
77
96
  export const ToolStatusChangedEvent = defineEvent({
78
97
  name: 'agent.tool.statusChanged',
79
98
  version: 1,
80
- description: 'An AI tool status was changed (activated, deprecated, disabled).',
99
+ description:
100
+ 'An AI tool status was changed (activated, deprecated, disabled).',
81
101
  payload: ToolStatusChangedPayload,
82
102
  });
83
-
84
-
@@ -5,7 +5,13 @@ import { MOCK_TOOLS } from '../shared/mock-tools';
5
5
 
6
6
  export interface ListToolsInput {
7
7
  organizationId: string;
8
- category?: 'RETRIEVAL' | 'COMPUTATION' | 'COMMUNICATION' | 'INTEGRATION' | 'UTILITY' | 'CUSTOM';
8
+ category?:
9
+ | 'RETRIEVAL'
10
+ | 'COMPUTATION'
11
+ | 'COMMUNICATION'
12
+ | 'INTEGRATION'
13
+ | 'UTILITY'
14
+ | 'CUSTOM';
9
15
  status?: 'DRAFT' | 'ACTIVE' | 'DEPRECATED' | 'DISABLED';
10
16
  search?: string;
11
17
  limit?: number;
@@ -17,7 +23,13 @@ export interface ToolSummary {
17
23
  name: string;
18
24
  slug: string;
19
25
  description: string;
20
- category: 'RETRIEVAL' | 'COMPUTATION' | 'COMMUNICATION' | 'INTEGRATION' | 'UTILITY' | 'CUSTOM';
26
+ category:
27
+ | 'RETRIEVAL'
28
+ | 'COMPUTATION'
29
+ | 'COMMUNICATION'
30
+ | 'INTEGRATION'
31
+ | 'UTILITY'
32
+ | 'CUSTOM';
21
33
  status: 'DRAFT' | 'ACTIVE' | 'DEPRECATED' | 'DISABLED';
22
34
  version: string;
23
35
  createdAt: Date;
@@ -32,15 +44,28 @@ export interface ListToolsOutput {
32
44
  /**
33
45
  * Mock handler for ListToolsQuery.
34
46
  */
35
- export async function mockListToolsHandler(input: ListToolsInput): Promise<ListToolsOutput> {
36
- const { organizationId, category, status, search, limit = 20, offset = 0 } = input;
47
+ export async function mockListToolsHandler(
48
+ input: ListToolsInput
49
+ ): Promise<ListToolsOutput> {
50
+ const {
51
+ organizationId,
52
+ category,
53
+ status,
54
+ search,
55
+ limit = 20,
56
+ offset = 0,
57
+ } = input;
37
58
 
38
59
  let filtered = MOCK_TOOLS.filter((t) => t.organizationId === organizationId);
39
60
  if (category) filtered = filtered.filter((t) => t.category === category);
40
61
  if (status) filtered = filtered.filter((t) => t.status === status);
41
62
  if (search) {
42
63
  const q = search.toLowerCase();
43
- filtered = filtered.filter((t) => t.name.toLowerCase().includes(q) || t.description.toLowerCase().includes(q));
64
+ filtered = filtered.filter(
65
+ (t) =>
66
+ t.name.toLowerCase().includes(q) ||
67
+ t.description.toLowerCase().includes(q)
68
+ );
44
69
  }
45
70
 
46
71
  const total = filtered.length;
@@ -77,24 +102,43 @@ export async function mockCreateToolHandler(input: {
77
102
  description: string;
78
103
  implementationType: 'http' | 'function' | 'workflow';
79
104
  }) {
80
- const exists = MOCK_TOOLS.some((t) => t.organizationId === input.organizationId && t.slug === input.slug);
105
+ const exists = MOCK_TOOLS.some(
106
+ (t) => t.organizationId === input.organizationId && t.slug === input.slug
107
+ );
81
108
  if (exists) throw new Error('SLUG_EXISTS');
82
- return { id: `tool-${Date.now()}`, name: input.name, slug: input.slug, status: 'DRAFT' as const };
109
+ return {
110
+ id: `tool-${Date.now()}`,
111
+ name: input.name,
112
+ slug: input.slug,
113
+ status: 'DRAFT' as const,
114
+ };
83
115
  }
84
116
 
85
117
  /**
86
118
  * Mock handler for UpdateToolCommand.
87
119
  */
88
- export async function mockUpdateToolHandler(input: { toolId: string; name?: string; status?: 'DRAFT' | 'ACTIVE' | 'DEPRECATED' | 'DISABLED' }) {
120
+ export async function mockUpdateToolHandler(input: {
121
+ toolId: string;
122
+ name?: string;
123
+ status?: 'DRAFT' | 'ACTIVE' | 'DEPRECATED' | 'DISABLED';
124
+ }) {
89
125
  const tool = MOCK_TOOLS.find((t) => t.id === input.toolId);
90
126
  if (!tool) throw new Error('TOOL_NOT_FOUND');
91
- return { id: tool.id, name: input.name ?? tool.name, status: input.status ?? tool.status, updatedAt: new Date() };
127
+ return {
128
+ id: tool.id,
129
+ name: input.name ?? tool.name,
130
+ status: input.status ?? tool.status,
131
+ updatedAt: new Date(),
132
+ };
92
133
  }
93
134
 
94
135
  /**
95
136
  * Mock handler for TestToolCommand.
96
137
  */
97
- export async function mockTestToolHandler(input: { toolId: string; testInput: Record<string, unknown> }) {
138
+ export async function mockTestToolHandler(input: {
139
+ toolId: string;
140
+ testInput: Record<string, unknown>;
141
+ }) {
98
142
  const tool = MOCK_TOOLS.find((t) => t.id === input.toolId);
99
143
  if (!tool) throw new Error('TOOL_NOT_FOUND');
100
144
 
@@ -102,6 +146,9 @@ export async function mockTestToolHandler(input: { toolId: string; testInput: Re
102
146
  const startTime = Date.now();
103
147
  await new Promise((resolve) => setTimeout(resolve, 100));
104
148
 
105
- return { success: true, output: { result: 'Test successful', input: input.testInput }, durationMs: Date.now() - startTime };
149
+ return {
150
+ success: true,
151
+ output: { result: 'Test successful', input: input.testInput },
152
+ durationMs: Date.now() - startTime,
153
+ };
106
154
  }
107
-
@@ -8,7 +8,8 @@ export const ToolListPresentation: PresentationDescriptorV2 = {
8
8
  meta: {
9
9
  name: 'agent-console.tool.list',
10
10
  version: 1,
11
- description: 'List view of AI tools with category, status, and version info',
11
+ description:
12
+ 'List view of AI tools with category, status, and version info',
12
13
  domain: 'agent-console',
13
14
  owners: ['agent-console-team'],
14
15
  tags: ['tool', 'list', 'dashboard'],
@@ -30,7 +31,8 @@ export const ToolDetailPresentation: PresentationDescriptorV2 = {
30
31
  meta: {
31
32
  name: 'agent-console.tool.detail',
32
33
  version: 1,
33
- description: 'Detailed view of an AI tool with configuration and test panel',
34
+ description:
35
+ 'Detailed view of an AI tool with configuration and test panel',
34
36
  domain: 'agent-console',
35
37
  owners: ['agent-console-team'],
36
38
  tags: ['tool', 'detail'],
@@ -43,5 +45,3 @@ export const ToolDetailPresentation: PresentationDescriptorV2 = {
43
45
  targets: ['react', 'markdown'],
44
46
  policy: { flags: ['agent-console.enabled'] },
45
47
  };
46
-
47
-
@@ -131,4 +131,3 @@ export const UpdateToolInputModel = defineSchemaModel({
131
131
  },
132
132
  },
133
133
  });
134
-