@nuvin/session 0.2.0-rc.7 → 0.2.0-rc.9
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/chunk-7LEIACBZ.js +85 -0
- package/dist/{chunk-I5U3WU6B.js → chunk-KQHHBUVY.js} +112 -32
- package/dist/{chunk-MRVGQ4DK.js → chunk-O3UBTUIO.js} +1 -1
- package/dist/client/daemon-client.d.ts.map +1 -1
- package/dist/client/data-client.d.ts +10 -15
- package/dist/client/data-client.d.ts.map +1 -1
- package/dist/client/directory.d.ts +12 -14
- package/dist/client/directory.d.ts.map +1 -1
- package/dist/client/http-data-client.d.ts +5 -0
- package/dist/client/http-data-client.d.ts.map +1 -1
- package/dist/client/index.js +90 -23
- package/dist/client/session-client.d.ts +2 -2
- package/dist/client/session-client.d.ts.map +1 -1
- package/dist/controller/agent-channel.d.ts +2 -2
- package/dist/controller/agent-channel.d.ts.map +1 -1
- package/dist/controller/index.js +131 -52
- package/dist/controller/session-controller.d.ts +12 -12
- package/dist/controller/session-controller.d.ts.map +1 -1
- package/dist/protocol/data-rpc.d.ts +13 -14
- package/dist/protocol/data-rpc.d.ts.map +1 -1
- package/dist/protocol/history-text.d.ts +4 -0
- package/dist/protocol/history-text.d.ts.map +1 -0
- package/dist/protocol/index.d.ts +1 -0
- package/dist/protocol/index.d.ts.map +1 -1
- package/dist/protocol/index.js +12 -4
- package/dist/protocol/model-identity.d.ts +7 -0
- package/dist/protocol/model-identity.d.ts.map +1 -1
- package/dist/protocol/types.d.ts +85 -18
- package/dist/protocol/types.d.ts.map +1 -1
- package/dist/protocol/version.d.ts +1 -1
- package/dist/state/index.d.ts +2 -0
- package/dist/state/index.d.ts.map +1 -1
- package/dist/state/index.js +13 -3
- package/dist/state/messages.d.ts +11 -3
- package/dist/state/messages.d.ts.map +1 -1
- package/dist/state/questions.d.ts +5 -0
- package/dist/state/questions.d.ts.map +1 -0
- package/dist/state/session.d.ts.map +1 -1
- package/dist/state/tool-key.d.ts +2 -0
- package/dist/state/tool-key.d.ts.map +1 -0
- package/dist/state/tool-preview.d.ts.map +1 -1
- package/dist/state/tool-preview.js +27 -27
- package/dist/test-utils/index.js +2 -2
- package/package.json +3 -3
- package/dist/chunk-7HGJO7ZX.js +0 -9
package/dist/controller/index.js
CHANGED
|
@@ -6,8 +6,9 @@ import {
|
|
|
6
6
|
createMessageStateFromMessages,
|
|
7
7
|
createSessionViewState,
|
|
8
8
|
isToolAutoApprovedForMode,
|
|
9
|
-
reduceSessionEvent
|
|
10
|
-
|
|
9
|
+
reduceSessionEvent,
|
|
10
|
+
scopedToolKey
|
|
11
|
+
} from "../chunk-KQHHBUVY.js";
|
|
11
12
|
|
|
12
13
|
// src/controller/agent-channel.ts
|
|
13
14
|
import { EventEmitter } from "events";
|
|
@@ -32,11 +33,11 @@ var AgentChannel = class {
|
|
|
32
33
|
}
|
|
33
34
|
return this.decider(request);
|
|
34
35
|
}
|
|
35
|
-
requestUserQuestion(request) {
|
|
36
|
+
requestUserQuestion(request, scope) {
|
|
36
37
|
if (!this.questionHandler) {
|
|
37
38
|
return Promise.reject(new Error("UI is not ready to handle user questions."));
|
|
38
39
|
}
|
|
39
|
-
return Promise.resolve(this.questionHandler(request));
|
|
40
|
+
return Promise.resolve(this.questionHandler(request, scope));
|
|
40
41
|
}
|
|
41
42
|
// ---------- UI-side (subscribers) ----------
|
|
42
43
|
onEvent(listener) {
|
|
@@ -86,6 +87,10 @@ function createSessionController(deps) {
|
|
|
86
87
|
let seq = 0;
|
|
87
88
|
let approvalMode = deps.approvalMode ?? "readOnly";
|
|
88
89
|
let abortController = null;
|
|
90
|
+
let activeTurnPromise = null;
|
|
91
|
+
let closePromise = null;
|
|
92
|
+
let closing = false;
|
|
93
|
+
let detached = false;
|
|
89
94
|
let activeTurnId;
|
|
90
95
|
let activePolicyDenial;
|
|
91
96
|
let hostBusyCount = 0;
|
|
@@ -246,7 +251,7 @@ function createSessionController(deps) {
|
|
|
246
251
|
const descriptor = {
|
|
247
252
|
agentId,
|
|
248
253
|
permissionClass,
|
|
249
|
-
summary: findToolSummary(toolCall.id),
|
|
254
|
+
summary: findToolSummary(toolCall.id, parentToolCallId),
|
|
250
255
|
toolCallId: toolCall.id,
|
|
251
256
|
toolName: toolCall.name,
|
|
252
257
|
...dirAccess !== void 0 ? { dirAccess } : {},
|
|
@@ -257,8 +262,13 @@ function createSessionController(deps) {
|
|
|
257
262
|
...request.workflowBashPolicy !== void 0 ? { workflowBashPolicy: request.workflowBashPolicy } : {}
|
|
258
263
|
};
|
|
259
264
|
return new Promise((resolve) => {
|
|
260
|
-
|
|
261
|
-
|
|
265
|
+
const toolKey = scopedToolKey(parentToolCallId, toolCall.id);
|
|
266
|
+
approvalResolvers.set(toolKey, {
|
|
267
|
+
resolve,
|
|
268
|
+
toolCallId: toolCall.id,
|
|
269
|
+
...parentToolCallId !== void 0 ? { parentToolCallId } : {}
|
|
270
|
+
});
|
|
271
|
+
privateApprovals.set(toolKey, {
|
|
262
272
|
approvalKey,
|
|
263
273
|
bashPolicy: hasBashPolicy,
|
|
264
274
|
...!dirAccess && toolCall.name === "Bash" && bashPolicy?.persistence.eligible && request.persistBashPermission !== void 0 ? { persistBashPermission: request.persistBashPermission } : {}
|
|
@@ -266,7 +276,7 @@ function createSessionController(deps) {
|
|
|
266
276
|
emit({ type: "approval-requested", approval: descriptor });
|
|
267
277
|
});
|
|
268
278
|
});
|
|
269
|
-
deps.channel.setQuestionHandler((request) => {
|
|
279
|
+
deps.channel.setQuestionHandler((request, scope) => {
|
|
270
280
|
if (deps.headless) {
|
|
271
281
|
activePolicyDenial = "Questions are unavailable in headless mode.";
|
|
272
282
|
return Promise.reject(new Error(activePolicyDenial));
|
|
@@ -275,31 +285,47 @@ function createSessionController(deps) {
|
|
|
275
285
|
const questionId = `question-${questionCounter}`;
|
|
276
286
|
return new Promise((resolve, reject) => {
|
|
277
287
|
questionResolvers.set(questionId, { resolve, reject });
|
|
278
|
-
|
|
288
|
+
const nickname = nicknameFor(scope?.parentToolCallId);
|
|
289
|
+
emit({
|
|
290
|
+
type: "question-asked",
|
|
291
|
+
question: {
|
|
292
|
+
questionId,
|
|
293
|
+
request,
|
|
294
|
+
...scope?.agentId !== void 0 ? { agentId: scope.agentId } : {},
|
|
295
|
+
...scope?.parentToolCallId !== void 0 ? { parentToolCallId: scope.parentToolCallId } : {},
|
|
296
|
+
...nickname !== void 0 ? { nickname } : {}
|
|
297
|
+
}
|
|
298
|
+
});
|
|
279
299
|
});
|
|
280
300
|
});
|
|
281
|
-
function findToolSummary(toolCallId) {
|
|
282
|
-
const messageId = state.messages.toolMessageIds[toolCallId];
|
|
301
|
+
function findToolSummary(toolCallId, parentToolCallId) {
|
|
302
|
+
const messageId = state.messages.toolMessageIds[scopedToolKey(parentToolCallId, toolCallId)];
|
|
283
303
|
const message = state.messages.messages.find((entry) => entry.id === messageId);
|
|
284
304
|
return message?.role === "tool" ? message.summary : "";
|
|
285
305
|
}
|
|
286
306
|
function nicknameFor(parentToolCallId) {
|
|
287
307
|
if (!parentToolCallId) return void 0;
|
|
288
|
-
const parentMessageId = state.messages.toolMessageIds[parentToolCallId];
|
|
308
|
+
const parentMessageId = state.messages.toolMessageIds[scopedToolKey(void 0, parentToolCallId)];
|
|
289
309
|
const parentMessage = state.messages.messages.find((entry) => entry.id === parentMessageId);
|
|
290
310
|
if (parentMessage?.role !== "tool") return void 0;
|
|
291
311
|
const nickname = parentMessage.input?.nickname;
|
|
292
312
|
return typeof nickname === "string" ? nickname : void 0;
|
|
293
313
|
}
|
|
294
|
-
function findDescriptor(toolCallId) {
|
|
314
|
+
function findDescriptor(toolCallId, parentToolCallId) {
|
|
295
315
|
return [state.approval.active, ...state.approval.pending].find(
|
|
296
|
-
(entry) => entry?.toolCallId === toolCallId
|
|
316
|
+
(entry) => entry?.toolCallId === toolCallId && entry.parentToolCallId === parentToolCallId
|
|
297
317
|
);
|
|
298
318
|
}
|
|
299
319
|
function rejectAllPending(reason) {
|
|
300
|
-
for (const
|
|
301
|
-
resolve({ action: "reject", reason });
|
|
302
|
-
emit({
|
|
320
|
+
for (const pending of approvalResolvers.values()) {
|
|
321
|
+
pending.resolve({ action: "reject", reason });
|
|
322
|
+
emit({
|
|
323
|
+
type: "approval-settled",
|
|
324
|
+
toolCallId: pending.toolCallId,
|
|
325
|
+
...pending.parentToolCallId === void 0 ? {} : { parentToolCallId: pending.parentToolCallId },
|
|
326
|
+
status: "rejected",
|
|
327
|
+
by: "abort"
|
|
328
|
+
});
|
|
303
329
|
}
|
|
304
330
|
approvalResolvers.clear();
|
|
305
331
|
privateApprovals.clear();
|
|
@@ -323,7 +349,7 @@ function createSessionController(deps) {
|
|
|
323
349
|
}
|
|
324
350
|
}
|
|
325
351
|
function startNextQueuedSubmission() {
|
|
326
|
-
if (abortController || hostBusyCount > 0) return;
|
|
352
|
+
if (closing || abortController || hostBusyCount > 0) return;
|
|
327
353
|
const next = queue.shift();
|
|
328
354
|
if (!next) return;
|
|
329
355
|
if (!next.opts.silent) {
|
|
@@ -336,9 +362,11 @@ function createSessionController(deps) {
|
|
|
336
362
|
next.opts.turnId
|
|
337
363
|
);
|
|
338
364
|
}
|
|
339
|
-
void
|
|
365
|
+
void startTrackedTurn(next.input, {
|
|
340
366
|
turnId: next.opts.turnId,
|
|
341
|
-
allowSteering: next.opts.turnId === void 0
|
|
367
|
+
allowSteering: next.opts.turnId === void 0,
|
|
368
|
+
submission: next.opts.submission ?? { origin: "user" },
|
|
369
|
+
...next.opts.signal === void 0 ? {} : { signal: next.opts.signal }
|
|
342
370
|
});
|
|
343
371
|
}
|
|
344
372
|
function finalizeTurn(controller, reason) {
|
|
@@ -350,6 +378,11 @@ function createSessionController(deps) {
|
|
|
350
378
|
}
|
|
351
379
|
async function runTurn(input, opts) {
|
|
352
380
|
const controller = new AbortController();
|
|
381
|
+
const abortFromCaller = () => controller.abort(opts.signal?.reason);
|
|
382
|
+
if (opts.signal !== void 0) {
|
|
383
|
+
if (opts.signal.aborted) abortFromCaller();
|
|
384
|
+
else opts.signal.addEventListener("abort", abortFromCaller, { once: true });
|
|
385
|
+
}
|
|
353
386
|
const drainSteering = async () => {
|
|
354
387
|
if (abortController !== controller || controller.signal.aborted) return [];
|
|
355
388
|
const barrierIndex = queue.findIndex((entry) => entry.delivery === "next-turn");
|
|
@@ -407,7 +440,12 @@ function createSessionController(deps) {
|
|
|
407
440
|
}
|
|
408
441
|
finalInput = guarded.prompt;
|
|
409
442
|
}
|
|
410
|
-
const compactionSend = (text) => runTurn(text, {
|
|
443
|
+
const compactionSend = (text) => runTurn(text, {
|
|
444
|
+
systemInitiated: true,
|
|
445
|
+
allowSteering: opts.allowSteering,
|
|
446
|
+
submission: opts.submission,
|
|
447
|
+
...opts.signal === void 0 ? {} : { signal: opts.signal }
|
|
448
|
+
});
|
|
411
449
|
const compactionIo = {
|
|
412
450
|
signal: controller.signal,
|
|
413
451
|
send: compactionSend,
|
|
@@ -431,6 +469,7 @@ function createSessionController(deps) {
|
|
|
431
469
|
const result = await deps.agent.send(finalInput, {
|
|
432
470
|
streaming: true,
|
|
433
471
|
signal: controller.signal,
|
|
472
|
+
submission: opts.submission,
|
|
434
473
|
...opts.allowSteering ? { drainSteering } : {}
|
|
435
474
|
});
|
|
436
475
|
if (typeof result === "object" && result !== null && "status" in result && result.status === "aborted") {
|
|
@@ -462,6 +501,7 @@ function createSessionController(deps) {
|
|
|
462
501
|
}
|
|
463
502
|
}
|
|
464
503
|
} finally {
|
|
504
|
+
opts.signal?.removeEventListener("abort", abortFromCaller);
|
|
465
505
|
const ownedTurn = finalizeTurn(
|
|
466
506
|
controller,
|
|
467
507
|
"Turn ended before pending interactions could be resolved."
|
|
@@ -486,10 +526,28 @@ function createSessionController(deps) {
|
|
|
486
526
|
if (ownedTurn) startNextQueuedSubmission();
|
|
487
527
|
}
|
|
488
528
|
}
|
|
529
|
+
function startTrackedTurn(input, opts) {
|
|
530
|
+
let tracked;
|
|
531
|
+
tracked = runTurn(input, opts).finally(() => {
|
|
532
|
+
if (activeTurnPromise === tracked) activeTurnPromise = null;
|
|
533
|
+
});
|
|
534
|
+
activeTurnPromise = tracked;
|
|
535
|
+
return tracked;
|
|
536
|
+
}
|
|
537
|
+
function detachController() {
|
|
538
|
+
if (detached) return;
|
|
539
|
+
detached = true;
|
|
540
|
+
unsubscribeEvents();
|
|
541
|
+
unsubscribeLoaded();
|
|
542
|
+
deps.channel.setToolDecider(null);
|
|
543
|
+
deps.channel.setQuestionHandler(null);
|
|
544
|
+
listeners.clear();
|
|
545
|
+
}
|
|
489
546
|
return {
|
|
490
547
|
abort() {
|
|
491
548
|
queue.length = 0;
|
|
492
549
|
abortController?.abort(new Error("User aborted the current turn."));
|
|
550
|
+
rejectAllPending("User aborted the current turn.");
|
|
493
551
|
},
|
|
494
552
|
attachHostHooks(hooks) {
|
|
495
553
|
if (hooks.compaction) compaction = hooks.compaction;
|
|
@@ -510,14 +568,21 @@ function createSessionController(deps) {
|
|
|
510
568
|
emit({ type: "info", message });
|
|
511
569
|
},
|
|
512
570
|
close() {
|
|
571
|
+
if (closePromise) return closePromise;
|
|
572
|
+
closing = true;
|
|
573
|
+
const shouldEmitTurnStatus = queue.length > 0 || abortController !== null || hostBusyCount > 0;
|
|
513
574
|
queue.length = 0;
|
|
514
575
|
abortController?.abort(new Error("Session closed."));
|
|
515
576
|
rejectAllPending("Session closed.");
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
577
|
+
if (shouldEmitTurnStatus) emitTurnStatus();
|
|
578
|
+
const active = activeTurnPromise;
|
|
579
|
+
if (!active) {
|
|
580
|
+
detachController();
|
|
581
|
+
closePromise = Promise.resolve();
|
|
582
|
+
return closePromise;
|
|
583
|
+
}
|
|
584
|
+
closePromise = active.then(detachController, detachController);
|
|
585
|
+
return closePromise;
|
|
521
586
|
},
|
|
522
587
|
dequeue(queuedId) {
|
|
523
588
|
const index = queue.findIndex((q) => q.id === queuedId);
|
|
@@ -526,17 +591,18 @@ function createSessionController(deps) {
|
|
|
526
591
|
emitTurnStatus();
|
|
527
592
|
return true;
|
|
528
593
|
},
|
|
529
|
-
decideApproval(toolCallId, decision, comment, grantDir) {
|
|
530
|
-
|
|
594
|
+
decideApproval(toolCallId, decision, comment, grantDir, parentToolCallId) {
|
|
595
|
+
const toolKey = scopedToolKey(parentToolCallId, toolCallId);
|
|
596
|
+
if (persistenceInFlight.has(toolKey)) {
|
|
531
597
|
return false;
|
|
532
598
|
}
|
|
533
|
-
const
|
|
534
|
-
if (!
|
|
535
|
-
approvalResolvers.delete(
|
|
536
|
-
persistenceInFlight.delete(
|
|
537
|
-
const descriptor = findDescriptor(toolCallId);
|
|
538
|
-
const privateApproval = privateApprovals.get(
|
|
539
|
-
privateApprovals.delete(
|
|
599
|
+
const pending = approvalResolvers.get(toolKey);
|
|
600
|
+
if (!pending) return false;
|
|
601
|
+
approvalResolvers.delete(toolKey);
|
|
602
|
+
persistenceInFlight.delete(toolKey);
|
|
603
|
+
const descriptor = findDescriptor(toolCallId, parentToolCallId);
|
|
604
|
+
const privateApproval = privateApprovals.get(toolKey);
|
|
605
|
+
privateApprovals.delete(toolKey);
|
|
540
606
|
if (decision === "a" && descriptor && !descriptor.dirAccess) {
|
|
541
607
|
alwaysApproved.add(
|
|
542
608
|
privateApproval?.approvalKey ?? `${descriptor.agentId}:${descriptor.toolName}`
|
|
@@ -545,9 +611,12 @@ function createSessionController(deps) {
|
|
|
545
611
|
const rejected = decision === "n";
|
|
546
612
|
if (rejected) {
|
|
547
613
|
const baseReason = `User rejected tool execution (${descriptor?.toolName ?? "unknown tool"})`;
|
|
548
|
-
resolve({
|
|
614
|
+
pending.resolve({
|
|
615
|
+
action: "reject",
|
|
616
|
+
reason: comment ? `${baseReason}: ${comment}` : baseReason
|
|
617
|
+
});
|
|
549
618
|
} else if (descriptor?.dirAccess) {
|
|
550
|
-
resolve({
|
|
619
|
+
pending.resolve({
|
|
551
620
|
action: "run",
|
|
552
621
|
grantDir: {
|
|
553
622
|
dir: resolveGrantDir(
|
|
@@ -563,30 +632,32 @@ function createSessionController(deps) {
|
|
|
563
632
|
} : {}
|
|
564
633
|
});
|
|
565
634
|
} else if (descriptor?.toolName === "Bash" && privateApproval?.bashPolicy) {
|
|
566
|
-
resolve({
|
|
635
|
+
pending.resolve({
|
|
567
636
|
action: "run",
|
|
568
637
|
approvalDecision: decision,
|
|
569
638
|
approvalSource: "user"
|
|
570
639
|
});
|
|
571
640
|
} else {
|
|
572
|
-
resolve({ action: "run" });
|
|
641
|
+
pending.resolve({ action: "run" });
|
|
573
642
|
}
|
|
574
643
|
emit({
|
|
575
644
|
type: "approval-settled",
|
|
576
645
|
toolCallId,
|
|
646
|
+
...parentToolCallId !== void 0 ? { parentToolCallId } : {},
|
|
577
647
|
status: rejected ? "rejected" : "approved",
|
|
578
648
|
by: "client"
|
|
579
649
|
});
|
|
580
650
|
return true;
|
|
581
651
|
},
|
|
582
|
-
async persistBashPermission(toolCallId, request) {
|
|
652
|
+
async persistBashPermission(toolCallId, request, parentToolCallId) {
|
|
653
|
+
const toolKey = scopedToolKey(parentToolCallId, toolCallId);
|
|
583
654
|
const descriptor = state.approval.active;
|
|
584
|
-
const privateApproval = privateApprovals.get(
|
|
655
|
+
const privateApproval = privateApprovals.get(toolKey);
|
|
585
656
|
const handler = privateApproval?.persistBashPermission;
|
|
586
|
-
if (descriptor?.toolCallId !== toolCallId || descriptor.toolName !== "Bash" || descriptor.dirAccess !== void 0 || descriptor.bashPolicy?.persistence.eligible !== true || handler === void 0 || !approvalResolvers.has(
|
|
657
|
+
if (descriptor?.toolCallId !== toolCallId || descriptor.parentToolCallId !== parentToolCallId || descriptor.toolName !== "Bash" || descriptor.dirAccess !== void 0 || descriptor.bashPolicy?.persistence.eligible !== true || handler === void 0 || !approvalResolvers.has(toolKey)) {
|
|
587
658
|
return void 0;
|
|
588
659
|
}
|
|
589
|
-
if (persistenceInFlight.has(
|
|
660
|
+
if (persistenceInFlight.has(toolKey)) {
|
|
590
661
|
return {
|
|
591
662
|
status: "validation-error",
|
|
592
663
|
message: "A persistent Bash permission save is already in progress.",
|
|
@@ -600,7 +671,7 @@ function createSessionController(deps) {
|
|
|
600
671
|
fieldErrors: { server: "Wait for the current operation to finish." }
|
|
601
672
|
};
|
|
602
673
|
}
|
|
603
|
-
persistenceInFlight.add(
|
|
674
|
+
persistenceInFlight.add(toolKey);
|
|
604
675
|
hostBusyCount += 1;
|
|
605
676
|
emitTurnStatus();
|
|
606
677
|
try {
|
|
@@ -608,13 +679,13 @@ function createSessionController(deps) {
|
|
|
608
679
|
if (outcome.status === "validation-error") {
|
|
609
680
|
return outcome;
|
|
610
681
|
}
|
|
611
|
-
const
|
|
612
|
-
if (
|
|
682
|
+
const pending = approvalResolvers.get(toolKey);
|
|
683
|
+
if (pending === void 0 || state.approval.active?.toolCallId !== toolCallId || state.approval.active.parentToolCallId !== parentToolCallId || privateApprovals.get(toolKey) !== privateApproval) {
|
|
613
684
|
return void 0;
|
|
614
685
|
}
|
|
615
|
-
approvalResolvers.delete(
|
|
616
|
-
privateApprovals.delete(
|
|
617
|
-
resolve({
|
|
686
|
+
approvalResolvers.delete(toolKey);
|
|
687
|
+
privateApprovals.delete(toolKey);
|
|
688
|
+
pending.resolve({
|
|
618
689
|
action: "run",
|
|
619
690
|
executionAuthorization: outcome.executionAuthorization,
|
|
620
691
|
approvalSource: "user"
|
|
@@ -622,12 +693,13 @@ function createSessionController(deps) {
|
|
|
622
693
|
emit({
|
|
623
694
|
type: "approval-settled",
|
|
624
695
|
toolCallId,
|
|
696
|
+
...parentToolCallId !== void 0 ? { parentToolCallId } : {},
|
|
625
697
|
status: "approved",
|
|
626
698
|
by: "client"
|
|
627
699
|
});
|
|
628
700
|
return { status: "approved" };
|
|
629
701
|
} finally {
|
|
630
|
-
persistenceInFlight.delete(
|
|
702
|
+
persistenceInFlight.delete(toolKey);
|
|
631
703
|
hostBusyCount = Math.max(0, hostBusyCount - 1);
|
|
632
704
|
emitTurnStatus();
|
|
633
705
|
}
|
|
@@ -645,6 +717,9 @@ function createSessionController(deps) {
|
|
|
645
717
|
isHostBusy() {
|
|
646
718
|
return hostBusyCount > 0;
|
|
647
719
|
},
|
|
720
|
+
isTurnActive() {
|
|
721
|
+
return abortController !== null;
|
|
722
|
+
},
|
|
648
723
|
onEvent(listener) {
|
|
649
724
|
listeners.add(listener);
|
|
650
725
|
return () => listeners.delete(listener);
|
|
@@ -695,6 +770,8 @@ function createSessionController(deps) {
|
|
|
695
770
|
startNextQueuedSubmission();
|
|
696
771
|
},
|
|
697
772
|
async submit(input, opts) {
|
|
773
|
+
if (closing) throw new Error("Session is closing.");
|
|
774
|
+
opts.signal?.throwIfAborted();
|
|
698
775
|
if (abortController || hostBusyCount > 0) {
|
|
699
776
|
queue.push({
|
|
700
777
|
id: `q-${++queueCounter}`,
|
|
@@ -715,9 +792,11 @@ function createSessionController(deps) {
|
|
|
715
792
|
opts.turnId
|
|
716
793
|
);
|
|
717
794
|
}
|
|
718
|
-
await
|
|
795
|
+
await startTrackedTurn(input, {
|
|
719
796
|
turnId: opts.turnId,
|
|
720
|
-
allowSteering: opts.turnId === void 0
|
|
797
|
+
allowSteering: opts.turnId === void 0,
|
|
798
|
+
submission: opts.submission ?? { origin: "user" },
|
|
799
|
+
...opts.signal === void 0 ? {} : { signal: opts.signal }
|
|
721
800
|
});
|
|
722
801
|
}
|
|
723
802
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AgentMetricsSnapshot } from "@nuvin/agent-core/agent";
|
|
2
|
-
import { type AgentInput, type AskUserAnswers, type Message, type SteeringInputDrain } from "@nuvin/agent-core/shared";
|
|
2
|
+
import { type AgentInput, type AgentSubmission, type AskUserAnswers, type Message, type SteeringInputDrain } from "@nuvin/agent-core/shared";
|
|
3
3
|
import type { BashPolicyApprovalDiagnostics, McpAuthFlowState, McpViewState, PersistBashPermissionRequest, PersistBashPermissionResult, ServerEvent, SessionMeta, SessionSnapshot, SlashCommandDescriptor, WorkflowProgressDelta } from "../protocol/types.ts";
|
|
4
4
|
import { type SessionApprovalMode } from "../state/approvals.ts";
|
|
5
5
|
import type { AgentChannel } from "./agent-channel.ts";
|
|
@@ -11,6 +11,7 @@ export type AgentLike = {
|
|
|
11
11
|
streaming: boolean;
|
|
12
12
|
signal: AbortSignal;
|
|
13
13
|
drainSteering?: SteeringInputDrain;
|
|
14
|
+
submission: AgentSubmission;
|
|
14
15
|
}): Promise<unknown>;
|
|
15
16
|
};
|
|
16
17
|
export type GuardResult = {
|
|
@@ -62,6 +63,10 @@ export interface SessionControllerDeps {
|
|
|
62
63
|
export type SubmitOptions = {
|
|
63
64
|
displayText: string;
|
|
64
65
|
attachmentLabels?: string[];
|
|
66
|
+
/** Immutable ownership metadata forwarded with this exact agent send. */
|
|
67
|
+
submission?: AgentSubmission;
|
|
68
|
+
/** Optional caller cancellation that remains linked for the full turn. */
|
|
69
|
+
signal?: AbortSignal;
|
|
65
70
|
/**
|
|
66
71
|
* When true, submit emits no `user-message` event (slash-initiated turns
|
|
67
72
|
* already echoed their text). `displayText` may be `""` in that case.
|
|
@@ -84,28 +89,21 @@ export interface SessionController {
|
|
|
84
89
|
compaction?: CompactionHooks;
|
|
85
90
|
guardPrompt?: (input: AgentInput) => Promise<GuardResult>;
|
|
86
91
|
}): void;
|
|
87
|
-
/**
|
|
88
|
-
* Settle a pending question by id.
|
|
89
|
-
*
|
|
90
|
-
* Single-active-question is the current protocol invariant: when parallel
|
|
91
|
-
* sub-agents ask concurrently, only the latest question is surfaced as
|
|
92
|
-
* `question.active` in state. All resolvers survive in the internal map, so
|
|
93
|
-
* answering any questionId settles the matching ask correctly.
|
|
94
|
-
*/
|
|
92
|
+
/** Settle a pending question by id. */
|
|
95
93
|
answerQuestion(questionId: string, answers: AskUserAnswers): boolean;
|
|
96
94
|
/** Emit an error line into the replicated transcript. */
|
|
97
95
|
appendError(message: string): void;
|
|
98
96
|
/** Emit an info line into the replicated transcript (slash output, system notices). */
|
|
99
97
|
appendInfo(message: string): void;
|
|
100
|
-
close(): void
|
|
98
|
+
close(): Promise<void>;
|
|
101
99
|
/**
|
|
102
100
|
* Cancel a queued (not-yet-running) submission by its `turn-status.queued` id.
|
|
103
101
|
* Returns true if an item was removed, false if the id was unknown (already
|
|
104
102
|
* drained or never existed) — a race-safe no-op the host still acks ok.
|
|
105
103
|
*/
|
|
106
104
|
dequeue(queuedId: string): boolean;
|
|
107
|
-
decideApproval(toolCallId: string, decision: "a" | "n" | "y", comment?: string, grantDir?: string): boolean;
|
|
108
|
-
persistBashPermission(toolCallId: string, request: PersistBashPermissionRequest): Promise<PersistBashPermissionResult | undefined>;
|
|
105
|
+
decideApproval(toolCallId: string, decision: "a" | "n" | "y", comment?: string, grantDir?: string, parentToolCallId?: string): boolean;
|
|
106
|
+
persistBashPermission(toolCallId: string, request: PersistBashPermissionRequest, parentToolCallId?: string): Promise<PersistBashPermissionResult | undefined>;
|
|
109
107
|
/** Echo a user-style message without starting a turn (slash commands echo their invocation). */
|
|
110
108
|
echoUserMessage(text: string, attachmentLabels?: string[]): void;
|
|
111
109
|
/**
|
|
@@ -116,6 +114,8 @@ export interface SessionController {
|
|
|
116
114
|
getSnapshot(): SessionSnapshot;
|
|
117
115
|
/** Return whether a host-controlled server operation currently owns busy state. */
|
|
118
116
|
isHostBusy(): boolean;
|
|
117
|
+
/** Return whether an agent turn is currently active, independent of host busy state. */
|
|
118
|
+
isTurnActive(): boolean;
|
|
119
119
|
onEvent(listener: (event: ServerEvent) => void): () => void;
|
|
120
120
|
/**
|
|
121
121
|
* Replace the server-executed slash-command descriptors surfaced in the attach
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-controller.d.ts","sourceRoot":"","sources":["../../src/controller/session-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EACL,KAAK,UAAU,EACf,KAAK,cAAc,EAEnB,KAAK,OAAO,EACZ,KAAK,kBAAkB,EAGxB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAEV,6BAA6B,EAC7B,gBAAgB,EAChB,YAAY,EAEZ,4BAA4B,EAC5B,2BAA2B,EAC3B,WAAW,EAEX,WAAW,EACX,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA6B,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"session-controller.d.ts","sourceRoot":"","sources":["../../src/controller/session-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EACL,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,cAAc,EAEnB,KAAK,OAAO,EACZ,KAAK,kBAAkB,EAGxB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAEV,6BAA6B,EAC7B,gBAAgB,EAChB,YAAY,EAEZ,4BAA4B,EAC5B,2BAA2B,EAC3B,WAAW,EAEX,WAAW,EACX,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAA6B,KAAK,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAM5F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,6BAA6B,GAAG,MAAM,CAazF;AAED,gGAAgG;AAChG,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,IAAI,CACF,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE;QACJ,SAAS,EAAE,OAAO,CAAC;QACnB,MAAM,EAAE,WAAW,CAAC;QACpB,aAAa,CAAC,EAAE,kBAAkB,CAAC;QACnC,UAAU,EAAE,eAAe,CAAC;KAC7B,GACA,OAAO,CAAC,OAAO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GAAG,iBAAiB,CA65BtF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ConfigMutationResult, HistoryPage, ProfileSummary, ProviderConfigSummary, ProviderCredentialInput, ProviderSurfaceId, SessionSnapshot, WorkspaceConfigSummary } from "./types.ts";
|
|
2
|
-
export type DataRpcErrorCode = "invalid-input" | "not-found" | "conflict" | "unsupported" | "unauthorized" | "daemon-offline" | "internal";
|
|
1
|
+
import type { ConfigMutationResult, HistoryPage, ListHistoryParams, ListHistoryWorkspacesParams, ListHistoryWorkspacesResult, ListWorkspaceHistoryParams, PersistenceIdentity, ProfileSummary, ProviderConfigSummary, ProviderCredentialInput, ProviderSurfaceId, SessionSnapshot, WorkspaceConfigSummary, WorkspaceHistoryPage } from "./types.ts";
|
|
2
|
+
export type DataRpcErrorCode = "invalid-input" | "not-found" | "conflict" | "unsupported" | "unauthorized" | "daemon-offline" | "transcript-unavailable" | "transcript-corrupt" | "history-state-conflict" | "ambiguous-session-identity" | "invalid-history-cursor" | "internal";
|
|
3
3
|
export type DataRpcError = {
|
|
4
4
|
code: DataRpcErrorCode;
|
|
5
5
|
message: string;
|
|
@@ -30,26 +30,25 @@ export type UpdateWorkspaceInput = ProfileScope & {
|
|
|
30
30
|
export type DataRpcSchema = {
|
|
31
31
|
"get-transcript": {
|
|
32
32
|
params: {
|
|
33
|
-
|
|
34
|
-
workspace?: string;
|
|
35
|
-
profile?: string;
|
|
33
|
+
identity: PersistenceIdentity;
|
|
36
34
|
};
|
|
37
35
|
result: SessionSnapshot;
|
|
38
36
|
};
|
|
39
37
|
"list-history": {
|
|
40
|
-
params:
|
|
41
|
-
profile?: string;
|
|
42
|
-
cwd?: string;
|
|
43
|
-
limit?: number;
|
|
44
|
-
cursor?: string;
|
|
45
|
-
};
|
|
38
|
+
params: ListHistoryParams;
|
|
46
39
|
result: HistoryPage;
|
|
47
40
|
};
|
|
41
|
+
"list-history-workspaces": {
|
|
42
|
+
params: ListHistoryWorkspacesParams;
|
|
43
|
+
result: ListHistoryWorkspacesResult;
|
|
44
|
+
};
|
|
45
|
+
"list-workspace-history": {
|
|
46
|
+
params: ListWorkspaceHistoryParams;
|
|
47
|
+
result: WorkspaceHistoryPage;
|
|
48
|
+
};
|
|
48
49
|
"delete-session": {
|
|
49
50
|
params: {
|
|
50
|
-
|
|
51
|
-
workspace?: string;
|
|
52
|
-
profile?: string;
|
|
51
|
+
identity: PersistenceIdentity;
|
|
53
52
|
};
|
|
54
53
|
result: {
|
|
55
54
|
ok: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-rpc.d.ts","sourceRoot":"","sources":["../../src/protocol/data-rpc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,EACf,sBAAsB,
|
|
1
|
+
{"version":3,"file":"data-rpc.d.ts","sourceRoot":"","sources":["../../src/protocol/data-rpc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,WAAW,EACX,iBAAiB,EACjB,2BAA2B,EAC3B,2BAA2B,EAC3B,0BAA0B,EAC1B,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,gBAAgB,GACxB,eAAe,GACf,WAAW,GACX,UAAU,GACV,aAAa,GACb,cAAc,GACd,gBAAgB,GAChB,wBAAwB,GACxB,oBAAoB,GACpB,wBAAwB,GACxB,4BAA4B,GAC5B,wBAAwB,GACxB,UAAU,CAAC;AAEf,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;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,CAAC;IACF,kBAAkB,EAAE;QAClB,MAAM,EAAE,oBAAoB,GAAG;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC;QAChD,MAAM,EAAE,oBAAoB,CAAC,sBAAsB,CAAC,CAAC;KACtD,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,MAAM,aAAa,CAAC;AAChD,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,aAAa,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AAChF,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,aAAa,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history-text.d.ts","sourceRoot":"","sources":["../../src/protocol/history-text.ts"],"names":[],"mappings":"AAsEA,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKhE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEvD"}
|
package/dist/protocol/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
|
package/dist/protocol/index.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
escapeLikeLiteral,
|
|
3
|
+
modelNameFromIdentity,
|
|
4
|
+
normalizeHistoryText,
|
|
5
|
+
providerFromIdentity,
|
|
6
|
+
sanitizeHistoryDisplayText
|
|
7
|
+
} from "../chunk-7LEIACBZ.js";
|
|
4
8
|
import {
|
|
5
9
|
PROTOCOL_VERSION
|
|
6
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-O3UBTUIO.js";
|
|
7
11
|
import {
|
|
8
12
|
GRANT_CAPABILITIES,
|
|
9
13
|
PROVIDER_SURFACE_IDS
|
|
@@ -12,5 +16,9 @@ export {
|
|
|
12
16
|
GRANT_CAPABILITIES,
|
|
13
17
|
PROTOCOL_VERSION,
|
|
14
18
|
PROVIDER_SURFACE_IDS,
|
|
15
|
-
|
|
19
|
+
escapeLikeLiteral,
|
|
20
|
+
modelNameFromIdentity,
|
|
21
|
+
normalizeHistoryText,
|
|
22
|
+
providerFromIdentity,
|
|
23
|
+
sanitizeHistoryDisplayText
|
|
16
24
|
};
|
|
@@ -4,4 +4,11 @@
|
|
|
4
4
|
* separator — remaining colons belong to the model id (e.g. `model:variant`).
|
|
5
5
|
*/
|
|
6
6
|
export declare function modelNameFromIdentity(modelIdentity: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Project a qualified model identity (`provider:model`) up to its provider
|
|
9
|
+
* name. Returns `undefined` for provider-less identities (bare `model` and
|
|
10
|
+
* provider-less `:model:variant`). Mirrors {@link modelNameFromIdentity}: only
|
|
11
|
+
* the first colon is the separator.
|
|
12
|
+
*/
|
|
13
|
+
export declare function providerFromIdentity(modelIdentity: string): string | undefined;
|
|
7
14
|
//# sourceMappingURL=model-identity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-identity.d.ts","sourceRoot":"","sources":["../../src/protocol/model-identity.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAGnE"}
|
|
1
|
+
{"version":3,"file":"model-identity.d.ts","sourceRoot":"","sources":["../../src/protocol/model-identity.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAGnE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAI9E"}
|