@yeaft/webchat-agent 1.0.533 → 1.0.535
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/local-runtime/server/db/yeaft-project-db.js +17 -0
- package/local-runtime/server/handlers/agent-output.js +24 -0
- package/local-runtime/version.json +1 -1
- package/local-runtime/web/app.bundle.js +154 -166
- package/local-runtime/web/app.bundle.js.gz +0 -0
- package/local-runtime/web/index.html +2 -2
- package/local-runtime/web/style.bundle.css +1 -1
- package/local-runtime/web/style.bundle.css.gz +0 -0
- package/package.json +1 -1
- package/yeaft/sessions/session-crud.js +2 -2
- package/yeaft/web-bridge.js +1 -1
|
@@ -196,6 +196,23 @@ export const yeaftProjectDb = {
|
|
|
196
196
|
})();
|
|
197
197
|
},
|
|
198
198
|
|
|
199
|
+
/**
|
|
200
|
+
* Assign a newly registered fork to the source's Project. The caller owns the
|
|
201
|
+
* Session-registration transaction and replay fence; this is one insert, not
|
|
202
|
+
* moveSession's independent transaction or a user-requested Project move.
|
|
203
|
+
*/
|
|
204
|
+
inheritSessionProject(userId, agentId, sourceSessionId, targetSessionId) {
|
|
205
|
+
const ownerId = requireUserId(userId);
|
|
206
|
+
const targetAgentId = requireId(agentId, 'invalid_agent_id', 'Agent id');
|
|
207
|
+
const sourceId = requireId(sourceSessionId, 'invalid_session_id', 'Source Session id');
|
|
208
|
+
const targetId = requireId(targetSessionId, 'invalid_session_id', 'Fork Session id');
|
|
209
|
+
if (sourceId === targetId) throw new YeaftProjectDbError('invalid_session_id', 'Fork must have a new identity');
|
|
210
|
+
const project = stmts.getYeaftProjectForSession.get(ownerId, targetAgentId, sourceId);
|
|
211
|
+
if (!project) return null;
|
|
212
|
+
stmts.insertYeaftProjectSessionMembership.run(ownerId, project.id, targetAgentId, targetId, Date.now());
|
|
213
|
+
return project.id;
|
|
214
|
+
},
|
|
215
|
+
|
|
199
216
|
reconcileAgentSessions(userId, agentId, sessionIds) {
|
|
200
217
|
const ownerId = requireUserId(userId);
|
|
201
218
|
const targetAgentId = requireId(agentId, 'invalid_agent_id', 'Agent id');
|
|
@@ -83,6 +83,30 @@ function syncYeaftSessionMetadata(agentId, agent, event) {
|
|
|
83
83
|
}
|
|
84
84
|
return { ...event, sessions: decorateYeaftSessionsWithPinned(agentId, event.sessions) };
|
|
85
85
|
}
|
|
86
|
+
// A fork is a new Session on the same Agent, not a new Project. Resolve
|
|
87
|
+
// membership here (never from browser/Agent project metadata) before the
|
|
88
|
+
// successful acknowledgement can focus the new Session in the browser.
|
|
89
|
+
if (event.ok && ownerId && op === 'copy' && event.sourceSessionId && event.session?.id) {
|
|
90
|
+
try {
|
|
91
|
+
if (event.sourceSessionId === event.session.id) throw new Error('Fork must have a new Session identity');
|
|
92
|
+
transaction(() => {
|
|
93
|
+
// Replayed acknowledgements must not undo a later user Project move.
|
|
94
|
+
if (yeaftSessionDb.getForAgent(ownerId, agentId, event.session.id)) return;
|
|
95
|
+
yeaftSessionDb.upsertFromSnapshot(ownerId, agentId, event.session);
|
|
96
|
+
yeaftProjectDb.inheritSessionProject(ownerId, agentId, event.sourceSessionId, event.session.id);
|
|
97
|
+
})();
|
|
98
|
+
} catch (e) {
|
|
99
|
+
console.warn('[Server] Fork Project inheritance failed:', e?.message || e);
|
|
100
|
+
return {
|
|
101
|
+
...event,
|
|
102
|
+
ok: false,
|
|
103
|
+
error: {
|
|
104
|
+
code: 'project_inheritance_failed',
|
|
105
|
+
message: `Fork ${event.session.id} was created, but its Project could not be saved.`,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
86
110
|
if (!event.ok || !ownerId || !sessionId || (op !== 'archive' && op !== 'delete')) return event;
|
|
87
111
|
|
|
88
112
|
if (op === 'archive') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"1.0.
|
|
1
|
+
{"version":"1.0.535"}
|