@frontmcp/sdk 1.13.0-rc.2 → 1.13.1

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.
@@ -16,7 +16,7 @@ async function delivered(answer, schema) {
16
16
  return { status: "accept", content: parsed.data };
17
17
  }
18
18
  async function askPersistentQuestion(deps, message, schema, options) {
19
- const { store, subject, signal } = deps;
19
+ const { store, subject, signal, sessionEnded } = deps;
20
20
  const request = {
21
21
  subject,
22
22
  key: options.key,
@@ -32,7 +32,8 @@ async function askPersistentQuestion(deps, message, schema, options) {
32
32
  };
33
33
  if (signal?.aborted) throw await putBack();
34
34
  const result = await delivered(taken.answer, schema);
35
- if (signal?.aborted) throw await putBack();
35
+ const ended = await sessionEnded?.();
36
+ if (ended || signal?.aborted) throw await putBack();
36
37
  return result;
37
38
  };
38
39
  const asked = await store.ask(request);
@@ -118,11 +119,13 @@ async function elicitPersistent(deps, message, requestedSchema, options) {
118
119
  );
119
120
  }
120
121
  const zodSchema = requestedSchema instanceof z.ZodType ? requestedSchema : z.object(requestedSchema);
121
- return askPersistentQuestion({ store: questions.store, subject, signal: deps.signal }, message, zodSchema, {
122
- key: persist.key,
123
- ttlMs,
124
- waitMs
125
- });
122
+ const sessionEnded = deps.sessionId ? questions.sessionEndCheck?.(deps.sessionId) : void 0;
123
+ return askPersistentQuestion(
124
+ { store: questions.store, subject, signal: deps.signal, sessionEnded },
125
+ message,
126
+ zodSchema,
127
+ { key: persist.key, ttlMs, waitMs }
128
+ );
126
129
  }
127
130
  export {
128
131
  askPersistentQuestion,
package/browser/index.cjs CHANGED
@@ -15560,7 +15560,7 @@ async function delivered(answer, schema) {
15560
15560
  return { status: "accept", content: parsed.data };
15561
15561
  }
15562
15562
  async function askPersistentQuestion(deps, message, schema, options) {
15563
- const { store, subject, signal } = deps;
15563
+ const { store, subject, signal, sessionEnded } = deps;
15564
15564
  const request = {
15565
15565
  subject,
15566
15566
  key: options.key,
@@ -15576,7 +15576,8 @@ async function askPersistentQuestion(deps, message, schema, options) {
15576
15576
  };
15577
15577
  if (signal?.aborted) throw await putBack();
15578
15578
  const result = await delivered(taken.answer, schema);
15579
- if (signal?.aborted) throw await putBack();
15579
+ const ended = await sessionEnded?.();
15580
+ if (ended || signal?.aborted) throw await putBack();
15580
15581
  return result;
15581
15582
  };
15582
15583
  const asked = await store.ask(request);
@@ -15662,11 +15663,13 @@ async function elicitPersistent(deps, message, requestedSchema, options) {
15662
15663
  );
15663
15664
  }
15664
15665
  const zodSchema = requestedSchema instanceof import_lazy_zod58.internalZ.ZodType ? requestedSchema : import_lazy_zod58.internalZ.object(requestedSchema);
15665
- return askPersistentQuestion({ store: questions.store, subject, signal: deps.signal }, message, zodSchema, {
15666
- key: persist.key,
15667
- ttlMs,
15668
- waitMs
15669
- });
15666
+ const sessionEnded = deps.sessionId ? questions.sessionEndCheck?.(deps.sessionId) : void 0;
15667
+ return askPersistentQuestion(
15668
+ { store: questions.store, subject, signal: deps.signal, sessionEnded },
15669
+ message,
15670
+ zodSchema,
15671
+ { key: persist.key, ttlMs, waitMs }
15672
+ );
15670
15673
  }
15671
15674
  var import_lazy_zod58, import_utils45, RECHECK_MS, MAX_QUESTION_KEY_LENGTH;
