agent-swarm-kit 4.0.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.cjs +397 -126
- package/build/index.mjs +397 -126
- package/package.json +1 -1
- package/types.d.ts +60 -13
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -6139,8 +6139,18 @@ declare class ClientStorage<T extends IStorageData = IStorageData> implements IS
|
|
|
6139
6139
|
*/
|
|
6140
6140
|
constructor(params: IStorageParams<T>);
|
|
6141
6141
|
/**
|
|
6142
|
-
*
|
|
6143
|
-
*
|
|
6142
|
+
* Queued core of dispatch. The wrapped function must never reject: queued()
|
|
6143
|
+
* chains every call on the previous promise, so a rejection inside the queue
|
|
6144
|
+
* (e.g. a throwing createIndex/createEmbedding/setData) would reject every
|
|
6145
|
+
* already-queued dispatch with this foreign error WITHOUT running it — a
|
|
6146
|
+
* concurrent upsert/remove/clear would be silently dropped. Errors are boxed
|
|
6147
|
+
* here and rethrown outside the queue, so only the failing caller observes them.
|
|
6148
|
+
*/
|
|
6149
|
+
private _dispatchQueue;
|
|
6150
|
+
/**
|
|
6151
|
+
* Dispatches a storage action (upsert, remove, or clear) through the serialized
|
|
6152
|
+
* queue, delegating to DISPATCH_FN. Ensures sequential execution of storage
|
|
6153
|
+
* operations, supporting thread-safe updates from ClientAgent or tools.
|
|
6144
6154
|
*/
|
|
6145
6155
|
dispatch: (action: Action$1, payload: Partial<Payload<T>>) => Promise<void>;
|
|
6146
6156
|
/**
|
|
@@ -6483,19 +6493,37 @@ declare class ClientState<State extends IStateData = IStateData> implements ISta
|
|
|
6483
6493
|
readonly params: IStateParams<State>;
|
|
6484
6494
|
readonly stateChanged: Subject<string>;
|
|
6485
6495
|
/**
|
|
6486
|
-
*
|
|
6487
|
-
* getState checks it to serve reentrant reads (getState
|
|
6488
|
-
* dispatchFn) without re-entering the queue, which would
|
|
6496
|
+
* Marks the async execution context of a running dispatch (read/write).
|
|
6497
|
+
* getState checks it to serve reentrant reads (getState called from INSIDE a
|
|
6498
|
+
* setState dispatchFn/middleware) without re-entering the queue, which would
|
|
6499
|
+
* deadlock. Scoping this per async-context — instead of a plain instance flag —
|
|
6500
|
+
* ensures an UNRELATED concurrent getState still queues and observes writes in
|
|
6501
|
+
* order, rather than reading a stale field while some other write is in flight.
|
|
6502
|
+
*/
|
|
6503
|
+
private _dispatchContext;
|
|
6504
|
+
/**
|
|
6505
|
+
* True only while the caller runs inside the async context of an active
|
|
6506
|
+
* dispatch on this instance (i.e. a reentrant call from within a dispatchFn).
|
|
6489
6507
|
*/
|
|
6490
|
-
_inDispatch: boolean;
|
|
6508
|
+
get _inDispatch(): boolean;
|
|
6491
6509
|
/**
|
|
6492
6510
|
* The current state data, initialized as null and set during waitForInit.
|
|
6493
6511
|
* Updated by setState and clearState, persisted via params.setState if provided.
|
|
6494
6512
|
*/
|
|
6495
6513
|
_state: State;
|
|
6496
6514
|
/**
|
|
6497
|
-
* Queued
|
|
6498
|
-
*
|
|
6515
|
+
* Queued core of dispatch. The wrapped function must never reject: queued()
|
|
6516
|
+
* chains every call on the previous promise, so a rejection inside the queue
|
|
6517
|
+
* would reject every already-queued dispatch with this foreign error WITHOUT
|
|
6518
|
+
* running it — a concurrent setState would be silently dropped. Errors (e.g.
|
|
6519
|
+
* a throwing user dispatchFn or middleware) are boxed here and rethrown
|
|
6520
|
+
* outside the queue, so only the caller whose operation failed observes them.
|
|
6521
|
+
*/
|
|
6522
|
+
private _dispatchQueue;
|
|
6523
|
+
/**
|
|
6524
|
+
* Dispatches a read or write of the state through the serialized queue,
|
|
6525
|
+
* delegating to DISPATCH_FN. Ensures thread-safe state operations, supporting
|
|
6526
|
+
* concurrent access from ClientAgent or tools.
|
|
6499
6527
|
*/
|
|
6500
6528
|
dispatch: (action: Action, payload?: DispatchFn<State>) => Promise<State>;
|
|
6501
6529
|
/**
|
|
@@ -7867,7 +7895,6 @@ declare class PolicyValidationService {
|
|
|
7867
7895
|
validate: (policyName: PolicyName, source: string) => void;
|
|
7868
7896
|
}
|
|
7869
7897
|
|
|
7870
|
-
declare const BAN_NEED_FETCH: unique symbol;
|
|
7871
7898
|
/**
|
|
7872
7899
|
* Class representing a client policy in the swarm system, implementing the IPolicy interface.
|
|
7873
7900
|
* Manages client bans, input/output validation, and restrictions, with lazy-loaded ban lists and event emission via BusService.
|
|
@@ -7878,11 +7905,19 @@ declare const BAN_NEED_FETCH: unique symbol;
|
|
|
7878
7905
|
declare class ClientPolicy implements IPolicy {
|
|
7879
7906
|
readonly params: IPolicyParams;
|
|
7880
7907
|
/**
|
|
7881
|
-
*
|
|
7882
|
-
*
|
|
7883
|
-
*
|
|
7908
|
+
* Ban sets keyed by swarm name, lazily populated via params.getBannedClients.
|
|
7909
|
+
* A ClientPolicy instance is memoized per policyName and shared by every swarm
|
|
7910
|
+
* that lists the policy, while bans are persisted per (policy, swarm) — a
|
|
7911
|
+
* single shared set would leak bans of one swarm into another and persist
|
|
7912
|
+
* the mixed set into the wrong store.
|
|
7884
7913
|
*/
|
|
7885
|
-
|
|
7914
|
+
_banSetBySwarm: Map<string, Set<string>>;
|
|
7915
|
+
/**
|
|
7916
|
+
* Returns the ban set of the given swarm, fetching it on first access.
|
|
7917
|
+
* Re-checks the map after the await: a ban committed through _banQueue while
|
|
7918
|
+
* the fetch was in flight must not be overwritten by the stale fetch result.
|
|
7919
|
+
*/
|
|
7920
|
+
private _getBanSet;
|
|
7886
7921
|
/**
|
|
7887
7922
|
* Serializes the read-modify-write of _banSet shared by banClient/unbanClient.
|
|
7888
7923
|
* Without it two concurrent bans of different clients both read the same ban
|
|
@@ -7890,8 +7925,20 @@ declare class ClientPolicy implements IPolicy {
|
|
|
7890
7925
|
* the earlier one — one ban is silently lost in memory and in the persisted
|
|
7891
7926
|
* store. queued() runs the mutations one at a time so each observes the result
|
|
7892
7927
|
* of the previous one.
|
|
7928
|
+
*
|
|
7929
|
+
* The wrapped function must never reject: queued() chains every call on the
|
|
7930
|
+
* previous promise, so a rejection inside the queue (e.g. a throwing
|
|
7931
|
+
* setBannedClients adapter) would reject every already-queued ban/unban with
|
|
7932
|
+
* this foreign error WITHOUT running it — a concurrent ban of another client
|
|
7933
|
+
* would be silently lost. Errors are boxed here and rethrown by the caller
|
|
7934
|
+
* outside the queue.
|
|
7893
7935
|
*/
|
|
7894
7936
|
private _banQueue;
|
|
7937
|
+
/**
|
|
7938
|
+
* Runs a ban-set mutation through _banQueue, rethrowing its boxed error
|
|
7939
|
+
* outside the queue so only the failing caller observes it.
|
|
7940
|
+
*/
|
|
7941
|
+
private _runBanQueue;
|
|
7895
7942
|
/**
|
|
7896
7943
|
* Constructs a ClientPolicy instance with the provided parameters.
|
|
7897
7944
|
* Invokes the onInit callback if defined and logs construction if debugging is enabled.
|