negotium 0.1.12 → 0.1.13
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/canonical-mcp-bridge.js +2 -3
- package/dist/canonical-mcp-bridge.js.map +1 -1
- package/dist/chunk-a9y2rwxf.js.map +1 -1
- package/dist/{chunk-j0kjscb7.js → chunk-s2gez3wg.js} +20 -2
- package/dist/{chunk-j0kjscb7.js.map → chunk-s2gez3wg.js.map} +2 -2
- package/dist/cron.js +49 -25
- package/dist/cron.js.map +15 -14
- package/dist/hosted-agent.js +3012 -17
- package/dist/hosted-agent.js.map +30 -3
- package/dist/main.js +31323 -36
- package/dist/main.js.map +198 -3
- package/dist/prompts.js +11 -8
- package/dist/prompts.js.map +4 -4
- package/dist/runtime/src/application/submit-user-message.ts +3 -0
- package/dist/runtime/src/index.ts +7 -0
- package/dist/runtime/src/mcp/runtime-spec.ts +3 -0
- package/dist/runtime/src/mcp/session-comm/server.ts +1 -1
- package/dist/runtime/src/platform/mcp-config.ts +13 -0
- package/dist/runtime/src/prompts/builders.ts +20 -6
- package/dist/runtime/src/query/active-rooms.ts +2 -0
- package/dist/runtime/src/runtime/delivery-ack.ts +112 -0
- package/dist/runtime/src/runtime/errors.ts +12 -12
- package/dist/runtime/src/runtime/turn-runner.ts +12 -0
- package/dist/runtime/src/storage/runtime-turn-requests.ts +1 -0
- package/dist/runtime/src/types/api.ts +2 -0
- package/dist/runtime/src/types.ts +2 -0
- package/dist/runtime/src/version.ts +1 -1
- package/dist/runtime-helpers.js.map +1 -1
- package/dist/storage.js.map +1 -1
- package/dist/types/packages/core/src/mcp/runtime-spec.d.ts +2 -0
- package/dist/types/packages/core/src/platform/mcp-config.d.ts +4 -0
- package/dist/types/packages/core/src/prompts/builders.d.ts +2 -0
- package/dist/types/packages/core/src/types/api.d.ts +2 -0
- package/dist/types/packages/core/src/types.d.ts +2 -0
- package/dist/types/packages/core/src/version.d.ts +1 -1
- package/dist/vault.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-00q25k7p.js +0 -2387
- package/dist/chunk-00q25k7p.js.map +0 -26
- package/dist/chunk-03kv7mvj.js +0 -2152
- package/dist/chunk-03kv7mvj.js.map +0 -15
- package/dist/chunk-05pm51dh.js +0 -589
- package/dist/chunk-05pm51dh.js.map +0 -11
- package/dist/chunk-0eh16bk1.js +0 -2936
- package/dist/chunk-0eh16bk1.js.map +0 -20
- package/dist/chunk-0yfqyv88.js +0 -108
- package/dist/chunk-0yfqyv88.js.map +0 -10
- package/dist/chunk-1k7t7bnx.js +0 -97
- package/dist/chunk-1k7t7bnx.js.map +0 -10
- package/dist/chunk-3gkfr9vb.js +0 -431
- package/dist/chunk-3gkfr9vb.js.map +0 -11
- package/dist/chunk-5akd1gbj.js +0 -281
- package/dist/chunk-5akd1gbj.js.map +0 -10
- package/dist/chunk-7k19pcg8.js +0 -577
- package/dist/chunk-7k19pcg8.js.map +0 -14
- package/dist/chunk-81tbfbmt.js +0 -10
- package/dist/chunk-81tbfbmt.js.map +0 -10
- package/dist/chunk-82qhv1mq.js +0 -512
- package/dist/chunk-82qhv1mq.js.map +0 -13
- package/dist/chunk-8dy7e2a9.js +0 -103
- package/dist/chunk-8dy7e2a9.js.map +0 -10
- package/dist/chunk-8f2sqmrj.js +0 -1712
- package/dist/chunk-8f2sqmrj.js.map +0 -18
- package/dist/chunk-9hjeemfz.js +0 -372
- package/dist/chunk-9hjeemfz.js.map +0 -10
- package/dist/chunk-a4aa2ccv.js +0 -141
- package/dist/chunk-a4aa2ccv.js.map +0 -10
- package/dist/chunk-bsg215q3.js +0 -3536
- package/dist/chunk-bsg215q3.js.map +0 -20
- package/dist/chunk-bxnfsc7w.js +0 -58
- package/dist/chunk-bxnfsc7w.js.map +0 -10
- package/dist/chunk-c500xe9z.js +0 -33
- package/dist/chunk-c500xe9z.js.map +0 -10
- package/dist/chunk-cngrf7ab.js +0 -149
- package/dist/chunk-cngrf7ab.js.map +0 -10
- package/dist/chunk-d7tprf06.js +0 -53
- package/dist/chunk-d7tprf06.js.map +0 -10
- package/dist/chunk-ddnrmkrv.js +0 -61
- package/dist/chunk-ddnrmkrv.js.map +0 -10
- package/dist/chunk-edb07sjp.js +0 -567
- package/dist/chunk-edb07sjp.js.map +0 -14
- package/dist/chunk-ejcm6zx8.js +0 -591
- package/dist/chunk-ejcm6zx8.js.map +0 -11
- package/dist/chunk-ezs352qs.js +0 -237
- package/dist/chunk-ezs352qs.js.map +0 -11
- package/dist/chunk-f5xgprg1.js +0 -59
- package/dist/chunk-f5xgprg1.js.map +0 -10
- package/dist/chunk-fbtb3v0s.js +0 -1339
- package/dist/chunk-fbtb3v0s.js.map +0 -16
- package/dist/chunk-ffefbd3r.js +0 -17
- package/dist/chunk-ffefbd3r.js.map +0 -10
- package/dist/chunk-gaknyw04.js +0 -708
- package/dist/chunk-gaknyw04.js.map +0 -14
- package/dist/chunk-gxmny6tq.js +0 -1637
- package/dist/chunk-gxmny6tq.js.map +0 -15
- package/dist/chunk-h7bj5zwb.js +0 -3069
- package/dist/chunk-h7bj5zwb.js.map +0 -32
- package/dist/chunk-hp4g7wx7.js +0 -46
- package/dist/chunk-hp4g7wx7.js.map +0 -10
- package/dist/chunk-hwy3n31w.js +0 -21
- package/dist/chunk-hwy3n31w.js.map +0 -9
- package/dist/chunk-jzz91jwh.js +0 -70
- package/dist/chunk-jzz91jwh.js.map +0 -10
- package/dist/chunk-k778y16p.js +0 -153
- package/dist/chunk-k778y16p.js.map +0 -11
- package/dist/chunk-mh5mexsf.js +0 -147
- package/dist/chunk-mh5mexsf.js.map +0 -11
- package/dist/chunk-mnwaext5.js +0 -318
- package/dist/chunk-mnwaext5.js.map +0 -10
- package/dist/chunk-nkgs40ch.js +0 -23
- package/dist/chunk-nkgs40ch.js.map +0 -10
- package/dist/chunk-pz57vwsm.js +0 -250
- package/dist/chunk-pz57vwsm.js.map +0 -11
- package/dist/chunk-r6kdp7gn.js +0 -252
- package/dist/chunk-r6kdp7gn.js.map +0 -10
- package/dist/chunk-rkvrkcgx.js +0 -117
- package/dist/chunk-rkvrkcgx.js.map +0 -10
- package/dist/chunk-s74rdyqe.js +0 -117
- package/dist/chunk-s74rdyqe.js.map +0 -12
- package/dist/chunk-sa874j5c.js +0 -9
- package/dist/chunk-sa874j5c.js.map +0 -10
- package/dist/chunk-sffqdkvq.js +0 -122
- package/dist/chunk-sffqdkvq.js.map +0 -10
- package/dist/chunk-tcs9qjps.js +0 -64
- package/dist/chunk-tcs9qjps.js.map +0 -10
- package/dist/chunk-wx83ep8e.js +0 -131
- package/dist/chunk-wx83ep8e.js.map +0 -10
- package/dist/chunk-xag86ng3.js +0 -122
- package/dist/chunk-xag86ng3.js.map +0 -10
- package/dist/chunk-xfdkep71.js +0 -371
- package/dist/chunk-xfdkep71.js.map +0 -11
- package/dist/chunk-xhm1rfpt.js +0 -2907
- package/dist/chunk-xhm1rfpt.js.map +0 -24
- package/dist/chunk-xpcps28p.js +0 -2138
- package/dist/chunk-xpcps28p.js.map +0 -29
- package/dist/chunk-yb4rbev9.js +0 -214
- package/dist/chunk-yb4rbev9.js.map +0 -10
package/dist/chunk-mnwaext5.js
DELETED
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
WsHub,
|
|
4
|
-
cloneProfileForChild,
|
|
5
|
-
copyMessagesForTopic,
|
|
6
|
-
isLegacySharedGeneral
|
|
7
|
-
} from "./chunk-fbtb3v0s.js";
|
|
8
|
-
import {
|
|
9
|
-
findTopicTitleConflict,
|
|
10
|
-
getTopic,
|
|
11
|
-
getTopicSessionId,
|
|
12
|
-
inferTopicKind,
|
|
13
|
-
isTopicVisible,
|
|
14
|
-
listTopics,
|
|
15
|
-
setTopicSessionId,
|
|
16
|
-
upsertTopic
|
|
17
|
-
} from "./chunk-ejcm6zx8.js";
|
|
18
|
-
import {
|
|
19
|
-
cleanupAgentFork,
|
|
20
|
-
forkAgentSession
|
|
21
|
-
} from "./chunk-hp4g7wx7.js";
|
|
22
|
-
import {
|
|
23
|
-
getRegistry
|
|
24
|
-
} from "./chunk-s74rdyqe.js";
|
|
25
|
-
import {
|
|
26
|
-
appendConversationEventStrict,
|
|
27
|
-
cloneConversationLog,
|
|
28
|
-
readConversation
|
|
29
|
-
} from "./chunk-k778y16p.js";
|
|
30
|
-
import {
|
|
31
|
-
resolveModelForAgent
|
|
32
|
-
} from "./chunk-xag86ng3.js";
|
|
33
|
-
import {
|
|
34
|
-
getApiTopicConfig,
|
|
35
|
-
setApiTopicConfig
|
|
36
|
-
} from "./chunk-wx83ep8e.js";
|
|
37
|
-
import"./chunk-gaknyw04.js";
|
|
38
|
-
import"./chunk-mh5mexsf.js";
|
|
39
|
-
import {
|
|
40
|
-
resolveTopicWorkspaceDir
|
|
41
|
-
} from "./chunk-ezs352qs.js";
|
|
42
|
-
import {
|
|
43
|
-
beginRuntimeTopicMaintenance,
|
|
44
|
-
isTopicRunning
|
|
45
|
-
} from "./chunk-82qhv1mq.js";
|
|
46
|
-
import {
|
|
47
|
-
logger
|
|
48
|
-
} from "./chunk-ffefbd3r.js";
|
|
49
|
-
import {
|
|
50
|
-
db
|
|
51
|
-
} from "./chunk-81tbfbmt.js";
|
|
52
|
-
import"./chunk-sffqdkvq.js";
|
|
53
|
-
import"./chunk-f5xgprg1.js";
|
|
54
|
-
import"./chunk-hwy3n31w.js";
|
|
55
|
-
|
|
56
|
-
// ../../packages/core/src/topics/derive.ts
|
|
57
|
-
import { randomUUID } from "crypto";
|
|
58
|
-
import { mkdirSync } from "fs";
|
|
59
|
-
function getTopics() {
|
|
60
|
-
return listTopics().filter((topic) => !isLegacySharedGeneral(topic.id));
|
|
61
|
-
}
|
|
62
|
-
function getVisibleTopics() {
|
|
63
|
-
return getTopics().filter(isTopicVisible).map((topic) => {
|
|
64
|
-
if (!topic.agent)
|
|
65
|
-
return topic;
|
|
66
|
-
const registry = getRegistry(topic.agent);
|
|
67
|
-
const config = getApiTopicConfig(topic.id);
|
|
68
|
-
const requestedEffort = config?.effort ?? topic.defaultEffort;
|
|
69
|
-
return {
|
|
70
|
-
...topic,
|
|
71
|
-
effectiveModel: resolveModelForAgent(topic.agent, config?.model ?? topic.defaultModel, registry),
|
|
72
|
-
effectiveEffort: requestedEffort && registry.validateEffort(requestedEffort) ? requestedEffort : registry.defaultEffort
|
|
73
|
-
};
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
function updateTopic(topicId, patch) {
|
|
77
|
-
const topic = getTopic(topicId);
|
|
78
|
-
if (!topic)
|
|
79
|
-
return false;
|
|
80
|
-
Object.assign(topic, patch);
|
|
81
|
-
upsertTopic(topic);
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
function isParticipant(topic, userId) {
|
|
85
|
-
return topic.participants.some((p) => p.userId === userId);
|
|
86
|
-
}
|
|
87
|
-
function nextDerivedTopicTitle(sourceTitle, kind, suffix) {
|
|
88
|
-
const visibleTitles = new Set(listTopics().filter((topic) => topic.kind === kind).map((topic) => topic.title.toLowerCase()));
|
|
89
|
-
let n = 1;
|
|
90
|
-
let title = `${sourceTitle}-${suffix}-${n}`;
|
|
91
|
-
while (visibleTitles.has(title.toLowerCase())) {
|
|
92
|
-
n += 1;
|
|
93
|
-
title = `${sourceTitle}-${suffix}-${n}`;
|
|
94
|
-
}
|
|
95
|
-
return title;
|
|
96
|
-
}
|
|
97
|
-
function effectiveAgentForTopic(_topicId, topic) {
|
|
98
|
-
if (!topic.agent)
|
|
99
|
-
return;
|
|
100
|
-
return topic.agent;
|
|
101
|
-
}
|
|
102
|
-
function rollbackHandleFor(agent, sessionId, rolloutPath) {
|
|
103
|
-
return { agent, forkId: sessionId, rolloutPath };
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
class TopicTitleConflictError extends Error {
|
|
107
|
-
title;
|
|
108
|
-
constructor(title) {
|
|
109
|
-
super(`A topic named "${title}" already exists`);
|
|
110
|
-
this.title = title;
|
|
111
|
-
this.name = "TopicTitleConflictError";
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
class TopicDeriveBusyError extends Error {
|
|
116
|
-
constructor(message = "Topic is busy; try again when the current operation finishes") {
|
|
117
|
-
super(message);
|
|
118
|
-
this.name = "TopicDeriveBusyError";
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
async function createDerivedTopic(sourceTopicId, userId, copyHistory, opts) {
|
|
122
|
-
const topic = getTopic(sourceTopicId);
|
|
123
|
-
if (!topic)
|
|
124
|
-
return null;
|
|
125
|
-
if (topic.kind === "manager")
|
|
126
|
-
return null;
|
|
127
|
-
if (!isParticipant(topic, userId))
|
|
128
|
-
return null;
|
|
129
|
-
const subagent = copyHistory ? undefined : opts?.subagent;
|
|
130
|
-
let maintenance = null;
|
|
131
|
-
if (!subagent && !opts?.allowActiveSource) {
|
|
132
|
-
if (isTopicRunning(sourceTopicId))
|
|
133
|
-
throw new TopicDeriveBusyError;
|
|
134
|
-
maintenance = beginRuntimeTopicMaintenance(sourceTopicId);
|
|
135
|
-
if (!maintenance)
|
|
136
|
-
throw new TopicDeriveBusyError;
|
|
137
|
-
if (isTopicRunning(sourceTopicId)) {
|
|
138
|
-
maintenance.finish();
|
|
139
|
-
maintenance = null;
|
|
140
|
-
throw new TopicDeriveBusyError;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
try {
|
|
144
|
-
return await createDerivedTopicUnderFence(topic, sourceTopicId, userId, copyHistory, opts);
|
|
145
|
-
} finally {
|
|
146
|
-
maintenance?.finish();
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
async function createDerivedTopicUnderFence(topic, sourceTopicId, userId, copyHistory, opts) {
|
|
150
|
-
const now = new Date().toISOString();
|
|
151
|
-
const subagent = copyHistory ? undefined : opts?.subagent;
|
|
152
|
-
const suffix = copyHistory ? "fork" : subagent ? "agent" : "spawn";
|
|
153
|
-
const sourceConfig = getApiTopicConfig(sourceTopicId);
|
|
154
|
-
const agent = subagent?.agent ?? effectiveAgentForTopic(sourceTopicId, topic);
|
|
155
|
-
const participants = copyHistory || subagent ? [
|
|
156
|
-
...topic.participants.filter((p) => p.userId !== userId).map((p) => ({ ...p, role: "member" })),
|
|
157
|
-
{ userId, role: "owner" }
|
|
158
|
-
] : [{ userId, role: "owner" }];
|
|
159
|
-
const kind = topic.kind ?? inferTopicKind(topic);
|
|
160
|
-
const title = opts?.name?.trim() || nextDerivedTopicTitle(topic.title, kind, suffix);
|
|
161
|
-
const conflict = findTopicTitleConflict(title, kind);
|
|
162
|
-
if (conflict) {
|
|
163
|
-
logger.info({ sourceTopicId, title, kind, conflictTopicId: conflict.id }, "createDerivedTopic: title conflict");
|
|
164
|
-
throw new TopicTitleConflictError(title);
|
|
165
|
-
}
|
|
166
|
-
const derived = {
|
|
167
|
-
id: randomUUID(),
|
|
168
|
-
title,
|
|
169
|
-
kind,
|
|
170
|
-
description: topic.description,
|
|
171
|
-
agent: subagent?.agent ?? topic.agent,
|
|
172
|
-
defaultModel: subagent?.model ?? topic.defaultModel,
|
|
173
|
-
defaultEffort: topic.defaultEffort,
|
|
174
|
-
aiMode: topic.aiMode,
|
|
175
|
-
aiMention: topic.aiMention,
|
|
176
|
-
participants,
|
|
177
|
-
createdAt: now,
|
|
178
|
-
lastMessageAt: now,
|
|
179
|
-
parentTopicId: sourceTopicId,
|
|
180
|
-
isFork: copyHistory,
|
|
181
|
-
...subagent ? { isSubagent: true } : {},
|
|
182
|
-
visibility: topic.visibility,
|
|
183
|
-
accessMode: topic.accessMode
|
|
184
|
-
};
|
|
185
|
-
let sessionId;
|
|
186
|
-
let rollbackHandle;
|
|
187
|
-
try {
|
|
188
|
-
if (agent) {
|
|
189
|
-
const cwd = resolveTopicWorkspaceDir(derived.id);
|
|
190
|
-
mkdirSync(cwd, { recursive: true });
|
|
191
|
-
const registry = getRegistry(agent);
|
|
192
|
-
const requestedRolloutModel = subagent?.model ?? (subagent?.agent ? undefined : sourceConfig?.model) ?? derived.defaultModel;
|
|
193
|
-
const rolloutModel = resolveModelForAgent(agent, requestedRolloutModel, registry);
|
|
194
|
-
const requestedRolloutEffort = subagent?.agent ? registry.defaultEffort : sourceConfig?.effort ?? derived.defaultEffort;
|
|
195
|
-
const rolloutEffort = requestedRolloutEffort && registry.validateEffort(requestedRolloutEffort) ? requestedRolloutEffort : registry.defaultEffort;
|
|
196
|
-
if (copyHistory) {
|
|
197
|
-
const parentSessionId = getTopicSessionId(sourceTopicId);
|
|
198
|
-
if (parentSessionId) {
|
|
199
|
-
try {
|
|
200
|
-
const fork = await forkAgentSession({
|
|
201
|
-
agent,
|
|
202
|
-
parentSessionId,
|
|
203
|
-
cwd,
|
|
204
|
-
userId,
|
|
205
|
-
topicName: topic.title,
|
|
206
|
-
title,
|
|
207
|
-
model: rolloutModel,
|
|
208
|
-
...rolloutEffort ? { effort: rolloutEffort } : {}
|
|
209
|
-
});
|
|
210
|
-
sessionId = fork.forkId;
|
|
211
|
-
rollbackHandle = fork;
|
|
212
|
-
} catch (err) {
|
|
213
|
-
logger.warn({ err, sourceTopicId, title: topic.title, agent, parentSessionId }, "createDerivedTopic: native fork failed; synthesizing from unified history");
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
if (!sessionId) {
|
|
217
|
-
const rollout = registry.writeRollout({
|
|
218
|
-
cwd,
|
|
219
|
-
entries: readConversation(userId, topic.title),
|
|
220
|
-
model: rolloutModel,
|
|
221
|
-
...rolloutEffort ? { effort: rolloutEffort } : {}
|
|
222
|
-
});
|
|
223
|
-
sessionId = rollout.sessionId;
|
|
224
|
-
rollbackHandle = rollbackHandleFor(agent, rollout.sessionId, rollout.rolloutPath);
|
|
225
|
-
}
|
|
226
|
-
} else {
|
|
227
|
-
const rollout = registry.writeRollout({
|
|
228
|
-
cwd,
|
|
229
|
-
entries: [],
|
|
230
|
-
model: rolloutModel,
|
|
231
|
-
...rolloutEffort ? { effort: rolloutEffort } : {}
|
|
232
|
-
});
|
|
233
|
-
sessionId = rollout.sessionId;
|
|
234
|
-
rollbackHandle = rollbackHandleFor(agent, rollout.sessionId, rollout.rolloutPath);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
const created = db.transaction(() => {
|
|
238
|
-
const currentSource = getTopic(sourceTopicId);
|
|
239
|
-
if (!currentSource || currentSource.kind === "manager" || !isParticipant(currentSource, userId)) {
|
|
240
|
-
throw new TopicDeriveBusyError("Source topic changed while deriving; try again");
|
|
241
|
-
}
|
|
242
|
-
const transactionalConflict = findTopicTitleConflict(title, kind);
|
|
243
|
-
if (transactionalConflict)
|
|
244
|
-
throw new TopicTitleConflictError(title);
|
|
245
|
-
upsertTopic(derived);
|
|
246
|
-
if (subagent) {
|
|
247
|
-
const childConfig = { ...sourceConfig ?? {} };
|
|
248
|
-
delete childConfig.mcp;
|
|
249
|
-
if (subagent.agent) {
|
|
250
|
-
delete childConfig.model;
|
|
251
|
-
}
|
|
252
|
-
if (subagent.model)
|
|
253
|
-
childConfig.model = subagent.model;
|
|
254
|
-
if (Object.keys(childConfig).length > 0)
|
|
255
|
-
setApiTopicConfig(derived.id, childConfig);
|
|
256
|
-
} else if (sourceConfig) {
|
|
257
|
-
setApiTopicConfig(derived.id, sourceConfig);
|
|
258
|
-
}
|
|
259
|
-
if (copyHistory) {
|
|
260
|
-
copyMessagesForTopic(sourceTopicId, derived.id);
|
|
261
|
-
cloneConversationLog({
|
|
262
|
-
userId,
|
|
263
|
-
srcTopic: topic.title,
|
|
264
|
-
dstTopic: derived.title
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
if (sessionId && agent) {
|
|
268
|
-
setTopicSessionId(derived.id, sessionId, {
|
|
269
|
-
reason: copyHistory ? "slash-fork" : subagent ? "spawn-subagent" : "slash-spawn",
|
|
270
|
-
agent
|
|
271
|
-
});
|
|
272
|
-
appendConversationEventStrict(userId, derived.title, agent, {
|
|
273
|
-
type: "session",
|
|
274
|
-
sessionId
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
return derived;
|
|
278
|
-
}).immediate();
|
|
279
|
-
try {
|
|
280
|
-
const profileClone = await cloneProfileForChild({
|
|
281
|
-
userId,
|
|
282
|
-
srcTopic: sourceTopicId,
|
|
283
|
-
dstTopic: derived.id
|
|
284
|
-
});
|
|
285
|
-
logger.info({
|
|
286
|
-
sourceTopicId,
|
|
287
|
-
derivedTopicId: derived.id,
|
|
288
|
-
copyHistory,
|
|
289
|
-
subagent: Boolean(subagent),
|
|
290
|
-
profileClone
|
|
291
|
-
}, "createDerivedTopic: playwright profile clone");
|
|
292
|
-
} catch (profileErr) {
|
|
293
|
-
logger.warn({ err: profileErr, sourceTopicId, derivedTopicId: derived.id }, "createDerivedTopic: playwright profile clone threw (continuing)");
|
|
294
|
-
}
|
|
295
|
-
WsHub.get().broadcastTopicCreated(created);
|
|
296
|
-
return created;
|
|
297
|
-
} catch (err) {
|
|
298
|
-
if (rollbackHandle)
|
|
299
|
-
cleanupAgentFork(rollbackHandle);
|
|
300
|
-
if (err instanceof TopicDeriveBusyError || err instanceof TopicTitleConflictError)
|
|
301
|
-
throw err;
|
|
302
|
-
logger.warn({ err, sourceTopicId, derivedTopicId: derived.id, copyHistory }, "createDerivedTopic: failed to create derived topic");
|
|
303
|
-
return null;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
export {
|
|
307
|
-
updateTopic,
|
|
308
|
-
isParticipant,
|
|
309
|
-
getVisibleTopics,
|
|
310
|
-
getTopics,
|
|
311
|
-
createDerivedTopic,
|
|
312
|
-
TopicTitleConflictError,
|
|
313
|
-
TopicDeriveBusyError
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
export { getTopics, getVisibleTopics, updateTopic, isParticipant, TopicTitleConflictError, TopicDeriveBusyError, createDerivedTopic };
|
|
317
|
-
|
|
318
|
-
//# debugId=695BB153EAD714B564756E2164756E21
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../packages/core/src/topics/derive.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"/**\n * Derived-topic creation — fork (config+history copy), spawn (config-only),\n * and subagent (agent-initiated worker room) share this helper.\n *\n * Ported from otium runtime-api `api/routes/topics.ts`, minus the REST route\n * table; the route-facing wrappers (`getTopics`, `updateTopic`) live here too\n * so ported call sites keep working.\n */\n\nimport { randomUUID } from \"node:crypto\";\nimport { mkdirSync } from \"node:fs\";\nimport { cleanupAgentFork, type ForkHandle, forkAgentSession } from \"#agents/fork\";\nimport { resolveModelForAgent } from \"#agents/model-catalog\";\nimport { getRegistry } from \"#agents/registry\";\nimport { WsHub } from \"#bus\";\nimport { resolveTopicWorkspaceDir } from \"#platform/config\";\nimport { logger } from \"#platform/logger\";\nimport { cloneProfileForChild } from \"#platform/playwright/manager\";\nimport { isTopicRunning } from \"#query/active-rooms\";\nimport { copyMessagesForTopic } from \"#storage/api-messages\";\nimport { getApiTopicConfig, setApiTopicConfig } from \"#storage/api-topic-config\";\nimport {\n findTopicTitleConflict,\n getTopic,\n getTopicSessionId,\n inferTopicKind,\n isTopicVisible,\n listTopics,\n setTopicSessionId,\n upsertTopic,\n} from \"#storage/api-topics\";\nimport {\n appendConversationEventStrict,\n cloneConversationLog,\n readConversation,\n} from \"#storage/conversations\";\nimport { db } from \"#storage/forum-db\";\nimport { beginRuntimeTopicMaintenance } from \"#storage/runtime-topic-state\";\nimport { isLegacySharedGeneral } from \"#topics/personal-general\";\nimport type { AgentKind } from \"#types\";\nimport type { TopicDto } from \"#types/api\";\n\nexport function getTopics(): TopicDto[] {\n return listTopics().filter((topic) => !isLegacySharedGeneral(topic.id));\n}\n\n/** Topics adapters may show in lists and selection UIs. */\nexport function getVisibleTopics(): TopicDto[] {\n return getTopics()\n .filter(isTopicVisible)\n .map((topic) => {\n if (!topic.agent) return topic;\n const registry = getRegistry(topic.agent);\n const config = getApiTopicConfig(topic.id);\n const requestedEffort = config?.effort ?? topic.defaultEffort;\n return {\n ...topic,\n effectiveModel: resolveModelForAgent(\n topic.agent,\n config?.model ?? topic.defaultModel,\n registry,\n ),\n effectiveEffort:\n requestedEffort && registry.validateEffort(requestedEffort)\n ? requestedEffort\n : registry.defaultEffort,\n };\n });\n}\n\nexport function updateTopic(topicId: string, patch: Partial<TopicDto>): boolean {\n const topic = getTopic(topicId);\n if (!topic) return false;\n Object.assign(topic, patch);\n upsertTopic(topic);\n return true;\n}\n\nexport function isParticipant(topic: TopicDto, userId: string): boolean {\n return topic.participants.some((p) => p.userId === userId);\n}\n\nfunction nextDerivedTopicTitle(\n sourceTitle: string,\n kind: TopicDto[\"kind\"],\n suffix: \"fork\" | \"spawn\" | \"agent\",\n): string {\n const visibleTitles = new Set(\n listTopics()\n .filter((topic) => topic.kind === kind)\n .map((topic) => topic.title.toLowerCase()),\n );\n let n = 1;\n let title = `${sourceTitle}-${suffix}-${n}`;\n while (visibleTitles.has(title.toLowerCase())) {\n n += 1;\n title = `${sourceTitle}-${suffix}-${n}`;\n }\n return title;\n}\n\nfunction effectiveAgentForTopic(_topicId: string, topic: TopicDto): AgentKind | undefined {\n if (!topic.agent) return undefined;\n return topic.agent;\n}\n\nfunction rollbackHandleFor(agent: AgentKind, sessionId: string, rolloutPath: string): ForkHandle {\n return { agent, forkId: sessionId, rolloutPath };\n}\n\n/** Thrown when a user-supplied derived-topic name collides with an existing\n * topic title. Callers surface this as a specific \"pick a different name\"\n * message instead of the generic membership/session failure. */\nexport class TopicTitleConflictError extends Error {\n constructor(readonly title: string) {\n super(`A topic named \"${title}\" already exists`);\n this.name = \"TopicTitleConflictError\";\n }\n}\n\nexport class TopicDeriveBusyError extends Error {\n constructor(message = \"Topic is busy; try again when the current operation finishes\") {\n super(message);\n this.name = \"TopicDeriveBusyError\";\n }\n}\n\ninterface DerivedTopicOptions {\n name?: string;\n subagent?: { agent?: AgentKind; model?: string };\n allowActiveSource?: boolean;\n}\n\n/**\n * Shared helper for spawn (config-only copy) and fork (config+history copy).\n *\n * - fork (copyHistory=true): inherits ALL source participants, copies messages,\n * creator becomes owner, and forks the source AI session when AI is enabled.\n * - spawn (copyHistory=false): config only, creator is sole owner, empty history.\n * It still creates a fresh AI session when AI is enabled.\n * - subagent (copyHistory=false + opts.subagent): agent-initiated worker room.\n * Marked `isSubagent`, optionally overriding the child's agent/model.\n *\n * @param sourceTopicId - must exist and caller must be a participant\n * @param userId - caller (becomes owner of the new topic)\n * @param copyHistory - true for fork, false for spawn\n * @param opts - optional custom name and subagent overrides\n * @returns the newly created TopicDto or null on error\n * @throws TopicDeriveBusyError when user-triggered derivation races active work or maintenance\n * @throws TopicTitleConflictError when the requested name is already taken\n */\nexport async function createDerivedTopic(\n sourceTopicId: string,\n userId: string,\n copyHistory: boolean,\n opts?: DerivedTopicOptions,\n): Promise<TopicDto | null> {\n const topic = getTopic(sourceTopicId);\n if (!topic) return null;\n if (topic.kind === \"manager\") return null;\n if (!isParticipant(topic, userId)) return null;\n\n const subagent = copyHistory ? undefined : opts?.subagent;\n let maintenance: ReturnType<typeof beginRuntimeTopicMaintenance> = null;\n if (!subagent && !opts?.allowActiveSource) {\n if (isTopicRunning(sourceTopicId)) throw new TopicDeriveBusyError();\n maintenance = beginRuntimeTopicMaintenance(sourceTopicId);\n if (!maintenance) throw new TopicDeriveBusyError();\n if (isTopicRunning(sourceTopicId)) {\n maintenance.finish();\n maintenance = null;\n throw new TopicDeriveBusyError();\n }\n }\n\n try {\n return await createDerivedTopicUnderFence(topic, sourceTopicId, userId, copyHistory, opts);\n } finally {\n maintenance?.finish();\n }\n}\n\nasync function createDerivedTopicUnderFence(\n topic: TopicDto,\n sourceTopicId: string,\n userId: string,\n copyHistory: boolean,\n opts?: DerivedTopicOptions,\n): Promise<TopicDto | null> {\n const now = new Date().toISOString();\n const subagent = copyHistory ? undefined : opts?.subagent;\n const suffix = copyHistory ? \"fork\" : subagent ? \"agent\" : \"spawn\";\n const sourceConfig = getApiTopicConfig(sourceTopicId);\n const agent = subagent?.agent ?? effectiveAgentForTopic(sourceTopicId, topic);\n\n // Fork: inherit all source participants, creator becomes owner\n // Spawn: creator is sole owner\n // Subagent: inherit all source participants — everyone who can see the\n // parent room sees the card there, so its \"view room\" target must be\n // accessible to them too (single-topic GET rejects non-participants).\n const participants: TopicDto[\"participants\"] =\n copyHistory || subagent\n ? [\n ...topic.participants\n .filter((p) => p.userId !== userId)\n .map((p) => ({ ...p, role: \"member\" as const })),\n { userId, role: \"owner\" as const },\n ]\n : [{ userId, role: \"owner\" as const }];\n const kind = topic.kind ?? inferTopicKind(topic);\n const title = opts?.name?.trim() || nextDerivedTopicTitle(topic.title, kind, suffix);\n const conflict = findTopicTitleConflict(title, kind);\n if (conflict) {\n logger.info(\n { sourceTopicId, title, kind, conflictTopicId: conflict.id },\n \"createDerivedTopic: title conflict\",\n );\n throw new TopicTitleConflictError(title);\n }\n const derived: TopicDto = {\n id: randomUUID(),\n title,\n kind,\n description: topic.description,\n agent: subagent?.agent ?? topic.agent,\n defaultModel: subagent?.model ?? topic.defaultModel,\n defaultEffort: topic.defaultEffort,\n aiMode: topic.aiMode,\n aiMention: topic.aiMention,\n participants,\n createdAt: now,\n lastMessageAt: now,\n parentTopicId: sourceTopicId,\n isFork: copyHistory,\n ...(subagent ? { isSubagent: true } : {}),\n visibility: topic.visibility,\n accessMode: topic.accessMode,\n };\n\n let sessionId: string | undefined;\n let rollbackHandle: ForkHandle | undefined;\n\n try {\n if (agent) {\n const cwd = resolveTopicWorkspaceDir(derived.id);\n mkdirSync(cwd, { recursive: true });\n const registry = getRegistry(agent);\n const requestedRolloutModel =\n subagent?.model ??\n (subagent?.agent ? undefined : sourceConfig?.model) ??\n derived.defaultModel;\n const rolloutModel = resolveModelForAgent(agent, requestedRolloutModel, registry);\n const requestedRolloutEffort = subagent?.agent\n ? registry.defaultEffort\n : (sourceConfig?.effort ?? derived.defaultEffort);\n const rolloutEffort =\n requestedRolloutEffort && registry.validateEffort(requestedRolloutEffort)\n ? requestedRolloutEffort\n : registry.defaultEffort;\n\n if (copyHistory) {\n const parentSessionId = getTopicSessionId(sourceTopicId);\n if (parentSessionId) {\n try {\n const fork = await forkAgentSession({\n agent,\n parentSessionId,\n cwd,\n userId,\n topicName: topic.title,\n title,\n model: rolloutModel,\n ...(rolloutEffort ? { effort: rolloutEffort } : {}),\n });\n sessionId = fork.forkId;\n rollbackHandle = fork;\n } catch (err) {\n logger.warn(\n { err, sourceTopicId, title: topic.title, agent, parentSessionId },\n \"createDerivedTopic: native fork failed; synthesizing from unified history\",\n );\n }\n }\n if (!sessionId) {\n const rollout = registry.writeRollout({\n cwd,\n entries: readConversation(userId, topic.title),\n model: rolloutModel,\n ...(rolloutEffort ? { effort: rolloutEffort } : {}),\n });\n sessionId = rollout.sessionId;\n rollbackHandle = rollbackHandleFor(agent, rollout.sessionId, rollout.rolloutPath);\n }\n } else {\n const rollout = registry.writeRollout({\n cwd,\n entries: [],\n model: rolloutModel,\n ...(rolloutEffort ? { effort: rolloutEffort } : {}),\n });\n sessionId = rollout.sessionId;\n rollbackHandle = rollbackHandleFor(agent, rollout.sessionId, rollout.rolloutPath);\n }\n }\n\n const created = db\n .transaction(() => {\n const currentSource = getTopic(sourceTopicId);\n if (\n !currentSource ||\n currentSource.kind === \"manager\" ||\n !isParticipant(currentSource, userId)\n ) {\n throw new TopicDeriveBusyError(\"Source topic changed while deriving; try again\");\n }\n const transactionalConflict = findTopicTitleConflict(title, kind);\n if (transactionalConflict) throw new TopicTitleConflictError(title);\n upsertTopic(derived);\n if (subagent) {\n // Subagent worker rooms do NOT cascade the parent's optional MCP\n // whitelist — they start with the default (required-only) MCP set,\n // mirroring clawgram's subagent policy. An explicit agent/model\n // override must also beat the parent's config override, which\n // startAiTurn resolves ahead of the topic defaults; dropping the\n // inherited model when only the agent changes avoids pinning the\n // child to a model that belongs to the parent's agent.\n const childConfig = { ...(sourceConfig ?? {}) };\n delete childConfig.mcp;\n if (subagent.agent) {\n delete childConfig.model;\n }\n if (subagent.model) childConfig.model = subagent.model;\n if (Object.keys(childConfig).length > 0) setApiTopicConfig(derived.id, childConfig);\n } else if (sourceConfig) {\n setApiTopicConfig(derived.id, sourceConfig);\n }\n if (copyHistory) {\n copyMessagesForTopic(sourceTopicId, derived.id);\n cloneConversationLog({\n userId,\n srcTopic: topic.title,\n dstTopic: derived.title,\n });\n }\n if (sessionId && agent) {\n setTopicSessionId(derived.id, sessionId, {\n reason: copyHistory ? \"slash-fork\" : subagent ? \"spawn-subagent\" : \"slash-spawn\",\n agent,\n });\n appendConversationEventStrict(userId, derived.title, agent, {\n type: \"session\",\n sessionId,\n });\n }\n return derived;\n })\n .immediate();\n\n // Derived rooms inherit the browser profile only when the creator already\n // owns the source. Crossing an owner boundary always starts with a fresh\n // profile so cookies and login state cannot be transferred by a member.\n try {\n const profileClone = await cloneProfileForChild({\n userId,\n srcTopic: sourceTopicId,\n dstTopic: derived.id,\n });\n logger.info(\n {\n sourceTopicId,\n derivedTopicId: derived.id,\n copyHistory,\n subagent: Boolean(subagent),\n profileClone,\n },\n \"createDerivedTopic: playwright profile clone\",\n );\n } catch (profileErr) {\n logger.warn(\n { err: profileErr, sourceTopicId, derivedTopicId: derived.id },\n \"createDerivedTopic: playwright profile clone threw (continuing)\",\n );\n }\n\n // Every derived room (fork/spawn/subagent) is user-visible: tell all\n // inherited participants, not just the client that issued the request.\n WsHub.get().broadcastTopicCreated(created);\n return created;\n } catch (err) {\n if (rollbackHandle) cleanupAgentFork(rollbackHandle);\n if (err instanceof TopicDeriveBusyError || err instanceof TopicTitleConflictError) throw err;\n logger.warn(\n { err, sourceTopicId, derivedTopicId: derived.id, copyHistory },\n \"createDerivedTopic: failed to create derived topic\",\n );\n return null;\n }\n}\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA;AACA;AAgCO,SAAS,SAAS,GAAe;AAAA,EACtC,OAAO,WAAW,EAAE,OAAO,CAAC,WAAW,sBAAsB,MAAM,EAAE,CAAC;AAAA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Q,IAAI,WAAW;AAAA,UACvC,QAAQ,cAAc,eAAe,WAAW,mBAAmB;AAAA,UACnE;AAAA,QACF,CAAC;AAAA,QACD,8BAA8B,QAAQ,QAAQ,OAAO,OAAO;AAAA,UAC1D,MAAM;AAAA,UACN;AAAA,QACF,CAAC;AAAA,MACH;AAAA,MACA,OAAO;AAAA,KACR,EACA,UAAU;AAAA,IAKb,IAAI;AAAA,MACF,MAAM,eAAe,MAAM,qBAAqB;AAAA,QAC9C;AAAA,QACA,UAAU;AAAA,QACV,UAAU,QAAQ;AAAA,MACpB,CAAC;AAAA,MACD,OAAO,KACL;AAAA,QACE;AAAA,QACA,gBAAgB,QAAQ;AAAA,QACxB;AAAA,QACA,UAAU,QAAQ,QAAQ;AAAA,QAC1B;AAAA,MACF,GACA,8CACF;AAAA,MACA,OAAO,YAAY;AAAA,MACnB,OAAO,KACL,EAAE,KAAK,YAAY,eAAe,gBAAgB,QAAQ,GAAG,GAC7D,iEACF;AAAA;AAAA,IAKF,MAAM,IAAI,EAAE,sBAAsB,OAAO;AAAA,IACzC,OAAO;AAAA,IACP,OAAO,KAAK;AAAA,IACZ,IAAI;AAAA,MAAgB,iBAAiB,cAAc;AAAA,IACnD,IAAI,eAAe,wBAAwB,eAAe;AAAA,MAAyB,MAAM;AAAA,IACzF,OAAO,KACL,EAAE,KAAK,eAAe,gBAAgB,QAAQ,IAAI,YAAY,GAC9D,oDACF;AAAA,IACA,OAAO;AAAA;AAAA;",
|
|
8
|
-
"debugId": "695BB153EAD714B564756E2164756E21",
|
|
9
|
-
"names": []
|
|
10
|
-
}
|
package/dist/chunk-nkgs40ch.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
__require,
|
|
3
|
-
__toESM
|
|
4
|
-
} from "./chunk-hwy3n31w.js";
|
|
5
|
-
|
|
6
|
-
// ../cli/src/adapter-loader.ts
|
|
7
|
-
var runningFromSource = import.meta.dir.endsWith("/src");
|
|
8
|
-
async function loadFromSource(sourcePath) {
|
|
9
|
-
return await import(new URL(sourcePath, import.meta.url).href);
|
|
10
|
-
}
|
|
11
|
-
function loadTerminalCli() {
|
|
12
|
-
return runningFromSource ? loadFromSource("../../../adapters/terminal/src/cli.ts") : import("./chunk-0yfqyv88.js");
|
|
13
|
-
}
|
|
14
|
-
function loadTelegramCli() {
|
|
15
|
-
return runningFromSource ? loadFromSource("../../../adapters/telegram/src/cli.ts") : import("./chunk-03kv7mvj.js");
|
|
16
|
-
}
|
|
17
|
-
function loadOtiumCli() {
|
|
18
|
-
return runningFromSource ? loadFromSource("../../../adapters/otium/src/cli.ts") : import("./chunk-yb4rbev9.js");
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export { loadTerminalCli, loadTelegramCli, loadOtiumCli };
|
|
22
|
-
|
|
23
|
-
//# debugId=283C96B3A44ADB4C64756E2164756E21
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../cli/src/adapter-loader.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"type TerminalCli = typeof import(\"@negotium/adapter-terminal/cli\");\ntype TelegramCli = typeof import(\"@negotium/adapter-telegram/cli\");\ntype OtiumCli = typeof import(\"@negotium/adapter-otium/cli\");\n\nconst runningFromSource = import.meta.dir.endsWith(\"/src\");\n\nasync function loadFromSource<T>(sourcePath: string): Promise<T> {\n // `bun apps/cli/src/main.ts` is a development entrypoint. Loading workspace\n // package exports there would silently use yesterday's dist build, so source\n // runs resolve the adapter source beside this package. A built/published CLI\n // continues to use normal package exports.\n return (await import(new URL(sourcePath, import.meta.url).href)) as T;\n}\n\nexport function loadTerminalCli(): Promise<TerminalCli> {\n return runningFromSource\n ? loadFromSource(\"../../../adapters/terminal/src/cli.ts\")\n : import(\"@negotium/adapter-terminal/cli\");\n}\n\nexport function loadTelegramCli(): Promise<TelegramCli> {\n return runningFromSource\n ? loadFromSource(\"../../../adapters/telegram/src/cli.ts\")\n : import(\"@negotium/adapter-telegram/cli\");\n}\n\nexport function loadOtiumCli(): Promise<OtiumCli> {\n return runningFromSource\n ? loadFromSource(\"../../../adapters/otium/src/cli.ts\")\n : import(\"@negotium/adapter-otium/cli\");\n}\n"
|
|
6
|
-
],
|
|
7
|
-
"mappings": ";;;;;;AAIA,IAAM,oBAAoB,YAAY,IAAI,SAAS,MAAM;AAEzD,eAAe,cAAiB,CAAC,YAAgC;AAAA,EAK/D,OAAQ,MAAa,WAAI,IAAI,YAAY,YAAY,GAAG,EAAE;AAAA;AAGrD,SAAS,eAAe,GAAyB;AAAA,EACtD,OAAO,oBACH,eAAe,uCAAuC,IAC/C;AAAA;AAGN,SAAS,eAAe,GAAyB;AAAA,EACtD,OAAO,oBACH,eAAe,uCAAuC,IAC/C;AAAA;AAGN,SAAS,YAAY,GAAsB;AAAA,EAChD,OAAO,oBACH,eAAe,oCAAoC,IAC5C;AAAA;",
|
|
8
|
-
"debugId": "283C96B3A44ADB4C64756E2164756E21",
|
|
9
|
-
"names": []
|
|
10
|
-
}
|
package/dist/chunk-pz57vwsm.js
DELETED
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import {
|
|
3
|
-
startDefaultNode
|
|
4
|
-
} from "./chunk-gxmny6tq.js";
|
|
5
|
-
import"./chunk-edb07sjp.js";
|
|
6
|
-
import {
|
|
7
|
-
executeVaultCommand,
|
|
8
|
-
isVaultCommandLine,
|
|
9
|
-
registerTopic
|
|
10
|
-
} from "./chunk-h7bj5zwb.js";
|
|
11
|
-
import"./chunk-tcs9qjps.js";
|
|
12
|
-
import"./chunk-7k19pcg8.js";
|
|
13
|
-
import"./chunk-8dy7e2a9.js";
|
|
14
|
-
import"./chunk-9hjeemfz.js";
|
|
15
|
-
import"./chunk-1k7t7bnx.js";
|
|
16
|
-
import {
|
|
17
|
-
answerPendingAskUserQuestion,
|
|
18
|
-
startAiTurn
|
|
19
|
-
} from "./chunk-xhm1rfpt.js";
|
|
20
|
-
import"./chunk-mnwaext5.js";
|
|
21
|
-
import"./chunk-xpcps28p.js";
|
|
22
|
-
import {
|
|
23
|
-
appendApiMessage,
|
|
24
|
-
runtimeBus
|
|
25
|
-
} from "./chunk-fbtb3v0s.js";
|
|
26
|
-
import {
|
|
27
|
-
getTopicByNameForUser
|
|
28
|
-
} from "./chunk-ejcm6zx8.js";
|
|
29
|
-
import"./chunk-hp4g7wx7.js";
|
|
30
|
-
import"./chunk-s74rdyqe.js";
|
|
31
|
-
import"./chunk-k778y16p.js";
|
|
32
|
-
import"./chunk-xag86ng3.js";
|
|
33
|
-
import"./chunk-wx83ep8e.js";
|
|
34
|
-
import"./chunk-00q25k7p.js";
|
|
35
|
-
import"./chunk-gaknyw04.js";
|
|
36
|
-
import"./chunk-mh5mexsf.js";
|
|
37
|
-
import {
|
|
38
|
-
isAgentKind
|
|
39
|
-
} from "./chunk-ezs352qs.js";
|
|
40
|
-
import"./chunk-j0kjscb7.js";
|
|
41
|
-
import {
|
|
42
|
-
abortRoom
|
|
43
|
-
} from "./chunk-82qhv1mq.js";
|
|
44
|
-
import"./chunk-ffefbd3r.js";
|
|
45
|
-
import"./chunk-81tbfbmt.js";
|
|
46
|
-
import"./chunk-sffqdkvq.js";
|
|
47
|
-
import"./chunk-f5xgprg1.js";
|
|
48
|
-
import"./chunk-hwy3n31w.js";
|
|
49
|
-
|
|
50
|
-
// ../cli/src/commands/chat.ts
|
|
51
|
-
import { randomUUID } from "crypto";
|
|
52
|
-
import { createInterface } from "readline";
|
|
53
|
-
|
|
54
|
-
// ../cli/src/render.ts
|
|
55
|
-
var dim = (s) => `\x1B[2m${s}\x1B[0m`;
|
|
56
|
-
var bold = (s) => `\x1B[1m${s}\x1B[0m`;
|
|
57
|
-
var cyan = (s) => `\x1B[36m${s}\x1B[0m`;
|
|
58
|
-
var red = (s) => `\x1B[31m${s}\x1B[0m`;
|
|
59
|
-
function renderBusEvent(event, opts = {}) {
|
|
60
|
-
if (opts.topicId && event.topicId !== opts.topicId)
|
|
61
|
-
return;
|
|
62
|
-
switch (event.type) {
|
|
63
|
-
case "message": {
|
|
64
|
-
const msg = event.payload;
|
|
65
|
-
if (opts.selfUserId && msg.authorId === opts.selfUserId)
|
|
66
|
-
return;
|
|
67
|
-
if (msg.kind === "tool") {
|
|
68
|
-
console.log(dim(` ${firstLine(msg.text)}`));
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const author = msg.authorId === "ai" ? cyan(bold("ai")) : bold(msg.authorId);
|
|
72
|
-
console.log(`${author}${msg.agentType ? dim(` (${msg.agentType})`) : ""}: ${msg.text}`);
|
|
73
|
-
if (msg.kind === "ask_user_question" && msg.askUserQuestion) {
|
|
74
|
-
msg.askUserQuestion.choices.forEach((choice, index) => {
|
|
75
|
-
const description = choice.description ? dim(` \u2014 ${choice.description}`) : "";
|
|
76
|
-
console.log(` ${index + 1}) ${choice.label}${description}`);
|
|
77
|
-
});
|
|
78
|
-
console.log(dim(" choose by number or exact label"));
|
|
79
|
-
}
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
case "message-updated":
|
|
83
|
-
return;
|
|
84
|
-
case "ai-status": {
|
|
85
|
-
const status = event.payload;
|
|
86
|
-
const kind = String(status.kind ?? "");
|
|
87
|
-
if (kind === "ai-active" || kind === "typing")
|
|
88
|
-
return;
|
|
89
|
-
if (kind === "tool-call") {
|
|
90
|
-
console.log(dim(` \u2699 ${firstLine(String(status.label ?? status.tool ?? "tool"))}`));
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
if (kind === "error") {
|
|
94
|
-
console.log(red(` \u2716 ${firstLine(String(status.message ?? "error"))}`));
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
if (kind === "aborted") {
|
|
98
|
-
console.log(dim(" \u23F9 aborted"));
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
case "topic-created": {
|
|
104
|
-
const topic = event.payload;
|
|
105
|
-
console.log(dim(` + topic created: ${topic.title ?? topic.id}`));
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
case "topic-deleted":
|
|
109
|
-
console.log(dim(` - topic deleted: ${event.topicId}`));
|
|
110
|
-
return;
|
|
111
|
-
default:
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
function firstLine(s) {
|
|
116
|
-
const line = s.split(`
|
|
117
|
-
`, 1)[0] ?? "";
|
|
118
|
-
return line.length > 120 ? `${line.slice(0, 117)}...` : line;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// ../cli/src/commands/chat.ts
|
|
122
|
-
var DEFAULT_USER = "local";
|
|
123
|
-
var DEFAULT_TOPIC = "chat";
|
|
124
|
-
var VAULT_SET_COMMAND_PATTERN = /^\/vault(?:@\w+)?\s+set(?:\s|$)/i;
|
|
125
|
-
function scrubVaultSetCommandsFromHistory(history) {
|
|
126
|
-
for (let index = history.length - 1;index >= 0; index -= 1) {
|
|
127
|
-
if (VAULT_SET_COMMAND_PATTERN.test(history[index]?.trim() ?? "")) {
|
|
128
|
-
history.splice(index, 1);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
function ensureTopic(title, agent) {
|
|
133
|
-
const existing = getTopicByNameForUser(title, DEFAULT_USER);
|
|
134
|
-
if (existing)
|
|
135
|
-
return existing;
|
|
136
|
-
return registerTopic({
|
|
137
|
-
title,
|
|
138
|
-
userId: DEFAULT_USER,
|
|
139
|
-
kind: "agent",
|
|
140
|
-
...agent && isAgentKind(agent) ? { agent } : {}
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
async function chatCommand(args) {
|
|
144
|
-
const topicArg = args.find((a) => !a.startsWith("--"));
|
|
145
|
-
const agentArg = args.find((a) => a.startsWith("--agent="))?.slice("--agent=".length);
|
|
146
|
-
const node = await startDefaultNode();
|
|
147
|
-
let topic = ensureTopic(topicArg ?? DEFAULT_TOPIC, agentArg);
|
|
148
|
-
console.log(`negotium node on :${node.port} \u2014 topic "${topic.title}" (agent: ${topic.agent})`);
|
|
149
|
-
console.log(`commands: /vault, /switch <topic>, /abort, /quit
|
|
150
|
-
`);
|
|
151
|
-
const rl = createInterface({
|
|
152
|
-
input: process.stdin,
|
|
153
|
-
output: process.stdout,
|
|
154
|
-
prompt: "> "
|
|
155
|
-
});
|
|
156
|
-
let pendingAsk = null;
|
|
157
|
-
const unsubscribe = runtimeBus().subscribe((event) => {
|
|
158
|
-
renderBusEvent(event, { topicId: topic.id, selfUserId: DEFAULT_USER });
|
|
159
|
-
if (event.topicId !== topic.id)
|
|
160
|
-
return;
|
|
161
|
-
if (event.type === "message") {
|
|
162
|
-
const msg = event.payload;
|
|
163
|
-
if (msg.kind === "ask_user_question" && msg.askUserQuestion) {
|
|
164
|
-
pendingAsk = { messageId: msg.id, choices: msg.askUserQuestion.choices };
|
|
165
|
-
rl.prompt();
|
|
166
|
-
}
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
if (event.type === "message-updated" && pendingAsk) {
|
|
170
|
-
const payload = event.payload;
|
|
171
|
-
if (payload.messageId === pendingAsk.messageId && (payload.patch?.askUserQuestion?.expired || payload.patch?.askUserQuestion?.selectedLabel)) {
|
|
172
|
-
pendingAsk = null;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
rl.prompt();
|
|
177
|
-
rl.on("line", (line) => {
|
|
178
|
-
const text = line.trim();
|
|
179
|
-
if (VAULT_SET_COMMAND_PATTERN.test(text)) {
|
|
180
|
-
scrubVaultSetCommandsFromHistory(rl.history);
|
|
181
|
-
}
|
|
182
|
-
if (!text) {
|
|
183
|
-
rl.prompt();
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
if (text === "/quit" || text === "/exit") {
|
|
187
|
-
rl.close();
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
if (text === "/abort") {
|
|
191
|
-
const aborted = abortRoom(topic.id);
|
|
192
|
-
console.log(aborted ? "aborted." : "nothing running.");
|
|
193
|
-
rl.prompt();
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
if (text.startsWith("/switch ")) {
|
|
197
|
-
topic = ensureTopic(text.slice("/switch ".length).trim(), agentArg);
|
|
198
|
-
pendingAsk = null;
|
|
199
|
-
console.log(`\u2192 topic "${topic.title}" (agent: ${topic.agent})`);
|
|
200
|
-
rl.prompt();
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
if (isVaultCommandLine(text)) {
|
|
204
|
-
const result = executeVaultCommand(DEFAULT_USER, text);
|
|
205
|
-
if (result)
|
|
206
|
-
console.log(result);
|
|
207
|
-
rl.prompt();
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
if (pendingAsk) {
|
|
211
|
-
const choiceIndex = /^\d+$/.test(text) ? Number(text) - 1 : -1;
|
|
212
|
-
const choice = (choiceIndex >= 0 ? pendingAsk.choices[choiceIndex] : undefined) ?? pendingAsk.choices.find((item) => item.label === text);
|
|
213
|
-
if (!choice) {
|
|
214
|
-
console.log("invalid choice \u2014 enter one of the displayed numbers or labels.");
|
|
215
|
-
rl.prompt();
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
const answered = answerPendingAskUserQuestion(topic.id, pendingAsk.messageId, choice.label, DEFAULT_USER);
|
|
219
|
-
if (!answered.ok) {
|
|
220
|
-
console.log(`could not answer: ${answered.error}`);
|
|
221
|
-
} else {
|
|
222
|
-
pendingAsk = null;
|
|
223
|
-
}
|
|
224
|
-
rl.prompt();
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
appendApiMessage({
|
|
228
|
-
id: randomUUID(),
|
|
229
|
-
topicId: topic.id,
|
|
230
|
-
authorId: DEFAULT_USER,
|
|
231
|
-
text,
|
|
232
|
-
createdAt: new Date().toISOString()
|
|
233
|
-
});
|
|
234
|
-
startAiTurn({ topic, userId: DEFAULT_USER, prompt: text, allowAutoContinue: true });
|
|
235
|
-
rl.prompt();
|
|
236
|
-
});
|
|
237
|
-
await new Promise((resolve) => {
|
|
238
|
-
rl.on("close", async () => {
|
|
239
|
-
unsubscribe();
|
|
240
|
-
await node.stop();
|
|
241
|
-
resolve();
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
export {
|
|
246
|
-
scrubVaultSetCommandsFromHistory,
|
|
247
|
-
chatCommand
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
//# debugId=31CF6CADA058B1C964756E2164756E21
|