@1agents/acp-service 0.10.8 → 0.10.10

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 (94) hide show
  1. package/dist/bin/a2a.js +12 -1
  2. package/dist/src/a2a/gateway.d.ts +268 -2
  3. package/dist/src/a2a/gateway.js +337 -25
  4. package/dist/src/a2a/job-directory.d.ts +5 -0
  5. package/dist/src/a2a/job-directory.js +15 -0
  6. package/dist/src/a2a/preflight.d.ts +38 -0
  7. package/dist/src/a2a/preflight.js +56 -8
  8. package/dist/src/a2a/types.d.ts +8 -0
  9. package/dist/src/execution/case-view.d.ts +109 -0
  10. package/dist/src/execution/case-view.js +125 -0
  11. package/dist/src/execution/cases.d.ts +56 -0
  12. package/dist/src/execution/cases.js +77 -0
  13. package/dist/src/execution/externals.d.ts +83 -0
  14. package/dist/src/execution/externals.js +61 -0
  15. package/dist/src/execution/handoff.d.ts +54 -1
  16. package/dist/src/execution/handoff.js +80 -15
  17. package/dist/src/execution/ledger.d.ts +35 -2
  18. package/dist/src/execution/ledger.js +72 -2
  19. package/dist/src/execution/snapshots.d.ts +28 -0
  20. package/dist/src/execution/snapshots.js +64 -0
  21. package/dist/src/execution/targets.d.ts +63 -0
  22. package/dist/src/execution/targets.js +15 -1
  23. package/dist/src/execution/workbench.d.ts +5 -1
  24. package/dist/src/execution/workbench.js +13 -4
  25. package/dist/workbench-ui/app.css +18 -0
  26. package/dist/workbench-ui/app.js +13 -13
  27. package/package.json +12 -13
  28. package/vendor/dsh/a2a-executor.d.ts +2 -2
  29. package/vendor/dsh/adapter.d.ts +4 -4
  30. package/vendor/dsh/cordis.patch.yml +6 -5
  31. package/vendor/dsh/handoff-executor.d.ts +7 -0
  32. package/vendor/dsh/handoff-executor.js +28 -0
  33. package/vendor/dsh/handoff-spec.d.ts +26 -0
  34. package/vendor/dsh/handoff-spec.js +14 -0
  35. package/vendor/dsh/handoff-tools.d.ts +4 -0
  36. package/vendor/dsh/handoff-tools.js +20 -0
  37. package/vendor/dsh/index.js +8 -0
  38. package/vendor/dsh/review-mcp.js +6 -2
  39. package/vendor/dsh/review.d.ts +3 -0
  40. package/vendor/dsh/review.js +19 -0
  41. package/vendor/dsh/service-process.d.ts +9 -1
  42. package/vendor/dsh/service-process.js +69 -3
  43. package/vendor/dsh/ticket-tools.d.ts +1 -1
  44. package/vendor/runtime/dist/{cli-DXmYwv3U.js → cli-BwanDcOo.js} +4 -4
  45. package/vendor/runtime/dist/{cli-DXmYwv3U.js.map → cli-BwanDcOo.js.map} +1 -1
  46. package/vendor/runtime/dist/cli.js +8 -8
  47. package/vendor/runtime/dist/{client-VQsqcIOJ.d.ts → client-C5zneoBs.d.ts} +3 -1
  48. package/vendor/runtime/dist/{client-VQsqcIOJ.d.ts.map → client-C5zneoBs.d.ts.map} +1 -1
  49. package/vendor/runtime/dist/docs-site/.nojekyll +0 -0
  50. package/vendor/runtime/dist/docs-site/CLI.html +833 -0
  51. package/vendor/runtime/dist/docs-site/VISION.html +415 -0
  52. package/vendor/runtime/dist/docs-site/agents.html +391 -0
  53. package/vendor/runtime/dist/docs-site/compare.html +359 -0
  54. package/vendor/runtime/dist/docs-site/config.html +450 -0
  55. package/vendor/runtime/dist/docs-site/custom-agents.html +408 -0
  56. package/vendor/runtime/dist/docs-site/exit-codes.html +347 -0
  57. package/vendor/runtime/dist/docs-site/favicon.svg +21 -0
  58. package/vendor/runtime/dist/docs-site/flows.html +498 -0
  59. package/vendor/runtime/dist/docs-site/index.html +367 -0
  60. package/vendor/runtime/dist/docs-site/install.html +386 -0
  61. package/vendor/runtime/dist/docs-site/llms.txt +36 -0
  62. package/vendor/runtime/dist/docs-site/output-formats.html +407 -0
  63. package/vendor/runtime/dist/docs-site/permissions.html +422 -0
  64. package/vendor/runtime/dist/docs-site/prompting.html +460 -0
  65. package/vendor/runtime/dist/docs-site/quickstart.html +382 -0
  66. package/vendor/runtime/dist/docs-site/releasing.html +341 -0
  67. package/vendor/runtime/dist/docs-site/runtime-environment.html +329 -0
  68. package/vendor/runtime/dist/docs-site/runtime-process-lifecycle.html +336 -0
  69. package/vendor/runtime/dist/docs-site/safe-errors.html +323 -0
  70. package/vendor/runtime/dist/docs-site/session-control.html +408 -0
  71. package/vendor/runtime/dist/docs-site/session-watch.html +354 -0
  72. package/vendor/runtime/dist/docs-site/sessions.html +488 -0
  73. package/vendor/runtime/dist/docs-site/shared-sessions.html +377 -0
  74. package/vendor/runtime/dist/{flows-DJ17ajbw.js → flows-CzLUHUTS.js} +4 -4
  75. package/vendor/runtime/dist/{flows-DJ17ajbw.js.map → flows-CzLUHUTS.js.map} +1 -1
  76. package/vendor/runtime/dist/flows.d.ts +1 -1
  77. package/vendor/runtime/dist/flows.js +1 -1
  78. package/vendor/runtime/dist/{invocation-options-PBfCgrdi.js → invocation-options-B6pIpdpR.js} +4 -4
  79. package/vendor/runtime/dist/{invocation-options-PBfCgrdi.js.map → invocation-options-B6pIpdpR.js.map} +1 -1
  80. package/vendor/runtime/dist/{ipc-BQQpcEdP.js → ipc-ivLtSAdL.js} +21 -3
  81. package/vendor/runtime/dist/ipc-ivLtSAdL.js.map +1 -0
  82. package/vendor/runtime/dist/{output-B3MDn7kv.js → output-BqKnXXb0.js} +3 -3
  83. package/vendor/runtime/dist/{output-B3MDn7kv.js.map → output-BqKnXXb0.js.map} +1 -1
  84. package/vendor/runtime/dist/{queue-owner-runtime-DXCVngwU.js → queue-owner-runtime-DXJND10J.js} +11 -2
  85. package/vendor/runtime/dist/queue-owner-runtime-DXJND10J.js.map +1 -0
  86. package/vendor/runtime/dist/runtime.d.ts +1 -1
  87. package/vendor/runtime/dist/runtime.d.ts.map +1 -1
  88. package/vendor/runtime/dist/runtime.js +3 -3
  89. package/vendor/runtime/dist/{session-watch-DURyCw31.js → session-watch-BHB3_PXm.js} +4 -4
  90. package/vendor/runtime/dist/{session-watch-DURyCw31.js.map → session-watch-BHB3_PXm.js.map} +1 -1
  91. package/vendor/runtime/dist/{watch-CIpoMaWD.js → watch-UjokHUfS.js} +2 -2
  92. package/vendor/runtime/dist/{watch-CIpoMaWD.js.map → watch-UjokHUfS.js.map} +1 -1
  93. package/vendor/runtime/dist/ipc-BQQpcEdP.js.map +0 -1
  94. package/vendor/runtime/dist/queue-owner-runtime-DXCVngwU.js.map +0 -1
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The frozen bytes of an accepted handoff.
3
+ *
4
+ * The store keeps files by their digest, so a later round of the source job cannot change what an accepted
5
+ * handoff points at. Every read re-hashes the file: bytes that no longer match their digest are refused.
6
+ */
7
+ import { createHash } from 'node:crypto';
8
+ import { mkdir, readFile, rename, writeFile } from 'node:fs/promises';
9
+ import { dirname, join } from 'node:path';
10
+ export class SnapshotError extends Error {
11
+ code;
12
+ constructor(code, message) {
13
+ super(message);
14
+ this.code = code;
15
+ this.name = 'SnapshotError';
16
+ }
17
+ }
18
+ export class SnapshotStore {
19
+ root;
20
+ constructor(root) {
21
+ this.root = root;
22
+ }
23
+ /** The path a frozen file is stored at, relative to the store's root. */
24
+ storedPath(caseId, handoffId, digest) {
25
+ return join(caseId, handoffId, digest);
26
+ }
27
+ absolute(storedPath) {
28
+ return join(this.root, storedPath);
29
+ }
30
+ /** Copy the bytes in. A file that is already frozen with the same digest is left alone. */
31
+ async freeze(input) {
32
+ const frozenAt = new Date().toISOString();
33
+ const output = [];
34
+ for (const file of input.files) {
35
+ const digest = createHash('sha256').update(file.bytes).digest('hex');
36
+ if (digest !== file.digest)
37
+ throw new SnapshotError('changed', 'The bytes do not match their digest');
38
+ const storedPath = this.storedPath(input.caseId, input.handoffId, digest);
39
+ const destination = this.absolute(storedPath);
40
+ await mkdir(dirname(destination), { recursive: true, mode: 0o700 });
41
+ const temporary = `${destination}.${process.pid}.tmp`;
42
+ await writeFile(temporary, file.bytes, { mode: 0o400 });
43
+ await rename(temporary, destination);
44
+ output.push({ digest, name: file.name, size: file.bytes.length, ...(file.mediaType ? { mediaType: file.mediaType } : {}),
45
+ storedPath, frozenAt });
46
+ }
47
+ return output;
48
+ }
49
+ /** Read the frozen bytes back. The digest is checked again on every read. */
50
+ async read(storedPath, expectedDigest) {
51
+ let content;
52
+ try {
53
+ content = await readFile(this.absolute(storedPath));
54
+ }
55
+ catch {
56
+ throw new SnapshotError('not_found', 'This frozen artifact is not available');
57
+ }
58
+ if (createHash('sha256').update(content).digest('hex') !== expectedDigest)
59
+ throw new SnapshotError('changed', 'The frozen artifact no longer matches its digest');
60
+ return content;
61
+ }
62
+ /** The absolute path a frozen file lives at on this host. */
63
+ absolutePath(storedPath) { return this.absolute(storedPath); }
64
+ }
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { type SandboxProfile } from '../a2a/preflight.js';
2
3
  export declare const executionConnectionConfigSchema: z.ZodObject<{
3
4
  connectionId: z.ZodString;
4
5
  provider: z.ZodDefault<z.ZodEnum<{
@@ -47,6 +48,16 @@ export declare const executionTargetBindingSchema: z.ZodObject<{
47
48
  agentFile: z.ZodOptional<z.ZodString>;
48
49
  provider: z.ZodOptional<z.ZodString>;
49
50
  model: z.ZodOptional<z.ZodString>;
51
+ sandbox: z.ZodOptional<z.ZodObject<{
52
+ name: z.ZodString;
53
+ image: z.ZodOptional<z.ZodString>;
54
+ network: z.ZodDefault<z.ZodEnum<{
55
+ bridge: "bridge";
56
+ none: "none";
57
+ }>>;
58
+ writableRoots: z.ZodOptional<z.ZodArray<z.ZodString>>;
59
+ env: z.ZodOptional<z.ZodArray<z.ZodString>>;
60
+ }, z.core.$strict>>;
50
61
  }, z.core.$strict>;
51
62
  export declare const executionTargetConfigSchema: z.ZodObject<{
52
63
  targetId: z.ZodString;
@@ -82,6 +93,16 @@ export declare const executionTargetConfigSchema: z.ZodObject<{
82
93
  agentFile: z.ZodOptional<z.ZodString>;
83
94
  provider: z.ZodOptional<z.ZodString>;
84
95
  model: z.ZodOptional<z.ZodString>;
96
+ sandbox: z.ZodOptional<z.ZodObject<{
97
+ name: z.ZodString;
98
+ image: z.ZodOptional<z.ZodString>;
99
+ network: z.ZodDefault<z.ZodEnum<{
100
+ bridge: "bridge";
101
+ none: "none";
102
+ }>>;
103
+ writableRoots: z.ZodOptional<z.ZodArray<z.ZodString>>;
104
+ env: z.ZodOptional<z.ZodArray<z.ZodString>>;
105
+ }, z.core.$strict>>;
85
106
  }, z.core.$strict>>;
86
107
  }, z.core.$strict>;
87
108
  export declare const executionTargetSchema: z.ZodObject<{
@@ -118,6 +139,16 @@ export declare const executionTargetSchema: z.ZodObject<{
118
139
  agentFile: z.ZodOptional<z.ZodString>;
119
140
  provider: z.ZodOptional<z.ZodString>;
120
141
  model: z.ZodOptional<z.ZodString>;
142
+ sandbox: z.ZodOptional<z.ZodObject<{
143
+ name: z.ZodString;
144
+ image: z.ZodOptional<z.ZodString>;
145
+ network: z.ZodDefault<z.ZodEnum<{
146
+ bridge: "bridge";
147
+ none: "none";
148
+ }>>;
149
+ writableRoots: z.ZodOptional<z.ZodArray<z.ZodString>>;
150
+ env: z.ZodOptional<z.ZodArray<z.ZodString>>;
151
+ }, z.core.$strict>>;
121
152
  }, z.core.$strict>>;
122
153
  configVersion: z.ZodNumber;
123
154
  createdAt: z.ZodString;
@@ -259,6 +290,16 @@ export declare const TARGET_METHODS: {
259
290
  agentFile: z.ZodOptional<z.ZodString>;
260
291
  provider: z.ZodOptional<z.ZodString>;
261
292
  model: z.ZodOptional<z.ZodString>;
293
+ sandbox: z.ZodOptional<z.ZodObject<{
294
+ name: z.ZodString;
295
+ image: z.ZodOptional<z.ZodString>;
296
+ network: z.ZodDefault<z.ZodEnum<{
297
+ bridge: "bridge";
298
+ none: "none";
299
+ }>>;
300
+ writableRoots: z.ZodOptional<z.ZodArray<z.ZodString>>;
301
+ env: z.ZodOptional<z.ZodArray<z.ZodString>>;
302
+ }, z.core.$strict>>;
262
303
  }, z.core.$strict>>;
263
304
  }, z.core.$strict>>;
264
305
  };
@@ -300,6 +341,16 @@ export declare const TARGET_METHODS: {
300
341
  agentFile: z.ZodOptional<z.ZodString>;
301
342
  provider: z.ZodOptional<z.ZodString>;
302
343
  model: z.ZodOptional<z.ZodString>;
344
+ sandbox: z.ZodOptional<z.ZodObject<{
345
+ name: z.ZodString;
346
+ image: z.ZodOptional<z.ZodString>;
347
+ network: z.ZodDefault<z.ZodEnum<{
348
+ bridge: "bridge";
349
+ none: "none";
350
+ }>>;
351
+ writableRoots: z.ZodOptional<z.ZodArray<z.ZodString>>;
352
+ env: z.ZodOptional<z.ZodArray<z.ZodString>>;
353
+ }, z.core.$strict>>;
303
354
  }, z.core.$strict>>;
304
355
  }, z.core.$strict>;
