@nextclaw/ncp-toolkit 0.4.15 → 0.4.16

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.d.ts CHANGED
@@ -98,6 +98,7 @@ interface AgentSessionStore {
98
98
  getSession(sessionId: string): Promise<AgentSessionRecord | null>;
99
99
  listSessions(): Promise<AgentSessionRecord[]>;
100
100
  saveSession(session: AgentSessionRecord): Promise<void>;
101
+ replaceSession(session: AgentSessionRecord): Promise<void>;
101
102
  deleteSession(sessionId: string): Promise<AgentSessionRecord | null>;
102
103
  }
103
104
 
@@ -163,10 +164,11 @@ declare class AgentRunExecutor {
163
164
 
164
165
  declare class InMemoryAgentSessionStore implements AgentSessionStore {
165
166
  private readonly sessions;
166
- getSession(sessionId: string): Promise<AgentSessionRecord | null>;
167
- listSessions(): Promise<AgentSessionRecord[]>;
168
- saveSession(session: AgentSessionRecord): Promise<void>;
169
- deleteSession(sessionId: string): Promise<AgentSessionRecord | null>;
167
+ getSession: (sessionId: string) => Promise<AgentSessionRecord | null>;
168
+ listSessions: () => Promise<AgentSessionRecord[]>;
169
+ saveSession: (session: AgentSessionRecord) => Promise<void>;
170
+ replaceSession: (session: AgentSessionRecord) => Promise<void>;
171
+ deleteSession: (sessionId: string) => Promise<AgentSessionRecord | null>;
170
172
  }
171
173
 
172
174
  /**
package/dist/index.js CHANGED
@@ -1353,7 +1353,7 @@ var DefaultNcpAgentBackend = class {
1353
1353
  const liveSession = this.sessionRegistry.getSession(sessionId);
1354
1354
  const storedSession = await this.sessionStore.getSession(sessionId);
1355
1355
  if (!liveSession && !storedSession) return null;
1356
- await this.sessionStore.saveSession(buildUpdatedSessionRecord({
1356
+ await this.sessionStore.replaceSession(buildUpdatedSessionRecord({
1357
1357
  sessionId,
1358
1358
  patch,
1359
1359
  liveSession,
@@ -1474,24 +1474,27 @@ var DefaultNcpAgentBackend = class {
1474
1474
  // src/agent/agent-backend/in-memory-agent-session-store.ts
1475
1475
  var InMemoryAgentSessionStore = class {
1476
1476
  sessions = /* @__PURE__ */ new Map();
1477
- async getSession(sessionId) {
1477
+ getSession = async (sessionId) => {
1478
1478
  const session = this.sessions.get(sessionId);
1479
1479
  return session ? structuredClone(session) : null;
1480
- }
1481
- async listSessions() {
1480
+ };
1481
+ listSessions = async () => {
1482
1482
  return [...this.sessions.values()].map((session) => structuredClone(session));
1483
- }
1484
- async saveSession(session) {
1483
+ };
1484
+ saveSession = async (session) => {
1485
1485
  this.sessions.set(session.sessionId, structuredClone(session));
1486
- }
1487
- async deleteSession(sessionId) {
1486
+ };
1487
+ replaceSession = async (session) => {
1488
+ this.sessions.set(session.sessionId, structuredClone(session));
1489
+ };
1490
+ deleteSession = async (sessionId) => {
1488
1491
  const session = this.sessions.get(sessionId);
1489
1492
  if (!session) {
1490
1493
  return null;
1491
1494
  }
1492
1495
  this.sessions.delete(sessionId);
1493
1496
  return structuredClone(session);
1494
- }
1497
+ };
1495
1498
  };
1496
1499
  export {
1497
1500
  AgentRunExecutor,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextclaw/ncp-toolkit",
3
- "version": "0.4.15",
3
+ "version": "0.4.16",
4
4
  "private": false,
5
5
  "description": "Toolkit implementations built on top of the NextClaw Communication Protocol.",
6
6
  "type": "module",