@sema-agent/client-core 0.30.4 → 0.30.6

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.
@@ -1,5 +1,5 @@
1
- import type { WorkflowRun } from '@sema-agent/sdk';
2
- import type { WorkflowRunState } from './workflowMonitor.js';
1
+ import type { WorkflowRun, WorkflowStreamEvent } from '@sema-agent/sdk';
2
+ import type { WorkflowRunState, WorkflowToolCall } from './workflowMonitor.js';
3
3
  /** The live controller the host drives — a projected-snapshot reader + diagnostics + teardown. */
4
4
  export interface LiveWorkflowController {
5
5
  /** the latest projected run state, or null (not yet resolved / degraded 501-404 / empty). */
@@ -63,6 +63,66 @@ export interface LiveWorkflowConfig {
63
63
  * tolerates absent/permissive fields and never throws (the graceful-degrade contract lives above, in the
64
64
  * source loop; this just maps a well-formed run). Exported for the mock-parity unit cross-check. */
65
65
  export declare function projectWorkflowRun(run: WorkflowRun): WorkflowRunState;
66
+ /** 台账里的一个 agent(读口产物,只读快照;缺席 = 不知道,绝不渲成 0/空)。 */
67
+ export interface WorkflowActivityAgentView {
68
+ /** `ctx.agent` 调用的稳定身份(SSE 主键);老引擎/无 callKey 的帧上缺席。 */
69
+ callKey?: string;
70
+ label: string;
71
+ /** `agent_end.toolCalls` 权威;缺席时 = `agent_activity` 的 start 相位计数(**下界**)。 */
72
+ toolCalls: number;
73
+ /** per-toolCallId 折好的 call 序(上限 {@link MAX_WORKFLOW_ACTIVITY_CALLS},超限丢最老)。 */
74
+ activity: WorkflowToolCall[];
75
+ lastToolName?: string;
76
+ lastToolSummary?: string;
77
+ /** `agent_start.model` —— **请求词原样**(不是生效模型)。 */
78
+ requestedModel?: string;
79
+ /** `agent_end.modelResolved` —— 实跑模型;core 的 workflow 记录从不折入它 ⇒ GET 结构上到不了。 */
80
+ resolvedModel?: string;
81
+ /** 尾条 beat 的 ts。 */
82
+ lastProgressAt?: number;
83
+ }
84
+ /** 台账读口产物。`byLabel` **已排除**归属不可判的 label —— 端侧零重名逻辑。 */
85
+ export interface WorkflowActivityLedgerView {
86
+ workflowId: string;
87
+ byCallKey: ReadonlyMap<string, WorkflowActivityAgentView>;
88
+ byLabel: ReadonlyMap<string, WorkflowActivityAgentView>;
89
+ /** 同 label 多个非 replay 的 agent_start ⇒ 归属不可判(诊断面;`byLabel` 已按它过滤)。 */
90
+ ambiguousLabels: ReadonlySet<string>;
91
+ /** 流已收口(run 终态 / 显式 stop)——数据保留只读,不再消费。 */
92
+ closed: boolean;
93
+ /** 已折入的帧数(反空转:0 = 这条台账一帧都没收到,「全都没有」不构成证据)。 */
94
+ frames: number;
95
+ /** 最近一次 SSE 错误的人话;从没出过错 = null。**诊断面**,不参与归属判定。 */
96
+ lastError: string | null;
97
+ }
98
+ /** 预热口/单流化源共用的连线配置(与 {@link LiveWorkflowConfig} 同域,workflowId 必填)。 */
99
+ export interface WorkflowActivityLedgerConfig {
100
+ baseUrl: string;
101
+ authToken: string | {
102
+ mode: 'same-origin-relay';
103
+ };
104
+ principal: string | undefined;
105
+ workflowId: string;
106
+ fetchImpl?: typeof fetch;
107
+ }
108
+ /** 台账读口:没有该 id 的台账 ⇒ **null**(不是空视图 —— 「没开过账」与「开了账但一帧没收到」
109
+ * 是两件事,端侧据此分辨)。产物只读,按 frames/closed 缓存。 */
110
+ export declare function readWorkflowActivityLedger(workflowId: string): WorkflowActivityLedgerView | null;
111
+ /**
112
+ * **预热口**(幂等):fleet 流上见到 running workflow 行就调 —— 从 workflow 起跑积累工具事实,
113
+ * monitor 无论何时打开都有自那时起的完整台账。已有台账(哪怕已收口)即早退,**绝不开第二条流**。
114
+ */
115
+ export declare function ensureWorkflowActivityLedger(cfg: WorkflowActivityLedgerConfig): void;
116
+ /** fleet 行终态/remove 的收口口(空流收口是主径;这里防重连定时器竞态)。数据保留只读。 */
117
+ export declare function stopWorkflowActivityLedger(workflowId: string): void;
118
+ /** 测试钩:清空全部台账(abort 在飞流)。 */
119
+ export declare function resetWorkflowActivityLedgers(): void;
120
+ /**
121
+ * 测试钩:**不起 SSE 流**,直接把一帧喂进(缺则新建)指定 run 的台账 —— 折叠规则走产品那一份
122
+ * `foldWorkflowActivityFrame`,不是测试自己抄一份。建出来的台账是 closed 的,后续
123
+ * `ensureWorkflowActivityLedger` 命中它即早退,离线单测因此永不触网。
124
+ */
125
+ export declare function __feedWorkflowActivityFrameForTests(workflowId: string, frame: WorkflowStreamEvent): void;
66
126
  /**
67
127
  * createLiveWorkflowSource({ baseUrl, authToken, principal, workflowId? }) — the LIVE workflow-monitor source.
68
128
  *