dsh-coding-subscription-oauth 0.5.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 (178) hide show
  1. package/CHANGELOG.md +136 -0
  2. package/CONTRIBUTING.md +109 -0
  3. package/INSTALL.md +220 -0
  4. package/LICENSE +19 -0
  5. package/NOTICE +11 -0
  6. package/README.de.md +254 -0
  7. package/README.es.md +254 -0
  8. package/README.fr.md +254 -0
  9. package/README.ja.md +254 -0
  10. package/README.ko.md +254 -0
  11. package/README.md +286 -0
  12. package/README.pt-BR.md +254 -0
  13. package/README.ru.md +254 -0
  14. package/README.zh-CN.md +271 -0
  15. package/cordis.patch.yml +13 -0
  16. package/docs/00-project-rules.md +195 -0
  17. package/docs/02-architecture.md +132 -0
  18. package/docs/02-architecture.zh-CN.md +128 -0
  19. package/lib/adapter.d.ts +24 -0
  20. package/lib/adapter.d.ts.map +1 -0
  21. package/lib/alias-adapter.d.ts +43 -0
  22. package/lib/alias-adapter.d.ts.map +1 -0
  23. package/lib/auth-routes.d.ts +155 -0
  24. package/lib/auth-routes.d.ts.map +1 -0
  25. package/lib/auth.d.ts +29 -0
  26. package/lib/auth.d.ts.map +1 -0
  27. package/lib/bin.d.ts +6 -0
  28. package/lib/bin.d.ts.map +1 -0
  29. package/lib/bin.js +27591 -0
  30. package/lib/bin.js.map +7 -0
  31. package/lib/capability-routes.d.ts +43 -0
  32. package/lib/capability-routes.d.ts.map +1 -0
  33. package/lib/capability-runtime.d.ts +56 -0
  34. package/lib/capability-runtime.d.ts.map +1 -0
  35. package/lib/capability-settings.d.ts +263 -0
  36. package/lib/capability-settings.d.ts.map +1 -0
  37. package/lib/capability-tools.d.ts +50 -0
  38. package/lib/capability-tools.d.ts.map +1 -0
  39. package/lib/catalog.d.ts +53 -0
  40. package/lib/catalog.d.ts.map +1 -0
  41. package/lib/client.js +3 -0
  42. package/lib/client.js.map +7 -0
  43. package/lib/codex-http.d.ts +77 -0
  44. package/lib/codex-http.d.ts.map +1 -0
  45. package/lib/codex-images.d.ts +109 -0
  46. package/lib/codex-images.d.ts.map +1 -0
  47. package/lib/codex-model-capabilities.d.ts +112 -0
  48. package/lib/codex-model-capabilities.d.ts.map +1 -0
  49. package/lib/codex-search.d.ts +96 -0
  50. package/lib/codex-search.d.ts.map +1 -0
  51. package/lib/codex-usage.d.ts +79 -0
  52. package/lib/codex-usage.d.ts.map +1 -0
  53. package/lib/gateway-anthropic-messages.d.ts +8 -0
  54. package/lib/gateway-anthropic-messages.d.ts.map +1 -0
  55. package/lib/gateway-auth.d.ts +22 -0
  56. package/lib/gateway-auth.d.ts.map +1 -0
  57. package/lib/gateway-backend.d.ts +62 -0
  58. package/lib/gateway-backend.d.ts.map +1 -0
  59. package/lib/gateway-body.d.ts +9 -0
  60. package/lib/gateway-body.d.ts.map +1 -0
  61. package/lib/gateway-config.d.ts +24 -0
  62. package/lib/gateway-config.d.ts.map +1 -0
  63. package/lib/gateway-http.d.ts +16 -0
  64. package/lib/gateway-http.d.ts.map +1 -0
  65. package/lib/gateway-openai-chat.d.ts +8 -0
  66. package/lib/gateway-openai-chat.d.ts.map +1 -0
  67. package/lib/gateway-openai-responses.d.ts +8 -0
  68. package/lib/gateway-openai-responses.d.ts.map +1 -0
  69. package/lib/gateway-parse.d.ts +10 -0
  70. package/lib/gateway-parse.d.ts.map +1 -0
  71. package/lib/gateway-protocol.d.ts +47 -0
  72. package/lib/gateway-protocol.d.ts.map +1 -0
  73. package/lib/gateway-routes.d.ts +21 -0
  74. package/lib/gateway-routes.d.ts.map +1 -0
  75. package/lib/gateway.d.ts +48 -0
  76. package/lib/gateway.d.ts.map +1 -0
  77. package/lib/grok-imagine.d.ts +271 -0
  78. package/lib/grok-imagine.d.ts.map +1 -0
  79. package/lib/grok-import.d.ts +21 -0
  80. package/lib/grok-import.d.ts.map +1 -0
  81. package/lib/http-json.d.ts +10 -0
  82. package/lib/http-json.d.ts.map +1 -0
  83. package/lib/ids.d.ts +33 -0
  84. package/lib/ids.d.ts.map +1 -0
  85. package/lib/imagine-routes.d.ts +59 -0
  86. package/lib/imagine-routes.d.ts.map +1 -0
  87. package/lib/index.d.ts +69 -0
  88. package/lib/index.d.ts.map +1 -0
  89. package/lib/index.js +35355 -0
  90. package/lib/index.js.map +7 -0
  91. package/lib/invariant.d.ts +9 -0
  92. package/lib/invariant.d.ts.map +1 -0
  93. package/lib/invariant.js +14 -0
  94. package/lib/invariant.js.map +7 -0
  95. package/lib/kimi-errors.d.ts +13 -0
  96. package/lib/kimi-errors.d.ts.map +1 -0
  97. package/lib/media-store.d.ts +130 -0
  98. package/lib/media-store.d.ts.map +1 -0
  99. package/lib/oauth-import-routes.d.ts +52 -0
  100. package/lib/oauth-import-routes.d.ts.map +1 -0
  101. package/lib/oauth-providers.d.ts +26 -0
  102. package/lib/oauth-providers.d.ts.map +1 -0
  103. package/lib/oauth-session.d.ts +40 -0
  104. package/lib/oauth-session.d.ts.map +1 -0
  105. package/lib/oauth-sources.d.ts +205 -0
  106. package/lib/oauth-sources.d.ts.map +1 -0
  107. package/lib/oauth.d.ts +79 -0
  108. package/lib/oauth.d.ts.map +1 -0
  109. package/lib/provider.d.ts +38 -0
  110. package/lib/provider.d.ts.map +1 -0
  111. package/lib/proxy.d.ts +17 -0
  112. package/lib/proxy.d.ts.map +1 -0
  113. package/lib/redact.d.ts +5 -0
  114. package/lib/redact.d.ts.map +1 -0
  115. package/lib/session.d.ts +40 -0
  116. package/lib/session.d.ts.map +1 -0
  117. package/lib/store.d.ts +46 -0
  118. package/lib/store.d.ts.map +1 -0
  119. package/lib/web-origin.d.ts +10 -0
  120. package/lib/web-origin.d.ts.map +1 -0
  121. package/lib/web-routes.d.ts +20 -0
  122. package/lib/web-routes.d.ts.map +1 -0
  123. package/package.json +185 -0
  124. package/patches/dsh-agy@0.1.2.patch +25 -0
  125. package/scripts/release.mjs +166 -0
  126. package/scripts/smoke-deployed-routes.mjs +146 -0
  127. package/scripts/verify-deployed-catalog.mjs +87 -0
  128. package/src/adapter.ts +282 -0
  129. package/src/alias-adapter.ts +152 -0
  130. package/src/auth-routes.ts +871 -0
  131. package/src/auth.ts +67 -0
  132. package/src/bin.ts +350 -0
  133. package/src/capability-routes.ts +275 -0
  134. package/src/capability-runtime.ts +313 -0
  135. package/src/capability-settings.ts +657 -0
  136. package/src/capability-tools.ts +666 -0
  137. package/src/catalog.ts +271 -0
  138. package/src/client/GrokBuildSettings.tsx +2221 -0
  139. package/src/client/index.tsx +37 -0
  140. package/src/client/locales.ts +421 -0
  141. package/src/codex-http.ts +447 -0
  142. package/src/codex-images.ts +485 -0
  143. package/src/codex-model-capabilities.ts +320 -0
  144. package/src/codex-search.ts +245 -0
  145. package/src/codex-usage.ts +263 -0
  146. package/src/gateway-anthropic-messages.ts +84 -0
  147. package/src/gateway-auth.ts +100 -0
  148. package/src/gateway-backend.ts +274 -0
  149. package/src/gateway-body.ts +49 -0
  150. package/src/gateway-config.ts +76 -0
  151. package/src/gateway-http.ts +104 -0
  152. package/src/gateway-openai-chat.ts +124 -0
  153. package/src/gateway-openai-responses.ts +53 -0
  154. package/src/gateway-parse.ts +224 -0
  155. package/src/gateway-protocol.ts +52 -0
  156. package/src/gateway-routes.ts +152 -0
  157. package/src/gateway.ts +242 -0
  158. package/src/grok-imagine.ts +1627 -0
  159. package/src/grok-import.ts +151 -0
  160. package/src/http-json.ts +82 -0
  161. package/src/ids.ts +45 -0
  162. package/src/imagine-routes.ts +461 -0
  163. package/src/index.ts +598 -0
  164. package/src/invariant.ts +17 -0
  165. package/src/kimi-errors.ts +26 -0
  166. package/src/media-store.ts +927 -0
  167. package/src/oauth-import-routes.ts +314 -0
  168. package/src/oauth-providers.ts +152 -0
  169. package/src/oauth-session.ts +183 -0
  170. package/src/oauth-sources.ts +1104 -0
  171. package/src/oauth.ts +620 -0
  172. package/src/provider.ts +128 -0
  173. package/src/proxy.ts +99 -0
  174. package/src/redact.ts +72 -0
  175. package/src/session.ts +218 -0
  176. package/src/store.ts +217 -0
  177. package/src/web-origin.ts +60 -0
  178. package/src/web-routes.ts +75 -0
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Plugin-owned same-origin Web routes for the capability-settings namespace.
3
+ * Arbitrary Host settings namespaces are not remotely exposed, so this plugin
4
+ * publishes only the secret-free snapshot and the two optional read surfaces.
5
+ * @module dsh-coding-subscription-oauth/capability-routes
6
+ */
7
+ import type { IncomingMessage, ServerResponse } from "node:http";
8
+ import { type CapabilitySettings, type CapabilitySettingsPatch, type CapabilitySettingsSnapshot } from "./capability-settings.js";
9
+ export declare const CAPABILITY_SETTINGS_PATH = "/plugins/dsh-grok-build/capabilities";
10
+ export declare const CODEX_USAGE_PATH = "/plugins/dsh-grok-build/codex/usage";
11
+ export declare const IMAGINE_CREDENTIAL_STATUS_PATH = "/plugins/dsh-grok-build/imagine/credential-status";
12
+ /** Structural `ctx.webServer` + `ctx.effect` surface used by the registrar. */
13
+ export interface CapabilityRouteContext {
14
+ readonly webServer: {
15
+ register(route: {
16
+ kind: "exact" | "prefix";
17
+ path: string;
18
+ handler: (req: IncomingMessage, res: ServerResponse) => void | Promise<void>;
19
+ }): () => void;
20
+ };
21
+ effect(callback: () => () => void | Promise<void>, label?: string): unknown;
22
+ }
23
+ /** Owner-facing subset of {@link import("./capability-settings.js").CapabilitySettingsController}. */
24
+ export interface CapabilityRouteController {
25
+ snapshot(): CapabilitySettingsSnapshot;
26
+ current(): CapabilitySettings;
27
+ patch(patch: CapabilitySettingsPatch, expectedRevision: number): Promise<CapabilitySettingsSnapshot>;
28
+ replace(section: CapabilitySettingsPatch, expectedRevision: number): Promise<CapabilitySettingsSnapshot>;
29
+ }
30
+ /** Secret-free Imagine credential probe returned on the optional status route. */
31
+ export interface ImagineCredentialStatus {
32
+ readonly configured: boolean;
33
+ readonly source: string;
34
+ readonly writable: boolean;
35
+ }
36
+ export interface CapabilityRouteOptions {
37
+ readonly controller: CapabilityRouteController;
38
+ readonly usage?: () => unknown | Promise<unknown>;
39
+ readonly credentialInfo?: () => unknown | Promise<unknown>;
40
+ }
41
+ /** Register the plugin-owned capability routes. Owns and returns the route disposer. */
42
+ export declare function registerCapabilityRoutes(ctx: CapabilityRouteContext, options: CapabilityRouteOptions): () => void;
43
+ //# sourceMappingURL=capability-routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability-routes.d.ts","sourceRoot":"","sources":["../../src/capability-routes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAEN,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAI/B,MAAM,0BAA0B,CAAC;AAMlC,eAAO,MAAM,wBAAwB,yCAAyC,CAAC;AAC/E,eAAO,MAAM,gBAAgB,wCAAwC,CAAC;AACtE,eAAO,MAAM,8BAA8B,sDAAsD,CAAC;AAElG,+EAA+E;AAC/E,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,SAAS,EAAE;QACnB,QAAQ,CAAC,KAAK,EAAE;YACf,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;YACzB,IAAI,EAAE,MAAM,CAAC;YACb,OAAO,EAAE,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;SAC7E,GAAG,MAAM,IAAI,CAAC;KACf,CAAC;IACF,MAAM,CAAC,QAAQ,EAAE,MAAM,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5E;AAED,sGAAsG;AACtG,MAAM,WAAW,yBAAyB;IACzC,QAAQ,IAAI,0BAA0B,CAAC;IACvC,OAAO,IAAI,kBAAkB,CAAC;IAC9B,KAAK,CAAC,KAAK,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;IACrG,OAAO,CAAC,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;CACzG;AAED,kFAAkF;AAClF,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,UAAU,EAAE,yBAAyB,CAAC;IAC/C,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAClD,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC3D;AAYD,wFAAwF;AACxF,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,sBAAsB,EAAE,OAAO,EAAE,sBAAsB,GAAG,MAAM,IAAI,CA4BjH"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Side-effect coordination for default-off optional capabilities.
3
+ *
4
+ * This module contains no Cordis service lookup. The parent supplies structural
5
+ * registries, which keeps live flag transitions deterministic and unit-testable.
6
+ * @module dsh-coding-subscription-oauth/capability-runtime
7
+ */
8
+ import type { ToolDefinition } from "@deepseek-ai/dsh-tools";
9
+ import { type CapabilitySettings } from "./capability-settings.js";
10
+ import type { CodexModelCapabilities } from "./codex-model-capabilities.js";
11
+ import type { CodexSearchProvider } from "./codex-search.js";
12
+ export type CapabilityRuntimeListener = (settings: CapabilitySettings) => void | Promise<void>;
13
+ /** Process-local live projection shared by optional service fibers. */
14
+ export declare class CapabilityRuntimeState {
15
+ private value;
16
+ private readonly listeners;
17
+ private readonly onListenerError;
18
+ constructor(initial?: CapabilitySettings, onListenerError?: (error: unknown) => void);
19
+ current(): CapabilitySettings;
20
+ set(next: unknown): CapabilitySettings;
21
+ /** Re-run live bindings after an external dependency (for example OAuth) changed. */
22
+ refresh(): void;
23
+ reset(): CapabilitySettings;
24
+ subscribe(listener: CapabilityRuntimeListener, emitCurrent?: boolean): () => void;
25
+ }
26
+ export interface CapabilitySearchRegistry {
27
+ registerSearchProvider(provider: CodexSearchProvider): () => void;
28
+ }
29
+ /** Dynamically expose search and clamp every request to the live result limit. */
30
+ export declare function bindCapabilitySearch(state: CapabilityRuntimeState, registry: CapabilitySearchRegistry, provider: CodexSearchProvider): () => void;
31
+ export interface CapabilityToolRegistry {
32
+ register(definition: ToolDefinition): () => void;
33
+ }
34
+ /** Return whether one optional tool should currently be advertised. */
35
+ export declare function capabilityToolEnabled(name: string, settings: CapabilitySettings): boolean;
36
+ /** Dynamically advertise only enabled tools; execute-time guards remain in each definition. */
37
+ export declare function bindCapabilityTools(state: CapabilityRuntimeState, registry: CapabilityToolRegistry, definitions: readonly ToolDefinition[]): () => void;
38
+ export interface ReplaceableAdapterRegistration {
39
+ replace(routes: string[]): void;
40
+ }
41
+ export interface CapabilityTimer {
42
+ setInterval(callback: () => void, ms: number): unknown;
43
+ clearInterval(handle: unknown): void;
44
+ }
45
+ export interface CodexFastBindingOptions {
46
+ readonly refreshIntervalMs?: number;
47
+ readonly timer?: CapabilityTimer;
48
+ readonly onError?: (error: unknown) => void;
49
+ }
50
+ /**
51
+ * Publish the Fast route only after a fresh live catalog explicitly lists at
52
+ * least one priority-eligible model. Disabling is synchronous; stale or failed
53
+ * refreshes atomically withdraw the optional route.
54
+ */
55
+ export declare function bindCodexFastRoute(state: CapabilityRuntimeState, capabilities: CodexModelCapabilities, registration: ReplaceableAdapterRegistration, options?: CodexFastBindingOptions): () => void;
56
+ //# sourceMappingURL=capability-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability-runtime.d.ts","sourceRoot":"","sources":["../../src/capability-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,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GAAG,OAAO,CAczF;AAED,+FAA+F;AAC/F,wBAAgB,mBAAmB,CAClC,KAAK,EAAE,sBAAsB,EAC7B,QAAQ,EAAE,sBAAsB,EAChC,WAAW,EAAE,SAAS,cAAc,EAAE,GACpC,MAAM,IAAI,CAyBZ;AAED,MAAM,WAAW,8BAA8B;IAC9C,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,eAAe;IAC/B,WAAW,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IACvD,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;CACrC;AAED,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,eAAe,CAAC;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAC5C;AAID;;;;GAIG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,sBAAsB,EAC7B,YAAY,EAAE,sBAAsB,EACpC,YAAY,EAAE,8BAA8B,EAC5C,OAAO,GAAE,uBAA4B,GACnC,MAAM,IAAI,CAoFZ"}
@@ -0,0 +1,263 @@
1
+ import Schema from "@deepseek-ai/schemastery";
2
+ /**
3
+ * Integration-ready capability settings controller for the
4
+ * `coding-subscription-oauth` namespace. Schema defaults sit under the
5
+ * composition/YAML `base`, and the user section layers on top. The controller
6
+ * talks to an injected structural settings service while registering a real
7
+ * Schemastery section that the Host settings service can render and validate.
8
+ * @module dsh-coding-subscription-oauth/capability-settings
9
+ */
10
+ /** Settings namespace owned by this plugin. */
11
+ export declare const CAPABILITY_SETTINGS_NAMESPACE = "coding-subscription-oauth";
12
+ /** Default-off capability flags. Presence in the user section marks an override. */
13
+ export declare const CAPABILITY_FLAG_KEYS: readonly ["codexSearch", "codexImages", "codexImageEdits", "codexUsage", "codexFast", "grokImagineImage", "grokImagineVideo"];
14
+ /** Conservative numeric limits persisted beside the flags. */
15
+ export declare const CAPABILITY_LIMIT_KEYS: readonly ["searchResults", "imageCount", "videoArtifactTtlMs"];
16
+ /** Every key the controller admits into secret-free state. */
17
+ export declare const CAPABILITY_SETTINGS_KEYS: readonly ["codexSearch", "codexImages", "codexImageEdits", "codexUsage", "codexFast", "grokImagineImage", "grokImagineVideo", "searchResults", "imageCount", "videoArtifactTtlMs"];
18
+ export type CapabilityFlagKey = (typeof CAPABILITY_FLAG_KEYS)[number];
19
+ export type CapabilityLimitKey = (typeof CAPABILITY_LIMIT_KEYS)[number];
20
+ export type CapabilitySettingsKey = (typeof CAPABILITY_SETTINGS_KEYS)[number];
21
+ /** Resolved, secret-free capability section. */
22
+ export interface CapabilitySettings {
23
+ readonly codexSearch: boolean;
24
+ readonly codexImages: boolean;
25
+ readonly codexImageEdits: boolean;
26
+ readonly codexUsage: boolean;
27
+ readonly codexFast: boolean;
28
+ readonly grokImagineImage: boolean;
29
+ readonly grokImagineVideo: boolean;
30
+ readonly searchResults: number;
31
+ readonly imageCount: number;
32
+ readonly videoArtifactTtlMs: number;
33
+ }
34
+ /** Sparse overlay used for YAML/composition `base` and the user section. */
35
+ export type CapabilitySettingsPatch = Partial<CapabilitySettings>;
36
+ /** Inclusive bounds and schema defaults for each numeric limit. */
37
+ export declare const CAPABILITY_SETTINGS_BOUNDS: {
38
+ readonly searchResults: {
39
+ readonly min: 1;
40
+ readonly max: 20;
41
+ readonly default: 5;
42
+ };
43
+ readonly imageCount: {
44
+ readonly min: 1;
45
+ readonly max: 4;
46
+ readonly default: 1;
47
+ };
48
+ readonly videoArtifactTtlMs: {
49
+ readonly min: number;
50
+ readonly max: number;
51
+ readonly default: number;
52
+ };
53
+ };
54
+ /** Schema defaults: every flag off, every limit at its conservative default. */
55
+ export declare const DEFAULT_CAPABILITY_SETTINGS: CapabilitySettings;
56
+ /**
57
+ * Real Schemastery schema registered with the Host settings service. Defaults
58
+ * remain conservative, and bounds are enforced before a user document commits.
59
+ */
60
+ export declare const CapabilitySettingsSchema: Schema<Schemastery.ObjectS<{
61
+ codexSearch: Schema<boolean, boolean>;
62
+ codexImages: Schema<boolean, boolean>;
63
+ codexImageEdits: Schema<boolean, boolean>;
64
+ codexUsage: Schema<boolean, boolean>;
65
+ codexFast: Schema<boolean, boolean>;
66
+ grokImagineImage: Schema<boolean, boolean>;
67
+ grokImagineVideo: Schema<boolean, boolean>;
68
+ searchResults: Schema<number, number>;
69
+ imageCount: Schema<number, number>;
70
+ videoArtifactTtlMs: Schema<number, number>;
71
+ }>, Schemastery.ObjectT<{
72
+ codexSearch: Schema<boolean, boolean>;
73
+ codexImages: Schema<boolean, boolean>;
74
+ codexImageEdits: Schema<boolean, boolean>;
75
+ codexUsage: Schema<boolean, boolean>;
76
+ codexFast: Schema<boolean, boolean>;
77
+ grokImagineImage: Schema<boolean, boolean>;
78
+ grokImagineVideo: Schema<boolean, boolean>;
79
+ searchResults: Schema<number, number>;
80
+ imageCount: Schema<number, number>;
81
+ videoArtifactTtlMs: Schema<number, number>;
82
+ }>>;
83
+ /** Serialized schema metadata consumed by Settings UI tests and diagnostics. */
84
+ export declare const CAPABILITY_SETTINGS_SCHEMA_JSON: Schema<Schemastery.ObjectS<{
85
+ codexSearch: Schema<boolean, boolean>;
86
+ codexImages: Schema<boolean, boolean>;
87
+ codexImageEdits: Schema<boolean, boolean>;
88
+ codexUsage: Schema<boolean, boolean>;
89
+ codexFast: Schema<boolean, boolean>;
90
+ grokImagineImage: Schema<boolean, boolean>;
91
+ grokImagineVideo: Schema<boolean, boolean>;
92
+ searchResults: Schema<number, number>;
93
+ imageCount: Schema<number, number>;
94
+ videoArtifactTtlMs: Schema<number, number>;
95
+ }>, Schemastery.ObjectT<{
96
+ codexSearch: Schema<boolean, boolean>;
97
+ codexImages: Schema<boolean, boolean>;
98
+ codexImageEdits: Schema<boolean, boolean>;
99
+ codexUsage: Schema<boolean, boolean>;
100
+ codexFast: Schema<boolean, boolean>;
101
+ grokImagineImage: Schema<boolean, boolean>;
102
+ grokImagineVideo: Schema<boolean, boolean>;
103
+ searchResults: Schema<number, number>;
104
+ imageCount: Schema<number, number>;
105
+ videoArtifactTtlMs: Schema<number, number>;
106
+ }>>;
107
+ export type CapabilitySettingsSchemaType = typeof CapabilitySettingsSchema;
108
+ /** Revision-bearing, secret-free snapshot used for CAS writes and UI. */
109
+ export interface CapabilitySettingsSnapshot {
110
+ readonly ns: typeof CAPABILITY_SETTINGS_NAMESPACE;
111
+ readonly value: CapabilitySettings;
112
+ readonly base?: CapabilitySettingsPatch;
113
+ readonly user?: CapabilitySettingsPatch;
114
+ readonly revision: number;
115
+ readonly writable: boolean;
116
+ readonly applies: "live";
117
+ readonly secrets: readonly [];
118
+ }
119
+ /** Owner-facing subset of `ctx.settings.register()` used when the parent injects a provider. */
120
+ export interface CapabilitySettingsScope {
121
+ get(): unknown;
122
+ watch(callback: (next: unknown, prev: unknown) => void | Promise<void>): () => void;
123
+ update(patch: object): Promise<void>;
124
+ replace(section: object): Promise<void>;
125
+ }
126
+ /** One namespace descriptor as returned by a structural `describe()`. */
127
+ export interface CapabilitySettingsDescriptor {
128
+ readonly ns: string;
129
+ readonly value?: unknown;
130
+ readonly base?: unknown;
131
+ readonly user?: unknown;
132
+ readonly revision?: number;
133
+ readonly applies?: "live" | "restart";
134
+ readonly secrets?: readonly {
135
+ readonly path?: readonly string[];
136
+ readonly set?: boolean;
137
+ }[];
138
+ }
139
+ /**
140
+ * Duck-typed settings service. A real `ctx.settings` satisfies this without a
141
+ * compile-time dependency on `@deepseek-ai/dsh-settings`.
142
+ */
143
+ export interface CapabilitySettingsService {
144
+ readonly writable?: boolean;
145
+ describe?(options?: {
146
+ readonly redactSecrets?: boolean;
147
+ }): readonly CapabilitySettingsDescriptor[];
148
+ get?(ns: string): unknown;
149
+ update?(ns: string, patch: object, expectedRevision?: number): Promise<void>;
150
+ replace?(ns: string, section: object, expectedRevision?: number): Promise<void>;
151
+ register?(ns: string, schema: CapabilitySettingsSchemaType, options?: {
152
+ readonly base?: CapabilitySettingsPatch;
153
+ readonly applies?: "live" | "restart";
154
+ readonly validate?: (value: CapabilitySettings) => void;
155
+ }): CapabilitySettingsScope;
156
+ }
157
+ /** Construction options. `base` is the YAML / composition entry layered under the user section. */
158
+ export interface CapabilitySettingsControllerOptions {
159
+ readonly settings?: CapabilitySettingsService | undefined;
160
+ readonly base?: CapabilitySettingsPatch | undefined;
161
+ /** Contain both synchronous and asynchronous observer failures. */
162
+ readonly onListenerError?: ((error: unknown) => void) | undefined;
163
+ }
164
+ /** Listener invoked after a committed snapshot change. */
165
+ export type CapabilitySettingsListener = (snapshot: CapabilitySettingsSnapshot) => void | Promise<void>;
166
+ /**
167
+ * A write refused because the namespace moved since the caller read it.
168
+ * `code` matches the Host settings seam so a later wire layer can map it.
169
+ */
170
+ export declare class CapabilitySettingsConflictError extends Error {
171
+ readonly code = "SETTINGS_CONFLICT";
172
+ readonly ns = "coding-subscription-oauth";
173
+ readonly expected: number;
174
+ readonly actual: number;
175
+ constructor(expected: number, actual: number);
176
+ }
177
+ /** A write refused because no writable settings provider is attached. */
178
+ export declare class CapabilitySettingsReadOnlyError extends Error {
179
+ readonly code: "SETTINGS_PROVIDER_ABSENT" | "SETTINGS_READ_ONLY" | "SETTINGS_DISPOSED";
180
+ readonly ns = "coding-subscription-oauth";
181
+ readonly reason: "absent" | "read-only" | "disposed";
182
+ constructor(reason: "absent" | "read-only" | "disposed");
183
+ }
184
+ export declare function isCapabilitySettingsConflictError(error: unknown): error is CapabilitySettingsConflictError;
185
+ export declare function isCapabilitySettingsReadOnlyError(error: unknown): error is CapabilitySettingsReadOnlyError;
186
+ /** Pick every independently default-off flag from a resolved section. */
187
+ export declare function capabilityFlags(settings: CapabilitySettings): Pick<CapabilitySettings, CapabilityFlagKey>;
188
+ /** Pick the conservative numeric limits from a resolved section. */
189
+ export declare function capabilityLimits(settings: CapabilitySettings): Pick<CapabilitySettings, CapabilityLimitKey>;
190
+ /** Layer schema defaults, then YAML/composition `base`, then the user section. */
191
+ export declare function resolveCapabilitySettings(base?: CapabilitySettingsPatch | undefined, user?: CapabilitySettingsPatch | undefined): CapabilitySettings;
192
+ /**
193
+ * Admit a candidate section: known keys only, flags default off, limits clamped,
194
+ * secret-shaped keys dropped. Used for both reads and the structural schema.
195
+ */
196
+ export declare function normalizeCapabilitySettings(input?: unknown): CapabilitySettings;
197
+ /**
198
+ * Normalize a sparse overlay. Invalid or secret fields are omitted so a lower
199
+ * layer (YAML base / schema default) remains authoritative for that key.
200
+ */
201
+ export declare function normalizeCapabilitySettingsPatch(input?: unknown): CapabilitySettingsPatch;
202
+ /**
203
+ * Strictly admit a caller-authored sparse section before normalizing it. Reads
204
+ * remain compatibility-tolerant, but writes must never silently drop unknown
205
+ * fields, coerce types, truncate decimals, or clamp out-of-range limits.
206
+ */
207
+ export declare function assertCapabilitySettingsPatch(input: unknown, label?: string): asserts input is CapabilitySettingsPatch;
208
+ /** Reject a resolved section the owner could not act on. Schema-valid by construction after normalize. */
209
+ export declare function assertServiceableCapabilitySettings(value: CapabilitySettings): void;
210
+ /**
211
+ * Live capability-settings controller. Without an injected provider the
212
+ * resolved state is the YAML/default layer and every write fails explicitly.
213
+ */
214
+ export declare class CapabilitySettingsController {
215
+ readonly ns = "coding-subscription-oauth";
216
+ private readonly settings;
217
+ private readonly base;
218
+ private readonly onListenerError;
219
+ private readonly listeners;
220
+ private scope;
221
+ private scopeDisposer;
222
+ private localRevision;
223
+ private lastSnapshot;
224
+ private disposed;
225
+ constructor(options?: CapabilitySettingsControllerOptions);
226
+ /** Current revision-bearing snapshot. Re-reads the injected provider when present. */
227
+ snapshot(): CapabilitySettingsSnapshot;
228
+ /** Resolved capability section (schema defaults ← YAML base ← user). */
229
+ current(): CapabilitySettings;
230
+ /**
231
+ * Merge a secret-free patch into the user layer using compare-and-swap on
232
+ * `expectedRevision` from a previously read {@link snapshot}.
233
+ */
234
+ patch(patch: CapabilitySettingsPatch, expectedRevision: number): Promise<CapabilitySettingsSnapshot>;
235
+ /**
236
+ * Replace the user section wholesale (`{}` re-inherits YAML base and defaults).
237
+ * Compare-and-swap uses the same revision token as {@link patch}.
238
+ */
239
+ replace(section: CapabilitySettingsPatch, expectedRevision: number): Promise<CapabilitySettingsSnapshot>;
240
+ /**
241
+ * Observe committed snapshot changes. The disposer removes this listener;
242
+ * an invocation already running still settles.
243
+ */
244
+ subscribe(listener: CapabilitySettingsListener): () => void;
245
+ /**
246
+ * Re-read the injected provider (or the local YAML/default layer) and notify
247
+ * listeners when the secret-free snapshot moved.
248
+ */
249
+ reconcile(): CapabilitySettingsSnapshot;
250
+ /** Drop the register() watcher and every listener. Further writes fail. */
251
+ dispose(): void;
252
+ private attachScope;
253
+ private writeReason;
254
+ private isWritable;
255
+ private write;
256
+ private readSnapshot;
257
+ private readResolvedFromService;
258
+ private readDescribed;
259
+ private publish;
260
+ }
261
+ /** Construct a {@link CapabilitySettingsController}. */
262
+ export declare function createCapabilitySettingsController(options?: CapabilitySettingsControllerOptions): CapabilitySettingsController;
263
+ //# sourceMappingURL=capability-settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability-settings.d.ts","sourceRoot":"","sources":["../../src/capability-settings.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,0BAA0B,CAAC;AAE9C;;;;;;;GAOG;AAEH,+CAA+C;AAC/C,eAAO,MAAM,6BAA6B,8BAA8B,CAAC;AAEzE,oFAAoF;AACpF,eAAO,MAAM,oBAAoB,+HAQvB,CAAC;AAEX,8DAA8D;AAC9D,eAAO,MAAM,qBAAqB,gEAAiE,CAAC;AAEpG,8DAA8D;AAC9D,eAAO,MAAM,wBAAwB,oLAA+D,CAAC;AAErG,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AACtE,MAAM,MAAM,kBAAkB,GA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AY;IAyBpB,OAAO,CAAC,uBAAuB;IAS/B,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,OAAO;CAgBf;AAED,wDAAwD;AACxD,wBAAgB,kCAAkC,CACjD,OAAO,GAAE,mCAAwC,GAC/C,4BAA4B,CAE9B"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Optional Codex / Grok Imagine tool definitions. The factory only returns
3
+ * public `ToolDefinition` objects — it never registers on `ctx.tools`.
4
+ * Feature flags and `imageCount` are re-read from `current()` at execute time.
5
+ * @module dsh-coding-subscription-oauth/capability-tools
6
+ */
7
+ import type { ToolDefinition, ToolRunContext } from "@deepseek-ai/dsh-tools";
8
+ import { type CapabilitySettings } from "./capability-settings.js";
9
+ import type { CodexAuthSession } from "./codex-http.js";
10
+ import { type CodexImageAttachmentStore, type CodexImageController, type CodexImageRoute, type CodexImageSessionContext } from "./codex-images.js";
11
+ import { type GrokImagineClient } from "./grok-imagine.js";
12
+ export declare const CODEX_IMAGE_GENERATE_TOOL = "codex_image_generate";
13
+ export declare const CODEX_IMAGE_EDIT_TOOL = "codex_image_edit";
14
+ export { GROK_IMAGINE_IMAGE_TOOL, GROK_IMAGINE_VIDEO_STATUS_TOOL, GROK_IMAGINE_VIDEO_TOOL, } from "./grok-imagine.js";
15
+ /** Shared client surface; production passes one `GrokImagineClient` so video status can see started jobs. */
16
+ export type CapabilityImagineClient = Pick<GrokImagineClient, "generateImage" | "startVideo" | "videoStatus">;
17
+ /** Per-exec Codex controller factory. Tests inject a fake; production binds auth + attachments. */
18
+ export type CreateCodexImageController = (session: CodexImageSessionContext) => CodexImageController;
19
+ /** Resolve authoritative host model metadata for the calling route. */
20
+ export type ResolveCodexImageRoute = (exec: ToolRunContext) => Promise<CodexImageRoute | undefined>;
21
+ /** Exact provider/model identity from the live request header, then agent options. */
22
+ export declare function callingRouteIdentity(exec: ToolRunContext): {
23
+ provider: string;
24
+ model: string;
25
+ } | undefined;
26
+ /**
27
+ * Copy host-resolved modalities onto the calling identity. Never invents
28
+ * `inputModalities`; lookup failures keep the identity and omit the field so
29
+ * the image-capability gate fails closed.
30
+ */
31
+ export declare function resolveCodexImageRouteFromLlm(exec: ToolRunContext, resolveModelInfo: (provider: string, model: string, signal?: AbortSignal) => Promise<{
32
+ inputModalities?: readonly string[];
33
+ }>): Promise<CodexImageRoute | undefined>;
34
+ export interface CapabilityToolsOptions {
35
+ /** Live capability section. Re-read on every execute so a disable takes effect immediately. */
36
+ current(): CapabilitySettings;
37
+ readonly auth: CodexAuthSession;
38
+ readonly attachments: CodexImageAttachmentStore;
39
+ readonly imagine: CapabilityImagineClient;
40
+ readonly createCodexController?: CreateCodexImageController;
41
+ readonly resolveCodexImageRoute?: ResolveCodexImageRoute;
42
+ }
43
+ /**
44
+ * Build the five optional capability tools. Callers register the returned
45
+ * definitions; this function has no Cordis / registry side effects. The tools
46
+ * peer is loaded only after Cordis has composed the optional `tools` service.
47
+ */
48
+ export declare function createCapabilityTools(options: CapabilityToolsOptions): Promise<readonly ToolDefinition[]>;
49
+ export declare const CAPABILITY_TOOL_NAMES: readonly ["codex_image_generate", "codex_image_edit", "grok_imagine_image", "grok_imagine_video", "grok_imagine_video_status"];
50
+ //# sourceMappingURL=capability-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability-tools.d.ts","sourceRoot":"","sources":["../../src/capability-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAA8B,KAAK,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC/F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAMN,KAAK,yBAAyB,EAE9B,KAAK,oBAAoB,EAGzB,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAG7B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAON,KAAK,iBAAiB,EAkBtB,M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AAQ,CAAC,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;CACzD;AAiQD;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,SAAS,cAAc,EAAE,CAAC,CA6Q/G;AAED,eAAO,MAAM,qBAAqB,gIAMxB,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Account-specific Grok Build catalog: live GET /v1/models-v2 merged onto the
3
+ * static baseline descriptors. Failures keep the last good list, then the
4
+ * static baseline.
5
+ * @module dsh-coding-subscription-oauth/catalog
6
+ */
7
+ import type { Api, Model, ThinkingLevelMap } from "@earendil-works/pi-ai";
8
+ export type CatalogSource = "live" | "cache" | "fallback";
9
+ /** Vendor listing fields we keep after a live `/models-v2` fetch. */
10
+ export interface LiveModelDescriptor {
11
+ id: string;
12
+ name?: string;
13
+ contextWindow?: number;
14
+ reasoning?: boolean;
15
+ thinkingLevelMap?: ThinkingLevelMap;
16
+ }
17
+ /**
18
+ * Translate Grok Build `reasoning_efforts` into a pi-ai map. Undeclared
19
+ * extended levels (especially `xhigh`) must be pinned to null — pi-ai treats
20
+ * an absent xhigh/max key as unsupported, and an absent low/medium/high key
21
+ * as supported.
22
+ */
23
+ export declare function thinkingLevelMapFromLiveEfforts(efforts: unknown): ThinkingLevelMap | undefined;
24
+ /** Pull the live listing, including per-model reasoning levels when present. */
25
+ export declare function extractLiveModels(body: unknown): LiveModelDescriptor[];
26
+ /**
27
+ * Pull model ids from a listing body. The `/v1/models-v2` response shape is
28
+ * not a published contract, so accept the common envelopes: a bare array, an
29
+ * OpenAI-style `{ data: [...] }`, or `{ models: [...] }`; rows may be plain
30
+ * ids or objects with an `id` field.
31
+ */
32
+ export declare function extractModelIds(body: unknown): string[];
33
+ /** Turn a live id into a pi-ai model, inheriting baseline metadata when possible. */
34
+ export declare function materializeLiveModel(id: string, catalog?: readonly Model<Api>[], overlay?: LiveModelDescriptor): Model<Api>;
35
+ /**
36
+ * If `liveIds` is missing or empty, serve the baseline catalog.
37
+ * Otherwise serve only the live ids, each materialized against the baseline
38
+ * and optionally overlaid with live `/models-v2` reasoning metadata.
39
+ */
40
+ export declare function mergeLiveCatalog(catalog: readonly Model<Api>[], liveIds: readonly string[] | undefined, liveModels?: readonly LiveModelDescriptor[]): Model<Api>[];
41
+ export declare function preferredGrokBuildModelFrom(models: readonly {
42
+ id: string;
43
+ }[]): string;
44
+ /**
45
+ * Fetch the account-visible models from `/v1/models-v2` with the CLI
46
+ * fingerprint headers. Throws a secret-free error on failure.
47
+ */
48
+ export declare function fetchLiveModels(accessToken: string, signal?: AbortSignal): Promise<LiveModelDescriptor[]>;
49
+ /** Fetch only the account-visible model ids from `/v1/models-v2`. */
50
+ export declare function fetchLiveModelIds(accessToken: string, signal?: AbortSignal): Promise<string[]>;
51
+ /** Re-exported so callers can normalise cached descriptors onto the route. */
52
+ export declare function asRouteModel(model: Model<Api>): Model<Api>;
53
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/catalog.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAS1E,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;AAE1D,qEAAqE;AACrE,MAAM,WAAW,mBAAmB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACpC;AAoBD;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,OAAO,GAAG,gBAAgB,GAAG,SAAS,CAmB9F;AAyBD,gFAAgF;AAChF,wBAAgB,iBAAiB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