@uibot/agents 0.0.0-stage → 0.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/agent-fs-source.d.ts +11 -0
- package/dist/agent-loader.d.ts +13 -0
- package/dist/agent-registry.d.ts +12 -0
- package/dist/context-tools.d.ts +23 -0
- package/dist/create-agent.d.ts +33 -0
- package/dist/execution-tools.d.ts +30 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +1520 -0
- package/dist/model-factory.d.ts +41 -0
- package/dist/playground-tools.d.ts +2 -0
- package/dist/run-agent.d.ts +43 -0
- package/dist/skill-registry.d.ts +21 -0
- package/dist/types.d.ts +38 -0
- package/package.json +47 -4
- package/README.md +0 -3
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ChatOpenAI } from "@langchain/openai";
|
|
2
|
+
/**
|
|
3
|
+
* Per-model routing target. Any field left out keeps the factory-level default,
|
|
4
|
+
* so a caller can override just the baseURL of one provider without restating
|
|
5
|
+
* the shared apiKey.
|
|
6
|
+
*/
|
|
7
|
+
export interface ResolvedModelTarget {
|
|
8
|
+
/** Canonical model id, allowing the caller to resolve an alias. */
|
|
9
|
+
modelId?: string;
|
|
10
|
+
/**
|
|
11
|
+
* `null` states that this model's provider has no key of its own. It is not
|
|
12
|
+
* the same as omitting the field, which inherits the factory-level key —
|
|
13
|
+
* inheriting would mail one provider's key to another provider's endpoint.
|
|
14
|
+
*/
|
|
15
|
+
apiKey?: string | null;
|
|
16
|
+
baseURL?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ModelFactoryOptions {
|
|
19
|
+
/** API key for the model provider. Falls back to OPENAI_API_KEY env var. */
|
|
20
|
+
apiKey?: string;
|
|
21
|
+
/** Base URL for OpenAI-compatible endpoints (e.g. DashScope). Falls back to OPENAI_BASE_URL env var. */
|
|
22
|
+
baseURL?: string;
|
|
23
|
+
/** Default model ID when the agent has no defaultModel specified. */
|
|
24
|
+
defaultModelId?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Routes a model id to the provider that actually serves it. Returning
|
|
27
|
+
* `null` (or omitting the option) keeps the factory-level apiKey/baseURL,
|
|
28
|
+
* which is what a single-provider deployment wants.
|
|
29
|
+
*/
|
|
30
|
+
resolveModel?: (modelId: string) => ResolvedModelTarget | null | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Extra request-body params merged into every completion (LangChain
|
|
33
|
+
* `modelKwargs`). Used to carry provider-specific flags such as DeepSeek's
|
|
34
|
+
* `{ thinking: { type: "disabled" } }` — required for reasoning models in
|
|
35
|
+
* multi-turn tool loops, where LangChain cannot replay `reasoning_content`
|
|
36
|
+
* back to the API and the provider would otherwise 400.
|
|
37
|
+
*/
|
|
38
|
+
modelKwargs?: Record<string, unknown>;
|
|
39
|
+
}
|
|
40
|
+
export type ModelFactory = (modelId: string) => ChatOpenAI;
|
|
41
|
+
export declare function createModelFactory(options?: ModelFactoryOptions): ModelFactory;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type AgentMessageContent, type ExecutionRuntime, type PlaygroundProjectContext } from "@uibot/contracts";
|
|
2
|
+
import type { UIBotAgentRegistry } from "./agent-registry.js";
|
|
3
|
+
import type { UIBotSkillRegistry } from "./skill-registry.js";
|
|
4
|
+
import type { ModelFactory } from "./model-factory.js";
|
|
5
|
+
import type { AgentStreamEvent } from "./types.js";
|
|
6
|
+
import { type CreateExecutionToolsOptions } from "./execution-tools.js";
|
|
7
|
+
export interface RunAgentInput {
|
|
8
|
+
agentId: string;
|
|
9
|
+
messages: Array<{
|
|
10
|
+
role: "user" | "assistant" | "system";
|
|
11
|
+
content: AgentMessageContent;
|
|
12
|
+
}>;
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
/** Playground mode: custom system prompt bypasses agent definition's prompt. */
|
|
15
|
+
systemPrompt?: string;
|
|
16
|
+
/** Extra prompt context appended without bypassing registry skill selection. */
|
|
17
|
+
additionalContext?: string;
|
|
18
|
+
/** Playground mode: project context used to create get_entity/api/page tools. */
|
|
19
|
+
projectContext?: PlaygroundProjectContext;
|
|
20
|
+
/** Playground mode: model ID passed to modelFactory. */
|
|
21
|
+
modelId?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface RunAgentOptions {
|
|
24
|
+
agentRegistry: UIBotAgentRegistry;
|
|
25
|
+
skillRegistry?: UIBotSkillRegistry;
|
|
26
|
+
/** Required when RunAgentInput.systemPrompt is used (playground mode). */
|
|
27
|
+
modelFactory?: ModelFactory;
|
|
28
|
+
craftResolver?: (slug: string) => {
|
|
29
|
+
title: string;
|
|
30
|
+
body: string;
|
|
31
|
+
} | null;
|
|
32
|
+
/** Explicit opt-in code execution runtime. Omit to keep run_code unavailable. */
|
|
33
|
+
executionRuntime?: ExecutionRuntime;
|
|
34
|
+
executionTool?: CreateExecutionToolsOptions;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Run an agent and yield a stream of AgentStreamEvents.
|
|
38
|
+
*
|
|
39
|
+
* Two modes:
|
|
40
|
+
* 1. **Agent mode** (default): looks up agent in registry, selects skills, builds system prompt from agent definition
|
|
41
|
+
* 2. **Playground mode** (when `input.systemPrompt` is set): uses provided system prompt + project tools, bypasses registry
|
|
42
|
+
*/
|
|
43
|
+
export declare function runAgent(input: RunAgentInput, options: RunAgentOptions): AsyncIterable<AgentStreamEvent>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Skill, SkillSelector } from "@uibot/contracts";
|
|
2
|
+
export interface UIBotSkillRegistry extends SkillSelector {
|
|
3
|
+
list(): Skill[];
|
|
4
|
+
/** Returns skills with enabled !== false */
|
|
5
|
+
listEnabled(): Skill[];
|
|
6
|
+
get(id: string): Skill | undefined;
|
|
7
|
+
/** Simple keyword scoring: returns skills whose triggers/tags match the input. */
|
|
8
|
+
score(input: string): Skill[];
|
|
9
|
+
}
|
|
10
|
+
export interface CreateSkillRegistryOptions {
|
|
11
|
+
skills: Skill[];
|
|
12
|
+
/**
|
|
13
|
+
* Matching strategy for `select`/`score`. Without it the registry falls back to a plain
|
|
14
|
+
* substring match on triggers and tags; production passes the `@uibot/skills` selector so
|
|
15
|
+
* agent runs route exactly like prompt composition does.
|
|
16
|
+
*/
|
|
17
|
+
selector?: SkillSelector & {
|
|
18
|
+
score?(input: string): Skill[];
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export declare function createSkillRegistry(options: CreateSkillRegistryOptions): UIBotSkillRegistry;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Union of all events emitted by a running UIBot agent.
|
|
3
|
+
* Covers LLM tokens, tool calls, skill selection, and lifecycle events.
|
|
4
|
+
*/
|
|
5
|
+
export type AgentStreamEvent = {
|
|
6
|
+
type: "reasoning";
|
|
7
|
+
chunk: string;
|
|
8
|
+
} | {
|
|
9
|
+
type: "content";
|
|
10
|
+
chunk: string;
|
|
11
|
+
} | {
|
|
12
|
+
type: "tool-call";
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
input: string;
|
|
16
|
+
} | {
|
|
17
|
+
type: "tool-result";
|
|
18
|
+
callId: string;
|
|
19
|
+
output: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: "skill-selected";
|
|
22
|
+
skillId: string;
|
|
23
|
+
trigger: string;
|
|
24
|
+
} | {
|
|
25
|
+
type: "subagent-delegated";
|
|
26
|
+
name: string;
|
|
27
|
+
} | {
|
|
28
|
+
type: "step";
|
|
29
|
+
stepIndex: number;
|
|
30
|
+
} | {
|
|
31
|
+
type: "done";
|
|
32
|
+
finishReason: string;
|
|
33
|
+
inputTokens?: number;
|
|
34
|
+
outputTokens?: number;
|
|
35
|
+
} | {
|
|
36
|
+
type: "error";
|
|
37
|
+
message: string;
|
|
38
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uibot/agents",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/Foundj/uibot.git",
|
|
8
|
+
"directory": "packages/agents"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"module": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"!dist/**/*.map",
|
|
23
|
+
"!dist/**/*.test.d.ts",
|
|
24
|
+
"!dist/**/*.spec.d.ts"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@uibot/context": "^0.2.0",
|
|
31
|
+
"@uibot/contracts": "^0.2.0",
|
|
32
|
+
"@langchain/anthropic": "^1.5.5",
|
|
33
|
+
"@langchain/core": "^1.2.6",
|
|
34
|
+
"@langchain/langgraph": "^1.4.4",
|
|
35
|
+
"@langchain/langgraph-checkpoint": "^1.1.2",
|
|
36
|
+
"@langchain/langgraph-sdk": "^1.9.23",
|
|
37
|
+
"@langchain/openai": "^1.5.7",
|
|
38
|
+
"deepagents": "^1.12.3",
|
|
39
|
+
"langchain": "1.5.6",
|
|
40
|
+
"langsmith": "^0.7.1",
|
|
41
|
+
"yaml": "2.9.1",
|
|
42
|
+
"zod": "^4.4.3"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "rm -rf dist && bun build --minify ./src/index.ts --outdir ./dist --format esm --target bun && bun x tsc -p tsconfig.json",
|
|
46
|
+
"typecheck": "bun x tsc -p tsconfig.json --noEmit",
|
|
47
|
+
"test": "bun test"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/README.md
DELETED