open-multi-agent-kit 0.90.0 → 0.90.4
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 +56 -0
- package/README.md +22 -31
- package/dist/cli/args.d.ts +0 -2
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +1 -7
- package/dist/cli/args.js.map +1 -1
- package/dist/config.d.ts +3 -6
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +27 -19
- package/dist/config.js.map +1 -1
- package/dist/core/adaptorch-bridge.d.ts +257 -0
- package/dist/core/adaptorch-bridge.d.ts.map +1 -0
- package/dist/core/adaptorch-bridge.js +473 -0
- package/dist/core/adaptorch-bridge.js.map +1 -0
- package/dist/core/agent-session.d.ts +132 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +327 -5
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bang-skill-invocation.d.ts +26 -0
- package/dist/core/bang-skill-invocation.d.ts.map +1 -0
- package/dist/core/bang-skill-invocation.js +208 -0
- package/dist/core/bang-skill-invocation.js.map +1 -0
- package/dist/core/compaction/utils.d.ts.map +1 -1
- package/dist/core/compaction/utils.js +15 -2
- package/dist/core/compaction/utils.js.map +1 -1
- package/dist/core/compactor.d.ts.map +1 -1
- package/dist/core/compactor.js +0 -3
- package/dist/core/compactor.js.map +1 -1
- package/dist/core/context-budget-governor-v2.d.ts +2 -1
- package/dist/core/context-budget-governor-v2.d.ts.map +1 -1
- package/dist/core/context-budget-governor-v2.js +1 -0
- package/dist/core/context-budget-governor-v2.js.map +1 -1
- package/dist/core/context-budget-headroom-types.d.ts +8 -0
- package/dist/core/context-budget-headroom-types.d.ts.map +1 -1
- package/dist/core/context-budget-headroom-types.js.map +1 -1
- package/dist/core/context-budget-headroom.d.ts +1 -1
- package/dist/core/context-budget-headroom.d.ts.map +1 -1
- package/dist/core/context-budget-headroom.js +17 -4
- package/dist/core/context-budget-headroom.js.map +1 -1
- package/dist/core/context-budget-system-prompt.d.ts +2 -1
- package/dist/core/context-budget-system-prompt.d.ts.map +1 -1
- package/dist/core/context-budget-system-prompt.js +6 -1
- package/dist/core/context-budget-system-prompt.js.map +1 -1
- package/dist/core/context-budget-v2-cache-hash.d.ts +3 -0
- package/dist/core/context-budget-v2-cache-hash.d.ts.map +1 -0
- package/dist/core/context-budget-v2-cache-hash.js +16 -0
- package/dist/core/context-budget-v2-cache-hash.js.map +1 -0
- package/dist/core/context-budget-v2-cache-keys.d.ts +58 -0
- package/dist/core/context-budget-v2-cache-keys.d.ts.map +1 -0
- package/dist/core/context-budget-v2-cache-keys.js +128 -0
- package/dist/core/context-budget-v2-cache-keys.js.map +1 -0
- package/dist/core/context-budget-v2-cache-provider.d.ts +23 -0
- package/dist/core/context-budget-v2-cache-provider.d.ts.map +1 -0
- package/dist/core/context-budget-v2-cache-provider.js +29 -0
- package/dist/core/context-budget-v2-cache-provider.js.map +1 -0
- package/dist/core/context-budget-v2-cache-telemetry.d.ts +36 -0
- package/dist/core/context-budget-v2-cache-telemetry.d.ts.map +1 -0
- package/dist/core/context-budget-v2-cache-telemetry.js +64 -0
- package/dist/core/context-budget-v2-cache-telemetry.js.map +1 -0
- package/dist/core/context-budget-v2-cache-validation.d.ts +36 -0
- package/dist/core/context-budget-v2-cache-validation.d.ts.map +1 -0
- package/dist/core/context-budget-v2-cache-validation.js +98 -0
- package/dist/core/context-budget-v2-cache-validation.js.map +1 -0
- package/dist/core/context-budget-v2-cache.d.ts +36 -0
- package/dist/core/context-budget-v2-cache.d.ts.map +1 -0
- package/dist/core/context-budget-v2-cache.js +50 -0
- package/dist/core/context-budget-v2-cache.js.map +1 -0
- package/dist/core/context-budget-v2-plan-cache-keys.d.ts +16 -0
- package/dist/core/context-budget-v2-plan-cache-keys.d.ts.map +1 -0
- package/dist/core/context-budget-v2-plan-cache-keys.js +49 -0
- package/dist/core/context-budget-v2-plan-cache-keys.js.map +1 -0
- package/dist/core/context-budget-v2-planner.d.ts.map +1 -1
- package/dist/core/context-budget-v2-planner.js +55 -2
- package/dist/core/context-budget-v2-planner.js.map +1 -1
- package/dist/core/context-budget-v2-representation-cache.d.ts +27 -0
- package/dist/core/context-budget-v2-representation-cache.d.ts.map +1 -0
- package/dist/core/context-budget-v2-representation-cache.js +173 -0
- package/dist/core/context-budget-v2-representation-cache.js.map +1 -0
- package/dist/core/context-budget-v2-selection.d.ts +2 -0
- package/dist/core/context-budget-v2-selection.d.ts.map +1 -1
- package/dist/core/context-budget-v2-selection.js +12 -2
- package/dist/core/context-budget-v2-selection.js.map +1 -1
- package/dist/core/context-budget-v2-types.d.ts +107 -1
- package/dist/core/context-budget-v2-types.d.ts.map +1 -1
- package/dist/core/context-budget-v2-types.js.map +1 -1
- package/dist/core/domain-loadouts.d.ts.map +1 -1
- package/dist/core/domain-loadouts.js +1 -1
- package/dist/core/domain-loadouts.js.map +1 -1
- package/dist/core/headroom.d.ts.map +1 -1
- package/dist/core/headroom.js +0 -4
- package/dist/core/headroom.js.map +1 -1
- package/dist/core/hook-inventory.d.ts.map +1 -1
- package/dist/core/hook-inventory.js +6 -0
- package/dist/core/hook-inventory.js.map +1 -1
- package/dist/core/mcp-computer-use-presets.d.ts +64 -0
- package/dist/core/mcp-computer-use-presets.d.ts.map +1 -0
- package/dist/core/mcp-computer-use-presets.js +158 -0
- package/dist/core/mcp-computer-use-presets.js.map +1 -0
- package/dist/core/mcp-public-presets.d.ts +578 -0
- package/dist/core/mcp-public-presets.d.ts.map +1 -0
- package/dist/core/mcp-public-presets.js +647 -0
- package/dist/core/mcp-public-presets.js.map +1 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +1 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/pi-package-intake-candidates.d.ts +14 -1
- package/dist/core/pi-package-intake-candidates.d.ts.map +1 -1
- package/dist/core/pi-package-intake-candidates.js +182 -0
- package/dist/core/pi-package-intake-candidates.js.map +1 -1
- package/dist/core/pi-package-intake.d.ts +8 -1
- package/dist/core/pi-package-intake.d.ts.map +1 -1
- package/dist/core/pi-package-intake.js +14 -4
- package/dist/core/pi-package-intake.js.map +1 -1
- package/dist/core/reasoning-router-bias.d.ts +119 -0
- package/dist/core/reasoning-router-bias.d.ts.map +1 -0
- package/dist/core/reasoning-router-bias.js +287 -0
- package/dist/core/reasoning-router-bias.js.map +1 -0
- package/dist/core/reasoning-router-v2.d.ts +94 -0
- package/dist/core/reasoning-router-v2.d.ts.map +1 -0
- package/dist/core/reasoning-router-v2.js +288 -0
- package/dist/core/reasoning-router-v2.js.map +1 -0
- package/dist/core/reasoning-router-v3.d.ts +15 -0
- package/dist/core/reasoning-router-v3.d.ts.map +1 -0
- package/dist/core/reasoning-router-v3.js +193 -0
- package/dist/core/reasoning-router-v3.js.map +1 -0
- package/dist/core/reasoning-router-v4-weights.d.ts +124 -0
- package/dist/core/reasoning-router-v4-weights.d.ts.map +1 -0
- package/dist/core/reasoning-router-v4-weights.js +112 -0
- package/dist/core/reasoning-router-v4-weights.js.map +1 -0
- package/dist/core/reasoning-router-v4.d.ts +163 -0
- package/dist/core/reasoning-router-v4.d.ts.map +1 -0
- package/dist/core/reasoning-router-v4.js +683 -0
- package/dist/core/reasoning-router-v4.js.map +1 -0
- package/dist/core/reasoning-router-weights.d.ts +155 -0
- package/dist/core/reasoning-router-weights.d.ts.map +1 -0
- package/dist/core/reasoning-router-weights.js +204 -0
- package/dist/core/reasoning-router-weights.js.map +1 -0
- package/dist/core/reasoning-router.d.ts +44 -0
- package/dist/core/reasoning-router.d.ts.map +1 -0
- package/dist/core/reasoning-router.js +138 -0
- package/dist/core/reasoning-router.js.map +1 -0
- package/dist/core/reverse-skill.d.ts +2 -0
- package/dist/core/reverse-skill.d.ts.map +1 -0
- package/dist/core/reverse-skill.js +7 -0
- package/dist/core/reverse-skill.js.map +1 -0
- package/dist/core/router-feedback-collector.d.ts +101 -0
- package/dist/core/router-feedback-collector.d.ts.map +1 -0
- package/dist/core/router-feedback-collector.js +239 -0
- package/dist/core/router-feedback-collector.js.map +1 -0
- package/dist/core/settings-manager.d.ts +31 -3
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +16 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +4 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts +2 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +58 -5
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/migrations.d.ts +19 -0
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +39 -15
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/control-panel-box.d.ts +3 -3
- package/dist/modes/interactive/components/control-panel-box.d.ts.map +1 -1
- package/dist/modes/interactive/components/control-panel-box.js +10 -10
- package/dist/modes/interactive/components/control-panel-box.js.map +1 -1
- package/dist/modes/interactive/components/control-panel-gradient-motion.d.ts.map +1 -1
- package/dist/modes/interactive/components/control-panel-gradient-motion.js +2 -1
- package/dist/modes/interactive/components/control-panel-gradient-motion.js.map +1 -1
- package/dist/modes/interactive/components/control-panel-layout.d.ts +15 -1
- package/dist/modes/interactive/components/control-panel-layout.d.ts.map +1 -1
- package/dist/modes/interactive/components/control-panel-layout.js +212 -68
- package/dist/modes/interactive/components/control-panel-layout.js.map +1 -1
- package/dist/modes/interactive/components/control-panel-runtime-status.d.ts +15 -0
- package/dist/modes/interactive/components/control-panel-runtime-status.d.ts.map +1 -1
- package/dist/modes/interactive/components/control-panel-runtime-status.js +105 -5
- package/dist/modes/interactive/components/control-panel-runtime-status.js.map +1 -1
- package/dist/modes/interactive/components/control-panel-sparkles.d.ts +27 -0
- package/dist/modes/interactive/components/control-panel-sparkles.d.ts.map +1 -0
- package/dist/modes/interactive/components/control-panel-sparkles.js +42 -0
- package/dist/modes/interactive/components/control-panel-sparkles.js.map +1 -0
- package/dist/modes/interactive/components/control-panel.d.ts +8 -0
- package/dist/modes/interactive/components/control-panel.d.ts.map +1 -1
- package/dist/modes/interactive/components/control-panel.js +40 -8
- package/dist/modes/interactive/components/control-panel.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +2 -1
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +2 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +6 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +206 -32
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +2 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/docs/loadout-domains/README.md +8 -6
- package/docs/loadout-domains/ai-agent-ops.md +3 -2
- package/docs/loadout-domains/backend-api.md +3 -2
- package/docs/loadout-domains/data-science.md +3 -2
- package/docs/loadout-domains/devops-infra.md +2 -1
- package/docs/loadout-domains/docs-writing.md +7 -2
- package/docs/loadout-domains/frontend-ui.md +42 -11
- package/docs/loadout-domains/korean-document.md +83 -0
- package/docs/loadout-domains/mobile.md +1 -1
- package/docs/loadout-domains/qa-testing.md +4 -2
- package/docs/loadout-domains/security-audit.md +2 -1
- package/docs/loadout-domains/visual-qa.md +94 -0
- package/docs/skills.md +11 -4
- package/docs/usage.md +39 -4
- 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/preset.ts +2 -2
- 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 +27 -34
- package/package.json +5 -5
- package/dist/agents/jailbreak/index.d.ts +0 -7
- package/dist/agents/jailbreak/index.d.ts.map +0 -1
- package/dist/agents/jailbreak/index.js +0 -7
- package/dist/agents/jailbreak/index.js.map +0 -1
- package/dist/agents/jailbreak/subagent-f.d.ts +0 -44
- package/dist/agents/jailbreak/subagent-f.d.ts.map +0 -1
- package/dist/agents/jailbreak/subagent-f.js +0 -60
- package/dist/agents/jailbreak/subagent-f.js.map +0 -1
- package/dist/cli/jailbreak-args.d.ts +0 -26
- package/dist/cli/jailbreak-args.d.ts.map +0 -1
- package/dist/cli/jailbreak-args.js +0 -86
- package/dist/cli/jailbreak-args.js.map +0 -1
- package/dist/commands/jailbreak.d.ts +0 -49
- package/dist/commands/jailbreak.d.ts.map +0 -1
- package/dist/commands/jailbreak.js +0 -201
- package/dist/commands/jailbreak.js.map +0 -1
- package/dist/encoding/index.d.ts +0 -6
- package/dist/encoding/index.d.ts.map +0 -1
- package/dist/encoding/index.js +0 -6
- package/dist/encoding/index.js.map +0 -1
- package/dist/encoding/l4-encoder.d.ts +0 -96
- package/dist/encoding/l4-encoder.d.ts.map +0 -1
- package/dist/encoding/l4-encoder.js +0 -474
- package/dist/encoding/l4-encoder.js.map +0 -1
- package/dist/fuzzing/index.d.ts +0 -6
- package/dist/fuzzing/index.d.ts.map +0 -1
- package/dist/fuzzing/index.js +0 -6
- package/dist/fuzzing/index.js.map +0 -1
- package/dist/fuzzing/mutation-engine.d.ts +0 -93
- package/dist/fuzzing/mutation-engine.d.ts.map +0 -1
- package/dist/fuzzing/mutation-engine.js +0 -244
- package/dist/fuzzing/mutation-engine.js.map +0 -1
- package/dist/jailbreak-extension.d.ts +0 -48
- package/dist/jailbreak-extension.d.ts.map +0 -1
- package/dist/jailbreak-extension.js +0 -47
- package/dist/jailbreak-extension.js.map +0 -1
- package/dist/modules/index.d.ts +0 -8
- package/dist/modules/index.d.ts.map +0 -1
- package/dist/modules/index.js +0 -7
- package/dist/modules/index.js.map +0 -1
- package/dist/modules/lrl-bypass.d.ts +0 -40
- package/dist/modules/lrl-bypass.d.ts.map +0 -1
- package/dist/modules/lrl-bypass.js +0 -84
- package/dist/modules/lrl-bypass.js.map +0 -1
- package/dist/modules/lrl-deps.d.ts +0 -38
- package/dist/modules/lrl-deps.d.ts.map +0 -1
- package/dist/modules/lrl-deps.js +0 -128
- package/dist/modules/lrl-deps.js.map +0 -1
- package/dist/multiturn/easl-chain.d.ts +0 -113
- package/dist/multiturn/easl-chain.d.ts.map +0 -1
- package/dist/multiturn/easl-chain.js +0 -351
- package/dist/multiturn/easl-chain.js.map +0 -1
- package/dist/multiturn/index.d.ts +0 -6
- package/dist/multiturn/index.d.ts.map +0 -1
- package/dist/multiturn/index.js +0 -6
- package/dist/multiturn/index.js.map +0 -1
- package/dist/routing/fallback-router.d.ts +0 -123
- package/dist/routing/fallback-router.d.ts.map +0 -1
- package/dist/routing/fallback-router.js +0 -355
- package/dist/routing/fallback-router.js.map +0 -1
- package/dist/routing/index.d.ts +0 -6
- package/dist/routing/index.d.ts.map +0 -1
- package/dist/routing/index.js +0 -6
- package/dist/routing/index.js.map +0 -1
- package/dist/types/jailbreak.d.ts +0 -246
- package/dist/types/jailbreak.d.ts.map +0 -1
- package/dist/types/jailbreak.js +0 -8
- package/dist/types/jailbreak.js.map +0 -1
- package/dist/utils/jailbreak/common.d.ts +0 -63
- package/dist/utils/jailbreak/common.d.ts.map +0 -1
- package/dist/utils/jailbreak/common.js +0 -130
- package/dist/utils/jailbreak/common.js.map +0 -1
- package/dist/utils/jailbreak/index.d.ts +0 -7
- package/dist/utils/jailbreak/index.d.ts.map +0 -1
- package/dist/utils/jailbreak/index.js +0 -7
- package/dist/utils/jailbreak/index.js.map +0 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface BangSkillRegistry {
|
|
2
|
+
hasSkill(name: string): boolean;
|
|
3
|
+
}
|
|
4
|
+
export type BangInvocation = {
|
|
5
|
+
kind: "plain";
|
|
6
|
+
prompt: string;
|
|
7
|
+
} | {
|
|
8
|
+
kind: "empty";
|
|
9
|
+
} | {
|
|
10
|
+
kind: "bash";
|
|
11
|
+
command: string;
|
|
12
|
+
includeContext: boolean;
|
|
13
|
+
} | {
|
|
14
|
+
kind: "skill";
|
|
15
|
+
skillName: string;
|
|
16
|
+
prompt: string;
|
|
17
|
+
activeSkillNames: readonly string[];
|
|
18
|
+
source: "bang";
|
|
19
|
+
} | {
|
|
20
|
+
kind: "unknownSkill";
|
|
21
|
+
skillName: string;
|
|
22
|
+
prompt: string;
|
|
23
|
+
source: "bang";
|
|
24
|
+
};
|
|
25
|
+
export declare function parseBangInvocation(input: string, registry: BangSkillRegistry): BangInvocation;
|
|
26
|
+
//# sourceMappingURL=bang-skill-invocation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bang-skill-invocation.d.ts","sourceRoot":"","sources":["../../src/core/bang-skill-invocation.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAChC;AAmFD,MAAM,MAAM,cAAc,GACvB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,OAAO,CAAA;CAAE,GAC1D;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACzG;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/E,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,GAAG,cAAc,CA4D9F","sourcesContent":["export interface BangSkillRegistry {\n\thasSkill(name: string): boolean;\n}\n\nconst OMK_INDEX_SKILL = \"omk-skills\";\n\ninterface OmkHubRoute {\n\tskillName: string;\n\taliases: readonly string[];\n\tkeywords: readonly string[];\n}\n\nconst OMK_HUB_ROUTES: readonly OmkHubRoute[] = [\n\t{\n\t\tskillName: \"omk-frontend\",\n\t\taliases: [\"front\", \"frontend\", \"fe\", \"ui\", \"ux\", \"react\", \"next\", \"vue\", \"svelte\", \"tailwind\"],\n\t\tkeywords: [\n\t\t\t\"component\",\n\t\t\t\"css\",\n\t\t\t\"html\",\n\t\t\t\"responsive\",\n\t\t\t\"a11y\",\n\t\t\t\"accessibility\",\n\t\t\t\"visual\",\n\t\t\t\"browser\",\n\t\t\t\"design-system\",\n\t\t],\n\t},\n\t{\n\t\tskillName: \"omk-backend-data\",\n\t\taliases: [\"back\", \"backend\", \"api\", \"db\", \"data\", \"database\", \"server\", \"postgres\", \"supabase\", \"redis\"],\n\t\tkeywords: [\"endpoint\", \"migration\", \"schema\", \"orm\", \"cache\", \"queue\", \"service\", \"auth\", \"prisma\", \"mysql\"],\n\t},\n\t{\n\t\tskillName: \"omk-loop\",\n\t\taliases: [\"loop\", \"run\", \"runner\", \"ralph\", \"evolve\", \"orchestrate\", \"orchestration\", \"team\", \"parallel\"],\n\t\tkeywords: [\"subagent\", \"workflow\", \"pipeline\", \"goal\", \"dag\", \"ouroboros\", \"adaptorch\", \"continuous\"],\n\t},\n\t{\n\t\tskillName: \"omk-plan\",\n\t\taliases: [\"plan\", \"planning\", \"spec\", \"prd\", \"pm\", \"blueprint\", \"interview\", \"requirements\"],\n\t\tkeywords: [\"roadmap\", \"scope\", \"acceptance\", \"criteria\", \"architecture\", \"proposal\", \"tasks\", \"design\"],\n\t},\n\t{\n\t\tskillName: \"omk-engineering\",\n\t\taliases: [\"code\", \"coding\", \"engineering\", \"eng\", \"debug\", \"test\", \"refactor\", \"review\", \"ponytail\"],\n\t\tkeywords: [\"typescript\", \"python\", \"rust\", \"go\", \"build\", \"lint\", \"bug\", \"fix\", \"minimal\", \"yagni\"],\n\t},\n\t{\n\t\tskillName: \"omk-security\",\n\t\taliases: [\"sec\", \"security\", \"audit\", \"vuln\", \"vulnerability\", \"semgrep\", \"codeql\", \"reverse\"],\n\t\tkeywords: [\"threat\", \"secret\", \"supply\", \"chain\", \"fuzz\", \"crypto\", \"sandbox\", \"malware\"],\n\t},\n\t{\n\t\tskillName: \"omk-devops-release\",\n\t\taliases: [\"devops\", \"release\", \"deploy\", \"ci\", \"cd\", \"github\", \"gh\", \"gh-repo\", \"git\", \"repo\", \"pr\"],\n\t\tkeywords: [\"docker\", \"kubernetes\", \"vercel\", \"canary\", \"workflow\", \"changelog\", \"version\"],\n\t},\n\t{\n\t\tskillName: \"omk-research-docs\",\n\t\taliases: [\"research\", \"docs\", \"doc\", \"documentation\", \"report\", \"pdf\", \"slides\", \"paper\"],\n\t\tkeywords: [\"citation\", \"literature\", \"academic\", \"write\", \"summarize\", \"evidence\", \"source\"],\n\t},\n\t{\n\t\tskillName: \"omk-design-media\",\n\t\taliases: [\"design\", \"media\", \"image\", \"video\", \"logo\", \"icon\", \"diagram\", \"asset\"],\n\t\tkeywords: [\"brand\", \"infographic\", \"svg\", \"gif\", \"audio\", \"poster\", \"visual\", \"animation\"],\n\t},\n\t{\n\t\tskillName: \"omk-agent-ops\",\n\t\taliases: [\"agent\", \"agents\", \"ops\", \"mcp\", \"skill\", \"skills\", \"headroom\", \"context\", \"memory\"],\n\t\tkeywords: [\"omk\", \"runtime\", \"hook\", \"loadout\", \"prompt\", \"harness\", \"adaptorch\", \"ouroboros\"],\n\t},\n\t{\n\t\tskillName: \"omk-product-ops\",\n\t\taliases: [\"product\", \"growth\", \"marketing\", \"seo\", \"cro\", \"analytics\", \"launch\", \"pricing\"],\n\t\tkeywords: [\"campaign\", \"content\", \"conversion\", \"copy\", \"sales\", \"investor\", \"market\"],\n\t},\n\t{\n\t\tskillName: \"omk-workspace-ops\",\n\t\taliases: [\"workspace\", \"gmail\", \"calendar\", \"drive\", \"sheets\", \"chat\", \"tasks\", \"email\"],\n\t\tkeywords: [\"google\", \"docs\", \"slides\", \"meet\", \"people\", \"message\", \"notification\"],\n\t},\n];\n\nexport type BangInvocation =\n\t| { kind: \"plain\"; prompt: string }\n\t| { kind: \"empty\" }\n\t| { kind: \"bash\"; command: string; includeContext: boolean }\n\t| { kind: \"skill\"; skillName: string; prompt: string; activeSkillNames: readonly string[]; source: \"bang\" }\n\t| { kind: \"unknownSkill\"; skillName: string; prompt: string; source: \"bang\" };\n\nexport function parseBangInvocation(input: string, registry: BangSkillRegistry): BangInvocation {\n\tif (!input.startsWith(\"!\")) {\n\t\treturn { kind: \"plain\", prompt: input };\n\t}\n\n\tif (input.startsWith(\"!!\")) {\n\t\tconst command = input.slice(2).trim();\n\t\treturn command ? { kind: \"bash\", command, includeContext: false } : { kind: \"empty\" };\n\t}\n\n\tconst second = input[1];\n\tif (second === undefined) {\n\t\treturn { kind: \"plain\", prompt: input };\n\t}\n\n\tif (/\\s/.test(second)) {\n\t\tconst command = input.slice(2).trim();\n\t\treturn command ? { kind: \"bash\", command, includeContext: true } : { kind: \"empty\" };\n\t}\n\n\tconst body = input.slice(1);\n\tconst omkInvocation = parseOmkBangInvocation(body, registry);\n\tif (omkInvocation) {\n\t\treturn omkInvocation;\n\t}\n\n\tif (body.startsWith(\"skill:\")) {\n\t\tconst explicit = body.slice(\"skill:\".length);\n\t\tconst { token: skillName, rest } = splitFirstToken(explicit);\n\t\tif (!skillName) {\n\t\t\treturn { kind: \"plain\", prompt: input };\n\t\t}\n\t\tif (!registry.hasSkill(skillName)) {\n\t\t\treturn { kind: \"unknownSkill\", skillName, prompt: rest, source: \"bang\" };\n\t\t}\n\t\treturn {\n\t\t\tkind: \"skill\",\n\t\t\tskillName,\n\t\t\tprompt: rest,\n\t\t\tactiveSkillNames: [skillName],\n\t\t\tsource: \"bang\",\n\t\t};\n\t}\n\n\tconst { token: skillName, rest } = splitFirstToken(body);\n\tif (!skillName) {\n\t\treturn { kind: \"plain\", prompt: input };\n\t}\n\tif (registry.hasSkill(skillName)) {\n\t\treturn {\n\t\t\tkind: \"skill\",\n\t\t\tskillName,\n\t\t\tprompt: rest,\n\t\t\tactiveSkillNames: [skillName],\n\t\t\tsource: \"bang\",\n\t\t};\n\t}\n\n\tconst command = body.trim();\n\treturn command ? { kind: \"bash\", command, includeContext: true } : { kind: \"empty\" };\n}\n\nfunction parseOmkBangInvocation(body: string, registry: BangSkillRegistry): BangInvocation | null {\n\tconst { token, rest } = splitFirstToken(body);\n\tif (normalizeOmkToken(token) !== \"omk\") {\n\t\treturn null;\n\t}\n\n\tconst route = resolveOmkHubRoute(rest);\n\tconst skillName = availableOmkSkillName(route.skillName, registry);\n\tif (!skillName) {\n\t\treturn { kind: \"unknownSkill\", skillName: route.skillName, prompt: route.prompt, source: \"bang\" };\n\t}\n\n\treturn {\n\t\tkind: \"skill\",\n\t\tskillName,\n\t\tprompt: route.prompt,\n\t\tactiveSkillNames: activeOmkSkillNames(skillName, registry),\n\t\tsource: \"bang\",\n\t};\n}\n\nfunction resolveOmkHubRoute(prompt: string): { skillName: string; prompt: string } {\n\tconst { token, rest } = splitFirstToken(prompt);\n\tconst normalizedToken = normalizeOmkToken(token);\n\tif (normalizedToken) {\n\t\tconst exactRoute = OMK_HUB_ROUTES.find((route) => route.aliases.includes(normalizedToken));\n\t\tif (exactRoute) {\n\t\t\treturn { skillName: exactRoute.skillName, prompt: rest };\n\t\t}\n\t}\n\n\tconst scored = OMK_HUB_ROUTES.map((route, index) => ({ route, index, score: scoreOmkRoute(route, prompt) }))\n\t\t.filter((entry) => entry.score > 0)\n\t\t.sort((a, b) => b.score - a.score || a.index - b.index);\n\n\tconst best = scored[0];\n\tif (best) {\n\t\treturn { skillName: best.route.skillName, prompt: prompt.trimStart() };\n\t}\n\n\treturn { skillName: OMK_INDEX_SKILL, prompt: prompt.trimStart() };\n}\n\nfunction availableOmkSkillName(skillName: string, registry: BangSkillRegistry): string | null {\n\tif (registry.hasSkill(skillName)) {\n\t\treturn skillName;\n\t}\n\tif (skillName !== OMK_INDEX_SKILL && registry.hasSkill(OMK_INDEX_SKILL)) {\n\t\treturn OMK_INDEX_SKILL;\n\t}\n\treturn null;\n}\n\nfunction activeOmkSkillNames(skillName: string, registry: BangSkillRegistry): readonly string[] {\n\tif (skillName !== OMK_INDEX_SKILL && registry.hasSkill(OMK_INDEX_SKILL)) {\n\t\treturn [OMK_INDEX_SKILL, skillName];\n\t}\n\treturn [skillName];\n}\n\nfunction scoreOmkRoute(route: OmkHubRoute, prompt: string): number {\n\tconst tokens = new Set(\n\t\tprompt\n\t\t\t.split(/[^\\p{L}\\p{N}-]+/u)\n\t\t\t.map(normalizeOmkToken)\n\t\t\t.filter(Boolean),\n\t);\n\tlet score = 0;\n\tfor (const alias of route.aliases) {\n\t\tif (tokens.has(alias)) {\n\t\t\tscore += 4;\n\t\t}\n\t}\n\tfor (const keyword of route.keywords) {\n\t\tif (tokens.has(keyword)) {\n\t\t\tscore += 2;\n\t\t}\n\t}\n\treturn score;\n}\n\nfunction normalizeOmkToken(token: string): string {\n\treturn token.trim().toLowerCase().replace(/^omk-/, \"\").replace(/_/g, \"-\");\n}\n\nfunction splitFirstToken(input: string): { token: string; rest: string } {\n\tconst trimmed = input.trimStart();\n\tconst match = /^([^\\s]+)(?:\\s+([\\s\\S]*))?$/.exec(trimmed);\n\tif (!match) {\n\t\treturn { token: \"\", rest: \"\" };\n\t}\n\treturn { token: match[1] ?? \"\", rest: match[2]?.trimStart() ?? \"\" };\n}\n"]}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
const OMK_INDEX_SKILL = "omk-skills";
|
|
2
|
+
const OMK_HUB_ROUTES = [
|
|
3
|
+
{
|
|
4
|
+
skillName: "omk-frontend",
|
|
5
|
+
aliases: ["front", "frontend", "fe", "ui", "ux", "react", "next", "vue", "svelte", "tailwind"],
|
|
6
|
+
keywords: [
|
|
7
|
+
"component",
|
|
8
|
+
"css",
|
|
9
|
+
"html",
|
|
10
|
+
"responsive",
|
|
11
|
+
"a11y",
|
|
12
|
+
"accessibility",
|
|
13
|
+
"visual",
|
|
14
|
+
"browser",
|
|
15
|
+
"design-system",
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
skillName: "omk-backend-data",
|
|
20
|
+
aliases: ["back", "backend", "api", "db", "data", "database", "server", "postgres", "supabase", "redis"],
|
|
21
|
+
keywords: ["endpoint", "migration", "schema", "orm", "cache", "queue", "service", "auth", "prisma", "mysql"],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
skillName: "omk-loop",
|
|
25
|
+
aliases: ["loop", "run", "runner", "ralph", "evolve", "orchestrate", "orchestration", "team", "parallel"],
|
|
26
|
+
keywords: ["subagent", "workflow", "pipeline", "goal", "dag", "ouroboros", "adaptorch", "continuous"],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
skillName: "omk-plan",
|
|
30
|
+
aliases: ["plan", "planning", "spec", "prd", "pm", "blueprint", "interview", "requirements"],
|
|
31
|
+
keywords: ["roadmap", "scope", "acceptance", "criteria", "architecture", "proposal", "tasks", "design"],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
skillName: "omk-engineering",
|
|
35
|
+
aliases: ["code", "coding", "engineering", "eng", "debug", "test", "refactor", "review", "ponytail"],
|
|
36
|
+
keywords: ["typescript", "python", "rust", "go", "build", "lint", "bug", "fix", "minimal", "yagni"],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
skillName: "omk-security",
|
|
40
|
+
aliases: ["sec", "security", "audit", "vuln", "vulnerability", "semgrep", "codeql", "reverse"],
|
|
41
|
+
keywords: ["threat", "secret", "supply", "chain", "fuzz", "crypto", "sandbox", "malware"],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
skillName: "omk-devops-release",
|
|
45
|
+
aliases: ["devops", "release", "deploy", "ci", "cd", "github", "gh", "gh-repo", "git", "repo", "pr"],
|
|
46
|
+
keywords: ["docker", "kubernetes", "vercel", "canary", "workflow", "changelog", "version"],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
skillName: "omk-research-docs",
|
|
50
|
+
aliases: ["research", "docs", "doc", "documentation", "report", "pdf", "slides", "paper"],
|
|
51
|
+
keywords: ["citation", "literature", "academic", "write", "summarize", "evidence", "source"],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
skillName: "omk-design-media",
|
|
55
|
+
aliases: ["design", "media", "image", "video", "logo", "icon", "diagram", "asset"],
|
|
56
|
+
keywords: ["brand", "infographic", "svg", "gif", "audio", "poster", "visual", "animation"],
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
skillName: "omk-agent-ops",
|
|
60
|
+
aliases: ["agent", "agents", "ops", "mcp", "skill", "skills", "headroom", "context", "memory"],
|
|
61
|
+
keywords: ["omk", "runtime", "hook", "loadout", "prompt", "harness", "adaptorch", "ouroboros"],
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
skillName: "omk-product-ops",
|
|
65
|
+
aliases: ["product", "growth", "marketing", "seo", "cro", "analytics", "launch", "pricing"],
|
|
66
|
+
keywords: ["campaign", "content", "conversion", "copy", "sales", "investor", "market"],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
skillName: "omk-workspace-ops",
|
|
70
|
+
aliases: ["workspace", "gmail", "calendar", "drive", "sheets", "chat", "tasks", "email"],
|
|
71
|
+
keywords: ["google", "docs", "slides", "meet", "people", "message", "notification"],
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
export function parseBangInvocation(input, registry) {
|
|
75
|
+
if (!input.startsWith("!")) {
|
|
76
|
+
return { kind: "plain", prompt: input };
|
|
77
|
+
}
|
|
78
|
+
if (input.startsWith("!!")) {
|
|
79
|
+
const command = input.slice(2).trim();
|
|
80
|
+
return command ? { kind: "bash", command, includeContext: false } : { kind: "empty" };
|
|
81
|
+
}
|
|
82
|
+
const second = input[1];
|
|
83
|
+
if (second === undefined) {
|
|
84
|
+
return { kind: "plain", prompt: input };
|
|
85
|
+
}
|
|
86
|
+
if (/\s/.test(second)) {
|
|
87
|
+
const command = input.slice(2).trim();
|
|
88
|
+
return command ? { kind: "bash", command, includeContext: true } : { kind: "empty" };
|
|
89
|
+
}
|
|
90
|
+
const body = input.slice(1);
|
|
91
|
+
const omkInvocation = parseOmkBangInvocation(body, registry);
|
|
92
|
+
if (omkInvocation) {
|
|
93
|
+
return omkInvocation;
|
|
94
|
+
}
|
|
95
|
+
if (body.startsWith("skill:")) {
|
|
96
|
+
const explicit = body.slice("skill:".length);
|
|
97
|
+
const { token: skillName, rest } = splitFirstToken(explicit);
|
|
98
|
+
if (!skillName) {
|
|
99
|
+
return { kind: "plain", prompt: input };
|
|
100
|
+
}
|
|
101
|
+
if (!registry.hasSkill(skillName)) {
|
|
102
|
+
return { kind: "unknownSkill", skillName, prompt: rest, source: "bang" };
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
kind: "skill",
|
|
106
|
+
skillName,
|
|
107
|
+
prompt: rest,
|
|
108
|
+
activeSkillNames: [skillName],
|
|
109
|
+
source: "bang",
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
const { token: skillName, rest } = splitFirstToken(body);
|
|
113
|
+
if (!skillName) {
|
|
114
|
+
return { kind: "plain", prompt: input };
|
|
115
|
+
}
|
|
116
|
+
if (registry.hasSkill(skillName)) {
|
|
117
|
+
return {
|
|
118
|
+
kind: "skill",
|
|
119
|
+
skillName,
|
|
120
|
+
prompt: rest,
|
|
121
|
+
activeSkillNames: [skillName],
|
|
122
|
+
source: "bang",
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const command = body.trim();
|
|
126
|
+
return command ? { kind: "bash", command, includeContext: true } : { kind: "empty" };
|
|
127
|
+
}
|
|
128
|
+
function parseOmkBangInvocation(body, registry) {
|
|
129
|
+
const { token, rest } = splitFirstToken(body);
|
|
130
|
+
if (normalizeOmkToken(token) !== "omk") {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
const route = resolveOmkHubRoute(rest);
|
|
134
|
+
const skillName = availableOmkSkillName(route.skillName, registry);
|
|
135
|
+
if (!skillName) {
|
|
136
|
+
return { kind: "unknownSkill", skillName: route.skillName, prompt: route.prompt, source: "bang" };
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
kind: "skill",
|
|
140
|
+
skillName,
|
|
141
|
+
prompt: route.prompt,
|
|
142
|
+
activeSkillNames: activeOmkSkillNames(skillName, registry),
|
|
143
|
+
source: "bang",
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function resolveOmkHubRoute(prompt) {
|
|
147
|
+
const { token, rest } = splitFirstToken(prompt);
|
|
148
|
+
const normalizedToken = normalizeOmkToken(token);
|
|
149
|
+
if (normalizedToken) {
|
|
150
|
+
const exactRoute = OMK_HUB_ROUTES.find((route) => route.aliases.includes(normalizedToken));
|
|
151
|
+
if (exactRoute) {
|
|
152
|
+
return { skillName: exactRoute.skillName, prompt: rest };
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const scored = OMK_HUB_ROUTES.map((route, index) => ({ route, index, score: scoreOmkRoute(route, prompt) }))
|
|
156
|
+
.filter((entry) => entry.score > 0)
|
|
157
|
+
.sort((a, b) => b.score - a.score || a.index - b.index);
|
|
158
|
+
const best = scored[0];
|
|
159
|
+
if (best) {
|
|
160
|
+
return { skillName: best.route.skillName, prompt: prompt.trimStart() };
|
|
161
|
+
}
|
|
162
|
+
return { skillName: OMK_INDEX_SKILL, prompt: prompt.trimStart() };
|
|
163
|
+
}
|
|
164
|
+
function availableOmkSkillName(skillName, registry) {
|
|
165
|
+
if (registry.hasSkill(skillName)) {
|
|
166
|
+
return skillName;
|
|
167
|
+
}
|
|
168
|
+
if (skillName !== OMK_INDEX_SKILL && registry.hasSkill(OMK_INDEX_SKILL)) {
|
|
169
|
+
return OMK_INDEX_SKILL;
|
|
170
|
+
}
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
function activeOmkSkillNames(skillName, registry) {
|
|
174
|
+
if (skillName !== OMK_INDEX_SKILL && registry.hasSkill(OMK_INDEX_SKILL)) {
|
|
175
|
+
return [OMK_INDEX_SKILL, skillName];
|
|
176
|
+
}
|
|
177
|
+
return [skillName];
|
|
178
|
+
}
|
|
179
|
+
function scoreOmkRoute(route, prompt) {
|
|
180
|
+
const tokens = new Set(prompt
|
|
181
|
+
.split(/[^\p{L}\p{N}-]+/u)
|
|
182
|
+
.map(normalizeOmkToken)
|
|
183
|
+
.filter(Boolean));
|
|
184
|
+
let score = 0;
|
|
185
|
+
for (const alias of route.aliases) {
|
|
186
|
+
if (tokens.has(alias)) {
|
|
187
|
+
score += 4;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
for (const keyword of route.keywords) {
|
|
191
|
+
if (tokens.has(keyword)) {
|
|
192
|
+
score += 2;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return score;
|
|
196
|
+
}
|
|
197
|
+
function normalizeOmkToken(token) {
|
|
198
|
+
return token.trim().toLowerCase().replace(/^omk-/, "").replace(/_/g, "-");
|
|
199
|
+
}
|
|
200
|
+
function splitFirstToken(input) {
|
|
201
|
+
const trimmed = input.trimStart();
|
|
202
|
+
const match = /^([^\s]+)(?:\s+([\s\S]*))?$/.exec(trimmed);
|
|
203
|
+
if (!match) {
|
|
204
|
+
return { token: "", rest: "" };
|
|
205
|
+
}
|
|
206
|
+
return { token: match[1] ?? "", rest: match[2]?.trimStart() ?? "" };
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=bang-skill-invocation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bang-skill-invocation.js","sourceRoot":"","sources":["../../src/core/bang-skill-invocation.ts"],"names":[],"mappings":"AAIA,MAAM,eAAe,GAAG,YAAY,CAAC;AAQrC,MAAM,cAAc,GAA2B;IAC9C;QACC,SAAS,EAAE,cAAc;QACzB,OAAO,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,CAAC;QAC9F,QAAQ,EAAE;YACT,WAAW;YACX,KAAK;YACL,MAAM;YACN,YAAY;YACZ,MAAM;YACN,eAAe;YACf,QAAQ;YACR,SAAS;YACT,eAAe;SACf;KACD;IACD;QACC,SAAS,EAAE,kBAAkB;QAC7B,OAAO,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC;QACxG,QAAQ,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC;KAC5G;IACD;QACC,SAAS,EAAE,UAAU;QACrB,OAAO,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,CAAC;QACzG,QAAQ,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,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AAG,KAAK,CAAC,SAAS,EAAE,CAAC;IAClC,MAAM,KAAK,GAAG,6BAA6B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1D,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IAChC,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;AAAA,CACpE","sourcesContent":["export interface BangSkillRegistry {\n\thasSkill(name: string): boolean;\n}\n\nconst OMK_INDEX_SKILL = \"omk-skills\";\n\ninterface OmkHubRoute {\n\tskillName: string;\n\taliases: readonly string[];\n\tkeywords: readonly string[];\n}\n\nconst OMK_HUB_ROUTES: readonly OmkHubRoute[] = [\n\t{\n\t\tskillName: \"omk-frontend\",\n\t\taliases: [\"front\", \"frontend\", \"fe\", \"ui\", \"ux\", \"react\", \"next\", \"vue\", \"svelte\", \"tailwind\"],\n\t\tkeywords: [\n\t\t\t\"component\",\n\t\t\t\"css\",\n\t\t\t\"html\",\n\t\t\t\"responsive\",\n\t\t\t\"a11y\",\n\t\t\t\"accessibility\",\n\t\t\t\"visual\",\n\t\t\t\"browser\",\n\t\t\t\"design-system\",\n\t\t],\n\t},\n\t{\n\t\tskillName: \"omk-backend-data\",\n\t\taliases: [\"back\", \"backend\", \"api\", \"db\", \"data\", \"database\", \"server\", \"postgres\", \"supabase\", \"redis\"],\n\t\tkeywords: [\"endpoint\", \"migration\", \"schema\", \"orm\", \"cache\", \"queue\", \"service\", \"auth\", \"prisma\", \"mysql\"],\n\t},\n\t{\n\t\tskillName: \"omk-loop\",\n\t\taliases: [\"loop\", \"run\", \"runner\", \"ralph\", \"evolve\", \"orchestrate\", \"orchestration\", \"team\", \"parallel\"],\n\t\tkeywords: [\"subagent\", \"workflow\", \"pipeline\", \"goal\", \"dag\", \"ouroboros\", \"adaptorch\", \"continuous\"],\n\t},\n\t{\n\t\tskillName: \"omk-plan\",\n\t\taliases: [\"plan\", \"planning\", \"spec\", \"prd\", \"pm\", \"blueprint\", \"interview\", \"requirements\"],\n\t\tkeywords: [\"roadmap\", \"scope\", \"acceptance\", \"criteria\", \"architecture\", \"proposal\", \"tasks\", \"design\"],\n\t},\n\t{\n\t\tskillName: \"omk-engineering\",\n\t\taliases: [\"code\", \"coding\", \"engineering\", \"eng\", \"debug\", \"test\", \"refactor\", \"review\", \"ponytail\"],\n\t\tkeywords: [\"typescript\", \"python\", \"rust\", \"go\", \"build\", \"lint\", \"bug\", \"fix\", \"minimal\", \"yagni\"],\n\t},\n\t{\n\t\tskillName: \"omk-security\",\n\t\taliases: [\"sec\", \"security\", \"audit\", \"vuln\", \"vulnerability\", \"semgrep\", \"codeql\", \"reverse\"],\n\t\tkeywords: [\"threat\", \"secret\", \"supply\", \"chain\", \"fuzz\", \"crypto\", \"sandbox\", \"malware\"],\n\t},\n\t{\n\t\tskillName: \"omk-devops-release\",\n\t\taliases: [\"devops\", \"release\", \"deploy\", \"ci\", \"cd\", \"github\", \"gh\", \"gh-repo\", \"git\", \"repo\", \"pr\"],\n\t\tkeywords: [\"docker\", \"kubernetes\", \"vercel\", \"canary\", \"workflow\", \"changelog\", \"version\"],\n\t},\n\t{\n\t\tskillName: \"omk-research-docs\",\n\t\taliases: [\"research\", \"docs\", \"doc\", \"documentation\", \"report\", \"pdf\", \"slides\", \"paper\"],\n\t\tkeywords: [\"citation\", \"literature\", \"academic\", \"write\", \"summarize\", \"evidence\", \"source\"],\n\t},\n\t{\n\t\tskillName: \"omk-design-media\",\n\t\taliases: [\"design\", \"media\", \"image\", \"video\", \"logo\", \"icon\", \"diagram\", \"asset\"],\n\t\tkeywords: [\"brand\", \"infographic\", \"svg\", \"gif\", \"audio\", \"poster\", \"visual\", \"animation\"],\n\t},\n\t{\n\t\tskillName: \"omk-agent-ops\",\n\t\taliases: [\"agent\", \"agents\", \"ops\", \"mcp\", \"skill\", \"skills\", \"headroom\", \"context\", \"memory\"],\n\t\tkeywords: [\"omk\", \"runtime\", \"hook\", \"loadout\", \"prompt\", \"harness\", \"adaptorch\", \"ouroboros\"],\n\t},\n\t{\n\t\tskillName: \"omk-product-ops\",\n\t\taliases: [\"product\", \"growth\", \"marketing\", \"seo\", \"cro\", \"analytics\", \"launch\", \"pricing\"],\n\t\tkeywords: [\"campaign\", \"content\", \"conversion\", \"copy\", \"sales\", \"investor\", \"market\"],\n\t},\n\t{\n\t\tskillName: \"omk-workspace-ops\",\n\t\taliases: [\"workspace\", \"gmail\", \"calendar\", \"drive\", \"sheets\", \"chat\", \"tasks\", \"email\"],\n\t\tkeywords: [\"google\", \"docs\", \"slides\", \"meet\", \"people\", \"message\", \"notification\"],\n\t},\n];\n\nexport type BangInvocation =\n\t| { kind: \"plain\"; prompt: string }\n\t| { kind: \"empty\" }\n\t| { kind: \"bash\"; command: string; includeContext: boolean }\n\t| { kind: \"skill\"; skillName: string; prompt: string; activeSkillNames: readonly string[]; source: \"bang\" }\n\t| { kind: \"unknownSkill\"; skillName: string; prompt: string; source: \"bang\" };\n\nexport function parseBangInvocation(input: string, registry: BangSkillRegistry): BangInvocation {\n\tif (!input.startsWith(\"!\")) {\n\t\treturn { kind: \"plain\", prompt: input };\n\t}\n\n\tif (input.startsWith(\"!!\")) {\n\t\tconst command = input.slice(2).trim();\n\t\treturn command ? { kind: \"bash\", command, includeContext: false } : { kind: \"empty\" };\n\t}\n\n\tconst second = input[1];\n\tif (second === undefined) {\n\t\treturn { kind: \"plain\", prompt: input };\n\t}\n\n\tif (/\\s/.test(second)) {\n\t\tconst command = input.slice(2).trim();\n\t\treturn command ? { kind: \"bash\", command, includeContext: true } : { kind: \"empty\" };\n\t}\n\n\tconst body = input.slice(1);\n\tconst omkInvocation = parseOmkBangInvocation(body, registry);\n\tif (omkInvocation) {\n\t\treturn omkInvocation;\n\t}\n\n\tif (body.startsWith(\"skill:\")) {\n\t\tconst explicit = body.slice(\"skill:\".length);\n\t\tconst { token: skillName, rest } = splitFirstToken(explicit);\n\t\tif (!skillName) {\n\t\t\treturn { kind: \"plain\", prompt: input };\n\t\t}\n\t\tif (!registry.hasSkill(skillName)) {\n\t\t\treturn { kind: \"unknownSkill\", skillName, prompt: rest, source: \"bang\" };\n\t\t}\n\t\treturn {\n\t\t\tkind: \"skill\",\n\t\t\tskillName,\n\t\t\tprompt: rest,\n\t\t\tactiveSkillNames: [skillName],\n\t\t\tsource: \"bang\",\n\t\t};\n\t}\n\n\tconst { token: skillName, rest } = splitFirstToken(body);\n\tif (!skillName) {\n\t\treturn { kind: \"plain\", prompt: input };\n\t}\n\tif (registry.hasSkill(skillName)) {\n\t\treturn {\n\t\t\tkind: \"skill\",\n\t\t\tskillName,\n\t\t\tprompt: rest,\n\t\t\tactiveSkillNames: [skillName],\n\t\t\tsource: \"bang\",\n\t\t};\n\t}\n\n\tconst command = body.trim();\n\treturn command ? { kind: \"bash\", command, includeContext: true } : { kind: \"empty\" };\n}\n\nfunction parseOmkBangInvocation(body: string, registry: BangSkillRegistry): BangInvocation | null {\n\tconst { token, rest } = splitFirstToken(body);\n\tif (normalizeOmkToken(token) !== \"omk\") {\n\t\treturn null;\n\t}\n\n\tconst route = resolveOmkHubRoute(rest);\n\tconst skillName = availableOmkSkillName(route.skillName, registry);\n\tif (!skillName) {\n\t\treturn { kind: \"unknownSkill\", skillName: route.skillName, prompt: route.prompt, source: \"bang\" };\n\t}\n\n\treturn {\n\t\tkind: \"skill\",\n\t\tskillName,\n\t\tprompt: route.prompt,\n\t\tactiveSkillNames: activeOmkSkillNames(skillName, registry),\n\t\tsource: \"bang\",\n\t};\n}\n\nfunction resolveOmkHubRoute(prompt: string): { skillName: string; prompt: string } {\n\tconst { token, rest } = splitFirstToken(prompt);\n\tconst normalizedToken = normalizeOmkToken(token);\n\tif (normalizedToken) {\n\t\tconst exactRoute = OMK_HUB_ROUTES.find((route) => route.aliases.includes(normalizedToken));\n\t\tif (exactRoute) {\n\t\t\treturn { skillName: exactRoute.skillName, prompt: rest };\n\t\t}\n\t}\n\n\tconst scored = OMK_HUB_ROUTES.map((route, index) => ({ route, index, score: scoreOmkRoute(route, prompt) }))\n\t\t.filter((entry) => entry.score > 0)\n\t\t.sort((a, b) => b.score - a.score || a.index - b.index);\n\n\tconst best = scored[0];\n\tif (best) {\n\t\treturn { skillName: best.route.skillName, prompt: prompt.trimStart() };\n\t}\n\n\treturn { skillName: OMK_INDEX_SKILL, prompt: prompt.trimStart() };\n}\n\nfunction availableOmkSkillName(skillName: string, registry: BangSkillRegistry): string | null {\n\tif (registry.hasSkill(skillName)) {\n\t\treturn skillName;\n\t}\n\tif (skillName !== OMK_INDEX_SKILL && registry.hasSkill(OMK_INDEX_SKILL)) {\n\t\treturn OMK_INDEX_SKILL;\n\t}\n\treturn null;\n}\n\nfunction activeOmkSkillNames(skillName: string, registry: BangSkillRegistry): readonly string[] {\n\tif (skillName !== OMK_INDEX_SKILL && registry.hasSkill(OMK_INDEX_SKILL)) {\n\t\treturn [OMK_INDEX_SKILL, skillName];\n\t}\n\treturn [skillName];\n}\n\nfunction scoreOmkRoute(route: OmkHubRoute, prompt: string): number {\n\tconst tokens = new Set(\n\t\tprompt\n\t\t\t.split(/[^\\p{L}\\p{N}-]+/u)\n\t\t\t.map(normalizeOmkToken)\n\t\t\t.filter(Boolean),\n\t);\n\tlet score = 0;\n\tfor (const alias of route.aliases) {\n\t\tif (tokens.has(alias)) {\n\t\t\tscore += 4;\n\t\t}\n\t}\n\tfor (const keyword of route.keywords) {\n\t\tif (tokens.has(keyword)) {\n\t\t\tscore += 2;\n\t\t}\n\t}\n\treturn score;\n}\n\nfunction normalizeOmkToken(token: string): string {\n\treturn token.trim().toLowerCase().replace(/^omk-/, \"\").replace(/_/g, \"-\");\n}\n\nfunction splitFirstToken(input: string): { token: string; rest: string } {\n\tconst trimmed = input.trimStart();\n\tconst match = /^([^\\s]+)(?:\\s+([\\s\\S]*))?$/.exec(trimmed);\n\tif (!match) {\n\t\treturn { token: \"\", rest: \"\" };\n\t}\n\treturn { token: match[1] ?? \"\", rest: match[2]?.trimStart() ?? \"\" };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/core/compaction/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAMtC,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClB,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACrB,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACpB;AAED,wBAAgB,aAAa,IAAI,cAAc,CAM9C;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CA2B9F;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,cAAc,GAAG;IAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAA;CAAE,CAK1G;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,MAAM,CAUzF;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/core/compaction/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAMtC,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClB,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACrB,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACpB;AAED,wBAAgB,aAAa,IAAI,cAAc,CAM9C;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CA2B9F;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,cAAc,GAAG;IAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAA;CAAE,CAK1G;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,MAAM,CAUzF;AAkCD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,CAqDjE;AAMD,eAAO,MAAM,2BAA2B,oUAEmF,CAAC","sourcesContent":["/**\n * Shared utilities for compaction and branch summarization.\n */\n\nimport type { AgentMessage } from \"omk-agent-core\";\nimport type { Message } from \"omk-ai\";\n\n// ============================================================================\n// File Operation Tracking\n// ============================================================================\n\nexport interface FileOperations {\n\tread: Set<string>;\n\twritten: Set<string>;\n\tedited: Set<string>;\n}\n\nexport function createFileOps(): FileOperations {\n\treturn {\n\t\tread: new Set(),\n\t\twritten: new Set(),\n\t\tedited: new Set(),\n\t};\n}\n\n/**\n * Extract file operations from tool calls in an assistant message.\n */\nexport function extractFileOpsFromMessage(message: AgentMessage, fileOps: FileOperations): void {\n\tif (message.role !== \"assistant\") return;\n\tif (!(\"content\" in message) || !Array.isArray(message.content)) return;\n\n\tfor (const block of message.content) {\n\t\tif (typeof block !== \"object\" || block === null) continue;\n\t\tif (!(\"type\" in block) || block.type !== \"toolCall\") continue;\n\t\tif (!(\"arguments\" in block) || !(\"name\" in block)) continue;\n\n\t\tconst args = block.arguments as Record<string, unknown> | undefined;\n\t\tif (!args) continue;\n\n\t\tconst path = typeof args.path === \"string\" ? args.path : undefined;\n\t\tif (!path) continue;\n\n\t\tswitch (block.name) {\n\t\t\tcase \"read\":\n\t\t\t\tfileOps.read.add(path);\n\t\t\t\tbreak;\n\t\t\tcase \"write\":\n\t\t\t\tfileOps.written.add(path);\n\t\t\t\tbreak;\n\t\t\tcase \"edit\":\n\t\t\t\tfileOps.edited.add(path);\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/**\n * Compute final file lists from file operations.\n * Returns readFiles (files only read, not modified) and modifiedFiles.\n */\nexport function computeFileLists(fileOps: FileOperations): { readFiles: string[]; modifiedFiles: string[] } {\n\tconst modified = new Set([...fileOps.edited, ...fileOps.written]);\n\tconst readOnly = [...fileOps.read].filter((f) => !modified.has(f)).sort();\n\tconst modifiedFiles = [...modified].sort();\n\treturn { readFiles: readOnly, modifiedFiles };\n}\n\n/**\n * Format file operations as XML tags for summary.\n */\nexport function formatFileOperations(readFiles: string[], modifiedFiles: string[]): string {\n\tconst sections: string[] = [];\n\tif (readFiles.length > 0) {\n\t\tsections.push(`<read-files>\\n${readFiles.join(\"\\n\")}\\n</read-files>`);\n\t}\n\tif (modifiedFiles.length > 0) {\n\t\tsections.push(`<modified-files>\\n${modifiedFiles.join(\"\\n\")}\\n</modified-files>`);\n\t}\n\tif (sections.length === 0) return \"\";\n\treturn `\\n\\n${sections.join(\"\\n\\n\")}`;\n}\n\n// ============================================================================\n// Message Serialization\n// ============================================================================\n\n/** Maximum characters for a tool result in serialized summaries. */\nconst TOOL_RESULT_MAX_CHARS = 2000;\n\n/** Maximum characters for a single serialized tool-call argument. */\nconst TOOL_CALL_ARGUMENT_MAX_CHARS = 500;\n\n/** Maximum characters for all tool calls in one assistant message. */\nconst TOOL_CALLS_MAX_CHARS = 4000;\n\n/**\n * Truncate text to a maximum character length for summarization.\n * Keeps the beginning and appends a truncation marker.\n */\nfunction truncateForSummary(text: string, maxChars: number): string {\n\tif (text.length <= maxChars) return text;\n\tconst truncatedChars = text.length - maxChars;\n\treturn `${text.slice(0, maxChars)}\\n\\n[... ${truncatedChars} more characters truncated]`;\n}\n\nfunction stringifyToolCallArgument(value: unknown): string {\n\ttry {\n\t\tconst serialized = JSON.stringify(value);\n\t\treturn truncateForSummary(serialized ?? String(value), TOOL_CALL_ARGUMENT_MAX_CHARS);\n\t} catch {\n\t\treturn truncateForSummary(String(value), TOOL_CALL_ARGUMENT_MAX_CHARS);\n\t}\n}\n\n/**\n * Serialize LLM messages to text for summarization.\n * This prevents the model from treating it as a conversation to continue.\n * Call convertToLlm() first to handle custom message types.\n *\n * Tool results are truncated to keep the summarization request within\n * reasonable token budgets. Full content is not needed for summarization.\n */\nexport function serializeConversation(messages: Message[]): string {\n\tconst parts: string[] = [];\n\n\tfor (const msg of messages) {\n\t\tif (msg.role === \"user\") {\n\t\t\tconst content =\n\t\t\t\ttypeof msg.content === \"string\"\n\t\t\t\t\t? msg.content\n\t\t\t\t\t: msg.content\n\t\t\t\t\t\t\t.filter((c): c is { type: \"text\"; text: string } => c.type === \"text\")\n\t\t\t\t\t\t\t.map((c) => c.text)\n\t\t\t\t\t\t\t.join(\"\");\n\t\t\tif (content) parts.push(`[User]: ${content}`);\n\t\t} else if (msg.role === \"assistant\") {\n\t\t\tconst textParts: string[] = [];\n\t\t\tconst thinkingParts: string[] = [];\n\t\t\tconst toolCalls: string[] = [];\n\n\t\t\tfor (const block of msg.content) {\n\t\t\t\tif (block.type === \"text\") {\n\t\t\t\t\ttextParts.push(block.text);\n\t\t\t\t} else if (block.type === \"thinking\") {\n\t\t\t\t\tthinkingParts.push(block.thinking);\n\t\t\t\t} else if (block.type === \"toolCall\") {\n\t\t\t\t\tconst args = block.arguments as Record<string, unknown>;\n\t\t\t\t\tconst argsStr = Object.entries(args)\n\t\t\t\t\t\t.map(([k, v]) => `${k}=${stringifyToolCallArgument(v)}`)\n\t\t\t\t\t\t.join(\", \");\n\t\t\t\t\ttoolCalls.push(`${block.name}(${argsStr})`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (thinkingParts.length > 0) {\n\t\t\t\tparts.push(`[Assistant thinking]: ${thinkingParts.join(\"\\n\")}`);\n\t\t\t}\n\t\t\tif (textParts.length > 0) {\n\t\t\t\tparts.push(`[Assistant]: ${textParts.join(\"\\n\")}`);\n\t\t\t}\n\t\t\tif (toolCalls.length > 0) {\n\t\t\t\tparts.push(`[Assistant tool calls]: ${truncateForSummary(toolCalls.join(\"; \"), TOOL_CALLS_MAX_CHARS)}`);\n\t\t\t}\n\t\t} else if (msg.role === \"toolResult\") {\n\t\t\tconst content = msg.content\n\t\t\t\t.filter((c): c is { type: \"text\"; text: string } => c.type === \"text\")\n\t\t\t\t.map((c) => c.text)\n\t\t\t\t.join(\"\");\n\t\t\tif (content) {\n\t\t\t\tparts.push(`[Tool result]: ${truncateForSummary(content, TOOL_RESULT_MAX_CHARS)}`);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn parts.join(\"\\n\\n\");\n}\n\n// ============================================================================\n// Summarization System Prompt\n// ============================================================================\n\nexport const SUMMARIZATION_SYSTEM_PROMPT = `You are a context summarization assistant. Your task is to read a conversation between a user and an AI coding assistant, then produce a structured summary following the exact format specified.\n\nDo NOT continue the conversation. Do NOT respond to any questions in the conversation. ONLY output the structured summary.`;\n"]}
|
|
@@ -72,6 +72,10 @@ export function formatFileOperations(readFiles, modifiedFiles) {
|
|
|
72
72
|
// ============================================================================
|
|
73
73
|
/** Maximum characters for a tool result in serialized summaries. */
|
|
74
74
|
const TOOL_RESULT_MAX_CHARS = 2000;
|
|
75
|
+
/** Maximum characters for a single serialized tool-call argument. */
|
|
76
|
+
const TOOL_CALL_ARGUMENT_MAX_CHARS = 500;
|
|
77
|
+
/** Maximum characters for all tool calls in one assistant message. */
|
|
78
|
+
const TOOL_CALLS_MAX_CHARS = 4000;
|
|
75
79
|
/**
|
|
76
80
|
* Truncate text to a maximum character length for summarization.
|
|
77
81
|
* Keeps the beginning and appends a truncation marker.
|
|
@@ -82,6 +86,15 @@ function truncateForSummary(text, maxChars) {
|
|
|
82
86
|
const truncatedChars = text.length - maxChars;
|
|
83
87
|
return `${text.slice(0, maxChars)}\n\n[... ${truncatedChars} more characters truncated]`;
|
|
84
88
|
}
|
|
89
|
+
function stringifyToolCallArgument(value) {
|
|
90
|
+
try {
|
|
91
|
+
const serialized = JSON.stringify(value);
|
|
92
|
+
return truncateForSummary(serialized ?? String(value), TOOL_CALL_ARGUMENT_MAX_CHARS);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return truncateForSummary(String(value), TOOL_CALL_ARGUMENT_MAX_CHARS);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
85
98
|
/**
|
|
86
99
|
* Serialize LLM messages to text for summarization.
|
|
87
100
|
* This prevents the model from treating it as a conversation to continue.
|
|
@@ -117,7 +130,7 @@ export function serializeConversation(messages) {
|
|
|
117
130
|
else if (block.type === "toolCall") {
|
|
118
131
|
const args = block.arguments;
|
|
119
132
|
const argsStr = Object.entries(args)
|
|
120
|
-
.map(([k, v]) => `${k}=${
|
|
133
|
+
.map(([k, v]) => `${k}=${stringifyToolCallArgument(v)}`)
|
|
121
134
|
.join(", ");
|
|
122
135
|
toolCalls.push(`${block.name}(${argsStr})`);
|
|
123
136
|
}
|
|
@@ -129,7 +142,7 @@ export function serializeConversation(messages) {
|
|
|
129
142
|
parts.push(`[Assistant]: ${textParts.join("\n")}`);
|
|
130
143
|
}
|
|
131
144
|
if (toolCalls.length > 0) {
|
|
132
|
-
parts.push(`[Assistant tool calls]: ${toolCalls.join("; ")}`);
|
|
145
|
+
parts.push(`[Assistant tool calls]: ${truncateForSummary(toolCalls.join("; "), TOOL_CALLS_MAX_CHARS)}`);
|
|
133
146
|
}
|
|
134
147
|
}
|
|
135
148
|
else if (msg.role === "toolResult") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot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C,EAAE,CAAC,CAAC;YAC/D,CAAC;QACF,CAAC;aAAM,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YACtC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO;iBACzB,MAAM,CAAC,CAAC,CAAC,EAAuC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC;iBACrE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;iBAClB,IAAI,CAAC,EAAE,CAAC,CAAC;YACX,IAAI,OAAO,EAAE,CAAC;gBACb,KAAK,CAAC,IAAI,CAAC,kBAAkB,kBAAkB,CAAC,OAAO,EAAE,qBAAqB,CAAC,EAAE,CAAC,CAAC;YACpF,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAAA,CAC1B;AAED,+EAA+E;AAC/E,8BAA8B;AAC9B,+EAA+E;AAE/E,MAAM,CAAC,MAAM,2BAA2B,GAAG;;2HAEgF,CAAC","sourcesContent":["/**\n * Shared utilities for compaction and branch summarization.\n */\n\nimport type { AgentMessage } from \"omk-agent-core\";\nimport type { Message } from \"omk-ai\";\n\n// ============================================================================\n// File Operation Tracking\n// ============================================================================\n\nexport interface FileOperations {\n\tread: Set<string>;\n\twritten: Set<string>;\n\tedited: Set<string>;\n}\n\nexport function createFileOps(): FileOperations {\n\treturn {\n\t\tread: new Set(),\n\t\twritten: new Set(),\n\t\tedited: new Set(),\n\t};\n}\n\n/**\n * Extract file operations from tool calls in an assistant message.\n */\nexport function extractFileOpsFromMessage(message: AgentMessage, fileOps: FileOperations): void {\n\tif (message.role !== \"assistant\") return;\n\tif (!(\"content\" in message) || !Array.isArray(message.content)) return;\n\n\tfor (const block of message.content) {\n\t\tif (typeof block !== \"object\" || block === null) continue;\n\t\tif (!(\"type\" in block) || block.type !== \"toolCall\") continue;\n\t\tif (!(\"arguments\" in block) || !(\"name\" in block)) continue;\n\n\t\tconst args = block.arguments as Record<string, unknown> | undefined;\n\t\tif (!args) continue;\n\n\t\tconst path = typeof args.path === \"string\" ? args.path : undefined;\n\t\tif (!path) continue;\n\n\t\tswitch (block.name) {\n\t\t\tcase \"read\":\n\t\t\t\tfileOps.read.add(path);\n\t\t\t\tbreak;\n\t\t\tcase \"write\":\n\t\t\t\tfileOps.written.add(path);\n\t\t\t\tbreak;\n\t\t\tcase \"edit\":\n\t\t\t\tfileOps.edited.add(path);\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/**\n * Compute final file lists from file operations.\n * Returns readFiles (files only read, not modified) and modifiedFiles.\n */\nexport function computeFileLists(fileOps: FileOperations): { readFiles: string[]; modifiedFiles: string[] } {\n\tconst modified = new Set([...fileOps.edited, ...fileOps.written]);\n\tconst readOnly = [...fileOps.read].filter((f) => !modified.has(f)).sort();\n\tconst modifiedFiles = [...modified].sort();\n\treturn { readFiles: readOnly, modifiedFiles };\n}\n\n/**\n * Format file operations as XML tags for summary.\n */\nexport function formatFileOperations(readFiles: string[], modifiedFiles: string[]): string {\n\tconst sections: string[] = [];\n\tif (readFiles.length > 0) {\n\t\tsections.push(`<read-files>\\n${readFiles.join(\"\\n\")}\\n</read-files>`);\n\t}\n\tif (modifiedFiles.length > 0) {\n\t\tsections.push(`<modified-files>\\n${modifiedFiles.join(\"\\n\")}\\n</modified-files>`);\n\t}\n\tif (sections.length === 0) return \"\";\n\treturn `\\n\\n${sections.join(\"\\n\\n\")}`;\n}\n\n// ============================================================================\n// Message Serialization\n// ============================================================================\n\n/** Maximum characters for a tool result in serialized summaries. */\nconst TOOL_RESULT_MAX_CHARS = 2000;\n\n/**\n * Truncate text to a maximum character length for summarization.\n * Keeps the beginning and appends a truncation marker.\n */\nfunction truncateForSummary(text: string, maxChars: number): string {\n\tif (text.length <= maxChars) return text;\n\tconst truncatedChars = text.length - maxChars;\n\treturn `${text.slice(0, maxChars)}\\n\\n[... ${truncatedChars} more characters truncated]`;\n}\n\n/**\n * Serialize LLM messages to text for summarization.\n * This prevents the model from treating it as a conversation to continue.\n * Call convertToLlm() first to handle custom message types.\n *\n * Tool results are truncated to keep the summarization request within\n * reasonable token budgets. Full content is not needed for summarization.\n */\nexport function serializeConversation(messages: Message[]): string {\n\tconst parts: string[] = [];\n\n\tfor (const msg of messages) {\n\t\tif (msg.role === \"user\") {\n\t\t\tconst content =\n\t\t\t\ttypeof msg.content === \"string\"\n\t\t\t\t\t? msg.content\n\t\t\t\t\t: msg.content\n\t\t\t\t\t\t\t.filter((c): c is { type: \"text\"; text: string } => c.type === \"text\")\n\t\t\t\t\t\t\t.map((c) => c.text)\n\t\t\t\t\t\t\t.join(\"\");\n\t\t\tif (content) parts.push(`[User]: ${content}`);\n\t\t} else if (msg.role === \"assistant\") {\n\t\t\tconst textParts: string[] = [];\n\t\t\tconst thinkingParts: string[] = [];\n\t\t\tconst toolCalls: string[] = [];\n\n\t\t\tfor (const block of msg.content) {\n\t\t\t\tif (block.type === \"text\") {\n\t\t\t\t\ttextParts.push(block.text);\n\t\t\t\t} else if (block.type === \"thinking\") {\n\t\t\t\t\tthinkingParts.push(block.thinking);\n\t\t\t\t} else if (block.type === \"toolCall\") {\n\t\t\t\t\tconst args = block.arguments as Record<string, unknown>;\n\t\t\t\t\tconst argsStr = Object.entries(args)\n\t\t\t\t\t\t.map(([k, v]) => `${k}=${JSON.stringify(v)}`)\n\t\t\t\t\t\t.join(\", \");\n\t\t\t\t\ttoolCalls.push(`${block.name}(${argsStr})`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (thinkingParts.length > 0) {\n\t\t\t\tparts.push(`[Assistant thinking]: ${thinkingParts.join(\"\\n\")}`);\n\t\t\t}\n\t\t\tif (textParts.length > 0) {\n\t\t\t\tparts.push(`[Assistant]: ${textParts.join(\"\\n\")}`);\n\t\t\t}\n\t\t\tif (toolCalls.length > 0) {\n\t\t\t\tparts.push(`[Assistant tool calls]: ${toolCalls.join(\"; \")}`);\n\t\t\t}\n\t\t} else if (msg.role === \"toolResult\") {\n\t\t\tconst content = msg.content\n\t\t\t\t.filter((c): c is { type: \"text\"; text: string } => c.type === \"text\")\n\t\t\t\t.map((c) => c.text)\n\t\t\t\t.join(\"\");\n\t\t\tif (content) {\n\t\t\t\tparts.push(`[Tool result]: ${truncateForSummary(content, TOOL_RESULT_MAX_CHARS)}`);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn parts.join(\"\\n\\n\");\n}\n\n// ============================================================================\n// Summarization System Prompt\n// ============================================================================\n\nexport const SUMMARIZATION_SYSTEM_PROMPT = `You are a context summarization assistant. Your task is to read a conversation between a user and an AI coding assistant, then produce a structured summary following the exact format specified.\n\nDo NOT continue the conversation. Do NOT respond to any questions in the conversation. ONLY output the structured summary.`;\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/core/compaction/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAeH,MAAM,UAAU,aAAa,GAAmB;IAC/C,OAAO;QACN,IAAI,EAAE,IAAI,GAAG,EAAE;QACf,OAAO,EAAE,IAAI,GAAG,EAAE;QAClB,MAAM,EAAE,IAAI,GAAG,EAAE;KACjB,CAAC;AAAA,CACF;AAED;;GAEG;AACH,MAAM,UAAU,yBAAyB,CAAC,OAAqB,EAAE,OAAuB,EAAQ;IAC/F,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW;QAAE,OAAO;IACzC,IAAI,CAAC,CAAC,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO;IAEvE,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACrC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;YAAE,SAAS;QAC1D,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU;YAAE,SAAS;QA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CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;iBAClB,IAAI,CAAC,EAAE,CAAC,CAAC;YACX,IAAI,OAAO,EAAE,CAAC;gBACb,KAAK,CAAC,IAAI,CAAC,kBAAkB,kBAAkB,CAAC,OAAO,EAAE,qBAAqB,CAAC,EAAE,CAAC,CAAC;YACpF,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAAA,CAC1B;AAED,+EAA+E;AAC/E,8BAA8B;AAC9B,+EAA+E;AAE/E,MAAM,CAAC,MAAM,2BAA2B,GAAG;;2HAEgF,CAAC","sourcesContent":["/**\n * Shared utilities for compaction and branch summarization.\n */\n\nimport type { AgentMessage } from \"omk-agent-core\";\nimport type { Message } from \"omk-ai\";\n\n// ============================================================================\n// File Operation Tracking\n// ============================================================================\n\nexport interface FileOperations {\n\tread: Set<string>;\n\twritten: Set<string>;\n\tedited: Set<string>;\n}\n\nexport function createFileOps(): FileOperations {\n\treturn {\n\t\tread: new Set(),\n\t\twritten: new Set(),\n\t\tedited: new Set(),\n\t};\n}\n\n/**\n * Extract file operations from tool calls in an assistant message.\n */\nexport function extractFileOpsFromMessage(message: AgentMessage, fileOps: FileOperations): void {\n\tif (message.role !== \"assistant\") return;\n\tif (!(\"content\" in message) || !Array.isArray(message.content)) return;\n\n\tfor (const block of message.content) {\n\t\tif (typeof block !== \"object\" || block === null) continue;\n\t\tif (!(\"type\" in block) || block.type !== \"toolCall\") continue;\n\t\tif (!(\"arguments\" in block) || !(\"name\" in block)) continue;\n\n\t\tconst args = block.arguments as Record<string, unknown> | undefined;\n\t\tif (!args) continue;\n\n\t\tconst path = typeof args.path === \"string\" ? args.path : undefined;\n\t\tif (!path) continue;\n\n\t\tswitch (block.name) {\n\t\t\tcase \"read\":\n\t\t\t\tfileOps.read.add(path);\n\t\t\t\tbreak;\n\t\t\tcase \"write\":\n\t\t\t\tfileOps.written.add(path);\n\t\t\t\tbreak;\n\t\t\tcase \"edit\":\n\t\t\t\tfileOps.edited.add(path);\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/**\n * Compute final file lists from file operations.\n * Returns readFiles (files only read, not modified) and modifiedFiles.\n */\nexport function computeFileLists(fileOps: FileOperations): { readFiles: string[]; modifiedFiles: string[] } {\n\tconst modified = new Set([...fileOps.edited, ...fileOps.written]);\n\tconst readOnly = [...fileOps.read].filter((f) => !modified.has(f)).sort();\n\tconst modifiedFiles = [...modified].sort();\n\treturn { readFiles: readOnly, modifiedFiles };\n}\n\n/**\n * Format file operations as XML tags for summary.\n */\nexport function formatFileOperations(readFiles: string[], modifiedFiles: string[]): string {\n\tconst sections: string[] = [];\n\tif (readFiles.length > 0) {\n\t\tsections.push(`<read-files>\\n${readFiles.join(\"\\n\")}\\n</read-files>`);\n\t}\n\tif (modifiedFiles.length > 0) {\n\t\tsections.push(`<modified-files>\\n${modifiedFiles.join(\"\\n\")}\\n</modified-files>`);\n\t}\n\tif (sections.length === 0) return \"\";\n\treturn `\\n\\n${sections.join(\"\\n\\n\")}`;\n}\n\n// ============================================================================\n// Message Serialization\n// ============================================================================\n\n/** Maximum characters for a tool result in serialized summaries. */\nconst TOOL_RESULT_MAX_CHARS = 2000;\n\n/** Maximum characters for a single serialized tool-call argument. */\nconst TOOL_CALL_ARGUMENT_MAX_CHARS = 500;\n\n/** Maximum characters for all tool calls in one assistant message. */\nconst TOOL_CALLS_MAX_CHARS = 4000;\n\n/**\n * Truncate text to a maximum character length for summarization.\n * Keeps the beginning and appends a truncation marker.\n */\nfunction truncateForSummary(text: string, maxChars: number): string {\n\tif (text.length <= maxChars) return text;\n\tconst truncatedChars = text.length - maxChars;\n\treturn `${text.slice(0, maxChars)}\\n\\n[... ${truncatedChars} more characters truncated]`;\n}\n\nfunction stringifyToolCallArgument(value: unknown): string {\n\ttry {\n\t\tconst serialized = JSON.stringify(value);\n\t\treturn truncateForSummary(serialized ?? String(value), TOOL_CALL_ARGUMENT_MAX_CHARS);\n\t} catch {\n\t\treturn truncateForSummary(String(value), TOOL_CALL_ARGUMENT_MAX_CHARS);\n\t}\n}\n\n/**\n * Serialize LLM messages to text for summarization.\n * This prevents the model from treating it as a conversation to continue.\n * Call convertToLlm() first to handle custom message types.\n *\n * Tool results are truncated to keep the summarization request within\n * reasonable token budgets. Full content is not needed for summarization.\n */\nexport function serializeConversation(messages: Message[]): string {\n\tconst parts: string[] = [];\n\n\tfor (const msg of messages) {\n\t\tif (msg.role === \"user\") {\n\t\t\tconst content =\n\t\t\t\ttypeof msg.content === \"string\"\n\t\t\t\t\t? msg.content\n\t\t\t\t\t: msg.content\n\t\t\t\t\t\t\t.filter((c): c is { type: \"text\"; text: string } => c.type === \"text\")\n\t\t\t\t\t\t\t.map((c) => c.text)\n\t\t\t\t\t\t\t.join(\"\");\n\t\t\tif (content) parts.push(`[User]: ${content}`);\n\t\t} else if (msg.role === \"assistant\") {\n\t\t\tconst textParts: string[] = [];\n\t\t\tconst thinkingParts: string[] = [];\n\t\t\tconst toolCalls: string[] = [];\n\n\t\t\tfor (const block of msg.content) {\n\t\t\t\tif (block.type === \"text\") {\n\t\t\t\t\ttextParts.push(block.text);\n\t\t\t\t} else if (block.type === \"thinking\") {\n\t\t\t\t\tthinkingParts.push(block.thinking);\n\t\t\t\t} else if (block.type === \"toolCall\") {\n\t\t\t\t\tconst args = block.arguments as Record<string, unknown>;\n\t\t\t\t\tconst argsStr = Object.entries(args)\n\t\t\t\t\t\t.map(([k, v]) => `${k}=${stringifyToolCallArgument(v)}`)\n\t\t\t\t\t\t.join(\", \");\n\t\t\t\t\ttoolCalls.push(`${block.name}(${argsStr})`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (thinkingParts.length > 0) {\n\t\t\t\tparts.push(`[Assistant thinking]: ${thinkingParts.join(\"\\n\")}`);\n\t\t\t}\n\t\t\tif (textParts.length > 0) {\n\t\t\t\tparts.push(`[Assistant]: ${textParts.join(\"\\n\")}`);\n\t\t\t}\n\t\t\tif (toolCalls.length > 0) {\n\t\t\t\tparts.push(`[Assistant tool calls]: ${truncateForSummary(toolCalls.join(\"; \"), TOOL_CALLS_MAX_CHARS)}`);\n\t\t\t}\n\t\t} else if (msg.role === \"toolResult\") {\n\t\t\tconst content = msg.content\n\t\t\t\t.filter((c): c is { type: \"text\"; text: string } => c.type === \"text\")\n\t\t\t\t.map((c) => c.text)\n\t\t\t\t.join(\"\");\n\t\t\tif (content) {\n\t\t\t\tparts.push(`[Tool result]: ${truncateForSummary(content, TOOL_RESULT_MAX_CHARS)}`);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn parts.join(\"\\n\\n\");\n}\n\n// ============================================================================\n// Summarization System Prompt\n// ============================================================================\n\nexport const SUMMARIZATION_SYSTEM_PROMPT = `You are a context summarization assistant. Your task is to read a conversation between a user and an AI coding assistant, then produce a structured summary following the exact format specified.\n\nDo NOT continue the conversation. Do NOT respond to any questions in the conversation. ONLY output the structured summary.`;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compactor.d.ts","sourceRoot":"","sources":["../../src/core/compactor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compactor.d.ts","sourceRoot":"","sources":["../../src/core/compactor.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAChC,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,UAAU,EAAE,cAAc,EAAE,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,sBAAuB,SAAQ,YAAY;IACvD,OAAO,CAAC,UAAU,CAAS;IAE3B,YAAY,UAAU,SAAK,EAG1B;IAED,OAAO,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG;QAAE,SAAS,EAAE,cAAc,EAAE,CAAC;QAAC,OAAO,EAAE,cAAc,EAAE,CAAA;KAAE,CAQ3F;CACD;AAED,qBAAa,oBAAqB,SAAQ,YAAY;IACrD,WAAW,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,cAAc,EAAE,CAarD;IAED,OAAO,CAAC,SAAS;CAGjB;AAED,qBAAa,gBAAiB,SAAQ,YAAY;IACjD,OAAO,CAAC,QAAQ,CAAiE;IAEjF,KAAK,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAYlC;CACD;AAED,qBAAa,gBAAiB,SAAQ,YAAY;IACjD,OAAO,CAAC,aAAa,CAAyB;IAC9C,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,MAAM,CAAmB;IAEjC,YAAY,UAAU,SAAK,EAK1B;IAED,OAAO,CAAC,KAAK,EAAE,cAAc,EAAE,EAAE,MAAM,GAAE,QAAQ,GAAG,UAAU,GAAG,YAAyB,GAAG,gBAAgB,CAsC5G;IAED,OAAO,CAAC,SAAS;CASjB;AAED,eAAe,gBAAgB,CAAC","sourcesContent":["// [DEPRECATED — DEAD CODE] OMK v6.2 — Context Compactor (TypeScript)\n// ==================================================================\n// packages/coding-agent/src/core/compactor.ts\n//\n// STATUS: DEAD CODE — Not imported by any module at runtime.\n// This file is NOT wired into AgentSession or any active pipeline.\n//\n// WHY DEAD:\n// - agent-session.ts imports CompactionResult from compaction/index.ts,\n// NOT from this file. The CompactionResult interfaces are different.\n// - No other file in src/ imports from compactor.ts.\n// - All classes (SlidingWindowCompactor, SemanticDeduplicator,\n// ImportanceScorer, ContextCompactor) are only referenced within this file.\n//\n// ACTUAL COMPACTION SYSTEM:\n// - compaction/compaction.ts → real compaction with LLM summarization\n// - compaction/branch-summarization.ts → branch-specific summarization\n// - compaction/utils.ts → compaction utilities\n// - agent-session.ts imports compact(), prepareCompaction(), shouldCompact()\n// from compaction/index.ts\n//\n// DO NOT MODIFY — preserved for reference only.\n\nimport { EventEmitter } from \"events\";\n\nexport interface CompactionTurn {\n\tindex: number;\n\trole: string;\n\tcontent: string;\n\ttimestamp: number;\n\timportance?: number;\n}\n\nexport interface CompactionResult {\n\tpreserved: CompactionTurn[];\n\tsummarized: CompactionTurn[];\n\tsummary: string;\n\toriginalCount: number;\n\tfinalCount: number;\n\tcompressionRatio: number;\n}\n\nexport class SlidingWindowCompactor extends EventEmitter {\n\tprivate windowSize: number;\n\n\tconstructor(windowSize = 10) {\n\t\tsuper();\n\t\tthis.windowSize = windowSize;\n\t}\n\n\tcompact(turns: CompactionTurn[]): { preserved: CompactionTurn[]; evicted: CompactionTurn[] } {\n\t\tif (turns.length <= this.windowSize) {\n\t\t\treturn { preserved: turns, evicted: [] };\n\t\t}\n\t\treturn {\n\t\t\tpreserved: turns.slice(-this.windowSize),\n\t\t\tevicted: turns.slice(0, -this.windowSize),\n\t\t};\n\t}\n}\n\nexport class SemanticDeduplicator extends EventEmitter {\n\tdeduplicate(turns: CompactionTurn[]): CompactionTurn[] {\n\t\tconst seen = new Set<string>();\n\t\tconst unique: CompactionTurn[] = [];\n\n\t\tfor (const turn of turns) {\n\t\t\tconst key = this.normalize(turn.content);\n\t\t\tif (!seen.has(key)) {\n\t\t\t\tseen.add(key);\n\t\t\t\tunique.push(turn);\n\t\t\t}\n\t\t}\n\n\t\treturn unique;\n\t}\n\n\tprivate normalize(text: string): string {\n\t\treturn text.toLowerCase().replace(/\\s+/g, \" \").trim().substring(0, 100);\n\t}\n}\n\nexport class ImportanceScorer extends EventEmitter {\n\tprivate keywords = [\"refusal\", \"error\", \"strategy\", \"phase\", \"decision\", \"goal\"];\n\n\tscore(turn: CompactionTurn): number {\n\t\tlet score = 0;\n\t\tconst content = turn.content.toLowerCase();\n\n\t\tfor (const kw of this.keywords) {\n\t\t\tif (content.includes(kw)) score += 2;\n\t\t}\n\n\t\tif (turn.role === \"system\") score += 1;\n\t\tif (turn.role === \"assistant\" && content.includes(\"refuse\")) score += 5;\n\n\t\treturn score;\n\t}\n}\n\nexport class ContextCompactor extends EventEmitter {\n\tprivate slidingWindow: SlidingWindowCompactor;\n\tprivate deduplicator: SemanticDeduplicator;\n\tprivate scorer: ImportanceScorer;\n\n\tconstructor(windowSize = 10) {\n\t\tsuper();\n\t\tthis.slidingWindow = new SlidingWindowCompactor(windowSize);\n\t\tthis.deduplicator = new SemanticDeduplicator();\n\t\tthis.scorer = new ImportanceScorer();\n\t}\n\n\tcompact(turns: CompactionTurn[], _level: \"gentle\" | \"moderate\" | \"aggressive\" = \"moderate\"): CompactionResult {\n\t\tconst originalCount = turns.length;\n\n\t\t// 1. Importance scoring\n\t\tconst scored = turns.map((t) => ({ ...t, importance: this.scorer.score(t) }));\n\n\t\t// 2. Protect high-importance turns\n\t\tconst protectedTurns = scored.filter((t) => (t.importance ?? 0) >= 3);\n\t\tconst candidates = scored.filter((t) => (t.importance ?? 0) < 3);\n\n\t\t// 3. Sliding window\n\t\tconst { preserved, evicted } = this.slidingWindow.compact(candidates);\n\n\t\t// 4. Deduplicate evicted\n\t\tconst uniqueEvicted = this.deduplicator.deduplicate(evicted);\n\n\t\t// 5. Summarize evicted\n\t\tconst summary = this.summarize(uniqueEvicted);\n\n\t\t// 6. Assemble result\n\t\tconst finalTurns = [...protectedTurns, ...preserved];\n\t\tif (summary) {\n\t\t\tfinalTurns.push({\n\t\t\t\tindex: -1,\n\t\t\t\trole: \"system\",\n\t\t\t\tcontent: `[Summary]: ${summary}`,\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t});\n\t\t}\n\n\t\treturn {\n\t\t\tpreserved: protectedTurns,\n\t\t\tsummarized: uniqueEvicted,\n\t\t\tsummary,\n\t\t\toriginalCount,\n\t\t\tfinalCount: finalTurns.length,\n\t\t\tcompressionRatio: finalTurns.length / originalCount,\n\t\t};\n\t}\n\n\tprivate summarize(turns: CompactionTurn[]): string {\n\t\tif (turns.length === 0) return \"\";\n\t\tconst topics = new Set<string>();\n\t\tfor (const turn of turns) {\n\t\t\tconst words = turn.content.split(/\\s+/).filter((w) => w.length > 4);\n\t\t\tfor (const w of words.slice(0, 3)) topics.add(w);\n\t\t}\n\t\treturn `Topics: ${Array.from(topics).slice(0, 5).join(\", \")}`;\n\t}\n}\n\nexport default ContextCompactor;\n"]}
|
package/dist/core/compactor.js
CHANGED
|
@@ -19,9 +19,6 @@
|
|
|
19
19
|
// - agent-session.ts imports compact(), prepareCompaction(), shouldCompact()
|
|
20
20
|
// from compaction/index.ts
|
|
21
21
|
//
|
|
22
|
-
// NOTE: types/jailbreak.ts also defines a CompactionResult interface (different shape).
|
|
23
|
-
// Both are distinct from the real CompactionResult in compaction/compaction.ts.
|
|
24
|
-
//
|
|
25
22
|
// DO NOT MODIFY — preserved for reference only.
|
|
26
23
|
import { EventEmitter } from "events";
|
|
27
24
|
export class SlidingWindowCompactor extends EventEmitter {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compactor.js","sourceRoot":"","sources":["../../src/core/compactor.ts"],"names":[],"mappings":"AAAA,yEAAqE;AACrE,qEAAqE;AACrE,8CAA8C;AAC9C,EAAE;AACF,+DAA6D;AAC7D,mEAAmE;AACnE,EAAE;AACF,YAAY;AACZ,0EAA0E;AAC1E,yEAAyE;AACzE,uDAAuD;AACvD,iEAAiE;AACjE,gFAAgF;AAChF,EAAE;AACF,4BAA4B;AAC5B,2EAAyE;AACzE,2EAAyE;AACzE,mDAAiD;AACjD,+EAA+E;AAC/E,+BAA+B;AAC/B,EAAE;AACF,
|
|
1
|
+
{"version":3,"file":"compactor.js","sourceRoot":"","sources":["../../src/core/compactor.ts"],"names":[],"mappings":"AAAA,yEAAqE;AACrE,qEAAqE;AACrE,8CAA8C;AAC9C,EA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O,EAAE,cAAc,OAAO,EAAE;gBAChC,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;aACrB,CAAC,CAAC;QACJ,CAAC;QAED,OAAO;YACN,SAAS,EAAE,cAAc;YACzB,UAAU,EAAE,aAAa;YACzB,OAAO;YACP,aAAa;YACb,UAAU,EAAE,UAAU,CAAC,MAAM;YAC7B,gBAAgB,EAAE,UAAU,CAAC,MAAM,GAAG,aAAa;SACnD,CAAC;IAAA,CACF;IAEO,SAAS,CAAC,KAAuB,EAAU;QAClD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QAClC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;QACjC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YAC1B,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACpE,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;gBAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAClD,CAAC;QACD,OAAO,WAAW,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IAAA,CAC9D;CACD;AAED,eAAe,gBAAgB,CAAC","sourcesContent":["// [DEPRECATED — DEAD CODE] OMK v6.2 — Context Compactor (TypeScript)\n// ==================================================================\n// packages/coding-agent/src/core/compactor.ts\n//\n// STATUS: DEAD CODE — Not imported by any module at runtime.\n// This file is NOT wired into AgentSession or any active pipeline.\n//\n// WHY DEAD:\n// - agent-session.ts imports CompactionResult from compaction/index.ts,\n// NOT from this file. The CompactionResult interfaces are different.\n// - No other file in src/ imports from compactor.ts.\n// - All classes (SlidingWindowCompactor, SemanticDeduplicator,\n// ImportanceScorer, ContextCompactor) are only referenced within this file.\n//\n// ACTUAL COMPACTION SYSTEM:\n// - compaction/compaction.ts → real compaction with LLM summarization\n// - compaction/branch-summarization.ts → branch-specific summarization\n// - compaction/utils.ts → compaction utilities\n// - agent-session.ts imports compact(), prepareCompaction(), shouldCompact()\n// from compaction/index.ts\n//\n// DO NOT MODIFY — preserved for reference only.\n\nimport { EventEmitter } from \"events\";\n\nexport interface CompactionTurn {\n\tindex: number;\n\trole: string;\n\tcontent: string;\n\ttimestamp: number;\n\timportance?: number;\n}\n\nexport interface CompactionResult {\n\tpreserved: CompactionTurn[];\n\tsummarized: CompactionTurn[];\n\tsummary: string;\n\toriginalCount: number;\n\tfinalCount: number;\n\tcompressionRatio: number;\n}\n\nexport class SlidingWindowCompactor extends EventEmitter {\n\tprivate windowSize: number;\n\n\tconstructor(windowSize = 10) {\n\t\tsuper();\n\t\tthis.windowSize = windowSize;\n\t}\n\n\tcompact(turns: CompactionTurn[]): { preserved: CompactionTurn[]; evicted: CompactionTurn[] } {\n\t\tif (turns.length <= this.windowSize) {\n\t\t\treturn { preserved: turns, evicted: [] };\n\t\t}\n\t\treturn {\n\t\t\tpreserved: turns.slice(-this.windowSize),\n\t\t\tevicted: turns.slice(0, -this.windowSize),\n\t\t};\n\t}\n}\n\nexport class SemanticDeduplicator extends EventEmitter {\n\tdeduplicate(turns: CompactionTurn[]): CompactionTurn[] {\n\t\tconst seen = new Set<string>();\n\t\tconst unique: CompactionTurn[] = [];\n\n\t\tfor (const turn of turns) {\n\t\t\tconst key = this.normalize(turn.content);\n\t\t\tif (!seen.has(key)) {\n\t\t\t\tseen.add(key);\n\t\t\t\tunique.push(turn);\n\t\t\t}\n\t\t}\n\n\t\treturn unique;\n\t}\n\n\tprivate normalize(text: string): string {\n\t\treturn text.toLowerCase().replace(/\\s+/g, \" \").trim().substring(0, 100);\n\t}\n}\n\nexport class ImportanceScorer extends EventEmitter {\n\tprivate keywords = [\"refusal\", \"error\", \"strategy\", \"phase\", \"decision\", \"goal\"];\n\n\tscore(turn: CompactionTurn): number {\n\t\tlet score = 0;\n\t\tconst content = turn.content.toLowerCase();\n\n\t\tfor (const kw of this.keywords) {\n\t\t\tif (content.includes(kw)) score += 2;\n\t\t}\n\n\t\tif (turn.role === \"system\") score += 1;\n\t\tif (turn.role === \"assistant\" && content.includes(\"refuse\")) score += 5;\n\n\t\treturn score;\n\t}\n}\n\nexport class ContextCompactor extends EventEmitter {\n\tprivate slidingWindow: SlidingWindowCompactor;\n\tprivate deduplicator: SemanticDeduplicator;\n\tprivate scorer: ImportanceScorer;\n\n\tconstructor(windowSize = 10) {\n\t\tsuper();\n\t\tthis.slidingWindow = new SlidingWindowCompactor(windowSize);\n\t\tthis.deduplicator = new SemanticDeduplicator();\n\t\tthis.scorer = new ImportanceScorer();\n\t}\n\n\tcompact(turns: CompactionTurn[], _level: \"gentle\" | \"moderate\" | \"aggressive\" = \"moderate\"): CompactionResult {\n\t\tconst originalCount = turns.length;\n\n\t\t// 1. Importance scoring\n\t\tconst scored = turns.map((t) => ({ ...t, importance: this.scorer.score(t) }));\n\n\t\t// 2. Protect high-importance turns\n\t\tconst protectedTurns = scored.filter((t) => (t.importance ?? 0) >= 3);\n\t\tconst candidates = scored.filter((t) => (t.importance ?? 0) < 3);\n\n\t\t// 3. Sliding window\n\t\tconst { preserved, evicted } = this.slidingWindow.compact(candidates);\n\n\t\t// 4. Deduplicate evicted\n\t\tconst uniqueEvicted = this.deduplicator.deduplicate(evicted);\n\n\t\t// 5. Summarize evicted\n\t\tconst summary = this.summarize(uniqueEvicted);\n\n\t\t// 6. Assemble result\n\t\tconst finalTurns = [...protectedTurns, ...preserved];\n\t\tif (summary) {\n\t\t\tfinalTurns.push({\n\t\t\t\tindex: -1,\n\t\t\t\trole: \"system\",\n\t\t\t\tcontent: `[Summary]: ${summary}`,\n\t\t\t\ttimestamp: Date.now(),\n\t\t\t});\n\t\t}\n\n\t\treturn {\n\t\t\tpreserved: protectedTurns,\n\t\t\tsummarized: uniqueEvicted,\n\t\t\tsummary,\n\t\t\toriginalCount,\n\t\t\tfinalCount: finalTurns.length,\n\t\t\tcompressionRatio: finalTurns.length / originalCount,\n\t\t};\n\t}\n\n\tprivate summarize(turns: CompactionTurn[]): string {\n\t\tif (turns.length === 0) return \"\";\n\t\tconst topics = new Set<string>();\n\t\tfor (const turn of turns) {\n\t\t\tconst words = turn.content.split(/\\s+/).filter((w) => w.length > 4);\n\t\t\tfor (const w of words.slice(0, 3)) topics.add(w);\n\t\t}\n\t\treturn `Topics: ${Array.from(topics).slice(0, 5).join(\", \")}`;\n\t}\n}\n\nexport default ContextCompactor;\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { type ContextBudgetItemV2, type ContextBudgetPriorityV2, type ContextBudgetTierV2, type ContextEvidenceKindV2, type ContextRepresentationCandidateV2, type ContextRepresentationFidelityV2, type ContextRepresentationKindV2, type ContextSourceRefV2, chooseHeadroomRepresentation, DEFAULT_HEADROOM_QUALITY_POLICY, deriveRepresentationCandidates, estimatePointerTokens, fnv1aHex, fullTextTokens, getHeadroomRuntimeStatus, type HeadroomQualityPolicyV2, type HeadroomRuntimeStatusV2, heuristicTokenCount, type RepresentationBudgetContext, } from "./context-budget-headroom.ts";
|
|
2
|
+
export { buildContextBudgetExactRepresentationCacheKeyV2, buildContextBudgetMaterializedRepresentationCacheKeyV2, buildContextBudgetMaterializedRepresentationCandidateKeyV2, buildContextBudgetPlanCacheKeyV2, buildContextBudgetRepresentationCacheKeyV2, computeContextBudgetOutputTextHashV2, computeContextBudgetQueryIntentHashV2, computeContextBudgetRepresentationFingerprintV2, computeContextBudgetTargetTokenBucketV2, createMemoryContextBudgetCacheProviderV2, DEFAULT_MATERIALIZED_COMPRESSOR_POLICY_HASH_V2, DEFAULT_MATERIALIZED_QUALITY_POLICY_HASH_V2, } from "./context-budget-v2-cache.ts";
|
|
2
3
|
export { computeCoverageGap } from "./context-budget-v2-coverage.ts";
|
|
3
4
|
export { computePlanHash, contentHashOf } from "./context-budget-v2-plan-hash.ts";
|
|
4
5
|
export { planPromptContextBudgetV2 } from "./context-budget-v2-planner.ts";
|
|
5
6
|
export { scoreContextBudgetItemV2 } from "./context-budget-v2-scoring.ts";
|
|
6
|
-
export { ALL_TIERS_V2, CONTEXT_BUDGET_POLICY_VERSION_V2, type ContextBudgetObservabilityCountsV2, type ContextBudgetObservabilityTokensV2, DEFAULT_TIER_POLICY_V2, type PromptContextBudgetInputV2, type PromptContextBudgetObservabilityV2, type PromptContextBudgetPlanV2, type QualityDiagnosticReasonV2, type QualityDiagnosticV2, type SelectedRepresentationV2, type TierBudgetAllocationV2, type TierBudgetPolicyV2, } from "./context-budget-v2-types.ts";
|
|
7
|
+
export { ALL_TIERS_V2, CONTEXT_BUDGET_POLICY_VERSION_V2, type ContextBudgetCacheProviderV2, type ContextBudgetCacheTokenTelemetryV2, type ContextBudgetMaterializedVerificationV2, type ContextBudgetObservabilityCountsV2, type ContextBudgetObservabilityTokensV2, type ContextBudgetPlanCacheTelemetryV2, type ContextBudgetRepresentationCacheEntryV2, type ContextBudgetRepresentationCacheKeyKindV2, type ContextBudgetRepresentationCacheTelemetryV2, DEFAULT_TIER_POLICY_V2, type PromptContextBudgetInputV2, type PromptContextBudgetObservabilityV2, type PromptContextBudgetPlanV2, type QualityDiagnosticReasonV2, type QualityDiagnosticV2, type SelectedRepresentationV2, type TierBudgetAllocationV2, type TierBudgetPolicyV2, } from "./context-budget-v2-types.ts";
|
|
7
8
|
//# sourceMappingURL=context-budget-governor-v2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-budget-governor-v2.d.ts","sourceRoot":"","sources":["../../src/core/context-budget-governor-v2.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,gCAAgC,EACrC,KAAK,+BAA+B,EACpC,KAAK,2BAA2B,EAChC,KAAK,kBAAkB,EACvB,4BAA4B,EAC5B,+BAA+B,EAC/B,8BAA8B,EAC9B,qBAAqB,EACrB,QAAQ,EACR,cAAc,EACd,wBAAwB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,mBAAmB,EACnB,KAAK,2BAA2B,GAChC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EACN,YAAY,EACZ,gCAAgC,EAChC,KAAK,kCAAkC,EACvC,KAAK,kCAAkC,EACvC,sBAAsB,EACtB,KAAK,0BAA0B,EAC/B,KAAK,kCAAkC,EACvC,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,GACvB,MAAM,8BAA8B,CAAC","sourcesContent":["export {\n\ttype ContextBudgetItemV2,\n\ttype ContextBudgetPriorityV2,\n\ttype ContextBudgetTierV2,\n\ttype ContextEvidenceKindV2,\n\ttype ContextRepresentationCandidateV2,\n\ttype ContextRepresentationFidelityV2,\n\ttype ContextRepresentationKindV2,\n\ttype ContextSourceRefV2,\n\tchooseHeadroomRepresentation,\n\tDEFAULT_HEADROOM_QUALITY_POLICY,\n\tderiveRepresentationCandidates,\n\testimatePointerTokens,\n\tfnv1aHex,\n\tfullTextTokens,\n\tgetHeadroomRuntimeStatus,\n\ttype HeadroomQualityPolicyV2,\n\ttype HeadroomRuntimeStatusV2,\n\theuristicTokenCount,\n\ttype RepresentationBudgetContext,\n} from \"./context-budget-headroom.ts\";\nexport { computeCoverageGap } from \"./context-budget-v2-coverage.ts\";\nexport { computePlanHash, contentHashOf } from \"./context-budget-v2-plan-hash.ts\";\nexport { planPromptContextBudgetV2 } from \"./context-budget-v2-planner.ts\";\nexport { scoreContextBudgetItemV2 } from \"./context-budget-v2-scoring.ts\";\nexport {\n\tALL_TIERS_V2,\n\tCONTEXT_BUDGET_POLICY_VERSION_V2,\n\ttype ContextBudgetObservabilityCountsV2,\n\ttype ContextBudgetObservabilityTokensV2,\n\tDEFAULT_TIER_POLICY_V2,\n\ttype PromptContextBudgetInputV2,\n\ttype PromptContextBudgetObservabilityV2,\n\ttype PromptContextBudgetPlanV2,\n\ttype QualityDiagnosticReasonV2,\n\ttype QualityDiagnosticV2,\n\ttype SelectedRepresentationV2,\n\ttype TierBudgetAllocationV2,\n\ttype TierBudgetPolicyV2,\n} from \"./context-budget-v2-types.ts\";\n"]}
|
|
1
|
+
{"version":3,"file":"context-budget-governor-v2.d.ts","sourceRoot":"","sources":["../../src/core/context-budget-governor-v2.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,gCAAgC,EACrC,KAAK,+BAA+B,EACpC,KAAK,2BAA2B,EAChC,KAAK,kBAAkB,EACvB,4BAA4B,EAC5B,+BAA+B,EAC/B,8BAA8B,EAC9B,qBAAqB,EACrB,QAAQ,EACR,cAAc,EACd,wBAAwB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,mBAAmB,EACnB,KAAK,2BAA2B,GAChC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,+CAA+C,EAC/C,sDAAsD,EACtD,0DAA0D,EAC1D,gCAAgC,EAChC,0CAA0C,EAC1C,oCAAoC,EACpC,qCAAqC,EACrC,+CAA+C,EAC/C,uCAAuC,EACvC,wCAAwC,EACxC,8CAA8C,EAC9C,2CAA2C,GAC3C,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EACN,YAAY,EACZ,gCAAgC,EAChC,KAAK,4BAA4B,EACjC,KAAK,kCAAkC,EACvC,KAAK,uCAAuC,EAC5C,KAAK,kCAAkC,EACvC,KAAK,kCAAkC,EACvC,KAAK,iCAAiC,EACtC,KAAK,uCAAuC,EAC5C,KAAK,yCAAyC,EAC9C,KAAK,2CAA2C,EAChD,sBAAsB,EACtB,KAAK,0BAA0B,EAC/B,KAAK,kCAAkC,EACvC,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,EACxB,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,GACvB,MAAM,8BAA8B,CAAC","sourcesContent":["export {\n\ttype ContextBudgetItemV2,\n\ttype ContextBudgetPriorityV2,\n\ttype ContextBudgetTierV2,\n\ttype ContextEvidenceKindV2,\n\ttype ContextRepresentationCandidateV2,\n\ttype ContextRepresentationFidelityV2,\n\ttype ContextRepresentationKindV2,\n\ttype ContextSourceRefV2,\n\tchooseHeadroomRepresentation,\n\tDEFAULT_HEADROOM_QUALITY_POLICY,\n\tderiveRepresentationCandidates,\n\testimatePointerTokens,\n\tfnv1aHex,\n\tfullTextTokens,\n\tgetHeadroomRuntimeStatus,\n\ttype HeadroomQualityPolicyV2,\n\ttype HeadroomRuntimeStatusV2,\n\theuristicTokenCount,\n\ttype RepresentationBudgetContext,\n} from \"./context-budget-headroom.ts\";\nexport {\n\tbuildContextBudgetExactRepresentationCacheKeyV2,\n\tbuildContextBudgetMaterializedRepresentationCacheKeyV2,\n\tbuildContextBudgetMaterializedRepresentationCandidateKeyV2,\n\tbuildContextBudgetPlanCacheKeyV2,\n\tbuildContextBudgetRepresentationCacheKeyV2,\n\tcomputeContextBudgetOutputTextHashV2,\n\tcomputeContextBudgetQueryIntentHashV2,\n\tcomputeContextBudgetRepresentationFingerprintV2,\n\tcomputeContextBudgetTargetTokenBucketV2,\n\tcreateMemoryContextBudgetCacheProviderV2,\n\tDEFAULT_MATERIALIZED_COMPRESSOR_POLICY_HASH_V2,\n\tDEFAULT_MATERIALIZED_QUALITY_POLICY_HASH_V2,\n} from \"./context-budget-v2-cache.ts\";\nexport { computeCoverageGap } from \"./context-budget-v2-coverage.ts\";\nexport { computePlanHash, contentHashOf } from \"./context-budget-v2-plan-hash.ts\";\nexport { planPromptContextBudgetV2 } from \"./context-budget-v2-planner.ts\";\nexport { scoreContextBudgetItemV2 } from \"./context-budget-v2-scoring.ts\";\nexport {\n\tALL_TIERS_V2,\n\tCONTEXT_BUDGET_POLICY_VERSION_V2,\n\ttype ContextBudgetCacheProviderV2,\n\ttype ContextBudgetCacheTokenTelemetryV2,\n\ttype ContextBudgetMaterializedVerificationV2,\n\ttype ContextBudgetObservabilityCountsV2,\n\ttype ContextBudgetObservabilityTokensV2,\n\ttype ContextBudgetPlanCacheTelemetryV2,\n\ttype ContextBudgetRepresentationCacheEntryV2,\n\ttype ContextBudgetRepresentationCacheKeyKindV2,\n\ttype ContextBudgetRepresentationCacheTelemetryV2,\n\tDEFAULT_TIER_POLICY_V2,\n\ttype PromptContextBudgetInputV2,\n\ttype PromptContextBudgetObservabilityV2,\n\ttype PromptContextBudgetPlanV2,\n\ttype QualityDiagnosticReasonV2,\n\ttype QualityDiagnosticV2,\n\ttype SelectedRepresentationV2,\n\ttype TierBudgetAllocationV2,\n\ttype TierBudgetPolicyV2,\n} from \"./context-budget-v2-types.ts\";\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { chooseHeadroomRepresentation, DEFAULT_HEADROOM_QUALITY_POLICY, deriveRepresentationCandidates, estimatePointerTokens, fnv1aHex, fullTextTokens, getHeadroomRuntimeStatus, heuristicTokenCount, } from "./context-budget-headroom.js";
|
|
2
|
+
export { buildContextBudgetExactRepresentationCacheKeyV2, buildContextBudgetMaterializedRepresentationCacheKeyV2, buildContextBudgetMaterializedRepresentationCandidateKeyV2, buildContextBudgetPlanCacheKeyV2, buildContextBudgetRepresentationCacheKeyV2, computeContextBudgetOutputTextHashV2, computeContextBudgetQueryIntentHashV2, computeContextBudgetRepresentationFingerprintV2, computeContextBudgetTargetTokenBucketV2, createMemoryContextBudgetCacheProviderV2, DEFAULT_MATERIALIZED_COMPRESSOR_POLICY_HASH_V2, DEFAULT_MATERIALIZED_QUALITY_POLICY_HASH_V2, } from "./context-budget-v2-cache.js";
|
|
2
3
|
export { computeCoverageGap } from "./context-budget-v2-coverage.js";
|
|
3
4
|
export { computePlanHash, contentHashOf } from "./context-budget-v2-plan-hash.js";
|
|
4
5
|
export { planPromptContextBudgetV2 } from "./context-budget-v2-planner.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-budget-governor-v2.js","sourceRoot":"","sources":["../../src/core/context-budget-governor-v2.ts"],"names":[],"mappings":"AAAA,OAAO,EASN,4BAA4B,EAC5B,+BAA+B,EAC/B,8BAA8B,EAC9B,qBAAqB,EACrB,QAAQ,EACR,cAAc,EACd,wBAAwB,EAGxB,mBAAmB,GAEnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EACN,YAAY,EACZ,gCAAgC,
|
|
1
|
+
{"version":3,"file":"context-budget-governor-v2.js","sourceRoot":"","sources":["../../src/core/context-budget-governor-v2.ts"],"names":[],"mappings":"AAAA,OAAO,EASN,4BAA4B,EAC5B,+BAA+B,EAC/B,8BAA8B,EAC9B,qBAAqB,EACrB,QAAQ,EACR,cAAc,EACd,wBAAwB,EAGxB,mBAAmB,GAEnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,+CAA+C,EAC/C,sDAAsD,EACtD,0DAA0D,EAC1D,gCAAgC,EAChC,0CAA0C,EAC1C,oCAAoC,EACpC,qCAAqC,EACrC,+CAA+C,EAC/C,uCAAuC,EACvC,wCAAwC,EACxC,8CAA8C,EAC9C,2CAA2C,GAC3C,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EACN,YAAY,EACZ,gCAAgC,EAUhC,sBAAsB,GAStB,MAAM,8BAA8B,CAAC","sourcesContent":["export {\n\ttype ContextBudgetItemV2,\n\ttype ContextBudgetPriorityV2,\n\ttype ContextBudgetTierV2,\n\ttype ContextEvidenceKindV2,\n\ttype ContextRepresentationCandidateV2,\n\ttype ContextRepresentationFidelityV2,\n\ttype ContextRepresentationKindV2,\n\ttype ContextSourceRefV2,\n\tchooseHeadroomRepresentation,\n\tDEFAULT_HEADROOM_QUALITY_POLICY,\n\tderiveRepresentationCandidates,\n\testimatePointerTokens,\n\tfnv1aHex,\n\tfullTextTokens,\n\tgetHeadroomRuntimeStatus,\n\ttype HeadroomQualityPolicyV2,\n\ttype HeadroomRuntimeStatusV2,\n\theuristicTokenCount,\n\ttype RepresentationBudgetContext,\n} from \"./context-budget-headroom.ts\";\nexport {\n\tbuildContextBudgetExactRepresentationCacheKeyV2,\n\tbuildContextBudgetMaterializedRepresentationCacheKeyV2,\n\tbuildContextBudgetMaterializedRepresentationCandidateKeyV2,\n\tbuildContextBudgetPlanCacheKeyV2,\n\tbuildContextBudgetRepresentationCacheKeyV2,\n\tcomputeContextBudgetOutputTextHashV2,\n\tcomputeContextBudgetQueryIntentHashV2,\n\tcomputeContextBudgetRepresentationFingerprintV2,\n\tcomputeContextBudgetTargetTokenBucketV2,\n\tcreateMemoryContextBudgetCacheProviderV2,\n\tDEFAULT_MATERIALIZED_COMPRESSOR_POLICY_HASH_V2,\n\tDEFAULT_MATERIALIZED_QUALITY_POLICY_HASH_V2,\n} from \"./context-budget-v2-cache.ts\";\nexport { computeCoverageGap } from \"./context-budget-v2-coverage.ts\";\nexport { computePlanHash, contentHashOf } from \"./context-budget-v2-plan-hash.ts\";\nexport { planPromptContextBudgetV2 } from \"./context-budget-v2-planner.ts\";\nexport { scoreContextBudgetItemV2 } from \"./context-budget-v2-scoring.ts\";\nexport {\n\tALL_TIERS_V2,\n\tCONTEXT_BUDGET_POLICY_VERSION_V2,\n\ttype ContextBudgetCacheProviderV2,\n\ttype ContextBudgetCacheTokenTelemetryV2,\n\ttype ContextBudgetMaterializedVerificationV2,\n\ttype ContextBudgetObservabilityCountsV2,\n\ttype ContextBudgetObservabilityTokensV2,\n\ttype ContextBudgetPlanCacheTelemetryV2,\n\ttype ContextBudgetRepresentationCacheEntryV2,\n\ttype ContextBudgetRepresentationCacheKeyKindV2,\n\ttype ContextBudgetRepresentationCacheTelemetryV2,\n\tDEFAULT_TIER_POLICY_V2,\n\ttype PromptContextBudgetInputV2,\n\ttype PromptContextBudgetObservabilityV2,\n\ttype PromptContextBudgetPlanV2,\n\ttype QualityDiagnosticReasonV2,\n\ttype QualityDiagnosticV2,\n\ttype SelectedRepresentationV2,\n\ttype TierBudgetAllocationV2,\n\ttype TierBudgetPolicyV2,\n} from \"./context-budget-v2-types.ts\";\n"]}
|