@triggerlink/sdk 0.4.0 → 0.4.1
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 +8 -4
- package/dist/agent.d.ts +3 -0
- package/dist/agent.js +7 -0
- package/dist/serve.d.ts +1 -1
- package/dist/serve.js +1 -1
- package/package.json +10 -6
package/README.md
CHANGED
|
@@ -73,15 +73,19 @@ Built on the [Vercel AI SDK](https://github.com/vercel/ai) for multi-provider
|
|
|
73
73
|
support; design details in [`docs/agent-design.md`](../docs/agent-design.md).
|
|
74
74
|
|
|
75
75
|
```bash
|
|
76
|
-
npm install @triggerlink/sdk
|
|
76
|
+
npm install @triggerlink/sdk zod # zod is for tool schemas; ai + providers are bundled
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
```ts
|
|
80
80
|
import { createFunction } from "@triggerlink/sdk";
|
|
81
|
-
import { createAgent } from "@triggerlink/sdk/agent"; // subpath import, not the main entry
|
|
82
|
-
import { anthropic } from "@ai-sdk/anthropic";
|
|
81
|
+
import { createAgent, anthropic } from "@triggerlink/sdk/agent"; // subpath import, not the main entry
|
|
83
82
|
import { z } from "zod";
|
|
84
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.
|
|
87
|
+
// Any other AI SDK LanguageModel can still be passed as `model` directly.
|
|
88
|
+
|
|
85
89
|
const researcher = createAgent({
|
|
86
90
|
name: "researcher", // stable ID, used in memo keys — do not rename casually
|
|
87
91
|
model: anthropic("claude-sonnet-4-5"), // any AI SDK LanguageModel
|
|
@@ -123,7 +127,7 @@ Notes:
|
|
|
123
127
|
callback timeout (5 minutes by default); two different agents in one function must have
|
|
124
128
|
different `name`s; changing the tool set or loop structure between retries of the same run
|
|
125
129
|
can misalign memo keys (changing prompt text is safe).
|
|
126
|
-
-
|
|
130
|
+
- `ai` and the three built-in providers are regular dependencies of the SDK (bundled, no extra install); `zod` is an optional peer dependency — install it if you define tool schemas.
|
|
127
131
|
|
|
128
132
|
## Sending events (any TS code, modeled after Inngest's `inngest.send`)
|
|
129
133
|
|
package/dist/agent.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { type LanguageModel } from "ai";
|
|
2
2
|
import type { ZodType } from "zod";
|
|
3
3
|
import type { StepTool } from "./step.js";
|
|
4
|
+
export { anthropic, createAnthropic } from "@ai-sdk/anthropic";
|
|
5
|
+
export { openai, createOpenAI } from "@ai-sdk/openai";
|
|
6
|
+
export { deepseek, createDeepSeek } from "@ai-sdk/deepseek";
|
|
4
7
|
/** Agent 工具定义。parameters 为 zod schema;handler 入参是 schema parse 后的值。 */
|
|
5
8
|
export interface AgentTool<P = unknown, R = unknown> {
|
|
6
9
|
description: string;
|
package/dist/agent.js
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
// 本模块只通过子路径 @triggerlink/sdk/agent 导出——ai/zod 是 optional peer 依赖,
|
|
4
4
|
// 主入口 index.ts 不得 import 本模块(§8.1),否则未装 ai 的普通用户会在 import 时崩溃。
|
|
5
5
|
import { generateText, tool, } from "ai";
|
|
6
|
+
// 内置 provider,开箱即用:默认实例从环境变量读 API key
|
|
7
|
+
// (ANTHROPIC_API_KEY / OPENAI_API_KEY / DEEPSEEK_API_KEY);
|
|
8
|
+
// 需要自定义 baseURL/apiKey/代理时用 createXxx 构造专属实例。
|
|
9
|
+
// 其余 provider 不受影响:createAgent 的 model 接受任意 AI SDK LanguageModel。
|
|
10
|
+
export { anthropic, createAnthropic } from "@ai-sdk/anthropic";
|
|
11
|
+
export { openai, createOpenAI } from "@ai-sdk/openai";
|
|
12
|
+
export { deepseek, createDeepSeek } from "@ai-sdk/deepseek";
|
|
6
13
|
/** redact 钩子可能破坏 llm memo 结构;此处 fail loud,不让坏 memo 落库或参与历史重建(§5.7)。 */
|
|
7
14
|
function assertLlmMemoShape(m, name) {
|
|
8
15
|
const o = m;
|
package/dist/serve.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Client } from "./client.js";
|
|
2
2
|
import type { TriggerFunction } from "./function.js";
|
|
3
|
-
export declare const sdkVersion = "triggerlink-ts/0.4.
|
|
3
|
+
export declare const sdkVersion = "triggerlink-ts/0.4.1";
|
|
4
4
|
export declare const SIGNATURE_HEADER = "x-triggerlink-signature";
|
|
5
5
|
export interface ServeOptions {
|
|
6
6
|
client: Client;
|
package/dist/serve.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ExecCtx, StepInterrupt } from "./execx.js";
|
|
2
2
|
import { createStepTool, errMessage } from "./step.js";
|
|
3
3
|
import { verifySignature } from "./sign.js";
|
|
4
|
-
export const sdkVersion = "triggerlink-ts/0.4.
|
|
4
|
+
export const sdkVersion = "triggerlink-ts/0.4.1";
|
|
5
5
|
export const SIGNATURE_HEADER = "x-triggerlink-signature";
|
|
6
6
|
const MAX_BODY = 10 << 20; // 10 MB,与平台一致
|
|
7
7
|
function json(data, status = 200) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@triggerlink/sdk",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "TriggerLink TypeScript SDK: durable, crash-recoverable functions for Next.js / Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"triggerlink",
|
|
@@ -36,6 +36,9 @@
|
|
|
36
36
|
"prepublishOnly": "npm run build"
|
|
37
37
|
},
|
|
38
38
|
"license": "MIT",
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"registry": "https://registry.npmjs.org"
|
|
41
|
+
},
|
|
39
42
|
"repository": {
|
|
40
43
|
"type": "git",
|
|
41
44
|
"url": "git+https://github.com/bearalise/triggerlink.git",
|
|
@@ -43,20 +46,21 @@
|
|
|
43
46
|
},
|
|
44
47
|
"devDependencies": {
|
|
45
48
|
"@types/node": "^22.0.0",
|
|
46
|
-
"ai": "^7.0.66",
|
|
47
49
|
"typescript": "^5.5.0",
|
|
48
50
|
"zod": "^4.4.3"
|
|
49
51
|
},
|
|
50
52
|
"peerDependencies": {
|
|
51
|
-
"ai": "^7.0.0",
|
|
52
53
|
"zod": "^3.25.76 || ^4.1.8"
|
|
53
54
|
},
|
|
54
55
|
"peerDependenciesMeta": {
|
|
55
|
-
"ai": {
|
|
56
|
-
"optional": true
|
|
57
|
-
},
|
|
58
56
|
"zod": {
|
|
59
57
|
"optional": true
|
|
60
58
|
}
|
|
59
|
+
},
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"@ai-sdk/anthropic": "^4.0.39",
|
|
62
|
+
"@ai-sdk/deepseek": "^3.0.28",
|
|
63
|
+
"@ai-sdk/openai": "^4.0.42",
|
|
64
|
+
"ai": "^7.0.66"
|
|
61
65
|
}
|
|
62
66
|
}
|