MCPcopy
hub / github.com/CopilotKit/CopilotKit / FakeAdapter

Class FakeAdapter

packages/bot/src/testing/fake-adapter.ts:65–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65export class FakeAdapter implements PlatformAdapter {
66 platform = "fake";
67 readonly capabilities: SurfaceCapabilities;
68 readonly ackDeadlineMs = 3000;
69
70 /** When true, `start()` rejects (set via constructor `failStart`). */
71 readonly failStart: boolean;
72 /** When true, `registerCommands()` rejects (set via constructor `failRegisterCommands`). */
73 readonly failRegisterCommands: boolean;
74 /** When true, `stop()` rejects (set via constructor `failStop`). */
75 readonly failStop: boolean;
76 /** Set once `start()` has run to completion; lets tests assert a healthy adapter still started. */
77 started = false;
78
79 /**
80 * @param fakeOpts.paneMethods When `false`, the optional
81 * `setSuggestedPrompts`/`setThreadTitle` methods are omitted (and the
82 * matching capability flags cleared) so tests can exercise the
83 * capability-gated `{ ok: false }` path. Defaults to present.
84 * @param fakeOpts.reactions When `false`, `addReaction`/`removeReaction` are
85 * omitted and `supportsReactions` is cleared. Defaults to present.
86 * @param fakeOpts.nativeEphemeral When `true`, `postEphemeral` reports a
87 * native success (`usedFallback: false`) and `supportsEphemeral` is set;
88 * otherwise DM-fallback / `null` semantics apply and `supportsEphemeral`
89 * is `false`.
90 * @param fakeOpts.modals When `false`, `renderModal`/`openModal` are omitted
91 * and `supportsModals` is `false`. Defaults to present.
92 */
93 constructor(
94 fakeOpts: {
95 paneMethods?: boolean;
96 reactions?: boolean;
97 nativeEphemeral?: boolean;
98 modals?: boolean;
99 /** Platform name override (defaults to "fake"); useful when a test needs distinct adapters. */
100 platform?: string;
101 /** When true, `start()` rejects — simulates an adapter that fails to come up. */
102 failStart?: boolean;
103 /** When true, `registerCommands()` rejects — simulates a command-registration failure. */
104 failRegisterCommands?: boolean;
105 /** When true, `stop()` rejects — simulates a shutdown failure. */
106 failStop?: boolean;
107 } = {},
108 ) {
109 if (fakeOpts.platform) this.platform = fakeOpts.platform;
110 this.failStart = fakeOpts.failStart === true;
111 this.failRegisterCommands = fakeOpts.failRegisterCommands === true;
112 this.failStop = fakeOpts.failStop === true;
113 const paneMethods = fakeOpts.paneMethods !== false;
114 this.capabilities = {
115 supportsModals: fakeOpts.modals !== false,
116 supportsTyping: false,
117 supportsReactions: fakeOpts.reactions !== false,
118 supportsStreaming: true,
119 supportsSuggestedPrompts: paneMethods,
120 supportsThreadTitle: paneMethods,
121 supportsEphemeral: fakeOpts.nativeEphemeral === true,
122 };

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…