@lambforge/agent-chat 0.0.2 → 0.0.3
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/agent-chat.js +39 -39
- package/dist/agent-chat.js.map +4 -4
- package/dist/index.cjs +289 -492
- package/dist/index.cjs.map +4 -4
- package/dist/index.mjs +286 -495
- package/dist/index.mjs.map +4 -4
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -4,12 +4,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, {
|
|
8
|
-
get: (a5, b2) => (typeof require !== "undefined" ? require : a5)[b2]
|
|
9
|
-
}) : x2)(function(x2) {
|
|
10
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
-
throw Error('Dynamic require of "' + x2 + '" is not supported');
|
|
12
|
-
});
|
|
13
7
|
var __esm = (fn, res, err) => function __init() {
|
|
14
8
|
if (err) throw err[0];
|
|
15
9
|
try {
|
|
@@ -18,7 +12,7 @@ var __esm = (fn, res, err) => function __init() {
|
|
|
18
12
|
throw err = [e16], e16;
|
|
19
13
|
}
|
|
20
14
|
};
|
|
21
|
-
var __commonJS = (cb, mod) => function
|
|
15
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
22
16
|
try {
|
|
23
17
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
24
18
|
} catch (e16) {
|
|
@@ -29,11 +23,11 @@ var __export = (target, all) => {
|
|
|
29
23
|
for (var name in all)
|
|
30
24
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
31
25
|
};
|
|
32
|
-
var __copyProps = (to,
|
|
33
|
-
if (
|
|
34
|
-
for (let key of __getOwnPropNames(
|
|
26
|
+
var __copyProps = (to, from3, except, desc) => {
|
|
27
|
+
if (from3 && typeof from3 === "object" || typeof from3 === "function") {
|
|
28
|
+
for (let key of __getOwnPropNames(from3))
|
|
35
29
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
36
|
-
__defProp(to, key, { get: () =>
|
|
30
|
+
__defProp(to, key, { get: () => from3[key], enumerable: !(desc = __getOwnPropDesc(from3, key)) || desc.enumerable });
|
|
37
31
|
}
|
|
38
32
|
return to;
|
|
39
33
|
};
|
|
@@ -2433,421 +2427,6 @@ var require_dist3 = __commonJS({
|
|
|
2433
2427
|
}
|
|
2434
2428
|
});
|
|
2435
2429
|
|
|
2436
|
-
// ../../node_modules/@rxdi/redux-store/dist/interfaces.js
|
|
2437
|
-
var require_interfaces = __commonJS({
|
|
2438
|
-
"../../node_modules/@rxdi/redux-store/dist/interfaces.js"(exports) {
|
|
2439
|
-
"use strict";
|
|
2440
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2441
|
-
exports.FlattenOperator = void 0;
|
|
2442
|
-
var FlattenOperator;
|
|
2443
|
-
(function(FlattenOperator2) {
|
|
2444
|
-
FlattenOperator2["switchMap"] = "switchMap";
|
|
2445
|
-
FlattenOperator2["mergeMap"] = "mergeMap";
|
|
2446
|
-
FlattenOperator2["concatMap"] = "concatMap";
|
|
2447
|
-
FlattenOperator2["exhaustMap"] = "exhaustMap";
|
|
2448
|
-
})(FlattenOperator || (exports.FlattenOperator = FlattenOperator = {}));
|
|
2449
|
-
}
|
|
2450
|
-
});
|
|
2451
|
-
|
|
2452
|
-
// ../../node_modules/@rxdi/redux-store/dist/utils.js
|
|
2453
|
-
var require_utils = __commonJS({
|
|
2454
|
-
"../../node_modules/@rxdi/redux-store/dist/utils.js"(exports) {
|
|
2455
|
-
"use strict";
|
|
2456
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2457
|
-
exports.mapToObservable = exports.flatCatch = exports.catchErr = exports.compose = exports.hasType = exports.isObject = void 0;
|
|
2458
|
-
exports.combineReducers = combineReducers;
|
|
2459
|
-
var rxjs_1 = __require("rxjs");
|
|
2460
|
-
var operators_1 = __require("rxjs/operators");
|
|
2461
|
-
var isObject = (value) => value !== null && typeof value === "object";
|
|
2462
|
-
exports.isObject = isObject;
|
|
2463
|
-
var hasType = (action2) => typeof action2.type === "string";
|
|
2464
|
-
exports.hasType = hasType;
|
|
2465
|
-
var compose = (fns) => fns.reduce((f4, g2) => (...args) => f4(g2(...args)));
|
|
2466
|
-
exports.compose = compose;
|
|
2467
|
-
exports.catchErr = (0, rxjs_1.pipe)((0, operators_1.catchError)((e16) => (0, rxjs_1.of)(e16)));
|
|
2468
|
-
var flatCatch = (o18) => o18.pipe(exports.catchErr);
|
|
2469
|
-
exports.flatCatch = flatCatch;
|
|
2470
|
-
var mapToObservable = (value) => {
|
|
2471
|
-
if ((0, rxjs_1.isObservable)(value))
|
|
2472
|
-
return value;
|
|
2473
|
-
if (value instanceof Promise)
|
|
2474
|
-
return (0, rxjs_1.from)(value);
|
|
2475
|
-
return (0, rxjs_1.of)(value);
|
|
2476
|
-
};
|
|
2477
|
-
exports.mapToObservable = mapToObservable;
|
|
2478
|
-
function combineReducers(reducers) {
|
|
2479
|
-
return (state = {}, action2) => {
|
|
2480
|
-
const { hasChanged, nextState } = Object.entries(reducers).reduce(({ hasChanged: hasChanged2, nextState: nextState2 }, [key, reducer2]) => {
|
|
2481
|
-
const prev = state[key];
|
|
2482
|
-
const next = reducer2(prev, action2);
|
|
2483
|
-
return {
|
|
2484
|
-
hasChanged: hasChanged2 || next !== prev,
|
|
2485
|
-
nextState: Object.assign(Object.assign({}, nextState2), { [key]: next })
|
|
2486
|
-
};
|
|
2487
|
-
}, { hasChanged: false, nextState: {} });
|
|
2488
|
-
return hasChanged ? nextState : state;
|
|
2489
|
-
};
|
|
2490
|
-
}
|
|
2491
|
-
}
|
|
2492
|
-
});
|
|
2493
|
-
|
|
2494
|
-
// ../../node_modules/@rxdi/redux-store/dist/reducer.factory.js
|
|
2495
|
-
var require_reducer_factory = __commonJS({
|
|
2496
|
-
"../../node_modules/@rxdi/redux-store/dist/reducer.factory.js"(exports) {
|
|
2497
|
-
"use strict";
|
|
2498
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2499
|
-
exports.reducerFactory$ = reducerFactory$;
|
|
2500
|
-
var operators_1 = __require("rxjs/operators");
|
|
2501
|
-
var utils_1 = require_utils();
|
|
2502
|
-
function reducerFactory$([initialState, reducer2, middleware]) {
|
|
2503
|
-
function _reducer(state, action2) {
|
|
2504
|
-
return middleware.length > 0 ? (0, utils_1.compose)(middleware)(reducer2)(state, action2) : reducer2(state, action2);
|
|
2505
|
-
}
|
|
2506
|
-
return (0, operators_1.scan)(_reducer, initialState);
|
|
2507
|
-
}
|
|
2508
|
-
}
|
|
2509
|
-
});
|
|
2510
|
-
|
|
2511
|
-
// ../../node_modules/@rxdi/redux-store/dist/defaults.js
|
|
2512
|
-
var require_defaults = __commonJS({
|
|
2513
|
-
"../../node_modules/@rxdi/redux-store/dist/defaults.js"(exports) {
|
|
2514
|
-
"use strict";
|
|
2515
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2516
|
-
exports.getDefaults = getDefaults;
|
|
2517
|
-
var rxjs_1 = __require("rxjs");
|
|
2518
|
-
var interfaces_1 = require_interfaces();
|
|
2519
|
-
var utils_1 = require_utils();
|
|
2520
|
-
var operators_1 = __require("rxjs/operators");
|
|
2521
|
-
var fop = {
|
|
2522
|
-
switchMap: operators_1.switchMap,
|
|
2523
|
-
mergeMap: operators_1.mergeMap,
|
|
2524
|
-
concatMap: operators_1.concatMap,
|
|
2525
|
-
exhaustMap: operators_1.exhaustMap
|
|
2526
|
-
};
|
|
2527
|
-
function getDefaults(config = {}, options = {}, dispatchSubject) {
|
|
2528
|
-
var _a;
|
|
2529
|
-
const reducer$ = config && config.reducer$ && config.reducer$.pipe(utils_1.catchErr) || (0, rxjs_1.of)((state, action2) => state);
|
|
2530
|
-
const actions$ = new rxjs_1.Subject();
|
|
2531
|
-
const actionStream$ = (reducer$2) => (0, rxjs_1.merge)(config && config.actionStream$ && config.actionStream$.pipe(utils_1.catchErr) || rxjs_1.EMPTY, dispatchSubject).pipe((0, operators_1.filter)(utils_1.isObject), (0, operators_1.map)(utils_1.mapToObservable), actionFlatten(utils_1.flatCatch), (0, operators_1.tap)(actions$), reducer$2, (0, operators_1.map)(utils_1.mapToObservable));
|
|
2532
|
-
const initialState$ = (config && config.initialState$ && config.initialState$.pipe(utils_1.catchErr) || (0, rxjs_1.of)({})).pipe((0, operators_1.share)());
|
|
2533
|
-
const middleware$ = config && config.middleware$ && config.middleware$.pipe(utils_1.catchErr) || (0, rxjs_1.of)([]);
|
|
2534
|
-
const destroy$ = ((_a = config === null || config === void 0 ? void 0 : config.destroy$) === null || _a === void 0 ? void 0 : _a.pipe(utils_1.catchErr)) || rxjs_1.NEVER;
|
|
2535
|
-
const actionFlatten = fop[options && options.actionFlatOp || interfaces_1.FlattenOperator.concatMap];
|
|
2536
|
-
const stateFlatten = fop[options && options.stateFlatOp || interfaces_1.FlattenOperator.switchMap];
|
|
2537
|
-
const flattenState$ = (source) => source.pipe(stateFlatten(utils_1.flatCatch), (0, operators_1.map)(utils_1.mapToObservable), stateFlatten(utils_1.flatCatch));
|
|
2538
|
-
const bufferSize = options && options.bufferSize || 1;
|
|
2539
|
-
const windowTime = options && options.windowTime;
|
|
2540
|
-
const shareReplayConfig = {
|
|
2541
|
-
refCount: false,
|
|
2542
|
-
bufferSize,
|
|
2543
|
-
windowTime
|
|
2544
|
-
};
|
|
2545
|
-
return {
|
|
2546
|
-
reducer$,
|
|
2547
|
-
actions$,
|
|
2548
|
-
actionStream$,
|
|
2549
|
-
initialState$,
|
|
2550
|
-
middleware$,
|
|
2551
|
-
destroy$,
|
|
2552
|
-
flattenState$,
|
|
2553
|
-
shareReplayConfig
|
|
2554
|
-
};
|
|
2555
|
-
}
|
|
2556
|
-
}
|
|
2557
|
-
});
|
|
2558
|
-
|
|
2559
|
-
// ../../node_modules/@rxdi/redux-store/dist/devtools.js
|
|
2560
|
-
var require_devtools = __commonJS({
|
|
2561
|
-
"../../node_modules/@rxdi/redux-store/dist/devtools.js"(exports) {
|
|
2562
|
-
"use strict";
|
|
2563
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2564
|
-
exports.DEVTOOLS_JUMP_TO_STATE = void 0;
|
|
2565
|
-
exports.normalizeDevToolsConfig = normalizeDevToolsConfig;
|
|
2566
|
-
exports.withDevToolsTimeTravel = withDevToolsTimeTravel;
|
|
2567
|
-
exports.connectReduxDevTools = connectReduxDevTools;
|
|
2568
|
-
var rxjs_1 = __require("rxjs");
|
|
2569
|
-
var operators_1 = __require("rxjs/operators");
|
|
2570
|
-
exports.DEVTOOLS_JUMP_TO_STATE = "@@redux-devtools/JUMP_TO_STATE";
|
|
2571
|
-
function normalizeDevToolsConfig(config) {
|
|
2572
|
-
if (!config) {
|
|
2573
|
-
return void 0;
|
|
2574
|
-
}
|
|
2575
|
-
const options = config === true ? {} : config;
|
|
2576
|
-
return options.enabled === false ? void 0 : options;
|
|
2577
|
-
}
|
|
2578
|
-
function withDevToolsTimeTravel(reducerFn) {
|
|
2579
|
-
return (state, action2) => (action2 === null || action2 === void 0 ? void 0 : action2.type) === exports.DEVTOOLS_JUMP_TO_STATE ? action2.state : reducerFn(state, action2);
|
|
2580
|
-
}
|
|
2581
|
-
function connectReduxDevTools(store, options = {}) {
|
|
2582
|
-
var _a, _b;
|
|
2583
|
-
const extension = globalThis.__REDUX_DEVTOOLS_EXTENSION__;
|
|
2584
|
-
if (options.enabled === false || !extension) {
|
|
2585
|
-
return () => void 0;
|
|
2586
|
-
}
|
|
2587
|
-
const devTools = extension.connect(Object.assign({ name: (_a = options.name) !== null && _a !== void 0 ? _a : "RxDI Store", maxAge: (_b = options.maxAge) !== null && _b !== void 0 ? _b : 50 }, options.extensionOptions));
|
|
2588
|
-
const subscription = new rxjs_1.Subscription();
|
|
2589
|
-
let currentState;
|
|
2590
|
-
subscription.add(store.state$.subscribe((state) => {
|
|
2591
|
-
currentState = state;
|
|
2592
|
-
}));
|
|
2593
|
-
devTools.init(currentState);
|
|
2594
|
-
subscription.add(store.state$.pipe(
|
|
2595
|
-
(0, operators_1.withLatestFrom)(store.actions$),
|
|
2596
|
-
// Jumps come from the DevTools UI — echoing them back would
|
|
2597
|
-
// pollute the action log.
|
|
2598
|
-
(0, operators_1.filter)(([, action2]) => action2.type !== exports.DEVTOOLS_JUMP_TO_STATE)
|
|
2599
|
-
).subscribe(([state, action2]) => devTools.send(action2, state)));
|
|
2600
|
-
const unsubscribeMessages = devTools.subscribe((message) => {
|
|
2601
|
-
var _a2;
|
|
2602
|
-
if (message.type !== "DISPATCH") {
|
|
2603
|
-
return;
|
|
2604
|
-
}
|
|
2605
|
-
const kind = (_a2 = message.payload) === null || _a2 === void 0 ? void 0 : _a2.type;
|
|
2606
|
-
if ((kind === "JUMP_TO_ACTION" || kind === "JUMP_TO_STATE") && message.state) {
|
|
2607
|
-
store.dispatch({
|
|
2608
|
-
type: exports.DEVTOOLS_JUMP_TO_STATE,
|
|
2609
|
-
state: JSON.parse(message.state)
|
|
2610
|
-
});
|
|
2611
|
-
} else if (kind === "COMMIT") {
|
|
2612
|
-
devTools.init(currentState);
|
|
2613
|
-
}
|
|
2614
|
-
});
|
|
2615
|
-
return () => {
|
|
2616
|
-
var _a2;
|
|
2617
|
-
subscription.unsubscribe();
|
|
2618
|
-
if (typeof unsubscribeMessages === "function") {
|
|
2619
|
-
unsubscribeMessages();
|
|
2620
|
-
}
|
|
2621
|
-
(_a2 = devTools.unsubscribe) === null || _a2 === void 0 ? void 0 : _a2.call(devTools);
|
|
2622
|
-
};
|
|
2623
|
-
}
|
|
2624
|
-
}
|
|
2625
|
-
});
|
|
2626
|
-
|
|
2627
|
-
// ../../node_modules/@rxdi/redux-store/dist/store.js
|
|
2628
|
-
var require_store = __commonJS({
|
|
2629
|
-
"../../node_modules/@rxdi/redux-store/dist/store.js"(exports) {
|
|
2630
|
-
"use strict";
|
|
2631
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2632
|
-
exports.Store = void 0;
|
|
2633
|
-
exports.createStore = createStore2;
|
|
2634
|
-
var rxjs_1 = __require("rxjs");
|
|
2635
|
-
var operators_1 = __require("rxjs/operators");
|
|
2636
|
-
var reducer_factory_1 = require_reducer_factory();
|
|
2637
|
-
var defaults_1 = require_defaults();
|
|
2638
|
-
var devtools_1 = require_devtools();
|
|
2639
|
-
var Store2 = class {
|
|
2640
|
-
/**
|
|
2641
|
-
* Default configuration
|
|
2642
|
-
*
|
|
2643
|
-
* @param {Object} config
|
|
2644
|
-
* {
|
|
2645
|
-
* reducer$: of(reducer({})),
|
|
2646
|
-
* actionStream$: EMPTY, // if not defined, no actions will be dispatched in the store
|
|
2647
|
-
* initialState$: of({}),
|
|
2648
|
-
* middleware$: of([]),
|
|
2649
|
-
* destroy$: NEVER // if not defined, the state subscription will live forever
|
|
2650
|
-
* }
|
|
2651
|
-
*
|
|
2652
|
-
* @param {Object} options
|
|
2653
|
-
* {
|
|
2654
|
-
* actionFop: FlattenOps.concatMap, // Flatten operator for actions's stream.
|
|
2655
|
-
* stateFop: FlattenOps.switchMap // Flatten operator for state's stream.
|
|
2656
|
-
* windowTime: undefined //Maximum time length of the replay buffer in milliseconds.
|
|
2657
|
-
* bufferSize: 1 //Maximum element count of the replay buffer.
|
|
2658
|
-
* }
|
|
2659
|
-
*/
|
|
2660
|
-
constructor(config, options) {
|
|
2661
|
-
var _a, _b, _c, _d;
|
|
2662
|
-
this.config = config;
|
|
2663
|
-
this.options = options;
|
|
2664
|
-
this._dispatch$ = new rxjs_1.Subject();
|
|
2665
|
-
this.dispatch = (action2) => {
|
|
2666
|
-
this._dispatch$.next(action2);
|
|
2667
|
-
};
|
|
2668
|
-
const devToolsOptions = (0, devtools_1.normalizeDevToolsConfig)((_a = this.config) === null || _a === void 0 ? void 0 : _a.devTools);
|
|
2669
|
-
if (devToolsOptions) {
|
|
2670
|
-
this.config = Object.assign(Object.assign({}, this.config), { reducer$: ((_c = (_b = this.config) === null || _b === void 0 ? void 0 : _b.reducer$) !== null && _c !== void 0 ? _c : (0, rxjs_1.of)((state) => state)).pipe((0, operators_1.map)((reducerFn) => (0, devtools_1.withDevToolsTimeTravel)(reducerFn))) });
|
|
2671
|
-
}
|
|
2672
|
-
const { reducer$, actions$, actionStream$, middleware$, initialState$, destroy$, flattenState$, shareReplayConfig } = (0, defaults_1.getDefaults)(this.config, this.options, this._dispatch$);
|
|
2673
|
-
this.state$ = (0, rxjs_1.combineLatest)([initialState$, reducer$, middleware$]).pipe((0, operators_1.map)(reducer_factory_1.reducerFactory$), (0, operators_1.concatMap)(actionStream$), (0, operators_1.startWith)(initialState$), flattenState$, (0, operators_1.takeUntil)(destroy$), (0, operators_1.shareReplay)(shareReplayConfig));
|
|
2674
|
-
this.state$.subscribe();
|
|
2675
|
-
this.actions$ = actions$.pipe((0, operators_1.shareReplay)(shareReplayConfig));
|
|
2676
|
-
if ((_d = this.config) === null || _d === void 0 ? void 0 : _d.epic$) {
|
|
2677
|
-
this.config.epic$(this.actions$, this.state$).pipe((0, operators_1.takeUntil)(destroy$)).subscribe({
|
|
2678
|
-
next: (action2) => this.dispatch(action2),
|
|
2679
|
-
error: (err) => console.error("[Epic] Error:", err)
|
|
2680
|
-
});
|
|
2681
|
-
}
|
|
2682
|
-
if (devToolsOptions) {
|
|
2683
|
-
const disconnect = (0, devtools_1.connectReduxDevTools)(this, devToolsOptions);
|
|
2684
|
-
destroy$.subscribe(() => disconnect());
|
|
2685
|
-
}
|
|
2686
|
-
}
|
|
2687
|
-
};
|
|
2688
|
-
exports.Store = Store2;
|
|
2689
|
-
function createStore2(config = {}, opts = {}) {
|
|
2690
|
-
return new Store2(config, opts);
|
|
2691
|
-
}
|
|
2692
|
-
}
|
|
2693
|
-
});
|
|
2694
|
-
|
|
2695
|
-
// ../../node_modules/@rxdi/redux-store/dist/middleware.js
|
|
2696
|
-
var require_middleware = __commonJS({
|
|
2697
|
-
"../../node_modules/@rxdi/redux-store/dist/middleware.js"(exports) {
|
|
2698
|
-
"use strict";
|
|
2699
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2700
|
-
exports.reduceA = exports.reduceNS = exports.reducePS = exports.filterA = exports.filterNS = exports.filterPS = exports.mapA = exports.mapNS = exports.mapPS = void 0;
|
|
2701
|
-
var mapPS = (mapFn) => (reducer2) => (state, Action) => reducer2(mapFn(state), Action);
|
|
2702
|
-
exports.mapPS = mapPS;
|
|
2703
|
-
var mapNS = (mapFn) => (reducer2) => (state, Action) => mapFn(reducer2(state, Action));
|
|
2704
|
-
exports.mapNS = mapNS;
|
|
2705
|
-
var mapA = (mapFn) => (reducer2) => (state, Action) => reducer2(state, mapFn(Action));
|
|
2706
|
-
exports.mapA = mapA;
|
|
2707
|
-
var filterPS = (filterFn) => (reducer2) => (state, Action) => {
|
|
2708
|
-
return filterFn(state) ? reducer2(state, Action) : state;
|
|
2709
|
-
};
|
|
2710
|
-
exports.filterPS = filterPS;
|
|
2711
|
-
var filterNS = (filterFn) => (reducer2) => (state, Action) => {
|
|
2712
|
-
const nextState = reducer2(state, Action);
|
|
2713
|
-
return filterFn(nextState) ? nextState : state;
|
|
2714
|
-
};
|
|
2715
|
-
exports.filterNS = filterNS;
|
|
2716
|
-
var filterA = (filterFn) => (reducer2) => (state, Action) => {
|
|
2717
|
-
return filterFn(Action) ? reducer2(state, Action) : state;
|
|
2718
|
-
};
|
|
2719
|
-
exports.filterA = filterA;
|
|
2720
|
-
var reducePS = (reducerFn) => (reducer2) => (state, Action) => {
|
|
2721
|
-
return reducer2(reducerFn(state, Action), Action);
|
|
2722
|
-
};
|
|
2723
|
-
exports.reducePS = reducePS;
|
|
2724
|
-
var reduceNS = (reducerFn) => (reducer2) => (state, Action) => {
|
|
2725
|
-
return reducerFn(reducer2(state, Action), Action);
|
|
2726
|
-
};
|
|
2727
|
-
exports.reduceNS = reduceNS;
|
|
2728
|
-
var reduceA = (reducerFn) => (reducer2) => (state, Action) => {
|
|
2729
|
-
return reducer2(state, reducerFn(state, Action));
|
|
2730
|
-
};
|
|
2731
|
-
exports.reduceA = reduceA;
|
|
2732
|
-
}
|
|
2733
|
-
});
|
|
2734
|
-
|
|
2735
|
-
// ../../node_modules/@rxdi/redux-store/dist/effects.js
|
|
2736
|
-
var require_effects = __commonJS({
|
|
2737
|
-
"../../node_modules/@rxdi/redux-store/dist/effects.js"(exports) {
|
|
2738
|
-
"use strict";
|
|
2739
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2740
|
-
exports.ofType = ofType2;
|
|
2741
|
-
exports.createEffect = createEffect2;
|
|
2742
|
-
exports.createSubscriptionEffect = createSubscriptionEffect;
|
|
2743
|
-
exports.createEpicRegistry = createEpicRegistry2;
|
|
2744
|
-
exports.createEffectRegistry = createEpicRegistry2;
|
|
2745
|
-
var rxjs_1 = __require("rxjs");
|
|
2746
|
-
var operators_1 = __require("rxjs/operators");
|
|
2747
|
-
function ofType2(...actionCreators) {
|
|
2748
|
-
return (action$) => {
|
|
2749
|
-
return action$.pipe((0, operators_1.filter)((action2) => actionCreators.some((creator) => creator.type === action2.type)));
|
|
2750
|
-
};
|
|
2751
|
-
}
|
|
2752
|
-
function createEffect2(options = { dispatch: true }) {
|
|
2753
|
-
return (effectFactory) => {
|
|
2754
|
-
return (action$, state$) => {
|
|
2755
|
-
const mappedEffect$ = effectFactory(action$, state$);
|
|
2756
|
-
if (!options.dispatch) {
|
|
2757
|
-
return mappedEffect$.pipe((0, operators_1.ignoreElements)(), (0, operators_1.catchError)((error) => {
|
|
2758
|
-
console.error("[Effect] Error:", error);
|
|
2759
|
-
return (0, rxjs_1.of)();
|
|
2760
|
-
}));
|
|
2761
|
-
}
|
|
2762
|
-
return mappedEffect$.pipe((0, operators_1.catchError)((error) => {
|
|
2763
|
-
console.error("[Effect] Error:", error);
|
|
2764
|
-
return (0, rxjs_1.of)();
|
|
2765
|
-
}));
|
|
2766
|
-
};
|
|
2767
|
-
};
|
|
2768
|
-
}
|
|
2769
|
-
function createSubscriptionEffect(destroy$) {
|
|
2770
|
-
return (effectFactory) => {
|
|
2771
|
-
return (action$, state$) => {
|
|
2772
|
-
return effectFactory(action$, state$).pipe((0, operators_1.takeUntil)(destroy$), (0, operators_1.catchError)((error) => {
|
|
2773
|
-
console.error("[Effect] Error:", error);
|
|
2774
|
-
return (0, rxjs_1.of)();
|
|
2775
|
-
}));
|
|
2776
|
-
};
|
|
2777
|
-
};
|
|
2778
|
-
}
|
|
2779
|
-
function createEpicRegistry2(...effects) {
|
|
2780
|
-
return (action$, state$) => {
|
|
2781
|
-
return (0, rxjs_1.merge)(...effects.map((effect) => effect(action$, state$)));
|
|
2782
|
-
};
|
|
2783
|
-
}
|
|
2784
|
-
}
|
|
2785
|
-
});
|
|
2786
|
-
|
|
2787
|
-
// ../../node_modules/@rxdi/redux-store/dist/index.js
|
|
2788
|
-
var require_dist4 = __commonJS({
|
|
2789
|
-
"../../node_modules/@rxdi/redux-store/dist/index.js"(exports) {
|
|
2790
|
-
"use strict";
|
|
2791
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o18, m4, k2, k22) {
|
|
2792
|
-
if (k22 === void 0) k22 = k2;
|
|
2793
|
-
var desc = Object.getOwnPropertyDescriptor(m4, k2);
|
|
2794
|
-
if (!desc || ("get" in desc ? !m4.__esModule : desc.writable || desc.configurable)) {
|
|
2795
|
-
desc = { enumerable: true, get: function() {
|
|
2796
|
-
return m4[k2];
|
|
2797
|
-
} };
|
|
2798
|
-
}
|
|
2799
|
-
Object.defineProperty(o18, k22, desc);
|
|
2800
|
-
}) : (function(o18, m4, k2, k22) {
|
|
2801
|
-
if (k22 === void 0) k22 = k2;
|
|
2802
|
-
o18[k22] = m4[k2];
|
|
2803
|
-
}));
|
|
2804
|
-
var __exportStar = exports && exports.__exportStar || function(m4, exports2) {
|
|
2805
|
-
for (var p4 in m4) if (p4 !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p4)) __createBinding(exports2, m4, p4);
|
|
2806
|
-
};
|
|
2807
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2808
|
-
exports.combineReducers = exports.flatCatch = exports.catchErr = exports.mapToObservable = exports.DEVTOOLS_JUMP_TO_STATE = exports.normalizeDevToolsConfig = exports.withDevToolsTimeTravel = exports.connectReduxDevTools = exports.createStore = exports.Store = exports.FlattenOperator = void 0;
|
|
2809
|
-
var interfaces_1 = require_interfaces();
|
|
2810
|
-
Object.defineProperty(exports, "FlattenOperator", { enumerable: true, get: function() {
|
|
2811
|
-
return interfaces_1.FlattenOperator;
|
|
2812
|
-
} });
|
|
2813
|
-
var store_1 = require_store();
|
|
2814
|
-
Object.defineProperty(exports, "Store", { enumerable: true, get: function() {
|
|
2815
|
-
return store_1.Store;
|
|
2816
|
-
} });
|
|
2817
|
-
Object.defineProperty(exports, "createStore", { enumerable: true, get: function() {
|
|
2818
|
-
return store_1.createStore;
|
|
2819
|
-
} });
|
|
2820
|
-
var devtools_1 = require_devtools();
|
|
2821
|
-
Object.defineProperty(exports, "connectReduxDevTools", { enumerable: true, get: function() {
|
|
2822
|
-
return devtools_1.connectReduxDevTools;
|
|
2823
|
-
} });
|
|
2824
|
-
Object.defineProperty(exports, "withDevToolsTimeTravel", { enumerable: true, get: function() {
|
|
2825
|
-
return devtools_1.withDevToolsTimeTravel;
|
|
2826
|
-
} });
|
|
2827
|
-
Object.defineProperty(exports, "normalizeDevToolsConfig", { enumerable: true, get: function() {
|
|
2828
|
-
return devtools_1.normalizeDevToolsConfig;
|
|
2829
|
-
} });
|
|
2830
|
-
Object.defineProperty(exports, "DEVTOOLS_JUMP_TO_STATE", { enumerable: true, get: function() {
|
|
2831
|
-
return devtools_1.DEVTOOLS_JUMP_TO_STATE;
|
|
2832
|
-
} });
|
|
2833
|
-
var utils_1 = require_utils();
|
|
2834
|
-
Object.defineProperty(exports, "mapToObservable", { enumerable: true, get: function() {
|
|
2835
|
-
return utils_1.mapToObservable;
|
|
2836
|
-
} });
|
|
2837
|
-
Object.defineProperty(exports, "catchErr", { enumerable: true, get: function() {
|
|
2838
|
-
return utils_1.catchErr;
|
|
2839
|
-
} });
|
|
2840
|
-
Object.defineProperty(exports, "flatCatch", { enumerable: true, get: function() {
|
|
2841
|
-
return utils_1.flatCatch;
|
|
2842
|
-
} });
|
|
2843
|
-
Object.defineProperty(exports, "combineReducers", { enumerable: true, get: function() {
|
|
2844
|
-
return utils_1.combineReducers;
|
|
2845
|
-
} });
|
|
2846
|
-
__exportStar(require_middleware(), exports);
|
|
2847
|
-
__exportStar(require_effects(), exports);
|
|
2848
|
-
}
|
|
2849
|
-
});
|
|
2850
|
-
|
|
2851
2430
|
// src/element.ts
|
|
2852
2431
|
var import_component = __toESM(require_dist3());
|
|
2853
2432
|
var import_lit_html19 = __toESM(require_dist());
|
|
@@ -3011,13 +2590,13 @@ function reducer(initialState) {
|
|
|
3011
2590
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
3012
2591
|
ons[_i - 1] = arguments[_i];
|
|
3013
2592
|
}
|
|
3014
|
-
var
|
|
2593
|
+
var map4 = /* @__PURE__ */ new Map();
|
|
3015
2594
|
for (var _a = 0, ons_1 = ons; _a < ons_1.length; _a++) {
|
|
3016
2595
|
var on_1 = ons_1[_a];
|
|
3017
2596
|
for (var _b = 0, _c = on_1.types; _b < _c.length; _b++) {
|
|
3018
2597
|
var type = _c[_b];
|
|
3019
|
-
if (!
|
|
3020
|
-
|
|
2598
|
+
if (!map4.has(type)) {
|
|
2599
|
+
map4.set(type, on_1.reducer);
|
|
3021
2600
|
} else {
|
|
3022
2601
|
console.warn(type + " already specified in an 'on' call.");
|
|
3023
2602
|
}
|
|
@@ -3027,7 +2606,7 @@ function reducer(initialState) {
|
|
|
3027
2606
|
if (state === void 0) {
|
|
3028
2607
|
state = initialState;
|
|
3029
2608
|
}
|
|
3030
|
-
var reducer2 =
|
|
2609
|
+
var reducer2 = map4.get(action2.type);
|
|
3031
2610
|
return reducer2 ? reducer2(state, action2) : state;
|
|
3032
2611
|
};
|
|
3033
2612
|
}
|
|
@@ -3056,24 +2635,243 @@ var agentEvent = action("[chat] event", payload());
|
|
|
3056
2635
|
var runEnded = action("[chat] run ended");
|
|
3057
2636
|
var stop = action("[chat] stop", payload());
|
|
3058
2637
|
|
|
2638
|
+
// ../../node_modules/@rxdi/redux-store/dist/esm/interfaces.js
|
|
2639
|
+
var FlattenOperator;
|
|
2640
|
+
(function(FlattenOperator2) {
|
|
2641
|
+
FlattenOperator2["switchMap"] = "switchMap";
|
|
2642
|
+
FlattenOperator2["mergeMap"] = "mergeMap";
|
|
2643
|
+
FlattenOperator2["concatMap"] = "concatMap";
|
|
2644
|
+
FlattenOperator2["exhaustMap"] = "exhaustMap";
|
|
2645
|
+
})(FlattenOperator || (FlattenOperator = {}));
|
|
2646
|
+
|
|
2647
|
+
// ../../node_modules/@rxdi/redux-store/dist/esm/store.js
|
|
2648
|
+
import { combineLatest, Subject as Subject2, of as of3 } from "rxjs";
|
|
2649
|
+
import { startWith, shareReplay, takeUntil, concatMap as concatMap2, map as map2 } from "rxjs/operators";
|
|
2650
|
+
|
|
2651
|
+
// ../../node_modules/@rxdi/redux-store/dist/esm/reducer.factory.js
|
|
2652
|
+
import { scan } from "rxjs/operators";
|
|
2653
|
+
|
|
2654
|
+
// ../../node_modules/@rxdi/redux-store/dist/esm/utils.js
|
|
2655
|
+
import { pipe, from, of, isObservable } from "rxjs";
|
|
2656
|
+
import { catchError } from "rxjs/operators";
|
|
2657
|
+
var isObject = (value) => value !== null && typeof value === "object";
|
|
2658
|
+
var compose = (fns) => fns.reduce((f4, g2) => (...args) => f4(g2(...args)));
|
|
2659
|
+
var catchErr = pipe(catchError((e16) => of(e16)));
|
|
2660
|
+
var flatCatch = (o18) => o18.pipe(catchErr);
|
|
2661
|
+
var mapToObservable = (value) => {
|
|
2662
|
+
if (isObservable(value))
|
|
2663
|
+
return value;
|
|
2664
|
+
if (value instanceof Promise)
|
|
2665
|
+
return from(value);
|
|
2666
|
+
return of(value);
|
|
2667
|
+
};
|
|
2668
|
+
|
|
2669
|
+
// ../../node_modules/@rxdi/redux-store/dist/esm/reducer.factory.js
|
|
2670
|
+
function reducerFactory$([initialState, reducer2, middleware]) {
|
|
2671
|
+
function _reducer(state, action2) {
|
|
2672
|
+
return middleware.length > 0 ? compose(middleware)(reducer2)(state, action2) : reducer2(state, action2);
|
|
2673
|
+
}
|
|
2674
|
+
return scan(_reducer, initialState);
|
|
2675
|
+
}
|
|
2676
|
+
|
|
2677
|
+
// ../../node_modules/@rxdi/redux-store/dist/esm/defaults.js
|
|
2678
|
+
import { of as of2, EMPTY, NEVER, Subject, merge } from "rxjs";
|
|
2679
|
+
import { switchMap, mergeMap, concatMap, exhaustMap, map, share, filter, tap } from "rxjs/operators";
|
|
2680
|
+
var fop = {
|
|
2681
|
+
switchMap,
|
|
2682
|
+
mergeMap,
|
|
2683
|
+
concatMap,
|
|
2684
|
+
exhaustMap
|
|
2685
|
+
};
|
|
2686
|
+
function getDefaults(config = {}, options = {}, dispatchSubject) {
|
|
2687
|
+
var _a;
|
|
2688
|
+
const reducer$ = config && config.reducer$ && config.reducer$.pipe(catchErr) || of2((state, action2) => state);
|
|
2689
|
+
const actions$ = new Subject();
|
|
2690
|
+
const actionStream$ = (reducer$2) => merge(config && config.actionStream$ && config.actionStream$.pipe(catchErr) || EMPTY, dispatchSubject).pipe(filter(isObject), map(mapToObservable), actionFlatten(flatCatch), tap(actions$), reducer$2, map(mapToObservable));
|
|
2691
|
+
const initialState$ = (config && config.initialState$ && config.initialState$.pipe(catchErr) || of2({})).pipe(share());
|
|
2692
|
+
const middleware$ = config && config.middleware$ && config.middleware$.pipe(catchErr) || of2([]);
|
|
2693
|
+
const destroy$ = ((_a = config === null || config === void 0 ? void 0 : config.destroy$) === null || _a === void 0 ? void 0 : _a.pipe(catchErr)) || NEVER;
|
|
2694
|
+
const actionFlatten = fop[options && options.actionFlatOp || FlattenOperator.concatMap];
|
|
2695
|
+
const stateFlatten = fop[options && options.stateFlatOp || FlattenOperator.switchMap];
|
|
2696
|
+
const flattenState$ = (source) => source.pipe(stateFlatten(flatCatch), map(mapToObservable), stateFlatten(flatCatch));
|
|
2697
|
+
const bufferSize = options && options.bufferSize || 1;
|
|
2698
|
+
const windowTime = options && options.windowTime;
|
|
2699
|
+
const shareReplayConfig = {
|
|
2700
|
+
refCount: false,
|
|
2701
|
+
bufferSize,
|
|
2702
|
+
windowTime
|
|
2703
|
+
};
|
|
2704
|
+
return {
|
|
2705
|
+
reducer$,
|
|
2706
|
+
actions$,
|
|
2707
|
+
actionStream$,
|
|
2708
|
+
initialState$,
|
|
2709
|
+
middleware$,
|
|
2710
|
+
destroy$,
|
|
2711
|
+
flattenState$,
|
|
2712
|
+
shareReplayConfig
|
|
2713
|
+
};
|
|
2714
|
+
}
|
|
2715
|
+
|
|
2716
|
+
// ../../node_modules/@rxdi/redux-store/dist/esm/devtools.js
|
|
2717
|
+
import { Subscription } from "rxjs";
|
|
2718
|
+
import { filter as filter2, withLatestFrom } from "rxjs/operators";
|
|
2719
|
+
var DEVTOOLS_JUMP_TO_STATE = "@@redux-devtools/JUMP_TO_STATE";
|
|
2720
|
+
function normalizeDevToolsConfig(config) {
|
|
2721
|
+
if (!config) {
|
|
2722
|
+
return void 0;
|
|
2723
|
+
}
|
|
2724
|
+
const options = config === true ? {} : config;
|
|
2725
|
+
return options.enabled === false ? void 0 : options;
|
|
2726
|
+
}
|
|
2727
|
+
function withDevToolsTimeTravel(reducerFn) {
|
|
2728
|
+
return (state, action2) => (action2 === null || action2 === void 0 ? void 0 : action2.type) === DEVTOOLS_JUMP_TO_STATE ? action2.state : reducerFn(state, action2);
|
|
2729
|
+
}
|
|
2730
|
+
function connectReduxDevTools(store, options = {}) {
|
|
2731
|
+
var _a, _b;
|
|
2732
|
+
const extension = globalThis.__REDUX_DEVTOOLS_EXTENSION__;
|
|
2733
|
+
if (options.enabled === false || !extension) {
|
|
2734
|
+
return () => void 0;
|
|
2735
|
+
}
|
|
2736
|
+
const devTools = extension.connect(Object.assign({ name: (_a = options.name) !== null && _a !== void 0 ? _a : "RxDI Store", maxAge: (_b = options.maxAge) !== null && _b !== void 0 ? _b : 50 }, options.extensionOptions));
|
|
2737
|
+
const subscription = new Subscription();
|
|
2738
|
+
let currentState;
|
|
2739
|
+
subscription.add(store.state$.subscribe((state) => {
|
|
2740
|
+
currentState = state;
|
|
2741
|
+
}));
|
|
2742
|
+
devTools.init(currentState);
|
|
2743
|
+
subscription.add(store.state$.pipe(
|
|
2744
|
+
withLatestFrom(store.actions$),
|
|
2745
|
+
// Jumps come from the DevTools UI — echoing them back would
|
|
2746
|
+
// pollute the action log.
|
|
2747
|
+
filter2(([, action2]) => action2.type !== DEVTOOLS_JUMP_TO_STATE)
|
|
2748
|
+
).subscribe(([state, action2]) => devTools.send(action2, state)));
|
|
2749
|
+
const unsubscribeMessages = devTools.subscribe((message) => {
|
|
2750
|
+
var _a2;
|
|
2751
|
+
if (message.type !== "DISPATCH") {
|
|
2752
|
+
return;
|
|
2753
|
+
}
|
|
2754
|
+
const kind = (_a2 = message.payload) === null || _a2 === void 0 ? void 0 : _a2.type;
|
|
2755
|
+
if ((kind === "JUMP_TO_ACTION" || kind === "JUMP_TO_STATE") && message.state) {
|
|
2756
|
+
store.dispatch({
|
|
2757
|
+
type: DEVTOOLS_JUMP_TO_STATE,
|
|
2758
|
+
state: JSON.parse(message.state)
|
|
2759
|
+
});
|
|
2760
|
+
} else if (kind === "COMMIT") {
|
|
2761
|
+
devTools.init(currentState);
|
|
2762
|
+
}
|
|
2763
|
+
});
|
|
2764
|
+
return () => {
|
|
2765
|
+
var _a2;
|
|
2766
|
+
subscription.unsubscribe();
|
|
2767
|
+
if (typeof unsubscribeMessages === "function") {
|
|
2768
|
+
unsubscribeMessages();
|
|
2769
|
+
}
|
|
2770
|
+
(_a2 = devTools.unsubscribe) === null || _a2 === void 0 ? void 0 : _a2.call(devTools);
|
|
2771
|
+
};
|
|
2772
|
+
}
|
|
2773
|
+
|
|
2774
|
+
// ../../node_modules/@rxdi/redux-store/dist/esm/store.js
|
|
2775
|
+
var Store = class {
|
|
2776
|
+
/**
|
|
2777
|
+
* Default configuration
|
|
2778
|
+
*
|
|
2779
|
+
* @param {Object} config
|
|
2780
|
+
* {
|
|
2781
|
+
* reducer$: of(reducer({})),
|
|
2782
|
+
* actionStream$: EMPTY, // if not defined, no actions will be dispatched in the store
|
|
2783
|
+
* initialState$: of({}),
|
|
2784
|
+
* middleware$: of([]),
|
|
2785
|
+
* destroy$: NEVER // if not defined, the state subscription will live forever
|
|
2786
|
+
* }
|
|
2787
|
+
*
|
|
2788
|
+
* @param {Object} options
|
|
2789
|
+
* {
|
|
2790
|
+
* actionFop: FlattenOps.concatMap, // Flatten operator for actions's stream.
|
|
2791
|
+
* stateFop: FlattenOps.switchMap // Flatten operator for state's stream.
|
|
2792
|
+
* windowTime: undefined //Maximum time length of the replay buffer in milliseconds.
|
|
2793
|
+
* bufferSize: 1 //Maximum element count of the replay buffer.
|
|
2794
|
+
* }
|
|
2795
|
+
*/
|
|
2796
|
+
constructor(config, options) {
|
|
2797
|
+
var _a, _b, _c, _d;
|
|
2798
|
+
this.config = config;
|
|
2799
|
+
this.options = options;
|
|
2800
|
+
this._dispatch$ = new Subject2();
|
|
2801
|
+
this.dispatch = (action2) => {
|
|
2802
|
+
this._dispatch$.next(action2);
|
|
2803
|
+
};
|
|
2804
|
+
const devToolsOptions = normalizeDevToolsConfig((_a = this.config) === null || _a === void 0 ? void 0 : _a.devTools);
|
|
2805
|
+
if (devToolsOptions) {
|
|
2806
|
+
this.config = Object.assign(Object.assign({}, this.config), { reducer$: ((_c = (_b = this.config) === null || _b === void 0 ? void 0 : _b.reducer$) !== null && _c !== void 0 ? _c : of3((state) => state)).pipe(map2((reducerFn) => withDevToolsTimeTravel(reducerFn))) });
|
|
2807
|
+
}
|
|
2808
|
+
const { reducer$, actions$, actionStream$, middleware$, initialState$, destroy$, flattenState$, shareReplayConfig } = getDefaults(this.config, this.options, this._dispatch$);
|
|
2809
|
+
this.state$ = combineLatest([initialState$, reducer$, middleware$]).pipe(map2(reducerFactory$), concatMap2(actionStream$), startWith(initialState$), flattenState$, takeUntil(destroy$), shareReplay(shareReplayConfig));
|
|
2810
|
+
this.state$.subscribe();
|
|
2811
|
+
this.actions$ = actions$.pipe(shareReplay(shareReplayConfig));
|
|
2812
|
+
if ((_d = this.config) === null || _d === void 0 ? void 0 : _d.epic$) {
|
|
2813
|
+
this.config.epic$(this.actions$, this.state$).pipe(takeUntil(destroy$)).subscribe({
|
|
2814
|
+
next: (action2) => this.dispatch(action2),
|
|
2815
|
+
error: (err) => console.error("[Epic] Error:", err)
|
|
2816
|
+
});
|
|
2817
|
+
}
|
|
2818
|
+
if (devToolsOptions) {
|
|
2819
|
+
const disconnect = connectReduxDevTools(this, devToolsOptions);
|
|
2820
|
+
destroy$.subscribe(() => disconnect());
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
};
|
|
2824
|
+
function createStore(config = {}, opts = {}) {
|
|
2825
|
+
return new Store(config, opts);
|
|
2826
|
+
}
|
|
2827
|
+
|
|
2828
|
+
// ../../node_modules/@rxdi/redux-store/dist/esm/effects.js
|
|
2829
|
+
import { merge as merge2, of as of4 } from "rxjs";
|
|
2830
|
+
import { catchError as catchError2, filter as filter3, ignoreElements, takeUntil as takeUntil2 } from "rxjs/operators";
|
|
2831
|
+
function ofType(...actionCreators) {
|
|
2832
|
+
const types = new Set(actionCreators.map((creator) => creator.type));
|
|
2833
|
+
return (action$) => action$.pipe(filter3((action2) => types.has(action2.type)));
|
|
2834
|
+
}
|
|
2835
|
+
function createEffect(options = { dispatch: true }) {
|
|
2836
|
+
return (effectFactory) => {
|
|
2837
|
+
return (action$, state$) => {
|
|
2838
|
+
const mappedEffect$ = effectFactory(action$, state$);
|
|
2839
|
+
if (options.dispatch === false) {
|
|
2840
|
+
return mappedEffect$.pipe(ignoreElements(), catchError2((error) => {
|
|
2841
|
+
console.error("[Effect] Error:", error);
|
|
2842
|
+
return of4();
|
|
2843
|
+
}));
|
|
2844
|
+
}
|
|
2845
|
+
return mappedEffect$.pipe(catchError2((error) => {
|
|
2846
|
+
console.error("[Effect] Error:", error);
|
|
2847
|
+
return of4();
|
|
2848
|
+
}));
|
|
2849
|
+
};
|
|
2850
|
+
};
|
|
2851
|
+
}
|
|
2852
|
+
function createEpicRegistry(...effects) {
|
|
2853
|
+
return (action$, state$) => {
|
|
2854
|
+
return merge2(...effects.map((effect) => effect(action$, state$)));
|
|
2855
|
+
};
|
|
2856
|
+
}
|
|
2857
|
+
|
|
3059
2858
|
// src/store/chat-effects.ts
|
|
3060
|
-
|
|
3061
|
-
import { concat, EMPTY, from, merge, of } from "rxjs";
|
|
2859
|
+
import { concat, EMPTY as EMPTY2, from as from2, merge as merge3, of as of5 } from "rxjs";
|
|
3062
2860
|
import {
|
|
3063
|
-
catchError,
|
|
2861
|
+
catchError as catchError3,
|
|
3064
2862
|
endWith,
|
|
3065
|
-
filter,
|
|
3066
|
-
ignoreElements,
|
|
3067
|
-
map,
|
|
3068
|
-
mergeMap,
|
|
3069
|
-
switchMap,
|
|
2863
|
+
filter as filter4,
|
|
2864
|
+
ignoreElements as ignoreElements2,
|
|
2865
|
+
map as map3,
|
|
2866
|
+
mergeMap as mergeMap2,
|
|
2867
|
+
switchMap as switchMap2,
|
|
3070
2868
|
take,
|
|
3071
|
-
takeUntil,
|
|
2869
|
+
takeUntil as takeUntil3,
|
|
3072
2870
|
takeWhile,
|
|
3073
|
-
tap
|
|
2871
|
+
tap as tap2
|
|
3074
2872
|
} from "rxjs/operators";
|
|
3075
2873
|
var errorCode = (e16) => e16?.code || "internal";
|
|
3076
|
-
var fail = (e16) =>
|
|
2874
|
+
var fail = (e16) => of5(failed(errorCode(e16)));
|
|
3077
2875
|
function pickAgents(all, ctx) {
|
|
3078
2876
|
const agents = ctx.agents.length ? all.filter((a5) => ctx.agents.includes(a5.id) || ctx.agents.includes(a5.name)) : all;
|
|
3079
2877
|
const preferred = agents.find((a5) => a5.id === ctx.agent || a5.name === ctx.agent) ?? agents[0];
|
|
@@ -3083,54 +2881,54 @@ var ChatEffects = class {
|
|
|
3083
2881
|
constructor(ctx) {
|
|
3084
2882
|
this.ctx = ctx;
|
|
3085
2883
|
/** The first time the panel is on screen: the agents this session may use. */
|
|
3086
|
-
this.connect$ =
|
|
2884
|
+
this.connect$ = createEffect()(
|
|
3087
2885
|
(_action$, state$) => state$.pipe(
|
|
3088
|
-
|
|
2886
|
+
filter4((s9) => s9.shown),
|
|
3089
2887
|
take(1),
|
|
3090
|
-
|
|
2888
|
+
switchMap2(() => {
|
|
3091
2889
|
const client = this.ctx.client;
|
|
3092
|
-
if (!client) return
|
|
2890
|
+
if (!client) return of5(failed("unauthorized"));
|
|
3093
2891
|
return concat(
|
|
3094
|
-
|
|
2892
|
+
of5(connecting()),
|
|
3095
2893
|
client.agents().pipe(
|
|
3096
2894
|
take(1),
|
|
3097
|
-
|
|
3098
|
-
|
|
2895
|
+
map3((all) => agentsLoaded(pickAgents(all, this.ctx))),
|
|
2896
|
+
catchError3(fail)
|
|
3099
2897
|
)
|
|
3100
2898
|
);
|
|
3101
2899
|
})
|
|
3102
2900
|
)
|
|
3103
2901
|
);
|
|
3104
2902
|
/** The selected agent's latest conversation (resuming a running answer). */
|
|
3105
|
-
this.select$ =
|
|
3106
|
-
(action$) =>
|
|
2903
|
+
this.select$ = createEffect()(
|
|
2904
|
+
(action$) => merge3(
|
|
3107
2905
|
action$.pipe(
|
|
3108
|
-
|
|
3109
|
-
|
|
2906
|
+
ofType(agentsLoaded),
|
|
2907
|
+
map3(({ payload: payload2 }) => payload2.agentId)
|
|
3110
2908
|
),
|
|
3111
2909
|
action$.pipe(
|
|
3112
|
-
|
|
3113
|
-
|
|
2910
|
+
ofType(pickAgent),
|
|
2911
|
+
map3(({ payload: payload2 }) => payload2)
|
|
3114
2912
|
)
|
|
3115
2913
|
).pipe(
|
|
3116
|
-
|
|
3117
|
-
|
|
2914
|
+
filter4((id) => !!id),
|
|
2915
|
+
switchMap2((agentId) => {
|
|
3118
2916
|
const client = this.ctx.client;
|
|
3119
2917
|
return client.conversations(agentId).pipe(
|
|
3120
2918
|
take(1),
|
|
3121
|
-
|
|
2919
|
+
switchMap2((list) => {
|
|
3122
2920
|
const latest = list?.[0];
|
|
3123
|
-
if (!latest) return
|
|
2921
|
+
if (!latest) return EMPTY2;
|
|
3124
2922
|
return client.agent(agentId).conversation(latest.id).history().pipe(
|
|
3125
|
-
|
|
3126
|
-
(detail) =>
|
|
2923
|
+
mergeMap2(
|
|
2924
|
+
(detail) => from2([
|
|
3127
2925
|
historyLoaded({ agentId, detail }),
|
|
3128
2926
|
...detail.answering ? [resume({ agentId, conversationId: detail.id, afterSeq: detail.lastSeq ?? 0 })] : []
|
|
3129
2927
|
])
|
|
3130
2928
|
)
|
|
3131
2929
|
);
|
|
3132
2930
|
}),
|
|
3133
|
-
|
|
2931
|
+
catchError3(fail)
|
|
3134
2932
|
);
|
|
3135
2933
|
})
|
|
3136
2934
|
)
|
|
@@ -3140,59 +2938,53 @@ var ChatEffects = class {
|
|
|
3140
2938
|
* actions until done / error, cancelled by stop, another agent or a new
|
|
3141
2939
|
* conversation.
|
|
3142
2940
|
*/
|
|
3143
|
-
this.run$ =
|
|
3144
|
-
(action$) =>
|
|
2941
|
+
this.run$ = createEffect()(
|
|
2942
|
+
(action$) => merge3(
|
|
3145
2943
|
action$.pipe(
|
|
3146
|
-
|
|
3147
|
-
|
|
2944
|
+
ofType(sendMessage),
|
|
2945
|
+
map3(({ payload: payload2 }) => {
|
|
3148
2946
|
const { agentId, conversationId, text } = payload2;
|
|
3149
2947
|
const c9 = this.conversation(agentId, conversationId);
|
|
3150
2948
|
return { c: c9, events: c9.send(text) };
|
|
3151
2949
|
})
|
|
3152
2950
|
),
|
|
3153
2951
|
action$.pipe(
|
|
3154
|
-
|
|
3155
|
-
|
|
2952
|
+
ofType(resume),
|
|
2953
|
+
map3(({ payload: payload2 }) => {
|
|
3156
2954
|
const { agentId, conversationId, afterSeq } = payload2;
|
|
3157
2955
|
const c9 = this.conversation(agentId, conversationId);
|
|
3158
2956
|
return { c: c9, events: c9.events(afterSeq) };
|
|
3159
2957
|
})
|
|
3160
2958
|
)
|
|
3161
2959
|
).pipe(
|
|
3162
|
-
|
|
2960
|
+
switchMap2(
|
|
3163
2961
|
({ c: c9, events }) => this.follow$(c9, events).pipe(
|
|
3164
|
-
|
|
3165
|
-
merge(
|
|
3166
|
-
action$.pipe((0, import_redux_store.ofType)(stop)),
|
|
3167
|
-
action$.pipe((0, import_redux_store.ofType)(pickAgent)),
|
|
3168
|
-
action$.pipe((0, import_redux_store.ofType)(newConversation))
|
|
3169
|
-
)
|
|
3170
|
-
),
|
|
2962
|
+
takeUntil3(action$.pipe(ofType(stop, pickAgent, newConversation))),
|
|
3171
2963
|
endWith(runEnded())
|
|
3172
2964
|
)
|
|
3173
2965
|
)
|
|
3174
2966
|
)
|
|
3175
2967
|
);
|
|
3176
2968
|
/** Tell the server to stop the answer. */
|
|
3177
|
-
this.abort$ =
|
|
2969
|
+
this.abort$ = createEffect()(
|
|
3178
2970
|
(action$) => action$.pipe(
|
|
3179
|
-
|
|
3180
|
-
|
|
2971
|
+
ofType(stop),
|
|
2972
|
+
mergeMap2(({ payload: payload2 }) => {
|
|
3181
2973
|
const { agentId, conversationId } = payload2;
|
|
3182
|
-
if (!conversationId || !this.ctx.client) return
|
|
2974
|
+
if (!conversationId || !this.ctx.client) return EMPTY2;
|
|
3183
2975
|
return this.conversation(agentId, conversationId).abort().pipe(
|
|
3184
|
-
|
|
3185
|
-
|
|
2976
|
+
ignoreElements2(),
|
|
2977
|
+
catchError3(() => EMPTY2)
|
|
3186
2978
|
);
|
|
3187
2979
|
})
|
|
3188
2980
|
)
|
|
3189
2981
|
);
|
|
3190
2982
|
/** Failures also reach the page as an `error` event. */
|
|
3191
|
-
this.failures$ =
|
|
2983
|
+
this.failures$ = createEffect()(
|
|
3192
2984
|
(action$) => action$.pipe(
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
2985
|
+
ofType(failed),
|
|
2986
|
+
tap2(({ payload: payload2 }) => this.ctx.emit("error", { code: payload2 })),
|
|
2987
|
+
ignoreElements2()
|
|
3196
2988
|
)
|
|
3197
2989
|
);
|
|
3198
2990
|
}
|
|
@@ -3203,15 +2995,15 @@ var ChatEffects = class {
|
|
|
3203
2995
|
const announced = /* @__PURE__ */ new Set();
|
|
3204
2996
|
return events.pipe(
|
|
3205
2997
|
takeWhile((e16) => e16.type !== "done" && e16.type !== "error", true),
|
|
3206
|
-
|
|
2998
|
+
tap2((e16) => {
|
|
3207
2999
|
if (e16.type === "message" && e16.data?.role === "assistant" && !announced.has(e16.data.id)) {
|
|
3208
3000
|
announced.add(e16.data.id);
|
|
3209
3001
|
this.ctx.emit("answer", { text: e16.data.text, agent: c9.agent, conversationId: e16.conversationId });
|
|
3210
3002
|
}
|
|
3211
3003
|
if (e16.type === "error") this.ctx.emit("error", { code: e16.data?.code ?? "internal" });
|
|
3212
3004
|
}),
|
|
3213
|
-
|
|
3214
|
-
|
|
3005
|
+
map3((e16) => agentEvent(e16)),
|
|
3006
|
+
catchError3(fail)
|
|
3215
3007
|
);
|
|
3216
3008
|
}
|
|
3217
3009
|
};
|
|
@@ -3300,20 +3092,19 @@ function withEvent(s9, event) {
|
|
|
3300
3092
|
}
|
|
3301
3093
|
|
|
3302
3094
|
// src/store/chat-store.ts
|
|
3303
|
-
|
|
3304
|
-
import { of as of2, Subject } from "rxjs";
|
|
3095
|
+
import { of as of6, Subject as Subject3 } from "rxjs";
|
|
3305
3096
|
import { distinctUntilChanged } from "rxjs/operators";
|
|
3306
3097
|
var ChatStore = class {
|
|
3307
3098
|
constructor(ctx, initial = {}) {
|
|
3308
|
-
this.destroy$ = new
|
|
3099
|
+
this.destroy$ = new Subject3();
|
|
3309
3100
|
const effects = new ChatEffects(ctx);
|
|
3310
|
-
this.store =
|
|
3311
|
-
reducer$:
|
|
3312
|
-
initialState$:
|
|
3101
|
+
this.store = createStore({
|
|
3102
|
+
reducer$: of6(chatReducer),
|
|
3103
|
+
initialState$: of6({ ...initialChatState, ...initial }),
|
|
3313
3104
|
// RULE: every effect must be listed here or it never runs.
|
|
3314
3105
|
// connect$ LAST: it can start at once (an inline chat is shown from
|
|
3315
3106
|
// the first state) and the others must already listen to its actions.
|
|
3316
|
-
epic$:
|
|
3107
|
+
epic$: createEpicRegistry(
|
|
3317
3108
|
effects.select$,
|
|
3318
3109
|
effects.run$,
|
|
3319
3110
|
effects.abort$,
|