@robota-sdk/agent-session 3.0.0-beta.64

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/CHANGELOG.md ADDED
@@ -0,0 +1,524 @@
1
+ # @robota-sdk/agent-session
2
+
3
+ ## 3.0.0-beta.64
4
+
5
+ ### Patch Changes
6
+
7
+ - @robota-sdk/agent-core@3.0.0-beta.64
8
+
9
+ ## 3.0.0-beta.63
10
+
11
+ ### Patch Changes
12
+
13
+ - @robota-sdk/agent-core@3.0.0-beta.63
14
+
15
+ ## 3.0.0-beta.62
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+ - @robota-sdk/agent-core@3.0.0-beta.62
21
+
22
+ ## 3.0.0-beta.61
23
+
24
+ ### Minor Changes
25
+
26
+ - 18fcc5b: Add provider-neutral sandbox snapshot hydration for interactive sessions. Snapshot-capable sandbox clients now persist `sandboxSnapshotId` on shutdown and restore it before saved message replay on non-fork resume, while the E2B structural adapter supports both `createSnapshot()`-style checkpoints and pause/resume sandbox references.
27
+
28
+ ### Patch Changes
29
+
30
+ - 1c0d44c: Align context usage estimation across session display, auto-compaction, and core hard-capacity guards so mid-window sessions do not block prematurely.
31
+ - 36eb7a9: Add provider-owned native replay payload hooks, replay validation coverage, and a session log validation command.
32
+ - d97bdf2: Add provider-owned model catalog metadata, route `/model` suggestions through the active provider, and make `cli:dev` resolve the CLI workspace dependency closure through source export conditions.
33
+ - Updated dependencies [1c0d44c]
34
+ - Updated dependencies [36eb7a9]
35
+ - Updated dependencies [d97bdf2]
36
+ - @robota-sdk/agent-core@3.0.0-beta.61
37
+
38
+ ## 3.0.0-beta.60
39
+
40
+ ### Minor Changes
41
+
42
+ - 7439391: Add provider-neutral native web search/fetch capability contracts, explicit unsupported handling for OpenAI-compatible/LM Studio profiles, and local WebFetch/WebSearch permission/documentation alignment.
43
+
44
+ ### Patch Changes
45
+
46
+ - Updated dependencies [7439391]
47
+ - @robota-sdk/agent-core@3.0.0-beta.60
48
+
49
+ ## 3.0.0-beta.59
50
+
51
+ ### Patch Changes
52
+
53
+ - @robota-sdk/agent-core@3.0.0-beta.59
54
+
55
+ ## 3.0.0-beta.58
56
+
57
+ ### Patch Changes
58
+
59
+ - Refresh package docs and robota.io content for the beta 57 feature set.
60
+ - Updated dependencies
61
+ - @robota-sdk/agent-core@3.0.0-beta.58
62
+
63
+ ## 3.0.0-beta.57
64
+
65
+ ### Minor Changes
66
+
67
+ - b80e51e: Add SDK-owned automatic project memory capture, approval review, bounded retrieval, and session-log provenance.
68
+
69
+ ### Patch Changes
70
+
71
+ - 16c3b6f: Persist and render provider-neutral per-turn usage summaries with pre-send context updates in CLI sessions.
72
+ - 26a1718: Preserve and render Edit tool diff metadata in persisted CLI tool summaries.
73
+ - Updated dependencies [16c3b6f]
74
+ - Updated dependencies [f61e2cb]
75
+ - @robota-sdk/agent-core@3.0.0-beta.57
76
+
77
+ ## 3.0.0-beta.56
78
+
79
+ ### Patch Changes
80
+
81
+ - Updated dependencies
82
+ - @robota-sdk/agent-core@3.0.0-beta.56
83
+
84
+ ## 3.0.0-beta.55
85
+
86
+ ### Patch Changes
87
+
88
+ - 38a72bf: fix: resolve ESLint tsconfig parsing errors and improve pnpm CI reliability
89
+ - Add tsconfig.eslint.json to all packages for per-package ESLint runs
90
+ - Migrate typecheck from pnpm -r exec tsc to per-package typecheck scripts
91
+ - Add --if-present to all recursive pnpm run scripts
92
+ - Fix React type imports, dynamic imports in tests, Express.Multer types
93
+
94
+ - Updated dependencies [38a72bf]
95
+ - @robota-sdk/agent-core@3.0.0-beta.55
96
+
97
+ ## 3.0.0-beta.54
98
+
99
+ ### Patch Changes
100
+
101
+ - fix: resolve all typecheck errors across packages
102
+ - Updated dependencies
103
+ - @robota-sdk/agent-core@3.0.0-beta.54
104
+
105
+ ## 3.0.0-beta.53
106
+
107
+ ### Patch Changes
108
+
109
+ - refactor: monolith decomposition — all agent-\* files under 300 lines
110
+ - fix: PR #69 code review — session resume tool messages, type SSOT, fork isolation, settings crash, Notification removal, chat validation
111
+ - Updated dependencies
112
+ - Updated dependencies
113
+ - @robota-sdk/agent-core@3.0.0-beta.53
114
+
115
+ ## 3.0.0-beta.52
116
+
117
+ ### Patch Changes
118
+
119
+ - @robota-sdk/agent-core@3.0.0-beta.52
120
+
121
+ ## 3.0.0-beta.51
122
+
123
+ ### Patch Changes
124
+
125
+ - @robota-sdk/agent-core@3.0.0-beta.51
126
+
127
+ ## 3.0.0-beta.50
128
+
129
+ ### Patch Changes
130
+
131
+ - @robota-sdk/agent-core@3.0.0-beta.50
132
+
133
+ ## 3.0.0-beta.49
134
+
135
+ ### Patch Changes
136
+
137
+ - @robota-sdk/agent-core@3.0.0-beta.49
138
+
139
+ ## 3.0.0-beta.48
140
+
141
+ ### Patch Changes
142
+
143
+ - @robota-sdk/agent-core@3.0.0-beta.48
144
+
145
+ ## 3.0.0-beta.47
146
+
147
+ ### Patch Changes
148
+
149
+ - @robota-sdk/agent-core@3.0.0-beta.47
150
+
151
+ ## 3.0.0-beta.46
152
+
153
+ ### Minor Changes
154
+
155
+ - feat: session continue/resume — persist, restore, and switch sessions
156
+ - ISessionRecord.history field (required) for UI timeline restoration
157
+ - Session.injectMessage() for AI context restoration on resume
158
+ - InteractiveSession: sessionStore, resumeSessionId, forkSession, getName/setName
159
+ - CLI: --continue, --resume, --fork-session, --name flags
160
+ - TUI: /resume (session picker), /rename (session naming)
161
+ - ListPicker generic component with viewport scrolling
162
+ - Session name display: input border title, terminal title, StatusBar
163
+ - Session picker: cwd filtering, date+time, response preview
164
+ - React key remount for instant session switching
165
+
166
+ ### Patch Changes
167
+
168
+ - @robota-sdk/agent-core@3.0.0-beta.46
169
+
170
+ ## 3.0.0-beta.45
171
+
172
+ ### Patch Changes
173
+
174
+ - @robota-sdk/agent-core@3.0.0-beta.45
175
+
176
+ ## 3.0.0-beta.44
177
+
178
+ ### Patch Changes
179
+
180
+ - feat: IHistoryEntry universal history architecture + test quality cleanup
181
+ - IHistoryEntry as universal history type across all 4 packages (core → sessions → sdk → cli)
182
+ - Tool summary stored as event entry in history (category: 'event', type: 'tool-summary')
183
+ - TuiStateManager pure TypeScript class for CLI rendering state
184
+ - MessageList renders IHistoryEntry[] with Tool:/System:/You:/Robota: labels
185
+ - Display order fixed: Tool → Robota (both streaming and abort)
186
+ - Remove 25 tautological, duplicate, and hardcoded tests
187
+
188
+ - Updated dependencies
189
+ - @robota-sdk/agent-core@3.0.0-beta.44
190
+
191
+ ## 2.0.9
192
+
193
+ ### Patch Changes
194
+
195
+ - Add environment-specific builds and conditional exports for optimal browser compatibility
196
+
197
+ This update introduces major build optimizations for better browser performance:
198
+
199
+ ## 🚀 Environment-Specific Builds
200
+ - **Node.js builds**: `dist/node/` with full ESM and CJS support
201
+ - **Browser builds**: `dist/browser/` with optimized ESM bundles
202
+ - **Automatic selection**: Bundlers automatically choose the right build
203
+
204
+ ## 📦 Bundle Size Optimizations
205
+ - **team package**: 36% smaller browser bundles (37.52KB → 24.12KB)
206
+ - **sessions package**: 48% smaller browser bundles (10.64KB → 5.55KB)
207
+ - **Tree-shaking**: Eliminates Node.js-specific code from browser builds
208
+ - **Production optimizations**: Removes console logs and debug code in browser builds
209
+
210
+ ## 🔧 Conditional Exports
211
+
212
+ All packages now support conditional exports for seamless environment detection:
213
+
214
+ ```json
215
+ {
216
+ "exports": {
217
+ "node": "./dist/node/index.js",
218
+ "browser": "./dist/browser/index.js",
219
+ "default": "./dist/node/index.js"
220
+ }
221
+ }
222
+ ```
223
+
224
+ ## 🌐 Enhanced Browser Support
225
+ - **Zero breaking changes**: Existing code continues to work unchanged
226
+ - **Better performance**: Optimized bundles for faster loading
227
+ - **Smaller footprint**: Reduced JavaScript bundle sizes for web applications
228
+ - **Universal API**: Same API works across all environments
229
+
230
+ This update completes the browser compatibility optimization phase, making Robota SDK production-ready for web applications with optimal performance characteristics.
231
+
232
+ - Updated dependencies
233
+ - @robota-sdk/agent-core@2.0.9
234
+
235
+ ## 2.0.8
236
+
237
+ ### Patch Changes
238
+
239
+ - # Model Configuration Refactoring
240
+
241
+ ## 🚀 **Breaking Changes**
242
+
243
+ ### **Provider Interface Simplification**
244
+ - **OpenAI Provider**: Removed `model`, `temperature`, `maxTokens`, `topP` from provider options
245
+ - **Anthropic Provider**: Removed `model`, `temperature`, `maxTokens` from provider options
246
+ - **Google Provider**: Removed `model`, `temperature`, `maxTokens` from provider options
247
+ - **All Providers**: `client` is now optional, automatically created from `apiKey`
248
+
249
+ ### **Centralized Model Configuration**
250
+ - Model configuration is now exclusively handled through `defaultModel` in Robota constructor
251
+ - Providers are simplified to handle only connection-related settings
252
+ - Runtime model switching via `setModel()` method is now the recommended approach
253
+
254
+ ## ✨ **Improvements**
255
+
256
+ ### **Simplified Provider Creation**
257
+
258
+ ```typescript
259
+ // Before
260
+ const provider = new OpenAIProvider({
261
+ client: openaiClient,
262
+ model: 'gpt-3.5-turbo',
263
+ });
264
+
265
+ // After
266
+ const provider = new OpenAIProvider({
267
+ apiKey: process.env.OPENAI_API_KEY,
268
+ });
269
+ ```
270
+
271
+ ### **Enhanced Validation**
272
+ - Added strict validation for required model configuration
273
+ - Removed default model fallbacks to prevent ambiguous behavior
274
+ - Clear error messages when model is not specified
275
+
276
+ ### **Documentation Updates**
277
+ - Updated all README files with new usage patterns
278
+ - Regenerated API documentation
279
+ - Updated all example files (11 examples)
280
+
281
+ ## 🔧 **Migration Guide**
282
+ 1. **Remove model settings from Provider constructors**
283
+ 2. **Use `apiKey` instead of `client` injection (recommended)**
284
+ 3. **Ensure `defaultModel` is properly configured in Robota constructor**
285
+ 4. **Update any hardcoded model references to use runtime switching**
286
+
287
+ ## 🎯 **Benefits**
288
+ - **Eliminates configuration confusion** - Single source of truth for models
289
+ - **Simplifies provider setup** - Just provide API credentials
290
+ - **Enables better runtime control** - Centralized model management
291
+ - **Improves consistency** - All providers follow same pattern
292
+
293
+ - Updated dependencies
294
+ - @robota-sdk/agent-core@2.0.8
295
+
296
+ ## 2.0.7
297
+
298
+ ### Patch Changes
299
+
300
+ - Browser compatibility improvements
301
+ - feat: Implement SimpleLogger system to replace direct console usage for better browser compatibility
302
+ - feat: Centralize SimpleLogger in @robota-sdk/agent-core package and export for other packages
303
+ - feat: Add support for silent and stderr-only logging modes via SilentLogger and StderrLogger
304
+ - refactor: Update all packages (@robota-sdk/agent-provider-openai, @robota-sdk/agent-provider-anthropic, etc.) to use centralized SimpleLogger
305
+ - chore: Add ESLint rules to prevent direct console usage while allowing legitimate cases
306
+ - fix: Remove unused AIProvider import from examples to clean up warnings
307
+
308
+ These changes ensure the SDK works properly in browser environments by removing Node.js-specific console behavior while maintaining full backward compatibility.
309
+
310
+ - Updated dependencies
311
+ - @robota-sdk/agent-core@2.0.7
312
+
313
+ ## 2.0.6
314
+
315
+ ### Patch Changes
316
+
317
+ - Add browser compatibility by removing Node.js dependencies
318
+ - Replace NodeJS.Timeout with cross-platform TimerId type
319
+ - Remove process.env dependency from logger configuration
320
+ - Replace Node.js crypto module with jsSHA library for webhook signatures
321
+ - Update OpenAI stream handlers to work in browser environments
322
+ - Maintain 100% backward compatibility with existing Node.js applications
323
+
324
+ This update enables Robota SDK to run seamlessly in both Node.js and browser environments without breaking changes.
325
+
326
+ - Updated dependencies
327
+ - @robota-sdk/agent-core@2.0.6
328
+
329
+ ## 2.0.5
330
+
331
+ ### Patch Changes
332
+
333
+ - ## 🎯 TypeScript Declaration File Optimization
334
+ - Updated dependencies
335
+ - @robota-sdk/agent-core@2.0.5
336
+
337
+ ## 2.0.4
338
+
339
+ ### Patch Changes
340
+
341
+ - 9f17ac6: Restore README.md files and prevent deletion during build process
342
+ - Updated dependencies [9f17ac6]
343
+ - @robota-sdk/agent-core@2.0.4
344
+
345
+ ## 2.1.0
346
+
347
+ ### Minor Changes
348
+
349
+ - **Production-Ready Architecture**: Complete refactoring from experimental to production-ready state
350
+ - **Purpose Redefinition**: Focused on managing multiple independent AI agents in isolated workspaces
351
+ - **Removed Message Editing**: Eliminated message editing/deletion functionality to focus on core purpose
352
+ - **Simplified Architecture**: ChatInstance now wraps Robota agents with clean delegation
353
+ - **SessionManager Implementation**: Complete multi-session management with workspace isolation
354
+ - **Template Integration**: Integrated with agents package AgentFactory and AgentTemplates
355
+ - **File Cleanup**: Removed duplicate implementations that existed in agents package
356
+ - **Type System Simplification**: Streamlined interfaces and removed complex EnhancedConversationHistory
357
+ - **Comprehensive Testing**: Added full test coverage and working examples
358
+ - **Documentation Overhaul**: Complete README rewrite with architecture diagrams and API reference
359
+
360
+ ### Patch Changes
361
+
362
+ - Updated dependencies
363
+ - @robota-sdk/agent-core@2.1.0
364
+
365
+ ## 2.0.3
366
+
367
+ ### Patch Changes
368
+
369
+ - @robota-sdk/agent-core@2.0.3
370
+
371
+ ## 2.0.2
372
+
373
+ ### Patch Changes
374
+
375
+ - Fix npm package documentation by ensuring README.md files are included
376
+ - Updated dependencies
377
+ - @robota-sdk/agent-core@2.0.2
378
+
379
+ ## 2.0.1
380
+
381
+ ### Patch Changes
382
+
383
+ - Remove unused dependencies from agents and sessions packages
384
+ - Updated dependencies
385
+ - @robota-sdk/agent-core@2.0.1
386
+
387
+ ## 2.0.0
388
+
389
+ ### Major Changes
390
+
391
+ - a3a464c: # Robota SDK v2.0.0-rc.1 - Unified Architecture
392
+
393
+ ## 🚀 Major Changes
394
+
395
+ ### New Unified Core
396
+ - **@robota-sdk/agent-core**: New unified core package consolidating all functionality
397
+ - **Zero `any` types**: Complete TypeScript type safety across all packages
398
+ - **Provider-agnostic design**: Seamless switching between OpenAI, Anthropic, and Google
399
+
400
+ ### Key Features
401
+ - **Multi-Provider Support**: Dynamic provider switching with type safety
402
+ - **Advanced Function Calling**: Type-safe tool system with Zod validation
403
+ - **Real-time Streaming**: Improved streaming with proper error handling
404
+ - **Task Delegation**: Improved delegated workflow support
405
+ - **Plugin Architecture**: Comprehensive plugin system with facade pattern
406
+
407
+ ### Breaking Changes
408
+ - `@robota-sdk/core` functionality moved to `@robota-sdk/agent-core`
409
+ - Redesigned provider interfaces with generic type parameters
410
+ - Updated agent configuration format
411
+
412
+ Complete architecture overhaul focused on type safety and developer experience.
413
+
414
+ ### Patch Changes
415
+
416
+ - Updated dependencies [a3a464c]
417
+ - @robota-sdk/agent-core@2.0.0
418
+
419
+ ## 1.0.5
420
+
421
+ ### Patch Changes
422
+
423
+ - Simplify team API, update docs, fix lint issues, add task coordinator template
424
+ - Updated dependencies
425
+ - @robota-sdk/agent-tools@1.0.5
426
+ - @robota-sdk/core@1.0.5
427
+
428
+ ## 1.0.4
429
+
430
+ ### Patch Changes
431
+
432
+ - Add task delegation tooling with assignTask MCP tools
433
+ - Updated dependencies
434
+ - @robota-sdk/core@1.0.4
435
+ - @robota-sdk/agent-tools@1.0.4
436
+
437
+ ## 1.0.3
438
+
439
+ ### Patch Changes
440
+
441
+ - Complete examples restructure and enhanced provider architecture
442
+ - Updated dependencies
443
+ - @robota-sdk/agent-tools@1.0.3
444
+ - @robota-sdk/core@1.0.3
445
+
446
+ ## 1.0.2
447
+
448
+ ### Patch Changes
449
+
450
+ - Refactor examples and improve resource management
451
+ - Simplified examples from 18+ files to 4 core examples (basic conversation, tool calling, multi-providers, advanced features)
452
+ - Added proper resource cleanup with `robota.close()` method to prevent hanging processes
453
+ - Implemented `ToolProviderManager.close()` for proper tool provider cleanup
454
+ - Added BaseAIProvider abstract class with common functionality for all AI providers
455
+ - Updated package.json scripts and README documentation for better user experience
456
+ - Removed duplicate and redundant example files
457
+ - Added .env.example file for easier setup
458
+
459
+ - Updated dependencies
460
+ - @robota-sdk/core@1.0.2
461
+ - @robota-sdk/agent-tools@1.0.2
462
+
463
+ ## 1.0.1
464
+
465
+ ### Patch Changes
466
+
467
+ - Fix facade pattern tests and conversation history message limits
468
+ - Updated dependencies
469
+ - @robota-sdk/agent-tools@1.0.1
470
+ - @robota-sdk/core@1.0.1
471
+
472
+ ## 1.0.0
473
+
474
+ ### Patch Changes
475
+
476
+ - Updated dependencies
477
+ - @robota-sdk/agent-tools@1.0.0
478
+ - @robota-sdk/core@1.0.0
479
+
480
+ ## 0.3.7
481
+
482
+ ### Patch Changes
483
+
484
+ - Major code quality improvements and architectural refactoring:
485
+ - **Facade Pattern Implementation**: Simplified Robota class interface with manager-based architecture (ai, system, functions, analytics, tools, limits, conversation)
486
+ - **Deprecated Methods Removal**: Removed 20+ deprecated methods, replaced with clean option-based constructor
487
+ - **File Modularization**: Split large files into focused modules (function.ts → 4 modules, conversation-history refactoring)
488
+ - **State Management Enhancement**: Implemented state machine pattern for sessions with improved error handling
489
+ - **Pure Function Optimization**: Reduced complexity with pure functions and better separation of concerns
490
+ - **TypeScript Improvements**: Fixed all compilation errors and improved type safety
491
+ - **Example Updates**: Updated examples to use new API patterns
492
+
493
+ Breaking changes are minimal as the core functionality remains the same, but the internal architecture is significantly cleaner and more maintainable.
494
+
495
+ - Updated dependencies
496
+ - @robota-sdk/agent-tools@0.3.7
497
+ - @robota-sdk/core@0.3.7
498
+
499
+ ## 0.3.6
500
+
501
+ ### Patch Changes
502
+
503
+ - Update publishing docs with proper deployment guidelines
504
+ - Updated dependencies
505
+ - @robota-sdk/agent-tools@0.3.6
506
+ - @robota-sdk/core@0.3.6
507
+
508
+ ## 0.3.5
509
+
510
+ ### Patch Changes
511
+
512
+ - Fix workspace dependencies & update README docs for all packages
513
+ - Updated dependencies
514
+ - @robota-sdk/agent-tools@0.3.5
515
+ - @robota-sdk/core@0.3.5
516
+
517
+ ## 0.3.4
518
+
519
+ ### Patch Changes
520
+
521
+ - f77f18e: Add sessions package for multi-session & chat management in workspaces
522
+ - Updated dependencies [f77f18e]
523
+ - @robota-sdk/agent-tools@0.3.4
524
+ - @robota-sdk/core@0.3.4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Robota Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,142 @@
1
+ # @robota-sdk/agent-session
2
+
3
+ Session lifecycle management for the Robota SDK. Wraps a `Robota` agent instance with permission-gated tool execution, hook-based lifecycle events, context window tracking, conversation compaction, and optional persistence.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @robota-sdk/agent-session @robota-sdk/agent-core
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { Session } from '@robota-sdk/agent-session';
15
+
16
+ const session = new Session({
17
+ tools,
18
+ provider,
19
+ systemMessage: 'You are a helpful assistant.',
20
+ terminal,
21
+ permissions: { allow: ['Read(*)'], deny: [] },
22
+ autoCompactThreshold: 0.75,
23
+ });
24
+
25
+ const response = await session.run('Hello!');
26
+
27
+ // Context tracking
28
+ const state = session.getContextState();
29
+ console.log(`${state.usedPercentage.toFixed(1)}% context used`);
30
+
31
+ // Manual compaction
32
+ await session.compact('Focus on the API changes');
33
+ ```
34
+
35
+ ## Features
36
+
37
+ | Feature | Description |
38
+ | -------------------------- | ---------------------------------------------------------------------------------------------------------- |
39
+ | **Permission enforcement** | Tool calls gated by 3-step policy (deny list, allow list, mode policy) |
40
+ | **Hook execution** | PreToolUse, PostToolUse, PreCompact, PostCompact, SessionStart, Stop |
41
+ | **Context tracking** | Effective token usage from the shared core estimator, configurable auto-compact threshold (default ~83.5%) |
42
+ | **Compaction** | LLM-generated conversation summary to free context space |
43
+ | **Persistence** | `SessionStore` for JSON file-based session save/load |
44
+ | **Abort** | Cancel via `session.abort()` — propagates AbortSignal to `robota.run()`, throws `AbortError` to caller |
45
+ | **Session logging** | `FileSessionLogger` writes JSONL event logs |
46
+ | **Replay events** | Provider/tool execution boundary events are forwarded from core into append-only session logs |
47
+ | **Provider capabilities** | Generic native web capability setup is requested through the provider contract, not provider-name branches |
48
+
49
+ ## Key Methods
50
+
51
+ | Method | Description |
52
+ | ------------------------------------------------- | ------------------------------------------------------------------ |
53
+ | `constructor(options)` (with `sessionId`) | Accepts optional `sessionId` for deterministic IDs |
54
+ | `run(message)` | Send a message, returns AI response |
55
+ | `injectMessage(message)` | Inject a message into history without running the agent |
56
+ | `compact(instructions?)` | Compress conversation via LLM summary |
57
+ | `getContextState()` | Effective token usage: `{ usedTokens, maxTokens, usedPercentage }` |
58
+ | `getAutoCompactThreshold()` | Auto-compact threshold fraction, or `false` if disabled |
59
+ | `getPermissionMode()` / `setPermissionMode(mode)` | Read/change permission mode |
60
+ | `getHistory()` / `clearHistory()` | Access or clear conversation history |
61
+ | `abort()` | Cancel running execution |
62
+ | `isRunning()` | Returns true if a `run()` call is in progress |
63
+ | `getSessionId()` | Returns the stable session identifier |
64
+ | `getMessageCount()` | Returns the number of completed `run()` calls |
65
+ | `getSessionAllowedTools()` | Tools approved for this session |
66
+ | `clearSessionAllowedTools()` | Clears all session-scoped allow rules |
67
+
68
+ ## Public API Surface
69
+
70
+ | Export | Kind | Description |
71
+ | ------------------------ | --------- | ------------------------------------------------------------ |
72
+ | `Session` | Class | Wraps Robota with permissions, hooks, streaming, persistence |
73
+ | `PermissionEnforcer` | Class | Tool permission checking, hook execution, output truncation |
74
+ | `ContextWindowTracker` | Class | Effective token usage tracking and auto-compact threshold |
75
+ | `CompactionOrchestrator` | Class | Conversation compaction via LLM summary |
76
+ | `SessionStore` | Class | JSON file persistence for session records |
77
+ | `FileSessionLogger` | Class | JSONL file-based session event logger |
78
+ | `SilentSessionLogger` | Class | No-op session logger |
79
+ | `ISessionOptions` | Interface | Constructor options for Session |
80
+ | `TAutoCompactThreshold` | Type | Auto-compact threshold fraction, or `false` to disable |
81
+ | `TPermissionHandler` | Type | Custom permission approval callback |
82
+ | `TPermissionResult` | Type | Permission decision result (`boolean \| 'allow-session'`) |
83
+ | `ITerminalOutput` | Interface | Terminal I/O abstraction (write, prompt, select, spinner) |
84
+ | `ISpinner` | Interface | Spinner handle |
85
+ | `ISessionLogger` | Interface | Pluggable session event logger interface |
86
+ | `TSessionLogData` | Type | Structured log event data |
87
+ | `ISessionRecord` | Interface | Persisted session record shape (includes `history` field) |
88
+ | `ISessionStore` | Interface | Minimal persistence port implemented by `SessionStore` |
89
+ | `IContextWindowState` | Type | Context window usage state (re-exported from agent-core) |
90
+
91
+ Note: `IPermissionEnforcerOptions` is an internal type and is not exported from the public API.
92
+
93
+ ## Sub-Components
94
+
95
+ | Component | Purpose |
96
+ | ------------------------ | ------------------------------------------------------------------- |
97
+ | `PermissionEnforcer` | Tool wrapping, permission checks, hook execution, output truncation |
98
+ | `ContextWindowTracker` | Token usage tracking, auto-compact threshold |
99
+ | `CompactionOrchestrator` | Conversation summarization via LLM |
100
+
101
+ ## Session vs Robota
102
+
103
+ - **`Robota`** (agent-core): Raw agent — conversation + tools + plugins. No permissions, no hooks.
104
+ - **`Session`** (this package): Wraps Robota with permissions, hooks, compaction, and persistence. Used by the CLI and SDK.
105
+
106
+ ### ISessionRecord
107
+
108
+ `ISessionRecord` includes a required `history` field (`IHistoryEntry[]`) that stores the full conversation timeline for session persistence, resume, and fork operations. It may also include `backgroundTasks` and `backgroundTaskEvents` so background work can be restored and debugged alongside the conversation. When a session is resumed, history entries are replayed via `Session.injectMessage()`.
109
+
110
+ Streaming text deltas are written to append-only JSONL session logs as `text_delta` events. Consumers should store high-frequency streaming chunks in JSONL logs/transcripts and keep session JSON focused on resumable snapshots and references.
111
+
112
+ ### Replay-Oriented JSONL Events
113
+
114
+ `Session.run()` forwards core execution events into the session logger through `onExecutionEvent`. Current events include:
115
+
116
+ - `provider_request`
117
+ - `provider_native_raw_payload`
118
+ - `provider_stream_raw_delta`
119
+ - `provider_response_raw`
120
+ - `provider_response_normalized`
121
+ - `assistant_message_committed`
122
+ - `tool_batch_started`
123
+ - `tool_execution_request`
124
+ - `tool_execution_result`
125
+ - `tool_message_committed`
126
+ - `history_mutation`
127
+
128
+ `FileSessionLogger` redacts common secret fields before writing logs and stores large fields as content-addressed JSON payload references under `{sessionId}.payloads/`. `session-log-replay` exports replay readers and validators that reconstruct chat history from `history_mutation` and report missing provider/tool terminal events. Replay validation now also requires provider-native raw response or stream payload coverage for each `provider_request`.
129
+
130
+ A migration script is available for upgrading session records from older formats. See the package source for details.
131
+
132
+ ## Assembly
133
+
134
+ Most users should use `createSession()` from `@robota-sdk/agent-framework` instead of constructing `Session` directly. The SDK factory wires tools, provider, and system prompt automatically from config and context.
135
+
136
+ ## Dependencies
137
+
138
+ - `@robota-sdk/agent-core` (production) — Robota agent, permission system, hook system, core types
139
+
140
+ ## License
141
+
142
+ MIT