@elevasis/core 0.46.0 → 0.48.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.
@@ -26,10 +26,15 @@ export type OpenRouterModel = 'openrouter/z-ai/glm-5'
26
26
  */
27
27
  export type GoogleModel = 'gemini-3-flash-preview' | 'gemini-3.1-flash-lite-preview'
28
28
 
29
- /**
30
- * Supported Anthropic models (direct SDK access via @anthropic-ai/sdk)
31
- */
32
- export type AnthropicModel = 'claude-sonnet-4-5'
29
+ /**
30
+ * Supported Anthropic models (direct SDK access via @anthropic-ai/sdk)
31
+ */
32
+ export type AnthropicModel =
33
+ | 'claude-opus-4-8'
34
+ | 'claude-sonnet-4-6'
35
+ | 'claude-haiku-4-5-20251001'
36
+ | 'claude-haiku-4-5'
37
+ | 'claude-sonnet-4-5'
33
38
 
34
39
  /** Supported LLM models */
35
40
  export type LLMModel = OpenAIModel | OpenRouterModel | GoogleModel | AnthropicModel | 'mock'
@@ -122,26 +127,48 @@ export const GoogleConfigSchema = z.object({
122
127
  modelOptions: GoogleOptionsSchema.optional()
123
128
  })
124
129
 
125
- /**
126
- * Anthropic model options schema
127
- * Currently empty - future options: budget_tokens for extended thinking
128
- */
129
- const AnthropicOptionsSchema = z.object({})
130
-
131
- /**
132
- * Anthropic config schema
133
- * Validates ModelConfig for Anthropic provider (direct SDK access)
134
- */
135
- export const AnthropicConfigSchema = z.object({
136
- model: z.enum(['claude-sonnet-4-5']),
137
- provider: z.literal('anthropic'),
138
- apiKey: z.string(),
139
- temperature: z.number().min(0).max(1).optional(),
140
- maxOutputTokens: z.number().min(1000).optional(), // Anthropic requires max_tokens
141
- topP: z.number().min(0).max(1).optional(),
142
- modelOptions: AnthropicOptionsSchema.optional()
143
- })
130
+ /**
131
+ * Anthropic model options schema
132
+ * Currently empty - future options must be added per supported model family
133
+ */
134
+ const AnthropicOptionsSchema = z.object({}).strict()
144
135
 
136
+ /**
137
+ * Anthropic config schema
138
+ * Validates ModelConfig for Anthropic provider (direct SDK access)
139
+ */
140
+ const AnthropicStandardConfigSchema = z.object({
141
+ model: z.enum([
142
+ 'claude-sonnet-4-6',
143
+ 'claude-haiku-4-5-20251001',
144
+ 'claude-haiku-4-5',
145
+ 'claude-sonnet-4-5'
146
+ ]),
147
+ provider: z.literal('anthropic'),
148
+ apiKey: z.string(),
149
+ temperature: z.number().min(0).max(1).optional(),
150
+ maxOutputTokens: z.number().min(1000).max(64000).optional(), // Anthropic requires max_tokens
151
+ topP: z.number().min(0).max(1).optional(),
152
+ modelOptions: AnthropicOptionsSchema.optional()
153
+ })
154
+
155
+ const AnthropicOpus48ConfigSchema = z.object({
156
+ model: z.literal('claude-opus-4-8'),
157
+ provider: z.literal('anthropic'),
158
+ apiKey: z.string(),
159
+ temperature: z.literal(1).optional(),
160
+ maxOutputTokens: z.number().min(1000).max(128000).optional(), // Anthropic requires max_tokens
161
+ topP: z.literal(1).optional(),
162
+ topK: z.undefined().optional(),
163
+ top_k: z.undefined().optional(),
164
+ modelOptions: AnthropicOptionsSchema.optional()
165
+ })
166
+
167
+ export const AnthropicConfigSchema = z.discriminatedUnion('model', [
168
+ AnthropicOpus48ConfigSchema,
169
+ AnthropicStandardConfigSchema
170
+ ])
171
+
145
172
  /**
146
173
  * Infer TypeScript types from schemas
147
174
  */