15672
15675
  var init_ask_question = __esm({
@@ -65691,6 +65694,8 @@ var init_transport_registry = __esm({
65691
65694
  sessionCheckTimeoutMs;
65692
65695
  /** Session-store reads of the per-request check that have not settled yet, by read and session. */
65693
65696
  pendingSessionChecks = /* @__PURE__ */ new Map();
65697
+ /** Sessions whose handover read timed out and has not settled yet. */
65698
+ silentHandoverReads = /* @__PURE__ */ new Set();
65694
65699
  /**
65695
65700
  * Redis key prefix under which session records are stored.
65696
65701
  * The session store appends `session:` to the transport key prefix.
@@ -66075,6 +66080,26 @@ var init_transport_registry = __esm({
66075
66080
  await this.destroyLocalSession(sessionId, "the session was deleted");
66076
66081
  return false;
66077
66082
  }
66083
+ /** A check, outside distributed mode, of whether a session held here was deleted through another instance. */
66084
+ sessionEndCheck(sessionId) {
66085
+ const store = this.sessionStore;
66086
+ if (this.distributed || !store || !this.storedLocalSessions.has(sessionId)) return void 0;
66087
+ return () => {
66088
+ if (this.silentHandoverReads.has(sessionId)) return Promise.resolve(false);
66089
+ const read = store.exists(sessionId);
66090
+ return this.raceSessionCheckTimeout(read).then(
66091
+ (stored) => !stored,
66092
+ () => {
66093
+ this.silentHandoverReads.add(sessionId);
66094
+ read.then(
66095
+ () => this.silentHandoverReads.delete(sessionId),
66096
+ () => this.silentHandoverReads.delete(sessionId)
66097
+ );
66098
+ return false;
66099
+ }
66100
+ );
66101
+ };
66102
+ }
66078
66103
  /**
66079
66104
  * Bound a session-store read made while serving a session held in memory. A store that accepts the
66080
66105
  * connection but never answers (a paused Redis, a partition that does not reset TCP) would otherwise
@@ -66090,6 +66115,9 @@ var init_transport_registry = __esm({
66090
66115
  read = issueRead().finally(() => this.pendingSessionChecks.delete(key));
66091
66116
  this.pendingSessionChecks.set(key, read);
66092
66117
  }
66118
+ return this.raceSessionCheckTimeout(read);
66119
+ }
66120
+ raceSessionCheckTimeout(read) {
66093
66121
  const timeoutMs = this.sessionCheckTimeoutMs;
66094
66122
  let timer;
66095
66123
  const timedOut = new Promise((_resolve, reject) => {
@@ -67516,7 +67544,7 @@ var init_ha = __esm({
67516
67544
  });
67517
67545
 
67518
67546
  // libs/sdk/src/transport/bus/redis-transport-bus.ts
67519
- var DEFAULT_BUS_PREFIX, DEFAULT_BUS_TTL_SECONDS, DEFAULT_RETRY_AFTER_SECONDS, ADVERTISE_LUA, REVOKE_LUA, RedisTransportBus;
67547
+ var DEFAULT_BUS_PREFIX, DEFAULT_BUS_TTL_SECONDS, DEFAULT_RETRY_AFTER_SECONDS, RELEASE_TIMEOUT_MS, RELEASE_POLL_MS, ADVERTISE_LUA, REVOKE_LUA, RedisTransportBus;
67520
67548
  var init_redis_transport_bus = __esm({
67521
67549
  "libs/sdk/src/transport/bus/redis-transport-bus.ts"() {
67522
67550
  "use strict";
@@ -67525,6 +67553,8 @@ var init_redis_transport_bus = __esm({
67525
67553
  DEFAULT_BUS_PREFIX = "mcp:bus:";
67526
67554
  DEFAULT_BUS_TTL_SECONDS = 3600;
67527
67555
  DEFAULT_RETRY_AFTER_SECONDS = 30;
67556
+ RELEASE_TIMEOUT_MS = 5e3;
67557
+ RELEASE_POLL_MS = 25;
67528
67558
  ADVERTISE_LUA = `
67529
67559
  redis.call('HSET', KEYS[1], 'nodeId', ARGV[1], 'channel', ARGV[2], 'type', ARGV[3], 'tokenHash', ARGV[4])
67530
67560
  redis.call('EXPIRE', KEYS[1], ARGV[5])
@@ -67642,9 +67672,7 @@ return 0
67642
67672
  }
67643
67673
  await this.relay.forward(location.nodeId, sessionId, serializeRelayRequest(request), response);
67644
67674
  }
67645
- /**
67646
- * Destroy a session on a remote node via pub/sub relay.
67647
- */
67675
+ /** Destroy a session on the node that owns it, and wait (bounded) until that node has released it. */
67648
67676
  async destroyRemote(key, reason) {
67649
67677
  const entry = await this.readEntry(key.sessionId);
67650
67678
  if (!entry || entry.nodeId === this.machineId) return;
@@ -67655,11 +67683,34 @@ return 0
67655
67683
  sourceNodeId: this.machineId,
67656
67684
  timestamp: Date.now()
67657
67685
  });
67658
- await this.redis.publish(entry.channel, message);
67686
+ const receivers = await this.redis.publish(entry.channel, message);
67659
67687
  this.logger?.info("[TransportBus] Sent destroy-remote", {
67660
67688
  sessionId: key.sessionId.slice(0, 20),
67661
67689
  targetNodeId: entry.nodeId
67662
67690
  });
67691
+ if (receivers > 0) await this.untilReleased(key.sessionId, entry.nodeId);
67692
+ }
67693
+ /** The owner revokes a session's entry only after it closed the session's transport, which ends its calls. */
67694
+ async untilReleased(sessionId, ownerNodeId) {
67695
+ let polling = true;
67696
+ let timer;
67697
+ const released = (async () => {
67698
+ while (polling) {
67699
+ await new Promise((resolve) => setTimeout(resolve, RELEASE_POLL_MS));
67700
+ if ((await this.readEntry(sessionId))?.nodeId !== ownerNodeId) return true;
67701
+ }
67702
+ return false;
67703
+ })();
67704
+ const timedOut = new Promise((resolve) => timer = setTimeout(() => resolve(false), RELEASE_TIMEOUT_MS));
67705
+ const releasedInTime = await Promise.race([released, timedOut]).finally(() => {
67706
+ polling = false;
67707
+ clearTimeout(timer);
67708
+ });
67709
+ if (releasedInTime) return;
67710
+ this.logger?.warn("[TransportBus] The session owner did not release the session in time", {
67711
+ sessionId: sessionId.slice(0, 20),
67712
+ ownerNodeId
67713
+ });
67663
67714
  }
67664
67715
  async readEntry(sessionId) {
67665
67716
  const fields = await this.redis.hgetall(this.busKey(sessionId));
@@ -87158,8 +87209,13 @@ var init_scope_instance = __esm({
87158
87209
  onEdgeRuntime: onEdgeRuntime2,
87159
87210
  logger: this.logger
87160
87211
  });
87161
- this._persistentQuestions = questions;
87162
- if (questions) this.onDispose(() => questions.store.close());
87212
+ if (questions) {
87213
+ this._persistentQuestions = {
87214
+ ...questions,
87215
+ sessionEndCheck: (sessionId) => this.transportService?.sessionEndCheck(sessionId)
87216
+ };
87217
+ this.onDispose(() => questions.store.close());
87218
+ }
87163
87219
  }
87164
87220
  })() : void 0;
