@akilium/telemetry-collector 0.1.10 → 0.1.11
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 +22 -1
- package/bin/akilium-telemetry.mjs +0 -0
- package/dist/instrumentation/src/client.d.ts +77 -0
- package/dist/instrumentation/src/client.js +237 -0
- package/dist/instrumentation/src/codex-cli.d.ts +20 -0
- package/dist/instrumentation/src/codex-cli.js +92 -0
- package/dist/instrumentation/src/codex-execution.d.ts +27 -0
- package/dist/instrumentation/src/codex-execution.js +123 -0
- package/dist/instrumentation/src/index.d.ts +11 -0
- package/dist/instrumentation/src/index.js +11 -0
- package/dist/instrumentation/src/persisted-file.d.ts +18 -0
- package/dist/instrumentation/src/persisted-file.js +65 -0
- package/dist/instrumentation/src/posting-wrappers.d.ts +49 -0
- package/dist/instrumentation/src/posting-wrappers.js +76 -0
- package/dist/instrumentation/src/wrappers.d.ts +68 -0
- package/dist/instrumentation/src/wrappers.js +76 -0
- package/dist/integration-contracts/src/action-lineage.d.ts +120 -0
- package/dist/integration-contracts/src/action-lineage.js +208 -0
- package/dist/integration-contracts/src/activity-classification.d.ts +251 -0
- package/dist/integration-contracts/src/activity-classification.js +406 -0
- package/dist/integration-contracts/src/ai-execution.d.ts +62 -0
- package/dist/integration-contracts/src/ai-execution.js +244 -0
- package/dist/integration-contracts/src/ai-session.d.ts +282 -0
- package/dist/integration-contracts/src/ai-session.js +192 -0
- package/dist/integration-contracts/src/artifact-lineage.d.ts +140 -0
- package/dist/integration-contracts/src/artifact-lineage.js +236 -0
- package/dist/integration-contracts/src/lineage-validation.d.ts +14 -0
- package/dist/integration-contracts/src/lineage-validation.js +64 -0
- package/dist/integration-contracts/src/posting-lineage.d.ts +105 -0
- package/dist/integration-contracts/src/posting-lineage.js +147 -0
- package/lib/execution-capture.mjs +1 -1
- package/package.json +16 -25
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ActionArtifactResultV1_1 } from '../../integration-contracts/src/action-lineage.ts';
|
|
2
|
+
export type PersistedFileSaveInput = {
|
|
3
|
+
path: string;
|
|
4
|
+
sourceReference: string;
|
|
5
|
+
content: string | Uint8Array;
|
|
6
|
+
subtype: 'report' | 'document' | 'other';
|
|
7
|
+
sourceContext?: string | null;
|
|
8
|
+
filename?: string | null;
|
|
9
|
+
resultReferenceId?: string;
|
|
10
|
+
createOnly?: boolean;
|
|
11
|
+
verifiedAt?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare class PersistedFileSaveError extends Error {
|
|
14
|
+
readonly partialOutput: ActionArtifactResultV1_1 | null;
|
|
15
|
+
constructor(message: string, partialOutput: ActionArtifactResultV1_1 | null, options?: ErrorOptions);
|
|
16
|
+
}
|
|
17
|
+
/** Persist a file and verify its current address, stable path identity, digest, and trusted pre-state. */
|
|
18
|
+
export declare function savePersistedFile(input: PersistedFileSaveInput): Promise<ActionArtifactResultV1_1>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
+
import { open, readFile } from 'node:fs/promises';
|
|
3
|
+
import { basename, resolve } from 'node:path';
|
|
4
|
+
export class PersistedFileSaveError extends Error {
|
|
5
|
+
partialOutput;
|
|
6
|
+
constructor(message, partialOutput, options) {
|
|
7
|
+
super(message, options);
|
|
8
|
+
this.partialOutput = partialOutput;
|
|
9
|
+
this.name = 'PersistedFileSaveError';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/** Persist a file and verify its current address, stable path identity, digest, and trusted pre-state. */
|
|
13
|
+
export async function savePersistedFile(input) {
|
|
14
|
+
if (!input.path || !input.sourceReference || input.sourceReference.length > 1024 || input.sourceReference.trim() !== input.sourceReference) {
|
|
15
|
+
throw new TypeError('A path and bounded, non-sensitive source reference are required');
|
|
16
|
+
}
|
|
17
|
+
const path = resolve(input.path);
|
|
18
|
+
const createOnly = input.createOnly ?? true;
|
|
19
|
+
let handle;
|
|
20
|
+
let priorExistence = 'unknown';
|
|
21
|
+
try {
|
|
22
|
+
if (createOnly) {
|
|
23
|
+
handle = await open(path, 'wx');
|
|
24
|
+
priorExistence = 'absent';
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
handle = await open(path, 'r+');
|
|
28
|
+
priorExistence = 'present';
|
|
29
|
+
await handle.truncate(0);
|
|
30
|
+
}
|
|
31
|
+
await handle.writeFile(input.content);
|
|
32
|
+
await handle.sync();
|
|
33
|
+
await handle.close();
|
|
34
|
+
handle = undefined;
|
|
35
|
+
return await verifiedOutput(input, path, priorExistence, createOnly);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
await handle?.close().catch(() => undefined);
|
|
39
|
+
const partialOutput = priorExistence ? await verifiedOutput(input, path, priorExistence, createOnly).catch(() => null) : null;
|
|
40
|
+
if (error instanceof PersistedFileSaveError)
|
|
41
|
+
throw error;
|
|
42
|
+
if (createOnly && error.code === 'EEXIST') {
|
|
43
|
+
throw new PersistedFileSaveError('Create-only save conflicted with an existing file', null, { cause: error });
|
|
44
|
+
}
|
|
45
|
+
throw new PersistedFileSaveError('File save failed; any verified persisted side effect is attached', partialOutput, { cause: error });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function verifiedOutput(input, path, priorExistence, createOnly) {
|
|
49
|
+
const content = await readFile(path);
|
|
50
|
+
const digest = createHash('sha256').update(content).digest('hex');
|
|
51
|
+
const stableResultId = createHash('sha256').update(path).digest('hex');
|
|
52
|
+
const integrity = { algorithm: 'sha256', value: digest };
|
|
53
|
+
return {
|
|
54
|
+
resultReferenceId: input.resultReferenceId ?? randomUUID(),
|
|
55
|
+
artifact: { kind: 'persisted_tool_result', persisted: true, resultId: stableResultId, integrity,
|
|
56
|
+
locator: { kind: 'source_reference', reference: input.sourceReference }, subtype: input.subtype },
|
|
57
|
+
relationship: priorExistence === 'absent' ? 'created' : 'modified',
|
|
58
|
+
revision: { sourceRevisionId: digest, headCommitSha: null, integrity },
|
|
59
|
+
presentation: { sourceContext: input.sourceContext ?? null, repositoryLabel: null, pullRequestNumber: null,
|
|
60
|
+
issueKey: null, filename: input.filename ?? basename(path), sourcePath: null,
|
|
61
|
+
copyReference: input.sourceReference, destination: null },
|
|
62
|
+
verification: { persistedReference: input.sourceReference, stableResultId, integrity,
|
|
63
|
+
verifiedAt: input.verifiedAt ?? new Date().toISOString(), basis: createOnly ? 'create_operation' : 'trusted_pre_state', priorExistence },
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type PostingActionResultV1_2 } from "../../integration-contracts/src/posting-lineage.ts";
|
|
2
|
+
import type { PostingReportInput, ReportOutcome } from "./client.ts";
|
|
3
|
+
export interface PostingToolClient {
|
|
4
|
+
reportPosting(input: PostingReportInput): Promise<ReportOutcome>;
|
|
5
|
+
}
|
|
6
|
+
export type PostingActionReference = Omit<PostingActionResultV1_2, "contractVersion" | "actionId" | "attemptId">;
|
|
7
|
+
export interface PostingStructuredResult<T> {
|
|
8
|
+
value: T;
|
|
9
|
+
/** Provider-confirmed resource IDs and bounded parent references only. */
|
|
10
|
+
postings: PostingActionReference[];
|
|
11
|
+
}
|
|
12
|
+
export declare class PostingToolFailure extends Error {
|
|
13
|
+
readonly postings: PostingActionReference[];
|
|
14
|
+
constructor(message: string, postings?: PostingActionReference[]);
|
|
15
|
+
}
|
|
16
|
+
export declare function postingReference(input: PostingActionReference): PostingActionReference;
|
|
17
|
+
type PostingReferenceFields = Pick<PostingActionReference, "resultReferenceId" | "relationship" | "confirmation" | "confirmedAt">;
|
|
18
|
+
export declare function linearCommentReference(input: PostingReferenceFields & {
|
|
19
|
+
workspaceId: string;
|
|
20
|
+
commentId: string;
|
|
21
|
+
issueId?: string | null;
|
|
22
|
+
}): PostingActionReference;
|
|
23
|
+
export declare function githubConversationCommentReference(input: PostingReferenceFields & {
|
|
24
|
+
repositoryId: string;
|
|
25
|
+
commentId: string;
|
|
26
|
+
issueNumber?: string | null;
|
|
27
|
+
pullRequestNumber?: string | null;
|
|
28
|
+
}): PostingActionReference;
|
|
29
|
+
export declare function githubInlineReviewCommentReference(input: PostingReferenceFields & {
|
|
30
|
+
repositoryId: string;
|
|
31
|
+
commentId: string;
|
|
32
|
+
pullRequestNumber: string;
|
|
33
|
+
threadId?: string | null;
|
|
34
|
+
}): PostingActionReference;
|
|
35
|
+
export declare function slackMessageReference(input: PostingReferenceFields & {
|
|
36
|
+
workspaceId: string;
|
|
37
|
+
channelId: string;
|
|
38
|
+
messageId: string;
|
|
39
|
+
parentMessageId?: string | null;
|
|
40
|
+
}): PostingActionReference;
|
|
41
|
+
export interface PostingWrapperOptions {
|
|
42
|
+
actionId?: string;
|
|
43
|
+
attemptId?: string;
|
|
44
|
+
startedAt?: string;
|
|
45
|
+
now?: () => number;
|
|
46
|
+
}
|
|
47
|
+
/** Reports only provider-confirmed identities; failures retain verified side effects without changing tool behavior. */
|
|
48
|
+
export declare function wrapPostingTool<T>(client: PostingToolClient, tool: () => Promise<PostingStructuredResult<T>>, options?: PostingWrapperOptions): Promise<T>;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { parsePostingActionResultV1_2, } from "../../integration-contracts/src/posting-lineage.js";
|
|
2
|
+
export class PostingToolFailure extends Error {
|
|
3
|
+
postings;
|
|
4
|
+
constructor(message, postings = []) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.postings = postings;
|
|
7
|
+
this.name = "PostingToolFailure";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export function postingReference(input) {
|
|
11
|
+
const parsed = parsePostingActionResultV1_2({ ...input, contractVersion: "1.2.0",
|
|
12
|
+
actionId: "posting-builder-action", attemptId: "posting-builder-attempt" });
|
|
13
|
+
const { contractVersion: _version, actionId: _action, attemptId: _attempt, ...reference } = parsed;
|
|
14
|
+
return reference;
|
|
15
|
+
}
|
|
16
|
+
export function linearCommentReference(input) {
|
|
17
|
+
const { workspaceId, commentId, issueId, ...metadata } = input;
|
|
18
|
+
return postingReference({ ...metadata, identity: { kind: "linear_comment", workspaceId, commentId },
|
|
19
|
+
parent: issueId ? { kind: "linear_issue", issueId } : null });
|
|
20
|
+
}
|
|
21
|
+
export function githubConversationCommentReference(input) {
|
|
22
|
+
const { repositoryId, commentId, issueNumber, pullRequestNumber, ...metadata } = input;
|
|
23
|
+
const parent = pullRequestNumber
|
|
24
|
+
? { kind: "github_pull_request", repositoryId, number: pullRequestNumber }
|
|
25
|
+
: issueNumber ? { kind: "github_issue", repositoryId, number: issueNumber } : null;
|
|
26
|
+
const identity = { kind: "github_comment", repositoryId, family: "conversation", commentId };
|
|
27
|
+
return postingReference({ ...metadata, identity, parent });
|
|
28
|
+
}
|
|
29
|
+
export function githubInlineReviewCommentReference(input) {
|
|
30
|
+
const { repositoryId, commentId, pullRequestNumber, threadId, ...metadata } = input;
|
|
31
|
+
const identity = { kind: "github_comment", repositoryId, family: "inline_review", commentId };
|
|
32
|
+
const parent = { kind: "github_review_thread", repositoryId,
|
|
33
|
+
pullRequestNumber, threadId: threadId ?? null };
|
|
34
|
+
return postingReference({ ...metadata, identity, parent });
|
|
35
|
+
}
|
|
36
|
+
export function slackMessageReference(input) {
|
|
37
|
+
const { workspaceId, channelId, messageId, parentMessageId, ...metadata } = input;
|
|
38
|
+
const identity = { kind: "slack_message", workspaceId, channelId, messageId };
|
|
39
|
+
const parent = parentMessageId
|
|
40
|
+
? { kind: "slack_thread", channelId, parentMessageId } : null;
|
|
41
|
+
return postingReference({ ...metadata, identity, parent });
|
|
42
|
+
}
|
|
43
|
+
/** Reports only provider-confirmed identities; failures retain verified side effects without changing tool behavior. */
|
|
44
|
+
export async function wrapPostingTool(client, tool, options = {}) {
|
|
45
|
+
const actionId = options.actionId ?? crypto.randomUUID();
|
|
46
|
+
const attemptId = options.attemptId ?? crypto.randomUUID();
|
|
47
|
+
const now = options.now ?? Date.now;
|
|
48
|
+
const startedAt = options.startedAt ?? new Date(now()).toISOString();
|
|
49
|
+
const report = async (postings, status) => {
|
|
50
|
+
if (!postings.length)
|
|
51
|
+
return;
|
|
52
|
+
const safeResults = postings.map((posting) => ({
|
|
53
|
+
resultReferenceId: posting.resultReferenceId,
|
|
54
|
+
identity: posting.identity,
|
|
55
|
+
parent: posting.parent,
|
|
56
|
+
relationship: posting.relationship,
|
|
57
|
+
confirmation: posting.confirmation,
|
|
58
|
+
confirmedAt: posting.confirmedAt,
|
|
59
|
+
}));
|
|
60
|
+
try {
|
|
61
|
+
await client.reportPosting({ actionId, attemptId, executionStatus: status,
|
|
62
|
+
startedAt, completedAt: new Date(now()).toISOString(), occurredAt: new Date(now()).toISOString(), results: safeResults });
|
|
63
|
+
}
|
|
64
|
+
catch { /* Instrumentation cannot alter the originating provider operation. */ }
|
|
65
|
+
};
|
|
66
|
+
try {
|
|
67
|
+
const result = await tool();
|
|
68
|
+
await report(result.postings, "succeeded");
|
|
69
|
+
return result.value;
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
if (error instanceof PostingToolFailure)
|
|
73
|
+
await report(error.postings, "failed");
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ActionArtifactResultV1, ActionCorrelationV1, ArtifactIdentityV1, ActionArtifactResultV1_1, ActionArtifactPresentationV1, PersistedOutputVerificationV1, ArtifactRelationship } from "./index.ts";
|
|
2
|
+
import type { ActionSession } from "./client.ts";
|
|
3
|
+
type ToolKind = "commit" | "pull_request" | "linear_ticket" | "persisted_result";
|
|
4
|
+
export interface StructuredToolClient {
|
|
5
|
+
action(input: {
|
|
6
|
+
toolKind: ToolKind;
|
|
7
|
+
correlation?: Partial<ActionCorrelationV1>;
|
|
8
|
+
}): ActionSession;
|
|
9
|
+
}
|
|
10
|
+
export interface StructuredResult<T> {
|
|
11
|
+
value: T;
|
|
12
|
+
/** Only durable, structured resource references belong here. */
|
|
13
|
+
references: Array<ActionArtifactResultV1 | ActionArtifactResultV1_1>;
|
|
14
|
+
}
|
|
15
|
+
/** A tool may fail after its provider persisted a resource. Preserve the original error. */
|
|
16
|
+
export declare class StructuredToolFailure extends Error {
|
|
17
|
+
readonly references: Array<ActionArtifactResultV1 | ActionArtifactResultV1_1>;
|
|
18
|
+
constructor(message: string, references?: Array<ActionArtifactResultV1 | ActionArtifactResultV1_1>);
|
|
19
|
+
}
|
|
20
|
+
export interface WrapperOptions {
|
|
21
|
+
correlation?: Partial<ActionCorrelationV1>;
|
|
22
|
+
}
|
|
23
|
+
export declare function commitReference(input: {
|
|
24
|
+
resultReferenceId: string;
|
|
25
|
+
repository: {
|
|
26
|
+
provider: "github" | "local";
|
|
27
|
+
repositoryId: string;
|
|
28
|
+
};
|
|
29
|
+
sha: string;
|
|
30
|
+
}): ActionArtifactResultV1;
|
|
31
|
+
export declare function pullRequestReference(input: {
|
|
32
|
+
resultReferenceId: string;
|
|
33
|
+
repositoryId: string;
|
|
34
|
+
pullRequestId: string;
|
|
35
|
+
relationship: "created" | "modified" | "read" | "referenced";
|
|
36
|
+
headCommitSha?: string | null;
|
|
37
|
+
sourceRevisionId?: string | null;
|
|
38
|
+
}): ActionArtifactResultV1;
|
|
39
|
+
export declare function linearTicketReference(input: {
|
|
40
|
+
resultReferenceId: string;
|
|
41
|
+
workspaceId: string;
|
|
42
|
+
issueId: string;
|
|
43
|
+
relationship: ArtifactRelationship;
|
|
44
|
+
sourceRevisionId?: string | null;
|
|
45
|
+
}): ActionArtifactResultV1;
|
|
46
|
+
export declare function persistedResultReference(input: {
|
|
47
|
+
resultReferenceId: string;
|
|
48
|
+
artifact: Extract<ArtifactIdentityV1, {
|
|
49
|
+
kind: "persisted_tool_result";
|
|
50
|
+
}>;
|
|
51
|
+
relationship: ArtifactRelationship;
|
|
52
|
+
sourceRevisionId?: string | null;
|
|
53
|
+
}): ActionArtifactResultV1;
|
|
54
|
+
/** Build a 1.1 result only after the producing tool has independently verified persistence and prior state. */
|
|
55
|
+
export declare function persistedResultReferenceEnhanced(input: {
|
|
56
|
+
resultReferenceId: string;
|
|
57
|
+
artifact: Extract<ArtifactIdentityV1, {
|
|
58
|
+
kind: "persisted_tool_result";
|
|
59
|
+
}>;
|
|
60
|
+
relationship: ArtifactRelationship;
|
|
61
|
+
presentation: ActionArtifactPresentationV1 | null;
|
|
62
|
+
verification: PersistedOutputVerificationV1;
|
|
63
|
+
}): ActionArtifactResultV1_1;
|
|
64
|
+
export declare const wrapCommitTool: <T>(client: StructuredToolClient, tool: () => Promise<StructuredResult<T>>, options?: WrapperOptions) => Promise<T>;
|
|
65
|
+
export declare const wrapPullRequestTool: <T>(client: StructuredToolClient, tool: () => Promise<StructuredResult<T>>, options?: WrapperOptions) => Promise<T>;
|
|
66
|
+
export declare const wrapLinearTicketTool: <T>(client: StructuredToolClient, tool: () => Promise<StructuredResult<T>>, options?: WrapperOptions) => Promise<T>;
|
|
67
|
+
export declare const wrapPersistedResultTool: <T>(client: StructuredToolClient, tool: () => Promise<StructuredResult<T>>, options?: WrapperOptions) => Promise<T>;
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** A tool may fail after its provider persisted a resource. Preserve the original error. */
|
|
2
|
+
export class StructuredToolFailure extends Error {
|
|
3
|
+
references;
|
|
4
|
+
constructor(message, references = []) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.references = references;
|
|
7
|
+
this.name = "StructuredToolFailure";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
async function reportSafely(report) {
|
|
11
|
+
try {
|
|
12
|
+
await report();
|
|
13
|
+
}
|
|
14
|
+
catch { /* An instrumentation failure cannot change tool behavior. */ }
|
|
15
|
+
}
|
|
16
|
+
async function execute(client, kind, tool, options = {}) {
|
|
17
|
+
const action = client.action({ toolKind: kind, correlation: options.correlation });
|
|
18
|
+
await reportSafely(() => action.start());
|
|
19
|
+
try {
|
|
20
|
+
const result = await tool();
|
|
21
|
+
if (result.references.length)
|
|
22
|
+
await reportReferences(action, result.references);
|
|
23
|
+
await reportSafely(() => action.complete("succeeded"));
|
|
24
|
+
return result.value;
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
if (error instanceof StructuredToolFailure && error.references.length) {
|
|
28
|
+
await reportReferences(action, error.references, "failed");
|
|
29
|
+
}
|
|
30
|
+
await reportSafely(() => action.complete("failed"));
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function reportReferences(action, references, status = "succeeded") {
|
|
35
|
+
const enhanced = references.some((reference) => "presentation" in reference || "verification" in reference);
|
|
36
|
+
await reportSafely(() => enhanced
|
|
37
|
+
? action.resultEnhanced(references, status)
|
|
38
|
+
: action.result(references, status));
|
|
39
|
+
}
|
|
40
|
+
const unknownRevision = {
|
|
41
|
+
sourceRevisionId: null, headCommitSha: null, integrity: null,
|
|
42
|
+
};
|
|
43
|
+
export function commitReference(input) {
|
|
44
|
+
return { resultReferenceId: input.resultReferenceId,
|
|
45
|
+
artifact: { kind: "commit", repository: input.repository, sha: input.sha },
|
|
46
|
+
relationship: "created", revision: { ...unknownRevision, sourceRevisionId: input.sha } };
|
|
47
|
+
}
|
|
48
|
+
export function pullRequestReference(input) {
|
|
49
|
+
return { resultReferenceId: input.resultReferenceId,
|
|
50
|
+
artifact: { kind: "pull_request", repositoryId: input.repositoryId,
|
|
51
|
+
pullRequestId: input.pullRequestId }, relationship: input.relationship,
|
|
52
|
+
revision: { ...unknownRevision, headCommitSha: input.headCommitSha ?? null,
|
|
53
|
+
sourceRevisionId: input.sourceRevisionId ?? null } };
|
|
54
|
+
}
|
|
55
|
+
export function linearTicketReference(input) {
|
|
56
|
+
return { resultReferenceId: input.resultReferenceId,
|
|
57
|
+
artifact: { kind: "linear_ticket", workspaceId: input.workspaceId, issueId: input.issueId },
|
|
58
|
+
relationship: input.relationship,
|
|
59
|
+
revision: { ...unknownRevision, sourceRevisionId: input.sourceRevisionId ?? null } };
|
|
60
|
+
}
|
|
61
|
+
export function persistedResultReference(input) {
|
|
62
|
+
return { resultReferenceId: input.resultReferenceId, artifact: input.artifact,
|
|
63
|
+
relationship: input.relationship,
|
|
64
|
+
revision: { ...unknownRevision, sourceRevisionId: input.sourceRevisionId ?? null,
|
|
65
|
+
integrity: input.artifact.integrity } };
|
|
66
|
+
}
|
|
67
|
+
/** Build a 1.1 result only after the producing tool has independently verified persistence and prior state. */
|
|
68
|
+
export function persistedResultReferenceEnhanced(input) {
|
|
69
|
+
return { resultReferenceId: input.resultReferenceId, artifact: input.artifact,
|
|
70
|
+
relationship: input.relationship, revision: { ...unknownRevision, integrity: input.artifact.integrity },
|
|
71
|
+
presentation: input.presentation, verification: input.verification };
|
|
72
|
+
}
|
|
73
|
+
export const wrapCommitTool = (client, tool, options) => execute(client, "commit", tool, options);
|
|
74
|
+
export const wrapPullRequestTool = (client, tool, options) => execute(client, "pull_request", tool, options);
|
|
75
|
+
export const wrapLinearTicketTool = (client, tool, options) => execute(client, "linear_ticket", tool, options);
|
|
76
|
+
export const wrapPersistedResultTool = (client, tool, options) => execute(client, "persisted_result", tool, options);
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { type ArtifactIdentityV1, type ArtifactRelationship, type ArtifactRevisionV1, type LineageAuthorityV1 } from "./artifact-lineage.ts";
|
|
2
|
+
export declare const ACTION_LINEAGE_CONTRACT_VERSION: "1.0.0";
|
|
3
|
+
export declare const ACTION_LINEAGE_CAPABILITY: "artifact_lineage_v1";
|
|
4
|
+
export declare const ACTION_LINEAGE_ENHANCED_CONTRACT_VERSION: "1.1.0";
|
|
5
|
+
export declare const ACTION_LINEAGE_PRESENTATION_CAPABILITY: "artifact_presentation_v1";
|
|
6
|
+
export declare const ACTION_LINEAGE_LIMITS: {
|
|
7
|
+
readonly maxBytes: 65536;
|
|
8
|
+
readonly maxArtifacts: 32;
|
|
9
|
+
readonly maxIdentifierLength: 128;
|
|
10
|
+
};
|
|
11
|
+
export type ActionExecutionStatus = "in_progress" | "succeeded" | "failed" | "cancelled" | "unknown";
|
|
12
|
+
export interface ActionCorrelationV1 {
|
|
13
|
+
/** Source-local namespace. IDs never establish a join to completion evidence by themselves. */
|
|
14
|
+
namespace: "explicit-sdk-v1" | "codex-cli-jsonl-v1" | "codex-otel-tool-result-v1";
|
|
15
|
+
runId: string | null;
|
|
16
|
+
sessionId: string | null;
|
|
17
|
+
parentRunId: string | null;
|
|
18
|
+
toolCallId: string | null;
|
|
19
|
+
completionReference: string | null;
|
|
20
|
+
}
|
|
21
|
+
export interface ActionArtifactResultV1 {
|
|
22
|
+
resultReferenceId: string;
|
|
23
|
+
artifact: ArtifactIdentityV1;
|
|
24
|
+
relationship: ArtifactRelationship;
|
|
25
|
+
revision: ArtifactRevisionV1;
|
|
26
|
+
}
|
|
27
|
+
export interface ActionArtifactPresentationV1 {
|
|
28
|
+
sourceContext: string | null;
|
|
29
|
+
repositoryLabel: string | null;
|
|
30
|
+
pullRequestNumber: number | null;
|
|
31
|
+
issueKey: string | null;
|
|
32
|
+
filename: string | null;
|
|
33
|
+
sourcePath: string | null;
|
|
34
|
+
copyReference: string | null;
|
|
35
|
+
destination: string | null;
|
|
36
|
+
}
|
|
37
|
+
export interface PersistedOutputVerificationV1 {
|
|
38
|
+
persistedReference: string;
|
|
39
|
+
stableResultId: string | null;
|
|
40
|
+
integrity: {
|
|
41
|
+
algorithm: "sha256";
|
|
42
|
+
value: string;
|
|
43
|
+
} | null;
|
|
44
|
+
verifiedAt: string;
|
|
45
|
+
basis: "post_write_lookup" | "create_operation" | "trusted_pre_state";
|
|
46
|
+
priorExistence: "absent" | "present" | "unknown";
|
|
47
|
+
}
|
|
48
|
+
export interface ActionArtifactResultV1_1 extends ActionArtifactResultV1 {
|
|
49
|
+
presentation: ActionArtifactPresentationV1 | null;
|
|
50
|
+
verification: PersistedOutputVerificationV1 | null;
|
|
51
|
+
}
|
|
52
|
+
export type ActionLineageEnvelopeV1_1 = Omit<ActionLineageEnvelopeV1, "contractVersion" | "artifacts"> & {
|
|
53
|
+
contractVersion: typeof ACTION_LINEAGE_ENHANCED_CONTRACT_VERSION;
|
|
54
|
+
artifacts: ActionArtifactResultV1_1[];
|
|
55
|
+
};
|
|
56
|
+
export interface BoundActionLineageV1_1 {
|
|
57
|
+
authority: LineageAuthorityV1;
|
|
58
|
+
envelope: ActionLineageEnvelopeV1_1;
|
|
59
|
+
reportKey: string;
|
|
60
|
+
attemptKey: string;
|
|
61
|
+
runCorrelation: "unresolved";
|
|
62
|
+
}
|
|
63
|
+
export interface ActionLineageEnvelopeV1 {
|
|
64
|
+
contractVersion: typeof ACTION_LINEAGE_CONTRACT_VERSION;
|
|
65
|
+
/** Generated once per immutable report; reuse the complete report for transport retry. */
|
|
66
|
+
reportId: string;
|
|
67
|
+
/** Logical action and distinct execution attempt; start/end keep the same two IDs. */
|
|
68
|
+
actionId: string;
|
|
69
|
+
attemptId: string;
|
|
70
|
+
phase: "started" | "completed" | "artifact_result";
|
|
71
|
+
executionStatus: ActionExecutionStatus;
|
|
72
|
+
startedAt: string | null;
|
|
73
|
+
completedAt: string | null;
|
|
74
|
+
occurredAt: string | null;
|
|
75
|
+
correlation: ActionCorrelationV1;
|
|
76
|
+
adapter: {
|
|
77
|
+
name: "explicit_sdk" | "codex_exec_jsonl" | "codex_otel_tool_result";
|
|
78
|
+
version: string;
|
|
79
|
+
sourceVersion: string | null;
|
|
80
|
+
};
|
|
81
|
+
metadata: {
|
|
82
|
+
toolKind: "commit" | "pull_request" | "linear_ticket" | "persisted_result" | "command" | "custom";
|
|
83
|
+
exitCode: number | null;
|
|
84
|
+
errorCode: "tool_failed" | "cancelled" | "unknown" | null;
|
|
85
|
+
};
|
|
86
|
+
artifacts: ActionArtifactResultV1[];
|
|
87
|
+
}
|
|
88
|
+
/** A source-local interval with known lost action reports. It carries no action or content fields. */
|
|
89
|
+
export interface ActionCollectionGapV1 {
|
|
90
|
+
contractVersion: typeof ACTION_LINEAGE_CONTRACT_VERSION;
|
|
91
|
+
kind: "collection_gap";
|
|
92
|
+
gapId: string;
|
|
93
|
+
gapStart: string;
|
|
94
|
+
gapEnd: string;
|
|
95
|
+
reason: "queue_overflow" | "queue_expired" | "operator_reported";
|
|
96
|
+
}
|
|
97
|
+
export declare function parseActionCollectionGap(value: unknown): ActionCollectionGapV1;
|
|
98
|
+
export interface AuthenticatedActionContextV1 {
|
|
99
|
+
authority: LineageAuthorityV1;
|
|
100
|
+
capabilities: readonly string[];
|
|
101
|
+
approvedLocatorOrigins?: readonly string[];
|
|
102
|
+
}
|
|
103
|
+
export interface BoundActionLineageV1 {
|
|
104
|
+
authority: LineageAuthorityV1;
|
|
105
|
+
envelope: ActionLineageEnvelopeV1;
|
|
106
|
+
reportKey: string;
|
|
107
|
+
attemptKey: string;
|
|
108
|
+
/** A separate server reconciliation step must establish a documented completion join. */
|
|
109
|
+
runCorrelation: "unresolved";
|
|
110
|
+
}
|
|
111
|
+
export declare function parseActionLineageEnvelope(value: unknown, approvedLocatorOrigins?: readonly string[]): ActionLineageEnvelopeV1;
|
|
112
|
+
/** Receiver verifies credentials before supplying context; this function cannot authenticate. */
|
|
113
|
+
export declare function bindActionLineageEnvelope(value: unknown, context: AuthenticatedActionContextV1): BoundActionLineageV1;
|
|
114
|
+
/** Parse bounded JSON before accepting reports; the HTTP receiver must also bound body reads. */
|
|
115
|
+
export declare function parseActionLineageJson(text: string, context: AuthenticatedActionContextV1): BoundActionLineageV1;
|
|
116
|
+
export declare function actionArtifactResultKey(result: ActionArtifactResultV1, bound: BoundActionLineageV1): string;
|
|
117
|
+
/** Enhanced parser is capability-gated separately; v1 parsing remains byte-for-byte strict. */
|
|
118
|
+
export declare function parseActionLineageEnvelopeV1_1(value: unknown, approvedLocatorOrigins?: readonly string[]): ActionLineageEnvelopeV1_1;
|
|
119
|
+
export declare function bindActionLineageEnvelopeV1_1(value: unknown, context: AuthenticatedActionContextV1): BoundActionLineageV1_1;
|
|
120
|
+
export declare function isConfirmedPersistedCreation(result: ActionArtifactResultV1_1): boolean;
|