@oisincoveney/pipeline 1.27.9 → 1.27.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/dist/hooks.d.ts CHANGED
@@ -13,8 +13,8 @@ declare const hookResultSchema: z.ZodObject<{
13
13
  taskContext: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
14
14
  }, z.core.$strict>>;
15
15
  status: z.ZodEnum<{
16
- fail: "fail";
17
16
  pass: "pass";
17
+ fail: "fail";
18
18
  skip: "skip";
19
19
  }>;
20
20
  summary: z.ZodOptional<z.ZodString>;
@@ -1,10 +1,14 @@
1
- import { mkdirSync } from "node:fs";
1
+ import { chmodSync, copyFileSync, existsSync, mkdirSync } from "node:fs";
2
2
  import { dirname, resolve } from "node:path";
3
+ import { tmpdir } from "node:os";
3
4
  import { execFile } from "node:child_process";
4
5
  import { promisify } from "node:util";
5
6
  //#region src/run-state/git-refs.ts
6
7
  const DEFAULT_WORKSPACE_PATH = "/workspace";
8
+ const DEFAULT_GIT_CREDENTIAL_STORE = "/root/.git-credentials";
9
+ const WRITABLE_GIT_CREDENTIAL_STORE = resolve(tmpdir(), "pipeline-git-credentials");
7
10
  const execGit = promisify(execFile);
11
+ let preparedCredentialStore;
8
12
  function runnerGitRefs(payload, nodeId) {
9
13
  const prefix = `refs/heads/pipeline/runs/${payload.run.id}/${payload.workflow.id}`;
10
14
  return {
@@ -97,12 +101,50 @@ async function configureGitCommitter(worktreePath, committer) {
97
101
  committer.email
98
102
  ]);
99
103
  }
104
+ function runnerGitCommandArgs(args) {
105
+ return [...gitCredentialConfigArgs(), ...args];
106
+ }
100
107
  async function runGit(cwd, args) {
101
- const { stdout } = await execGit("git", args, {
108
+ const { stdout } = await execGit("git", runnerGitCommandArgs(args), {
102
109
  cwd,
103
- encoding: "utf8"
110
+ encoding: "utf8",
111
+ env: {
112
+ ...process.env,
113
+ GIT_TERMINAL_PROMPT: "0"
114
+ }
104
115
  });
105
116
  return stdout;
106
117
  }
118
+ function gitCredentialConfigArgs() {
119
+ const writablePath = prepareWritableGitCredentialStore();
120
+ if (!writablePath) return [];
121
+ return [
122
+ "-c",
123
+ "credential.helper=",
124
+ "-c",
125
+ `credential.helper=store --file=${writablePath}`
126
+ ];
127
+ }
128
+ function prepareWritableGitCredentialStore() {
129
+ const sourcePath = availableGitCredentialStore();
130
+ if (!sourcePath) return;
131
+ const writablePath = writableGitCredentialStore();
132
+ copyGitCredentialStore(sourcePath, writablePath);
133
+ return writablePath;
134
+ }
135
+ function availableGitCredentialStore() {
136
+ const sourcePath = process.env.PIPELINE_GIT_CREDENTIAL_STORE ?? DEFAULT_GIT_CREDENTIAL_STORE;
137
+ return existsSync(sourcePath) ? sourcePath : void 0;
138
+ }
139
+ function writableGitCredentialStore() {
140
+ return process.env.PIPELINE_WRITABLE_GIT_CREDENTIAL_STORE ?? WRITABLE_GIT_CREDENTIAL_STORE;
141
+ }
142
+ function copyGitCredentialStore(sourcePath, writablePath) {
143
+ if (preparedCredentialStore === writablePath) return;
144
+ mkdirSync(dirname(writablePath), { recursive: true });
145
+ copyFileSync(sourcePath, writablePath);
146
+ chmodSync(writablePath, 384);
147
+ preparedCredentialStore = writablePath;
148
+ }
107
149
  //#endregion
108
150
  export { commitAndPushNodeRef, mergeDependencyRefs, prepareRunnerGitWorkspace, promoteFinalRef };
@@ -485,35 +485,71 @@ function executeBaselineWorkflow() {
485
485
  } };
486
486
  }
