@lota-sdk/core 0.1.15 → 0.1.16
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 +0 -2
- package/infrastructure/schema/01_memory.surql +1 -1
- package/infrastructure/schema/02_execution_plan.surql +62 -1
- package/infrastructure/schema/03_learned_skill.surql +1 -1
- package/infrastructure/schema/06_playbook.surql +25 -0
- package/infrastructure/schema/07_institutional_memory.surql +13 -0
- package/infrastructure/schema/08_quality_metrics.surql +17 -0
- package/package.json +8 -7
- package/src/ai/definitions.ts +80 -2
- package/src/ai/index.ts +0 -2
- package/src/bifrost/bifrost.ts +2 -7
- package/src/config/agent-defaults.ts +31 -21
- package/src/config/agent-types.ts +11 -0
- package/src/config/constants.ts +2 -14
- package/src/config/debug-logger.ts +5 -1
- package/src/config/index.ts +3 -0
- package/src/config/model-constants.ts +16 -34
- package/src/config/search.ts +1 -15
- package/src/create-runtime.ts +244 -178
- package/src/db/cursor-pagination.ts +3 -6
- package/src/db/index.ts +2 -0
- package/src/db/memory-store.rows.ts +7 -7
- package/src/db/memory-store.ts +14 -18
- package/src/db/memory.ts +13 -13
- package/src/db/service.ts +153 -79
- package/src/db/startup.ts +6 -10
- package/src/db/surreal-mutation.ts +43 -0
- package/src/db/tables.ts +7 -0
- package/src/db/workstream-message-row.ts +15 -0
- package/src/embeddings/provider.ts +1 -1
- package/src/queues/context-compaction.queue.ts +15 -46
- package/src/queues/delayed-node-promotion.queue.ts +41 -0
- package/src/queues/index.ts +3 -0
- package/src/queues/memory-consolidation.queue.ts +16 -51
- package/src/queues/plan-scheduler.queue.ts +97 -0
- package/src/queues/post-chat-memory.queue.ts +15 -56
- package/src/queues/queue-factory.ts +100 -0
- package/src/queues/recent-activity-title-refinement.queue.ts +15 -50
- package/src/queues/regular-chat-memory-digest.queue.ts +16 -52
- package/src/queues/skill-extraction.queue.ts +15 -47
- package/src/queues/workstream-title-generation.queue.ts +15 -47
- package/src/redis/connection.ts +6 -0
- package/src/redis/index.ts +1 -1
- package/src/redis/stream-context.ts +11 -0
- package/src/runtime/agent-runtime-policy.ts +106 -21
- package/src/runtime/approval-continuation.ts +12 -6
- package/src/runtime/context-compaction-runtime.ts +1 -1
- package/src/runtime/context-compaction.ts +22 -60
- package/src/runtime/execution-plan.ts +22 -18
- package/src/runtime/graph-designer.ts +15 -0
- package/src/runtime/helper-model.ts +9 -197
- package/src/runtime/index.ts +2 -0
- package/src/runtime/llm-content.ts +1 -1
- package/src/runtime/memory-block.ts +9 -11
- package/src/runtime/memory-pipeline.ts +6 -9
- package/src/runtime/plugin-resolution.ts +35 -0
- package/src/runtime/plugin-types.ts +72 -0
- package/src/runtime/retrieval-adapters.ts +1 -1
- package/src/runtime/runtime-config.ts +25 -12
- package/src/runtime/runtime-extensions.ts +2 -2
- package/src/runtime/runtime-worker-registry.ts +6 -0
- package/src/runtime/team-consultation-orchestrator.ts +45 -28
- package/src/runtime/team-consultation-prompts.ts +11 -2
- package/src/runtime/title-helpers.ts +2 -4
- package/src/runtime/workstream-chat-helpers.ts +1 -1
- package/src/services/adaptive-playbook.service.ts +152 -0
- package/src/services/agent-executor.service.ts +293 -0
- package/src/services/artifact-provenance.service.ts +172 -0
- package/src/services/attachment.service.ts +6 -11
- package/src/services/context-compaction.service.ts +72 -55
- package/src/services/context-enrichment.service.ts +33 -0
- package/src/services/coordination-registry.service.ts +117 -0
- package/src/services/document-chunk.service.ts +1 -1
- package/src/services/domain-agent-executor.service.ts +71 -0
- package/src/services/execution-plan.service.ts +269 -50
- package/src/services/feedback-loop.service.ts +96 -0
- package/src/services/global-orchestrator.service.ts +148 -0
- package/src/services/index.ts +26 -0
- package/src/services/institutional-memory.service.ts +145 -0
- package/src/services/learned-skill.service.ts +24 -5
- package/src/services/memory-assessment.service.ts +3 -2
- package/src/services/memory-utils.ts +3 -8
- package/src/services/memory.service.ts +42 -59
- package/src/services/monitoring-window.service.ts +86 -0
- package/src/services/mutating-approval.service.ts +1 -1
- package/src/services/node-workspace.service.ts +155 -0
- package/src/services/notification.service.ts +39 -0
- package/src/services/organization-member.service.ts +11 -4
- package/src/services/organization.service.ts +5 -5
- package/src/services/ownership-dispatcher.service.ts +403 -0
- package/src/services/plan-approval.service.ts +1 -1
- package/src/services/plan-builder.service.ts +1 -0
- package/src/services/plan-checkpoint.service.ts +30 -2
- package/src/services/plan-compiler.service.ts +5 -0
- package/src/services/plan-coordination.service.ts +152 -0
- package/src/services/plan-cycle.service.ts +284 -0
- package/src/services/plan-deadline.service.ts +287 -0
- package/src/services/plan-executor.service.ts +384 -40
- package/src/services/plan-run.service.ts +41 -7
- package/src/services/plan-scheduler.service.ts +240 -0
- package/src/services/plan-template.service.ts +117 -0
- package/src/services/plan-validator.service.ts +84 -2
- package/src/services/plan-workspace.service.ts +83 -0
- package/src/services/playbook-registry.service.ts +67 -0
- package/src/services/plugin-executor.service.ts +103 -0
- package/src/services/quality-metrics.service.ts +132 -0
- package/src/services/recent-activity.service.ts +27 -31
- package/src/services/skill-resolver.service.ts +19 -0
- package/src/services/system-executor.service.ts +105 -0
- package/src/services/workstream-message.service.ts +12 -34
- package/src/services/workstream-plan-registry.service.ts +22 -0
- package/src/services/workstream-title.service.ts +3 -1
- package/src/services/workstream-turn-preparation.service.ts +34 -66
- package/src/services/workstream.service.ts +33 -55
- package/src/services/workstream.types.ts +9 -9
- package/src/services/write-intent-validator.service.ts +81 -0
- package/src/storage/attachment-parser.ts +1 -1
- package/src/storage/attachment-utils.ts +1 -1
- package/src/storage/generated-document-storage.service.ts +3 -2
- package/src/system-agents/delegated-agent-factory.ts +2 -0
- package/src/tools/execution-plan.tool.ts +17 -23
- package/src/tools/index.ts +0 -1
- package/src/tools/team-think.tool.ts +6 -4
- package/src/utils/async.ts +2 -1
- package/src/utils/date-time.ts +4 -32
- package/src/utils/env.ts +8 -0
- package/src/utils/errors.ts +42 -10
- package/src/utils/index.ts +9 -0
- package/src/utils/string.ts +114 -1
- package/src/workers/index.ts +1 -0
- package/src/workers/regular-chat-memory-digest.runner.ts +2 -2
- package/src/workers/skill-extraction.runner.ts +1 -1
- package/src/workers/utils/file-section-chunker.ts +2 -1
- package/src/workers/utils/repomix-file-sections.ts +2 -2
- package/src/workers/utils/sandbox-error.ts +11 -2
- package/src/workers/utils/workstream-message-query.ts +11 -20
- package/src/workers/worker-utils.ts +2 -2
- package/src/tools/log-hello-world.tool.ts +0 -17
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
# SDK identity tables.
|
|
2
1
|
DEFINE TABLE IF NOT EXISTS organization SCHEMAFULL;
|
|
3
2
|
DEFINE FIELD IF NOT EXISTS name ON TABLE organization TYPE string;
|
|
4
3
|
DEFINE FIELD IF NOT EXISTS regularChatDigestLastWorkstreamCursorCreatedAt ON TABLE organization TYPE option<datetime>;
|
|
@@ -14,7 +13,6 @@ DEFINE FIELD IF NOT EXISTS email ON TABLE user TYPE string;
|
|
|
14
13
|
DEFINE FIELD IF NOT EXISTS createdAt ON TABLE user TYPE datetime DEFAULT time::now() READONLY;
|
|
15
14
|
DEFINE FIELD IF NOT EXISTS updatedAt ON TABLE user TYPE datetime VALUE time::now();
|
|
16
15
|
|
|
17
|
-
DEFINE INDEX IF NOT EXISTS sdkUserEmailIdx ON TABLE user COLUMNS email;
|
|
18
16
|
|
|
19
17
|
DEFINE TABLE IF NOT EXISTS organizationMember SCHEMAFULL TYPE RELATION IN user OUT organization;
|
|
20
18
|
DEFINE FIELD IF NOT EXISTS in ON TABLE organizationMember TYPE record<user>;
|
|
@@ -14,7 +14,7 @@ DEFINE FIELD IF NOT EXISTS importance ON TABLE memory TYPE float DEFAULT 1.0;
|
|
|
14
14
|
DEFINE FIELD IF NOT EXISTS accessCount ON TABLE memory TYPE int DEFAULT 0;
|
|
15
15
|
DEFINE FIELD IF NOT EXISTS lastAccessedAt ON TABLE memory TYPE option<datetime>;
|
|
16
16
|
DEFINE FIELD IF NOT EXISTS createdAt ON TABLE memory TYPE datetime DEFAULT time::now() READONLY;
|
|
17
|
-
DEFINE FIELD IF NOT EXISTS updatedAt ON TABLE memory TYPE option<datetime
|
|
17
|
+
DEFINE FIELD IF NOT EXISTS updatedAt ON TABLE memory TYPE option<datetime> VALUE time::now();
|
|
18
18
|
DEFINE FIELD IF NOT EXISTS validFrom ON TABLE memory TYPE datetime DEFAULT time::now();
|
|
19
19
|
DEFINE FIELD IF NOT EXISTS validUntil ON TABLE memory TYPE option<datetime>;
|
|
20
20
|
DEFINE FIELD IF NOT EXISTS archivedAt ON TABLE memory TYPE option<datetime>;
|
|
@@ -17,11 +17,17 @@ DEFINE FIELD IF NOT EXISTS edges.*.target ON TABLE planSpec TYPE string;
|
|
|
17
17
|
DEFINE FIELD IF NOT EXISTS edges.*.when ON TABLE planSpec TYPE option<string>;
|
|
18
18
|
DEFINE FIELD IF NOT EXISTS edges.*.map ON TABLE planSpec TYPE object FLEXIBLE DEFAULT {};
|
|
19
19
|
DEFINE FIELD IF NOT EXISTS entryNodeIds ON TABLE planSpec TYPE array<string>;
|
|
20
|
+
DEFINE FIELD IF NOT EXISTS executionMode ON TABLE planSpec TYPE string DEFAULT 'linear';
|
|
21
|
+
DEFINE FIELD IF NOT EXISTS contextEnrichments ON TABLE planSpec TYPE option<array<object>> FLEXIBLE;
|
|
22
|
+
DEFINE FIELD OVERWRITE contextEnrichments.* ON TABLE planSpec TYPE object FLEXIBLE;
|
|
23
|
+
DEFINE FIELD IF NOT EXISTS schedule ON TABLE planSpec TYPE option<object> FLEXIBLE;
|
|
24
|
+
DEFINE FIELD IF NOT EXISTS dependencies ON TABLE planSpec TYPE option<array>;
|
|
20
25
|
DEFINE FIELD IF NOT EXISTS replacedSpecId ON TABLE planSpec TYPE option<record<planSpec>>;
|
|
21
26
|
DEFINE FIELD IF NOT EXISTS createdAt ON TABLE planSpec TYPE datetime DEFAULT time::now() READONLY;
|
|
22
27
|
DEFINE FIELD IF NOT EXISTS updatedAt ON TABLE planSpec TYPE datetime VALUE time::now();
|
|
23
28
|
DEFINE FIELD IF NOT EXISTS compiledAt ON TABLE planSpec TYPE option<datetime>;
|
|
24
29
|
|
|
30
|
+
DEFINE INDEX IF NOT EXISTS planSpecOrgIdx ON TABLE planSpec COLUMNS organizationId;
|
|
25
31
|
DEFINE INDEX IF NOT EXISTS planSpecWorkstreamIdx ON TABLE planSpec COLUMNS workstreamId;
|
|
26
32
|
DEFINE INDEX IF NOT EXISTS planSpecWorkstreamStatusIdx ON TABLE planSpec COLUMNS workstreamId, status;
|
|
27
33
|
|
|
@@ -59,6 +65,11 @@ DEFINE FIELD IF NOT EXISTS failurePolicy.*.note ON TABLE planNodeSpec TYPE strin
|
|
|
59
65
|
DEFINE FIELD IF NOT EXISTS timeoutMs ON TABLE planNodeSpec TYPE option<int>;
|
|
60
66
|
DEFINE FIELD IF NOT EXISTS toolPolicy ON TABLE planNodeSpec TYPE object FLEXIBLE;
|
|
61
67
|
DEFINE FIELD IF NOT EXISTS contextPolicy ON TABLE planNodeSpec TYPE object FLEXIBLE;
|
|
68
|
+
DEFINE FIELD IF NOT EXISTS schedule ON TABLE planNodeSpec TYPE option<object> FLEXIBLE;
|
|
69
|
+
DEFINE FIELD IF NOT EXISTS deadline ON TABLE planNodeSpec TYPE option<object> FLEXIBLE;
|
|
70
|
+
DEFINE FIELD IF NOT EXISTS monitoringConfig ON TABLE planNodeSpec TYPE option<object> FLEXIBLE;
|
|
71
|
+
DEFINE FIELD IF NOT EXISTS delayAfterPredecessorMs ON TABLE planNodeSpec TYPE option<int>;
|
|
72
|
+
DEFINE FIELD IF NOT EXISTS deliberationConfig ON TABLE planNodeSpec TYPE option<object> FLEXIBLE;
|
|
62
73
|
DEFINE FIELD IF NOT EXISTS upstreamNodeIds ON TABLE planNodeSpec TYPE array<string> DEFAULT [];
|
|
63
74
|
DEFINE FIELD IF NOT EXISTS downstreamNodeIds ON TABLE planNodeSpec TYPE array<string> DEFAULT [];
|
|
64
75
|
DEFINE FIELD IF NOT EXISTS createdAt ON TABLE planNodeSpec TYPE datetime DEFAULT time::now() READONLY;
|
|
@@ -80,11 +91,14 @@ DEFINE FIELD IF NOT EXISTS readyNodeIds ON TABLE planRun TYPE array<string> DEFA
|
|
|
80
91
|
DEFINE FIELD IF NOT EXISTS failureCount ON TABLE planRun TYPE int DEFAULT 0;
|
|
81
92
|
DEFINE FIELD IF NOT EXISTS replacedRunId ON TABLE planRun TYPE option<record<planRun>>;
|
|
82
93
|
DEFINE FIELD IF NOT EXISTS lastCheckpointId ON TABLE planRun TYPE option<record<planCheckpoint>>;
|
|
94
|
+
DEFINE FIELD IF NOT EXISTS scheduledAt ON TABLE planRun TYPE option<datetime>;
|
|
95
|
+
DEFINE FIELD IF NOT EXISTS scheduleId ON TABLE planRun TYPE option<record<planSchedule>>;
|
|
83
96
|
DEFINE FIELD IF NOT EXISTS createdAt ON TABLE planRun TYPE datetime DEFAULT time::now() READONLY;
|
|
84
97
|
DEFINE FIELD IF NOT EXISTS updatedAt ON TABLE planRun TYPE datetime VALUE time::now();
|
|
85
98
|
DEFINE FIELD IF NOT EXISTS startedAt ON TABLE planRun TYPE option<datetime>;
|
|
86
99
|
DEFINE FIELD IF NOT EXISTS completedAt ON TABLE planRun TYPE option<datetime>;
|
|
87
100
|
|
|
101
|
+
DEFINE INDEX IF NOT EXISTS planRunOrgIdx ON TABLE planRun COLUMNS organizationId;
|
|
88
102
|
DEFINE INDEX IF NOT EXISTS planRunWorkstreamIdx ON TABLE planRun COLUMNS workstreamId;
|
|
89
103
|
DEFINE INDEX IF NOT EXISTS planRunWorkstreamStatusIdx ON TABLE planRun COLUMNS workstreamId, status;
|
|
90
104
|
DEFINE INDEX IF NOT EXISTS planRunSpecIdx ON TABLE planRun COLUMNS planSpecId;
|
|
@@ -102,6 +116,7 @@ DEFINE FIELD IF NOT EXISTS latestNotes ON TABLE planNodeRun TYPE option<string>;
|
|
|
102
116
|
DEFINE FIELD IF NOT EXISTS latestAttemptId ON TABLE planNodeRun TYPE option<record<planNodeAttempt>>;
|
|
103
117
|
DEFINE FIELD IF NOT EXISTS blockedReason ON TABLE planNodeRun TYPE option<string>;
|
|
104
118
|
DEFINE FIELD IF NOT EXISTS failureClass ON TABLE planNodeRun TYPE option<string>;
|
|
119
|
+
DEFINE FIELD IF NOT EXISTS scheduledAt ON TABLE planNodeRun TYPE option<datetime>;
|
|
105
120
|
DEFINE FIELD IF NOT EXISTS readyAt ON TABLE planNodeRun TYPE option<datetime>;
|
|
106
121
|
DEFINE FIELD IF NOT EXISTS startedAt ON TABLE planNodeRun TYPE option<datetime>;
|
|
107
122
|
DEFINE FIELD IF NOT EXISTS completedAt ON TABLE planNodeRun TYPE option<datetime>;
|
|
@@ -137,7 +152,7 @@ DEFINE FIELD IF NOT EXISTS kind ON TABLE planArtifact TYPE string;
|
|
|
137
152
|
DEFINE FIELD IF NOT EXISTS pointer ON TABLE planArtifact TYPE string;
|
|
138
153
|
DEFINE FIELD IF NOT EXISTS schemaRef ON TABLE planArtifact TYPE option<string>;
|
|
139
154
|
DEFINE FIELD IF NOT EXISTS description ON TABLE planArtifact TYPE option<string>;
|
|
140
|
-
DEFINE FIELD IF NOT EXISTS payload ON TABLE planArtifact TYPE option<object
|
|
155
|
+
DEFINE FIELD IF NOT EXISTS payload ON TABLE planArtifact TYPE option<object> FLEXIBLE;
|
|
141
156
|
DEFINE FIELD IF NOT EXISTS createdAt ON TABLE planArtifact TYPE datetime DEFAULT time::now() READONLY;
|
|
142
157
|
|
|
143
158
|
DEFINE INDEX IF NOT EXISTS planArtifactRunIdx ON TABLE planArtifact COLUMNS runId;
|
|
@@ -210,3 +225,49 @@ DEFINE FIELD IF NOT EXISTS createdAt ON TABLE planEvent TYPE datetime DEFAULT ti
|
|
|
210
225
|
DEFINE INDEX IF NOT EXISTS planEventRunIdx ON TABLE planEvent COLUMNS runId;
|
|
211
226
|
DEFINE INDEX IF NOT EXISTS planEventRunNodeIdx ON TABLE planEvent COLUMNS runId, nodeId;
|
|
212
227
|
DEFINE INDEX IF NOT EXISTS planEventRunTimeIdx ON TABLE planEvent COLUMNS runId, createdAt;
|
|
228
|
+
|
|
229
|
+
DEFINE TABLE IF NOT EXISTS planSchedule SCHEMAFULL;
|
|
230
|
+
DEFINE FIELD IF NOT EXISTS organizationId ON TABLE planSchedule TYPE record<organization>;
|
|
231
|
+
DEFINE FIELD IF NOT EXISTS workstreamId ON TABLE planSchedule TYPE record<workstream> REFERENCE ON DELETE CASCADE;
|
|
232
|
+
DEFINE FIELD IF NOT EXISTS planSpecId ON TABLE planSchedule TYPE option<record<planSpec>>;
|
|
233
|
+
DEFINE FIELD IF NOT EXISTS runId ON TABLE planSchedule TYPE option<record<planRun>>;
|
|
234
|
+
DEFINE FIELD IF NOT EXISTS nodeId ON TABLE planSchedule TYPE option<string>;
|
|
235
|
+
DEFINE FIELD IF NOT EXISTS scheduleSpec ON TABLE planSchedule TYPE object FLEXIBLE;
|
|
236
|
+
DEFINE FIELD IF NOT EXISTS status ON TABLE planSchedule TYPE string;
|
|
237
|
+
DEFINE FIELD IF NOT EXISTS fireCount ON TABLE planSchedule TYPE int DEFAULT 0;
|
|
238
|
+
DEFINE FIELD IF NOT EXISTS nextFireAt ON TABLE planSchedule TYPE option<datetime>;
|
|
239
|
+
DEFINE FIELD IF NOT EXISTS lastFiredAt ON TABLE planSchedule TYPE option<datetime>;
|
|
240
|
+
DEFINE FIELD IF NOT EXISTS createdAt ON TABLE planSchedule TYPE datetime DEFAULT time::now() READONLY;
|
|
241
|
+
DEFINE FIELD IF NOT EXISTS updatedAt ON TABLE planSchedule TYPE datetime VALUE time::now();
|
|
242
|
+
DEFINE INDEX IF NOT EXISTS planScheduleStatusIdx ON TABLE planSchedule COLUMNS status;
|
|
243
|
+
DEFINE INDEX IF NOT EXISTS planScheduleNextFireIdx ON TABLE planSchedule COLUMNS status, nextFireAt;
|
|
244
|
+
DEFINE INDEX IF NOT EXISTS planScheduleWorkstreamIdx ON TABLE planSchedule COLUMNS workstreamId;
|
|
245
|
+
|
|
246
|
+
DEFINE TABLE IF NOT EXISTS planTemplate SCHEMAFULL;
|
|
247
|
+
DEFINE FIELD IF NOT EXISTS organizationId ON TABLE planTemplate TYPE record<organization>;
|
|
248
|
+
DEFINE FIELD IF NOT EXISTS name ON TABLE planTemplate TYPE string;
|
|
249
|
+
DEFINE FIELD IF NOT EXISTS description ON TABLE planTemplate TYPE option<string>;
|
|
250
|
+
DEFINE FIELD IF NOT EXISTS draft ON TABLE planTemplate TYPE object FLEXIBLE;
|
|
251
|
+
DEFINE FIELD IF NOT EXISTS tags ON TABLE planTemplate TYPE array DEFAULT [];
|
|
252
|
+
DEFINE FIELD IF NOT EXISTS source ON TABLE planTemplate TYPE string DEFAULT 'user';
|
|
253
|
+
DEFINE FIELD IF NOT EXISTS sourceRef ON TABLE planTemplate TYPE option<string>;
|
|
254
|
+
DEFINE FIELD IF NOT EXISTS createdAt ON TABLE planTemplate TYPE datetime DEFAULT time::now() READONLY;
|
|
255
|
+
DEFINE FIELD IF NOT EXISTS updatedAt ON TABLE planTemplate TYPE datetime VALUE time::now();
|
|
256
|
+
DEFINE INDEX IF NOT EXISTS planTemplateOrgIdx ON TABLE planTemplate COLUMNS organizationId;
|
|
257
|
+
DEFINE INDEX IF NOT EXISTS planTemplateOrgNameIdx ON TABLE planTemplate COLUMNS organizationId, name UNIQUE;
|
|
258
|
+
|
|
259
|
+
DEFINE TABLE IF NOT EXISTS planCycle SCHEMAFULL;
|
|
260
|
+
DEFINE FIELD IF NOT EXISTS organizationId ON TABLE planCycle TYPE record<organization>;
|
|
261
|
+
DEFINE FIELD IF NOT EXISTS workstreamId ON TABLE planCycle TYPE record<workstream> REFERENCE ON DELETE CASCADE;
|
|
262
|
+
DEFINE FIELD IF NOT EXISTS templateId ON TABLE planCycle TYPE record<planTemplate>;
|
|
263
|
+
DEFINE FIELD IF NOT EXISTS name ON TABLE planCycle TYPE string;
|
|
264
|
+
DEFINE FIELD IF NOT EXISTS schedule ON TABLE planCycle TYPE object FLEXIBLE;
|
|
265
|
+
DEFINE FIELD IF NOT EXISTS carryForwardPolicy ON TABLE planCycle TYPE string DEFAULT 'incomplete-only';
|
|
266
|
+
DEFINE FIELD IF NOT EXISTS status ON TABLE planCycle TYPE string;
|
|
267
|
+
DEFINE FIELD IF NOT EXISTS currentIteration ON TABLE planCycle TYPE int DEFAULT 0;
|
|
268
|
+
DEFINE FIELD IF NOT EXISTS currentRunId ON TABLE planCycle TYPE option<record<planRun>>;
|
|
269
|
+
DEFINE FIELD IF NOT EXISTS scheduleId ON TABLE planCycle TYPE option<record<planSchedule>>;
|
|
270
|
+
DEFINE FIELD IF NOT EXISTS createdAt ON TABLE planCycle TYPE datetime DEFAULT time::now() READONLY;
|
|
271
|
+
DEFINE FIELD IF NOT EXISTS updatedAt ON TABLE planCycle TYPE datetime VALUE time::now();
|
|
272
|
+
DEFINE INDEX IF NOT EXISTS planCycleWorkstreamIdx ON TABLE planCycle COLUMNS workstreamId;
|
|
273
|
+
DEFINE INDEX IF NOT EXISTS planCycleStatusIdx ON TABLE planCycle COLUMNS status;
|
|
@@ -19,7 +19,7 @@ DEFINE FIELD IF NOT EXISTS supersedes ON TABLE learnedSkill TYPE option<record<l
|
|
|
19
19
|
DEFINE FIELD IF NOT EXISTS embedding ON TABLE learnedSkill TYPE array<float>;
|
|
20
20
|
DEFINE FIELD IF NOT EXISTS hash ON TABLE learnedSkill TYPE string;
|
|
21
21
|
DEFINE FIELD IF NOT EXISTS createdAt ON TABLE learnedSkill TYPE datetime DEFAULT time::now() READONLY;
|
|
22
|
-
DEFINE FIELD IF NOT EXISTS updatedAt ON TABLE learnedSkill TYPE option<datetime
|
|
22
|
+
DEFINE FIELD IF NOT EXISTS updatedAt ON TABLE learnedSkill TYPE option<datetime> VALUE time::now();
|
|
23
23
|
DEFINE FIELD IF NOT EXISTS lastUsedAt ON TABLE learnedSkill TYPE option<datetime>;
|
|
24
24
|
DEFINE FIELD IF NOT EXISTS archivedAt ON TABLE learnedSkill TYPE option<datetime>;
|
|
25
25
|
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Playbook tables for compound intelligence.
|
|
2
|
+
|
|
3
|
+
DEFINE TABLE IF NOT EXISTS playbook SCHEMAFULL;
|
|
4
|
+
DEFINE FIELD IF NOT EXISTS organizationId ON TABLE playbook TYPE record<organization>;
|
|
5
|
+
DEFINE FIELD IF NOT EXISTS name ON TABLE playbook TYPE string;
|
|
6
|
+
DEFINE FIELD IF NOT EXISTS objective ON TABLE playbook TYPE string;
|
|
7
|
+
DEFINE FIELD IF NOT EXISTS currentVersionId ON TABLE playbook TYPE record<playbookVersion>;
|
|
8
|
+
DEFINE FIELD IF NOT EXISTS previousVersionId ON TABLE playbook TYPE option<record<playbookVersion>>;
|
|
9
|
+
DEFINE FIELD IF NOT EXISTS cycleCount ON TABLE playbook TYPE int DEFAULT 0;
|
|
10
|
+
DEFINE FIELD IF NOT EXISTS createdAt ON TABLE playbook TYPE datetime DEFAULT time::now() READONLY;
|
|
11
|
+
DEFINE FIELD IF NOT EXISTS updatedAt ON TABLE playbook TYPE datetime VALUE time::now();
|
|
12
|
+
|
|
13
|
+
DEFINE INDEX IF NOT EXISTS playbookOrgIdx ON TABLE playbook COLUMNS organizationId;
|
|
14
|
+
|
|
15
|
+
DEFINE TABLE IF NOT EXISTS playbookVersion SCHEMAFULL;
|
|
16
|
+
DEFINE FIELD IF NOT EXISTS playbookId ON TABLE playbookVersion TYPE record<playbook> REFERENCE ON DELETE CASCADE;
|
|
17
|
+
DEFINE FIELD IF NOT EXISTS version ON TABLE playbookVersion TYPE int;
|
|
18
|
+
DEFINE FIELD IF NOT EXISTS parentVersionId ON TABLE playbookVersion TYPE option<record<playbookVersion>>;
|
|
19
|
+
DEFINE FIELD IF NOT EXISTS appliedRecommendations ON TABLE playbookVersion TYPE array<string> DEFAULT [];
|
|
20
|
+
DEFINE FIELD IF NOT EXISTS qualityScore ON TABLE playbookVersion TYPE option<float>;
|
|
21
|
+
DEFINE FIELD IF NOT EXISTS status ON TABLE playbookVersion TYPE string;
|
|
22
|
+
DEFINE FIELD IF NOT EXISTS createdAt ON TABLE playbookVersion TYPE datetime DEFAULT time::now() READONLY;
|
|
23
|
+
|
|
24
|
+
DEFINE INDEX IF NOT EXISTS playbookVersionPlaybookIdx ON TABLE playbookVersion COLUMNS playbookId;
|
|
25
|
+
DEFINE INDEX IF NOT EXISTS playbookVersionUniqueIdx ON TABLE playbookVersion COLUMNS playbookId, version UNIQUE;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Institutional memory for compound intelligence.
|
|
2
|
+
|
|
3
|
+
DEFINE TABLE IF NOT EXISTS institutionalMemory SCHEMAFULL;
|
|
4
|
+
DEFINE FIELD IF NOT EXISTS organizationId ON TABLE institutionalMemory TYPE record<organization>;
|
|
5
|
+
DEFINE FIELD IF NOT EXISTS type ON TABLE institutionalMemory TYPE string;
|
|
6
|
+
DEFINE FIELD IF NOT EXISTS pattern ON TABLE institutionalMemory TYPE object FLEXIBLE;
|
|
7
|
+
DEFINE FIELD IF NOT EXISTS confidence ON TABLE institutionalMemory TYPE float;
|
|
8
|
+
DEFINE FIELD IF NOT EXISTS sampleCount ON TABLE institutionalMemory TYPE int;
|
|
9
|
+
DEFINE FIELD IF NOT EXISTS createdAt ON TABLE institutionalMemory TYPE datetime DEFAULT time::now() READONLY;
|
|
10
|
+
DEFINE FIELD IF NOT EXISTS updatedAt ON TABLE institutionalMemory TYPE datetime VALUE time::now();
|
|
11
|
+
|
|
12
|
+
DEFINE INDEX IF NOT EXISTS institutionalMemoryOrgIdx ON TABLE institutionalMemory COLUMNS organizationId;
|
|
13
|
+
DEFINE INDEX IF NOT EXISTS institutionalMemoryOrgTypeIdx ON TABLE institutionalMemory COLUMNS organizationId, type;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Quality metrics for compound intelligence.
|
|
2
|
+
|
|
3
|
+
DEFINE TABLE IF NOT EXISTS qualityMetric SCHEMAFULL;
|
|
4
|
+
DEFINE FIELD IF NOT EXISTS organizationId ON TABLE qualityMetric TYPE record<organization>;
|
|
5
|
+
DEFINE FIELD IF NOT EXISTS runId ON TABLE qualityMetric TYPE record<planRun>;
|
|
6
|
+
DEFINE FIELD IF NOT EXISTS nodeId ON TABLE qualityMetric TYPE option<string>;
|
|
7
|
+
DEFINE FIELD IF NOT EXISTS ownerRef ON TABLE qualityMetric TYPE string;
|
|
8
|
+
DEFINE FIELD IF NOT EXISTS ownerType ON TABLE qualityMetric TYPE string;
|
|
9
|
+
DEFINE FIELD IF NOT EXISTS nodeType ON TABLE qualityMetric TYPE string;
|
|
10
|
+
DEFINE FIELD IF NOT EXISTS executionTimeMs ON TABLE qualityMetric TYPE int;
|
|
11
|
+
DEFINE FIELD IF NOT EXISTS attemptCount ON TABLE qualityMetric TYPE int;
|
|
12
|
+
DEFINE FIELD IF NOT EXISTS artifactCount ON TABLE qualityMetric TYPE int;
|
|
13
|
+
DEFINE FIELD IF NOT EXISTS validationIssueCount ON TABLE qualityMetric TYPE int;
|
|
14
|
+
DEFINE FIELD IF NOT EXISTS createdAt ON TABLE qualityMetric TYPE datetime DEFAULT time::now() READONLY;
|
|
15
|
+
|
|
16
|
+
DEFINE INDEX IF NOT EXISTS qualityMetricOrgIdx ON TABLE qualityMetric COLUMNS organizationId;
|
|
17
|
+
DEFINE INDEX IF NOT EXISTS qualityMetricRunIdx ON TABLE qualityMetric COLUMNS runId;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lota-sdk/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -28,14 +28,15 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@ai-sdk/devtools": "^0.0.15",
|
|
31
|
-
"@ai-sdk/openai": "^3.0.
|
|
32
|
-
"@logtape/logtape": "^2.0.
|
|
33
|
-
"@lota-sdk/shared": "0.1.
|
|
34
|
-
"@mendable/firecrawl-js": "^4.
|
|
31
|
+
"@ai-sdk/openai": "^3.0.48",
|
|
32
|
+
"@logtape/logtape": "^2.0.5",
|
|
33
|
+
"@lota-sdk/shared": "0.1.16",
|
|
34
|
+
"@mendable/firecrawl-js": "^4.17.0",
|
|
35
35
|
"@surrealdb/node": "^3.0.3",
|
|
36
|
-
"ai": "^6.0.
|
|
36
|
+
"ai": "^6.0.137",
|
|
37
37
|
"bullmq": "^5.71.0",
|
|
38
|
-
"
|
|
38
|
+
"cron-parser": "^5.5.0",
|
|
39
|
+
"hono": "^4.12.9",
|
|
39
40
|
"ioredis": "5.9.3",
|
|
40
41
|
"mammoth": "^1.12.0",
|
|
41
42
|
"pdf-parse": "^2.4.5",
|
package/src/ai/definitions.ts
CHANGED
|
@@ -50,7 +50,6 @@ export function renderSkillInstructions(skills: readonly SkillDefinition[]): str
|
|
|
50
50
|
return ['<skills>', ...sections, '</skills>'].join('\n\n')
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
/** @lintignore */
|
|
54
53
|
export interface LearnedSkillEntry {
|
|
55
54
|
name: string
|
|
56
55
|
instructions: string
|
|
@@ -173,7 +172,7 @@ Do NOT use when:
|
|
|
173
172
|
- For broad research, call 2-3 \`researchTopic\` instances **in parallel** with different focused tasks (e.g., one for market sizing, one for competitor analysis, one for pricing benchmarks).
|
|
174
173
|
- Each \`researchTopic\` call returns a synthesized markdown report with sources — you do not need to search or fetch pages yourself.
|
|
175
174
|
- Use \`fetchWebpage\` **only** when the user shares a specific URL they want you to read. Do not use it for general research.
|
|
176
|
-
- Use \`inspectWebsite\` when the user wants a structured analysis of a specific website or landing page.
|
|
175
|
+
- Use \`inspectWebsite\` when the user wants a structured analysis of a specific website or landing page. Pass the exact URL in the tool's \`url\` field and the learning goal in \`task\`.
|
|
177
176
|
- When the user asks to refresh, re-run, or overwrite existing website extraction, call \`inspectWebsite\` with \`forceRefresh: true\`.
|
|
178
177
|
</how-to-research>
|
|
179
178
|
|
|
@@ -201,6 +200,85 @@ Do NOT use when:
|
|
|
201
200
|
</output-structure>`,
|
|
202
201
|
})
|
|
203
202
|
|
|
203
|
+
const surrealDbSkillTools = [] as const
|
|
204
|
+
|
|
205
|
+
export const surrealDbSkill = defineSkill({
|
|
206
|
+
name: 'surrealdb',
|
|
207
|
+
description:
|
|
208
|
+
'Design and query SurrealDB correctly for Lota SDK tables, record IDs, relations, vector indexes, full-text search, and DB-boundary rules. Use this whenever the task touches SurrealQL schema files, DB services, query patterns, or SurrealDB modeling decisions.',
|
|
209
|
+
tools: surrealDbSkillTools,
|
|
210
|
+
instructions: `# surrealdb
|
|
211
|
+
|
|
212
|
+
## Description
|
|
213
|
+
|
|
214
|
+
Use this skill for any Lota SDK task that changes SurrealQL schema files, DB services, record IDs, relations, vector search, or full-text search.
|
|
215
|
+
|
|
216
|
+
## Details
|
|
217
|
+
|
|
218
|
+
<schema-rules>
|
|
219
|
+
- Default schema files to \`IF NOT EXISTS\`. Do not add migration DML, compatibility branches, or fallback logic.
|
|
220
|
+
- Avoid \`OVERWRITE\` unless SurrealDB itself requires a specific wildcard exception on a fresh database shape, such as \`workstreamMessage.parts.*\` or \`planSpec.contextEnrichments.*\`.
|
|
221
|
+
- Treat the database as fresh. Replace incorrect definitions directly instead of layering migrations.
|
|
222
|
+
- Let SurrealDB own \`updatedAt\` when the schema uses \`VALUE time::now()\`. Do not write that field from application code.
|
|
223
|
+
- Keep flexible object fields explicit, for example \`TYPE option<object> FLEXIBLE\` or \`TYPE array<object> FLEXIBLE\`.
|
|
224
|
+
</schema-rules>
|
|
225
|
+
|
|
226
|
+
<id-rules>
|
|
227
|
+
- Keep DB-boundary record IDs structural. Normalize \`string | { tb, id }\` inputs at the SDK boundary instead of relying on nominal \`RecordId\` identity across packages.
|
|
228
|
+
- Use array/object record IDs only when exact-key lookup or record-range access is the real model requirement. Do not invent composite IDs for ordinary references.
|
|
229
|
+
- Parameterize record IDs and all user-controlled values with bindings. Never concatenate them into SurrealQL.
|
|
230
|
+
- \`NONE\` removes a field. \`null\` stores a real NULL value. JavaScript \`null\` is not a synonym for \`NONE\`.
|
|
231
|
+
- For JavaScript SDK mutation payloads (\`create\`, \`update\`, \`upsert\`, \`insert\`, \`content\`, \`merge\`), clear top-level optional fields by omitting them or using \`undefined\`. Use explicit raw \`NONE\` only when you are writing bound SurrealQL directly.
|
|
232
|
+
</id-rules>
|
|
233
|
+
|
|
234
|
+
<modeling>
|
|
235
|
+
- Use record links for simple references and ownership fields when the link itself does not need properties or graph traversal semantics.
|
|
236
|
+
- Use \`TYPE RELATION\` tables and \`RELATE\` when the edge is first-class, needs metadata, or will be traversed as graph data.
|
|
237
|
+
- Use vector indexes for embedding similarity and BM25 full-text indexes for lexical retrieval. Reach for both when hybrid retrieval materially improves recall.
|
|
238
|
+
</modeling>
|
|
239
|
+
|
|
240
|
+
<sdk-querying>
|
|
241
|
+
- Prefer JavaScript SDK select chains for straightforward reads, for example \`db.select(new Table('users')).where(...).start(...).limit(...)\`.
|
|
242
|
+
- Fall back to bound SQL only when the SDK builder cannot express the query clearly.
|
|
243
|
+
- Any identifier that must enter a raw query string must be validated explicitly first.
|
|
244
|
+
</sdk-querying>`,
|
|
245
|
+
})
|
|
246
|
+
|
|
247
|
+
const zodSchemaSkillTools = [] as const
|
|
248
|
+
|
|
249
|
+
export const zodSchemaSkill = defineSkill({
|
|
250
|
+
name: 'zod-schema-boundaries',
|
|
251
|
+
description:
|
|
252
|
+
'Define Zod schemas that keep SurrealDB row parsing separate from API/tool contracts. Use this whenever shared schemas, DB row schemas, tool arguments, or serialized execution-plan payloads are added or changed.',
|
|
253
|
+
tools: zodSchemaSkillTools,
|
|
254
|
+
instructions: `# zod-schema-boundaries
|
|
255
|
+
|
|
256
|
+
## Description
|
|
257
|
+
|
|
258
|
+
Use this skill whenever you touch shared schemas, DB record parsers, tool contracts, or serialized API payloads.
|
|
259
|
+
|
|
260
|
+
## Details
|
|
261
|
+
|
|
262
|
+
<datetime-boundary>
|
|
263
|
+
- DB row schemas use \`z.coerce.date()\` for SurrealDB datetime fields such as \`createdAt\`, \`updatedAt\`, and stored schedule timestamps.
|
|
264
|
+
- Tool and API schemas that must remain JSON Schema compatible use ISO datetime strings, typically \`z.iso.datetime()\`.
|
|
265
|
+
- Do not blur the boundary with \`z.union([z.string(), z.date()])\`, preprocess hacks, or mixed-type public contracts.
|
|
266
|
+
</datetime-boundary>
|
|
267
|
+
|
|
268
|
+
<serialization-boundary>
|
|
269
|
+
- Parse DB records at the SDK boundary, then serialize outward deliberately.
|
|
270
|
+
- Shared host-facing contracts should expose plain JSON values and strings, not Surreal SDK classes or runtime-only objects.
|
|
271
|
+
- Reuse existing shared schema fragments before inventing another timestamp or record-id representation.
|
|
272
|
+
</serialization-boundary>
|
|
273
|
+
|
|
274
|
+
<shape-rules>
|
|
275
|
+
- Keep public contracts explicit and small.
|
|
276
|
+
- Prefer strict object schemas for tool arguments and serialized payloads.
|
|
277
|
+
- Use flexible object fields only where the domain genuinely requires open-ended storage.
|
|
278
|
+
- Reuse shared helpers like \`recordIdSchema\` for current host-facing string-or-\`{ tb, id }\` record-id contracts, and keep richer array/object record IDs internal unless the public API truly needs them.
|
|
279
|
+
</shape-rules>`,
|
|
280
|
+
})
|
|
281
|
+
|
|
204
282
|
export const generalRule = defineRule({
|
|
205
283
|
name: 'general',
|
|
206
284
|
instructions: `# General Rules
|
package/src/ai/index.ts
CHANGED
package/src/bifrost/bifrost.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { createOpenAI } from '@ai-sdk/openai'
|
|
|
3
3
|
import { wrapLanguageModel } from 'ai'
|
|
4
4
|
import type { LanguageModelMiddleware } from 'ai'
|
|
5
5
|
|
|
6
|
+
import { getRequiredEnv } from '../utils/env'
|
|
6
7
|
import { isRecord, readString } from '../utils/string'
|
|
7
8
|
|
|
8
9
|
type BifrostLanguageModel = Parameters<typeof wrapLanguageModel>[0]['model']
|
|
@@ -21,9 +22,7 @@ const OPENROUTER_RESPONSE_HEALING_EXTRA_PARAMS = {
|
|
|
21
22
|
} as const satisfies BifrostExtraParams
|
|
22
23
|
|
|
23
24
|
function readRequiredGatewayEnv(name: 'AI_GATEWAY_KEY' | 'AI_GATEWAY_URL'): string {
|
|
24
|
-
|
|
25
|
-
if (value) return value
|
|
26
|
-
throw new Error(`[bifrost] Missing ${name}.`)
|
|
25
|
+
return getRequiredEnv(name).trim()
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
function readReasoningDetailsText(value: unknown): string | null {
|
|
@@ -248,10 +247,6 @@ function createBifrostProvider(extraParams?: BifrostExtraParams) {
|
|
|
248
247
|
}
|
|
249
248
|
|
|
250
249
|
function withBifrostDevTools<TModel extends BifrostLanguageModel>(model: TModel): TModel {
|
|
251
|
-
if (process.env.NODE_ENV === 'production') {
|
|
252
|
-
return model
|
|
253
|
-
}
|
|
254
|
-
|
|
255
250
|
return wrapLanguageModel({ model, middleware: devToolsMiddleware() }) as TModel
|
|
256
251
|
}
|
|
257
252
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type
|
|
1
|
+
import type { AgentFactory, AgentRuntimeConfigProvider, AgentToolBuilder } from './agent-types'
|
|
2
2
|
|
|
3
3
|
function defaultBuildAgentTools(): Record<string, never> {
|
|
4
4
|
return {}
|
|
@@ -49,10 +49,15 @@ export function configureAgents(config: {
|
|
|
49
49
|
if (config.getCoreWorkstreamProfile) {
|
|
50
50
|
getCoreWorkstreamProfile = config.getCoreWorkstreamProfile
|
|
51
51
|
}
|
|
52
|
+
_agentRosterSet = null
|
|
53
|
+
_aliasMap = null
|
|
52
54
|
}
|
|
53
55
|
|
|
56
|
+
let _agentRosterSet: Set<string> | null = null
|
|
57
|
+
|
|
54
58
|
export function isAgentName(value: unknown): value is string {
|
|
55
|
-
|
|
59
|
+
_agentRosterSet ??= new Set(agentRoster)
|
|
60
|
+
return typeof value === 'string' && _agentRosterSet.has(value)
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
export function getLeadAgentId(): string {
|
|
@@ -63,31 +68,36 @@ export function getLeadAgentDisplayName(): string {
|
|
|
63
68
|
return agentDisplayNames[leadAgentId] ?? leadAgentId
|
|
64
69
|
}
|
|
65
70
|
|
|
71
|
+
let _aliasMap: Map<string, string> | null = null
|
|
72
|
+
|
|
66
73
|
export function resolveAgentNameAlias(value: unknown): string | undefined {
|
|
67
74
|
if (typeof value !== 'string') return undefined
|
|
68
75
|
const lowered = value.trim().toLowerCase()
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
_aliasMap ??= (() => {
|
|
77
|
+
const map = new Map<string, string>()
|
|
78
|
+
for (const agent of agentRoster) {
|
|
79
|
+
map.set(agent.toLowerCase(), agent)
|
|
80
|
+
const displayName = agentDisplayNames[agent]
|
|
81
|
+
if (displayName) map.set(displayName.toLowerCase(), agent)
|
|
82
|
+
const shortName = agentShortDisplayNames[agent]
|
|
83
|
+
if (shortName) map.set(shortName.toLowerCase(), agent)
|
|
84
|
+
}
|
|
85
|
+
return map
|
|
86
|
+
})()
|
|
87
|
+
return _aliasMap.get(lowered)
|
|
78
88
|
}
|
|
79
89
|
|
|
80
|
-
export let createAgent:
|
|
90
|
+
export let createAgent: AgentFactory = {}
|
|
81
91
|
|
|
82
|
-
export let buildAgentTools:
|
|
83
|
-
export let getAgentRuntimeConfig:
|
|
84
|
-
export let pluginRuntime: unknown = undefined
|
|
92
|
+
export let buildAgentTools: AgentToolBuilder = defaultBuildAgentTools
|
|
93
|
+
export let getAgentRuntimeConfig: AgentRuntimeConfigProvider = defaultGetAgentRuntimeConfig
|
|
94
|
+
export let pluginRuntime: Record<string, unknown> | undefined = undefined
|
|
85
95
|
|
|
86
96
|
export function configureAgentFactory(config: {
|
|
87
|
-
createAgent?:
|
|
88
|
-
buildAgentTools?:
|
|
89
|
-
getAgentRuntimeConfig?:
|
|
90
|
-
pluginRuntime?: unknown
|
|
97
|
+
createAgent?: AgentFactory
|
|
98
|
+
buildAgentTools?: AgentToolBuilder
|
|
99
|
+
getAgentRuntimeConfig?: AgentRuntimeConfigProvider
|
|
100
|
+
pluginRuntime?: Record<string, unknown>
|
|
91
101
|
}): void {
|
|
92
102
|
createAgent = config.createAgent ?? {}
|
|
93
103
|
buildAgentTools = config.buildAgentTools ?? defaultBuildAgentTools
|
|
@@ -110,8 +120,8 @@ export function extractAgentMentions(message: string): AgentMentionMatch[] {
|
|
|
110
120
|
|
|
111
121
|
const regex = new RegExp(AGENT_MENTION_REGEX)
|
|
112
122
|
for (const rawMatch of message.matchAll(regex)) {
|
|
113
|
-
const prefix = rawMatch[1]
|
|
114
|
-
const rawAgent =
|
|
123
|
+
const prefix = rawMatch[1]
|
|
124
|
+
const rawAgent = rawMatch[2].toLowerCase()
|
|
115
125
|
if (!isAgentName(rawAgent)) continue
|
|
116
126
|
|
|
117
127
|
const index = rawMatch.index + prefix.length
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry of agent factory functions keyed by agent name.
|
|
3
|
+
* Each factory receives runtime args and returns an agent instance.
|
|
4
|
+
*/
|
|
5
|
+
export type AgentFactory = Record<string, (...args: unknown[]) => unknown>
|
|
6
|
+
|
|
7
|
+
/** Builds the tool set for a given agent. */
|
|
8
|
+
export type AgentToolBuilder = (...args: unknown[]) => unknown
|
|
9
|
+
|
|
10
|
+
/** Returns runtime configuration for a given agent. */
|
|
11
|
+
export type AgentRuntimeConfigProvider = (...args: unknown[]) => unknown
|
package/src/config/constants.ts
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
// ============================================================================
|
|
4
|
-
// Memory System Constants
|
|
5
|
-
// ============================================================================
|
|
6
|
-
|
|
7
3
|
export const MEMORY = {
|
|
8
|
-
/** Default number of memory candidates to fetch */
|
|
9
4
|
DEFAULT_CANDIDATE_LIMIT: 12,
|
|
10
|
-
/**
|
|
5
|
+
/** Safety cap to prevent runaway KNN queries */
|
|
11
6
|
MAX_KNN_LIMIT: 100,
|
|
12
7
|
} as const
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
// Validation Helpers
|
|
16
|
-
// ============================================================================
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Validates that a value is a safe integer for KNN queries
|
|
20
|
-
* Throws if validation fails
|
|
21
|
-
*/
|
|
9
|
+
/** Validates that a value is a safe integer for KNN queries. Throws if validation fails. */
|
|
22
10
|
export function validateKnnLimit(limit: unknown): number {
|
|
23
11
|
return z.number().int().positive().max(MEMORY.MAX_KNN_LIMIT).parse(limit)
|
|
24
12
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { chatLogger } from './logger'
|
|
2
2
|
|
|
3
|
-
const isDebug = () =>
|
|
3
|
+
const isDebug = (): boolean => {
|
|
4
|
+
const level = process.env.LOG_LEVEL
|
|
5
|
+
const flag = process.env.LOTA_DEBUG
|
|
6
|
+
return level === 'debug' || flag === '1'
|
|
7
|
+
}
|
|
4
8
|
|
|
5
9
|
interface DebugTimer {
|
|
6
10
|
step(name: string): void
|
package/src/config/index.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export * from './agent-defaults'
|
|
2
|
+
export * from './agent-types'
|
|
2
3
|
export * from './background-processing'
|
|
4
|
+
export * from './constants'
|
|
3
5
|
export * from './logger'
|
|
4
6
|
export * from './model-constants'
|
|
7
|
+
export * from './search'
|
|
5
8
|
export * from './workstream-defaults'
|
|
@@ -1,34 +1,16 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
openai: { forceReasoning: true, reasoningEffort: 'high', reasoningSummary: BIFROST_REASONING_SUMMARY_LEVEL },
|
|
18
|
-
} as const
|
|
19
|
-
|
|
20
|
-
export const OPENROUTER_XHIGH_REASONING_PROVIDER_OPTIONS = {
|
|
21
|
-
openai: { forceReasoning: true, reasoningEffort: 'xhigh', reasoningSummary: BIFROST_REASONING_SUMMARY_LEVEL },
|
|
22
|
-
} as const
|
|
23
|
-
|
|
24
|
-
export const OPENROUTER_MEDIUM_REASONING_PROVIDER_OPTIONS = {
|
|
25
|
-
openai: { forceReasoning: true, reasoningEffort: 'medium', reasoningSummary: BIFROST_REASONING_SUMMARY_LEVEL },
|
|
26
|
-
} as const
|
|
27
|
-
|
|
28
|
-
export const OPENROUTER_LOW_REASONING_PROVIDER_OPTIONS = {
|
|
29
|
-
openai: { forceReasoning: true, reasoningEffort: 'low', reasoningSummary: BIFROST_REASONING_SUMMARY_LEVEL },
|
|
30
|
-
} as const
|
|
31
|
-
|
|
32
|
-
export const OPENROUTER_MINIMAL_REASONING_PROVIDER_OPTIONS = {
|
|
33
|
-
openai: { forceReasoning: true, reasoningEffort: 'minimal', reasoningSummary: BIFROST_REASONING_SUMMARY_LEVEL },
|
|
34
|
-
} as const
|
|
1
|
+
export {
|
|
2
|
+
BIFROST_REASONING_SUMMARY_LEVEL,
|
|
3
|
+
OPENAI_HIGH_REASONING_PROVIDER_OPTIONS,
|
|
4
|
+
OPENAI_REASONING_MODEL_ID,
|
|
5
|
+
OPENROUTER_DELEGATED_REASONING_MODEL_ID,
|
|
6
|
+
OPENROUTER_FAST_REASONING_MODEL_ID,
|
|
7
|
+
OPENROUTER_HIGH_REASONING_PROVIDER_OPTIONS,
|
|
8
|
+
OPENROUTER_LOW_REASONING_PROVIDER_OPTIONS,
|
|
9
|
+
OPENROUTER_MEDIUM_REASONING_PROVIDER_OPTIONS,
|
|
10
|
+
OPENROUTER_MINIMAL_REASONING_PROVIDER_OPTIONS,
|
|
11
|
+
OPENROUTER_STRUCTURED_HELPER_MODEL_ID,
|
|
12
|
+
OPENROUTER_STRUCTURED_REASONING_MODEL_ID,
|
|
13
|
+
OPENROUTER_TEAM_AGENT_MODEL_ID,
|
|
14
|
+
OPENROUTER_WEB_RESEARCH_MODEL_ID,
|
|
15
|
+
OPENROUTER_XHIGH_REASONING_PROVIDER_OPTIONS,
|
|
16
|
+
} from '@lota-sdk/shared'
|
package/src/config/search.ts
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
* Search-related constants for vector search and hybrid search
|
|
3
|
-
*/
|
|
1
|
+
export { VECTOR_SEARCH_OVERFETCH_MULTIPLIER } from '@lota-sdk/shared'
|
|
4
2
|
|
|
5
|
-
/**
|
|
6
|
-
* Multiplier for vector search fetch limit.
|
|
7
|
-
* We fetch more candidates than needed (limit * multiplier) to allow for:
|
|
8
|
-
* - RRF (Reciprocal Rank Fusion) re-ranking
|
|
9
|
-
* - Hybrid search combining vector + full-text results
|
|
10
|
-
* - Filtering out low-quality matches before returning final results
|
|
11
|
-
*/
|
|
12
|
-
export const VECTOR_SEARCH_OVERFETCH_MULTIPLIER = 2
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Default limit for memory search queries
|
|
16
|
-
*/
|
|
17
3
|
export const DEFAULT_MEMORY_SEARCH_LIMIT = 10
|