agentrein 1.0.12 → 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 currentSession;
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;
@@ -12,7 +12,6 @@ function createUndoConfig(config) {
12
12
  class AgentRein {
13
13
  constructor(options) {
14
14
  this.token = null;
15
- this.currentSession = null;
16
15
  this.serverUrl = options.serverUrl || 'https://api.agentrein.com';
17
16
  this.apiKey = options.apiKey;
18
17
  this.failureMode = options.failureMode ?? 'open';
@@ -61,41 +60,7 @@ class AgentRein {
61
60
  const res = await axios_1.default.post(`${this.serverUrl}/sessions`, { agentId, intent }, { headers });
62
61
  return res.data.data;
63
62
  }
64
- /**
65
- * Start a new workflow session.
66
- * All subsequent agentrein.call() will be logged under this session automatically.
67
- */
68
- async startWorkflow(options) {
69
- this.currentSession = await this.newSession(options);
70
- return this.currentSession;
71
- }
72
- /**
73
- * End the current workflow and clear the internal session state.
74
- */
75
- async endWorkflow() {
76
- this.currentSession = null;
77
- }
78
- /**
79
- * Get the current active session, or create one automatically if none exists.
80
- */
81
- async getCurrentSession() {
82
- if (!this.currentSession) {
83
- this.currentSession = await this.newSession();
84
- }
85
- return this.currentSession;
86
- }
87
- /**
88
- * Resume an existing session by ID.
89
- * Use this when you need to explicitly attach to a known session.
90
- */
91
- async resumeSession(sessionId) {
92
- const headers = await this.authHeaders();
93
- const res = await axios_1.default.get(`${this.serverUrl}/sessions/${sessionId}`, { headers });
94
- this.currentSession = res.data.data;
95
- return this.currentSession;
96
- }
97
- async call(fn, ...args) {
98
- const session = await this.getCurrentSession();
63
+ async call(fn, session, ...args) {
99
64
  // Detect if first extra arg is an UndoConfig object
100
65
  let undoConfig;
101
66
  let callArgs = args;
@@ -9,7 +9,6 @@ export { AgentReinUnavailableError };
9
9
  export class AgentRein {
10
10
  constructor(options) {
11
11
  this.token = null;
12
- this.currentSession = null;
13
12
  this.serverUrl = options.serverUrl || 'https://api.agentrein.com';
14
13
  this.apiKey = options.apiKey;
15
14
  this.failureMode = options.failureMode ?? 'open';
@@ -58,41 +57,7 @@ export class AgentRein {
58
57
  const res = await axios.post(`${this.serverUrl}/sessions`, { agentId, intent }, { headers });
59
58
  return res.data.data;
60
59
  }
61
- /**
62
- * Start a new workflow session.
63
- * All subsequent agentrein.call() will be logged under this session automatically.
64
- */
65
- async startWorkflow(options) {
66
- this.currentSession = await this.newSession(options);
67
- return this.currentSession;
68
- }
69
- /**
70
- * End the current workflow and clear the internal session state.
71
- */
72
- async endWorkflow() {
73
- this.currentSession = null;
74
- }
75
- /**
76
- * Get the current active session, or create one automatically if none exists.
77
- */
78
- async getCurrentSession() {
79
- if (!this.currentSession) {
80
- this.currentSession = await this.newSession();
81
- }
82
- return this.currentSession;
83
- }
84
- /**
85
- * Resume an existing session by ID.
86
- * Use this when you need to explicitly attach to a known session.
87
- */
88
- async resumeSession(sessionId) {
89
- const headers = await this.authHeaders();
90
- const res = await axios.get(`${this.serverUrl}/sessions/${sessionId}`, { headers });
91
- this.currentSession = res.data.data;
92
- return this.currentSession;
93
- }
94
- async call(fn, ...args) {
95
- const session = await this.getCurrentSession();
60
+ async call(fn, session, ...args) {
96
61
  // Detect if first extra arg is an UndoConfig object
97
62
  let undoConfig;
98
63
  let callArgs = args;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentrein",
3
- "version": "1.0.12",
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",