487
487
  async function planScheduleArtifact(baseline, plannerProfile, options, planningContext) {
488
- if (!plannerProfile) throw new ScheduleArtifactError(`schedule '${options.entrypointId}' requires planner_profile`);
489
- const source = await runSchedulePlanner(plannerProfile, plannerPrompt(options.entrypointId, options.task, baseline, options.config, planningContext), options);
490
- if (!source) throw new ScheduleArtifactError("schedule planner returned empty output");
488
+ const requiredPlannerProfile = requireSchedulePlannerProfile(plannerProfile, options.entrypointId);
489
+ const source = requireSchedulePlannerSource(await runSchedulePlanner(requiredPlannerProfile, plannerPrompt(options.entrypointId, options.task, baseline, options.config, planningContext), options));
491
490
  const initial = acceptedGeneratedSchedule(parseGeneratedSchedule(source, "planner output"));
492
491
  if (initial.ok) return initial.artifact;
493
- let latestFailure = initial.error;
494
- let latestSource = source;
492
+ return scheduleArtifactAfterRepair(await repairInvalidScheduleArtifact({
493
+ baseline,
494
+ initialFailure: initial.error,
495
+ initialSource: source,
496
+ options,
497
+ plannerProfile: requiredPlannerProfile
498
+ }), baseline, initial.error, source);
499
+ }
500
+ function requireSchedulePlannerProfile(plannerProfile, entrypointId) {
501
+ if (plannerProfile) return plannerProfile;
502
+ throw new ScheduleArtifactError(`schedule '${entrypointId}' requires planner_profile`);
503
+ }
504
+ function requireSchedulePlannerSource(source) {
505
+ if (source) return source;
506
+ throw new ScheduleArtifactError("schedule planner returned empty output");
507
+ }
508
+ function scheduleArtifactAfterRepair(repair, baseline, initialFailure, initialSource) {
509
+ if (repair.kind === "accepted") return repair.artifact;
510
+ if (repair.kind === "fallback") return baseline;
511
+ throw new ScheduleArtifactError([
512
+ "Schedule planner produced invalid output after repair.",
513
+ initialFailure.message,
514
+ "Original planner output:",
515
+ initialSource,
516
+ repair.latestFailure.message,
517
+ "Planner repair output:",
518
+ repair.latestSource
519
+ ].join("\n"));
520
+ }
521
+ async function repairInvalidScheduleArtifact(input) {
522
+ let latestFailure = input.initialFailure;
523
+ let latestSource = input.initialSource;
495
524
  for (let attempt = 1; attempt <= SCHEDULE_PLANNER_REPAIR_ATTEMPTS; attempt += 1) {
496
- const repairedSource = await runSchedulePlanner(plannerProfile, plannerRepairPrompt({
497
- attempt,
498
- baseline,
499
- error: latestFailure,
500
- source: latestSource
501
- }), options, "schedule-plan-repair");
502
- if (!repairedSource) throw new ScheduleArtifactError(`schedule planner repair returned empty output after invalid schedule\n${latestFailure.message}\nPlanner output:\n${latestSource}`);
525
+ const repairedSource = await runScheduleRepair(input, latestFailure, latestSource, attempt);
526
+ if (!repairedSource) return { kind: "fallback" };
503
527
  const repaired = acceptedGeneratedSchedule(parseGeneratedSchedule(repairedSource, "planner repair output"));
504
- if (repaired.ok) return repaired.artifact;
528
+ if (repaired.ok) return {
529
+ artifact: repaired.artifact,
530
+ kind: "accepted"
531
+ };
505
532
  latestFailure = repaired.error;
506
533
  latestSource = repairedSource;
507
534
  }
508
- throw new ScheduleArtifactError([
509
- "Schedule planner produced invalid output after repair.",
510
- initial.error.message,
511
- "Original planner output:",
512
- source,
513
- latestFailure.message,
514
- "Planner repair output:",
535
+ return {
536
+ kind: "invalid",
537
+ latestFailure,
515
538
  latestSource
516
- ].join("\n"));
539
+ };
540
+ }
541
+ async function runScheduleRepair(input, latestFailure, latestSource, attempt) {
542
+ try {
543
+ return await runSchedulePlanner(input.plannerProfile, plannerRepairPrompt({
544
+ attempt,
545
+ baseline: input.baseline,
546
+ error: latestFailure,
547
+ source: latestSource
548
+ }), input.options, "schedule-plan-repair");
549
+ } catch (err) {
550
+ if (err instanceof ScheduleArtifactError) return;
551
+ throw err;
552
+ }
517
553
  }
