@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.
Files changed (70) hide show
  1. package/LICENSE +21 -676
  2. package/README.md +7 -3
  3. package/dist/{agent-CahnMASx.d.ts → agent-DDGWuUpe.d.ts} +1 -1
  4. package/dist/{chunk-B7XWL35G.js → chunk-7VL333VJ.js} +5 -1
  5. package/dist/{chunk-5LX742GP.js → chunk-C4CC5UEF.js} +25 -53
  6. package/{src/env.ts → dist/chunk-FCXWOXII.js} +23 -47
  7. package/dist/chunk-HVLFZW6E.js +71 -0
  8. package/dist/chunk-HZQXXUKB.js +171 -0
  9. package/dist/{chunk-RLWM437Q.js → chunk-KC6SOI5Z.js} +19 -4
  10. package/dist/{chunk-NPQECBXL.js → chunk-S5N743EP.js} +60 -7
  11. package/dist/chunk-VZPQOXWW.js +47 -0
  12. package/dist/{chunk-NVPE5EDI.js → chunk-YBCIJKC7.js} +20 -3
  13. package/dist/env.d.ts +45 -0
  14. package/dist/env.js +12 -0
  15. package/dist/fallback.d.ts +100 -0
  16. package/dist/fallback.js +18 -0
  17. package/dist/generation/index.d.ts +122 -0
  18. package/dist/generation/index.js +19 -0
  19. package/dist/index.d.ts +22 -329
  20. package/dist/index.js +59 -245
  21. package/dist/observability.d.ts +46 -0
  22. package/dist/observability.js +13 -0
  23. package/dist/providers/langchain.d.ts +2 -2
  24. package/dist/providers/vercel-ai.d.ts +2 -2
  25. package/dist/providers/vercel-ai.js +15 -7
  26. package/dist/sdk/config.d.ts +6 -0
  27. package/dist/sdk/config.js +2 -1
  28. package/dist/sdk/index.d.ts +37 -4
  29. package/dist/sdk/index.js +23 -8
  30. package/dist/sdk/models.d.ts +20 -27
  31. package/dist/sdk/models.js +5 -3
  32. package/dist/sdk/provider.d.ts +1 -0
  33. package/dist/sdk/provider.js +3 -3
  34. package/dist/tools.d.ts +1 -1
  35. package/dist/{types-NtgB3pch.d.ts → types-BytC-HfQ.d.ts} +1 -5
  36. package/package.json +73 -19
  37. package/.turbo/turbo-build.log +0 -40
  38. package/.turbo/turbo-test.log +0 -19
  39. package/.turbo/turbo-typecheck.log +0 -4
  40. package/AGENTS.md +0 -63
  41. package/CHANGELOG.md +0 -36
  42. package/dist/chunk-5JZJ5KMC.js +0 -37
  43. package/src/__tests__/cost-observability.test.ts +0 -172
  44. package/src/__tests__/fallback-wiring.test.ts +0 -313
  45. package/src/__tests__/generation.test.ts +0 -111
  46. package/src/__tests__/public-api.test.ts +0 -114
  47. package/src/__tests__/runtime-gateway.test.ts +0 -108
  48. package/src/agent.ts +0 -117
  49. package/src/context.ts +0 -99
  50. package/src/fallback.ts +0 -358
  51. package/src/gateway.ts +0 -234
  52. package/src/generation/index.ts +0 -157
  53. package/src/generation/mock-provider.ts +0 -123
  54. package/src/generation/types.ts +0 -87
  55. package/src/index.ts +0 -104
  56. package/src/memory.ts +0 -126
  57. package/src/observability.ts +0 -102
  58. package/src/orchestrator.ts +0 -147
  59. package/src/providers/langchain.ts +0 -28
  60. package/src/providers/vercel-ai.ts +0 -114
  61. package/src/router.ts +0 -158
  62. package/src/sdk/config.ts +0 -73
  63. package/src/sdk/index.ts +0 -214
  64. package/src/sdk/models.ts +0 -57
  65. package/src/sdk/provider.ts +0 -80
  66. package/src/tenant.ts +0 -52
  67. package/src/tools.ts +0 -65
  68. package/src/types.ts +0 -114
  69. package/tsconfig.json +0 -12
  70. package/tsup.config.ts +0 -21
@@ -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
- /** High-quality reasoning — default for complex tasks */
11
- readonly flagship: "anthropic/claude-sonnet-4";
12
- /** Deep reasoning for architecture and research */
13
- readonly reasoning: "anthropic/claude-opus-4";
14
- /** Fast + cheap — chat, summaries, classification */
15
- readonly fast: "anthropic/claude-haiku-4";
16
- /** OpenAI flagship */
17
- readonly "openai-flagship": "openai/gpt-5.4";
18
- /** Google flagship */
19
- readonly "google-flagship": "google/gemini-2.5-pro";
20
- /** Google fast */
21
- readonly "google-fast": "google/gemini-2.5-flash";
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
- /** SiliconFlow — Qwen 2.5 72B (flagship open-source) */
27
- readonly "sf-qwen": "Qwen/Qwen2.5-72B-Instruct";
28
- /** SiliconFlow — DeepSeek R1 reasoning (via SiliconFlow Pro) */
29
- readonly "sf-deepseek-r1": "Pro/deepseek-ai/DeepSeek-R1";
30
- /** SiliconFlow — DeepSeek V3 (fast, capable) */
31
- readonly "sf-deepseek-v3": "deepseek-ai/DeepSeek-V3";
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 };
@@ -1,8 +1,10 @@
1
1
  import {
2
2
  models,
3
- resolveModel
4
- } from "../chunk-5JZJ5KMC.js";
3
+ resolveModel,
4
+ toAi302ModelId
5
+ } from "../chunk-HVLFZW6E.js";
5
6
  export {
6
7
  models,
7
- resolveModel
8
+ resolveModel,
9
+ toAi302ModelId
8
10
  };
