@xandreed/sdk 0.15.1 → 0.16.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 CHANGED
@@ -1,5 +1,5 @@
1
1
  # @xandreed/sdk
2
2
 
3
- Efferent composable agent framework, 0.15.1. Node 24 or Bun.
3
+ Efferent composable agent framework, 0.16.0. Node 24 or Bun.
4
4
 
5
5
  Documentation: https://github.com/xandreeddev/efferent
@@ -3,6 +3,7 @@ import {
3
3
  CurrentTraceContent,
4
4
  DrainActivity,
5
5
  WaitingInput,
6
+ BackgroundWorkers,
6
7
  CapabilitiesLive,
7
8
  DEFAULT_SHUTDOWN_DEADLINE,
8
9
  Capabilities,
@@ -11,6 +12,7 @@ import {
11
12
  harnessDefectsAsFailures,
12
13
  HarnessError,
13
14
  LoopProtection,
15
+ notifyCommittedTurn,
14
16
  isBudgetTokens,
15
17
  normalizeUserMessage,
16
18
  PluginInstanceId,
@@ -123,16 +125,17 @@ const failure = (code, message) => new HarnessError({ code, message }), missing
123
125
  if (!own)
124
126
  return yield* exit;
125
127
  if (Exit.isFailure(exit)) {
126
- yield* writer.end(turnEndingOf(exit)).pipe(Effect.catchTag("TurnClosed", (closed) => Effect.logDebug(`the failed turn's end was not stored: the turn was ${closed.reason}`)), Effect.catch((error) => Effect.logWarning(`the failed turn's end was not stored: ${reasonOf(Cause.fail(error))}`)));
128
+ yield* writer.end(turnEndingOf(exit)).pipe(Effect.tap(() => notifyCommittedTurn({ session: writer.admitted.session, runId: writer.admitted.runId, turn: writer.admitted.turn }).pipe(Effect.provide(context))), Effect.catchTag("TurnClosed", (closed) => Effect.logDebug(`the failed turn's end was not stored: the turn was ${closed.reason}`)), Effect.catch((error) => Effect.logWarning(`the failed turn's end was not stored: ${reasonOf(Cause.fail(error))}`)));
127
129
  return yield* Effect.failCause(exit.cause);
128
130
  }
129
131
  const { pending } = yield* writer.end(turnEndingOf(exit));
132
+ yield* notifyCommittedTurn({ session: writer.admitted.session, runId: writer.admitted.runId, turn: writer.admitted.turn }).pipe(Effect.provide(context));
130
133
  return { ...exit.value, pending };
131
134
  }).pipe(Effect.annotateLogs(turnAttributes(writer.admitted)), measureTurn, traceTurn(writer, { spanMeta: config.spanMeta ?? [] }));
132
135
  }))), runtimeProbes = (effect) => effect.pipe(Effect.updateContext((current) => {
133
- const probes = Context.merge(Context.omit(TurnActivity, TaskActivity, TurnShutdown, WaitingInput, DrainActivity)(current), Context.pick(TurnActivity, TaskActivity, TurnShutdown, WaitingInput, DrainActivity)(runtime)), drains = Option.orElse(Context.getOption(runtime, DrainActivity), () => Context.getOption(current, DrainActivity));
136
+ const probes = Context.merge(Context.omit(TurnActivity, TaskActivity, TurnShutdown, WaitingInput, DrainActivity, BackgroundWorkers)(current), Context.pick(TurnActivity, TaskActivity, TurnShutdown, WaitingInput, DrainActivity, BackgroundWorkers)(runtime)), drains = Option.orElse(Context.getOption(runtime, DrainActivity), () => Context.getOption(current, DrainActivity));
134
137
  return Option.match(drains, { onNone: () => probes, onSome: (probe) => Context.add(probes, DrainActivity, probe) });
135
- })), activity = runtimeProbes(processActivity), shutdown = (options) => runtimeProbes(shutdownGracefully(options ?? config.shutdown ?? { deadline: DEFAULT_SHUTDOWN_DEADLINE })).pipe(Effect.tap((report) => report.left.inFlight ? Effect.logWarning(`the agent stopped with ${report.left.openTurns.length + report.left.beginningTurns} turns and ${report.left.runningTasks} tasks still in flight`) : Effect.void)), configured = config.shutdown;
138
+ })), activity = runtimeProbes(processActivity), shutdown = (options) => runtimeProbes(shutdownGracefully(options ?? config.shutdown ?? { deadline: DEFAULT_SHUTDOWN_DEADLINE })).pipe(Effect.tap((report) => report.left.inFlight ? Effect.logWarning(`the agent stopped with ${report.left.openTurns.length + report.left.beginningTurns} turns and ${report.left.runningTasks} tasks${report.left.runningWorkers === void 0 ? "" : ` and ${report.left.runningWorkers} worker jobs`} still in flight`) : Effect.void)), configured = config.shutdown;
136
139
  if (configured !== void 0)
137
140
  yield* Effect.addFinalizer(() => shutdown(configured).pipe(Effect.asVoid));
138
141
  return { fingerprint: graphFingerprint(graph), activity, shutdown, turn };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xandreed/sdk",
3
- "version": "0.15.1",
3
+ "version": "0.16.0",
4
4
  "engines": {
5
5
  "node": ">=24",
6
6
  "bun": ">=1.3.0"
@@ -18,12 +18,13 @@
18
18
  }
19
19
  },
20
20
  "dependencies": {
21
- "@xandreed/runtime": "^0.15.1"
21
+ "@xandreed/runtime": "^0.16.0"
22
22
  },
23
+ "gitHead": "7eb972d259e80a0c88a99d81e84e9440aed884f0",
23
24
  "private": false,
24
25
  "types": "./dist/index.d.ts",
25
26
  "peerDependencies": {
26
- "@xandreed/core": "^0.15.1",
27
+ "@xandreed/core": "^0.16.0",
27
28
  "effect": "^4.0.7"
28
29
  },
29
30
  "files": [