@wrongstack/acp 0.283.0 → 0.284.0
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/agent.js +39 -6
- package/dist/agent.js.map +1 -1
- package/dist/index.js +39 -6
- package/dist/index.js.map +1 -1
- package/dist/sdk.js +39 -6
- package/dist/sdk.js.map +1 -1
- package/dist/wrongstack-acp-agent.js +39 -6
- package/dist/wrongstack-acp-agent.js.map +1 -1
- package/package.json +2 -2
package/dist/agent.js
CHANGED
|
@@ -413,7 +413,8 @@ var ACPProtocolHandler = class {
|
|
|
413
413
|
close: {},
|
|
414
414
|
list: {},
|
|
415
415
|
delete: {},
|
|
416
|
-
resume: {}
|
|
416
|
+
resume: {},
|
|
417
|
+
fork: {}
|
|
417
418
|
},
|
|
418
419
|
auth: {
|
|
419
420
|
logout: {}
|
|
@@ -625,12 +626,44 @@ var ACPProtocolHandler = class {
|
|
|
625
626
|
async handleSessionFork(id, params) {
|
|
626
627
|
const p = params ?? {};
|
|
627
628
|
const sourceId = typeof p.sessionId === "string" ? p.sessionId : null;
|
|
628
|
-
|
|
629
|
+
const source = sourceId ? this.sessions.get(sourceId) : void 0;
|
|
630
|
+
if (!sourceId || !source) {
|
|
629
631
|
await this.sendError(id, -32e3, `session not found: ${sourceId}`);
|
|
630
632
|
return false;
|
|
631
633
|
}
|
|
632
|
-
const
|
|
633
|
-
|
|
634
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
635
|
+
const sessionId = `sess_${this.allocId()}`;
|
|
636
|
+
const forked = {
|
|
637
|
+
id: sessionId,
|
|
638
|
+
cwd: typeof p.cwd === "string" ? p.cwd : source.cwd,
|
|
639
|
+
abort: new AbortController(),
|
|
640
|
+
modeId: source.modeId,
|
|
641
|
+
createdAt: now,
|
|
642
|
+
updatedAt: now,
|
|
643
|
+
...source.title !== void 0 ? { title: source.title } : {}
|
|
644
|
+
};
|
|
645
|
+
const history = (this.replayFor?.(sourceId) ?? []).map((update) => ({
|
|
646
|
+
sessionUpdate: update.sessionUpdate,
|
|
647
|
+
content: structuredClone(update.content)
|
|
648
|
+
}));
|
|
649
|
+
this.sessions.set(sessionId, forked);
|
|
650
|
+
this.seedFor?.(sessionId, history);
|
|
651
|
+
this.onSessionNew(forked);
|
|
652
|
+
await this.persist(forked, history);
|
|
653
|
+
await this.sendNotification({
|
|
654
|
+
sessionId,
|
|
655
|
+
update: { sessionUpdate: "current_mode_update", modeId: forked.modeId }
|
|
656
|
+
});
|
|
657
|
+
await this.transport.send(toWire({
|
|
658
|
+
jsonrpc: "2.0",
|
|
659
|
+
id,
|
|
660
|
+
result: {
|
|
661
|
+
sessionId,
|
|
662
|
+
modes: this.modes,
|
|
663
|
+
configOptions: this.configOptions
|
|
664
|
+
}
|
|
665
|
+
}));
|
|
666
|
+
return false;
|
|
634
667
|
}
|
|
635
668
|
async handleProvidersList(id, _params) {
|
|
636
669
|
await this.transport.send(toWire({
|
|
@@ -831,10 +864,10 @@ var ACPProtocolHandler = class {
|
|
|
831
864
|
await this.transport.send(toWire({ jsonrpc: "2.0", method: "session/update", params }));
|
|
832
865
|
}
|
|
833
866
|
/** Best-effort durable persistence of a session + its recorded history. */
|
|
834
|
-
async persist(state) {
|
|
867
|
+
async persist(state, history = void 0) {
|
|
835
868
|
if (!this.store) return;
|
|
836
869
|
try {
|
|
837
|
-
await this.store.save(state, this.replayFor?.(state.id));
|
|
870
|
+
await this.store.save(state, history ?? this.replayFor?.(state.id));
|
|
838
871
|
} catch {
|
|
839
872
|
}
|
|
840
873
|
}
|