@hongmaple0820/scale-engine 0.29.0 → 0.33.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/README.en.md +2 -0
- package/README.md +2 -0
- package/dist/api/cli.js +4 -0
- package/dist/api/cli.js.map +1 -1
- package/dist/evolution/SessionLearnings.d.ts +70 -0
- package/dist/evolution/SessionLearnings.js +217 -0
- package/dist/evolution/SessionLearnings.js.map +1 -0
- package/dist/runtime/AiOsRuntime.d.ts +99 -1
- package/dist/runtime/AiOsRuntime.js +462 -14
- package/dist/runtime/AiOsRuntime.js.map +1 -1
- package/dist/skills/RoleSkills.d.ts +20 -0
- package/dist/skills/RoleSkills.js +154 -0
- package/dist/skills/RoleSkills.js.map +1 -0
- package/dist/skills/SkillDiscovery.d.ts +5 -0
- package/dist/skills/SkillDiscovery.js +15 -0
- package/dist/skills/SkillDiscovery.js.map +1 -1
- package/dist/skills/SkillFrontmatter.d.ts +28 -0
- package/dist/skills/SkillFrontmatter.js +152 -0
- package/dist/skills/SkillFrontmatter.js.map +1 -0
- package/dist/skills/SkillRegistry.d.ts +11 -0
- package/dist/skills/SkillRegistry.js +12 -0
- package/dist/skills/SkillRegistry.js.map +1 -1
- package/dist/skills/index.d.ts +1 -0
- package/dist/skills/index.js +1 -0
- package/dist/skills/index.js.map +1 -1
- package/dist/testing/DiffTestSelector.d.ts +22 -0
- package/dist/testing/DiffTestSelector.js +114 -0
- package/dist/testing/DiffTestSelector.js.map +1 -0
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.js +3 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/workflow/AdaptiveWorkflowRouter.d.ts +37 -0
- package/dist/workflow/AdaptiveWorkflowRouter.js +211 -0
- package/dist/workflow/AdaptiveWorkflowRouter.js.map +1 -0
- package/dist/workflow/EvolutionShadowPromoter.d.ts +46 -0
- package/dist/workflow/EvolutionShadowPromoter.js +73 -0
- package/dist/workflow/EvolutionShadowPromoter.js.map +1 -0
- package/dist/workflow/ReviewAnalyzer.d.ts +15 -0
- package/dist/workflow/ReviewAnalyzer.js +82 -0
- package/dist/workflow/ReviewAnalyzer.js.map +1 -1
- package/dist/workflow/SecurityAudit.d.ts +27 -0
- package/dist/workflow/SecurityAudit.js +294 -0
- package/dist/workflow/SecurityAudit.js.map +1 -0
- package/dist/workflow/SessionPreamble.d.ts +19 -0
- package/dist/workflow/SessionPreamble.js +125 -0
- package/dist/workflow/SessionPreamble.js.map +1 -0
- package/dist/workflow/ShipPipeline.d.ts +30 -0
- package/dist/workflow/ShipPipeline.js +366 -0
- package/dist/workflow/ShipPipeline.js.map +1 -0
- package/dist/workflow/WorkflowGuidance.d.ts +5 -1
- package/dist/workflow/WorkflowGuidance.js +31 -0
- package/dist/workflow/WorkflowGuidance.js.map +1 -1
- package/dist/workflow/index.d.ts +5 -0
- package/dist/workflow/index.js +5 -0
- package/dist/workflow/index.js.map +1 -1
- package/docs/AI_ENGINEERING_OS_POSITIONING.md +9 -0
- package/docs/CONTEXT_BUDGET.md +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export type LearningCategory = 'failure' | 'pattern' | 'preference' | 'environment';
|
|
2
|
+
export interface LearningEntry {
|
|
3
|
+
id: string;
|
|
4
|
+
ts: string;
|
|
5
|
+
projectSlug: string;
|
|
6
|
+
category: LearningCategory;
|
|
7
|
+
title: string;
|
|
8
|
+
detail: string;
|
|
9
|
+
evidenceIds: string[];
|
|
10
|
+
tags: string[];
|
|
11
|
+
relevanceDecay?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface LearningSearchQuery {
|
|
14
|
+
tags?: string[];
|
|
15
|
+
category?: LearningCategory;
|
|
16
|
+
limit?: number;
|
|
17
|
+
projectSlug?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface LearningStore {
|
|
20
|
+
append(entry: LearningEntry): void;
|
|
21
|
+
search(query: LearningSearchQuery): LearningEntry[];
|
|
22
|
+
prune(opts: {
|
|
23
|
+
olderThanDays?: number;
|
|
24
|
+
minRelevance?: number;
|
|
25
|
+
}): number;
|
|
26
|
+
count(): number;
|
|
27
|
+
exportJsonl(): string;
|
|
28
|
+
}
|
|
29
|
+
export declare function createLearningStore(opts: {
|
|
30
|
+
storePath?: string;
|
|
31
|
+
}): LearningStore;
|
|
32
|
+
interface RunReportForLearning {
|
|
33
|
+
status: string;
|
|
34
|
+
mode: string;
|
|
35
|
+
plan: {
|
|
36
|
+
task: string;
|
|
37
|
+
level?: string;
|
|
38
|
+
governance?: {
|
|
39
|
+
mode?: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
failureLearning: {
|
|
43
|
+
status: string;
|
|
44
|
+
candidates: Array<{
|
|
45
|
+
id: string;
|
|
46
|
+
source: string;
|
|
47
|
+
title: string;
|
|
48
|
+
summary: string;
|
|
49
|
+
evidenceRefs: string[];
|
|
50
|
+
promotable: boolean;
|
|
51
|
+
}>;
|
|
52
|
+
};
|
|
53
|
+
verification: {
|
|
54
|
+
allPassed: boolean;
|
|
55
|
+
commands: Array<{
|
|
56
|
+
command: string;
|
|
57
|
+
status: string;
|
|
58
|
+
exitCode: number;
|
|
59
|
+
}>;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export declare function autoLearnFromRunReport(report: RunReportForLearning): LearningEntry[];
|
|
63
|
+
export declare function loadRelevantLearnings(opts: {
|
|
64
|
+
projectDir?: string;
|
|
65
|
+
scaleDir?: string;
|
|
66
|
+
task?: string;
|
|
67
|
+
tags?: string[];
|
|
68
|
+
limit?: number;
|
|
69
|
+
}): LearningEntry[];
|
|
70
|
+
export {};
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// SCALE Engine — Session Learnings (v0.31.0)
|
|
2
|
+
// Cross-session knowledge persistence inspired by gstack's learnings.jsonl.
|
|
3
|
+
// Learnings survive across sessions and are loaded into future plans.
|
|
4
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync, appendFileSync, readdirSync } from 'node:fs';
|
|
5
|
+
import { join, basename } from 'node:path';
|
|
6
|
+
import { randomUUID } from 'node:crypto';
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Store Implementation
|
|
9
|
+
// ============================================================================
|
|
10
|
+
export function createLearningStore(opts) {
|
|
11
|
+
const storePath = opts.storePath ?? '.scale/learnings';
|
|
12
|
+
const dir = storePath;
|
|
13
|
+
function ensureDir() {
|
|
14
|
+
if (!existsSync(dir))
|
|
15
|
+
mkdirSync(dir, { recursive: true });
|
|
16
|
+
}
|
|
17
|
+
function getJsonlPath(projectSlug) {
|
|
18
|
+
return join(dir, `${projectSlug}.jsonl`);
|
|
19
|
+
}
|
|
20
|
+
function readEntries(projectSlug) {
|
|
21
|
+
const path = getJsonlPath(projectSlug);
|
|
22
|
+
if (!existsSync(path))
|
|
23
|
+
return [];
|
|
24
|
+
try {
|
|
25
|
+
const content = readFileSync(path, 'utf-8');
|
|
26
|
+
return content.split('\n').filter(line => line.trim()).map(line => JSON.parse(line));
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function writeEntries(projectSlug, entries) {
|
|
33
|
+
ensureDir();
|
|
34
|
+
const path = getJsonlPath(projectSlug);
|
|
35
|
+
const content = entries.map(e => JSON.stringify(e)).join('\n') + '\n';
|
|
36
|
+
writeFileSync(path, content, 'utf-8');
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
append(entry) {
|
|
40
|
+
ensureDir();
|
|
41
|
+
const path = getJsonlPath(entry.projectSlug);
|
|
42
|
+
appendFileSync(path, JSON.stringify(entry) + '\n', 'utf-8');
|
|
43
|
+
},
|
|
44
|
+
search(query) {
|
|
45
|
+
const slug = query.projectSlug;
|
|
46
|
+
const slugs = slug ? [slug] : listProjectSlugs(dir);
|
|
47
|
+
const allEntries = [];
|
|
48
|
+
for (const s of slugs) {
|
|
49
|
+
const entries = readEntries(s);
|
|
50
|
+
allEntries.push(...entries);
|
|
51
|
+
}
|
|
52
|
+
let filtered = allEntries;
|
|
53
|
+
if (query.category) {
|
|
54
|
+
filtered = filtered.filter(e => e.category === query.category);
|
|
55
|
+
}
|
|
56
|
+
if (query.tags && query.tags.length > 0) {
|
|
57
|
+
filtered = filtered.filter(e => query.tags.some(t => e.tags.includes(t)));
|
|
58
|
+
}
|
|
59
|
+
// Sort by timestamp descending (newest first)
|
|
60
|
+
filtered.sort((a, b) => new Date(b.ts).getTime() - new Date(a.ts).getTime());
|
|
61
|
+
if (query.limit) {
|
|
62
|
+
filtered = filtered.slice(0, query.limit);
|
|
63
|
+
}
|
|
64
|
+
return filtered;
|
|
65
|
+
},
|
|
66
|
+
prune(opts) {
|
|
67
|
+
const slugs = listProjectSlugs(dir);
|
|
68
|
+
let prunedCount = 0;
|
|
69
|
+
for (const slug of slugs) {
|
|
70
|
+
const entries = readEntries(slug);
|
|
71
|
+
const now = Date.now();
|
|
72
|
+
const kept = entries.filter(e => {
|
|
73
|
+
if (opts.olderThanDays) {
|
|
74
|
+
const ageMs = now - new Date(e.ts).getTime();
|
|
75
|
+
const ageDays = ageMs / (1000 * 60 * 60 * 24);
|
|
76
|
+
if (ageDays > opts.olderThanDays) {
|
|
77
|
+
prunedCount++;
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (opts.minRelevance && e.relevanceDecay) {
|
|
82
|
+
const ageMs = now - new Date(e.ts).getTime();
|
|
83
|
+
const ageDays = ageMs / (1000 * 60 * 60 * 24);
|
|
84
|
+
const relevance = Math.max(0, 1 - (e.relevanceDecay * ageDays / 30));
|
|
85
|
+
if (relevance < opts.minRelevance) {
|
|
86
|
+
prunedCount++;
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
});
|
|
92
|
+
if (kept.length !== entries.length) {
|
|
93
|
+
writeEntries(slug, kept);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return prunedCount;
|
|
97
|
+
},
|
|
98
|
+
count() {
|
|
99
|
+
const slugs = listProjectSlugs(dir);
|
|
100
|
+
let total = 0;
|
|
101
|
+
for (const slug of slugs) {
|
|
102
|
+
total += readEntries(slug).length;
|
|
103
|
+
}
|
|
104
|
+
return total;
|
|
105
|
+
},
|
|
106
|
+
exportJsonl() {
|
|
107
|
+
const slugs = listProjectSlugs(dir);
|
|
108
|
+
const lines = [];
|
|
109
|
+
for (const slug of slugs) {
|
|
110
|
+
const entries = readEntries(slug);
|
|
111
|
+
for (const entry of entries) {
|
|
112
|
+
lines.push(JSON.stringify(entry));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return lines.join('\n') + '\n';
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
export function autoLearnFromRunReport(report) {
|
|
120
|
+
const entries = [];
|
|
121
|
+
const projectSlug = deriveProjectSlug();
|
|
122
|
+
const ts = new Date().toISOString();
|
|
123
|
+
// Learn from blocked runs
|
|
124
|
+
if (report.status === 'blocked') {
|
|
125
|
+
entries.push({
|
|
126
|
+
id: randomUUID(),
|
|
127
|
+
ts,
|
|
128
|
+
projectSlug,
|
|
129
|
+
category: 'failure',
|
|
130
|
+
title: `Run blocked: ${report.plan.task.slice(0, 80)}`,
|
|
131
|
+
detail: `Task "${report.plan.task}" was blocked. Governance mode: ${report.plan.governance?.mode ?? 'unknown'}.`,
|
|
132
|
+
evidenceIds: [],
|
|
133
|
+
tags: ['blocked', report.mode],
|
|
134
|
+
relevanceDecay: 0.3,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
// Learn from failure learning candidates
|
|
138
|
+
for (const candidate of report.failureLearning.candidates) {
|
|
139
|
+
entries.push({
|
|
140
|
+
id: randomUUID(),
|
|
141
|
+
ts,
|
|
142
|
+
projectSlug,
|
|
143
|
+
category: 'failure',
|
|
144
|
+
title: candidate.title,
|
|
145
|
+
detail: candidate.summary,
|
|
146
|
+
evidenceIds: candidate.evidenceRefs,
|
|
147
|
+
tags: ['failure-learning', candidate.source, candidate.promotable ? 'promotable' : 'non-promotable'],
|
|
148
|
+
relevanceDecay: 0.2,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
// Learn from verification failures
|
|
152
|
+
for (const cmd of report.verification.commands) {
|
|
153
|
+
if (cmd.status === 'failed') {
|
|
154
|
+
entries.push({
|
|
155
|
+
id: randomUUID(),
|
|
156
|
+
ts,
|
|
157
|
+
projectSlug,
|
|
158
|
+
category: 'failure',
|
|
159
|
+
title: `Verification failed: ${cmd.command}`,
|
|
160
|
+
detail: `Command "${cmd.command}" exited with code ${cmd.exitCode}.`,
|
|
161
|
+
evidenceIds: [],
|
|
162
|
+
tags: ['verification-failure', 'exit-code-' + cmd.exitCode],
|
|
163
|
+
relevanceDecay: 0.4,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return entries;
|
|
168
|
+
}
|
|
169
|
+
// ============================================================================
|
|
170
|
+
// Load Relevant Learnings
|
|
171
|
+
// ============================================================================
|
|
172
|
+
export function loadRelevantLearnings(opts) {
|
|
173
|
+
const scaleDir = opts.scaleDir ?? '.scale';
|
|
174
|
+
const storePath = join(scaleDir, 'learnings');
|
|
175
|
+
const store = createLearningStore({ storePath });
|
|
176
|
+
const projectSlug = deriveProjectSlug(opts.projectDir);
|
|
177
|
+
const query = {
|
|
178
|
+
projectSlug,
|
|
179
|
+
tags: opts.tags,
|
|
180
|
+
limit: opts.limit ?? 10,
|
|
181
|
+
};
|
|
182
|
+
let results = store.search(query);
|
|
183
|
+
// If task is provided, filter by relevance to task keywords
|
|
184
|
+
if (opts.task) {
|
|
185
|
+
const taskWords = opts.task.toLowerCase().split(/\s+/).filter(w => w.length > 3);
|
|
186
|
+
results = results.filter(e => {
|
|
187
|
+
const entryText = `${e.title} ${e.detail}`.toLowerCase();
|
|
188
|
+
return taskWords.some(w => entryText.includes(w));
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
return results.slice(0, opts.limit ?? 10);
|
|
192
|
+
}
|
|
193
|
+
// ============================================================================
|
|
194
|
+
// Helpers
|
|
195
|
+
// ============================================================================
|
|
196
|
+
function deriveProjectSlug(projectDir) {
|
|
197
|
+
try {
|
|
198
|
+
const dir = projectDir ?? process.cwd();
|
|
199
|
+
return basename(dir).replace(/[^a-zA-Z0-9-]/g, '-').toLowerCase();
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
return 'unknown';
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
function listProjectSlugs(dir) {
|
|
206
|
+
if (!existsSync(dir))
|
|
207
|
+
return [];
|
|
208
|
+
try {
|
|
209
|
+
return readdirSync(dir)
|
|
210
|
+
.filter(f => f.endsWith('.jsonl'))
|
|
211
|
+
.map(f => f.replace('.jsonl', ''));
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
return [];
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=SessionLearnings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionLearnings.js","sourceRoot":"","sources":["../../src/evolution/SessionLearnings.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,4EAA4E;AAC5E,sEAAsE;AAEtE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACzG,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAmCxC,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E,MAAM,UAAU,mBAAmB,CAAC,IAA4B;IAC9D,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,kBAAkB,CAAA;IACtD,MAAM,GAAG,GAAG,SAAS,CAAA;IAErB,SAAS,SAAS;QAChB,I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,CAAC;AACH,CAAC"}
|
|
@@ -4,6 +4,10 @@ import { type GovernanceMode, type ProgressiveGovernanceReport } from '../govern
|
|
|
4
4
|
import type { IKnowledgeBase } from '../knowledge/KnowledgeBase.js';
|
|
5
5
|
import { type ContextPack as MemoryContextPack, type MemoryProviderRecallItem } from '../memory/index.js';
|
|
6
6
|
import { type SkillPlan, type SkillTaskLevel } from '../skills/routing/index.js';
|
|
7
|
+
import { type WorkflowProfile } from '../workflow/AdaptiveWorkflowRouter.js';
|
|
8
|
+
import { type EvolutionShadowReport } from '../workflow/EvolutionShadowPromoter.js';
|
|
9
|
+
import { type LearningEntry } from '../evolution/SessionLearnings.js';
|
|
10
|
+
import { type SessionPreamble } from '../workflow/SessionPreamble.js';
|
|
7
11
|
export interface AiOsRuntimeInput {
|
|
8
12
|
projectDir?: string;
|
|
9
13
|
scaleDir?: string;
|
|
@@ -37,11 +41,67 @@ export interface AiOsMemoryRuntimeSummary {
|
|
|
37
41
|
}
|
|
38
42
|
export interface AiOsAdaptiveWorkflow {
|
|
39
43
|
strategy: 'risk-adaptive-runtime-v1';
|
|
44
|
+
profile: WorkflowProfile;
|
|
45
|
+
escalationReasons: string[];
|
|
40
46
|
mode: GovernanceMode;
|
|
41
47
|
requiredBehaviors: string[];
|
|
42
48
|
gates: string[];
|
|
43
49
|
exitCriteria: string[];
|
|
44
50
|
}
|
|
51
|
+
export type AiOsEvaluatorGateId = 'architecture-critique' | 'root-cause-review' | 'security-threat-model' | 'release-readiness-review' | 'uncertainty-decision-log';
|
|
52
|
+
export interface AiOsEvaluatorGate {
|
|
53
|
+
id: AiOsEvaluatorGateId;
|
|
54
|
+
required: boolean;
|
|
55
|
+
reason: string;
|
|
56
|
+
evidence: string[];
|
|
57
|
+
}
|
|
58
|
+
export interface AiOsEvaluatorIntelligence {
|
|
59
|
+
strategy: 'evaluator-intelligence-v1';
|
|
60
|
+
required: boolean;
|
|
61
|
+
riskLevel: 'low' | 'medium' | 'high';
|
|
62
|
+
uncertainty: {
|
|
63
|
+
score: number;
|
|
64
|
+
threshold: number;
|
|
65
|
+
drivers: string[];
|
|
66
|
+
};
|
|
67
|
+
gates: AiOsEvaluatorGate[];
|
|
68
|
+
recommendations: string[];
|
|
69
|
+
}
|
|
70
|
+
export type AiOsToolStrategyRisk = 'low' | 'medium' | 'high';
|
|
71
|
+
export interface AiOsToolStrategyNode {
|
|
72
|
+
id: string;
|
|
73
|
+
kind: SkillPlan['executionPlan']['steps'][number]['kind'];
|
|
74
|
+
required: boolean;
|
|
75
|
+
cost: {
|
|
76
|
+
units: number;
|
|
77
|
+
timeRisk: AiOsToolStrategyRisk;
|
|
78
|
+
sideEffectRisk: AiOsToolStrategyRisk;
|
|
79
|
+
};
|
|
80
|
+
retry: {
|
|
81
|
+
maxAttempts: number;
|
|
82
|
+
backoff: 'none' | 'linear' | 'manual-review';
|
|
83
|
+
};
|
|
84
|
+
fallback: string;
|
|
85
|
+
evidence: string[];
|
|
86
|
+
}
|
|
87
|
+
export interface AiOsToolStrategyEdge {
|
|
88
|
+
from: string;
|
|
89
|
+
to: string;
|
|
90
|
+
reason: string;
|
|
91
|
+
}
|
|
92
|
+
export interface AiOsToolStrategyPlan {
|
|
93
|
+
strategy: 'tool-strategy-v1';
|
|
94
|
+
nodes: AiOsToolStrategyNode[];
|
|
95
|
+
edges: AiOsToolStrategyEdge[];
|
|
96
|
+
summary: {
|
|
97
|
+
totalSteps: number;
|
|
98
|
+
requiredSteps: number;
|
|
99
|
+
highRiskSteps: number;
|
|
100
|
+
estimatedCostUnits: number;
|
|
101
|
+
fallbackCoveredSteps: number;
|
|
102
|
+
};
|
|
103
|
+
recommendations: string[];
|
|
104
|
+
}
|
|
45
105
|
export interface AiOsRuntimePlan {
|
|
46
106
|
version: string;
|
|
47
107
|
generatedAt: string;
|
|
@@ -52,11 +112,16 @@ export interface AiOsRuntimePlan {
|
|
|
52
112
|
files: string[];
|
|
53
113
|
services: string[];
|
|
54
114
|
};
|
|
115
|
+
preamble: SessionPreamble;
|
|
55
116
|
governance: ProgressiveGovernanceReport;
|
|
56
117
|
adaptiveWorkflow: AiOsAdaptiveWorkflow;
|
|
118
|
+
evaluator: AiOsEvaluatorIntelligence;
|
|
119
|
+
toolStrategy: AiOsToolStrategyPlan;
|
|
120
|
+
evolutionShadow: EvolutionShadowReport;
|
|
57
121
|
context: BudgetedContextPack;
|
|
58
122
|
memory: AiOsMemoryRuntimeSummary;
|
|
59
123
|
skillPlan: SkillPlan;
|
|
124
|
+
sessionLearnings: LearningEntry[];
|
|
60
125
|
roi: GovernanceRoiReport;
|
|
61
126
|
recommendations: string[];
|
|
62
127
|
}
|
|
@@ -172,6 +237,7 @@ export interface AiOsBenchmarkScenarioResult {
|
|
|
172
237
|
task: string;
|
|
173
238
|
level: SkillTaskLevel;
|
|
174
239
|
governanceMode: GovernanceMode;
|
|
240
|
+
workflowProfile: WorkflowProfile;
|
|
175
241
|
metrics: {
|
|
176
242
|
estimatedTokens: number;
|
|
177
243
|
budget: number;
|
|
@@ -180,6 +246,10 @@ export interface AiOsBenchmarkScenarioResult {
|
|
|
180
246
|
selectedProviders: string[];
|
|
181
247
|
skillSteps: number;
|
|
182
248
|
requiredSkillSteps: number;
|
|
249
|
+
evaluatorGates: number;
|
|
250
|
+
toolStrategySteps: number;
|
|
251
|
+
toolStrategyCostUnits: number;
|
|
252
|
+
evolutionProposals: number;
|
|
183
253
|
gates: number;
|
|
184
254
|
roiModules: number;
|
|
185
255
|
};
|
|
@@ -196,7 +266,12 @@ export interface AiOsBenchmarkReport {
|
|
|
196
266
|
totalMemoryItems: number;
|
|
197
267
|
totalSkillSteps: number;
|
|
198
268
|
requiredSkillSteps: number;
|
|
269
|
+
totalEvaluatorGates: number;
|
|
270
|
+
totalToolStrategySteps: number;
|
|
271
|
+
totalToolStrategyCostUnits: number;
|
|
272
|
+
totalEvolutionProposals: number;
|
|
199
273
|
governanceModes: GovernanceMode[];
|
|
274
|
+
workflowProfiles: WorkflowProfile[];
|
|
200
275
|
averageTokenUtilization: number;
|
|
201
276
|
};
|
|
202
277
|
dashboard: AiOsDashboardReport;
|
|
@@ -335,7 +410,7 @@ export interface AiOsStatusReport {
|
|
|
335
410
|
nextActions: string[];
|
|
336
411
|
warnings: string[];
|
|
337
412
|
}
|
|
338
|
-
export type AiOsIntelligenceSignalId = 'memory-recall' | 'context-savings' | 'skill-routing' | 'benchmark-intelligence';
|
|
413
|
+
export type AiOsIntelligenceSignalId = 'memory-recall' | 'context-savings' | 'skill-routing' | 'evaluator-intelligence' | 'tool-strategy' | 'adaptive-workflow' | 'evolution-shadow' | 'benchmark-intelligence';
|
|
339
414
|
export interface AiOsIntelligenceSignal {
|
|
340
415
|
id: AiOsIntelligenceSignalId;
|
|
341
416
|
status: AiOsClosedLoopStatus;
|
|
@@ -353,6 +428,9 @@ export interface AiOsIntelligenceReport {
|
|
|
353
428
|
selectedProviders: string[];
|
|
354
429
|
memoryQuality: AiOsMemoryQualitySummary;
|
|
355
430
|
contextQuality: AiOsContextQualitySummary;
|
|
431
|
+
evaluatorQuality: AiOsEvaluatorQualitySummary;
|
|
432
|
+
toolStrategyQuality: AiOsToolStrategyQualitySummary;
|
|
433
|
+
evolutionQuality: AiOsEvolutionQualitySummary;
|
|
356
434
|
estimatedTokenSavings: number;
|
|
357
435
|
skillSteps: number;
|
|
358
436
|
};
|
|
@@ -374,6 +452,26 @@ export interface AiOsContextQualitySummary {
|
|
|
374
452
|
highestOmittedTokens: number;
|
|
375
453
|
compressionRisk: 'low' | 'medium' | 'high';
|
|
376
454
|
}
|
|
455
|
+
export interface AiOsEvaluatorQualitySummary {
|
|
456
|
+
requiredGates: number;
|
|
457
|
+
highRiskPlans: number;
|
|
458
|
+
averageUncertainty: number;
|
|
459
|
+
gateIds: AiOsEvaluatorGateId[];
|
|
460
|
+
}
|
|
461
|
+
export interface AiOsToolStrategyQualitySummary {
|
|
462
|
+
totalSteps: number;
|
|
463
|
+
requiredSteps: number;
|
|
464
|
+
highRiskSteps: number;
|
|
465
|
+
estimatedCostUnits: number;
|
|
466
|
+
fallbackCoverage: number;
|
|
467
|
+
}
|
|
468
|
+
export interface AiOsEvolutionQualitySummary {
|
|
469
|
+
proposals: number;
|
|
470
|
+
shadowRules: number;
|
|
471
|
+
candidateHooks: number;
|
|
472
|
+
approvedBlocking: number;
|
|
473
|
+
pendingValidation: number;
|
|
474
|
+
}
|
|
377
475
|
export declare function createAiOsPlan(input: AiOsRuntimeInput): Promise<AiOsRuntimePlan>;
|
|
378
476
|
export declare function createAiOsRun(input: AiOsRunInput): Promise<AiOsRunReport>;
|
|
379
477
|
export declare function createAiOsDashboard(input?: AiOsDashboardInput): AiOsDashboardReport;
|