@robota-sdk/agent-sdk 3.0.0-beta.45 → 3.0.0-beta.46
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/README.md +7 -1
- package/dist/node/index.cjs +111 -1
- package/dist/node/index.d.cts +20 -0
- package/dist/node/index.d.ts +20 -0
- package/dist/node/index.js +111 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -84,7 +84,9 @@ const session = new InteractiveSession({
|
|
|
84
84
|
config,
|
|
85
85
|
context,
|
|
86
86
|
projectInfo,
|
|
87
|
-
sessionStore,
|
|
87
|
+
sessionStore, // SessionStore instance for persistence
|
|
88
|
+
resumeSessionId, // Session ID to restore (optional)
|
|
89
|
+
forkSession, // Session ID to fork from (optional)
|
|
88
90
|
permissionMode: 'default',
|
|
89
91
|
maxTurns: 10,
|
|
90
92
|
cwd: process.cwd(),
|
|
@@ -144,6 +146,10 @@ session.getContextState(); // IContextWindowState
|
|
|
144
146
|
session.getStreamingText(); // string (accumulated so far)
|
|
145
147
|
session.getActiveTools(); // IToolState[]
|
|
146
148
|
|
|
149
|
+
// Session naming
|
|
150
|
+
session.getName(); // string | undefined
|
|
151
|
+
session.setName('my-task'); // sets the session name
|
|
152
|
+
|
|
147
153
|
// Access underlying Session for advanced use
|
|
148
154
|
session.getSession(); // Session
|
|
149
155
|
```
|
package/dist/node/index.cjs
CHANGED
|
@@ -713,6 +713,7 @@ function createSession(options) {
|
|
|
713
713
|
model: options.config.provider.model,
|
|
714
714
|
maxTurns: options.maxTurns,
|
|
715
715
|
sessionStore: options.sessionStore,
|
|
716
|
+
sessionId: options.sessionId,
|
|
716
717
|
permissionHandler: options.permissionHandler,
|
|
717
718
|
onTextDelta: options.onTextDelta,
|
|
718
719
|
onToolExecution: options.onToolExecution,
|
|
@@ -1117,6 +1118,8 @@ function createSystemCommands() {
|
|
|
1117
1118
|
" cost \u2014 Show session info",
|
|
1118
1119
|
" context \u2014 Context window info",
|
|
1119
1120
|
" permissions \u2014 Permission rules",
|
|
1121
|
+
" resume \u2014 Resume a previous session",
|
|
1122
|
+
" rename <name> \u2014 Rename the current session",
|
|
1120
1123
|
" reset \u2014 Delete settings and exit"
|
|
1121
1124
|
].join("\n"),
|
|
1122
1125
|
success: true
|
|
@@ -1255,6 +1258,30 @@ Messages: ${messageCount}`,
|
|
|
1255
1258
|
};
|
|
1256
1259
|
}
|
|
1257
1260
|
},
|
|
1261
|
+
{
|
|
1262
|
+
name: "resume",
|
|
1263
|
+
description: "Resume a previous session",
|
|
1264
|
+
execute: (_session, _args) => ({
|
|
1265
|
+
message: "Opening session picker...",
|
|
1266
|
+
success: true,
|
|
1267
|
+
data: { triggerResumePicker: true }
|
|
1268
|
+
})
|
|
1269
|
+
},
|
|
1270
|
+
{
|
|
1271
|
+
name: "rename",
|
|
1272
|
+
description: "Rename the current session",
|
|
1273
|
+
execute: (_session, args) => {
|
|
1274
|
+
const name = args.trim();
|
|
1275
|
+
if (!name) {
|
|
1276
|
+
return { message: "Usage: rename <name>", success: false };
|
|
1277
|
+
}
|
|
1278
|
+
return {
|
|
1279
|
+
message: `Session renamed to "${name}".`,
|
|
1280
|
+
success: true,
|
|
1281
|
+
data: { name }
|
|
1282
|
+
};
|
|
1283
|
+
}
|
|
1284
|
+
},
|
|
1258
1285
|
{
|
|
1259
1286
|
name: "reset",
|
|
1260
1287
|
description: "Delete settings",
|
|
@@ -2180,6 +2207,14 @@ var InteractiveSession = class {
|
|
|
2180
2207
|
pendingRawInput;
|
|
2181
2208
|
// Full history timeline (chat messages + events)
|
|
2182
2209
|
history = [];
|
|
2210
|
+
// Session persistence
|
|
2211
|
+
sessionStore;
|
|
2212
|
+
sessionName;
|
|
2213
|
+
cwd;
|
|
2214
|
+
// Session restore state
|
|
2215
|
+
pendingRestoreMessages = null;
|
|
2216
|
+
resumeSessionId;
|
|
2217
|
+
forkSession;
|
|
2183
2218
|
constructor(options) {
|
|
2184
2219
|
this.commandExecutor = new SystemCommandExecutor(createSystemCommands());
|
|
2185
2220
|
if ("session" in options && options.session) {
|
|
@@ -2189,6 +2224,30 @@ var InteractiveSession = class {
|
|
|
2189
2224
|
const stdOpts = options;
|
|
2190
2225
|
this.initPromise = this.initializeAsync(stdOpts);
|
|
2191
2226
|
}
|
|
2227
|
+
this.sessionStore = options.sessionStore;
|
|
2228
|
+
this.sessionName = options.sessionName;
|
|
2229
|
+
this.cwd = ("cwd" in options ? options.cwd : void 0) ?? "";
|
|
2230
|
+
this.resumeSessionId = options.resumeSessionId;
|
|
2231
|
+
this.forkSession = options.forkSession ?? false;
|
|
2232
|
+
if (options.resumeSessionId && this.sessionStore) {
|
|
2233
|
+
const record = this.sessionStore.load(options.resumeSessionId);
|
|
2234
|
+
if (record) {
|
|
2235
|
+
this.history = record.history ?? [];
|
|
2236
|
+
this.sessionName = record.name;
|
|
2237
|
+
if (record.messages) {
|
|
2238
|
+
if (this.session) {
|
|
2239
|
+
for (const msg of record.messages) {
|
|
2240
|
+
const m = msg;
|
|
2241
|
+
if (m.role && m.content) {
|
|
2242
|
+
this.session.injectMessage(m.role, m.content);
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
} else {
|
|
2246
|
+
this.pendingRestoreMessages = record.messages;
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2192
2251
|
}
|
|
2193
2252
|
async initializeAsync(options) {
|
|
2194
2253
|
const cwd = options.cwd;
|
|
@@ -2215,6 +2274,7 @@ var InteractiveSession = class {
|
|
|
2215
2274
|
} catch {
|
|
2216
2275
|
}
|
|
2217
2276
|
const paths = projectPaths(cwd);
|
|
2277
|
+
const sessionId = this.resumeSessionId && !this.forkSession ? this.resumeSessionId : void 0;
|
|
2218
2278
|
this.session = createSession({
|
|
2219
2279
|
config: mergedConfig,
|
|
2220
2280
|
context,
|
|
@@ -2226,8 +2286,20 @@ var InteractiveSession = class {
|
|
|
2226
2286
|
permissionHandler: options.permissionHandler,
|
|
2227
2287
|
provider: options.provider,
|
|
2228
2288
|
onTextDelta: (delta) => this.handleTextDelta(delta),
|
|
2229
|
-
onToolExecution: (event) => this.handleToolExecution(event)
|
|
2289
|
+
onToolExecution: (event) => this.handleToolExecution(event),
|
|
2290
|
+
sessionId
|
|
2230
2291
|
});
|
|
2292
|
+
if (this.pendingRestoreMessages) {
|
|
2293
|
+
for (const msg of this.pendingRestoreMessages) {
|
|
2294
|
+
if (msg && typeof msg === "object" && "role" in msg && "content" in msg) {
|
|
2295
|
+
this.session.injectMessage(
|
|
2296
|
+
msg.role,
|
|
2297
|
+
msg.content
|
|
2298
|
+
);
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
this.pendingRestoreMessages = null;
|
|
2302
|
+
}
|
|
2231
2303
|
this.initialized = true;
|
|
2232
2304
|
}
|
|
2233
2305
|
async ensureInitialized() {
|
|
@@ -2317,6 +2389,26 @@ var InteractiveSession = class {
|
|
|
2317
2389
|
getContextState() {
|
|
2318
2390
|
return this.getSessionOrThrow().getContextState();
|
|
2319
2391
|
}
|
|
2392
|
+
/** Get session name. */
|
|
2393
|
+
getName() {
|
|
2394
|
+
return this.sessionName;
|
|
2395
|
+
}
|
|
2396
|
+
/** Set session name and persist if store is available. */
|
|
2397
|
+
setName(name) {
|
|
2398
|
+
this.sessionName = name;
|
|
2399
|
+
if (this.sessionStore && this.session) {
|
|
2400
|
+
try {
|
|
2401
|
+
const id = this.getSessionOrThrow().getSessionId();
|
|
2402
|
+
const existing = this.sessionStore.load(id);
|
|
2403
|
+
if (existing) {
|
|
2404
|
+
existing.name = name;
|
|
2405
|
+
existing.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2406
|
+
this.sessionStore.save(existing);
|
|
2407
|
+
}
|
|
2408
|
+
} catch {
|
|
2409
|
+
}
|
|
2410
|
+
}
|
|
2411
|
+
}
|
|
2320
2412
|
/** Access underlying Session. For advanced use / testing only. */
|
|
2321
2413
|
getSession() {
|
|
2322
2414
|
return this.getSessionOrThrow();
|
|
@@ -2358,6 +2450,22 @@ var InteractiveSession = class {
|
|
|
2358
2450
|
} finally {
|
|
2359
2451
|
this.executing = false;
|
|
2360
2452
|
this.emit("thinking", false);
|
|
2453
|
+
if (this.sessionStore && this.session) {
|
|
2454
|
+
try {
|
|
2455
|
+
const sessionId = this.getSessionOrThrow().getSessionId();
|
|
2456
|
+
const existing = this.sessionStore.load(sessionId);
|
|
2457
|
+
this.sessionStore.save({
|
|
2458
|
+
id: sessionId,
|
|
2459
|
+
name: this.sessionName ?? existing?.name,
|
|
2460
|
+
cwd: this.cwd ?? "",
|
|
2461
|
+
createdAt: existing?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
2462
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2463
|
+
messages: this.getSessionOrThrow().getHistory(),
|
|
2464
|
+
history: this.history
|
|
2465
|
+
});
|
|
2466
|
+
} catch {
|
|
2467
|
+
}
|
|
2468
|
+
}
|
|
2361
2469
|
if (this.pendingPrompt) {
|
|
2362
2470
|
const queued = this.pendingPrompt;
|
|
2363
2471
|
const queuedDisplay = this.pendingDisplayInput;
|
|
@@ -2645,6 +2753,8 @@ function createBuiltinCommands() {
|
|
|
2645
2753
|
{ name: "cost", description: "Show session info", source: "builtin" },
|
|
2646
2754
|
{ name: "context", description: "Context window info", source: "builtin" },
|
|
2647
2755
|
{ name: "permissions", description: "Permission rules", source: "builtin" },
|
|
2756
|
+
{ name: "resume", description: "Resume a previous session", source: "builtin" },
|
|
2757
|
+
{ name: "rename", description: "Rename the current session", source: "builtin" },
|
|
2648
2758
|
{ name: "plugin", description: "Manage plugins", source: "builtin" },
|
|
2649
2759
|
{ name: "reload-plugins", description: "Reload all plugin resources", source: "builtin" },
|
|
2650
2760
|
{ name: "reset", description: "Delete settings and exit", source: "builtin" },
|
package/dist/node/index.d.cts
CHANGED
|
@@ -210,6 +210,8 @@ interface ICreateSessionOptions {
|
|
|
210
210
|
sessionFactory?: TSessionFactory;
|
|
211
211
|
/** Additional hook type executors beyond the defaults (prompt, agent). */
|
|
212
212
|
additionalHookExecutors?: IHookTypeExecutor[];
|
|
213
|
+
/** Override session ID (used when resuming a session to reuse the original ID) */
|
|
214
|
+
sessionId?: string;
|
|
213
215
|
}
|
|
214
216
|
|
|
215
217
|
/**
|
|
@@ -420,6 +422,10 @@ interface IInteractiveSessionStandardOptions {
|
|
|
420
422
|
permissionMode?: ICreateSessionOptions['permissionMode'];
|
|
421
423
|
maxTurns?: number;
|
|
422
424
|
permissionHandler?: TInteractivePermissionHandler;
|
|
425
|
+
sessionStore?: SessionStore;
|
|
426
|
+
sessionName?: string;
|
|
427
|
+
resumeSessionId?: string;
|
|
428
|
+
forkSession?: boolean;
|
|
423
429
|
}
|
|
424
430
|
/** Test/advanced construction: inject pre-built session directly. */
|
|
425
431
|
interface IInteractiveSessionInjectedOptions {
|
|
@@ -429,6 +435,10 @@ interface IInteractiveSessionInjectedOptions {
|
|
|
429
435
|
permissionMode?: ICreateSessionOptions['permissionMode'];
|
|
430
436
|
maxTurns?: number;
|
|
431
437
|
permissionHandler?: TInteractivePermissionHandler;
|
|
438
|
+
sessionStore?: SessionStore;
|
|
439
|
+
sessionName?: string;
|
|
440
|
+
resumeSessionId?: string;
|
|
441
|
+
forkSession?: boolean;
|
|
432
442
|
}
|
|
433
443
|
type IInteractiveSessionOptions = IInteractiveSessionStandardOptions | IInteractiveSessionInjectedOptions;
|
|
434
444
|
declare class InteractiveSession {
|
|
@@ -445,6 +455,12 @@ declare class InteractiveSession {
|
|
|
445
455
|
private pendingDisplayInput;
|
|
446
456
|
private pendingRawInput;
|
|
447
457
|
private history;
|
|
458
|
+
private sessionStore?;
|
|
459
|
+
private sessionName?;
|
|
460
|
+
private cwd?;
|
|
461
|
+
private pendingRestoreMessages;
|
|
462
|
+
private resumeSessionId?;
|
|
463
|
+
private forkSession;
|
|
448
464
|
constructor(options: IInteractiveSessionOptions);
|
|
449
465
|
private initializeAsync;
|
|
450
466
|
private ensureInitialized;
|
|
@@ -478,6 +494,10 @@ declare class InteractiveSession {
|
|
|
478
494
|
getStreamingText(): string;
|
|
479
495
|
getActiveTools(): IToolState[];
|
|
480
496
|
getContextState(): IContextWindowState;
|
|
497
|
+
/** Get session name. */
|
|
498
|
+
getName(): string | undefined;
|
|
499
|
+
/** Set session name and persist if store is available. */
|
|
500
|
+
setName(name: string): void;
|
|
481
501
|
/** Access underlying Session. For advanced use / testing only. */
|
|
482
502
|
getSession(): Session;
|
|
483
503
|
private executePrompt;
|
package/dist/node/index.d.ts
CHANGED
|
@@ -210,6 +210,8 @@ interface ICreateSessionOptions {
|
|
|
210
210
|
sessionFactory?: TSessionFactory;
|
|
211
211
|
/** Additional hook type executors beyond the defaults (prompt, agent). */
|
|
212
212
|
additionalHookExecutors?: IHookTypeExecutor[];
|
|
213
|
+
/** Override session ID (used when resuming a session to reuse the original ID) */
|
|
214
|
+
sessionId?: string;
|
|
213
215
|
}
|
|
214
216
|
|
|
215
217
|
/**
|
|
@@ -420,6 +422,10 @@ interface IInteractiveSessionStandardOptions {
|
|
|
420
422
|
permissionMode?: ICreateSessionOptions['permissionMode'];
|
|
421
423
|
maxTurns?: number;
|
|
422
424
|
permissionHandler?: TInteractivePermissionHandler;
|
|
425
|
+
sessionStore?: SessionStore;
|
|
426
|
+
sessionName?: string;
|
|
427
|
+
resumeSessionId?: string;
|
|
428
|
+
forkSession?: boolean;
|
|
423
429
|
}
|
|
424
430
|
/** Test/advanced construction: inject pre-built session directly. */
|
|
425
431
|
interface IInteractiveSessionInjectedOptions {
|
|
@@ -429,6 +435,10 @@ interface IInteractiveSessionInjectedOptions {
|
|
|
429
435
|
permissionMode?: ICreateSessionOptions['permissionMode'];
|
|
430
436
|
maxTurns?: number;
|
|
431
437
|
permissionHandler?: TInteractivePermissionHandler;
|
|
438
|
+
sessionStore?: SessionStore;
|
|
439
|
+
sessionName?: string;
|
|
440
|
+
resumeSessionId?: string;
|
|
441
|
+
forkSession?: boolean;
|
|
432
442
|
}
|
|
433
443
|
type IInteractiveSessionOptions = IInteractiveSessionStandardOptions | IInteractiveSessionInjectedOptions;
|
|
434
444
|
declare class InteractiveSession {
|
|
@@ -445,6 +455,12 @@ declare class InteractiveSession {
|
|
|
445
455
|
private pendingDisplayInput;
|
|
446
456
|
private pendingRawInput;
|
|
447
457
|
private history;
|
|
458
|
+
private sessionStore?;
|
|
459
|
+
private sessionName?;
|
|
460
|
+
private cwd?;
|
|
461
|
+
private pendingRestoreMessages;
|
|
462
|
+
private resumeSessionId?;
|
|
463
|
+
private forkSession;
|
|
448
464
|
constructor(options: IInteractiveSessionOptions);
|
|
449
465
|
private initializeAsync;
|
|
450
466
|
private ensureInitialized;
|
|
@@ -478,6 +494,10 @@ declare class InteractiveSession {
|
|
|
478
494
|
getStreamingText(): string;
|
|
479
495
|
getActiveTools(): IToolState[];
|
|
480
496
|
getContextState(): IContextWindowState;
|
|
497
|
+
/** Get session name. */
|
|
498
|
+
getName(): string | undefined;
|
|
499
|
+
/** Set session name and persist if store is available. */
|
|
500
|
+
setName(name: string): void;
|
|
481
501
|
/** Access underlying Session. For advanced use / testing only. */
|
|
482
502
|
getSession(): Session;
|
|
483
503
|
private executePrompt;
|
package/dist/node/index.js
CHANGED
|
@@ -650,6 +650,7 @@ function createSession(options) {
|
|
|
650
650
|
model: options.config.provider.model,
|
|
651
651
|
maxTurns: options.maxTurns,
|
|
652
652
|
sessionStore: options.sessionStore,
|
|
653
|
+
sessionId: options.sessionId,
|
|
653
654
|
permissionHandler: options.permissionHandler,
|
|
654
655
|
onTextDelta: options.onTextDelta,
|
|
655
656
|
onToolExecution: options.onToolExecution,
|
|
@@ -1059,6 +1060,8 @@ function createSystemCommands() {
|
|
|
1059
1060
|
" cost \u2014 Show session info",
|
|
1060
1061
|
" context \u2014 Context window info",
|
|
1061
1062
|
" permissions \u2014 Permission rules",
|
|
1063
|
+
" resume \u2014 Resume a previous session",
|
|
1064
|
+
" rename <name> \u2014 Rename the current session",
|
|
1062
1065
|
" reset \u2014 Delete settings and exit"
|
|
1063
1066
|
].join("\n"),
|
|
1064
1067
|
success: true
|
|
@@ -1197,6 +1200,30 @@ Messages: ${messageCount}`,
|
|
|
1197
1200
|
};
|
|
1198
1201
|
}
|
|
1199
1202
|
},
|
|
1203
|
+
{
|
|
1204
|
+
name: "resume",
|
|
1205
|
+
description: "Resume a previous session",
|
|
1206
|
+
execute: (_session, _args) => ({
|
|
1207
|
+
message: "Opening session picker...",
|
|
1208
|
+
success: true,
|
|
1209
|
+
data: { triggerResumePicker: true }
|
|
1210
|
+
})
|
|
1211
|
+
},
|
|
1212
|
+
{
|
|
1213
|
+
name: "rename",
|
|
1214
|
+
description: "Rename the current session",
|
|
1215
|
+
execute: (_session, args) => {
|
|
1216
|
+
const name = args.trim();
|
|
1217
|
+
if (!name) {
|
|
1218
|
+
return { message: "Usage: rename <name>", success: false };
|
|
1219
|
+
}
|
|
1220
|
+
return {
|
|
1221
|
+
message: `Session renamed to "${name}".`,
|
|
1222
|
+
success: true,
|
|
1223
|
+
data: { name }
|
|
1224
|
+
};
|
|
1225
|
+
}
|
|
1226
|
+
},
|
|
1200
1227
|
{
|
|
1201
1228
|
name: "reset",
|
|
1202
1229
|
description: "Delete settings",
|
|
@@ -2130,6 +2157,14 @@ var InteractiveSession = class {
|
|
|
2130
2157
|
pendingRawInput;
|
|
2131
2158
|
// Full history timeline (chat messages + events)
|
|
2132
2159
|
history = [];
|
|
2160
|
+
// Session persistence
|
|
2161
|
+
sessionStore;
|
|
2162
|
+
sessionName;
|
|
2163
|
+
cwd;
|
|
2164
|
+
// Session restore state
|
|
2165
|
+
pendingRestoreMessages = null;
|
|
2166
|
+
resumeSessionId;
|
|
2167
|
+
forkSession;
|
|
2133
2168
|
constructor(options) {
|
|
2134
2169
|
this.commandExecutor = new SystemCommandExecutor(createSystemCommands());
|
|
2135
2170
|
if ("session" in options && options.session) {
|
|
@@ -2139,6 +2174,30 @@ var InteractiveSession = class {
|
|
|
2139
2174
|
const stdOpts = options;
|
|
2140
2175
|
this.initPromise = this.initializeAsync(stdOpts);
|
|
2141
2176
|
}
|
|
2177
|
+
this.sessionStore = options.sessionStore;
|
|
2178
|
+
this.sessionName = options.sessionName;
|
|
2179
|
+
this.cwd = ("cwd" in options ? options.cwd : void 0) ?? "";
|
|
2180
|
+
this.resumeSessionId = options.resumeSessionId;
|
|
2181
|
+
this.forkSession = options.forkSession ?? false;
|
|
2182
|
+
if (options.resumeSessionId && this.sessionStore) {
|
|
2183
|
+
const record = this.sessionStore.load(options.resumeSessionId);
|
|
2184
|
+
if (record) {
|
|
2185
|
+
this.history = record.history ?? [];
|
|
2186
|
+
this.sessionName = record.name;
|
|
2187
|
+
if (record.messages) {
|
|
2188
|
+
if (this.session) {
|
|
2189
|
+
for (const msg of record.messages) {
|
|
2190
|
+
const m = msg;
|
|
2191
|
+
if (m.role && m.content) {
|
|
2192
|
+
this.session.injectMessage(m.role, m.content);
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
} else {
|
|
2196
|
+
this.pendingRestoreMessages = record.messages;
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2142
2201
|
}
|
|
2143
2202
|
async initializeAsync(options) {
|
|
2144
2203
|
const cwd = options.cwd;
|
|
@@ -2165,6 +2224,7 @@ var InteractiveSession = class {
|
|
|
2165
2224
|
} catch {
|
|
2166
2225
|
}
|
|
2167
2226
|
const paths = projectPaths(cwd);
|
|
2227
|
+
const sessionId = this.resumeSessionId && !this.forkSession ? this.resumeSessionId : void 0;
|
|
2168
2228
|
this.session = createSession({
|
|
2169
2229
|
config: mergedConfig,
|
|
2170
2230
|
context,
|
|
@@ -2176,8 +2236,20 @@ var InteractiveSession = class {
|
|
|
2176
2236
|
permissionHandler: options.permissionHandler,
|
|
2177
2237
|
provider: options.provider,
|
|
2178
2238
|
onTextDelta: (delta) => this.handleTextDelta(delta),
|
|
2179
|
-
onToolExecution: (event) => this.handleToolExecution(event)
|
|
2239
|
+
onToolExecution: (event) => this.handleToolExecution(event),
|
|
2240
|
+
sessionId
|
|
2180
2241
|
});
|
|
2242
|
+
if (this.pendingRestoreMessages) {
|
|
2243
|
+
for (const msg of this.pendingRestoreMessages) {
|
|
2244
|
+
if (msg && typeof msg === "object" && "role" in msg && "content" in msg) {
|
|
2245
|
+
this.session.injectMessage(
|
|
2246
|
+
msg.role,
|
|
2247
|
+
msg.content
|
|
2248
|
+
);
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
this.pendingRestoreMessages = null;
|
|
2252
|
+
}
|
|
2181
2253
|
this.initialized = true;
|
|
2182
2254
|
}
|
|
2183
2255
|
async ensureInitialized() {
|
|
@@ -2267,6 +2339,26 @@ var InteractiveSession = class {
|
|
|
2267
2339
|
getContextState() {
|
|
2268
2340
|
return this.getSessionOrThrow().getContextState();
|
|
2269
2341
|
}
|
|
2342
|
+
/** Get session name. */
|
|
2343
|
+
getName() {
|
|
2344
|
+
return this.sessionName;
|
|
2345
|
+
}
|
|
2346
|
+
/** Set session name and persist if store is available. */
|
|
2347
|
+
setName(name) {
|
|
2348
|
+
this.sessionName = name;
|
|
2349
|
+
if (this.sessionStore && this.session) {
|
|
2350
|
+
try {
|
|
2351
|
+
const id = this.getSessionOrThrow().getSessionId();
|
|
2352
|
+
const existing = this.sessionStore.load(id);
|
|
2353
|
+
if (existing) {
|
|
2354
|
+
existing.name = name;
|
|
2355
|
+
existing.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2356
|
+
this.sessionStore.save(existing);
|
|
2357
|
+
}
|
|
2358
|
+
} catch {
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2270
2362
|
/** Access underlying Session. For advanced use / testing only. */
|
|
2271
2363
|
getSession() {
|
|
2272
2364
|
return this.getSessionOrThrow();
|
|
@@ -2308,6 +2400,22 @@ var InteractiveSession = class {
|
|
|
2308
2400
|
} finally {
|
|
2309
2401
|
this.executing = false;
|
|
2310
2402
|
this.emit("thinking", false);
|
|
2403
|
+
if (this.sessionStore && this.session) {
|
|
2404
|
+
try {
|
|
2405
|
+
const sessionId = this.getSessionOrThrow().getSessionId();
|
|
2406
|
+
const existing = this.sessionStore.load(sessionId);
|
|
2407
|
+
this.sessionStore.save({
|
|
2408
|
+
id: sessionId,
|
|
2409
|
+
name: this.sessionName ?? existing?.name,
|
|
2410
|
+
cwd: this.cwd ?? "",
|
|
2411
|
+
createdAt: existing?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
2412
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2413
|
+
messages: this.getSessionOrThrow().getHistory(),
|
|
2414
|
+
history: this.history
|
|
2415
|
+
});
|
|
2416
|
+
} catch {
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2311
2419
|
if (this.pendingPrompt) {
|
|
2312
2420
|
const queued = this.pendingPrompt;
|
|
2313
2421
|
const queuedDisplay = this.pendingDisplayInput;
|
|
@@ -2595,6 +2703,8 @@ function createBuiltinCommands() {
|
|
|
2595
2703
|
{ name: "cost", description: "Show session info", source: "builtin" },
|
|
2596
2704
|
{ name: "context", description: "Context window info", source: "builtin" },
|
|
2597
2705
|
{ name: "permissions", description: "Permission rules", source: "builtin" },
|
|
2706
|
+
{ name: "resume", description: "Resume a previous session", source: "builtin" },
|
|
2707
|
+
{ name: "rename", description: "Rename the current session", source: "builtin" },
|
|
2598
2708
|
{ name: "plugin", description: "Manage plugins", source: "builtin" },
|
|
2599
2709
|
{ name: "reload-plugins", description: "Reload all plugin resources", source: "builtin" },
|
|
2600
2710
|
{ name: "reset", description: "Delete settings and exit", source: "builtin" },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@robota-sdk/agent-sdk",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.46",
|
|
4
4
|
"description": "Programmatic SDK for building AI agents with Robota — provides Session, query(), built-in tools, permissions, hooks, and context loading",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/node/index.js",
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"chalk": "^5.3.0",
|
|
26
26
|
"zod": "^3.24.0",
|
|
27
|
-
"@robota-sdk/agent-core": "3.0.0-beta.
|
|
28
|
-
"@robota-sdk/agent-sessions": "3.0.0-beta.
|
|
29
|
-
"@robota-sdk/agent-tools": "3.0.0-beta.
|
|
27
|
+
"@robota-sdk/agent-core": "3.0.0-beta.46",
|
|
28
|
+
"@robota-sdk/agent-sessions": "3.0.0-beta.46",
|
|
29
|
+
"@robota-sdk/agent-tools": "3.0.0-beta.46"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"rimraf": "^5.0.5",
|