dsh-more 0.0.8 → 0.0.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/index.js +100 -30
- package/dsh.plugin.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -282,9 +282,13 @@ async function createEditedContinuation(ctx, sourceAgent, cut, editedText, child
|
|
|
282
282
|
agentOptions: {
|
|
283
283
|
...(request?.provider ?? sourceAgent.options.provider) === void 0 ? {} : { provider: request?.provider ?? sourceAgent.options.provider },
|
|
284
284
|
...(request?.model ?? sourceAgent.options.model) === void 0 ? {} : { model: request?.model ?? sourceAgent.options.model },
|
|
285
|
-
...sourceAgent.options.maxTokens === void 0 ? {} : { maxTokens: sourceAgent.options.maxTokens }
|
|
285
|
+
...sourceAgent.options.maxTokens === void 0 ? {} : { maxTokens: sourceAgent.options.maxTokens },
|
|
286
|
+
...(request?.reasoningEffort ?? sourceAgent.options.reasoningEffort) === void 0 ? {} : {
|
|
287
|
+
reasoningEffort: request?.reasoningEffort ?? sourceAgent.options.reasoningEffort
|
|
288
|
+
}
|
|
286
289
|
},
|
|
287
|
-
setup: (agentCtx) => {
|
|
290
|
+
setup: (agentCtx, agent) => {
|
|
291
|
+
agent.inbox.clear();
|
|
288
292
|
roster?.composeFrom(agentCtx, sourceAgent.ctx);
|
|
289
293
|
releaseRuntimeContextReplay = replaySeedRuntimeContext(agentCtx, seed);
|
|
290
294
|
}
|
|
@@ -475,7 +479,21 @@ function recordedDeletionSeqs(events) {
|
|
|
475
479
|
function buildCleanSeed(source, selection) {
|
|
476
480
|
const deleted = recordedDeletionSeqs(source.snapshotEvents());
|
|
477
481
|
for (const seq of selection.shadowedSeqs) deleted.add(seq);
|
|
478
|
-
const survivors =
|
|
482
|
+
const survivors = /* @__PURE__ */ new Map();
|
|
483
|
+
for (const seq of source.surface.nodes) {
|
|
484
|
+
if (deleted.has(seq)) continue;
|
|
485
|
+
const event = source.eventAt(seq);
|
|
486
|
+
if (event === void 0 || source.deriveEventMessage(event) === null) continue;
|
|
487
|
+
let anchor = event;
|
|
488
|
+
while (anchor.surfaceOp !== void 0 && anchor.surfaceOp !== "append") {
|
|
489
|
+
const previous = source.eventAt(anchor.surfaceOp.startSeq);
|
|
490
|
+
if (previous === void 0 || previous.seq >= anchor.seq) break;
|
|
491
|
+
anchor = previous;
|
|
492
|
+
}
|
|
493
|
+
const at = survivors.get(anchor.seq) ?? [];
|
|
494
|
+
at.push(event);
|
|
495
|
+
survivors.set(anchor.seq, at);
|
|
496
|
+
}
|
|
479
497
|
const rebuilt = Session.create(SessionId4(`session-rebuild-${randomUUID3()}`));
|
|
480
498
|
let turn = 0;
|
|
481
499
|
let step = 0;
|
|
@@ -483,6 +501,8 @@ function buildCleanSeed(source, selection) {
|
|
|
483
501
|
let stepOpen = false;
|
|
484
502
|
let assistantSeen = false;
|
|
485
503
|
const loggedCalls = /* @__PURE__ */ new Set();
|
|
504
|
+
const userSeqs = /* @__PURE__ */ new Map();
|
|
505
|
+
let sourceTurnOpen = false;
|
|
486
506
|
const closeStep = () => {
|
|
487
507
|
if (!stepOpen) return;
|
|
488
508
|
rebuilt.append("step/end", { turn, step });
|
|
@@ -509,40 +529,87 @@ function buildCleanSeed(source, selection) {
|
|
|
509
529
|
stepOpen = true;
|
|
510
530
|
}
|
|
511
531
|
};
|
|
512
|
-
for (const
|
|
513
|
-
if (
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
532
|
+
for (const entry of source.snapshotEvents()) {
|
|
533
|
+
if ([
|
|
534
|
+
"permission/preset",
|
|
535
|
+
"sandbox/mode",
|
|
536
|
+
"approval/policy",
|
|
537
|
+
"subagent/model-selection-policy",
|
|
538
|
+
"model/selection",
|
|
539
|
+
"request/header",
|
|
540
|
+
"request/context",
|
|
541
|
+
"agent-preset/selected"
|
|
542
|
+
].includes(entry.type)) {
|
|
543
|
+
rebuilt.append(entry.type, entry.data);
|
|
518
544
|
continue;
|
|
519
545
|
}
|
|
520
|
-
if (
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
// Only the reconstructed turn/step coordinates belong to the new log.
|
|
524
|
-
...event.data,
|
|
525
|
-
turn,
|
|
526
|
-
step
|
|
527
|
-
}, { surfaceOp: "append" });
|
|
528
|
-
assistantSeen = true;
|
|
529
|
-
for (const call of event.data.message.content) {
|
|
530
|
-
if (call.type !== "tool-call") continue;
|
|
531
|
-
rebuilt.append("tool/call", { turn, step, callId: call.id, name: call.name, arguments: call.arguments });
|
|
532
|
-
loggedCalls.add(call.id);
|
|
533
|
-
}
|
|
546
|
+
if (entry.type === "turn/start") {
|
|
547
|
+
closeTurn();
|
|
548
|
+
sourceTurnOpen = true;
|
|
534
549
|
continue;
|
|
535
550
|
}
|
|
536
|
-
if (
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
551
|
+
if (entry.type === "turn/end") {
|
|
552
|
+
closeTurn();
|
|
553
|
+
sourceTurnOpen = false;
|
|
554
|
+
continue;
|
|
555
|
+
}
|
|
556
|
+
if (entry.type === "step/end") {
|
|
557
|
+
closeStep();
|
|
558
|
+
continue;
|
|
559
|
+
}
|
|
560
|
+
for (const event of survivors.get(entry.seq) ?? []) {
|
|
561
|
+
if (event.type === "user/message" && !sourceTurnOpen && event.data.source.kind !== "user") {
|
|
562
|
+
rebuilt.append("user/message", event.data, { surfaceOp: "append" });
|
|
563
|
+
continue;
|
|
564
|
+
}
|
|
565
|
+
if (event.type === "assistant/message" && assistantSeen) closeStep();
|
|
566
|
+
openStep();
|
|
567
|
+
if (event.type === "system/message") {
|
|
568
|
+
rebuilt.append("system/message", { ...event.data, turn, step }, { surfaceOp: "append" });
|
|
569
|
+
continue;
|
|
570
|
+
}
|
|
571
|
+
if (event.type === "user/message") {
|
|
572
|
+
const appended = rebuilt.append("user/message", event.data, { surfaceOp: "append" });
|
|
573
|
+
if (event.data.source.kind === "user") userSeqs.set(event.seq, appended.seq);
|
|
574
|
+
continue;
|
|
575
|
+
}
|
|
576
|
+
if (event.type === "assistant/message") {
|
|
577
|
+
rebuilt.append("assistant/message", {
|
|
578
|
+
// Keep the durable stream and settlement metadata required by DSH 0.1.5.
|
|
579
|
+
// Only the reconstructed turn/step coordinates belong to the new log.
|
|
580
|
+
...event.data,
|
|
581
|
+
turn,
|
|
582
|
+
step
|
|
583
|
+
}, { surfaceOp: "append" });
|
|
584
|
+
assistantSeen = true;
|
|
585
|
+
for (const call of event.data.message.content) {
|
|
586
|
+
if (call.type !== "tool-call") continue;
|
|
587
|
+
rebuilt.append("tool/call", { turn, step, callId: call.id, name: call.name, arguments: call.arguments });
|
|
588
|
+
loggedCalls.add(call.id);
|
|
589
|
+
}
|
|
590
|
+
continue;
|
|
591
|
+
}
|
|
592
|
+
if (event.type === "tool/result") {
|
|
593
|
+
const callId = event.data.message.source.callId;
|
|
594
|
+
if (!loggedCalls.has(callId)) {
|
|
595
|
+
rebuilt.append("tool/call", { turn, step, callId: event.data.message.source.callId, name: "restored-tool", arguments: "{}" });
|
|
596
|
+
loggedCalls.add(callId);
|
|
597
|
+
}
|
|
598
|
+
rebuilt.append("tool/result", { turn, step, message: event.data.message, ...event.data.error === void 0 ? {} : { error: event.data.error }, ...event.data.meta === void 0 ? {} : { meta: event.data.meta } }, { surfaceOp: "append" });
|
|
541
599
|
}
|
|
542
|
-
rebuilt.append("tool/result", { turn, step, message: event.data.message, ...event.data.error === void 0 ? {} : { error: event.data.error }, ...event.data.meta === void 0 ? {} : { meta: event.data.meta } }, { surfaceOp: "append" });
|
|
543
600
|
}
|
|
544
601
|
}
|
|
545
602
|
closeTurn();
|
|
603
|
+
const title = source.snapshotEvents().findLast((event) => event.type === "session/title");
|
|
604
|
+
if (title?.type === "session/title") {
|
|
605
|
+
const messageSeqs = title.data.messageSeqs.flatMap((seq) => {
|
|
606
|
+
const mapped = userSeqs.get(seq);
|
|
607
|
+
return mapped === void 0 ? [] : [mapped];
|
|
608
|
+
});
|
|
609
|
+
if (title.data.source.kind === "user" || messageSeqs.length > 0) {
|
|
610
|
+
rebuilt.append("session/title", { ...title.data, messageSeqs });
|
|
611
|
+
}
|
|
612
|
+
}
|
|
546
613
|
return rebuilt.snapshotEvents();
|
|
547
614
|
}
|
|
548
615
|
async function createDeletedContinuation(ctx, sourceAgent, selection, childId = SessionId4(`session-${randomUUID3()}`)) {
|
|
@@ -578,7 +645,10 @@ async function createDeletedContinuation(ctx, sourceAgent, selection, childId =
|
|
|
578
645
|
agentOptions: {
|
|
579
646
|
...provider === void 0 ? {} : { provider },
|
|
580
647
|
...model === void 0 ? {} : { model },
|
|
581
|
-
...sourceAgent.options.maxTokens === void 0 ? {} : { maxTokens: sourceAgent.options.maxTokens }
|
|
648
|
+
...sourceAgent.options.maxTokens === void 0 ? {} : { maxTokens: sourceAgent.options.maxTokens },
|
|
649
|
+
...(request?.reasoningEffort ?? sourceAgent.options.reasoningEffort) === void 0 ? {} : {
|
|
650
|
+
reasoningEffort: request?.reasoningEffort ?? sourceAgent.options.reasoningEffort
|
|
651
|
+
}
|
|
582
652
|
},
|
|
583
653
|
setup: (agentCtx) => {
|
|
584
654
|
roster?.composeFrom(agentCtx, sourceAgent.ctx);
|
package/dsh.plugin.json
CHANGED