odai-dsh-agent 0.2.3 → 0.2.6
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.md +3 -3
- package/build/bin/odai-dsh-agent.d.mts +3 -0
- package/build/bin/odai-dsh-agent.d.mts.map +1 -0
- package/build/bin/odai-dsh-agent.mjs +114 -0
- package/build/bin/odai-dsh-agent.mjs.map +1 -0
- package/build/src/dsh-version.d.mts +16 -0
- package/build/src/dsh-version.d.mts.map +1 -0
- package/build/src/dsh-version.mjs +20 -0
- package/build/src/dsh-version.mjs.map +1 -0
- package/build/src/installer.d.mts +46 -0
- package/build/src/installer.d.mts.map +1 -0
- package/build/src/installer.mjs +397 -0
- package/build/src/installer.mjs.map +1 -0
- package/package.json +13 -12
- package/preset/odai/runtime/compaction-config.d.mts +66 -0
- package/preset/odai/runtime/compaction-config.d.mts.map +1 -0
- package/preset/odai/runtime/compaction-config.mjs +320 -342
- package/preset/odai/runtime/compaction-config.mjs.map +1 -0
- package/preset/odai/runtime/compaction-runtime.d.mts +68 -0
- package/preset/odai/runtime/compaction-runtime.d.mts.map +1 -0
- package/preset/odai/runtime/compaction-runtime.mjs +157 -0
- package/preset/odai/runtime/compaction-runtime.mjs.map +1 -0
- package/preset/odai/runtime/context-activation.d.mts +31 -0
- package/preset/odai/runtime/context-activation.d.mts.map +1 -0
- package/preset/odai/runtime/context-activation.mjs +55 -49
- package/preset/odai/runtime/context-activation.mjs.map +1 -0
- package/preset/odai/runtime/context-capability.d.mts +16 -0
- package/preset/odai/runtime/context-capability.d.mts.map +1 -0
- package/preset/odai/runtime/context-capability.mjs +79 -74
- package/preset/odai/runtime/context-capability.mjs.map +1 -0
- package/preset/odai/runtime/governance.d.mts +30 -0
- package/preset/odai/runtime/governance.d.mts.map +1 -0
- package/preset/odai/runtime/governance.mjs +126 -113
- package/preset/odai/runtime/governance.mjs.map +1 -0
- package/preset/odai/runtime/human-care.d.mts +13 -0
- package/preset/odai/runtime/human-care.d.mts.map +1 -0
- package/preset/odai/runtime/human-care.mjs +45 -42
- package/preset/odai/runtime/human-care.mjs.map +1 -0
- package/preset/odai/runtime/human-safety-continuity-store.d.mts +43 -0
- package/preset/odai/runtime/human-safety-continuity-store.d.mts.map +1 -0
- package/preset/odai/runtime/human-safety-continuity-store.mjs +193 -215
- package/preset/odai/runtime/human-safety-continuity-store.mjs.map +1 -0
- package/preset/odai/runtime/human-safety-continuity.d.mts +27 -0
- package/preset/odai/runtime/human-safety-continuity.d.mts.map +1 -0
- package/preset/odai/runtime/human-safety-continuity.mjs +205 -216
- package/preset/odai/runtime/human-safety-continuity.mjs.map +1 -0
- package/preset/odai/runtime/human-safety.d.mts +14 -0
- package/preset/odai/runtime/human-safety.d.mts.map +1 -0
- package/preset/odai/runtime/human-safety.mjs +50 -47
- package/preset/odai/runtime/human-safety.mjs.map +1 -0
- package/preset/odai/runtime/index.d.mts +8 -0
- package/preset/odai/runtime/index.d.mts.map +1 -0
- package/preset/odai/runtime/index.mjs +161 -2441
- package/preset/odai/runtime/index.mjs.map +1 -0
- package/preset/odai/runtime/lifecycle-runtime.d.mts +83 -0
- package/preset/odai/runtime/lifecycle-runtime.d.mts.map +1 -0
- package/preset/odai/runtime/lifecycle-runtime.mjs +1081 -0
- package/preset/odai/runtime/lifecycle-runtime.mjs.map +1 -0
- package/preset/odai/runtime/model-route.d.mts +22 -0
- package/preset/odai/runtime/model-route.d.mts.map +1 -0
- package/preset/odai/runtime/model-route.mjs +68 -60
- package/preset/odai/runtime/model-route.mjs.map +1 -0
- package/preset/odai/runtime/output-config.d.mts +54 -0
- package/preset/odai/runtime/output-config.d.mts.map +1 -0
- package/preset/odai/runtime/output-config.mjs +289 -315
- package/preset/odai/runtime/output-config.mjs.map +1 -0
- package/preset/odai/runtime/output-policy-state.d.mts +3 -0
- package/preset/odai/runtime/output-policy-state.d.mts.map +1 -0
- package/preset/odai/runtime/output-policy-state.mjs +41 -29
- package/preset/odai/runtime/output-policy-state.mjs.map +1 -0
- package/preset/odai/runtime/prompt-runtime.d.mts +55 -0
- package/preset/odai/runtime/prompt-runtime.d.mts.map +1 -0
- package/preset/odai/runtime/prompt-runtime.mjs +303 -0
- package/preset/odai/runtime/prompt-runtime.mjs.map +1 -0
- package/preset/odai/runtime/research-packet.d.mts +30 -0
- package/preset/odai/runtime/research-packet.d.mts.map +1 -0
- package/preset/odai/runtime/research-packet.mjs +116 -117
- package/preset/odai/runtime/research-packet.mjs.map +1 -0
- package/preset/odai/runtime/responsibility-gap.d.mts +26 -0
- package/preset/odai/runtime/responsibility-gap.d.mts.map +1 -0
- package/preset/odai/runtime/responsibility-gap.mjs +91 -85
- package/preset/odai/runtime/responsibility-gap.mjs.map +1 -0
- package/preset/odai/runtime/responsibility-scope.d.mts +69 -0
- package/preset/odai/runtime/responsibility-scope.d.mts.map +1 -0
- package/preset/odai/runtime/responsibility-scope.mjs +199 -171
- package/preset/odai/runtime/responsibility-scope.mjs.map +1 -0
- package/preset/odai/runtime/role-overlays.d.mts +5 -0
- package/preset/odai/runtime/role-overlays.d.mts.map +1 -0
- package/preset/odai/runtime/role-overlays.mjs +14 -13
- package/preset/odai/runtime/role-overlays.mjs.map +1 -0
- package/preset/odai/runtime/route-card.d.mts +42 -0
- package/preset/odai/runtime/route-card.d.mts.map +1 -0
- package/preset/odai/runtime/route-card.mjs +158 -146
- package/preset/odai/runtime/route-card.mjs.map +1 -0
- package/preset/odai/runtime/router.d.mts +79 -0
- package/preset/odai/runtime/router.d.mts.map +1 -0
- package/preset/odai/runtime/router.mjs +491 -559
- package/preset/odai/runtime/router.mjs.map +1 -0
- package/preset/odai/runtime/routing-config.d.mts +76 -0
- package/preset/odai/runtime/routing-config.d.mts.map +1 -0
- package/preset/odai/runtime/routing-config.mjs +373 -438
- package/preset/odai/runtime/routing-config.mjs.map +1 -0
- package/preset/odai/runtime/routing-context.d.mts +47 -0
- package/preset/odai/runtime/routing-context.d.mts.map +1 -0
- package/preset/odai/runtime/routing-context.mjs +238 -273
- package/preset/odai/runtime/routing-context.mjs.map +1 -0
- package/preset/odai/runtime/runtime-config.d.mts +24 -0
- package/preset/odai/runtime/runtime-config.d.mts.map +1 -0
- package/preset/odai/runtime/runtime-config.mjs +181 -0
- package/preset/odai/runtime/runtime-config.mjs.map +1 -0
- package/preset/odai/runtime/runtime-support.d.mts +91 -0
- package/preset/odai/runtime/runtime-support.d.mts.map +1 -0
- package/preset/odai/runtime/runtime-support.mjs +371 -0
- package/preset/odai/runtime/runtime-support.mjs.map +1 -0
- package/preset/odai/runtime/runtime-types.d.mts +235 -0
- package/preset/odai/runtime/runtime-types.d.mts.map +1 -0
- package/preset/odai/runtime/runtime-types.mjs +4 -0
- package/preset/odai/runtime/runtime-types.mjs.map +1 -0
- package/preset/odai/runtime/semantic-memory-store.d.mts +110 -0
- package/preset/odai/runtime/semantic-memory-store.d.mts.map +1 -0
- package/preset/odai/runtime/semantic-memory-store.mjs +271 -385
- package/preset/odai/runtime/semantic-memory-store.mjs.map +1 -0
- package/preset/odai/runtime/semantic-memory.d.mts +88 -0
- package/preset/odai/runtime/semantic-memory.d.mts.map +1 -0
- package/preset/odai/runtime/semantic-memory.mjs +790 -750
- package/preset/odai/runtime/semantic-memory.mjs.map +1 -0
- package/preset/odai/runtime/session-compat.d.mts +31 -0
- package/preset/odai/runtime/session-compat.d.mts.map +1 -0
- package/preset/odai/runtime/session-compat.mjs +301 -328
- package/preset/odai/runtime/session-compat.mjs.map +1 -0
- package/preset/odai/runtime/session-evidence.d.mts +25 -0
- package/preset/odai/runtime/session-evidence.d.mts.map +1 -0
- package/preset/odai/runtime/session-evidence.mjs +309 -287
- package/preset/odai/runtime/session-evidence.mjs.map +1 -0
- package/preset/odai/runtime/skill-bundle.d.mts +53 -0
- package/preset/odai/runtime/skill-bundle.d.mts.map +1 -0
- package/preset/odai/runtime/skill-bundle.mjs +286 -276
- package/preset/odai/runtime/skill-bundle.mjs.map +1 -0
- package/preset/odai/runtime/skill-evolution.d.mts +112 -0
- package/preset/odai/runtime/skill-evolution.d.mts.map +1 -0
- package/preset/odai/runtime/skill-evolution.mjs +1287 -1261
- package/preset/odai/runtime/skill-evolution.mjs.map +1 -0
- package/preset/odai/runtime/skill-selection-state.d.mts +5 -0
- package/preset/odai/runtime/skill-selection-state.d.mts.map +1 -0
- package/preset/odai/runtime/skill-selection-state.mjs +59 -43
- package/preset/odai/runtime/skill-selection-state.mjs.map +1 -0
- package/preset/odai/runtime/skill-selector.d.mts +28 -0
- package/preset/odai/runtime/skill-selector.d.mts.map +1 -0
- package/preset/odai/runtime/skill-selector.mjs +100 -109
- package/preset/odai/runtime/skill-selector.mjs.map +1 -0
- package/preset/odai/runtime/skill-source-config.d.mts +32 -0
- package/preset/odai/runtime/skill-source-config.d.mts.map +1 -0
- package/preset/odai/runtime/skill-source-config.mjs +200 -210
- package/preset/odai/runtime/skill-source-config.mjs.map +1 -0
- package/preset/odai/runtime/store-lock.d.mts +2 -0
- package/preset/odai/runtime/store-lock.d.mts.map +1 -0
- package/preset/odai/runtime/store-lock.mjs +92 -87
- package/preset/odai/runtime/store-lock.mjs.map +1 -0
- package/preset/odai/runtime/tool-runtime.d.mts +43 -0
- package/preset/odai/runtime/tool-runtime.d.mts.map +1 -0
- package/preset/odai/runtime/tool-runtime.mjs +221 -0
- package/preset/odai/runtime/tool-runtime.mjs.map +1 -0
- package/bin/odai-dsh-agent.mjs +0 -108
- package/scripts/verify-agent-load.mjs +0 -257
- package/src/dsh-version.mjs +0 -24
- package/src/installer.mjs +0 -398
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { CONFIGURABLE_ROLES, resolveRoleRoute, resolveRoutingConfigPath } from "./routing-config.mjs";
|
|
5
|
+
import { resolveOutputConfigPath } from "./output-config.mjs";
|
|
6
|
+
import { resolveCompactionConfigPath } from "./compaction-config.mjs";
|
|
7
|
+
import { resolveSkillSourceConfigPath } from "./skill-source-config.mjs";
|
|
8
|
+
import { SKILL_SOURCE_MODES, loadSkillBundle } from "./skill-bundle.mjs";
|
|
9
|
+
import { resolveSkillEvolutionRoot } from "./skill-evolution.mjs";
|
|
10
|
+
import { MEMORY_MODES, resolveMemoryStorePath } from "./semantic-memory-store.mjs";
|
|
11
|
+
import { isUnknownRecord } from "./runtime-types.mjs";
|
|
12
|
+
const PLUGIN_DIR = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
13
|
+
const ROUTING_MODES = new Set(["off", "observe", "auto", "execute"]);
|
|
14
|
+
const COMPACTION_CACHE_RETENTIONS = new Set(["provider-default", "short", "long", "none"]);
|
|
15
|
+
export const ROUTED_ROLES = CONFIGURABLE_ROLES;
|
|
16
|
+
const DEFAULT_ROUTING_MODE = "auto";
|
|
17
|
+
function isRoutingMode(value) {
|
|
18
|
+
return typeof value === "string" && ROUTING_MODES.has(value);
|
|
19
|
+
}
|
|
20
|
+
function isMemoryMode(value) {
|
|
21
|
+
return typeof value === "string" && MEMORY_MODES.includes(value);
|
|
22
|
+
}
|
|
23
|
+
function isCacheRetention(value) {
|
|
24
|
+
return typeof value === "string" && COMPACTION_CACHE_RETENTIONS.has(value);
|
|
25
|
+
}
|
|
26
|
+
function isSkillSource(value) {
|
|
27
|
+
return typeof value === "string" && SKILL_SOURCE_MODES.includes(value);
|
|
28
|
+
}
|
|
29
|
+
function assertPlainObject(value, field) {
|
|
30
|
+
if (value === undefined)
|
|
31
|
+
return {};
|
|
32
|
+
if (!isUnknownRecord(value))
|
|
33
|
+
throw new TypeError(`${field} must be an object`);
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
export function resolveConfig(rawConfig = {}) {
|
|
37
|
+
const raw = assertPlainObject(rawConfig, "config");
|
|
38
|
+
const routing = assertPlainObject(raw.routing, "config.routing");
|
|
39
|
+
const roles = assertPlainObject(routing.roles, "config.routing.roles");
|
|
40
|
+
const governance = assertPlainObject(raw.governance, "config.governance");
|
|
41
|
+
const output = assertPlainObject(raw.output, "config.output");
|
|
42
|
+
const compaction = assertPlainObject(raw.compaction, "config.compaction");
|
|
43
|
+
const memory = assertPlainObject(raw.memory, "config.memory");
|
|
44
|
+
const mode = routing.mode ?? DEFAULT_ROUTING_MODE;
|
|
45
|
+
const provider = routing.provider ?? "spawn";
|
|
46
|
+
const maxInputChars = routing.maxInputChars ?? 12_000;
|
|
47
|
+
const configPath = resolveRoutingConfigPath(routing.configPath);
|
|
48
|
+
const additionalDeniedTools = governance.additionalDeniedTools ?? [];
|
|
49
|
+
const skillSource = governance.skillSource ?? "bundled";
|
|
50
|
+
const skillConfigPath = resolveSkillSourceConfigPath(governance.skillConfigPath);
|
|
51
|
+
const evolutionRoot = resolveSkillEvolutionRoot(governance.evolutionRoot);
|
|
52
|
+
const outputConfigPath = resolveOutputConfigPath(output.configPath);
|
|
53
|
+
const compactionConfigPath = resolveCompactionConfigPath(compaction.configPath);
|
|
54
|
+
const memoryStorePath = resolveMemoryStorePath(memory.storePath);
|
|
55
|
+
const memoryMode = memory.mode ?? "auto";
|
|
56
|
+
const memoryMaxRetrieved = memory.maxRetrieved ?? 6;
|
|
57
|
+
const compactionCacheRetention = compaction.cacheRetention
|
|
58
|
+
?? process.env.ODAI_COMPACTION_CACHE_RETENTION
|
|
59
|
+
?? "provider-default";
|
|
60
|
+
const unknownRoles = Object.keys(roles).filter((role) => !ROUTED_ROLES.includes(role));
|
|
61
|
+
const unknownOutputFields = Object.keys(output).filter((field) => field !== "configPath");
|
|
62
|
+
const unknownCompactionFields = Object.keys(compaction).filter((field) => !["cacheRetention", "configPath"].includes(field));
|
|
63
|
+
const unknownMemoryFields = Object.keys(memory).filter((field) => !["mode", "storePath", "maxRetrieved"].includes(field));
|
|
64
|
+
if (!isRoutingMode(mode)) {
|
|
65
|
+
throw new TypeError("config.routing.mode must be off, observe, auto, or execute");
|
|
66
|
+
}
|
|
67
|
+
if (typeof provider !== "string" || provider.trim() === "") {
|
|
68
|
+
throw new TypeError("config.routing.provider must be a non-empty string");
|
|
69
|
+
}
|
|
70
|
+
if (typeof maxInputChars !== "number" || !Number.isSafeInteger(maxInputChars) || maxInputChars < 256) {
|
|
71
|
+
throw new TypeError("config.routing.maxInputChars must be an integer of at least 256");
|
|
72
|
+
}
|
|
73
|
+
if (unknownRoles.length > 0) {
|
|
74
|
+
throw new TypeError(`config.routing.roles has unknown roles: ${unknownRoles.join(", ")}`);
|
|
75
|
+
}
|
|
76
|
+
if (unknownOutputFields.length > 0) {
|
|
77
|
+
throw new TypeError(`config.output has unknown fields: ${unknownOutputFields.join(", ")}`);
|
|
78
|
+
}
|
|
79
|
+
if (unknownCompactionFields.length > 0) {
|
|
80
|
+
throw new TypeError(`config.compaction has unknown fields: ${unknownCompactionFields.join(", ")}`);
|
|
81
|
+
}
|
|
82
|
+
if (unknownMemoryFields.length > 0) {
|
|
83
|
+
throw new TypeError(`config.memory has unknown fields: ${unknownMemoryFields.join(", ")}`);
|
|
84
|
+
}
|
|
85
|
+
if (!isMemoryMode(memoryMode)) {
|
|
86
|
+
throw new TypeError("config.memory.mode must be auto or off");
|
|
87
|
+
}
|
|
88
|
+
if (typeof memoryMaxRetrieved !== "number" || !Number.isSafeInteger(memoryMaxRetrieved) || memoryMaxRetrieved < 1 || memoryMaxRetrieved > 12) {
|
|
89
|
+
throw new TypeError("config.memory.maxRetrieved must be an integer from 1 to 12");
|
|
90
|
+
}
|
|
91
|
+
if (!isCacheRetention(compactionCacheRetention)) {
|
|
92
|
+
throw new TypeError("config.compaction.cacheRetention must be provider-default, short, long, or none");
|
|
93
|
+
}
|
|
94
|
+
if (!Array.isArray(additionalDeniedTools)
|
|
95
|
+
|| additionalDeniedTools.some((tool) => typeof tool !== "string" || tool.trim() === "")) {
|
|
96
|
+
throw new TypeError("config.governance.additionalDeniedTools must be an array of non-empty strings");
|
|
97
|
+
}
|
|
98
|
+
if (!isSkillSource(skillSource)) {
|
|
99
|
+
throw new TypeError("config.governance.skillSource must be bundled, auto, or user");
|
|
100
|
+
}
|
|
101
|
+
if (raw.skillPath !== undefined && (typeof raw.skillPath !== "string" || raw.skillPath.trim() === "")) {
|
|
102
|
+
throw new TypeError("config.skillPath must be a non-empty string");
|
|
103
|
+
}
|
|
104
|
+
const deniedTools = additionalDeniedTools;
|
|
105
|
+
return Object.freeze({
|
|
106
|
+
skillPath: raw.skillPath,
|
|
107
|
+
routing: Object.freeze({
|
|
108
|
+
mode,
|
|
109
|
+
provider: provider.trim(),
|
|
110
|
+
maxInputChars,
|
|
111
|
+
configPath,
|
|
112
|
+
roles: Object.freeze(Object.fromEntries(ROUTED_ROLES.map((role) => [
|
|
113
|
+
role,
|
|
114
|
+
resolveRoleRoute(roles[role], role),
|
|
115
|
+
]))),
|
|
116
|
+
}),
|
|
117
|
+
governance: Object.freeze({
|
|
118
|
+
additionalDeniedTools: Object.freeze(deniedTools.map((tool) => tool.trim())),
|
|
119
|
+
skillSource,
|
|
120
|
+
skillConfigPath,
|
|
121
|
+
evolutionRoot,
|
|
122
|
+
}),
|
|
123
|
+
output: Object.freeze({ configPath: outputConfigPath }),
|
|
124
|
+
compaction: Object.freeze({
|
|
125
|
+
cacheRetention: compactionCacheRetention,
|
|
126
|
+
configPath: compactionConfigPath,
|
|
127
|
+
}),
|
|
128
|
+
memory: Object.freeze({
|
|
129
|
+
mode: memoryMode,
|
|
130
|
+
storePath: memoryStorePath,
|
|
131
|
+
maxRetrieved: memoryMaxRetrieved,
|
|
132
|
+
}),
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
/** Mutate exact-route compaction options; returns true only when an option changed. */
|
|
136
|
+
export function inheritCompactionReasoning(options, sessions, cacheRetention = "provider-default") {
|
|
137
|
+
if (options?.purpose !== "compaction"
|
|
138
|
+
|| options.sessionId === undefined
|
|
139
|
+
|| !Object.isExtensible(options)) {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
const route = sessions?.get?.(options.sessionId)?.requestHeader?.()?.config;
|
|
143
|
+
if (!route
|
|
144
|
+
|| route.provider !== options.provider
|
|
145
|
+
|| route.model !== options.model
|
|
146
|
+
|| typeof route.reasoningEffort !== "string"
|
|
147
|
+
|| route.reasoningEffort.length === 0) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
let changed = false;
|
|
151
|
+
if (options.reasoningEffort === undefined) {
|
|
152
|
+
options.reasoningEffort = route.reasoningEffort;
|
|
153
|
+
changed = true;
|
|
154
|
+
}
|
|
155
|
+
if (options.cacheRetention === undefined && cacheRetention !== "provider-default") {
|
|
156
|
+
options.cacheRetention = cacheRetention;
|
|
157
|
+
changed = true;
|
|
158
|
+
}
|
|
159
|
+
return changed;
|
|
160
|
+
}
|
|
161
|
+
export function resolveSkillPath(configuredPath, env = process.env) {
|
|
162
|
+
const explicit = configuredPath ?? env.ODAI_SKILL_PATH;
|
|
163
|
+
if (explicit !== undefined) {
|
|
164
|
+
const path = resolve(explicit);
|
|
165
|
+
if (!existsSync(path))
|
|
166
|
+
throw new Error(`explicit Odai canonical skill not found: ${path}`);
|
|
167
|
+
return path;
|
|
168
|
+
}
|
|
169
|
+
const candidates = [
|
|
170
|
+
resolve(PLUGIN_DIR, "skills/odai/SKILL.md"),
|
|
171
|
+
resolve(PLUGIN_DIR, "../../skills/odai/SKILL.md"),
|
|
172
|
+
];
|
|
173
|
+
const found = candidates.find((candidate) => existsSync(candidate));
|
|
174
|
+
if (found)
|
|
175
|
+
return found;
|
|
176
|
+
throw new Error(`Odai bundled canonical skill not found; checked: ${candidates.join(", ")}`);
|
|
177
|
+
}
|
|
178
|
+
export function loadRoleContracts(skillPath) {
|
|
179
|
+
return loadSkillBundle(skillPath).roleContracts;
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=runtime-config.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-config.mjs","sourceRoot":"","sources":["../src/runtime-config.mts"],"names":[],"mappings":"AAAA,OAAO,EAA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KAAK,CAAC,4CAA4C,IAAI,EAAE,CAAC,CAAC;QAC3F,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,UAAU,GAAG;QACjB,OAAO,CAAC,UAAU,EAAE,sBAAsB,CAAC;QAC3C,OAAO,CAAC,UAAU,EAAE,4BAA4B,CAAC;KAClD,CAAC;IACF,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;IACpE,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC;IACxB,MAAM,IAAI,KAAK,CAAC,oDAAoD,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC/F,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,SAAiB;IACjD,OAAO,eAAe,CAAC,SAAS,CAAC,CAAC,aAAa,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { RouteDecision } from "./router.mjs";
|
|
2
|
+
import type { SkillBundle } from "./skill-bundle.mjs";
|
|
3
|
+
import type { ResponsibilityInterruption } from "./responsibility-scope.mjs";
|
|
4
|
+
import type { DshAgent, DshContentBlock, DshEvent, DshMessage, ModelRoute, PromptAssembly, RuntimeLogger, ToolSchema, UnknownRecord } from "./runtime-types.mjs";
|
|
5
|
+
interface RoutedRunResult {
|
|
6
|
+
stopReason: string;
|
|
7
|
+
output?: readonly DshContentBlock[];
|
|
8
|
+
}
|
|
9
|
+
interface RequestRouteAgent {
|
|
10
|
+
session?: {
|
|
11
|
+
events?: readonly DshEvent[];
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
interface RoutedRun {
|
|
15
|
+
result: Promise<RoutedRunResult>;
|
|
16
|
+
localAgent?: RequestRouteAgent;
|
|
17
|
+
dispose(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export interface SubagentsService {
|
|
20
|
+
start(provider: string, options: UnknownRecord): Promise<RoutedRun>;
|
|
21
|
+
}
|
|
22
|
+
export interface RoutedRoleOutcome extends UnknownRecord {
|
|
23
|
+
status: "completed" | "fallback";
|
|
24
|
+
stopReason: string;
|
|
25
|
+
output: readonly DshContentBlock[];
|
|
26
|
+
routeReceiptStatus?: "applied" | "mismatch" | "unverified";
|
|
27
|
+
routeReceiptError?: string;
|
|
28
|
+
actualRoute?: ModelRoute;
|
|
29
|
+
error?: string;
|
|
30
|
+
taskError?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface SkillSelection {
|
|
33
|
+
mode: string;
|
|
34
|
+
status: string;
|
|
35
|
+
reasonCode: string;
|
|
36
|
+
detail?: string;
|
|
37
|
+
bundle: SkillBundle;
|
|
38
|
+
rejections: readonly {
|
|
39
|
+
source: string;
|
|
40
|
+
reasonCode: string;
|
|
41
|
+
}[];
|
|
42
|
+
evolution?: {
|
|
43
|
+
status?: string;
|
|
44
|
+
generationId?: string;
|
|
45
|
+
baseDigest?: string;
|
|
46
|
+
upstreamDigest?: string;
|
|
47
|
+
rebaseRequired?: boolean;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export interface RoutingSnapshotState {
|
|
51
|
+
error?: string;
|
|
52
|
+
detail?: string;
|
|
53
|
+
snapshot?: {
|
|
54
|
+
roles: Readonly<Record<string, ModelRoute | undefined>>;
|
|
55
|
+
sources: Readonly<Record<string, string>>;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export declare const RUNTIME_NAME = "odai-dsh-runtime";
|
|
59
|
+
export declare function deepFreeze<T>(value: T): Readonly<T>;
|
|
60
|
+
export declare function pluginMessage(text: string, summary: string, extraBlocks?: readonly DshContentBlock[]): Readonly<DshMessage>;
|
|
61
|
+
export declare function renderOutputLimitInterruptionNotice(interruption: ResponsibilityInterruption): string;
|
|
62
|
+
export declare function loggerFor(ctx: {
|
|
63
|
+
logger?: (name: string) => RuntimeLogger;
|
|
64
|
+
}): RuntimeLogger;
|
|
65
|
+
export declare function outputText(blocks: unknown): string;
|
|
66
|
+
export declare function renderResearchTaskContract(taskText: string): string;
|
|
67
|
+
export declare function roleAgentOptions(roleRoute?: ModelRoute): UnknownRecord | undefined;
|
|
68
|
+
export declare function sameRequestModelRoute(left?: Partial<ModelRoute>, right?: Partial<ModelRoute>): boolean;
|
|
69
|
+
export declare function currentAgentStep(agent: DshAgent): number | undefined;
|
|
70
|
+
export declare function routeFromConfig(config: unknown): ModelRoute | undefined;
|
|
71
|
+
export declare function latestRequestRoute(localAgent: RequestRouteAgent | undefined): ModelRoute | undefined;
|
|
72
|
+
export declare function routeMismatchFor(expected: ModelRoute | undefined, actual: ModelRoute | undefined, subject: string): string | undefined;
|
|
73
|
+
export declare function routeMismatch(expected?: ModelRoute, actual?: ModelRoute): string | undefined;
|
|
74
|
+
export declare function runRoutedRole({ subagents, provider, decision, taskText, roleContract, agent, signal, roleRoute, }: {
|
|
75
|
+
subagents: SubagentsService;
|
|
76
|
+
provider: string;
|
|
77
|
+
decision: Pick<RouteDecision, "role">;
|
|
78
|
+
taskText: string;
|
|
79
|
+
roleContract: string;
|
|
80
|
+
agent: unknown;
|
|
81
|
+
signal: AbortSignal;
|
|
82
|
+
roleRoute?: ModelRoute;
|
|
83
|
+
}): Promise<Readonly<RoutedRoleOutcome>>;
|
|
84
|
+
export declare function canonicalPrompt(selection: SkillSelection): string;
|
|
85
|
+
export declare function renderEffectiveRoutingContext(snapshotState: RoutingSnapshotState): string;
|
|
86
|
+
export declare function latestRouteReceipt(events: readonly DshEvent[]): Readonly<UnknownRecord> | undefined;
|
|
87
|
+
export declare function isSubagentSession(agent: DshAgent): boolean;
|
|
88
|
+
export declare function routedRoleOf(agent: DshAgent): string | undefined;
|
|
89
|
+
export declare function reconcileAdaptiveToolSchemas(assembly: PromptAssembly, activeNames: readonly string[], executableSchemas?: readonly ToolSchema[]): PromptAssembly;
|
|
90
|
+
export {};
|
|
91
|
+
//# sourceMappingURL=runtime-support.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|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,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,WAAW,CAAC;IACpB,SAAS,CAAC,EAAE,UAAU,CAAC;CACxB,GAAG,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAyFvC;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,cAAc,GAAG,MAAM,CAmBjE;AAED,wBAAgB,6BAA6B,CAAC,aAAa,EAAE,oBAAoB,GAAG,MAAM,CAsBzF;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,SAAS,CA2DnG;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAI1D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAYhE;AAID,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,cAAc,EACxB,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,iBAAiB,GAAE,SAAS,UAAU,EAAO,GAC5C,cAAc,CAsBhB"}
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { renderDelegationPrompt } from "./router.mjs";
|
|
3
|
+
import { CONFIGURABLE_ROLES } from "./routing-config.mjs";
|
|
4
|
+
import { ODAI_CONTEXTUAL_TOOL_NAMES, ODAI_CORE_TOOL_NAMES } from "./context-activation.mjs";
|
|
5
|
+
import { ROUTED_ROLES } from "./runtime-config.mjs";
|
|
6
|
+
function isUnknownRecord(value) {
|
|
7
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
8
|
+
}
|
|
9
|
+
export const RUNTIME_NAME = "odai-dsh-runtime";
|
|
10
|
+
export function deepFreeze(value) {
|
|
11
|
+
if (value === null || typeof value !== "object" || Object.isFrozen(value))
|
|
12
|
+
return value;
|
|
13
|
+
for (const child of Object.values(value))
|
|
14
|
+
deepFreeze(child);
|
|
15
|
+
return Object.freeze(value);
|
|
16
|
+
}
|
|
17
|
+
export function pluginMessage(text, summary, extraBlocks = []) {
|
|
18
|
+
return deepFreeze({
|
|
19
|
+
id: randomUUID(),
|
|
20
|
+
role: "user",
|
|
21
|
+
content: [{ type: "text", text }, ...extraBlocks],
|
|
22
|
+
source: {
|
|
23
|
+
kind: "plugin",
|
|
24
|
+
plugin: RUNTIME_NAME,
|
|
25
|
+
form: "notice",
|
|
26
|
+
summary: summary.length <= 120 ? summary : `${summary.slice(0, 119)}…`,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export function renderOutputLimitInterruptionNotice(interruption) {
|
|
31
|
+
const route = interruption.effectiveRoute ?? interruption.requestedRoute;
|
|
32
|
+
return [
|
|
33
|
+
"Odai verified output-limit interruption",
|
|
34
|
+
`responsibility: ${interruption.responsibility}`,
|
|
35
|
+
`interrupted scope: ${interruption.scopeId}`,
|
|
36
|
+
`provider finish reason: ${interruption.reason}`,
|
|
37
|
+
...(route ? [`effective route: ${route.provider}/${route.model}`] : []),
|
|
38
|
+
...(interruption.effectiveMaxTokens === undefined ? [] : [`effective maxTokens: ${interruption.effectiveMaxTokens}`]),
|
|
39
|
+
...(interruption.outputTokens === undefined ? [] : [`observed outputTokens: ${interruption.outputTokens}`]),
|
|
40
|
+
"This proves the responsibility output was interrupted, not that its task completed. Explain the verified cause without guessing. Resume only after an explicit user continuation.",
|
|
41
|
+
].join("\n");
|
|
42
|
+
}
|
|
43
|
+
export function loggerFor(ctx) {
|
|
44
|
+
if (typeof ctx.logger !== "function")
|
|
45
|
+
return { info() { }, warn() { } };
|
|
46
|
+
return ctx.logger(RUNTIME_NAME);
|
|
47
|
+
}
|
|
48
|
+
export function outputText(blocks) {
|
|
49
|
+
if (!Array.isArray(blocks))
|
|
50
|
+
return "";
|
|
51
|
+
return blocks
|
|
52
|
+
.filter((block) => isUnknownRecord(block) && block.type === "text" && typeof block.text === "string")
|
|
53
|
+
.map((block) => block.text ?? "")
|
|
54
|
+
.join("\n")
|
|
55
|
+
.trim();
|
|
56
|
+
}
|
|
57
|
+
export function renderResearchTaskContract(taskText) {
|
|
58
|
+
return [
|
|
59
|
+
"Decision-blocking factual question: Determine whether the user's causal claim is supported and which existing repository facts govern the safety of the requested high-impact change.",
|
|
60
|
+
"Allowed source scope: the current project root only. Use repository-relative paths and read-only source tools; do not inspect parent, sibling, user, or unrelated directories.",
|
|
61
|
+
"Authority and freshness: label each current-checkout source by its actual role (for example runtime configuration, implementation, test, incident record, or documentation). Do not invent an authority hierarchy; report unresolved conflicts and missing freshness evidence as unknowns.",
|
|
62
|
+
"Stop condition: return the smallest packet with 2-6 source-backed facts from at least two files, or stop with the missing evidence boundary. Do not select a route or continue after additional reading cannot change this factual question.",
|
|
63
|
+
"For every fact, excerpt must exactly equal the complete cited source line after trimming leading and trailing whitespace.",
|
|
64
|
+
"",
|
|
65
|
+
"Original user request:",
|
|
66
|
+
taskText,
|
|
67
|
+
].join("\n");
|
|
68
|
+
}
|
|
69
|
+
export function roleAgentOptions(roleRoute) {
|
|
70
|
+
if (!roleRoute)
|
|
71
|
+
return undefined;
|
|
72
|
+
return {
|
|
73
|
+
provider: roleRoute.provider,
|
|
74
|
+
model: roleRoute.model,
|
|
75
|
+
...(roleRoute.maxTokens === undefined ? {} : { maxTokens: roleRoute.maxTokens }),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export function sameRequestModelRoute(left, right) {
|
|
79
|
+
return Boolean(left && right
|
|
80
|
+
&& left.provider === right.provider
|
|
81
|
+
&& left.model === right.model
|
|
82
|
+
&& left.reasoningEffort === right.reasoningEffort);
|
|
83
|
+
}
|
|
84
|
+
export function currentAgentStep(agent) {
|
|
85
|
+
const events = agent?.session?.events;
|
|
86
|
+
if (!Array.isArray(events))
|
|
87
|
+
return undefined;
|
|
88
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
89
|
+
if (events[index]?.type === "step/start" && Number.isSafeInteger(events[index].data?.step))
|
|
90
|
+
return events[index].data.step;
|
|
91
|
+
}
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
export function routeFromConfig(config) {
|
|
95
|
+
if (!isUnknownRecord(config) || typeof config.provider !== "string" || typeof config.model !== "string")
|
|
96
|
+
return undefined;
|
|
97
|
+
return Object.freeze({
|
|
98
|
+
provider: config.provider,
|
|
99
|
+
model: config.model,
|
|
100
|
+
...(typeof config.reasoningEffort === "string" ? { reasoningEffort: config.reasoningEffort } : {}),
|
|
101
|
+
...(typeof config.maxTokens === "number" ? { maxTokens: config.maxTokens } : {}),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
export function latestRequestRoute(localAgent) {
|
|
105
|
+
const events = localAgent?.session?.events;
|
|
106
|
+
if (!Array.isArray(events))
|
|
107
|
+
return undefined;
|
|
108
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
109
|
+
const event = events[index];
|
|
110
|
+
if (event?.type !== "request/header")
|
|
111
|
+
continue;
|
|
112
|
+
const header = isUnknownRecord(event.data.header) ? event.data.header : undefined;
|
|
113
|
+
return routeFromConfig(header?.config);
|
|
114
|
+
}
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
export function routeMismatchFor(expected, actual, subject) {
|
|
118
|
+
if (!expected)
|
|
119
|
+
return undefined;
|
|
120
|
+
if (!actual)
|
|
121
|
+
return `${subject} request/header did not expose an actual model route`;
|
|
122
|
+
for (const field of ["provider", "model", "reasoningEffort", "maxTokens"]) {
|
|
123
|
+
if (expected[field] !== undefined && expected[field] !== actual[field]) {
|
|
124
|
+
return `${subject} ${field} mismatch: expected ${expected[field]}, got ${actual[field] ?? "<absent>"}`;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
export function routeMismatch(expected, actual) {
|
|
130
|
+
return routeMismatchFor(expected, actual, "child");
|
|
131
|
+
}
|
|
132
|
+
export async function runRoutedRole({ subagents, provider, decision, taskText, roleContract, agent, signal, roleRoute, }) {
|
|
133
|
+
let run;
|
|
134
|
+
let outcome;
|
|
135
|
+
try {
|
|
136
|
+
run = await subagents.start(provider, {
|
|
137
|
+
label: `odai-${decision.role}`,
|
|
138
|
+
prompt: [{ type: "text", text: renderDelegationPrompt(decision, taskText, roleContract) }],
|
|
139
|
+
parent: agent,
|
|
140
|
+
signal,
|
|
141
|
+
maxDepth: 1,
|
|
142
|
+
...(roleRoute ? { agentOptions: roleAgentOptions(roleRoute) } : {}),
|
|
143
|
+
});
|
|
144
|
+
const result = await run.result;
|
|
145
|
+
const actualRoute = latestRequestRoute(run.localAgent);
|
|
146
|
+
const mismatch = routeMismatch(roleRoute, actualRoute);
|
|
147
|
+
const routeReceiptStatus = !actualRoute ? "unverified" : mismatch ? "mismatch" : "applied";
|
|
148
|
+
const routeEvidence = Object.freeze({
|
|
149
|
+
routeReceiptStatus,
|
|
150
|
+
...(mismatch ? { routeReceiptError: mismatch } : {}),
|
|
151
|
+
...(actualRoute ? { actualRoute } : {}),
|
|
152
|
+
});
|
|
153
|
+
if (result.stopReason !== "completed") {
|
|
154
|
+
outcome = Object.freeze({
|
|
155
|
+
status: "fallback",
|
|
156
|
+
stopReason: result.stopReason,
|
|
157
|
+
output: result.output ?? [],
|
|
158
|
+
...routeEvidence,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
else if (mismatch) {
|
|
162
|
+
outcome = Object.freeze({
|
|
163
|
+
status: "fallback",
|
|
164
|
+
stopReason: "route-unverified",
|
|
165
|
+
output: [],
|
|
166
|
+
error: mismatch,
|
|
167
|
+
...routeEvidence,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
else if (!outputText(result.output)) {
|
|
171
|
+
outcome = Object.freeze({
|
|
172
|
+
status: "fallback",
|
|
173
|
+
stopReason: "route-empty-output",
|
|
174
|
+
output: [],
|
|
175
|
+
error: "child completed without textual evidence",
|
|
176
|
+
taskError: "child completed without textual evidence",
|
|
177
|
+
...routeEvidence,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
outcome = Object.freeze({
|
|
182
|
+
status: "completed",
|
|
183
|
+
stopReason: result.stopReason,
|
|
184
|
+
output: result.output ?? [],
|
|
185
|
+
...routeEvidence,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
const taskError = error instanceof Error ? error.message : String(error);
|
|
191
|
+
outcome = Object.freeze({
|
|
192
|
+
status: "fallback",
|
|
193
|
+
stopReason: "infrastructure-error",
|
|
194
|
+
output: [],
|
|
195
|
+
routeReceiptStatus: "unverified",
|
|
196
|
+
error: taskError,
|
|
197
|
+
taskError,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
if (run) {
|
|
201
|
+
try {
|
|
202
|
+
await run.dispose();
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
const disposeError = error instanceof Error ? error.message : String(error);
|
|
206
|
+
const cleanupTaskError = outcome?.taskError
|
|
207
|
+
? `${outcome.taskError}; provider cleanup failed: ${disposeError}`
|
|
208
|
+
: `provider cleanup failed: ${disposeError}`;
|
|
209
|
+
return Object.freeze({
|
|
210
|
+
status: "fallback",
|
|
211
|
+
stopReason: "infrastructure-error",
|
|
212
|
+
output: [],
|
|
213
|
+
routeReceiptStatus: outcome?.routeReceiptStatus ?? "unverified",
|
|
214
|
+
...(outcome?.routeReceiptError ? { routeReceiptError: outcome.routeReceiptError } : {}),
|
|
215
|
+
...(outcome?.actualRoute ? { actualRoute: outcome.actualRoute } : {}),
|
|
216
|
+
error: outcome?.error
|
|
217
|
+
? `${outcome.error}; provider cleanup failed: ${disposeError}`
|
|
218
|
+
: cleanupTaskError,
|
|
219
|
+
taskError: cleanupTaskError,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return outcome;
|
|
224
|
+
}
|
|
225
|
+
export function canonicalPrompt(selection) {
|
|
226
|
+
const { bundle } = selection;
|
|
227
|
+
const fallback = selection.status === "fallback"
|
|
228
|
+
? `Selection fallback: ${selection.reasonCode}${selection.detail ? ` (${selection.detail})` : ""}.`
|
|
229
|
+
: undefined;
|
|
230
|
+
const evolution = selection.evolution?.status === "active"
|
|
231
|
+
? `User evolution: generation ${selection.evolution.generationId}; base digest ${selection.evolution.baseDigest}; current upstream digest ${selection.evolution.upstreamDigest}; rebase required: ${String(selection.evolution.rebaseRequired)}.`
|
|
232
|
+
: undefined;
|
|
233
|
+
return [
|
|
234
|
+
"## odai canonical governance",
|
|
235
|
+
`Canonical source: ${bundle.source} (${bundle.provider})`,
|
|
236
|
+
`Canonical skill: ${bundle.manifest.skillVersion}; runtime contract: ${bundle.manifest.runtimeContract}; digest: ${bundle.digest}.`,
|
|
237
|
+
...(evolution ? [evolution] : []),
|
|
238
|
+
...(fallback ? [fallback] : []),
|
|
239
|
+
"Apply this governance to every request. Keep the controller as the final delivery owner; use another role only for a real independent gap with observable net benefit.",
|
|
240
|
+
"Odai governance is already loaded by this runtime; do not call the skill tool or read SKILL.md to load odai again.",
|
|
241
|
+
"",
|
|
242
|
+
bundle.skillText,
|
|
243
|
+
].join("\n");
|
|
244
|
+
}
|
|
245
|
+
export function renderEffectiveRoutingContext(snapshotState) {
|
|
246
|
+
if (snapshotState.error || !snapshotState.snapshot) {
|
|
247
|
+
return [
|
|
248
|
+
"Current effective responsibility mappings: unavailable because the saved routing configuration is invalid.",
|
|
249
|
+
`Configuration error: ${snapshotState.detail}`,
|
|
250
|
+
"Use odai_routing_config only when the user asks to inspect or repair it; do not infer any route.",
|
|
251
|
+
].join("\n");
|
|
252
|
+
}
|
|
253
|
+
const snapshot = snapshotState.snapshot;
|
|
254
|
+
const mappings = CONFIGURABLE_ROLES.flatMap((role) => {
|
|
255
|
+
const route = snapshot.roles[role];
|
|
256
|
+
if (!route)
|
|
257
|
+
return [];
|
|
258
|
+
const options = [
|
|
259
|
+
...(route.reasoningEffort ? [`reasoningEffort=${route.reasoningEffort}`] : []),
|
|
260
|
+
...(route.maxTokens ? [`maxTokens=${route.maxTokens}`] : []),
|
|
261
|
+
];
|
|
262
|
+
return [`${role}=${route.provider}/${route.model}${options.length > 0 ? ` (${options.join(", ")})` : ""} [${snapshot.sources[role]}]`];
|
|
263
|
+
});
|
|
264
|
+
return [
|
|
265
|
+
`Current effective responsibility mappings (runtime-owned; supersedes conversation summaries): ${mappings.join("; ") || "none"}.`,
|
|
266
|
+
"These are route targets, not evidence that a responsibility ran. Only an actual route receipt proves use; a generic subagent does not.",
|
|
267
|
+
].join("\n");
|
|
268
|
+
}
|
|
269
|
+
export function latestRouteReceipt(events) {
|
|
270
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
271
|
+
const event = events[index];
|
|
272
|
+
const data = event?.data;
|
|
273
|
+
if (!data?.routeSource || !Number.isSafeInteger(data.turn) || !Number.isSafeInteger(data.step))
|
|
274
|
+
continue;
|
|
275
|
+
if (event.type === "odai/route-fallback") {
|
|
276
|
+
return Object.freeze({
|
|
277
|
+
turn: data.turn,
|
|
278
|
+
step: data.step,
|
|
279
|
+
responsibility: data.responsibility,
|
|
280
|
+
...(data.responsibilityScopeId ? { responsibilityScopeId: data.responsibilityScopeId } : {}),
|
|
281
|
+
...(data.routeCardId ? { routeCardId: data.routeCardId } : {}),
|
|
282
|
+
status: "fallback",
|
|
283
|
+
taskStatus: "fallback",
|
|
284
|
+
routeMode: data.routeMode,
|
|
285
|
+
routeSource: data.routeSource,
|
|
286
|
+
fallbackUsed: true,
|
|
287
|
+
requestedRoute: data.requestedRoute,
|
|
288
|
+
...(data.fallbackRoute ? { actualRoute: data.fallbackRoute } : {}),
|
|
289
|
+
...(data.error ? { error: data.error } : {}),
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
if (event.type === "odai/route-applied") {
|
|
293
|
+
return Object.freeze({
|
|
294
|
+
turn: data.turn,
|
|
295
|
+
step: data.step,
|
|
296
|
+
responsibility: data.responsibility,
|
|
297
|
+
...(data.responsibilityScopeId ? { responsibilityScopeId: data.responsibilityScopeId } : {}),
|
|
298
|
+
...(data.routeCardId ? { routeCardId: data.routeCardId } : {}),
|
|
299
|
+
status: data.status,
|
|
300
|
+
routeMode: data.routeMode,
|
|
301
|
+
routeSource: data.routeSource,
|
|
302
|
+
fallbackUsed: data.fallbackUsed,
|
|
303
|
+
requestedRoute: data.requestedRoute,
|
|
304
|
+
...(data.actualRoute ? { actualRoute: data.actualRoute } : {}),
|
|
305
|
+
...(data.stopReason ? { stopReason: data.stopReason } : {}),
|
|
306
|
+
...(data.error ? { error: data.error } : {}),
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
if (["odai/route-result", "odai/research-result"].includes(event.type)) {
|
|
310
|
+
const routeReceiptStatus = data.routeReceiptStatus ?? "unverified";
|
|
311
|
+
return Object.freeze({
|
|
312
|
+
turn: data.turn,
|
|
313
|
+
step: data.step,
|
|
314
|
+
responsibility: data.role,
|
|
315
|
+
status: routeReceiptStatus,
|
|
316
|
+
taskStatus: data.status,
|
|
317
|
+
routeMode: "child",
|
|
318
|
+
routeSource: data.routeSource,
|
|
319
|
+
fallbackUsed: routeReceiptStatus !== "applied",
|
|
320
|
+
requestedRoute: data.requestedRoute,
|
|
321
|
+
...(data.actualRoute ? { actualRoute: data.actualRoute } : {}),
|
|
322
|
+
...(data.routeReceiptError ? { error: data.routeReceiptError } : {}),
|
|
323
|
+
...(data.stopReason ? { taskStopReason: data.stopReason } : {}),
|
|
324
|
+
...(data.error ? { taskError: data.error } : {}),
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return undefined;
|
|
329
|
+
}
|
|
330
|
+
export function isSubagentSession(agent) {
|
|
331
|
+
const header = agent.session?.header;
|
|
332
|
+
return header?.origin === "subagent"
|
|
333
|
+
|| (Number.isSafeInteger(header?.delegationDepth) && (header.delegationDepth ?? 0) > 0);
|
|
334
|
+
}
|
|
335
|
+
export function routedRoleOf(agent) {
|
|
336
|
+
const events = agent?.session?.events;
|
|
337
|
+
if (!Array.isArray(events))
|
|
338
|
+
return undefined;
|
|
339
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
340
|
+
const event = events[index];
|
|
341
|
+
if (event?.type !== "subagent/descriptor")
|
|
342
|
+
continue;
|
|
343
|
+
const label = event.data?.label;
|
|
344
|
+
if (typeof label !== "string")
|
|
345
|
+
return undefined;
|
|
346
|
+
const match = /^odai-(researcher|planner|executor|reviewer|frontend)(?:$|[\s:])/u.exec(label.trim());
|
|
347
|
+
return match && ROUTED_ROLES.includes(match[1]) ? match[1] : undefined;
|
|
348
|
+
}
|
|
349
|
+
return undefined;
|
|
350
|
+
}
|
|
351
|
+
const ODAI_ADAPTIVE_TOOL_NAMES = new Set([...ODAI_CONTEXTUAL_TOOL_NAMES, ...ODAI_CORE_TOOL_NAMES]);
|
|
352
|
+
export function reconcileAdaptiveToolSchemas(assembly, activeNames, executableSchemas = []) {
|
|
353
|
+
if (!assembly || !Array.isArray(assembly.tools))
|
|
354
|
+
return assembly;
|
|
355
|
+
const active = new Set(activeNames);
|
|
356
|
+
const executableByName = new Map((Array.isArray(executableSchemas) ? executableSchemas : [])
|
|
357
|
+
.filter((tool) => active.has(tool?.name))
|
|
358
|
+
.map((tool) => [tool.name, tool]));
|
|
359
|
+
const tools = assembly.tools.filter((tool) => !ODAI_ADAPTIVE_TOOL_NAMES.has(tool?.name)
|
|
360
|
+
|| (active.has(tool.name) && executableByName.has(tool.name)));
|
|
361
|
+
const present = new Set(tools.map((tool) => tool?.name));
|
|
362
|
+
const missing = activeNames
|
|
363
|
+
.filter((name) => !present.has(name) && executableByName.has(name))
|
|
364
|
+
.map((name) => executableByName.get(name));
|
|
365
|
+
if (missing.length > 0) {
|
|
366
|
+
const lastAdaptiveIndex = tools.reduce((last, tool, index) => ODAI_ADAPTIVE_TOOL_NAMES.has(tool?.name) ? index : last, -1);
|
|
367
|
+
tools.splice(lastAdaptiveIndex < 0 ? tools.length : lastAdaptiveIndex + 1, 0, ...missing);
|
|
368
|
+
}
|
|
369
|
+
return tools.length === assembly.tools.length && missing.length === 0 ? assembly : { ...assembly, tools };
|
|
370
|
+
}
|
|
371
|
+
//# sourceMappingURL=runtime-support.mjs.map
|