dsh-advisor 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.
- package/LICENSE +21 -0
- package/README.i18n.yaml +7 -0
- package/README.md +303 -0
- package/README.zh.md +166 -0
- package/cordis.patch.yml +6 -0
- package/lib/advisor-runtime.d.ts +242 -0
- package/lib/advisor-runtime.js +662 -0
- package/lib/advisor-runtime.js.map +1 -0
- package/lib/client/advisor-card.d.ts +90 -0
- package/lib/client/advisor-store.d.ts +310 -0
- package/lib/client/index.d.ts +39 -0
- package/lib/client/locales.d.ts +40 -0
- package/lib/client.d.ts +1 -0
- package/lib/client.js +840 -0
- package/lib/commands.d.ts +136 -0
- package/lib/commands.js +185 -0
- package/lib/commands.js.map +1 -0
- package/lib/config.d.ts +74 -0
- package/lib/config.js +93 -0
- package/lib/config.js.map +1 -0
- package/lib/delivery.d.ts +129 -0
- package/lib/delivery.js +169 -0
- package/lib/delivery.js.map +1 -0
- package/lib/emission-guard.d.ts +99 -0
- package/lib/emission-guard.js +155 -0
- package/lib/emission-guard.js.map +1 -0
- package/lib/gateway.d.ts +116 -0
- package/lib/gateway.js +214 -0
- package/lib/gateway.js.map +1 -0
- package/lib/index.d.ts +48 -0
- package/lib/index.js +485 -0
- package/lib/index.js.map +1 -0
- package/lib/kinds.d.ts +38 -0
- package/lib/kinds.js +24 -0
- package/lib/kinds.js.map +1 -0
- package/lib/prompts.d.ts +22 -0
- package/lib/prompts.js +38 -0
- package/lib/prompts.js.map +1 -0
- package/lib/settings.d.ts +96 -0
- package/lib/settings.js +141 -0
- package/lib/settings.js.map +1 -0
- package/lib/transcript.d.ts +257 -0
- package/lib/transcript.js +530 -0
- package/lib/transcript.js.map +1 -0
- package/package.json +90 -0
- package/scripts/build-client.mjs +268 -0
package/lib/gateway.js
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T1 (plan dsh-advisor-settings-gateway-n5) — host-side `advisor` config
|
|
3
|
+
* gateway: the `/api/advisor/get` + `/api/advisor/set` Remote endpoints.
|
|
4
|
+
*
|
|
5
|
+
* Transport: the typertGateway `/api` interceptor is the single host-wide RPC
|
|
6
|
+
* slot (a plugin must NOT `connection.rpc.intercept('/api')` again — it would
|
|
7
|
+
* throw). Instead this service declares a typertGateway binding (via the
|
|
8
|
+
* `TypertRemoteService` base) plus `@Remote` method markers; the gateway's SRC
|
|
9
|
+
* discovery (`claimsEndpoint` — `ctx.reflect.props` + `remoteMethods`) claims
|
|
10
|
+
* `/api/advisor/get` and `/api/advisor/set`, and the payload contract is
|
|
11
|
+
* exactly one plain-object `args` field whose keys are the method parameter
|
|
12
|
+
* names (`get()` → `{ args: {} }`; `set(patch)` → `{ args: { patch } }`).
|
|
13
|
+
*
|
|
14
|
+
* Data: `get` reads the `AdvisorSettingsBridge` source — the same live
|
|
15
|
+
* composed config the runtime reads (schema defaults → plugin-row base →
|
|
16
|
+
* settings user layer), resolved through the `resolveAdvisorConfig` hard gate
|
|
17
|
+
* (the SSOT for enabled-without-pair disabled-with-reason). `set` validates
|
|
18
|
+
* the patch against the `Config` schema first (unknown-key rejection
|
|
19
|
+
* unchanged — the settings service itself is non-strict and would accept the
|
|
20
|
+
* unknown key), then writes the USER layer in-process via
|
|
21
|
+
* `ctx.settings.update` (no exposed-namespace gate on the in-process write —
|
|
22
|
+
* the wire-level `exposedNamespaces()` check only guards the apiproxy path),
|
|
23
|
+
* and returns the new composed value.
|
|
24
|
+
*
|
|
25
|
+
* The settings service is OPTIONAL (no settings service → the bridge source
|
|
26
|
+
* stays the entry, `get` still works; `set` fails with a clear error — KD-G5
|
|
27
|
+
* fallback). The gateway captures the service through a conditional
|
|
28
|
+
* `ctx.inject(['settings'], ...)` child (the same activation pattern as
|
|
29
|
+
* `installAdvisorSettings`), because `ctx.settings` is only resolvable from a
|
|
30
|
+
* fiber that declares it.
|
|
31
|
+
*
|
|
32
|
+
* The returned config is normalized to the typertGateway JSON wire boundary:
|
|
33
|
+
* absent keys (provider/model/disabledReason) are OMITTED, never
|
|
34
|
+
* present-as-undefined (the gateway's result validation rejects undefined
|
|
35
|
+
* values).
|
|
36
|
+
*
|
|
37
|
+
* @module dsh-advisor/gateway
|
|
38
|
+
*/
|
|
39
|
+
import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
|
|
40
|
+
import { ADVISOR_SETTINGS_NAMESPACE } from './settings.js';
|
|
41
|
+
import { resolveAdvisorConfig } from './config.js';
|
|
42
|
+
/**
|
|
43
|
+
* The host-side `advisor` config gateway (`/api/advisor/get` +
|
|
44
|
+
* `/api/advisor/set`). Registered as the cordis service key `'advisor'`
|
|
45
|
+
* (namespace defaults to the service key). The `TypertRemoteService` base is
|
|
46
|
+
* kept ONLY for its `typertRemote` binding — the typertGateway's dispatch
|
|
47
|
+
* `validateBinding` requires the visible binding on the live service (a pure
|
|
48
|
+
* instance property, no module-private state). Endpoints are registered
|
|
49
|
+
* EXPLICITLY through `ctx.typert.register(advisorTypertContribution())`
|
|
50
|
+
* (see `apply` in `src/index.ts`) instead of the `@Remote` SRC markers:
|
|
51
|
+
* SRC discovery reads `remoteMethods()` — a module-private WeakMap in
|
|
52
|
+
* `@deepseek-ai/dsh-typert-protocol` — so a locally-linked plugin whose
|
|
53
|
+
* peers resolve outside the host installation never shares that table with
|
|
54
|
+
* the host typertGateway (zero claimed endpoints, `/api/advisor/*` 404).
|
|
55
|
+
* The explicit `TypertRegistry.register` path writes the invocation
|
|
56
|
+
* descriptors into `ctx.typert.local`, which `claimsEndpoint` checks FIRST,
|
|
57
|
+
* so claim + dispatch work regardless of module identity.
|
|
58
|
+
*/
|
|
59
|
+
export class AdvisorConfigGateway extends TypertRemoteService {
|
|
60
|
+
bridge;
|
|
61
|
+
/** The live settings service once the optional inject child activates. */
|
|
62
|
+
settings;
|
|
63
|
+
/**
|
|
64
|
+
* @param ctx - owning context (the plugin fiber's ctx inside `apply`).
|
|
65
|
+
* @param bridge - the same `AdvisorSettingsBridge` the runtime reads, so
|
|
66
|
+
* get/set always operate on the live composed config.
|
|
67
|
+
*/
|
|
68
|
+
constructor(ctx, bridge) {
|
|
69
|
+
super(ctx, 'advisor');
|
|
70
|
+
this.bridge = bridge;
|
|
71
|
+
// The settings service is optional (no settings → entry fallback). The
|
|
72
|
+
// inject child activates only when a settings service is composed, mirroring
|
|
73
|
+
// installAdvisorSettings' conditional child; the returned disposer mirrors
|
|
74
|
+
// its detach path — when the settings service goes away, the write channel
|
|
75
|
+
// is gone with it, and `set` must fail cleanly (KD-G5) instead of holding a
|
|
76
|
+
// stale service reference.
|
|
77
|
+
ctx.inject(['settings'], (sctx) => {
|
|
78
|
+
this.settings = sctx.settings;
|
|
79
|
+
return () => {
|
|
80
|
+
this.settings = undefined;
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Read the current composed config (schema defaults → entry base → settings
|
|
86
|
+
* user layer) through the hard gate.
|
|
87
|
+
* @returns the resolved config (incl. disabledReason when the gate blocks).
|
|
88
|
+
*/
|
|
89
|
+
get() {
|
|
90
|
+
return { config: this.readConfig() };
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Validate a config patch and write it to the settings USER layer (live —
|
|
94
|
+
* the runtime re-applies through the bridge `onChange`; no restart needed).
|
|
95
|
+
* @param patch - any subset of the config keys; unknown keys are rejected
|
|
96
|
+
* by the `Config` schema before anything is written.
|
|
97
|
+
* @returns the NEW composed config after the write.
|
|
98
|
+
* @throws when the patch fails `Config` validation, or when no settings
|
|
99
|
+
* service is composed (KD-G5: the write channel is unavailable).
|
|
100
|
+
*/
|
|
101
|
+
async set(patch) {
|
|
102
|
+
// Unknown-key rejection + type/bounds validation. The settings service
|
|
103
|
+
// schema is non-strict (unknown keys merge through), so the explicit
|
|
104
|
+
// reject happens here, before the write — same strictness as the Loader.
|
|
105
|
+
resolveAdvisorConfig(patch);
|
|
106
|
+
// S2: an empty patch is a no-op — return the current composed value
|
|
107
|
+
// without a pointless settings round-trip.
|
|
108
|
+
if (Object.keys(patch).length === 0)
|
|
109
|
+
return { config: this.readConfig() };
|
|
110
|
+
const settings = this.settings;
|
|
111
|
+
if (settings === undefined) {
|
|
112
|
+
throw new Error('advisor: settings service is unavailable — configuration cannot be written');
|
|
113
|
+
}
|
|
114
|
+
// Wire normalization (QC tri M-2): JSON cannot carry undefined, so a
|
|
115
|
+
// null-valued key is a third-party client's way of saying "absent" — the
|
|
116
|
+
// resolver already treats null as missing on read, but the raw user layer
|
|
117
|
+
// must not store it. Drop null values before the write (an all-null patch
|
|
118
|
+
// is a no-op, like the empty patch above).
|
|
119
|
+
const normalized = Object.fromEntries(Object.entries(patch).filter(([, value]) => value !== null));
|
|
120
|
+
if (Object.keys(normalized).length === 0)
|
|
121
|
+
return { config: this.readConfig() };
|
|
122
|
+
await settings.update(ADVISOR_SETTINGS_NAMESPACE, normalized);
|
|
123
|
+
return { config: this.readConfig() };
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Resolve the live composed config through the hard gate. Containment
|
|
127
|
+
* (qc2 W-1): a user layer the resolver rejects (e.g. an unknown key that
|
|
128
|
+
* survived the non-strict settings schema) resolves to disabled-with-reason
|
|
129
|
+
* carrying the message — the gateway never fails the RPC on a bad user
|
|
130
|
+
* layer, and gate semantics hold (no model call can start). S1: when the
|
|
131
|
+
* raw source is still readable, the fallback seeds its scalar latches
|
|
132
|
+
* (systemPrompt / immuneTurns / maxDeltaMessages) instead of hardcoded
|
|
133
|
+
* defaults, so an invalid layer only drops the offending keys.
|
|
134
|
+
*/
|
|
135
|
+
readConfig() {
|
|
136
|
+
let config;
|
|
137
|
+
try {
|
|
138
|
+
config = resolveAdvisorConfig(this.bridge.source());
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
let raw;
|
|
142
|
+
try {
|
|
143
|
+
raw = this.bridge.source();
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
// unreadable source — fall back to the schema defaults below
|
|
147
|
+
}
|
|
148
|
+
config = {
|
|
149
|
+
enabled: false,
|
|
150
|
+
systemPrompt: raw?.systemPrompt ?? '',
|
|
151
|
+
immuneTurns: raw?.immuneTurns ?? 3,
|
|
152
|
+
maxDeltaMessages: raw?.maxDeltaMessages ?? 60,
|
|
153
|
+
disabledReason: error instanceof Error ? error.message : String(error),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
// typertGateway wire boundary: absent keys are omitted, never
|
|
157
|
+
// present-as-undefined (the result validator rejects undefined values).
|
|
158
|
+
const wire = {
|
|
159
|
+
enabled: config.enabled,
|
|
160
|
+
systemPrompt: config.systemPrompt,
|
|
161
|
+
immuneTurns: config.immuneTurns,
|
|
162
|
+
maxDeltaMessages: config.maxDeltaMessages,
|
|
163
|
+
};
|
|
164
|
+
if (config.provider !== undefined)
|
|
165
|
+
wire.provider = config.provider;
|
|
166
|
+
if (config.model !== undefined)
|
|
167
|
+
wire.model = config.model;
|
|
168
|
+
if (config.disabledReason !== undefined)
|
|
169
|
+
wire.disabledReason = config.disabledReason;
|
|
170
|
+
return wire;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* The explicit typert contribution for the `advisor` gateway endpoints —
|
|
175
|
+
* registered via `ctx.typert.register(...)` (see `apply` in `src/index.ts`).
|
|
176
|
+
* The descriptors mirror exactly what the former SRC discovery derived from
|
|
177
|
+
* the `@Remote` markers (`src:advisor#<endpoint>` identity shape, direct
|
|
178
|
+
* receiver, JSON wire params with `src-json` codec), so the host
|
|
179
|
+
* typertGateway claim + dispatch behavior is byte-for-byte the same — the
|
|
180
|
+
* only difference is the registration does not depend on the module-private
|
|
181
|
+
* `remoteMethods` marker table, which a locally-linked plugin can never
|
|
182
|
+
* share with the host installation.
|
|
183
|
+
*/
|
|
184
|
+
export function advisorTypertContribution() {
|
|
185
|
+
return {
|
|
186
|
+
package: 'dsh-advisor',
|
|
187
|
+
face: 'host',
|
|
188
|
+
schemas: [],
|
|
189
|
+
model: { services: [], events: [], objects: [] },
|
|
190
|
+
invocations: [
|
|
191
|
+
{
|
|
192
|
+
id: 'dsh-advisor#advisor/get',
|
|
193
|
+
service: 'advisor',
|
|
194
|
+
namespace: 'advisor',
|
|
195
|
+
method: 'get',
|
|
196
|
+
invocation: { kind: 'direct' },
|
|
197
|
+
parameters: [],
|
|
198
|
+
result: { mode: 'src-json' },
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
id: 'dsh-advisor#advisor/set',
|
|
202
|
+
service: 'advisor',
|
|
203
|
+
namespace: 'advisor',
|
|
204
|
+
method: 'set',
|
|
205
|
+
invocation: { kind: 'direct' },
|
|
206
|
+
parameters: [
|
|
207
|
+
{ name: 'patch', wire: 'patch', source: 'json', codec: { mode: 'src-json' } },
|
|
208
|
+
],
|
|
209
|
+
result: { mode: 'src-json' },
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=gateway.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../src/gateway.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAKH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAA;AAE1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAMlD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,oBAAqB,SAAQ,mBAAmB;IAC1C,MAAM,CAAuB;IAC9C,0EAA0E;IAClE,QAAQ,CAA8B;IAE9C;;;;OAIG;IACH,YAAY,GAAY,EAAE,MAA6B;QACrD,KAAK,CAAC,GAAG,EAAE,SAAS,CAAC,CAAA;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,uEAAuE;QACvE,6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isor" subsystem). Observes the primary transcript, reviews each stepped
|
|
4
|
+
* turn with an explicitly configured model, and injects severity-ranked
|
|
5
|
+
* advice (nit/concern/blocker) without polluting or recursively reviewing
|
|
6
|
+
* itself.
|
|
7
|
+
*
|
|
8
|
+
* T1 scaffold: declares the Cordis plugin entry (`name`/`inject`/`apply`).
|
|
9
|
+
* T2: config contract — the Loader schema (`Config`) plus the explicit
|
|
10
|
+
* provider/model gate via `resolveAdvisorConfig` (spec §5 / S4).
|
|
11
|
+
* T3: session observation — subscribe `session/event`, detect stepped
|
|
12
|
+
* `turn/end` (reason.kind ∈ {completed, 'max-tokens', error}, spec §4), drive
|
|
13
|
+
* a per-session bounded delta renderer, and dispose per-session state on
|
|
14
|
+
* `session/disposed` / `agent/disposed` (KD-5).
|
|
15
|
+
* T4: the per-session advisor runtime — queue each rendered delta, drain
|
|
16
|
+
* asynchronously via `ctx.llm.stream` (system prompt + delta, `purpose` left
|
|
17
|
+
* unset, KD-5), extract `{note, severity}` (KD-2), and apply the failure
|
|
18
|
+
* policy (retry-light → drop, 3-drop backlog flush, quota pause, permanent
|
|
19
|
+
* halt — never park the primary). The emission guard (T5) gates extracted
|
|
20
|
+
* notes before delivery; the delivery router (T6) routes accepted notes into
|
|
21
|
+
* the primary agent (nit → inject, concern/blocker → steer, immuneTurns
|
|
22
|
+
* cooldown, KD-4 agent map). T7: `/advisor` toggle/on/off/status commands
|
|
23
|
+
* (registered through the conditional `ctx.inject(['commands'], ...)` child)
|
|
24
|
+
* drive a per-session override consulted by the runtime gate — the commands
|
|
25
|
+
* start/stop per-session runtimes without touching the persisted config.
|
|
26
|
+
* Settings (plan dsh-advisor-settings-n2): the plugin-row config is the
|
|
27
|
+
* composition base of the `advisor` settings namespace (`src/settings.ts`),
|
|
28
|
+
* read live through the bridge source; committed settings edits re-apply
|
|
29
|
+
* derived state (immuneTurns / maxDeltaMessages / per-session runtimes)
|
|
30
|
+
* without a restart.
|
|
31
|
+
* Config gateway (plan dsh-advisor-settings-gateway-n5): `apply` also
|
|
32
|
+
* registers the host-side `AdvisorConfigGateway` (`src/gateway.ts`) — the
|
|
33
|
+
* `/api/advisor/get` + `/api/advisor/set` endpoints (explicit
|
|
34
|
+
* `ctx.typert.register` contribution — the host typertGateway claims
|
|
35
|
+
* `ctx.typert.local` first, so link-plugin module identity never matters)
|
|
36
|
+
* that make the Settings card truly readable/writable from the web client.
|
|
37
|
+
*
|
|
38
|
+
* @module dsh-advisor
|
|
39
|
+
*/
|
|
40
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
41
|
+
import type { AdvisorConfig } from './config.js';
|
|
42
|
+
export declare const name = "dsh-advisor";
|
|
43
|
+
/** Services the advisor consumes; the row loads once all are available. */
|
|
44
|
+
export declare const inject: string[];
|
|
45
|
+
/** Loader schema (schemastery, strict) — validated by the cordis Loader. */
|
|
46
|
+
export { Config } from './config.js';
|
|
47
|
+
export type { AdvisorConfig, ResolvedAdvisorConfig } from './config.js';
|
|
48
|
+
export declare function apply(ctx: Context, config: AdvisorConfig): void;
|