dsh-connect 0.9.0 → 0.9.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.
Files changed (54) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +119 -18
  3. package/README.zh.md +87 -13
  4. package/client/client.js +18 -15
  5. package/client/client.js.map +2 -2
  6. package/client/settings-client.mjs +22 -13
  7. package/lib/channels/dingtalk/index.d.ts +49 -49
  8. package/lib/channels/dingtalk/index.d.ts.map +1 -1
  9. package/lib/channels/feishu/adapter.d.ts +8 -1
  10. package/lib/channels/feishu/adapter.d.ts.map +1 -1
  11. package/lib/channels/feishu/adapter.js +120 -39
  12. package/lib/channels/feishu/adapter.js.map +1 -1
  13. package/lib/channels/feishu/index.d.ts +27 -27
  14. package/lib/channels/feishu/index.d.ts.map +1 -1
  15. package/lib/channels/telegram/index.d.ts +13 -13
  16. package/lib/channels/telegram/index.d.ts.map +1 -1
  17. package/lib/channels/web/adapter.d.ts +3 -1
  18. package/lib/channels/web/adapter.d.ts.map +1 -1
  19. package/lib/channels/web/adapter.js +3 -1
  20. package/lib/channels/web/adapter.js.map +1 -1
  21. package/lib/channels/web/index.d.ts +5 -5
  22. package/lib/channels/web/index.d.ts.map +1 -1
  23. package/lib/index.d.ts +42 -58
  24. package/lib/index.d.ts.map +1 -1
  25. package/lib/index.js +162 -57
  26. package/lib/index.js.map +1 -1
  27. package/lib/interaction.d.ts +90 -50
  28. package/lib/interaction.d.ts.map +1 -1
  29. package/lib/interaction.js +233 -272
  30. package/lib/interaction.js.map +1 -1
  31. package/lib/retry.d.ts.map +1 -1
  32. package/lib/retry.js +7 -1
  33. package/lib/retry.js.map +1 -1
  34. package/lib/service.d.ts.map +1 -1
  35. package/lib/service.js +0 -2
  36. package/lib/service.js.map +1 -1
  37. package/lib/settings/legacy-import.d.ts +190 -0
  38. package/lib/settings/legacy-import.d.ts.map +1 -0
  39. package/lib/settings/legacy-import.js +373 -0
  40. package/lib/settings/legacy-import.js.map +1 -0
  41. package/lib/settings/namespace.d.ts +204 -116
  42. package/lib/settings/namespace.d.ts.map +1 -1
  43. package/lib/settings/namespace.js +235 -148
  44. package/lib/settings/namespace.js.map +1 -1
  45. package/lib/settings/settings-model.d.ts.map +1 -1
  46. package/lib/settings/settings-model.js +10 -1
  47. package/lib/settings/settings-model.js.map +1 -1
  48. package/lib/settings/settings-service.d.ts +13 -0
  49. package/lib/settings/settings-service.d.ts.map +1 -1
  50. package/lib/settings/settings-service.js +73 -4
  51. package/lib/settings/settings-service.js.map +1 -1
  52. package/lib/types.d.ts +14 -1
  53. package/lib/types.d.ts.map +1 -1
  54. package/package.json +12 -11
package/lib/index.js CHANGED
@@ -16,10 +16,10 @@ import { ConnectService } from "./service.js";
16
16
  import { resolveStateDir } from "./state-dir.js";
17
17
  import { CHANNELS, extractConfigSecrets, injectSecrets, } from "./settings/channels.js";
18
18
  import { ChannelRuntime } from "./settings/channel-runtime.js";
19
- import { installConnectSection } from "./settings/namespace.js";
19
+ import { CONNECT_PRESENTATION, installConnectSection, materializeConfig, paneConfigFields, sectionOf, } from "./settings/namespace.js";
20
+ import { importLegacySection } from "./settings/legacy-import.js";
20
21
  import { installSettingsRpc } from "./settings/settings-rpc.js";
21
22
  import { createSettingsService } from "./settings/settings-service.js";
22
- import { CHANNEL_CONFIG_FIELDS } from "./settings/settings-model.js";
23
23
  import { CHANNEL_SECRET_KEYS, createCredentialStore, } from "./settings/credential-store.js";
24
24
  import { register as feishuRegister, loadCredentials } from "./channels/feishu/index.js";
25
25
  import { register as telegramRegister } from "./channels/telegram/index.js";
