@triggerlink/sdk 0.4.2 → 0.4.3

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 CHANGED
@@ -122,6 +122,10 @@ Notes:
122
122
  *L + T* platform callbacks (one per step). Each step appears in the dashboard run detail
123
123
  with its output — per-call tracing and token usage for free.
124
124
  - **Multi-tool responses** are executed sequentially in array order, one step each.
125
+ - **Structured tool outputs**: `AgentResult.toolCalls` lists every tool execution of the run
126
+ (`{ toolCallId, toolName, input, output }`, in order; rebuilt from memos on recovery).
127
+ This covers the "done tool writes to shared state" pattern from agent frameworks like
128
+ AgentKit — read the tool's output here instead of parsing the final text.
125
129
  - **`redact` hook** (optional): transforms each step's output inside `step.run` before
126
130
  persistence, e.g. to strip secrets or PII from memos. It must be deterministic and
127
131
  replay-safe — the memo is what the model sees of its own prior turns after a crash-resume:
package/dist/agent.d.ts CHANGED
@@ -52,6 +52,20 @@ export interface AgentResult {
52
52
  inputTokens: number;
53
53
  outputTokens: number;
54
54
  };
55
+ /**
56
+ * 本次运行的全部工具执行记录(按执行顺序,含结构化输出)。
57
+ * 覆盖 AgentKit 的 "done 工具写 state.kv" 模式:函数代码从这里的 output 读取
58
+ * 工具产出,无需解析最终文本。恢复重放时 memo 命中路径同样重建该列表。
59
+ */
60
+ toolCalls: AgentToolCallRecord[];
61
+ }
62
+ /** 一次工具执行的记录。 */
63
+ export interface AgentToolCallRecord {
64
+ toolCallId: string;
65
+ toolName: string;
66
+ input: unknown;
67
+ /** 工具的返回值(redact 钩子启用时为脱敏后的值——与模型所见一致) */
68
+ output: unknown;
55
69
  }
56
70
  export interface Agent {
57
71
  readonly name: string;
package/dist/agent.js CHANGED
@@ -75,6 +75,7 @@ export function createAgent(opts) {
75
75
  const toolStepId = `agent/${agent.name}/tool`;
76
76
  const messages = [{ role: "user", content: input }];
77
77
  const usage = { inputTokens: 0, outputTokens: 0 };
78
+ const toolCalls = [];
78
79
  for (let i = 0;; i++) {
79
80
  if (i >= maxIterations) {
80
81
  throw new Error(`agent "${agent.name}": maxIterations (${maxIterations}) exceeded`);
@@ -105,7 +106,7 @@ export function createAgent(opts) {
105
106
  usage.outputTokens += llmMemo.usage.outputTokens ?? 0;
106
107
  messages.push(...llmMemo.responseMessages);
107
108
  if (llmMemo.toolCalls.length === 0) {
108
- return { text: llmMemo.text, iterations: i + 1, usage };
109
+ return { text: llmMemo.text, iterations: i + 1, usage, toolCalls };
109
110
  }
110
111
  // 并行 tool call 顺序执行(数组序),每个一个 durable step(§5.3)
111
112
  for (const call of llmMemo.toolCalls) {
@@ -119,6 +120,8 @@ export function createAgent(opts) {
119
120
  ? redact(out, { kind: "tool", iteration: i, toolName: call.toolName })
120
121
  : out;
121
122
  });
123
+ // memo 命中时 step.run 直接返回缓存值,重放路径同样补全记录
124
+ toolCalls.push({ toolCallId: call.toolCallId, toolName: call.toolName, input: call.input, output });
122
125
  const toolMsg = {
123
126
  role: "tool",
124
127
  content: [
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.2";
3
+ export declare const sdkVersion = "triggerlink-ts/0.4.3";
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.2";
4
+ export const sdkVersion = "triggerlink-ts/0.4.3";
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.2",
3
+ "version": "0.4.3",
4
4
  "description": "TriggerLink TypeScript SDK: durable, crash-recoverable functions for Next.js / Node.js",
5
5
  "keywords": [
6
6
  "triggerlink",