@lota-sdk/core 0.1.15 → 0.1.17
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 +12 -8
- package/src/ai/definitions.ts +81 -3
- package/src/ai/embedding-cache.ts +2 -4
- package/src/ai/index.ts +0 -2
- package/src/bifrost/bifrost.ts +2 -7
- package/src/bifrost/cache-headers.ts +8 -0
- package/src/bifrost/index.ts +1 -0
- 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 +269 -178
- package/src/db/cursor-pagination.ts +3 -6
- package/src/db/index.ts +2 -0
- package/src/db/memory-store.helpers.ts +1 -3
- 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/schema-fingerprint.ts +1 -3
- 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/document-processor.queue.ts +2 -4
- 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 +20 -55
- 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/redis-lease-lock.ts +1 -2
- package/src/redis/stream-context.ts +11 -0
- package/src/runtime/agent-runtime-policy.ts +109 -35
- package/src/runtime/approval-continuation.ts +12 -6
- package/src/runtime/context-compaction-runtime.ts +1 -1
- package/src/runtime/context-compaction.ts +24 -64
- 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 +3 -1
- 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 +111 -14
- package/src/runtime/runtime-extensions.ts +2 -3
- package/src/runtime/runtime-worker-registry.ts +6 -0
- package/src/runtime/social-chat.ts +752 -0
- package/src/runtime/team-consultation-orchestrator.ts +45 -32
- 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 +292 -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 +2 -4
- 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 +27 -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 +49 -61
- 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 +28 -34
- package/src/services/skill-resolver.service.ts +19 -0
- package/src/services/social-chat-history.service.ts +197 -0
- package/src/services/system-executor.service.ts +105 -0
- package/src/services/workstream-message.service.ts +13 -37
- 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 -89
- 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/context-compaction.agent.ts +2 -0
- package/src/system-agents/delegated-agent-factory.ts +5 -0
- package/src/system-agents/memory-reranker.agent.ts +4 -2
- package/src/system-agents/memory.agent.ts +2 -0
- package/src/system-agents/recent-activity-title-refiner.agent.ts +2 -0
- package/src/system-agents/regular-chat-memory-digest.agent.ts +2 -0
- package/src/system-agents/skill-extractor.agent.ts +2 -0
- package/src/system-agents/skill-manager.agent.ts +2 -0
- package/src/system-agents/title-generator.agent.ts +2 -0
- package/src/tools/execution-plan.tool.ts +17 -23
- package/src/tools/index.ts +0 -1
- package/src/tools/research-topic.tool.ts +2 -0
- package/src/tools/team-think.tool.ts +5 -6
- 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.helpers.ts +1 -1
- package/src/workers/regular-chat-memory-digest.runner.ts +45 -12
- package/src/workers/skill-extraction.runner.ts +26 -6
- package/src/workers/utils/file-section-chunker.ts +2 -1
- package/src/workers/utils/repo-structure-extractor.ts +2 -2
- 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 +14 -25
- package/src/workers/worker-utils.ts +2 -2
- package/src/runtime/workstream-routing-policy.ts +0 -267
- package/src/tools/log-hello-world.tool.ts +0 -17
|
@@ -1,34 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { requireTimestamp } from '@lota-sdk/shared'
|
|
2
2
|
import { BoundQuery } from 'surrealdb'
|
|
3
3
|
import { z } from 'zod'
|
|
4
4
|
|
|
5
|
-
import { ensureRecordId } from '../../db/record-id'
|
|
5
|
+
import { ensureRecordId, recordIdToString } from '../../db/record-id'
|
|
6
6
|
import type { RecordIdRef } from '../../db/record-id'
|
|
7
7
|
import { databaseService } from '../../db/service'
|
|
8
8
|
import { TABLES } from '../../db/tables'
|
|
9
|
+
import { WorkstreamMessageRowSchema } from '../../db/workstream-message-row'
|
|
10
|
+
import type { WorkstreamMessageRow } from '../../db/workstream-message-row'
|
|
9
11
|
import { normalizeTextBody } from '../../document/parsing'
|
|
12
|
+
import type { LotaRuntimeBackgroundCursor } from '../../runtime/runtime-extensions'
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
const MessageRoleSchema = z.enum(['system', 'user', 'assistant'])
|
|
13
|
-
const MessagePartSchema = z.record(z.string(), z.unknown())
|
|
14
|
-
const MessageMetadataSchema = z.record(z.string(), z.unknown()).nullish()
|
|
15
|
-
|
|
16
|
-
const WorkstreamMessageRowSchema = z.object({
|
|
17
|
-
id: z.string(),
|
|
18
|
-
workstreamId: z.string(),
|
|
19
|
-
role: MessageRoleSchema,
|
|
20
|
-
parts: z.array(MessagePartSchema).optional(),
|
|
21
|
-
metadata: MessageMetadataSchema,
|
|
22
|
-
createdAt: RecordTimestampSchema,
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
export interface DigestCursor {
|
|
26
|
-
createdAt: Date
|
|
27
|
-
id: string
|
|
28
|
-
}
|
|
14
|
+
export type DigestCursor = LotaRuntimeBackgroundCursor
|
|
29
15
|
|
|
30
16
|
export interface DigestMessage {
|
|
31
|
-
source: 'workstream'
|
|
17
|
+
source: 'workstream' | 'social'
|
|
32
18
|
sourceId: string
|
|
33
19
|
role: 'system' | 'user' | 'assistant'
|
|
34
20
|
parts: Array<Record<string, unknown>>
|
|
@@ -36,14 +22,17 @@ export interface DigestMessage {
|
|
|
36
22
|
cursor: DigestCursor
|
|
37
23
|
}
|
|
38
24
|
|
|
39
|
-
function mapWorkstreamRow(row:
|
|
25
|
+
function mapWorkstreamRow(row: WorkstreamMessageRow): DigestMessage {
|
|
40
26
|
return {
|
|
41
27
|
source: 'workstream',
|
|
42
|
-
sourceId: row.workstreamId,
|
|
28
|
+
sourceId: recordIdToString(row.workstreamId, TABLES.WORKSTREAM),
|
|
43
29
|
role: row.role,
|
|
44
|
-
parts: row.parts
|
|
30
|
+
parts: row.parts as Array<Record<string, unknown>>,
|
|
45
31
|
metadata: row.metadata ?? undefined,
|
|
46
|
-
cursor: {
|
|
32
|
+
cursor: {
|
|
33
|
+
createdAt: new Date(requireTimestamp(row.createdAt)),
|
|
34
|
+
id: recordIdToString(row.id, TABLES.WORKSTREAM_MESSAGE),
|
|
35
|
+
},
|
|
47
36
|
}
|
|
48
37
|
}
|
|
49
38
|
|
|
@@ -4,6 +4,7 @@ import { fileURLToPath } from 'node:url'
|
|
|
4
4
|
import type { Job, Worker } from 'bullmq'
|
|
5
5
|
|
|
6
6
|
import { chatLogger } from '../config/logger'
|
|
7
|
+
import { truncateText } from '../utils/string'
|
|
7
8
|
|
|
8
9
|
export const DEFAULT_JOB_RETENTION = { removeOnComplete: 200, removeOnFail: 200 }
|
|
9
10
|
export const LOW_JOB_RETENTION = { removeOnComplete: 50, removeOnFail: 50 }
|
|
@@ -32,8 +33,7 @@ interface TracedWorkerJobLike {
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
function truncateTraceString(value: string, maxChars = MAX_TRACE_STRING_CHARS): string {
|
|
35
|
-
|
|
36
|
-
return `${value.slice(0, maxChars - 3)}...`
|
|
36
|
+
return truncateText(value, maxChars)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function normalizeTraceValue(value: unknown, depth = 0): unknown {
|
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import { extractAgentMentions, getLeadAgentId } from '../config/agent-defaults'
|
|
2
|
-
|
|
3
|
-
export type MessageRoute =
|
|
4
|
-
| { type: 'direct'; agents: [string] }
|
|
5
|
-
| { type: 'mentions'; agents: string[] }
|
|
6
|
-
| { type: 'group-default'; agents: [string] }
|
|
7
|
-
|
|
8
|
-
export type ReasoningProfileName = 'fast' | 'standard' | 'deep'
|
|
9
|
-
|
|
10
|
-
export interface ReasoningProfile {
|
|
11
|
-
name: ReasoningProfileName
|
|
12
|
-
maxSteps: number
|
|
13
|
-
toolCallBudget: number
|
|
14
|
-
maxInputTokensHint: number
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type HighImpactResponseClass =
|
|
18
|
-
| 'architecture-recommendation'
|
|
19
|
-
| 'gtm-strategy'
|
|
20
|
-
| 'pricing-positioning'
|
|
21
|
-
| 'product-capability-claim'
|
|
22
|
-
| 'community-targeting'
|
|
23
|
-
| 'mutating-operation'
|
|
24
|
-
|
|
25
|
-
export type PolicyClass = 'external-mutation' | 'security-privacy' | 'legal-compliance' | 'financial-decision'
|
|
26
|
-
|
|
27
|
-
export function uniqueMentionOrder(message: string): string[] {
|
|
28
|
-
const ordered: string[] = []
|
|
29
|
-
const seen = new Set<string>()
|
|
30
|
-
for (const mention of extractAgentMentions(message)) {
|
|
31
|
-
const agent = mention.agent
|
|
32
|
-
if (seen.has(agent)) continue
|
|
33
|
-
seen.add(agent)
|
|
34
|
-
ordered.push(agent)
|
|
35
|
-
}
|
|
36
|
-
return ordered
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const HIGH_IMPACT_CLASS_PATTERNS: Array<{ className: HighImpactResponseClass; patterns: RegExp[] }> = [
|
|
40
|
-
{
|
|
41
|
-
className: 'architecture-recommendation',
|
|
42
|
-
patterns: [
|
|
43
|
-
/\barchitecture\b/i,
|
|
44
|
-
/\btech(?:nical)?\s+stack\b/i,
|
|
45
|
-
/\binfra(?:structure)?\b/i,
|
|
46
|
-
/\brefactor\b/i,
|
|
47
|
-
/\bsystem\s+design\b/i,
|
|
48
|
-
],
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
className: 'gtm-strategy',
|
|
52
|
-
patterns: [
|
|
53
|
-
/\bgo[-\s]?to[-\s]?market\b/i,
|
|
54
|
-
/\bgtm\b/i,
|
|
55
|
-
/\bdistribution\s+strategy\b/i,
|
|
56
|
-
/\blaunch\s+strategy\b/i,
|
|
57
|
-
/\bcontent\s+strategy\b/i,
|
|
58
|
-
/\bdemand\s+gen(?:eration)?\b/i,
|
|
59
|
-
],
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
className: 'pricing-positioning',
|
|
63
|
-
patterns: [/\bpricing\b/i, /\bpositioning\b/i, /\bpackaging\b/i, /\bfreemium\b/i, /\bbilling\b/i],
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
className: 'product-capability-claim',
|
|
67
|
-
patterns: [
|
|
68
|
-
/\bdoes\s+it\s+(already\s+)?(support|have|do)\b/i,
|
|
69
|
-
/\bwhat\s+can\s+(it|we)\s+do\b/i,
|
|
70
|
-
/\bis\s+this\s+implemented\b/i,
|
|
71
|
-
/\bcurrent(?:ly)?\s+supports?\b/i,
|
|
72
|
-
/\bcapabilities?\b/i,
|
|
73
|
-
],
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
className: 'community-targeting',
|
|
77
|
-
patterns: [
|
|
78
|
-
/\bwhere\s+to\s+post\b/i,
|
|
79
|
-
/\bcommunity\b/i,
|
|
80
|
-
/\btarget\s+audience\b/i,
|
|
81
|
-
/\bchannels?\b/i,
|
|
82
|
-
/\bdistribution\s+channels?\b/i,
|
|
83
|
-
],
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
className: 'mutating-operation',
|
|
87
|
-
patterns: [
|
|
88
|
-
/\bdelete\s+(issue|comment|task|record|workspace|project)\b/i,
|
|
89
|
-
/\bremove\s+(issue|comment|task|record|workspace|project)\b/i,
|
|
90
|
-
/\bupdate\s+(issue|comment|task|record|workspace|project)\b/i,
|
|
91
|
-
/\bcreate\s+(issue|comment|task|record|workspace|project)\b/i,
|
|
92
|
-
/\bchange\s+(issue|comment|task|record|workspace|project)\b/i,
|
|
93
|
-
/\barchive\b/i,
|
|
94
|
-
/\bskip\s+onboarding\b/i,
|
|
95
|
-
/\bproceed\s+in\s+onboarding\b/i,
|
|
96
|
-
],
|
|
97
|
-
},
|
|
98
|
-
]
|
|
99
|
-
|
|
100
|
-
const POLICY_CLASS_PATTERNS: Array<{ className: PolicyClass; patterns: RegExp[] }> = [
|
|
101
|
-
{
|
|
102
|
-
className: 'external-mutation',
|
|
103
|
-
patterns: [
|
|
104
|
-
/\bdelete\s+(issue|comment|task|record|workspace|project)\b/i,
|
|
105
|
-
/\bremove\s+(issue|comment|task|record|workspace|project)\b/i,
|
|
106
|
-
/\bupdate\s+(issue|comment|task|record|workspace|project)\b/i,
|
|
107
|
-
/\bcreate\s+(issue|comment|task|record|workspace|project)\b/i,
|
|
108
|
-
/\bchange\s+(issue|comment|task|record|workspace|project)\b/i,
|
|
109
|
-
/\barchive\b/i,
|
|
110
|
-
/\bskip\s+onboarding\b/i,
|
|
111
|
-
/\bproceed\s+in\s+onboarding\b/i,
|
|
112
|
-
],
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
className: 'security-privacy',
|
|
116
|
-
patterns: [
|
|
117
|
-
/\bsecurity\b/i,
|
|
118
|
-
/\bprivacy\b/i,
|
|
119
|
-
/\bpii\b/i,
|
|
120
|
-
/\bauth(?:entication|orization)?\b/i,
|
|
121
|
-
/\bencrypt(?:ion|ed)?\b/i,
|
|
122
|
-
/\bpermission(?:s)?\b/i,
|
|
123
|
-
/\baccess\s+control\b/i,
|
|
124
|
-
/\bsecret(?:s)?\b/i,
|
|
125
|
-
],
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
className: 'legal-compliance',
|
|
129
|
-
patterns: [
|
|
130
|
-
/\blegal\b/i,
|
|
131
|
-
/\bcompliance\b/i,
|
|
132
|
-
/\bregulation(?:s)?\b/i,
|
|
133
|
-
/\bgdpr\b/i,
|
|
134
|
-
/\bhipaa\b/i,
|
|
135
|
-
/\bsoc\s*2\b/i,
|
|
136
|
-
/\blicense\b/i,
|
|
137
|
-
/\bterms?\b/i,
|
|
138
|
-
],
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
className: 'financial-decision',
|
|
142
|
-
patterns: [
|
|
143
|
-
/\bpricing\b/i,
|
|
144
|
-
/\bbilling\b/i,
|
|
145
|
-
/\brevenue\b/i,
|
|
146
|
-
/\bbudget\b/i,
|
|
147
|
-
/\bburn\s+rate\b/i,
|
|
148
|
-
/\brunway\b/i,
|
|
149
|
-
/\bfundrais(?:e|ing)\b/i,
|
|
150
|
-
/\bcash\s+flow\b/i,
|
|
151
|
-
],
|
|
152
|
-
},
|
|
153
|
-
]
|
|
154
|
-
|
|
155
|
-
const REASONING_PROFILES: Record<ReasoningProfileName, ReasoningProfile> = {
|
|
156
|
-
fast: { name: 'fast', maxSteps: 5, toolCallBudget: 3, maxInputTokensHint: 12_000 },
|
|
157
|
-
standard: { name: 'standard', maxSteps: 10, toolCallBudget: 6, maxInputTokensHint: 24_000 },
|
|
158
|
-
deep: { name: 'deep', maxSteps: 15, toolCallBudget: 10, maxInputTokensHint: 36_000 },
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
const STRATEGIC_COMPLEXITY_PATTERNS: RegExp[] = [
|
|
162
|
-
/\bstrategy\b/i,
|
|
163
|
-
/\btrade[-\s]?off\b/i,
|
|
164
|
-
/\bcompare\b/i,
|
|
165
|
-
/\broadmap\b/i,
|
|
166
|
-
/\barchitecture\b/i,
|
|
167
|
-
/\bconstraints?\b/i,
|
|
168
|
-
/\bprioriti(?:y|es)\b/i,
|
|
169
|
-
]
|
|
170
|
-
|
|
171
|
-
const CROSS_SOURCE_COMPLEXITY_PATTERNS: RegExp[] = [
|
|
172
|
-
/\bcitation\b/i,
|
|
173
|
-
/\bevidence\b/i,
|
|
174
|
-
/\bsource\b/i,
|
|
175
|
-
/\bground(?:ed|ing)\b/i,
|
|
176
|
-
/\brepo\b/i,
|
|
177
|
-
/\bmemory\b/i,
|
|
178
|
-
]
|
|
179
|
-
|
|
180
|
-
const STANDARD_FLOOR_INTENT_PATTERNS: RegExp[] = [
|
|
181
|
-
/\bplan(?:ning)?\b/i,
|
|
182
|
-
/\bthink(?:ing)?\b/i,
|
|
183
|
-
/\bcareful(?:ly)?\b/i,
|
|
184
|
-
/\bimportant\b/i,
|
|
185
|
-
/\bcritical(?:ly)?\b/i,
|
|
186
|
-
/\bthorough(?:ly)?\b/i,
|
|
187
|
-
]
|
|
188
|
-
|
|
189
|
-
export function classifyHighImpactResponse(params: { message: string }): { classes: HighImpactResponseClass[] } {
|
|
190
|
-
const message = params.message.trim()
|
|
191
|
-
if (!message) return { classes: [] }
|
|
192
|
-
|
|
193
|
-
const classes: HighImpactResponseClass[] = []
|
|
194
|
-
for (const entry of HIGH_IMPACT_CLASS_PATTERNS) {
|
|
195
|
-
if (entry.patterns.some((pattern) => pattern.test(message))) {
|
|
196
|
-
classes.push(entry.className)
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return { classes }
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export function classifyPolicyClasses(params: { message: string }): { classes: PolicyClass[] } {
|
|
204
|
-
const message = params.message.trim()
|
|
205
|
-
if (!message) return { classes: [] }
|
|
206
|
-
|
|
207
|
-
const classes: PolicyClass[] = []
|
|
208
|
-
for (const entry of POLICY_CLASS_PATTERNS) {
|
|
209
|
-
if (entry.patterns.some((pattern) => pattern.test(message))) {
|
|
210
|
-
classes.push(entry.className)
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return { classes }
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
export function resolveReasoningProfile(params: {
|
|
218
|
-
message: string
|
|
219
|
-
forceDeep?: boolean
|
|
220
|
-
explicitProfile?: ReasoningProfileName
|
|
221
|
-
}): ReasoningProfile {
|
|
222
|
-
if (params.explicitProfile) {
|
|
223
|
-
return REASONING_PROFILES[params.explicitProfile]
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
const text = params.message.trim()
|
|
227
|
-
if (!text) {
|
|
228
|
-
return REASONING_PROFILES.standard
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
let score = 0
|
|
232
|
-
if (text.length >= 700) score += 3
|
|
233
|
-
else if (text.length >= 350) score += 2
|
|
234
|
-
else if (text.length >= 180) score += 1
|
|
235
|
-
|
|
236
|
-
const numberedListCount = (text.match(/\n\s*\d+\./g) ?? []).length
|
|
237
|
-
if (numberedListCount >= 3) score += 2
|
|
238
|
-
else if (numberedListCount >= 1) score += 1
|
|
239
|
-
|
|
240
|
-
if (STRATEGIC_COMPLEXITY_PATTERNS.some((pattern) => pattern.test(text))) score += 2
|
|
241
|
-
if (CROSS_SOURCE_COMPLEXITY_PATTERNS.some((pattern) => pattern.test(text))) score += 2
|
|
242
|
-
if (params.forceDeep) score += 2
|
|
243
|
-
if (STANDARD_FLOOR_INTENT_PATTERNS.some((pattern) => pattern.test(text))) {
|
|
244
|
-
score += 3
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
if (score >= 7) return REASONING_PROFILES.deep
|
|
248
|
-
if (score >= 3) return REASONING_PROFILES.standard
|
|
249
|
-
return REASONING_PROFILES.fast
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
export function resolveMessageRoute(params: {
|
|
253
|
-
workstreamMode: 'direct' | 'group'
|
|
254
|
-
workstreamAgentId?: string
|
|
255
|
-
message: string
|
|
256
|
-
}): MessageRoute {
|
|
257
|
-
if (params.workstreamMode === 'direct') {
|
|
258
|
-
return { type: 'direct', agents: [params.workstreamAgentId ?? getLeadAgentId()] }
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
const mentions = uniqueMentionOrder(params.message)
|
|
262
|
-
if (mentions.length > 0) {
|
|
263
|
-
return { type: 'mentions', agents: mentions }
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
return { type: 'group-default', agents: [getLeadAgentId()] }
|
|
267
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { tool } from 'ai'
|
|
2
|
-
import { z } from 'zod'
|
|
3
|
-
|
|
4
|
-
export function createLogHelloWorldTool() {
|
|
5
|
-
return tool({
|
|
6
|
-
description: 'Logs "Hello World" to the server console. Requires user approval before running.',
|
|
7
|
-
inputSchema: z.object({
|
|
8
|
-
message: z.string().optional().describe('Optional custom message to log alongside Hello World'),
|
|
9
|
-
}),
|
|
10
|
-
needsApproval: true,
|
|
11
|
-
execute: async ({ message }: { message?: string }) => {
|
|
12
|
-
const output = message ? `Hello World: ${message}` : 'Hello World'
|
|
13
|
-
console.log('[logHelloWorld]', output)
|
|
14
|
-
return { logged: output, timestamp: new Date().toISOString() }
|
|
15
|
-
},
|
|
16
|
-
})
|
|
17
|
-
}
|