@agentxm/workspace-operations 0.28.6 → 0.28.7

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.
@@ -16,7 +16,7 @@ export { AtomicityClassSchema, OperationOutcomeSchema, OperationPhaseSchema, Uni
16
16
  export type { AtomicityClass, MakeOperationResolutionArgs, OperationAtomicity, OperationBlock, OperationFootprintEntry, OperationInterruption, OperationOutcome, OperationPhase, OperationRecovery, OperationResolution, ResolvedUnit, UnitDisposition, UnitState, UnitStateCounts, } from "./plan/operation-resolution.js";
17
17
  export { OperationJournal, appendResolvedUnit, appendStartedUnit, recordJournalPhase, getOperationJournal, makeOperationJournal, recordOperationJournal, updateOperationJournal, type OperationJournalService, type OperationJournalState, } from "./plan/operation-journal.js";
18
18
  export { applyPlan, type ApplyPlanOptions, type OperationHandler } from "./plan/apply-plan.js";
19
- export { CurrentOperationUnit, OperationEventSchema, OperationLifecycle, OperationModeSchema, ProgressUnitSchema, SettledOutcomeSchema, awaitDrained, lifecycleEvents, makeOperationLifecycle, makeThrottledUnitProgress, observeUnit, publishOperationEvent, publishPhaseStarted, publishUnitProgress, publishWaitEnded, publishWaiting, settleOperation, subscribeLossless, type ObservedUnit, type OperationEvent, type OperationEventEncoded, type OperationEventInput, type OperationLifecycleService, type OperationMode, type ProgressUnit, type SettledOutcome, } from "./plan/operation-events.js";
19
+ export { CurrentOperationUnit, OperationEventSchema, OperationLifecycle, OperationModeSchema, ProgressUnitSchema, SettledOutcomeSchema, awaitDrained, lifecycleEvents, makeOperationLifecycle, makeThrottledUnitProgress, observeChildUnit, observeUnit, publishOperationEvent, publishPhaseStarted, publishUnitProgress, publishWaitEnded, publishWaiting, settleOperation, subscribeLossless, type ObservedUnit, type OperationEvent, type OperationEventEncoded, type OperationEventInput, type OperationLifecycleService, type OperationMode, type ProgressUnit, type SettledOutcome, } from "./plan/operation-events.js";
20
20
  export { ApprovalRecoveryMissing, CandidateFingerprintFailed, OPERATION_ERROR_CATEGORIES, OperationErrorCategorySchema, PlanInteractionFailed, STALE_CANDIDATE_DETAIL, StaleExecutionCandidate, StepFailure, type OperationErrorCategory, } from "./plan/errors.js";
21
21
  export { previewOrApplyPlan } from "./plan/resolve-plan.js";
22
22
  export { ResolvePlanInteraction, type ApplyConfirmation, type ResolvePlanInteractionService, } from "./plan/resolve-plan-interaction.js";
package/dist/src/index.js CHANGED
@@ -20,7 +20,7 @@ export { OperationJournal, appendResolvedUnit, appendStartedUnit, recordJournalP
20
20
  // Apply plan + operation handler registry
21
21
  export { applyPlan } from "./plan/apply-plan.js";
22
22
  // Operation lifecycle events — the live contract every observer subscribes to.
23
- export { CurrentOperationUnit, OperationEventSchema, OperationLifecycle, OperationModeSchema, ProgressUnitSchema, SettledOutcomeSchema, awaitDrained, lifecycleEvents, makeOperationLifecycle, makeThrottledUnitProgress, observeUnit, publishOperationEvent, publishPhaseStarted, publishUnitProgress, publishWaitEnded, publishWaiting, settleOperation, subscribeLossless, } from "./plan/operation-events.js";
23
+ export { CurrentOperationUnit, OperationEventSchema, OperationLifecycle, OperationModeSchema, ProgressUnitSchema, SettledOutcomeSchema, awaitDrained, lifecycleEvents, makeOperationLifecycle, makeThrottledUnitProgress, observeChildUnit, observeUnit, publishOperationEvent, publishPhaseStarted, publishUnitProgress, publishWaitEnded, publishWaiting, settleOperation, subscribeLossless, } from "./plan/operation-events.js";
24
24
  // Serialized error vocabulary and the plan-family tagged errors.
25
25
  export { ApprovalRecoveryMissing, CandidateFingerprintFailed, OPERATION_ERROR_CATEGORIES, OperationErrorCategorySchema, PlanInteractionFailed, STALE_CANDIDATE_DETAIL, StaleExecutionCandidate, StepFailure, } from "./plan/errors.js";
26
26
  // Interactive preview/apply orchestration over the workspace read model.
@@ -233,21 +233,37 @@ export declare const makeThrottledUnitProgress: (options: {
233
233
  readonly unit: ProgressUnit;
234
234
  readonly intervalMs?: number | undefined;
235
235
  }) => Effect.Effect<(done: number, total?: number | undefined) => Effect.Effect<void>>;
236
- export interface ObservedUnit {
236
+ export interface ObservedUnit<A = never> {
237
237
  readonly id: string;
238
238
  readonly label: string;
239
239
  /** Planned position; assigned by the service when the caller has none. */
240
240
  readonly index?: number | undefined;
241
241
  readonly total?: number | undefined;
242
242
  readonly parentUnitId?: string | undefined;
243
+ /**
244
+ * The label the unit settles with, read from the value it produced. A unit
245
+ * that exists to resolve a fact reports that fact here, so its settlement
246
+ * names the answer instead of repeating the question. Only a successful
247
+ * exit has a value to read; a failed or interrupted unit settles with the
248
+ * label it started with.
249
+ */
250
+ readonly resolvedLabel?: (value: A) => string;
243
251
  }
244
252
  /**
245
253
  * Run one unit of work under the lifecycle: `UnitStarted` before, then
246
254
  * `UnitResolved` with the state the exit proves (`committed`, `failed`, or
247
- * `interrupted`). The unit identity is provided to the run so nested producers
248
- * can publish progress. No-op wrapper without a broadcast.
255
+ * `interrupted`) and the label the unit settles with. The unit identity is
256
+ * provided to the run so nested producers can publish progress. No-op wrapper
257
+ * without a broadcast.
258
+ */
259
+ export declare const observeUnit: <A, E, R>(unit: ObservedUnit<A>, effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
260
+ /**
261
+ * Run a unit as a child of the unit currently in progress, so work a step
262
+ * delegates nests under the step that delegated it. Identical to
263
+ * `observeUnit` when no unit is in progress, and when the caller states its
264
+ * own parent that statement wins.
249
265
  */
250
- export declare const observeUnit: <A, E, R>(unit: ObservedUnit, effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
266
+ export declare const observeChildUnit: <A, E, R>(unit: ObservedUnit<A>, effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
251
267
  /** Publish the terminal event once. No-op without a broadcast. */
252
268
  export declare const settleOperation: (outcome: SettledOutcome) => Effect.Effect<void>;
253
269
  /**
@@ -234,8 +234,9 @@ const unitStateForExit = (exit) => Exit.isSuccess(exit)
234
234
  /**
235
235
  * Run one unit of work under the lifecycle: `UnitStarted` before, then
236
236
  * `UnitResolved` with the state the exit proves (`committed`, `failed`, or
237
- * `interrupted`). The unit identity is provided to the run so nested producers
238
- * can publish progress. No-op wrapper without a broadcast.
237
+ * `interrupted`) and the label the unit settles with. The unit identity is
238
+ * provided to the run so nested producers can publish progress. No-op wrapper
239
+ * without a broadcast.
239
240
  */
240
241
  export const observeUnit = (unit, effect) => Effect.flatMap(Effect.serviceOption(OperationLifecycle), (service) => {
241
242
  if (Option.isNone(service))
@@ -259,13 +260,24 @@ export const observeUnit = (unit, effect) => Effect.flatMap(Effect.serviceOption
259
260
  seq,
260
261
  atMs,
261
262
  unitId: unit.id,
262
- label: unit.label,
263
+ label: Exit.isSuccess(exit) && unit.resolvedLabel !== undefined
264
+ ? unit.resolvedLabel(exit.value)
265
+ : unit.label,
263
266
  state: unitStateForExit(exit),
264
267
  index,
265
268
  ...total,
266
269
  }))));
267
270
  });
268
271
  });
