@soleri/core 2.11.0 → 7.0.0
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/data/flows/build.flow.yaml +128 -0
- package/data/flows/deliver.flow.yaml +110 -0
- package/data/flows/design.flow.yaml +108 -0
- package/data/flows/enhance.flow.yaml +90 -0
- package/data/flows/explore.flow.yaml +84 -0
- package/data/flows/fix.flow.yaml +90 -0
- package/data/flows/plan.flow.yaml +87 -0
- package/data/flows/review.flow.yaml +90 -0
- package/dist/brain/brain.d.ts.map +1 -1
- package/dist/brain/brain.js +10 -0
- package/dist/brain/brain.js.map +1 -1
- package/dist/brain/intelligence.d.ts.map +1 -1
- package/dist/brain/intelligence.js +16 -2
- package/dist/brain/intelligence.js.map +1 -1
- package/dist/capabilities/chain-mapping.d.ts +21 -0
- package/dist/capabilities/chain-mapping.d.ts.map +1 -0
- package/dist/capabilities/chain-mapping.js +86 -0
- package/dist/capabilities/chain-mapping.js.map +1 -0
- package/dist/capabilities/index.d.ts +10 -0
- package/dist/capabilities/index.d.ts.map +1 -0
- package/dist/capabilities/index.js +8 -0
- package/dist/capabilities/index.js.map +1 -0
- package/dist/capabilities/registry.d.ts +95 -0
- package/dist/capabilities/registry.d.ts.map +1 -0
- package/dist/capabilities/registry.js +227 -0
- package/dist/capabilities/registry.js.map +1 -0
- package/dist/capabilities/types.d.ts +106 -0
- package/dist/capabilities/types.d.ts.map +1 -0
- package/dist/capabilities/types.js +12 -0
- package/dist/capabilities/types.js.map +1 -0
- package/dist/control/intent-router.d.ts.map +1 -1
- package/dist/control/intent-router.js +58 -2
- package/dist/control/intent-router.js.map +1 -1
- package/dist/domain-packs/index.d.ts +8 -0
- package/dist/domain-packs/index.d.ts.map +1 -0
- package/dist/domain-packs/index.js +8 -0
- package/dist/domain-packs/index.js.map +1 -0
- package/dist/domain-packs/inject-rules.d.ts +24 -0
- package/dist/domain-packs/inject-rules.d.ts.map +1 -0
- package/dist/domain-packs/inject-rules.js +65 -0
- package/dist/domain-packs/inject-rules.js.map +1 -0
- package/dist/domain-packs/knowledge-installer.d.ts +27 -0
- package/dist/domain-packs/knowledge-installer.d.ts.map +1 -0
- package/dist/domain-packs/knowledge-installer.js +89 -0
- package/dist/domain-packs/knowledge-installer.js.map +1 -0
- package/dist/domain-packs/loader.d.ts +28 -0
- package/dist/domain-packs/loader.d.ts.map +1 -0
- package/dist/domain-packs/loader.js +105 -0
- package/dist/domain-packs/loader.js.map +1 -0
- package/dist/domain-packs/pack-runtime.d.ts +80 -0
- package/dist/domain-packs/pack-runtime.d.ts.map +1 -0
- package/dist/domain-packs/pack-runtime.js +36 -0
- package/dist/domain-packs/pack-runtime.js.map +1 -0
- package/dist/domain-packs/skills-installer.d.ts +21 -0
- package/dist/domain-packs/skills-installer.d.ts.map +1 -0
- package/dist/domain-packs/skills-installer.js +38 -0
- package/dist/domain-packs/skills-installer.js.map +1 -0
- package/dist/domain-packs/token-resolver.d.ts +37 -0
- package/dist/domain-packs/token-resolver.d.ts.map +1 -0
- package/dist/domain-packs/token-resolver.js +109 -0
- package/dist/domain-packs/token-resolver.js.map +1 -0
- package/dist/domain-packs/types.d.ts +91 -0
- package/dist/domain-packs/types.d.ts.map +1 -0
- package/dist/domain-packs/types.js +122 -0
- package/dist/domain-packs/types.js.map +1 -0
- package/dist/engine/bin/soleri-engine.d.ts +12 -0
- package/dist/engine/bin/soleri-engine.d.ts.map +1 -0
- package/dist/engine/bin/soleri-engine.js +183 -0
- package/dist/engine/bin/soleri-engine.js.map +1 -0
- package/dist/engine/core-ops.d.ts +27 -0
- package/dist/engine/core-ops.d.ts.map +1 -0
- package/dist/engine/core-ops.js +159 -0
- package/dist/engine/core-ops.js.map +1 -0
- package/dist/engine/index.d.ts +19 -0
- package/dist/engine/index.d.ts.map +1 -0
- package/dist/engine/index.js +17 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/register-engine.d.ts +54 -0
- package/dist/engine/register-engine.d.ts.map +1 -0
- package/dist/engine/register-engine.js +270 -0
- package/dist/engine/register-engine.js.map +1 -0
- package/dist/engine/test-helpers.d.ts +30 -0
- package/dist/engine/test-helpers.d.ts.map +1 -0
- package/dist/engine/test-helpers.js +59 -0
- package/dist/engine/test-helpers.js.map +1 -0
- package/dist/flows/context-router.d.ts +39 -0
- package/dist/flows/context-router.d.ts.map +1 -0
- package/dist/flows/context-router.js +206 -0
- package/dist/flows/context-router.js.map +1 -0
- package/dist/flows/dispatch-registry.d.ts +24 -0
- package/dist/flows/dispatch-registry.d.ts.map +1 -0
- package/dist/flows/dispatch-registry.js +70 -0
- package/dist/flows/dispatch-registry.js.map +1 -0
- package/dist/flows/epilogue.d.ts +24 -0
- package/dist/flows/epilogue.d.ts.map +1 -0
- package/dist/flows/epilogue.js +52 -0
- package/dist/flows/epilogue.js.map +1 -0
- package/dist/flows/executor.d.ts +25 -0
- package/dist/flows/executor.d.ts.map +1 -0
- package/dist/flows/executor.js +153 -0
- package/dist/flows/executor.js.map +1 -0
- package/dist/flows/gate-evaluator.d.ts +26 -0
- package/dist/flows/gate-evaluator.d.ts.map +1 -0
- package/dist/flows/gate-evaluator.js +162 -0
- package/dist/flows/gate-evaluator.js.map +1 -0
- package/dist/flows/index.d.ts +14 -0
- package/dist/flows/index.d.ts.map +1 -0
- package/dist/flows/index.js +20 -0
- package/dist/flows/index.js.map +1 -0
- package/dist/flows/loader.d.ts +17 -0
- package/dist/flows/loader.d.ts.map +1 -0
- package/dist/flows/loader.js +61 -0
- package/dist/flows/loader.js.map +1 -0
- package/dist/flows/plan-builder.d.ts +40 -0
- package/dist/flows/plan-builder.d.ts.map +1 -0
- package/dist/flows/plan-builder.js +213 -0
- package/dist/flows/plan-builder.js.map +1 -0
- package/dist/flows/probes.d.ts +11 -0
- package/dist/flows/probes.d.ts.map +1 -0
- package/dist/flows/probes.js +62 -0
- package/dist/flows/probes.js.map +1 -0
- package/dist/flows/types.d.ts +950 -0
- package/dist/flows/types.d.ts.map +1 -0
- package/dist/flows/types.js +105 -0
- package/dist/flows/types.js.map +1 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/intelligence/loader.d.ts +19 -0
- package/dist/intelligence/loader.d.ts.map +1 -1
- package/dist/intelligence/loader.js +86 -5
- package/dist/intelligence/loader.js.map +1 -1
- package/dist/intelligence/types.d.ts +1 -0
- package/dist/intelligence/types.d.ts.map +1 -1
- package/dist/packs/types.d.ts +58 -19
- package/dist/packs/types.d.ts.map +1 -1
- package/dist/packs/types.js +14 -0
- package/dist/packs/types.js.map +1 -1
- package/dist/playbooks/generic/onboarding.d.ts +9 -0
- package/dist/playbooks/generic/onboarding.d.ts.map +1 -0
- package/dist/playbooks/generic/onboarding.js +74 -0
- package/dist/playbooks/generic/onboarding.js.map +1 -0
- package/dist/playbooks/playbook-registry.d.ts.map +1 -1
- package/dist/playbooks/playbook-registry.js +2 -0
- package/dist/playbooks/playbook-registry.js.map +1 -1
- package/dist/runtime/admin-extra-ops.d.ts.map +1 -1
- package/dist/runtime/admin-extra-ops.js +15 -9
- package/dist/runtime/admin-extra-ops.js.map +1 -1
- package/dist/runtime/admin-ops.js +4 -4
- package/dist/runtime/admin-ops.js.map +1 -1
- package/dist/runtime/capture-ops.d.ts.map +1 -1
- package/dist/runtime/capture-ops.js +33 -1
- package/dist/runtime/capture-ops.js.map +1 -1
- package/dist/runtime/domain-ops.d.ts +21 -5
- package/dist/runtime/domain-ops.d.ts.map +1 -1
- package/dist/runtime/domain-ops.js +85 -8
- package/dist/runtime/domain-ops.js.map +1 -1
- package/dist/runtime/facades/cognee-facade.d.ts.map +1 -1
- package/dist/runtime/facades/cognee-facade.js +3 -1
- package/dist/runtime/facades/cognee-facade.js.map +1 -1
- package/dist/runtime/facades/index.d.ts.map +1 -1
- package/dist/runtime/facades/index.js +10 -6
- package/dist/runtime/facades/index.js.map +1 -1
- package/dist/runtime/facades/vault-facade.d.ts.map +1 -1
- package/dist/runtime/facades/vault-facade.js +2 -0
- package/dist/runtime/facades/vault-facade.js.map +1 -1
- package/dist/runtime/orchestrate-ops.d.ts +8 -7
- package/dist/runtime/orchestrate-ops.d.ts.map +1 -1
- package/dist/runtime/orchestrate-ops.js +227 -58
- package/dist/runtime/orchestrate-ops.js.map +1 -1
- package/dist/runtime/runtime.d.ts.map +1 -1
- package/dist/runtime/runtime.js +23 -17
- package/dist/runtime/runtime.js.map +1 -1
- package/dist/runtime/types.d.ts +6 -2
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime/vault-linking-ops.d.ts +13 -0
- package/dist/runtime/vault-linking-ops.d.ts.map +1 -0
- package/dist/runtime/vault-linking-ops.js +367 -0
- package/dist/runtime/vault-linking-ops.js.map +1 -0
- package/dist/vault/linking.d.ts +46 -0
- package/dist/vault/linking.d.ts.map +1 -0
- package/dist/vault/linking.js +275 -0
- package/dist/vault/linking.js.map +1 -0
- package/dist/vault/vault-types.d.ts +37 -0
- package/dist/vault/vault-types.d.ts.map +1 -1
- package/dist/vault/vault.d.ts +12 -0
- package/dist/vault/vault.d.ts.map +1 -1
- package/dist/vault/vault.js +85 -6
- package/dist/vault/vault.js.map +1 -1
- package/package.json +4 -1
- package/src/__tests__/admin-extra-ops.test.ts +1 -1
- package/src/__tests__/admin-ops.test.ts +2 -1
- package/src/__tests__/cognee-client-gaps.test.ts +470 -0
- package/src/__tests__/cognee-hybrid-search.test.ts +478 -0
- package/src/__tests__/cognee-sync-manager-deep.test.ts +630 -0
- package/src/__tests__/cognee-sync-manager.test.ts +1 -0
- package/src/__tests__/core-ops.test.ts +9 -61
- package/src/__tests__/domain-packs.test.ts +421 -0
- package/src/__tests__/flows.test.ts +604 -0
- package/src/__tests__/playbook-registry.test.ts +2 -2
- package/src/__tests__/playbook-seeder.test.ts +8 -8
- package/src/__tests__/playbook.test.ts +5 -5
- package/src/__tests__/token-resolver.test.ts +79 -0
- package/src/brain/brain.ts +12 -0
- package/src/brain/intelligence.ts +21 -2
- package/src/capabilities/chain-mapping.ts +93 -0
- package/src/capabilities/index.ts +21 -0
- package/src/capabilities/registry.ts +290 -0
- package/src/capabilities/types.ts +143 -0
- package/src/control/intent-router.ts +46 -2
- package/src/domain-packs/index.ts +27 -0
- package/src/domain-packs/inject-rules.ts +74 -0
- package/src/domain-packs/knowledge-installer.ts +116 -0
- package/src/domain-packs/loader.ts +124 -0
- package/src/domain-packs/pack-runtime.ts +99 -0
- package/src/domain-packs/skills-installer.ts +56 -0
- package/src/domain-packs/token-resolver.ts +126 -0
- package/src/domain-packs/types.ts +229 -0
- package/src/engine/__tests__/register-engine.test.ts +104 -0
- package/src/engine/bin/soleri-engine.ts +217 -0
- package/src/engine/core-ops.ts +178 -0
- package/src/engine/index.ts +19 -0
- package/src/engine/register-engine.ts +385 -0
- package/src/engine/test-helpers.ts +83 -0
- package/src/flows/context-router.ts +257 -0
- package/src/flows/dispatch-registry.ts +80 -0
- package/src/flows/epilogue.ts +65 -0
- package/src/flows/executor.ts +182 -0
- package/src/flows/gate-evaluator.ts +171 -0
- package/src/flows/index.ts +52 -0
- package/src/flows/loader.ts +63 -0
- package/src/flows/plan-builder.ts +250 -0
- package/src/flows/probes.ts +70 -0
- package/src/flows/types.ts +217 -0
- package/src/index.ts +68 -1
- package/src/intelligence/loader.ts +96 -5
- package/src/intelligence/types.ts +1 -0
- package/src/packs/types.ts +19 -0
- package/src/playbooks/generic/onboarding.ts +79 -0
- package/src/playbooks/playbook-registry.ts +2 -0
- package/src/runtime/admin-extra-ops.ts +14 -8
- package/src/runtime/admin-ops.ts +4 -4
- package/src/runtime/capture-ops.ts +40 -1
- package/src/runtime/domain-ops.ts +92 -7
- package/src/runtime/facades/cognee-facade.ts +3 -1
- package/src/runtime/facades/index.ts +12 -6
- package/src/runtime/facades/vault-facade.ts +2 -0
- package/src/runtime/orchestrate-ops.ts +271 -62
- package/src/runtime/runtime.ts +27 -18
- package/src/runtime/types.ts +6 -2
- package/src/runtime/vault-linking-ops.ts +454 -0
- package/src/vault/linking.ts +333 -0
- package/src/vault/vault-types.ts +46 -0
- package/src/vault/vault.ts +94 -7
|
@@ -1,57 +1,180 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Orchestration operations —
|
|
2
|
+
* Orchestration operations — flow-engine-driven workflows.
|
|
3
3
|
*
|
|
4
|
-
* These ops
|
|
5
|
-
* - orchestrate_plan:
|
|
6
|
-
* - orchestrate_execute:
|
|
7
|
-
* - orchestrate_complete:
|
|
4
|
+
* These ops wire the YAML flow engine into the facade layer:
|
|
5
|
+
* - orchestrate_plan: intent detection + buildPlan from flow engine
|
|
6
|
+
* - orchestrate_execute: FlowExecutor dispatches steps to facade ops
|
|
7
|
+
* - orchestrate_complete: runEpilogue captures knowledge + session
|
|
8
8
|
* - orchestrate_status: combined status across all modules
|
|
9
9
|
* - orchestrate_quick_capture: one-call knowledge capture without full planning
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { z } from 'zod';
|
|
13
|
-
import type { OpDefinition } from '../facades/types.js';
|
|
13
|
+
import type { OpDefinition, FacadeConfig } from '../facades/types.js';
|
|
14
14
|
import type { AgentRuntime } from './types.js';
|
|
15
|
+
import { buildPlan } from '../flows/plan-builder.js';
|
|
16
|
+
import { FlowExecutor } from '../flows/executor.js';
|
|
17
|
+
import { createDispatcher } from '../flows/dispatch-registry.js';
|
|
18
|
+
import { runEpilogue } from '../flows/epilogue.js';
|
|
19
|
+
import type { OrchestrationPlan, ExecutionResult } from '../flows/types.js';
|
|
20
|
+
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
// Intent detection — keyword-based mapping from prompt to intent
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
|
|
25
|
+
const INTENT_KEYWORDS: [RegExp, string][] = [
|
|
26
|
+
[/\b(fix|bug|broken|error|crash|issue)\b/i, 'FIX'],
|
|
27
|
+
[/\b(review|audit|check|inspect)\b/i, 'REVIEW'],
|
|
28
|
+
[/\b(build|create|add|new|implement|scaffold)\b/i, 'BUILD'],
|
|
29
|
+
[/\b(plan|architect|design-system|roadmap)\b/i, 'PLAN'],
|
|
30
|
+
[/\b(enhance|improve|refactor|optimize)\b/i, 'ENHANCE'],
|
|
31
|
+
[/\b(explore|research|investigate|spike)\b/i, 'EXPLORE'],
|
|
32
|
+
[/\b(deploy|ship|release|publish)\b/i, 'DELIVER'],
|
|
33
|
+
[/\b(design|palette|theme|color|typography)\b/i, 'DESIGN'],
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
function detectIntent(prompt: string): string {
|
|
37
|
+
for (const [pattern, intent] of INTENT_KEYWORDS) {
|
|
38
|
+
if (pattern.test(prompt)) return intent;
|
|
39
|
+
}
|
|
40
|
+
return 'BUILD'; // default
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
// In-memory plan store
|
|
45
|
+
// ---------------------------------------------------------------------------
|
|
46
|
+
|
|
47
|
+
interface PlanEntry {
|
|
48
|
+
plan: OrchestrationPlan;
|
|
49
|
+
executionResult?: ExecutionResult;
|
|
50
|
+
createdAt: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const planStore = new Map<string, PlanEntry>();
|
|
54
|
+
|
|
55
|
+
// ---------------------------------------------------------------------------
|
|
56
|
+
// Helper: create a runtime-backed dispatcher
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Build a dispatch function that routes tool names to runtime modules.
|
|
61
|
+
* If facades are provided, uses the full dispatch registry.
|
|
62
|
+
* Otherwise, falls back to a simple runtime-based dispatcher.
|
|
63
|
+
*/
|
|
64
|
+
function buildDispatch(
|
|
65
|
+
agentId: string,
|
|
66
|
+
runtime: AgentRuntime,
|
|
67
|
+
facades?: FacadeConfig[],
|
|
68
|
+
) {
|
|
69
|
+
if (facades && facades.length > 0) {
|
|
70
|
+
return createDispatcher(agentId, facades);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Fallback: runtime-based dispatch for known tool patterns
|
|
74
|
+
return async (
|
|
75
|
+
toolName: string,
|
|
76
|
+
params: Record<string, unknown>,
|
|
77
|
+
): Promise<{ tool: string; status: string; data?: unknown; error?: string }> => {
|
|
78
|
+
try {
|
|
79
|
+
// Handle well-known epilogue tools directly via runtime
|
|
80
|
+
if (toolName === 'capture_knowledge' || toolName.endsWith('_capture_knowledge')) {
|
|
81
|
+
const title = (params.title as string) ?? 'Flow execution';
|
|
82
|
+
const description = (params.content as string) ?? (params.description as string) ?? '';
|
|
83
|
+
const tags = (params.tags as string[]) ?? ['workflow'];
|
|
84
|
+
runtime.vault.add({
|
|
85
|
+
id: `flow-${Date.now()}`,
|
|
86
|
+
title,
|
|
87
|
+
description,
|
|
88
|
+
type: 'pattern',
|
|
89
|
+
domain: 'workflow',
|
|
90
|
+
severity: 'suggestion',
|
|
91
|
+
tags,
|
|
92
|
+
});
|
|
93
|
+
return { tool: toolName, status: 'ok', data: { title } };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (toolName === 'session_capture' || toolName.endsWith('_session_capture')) {
|
|
97
|
+
// Session capture is best-effort
|
|
98
|
+
return { tool: toolName, status: 'ok', data: { sessionId: 'flow-session' } };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// For other tools: mark as unregistered (graceful degradation)
|
|
102
|
+
return { tool: toolName, status: 'unregistered' };
|
|
103
|
+
} catch (err) {
|
|
104
|
+
return {
|
|
105
|
+
tool: toolName,
|
|
106
|
+
status: 'error',
|
|
107
|
+
error: err instanceof Error ? err.message : String(err),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// ---------------------------------------------------------------------------
|
|
114
|
+
// Op factory
|
|
115
|
+
// ---------------------------------------------------------------------------
|
|
15
116
|
|
|
16
117
|
/**
|
|
17
118
|
* Create the 5 orchestration operations for an agent runtime.
|
|
119
|
+
* Optionally accepts facades for full dispatch capability.
|
|
18
120
|
*/
|
|
19
|
-
export function createOrchestrateOps(
|
|
121
|
+
export function createOrchestrateOps(
|
|
122
|
+
runtime: AgentRuntime,
|
|
123
|
+
facades?: FacadeConfig[],
|
|
124
|
+
): OpDefinition[] {
|
|
20
125
|
const { planner, brainIntelligence, vault } = runtime;
|
|
126
|
+
const agentId = runtime.config.agentId;
|
|
21
127
|
|
|
22
128
|
return [
|
|
23
129
|
// ─── orchestrate_plan ─────────────────────────────────────────
|
|
24
130
|
{
|
|
25
131
|
name: 'orchestrate_plan',
|
|
26
132
|
description:
|
|
27
|
-
'Create a
|
|
28
|
-
'
|
|
29
|
-
'
|
|
133
|
+
'Create a flow-engine-driven plan. Detects intent from the prompt, ' +
|
|
134
|
+
'loads the matching YAML flow, probes runtime capabilities, and builds ' +
|
|
135
|
+
'a pruned orchestration plan with gate-guarded steps.',
|
|
30
136
|
auth: 'write',
|
|
31
137
|
schema: z.object({
|
|
32
|
-
|
|
33
|
-
|
|
138
|
+
prompt: z
|
|
139
|
+
.string()
|
|
140
|
+
.describe('Natural language description of what to do'),
|
|
141
|
+
projectPath: z
|
|
142
|
+
.string()
|
|
143
|
+
.optional()
|
|
144
|
+
.default('.')
|
|
145
|
+
.describe('Project root path'),
|
|
146
|
+
// Legacy params — still accepted for backward compat
|
|
147
|
+
objective: z
|
|
148
|
+
.string()
|
|
149
|
+
.optional()
|
|
150
|
+
.describe('(Legacy) Plan objective — use prompt instead'),
|
|
151
|
+
scope: z
|
|
152
|
+
.string()
|
|
153
|
+
.optional()
|
|
154
|
+
.describe('(Legacy) Plan scope'),
|
|
34
155
|
domain: z
|
|
35
156
|
.string()
|
|
36
157
|
.optional()
|
|
37
|
-
.describe('Domain for brain recommendations
|
|
158
|
+
.describe('Domain hint for brain recommendations'),
|
|
38
159
|
tasks: z
|
|
39
160
|
.array(z.object({ title: z.string(), description: z.string() }))
|
|
40
161
|
.optional()
|
|
41
162
|
.describe('Optional pre-defined tasks'),
|
|
42
163
|
}),
|
|
43
164
|
handler: async (params) => {
|
|
44
|
-
const
|
|
45
|
-
const
|
|
165
|
+
const prompt = (params.prompt as string) ?? (params.objective as string) ?? '';
|
|
166
|
+
const projectPath = (params.projectPath as string) ?? '.';
|
|
46
167
|
const domain = params.domain as string | undefined;
|
|
47
|
-
const tasks = (params.tasks as Array<{ title: string; description: string }>) ?? [];
|
|
48
168
|
|
|
49
|
-
//
|
|
169
|
+
// 1. Detect intent from prompt
|
|
170
|
+
const intent = detectIntent(prompt);
|
|
171
|
+
|
|
172
|
+
// 2. Get brain recommendations — graceful degradation
|
|
50
173
|
let recommendations: Array<{ pattern: string; strength: number }> = [];
|
|
51
174
|
try {
|
|
52
175
|
const raw = brainIntelligence.recommend({
|
|
53
176
|
domain,
|
|
54
|
-
task:
|
|
177
|
+
task: prompt,
|
|
55
178
|
limit: 5,
|
|
56
179
|
});
|
|
57
180
|
recommendations = raw.map((r) => ({
|
|
@@ -59,23 +182,63 @@ export function createOrchestrateOps(runtime: AgentRuntime): OpDefinition[] {
|
|
|
59
182
|
strength: r.strength,
|
|
60
183
|
}));
|
|
61
184
|
} catch {
|
|
62
|
-
// Brain has no data yet
|
|
185
|
+
// Brain has no data yet
|
|
63
186
|
}
|
|
64
187
|
|
|
65
|
-
//
|
|
188
|
+
// Fallback to vault if brain empty
|
|
189
|
+
if (recommendations.length === 0) {
|
|
190
|
+
try {
|
|
191
|
+
const vaultResults = vault.search(prompt, { domain, limit: 5 });
|
|
192
|
+
recommendations = vaultResults.map((r) => ({
|
|
193
|
+
pattern: r.entry.title,
|
|
194
|
+
strength: 50,
|
|
195
|
+
}));
|
|
196
|
+
} catch {
|
|
197
|
+
// Vault search failed
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// 3. Build flow-engine plan
|
|
202
|
+
const plan = await buildPlan(intent, agentId, projectPath, runtime, prompt);
|
|
203
|
+
|
|
204
|
+
// 4. Store in planStore
|
|
205
|
+
planStore.set(plan.planId, { plan, createdAt: Date.now() });
|
|
206
|
+
|
|
207
|
+
// 5. Also create a planner plan for lifecycle tracking (backward compat)
|
|
66
208
|
const decisions = recommendations.map(
|
|
67
209
|
(r) => `Brain pattern: ${r.pattern} (strength: ${r.strength.toFixed(1)})`,
|
|
68
210
|
);
|
|
211
|
+
const tasks = (params.tasks as Array<{ title: string; description: string }>) ?? [];
|
|
69
212
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
213
|
+
let legacyPlan;
|
|
214
|
+
try {
|
|
215
|
+
legacyPlan = planner.create({
|
|
216
|
+
objective: prompt,
|
|
217
|
+
scope: (params.scope as string) ?? `${intent} workflow`,
|
|
218
|
+
decisions,
|
|
219
|
+
tasks,
|
|
220
|
+
});
|
|
221
|
+
} catch {
|
|
222
|
+
// Planner creation failed — flow plan still valid
|
|
223
|
+
}
|
|
77
224
|
|
|
78
|
-
return {
|
|
225
|
+
return {
|
|
226
|
+
plan: legacyPlan ?? {
|
|
227
|
+
id: plan.planId,
|
|
228
|
+
objective: prompt,
|
|
229
|
+
decisions,
|
|
230
|
+
},
|
|
231
|
+
recommendations,
|
|
232
|
+
flow: {
|
|
233
|
+
planId: plan.planId,
|
|
234
|
+
intent: plan.intent,
|
|
235
|
+
flowId: plan.flowId,
|
|
236
|
+
stepsCount: plan.steps.length,
|
|
237
|
+
skippedCount: plan.skipped.length,
|
|
238
|
+
warnings: plan.warnings,
|
|
239
|
+
estimatedTools: plan.estimatedTools,
|
|
240
|
+
},
|
|
241
|
+
};
|
|
79
242
|
},
|
|
80
243
|
},
|
|
81
244
|
|
|
@@ -83,11 +246,11 @@ export function createOrchestrateOps(runtime: AgentRuntime): OpDefinition[] {
|
|
|
83
246
|
{
|
|
84
247
|
name: 'orchestrate_execute',
|
|
85
248
|
description:
|
|
86
|
-
'
|
|
87
|
-
'
|
|
249
|
+
'Execute a flow-engine plan. Dispatches each step to its facade ops, ' +
|
|
250
|
+
'evaluates gates, and tracks execution with a brain session.',
|
|
88
251
|
auth: 'write',
|
|
89
252
|
schema: z.object({
|
|
90
|
-
planId: z.string().describe('ID of the
|
|
253
|
+
planId: z.string().describe('ID of the plan to execute (flow planId or legacy planId)'),
|
|
91
254
|
domain: z.string().optional().describe('Domain for brain session tracking'),
|
|
92
255
|
context: z.string().optional().describe('Additional context for the brain session'),
|
|
93
256
|
}),
|
|
@@ -96,10 +259,41 @@ export function createOrchestrateOps(runtime: AgentRuntime): OpDefinition[] {
|
|
|
96
259
|
const domain = params.domain as string | undefined;
|
|
97
260
|
const context = params.context as string | undefined;
|
|
98
261
|
|
|
99
|
-
//
|
|
100
|
-
const
|
|
262
|
+
// Look up flow plan
|
|
263
|
+
const entry = planStore.get(planId);
|
|
264
|
+
|
|
265
|
+
if (entry) {
|
|
266
|
+
// Flow-engine execution path
|
|
267
|
+
const dispatch = buildDispatch(agentId, runtime, facades);
|
|
268
|
+
const executor = new FlowExecutor(dispatch);
|
|
269
|
+
const executionResult = await executor.execute(entry.plan);
|
|
270
|
+
|
|
271
|
+
// Store result
|
|
272
|
+
entry.executionResult = executionResult;
|
|
273
|
+
|
|
274
|
+
// Start brain session
|
|
275
|
+
const session = brainIntelligence.lifecycle({
|
|
276
|
+
action: 'start',
|
|
277
|
+
domain,
|
|
278
|
+
context,
|
|
279
|
+
planId,
|
|
280
|
+
});
|
|
101
281
|
|
|
102
|
-
|
|
282
|
+
return {
|
|
283
|
+
plan: { id: planId, status: 'executing' },
|
|
284
|
+
session,
|
|
285
|
+
execution: {
|
|
286
|
+
status: executionResult.status,
|
|
287
|
+
stepsCompleted: executionResult.stepsCompleted,
|
|
288
|
+
totalSteps: executionResult.totalSteps,
|
|
289
|
+
toolsCalled: executionResult.toolsCalled,
|
|
290
|
+
durationMs: executionResult.durationMs,
|
|
291
|
+
},
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Legacy path: no flow plan found, use planner directly
|
|
296
|
+
const plan = planner.startExecution(planId);
|
|
103
297
|
const session = brainIntelligence.lifecycle({
|
|
104
298
|
action: 'start',
|
|
105
299
|
domain,
|
|
@@ -115,9 +309,8 @@ export function createOrchestrateOps(runtime: AgentRuntime): OpDefinition[] {
|
|
|
115
309
|
{
|
|
116
310
|
name: 'orchestrate_complete',
|
|
117
311
|
description:
|
|
118
|
-
'Complete plan execution,
|
|
119
|
-
'
|
|
120
|
-
'and runs knowledge extraction on the session.',
|
|
312
|
+
'Complete plan execution, run epilogue (knowledge capture + session capture), ' +
|
|
313
|
+
'end brain session, and clean up.',
|
|
121
314
|
auth: 'write',
|
|
122
315
|
schema: z.object({
|
|
123
316
|
planId: z.string().describe('ID of the executing plan to complete'),
|
|
@@ -137,10 +330,10 @@ export function createOrchestrateOps(runtime: AgentRuntime): OpDefinition[] {
|
|
|
137
330
|
const toolsUsed = (params.toolsUsed as string[]) ?? [];
|
|
138
331
|
const filesModified = (params.filesModified as string[]) ?? [];
|
|
139
332
|
|
|
140
|
-
// Complete the plan
|
|
333
|
+
// Complete the planner plan (legacy lifecycle)
|
|
141
334
|
const plan = planner.complete(planId);
|
|
142
335
|
|
|
143
|
-
// End brain session
|
|
336
|
+
// End brain session
|
|
144
337
|
const session = brainIntelligence.lifecycle({
|
|
145
338
|
action: 'end',
|
|
146
339
|
sessionId,
|
|
@@ -150,15 +343,36 @@ export function createOrchestrateOps(runtime: AgentRuntime): OpDefinition[] {
|
|
|
150
343
|
filesModified,
|
|
151
344
|
});
|
|
152
345
|
|
|
153
|
-
// Extract knowledge
|
|
346
|
+
// Extract knowledge
|
|
154
347
|
let extraction = null;
|
|
155
348
|
try {
|
|
156
349
|
extraction = brainIntelligence.extractKnowledge(sessionId);
|
|
157
350
|
} catch {
|
|
158
|
-
//
|
|
351
|
+
// Not enough signal
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// Run flow-engine epilogue if we have a flow plan
|
|
355
|
+
let epilogueResult = null;
|
|
356
|
+
const entry = planStore.get(planId);
|
|
357
|
+
if (entry) {
|
|
358
|
+
try {
|
|
359
|
+
const dispatch = buildDispatch(agentId, runtime, facades);
|
|
360
|
+
const summary = `${outcome}: ${entry.plan.summary}. Tools: ${toolsUsed.join(', ') || 'none'}. Files: ${filesModified.join(', ') || 'none'}.`;
|
|
361
|
+
epilogueResult = await runEpilogue(
|
|
362
|
+
dispatch,
|
|
363
|
+
entry.plan.context.probes,
|
|
364
|
+
entry.plan.context.projectPath,
|
|
365
|
+
summary,
|
|
366
|
+
);
|
|
367
|
+
} catch {
|
|
368
|
+
// Epilogue is best-effort
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// Clean up plan store
|
|
372
|
+
planStore.delete(planId);
|
|
159
373
|
}
|
|
160
374
|
|
|
161
|
-
return { plan, session, extraction };
|
|
375
|
+
return { plan, session, extraction, epilogue: epilogueResult };
|
|
162
376
|
},
|
|
163
377
|
},
|
|
164
378
|
|
|
@@ -167,7 +381,7 @@ export function createOrchestrateOps(runtime: AgentRuntime): OpDefinition[] {
|
|
|
167
381
|
name: 'orchestrate_status',
|
|
168
382
|
description:
|
|
169
383
|
'Get combined orchestration status: active plans, brain session context, ' +
|
|
170
|
-
'vault stats,
|
|
384
|
+
'vault stats, recent brain recommendations, and flow plan store.',
|
|
171
385
|
auth: 'read',
|
|
172
386
|
schema: z.object({
|
|
173
387
|
domain: z.string().optional().describe('Filter recommendations by domain'),
|
|
@@ -180,22 +394,13 @@ export function createOrchestrateOps(runtime: AgentRuntime): OpDefinition[] {
|
|
|
180
394
|
const domain = params.domain as string | undefined;
|
|
181
395
|
const sessionLimit = (params.sessionLimit as number) ?? 5;
|
|
182
396
|
|
|
183
|
-
// Active plans
|
|
184
397
|
const activePlans = planner.getActive();
|
|
185
|
-
|
|
186
|
-
// Brain session context
|
|
187
398
|
const sessionContext = brainIntelligence.getSessionContext(sessionLimit);
|
|
188
|
-
|
|
189
|
-
// Vault stats
|
|
190
399
|
const vaultStats = vault.stats();
|
|
191
400
|
|
|
192
|
-
// Recent recommendations — graceful degradation
|
|
193
401
|
let recommendations: Array<{ pattern: string; strength: number }> = [];
|
|
194
402
|
try {
|
|
195
|
-
const raw = brainIntelligence.recommend({
|
|
196
|
-
domain,
|
|
197
|
-
limit: 5,
|
|
198
|
-
});
|
|
403
|
+
const raw = brainIntelligence.recommend({ domain, limit: 5 });
|
|
199
404
|
recommendations = raw.map((r) => ({
|
|
200
405
|
pattern: r.pattern,
|
|
201
406
|
strength: r.strength,
|
|
@@ -204,15 +409,25 @@ export function createOrchestrateOps(runtime: AgentRuntime): OpDefinition[] {
|
|
|
204
409
|
// No recommendations available
|
|
205
410
|
}
|
|
206
411
|
|
|
207
|
-
// Brain intelligence stats
|
|
208
412
|
const brainStats = brainIntelligence.getStats();
|
|
209
413
|
|
|
414
|
+
// Include flow plan store info
|
|
415
|
+
const flowPlans = Array.from(planStore.entries()).map(([id, e]) => ({
|
|
416
|
+
planId: id,
|
|
417
|
+
intent: e.plan.intent,
|
|
418
|
+
flowId: e.plan.flowId,
|
|
419
|
+
stepsCount: e.plan.steps.length,
|
|
420
|
+
hasResult: !!e.executionResult,
|
|
421
|
+
createdAt: e.createdAt,
|
|
422
|
+
}));
|
|
423
|
+
|
|
210
424
|
return {
|
|
211
425
|
activePlans,
|
|
212
426
|
sessionContext,
|
|
213
427
|
vaultStats,
|
|
214
428
|
recommendations,
|
|
215
429
|
brainStats,
|
|
430
|
+
flowPlans,
|
|
216
431
|
};
|
|
217
432
|
},
|
|
218
433
|
},
|
|
@@ -242,7 +457,6 @@ export function createOrchestrateOps(runtime: AgentRuntime): OpDefinition[] {
|
|
|
242
457
|
const filesModified = (params.filesModified as string[]) ?? [];
|
|
243
458
|
const outcome = (params.outcome as string) ?? 'completed';
|
|
244
459
|
|
|
245
|
-
// Start session
|
|
246
460
|
const startedSession = brainIntelligence.lifecycle({
|
|
247
461
|
action: 'start',
|
|
248
462
|
domain,
|
|
@@ -251,7 +465,6 @@ export function createOrchestrateOps(runtime: AgentRuntime): OpDefinition[] {
|
|
|
251
465
|
filesModified,
|
|
252
466
|
});
|
|
253
467
|
|
|
254
|
-
// End session immediately with outcome
|
|
255
468
|
const endedSession = brainIntelligence.lifecycle({
|
|
256
469
|
action: 'end',
|
|
257
470
|
sessionId: startedSession.id,
|
|
@@ -260,18 +473,14 @@ export function createOrchestrateOps(runtime: AgentRuntime): OpDefinition[] {
|
|
|
260
473
|
planOutcome: outcome,
|
|
261
474
|
});
|
|
262
475
|
|
|
263
|
-
// Extract knowledge — graceful if nothing to extract
|
|
264
476
|
let extraction = null;
|
|
265
477
|
try {
|
|
266
478
|
extraction = brainIntelligence.extractKnowledge(startedSession.id);
|
|
267
479
|
} catch {
|
|
268
|
-
// Not enough signal
|
|
480
|
+
// Not enough signal
|
|
269
481
|
}
|
|
270
482
|
|
|
271
|
-
return {
|
|
272
|
-
session: endedSession,
|
|
273
|
-
extraction,
|
|
274
|
-
};
|
|
483
|
+
return { session: endedSession, extraction };
|
|
275
484
|
},
|
|
276
485
|
},
|
|
277
486
|
];
|
package/src/runtime/runtime.ts
CHANGED
|
@@ -85,21 +85,24 @@ export function createAgentRuntime(config: AgentRuntimeConfig): AgentRuntime {
|
|
|
85
85
|
// Planner — multi-step task tracking
|
|
86
86
|
const planner = new Planner(plansPath);
|
|
87
87
|
|
|
88
|
-
// Cognee — vector search client (graceful degradation if Cognee is down)
|
|
89
|
-
|
|
90
|
-
if (
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
// Cognee — vector search client (opt-in, graceful degradation if Cognee is down)
|
|
89
|
+
let cognee: CogneeClient | null = null;
|
|
90
|
+
if (config.cognee) {
|
|
91
|
+
const cogneePartial: Partial<import('../cognee/types.js').CogneeConfig> = { dataset: agentId };
|
|
92
|
+
if (process.env.COGNEE_BASE_URL) cogneePartial.baseUrl = process.env.COGNEE_BASE_URL;
|
|
93
|
+
if (process.env.COGNEE_API_TOKEN) cogneePartial.apiToken = process.env.COGNEE_API_TOKEN;
|
|
94
|
+
if (process.env.COGNEE_DATASET) cogneePartial.dataset = process.env.COGNEE_DATASET;
|
|
95
|
+
cognee = new CogneeClient(cogneePartial);
|
|
96
|
+
}
|
|
94
97
|
|
|
95
98
|
// Brain — intelligence layer (TF-IDF scoring, auto-tagging, dedup)
|
|
96
|
-
const brain = new Brain(vault, cognee);
|
|
99
|
+
const brain = new Brain(vault, cognee ?? undefined);
|
|
97
100
|
|
|
98
101
|
// Brain Intelligence — pattern strengths, session knowledge, intelligence pipeline
|
|
99
102
|
const brainIntelligence = new BrainIntelligence(vault, brain);
|
|
100
103
|
|
|
101
104
|
// Curator — vault self-maintenance (dedup, contradictions, grooming, health)
|
|
102
|
-
const curator = new Curator(vault, cognee);
|
|
105
|
+
const curator = new Curator(vault, cognee ?? undefined);
|
|
103
106
|
|
|
104
107
|
// Governance — policy engine + proposal tracker for gated knowledge capture
|
|
105
108
|
const governance = new Governance(vault);
|
|
@@ -132,13 +135,16 @@ export function createAgentRuntime(config: AgentRuntimeConfig): AgentRuntime {
|
|
|
132
135
|
const anthropicKeyPool = new KeyPool(keyPoolFiles.anthropic);
|
|
133
136
|
const llmClient = new LLMClient(openaiKeyPool, anthropicKeyPool, agentId);
|
|
134
137
|
|
|
135
|
-
// Cognee Sync Manager — queue-based dirty tracking with offline resilience
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
138
|
+
// Cognee Sync Manager — queue-based dirty tracking with offline resilience (only when Cognee enabled)
|
|
139
|
+
let syncManager: CogneeSyncManager | null = null;
|
|
140
|
+
if (cognee) {
|
|
141
|
+
syncManager = new CogneeSyncManager(
|
|
142
|
+
vault.getProvider(),
|
|
143
|
+
cognee,
|
|
144
|
+
process.env.COGNEE_DATASET ?? agentId,
|
|
145
|
+
);
|
|
146
|
+
vault.setSyncManager(syncManager);
|
|
147
|
+
}
|
|
142
148
|
|
|
143
149
|
// Intake Pipeline — PDF/book ingestion with LLM classification
|
|
144
150
|
const intakePipeline = new IntakePipeline(vault.getProvider(), vault, llmClient);
|
|
@@ -168,7 +174,10 @@ export function createAgentRuntime(config: AgentRuntimeConfig): AgentRuntime {
|
|
|
168
174
|
const health = new HealthRegistry();
|
|
169
175
|
health.register('vault', 'healthy');
|
|
170
176
|
health.register('brain', 'healthy');
|
|
171
|
-
health.register(
|
|
177
|
+
health.register(
|
|
178
|
+
'cognee',
|
|
179
|
+
cognee ? (cognee.getStatus()?.available ? 'healthy' : 'degraded') : 'down',
|
|
180
|
+
);
|
|
172
181
|
health.register(
|
|
173
182
|
'llm',
|
|
174
183
|
llmClient.isAvailable().openai || llmClient.isAvailable().anthropic ? 'healthy' : 'degraded',
|
|
@@ -221,8 +230,8 @@ export function createAgentRuntime(config: AgentRuntimeConfig): AgentRuntime {
|
|
|
221
230
|
knowledgeReview,
|
|
222
231
|
createdAt: Date.now(),
|
|
223
232
|
close: () => {
|
|
224
|
-
syncManager
|
|
225
|
-
cognee
|
|
233
|
+
syncManager?.close();
|
|
234
|
+
cognee?.resetPendingCognify();
|
|
226
235
|
vaultManager.close();
|
|
227
236
|
},
|
|
228
237
|
};
|
package/src/runtime/types.ts
CHANGED
|
@@ -48,6 +48,8 @@ export interface AgentRuntimeConfig {
|
|
|
48
48
|
logLevel?: LogLevel;
|
|
49
49
|
/** Path to shared global vault. Default: ~/.soleri/vault.db */
|
|
50
50
|
sharedVaultPath?: string;
|
|
51
|
+
/** Enable Cognee vector search integration. Default: false (opt-in). */
|
|
52
|
+
cognee?: boolean;
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
/**
|
|
@@ -63,7 +65,8 @@ export interface AgentRuntime {
|
|
|
63
65
|
planner: Planner;
|
|
64
66
|
curator: Curator;
|
|
65
67
|
governance: Governance;
|
|
66
|
-
|
|
68
|
+
/** Cognee vector search client. Null when Cognee integration is disabled. */
|
|
69
|
+
cognee: CogneeClient | null;
|
|
67
70
|
loop: LoopManager;
|
|
68
71
|
identityManager: IdentityManager;
|
|
69
72
|
intentRouter: IntentRouter;
|
|
@@ -72,7 +75,8 @@ export interface AgentRuntime {
|
|
|
72
75
|
telemetry: Telemetry;
|
|
73
76
|
projectRegistry: ProjectRegistry;
|
|
74
77
|
templateManager: TemplateManager;
|
|
75
|
-
|
|
78
|
+
/** Cognee sync manager. Null when Cognee integration is disabled. */
|
|
79
|
+
syncManager: CogneeSyncManager | null;
|
|
76
80
|
intakePipeline: IntakePipeline;
|
|
77
81
|
/** Mutable auth policy — controls facade dispatch enforcement. */
|
|
78
82
|
authPolicy: AuthPolicy;
|