@@ -119,6 +119,53 @@ async function migrateConfigSecrets(provider, cfg, enabled) {
119
119
  }
120
120
  await migrateOnboardedSecrets(provider, enabled);
121
121
  }
122
+ /**
123
+ * The profile entry id this instance was loaded from (`connect`).
124
+ *
125
+ * This — not the package name — is what `SettingsForms.replace()` addresses:
126
+ * its own jsdoc calls the first argument "Profile entry id". It comes from the
127
+ * loader entry, which is attached to the fiber at runtime but *typed* only in
128
+ * `cordis-plugin-loader`'s `declare module` augmentation; that package is the
129
+ * host's loader, not a dependency of this plugin, so importing the type is not
130
+ * an option and the narrow cast below is the whole of the compromise. Returns
131
+ * `undefined` outside a loader (`new Context().plugin(...)` in a test), which
132
+ * `installConnectSection` reports and degrades on rather than failing.
133
+ */
134
+ function entryId(ctx) {
135
+ const fiber = ctx.fiber;
136
+ const id = fiber?.entry?.options?.id;
137
+ return typeof id === "string" && id.length > 0 ? id : undefined;
138
+ }
139
+ /**
140
+ * The Harness home as the host resolved it, when it told us.
141
+ *
142
+ * `profileContext.home` is the authoritative answer (it also covers a home
143
+ * configured outside the environment); `undefined` hands the question to
144
+ * `resolveHarnessHome()`, which repeats the `$DSH_HOME` → `~/.dsh` precedence on
145
+ * its own. The pre-0.2 settings document lived in the *home*, not in the
146
+ * profile directory, which is why this is not derived from the state dir.
147
+ */
148
+ function harnessHome(ctx) {
149
+ const profile = ctx.get?.("profileContext");
150
+ return typeof profile?.home === "string" ? profile.home : undefined;
151
+ }
152
+ /**
153
+ * The active profile's patch file — `~/.dsh/profiles/<profile>/cordis.patch.yml`.
154
+ *
155
+ * Same `profileContext` service as above (`profileContext.patchPath`), and the
156
+ * same reason for going through `ctx.get`: the field is the host's, not ours.
157
+ * The one-shot legacy import anchors its marker on this path, because the
158
+ * marker means "this profile entry has already consumed the legacy document" and
159
+ * a profile is the only unit that can move without that staying true.
160
+ */
161
+ function profilePatchPath(ctx) {
162
+ const profile = ctx.get?.("profileContext");
163
+ return typeof profile?.patchPath === "string" ? profile.patchPath : undefined;
164
+ }
165
+ /** One-line error text for a warning line; `String()` for a thrown non-Error. */
166
+ function errorText(error) {
167
+ return error instanceof Error ? error.message : String(error);
168
+ }
122
169
  /** Cordis plugin name used by loader diagnostics. */
123
170
  export const name = "connect";
124
171
  /**
@@ -170,14 +217,16 @@ export const Config = z.object({
170
217
  notifyLevel: z.union([z.const("full"), z.const("important"), z.const("result")]),
171
218
  /** Proactive progress-notice interval ms when a turn stays silent (default: 300000 = 5 min; 0 disables). */
172
219
  progressTimeoutMs: z.number(),
173
- /** Channels to activate; default: all built-in channels. */
174
- channels: z.array(z.union([z.const("feishu"), z.const("telegram"), z.const("dingtalk"), z.const("web")])),
175
- /** Keys applied to every channel that doesn't set its own (e.g. a shared `language`). */
176
- channelDefaults: z.any(),
177
- feishu: z.any(),
178
- telegram: z.any(),
179
- dingtalk: z.any(),
180
- web: z.any(),
220
+ /**
221
+ * Channels to activate, shared `channelDefaults`, and the per-channel options
222
+ * the settings pane edits. Spread from `paneConfigFields()` rather than
223
+ * restated: those are exactly the fields a profile entry is allowed to
224
+ * hot-commit, so declaring them here as `volatile` leaves is what turns a pane
225
+ * save into a live change instead of a remount (see `settings/namespace.ts`).
226
+ * Each channel's `appSecret`/`appId`/`botToken` stays *outside* this set on
227
+ * purpose — a volatile container would copy the secret into the profile.
228
+ */
229
+ ...paneConfigFields(),
181
230
  /** Optional path to persist web-settings edits (non-secret). */