305
356
  }, z.core.$strict>>;
@@ -349,6 +400,16 @@ export declare const TARGET_METHODS: {
349
400
  agentFile: z.ZodOptional<z.ZodOptional<z.ZodString>>;
350
401
  provider: z.ZodOptional<z.ZodOptional<z.ZodString>>;
351
402
  model: z.ZodOptional<z.ZodOptional<z.ZodString>>;
403
+ sandbox: z.ZodOptional<z.ZodOptional<z.ZodObject<{
404
+ name: z.ZodString;
405
+ image: z.ZodOptional<z.ZodString>;
406
+ network: z.ZodDefault<z.ZodEnum<{
407
+ bridge: "bridge";
408
+ none: "none";
409
+ }>>;
410
+ writableRoots: z.ZodOptional<z.ZodArray<z.ZodString>>;
411
+ env: z.ZodOptional<z.ZodArray<z.ZodString>>;
412
+ }, z.core.$strict>>>;
352
413
  }, z.core.$strict>>;
353
414
  }, z.core.$strict>>;
354
415
  }, z.core.$strict>>;
@@ -378,6 +439,8 @@ export interface ExecutionTargetSnapshot {
378
439
  allowedDirectories: string[];
379
440
  executorVerificationRequired: true;
380
441
  };
442
+ /** The sandbox this target runs commands in, when it has one. */
443
+ sandbox?: SandboxProfile;
381
444
  }
