@tansr/protocol 0.2.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 (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +74 -0
  3. package/dist/canonical/common.d.ts +37 -0
  4. package/dist/canonical/common.js +149 -0
  5. package/dist/canonical/digest.d.ts +12 -0
  6. package/dist/canonical/digest.js +58 -0
  7. package/dist/canonical/encode.d.ts +15 -0
  8. package/dist/canonical/encode.js +157 -0
  9. package/dist/canonical/errors.d.ts +81 -0
  10. package/dist/canonical/errors.js +89 -0
  11. package/dist/canonical/index.d.ts +21 -0
  12. package/dist/canonical/index.js +21 -0
  13. package/dist/canonical/parse.d.ts +21 -0
  14. package/dist/canonical/parse.js +295 -0
  15. package/dist/client.d.ts +42 -0
  16. package/dist/client.js +1 -0
  17. package/dist/config.d.ts +4990 -0
  18. package/dist/config.js +657 -0
  19. package/dist/daemon.d.ts +70 -0
  20. package/dist/daemon.js +48 -0
  21. package/dist/events.d.ts +2152 -0
  22. package/dist/events.js +625 -0
  23. package/dist/governance.d.ts +445 -0
  24. package/dist/governance.js +183 -0
  25. package/dist/headless.d.ts +97 -0
  26. package/dist/headless.js +39 -0
  27. package/dist/identity.d.ts +96 -0
  28. package/dist/identity.js +45 -0
  29. package/dist/index.d.ts +525 -0
  30. package/dist/index.js +529 -0
  31. package/dist/ir.d.ts +1418 -0
  32. package/dist/ir.js +283 -0
  33. package/dist/journal.d.ts +297 -0
  34. package/dist/journal.js +150 -0
  35. package/dist/media.d.ts +563 -0
  36. package/dist/media.js +190 -0
  37. package/dist/metering.d.ts +225 -0
  38. package/dist/metering.js +90 -0
  39. package/dist/orchestration.d.ts +1551 -0
  40. package/dist/orchestration.js +333 -0
  41. package/dist/redact-patterns.d.ts +49 -0
  42. package/dist/redact-patterns.js +141 -0
  43. package/dist/storage.d.ts +507 -0
  44. package/dist/storage.js +110 -0
  45. package/dist/tool-result-artifact.d.ts +257 -0
  46. package/dist/tool-result-artifact.js +263 -0
  47. package/package.json +30 -0
@@ -0,0 +1,1551 @@
1
+ /**
2
+ * contract-v0.9 — 编排域契约(T-O0,二期 W0 契约周)。
3
+ *
4
+ * 设计依据:doc/rfc/contract-v0.9.md(会签 2026-07-26,采纳 9/缓议 3)、
5
+ * 《10》§1.3(编排选型定论:借鉴 Temporal 语义自建)、《07》§7.6(任务对象
6
+ * 三层分离:playbook 定义 / run 实例 / step journal 事实源)、
7
+ * spikes/orchestrator-journal PoC 两条发现——①不可重试错误必须是
8
+ * RetryPolicy 一等公民;②补偿体事实源必须是 Playbook 静态定义。
9
+ *
10
+ * 与会话面(events.ts)的关系:**平行不复用**——EventEnvelope 的 sessionId
11
+ * 必填而 Run 不是会话;编排面以 OrchestrationEnvelope 包络,消费端(tansrd
12
+ * SSE / 控制台 / 审计)按 StepJournalKind 封闭词表穷举渲染。
13
+ * 本模块为纯增量新命名空间,一期 schema 零触碰;包络 `v` 维持 "v0"。
14
+ */
15
+ import { z } from 'zod';
16
+ /** 编排面事件包络(与会话面 EventEnvelope 平行;seq 单调支持断线重放) */
17
+ export declare const OrchestrationEnvelopeSchema: z.ZodObject<{
18
+ runId: z.ZodString;
19
+ /** run 内单调递增序号 */
20
+ seq: z.ZodNumber;
21
+ /** UTC 毫秒时间戳 */
22
+ ts: z.ZodNumber;
23
+ /** 协议版本,当前 "v0" */
24
+ v: z.ZodString;
25
+ /** 事件产生源:orchestrator / trigger / approval / pool */
26
+ source: z.ZodString;
27
+ }, "strip", z.ZodTypeAny, {
28
+ seq: number;
29
+ ts: number;
30
+ v: string;
31
+ source: string;
32
+ runId: string;
33
+ }, {
34
+ seq: number;
35
+ ts: number;
36
+ v: string;
37
+ source: string;
38
+ runId: string;
39
+ }>;
40
+ export type OrchestrationEnvelope = z.infer<typeof OrchestrationEnvelopeSchema>;
41
+ export declare const RunStatusSchema: z.ZodEnum<["running", "completed", "failed", "compensated"]>;
42
+ export type RunStatus = z.infer<typeof RunStatusSchema>;
43
+ /**
44
+ * runs 表形态(durable;《07》§7.6①:定义/实例分离 + revision CAS + 幂等键)。
45
+ * revision:Update/CAS 乐观并发位,每次受控变更 +1,旧 revision 写入失配即拒;
46
+ * idempotencyKey:触发去重(存储层 UNIQUE),同键重复触发不建新 run;
47
+ * workspaceId:三期多租户预埋(《15》§9-1),二期单租户可缺省。
48
+ */
49
+ export declare const RunRecordSchema: z.ZodObject<{
50
+ runId: z.ZodString;
51
+ playbookId: z.ZodString;
52
+ playbookVersion: z.ZodOptional<z.ZodString>;
53
+ status: z.ZodEnum<["running", "completed", "failed", "compensated"]>;
54
+ revision: z.ZodNumber;
55
+ idempotencyKey: z.ZodOptional<z.ZodString>;
56
+ workspaceId: z.ZodOptional<z.ZodString>;
57
+ createdAt: z.ZodNumber;
58
+ updatedAt: z.ZodNumber;
59
+ /**
60
+ * 归因标签(contract-v0.10,RFC-WB-2):createRun 入参透传,run.created
61
+ * payload 同步携带——T-Q3 路由规则 labels 条件与 T-Q2 组织配额三级归因
62
+ * 的取数位。纯增量可选,旧记录不带仍合法。
63
+ */
64
+ labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
65
+ /**
66
+ * Run 分段链(contract-v0.10,RFC-WB-3):continueAsNew 的父 run 标识
67
+ * 转正为一等列(此前为 run.created payload 私约);逐级追溯分段链条。
68
+ */
69
+ parentRunId: z.ZodOptional<z.ZodString>;
70
+ }, "strip", z.ZodTypeAny, {
71
+ status: "completed" | "running" | "failed" | "compensated";
72
+ runId: string;
73
+ playbookId: string;
74
+ revision: number;
75
+ createdAt: number;
76
+ updatedAt: number;
77
+ playbookVersion?: string | undefined;
78
+ idempotencyKey?: string | undefined;
79
+ workspaceId?: string | undefined;
80
+ labels?: Record<string, string> | undefined;
81
+ parentRunId?: string | undefined;
82
+ }, {
83
+ status: "completed" | "running" | "failed" | "compensated";
84
+ runId: string;
85
+ playbookId: string;
86
+ revision: number;
87
+ createdAt: number;
88
+ updatedAt: number;
89
+ playbookVersion?: string | undefined;
90
+ idempotencyKey?: string | undefined;
91
+ workspaceId?: string | undefined;
92
+ labels?: Record<string, string> | undefined;
93
+ parentRunId?: string | undefined;
94
+ }>;
95
+ export type RunRecord = z.infer<typeof RunRecordSchema>;
96
+ /** step journal kind 封闭词表(八族;消费端按 `.` 前缀分组渲染) */
97
+ export declare const StepJournalKindSchema: z.ZodEnum<["run.created", "run.completed", "run.failed", "run.compensated", "step.scheduled", "step.started", "step.attempt_failed", "step.completed", "step.failed", "saga.registered", "saga.compensated", "saga.skipped", "timer.created", "timer.fired", "signal.received", "update.applied", "trigger.fired", "approval.requested", "approval.decided"]>;
98
+ export type StepJournalKind = z.infer<typeof StepJournalKindSchema>;
99
+ /**
100
+ * journal 表形态(append-only 事实源;崩溃重放的唯一依据)。
101
+ * payload 超限语义:写入方在 append 前按 MAX_STEP_PAYLOAD_BYTES 校验,超限抛
102
+ * **不可重试**错误并提示改走 artifact 引用;schema 不内嵌字节校验(每读一次
103
+ * refine 的代价不值,写入口统一把关)。bytes 供截断建议线核算。
104
+ */
105
+ export declare const StepJournalRecordSchema: z.ZodObject<{
106
+ /** 存储层 AUTOINCREMENT,run 内全序 */
107
+ seq: z.ZodNumber;
108
+ runId: z.ZodString;
109
+ kind: z.ZodEnum<["run.created", "run.completed", "run.failed", "run.compensated", "step.scheduled", "step.started", "step.attempt_failed", "step.completed", "step.failed", "saga.registered", "saga.compensated", "saga.skipped", "timer.created", "timer.fired", "signal.received", "update.applied", "trigger.fired", "approval.requested", "approval.decided"]>;
110
+ /** 引用位:stepId / timerId / dedupKey…按 kind 语义解释 */
111
+ refId: z.ZodOptional<z.ZodString>;
112
+ payload: z.ZodUnknown;
113
+ bytes: z.ZodNumber;
114
+ ts: z.ZodNumber;
115
+ }, "strip", z.ZodTypeAny, {
116
+ kind: "run.created" | "run.completed" | "run.failed" | "run.compensated" | "step.scheduled" | "step.started" | "step.attempt_failed" | "step.completed" | "step.failed" | "saga.registered" | "saga.compensated" | "saga.skipped" | "timer.created" | "timer.fired" | "signal.received" | "update.applied" | "trigger.fired" | "approval.requested" | "approval.decided";
117
+ seq: number;
118
+ ts: number;
119
+ runId: string;
120
+ bytes: number;
121
+ payload?: unknown;
122
+ refId?: string | undefined;
123
+ }, {
124
+ kind: "run.created" | "run.completed" | "run.failed" | "run.compensated" | "step.scheduled" | "step.started" | "step.attempt_failed" | "step.completed" | "step.failed" | "saga.registered" | "saga.compensated" | "saga.skipped" | "timer.created" | "timer.fired" | "signal.received" | "update.applied" | "trigger.fired" | "approval.requested" | "approval.decided";
125
+ seq: number;
126
+ ts: number;
127
+ runId: string;
128
+ bytes: number;
129
+ payload?: unknown;
130
+ refId?: string | undefined;
131
+ }>;
132
+ export type StepJournalRecord = z.infer<typeof StepJournalRecordSchema>;
133
+ /** 持久 Timer 最小落盘形态(fired 翻位 = 恰好一次触发的 CAS 依据) */
134
+ export declare const TimerRecordSchema: z.ZodObject<{
135
+ timerId: z.ZodString;
136
+ runId: z.ZodString;
137
+ /** UTC 毫秒;到点由 tick 扫描触发,崩溃重启后依然有效 */
138
+ fireAt: z.ZodNumber;
139
+ fired: z.ZodBoolean;
140
+ }, "strip", z.ZodTypeAny, {
141
+ runId: string;
142
+ timerId: string;
143
+ fireAt: number;
144
+ fired: boolean;
145
+ }, {
146
+ runId: string;
147
+ timerId: string;
148
+ fireAt: number;
149
+ fired: boolean;
150
+ }>;
151
+ export type TimerRecord = z.infer<typeof TimerRecordSchema>;
152
+ /**
153
+ * 重试策略(Temporal 默认参数族)。nonRetryableErrorTypes 为 PoC 发现①:
154
+ * 确定性错误(schema 校验失败/载荷超限/权限拒绝)不标记即无限重试挂死。
155
+ * 默认不可重试错误类的运行时约定(进 T-O1 DoD):PayloadTooLarge /
156
+ * SchemaValidation / PermissionDenied。
157
+ */
158
+ export declare const RetryPolicySchema: z.ZodObject<{
159
+ initialMs: z.ZodDefault<z.ZodNumber>;
160
+ backoff: z.ZodDefault<z.ZodNumber>;
161
+ maxIntervalMs: z.ZodDefault<z.ZodNumber>;
162
+ /** 缺席 = 无限重试(仅对可重试错误) */
163
+ maxAttempts: z.ZodOptional<z.ZodNumber>;
164
+ /**
165
+ * 重试总时长上限(毫秒;contract-v0.13,RFC-WE-4)。与 maxAttempts/
166
+ * maxIntervalMs 构成三上限族;「effectful 步强制显式上限」属编译/部署
167
+ * 策略(T-G4),schema 只承载可表达性。
168
+ */
169
+ maxTotalMs: z.ZodOptional<z.ZodNumber>;
170
+ nonRetryableErrorTypes: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
171
+ }, "strip", z.ZodTypeAny, {
172
+ initialMs: number;
173
+ backoff: number;
174
+ maxIntervalMs: number;
175
+ nonRetryableErrorTypes: string[];
176
+ maxAttempts?: number | undefined;
177
+ maxTotalMs?: number | undefined;
178
+ }, {
179
+ maxAttempts?: number | undefined;
180
+ initialMs?: number | undefined;
181
+ backoff?: number | undefined;
182
+ maxIntervalMs?: number | undefined;
183
+ maxTotalMs?: number | undefined;
184
+ nonRetryableErrorTypes?: string[] | undefined;
185
+ }>;
186
+ export type RetryPolicy = z.infer<typeof RetryPolicySchema>;
187
+ /** 跨层消息自律线(《10》§1.1 官方数值依据;与内核工具大输出落盘线同源) */
188
+ export declare const MAX_STEP_PAYLOAD_BYTES: number;
189
+ /** journal 截断建议线:超过即建议 checkpoint + 新 run 续接(硬线由引擎执行) */
190
+ export declare const STEP_JOURNAL_TRUNCATION: {
191
+ readonly maxEvents: 4096;
192
+ readonly maxBytes: number;
193
+ };
194
+ /**
195
+ * 触发源:cron 定时 / webhook 回调(HMAC 验签)/ webhook-internal 可信内网
196
+ * 回调(无验签,网络边界负责)/ api 显式调用。
197
+ *
198
+ * contract-v0.13(RFC-WE-1,P2-R11 + P-A 红队 P0-10):webhook 的 secretRef
199
+ * 自 optional 收紧为必填——「忘了配 secretRef 的裸 webhook」第三态从契约面
200
+ * 消灭;确需免验签的内网集成显式声明 `webhook-internal`(tansrd 投递面
201
+ * fail-closed:来源白名单 allowFrom 为空时一律 403)。存量 Playbook 属
202
+ * 自觉破坏面,迁移条款见 doc/rfc/contract-v0.13.md §2.1。
203
+ */
204
+ export declare const TriggerSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
205
+ type: z.ZodLiteral<"cron">;
206
+ expr: z.ZodString;
207
+ tz: z.ZodOptional<z.ZodString>;
208
+ }, "strip", z.ZodTypeAny, {
209
+ type: "cron";
210
+ expr: string;
211
+ tz?: string | undefined;
212
+ }, {
213
+ type: "cron";
214
+ expr: string;
215
+ tz?: string | undefined;
216
+ }>, z.ZodObject<{
217
+ type: z.ZodLiteral<"webhook">;
218
+ path: z.ZodString;
219
+ /** 秘密引用名(解析走秘密管理,值绝不入 Playbook);v0.13 起必填 */
220
+ secretRef: z.ZodString;
221
+ }, "strip", z.ZodTypeAny, {
222
+ path: string;
223
+ type: "webhook";
224
+ secretRef: string;
225
+ }, {
226
+ path: string;
227
+ type: "webhook";
228
+ secretRef: string;
229
+ }>, z.ZodObject<{
230
+ type: z.ZodLiteral<"webhook-internal">;
231
+ path: z.ZodString;
232
+ }, "strip", z.ZodTypeAny, {
233
+ path: string;
234
+ type: "webhook-internal";
235
+ }, {
236
+ path: string;
237
+ type: "webhook-internal";
238
+ }>, z.ZodObject<{
239
+ type: z.ZodLiteral<"api">;
240
+ }, "strip", z.ZodTypeAny, {
241
+ type: "api";
242
+ }, {
243
+ type: "api";
244
+ }>]>;
245
+ export type Trigger = z.infer<typeof TriggerSchema>;
246
+ /**
247
+ * webhook 入站签名 v2 线路契约(contract-v0.13,RFC-WE-1)。外部发送方按此
248
+ * 构造;orchestrator 验签器与 tansrd 路由消费同一常量:
249
+ *
250
+ * canonical = "tansr-webhook-v2\n" + UPPER(method) + "\n" + path + "\n"
251
+ * + timestampMs + "\n" + nonce + "\n" + hex(SHA-256(rawBody))
252
+ * X-Tansr-Signature: v2=<hex(HMAC-SHA256(secret, canonical))>
253
+ *
254
+ * - path = 请求行路径,不含 query(入站处理器不消费 query,未签名 query
255
+ * 惰性无害);X-Tansr-Timestamp / X-Tansr-Nonce 在 v2 下必带——时间戳
256
+ * 容差窗恒强制,nonce 进签名体(重放者无法改 nonce 换去重键);
257
+ * - 旧 v1 形态(`sha256=<hex>` 只签 raw body)默认拒绝,tansrd
258
+ * `webhook.inbound.allowLegacySignature=true` 为迁移窗旋钮。
259
+ */
260
+ export declare const WEBHOOK_SIGNATURE_V2: {
261
+ /** 签名头值前缀(`v2=<hex>`) */
262
+ readonly prefix: "v2=";
263
+ /** canonical 串首行常量 */
264
+ readonly canonicalPrefix: "tansr-webhook-v2";
265
+ readonly headers: {
266
+ readonly signature: "x-tansr-signature";
267
+ readonly timestamp: "x-tansr-timestamp";
268
+ readonly nonce: "x-tansr-nonce";
269
+ };
270
+ };
271
+ /** 人审步策略:超时三出口;escalate 必须给出升级链 */
272
+ export declare const ApprovalPolicySchema: z.ZodEffects<z.ZodObject<{
273
+ /** 审批人/组标识(语义由部署侧目录服务解释) */
274
+ approvers: z.ZodArray<z.ZodString, "many">;
275
+ timeoutMs: z.ZodNumber;
276
+ onTimeout: z.ZodEnum<["deny", "escalate", "degrade"]>;
277
+ escalateTo: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
278
+ }, "strip", z.ZodTypeAny, {
279
+ timeoutMs: number;
280
+ approvers: string[];
281
+ onTimeout: "deny" | "escalate" | "degrade";
282
+ escalateTo?: string[] | undefined;
283
+ }, {
284
+ timeoutMs: number;
285
+ approvers: string[];
286
+ onTimeout: "deny" | "escalate" | "degrade";
287
+ escalateTo?: string[] | undefined;
288
+ }>, {
289
+ timeoutMs: number;
290
+ approvers: string[];
291
+ onTimeout: "deny" | "escalate" | "degrade";
292
+ escalateTo?: string[] | undefined;
293
+ }, {
294
+ timeoutMs: number;
295
+ approvers: string[];
296
+ onTimeout: "deny" | "escalate" | "degrade";
297
+ escalateTo?: string[] | undefined;
298
+ }>;
299
+ export type ApprovalPolicy = z.infer<typeof ApprovalPolicySchema>;
300
+ /**
301
+ * 补偿体 = 内联步定义(无 id,寻址 `<stepId>#compensate`)。PoC 发现②:
302
+ * 补偿事实源必须是 Playbook 静态定义——运行期注册的内存补偿表跨崩溃即失。
303
+ */
304
+ export declare const CompensationBodySchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
305
+ type: z.ZodLiteral<"agent">;
306
+ profile: z.ZodString;
307
+ prompt: z.ZodString;
308
+ model: z.ZodOptional<z.ZodString>;
309
+ tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
310
+ }, "strip", z.ZodTypeAny, {
311
+ type: "agent";
312
+ profile: string;
313
+ prompt: string;
314
+ model?: string | undefined;
315
+ tools?: string[] | undefined;
316
+ }, {
317
+ type: "agent";
318
+ profile: string;
319
+ prompt: string;
320
+ model?: string | undefined;
321
+ tools?: string[] | undefined;
322
+ }>, z.ZodObject<{
323
+ type: z.ZodLiteral<"tool">;
324
+ run: z.ZodString;
325
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
326
+ }, "strip", z.ZodTypeAny, {
327
+ type: "tool";
328
+ run: string;
329
+ args?: Record<string, unknown> | undefined;
330
+ }, {
331
+ type: "tool";
332
+ run: string;
333
+ args?: Record<string, unknown> | undefined;
334
+ }>]>;
335
+ export type CompensationBody = z.infer<typeof CompensationBodySchema>;
336
+ /** 四步型:agent 智能体步 / tool 工具步 / condition 条件步 / approval 人审步 */
337
+ export declare const StepSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
338
+ type: z.ZodLiteral<"agent">;
339
+ /** AgentProfile 名(《14》§4:模型+工具面+权限+预算的命名组合) */
340
+ profile: z.ZodString;
341
+ /** 提示词模板(插值语法由 T-O3 定) */
342
+ prompt: z.ZodString;
343
+ model: z.ZodOptional<z.ZodString>;
344
+ tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
345
+ budget: z.ZodOptional<z.ZodObject<{
346
+ maxUsd: z.ZodOptional<z.ZodNumber>;
347
+ maxTotalTokens: z.ZodOptional<z.ZodNumber>;
348
+ }, "strip", z.ZodTypeAny, {
349
+ maxUsd?: number | undefined;
350
+ maxTotalTokens?: number | undefined;
351
+ }, {
352
+ maxUsd?: number | undefined;
353
+ maxTotalTokens?: number | undefined;
354
+ }>>;
355
+ compensate: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
356
+ type: z.ZodLiteral<"agent">;
357
+ profile: z.ZodString;
358
+ prompt: z.ZodString;
359
+ model: z.ZodOptional<z.ZodString>;
360
+ tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
361
+ }, "strip", z.ZodTypeAny, {
362
+ type: "agent";
363
+ profile: string;
364
+ prompt: string;
365
+ model?: string | undefined;
366
+ tools?: string[] | undefined;
367
+ }, {
368
+ type: "agent";
369
+ profile: string;
370
+ prompt: string;
371
+ model?: string | undefined;
372
+ tools?: string[] | undefined;
373
+ }>, z.ZodObject<{
374
+ type: z.ZodLiteral<"tool">;
375
+ run: z.ZodString;
376
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
377
+ }, "strip", z.ZodTypeAny, {
378
+ type: "tool";
379
+ run: string;
380
+ args?: Record<string, unknown> | undefined;
381
+ }, {
382
+ type: "tool";
383
+ run: string;
384
+ args?: Record<string, unknown> | undefined;
385
+ }>]>>;
386
+ id: z.ZodString;
387
+ dependsOn: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
388
+ when: z.ZodOptional<z.ZodString>;
389
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
390
+ retry: z.ZodOptional<z.ZodObject<{
391
+ initialMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
392
+ backoff: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
393
+ maxIntervalMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
394
+ maxAttempts: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
395
+ maxTotalMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
396
+ nonRetryableErrorTypes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
397
+ }, "strip", z.ZodTypeAny, {
398
+ maxAttempts?: number | undefined;
399
+ initialMs?: number | undefined;
400
+ backoff?: number | undefined;
401
+ maxIntervalMs?: number | undefined;
402
+ maxTotalMs?: number | undefined;
403
+ nonRetryableErrorTypes?: string[] | undefined;
404
+ }, {
405
+ maxAttempts?: number | undefined;
406
+ initialMs?: number | undefined;
407
+ backoff?: number | undefined;
408
+ maxIntervalMs?: number | undefined;
409
+ maxTotalMs?: number | undefined;
410
+ nonRetryableErrorTypes?: string[] | undefined;
411
+ }>>;
412
+ }, "strip", z.ZodTypeAny, {
413
+ type: "agent";
414
+ id: string;
415
+ profile: string;
416
+ prompt: string;
417
+ dependsOn: string[];
418
+ model?: string | undefined;
419
+ tools?: string[] | undefined;
420
+ budget?: {
421
+ maxUsd?: number | undefined;
422
+ maxTotalTokens?: number | undefined;
423
+ } | undefined;
424
+ timeoutMs?: number | undefined;
425
+ compensate?: {
426
+ type: "agent";
427
+ profile: string;
428
+ prompt: string;
429
+ model?: string | undefined;
430
+ tools?: string[] | undefined;
431
+ } | {
432
+ type: "tool";
433
+ run: string;
434
+ args?: Record<string, unknown> | undefined;
435
+ } | undefined;
436
+ when?: string | undefined;
437
+ retry?: {
438
+ maxAttempts?: number | undefined;
439
+ initialMs?: number | undefined;
440
+ backoff?: number | undefined;
441
+ maxIntervalMs?: number | undefined;
442
+ maxTotalMs?: number | undefined;
443
+ nonRetryableErrorTypes?: string[] | undefined;
444
+ } | undefined;
445
+ }, {
446
+ type: "agent";
447
+ id: string;
448
+ profile: string;
449
+ prompt: string;
450
+ model?: string | undefined;
451
+ tools?: string[] | undefined;
452
+ budget?: {
453
+ maxUsd?: number | undefined;
454
+ maxTotalTokens?: number | undefined;
455
+ } | undefined;
456
+ timeoutMs?: number | undefined;
457
+ compensate?: {
458
+ type: "agent";
459
+ profile: string;
460
+ prompt: string;
461
+ model?: string | undefined;
462
+ tools?: string[] | undefined;
463
+ } | {
464
+ type: "tool";
465
+ run: string;
466
+ args?: Record<string, unknown> | undefined;
467
+ } | undefined;
468
+ dependsOn?: string[] | undefined;
469
+ when?: string | undefined;
470
+ retry?: {
471
+ maxAttempts?: number | undefined;
472
+ initialMs?: number | undefined;
473
+ backoff?: number | undefined;
474
+ maxIntervalMs?: number | undefined;
475
+ maxTotalMs?: number | undefined;
476
+ nonRetryableErrorTypes?: string[] | undefined;
477
+ } | undefined;
478
+ }>, z.ZodObject<{
479
+ type: z.ZodLiteral<"tool">;
480
+ run: z.ZodString;
481
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
482
+ compensate: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
483
+ type: z.ZodLiteral<"agent">;
484
+ profile: z.ZodString;
485
+ prompt: z.ZodString;
486
+ model: z.ZodOptional<z.ZodString>;
487
+ tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
488
+ }, "strip", z.ZodTypeAny, {
489
+ type: "agent";
490
+ profile: string;
491
+ prompt: string;
492
+ model?: string | undefined;
493
+ tools?: string[] | undefined;
494
+ }, {
495
+ type: "agent";
496
+ profile: string;
497
+ prompt: string;
498
+ model?: string | undefined;
499
+ tools?: string[] | undefined;
500
+ }>, z.ZodObject<{
501
+ type: z.ZodLiteral<"tool">;
502
+ run: z.ZodString;
503
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
504
+ }, "strip", z.ZodTypeAny, {
505
+ type: "tool";
506
+ run: string;
507
+ args?: Record<string, unknown> | undefined;
508
+ }, {
509
+ type: "tool";
510
+ run: string;
511
+ args?: Record<string, unknown> | undefined;
512
+ }>]>>;
513
+ id: z.ZodString;
514
+ dependsOn: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
515
+ when: z.ZodOptional<z.ZodString>;
516
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
517
+ retry: z.ZodOptional<z.ZodObject<{
518
+ initialMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
519
+ backoff: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
520
+ maxIntervalMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
521
+ maxAttempts: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
522
+ maxTotalMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
523
+ nonRetryableErrorTypes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
524
+ }, "strip", z.ZodTypeAny, {
525
+ maxAttempts?: number | undefined;
526
+ initialMs?: number | undefined;
527
+ backoff?: number | undefined;
528
+ maxIntervalMs?: number | undefined;
529
+ maxTotalMs?: number | undefined;
530
+ nonRetryableErrorTypes?: string[] | undefined;
531
+ }, {
532
+ maxAttempts?: number | undefined;
533
+ initialMs?: number | undefined;
534
+ backoff?: number | undefined;
535
+ maxIntervalMs?: number | undefined;
536
+ maxTotalMs?: number | undefined;
537
+ nonRetryableErrorTypes?: string[] | undefined;
538
+ }>>;
539
+ }, "strip", z.ZodTypeAny, {
540
+ type: "tool";
541
+ id: string;
542
+ run: string;
543
+ dependsOn: string[];
544
+ args?: Record<string, unknown> | undefined;
545
+ timeoutMs?: number | undefined;
546
+ compensate?: {
547
+ type: "agent";
548
+ profile: string;
549
+ prompt: string;
550
+ model?: string | undefined;
551
+ tools?: string[] | undefined;
552
+ } | {
553
+ type: "tool";
554
+ run: string;
555
+ args?: Record<string, unknown> | undefined;
556
+ } | undefined;
557
+ when?: string | undefined;
558
+ retry?: {
559
+ maxAttempts?: number | undefined;
560
+ initialMs?: number | undefined;
561
+ backoff?: number | undefined;
562
+ maxIntervalMs?: number | undefined;
563
+ maxTotalMs?: number | undefined;
564
+ nonRetryableErrorTypes?: string[] | undefined;
565
+ } | undefined;
566
+ }, {
567
+ type: "tool";
568
+ id: string;
569
+ run: string;
570
+ args?: Record<string, unknown> | undefined;
571
+ timeoutMs?: number | undefined;
572
+ compensate?: {
573
+ type: "agent";
574
+ profile: string;
575
+ prompt: string;
576
+ model?: string | undefined;
577
+ tools?: string[] | undefined;
578
+ } | {
579
+ type: "tool";
580
+ run: string;
581
+ args?: Record<string, unknown> | undefined;
582
+ } | undefined;
583
+ dependsOn?: string[] | undefined;
584
+ when?: string | undefined;
585
+ retry?: {
586
+ maxAttempts?: number | undefined;
587
+ initialMs?: number | undefined;
588
+ backoff?: number | undefined;
589
+ maxIntervalMs?: number | undefined;
590
+ maxTotalMs?: number | undefined;
591
+ nonRetryableErrorTypes?: string[] | undefined;
592
+ } | undefined;
593
+ }>, z.ZodObject<{
594
+ type: z.ZodLiteral<"condition">;
595
+ /** 布尔表达式串;求值结果进 journal,下游以 when 引用 */
596
+ expr: z.ZodString;
597
+ id: z.ZodString;
598
+ dependsOn: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
599
+ when: z.ZodOptional<z.ZodString>;
600
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
601
+ retry: z.ZodOptional<z.ZodObject<{
602
+ initialMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
603
+ backoff: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
604
+ maxIntervalMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
605
+ maxAttempts: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
606
+ maxTotalMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
607
+ nonRetryableErrorTypes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
608
+ }, "strip", z.ZodTypeAny, {
609
+ maxAttempts?: number | undefined;
610
+ initialMs?: number | undefined;
611
+ backoff?: number | undefined;
612
+ maxIntervalMs?: number | undefined;
613
+ maxTotalMs?: number | undefined;
614
+ nonRetryableErrorTypes?: string[] | undefined;
615
+ }, {
616
+ maxAttempts?: number | undefined;
617
+ initialMs?: number | undefined;
618
+ backoff?: number | undefined;
619
+ maxIntervalMs?: number | undefined;
620
+ maxTotalMs?: number | undefined;
621
+ nonRetryableErrorTypes?: string[] | undefined;
622
+ }>>;
623
+ }, "strip", z.ZodTypeAny, {
624
+ type: "condition";
625
+ id: string;
626
+ expr: string;
627
+ dependsOn: string[];
628
+ timeoutMs?: number | undefined;
629
+ when?: string | undefined;
630
+ retry?: {
631
+ maxAttempts?: number | undefined;
632
+ initialMs?: number | undefined;
633
+ backoff?: number | undefined;
634
+ maxIntervalMs?: number | undefined;
635
+ maxTotalMs?: number | undefined;
636
+ nonRetryableErrorTypes?: string[] | undefined;
637
+ } | undefined;
638
+ }, {
639
+ type: "condition";
640
+ id: string;
641
+ expr: string;
642
+ timeoutMs?: number | undefined;
643
+ dependsOn?: string[] | undefined;
644
+ when?: string | undefined;
645
+ retry?: {
646
+ maxAttempts?: number | undefined;
647
+ initialMs?: number | undefined;
648
+ backoff?: number | undefined;
649
+ maxIntervalMs?: number | undefined;
650
+ maxTotalMs?: number | undefined;
651
+ nonRetryableErrorTypes?: string[] | undefined;
652
+ } | undefined;
653
+ }>, z.ZodObject<{
654
+ type: z.ZodLiteral<"approval">;
655
+ policy: z.ZodEffects<z.ZodObject<{
656
+ /** 审批人/组标识(语义由部署侧目录服务解释) */
657
+ approvers: z.ZodArray<z.ZodString, "many">;
658
+ timeoutMs: z.ZodNumber;
659
+ onTimeout: z.ZodEnum<["deny", "escalate", "degrade"]>;
660
+ escalateTo: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
661
+ }, "strip", z.ZodTypeAny, {
662
+ timeoutMs: number;
663
+ approvers: string[];
664
+ onTimeout: "deny" | "escalate" | "degrade";
665
+ escalateTo?: string[] | undefined;
666
+ }, {
667
+ timeoutMs: number;
668
+ approvers: string[];
669
+ onTimeout: "deny" | "escalate" | "degrade";
670
+ escalateTo?: string[] | undefined;
671
+ }>, {
672
+ timeoutMs: number;
673
+ approvers: string[];
674
+ onTimeout: "deny" | "escalate" | "degrade";
675
+ escalateTo?: string[] | undefined;
676
+ }, {
677
+ timeoutMs: number;
678
+ approvers: string[];
679
+ onTimeout: "deny" | "escalate" | "degrade";
680
+ escalateTo?: string[] | undefined;
681
+ }>;
682
+ id: z.ZodString;
683
+ dependsOn: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
684
+ when: z.ZodOptional<z.ZodString>;
685
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
686
+ retry: z.ZodOptional<z.ZodObject<{
687
+ initialMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
688
+ backoff: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
689
+ maxIntervalMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
690
+ maxAttempts: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
691
+ maxTotalMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
692
+ nonRetryableErrorTypes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
693
+ }, "strip", z.ZodTypeAny, {
694
+ maxAttempts?: number | undefined;
695
+ initialMs?: number | undefined;
696
+ backoff?: number | undefined;
697
+ maxIntervalMs?: number | undefined;
698
+ maxTotalMs?: number | undefined;
699
+ nonRetryableErrorTypes?: string[] | undefined;
700
+ }, {
701
+ maxAttempts?: number | undefined;
702
+ initialMs?: number | undefined;
703
+ backoff?: number | undefined;
704
+ maxIntervalMs?: number | undefined;
705
+ maxTotalMs?: number | undefined;
706
+ nonRetryableErrorTypes?: string[] | undefined;
707
+ }>>;
708
+ }, "strip", z.ZodTypeAny, {
709
+ type: "approval";
710
+ id: string;
711
+ policy: {
712
+ timeoutMs: number;
713
+ approvers: string[];
714
+ onTimeout: "deny" | "escalate" | "degrade";
715
+ escalateTo?: string[] | undefined;
716
+ };
717
+ dependsOn: string[];
718
+ timeoutMs?: number | undefined;
719
+ when?: string | undefined;
720
+ retry?: {
721
+ maxAttempts?: number | undefined;
722
+ initialMs?: number | undefined;
723
+ backoff?: number | undefined;
724
+ maxIntervalMs?: number | undefined;
725
+ maxTotalMs?: number | undefined;
726
+ nonRetryableErrorTypes?: string[] | undefined;
727
+ } | undefined;
728
+ }, {
729
+ type: "approval";
730
+ id: string;
731
+ policy: {
732
+ timeoutMs: number;
733
+ approvers: string[];
734
+ onTimeout: "deny" | "escalate" | "degrade";
735
+ escalateTo?: string[] | undefined;
736
+ };
737
+ timeoutMs?: number | undefined;
738
+ dependsOn?: string[] | undefined;
739
+ when?: string | undefined;
740
+ retry?: {
741
+ maxAttempts?: number | undefined;
742
+ initialMs?: number | undefined;
743
+ backoff?: number | undefined;
744
+ maxIntervalMs?: number | undefined;
745
+ maxTotalMs?: number | undefined;
746
+ nonRetryableErrorTypes?: string[] | undefined;
747
+ } | undefined;
748
+ }>]>;
749
+ export type Step = z.infer<typeof StepSchema>;
750
+ /**
751
+ * Playbook 定义(《14》§4 对象模型)。steps 构成 DAG;引用存在性/无环/
752
+ * 补偿可达性/预算叠加等编译期校验归 T-O3,不进 schema(形态与语义分层)。
753
+ */
754
+ export declare const PlaybookSchema: z.ZodObject<{
755
+ name: z.ZodString;
756
+ version: z.ZodString;
757
+ description: z.ZodOptional<z.ZodString>;
758
+ triggers: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
759
+ type: z.ZodLiteral<"cron">;
760
+ expr: z.ZodString;
761
+ tz: z.ZodOptional<z.ZodString>;
762
+ }, "strip", z.ZodTypeAny, {
763
+ type: "cron";
764
+ expr: string;
765
+ tz?: string | undefined;
766
+ }, {
767
+ type: "cron";
768
+ expr: string;
769
+ tz?: string | undefined;
770
+ }>, z.ZodObject<{
771
+ type: z.ZodLiteral<"webhook">;
772
+ path: z.ZodString;
773
+ /** 秘密引用名(解析走秘密管理,值绝不入 Playbook);v0.13 起必填 */
774
+ secretRef: z.ZodString;
775
+ }, "strip", z.ZodTypeAny, {
776
+ path: string;
777
+ type: "webhook";
778
+ secretRef: string;
779
+ }, {
780
+ path: string;
781
+ type: "webhook";
782
+ secretRef: string;
783
+ }>, z.ZodObject<{
784
+ type: z.ZodLiteral<"webhook-internal">;
785
+ path: z.ZodString;
786
+ }, "strip", z.ZodTypeAny, {
787
+ path: string;
788
+ type: "webhook-internal";
789
+ }, {
790
+ path: string;
791
+ type: "webhook-internal";
792
+ }>, z.ZodObject<{
793
+ type: z.ZodLiteral<"api">;
794
+ }, "strip", z.ZodTypeAny, {
795
+ type: "api";
796
+ }, {
797
+ type: "api";
798
+ }>]>, "many">>;
799
+ steps: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
800
+ type: z.ZodLiteral<"agent">;
801
+ /** AgentProfile 名(《14》§4:模型+工具面+权限+预算的命名组合) */
802
+ profile: z.ZodString;
803
+ /** 提示词模板(插值语法由 T-O3 定) */
804
+ prompt: z.ZodString;
805
+ model: z.ZodOptional<z.ZodString>;
806
+ tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
807
+ budget: z.ZodOptional<z.ZodObject<{
808
+ maxUsd: z.ZodOptional<z.ZodNumber>;
809
+ maxTotalTokens: z.ZodOptional<z.ZodNumber>;
810
+ }, "strip", z.ZodTypeAny, {
811
+ maxUsd?: number | undefined;
812
+ maxTotalTokens?: number | undefined;
813
+ }, {
814
+ maxUsd?: number | undefined;
815
+ maxTotalTokens?: number | undefined;
816
+ }>>;
817
+ compensate: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
818
+ type: z.ZodLiteral<"agent">;
819
+ profile: z.ZodString;
820
+ prompt: z.ZodString;
821
+ model: z.ZodOptional<z.ZodString>;
822
+ tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
823
+ }, "strip", z.ZodTypeAny, {
824
+ type: "agent";
825
+ profile: string;
826
+ prompt: string;
827
+ model?: string | undefined;
828
+ tools?: string[] | undefined;
829
+ }, {
830
+ type: "agent";
831
+ profile: string;
832
+ prompt: string;
833
+ model?: string | undefined;
834
+ tools?: string[] | undefined;
835
+ }>, z.ZodObject<{
836
+ type: z.ZodLiteral<"tool">;
837
+ run: z.ZodString;
838
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
839
+ }, "strip", z.ZodTypeAny, {
840
+ type: "tool";
841
+ run: string;
842
+ args?: Record<string, unknown> | undefined;
843
+ }, {
844
+ type: "tool";
845
+ run: string;
846
+ args?: Record<string, unknown> | undefined;
847
+ }>]>>;
848
+ id: z.ZodString;
849
+ dependsOn: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
850
+ when: z.ZodOptional<z.ZodString>;
851
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
852
+ retry: z.ZodOptional<z.ZodObject<{
853
+ initialMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
854
+ backoff: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
855
+ maxIntervalMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
856
+ maxAttempts: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
857
+ maxTotalMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
858
+ nonRetryableErrorTypes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
859
+ }, "strip", z.ZodTypeAny, {
860
+ maxAttempts?: number | undefined;
861
+ initialMs?: number | undefined;
862
+ backoff?: number | undefined;
863
+ maxIntervalMs?: number | undefined;
864
+ maxTotalMs?: number | undefined;
865
+ nonRetryableErrorTypes?: string[] | undefined;
866
+ }, {
867
+ maxAttempts?: number | undefined;
868
+ initialMs?: number | undefined;
869
+ backoff?: number | undefined;
870
+ maxIntervalMs?: number | undefined;
871
+ maxTotalMs?: number | undefined;
872
+ nonRetryableErrorTypes?: string[] | undefined;
873
+ }>>;
874
+ }, "strip", z.ZodTypeAny, {
875
+ type: "agent";
876
+ id: string;
877
+ profile: string;
878
+ prompt: string;
879
+ dependsOn: string[];
880
+ model?: string | undefined;
881
+ tools?: string[] | undefined;
882
+ budget?: {
883
+ maxUsd?: number | undefined;
884
+ maxTotalTokens?: number | undefined;
885
+ } | undefined;
886
+ timeoutMs?: number | undefined;
887
+ compensate?: {
888
+ type: "agent";
889
+ profile: string;
890
+ prompt: string;
891
+ model?: string | undefined;
892
+ tools?: string[] | undefined;
893
+ } | {
894
+ type: "tool";
895
+ run: string;
896
+ args?: Record<string, unknown> | undefined;
897
+ } | undefined;
898
+ when?: string | undefined;
899
+ retry?: {
900
+ maxAttempts?: number | undefined;
901
+ initialMs?: number | undefined;
902
+ backoff?: number | undefined;
903
+ maxIntervalMs?: number | undefined;
904
+ maxTotalMs?: number | undefined;
905
+ nonRetryableErrorTypes?: string[] | undefined;
906
+ } | undefined;
907
+ }, {
908
+ type: "agent";
909
+ id: string;
910
+ profile: string;
911
+ prompt: string;
912
+ model?: string | undefined;
913
+ tools?: string[] | undefined;
914
+ budget?: {
915
+ maxUsd?: number | undefined;
916
+ maxTotalTokens?: number | undefined;
917
+ } | undefined;
918
+ timeoutMs?: number | undefined;
919
+ compensate?: {
920
+ type: "agent";
921
+ profile: string;
922
+ prompt: string;
923
+ model?: string | undefined;
924
+ tools?: string[] | undefined;
925
+ } | {
926
+ type: "tool";
927
+ run: string;
928
+ args?: Record<string, unknown> | undefined;
929
+ } | undefined;
930
+ dependsOn?: string[] | undefined;
931
+ when?: string | undefined;
932
+ retry?: {
933
+ maxAttempts?: number | undefined;
934
+ initialMs?: number | undefined;
935
+ backoff?: number | undefined;
936
+ maxIntervalMs?: number | undefined;
937
+ maxTotalMs?: number | undefined;
938
+ nonRetryableErrorTypes?: string[] | undefined;
939
+ } | undefined;
940
+ }>, z.ZodObject<{
941
+ type: z.ZodLiteral<"tool">;
942
+ run: z.ZodString;
943
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
944
+ compensate: z.ZodOptional<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
945
+ type: z.ZodLiteral<"agent">;
946
+ profile: z.ZodString;
947
+ prompt: z.ZodString;
948
+ model: z.ZodOptional<z.ZodString>;
949
+ tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
950
+ }, "strip", z.ZodTypeAny, {
951
+ type: "agent";
952
+ profile: string;
953
+ prompt: string;
954
+ model?: string | undefined;
955
+ tools?: string[] | undefined;
956
+ }, {
957
+ type: "agent";
958
+ profile: string;
959
+ prompt: string;
960
+ model?: string | undefined;
961
+ tools?: string[] | undefined;
962
+ }>, z.ZodObject<{
963
+ type: z.ZodLiteral<"tool">;
964
+ run: z.ZodString;
965
+ args: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
966
+ }, "strip", z.ZodTypeAny, {
967
+ type: "tool";
968
+ run: string;
969
+ args?: Record<string, unknown> | undefined;
970
+ }, {
971
+ type: "tool";
972
+ run: string;
973
+ args?: Record<string, unknown> | undefined;
974
+ }>]>>;
975
+ id: z.ZodString;
976
+ dependsOn: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
977
+ when: z.ZodOptional<z.ZodString>;
978
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
979
+ retry: z.ZodOptional<z.ZodObject<{
980
+ initialMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
981
+ backoff: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
982
+ maxIntervalMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
983
+ maxAttempts: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
984
+ maxTotalMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
985
+ nonRetryableErrorTypes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
986
+ }, "strip", z.ZodTypeAny, {
987
+ maxAttempts?: number | undefined;
988
+ initialMs?: number | undefined;
989
+ backoff?: number | undefined;
990
+ maxIntervalMs?: number | undefined;
991
+ maxTotalMs?: number | undefined;
992
+ nonRetryableErrorTypes?: string[] | undefined;
993
+ }, {
994
+ maxAttempts?: number | undefined;
995
+ initialMs?: number | undefined;
996
+ backoff?: number | undefined;
997
+ maxIntervalMs?: number | undefined;
998
+ maxTotalMs?: number | undefined;
999
+ nonRetryableErrorTypes?: string[] | undefined;
1000
+ }>>;
1001
+ }, "strip", z.ZodTypeAny, {
1002
+ type: "tool";
1003
+ id: string;
1004
+ run: string;
1005
+ dependsOn: string[];
1006
+ args?: Record<string, unknown> | undefined;
1007
+ timeoutMs?: number | undefined;
1008
+ compensate?: {
1009
+ type: "agent";
1010
+ profile: string;
1011
+ prompt: string;
1012
+ model?: string | undefined;
1013
+ tools?: string[] | undefined;
1014
+ } | {
1015
+ type: "tool";
1016
+ run: string;
1017
+ args?: Record<string, unknown> | undefined;
1018
+ } | undefined;
1019
+ when?: string | undefined;
1020
+ retry?: {
1021
+ maxAttempts?: number | undefined;
1022
+ initialMs?: number | undefined;
1023
+ backoff?: number | undefined;
1024
+ maxIntervalMs?: number | undefined;
1025
+ maxTotalMs?: number | undefined;
1026
+ nonRetryableErrorTypes?: string[] | undefined;
1027
+ } | undefined;
1028
+ }, {
1029
+ type: "tool";
1030
+ id: string;
1031
+ run: string;
1032
+ args?: Record<string, unknown> | undefined;
1033
+ timeoutMs?: number | undefined;
1034
+ compensate?: {
1035
+ type: "agent";
1036
+ profile: string;
1037
+ prompt: string;
1038
+ model?: string | undefined;
1039
+ tools?: string[] | undefined;
1040
+ } | {
1041
+ type: "tool";
1042
+ run: string;
1043
+ args?: Record<string, unknown> | undefined;
1044
+ } | undefined;
1045
+ dependsOn?: string[] | undefined;
1046
+ when?: string | undefined;
1047
+ retry?: {
1048
+ maxAttempts?: number | undefined;
1049
+ initialMs?: number | undefined;
1050
+ backoff?: number | undefined;
1051
+ maxIntervalMs?: number | undefined;
1052
+ maxTotalMs?: number | undefined;
1053
+ nonRetryableErrorTypes?: string[] | undefined;
1054
+ } | undefined;
1055
+ }>, z.ZodObject<{
1056
+ type: z.ZodLiteral<"condition">;
1057
+ /** 布尔表达式串;求值结果进 journal,下游以 when 引用 */
1058
+ expr: z.ZodString;
1059
+ id: z.ZodString;
1060
+ dependsOn: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1061
+ when: z.ZodOptional<z.ZodString>;
1062
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
1063
+ retry: z.ZodOptional<z.ZodObject<{
1064
+ initialMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
1065
+ backoff: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
1066
+ maxIntervalMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
1067
+ maxAttempts: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
1068
+ maxTotalMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
1069
+ nonRetryableErrorTypes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
1070
+ }, "strip", z.ZodTypeAny, {
1071
+ maxAttempts?: number | undefined;
1072
+ initialMs?: number | undefined;
1073
+ backoff?: number | undefined;
1074
+ maxIntervalMs?: number | undefined;
1075
+ maxTotalMs?: number | undefined;
1076
+ nonRetryableErrorTypes?: string[] | undefined;
1077
+ }, {
1078
+ maxAttempts?: number | undefined;
1079
+ initialMs?: number | undefined;
1080
+ backoff?: number | undefined;
1081
+ maxIntervalMs?: number | undefined;
1082
+ maxTotalMs?: number | undefined;
1083
+ nonRetryableErrorTypes?: string[] | undefined;
1084
+ }>>;
1085
+ }, "strip", z.ZodTypeAny, {
1086
+ type: "condition";
1087
+ id: string;
1088
+ expr: string;
1089
+ dependsOn: string[];
1090
+ timeoutMs?: number | undefined;
1091
+ when?: string | undefined;
1092
+ retry?: {
1093
+ maxAttempts?: number | undefined;
1094
+ initialMs?: number | undefined;
1095
+ backoff?: number | undefined;
1096
+ maxIntervalMs?: number | undefined;
1097
+ maxTotalMs?: number | undefined;
1098
+ nonRetryableErrorTypes?: string[] | undefined;
1099
+ } | undefined;
1100
+ }, {
1101
+ type: "condition";
1102
+ id: string;
1103
+ expr: string;
1104
+ timeoutMs?: number | undefined;
1105
+ dependsOn?: string[] | undefined;
1106
+ when?: string | undefined;
1107
+ retry?: {
1108
+ maxAttempts?: number | undefined;
1109
+ initialMs?: number | undefined;
1110
+ backoff?: number | undefined;
1111
+ maxIntervalMs?: number | undefined;
1112
+ maxTotalMs?: number | undefined;
1113
+ nonRetryableErrorTypes?: string[] | undefined;
1114
+ } | undefined;
1115
+ }>, z.ZodObject<{
1116
+ type: z.ZodLiteral<"approval">;
1117
+ policy: z.ZodEffects<z.ZodObject<{
1118
+ /** 审批人/组标识(语义由部署侧目录服务解释) */
1119
+ approvers: z.ZodArray<z.ZodString, "many">;
1120
+ timeoutMs: z.ZodNumber;
1121
+ onTimeout: z.ZodEnum<["deny", "escalate", "degrade"]>;
1122
+ escalateTo: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1123
+ }, "strip", z.ZodTypeAny, {
1124
+ timeoutMs: number;
1125
+ approvers: string[];
1126
+ onTimeout: "deny" | "escalate" | "degrade";
1127
+ escalateTo?: string[] | undefined;
1128
+ }, {
1129
+ timeoutMs: number;
1130
+ approvers: string[];
1131
+ onTimeout: "deny" | "escalate" | "degrade";
1132
+ escalateTo?: string[] | undefined;
1133
+ }>, {
1134
+ timeoutMs: number;
1135
+ approvers: string[];
1136
+ onTimeout: "deny" | "escalate" | "degrade";
1137
+ escalateTo?: string[] | undefined;
1138
+ }, {
1139
+ timeoutMs: number;
1140
+ approvers: string[];
1141
+ onTimeout: "deny" | "escalate" | "degrade";
1142
+ escalateTo?: string[] | undefined;
1143
+ }>;
1144
+ id: z.ZodString;
1145
+ dependsOn: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
1146
+ when: z.ZodOptional<z.ZodString>;
1147
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
1148
+ retry: z.ZodOptional<z.ZodObject<{
1149
+ initialMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
1150
+ backoff: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
1151
+ maxIntervalMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
1152
+ maxAttempts: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
1153
+ maxTotalMs: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
1154
+ nonRetryableErrorTypes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
1155
+ }, "strip", z.ZodTypeAny, {
1156
+ maxAttempts?: number | undefined;
1157
+ initialMs?: number | undefined;
1158
+ backoff?: number | undefined;
1159
+ maxIntervalMs?: number | undefined;
1160
+ maxTotalMs?: number | undefined;
1161
+ nonRetryableErrorTypes?: string[] | undefined;
1162
+ }, {
1163
+ maxAttempts?: number | undefined;
1164
+ initialMs?: number | undefined;
1165
+ backoff?: number | undefined;
1166
+ maxIntervalMs?: number | undefined;
1167
+ maxTotalMs?: number | undefined;
1168
+ nonRetryableErrorTypes?: string[] | undefined;
1169
+ }>>;
1170
+ }, "strip", z.ZodTypeAny, {
1171
+ type: "approval";
1172
+ id: string;
1173
+ policy: {
1174
+ timeoutMs: number;
1175
+ approvers: string[];
1176
+ onTimeout: "deny" | "escalate" | "degrade";
1177
+ escalateTo?: string[] | undefined;
1178
+ };
1179
+ dependsOn: string[];
1180
+ timeoutMs?: number | undefined;
1181
+ when?: string | undefined;
1182
+ retry?: {
1183
+ maxAttempts?: number | undefined;
1184
+ initialMs?: number | undefined;
1185
+ backoff?: number | undefined;
1186
+ maxIntervalMs?: number | undefined;
1187
+ maxTotalMs?: number | undefined;
1188
+ nonRetryableErrorTypes?: string[] | undefined;
1189
+ } | undefined;
1190
+ }, {
1191
+ type: "approval";
1192
+ id: string;
1193
+ policy: {
1194
+ timeoutMs: number;
1195
+ approvers: string[];
1196
+ onTimeout: "deny" | "escalate" | "degrade";
1197
+ escalateTo?: string[] | undefined;
1198
+ };
1199
+ timeoutMs?: number | undefined;
1200
+ dependsOn?: string[] | undefined;
1201
+ when?: string | undefined;
1202
+ retry?: {
1203
+ maxAttempts?: number | undefined;
1204
+ initialMs?: number | undefined;
1205
+ backoff?: number | undefined;
1206
+ maxIntervalMs?: number | undefined;
1207
+ maxTotalMs?: number | undefined;
1208
+ nonRetryableErrorTypes?: string[] | undefined;
1209
+ } | undefined;
1210
+ }>]>, "many">;
1211
+ budget: z.ZodOptional<z.ZodObject<{
1212
+ maxUsd: z.ZodOptional<z.ZodNumber>;
1213
+ maxTotalTokens: z.ZodOptional<z.ZodNumber>;
1214
+ }, "strip", z.ZodTypeAny, {
1215
+ maxUsd?: number | undefined;
1216
+ maxTotalTokens?: number | undefined;
1217
+ }, {
1218
+ maxUsd?: number | undefined;
1219
+ maxTotalTokens?: number | undefined;
1220
+ }>>;
1221
+ /** 步终态失败后的整 run 策略:compensate 走 Saga 逆序补偿;halt 原地停 */
1222
+ onFailure: z.ZodDefault<z.ZodEnum<["compensate", "halt"]>>;
1223
+ /**
1224
+ * 数据等级(contract-v0.13,RFC-WE-4;T-G5 消费位)。缺席语义由消费方定
1225
+ * (T-G5 拟按 internal 兜底);sensitive 级触发 provider 边界 fail-closed。
1226
+ */
1227
+ dataClassification: z.ZodOptional<z.ZodEnum<["public", "internal", "sensitive"]>>;
1228
+ /**
1229
+ * provider 白名单(providerId 集;contract-v0.13,RFC-WE-4;T-G5 消费位)。
1230
+ * 声明后模型 fallback 链恒不越出本集合;强制语义在 T-G5,schema 先冻结形态。
1231
+ */
1232
+ providerAllowlist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1233
+ }, "strip", z.ZodTypeAny, {
1234
+ name: string;
1235
+ version: string;
1236
+ triggers: ({
1237
+ type: "cron";
1238
+ expr: string;
1239
+ tz?: string | undefined;
1240
+ } | {
1241
+ path: string;
1242
+ type: "webhook";
1243
+ secretRef: string;
1244
+ } | {
1245
+ path: string;
1246
+ type: "webhook-internal";
1247
+ } | {
1248
+ type: "api";
1249
+ })[];
1250
+ steps: ({
1251
+ type: "agent";
1252
+ id: string;
1253
+ profile: string;
1254
+ prompt: string;
1255
+ dependsOn: string[];
1256
+ model?: string | undefined;
1257
+ tools?: string[] | undefined;
1258
+ budget?: {
1259
+ maxUsd?: number | undefined;
1260
+ maxTotalTokens?: number | undefined;
1261
+ } | undefined;
1262
+ timeoutMs?: number | undefined;
1263
+ compensate?: {
1264
+ type: "agent";
1265
+ profile: string;
1266
+ prompt: string;
1267
+ model?: string | undefined;
1268
+ tools?: string[] | undefined;
1269
+ } | {
1270
+ type: "tool";
1271
+ run: string;
1272
+ args?: Record<string, unknown> | undefined;
1273
+ } | undefined;
1274
+ when?: string | undefined;
1275
+ retry?: {
1276
+ maxAttempts?: number | undefined;
1277
+ initialMs?: number | undefined;
1278
+ backoff?: number | undefined;
1279
+ maxIntervalMs?: number | undefined;
1280
+ maxTotalMs?: number | undefined;
1281
+ nonRetryableErrorTypes?: string[] | undefined;
1282
+ } | undefined;
1283
+ } | {
1284
+ type: "tool";
1285
+ id: string;
1286
+ run: string;
1287
+ dependsOn: string[];
1288
+ args?: Record<string, unknown> | undefined;
1289
+ timeoutMs?: number | undefined;
1290
+ compensate?: {
1291
+ type: "agent";
1292
+ profile: string;
1293
+ prompt: string;
1294
+ model?: string | undefined;
1295
+ tools?: string[] | undefined;
1296
+ } | {
1297
+ type: "tool";
1298
+ run: string;
1299
+ args?: Record<string, unknown> | undefined;
1300
+ } | undefined;
1301
+ when?: string | undefined;
1302
+ retry?: {
1303
+ maxAttempts?: number | undefined;
1304
+ initialMs?: number | undefined;
1305
+ backoff?: number | undefined;
1306
+ maxIntervalMs?: number | undefined;
1307
+ maxTotalMs?: number | undefined;
1308
+ nonRetryableErrorTypes?: string[] | undefined;
1309
+ } | undefined;
1310
+ } | {
1311
+ type: "condition";
1312
+ id: string;
1313
+ expr: string;
1314
+ dependsOn: string[];
1315
+ timeoutMs?: number | undefined;
1316
+ when?: string | undefined;
1317
+ retry?: {
1318
+ maxAttempts?: number | undefined;
1319
+ initialMs?: number | undefined;
1320
+ backoff?: number | undefined;
1321
+ maxIntervalMs?: number | undefined;
1322
+ maxTotalMs?: number | undefined;
1323
+ nonRetryableErrorTypes?: string[] | undefined;
1324
+ } | undefined;
1325
+ } | {
1326
+ type: "approval";
1327
+ id: string;
1328
+ policy: {
1329
+ timeoutMs: number;
1330
+ approvers: string[];
1331
+ onTimeout: "deny" | "escalate" | "degrade";
1332
+ escalateTo?: string[] | undefined;
1333
+ };
1334
+ dependsOn: string[];
1335
+ timeoutMs?: number | undefined;
1336
+ when?: string | undefined;
1337
+ retry?: {
1338
+ maxAttempts?: number | undefined;
1339
+ initialMs?: number | undefined;
1340
+ backoff?: number | undefined;
1341
+ maxIntervalMs?: number | undefined;
1342
+ maxTotalMs?: number | undefined;
1343
+ nonRetryableErrorTypes?: string[] | undefined;
1344
+ } | undefined;
1345
+ })[];
1346
+ onFailure: "compensate" | "halt";
1347
+ description?: string | undefined;
1348
+ budget?: {
1349
+ maxUsd?: number | undefined;
1350
+ maxTotalTokens?: number | undefined;
1351
+ } | undefined;
1352
+ dataClassification?: "public" | "internal" | "sensitive" | undefined;
1353
+ providerAllowlist?: string[] | undefined;
1354
+ }, {
1355
+ name: string;
1356
+ version: string;
1357
+ steps: ({
1358
+ type: "agent";
1359
+ id: string;
1360
+ profile: string;
1361
+ prompt: string;
1362
+ model?: string | undefined;
1363
+ tools?: string[] | undefined;
1364
+ budget?: {
1365
+ maxUsd?: number | undefined;
1366
+ maxTotalTokens?: number | undefined;
1367
+ } | undefined;
1368
+ timeoutMs?: number | undefined;
1369
+ compensate?: {
1370
+ type: "agent";
1371
+ profile: string;
1372
+ prompt: string;
1373
+ model?: string | undefined;
1374
+ tools?: string[] | undefined;
1375
+ } | {
1376
+ type: "tool";
1377
+ run: string;
1378
+ args?: Record<string, unknown> | undefined;
1379
+ } | undefined;
1380
+ dependsOn?: string[] | undefined;
1381
+ when?: string | undefined;
1382
+ retry?: {
1383
+ maxAttempts?: number | undefined;
1384
+ initialMs?: number | undefined;
1385
+ backoff?: number | undefined;
1386
+ maxIntervalMs?: number | undefined;
1387
+ maxTotalMs?: number | undefined;
1388
+ nonRetryableErrorTypes?: string[] | undefined;
1389
+ } | undefined;
1390
+ } | {
1391
+ type: "tool";
1392
+ id: string;
1393
+ run: string;
1394
+ args?: Record<string, unknown> | undefined;
1395
+ timeoutMs?: number | undefined;
1396
+ compensate?: {
1397
+ type: "agent";
1398
+ profile: string;
1399
+ prompt: string;
1400
+ model?: string | undefined;
1401
+ tools?: string[] | undefined;
1402
+ } | {
1403
+ type: "tool";
1404
+ run: string;
1405
+ args?: Record<string, unknown> | undefined;
1406
+ } | undefined;
1407
+ dependsOn?: string[] | undefined;
1408
+ when?: string | undefined;
1409
+ retry?: {
1410
+ maxAttempts?: number | undefined;
1411
+ initialMs?: number | undefined;
1412
+ backoff?: number | undefined;
1413
+ maxIntervalMs?: number | undefined;
1414
+ maxTotalMs?: number | undefined;
1415
+ nonRetryableErrorTypes?: string[] | undefined;
1416
+ } | undefined;
1417
+ } | {
1418
+ type: "condition";
1419
+ id: string;
1420
+ expr: string;
1421
+ timeoutMs?: number | undefined;
1422
+ dependsOn?: string[] | undefined;
1423
+ when?: string | undefined;
1424
+ retry?: {
1425
+ maxAttempts?: number | undefined;
1426
+ initialMs?: number | undefined;
1427
+ backoff?: number | undefined;
1428
+ maxIntervalMs?: number | undefined;
1429
+ maxTotalMs?: number | undefined;
1430
+ nonRetryableErrorTypes?: string[] | undefined;
1431
+ } | undefined;
1432
+ } | {
1433
+ type: "approval";
1434
+ id: string;
1435
+ policy: {
1436
+ timeoutMs: number;
1437
+ approvers: string[];
1438
+ onTimeout: "deny" | "escalate" | "degrade";
1439
+ escalateTo?: string[] | undefined;
1440
+ };
1441
+ timeoutMs?: number | undefined;
1442
+ dependsOn?: string[] | undefined;
1443
+ when?: string | undefined;
1444
+ retry?: {
1445
+ maxAttempts?: number | undefined;
1446
+ initialMs?: number | undefined;
1447
+ backoff?: number | undefined;
1448
+ maxIntervalMs?: number | undefined;
1449
+ maxTotalMs?: number | undefined;
1450
+ nonRetryableErrorTypes?: string[] | undefined;
1451
+ } | undefined;
1452
+ })[];
1453
+ description?: string | undefined;
1454
+ budget?: {
1455
+ maxUsd?: number | undefined;
1456
+ maxTotalTokens?: number | undefined;
1457
+ } | undefined;
1458
+ triggers?: ({
1459
+ type: "cron";
1460
+ expr: string;
1461
+ tz?: string | undefined;
1462
+ } | {
1463
+ path: string;
1464
+ type: "webhook";
1465
+ secretRef: string;
1466
+ } | {
1467
+ path: string;
1468
+ type: "webhook-internal";
1469
+ } | {
1470
+ type: "api";
1471
+ })[] | undefined;
1472
+ onFailure?: "compensate" | "halt" | undefined;
1473
+ dataClassification?: "public" | "internal" | "sensitive" | undefined;
1474
+ providerAllowlist?: string[] | undefined;
1475
+ }>;
1476
+ export type Playbook = z.infer<typeof PlaybookSchema>;
1477
+ /**
1478
+ * 资产 id 约束(contract-v0.10,随 AgentProfile 自 tansrd assets/schema.ts
1479
+ * 上移):一期代理名同款——小写字母数字开头,余者小写字母数字/连字符/点/
1480
+ * 下划线,≤64 字符。
1481
+ */
1482
+ export declare const ASSET_ID_RE: RegExp;
1483
+ /**
1484
+ * AgentProfile(contract-v0.10,RFC-WB-5;自 tansrd 私有 zod 上移,形态不变)。
1485
+ * 《14》§4「一期子代理定义(.tansr/agents/*.md)的服务端化,格式不变」:
1486
+ * name/description/systemPrompt/tools/model 同一期 AgentDefinition 键,另加
1487
+ * 资产库版本化必填 version、permissionMode(PERMISSION_MODES 词表)与
1488
+ * budget(与 Playbook 步预算同口径)。消费方:T-U3 编辑器 / T-O4 执行器 /
1489
+ * T-P3 池。name 即资产 id。
1490
+ */
1491
+ export declare const AgentProfileSchema: z.ZodObject<{
1492
+ name: z.ZodString;
1493
+ version: z.ZodString;
1494
+ /** 何时使用(一期拼进 Task 工具描述的索引面;上限同一期) */
1495
+ description: z.ZodOptional<z.ZodString>;
1496
+ /** 子代理 system prompt(一期文件正文位) */
1497
+ systemPrompt: z.ZodOptional<z.ZodString>;
1498
+ model: z.ZodOptional<z.ZodString>;
1499
+ /** 工具白名单:一期语义 = 在父 toolset 上收窄,绝不放宽(权限单调收缩) */
1500
+ tools: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1501
+ permissionMode: z.ZodOptional<z.ZodEnum<["default", "acceptEdits", "plan", "bypassPermissions", "auto", "dontAsk"]>>;
1502
+ /** 与 Playbook 步预算同口径(USD 主 + token 兜底) */
1503
+ budget: z.ZodOptional<z.ZodObject<{
1504
+ maxUsd: z.ZodOptional<z.ZodNumber>;
1505
+ maxTotalTokens: z.ZodOptional<z.ZodNumber>;
1506
+ }, "strip", z.ZodTypeAny, {
1507
+ maxUsd?: number | undefined;
1508
+ maxTotalTokens?: number | undefined;
1509
+ }, {
1510
+ maxUsd?: number | undefined;
1511
+ maxTotalTokens?: number | undefined;
1512
+ }>>;
1513
+ }, "strip", z.ZodTypeAny, {
1514
+ name: string;
1515
+ version: string;
1516
+ description?: string | undefined;
1517
+ model?: string | undefined;
1518
+ tools?: string[] | undefined;
1519
+ budget?: {
1520
+ maxUsd?: number | undefined;
1521
+ maxTotalTokens?: number | undefined;
1522
+ } | undefined;
1523
+ systemPrompt?: string | undefined;
1524
+ permissionMode?: "default" | "acceptEdits" | "plan" | "bypassPermissions" | "auto" | "dontAsk" | undefined;
1525
+ }, {
1526
+ name: string;
1527
+ version: string;
1528
+ description?: string | undefined;
1529
+ model?: string | undefined;
1530
+ tools?: string[] | undefined;
1531
+ budget?: {
1532
+ maxUsd?: number | undefined;
1533
+ maxTotalTokens?: number | undefined;
1534
+ } | undefined;
1535
+ systemPrompt?: string | undefined;
1536
+ permissionMode?: "default" | "acceptEdits" | "plan" | "bypassPermissions" | "auto" | "dontAsk" | undefined;
1537
+ }>;
1538
+ export type AgentProfile = z.infer<typeof AgentProfileSchema>;
1539
+ /**
1540
+ * 会话创建可选归因标签(RFC-O0-8):POST /v1/sessions 请求体的 labels 位。
1541
+ * 键 ≤16 个、键长 ≤64、值长 ≤256(防滥用为数据通道);serve 存入会话元数据
1542
+ * 并透出到审计记录关联链(《10》§3.3 六字段组③);内核行为零变化。
1543
+ */
1544
+ export declare const SessionLabelsSchema: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodString>, Record<string, string>, Record<string, string>>;
1545
+ export type SessionLabels = z.infer<typeof SessionLabelsSchema>;
1546
+ /** 编排面约定标签键(tansrd 写入,审计/成本归因消费) */
1547
+ export declare const ORCHESTRATION_LABEL_KEYS: {
1548
+ readonly runId: "tansr.run_id";
1549
+ readonly stepId: "tansr.step_id";
1550
+ readonly playbookId: "tansr.playbook_id";
1551
+ };