@agent-phonon/protocol 0.6.1 → 0.8.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.
- package/dist/schemas/methods.d.ts +1071 -3
- package/dist/schemas/methods.d.ts.map +1 -1
- package/dist/schemas/methods.js +55 -2
- package/dist/schemas/methods.js.map +1 -1
- package/dist/schemas/project.d.ts +447 -0
- package/dist/schemas/project.d.ts.map +1 -1
- package/dist/schemas/project.js +165 -0
- package/dist/schemas/project.js.map +1 -1
- package/dist/schemas/workflow.d.ts +927 -3
- package/dist/schemas/workflow.d.ts.map +1 -1
- package/dist/schemas/workflow.js +93 -0
- package/dist/schemas/workflow.js.map +1 -1
- package/package.json +1 -1
- package/src/schemas/methods.ts +67 -0
- package/src/schemas/project.ts +198 -0
- package/src/schemas/workflow.ts +111 -0
package/src/schemas/workflow.ts
CHANGED
|
@@ -227,6 +227,26 @@ export const WorkflowResumeFrom = z.object({
|
|
|
227
227
|
});
|
|
228
228
|
export type WorkflowResumeFrom = z.infer<typeof WorkflowResumeFrom>;
|
|
229
229
|
|
|
230
|
+
/**
|
|
231
|
+
* workflow.resume:独立 method(v0.7),取代之前用 workflow.run.resumeFrom 偷渡的方式。
|
|
232
|
+
* resumeFrom 字段保留向后兼容,但 SDK 优先使用 workflow.resume。
|
|
233
|
+
*/
|
|
234
|
+
export const WorkflowResumeParams = z.object({
|
|
235
|
+
workflowId: WorkflowId,
|
|
236
|
+
strategy: z.union([
|
|
237
|
+
z.literal("last_success_dependents"),
|
|
238
|
+
z.literal("failed_node"),
|
|
239
|
+
z.string().regex(/^node:/),
|
|
240
|
+
]).default("failed_node"),
|
|
241
|
+
rerunNodes: z.array(WorkflowNodeId).optional(),
|
|
242
|
+
/** 可选:附加给 executor 的反馈文本(HITL 后特别有用) */
|
|
243
|
+
feedback: z.string().optional(),
|
|
244
|
+
/** 可选:恢复时调整 sharedContext */
|
|
245
|
+
sharedContextPatch: WorkflowSharedContext.optional(),
|
|
246
|
+
});
|
|
247
|
+
export type WorkflowResumeParams = z.infer<typeof WorkflowResumeParams>;
|
|
248
|
+
|
|
249
|
+
|
|
230
250
|
// ---------------------------------------------------------------------------
|
|
231
251
|
// workflow.run
|
|
232
252
|
// ---------------------------------------------------------------------------
|
|
@@ -273,6 +293,11 @@ export const WorkflowNodeResult = z.object({
|
|
|
273
293
|
.object({
|
|
274
294
|
inputTokens: z.number().int().nonnegative().optional(),
|
|
275
295
|
outputTokens: z.number().int().nonnegative().optional(),
|
|
296
|
+
cachedTokens: z.number().int().nonnegative().optional(),
|
|
297
|
+
reasoningTokens: z.number().int().nonnegative().optional(),
|
|
298
|
+
toolCalls: z.number().int().nonnegative().optional(),
|
|
299
|
+
durationMs: z.number().int().nonnegative().optional(),
|
|
300
|
+
costEstimate: z.object({ amount: z.number().nonnegative(), currency: z.enum(["USD", "CNY"]) }).optional(),
|
|
276
301
|
})
|
|
277
302
|
.optional(),
|
|
278
303
|
});
|
|
@@ -356,6 +381,10 @@ export const WorkflowEvent = z.object({
|
|
|
356
381
|
"round.started", // discussion / graph iteration 轮次开始
|
|
357
382
|
"round.completed", // 一轮所有参与者发完
|
|
358
383
|
"discussion.terminated", // discussion 终止(含理由)
|
|
384
|
+
"human_review.requested", // executor emit workflow.human_review 触发
|
|
385
|
+
"human_review.resolved", // server 通过 interaction.respond 回复
|
|
386
|
+
"artifact.written",
|
|
387
|
+
"node.diagnostic",
|
|
359
388
|
]),
|
|
360
389
|
nodeId: WorkflowNodeId.optional(),
|
|
361
390
|
sessionId: SessionId.optional(),
|
|
@@ -381,6 +410,50 @@ export const WorkflowAckParams = z.object({
|
|
|
381
410
|
});
|
|
382
411
|
export type WorkflowAckParams = z.infer<typeof WorkflowAckParams>;
|
|
383
412
|
|
|
413
|
+
export const WorkflowEventsListParams = z.object({
|
|
414
|
+
workflowId: WorkflowId,
|
|
415
|
+
afterSeq: z.number().int().nonnegative().optional(),
|
|
416
|
+
limit: z.number().int().positive().max(1000).default(200).optional(),
|
|
417
|
+
});
|
|
418
|
+
export type WorkflowEventsListParams = z.infer<typeof WorkflowEventsListParams>;
|
|
419
|
+
export const WorkflowEventsListResult = z.object({
|
|
420
|
+
events: z.array(WorkflowEvent),
|
|
421
|
+
nextSeq: z.number().int().nonnegative().optional(),
|
|
422
|
+
});
|
|
423
|
+
export type WorkflowEventsListResult = z.infer<typeof WorkflowEventsListResult>;
|
|
424
|
+
|
|
425
|
+
export const WorkflowArtifact = z.object({
|
|
426
|
+
artifactId: z.string().min(1),
|
|
427
|
+
workflowId: WorkflowId,
|
|
428
|
+
nodeId: WorkflowNodeId.optional(),
|
|
429
|
+
kind: z.enum(["report", "diff", "spec", "log", "patch", "image", "binary", "other"]),
|
|
430
|
+
path: z.string().min(1),
|
|
431
|
+
title: z.string().optional(),
|
|
432
|
+
mimeType: z.string().optional(),
|
|
433
|
+
size: z.number().int().nonnegative().optional(),
|
|
434
|
+
createdAt: Timestamp,
|
|
435
|
+
metadata: z.record(z.unknown()).optional(),
|
|
436
|
+
});
|
|
437
|
+
export type WorkflowArtifact = z.infer<typeof WorkflowArtifact>;
|
|
438
|
+
|
|
439
|
+
export const WorkflowArtifactRegisterParams = z.object({
|
|
440
|
+
workflowId: WorkflowId,
|
|
441
|
+
nodeId: WorkflowNodeId.optional(),
|
|
442
|
+
kind: WorkflowArtifact.shape.kind,
|
|
443
|
+
path: z.string().min(1),
|
|
444
|
+
title: z.string().optional(),
|
|
445
|
+
mimeType: z.string().optional(),
|
|
446
|
+
metadata: z.record(z.unknown()).optional(),
|
|
447
|
+
});
|
|
448
|
+
export type WorkflowArtifactRegisterParams = z.infer<typeof WorkflowArtifactRegisterParams>;
|
|
449
|
+
export const WorkflowArtifactRegisterResult = z.object({ artifact: WorkflowArtifact });
|
|
450
|
+
export type WorkflowArtifactRegisterResult = z.infer<typeof WorkflowArtifactRegisterResult>;
|
|
451
|
+
|
|
452
|
+
export const WorkflowArtifactsListParams = z.object({ workflowId: WorkflowId });
|
|
453
|
+
export type WorkflowArtifactsListParams = z.infer<typeof WorkflowArtifactsListParams>;
|
|
454
|
+
export const WorkflowArtifactsListResult = z.object({ artifacts: z.array(WorkflowArtifact) });
|
|
455
|
+
export type WorkflowArtifactsListResult = z.infer<typeof WorkflowArtifactsListResult>;
|
|
456
|
+
|
|
384
457
|
// ---------------------------------------------------------------------------
|
|
385
458
|
// Routing directive — v0.5 升级为判别联合(review 借鉴 1)
|
|
386
459
|
//
|
|
@@ -430,10 +503,48 @@ export const WorkflowDoneDirective = z.object({
|
|
|
430
503
|
});
|
|
431
504
|
export type WorkflowDoneDirective = z.infer<typeof WorkflowDoneDirective>;
|
|
432
505
|
|
|
506
|
+
/**
|
|
507
|
+
* human_review: 请求 server 进行人工审查(v0.7 新增)。
|
|
508
|
+
*
|
|
509
|
+
* Executor emit 这个 directive 后,phonon 暂停 workflow,通过 `interaction.request`
|
|
510
|
+
* 反向问 server;server 返回 { approved, feedback? } 后:
|
|
511
|
+
* - approved=true → 当作 workflow.done 处理(finalSummary = feedback ?? executor 文本)
|
|
512
|
+
* - approved=false → 把 feedback 文本作为 executor 下一轮的输入("revise based on review")
|
|
513
|
+
* phonon 同时 emit workflow.event { type: "human_review.requested" / "human_review.resolved" }。
|
|
514
|
+
*
|
|
515
|
+
* 这是设备侧底层 HITL 机制;UI 渲染、表单字段、文档关联、Feishu 集成等业务由 server 实现。
|
|
516
|
+
*/
|
|
517
|
+
export const WorkflowHumanReviewDirective = z.object({
|
|
518
|
+
kind: z.literal("workflow.human_review"),
|
|
519
|
+
/** 审查标题(短,给 UI 显示用) */
|
|
520
|
+
title: z.string(),
|
|
521
|
+
/** 审查内容/摘要(长,给 reviewer 看) */
|
|
522
|
+
summary: z.string(),
|
|
523
|
+
/** 关联的产物文件路径(workspace 相对) */
|
|
524
|
+
artifacts: z.array(z.object({
|
|
525
|
+
path: z.string(),
|
|
526
|
+
role: z.enum(["report", "diff", "spec", "log", "other"]).default("other"),
|
|
527
|
+
})).optional(),
|
|
528
|
+
reason: z.string().optional(),
|
|
529
|
+
/** 等待 server 响应的超时秒数,默认 1800 (30min) */
|
|
530
|
+
timeoutSeconds: z.number().int().positive().default(1800),
|
|
531
|
+
});
|
|
532
|
+
export type WorkflowHumanReviewDirective = z.infer<typeof WorkflowHumanReviewDirective>;
|
|
533
|
+
|
|
534
|
+
/** server 对 human_review 的响应 schema(通过 interaction.respond 走 form value) */
|
|
535
|
+
export const WorkflowHumanReviewResponse = z.object({
|
|
536
|
+
approved: z.boolean(),
|
|
537
|
+
/** 反馈文字。approved=true 时可作 finalSummary;approved=false 时作 executor 下一轮输入 */
|
|
538
|
+
feedback: z.string().optional(),
|
|
539
|
+
reviewer: z.string().optional(),
|
|
540
|
+
});
|
|
541
|
+
export type WorkflowHumanReviewResponse = z.infer<typeof WorkflowHumanReviewResponse>;
|
|
542
|
+
|
|
433
543
|
export const WorkflowRoutingDirective = z.discriminatedUnion("kind", [
|
|
434
544
|
WorkflowRouteDirective,
|
|
435
545
|
WorkflowFeedbackDirective,
|
|
436
546
|
WorkflowReplyDirective,
|
|
437
547
|
WorkflowDoneDirective,
|
|
548
|
+
WorkflowHumanReviewDirective,
|
|
438
549
|
]);
|
|
439
550
|
export type WorkflowRoutingDirective = z.infer<typeof WorkflowRoutingDirective>;
|