182
231
  settingsStatePath: z.string(),
183
232
  });
@@ -189,9 +238,16 @@ export const Config = z.object({
189
238
  * `apply` (the fiber is still LOADING until this function resolves).
190
239
  */
191
240
  export async function apply(ctx, config = {}) {
192
- // Shallow-clone so we never mutate the caller's config object. Only core
193
- // fields are consumed by ConnectService; the rest are channel/settings.
194
- const cfg = { ...(config ?? {}) };
241
+ // `config` as the loader resolved it. The pane-editable field set is declared
242
+ // `volatile` (see `Config` above), so those fields arrive here as *references*
243
+ // (`{ get() }`) whose value the loader replaces in place, while ordinary
244
+ // fields arrive as plain data. Both are kept: every consumer below works on a
245
+ // materialized plain-data copy (`cfg`, and nothing mutates the caller's
246
+ // object — `materializeConfig` copies as it walks), and the references stay
247
+ // behind in `rawConfig` so a pane save can be read back without re-running
248
+ // `apply`.
249
+ const rawConfig = (config ?? {});
250
+ const cfg = materializeConfig(rawConfig);
195
251
  const connect = new ConnectService(ctx, cfg);
196
252
  // DSH credentials store: report presence + inject secrets into each channel
197
253
  // config so store-backed secrets reach the adapter without the config file
@@ -245,13 +301,35 @@ export async function apply(ctx, config = {}) {
245
301
  getSecrets: credentialStore ? (name) => credentialStore.get(name) : undefined,
246
302
  });
247
303
  await runtime.apply(finalCfg);
248
- // Register the `dsh-connect` namespace so the channel selection and the
249
- // per-channel non-secret options become user-editable and *effective*:
250
- // `installSection` layers the plugin's own config (as `base`) under the
251
- // user's `settings.yaml` section, and every change re-reconciles the running
252
- // adapters through the runtime above. The panel's own RPC
253
- // (`settings/settings-rpc.ts`) is a separate transport onto the same idea and
254
- // is kept for the pane's compatibility path.
304
+ // Web-settings pane state. The pane's store is the profile entry itself (see
305
+ // the namespace block below); this path backs only the *fallback* store, used
306
+ // by a host that has no settings service. (The one-shot legacy import used to
307
+ // record itself here too; it is anchored on the profile entry now, see
308
+ // `profilePatchPath` — this path is user-relocatable and deletable, which made
309
+ // it the wrong place to remember that a migration had run.) Resolved through
310
+ // the shared helper and off the *merged* config, so the state file lands beside
311
+ // `bindings.json` and can't disagree with the stores. This used to read the raw `cfg.stateDir`,
312
+ // which made the path `undefined` for every profile that never set
313
+ // `stateDir` — and an undefined path made the settings service degrade to
314
+ // in-memory, so a pane save silently vanished.
315
+ const settingsStatePath = finalCfg.settingsStatePath
316
+ ?? join(resolveStateDir(finalCfg), "dsh-connect-settings.json");
317
+ // One projection, two triggers. A change reaches the adapters either through
318
+ // a write (the settings pane, or the legacy import) or through the loader
319
+ // committing new values into the volatile references behind `rawConfig`, and
320
+ // both must hand the runtime the *same* shape: `ChannelRuntime` restarts an
321
+ // adapter whose config it reads as different, so a mismatch here would bounce
322
+ // a live channel on every commit.
323
+ const reconcile = () => {
324
+ void runtime.apply(sectionOf(materializeConfig(rawConfig)));
325
+ };
326
+ // Register the `connect` profile entry's pane fields with the host, so the
327
+ // channel selection and the per-channel non-secret options become
328
+ // user-editable and *effective*: the pane writes them onto the entry, the
329
+ // loader commits them into the volatile references `rawConfig` carries, and
330
+ // every change re-reconciles the running adapters through `reconcile`. The
331
+ // panel's own RPC (`settings/settings-rpc.ts`) is a separate transport onto
332
+ // the same service and is kept for the pane's compatibility path.
255
333
  //
256
334
  // Deferred through `inject` for the same reason as the RPC below: `settings`
257
335
  // is a `dsh-base` row loaded after a user plugin's `apply` runs, so a plain
@@ -259,19 +337,53 @@ export async function apply(ctx, config = {}) {
259
337
  // host never provides it the callback never runs and the plugin config
260
338
  // stands on its own — which is exactly what `installConnectSection` falls
261
339
  // back to.
262
- // Set once the namespace is live; read lazily by the settings service below,
263
- // which is built before the deferred install runs.
340
+ //
341
+ // Set once the seam is live; read lazily by the settings service below, which
342
+ // is built before the deferred callback runs.
264
343
  let liveSection;
265
344
  const installNamespace = (scopeCtx) => {
345
+ const settings = scopeCtx.get?.("settings");
346
+ // Suppress the host's automatic Plugins-page form for this entry: this
347
+ // plugin ships its own client pane, and two generated editors of the same
348
+ // fields is how a save silently reverts. `owner` must be *our* fiber — the
349
+ // method's default is the settings service's own fiber, which would attach
350
+ // the policy to the service and leave this entry's page alone.
351
+ if (typeof settings?.configure === "function") {
352
+ try {
353
+ const release = settings.configure(CONNECT_PRESENTATION, ctx.fiber);
354
+ if (typeof release === "function")
355
+ ctx.effect(() => release);
356
+ }
357
+ catch (error) {
358
+ scopeCtx.logger?.warn?.(`connect: could not suppress the automatic settings page (${errorText(error)})`);
359
+ }
360
+ }
266
361
  const installed = installConnectSection({
267
362
  owner: scopeCtx,
268
- settings: scopeCtx.get?.("settings"),
269
- entry: finalCfg,
270
- onChange: (section) => {
271
- void runtime.apply(section);
272
- },
363
+ settings,
364
+ config: rawConfig,
365
+ ns: entryId(ctx),
366
+ onChange: () => reconcile(),
273
367
  });
274
368
  liveSection = installed.handle;
369
+ // One-shot: fold a pre-0.2 `$DSH_HOME/settings.yaml` `dsh-connect:` section
370
+ // into the entry. The host's own legacy import renames that document and
371
+ // then drops this section — it has no entry by that name — so on an
372
+ // upgraded install this is the only remaining copy of the user's pane
373
+ // choices. Nothing happens when there is no such document, and `current` is
374
+ // the section in force, so the write cannot clear a field the legacy
375
+ // document does not mention.
376
+ const handle = installed.handle;
377
+ if (handle !== undefined) {
378
+ void importLegacySection({
379
+ home: harnessHome(scopeCtx),
380
+ write: (section) => handle.write(section),
381
+ current: installed.section,
382
+ statePath: settingsStatePath,
383
+ entryPath: profilePatchPath(scopeCtx),
384
+ logger: scopeCtx.logger,
385
+ });
386
+ }
275
387
  };
276
388
  if (typeof ctx.inject === "function") {
277
389
  ctx.inject(["settings"], installNamespace);
@@ -280,6 +392,11 @@ export async function apply(ctx, config = {}) {
280
392
  // Bare context (unit tests): no inject-scope API, install directly.
281
393
  installNamespace(ctx);
282
394
  }
395
+ // A pane save is not the only writer: editing a running profile's patch (or
396
+ // reloading the plugin entry) commits volatile paths without re-running
397
+ // `apply`. The host announces that here, so the adapters follow the config
398
+ // they were started from.
399
+ ctx.on("loader/volatile-update", () => reconcile());
283
400
  // Expose the web-settings RPC. The host `connection`/`webServer` services are
284
401
  // loaded as base plugins AFTER this user plugin's apply runs, so a plain
285
402
  // optional inject would see `ctx.connection === undefined` and mount nothing
@@ -296,42 +413,30 @@ export async function apply(ctx, config = {}) {
296
413
  // fence.
297
414
  //
298
415
  // Web settings pane state. When the namespace above is live, that registration
299
- // *is* the store: the pane reads and writes `$DSH_HOME/settings.yaml` through
300
- // `liveSection`, a save reconciles the adapters immediately (via the same
301
- // `onChange`) and survives a restart. The JSON file below is then only a
302
- // fallback for a host with no settings service, which is why the service takes
303
- // the handle as a getter rather than a value.
416
+ // *is* the store: the pane reads and writes this plugin's entry in the active
417
+ // profile patch (`cordis.patch.yml`) through `liveSection`, a save reconciles
418
+ // the adapters immediately (via the same `onChange`) and survives a restart.
419
+ // The JSON file below is then only a fallback for a host with no settings
420
+ // service, which is why the service takes the handle as a getter, not a value.
421
+ // Credentials are a second call, and a secret is not config: `onCredentialsSaved`
422
+ // is the reconcile trigger for that plane, since no config write happens.
304
423
  //
305
- // Seeded from the live plugin config so the pane reflects the channels actually
306
- // enabled; only NON-SECRET editable fields per channel (secrets live in the
307
- // credential store, never in either store this file touches). The fallback path
308
- // is defaulted under the state dir so a save persists out of the box.
309
- const settingsSeed = {
310
- channels: finalCfg.channels ?? CHANNELS,
311
- ...(finalCfg.channelDefaults ? { channelDefaults: finalCfg.channelDefaults } : {}),
312
- };
313
- for (const ch of CHANNELS) {
314
- const raw = finalCfg[ch] ?? {};
315
- const nonSecret = {};
316
- for (const field of CHANNEL_CONFIG_FIELDS[ch] ?? []) {
317
- if (raw[field.key] !== undefined)
318
- nonSecret[field.key] = raw[field.key];
319
- }
320
- if (Object.keys(nonSecret).length)
321
- settingsSeed[ch] = nonSecret;
322
- }
323
- // Resolve through the shared helper and off the *merged* config, so the state
324
- // file lands beside `bindings.json` and can't disagree with the stores. This
325
- // used to read the raw `cfg.stateDir`, which made the path `undefined` for
326
- // every profile that never set `stateDir` — and an undefined path made the
327
- // settings service degrade to in-memory, so a pane save silently vanished.
328
- const settingsStatePath = finalCfg.settingsStatePath
329
- ?? join(resolveStateDir(finalCfg), "dsh-connect-settings.json");
424
+ // Seeded from the live plugin config so the pane reflects the channels
425
+ // actually enabled; only NON-SECRET *declared* fields (secrets live in the
426
+ // credential store, never in either store this file touches), which is
427
+ // exactly the projection `sectionOf` performs — the same one the write path
428
+ // applies, so the fallback store cannot drift from the entry.
429
+ const settingsSeed = { ...sectionOf(finalCfg) };
330
430
  const settingsService = createSettingsService({
331
431
  statePath: settingsStatePath,
332
432
  credentialStore,
333
433
  initialConfig: settingsSeed,
334
434
  live: () => liveSection,
435
+ // A rotated secret is inert until the adapters are re-applied, and the
436
+ // namespace's `onChange` only fires for a config write — the pane saves
437
+ // credentials as a second, separate call. Without this the user pastes a
438
+ // new appSecret, is told 「已保存」, and the bot stays broken until restart.
439
+ onCredentialsSaved: () => reconcile(),
335
440
  });
336
441
  if (typeof ctx.inject === "function") {
337
442
  ctx.inject(["connection", "webServer"], (scopeCtx) => {
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":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kB,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE;KACtC,CAAC,CAAC;IACH,IAAI,OAAQ,GAA4B,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QAC9D,GAAe,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE;YAChE,kBAAkB,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,0EAA0E;QAC1E,kBAAkB,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;IACxD,CAAC;AACH,CAAC;AAED,gFAAgF;AAChF,4EAA4E;AAC5E,iFAAiF;AACjF,6EAA6E;AAC7E,8CAA8C;AAC9C,EAAE;AACF,8EAA8E;AAC9E,6EAA6E;AAC7E,gFAAgF;AAChF,4EAA4E;AAC5E,kEAAkE;AAClE,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC"}
@@ -2,26 +2,41 @@
2
2
  * Interactive user-choices and permission approvals bridged into the chat
3
3
  * channel (Feishu first).
4
4
  *
5
- * DSH's host api-proxy owns the single `userQuestions` provider and the
6
- * `approval/request` waterfall, so a channel plugin cannot register a second
7
- * answerer. Instead this bridge acts as an in-process client of the host's
8
- * `ctx.apiProxy`: it subscribes to the same mux stream the Web GUI uses,
9
- * watches for `question/requested` and `approval/requested` frames on
10
- * connect-bound sessions, renders them as chat cards with buttons, and feeds
11
- * the user's answer back through `apiProxy.respond` — the exact same path a
12
- * Web client uses. The Web GUI stays fully functional; whoever answers first
13
- * wins.
5
+ * DSH exposes both as cordis **waterfall** events on the calling agent's scope:
14
6
  *
15
- * Everything is best-effort: when the host api-proxy is absent (e.g. a
16
- * headless host), the bridge is a no-op and the current behavior (question
17
- * pending until a Web client answers) is unchanged.
7
+ * `user-questions/request` — request `{ questions, agent?, signal? }`,
8
+ * result `{ answers: [{ id, selected, custom? }] }`
9
+ * `approval/request` — request `{ agent, toolName, callId?, reason?, signal? }`,
10
+ * result `'allowed-once' | 'rejected' | 'cancelled' | 'unavailable'`
11
+ *
12
+ * A listener that *returns a value* answers the request; calling `next()` hands
13
+ * it to the following listener (the host's Web-GUI forwarder, and ultimately
14
+ * the fail-closed default). So this bridge is a genuine answerer, not a client
15
+ * of something else: it used to subscribe to the host's `apiProxy` mux stream,
16
+ * but no such host service exists, and every question silently fell through —
17
+ * which is why a chat user saw no options at all.
18
+ *
19
+ * Two properties of the dispatch shape the registration:
20
+ *
21
+ * - Listeners are registered with `prepend: true`. The host's api-remotes
22
+ * plugin registers its own forwarder on these events and *parks* the
23
+ * waterfall on it while it waits for a Web client to answer; with no browser
24
+ * tab connected that promise never settles, so a listener registered after it
25
+ * would never run at all. Going first is the only placement that always runs.
26
+ * - The listener is registered on the plugin's own unscoped context, which
27
+ * `scopeTarget` admits to every scoped dispatch. `request.agent.id` is what
28
+ * decides whether one of *our* chats owns the session.
29
+ *
30
+ * Everything stays best-effort: whenever no binding matches, the prompt cannot
31
+ * be delivered, or the request is cancelled, the listener calls `next()` and
32
+ * the host's normal path (Web GUI, then fail-closed) takes over.
18
33
  * @module dsh-connect/interaction
19
34
  */
20
35
  import type { Context } from "@deepseek-ai/cordis";
21
36
  import type { ChannelAdapter } from "./types.js";
22
37
  import type { BindingStore } from "./binding.js";
23
38
  import type { ResolvedConnectConfig } from "./runner.js";
24
- /** One question from a `question/requested` mux frame (loosely typed). */
39
+ /** One question from a `user-questions/request` dispatch. */
25
40
  export interface AskQuestionLike {
26
41
  id: string;
27
42
  question: string;
@@ -33,19 +48,47 @@ export interface AskQuestionLike {
33
48
  }[];
34
49
  multiSelect?: boolean;
35
50
  }
51
+ /** One answer as the host expects it. */
52
+ interface AskAnswerItem {
53
+ id: string;
54
+ selected: string[];
55
+ custom?: string;
56
+ }
57
+ /** An answer for one question, before it is tagged with that question's id. */
58
+ type AskAnswerValue = Omit<AskAnswerItem, "id">;
59
+ /** Result of a `user-questions/request` waterfall. */
60
+ export interface AskAnswer {
61
+ answers: AskAnswerItem[];
62
+ }
63
+ /** Payload of a `user-questions/request` waterfall. */
64
+ export interface AskRequestEvent {
65
+ questions: AskQuestionLike[];
66
+ agent?: {
67
+ id?: string;
68
+ };
69
+ signal?: AbortSignal;
70
+ }
71
+ /** Result of an `approval/request` waterfall. */
72
+ export type ApprovalOutcome = "allowed-once" | "rejected" | "cancelled" | "unavailable";
73
+ /** Payload of an `approval/request` waterfall. */
74
+ export interface ApprovalRequestEvent {
75
+ readonly agent?: {
76
+ id?: string;
77
+ };
78
+ readonly toolName: string;
79
+ readonly callId?: string;
80
+ readonly reason?: string;
81
+ readonly signal?: AbortSignal;
82
+ }
36
83
  /**
37
84
  * Decode a free-text chat reply into the answer for one question. Exact label
38
85
  * match wins; otherwise space/comma separated numbers are mapped onto the
39
86
  * options (multi-select accumulates them); anything else becomes free text.
40
87
  */
41
- export declare function decodeTextAnswer(q: AskQuestionLike, text: string): {
42
- selected: string[];
43
- custom?: string;
44
- };
88
+ export declare function decodeTextAnswer(q: AskQuestionLike, text: string): AskAnswerValue;
45
89
  /**
46
- * Bridge user choices and permission approvals from DSH into the chat channel.
47
- * Subscribes once to the host mux stream; frames for connect-bound sessions are
48
- * rendered as interactive cards and answered via `apiProxy.respond`.
90
+ * Answer the host's user-question and approval waterfalls from the chat
91
+ * channel. Registered once, eagerly, at construction time.
49
92
  */
50
93
  export declare class InteractionBridge {
51
94
  private readonly ctx;
@@ -53,47 +96,44 @@ export declare class InteractionBridge {
53
96
  private readonly bindings;
54
97
  private readonly config;
55
98
  private readonly pending;
56
- private started;
57
- private apiProxy?;
58
- private controller?;
59
99
  constructor(ctx: Context, adapters: ReadonlyMap<string, ChannelAdapter>, bindings: BindingStore, config: ResolvedConnectConfig);
60
- /** Open the mux subscription (idempotent). No-op when the host api-proxy is absent. */
61
- start(): void;
100
+ /** Register one waterfall listener, tolerating a host without the event API. */
101
+ private register;
62
102
  /** Whether a question/approval is waiting on an answer in this chat. */
63
103
  pendingFor(chatKey: string): boolean;
64
104
  /** Deliver a plain-text chat reply as the answer to the pending question. */
65
105
  answerText(chatKey: string, text: string): boolean;
66
- private run;
67
- private onFrame;
68
- /** Every connect-bound chat that currently uses this session (active or mirrored). */
69
- private targetsFor;
70
- private presentQuestion;
71
- private presentApproval;
72
- /** Advance to the next unanswered question, or settle once all are answered. */
73
- private stepQuestion;
74
- private presentQuestionButtons;
75
- private presentQuestionText;
76
- private presentApprovalLoop;
106
+ private answerQuestion;
107
+ /** Ask every question in turn. `undefined` = the flow was interrupted. */
108
+ private runQuestions;
109
+ private askOne;
110
+ /** Options-free question: the user answers by sending an ordinary message. */
111
+ private askByText;
77
112
  /**
78
- * Keep one interactive card alive until the user answers (or the ask is
79
- * cancelled). The channel's choice prompt expires after its own idle
80
- * timeout; on expiry the same card is re-presented in place so the choice
81
- * stays clickable for as long as the agent waits. Resolves `"answered"`
82
- * when `onChoice` accepted a choice, `"stopped"` otherwise.
83
- *
84
- * `onChoice` may be async and receives the card's message id (for feedback
85
- * such as updating the card once the decision is delivered). A thrown
86
- * `onChoice` error resolves the loop as `"stopped"` (best-effort channel).
113
+ * Wait until an answer is recorded, the flow stops, or `timeoutMs` elapses.
114
+ * Resolves (never rejects) and always removes its own listener and timer.
87
115
  */
88
- private presentLoop;
116
+ private waitForAnswer;
89
117
  private questionPromptText;
90
118
  private recordAnswer;
91
- /** All questions answered — deliver the answers through the host respond path. */
92
- private settleQuestion;
93
- private respond;
94
- /** Stop presenting and drop the interaction (answered, cancelled, or the turn ended). */
119
+ private answerApproval;
120
+ /**
121
+ * Pick the one chat that owns `sessionId` and can actually present a prompt.
122
+ *
123
+ * Only the first match is claimed: two cards for one question would leave the
124
+ * second one unanswerable (the answer is delivered to the agent, not to a
125
+ * specific card), and the Web GUI would render a duplicate.
126
+ *
127
+ * The `web` channel is a GUI mirror whose outbound face is a no-op by design
128
+ * — it can neither show a card nor report a tap, so claiming it would spin
129
+ * the re-present loop forever. Declining it leaves the request to the host's
130
+ * own forwarder, which is precisely the Web GUI.
131
+ */
132
+ private claimTarget;
133
+ /** Stop presenting and drop the interaction (answered, cancelled, or torn down). */
95
134
  private settle;
96
135
  private outbound;
97
136
  private log;
98
137
  }
138
+ export {};
99
139
  //# sourceMappingURL=interaction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interaction.d.ts","sourceRoot":"","sources":["../src/interaction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAA8C,MAAM,YAAY,CAAC;AAC7F,OAAO,KAAK,EAAE,YAAY,EAAe,MAAM,cAAc,CAAC;AAE9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEzD,0EAA0E;AAC1E,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACpD,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AA2CD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAiB1G;AAYD;;;;GAIG;AACH,qBAAa,iBAAiB;IAO1B,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ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