open-multi-agent-kit 0.98.5 → 0.99.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/CHANGELOG.md +24 -0
- package/README.md +3 -2
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +1 -0
- package/dist/cli/help.js.map +1 -1
- package/dist/commands/verified-run-cli.d.ts.map +1 -1
- package/dist/commands/verified-run-cli.js +2 -2
- package/dist/commands/verified-run-cli.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +19 -2
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/devin-harness-dispatch.d.ts +12 -0
- package/dist/core/devin-harness-dispatch.d.ts.map +1 -0
- package/dist/core/devin-harness-dispatch.js +12 -0
- package/dist/core/devin-harness-dispatch.js.map +1 -0
- package/dist/core/devin-harness.d.ts +53 -0
- package/dist/core/devin-harness.d.ts.map +1 -0
- package/dist/core/devin-harness.js +112 -0
- package/dist/core/devin-harness.js.map +1 -0
- package/dist/core/domain-dispatch.d.ts +4 -1
- package/dist/core/domain-dispatch.d.ts.map +1 -1
- package/dist/core/domain-dispatch.js +5 -0
- package/dist/core/domain-dispatch.js.map +1 -1
- package/dist/core/domain-loadouts-provider-harness.d.ts +12 -0
- package/dist/core/domain-loadouts-provider-harness.d.ts.map +1 -0
- package/dist/core/domain-loadouts-provider-harness.js +122 -0
- package/dist/core/domain-loadouts-provider-harness.js.map +1 -0
- package/dist/core/domain-loadouts.d.ts +2 -33
- package/dist/core/domain-loadouts.d.ts.map +1 -1
- package/dist/core/domain-loadouts.js +3 -56
- package/dist/core/domain-loadouts.js.map +1 -1
- package/dist/core/domain-profile.d.ts +40 -0
- package/dist/core/domain-profile.d.ts.map +1 -0
- package/dist/core/domain-profile.js +7 -0
- package/dist/core/domain-profile.js.map +1 -0
- package/dist/core/grok-harness-dispatch.d.ts +6 -20
- package/dist/core/grok-harness-dispatch.d.ts.map +1 -1
- package/dist/core/grok-harness-dispatch.js +6 -55
- package/dist/core/grok-harness-dispatch.js.map +1 -1
- package/dist/core/grok-harness.d.ts +7 -9
- package/dist/core/grok-harness.d.ts.map +1 -1
- package/dist/core/grok-harness.js +9 -23
- package/dist/core/grok-harness.js.map +1 -1
- package/dist/core/harness-skills.d.ts +20 -0
- package/dist/core/harness-skills.d.ts.map +1 -0
- package/dist/core/harness-skills.js +36 -0
- package/dist/core/harness-skills.js.map +1 -0
- package/dist/core/loadout-runtime-state.d.ts +25 -0
- package/dist/core/loadout-runtime-state.d.ts.map +1 -0
- package/dist/core/loadout-runtime-state.js +39 -0
- package/dist/core/loadout-runtime-state.js.map +1 -0
- package/dist/core/loadout-runtime.d.ts +2 -12
- package/dist/core/loadout-runtime.d.ts.map +1 -1
- package/dist/core/loadout-runtime.js +6 -13
- package/dist/core/loadout-runtime.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -41
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +2 -49
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/provider-default-models.d.ts +42 -0
- package/dist/core/provider-default-models.d.ts.map +1 -0
- package/dist/core/provider-default-models.js +50 -0
- package/dist/core/provider-default-models.js.map +1 -0
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/provider-display-names.js +1 -0
- package/dist/core/provider-display-names.js.map +1 -1
- package/dist/core/provider-harness-dispatch.d.ts +63 -0
- package/dist/core/provider-harness-dispatch.d.ts.map +1 -0
- package/dist/core/provider-harness-dispatch.js +60 -0
- package/dist/core/provider-harness-dispatch.js.map +1 -0
- package/dist/core/provider-usage-devin.d.ts +16 -0
- package/dist/core/provider-usage-devin.d.ts.map +1 -0
- package/dist/core/provider-usage-devin.js +61 -0
- package/dist/core/provider-usage-devin.js.map +1 -0
- package/dist/core/provider-usage-text.d.ts +5 -0
- package/dist/core/provider-usage-text.d.ts.map +1 -0
- package/dist/core/provider-usage-text.js +15 -0
- package/dist/core/provider-usage-text.js.map +1 -0
- package/dist/core/provider-usage-types.d.ts +2 -1
- package/dist/core/provider-usage-types.d.ts.map +1 -1
- package/dist/core/provider-usage-types.js.map +1 -1
- package/dist/core/provider-usage.d.ts +1 -2
- package/dist/core/provider-usage.d.ts.map +1 -1
- package/dist/core/provider-usage.js +12 -7
- package/dist/core/provider-usage.js.map +1 -1
- package/dist/core/run-execution-api.d.ts +1 -1
- package/dist/core/run-execution-api.d.ts.map +1 -1
- package/dist/core/run-execution-api.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +23 -18
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/verified-run/dag-phase.d.ts +1 -1
- package/dist/core/verified-run/dag-phase.d.ts.map +1 -1
- package/dist/core/verified-run/dag-phase.js +46 -8
- package/dist/core/verified-run/dag-phase.js.map +1 -1
- package/dist/core/verified-run/dag-projection.d.ts.map +1 -1
- package/dist/core/verified-run/dag-projection.js +25 -12
- package/dist/core/verified-run/dag-projection.js.map +1 -1
- package/dist/core/verified-run/dag-types.d.ts +11 -0
- package/dist/core/verified-run/dag-types.d.ts.map +1 -1
- package/dist/core/verified-run/dag-types.js.map +1 -1
- package/dist/core/verified-run/event-parser.d.ts.map +1 -1
- package/dist/core/verified-run/event-parser.js +1 -0
- package/dist/core/verified-run/event-parser.js.map +1 -1
- package/dist/core/verified-run/owned-execution.d.ts +1 -0
- package/dist/core/verified-run/owned-execution.d.ts.map +1 -1
- package/dist/core/verified-run/owned-execution.js +7 -1
- package/dist/core/verified-run/owned-execution.js.map +1 -1
- package/dist/core/verified-run/process-projection.d.ts +13 -0
- package/dist/core/verified-run/process-projection.d.ts.map +1 -0
- package/dist/core/verified-run/process-projection.js +82 -0
- package/dist/core/verified-run/process-projection.js.map +1 -0
- package/dist/core/verified-run/projection.d.ts.map +1 -1
- package/dist/core/verified-run/projection.js +11 -55
- package/dist/core/verified-run/projection.js.map +1 -1
- package/dist/core/verified-run/run-types.d.ts +1 -0
- package/dist/core/verified-run/run-types.d.ts.map +1 -1
- package/dist/core/verified-run/run-types.js.map +1 -1
- package/dist/core/verified-run/task-execution.d.ts +9 -0
- package/dist/core/verified-run/task-execution.d.ts.map +1 -0
- package/dist/core/verified-run/task-execution.js +29 -0
- package/dist/core/verified-run/task-execution.js.map +1 -0
- package/dist/core/verified-run/writer-projection.d.ts.map +1 -1
- package/dist/core/verified-run/writer-projection.js +6 -5
- package/dist/core/verified-run/writer-projection.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +2 -5
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/resource-description.d.ts +3 -0
- package/dist/modes/interactive/resource-description.d.ts.map +1 -0
- package/dist/modes/interactive/resource-description.js +15 -0
- package/dist/modes/interactive/resource-description.js.map +1 -0
- package/docs/devin-harness.md +121 -0
- package/docs/docs.json +4 -0
- package/docs/environment-variables.md +2 -1
- package/docs/index.md +1 -0
- package/docs/loadout-domains/README.md +2 -1
- package/docs/loadout-domains/devin-harness.md +72 -0
- package/docs/metrics.md +57 -16
- package/docs/providers.md +76 -0
- package/docs/release-audit-0.98.5.md +17 -0
- package/docs/release-audit-0.99.0.md +68 -0
- package/docs/run-protocol.md +4 -3
- package/docs/runtime-algorithms.md +4 -1
- package/docs/sdk.md +9 -5
- package/docs/settings.md +1 -1
- package/docs/startup-resource-labels-testing.md +47 -0
- package/docs/tb21-audit.md +18 -4
- package/docs/usage.md +5 -0
- package/docs/verified-run-remaining-design.md +881 -0
- package/docs/verified-run-testing.md +91 -0
- package/docs/verified-run.md +30 -9
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +18 -18
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grok-harness-dispatch.d.ts","sourceRoot":"","sources":["../../src/core/grok-harness-dispatch.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"grok-harness-dispatch.d.ts","sourceRoot":"","sources":["../../src/core/grok-harness-dispatch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACvF,OAAO,EACN,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EAElC,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,MAAM,MAAM,wBAAwB,GAAG,4BAA4B,CAAC,qBAAqB,EAAE,cAAc,CAAC,CAAC;AAC3G,MAAM,MAAM,yBAAyB,GAAG,6BAA6B,CAAC,mBAAmB,CAAC,CAAC;AAE3F,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,wBAAwB,GAAG,yBAAyB,CAEjG","sourcesContent":["/**\n * Apply the `grok-harness` domain loadout when the active provider is Grok OAuth.\n * Does not require `OMK_DOMAIN_ROUTING=1`. Convenience wrapper over\n * `tryProviderHarnessDispatch()` bound to the real loadout runtime.\n */\n\nimport { LOADOUT_HARNESS_RUNTIME } from \"./domain-dispatch.ts\";\nimport { GROK_HARNESS_SPEC } from \"./grok-harness.ts\";\nimport type { LoadoutRuntimeSession, LoadoutRuntimeState } from \"./loadout-runtime.ts\";\nimport {\n\ttype ProviderHarnessDispatchInput,\n\ttype ProviderHarnessDispatchResult,\n\ttryProviderHarnessDispatch,\n} from \"./provider-harness-dispatch.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\n\nexport type GrokHarnessDispatchInput = ProviderHarnessDispatchInput<LoadoutRuntimeSession, ResourceLoader>;\nexport type GrokHarnessDispatchResult = ProviderHarnessDispatchResult<LoadoutRuntimeState>;\n\nexport function tryGrokHarnessDispatch(input: GrokHarnessDispatchInput): GrokHarnessDispatchResult {\n\treturn tryProviderHarnessDispatch(GROK_HARNESS_SPEC, LOADOUT_HARNESS_RUNTIME, input);\n}\n"]}
|
|
@@ -1,61 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Apply the `grok-harness` domain loadout when the active provider is Grok OAuth.
|
|
3
|
-
* Does not require `OMK_DOMAIN_ROUTING=1`.
|
|
3
|
+
* Does not require `OMK_DOMAIN_ROUTING=1`. Convenience wrapper over
|
|
4
|
+
* `tryProviderHarnessDispatch()` bound to the real loadout runtime.
|
|
4
5
|
*/
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { createLoadoutPolicyFromRuntimeState } from "./loadout-policy-bridge.js";
|
|
9
|
-
import { applyLoadoutToRuntime } from "./loadout-runtime.js";
|
|
10
|
-
import { uniqueSorted } from "./loadout-safety.js";
|
|
6
|
+
import { LOADOUT_HARNESS_RUNTIME } from "./domain-dispatch.js";
|
|
7
|
+
import { GROK_HARNESS_SPEC } from "./grok-harness.js";
|
|
8
|
+
import { tryProviderHarnessDispatch, } from "./provider-harness-dispatch.js";
|
|
11
9
|
export function tryGrokHarnessDispatch(input) {
|
|
12
|
-
|
|
13
|
-
if (!grokHarnessAutoApplyEnabled(env) || !isGrokOAuthProvider(input.provider)) {
|
|
14
|
-
return { loadoutAccessPolicy: undefined, warnings: [], runtimeState: undefined };
|
|
15
|
-
}
|
|
16
|
-
const agentDir = input.agentDir ?? getAgentDir();
|
|
17
|
-
try {
|
|
18
|
-
const profile = composeGrokHarnessProfile(input);
|
|
19
|
-
const state = applyLoadoutToRuntime(input.session, input.resourceLoader, input.cwd, agentDir, {
|
|
20
|
-
profile,
|
|
21
|
-
role: "coder",
|
|
22
|
-
});
|
|
23
|
-
if (state.blockers.length > 0) {
|
|
24
|
-
return {
|
|
25
|
-
loadoutAccessPolicy: undefined,
|
|
26
|
-
warnings: state.blockers,
|
|
27
|
-
runtimeState: state,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
const policy = createLoadoutPolicyFromRuntimeState(state, {
|
|
31
|
-
cwd: input.cwd,
|
|
32
|
-
commands: profile.commands,
|
|
33
|
-
});
|
|
34
|
-
return {
|
|
35
|
-
loadoutAccessPolicy: policy,
|
|
36
|
-
warnings: uniqueSorted([
|
|
37
|
-
...state.warnings,
|
|
38
|
-
...(input.task?.trim() && state.activeSkills.length === 0 ? ["no grok-harness skill signals"] : []),
|
|
39
|
-
]),
|
|
40
|
-
runtimeState: state,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
45
|
-
return { loadoutAccessPolicy: undefined, warnings: [message], runtimeState: undefined };
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function composeGrokHarnessProfile(input) {
|
|
49
|
-
const profile = composeLoadout("coder", GROK_HARNESS_DOMAIN_ID);
|
|
50
|
-
const task = input.task?.trim();
|
|
51
|
-
if (!task) {
|
|
52
|
-
return { ...profile, skills: { allow: [{ kind: "skill", names: [] }] } };
|
|
53
|
-
}
|
|
54
|
-
const inventory = input.resourceLoader.getSkills().skills;
|
|
55
|
-
const selected = selectGrokHarnessSkills(task, inventory, { paths: input.paths });
|
|
56
|
-
return {
|
|
57
|
-
...profile,
|
|
58
|
-
skills: { allow: [{ kind: "skill", names: [...selected] }] },
|
|
59
|
-
};
|
|
10
|
+
return tryProviderHarnessDispatch(GROK_HARNESS_SPEC, LOADOUT_HARNESS_RUNTIME, input);
|
|
60
11
|
}
|
|
61
12
|
//# sourceMappingURL=grok-harness-dispatch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grok-harness-dispatch.js","sourceRoot":"","sources":["../../src/core/grok-harness-dispatch.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"grok-harness-dispatch.js","sourceRoot":"","sources":["../../src/core/grok-harness-dispatch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAGN,0BAA0B,GAC1B,MAAM,gCAAgC,CAAC;AAMxC,MAAM,UAAU,sBAAsB,CAAC,KAA+B,EAA6B;IAClG,OAAO,0BAA0B,CAAC,iBAAiB,EAAE,uBAAuB,EAAE,KAAK,CAAC,CAAC;AAAA,CACrF","sourcesContent":["/**\n * Apply the `grok-harness` domain loadout when the active provider is Grok OAuth.\n * Does not require `OMK_DOMAIN_ROUTING=1`. Convenience wrapper over\n * `tryProviderHarnessDispatch()` bound to the real loadout runtime.\n */\n\nimport { LOADOUT_HARNESS_RUNTIME } from \"./domain-dispatch.ts\";\nimport { GROK_HARNESS_SPEC } from \"./grok-harness.ts\";\nimport type { LoadoutRuntimeSession, LoadoutRuntimeState } from \"./loadout-runtime.ts\";\nimport {\n\ttype ProviderHarnessDispatchInput,\n\ttype ProviderHarnessDispatchResult,\n\ttryProviderHarnessDispatch,\n} from \"./provider-harness-dispatch.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\n\nexport type GrokHarnessDispatchInput = ProviderHarnessDispatchInput<LoadoutRuntimeSession, ResourceLoader>;\nexport type GrokHarnessDispatchResult = ProviderHarnessDispatchResult<LoadoutRuntimeState>;\n\nexport function tryGrokHarnessDispatch(input: GrokHarnessDispatchInput): GrokHarnessDispatchResult {\n\treturn tryProviderHarnessDispatch(GROK_HARNESS_SPEC, LOADOUT_HARNESS_RUNTIME, input);\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type HarnessSkillCandidate, type HarnessSkillSelectionOptions } from "./harness-skills.ts";
|
|
2
|
+
import type { ProviderHarnessSpec } from "./provider-harness-dispatch.ts";
|
|
2
3
|
/** Domain loadout id applied automatically when Grok OAuth provider is active. */
|
|
3
4
|
export declare const GROK_HARNESS_DOMAIN_ID = "grok-harness";
|
|
4
5
|
export declare const GROK_IMAGINE_MODEL_PREFIX = "grok-imagine-";
|
|
@@ -8,21 +9,18 @@ export declare function isGrokImagineModelId(id: string): boolean;
|
|
|
8
9
|
export declare function classifyGrokModelRoute(modelId: string): GrokModelRoute;
|
|
9
10
|
export declare function assertTextChatModelForCompletion(modelId: string, provider?: string): void;
|
|
10
11
|
export declare function recommendedSkillTierForIntent(intent: GrokHarnessIntent): readonly string[];
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
export interface GrokHarnessSkillSelectionOptions {
|
|
15
|
-
readonly paths?: readonly string[];
|
|
16
|
-
readonly contextPressure?: boolean;
|
|
17
|
-
}
|
|
12
|
+
export type GrokHarnessSkillCandidate = HarnessSkillCandidate;
|
|
13
|
+
export type GrokHarnessSkillSelectionOptions = HarnessSkillSelectionOptions;
|
|
18
14
|
/**
|
|
19
15
|
* Smallest grok-harness skill grant from the live inventory. The domain
|
|
20
16
|
* profile owns the allowlist; explicit-only skills are excluded. `headroom`
|
|
21
17
|
* requires lexical or measured pressure, and the result never exceeds
|
|
22
|
-
*
|
|
18
|
+
* `MAX_SELECTED_SKILLS` names.
|
|
23
19
|
*/
|
|
24
20
|
export declare function selectGrokHarnessSkills(task: string, inventory: readonly GrokHarnessSkillCandidate[], options?: GrokHarnessSkillSelectionOptions): readonly string[];
|
|
25
21
|
export declare function isGrokOAuthProvider(provider: string | undefined): boolean;
|
|
22
|
+
/** Provider-harness spec consumed by `tryProviderHarnessDispatch()`. */
|
|
23
|
+
export declare const GROK_HARNESS_SPEC: ProviderHarnessSpec;
|
|
26
24
|
/**
|
|
27
25
|
* When true (default), selecting native `xai` applies the `grok-harness` domain loadout
|
|
28
26
|
* (skills/MCP/hooks/tool gate). Set `OMK_GROK_HARNESS=0` to disable.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grok-harness.d.ts","sourceRoot":"","sources":["../../src/core/grok-harness.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"grok-harness.d.ts","sourceRoot":"","sources":["../../src/core/grok-harness.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,4BAA4B,EAEjC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAE1E,kFAAkF;AAClF,eAAO,MAAM,sBAAsB,iBAAiB,CAAC;AAIrD,eAAO,MAAM,yBAAyB,kBAAkB,CAAC;AAEzD,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,mBAAmB,CAAC;AAC/D,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAwB9E,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAExD;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,CAKtE;AAED,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAIzF;AAED,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,iBAAiB,GAAG,SAAS,MAAM,EAAE,CAE1F;AAED,MAAM,MAAM,yBAAyB,GAAG,qBAAqB,CAAC;AAC9D,MAAM,MAAM,gCAAgC,GAAG,4BAA4B,CAAC;AAM5E;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACtC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,SAAS,yBAAyB,EAAE,EAC/C,OAAO,GAAE,gCAAqC,GAC5C,SAAS,MAAM,EAAE,CAEnB;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAEzE;AAED,wEAAwE;AACxE,eAAO,MAAM,iBAAiB,EAAE,mBAI/B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,2BAA2B,CAC1C,GAAG,GAAE,MAAM,CAAC,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAe,GACjF,OAAO,CAMT","sourcesContent":["import { getDomainProfile } from \"./domain-loadouts.ts\";\nimport { GROK_OAUTH_PROVIDER } from \"./grok-playbook.ts\";\nimport {\n\ttype HarnessSkillCandidate,\n\ttype HarnessSkillSelectionOptions,\n\tselectHarnessSkills,\n} from \"./harness-skills.ts\";\nimport { capabilityGateNames } from \"./loadout-safety.ts\";\nimport type { ProviderHarnessSpec } from \"./provider-harness-dispatch.ts\";\n\n/** Domain loadout id applied automatically when Grok OAuth provider is active. */\nexport const GROK_HARNESS_DOMAIN_ID = \"grok-harness\";\n\nconst GROK_HARNESS_AUTO_APPLY_ENV = \"OMK_GROK_HARNESS\";\n\nexport const GROK_IMAGINE_MODEL_PREFIX = \"grok-imagine-\";\n\nexport type GrokModelRoute = \"text-chat\" | \"imagine-tool-only\";\nexport type GrokHarnessIntent = \"code\" | \"debug\" | \"plan\" | \"image\" | \"media\";\n\nconst SKILLS_BY_INTENT = {\n\tcode: [\"packages\", \"programming\"],\n\tdebug: [\"packages\", \"debugging\", \"programming\"],\n\tplan: [\"packages\", \"adaptorch-route\"],\n\timage: [\"image-prompt\"],\n\tmedia: [\"image-prompt\", \"adaptorch-route\"],\n} as const satisfies Record<GrokHarnessIntent, readonly string[]>;\n\nclass GrokImagineModelCompletionError extends Error {\n\treadonly name = \"GrokImagineModelCompletionError\";\n\treadonly modelId: string;\n\treadonly provider: string;\n\n\tconstructor(modelId: string, provider: string) {\n\t\tsuper(\n\t\t\t`Grok Imagine model \"${modelId}\" is tool-only on ${provider}; select a text-chat Grok model for completions.`,\n\t\t);\n\t\tthis.modelId = modelId;\n\t\tthis.provider = provider;\n\t}\n}\n\nexport function isGrokImagineModelId(id: string): boolean {\n\treturn id.startsWith(GROK_IMAGINE_MODEL_PREFIX);\n}\n\nexport function classifyGrokModelRoute(modelId: string): GrokModelRoute {\n\tif (isGrokImagineModelId(modelId)) {\n\t\treturn \"imagine-tool-only\";\n\t}\n\treturn \"text-chat\";\n}\n\nexport function assertTextChatModelForCompletion(modelId: string, provider?: string): void {\n\tif (provider === GROK_OAUTH_PROVIDER && isGrokImagineModelId(modelId)) {\n\t\tthrow new GrokImagineModelCompletionError(modelId, provider);\n\t}\n}\n\nexport function recommendedSkillTierForIntent(intent: GrokHarnessIntent): readonly string[] {\n\treturn SKILLS_BY_INTENT[intent];\n}\n\nexport type GrokHarnessSkillCandidate = HarnessSkillCandidate;\nexport type GrokHarnessSkillSelectionOptions = HarnessSkillSelectionOptions;\n\nconst GROK_HARNESS_ALLOWED_SKILLS: ReadonlySet<string> = new Set(\n\tcapabilityGateNames(getDomainProfile(GROK_HARNESS_DOMAIN_ID).skills),\n);\n\n/**\n * Smallest grok-harness skill grant from the live inventory. The domain\n * profile owns the allowlist; explicit-only skills are excluded. `headroom`\n * requires lexical or measured pressure, and the result never exceeds\n * `MAX_SELECTED_SKILLS` names.\n */\nexport function selectGrokHarnessSkills(\n\ttask: string,\n\tinventory: readonly GrokHarnessSkillCandidate[],\n\toptions: GrokHarnessSkillSelectionOptions = {},\n): readonly string[] {\n\treturn selectHarnessSkills(GROK_HARNESS_ALLOWED_SKILLS, task, inventory, options);\n}\n\nexport function isGrokOAuthProvider(provider: string | undefined): boolean {\n\treturn provider === GROK_OAUTH_PROVIDER;\n}\n\n/** Provider-harness spec consumed by `tryProviderHarnessDispatch()`. */\nexport const GROK_HARNESS_SPEC: ProviderHarnessSpec = {\n\tdomainId: GROK_HARNESS_DOMAIN_ID,\n\tapplies: (provider, env) => grokHarnessAutoApplyEnabled(env) && isGrokOAuthProvider(provider),\n\tselectSkills: (task, inventory, options) => selectGrokHarnessSkills(task, inventory, { paths: options.paths }),\n};\n\n/**\n * When true (default), selecting native `xai` applies the `grok-harness` domain loadout\n * (skills/MCP/hooks/tool gate). Set `OMK_GROK_HARNESS=0` to disable.\n */\nexport function grokHarnessAutoApplyEnabled(\n\tenv: NodeJS.ProcessEnv | Readonly<Record<string, string | undefined>> = process.env,\n): boolean {\n\tconst raw = env[GROK_HARNESS_AUTO_APPLY_ENV]?.trim().toLowerCase();\n\tif (raw === \"0\" || raw === \"false\" || raw === \"off\" || raw === \"no\") {\n\t\treturn false;\n\t}\n\treturn true;\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getDomainProfile } from "./domain-loadouts.js";
|
|
2
2
|
import { GROK_OAUTH_PROVIDER } from "./grok-playbook.js";
|
|
3
|
+
import { selectHarnessSkills, } from "./harness-skills.js";
|
|
3
4
|
import { capabilityGateNames } from "./loadout-safety.js";
|
|
4
|
-
import { MAX_SELECTED_SKILLS, selectSkills } from "./skill-selector.js";
|
|
5
5
|
/** Domain loadout id applied automatically when Grok OAuth provider is active. */
|
|
6
6
|
export const GROK_HARNESS_DOMAIN_ID = "grok-harness";
|
|
7
7
|
const GROK_HARNESS_AUTO_APPLY_ENV = "OMK_GROK_HARNESS";
|
|
@@ -41,38 +41,24 @@ export function recommendedSkillTierForIntent(intent) {
|
|
|
41
41
|
return SKILLS_BY_INTENT[intent];
|
|
42
42
|
}
|
|
43
43
|
const GROK_HARNESS_ALLOWED_SKILLS = new Set(capabilityGateNames(getDomainProfile(GROK_HARNESS_DOMAIN_ID).skills));
|
|
44
|
-
const HEADROOM_PRESSURE_RE = /headroom|oversized|context window|context pressure|token budget|\bcompress\b/i;
|
|
45
44
|
/**
|
|
46
45
|
* Smallest grok-harness skill grant from the live inventory. The domain
|
|
47
46
|
* profile owns the allowlist; explicit-only skills are excluded. `headroom`
|
|
48
47
|
* requires lexical or measured pressure, and the result never exceeds
|
|
49
|
-
*
|
|
48
|
+
* `MAX_SELECTED_SKILLS` names.
|
|
50
49
|
*/
|
|
51
50
|
export function selectGrokHarnessSkills(task, inventory, options = {}) {
|
|
52
|
-
|
|
53
|
-
const skills = inventory.filter((skill) => {
|
|
54
|
-
if (!GROK_HARNESS_ALLOWED_SKILLS.has(skill.name))
|
|
55
|
-
return false;
|
|
56
|
-
if (skill.disableModelInvocation)
|
|
57
|
-
return false;
|
|
58
|
-
if (skill.name === "headroom" && !pressure)
|
|
59
|
-
return false;
|
|
60
|
-
return true;
|
|
61
|
-
});
|
|
62
|
-
const selected = selectSkills({
|
|
63
|
-
task,
|
|
64
|
-
skills,
|
|
65
|
-
paths: options.paths,
|
|
66
|
-
max: MAX_SELECTED_SKILLS,
|
|
67
|
-
}).selected.map((skill) => skill.name);
|
|
68
|
-
const headroom = pressure ? skills.find((skill) => skill.name === "headroom") : undefined;
|
|
69
|
-
if (!headroom || selected.includes(headroom.name))
|
|
70
|
-
return selected;
|
|
71
|
-
return [...selected.slice(0, MAX_SELECTED_SKILLS - 1), headroom.name];
|
|
51
|
+
return selectHarnessSkills(GROK_HARNESS_ALLOWED_SKILLS, task, inventory, options);
|
|
72
52
|
}
|
|
73
53
|
export function isGrokOAuthProvider(provider) {
|
|
74
54
|
return provider === GROK_OAUTH_PROVIDER;
|
|
75
55
|
}
|
|
56
|
+
/** Provider-harness spec consumed by `tryProviderHarnessDispatch()`. */
|
|
57
|
+
export const GROK_HARNESS_SPEC = {
|
|
58
|
+
domainId: GROK_HARNESS_DOMAIN_ID,
|
|
59
|
+
applies: (provider, env) => grokHarnessAutoApplyEnabled(env) && isGrokOAuthProvider(provider),
|
|
60
|
+
selectSkills: (task, inventory, options) => selectGrokHarnessSkills(task, inventory, { paths: options.paths }),
|
|
61
|
+
};
|
|
76
62
|
/**
|
|
77
63
|
* When true (default), selecting native `xai` applies the `grok-harness` domain loadout
|
|
78
64
|
* (skills/MCP/hooks/tool gate). Set `OMK_GROK_HARNESS=0` to disable.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grok-harness.js","sourceRoot":"","sources":["../../src/core/grok-harness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,
|
|
1
|
+
{"version":3,"file":"grok-harness.js","sourceRoot":"","sources":["../../src/core/grok-harness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAGN,mBAAmB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG1D,kFAAkF;AAClF,MAAM,CAAC,MAAM,sBAAsB,GAAG,cAAc,CAAC;AAErD,MAAM,2BAA2B,GAAG,kBAAkB,CAAC;AAEvD,MAAM,CAAC,MAAM,yBAAyB,GAAG,eAAe,CAAC;AAKzD,MAAM,gBAAgB,GAAG;IACxB,IAAI,EAAE,CAAC,UAAU,EAAE,aAAa,CAAC;IACjC,KAAK,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,aAAa,CAAC;IAC/C,IAAI,EAAE,CAAC,UAAU,EAAE,iBAAiB,CAAC;IACrC,KAAK,EAAE,CAAC,cAAc,CAAC;IACvB,KAAK,EAAE,CAAC,cAAc,EAAE,iBAAiB,CAAC;CACsB,CAAC;AAElE,MAAM,+BAAgC,SAAQ,KAAK;IACzC,IAAI,GAAG,iCAAiC,CAAC;IACzC,OAAO,CAAS;IAChB,QAAQ,CAAS;IAE1B,YAAY,OAAe,EAAE,QAAgB,EAAE;QAC9C,KAAK,CACJ,uBAAuB,OAAO,qBAAqB,QAAQ,kDAAkD,CAC7G,CAAC;QACF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CA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,QAAQ,CAAC;IAC7F,YAAY,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,CAAC,uBAAuB,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;CAC9G,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CAC1C,GAAG,GAAqE,OAAO,CAAC,GAAG,EACzE;IACV,MAAM,GAAG,GAAG,GAAG,CAAC,2BAA2B,CAAC,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACnE,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,KAAK,KAAK,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACrE,OAAO,KAAK,CAAC;IACd,CAAC;IACD,OAAO,IAAI,CAAC;AAAA,CACZ","sourcesContent":["import { getDomainProfile } from \"./domain-loadouts.ts\";\nimport { GROK_OAUTH_PROVIDER } from \"./grok-playbook.ts\";\nimport {\n\ttype HarnessSkillCandidate,\n\ttype HarnessSkillSelectionOptions,\n\tselectHarnessSkills,\n} from \"./harness-skills.ts\";\nimport { capabilityGateNames } from \"./loadout-safety.ts\";\nimport type { ProviderHarnessSpec } from \"./provider-harness-dispatch.ts\";\n\n/** Domain loadout id applied automatically when Grok OAuth provider is active. */\nexport const GROK_HARNESS_DOMAIN_ID = \"grok-harness\";\n\nconst GROK_HARNESS_AUTO_APPLY_ENV = \"OMK_GROK_HARNESS\";\n\nexport const GROK_IMAGINE_MODEL_PREFIX = \"grok-imagine-\";\n\nexport type GrokModelRoute = \"text-chat\" | \"imagine-tool-only\";\nexport type GrokHarnessIntent = \"code\" | \"debug\" | \"plan\" | \"image\" | \"media\";\n\nconst SKILLS_BY_INTENT = {\n\tcode: [\"packages\", \"programming\"],\n\tdebug: [\"packages\", \"debugging\", \"programming\"],\n\tplan: [\"packages\", \"adaptorch-route\"],\n\timage: [\"image-prompt\"],\n\tmedia: [\"image-prompt\", \"adaptorch-route\"],\n} as const satisfies Record<GrokHarnessIntent, readonly string[]>;\n\nclass GrokImagineModelCompletionError extends Error {\n\treadonly name = \"GrokImagineModelCompletionError\";\n\treadonly modelId: string;\n\treadonly provider: string;\n\n\tconstructor(modelId: string, provider: string) {\n\t\tsuper(\n\t\t\t`Grok Imagine model \"${modelId}\" is tool-only on ${provider}; select a text-chat Grok model for completions.`,\n\t\t);\n\t\tthis.modelId = modelId;\n\t\tthis.provider = provider;\n\t}\n}\n\nexport function isGrokImagineModelId(id: string): boolean {\n\treturn id.startsWith(GROK_IMAGINE_MODEL_PREFIX);\n}\n\nexport function classifyGrokModelRoute(modelId: string): GrokModelRoute {\n\tif (isGrokImagineModelId(modelId)) {\n\t\treturn \"imagine-tool-only\";\n\t}\n\treturn \"text-chat\";\n}\n\nexport function assertTextChatModelForCompletion(modelId: string, provider?: string): void {\n\tif (provider === GROK_OAUTH_PROVIDER && isGrokImagineModelId(modelId)) {\n\t\tthrow new GrokImagineModelCompletionError(modelId, provider);\n\t}\n}\n\nexport function recommendedSkillTierForIntent(intent: GrokHarnessIntent): readonly string[] {\n\treturn SKILLS_BY_INTENT[intent];\n}\n\nexport type GrokHarnessSkillCandidate = HarnessSkillCandidate;\nexport type GrokHarnessSkillSelectionOptions = HarnessSkillSelectionOptions;\n\nconst GROK_HARNESS_ALLOWED_SKILLS: ReadonlySet<string> = new Set(\n\tcapabilityGateNames(getDomainProfile(GROK_HARNESS_DOMAIN_ID).skills),\n);\n\n/**\n * Smallest grok-harness skill grant from the live inventory. The domain\n * profile owns the allowlist; explicit-only skills are excluded. `headroom`\n * requires lexical or measured pressure, and the result never exceeds\n * `MAX_SELECTED_SKILLS` names.\n */\nexport function selectGrokHarnessSkills(\n\ttask: string,\n\tinventory: readonly GrokHarnessSkillCandidate[],\n\toptions: GrokHarnessSkillSelectionOptions = {},\n): readonly string[] {\n\treturn selectHarnessSkills(GROK_HARNESS_ALLOWED_SKILLS, task, inventory, options);\n}\n\nexport function isGrokOAuthProvider(provider: string | undefined): boolean {\n\treturn provider === GROK_OAUTH_PROVIDER;\n}\n\n/** Provider-harness spec consumed by `tryProviderHarnessDispatch()`. */\nexport const GROK_HARNESS_SPEC: ProviderHarnessSpec = {\n\tdomainId: GROK_HARNESS_DOMAIN_ID,\n\tapplies: (provider, env) => grokHarnessAutoApplyEnabled(env) && isGrokOAuthProvider(provider),\n\tselectSkills: (task, inventory, options) => selectGrokHarnessSkills(task, inventory, { paths: options.paths }),\n};\n\n/**\n * When true (default), selecting native `xai` applies the `grok-harness` domain loadout\n * (skills/MCP/hooks/tool gate). Set `OMK_GROK_HARNESS=0` to disable.\n */\nexport function grokHarnessAutoApplyEnabled(\n\tenv: NodeJS.ProcessEnv | Readonly<Record<string, string | undefined>> = process.env,\n): boolean {\n\tconst raw = env[GROK_HARNESS_AUTO_APPLY_ENV]?.trim().toLowerCase();\n\tif (raw === \"0\" || raw === \"false\" || raw === \"off\" || raw === \"no\") {\n\t\treturn false;\n\t}\n\treturn true;\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared skill-grant selection for provider harnesses (Grok, Devin SWE-2).
|
|
3
|
+
* The domain profile owns the allowlist; this module applies the common
|
|
4
|
+
* exclusions and the `headroom` pressure rule on top of `selectSkills()`.
|
|
5
|
+
*/
|
|
6
|
+
import { type SkillCandidate } from "./skill-selector.ts";
|
|
7
|
+
export interface HarnessSkillCandidate extends SkillCandidate {
|
|
8
|
+
readonly disableModelInvocation?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface HarnessSkillSelectionOptions {
|
|
11
|
+
readonly paths?: readonly string[];
|
|
12
|
+
readonly contextPressure?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Smallest harness skill grant from the live inventory. Explicit-only skills
|
|
16
|
+
* are excluded; `headroom` requires lexical or measured pressure; the result
|
|
17
|
+
* never exceeds {@link MAX_SELECTED_SKILLS} names.
|
|
18
|
+
*/
|
|
19
|
+
export declare function selectHarnessSkills(allowed: ReadonlySet<string>, task: string, inventory: readonly HarnessSkillCandidate[], options?: HarnessSkillSelectionOptions): readonly string[];
|
|
20
|
+
//# sourceMappingURL=harness-skills.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"harness-skills.d.ts","sourceRoot":"","sources":["../../src/core/harness-skills.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAuB,KAAK,cAAc,EAAgB,MAAM,qBAAqB,CAAC;AAE7F,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC5D,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAC1C;AAED,MAAM,WAAW,4BAA4B;IAC5C,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;CACnC;AAKD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,EAC5B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,SAAS,qBAAqB,EAAE,EAC3C,OAAO,GAAE,4BAAiC,GACxC,SAAS,MAAM,EAAE,CAiBnB","sourcesContent":["/**\n * Shared skill-grant selection for provider harnesses (Grok, Devin SWE-2).\n * The domain profile owns the allowlist; this module applies the common\n * exclusions and the `headroom` pressure rule on top of `selectSkills()`.\n */\n\nimport { MAX_SELECTED_SKILLS, type SkillCandidate, selectSkills } from \"./skill-selector.ts\";\n\nexport interface HarnessSkillCandidate extends SkillCandidate {\n\treadonly disableModelInvocation?: boolean;\n}\n\nexport interface HarnessSkillSelectionOptions {\n\treadonly paths?: readonly string[];\n\treadonly contextPressure?: boolean;\n}\n\nconst HEADROOM_SKILL = \"headroom\";\nconst HEADROOM_PRESSURE_RE = /headroom|oversized|context window|context pressure|token budget|\\bcompress\\b/i;\n\n/**\n * Smallest harness skill grant from the live inventory. Explicit-only skills\n * are excluded; `headroom` requires lexical or measured pressure; the result\n * never exceeds {@link MAX_SELECTED_SKILLS} names.\n */\nexport function selectHarnessSkills(\n\tallowed: ReadonlySet<string>,\n\ttask: string,\n\tinventory: readonly HarnessSkillCandidate[],\n\toptions: HarnessSkillSelectionOptions = {},\n): readonly string[] {\n\tconst pressure = options.contextPressure === true || HEADROOM_PRESSURE_RE.test(task);\n\tconst skills = inventory.filter((skill) => {\n\t\tif (!allowed.has(skill.name)) return false;\n\t\tif (skill.disableModelInvocation) return false;\n\t\tif (skill.name === HEADROOM_SKILL && !pressure) return false;\n\t\treturn true;\n\t});\n\tconst selected = selectSkills({\n\t\ttask,\n\t\tskills,\n\t\tpaths: options.paths,\n\t\tmax: MAX_SELECTED_SKILLS,\n\t}).selected.map((skill) => skill.name);\n\tconst headroom = pressure ? skills.find((skill) => skill.name === HEADROOM_SKILL) : undefined;\n\tif (!headroom || selected.includes(headroom.name)) return selected;\n\treturn [...selected.slice(0, MAX_SELECTED_SKILLS - 1), headroom.name];\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared skill-grant selection for provider harnesses (Grok, Devin SWE-2).
|
|
3
|
+
* The domain profile owns the allowlist; this module applies the common
|
|
4
|
+
* exclusions and the `headroom` pressure rule on top of `selectSkills()`.
|
|
5
|
+
*/
|
|
6
|
+
import { MAX_SELECTED_SKILLS, selectSkills } from "./skill-selector.js";
|
|
7
|
+
const HEADROOM_SKILL = "headroom";
|
|
8
|
+
const HEADROOM_PRESSURE_RE = /headroom|oversized|context window|context pressure|token budget|\bcompress\b/i;
|
|
9
|
+
/**
|
|
10
|
+
* Smallest harness skill grant from the live inventory. Explicit-only skills
|
|
11
|
+
* are excluded; `headroom` requires lexical or measured pressure; the result
|
|
12
|
+
* never exceeds {@link MAX_SELECTED_SKILLS} names.
|
|
13
|
+
*/
|
|
14
|
+
export function selectHarnessSkills(allowed, task, inventory, options = {}) {
|
|
15
|
+
const pressure = options.contextPressure === true || HEADROOM_PRESSURE_RE.test(task);
|
|
16
|
+
const skills = inventory.filter((skill) => {
|
|
17
|
+
if (!allowed.has(skill.name))
|
|
18
|
+
return false;
|
|
19
|
+
if (skill.disableModelInvocation)
|
|
20
|
+
return false;
|
|
21
|
+
if (skill.name === HEADROOM_SKILL && !pressure)
|
|
22
|
+
return false;
|
|
23
|
+
return true;
|
|
24
|
+
});
|
|
25
|
+
const selected = selectSkills({
|
|
26
|
+
task,
|
|
27
|
+
skills,
|
|
28
|
+
paths: options.paths,
|
|
29
|
+
max: MAX_SELECTED_SKILLS,
|
|
30
|
+
}).selected.map((skill) => skill.name);
|
|
31
|
+
const headroom = pressure ? skills.find((skill) => skill.name === HEADROOM_SKILL) : undefined;
|
|
32
|
+
if (!headroom || selected.includes(headroom.name))
|
|
33
|
+
return selected;
|
|
34
|
+
return [...selected.slice(0, MAX_SELECTED_SKILLS - 1), headroom.name];
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=harness-skills.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"harness-skills.js","sourceRoot":"","sources":["../../src/core/harness-skills.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,mBAAmB,EAAuB,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAW7F,MAAM,cAAc,GAAG,UAAU,CAAC;AAClC,MAAM,oBAAoB,GAAG,+EAA+E,CAAC;AAE7G;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAClC,OAA4B,EAC5B,IAAY,EACZ,SAA2C,EAC3C,OAAO,GAAiC,EAAE,EACtB;IACpB,MAAM,QAAQ,GAAG,OAAO,CAAC,eAAe,KAAK,IAAI,IAAI,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrF,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;QAC1C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;YAAE,OAAO,KAAK,CAAC;QAC3C,IAAI,KAAK,CAAC,sBAAsB;YAAE,OAAO,KAAK,CAAC;QAC/C,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,IAAI,CAAC,QAAQ;YAAE,OAAO,KAAK,CAAC;QAC7D,OAAO,IAAI,CAAC;IAAA,CACZ,CAAC,CAAC;IACH,MAAM,QAAQ,GAAG,YAAY,CAAC;QAC7B,IAAI;QACJ,MAAM;QACN,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,GAAG,EAAE,mBAAmB;KACxB,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACvC,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC9F,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;QAAE,OAAO,QAAQ,CAAC;IACnE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,mBAAmB,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;AAAA,CACtE","sourcesContent":["/**\n * Shared skill-grant selection for provider harnesses (Grok, Devin SWE-2).\n * The domain profile owns the allowlist; this module applies the common\n * exclusions and the `headroom` pressure rule on top of `selectSkills()`.\n */\n\nimport { MAX_SELECTED_SKILLS, type SkillCandidate, selectSkills } from \"./skill-selector.ts\";\n\nexport interface HarnessSkillCandidate extends SkillCandidate {\n\treadonly disableModelInvocation?: boolean;\n}\n\nexport interface HarnessSkillSelectionOptions {\n\treadonly paths?: readonly string[];\n\treadonly contextPressure?: boolean;\n}\n\nconst HEADROOM_SKILL = \"headroom\";\nconst HEADROOM_PRESSURE_RE = /headroom|oversized|context window|context pressure|token budget|\\bcompress\\b/i;\n\n/**\n * Smallest harness skill grant from the live inventory. Explicit-only skills\n * are excluded; `headroom` requires lexical or measured pressure; the result\n * never exceeds {@link MAX_SELECTED_SKILLS} names.\n */\nexport function selectHarnessSkills(\n\tallowed: ReadonlySet<string>,\n\ttask: string,\n\tinventory: readonly HarnessSkillCandidate[],\n\toptions: HarnessSkillSelectionOptions = {},\n): readonly string[] {\n\tconst pressure = options.contextPressure === true || HEADROOM_PRESSURE_RE.test(task);\n\tconst skills = inventory.filter((skill) => {\n\t\tif (!allowed.has(skill.name)) return false;\n\t\tif (skill.disableModelInvocation) return false;\n\t\tif (skill.name === HEADROOM_SKILL && !pressure) return false;\n\t\treturn true;\n\t});\n\tconst selected = selectSkills({\n\t\ttask,\n\t\tskills,\n\t\tpaths: options.paths,\n\t\tmax: MAX_SELECTED_SKILLS,\n\t}).selected.map((skill) => skill.name);\n\tconst headroom = pressure ? skills.find((skill) => skill.name === HEADROOM_SKILL) : undefined;\n\tif (!headroom || selected.includes(headroom.name)) return selected;\n\treturn [...selected.slice(0, MAX_SELECTED_SKILLS - 1), headroom.name];\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loadout runtime state shape and the blocked-state constructors shared by
|
|
3
|
+
* profile validation and builtin-shadow detection. Pure data; no session access.
|
|
4
|
+
*/
|
|
5
|
+
import type { CapabilityInventory, LoadoutAuthority, LoadoutProfile, SchedulerFields } from "./loadouts.ts";
|
|
6
|
+
export interface LoadoutRuntimeState {
|
|
7
|
+
profileName: string;
|
|
8
|
+
authority: LoadoutAuthority;
|
|
9
|
+
activeTools: string[];
|
|
10
|
+
activeSkills: string[];
|
|
11
|
+
activeMcp: string[];
|
|
12
|
+
activeHooks: string[];
|
|
13
|
+
schedulerFields: SchedulerFields;
|
|
14
|
+
blockers: string[];
|
|
15
|
+
warnings: string[];
|
|
16
|
+
}
|
|
17
|
+
/** A runtime state that activates nothing because the profile could not be applied. */
|
|
18
|
+
export declare function blockedLoadoutRuntime(profile: Pick<LoadoutProfile, "name" | "authority">, blockers: string[]): LoadoutRuntimeState;
|
|
19
|
+
/**
|
|
20
|
+
* A builtin always wins a name collision; an extension tool must never shadow
|
|
21
|
+
* `bash` (mirrors the AgentSession._refreshToolRegistry check). Returns the
|
|
22
|
+
* sorted, deduplicated builtin names that non-builtin inventory tools reuse.
|
|
23
|
+
*/
|
|
24
|
+
export declare function shadowedBuiltinTools(builtinNames: Iterable<string>, inventory: Pick<CapabilityInventory, "tools">): string[];
|
|
25
|
+
//# sourceMappingURL=loadout-runtime-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadout-runtime-state.d.ts","sourceRoot":"","sources":["../../src/core/loadout-runtime-state.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAE5G,MAAM,WAAW,mBAAmB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,gBAAgB,CAAC;IAC5B,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,eAAe,EAAE,eAAe,CAAC;IACjC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,uFAAuF;AACvF,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,WAAW,CAAC,EACnD,QAAQ,EAAE,MAAM,EAAE,GAChB,mBAAmB,CAYrB;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CACnC,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,EAC9B,SAAS,EAAE,IAAI,CAAC,mBAAmB,EAAE,OAAO,CAAC,GAC3C,MAAM,EAAE,CAOV","sourcesContent":["/**\n * Loadout runtime state shape and the blocked-state constructors shared by\n * profile validation and builtin-shadow detection. Pure data; no session access.\n */\n\nimport type { CapabilityInventory, LoadoutAuthority, LoadoutProfile, SchedulerFields } from \"./loadouts.ts\";\n\nexport interface LoadoutRuntimeState {\n\tprofileName: string;\n\tauthority: LoadoutAuthority;\n\tactiveTools: string[];\n\tactiveSkills: string[];\n\tactiveMcp: string[];\n\tactiveHooks: string[];\n\tschedulerFields: SchedulerFields;\n\tblockers: string[];\n\twarnings: string[];\n}\n\n/** A runtime state that activates nothing because the profile could not be applied. */\nexport function blockedLoadoutRuntime(\n\tprofile: Pick<LoadoutProfile, \"name\" | \"authority\">,\n\tblockers: string[],\n): LoadoutRuntimeState {\n\treturn {\n\t\tprofileName: profile.name,\n\t\tauthority: profile.authority,\n\t\tactiveTools: [],\n\t\tactiveSkills: [],\n\t\tactiveMcp: [],\n\t\tactiveHooks: [],\n\t\tschedulerFields: { readSet: [], writeSet: [], parallelizable: true },\n\t\tblockers,\n\t\twarnings: [],\n\t};\n}\n\n/**\n * A builtin always wins a name collision; an extension tool must never shadow\n * `bash` (mirrors the AgentSession._refreshToolRegistry check). Returns the\n * sorted, deduplicated builtin names that non-builtin inventory tools reuse.\n */\nexport function shadowedBuiltinTools(\n\tbuiltinNames: Iterable<string>,\n\tinventory: Pick<CapabilityInventory, \"tools\">,\n): string[] {\n\tconst builtins = new Set(builtinNames);\n\tconst shadowed = new Set<string>();\n\tfor (const tool of inventory.tools) {\n\t\tif (tool.source !== \"builtin\" && tool.source !== \"sdk\" && builtins.has(tool.name)) shadowed.add(tool.name);\n\t}\n\treturn [...shadowed].sort(compareCodeUnits);\n}\n\n/** Same ordering as the default `Array.prototype.sort` for strings, made explicit. */\nfunction compareCodeUnits(left: string, right: string): number {\n\tif (left === right) return 0;\n\treturn left < right ? -1 : 1;\n}\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loadout runtime state shape and the blocked-state constructors shared by
|
|
3
|
+
* profile validation and builtin-shadow detection. Pure data; no session access.
|
|
4
|
+
*/
|
|
5
|
+
/** A runtime state that activates nothing because the profile could not be applied. */
|
|
6
|
+
export function blockedLoadoutRuntime(profile, blockers) {
|
|
7
|
+
return {
|
|
8
|
+
profileName: profile.name,
|
|
9
|
+
authority: profile.authority,
|
|
10
|
+
activeTools: [],
|
|
11
|
+
activeSkills: [],
|
|
12
|
+
activeMcp: [],
|
|
13
|
+
activeHooks: [],
|
|
14
|
+
schedulerFields: { readSet: [], writeSet: [], parallelizable: true },
|
|
15
|
+
blockers,
|
|
16
|
+
warnings: [],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A builtin always wins a name collision; an extension tool must never shadow
|
|
21
|
+
* `bash` (mirrors the AgentSession._refreshToolRegistry check). Returns the
|
|
22
|
+
* sorted, deduplicated builtin names that non-builtin inventory tools reuse.
|
|
23
|
+
*/
|
|
24
|
+
export function shadowedBuiltinTools(builtinNames, inventory) {
|
|
25
|
+
const builtins = new Set(builtinNames);
|
|
26
|
+
const shadowed = new Set();
|
|
27
|
+
for (const tool of inventory.tools) {
|
|
28
|
+
if (tool.source !== "builtin" && tool.source !== "sdk" && builtins.has(tool.name))
|
|
29
|
+
shadowed.add(tool.name);
|
|
30
|
+
}
|
|
31
|
+
return [...shadowed].sort(compareCodeUnits);
|
|
32
|
+
}
|
|
33
|
+
/** Same ordering as the default `Array.prototype.sort` for strings, made explicit. */
|
|
34
|
+
function compareCodeUnits(left, right) {
|
|
35
|
+
if (left === right)
|
|
36
|
+
return 0;
|
|
37
|
+
return left < right ? -1 : 1;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=loadout-runtime-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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CAAC,CAAC;AAAA,CAC7B","sourcesContent":["/**\n * Loadout runtime state shape and the blocked-state constructors shared by\n * profile validation and builtin-shadow detection. Pure data; no session access.\n */\n\nimport type { CapabilityInventory, LoadoutAuthority, LoadoutProfile, SchedulerFields } from \"./loadouts.ts\";\n\nexport interface LoadoutRuntimeState {\n\tprofileName: string;\n\tauthority: LoadoutAuthority;\n\tactiveTools: string[];\n\tactiveSkills: string[];\n\tactiveMcp: string[];\n\tactiveHooks: string[];\n\tschedulerFields: SchedulerFields;\n\tblockers: string[];\n\twarnings: string[];\n}\n\n/** A runtime state that activates nothing because the profile could not be applied. */\nexport function blockedLoadoutRuntime(\n\tprofile: Pick<LoadoutProfile, \"name\" | \"authority\">,\n\tblockers: string[],\n): LoadoutRuntimeState {\n\treturn {\n\t\tprofileName: profile.name,\n\t\tauthority: profile.authority,\n\t\tactiveTools: [],\n\t\tactiveSkills: [],\n\t\tactiveMcp: [],\n\t\tactiveHooks: [],\n\t\tschedulerFields: { readSet: [], writeSet: [], parallelizable: true },\n\t\tblockers,\n\t\twarnings: [],\n\t};\n}\n\n/**\n * A builtin always wins a name collision; an extension tool must never shadow\n * `bash` (mirrors the AgentSession._refreshToolRegistry check). Returns the\n * sorted, deduplicated builtin names that non-builtin inventory tools reuse.\n */\nexport function shadowedBuiltinTools(\n\tbuiltinNames: Iterable<string>,\n\tinventory: Pick<CapabilityInventory, \"tools\">,\n): string[] {\n\tconst builtins = new Set(builtinNames);\n\tconst shadowed = new Set<string>();\n\tfor (const tool of inventory.tools) {\n\t\tif (tool.source !== \"builtin\" && tool.source !== \"sdk\" && builtins.has(tool.name)) shadowed.add(tool.name);\n\t}\n\treturn [...shadowed].sort(compareCodeUnits);\n}\n\n/** Same ordering as the default `Array.prototype.sort` for strings, made explicit. */\nfunction compareCodeUnits(left: string, right: string): number {\n\tif (left === right) return 0;\n\treturn left < right ? -1 : 1;\n}\n"]}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import type { ToolDefinition } from "./extensions/types.ts";
|
|
9
9
|
import { type HookInventory } from "./hook-inventory.ts";
|
|
10
10
|
import { type LoadoutAccessPolicy } from "./loadout-access-policy.ts";
|
|
11
|
+
import { type LoadoutRuntimeState } from "./loadout-runtime-state.ts";
|
|
11
12
|
import { type AppliedLoadout, type CapabilityInventory, type LoadoutAuthority, type LoadoutCommands, type LoadoutProfile, type LoadoutRole, type SchedulerFields } from "./loadouts.ts";
|
|
12
13
|
import type { ResourceLoader } from "./resource-loader.ts";
|
|
13
14
|
import type { SourceInfo } from "./source-info.ts";
|
|
@@ -29,17 +30,7 @@ export interface LoadoutRuntimeSession {
|
|
|
29
30
|
_extensionRunner: ExtensionRunnerLike;
|
|
30
31
|
_customTools: ToolDefinition[];
|
|
31
32
|
}
|
|
32
|
-
export
|
|
33
|
-
profileName: string;
|
|
34
|
-
authority: LoadoutAuthority;
|
|
35
|
-
activeTools: string[];
|
|
36
|
-
activeSkills: string[];
|
|
37
|
-
activeMcp: string[];
|
|
38
|
-
activeHooks: string[];
|
|
39
|
-
schedulerFields: SchedulerFields;
|
|
40
|
-
blockers: string[];
|
|
41
|
-
warnings: string[];
|
|
42
|
-
}
|
|
33
|
+
export type { LoadoutRuntimeState };
|
|
43
34
|
export interface BuildLoadoutAccessPolicyOptions {
|
|
44
35
|
cwd: string;
|
|
45
36
|
blockedPaths?: readonly string[];
|
|
@@ -102,5 +93,4 @@ export interface BuildSubagentLaneGrantOptions {
|
|
|
102
93
|
acceptance?: readonly string[];
|
|
103
94
|
}
|
|
104
95
|
export declare function buildSubagentLaneGrant(nodeId: string, role: LoadoutRole, task: string, applied: AppliedLoadout, schedulerFields: SchedulerFields, options?: BuildSubagentLaneGrantOptions): SubagentLaneGrant;
|
|
105
|
-
export {};
|
|
106
96
|
//# sourceMappingURL=loadout-runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadout-runtime.d.ts","sourceRoot":"","sources":["../../src/core/loadout-runtime.ts"],"names":[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AW,EACjB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,cAAc,EACvB,eAAe,EAAE,eAAe,EAChC,OAAO,GAAE,6BAAkC,GACzC,iBAAiB,CAwCnB","sourcesContent":["/**\n * Loadout runtime wiring — pure algorithms.\n *\n * Converts the pure loadout decisions in `loadouts.ts` into runtime-ready\n * capability inventories, lane grants, and scheduler fields without mutating\n * `AgentSession`.\n */\n\nimport path from \"node:path\";\nimport type { ToolDefinition } from \"./extensions/types.ts\";\nimport { type HookInventory, loadHookInventory } from \"./hook-inventory.ts\";\nimport { sanitizeHookPolicy } from \"./hooks/index.ts\";\nimport { createLoadoutAccessPolicy, type LoadoutAccessPolicy } from \"./loadout-access-policy.ts\";\nimport {\n\ttype AppliedLoadout,\n\tapplyLoadoutProfile,\n\ttype CapabilityInventory,\n\tderiveSchedulerFields,\n\ttype LoadoutAuthority,\n\ttype LoadoutCommands,\n\ttype LoadoutProfile,\n\ttype LoadoutRole,\n\ttype NamedResource,\n\ttype SchedulerFields,\n\tvalidateLoadoutProfile,\n} from \"./loadouts.ts\";\nimport { loadMcpInventory } from \"./mcp-inventory.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { SourceInfo } from \"./source-info.ts\";\n\ninterface ExtensionRunnerLike {\n\tgetAllRegisteredTools(): Array<{ definition: { name: string }; sourceInfo: SourceInfo }>;\n}\n\n/**\n * Subset of `AgentSession` fields needed to build a capability inventory.\n * Callers (including `AgentSession` itself) can cast the session to this\n * interface because the fields are read-only for inventory construction.\n */\nexport interface LoadoutRuntimeSession {\n\t_baseToolDefinitions: Map<string, ToolDefinition>;\n\t_extensionRunner: ExtensionRunnerLike;\n\t_customTools: ToolDefinition[];\n}\n\nexport interface LoadoutRuntimeState {\n\tprofileName: string;\n\tauthority: LoadoutAuthority;\n\tactiveTools: string[];\n\tactiveSkills: string[];\n\tactiveMcp: string[];\n\tactiveHooks: string[];\n\tschedulerFields: SchedulerFields;\n\tblockers: string[];\n\twarnings: string[];\n}\n\nexport interface BuildLoadoutAccessPolicyOptions {\n\tcwd: string;\n\tblockedPaths?: readonly string[];\n\tcommands?: LoadoutCommands;\n}\n\nexport function buildLoadoutAccessPolicy(\n\tstate: LoadoutRuntimeState,\n\toptions: BuildLoadoutAccessPolicyOptions,\n): LoadoutAccessPolicy {\n\treturn createLoadoutAccessPolicy({\n\t\tcwd: options.cwd,\n\t\tactiveTools: state.activeTools,\n\t\treadSet: state.schedulerFields.readSet,\n\t\twriteSet: state.schedulerFields.writeSet,\n\t\tblockedPaths: options.blockedPaths,\n\t\tcommands: options.commands,\n\t});\n}\n\nexport interface SubagentLaneGrant {\n\tlaneId: string;\n\tagent: string;\n\ttask: string;\n\tscope: string;\n\tauthority: LoadoutAuthority;\n\tallowedPaths: string[];\n\tblockedPaths: string[];\n\ttools: string[];\n\tskills: string[];\n\tmcp: string[];\n\thooks: string[];\n\tcommands: LoadoutCommands;\n\tcontextInheritance: LaneContextInheritanceMode;\n\tspawnReceipt?: LaneSpawnReceipt;\n\tevidenceGates: LaneEvidenceGate[];\n\tdependsOn: string[];\n\tacceptance: string[];\n\tevidenceOutput?: string;\n\tscheduler: SchedulerFields;\n}\n\nexport type LaneContextInheritanceMode = \"none\" | \"receipt\" | \"last-turn\" | \"bounded\" | \"full\";\n\nexport type LaneEvidenceGate = \"plan-reread\" | \"automated-verification\" | \"manual-qa\" | \"adversarial-qa\" | \"cleanup\";\n\nexport interface LaneSpawnReceipt {\n\twhyParallel: string;\n\twhyNotLocal: string;\n\tindependence: string;\n\texpectedReceiptShape: string;\n\tmaxInlineTokens: number;\n}\n\nexport function buildCapabilityInventory(\n\tsession: LoadoutRuntimeSession,\n\tresourceLoader: ResourceLoader,\n\tcwd: string,\n\thookInventory: HookInventory,\n): CapabilityInventory {\n\tconst tools: NamedResource[] = [];\n\n\tfor (const [name] of session._baseToolDefinitions) {\n\t\ttools.push({\n\t\t\tkind: \"tool\",\n\t\t\tname,\n\t\t\tsource: \"builtin\",\n\t\t\tscope: \"temporary\",\n\t\t\torigin: \"top-level\",\n\t\t});\n\t}\n\n\tfor (const registered of session._extensionRunner.getAllRegisteredTools()) {\n\t\tconst { sourceInfo } = registered;\n\t\ttools.push({\n\t\t\tkind: \"tool\",\n\t\t\tname: registered.definition.name,\n\t\t\tsource: sourceInfo.source,\n\t\t\tscope: sourceInfo.scope,\n\t\t\torigin: sourceInfo.origin,\n\t\t\tpath: sourceInfo.path,\n\t\t});\n\t}\n\n\tfor (const definition of session._customTools) {\n\t\ttools.push({\n\t\t\tkind: \"tool\",\n\t\t\tname: definition.name,\n\t\t\tsource: \"sdk\",\n\t\t\tscope: \"temporary\",\n\t\t\torigin: \"top-level\",\n\t\t});\n\t}\n\n\tconst skills: NamedResource[] = resourceLoader.getSkills().skills.map((skill) => ({\n\t\tkind: \"skill\",\n\t\tname: skill.name,\n\t\tsource: skill.sourceInfo.source,\n\t\tscope: skill.sourceInfo.scope,\n\t\torigin: skill.sourceInfo.origin,\n\t\tpath: skill.filePath,\n\t}));\n\n\tconst mcp: NamedResource[] = loadMcpInventory(cwd).entries.map((entry) => ({\n\t\tkind: \"mcp\",\n\t\tname: entry.name,\n\t\tsource: entry.source,\n\t\tscope: mcpInventoryScope(cwd, entry.source),\n\t\torigin: \"top-level\",\n\t\tpath: entry.source,\n\t}));\n\n\tconst hooks: NamedResource[] = hookInventory.hooks.map((descriptor) => ({\n\t\tkind: \"hook\",\n\t\tname: descriptor.name,\n\t\tsource: descriptor.builtin ? \"builtin\" : \"project\",\n\t\tscope: descriptor.builtin ? \"builtin\" : \"project\",\n\t\torigin: \"top-level\",\n\t\tpath: descriptor.scriptPath,\n\t\tpolicy: sanitizeHookPolicy(descriptor.policy),\n\t}));\n\n\treturn { tools, skills, mcp, hooks };\n}\n\nfunction mcpInventoryScope(cwd: string, sourcePath: string): \"project\" | \"user\" {\n\tconst relative = path.relative(cwd, sourcePath);\n\treturn relative !== \"\" && !relative.startsWith(\"..\") && !path.isAbsolute(relative) ? \"project\" : \"user\";\n}\n\nexport interface ApplyLoadoutToRuntimeRequest {\n\tprofile: LoadoutProfile;\n\trole: LoadoutRole;\n\tgrantAuthority?: LoadoutAuthority;\n\tassignedReadPaths?: readonly string[];\n\tassignedWritePaths?: readonly string[];\n}\n\nexport function applyLoadoutToRuntime(\n\tsession: LoadoutRuntimeSession,\n\tresourceLoader: ResourceLoader,\n\tcwd: string,\n\tagentDir: string,\n\trequest: ApplyLoadoutToRuntimeRequest,\n): LoadoutRuntimeState {\n\tconst validation = validateLoadoutProfile(request.profile);\n\tif (!validation.valid) {\n\t\treturn {\n\t\t\tprofileName: request.profile.name,\n\t\t\tauthority: request.profile.authority,\n\t\t\tactiveTools: [],\n\t\t\tactiveSkills: [],\n\t\t\tactiveMcp: [],\n\t\t\tactiveHooks: [],\n\t\t\tschedulerFields: { readSet: [], writeSet: [], parallelizable: true },\n\t\t\tblockers: validation.errors,\n\t\t\twarnings: [],\n\t\t};\n\t}\n\n\tconst hookInventory = loadHookInventory(agentDir);\n\tconst inventory = buildCapabilityInventory(session, resourceLoader, cwd, hookInventory);\n\tconst applied = applyLoadoutProfile(request.profile, inventory, { grantAuthority: request.grantAuthority });\n\tif (applied.blockers.length > 0) {\n\t\treturn {\n\t\t\tprofileName: applied.profileName,\n\t\t\tauthority: applied.authority,\n\t\t\tactiveTools: applied.activeTools,\n\t\t\tactiveSkills: applied.activeSkills,\n\t\t\tactiveMcp: applied.activeMcp,\n\t\t\tactiveHooks: applied.activeHooks,\n\t\t\tschedulerFields: { readSet: [], writeSet: [], parallelizable: true },\n\t\t\tblockers: applied.blockers,\n\t\t\twarnings: applied.warnings,\n\t\t};\n\t}\n\n\tconst schedulerFields = deriveSchedulerFields({\n\t\trole: request.role,\n\t\tassignedReadPaths: request.assignedReadPaths,\n\t\tassignedWritePaths: request.assignedWritePaths,\n\t});\n\n\treturn {\n\t\tprofileName: applied.profileName,\n\t\tauthority: applied.authority,\n\t\tactiveTools: applied.activeTools,\n\t\tactiveSkills: applied.activeSkills,\n\t\tactiveMcp: applied.activeMcp,\n\t\tactiveHooks: applied.activeHooks,\n\t\tschedulerFields,\n\t\tblockers: applied.blockers,\n\t\twarnings: applied.warnings,\n\t};\n}\n\nexport interface BuildSubagentLaneGrantOptions {\n\tallowedReadPaths?: readonly string[];\n\tallowedWritePaths?: readonly string[];\n\tblockedPaths?: readonly string[];\n\tevidenceOutputPattern?: string;\n\trunId?: string;\n\tprofile?: { commands?: LoadoutCommands };\n\tagentName?: string;\n\tcontextInheritance?: LaneContextInheritanceMode;\n\tspawnReceipt?: LaneSpawnReceipt;\n\tevidenceGates?: readonly LaneEvidenceGate[];\n\tdependsOn?: readonly string[];\n\tacceptance?: readonly string[];\n}\n\nexport function buildSubagentLaneGrant(\n\tnodeId: string,\n\trole: LoadoutRole,\n\ttask: string,\n\tapplied: AppliedLoadout,\n\tschedulerFields: SchedulerFields,\n\toptions: BuildSubagentLaneGrantOptions = {},\n): SubagentLaneGrant {\n\tconst allowedPaths = uniqueSorted([...(options.allowedReadPaths ?? []), ...(options.allowedWritePaths ?? [])]);\n\tconst blockedPaths = uniqueSorted([\n\t\t\"**/.env*\",\n\t\t\"**/*secret*\",\n\t\t\"**/*key*\",\n\t\t\"**/.git/*\",\n\t\t...(options.blockedPaths ?? []),\n\t]);\n\n\tlet evidenceOutput: string | undefined;\n\tif (options.evidenceOutputPattern) {\n\t\tevidenceOutput = options.runId\n\t\t\t? options.evidenceOutputPattern.replace(\"<goal>\", options.runId)\n\t\t\t: options.evidenceOutputPattern;\n\t}\n\n\tconst commands = options.profile?.commands ?? { mode: \"none\" };\n\n\treturn {\n\t\tlaneId: nodeId,\n\t\tagent: options.agentName ?? `omk-${role}`,\n\t\ttask,\n\t\tscope: \"loadout-derived lane grant\",\n\t\tauthority: applied.authority,\n\t\tallowedPaths,\n\t\tblockedPaths,\n\t\ttools: applied.activeTools,\n\t\tskills: applied.activeSkills,\n\t\tmcp: applied.activeMcp,\n\t\thooks: applied.activeHooks,\n\t\tcommands,\n\t\tcontextInheritance: options.contextInheritance ?? defaultContextInheritance(role),\n\t\t...(options.spawnReceipt ? { spawnReceipt: options.spawnReceipt } : {}),\n\t\tevidenceGates: uniqueSortedEvidenceGates(options.evidenceGates ?? []),\n\t\tdependsOn: uniqueSorted(options.dependsOn ?? []),\n\t\tacceptance: uniqueSorted(options.acceptance ?? []),\n\t\tevidenceOutput,\n\t\tscheduler: schedulerFields,\n\t};\n}\n\nfunction defaultContextInheritance(role: LoadoutRole): LaneContextInheritanceMode {\n\tswitch (role) {\n\t\tcase \"planner\":\n\t\tcase \"critic\":\n\t\tcase \"visual-qa\":\n\t\t\treturn \"receipt\";\n\t\tcase \"security\":\n\t\t\treturn \"none\";\n\t\tdefault:\n\t\t\treturn \"bounded\";\n\t}\n}\n\nfunction uniqueSorted(values: readonly string[]): string[] {\n\treturn [...new Set(values)]\n\t\t.map((value) => value.trim())\n\t\t.filter((value) => value !== \"\")\n\t\t.sort();\n}\n\nfunction uniqueSortedEvidenceGates(values: readonly LaneEvidenceGate[]): LaneEvidenceGate[] {\n\treturn [...new Set(values)].sort();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"loadout-runtime.d.ts","sourceRoot":"","sources":["../../src/core/loadout-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,KAAK,aAAa,EAAqB,MAAM,qBAAqB,CAAC;AAE5E,OAAO,EAA6B,KAAK,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjG,OAAO,EAAyB,KAAK,mBAAmB,EAAwB,MAAM,4BAA4B,CAAC;AACnH,OAAO,EACN,KAAK,cAAc,EAEnB,KAAK,mBAAmB,EAExB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,WAAW,EAEhB,KAAK,eAAe,EAEpB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,cAAc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AY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,eAAe,CAAA;KAAE,CAAC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,0BAA0B,CAAC;IAChD,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,aAAa,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC5C,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC/B;AAED,wBAAgB,sBAAsB,CACrC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,cAAc,EACvB,eAAe,EAAE,eAAe,EAChC,OAAO,GAAE,6BAAkC,GACzC,iBAAiB,CAwCnB","sourcesContent":["/**\n * Loadout runtime wiring — pure algorithms.\n *\n * Converts the pure loadout decisions in `loadouts.ts` into runtime-ready\n * capability inventories, lane grants, and scheduler fields without mutating\n * `AgentSession`.\n */\n\nimport path from \"node:path\";\nimport type { ToolDefinition } from \"./extensions/types.ts\";\nimport { type HookInventory, loadHookInventory } from \"./hook-inventory.ts\";\nimport { sanitizeHookPolicy } from \"./hooks/index.ts\";\nimport { createLoadoutAccessPolicy, type LoadoutAccessPolicy } from \"./loadout-access-policy.ts\";\nimport { blockedLoadoutRuntime, type LoadoutRuntimeState, shadowedBuiltinTools } from \"./loadout-runtime-state.ts\";\nimport {\n\ttype AppliedLoadout,\n\tapplyLoadoutProfile,\n\ttype CapabilityInventory,\n\tderiveSchedulerFields,\n\ttype LoadoutAuthority,\n\ttype LoadoutCommands,\n\ttype LoadoutProfile,\n\ttype LoadoutRole,\n\ttype NamedResource,\n\ttype SchedulerFields,\n\tvalidateLoadoutProfile,\n} from \"./loadouts.ts\";\nimport { loadMcpInventory } from \"./mcp-inventory.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { SourceInfo } from \"./source-info.ts\";\n\ninterface ExtensionRunnerLike {\n\tgetAllRegisteredTools(): Array<{ definition: { name: string }; sourceInfo: SourceInfo }>;\n}\n\n/**\n * Subset of `AgentSession` fields needed to build a capability inventory.\n * Callers (including `AgentSession` itself) can cast the session to this\n * interface because the fields are read-only for inventory construction.\n */\nexport interface LoadoutRuntimeSession {\n\t_baseToolDefinitions: Map<string, ToolDefinition>;\n\t_extensionRunner: ExtensionRunnerLike;\n\t_customTools: ToolDefinition[];\n}\n\nexport type { LoadoutRuntimeState };\n\nexport interface BuildLoadoutAccessPolicyOptions {\n\tcwd: string;\n\tblockedPaths?: readonly string[];\n\tcommands?: LoadoutCommands;\n}\n\nexport function buildLoadoutAccessPolicy(\n\tstate: LoadoutRuntimeState,\n\toptions: BuildLoadoutAccessPolicyOptions,\n): LoadoutAccessPolicy {\n\treturn createLoadoutAccessPolicy({\n\t\tcwd: options.cwd,\n\t\tactiveTools: state.activeTools,\n\t\treadSet: state.schedulerFields.readSet,\n\t\twriteSet: state.schedulerFields.writeSet,\n\t\tblockedPaths: options.blockedPaths,\n\t\tcommands: options.commands,\n\t});\n}\n\nexport interface SubagentLaneGrant {\n\tlaneId: string;\n\tagent: string;\n\ttask: string;\n\tscope: string;\n\tauthority: LoadoutAuthority;\n\tallowedPaths: string[];\n\tblockedPaths: string[];\n\ttools: string[];\n\tskills: string[];\n\tmcp: string[];\n\thooks: string[];\n\tcommands: LoadoutCommands;\n\tcontextInheritance: LaneContextInheritanceMode;\n\tspawnReceipt?: LaneSpawnReceipt;\n\tevidenceGates: LaneEvidenceGate[];\n\tdependsOn: string[];\n\tacceptance: string[];\n\tevidenceOutput?: string;\n\tscheduler: SchedulerFields;\n}\n\nexport type LaneContextInheritanceMode = \"none\" | \"receipt\" | \"last-turn\" | \"bounded\" | \"full\";\n\nexport type LaneEvidenceGate = \"plan-reread\" | \"automated-verification\" | \"manual-qa\" | \"adversarial-qa\" | \"cleanup\";\n\nexport interface LaneSpawnReceipt {\n\twhyParallel: string;\n\twhyNotLocal: string;\n\tindependence: string;\n\texpectedReceiptShape: string;\n\tmaxInlineTokens: number;\n}\n\nexport function buildCapabilityInventory(\n\tsession: LoadoutRuntimeSession,\n\tresourceLoader: ResourceLoader,\n\tcwd: string,\n\thookInventory: HookInventory,\n): CapabilityInventory {\n\tconst tools: NamedResource[] = [];\n\n\tfor (const [name] of session._baseToolDefinitions) {\n\t\ttools.push({\n\t\t\tkind: \"tool\",\n\t\t\tname,\n\t\t\tsource: \"builtin\",\n\t\t\tscope: \"temporary\",\n\t\t\torigin: \"top-level\",\n\t\t});\n\t}\n\n\tfor (const registered of session._extensionRunner.getAllRegisteredTools()) {\n\t\tconst { sourceInfo } = registered;\n\t\ttools.push({\n\t\t\tkind: \"tool\",\n\t\t\tname: registered.definition.name,\n\t\t\tsource: sourceInfo.source,\n\t\t\tscope: sourceInfo.scope,\n\t\t\torigin: sourceInfo.origin,\n\t\t\tpath: sourceInfo.path,\n\t\t});\n\t}\n\n\tfor (const definition of session._customTools) {\n\t\ttools.push({\n\t\t\tkind: \"tool\",\n\t\t\tname: definition.name,\n\t\t\tsource: \"sdk\",\n\t\t\tscope: \"temporary\",\n\t\t\torigin: \"top-level\",\n\t\t});\n\t}\n\n\tconst skills: NamedResource[] = resourceLoader.getSkills().skills.map((skill) => ({\n\t\tkind: \"skill\",\n\t\tname: skill.name,\n\t\tsource: skill.sourceInfo.source,\n\t\tscope: skill.sourceInfo.scope,\n\t\torigin: skill.sourceInfo.origin,\n\t\tpath: skill.filePath,\n\t}));\n\n\tconst mcp: NamedResource[] = loadMcpInventory(cwd).entries.map((entry) => ({\n\t\tkind: \"mcp\",\n\t\tname: entry.name,\n\t\tsource: entry.source,\n\t\tscope: mcpInventoryScope(cwd, entry.source),\n\t\torigin: \"top-level\",\n\t\tpath: entry.source,\n\t}));\n\n\tconst hooks: NamedResource[] = hookInventory.hooks.map((descriptor) => ({\n\t\tkind: \"hook\",\n\t\tname: descriptor.name,\n\t\tsource: descriptor.builtin ? \"builtin\" : \"project\",\n\t\tscope: descriptor.builtin ? \"builtin\" : \"project\",\n\t\torigin: \"top-level\",\n\t\tpath: descriptor.scriptPath,\n\t\tpolicy: sanitizeHookPolicy(descriptor.policy),\n\t}));\n\n\treturn { tools, skills, mcp, hooks };\n}\n\nfunction mcpInventoryScope(cwd: string, sourcePath: string): \"project\" | \"user\" {\n\tconst relative = path.relative(cwd, sourcePath);\n\treturn relative !== \"\" && !relative.startsWith(\"..\") && !path.isAbsolute(relative) ? \"project\" : \"user\";\n}\n\nexport interface ApplyLoadoutToRuntimeRequest {\n\tprofile: LoadoutProfile;\n\trole: LoadoutRole;\n\tgrantAuthority?: LoadoutAuthority;\n\tassignedReadPaths?: readonly string[];\n\tassignedWritePaths?: readonly string[];\n}\n\nexport function applyLoadoutToRuntime(\n\tsession: LoadoutRuntimeSession,\n\tresourceLoader: ResourceLoader,\n\tcwd: string,\n\tagentDir: string,\n\trequest: ApplyLoadoutToRuntimeRequest,\n): LoadoutRuntimeState {\n\tconst validation = validateLoadoutProfile(request.profile);\n\tif (!validation.valid) return blockedLoadoutRuntime(request.profile, validation.errors);\n\n\tconst hookInventory = loadHookInventory(agentDir);\n\tconst inventory = buildCapabilityInventory(session, resourceLoader, cwd, hookInventory);\n\tconst shadowed = shadowedBuiltinTools(session._baseToolDefinitions.keys(), inventory);\n\tif (shadowed.length > 0)\n\t\treturn blockedLoadoutRuntime(request.profile, [`loadout extension tool shadows builtin: ${shadowed.join(\", \")}`]);\n\tconst applied = applyLoadoutProfile(request.profile, inventory, { grantAuthority: request.grantAuthority });\n\tif (applied.blockers.length > 0) {\n\t\treturn {\n\t\t\tprofileName: applied.profileName,\n\t\t\tauthority: applied.authority,\n\t\t\tactiveTools: applied.activeTools,\n\t\t\tactiveSkills: applied.activeSkills,\n\t\t\tactiveMcp: applied.activeMcp,\n\t\t\tactiveHooks: applied.activeHooks,\n\t\t\tschedulerFields: { readSet: [], writeSet: [], parallelizable: true },\n\t\t\tblockers: applied.blockers,\n\t\t\twarnings: applied.warnings,\n\t\t};\n\t}\n\n\tconst schedulerFields = deriveSchedulerFields({\n\t\trole: request.role,\n\t\tassignedReadPaths: request.assignedReadPaths,\n\t\tassignedWritePaths: request.assignedWritePaths,\n\t});\n\n\treturn {\n\t\tprofileName: applied.profileName,\n\t\tauthority: applied.authority,\n\t\tactiveTools: applied.activeTools,\n\t\tactiveSkills: applied.activeSkills,\n\t\tactiveMcp: applied.activeMcp,\n\t\tactiveHooks: applied.activeHooks,\n\t\tschedulerFields,\n\t\tblockers: applied.blockers,\n\t\twarnings: applied.warnings,\n\t};\n}\n\nexport interface BuildSubagentLaneGrantOptions {\n\tallowedReadPaths?: readonly string[];\n\tallowedWritePaths?: readonly string[];\n\tblockedPaths?: readonly string[];\n\tevidenceOutputPattern?: string;\n\trunId?: string;\n\tprofile?: { commands?: LoadoutCommands };\n\tagentName?: string;\n\tcontextInheritance?: LaneContextInheritanceMode;\n\tspawnReceipt?: LaneSpawnReceipt;\n\tevidenceGates?: readonly LaneEvidenceGate[];\n\tdependsOn?: readonly string[];\n\tacceptance?: readonly string[];\n}\n\nexport function buildSubagentLaneGrant(\n\tnodeId: string,\n\trole: LoadoutRole,\n\ttask: string,\n\tapplied: AppliedLoadout,\n\tschedulerFields: SchedulerFields,\n\toptions: BuildSubagentLaneGrantOptions = {},\n): SubagentLaneGrant {\n\tconst allowedPaths = uniqueSorted([...(options.allowedReadPaths ?? []), ...(options.allowedWritePaths ?? [])]);\n\tconst blockedPaths = uniqueSorted([\n\t\t\"**/.env*\",\n\t\t\"**/*secret*\",\n\t\t\"**/*key*\",\n\t\t\"**/.git/*\",\n\t\t...(options.blockedPaths ?? []),\n\t]);\n\n\tlet evidenceOutput: string | undefined;\n\tif (options.evidenceOutputPattern) {\n\t\tevidenceOutput = options.runId\n\t\t\t? options.evidenceOutputPattern.replace(\"<goal>\", options.runId)\n\t\t\t: options.evidenceOutputPattern;\n\t}\n\n\tconst commands = options.profile?.commands ?? { mode: \"none\" };\n\n\treturn {\n\t\tlaneId: nodeId,\n\t\tagent: options.agentName ?? `omk-${role}`,\n\t\ttask,\n\t\tscope: \"loadout-derived lane grant\",\n\t\tauthority: applied.authority,\n\t\tallowedPaths,\n\t\tblockedPaths,\n\t\ttools: applied.activeTools,\n\t\tskills: applied.activeSkills,\n\t\tmcp: applied.activeMcp,\n\t\thooks: applied.activeHooks,\n\t\tcommands,\n\t\tcontextInheritance: options.contextInheritance ?? defaultContextInheritance(role),\n\t\t...(options.spawnReceipt ? { spawnReceipt: options.spawnReceipt } : {}),\n\t\tevidenceGates: uniqueSortedEvidenceGates(options.evidenceGates ?? []),\n\t\tdependsOn: uniqueSorted(options.dependsOn ?? []),\n\t\tacceptance: uniqueSorted(options.acceptance ?? []),\n\t\tevidenceOutput,\n\t\tscheduler: schedulerFields,\n\t};\n}\n\nfunction defaultContextInheritance(role: LoadoutRole): LaneContextInheritanceMode {\n\tswitch (role) {\n\t\tcase \"planner\":\n\t\tcase \"critic\":\n\t\tcase \"visual-qa\":\n\t\t\treturn \"receipt\";\n\t\tcase \"security\":\n\t\t\treturn \"none\";\n\t\tdefault:\n\t\t\treturn \"bounded\";\n\t}\n}\n\nfunction uniqueSorted(values: readonly string[]): string[] {\n\treturn [...new Set(values)]\n\t\t.map((value) => value.trim())\n\t\t.filter((value) => value !== \"\")\n\t\t.sort();\n}\n\nfunction uniqueSortedEvidenceGates(values: readonly LaneEvidenceGate[]): LaneEvidenceGate[] {\n\treturn [...new Set(values)].sort();\n}\n"]}
|
|
@@ -9,6 +9,7 @@ import path from "node:path";
|
|
|
9
9
|
import { loadHookInventory } from "./hook-inventory.js";
|
|
10
10
|
import { sanitizeHookPolicy } from "./hooks/index.js";
|
|
11
11
|
import { createLoadoutAccessPolicy } from "./loadout-access-policy.js";
|
|
12
|
+
import { blockedLoadoutRuntime, shadowedBuiltinTools } from "./loadout-runtime-state.js";
|
|
12
13
|
import { applyLoadoutProfile, deriveSchedulerFields, validateLoadoutProfile, } from "./loadouts.js";
|
|
13
14
|
import { loadMcpInventory } from "./mcp-inventory.js";
|
|
14
15
|
export function buildLoadoutAccessPolicy(state, options) {
|
|
@@ -85,21 +86,13 @@ function mcpInventoryScope(cwd, sourcePath) {
|
|
|
85
86
|
}
|
|
86
87
|
export function applyLoadoutToRuntime(session, resourceLoader, cwd, agentDir, request) {
|
|
87
88
|
const validation = validateLoadoutProfile(request.profile);
|
|
88
|
-
if (!validation.valid)
|
|
89
|
-
return
|
|
90
|
-
profileName: request.profile.name,
|
|
91
|
-
authority: request.profile.authority,
|
|
92
|
-
activeTools: [],
|
|
93
|
-
activeSkills: [],
|
|
94
|
-
activeMcp: [],
|
|
95
|
-
activeHooks: [],
|
|
96
|
-
schedulerFields: { readSet: [], writeSet: [], parallelizable: true },
|
|
97
|
-
blockers: validation.errors,
|
|
98
|
-
warnings: [],
|
|
99
|
-
};
|
|
100
|
-
}
|
|
89
|
+
if (!validation.valid)
|
|
90
|
+
return blockedLoadoutRuntime(request.profile, validation.errors);
|
|
101
91
|
const hookInventory = loadHookInventory(agentDir);
|
|
102
92
|
const inventory = buildCapabilityInventory(session, resourceLoader, cwd, hookInventory);
|
|
93
|
+
const shadowed = shadowedBuiltinTools(session._baseToolDefinitions.keys(), inventory);
|
|
94
|
+
if (shadowed.length > 0)
|
|
95
|
+
return blockedLoadoutRuntime(request.profile, [`loadout extension tool shadows builtin: ${shadowed.join(", ")}`]);
|
|
103
96
|
const applied = applyLoadoutProfile(request.profile, inventory, { grantAuthority: request.grantAuthority });
|
|
104
97
|
if (applied.blockers.length > 0) {
|
|
105
98
|
return {
|