272
+ /**
273
+ * Run a unit as a child of the unit currently in progress, so work a step
274
+ * delegates nests under the step that delegated it. Identical to
275
+ * `observeUnit` when no unit is in progress, and when the caller states its
276
+ * own parent that statement wins.
277
+ */
278
+ export const observeChildUnit = (unit, effect) => Effect.flatMap(Effect.serviceOption(CurrentOperationUnit), (parent) => observeUnit(unit.parentUnitId !== undefined || Option.isNone(parent)
279
+ ? unit
280
+ : { ...unit, parentUnitId: parent.value.unitId }, effect));
269
281
  /** Publish the terminal event once. No-op without a broadcast. */
270
282
  export const settleOperation = (outcome) => withLifecycle((service) => service.settle(outcome), () => Effect.void);
271
283
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentxm/workspace-operations",
3
- "version": "0.28.6",
3
+ "version": "0.28.7",
4
4
  "description": "AXM workspace operations kernel: plans, execution candidates, operation resolutions, and workspace transactions for the axm CLI. Unstable and unsupported — use the axm.sh CLI.",
5
5
  "type": "module",
6
6
  "license": "FSL-1.1-MIT",
@@ -48,9 +48,9 @@
48
48
  "dependencies": {
49
49
  "effect": "4.0.0-rc.112",
50
50
  "proper-lockfile": "^4.1.2",
51
- "@agentxm/extension-model": "^0.28.6",
52
- "@agentxm/workspace-state": "^0.28.6",
53
- "@agentxm/registry-protocol": "^0.28.6"
51
+ "@agentxm/registry-protocol": "^0.28.7",
52
+ "@agentxm/workspace-state": "^0.28.7",
53
+ "@agentxm/extension-model": "^0.28.7"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@effect/platform-node": "4.0.0-rc.112",