@lota-sdk/core 0.1.9 → 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.
Files changed (105) hide show
  1. package/infrastructure/schema/00_workstream.surql +1 -0
  2. package/infrastructure/schema/02_execution_plan.surql +202 -52
  3. package/package.json +4 -87
  4. package/src/ai/index.ts +3 -0
  5. package/src/bifrost/bifrost.ts +94 -25
  6. package/src/bifrost/index.ts +1 -0
  7. package/src/config/agent-defaults.ts +30 -7
  8. package/src/config/constants.ts +0 -9
  9. package/src/config/debug-logger.ts +43 -0
  10. package/src/config/index.ts +5 -0
  11. package/src/config/model-constants.ts +8 -9
  12. package/src/config/workstream-defaults.ts +4 -0
  13. package/src/db/cursor-pagination.ts +2 -2
  14. package/src/db/index.ts +10 -0
  15. package/src/db/memory-store.ts +3 -71
  16. package/src/db/memory.ts +9 -15
  17. package/src/db/service.ts +42 -2
  18. package/src/db/tables.ts +9 -2
  19. package/src/document/index.ts +2 -0
  20. package/src/document/parsing.ts +0 -25
  21. package/src/embeddings/provider.ts +102 -22
  22. package/src/index.ts +15 -499
  23. package/src/queues/index.ts +10 -0
  24. package/src/redis/connection-accessor.ts +26 -0
  25. package/src/redis/connection.ts +1 -1
  26. package/src/redis/index.ts +9 -25
  27. package/src/redis/org-memory-lock.ts +1 -1
  28. package/src/redis/redis-lease-lock.ts +1 -1
  29. package/src/redis/stream-context.ts +54 -0
  30. package/src/runtime/agent-runtime-policy.ts +9 -5
  31. package/src/runtime/agent-stream-helpers.ts +6 -3
  32. package/src/runtime/agent-types.ts +1 -5
  33. package/src/runtime/approval-continuation.ts +68 -1
  34. package/src/runtime/chat-attachments.ts +1 -1
  35. package/src/runtime/chat-request-routing.ts +6 -2
  36. package/src/runtime/context-compaction-runtime.ts +2 -2
  37. package/src/runtime/context-compaction.ts +1 -1
  38. package/src/runtime/execution-plan.ts +22 -15
  39. package/src/runtime/index.ts +26 -0
  40. package/src/runtime/indexed-repositories-policy.ts +10 -10
  41. package/src/runtime/memory-pipeline.ts +0 -2
  42. package/src/runtime/runtime-config.ts +238 -0
  43. package/src/runtime/runtime-extensions.ts +3 -2
  44. package/src/runtime/runtime-worker-registry.ts +47 -0
  45. package/src/runtime/team-consultation-orchestrator.ts +9 -6
  46. package/src/runtime/team-consultation-prompts.ts +3 -2
  47. package/src/runtime/turn-lifecycle.ts +13 -5
  48. package/src/runtime/workstream-chat-helpers.ts +0 -54
  49. package/src/runtime/workstream-routing-policy.ts +3 -7
  50. package/src/runtime.ts +387 -0
  51. package/src/services/chat-attachments.service.ts +1 -1
  52. package/src/services/context-compaction.service.ts +1 -1
  53. package/src/services/document-chunk.service.ts +2 -2
  54. package/src/services/execution-plan.service.ts +584 -793
  55. package/src/services/index.ts +14 -0
  56. package/src/services/learned-skill.service.ts +82 -39
  57. package/src/services/memory.service.ts +5 -4
  58. package/src/services/mutating-approval.service.ts +1 -1
  59. package/src/services/organization-member.service.ts +1 -1
  60. package/src/services/organization.service.ts +1 -1
  61. package/src/services/plan-approval.service.ts +83 -0
  62. package/src/services/plan-artifact.service.ts +44 -0
  63. package/src/services/plan-builder.service.ts +61 -0
  64. package/src/services/plan-checkpoint.service.ts +53 -0
  65. package/src/services/plan-compiler.service.ts +81 -0
  66. package/src/services/plan-executor.service.ts +1624 -0
  67. package/src/services/plan-run.service.ts +422 -0
  68. package/src/services/plan-validator.service.ts +760 -0
  69. package/src/services/recent-activity-title.service.ts +1 -1
  70. package/src/services/recent-activity.service.ts +14 -16
  71. package/src/services/user.service.ts +2 -2
  72. package/src/services/workstream-message.service.ts +2 -3
  73. package/src/services/workstream-title.service.ts +1 -1
  74. package/src/services/workstream-turn-preparation.ts +156 -59
  75. package/src/services/workstream-turn.ts +26 -1
  76. package/src/services/workstream.service.ts +35 -9
  77. package/src/services/workstream.types.ts +1 -0
  78. package/src/storage/attachment-parser.ts +1 -1
  79. package/src/storage/attachment-storage.service.ts +11 -10
  80. package/src/storage/generated-document-storage.service.ts +7 -6
  81. package/src/storage/index.ts +10 -0
  82. package/src/system-agents/delegated-agent-factory.ts +78 -29
  83. package/src/system-agents/index.ts +4 -0
  84. package/src/system-agents/recent-activity-title-refiner.agent.ts +38 -3
  85. package/src/system-agents/regular-chat-memory-digest.agent.ts +1 -1
  86. package/src/system-agents/skill-extractor.agent.ts +1 -1
  87. package/src/system-agents/skill-manager.agent.ts +2 -4
  88. package/src/system-agents/title-generator.agent.ts +2 -2
  89. package/src/tools/execution-plan.tool.ts +22 -48
  90. package/src/tools/firecrawl-client.ts +2 -2
  91. package/src/tools/index.ts +12 -0
  92. package/src/tools/log-hello-world.tool.ts +17 -0
  93. package/src/tools/research-topic.tool.ts +1 -1
  94. package/src/tools/team-think.tool.ts +1 -1
  95. package/src/tools/user-questions.tool.ts +2 -2
  96. package/src/utils/index.ts +6 -0
  97. package/src/workers/bootstrap.ts +8 -16
  98. package/src/workers/index.ts +7 -0
  99. package/src/workers/regular-chat-memory-digest.runner.ts +1 -1
  100. package/src/workers/skill-extraction.runner.ts +3 -3
  101. package/src/workers/utils/{repo-indexer-chunker.ts → file-section-chunker.ts} +23 -52
  102. package/src/workers/utils/repo-structure-extractor.ts +2 -5
  103. package/src/workers/utils/repomix-file-sections.ts +42 -0
  104. package/src/config/env-shapes.ts +0 -121
  105. package/src/runtime/agent-contract.ts +0 -1
