agentrein 1.0.13 → 1.0.14

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.
@@ -33,7 +33,6 @@ export declare class AgentRein {
33
33
  private readonly apiKey;
34
34
  private readonly failureMode;
35
35
  private token;
36
- private static activeSessions;
37
36
  constructor(options: AgentReinOptions);
38
37
  /**
39
38
  * Obtain a JWT token from the AgentRein server using the API key.
@@ -52,24 +51,6 @@ export declare class AgentRein {
52
51
  * If omitted, a random agentId is generated.
53
52
  */
54
53
  newSession(options?: SessionOptions | string): Promise<Session>;
55
- /**
56
- * Start a new workflow session.
57
- * All subsequent agentrein.call() will be logged under this session automatically.
58
- */
59
- startWorkflow(options?: SessionOptions | string): Promise<Session>;
60
- /**
61
- * End the current workflow and clear the internal session state.
62
- */
63
- endWorkflow(): Promise<void>;
64
- /**
65
- * Get the current active session, or create one automatically if none exists.
66
- */
67
- getCurrentSession(): Promise<Session>;
68
- /**
69
- * Resume an existing session by ID.
70
- * Use this when you need to explicitly attach to a known session.
71
- */
72
- resumeSession(sessionId: string): Promise<Session>;
73
54
  /**
74
55
  * Execute an API call under AgentRein's protection.
75
56
  *
@@ -78,9 +59,10 @@ export declare class AgentRein {
78
59
  * 3. On failure, triggers server-side rollback
79
60
  *
80
61
  * @param fn - The function to execute
62
+ * @param session - The active AgentRein session
81
63
  * @param args - Arguments forwarded to fn
82
64
  */
83
- call<T>(fn: Function, ...args: any[]): Promise<T>;
84
- call<T>(fn: Function, undoConfig: UndoConfig, ...args: any[]): Promise<T>;
65
+ call<T>(fn: Function, session: Session, ...args: any[]): Promise<T>;
66
+ call<T>(fn: Function, session: Session, undoConfig: UndoConfig, ...args: any[]): Promise<T>;
85
67
  }
86
68
  export default AgentRein;
@@ -60,45 +60,7 @@ class AgentRein {
60
60
  const res = await axios_1.default.post(`${this.serverUrl}/sessions`, { agentId, intent }, { headers });
61
61
  return res.data.data;
62
62
  }
63
- /**
64
- * Start a new workflow session.
65
- * All subsequent agentrein.call() will be logged under this session automatically.
66
- */
67
- async startWorkflow(options) {
68
- const session = await this.newSession(options);
69
- AgentRein.activeSessions.set(this.apiKey, session);
70
- return session;
71
- }
72
- /**
73
- * End the current workflow and clear the internal session state.
74
- */
75
- async endWorkflow() {
76
- AgentRein.activeSessions.delete(this.apiKey);
77
- }
78
- /**
79
- * Get the current active session, or create one automatically if none exists.
80
- */
81
- async getCurrentSession() {
82
- const cached = AgentRein.activeSessions.get(this.apiKey);
83
- if (cached)
84
- return cached;
85
- const session = await this.newSession();
86
- AgentRein.activeSessions.set(this.apiKey, session);
87
- return session;
88
- }
89
- /**
90
- * Resume an existing session by ID.
91
- * Use this when you need to explicitly attach to a known session.
92
- */
93
- async resumeSession(sessionId) {
94
- const headers = await this.authHeaders();
95
- const res = await axios_1.default.get(`${this.serverUrl}/sessions/${sessionId}`, { headers });
96
- const session = res.data.data;
97
- AgentRein.activeSessions.set(this.apiKey, session);
98
- return session;
99
- }
100
- async call(fn, ...args) {
101
- const session = await this.getCurrentSession();
63
+ async call(fn, session, ...args) {
102
64
  // Detect if first extra arg is an UndoConfig object
103
65
  let undoConfig;
104
66
  let callArgs = args;
@@ -131,5 +93,4 @@ class AgentRein {
131
93
  }
132
94
  }
133
95
  exports.AgentRein = AgentRein;
134
- AgentRein.activeSessions = new Map();
135
96
  exports.default = AgentRein;
@@ -57,45 +57,7 @@ export class AgentRein {
57
57
  const res = await axios.post(`${this.serverUrl}/sessions`, { agentId, intent }, { headers });
58
58
  return res.data.data;
59
59
  }
60
- /**
61
- * Start a new workflow session.
62
- * All subsequent agentrein.call() will be logged under this session automatically.
63
- */
64
- async startWorkflow(options) {
65
- const session = await this.newSession(options);
66
- AgentRein.activeSessions.set(this.apiKey, session);
67
- return session;
68
- }
69
- /**
70
- * End the current workflow and clear the internal session state.
71
- */
72
- async endWorkflow() {
73
- AgentRein.activeSessions.delete(this.apiKey);
74
- }
75
- /**
76
- * Get the current active session, or create one automatically if none exists.
77
- */
78
- async getCurrentSession() {
79
- const cached = AgentRein.activeSessions.get(this.apiKey);
80
- if (cached)
81
- return cached;
82
- const session = await this.newSession();
83
- AgentRein.activeSessions.set(this.apiKey, session);
84
- return session;
85
- }
86
- /**
87
- * Resume an existing session by ID.
88
- * Use this when you need to explicitly attach to a known session.
89
- */
90
- async resumeSession(sessionId) {
91
- const headers = await this.authHeaders();
92
- const res = await axios.get(`${this.serverUrl}/sessions/${sessionId}`, { headers });
93
- const session = res.data.data;
94
- AgentRein.activeSessions.set(this.apiKey, session);
95
- return session;
96
- }
97
- async call(fn, ...args) {
98
- const session = await this.getCurrentSession();
60
+ async call(fn, session, ...args) {
99
61
  // Detect if first extra arg is an UndoConfig object
100
62
  let undoConfig;
101
63
  let callArgs = args;
@@ -127,5 +89,4 @@ export class AgentRein {
127
89
  }
128
90
  }
129
91
  }
130
- AgentRein.activeSessions = new Map();
131
92
  export default AgentRein;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentrein",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "main": "./dist/cjs/agentreinClient.js",
5
5
  "module": "./dist/esm/agentreinClient.js",
6
6
  "types": "./dist/cjs/agentreinClient.d.ts",