@@ -191,16 +218,18 @@ export interface ModelInfo {
191
218
  minTokens: number
192
219
  /** Recommended tokens for production use (typically 2x minimum) */
193
220
  recommendedTokens: number
194
- /** Maximum context window size (total tokens: input + output) */
195
- maxTokens: number
196
- /** Model category for grouping and documentation */
197
- category: 'reasoning' | 'standard' | 'embedding'
198
- /** Zod schema for validating complete ModelConfig (replaces constraints + optionsSchema) */
199
- configSchema?: z.ZodType<ModelConfig>
200
- }
221
+ /** Maximum context window size (total tokens: input + output) */
222
+ maxTokens: number
223
+ /** Maximum output tokens supported by the synchronous generation API */
224
+ maxOutputTokens?: number
225
+ /** Model category for grouping and documentation */
226
+ category: 'reasoning' | 'standard' | 'embedding'
227
+ /** Zod schema for validating complete ModelConfig (replaces constraints + optionsSchema) */
228
+ configSchema?: z.ZodType<ModelConfig>
229
+ }
201
230
 
202
- // Model configuration as of 2026-03-17
203
- export const MODEL_INFO: Record<LLMModel, ModelInfo> = {
231
+ // Model configuration as of 2026-06-09
232
+ export const MODEL_INFO: Record<LLMModel, ModelInfo> = {
204
233
  // OpenAI GPT-5 (Reasoning Models)
205
234
  'gpt-5': {
206
235
  inputCostPer1M: 125, // $1.25 per 1M tokens
@@ -268,17 +297,58 @@ export const MODEL_INFO: Record<LLMModel, ModelInfo> = {
268
297
  category: 'standard',
269
298
  configSchema: GoogleConfigSchema
270
299
  },
271
- // Anthropic Claude Models (direct SDK access via @anthropic-ai/sdk)
272
- 'claude-sonnet-4-5': {
273
- inputCostPer1M: 300, // $3.00 per 1M tokens
274
- outputCostPer1M: 1500, // $15.00 per 1M tokens
275
- minTokens: 4000,
276
- recommendedTokens: 8000,
277
- maxTokens: 200000, // 200k context window
278
- category: 'standard',
279
- configSchema: AnthropicConfigSchema
280
- }
281
- }
300
+ // Anthropic Claude Models (direct SDK access via @anthropic-ai/sdk)
301
+ 'claude-opus-4-8': {
302
+ inputCostPer1M: 500, // $5.00 per 1M tokens
303
+ outputCostPer1M: 2500, // $25.00 per 1M tokens
304
+ minTokens: 4000,
305
+ recommendedTokens: 8000,
306
+ maxTokens: 1000000, // 1M context window
307
+ maxOutputTokens: 128000,
308
+ category: 'reasoning',
309
+ configSchema: AnthropicConfigSchema
310
+ },
311
+ 'claude-sonnet-4-6': {
312
+ inputCostPer1M: 300, // $3.00 per 1M tokens
313
+ outputCostPer1M: 1500, // $15.00 per 1M tokens
314
+ minTokens: 4000,
315
+ recommendedTokens: 8000,
316
+ maxTokens: 1000000, // 1M context window
317
+ maxOutputTokens: 64000,
318
+ category: 'standard',
319
+ configSchema: AnthropicConfigSchema
320
+ },
321
+ 'claude-haiku-4-5-20251001': {
322
+ inputCostPer1M: 100, // $1.00 per 1M tokens
323
+ outputCostPer1M: 500, // $5.00 per 1M tokens
324
+ minTokens: 4000,
325
+ recommendedTokens: 8000,
326
+ maxTokens: 200000, // 200k context window
327
+ maxOutputTokens: 64000,
328
+ category: 'standard',
329
+ configSchema: AnthropicConfigSchema
330
+ },
331
+ 'claude-haiku-4-5': {
332
+ inputCostPer1M: 100, // $1.00 per 1M tokens
333
+ outputCostPer1M: 500, // $5.00 per 1M tokens
334
+ minTokens: 4000,
335
+ recommendedTokens: 8000,
336
+ maxTokens: 200000, // 200k context window
337
+ maxOutputTokens: 64000,
338
+ category: 'standard',
339
+ configSchema: AnthropicConfigSchema
340
+ },
341
+ 'claude-sonnet-4-5': {
342
+ inputCostPer1M: 300, // $3.00 per 1M tokens
343
+ outputCostPer1M: 1500, // $15.00 per 1M tokens
344
+ minTokens: 4000,
345
+ recommendedTokens: 8000,
346
+ maxTokens: 200000, // 200k context window
347
+ maxOutputTokens: 64000,
348
+ category: 'standard',
349
+ configSchema: AnthropicConfigSchema
350
+ }
351
+ }
282
352
 
283
353
  /**
284
354
  * Get model information (pricing and token requirements)
@@ -1,6 +1,7 @@
1
1
  import { describe, expect, it } from 'vitest'
2
2
  import { bySystem, byOntology, byKind, byOwner, governs, governedBy, parsePath, omSearch, omDescribe } from '../queries'
3
3
  import { byOntology as publicByOntology } from '../index'
4
+ import { byOntology as publishedByOntology } from '../published'
4
5
  import { formatText, formatJson, formatIdsOnly, formatOmSearchHits, formatOmDescribe } from '../format'
5
6
  import type { OrganizationGraph } from '../../organization-model/graph/types'
6
7
  import type { OrgKnowledgeNode } from '../../organization-model/domains/knowledge'
@@ -259,6 +260,13 @@ describe('byOntology', () => {
259
260
  'knowledge.playbook-d'
260
261
  ])
261
262
  })
263
+
264
+ it('is exported from the published knowledge API', () => {
265
+ expect(publishedByOntology).toBe(byOntology)
266
+ expect(publishedByOntology(GRAPH, 'sales.crm:object/deal', NODES).map((node) => node.id)).toEqual([
267
+ 'knowledge.playbook-d'
268
+ ])
269
+ })
262
270
  })
263
271
 
264
272
  // ---------------------------------------------------------------------------
@@ -1,4 +1,4 @@
1
- export { bySystem, byKind, byOwner, governs, governedBy, parsePath } from './queries'
1
+ export { bySystem, byOntology, byKind, byOwner, governs, governedBy, parsePath } from './queries'
2
2
  export type { KnowledgeMount, ParsedKnowledgePath, OmSearchHitKind } from './queries'
3
3
 
4
4
  export { formatText, formatJson, formatIdsOnly } from './format'
@@ -22,17 +22,19 @@ export type {
22
22
 
23
23
  // Session validation schemas
24
24
  export {
25
- CreateSessionSchema,
26
- ExecuteTurnSchema,
27
- ListSessionsQuerySchema,
28
- SessionIdParamSchema,
29
- ExecutionIdParamsSchema,
30
- WebSocketSessionTurnSchema,
31
- type CreateSessionInput,
32
- type ExecuteTurnInput,
33
- type ListSessionsQuery,
34
- type WebSocketSessionTurnMessage
35
- } from './sessions'
25
+ CreateSessionSchema,
26
+ ExecuteTurnSchema,
27
+ ListSessionsQuerySchema,
28
+ SessionMessagesQuerySchema,
29
+ SessionIdParamSchema,
30
+ ExecutionIdParamsSchema,
31
+ WebSocketSessionTurnSchema,
32
+ type CreateSessionInput,
33
+ type ExecuteTurnInput,
34
+ type ListSessionsQuery,
35
+ type SessionMessagesQuery,
36
+ type WebSocketSessionTurnMessage
37
+ } from './sessions'
36
38
 
37
39
  // Notification types and validation schemas
38
40
  export * from './notifications/index'
@@ -46,5 +48,8 @@ export * from './activities/index'
46
48
  // Triggers (includes webhook providers and trigger definitions)
47
49
  export * from './triggers/index'
48
50
 
49
- // Debug Logs
50
- export * from './debug-logs/index'
51
+ // Debug Logs
52
+ export * from './debug-logs/index'
53
+
54
+ // Public agent chat route schemas
55
+ export * from './public-agent-chat'
@@ -0,0 +1,40 @@
1
+ import { z } from 'zod'
2
+ import { UuidSchema } from '../../platform/utils/validation'
3
+
4
+ export const PublicAgentChatSlugParamSchema = z
5
+ .object({
6
+ slug: z.string().min(1).max(120).regex(/^[a-zA-Z0-9._-]+$/)
7
+ })
8
+ .strict()
9
+
10
+ export const PublicAgentChatSessionParamSchema = z
11
+ .object({
12
+ sessionId: UuidSchema
13
+ })
14
+ .strict()
15
+
16
+ export const PublicAgentChatAuthorizeSchema = z
17
+ .object({
18
+ code: z.string().min(1).max(200).optional(),
19
+ visitorId: z.string().min(1).max(120).optional()
20
+ })
21
+ .strict()
22
+
23
+ export const PublicAgentChatCreateSessionSchema = z
24
+ .object({
25
+ capabilityToken: z.string().min(32).optional(),
26
+ metadata: z.record(z.string(), z.unknown()).optional()
27
+ })
28
+ .strict()
29
+
30
+ export const PublicAgentChatCapabilityQuerySchema = z
31
+ .object({
32
+ token: z.string().min(32)
33
+ })
34
+ .strict()
35
+
36
+ export type PublicAgentChatSlugParams = z.infer<typeof PublicAgentChatSlugParamSchema>
37
+ export type PublicAgentChatSessionParams = z.infer<typeof PublicAgentChatSessionParamSchema>
38
+ export type PublicAgentChatAuthorizeInput = z.infer<typeof PublicAgentChatAuthorizeSchema>
39
+ export type PublicAgentChatCreateSessionInput = z.infer<typeof PublicAgentChatCreateSessionSchema>
40
+ export type PublicAgentChatCapabilityQuery = z.infer<typeof PublicAgentChatCapabilityQuerySchema>
@@ -0,0 +1,12 @@
1
+ export {
2
+ PublicAgentChatSlugParamSchema,
3
+ PublicAgentChatSessionParamSchema,
4
+ PublicAgentChatAuthorizeSchema,
5
+ PublicAgentChatCreateSessionSchema,
6
+ PublicAgentChatCapabilityQuerySchema,
7
+ type PublicAgentChatSlugParams,
8
+ type PublicAgentChatSessionParams,
9
+ type PublicAgentChatAuthorizeInput,
10
+ type PublicAgentChatCreateSessionInput,
11
+ type PublicAgentChatCapabilityQuery
12
+ } from './api-schemas'
@@ -113,13 +113,32 @@ export const ExecuteTurnSchema = z
113
113
  * - resourceId validated as string (resource identifiers)
114
114
  * - Limit bounded (prevents DoS via large result sets)
115
115
  */
116
- export const ListSessionsQuerySchema = z
117
- .object({
118
- userId: UuidSchema.optional(),
119
- resourceId: z.string().optional(),
120
- limit: z.coerce.number().int().min(1).max(100).default(20)
121
- })
122
- .strict()
116
+ export const ListSessionsQuerySchema = z
117
+ .object({
118
+ userId: UuidSchema.optional(),
119
+ resourceId: z.string().optional(),
120
+ limit: z.coerce.number().int().min(1).max(100).default(20)
121
+ })
122
+ .strict()
123
+
124
+ /**
125
+ * Get session messages with cursor pagination
126
+ * GET /sessions/:sessionId/messages
127
+ *
128
+ * Cursor:
129
+ * - cursor is the last seen message_index
130
+ * - next page returns rows where message_index > cursor
131
+ *
132
+ * Security:
133
+ * - Limit bounded to prevent unbounded transcript reads
134
+ * - Cursor coerced and validated as a non-negative integer
135
+ */
136
+ export const SessionMessagesQuerySchema = z
137
+ .object({
138
+ limit: z.coerce.number().int().min(1).max(100).default(100),
139
+ cursor: z.coerce.number().int().min(0).optional()
140
+ })
141
+ .strict()
123
142
 
124
143
  // ============================================================================
125
144
  // WebSocket Messages
@@ -160,7 +179,8 @@ export const WebSocketSessionTurnSchema = z
160
179
  // ============================================================================
161
180
 
162
181
  // Export inferred types for use in route handlers
163
- export type CreateSessionInput = z.infer<typeof CreateSessionSchema>
164
- export type ExecuteTurnInput = z.infer<typeof ExecuteTurnSchema>
165
- export type ListSessionsQuery = z.infer<typeof ListSessionsQuerySchema>
166
- export type WebSocketSessionTurnMessage = z.infer<typeof WebSocketSessionTurnSchema>
182
+ export type CreateSessionInput = z.infer<typeof CreateSessionSchema>
183
+ export type ExecuteTurnInput = z.infer<typeof ExecuteTurnSchema>
184
+ export type ListSessionsQuery = z.infer<typeof ListSessionsQuerySchema>
185
+ export type SessionMessagesQuery = z.infer<typeof SessionMessagesQuerySchema>
186
+ export type WebSocketSessionTurnMessage = z.infer<typeof WebSocketSessionTurnSchema>
@@ -12,15 +12,17 @@ export type {
12
12
 
13
13
  // Export validation schemas
14
14
  export {
15
- CreateSessionSchema,
16
- ExecuteTurnSchema,
17
- ListSessionsQuerySchema,
18
- SessionIdParamSchema,
19
- ExecutionIdParamsSchema,
20
- WebSocketSessionTurnSchema,
21
- UuidSchema,
22
- type CreateSessionInput,
23
- type ExecuteTurnInput,
24
- type ListSessionsQuery,
25
- type WebSocketSessionTurnMessage
26
- } from './api-schemas'
15
+ CreateSessionSchema,
16
+ ExecuteTurnSchema,
17
+ ListSessionsQuerySchema,
18
+ SessionMessagesQuerySchema,
19
+ SessionIdParamSchema,
20
+ ExecutionIdParamsSchema,
21
+ WebSocketSessionTurnSchema,
22
+ UuidSchema,
23
+ type CreateSessionInput,
24
+ type ExecuteTurnInput,
25
+ type ListSessionsQuery,
26
+ type SessionMessagesQuery,
27
+ type WebSocketSessionTurnMessage
28
+ } from './api-schemas'
@@ -1,3 +1,3 @@
1
1
  export const VERSION = {
2
- CURRENT: '1.12.19'
2
+ CURRENT: '1.13.4'
3
3
  }
@@ -2118,6 +2118,138 @@ export type Database = {
2118
2118
  }
2119
2119
  Relationships: []
2120
2120
  }
