scene-capability-engine 3.6.65 → 3.6.67
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/CHANGELOG.md +16 -0
- package/README.md +17 -6
- package/README.zh.md +18 -6
- package/bin/scene-capability-engine.js +4 -0
- package/docs/README.md +2 -2
- package/docs/command-reference.md +382 -6
- package/docs/document-governance.md +3 -2
- package/docs/integration-modes.md +62 -478
- package/docs/integration-philosophy.md +56 -263
- package/docs/magicball-project-portfolio-contract.md +114 -2
- package/docs/project-management/README.md +14 -0
- package/docs/project-management/assurance/backup.md +3 -0
- package/docs/project-management/assurance/config.md +3 -0
- package/docs/project-management/assurance/evidence/README.md +3 -0
- package/docs/project-management/assurance/incidents/README.md +3 -0
- package/docs/project-management/assurance/logs.md +3 -0
- package/docs/project-management/assurance/overview.md +3 -0
- package/docs/project-management/assurance/recovery/README.md +3 -0
- package/docs/project-management/assurance/resource.md +3 -0
- package/docs/project-management/assurance/runbooks/README.md +3 -0
- package/docs/project-management/delivery/acceptance/README.md +3 -0
- package/docs/project-management/delivery/acceptance/evidence/README.md +3 -0
- package/docs/project-management/delivery/acceptance/exceptions/README.md +3 -0
- package/docs/project-management/delivery/acceptance/reports/README.md +3 -0
- package/docs/project-management/delivery/documents/changes.md +3 -0
- package/docs/project-management/delivery/documents/issues.md +3 -0
- package/docs/project-management/delivery/documents/overview.md +3 -0
- package/docs/project-management/delivery/documents/planning.md +3 -0
- package/docs/project-management/delivery/documents/requirements.md +3 -0
- package/docs/project-management/delivery/documents/tracking.md +3 -0
- package/docs/project-management/delivery/handoffs/README.md +3 -0
- package/docs/project-management/delivery/handoffs/evidence/README.md +3 -0
- package/docs/project-management/delivery/handoffs/records/README.md +3 -0
- package/docs/project-management/delivery/overview.md +10 -0
- package/docs/project-management/delivery/releases/README.md +3 -0
- package/docs/project-management/delivery/releases/baselines/README.md +3 -0
- package/docs/project-management/delivery/releases/evidence/README.md +3 -0
- package/docs/project-management/delivery/tables/changes.md +3 -0
- package/docs/project-management/delivery/tables/issues.md +3 -0
- package/docs/project-management/delivery/tables/planning.md +3 -0
- package/docs/project-management/delivery/tables/requirements.md +3 -0
- package/docs/project-management/delivery/tables/tracking.md +3 -0
- package/docs/project-management/environment/agent-discovery.md +3 -0
- package/docs/project-management/environment/development.md +3 -0
- package/docs/project-management/environment/overview.md +10 -0
- package/docs/project-management/environment/testing.md +3 -0
- package/docs/project-management/environment/version-alignment.md +3 -0
- package/docs/quick-start-with-ai-tools.md +68 -308
- package/docs/releases/README.md +2 -0
- package/docs/releases/v3.6.66.md +23 -0
- package/docs/releases/v3.6.67.md +23 -0
- package/docs/steering-governance.md +64 -2
- package/docs/zh/README.md +2 -2
- package/docs/zh/releases/README.md +2 -0
- package/docs/zh/releases/v3.6.66.md +23 -0
- package/docs/zh/releases/v3.6.67.md +23 -0
- package/lib/commands/adopt.js +24 -0
- package/lib/commands/native.js +158 -0
- package/lib/commands/project.js +95 -0
- package/lib/commands/semantic.js +1459 -0
- package/lib/commands/session.js +74 -3
- package/lib/commands/spec-bootstrap.js +10 -1
- package/lib/commands/spec-gate.js +10 -1
- package/lib/commands/spec-pipeline.js +10 -1
- package/lib/commands/studio.js +405 -30
- package/lib/commands/task.js +141 -7
- package/lib/governance/supreme-principles.js +530 -0
- package/lib/problem/problem-evaluator.js +4 -0
- package/lib/project/candidate-inspection-service.js +24 -1
- package/lib/project/portfolio-projection-service.js +315 -5
- package/lib/project/project-channel-output.js +94 -0
- package/lib/project/project-channel-projection.js +181 -0
- package/lib/project/root-onboarding-service.js +60 -8
- package/lib/project/semantic-shared-source-projection.js +150 -0
- package/lib/project/supervision-action-model.js +277 -0
- package/lib/project/supervision-projection-service.js +305 -5
- package/lib/project/target-resolution-service.js +70 -5
- package/lib/project/visibility-policy.js +93 -0
- package/lib/runtime/multi-spec-scene-session.js +8 -1
- package/lib/runtime/project-channel-context-store.js +387 -0
- package/lib/runtime/project-channel-context.js +406 -0
- package/lib/runtime/scene-session-binding.js +46 -0
- package/lib/runtime/session-store.js +186 -0
- package/lib/runtime/steering-contract.js +7 -1
- package/lib/semantic/archive-report.js +283 -0
- package/lib/semantic/archive-routing.js +67 -0
- package/lib/semantic/backflow-report.js +245 -0
- package/lib/semantic/capability-contract.js +30 -0
- package/lib/semantic/delta-export.js +145 -0
- package/lib/semantic/interaction-observer.js +254 -0
- package/lib/semantic/kernel-loader.js +881 -0
- package/lib/semantic/native-runtime.js +359 -0
- package/lib/semantic/progress-ledger.js +433 -0
- package/lib/semantic/replay-evaluator.js +382 -0
- package/lib/semantic/shared-publication.js +592 -0
- package/lib/semantic/shared-source-config.js +183 -0
- package/lib/semantic/shared-source-connect.js +139 -0
- package/lib/semantic/shared-source-discovery.js +98 -0
- package/lib/semantic/shared-sync-export.js +413 -0
- package/lib/semantic/shared-sync-intake.js +592 -0
- package/lib/semantic/shared-sync-merge.js +547 -0
- package/lib/semantic/shared-sync-release.js +463 -0
- package/lib/semantic/supreme-intent-report.js +300 -0
- package/lib/state/sce-state-store.js +1360 -0
- package/lib/steering/context-sync-manager.js +276 -25
- package/lib/studio/spec-intake-governor.js +39 -3
- package/lib/studio/task-envelope.js +35 -2
- package/lib/workspace/takeover-baseline.js +342 -83
- package/package.json +7 -2
- package/scripts/agent-governance-baseline-audit.js +395 -0
- package/scripts/clarification-first-audit.js +9 -9
- package/scripts/deprecated-entry-audit.js +240 -0
- package/scripts/release-posture-report.js +262 -0
- package/template/.sce/README.md +62 -228
- package/template/.sce/config/semantic-shared-sources.json +5 -0
- package/template/.sce/config/supreme-principles-policy.json +105 -0
- package/template/.sce/config/takeover-baseline.json +7 -0
- package/template/.sce/steering/CORE_PRINCIPLES.md +23 -63
- package/template/.sce/steering/CURRENT_CONTEXT.md +4 -0
- package/template/.sce/steering/RULES_GUIDE.md +17 -9
- package/template/README.md +32 -96
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
const { SessionStore } = require('../runtime/session-store');
|
|
2
|
+
const { observeSemanticInteraction } = require('./interaction-observer');
|
|
3
|
+
const {
|
|
4
|
+
activatePromotedSemanticBehaviors,
|
|
5
|
+
listPromotedSemanticBehaviors,
|
|
6
|
+
recordSemanticCapabilityActivation
|
|
7
|
+
} = require('./kernel-loader');
|
|
8
|
+
const { getWriteAuthorizationLease } = require('../security/write-authorization');
|
|
9
|
+
const {
|
|
10
|
+
assessSupremeIntent,
|
|
11
|
+
buildNativeGovernedReply,
|
|
12
|
+
writeSupremeIntentEvidence,
|
|
13
|
+
recordSupremeIntentAssessment
|
|
14
|
+
} = require('../governance/supreme-principles');
|
|
15
|
+
|
|
16
|
+
function normalizeString(value) {
|
|
17
|
+
if (typeof value !== 'string') {
|
|
18
|
+
return '';
|
|
19
|
+
}
|
|
20
|
+
return value.trim();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function unique(values = []) {
|
|
24
|
+
return Array.from(new Set(values.filter(Boolean)));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function resolveLeaseSnapshot(leaseId, dependencies = {}) {
|
|
28
|
+
const normalizedLeaseId = normalizeString(leaseId);
|
|
29
|
+
if (!normalizedLeaseId) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return getWriteAuthorizationLease(normalizedLeaseId, {
|
|
33
|
+
projectPath: dependencies.projectPath || process.cwd(),
|
|
34
|
+
fileSystem: dependencies.fileSystem,
|
|
35
|
+
env: dependencies.env
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function resolveNativeSession(options = {}, dependencies = {}) {
|
|
40
|
+
const projectPath = dependencies.projectPath || process.cwd();
|
|
41
|
+
const store = dependencies.sessionStore || new SessionStore(projectPath, null, {
|
|
42
|
+
fileSystem: dependencies.fileSystem,
|
|
43
|
+
env: dependencies.env,
|
|
44
|
+
sqliteModule: dependencies.sqliteModule
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const requestedSessionId = normalizeString(options.session_id || options.sessionId);
|
|
48
|
+
if (requestedSessionId) {
|
|
49
|
+
const session = await store.getSession(requestedSessionId);
|
|
50
|
+
return { store, session, created: false };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const sessions = await store.listSessions();
|
|
54
|
+
const latestNative = sessions.find((item) => normalizeString(item.tool) === 'sce-native');
|
|
55
|
+
if (latestNative) {
|
|
56
|
+
return { store, session: latestNative, created: false };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const session = await store.startSession({
|
|
60
|
+
tool: 'sce-native',
|
|
61
|
+
agentVersion: options.agent_version || options.agentVersion || null,
|
|
62
|
+
objective: normalizeString(options.objective) || 'SCE native semantic session',
|
|
63
|
+
sessionId: options.id || null
|
|
64
|
+
});
|
|
65
|
+
return { store, session, created: true };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function bindNativeSession(store, session, options = {}) {
|
|
69
|
+
const projectId = normalizeString(options.project_id || options.projectId);
|
|
70
|
+
const channelId = normalizeString(options.channel_id || options.channelId || options.channel);
|
|
71
|
+
if (!projectId || !channelId) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const bound = await store.bindSessionToProjectChannel(session.session_id, {
|
|
76
|
+
projectId,
|
|
77
|
+
channelId,
|
|
78
|
+
activeScene: options.scene_id || options.sceneId || options.scene,
|
|
79
|
+
activeSpecId: options.spec_id || options.specId || options.spec,
|
|
80
|
+
activeDoc: options.doc_id || options.docId || options.doc,
|
|
81
|
+
focus: true,
|
|
82
|
+
syncCurrentContext: true
|
|
83
|
+
});
|
|
84
|
+
return {
|
|
85
|
+
project_id: projectId,
|
|
86
|
+
channel_id: channelId,
|
|
87
|
+
focused_channel_id: bound.context.focusedChannelId,
|
|
88
|
+
active_session_path: bound.channel.activeSessionPath,
|
|
89
|
+
active_scene: bound.channel.activeScene,
|
|
90
|
+
active_spec_id: bound.channel.activeSpecId,
|
|
91
|
+
active_doc: bound.channel.activeDoc
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function buildNativeReply(prompt, activations = [], context = {}) {
|
|
96
|
+
const top = activations.slice(0, 3);
|
|
97
|
+
if (top.length === 0) {
|
|
98
|
+
return {
|
|
99
|
+
text: 'No promoted semantic behavior matched this request. Continue with project/channel/spec context and gather more governed observations before promotion.',
|
|
100
|
+
explanation: {
|
|
101
|
+
activated_lessons: [],
|
|
102
|
+
matched_terms: []
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const steps = unique(top.map((item) => normalizeString(item.heuristic)).filter(Boolean)).slice(0, 3);
|
|
108
|
+
const activatedLessons = top.map((item) => ({
|
|
109
|
+
lesson_id: item.lesson_id,
|
|
110
|
+
title: item.title,
|
|
111
|
+
matched_terms: item.activation.matched_terms
|
|
112
|
+
}));
|
|
113
|
+
const matchedTerms = unique(top.flatMap((item) => item.activation.matched_terms || []));
|
|
114
|
+
const prefix = context.project_id
|
|
115
|
+
? `Native SCE guidance for ${context.project_id}:`
|
|
116
|
+
: 'Native SCE guidance:';
|
|
117
|
+
const body = steps.length > 0
|
|
118
|
+
? steps.map((item, index) => `${index + 1}. ${item}`).join('\n')
|
|
119
|
+
: top.map((item, index) => `${index + 1}. ${item.summary || item.title || item.lesson_id}`).join('\n');
|
|
120
|
+
|
|
121
|
+
return {
|
|
122
|
+
text: `${prefix}\n${body}`,
|
|
123
|
+
explanation: {
|
|
124
|
+
activated_lessons: activatedLessons,
|
|
125
|
+
matched_terms: matchedTerms
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async function startNativeConsoleSession(options = {}, dependencies = {}) {
|
|
131
|
+
const { store, session, created } = await resolveNativeSession(options, dependencies);
|
|
132
|
+
const projectChannel = await bindNativeSession(store, session, options);
|
|
133
|
+
const promoted = await listPromotedSemanticBehaviors({
|
|
134
|
+
project_id: options.project_id || options.projectId,
|
|
135
|
+
channel_id: options.channel_id || options.channelId || options.channel,
|
|
136
|
+
scene_id: options.scene_id || options.sceneId || options.scene,
|
|
137
|
+
spec_id: options.spec_id || options.specId || options.spec,
|
|
138
|
+
limit: options.limit || 20
|
|
139
|
+
}, {
|
|
140
|
+
projectPath: dependencies.projectPath || process.cwd(),
|
|
141
|
+
fileSystem: dependencies.fileSystem,
|
|
142
|
+
env: dependencies.env,
|
|
143
|
+
sqliteModule: dependencies.sqliteModule,
|
|
144
|
+
stateStore: dependencies.stateStore
|
|
145
|
+
});
|
|
146
|
+
const lease = await resolveLeaseSnapshot(options.auth_lease || options.authLease, dependencies);
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
session,
|
|
150
|
+
created,
|
|
151
|
+
project_channel: projectChannel,
|
|
152
|
+
lease,
|
|
153
|
+
promoted_behaviors: promoted
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async function runNativeSemanticTurn(options = {}, dependencies = {}) {
|
|
158
|
+
const prompt = normalizeString(options.prompt || options.message);
|
|
159
|
+
if (!prompt) {
|
|
160
|
+
throw new Error('prompt is required');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const supremeAssessment = await assessSupremeIntent({
|
|
164
|
+
text: prompt,
|
|
165
|
+
source_kind: 'native-ask',
|
|
166
|
+
scene_id: options.scene_id || options.sceneId || options.scene,
|
|
167
|
+
spec_id: options.spec_id || options.specId || options.spec
|
|
168
|
+
}, {
|
|
169
|
+
projectPath: dependencies.projectPath || process.cwd(),
|
|
170
|
+
fileSystem: dependencies.fileSystem
|
|
171
|
+
});
|
|
172
|
+
const effectivePrompt = normalizeString(supremeAssessment.effective_text) || prompt;
|
|
173
|
+
|
|
174
|
+
const resolved = await startNativeConsoleSession(options, dependencies);
|
|
175
|
+
const { store, session } = await resolveNativeSession({
|
|
176
|
+
session_id: resolved.session.session_id
|
|
177
|
+
}, dependencies);
|
|
178
|
+
const governedReply = buildNativeGovernedReply(supremeAssessment);
|
|
179
|
+
let activations = [];
|
|
180
|
+
let reply = governedReply;
|
|
181
|
+
|
|
182
|
+
if (supremeAssessment.execution_allowed) {
|
|
183
|
+
activations = await activatePromotedSemanticBehaviors(effectivePrompt, {
|
|
184
|
+
project_id: options.project_id || options.projectId,
|
|
185
|
+
channel_id: options.channel_id || options.channelId || options.channel,
|
|
186
|
+
scene_id: options.scene_id || options.sceneId || options.scene,
|
|
187
|
+
spec_id: options.spec_id || options.specId || options.spec,
|
|
188
|
+
limit: options.limit || 10
|
|
189
|
+
}, {
|
|
190
|
+
projectPath: dependencies.projectPath || process.cwd(),
|
|
191
|
+
fileSystem: dependencies.fileSystem,
|
|
192
|
+
env: dependencies.env,
|
|
193
|
+
sqliteModule: dependencies.sqliteModule,
|
|
194
|
+
stateStore: dependencies.stateStore
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
const semanticReply = buildNativeReply(effectivePrompt, activations, {
|
|
198
|
+
project_id: options.project_id || options.projectId
|
|
199
|
+
});
|
|
200
|
+
reply = (supremeAssessment.action === 'rewrite' || supremeAssessment.action === 'narrow') && governedReply
|
|
201
|
+
? {
|
|
202
|
+
...semanticReply,
|
|
203
|
+
text: `${governedReply.text}\n\n${semanticReply.text}`
|
|
204
|
+
}
|
|
205
|
+
: semanticReply;
|
|
206
|
+
}
|
|
207
|
+
const activatedLessonIds = activations.map((item) => item.lesson_id);
|
|
208
|
+
const activatedCapabilityIds = activations.map((item) => item.capability_id);
|
|
209
|
+
const replyQualitySignal = supremeAssessment.execution_allowed
|
|
210
|
+
? (activations.length > 0 ? 'positive' : 'mixed')
|
|
211
|
+
: (supremeAssessment.action === 'refuse' ? 'negative' : 'mixed');
|
|
212
|
+
|
|
213
|
+
const supremeEvidence = normalizeString(options.spec_id || options.specId || options.spec)
|
|
214
|
+
? await writeSupremeIntentEvidence(dependencies.projectPath || process.cwd(), options.spec_id || options.specId || options.spec, {
|
|
215
|
+
...supremeAssessment,
|
|
216
|
+
source_kind: 'native-ask',
|
|
217
|
+
spec_id: options.spec_id || options.specId || options.spec
|
|
218
|
+
}, {
|
|
219
|
+
fileSystem: dependencies.fileSystem
|
|
220
|
+
})
|
|
221
|
+
: null;
|
|
222
|
+
|
|
223
|
+
const supremeLedgerEntry = await recordSupremeIntentAssessment({
|
|
224
|
+
...supremeAssessment,
|
|
225
|
+
project_id: options.project_id || options.projectId,
|
|
226
|
+
channel_id: options.channel_id || options.channelId || options.channel,
|
|
227
|
+
session_id: session.session_id,
|
|
228
|
+
scene_id: options.scene_id || options.sceneId || options.scene,
|
|
229
|
+
spec_id: options.spec_id || options.specId || options.spec,
|
|
230
|
+
source_kind: 'native-ask',
|
|
231
|
+
evidence_path: supremeEvidence ? supremeEvidence.relative_path : null,
|
|
232
|
+
metadata: {
|
|
233
|
+
project_channel: resolved.project_channel || null,
|
|
234
|
+
activated_lesson_ids: activatedLessonIds,
|
|
235
|
+
activated_capability_ids: activatedCapabilityIds,
|
|
236
|
+
reply_quality_signal: replyQualitySignal
|
|
237
|
+
}
|
|
238
|
+
}, {
|
|
239
|
+
projectPath: dependencies.projectPath || process.cwd(),
|
|
240
|
+
fileSystem: dependencies.fileSystem,
|
|
241
|
+
env: dependencies.env,
|
|
242
|
+
sqliteModule: dependencies.sqliteModule,
|
|
243
|
+
stateStore: dependencies.stateStore,
|
|
244
|
+
noCache: dependencies.noCache === true
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
await observeSemanticInteraction({
|
|
248
|
+
project_id: options.project_id || options.projectId,
|
|
249
|
+
channel_id: options.channel_id || options.channelId || options.channel,
|
|
250
|
+
session_id: session.session_id,
|
|
251
|
+
scene_id: options.scene_id || options.sceneId || options.scene,
|
|
252
|
+
spec_id: options.spec_id || options.specId || options.spec,
|
|
253
|
+
source_runtime: 'sce-native',
|
|
254
|
+
source_kind: 'native-shell',
|
|
255
|
+
event_kind: 'prompt',
|
|
256
|
+
role: 'user',
|
|
257
|
+
text: prompt,
|
|
258
|
+
summary: prompt.slice(0, 240),
|
|
259
|
+
outcome: 'observed',
|
|
260
|
+
quality_signal: 'unknown',
|
|
261
|
+
metadata: {
|
|
262
|
+
native_runtime: true,
|
|
263
|
+
activated_lesson_ids: [],
|
|
264
|
+
activated_capability_ids: [],
|
|
265
|
+
supreme_action: supremeAssessment.action,
|
|
266
|
+
supreme_effective_text: effectivePrompt,
|
|
267
|
+
supreme_intent_evidence: supremeEvidence ? supremeEvidence.relative_path : null
|
|
268
|
+
}
|
|
269
|
+
}, {
|
|
270
|
+
projectPath: dependencies.projectPath || process.cwd(),
|
|
271
|
+
fileSystem: dependencies.fileSystem,
|
|
272
|
+
env: dependencies.env,
|
|
273
|
+
sqliteModule: dependencies.sqliteModule,
|
|
274
|
+
stateStore: dependencies.stateStore
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
await observeSemanticInteraction({
|
|
278
|
+
project_id: options.project_id || options.projectId,
|
|
279
|
+
channel_id: options.channel_id || options.channelId || options.channel,
|
|
280
|
+
session_id: session.session_id,
|
|
281
|
+
scene_id: options.scene_id || options.sceneId || options.scene,
|
|
282
|
+
spec_id: options.spec_id || options.specId || options.spec,
|
|
283
|
+
source_runtime: 'sce-native',
|
|
284
|
+
source_kind: 'native-shell',
|
|
285
|
+
event_kind: 'reply',
|
|
286
|
+
role: 'assistant',
|
|
287
|
+
text: reply.text,
|
|
288
|
+
summary: reply.text.slice(0, 240),
|
|
289
|
+
outcome: 'observed',
|
|
290
|
+
quality_signal: replyQualitySignal,
|
|
291
|
+
metadata: {
|
|
292
|
+
native_runtime: true,
|
|
293
|
+
activated_lesson_ids: activatedLessonIds,
|
|
294
|
+
activated_capability_ids: activatedCapabilityIds,
|
|
295
|
+
supreme_action: supremeAssessment.action,
|
|
296
|
+
supreme_effective_text: effectivePrompt,
|
|
297
|
+
supreme_intent_evidence: supremeEvidence ? supremeEvidence.relative_path : null
|
|
298
|
+
}
|
|
299
|
+
}, {
|
|
300
|
+
projectPath: dependencies.projectPath || process.cwd(),
|
|
301
|
+
fileSystem: dependencies.fileSystem,
|
|
302
|
+
env: dependencies.env,
|
|
303
|
+
sqliteModule: dependencies.sqliteModule,
|
|
304
|
+
stateStore: dependencies.stateStore
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
for (const activation of activations) {
|
|
308
|
+
await recordSemanticCapabilityActivation({
|
|
309
|
+
capability_id: activation.capability_id,
|
|
310
|
+
lesson_id: activation.lesson_id,
|
|
311
|
+
project_id: options.project_id || options.projectId,
|
|
312
|
+
channel_id: options.channel_id || options.channelId || options.channel,
|
|
313
|
+
session_id: session.session_id,
|
|
314
|
+
source_runtime: 'sce-native',
|
|
315
|
+
quality_signal: replyQualitySignal,
|
|
316
|
+
activated_at: new Date().toISOString()
|
|
317
|
+
}, {
|
|
318
|
+
projectPath: dependencies.projectPath || process.cwd(),
|
|
319
|
+
fileSystem: dependencies.fileSystem,
|
|
320
|
+
env: dependencies.env,
|
|
321
|
+
sqliteModule: dependencies.sqliteModule,
|
|
322
|
+
stateStore: dependencies.stateStore
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
await store.snapshotSession(session.session_id, {
|
|
327
|
+
summary: `native turn | ${prompt.slice(0, 80)}`,
|
|
328
|
+
status: 'active',
|
|
329
|
+
payload: {
|
|
330
|
+
prompt,
|
|
331
|
+
effective_prompt: effectivePrompt,
|
|
332
|
+
reply_preview: reply.text.slice(0, 240),
|
|
333
|
+
activated_lesson_ids: activatedLessonIds,
|
|
334
|
+
activated_capability_ids: activatedCapabilityIds,
|
|
335
|
+
supreme_principles: {
|
|
336
|
+
action: supremeAssessment.action,
|
|
337
|
+
execution_allowed: supremeAssessment.execution_allowed,
|
|
338
|
+
evidence: supremeEvidence ? supremeEvidence.relative_path : null
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
return {
|
|
344
|
+
session: await store.getSession(session.session_id),
|
|
345
|
+
project_channel: resolved.project_channel,
|
|
346
|
+
lease: resolved.lease,
|
|
347
|
+
reply,
|
|
348
|
+
activations,
|
|
349
|
+
supreme_principles: supremeAssessment,
|
|
350
|
+
supreme_intent_record: supremeLedgerEntry
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
module.exports = {
|
|
355
|
+
resolveNativeSession,
|
|
356
|
+
buildNativeReply,
|
|
357
|
+
startNativeConsoleSession,
|
|
358
|
+
runNativeSemanticTurn
|
|
359
|
+
};
|