open-multi-agent-kit 0.95.2 → 0.96.1
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 +60 -0
- package/README.md +37 -4
- package/dist/approvals/approval-receipt-store.d.ts.map +1 -1
- package/dist/approvals/approval-receipt-store.js +25 -0
- package/dist/approvals/approval-receipt-store.js.map +1 -1
- package/dist/commands/doctor-provider.d.ts.map +1 -1
- package/dist/commands/doctor-provider.js +15 -20
- package/dist/commands/doctor-provider.js.map +1 -1
- package/dist/commands/sdk-session-cli.d.ts +24 -0
- package/dist/commands/sdk-session-cli.d.ts.map +1 -0
- package/dist/commands/sdk-session-cli.js +225 -0
- package/dist/commands/sdk-session-cli.js.map +1 -0
- package/dist/core/advisory-judge-model.d.ts +18 -0
- package/dist/core/advisory-judge-model.d.ts.map +1 -0
- package/dist/core/advisory-judge-model.js +168 -0
- package/dist/core/advisory-judge-model.js.map +1 -0
- package/dist/core/advisory-judge-response.d.ts +8 -0
- package/dist/core/advisory-judge-response.d.ts.map +1 -0
- package/dist/core/advisory-judge-response.js +61 -0
- package/dist/core/advisory-judge-response.js.map +1 -0
- package/dist/core/advisory-judge-types.d.ts +53 -0
- package/dist/core/advisory-judge-types.d.ts.map +1 -0
- package/dist/core/advisory-judge-types.js +2 -0
- package/dist/core/advisory-judge-types.js.map +1 -0
- package/dist/core/advisory-judge.d.ts +8 -0
- package/dist/core/advisory-judge.d.ts.map +1 -0
- package/dist/core/advisory-judge.js +178 -0
- package/dist/core/advisory-judge.js.map +1 -0
- package/dist/core/agent-session-services.d.ts +1 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +1 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +6 -3
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +141 -184
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +28 -4
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/compaction-gate.d.ts +28 -0
- package/dist/core/compaction-gate.d.ts.map +1 -0
- package/dist/core/compaction-gate.js +34 -0
- package/dist/core/compaction-gate.js.map +1 -0
- package/dist/core/context-budget-system-prompt-items.d.ts.map +1 -1
- package/dist/core/context-budget-system-prompt-items.js +5 -3
- package/dist/core/context-budget-system-prompt-items.js.map +1 -1
- package/dist/core/domain-loadouts.d.ts.map +1 -1
- package/dist/core/domain-loadouts.js +2 -2
- package/dist/core/domain-loadouts.js.map +1 -1
- package/dist/core/durable-goal-checkpoint.d.ts +6 -0
- package/dist/core/durable-goal-checkpoint.d.ts.map +1 -0
- package/dist/core/durable-goal-checkpoint.js +195 -0
- package/dist/core/durable-goal-checkpoint.js.map +1 -0
- package/dist/core/durable-goal-parse.d.ts +3 -0
- package/dist/core/durable-goal-parse.d.ts.map +1 -0
- package/dist/core/durable-goal-parse.js +86 -0
- package/dist/core/durable-goal-parse.js.map +1 -0
- package/dist/core/durable-goal-reducer.d.ts +3 -0
- package/dist/core/durable-goal-reducer.d.ts.map +1 -0
- package/dist/core/durable-goal-reducer.js +175 -0
- package/dist/core/durable-goal-reducer.js.map +1 -0
- package/dist/core/durable-goal-store.d.ts +19 -0
- package/dist/core/durable-goal-store.d.ts.map +1 -0
- package/dist/core/durable-goal-store.js +126 -0
- package/dist/core/durable-goal-store.js.map +1 -0
- package/dist/core/durable-goal.d.ts +92 -0
- package/dist/core/durable-goal.d.ts.map +1 -0
- package/dist/core/durable-goal.js +62 -0
- package/dist/core/durable-goal.js.map +1 -0
- package/dist/core/extensions/builtin/goal-controller.d.ts +3 -0
- package/dist/core/extensions/builtin/goal-controller.d.ts.map +1 -0
- package/dist/core/extensions/builtin/goal-controller.js +125 -0
- package/dist/core/extensions/builtin/goal-controller.js.map +1 -0
- package/dist/core/extensions/builtin/identical-loop.d.ts +3 -0
- package/dist/core/extensions/builtin/identical-loop.d.ts.map +1 -0
- package/dist/core/extensions/builtin/identical-loop.js +31 -0
- package/dist/core/extensions/builtin/identical-loop.js.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset.d.ts +3 -0
- package/dist/core/extensions/builtin/prompt-preset.d.ts.map +1 -0
- package/dist/core/extensions/builtin/prompt-preset.js +13 -0
- package/dist/core/extensions/builtin/prompt-preset.js.map +1 -0
- package/dist/core/extensions/builtin/tool-pair-repair.d.ts +3 -0
- package/dist/core/extensions/builtin/tool-pair-repair.d.ts.map +1 -0
- package/dist/core/extensions/builtin/tool-pair-repair.js +12 -0
- package/dist/core/extensions/builtin/tool-pair-repair.js.map +1 -0
- package/dist/core/extensions/types.d.ts +6 -2
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/goal-continuation.d.ts +13 -0
- package/dist/core/goal-continuation.d.ts.map +1 -0
- package/dist/core/goal-continuation.js +10 -0
- package/dist/core/goal-continuation.js.map +1 -0
- package/dist/core/grok-harness.d.ts +1 -1
- package/dist/core/grok-harness.d.ts.map +1 -1
- package/dist/core/grok-harness.js +1 -1
- package/dist/core/grok-harness.js.map +1 -1
- package/dist/core/grok-playbook.d.ts +1 -1
- package/dist/core/grok-playbook.d.ts.map +1 -1
- package/dist/core/grok-playbook.js +1 -1
- package/dist/core/grok-playbook.js.map +1 -1
- package/dist/core/identical-loop.d.ts +15 -0
- package/dist/core/identical-loop.d.ts.map +1 -0
- package/dist/core/identical-loop.js +34 -0
- package/dist/core/identical-loop.js.map +1 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/model-prompt-policy.d.ts +11 -0
- package/dist/core/model-prompt-policy.d.ts.map +1 -0
- package/dist/core/model-prompt-policy.js +17 -0
- package/dist/core/model-prompt-policy.js.map +1 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +16 -4
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +2 -2
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/prompt-budget.d.ts +21 -0
- package/dist/core/prompt-budget.d.ts.map +1 -0
- package/dist/core/prompt-budget.js +51 -0
- package/dist/core/prompt-budget.js.map +1 -0
- package/dist/core/prompt-cache.d.ts +14 -0
- package/dist/core/prompt-cache.d.ts.map +1 -0
- package/dist/core/prompt-cache.js +16 -0
- package/dist/core/prompt-cache.js.map +1 -0
- package/dist/core/prompt-preset.d.ts +8 -0
- package/dist/core/prompt-preset.d.ts.map +1 -0
- package/dist/core/prompt-preset.js +56 -0
- package/dist/core/prompt-preset.js.map +1 -0
- package/dist/core/provider-resilience.d.ts +23 -0
- package/dist/core/provider-resilience.d.ts.map +1 -1
- package/dist/core/provider-resilience.js +34 -1
- package/dist/core/provider-resilience.js.map +1 -1
- package/dist/core/provider-retry.d.ts +29 -0
- package/dist/core/provider-retry.d.ts.map +1 -0
- package/dist/core/provider-retry.js +49 -0
- package/dist/core/provider-retry.js.map +1 -0
- package/dist/core/provider-usage.d.ts +2 -1
- package/dist/core/provider-usage.d.ts.map +1 -1
- package/dist/core/provider-usage.js +40 -6
- package/dist/core/provider-usage.js.map +1 -1
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +32 -0
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sandbox/backend.d.ts +12 -0
- package/dist/core/sandbox/backend.d.ts.map +1 -1
- package/dist/core/sandbox/backend.js +52 -42
- package/dist/core/sandbox/backend.js.map +1 -1
- package/dist/core/sandbox/policy.d.ts +2 -0
- package/dist/core/sandbox/policy.d.ts.map +1 -1
- package/dist/core/sandbox/policy.js +2 -1
- package/dist/core/sandbox/policy.js.map +1 -1
- package/dist/core/sdk.d.ts +2 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +1 -0
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-system-prompt.d.ts +28 -0
- package/dist/core/session-system-prompt.d.ts.map +1 -0
- package/dist/core/session-system-prompt.js +37 -0
- package/dist/core/session-system-prompt.js.map +1 -0
- package/dist/core/strict-record.d.ts +2 -0
- package/dist/core/strict-record.d.ts.map +1 -0
- package/dist/core/strict-record.js +9 -0
- package/dist/core/strict-record.js.map +1 -0
- package/dist/core/subagent-orchestration.d.ts.map +1 -1
- package/dist/core/subagent-orchestration.js +4 -2
- package/dist/core/subagent-orchestration.js.map +1 -1
- package/dist/core/tool-pair-repair.d.ts +11 -0
- package/dist/core/tool-pair-repair.d.ts.map +1 -0
- package/dist/core/tool-pair-repair.js +38 -0
- package/dist/core/tool-pair-repair.js.map +1 -0
- package/dist/core/tools/artifact-spill.d.ts +13 -0
- package/dist/core/tools/artifact-spill.d.ts.map +1 -0
- package/dist/core/tools/artifact-spill.js +26 -0
- package/dist/core/tools/artifact-spill.js.map +1 -0
- package/dist/core/tools/bash.d.ts +7 -4
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +8 -7
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/diagnostics.d.ts.map +1 -1
- package/dist/core/tools/diagnostics.js +8 -2
- package/dist/core/tools/diagnostics.js.map +1 -1
- package/dist/core/tools/index.d.ts +1 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/read.d.ts +1 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +10 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +2 -0
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/guardrails/evidence-protocol.d.ts +10 -0
- package/dist/guardrails/evidence-protocol.d.ts.map +1 -0
- package/dist/guardrails/evidence-protocol.js +34 -0
- package/dist/guardrails/evidence-protocol.js.map +1 -0
- package/dist/guardrails/evidence-system.d.ts +3 -1
- package/dist/guardrails/evidence-system.d.ts.map +1 -1
- package/dist/guardrails/evidence-system.js +22 -14
- package/dist/guardrails/evidence-system.js.map +1 -1
- package/dist/guardrails/replay-ledger-lock-owner.d.ts.map +1 -1
- package/dist/guardrails/replay-ledger-lock-owner.js +3 -1
- package/dist/guardrails/replay-ledger-lock-owner.js.map +1 -1
- package/dist/guardrails/replay-payload-hash.d.ts +6 -0
- package/dist/guardrails/replay-payload-hash.d.ts.map +1 -0
- package/dist/guardrails/replay-payload-hash.js +24 -0
- package/dist/guardrails/replay-payload-hash.js.map +1 -0
- package/dist/index.d.ts +20 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +8 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +14 -3
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/types/evidence.d.ts +11 -3
- package/dist/types/evidence.d.ts.map +1 -1
- package/dist/types/evidence.js.map +1 -1
- package/docs/adaptorch-preview-spec.md +1 -1
- package/docs/adaptorch-preview.md +2 -2
- package/docs/book-to-skill.md +79 -0
- package/docs/compaction.md +10 -0
- package/docs/containerization.md +9 -0
- package/docs/docs.json +18 -2
- package/docs/environment-variables.md +11 -4
- package/docs/extensions.md +14 -1
- package/docs/grok-harness.md +35 -12
- package/docs/index.md +9 -5
- package/docs/loadout-domains/grok-harness.md +2 -2
- package/docs/models.md +21 -8
- package/docs/provider-resilience.md +42 -55
- package/docs/providers.md +13 -4
- package/docs/run-protocol.md +104 -0
- package/docs/sdk.md +111 -5
- package/docs/security.md +22 -32
- package/docs/sessions.md +20 -0
- package/docs/settings.md +2 -0
- package/docs/skills.md +9 -1
- package/docs/usage.md +38 -16
- 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/index.ts +6 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +37 -15
- package/package.json +8 -5
- package/dist/core/context-budget-compressors.d.ts +0 -50
- package/dist/core/context-budget-compressors.d.ts.map +0 -1
- package/dist/core/context-budget-compressors.js +0 -166
- package/dist/core/context-budget-compressors.js.map +0 -1
- package/dist/core/extensions/loader.js.bak-sharedjiti-20260812-111246 +0 -553
package/docs/sessions.md
CHANGED
|
@@ -17,8 +17,25 @@ omk --fork <path|id> # Fork a session file or partial session ID into a new s
|
|
|
17
17
|
|
|
18
18
|
Use `/session` in interactive mode to see the current session file, session ID, message count, tokens, and cost.
|
|
19
19
|
|
|
20
|
+
Stored sessions can also be inspected or appended from scripts:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
omk sdk session status [id] [--json]
|
|
24
|
+
omk sdk session tail [id] [--limit 20]
|
|
25
|
+
omk sdk session inspect [id]
|
|
26
|
+
omk sdk session send <id> "message"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`send` requires an exact session ID and appends only when the session has no active owner; it does not connect to a running process or execute the message. See [SDK](sdk.md#inspect-persisted-sessions-from-the-cli) for full flags and exit codes.
|
|
30
|
+
|
|
20
31
|
For the JSONL file format and SessionManager API, see [Session Format](session-format.md).
|
|
21
32
|
|
|
33
|
+
## Retries and Termination Events
|
|
34
|
+
|
|
35
|
+
Each provider attempt writes its own `run_started`/`run_finished` journal pair and emits `session_termination`. A retryable termination is attempt-level when `auto_retry_start` follows it; consumers should not treat that event alone as the end of the outer `prompt()` call.
|
|
36
|
+
|
|
37
|
+
If a retry or failover succeeds, the later attempt emits `completed` and becomes `session.lastTermination`. If retry budget is exhausted, the last provider failure remains final. Quota and billing-cycle exhaustion are classified as `provider.rate_limit` and can switch through the configured provider-resilience chain before retrying. See [Provider Resilience](provider-resilience.md).
|
|
38
|
+
|
|
22
39
|
## Session Commands
|
|
23
40
|
|
|
24
41
|
| Command | Description |
|
|
@@ -27,6 +44,7 @@ For the JSONL file format and SessionManager API, see [Session Format](session-f
|
|
|
27
44
|
| `/new` | Start a new session |
|
|
28
45
|
| `/name <name>` | Set the current session display name |
|
|
29
46
|
| `/session` | Show session info |
|
|
47
|
+
| `/goal [objective]` | Show or set the durable goal; `checkpoint <json>` records Goal/Core/Verified/Open/Next continuity |
|
|
30
48
|
| `/tree` | Navigate the current session tree |
|
|
31
49
|
| `/fork` | Create a new session from a previous user message |
|
|
32
50
|
| `/clone` | Duplicate the current active branch into a new session |
|
|
@@ -34,6 +52,8 @@ For the JSONL file format and SessionManager API, see [Session Format](session-f
|
|
|
34
52
|
| `/export [file]` | Export session to HTML |
|
|
35
53
|
| `/share` | Upload as private GitHub gist with shareable HTML link |
|
|
36
54
|
|
|
55
|
+
`/goal` state lives under the working directory, not in one session file. Seam checkpoints are digest-correlated revisions in the same goal journal; session entries contain only their goal ID, revision, and digest. The unkeyed digest is not workspace authentication, so checkpoint prose loaded on resume is not promoted to user authority. See [Run Protocol](run-protocol.md#durable-goal-lifecycle).
|
|
56
|
+
|
|
37
57
|
## Resuming and Deleting Sessions
|
|
38
58
|
|
|
39
59
|
`/resume` opens an interactive session picker for the current project. `omk -r` opens the same picker at startup.
|
package/docs/settings.md
CHANGED
|
@@ -202,6 +202,8 @@ When a provider requests a retry delay longer than `retry.provider.maxRetryDelay
|
|
|
202
202
|
|
|
203
203
|
Keep `retry.provider.maxRetries` at `0` unless provider-level retries are explicitly needed. Setting it above `0` can make SDK/provider retries handle out-of-usage-limit errors before OMK sees them, which may block the agent until the provider quota resets in some circumstances.
|
|
204
204
|
|
|
205
|
+
At the agent level, recognized quota and billing-cycle failures are retryable so OMK can first switch to an authenticated `providerResilience.failoverCandidates` entry. If no candidate qualifies, normal retry backoff applies. See [Provider Resilience](provider-resilience.md).
|
|
206
|
+
|
|
205
207
|
```json
|
|
206
208
|
{
|
|
207
209
|
"retry": {
|
package/docs/skills.md
CHANGED
|
@@ -11,6 +11,7 @@ OMK implements the [Agent Skills standard](https://agentskills.io/specification)
|
|
|
11
11
|
## Table of Contents
|
|
12
12
|
|
|
13
13
|
- [Locations](#locations)
|
|
14
|
+
- [Optional Document Compiler](#optional-document-compiler)
|
|
14
15
|
- [How Skills Work](#how-skills-work)
|
|
15
16
|
- [Skill Commands](#skill-commands)
|
|
16
17
|
- [Skill Structure](#skill-structure)
|
|
@@ -42,6 +43,10 @@ Discovery rules:
|
|
|
42
43
|
|
|
43
44
|
Disable discovery with `--no-skills` (explicit `--skill` paths still load).
|
|
44
45
|
|
|
46
|
+
## Optional Document Compiler
|
|
47
|
+
|
|
48
|
+
Install [`omk-book-to-skill`](book-to-skill.md) to compile PDF, EPUB, DOCX, HTML, Markdown, text, RTF, MOBI, and AZW sources into generated skills. It is an optional OMK package, not a built-in skill, and keeps Python extractors outside OMK core.
|
|
49
|
+
|
|
45
50
|
### Using Skills from Other Harnesses
|
|
46
51
|
|
|
47
52
|
To use skills from Claude Code or OpenAI Codex, add their directories to settings:
|
|
@@ -88,7 +93,7 @@ Arguments after the command are appended after the skill content for the current
|
|
|
88
93
|
|
|
89
94
|
`!omk <role-or-request>` is a deterministic OMK hub router. Exact role aliases such as `frontend`, `backend`, `loop`, and `plan` select `omk-frontend`, `omk-backend-data`, `omk-loop`, and `omk-plan`; free-form prompts are scored against the same hub vocabulary and fall back to `omk-skills` when no role is clear.
|
|
90
95
|
|
|
91
|
-
In interactive mode, type `!` to open skill autocomplete. Selecting a skill inserts the explicit `!skill:name
|
|
96
|
+
In interactive mode, type `!` to open skill autocomplete. Selecting a skill inserts the explicit `!skill:name` form, and `!omk` is offered when the OMK skill hub index is available. Bash remains available as `! command`, and `!! command` runs bash without sending output to the model. If `!token` is not a known skill, it falls back to bash; use `! command` when a command name might collide with a skill. `!omk` is reserved for OMK hub routing and never falls through to bash.
|
|
92
97
|
|
|
93
98
|
Toggle skill commands via `/settings` in interactive mode or in `settings.json`:
|
|
94
99
|
|
|
@@ -173,11 +178,13 @@ Invalid: `PDF-Processing`, `-pdf`, `pdf--processing`
|
|
|
173
178
|
The description determines when the agent loads the skill. Be specific.
|
|
174
179
|
|
|
175
180
|
Good:
|
|
181
|
+
|
|
176
182
|
```yaml
|
|
177
183
|
description: Extracts text and tables from PDF files, fills PDF forms, and merges multiple PDFs. Use when working with PDF documents.
|
|
178
184
|
```
|
|
179
185
|
|
|
180
186
|
Poor:
|
|
187
|
+
|
|
181
188
|
```yaml
|
|
182
189
|
description: Helps with PDFs.
|
|
183
190
|
```
|
|
@@ -206,6 +213,7 @@ brave-search/
|
|
|
206
213
|
```
|
|
207
214
|
|
|
208
215
|
**SKILL.md:**
|
|
216
|
+
|
|
209
217
|
````markdown
|
|
210
218
|
---
|
|
211
219
|
name: brave-search
|
package/docs/usage.md
CHANGED
|
@@ -45,12 +45,14 @@ Type `/` in the editor to open command completion. Extensions can register custo
|
|
|
45
45
|
| `/new` | Start a new session |
|
|
46
46
|
| `/name <name>` | Set session display name |
|
|
47
47
|
| `/session` | Show session file, ID, messages, tokens, and cost |
|
|
48
|
+
| `/goal [objective]` | Show or set the durable goal for the current working directory |
|
|
48
49
|
| `/tree` | Jump to any point in the session and continue from there |
|
|
49
50
|
| `/fork` | Create a new session from a previous user message |
|
|
50
51
|
| `/clone` | Duplicate the current active branch into a new session |
|
|
51
52
|
| `/compact [prompt]` | Manually compact context, optionally with custom instructions |
|
|
52
53
|
| `/copy` | Copy last assistant message to clipboard |
|
|
53
54
|
| `/export [file]` | Export session to HTML |
|
|
55
|
+
| `/import <path.jsonl>` | Import a JSONL session and continue it |
|
|
54
56
|
| `/share` | Upload as private GitHub gist with shareable HTML link |
|
|
55
57
|
| `/reload` | Reload keybindings, extensions, skills, prompts, and context files |
|
|
56
58
|
| `/hotkeys` | Show all keyboard shortcuts |
|
|
@@ -58,6 +60,25 @@ Type `/` in the editor to open command completion. Extensions can register custo
|
|
|
58
60
|
| `/star` | Open the OMK GitHub repository |
|
|
59
61
|
| `/quit` | Quit omk |
|
|
60
62
|
|
|
63
|
+
### Durable Goals
|
|
64
|
+
|
|
65
|
+
Use `/goal <objective>` to create or update the durable goal for the current working directory; `/goal` without arguments shows its status. See [Run Protocol](run-protocol.md#durable-goal-lifecycle) for the authoritative persistence, round-limit, continuation, and SDK lifecycle rules.
|
|
66
|
+
|
|
67
|
+
## Built-in Harness Safeguards
|
|
68
|
+
|
|
69
|
+
`DefaultResourceLoader` enables these first-party safeguards:
|
|
70
|
+
|
|
71
|
+
| Safeguard | Behavior | Opt out |
|
|
72
|
+
| --- | --- | --- |
|
|
73
|
+
| Identical-loop guard | Warns from the third consecutive identical tool call and blocks the sixth | `OMK_IDENTICAL_LOOP=0` |
|
|
74
|
+
| Tool-pair repair | Removes unmatched tool-use and tool-result blocks from outbound context | `OMK_TOOL_PAIR_REPAIR=0` |
|
|
75
|
+
| Model prompt presets | Adds model-specific execution guidance for supported Claude, Kimi, GLM, and Grok models | `OMK_PROMPT_PRESET=0` |
|
|
76
|
+
| Goal controller | Registers `/goal` and continues active goals within their round limit | `OMK_GOAL_CONTROLLER=0` |
|
|
77
|
+
|
|
78
|
+
These built-ins remain active with `--no-extensions`. A custom `ResourceLoader` owns its own extension set and does not receive them automatically.
|
|
79
|
+
|
|
80
|
+
Claude models use a clean prompt context by default: OMK keeps tools, skills, and the Claude preset but omits discovered `AGENTS.md` and `CLAUDE.md` files. This avoids provider false positives caused by unrelated instruction text. Set `OMK_CLAUDE_CONTEXT_FILES=1` to restore those files for Claude.
|
|
81
|
+
|
|
61
82
|
## Automatic Thinking Level Routing
|
|
62
83
|
|
|
63
84
|
`/think <level>` sets the thinking level manually. Manual levels always win: choosing a concrete level leaves auto routing, so no auto router runs.
|
|
@@ -135,6 +156,17 @@ Useful session commands:
|
|
|
135
156
|
- `/clone` duplicates the current active branch into a new session file.
|
|
136
157
|
- `/compact` summarizes older messages to free context.
|
|
137
158
|
|
|
159
|
+
External controllers can inspect stored sessions without starting the TUI:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
omk sdk session status [id] [--json]
|
|
163
|
+
omk sdk session tail [id] [--limit 20]
|
|
164
|
+
omk sdk session inspect [id]
|
|
165
|
+
omk sdk session send <id> "message"
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
`send` appends a user-message entry; it does not wake or execute an agent. See [SDK](sdk.md#inspect-persisted-sessions-from-the-cli) for flags and output formats.
|
|
169
|
+
|
|
138
170
|
See [Sessions](sessions.md) and [Compaction](compaction.md) for details.
|
|
139
171
|
|
|
140
172
|
### Session Doctor and Recovery
|
|
@@ -150,7 +182,7 @@ The doctor verifies the session's complete JSONL prefix, run journal, compaction
|
|
|
150
182
|
|
|
151
183
|
Session and journal bytes after the final newline are copied byte-for-byte to a `.quarantine-*` file before the original is atomically rewritten to its valid complete prefix. Opening a session uses the same complete-prefix rule; `SessionManager.getQuarantineReport()` reports any startup quarantine.
|
|
152
184
|
|
|
153
|
-
Each
|
|
185
|
+
Each agent attempt writes fsynced `run_started` and `run_finished` records to `<session>.runjournal`. An unclosed valid run is recorded as an inferred `process_crash` on the next startup. JSON/RPC emit `session_termination`; text and TUI errors include kind, provider/model, retryability, cause, run ID, and next action. Recovered retries therefore record the failed attempt and a later `completed` attempt.
|
|
154
186
|
|
|
155
187
|
## Context Files
|
|
156
188
|
|
|
@@ -279,6 +311,8 @@ cat README.md | omk -p "Summarize this text"
|
|
|
279
311
|
|
|
280
312
|
Built-in tools: `read`, `bash`, `edit`, `write`, `grep`, `find`, `ls`.
|
|
281
313
|
|
|
314
|
+
With default OMP seams, a long text `read` returns a bounded window and continuation marker without creating a sidecar. With `OMK_OMP_SEAMS=0`, legacy truncation may write the selected window to `<absolute-source-path>.omk-spill.txt` and report that path. A first line that alone exceeds the byte cap is clipped without a sidecar. An inspection-only tool allowlist is therefore not a strict no-write filesystem boundary in legacy read mode.
|
|
315
|
+
|
|
282
316
|
### Resource Options
|
|
283
317
|
|
|
284
318
|
| Option | Description |
|
|
@@ -346,7 +380,7 @@ omk --model sonnet:high "Solve this complex problem"
|
|
|
346
380
|
# Limit model cycling
|
|
347
381
|
omk --models "claude-*,gpt-4o"
|
|
348
382
|
|
|
349
|
-
#
|
|
383
|
+
# Inspection-only tool allowlist; legacy read mode may create a spill sidecar
|
|
350
384
|
omk --tools read,grep,find,ls -p "Review the code"
|
|
351
385
|
|
|
352
386
|
# Disable one extension or built-in tool while keeping the rest available
|
|
@@ -355,22 +389,10 @@ omk --exclude-tools ask_question
|
|
|
355
389
|
|
|
356
390
|
### Environment Variables
|
|
357
391
|
|
|
358
|
-
|
|
359
|
-
| ---------- | ------------- |
|
|
360
|
-
| `OMK_CODING_AGENT_DIR` | Override config directory; default is `~/.omk/agent` |
|
|
361
|
-
| `OMK_CODING_AGENT_SESSION_DIR` | Override session storage directory; overridden by `--session-dir` |
|
|
362
|
-
| `OMK_PACKAGE_DIR` | Override package directory, useful for Nix/Guix store paths |
|
|
363
|
-
| `OMK_TOOL_SCHEDULER` | Override the tool scheduler with `dag-v2` or use `waves-v1` for process-local rollback |
|
|
364
|
-
| `OMK_OFFLINE` | Disable startup network operations, including update checks, package update checks, and install/update telemetry |
|
|
365
|
-
| `OMK_SKIP_VERSION_CHECK` | Skip the OMK version update check at startup. This prevents the `the OMK repository` latest-version request |
|
|
366
|
-
| `OMK_TELEMETRY` | Override install/update telemetry and provider attribution headers: `1`/`true`/`yes` or `0`/`false`/`no`. This does not disable update checks |
|
|
367
|
-
| `OMK_CACHE_RETENTION` | Set to `long` for extended prompt cache where supported |
|
|
368
|
-
| `VISUAL`, `EDITOR` | External editor for Ctrl+G |
|
|
392
|
+
See [Environment Variables](environment-variables.md) for the authoritative variable list and exact startup semantics.
|
|
369
393
|
|
|
370
394
|
## Design Principles
|
|
371
395
|
|
|
372
|
-
OMK keeps the core small
|
|
373
|
-
|
|
374
|
-
It intentionally does not include built-in MCP, sub-agents, permission popups, plan mode, to-dos, or background bash. You can build or install those workflows as extensions or packages, or use external tools such as containers and tmux.
|
|
396
|
+
OMK keeps the core small while shipping a first-party MCP client and a small default harness layer for loop detection, context repair, model guidance, and durable goals. Broader subagent runtimes, permission UIs, plan mode, and background bash remain extension or package concerns.
|
|
375
397
|
|
|
376
398
|
For the full rationale, read the [blog post](https://mariozechner.at/posts/2025-11-30-omk-coding-agent/).
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omk-extension-custom-provider-anthropic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.96.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "omk-extension-custom-provider-anthropic",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.96.1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "0.52.0"
|
|
12
12
|
}
|
|
@@ -244,7 +244,12 @@ async function loginGitLab(callbacks: OAuthLoginCallbacks): Promise<OAuthCredent
|
|
|
244
244
|
|
|
245
245
|
callbacks.onAuth({ url: `${GITLAB_COM_URL}/oauth/authorize?${authParams.toString()}` });
|
|
246
246
|
const callbackUrl = await callbacks.onPrompt({ message: "Paste the callback URL:" });
|
|
247
|
-
|
|
247
|
+
let code: string | null = null;
|
|
248
|
+
try {
|
|
249
|
+
code = new URL(callbackUrl).searchParams.get("code");
|
|
250
|
+
} catch {
|
|
251
|
+
throw new Error("Invalid callback URL — paste the full redirect URL from the browser");
|
|
252
|
+
}
|
|
248
253
|
if (!code) throw new Error("No authorization code found in callback URL");
|
|
249
254
|
|
|
250
255
|
const tokenResponse = await fetch(`${GITLAB_COM_URL}/oauth/token`, {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omk-extension-gondolin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.96.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "omk-extension-gondolin",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.96.1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@earendil-works/gondolin": "0.12.0"
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omk-extension-sandbox",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.96.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "omk-extension-sandbox",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.96.1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sandbox-runtime": "0.0.26"
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omk-extension-with-deps",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.96.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "omk-extension-with-deps",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.96.1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"ms": "2.1.3"
|
|
12
12
|
},
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "open-multi-agent-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.96.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "open-multi-agent-kit",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.96.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"omk-agent-core": "^0.
|
|
13
|
-
"omk-ai": "^0.
|
|
14
|
-
"omk-tui": "^0.
|
|
12
|
+
"omk-agent-core": "^0.96.1",
|
|
13
|
+
"omk-ai": "^0.96.1",
|
|
14
|
+
"omk-tui": "^0.96.1",
|
|
15
15
|
"@silvia-odwyer/photon-node": "0.3.4",
|
|
16
|
+
"canonicalize": "4.0.0",
|
|
16
17
|
"chalk": "5.6.2",
|
|
17
18
|
"cross-spawn": "7.0.6",
|
|
18
19
|
"diff": "8.0.4",
|
|
@@ -26,7 +27,8 @@
|
|
|
26
27
|
"typebox": "1.3.11",
|
|
27
28
|
"undici": "8.10.0",
|
|
28
29
|
"yaml": "2.9.0",
|
|
29
|
-
"omk-adaptorch-wpl": "^0.
|
|
30
|
+
"omk-adaptorch-wpl": "^0.96.1",
|
|
31
|
+
"omk-protocol": "^0.96.1"
|
|
30
32
|
},
|
|
31
33
|
"optionalDependencies": {
|
|
32
34
|
"@mariozechner/clipboard": "0.3.9"
|
|
@@ -861,6 +863,18 @@
|
|
|
861
863
|
"integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==",
|
|
862
864
|
"license": "BSD-3-Clause"
|
|
863
865
|
},
|
|
866
|
+
"node_modules/canonicalize": {
|
|
867
|
+
"version": "4.0.0",
|
|
868
|
+
"resolved": "https://registry.npmjs.org/canonicalize/-/canonicalize-4.0.0.tgz",
|
|
869
|
+
"integrity": "sha512-FEdXzwWs+N3rZqEqpqleiY9M1A6IAf9oo1zHFABnLW9FcJ/jzsu+G/Ks3Hq3FglmPKe80GeGBw8ZXLEnwPB0vQ==",
|
|
870
|
+
"license": "Apache-2.0",
|
|
871
|
+
"bin": {
|
|
872
|
+
"canonicalize": "bin/canonicalize.js"
|
|
873
|
+
},
|
|
874
|
+
"engines": {
|
|
875
|
+
"node": ">=18"
|
|
876
|
+
}
|
|
877
|
+
},
|
|
864
878
|
"node_modules/chalk": {
|
|
865
879
|
"version": "5.6.2",
|
|
866
880
|
"resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.2.tgz",
|
|
@@ -1271,19 +1285,19 @@
|
|
|
1271
1285
|
}
|
|
1272
1286
|
},
|
|
1273
1287
|
"node_modules/omk-adaptorch-wpl": {
|
|
1274
|
-
"version": "0.
|
|
1275
|
-
"resolved": "https://registry.npmjs.org/omk-adaptorch-wpl/-/omk-adaptorch-wpl-0.
|
|
1288
|
+
"version": "0.96.1",
|
|
1289
|
+
"resolved": "https://registry.npmjs.org/omk-adaptorch-wpl/-/omk-adaptorch-wpl-0.96.1.tgz",
|
|
1276
1290
|
"license": "MIT",
|
|
1277
1291
|
"engines": {
|
|
1278
1292
|
"node": ">=22.19.0"
|
|
1279
1293
|
}
|
|
1280
1294
|
},
|
|
1281
1295
|
"node_modules/omk-agent-core": {
|
|
1282
|
-
"version": "0.
|
|
1283
|
-
"resolved": "https://registry.npmjs.org/omk-agent-core/-/omk-agent-core-0.
|
|
1296
|
+
"version": "0.96.1",
|
|
1297
|
+
"resolved": "https://registry.npmjs.org/omk-agent-core/-/omk-agent-core-0.96.1.tgz",
|
|
1284
1298
|
"license": "MIT",
|
|
1285
1299
|
"dependencies": {
|
|
1286
|
-
"omk-ai": "^0.
|
|
1300
|
+
"omk-ai": "^0.96.1",
|
|
1287
1301
|
"ignore": "7.0.6",
|
|
1288
1302
|
"typebox": "1.3.11",
|
|
1289
1303
|
"yaml": "2.9.0"
|
|
@@ -1293,8 +1307,8 @@
|
|
|
1293
1307
|
}
|
|
1294
1308
|
},
|
|
1295
1309
|
"node_modules/omk-ai": {
|
|
1296
|
-
"version": "0.
|
|
1297
|
-
"resolved": "https://registry.npmjs.org/omk-ai/-/omk-ai-0.
|
|
1310
|
+
"version": "0.96.1",
|
|
1311
|
+
"resolved": "https://registry.npmjs.org/omk-ai/-/omk-ai-0.96.1.tgz",
|
|
1298
1312
|
"license": "MIT",
|
|
1299
1313
|
"dependencies": {
|
|
1300
1314
|
"@anthropic-ai/sdk": "0.91.1",
|
|
@@ -1315,9 +1329,17 @@
|
|
|
1315
1329
|
"node": ">=22.19.0"
|
|
1316
1330
|
}
|
|
1317
1331
|
},
|
|
1332
|
+
"node_modules/omk-protocol": {
|
|
1333
|
+
"version": "0.96.1",
|
|
1334
|
+
"resolved": "https://registry.npmjs.org/omk-protocol/-/omk-protocol-0.96.1.tgz",
|
|
1335
|
+
"license": "MIT",
|
|
1336
|
+
"engines": {
|
|
1337
|
+
"node": ">=22.19.0"
|
|
1338
|
+
}
|
|
1339
|
+
},
|
|
1318
1340
|
"node_modules/omk-tui": {
|
|
1319
|
-
"version": "0.
|
|
1320
|
-
"resolved": "https://registry.npmjs.org/omk-tui/-/omk-tui-0.
|
|
1341
|
+
"version": "0.96.1",
|
|
1342
|
+
"resolved": "https://registry.npmjs.org/omk-tui/-/omk-tui-0.96.1.tgz",
|
|
1321
1343
|
"license": "MIT",
|
|
1322
1344
|
"dependencies": {
|
|
1323
1345
|
"get-east-asian-width": "1.6.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "open-multi-agent-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.96.1",
|
|
4
4
|
"description": "OMK (Open Multi-Agent Kit) coding agent CLI with read, bash, edit, write tools and session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"omkConfig": {
|
|
@@ -44,10 +44,11 @@
|
|
|
44
44
|
"postinstall": "node ./scripts/link-workspace-deps.mjs"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"omk-agent-core": "^0.
|
|
48
|
-
"omk-ai": "^0.
|
|
49
|
-
"omk-tui": "^0.
|
|
47
|
+
"omk-agent-core": "^0.96.1",
|
|
48
|
+
"omk-ai": "^0.96.1",
|
|
49
|
+
"omk-tui": "^0.96.1",
|
|
50
50
|
"@silvia-odwyer/photon-node": "0.3.4",
|
|
51
|
+
"canonicalize": "4.0.0",
|
|
51
52
|
"chalk": "5.6.2",
|
|
52
53
|
"cross-spawn": "7.0.6",
|
|
53
54
|
"diff": "8.0.4",
|
|
@@ -61,7 +62,8 @@
|
|
|
61
62
|
"typebox": "1.3.11",
|
|
62
63
|
"undici": "8.10.0",
|
|
63
64
|
"yaml": "2.9.0",
|
|
64
|
-
"omk-adaptorch-wpl": "^0.
|
|
65
|
+
"omk-adaptorch-wpl": "^0.96.1",
|
|
66
|
+
"omk-protocol": "^0.96.1"
|
|
65
67
|
},
|
|
66
68
|
"overrides": {
|
|
67
69
|
"rimraf": "6.1.2",
|
|
@@ -79,6 +81,7 @@
|
|
|
79
81
|
"@types/ms": "2.1.0",
|
|
80
82
|
"@types/node": "24.12.4",
|
|
81
83
|
"@types/proper-lockfile": "4.1.4",
|
|
84
|
+
"fast-check": "4.9.0",
|
|
82
85
|
"shx": "0.4.0",
|
|
83
86
|
"typescript": "5.9.3",
|
|
84
87
|
"vitest": "3.2.6"
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { type TokenCounterAdapter, type TokenCountResult } from "./context-budget-token-counter.ts";
|
|
2
|
-
export type ContextBudgetCompressorMode = "off" | "auto" | "headroom" | "llmlingua";
|
|
3
|
-
export type ContextBudgetCompressionMethod = "compressed" | "none";
|
|
4
|
-
export interface ContextCompressionRequest {
|
|
5
|
-
readonly text: string;
|
|
6
|
-
readonly targetTokens: number;
|
|
7
|
-
readonly modelId: string;
|
|
8
|
-
readonly timeoutMs?: number;
|
|
9
|
-
readonly maxOutputChars?: number;
|
|
10
|
-
}
|
|
11
|
-
export interface ContextCompressionResult {
|
|
12
|
-
readonly text: string;
|
|
13
|
-
readonly method: ContextBudgetCompressionMethod;
|
|
14
|
-
readonly adapterId: string;
|
|
15
|
-
readonly input: TokenCountResult;
|
|
16
|
-
readonly output: TokenCountResult;
|
|
17
|
-
readonly notes: readonly string[];
|
|
18
|
-
}
|
|
19
|
-
export interface ContextCompressorAdapter {
|
|
20
|
-
readonly id: string;
|
|
21
|
-
readonly priority: number;
|
|
22
|
-
isAvailable(): Promise<boolean>;
|
|
23
|
-
compress(request: ContextCompressionRequest): Promise<ContextCompressionResult>;
|
|
24
|
-
}
|
|
25
|
-
export interface CommandRunRequest {
|
|
26
|
-
readonly command: string;
|
|
27
|
-
readonly args: readonly string[];
|
|
28
|
-
readonly input: string;
|
|
29
|
-
readonly timeoutMs: number;
|
|
30
|
-
}
|
|
31
|
-
export interface CommandRunResult {
|
|
32
|
-
readonly exitCode: number | null;
|
|
33
|
-
readonly stdout: string;
|
|
34
|
-
readonly stderr: string;
|
|
35
|
-
readonly timedOut: boolean;
|
|
36
|
-
}
|
|
37
|
-
export interface CommandRunner {
|
|
38
|
-
run(request: CommandRunRequest): Promise<CommandRunResult>;
|
|
39
|
-
}
|
|
40
|
-
export interface CliCompressorOptions {
|
|
41
|
-
readonly command?: string;
|
|
42
|
-
readonly runner?: CommandRunner;
|
|
43
|
-
readonly tokenCounter?: TokenCounterAdapter;
|
|
44
|
-
}
|
|
45
|
-
export declare function createNodeCommandRunner(): CommandRunner;
|
|
46
|
-
export declare function createHeadroomCliCompressor(options?: CliCompressorOptions): ContextCompressorAdapter;
|
|
47
|
-
export declare function createLlmlinguaCliCompressor(options?: CliCompressorOptions): ContextCompressorAdapter;
|
|
48
|
-
export declare function createContextCompressorForMode(mode: ContextBudgetCompressorMode, options?: CliCompressorOptions): ContextCompressorAdapter | undefined;
|
|
49
|
-
export declare function createCompressorRegistry(adapters: readonly ContextCompressorAdapter[]): ContextCompressorAdapter;
|
|
50
|
-
//# sourceMappingURL=context-budget-compressors.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-budget-compressors.d.ts","sourceRoot":"","sources":["../../src/core/context-budget-compressors.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,MAAM,mCAAmC,CAAC;AAE3C,MAAM,MAAM,2BAA2B,GAAG,KAAK,GAAG,MAAM,GAAG,UAAU,GAAG,WAAW,CAAC;AACpF,MAAM,MAAM,8BAA8B,GAAG,YAAY,GAAG,MAAM,CAAC;AAEnE,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,8BAA8B,CAAC;IAChD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;CAChF;AAED,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC7B,GAAG,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC3D;AAED,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC;IAChC,QAAQ,CAAC,YAAY,CAAC,EAAE,mBAAmB,CAAC;CAC5C;AAKD,wBAAgB,uBAAuB,IAAI,aAAa,CAqCvD;AAED,wBAAgB,2BAA2B,CAAC,OAAO,GAAE,oBAAyB,GAAG,wBAAwB,CASxG;AAED,wBAAgB,4BAA4B,CAAC,OAAO,GAAE,oBAAyB,GAAG,wBAAwB,CASzG;AAED,wBAAgB,8BAA8B,CAC7C,IAAI,EAAE,2BAA2B,EACjC,OAAO,GAAE,oBAAyB,GAChC,wBAAwB,GAAG,SAAS,CAWtC;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,SAAS,wBAAwB,EAAE,GAAG,wBAAwB,CAwBhH","sourcesContent":["import { spawn } from \"node:child_process\";\nimport {\n\tcreateFallbackTokenCounter,\n\ttype TokenCounterAdapter,\n\ttype TokenCountResult,\n} from \"./context-budget-token-counter.ts\";\n\nexport type ContextBudgetCompressorMode = \"off\" | \"auto\" | \"headroom\" | \"llmlingua\";\nexport type ContextBudgetCompressionMethod = \"compressed\" | \"none\";\n\nexport interface ContextCompressionRequest {\n\treadonly text: string;\n\treadonly targetTokens: number;\n\treadonly modelId: string;\n\treadonly timeoutMs?: number;\n\treadonly maxOutputChars?: number;\n}\n\nexport interface ContextCompressionResult {\n\treadonly text: string;\n\treadonly method: ContextBudgetCompressionMethod;\n\treadonly adapterId: string;\n\treadonly input: TokenCountResult;\n\treadonly output: TokenCountResult;\n\treadonly notes: readonly string[];\n}\n\nexport interface ContextCompressorAdapter {\n\treadonly id: string;\n\treadonly priority: number;\n\tisAvailable(): Promise<boolean>;\n\tcompress(request: ContextCompressionRequest): Promise<ContextCompressionResult>;\n}\n\nexport interface CommandRunRequest {\n\treadonly command: string;\n\treadonly args: readonly string[];\n\treadonly input: string;\n\treadonly timeoutMs: number;\n}\n\nexport interface CommandRunResult {\n\treadonly exitCode: number | null;\n\treadonly stdout: string;\n\treadonly stderr: string;\n\treadonly timedOut: boolean;\n}\n\nexport interface CommandRunner {\n\trun(request: CommandRunRequest): Promise<CommandRunResult>;\n}\n\nexport interface CliCompressorOptions {\n\treadonly command?: string;\n\treadonly runner?: CommandRunner;\n\treadonly tokenCounter?: TokenCounterAdapter;\n}\n\nconst DEFAULT_TIMEOUT_MS = 15_000;\nconst DEFAULT_MAX_OUTPUT_CHARS = 400_000;\n\nexport function createNodeCommandRunner(): CommandRunner {\n\treturn {\n\t\trun(request) {\n\t\t\treturn new Promise((resolve) => {\n\t\t\t\tconst child = spawn(request.command, [...request.args], { stdio: [\"pipe\", \"pipe\", \"pipe\"] });\n\t\t\t\tlet stdout = \"\";\n\t\t\t\tlet stderr = \"\";\n\t\t\t\tlet settled = false;\n\t\t\t\tconst timeout = setTimeout(() => {\n\t\t\t\t\tsettled = true;\n\t\t\t\t\tchild.kill(\"SIGTERM\");\n\t\t\t\t\tresolve({ exitCode: null, stdout, stderr, timedOut: true });\n\t\t\t\t}, request.timeoutMs);\n\t\t\t\tchild.stdout.setEncoding(\"utf8\");\n\t\t\t\tchild.stderr.setEncoding(\"utf8\");\n\t\t\t\tchild.stdout.on(\"data\", (chunk: string) => {\n\t\t\t\t\tstdout += chunk;\n\t\t\t\t});\n\t\t\t\tchild.stderr.on(\"data\", (chunk: string) => {\n\t\t\t\t\tstderr += chunk;\n\t\t\t\t});\n\t\t\t\tchild.on(\"error\", (error) => {\n\t\t\t\t\tif (settled) return;\n\t\t\t\t\tsettled = true;\n\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\tresolve({ exitCode: null, stdout, stderr: error.message, timedOut: false });\n\t\t\t\t});\n\t\t\t\tchild.on(\"close\", (exitCode) => {\n\t\t\t\t\tif (settled) return;\n\t\t\t\t\tsettled = true;\n\t\t\t\t\tclearTimeout(timeout);\n\t\t\t\t\tresolve({ exitCode, stdout, stderr, timedOut: false });\n\t\t\t\t});\n\t\t\t\tchild.stdin.end(request.input, \"utf8\");\n\t\t\t});\n\t\t},\n\t};\n}\n\nexport function createHeadroomCliCompressor(options: CliCompressorOptions = {}): ContextCompressorAdapter {\n\treturn createCliCompressor({\n\t\tid: \"headroom-cli\",\n\t\tpriority: 80,\n\t\tcommand: options.command ?? \"headroom\",\n\t\targs: (request) => [\"compress\", \"--target-tokens\", String(request.targetTokens), \"--model\", request.modelId],\n\t\trunner: options.runner,\n\t\ttokenCounter: options.tokenCounter,\n\t});\n}\n\nexport function createLlmlinguaCliCompressor(options: CliCompressorOptions = {}): ContextCompressorAdapter {\n\treturn createCliCompressor({\n\t\tid: \"llmlingua-cli\",\n\t\tpriority: 60,\n\t\tcommand: options.command ?? \"llmlingua\",\n\t\targs: (request) => [\"compress\", \"--target-tokens\", String(request.targetTokens), \"--model\", request.modelId],\n\t\trunner: options.runner,\n\t\ttokenCounter: options.tokenCounter,\n\t});\n}\n\nexport function createContextCompressorForMode(\n\tmode: ContextBudgetCompressorMode,\n\toptions: CliCompressorOptions = {},\n): ContextCompressorAdapter | undefined {\n\tif (mode === \"off\") {\n\t\treturn undefined;\n\t}\n\tif (mode === \"headroom\") {\n\t\treturn createHeadroomCliCompressor(options);\n\t}\n\tif (mode === \"llmlingua\") {\n\t\treturn createLlmlinguaCliCompressor(options);\n\t}\n\treturn createCompressorRegistry([createHeadroomCliCompressor(options), createLlmlinguaCliCompressor(options)]);\n}\n\nexport function createCompressorRegistry(adapters: readonly ContextCompressorAdapter[]): ContextCompressorAdapter {\n\tconst ordered = [...adapters].sort((a, b) => b.priority - a.priority || a.id.localeCompare(b.id));\n\treturn {\n\t\tid: \"context-compressor-registry\",\n\t\tpriority: 100,\n\t\tisAvailable: async () => true,\n\t\tasync compress(request) {\n\t\t\tconst notes: string[] = [];\n\t\t\tfor (const adapter of ordered) {\n\t\t\t\ttry {\n\t\t\t\t\tif (!(await adapter.isAvailable())) {\n\t\t\t\t\t\tnotes.push(`${adapter.id}:unavailable`);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst result = await adapter.compress(request);\n\t\t\t\t\treturn { ...result, notes: [...notes, ...result.notes] };\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = error instanceof Error ? error.message : \"unknown compressor failure\";\n\t\t\t\t\tnotes.push(`${adapter.id}:failed:${message}`);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn createNoCompressionResult(request, createFallbackTokenCounter(), notes);\n\t\t},\n\t};\n}\n\ninterface CliCompressorInternalOptions {\n\treadonly id: string;\n\treadonly priority: number;\n\treadonly command: string;\n\treadonly args: (request: ContextCompressionRequest) => readonly string[];\n\treadonly runner?: CommandRunner;\n\treadonly tokenCounter?: TokenCounterAdapter;\n}\n\nfunction createCliCompressor(options: CliCompressorInternalOptions): ContextCompressorAdapter {\n\tconst runner = options.runner ?? createNodeCommandRunner();\n\tconst tokenCounter = options.tokenCounter ?? createFallbackTokenCounter();\n\treturn {\n\t\tid: options.id,\n\t\tpriority: options.priority,\n\t\tasync isAvailable() {\n\t\t\tconst result = await runner.run({\n\t\t\t\tcommand: options.command,\n\t\t\t\targs: [\"--version\"],\n\t\t\t\tinput: \"\",\n\t\t\t\ttimeoutMs: 3_000,\n\t\t\t});\n\t\t\treturn result.exitCode === 0 && !result.timedOut;\n\t\t},\n\t\tasync compress(request) {\n\t\t\tconst input = tokenCounter.countText(request.text, request.modelId);\n\t\t\tif (input.tokens <= request.targetTokens) {\n\t\t\t\treturn createNoCompressionResult(request, tokenCounter, [`${options.id}:already-within-budget`]);\n\t\t\t}\n\t\t\tconst timeoutMs = request.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n\t\t\tconst result = await runner.run({\n\t\t\t\tcommand: options.command,\n\t\t\t\targs: options.args(request),\n\t\t\t\tinput: request.text,\n\t\t\t\ttimeoutMs,\n\t\t\t});\n\t\t\tif (result.timedOut) {\n\t\t\t\treturn createNoCompressionResult(request, tokenCounter, [`${options.id}:timeout`]);\n\t\t\t}\n\t\t\tif (result.exitCode !== 0) {\n\t\t\t\treturn createNoCompressionResult(request, tokenCounter, [\n\t\t\t\t\t`${options.id}:exit:${result.exitCode ?? \"null\"}`,\n\t\t\t\t]);\n\t\t\t}\n\t\t\tconst maxOutputChars = request.maxOutputChars ?? DEFAULT_MAX_OUTPUT_CHARS;\n\t\t\tconst outputText = result.stdout.slice(0, maxOutputChars);\n\t\t\tif (outputText.trim().length === 0) {\n\t\t\t\treturn createNoCompressionResult(request, tokenCounter, [`${options.id}:empty-output`]);\n\t\t\t}\n\t\t\tconst output = tokenCounter.countText(outputText, request.modelId);\n\t\t\treturn {\n\t\t\t\ttext: outputText,\n\t\t\t\tmethod: \"compressed\",\n\t\t\t\tadapterId: options.id,\n\t\t\t\tinput,\n\t\t\t\toutput,\n\t\t\t\tnotes: outputText.length < result.stdout.length ? [`${options.id}:output-truncated`] : [`${options.id}:ok`],\n\t\t\t};\n\t\t},\n\t};\n}\n\nfunction createNoCompressionResult(\n\trequest: ContextCompressionRequest,\n\ttokenCounter: TokenCounterAdapter,\n\tnotes: readonly string[],\n): ContextCompressionResult {\n\tconst input = tokenCounter.countText(request.text, request.modelId);\n\treturn {\n\t\ttext: request.text,\n\t\tmethod: \"none\",\n\t\tadapterId: \"none\",\n\t\tinput,\n\t\toutput: input,\n\t\tnotes,\n\t};\n}\n"]}
|