@1agents/acp-service 0.9.0 → 0.9.1
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/README.md +19 -13
- package/dist/bin/a2a.js +6 -2
- package/dist/bin/acp-service.js +24 -0
- package/dist/bin/process.d.ts +4 -0
- package/dist/bin/process.js +57 -0
- package/dist/bin/rsi.d.ts +3 -0
- package/dist/bin/rsi.js +114 -0
- package/dist/bin/ticket.d.ts +13 -0
- package/dist/bin/ticket.js +97 -0
- package/dist/bin/trail.d.ts +4 -0
- package/dist/bin/trail.js +62 -0
- package/dist/src/a2a/artifact-content.d.ts +9 -0
- package/dist/src/a2a/artifact-content.js +45 -0
- package/dist/src/a2a/desktop-notify.d.ts +1 -0
- package/dist/src/a2a/desktop-notify.js +12 -0
- package/dist/src/a2a/execution-binding.d.ts +9 -0
- package/dist/src/a2a/execution-binding.js +19 -0
- package/dist/src/a2a/executor.d.ts +6 -0
- package/dist/src/a2a/executor.js +112 -12
- package/dist/src/a2a/gateway.d.ts +537 -2
- package/dist/src/a2a/gateway.js +1014 -87
- package/dist/src/a2a/index.d.ts +8 -1
- package/dist/src/a2a/index.js +4 -0
- package/dist/src/a2a/job-directory.d.ts +6 -0
- package/dist/src/a2a/job-directory.js +19 -0
- package/dist/src/a2a/preflight.js +16 -1
- package/dist/src/a2a/resubmit.d.ts +46 -0
- package/dist/src/a2a/resubmit.js +82 -0
- package/dist/src/a2a/result-metadata.d.ts +3 -0
- package/dist/src/a2a/result-metadata.js +23 -5
- package/dist/src/a2a/server.d.ts +10 -0
- package/dist/src/a2a/server.js +125 -1
- package/dist/src/a2a/session-lifecycle.d.ts +40 -0
- package/dist/src/a2a/session-lifecycle.js +54 -0
- package/dist/src/a2a/store.d.ts +4 -0
- package/dist/src/a2a/store.js +70 -1
- package/dist/src/a2a/types.d.ts +45 -0
- package/dist/src/a2a/workbench-ui.d.ts +28 -0
- package/dist/src/a2a/workbench-ui.js +182 -0
- package/dist/src/acp-connection.js +27 -3
- package/dist/src/bridge.d.ts +1 -0
- package/dist/src/bridge.js +191 -39
- package/dist/src/capacity-queue.d.ts +35 -0
- package/dist/src/capacity-queue.js +139 -2
- package/dist/src/capacity.d.ts +25 -0
- package/dist/src/capacity.js +48 -9
- package/dist/src/dsh.js +1 -1
- package/dist/src/execution/agent-files.d.ts +25 -0
- package/dist/src/execution/agent-files.js +90 -0
- package/dist/src/execution/agent-registry.d.ts +164 -0
- package/dist/src/execution/agent-registry.js +275 -0
- package/dist/src/execution/human-review.d.ts +2 -0
- package/dist/src/execution/human-review.js +3 -1
- package/dist/src/execution/ledger.d.ts +52 -0
- package/dist/src/execution/ledger.js +83 -5
- package/dist/src/execution/process-request.d.ts +151 -0
- package/dist/src/execution/process-request.js +177 -0
- package/dist/src/execution/targets.d.ts +15 -0
- package/dist/src/execution/targets.js +22 -3
- package/dist/src/execution/ticket-executor.d.ts +25 -0
- package/dist/src/execution/ticket-executor.js +27 -0
- package/dist/src/execution/ticket.d.ts +326 -0
- package/dist/src/execution/ticket.js +301 -0
- package/dist/src/execution/workbench-chat.d.ts +25 -0
- package/dist/src/execution/workbench-chat.js +54 -0
- package/dist/src/execution/workbench.d.ts +32 -1
- package/dist/src/execution/workbench.js +113 -22
- package/dist/src/rsi/gate.d.ts +25 -0
- package/dist/src/rsi/gate.js +59 -0
- package/dist/src/rsi/outline-run.d.ts +107 -0
- package/dist/src/rsi/outline-run.js +443 -0
- package/dist/workbench-ui/app.css +453 -0
- package/dist/workbench-ui/app.js +13 -0
- package/dist/workbench-ui/chunk-23JHGYT3.js +1 -0
- package/dist/workbench-ui/chunk-3H6STGPV.js +1 -0
- package/dist/workbench-ui/chunk-3SNBBMGH.js +1 -0
- package/dist/workbench-ui/chunk-3XJZ6DIE.js +1 -0
- package/dist/workbench-ui/chunk-44KDLLKJ.js +1 -0
- package/dist/workbench-ui/chunk-46H7FU5Y.js +7 -0
- package/dist/workbench-ui/chunk-4N44QPL7.js +1 -0
- package/dist/workbench-ui/chunk-4YN4BS7I.js +1 -0
- package/dist/workbench-ui/chunk-53EG4IVQ.js +96 -0
- package/dist/workbench-ui/chunk-5FIPUNR4.js +1 -0
- package/dist/workbench-ui/chunk-6DWWYA6G.js +2 -0
- package/dist/workbench-ui/chunk-6FU3T633.js +99 -0
- package/dist/workbench-ui/chunk-6XKIHRA4.js +1 -0
- package/dist/workbench-ui/chunk-7GIX43Y5.js +1 -0
- package/dist/workbench-ui/chunk-7Q4WBGX6.js +4 -0
- package/dist/workbench-ui/chunk-A3BQM7HR.js +1 -0
- package/dist/workbench-ui/chunk-AFCFDDOP.js +24 -0
- package/dist/workbench-ui/chunk-AG67EUYD.js +89 -0
- package/dist/workbench-ui/chunk-AGJHMMTN.js +1 -0
- package/dist/workbench-ui/chunk-AO6JUBV6.js +41 -0
- package/dist/workbench-ui/chunk-AUSLTP43.js +72 -0
- package/dist/workbench-ui/chunk-AVZL46TT.js +1 -0
- package/dist/workbench-ui/chunk-AZRIGIV2.js +168 -0
- package/dist/workbench-ui/chunk-B2LIVH37.js +1 -0
- package/dist/workbench-ui/chunk-B7YX5TR5.js +1 -0
- package/dist/workbench-ui/chunk-BCB4X4XX.js +1 -0
- package/dist/workbench-ui/chunk-BCRQUL2A.js +88 -0
- package/dist/workbench-ui/chunk-BI6UHHQP.js +1 -0
- package/dist/workbench-ui/chunk-BLSLQ4AQ.js +120 -0
- package/dist/workbench-ui/chunk-C3QSRS6E.js +1 -0
- package/dist/workbench-ui/chunk-CK7M2PJ3.js +62 -0
- package/dist/workbench-ui/chunk-CM6LZ7TU.js +1 -0
- package/dist/workbench-ui/chunk-CP63H27F.js +36 -0
- package/dist/workbench-ui/chunk-CPUMMIS2.js +70 -0
- package/dist/workbench-ui/chunk-CSEIBI5U.js +2 -0
- package/dist/workbench-ui/chunk-CUS65DKZ.js +161 -0
- package/dist/workbench-ui/chunk-CVQY7TNC.js +1 -0
- package/dist/workbench-ui/chunk-D6S3XBIX.js +106 -0
- package/dist/workbench-ui/chunk-E253Y562.js +1 -0
- package/dist/workbench-ui/chunk-EADDJUDC.js +1 -0
- package/dist/workbench-ui/chunk-EBGJ3YXG.js +206 -0
- package/dist/workbench-ui/chunk-EKPVZ3WY.js +8 -0
- package/dist/workbench-ui/chunk-EQDCEAFY.js +1 -0
- package/dist/workbench-ui/chunk-ES3SSDJY.js +40 -0
- package/dist/workbench-ui/chunk-ESFD2H7N.js +231 -0
- package/dist/workbench-ui/chunk-FVOHPMS6.js +1 -0
- package/dist/workbench-ui/chunk-FXMQAGVT.js +1 -0
- package/dist/workbench-ui/chunk-GGTADRXD.js +24 -0
- package/dist/workbench-ui/chunk-GHIVPGNQ.js +1 -0
- package/dist/workbench-ui/chunk-GLU2YQV2.js +1 -0
- package/dist/workbench-ui/chunk-GOCKBYSM.js +1 -0
- package/dist/workbench-ui/chunk-H2KMMTJB.js +1 -0
- package/dist/workbench-ui/chunk-HGVLDNPP.js +39 -0
- package/dist/workbench-ui/chunk-HSAVC5GY.js +1 -0
- package/dist/workbench-ui/chunk-HSEAD2JH.js +1 -0
- package/dist/workbench-ui/chunk-HSIHOBTY.js +1 -0
- package/dist/workbench-ui/chunk-IZXOKUGG.js +67 -0
- package/dist/workbench-ui/chunk-JFT2LC2T.js +1 -0
- package/dist/workbench-ui/chunk-JHL3ZDYK.js +3 -0
- package/dist/workbench-ui/chunk-JMORLCZG.js +257 -0
- package/dist/workbench-ui/chunk-JR4SIX7A.js +1 -0
- package/dist/workbench-ui/chunk-K23HAGEH.js +30 -0
- package/dist/workbench-ui/chunk-K43JDCBH.js +1 -0
- package/dist/workbench-ui/chunk-KINKFJY7.js +1 -0
- package/dist/workbench-ui/chunk-KKQSA4LI.js +2 -0
- package/dist/workbench-ui/chunk-KOUZX3UX.js +1 -0
- package/dist/workbench-ui/chunk-KR4DRHW2.js +78 -0
- package/dist/workbench-ui/chunk-KT4DJNOR.js +1 -0
- package/dist/workbench-ui/chunk-KTPNKRRZ.js +292 -0
- package/dist/workbench-ui/chunk-LFHIPGSU.js +7 -0
- package/dist/workbench-ui/chunk-LWDL4HZB.js +125 -0
- package/dist/workbench-ui/chunk-MVYC3CY4.js +1 -0
- package/dist/workbench-ui/chunk-NWUPALCY.js +129 -0
- package/dist/workbench-ui/chunk-NY7C662Z.js +1 -0
- package/dist/workbench-ui/chunk-O76WTHWP.js +1 -0
- package/dist/workbench-ui/chunk-OTF7YHRE.js +162 -0
- package/dist/workbench-ui/chunk-P6TKKRKP.js +1 -0
- package/dist/workbench-ui/chunk-PFHOOWV3.js +1 -0
- package/dist/workbench-ui/chunk-PUQLANIM.js +1 -0
- package/dist/workbench-ui/chunk-PZCGBYVO.js +1 -0
- package/dist/workbench-ui/chunk-QOHUZGP4.js +1 -0
- package/dist/workbench-ui/chunk-QSEG3OFF.js +1 -0
- package/dist/workbench-ui/chunk-QYPOXZIA.js +84 -0
- package/dist/workbench-ui/chunk-R6SOF3JC.js +1 -0
- package/dist/workbench-ui/chunk-RCLOYU5F.js +1 -0
- package/dist/workbench-ui/chunk-RSRUP64S.js +1 -0
- package/dist/workbench-ui/chunk-RVAIT6JW.js +1 -0
- package/dist/workbench-ui/chunk-S2CCN3II.js +1 -0
- package/dist/workbench-ui/chunk-S2Q52W46.js +1 -0
- package/dist/workbench-ui/chunk-S2W5THJ5.js +1 -0
- package/dist/workbench-ui/chunk-S6ZQZNOX.js +1 -0
- package/dist/workbench-ui/chunk-S74PLMMS.js +1 -0
- package/dist/workbench-ui/chunk-S7C4HKEY.js +1 -0
- package/dist/workbench-ui/chunk-SDTB3Q65.js +1 -0
- package/dist/workbench-ui/chunk-SLPRGYUV.js +32 -0
- package/dist/workbench-ui/chunk-SQE76S5B.js +1 -0
- package/dist/workbench-ui/chunk-SSDZPVPW.js +1 -0
- package/dist/workbench-ui/chunk-SVI7DGIE.js +1 -0
- package/dist/workbench-ui/chunk-T6QKLZ4H.js +62 -0
- package/dist/workbench-ui/chunk-TJNRPTFL.js +1 -0
- package/dist/workbench-ui/chunk-TP6U4EDH.js +2 -0
- package/dist/workbench-ui/chunk-TYAAT3GQ.js +1 -0
- package/dist/workbench-ui/chunk-U6OCY4ZH.js +1 -0
- package/dist/workbench-ui/chunk-UAN3NLRF.js +1 -0
- package/dist/workbench-ui/chunk-UMLU3FIX.js +1 -0
- package/dist/workbench-ui/chunk-URIY2OTM.js +1 -0
- package/dist/workbench-ui/chunk-V2NUKAA7.js +38 -0
- package/dist/workbench-ui/chunk-V4QLL4TE.js +139 -0
- package/dist/workbench-ui/chunk-VASHXUK4.js +2 -0
- package/dist/workbench-ui/chunk-VJLIWNIU.js +1 -0
- package/dist/workbench-ui/chunk-VQNQFBID.js +1 -0
- package/dist/workbench-ui/chunk-VSIWU7XA.js +3 -0
- package/dist/workbench-ui/chunk-VSJASPUZ.js +321 -0
- package/dist/workbench-ui/chunk-VXPNUNUX.js +3 -0
- package/dist/workbench-ui/chunk-WBKLDCV6.js +1 -0
- package/dist/workbench-ui/chunk-WOKJM3FY.js +1 -0
- package/dist/workbench-ui/chunk-X3U3NA3X.js +34 -0
- package/dist/workbench-ui/chunk-XBYU7M4J.js +1 -0
- package/dist/workbench-ui/chunk-XBZAO4ID.js +10 -0
- package/dist/workbench-ui/chunk-XLLPZ2WO.js +1 -0
- package/dist/workbench-ui/chunk-YFVL4NJL.js +1 -0
- package/dist/workbench-ui/chunk-YRFQENM4.js +1 -0
- package/dist/workbench-ui/chunk-YUADQVB2.js +1 -0
- package/dist/workbench-ui/chunk-Z3TCAKM5.js +1 -0
- package/dist/workbench-ui/chunk-Z6QR6FRE.js +10 -0
- package/dist/workbench-ui/chunk-ZJPSORPP.js +3 -0
- package/dist/workbench-ui/chunk-ZLGCSTR2.js +15 -0
- package/dist/workbench-ui/chunk-ZLR4SG5X.js +1 -0
- package/dist/workbench-ui/chunk-ZND3TTGF.js +1 -0
- package/dist/workbench-ui/chunk-ZOP3ZYH7.js +2 -0
- package/dist/workbench-ui/index.html +14 -0
- package/package.json +19 -8
- package/skills/acp-service/SKILL.md +3 -1
- package/skills/acp-service/references/a2a.md +17 -5
- package/skills/acp-service/references/dsh.md +2 -0
- package/skills/acp-service/references/roles-and-tasks.md +1 -1
- package/skills/rsi-coach/SKILL.md +134 -0
- package/vendor/dsh/README.md +10 -6
- package/vendor/dsh/a2a-executor.d.ts +56 -2
- package/vendor/dsh/a2a-executor.js +163 -17
- package/vendor/dsh/a2a.d.ts +12 -2
- package/vendor/dsh/a2a.js +9 -2
- package/vendor/dsh/adapter.d.ts +52 -3
- package/vendor/dsh/adapter.js +297 -30
- package/vendor/dsh/client.js +67 -11
- package/vendor/dsh/index.js +55 -3
- package/vendor/dsh/native-approvals.d.ts +4 -0
- package/vendor/dsh/native-approvals.js +44 -0
- package/vendor/dsh/preset-route.d.ts +49 -0
- package/vendor/dsh/preset-route.js +51 -0
- package/vendor/dsh/preset.js +10 -3
- package/vendor/dsh/process-admission.d.ts +25 -0
- package/vendor/dsh/process-admission.js +87 -0
- package/vendor/dsh/process-requests.d.ts +57 -0
- package/vendor/dsh/process-requests.js +49 -0
- package/vendor/dsh/review-mcp.d.ts +1 -0
- package/vendor/dsh/review-mcp.js +56 -0
- package/vendor/dsh/review.d.ts +30 -0
- package/vendor/dsh/review.js +149 -0
- package/vendor/dsh/session-settings.d.ts +34 -0
- package/vendor/dsh/session-settings.js +114 -0
- package/vendor/dsh/ticket-spec.d.ts +30 -0
- package/vendor/dsh/ticket-spec.js +10 -0
- package/vendor/dsh/ticket-tools.d.ts +21 -0
- package/vendor/dsh/ticket-tools.js +43 -0
- package/vendor/dsh/workbench.d.ts +18 -0
- package/vendor/dsh/workbench.js +91 -0
- package/vendor/runtime/README.md +6 -4
- package/vendor/runtime/dist/docs-site/CLI.html +2 -2
- package/vendor/runtime/dist/docs-site/VISION.html +2 -2
- package/vendor/runtime/dist/docs-site/agents.html +2 -2
- package/vendor/runtime/dist/docs-site/compare.html +2 -2
- package/vendor/runtime/dist/docs-site/config.html +2 -2
- package/vendor/runtime/dist/docs-site/custom-agents.html +2 -2
- package/vendor/runtime/dist/docs-site/exit-codes.html +2 -2
- package/vendor/runtime/dist/docs-site/flows.html +2 -2
- package/vendor/runtime/dist/docs-site/index.html +1 -1
- package/vendor/runtime/dist/docs-site/install.html +2 -2
- package/vendor/runtime/dist/docs-site/llms.txt +1 -1
- package/vendor/runtime/dist/docs-site/output-formats.html +2 -2
- package/vendor/runtime/dist/docs-site/permissions.html +2 -2
- package/vendor/runtime/dist/docs-site/prompting.html +2 -2
- package/vendor/runtime/dist/docs-site/quickstart.html +2 -2
- package/vendor/runtime/dist/docs-site/releasing.html +2 -2
- package/vendor/runtime/dist/docs-site/runtime-environment.html +2 -2
- package/vendor/runtime/dist/docs-site/runtime-process-lifecycle.html +2 -2
- package/vendor/runtime/dist/docs-site/safe-errors.html +2 -2
- package/vendor/runtime/dist/docs-site/session-control.html +2 -2
- package/vendor/runtime/dist/docs-site/session-watch.html +2 -2
- package/vendor/runtime/dist/docs-site/sessions.html +2 -2
- package/vendor/runtime/dist/docs-site/shared-sessions.html +2 -2
- package/vendor/runtime/package.json +6 -4
- package/vendor/runtime/skills/acpx/SKILL.md +2 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** Turns the A2A tasks behind one workbench job into the chat view's transcript items, newest page first. */
|
|
2
|
+
import { Role, Task } from '@a2a-js/sdk';
|
|
3
|
+
/** Queue and progress notices the executor writes into A2A history on every poll; they are status, not conversation. */
|
|
4
|
+
const STATUS_NOTICE = /^(CAPACITY_PENDING|Pending: waiting\b)/;
|
|
5
|
+
const fence = (value) => '```json\n' + JSON.stringify(value, null, 2) + '\n```';
|
|
6
|
+
/**
|
|
7
|
+
* One item per message: text parts joined, structured data fenced, file parts as links. Status notices are
|
|
8
|
+
* dropped and repeats collapse; the agent's final answer lives in the task's text artifacts, not its history.
|
|
9
|
+
*/
|
|
10
|
+
export function chatItems(tasks) {
|
|
11
|
+
const items = [], seen = new Set();
|
|
12
|
+
for (const { attemptId, task: raw } of tasks) {
|
|
13
|
+
const task = Task.fromJSON(raw);
|
|
14
|
+
const messages = [...task.history, ...(task.status?.message ? [task.status.message] : [])];
|
|
15
|
+
for (const message of messages) {
|
|
16
|
+
const key = `${task.id}:${message.messageId}`;
|
|
17
|
+
if (seen.has(key))
|
|
18
|
+
continue;
|
|
19
|
+
seen.add(key);
|
|
20
|
+
const blocks = message.parts.flatMap(part => {
|
|
21
|
+
const content = part.content;
|
|
22
|
+
if (!content)
|
|
23
|
+
return [];
|
|
24
|
+
if (content.$case === 'text')
|
|
25
|
+
return content.value.trim() ? [content.value] : [];
|
|
26
|
+
if (content.$case === 'data')
|
|
27
|
+
return [fence(content.value)];
|
|
28
|
+
if (content.$case === 'url')
|
|
29
|
+
return [`[${part.filename || content.value}](${content.value})`];
|
|
30
|
+
return [];
|
|
31
|
+
});
|
|
32
|
+
const content = blocks.join('\n\n');
|
|
33
|
+
const role = message.role === Role.ROLE_USER ? 'user' : 'assistant_text';
|
|
34
|
+
if (!content || role === 'assistant_text' && STATUS_NOTICE.test(content.trim()))
|
|
35
|
+
continue;
|
|
36
|
+
if (items.at(-1)?.kind === role && items.at(-1).content === content)
|
|
37
|
+
continue;
|
|
38
|
+
// Ordinals, not clocks: A2A history carries no timestamps, and ids must stay stable as history grows.
|
|
39
|
+
items.push({ id: `${attemptId ?? task.id}:${message.messageId}`, createdAt: items.length, kind: role, content });
|
|
40
|
+
}
|
|
41
|
+
for (const artifact of task.artifacts) {
|
|
42
|
+
const answer = artifact.parts.flatMap(part => part.content?.$case === 'text' && part.content.value.trim() ? [part.content.value] : []).join('\n\n');
|
|
43
|
+
if (!answer || items.some(item => item.kind === 'assistant_text' && item.content === answer))
|
|
44
|
+
continue;
|
|
45
|
+
items.push({ id: `${attemptId ?? task.id}:artifact:${artifact.artifactId}`, createdAt: items.length, kind: 'assistant_text', content: answer });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return items;
|
|
49
|
+
}
|
|
50
|
+
/** `before` is the index the previous page started at; pages walk from the newest toward the oldest. */
|
|
51
|
+
export function pageChat(items, query = {}) {
|
|
52
|
+
const end = Math.min(query.before ?? items.length, items.length), start = Math.max(0, end - (query.limit ?? 40));
|
|
53
|
+
return { items: items.slice(start, end), hasMore: start > 0, ...(start > 0 ? { nextCursor: String(start) } : {}), total: items.length };
|
|
54
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/** Human-readable projections of the execution ledger. Reading never dispatches or acknowledges work. */
|
|
2
|
-
import type { JobRef, LedgerAttempt, LedgerEvent, LedgerState } from './ledger.js';
|
|
2
|
+
import type { BusinessAcceptance, JobRef, LedgerActor, LedgerAttempt, LedgerEvent, 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';
|
|
6
6
|
import type { HumanReviewRequest, HumanReviewStatus } from './human-review.js';
|
|
7
|
+
import { type ProcessRequest } from './process-request.js';
|
|
8
|
+
import { type AgentDraft, type AgentRelease, type ResidentAgentRef, type WorkbenchAgentRow } from './agent-registry.js';
|
|
7
9
|
export interface WorkbenchServiceInfo {
|
|
8
10
|
kind: 'a2a' | 'gateway_workflow' | 'activepieces' | 'unknown';
|
|
9
11
|
source: 'backend_run' | 'target_snapshot' | 'workflow_run' | 'unrecorded';
|
|
@@ -42,10 +44,24 @@ export interface AcpTaskSummary {
|
|
|
42
44
|
stale: boolean;
|
|
43
45
|
reviewStatus?: HumanReviewStatus;
|
|
44
46
|
pendingReviewId?: string;
|
|
47
|
+
pendingProcessRequestId?: string;
|
|
45
48
|
progressSummary: string;
|
|
49
|
+
channel: 'trial' | 'formal' | 'standalone';
|
|
50
|
+
agentId?: string;
|
|
51
|
+
agentName?: string;
|
|
52
|
+
agentPhase?: 'developing' | 'published';
|
|
46
53
|
inFlightAttemptIds: string[];
|
|
47
54
|
unresolvedAttemptIds: string[];
|
|
48
55
|
execution: WorkbenchExecution;
|
|
56
|
+
/** The origin session's execution_review for the current result, if one was recorded. */
|
|
57
|
+
businessAcceptance?: BusinessAcceptance;
|
|
58
|
+
/** Tools the finished attempt asked for that nobody approved; its result may be incomplete. */
|
|
59
|
+
blockedTools?: string[];
|
|
60
|
+
/** The round failed and nothing else drives this task, so a person can send it another round from the workbench. */
|
|
61
|
+
canContinue?: boolean;
|
|
62
|
+
/** A finished top-level result with no conclusion yet and no review flow of its own, so a person can mark it read. */
|
|
63
|
+
canAccept?: boolean;
|
|
64
|
+
initiatedBy?: LedgerActor;
|
|
49
65
|
}
|
|
50
66
|
export interface WorkbenchStage {
|
|
51
67
|
stage: string;
|
|
@@ -78,16 +94,22 @@ export type WorkbenchReview = HumanReviewRequest & {
|
|
|
78
94
|
resumeStatus?: 'pending' | 'applied';
|
|
79
95
|
resumeError?: string;
|
|
80
96
|
};
|
|
97
|
+
export type WorkbenchProcessRequest = ProcessRequest & {
|
|
98
|
+
canAnswer: boolean;
|
|
99
|
+
};
|
|
81
100
|
export type WorkbenchAttempt = Omit<LedgerAttempt, 'input' | 'targetSnapshot' | 'backendRunRef'> & {
|
|
82
101
|
backendRunRef?: Record<string, string>;
|
|
83
102
|
execution: WorkbenchExecution;
|
|
84
103
|
};
|
|
85
104
|
export interface AcpTaskDetail extends AcpTaskSummary {
|
|
105
|
+
/** The first attempt's prompt: what the task was asked to do. Other input fields stay private. */
|
|
106
|
+
description?: string;
|
|
86
107
|
attempts: WorkbenchAttempt[];
|
|
87
108
|
children: AcpTaskSummary[];
|
|
88
109
|
ancestors: AcpTaskSummary[];
|
|
89
110
|
progress: WorkbenchProgress;
|
|
90
111
|
reviews: WorkbenchReview[];
|
|
112
|
+
processRequests: WorkbenchProcessRequest[];
|
|
91
113
|
events: LedgerEvent[];
|
|
92
114
|
dependencies: WorkbenchDependency[];
|
|
93
115
|
artifacts: {
|
|
@@ -101,10 +123,12 @@ export interface WorkbenchSource {
|
|
|
101
123
|
runs: readonly PptDeliveryRun[];
|
|
102
124
|
reviews: readonly HumanReviewRequest[];
|
|
103
125
|
reportRuns?: readonly ReportReviewRun[];
|
|
126
|
+
processRequests?: readonly ProcessRequest[];
|
|
104
127
|
actorId: string;
|
|
105
128
|
allowedOrigins?: readonly string[];
|
|
106
129
|
now?: number;
|
|
107
130
|
}
|
|
131
|
+
export type { AgentDraft, AgentRelease, WorkbenchAgentRow };
|
|
108
132
|
export interface WorkbenchSnapshot {
|
|
109
133
|
sourceId: string;
|
|
110
134
|
tasks: AcpTaskSummary[];
|
|
@@ -128,4 +152,11 @@ export declare function listWorkbenchTasks(snapshot: WorkbenchSnapshot, query?:
|
|
|
128
152
|
offset: number;
|
|
129
153
|
limit: number;
|
|
130
154
|
};
|
|
155
|
+
export declare function listWorkbenchAgents(snapshot: WorkbenchSnapshot, catalog: {
|
|
156
|
+
drafts: readonly AgentDraft[];
|
|
157
|
+
releases: readonly AgentRelease[];
|
|
158
|
+
}, residents?: readonly ResidentAgentRef[]): {
|
|
159
|
+
developing: WorkbenchAgentRow[];
|
|
160
|
+
published: WorkbenchAgentRow[];
|
|
161
|
+
};
|
|
131
162
|
export declare function getWorkbenchTask(snapshot: WorkbenchSnapshot, jobId: string): AcpTaskDetail;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { deliveryProgress } from './delivery-progress.js';
|
|
2
|
+
import { projectProcessRequest } from './process-request.js';
|
|
3
|
+
import { describeTaskDevelopment, projectWorkbenchAgents } from './agent-registry.js';
|
|
2
4
|
const stageNames = { summary: '文稿生成', human_review: '人工审核', make: '设计制作', validate: '机器校验', review: '独立验收', finished: '交付完成' };
|
|
3
5
|
const purposeNames = { project_script: '文稿生成', ppt_production: '设计制作', independent_review: '独立验收' };
|
|
4
6
|
const terminal = new Set(['completed', 'failed', 'canceled', 'rejected']);
|
|
@@ -101,9 +103,10 @@ function safeArtifact(input) {
|
|
|
101
103
|
if (!input || typeof input !== 'object')
|
|
102
104
|
return undefined;
|
|
103
105
|
const value = input;
|
|
104
|
-
|
|
106
|
+
// Path-only artifacts (no url) are listed by name/path without a link; a present but unsafe url is still dropped.
|
|
107
|
+
if (value.url !== undefined ? typeof value.url !== 'string' || !safeArtifact(value.url) : typeof value.path !== 'string')
|
|
105
108
|
return undefined;
|
|
106
|
-
const result = { url: value.url };
|
|
109
|
+
const result = value.url !== undefined ? { url: value.url } : {};
|
|
107
110
|
for (const key of ['name', 'path', 'mediaType', 'size', 'sha256'])
|
|
108
111
|
if (['string', 'number'].includes(typeof value[key]))
|
|
109
112
|
result[key] = value[key];
|
|
@@ -156,28 +159,94 @@ function progress(job, run, reviews, attempt, now) {
|
|
|
156
159
|
executionElapsedMs: run.metrics.elapsedMs, humanWaitingMs: (human.humanWaitingMs ?? 0) + (human.humanWaitStartedAt && Number.isFinite(Date.parse(human.humanWaitStartedAt)) ? Math.max(0, now - Date.parse(human.humanWaitStartedAt)) : 0),
|
|
157
160
|
availableResults: deliveryProgress(run).availableResults, updatedAt: run.updatedAt };
|
|
158
161
|
}
|
|
159
|
-
function
|
|
162
|
+
function pendingProcessRequest(requests, job, now) {
|
|
163
|
+
return requests.filter(request => request.jobId === job.jobId && request.attemptId === job.currentAttemptId)
|
|
164
|
+
.map(request => projectProcessRequest(request, now)).filter(request => request.status === 'pending')
|
|
165
|
+
.sort((a, b) => b.createdAt.localeCompare(a.createdAt))[0];
|
|
166
|
+
}
|
|
167
|
+
/** Same rule as the ledger view: acceptance counts only for the current completed result revision and digest. */
|
|
168
|
+
function currentAcceptance(job, ledger) {
|
|
169
|
+
const attempt = ledger.attempts[job.currentAttemptId], result = attempt?.result;
|
|
170
|
+
if (attempt?.executionStatus !== 'completed' || !result?.resultAvailable)
|
|
171
|
+
return undefined;
|
|
172
|
+
return (ledger.acceptances[job.jobId] ?? []).findLast(item => item.attemptId === attempt.attemptId
|
|
173
|
+
&& item.resultRevision === result.resultRevision && item.resultDigest === result.resultDigest);
|
|
174
|
+
}
|
|
175
|
+
/** A tool is blocked when its latest request was not approved; an agent's retry that a person allowed clears it. */
|
|
176
|
+
function blockedTools(requests, job, now) {
|
|
177
|
+
if (job.executionStatus !== 'completed')
|
|
178
|
+
return [];
|
|
179
|
+
const latest = new Map();
|
|
180
|
+
for (const request of requests.filter(request => request.kind === 'permission' && request.jobId === job.jobId && request.attemptId === job.currentAttemptId)
|
|
181
|
+
.map(request => projectProcessRequest(request, now)).sort((a, b) => a.createdAt.localeCompare(b.createdAt))) {
|
|
182
|
+
latest.set(JSON.stringify([request.toolTitle ?? '', request.toolDetail ?? '']), request);
|
|
183
|
+
}
|
|
184
|
+
return [...latest.values()].filter(request => request.answer?.outcome !== 'approved')
|
|
185
|
+
.map(request => request.toolTitle ?? '').filter((name, index, all) => name && all.indexOf(name) === index);
|
|
186
|
+
}
|
|
187
|
+
function summary(job, run, reviews, ledger, actorId, requests, now) {
|
|
160
188
|
const attempt = ledger.attempts[job.currentAttemptId], review = latestReview(reviews, job), pending = review?.status === 'pending' && !terminal.has(job.executionStatus) && (!run || !terminal.has(run.executionStatus));
|
|
189
|
+
const pendingRequest = terminal.has(job.executionStatus) ? undefined : pendingProcessRequest(requests, job, now);
|
|
161
190
|
const awaitingResume = review?.resume?.status === 'pending' && !terminal.has(job.executionStatus);
|
|
162
191
|
const resumeError = awaitingResume ? run?.diagnostics?.findLast(item => item.startsWith('Human continuation deferred:')) : undefined;
|
|
163
|
-
const
|
|
164
|
-
const
|
|
192
|
+
const acceptance = currentAcceptance(job, ledger), blocked = blockedTools(requests, job, now);
|
|
193
|
+
const toolBlocked = blocked.length > 0 && acceptance?.reviewStatus !== 'accepted';
|
|
194
|
+
const unwatched = attempt?.unwatched && !terminal.has(job.executionStatus) ? attempt.unwatched : undefined;
|
|
195
|
+
const displayStatus = toolBlocked ? 'tool_blocked' : pending || pendingRequest ? 'awaiting_human' : unwatched ? 'unwatched' : awaitingResume && !resumeError ? 'resuming' : review?.status === 'changes_requested' && !terminal.has(job.executionStatus) ? 'changes_requested' : job.executionStatus;
|
|
196
|
+
const phase = pending ? 'human_review' : pendingRequest ? 'process_request' : awaitingResume ? 'human_resume' : run?.phase ?? attempt?.phase ?? job.purpose ?? '';
|
|
165
197
|
const progressSummary = pending ? `${review.title}已形成,等待确认 ${review.revision};通过后开始设计制作。`
|
|
166
|
-
:
|
|
167
|
-
:
|
|
168
|
-
:
|
|
198
|
+
: pendingRequest ? (pendingRequest.kind === 'plan' ? '计划待批准,请在过程请求里提交。' : pendingRequest.kind === 'permission' ? `工具「${pendingRequest.toolTitle}」待批准,请在过程请求里提交。` : '有待回答的问题,请在过程请求里提交。')
|
|
199
|
+
: awaitingResume ? resumeError ? `决定已保存,继续执行受阻:${resumeError.slice('Human continuation deferred:'.length).trim()}` : '本版决定已保存,等待系统继续处理。'
|
|
200
|
+
: review?.status === 'changes_requested' && !terminal.has(job.executionStatus) ? run?.summaryRevisionPending ? '修改意见已保存,正在提交原作者。' : '修改意见已提交原作者,等待新版本。'
|
|
201
|
+
: toolBlocked ? `执行已结束,但有 ${blocked.length} 个工具调用未获批准,结果可能不完整,请核对后再验收。`
|
|
202
|
+
: unwatched ? `发起方在 ${unwatched.at} 停止等待(${unwatched.reason})。任务可能仍在执行或已经结束,请重新查询执行宿主。`
|
|
203
|
+
: attempt?.diagnostic || (run ? runDescription(run) : attempt?.result?.resultSummary || stateDescriptions[job.executionStatus] || '等待同步执行进展。');
|
|
204
|
+
const execution = executionView(attempt, job.targetId, Boolean(run));
|
|
205
|
+
const development = describeTaskDevelopment(attempt?.targetSnapshot?.development, { targetId: job.targetId, resident: execution.kind === 'resident', residentName: execution.targetName });
|
|
169
206
|
return { sourceId: job.sourceId, jobId: job.jobId, title: job.title ?? `${purposeNames[job.purpose ?? ''] ?? '执行任务'} ${job.jobId.slice(0, 8)}`,
|
|
207
|
+
channel: development.channel, ...(development.agentId ? { agentId: development.agentId, agentName: development.name, agentPhase: development.phase } : {}),
|
|
170
208
|
originSessionId: job.originSessionId, ...(job.parentJobRef ? { parentJobRef: job.parentJobRef } : {}), ...(job.parentAttemptId ? { parentAttemptId: job.parentAttemptId } : {}),
|
|
171
209
|
...(job.purpose ? { purpose: job.purpose } : {}), targetId: job.targetId, currentAttemptId: job.currentAttemptId, executionStatus: job.executionStatus, displayStatus, phase,
|
|
172
|
-
createdAt: job.createdAt, updatedAt:
|
|
173
|
-
inFlightAttemptIds: [...job.inFlightAttemptIds], unresolvedAttemptIds: [...job.unresolvedAttemptIds], execution
|
|
174
|
-
...(review ? { reviewStatus: review.status } : {}), ...(pending && review.reviewerId === actorId ? { pendingReviewId: review.reviewId } : {}),
|
|
210
|
+
createdAt: job.createdAt, updatedAt: [job.updatedAt, review?.updatedAt, pendingRequest?.updatedAt].filter((value) => Boolean(value)).sort().at(-1), stale: attempt?.stale ?? true,
|
|
211
|
+
inFlightAttemptIds: [...job.inFlightAttemptIds], unresolvedAttemptIds: [...job.unresolvedAttemptIds], execution,
|
|
212
|
+
...(review ? { reviewStatus: review.status } : {}), ...(pending && review.reviewerId === actorId ? { pendingReviewId: review.reviewId } : {}),
|
|
213
|
+
...(pendingRequest ? { pendingProcessRequestId: pendingRequest.requestId } : {}), progressSummary,
|
|
214
|
+
...(acceptance ? { businessAcceptance: structuredClone(acceptance) } : {}), ...(blocked.length ? { blockedTools: blocked } : {}),
|
|
215
|
+
...(job.executionStatus === 'failed' && !run && !job.parentJobRef && !job.unresolvedAttemptIds.length ? { canContinue: true } : {}),
|
|
216
|
+
...(job.executionStatus === 'completed' && !run && !job.parentJobRef && !acceptance && attempt?.result?.resultAvailable && attempt.result.resultRevision && attempt.result.resultDigest ? { canAccept: true } : {}),
|
|
217
|
+
...(job.initiatedBy ? { initiatedBy: job.initiatedBy } : {}) };
|
|
218
|
+
}
|
|
219
|
+
function bubbleProcessWait(summaries) {
|
|
220
|
+
const tasks = [...summaries.values()];
|
|
221
|
+
for (let depth = 0; depth < 5; depth++) {
|
|
222
|
+
let changed = false;
|
|
223
|
+
for (const task of tasks) {
|
|
224
|
+
if (task.pendingReviewId || task.pendingProcessRequestId || terminal.has(task.executionStatus))
|
|
225
|
+
continue;
|
|
226
|
+
const child = tasks.filter(item => item.parentJobRef?.jobId === task.jobId && item.pendingProcessRequestId).sort((a, b) => b.updatedAt.localeCompare(a.updatedAt))[0];
|
|
227
|
+
if (!child?.pendingProcessRequestId)
|
|
228
|
+
continue;
|
|
229
|
+
task.pendingProcessRequestId = child.pendingProcessRequestId;
|
|
230
|
+
if (!['awaiting_human', 'resuming', 'changes_requested'].includes(task.displayStatus)) {
|
|
231
|
+
task.displayStatus = 'awaiting_human';
|
|
232
|
+
task.phase = 'process_request';
|
|
233
|
+
task.progressSummary = child.progressSummary;
|
|
234
|
+
if (child.updatedAt > task.updatedAt)
|
|
235
|
+
task.updatedAt = child.updatedAt;
|
|
236
|
+
}
|
|
237
|
+
changed = true;
|
|
238
|
+
}
|
|
239
|
+
if (!changed)
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
175
242
|
}
|
|
176
243
|
export function workbenchSnapshot(source) {
|
|
177
244
|
const { ledger, actorId } = source, allowed = source.allowedOrigins ? new Set(source.allowedOrigins) : undefined;
|
|
178
245
|
const jobs = Object.values(ledger.jobs).filter(job => !allowed || allowed.has(job.originSessionId));
|
|
179
246
|
const visible = new Set(jobs.map(job => job.jobId)), runFor = (job) => source.runs.find(run => run.jobId === job.jobId && run.attemptId === job.currentAttemptId);
|
|
180
|
-
const
|
|
247
|
+
const now = source.now ?? Date.now();
|
|
248
|
+
const summaries = new Map(jobs.map(job => [job.jobId, summary(job, runFor(job), source.reviews, ledger, actorId, source.processRequests ?? [], now)]));
|
|
249
|
+
bubbleProcessWait(summaries);
|
|
181
250
|
const details = {};
|
|
182
251
|
for (const job of jobs) {
|
|
183
252
|
const run = runFor(job), ownReviews = source.reviews.filter(r => r.jobId === job.jobId || r.authorJobId === job.jobId && visible.has(r.jobId));
|
|
@@ -211,13 +280,24 @@ export function workbenchSnapshot(source) {
|
|
|
211
280
|
const attempts = Object.values(ledger.attempts).filter(attempt => attempt.jobId === job.jobId)
|
|
212
281
|
.map(attempt => attemptView(attempt, source.runs.some(item => item.jobId === job.jobId && item.attemptId === attempt.attemptId)));
|
|
213
282
|
if (!run)
|
|
214
|
-
for (const attempt of attempts)
|
|
215
|
-
|
|
216
|
-
|
|
283
|
+
for (const attempt of attempts) {
|
|
284
|
+
const pathOnly = (attempt.result?.resultArtifacts ?? []).filter(item => !item.url);
|
|
285
|
+
const links = [...(attempt.result?.artifactLinks ?? []), ...pathOnly];
|
|
286
|
+
if (links.length)
|
|
287
|
+
artifacts.push({ revision: attempt.result.resultRevision ?? attempt.attemptId, digest: attempt.result.resultDigest, artifacts: links });
|
|
288
|
+
}
|
|
217
289
|
const humanEvents = ownReviews.flatMap(review => review.history.map((decision, index) => ({ eventId: decision.decisionId, sourceId: ledger.sourceId, sequence: -(index + 1), jobId: review.jobId,
|
|
218
290
|
attemptId: review.attemptId, jobVersion: 0, type: `human_review.${decision.action}`, observedAt: decision.at,
|
|
219
291
|
data: { reviewId: review.reviewId, revision: review.revision, actor: decision.actor, ...(decision.note ? { note: decision.note } : {}) } })));
|
|
220
|
-
|
|
292
|
+
const asked = Object.values(ledger.attempts).filter(attempt => attempt.jobId === job.jobId)
|
|
293
|
+
.sort((a, b) => (a.createdAt ?? '').localeCompare(b.createdAt ?? ''))[0]?.input;
|
|
294
|
+
const description = typeof asked?.prompt === 'string' && asked.prompt.trim() ? asked.prompt.slice(0, 20_000) : undefined;
|
|
295
|
+
details[job.jobId] = { ...summaries.get(job.jobId), ...(description ? { description } : {}), attempts, children, ancestors, progress: progress(job, run, source.reviews, ledger.attempts[job.currentAttemptId], source.now ?? Date.now()),
|
|
296
|
+
processRequests: (source.processRequests ?? []).filter(request => request.jobId === job.jobId || children.some(child => child.jobId === request.jobId)).map(request => {
|
|
297
|
+
const projected = projectProcessRequest(request, now);
|
|
298
|
+
const owner = ledger.jobs[request.jobId];
|
|
299
|
+
return { ...projected, canAnswer: projected.status === 'pending' && owner?.currentAttemptId === request.attemptId && !terminal.has(owner.executionStatus) };
|
|
300
|
+
}),
|
|
221
301
|
reviews: ownReviews.map(review => {
|
|
222
302
|
const ownerRun = source.runs.find(item => item.jobId === review.jobId && item.attemptId === review.attemptId);
|
|
223
303
|
const resumeError = review.resume?.status === 'pending' ? ownerRun?.diagnostics?.findLast(item => item.startsWith('Human continuation deferred:')) : undefined;
|
|
@@ -232,6 +312,10 @@ export function workbenchSnapshot(source) {
|
|
|
232
312
|
const detail = details[report.jobId], task = summaries.get(report.jobId);
|
|
233
313
|
if (!detail || !task || detail.currentAttemptId !== report.attemptId)
|
|
234
314
|
continue;
|
|
315
|
+
delete task.canContinue;
|
|
316
|
+
delete detail.canContinue;
|
|
317
|
+
delete task.canAccept;
|
|
318
|
+
delete detail.canAccept;
|
|
235
319
|
const pending = report.humanReviews.at(-1), author = report.child;
|
|
236
320
|
const stages = [
|
|
237
321
|
{ stage: 'research', name: '临时智能体分析', status: author ? ledger.attempts[author.attemptId]?.executionStatus ?? 'unknown' : 'not_started', planned: !author,
|
|
@@ -239,8 +323,10 @@ export function workbenchSnapshot(source) {
|
|
|
239
323
|
{ stage: 'file_check', name: '报告文件检查', status: report.fileCheck ? report.fileCheck.passed ? 'completed' : 'failed' : 'not_started', planned: !report.fileCheck },
|
|
240
324
|
{ stage: 'human_review', name: '人工最终确认', status: pending?.status ?? 'not_started', planned: !pending, jobId: report.jobId, attemptId: report.attemptId },
|
|
241
325
|
];
|
|
242
|
-
|
|
243
|
-
|
|
326
|
+
if (!detail.pendingProcessRequestId) {
|
|
327
|
+
task.progressSummary = report.resultSummary ?? '临时智能体正在分析项目,输出报告后进行文件检查与人工最终确认。';
|
|
328
|
+
detail.progressSummary = task.progressSummary;
|
|
329
|
+
}
|
|
244
330
|
detail.progress = { stage: report.stage, phase: report.phase, stages,
|
|
245
331
|
completedStages: stages.filter(stage => ['completed', 'approved'].includes(stage.status)).map(stage => stage.name),
|
|
246
332
|
remainingStages: stages.filter(stage => !['completed', 'approved'].includes(stage.status)).map(stage => stage.name), updatedAt: report.updatedAt };
|
|
@@ -250,13 +336,18 @@ export function workbenchSnapshot(source) {
|
|
|
250
336
|
export function listWorkbenchTasks(snapshot, query = {}) {
|
|
251
337
|
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)));
|
|
252
338
|
const rootIds = new Set(snapshot.tasks.filter(task => !task.parentJobRef || !Object.hasOwn(snapshot.details, task.parentJobRef.jobId)).map(task => task.jobId));
|
|
253
|
-
const
|
|
254
|
-
const
|
|
339
|
+
const needsPerson = (task) => Boolean(task.pendingReviewId || task.pendingProcessRequestId);
|
|
340
|
+
const isWorking = (task) => task.displayStatus === 'resuming' || !needsPerson(task) && task.displayStatus !== 'unwatched' && ['working', 'submitted', 'not_started'].includes(task.executionStatus);
|
|
341
|
+
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);
|
|
255
342
|
const roots = snapshot.tasks.filter(task => rootIds.has(task.jobId));
|
|
256
|
-
const counts = { all: roots.length, pending: roots.filter(
|
|
257
|
-
const matches = snapshot.tasks.filter(task => filter === 'all' ? true : filter === 'pending' ?
|
|
343
|
+
const counts = { all: roots.length, pending: roots.filter(needsPerson).length, working: roots.filter(isWorking).length, failed: roots.filter(isFailed).length };
|
|
344
|
+
const matches = snapshot.tasks.filter(task => filter === 'all' ? true : filter === 'pending' ? needsPerson(task) : filter === 'working' ? isWorking(task) : isFailed(task));
|
|
258
345
|
return { items: structuredClone(matches.slice(offset, offset + limit)), total: matches.length, counts, offset, limit };
|
|
259
346
|
}
|
|
347
|
+
export function listWorkbenchAgents(snapshot, catalog, residents = []) {
|
|
348
|
+
const tasks = snapshot.tasks.map(task => ({ ...(task.agentId ? { agentId: task.agentId } : {}), ...(task.pendingReviewId ? { pendingReviewId: task.pendingReviewId } : {}), ...(task.pendingProcessRequestId ? { pendingProcessRequestId: task.pendingProcessRequestId } : {}) }));
|
|
349
|
+
return projectWorkbenchAgents({ ...catalog, residents }, tasks);
|
|
350
|
+
}
|
|
260
351
|
export function getWorkbenchTask(snapshot, jobId) {
|
|
261
352
|
const detail = Object.hasOwn(snapshot.details, jobId) ? snapshot.details[jobId] : undefined;
|
|
262
353
|
if (!detail)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type LedgerEntry, type RoleVersion } from './outline-run.js';
|
|
2
|
+
export interface GateReport {
|
|
3
|
+
roleId: string;
|
|
4
|
+
role: RoleVersion;
|
|
5
|
+
ready: boolean;
|
|
6
|
+
reasons: string[];
|
|
7
|
+
required: number;
|
|
8
|
+
/** The latest development runs on this version, newest last. */
|
|
9
|
+
devRuns: LedgerEntry[];
|
|
10
|
+
/** Development runs on this version that never reached a verdict and so do not count. */
|
|
11
|
+
unfinished: LedgerEntry[];
|
|
12
|
+
/** Every case in the role, with its latest test result on this version. */
|
|
13
|
+
testCases: {
|
|
14
|
+
caseId: string;
|
|
15
|
+
kind: string;
|
|
16
|
+
result: 'passed' | 'failed' | 'not_run';
|
|
17
|
+
}[];
|
|
18
|
+
}
|
|
19
|
+
export declare function checkGate(options: {
|
|
20
|
+
roleDirectory: string;
|
|
21
|
+
workspace: string;
|
|
22
|
+
required?: number;
|
|
23
|
+
/** The gateway, for the proposals' current state; without it every proposal in the ledger counts as open. */
|
|
24
|
+
invoke?: (method: string, params: Record<string, unknown>) => Promise<unknown>;
|
|
25
|
+
}): Promise<GateReport>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The gate from development to testing, decided from the role's ledger. Development is done when the current
|
|
3
|
+
* committed role version has passed the development case several times in a row, each first draft passed the
|
|
4
|
+
* program checks, and every proposal QA made to codify a check or change a locked item has been settled by a
|
|
5
|
+
* person (accepted, rejected or done on the ticket). Any change to the role directory is a new version, so the
|
|
6
|
+
* count starts again. Runs that never reached a verdict (the executor or QA task did not finish, e.g. the model
|
|
7
|
+
* quota ran out, or the host itself failed) say nothing about the role and are left out.
|
|
8
|
+
*/
|
|
9
|
+
import { readdir, readFile } from 'node:fs/promises';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
import { ledgerPath, roleVersion } from './outline-run.js';
|
|
13
|
+
const UNFINISHED = ['not_completed', 'review_failed', 'host_error'];
|
|
14
|
+
export async function checkGate(options) {
|
|
15
|
+
const roleDirectory = path.resolve(options.roleDirectory), required = options.required ?? 2;
|
|
16
|
+
const roleId = z.object({ id: z.string().min(1) }).passthrough().parse(JSON.parse(await readFile(path.join(roleDirectory, 'profile.json'), 'utf8'))).id;
|
|
17
|
+
const role = await roleVersion(roleDirectory);
|
|
18
|
+
const text = await readFile(ledgerPath(options.workspace, roleId), 'utf8').catch(() => '');
|
|
19
|
+
// A resumed run appends a new line for the same work directory; its latest line is the run.
|
|
20
|
+
const lines = text.split('\n').filter(Boolean).map(line => JSON.parse(line));
|
|
21
|
+
const entries = lines.filter((entry, index) => !lines.slice(index + 1).some(later => later.workDirectory === entry.workDirectory))
|
|
22
|
+
.filter(entry => role.commit && entry.role.commit === role.commit && !entry.role.dirty);
|
|
23
|
+
const dev = entries.filter(entry => entry.phase === 'dev' && entry.caseKind === 'original');
|
|
24
|
+
const unfinished = dev.filter(entry => UNFINISHED.includes(entry.stopReason));
|
|
25
|
+
const devRuns = dev.filter(entry => !UNFINISHED.includes(entry.stopReason)).slice(-required);
|
|
26
|
+
const reasons = [];
|
|
27
|
+
if (role.dirty)
|
|
28
|
+
reasons.push('角色目录有未提交的改动,先提交成一个版本');
|
|
29
|
+
if (devRuns.length < required)
|
|
30
|
+
reasons.push(`当前版本在开发题上有 ${devRuns.length} 次运行,需要连续 ${required} 次通过`);
|
|
31
|
+
for (const run of devRuns) {
|
|
32
|
+
const at = `${run.startedAt} ${run.caseId}`;
|
|
33
|
+
if (!run.passed)
|
|
34
|
+
reasons.push(`${at}:未通过(${run.stopReason})`);
|
|
35
|
+
if (!run.firstDraftPassed)
|
|
36
|
+
reasons.push(`${at}:初稿没有一次通过程序检查`);
|
|
37
|
+
if (run.mustIssues)
|
|
38
|
+
reasons.push(`${at}:还有 ${run.mustIssues} 条必须改`);
|
|
39
|
+
// Entries written before the ledger carried the job fall back to the run's own record.
|
|
40
|
+
const jobId = run.jobId ?? await readFile(path.join(run.workDirectory, 'run.json'), 'utf8')
|
|
41
|
+
.then(text => JSON.parse(text).rounds?.[0]?.jobId, () => undefined);
|
|
42
|
+
const ticket = options.invoke && jobId
|
|
43
|
+
? await options.invoke('ticket_get', { originSessionId: run.originSessionId ?? 'rsi-cli', jobId }) : undefined;
|
|
44
|
+
const open = (ticket ? ticket.proposals.filter(p => p.state === 'open') : run.proposals.map((p, i) => ({ ...p, id: `#${i + 1}` })))
|
|
45
|
+
.filter(p => p.kind === 'check' || p.kind === 'locked');
|
|
46
|
+
if (open.length)
|
|
47
|
+
reasons.push(`${at}:质检有 ${open.length} 条提议还没人处理(${open.map(p => `${p.id} ${p.kind}`).join('、')})`
|
|
48
|
+
+ (jobId ? `,用 acp-service ticket proposal --job ${jobId} --id <编号> accept|reject|done 处理` : ''));
|
|
49
|
+
}
|
|
50
|
+
const casesDirectory = path.join(roleDirectory, 'cases');
|
|
51
|
+
const testCases = [];
|
|
52
|
+
const names = (await readdir(casesDirectory, { withFileTypes: true })).filter(entry => entry.isDirectory()).map(entry => entry.name).sort();
|
|
53
|
+
for (const name of names) {
|
|
54
|
+
const kase = JSON.parse(await readFile(path.join(casesDirectory, name, 'case.json'), 'utf8'));
|
|
55
|
+
const latest = entries.filter(entry => entry.phase === 'test' && entry.caseId === kase.id).at(-1);
|
|
56
|
+
testCases.push({ caseId: kase.id, kind: kase.kind, result: !latest ? 'not_run' : latest.passed ? 'passed' : 'failed' });
|
|
57
|
+
}
|
|
58
|
+
return { roleId, role, ready: reasons.length === 0, reasons, required, devRuns, unfinished, testCases };
|
|
59
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { type QualityReview, type CheckResult } from '../execution/ticket.js';
|
|
2
|
+
export type { CheckResult, QualityReview };
|
|
3
|
+
/** One QA pass over a frozen copy of the outline, in its own session. */
|
|
4
|
+
export interface ReviewRecord {
|
|
5
|
+
jobId?: string;
|
|
6
|
+
executionStatus: string;
|
|
7
|
+
outlineCopy: string;
|
|
8
|
+
review?: QualityReview;
|
|
9
|
+
error?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface OutlineRound {
|
|
12
|
+
round: number;
|
|
13
|
+
jobId: string;
|
|
14
|
+
executionStatus: string;
|
|
15
|
+
passed: boolean;
|
|
16
|
+
results: CheckResult[];
|
|
17
|
+
outlineSha256?: string;
|
|
18
|
+
review?: ReviewRecord;
|
|
19
|
+
/** Why the round went back unchecked: the executor finished without submitting the ticket. */
|
|
20
|
+
ticketErrors?: string[];
|
|
21
|
+
}
|
|
22
|
+
export type Phase = 'dev' | 'test';
|
|
23
|
+
/** `host_error`: the host itself failed mid-run (the gateway went away, a call threw); the run is recorded and the error rethrown. */
|
|
24
|
+
export type StopReason = 'passed' | 'max_bounces' | 'max_revisions' | 'stalled' | 'needs_human' | 'not_completed' | 'review_failed' | 'host_error';
|
|
25
|
+
/** The role version is the last commit that touched the role directory; uncommitted changes make a run unattributable. */
|
|
26
|
+
export interface RoleVersion {
|
|
27
|
+
commit?: string;
|
|
28
|
+
dirty: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface OutlineRunReport {
|
|
31
|
+
roleId: string;
|
|
32
|
+
caseId: string;
|
|
33
|
+
phase: Phase;
|
|
34
|
+
role: RoleVersion;
|
|
35
|
+
repo: string;
|
|
36
|
+
commit: string;
|
|
37
|
+
workDirectory: string;
|
|
38
|
+
outlinePath: string;
|
|
39
|
+
ticketPath: string;
|
|
40
|
+
/** The executor's job, which carries the ticket. */
|
|
41
|
+
jobId?: string;
|
|
42
|
+
featuresConfirmed: boolean;
|
|
43
|
+
rounds: OutlineRound[];
|
|
44
|
+
passed: boolean;
|
|
45
|
+
stopReason: StopReason;
|
|
46
|
+
startedAt: string;
|
|
47
|
+
finishedAt: string;
|
|
48
|
+
/** The host error that stopped the run. */
|
|
49
|
+
error?: string;
|
|
50
|
+
}
|
|
51
|
+
/** One line of `<workspace>/<role>/ledger.jsonl`. */
|
|
52
|
+
export interface LedgerEntry {
|
|
53
|
+
startedAt: string;
|
|
54
|
+
phase: Phase;
|
|
55
|
+
caseId: string;
|
|
56
|
+
caseKind: 'original' | 'variant';
|
|
57
|
+
role: RoleVersion;
|
|
58
|
+
passed: boolean;
|
|
59
|
+
stopReason: StopReason;
|
|
60
|
+
/** The executor's first outline passed every program check without a bounce. */
|
|
61
|
+
firstDraftPassed: boolean;
|
|
62
|
+
bounces: number;
|
|
63
|
+
revisions: number;
|
|
64
|
+
scores: Record<string, number>[];
|
|
65
|
+
mustIssues: number;
|
|
66
|
+
proposals: NonNullable<QualityReview['proposals']>;
|
|
67
|
+
workDirectory: string;
|
|
68
|
+
ticketPath: string;
|
|
69
|
+
/** The executor's job, which carries the ticket; the gate reads the proposals' current state from it. */
|
|
70
|
+
jobId?: string;
|
|
71
|
+
originSessionId?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface OutlineRunOptions {
|
|
74
|
+
roleDirectory: string;
|
|
75
|
+
caseId: string;
|
|
76
|
+
projectPath: string;
|
|
77
|
+
workspace: string;
|
|
78
|
+
/** A test run needs a committed role directory and QA; development runs take whatever is on disk. */
|
|
79
|
+
phase?: Phase;
|
|
80
|
+
targetId: string;
|
|
81
|
+
agentPreset: string;
|
|
82
|
+
originSessionId: string;
|
|
83
|
+
/** Times a failed check goes back to the executor. The design default is one. */
|
|
84
|
+
maxBounces?: number;
|
|
85
|
+
pollMs?: number;
|
|
86
|
+
timeoutMs?: number;
|
|
87
|
+
python?: string;
|
|
88
|
+
/** How to run acp-service: the executor's ticket commands, and the coach's answer to a process request. */
|
|
89
|
+
cli?: {
|
|
90
|
+
command: string;
|
|
91
|
+
url: string;
|
|
92
|
+
};
|
|
93
|
+
/** A QA agent reviews each outline that passes the program checks and may send it back for revision, by default up to three times. */
|
|
94
|
+
qa?: {
|
|
95
|
+
agentPreset?: string;
|
|
96
|
+
targetId?: string;
|
|
97
|
+
maxRevisions?: number;
|
|
98
|
+
};
|
|
99
|
+
invoke: (method: string, params: Record<string, unknown>) => Promise<any>;
|
|
100
|
+
log?: (line: string) => void;
|
|
101
|
+
now?: () => Date;
|
|
102
|
+
/** A run directory: goes on with the run recorded there instead of starting one. */
|
|
103
|
+
resume?: string;
|
|
104
|
+
}
|
|
105
|
+
export declare function roleVersion(roleDirectory: string): Promise<RoleVersion>;
|
|
106
|
+
export declare const ledgerPath: (workspace: string, roleId: string) => string;
|
|
107
|
+
export declare function runOutlineCase(options: OutlineRunOptions): Promise<OutlineRunReport>;
|