@copilotkit/core 1.56.5 → 1.57.0
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/index.cjs +96 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +605 -557
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +417 -369
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +96 -1
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +96 -0
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -2429,6 +2429,67 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2429
2429
|
}
|
|
2430
2430
|
};
|
|
2431
2431
|
|
|
2432
|
+
//#endregion
|
|
2433
|
+
//#region src/core/thread-store-registry.ts
|
|
2434
|
+
var ThreadStoreRegistry = class {
|
|
2435
|
+
constructor(core) {
|
|
2436
|
+
this.core = core;
|
|
2437
|
+
_defineProperty(this, "_stores", {});
|
|
2438
|
+
_defineProperty(this, "_snapshot", null);
|
|
2439
|
+
}
|
|
2440
|
+
register(agentId, store) {
|
|
2441
|
+
if (agentId in this._stores) {
|
|
2442
|
+
const prevStore = this._stores[agentId];
|
|
2443
|
+
delete this._stores[agentId];
|
|
2444
|
+
this._snapshot = null;
|
|
2445
|
+
this.notifyUnregistered(agentId, prevStore).catch((err) => {
|
|
2446
|
+
console.error("ThreadStoreRegistry notifyUnregistered failed:", err);
|
|
2447
|
+
});
|
|
2448
|
+
}
|
|
2449
|
+
this._stores[agentId] = store;
|
|
2450
|
+
this._snapshot = null;
|
|
2451
|
+
this.notifyRegistered(agentId, store).catch((err) => {
|
|
2452
|
+
console.error("ThreadStoreRegistry notifyRegistered failed:", err);
|
|
2453
|
+
});
|
|
2454
|
+
}
|
|
2455
|
+
unregister(agentId) {
|
|
2456
|
+
if (!(agentId in this._stores)) return;
|
|
2457
|
+
const prevStore = this._stores[agentId];
|
|
2458
|
+
delete this._stores[agentId];
|
|
2459
|
+
this._snapshot = null;
|
|
2460
|
+
this.notifyUnregistered(agentId, prevStore).catch((err) => {
|
|
2461
|
+
console.error("ThreadStoreRegistry notifyUnregistered failed:", err);
|
|
2462
|
+
});
|
|
2463
|
+
}
|
|
2464
|
+
get(agentId) {
|
|
2465
|
+
return this._stores[agentId];
|
|
2466
|
+
}
|
|
2467
|
+
getAll() {
|
|
2468
|
+
if (this._snapshot === null) this._snapshot = Object.freeze({ ...this._stores });
|
|
2469
|
+
return this._snapshot;
|
|
2470
|
+
}
|
|
2471
|
+
async notifyRegistered(agentId, store) {
|
|
2472
|
+
await this.core.notifySubscribers((subscriber) => {
|
|
2473
|
+
var _subscriber$onThreadS;
|
|
2474
|
+
return (_subscriber$onThreadS = subscriber.onThreadStoreRegistered) === null || _subscriber$onThreadS === void 0 ? void 0 : _subscriber$onThreadS.call(subscriber, {
|
|
2475
|
+
copilotkit: this.core,
|
|
2476
|
+
agentId,
|
|
2477
|
+
store
|
|
2478
|
+
});
|
|
2479
|
+
}, "Subscriber onThreadStoreRegistered error:");
|
|
2480
|
+
}
|
|
2481
|
+
async notifyUnregistered(agentId, prevStore) {
|
|
2482
|
+
await this.core.notifySubscribers((subscriber) => {
|
|
2483
|
+
var _subscriber$onThreadS2;
|
|
2484
|
+
return (_subscriber$onThreadS2 = subscriber.onThreadStoreUnregistered) === null || _subscriber$onThreadS2 === void 0 ? void 0 : _subscriber$onThreadS2.call(subscriber, {
|
|
2485
|
+
copilotkit: this.core,
|
|
2486
|
+
agentId,
|
|
2487
|
+
prevStore
|
|
2488
|
+
});
|
|
2489
|
+
}, "Subscriber onThreadStoreUnregistered error:");
|
|
2490
|
+
}
|
|
2491
|
+
};
|
|
2492
|
+
|
|
2432
2493
|
//#endregion
|
|
2433
2494
|
//#region src/core/core.ts
|
|
2434
2495
|
let CopilotKitCoreErrorCode = /* @__PURE__ */ function(CopilotKitCoreErrorCode) {
|
|
@@ -2498,6 +2559,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2498
2559
|
_defineProperty(this, "suggestionEngine", void 0);
|
|
2499
2560
|
_defineProperty(this, "runHandler", void 0);
|
|
2500
2561
|
_defineProperty(this, "stateManager", void 0);
|
|
2562
|
+
_defineProperty(this, "threadStoreRegistry", void 0);
|
|
2563
|
+
_defineProperty(this, "previousAgentIds", /* @__PURE__ */ new Set());
|
|
2501
2564
|
this._headers = headers;
|
|
2502
2565
|
this._credentials = credentials;
|
|
2503
2566
|
this._properties = properties;
|
|
@@ -2507,16 +2570,21 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2507
2570
|
this.suggestionEngine = new SuggestionEngine(this);
|
|
2508
2571
|
this.runHandler = new RunHandler(this);
|
|
2509
2572
|
this.stateManager = new StateManager(this);
|
|
2573
|
+
this.threadStoreRegistry = new ThreadStoreRegistry(this);
|
|
2510
2574
|
this.agentRegistry.initialize(agents__unsafe_dev_only);
|
|
2511
2575
|
this.runHandler.initialize(tools);
|
|
2512
2576
|
this.suggestionEngine.initialize(suggestionsConfig);
|
|
2513
2577
|
this.stateManager.initialize();
|
|
2514
2578
|
this.agentRegistry.setRuntimeTransport(runtimeTransport);
|
|
2515
2579
|
this.agentRegistry.setRuntimeUrl(runtimeUrl);
|
|
2580
|
+
this.previousAgentIds = new Set(Object.keys(agents__unsafe_dev_only));
|
|
2516
2581
|
this.subscribe({ onAgentsChanged: ({ agents }) => {
|
|
2517
2582
|
Object.values(agents).forEach((agent) => {
|
|
2518
2583
|
if (agent.agentId) this.stateManager.subscribeToAgent(agent);
|
|
2519
2584
|
});
|
|
2585
|
+
const currentAgentIds = new Set(Object.keys(agents));
|
|
2586
|
+
for (const agentId of Object.keys(this.threadStoreRegistry.getAll())) if (this.previousAgentIds.has(agentId) && !currentAgentIds.has(agentId)) this.threadStoreRegistry.unregister(agentId);
|
|
2587
|
+
this.previousAgentIds = currentAgentIds;
|
|
2520
2588
|
} });
|
|
2521
2589
|
}
|
|
2522
2590
|
/**
|
|
@@ -2700,6 +2768,21 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2700
2768
|
this.contextStore.removeContext(id);
|
|
2701
2769
|
}
|
|
2702
2770
|
/**
|
|
2771
|
+
* Thread store registry (delegated to ThreadStoreRegistry)
|
|
2772
|
+
*/
|
|
2773
|
+
registerThreadStore(agentId, store) {
|
|
2774
|
+
this.threadStoreRegistry.register(agentId, store);
|
|
2775
|
+
}
|
|
2776
|
+
unregisterThreadStore(agentId) {
|
|
2777
|
+
this.threadStoreRegistry.unregister(agentId);
|
|
2778
|
+
}
|
|
2779
|
+
getThreadStore(agentId) {
|
|
2780
|
+
return this.threadStoreRegistry.get(agentId);
|
|
2781
|
+
}
|
|
2782
|
+
getThreadStores() {
|
|
2783
|
+
return this.threadStoreRegistry.getAll();
|
|
2784
|
+
}
|
|
2785
|
+
/**
|
|
2703
2786
|
* Suggestions management (delegated to SuggestionEngine)
|
|
2704
2787
|
*/
|
|
2705
2788
|
addSuggestionsConfig(config) {
|
|
@@ -3797,6 +3880,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3797
3880
|
setContext(context) {
|
|
3798
3881
|
store.dispatch(threadAdapterEvents.contextChanged({ context }));
|
|
3799
3882
|
},
|
|
3883
|
+
refresh() {
|
|
3884
|
+
const { sessionId, context } = store.getState();
|
|
3885
|
+
if (!context) return;
|
|
3886
|
+
store.dispatch(threadRestEvents.listRequested({ sessionId }));
|
|
3887
|
+
},
|
|
3800
3888
|
fetchNextPage() {
|
|
3801
3889
|
store.dispatch(threadAdapterEvents.fetchNextPageRequested());
|
|
3802
3890
|
},
|
|
@@ -3831,6 +3919,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
3831
3919
|
const ɵselectThreadsError = selectThreadsError;
|
|
3832
3920
|
const ɵselectHasNextPage = selectHasNextPage;
|
|
3833
3921
|
const ɵselectIsFetchingNextPage = selectIsFetchingNextPage;
|
|
3922
|
+
/**
|
|
3923
|
+
* Number of consecutive WebSocket connection failures after which the
|
|
3924
|
+
* threads channel tears itself down rather than retrying indefinitely.
|
|
3925
|
+
* Exposed for tests so they can assert teardown semantics without
|
|
3926
|
+
* hardcoding the threshold separately from production.
|
|
3927
|
+
*/
|
|
3928
|
+
const ɵMAX_SOCKET_RETRIES = MAX_SOCKET_RETRIES;
|
|
3834
3929
|
|
|
3835
3930
|
//#endregion
|
|
3836
3931
|
exports.AgentRegistry = AgentRegistry;
|
|
@@ -3858,6 +3953,7 @@ exports.on = on;
|
|
|
3858
3953
|
exports.parseToolArguments = parseToolArguments;
|
|
3859
3954
|
exports.props = props;
|
|
3860
3955
|
exports.select = select;
|
|
3956
|
+
exports.ɵMAX_SOCKET_RETRIES = ɵMAX_SOCKET_RETRIES;
|
|
3861
3957
|
exports.ɵcreateThreadStore = createThreadStore;
|
|
3862
3958
|
exports.ɵjoinPhoenixChannel$ = ɵjoinPhoenixChannel$;
|
|
3863
3959
|
exports.ɵobservePhoenixEvent$ = ɵobservePhoenixEvent$;
|