@copilotkit/channels-core 0.6.0 → 0.6.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.
package/dist/create-channel.d.ts
CHANGED
|
@@ -43,7 +43,8 @@ export type ChannelConcurrency = "parallel" | "serial" | "drop";
|
|
|
43
43
|
*
|
|
44
44
|
* Fails loud on all three ways cloning can fail to isolate: a missing `clone()`,
|
|
45
45
|
* a `clone()` that hands back the same object, and a `clone()` that silently
|
|
46
|
-
* drops subclass state (see {@link
|
|
46
|
+
* drops subclass state (see {@link warnOnCloneDroppedOwnFields}, which reports
|
|
47
|
+
* rather than refuses).
|
|
47
48
|
*/
|
|
48
49
|
export declare function isolateAgentInstance(prototype: AbstractAgent, threadId: string): AbstractAgent;
|
|
49
50
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-channel.d.ts","sourceRoot":"","sources":["../src/create-channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EAUf,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE5D,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,eAAe,EACf,UAAU,EAGV,WAAW,EACX,UAAU,EACX,MAAM,yBAAyB,CAAC;AAMjC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,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AO,EAAE,cAAc,GAAG,IAAI,CAAC;IACzC,kDAAkD;IAClD,SAAS,CACP,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GACrD,IAAI,CAAC;IACR,kGAAkG;IAClG,UAAU,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;IAC3C,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,EAAE,EAAE,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;IAC7E,uFAAuF;IACvF,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACrE,uEAAuE;IACvE,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACnE,IAAI,CAAC,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3B,kFAAkF;IAClF,WAAW,EAAE,WAAW,CAAC;IACzB;;;;;OAKG;IACH,QAAQ,EAAE;QACR,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;QACtB,UAAU,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;QAC3C,iFAAiF;QACjF,wBAAwB,IAAI,IAAI,CAAC;KAClC,CAAC;CACH;AA0FD,wBAAgB,aAAa,CAC3B,YAAY,SAAS,gBAAgB,GAAG,SAAS,GAAG,SAAS,EAE7D,IAAI,EAAE,oBAAoB,CAAC,YAAY,CAAC,GACvC,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAg8BtC"}
|
package/dist/create-channel.js
CHANGED
|
@@ -58,7 +58,8 @@ function isEmojiPlatform(platform) {
|
|
|
58
58
|
*
|
|
59
59
|
* Fails loud on all three ways cloning can fail to isolate: a missing `clone()`,
|
|
60
60
|
* a `clone()` that hands back the same object, and a `clone()` that silently
|
|
61
|
-
* drops subclass state (see {@link
|
|
61
|
+
* drops subclass state (see {@link warnOnCloneDroppedOwnFields}, which reports
|
|
62
|
+
* rather than refuses).
|
|
62
63
|
*/
|
|
63
64
|
export function isolateAgentInstance(prototype, threadId) {
|
|
64
65
|
if (typeof prototype.clone !== "function") {
|
|
@@ -70,7 +71,7 @@ export function isolateAgentInstance(prototype, threadId) {
|
|
|
70
71
|
if (cloned == null || cloned === prototype) {
|
|
71
72
|
throw new Error("createChannel: agent.clone() must return a distinct instance for concurrent turns");
|
|
72
73
|
}
|
|
73
|
-
|
|
74
|
+
warnOnCloneDroppedOwnFields(prototype, cloned);
|
|
74
75
|
cloned.threadId = threadId;
|
|
75
76
|
// `clone()` copies `isRunning` from the source, and a source that has already
|
|
76
77
|
// run can be mid-run at the moment it is cloned. A fresh turn is not.
|
|
@@ -90,7 +91,7 @@ export function isolateAgentInstance(prototype, threadId) {
|
|
|
90
91
|
return cloned;
|
|
91
92
|
}
|
|
92
93
|
/**
|
|
93
|
-
*
|
|
94
|
+
* Report — but do not refuse — a `clone()` that drops subclass state.
|
|
94
95
|
*
|
|
95
96
|
* `AbstractAgent.prototype.clone()` copies a fixed field list, so a subclass
|
|
96
97
|
* that declares its own fields (an auth client, config, a cache) gets them back
|
|
@@ -98,27 +99,49 @@ export function isolateAgentInstance(prototype, threadId) {
|
|
|
98
99
|
* exists and returns a correctly-typed instance, nothing else surfaces it. The
|
|
99
100
|
* agent just runs gutted.
|
|
100
101
|
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
102
|
+
* This used to throw. It no longer does, because whether a dropped field matters
|
|
103
|
+
* depends on what the field HOLDS, and from here the two cases are
|
|
104
|
+
* indistinguishable:
|
|
105
|
+
*
|
|
106
|
+
* - **Config** (`orchestrationAgentUrl`, an auth client) is read during the run
|
|
107
|
+
* and never rewritten, so losing it does gut the agent.
|
|
108
|
+
* - **Per-run scratch state** is re-initialized at the start of every run, so
|
|
109
|
+
* losing it changes nothing. `LangGraphAgent`'s `emittedToolCallStartIds` and
|
|
110
|
+
* `eventsStreamActive` are exactly this: both are reset when a run binds its
|
|
111
|
+
* subscriber, before anything reads them.
|
|
112
|
+
*
|
|
113
|
+
* Throwing on the second case took a Channel that works and refused every turn
|
|
114
|
+
* — while the identical clone happens on every ordinary runtime request
|
|
115
|
+
* (`agent-utils.ts` clones per request) with no ill effect at all, which is why
|
|
116
|
+
* it had never been noticed outside Channels. A warning keeps the signal for the
|
|
117
|
+
* config case without failing the harmless one.
|
|
118
|
+
*
|
|
119
|
+
* Deliberately NOT done: copying the dropped fields onto the clone. That would
|
|
120
|
+
* share one mutable object across concurrent turns, which is the exact hazard
|
|
121
|
+
* this isolation exists to prevent.
|
|
122
|
+
*
|
|
123
|
+
* Comparing own enumerable keys stays quiet for the agents that override
|
|
124
|
+
* `clone()` fully (`HttpAgent`, `BuiltInAgent`, `IntelligenceAgent`).
|
|
125
|
+
* Symbol-keyed and non-enumerable fields are not covered.
|
|
105
126
|
*
|
|
106
127
|
* Own *functions* are deliberately exempt. Assigning a method on the instance is
|
|
107
128
|
* how spies and instrumentation wrap an agent, and losing that wrapper leaves
|
|
108
129
|
* the class's prototype method intact — the clone still behaves correctly, it
|
|
109
130
|
* just isn't wrapped. Only dropped state leaves an agent genuinely gutted.
|
|
110
131
|
*/
|
|
111
|
-
function
|
|
132
|
+
function warnOnCloneDroppedOwnFields(prototype, cloned) {
|
|
112
133
|
const source = prototype;
|
|
113
134
|
const dropped = Object.keys(prototype).filter((key) => typeof source[key] !== "function" &&
|
|
114
135
|
!Object.prototype.hasOwnProperty.call(cloned, key));
|
|
115
136
|
if (dropped.length === 0)
|
|
116
137
|
return;
|
|
117
138
|
const name = prototype.constructor?.name ?? "the configured agent";
|
|
118
|
-
|
|
139
|
+
console.warn(`createChannel: ${name}.clone() dropped ${dropped.join(", ")}. ` +
|
|
119
140
|
"Every turn runs on a clone, and AbstractAgent's clone() only copies its " +
|
|
120
|
-
|
|
121
|
-
|
|
141
|
+
"own fixed field list, so those fields read as undefined on the clone. " +
|
|
142
|
+
"That is harmless for state a run re-initializes, and gutting for anything " +
|
|
143
|
+
`read as configuration — override clone() on ${name} to carry them if it is ` +
|
|
144
|
+
"the latter (HttpAgent.clone() is the reference).");
|
|
122
145
|
}
|
|
123
146
|
/**
|
|
124
147
|
* Resolve effective turn concurrency from `store.concurrency` and legacy
|
|
@@ -985,8 +985,9 @@ describe("createChannel", () => {
|
|
|
985
985
|
// Nothing ever runs on the configured object, so it stays pristine.
|
|
986
986
|
expect(shared.messages).toEqual([]);
|
|
987
987
|
});
|
|
988
|
-
it("agent whose clone() drops subclass state
|
|
988
|
+
it("agent whose clone() drops subclass state warns and still runs the turn", async () => {
|
|
989
989
|
const state = new MemoryStore();
|
|
990
|
+
const warn = vi.spyOn(console, "warn").mockImplementation(() => undefined);
|
|
990
991
|
// Inherits `FakeAgent.clone()`, which builds a plain `FakeAgent` and so
|
|
991
992
|
// cannot carry this field — the same shape as a subclass inheriting
|
|
992
993
|
// `AbstractAgent.prototype.clone()`, which copies a fixed field list.
|
|
@@ -1006,13 +1007,46 @@ describe("createChannel", () => {
|
|
|
1006
1007
|
});
|
|
1007
1008
|
await channel.ɵruntime.start();
|
|
1008
1009
|
const sink = fake.getSink();
|
|
1010
|
+
// Reports it, and does not refuse the turn: whether a dropped field matters
|
|
1011
|
+
// depends on what it holds, and this cannot tell config from per-run state.
|
|
1009
1012
|
await expect(sink.onTurn({
|
|
1010
1013
|
conversationKey: "c1",
|
|
1011
1014
|
replyTarget: {},
|
|
1012
1015
|
userText: "hi",
|
|
1013
1016
|
platform: "fake",
|
|
1014
1017
|
eventId: "E1",
|
|
1015
|
-
})).
|
|
1018
|
+
})).resolves.not.toThrow();
|
|
1019
|
+
expect(warn).toHaveBeenCalledWith(expect.stringMatching(/StatefulAgent\.clone\(\) dropped authClient/));
|
|
1020
|
+
warn.mockRestore();
|
|
1021
|
+
});
|
|
1022
|
+
it("the dropped-state warning names every field, once per turn", async () => {
|
|
1023
|
+
const state = new MemoryStore();
|
|
1024
|
+
const warn = vi.spyOn(console, "warn").mockImplementation(() => undefined);
|
|
1025
|
+
class TwoFieldAgent extends FakeAgent {
|
|
1026
|
+
authClient = { token: "secret" };
|
|
1027
|
+
cache = new Map();
|
|
1028
|
+
}
|
|
1029
|
+
const fake = new FakeAdapter();
|
|
1030
|
+
const channel = createChannel({
|
|
1031
|
+
identifyUser: "platform",
|
|
1032
|
+
adapters: [fake],
|
|
1033
|
+
agent: () => new TwoFieldAgent(),
|
|
1034
|
+
store: { adapter: state },
|
|
1035
|
+
});
|
|
1036
|
+
channel.onMention(async ({ thread }) => {
|
|
1037
|
+
await thread.runAgent({ prompt: "hi" });
|
|
1038
|
+
});
|
|
1039
|
+
await channel.ɵruntime.start();
|
|
1040
|
+
await fake.getSink().onTurn({
|
|
1041
|
+
conversationKey: "c1",
|
|
1042
|
+
replyTarget: {},
|
|
1043
|
+
userText: "hi",
|
|
1044
|
+
platform: "fake",
|
|
1045
|
+
eventId: "E1",
|
|
1046
|
+
});
|
|
1047
|
+
expect(warn).toHaveBeenCalledTimes(1);
|
|
1048
|
+
expect(warn).toHaveBeenCalledWith(expect.stringContaining("authClient, cache"));
|
|
1049
|
+
warn.mockRestore();
|
|
1016
1050
|
});
|
|
1017
1051
|
it("does not fail loud when clone() drops an instance-patched method", async () => {
|
|
1018
1052
|
const state = new MemoryStore();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@copilotkit/channels-core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Platform-agnostic JSX channel engine for CopilotKit (createChannel, Thread, PlatformAdapter, ActionStore).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"@ag-ui/client": "0.0.57",
|
|
52
52
|
"@ag-ui/core": "0.0.57",
|
|
53
53
|
"zod-to-json-schema": "^3.24.1",
|
|
54
|
-
"@copilotkit/core": "^1.
|
|
55
|
-
"@copilotkit/shared": "^1.
|
|
56
|
-
"@copilotkit/channels-ui": "~0.6.
|
|
54
|
+
"@copilotkit/core": "^1.65.0",
|
|
55
|
+
"@copilotkit/shared": "^1.65.0",
|
|
56
|
+
"@copilotkit/channels-ui": "~0.6.1"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/node": "^22.10.0",
|