@dudousxd/nestjs-agent-core 0.42.1 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -25,6 +25,7 @@ __export(src_exports, {
25
25
  AGENT_ACTOR_RESOLVER: () => AGENT_ACTOR_RESOLVER,
26
26
  AGENT_APPROVAL_PORT: () => AGENT_APPROVAL_PORT,
27
27
  AGENT_ATTACHMENT_STAGING: () => AGENT_ATTACHMENT_STAGING,
28
+ AGENT_CHANNEL_STORE: () => AGENT_CHANNEL_STORE,
28
29
  AGENT_CONFIRM_TOKEN_STORE: () => AGENT_CONFIRM_TOKEN_STORE,
29
30
  AGENT_DEPS_FACTORY: () => AGENT_DEPS_FACTORY,
30
31
  AGENT_DIAGNOSTIC_EVENTS: () => AGENT_DIAGNOSTIC_EVENTS,
@@ -79,6 +80,7 @@ __export(src_exports, {
79
80
  GLOBAL_SCOPE: () => GLOBAL_SCOPE,
80
81
  InMemoryActionProposalStore: () => InMemoryActionProposalStore,
81
82
  InMemoryAgentStore: () => InMemoryAgentStore,
83
+ InMemoryChannelStore: () => InMemoryChannelStore,
82
84
  InMemoryConfirmTokenStore: () => InMemoryConfirmTokenStore,
83
85
  MAX_ASK_QUESTIONS: () => MAX_ASK_QUESTIONS,
84
86
  OutputRejectedError: () => OutputRejectedError,
@@ -308,6 +310,7 @@ var AGENT_SKILLS = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skills");
308
310
  var AGENT_MEMORY = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:memory");
309
311
  var AGENT_SKILL_SOURCES = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:skill-sources");
310
312
  var AGENT_CONFIRM_TOKEN_STORE = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:confirm-token-store");
313
+ var AGENT_CHANNEL_STORE = /* @__PURE__ */ Symbol.for("@dudousxd/nestjs-agent:channel-store");
311
314
 
312
315
  // src/spi/model-catalog.ts
313
316
  function staticModelCatalog(view) {
@@ -8786,6 +8789,62 @@ var InMemoryConfirmTokenStore = class {
8786
8789
  }
8787
8790
  };
8788
8791
 
8792
+ // src/channel-store.ts
8793
+ var InMemoryChannelStore = class {
8794
+ static {
8795
+ __name(this, "InMemoryChannelStore");
8796
+ }
8797
+ maxEntries;
8798
+ #entries = /* @__PURE__ */ new Map();
8799
+ constructor(maxEntries = 5e4) {
8800
+ this.maxEntries = maxEntries;
8801
+ }
8802
+ #live(key) {
8803
+ const entry = this.#entries.get(key);
8804
+ if (entry === void 0) return void 0;
8805
+ if (entry.expiresAt > Date.now()) return entry;
8806
+ this.#entries.delete(key);
8807
+ return void 0;
8808
+ }
8809
+ #put(key, value, ttlMs) {
8810
+ const now = Date.now();
8811
+ this.#entries.delete(key);
8812
+ this.#entries.set(key, {
8813
+ value,
8814
+ expiresAt: now + ttlMs
8815
+ });
8816
+ if (this.#entries.size <= this.maxEntries) return;
8817
+ for (const [stored, entry] of this.#entries) {
8818
+ if (this.#entries.size <= this.maxEntries && entry.expiresAt > now) break;
8819
+ this.#entries.delete(stored);
8820
+ }
8821
+ }
8822
+ async claim(key, ttlMs) {
8823
+ if (this.#live(key) !== void 0) return false;
8824
+ this.#put(key, null, ttlMs);
8825
+ return true;
8826
+ }
8827
+ async get(key) {
8828
+ return this.#live(key)?.value ?? null;
8829
+ }
8830
+ async set(key, value, ttlMs) {
8831
+ this.#put(key, value, ttlMs);
8832
+ }
8833
+ async delete(key) {
8834
+ this.#entries.delete(key);
8835
+ }
8836
+ async purgeExpired(now = Date.now()) {
8837
+ let purged = 0;
8838
+ for (const [key, entry] of this.#entries) {
8839
+ if (entry.expiresAt <= now) {
8840
+ this.#entries.delete(key);
8841
+ purged += 1;
8842
+ }
8843
+ }
8844
+ return purged;
8845
+ }
8846
+ };
8847
+
8789
8848
  // src/confirmed-tool.ts
8790
8849
  var DEFAULT_MESSAGES = {
8791
8850
  confirm: 'Nothing was written. Show this preview to the user and ask them to confirm. To commit, call this tool again with the SAME arguments plus "confirm": true and this "confirmToken" (valid for {minutes} minutes).',
@@ -9685,6 +9744,7 @@ __name(createFunctionalTool, "createFunctionalTool");
9685
9744
  AGENT_ACTOR_RESOLVER,
9686
9745
  AGENT_APPROVAL_PORT,
9687
9746
  AGENT_ATTACHMENT_STAGING,
9747
+ AGENT_CHANNEL_STORE,
9688
9748
  AGENT_CONFIRM_TOKEN_STORE,
9689
9749
  AGENT_DEPS_FACTORY,
9690
9750
  AGENT_DIAGNOSTIC_EVENTS,
@@ -9739,6 +9799,7 @@ __name(createFunctionalTool, "createFunctionalTool");
9739
9799
  GLOBAL_SCOPE,
9740
9800
  InMemoryActionProposalStore,
9741
9801
  InMemoryAgentStore,
9802
+ InMemoryChannelStore,
9742
9803
  InMemoryConfirmTokenStore,
9743
9804
  MAX_ASK_QUESTIONS,
9744
9805
  OutputRejectedError,