518
554
  function parseGeneratedSchedule(source, sourcePath) {
519
555
  const parseableSource = normalizeGeneratedScheduleSource(source);
@@ -644,18 +680,43 @@ function plannerRepairPrompt(inputs) {
644
680
  function allowedProfilePromptLine(config, id) {
645
681
  const profile = config.profiles[id];
646
682
  const runner = config.runners[profile.runner];
647
- const roles = effectiveSchedulingRoles(config, id);
648
- const model = profile.model ?? runner?.model;
649
- return `- ${id} (${[
650
- `runner: ${profile.runner}`,
651
- model ? `model: ${model}` : "",
652
- roles.length > 0 ? `scheduling_roles: ${roles.join(", ")}` : "",
653
- profile.description ? `description: ${profile.description}` : "",
654
- profile.tools?.length ? `tools: ${profile.tools.join(", ")}` : "",
655
- profile.filesystem?.mode ? `filesystem: ${profile.filesystem.mode}` : "",
656
- profile.network?.mode ? `network: ${profile.network.mode}` : "",
657
- `output: ${profile.output?.format ?? "text"}`
658
- ].filter(Boolean).join("; ")})`;
683
+ return `- ${id} (${profilePromptFields(config, id, profile, runner).join("; ")})`;
684
+ }
685
+ function profilePromptFields(config, id, profile, runner) {
686
+ return definedProfilePromptFields([
687
+ requiredProfilePromptField("runner", profile.runner),
688
+ optionalProfilePromptField("model", profileModel(profile, runner)),
689
+ optionalProfilePromptField("scheduling_roles", effectiveSchedulingRoles(config, id).join(", ")),
690
+ optionalProfilePromptField("description", profile.description),
691
+ optionalProfilePromptField("tools", profileTools(profile)),
692
+ optionalProfilePromptField("filesystem", profileFilesystemMode(profile)),
693
+ optionalProfilePromptField("network", profileNetworkMode(profile)),
694
+ requiredProfilePromptField("output", profileOutputFormat(profile))
695
+ ]);
696
+ }
697
+ function profileModel(profile, runner) {
698
+ return profile.model ?? runner?.model;
699
+ }
700
+ function profileTools(profile) {
701
+ return profile.tools?.join(", ");
702
+ }
703
+ function profileFilesystemMode(profile) {
704
+ return profile.filesystem?.mode;
705
+ }
706
+ function profileNetworkMode(profile) {
707
+ return profile.network?.mode;
708
+ }
709
+ function profileOutputFormat(profile) {
710
+ return profile.output?.format ?? "text";
711
+ }
712
+ function requiredProfilePromptField(label, value) {
713
+ return `${label}: ${value}`;
714
+ }
715
+ function optionalProfilePromptField(label, value) {
716
+ return value ? requiredProfilePromptField(label, value) : void 0;
717
+ }
718
+ function definedProfilePromptFields(fields) {
719
+ return fields.filter((field) => Boolean(field));
659
720
  }
660
721
  function schedulerCatalogPrompt(config, entrypointId) {
661
722
  const catalog = resolveSchedulerCatalog(config, entrypointId);
@@ -837,16 +898,7 @@ function nodesByAssignedWorkUnit(nodes) {
837
898
  return grouped;
838
899
  }
839
900
  function hasPathToNode(sourceId, targetId, dependentsByNeed) {
840
- const queue = [...dependentsByNeed.get(sourceId) ?? []];
841
- const seen = /* @__PURE__ */ new Set();
842
- while (queue.length > 0) {
843
- const node = queue.shift();
844
- if (!node || seen.has(node.id)) continue;
845
- if (node.id === targetId) return true;
846
- seen.add(node.id);
847
- queue.push(...dependentsByNeed.get(node.id) ?? []);
848
- }
849
- return false;
901
+ return hasReachableDependent(sourceId, dependentsByNeed, (node) => node.id === targetId);
850
902
  }
851
903
  function unsupportedGeneratedBuiltinIssues(artifact) {
852
904
  const allowed = new Set(SCHEDULE_BUILTINS);
package/package.json CHANGED
@@ -120,7 +120,7 @@
120
120
  "prepack": "bun run build:cli"
121
121
  },
122
122
  "type": "module",
123
- "version": "1.27.9",
123
+ "version": "1.27.11",
124
124
  "description": "Config-driven multi-agent pipeline runner for repository work",
125
125
  "main": "./dist/index.js",
126
126
  "types": "./dist/index.d.ts",