@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/index.js
CHANGED
|
@@ -602,7 +602,8 @@ var ACPProtocolHandler = class {
|
|
|
602
602
|
close: {},
|
|
603
603
|
list: {},
|
|
604
604
|
delete: {},
|
|
605
|
-
resume: {}
|
|
605
|
+
resume: {},
|
|
606
|
+
fork: {}
|
|
606
607
|
},
|
|
607
608
|
auth: {
|
|
608
609
|
logout: {}
|
|
@@ -814,12 +815,44 @@ var ACPProtocolHandler = class {
|
|
|
814
815
|
async handleSessionFork(id, params) {
|
|
815
816
|
const p = params ?? {};
|
|
816
817
|
const sourceId = typeof p.sessionId === "string" ? p.sessionId : null;
|
|
817
|
-
|
|
818
|
+
const source = sourceId ? this.sessions.get(sourceId) : void 0;
|
|
819
|
+
if (!sourceId || !source) {
|
|
818
820
|
await this.sendError(id, -32e3, `session not found: ${sourceId}`);
|
|
819
821
|
return false;
|
|
820
822
|
}
|
|
821
|
-
const
|
|
822
|
-
|
|
823
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
824
|
+
const sessionId = `sess_${this.allocId()}`;
|
|
825
|
+
const forked = {
|
|
826
|
+
id: sessionId,
|
|
827
|
+
cwd: typeof p.cwd === "string" ? p.cwd : source.cwd,
|
|
828
|
+
abort: new AbortController(),
|
|
829
|
+
modeId: source.modeId,
|
|
830
|
+
createdAt: now,
|
|
831
|
+
updatedAt: now,
|
|
832
|
+
...source.title !== void 0 ? { title: source.title } : {}
|
|
833
|
+
};
|
|
834
|
+
const history = (this.replayFor?.(sourceId) ?? []).map((update) => ({
|
|
835
|
+
sessionUpdate: update.sessionUpdate,
|
|
836
|
+
content: structuredClone(update.content)
|
|
837
|
+
}));
|
|
838
|
+
this.sessions.set(sessionId, forked);
|
|
839
|
+
this.seedFor?.(sessionId, history);
|
|
840
|
+
this.onSessionNew(forked);
|
|
841
|
+
await this.persist(forked, history);
|
|
842
|
+
await this.sendNotification({
|
|
843
|
+
sessionId,
|
|
844
|
+
update: { sessionUpdate: "current_mode_update", modeId: forked.modeId }
|
|
845
|
+
});
|
|
846
|
+
await this.transport.send(toWire({
|
|
847
|
+
jsonrpc: "2.0",
|
|
848
|
+
id,
|
|
849
|
+
result: {
|
|
850
|
+
sessionId,
|
|
851
|
+
modes: this.modes,
|
|
852
|
+
configOptions: this.configOptions
|
|
853
|
+
}
|
|
854
|
+
}));
|
|
855
|
+
return false;
|
|
823
856
|
}
|
|
824
857
|
async handleProvidersList(id, _params) {
|
|
825
858
|
await this.transport.send(toWire({
|
|
@@ -1020,10 +1053,10 @@ var ACPProtocolHandler = class {
|
|
|
1020
1053
|
await this.transport.send(toWire({ jsonrpc: "2.0", method: "session/update", params }));
|
|
1021
1054
|
}
|
|
1022
1055
|
/** Best-effort durable persistence of a session + its recorded history. */
|
|
1023
|
-
async persist(state) {
|
|
1056
|
+
async persist(state, history = void 0) {
|
|
1024
1057
|
if (!this.store) return;
|
|
1025
1058
|
try {
|
|
1026
|
-
await this.store.save(state, this.replayFor?.(state.id));
|
|
1059
|
+
await this.store.save(state, history ?? this.replayFor?.(state.id));
|
|
1027
1060
|
} catch {
|
|
1028
1061
|
}
|
|
1029
1062
|
}
|