@nebutra/agents 1.1.1 → 2.0.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/LICENSE +21 -676
- package/README.md +7 -3
- package/dist/{agent-CahnMASx.d.ts → agent-DDGWuUpe.d.ts} +1 -1
- package/dist/{chunk-B7XWL35G.js → chunk-7VL333VJ.js} +5 -1
- package/dist/{chunk-5LX742GP.js → chunk-C4CC5UEF.js} +25 -53
- package/{src/env.ts → dist/chunk-FCXWOXII.js} +23 -47
- package/dist/chunk-HVLFZW6E.js +71 -0
- package/dist/chunk-HZQXXUKB.js +171 -0
- package/dist/{chunk-RLWM437Q.js → chunk-KC6SOI5Z.js} +19 -4
- package/dist/{chunk-NPQECBXL.js → chunk-S5N743EP.js} +60 -7
- package/dist/chunk-VZPQOXWW.js +47 -0
- package/dist/{chunk-NVPE5EDI.js → chunk-YBCIJKC7.js} +20 -3
- package/dist/env.d.ts +45 -0
- package/dist/env.js +12 -0
- package/dist/fallback.d.ts +100 -0
- package/dist/fallback.js +18 -0
- package/dist/generation/index.d.ts +122 -0
- package/dist/generation/index.js +19 -0
- package/dist/index.d.ts +22 -329
- package/dist/index.js +59 -245
- package/dist/observability.d.ts +46 -0
- package/dist/observability.js +13 -0
- package/dist/providers/langchain.d.ts +2 -2
- package/dist/providers/vercel-ai.d.ts +2 -2
- package/dist/providers/vercel-ai.js +15 -7
- package/dist/sdk/config.d.ts +6 -0
- package/dist/sdk/config.js +2 -1
- package/dist/sdk/index.d.ts +37 -4
- package/dist/sdk/index.js +23 -8
- package/dist/sdk/models.d.ts +20 -27
- package/dist/sdk/models.js +5 -3
- package/dist/sdk/provider.d.ts +1 -0
- package/dist/sdk/provider.js +3 -3
- package/dist/tools.d.ts +1 -1
- package/dist/{types-NtgB3pch.d.ts → types-BytC-HfQ.d.ts} +1 -5
- package/package.json +73 -19
- package/.turbo/turbo-build.log +0 -40
- package/.turbo/turbo-test.log +0 -19
- package/.turbo/turbo-typecheck.log +0 -4
- package/AGENTS.md +0 -63
- package/CHANGELOG.md +0 -36
- package/dist/chunk-5JZJ5KMC.js +0 -37
- package/src/__tests__/cost-observability.test.ts +0 -172
- package/src/__tests__/fallback-wiring.test.ts +0 -313
- package/src/__tests__/generation.test.ts +0 -111
- package/src/__tests__/public-api.test.ts +0 -114
- package/src/__tests__/runtime-gateway.test.ts +0 -108
- package/src/agent.ts +0 -117
- package/src/context.ts +0 -99
- package/src/fallback.ts +0 -358
- package/src/gateway.ts +0 -234
- package/src/generation/index.ts +0 -157
- package/src/generation/mock-provider.ts +0 -123
- package/src/generation/types.ts +0 -87
- package/src/index.ts +0 -104
- package/src/memory.ts +0 -126
- package/src/observability.ts +0 -102
- package/src/orchestrator.ts +0 -147
- package/src/providers/langchain.ts +0 -28
- package/src/providers/vercel-ai.ts +0 -114
- package/src/router.ts +0 -158
- package/src/sdk/config.ts +0 -73
- package/src/sdk/index.ts +0 -214
- package/src/sdk/models.ts +0 -57
- package/src/sdk/provider.ts +0 -80
- package/src/tenant.ts +0 -52
- package/src/tools.ts +0 -65
- package/src/types.ts +0 -114
- package/tsconfig.json +0 -12
- package/tsup.config.ts +0 -21
package/dist/sdk/models.d.ts
CHANGED
|
@@ -1,34 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Model presets for common Nebutra use cases.
|
|
3
|
-
*
|
|
4
|
-
* All IDs use "vendor/model" format (OpenRouter / SiliconFlow).
|
|
5
|
-
* When using direct OpenAI provider, only OpenAI models are valid.
|
|
6
|
-
* When using Vercel AI Gateway, use "provider/model" format.
|
|
7
|
-
* When using SiliconFlow, use "Vendor/Model" format (e.g. "Qwen/Qwen2.5-72B-Instruct").
|
|
8
|
-
*/
|
|
9
1
|
declare const models: {
|
|
10
|
-
/**
|
|
11
|
-
readonly
|
|
12
|
-
/**
|
|
13
|
-
readonly
|
|
14
|
-
/**
|
|
15
|
-
readonly
|
|
16
|
-
|
|
17
|
-
readonly "
|
|
18
|
-
|
|
19
|
-
readonly "
|
|
20
|
-
|
|
21
|
-
readonly "
|
|
2
|
+
/** SenseNova 6.7 Flash-Lite — small multimodal agent (default for i18n CI) */
|
|
3
|
+
readonly "sn-flash-lite": "sensenova-6.7-flash-lite";
|
|
4
|
+
/** DeepSeek V4 Flash via SenseNova Token Plan — long context, cheap */
|
|
5
|
+
readonly "sn-deepseek-flash": "deepseek-v4-flash";
|
|
6
|
+
/** Alias: prefer flash-lite for bulk translation */
|
|
7
|
+
readonly "sn-translate": "sensenova-6.7-flash-lite";
|
|
8
|
+
readonly "302-deepseek": "deepseek-v4-pro";
|
|
9
|
+
readonly "302-deepseek-fast": "deepseek-v4-flash";
|
|
10
|
+
readonly "302-qwen": "qwen3.8-max";
|
|
11
|
+
readonly "302-glm": "glm-5.3";
|
|
12
|
+
readonly "302-kimi": "kimi-k3";
|
|
13
|
+
readonly "302-minimax": "MiniMax-M3";
|
|
22
14
|
/** Embedding model */
|
|
23
15
|
readonly embedding: "openai/text-embedding-3-small";
|
|
24
16
|
/** Embedding model (high-dimensional) */
|
|
25
17
|
readonly "embedding-large": "openai/text-embedding-3-large";
|
|
26
|
-
|
|
27
|
-
readonly
|
|
28
|
-
|
|
29
|
-
readonly "
|
|
30
|
-
|
|
31
|
-
readonly "
|
|
18
|
+
readonly reasoning: "anthropic/claude-opus-5";
|
|
19
|
+
readonly flagship: "anthropic/claude-sonnet-5";
|
|
20
|
+
readonly fast: "anthropic/claude-haiku-4.5";
|
|
21
|
+
readonly "openai-flagship": "openai/gpt-5.6-sol";
|
|
22
|
+
readonly "google-flagship": "google/gemini-3.1-pro-preview";
|
|
23
|
+
readonly "google-fast": "google/gemini-3.7-flash";
|
|
32
24
|
};
|
|
33
25
|
type ModelPreset = keyof typeof models;
|
|
34
26
|
/**
|
|
@@ -36,5 +28,6 @@ type ModelPreset = keyof typeof models;
|
|
|
36
28
|
* If the input is not a preset key, returns it as-is (passthrough).
|
|
37
29
|
*/
|
|
38
30
|
declare function resolveModel(modelOrPreset: string): string;
|
|
31
|
+
declare function toAi302ModelId(modelOrPreset: string): string;
|
|
39
32
|
|
|
40
|
-
export { type ModelPreset, models, resolveModel };
|
|
33
|
+
export { type ModelPreset, models, resolveModel, toAi302ModelId };
|
package/dist/sdk/models.js
CHANGED
package/dist/sdk/provider.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import 'zod';
|
|
|
9
9
|
* - "openrouter" → @openrouter/ai-sdk-provider (300+ models, failover)
|
|
10
10
|
* - "openai" → @ai-sdk/openai (direct OpenAI API)
|
|
11
11
|
* - "siliconflow" → @ai-sdk/openai with SiliconFlow baseURL (OpenAI-compatible)
|
|
12
|
+
* - "sensenova" → @ai-sdk/openai with SenseNova compatible-mode baseURL
|
|
12
13
|
* - "gateway" → Vercel AI Gateway via plain model string (OIDC auth)
|
|
13
14
|
*/
|
|
14
15
|
declare function createModel(modelOrPreset: string, config: ResolvedNebutraAIConfig): LanguageModel;
|
package/dist/sdk/provider.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createEmbeddingModel,
|
|
3
3
|
createModel
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-KC6SOI5Z.js";
|
|
5
|
+
import "../chunk-YBCIJKC7.js";
|
|
6
|
+
import "../chunk-HVLFZW6E.js";
|
|
7
7
|
export {
|
|
8
8
|
createEmbeddingModel,
|
|
9
9
|
createModel
|
package/dist/tools.d.ts
CHANGED
|
@@ -73,10 +73,6 @@ interface RouterConfig {
|
|
|
73
73
|
readonly strategy: "keyword" | "llm" | "custom";
|
|
74
74
|
readonly customRouter?: (message: string, context: AgentContext) => Promise<string>;
|
|
75
75
|
}
|
|
76
|
-
interface PipelineStep {
|
|
77
|
-
readonly agentId: string;
|
|
78
|
-
readonly transformInput?: (prevOutput: string) => string;
|
|
79
|
-
}
|
|
80
76
|
interface AgentUsageEvent {
|
|
81
77
|
readonly tenantId: string;
|
|
82
78
|
readonly userId: string;
|
|
@@ -89,4 +85,4 @@ interface AgentUsageEvent {
|
|
|
89
85
|
readonly timestamp: Date;
|
|
90
86
|
}
|
|
91
87
|
|
|
92
|
-
export type { AgentMessage as A, MemoryConfig as M, OrchestratorConfig as O,
|
|
88
|
+
export type { AgentMessage as A, MemoryConfig as M, OrchestratorConfig as O, RouterConfig as R, TokenUsage as T, AgentContext as a, AgentResponse as b, AgentConfig as c, AgentTool as d, AgentUsageEvent as e, ToolCallResult as f };
|
package/package.json
CHANGED
|
@@ -1,46 +1,97 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nebutra/agents",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Nebutra AI runtime: multi-agent orchestration + Vercel AI SDK helpers (absorbed @nebutra/ai-sdk in 1.0.0)",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"nebutra": {
|
|
9
|
+
"status": "wip",
|
|
10
|
+
"graph": "runtime",
|
|
9
11
|
"featureId": "agents",
|
|
10
12
|
"category": "ai",
|
|
11
13
|
"surface": "model-runtime",
|
|
12
14
|
"summary": "Nebutra AI runtime: multi-agent orchestration + Vercel AI SDK helpers"
|
|
13
15
|
},
|
|
14
|
-
"main": "./
|
|
15
|
-
"types": "./
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
16
18
|
"exports": {
|
|
17
|
-
".":
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"./
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"./
|
|
28
|
-
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js",
|
|
22
|
+
"default": "./dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./tools": {
|
|
25
|
+
"types": "./dist/tools.d.ts",
|
|
26
|
+
"import": "./dist/tools.js",
|
|
27
|
+
"default": "./dist/tools.js"
|
|
28
|
+
},
|
|
29
|
+
"./providers/vercel-ai": {
|
|
30
|
+
"types": "./dist/providers/vercel-ai.d.ts",
|
|
31
|
+
"import": "./dist/providers/vercel-ai.js",
|
|
32
|
+
"default": "./dist/providers/vercel-ai.js"
|
|
33
|
+
},
|
|
34
|
+
"./providers/langchain": {
|
|
35
|
+
"types": "./dist/providers/langchain.d.ts",
|
|
36
|
+
"import": "./dist/providers/langchain.js",
|
|
37
|
+
"default": "./dist/providers/langchain.js"
|
|
38
|
+
},
|
|
39
|
+
"./generation": {
|
|
40
|
+
"types": "./dist/generation/index.d.ts",
|
|
41
|
+
"import": "./dist/generation/index.js",
|
|
42
|
+
"default": "./dist/generation/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./sdk": {
|
|
45
|
+
"types": "./dist/sdk/index.d.ts",
|
|
46
|
+
"import": "./dist/sdk/index.js",
|
|
47
|
+
"default": "./dist/sdk/index.js"
|
|
48
|
+
},
|
|
49
|
+
"./sdk/config": {
|
|
50
|
+
"types": "./dist/sdk/config.d.ts",
|
|
51
|
+
"import": "./dist/sdk/config.js",
|
|
52
|
+
"default": "./dist/sdk/config.js"
|
|
53
|
+
},
|
|
54
|
+
"./sdk/models": {
|
|
55
|
+
"types": "./dist/sdk/models.d.ts",
|
|
56
|
+
"import": "./dist/sdk/models.js",
|
|
57
|
+
"default": "./dist/sdk/models.js"
|
|
58
|
+
},
|
|
59
|
+
"./sdk/provider": {
|
|
60
|
+
"types": "./dist/sdk/provider.d.ts",
|
|
61
|
+
"import": "./dist/sdk/provider.js",
|
|
62
|
+
"default": "./dist/sdk/provider.js"
|
|
63
|
+
},
|
|
64
|
+
"./env": {
|
|
65
|
+
"types": "./dist/env.d.ts",
|
|
66
|
+
"import": "./dist/env.js",
|
|
67
|
+
"default": "./dist/env.js"
|
|
68
|
+
},
|
|
69
|
+
"./observability": {
|
|
70
|
+
"types": "./dist/observability.d.ts",
|
|
71
|
+
"import": "./dist/observability.js",
|
|
72
|
+
"default": "./dist/observability.js"
|
|
73
|
+
},
|
|
74
|
+
"./fallback": {
|
|
75
|
+
"types": "./dist/fallback.d.ts",
|
|
76
|
+
"import": "./dist/fallback.js",
|
|
77
|
+
"default": "./dist/fallback.js"
|
|
78
|
+
}
|
|
29
79
|
},
|
|
30
80
|
"dependencies": {
|
|
31
81
|
"@ai-sdk/anthropic": "^3.0.76",
|
|
32
82
|
"@ai-sdk/openai": "^3.0.41",
|
|
33
83
|
"@openrouter/ai-sdk-provider": "^2.3.3",
|
|
34
84
|
"ai": "^6.0.0",
|
|
85
|
+
"ajv": "^8.18.0",
|
|
35
86
|
"langfuse": "^3.38.20",
|
|
36
87
|
"langfuse-vercel": "^3.38.20",
|
|
37
88
|
"zod": "^4.3.6",
|
|
38
|
-
"@nebutra/billing": "0.
|
|
39
|
-
"@nebutra/cache": "0.0
|
|
40
|
-
"@nebutra/logger": "0.
|
|
89
|
+
"@nebutra/billing": "2.0.0",
|
|
90
|
+
"@nebutra/cache": "2.0.0",
|
|
91
|
+
"@nebutra/logger": "2.0.0"
|
|
41
92
|
},
|
|
42
93
|
"devDependencies": {
|
|
43
|
-
"@types/node": "^
|
|
94
|
+
"@types/node": "^25.9.1",
|
|
44
95
|
"tsup": "^8.5.1",
|
|
45
96
|
"typescript": "^5.9.3",
|
|
46
97
|
"vitest": "^4.0.18"
|
|
@@ -57,6 +108,9 @@
|
|
|
57
108
|
"publishConfig": {
|
|
58
109
|
"access": "public"
|
|
59
110
|
},
|
|
111
|
+
"files": [
|
|
112
|
+
"dist"
|
|
113
|
+
],
|
|
60
114
|
"scripts": {
|
|
61
115
|
"build": "tsup",
|
|
62
116
|
"dev": "tsup --watch",
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @nebutra/agents@1.1.1 build /home/runner/work/Nebutra-Sailor/Nebutra-Sailor/packages/ai/agents
|
|
3
|
-
> tsup
|
|
4
|
-
|
|
5
|
-
[34mCLI[39m Building entry: src/index.ts, src/tools.ts, src/providers/langchain.ts, src/providers/vercel-ai.ts, src/sdk/config.ts, src/sdk/index.ts, src/sdk/models.ts, src/sdk/provider.ts
|
|
6
|
-
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
-
[34mCLI[39m tsup v8.5.1
|
|
8
|
-
[34mCLI[39m Using tsup config: /home/runner/work/Nebutra-Sailor/Nebutra-Sailor/packages/ai/agents/tsup.config.ts
|
|
9
|
-
[34mCLI[39m Target: node20
|
|
10
|
-
[34mCLI[39m Cleaning output folder
|
|
11
|
-
[34mESM[39m Build start
|
|
12
|
-
[32mESM[39m [1mdist/index.js [22m[32m16.08 KB[39m
|
|
13
|
-
[32mESM[39m [1mdist/providers/langchain.js [22m[32m536.00 B[39m
|
|
14
|
-
[32mESM[39m [1mdist/sdk/config.js [22m[32m166.00 B[39m
|
|
15
|
-
[32mESM[39m [1mdist/chunk-UVL2UVVM.js [22m[32m1.26 KB[39m
|
|
16
|
-
[32mESM[39m [1mdist/tools.js [22m[32m203.00 B[39m
|
|
17
|
-
[32mESM[39m [1mdist/providers/vercel-ai.js [22m[32m2.43 KB[39m
|
|
18
|
-
[32mESM[39m [1mdist/chunk-B7XWL35G.js [22m[32m1.51 KB[39m
|
|
19
|
-
[32mESM[39m [1mdist/chunk-RDOFKRI6.js [22m[32m4.71 KB[39m
|
|
20
|
-
[32mESM[39m [1mdist/sdk/index.js [22m[32m534.00 B[39m
|
|
21
|
-
[32mESM[39m [1mdist/chunk-NPQECBXL.js [22m[32m2.37 KB[39m
|
|
22
|
-
[32mESM[39m [1mdist/chunk-5LX742GP.js [22m[32m7.78 KB[39m
|
|
23
|
-
[32mESM[39m [1mdist/sdk/provider.js [22m[32m190.00 B[39m
|
|
24
|
-
[32mESM[39m [1mdist/sdk/models.js [22m[32m102.00 B[39m
|
|
25
|
-
[32mESM[39m [1mdist/chunk-RLWM437Q.js [22m[32m1.63 KB[39m
|
|
26
|
-
[32mESM[39m [1mdist/chunk-NVPE5EDI.js [22m[32m1.49 KB[39m
|
|
27
|
-
[32mESM[39m [1mdist/chunk-5JZJ5KMC.js [22m[32m1.22 KB[39m
|
|
28
|
-
[32mESM[39m ⚡️ Build success in 48ms
|
|
29
|
-
[34mDTS[39m Build start
|
|
30
|
-
[32mDTS[39m ⚡️ Build success in 5575ms
|
|
31
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m19.71 KB[39m
|
|
32
|
-
[32mDTS[39m [1mdist/tools.d.ts [22m[32m724.00 B[39m
|
|
33
|
-
[32mDTS[39m [1mdist/providers/langchain.d.ts [22m[32m546.00 B[39m
|
|
34
|
-
[32mDTS[39m [1mdist/providers/vercel-ai.d.ts [22m[32m569.00 B[39m
|
|
35
|
-
[32mDTS[39m [1mdist/sdk/index.d.ts [22m[32m3.88 KB[39m
|
|
36
|
-
[32mDTS[39m [1mdist/sdk/models.d.ts [22m[32m1.73 KB[39m
|
|
37
|
-
[32mDTS[39m [1mdist/sdk/provider.d.ts [22m[32m882.00 B[39m
|
|
38
|
-
[32mDTS[39m [1mdist/sdk/config.d.ts [22m[32m1.80 KB[39m
|
|
39
|
-
[32mDTS[39m [1mdist/agent-CahnMASx.d.ts [22m[32m1.10 KB[39m
|
|
40
|
-
[32mDTS[39m [1mdist/types-NtgB3pch.d.ts [22m[32m3.02 KB[39m
|
package/.turbo/turbo-test.log
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @nebutra/agents@1.1.1 test /home/runner/work/Nebutra-Sailor/Nebutra-Sailor/packages/ai/agents
|
|
3
|
-
> vitest run
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
[1m[30m[46m RUN [49m[39m[22m [36mv4.1.4 [39m[90m/home/runner/work/Nebutra-Sailor/Nebutra-Sailor/packages/ai/agents[39m
|
|
7
|
-
|
|
8
|
-
[32m✓[39m src/__tests__/fallback-wiring.test.ts [2m([22m[2m9 tests[22m[2m)[22m[32m 235[2mms[22m[39m
|
|
9
|
-
[32m✓[39m src/__tests__/cost-observability.test.ts [2m([22m[2m18 tests[22m[2m)[22m[33m 510[2mms[22m[39m
|
|
10
|
-
[33m[2m✓[22m[39m falls through retryable errors and returns the next provider's result [33m 335[2mms[22m[39m
|
|
11
|
-
[32m✓[39m src/__tests__/public-api.test.ts [2m([22m[2m16 tests[22m[2m)[22m[32m 72[2mms[22m[39m
|
|
12
|
-
[32m✓[39m src/__tests__/runtime-gateway.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 80[2mms[22m[39m
|
|
13
|
-
[32m✓[39m src/__tests__/generation.test.ts [2m([22m[2m7 tests[22m[2m)[22m[32m 61[2mms[22m[39m
|
|
14
|
-
|
|
15
|
-
[2m Test Files [22m [1m[32m5 passed[39m[22m[90m (5)[39m
|
|
16
|
-
[2m Tests [22m [1m[32m53 passed[39m[22m[90m (53)[39m
|
|
17
|
-
[2m Start at [22m 08:15:21
|
|
18
|
-
[2m Duration [22m 4.98s[2m (transform 2.66s, setup 0ms, import 7.42s, tests 958ms, environment 1ms)[22m
|
|
19
|
-
|
package/AGENTS.md
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# AGENTS.md — packages/agents
|
|
2
|
-
|
|
3
|
-
Execution contract for Nebutra's multi-agent runtime package.
|
|
4
|
-
|
|
5
|
-
## Scope
|
|
6
|
-
|
|
7
|
-
Applies to everything under `packages/ai/agents/`.
|
|
8
|
-
|
|
9
|
-
This package owns agent lifecycle, orchestration, routing, tenant-aware memory,
|
|
10
|
-
built-in tool stubs, and the shared AI SDK wrapper surface exported to the rest
|
|
11
|
-
of the repo. It is the runtime layer for agent execution, not the place for
|
|
12
|
-
app-specific prompts, UI behavior, or direct provider-specific business logic.
|
|
13
|
-
|
|
14
|
-
## Source Of Truth
|
|
15
|
-
|
|
16
|
-
- Public package surface and subpath exports: `package.json`, `src/index.ts`
|
|
17
|
-
- Canonical agent and orchestration contracts: `src/types.ts`
|
|
18
|
-
- Base agent lifecycle, memory loading, usage emission, and billing hook:
|
|
19
|
-
`src/agent.ts`
|
|
20
|
-
- Multi-agent routing, quota checks, chat/pipeline/broadcast semantics:
|
|
21
|
-
`src/orchestrator.ts`, `src/router.ts`, `src/tenant.ts`
|
|
22
|
-
- Built-in tool catalog and current stub behavior: `src/tools.ts`
|
|
23
|
-
- Shared AI SDK wrapper config, model resolution, and provider helpers:
|
|
24
|
-
`src/sdk/`
|
|
25
|
-
- Provider-specific runtime adapters: `src/providers/`
|
|
26
|
-
- Public API coverage for exported surface: `src/__tests__/public-api.test.ts`
|
|
27
|
-
|
|
28
|
-
Treat `README.md` as descriptive only. If docs drift, update the source files
|
|
29
|
-
above instead of preserving outdated examples.
|
|
30
|
-
|
|
31
|
-
## Contract Boundaries
|
|
32
|
-
|
|
33
|
-
- Keep `package.json` exports and `src/index.ts` aligned. Do not ask consumers
|
|
34
|
-
to deep-import internals when a supported subpath export already exists.
|
|
35
|
-
- Treat `src/types.ts` as the canonical contract for agent config, context,
|
|
36
|
-
memory, tool, usage, and orchestration semantics. Tightening these shapes is
|
|
37
|
-
a cross-package compatibility change.
|
|
38
|
-
- Preserve the split between core runtime and provider adapters:
|
|
39
|
-
`src/agent.ts`, `src/orchestrator.ts`, and `src/router.ts` own generic agent
|
|
40
|
-
lifecycle semantics; `src/providers/` and `src/sdk/` own provider-specific
|
|
41
|
-
runtime behavior.
|
|
42
|
-
- Keep quota and usage semantics centralized in `src/tenant.ts` and
|
|
43
|
-
`src/agent.ts`. Do not scatter billing deduction or quota checks into callers.
|
|
44
|
-
- Keep built-in tools honest about current capability. `src/tools.ts` is still
|
|
45
|
-
stub-oriented; do not document or code against live search, RAG, or SQL
|
|
46
|
-
access unless the actual implementation is being added.
|
|
47
|
-
- Memory semantics belong in `src/memory.ts` and the base lifecycle in
|
|
48
|
-
`src/agent.ts`. Do not invent parallel persistence paths in downstream apps.
|
|
49
|
-
|
|
50
|
-
## Generated And Derived Files
|
|
51
|
-
|
|
52
|
-
- Treat future `dist/` output from `tsup` as derived build output.
|
|
53
|
-
- Do not hand-edit temporary runtime logs, cached memory snapshots, or ad hoc
|
|
54
|
-
generated provider metadata.
|
|
55
|
-
- If public runtime behavior changes, update the source files above and rebuild
|
|
56
|
-
rather than patching emitted output.
|
|
57
|
-
|
|
58
|
-
## Validation
|
|
59
|
-
|
|
60
|
-
- Public API, routing, tool, or lifecycle changes:
|
|
61
|
-
`pnpm --filter @nebutra/agents test`
|
|
62
|
-
- Export, type, or provider-surface changes:
|
|
63
|
-
`pnpm --filter @nebutra/agents typecheck`
|
package/CHANGELOG.md
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# @nebutra/agents
|
|
2
|
-
|
|
3
|
-
## 1.1.1
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- Publish registry package metadata under the MIT license.
|
|
8
|
-
|
|
9
|
-
- Updated dependencies []:
|
|
10
|
-
- @nebutra/billing@0.1.2
|
|
11
|
-
- @nebutra/cache@0.0.2
|
|
12
|
-
- @nebutra/logger@0.1.1
|
|
13
|
-
|
|
14
|
-
## 1.1.0
|
|
15
|
-
|
|
16
|
-
### Minor Changes
|
|
17
|
-
|
|
18
|
-
- [`092a1ce`](https://github.com/Nebutra/Nebutra-Sailor/commit/092a1ce810965e2d81767642e4bad05b80df81f4) Thanks [@TsekaLuk](https://github.com/TsekaLuk)! - Add the Atelier agentic creative-canvas capability.
|
|
19
|
-
- `@nebutra/agents`: new image/video **generation modality**
|
|
20
|
-
(`@nebutra/agents/generation`) on the same env-key-gated provider layer as
|
|
21
|
-
the LLM fallback chain, with a deterministic always-available mock provider.
|
|
22
|
-
- `@nebutra/atelier-canvas`: new package — server-authoritative non-overlap
|
|
23
|
-
placement, persist-then-broadcast consistency, per-`(tenant,canvas)`
|
|
24
|
-
serialization, tenant-scoped store (in-memory + Prisma adapter). The
|
|
25
|
-
`./agent` subpath adds the creative-direction prompt strategy + generation
|
|
26
|
-
tool + `AgentConfig` factory (optional `@nebutra/agents` peer).
|
|
27
|
-
- `@nebutra/feature-flags`: new `FLAGS.ATELIER_CANVAS` (off by default).
|
|
28
|
-
|
|
29
|
-
Additive `AtelierCanvas` Prisma model. A flag-gated `/atelier` demo route in
|
|
30
|
-
`apps/web` exercises the loop end-to-end with the mock provider (no AI key
|
|
31
|
-
required).
|
|
32
|
-
|
|
33
|
-
### Patch Changes
|
|
34
|
-
|
|
35
|
-
- Updated dependencies [[`5d3d7e6`](https://github.com/Nebutra/Nebutra-Sailor/commit/5d3d7e6c59cae5aa242bb988b75a9888cfd0db39)]:
|
|
36
|
-
- @nebutra/billing@0.1.1
|
package/dist/chunk-5JZJ5KMC.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// src/sdk/models.ts
|
|
2
|
-
var models = {
|
|
3
|
-
/** High-quality reasoning — default for complex tasks */
|
|
4
|
-
flagship: "anthropic/claude-sonnet-4",
|
|
5
|
-
/** Deep reasoning for architecture and research */
|
|
6
|
-
reasoning: "anthropic/claude-opus-4",
|
|
7
|
-
/** Fast + cheap — chat, summaries, classification */
|
|
8
|
-
fast: "anthropic/claude-haiku-4",
|
|
9
|
-
/** OpenAI flagship */
|
|
10
|
-
"openai-flagship": "openai/gpt-5.4",
|
|
11
|
-
/** Google flagship */
|
|
12
|
-
"google-flagship": "google/gemini-2.5-pro",
|
|
13
|
-
/** Google fast */
|
|
14
|
-
"google-fast": "google/gemini-2.5-flash",
|
|
15
|
-
/** Embedding model */
|
|
16
|
-
embedding: "openai/text-embedding-3-small",
|
|
17
|
-
/** Embedding model (high-dimensional) */
|
|
18
|
-
"embedding-large": "openai/text-embedding-3-large",
|
|
19
|
-
// --- SiliconFlow presets (use with provider: "siliconflow") ---
|
|
20
|
-
/** SiliconFlow — Qwen 2.5 72B (flagship open-source) */
|
|
21
|
-
"sf-qwen": "Qwen/Qwen2.5-72B-Instruct",
|
|
22
|
-
/** SiliconFlow — DeepSeek R1 reasoning (via SiliconFlow Pro) */
|
|
23
|
-
"sf-deepseek-r1": "Pro/deepseek-ai/DeepSeek-R1",
|
|
24
|
-
/** SiliconFlow — DeepSeek V3 (fast, capable) */
|
|
25
|
-
"sf-deepseek-v3": "deepseek-ai/DeepSeek-V3"
|
|
26
|
-
};
|
|
27
|
-
function resolveModel(modelOrPreset) {
|
|
28
|
-
if (modelOrPreset in models) {
|
|
29
|
-
return models[modelOrPreset];
|
|
30
|
-
}
|
|
31
|
-
return modelOrPreset;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export {
|
|
35
|
-
models,
|
|
36
|
-
resolveModel
|
|
37
|
-
};
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cost & observability primitives:
|
|
3
|
-
* - Anthropic prompt cache control wiring
|
|
4
|
-
* - Multi-provider fallback chain on retryable errors
|
|
5
|
-
* - Langfuse no-op when env missing
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
9
|
-
|
|
10
|
-
import { _resetAgentsEnvCache } from "../env";
|
|
11
|
-
import {
|
|
12
|
-
buildSystemWithCache,
|
|
13
|
-
isRetryableError,
|
|
14
|
-
runWithFallback,
|
|
15
|
-
withAnthropicCacheControl,
|
|
16
|
-
} from "../fallback";
|
|
17
|
-
import { _resetLangfuseCache, buildTelemetryConfig, initLangfuse } from "../observability";
|
|
18
|
-
|
|
19
|
-
describe("withAnthropicCacheControl()", () => {
|
|
20
|
-
it("returns ephemeral cache control under the anthropic provider key", () => {
|
|
21
|
-
const opts = withAnthropicCacheControl();
|
|
22
|
-
expect(opts.anthropic.cacheControl.type).toBe("ephemeral");
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("wraps a system prompt with cache-control providerOptions", () => {
|
|
26
|
-
const wrapped = buildSystemWithCache("You are a helpful assistant.");
|
|
27
|
-
expect(wrapped.role).toBe("system");
|
|
28
|
-
expect(wrapped.content).toBe("You are a helpful assistant.");
|
|
29
|
-
expect(wrapped.providerOptions.anthropic.cacheControl.type).toBe("ephemeral");
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
describe("isRetryableError()", () => {
|
|
34
|
-
it.each([429, 500, 502, 503, 504, 408])("marks status %i as retryable", (statusCode: number) => {
|
|
35
|
-
expect(isRetryableError({ statusCode })).toBe(true);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("marks ECONNRESET / ETIMEDOUT as retryable", () => {
|
|
39
|
-
expect(isRetryableError({ code: "ECONNRESET" })).toBe(true);
|
|
40
|
-
expect(isRetryableError({ code: "ETIMEDOUT" })).toBe(true);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("marks 4xx auth/validation errors as non-retryable", () => {
|
|
44
|
-
expect(isRetryableError({ statusCode: 401 })).toBe(false);
|
|
45
|
-
expect(isRetryableError({ statusCode: 403 })).toBe(false);
|
|
46
|
-
expect(isRetryableError({ statusCode: 400 })).toBe(false);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("returns false for null / undefined / non-objects", () => {
|
|
50
|
-
expect(isRetryableError(null)).toBe(false);
|
|
51
|
-
expect(isRetryableError(undefined)).toBe(false);
|
|
52
|
-
expect(isRetryableError("oops")).toBe(false);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("respects an explicit isRetryable=true flag (AI SDK APICallError)", () => {
|
|
56
|
-
expect(isRetryableError({ isRetryable: true })).toBe(true);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
describe("runWithFallback()", () => {
|
|
61
|
-
beforeEach(() => {
|
|
62
|
-
_resetAgentsEnvCache();
|
|
63
|
-
// Provide stub keys so buildModel() doesn't throw before invoke() runs.
|
|
64
|
-
vi.stubEnv("OPENROUTER_API_KEY", "test-or");
|
|
65
|
-
vi.stubEnv("ANTHROPIC_API_KEY", "test-an");
|
|
66
|
-
vi.stubEnv("OPENAI_API_KEY", "test-oa");
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
afterEach(() => {
|
|
70
|
-
vi.unstubAllEnvs();
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("falls through retryable errors and returns the next provider's result", async () => {
|
|
74
|
-
let calls = 0;
|
|
75
|
-
const result = await runWithFallback(
|
|
76
|
-
async () => {
|
|
77
|
-
calls += 1;
|
|
78
|
-
if (calls === 1) {
|
|
79
|
-
// simulate primary provider 503
|
|
80
|
-
const err = Object.assign(new Error("Service Unavailable"), {
|
|
81
|
-
statusCode: 503,
|
|
82
|
-
});
|
|
83
|
-
throw err;
|
|
84
|
-
}
|
|
85
|
-
return "ok-from-fallback" as const;
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
chain: ["openrouter", "anthropic"],
|
|
89
|
-
// Stub buildModel by injecting fake creds via env
|
|
90
|
-
model: "flagship",
|
|
91
|
-
},
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
expect(result.result).toBe("ok-from-fallback");
|
|
95
|
-
expect(result.attempts).toBe(2);
|
|
96
|
-
expect(result.provider).toBe("anthropic");
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it("rethrows non-retryable errors immediately (no fallback)", async () => {
|
|
100
|
-
let calls = 0;
|
|
101
|
-
await expect(
|
|
102
|
-
runWithFallback(
|
|
103
|
-
async () => {
|
|
104
|
-
calls += 1;
|
|
105
|
-
throw Object.assign(new Error("Unauthorized"), { statusCode: 401 });
|
|
106
|
-
},
|
|
107
|
-
{ chain: ["openrouter", "anthropic"] },
|
|
108
|
-
),
|
|
109
|
-
).rejects.toThrow(/Unauthorized/);
|
|
110
|
-
expect(calls).toBe(1);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
it("throws an aggregate error when the entire chain fails with retryables", async () => {
|
|
114
|
-
await expect(
|
|
115
|
-
runWithFallback(
|
|
116
|
-
async () => {
|
|
117
|
-
throw Object.assign(new Error("503"), { statusCode: 503 });
|
|
118
|
-
},
|
|
119
|
-
{ chain: ["openrouter", "anthropic", "openai"] },
|
|
120
|
-
),
|
|
121
|
-
).rejects.toThrow(/All LLM providers in fallback chain/);
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
describe("Langfuse telemetry — no-op when env missing", () => {
|
|
126
|
-
beforeEach(() => {
|
|
127
|
-
_resetLangfuseCache();
|
|
128
|
-
_resetAgentsEnvCache();
|
|
129
|
-
vi.unstubAllEnvs();
|
|
130
|
-
vi.stubEnv("LANGFUSE_PUBLIC_KEY", "");
|
|
131
|
-
vi.stubEnv("LANGFUSE_SECRET_KEY", "");
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
afterEach(() => {
|
|
135
|
-
vi.unstubAllEnvs();
|
|
136
|
-
_resetLangfuseCache();
|
|
137
|
-
_resetAgentsEnvCache();
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it("initLangfuse() returns null when keys missing", async () => {
|
|
141
|
-
const client = await initLangfuse();
|
|
142
|
-
expect(client).toBeNull();
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it("buildTelemetryConfig() returns isEnabled=false when keys missing", () => {
|
|
146
|
-
const cfg = buildTelemetryConfig({ functionId: "test-fn" });
|
|
147
|
-
expect(cfg.isEnabled).toBe(false);
|
|
148
|
-
expect(cfg.functionId).toBeUndefined();
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it("buildTelemetryConfig() includes tenant/session metadata when configured", () => {
|
|
152
|
-
vi.stubEnv("LANGFUSE_PUBLIC_KEY", "pk-test");
|
|
153
|
-
vi.stubEnv("LANGFUSE_SECRET_KEY", "sk-test");
|
|
154
|
-
_resetAgentsEnvCache();
|
|
155
|
-
|
|
156
|
-
const cfg = buildTelemetryConfig({
|
|
157
|
-
functionId: "agent.support-bot",
|
|
158
|
-
metadata: {
|
|
159
|
-
tenantId: "org_123",
|
|
160
|
-
userId: "user_456",
|
|
161
|
-
sessionId: "conv_789",
|
|
162
|
-
agentId: "support-bot",
|
|
163
|
-
},
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
expect(cfg.isEnabled).toBe(true);
|
|
167
|
-
expect(cfg.functionId).toBe("agent.support-bot");
|
|
168
|
-
expect(cfg.metadata?.tenantId).toBe("org_123");
|
|
169
|
-
expect(cfg.metadata?.langfuseUserId).toBe("org_123");
|
|
170
|
-
expect(cfg.metadata?.langfuseSessionId).toBe("conv_789");
|
|
171
|
-
});
|
|
172
|
-
});
|