@goodandready/dsh-agent-loop-guard 0.2.14 → 0.2.15

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 CHANGED
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.2.15] - 2026-09-25
9
+
10
+ ### Fixed
11
+ - **SettingsForms API Migration**: Replaced legacy, removed `sctx.settings.register()` call with modern DSH 0.1.7-rc.1 `SettingsForms` lifecycle integration (#85).
12
+ - **Presentation Policy**: Configured `sctx.settings.configure({ auto: false }, ctx.fiber)` to register page policy with proper disposer in `sctx.effect`.
13
+ - **Live Settings Resolution**: Resolved live configuration via `sctx.settings.describe()` and subscribed to `settings/document-updated` event.
14
+ - **Config Reload Contract**: Supported `app-boot/config-reload` and `internal/update` events for runtime guard limit re-synchronization.
15
+ - **Optional Dependency**: Removed `settings` from top-level required `inject` array, enabling the plugin to run cleanly in headless or minimal environments.
16
+
8
17
  ## [0.2.14] - 2026-09-24
9
18
 
10
19
  ### Added
package/lib/index.js CHANGED
@@ -9,7 +9,7 @@ import { AssistantOutputGuardState, assistantTextFromMessage } from './assistant
9
9
  import { registerPluginUpdater, isTrustedTelemetryRequest } from './plugin-updater.js';
10
10
 
11
11
  export const name = '@goodandready/dsh-agent-loop-guard';
12
- export const inject = ['tools', 'agents', 'sessions', 'settings'];
12
+ export const inject = ['tools', 'agents', 'sessions'];
13
13
 
14
14
  export const Config = Schema.object({
15
15
  maxToolAttemptsPerTurn: Schema.number().min(0).default(64),
@@ -97,7 +97,7 @@ function logGuardViolation(ctx, event) {
97
97
 
98
98
  export function apply(ctx, config = {}) {
99
99
  const NS = name;
100
- let getConfig = () => Config(config) ?? {};
100
+ let getConfig = () => Config(ctx.fiber?.config ?? config) ?? {};
101
101
 
102
102
  const syncFrom = (raw) => {
103
103
  const maxCallsPerRepeatGroup = positiveInteger(raw.maxCallsPerRepeatGroup ?? raw.maxCallsPerToolPerTurn, 5);
@@ -138,18 +138,72 @@ export function apply(ctx, config = {}) {
138
138
  if (typeof assistantState.updateConfig === 'function') assistantState.updateConfig(raw);
139
139
  };
140
140
 
141
+ if (typeof ctx.on === 'function') {
142
+ ctx.on('app-boot/config-reload', () => applyLiveConfig());
143
+ ctx.on('internal/update', () => applyLiveConfig());
144
+ }
145
+
141
146
  ctx.inject(['settings'], (sctx) => {
142
- const scope = sctx.settings.register(NS, Config, { base: config });
143
- getConfig = () => Config(scope.get() ?? config) ?? {};
144
- applyLiveConfig();
147
+ if (!sctx?.settings) return;
148
+
149
+ let disposeConfigure;
145
150
  try {
146
- if (typeof scope.watch === 'function') {
147
- sctx.effect(() => scope.watch(() => applyLiveConfig()));
148
- } else if (typeof scope.subscribe === 'function') {
149
- sctx.effect(() => scope.subscribe(() => applyLiveConfig()));
151
+ if (typeof sctx.settings.configure === 'function') {
152
+ disposeConfigure = sctx.settings.configure({ auto: false }, ctx.fiber);
150
153
  }
151
154
  } catch (error) {
152
- ctx.logger?.warn?.('dsh-agent-loop-guard: settings watch failed: ' + (error instanceof Error ? error.message : String(error)));
155
+ ctx.logger?.warn?.('dsh-agent-loop-guard: settings configure failed: ' + (error instanceof Error ? error.message : String(error)));
156
+ }
157
+
158
+ const readLiveSettings = () => {
159
+ try {
160
+ if (typeof sctx.settings.describe === 'function') {
161
+ const desc = sctx.settings.describe().find((row) => row.ns === NS);
162
+ if (desc && desc.value && typeof desc.value === 'object') {
163
+ return Config(desc.value);
164
+ }
165
+ } else if (typeof sctx.settings.get === 'function') {
166
+ const val = sctx.settings.get(NS);
167
+ if (val && typeof val === 'object') {
168
+ return Config(val);
169
+ }
170
+ }
171
+ } catch (error) {
172
+ ctx.logger?.warn?.('dsh-agent-loop-guard: settings describe failed: ' + (error instanceof Error ? error.message : String(error)));
173
+ }
174
+ return null;
175
+ };
176
+
177
+ getConfig = () => readLiveSettings() ?? Config(ctx.fiber?.config ?? config) ?? {};
178
+ applyLiveConfig();
179
+
180
+ const disposeDocUpdated = typeof sctx.on === 'function'
181
+ ? sctx.on('settings/document-updated', (updatedNs) => {
182
+ if (updatedNs === NS) {
183
+ applyLiveConfig();
184
+ }
185
+ })
186
+ : null;
187
+
188
+ const cleanup = () => {
189
+ if (typeof disposeConfigure === 'function') {
190
+ try {
191
+ disposeConfigure();
192
+ } catch (error) {
193
+ ctx.logger?.debug?.('dsh-agent-loop-guard: disposeConfigure error: ' + (error instanceof Error ? error.message : String(error)));
194
+ }
195
+ }
196
+ if (typeof disposeDocUpdated === 'function') {
197
+ try {
198
+ disposeDocUpdated();
199
+ } catch (error) {
200
+ ctx.logger?.debug?.('dsh-agent-loop-guard: disposeDocUpdated error: ' + (error instanceof Error ? error.message : String(error)));
201
+ }
202
+ }
203
+ };
204
+
205
+ if (typeof sctx.effect === 'function') {
206
+ sctx.effect(() => cleanup, 'dsh-agent-loop-guard: settings');
153
207
  }
154
208
  });
155
209
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-agent-loop-guard",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
4
4
  "description": "Fail-closed runtime tool-call loop guard for DeepSeek Harness.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",