openbot 0.3.5 → 0.3.6
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/README.md +1 -1
- package/dist/app/cli.js +1 -1
- package/dist/assets/icon.svg +9 -3
- package/dist/bus/services.js +44 -8
- package/dist/harness/context.js +10 -5
- package/dist/services/storage.js +30 -5
- package/package.json +1 -1
- package/src/app/cli.ts +1 -1
- package/src/app/types.ts +7 -1
- package/src/assets/icon.svg +9 -3
- package/src/bus/services.ts +56 -10
- package/src/bus/types.ts +4 -0
- package/src/harness/context.ts +17 -8
- package/src/services/storage.ts +33 -5
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ OpenBot is a local-first harness for running AI agents. It is built around a sma
|
|
|
18
18
|
|
|
19
19
|
- Runs a local agent server.
|
|
20
20
|
- Stores channels, threads, agents, plugins, config, and variables under `~/.openbot`.
|
|
21
|
-
- Ships with a built-in `system` agent named
|
|
21
|
+
- Ships with a built-in `system` agent named OpenBot.
|
|
22
22
|
- Loads custom agents from `~/.openbot/agents/<agent-id>/AGENT.md`.
|
|
23
23
|
- Loads shared plugins from `~/.openbot/plugins`.
|
|
24
24
|
- Streams events to clients with Server-Sent Events.
|
package/dist/app/cli.js
CHANGED
|
@@ -16,7 +16,7 @@ function checkNodeVersion() {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
checkNodeVersion();
|
|
19
|
-
program.name('openbot').description('OpenBot CLI').version('0.3.
|
|
19
|
+
program.name('openbot').description('OpenBot CLI').version('0.3.6');
|
|
20
20
|
program
|
|
21
21
|
.command('start')
|
|
22
22
|
.description('Start the OpenBot harness')
|
package/dist/assets/icon.svg
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
<svg width="60.2" height="58.1" viewBox="
|
|
2
|
-
<
|
|
3
|
-
|
|
1
|
+
<svg width="60.2" height="58.1" viewBox="272.584 370.297 64.635 62.51" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<style>
|
|
3
|
+
.mark { fill: #000000; }
|
|
4
|
+
@media (prefers-color-scheme: dark) {
|
|
5
|
+
.mark { fill: #ffffff; }
|
|
6
|
+
}
|
|
7
|
+
</style>
|
|
8
|
+
<path class="mark" fill="#000000" d="M301.841 380.896C302.069 380.893 302.297 380.889 302.531 380.885C304.636 380.853 306.741 380.836 308.845 380.822C310.26 380.813 311.675 380.8 313.09 380.775C314.456 380.752 315.822 380.739 317.189 380.735C317.71 380.731 318.231 380.724 318.752 380.712C322.824 380.626 322.824 380.626 323.909 381.43C324.315 382.025 324.561 382.569 324.8 383.246C324.965 383.518 325.13 383.789 325.301 384.068C325.519 384.445 325.519 384.445 325.741 384.83C325.909 385.118 326.077 385.407 326.249 385.704C326.336 385.854 326.423 386.004 326.513 386.159C328.304 389.25 330.137 392.314 332.004 395.361C332.482 396.144 332.957 396.929 333.431 397.715C333.631 398.035 333.631 398.035 333.835 398.361C334.546 399.544 334.969 400.367 334.7 401.777C334.24 402.838 333.683 403.834 333.113 404.839C332.867 405.285 332.621 405.73 332.375 406.176C332.125 406.626 331.874 407.075 331.622 407.525C330.952 408.724 330.296 409.931 329.639 411.137C329.518 411.359 329.397 411.58 329.272 411.807C328.303 413.581 327.349 415.362 326.398 417.144C324.53 420.642 322.621 424.107 320.611 427.525C320.282 428.088 319.962 428.655 319.644 429.224C319.215 429.954 319.215 429.954 318.708 430.462C317.978 430.557 317.978 430.557 317.185 430.462C316.049 429.578 315.42 428.258 314.71 427.035C313.685 425.291 312.637 423.6 311.454 421.96C311.024 421.203 310.906 420.668 310.838 419.8C311.092 419.081 311.092 419.081 311.491 418.343C311.707 417.937 311.707 417.937 311.927 417.522C312.081 417.242 312.235 416.963 312.393 416.675C312.615 416.26 312.615 416.26 312.841 415.836C314.003 413.671 314.003 413.671 314.549 412.797C315.269 411.676 315.269 411.676 315.308 410.387C314.801 409.466 314.268 408.575 313.694 407.695C313.466 407.335 313.238 406.976 313.011 406.616C312.845 406.353 312.845 406.353 312.676 406.085C312.247 405.402 311.829 404.713 311.425 404.014C311.304 403.806 311.183 403.598 311.058 403.384C310.786 402.65 310.848 402.26 311.092 401.523C311.6 401.015 311.6 401.015 312.57 400.967C312.988 400.97 313.407 400.975 313.826 400.982C314.281 400.981 314.737 400.981 315.192 400.98C315.911 400.98 316.629 400.984 317.348 400.995C318.041 401.005 318.733 401.002 319.427 400.998C319.641 401.004 319.854 401.011 320.075 401.017C320.695 401.007 321.171 400.974 321.754 400.762C322.329 400.154 322.665 399.481 323.023 398.731C323.171 398.49 323.318 398.248 323.47 398C323.899 397.287 324.326 396.573 324.752 395.859C324.904 395.608 325.056 395.357 325.212 395.099C325.355 394.859 325.498 394.618 325.646 394.371C325.841 394.045 325.841 394.045 326.04 393.713C326.38 393.138 326.38 393.138 326.323 392.385C326.167 392.384 326.011 392.383 325.85 392.383C322.054 392.368 318.257 392.349 314.461 392.325C312.625 392.313 310.789 392.303 308.953 392.297C307.352 392.291 305.752 392.282 304.152 392.271C303.305 392.265 302.458 392.26 301.61 392.258C300.664 392.256 299.719 392.249 298.773 392.241C298.351 392.241 298.351 392.241 297.921 392.242C297.663 392.238 297.406 392.235 297.14 392.232C296.916 392.231 296.693 392.23 296.462 392.228C295.73 392.109 295.379 391.879 294.846 391.369C294.591 389.978 295.187 388.999 295.837 387.818C295.938 387.63 296.038 387.441 296.142 387.246C296.464 386.646 296.789 386.049 297.115 385.451C297.333 385.045 297.551 384.638 297.769 384.231C299.545 380.925 299.545 380.925 301.841 380.896Z"/>
|
|
9
|
+
<path class="mark" fill="#000000" d="M291.476 372.547C292.795 373.009 293.243 374.055 293.942 375.218C294.23 375.684 294.519 376.15 294.807 376.615C294.945 376.84 295.082 377.065 295.223 377.297C295.544 377.813 295.875 378.314 296.225 378.811C296.388 379.044 296.551 379.277 296.718 379.518C296.856 379.711 296.994 379.903 297.137 380.102C297.492 380.97 297.407 381.615 297.131 382.485C296.704 383.459 296.209 384.39 295.703 385.325C295.497 385.714 295.497 385.714 295.287 386.111C294.44 387.702 293.559 389.255 292.565 390.759C292.217 391.585 292.351 392.026 292.562 392.892C292.955 393.665 292.955 393.665 293.466 394.431C293.555 394.572 293.644 394.713 293.736 394.858C294.019 395.304 294.305 395.748 294.592 396.192C294.971 396.778 295.346 397.365 295.719 397.953C295.886 398.212 296.053 398.471 296.225 398.738C296.646 399.535 296.848 400.115 296.877 401.015C296.559 401.435 296.559 401.435 296.115 401.777C295.364 401.849 294.663 401.877 293.911 401.871C293.467 401.876 293.023 401.88 292.579 401.885C291.879 401.887 291.18 401.888 290.48 401.888C289.804 401.888 289.129 401.895 288.453 401.903C288.244 401.901 288.036 401.899 287.82 401.897C286.637 401.91 286.637 401.91 285.616 402.466C284.844 403.543 284.229 404.69 283.598 405.854C283.455 406.11 283.312 406.365 283.165 406.628C283.031 406.873 282.897 407.118 282.76 407.371C282.637 407.594 282.515 407.818 282.389 408.048C282.071 408.656 282.071 408.656 282.408 409.392C282.559 409.393 282.71 409.394 282.865 409.395C286.539 409.416 290.213 409.439 293.886 409.465C295.663 409.478 297.439 409.49 299.216 409.499C300.929 409.509 302.642 409.521 304.356 409.534C305.011 409.539 305.665 409.543 306.32 409.546C307.235 409.55 308.15 409.557 309.064 409.565C309.473 409.566 309.473 409.566 309.89 409.567C310.139 409.57 310.388 409.573 310.644 409.576C310.861 409.577 311.077 409.578 311.3 409.58C311.854 409.646 311.854 409.646 312.615 410.154C312.797 411.581 312.41 412.577 311.745 413.808C311.656 413.979 311.567 414.15 311.475 414.326C311.288 414.685 311.099 415.042 310.908 415.399C310.616 415.946 310.329 416.495 310.042 417.045C309.859 417.394 309.676 417.743 309.492 418.092C309.363 418.337 309.363 418.337 309.231 418.588C308.881 419.242 308.574 419.78 308.046 420.308C307.364 420.361 306.707 420.382 306.024 420.382C305.815 420.383 305.606 420.385 305.391 420.387C304.698 420.392 304.005 420.392 303.312 420.393C302.832 420.395 302.351 420.396 301.871 420.398C300.862 420.401 299.854 420.402 298.845 420.402C297.552 420.402 296.259 420.409 294.966 420.417C293.973 420.423 292.98 420.424 291.987 420.424C291.51 420.424 291.034 420.427 290.557 420.431C289.89 420.436 289.224 420.434 288.557 420.431C288.36 420.434 288.163 420.437 287.959 420.44C287.061 420.429 286.569 420.386 285.852 419.824C285.47 419.314 285.137 418.817 284.831 418.259C284.718 418.056 284.605 417.852 284.488 417.643C284.367 417.423 284.246 417.203 284.121 416.976C282.907 414.808 281.638 412.679 280.329 410.566C280.156 410.286 279.982 410.006 279.803 409.717C279.469 409.176 279.134 408.636 278.799 408.096C277.871 406.592 276.959 405.077 276.062 403.554C275.968 403.409 275.874 403.264 275.777 403.114C275.143 402.097 274.834 401.442 275.046 400.254C275.425 399.337 275.889 398.475 276.363 397.604C276.568 397.22 276.568 397.22 276.777 396.828C278.005 394.541 279.284 392.283 280.569 390.029C282.224 387.119 283.868 384.197 285.327 381.184C289.509 372.654 289.509 372.654 291.476 372.547Z"/>
|
|
4
10
|
</svg>
|
package/dist/bus/services.js
CHANGED
|
@@ -163,7 +163,7 @@ export const busServicesPlugin = (options) => (builder) => {
|
|
|
163
163
|
};
|
|
164
164
|
});
|
|
165
165
|
builder.on('action:create_channel', async function* (event, context) {
|
|
166
|
-
const { channelId, spec, initialState, cwd } = event.data;
|
|
166
|
+
const { channelId, spec, initialState, cwd, participants } = event.data;
|
|
167
167
|
const rawChannelId = (channelId || '').trim();
|
|
168
168
|
const channelSpec = typeof spec === 'string' ? spec : '';
|
|
169
169
|
const resultMeta = { ...(event.meta || {}), agentId: context.state.agentId };
|
|
@@ -176,11 +176,21 @@ export const busServicesPlugin = (options) => (builder) => {
|
|
|
176
176
|
return;
|
|
177
177
|
}
|
|
178
178
|
const channelUrl = `/channels/${rawChannelId}`;
|
|
179
|
+
const mergedInitial = { ...(initialState || {}) };
|
|
180
|
+
if (participants !== undefined) {
|
|
181
|
+
const normalized = Array.isArray(participants)
|
|
182
|
+
? participants
|
|
183
|
+
.filter((x) => typeof x === 'string')
|
|
184
|
+
.map((s) => s.trim())
|
|
185
|
+
.filter(Boolean)
|
|
186
|
+
: [];
|
|
187
|
+
mergedInitial.participants = normalized;
|
|
188
|
+
}
|
|
179
189
|
try {
|
|
180
190
|
await storage.createChannel({
|
|
181
191
|
channelId: rawChannelId,
|
|
182
192
|
spec: channelSpec,
|
|
183
|
-
initialState:
|
|
193
|
+
initialState: mergedInitial,
|
|
184
194
|
cwd,
|
|
185
195
|
});
|
|
186
196
|
yield {
|
|
@@ -224,6 +234,18 @@ export const busServicesPlugin = (options) => (builder) => {
|
|
|
224
234
|
patch.cwd = data.cwd.trim();
|
|
225
235
|
updatedFields.push('cwd');
|
|
226
236
|
}
|
|
237
|
+
if (data.participants !== undefined) {
|
|
238
|
+
if (Array.isArray(data.participants)) {
|
|
239
|
+
patch.participants = data.participants
|
|
240
|
+
.filter((x) => typeof x === 'string')
|
|
241
|
+
.map((s) => s.trim())
|
|
242
|
+
.filter(Boolean);
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
patch.participants = [];
|
|
246
|
+
}
|
|
247
|
+
updatedFields.push('participants');
|
|
248
|
+
}
|
|
227
249
|
try {
|
|
228
250
|
if (updatedFields.length > 0) {
|
|
229
251
|
await storage.patchChannelState({ channelId: targetChannelId, state: patch });
|
|
@@ -250,28 +272,42 @@ export const busServicesPlugin = (options) => (builder) => {
|
|
|
250
272
|
builder.on('action:patch_channel_details', async function* (event, context) {
|
|
251
273
|
const updatedFields = [];
|
|
252
274
|
const resultMeta = { ...(event.meta || {}), agentId: context.state.agentId };
|
|
275
|
+
const data = (event.data || {});
|
|
253
276
|
try {
|
|
254
|
-
if (
|
|
277
|
+
if (data.state !== undefined) {
|
|
255
278
|
await storage.patchChannelState({
|
|
256
279
|
channelId: context.state.channelId,
|
|
257
|
-
state:
|
|
280
|
+
state: data.state,
|
|
258
281
|
});
|
|
259
282
|
updatedFields.push('state');
|
|
260
283
|
}
|
|
261
|
-
if (typeof
|
|
284
|
+
if (typeof data.spec === 'string') {
|
|
262
285
|
await storage.patchChannelSpec({
|
|
263
286
|
channelId: context.state.channelId,
|
|
264
|
-
spec:
|
|
287
|
+
spec: data.spec,
|
|
265
288
|
});
|
|
266
289
|
updatedFields.push('spec');
|
|
267
290
|
}
|
|
268
|
-
if (typeof
|
|
291
|
+
if (typeof data.cwd === 'string') {
|
|
269
292
|
await storage.patchChannelState({
|
|
270
293
|
channelId: context.state.channelId,
|
|
271
|
-
state: { cwd:
|
|
294
|
+
state: { cwd: data.cwd },
|
|
272
295
|
});
|
|
273
296
|
updatedFields.push('cwd');
|
|
274
297
|
}
|
|
298
|
+
if (data.participants !== undefined) {
|
|
299
|
+
const normalized = Array.isArray(data.participants)
|
|
300
|
+
? data.participants
|
|
301
|
+
.filter((x) => typeof x === 'string')
|
|
302
|
+
.map((s) => s.trim())
|
|
303
|
+
.filter(Boolean)
|
|
304
|
+
: [];
|
|
305
|
+
await storage.patchChannelState({
|
|
306
|
+
channelId: context.state.channelId,
|
|
307
|
+
state: { participants: normalized },
|
|
308
|
+
});
|
|
309
|
+
updatedFields.push('participants');
|
|
310
|
+
}
|
|
275
311
|
context.state.channelDetails = await storage.getChannelDetails({
|
|
276
312
|
channelId: context.state.channelId,
|
|
277
313
|
});
|
package/dist/harness/context.js
CHANGED
|
@@ -89,15 +89,20 @@ class ChannelDetailsProvider {
|
|
|
89
89
|
async provide(state) {
|
|
90
90
|
if (!state.channelDetails)
|
|
91
91
|
return [];
|
|
92
|
-
const
|
|
93
|
-
if (!
|
|
92
|
+
const participants = state.channelDetails.participants;
|
|
93
|
+
if (!participants?.length)
|
|
94
94
|
return [];
|
|
95
|
-
|
|
95
|
+
const channelLabel = state.channelDetails.name?.trim() || state.channelDetails.id;
|
|
96
|
+
const lines = participants.map((id) => `- \`${id}\``).join('\n');
|
|
97
|
+
return [
|
|
98
|
+
{
|
|
96
99
|
id: 'channel-details',
|
|
97
100
|
type: 'channel',
|
|
98
101
|
priority: 80,
|
|
99
|
-
content:
|
|
100
|
-
|
|
102
|
+
content: `## Channel participants (${channelLabel})\n` +
|
|
103
|
+
`Agent ids collaborating in this channel:\n${lines}`,
|
|
104
|
+
},
|
|
105
|
+
];
|
|
101
106
|
}
|
|
102
107
|
}
|
|
103
108
|
class ThreadDetailsProvider {
|
package/dist/services/storage.js
CHANGED
|
@@ -262,6 +262,22 @@ const listPluginsFromDisk = async () => {
|
|
|
262
262
|
return descriptors.filter((d) => d !== null);
|
|
263
263
|
};
|
|
264
264
|
const isRecord = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
|
|
265
|
+
/** Display-oriented fields persisted in a channel's `state.json`. */
|
|
266
|
+
const readChannelStateFileFields = (parsed) => {
|
|
267
|
+
if (!isRecord(parsed)) {
|
|
268
|
+
return { participants: [] };
|
|
269
|
+
}
|
|
270
|
+
const name = typeof parsed.name === 'string' && parsed.name.trim() ? parsed.name.trim() : undefined;
|
|
271
|
+
const cwd = typeof parsed.cwd === 'string' ? parsed.cwd : undefined;
|
|
272
|
+
const participants = [];
|
|
273
|
+
if (Array.isArray(parsed.participants)) {
|
|
274
|
+
for (const x of parsed.participants) {
|
|
275
|
+
if (typeof x === 'string' && x.trim())
|
|
276
|
+
participants.push(x.trim());
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return { name, cwd, participants };
|
|
280
|
+
};
|
|
265
281
|
/**
|
|
266
282
|
* Parse the `plugins:` array from AGENT.md frontmatter. Each entry must have an
|
|
267
283
|
* `id`; `config` is optional. Strings are accepted as a shorthand for `{ id }`.
|
|
@@ -308,19 +324,25 @@ export const storageService = {
|
|
|
308
324
|
const channelDir = getConversationDir(name);
|
|
309
325
|
const statePath = path.join(channelDir, 'state.json');
|
|
310
326
|
let cwd;
|
|
327
|
+
let displayName = name;
|
|
328
|
+
let participants = [];
|
|
311
329
|
try {
|
|
312
330
|
const stateContent = await fs.readFile(statePath, 'utf-8');
|
|
313
|
-
const
|
|
314
|
-
|
|
331
|
+
const parsed = JSON.parse(stateContent);
|
|
332
|
+
const fields = readChannelStateFileFields(parsed);
|
|
333
|
+
cwd = fields.cwd;
|
|
334
|
+
displayName = fields.name ?? name;
|
|
335
|
+
participants = fields.participants;
|
|
315
336
|
}
|
|
316
337
|
catch {
|
|
317
338
|
// ignore
|
|
318
339
|
}
|
|
319
340
|
const channel = {
|
|
320
341
|
id: name,
|
|
321
|
-
name:
|
|
342
|
+
name: displayName,
|
|
322
343
|
description: '',
|
|
323
344
|
cwd,
|
|
345
|
+
participants,
|
|
324
346
|
createdAt: new Date(),
|
|
325
347
|
updatedAt: new Date(),
|
|
326
348
|
};
|
|
@@ -484,13 +506,16 @@ export const storageService = {
|
|
|
484
506
|
console.error(`Failed to read state file for channel ${channelId}`, error);
|
|
485
507
|
}
|
|
486
508
|
}
|
|
487
|
-
const
|
|
509
|
+
const diskFields = readChannelStateFileFields(state);
|
|
510
|
+
const cwd = diskFields.cwd;
|
|
511
|
+
const displayName = diskFields.name ?? channelId;
|
|
488
512
|
const details = {
|
|
489
513
|
id: channelId,
|
|
490
|
-
name:
|
|
514
|
+
name: displayName,
|
|
491
515
|
spec,
|
|
492
516
|
state,
|
|
493
517
|
cwd,
|
|
518
|
+
participants: diskFields.participants,
|
|
494
519
|
};
|
|
495
520
|
details.threads = await storageService.getThreads({ channelId });
|
|
496
521
|
return details;
|
package/package.json
CHANGED
package/src/app/cli.ts
CHANGED
package/src/app/types.ts
CHANGED
|
@@ -277,6 +277,8 @@ export type PatchChannelDetailsEvent = BaseEvent & {
|
|
|
277
277
|
state?: Record<string, unknown>;
|
|
278
278
|
spec?: string;
|
|
279
279
|
cwd?: string;
|
|
280
|
+
/** When set, replaces `state.json` `participants` (merged after `state` if both are sent). */
|
|
281
|
+
participants?: string[];
|
|
280
282
|
};
|
|
281
283
|
};
|
|
282
284
|
|
|
@@ -284,7 +286,7 @@ export type PatchChannelDetailsResultEvent = BaseEvent & {
|
|
|
284
286
|
type: 'action:patch_channel_details:result';
|
|
285
287
|
data: {
|
|
286
288
|
success: boolean;
|
|
287
|
-
updatedFields: ('state' | 'spec' | 'cwd')[];
|
|
289
|
+
updatedFields: ('state' | 'spec' | 'cwd' | 'participants')[];
|
|
288
290
|
};
|
|
289
291
|
};
|
|
290
292
|
|
|
@@ -441,6 +443,8 @@ export type CreateChannelEvent = BaseEvent & {
|
|
|
441
443
|
spec?: string;
|
|
442
444
|
initialState?: Record<string, unknown>;
|
|
443
445
|
cwd?: string;
|
|
446
|
+
/** Initial channel agent ids; written into `state.json` (overrides `initialState.participants` if both are set). */
|
|
447
|
+
participants?: string[];
|
|
444
448
|
};
|
|
445
449
|
meta?: {
|
|
446
450
|
toolCallId?: string;
|
|
@@ -464,6 +468,8 @@ export type UpdateChannelEvent = BaseEvent & {
|
|
|
464
468
|
channelId?: string;
|
|
465
469
|
name?: string;
|
|
466
470
|
cwd?: string;
|
|
471
|
+
/** Replaces the channel participant list when provided. */
|
|
472
|
+
participants?: string[];
|
|
467
473
|
};
|
|
468
474
|
};
|
|
469
475
|
|
package/src/assets/icon.svg
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
<svg width="60.2" height="58.1" viewBox="
|
|
2
|
-
<
|
|
3
|
-
|
|
1
|
+
<svg width="60.2" height="58.1" viewBox="272.584 370.297 64.635 62.51" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<style>
|
|
3
|
+
.mark { fill: #000000; }
|
|
4
|
+
@media (prefers-color-scheme: dark) {
|
|
5
|
+
.mark { fill: #ffffff; }
|
|
6
|
+
}
|
|
7
|
+
</style>
|
|
8
|
+
<path class="mark" fill="#000000" d="M301.841 380.896C302.069 380.893 302.297 380.889 302.531 380.885C304.636 380.853 306.741 380.836 308.845 380.822C310.26 380.813 311.675 380.8 313.09 380.775C314.456 380.752 315.822 380.739 317.189 380.735C317.71 380.731 318.231 380.724 318.752 380.712C322.824 380.626 322.824 380.626 323.909 381.43C324.315 382.025 324.561 382.569 324.8 383.246C324.965 383.518 325.13 383.789 325.301 384.068C325.519 384.445 325.519 384.445 325.741 384.83C325.909 385.118 326.077 385.407 326.249 385.704C326.336 385.854 326.423 386.004 326.513 386.159C328.304 389.25 330.137 392.314 332.004 395.361C332.482 396.144 332.957 396.929 333.431 397.715C333.631 398.035 333.631 398.035 333.835 398.361C334.546 399.544 334.969 400.367 334.7 401.777C334.24 402.838 333.683 403.834 333.113 404.839C332.867 405.285 332.621 405.73 332.375 406.176C332.125 406.626 331.874 407.075 331.622 407.525C330.952 408.724 330.296 409.931 329.639 411.137C329.518 411.359 329.397 411.58 329.272 411.807C328.303 413.581 327.349 415.362 326.398 417.144C324.53 420.642 322.621 424.107 320.611 427.525C320.282 428.088 319.962 428.655 319.644 429.224C319.215 429.954 319.215 429.954 318.708 430.462C317.978 430.557 317.978 430.557 317.185 430.462C316.049 429.578 315.42 428.258 314.71 427.035C313.685 425.291 312.637 423.6 311.454 421.96C311.024 421.203 310.906 420.668 310.838 419.8C311.092 419.081 311.092 419.081 311.491 418.343C311.707 417.937 311.707 417.937 311.927 417.522C312.081 417.242 312.235 416.963 312.393 416.675C312.615 416.26 312.615 416.26 312.841 415.836C314.003 413.671 314.003 413.671 314.549 412.797C315.269 411.676 315.269 411.676 315.308 410.387C314.801 409.466 314.268 408.575 313.694 407.695C313.466 407.335 313.238 406.976 313.011 406.616C312.845 406.353 312.845 406.353 312.676 406.085C312.247 405.402 311.829 404.713 311.425 404.014C311.304 403.806 311.183 403.598 311.058 403.384C310.786 402.65 310.848 402.26 311.092 401.523C311.6 401.015 311.6 401.015 312.57 400.967C312.988 400.97 313.407 400.975 313.826 400.982C314.281 400.981 314.737 400.981 315.192 400.98C315.911 400.98 316.629 400.984 317.348 400.995C318.041 401.005 318.733 401.002 319.427 400.998C319.641 401.004 319.854 401.011 320.075 401.017C320.695 401.007 321.171 400.974 321.754 400.762C322.329 400.154 322.665 399.481 323.023 398.731C323.171 398.49 323.318 398.248 323.47 398C323.899 397.287 324.326 396.573 324.752 395.859C324.904 395.608 325.056 395.357 325.212 395.099C325.355 394.859 325.498 394.618 325.646 394.371C325.841 394.045 325.841 394.045 326.04 393.713C326.38 393.138 326.38 393.138 326.323 392.385C326.167 392.384 326.011 392.383 325.85 392.383C322.054 392.368 318.257 392.349 314.461 392.325C312.625 392.313 310.789 392.303 308.953 392.297C307.352 392.291 305.752 392.282 304.152 392.271C303.305 392.265 302.458 392.26 301.61 392.258C300.664 392.256 299.719 392.249 298.773 392.241C298.351 392.241 298.351 392.241 297.921 392.242C297.663 392.238 297.406 392.235 297.14 392.232C296.916 392.231 296.693 392.23 296.462 392.228C295.73 392.109 295.379 391.879 294.846 391.369C294.591 389.978 295.187 388.999 295.837 387.818C295.938 387.63 296.038 387.441 296.142 387.246C296.464 386.646 296.789 386.049 297.115 385.451C297.333 385.045 297.551 384.638 297.769 384.231C299.545 380.925 299.545 380.925 301.841 380.896Z"/>
|
|
9
|
+
<path class="mark" fill="#000000" d="M291.476 372.547C292.795 373.009 293.243 374.055 293.942 375.218C294.23 375.684 294.519 376.15 294.807 376.615C294.945 376.84 295.082 377.065 295.223 377.297C295.544 377.813 295.875 378.314 296.225 378.811C296.388 379.044 296.551 379.277 296.718 379.518C296.856 379.711 296.994 379.903 297.137 380.102C297.492 380.97 297.407 381.615 297.131 382.485C296.704 383.459 296.209 384.39 295.703 385.325C295.497 385.714 295.497 385.714 295.287 386.111C294.44 387.702 293.559 389.255 292.565 390.759C292.217 391.585 292.351 392.026 292.562 392.892C292.955 393.665 292.955 393.665 293.466 394.431C293.555 394.572 293.644 394.713 293.736 394.858C294.019 395.304 294.305 395.748 294.592 396.192C294.971 396.778 295.346 397.365 295.719 397.953C295.886 398.212 296.053 398.471 296.225 398.738C296.646 399.535 296.848 400.115 296.877 401.015C296.559 401.435 296.559 401.435 296.115 401.777C295.364 401.849 294.663 401.877 293.911 401.871C293.467 401.876 293.023 401.88 292.579 401.885C291.879 401.887 291.18 401.888 290.48 401.888C289.804 401.888 289.129 401.895 288.453 401.903C288.244 401.901 288.036 401.899 287.82 401.897C286.637 401.91 286.637 401.91 285.616 402.466C284.844 403.543 284.229 404.69 283.598 405.854C283.455 406.11 283.312 406.365 283.165 406.628C283.031 406.873 282.897 407.118 282.76 407.371C282.637 407.594 282.515 407.818 282.389 408.048C282.071 408.656 282.071 408.656 282.408 409.392C282.559 409.393 282.71 409.394 282.865 409.395C286.539 409.416 290.213 409.439 293.886 409.465C295.663 409.478 297.439 409.49 299.216 409.499C300.929 409.509 302.642 409.521 304.356 409.534C305.011 409.539 305.665 409.543 306.32 409.546C307.235 409.55 308.15 409.557 309.064 409.565C309.473 409.566 309.473 409.566 309.89 409.567C310.139 409.57 310.388 409.573 310.644 409.576C310.861 409.577 311.077 409.578 311.3 409.58C311.854 409.646 311.854 409.646 312.615 410.154C312.797 411.581 312.41 412.577 311.745 413.808C311.656 413.979 311.567 414.15 311.475 414.326C311.288 414.685 311.099 415.042 310.908 415.399C310.616 415.946 310.329 416.495 310.042 417.045C309.859 417.394 309.676 417.743 309.492 418.092C309.363 418.337 309.363 418.337 309.231 418.588C308.881 419.242 308.574 419.78 308.046 420.308C307.364 420.361 306.707 420.382 306.024 420.382C305.815 420.383 305.606 420.385 305.391 420.387C304.698 420.392 304.005 420.392 303.312 420.393C302.832 420.395 302.351 420.396 301.871 420.398C300.862 420.401 299.854 420.402 298.845 420.402C297.552 420.402 296.259 420.409 294.966 420.417C293.973 420.423 292.98 420.424 291.987 420.424C291.51 420.424 291.034 420.427 290.557 420.431C289.89 420.436 289.224 420.434 288.557 420.431C288.36 420.434 288.163 420.437 287.959 420.44C287.061 420.429 286.569 420.386 285.852 419.824C285.47 419.314 285.137 418.817 284.831 418.259C284.718 418.056 284.605 417.852 284.488 417.643C284.367 417.423 284.246 417.203 284.121 416.976C282.907 414.808 281.638 412.679 280.329 410.566C280.156 410.286 279.982 410.006 279.803 409.717C279.469 409.176 279.134 408.636 278.799 408.096C277.871 406.592 276.959 405.077 276.062 403.554C275.968 403.409 275.874 403.264 275.777 403.114C275.143 402.097 274.834 401.442 275.046 400.254C275.425 399.337 275.889 398.475 276.363 397.604C276.568 397.22 276.568 397.22 276.777 396.828C278.005 394.541 279.284 392.283 280.569 390.029C282.224 387.119 283.868 384.197 285.327 381.184C289.509 372.654 289.509 372.654 291.476 372.547Z"/>
|
|
4
10
|
</svg>
|
package/src/bus/services.ts
CHANGED
|
@@ -226,7 +226,7 @@ export const busServicesPlugin =
|
|
|
226
226
|
});
|
|
227
227
|
|
|
228
228
|
builder.on('action:create_channel', async function* (event, context) {
|
|
229
|
-
const { channelId, spec, initialState, cwd } = (event as any).data;
|
|
229
|
+
const { channelId, spec, initialState, cwd, participants } = (event as any).data;
|
|
230
230
|
const rawChannelId = (channelId || '').trim();
|
|
231
231
|
const channelSpec = typeof spec === 'string' ? spec : '';
|
|
232
232
|
|
|
@@ -243,11 +243,22 @@ export const busServicesPlugin =
|
|
|
243
243
|
|
|
244
244
|
const channelUrl = `/channels/${rawChannelId}`;
|
|
245
245
|
|
|
246
|
+
const mergedInitial: Record<string, unknown> = { ...(initialState || {}) };
|
|
247
|
+
if (participants !== undefined) {
|
|
248
|
+
const normalized = Array.isArray(participants)
|
|
249
|
+
? participants
|
|
250
|
+
.filter((x: unknown): x is string => typeof x === 'string')
|
|
251
|
+
.map((s: string) => s.trim())
|
|
252
|
+
.filter(Boolean)
|
|
253
|
+
: [];
|
|
254
|
+
mergedInitial.participants = normalized;
|
|
255
|
+
}
|
|
256
|
+
|
|
246
257
|
try {
|
|
247
258
|
await storage.createChannel({
|
|
248
259
|
channelId: rawChannelId,
|
|
249
260
|
spec: channelSpec,
|
|
250
|
-
initialState:
|
|
261
|
+
initialState: mergedInitial,
|
|
251
262
|
cwd,
|
|
252
263
|
});
|
|
253
264
|
|
|
@@ -272,7 +283,12 @@ export const busServicesPlugin =
|
|
|
272
283
|
});
|
|
273
284
|
|
|
274
285
|
builder.on('action:update_channel', async function* (event, context) {
|
|
275
|
-
const data = (event.data || {}) as {
|
|
286
|
+
const data = (event.data || {}) as {
|
|
287
|
+
channelId?: string;
|
|
288
|
+
name?: string;
|
|
289
|
+
cwd?: string;
|
|
290
|
+
participants?: string[];
|
|
291
|
+
};
|
|
276
292
|
const targetChannelId = (data.channelId || context.state.channelId || '').trim();
|
|
277
293
|
const resultMeta = { ...(event.meta || {}), agentId: context.state.agentId };
|
|
278
294
|
|
|
@@ -296,6 +312,17 @@ export const busServicesPlugin =
|
|
|
296
312
|
patch.cwd = data.cwd.trim();
|
|
297
313
|
updatedFields.push('cwd');
|
|
298
314
|
}
|
|
315
|
+
if (data.participants !== undefined) {
|
|
316
|
+
if (Array.isArray(data.participants)) {
|
|
317
|
+
patch.participants = data.participants
|
|
318
|
+
.filter((x): x is string => typeof x === 'string')
|
|
319
|
+
.map((s) => s.trim())
|
|
320
|
+
.filter(Boolean);
|
|
321
|
+
} else {
|
|
322
|
+
patch.participants = [];
|
|
323
|
+
}
|
|
324
|
+
updatedFields.push('participants');
|
|
325
|
+
}
|
|
299
326
|
|
|
300
327
|
try {
|
|
301
328
|
if (updatedFields.length > 0) {
|
|
@@ -323,30 +350,49 @@ export const busServicesPlugin =
|
|
|
323
350
|
});
|
|
324
351
|
|
|
325
352
|
builder.on('action:patch_channel_details', async function* (event, context) {
|
|
326
|
-
const updatedFields: ('state' | 'spec' | 'cwd')[] = [];
|
|
353
|
+
const updatedFields: ('state' | 'spec' | 'cwd' | 'participants')[] = [];
|
|
327
354
|
const resultMeta = { ...(event.meta || {}), agentId: context.state.agentId };
|
|
355
|
+
const data = (event.data || {}) as {
|
|
356
|
+
state?: Record<string, unknown>;
|
|
357
|
+
spec?: string;
|
|
358
|
+
cwd?: string;
|
|
359
|
+
participants?: string[];
|
|
360
|
+
};
|
|
328
361
|
try {
|
|
329
|
-
if (
|
|
362
|
+
if (data.state !== undefined) {
|
|
330
363
|
await storage.patchChannelState({
|
|
331
364
|
channelId: context.state.channelId,
|
|
332
|
-
state:
|
|
365
|
+
state: data.state,
|
|
333
366
|
});
|
|
334
367
|
updatedFields.push('state');
|
|
335
368
|
}
|
|
336
|
-
if (typeof
|
|
369
|
+
if (typeof data.spec === 'string') {
|
|
337
370
|
await storage.patchChannelSpec({
|
|
338
371
|
channelId: context.state.channelId,
|
|
339
|
-
spec:
|
|
372
|
+
spec: data.spec,
|
|
340
373
|
});
|
|
341
374
|
updatedFields.push('spec');
|
|
342
375
|
}
|
|
343
|
-
if (typeof
|
|
376
|
+
if (typeof data.cwd === 'string') {
|
|
344
377
|
await storage.patchChannelState({
|
|
345
378
|
channelId: context.state.channelId,
|
|
346
|
-
state: { cwd:
|
|
379
|
+
state: { cwd: data.cwd },
|
|
347
380
|
});
|
|
348
381
|
updatedFields.push('cwd');
|
|
349
382
|
}
|
|
383
|
+
if (data.participants !== undefined) {
|
|
384
|
+
const normalized = Array.isArray(data.participants)
|
|
385
|
+
? data.participants
|
|
386
|
+
.filter((x): x is string => typeof x === 'string')
|
|
387
|
+
.map((s) => s.trim())
|
|
388
|
+
.filter(Boolean)
|
|
389
|
+
: [];
|
|
390
|
+
await storage.patchChannelState({
|
|
391
|
+
channelId: context.state.channelId,
|
|
392
|
+
state: { participants: normalized },
|
|
393
|
+
});
|
|
394
|
+
updatedFields.push('participants');
|
|
395
|
+
}
|
|
350
396
|
|
|
351
397
|
context.state.channelDetails = await storage.getChannelDetails({
|
|
352
398
|
channelId: context.state.channelId,
|
package/src/bus/types.ts
CHANGED
|
@@ -60,6 +60,8 @@ export type Channel = {
|
|
|
60
60
|
name: string;
|
|
61
61
|
description: string;
|
|
62
62
|
cwd?: string;
|
|
63
|
+
/** Agent ids associated with this channel (from `state.json`). */
|
|
64
|
+
participants: string[];
|
|
63
65
|
createdAt: Date;
|
|
64
66
|
updatedAt: Date;
|
|
65
67
|
hasUnseenMessages?: boolean;
|
|
@@ -87,6 +89,8 @@ export type ChannelDetails = {
|
|
|
87
89
|
spec: string;
|
|
88
90
|
state: unknown;
|
|
89
91
|
cwd?: string;
|
|
92
|
+
/** Agent ids for this channel (from `state.json`). */
|
|
93
|
+
participants: string[];
|
|
90
94
|
threads?: Thread[];
|
|
91
95
|
};
|
|
92
96
|
|
package/src/harness/context.ts
CHANGED
|
@@ -127,15 +127,24 @@ class ChannelDetailsProvider implements ContextProvider {
|
|
|
127
127
|
name = 'channel-details';
|
|
128
128
|
async provide(state: OpenBotState): Promise<ContextItem[]> {
|
|
129
129
|
if (!state.channelDetails) return [];
|
|
130
|
-
const spec = state.channelDetails.spec?.trim();
|
|
131
|
-
if (!spec) return [];
|
|
132
130
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
131
|
+
const participants = state.channelDetails.participants;
|
|
132
|
+
if (!participants?.length) return [];
|
|
133
|
+
|
|
134
|
+
const channelLabel =
|
|
135
|
+
state.channelDetails.name?.trim() || state.channelDetails.id;
|
|
136
|
+
const lines = participants.map((id) => `- \`${id}\``).join('\n');
|
|
137
|
+
|
|
138
|
+
return [
|
|
139
|
+
{
|
|
140
|
+
id: 'channel-details',
|
|
141
|
+
type: 'channel',
|
|
142
|
+
priority: 80,
|
|
143
|
+
content:
|
|
144
|
+
`## Channel participants (${channelLabel})\n` +
|
|
145
|
+
`Agent ids collaborating in this channel:\n${lines}`,
|
|
146
|
+
},
|
|
147
|
+
];
|
|
139
148
|
}
|
|
140
149
|
}
|
|
141
150
|
|
package/src/services/storage.ts
CHANGED
|
@@ -316,6 +316,25 @@ const listPluginsFromDisk = async (): Promise<PluginDescriptor[]> => {
|
|
|
316
316
|
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
317
317
|
!!value && typeof value === 'object' && !Array.isArray(value);
|
|
318
318
|
|
|
319
|
+
/** Display-oriented fields persisted in a channel's `state.json`. */
|
|
320
|
+
const readChannelStateFileFields = (
|
|
321
|
+
parsed: unknown,
|
|
322
|
+
): { name?: string; cwd?: string; participants: string[] } => {
|
|
323
|
+
if (!isRecord(parsed)) {
|
|
324
|
+
return { participants: [] };
|
|
325
|
+
}
|
|
326
|
+
const name =
|
|
327
|
+
typeof parsed.name === 'string' && parsed.name.trim() ? parsed.name.trim() : undefined;
|
|
328
|
+
const cwd = typeof parsed.cwd === 'string' ? parsed.cwd : undefined;
|
|
329
|
+
const participants: string[] = [];
|
|
330
|
+
if (Array.isArray(parsed.participants)) {
|
|
331
|
+
for (const x of parsed.participants) {
|
|
332
|
+
if (typeof x === 'string' && x.trim()) participants.push(x.trim());
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return { name, cwd, participants };
|
|
336
|
+
};
|
|
337
|
+
|
|
319
338
|
/**
|
|
320
339
|
* Parse the `plugins:` array from AGENT.md frontmatter. Each entry must have an
|
|
321
340
|
* `id`; `config` is optional. Strings are accepted as a shorthand for `{ id }`.
|
|
@@ -376,20 +395,26 @@ export const storageService = {
|
|
|
376
395
|
const channelDir = getConversationDir(name);
|
|
377
396
|
const statePath = path.join(channelDir, 'state.json');
|
|
378
397
|
let cwd: string | undefined;
|
|
398
|
+
let displayName = name;
|
|
399
|
+
let participants: string[] = [];
|
|
379
400
|
|
|
380
401
|
try {
|
|
381
402
|
const stateContent = await fs.readFile(statePath, 'utf-8');
|
|
382
|
-
const
|
|
383
|
-
|
|
403
|
+
const parsed = JSON.parse(stateContent);
|
|
404
|
+
const fields = readChannelStateFileFields(parsed);
|
|
405
|
+
cwd = fields.cwd;
|
|
406
|
+
displayName = fields.name ?? name;
|
|
407
|
+
participants = fields.participants;
|
|
384
408
|
} catch {
|
|
385
409
|
// ignore
|
|
386
410
|
}
|
|
387
411
|
|
|
388
412
|
const channel: Channel = {
|
|
389
413
|
id: name,
|
|
390
|
-
name:
|
|
414
|
+
name: displayName,
|
|
391
415
|
description: '',
|
|
392
416
|
cwd,
|
|
417
|
+
participants,
|
|
393
418
|
createdAt: new Date(),
|
|
394
419
|
updatedAt: new Date(),
|
|
395
420
|
};
|
|
@@ -610,14 +635,17 @@ export const storageService = {
|
|
|
610
635
|
}
|
|
611
636
|
}
|
|
612
637
|
|
|
613
|
-
const
|
|
638
|
+
const diskFields = readChannelStateFileFields(state);
|
|
639
|
+
const cwd = diskFields.cwd;
|
|
640
|
+
const displayName = diskFields.name ?? channelId;
|
|
614
641
|
|
|
615
642
|
const details: ChannelDetails = {
|
|
616
643
|
id: channelId,
|
|
617
|
-
name:
|
|
644
|
+
name: displayName,
|
|
618
645
|
spec,
|
|
619
646
|
state,
|
|
620
647
|
cwd,
|
|
648
|
+
participants: diskFields.participants,
|
|
621
649
|
};
|
|
622
650
|
|
|
623
651
|
details.threads = await storageService.getThreads({ channelId });
|