2121
+ agent_access_grants: {
2122
+ Row: {
2123
+ allowed_origins: string[]
2124
+ branding: Json
2125
+ capture_fields: Json
2126
+ code_hash: string | null
2127
+ code_salt: string | null
2128
+ created_at: string
2129
+ disabled_at: string | null
2130
+ expires_at: string | null
2131
+ id: string
2132
+ max_sessions_per_visitor: number
2133
+ max_turns_per_session: number
2134
+ mode: string
2135
+ organization_id: string
2136
+ resource_id: string
2137
+ slug: string
2138
+ tool_policy: Json
2139
+ updated_at: string
2140
+ }
2141
+ Insert: {
2142
+ allowed_origins?: string[]
2143
+ branding?: Json
2144
+ capture_fields?: Json
2145
+ code_hash?: string | null
2146
+ code_salt?: string | null
2147
+ created_at?: string
2148
+ disabled_at?: string | null
2149
+ expires_at?: string | null
2150
+ id?: string
2151
+ max_sessions_per_visitor?: number
2152
+ max_turns_per_session?: number
2153
+ mode?: string
2154
+ organization_id: string
2155
+ resource_id: string
2156
+ slug: string
2157
+ tool_policy?: Json
2158
+ updated_at?: string
2159
+ }
2160
+ Update: {
2161
+ allowed_origins?: string[]
2162
+ branding?: Json
2163
+ capture_fields?: Json
2164
+ code_hash?: string | null
2165
+ code_salt?: string | null
2166
+ created_at?: string
2167
+ disabled_at?: string | null
2168
+ expires_at?: string | null
2169
+ id?: string
2170
+ max_sessions_per_visitor?: number
2171
+ max_turns_per_session?: number
2172
+ mode?: string
2173
+ organization_id?: string
2174
+ resource_id?: string
2175
+ slug?: string
2176
+ tool_policy?: Json
2177
+ updated_at?: string
2178
+ }
2179
+ Relationships: [
2180
+ {
2181
+ foreignKeyName: "agent_access_grants_organization_id_fkey"
2182
+ columns: ["organization_id"]
2183
+ isOneToOne: false
2184
+ referencedRelation: "organizations"
2185
+ referencedColumns: ["id"]
2186
+ },
2187
+ ]
2188
+ }
2189
+ agent_chat_capabilities: {
2190
+ Row: {
2191
+ created_at: string
2192
+ expires_at: string
2193
+ grant_id: string
2194
+ id: string
2195
+ organization_id: string
2196
+ origin: string | null
2197
+ resource_id: string
2198
+ revoked_at: string | null
2199
+ session_id: string | null
2200
+ token_hash: string
2201
+ visitor_id: string | null
2202
+ }
2203
+ Insert: {
2204
+ created_at?: string
2205
+ expires_at: string
2206
+ grant_id: string
2207
+ id?: string
2208
+ organization_id: string
2209
+ origin?: string | null
2210
+ resource_id: string
2211
+ revoked_at?: string | null
2212
+ session_id?: string | null
2213
+ token_hash: string
2214
+ visitor_id?: string | null
2215
+ }
2216
+ Update: {
2217
+ created_at?: string
2218
+ expires_at?: string
2219
+ grant_id?: string
2220
+ id?: string
2221
+ organization_id?: string
2222
+ origin?: string | null
2223
+ resource_id?: string
2224
+ revoked_at?: string | null
2225
+ session_id?: string | null
2226
+ token_hash?: string
2227
+ visitor_id?: string | null
2228
+ }
2229
+ Relationships: [
2230
+ {
2231
+ foreignKeyName: "agent_chat_capabilities_grant_id_fkey"
2232
+ columns: ["grant_id"]
2233
+ isOneToOne: false
2234
+ referencedRelation: "agent_access_grants"
2235
+ referencedColumns: ["id"]
2236
+ },
2237
+ {
2238
+ foreignKeyName: "agent_chat_capabilities_organization_id_fkey"
2239
+ columns: ["organization_id"]
2240
+ isOneToOne: false
2241
+ referencedRelation: "organizations"
2242
+ referencedColumns: ["id"]
2243
+ },
2244
+ {
2245
+ foreignKeyName: "agent_chat_capabilities_session_id_fkey"
2246
+ columns: ["session_id"]
2247
+ isOneToOne: false
2248
+ referencedRelation: "sessions"
2249
+ referencedColumns: ["session_id"]
2250
+ },
2251
+ ]
2252
+ }
2121
2253
  organizations: {
2122
2254
  Row: {
2123
2255
  config: Json