@artieeez/cf-sdk 0.0.0-stage → 0.1.0
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 +96 -2
- package/dist/fragments/approval.d.ts +83 -0
- package/dist/fragments/approval.d.ts.map +1 -0
- package/dist/fragments/approval.js +170 -0
- package/dist/fragments/approval.js.map +1 -0
- package/dist/fragments/common.d.ts +65 -0
- package/dist/fragments/common.d.ts.map +1 -0
- package/dist/fragments/common.js +138 -0
- package/dist/fragments/common.js.map +1 -0
- package/dist/fragments/deliver.d.ts +178 -0
- package/dist/fragments/deliver.d.ts.map +1 -0
- package/dist/fragments/deliver.js +232 -0
- package/dist/fragments/deliver.js.map +1 -0
- package/dist/fragments/index.d.ts +6 -0
- package/dist/fragments/index.d.ts.map +1 -0
- package/dist/fragments/index.js +6 -0
- package/dist/fragments/index.js.map +1 -0
- package/dist/fragments/validated.d.ts +64 -0
- package/dist/fragments/validated.d.ts.map +1 -0
- package/dist/fragments/validated.js +95 -0
- package/dist/fragments/validated.js.map +1 -0
- package/dist/fragments/verifier-round.d.ts +128 -0
- package/dist/fragments/verifier-round.d.ts.map +1 -0
- package/dist/fragments/verifier-round.js +295 -0
- package/dist/fragments/verifier-round.js.map +1 -0
- package/dist/index.d.ts +597 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +244 -0
- package/dist/index.js.map +1 -0
- package/dist/kit.d.ts +44 -0
- package/dist/kit.d.ts.map +1 -0
- package/dist/kit.js +32 -0
- package/dist/kit.js.map +1 -0
- package/dist/plugin.d.ts +126 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +15 -0
- package/dist/plugin.js.map +1 -0
- package/dist/prompt.d.ts +10 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +34 -0
- package/dist/prompt.js.map +1 -0
- package/dist/runner.d.ts +88 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +224 -0
- package/dist/runner.js.map +1 -0
- package/package.json +79 -3
- package/src/fragments/approval.ts +267 -0
- package/src/fragments/common.ts +195 -0
- package/src/fragments/deliver.ts +447 -0
- package/src/fragments/index.ts +57 -0
- package/src/fragments/validated.ts +217 -0
- package/src/fragments/verifier-round.ts +442 -0
- package/src/index.ts +890 -0
- package/src/kit.ts +137 -0
- package/src/plugin.ts +128 -0
- package/src/prompt.ts +29 -0
- package/src/runner.ts +278 -0
package/README.md
CHANGED
|
@@ -1,3 +1,97 @@
|
|
|
1
|
-
#
|
|
1
|
+
# sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Workflow authoring: defineWorkflow, task/human/wait/map/parallel, hooks, ctx types, signals,
|
|
4
|
+
**event contracts**, build to manifest + bundle.
|
|
5
|
+
|
|
6
|
+
A workflow folder (AD-030) binds its input, plugins, settings and events once in `kit.ts`,
|
|
7
|
+
so steps and hooks are typed without type arguments or casts:
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
// kit.ts
|
|
11
|
+
export const kit = workflowKit({ input: Input, plugins: { tracker: linear.slot() } });
|
|
12
|
+
export const { task, human } = kit;
|
|
13
|
+
|
|
14
|
+
// steps/compose.ts
|
|
15
|
+
const greets = prompt(import.meta.dirname, '../prompts/compose.md'); // {{name}} placeholders
|
|
16
|
+
export const compose = task({
|
|
17
|
+
outcomes: ['ok', 'fail'],
|
|
18
|
+
next: { ok: 'report', fail: '$fail' },
|
|
19
|
+
output: Line, // checked before the unit completes (AD-031); types ctx.output(compose)
|
|
20
|
+
async run(ctx) {
|
|
21
|
+
const r = await ctx.agent({ role: 'poet', prompt: greets({ name: ctx.input.name }), output: Line });
|
|
22
|
+
return r.status === 'completed' ? { outcome: 'ok', output: r.output } : { outcome: 'fail' };
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// workflow.ts
|
|
27
|
+
export const hello = kit.define({ id: 'hello', version: '0.5.0', start: 'compose', steps: { compose, report } });
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Reusable graph fragments
|
|
31
|
+
|
|
32
|
+
Four plain TypeScript fragments live on `workflowKit` (`kit.validated`, `kit.approval`,
|
|
33
|
+
`kit.verifierRound`, `kit.deliver`) and as standalone exports from `@artieeez/cf-sdk`
|
|
34
|
+
(AD-065). Each compiles to standard v1 manifest steps with slug-prefixed IDs and returns
|
|
35
|
+
`{ start, ids, steps, ...handles }` so workflows compose them with full TypeScript
|
|
36
|
+
inference:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
const plan = kit.validated('plan', {
|
|
40
|
+
agent: {
|
|
41
|
+
outcomes: ['ready', 'fail'],
|
|
42
|
+
next: { fail: '$fail' },
|
|
43
|
+
async run(ctx, lastFailure) {
|
|
44
|
+
// lastFailure carries ValidationOutput after a failed validation visit
|
|
45
|
+
return { outcome: 'ready' };
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
script: ['python3', 'scripts/validate_plan.py', 'my-feature'],
|
|
49
|
+
next: 'approve-plan',
|
|
50
|
+
maxVisits: 3,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const approvePlan = kit.approval('approve-plan', {
|
|
54
|
+
file: '.specs/features/my-feature/plan.md',
|
|
55
|
+
producer: plan.ids.producer,
|
|
56
|
+
next: 'verify-proofs',
|
|
57
|
+
onRejected: plan.start,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const verify = kit.verifierRound({
|
|
61
|
+
id: 'verify',
|
|
62
|
+
proofs: ['python3', 'scripts/check_proofs.py', 'my-feature'],
|
|
63
|
+
verifier: { run: async (ctx) => ({ findings: [] }) },
|
|
64
|
+
screens: { run: async (ctx, { round, resumeSessionId }) => ({ passed: true, findings: [] }) },
|
|
65
|
+
fix: { run: async (ctx, findings) => 'done' },
|
|
66
|
+
gate: ['python3', 'scripts/validate_verification.py', 'my-feature'],
|
|
67
|
+
next: 'deliver-approve-push',
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const delivery = kit.deliver({
|
|
71
|
+
id: 'deliver',
|
|
72
|
+
forge: {
|
|
73
|
+
slot: 'forge',
|
|
74
|
+
target: (ctx) => ({ repo: 'org/app', dir: 'repo', sha, branch, base: 'main', title, body }),
|
|
75
|
+
push: (ctx, p) => github.git.push(ctx, { token, ...p }),
|
|
76
|
+
openPr: (ctx, p) => github.pr.open(ctx, { octokit, ...p }),
|
|
77
|
+
comment: (_ctx, pr) => `Opened PR #${pr.number}`,
|
|
78
|
+
},
|
|
79
|
+
tracker: { slot: 'tracker', issueId: (ctx) => ctx.input.issueId },
|
|
80
|
+
next: '$end',
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
export const workflow = kit.define({
|
|
84
|
+
id: 'my-flow',
|
|
85
|
+
version: '0.1.0',
|
|
86
|
+
start: plan.start,
|
|
87
|
+
steps: { ...plan.steps, ...approvePlan.steps, ...verify.steps, ...delivery.steps },
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`@artieeez/cf-sdk/runner` is what the CLI agent runners share
|
|
92
|
+
(`@artieeez/cf-runner-claude-code`, `-agy`, `-pi`): the child's env, the process with its
|
|
93
|
+
timeout and stop, JSONL framing, and the attempt loop with the output contract, the facts
|
|
94
|
+
check, one retry and the transcript. A runner keeps its argv and how it reads its CLI's
|
|
95
|
+
stream.
|
|
96
|
+
|
|
97
|
+
See [docs/design](../../docs/design/README.md).
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type Duration, type HumanStep, type NoEvents, type PluginApis, type Ref, type Settings, type TaskContext, type TaskStep } from '../index.ts';
|
|
3
|
+
/** Form schema of an `approval` human step: captures the approver's verbatim words. */
|
|
4
|
+
export declare const ApprovalForm: z.ZodObject<{
|
|
5
|
+
words: z.ZodString;
|
|
6
|
+
}, z.core.$strict>;
|
|
7
|
+
export type ApprovalFormData = z.infer<typeof ApprovalForm>;
|
|
8
|
+
/** Output schema of an `approval` record task (AD-031). */
|
|
9
|
+
export declare const ApprovalRecordOutput: z.ZodObject<{
|
|
10
|
+
file: z.ZodString;
|
|
11
|
+
date: z.ZodString;
|
|
12
|
+
words: z.ZodString;
|
|
13
|
+
line: z.ZodString;
|
|
14
|
+
}, z.core.$strict>;
|
|
15
|
+
export type ApprovalRecordOutput = z.infer<typeof ApprovalRecordOutput>;
|
|
16
|
+
/** Information passed to a custom `record` hook in `approval`. */
|
|
17
|
+
export interface ApprovalRecordInfo {
|
|
18
|
+
file: string;
|
|
19
|
+
words: string;
|
|
20
|
+
date: string;
|
|
21
|
+
line: string;
|
|
22
|
+
}
|
|
23
|
+
/** Options for `approval(id, opts)`. */
|
|
24
|
+
export interface ApprovalOptions<I = unknown, P extends PluginApis = PluginApis, S = Settings, E = NoEvents> {
|
|
25
|
+
/** Workspace-relative path to the file being approved (static string or derived from `ctx`). */
|
|
26
|
+
file: string | ((ctx: TaskContext<I, P, S, E>) => string);
|
|
27
|
+
/** Explicit artifacts ref for hash binding (`ref('<producer>.artifacts.<glob>')`); overrides `producer`. */
|
|
28
|
+
bind?: Ref;
|
|
29
|
+
/** Producer step id shorthand when `file` is a static string (builds `ref('<producer>.artifacts.<file>')`). */
|
|
30
|
+
producer?: string;
|
|
31
|
+
/** Human prompt title; defaults to `Approve <file>` or `Approve <id>`. */
|
|
32
|
+
title?: string;
|
|
33
|
+
/** Extra `about` entries merged alongside the bound artifact ref. */
|
|
34
|
+
about?: Record<string, Ref>;
|
|
35
|
+
/** Target step after the approval is recorded. */
|
|
36
|
+
next: string;
|
|
37
|
+
/** Target step when the human rejects the approval. */
|
|
38
|
+
onRejected: string;
|
|
39
|
+
/** Optional visit cap on the human approval step. */
|
|
40
|
+
maxVisits?: number;
|
|
41
|
+
/** Target step when `maxVisits` is exhausted; defaults to `'$fail'` when `maxVisits` is set. */
|
|
42
|
+
onExhausted?: string;
|
|
43
|
+
/** Optional deadline on the human approval step. */
|
|
44
|
+
timeout?: {
|
|
45
|
+
after: Duration;
|
|
46
|
+
outcome: 'approved' | 'rejected';
|
|
47
|
+
};
|
|
48
|
+
/** Optional reminder cadence on the human approval step. */
|
|
49
|
+
remind?: {
|
|
50
|
+
every: Duration;
|
|
51
|
+
};
|
|
52
|
+
/** Optional working directory for the record task. */
|
|
53
|
+
wd?: string;
|
|
54
|
+
/** Optional clock used to format `<YYYY-MM-DD>`; defaults to `() => new Date()`. */
|
|
55
|
+
now?: () => Date;
|
|
56
|
+
/** Custom recorder replacing the default workspace disk write. */
|
|
57
|
+
record?: (ctx: TaskContext<I, P, S, E>, info: ApprovalRecordInfo) => Promise<void> | void;
|
|
58
|
+
}
|
|
59
|
+
/** What `approval(id, opts)` returns: entry id, step handles, and spreadable `steps`. */
|
|
60
|
+
export interface ApprovalFragment<Id extends string, I, P extends PluginApis, S, E> {
|
|
61
|
+
start: Id;
|
|
62
|
+
ids: {
|
|
63
|
+
approve: Id;
|
|
64
|
+
record: `${Id}-record`;
|
|
65
|
+
};
|
|
66
|
+
approve: HumanStep<'approved' | 'rejected', typeof ApprovalForm>;
|
|
67
|
+
record: TaskStep<I, 'recorded', P, typeof ApprovalRecordOutput, S, E>;
|
|
68
|
+
steps: Record<Id, HumanStep<'approved' | 'rejected', typeof ApprovalForm>> & Record<`${Id}-record`, TaskStep<I, 'recorded', P, typeof ApprovalRecordOutput, S, E>>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Inserts or replaces `**Approved**: <date> - user: "<words>"` in `content`:
|
|
72
|
+
* 1. Replaces an existing `**Approved**:` line outside fenced code blocks (idempotent).
|
|
73
|
+
* 2. Otherwise inserts after the first leading `# Heading` line.
|
|
74
|
+
* 3. Otherwise prepends at the top of the file.
|
|
75
|
+
*/
|
|
76
|
+
export declare function applyApprovalLine(content: string, line: string): string;
|
|
77
|
+
/**
|
|
78
|
+
* Builds a hash-bound human approval step `<id>` followed by `<id>-record`, which writes the
|
|
79
|
+
* approver's exact words into the workspace file on disk without calling `ctx.artifacts.put` on
|
|
80
|
+
* the bound artifact path (preventing AD-015 reopen loops).
|
|
81
|
+
*/
|
|
82
|
+
export declare function approval<const Id extends string, I = unknown, P extends PluginApis = PluginApis, S = Settings, E = NoEvents>(id: Id, opts: ApprovalOptions<I, P, S, E>): ApprovalFragment<Id, I, P, S, E>;
|
|
83
|
+
//# sourceMappingURL=approval.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../../src/fragments/approval.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,GAAG,EACR,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,QAAQ,EACd,MAAM,aAAa,CAAC;AAGrB,uFAAuF;AACvF,eAAO,MAAM,YAAY;;kBAEvB,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAE5D,2DAA2D;AAC3D,eAAO,MAAM,oBAAoB;;;;;kBAK/B,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE,kEAAkE;AAClE,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wCAAwC;AACxC,MAAM,WAAW,eAAe,CAC9B,CAAC,GAAG,OAAO,EACX,CAAC,SAAS,UAAU,GAAG,UAAU,EACjC,CAAC,GAAG,QAAQ,EACZ,CAAC,GAAG,QAAQ;IAEZ,gGAAgG;IAChG,IAAI,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,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C;IAC7C,OAAO,EAAE,SAAS,CAAC,UAAU,GAAG,UAAU,EAAE,OAAO,YAAY,CAAC,CAAC;IACjE,MAAM,EAAE,QAAQ,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,OAAO,oBAAoB,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACtE,KAAK,EAAE,MAAM,CAAC,EAAE,EAAE,SAAS,CAAC,UAAU,GAAG,UAAU,EAAE,OAAO,YAAY,CAAC,CAAC,GACxE,MAAM,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,OAAO,oBAAoB,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;CACzF;AAKD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAqCvE;AAgBD;;;;GAIG;AACH,wBAAgB,QAAQ,CACtB,KAAK,CAAC,EAAE,SAAS,MAAM,EACvB,CAAC,GAAG,OAAO,EACX,CAAC,SAAS,UAAU,GAAG,UAAU,EACjC,CAAC,GAAG,QAAQ,EACZ,CAAC,GAAG,QAAQ,EAEZ,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAChC,gBAAgB,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAiGlC"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { existsSync, readFileSync, realpathSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { isAbsolute, relative, resolve, sep } from 'node:path';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { parseRef } from '@artieeez/cf-core';
|
|
5
|
+
import { ref, } from "../index.js";
|
|
6
|
+
import { assertPositiveInt, assertSlug, stepId } from "./common.js";
|
|
7
|
+
/** Form schema of an `approval` human step: captures the approver's verbatim words. */
|
|
8
|
+
export const ApprovalForm = z.strictObject({
|
|
9
|
+
words: z.string().min(1),
|
|
10
|
+
});
|
|
11
|
+
/** Output schema of an `approval` record task (AD-031). */
|
|
12
|
+
export const ApprovalRecordOutput = z.strictObject({
|
|
13
|
+
file: z.string(),
|
|
14
|
+
date: z.string(),
|
|
15
|
+
words: z.string(),
|
|
16
|
+
line: z.string(),
|
|
17
|
+
});
|
|
18
|
+
const APPROVED_LINE_RE = /^\**\s*Approved\s*\**\s*:/i;
|
|
19
|
+
const FENCE_RE = /^(`{3,}|~{3,})/;
|
|
20
|
+
/**
|
|
21
|
+
* Inserts or replaces `**Approved**: <date> - user: "<words>"` in `content`:
|
|
22
|
+
* 1. Replaces an existing `**Approved**:` line outside fenced code blocks (idempotent).
|
|
23
|
+
* 2. Otherwise inserts after the first leading `# Heading` line.
|
|
24
|
+
* 3. Otherwise prepends at the top of the file.
|
|
25
|
+
*/
|
|
26
|
+
export function applyApprovalLine(content, line) {
|
|
27
|
+
const eol = content.includes('\r\n') ? '\r\n' : '\n';
|
|
28
|
+
const hadTrailingNewline = content.endsWith('\n');
|
|
29
|
+
const raw = hadTrailingNewline ? content.slice(0, content.endsWith('\r\n') ? -2 : -1) : content;
|
|
30
|
+
const lines = raw === '' ? [] : raw.split(/\r?\n/);
|
|
31
|
+
let fence;
|
|
32
|
+
for (let i = 0; i < lines.length; i++) {
|
|
33
|
+
const trimmed = lines[i].trim();
|
|
34
|
+
const fenceMatch = FENCE_RE.exec(trimmed);
|
|
35
|
+
if (fenceMatch !== null) {
|
|
36
|
+
const marker = fenceMatch[1][0];
|
|
37
|
+
if (fence === undefined)
|
|
38
|
+
fence = marker;
|
|
39
|
+
else if (fence === marker)
|
|
40
|
+
fence = undefined;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (fence === undefined && APPROVED_LINE_RE.test(trimmed)) {
|
|
44
|
+
lines[i] = line;
|
|
45
|
+
return lines.join(eol) + (hadTrailingNewline ? eol : '');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const firstNonEmpty = lines.findIndex((l) => l.trim() !== '');
|
|
49
|
+
if (firstNonEmpty !== -1 && /^#\s+/.test(lines[firstNonEmpty])) {
|
|
50
|
+
const after = firstNonEmpty + 1;
|
|
51
|
+
if (lines[after] === '') {
|
|
52
|
+
lines.splice(after + 1, 0, line, '');
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
lines.splice(after, 0, '', line);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if (lines.length === 0) {
|
|
59
|
+
lines.push(line);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
lines.unshift(line, '');
|
|
63
|
+
}
|
|
64
|
+
return lines.join(eol) + (hadTrailingNewline || content === '' ? eol : '');
|
|
65
|
+
}
|
|
66
|
+
/** Ensures `filePath` is relative and resolves strictly inside `baseDir`. */
|
|
67
|
+
function confinePath(baseDir, filePath, id) {
|
|
68
|
+
if (filePath.trim() === '' || isAbsolute(filePath)) {
|
|
69
|
+
throw new Error(`approval(${id}): file "${filePath}" must be relative to workspace "${baseDir}"`);
|
|
70
|
+
}
|
|
71
|
+
const base = resolve(baseDir);
|
|
72
|
+
const abs = resolve(base, filePath);
|
|
73
|
+
const rel = relative(base, abs);
|
|
74
|
+
if (rel === '' || rel === '..' || rel.startsWith(`..${sep}`) || isAbsolute(rel)) {
|
|
75
|
+
throw new Error(`approval(${id}): file "${filePath}" escapes workspace "${baseDir}"`);
|
|
76
|
+
}
|
|
77
|
+
return abs;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Builds a hash-bound human approval step `<id>` followed by `<id>-record`, which writes the
|
|
81
|
+
* approver's exact words into the workspace file on disk without calling `ctx.artifacts.put` on
|
|
82
|
+
* the bound artifact path (preventing AD-015 reopen loops).
|
|
83
|
+
*/
|
|
84
|
+
export function approval(id, opts) {
|
|
85
|
+
assertSlug(id, 'approval');
|
|
86
|
+
let bindRef;
|
|
87
|
+
if (opts.bind !== undefined) {
|
|
88
|
+
bindRef = opts.bind;
|
|
89
|
+
}
|
|
90
|
+
else if (opts.producer !== undefined && typeof opts.file === 'string') {
|
|
91
|
+
assertSlug(opts.producer, `approval(${id}) producer`);
|
|
92
|
+
bindRef = ref(`${opts.producer}.artifacts.${opts.file}`);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
throw new Error(`approval(${id}): provide "bind" (or "producer" with a static file path)`);
|
|
96
|
+
}
|
|
97
|
+
const parsed = parseRef(bindRef.ref);
|
|
98
|
+
if (typeof parsed === 'string' || parsed.scope !== 'artifacts') {
|
|
99
|
+
throw new Error(`approval(${id}): bind must be a valid artifacts ref (<step>.artifacts.<glob>), got "${bindRef.ref}"`);
|
|
100
|
+
}
|
|
101
|
+
if (opts.maxVisits !== undefined) {
|
|
102
|
+
assertPositiveInt(opts.maxVisits, `approval(${id}) maxVisits`);
|
|
103
|
+
}
|
|
104
|
+
const recordId = stepId(id, 'record');
|
|
105
|
+
const label = typeof opts.file === 'string' ? opts.file : 'artifact';
|
|
106
|
+
const approve = {
|
|
107
|
+
kind: 'human',
|
|
108
|
+
title: opts.title ?? `Approve ${typeof opts.file === 'string' ? opts.file : id}`,
|
|
109
|
+
form: ApprovalForm,
|
|
110
|
+
bind: bindRef,
|
|
111
|
+
about: { [label]: bindRef, ...(opts.about ?? {}) },
|
|
112
|
+
outcomes: ['approved', 'rejected'],
|
|
113
|
+
next: { approved: recordId, rejected: opts.onRejected },
|
|
114
|
+
...(opts.maxVisits !== undefined
|
|
115
|
+
? { maxVisits: opts.maxVisits, onExhausted: opts.onExhausted ?? '$fail' }
|
|
116
|
+
: {}),
|
|
117
|
+
...(opts.timeout !== undefined ? { timeout: opts.timeout } : {}),
|
|
118
|
+
...(opts.remind !== undefined ? { remind: opts.remind } : {}),
|
|
119
|
+
};
|
|
120
|
+
const record = {
|
|
121
|
+
kind: 'task',
|
|
122
|
+
outcomes: ['recorded'],
|
|
123
|
+
next: { recorded: opts.next },
|
|
124
|
+
...(opts.wd !== undefined ? { wd: opts.wd } : {}),
|
|
125
|
+
output: ApprovalRecordOutput,
|
|
126
|
+
async run(ctx) {
|
|
127
|
+
const answer = ctx.output(approve);
|
|
128
|
+
const rawWords = answer?.words;
|
|
129
|
+
const trimmed = typeof rawWords === 'string' ? rawWords.trim() : '';
|
|
130
|
+
if (trimmed === '') {
|
|
131
|
+
throw new Error(`approval(${id}): approver words are empty`);
|
|
132
|
+
}
|
|
133
|
+
const filePath = typeof opts.file === 'function' ? opts.file(ctx) : opts.file;
|
|
134
|
+
const abs = confinePath(ctx.wd, filePath, id);
|
|
135
|
+
const date = (opts.now?.() ?? new Date()).toISOString().slice(0, 10);
|
|
136
|
+
const safeWords = trimmed.replace(/\r?\n+/g, ' ').replace(/\s+/g, ' ').replace(/"/g, "'");
|
|
137
|
+
const line = `**Approved**: ${date} - user: "${safeWords}"`;
|
|
138
|
+
if (opts.record !== undefined) {
|
|
139
|
+
await opts.record(ctx, { file: filePath, words: trimmed, date, line });
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
if (!existsSync(abs)) {
|
|
143
|
+
throw new Error(`approval(${id}): file not found at "${abs}"`);
|
|
144
|
+
}
|
|
145
|
+
const realBase = realpathSync(resolve(ctx.wd));
|
|
146
|
+
const realAbs = realpathSync(abs);
|
|
147
|
+
const realRel = relative(realBase, realAbs);
|
|
148
|
+
if (realRel === '' || realRel === '..' || realRel.startsWith(`..${sep}`) || isAbsolute(realRel)) {
|
|
149
|
+
throw new Error(`approval(${id}): file "${filePath}" escapes workspace "${ctx.wd}"`);
|
|
150
|
+
}
|
|
151
|
+
const current = readFileSync(abs, 'utf8');
|
|
152
|
+
const updated = applyApprovalLine(current, line);
|
|
153
|
+
writeFileSync(abs, updated, 'utf8');
|
|
154
|
+
}
|
|
155
|
+
return { outcome: 'recorded', output: { file: filePath, date, words: trimmed, line } };
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
const steps = {
|
|
159
|
+
[id]: approve,
|
|
160
|
+
[recordId]: record,
|
|
161
|
+
};
|
|
162
|
+
return {
|
|
163
|
+
start: id,
|
|
164
|
+
ids: { approve: id, record: recordId },
|
|
165
|
+
approve,
|
|
166
|
+
record,
|
|
167
|
+
steps,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=approval.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approval.js","sourceRoot":"","sources":["../../src/fragments/approval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EACL,GAAG,GASJ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEpE,uFAAuF;AACvF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,YAAY,CAAC;IACzC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACzB,CAAC,CAAC;AAGH,2DAA2D;AAC3D,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,YAAY,CAAC;IACjD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;CACjB,CAAC,CAAC;AAgEH,MAAM,gBAAgB,GAAG,4BAA4B,CAAC;AACtD,MAAM,QAA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AAC,YAAY,EAAE,YAAY,QAAQ,wBAAwB,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;gBACvF,CAAC;gBACD,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;gBAC1C,MAAM,OAAO,GAAG,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBACjD,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YACtC,CAAC;YAED,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;QACzF,CAAC;KACF,CAAC;IAEF,MAAM,KAAK,GAAG;QACZ,CAAC,EAAE,CAAC,EAAE,OAAO;QACb,CAAC,QAAQ,CAAC,EAAE,MAAM;KAEmE,CAAC;IAExF,OAAO;QACL,KAAK,EAAE,EAAE;QACT,GAAG,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;QACtC,OAAO;QACP,MAAM;QACN,KAAK;KACN,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { NoEvents, PluginApis, Settings, TaskContext } from '../index.ts';
|
|
3
|
+
/** Matches manifest `StepId` (`packages/core/src/manifest.ts`). */
|
|
4
|
+
export declare const SLUG_RE: RegExp;
|
|
5
|
+
/** Default per-stream char cap for script output (keeps serialized ValidationOutput under AD-012). */
|
|
6
|
+
export declare const DEFAULT_MAX_OUTPUT_CHARS = 16000;
|
|
7
|
+
/** Asserts that `id` is a valid manifest step slug (`/^[a-z][a-z0-9-]*$/`). */
|
|
8
|
+
export declare function assertSlug(id: string, context: string): void;
|
|
9
|
+
/** Asserts that `value` is a positive integer (>= 1). */
|
|
10
|
+
export declare function assertPositiveInt(value: number, label: string): void;
|
|
11
|
+
/** Builds a prefixed step id `<prefix>-<suffix>`. */
|
|
12
|
+
export declare function stepId<P extends string, S extends string>(prefix: P, suffix: S): `${P}-${S}`;
|
|
13
|
+
/**
|
|
14
|
+
* Enclosing fan-out prefix of `stepPath`: `""` at top level, `"units[u1]."` for
|
|
15
|
+
* `"units[u1].verify-findings"`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function scopePrefix(stepPath: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Slices `text` to at most `maxChars` UTF-16 code units without splitting a surrogate pair
|
|
20
|
+
* (prevents lone surrogates that JSONB rejects, L-022).
|
|
21
|
+
*/
|
|
22
|
+
export declare function sliceSurrogateSafe(text: string, maxChars: number): {
|
|
23
|
+
text: string;
|
|
24
|
+
truncated: boolean;
|
|
25
|
+
};
|
|
26
|
+
/** Structured output of a script validation / proofs / completion gate task (AD-031). */
|
|
27
|
+
export declare const ValidationOutput: z.ZodObject<{
|
|
28
|
+
passed: z.ZodBoolean;
|
|
29
|
+
code: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
30
|
+
stdout: z.ZodString;
|
|
31
|
+
stderr: z.ZodString;
|
|
32
|
+
output: z.ZodString;
|
|
33
|
+
truncated: z.ZodBoolean;
|
|
34
|
+
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
}, z.core.$strict>;
|
|
36
|
+
export type ValidationOutput = z.infer<typeof ValidationOutput>;
|
|
37
|
+
/** Command run without a shell via `ctx.exec` (AD-010). */
|
|
38
|
+
export interface CommandSpec {
|
|
39
|
+
cmd: string;
|
|
40
|
+
args?: readonly string[];
|
|
41
|
+
cwd?: string;
|
|
42
|
+
env?: Record<string, string>;
|
|
43
|
+
timeoutMs?: number;
|
|
44
|
+
}
|
|
45
|
+
/** Result returned by a custom validation callback `{ run(ctx) }`. */
|
|
46
|
+
export interface ValidationCheckResult {
|
|
47
|
+
passed: boolean;
|
|
48
|
+
output?: string;
|
|
49
|
+
stdout?: string;
|
|
50
|
+
stderr?: string;
|
|
51
|
+
code?: number | null;
|
|
52
|
+
}
|
|
53
|
+
/** A command tuple, `CommandSpec`, dynamic builder, or custom validator function. */
|
|
54
|
+
export type ValidationScript<I = unknown, P extends PluginApis = PluginApis, S = Settings, E = NoEvents> = readonly [cmd: string, ...args: string[]] | CommandSpec | ((ctx: TaskContext<I, P, S, E>) => Promise<CommandSpec | readonly [string, ...string[]]> | CommandSpec | readonly [string, ...string[]]) | {
|
|
55
|
+
run(ctx: TaskContext<I, P, S, E>): Promise<ValidationCheckResult> | ValidationCheckResult;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Executes a `ValidationScript`, enforces surrogate-safe truncation within `maxOutputChars` and
|
|
59
|
+
* AD-012's `OUTPUT_MAX_BYTES`, and writes the full output log as an artifact when truncated.
|
|
60
|
+
*/
|
|
61
|
+
export declare function runValidationScript<I, P extends PluginApis, S, E>(ctx: TaskContext<I, P, S, E>, script: ValidationScript<I, P, S, E>, opts: {
|
|
62
|
+
artifactPrefix: string;
|
|
63
|
+
maxOutputChars?: number;
|
|
64
|
+
}): Promise<ValidationOutput>;
|
|
65
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/fragments/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/E,mEAAmE;AACnE,eAAO,MAAM,OAAO,QAAsB,CAAC;AAE3C,sGAAsG;AACtG,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAE/C,+EAA+E;AAC/E,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAI5D;AAED,yDAAyD;AACzD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MA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,CAAC,GAAG,QAAQ,IAEV,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,GACzC,WAAW,GACX,CAAC,CACC,GAAG,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KACzB,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC,GAAG,WAAW,GAAG,SAAS,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC,GAC1G;IACE,GAAG,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,qBAAqB,CAAC,GAAG,qBAAqB,CAAC;CAC3F,CAAC;AAQN;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,CAAC,EACD,CAAC,SAAS,UAAU,EACpB,CAAC,EACD,CAAC,EAED,GAAG,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC5B,MAAM,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACpC,IAAI,EAAE;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,GACxD,OAAO,CAAC,gBAAgB,CAAC,CA4E3B"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { OUTPUT_MAX_BYTES, outputBytes } from '@artieeez/cf-core';
|
|
3
|
+
/** Matches manifest `StepId` (`packages/core/src/manifest.ts`). */
|
|
4
|
+
export const SLUG_RE = /^[a-z][a-z0-9-]*$/;
|
|
5
|
+
/** Default per-stream char cap for script output (keeps serialized ValidationOutput under AD-012). */
|
|
6
|
+
export const DEFAULT_MAX_OUTPUT_CHARS = 16_000;
|
|
7
|
+
/** Asserts that `id` is a valid manifest step slug (`/^[a-z][a-z0-9-]*$/`). */
|
|
8
|
+
export function assertSlug(id, context) {
|
|
9
|
+
if (!SLUG_RE.test(id)) {
|
|
10
|
+
throw new Error(`${context}: fragment id "${id}" must be a lowercase slug (/^[a-z][a-z0-9-]*$/)`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** Asserts that `value` is a positive integer (>= 1). */
|
|
14
|
+
export function assertPositiveInt(value, label) {
|
|
15
|
+
if (!Number.isInteger(value) || value < 1) {
|
|
16
|
+
throw new Error(`${label} must be a positive integer, got ${String(value)}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Builds a prefixed step id `<prefix>-<suffix>`. */
|
|
20
|
+
export function stepId(prefix, suffix) {
|
|
21
|
+
return `${prefix}-${suffix}`;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Enclosing fan-out prefix of `stepPath`: `""` at top level, `"units[u1]."` for
|
|
25
|
+
* `"units[u1].verify-findings"`.
|
|
26
|
+
*/
|
|
27
|
+
export function scopePrefix(stepPath) {
|
|
28
|
+
const dot = stepPath.lastIndexOf('.');
|
|
29
|
+
return dot === -1 ? '' : stepPath.slice(0, dot + 1);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Slices `text` to at most `maxChars` UTF-16 code units without splitting a surrogate pair
|
|
33
|
+
* (prevents lone surrogates that JSONB rejects, L-022).
|
|
34
|
+
*/
|
|
35
|
+
export function sliceSurrogateSafe(text, maxChars) {
|
|
36
|
+
const limit = Math.max(0, Math.floor(maxChars));
|
|
37
|
+
if (text.length <= limit)
|
|
38
|
+
return { text, truncated: false };
|
|
39
|
+
let end = limit;
|
|
40
|
+
if (end > 0) {
|
|
41
|
+
const code = text.charCodeAt(end - 1);
|
|
42
|
+
if (code >= 0xd800 && code <= 0xdbff)
|
|
43
|
+
end -= 1;
|
|
44
|
+
}
|
|
45
|
+
return { text: text.slice(0, end), truncated: true };
|
|
46
|
+
}
|
|
47
|
+
/** Structured output of a script validation / proofs / completion gate task (AD-031). */
|
|
48
|
+
export const ValidationOutput = z.strictObject({
|
|
49
|
+
passed: z.boolean(),
|
|
50
|
+
code: z.number().int().nullable().optional(),
|
|
51
|
+
stdout: z.string(),
|
|
52
|
+
stderr: z.string(),
|
|
53
|
+
output: z.string(),
|
|
54
|
+
truncated: z.boolean(),
|
|
55
|
+
durationMs: z.number().int().nonnegative().optional(),
|
|
56
|
+
});
|
|
57
|
+
function combineStreams(stdout, stderr) {
|
|
58
|
+
if (stdout === '')
|
|
59
|
+
return stderr;
|
|
60
|
+
if (stderr === '')
|
|
61
|
+
return stdout;
|
|
62
|
+
return `${stdout}\n${stderr}`;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Executes a `ValidationScript`, enforces surrogate-safe truncation within `maxOutputChars` and
|
|
66
|
+
* AD-012's `OUTPUT_MAX_BYTES`, and writes the full output log as an artifact when truncated.
|
|
67
|
+
*/
|
|
68
|
+
export async function runValidationScript(ctx, script, opts) {
|
|
69
|
+
const maxChars = opts.maxOutputChars ?? DEFAULT_MAX_OUTPUT_CHARS;
|
|
70
|
+
let passed;
|
|
71
|
+
let code;
|
|
72
|
+
let rawStdout;
|
|
73
|
+
let rawStderr;
|
|
74
|
+
let rawCombined;
|
|
75
|
+
let durationMs;
|
|
76
|
+
if (typeof script === 'object' && !Array.isArray(script) && 'run' in script) {
|
|
77
|
+
const started = Date.now();
|
|
78
|
+
const res = await script.run(ctx);
|
|
79
|
+
passed = res.passed;
|
|
80
|
+
code = res.code;
|
|
81
|
+
rawStdout = res.stdout ?? (res.output !== undefined && res.stderr === undefined ? res.output : '');
|
|
82
|
+
rawStderr = res.stderr ?? '';
|
|
83
|
+
rawCombined = res.output ?? combineStreams(rawStdout, rawStderr);
|
|
84
|
+
durationMs = Math.max(0, Date.now() - started);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
const resolved = typeof script === 'function' ? await script(ctx) : script;
|
|
88
|
+
const spec = Array.isArray(resolved)
|
|
89
|
+
? { cmd: resolved[0], args: resolved.slice(1) }
|
|
90
|
+
: resolved;
|
|
91
|
+
const execOpts = {
|
|
92
|
+
...(spec.cwd !== undefined ? { cwd: spec.cwd } : {}),
|
|
93
|
+
...(spec.env !== undefined ? { env: spec.env } : {}),
|
|
94
|
+
...(spec.timeoutMs !== undefined ? { timeoutMs: spec.timeoutMs } : {}),
|
|
95
|
+
};
|
|
96
|
+
const r = await ctx.exec(spec.cmd, [...(spec.args ?? [])], execOpts);
|
|
97
|
+
passed = r.code === 0 && !r.timedOut && !r.cancelled;
|
|
98
|
+
code = r.code;
|
|
99
|
+
rawStdout = r.stdout;
|
|
100
|
+
rawStderr = r.stderr;
|
|
101
|
+
rawCombined = combineStreams(rawStdout, rawStderr);
|
|
102
|
+
durationMs = Math.max(0, Math.round(r.durationMs));
|
|
103
|
+
}
|
|
104
|
+
let outSlice = sliceSurrogateSafe(rawStdout, maxChars);
|
|
105
|
+
let errSlice = sliceSurrogateSafe(rawStderr, maxChars);
|
|
106
|
+
const combinedFromSlices = combineStreams(outSlice.text, errSlice.text);
|
|
107
|
+
let combSlice = rawCombined === combineStreams(rawStdout, rawStderr)
|
|
108
|
+
? { text: combinedFromSlices, truncated: outSlice.truncated || errSlice.truncated }
|
|
109
|
+
: sliceSurrogateSafe(rawCombined, maxChars * 2);
|
|
110
|
+
let truncated = outSlice.truncated || errSlice.truncated || combSlice.truncated;
|
|
111
|
+
const build = () => ({
|
|
112
|
+
passed,
|
|
113
|
+
...(code !== undefined ? { code } : {}),
|
|
114
|
+
stdout: outSlice.text,
|
|
115
|
+
stderr: errSlice.text,
|
|
116
|
+
output: combSlice.text,
|
|
117
|
+
truncated,
|
|
118
|
+
...(durationMs !== undefined ? { durationMs } : {}),
|
|
119
|
+
});
|
|
120
|
+
// Guarantee serialized JSON stays within AD-012's 65,536-byte cap even with multi-byte UTF-8.
|
|
121
|
+
let payload = build();
|
|
122
|
+
let cap = maxChars;
|
|
123
|
+
while (outputBytes(payload) > OUTPUT_MAX_BYTES && cap > 0) {
|
|
124
|
+
cap = Math.floor(cap / 2);
|
|
125
|
+
truncated = true;
|
|
126
|
+
outSlice = sliceSurrogateSafe(rawStdout, cap);
|
|
127
|
+
errSlice = sliceSurrogateSafe(rawStderr, cap);
|
|
128
|
+
combSlice = sliceSurrogateSafe(rawCombined, cap);
|
|
129
|
+
payload = build();
|
|
130
|
+
}
|
|
131
|
+
if (truncated) {
|
|
132
|
+
await ctx.artifacts.put(`${opts.artifactPrefix}-visit-${ctx.visit}.log`, rawCombined, {
|
|
133
|
+
mediaType: 'text/plain',
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return payload;
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/fragments/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGlE,mEAAmE;AACnE,MAAM,CAAC,MAAM,OAAO,GAAG,mBAAmB,CAAC;AAE3C,sGAAsG;AACtG,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC;AAE/C,+EAA+E;AAC/E,MAAM,UAAU,UAAU,CAAC,EAAU,EAAE,OAAe;IACpD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,kBAAkB,EAAE,kDAAkD,CAAC,CAAC;IACpG,CAAC;AACH,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,iBAAiB,CAAC,KAAa,EAAE,KAAa;IAC5D,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAC1C,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