@copilotkit/react-core 2.0.0-rc.14 → 2.0.0-rc.16
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/dist/{MarkdownSurfaces-EGmsCZWN.cjs → MarkdownSurfaces-ChOKawIN.cjs} +52 -43
- package/dist/MarkdownSurfaces-ChOKawIN.cjs.map +1 -0
- package/dist/{MarkdownSurfaces-DKC9Eg_a.mjs → MarkdownSurfaces-DAEqIF5v.mjs} +52 -43
- package/dist/MarkdownSurfaces-DAEqIF5v.mjs.map +1 -0
- package/dist/context.cjs +6 -6
- package/dist/context.cjs.map +1 -1
- package/dist/context.mjs +6 -6
- package/dist/context.mjs.map +1 -1
- package/dist/generative-ui.cjs +6 -4
- package/dist/generative-ui.cjs.map +1 -1
- package/dist/generative-ui.mjs +6 -4
- package/dist/generative-ui.mjs.map +1 -1
- package/dist/headless.cjs +2 -2
- package/dist/headless.cjs.map +1 -1
- package/dist/headless.mjs +2 -2
- package/dist/headless.mjs.map +1 -1
- package/dist/index.cjs +98 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +23 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +98 -40
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +167 -65
- package/dist/index.umd.js.map +1 -1
- package/package.json +9 -9
- package/dist/MarkdownSurfaces-DKC9Eg_a.mjs.map +0 -1
- package/dist/MarkdownSurfaces-EGmsCZWN.cjs.map +0 -1
package/dist/index.umd.js
CHANGED
|
@@ -158,6 +158,48 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
158
158
|
});
|
|
159
159
|
});
|
|
160
160
|
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region \0@oxc-project+runtime@0.112.0/helpers/typeof.js
|
|
163
|
+
function _typeof(o) {
|
|
164
|
+
"@babel/helpers - typeof";
|
|
165
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
166
|
+
return typeof o;
|
|
167
|
+
} : function(o) {
|
|
168
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
169
|
+
}, _typeof(o);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
//#endregion
|
|
173
|
+
//#region \0@oxc-project+runtime@0.112.0/helpers/toPrimitive.js
|
|
174
|
+
function toPrimitive(t, r) {
|
|
175
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
176
|
+
var e = t[Symbol.toPrimitive];
|
|
177
|
+
if (void 0 !== e) {
|
|
178
|
+
var i = e.call(t, r || "default");
|
|
179
|
+
if ("object" != _typeof(i)) return i;
|
|
180
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
181
|
+
}
|
|
182
|
+
return ("string" === r ? String : Number)(t);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region \0@oxc-project+runtime@0.112.0/helpers/toPropertyKey.js
|
|
187
|
+
function toPropertyKey(t) {
|
|
188
|
+
var i = toPrimitive(t, "string");
|
|
189
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region \0@oxc-project+runtime@0.112.0/helpers/defineProperty.js
|
|
194
|
+
function _defineProperty(e, r, t) {
|
|
195
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
196
|
+
value: t,
|
|
197
|
+
enumerable: !0,
|
|
198
|
+
configurable: !0,
|
|
199
|
+
writable: !0
|
|
200
|
+
}) : e[r] = t, e;
|
|
201
|
+
}
|
|
202
|
+
|
|
161
203
|
//#endregion
|
|
162
204
|
//#region src/lib/react-core.ts
|
|
163
205
|
/**
|
|
@@ -182,12 +224,12 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
182
224
|
...config,
|
|
183
225
|
ɵwaitForFrameworkUpdates: waitForReactCommit
|
|
184
226
|
});
|
|
185
|
-
this
|
|
186
|
-
this
|
|
187
|
-
this
|
|
188
|
-
this
|
|
189
|
-
this
|
|
190
|
-
this
|
|
227
|
+
_defineProperty(this, "_renderToolCalls", []);
|
|
228
|
+
_defineProperty(this, "_hookRenderToolCalls", /* @__PURE__ */ new Map());
|
|
229
|
+
_defineProperty(this, "_cachedMergedRenderToolCalls", null);
|
|
230
|
+
_defineProperty(this, "_renderCustomMessages", []);
|
|
231
|
+
_defineProperty(this, "_renderActivityMessages", []);
|
|
232
|
+
_defineProperty(this, "_interruptElement", null);
|
|
191
233
|
this._renderToolCalls = config.renderToolCalls ?? [];
|
|
192
234
|
this._renderCustomMessages = config.renderCustomMessages ?? [];
|
|
193
235
|
this._renderActivityMessages = config.renderActivityMessages ?? [];
|
|
@@ -1882,7 +1924,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
1882
1924
|
|
|
1883
1925
|
//#endregion
|
|
1884
1926
|
//#region package.json
|
|
1885
|
-
var version$1 = "2.0.0-rc.
|
|
1927
|
+
var version$1 = "2.0.0-rc.16";
|
|
1886
1928
|
|
|
1887
1929
|
//#endregion
|
|
1888
1930
|
//#region src/components/CopilotKitInspector.tsx
|
|
@@ -3502,7 +3544,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
3502
3544
|
* includeCatalog: true,
|
|
3503
3545
|
* contextSent: false,
|
|
3504
3546
|
* });
|
|
3505
|
-
* envelope["
|
|
3547
|
+
* envelope["1.0"].supportedCatalogIds; // [runtime.ui.id]
|
|
3506
3548
|
* ```
|
|
3507
3549
|
*/
|
|
3508
3550
|
function buildGenerativeUIEnvelope(runtime, threadId, options) {
|
|
@@ -3511,7 +3553,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
3511
3553
|
const instructions = options.instructions ?? (transport === "markdown" ? (0, _copilotkit_shared.buildGenerativeUIMarkdownGuidelines)((0, _copilotkit_shared.generativeUIGuideFeatures)(manifest)) : void 0);
|
|
3512
3554
|
const omitComponents = transport === "markdown" && !includeCatalog;
|
|
3513
3555
|
return {
|
|
3514
|
-
"
|
|
3556
|
+
"1.0": {
|
|
3515
3557
|
supportedCatalogIds: manifest.catalogIds ?? [manifest.catalogId],
|
|
3516
3558
|
inlineCatalogs: [{
|
|
3517
3559
|
catalogId: manifest.catalogId,
|
|
@@ -3654,6 +3696,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
3654
3696
|
var GenerativeUIError = class extends Error {
|
|
3655
3697
|
constructor(code, message) {
|
|
3656
3698
|
super(message);
|
|
3699
|
+
_defineProperty(this, "code", void 0);
|
|
3657
3700
|
this.name = "GenerativeUIError";
|
|
3658
3701
|
this.code = code;
|
|
3659
3702
|
}
|
|
@@ -3990,13 +4033,16 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
3990
4033
|
* gesture runs only from an event binding.
|
|
3991
4034
|
*/
|
|
3992
4035
|
const invokeBasic = (name, args, origin) => {
|
|
3993
|
-
const
|
|
4036
|
+
const info = _copilotkit_shared.GENERATIVE_UI_FUNCTIONS[name];
|
|
4037
|
+
const run = BASIC_FUNCTIONS[name];
|
|
4038
|
+
if (info === void 0 || run === void 0) throw new Error(`"${name}" is not a basic function`);
|
|
4039
|
+
const refused = callerError(name, info, origin);
|
|
3994
4040
|
if (refused) return failWith(name, origin, refused);
|
|
3995
4041
|
if (args !== void 0 && !(typeof args === "object" && args !== null && !Array.isArray(args))) return failWith(name, origin, new GenerativeUIError("invalid_arguments", `Invalid arguments for "${name}": args must be an object`));
|
|
3996
4042
|
try {
|
|
3997
4043
|
return {
|
|
3998
4044
|
ok: true,
|
|
3999
|
-
result:
|
|
4045
|
+
result: run(args ?? {})
|
|
4000
4046
|
};
|
|
4001
4047
|
} catch (error) {
|
|
4002
4048
|
return failWith(name, origin, new GenerativeUIError(error instanceof ExpressionError ? "invalid_arguments" : "handler_failed", `"${name}" failed: ${messageOf(error)}`));
|
|
@@ -4149,8 +4195,8 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
4149
4195
|
*/
|
|
4150
4196
|
var BuildMemo = class {
|
|
4151
4197
|
constructor() {
|
|
4152
|
-
this
|
|
4153
|
-
this
|
|
4198
|
+
_defineProperty(this, "previous", /* @__PURE__ */ new Map());
|
|
4199
|
+
_defineProperty(this, "current", /* @__PURE__ */ new Map());
|
|
4154
4200
|
}
|
|
4155
4201
|
/**
|
|
4156
4202
|
* The value of `key`. It is computed when no earlier value is there, or
|
|
@@ -4170,10 +4216,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
4170
4216
|
/** The results of the builds of one thread. See `BuildMarkdownSurfacesOptions.cache`. */
|
|
4171
4217
|
var MarkdownBuildCache = class {
|
|
4172
4218
|
constructor() {
|
|
4173
|
-
this
|
|
4174
|
-
this
|
|
4175
|
-
this
|
|
4176
|
-
this
|
|
4219
|
+
_defineProperty(this, "segments", new BuildMemo());
|
|
4220
|
+
_defineProperty(this, "fences", new BuildMemo());
|
|
4221
|
+
_defineProperty(this, "drafts", new BuildMemo());
|
|
4222
|
+
_defineProperty(this, "readdressed", /* @__PURE__ */ new WeakMap());
|
|
4177
4223
|
}
|
|
4178
4224
|
endBuild() {
|
|
4179
4225
|
this.segments.endBuild();
|
|
@@ -4688,10 +4734,11 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
4688
4734
|
constructor(manager, ui) {
|
|
4689
4735
|
this.manager = manager;
|
|
4690
4736
|
this.ui = ui;
|
|
4691
|
-
this
|
|
4692
|
-
this
|
|
4693
|
-
this
|
|
4694
|
-
this
|
|
4737
|
+
_defineProperty(this, "functions", void 0);
|
|
4738
|
+
_defineProperty(this, "fences", /* @__PURE__ */ new Map());
|
|
4739
|
+
_defineProperty(this, "ingested", /* @__PURE__ */ new Map());
|
|
4740
|
+
_defineProperty(this, "contents", /* @__PURE__ */ new Map());
|
|
4741
|
+
_defineProperty(this, "caches", /* @__PURE__ */ new Map());
|
|
4695
4742
|
this.functions = declaredFunctions(ui);
|
|
4696
4743
|
}
|
|
4697
4744
|
/**
|
|
@@ -4870,18 +4917,18 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
4870
4917
|
const MATH = {
|
|
4871
4918
|
min: (args) => Math.min(...args),
|
|
4872
4919
|
max: (args) => Math.max(...args),
|
|
4873
|
-
abs: ([x]) => Math.abs(x),
|
|
4874
|
-
floor: ([x]) => Math.floor(x),
|
|
4875
|
-
ceil: ([x]) => Math.ceil(x),
|
|
4876
|
-
round: ([x, decimals = 0]) => {
|
|
4920
|
+
abs: ([x = NaN]) => Math.abs(x),
|
|
4921
|
+
floor: ([x = NaN]) => Math.floor(x),
|
|
4922
|
+
ceil: ([x = NaN]) => Math.ceil(x),
|
|
4923
|
+
round: ([x = NaN, decimals = 0]) => {
|
|
4877
4924
|
const factor = 10 ** Math.trunc(decimals);
|
|
4878
4925
|
return Math.round(x * factor) / factor;
|
|
4879
4926
|
},
|
|
4880
|
-
pow: ([x, y]) => x ** y,
|
|
4881
|
-
sqrt: ([x]) => Math.sqrt(x),
|
|
4882
|
-
exp: ([x]) => Math.exp(x),
|
|
4883
|
-
ln: ([x]) => Math.log(x),
|
|
4884
|
-
log10: ([x]) => Math.log10(x)
|
|
4927
|
+
pow: ([x = NaN, y = NaN]) => x ** y,
|
|
4928
|
+
sqrt: ([x = NaN]) => Math.sqrt(x),
|
|
4929
|
+
exp: ([x = NaN]) => Math.exp(x),
|
|
4930
|
+
ln: ([x = NaN]) => Math.log(x),
|
|
4931
|
+
log10: ([x = NaN]) => Math.log10(x)
|
|
4885
4932
|
};
|
|
4886
4933
|
/** How many args a function takes, at least and at most; min and max take any. */
|
|
4887
4934
|
const ARITY = {
|
|
@@ -4905,14 +4952,24 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
4905
4952
|
this.tokens = tokens;
|
|
4906
4953
|
this.scope = scope;
|
|
4907
4954
|
this.source = source;
|
|
4908
|
-
this
|
|
4909
|
-
this
|
|
4955
|
+
_defineProperty(this, "pos", 0);
|
|
4956
|
+
_defineProperty(this, "skipDepth", 0);
|
|
4910
4957
|
}
|
|
4911
4958
|
parse() {
|
|
4912
4959
|
const value = this.ternary();
|
|
4913
|
-
|
|
4960
|
+
const token = this.peek();
|
|
4961
|
+
if (token.kind !== "end") this.fail(`unexpected "${this.text(token)}"`);
|
|
4914
4962
|
return value;
|
|
4915
4963
|
}
|
|
4964
|
+
/**
|
|
4965
|
+
* The token at `pos`. The parser never moves past the "end" token, which
|
|
4966
|
+
* `tokenize` always adds last, so there is always one.
|
|
4967
|
+
*/
|
|
4968
|
+
peek() {
|
|
4969
|
+
const token = this.tokens[this.pos];
|
|
4970
|
+
if (token === void 0) throw new Error(`calc: no token at ${this.pos} in "${this.source}"`);
|
|
4971
|
+
return token;
|
|
4972
|
+
}
|
|
4916
4973
|
fail(what) {
|
|
4917
4974
|
throw new ExpressionError(`calc: ${what} in "${this.source}"`);
|
|
4918
4975
|
}
|
|
@@ -4920,11 +4977,11 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
4920
4977
|
return token.kind === "end" ? "end" : String(token.value);
|
|
4921
4978
|
}
|
|
4922
4979
|
peekOp(...ops) {
|
|
4923
|
-
const token = this.
|
|
4980
|
+
const token = this.peek();
|
|
4924
4981
|
return token.kind === "op" && ops.includes(token.value) ? token.value : void 0;
|
|
4925
4982
|
}
|
|
4926
4983
|
expectOp(op) {
|
|
4927
|
-
if (this.peekOp(op) === void 0) this.fail(`expected "${op}" but found "${this.text(this.
|
|
4984
|
+
if (this.peekOp(op) === void 0) this.fail(`expected "${op}" but found "${this.text(this.peek())}"`);
|
|
4928
4985
|
this.pos++;
|
|
4929
4986
|
}
|
|
4930
4987
|
/**
|
|
@@ -5049,7 +5106,8 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
5049
5106
|
return value;
|
|
5050
5107
|
}
|
|
5051
5108
|
primary() {
|
|
5052
|
-
const token = this.
|
|
5109
|
+
const token = this.peek();
|
|
5110
|
+
this.pos++;
|
|
5053
5111
|
switch (token.kind) {
|
|
5054
5112
|
case "number": return token.value;
|
|
5055
5113
|
case "string": return token.value;
|
|
@@ -5332,7 +5390,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
5332
5390
|
constructor(source, state) {
|
|
5333
5391
|
this.source = source;
|
|
5334
5392
|
this.state = state;
|
|
5335
|
-
this
|
|
5393
|
+
_defineProperty(this, "pos", 0);
|
|
5336
5394
|
}
|
|
5337
5395
|
parse() {
|
|
5338
5396
|
const value = this.expression();
|
|
@@ -5524,23 +5582,33 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
5524
5582
|
constructor(ui, options = {}) {
|
|
5525
5583
|
this.ui = ui;
|
|
5526
5584
|
this.options = options;
|
|
5527
|
-
this
|
|
5528
|
-
this
|
|
5529
|
-
this
|
|
5530
|
-
this
|
|
5531
|
-
this
|
|
5532
|
-
this
|
|
5533
|
-
this
|
|
5534
|
-
this
|
|
5535
|
-
this
|
|
5536
|
-
this
|
|
5585
|
+
_defineProperty(this, "surfaces", /* @__PURE__ */ new Map());
|
|
5586
|
+
_defineProperty(this, "bookkeeping", /* @__PURE__ */ new Map());
|
|
5587
|
+
_defineProperty(this, "listeners", /* @__PURE__ */ new Set());
|
|
5588
|
+
_defineProperty(this, "targets", /* @__PURE__ */ new Map());
|
|
5589
|
+
_defineProperty(this, "state", {});
|
|
5590
|
+
_defineProperty(this, "owned", /* @__PURE__ */ new Map());
|
|
5591
|
+
_defineProperty(this, "deletedKeys", /* @__PURE__ */ new Set());
|
|
5592
|
+
_defineProperty(this, "linked", /* @__PURE__ */ new Map());
|
|
5593
|
+
_defineProperty(this, "webCoreCatalog", void 0);
|
|
5594
|
+
_defineProperty(this, "activeThreadId", void 0);
|
|
5595
|
+
_defineProperty(this, "version", 0);
|
|
5596
|
+
_defineProperty(this, "subscribe", (listener) => {
|
|
5537
5597
|
this.listeners.add(listener);
|
|
5538
5598
|
return () => {
|
|
5539
5599
|
this.listeners.delete(listener);
|
|
5540
5600
|
};
|
|
5541
|
-
};
|
|
5542
|
-
this
|
|
5543
|
-
|
|
5601
|
+
});
|
|
5602
|
+
_defineProperty(this, "getVersion", () => this.version);
|
|
5603
|
+
_defineProperty(
|
|
5604
|
+
this,
|
|
5605
|
+
/**
|
|
5606
|
+
* The app state object. It is the same object until a key changes, so it
|
|
5607
|
+
* can be a `useSyncExternalStore` snapshot.
|
|
5608
|
+
*/
|
|
5609
|
+
"getState",
|
|
5610
|
+
() => this.state
|
|
5611
|
+
);
|
|
5544
5612
|
this.webCoreCatalog = new _a2ui_web_core_v0_9.Catalog(ui.id, [...ui.components.keys()].map((name) => ({
|
|
5545
5613
|
name,
|
|
5546
5614
|
schema: zod.any()
|
|
@@ -6605,11 +6673,11 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
6605
6673
|
var NodeBoundary = class extends react.Component {
|
|
6606
6674
|
constructor(..._args) {
|
|
6607
6675
|
super(..._args);
|
|
6608
|
-
this
|
|
6676
|
+
_defineProperty(this, "state", {
|
|
6609
6677
|
error: null,
|
|
6610
6678
|
revision: this.props.revision
|
|
6611
|
-
};
|
|
6612
|
-
this
|
|
6679
|
+
});
|
|
6680
|
+
_defineProperty(this, "retry", () => this.setState({ error: null }));
|
|
6613
6681
|
}
|
|
6614
6682
|
static getDerivedStateFromError(error) {
|
|
6615
6683
|
return { error };
|
|
@@ -6650,7 +6718,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
6650
6718
|
var SurfaceBoundary = class extends react.Component {
|
|
6651
6719
|
constructor(..._args2) {
|
|
6652
6720
|
super(..._args2);
|
|
6653
|
-
this
|
|
6721
|
+
_defineProperty(this, "state", { error: null });
|
|
6654
6722
|
}
|
|
6655
6723
|
static getDerivedStateFromError(error) {
|
|
6656
6724
|
return { error };
|
|
@@ -10022,7 +10090,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
10022
10090
|
try {
|
|
10023
10091
|
maybePromise = handler({
|
|
10024
10092
|
event: legacyEvent,
|
|
10025
|
-
interrupt: pending.kind === "standard" ? pending.interrupts[0] : null,
|
|
10093
|
+
interrupt: pending.kind === "standard" ? pending.interrupts[0] ?? null : null,
|
|
10026
10094
|
interrupts: pending.kind === "standard" ? [...pending.interrupts] : [],
|
|
10027
10095
|
resolve: resolveRef.current,
|
|
10028
10096
|
cancel: cancelRef.current
|
|
@@ -10051,7 +10119,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
10051
10119
|
if (!isEnabled(legacyEvent)) return null;
|
|
10052
10120
|
return renderRef.current({
|
|
10053
10121
|
event: legacyEvent,
|
|
10054
|
-
interrupt: pending.kind === "standard" ? pending.interrupts[0] : null,
|
|
10122
|
+
interrupt: pending.kind === "standard" ? pending.interrupts[0] ?? null : null,
|
|
10055
10123
|
interrupts: pending.kind === "standard" ? [...pending.interrupts] : [],
|
|
10056
10124
|
result: handlerResult,
|
|
10057
10125
|
resolve,
|
|
@@ -14159,6 +14227,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
14159
14227
|
const lastNonceRef = (0, react.useRef)(-1);
|
|
14160
14228
|
(0, react.useEffect)(() => {
|
|
14161
14229
|
if (sendNonce === lastNonceRef.current) return;
|
|
14230
|
+
const previousNonce = lastNonceRef.current;
|
|
14162
14231
|
lastNonceRef.current = sendNonce;
|
|
14163
14232
|
if (!id) return;
|
|
14164
14233
|
const scrollEl = scrollRef.current;
|
|
@@ -14174,7 +14243,9 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
14174
14243
|
const bubbleHeight = Math.max(0, userMessageHeight - paddingTop);
|
|
14175
14244
|
const spacerHeight = Math.max(0, viewportHeight - bubbleHeight - topOffset);
|
|
14176
14245
|
spacerEl.style.height = `${spacerHeight}px`;
|
|
14246
|
+
let pinned = false;
|
|
14177
14247
|
const raf = requestAnimationFrame(() => {
|
|
14248
|
+
pinned = true;
|
|
14178
14249
|
const targetTop = computeOffsetTop(targetEl, scrollEl) + paddingTop - topOffset;
|
|
14179
14250
|
scrollEl.scrollTo({
|
|
14180
14251
|
top: Math.max(0, targetTop),
|
|
@@ -14191,6 +14262,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
14191
14262
|
return () => {
|
|
14192
14263
|
cancelAnimationFrame(raf);
|
|
14193
14264
|
ro.disconnect();
|
|
14265
|
+
if (!pinned) lastNonceRef.current = previousNonce;
|
|
14194
14266
|
};
|
|
14195
14267
|
}, [
|
|
14196
14268
|
id,
|
|
@@ -14226,15 +14298,16 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
14226
14298
|
})
|
|
14227
14299
|
});
|
|
14228
14300
|
}
|
|
14229
|
-
function CopilotChatView({ messageView, input, scrollView, suggestionView, welcomeScreen, messages = [], autoScroll = true, isRunning = false, suggestions, suggestionLoadingIndexes, onSelectSuggestion, onSubmitMessage, onStop, inputMode, inputValue, onInputChange, onStartTranscribe, onCancelTranscribe, onFinishTranscribe, onFinishTranscribeWithAudio, attachments, onRemoveAttachment, onAddFile, dragOver, onDragOver, onDragLeave, onDrop, isConnecting = false, hasExplicitThreadId = false, intelligenceIndicator, children, className, ...props }) {
|
|
14301
|
+
function CopilotChatView({ messageView, input, scrollView, suggestionView, welcomeScreen, messages = [], autoScroll = true, isRunning = false, suggestions, suggestionLoadingIndexes, onSelectSuggestion, onSubmitMessage, onStop, inputMode, inputValue, onInputChange, onStartTranscribe, onCancelTranscribe, onFinishTranscribe, onFinishTranscribeWithAudio, attachments, onRemoveAttachment, onAddFile, dragOver, onDragOver, onDragLeave, onDrop, isConnecting = false, connectingIndicator, hasExplicitThreadId = false, intelligenceIndicator, children, className, ...props }) {
|
|
14230
14302
|
const configuredThreadId = useCopilotChatConfiguration()?.threadId;
|
|
14231
14303
|
const [fallbackThreadId, setFallbackThreadId] = (0, react.useState)(messages[0]?.id);
|
|
14232
14304
|
const previousMessageIds = (0, react.useRef)(/* @__PURE__ */ new Set());
|
|
14233
14305
|
(0, react.useEffect)(() => {
|
|
14234
|
-
|
|
14306
|
+
const firstMessage = messages[0];
|
|
14307
|
+
if (firstMessage === void 0) return;
|
|
14235
14308
|
const overlaps = messages.some((message) => previousMessageIds.current.has(message.id));
|
|
14236
14309
|
previousMessageIds.current = new Set(messages.map((message) => message.id));
|
|
14237
|
-
if (!overlaps) setFallbackThreadId(
|
|
14310
|
+
if (!overlaps) setFallbackThreadId(firstMessage.id);
|
|
14238
14311
|
}, [messages]);
|
|
14239
14312
|
const scrollThreadId = configuredThreadId ?? fallbackThreadId;
|
|
14240
14313
|
const [inputContainerEl, setInputContainerEl] = (0, react.useState)(null);
|
|
@@ -14300,6 +14373,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
14300
14373
|
onSelectSuggestion,
|
|
14301
14374
|
className: "cpk-chat-view-suggestion-view"
|
|
14302
14375
|
}) : null;
|
|
14376
|
+
const BoundConnectingIndicator = isConnecting && messages.length === 0 && connectingIndicator !== false ? renderSlot(connectingIndicator === true ? void 0 : connectingIndicator, CopilotChatView.ConnectingIndicator, {}) : null;
|
|
14303
14377
|
const BoundScrollView = renderSlot(scrollView, CopilotChatView.ScrollView, {
|
|
14304
14378
|
autoScroll,
|
|
14305
14379
|
scrollThreadId,
|
|
@@ -14310,10 +14384,14 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
14310
14384
|
style: { paddingBottom: `${inputContainerHeight + (hasSuggestions ? 4 : 32)}px` },
|
|
14311
14385
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
14312
14386
|
className: "cpk-chat-view-feed",
|
|
14313
|
-
children: [
|
|
14314
|
-
|
|
14315
|
-
|
|
14316
|
-
|
|
14387
|
+
children: [
|
|
14388
|
+
BoundConnectingIndicator,
|
|
14389
|
+
BoundMessageView,
|
|
14390
|
+
hasSuggestions ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
14391
|
+
className: "cpk-chat-view-suggestions",
|
|
14392
|
+
children: BoundSuggestionView
|
|
14393
|
+
}) : null
|
|
14394
|
+
]
|
|
14317
14395
|
})
|
|
14318
14396
|
})
|
|
14319
14397
|
});
|
|
@@ -14350,6 +14428,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
14350
14428
|
"data-copilotkit": true,
|
|
14351
14429
|
"data-testid": "copilot-chat",
|
|
14352
14430
|
"data-copilot-running": isRunning ? "true" : "false",
|
|
14431
|
+
"data-copilot-connecting": isConnecting ? "true" : "false",
|
|
14353
14432
|
onDragOver,
|
|
14354
14433
|
onDragLeave,
|
|
14355
14434
|
onDrop,
|
|
@@ -14360,6 +14439,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
14360
14439
|
}
|
|
14361
14440
|
if (children) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
14362
14441
|
"data-copilotkit": true,
|
|
14442
|
+
"data-copilot-connecting": isConnecting ? "true" : "false",
|
|
14363
14443
|
style: { display: "contents" },
|
|
14364
14444
|
children: children({
|
|
14365
14445
|
messageView: BoundMessageView,
|
|
@@ -14372,6 +14452,7 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
14372
14452
|
"data-copilotkit": true,
|
|
14373
14453
|
"data-testid": "copilot-chat",
|
|
14374
14454
|
"data-copilot-running": isRunning ? "true" : "false",
|
|
14455
|
+
"data-copilot-connecting": isConnecting ? "true" : "false",
|
|
14375
14456
|
onDragOver,
|
|
14376
14457
|
onDragLeave,
|
|
14377
14458
|
onDrop,
|
|
@@ -14587,13 +14668,15 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
14587
14668
|
if (mode === "pin-to-bottom") return;
|
|
14588
14669
|
const scrollElement = nonAutoScrollEl;
|
|
14589
14670
|
if (!scrollElement) return;
|
|
14671
|
+
const contentElement = contentRef.current;
|
|
14590
14672
|
const checkScroll = () => {
|
|
14591
|
-
setShowScrollButton(
|
|
14673
|
+
setShowScrollButton((contentElement ? contentElement.getBoundingClientRect().bottom - scrollElement.getBoundingClientRect().bottom : scrollElement.scrollHeight - scrollElement.scrollTop - scrollElement.clientHeight) >= 10);
|
|
14592
14674
|
};
|
|
14593
14675
|
checkScroll();
|
|
14594
14676
|
scrollElement.addEventListener("scroll", checkScroll);
|
|
14595
14677
|
const resizeObserver = new ResizeObserver(checkScroll);
|
|
14596
14678
|
resizeObserver.observe(scrollElement);
|
|
14679
|
+
if (contentElement) resizeObserver.observe(contentElement);
|
|
14597
14680
|
return () => {
|
|
14598
14681
|
scrollElement.removeEventListener("scroll", checkScroll);
|
|
14599
14682
|
resizeObserver.disconnect();
|
|
@@ -14679,6 +14762,22 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
14679
14762
|
className,
|
|
14680
14763
|
...props
|
|
14681
14764
|
});
|
|
14765
|
+
_CopilotChatView.ConnectingIndicator = ({ className, ...props }) => {
|
|
14766
|
+
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
14767
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
14768
|
+
"data-testid": "copilot-connecting-indicator",
|
|
14769
|
+
role: "status",
|
|
14770
|
+
className: cn("cpk-chat-view-connecting-indicator", className),
|
|
14771
|
+
...props,
|
|
14772
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopilotIcon, {
|
|
14773
|
+
name: "Loader2",
|
|
14774
|
+
className: "cpk-chat-view-connecting-spinner"
|
|
14775
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
14776
|
+
className: "cpk-chat-view-connecting-label",
|
|
14777
|
+
children: labels.chatConnectingLabel
|
|
14778
|
+
})]
|
|
14779
|
+
});
|
|
14780
|
+
};
|
|
14682
14781
|
_CopilotChatView.WelcomeMessage = ({ className, ...props }) => {
|
|
14683
14782
|
const labels = useCopilotChatConfiguration()?.labels ?? _copilotkit_core.CopilotChatDefaultLabels;
|
|
14684
14783
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
|
|
@@ -15407,7 +15506,10 @@ _radix_ui_react_popover = __toESM(_radix_ui_react_popover);
|
|
|
15407
15506
|
const effectiveMode = isTranscribing ? "processing" : transcribeMode;
|
|
15408
15507
|
const messages = (0, react.useMemo)(() => [...agent.messages], [(0, _copilotkit_core.ɵmessagesFingerprint)(agent.messages)]);
|
|
15409
15508
|
const lastUserMessageId = (0, react.useMemo)(() => {
|
|
15410
|
-
for (let i = messages.length - 1; i >= 0; i--)
|
|
15509
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
15510
|
+
const message = messages[i];
|
|
15511
|
+
if (message?.role === "user") return message.id;
|
|
15512
|
+
}
|
|
15411
15513
|
return null;
|
|
15412
15514
|
}, [messages]);
|
|
15413
15515
|
const [sendNonce, setSendNonce] = (0, react.useState)(0);
|