@@ -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;
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  createEmbeddingModel,
3
3
  createModel
4
- } from "../chunk-RLWM437Q.js";
5
- import "../chunk-NVPE5EDI.js";
6
- import "../chunk-5JZJ5KMC.js";
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
@@ -1,4 +1,4 @@
1
- import { d as AgentTool } from './types-NtgB3pch.js';
1
+ import { d as AgentTool } from './types-BytC-HfQ.js';
2
2
 
3
3
  /**
4
4
  * Built-in tool registry for agents.
@@ -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, PipelineStep as P, RouterConfig as R, TokenUsage as T, AgentContext as a, AgentResponse as b, AgentConfig as c, AgentTool as d, AgentUsageEvent as e, ToolCallResult as f };
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": "1.1.1",
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": "./src/index.ts",
15
- "types": "./src/index.ts",
16
+ "main": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
16
18
  "exports": {
17
- ".": "./src/index.ts",
18
- "./tools": "./src/tools.ts",
19
- "./providers/vercel-ai": "./src/providers/vercel-ai.ts",
20
- "./providers/langchain": "./src/providers/langchain.ts",
21
- "./generation": "./src/generation/index.ts",
22
- "./sdk": "./src/sdk/index.ts",
23
- "./sdk/config": "./src/sdk/config.ts",
24
- "./sdk/models": "./src/sdk/models.ts",
25
- "./sdk/provider": "./src/sdk/provider.ts",
26
- "./env": "./src/env.ts",
27
- "./observability": "./src/observability.ts",
28
- "./fallback": "./src/fallback.ts"
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.1.2",
39
- "@nebutra/cache": "0.0.2",
40
- "@nebutra/logger": "0.1.1"
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": "^22.19.15",
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",
@@ -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
- CLI 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
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.5.1
8
- CLI Using tsup config: /home/runner/work/Nebutra-Sailor/Nebutra-Sailor/packages/ai/agents/tsup.config.ts
9
- CLI Target: node20
10
- CLI Cleaning output folder
11
- ESM Build start
12
- ESM dist/index.js 16.08 KB
13
- ESM dist/providers/langchain.js 536.00 B
14
- ESM dist/sdk/config.js 166.00 B
15
- ESM dist/chunk-UVL2UVVM.js 1.26 KB
16
- ESM dist/tools.js 203.00 B
17
- ESM dist/providers/vercel-ai.js 2.43 KB
18
- ESM dist/chunk-B7XWL35G.js 1.51 KB
19
- ESM dist/chunk-RDOFKRI6.js 4.71 KB
20
- ESM dist/sdk/index.js 534.00 B
21
- ESM dist/chunk-NPQECBXL.js 2.37 KB
22
- ESM dist/chunk-5LX742GP.js 7.78 KB
23
- ESM dist/sdk/provider.js 190.00 B
24
- ESM dist/sdk/models.js 102.00 B
25
- ESM dist/chunk-RLWM437Q.js 1.63 KB
26
- ESM dist/chunk-NVPE5EDI.js 1.49 KB
27
- ESM dist/chunk-5JZJ5KMC.js 1.22 KB
28
- ESM ⚡️ Build success in 48ms
29
- DTS Build start
30
- DTS ⚡️ Build success in 5575ms
31
- DTS dist/index.d.ts 19.71 KB
32
- DTS dist/tools.d.ts 724.00 B
33
- DTS dist/providers/langchain.d.ts 546.00 B
34
- DTS dist/providers/vercel-ai.d.ts 569.00 B
35
- DTS dist/sdk/index.d.ts 3.88 KB
36
- DTS dist/sdk/models.d.ts 1.73 KB
37
- DTS dist/sdk/provider.d.ts 882.00 B
38
- DTS dist/sdk/config.d.ts 1.80 KB
39
- DTS dist/agent-CahnMASx.d.ts 1.10 KB
40
- DTS dist/types-NtgB3pch.d.ts 3.02 KB
@@ -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
-  RUN  v4.1.4 /home/runner/work/Nebutra-Sailor/Nebutra-Sailor/packages/ai/agents
7
-
8
- ✓ src/__tests__/fallback-wiring.test.ts (9 tests) 235ms
9
- ✓ src/__tests__/cost-observability.test.ts (18 tests) 510ms
10
- ✓ falls through retryable errors and returns the next provider's result  335ms
11
- ✓ src/__tests__/public-api.test.ts (16 tests) 72ms
12
- ✓ src/__tests__/runtime-gateway.test.ts (3 tests) 80ms
13
- ✓ src/__tests__/generation.test.ts (7 tests) 61ms
14
-
15
-  Test Files  5 passed (5)
16
-  Tests  53 passed (53)
17
-  Start at  08:15:21
18
-  Duration  4.98s (transform 2.66s, setup 0ms, import 7.42s, tests 958ms, environment 1ms)
19
-
@@ -1,4 +0,0 @@
1
-
2
- > @nebutra/agents@1.1.1 typecheck /home/runner/work/Nebutra-Sailor/Nebutra-Sailor/packages/ai/agents
3
- > tsc --noEmit
4
-
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
@@ -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
- });