@triggerlink/sdk 0.4.6 → 0.4.8
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/README.md +3 -3
- package/dist/agent.d.ts +1 -0
- package/dist/agent.js +4 -4
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -81,9 +81,9 @@ import { createFunction } from "@triggerlink/sdk";
|
|
|
81
81
|
import { createAgent, createTool, anthropic } from "@triggerlink/sdk/agent"; // subpath import, not the main entry
|
|
82
82
|
import { z } from "zod";
|
|
83
83
|
|
|
84
|
-
// Built-in providers, zero extra installs: anthropic / openai / deepseek
|
|
85
|
-
// (plus createAnthropic / createOpenAI / createDeepSeek for custom baseURL/apiKey).
|
|
86
|
-
// Default instances read ANTHROPIC_API_KEY / OPENAI_API_KEY / DEEPSEEK_API_KEY from the env.
|
|
84
|
+
// Built-in providers, zero extra installs: anthropic / openai / deepseek / zai
|
|
85
|
+
// (plus createAnthropic / createOpenAI / createDeepSeek / createZhipu for custom baseURL/apiKey).
|
|
86
|
+
// Default instances read ANTHROPIC_API_KEY / OPENAI_API_KEY / DEEPSEEK_API_KEY / ZHIPU_API_KEY from the env.
|
|
87
87
|
// Any other AI SDK LanguageModel can still be passed as `model` directly.
|
|
88
88
|
|
|
89
89
|
// createTool is a generic factory: the zod schema's type flows into the handler's
|
package/dist/agent.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export type TextMessage = UserModelMessage | AssistantModelMessage | ToolModelMe
|
|
|
9
9
|
export { anthropic, createAnthropic } from "@ai-sdk/anthropic";
|
|
10
10
|
export { openai, createOpenAI } from "@ai-sdk/openai";
|
|
11
11
|
export { deepseek, createDeepSeek } from "@ai-sdk/deepseek";
|
|
12
|
+
export { zai, createZhipu } from "zhipu-ai-provider";
|
|
12
13
|
/** Agent 工具定义。parameters 为 zod schema;handler 入参是 schema parse 后的值。 */
|
|
13
14
|
export interface AgentTool<P = unknown, R = unknown> {
|
|
14
15
|
description: string;
|
package/dist/agent.js
CHANGED
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
// 主入口 index.ts 不得 import 本模块(§8.1),否则未装 ai 的普通用户会在 import 时崩溃。
|
|
5
5
|
import { generateText, tool, } from "ai";
|
|
6
6
|
// 内置 provider,开箱即用:默认实例从环境变量读 API key
|
|
7
|
-
// (ANTHROPIC_API_KEY / OPENAI_API_KEY / DEEPSEEK_API_KEY);
|
|
7
|
+
// (ANTHROPIC_API_KEY / OPENAI_API_KEY / DEEPSEEK_API_KEY / ZHIPU_API_KEY);
|
|
8
8
|
// 需要自定义 baseURL/apiKey/代理时用 createXxx 构造专属实例。
|
|
9
9
|
// 其余 provider 不受影响:createAgent 的 model 接受任意 AI SDK LanguageModel。
|
|
10
10
|
export { anthropic, createAnthropic } from "@ai-sdk/anthropic";
|
|
11
11
|
export { openai, createOpenAI } from "@ai-sdk/openai";
|
|
12
12
|
export { deepseek, createDeepSeek } from "@ai-sdk/deepseek";
|
|
13
|
+
export { zai, createZhipu } from "zhipu-ai-provider";
|
|
13
14
|
/**
|
|
14
15
|
* 定义一个 Agent 工具(泛型工厂):让 zod schema 的类型流到 handler 入参。
|
|
15
16
|
* 与直接写字面量等价,但获得完整的类型推断;跨 Agent 复用工具时也应使用它。
|
|
@@ -87,8 +88,7 @@ export function createAgent(opts) {
|
|
|
87
88
|
}
|
|
88
89
|
registry.set(agent.name, agent);
|
|
89
90
|
const redact = opts.redact;
|
|
90
|
-
const llmStepId = `agent/${agent.name}
|
|
91
|
-
const toolStepId = `agent/${agent.name}/tool`;
|
|
91
|
+
const llmStepId = `agent/${agent.name}`;
|
|
92
92
|
const messages = [{ role: "user", content: input }];
|
|
93
93
|
const usage = { inputTokens: 0, outputTokens: 0 };
|
|
94
94
|
const toolCalls = [];
|
|
@@ -141,7 +141,7 @@ export function createAgent(opts) {
|
|
|
141
141
|
if (!def) {
|
|
142
142
|
throw new Error(`agent "${agent.name}": model called unknown tool "${call.toolName}"`);
|
|
143
143
|
}
|
|
144
|
-
const output = await step.run(
|
|
144
|
+
const output = await step.run(`agent/${agent.name}/${call.toolName}`, async () => {
|
|
145
145
|
const out = await def.handler(def.parameters.parse(call.input));
|
|
146
146
|
return redact
|
|
147
147
|
? redact(out, { kind: "tool", iteration: i, toolName: call.toolName })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@triggerlink/sdk",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.8",
|
|
4
4
|
"description": "TriggerLink TypeScript SDK: durable, crash-recoverable functions for Next.js / Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"triggerlink",
|
|
@@ -59,8 +59,9 @@
|
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@ai-sdk/anthropic": "^4.0.39",
|
|
62
|
-
"@ai-sdk/deepseek": "^3.0.
|
|
62
|
+
"@ai-sdk/deepseek": "^3.0.32",
|
|
63
63
|
"@ai-sdk/openai": "^4.0.42",
|
|
64
|
-
"ai": "^7.0.66"
|
|
64
|
+
"ai": "^7.0.66",
|
|
65
|
+
"zhipu-ai-provider": "^0.4.0"
|
|
65
66
|
}
|
|
66
67
|
}
|