@lota-sdk/core 0.1.11 → 0.1.12
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/package.json +2 -87
- package/src/ai/index.ts +3 -0
- package/src/bifrost/index.ts +1 -0
- package/src/config/agent-defaults.ts +30 -7
- package/src/config/constants.ts +0 -9
- package/src/config/debug-logger.ts +43 -0
- package/src/config/index.ts +5 -0
- package/src/config/model-constants.ts +0 -3
- package/src/config/workstream-defaults.ts +4 -0
- package/src/db/cursor-pagination.ts +2 -2
- package/src/db/index.ts +10 -0
- package/src/db/memory.ts +9 -15
- package/src/document/index.ts +2 -0
- package/src/document/parsing.ts +0 -25
- package/src/embeddings/provider.ts +17 -8
- package/src/index.ts +15 -505
- package/src/queues/index.ts +10 -0
- package/src/redis/connection-accessor.ts +26 -0
- package/src/redis/connection.ts +1 -1
- package/src/redis/index.ts +9 -25
- package/src/redis/org-memory-lock.ts +1 -1
- package/src/redis/redis-lease-lock.ts +1 -1
- package/src/redis/stream-context.ts +12 -2
- package/src/runtime/agent-runtime-policy.ts +9 -5
- package/src/runtime/agent-stream-helpers.ts +6 -3
- package/src/runtime/agent-types.ts +1 -5
- package/src/runtime/approval-continuation.ts +9 -1
- package/src/runtime/chat-attachments.ts +1 -1
- package/src/runtime/chat-request-routing.ts +1 -1
- package/src/runtime/context-compaction-runtime.ts +2 -2
- package/src/runtime/context-compaction.ts +1 -1
- package/src/runtime/execution-plan.ts +1 -1
- package/src/runtime/index.ts +26 -0
- package/src/runtime/indexed-repositories-policy.ts +10 -10
- package/src/runtime/memory-pipeline.ts +0 -2
- package/src/runtime/runtime-config.ts +238 -0
- package/src/runtime/runtime-extensions.ts +3 -2
- package/src/runtime/runtime-worker-registry.ts +47 -0
- package/src/runtime/team-consultation-orchestrator.ts +9 -6
- package/src/runtime/team-consultation-prompts.ts +3 -2
- package/src/runtime/turn-lifecycle.ts +1 -1
- package/src/runtime/workstream-chat-helpers.ts +0 -54
- package/src/runtime/workstream-routing-policy.ts +3 -7
- package/src/runtime.ts +387 -0
- package/src/services/chat-attachments.service.ts +1 -1
- package/src/services/context-compaction.service.ts +1 -1
- package/src/services/execution-plan.service.ts +14 -16
- package/src/services/index.ts +14 -0
- package/src/services/learned-skill.service.ts +80 -37
- package/src/services/memory.service.ts +5 -4
- package/src/services/mutating-approval.service.ts +1 -1
- package/src/services/organization-member.service.ts +1 -1
- package/src/services/organization.service.ts +1 -1
- package/src/services/plan-approval.service.ts +2 -2
- package/src/services/plan-artifact.service.ts +2 -3
- package/src/services/plan-builder.service.ts +1 -1
- package/src/services/plan-checkpoint.service.ts +2 -2
- package/src/services/plan-compiler.service.ts +2 -2
- package/src/services/plan-executor.service.ts +10 -9
- package/src/services/plan-run.service.ts +2 -2
- package/src/services/plan-validator.service.ts +4 -4
- package/src/services/recent-activity-title.service.ts +1 -1
- package/src/services/recent-activity.service.ts +14 -16
- package/src/services/user.service.ts +2 -2
- package/src/services/workstream-message.service.ts +2 -3
- package/src/services/workstream-title.service.ts +1 -1
- package/src/services/workstream-turn-preparation.ts +105 -50
- package/src/services/workstream-turn.ts +14 -1
- package/src/services/workstream.service.ts +9 -9
- package/src/storage/attachment-parser.ts +1 -1
- package/src/storage/attachment-storage.service.ts +11 -10
- package/src/storage/generated-document-storage.service.ts +7 -6
- package/src/storage/index.ts +10 -0
- package/src/system-agents/delegated-agent-factory.ts +78 -29
- package/src/system-agents/index.ts +4 -0
- package/src/system-agents/recent-activity-title-refiner.agent.ts +38 -3
- package/src/system-agents/regular-chat-memory-digest.agent.ts +1 -1
- package/src/system-agents/skill-extractor.agent.ts +1 -1
- package/src/system-agents/skill-manager.agent.ts +2 -4
- package/src/tools/execution-plan.tool.ts +2 -2
- package/src/tools/firecrawl-client.ts +2 -2
- package/src/tools/index.ts +12 -0
- package/src/tools/research-topic.tool.ts +1 -1
- package/src/tools/team-think.tool.ts +1 -1
- package/src/tools/user-questions.tool.ts +2 -2
- package/src/utils/index.ts +6 -0
- package/src/workers/bootstrap.ts +8 -16
- package/src/workers/index.ts +7 -0
- package/src/workers/regular-chat-memory-digest.runner.ts +1 -1
- package/src/workers/skill-extraction.runner.ts +1 -1
- package/src/workers/utils/{repo-indexer-chunker.ts → file-section-chunker.ts} +23 -52
- package/src/workers/utils/repo-structure-extractor.ts +2 -5
- package/src/workers/utils/repomix-file-sections.ts +42 -0
- package/src/config/env-shapes.ts +0 -121
- package/src/runtime/agent-contract.ts +0 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { FileSection, FileSectionChunk, FileSectionChunkOptions } from './file-section-chunker'
|
|
2
|
+
import { chunkFileSections } from './file-section-chunker'
|
|
3
|
+
|
|
4
|
+
const FILE_SECTION_HEADER_SOURCE = '^## File:\\s+(.+)$'
|
|
5
|
+
|
|
6
|
+
export function parseRepomixFileSections(repomixOutput: string): FileSection[] {
|
|
7
|
+
const source = repomixOutput.trim()
|
|
8
|
+
if (!source) return []
|
|
9
|
+
|
|
10
|
+
const matches = Array.from(source.matchAll(new RegExp(FILE_SECTION_HEADER_SOURCE, 'gm')))
|
|
11
|
+
if (matches.length === 0) {
|
|
12
|
+
return [{ kind: 'preamble', content: source }]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const sections: FileSection[] = []
|
|
16
|
+
const firstMatch = matches.at(0)
|
|
17
|
+
const firstIndex = firstMatch ? firstMatch.index : 0
|
|
18
|
+
if (firstIndex > 0) {
|
|
19
|
+
const preamble = source.slice(0, firstIndex).trim()
|
|
20
|
+
if (preamble) {
|
|
21
|
+
sections.push({ kind: 'preamble', content: preamble })
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
for (const [index, match] of matches.entries()) {
|
|
26
|
+
const start = match.index
|
|
27
|
+
const nextStart = matches[index + 1]?.index ?? source.length
|
|
28
|
+
const content = source.slice(start, nextStart).trim()
|
|
29
|
+
if (!content) continue
|
|
30
|
+
const filePath = (match[1] ?? '').trim()
|
|
31
|
+
sections.push({ kind: 'file', content, filePath: filePath || undefined })
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return sections
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export async function chunkRepomixFileSections(
|
|
38
|
+
repomixOutput: string,
|
|
39
|
+
options: FileSectionChunkOptions = {},
|
|
40
|
+
): Promise<FileSectionChunk[]> {
|
|
41
|
+
return await chunkFileSections(parseRepomixFileSections(repomixOutput), options)
|
|
42
|
+
}
|
package/src/config/env-shapes.ts
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import type { ZodTypeAny } from 'zod'
|
|
2
|
-
import { z } from 'zod'
|
|
3
|
-
|
|
4
|
-
const logLevelValues = ['trace', 'debug', 'info', 'warning', 'error', 'fatal'] as const
|
|
5
|
-
|
|
6
|
-
export const nodeServerEnvShape = {
|
|
7
|
-
NODE_ENV: z.enum(['development', 'production', 'test']).default('development'),
|
|
8
|
-
PORT: z.coerce.number().default(3000),
|
|
9
|
-
MAIN_CLIENT_URL: z.string().min(1).default('http://localhost:5173'),
|
|
10
|
-
} as const satisfies Record<string, ZodTypeAny>
|
|
11
|
-
|
|
12
|
-
export const surrealDbEnvShape = {
|
|
13
|
-
SURREALDB_URL: z.string().min(1, 'SurrealDB URL is required'),
|
|
14
|
-
SURREALDB_USER: z.string().min(1, 'SurrealDB user is required'),
|
|
15
|
-
SURREALDB_PASSWORD: z.string().min(1, 'SurrealDB password is required'),
|
|
16
|
-
SURREALDB_NAMESPACE: z.string().min(1, 'SurrealDB namespace is required'),
|
|
17
|
-
} as const satisfies Record<string, ZodTypeAny>
|
|
18
|
-
|
|
19
|
-
export const betterAuthEnvShape = {
|
|
20
|
-
BETTER_AUTH_SECRET: z.string().min(32, 'Better Auth secret must be at least 32 characters long'),
|
|
21
|
-
} as const satisfies Record<string, ZodTypeAny>
|
|
22
|
-
|
|
23
|
-
export const serverUrlEnvShape = { SERVER_URL: z.string().min(1, 'Server URL is required') } as const satisfies Record<
|
|
24
|
-
string,
|
|
25
|
-
ZodTypeAny
|
|
26
|
-
>
|
|
27
|
-
|
|
28
|
-
export const aiGatewayEnvShape = {
|
|
29
|
-
AI_GATEWAY_URL: z.string().url('AI gateway URL is required'),
|
|
30
|
-
AI_GATEWAY_KEY: z.string().min(1, 'AI gateway key is required'),
|
|
31
|
-
AI_GATEWAY_ADMIN: z.string().min(1).optional(),
|
|
32
|
-
AI_GATEWAY_PASS: z.string().min(1).optional(),
|
|
33
|
-
AI_EMBEDDING_MODEL: z.string().default('openai/text-embedding-3-small'),
|
|
34
|
-
} as const satisfies Record<string, ZodTypeAny>
|
|
35
|
-
|
|
36
|
-
export const firecrawlEnvShape = {
|
|
37
|
-
FIRECRAWL_API_KEY: z
|
|
38
|
-
.string()
|
|
39
|
-
.min(1, 'Firecrawl API key is required')
|
|
40
|
-
.refine((value) => value.startsWith('fc-'), 'Firecrawl API key must start with fc-')
|
|
41
|
-
.refine((value) => value !== 'dev-fire-key', 'Firecrawl API key placeholder is not allowed'),
|
|
42
|
-
FIRECRAWL_API_BASE_URL: z.string().url().optional(),
|
|
43
|
-
} as const satisfies Record<string, ZodTypeAny>
|
|
44
|
-
|
|
45
|
-
export const memorySearchEnvShape = {
|
|
46
|
-
MEMORY_SEARCH_K: z.coerce.number().int().positive().default(6),
|
|
47
|
-
} as const satisfies Record<string, ZodTypeAny>
|
|
48
|
-
|
|
49
|
-
export const redisEnvShape = { REDIS_URL: z.string().min(1, 'Redis URL is required') } as const satisfies Record<
|
|
50
|
-
string,
|
|
51
|
-
ZodTypeAny
|
|
52
|
-
>
|
|
53
|
-
|
|
54
|
-
export const s3StorageEnvShape = {
|
|
55
|
-
S3_ENDPOINT: z.string().min(1, 'S3 endpoint is required'),
|
|
56
|
-
S3_BUCKET: z.string().min(1, 'S3 bucket is required'),
|
|
57
|
-
S3_REGION: z.string().default('garage'),
|
|
58
|
-
S3_ACCESS_KEY_ID: z.string().min(1, 'S3 access key is required'),
|
|
59
|
-
S3_SECRET_ACCESS_KEY: z.string().min(1, 'S3 secret access key is required'),
|
|
60
|
-
ATTACHMENT_URL_EXPIRES_IN: z.coerce.number().positive('Attachment URL expiry must be positive').default(1800),
|
|
61
|
-
} as const satisfies Record<string, ZodTypeAny>
|
|
62
|
-
|
|
63
|
-
export const loggingEnvShape = { LOG_LEVEL: z.enum(logLevelValues).default('info') } as const satisfies Record<
|
|
64
|
-
string,
|
|
65
|
-
ZodTypeAny
|
|
66
|
-
>
|
|
67
|
-
|
|
68
|
-
export const githubAppEnvShape = {
|
|
69
|
-
GITHUB_APP_ID: z.string().optional(),
|
|
70
|
-
GITHUB_PRIVATE_KEY: z.string().optional(),
|
|
71
|
-
GITHUB_APP_SLUG: z.string().optional(),
|
|
72
|
-
} as const satisfies Record<string, ZodTypeAny>
|
|
73
|
-
|
|
74
|
-
export const linearOauthEnvShape = {
|
|
75
|
-
LINEAR_CLIENT_ID: z.string().optional(),
|
|
76
|
-
LINEAR_CLIENT_SECRET: z.string().optional(),
|
|
77
|
-
LINEAR_REDIRECT_URI: z.string().optional(),
|
|
78
|
-
} as const satisfies Record<string, ZodTypeAny>
|
|
79
|
-
|
|
80
|
-
export const marketingStudioEnvShape = {
|
|
81
|
-
MARKETING_STUDIO_BASE_URL: z.string().url().optional(),
|
|
82
|
-
MARKETING_STUDIO_ADMIN_API_KEY: z.string().min(1).optional(),
|
|
83
|
-
MARKETING_STUDIO_WEBHOOK_SIGNING_SECRET: z.string().min(1).optional(),
|
|
84
|
-
} as const satisfies Record<string, ZodTypeAny>
|
|
85
|
-
|
|
86
|
-
export function envKeys<TShape extends Record<string, ZodTypeAny>>(shape: TShape) {
|
|
87
|
-
return Object.freeze(Object.keys(shape)) as readonly Extract<keyof TShape, string>[]
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const lotaSdkEnvSchema = z.object({
|
|
91
|
-
...aiGatewayEnvShape,
|
|
92
|
-
...memorySearchEnvShape,
|
|
93
|
-
...redisEnvShape,
|
|
94
|
-
...loggingEnvShape,
|
|
95
|
-
...s3StorageEnvShape,
|
|
96
|
-
...firecrawlEnvShape,
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
export const lotaSdkEnvKeys = Object.freeze([
|
|
100
|
-
...envKeys(aiGatewayEnvShape),
|
|
101
|
-
...envKeys(memorySearchEnvShape),
|
|
102
|
-
...envKeys(redisEnvShape),
|
|
103
|
-
...envKeys(loggingEnvShape),
|
|
104
|
-
...envKeys(s3StorageEnvShape),
|
|
105
|
-
...envKeys(firecrawlEnvShape),
|
|
106
|
-
]) as readonly string[]
|
|
107
|
-
|
|
108
|
-
type LotaSdkEnv = z.infer<typeof lotaSdkEnvSchema>
|
|
109
|
-
|
|
110
|
-
let _env: LotaSdkEnv | undefined
|
|
111
|
-
|
|
112
|
-
export function setEnv(value: LotaSdkEnv): void {
|
|
113
|
-
_env = value
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export const env: LotaSdkEnv = new Proxy({} as LotaSdkEnv, {
|
|
117
|
-
get(_target, prop: string) {
|
|
118
|
-
if (!_env) throw new Error(`lota-sdk env not configured. Call setEnv() before accessing env.${prop}`)
|
|
119
|
-
return (_env as Record<string, unknown>)[prop]
|
|
120
|
-
},
|
|
121
|
-
})
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type AgentSkill = string
|