@meetopenbot/openbot 1.1.1 → 1.2.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/build-tools.js +3 -2
- package/dist/tools/storage.js +87 -0
- package/package.json +2 -2
package/dist/build-tools.js
CHANGED
|
@@ -7,6 +7,7 @@ import { startWorkTools } from "./tools/start-work.js";
|
|
|
7
7
|
import { threadStatusTools } from "./tools/thread-status.js";
|
|
8
8
|
import { threadTitleTools } from "./tools/thread-title.js";
|
|
9
9
|
import { wrapToolsWithApproval } from "./tools/approval.js";
|
|
10
|
+
export const DEFAULT_APPROVAL_ACTIONS = ["update_channel_spec"];
|
|
10
11
|
/** Always gated: installing an agent changes the workspace. */
|
|
11
12
|
const ALWAYS_APPROVE = ["install_agent"];
|
|
12
13
|
/**
|
|
@@ -25,6 +26,6 @@ export function buildOpenbotTools(args) {
|
|
|
25
26
|
...threadTitleTools,
|
|
26
27
|
...args.context.tools,
|
|
27
28
|
};
|
|
28
|
-
const approvalConfig = args.context.config?.approval
|
|
29
|
-
return wrapToolsWithApproval(tools, [...new Set([...ALWAYS_APPROVE, ...(approvalConfig
|
|
29
|
+
const approvalConfig = args.context.config?.approval;
|
|
30
|
+
return wrapToolsWithApproval(tools, [...new Set([...ALWAYS_APPROVE, ...(approvalConfig?.actions ?? DEFAULT_APPROVAL_ACTIONS)])], args.context);
|
|
30
31
|
}
|
package/dist/tools/storage.js
CHANGED
|
@@ -53,6 +53,22 @@ export const storageTools = {
|
|
|
53
53
|
const { channelId, name, spec, initialState } = (raw ?? {});
|
|
54
54
|
const rawChannelId = normalizeChannelId(channelId || '');
|
|
55
55
|
const widgetId = ctx.toolCallId ?? `create_channel:${rawChannelId || Date.now()}`;
|
|
56
|
+
if (ctx.agentId !== ctx.host.orchestratorAgentId) {
|
|
57
|
+
const error = 'Only OpenBot can create Spaces.';
|
|
58
|
+
await emitCreateChannelWidget(ctx, {
|
|
59
|
+
widgetId,
|
|
60
|
+
channelId: rawChannelId,
|
|
61
|
+
body: error,
|
|
62
|
+
state: 'error',
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
success: false,
|
|
66
|
+
channelId: rawChannelId,
|
|
67
|
+
channelUrl: '',
|
|
68
|
+
error,
|
|
69
|
+
output: error,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
56
72
|
if (!rawChannelId) {
|
|
57
73
|
const error = 'channelId is required';
|
|
58
74
|
await emitCreateChannelWidget(ctx, {
|
|
@@ -131,6 +147,77 @@ export const storageTools = {
|
|
|
131
147
|
}
|
|
132
148
|
},
|
|
133
149
|
},
|
|
150
|
+
update_channel_spec: {
|
|
151
|
+
description: 'Replace an existing Space spec with new markdown only when the human explicitly asked for the update or agreed to it.',
|
|
152
|
+
inputSchema: z.object({
|
|
153
|
+
channelId: z.string().describe('Existing Space id whose spec should be replaced.'),
|
|
154
|
+
spec: z.string().describe('Complete replacement markdown for the Space spec.'),
|
|
155
|
+
}),
|
|
156
|
+
execute: async (raw, ctx) => {
|
|
157
|
+
const { channelId, spec } = (raw ?? {});
|
|
158
|
+
const normalizedChannelId = normalizeChannelId(channelId || '');
|
|
159
|
+
if (ctx.agentId !== ctx.host.orchestratorAgentId) {
|
|
160
|
+
const error = 'Only OpenBot can update Space specs.';
|
|
161
|
+
return {
|
|
162
|
+
success: false,
|
|
163
|
+
channelId: normalizedChannelId,
|
|
164
|
+
error,
|
|
165
|
+
output: error,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
if (!normalizedChannelId) {
|
|
169
|
+
const error = 'channelId is required';
|
|
170
|
+
return { success: false, channelId: '', error, output: error };
|
|
171
|
+
}
|
|
172
|
+
if (isPlaceholderSpaceId(normalizedChannelId)) {
|
|
173
|
+
const error = `Refused to update #${normalizedChannelId}: that looks like a placeholder, not a real Space.`;
|
|
174
|
+
return {
|
|
175
|
+
success: false,
|
|
176
|
+
channelId: normalizedChannelId,
|
|
177
|
+
error,
|
|
178
|
+
output: error,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
if (typeof spec !== 'string') {
|
|
182
|
+
const error = 'spec is required';
|
|
183
|
+
return {
|
|
184
|
+
success: false,
|
|
185
|
+
channelId: normalizedChannelId,
|
|
186
|
+
error,
|
|
187
|
+
output: error,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
try {
|
|
191
|
+
const channels = await ctx.storage.getChannels();
|
|
192
|
+
const exists = channels.some((channel) => channel.id === normalizedChannelId);
|
|
193
|
+
if (!exists) {
|
|
194
|
+
const error = `Space #${normalizedChannelId} does not exist.`;
|
|
195
|
+
return {
|
|
196
|
+
success: false,
|
|
197
|
+
channelId: normalizedChannelId,
|
|
198
|
+
error,
|
|
199
|
+
output: error,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
await ctx.storage.patchChannelSpec({
|
|
203
|
+
channelId: normalizedChannelId,
|
|
204
|
+
spec,
|
|
205
|
+
});
|
|
206
|
+
const output = `Updated the spec for Space #${normalizedChannelId}.`;
|
|
207
|
+
return { success: true, channelId: normalizedChannelId, output };
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
211
|
+
const output = `Failed to update the spec for Space #${normalizedChannelId}: ${message}`;
|
|
212
|
+
return {
|
|
213
|
+
success: false,
|
|
214
|
+
channelId: normalizedChannelId,
|
|
215
|
+
error: message,
|
|
216
|
+
output,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
},
|
|
134
221
|
};
|
|
135
222
|
export const tools = storageTools;
|
|
136
223
|
export const storageToolPlugin = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meetopenbot/openbot",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "OpenBot coordinator runtime: ask specialists, route work into Spaces, and track todos.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@ai-sdk/openai": "^4.0.46",
|
|
26
26
|
"ai": "^7.0.77",
|
|
27
27
|
"zod": "^4.3.5",
|
|
28
|
-
"@meetopenbot/plugin-sdk": "^1.0
|
|
28
|
+
"@meetopenbot/plugin-sdk": "^1.1.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^20.10.1",
|