@darkbear9494/dsh-model-manager 0.7.0 → 0.7.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/README.md +88 -11
- package/client.js +1 -1
- package/cordis.patch.yml +8 -0
- package/lib/index.js +385 -166
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -17,7 +17,9 @@ it also follows DSH 0.2's model-selection contract: a route is assigned with `ag
|
|
|
17
17
|
before the step is prepared, instead of being rewritten at request time (which 0.2 aborts). Since
|
|
18
18
|
0.7.0 it registers its first real slash command: **`/readimage`** puts one message — and the images
|
|
19
19
|
attached to it — on the `vision` tier for that turn alone, then hands the session back to whatever
|
|
20
|
-
routing was in force.
|
|
20
|
+
routing was in force. Since 0.7.1 the same one-turn contract has a cheap end: **`/quicktask`** puts
|
|
21
|
+
one text message on the `execution` tier for that turn alone — the simple task or quick question
|
|
22
|
+
that does not deserve the main model.
|
|
21
23
|
|
|
22
24
|
## What it is
|
|
23
25
|
|
|
@@ -50,7 +52,9 @@ plans on the planning tier and implements on `main` in the same turn, with no ap
|
|
|
50
52
|
between — the label-driven tiers become a workflow instead of a setting. 0.7.0 adds the first
|
|
51
53
|
trigger that is a real slash command: `/readimage`, registered through the harness's `commands`
|
|
52
54
|
service, puts the one message that carries it — image attachments included — on the `vision` tier,
|
|
53
|
-
and only for that turn.
|
|
55
|
+
and only for that turn. 0.7.1 generalises that machinery into a family of one-turn commands and
|
|
56
|
+
adds its second member: `/quicktask` runs the one text message that carries it on the `execution`
|
|
57
|
+
tier, and only for that turn — the cheap end of the same contract. It is still deliberately
|
|
54
58
|
small: one ESM host file, one config schema, one bundled skill body, and one hand-written client
|
|
55
59
|
file that contributes a configuration card to the Plugins page. There is no build step for either
|
|
56
60
|
half.
|
|
@@ -799,6 +803,63 @@ selected. The system-prompt cheat sheet gains one line telling the agent that yo
|
|
|
799
803
|
The command name is configurable — `strategy.readImageCommand`, default `'readimage'`; an explicit
|
|
800
804
|
`''` disables both the command and the gesture. See [Configuration](#configuration).
|
|
801
805
|
|
|
806
|
+
### The `/quicktask` command
|
|
807
|
+
|
|
808
|
+
`/quicktask` puts **one text message** on the `execution` tier — the 执行 role, the one that serves
|
|
809
|
+
delegated implementation work — and only that message's turn. It is 0.7.1's second one-turn
|
|
810
|
+
command: the same machinery `/readimage` introduced in 0.7.0, pointed at the cheap end of the
|
|
811
|
+
tier list instead of the vision end. The use case is the request that does not deserve your main
|
|
812
|
+
model — "rename this variable", "what does this error mean", "list the failing tests" — typed
|
|
813
|
+
from a session that is otherwise riding an expensive composer pick:
|
|
814
|
+
|
|
815
|
+
```text
|
|
816
|
+
you: /quicktask what does this ESLint error mean?
|
|
817
|
+
→ the whole turn runs on the execution role, tool-loop steps included
|
|
818
|
+
you: now refactor the module properly
|
|
819
|
+
→ back on main (or planning, if plan mode or a planning skill is in force)
|
|
820
|
+
```
|
|
821
|
+
|
|
822
|
+
Everything about the [one-turn contract](#the-readimage-command) carries over unchanged — the
|
|
823
|
+
turn-keyed override, the precedence over plan mode and planning skills for that turn only, the
|
|
824
|
+
force-then-restore of a hand-picked composer model, the process-live scope, the unaffected
|
|
825
|
+
subagent sessions, and the plain-text gesture recognition (the token `/quicktask` anywhere in a
|
|
826
|
+
direct user message routes the same way the command does). What differs:
|
|
827
|
+
|
|
828
|
+
- **Text only, on purpose.** The registration declares no attachment support, and the harness's
|
|
829
|
+
command executor refuses an invocation carrying attachments before dispatch. An image belongs
|
|
830
|
+
to `/readimage`; a quick turn must never land on an execution model that cannot read it. The
|
|
831
|
+
handler defends the same contract defensively: if attachments ever reach it anyway, it returns
|
|
832
|
+
an error instead of forwarding.
|
|
833
|
+
- **No admission gate to bypass.** `/readimage` needs the command path because the ordinary
|
|
834
|
+
prompt path refuses images while a text-only model is selected. `/quicktask` forwards plain
|
|
835
|
+
text, so the command registration is mostly convenience — palette discoverability, the hint,
|
|
836
|
+
the description — and a plain-text `/quicktask` gesture routes identically without it.
|
|
837
|
+
- **Failover walks the execution chain.** The commanded turn's role is recorded as `execution`,
|
|
838
|
+
so in-step failover walks the execution role's own list — with your quick-task model first.
|
|
839
|
+
The turn resolves the role the same way delegated implementation work does; there is no
|
|
840
|
+
fallback below `execution` (it *is* the fallback). And a command whose role resolves to no
|
|
841
|
+
models is inert everywhere: the handler refuses, the cheat sheet stays quiet, and the
|
|
842
|
+
plain-text gesture does not bind either — so the report never claims a turn "ran on" a role
|
|
843
|
+
nothing was selected for.
|
|
844
|
+
- **Two commands, one message.** A message carrying both `/readimage` and `/quicktask` tokens
|
|
845
|
+
binds `/readimage`: the image is physically in the message and only a vision-capable model can
|
|
846
|
+
serve it, while a quick turn is a cost preference you can re-issue on the next message. A
|
|
847
|
+
`/readimage` turn chaining straight into a `/quicktask` turn switches roles cleanly, and a
|
|
848
|
+
later plain turn restores the composer pick remembered before the first commanded turn.
|
|
849
|
+
- **Both commands must keep their own names.** The registry does not refuse a duplicate command
|
|
850
|
+
name (a second registration would shadow the first), so the manager resolves a config that
|
|
851
|
+
points both commands at one name itself: the earlier command in its scan order keeps the name
|
|
852
|
+
and the later one is skipped with a warning.
|
|
853
|
+
|
|
854
|
+
Diagnostics mirror the read-image ones: `model_manager(action: "report")` names the trigger
|
|
855
|
+
`command:quicktask` and prints a `Quick-task command:` block for sessions whose last turn was
|
|
856
|
+
commanded, and `model_manager(action: "routes")` prints a line describing the command — or
|
|
857
|
+
saying it is disabled or not registered. The system-prompt cheat sheet gains one line telling
|
|
858
|
+
the agent that you can type `/quicktask` to run one message on the execution tier.
|
|
859
|
+
|
|
860
|
+
The command name is configurable — `strategy.quickTaskCommand`, default `'quicktask'`; an
|
|
861
|
+
explicit `''` disables both the command and the gesture. See [Configuration](#configuration).
|
|
862
|
+
|
|
802
863
|
### Switching models on DSH 0.2.x
|
|
803
864
|
|
|
804
865
|
DSH 0.2 moved model selection out of the request waterfall. The loop reads
|
|
@@ -1070,6 +1131,7 @@ Complete key set, with the schema defaults shown in comments:
|
|
|
1070
1131
|
# planningKeywords: omitted = the 24 built-ins; [] DISABLES that classifier
|
|
1071
1132
|
# planningSkills: omitted = ['grill-me', 'grilling']; [] DISABLES the trigger
|
|
1072
1133
|
readImageCommand: readimage # default: readimage; '' DISABLES the command and the text gesture
|
|
1134
|
+
quickTaskCommand: quicktask # default: quicktask; '' DISABLES the command and the text gesture
|
|
1073
1135
|
historyLimit: 300 # default: 300; any positive value floors to at least 1
|
|
1074
1136
|
autoDelegate: balanced # default: balanced; "off" | "balanced" | "eager" — the delegation policy
|
|
1075
1137
|
update: # 0.3.0 — automatic update check
|
|
@@ -1127,6 +1189,12 @@ Behaviours of `readConfig` worth knowing:
|
|
|
1127
1189
|
instead of failing registration at boot. A Settings save re-registers
|
|
1128
1190
|
the command under the new name immediately. See [The `/readimage`
|
|
1129
1191
|
command](#the-readimage-command).
|
|
1192
|
+
- `strategy.quickTaskCommand` (0.7.1) follows exactly the same grammar and disable semantics for
|
|
1193
|
+
the quick-task command — omitted means `'quicktask'`, `''` disables it, an invalid name warns
|
|
1194
|
+
and disables — and one further rule: if both command names resolve to the same string, the
|
|
1195
|
+
earlier command (read-image) keeps the name and the quick-task command is skipped with a
|
|
1196
|
+
warning, because the registry would otherwise only shadow one of them. See [The `/quicktask`
|
|
1197
|
+
command](#the-quicktask-command).
|
|
1130
1198
|
- `historyLimit` accepts any positive number, floored to an integer and raised to a
|
|
1131
1199
|
minimum of 1, so a fractional value cannot floor to 0 and silently disable usage
|
|
1132
1200
|
tracking. `0`, a negative number, a non-number or an absent key all mean 300.
|
|
@@ -1555,7 +1623,10 @@ planning tier is missing it says so, so a `plan:` label is never a silent no-op.
|
|
|
1555
1623
|
line saying that a top-level session which invoked one of those skills runs on the planning tier,
|
|
1556
1624
|
like plan mode; with no models behind the tier it stays quiet rather than advertising a trigger
|
|
1557
1625
|
that routes nowhere. One further line tells the agent that the user can type `/readimage` to put a
|
|
1558
|
-
single message on the vision tier (see [The `/readimage` command](#the-readimage-command))
|
|
1626
|
+
single message on the vision tier (see [The `/readimage` command](#the-readimage-command)), and
|
|
1627
|
+
one more that the user can type `/quicktask` to run a single message on the execution tier
|
|
1628
|
+
(see [The `/quicktask` command](#the-quicktask-command)) — each line only while its command is
|
|
1629
|
+
enabled, the manager is neither disabled nor advisory, and the tier actually has models.
|
|
1559
1630
|
|
|
1560
1631
|
## How it stays safe
|
|
1561
1632
|
|
|
@@ -1637,7 +1708,10 @@ degrades to a notice or a log line.
|
|
|
1637
1708
|
`readConfig`, `applyRoute`, `effectiveRouteOf`, `parseVersion`, `compareVersions`,
|
|
1638
1709
|
`installedVersion`, `profileHint`, `delegationPolicyText`, `skillNamesOfEvent` — the skill
|
|
1639
1710
|
fold's whole recognizer, so the gesture, injection and `tool/call` paths are testable without
|
|
1640
|
-
a session —
|
|
1711
|
+
a session — the gesture scanner `commandGestureInMessages` with its 0.7.0 alias
|
|
1712
|
+
`readImageGestureInMessages`, both command-name normalizers, and the default lists and
|
|
1713
|
+
command names (vision keywords, planning keywords, planning skills, read-image and
|
|
1714
|
+
quick-task).
|
|
1641
1715
|
- **It does not touch the subagent allow-list row**, precisely to avoid the duplicate
|
|
1642
1716
|
loader entry id that would abort startup.
|
|
1643
1717
|
- **The `model_manager` tool is read-only.** Its description says so and the
|
|
@@ -1650,8 +1724,8 @@ degrades to a notice or a log line.
|
|
|
1650
1724
|
npm test
|
|
1651
1725
|
```
|
|
1652
1726
|
|
|
1653
|
-
Runs the suites in child processes and aggregates the result — **
|
|
1654
|
-
**
|
|
1727
|
+
Runs the suites in child processes and aggregates the result — **1382 assertions** across
|
|
1728
|
+
**15 suites** at the time of writing. Each suite also runs on
|
|
1655
1729
|
its own: `node test/<name>.test.mjs`.
|
|
1656
1730
|
|
|
1657
1731
|
| Suite | Assertions | What it pins |
|
|
@@ -1669,7 +1743,8 @@ its own: `node test/<name>.test.mjs`.
|
|
|
1669
1743
|
| `autoplan-skill.test.mjs` | 42 | New in 0.6.0. The bundled `/autoplan` skill: the pure frontmatter parser (`parseSkillMarkdown`) accepting exactly a well-formed SKILL.md — CRLF, edge-trimming, a `---` line inside the body preserved, a `name:` line in the body not mistaken for frontmatter — and returning `undefined` for a missing/unclosed fence, an empty body, an empty description, an invalid name, and every hostile input without throwing; the shipped definition satisfying the runtime contract `dsh-skill` validates on `get()` (kebab name, non-empty description/content, both invocation flags, a string source) and its body carrying the load-bearing instructions (the `plan:`-labelled `subagent_fork`, the no-approval rule, the plan-mode boundary, the `subagent` fallback, the main-tier implementation phase) so it cannot be silently gutted; registration through a mock skills service — exactly once, the shipped definition, an info log naming the skill — and every degradation: a throwing `register()` and a composition with no skills service both leave `apply()` working with a warning, and `routes()` distinguishing registered from not; registration independent of `config.enabled`; and the routing invariant that `/autoplan` is not a planning skill — a top-level session that invoked it stays on the `main` tier, with `/grilling` as the escalating control. The packaging suite additionally pins that `skills/` is in `files` and the body ships. |
|
|
1670
1744
|
| `planning-skills.test.mjs` | 100 | New in 0.5.0. The skill → top-level `planning` escalation, in eight blocks: the pure event fold `skillNamesOfEvent` over all three records — the `skill-invocation` injection, the `/name` gesture in direct user text, and a model's `skill` `tool/call` with JSON arguments — including the gesture-boundary rules, hostile payloads that record nothing and never throw, and the grammar pinned **byte-identical against the real `dsh-tool-skill`** when a DSH install resolves; `planningSkills` configuration (absent → `grill-me`/`grilling`, explicit `[]` honoured, lowercasing/trimming/de-duplication, invalid names dropped, volatile refs unwrapped, no unknown-key warning either way, and the schema union accepting an array / rejecting anything else); the `modelManagerPlanningSkill` projection (key, `stateVersion`, `init`, folding all three event shapes, mixed-case canonicalization, same-reference returns that suppress republishing, `.parse` rejecting junk); the **live** `agent/pre-step` signal — registered prepended, routing the FIRST request of a gesture step, stickiness across later turns, non-listed skills left on `main`, `[]` disabling it, the enter/reject decision returned by identity, a dozen hostile payloads, a subagent never escalated, `agent/disposed` dropping the live signal, a volatile reload of `[]` applying to the next request, and the info notice firing once per switch; the **durable** signal (a resumed session routing planning from a logged invocation, gesture, or model tool call, a durable name inert under `[]`, and no throw when the projection service is absent); plan mode keeping its own behaviour and owning the trigger when both apply; an explicit composer pick still winning the route while the row records role `planning`; and both diagnostic surfaces — the `Planning skills:` line in `routes` and the `Planning skill trigger:` line in `report`, each in its enabled and disabled form. |
|
|
1671
1745
|
| `model-select.test.mjs` | 26 | New in 0.6.1. DSH 0.2's selection contract: the pure helpers (`sameSelection`, `planningSkillInMessages`, `selectionModelOf`); a claimed user message selects the role's route before the step is prepared — plain prompt → `main`, `/grilling` → `planning`, `/autoplan` → `main`, plan mode → `planning`, round-robin committing only on an applied selection, and a hand-picked composer model respected under `hybrid` while `managed` overrides it; the manager's own selection is not mistaken for a hand-picked one on the next turn; `agent/request` returns the step's fixed route untouched (the 0.2 crash path); `agent/pre-step` corrects the next step; failover selects the next model and does not retry the fixed step; and a 0.1.x agent without a selection surface keeps request-time rewriting. |
|
|
1672
|
-
| `readimage.test.mjs` |
|
|
1746
|
+
| `readimage.test.mjs` | 180 | New in 0.7.0. The `/readimage` command: the pure gesture helper `readImageGestureInMessages` (word-boundary recognition in direct user text, pinned against the real `dsh-tool-skill` grammar when a DSH install resolves) and `normalizeReadImageCommand` (the default, an explicit `''`, trimming/lowercasing, an invalid name disabling the feature with a warning), command registration through the `commands` service — name/input/handler registration, volatile rename and disable re-arming, and the handler's forwarding (frozen user message with a fresh UUID, the `/readimage` token included, attachments preserved by identity) plus every refusal path (bare command, disabled manager, advisory mode, vision-unconfigured, no inbox, throwing followup, aborted signal), the turn-keyed override lifecycle through the real seam order claim → current → pre-step → request (whole-turn vision routing including tool-loop steps, mid-turn steering not cancelling it, the next plain turn returning to normal routing, consecutive gestures), composer-pick force-then-restore — including the corner cases that the restore must hand back the user's LATEST pick (a newer composer pick made after or between commanded turns is kept, never clobbered by the stale memory) and that `main` does not eat the restored pick — precedence over plan mode and planning skills for the commanded turn only, subagent sessions never binding the override while their label routing is untouched, the legacy 0.1.x rewrite path with the explicit-selection bypass for that one turn, both diagnostic surfaces, the cheat sheet never advertising the command while disabled or advisory, and `agent/disposed` clean rebind. Since 0.7.1 the suite also pins the exact 0.7.0 usage-error wording, so the shared handler cannot drift it. |
|
|
1747
|
+
| `quicktask.test.mjs` | 183 | New in 0.7.1. The `/quicktask` command, sharing the 0.7.0 turn-command machinery: `normalizeQuickTaskCommand` grammar (and the read-image normalizer staying intact through the shared core), the generic gesture scanner `commandGestureInMessages` with `readImageGestureInMessages` pinned as its alias export, command registration without attachment support and the handler's text-only contract (attachments refused defensively even though the executor refuses them first, exact usage wording pinned), every refusal path with execution-specific texts (disabled, advisory, execution-unconfigured, no inbox, throwing followup, aborted), volatile rename/disable/invalid re-arming with the read-image sibling untouched, the turn-keyed override lifecycle on the execution role (whole-turn routing, mid-turn steering, consecutive gestures, non-integer turns never binding), the quick-task-specific corners — a both-gesture message binding read-image, a `/readimage` turn chaining into a `/quicktask` turn with the original pick restored at the end, name collisions resolved first-wins in BOTH directions (with `routes` naming the collision rather than a missing service, the warning firing once per colliding name rather than per save, and the gesture scan staying consistent with the registry), and the gesture staying inert while the execution tier is empty so the report never claims a turn it could not route — composer-pick force-then-restore (including the newer-pick rules), precedence over plan mode and planning skills, subagent label routing untouched, the legacy 0.1.x rewrite path recording `applied (quick-task command, one turn)`, both diagnostic surfaces (`Quick-task command:` blocks and routes lines, gated in every disabled/advisory/unconfigured form), and `agent/disposed` clean rebind. |
|
|
1673
1748
|
|
|
1674
1749
|
The suites are plain Node scripts — no test framework, and no dependency beyond Node itself.
|
|
1675
1750
|
|
|
@@ -1715,16 +1790,18 @@ outside the repository.
|
|
|
1715
1790
|
routes the planning fork, and the top-level session stays on `main` because `autoplan` is not in
|
|
1716
1791
|
`planningSkills`. A project-level skill file of the same name overrides the bundled body
|
|
1717
1792
|
entirely (see the override note above).
|
|
1718
|
-
- **The
|
|
1793
|
+
- **The one-turn command overrides are process-live.** `/readimage` and `/quicktask` are
|
|
1794
|
+
per-message intent, not durable session
|
|
1719
1795
|
state: nothing is folded into the log, so a restart loses an in-flight commanded turn's routing
|
|
1720
1796
|
and the next message routes normally. Type the gesture again to command a new turn.
|
|
1721
1797
|
- **Images need the command path on a text-only current model.** The plain-text gesture routes
|
|
1722
1798
|
text-only messages, but it cannot carry attachments past the admission gate: on DSH 0.2.x with a
|
|
1723
1799
|
text-only model selected, the harness refuses the images with `MODEL_DOES_NOT_SUPPORT_IMAGES`
|
|
1724
1800
|
before any routing hook runs. Only the registered command admits them.
|
|
1725
|
-
- **The
|
|
1726
|
-
register no command, and
|
|
1727
|
-
then have no path at all while a text-only model is selected.
|
|
1801
|
+
- **The commands need a `commands` service in the composition.** Older harnesses without one
|
|
1802
|
+
register no command, and both features degrade to gesture-only routing for text messages — images
|
|
1803
|
+
then have no path at all while a text-only model is selected. `/quicktask` loses only the palette
|
|
1804
|
+
entry; its plain-text gesture routes identically.
|
|
1728
1805
|
- **`hybrid` compares routes by value.** A child that deliberately names the same route as
|
|
1729
1806
|
the parent's effective route is indistinguishable from one that inherited it, and will
|
|
1730
1807
|
be rewritten to the role route.
|
package/client.js
CHANGED
|
@@ -64,7 +64,7 @@ window.__ModuleLoader__.load({
|
|
|
64
64
|
* test/packaging.test.mjs pins it equal to package.json, so a release that
|
|
65
65
|
* forgets to bump both fails the suite instead of shipping a wrong banner.
|
|
66
66
|
*/
|
|
67
|
-
const VERSION = '0.7.
|
|
67
|
+
const VERSION = '0.7.1';
|
|
68
68
|
/**
|
|
69
69
|
* Registry path of this package. The scoped name is percent-encoded the
|
|
70
70
|
* way npm serves scoped packuments.
|
package/cordis.patch.yml
CHANGED
|
@@ -55,6 +55,14 @@
|
|
|
55
55
|
# selected. Omitting the key uses the built-in 'readimage'; an
|
|
56
56
|
# explicit '' disables the command and the gesture scan.
|
|
57
57
|
# readImageCommand: readimage
|
|
58
|
+
# Quick-task command (0.7.1): the turn carrying `/quicktask` runs on
|
|
59
|
+
# the execution role — the same one-turn contract, pointed at the
|
|
60
|
+
# cheap end: a simple task or quick question that does not deserve
|
|
61
|
+
# the main model. Text only (the executor refuses attachments for
|
|
62
|
+
# it; images belong to /readimage), and the next message routes
|
|
63
|
+
# normally again. Omitting the key uses the built-in 'quicktask';
|
|
64
|
+
# an explicit '' disables the command and the gesture scan.
|
|
65
|
+
# quickTaskCommand: quicktask
|
|
58
66
|
# Auto-delegation policy (0.3.0): off | balanced | eager.
|
|
59
67
|
# Adds a system-prompt section telling the top-level agent to plan
|
|
60
68
|
# and dispatch subagents instead of doing everything itself.
|
package/lib/index.js
CHANGED
|
@@ -53,7 +53,7 @@ const ROLE_NAMES = ['main', 'planning', 'execution', 'vision'];
|
|
|
53
53
|
const KNOWN_TOP_KEYS = ['enabled', 'pick', 'roles', 'strategy', 'update'];
|
|
54
54
|
const KNOWN_ROLE_KEYS = ['models', 'note'];
|
|
55
55
|
const KNOWN_ROUTE_KEYS = ['provider', 'model', 'reasoningEffort'];
|
|
56
|
-
const KNOWN_STRATEGY_KEYS = ['mode', 'visionKeywords', 'planningKeywords', 'planningSkills', 'readImageCommand', 'historyLimit', 'autoDelegate'];
|
|
56
|
+
const KNOWN_STRATEGY_KEYS = ['mode', 'visionKeywords', 'planningKeywords', 'planningSkills', 'readImageCommand', 'quickTaskCommand', 'historyLimit', 'autoDelegate'];
|
|
57
57
|
const KNOWN_UPDATE_KEYS = ['enabled', 'registry', 'intervalHours'];
|
|
58
58
|
|
|
59
59
|
/**
|
|
@@ -189,6 +189,80 @@ const DEFAULT_PLANNING_SKILLS = ['grill-me', 'grilling'];
|
|
|
189
189
|
*/
|
|
190
190
|
const DEFAULT_READ_IMAGE_COMMAND = 'readimage';
|
|
191
191
|
|
|
192
|
+
/**
|
|
193
|
+
* The command that puts ONE turn on the execution role (0.7.1).
|
|
194
|
+
*
|
|
195
|
+
* `/quicktask` is the cheap end of the same one-turn contract `/readimage`
|
|
196
|
+
* holds for vision: the turn carrying it runs on the execution tier (the
|
|
197
|
+
* 执行 role) — the tier that serves delegated implementation work — and the
|
|
198
|
+
* next message without it routes normally again. It exists for the quick
|
|
199
|
+
* request that does not deserve the main model: a rename, a one-line lookup,
|
|
200
|
+
* a "what does this error mean". It outranks plan mode, planning skills and a
|
|
201
|
+
* composer-picked model for its turn only, and the pick is restored
|
|
202
|
+
* afterwards, exactly like `/readimage`. Text only, on purpose: unlike
|
|
203
|
+
* `/readimage` the command does not declare attachment support, so the
|
|
204
|
+
* harness's executor refuses an invocation carrying attachments before
|
|
205
|
+
* dispatch — an image belongs to `/readimage`, and a quick turn must never
|
|
206
|
+
* land on an execution model that cannot read it. An empty string disables
|
|
207
|
+
* it.
|
|
208
|
+
*/
|
|
209
|
+
const DEFAULT_QUICK_TASK_COMMAND = 'quicktask';
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* The manager's one-turn commands: per-message intent that owns its whole
|
|
213
|
+
* turn, then expires (0.7.1 generalises the 0.7.0 `/readimage` machinery).
|
|
214
|
+
*
|
|
215
|
+
* Each entry names the `strategy` key holding its command name, the role its
|
|
216
|
+
* turn runs on, and the surface texts (registration, refusal, routes,
|
|
217
|
+
* report); the engine machinery — turn binding, composer-pick restore,
|
|
218
|
+
* precedence over plan mode and planning skills, registration and re-arm —
|
|
219
|
+
* is shared and generic. `feature` is the label used in reasons and logs,
|
|
220
|
+
* `reportLabel` the heading the report block prints.
|
|
221
|
+
*
|
|
222
|
+
* The list order is also the precedence order for the gesture scan: a
|
|
223
|
+
* message carrying two command tokens binds the FIRST match, so `/readimage`
|
|
224
|
+
* wins over `/quicktask` — the image is physically in the message and only a
|
|
225
|
+
* vision-capable model can serve it, while `/quicktask` is a cost preference
|
|
226
|
+
* the user can re-issue on the next message.
|
|
227
|
+
*/
|
|
228
|
+
const TURN_COMMANDS = [
|
|
229
|
+
{
|
|
230
|
+
key: 'readImage',
|
|
231
|
+
field: 'readImageCommand',
|
|
232
|
+
defaultName: DEFAULT_READ_IMAGE_COMMAND,
|
|
233
|
+
role: 'vision',
|
|
234
|
+
feature: 'read-image',
|
|
235
|
+
reportLabel: 'Read-image command:',
|
|
236
|
+
configureHint: 'set roles.vision.models to an image-capable model',
|
|
237
|
+
registeredNote: 'Registered with attachment support, so images pass admission even on a text-only current model.',
|
|
238
|
+
unregisteredNote: 'NOT registered (no commands service, or registration failed — see the startup log) — '
|
|
239
|
+
+ 'only plain-text gestures route; images still need a current model that accepts them.',
|
|
240
|
+
description: 'Read attached images with the vision model: this message (and its turn) runs on the '
|
|
241
|
+
+ "manager's vision role, then the next message returns to the normal route. Accepts image attachments.",
|
|
242
|
+
hint: 'question about the attached image(s)',
|
|
243
|
+
usageHint: 'question',
|
|
244
|
+
attachments: true,
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
key: 'quickTask',
|
|
248
|
+
field: 'quickTaskCommand',
|
|
249
|
+
defaultName: DEFAULT_QUICK_TASK_COMMAND,
|
|
250
|
+
role: 'execution',
|
|
251
|
+
feature: 'quick-task',
|
|
252
|
+
reportLabel: 'Quick-task command:',
|
|
253
|
+
configureHint: 'set roles.execution.models to the model simple tasks should run on',
|
|
254
|
+
registeredNote: 'Registered as a real command; a plain-text /name gesture routes the same turn.',
|
|
255
|
+
unregisteredNote: 'NOT registered (no commands service, or registration failed — see the startup log); '
|
|
256
|
+
+ 'plain-text gestures still route the same turn, only the palette entry is missing.',
|
|
257
|
+
description: 'Run one simple task on the execution model: this message (and its turn) runs on the '
|
|
258
|
+
+ "manager's execution role, then the next message returns to the normal route. Text only — images "
|
|
259
|
+
+ 'belong to the read-image command.',
|
|
260
|
+
hint: 'simple task or question',
|
|
261
|
+
usageHint: 'simple task or question',
|
|
262
|
+
attachments: false,
|
|
263
|
+
},
|
|
264
|
+
];
|
|
265
|
+
|
|
192
266
|
/**
|
|
193
267
|
* The public DSH skill-name grammar and the `/name` gesture the harness scans
|
|
194
268
|
* for in direct user text.
|
|
@@ -353,6 +427,7 @@ function buildConfigSchema(z) {
|
|
|
353
427
|
planningKeywords: z.array(z.string()).default(DEFAULT_PLANNING_KEYWORDS),
|
|
354
428
|
planningSkills: z.array(z.string()).default(DEFAULT_PLANNING_SKILLS),
|
|
355
429
|
readImageCommand: z.string().default(DEFAULT_READ_IMAGE_COMMAND),
|
|
430
|
+
quickTaskCommand: z.string().default(DEFAULT_QUICK_TASK_COMMAND),
|
|
356
431
|
historyLimit: z.number().default(300),
|
|
357
432
|
autoDelegate: z.union([z.const('off'), z.const('balanced'), z.const('eager')]).default('balanced'),
|
|
358
433
|
});
|
|
@@ -468,31 +543,42 @@ function normalizeSkillNames(value) {
|
|
|
468
543
|
}
|
|
469
544
|
|
|
470
545
|
/**
|
|
471
|
-
* Normalize `strategy.readImageCommand
|
|
546
|
+
* Normalize a one-turn command name (`strategy.readImageCommand` /
|
|
547
|
+
* `strategy.quickTaskCommand`).
|
|
472
548
|
*
|
|
473
|
-
* An absent or non-string value takes the built-in default (the
|
|
474
|
-
* philosophy as the keyword lists: a malformed value must not
|
|
475
|
-
* a feature off). An explicit empty string is honoured and
|
|
476
|
-
* command registration and the gesture scan. A name
|
|
477
|
-
* a warning and disables the feature: it must be
|
|
478
|
-
* scanner AND start with a letter for the command
|
|
479
|
-
* `COMMAND_NAME`, so a name failing either could never be
|
|
480
|
-
* command — better to refuse it at config time than fail
|
|
549
|
+
* An absent or non-string value takes the command's built-in default (the
|
|
550
|
+
* same fail-on philosophy as the keyword lists: a malformed value must not
|
|
551
|
+
* silently switch a feature off). An explicit empty string is honoured and
|
|
552
|
+
* disables both the command registration and the gesture scan. A name
|
|
553
|
+
* outside the grammar logs a warning and disables the feature: it must be
|
|
554
|
+
* kebab-case for the gesture scanner AND start with a letter for the command
|
|
555
|
+
* registry's own `COMMAND_NAME`, so a name failing either could never be
|
|
556
|
+
* invoked as a command — better to refuse it at config time than fail
|
|
557
|
+
* registration at boot.
|
|
481
558
|
*/
|
|
482
|
-
const
|
|
559
|
+
const COMMAND_NAME = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
483
560
|
|
|
484
|
-
function
|
|
561
|
+
function normalizeCommandName(value, warnings, field, fallback) {
|
|
485
562
|
const raw = readVal(value);
|
|
486
|
-
if (raw === undefined || raw === null || typeof raw !== 'string') return
|
|
563
|
+
if (raw === undefined || raw === null || typeof raw !== 'string') return fallback;
|
|
487
564
|
const name = raw.trim().toLowerCase();
|
|
488
565
|
if (name === '') return '';
|
|
489
|
-
if (!
|
|
490
|
-
warnings?.push(`strategy
|
|
566
|
+
if (!COMMAND_NAME.test(name)) {
|
|
567
|
+
warnings?.push(`strategy.${field} "${raw}" is not a lowercase kebab-case name starting with a letter; the ${field === 'readImageCommand' ? 'read-image' : 'quick-task'} command is disabled`);
|
|
491
568
|
return '';
|
|
492
569
|
}
|
|
493
570
|
return name;
|
|
494
571
|
}
|
|
495
572
|
|
|
573
|
+
function normalizeReadImageCommand(value, warnings) {
|
|
574
|
+
return normalizeCommandName(value, warnings, 'readImageCommand', DEFAULT_READ_IMAGE_COMMAND);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/** Normalize `strategy.quickTaskCommand` (0.7.1); see {@link normalizeCommandName}. */
|
|
578
|
+
function normalizeQuickTaskCommand(value, warnings) {
|
|
579
|
+
return normalizeCommandName(value, warnings, 'quickTaskCommand', DEFAULT_QUICK_TASK_COMMAND);
|
|
580
|
+
}
|
|
581
|
+
|
|
496
582
|
function normalizeRoute(raw) {
|
|
497
583
|
const value = readVal(raw);
|
|
498
584
|
if (value === null || typeof value !== 'object') return undefined;
|
|
@@ -722,6 +808,9 @@ function readConfig(raw) {
|
|
|
722
808
|
// Absent/malformed -> 'readimage'; explicit '' switches the one-turn
|
|
723
809
|
// vision command off; an invalid name warns and disables it.
|
|
724
810
|
readImageCommand: normalizeReadImageCommand(strategyRaw.readImageCommand, warnings),
|
|
811
|
+
// Absent/malformed -> 'quicktask'; explicit '' switches the one-turn
|
|
812
|
+
// execution command off; an invalid name warns and disables it.
|
|
813
|
+
quickTaskCommand: normalizeQuickTaskCommand(strategyRaw.quickTaskCommand, warnings),
|
|
725
814
|
// Guard against a positive fraction flooring to 0, which would evict every
|
|
726
815
|
// record immediately and silently disable usage tracking.
|
|
727
816
|
historyLimit: Number.isFinite(limit) && limit > 0 ? Math.max(1, Math.floor(limit)) : 300,
|
|
@@ -847,16 +936,16 @@ function planningSkillInMessages(messages, wanted) {
|
|
|
847
936
|
}
|
|
848
937
|
|
|
849
938
|
/**
|
|
850
|
-
* Whether a batch of user messages carries
|
|
939
|
+
* Whether a batch of user messages carries a given command's gesture. Pure.
|
|
851
940
|
*
|
|
852
941
|
* Recognition uses the harness's own `/name` grammar (the same word-boundary
|
|
853
|
-
* shape tool-skill scans), so `/readimage` reads as a gesture
|
|
854
|
-
* in the sentence while file paths and fractions never match.
|
|
855
|
-
* text counts — no other source can forge the gesture. The
|
|
856
|
-
*
|
|
857
|
-
* carries the gesture into the routing seams below.
|
|
942
|
+
* shape tool-skill scans), so `/readimage` or `/quicktask` reads as a gesture
|
|
943
|
+
* wherever it sits in the sentence while file paths and fractions never match.
|
|
944
|
+
* Only direct user text counts — no other source can forge the gesture. The
|
|
945
|
+
* command handlers forward the original line, token included, so the claimed
|
|
946
|
+
* message they queue carries the gesture into the routing seams below.
|
|
858
947
|
*/
|
|
859
|
-
function
|
|
948
|
+
function commandGestureInMessages(messages, command) {
|
|
860
949
|
if (typeof command !== 'string' || command === '') return false;
|
|
861
950
|
for (const message of Array.isArray(messages) ? messages : []) {
|
|
862
951
|
if (message?.source?.kind !== 'user') continue;
|
|
@@ -870,6 +959,12 @@ function readImageGestureInMessages(messages, command) {
|
|
|
870
959
|
return false;
|
|
871
960
|
}
|
|
872
961
|
|
|
962
|
+
/**
|
|
963
|
+
* The 0.7.0 export name for {@link commandGestureInMessages}, kept stable for
|
|
964
|
+
* the read-image test surface; the function itself is command-agnostic.
|
|
965
|
+
*/
|
|
966
|
+
const readImageGestureInMessages = commandGestureInMessages;
|
|
967
|
+
|
|
873
968
|
/** Find the delegating parent of a child session. */
|
|
874
969
|
function findParent(ctx, childId) {
|
|
875
970
|
return probe(() => {
|
|
@@ -1171,14 +1266,19 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1171
1266
|
|
|
1172
1267
|
/**
|
|
1173
1268
|
* The `commands` service, captured when its injection resolves, plus the
|
|
1174
|
-
* live
|
|
1175
|
-
*
|
|
1176
|
-
*
|
|
1177
|
-
*
|
|
1269
|
+
* live registrations of the one-turn commands. `commandRegistrations` maps
|
|
1270
|
+
* each TURN_COMMANDS key to `{ name, dispose }` — the name actually
|
|
1271
|
+
* registered ('' when none) — so a volatile Settings save that renames a
|
|
1272
|
+
* command can dispose the old registration and arm the new one, and
|
|
1273
|
+
* `routes` can tell "configured" from "registered in this composition".
|
|
1178
1274
|
*/
|
|
1179
1275
|
let commandsService;
|
|
1180
|
-
|
|
1181
|
-
|
|
1276
|
+
const commandRegistrations = new Map();
|
|
1277
|
+
/**
|
|
1278
|
+
* TURN_COMMANDS key -> the colliding name already warned about, so an
|
|
1279
|
+
* unchanged volatile save does not repeat the collision warning.
|
|
1280
|
+
*/
|
|
1281
|
+
const commandCollisionWarned = new Map();
|
|
1182
1282
|
|
|
1183
1283
|
/**
|
|
1184
1284
|
* Latest update-check outcome. Statuses: `idle` (not yet checked), `checking`,
|
|
@@ -1222,21 +1322,23 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1222
1322
|
const topTriggers = new Map();
|
|
1223
1323
|
|
|
1224
1324
|
/**
|
|
1225
|
-
* session id -> `{ turn, restore }` for the ONE turn
|
|
1325
|
+
* session id -> `{ turn, restore, command }` for the ONE turn a one-turn
|
|
1326
|
+
* command owns (`/readimage` since 0.7.0, `/quicktask` since 0.7.1).
|
|
1226
1327
|
*
|
|
1227
1328
|
* The override is keyed to the turn number that claimed the gesture, which
|
|
1228
1329
|
* is what makes it expire by itself: every later step of that turn compares
|
|
1229
|
-
* equal and stays on
|
|
1230
|
-
* different and ends it. `restore` remembers a hand-picked
|
|
1231
|
-
* command overrode (hybrid normally respects it), so the
|
|
1232
|
-
* back when the commanded turn ends instead of being
|
|
1330
|
+
* equal and stays on the command's role, while the first claim of any other
|
|
1331
|
+
* turn compares different and ends it. `restore` remembers a hand-picked
|
|
1332
|
+
* composer route the command overrode (hybrid normally respects it), so the
|
|
1333
|
+
* pick is selected back when the commanded turn ends instead of being
|
|
1334
|
+
* silently dropped.
|
|
1233
1335
|
*
|
|
1234
1336
|
* Deliberately process-live, with no durable projection: this is per-message
|
|
1235
1337
|
* intent, not session state. After a restart the next message routes
|
|
1236
1338
|
* normally, which is exactly the contract — only a fresh gesture commands a
|
|
1237
1339
|
* fresh turn.
|
|
1238
1340
|
*/
|
|
1239
|
-
const
|
|
1341
|
+
const commandTurns = new Map();
|
|
1240
1342
|
|
|
1241
1343
|
/** Add one skill name to a session's live list, bounded and de-duplicated. */
|
|
1242
1344
|
function addLiveSkill(id, name) {
|
|
@@ -1307,15 +1409,16 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1307
1409
|
for (const name of skillNamesOfMessage(message)) addLiveSkill(id, name);
|
|
1308
1410
|
}
|
|
1309
1411
|
}
|
|
1310
|
-
// The
|
|
1311
|
-
// claim boundary covers the first step, and this scan covers a
|
|
1312
|
-
// whose claim notification predates the listener (or a batch
|
|
1313
|
-
// seam never saw). Top-level only — a child's routing stays
|
|
1412
|
+
// The one-turn command override binds here too, on every transport:
|
|
1413
|
+
// the claim boundary covers the first step, and this scan covers a
|
|
1414
|
+
// harness whose claim notification predates the listener (or a batch
|
|
1415
|
+
// the claim seam never saw). Top-level only — a child's routing stays
|
|
1416
|
+
// label-driven.
|
|
1314
1417
|
if (!isSubagent) {
|
|
1315
1418
|
for (const batch of [payload?.messages, decision?.messages]) {
|
|
1316
|
-
if (Array.isArray(batch))
|
|
1419
|
+
if (Array.isArray(batch)) noteCommandGesture(agent, batch, payload?.turn);
|
|
1317
1420
|
}
|
|
1318
|
-
|
|
1421
|
+
endCommandTurn(agent, payload?.turn);
|
|
1319
1422
|
}
|
|
1320
1423
|
}
|
|
1321
1424
|
// On a harness that fixes the route at step preparation, keep the
|
|
@@ -1331,15 +1434,15 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1331
1434
|
applySelection(agent, classifySubagent(facts.label), undefined, facts.label, true);
|
|
1332
1435
|
}
|
|
1333
1436
|
} else {
|
|
1334
|
-
const
|
|
1437
|
+
const command = commandActive(agent, payload?.turn);
|
|
1335
1438
|
const plan = planActive(ctx, agent);
|
|
1336
|
-
const skill = plan ||
|
|
1337
|
-
const trigger =
|
|
1338
|
-
? `command:${config.strategy.
|
|
1439
|
+
const skill = plan || command ? undefined : planningSkillFor(agent);
|
|
1440
|
+
const trigger = command
|
|
1441
|
+
? `command:${config.strategy[command.field]}`
|
|
1339
1442
|
: skill === undefined ? (plan ? 'plan-mode' : 'main') : `skill:${skill}`;
|
|
1340
|
-
noteTopTrigger(agent, trigger);
|
|
1341
|
-
applySelection(agent,
|
|
1342
|
-
trigger, undefined, false,
|
|
1443
|
+
noteTopTrigger(agent, trigger, command);
|
|
1444
|
+
applySelection(agent, command ? command.role : plan || skill !== undefined ? 'planning' : 'main',
|
|
1445
|
+
trigger, undefined, false, command !== undefined);
|
|
1343
1446
|
}
|
|
1344
1447
|
}
|
|
1345
1448
|
} catch {
|
|
@@ -1348,8 +1451,13 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1348
1451
|
return decision;
|
|
1349
1452
|
}
|
|
1350
1453
|
|
|
1351
|
-
/**
|
|
1352
|
-
|
|
1454
|
+
/**
|
|
1455
|
+
* Log a top-level trigger once per switch, never once per request.
|
|
1456
|
+
*
|
|
1457
|
+
* `command` is the active one-turn command descriptor when `trigger` is a
|
|
1458
|
+
* `command:` trigger, so the log names the role its turn runs on.
|
|
1459
|
+
*/
|
|
1460
|
+
function noteTopTrigger(agent, trigger, command) {
|
|
1353
1461
|
const id = typeof agent?.id === 'string' ? agent.id : undefined;
|
|
1354
1462
|
if (id === undefined) return;
|
|
1355
1463
|
if (topTriggers.get(id) === trigger) return;
|
|
@@ -1358,17 +1466,46 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1358
1466
|
log('info', `planning skill "${trigger.slice('skill:'.length)}" is active in this session; `
|
|
1359
1467
|
+ 'top-level requests route as planning');
|
|
1360
1468
|
}
|
|
1361
|
-
if (trigger.startsWith('command:')) {
|
|
1362
|
-
log('info', `/${trigger.slice('command:'.length)} commands this turn on the
|
|
1469
|
+
if (trigger.startsWith('command:') && command !== undefined) {
|
|
1470
|
+
log('info', `/${trigger.slice('command:'.length)} commands this turn on the ${command.role} role; `
|
|
1363
1471
|
+ 'the next message without the gesture returns to the normal route');
|
|
1364
1472
|
}
|
|
1365
1473
|
}
|
|
1366
1474
|
|
|
1367
|
-
/**
|
|
1368
|
-
|
|
1369
|
-
|
|
1475
|
+
/**
|
|
1476
|
+
* The one-turn command owning the turn a step belongs to, or `undefined`.
|
|
1477
|
+
* A bound turn only answers for its own turn number: a mid-turn steering
|
|
1478
|
+
* message (no gesture, same turn) keeps the command; a later turn does not.
|
|
1479
|
+
*/
|
|
1480
|
+
function commandActive(agent, turn) {
|
|
1481
|
+
if (!Number.isSafeInteger(turn)) return undefined;
|
|
1370
1482
|
const id = typeof agent?.id === 'string' ? agent.id : undefined;
|
|
1371
|
-
|
|
1483
|
+
const active = id === undefined ? undefined : commandTurns.get(id);
|
|
1484
|
+
return active !== undefined && active.turn === turn ? active.command : undefined;
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
/**
|
|
1488
|
+
* The first TURN_COMMANDS descriptor whose configured name appears as a
|
|
1489
|
+
* gesture in a batch of user messages, or `undefined`.
|
|
1490
|
+
*
|
|
1491
|
+
* `TURN_COMMANDS` order decides a message carrying two command tokens:
|
|
1492
|
+
* `/readimage` beats `/quicktask`, because the image in the message can
|
|
1493
|
+
* only be served by a vision-capable model while a quick turn is a cost
|
|
1494
|
+
* preference the user can re-issue.
|
|
1495
|
+
*
|
|
1496
|
+
* A command whose role resolves to no models never binds: there is no
|
|
1497
|
+
* route to command, and binding anyway would let the report claim a turn
|
|
1498
|
+
* "ran on" a role nothing was selected for. The handler and the cheat
|
|
1499
|
+
* sheet gate on the same emptiness, so every surface then agrees: the
|
|
1500
|
+
* gesture is inert, not half-alive.
|
|
1501
|
+
*/
|
|
1502
|
+
function turnCommandInMessages(messages) {
|
|
1503
|
+
for (const command of TURN_COMMANDS) {
|
|
1504
|
+
const name = config.strategy[command.field];
|
|
1505
|
+
if (name !== '' && effectiveModels(command.role).length > 0
|
|
1506
|
+
&& commandGestureInMessages(messages, name)) return command;
|
|
1507
|
+
}
|
|
1508
|
+
return undefined;
|
|
1372
1509
|
}
|
|
1373
1510
|
|
|
1374
1511
|
/**
|
|
@@ -1379,23 +1516,24 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1379
1516
|
* that OWNS the message — a mid-turn steering message without the gesture
|
|
1380
1517
|
* cannot steal or cancel it. A consecutive commanded turn keeps the original
|
|
1381
1518
|
* `restore` route: the pick to hand back is the one from before the first
|
|
1382
|
-
* override, never the
|
|
1519
|
+
* override, never the role route the manager itself selected.
|
|
1383
1520
|
*/
|
|
1384
|
-
function
|
|
1385
|
-
|
|
1386
|
-
if (command === '' || !Number.isSafeInteger(turn)) return;
|
|
1521
|
+
function noteCommandGesture(agent, messages, turn) {
|
|
1522
|
+
if (!Number.isSafeInteger(turn)) return;
|
|
1387
1523
|
const id = typeof agent?.id === 'string' ? agent.id : undefined;
|
|
1388
|
-
if (id === undefined
|
|
1389
|
-
const
|
|
1524
|
+
if (id === undefined) return;
|
|
1525
|
+
const command = turnCommandInMessages(messages);
|
|
1526
|
+
if (command === undefined) return;
|
|
1527
|
+
const existing = commandTurns.get(id);
|
|
1390
1528
|
if (existing?.turn === turn) return;
|
|
1391
1529
|
const current = probe(() => selectionModelOf(agent)?.current());
|
|
1392
1530
|
// A pick made after the previous commanded turn is newer than the one
|
|
1393
1531
|
// remembered then, so it replaces the memory: what must come back is the
|
|
1394
1532
|
// user's LATEST choice, never a stale one. When current is the manager's
|
|
1395
|
-
// own
|
|
1396
|
-
// memory stands.
|
|
1533
|
+
// own route for the previous commanded turn (the ordinary case) it is not
|
|
1534
|
+
// foreign and the original memory stands.
|
|
1397
1535
|
const restore = (selectionIsForeign(agent, current) ? current : undefined) ?? existing?.restore;
|
|
1398
|
-
|
|
1536
|
+
commandTurns.set(id, { turn, restore, command });
|
|
1399
1537
|
}
|
|
1400
1538
|
|
|
1401
1539
|
/**
|
|
@@ -1409,12 +1547,12 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1409
1547
|
* rewrite path nothing was ever durably selected, so there is nothing to
|
|
1410
1548
|
* restore and the pick survives on its own.
|
|
1411
1549
|
*/
|
|
1412
|
-
function
|
|
1550
|
+
function endCommandTurn(agent, turn) {
|
|
1413
1551
|
const id = typeof agent?.id === 'string' ? agent.id : undefined;
|
|
1414
1552
|
if (id === undefined || !Number.isSafeInteger(turn)) return;
|
|
1415
|
-
const active =
|
|
1553
|
+
const active = commandTurns.get(id);
|
|
1416
1554
|
if (active === undefined || active.turn === turn) return;
|
|
1417
|
-
|
|
1555
|
+
commandTurns.delete(id);
|
|
1418
1556
|
if (active.restore === undefined) return;
|
|
1419
1557
|
if (!config.enabled || config.strategy.mode === 'advisory') return;
|
|
1420
1558
|
const model = selectionModelOf(agent);
|
|
@@ -1436,12 +1574,37 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1436
1574
|
});
|
|
1437
1575
|
managerSelected.delete(id);
|
|
1438
1576
|
log('info', `restored the hand-picked ${active.restore.provider}/${active.restore.model} `
|
|
1439
|
-
+ `for ${shortId(id)} after the
|
|
1577
|
+
+ `for ${shortId(id)} after the ${active.command.feature} turn`);
|
|
1440
1578
|
} catch (error) {
|
|
1441
1579
|
log('warn', `could not restore the hand-picked route: ${error?.message ?? error}`);
|
|
1442
1580
|
}
|
|
1443
1581
|
}
|
|
1444
1582
|
|
|
1583
|
+
/**
|
|
1584
|
+
* First-wins name ownership across the one-turn commands, in `TURN_COMMANDS`
|
|
1585
|
+
* order: the name each command's live config value resolves to, mapped to
|
|
1586
|
+
* the command that owns it. Used by the registration (the registry itself
|
|
1587
|
+
* only shadows a duplicate name) and by the `routes` note, so the two can
|
|
1588
|
+
* never disagree about who owns a token.
|
|
1589
|
+
*/
|
|
1590
|
+
function turnCommandOwners() {
|
|
1591
|
+
const owner = new Map();
|
|
1592
|
+
for (const command of TURN_COMMANDS) {
|
|
1593
|
+
const name = config.strategy[command.field];
|
|
1594
|
+
if (name !== '' && !owner.has(name)) owner.set(name, command);
|
|
1595
|
+
}
|
|
1596
|
+
return owner;
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
/**
|
|
1600
|
+
* Whether a one-turn command is registered under its live config name —
|
|
1601
|
+
* the fact `routes` reports next to each command, so an operator can tell
|
|
1602
|
+
* "configured" from "actually invocable in this composition".
|
|
1603
|
+
*/
|
|
1604
|
+
function commandRegistered(command) {
|
|
1605
|
+
return commandRegistrations.get(command.key)?.name === config.strategy[command.field];
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1445
1608
|
/** The model list a role actually resolves to, including the vision fallback. */
|
|
1446
1609
|
function effectiveModels(key) {
|
|
1447
1610
|
const role = roleOf(key);
|
|
@@ -1541,11 +1704,12 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1541
1704
|
* in flight). Returns whether a selection was recorded; every failure is
|
|
1542
1705
|
* contained.
|
|
1543
1706
|
*
|
|
1544
|
-
* `force` is the
|
|
1545
|
-
* instruction for THIS message outranks even a hand-picked
|
|
1546
|
-
* for the turn it commands (the pick is remembered and
|
|
1547
|
-
* by `
|
|
1548
|
-
* mode — those mean the manager does not move routes at
|
|
1707
|
+
* `force` is the one-turn commands' authority (`/readimage`, `/quicktask`):
|
|
1708
|
+
* an explicit user instruction for THIS message outranks even a hand-picked
|
|
1709
|
+
* composer route for the turn it commands (the pick is remembered and
|
|
1710
|
+
* restored afterwards by `endCommandTurn`). It never bypasses the master
|
|
1711
|
+
* switch or advisory mode — those mean the manager does not move routes at
|
|
1712
|
+
* all.
|
|
1549
1713
|
*/
|
|
1550
1714
|
function applySelection(agent, role, trigger, label, isSubagent, force = false) {
|
|
1551
1715
|
const model = selectionModelOf(agent);
|
|
@@ -1654,25 +1818,26 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1654
1818
|
return;
|
|
1655
1819
|
}
|
|
1656
1820
|
// The claimed message names the intent, and the payload names the turn
|
|
1657
|
-
// that owns it: bind the
|
|
1658
|
-
// one (handing a remembered composer pick back), then decide the
|
|
1659
|
-
//
|
|
1660
|
-
// it is the most recent explicit instruction — and only for that
|
|
1821
|
+
// that owns it: bind the one-turn command override to THAT turn, end any
|
|
1822
|
+
// older one (handing a remembered composer pick back), then decide the
|
|
1823
|
+
// role. A command outranks plan mode and planning skills for its own
|
|
1824
|
+
// turn — it is the most recent explicit instruction — and only for that
|
|
1825
|
+
// turn.
|
|
1661
1826
|
const turn = payload?.turn;
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
const
|
|
1827
|
+
noteCommandGesture(agent, [message], turn);
|
|
1828
|
+
endCommandTurn(agent, turn);
|
|
1829
|
+
const command = commandActive(agent, turn);
|
|
1665
1830
|
const plan = planActive(ctx, agent);
|
|
1666
|
-
const skill = plan ||
|
|
1831
|
+
const skill = plan || command
|
|
1667
1832
|
? undefined
|
|
1668
1833
|
: (planningSkillFor(agent)
|
|
1669
1834
|
?? planningSkillInMessages([message], config.strategy.planningSkills));
|
|
1670
|
-
const trigger =
|
|
1671
|
-
? `command:${config.strategy.
|
|
1835
|
+
const trigger = command
|
|
1836
|
+
? `command:${config.strategy[command.field]}`
|
|
1672
1837
|
: skill === undefined ? (plan ? 'plan-mode' : 'main') : `skill:${skill}`;
|
|
1673
|
-
noteTopTrigger(agent, trigger);
|
|
1674
|
-
applySelection(agent,
|
|
1675
|
-
trigger, undefined, false,
|
|
1838
|
+
noteTopTrigger(agent, trigger, command);
|
|
1839
|
+
applySelection(agent, command ? command.role : plan || skill !== undefined ? 'planning' : 'main',
|
|
1840
|
+
trigger, undefined, false, command !== undefined);
|
|
1676
1841
|
} catch {
|
|
1677
1842
|
/* observe-only at the claim boundary */
|
|
1678
1843
|
}
|
|
@@ -1835,26 +2000,26 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1835
2000
|
let role;
|
|
1836
2001
|
let label;
|
|
1837
2002
|
let trigger;
|
|
1838
|
-
let
|
|
2003
|
+
let command;
|
|
1839
2004
|
if (isSubagent) {
|
|
1840
2005
|
const facts = await factsFor(agent.id);
|
|
1841
2006
|
label = facts?.label;
|
|
1842
2007
|
role = classifySubagent(label);
|
|
1843
2008
|
} else {
|
|
1844
|
-
// The
|
|
2009
|
+
// The one-turn commands own their turn outright; below them, plan mode
|
|
1845
2010
|
// is the harness's own "thinking work" mode and a planning skill
|
|
1846
2011
|
// (`grilling` / `grill-me`) is the user's own version of the same
|
|
1847
2012
|
// intent, so both put the top-level session on the planning tier.
|
|
1848
|
-
|
|
2013
|
+
command = commandActive(agent, payload?.turn);
|
|
1849
2014
|
const plan = planActive(ctx, agent);
|
|
1850
|
-
const skill = plan ||
|
|
1851
|
-
trigger =
|
|
1852
|
-
? `command:${config.strategy.
|
|
2015
|
+
const skill = plan || command ? undefined : planningSkillFor(agent);
|
|
2016
|
+
trigger = command
|
|
2017
|
+
? `command:${config.strategy[command.field]}`
|
|
1853
2018
|
: skill === undefined ? (plan ? 'plan-mode' : 'main') : `skill:${skill}`;
|
|
1854
2019
|
// Only claim routing when routing is on; a disabled manager still records
|
|
1855
2020
|
// the trigger in its observed rows, but must not log that requests route.
|
|
1856
|
-
if (config.enabled) noteTopTrigger(agent, trigger);
|
|
1857
|
-
role =
|
|
2021
|
+
if (config.enabled) noteTopTrigger(agent, trigger, command);
|
|
2022
|
+
role = command ? command.role : plan || skill !== undefined ? 'planning' : 'main';
|
|
1858
2023
|
}
|
|
1859
2024
|
|
|
1860
2025
|
// Master switch off: observe and record, but never rewrite a route. The
|
|
@@ -1940,17 +2105,17 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1940
2105
|
output = resolved;
|
|
1941
2106
|
} else {
|
|
1942
2107
|
let inherited = true;
|
|
1943
|
-
if (mode === 'hybrid' && !isSubagent && !
|
|
2108
|
+
if (mode === 'hybrid' && !isSubagent && !command && selectionWasExplicit(agent)) {
|
|
1944
2109
|
// `main` replaces a route the user never chose; it does not overrule
|
|
1945
2110
|
// one they did choose. The proof is a durable log event, so a real
|
|
1946
2111
|
// composer pick survives restart, resume and fork, while a session
|
|
1947
2112
|
// still riding the deployment default is rewritten as before.
|
|
1948
2113
|
// `managed` is the mode for "the manager owns every route", including a
|
|
1949
2114
|
// session the user already picked, and is left untouched here.
|
|
1950
|
-
// The
|
|
1951
|
-
// instruction for THIS turn, newer than the pick, so it rewrites
|
|
1952
|
-
// that turn only — the durable selection is untouched on this
|
|
1953
|
-
// and the next turn respects the pick again by itself.
|
|
2115
|
+
// The one-turn commands are the one exception: each is an explicit
|
|
2116
|
+
// user instruction for THIS turn, newer than the pick, so it rewrites
|
|
2117
|
+
// for that turn only — the durable selection is untouched on this
|
|
2118
|
+
// path, and the next turn respects the pick again by itself.
|
|
1954
2119
|
inherited = false;
|
|
1955
2120
|
reason = 'explicit session selection (respected)';
|
|
1956
2121
|
} else if (mode === 'hybrid' && isSubagent) {
|
|
@@ -1983,7 +2148,7 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1983
2148
|
}
|
|
1984
2149
|
output = inherited ? applyRoute(resolved, route) : resolved;
|
|
1985
2150
|
didApply = inherited;
|
|
1986
|
-
if (didApply &&
|
|
2151
|
+
if (didApply && command) reason = `applied (${command.feature} command, one turn)`;
|
|
1987
2152
|
}
|
|
1988
2153
|
|
|
1989
2154
|
// Commit the rotation only when a route was actually applied, and record
|
|
@@ -2552,13 +2717,19 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
2552
2717
|
const commandTriggers = topRows.filter((row) => typeof row.seen.trigger === 'string'
|
|
2553
2718
|
&& row.seen.trigger.startsWith('command:')
|
|
2554
2719
|
&& row.seen.reason !== 'manager disabled (observed only)');
|
|
2555
|
-
|
|
2720
|
+
// One block per one-turn command, matched by the recorded ROLE rather
|
|
2721
|
+
// than the trigger's name text: a Settings rename after the fact must
|
|
2722
|
+
// not orphan a row, and a top-level turn only ever lands on `vision`
|
|
2723
|
+
// via /readimage or `execution` via /quicktask.
|
|
2724
|
+
for (const command of TURN_COMMANDS) {
|
|
2725
|
+
const rows = commandTriggers.filter((row) => row.seen.role === command.role);
|
|
2726
|
+
if (rows.length === 0) continue;
|
|
2556
2727
|
lines.push('');
|
|
2557
|
-
lines.push(
|
|
2728
|
+
lines.push(command.reportLabel + ' ' + rows
|
|
2558
2729
|
.map((row) => `${shortId(row.sessionId)} → /${row.seen.trigger.slice('command:'.length)}`)
|
|
2559
2730
|
.join(', '));
|
|
2560
|
-
lines.push(
|
|
2561
|
-
lines.push(
|
|
2731
|
+
lines.push(`The last turn of these sessions carried the ${command.feature} gesture, so it ran on the`);
|
|
2732
|
+
lines.push(`${command.role} role for that one turn; the next message without it routes normally again.`);
|
|
2562
2733
|
}
|
|
2563
2734
|
lines.push('');
|
|
2564
2735
|
}
|
|
@@ -2650,15 +2821,20 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
2650
2821
|
: `${config.strategy.planningSkills.join(', ')} — a top-level session that invoked one routes as `
|
|
2651
2822
|
+ 'planning for the rest of the session, like plan mode'}`,
|
|
2652
2823
|
'',
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2824
|
+
...TURN_COMMANDS.map((command) => {
|
|
2825
|
+
const name = config.strategy[command.field];
|
|
2826
|
+
const owner = turnCommandOwners().get(name);
|
|
2827
|
+
return `${command.reportLabel} ${name === ''
|
|
2828
|
+
? `(disabled) — strategy.${command.field} is empty`
|
|
2829
|
+
: `/${name} — the turn carrying it runs on the ${command.role} role (one turn only; `
|
|
2830
|
+
+ 'the next message without the gesture returns to the normal route, and a hand-picked composer model '
|
|
2831
|
+
+ 'is restored afterwards). '
|
|
2832
|
+
+ (commandRegistered(command) ? command.registeredNote
|
|
2833
|
+
: owner !== undefined && owner !== command
|
|
2834
|
+
? `NOT registered under this name — strategy.${command.field} collides with the `
|
|
2835
|
+
+ `${owner.feature} command's name, which keeps /${name}; the token routes ${owner.role}.`
|
|
2836
|
+
: command.unregisteredNote)}`;
|
|
2837
|
+
}),
|
|
2662
2838
|
'',
|
|
2663
2839
|
`Autoplan skill: ${autoplanRegistered
|
|
2664
2840
|
? 'registered — `/autoplan` plans on the planning tier and implements on `main` '
|
|
@@ -2711,12 +2887,18 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
2711
2887
|
+ 'tier for its whole turn; the next message without it returns to the normal route. Suggest it when '
|
|
2712
2888
|
+ 'the user wants an image read but the current model cannot see images.'
|
|
2713
2889
|
: '';
|
|
2890
|
+
const quickTaskNote = config.enabled && config.strategy.mode !== 'advisory'
|
|
2891
|
+
&& config.strategy.quickTaskCommand !== '' && effectiveModels('execution').length > 0
|
|
2892
|
+
? `\nThe user can type /${config.strategy.quickTaskCommand} to run one message on the execution `
|
|
2893
|
+
+ 'tier for its whole turn — a simple task or quick question that does not need the main model; '
|
|
2894
|
+
+ 'the next message without it returns to the normal route.'
|
|
2895
|
+
: '';
|
|
2714
2896
|
return [
|
|
2715
2897
|
'## Model manager',
|
|
2716
2898
|
'Delegated work is routed by the label you give each delegation:',
|
|
2717
2899
|
...summary,
|
|
2718
2900
|
routing,
|
|
2719
|
-
`Call \`model_manager\` with action "report" to see which model each subagent actually used.${planningGap}${skillNote}${readImageNote}`,
|
|
2901
|
+
`Call \`model_manager\` with action "report" to see which model each subagent actually used.${planningGap}${skillNote}${readImageNote}${quickTaskNote}`,
|
|
2720
2902
|
].join('\n');
|
|
2721
2903
|
}
|
|
2722
2904
|
|
|
@@ -2967,7 +3149,8 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
2967
3149
|
}
|
|
2968
3150
|
|
|
2969
3151
|
/**
|
|
2970
|
-
* The
|
|
3152
|
+
* The one-turn command handler (`/readimage`, `/quicktask`): forward,
|
|
3153
|
+
* don't answer.
|
|
2971
3154
|
*
|
|
2972
3155
|
* The harness's ordinary prompt path refuses images while the selected model
|
|
2973
3156
|
* declares text-only input (`MODEL_DOES_NOT_SUPPORT_IMAGES` in
|
|
@@ -2981,26 +3164,38 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
2981
3164
|
* `source.kind: 'user'` — without importing a harness package, which a
|
|
2982
3165
|
* profile-installed plugin cannot resolve. Routing then happens at the claim
|
|
2983
3166
|
* boundary exactly as it does for any typed message.
|
|
3167
|
+
*
|
|
3168
|
+
* `/quicktask` declares no attachment support, so the executor refuses an
|
|
3169
|
+
* invocation carrying attachments before this handler can ever see them;
|
|
3170
|
+
* the forwarding below stays generic (and defensive) regardless.
|
|
2984
3171
|
*/
|
|
2985
|
-
function
|
|
3172
|
+
function turnCommandHandler(invocation, command) {
|
|
2986
3173
|
try {
|
|
3174
|
+
const name = config.strategy[command.field];
|
|
2987
3175
|
const agent = invocation?.agent;
|
|
2988
3176
|
if (agent === undefined || typeof agent.followup !== 'function') {
|
|
2989
3177
|
return { kind: 'error', text: `/${name}: this composition exposes no agent inbox to forward the message to` };
|
|
2990
3178
|
}
|
|
2991
3179
|
if (!config.enabled) {
|
|
2992
|
-
return { kind: 'error', text: `/${name}: the model manager is disabled, so the
|
|
3180
|
+
return { kind: 'error', text: `/${name}: the model manager is disabled, so the ${command.role} route cannot be selected` };
|
|
2993
3181
|
}
|
|
2994
3182
|
if (config.strategy.mode === 'advisory') {
|
|
2995
|
-
return { kind: 'error', text: `/${name}: the manager is advisory (observe-only), so it cannot switch this message to the
|
|
3183
|
+
return { kind: 'error', text: `/${name}: the manager is advisory (observe-only), so it cannot switch this message to the ${command.role} model` };
|
|
2996
3184
|
}
|
|
2997
|
-
if (effectiveModels(
|
|
2998
|
-
return { kind: 'error', text: `/${name}: no
|
|
3185
|
+
if (effectiveModels(command.role).length === 0) {
|
|
3186
|
+
return { kind: 'error', text: `/${name}: no ${command.role} model is configured — ${command.configureHint}` };
|
|
2999
3187
|
}
|
|
3000
3188
|
const rawInput = typeof invocation?.rawInput === 'string' ? invocation.rawInput : '';
|
|
3001
3189
|
const attachments = Array.isArray(invocation?.attachments) ? invocation.attachments : [];
|
|
3190
|
+
// Defensive, mirroring the registration: a non-declaring command never
|
|
3191
|
+
// legitimately receives attachments (the executor refuses the invocation
|
|
3192
|
+
// before dispatch), and a quick turn must not land an image on an
|
|
3193
|
+
// execution model that cannot read it.
|
|
3194
|
+
if (!command.attachments && attachments.length > 0) {
|
|
3195
|
+
return { kind: 'error', text: `/${name}: this command is text only — images belong to the read-image command` };
|
|
3196
|
+
}
|
|
3002
3197
|
if (rawInput.trim() === '' && attachments.length === 0) {
|
|
3003
|
-
return { kind: 'error', text: `usage: /${name}
|
|
3198
|
+
return { kind: 'error', text: `usage: /${name} <${command.usageHint}> — ${command.attachments ? 'attach the image(s) to read; ' : ''}the message runs on the ${command.role} model for one turn` };
|
|
3004
3199
|
}
|
|
3005
3200
|
if (invocation?.signal?.aborted === true) {
|
|
3006
3201
|
return { kind: 'error', text: `/${name}: cancelled before the message was forwarded` };
|
|
@@ -3014,39 +3209,58 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
3014
3209
|
}));
|
|
3015
3210
|
return { kind: 'success' };
|
|
3016
3211
|
} catch (error) {
|
|
3017
|
-
return { kind: 'error', text: `/${
|
|
3212
|
+
return { kind: 'error', text: `/${config.strategy[command.field]}: ${error?.message ?? error}` };
|
|
3018
3213
|
}
|
|
3019
3214
|
}
|
|
3020
3215
|
|
|
3021
3216
|
/**
|
|
3022
|
-
* Register (or re-register)
|
|
3023
|
-
* name. Idempotent while
|
|
3217
|
+
* Register (or re-register) every one-turn command under its live config
|
|
3218
|
+
* name. Idempotent while a name is unchanged; a rename disposes the old
|
|
3024
3219
|
* registration first. Every failure degrades to a warning — a composition
|
|
3025
3220
|
* without the commands service simply keeps the plain-text gesture routing.
|
|
3221
|
+
*
|
|
3222
|
+
* The registry itself does NOT refuse a duplicate name (a later
|
|
3223
|
+
* registration shadows the earlier one), so a config pointing two commands
|
|
3224
|
+
* at one name is resolved here instead, first-wins in `TURN_COMMANDS`
|
|
3225
|
+
* order: the losing command is skipped with a warning, and the gesture scan
|
|
3226
|
+
* (which walks the same order) stays consistent with what is registered.
|
|
3026
3227
|
*/
|
|
3027
|
-
function
|
|
3228
|
+
function armTurnCommands() {
|
|
3028
3229
|
if (commandsService === undefined || typeof commandsService.register !== 'function') return;
|
|
3029
|
-
const
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3230
|
+
const owner = turnCommandOwners();
|
|
3231
|
+
for (const command of TURN_COMMANDS) {
|
|
3232
|
+
const name = config.strategy[command.field];
|
|
3233
|
+
const registered = commandRegistrations.get(command.key);
|
|
3234
|
+
if (registered?.name === name && owner.get(name) === command) continue;
|
|
3235
|
+
if (registered !== undefined) {
|
|
3236
|
+
try { registered.dispose(); } catch { /* a failed dispose must not block the re-arm */ }
|
|
3237
|
+
commandRegistrations.delete(command.key);
|
|
3238
|
+
}
|
|
3239
|
+
if (name === '') continue;
|
|
3240
|
+
if (owner.get(name) !== command) {
|
|
3241
|
+
// Warn once per colliding name, not once per volatile save: an
|
|
3242
|
+
// unchanged config re-arms identically and must stay quiet.
|
|
3243
|
+
if (commandCollisionWarned.get(command.key) !== name) {
|
|
3244
|
+
commandCollisionWarned.set(command.key, name);
|
|
3245
|
+
log('warn', `/${name} already names the ${owner.get(name).feature} command, so the ${command.feature} `
|
|
3246
|
+
+ `command is not registered — give strategy.${command.field} a name of its own`);
|
|
3247
|
+
}
|
|
3248
|
+
continue;
|
|
3249
|
+
}
|
|
3250
|
+
commandCollisionWarned.delete(command.key);
|
|
3251
|
+
try {
|
|
3252
|
+
const dispose = commandsService.register({
|
|
3253
|
+
name,
|
|
3254
|
+
description: command.description,
|
|
3255
|
+
input: { hint: command.hint, ...(command.attachments ? { attachments: true } : {}) },
|
|
3256
|
+
handler: (invocation) => turnCommandHandler(invocation, command),
|
|
3257
|
+
});
|
|
3258
|
+
commandRegistrations.set(command.key, { name, dispose: typeof dispose === 'function' ? dispose : () => {} });
|
|
3259
|
+
log('info', `registered the /${name} command — one turn on the ${command.role} role`
|
|
3260
|
+
+ `${command.attachments ? ', with attachment support' : ''}`);
|
|
3261
|
+
} catch (error) {
|
|
3262
|
+
log('warn', `/${name} command not registered: ${error?.message ?? error}`);
|
|
3263
|
+
}
|
|
3050
3264
|
}
|
|
3051
3265
|
}
|
|
3052
3266
|
|
|
@@ -3074,7 +3288,7 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
3074
3288
|
liveSkills.delete(id);
|
|
3075
3289
|
topTriggers.delete(id);
|
|
3076
3290
|
managerSelected.delete(id);
|
|
3077
|
-
|
|
3291
|
+
commandTurns.delete(id);
|
|
3078
3292
|
});
|
|
3079
3293
|
|
|
3080
3294
|
// Claim-boundary selection (DSH 0.2.x): the loop claims a step's input and
|
|
@@ -3119,10 +3333,10 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
3119
3333
|
};
|
|
3120
3334
|
visionMatch = keywordMatcher(config.strategy.visionKeywords);
|
|
3121
3335
|
planningMatch = keywordMatcher(config.strategy.planningKeywords);
|
|
3122
|
-
// A renamed (or disabled)
|
|
3336
|
+
// A renamed (or disabled) one-turn command takes effect on the save:
|
|
3123
3337
|
// the gesture scan already reads the live config, and this re-arms the
|
|
3124
|
-
// harness command
|
|
3125
|
-
|
|
3338
|
+
// harness command registrations under the new names.
|
|
3339
|
+
armTurnCommands();
|
|
3126
3340
|
for (const warning of config.warnings) log('warn', warning);
|
|
3127
3341
|
// The delegation policy and the update schedule both read the live
|
|
3128
3342
|
// config through this closure, so they follow a save with no restart.
|
|
@@ -3131,7 +3345,8 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
3131
3345
|
if (updateChanged) void checkForUpdate().catch(() => {});
|
|
3132
3346
|
log('info', `settings reloaded — mode ${config.strategy.mode}, pick ${config.pick}, autoDelegate ${config.strategy.autoDelegate}, `
|
|
3133
3347
|
+ `planningSkills ${config.strategy.planningSkills.join('|') || '-'}, `
|
|
3134
|
-
+ `readImage ${config.strategy.readImageCommand || '-'}
|
|
3348
|
+
+ `readImage ${config.strategy.readImageCommand || '-'}, `
|
|
3349
|
+
+ `quickTask ${config.strategy.quickTaskCommand || '-'}; `
|
|
3135
3350
|
+ ROLE_NAMES
|
|
3136
3351
|
.map((key) => `${key}=${config.roles[key].models.length === 0 ? '-' : config.roles[key].models.map((r) => `${r.provider}/${r.model}`).join('|')}`)
|
|
3137
3352
|
.join(' '));
|
|
@@ -3152,12 +3367,12 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
3152
3367
|
+ 'action "report": a Top-level agents section naming which model served each '
|
|
3153
3368
|
+ 'conversation, whether the manager yielded to a model a person picked in the '
|
|
3154
3369
|
+ 'composer, which planning skill (if any) put a session on the planning tier, '
|
|
3155
|
-
+ 'and whether the last turn carried
|
|
3370
|
+
+ 'and whether the last turn carried a one-turn command (/readimage, /quicktask), '
|
|
3156
3371
|
+ 'then one row per subagent with its label, role, reason, live status and '
|
|
3157
3372
|
+ 'totals. action "routes": the four role assignments '
|
|
3158
3373
|
+ '(including the vision->execution fallback), the shared selection strategy (first or round-robin), '
|
|
3159
3374
|
+ 'the active distribution mode, the auto-delegation level, the planning-skill trigger, '
|
|
3160
|
-
+ 'the
|
|
3375
|
+
+ 'the one-turn commands (/readimage on the vision role, /quicktask on the execution role), '
|
|
3161
3376
|
+ 'the update-check status, '
|
|
3162
3377
|
+ 'and whether each '
|
|
3163
3378
|
+ 'route is dispatchable by the delegation tool, with the YAML to add any that are not. '
|
|
@@ -3315,34 +3530,35 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
3315
3530
|
}
|
|
3316
3531
|
});
|
|
3317
3532
|
|
|
3318
|
-
// The
|
|
3319
|
-
//
|
|
3320
|
-
//
|
|
3321
|
-
//
|
|
3322
|
-
//
|
|
3533
|
+
// The one-turn commands (`/readimage` since 0.7.0, `/quicktask` since
|
|
3534
|
+
// 0.7.1). Like /autoplan these are workflow gestures the plugin ships,
|
|
3535
|
+
// but unlike a skill /readimage must accept image attachments: the
|
|
3536
|
+
// command path is the only admission seam that lets images through while
|
|
3537
|
+
// a text-only model is selected (/quicktask declares none, so the
|
|
3538
|
+
// executor refuses attachments for it before dispatch). Registration
|
|
3539
|
+
// follows the live config names; a volatile save re-arms them below.
|
|
3323
3540
|
ctx.inject(['commands'], (scoped) => {
|
|
3324
3541
|
try {
|
|
3325
3542
|
commandsService = scoped?.commands;
|
|
3326
3543
|
if (commandsService === undefined || typeof commandsService.register !== 'function') {
|
|
3327
|
-
log('warn', 'the commands service is present but exposes no register(); the
|
|
3544
|
+
log('warn', 'the commands service is present but exposes no register(); the one-turn commands are unavailable');
|
|
3328
3545
|
return;
|
|
3329
3546
|
}
|
|
3330
3547
|
if (typeof scoped.effect === 'function') {
|
|
3331
3548
|
scoped.effect(() => {
|
|
3332
|
-
|
|
3549
|
+
armTurnCommands();
|
|
3333
3550
|
return () => {
|
|
3334
|
-
|
|
3335
|
-
try {
|
|
3336
|
-
readImageDispose = undefined;
|
|
3551
|
+
for (const [, entry] of commandRegistrations) {
|
|
3552
|
+
try { entry.dispose(); } catch { /* disposal is best-effort */ }
|
|
3337
3553
|
}
|
|
3338
|
-
|
|
3554
|
+
commandRegistrations.clear();
|
|
3339
3555
|
};
|
|
3340
3556
|
});
|
|
3341
3557
|
} else {
|
|
3342
|
-
|
|
3558
|
+
armTurnCommands();
|
|
3343
3559
|
}
|
|
3344
3560
|
} catch (error) {
|
|
3345
|
-
log('warn', `
|
|
3561
|
+
log('warn', `one-turn command not registered: ${error?.message ?? error}`);
|
|
3346
3562
|
}
|
|
3347
3563
|
});
|
|
3348
3564
|
}
|
|
@@ -3447,10 +3663,13 @@ export {
|
|
|
3447
3663
|
selectionModelOf,
|
|
3448
3664
|
sameSelection,
|
|
3449
3665
|
planningSkillInMessages,
|
|
3666
|
+
commandGestureInMessages,
|
|
3450
3667
|
readImageGestureInMessages,
|
|
3451
3668
|
normalizeReadImageCommand,
|
|
3669
|
+
normalizeQuickTaskCommand,
|
|
3452
3670
|
DEFAULT_PLANNING_KEYWORDS,
|
|
3453
3671
|
DEFAULT_PLANNING_SKILLS,
|
|
3454
3672
|
DEFAULT_READ_IMAGE_COMMAND,
|
|
3673
|
+
DEFAULT_QUICK_TASK_COMMAND,
|
|
3455
3674
|
DEFAULT_VISION_KEYWORDS,
|
|
3456
3675
|
};
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darkbear9494/dsh-model-manager",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Role-based model manager for DeepSeek Harness: assign models to planning, execution, vision and main roles, route subagent work by role, escalate sessions that invoke a planning skill (grilling / grill-me) to the planning role, run /readimage messages with images on the vision role for one turn, report which model every subagent used, prompt the top-level agent to delegate, ship a /autoplan skill that plans on the planning tier then implements on main without stopping for approval, and switch models through agent.model.select() on DSH 0.2.x, and check npm for updates.",
|
|
5
|
+
"description": "Role-based model manager for DeepSeek Harness: assign models to planning, execution, vision and main roles, route subagent work by role, escalate sessions that invoke a planning skill (grilling / grill-me) to the planning role, run /readimage messages with images on the vision role for one turn, run /quicktask messages on the execution role for one turn, report which model every subagent used, prompt the top-level agent to delegate, ship a /autoplan skill that plans on the planning tier then implements on main without stopping for approval, and switch models through agent.model.select() on DSH 0.2.x, and check npm for updates.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"dsh",
|
|
9
9
|
"dsh-plugin",
|
|
10
10
|
"autoplan",
|
|
11
11
|
"readimage",
|
|
12
|
+
"quicktask",
|
|
12
13
|
"deepseek-harness",
|
|
13
14
|
"cordis",
|
|
14
15
|
"model-routing",
|
|
@@ -36,7 +37,7 @@
|
|
|
36
37
|
},
|
|
37
38
|
"meta": {
|
|
38
39
|
"title": "Model manager",
|
|
39
|
-
"description": "Assign models to planning, execution, vision and main roles, see which model each subagent used, auto-delegate, run /autoplan (plan on the planning tier, then implement on main without an approval gate), read images with /readimage (one turn on the vision tier), and get update notices."
|
|
40
|
+
"description": "Assign models to planning, execution, vision and main roles, see which model each subagent used, auto-delegate, run /autoplan (plan on the planning tier, then implement on main without an approval gate), read images with /readimage (one turn on the vision tier), run simple tasks with /quicktask (one turn on the execution tier), and get update notices."
|
|
40
41
|
},
|
|
41
42
|
"exports": {
|
|
42
43
|
".": "./lib/index.js",
|