87165
87221
  const tasksConfig = this.metadata.tasks;
@@ -367,8 +367,13 @@ var Scope = class _Scope extends ScopeEntry {
367
367
  onEdgeRuntime: onEdgeRuntime2,
368
368
  logger: this.logger
369
369
  });
370
- this._persistentQuestions = questions;
371
- if (questions) this.onDispose(() => questions.store.close());
370
+ if (questions) {
371
+ this._persistentQuestions = {
372
+ ...questions,
373
+ sessionEndCheck: (sessionId) => this.transportService?.sessionEndCheck(sessionId)
374
+ };
375
+ this.onDispose(() => questions.store.close());
376
+ }
372
377
  }
373
378
  })() : void 0;
374
379
  const tasksConfig = this.metadata.tasks;
@@ -4,6 +4,8 @@ import { isRelayedRequest, serializeRelayRequest } from "../relay/relay-http.mjs
4
4
  var DEFAULT_BUS_PREFIX = "mcp:bus:";
5
5
  var DEFAULT_BUS_TTL_SECONDS = 3600;
6
6
  var DEFAULT_RETRY_AFTER_SECONDS = 30;
7
+ var RELEASE_TIMEOUT_MS = 5e3;
8
+ var RELEASE_POLL_MS = 25;
7
9
  var ADVERTISE_LUA = `
8
10
  redis.call('HSET', KEYS[1], 'nodeId', ARGV[1], 'channel', ARGV[2], 'type', ARGV[3], 'tokenHash', ARGV[4])
9
11
  redis.call('EXPIRE', KEYS[1], ARGV[5])
@@ -121,9 +123,7 @@ var RedisTransportBus = class {
121
123
  }
122
124
  await this.relay.forward(location.nodeId, sessionId, serializeRelayRequest(request), response);
123
125
  }
124
- /**
125
- * Destroy a session on a remote node via pub/sub relay.
126
- */
126
+ /** Destroy a session on the node that owns it, and wait (bounded) until that node has released it. */
127
127
  async destroyRemote(key, reason) {
128
128
  const entry = await this.readEntry(key.sessionId);
129
129
  if (!entry || entry.nodeId === this.machineId) return;
@@ -134,11 +134,34 @@ var RedisTransportBus = class {
134
134
  sourceNodeId: this.machineId,
135
135
  timestamp: Date.now()
136
136
  });
137
- await this.redis.publish(entry.channel, message);
137
+ const receivers = await this.redis.publish(entry.channel, message);
138
138
  this.logger?.info("[TransportBus] Sent destroy-remote", {
139
139
  sessionId: key.sessionId.slice(0, 20),
140
140
  targetNodeId: entry.nodeId
141
141
  });
142
+ if (receivers > 0) await this.untilReleased(key.sessionId, entry.nodeId);
143
+ }
144
+ /** The owner revokes a session's entry only after it closed the session's transport, which ends its calls. */
145
+ async untilReleased(sessionId, ownerNodeId) {
146
+ let polling = true;
147
+ let timer;
148
+ const released = (async () => {
149
+ while (polling) {
150
+ await new Promise((resolve) => setTimeout(resolve, RELEASE_POLL_MS));
151
+ if ((await this.readEntry(sessionId))?.nodeId !== ownerNodeId) return true;
152
+ }
153
+ return false;
154
+ })();
155
+ const timedOut = new Promise((resolve) => timer = setTimeout(() => resolve(false), RELEASE_TIMEOUT_MS));
156
+ const releasedInTime = await Promise.race([released, timedOut]).finally(() => {
157
+ polling = false;
158
+ clearTimeout(timer);
159
+ });
160
+ if (releasedInTime) return;
161
+ this.logger?.warn("[TransportBus] The session owner did not release the session in time", {
162
+ sessionId: sessionId.slice(0, 20),
163
+ ownerNodeId
164
+ });
142
165
  }
143
166
  async readEntry(sessionId) {
144
167
  const fields = await this.redis.hgetall(this.busKey(sessionId));
@@ -116,6 +116,8 @@ var TransportService = class {
116
116
  sessionCheckTimeoutMs;
117
117
  /** Session-store reads of the per-request check that have not settled yet, by read and session. */
118
118
  pendingSessionChecks = /* @__PURE__ */ new Map();
119
+ /** Sessions whose handover read timed out and has not settled yet. */
120
+ silentHandoverReads = /* @__PURE__ */ new Set();
119
121
  /**
120
122
  * Redis key prefix under which session records are stored.
121
123
  * The session store appends `session:` to the transport key prefix.
@@ -500,6 +502,26 @@ var TransportService = class {
500
502
  await this.destroyLocalSession(sessionId, "the session was deleted");
501
503
  return false;
502
504
  }
505
+ /** A check, outside distributed mode, of whether a session held here was deleted through another instance. */
506
+ sessionEndCheck(sessionId) {
507
+ const store = this.sessionStore;
508
+ if (this.distributed || !store || !this.storedLocalSessions.has(sessionId)) return void 0;
509
+ return () => {
510
+ if (this.silentHandoverReads.has(sessionId)) return Promise.resolve(false);
511
+ const read = store.exists(sessionId);
512
+ return this.raceSessionCheckTimeout(read).then(
513
+ (stored) => !stored,
514
+ () => {
515
+ this.silentHandoverReads.add(sessionId);
516
+ read.then(
517
+ () => this.silentHandoverReads.delete(sessionId),
518
+ () => this.silentHandoverReads.delete(sessionId)
519
+ );
520
+ return false;
521
+ }
522
+ );
523
+ };
524
+ }
503
525
  /**
504
526
  * Bound a session-store read made while serving a session held in memory. A store that accepts the
505
527
  * connection but never answers (a paused Redis, a partition that does not reset TCP) would otherwise
@@ -515,6 +537,9 @@ var TransportService = class {
515
537
  read = issueRead().finally(() => this.pendingSessionChecks.delete(key));
516
538
  this.pendingSessionChecks.set(key, read);
517
539
  }
540
+ return this.raceSessionCheckTimeout(read);
541
+ }
542
+ raceSessionCheckTimeout(read) {
518
543
  const timeoutMs = this.sessionCheckTimeoutMs;
519
544
  let timer;
520
545
  const timedOut = new Promise((_resolve, reject) => {
@@ -10,7 +10,7 @@ import { type ZodType } from '@frontmcp/lazy-zod';
10
10
  import { type FrontMcpContext } from '../../context';
11
11
  import { type ClientCapabilities } from '../../notification';
12
12
  import { type ElicitOptions, type ElicitResult } from '../elicitation.types';
13
- import { type QuestionStore } from '../questions/question.store';
13
+ import { type PersistentQuestions } from '../questions/question-scope.helper';
14
14
  /**
15
15
  * Transport interface for elicitation.
16
16
  * Matches the shape exposed by FrontMcpContext.
@@ -39,10 +39,7 @@ export interface ElicitHelperDeps {
39
39
  */
40
40
  elicitationEnabled?: boolean;
41
41
  /** The scope's persistent questions (`elicitation.persistent`), with their default TTL. */
42
- questions?: {
43
- store: QuestionStore;
44
- ttlMs: number;
45
- };
42
+ questions?: Pick<PersistentQuestions, 'store' | 'ttlMs' | 'sessionEndCheck'>;
46
43
  /** Aborts when the call stops; a persistent question then stops waiting. */
47
44
  signal?: AbortSignal;
48
45
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"elicit.helper.d.ts","sourceRoot":"","sources":["../../../src/elicitation/helpers/elicit.helper.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAgC,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGhF,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAOrD,OAAO,EAAuB,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAsB,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACjG,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAGjE;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,CAAC,SAAS,OAAO,EACtB,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,CAAC,EAClB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,YAAY,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,C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,CAAC,EAClB,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,YAAY,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAoGjE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C"}
@@ -7,6 +7,8 @@ export interface PersistentAskDeps {
7
7
  subject: string;
8
8
  /** Aborted when the call stops: the question stays for the next call. */
9
9
  signal?: AbortSignal;
10
+ /** Whether the call's session has ended where no abort reaches it: the answer then stays for the next call. */
11
+ sessionEnded?: () => Promise<boolean>;
10
12
  }
11
13
  export interface PersistentAskOptions {
12
14
  key: string;
@@ -23,7 +25,7 @@ export interface PersistentAskOptions {
23
25
  */
24
26
  export declare function askPersistentQuestion<S extends ZodType>(deps: PersistentAskDeps, message: string, schema: S, options: PersistentAskOptions): Promise<ElicitResult<S extends ZodType<infer O> ? O : unknown>>;
25
27
  /** `this.elicit(message, schema, { persist })`: checks the call, then asks for the caller the request names. */
26
- export declare function elicitPersistent<S extends ZodType>(deps: Pick<ElicitHelperDeps, 'questions' | 'signal' | 'tryGetContext'>, message: string, requestedSchema: S, options: ElicitOptions & {
28
+ export declare function elicitPersistent<S extends ZodType>(deps: Pick<ElicitHelperDeps, 'questions' | 'signal' | 'tryGetContext' | 'sessionId'>, message: string, requestedSchema: S, options: ElicitOptions & {
27
29
  persist: PersistOptions;
28
30
  }): Promise<ElicitResult<S extends ZodType<infer O> ? O : unknown>>;
29
31
  //# sourceMappingURL=ask-question.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ask-question.d.ts","sourceRoot":"","sources":["../../../src/elicitation/questions/ask-question.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAIhF,OAAO,EAAsB,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtH,O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+29,8 @@ export interface PersistentQuestions {
29
29
  ttlMs: number;
30
30
  type: QuestionStoreResult['type'];
31
31
  inboxLinks: InboxLinks;
32
+ /** For a session held here, a check of whether it has since been ended through another instance. */
33
+ sessionEndCheck?: (sessionId: string) => (() => Promise<boolean>) | undefined;
32
34
  }
33
35
  /** Open the store `elicitation.persistent` asks for, keyed apart from other servers on it; undefined while it is off. */
34
36
  export declare function openPersistentQuestions(options: {
@@ -1 +1 @@
1
- {"version":3,"file":"question-scope.helper.d.ts","sourceRoot":"","sources":["../../../src/elicitation/questions/question-scope.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EACL,KAAK,UAAU,EACf,KAAK,mCAAmC,EACxC,KAAK,0BAA0B,EAChC,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAA+C,KAAK,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEjH,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,wBAAwB;AACxB,eAAO,MAAM,uBAAuB,WAAa,CAAC;AA4BlD,2FAA2F;AAC3F,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,OAAO,GAAG,mCAAmC,CAMxG;AAYD;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,OAAO,EACnB,aAAa,EAAE,OAAO,GACrB,mCAAmC,CAKrC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,0BAA0B,GAAG,SAAS,EAC/C,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;CAAE,GAC/E,MAAM,GAAG,SAAS,CAMpB;AAED,qGAAqG;AACrG,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,aAAa,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAClC,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,yHAAyH;AACzH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE;IACrD,UAAU,EAAE,OAAO,CAAC;IACpB,8FAA8F;IAC9F,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,qFAAqF;IACrF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,EAAE,cAAc,CAAC;CACxB,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAkB3C"}
1
+ {"version":3,"file":"question-scope.helper.d.ts","sourceRoot":"","sources":["../../../src/elicitation/questions/question-scope.helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EACL,KAAK,UAAU,EACf,KAAK,mCAAmC,EACxC,KAAK,0BAA0B,EAChC,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAA+C,KAAK,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEjH,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,wBAAwB;AACxB,eAAO,MAAM,uBAAuB,WAAa,CAAC;AA4BlD,2FAA2F;AAC3F,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,OAAO,GAAG,mCAAmC,CAMxG;AAYD;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,OAAO,EACnB,aAAa,EAAE,OAAO,GACrB,mCAAmC,CAKrC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB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