newmark-agent 0.6.2 → 0.6.4

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.
@@ -5,6 +5,8 @@ import { ConversationRuntimeTarget, NormalizedConversationTarget } from './conve
5
5
  export type ConversationQueueMode = 'steer' | 'followUp';
6
6
  export interface ConversationQueueItemSnapshot {
7
7
  id: string;
8
+ /** Authoritative continuation-v1 build id (null for legacy/in-memory rows). */
9
+ buildId?: string;
8
10
  text: string;
9
11
  queueMode: ConversationQueueMode;
10
12
  requestedMode?: string;
@@ -12,8 +14,17 @@ export interface ConversationQueueItemSnapshot {
12
14
  runId?: string;
13
15
  createdAt: string;
14
16
  images?: AgentPromptMessage['images'];
17
+ branchNodeId?: string;
18
+ branchPath?: string[];
19
+ /** Exact workspace ledger branch id used when this row was admitted. */
20
+ ledgerBranchId?: string;
21
+ modelSelection?: string;
22
+ /** Ledger reason shown when a queued row cannot run (for example DEPENDENCY_FAILED). */
23
+ waitingReason?: string;
24
+ /** True when the ledger currently blocks this row from being claimed. */
25
+ blocked?: boolean;
15
26
  }
16
- export type ConversationQueueAction = 'enqueue' | 'update' | 'delete' | 'reorder' | 'toggle_pause' | 'set_pause' | 'guide';
27
+ export type ConversationQueueAction = 'enqueue' | 'update' | 'delete' | 'reorder' | 'toggle_pause' | 'set_pause' | 'repair_blocked' | 'guide';
17
28
  export interface ConversationQueueActionInput {
18
29
  id?: string;
19
30
  text?: string;
@@ -21,11 +32,22 @@ export interface ConversationQueueActionInput {
21
32
  goalObjective?: string;
22
33
  createdAt?: string;
23
34
  images?: AgentPromptMessage['images'];
35
+ /** Runtime branch node that owns this queued user turn. */
36
+ branchNodeId?: string;
37
+ /** Full runtime branch path captured when the item was enqueued. */
38
+ branchPath?: string[];
39
+ /** Exact conversation runtime identity captured at enqueue time. */
40
+ targetRuntimeKey?: string;
41
+ workspaceKey?: string;
42
+ /** Provider-qualified model selected when the user enqueued this turn. */
43
+ modelSelection?: string;
24
44
  orderedIds?: string[];
25
45
  paused?: boolean;
26
46
  }
27
47
  export interface AgentPromptMessage {
28
48
  text: string;
49
+ /** Authoritative continuation-v1 build id for a queued user turn. */
50
+ buildId?: string;
29
51
  /** Public transcript text when the execution prompt contains hidden orchestration instructions. */
30
52
  visibleUserInput?: string;
31
53
  /** Public semantic mode label; execution policy still follows the runner mode. */
@@ -45,6 +67,13 @@ export interface AgentPromptMessage {
45
67
  createdAt?: string;
46
68
  guideId?: string;
47
69
  runId?: string;
70
+ /** Stable conversation/branch ownership for queued user turns. */
71
+ branchNodeId?: string;
72
+ branchPath?: string[];
73
+ ledgerBranchId?: string;
74
+ targetRuntimeKey?: string;
75
+ workspaceKey?: string;
76
+ modelSelection?: string;
48
77
  /**
49
78
  * dev-0.4.3: 同一 Build block 内连续到达的多个 Guide 会被 conversation
50
79
  * kernel 合并为一次 provider 续接,而不是每来一个 Guide 就响应一次。
@@ -200,7 +229,31 @@ export declare class ConversationKernel {
200
229
  /** Detach idle owners before config replacement or workspace removal. */
201
230
  disposeIdle(workspaceKey?: string): string[];
202
231
  /** A Flow and its queue share one Agent; no second history writer is created. */
203
- beginExternalRun(targetInput: ConversationTargetInput, options: ConversationKernelRunOptions, createOwner: () => Agent, previousQueuePaused?: boolean): Agent;
232
+ beginExternalRun(targetInput: ConversationTargetInput, options: ConversationKernelRunOptions, createOwner: () => Agent, previousQueuePaused?: boolean, buildInput?: {
233
+ commandId?: string;
234
+ text: string;
235
+ requestedMode?: string;
236
+ goalObjective?: string;
237
+ modelSelection?: string;
238
+ branchNodeId?: string;
239
+ branchPath?: string[];
240
+ resume?: boolean;
241
+ existingBuildId?: string;
242
+ }): Agent;
243
+ /**
244
+ * Admit a Flow build at command-acceptance time. The Flow may wait behind a
245
+ * running Build, but its queue position (and therefore the parent of every
246
+ * later Next item) is fixed now, not when the Flow finally starts.
247
+ */
248
+ admitExternalBuild(targetInput: ConversationTargetInput, buildInput: {
249
+ commandId: string;
250
+ text: string;
251
+ requestedMode?: string;
252
+ goalObjective?: string;
253
+ modelSelection?: string;
254
+ branchNodeId?: string;
255
+ branchPath?: string[];
256
+ }): string | null;
204
257
  settleExternalRun(target: ConversationTargetInput, completed: boolean): void;
205
258
  releaseExternalRun(target: ConversationTargetInput, paused: boolean): void;
206
259
  prepareForArchive(target: ConversationTargetInput): Promise<Agent | null>;
@@ -225,6 +278,19 @@ export declare class ConversationKernel {
225
278
  */
226
279
  private drainQueuedFollowUpMessage;
227
280
  queueItems(target: ConversationTargetInput): ConversationQueueItemSnapshot[];
281
+ /**
282
+ * Capture the exact runtime branch that owns a queued user turn. A queued
283
+ * Next is a new user turn, but it must still land on the branch the user was
284
+ * viewing when they enqueued it, not on whatever branch happens to be active
285
+ * when the previous Build settles.
286
+ */
287
+ private runtimeBranchIdentity;
288
+ /**
289
+ * Map the current conversation/branch model onto the continuation-v1
290
+ * Root/Branch identity. The ledger is workspace-scoped and shared by the
291
+ * PC GUI, hosted mobile API and isolated runtimes.
292
+ */
293
+ private continuationStore;
228
294
  enqueueNext(target: ConversationTargetInput, input: {
229
295
  id: string;
230
296
  text: string;
@@ -232,11 +298,23 @@ export declare class ConversationKernel {
232
298
  goalObjective?: string;
233
299
  createdAt?: string;
234
300
  images?: AgentPromptMessage['images'];
301
+ branchNodeId?: string;
302
+ branchPath?: string[];
303
+ modelSelection?: string;
304
+ targetRuntimeKey?: string;
235
305
  }): ConversationQueueItemSnapshot;
236
306
  updateQueueItem(target: ConversationTargetInput, idInput: string, textInput: string, input?: ConversationQueueActionInput): ConversationQueueItemSnapshot;
237
307
  deleteQueueItem(target: ConversationTargetInput, idInput: string): boolean;
238
308
  reorderQueueItems(target: ConversationTargetInput, orderedIdsInput: string[]): ConversationQueueItemSnapshot[];
239
309
  setQueuePaused(target: ConversationTargetInput, paused: boolean): boolean;
310
+ /**
311
+ * dev-0.6.4 hotfix: 显式修复被失败前置阻断的排队行。
312
+ *
313
+ * 0.6.3 的合约是「失败/取消阻断后继,且不静默跳过」,所以这里不挂在恢复动作上
314
+ * 自动执行;它必须由用户的显式动作触发(界面上的“修复受阻队列”按钮)。每一次
315
+ * 改挂都写入 `BuildQueueRepaired` 事件并发布可见状态,触发者与原因可审计。
316
+ */
317
+ private repairBlockedQueueNow;
240
318
  queueAction(target: ConversationTargetInput, action: ConversationQueueAction, input?: ConversationQueueActionInput): {
241
319
  ok: boolean;
242
320
  queueItems: ConversationQueueItemSnapshot[];
@@ -325,6 +403,12 @@ export declare class ConversationKernel {
325
403
  private runtime;
326
404
  private scheduleGoalContinuation;
327
405
  private schedulePendingRuntimeContinuation;
406
+ /**
407
+ * Restore the runtime branch captured by a queued user turn. If the branch
408
+ * disappeared (manual deletion/rewind), fail the queued item into the
409
+ * existing pause/retry path instead of appending it to a different branch.
410
+ */
411
+ private bindQueuedTurnBranch;
328
412
  private runPendingQueueItem;
329
413
  private startGoalDrivenBuild;
330
414
  private createRunner;
@@ -345,6 +429,13 @@ export declare class ConversationKernel {
345
429
  private emitQueueUpdate;
346
430
  private clearQueued;
347
431
  private queueState;
432
+ /**
433
+ * Merge queue continuations persisted by another owner/kernel into this
434
+ * runtime's in-memory projection. Flow takeover, cold restore and a pool
435
+ * hand-off must not lose an already-admitted Next row. Deduplication is by
436
+ * the stable clientMessageId, never by text.
437
+ */
438
+ private reconcilePendingContinuations;
348
439
  private normalizeTarget;
349
440
  private workspaceForId;
350
441
  private findRuntime;