@lota-sdk/core 0.1.5
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/infrastructure/schema/00_workstream.surql +55 -0
- package/infrastructure/schema/01_memory.surql +47 -0
- package/infrastructure/schema/02_execution_plan.surql +62 -0
- package/infrastructure/schema/03_learned_skill.surql +32 -0
- package/infrastructure/schema/04_runtime_bootstrap.surql +8 -0
- package/package.json +128 -0
- package/src/ai/definitions.ts +308 -0
- package/src/bifrost/bifrost.ts +256 -0
- package/src/config/agent-defaults.ts +99 -0
- package/src/config/constants.ts +33 -0
- package/src/config/env-shapes.ts +122 -0
- package/src/config/logger.ts +29 -0
- package/src/config/model-constants.ts +31 -0
- package/src/config/search.ts +17 -0
- package/src/config/workstream-defaults.ts +68 -0
- package/src/db/base.service.ts +55 -0
- package/src/db/cursor-pagination.ts +73 -0
- package/src/db/memory-query-builder.ts +207 -0
- package/src/db/memory-store.helpers.ts +118 -0
- package/src/db/memory-store.rows.ts +29 -0
- package/src/db/memory-store.ts +974 -0
- package/src/db/memory-types.ts +193 -0
- package/src/db/memory.ts +505 -0
- package/src/db/record-id.ts +78 -0
- package/src/db/service.ts +932 -0
- package/src/db/startup.ts +152 -0
- package/src/db/tables.ts +20 -0
- package/src/document/org-document-chunking.ts +224 -0
- package/src/document/parsing.ts +40 -0
- package/src/embeddings/provider.ts +76 -0
- package/src/index.ts +302 -0
- package/src/queues/context-compaction.queue.ts +82 -0
- package/src/queues/document-processor.queue.ts +118 -0
- package/src/queues/memory-consolidation.queue.ts +65 -0
- package/src/queues/post-chat-memory.queue.ts +128 -0
- package/src/queues/recent-activity-title-refinement.queue.ts +69 -0
- package/src/queues/regular-chat-memory-digest.config.ts +12 -0
- package/src/queues/regular-chat-memory-digest.queue.ts +73 -0
- package/src/queues/skill-extraction.config.ts +9 -0
- package/src/queues/skill-extraction.queue.ts +62 -0
- package/src/redis/connection.ts +176 -0
- package/src/redis/index.ts +30 -0
- package/src/redis/org-memory-lock.ts +43 -0
- package/src/redis/redis-lease-lock.ts +158 -0
- package/src/runtime/agent-contract.ts +1 -0
- package/src/runtime/agent-prompt-context.ts +119 -0
- package/src/runtime/agent-runtime-policy.ts +192 -0
- package/src/runtime/agent-stream-helpers.ts +117 -0
- package/src/runtime/agent-types.ts +22 -0
- package/src/runtime/approval-continuation.ts +16 -0
- package/src/runtime/chat-attachments.ts +46 -0
- package/src/runtime/chat-message.ts +10 -0
- package/src/runtime/chat-request-routing.ts +21 -0
- package/src/runtime/chat-run-orchestration.ts +25 -0
- package/src/runtime/chat-run-registry.ts +20 -0
- package/src/runtime/chat-types.ts +18 -0
- package/src/runtime/context-compaction-constants.ts +11 -0
- package/src/runtime/context-compaction-runtime.ts +86 -0
- package/src/runtime/context-compaction.ts +909 -0
- package/src/runtime/execution-plan.ts +59 -0
- package/src/runtime/helper-model.ts +405 -0
- package/src/runtime/indexed-repositories-policy.ts +28 -0
- package/src/runtime/instruction-sections.ts +8 -0
- package/src/runtime/llm-content.ts +71 -0
- package/src/runtime/memory-block.ts +264 -0
- package/src/runtime/memory-digest-policy.ts +14 -0
- package/src/runtime/memory-format.ts +8 -0
- package/src/runtime/memory-pipeline.ts +570 -0
- package/src/runtime/memory-prompts-fact.ts +47 -0
- package/src/runtime/memory-prompts-parse.ts +3 -0
- package/src/runtime/memory-prompts-update.ts +37 -0
- package/src/runtime/memory-scope.ts +43 -0
- package/src/runtime/plugin-types.ts +10 -0
- package/src/runtime/retrieval-adapters.ts +25 -0
- package/src/runtime/retrieval-pipeline.ts +3 -0
- package/src/runtime/runtime-extensions.ts +154 -0
- package/src/runtime/skill-extraction-policy.ts +3 -0
- package/src/runtime/team-consultation-orchestrator.ts +245 -0
- package/src/runtime/team-consultation-prompts.ts +32 -0
- package/src/runtime/title-helpers.ts +12 -0
- package/src/runtime/turn-lifecycle.ts +28 -0
- package/src/runtime/workstream-chat-helpers.ts +187 -0
- package/src/runtime/workstream-routing-policy.ts +301 -0
- package/src/runtime/workstream-state.ts +261 -0
- package/src/services/attachment.service.ts +159 -0
- package/src/services/chat-attachments.service.ts +17 -0
- package/src/services/chat-run-registry.service.ts +3 -0
- package/src/services/context-compaction-runtime.ts +13 -0
- package/src/services/context-compaction.service.ts +115 -0
- package/src/services/document-chunk.service.ts +141 -0
- package/src/services/execution-plan.service.ts +890 -0
- package/src/services/learned-skill.service.ts +328 -0
- package/src/services/memory-assessment.service.ts +43 -0
- package/src/services/memory.service.ts +807 -0
- package/src/services/memory.utils.ts +84 -0
- package/src/services/mutating-approval.service.ts +110 -0
- package/src/services/recent-activity-title.service.ts +74 -0
- package/src/services/recent-activity.service.ts +397 -0
- package/src/services/workstream-change-tracker.service.ts +313 -0
- package/src/services/workstream-message.service.ts +283 -0
- package/src/services/workstream-title.service.ts +58 -0
- package/src/services/workstream-turn-preparation.ts +1340 -0
- package/src/services/workstream-turn.ts +37 -0
- package/src/services/workstream.service.ts +854 -0
- package/src/services/workstream.types.ts +118 -0
- package/src/storage/attachment-parser.ts +101 -0
- package/src/storage/attachment-storage.service.ts +391 -0
- package/src/storage/attachments.types.ts +11 -0
- package/src/storage/attachments.utils.ts +58 -0
- package/src/storage/generated-document-storage.service.ts +55 -0
- package/src/system-agents/agent-result.ts +27 -0
- package/src/system-agents/context-compacter.agent.ts +46 -0
- package/src/system-agents/delegated-agent-factory.ts +177 -0
- package/src/system-agents/helper-agent-options.ts +20 -0
- package/src/system-agents/memory-reranker.agent.ts +38 -0
- package/src/system-agents/memory.agent.ts +58 -0
- package/src/system-agents/recent-activity-title-refiner.agent.ts +53 -0
- package/src/system-agents/regular-chat-memory-digest.agent.ts +75 -0
- package/src/system-agents/researcher.agent.ts +34 -0
- package/src/system-agents/skill-extractor.agent.ts +88 -0
- package/src/system-agents/skill-manager.agent.ts +80 -0
- package/src/system-agents/title-generator.agent.ts +42 -0
- package/src/system-agents/workstream-tracker.agent.ts +58 -0
- package/src/tools/execution-plan.tool.ts +163 -0
- package/src/tools/fetch-webpage.tool.ts +132 -0
- package/src/tools/firecrawl-client.ts +12 -0
- package/src/tools/memory-block.tool.ts +55 -0
- package/src/tools/read-file-parts.tool.ts +80 -0
- package/src/tools/remember-memory.tool.ts +85 -0
- package/src/tools/research-topic.tool.ts +15 -0
- package/src/tools/search-tools.ts +55 -0
- package/src/tools/search-web.tool.ts +175 -0
- package/src/tools/team-think.tool.ts +125 -0
- package/src/tools/tool-contract.ts +21 -0
- package/src/tools/user-questions.tool.ts +18 -0
- package/src/utils/async.ts +50 -0
- package/src/utils/date-time.ts +34 -0
- package/src/utils/error.ts +10 -0
- package/src/utils/errors.ts +28 -0
- package/src/utils/hono-error-handler.ts +71 -0
- package/src/utils/string.ts +51 -0
- package/src/workers/bootstrap.ts +44 -0
- package/src/workers/memory-consolidation.worker.ts +318 -0
- package/src/workers/regular-chat-memory-digest.helpers.ts +100 -0
- package/src/workers/regular-chat-memory-digest.runner.ts +363 -0
- package/src/workers/regular-chat-memory-digest.worker.ts +22 -0
- package/src/workers/skill-extraction.runner.ts +331 -0
- package/src/workers/skill-extraction.worker.ts +22 -0
- package/src/workers/utils/repo-indexer-chunker.ts +331 -0
- package/src/workers/utils/repo-structure-extractor.ts +645 -0
- package/src/workers/utils/repomix-process-concurrency.ts +65 -0
- package/src/workers/utils/sandbox-error.ts +5 -0
- package/src/workers/worker-utils.ts +182 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { createContextCompacterAgent } from '../system-agents/context-compacter.agent'
|
|
2
|
+
import {
|
|
3
|
+
buildContextCompactionPrompt,
|
|
4
|
+
buildMemoryBlockCompactionPrompt,
|
|
5
|
+
createContextCompactionRuntime,
|
|
6
|
+
parseCompactionOutput,
|
|
7
|
+
} from './context-compaction'
|
|
8
|
+
import type { ContextCompactionRunnerParams } from './context-compaction'
|
|
9
|
+
import {
|
|
10
|
+
COMPACTION_CHUNK_MAX_CHARS,
|
|
11
|
+
CONTEXT_COMPACTION_INCLUDED_TOOL_NAMES,
|
|
12
|
+
CONTEXT_COMPACTION_INCLUDED_TOOL_PREFIXES,
|
|
13
|
+
CONTEXT_COMPACTION_THRESHOLD_RATIO,
|
|
14
|
+
CONTEXT_OUTPUT_RESERVE_TOKENS,
|
|
15
|
+
CONTEXT_SAFETY_MARGIN_TOKENS,
|
|
16
|
+
SUMMARY_ROLLUP_MAX_TOKENS,
|
|
17
|
+
} from './context-compaction-constants'
|
|
18
|
+
import type { GenerateHelperStructuredParams, GenerateHelperTextParams } from './helper-model'
|
|
19
|
+
import { StructuredCompactionOutputSchema } from './workstream-state'
|
|
20
|
+
|
|
21
|
+
export interface HelperModelRuntime {
|
|
22
|
+
generateHelperStructured<T>(params: GenerateHelperStructuredParams<T>): Promise<T>
|
|
23
|
+
generateHelperText(params: GenerateHelperTextParams): Promise<string>
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface CreateContextCompactionRuntimeDeps {
|
|
27
|
+
helperModelRuntime: HelperModelRuntime
|
|
28
|
+
now?: () => number
|
|
29
|
+
randomId?: () => string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function runContextCompacter(helperModelRuntime: HelperModelRuntime, params: ContextCompactionRunnerParams) {
|
|
33
|
+
const output = await helperModelRuntime.generateHelperStructured({
|
|
34
|
+
tag: 'context-compaction',
|
|
35
|
+
createAgent: createContextCompacterAgent,
|
|
36
|
+
messages: [
|
|
37
|
+
{
|
|
38
|
+
role: 'user',
|
|
39
|
+
content: buildContextCompactionPrompt({
|
|
40
|
+
previousSummary: params.previousSummary,
|
|
41
|
+
existingState: params.existingState,
|
|
42
|
+
transcript: params.transcript,
|
|
43
|
+
}),
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
schema: StructuredCompactionOutputSchema,
|
|
47
|
+
maxOutputTokens: 8_000,
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
return parseCompactionOutput(output)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function createWiredContextCompactionRuntime(deps: CreateContextCompactionRuntimeDeps) {
|
|
54
|
+
const { helperModelRuntime } = deps
|
|
55
|
+
|
|
56
|
+
const runtime = createContextCompactionRuntime({
|
|
57
|
+
runCompacter: (params) => runContextCompacter(helperModelRuntime, params),
|
|
58
|
+
now: deps.now,
|
|
59
|
+
randomId: deps.randomId,
|
|
60
|
+
thresholdRatio: CONTEXT_COMPACTION_THRESHOLD_RATIO,
|
|
61
|
+
outputReserveTokens: CONTEXT_OUTPUT_RESERVE_TOKENS,
|
|
62
|
+
safetyMarginTokens: CONTEXT_SAFETY_MARGIN_TOKENS,
|
|
63
|
+
compactionChunkMaxChars: COMPACTION_CHUNK_MAX_CHARS,
|
|
64
|
+
summaryRollupMaxTokens: SUMMARY_ROLLUP_MAX_TOKENS,
|
|
65
|
+
includedToolNames: CONTEXT_COMPACTION_INCLUDED_TOOL_NAMES,
|
|
66
|
+
includedToolPrefixes: CONTEXT_COMPACTION_INCLUDED_TOOL_PREFIXES,
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
async function compactMemoryBlockSummary(params: {
|
|
70
|
+
previousSummary: string
|
|
71
|
+
newEntriesText: string
|
|
72
|
+
}): Promise<string> {
|
|
73
|
+
const previousSummary = params.previousSummary.trim()
|
|
74
|
+
const newEntriesText = params.newEntriesText.trim()
|
|
75
|
+
if (!previousSummary && !newEntriesText) return ''
|
|
76
|
+
|
|
77
|
+
return await helperModelRuntime.generateHelperText({
|
|
78
|
+
tag: 'memory-block-compaction',
|
|
79
|
+
createAgent: createContextCompacterAgent,
|
|
80
|
+
messages: [{ role: 'user', content: buildMemoryBlockCompactionPrompt({ previousSummary, newEntriesText }) }],
|
|
81
|
+
maxOutputTokens: 512,
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return { ...runtime, compactMemoryBlockSummary }
|
|
86
|
+
}
|