@meetopenbot/openbot 0.1.7 → 0.1.9
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/context.js +2 -0
- package/dist/credits-auth.d.ts +1 -1
- package/dist/credits-auth.js +2 -0
- package/dist/model-registry.js +3 -1
- package/dist/model.js +12 -5
- package/dist/runtime.js +10 -3
- package/dist/tools/delegation.d.ts +1 -1
- package/dist/tools/delegation.js +30 -23
- package/dist/types.d.ts +12 -13
- package/dist/types.js +1 -1
- package/package.json +1 -1
package/dist/context.js
CHANGED
|
@@ -16,6 +16,8 @@ export const getContextBudgetForModel = (modelString) => {
|
|
|
16
16
|
'anthropic/claude-3-opus-20240229': 200000,
|
|
17
17
|
'anthropic/claude-3-sonnet-20240229': 200000,
|
|
18
18
|
'anthropic/claude-3-haiku-20240307': 200000,
|
|
19
|
+
'deepseek/deepseek-chat': 64000,
|
|
20
|
+
'deepseek/deepseek-reasoner': 64000,
|
|
19
21
|
};
|
|
20
22
|
return budgets[modelString] || DEFAULT_CONTEXT_BUDGET;
|
|
21
23
|
};
|
package/dist/credits-auth.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export interface CreditsAuthConfig {
|
|
|
5
5
|
baseUrl: string;
|
|
6
6
|
token: string;
|
|
7
7
|
}
|
|
8
|
-
export type CreditsProviderId = 'openai' | 'anthropic';
|
|
8
|
+
export type CreditsProviderId = 'openai' | 'anthropic' | 'google' | 'deepseek';
|
|
9
9
|
/** Cloud host injects these when routing LLM calls through OpenBot Credits. */
|
|
10
10
|
export declare function resolveCreditsAuthConfig(): CreditsAuthConfig | undefined;
|
|
11
11
|
export declare function creditsProviderBaseUrl(config: CreditsAuthConfig, provider: CreditsProviderId): string;
|
package/dist/credits-auth.js
CHANGED
|
@@ -4,6 +4,8 @@ export const CREDITS_API_KEY_PLACEHOLDER = 'openbot-credits';
|
|
|
4
4
|
const CREDITS_PROVIDER_PATHS = {
|
|
5
5
|
openai: 'openai/v1',
|
|
6
6
|
anthropic: 'anthropic/v1',
|
|
7
|
+
google: 'google/v1',
|
|
8
|
+
deepseek: 'deepseek/v1',
|
|
7
9
|
};
|
|
8
10
|
/** Cloud host injects these when routing LLM calls through OpenBot Credits. */
|
|
9
11
|
export function resolveCreditsAuthConfig() {
|
package/dist/model-registry.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
const DEFAULT_REGISTRY_URL = 'https://raw.githubusercontent.com/meetopenbot/openbot-registry/main/registry.json';
|
|
2
|
-
const API_KEY_PROVIDER_IDS = ['openai', 'anthropic', 'google'];
|
|
2
|
+
const API_KEY_PROVIDER_IDS = ['openai', 'anthropic', 'google', 'deepseek'];
|
|
3
3
|
export const PROVIDER_API_KEY_LINKS = {
|
|
4
4
|
openai: 'https://platform.openai.com/api-keys',
|
|
5
5
|
anthropic: 'https://console.anthropic.com/settings/keys',
|
|
6
6
|
google: 'https://aistudio.google.com/app/apikey',
|
|
7
|
+
deepseek: 'https://platform.deepseek.com/api_keys',
|
|
7
8
|
};
|
|
8
9
|
const FALLBACK_PROVIDERS = [
|
|
9
10
|
{ id: 'openai', label: 'OpenAI' },
|
|
10
11
|
{ id: 'anthropic', label: 'Anthropic' },
|
|
11
12
|
{ id: 'google', label: 'Google' },
|
|
13
|
+
{ id: 'deepseek', label: 'DeepSeek' },
|
|
12
14
|
];
|
|
13
15
|
let cachedRegistry;
|
|
14
16
|
export async function fetchModelRegistry() {
|
package/dist/model.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { createOpenAI, openai as defaultOpenai } from '@ai-sdk/openai';
|
|
2
2
|
import { createAnthropic, anthropic } from '@ai-sdk/anthropic';
|
|
3
|
-
import { google } from '@ai-sdk/google';
|
|
3
|
+
import { createGoogleGenerativeAI, google } from '@ai-sdk/google';
|
|
4
4
|
import { CREDITS_API_KEY_PLACEHOLDER, INTEGRATIONS_TOKEN_HEADER, creditsProviderBaseUrl, resolveCreditsAuthConfig, shouldUseCreditsAuth, } from './credits-auth.js';
|
|
5
|
+
const defaultDeepseek = createOpenAI({
|
|
6
|
+
baseURL: 'https://api.deepseek.com',
|
|
7
|
+
apiKey: process.env.DEEPSEEK_API_KEY,
|
|
8
|
+
});
|
|
5
9
|
function resolveCreditsProvider(provider, modelId) {
|
|
6
10
|
const config = resolveCreditsAuthConfig();
|
|
7
11
|
if (!config) {
|
|
@@ -16,6 +20,10 @@ function resolveCreditsProvider(provider, modelId) {
|
|
|
16
20
|
return createOpenAI({ baseURL, apiKey, headers })(modelId);
|
|
17
21
|
case 'anthropic':
|
|
18
22
|
return createAnthropic({ baseURL, apiKey, headers })(modelId);
|
|
23
|
+
case 'google':
|
|
24
|
+
return createGoogleGenerativeAI({ baseURL, apiKey, headers })(modelId);
|
|
25
|
+
case 'deepseek':
|
|
26
|
+
return createOpenAI({ baseURL, apiKey, headers })(modelId);
|
|
19
27
|
}
|
|
20
28
|
}
|
|
21
29
|
export function resolveModel(modelString, options) {
|
|
@@ -31,10 +39,9 @@ export function resolveModel(modelString, options) {
|
|
|
31
39
|
case 'anthropic':
|
|
32
40
|
return useCredits ? resolveCreditsProvider('anthropic', modelId) : anthropic(modelId);
|
|
33
41
|
case 'google':
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return google(modelId);
|
|
42
|
+
return useCredits ? resolveCreditsProvider('google', modelId) : google(modelId);
|
|
43
|
+
case 'deepseek':
|
|
44
|
+
return useCredits ? resolveCreditsProvider('deepseek', modelId) : defaultDeepseek(modelId);
|
|
38
45
|
default:
|
|
39
46
|
throw new Error(`Unsupported AI provider: "${provider}"`);
|
|
40
47
|
}
|
package/dist/runtime.js
CHANGED
|
@@ -313,7 +313,9 @@ export const openbotRuntime = (options) => (builder) => {
|
|
|
313
313
|
? 'gpt-4o-mini'
|
|
314
314
|
: provider === 'anthropic'
|
|
315
315
|
? 'claude-3-5-sonnet-20241022'
|
|
316
|
-
: '
|
|
316
|
+
: provider === 'deepseek'
|
|
317
|
+
? 'deepseek-chat'
|
|
318
|
+
: 'gemini-2.0-flash',
|
|
317
319
|
required: true,
|
|
318
320
|
defaultValue: currentModelId || '',
|
|
319
321
|
},
|
|
@@ -395,7 +397,10 @@ export const openbotRuntime = (options) => (builder) => {
|
|
|
395
397
|
if (!modelId)
|
|
396
398
|
return;
|
|
397
399
|
const apiKey = String(values.apiKey);
|
|
398
|
-
if (provider !== 'openai' &&
|
|
400
|
+
if (provider !== 'openai' &&
|
|
401
|
+
provider !== 'anthropic' &&
|
|
402
|
+
provider !== 'google' &&
|
|
403
|
+
provider !== 'deepseek') {
|
|
399
404
|
yield {
|
|
400
405
|
type: 'agent:output',
|
|
401
406
|
data: { content: `Unsupported provider: ${provider}` },
|
|
@@ -407,7 +412,9 @@ export const openbotRuntime = (options) => (builder) => {
|
|
|
407
412
|
? 'OPENAI_API_KEY'
|
|
408
413
|
: provider === 'anthropic'
|
|
409
414
|
? 'ANTHROPIC_API_KEY'
|
|
410
|
-
: '
|
|
415
|
+
: provider === 'deepseek'
|
|
416
|
+
? 'DEEPSEEK_API_KEY'
|
|
417
|
+
: 'GOOGLE_GENERATIVE_AI_API_KEY';
|
|
411
418
|
const newModelString = `${provider}/${modelId}`;
|
|
412
419
|
if (!storage)
|
|
413
420
|
return;
|
package/dist/tools/delegation.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { randomUUID } from
|
|
2
|
-
import { z } from
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { z } from "zod";
|
|
3
3
|
/**
|
|
4
4
|
* `delegation` — allows agents to delegate tasks to other agents.
|
|
5
5
|
*
|
|
@@ -9,29 +9,33 @@ import { z } from 'zod';
|
|
|
9
9
|
*/
|
|
10
10
|
const delegationToolDefinitions = {
|
|
11
11
|
delegate_task: {
|
|
12
|
-
description:
|
|
12
|
+
description: "Delegate a specific task or question to another specialized agent.",
|
|
13
13
|
inputSchema: z.object({
|
|
14
|
-
agentId: z
|
|
15
|
-
|
|
14
|
+
agentId: z
|
|
15
|
+
.string()
|
|
16
|
+
.describe('The ID of the agent to delegate to (e.g., "researcher", "coder").'),
|
|
17
|
+
prompt: z
|
|
18
|
+
.string()
|
|
19
|
+
.describe("The instructions or question for the delegated agent."),
|
|
16
20
|
}),
|
|
17
21
|
},
|
|
18
22
|
};
|
|
19
23
|
export const delegationPlugin = {
|
|
20
|
-
id:
|
|
21
|
-
name:
|
|
22
|
-
description:
|
|
24
|
+
id: "delegation",
|
|
25
|
+
name: "Delegation",
|
|
26
|
+
description: "Allows agents to call upon other agents to solve sub-tasks.",
|
|
23
27
|
toolDefinitions: delegationToolDefinitions,
|
|
24
28
|
factory: (pluginContext) => (builder) => {
|
|
25
29
|
// Handle the tool execution
|
|
26
|
-
builder.on(
|
|
30
|
+
builder.on("action:delegate_task", async function* (event, context) {
|
|
27
31
|
const delegateEvent = event;
|
|
28
32
|
// POLICY: Only the 'system' agent can delegate
|
|
29
33
|
if (context.state.agentId !== pluginContext.host.orchestratorAgentId) {
|
|
30
34
|
yield {
|
|
31
|
-
type:
|
|
35
|
+
type: "action:delegate_task:result",
|
|
32
36
|
data: {
|
|
33
37
|
success: false,
|
|
34
|
-
error:
|
|
38
|
+
error: "Only the system agent can delegate.",
|
|
35
39
|
},
|
|
36
40
|
meta: delegateEvent.meta,
|
|
37
41
|
};
|
|
@@ -43,7 +47,7 @@ export const delegationPlugin = {
|
|
|
43
47
|
return;
|
|
44
48
|
const runAgent = pluginContext.host.runAgent;
|
|
45
49
|
const runId = `dg_${randomUUID()}`;
|
|
46
|
-
let lastAgentOutput =
|
|
50
|
+
let lastAgentOutput = "";
|
|
47
51
|
// Queue to bridge the async onEvent callback to this generator
|
|
48
52
|
const eventQueue = [];
|
|
49
53
|
let resolveNext = null;
|
|
@@ -54,20 +58,19 @@ export const delegationPlugin = {
|
|
|
54
58
|
runId,
|
|
55
59
|
agentId,
|
|
56
60
|
event: {
|
|
57
|
-
type:
|
|
61
|
+
type: "agent:invoke",
|
|
58
62
|
data: {
|
|
59
|
-
role:
|
|
63
|
+
role: "user",
|
|
60
64
|
content: prompt,
|
|
61
65
|
agentId: agentId,
|
|
62
66
|
},
|
|
63
67
|
meta: {
|
|
68
|
+
channelId: context.state.channelId,
|
|
64
69
|
threadId: context.state.threadId,
|
|
65
70
|
parentAgentId: context.state.agentId,
|
|
66
71
|
parentToolCallId: toolCallId,
|
|
67
72
|
},
|
|
68
73
|
},
|
|
69
|
-
channelId: context.state.channelId,
|
|
70
|
-
threadId: context.state.threadId,
|
|
71
74
|
publicBaseUrl: pluginContext.publicBaseUrl,
|
|
72
75
|
// Child events are re-yielded to the parent harness, which persists them once.
|
|
73
76
|
persistEvents: false,
|
|
@@ -79,10 +82,10 @@ export const delegationPlugin = {
|
|
|
79
82
|
...outEvent.meta,
|
|
80
83
|
parentAgentId: context.state.agentId,
|
|
81
84
|
parentToolCallId: toolCallId,
|
|
82
|
-
}
|
|
85
|
+
},
|
|
83
86
|
};
|
|
84
87
|
eventQueue.push(enrichedEvent);
|
|
85
|
-
if (outEvent.type ===
|
|
88
|
+
if (outEvent.type === "agent:output") {
|
|
86
89
|
lastAgentOutput = outEvent.data.content;
|
|
87
90
|
}
|
|
88
91
|
// Wake up the generator loop if it's waiting
|
|
@@ -90,10 +93,12 @@ export const delegationPlugin = {
|
|
|
90
93
|
resolveNext();
|
|
91
94
|
resolveNext = null;
|
|
92
95
|
}
|
|
93
|
-
}
|
|
94
|
-
})
|
|
96
|
+
},
|
|
97
|
+
})
|
|
98
|
+
.catch((error) => {
|
|
95
99
|
console.error(`[delegation] Error in delegated run ${runId}:`, error);
|
|
96
|
-
})
|
|
100
|
+
})
|
|
101
|
+
.finally(() => {
|
|
97
102
|
isFinished = true;
|
|
98
103
|
if (resolveNext) {
|
|
99
104
|
resolveNext();
|
|
@@ -103,7 +108,9 @@ export const delegationPlugin = {
|
|
|
103
108
|
// Yield events from the delegated agent as they arrive
|
|
104
109
|
while (!isFinished || eventQueue.length > 0) {
|
|
105
110
|
if (eventQueue.length === 0) {
|
|
106
|
-
await new Promise(r => {
|
|
111
|
+
await new Promise((r) => {
|
|
112
|
+
resolveNext = r;
|
|
113
|
+
});
|
|
107
114
|
}
|
|
108
115
|
while (eventQueue.length > 0) {
|
|
109
116
|
yield eventQueue.shift();
|
|
@@ -113,7 +120,7 @@ export const delegationPlugin = {
|
|
|
113
120
|
await runPromise;
|
|
114
121
|
// Yield the result back to our own LLM runtime.
|
|
115
122
|
yield {
|
|
116
|
-
type:
|
|
123
|
+
type: "action:delegate_task:result",
|
|
117
124
|
data: {
|
|
118
125
|
success: true,
|
|
119
126
|
output: lastAgentOutput,
|
package/dist/types.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { Plugin as SdkPlugin, PluginContext as SdkPluginContext, OpenBotState as SdkOpenBotState, ToolActionEvent, PluginFactory as SdkPluginFactory, PluginBuilder, PluginHandlerContext, OpenBotEvent } from
|
|
2
|
-
export { definePlugin } from
|
|
3
|
-
export type { AgentInvokeEvent, AgentOutputEvent, ConfigSchema, OpenBotEvent, PluginBuilder, PluginFactory, PluginHandlerContext, Storage, ToolDefinition, ToolActionEvent, UIWidgetListItem, UIWidgetResponseEvent, } from
|
|
4
|
-
export type MemoryScopeAlias =
|
|
1
|
+
import type { Plugin as SdkPlugin, PluginContext as SdkPluginContext, OpenBotState as SdkOpenBotState, ToolActionEvent, PluginFactory as SdkPluginFactory, PluginBuilder, PluginHandlerContext, OpenBotEvent } from "@meetopenbot/plugin-sdk";
|
|
2
|
+
export { definePlugin } from "@meetopenbot/plugin-sdk";
|
|
3
|
+
export type { AgentInvokeEvent, AgentOutputEvent, ConfigSchema, OpenBotEvent, PluginBuilder, PluginFactory, PluginHandlerContext, Storage, ToolDefinition, ToolActionEvent, UIWidgetListItem, UIWidgetResponseEvent, } from "@meetopenbot/plugin-sdk";
|
|
4
|
+
export type MemoryScopeAlias = "global" | "agent" | "channel";
|
|
5
5
|
export type DelegateTaskEvent = ToolActionEvent<{
|
|
6
6
|
agentId: string;
|
|
7
7
|
prompt: string;
|
|
8
8
|
}> & {
|
|
9
|
-
type:
|
|
9
|
+
type: "action:delegate_task";
|
|
10
10
|
};
|
|
11
11
|
export type RenderWidgetEvent = ToolActionEvent<Record<string, unknown>> & {
|
|
12
|
-
type:
|
|
12
|
+
type: "action:render_widget";
|
|
13
13
|
};
|
|
14
14
|
/** Runtime state extends the SDK with fields used by the OpenBot agent plugin. */
|
|
15
15
|
export type OpenBotState = SdkOpenBotState & {
|
|
@@ -18,7 +18,7 @@ export type OpenBotState = SdkOpenBotState & {
|
|
|
18
18
|
userName?: string;
|
|
19
19
|
};
|
|
20
20
|
pendingToolCallIds?: string[];
|
|
21
|
-
threadDetails?: SdkOpenBotState[
|
|
21
|
+
threadDetails?: SdkOpenBotState["threadDetails"] & {
|
|
22
22
|
name?: string;
|
|
23
23
|
};
|
|
24
24
|
};
|
|
@@ -32,25 +32,24 @@ export type ActionBuilder = {
|
|
|
32
32
|
};
|
|
33
33
|
export declare function asActionBuilder(builder: PluginBuilder): ActionBuilder;
|
|
34
34
|
export interface PluginHost {
|
|
35
|
+
/** Run context (channelId, threadId) is passed on `event.meta`, not as top-level options. */
|
|
35
36
|
runAgent: (options: {
|
|
36
37
|
runId: string;
|
|
37
38
|
agentId: string;
|
|
38
39
|
event: OpenBotEvent;
|
|
39
|
-
channelId: string;
|
|
40
|
-
threadId?: string;
|
|
41
40
|
persistEvents?: boolean;
|
|
42
41
|
publicBaseUrl?: string;
|
|
43
42
|
onEvent: (event: OpenBotEvent, state?: OpenBotState) => Promise<void>;
|
|
44
43
|
}) => Promise<void>;
|
|
45
44
|
isCloudSystemAgent: (agentId: string) => boolean;
|
|
46
45
|
isCloudMode: () => boolean;
|
|
47
|
-
parseOpenbotAuthMode: (value: unknown) =>
|
|
46
|
+
parseOpenbotAuthMode: (value: unknown) => "credits" | "byok";
|
|
48
47
|
saveConfig: (patch: Record<string, unknown>) => void;
|
|
49
48
|
getBaseDir: () => string;
|
|
50
49
|
resolvePath: (p: string) => string;
|
|
51
50
|
orchestratorAgentId: string;
|
|
52
51
|
openbotPluginId: string;
|
|
53
|
-
defaultCloudAuthMode:
|
|
52
|
+
defaultCloudAuthMode: "credits" | "byok";
|
|
54
53
|
}
|
|
55
54
|
/** Host context extends the SDK with OpenBot runtime wiring. */
|
|
56
55
|
export interface PluginContext extends SdkPluginContext {
|
|
@@ -58,8 +57,8 @@ export interface PluginContext extends SdkPluginContext {
|
|
|
58
57
|
abortSignal?: AbortSignal;
|
|
59
58
|
host: PluginHost;
|
|
60
59
|
}
|
|
61
|
-
export interface Plugin extends Omit<SdkPlugin,
|
|
62
|
-
configSchema?: SdkPlugin[
|
|
60
|
+
export interface Plugin extends Omit<SdkPlugin, "factory" | "configSchema"> {
|
|
61
|
+
configSchema?: SdkPlugin["configSchema"] | Record<string, unknown>;
|
|
63
62
|
factory: (context: PluginContext) => SdkPluginFactory;
|
|
64
63
|
}
|
|
65
64
|
/** Type-safe plugin definition for the extended OpenBot host context. */
|
package/dist/types.js
CHANGED