@khorsheed/dsh-context-guard 0.2.1 → 0.2.2
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 +9 -0
- package/README.en.md +2 -1
- package/README.i18n.yaml +2 -2
- package/README.md +2 -1
- package/lib/client.js +320 -135
- package/lib/index.js +47 -18
- package/lib/types/client/CompactGuardButton.js +2 -2
- package/lib/types/client/SettingsCard.d.ts +11 -6
- package/lib/types/client/SettingsCard.js +50 -22
- package/lib/types/client/config.js +14 -1
- package/lib/types/client/icons.d.ts +19 -0
- package/lib/types/client/icons.js +3 -0
- package/lib/types/client/index.d.ts +22 -7
- package/lib/types/client/index.js +52 -10
- package/lib/types/client/scope.d.ts +62 -0
- package/lib/types/client/scope.js +59 -0
- package/lib/types/client/slots.d.ts +22 -11
- package/lib/types/index.d.ts +22 -8
- package/lib/types/index.js +32 -9
- package/lib/types/namespace.d.ts +2 -2
- package/lib/types/namespace.js +2 -2
- package/lib/types/settings.d.ts +16 -10
- package/lib/types/settings.js +19 -6
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +7 -21
package/lib/types/index.d.ts
CHANGED
|
@@ -1,19 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Context-guard plugin, node half.
|
|
3
|
-
*
|
|
4
|
-
* the browser half can bind its
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* Context-guard plugin, node half. Serves the `context-guard` settings
|
|
3
|
+
* section so the web settings page can render the compact-timing card and
|
|
4
|
+
* the browser half can bind its scope to the same section — on rc.1 through
|
|
5
|
+
* the entry's own Config (below; SettingsForms serves and edits its volatile
|
|
6
|
+
* field), on 0.1.5 through an explicit `settings.register` namespace whose
|
|
7
|
+
* base layer is the composition entry. The plugin's own runtime behavior is
|
|
8
|
+
* purely client-side (the composer compact button); this registration only
|
|
9
|
+
* exists to make the two tunables (`thresholdRatio`, `maxTokens`) editable
|
|
10
|
+
* from the GUI instead of YAML.
|
|
8
11
|
* @module @khorsheed/dsh-context-guard
|
|
9
12
|
*/
|
|
10
13
|
import type { Context } from '@deepseek-ai/cordis';
|
|
14
|
+
import type z from '@deepseek-ai/schemastery';
|
|
11
15
|
export { CONTEXT_GUARD_NS } from './namespace.ts';
|
|
12
16
|
export { ContextGuardSettingsSchema } from './settings.ts';
|
|
13
17
|
/**
|
|
14
|
-
*
|
|
18
|
+
* The entry Config: rc.1's SettingsForms serves exactly this schema under the
|
|
19
|
+
* row id (`context-guard` — the settings namespace by construction) and
|
|
20
|
+
* persists edits to its volatile field through the profile patch. On 0.1.5
|
|
21
|
+
* the same schema validates the legacy namespace instead; the volatile
|
|
22
|
+
* marker is probed at schema build time and simply absent there. The bare
|
|
23
|
+
* `z` annotation keeps the emitted type nameable under pnpm's layout.
|
|
24
|
+
*/
|
|
25
|
+
export declare const Config: z;
|
|
26
|
+
/**
|
|
27
|
+
* Serve the compact-timing section on whichever settings face the host line
|
|
28
|
+
* carries.
|
|
15
29
|
* @param ctx - Host context whose optional settings service owns the section.
|
|
16
|
-
* @param config - the plugin's composition entry,
|
|
30
|
+
* @param config - the plugin's composition entry, the legacy path's base layer.
|
|
17
31
|
*/
|
|
18
32
|
export declare function apply(ctx: Context, config?: Record<string, unknown>): void;
|
|
19
33
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/types/index.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Context-guard plugin, node half.
|
|
3
|
-
*
|
|
4
|
-
* the browser half can bind its
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* Context-guard plugin, node half. Serves the `context-guard` settings
|
|
3
|
+
* section so the web settings page can render the compact-timing card and
|
|
4
|
+
* the browser half can bind its scope to the same section — on rc.1 through
|
|
5
|
+
* the entry's own Config (below; SettingsForms serves and edits its volatile
|
|
6
|
+
* field), on 0.1.5 through an explicit `settings.register` namespace whose
|
|
7
|
+
* base layer is the composition entry. The plugin's own runtime behavior is
|
|
8
|
+
* purely client-side (the composer compact button); this registration only
|
|
9
|
+
* exists to make the two tunables (`thresholdRatio`, `maxTokens`) editable
|
|
10
|
+
* from the GUI instead of YAML.
|
|
8
11
|
* @module @khorsheed/dsh-context-guard
|
|
9
12
|
*/
|
|
10
13
|
import { CONTEXT_GUARD_NS } from './namespace.js';
|
|
@@ -12,12 +15,32 @@ import { ContextGuardSettingsSchema } from './settings.js';
|
|
|
12
15
|
export { CONTEXT_GUARD_NS } from './namespace.js';
|
|
13
16
|
export { ContextGuardSettingsSchema } from './settings.js';
|
|
14
17
|
/**
|
|
15
|
-
*
|
|
18
|
+
* The entry Config: rc.1's SettingsForms serves exactly this schema under the
|
|
19
|
+
* row id (`context-guard` — the settings namespace by construction) and
|
|
20
|
+
* persists edits to its volatile field through the profile patch. On 0.1.5
|
|
21
|
+
* the same schema validates the legacy namespace instead; the volatile
|
|
22
|
+
* marker is probed at schema build time and simply absent there. The bare
|
|
23
|
+
* `z` annotation keeps the emitted type nameable under pnpm's layout.
|
|
24
|
+
*/
|
|
25
|
+
export const Config = ContextGuardSettingsSchema;
|
|
26
|
+
/**
|
|
27
|
+
* Serve the compact-timing section on whichever settings face the host line
|
|
28
|
+
* carries.
|
|
16
29
|
* @param ctx - Host context whose optional settings service owns the section.
|
|
17
|
-
* @param config - the plugin's composition entry,
|
|
30
|
+
* @param config - the plugin's composition entry, the legacy path's base layer.
|
|
18
31
|
*/
|
|
19
32
|
export function apply(ctx, config = {}) {
|
|
20
33
|
ctx.inject(['settings'], (settingsCtx) => {
|
|
21
|
-
settingsCtx.settings
|
|
34
|
+
const settings = settingsCtx.settings;
|
|
35
|
+
if (typeof settings.register === 'function') {
|
|
36
|
+
// 0.1.5: the explicit namespace, the composition entry as its base layer.
|
|
37
|
+
settings.register(CONTEXT_GUARD_NS, ContextGuardSettingsSchema, { base: config });
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
// rc.1: the entry's own Config (above) is the served form. Keep the
|
|
41
|
+
// auto-generated page out of the settings tree — the bundle's own cards
|
|
42
|
+
// (plugins.bundle.config / the legacy tab seat) edit the same field.
|
|
43
|
+
if (typeof settings.configure === 'function')
|
|
44
|
+
settings.configure({ auto: false }, ctx.fiber);
|
|
22
45
|
});
|
|
23
46
|
}
|
package/lib/types/namespace.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The settings namespace owned by the context-guard plugin. Plain string so
|
|
3
3
|
* both the host half (settings registration) and the browser half
|
|
4
|
-
* (settingsScope binding and the settings.plugin.item card key) import
|
|
5
|
-
* without dragging host-only dependencies into the client bundle.
|
|
4
|
+
* (settingsScope binding and the 0.1.5 settings.plugin.item card key) import
|
|
5
|
+
* it without dragging host-only dependencies into the client bundle.
|
|
6
6
|
*/
|
|
7
7
|
/** Settings namespace owned by the context-guard plugin. */
|
|
8
8
|
export declare const CONTEXT_GUARD_NS = "context-guard";
|
package/lib/types/namespace.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The settings namespace owned by the context-guard plugin. Plain string so
|
|
3
3
|
* both the host half (settings registration) and the browser half
|
|
4
|
-
* (settingsScope binding and the settings.plugin.item card key) import
|
|
5
|
-
* without dragging host-only dependencies into the client bundle.
|
|
4
|
+
* (settingsScope binding and the 0.1.5 settings.plugin.item card key) import
|
|
5
|
+
* it without dragging host-only dependencies into the client bundle.
|
|
6
6
|
*/
|
|
7
7
|
/** Settings namespace owned by the context-guard plugin. */
|
|
8
8
|
export const CONTEXT_GUARD_NS = 'context-guard';
|
package/lib/types/settings.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Host-side settings section of the context-guard plugin: the schemastery
|
|
3
|
-
* schema
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* schema of the `context-guard` configuration entry. rc.1's SettingsForms
|
|
4
|
+
* serves the entry's own Config and edits only its volatile fields; 0.1.5
|
|
5
|
+
* validates the legacy `settings.register` namespace with the same schema.
|
|
6
|
+
* The browser half reads the resolved section through whichever settings
|
|
7
|
+
* scope the line serves (see client/scope.ts); the composition entry (the
|
|
8
|
+
* cordis.yml row) becomes the section's base layer, so YAML values keep
|
|
7
9
|
* working as the defaults the card can override.
|
|
8
10
|
*
|
|
9
11
|
* These two fields tune ONLY when the compact button appears — the official
|
|
@@ -11,10 +13,14 @@
|
|
|
11
13
|
* `maxTokens` config and never touches this section.
|
|
12
14
|
*/
|
|
13
15
|
import z from '@deepseek-ai/schemastery';
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Section shape: the context-occupancy fraction at which the button appears.
|
|
18
|
+
* The field is marked `.volatile()` when the running schemastery supports it
|
|
19
|
+
* (3.18.4, host rc.1 — SettingsForms serves and edits ONLY volatile fields);
|
|
20
|
+
* 0.1.5's schemastery (3.18.2) has no such method, the probe leaves the field
|
|
21
|
+
* plain, and the legacy register path carries the section (the marker is
|
|
22
|
+
* inert there). The inline probe (not a helper) keeps the emitted type
|
|
23
|
+
* nameable under pnpm's layout.
|
|
24
|
+
*/
|
|
25
|
+
export declare const ContextGuardSettingsSchema: z;
|
|
20
26
|
//# sourceMappingURL=settings.d.ts.map
|
package/lib/types/settings.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Host-side settings section of the context-guard plugin: the schemastery
|
|
3
|
-
* schema
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* schema of the `context-guard` configuration entry. rc.1's SettingsForms
|
|
4
|
+
* serves the entry's own Config and edits only its volatile fields; 0.1.5
|
|
5
|
+
* validates the legacy `settings.register` namespace with the same schema.
|
|
6
|
+
* The browser half reads the resolved section through whichever settings
|
|
7
|
+
* scope the line serves (see client/scope.ts); the composition entry (the
|
|
8
|
+
* cordis.yml row) becomes the section's base layer, so YAML values keep
|
|
7
9
|
* working as the defaults the card can override.
|
|
8
10
|
*
|
|
9
11
|
* These two fields tune ONLY when the compact button appears — the official
|
|
@@ -11,7 +13,18 @@
|
|
|
11
13
|
* `maxTokens` config and never touches this section.
|
|
12
14
|
*/
|
|
13
15
|
import z from '@deepseek-ai/schemastery';
|
|
14
|
-
|
|
16
|
+
const thresholdField = z.number().min(0.01).max(1).default(0.8);
|
|
17
|
+
/**
|
|
18
|
+
* Section shape: the context-occupancy fraction at which the button appears.
|
|
19
|
+
* The field is marked `.volatile()` when the running schemastery supports it
|
|
20
|
+
* (3.18.4, host rc.1 — SettingsForms serves and edits ONLY volatile fields);
|
|
21
|
+
* 0.1.5's schemastery (3.18.2) has no such method, the probe leaves the field
|
|
22
|
+
* plain, and the legacy register path carries the section (the marker is
|
|
23
|
+
* inert there). The inline probe (not a helper) keeps the emitted type
|
|
24
|
+
* nameable under pnpm's layout.
|
|
25
|
+
*/
|
|
15
26
|
export const ContextGuardSettingsSchema = z.object({
|
|
16
|
-
thresholdRatio:
|
|
27
|
+
thresholdRatio: typeof thresholdField.volatile === 'function'
|
|
28
|
+
? thresholdField.volatile()
|
|
29
|
+
: thresholdField,
|
|
17
30
|
});
|
package/locale/en.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"context",
|
|
9
9
|
"compaction"
|
|
10
10
|
],
|
|
11
|
-
"version": "0.2.
|
|
11
|
+
"version": "0.2.2",
|
|
12
12
|
"type": "module",
|
|
13
13
|
"main": "lib/index.js",
|
|
14
14
|
"types": "lib/types/index.d.ts",
|
|
@@ -26,9 +26,13 @@
|
|
|
26
26
|
"default": "./lib/client.js"
|
|
27
27
|
},
|
|
28
28
|
"./src/*": "./src/*",
|
|
29
|
-
"./package.json": "./package.json"
|
|
29
|
+
"./package.json": "./package.json",
|
|
30
|
+
"./locale/*.json": "./locale/*.json"
|
|
30
31
|
},
|
|
31
32
|
"dsh": {
|
|
33
|
+
"references": [
|
|
34
|
+
"@khorsheed/dsh-bundle-conversation-toolbox"
|
|
35
|
+
],
|
|
32
36
|
"bundle": {
|
|
33
37
|
"patch": "./cordis.patch.yml"
|
|
34
38
|
},
|
|
@@ -60,28 +64,10 @@
|
|
|
60
64
|
"@deepseek-ai/dsh-token-meter": "^0.1.0-rc.6",
|
|
61
65
|
"react": "^18.2.0"
|
|
62
66
|
},
|
|
63
|
-
"devDependencies": {
|
|
64
|
-
"@deepseek-ai/cordis": "^4.0.1",
|
|
65
|
-
"@deepseek-ai/dsh-api-remotes": "^0.1.5-rc.1",
|
|
66
|
-
"@deepseek-ai/dsh-client-locale": "^0.1.5-rc.1",
|
|
67
|
-
"@deepseek-ai/dsh-client-test-runtime": "^0.1.5-rc.1",
|
|
68
|
-
"@deepseek-ai/dsh-client-ui-conversation": "^0.1.5-rc.1",
|
|
69
|
-
"@deepseek-ai/dsh-client-ui-primitives": "^0.1.5-rc.1",
|
|
70
|
-
"@deepseek-ai/dsh-client-ui-renderer": "^0.1.5-rc.1",
|
|
71
|
-
"@deepseek-ai/dsh-client-ui-settings": "^0.1.5-rc.1",
|
|
72
|
-
"@deepseek-ai/dsh-client-ui-settings-plugins": "^0.1.5-rc.1",
|
|
73
|
-
"@deepseek-ai/dsh-client-ui-slots": "^0.1.5-rc.1",
|
|
74
|
-
"@deepseek-ai/dsh-invariants": "^0.1.5-rc.1",
|
|
75
|
-
"@deepseek-ai/dsh-session": "^0.1.5-rc.1",
|
|
76
|
-
"@deepseek-ai/dsh-token-meter": "^0.1.5-rc.1",
|
|
77
|
-
"@testing-library/react": "^16.1.0",
|
|
78
|
-
"@types/react": "~18.3.1",
|
|
79
|
-
"react": "^18.2.0",
|
|
80
|
-
"react-dom": "^18.2.0"
|
|
81
|
-
},
|
|
82
67
|
"files": [
|
|
83
68
|
"lib",
|
|
84
69
|
"cordis.patch.yml",
|
|
70
|
+
"locale/*.json",
|
|
85
71
|
"LICENSE",
|
|
86
72
|
"CHANGELOG.md"
|
|
87
73
|
]
|