feat(mode): the session-mode core — logged per-agent policy state (@deepseek-ai/dsh-mode)
Plan mode's stage 1 (RFC 2026-07-07-plan-mode): a new packages/mode/ group
with one product package owning the mode/set SessionEventMap vocabulary
(log-only, non-surface, whole-value replace), the pure foldMode, and the
ctx.modes service (list/get/set). User flips are pending intents flushed
at turn/start / step/end — turn enclosure makes an idle append illegal —
with one coalesced context/message notice when the flushed mode differs
from what the last logged request header told the model; a folded mode
the config no longer defines reads as default plus one boundary notice.
Enforcement is two covering layers: a system-prompt/assemble wrapper
filters the RETURNED assembly's tools to the mode's allowlist (and shows
exit_plan_mode IFF the folded mode is plan) beside the mode:policy
section at order 50, and a tools/pre-execute gate denies deny-by-default
against the same allowlist, judging by the logged mode only. The default
mode is the absence of policy — assemblies stay byte-identical to a
no-dsh-mode deployment.
AgentOptions.mode (declaration-merged) seeds a child's initial mode
through the same flush on agent/created; the stdio app gains /mode
(print/switch, never sent to the model) over an opportunistic
ctx.get('modes'). Config is an explicit resolve step: the built-in plan
definition (read-only allowlist; bash/subagent excluded until the
sandbox family lands) merges unless overridden, 'default' as a key
throws at load, unknown names throw at set() time.
This commit is contained in:
@@ -398,6 +398,35 @@ export interface Config {
|
||||
|
||||
Source: [`packages/support/llm-replay/src/index.ts:429`](../packages/support/llm-replay/src/index.ts)
|
||||
|
||||
## `@deepseek-ai/dsh-mode`
|
||||
|
||||
Requires: `tools` · `systemPrompt`
|
||||
|
||||
```ts config-catalog
|
||||
/**
|
||||
* Plugin config: mode definitions by name. The built-in {@link PLAN_MODE}
|
||||
* definition is merged in unless overridden; {@link DEFAULT_MODE} is rejected
|
||||
* as a key ({@link resolveConfig} throws at load).
|
||||
*/
|
||||
export interface ModeConfig {
|
||||
/** Mode definitions by name, overriding or extending the built-in `plan`. */
|
||||
modes?: Record<string, ModeDefinition>
|
||||
}
|
||||
|
||||
/**
|
||||
* One mode's deployment-configured policy: the guidance section the model sees
|
||||
* and the allowlist of tool names that stay visible and executable.
|
||||
*/
|
||||
export interface ModeDefinition {
|
||||
/** Guidance text rendered as the `mode:policy` prompt section while the mode is in force. */
|
||||
section: string
|
||||
/** Allowlist of tool NAMES; names may reference not-yet-registered tools (registration is dynamic). */
|
||||
tools: string[]
|
||||
}
|
||||
```
|
||||
|
||||
Source: [`packages/mode/mode/src/index.ts:94`](../packages/mode/mode/src/index.ts)
|
||||
|
||||
## `@deepseek-ai/dsh-repeat-tool-guard`
|
||||
|
||||
```ts config-catalog
|
||||
|
||||
Reference in New Issue
Block a user