@lota-sdk/core 0.2.3 → 0.3.1
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_identity.surql +2 -2
- package/infrastructure/schema/00_thread.surql +73 -0
- package/infrastructure/schema/02_execution_plan.surql +10 -11
- package/infrastructure/schema/04_runtime_bootstrap.surql +1 -0
- package/infrastructure/schema/10_autonomous_job.surql +3 -3
- package/package.json +2 -2
- package/src/ai/definitions.ts +1 -1
- package/src/config/agent-defaults.ts +5 -5
- package/src/config/index.ts +1 -1
- package/src/config/thread-defaults.ts +72 -0
- package/src/create-runtime.ts +90 -94
- package/src/db/record-id.ts +21 -21
- package/src/db/service.ts +44 -40
- package/src/db/tables.ts +3 -3
- package/src/db/{workstream-message-row.ts → thread-message-row.ts} +3 -3
- package/src/queues/context-compaction.queue.ts +6 -6
- package/src/queues/plan-agent-heartbeat.queue.ts +3 -3
- package/src/queues/post-chat-memory.queue.ts +1 -1
- package/src/queues/title-generation.queue.ts +10 -13
- package/src/redis/index.ts +1 -1
- package/src/redis/stream-context.ts +1 -1
- package/src/runtime/agent-identity-overrides.ts +1 -1
- package/src/runtime/agent-runtime-policy.ts +19 -21
- package/src/runtime/chat-request-routing.ts +1 -1
- package/src/runtime/context-compaction-constants.ts +1 -1
- package/src/runtime/context-compaction.ts +1 -1
- package/src/runtime/execution-plan.ts +1 -1
- package/src/runtime/index.ts +1 -1
- package/src/runtime/memory-digest-policy.ts +1 -1
- package/src/runtime/plugin-types.ts +1 -1
- package/src/runtime/post-turn-side-effects.ts +35 -35
- package/src/runtime/runtime-config.ts +24 -21
- package/src/runtime/runtime-extensions.ts +11 -11
- package/src/runtime/social-chat-agent-runner.ts +3 -3
- package/src/runtime/social-chat-history.ts +1 -1
- package/src/runtime/social-chat.ts +6 -6
- package/src/runtime/team-consultation-orchestrator.ts +1 -1
- package/src/runtime/{workstream-chat-helpers.ts → thread-chat-helpers.ts} +7 -7
- package/src/runtime/{workstream-plan-turn.ts → thread-plan-turn.ts} +11 -17
- package/src/runtime/{workstream-turn-context.ts → thread-turn-context.ts} +10 -10
- package/src/services/agent-activity.service.ts +39 -44
- package/src/services/agent-executor.service.ts +17 -19
- package/src/services/attachment.service.ts +4 -8
- package/src/services/autonomous-job.service.ts +29 -28
- package/src/services/context-compaction.service.ts +19 -29
- package/src/services/execution-plan.service.ts +58 -70
- package/src/services/global-orchestrator.service.ts +5 -5
- package/src/services/index.ts +6 -6
- package/src/services/memory.service.ts +1 -1
- package/src/services/monitoring-window.service.ts +2 -2
- package/src/services/mutating-approval.service.ts +7 -10
- package/src/services/node-workspace.service.ts +8 -7
- package/src/services/notification.service.ts +1 -1
- package/src/services/organization.service.ts +9 -9
- package/src/services/ownership-dispatcher.service.ts +13 -19
- package/src/services/plan-agent-heartbeat.service.ts +13 -13
- package/src/services/plan-agent-query.service.ts +7 -7
- package/src/services/plan-artifact.service.ts +1 -2
- package/src/services/plan-coordination.service.ts +4 -4
- package/src/services/plan-cycle.service.ts +7 -7
- package/src/services/plan-deadline.service.ts +4 -4
- package/src/services/plan-event-delivery.service.ts +8 -12
- package/src/services/plan-executor.service.ts +25 -39
- package/src/services/plan-run-data.ts +27 -8
- package/src/services/plan-run.service.ts +7 -9
- package/src/services/plan-scheduler.service.ts +4 -4
- package/src/services/plan-template.service.ts +2 -2
- package/src/services/plan-validator.service.ts +0 -11
- package/src/services/plugin-executor.service.ts +1 -1
- package/src/services/queue-job.service.ts +1 -1
- package/src/services/recent-activity-title.service.ts +1 -1
- package/src/services/recent-activity.service.ts +4 -4
- package/src/services/system-executor.service.ts +2 -2
- package/src/services/{workstream-message.service.ts → thread-message.service.ts} +72 -76
- package/src/services/thread-plan-registry.service.ts +22 -0
- package/src/services/thread-title.service.ts +39 -0
- package/src/services/{workstream-turn-preparation.service.ts → thread-turn-preparation.service.ts} +148 -171
- package/src/services/{workstream-turn.ts → thread-turn.ts} +27 -31
- package/src/services/thread.service.ts +853 -0
- package/src/services/thread.types.ts +17 -0
- package/src/storage/attachment-storage.service.ts +4 -4
- package/src/system-agents/index.ts +1 -1
- package/src/system-agents/memory.agent.ts +1 -1
- package/src/system-agents/recent-activity-title-refiner.agent.ts +2 -2
- package/src/system-agents/regular-chat-memory-digest.agent.ts +1 -1
- package/src/system-agents/researcher.agent.ts +3 -3
- package/src/system-agents/{workstream-router.agent.ts → thread-router.agent.ts} +68 -135
- package/src/system-agents/title-generator.agent.ts +8 -8
- package/src/tools/execution-plan.tool.ts +39 -40
- package/src/tools/memory-block.tool.ts +4 -4
- package/src/tools/research-topic.tool.ts +1 -0
- package/src/tools/search-web.tool.ts +1 -1
- package/src/tools/search.tool.ts +4 -4
- package/src/tools/team-think.tool.ts +9 -9
- package/src/utils/async.ts +6 -7
- package/src/workers/regular-chat-memory-digest.helpers.ts +1 -1
- package/src/workers/regular-chat-memory-digest.runner.ts +43 -43
- package/src/workers/skill-extraction.runner.ts +9 -13
- package/src/workers/utils/{workstream-message-query.ts → thread-message-query.ts} +21 -21
- package/infrastructure/schema/00_workstream.surql +0 -64
- package/src/config/workstream-defaults.ts +0 -72
- package/src/services/workstream-plan-registry.service.ts +0 -22
- package/src/services/workstream-title.service.ts +0 -42
- package/src/services/workstream.service.ts +0 -803
- package/src/services/workstream.types.ts +0 -17
- /package/src/services/{workstream-constants.ts → thread-constants.ts} +0 -0
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
export interface WorkstreamBootstrapWelcomeConfig {
|
|
2
|
-
directAgentId: string
|
|
3
|
-
buildMessageText: (params: { userName?: string | null }) => string
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export interface LotaWorkstreamBootstrapConfig {
|
|
7
|
-
onboardingDirectAgents?: readonly string[]
|
|
8
|
-
completedDirectAgents?: readonly string[]
|
|
9
|
-
coreTypesAfterOnboarding?: readonly string[]
|
|
10
|
-
ensureDefaultGroupOnCompleted?: boolean
|
|
11
|
-
onboardingWelcome?: WorkstreamBootstrapWelcomeConfig
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface LotaWorkstreamConfig {
|
|
15
|
-
bootstrap?: LotaWorkstreamBootstrapConfig
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface ResolvedWorkstreamBootstrapConfig {
|
|
19
|
-
onboardingDirectAgents: readonly string[]
|
|
20
|
-
completedDirectAgents: readonly string[]
|
|
21
|
-
coreTypesAfterOnboarding: readonly string[]
|
|
22
|
-
ensureDefaultGroupOnCompleted: boolean
|
|
23
|
-
onboardingWelcome?: WorkstreamBootstrapWelcomeConfig
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const DEFAULT_WORKSTREAM_BOOTSTRAP_CONFIG: ResolvedWorkstreamBootstrapConfig = {
|
|
27
|
-
onboardingDirectAgents: [],
|
|
28
|
-
completedDirectAgents: [],
|
|
29
|
-
coreTypesAfterOnboarding: [],
|
|
30
|
-
ensureDefaultGroupOnCompleted: true,
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
let resolvedWorkstreamBootstrapConfig: ResolvedWorkstreamBootstrapConfig = DEFAULT_WORKSTREAM_BOOTSTRAP_CONFIG
|
|
34
|
-
|
|
35
|
-
function withDedupedStrings(values: readonly string[]): string[] {
|
|
36
|
-
const seen = new Set<string>()
|
|
37
|
-
const deduped: string[] = []
|
|
38
|
-
|
|
39
|
-
for (const value of values) {
|
|
40
|
-
const normalized = value.trim()
|
|
41
|
-
if (!normalized || seen.has(normalized)) continue
|
|
42
|
-
seen.add(normalized)
|
|
43
|
-
deduped.push(normalized)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return deduped
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function configureWorkstreams(params: { agentRoster: readonly string[]; config?: LotaWorkstreamConfig }): void {
|
|
50
|
-
const bootstrap = params.config?.bootstrap
|
|
51
|
-
const onboardingWelcome = bootstrap?.onboardingWelcome
|
|
52
|
-
const onboardingDirectAgents = withDedupedStrings([
|
|
53
|
-
...(bootstrap?.onboardingDirectAgents ?? params.agentRoster),
|
|
54
|
-
...(onboardingWelcome ? [onboardingWelcome.directAgentId] : []),
|
|
55
|
-
])
|
|
56
|
-
|
|
57
|
-
resolvedWorkstreamBootstrapConfig = {
|
|
58
|
-
onboardingDirectAgents,
|
|
59
|
-
completedDirectAgents: withDedupedStrings(bootstrap?.completedDirectAgents ?? params.agentRoster),
|
|
60
|
-
coreTypesAfterOnboarding: withDedupedStrings(bootstrap?.coreTypesAfterOnboarding ?? []),
|
|
61
|
-
ensureDefaultGroupOnCompleted: bootstrap?.ensureDefaultGroupOnCompleted ?? true,
|
|
62
|
-
...(onboardingWelcome ? { onboardingWelcome } : {}),
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function getWorkstreamBootstrapConfig(): ResolvedWorkstreamBootstrapConfig {
|
|
67
|
-
return resolvedWorkstreamBootstrapConfig
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function resolveOnboardingOwnerAgentId(defaultLeadAgentId: string): string {
|
|
71
|
-
return resolvedWorkstreamBootstrapConfig.onboardingWelcome?.directAgentId ?? defaultLeadAgentId
|
|
72
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { PlanRunRecord, SerializableExecutionPlan } from '@lota-sdk/shared'
|
|
2
|
-
|
|
3
|
-
import type { RecordIdInput } from '../db/record-id'
|
|
4
|
-
import { planRunService } from './plan-run.service'
|
|
5
|
-
|
|
6
|
-
class WorkstreamPlanRegistryService {
|
|
7
|
-
async listActiveRuns(workstreamId: RecordIdInput): Promise<PlanRunRecord[]> {
|
|
8
|
-
return planRunService.getActiveRunRecords(workstreamId)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
async countActiveRuns(workstreamId: RecordIdInput): Promise<number> {
|
|
12
|
-
const runs = await this.listActiveRuns(workstreamId)
|
|
13
|
-
return runs.length
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async listActivePlans(workstreamId: RecordIdInput): Promise<SerializableExecutionPlan[]> {
|
|
17
|
-
const runs = await this.listActiveRuns(workstreamId)
|
|
18
|
-
return Promise.all(runs.map((run) => planRunService.toSerializablePlan(run)))
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const workstreamPlanRegistryService = new WorkstreamPlanRegistryService()
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { WORKSTREAM } from '@lota-sdk/shared'
|
|
2
|
-
|
|
3
|
-
import { chatLogger } from '../config/logger'
|
|
4
|
-
import type { RecordIdRef } from '../db/record-id'
|
|
5
|
-
import { createHelperModelRuntime } from '../runtime/helper-model'
|
|
6
|
-
import { deriveTitle, limitTitleWords, normalizeTitle } from '../runtime/title-helpers'
|
|
7
|
-
import {
|
|
8
|
-
createWorkstreamTitleGeneratorAgent,
|
|
9
|
-
WORKSTREAM_TITLE_GENERATOR_PROMPT,
|
|
10
|
-
} from '../system-agents/title-generator.agent'
|
|
11
|
-
import { workstreamService } from './workstream.service'
|
|
12
|
-
|
|
13
|
-
const WORKSTREAM_TITLE_TIMEOUT_MS = 30_000
|
|
14
|
-
|
|
15
|
-
class WorkstreamTitleService {
|
|
16
|
-
helperRuntime = createHelperModelRuntime()
|
|
17
|
-
|
|
18
|
-
async generateAndPersistTitle(workstreamId: RecordIdRef, sourceText: string): Promise<void> {
|
|
19
|
-
let title = ''
|
|
20
|
-
try {
|
|
21
|
-
title = normalizeTitle(
|
|
22
|
-
await this.helperRuntime.generateHelperText({
|
|
23
|
-
tag: 'workstream-title',
|
|
24
|
-
createAgent: createWorkstreamTitleGeneratorAgent,
|
|
25
|
-
defaultSystemPrompt: WORKSTREAM_TITLE_GENERATOR_PROMPT,
|
|
26
|
-
timeoutMs: WORKSTREAM_TITLE_TIMEOUT_MS,
|
|
27
|
-
messages: [{ role: 'user', content: sourceText }],
|
|
28
|
-
}),
|
|
29
|
-
)
|
|
30
|
-
} catch (error) {
|
|
31
|
-
chatLogger.warn`Failed to generate workstream title via LLM (non-fatal): ${error}`
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (!title) {
|
|
35
|
-
title = limitTitleWords(deriveTitle(sourceText || WORKSTREAM.DEFAULT_TITLE))
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
await workstreamService.update(workstreamId, { title, nameGenerated: true })
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export const workstreamTitleService = new WorkstreamTitleService()
|