@agimon-ai/po-workflow 0.0.0-alpha.197 → 0.0.0-alpha.198

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.
@@ -11533,14 +11533,14 @@ function defaultCatalogDeps(runtime) {
11533
11533
  const parser = new require_workflowHost.WorkflowParserService(runtime);
11534
11534
  return {
11535
11535
  list: (directory) => readWorkflowCatalog(directory, runtime),
11536
- summarize: async (workflowPath) => {
11537
- const detail = await summarizeWorkflow(workflowPath, (target) => parser.parseWorkflowFile(target));
11536
+ summarize: async (workflowPath, definition) => {
11537
+ const detail = await summarizeWorkflow(workflowPath, async (target) => definition ? structuredClone(definition) : parser.parseWorkflowFile(target));
11538
11538
  if (detail.error !== void 0) return detail;
11539
11539
  const errors = (await diagnoseWorkflow(workflowPath, {
11540
11540
  runtime,
11541
11541
  runConfigKeys: PO_RUN_CONFIG_KEYS,
11542
11542
  renamedRunConfigKeys: RENAMED_RUN_CONFIG_KEYS
11543
- })).diagnostics.filter((diagnostic) => diagnostic.level === "error");
11543
+ }, definition)).diagnostics.filter((diagnostic) => diagnostic.level === "error");
11544
11544
  if (errors.length === 0) return detail;
11545
11545
  return {
11546
11546
  ...detail,
@@ -15964,9 +15964,10 @@ var RunWorkflowService = class {
15964
15964
  * Execute the workflow after signal handlers are installed.
15965
15965
  */
15966
15966
  async prepareAllocation(input) {
15967
- const saved = input.recovery?.definition;
15967
+ const saved = input.recovery?.definition ?? input.definition;
15968
+ const pinned = input.recovery === void 0 && input.definition !== void 0;
15968
15969
  const path = (0, node_path.resolve)(this.runtime.cwd, input.workflowPath);
15969
- return this.admitAllocationForWorkflow(input, saved && (input.helpActive?.() !== true || !await this.pathExists(path)) ? structuredClone(saved) : await this.parser.parseWorkflowFile(path));
15970
+ return this.admitAllocationForWorkflow(input, saved && (pinned || input.helpActive?.() !== true || !await this.pathExists(path)) ? structuredClone(saved) : await this.parser.parseWorkflowFile(path));
15970
15971
  }
15971
15972
  async admitAllocationForWorkflow(input, workflow) {
15972
15973
  const expected = input.allocation ?? input.admission?.allocation;
@@ -15997,9 +15998,10 @@ var RunWorkflowService = class {
15997
15998
  }
15998
15999
  async executeWorkflow(input, dryRun, continueOnError) {
15999
16000
  const workflowPath = (0, node_path.resolve)(this.runtime.cwd, input.workflowPath);
16000
- let saved = input.recovery?.definition;
16001
+ let saved = input.recovery?.definition ?? input.definition;
16002
+ const pinned = input.recovery === void 0 && input.definition !== void 0;
16001
16003
  const readDefinition = async (path) => {
16002
- if (saved && (input.helpActive?.() !== true || !await this.pathExists(path))) return structuredClone(saved);
16004
+ if (saved && (pinned || input.helpActive?.() !== true || !await this.pathExists(path))) return structuredClone(saved);
16003
16005
  const parsed = await this.parser.parseWorkflowFile(path);
16004
16006
  if (saved) saved = structuredClone(parsed);
16005
16007
  return parsed;
@@ -19440,6 +19442,16 @@ function createWorkflowServerRuntime(host, serverHost, runtime, resolveSecrets,
19440
19442
  if (source === void 0) throw new Error(WORKFLOW_SOURCE_UNAVAILABLE);
19441
19443
  return source;
19442
19444
  };
19445
+ /**
19446
+ * The launching session's own copy of a definition. A session in the workspace's checkout reads the registered
19447
+ * source; a session in another checkout of the repository (a worktree) reads its own checkout instead.
19448
+ */
19449
+ const definitionPath = (definition) => {
19450
+ const source = sourceNamed(definition.source);
19451
+ const fromSession = (0, node_path.relative)(host.context.repoRoot, source.directory);
19452
+ const elsewhere = source.source === REPO_SOURCE && (fromSession.startsWith("..") || (0, node_path.isAbsolute)(fromSession));
19453
+ return (0, node_path.resolve)(elsewhere ? host.context.cwd : source.directory, definition.key);
19454
+ };
19443
19455
  const workflowRuns = {
19444
19456
  async readConfig(id) {
19445
19457
  if (disposed) return void 0;
@@ -19847,10 +19859,10 @@ function createWorkflowServerRuntime(host, serverHost, runtime, resolveSecrets,
19847
19859
  const stored = require_contract.librarySourceOf(workflowPath, runtime.library);
19848
19860
  const inside = stored ? require_contract.workflowDefinitionRef(workflowPath, where.repoRoot, runtime.library).key : (0, node_path.relative)(where.repoRoot, workflowPath);
19849
19861
  if (!stored && (inside.startsWith("..") || (0, node_path.isAbsolute)(inside))) return `Workflow ${input.workflowPath} is outside this session's repository, so it cannot be launched here.`;
19850
- const detail = await catalogDeps.summarize(workflowPath);
19862
+ const detail = await catalogDeps.summarize(workflowPath, input.definition);
19851
19863
  if (detail.error !== void 0) return needsFixingNotice(inside, detail.error);
19852
19864
  if (runtime.workflowHost.platform === "edge") {
19853
- const refusal = cloudWorkflowLaunchRefusal(await feature.parser.parseWorkflowFile(workflowPath), input);
19865
+ const refusal = cloudWorkflowLaunchRefusal(input.definition ?? await feature.parser.parseWorkflowFile(workflowPath), input);
19854
19866
  if (refusal !== void 0) return refusal;
19855
19867
  }
19856
19868
  const requirements = preparing ? {
@@ -20389,13 +20401,10 @@ function createWorkflowServerRuntime(host, serverHost, runtime, resolveSecrets,
20389
20401
  const admissionInput = async (request) => {
20390
20402
  if (request.kind === "launch") {
20391
20403
  if (!typebox_value.Value.Check(_agimon_ai_po_core_workflow.PoWorkflowDefinitionRefSchema, request.definition)) throw new Error(INVALID_WORKFLOW_REFERENCE);
20392
- const source = sourceNamed(request.definition.source);
20393
- const { policy: _policy, targetSessionId, allocation: _allocation, ...overrides } = request.overrides ?? {};
20394
- const directory = targetSessionId === void 0 || source.source !== REPO_SOURCE ? source.directory : publicServices?.owner(targetSessionId)?.location.repoRoot;
20395
- if (directory === void 0) throw new Error("Workflow target session is unavailable.");
20404
+ const { policy: _policy, targetSessionId: _target, allocation: _allocation, ...overrides } = request.overrides ?? {};
20396
20405
  return feature.runTool.getInputSchema().parse({
20397
20406
  ...overrides,
20398
- workflowPath: (0, node_path.resolve)(directory, request.definition.key)
20407
+ workflowPath: definitionPath(request.definition)
20399
20408
  });
20400
20409
  }
20401
20410
  if (request.kind !== "recover") throw new Error("Invalid workflow admission request.");
@@ -20418,7 +20427,7 @@ function createWorkflowServerRuntime(host, serverHost, runtime, resolveSecrets,
20418
20427
  warnings: [],
20419
20428
  deferred: []
20420
20429
  };
20421
- const where = owner?.location ?? host.context;
20430
+ const where = request.kind === "launch" && request.definition?.source === REPO_SOURCE ? host.context : owner?.location ?? host.context;
20422
20431
  let input;
20423
20432
  try {
20424
20433
  input = await admissionInput(request);
@@ -20474,10 +20483,9 @@ function createWorkflowServerRuntime(host, serverHost, runtime, resolveSecrets,
20474
20483
  async requirements(definition, options = {}) {
20475
20484
  assertAvailable();
20476
20485
  if (!typebox_value.Value.Check(_agimon_ai_po_core_workflow.PoWorkflowDefinitionRefSchema, definition)) throw new Error(INVALID_WORKFLOW_REFERENCE);
20477
- const source = sourceNamed(definition.source);
20478
20486
  return operations.requirements({
20479
20487
  ...options,
20480
- workflowPath: (0, node_path.resolve)(source.directory, definition.key)
20488
+ workflowPath: definitionPath(definition)
20481
20489
  }, host.context.cwd, void 0, definition);
20482
20490
  },
20483
20491
  registerPolicy(coordinator, callback, options) {
@@ -20521,7 +20529,12 @@ function createWorkflowServerRuntime(host, serverHost, runtime, resolveSecrets,
20521
20529
  const owner = publicServices?.owner(ownerId);
20522
20530
  if (!owner) throw new Error("Workflow launch owner is unavailable; admission remains pending.");
20523
20531
  watchOwner(ownerId);
20524
- await owner.launch(input, {
20532
+ const pinned = request.kind === "launch" && request.definition.source === REPO_SOURCE ? {
20533
+ ...input,
20534
+ workflowPath: (0, node_path.resolve)(owner.location.repoRoot, request.definition.key),
20535
+ definition: await feature.parser.parseWorkflowFile(input.workflowPath)
20536
+ } : input;
20537
+ await owner.launch(pinned, {
20525
20538
  ...admission,
20526
20539
  ownerSessionId: ownerId
20527
20540
  });
@@ -20697,10 +20710,9 @@ function createWorkflowServerRuntime(host, serverHost, runtime, resolveSecrets,
20697
20710
  scope.provide(_agimon_ai_po_core_workflow.PO_WORKFLOW_LAUNCH_SERVICE, { async launch(definition, overrides = {}) {
20698
20711
  await waitForReadiness();
20699
20712
  if (!typebox_value.Value.Check(_agimon_ai_po_core_workflow.PoWorkflowDefinitionRefSchema, definition)) throw new Error(INVALID_WORKFLOW_REFERENCE);
20700
- const source = sourceNamed(definition.source);
20701
20713
  const result = await launch({
20702
20714
  ...overrides,
20703
- workflowPath: (0, node_path.resolve)(source.directory, definition.key),
20715
+ workflowPath: definitionPath(definition),
20704
20716
  env: {
20705
20717
  ...overrides.env,
20706
20718
  [PUBLIC_LAUNCH_ENV]: PUBLIC_LAUNCH_ENABLED