@@ -58,7 +58,7 @@ class RecentActivityTitleService {
58
58
  }),
59
59
  )
60
60
  if (
61
- !recentActivityService.isChiefTitleUseful({
61
+ !recentActivityService.isAgentTitleUseful({
62
62
  currentTitle: candidate.title,
63
63
  systemTitle: candidate.systemTitle,
64
64
  candidateTitle: refinedTitle,
@@ -8,13 +8,13 @@ import {
8
8
  RecentActivitySchema,
9
9
  RecentActivitySourceSchema,
10
10
  RecentActivityTitleSourceSchema,
11
- } from '@lota-sdk/shared/schemas/recent-activity'
11
+ } from '@lota-sdk/shared'
12
12
  import type {
13
13
  RecentActivity,
14
14
  RecentActivityEvent,
15
15
  RecentActivityEventInput,
16
16
  RecentActivitySource,
17
- } from '@lota-sdk/shared/schemas/recent-activity'
17
+ } from '@lota-sdk/shared'
18
18
  import { RecordId } from 'surrealdb'
19
19
  import { z } from 'zod'
20
20
 
@@ -83,18 +83,16 @@ function buildDeterministicRecordId(table: string, key: string): RecordId {
83
83
  return new RecordId(table, digest)
84
84
  }
85
85
 
86
- function shouldKeepExistingChiefTitle(existing: RecentActivityRow | null): boolean {
87
- return existing?.titleSource === 'chief' && compactWhitespace(existing.title).length > 0
86
+ function shouldKeepExistingAgentTitle(existing: RecentActivityRow | null): boolean {
87
+ return existing?.titleSource === 'agent' && compactWhitespace(existing.title).length > 0
88
88
  }
89
89
 
90
90
  function buildRecentActivityAreaKey(
91
- row: Pick<RecentActivityRow, 'deepLink' | 'kind' | 'mergeKey' | 'metadata'>,
91
+ row: Pick<RecentActivityRow, 'targetKind' | 'targetId' | 'kind' | 'mergeKey' | 'metadata'>,
92
92
  ): string {
93
- const target = row.deepLink.search
94
-
95
- if (target.docId) return `document:${target.docId}`
96
- if (target.chat) return `workstream:${target.chat}`
97
- if (target.agent) return `agent:${target.agent}`
93
+ if (row.targetId) {
94
+ return `${row.targetKind}:${row.targetId}`
95
+ }
98
96
 
99
97
  const normalizedWebsiteUrl = row.metadata?.normalizedWebsiteUrl
100
98
  if (row.kind === 'website-intelligence.viewed' && normalizedWebsiteUrl) {
@@ -230,8 +228,8 @@ class RecentActivityService {
230
228
  { mutation: 'merge' },
231
229
  )
232
230
 
233
- const keepExistingChiefTitle = shouldKeepExistingChiefTitle(existingRecent)
234
- const visibleTitle = keepExistingChiefTitle && existingRecent ? existingRecent.title : parsedEvent.title
231
+ const keepExistingAgentTitle = shouldKeepExistingAgentTitle(existingRecent)
232
+ const visibleTitle = keepExistingAgentTitle && existingRecent ? existingRecent.title : parsedEvent.title
235
233
  const recentRow = await databaseService.upsert(
236
234
  TABLES.RECENT_ACTIVITY,
237
235
  recentRecordId,
@@ -244,7 +242,7 @@ class RecentActivityService {
244
242
  targetId: parsedEvent.targetId,
245
243
  title: visibleTitle,
246
244
  systemTitle: parsedEvent.title,
247
- titleSource: keepExistingChiefTitle ? 'chief' : 'system',
245
+ titleSource: keepExistingAgentTitle ? 'agent' : 'system',
248
246
  sourceLabel: parsedEvent.sourceLabel,
249
247
  deepLink: parsedEvent.deepLink,
250
248
  metadata: parsedEvent.metadata,
@@ -326,7 +324,7 @@ class RecentActivityService {
326
324
  const updated = await databaseService.update(
327
325
  TABLES.RECENT_ACTIVITY,
328
326
  activityRef,
329
- { title: nextTitle, titleSource: 'chief', titleRefinedAt: new Date() },
327
+ { title: nextTitle, titleSource: 'agent', titleRefinedAt: new Date() },
330
328
  RecentActivityRowSchema,
331
329
  { mutation: 'merge' },
332
330
  )
@@ -365,7 +363,7 @@ class RecentActivityService {
365
363
  return activity.titleSource === 'system'
366
364
  }
367
365
 
368
- isChiefTitleUseful(params: { currentTitle: string; systemTitle: string; candidateTitle: string }): boolean {
366
+ isAgentTitleUseful(params: { currentTitle: string; systemTitle: string; candidateTitle: string }): boolean {
369
367
  const candidate = compactWhitespace(params.candidateTitle)
370
368
  if (!candidate) return false
371
369
 
@@ -385,7 +383,7 @@ class RecentActivityService {
385
383
  'follow up',
386
384
  'conversation',
387
385
  'chat',
388
- 'chief task',
386
+ 'agent task',
389
387
  'recent activity',
390
388
  'workstream update',
391
389
  ])
@@ -1,5 +1,5 @@
1
- import type { SdkUser, SdkUserRecord } from '@lota-sdk/shared/schemas/user'
2
- import { sdkUserRecordSchema, sdkUserSchema } from '@lota-sdk/shared/schemas/user'
1
+ import type { SdkUser, SdkUserRecord } from '@lota-sdk/shared'
2
+ import { sdkUserRecordSchema, sdkUserSchema } from '@lota-sdk/shared'
3
3
 
4
4
  import { BaseService } from '../db/base.service'
5
5
  import { ensureRecordId, recordIdToString } from '../db/record-id'
@@ -1,6 +1,5 @@
1
- import { toTimestamp, withCreatedAtMetadata } from '@lota-sdk/shared/runtime/chat-message-metadata'
2
- import { parseRowMetadata } from '@lota-sdk/shared/schemas/chat-message'
3
- import type { ChatMessage } from '@lota-sdk/shared/schemas/chat-message'
1
+ import { parseRowMetadata, toTimestamp, withCreatedAtMetadata } from '@lota-sdk/shared'
2
+ import type { ChatMessage } from '@lota-sdk/shared'
4
3
  import { RecordId, surql } from 'surrealdb'
5
4
  import { z } from 'zod'
6
5
 
@@ -1,4 +1,4 @@
1
- import { WORKSTREAM } from '@lota-sdk/shared/constants/workstream'
1
+ import { WORKSTREAM } from '@lota-sdk/shared'
2
2
 
3
3
  import { chatLogger } from '../config/logger'
4
4
  import type { RecordIdRef } from '../db/record-id'