@1agents/acp-service 0.8.1 → 0.8.3
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 +37 -2
- package/dist/bin/a2a.js +3 -2
- package/dist/src/a2a/executor.d.ts +2 -0
- package/dist/src/a2a/executor.js +63 -10
- package/dist/src/a2a/gateway.d.ts +407 -14
- package/dist/src/a2a/gateway.js +719 -37
- package/dist/src/a2a/index.d.ts +8 -1
- package/dist/src/a2a/index.js +4 -0
- package/dist/src/a2a/notices.d.ts +24 -0
- package/dist/src/a2a/notices.js +56 -0
- package/dist/src/a2a/preflight.d.ts +52 -0
- package/dist/src/a2a/preflight.js +153 -0
- package/dist/src/a2a/result-metadata.d.ts +59 -0
- package/dist/src/a2a/result-metadata.js +156 -0
- package/dist/src/a2a/server.js +30 -0
- package/dist/src/a2a/session-delivery.d.ts +69 -0
- package/dist/src/a2a/session-delivery.js +260 -0
- package/dist/src/a2a/session-hosts.d.ts +34 -0
- package/dist/src/a2a/session-hosts.js +211 -0
- package/dist/src/a2a/store.js +3 -1
- package/dist/src/a2a/types.d.ts +33 -0
- package/dist/src/execution/delivery-progress.d.ts +108 -0
- package/dist/src/execution/delivery-progress.js +57 -0
- package/dist/src/execution/ledger.d.ts +235 -0
- package/dist/src/execution/ledger.js +396 -0
- package/dist/src/execution/ppt-delivery.d.ts +231 -0
- package/dist/src/execution/ppt-delivery.js +625 -0
- package/dist/src/execution/targets.d.ts +349 -0
- package/dist/src/execution/targets.js +428 -0
- package/package.json +11 -12
- package/skills/acp-service/SKILL.md +9 -2
- package/skills/acp-service/references/a2a.md +72 -4
- package/vendor/dsh/a2a-executor.d.ts +2 -1
- package/vendor/dsh/a2a-executor.js +28 -1
- package/vendor/dsh/a2a.js +1 -0
- package/vendor/dsh/client.js +95 -27
- package/vendor/runtime/dist/{agent-registry-CMg8LHKY.js → agent-registry-R7A3MSpr.js} +9 -1
- package/vendor/runtime/dist/agent-registry-R7A3MSpr.js.map +1 -0
- package/vendor/runtime/dist/agent-registry.d.ts +1 -0
- package/vendor/runtime/dist/agent-registry.d.ts.map +1 -1
- package/vendor/runtime/dist/agent-registry.js +1 -2
- package/vendor/runtime/dist/{cli-Bdzplbpj.js → cli-DeOpE2Xz.js} +4 -4
- package/vendor/runtime/dist/{cli-Bdzplbpj.js.map → cli-DeOpE2Xz.js.map} +1 -1
- package/vendor/runtime/dist/cli.d.ts +2 -1
- package/vendor/runtime/dist/cli.js +10 -10
- package/vendor/runtime/dist/cli.js.map +1 -1
- package/vendor/runtime/dist/{client-BXOiB0ND.d.ts → client-VQsqcIOJ.d.ts} +2 -2
- package/vendor/runtime/dist/{client-BXOiB0ND.d.ts.map → client-VQsqcIOJ.d.ts.map} +1 -1
- package/vendor/runtime/dist/docs-site/.nojekyll +0 -0
- package/vendor/runtime/dist/docs-site/CLI.html +833 -0
- package/vendor/runtime/dist/docs-site/VISION.html +415 -0
- package/vendor/runtime/dist/docs-site/agents.html +391 -0
- package/vendor/runtime/dist/docs-site/compare.html +359 -0
- package/vendor/runtime/dist/docs-site/config.html +450 -0
- package/vendor/runtime/dist/docs-site/custom-agents.html +408 -0
- package/vendor/runtime/dist/docs-site/exit-codes.html +347 -0
- package/vendor/runtime/dist/docs-site/favicon.svg +21 -0
- package/vendor/runtime/dist/docs-site/flows.html +498 -0
- package/vendor/runtime/dist/docs-site/index.html +367 -0
- package/vendor/runtime/dist/docs-site/install.html +386 -0
- package/vendor/runtime/dist/docs-site/llms.txt +36 -0
- package/vendor/runtime/dist/docs-site/output-formats.html +407 -0
- package/vendor/runtime/dist/docs-site/permissions.html +422 -0
- package/vendor/runtime/dist/docs-site/prompting.html +460 -0
- package/vendor/runtime/dist/docs-site/quickstart.html +382 -0
- package/vendor/runtime/dist/docs-site/releasing.html +341 -0
- package/vendor/runtime/dist/docs-site/runtime-environment.html +329 -0
- package/vendor/runtime/dist/docs-site/runtime-process-lifecycle.html +335 -0
- package/vendor/runtime/dist/docs-site/safe-errors.html +323 -0
- package/vendor/runtime/dist/docs-site/session-control.html +408 -0
- package/vendor/runtime/dist/docs-site/session-watch.html +354 -0
- package/vendor/runtime/dist/docs-site/sessions.html +488 -0
- package/vendor/runtime/dist/docs-site/shared-sessions.html +377 -0
- package/vendor/runtime/dist/{flows-BKlAuzM8.js → flows-oaBGn31w.js} +5 -5
- package/vendor/runtime/dist/{flows-BKlAuzM8.js.map → flows-oaBGn31w.js.map} +1 -1
- package/vendor/runtime/dist/flows.d.ts +2 -2
- package/vendor/runtime/dist/flows.d.ts.map +1 -1
- package/vendor/runtime/dist/flows.js +1 -2
- package/vendor/runtime/dist/{invocation-options-DMy77sEU.js → invocation-options-CUDEE8vW.js} +5 -5
- package/vendor/runtime/dist/{invocation-options-DMy77sEU.js.map → invocation-options-CUDEE8vW.js.map} +1 -1
- package/vendor/runtime/dist/{ipc-CLv2iL89.js → ipc-BQQpcEdP.js} +98 -20
- package/vendor/runtime/dist/ipc-BQQpcEdP.js.map +1 -0
- package/vendor/runtime/dist/{output-I-t-v55D.js → output-CFv3jcOQ.js} +86 -22
- package/vendor/runtime/dist/output-CFv3jcOQ.js.map +1 -0
- package/vendor/runtime/dist/{queue-owner-runtime-RN3uSid0.js → queue-owner-runtime-DvMJiGbP.js} +86 -27
- package/vendor/runtime/dist/queue-owner-runtime-DvMJiGbP.js.map +1 -0
- package/vendor/runtime/dist/runtime.d.ts +5 -2
- package/vendor/runtime/dist/runtime.d.ts.map +1 -1
- package/vendor/runtime/dist/runtime.js +77 -29
- package/vendor/runtime/dist/runtime.js.map +1 -1
- package/vendor/runtime/dist/{session-options-DNnDfiUt.d.ts → session-options-NjpFwf-c.d.ts} +5 -1
- package/vendor/runtime/dist/session-options-NjpFwf-c.d.ts.map +1 -0
- package/vendor/runtime/dist/{session-watch-CmHbH0jS.js → session-watch-Di-wIdCH.js} +4 -4
- package/vendor/runtime/dist/{session-watch-CmHbH0jS.js.map → session-watch-Di-wIdCH.js.map} +1 -1
- package/vendor/runtime/dist/{watch-BE-kKa7o.js → watch-CIpoMaWD.js} +2 -2
- package/vendor/runtime/dist/{watch-BE-kKa7o.js.map → watch-CIpoMaWD.js.map} +1 -1
- package/vendor/runtime/package.json +1 -1
- package/vendor/runtime/skills/acpx/SKILL.md +7 -2
- package/vendor/runtime/dist/agent-registry-CMg8LHKY.js.map +0 -1
- package/vendor/runtime/dist/ipc-CLv2iL89.js.map +0 -1
- package/vendor/runtime/dist/output-I-t-v55D.js.map +0 -1
- package/vendor/runtime/dist/queue-owner-runtime-RN3uSid0.js.map +0 -1
- package/vendor/runtime/dist/session-options-DNnDfiUt.d.ts.map +0 -1
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { PptDeliveryArtifact, PptDeliveryRun } from './ppt-delivery.js';
|
|
2
|
+
export declare const deliveryStageNames: {
|
|
3
|
+
readonly summary: "项目总结与脚本";
|
|
4
|
+
readonly make: "PPT制作";
|
|
5
|
+
readonly validate: "机器校验";
|
|
6
|
+
readonly review: "独立验收";
|
|
7
|
+
};
|
|
8
|
+
/** Persisted facts projected for readers; producing a projection never schedules work or a notification. */
|
|
9
|
+
export declare function deliveryProgress(run: PptDeliveryRun): {
|
|
10
|
+
stage: "summary" | "make" | "validate" | "review" | "finished";
|
|
11
|
+
phase: string;
|
|
12
|
+
revision: string;
|
|
13
|
+
executionStatus: "failed" | "completed" | "canceled" | "working" | "input_required";
|
|
14
|
+
stages: ({
|
|
15
|
+
jobId?: string | undefined;
|
|
16
|
+
attemptId?: string | undefined;
|
|
17
|
+
sessionId?: string | undefined;
|
|
18
|
+
stage: string;
|
|
19
|
+
name: "项目总结与脚本";
|
|
20
|
+
status: string;
|
|
21
|
+
} | {
|
|
22
|
+
jobId?: string | undefined;
|
|
23
|
+
attemptId?: string | undefined;
|
|
24
|
+
sessionId?: string | undefined;
|
|
25
|
+
stage: string;
|
|
26
|
+
name: "PPT制作";
|
|
27
|
+
status: string;
|
|
28
|
+
} | {
|
|
29
|
+
jobId?: string | undefined;
|
|
30
|
+
attemptId?: string | undefined;
|
|
31
|
+
sessionId?: string | undefined;
|
|
32
|
+
stage: string;
|
|
33
|
+
name: "机器校验";
|
|
34
|
+
status: string;
|
|
35
|
+
} | {
|
|
36
|
+
jobId?: string | undefined;
|
|
37
|
+
attemptId?: string | undefined;
|
|
38
|
+
sessionId?: string | undefined;
|
|
39
|
+
stage: string;
|
|
40
|
+
name: "独立验收";
|
|
41
|
+
status: string;
|
|
42
|
+
})[];
|
|
43
|
+
completedStages: ("项目总结与脚本" | "PPT制作" | "机器校验" | "独立验收")[];
|
|
44
|
+
remainingStages: ("项目总结与脚本" | "PPT制作" | "机器校验" | "独立验收")[];
|
|
45
|
+
availableResults: {
|
|
46
|
+
revision: string;
|
|
47
|
+
artifactDigest: string;
|
|
48
|
+
artifacts: PptDeliveryArtifact[];
|
|
49
|
+
validation: "machine_passed" | "producer_host_verified";
|
|
50
|
+
independentReview: string;
|
|
51
|
+
deliveryReady: boolean;
|
|
52
|
+
}[];
|
|
53
|
+
cancellationRequestedAt: string | undefined;
|
|
54
|
+
updatedAt: string;
|
|
55
|
+
stageCompletionWakeups: false;
|
|
56
|
+
};
|
|
57
|
+
export declare function deliveryException(run: PptDeliveryRun, reason: string): {
|
|
58
|
+
progress: {
|
|
59
|
+
stage: "summary" | "make" | "validate" | "review" | "finished";
|
|
60
|
+
phase: string;
|
|
61
|
+
revision: string;
|
|
62
|
+
executionStatus: "failed" | "completed" | "canceled" | "working" | "input_required";
|
|
63
|
+
stages: ({
|
|
64
|
+
jobId?: string | undefined;
|
|
65
|
+
attemptId?: string | undefined;
|
|
66
|
+
sessionId?: string | undefined;
|
|
67
|
+
stage: string;
|
|
68
|
+
name: "项目总结与脚本";
|
|
69
|
+
status: string;
|
|
70
|
+
} | {
|
|
71
|
+
jobId?: string | undefined;
|
|
72
|
+
attemptId?: string | undefined;
|
|
73
|
+
sessionId?: string | undefined;
|
|
74
|
+
stage: string;
|
|
75
|
+
name: "PPT制作";
|
|
76
|
+
status: string;
|
|
77
|
+
} | {
|
|
78
|
+
jobId?: string | undefined;
|
|
79
|
+
attemptId?: string | undefined;
|
|
80
|
+
sessionId?: string | undefined;
|
|
81
|
+
stage: string;
|
|
82
|
+
name: "机器校验";
|
|
83
|
+
status: string;
|
|
84
|
+
} | {
|
|
85
|
+
jobId?: string | undefined;
|
|
86
|
+
attemptId?: string | undefined;
|
|
87
|
+
sessionId?: string | undefined;
|
|
88
|
+
stage: string;
|
|
89
|
+
name: "独立验收";
|
|
90
|
+
status: string;
|
|
91
|
+
})[];
|
|
92
|
+
completedStages: ("项目总结与脚本" | "PPT制作" | "机器校验" | "独立验收")[];
|
|
93
|
+
remainingStages: ("项目总结与脚本" | "PPT制作" | "机器校验" | "独立验收")[];
|
|
94
|
+
availableResults: {
|
|
95
|
+
revision: string;
|
|
96
|
+
artifactDigest: string;
|
|
97
|
+
artifacts: PptDeliveryArtifact[];
|
|
98
|
+
validation: "machine_passed" | "producer_host_verified";
|
|
99
|
+
independentReview: string;
|
|
100
|
+
deliveryReady: boolean;
|
|
101
|
+
}[];
|
|
102
|
+
cancellationRequestedAt: string | undefined;
|
|
103
|
+
updatedAt: string;
|
|
104
|
+
stageCompletionWakeups: false;
|
|
105
|
+
};
|
|
106
|
+
summary: string;
|
|
107
|
+
artifacts: PptDeliveryArtifact[];
|
|
108
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export const deliveryStageNames = {
|
|
2
|
+
summary: '项目总结与脚本', make: 'PPT制作', validate: '机器校验', review: '独立验收',
|
|
3
|
+
};
|
|
4
|
+
/** Persisted facts projected for readers; producing a projection never schedules work or a notification. */
|
|
5
|
+
export function deliveryProgress(run) {
|
|
6
|
+
const latest = (purpose) => [...run.children].reverse().find(item => item.purpose === purpose);
|
|
7
|
+
const summary = latest('project_script'), maker = latest('ppt_production'), reviewer = latest('independent_review');
|
|
8
|
+
const status = (child) => child?.child.executionStatus ?? 'not_started';
|
|
9
|
+
const stages = [
|
|
10
|
+
{ stage: 'summary', name: deliveryStageNames.summary, status: status(summary) === 'completed' && !run.scriptDigest ? 'awaiting_validation' : status(summary), child: summary?.child },
|
|
11
|
+
{ stage: 'make', name: deliveryStageNames.make, status: status(maker), child: maker?.child },
|
|
12
|
+
{ stage: 'validate', name: deliveryStageNames.validate, status: run.validation ? 'completed' : run.stage === 'validate' ? run.executionStatus : 'not_started', child: undefined },
|
|
13
|
+
{ stage: 'review', name: deliveryStageNames.review, status: run.review?.verdict === 'passed' ? 'completed'
|
|
14
|
+
: run.review?.verdict === 'changes_requested' ? 'changes_requested' : status(reviewer) === 'completed' ? 'awaiting_validation' : status(reviewer), child: reviewer?.child },
|
|
15
|
+
].map(({ child, ...stage }) => ({ ...stage, ...(child ? { jobId: child.jobId, attemptId: child.attemptId, sessionId: child.sessionId } : {}) }));
|
|
16
|
+
const versions = new Map();
|
|
17
|
+
for (const entry of run.artifactHistory ?? [])
|
|
18
|
+
versions.set(`${entry.revision}:${entry.validation.artifactDigest}`, entry);
|
|
19
|
+
if (run.validation)
|
|
20
|
+
versions.set(`${run.revision}:${run.validation.artifactDigest}`, { revision: run.revision, validation: run.validation });
|
|
21
|
+
const availableResults = [...versions.values()].map(({ revision, validation }) => ({
|
|
22
|
+
revision: `revision-${revision}`, artifactDigest: validation.artifactDigest, artifacts: validation.artifacts,
|
|
23
|
+
validation: 'machine_passed',
|
|
24
|
+
independentReview: revision === run.revision && run.review?.artifactDigest === validation.artifactDigest ? run.review.verdict : 'not_completed',
|
|
25
|
+
deliveryReady: run.executionStatus === 'completed' && revision === run.revision && run.review?.verdict === 'passed'
|
|
26
|
+
&& run.review.artifactDigest === validation.artifactDigest,
|
|
27
|
+
}));
|
|
28
|
+
// A completed producer's host-authored receipt can expose a draft before the parent's machine check.
|
|
29
|
+
const metadata = maker?.child.resultMetadata;
|
|
30
|
+
if (maker && metadata?.producer === '1agents/a2a-host' && metadata.outcome === 'completed' && metadata.validation?.status === 'passed'
|
|
31
|
+
&& metadata.taskId === maker.child.backendRunRef?.taskId && !availableResults.some(item => item.revision === `revision-${maker.revision}`)) {
|
|
32
|
+
const artifacts = (Array.isArray(metadata.artifacts) ? metadata.artifacts : []).filter(a => {
|
|
33
|
+
try {
|
|
34
|
+
const url = new URL(a.url ?? '');
|
|
35
|
+
return ['http:', 'https:'].includes(url.protocol) && !url.username && !url.password
|
|
36
|
+
&& typeof a.mediaType === 'string' && typeof a.path === 'string' && Number.isSafeInteger(a.size) && a.size > 0 && /^[a-f0-9]{64}$/.test(a.sha256);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
if (artifacts.length)
|
|
43
|
+
availableResults.push({ revision: `revision-${maker.revision}`, artifactDigest: '', artifacts,
|
|
44
|
+
validation: 'producer_host_verified', independentReview: 'not_completed', deliveryReady: false });
|
|
45
|
+
}
|
|
46
|
+
return { stage: run.stage, phase: run.phase, revision: `revision-${run.revision}`, executionStatus: run.executionStatus,
|
|
47
|
+
stages, completedStages: stages.filter(stage => stage.status === 'completed').map(stage => stage.name),
|
|
48
|
+
remainingStages: stages.filter(stage => stage.status !== 'completed').map(stage => stage.name),
|
|
49
|
+
availableResults, cancellationRequestedAt: run.cancellationRequestedAt, updatedAt: run.updatedAt,
|
|
50
|
+
stageCompletionWakeups: false };
|
|
51
|
+
}
|
|
52
|
+
export function deliveryException(run, reason) {
|
|
53
|
+
const progress = deliveryProgress(run), candidate = progress.availableResults.at(-1);
|
|
54
|
+
const summary = `${reason}\n\n已完成:${progress.completedStages.join('、') || '暂无'}。\n未完成:${progress.remainingStages.join('、') || '无'}。`
|
|
55
|
+
+ (candidate ? `\n已有产物:${candidate.revision};${candidate.validation === 'machine_passed' ? '机器校验通过' : '仅制作端文件校验通过'},独立验收状态:${candidate.independentReview}。以下为已有制作稿,尚非最终交付。` : '');
|
|
56
|
+
return { progress, summary, artifacts: candidate?.artifacts ?? [] };
|
|
57
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
export type ExecutionStatus = 'not_started' | 'submitted' | 'working' | 'input_required' | 'auth_required' | 'completed' | 'failed' | 'canceled' | 'rejected' | 'unknown';
|
|
2
|
+
export type SubmissionStatus = 'prepared' | 'dispatching' | 'accepted' | 'known_not_submitted' | 'submission_unknown';
|
|
3
|
+
export interface JobRef {
|
|
4
|
+
sourceId: string;
|
|
5
|
+
jobId: string;
|
|
6
|
+
}
|
|
7
|
+
export interface LedgerTargetSnapshot {
|
|
8
|
+
targetId: string;
|
|
9
|
+
configVersion?: number;
|
|
10
|
+
targetConfigVersion?: number;
|
|
11
|
+
connectionId?: string;
|
|
12
|
+
connectionVersion?: number;
|
|
13
|
+
provider?: string;
|
|
14
|
+
roleId?: string;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
export interface BackendRunRef {
|
|
18
|
+
provider?: string;
|
|
19
|
+
remote?: string;
|
|
20
|
+
taskId?: string;
|
|
21
|
+
contextId?: string;
|
|
22
|
+
sessionId?: string;
|
|
23
|
+
flowRunId?: string;
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
}
|
|
26
|
+
export interface LedgerResult {
|
|
27
|
+
attemptId: string;
|
|
28
|
+
resultSummary?: string;
|
|
29
|
+
structuredResultRef?: unknown;
|
|
30
|
+
resultDigest?: string;
|
|
31
|
+
resultRevision?: string;
|
|
32
|
+
artifactLinks: unknown[];
|
|
33
|
+
resultAvailable: boolean;
|
|
34
|
+
observedAt: string;
|
|
35
|
+
}
|
|
36
|
+
export interface BusinessAcceptance {
|
|
37
|
+
attemptId: string;
|
|
38
|
+
resultRevision: string;
|
|
39
|
+
resultDigest: string;
|
|
40
|
+
reviewStatus: 'pending' | 'accepted' | 'changes_requested';
|
|
41
|
+
note?: string;
|
|
42
|
+
recordedAt: string;
|
|
43
|
+
}
|
|
44
|
+
export interface LedgerAttempt {
|
|
45
|
+
attemptId: string;
|
|
46
|
+
jobId: string;
|
|
47
|
+
operation: string;
|
|
48
|
+
clientRequestId?: string;
|
|
49
|
+
requestDigest: string;
|
|
50
|
+
targetId: string;
|
|
51
|
+
targetConfigVersion?: number;
|
|
52
|
+
connectionId?: string;
|
|
53
|
+
connectionVersion?: number;
|
|
54
|
+
provider: string;
|
|
55
|
+
targetSnapshot: LedgerTargetSnapshot;
|
|
56
|
+
input: unknown;
|
|
57
|
+
previousAttemptId?: string;
|
|
58
|
+
backendRunRef?: BackendRunRef;
|
|
59
|
+
submissionStatus: SubmissionStatus;
|
|
60
|
+
executionStatus: ExecutionStatus;
|
|
61
|
+
providerState?: string;
|
|
62
|
+
phase?: string;
|
|
63
|
+
cancellationRequestedAt?: string;
|
|
64
|
+
checkedAt?: string;
|
|
65
|
+
stale: boolean;
|
|
66
|
+
createdAt: string | null;
|
|
67
|
+
updatedAt: string;
|
|
68
|
+
diagnostic?: string;
|
|
69
|
+
result?: LedgerResult;
|
|
70
|
+
}
|
|
71
|
+
export interface LedgerJob {
|
|
72
|
+
sourceId: string;
|
|
73
|
+
jobId: string;
|
|
74
|
+
title?: string;
|
|
75
|
+
originSessionId: string;
|
|
76
|
+
accessScopeRef: string;
|
|
77
|
+
originKind: 'session' | 'legacy';
|
|
78
|
+
originRef: string;
|
|
79
|
+
targetId: string;
|
|
80
|
+
roleId?: string;
|
|
81
|
+
currentAttemptId: string;
|
|
82
|
+
executionStatus: ExecutionStatus;
|
|
83
|
+
inFlightAttemptIds: string[];
|
|
84
|
+
unresolvedAttemptIds: string[];
|
|
85
|
+
parentJobRef?: JobRef;
|
|
86
|
+
parentAttemptId?: string;
|
|
87
|
+
purpose?: string;
|
|
88
|
+
resultRevision?: string;
|
|
89
|
+
replacesJobRef?: JobRef;
|
|
90
|
+
jobVersion: number;
|
|
91
|
+
createdAt: string | null;
|
|
92
|
+
updatedAt: string;
|
|
93
|
+
provenance: 'native' | 'legacy';
|
|
94
|
+
migratedAt?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface LedgerEvent {
|
|
97
|
+
eventId: string;
|
|
98
|
+
sourceId: string;
|
|
99
|
+
sequence: number;
|
|
100
|
+
jobId: string;
|
|
101
|
+
attemptId?: string;
|
|
102
|
+
jobVersion: number;
|
|
103
|
+
type: string;
|
|
104
|
+
observedAt: string;
|
|
105
|
+
data?: unknown;
|
|
106
|
+
}
|
|
107
|
+
interface RequestRecord {
|
|
108
|
+
digest: string;
|
|
109
|
+
jobId: string;
|
|
110
|
+
attemptId: string;
|
|
111
|
+
}
|
|
112
|
+
export interface LedgerState {
|
|
113
|
+
version: 1;
|
|
114
|
+
sourceId: string;
|
|
115
|
+
jobs: Record<string, LedgerJob>;
|
|
116
|
+
attempts: Record<string, LedgerAttempt>;
|
|
117
|
+
requests: Record<string, RequestRecord>;
|
|
118
|
+
events: LedgerEvent[];
|
|
119
|
+
nextSequence: number;
|
|
120
|
+
acceptances: Record<string, BusinessAcceptance[]>;
|
|
121
|
+
}
|
|
122
|
+
export interface LedgerPrepareInput {
|
|
123
|
+
originSessionId: string;
|
|
124
|
+
targetSnapshot: LedgerTargetSnapshot;
|
|
125
|
+
input: unknown;
|
|
126
|
+
clientRequestId?: string;
|
|
127
|
+
/** Trusted adapter only: hash the caller request before adding current-attempt defaults. */
|
|
128
|
+
requestDigestInput?: unknown;
|
|
129
|
+
jobId?: string;
|
|
130
|
+
parentJobRef?: JobRef;
|
|
131
|
+
parentAttemptId?: string;
|
|
132
|
+
purpose?: string;
|
|
133
|
+
title?: string;
|
|
134
|
+
operation?: string;
|
|
135
|
+
resultRevision?: string;
|
|
136
|
+
replacesJobRef?: JobRef;
|
|
137
|
+
}
|
|
138
|
+
export interface LedgerObservation {
|
|
139
|
+
executionStatus?: ExecutionStatus;
|
|
140
|
+
providerState?: string;
|
|
141
|
+
phase?: string;
|
|
142
|
+
checkedAt?: string;
|
|
143
|
+
stale?: boolean;
|
|
144
|
+
resultSummary?: string;
|
|
145
|
+
structuredResultRef?: unknown;
|
|
146
|
+
resultDigest?: string;
|
|
147
|
+
resultRevision?: string;
|
|
148
|
+
artifactLinks?: unknown[];
|
|
149
|
+
resultAvailable?: boolean;
|
|
150
|
+
diagnostic?: string;
|
|
151
|
+
}
|
|
152
|
+
export interface LegacyLedgerRecord {
|
|
153
|
+
originSessionId: string;
|
|
154
|
+
remote: string;
|
|
155
|
+
taskId: string;
|
|
156
|
+
contextId?: string;
|
|
157
|
+
sessionId?: string;
|
|
158
|
+
cwd?: string;
|
|
159
|
+
agentPreset?: string;
|
|
160
|
+
title?: string;
|
|
161
|
+
executionStatus?: ExecutionStatus;
|
|
162
|
+
providerState?: string;
|
|
163
|
+
resultSummary?: string;
|
|
164
|
+
artifactLinks?: unknown[];
|
|
165
|
+
createdAt?: string | null;
|
|
166
|
+
checkedAt?: string;
|
|
167
|
+
stale?: boolean;
|
|
168
|
+
targetSnapshot?: LedgerTargetSnapshot;
|
|
169
|
+
}
|
|
170
|
+
export interface LedgerJobView extends LedgerJob {
|
|
171
|
+
attempts: LedgerAttempt[];
|
|
172
|
+
children: LedgerJob[];
|
|
173
|
+
result?: LedgerResult;
|
|
174
|
+
businessAcceptance?: BusinessAcceptance;
|
|
175
|
+
acceptanceHistory: BusinessAcceptance[];
|
|
176
|
+
}
|
|
177
|
+
export declare class JobLedger {
|
|
178
|
+
private readonly persist;
|
|
179
|
+
private state;
|
|
180
|
+
constructor(initial: LedgerState | undefined, persist: (next: LedgerState) => void);
|
|
181
|
+
snapshot(): LedgerState;
|
|
182
|
+
/** Trusted adapter use only; public reads must call scoped get/list. */
|
|
183
|
+
getAttempt(attemptId: string): LedgerAttempt;
|
|
184
|
+
get sourceId(): string;
|
|
185
|
+
/** A crash during dispatch proves neither acceptance nor rejection; never silently send it again. */
|
|
186
|
+
recoverAfterRestart(): string[];
|
|
187
|
+
private mutate;
|
|
188
|
+
private job;
|
|
189
|
+
private attempt;
|
|
190
|
+
private event;
|
|
191
|
+
private refresh;
|
|
192
|
+
private checkRef;
|
|
193
|
+
private requestIdentity;
|
|
194
|
+
/** Read-only idempotency check before resolving current target configuration or contacting a Provider. */
|
|
195
|
+
replay(input: LedgerPrepareInput): {
|
|
196
|
+
job: LedgerJob;
|
|
197
|
+
attempt: LedgerAttempt;
|
|
198
|
+
idempotent: true;
|
|
199
|
+
} | undefined;
|
|
200
|
+
prepare(input: LedgerPrepareInput): {
|
|
201
|
+
job: LedgerJob;
|
|
202
|
+
attempt: LedgerAttempt;
|
|
203
|
+
idempotent: boolean;
|
|
204
|
+
};
|
|
205
|
+
markDispatching(attemptId: string): LedgerAttempt;
|
|
206
|
+
accept(attemptId: string, backendRunRef: BackendRunRef, observation?: LedgerObservation): LedgerAttempt;
|
|
207
|
+
knownNotSubmitted(attemptId: string, input: {
|
|
208
|
+
executionStatus: 'failed' | 'rejected' | 'canceled';
|
|
209
|
+
diagnostic?: string;
|
|
210
|
+
}): LedgerAttempt;
|
|
211
|
+
markUnknown(attemptId: string, diagnostic?: string): LedgerAttempt;
|
|
212
|
+
private applyObservation;
|
|
213
|
+
observe(attemptId: string, input: LedgerObservation): LedgerAttempt;
|
|
214
|
+
requestCancellation(attemptId: string): LedgerAttempt;
|
|
215
|
+
get(originSessionId: string, jobId: string): LedgerJobView;
|
|
216
|
+
list(originSessionId: string): LedgerJobView[];
|
|
217
|
+
events(originSessionId: string, jobId?: string, afterSequence?: number): LedgerEvent[];
|
|
218
|
+
findByBackend(originSessionId: string, ref: {
|
|
219
|
+
remote?: string;
|
|
220
|
+
taskId?: string;
|
|
221
|
+
flowRunId?: string;
|
|
222
|
+
}): {
|
|
223
|
+
job: LedgerJob;
|
|
224
|
+
attempt: LedgerAttempt;
|
|
225
|
+
} | undefined;
|
|
226
|
+
acceptance(originSessionId: string, jobId: string, input: Omit<BusinessAcceptance, 'recordedAt'>): BusinessAcceptance;
|
|
227
|
+
/** Each old Task gets one legacy Job; matching context IDs never merge jobs. */
|
|
228
|
+
migrateLegacy(records: LegacyLedgerRecord[]): Array<{
|
|
229
|
+
remote: string;
|
|
230
|
+
taskId: string;
|
|
231
|
+
jobId: string;
|
|
232
|
+
attemptId: string;
|
|
233
|
+
}>;
|
|
234
|
+
}
|
|
235
|
+
export {};
|