382
445
  /** Use inside the gateway's single-owner lease; targets.json is not a transaction with gateway.json. */
383
446
  export declare class TargetDirectory {
@@ -3,6 +3,7 @@ import { createHash, randomUUID } from 'node:crypto';
3
3
  import { closeSync, fsyncSync, mkdirSync, openSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
4
4
  import path from 'node:path';
5
5
  import { z } from 'zod';
6
+ import { sandboxProfileSchema, sandboxViolation } from '../a2a/preflight.js';
6
7
  const id = z.string().trim().min(1).max(256).regex(/^[A-Za-z0-9][A-Za-z0-9.:_-]*$/);
7
8
  const text = z.string().trim().min(1).max(4096);
8
9
  const version = z.number().int().positive();
@@ -35,6 +36,8 @@ export const executionTargetBindingSchema = z.object({
35
36
  agentFile: absolutePath.optional(),
36
37
  // A path agent on a DSH-native preset may fix its model; both are passed together and checked against the host catalog.
37
38
  provider: id.optional(), model: text.optional(),
39
+ /** The sandbox this target runs commands in. Only a target that runs commands needs one. */
40
+ sandbox: sandboxProfileSchema.optional(),
38
41
  }).strict();
39
42
  export const executionTargetConfigSchema = z.object({
40
43
  targetId: id, kind: z.enum(['agent_host', 'resident_agent', 'workflow']), name: text,
@@ -287,6 +290,16 @@ export class TargetDirectory {
287
290
  this.checkDirectory(binding.cwd, binding.allowedDirectories);
288
291
  if (binding.agentPreset && binding.allowedPresets && !binding.allowedPresets.includes(binding.agentPreset))
289
292
  throw new Error('Fixed preset is outside the allowed preset scope');
293
+ // A sandbox profile is configuration for a target that runs commands; it never reaches the host credentials.
294
+ if (binding.sandbox) {
295
+ const violation = sandboxViolation(binding.sandbox);
296
+ if (violation)
297
+ throw new Error(violation);
298
+ if (binding.sandbox.writableRoots?.length && binding.cwd) {
299
+ for (const root of binding.sandbox.writableRoots)
300
+ this.checkDirectory(root, binding.sandbox.writableRoots);
301
+ }
302
+ }
290
303
  }
291
304
  }
292
305
  checkDirectory(cwd, allowed) {
@@ -341,7 +354,8 @@ export class TargetDirectory {
341
354
  throw new Error('Requested preset is outside allowedPresets');
342
355
  return clone({ target, connection, configVersion: target.configVersion, connectionVersion: connection.connectionVersion,
343
356
  remote: connection.remote, endpoint: connection.endpoint, cwd, agentPreset, input: resolvedInput,
344
- ...(target.binding.allowedDirectories ? { directoryPolicy: { allowedDirectories: target.binding.allowedDirectories, executorVerificationRequired: true } } : {}) });
357
+ ...(target.binding.allowedDirectories ? { directoryPolicy: { allowedDirectories: target.binding.allowedDirectories, executorVerificationRequired: true } } : {}),
358
+ ...(target.binding.sandbox ? { sandbox: clone(target.binding.sandbox) } : {}) });
345
359
  }
346
360
  getHealth(targetId) {
347
361
  const target = this.getTarget(targetId), connection = this.getConnection(target.connectionId);
@@ -1,5 +1,5 @@
1
1
  /** Human-readable projections of the execution ledger. Reading never dispatches or acknowledges work. */
2
- import type { BusinessAcceptance, JobRef, LedgerActor, LedgerAttempt, LedgerEvent, LedgerState } from './ledger.js';
2
+ import type { BusinessAcceptance, JobRef, LedgerActor, LedgerAttempt, LedgerEvent, LedgerJob, LedgerState } from './ledger.js';
3
3
  import type { ReportReviewRun } from './report-review.js';
4
4
  import type { PptDeliveryRun } from './ppt-delivery.js';
5
5
  import { deliveryProgress } from './delivery-progress.js';
@@ -48,6 +48,8 @@ export interface AcpTaskSummary {
48
48
  pendingReviewId?: string;
49
49
  pendingProcessRequestId?: string;
50
50
  progressSummary: string;
51
+ /** A handoff this task proposed that nobody has answered yet. */
52
+ pendingHandoffId?: string;
51
53
  channel: 'trial' | 'formal' | 'standalone';
52
54
  agentId?: string;
53
55
  agentName?: string;
@@ -145,6 +147,8 @@ export interface WorkbenchListQuery {
145
147
  limit?: number;
146
148
  offset?: number;
147
149
  }
150
+ /** The next hops this job may take, with the condition each one waits for. A threshold compares measured facts. */
151
+ export declare function legalNextForJob(ledger: LedgerState, job: LedgerJob): LegalNext[];
148
152
  export declare function workbenchSnapshot(source: WorkbenchSource): WorkbenchSnapshot;
149
153
  export declare function listWorkbenchTasks(snapshot: WorkbenchSnapshot, query?: WorkbenchListQuery): {
150
154
  items: AcpTaskSummary[];
@@ -1,6 +1,7 @@
1
1
  import { deliveryProgress } from './delivery-progress.js';
2
2
  import { projectProcessRequest } from './process-request.js';
3
3
  import { describeTaskDevelopment, projectWorkbenchAgents } from './agent-registry.js';
4
+ import { factSatisfied } from './externals.js';
4
5
  const stageNames = { summary: '文稿生成', human_review: '人工审核', make: '设计制作', validate: '机器校验', review: '独立验收', finished: '交付完成' };
5
6
  const purposeNames = { project_script: '文稿生成', ppt_production: '设计制作', independent_review: '独立验收' };
6
7
  const terminal = new Set(['completed', 'failed', 'canceled', 'rejected']);
@@ -15,17 +16,23 @@ function runDescription(run) {
15
16
  return ({ summary: '文稿作者正在生成或修订文字稿。', make: '制作角色正在根据确认的文字稿设计 PPT。', validate: '正在检查制作产物的文件与结构。',
16
17
  review: '独立验收角色正在核对事实和页面效果。', finished: '交付已完成,可查看最终产物。' })[run.stage];
17
18
  }
18
- function legalNext(ledger, job) {
19
+ /** The next hops this job may take, with the condition each one waits for. A threshold compares measured facts. */
20
+ export function legalNextForJob(ledger, job) {
19
21
  if (!job.caseId)
20
22
  return [];
21
23
  const attempt = ledger.attempts[job.currentAttemptId];
22
24
  const acceptance = [...(ledger.acceptances[job.jobId] ?? [])].reverse().find(item => item.attemptId === job.currentAttemptId && item.resultDigest === attempt?.result?.resultDigest && item.resultRevision === attempt?.result?.resultRevision);
23
25
  const closed = ledger.tickets?.[job.jobId]?.status === 'closed';
26
+ const facts = (ledger.facts ?? []).filter(item => item.originSessionId === job.originSessionId && item.caseId === job.caseId)
27
+ .map(item => ({ metric: item.metric, value: item.value }));
24
28
  const applies = (rule) => rule.originSessionId === job.originSessionId && rule.caseId === job.caseId
25
29
  && (!rule.fromPurpose || rule.fromPurpose === job.purpose) && (!rule.fromTargetId || rule.fromTargetId === job.targetId) && rule.toTargetId !== job.targetId;
26
30
  return (ledger.conventions ?? []).filter(applies).map(rule => ({
27
31
  conventionId: rule.conventionId, toTargetId: rule.toTargetId, purpose: rule.toPurpose, requireHuman: rule.requireHuman, when: rule.when,
28
- achieved: rule.when === 'ticket_closed' ? Boolean(closed) : acceptance?.reviewStatus === 'accepted' && attempt?.result?.resultAvailable === true,
32
+ achieved: rule.when === 'ticket_closed' ? Boolean(closed)
33
+ : rule.when === 'fact_reached' ? Boolean(rule.condition && facts.some(fact => fact.metric === rule.condition.metric
34
+ && factSatisfied(fact.value, rule.condition.operator, rule.condition.value)))
35
+ : acceptance?.reviewStatus === 'accepted' && attempt?.result?.resultAvailable === true,
29
36
  }));
30
37
  }
31
38
  function byNewest(items) { return items.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt)); }
@@ -216,6 +223,7 @@ function summary(job, run, reviews, ledger, actorId, requests, now) {
216
223
  : attempt?.diagnostic || (run ? runDescription(run) : attempt?.result?.resultSummary || stateDescriptions[job.executionStatus] || '等待同步执行进展。');
217
224
  const execution = executionView(attempt, job.targetId, Boolean(run));
218
225
  const development = describeTaskDevelopment(attempt?.targetSnapshot?.development, { targetId: job.targetId, resident: execution.kind === 'resident', residentName: execution.targetName });
226
+ const pendingHandoff = (ledger.handoffs ?? []).find(item => item.fromJobId === job.jobId && item.status === 'proposed');
219
227
  return { sourceId: job.sourceId, jobId: job.jobId, title: job.title ?? `${purposeNames[job.purpose ?? ''] ?? '执行任务'} ${job.jobId.slice(0, 8)}`,
220
228
  channel: development.channel, ...(development.agentId ? { agentId: development.agentId, agentName: development.name, agentPhase: development.phase } : {}),
221
229
  originSessionId: job.originSessionId, ...(job.caseId ? { caseId: job.caseId } : {}), ...(job.parentJobRef ? { parentJobRef: job.parentJobRef } : {}), ...(job.parentAttemptId ? { parentAttemptId: job.parentAttemptId } : {}),
@@ -224,6 +232,7 @@ function summary(job, run, reviews, ledger, actorId, requests, now) {
224
232
  inFlightAttemptIds: [...job.inFlightAttemptIds], unresolvedAttemptIds: [...job.unresolvedAttemptIds], execution,
225
233
  ...(review ? { reviewStatus: review.status } : {}), ...(pending && review.reviewerId === actorId ? { pendingReviewId: review.reviewId } : {}),
226
234
  ...(pendingRequest ? { pendingProcessRequestId: pendingRequest.requestId } : {}), progressSummary,
235
+ ...(pendingHandoff ? { pendingHandoffId: pendingHandoff.handoffId } : {}),
227
236
  ...(acceptance ? { businessAcceptance: structuredClone(acceptance) } : {}), ...(blocked.length ? { blockedTools: blocked } : {}),
228
237
  ...(job.executionStatus === 'failed' && !run && !job.parentJobRef && !job.unresolvedAttemptIds.length ? { canContinue: true } : {}),
229
238
  ...(job.executionStatus === 'completed' && !run && !job.parentJobRef && !acceptance && attempt?.result?.resultAvailable && attempt.result.resultRevision && attempt.result.resultDigest ? { canAccept: true } : {}),
@@ -285,7 +294,7 @@ export function workbenchSnapshot(source) {
285
294
  label: handoff.status === 'taken' ? '已交接' : handoff.status === 'accepted' ? '待开下一单' : '提议交接',
286
295
  handoffId: handoff.handoffId, status: handoff.status });
287
296
  }
288
- const next = legalNext(ledger, job);
297
+ const next = legalNextForJob(ledger, job);
289
298
  // Only this explicit domain workflow supplies its own stage ordering. Parent refs alone never imply dependencies.
290
299
  if (run) {
291
300
  const last = (purpose) => [...run.children].reverse().find(item => item.purpose === purpose)?.child.jobId;
@@ -357,7 +366,7 @@ export function workbenchSnapshot(source) {
357
366
  export function listWorkbenchTasks(snapshot, query = {}) {
358
367
  const filter = query.filter ?? 'all', offset = Math.max(0, Math.trunc(query.offset ?? 0)), limit = Math.min(200, Math.max(1, Math.trunc(query.limit ?? 50)));
359
368
  const rootIds = new Set(snapshot.tasks.filter(task => !task.parentJobRef || !Object.hasOwn(snapshot.details, task.parentJobRef.jobId)).map(task => task.jobId));
360
- const needsPerson = (task) => Boolean(task.pendingReviewId || task.pendingProcessRequestId);
369
+ const needsPerson = (task) => Boolean(task.pendingReviewId || task.pendingProcessRequestId || task.pendingHandoffId);
361
370
  const isWorking = (task) => task.displayStatus === 'resuming' || !needsPerson(task) && task.displayStatus !== 'unwatched' && ['working', 'submitted', 'not_started'].includes(task.executionStatus);
362
371
  const isFailed = (task) => task.unresolvedAttemptIds.length > 0 || task.displayStatus === 'tool_blocked' || task.displayStatus === 'unwatched' || ['failed', 'rejected', 'unknown', 'auth_required', 'input_required'].includes(task.executionStatus) && !['awaiting_human', 'resuming'].includes(task.displayStatus);
363
372
  const roots = snapshot.tasks.filter(task => rootIds.has(task.jobId));
@@ -343,6 +343,24 @@ th { color: var(--text-muted); font-weight: 500; white-space: nowrap; font-size:
343
343
  .fp-md.acp-md > * + :is(h1, h2, h3, h4) { margin-top: var(--space-5); }
344
344
  .fp-md.acp-md li + li { margin-top: var(--space-1); }
345
345
 
346
+ /* A thing is the first screen of the workbench: its list on the left, its detail on the right. */
347
+ .acp-case-create { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 12px; border: 1px solid var(--border-color); border-radius: var(--radius); }
348
+ .acp-case-create label { display: grid; gap: 4px; font-size: 12px; color: var(--text-muted); flex: 1 1 240px; }
349
+ .acp-case-create input, .acp-case-create select { padding: 6px 8px; border: 1px solid var(--border-color); border-radius: var(--radius); background: var(--bg-panel); color: var(--text-main); }
350
+ .acp-case-panel { min-height: 0; display: flex; }
351
+ .acp-case-panel .acp-detail { flex: 1; }
352
+ /* With a case open, its list and its detail sit side by side and scroll on their own. */
353
+ .has-case-detail { grid-template-columns: minmax(0, 1fr) minmax(360px, 46%); }
354
+ .has-case-detail .acp-workbench-table { overflow-x: auto; }
355
+ @media (max-width: 800px) { .has-case-detail { grid-template-columns: minmax(0, 1fr); } }
356
+ /* A happened edge is solid; a proposal is dashed and names no destination job. */
357
+ .acp-case-edges li { grid-template-columns: 24px 1fr auto; align-items: center; }
358
+ .acp-case-edge-line { display: block; width: 24px; height: 0; border-top: 2px solid var(--text-secondary); }
359
+ .acp-case-edge.is-proposed .acp-case-edge-line { border-top-style: dashed; border-top-color: var(--text-muted); }
360
+ .acp-case-edge.is-happened .acp-case-edge-line { border-top-color: var(--success); }
361
+ .acp-inbox-list li { grid-template-columns: max-content 1fr auto; align-items: center; }
362
+ .acp-case-detail .acp-artifact-drawer { height: 50%; }
363
+
346
364
  /* Colors come from the host's tokens when present and fall back to a neutral light/dark pair. */
347
365
  .fp-root, .fp-md {
348
366
  --fp-bg: var(--bg-card, #ffffff);