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