@khorsheed/dsh-context-guard 0.1.0

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/LICENSE +21 -0
  3. package/README.en.md +89 -0
  4. package/README.i18n.yaml +6 -0
  5. package/README.md +89 -0
  6. package/cordis.patch.yml +10 -0
  7. package/lib/client.js +461 -0
  8. package/lib/client.js.map +1 -0
  9. package/lib/index.js +50 -0
  10. package/lib/invariant.js +26 -0
  11. package/lib/tsconfig.tsbuildinfo +1 -0
  12. package/lib/types/client/CompactGuardButton.d.ts +13 -0
  13. package/lib/types/client/CompactGuardButton.d.ts.map +1 -0
  14. package/lib/types/client/CompactGuardButton.js +53 -0
  15. package/lib/types/client/SettingsCard.d.ts +12 -0
  16. package/lib/types/client/SettingsCard.d.ts.map +1 -0
  17. package/lib/types/client/SettingsCard.js +97 -0
  18. package/lib/types/client/config.d.ts +42 -0
  19. package/lib/types/client/config.d.ts.map +1 -0
  20. package/lib/types/client/config.js +30 -0
  21. package/lib/types/client/guard.d.ts +44 -0
  22. package/lib/types/client/guard.d.ts.map +1 -0
  23. package/lib/types/client/guard.js +42 -0
  24. package/lib/types/client/index.d.ts +46 -0
  25. package/lib/types/client/index.d.ts.map +1 -0
  26. package/lib/types/client/index.js +61 -0
  27. package/lib/types/client/locales.d.ts +48 -0
  28. package/lib/types/client/locales.d.ts.map +1 -0
  29. package/lib/types/client/locales.js +39 -0
  30. package/lib/types/client/slots.d.ts +39 -0
  31. package/lib/types/client/slots.d.ts.map +1 -0
  32. package/lib/types/client/slots.js +1 -0
  33. package/lib/types/index.d.ts +19 -0
  34. package/lib/types/index.d.ts.map +1 -0
  35. package/lib/types/index.js +24 -0
  36. package/lib/types/invariant.d.ts +16 -0
  37. package/lib/types/invariant.d.ts.map +1 -0
  38. package/lib/types/invariant.js +24 -0
  39. package/lib/types/namespace.d.ts +9 -0
  40. package/lib/types/namespace.d.ts.map +1 -0
  41. package/lib/types/namespace.js +8 -0
  42. package/lib/types/settings.d.ts +20 -0
  43. package/lib/types/settings.d.ts.map +1 -0
  44. package/lib/types/settings.js +17 -0
  45. package/package.json +89 -0
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Package-owned invariant companion for `@khorsheed/dsh-context-guard`.
3
+ * @module @khorsheed/dsh-context-guard/invariant
4
+ */
5
+ import type { Context } from '@deepseek-ai/cordis';
6
+ /** Cordis companion plugin name. */
7
+ export declare const name = "context-guard-invariant";
8
+ /** Service required before the companion can reserve package ownership. */
9
+ export declare const inject: string[];
10
+ /**
11
+ * Register this package's invariant companion.
12
+ * @param ctx - Cordis context carrying the invariant service.
13
+ * @returns the installed registration's disposer after setup succeeds.
14
+ */
15
+ export declare const apply: (ctx: Context) => Promise<() => void>;
16
+ //# sourceMappingURL=invariant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invariant.d.ts","sourceRoot":"","sources":["../../src/invariant.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAKlD,oCAAoC;AACpC,eAAO,MAAM,IAAI,4BAA4B,CAAA;AAC7C,2EAA2E;AAC3E,eAAO,MAAM,MAAM,UAAiB,CAAA;AAWpC;;;;GAIG;AACH,eAAO,MAAM,KAAK,QAAS,OAAO,KAAG,OAAO,CAAC,MAAM,IAAI,CACU,CAAA"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Package-owned invariant companion for `@khorsheed/dsh-context-guard`.
3
+ * @module @khorsheed/dsh-context-guard/invariant
4
+ */
5
+ const PACKAGE_NAME = '@khorsheed/dsh-context-guard';
6
+ /** Cordis companion plugin name. */
7
+ export const name = 'context-guard-invariant';
8
+ /** Service required before the companion can reserve package ownership. */
9
+ export const inject = ['invariants'];
10
+ /**
11
+ * No runtime invariant: every compact action is executed through the official
12
+ * `/compact` command channel, whose command-log invariant companion audits the
13
+ * command lifecycle, and the plugin's one composer-tool-row entry proves
14
+ * disposal through the browser-plugin spec. No second authority exists to
15
+ * check at runtime.
16
+ */
17
+ const install = () => { };
18
+ /**
19
+ * Register this package's invariant companion.
20
+ * @param ctx - Cordis context carrying the invariant service.
21
+ * @returns the installed registration's disposer after setup succeeds.
22
+ */
23
+ export const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
24
+ /* jscpd:ignore-end */
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The settings namespace owned by the context-guard plugin. Plain string so
3
+ * both the host half (settings registration) and the browser half
4
+ * (settingsScope binding and the settings.plugin.item card key) import it
5
+ * without dragging host-only dependencies into the client bundle.
6
+ */
7
+ /** Settings namespace owned by the context-guard plugin. */
8
+ export declare const CONTEXT_GUARD_NS = "context-guard";
9
+ //# sourceMappingURL=namespace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namespace.d.ts","sourceRoot":"","sources":["../../src/namespace.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,4DAA4D;AAC5D,eAAO,MAAM,gBAAgB,kBAAkB,CAAA"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The settings namespace owned by the context-guard plugin. Plain string so
3
+ * both the host half (settings registration) and the browser half
4
+ * (settingsScope binding and the settings.plugin.item card key) import it
5
+ * without dragging host-only dependencies into the client bundle.
6
+ */
7
+ /** Settings namespace owned by the context-guard plugin. */
8
+ export const CONTEXT_GUARD_NS = 'context-guard';
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Host-side settings section of the context-guard plugin: the schemastery
3
+ * schema that validates the `context-guard` settings namespace. The browser
4
+ * half reads the resolved section through `ctx.settingsScope` and the
5
+ * settings page renders it as a plugin card; the composition entry (the
6
+ * cordis.yml row) becomes the section's `base` layer, so YAML values keep
7
+ * working as the defaults the card can override.
8
+ *
9
+ * These two fields tune ONLY when the compact button appears — the official
10
+ * compaction engine (compaction-basic) reads its own `thresholdRatio` /
11
+ * `maxTokens` config and never touches this section.
12
+ */
13
+ import z from '@deepseek-ai/schemastery';
14
+ /** Section shape: the context-occupancy fraction at which the button appears. */
15
+ export declare const ContextGuardSettingsSchema: z<Schemastery.ObjectS<{
16
+ thresholdRatio: z<number, number>;
17
+ }>, Schemastery.ObjectT<{
18
+ thresholdRatio: z<number, number>;
19
+ }>>;
20
+ //# sourceMappingURL=settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAExC,iFAAiF;AACjF,eAAO,MAAM,0BAA0B;;;;GAErC,CAAA"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Host-side settings section of the context-guard plugin: the schemastery
3
+ * schema that validates the `context-guard` settings namespace. The browser
4
+ * half reads the resolved section through `ctx.settingsScope` and the
5
+ * settings page renders it as a plugin card; the composition entry (the
6
+ * cordis.yml row) becomes the section's `base` layer, so YAML values keep
7
+ * working as the defaults the card can override.
8
+ *
9
+ * These two fields tune ONLY when the compact button appears — the official
10
+ * compaction engine (compaction-basic) reads its own `thresholdRatio` /
11
+ * `maxTokens` config and never touches this section.
12
+ */
13
+ import z from '@deepseek-ai/schemastery';
14
+ /** Section shape: the context-occupancy fraction at which the button appears. */
15
+ export const ContextGuardSettingsSchema = z.object({
16
+ thresholdRatio: z.number().min(0.01).max(1).default(0.8),
17
+ });
package/package.json ADDED
@@ -0,0 +1,89 @@
1
+ {
2
+ "name": "@khorsheed/dsh-context-guard",
3
+ "description": "Context-window compaction reminder: a compact button appears in the composer once context occupancy (the same number the context ring shows) crosses a configurable fraction of the model's context window, so you can compact before requests hit the provider's rejection wall (which sits below 100% occupancy because the request reserves output tokens)",
4
+ "keywords": [
5
+ "dsh",
6
+ "dsh-plugin",
7
+ "cordis",
8
+ "context",
9
+ "compaction"
10
+ ],
11
+ "version": "0.1.0",
12
+ "type": "module",
13
+ "main": "lib/index.js",
14
+ "types": "lib/types/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./lib/types/index.d.ts",
18
+ "default": "./lib/index.js"
19
+ },
20
+ "./invariant": {
21
+ "types": "./lib/types/invariant.d.ts",
22
+ "default": "./lib/invariant.js"
23
+ },
24
+ "./client": {
25
+ "types": "./lib/types/client/index.d.ts",
26
+ "default": "./lib/client.js"
27
+ },
28
+ "./src/*": "./src/*",
29
+ "./package.json": "./package.json"
30
+ },
31
+ "dsh": {
32
+ "bundle": {
33
+ "patch": "./cordis.patch.yml"
34
+ },
35
+ "client": {
36
+ "inject": [
37
+ "@deepseek-ai/dsh-api-remotes",
38
+ "@deepseek-ai/dsh-client-locale",
39
+ "@deepseek-ai/dsh-client-runtime",
40
+ "@deepseek-ai/dsh-client-ui-conversation",
41
+ "@deepseek-ai/dsh-client-ui-primitives",
42
+ "@deepseek-ai/dsh-client-ui-settings"
43
+ ],
44
+ "platform": "web"
45
+ },
46
+ "compat": {
47
+ "minHost": "0.1.0-rc.8",
48
+ "verifiedHost": "0.1.1-rc.2"
49
+ }
50
+ },
51
+ "license": "MIT",
52
+ "peerDependencies": {
53
+ "@deepseek-ai/cordis": "^4.0.1",
54
+ "@deepseek-ai/dsh-api-remotes": "^0.1.0-rc.6",
55
+ "@deepseek-ai/dsh-client-locale": "^0.1.0-rc.6",
56
+ "@deepseek-ai/dsh-client-runtime": "^0.1.0-rc.6",
57
+ "@deepseek-ai/dsh-client-ui-conversation": "^0.1.0-rc.6",
58
+ "@deepseek-ai/dsh-client-ui-primitives": "^0.1.0-rc.6",
59
+ "@deepseek-ai/dsh-client-ui-settings": "^0.1.0-rc.6",
60
+ "@deepseek-ai/dsh-client-ui-slots": "^0.1.0-rc.6",
61
+ "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6",
62
+ "@deepseek-ai/dsh-token-meter": "^0.1.0-rc.6",
63
+ "react": "^18.2.0"
64
+ },
65
+ "devDependencies": {
66
+ "@deepseek-ai/cordis": "^4.0.1",
67
+ "@deepseek-ai/dsh-api-remotes": "^0.1.1-rc.1",
68
+ "@deepseek-ai/dsh-client-locale": "^0.1.1-rc.1",
69
+ "@deepseek-ai/dsh-client-runtime": "^0.1.1-rc.1",
70
+ "@deepseek-ai/dsh-client-test-runtime": "^0.1.1-rc.1",
71
+ "@deepseek-ai/dsh-client-ui-conversation": "^0.1.1-rc.1",
72
+ "@deepseek-ai/dsh-client-ui-primitives": "^0.1.1-rc.1",
73
+ "@deepseek-ai/dsh-client-ui-settings": "^0.1.1-rc.1",
74
+ "@deepseek-ai/dsh-client-ui-settings-plugins": "^0.1.1-rc.1",
75
+ "@deepseek-ai/dsh-client-ui-slots": "^0.1.1-rc.1",
76
+ "@deepseek-ai/dsh-invariants": "^0.1.1-rc.1",
77
+ "@deepseek-ai/dsh-token-meter": "^0.1.1-rc.1",
78
+ "@testing-library/react": "^16.1.0",
79
+ "@types/react": "~18.3.1",
80
+ "react": "^18.2.0",
81
+ "react-dom": "^18.2.0"
82
+ },
83
+ "files": [
84
+ "lib",
85
+ "cordis.patch.yml",
86
+ "LICENSE",
87
+ "CHANGELOG.md"
88
+ ]
89
+ }