@nylorun/core 0.42.0-beta → 0.44.0-beta

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/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @nylorun/core
2
2
 
3
+ ## 0.44.0-beta
4
+
5
+ ### Minor Changes
6
+
7
+ - 874cc83: Pods on Agent Substrate (preview): suspend before drain, following Substrate's eviction contract. A worker pod that stops (a drain, a GKE node upgrade or scale-down, a WorkerPool rollout, a deleted pod) sends each of its actors SIGTERM and gives them 30 minutes to be suspended; until now the engine exited on that signal, so the actor crashed and went back to its last suspend, losing everything since.
8
+
9
+ - `@nylorun/runtime`: on Substrate (`NYLORUN_SANDBOX_SUBSTRATE=1`, which the sandboxes service's template sets), the engine logs `harness_worker_stopping` on SIGTERM and keeps running, with its runs. The sandboxes service watches worker pods (label `ate.dev/worker-pool`) and, when one turns Terminating, suspends each of the Tenant's actors on it synchronously (eight at a time, trying again for up to 29 minutes), records `drainedAt`, and resumes a sandbox whose request is `Running` on another worker. While it moves, its status reason is `Moving`, and the pod lifecycle waits instead of failing it at the ready deadline. Each drain is recorded once, as `agent.suspended` with reason `drain` (the pod row's `drained_at`, store migration 0048, nullable, run at start). Not covered: a spot reclaim or a node that dies, which still crash and revert. An actor created by an earlier release keeps its engine (#643) until it is reset.
10
+ - `@nylorun/core`: `agent.suspended`'s `reason` may be `drain`.
11
+ - `nylorun`: `local sandbox enable --backend substrate` lets the sandboxes service read pods cluster-wide (`get`, `list`, `watch`), for the worker pods it watches.
12
+
13
+ ## 0.43.0-beta
14
+
15
+ ### Minor Changes
16
+
17
+ - 745ef22: A model call's retries are in its event. `message.assistant` and `model.failed` carry `attempts`, the provider calls the gate made for the call (the first included), and `retries`, one `{ attempt, delayMs, error }` for each retry (the error as the provider worded it, cut to 300 characters, with the provider's credential scrubbed). Before, a call that answered after a retry was one `message.assistant` that showed no sign of it, and a call that failed after its attempts showed only its last error; the retries were only in the gates service's `model_retry` log lines.
18
+
19
+ - `@nylorun/core`: `ModelRetrySchema`, and the optional `attempts` and `retries` on the facts `message.assistant`, `model.failed` and `context.compacted` share. `ModelFailureOutcome` takes optional `attempts` and `retries`.
20
+ - `@nylorun/runtime`: the gate's answer reports them in `evidence.extras`, the usage ledger keeps them (`model_usage.attempts` and `retries`, store migration 0047, nullable, run at start), and the call's event takes them from its row; a failed call's from its failure outcome. A trace's chat span has `nylorun.model.attempts`. A retried call is still metered once, as one call. `/calls/model` is unchanged.
21
+
3
22
  ## 0.42.0-beta
4
23
 
5
24
  ### Minor Changes
@@ -770,9 +770,14 @@ export declare const AGENT_EVENT_PAYLOADS: {
770
770
  readonly "agent.running": z.ZodObject<{
771
771
  hostEpoch: z.ZodNumber;
772
772
  }, z.core.$loose>;
773
- /** Stopped (`POST .../stop`, or idle): the volume is kept; the next turn starts it again. */
773
+ /**
774
+ * Stopped (`POST .../stop`, or idle): the volume is kept; the next turn starts it again.
775
+ * `drain` (Agent Substrate): its worker stopped, so it was suspended with everything it held
776
+ * and resumed on another worker; nothing was lost.
777
+ */
774
778
  readonly "agent.suspended": z.ZodObject<{
775
779
  reason: z.ZodEnum<{
780
+ drain: "drain";
776
781
  idle: "idle";
777
782
  restart: "restart";
778
783
  stop: "stop";
@@ -4757,6 +4762,17 @@ export declare const MeteredUsageSchema: z.ZodObject<{
4757
4762
  cachedTokens: z.ZodOptional<z.ZodNumber>;
4758
4763
  costUsd: z.ZodOptional<z.ZodNumber>;
4759
4764
  }, z.core.$loose>;
4765
+ /**
4766
+ * One retry of a model call (Model Calls §6): the attempt it started, the first counted as 1,
4767
+ * the delay waited before it, and the error that ended the attempt before it, as the provider or
4768
+ * its SDK worded it, cut to 300 characters.
4769
+ */
4770
+ export declare const ModelRetrySchema: z.ZodObject<{
4771
+ attempt: z.ZodNumber;
4772
+ delayMs: z.ZodNumber;
4773
+ error: z.ZodString;
4774
+ }, z.core.$loose>;
4775
+ export type ModelRetry = z.infer<typeof ModelRetrySchema>;
4760
4776
  /**
4761
4777
  * `message.assistant`: one completed model step. `invocationId` is the model call's.
4762
4778
  * `model`, `finishReason` and `usage` are present when the provider reported them. A step that
@@ -4783,6 +4799,12 @@ export declare const AssistantMessagePayloadSchema: z.ZodObject<{
4783
4799
  cachedTokens: z.ZodOptional<z.ZodNumber>;
4784
4800
  costUsd: z.ZodOptional<z.ZodNumber>;
4785
4801
  }, z.core.$loose>>;
4802
+ attempts: z.ZodOptional<z.ZodNumber>;
4803
+ retries: z.ZodOptional<z.ZodArray<z.ZodObject<{
4804
+ attempt: z.ZodNumber;
4805
+ delayMs: z.ZodNumber;
4806
+ error: z.ZodString;
4807
+ }, z.core.$loose>>>;
4786
4808
  invocationId: z.ZodString;
4787
4809
  text: z.ZodString;
4788
4810
  model: z.ZodOptional<z.ZodObject<{
@@ -4826,6 +4848,12 @@ export declare const ModelFailedPayloadSchema: z.ZodObject<{
4826
4848
  cachedTokens: z.ZodOptional<z.ZodNumber>;
4827
4849
  costUsd: z.ZodOptional<z.ZodNumber>;
4828
4850
  }, z.core.$loose>>;
4851
+ attempts: z.ZodOptional<z.ZodNumber>;
4852
+ retries: z.ZodOptional<z.ZodArray<z.ZodObject<{
4853
+ attempt: z.ZodNumber;
4854
+ delayMs: z.ZodNumber;
4855
+ error: z.ZodString;
4856
+ }, z.core.$loose>>>;
4829
4857
  invocationId: z.ZodOptional<z.ZodString>;
4830
4858
  code: z.ZodString;
4831
4859
  message: z.ZodString;
@@ -4857,6 +4885,12 @@ export declare const ContextCompactedPayloadSchema: z.ZodObject<{
4857
4885
  cachedTokens: z.ZodOptional<z.ZodNumber>;
4858
4886
  costUsd: z.ZodOptional<z.ZodNumber>;
4859
4887
  }, z.core.$loose>>;
4888
+ attempts: z.ZodOptional<z.ZodNumber>;
4889
+ retries: z.ZodOptional<z.ZodArray<z.ZodObject<{
4890
+ attempt: z.ZodNumber;
4891
+ delayMs: z.ZodNumber;
4892
+ error: z.ZodString;
4893
+ }, z.core.$loose>>>;
4860
4894
  invocationId: z.ZodOptional<z.ZodString>;
4861
4895
  trigger: z.ZodEnum<{
4862
4896
  overflow: "overflow";
@@ -5139,6 +5173,12 @@ declare const TRANSCRIPT_PAYLOADS: {
5139
5173
  cachedTokens: z.ZodOptional<z.ZodNumber>;
5140
5174
  costUsd: z.ZodOptional<z.ZodNumber>;
5141
5175
  }, z.core.$loose>>;
5176
+ attempts: z.ZodOptional<z.ZodNumber>;
5177
+ retries: z.ZodOptional<z.ZodArray<z.ZodObject<{
5178
+ attempt: z.ZodNumber;
5179
+ delayMs: z.ZodNumber;
5180
+ error: z.ZodString;
5181
+ }, z.core.$loose>>>;
5142
5182
  invocationId: z.ZodString;
5143
5183
  text: z.ZodString;
5144
5184
  model: z.ZodOptional<z.ZodObject<{
@@ -5173,6 +5213,12 @@ declare const TRANSCRIPT_PAYLOADS: {
5173
5213
  cachedTokens: z.ZodOptional<z.ZodNumber>;
5174
5214
  costUsd: z.ZodOptional<z.ZodNumber>;
5175
5215
  }, z.core.$loose>>;
5216
+ attempts: z.ZodOptional<z.ZodNumber>;
5217
+ retries: z.ZodOptional<z.ZodArray<z.ZodObject<{
5218
+ attempt: z.ZodNumber;
5219
+ delayMs: z.ZodNumber;
5220
+ error: z.ZodString;
5221
+ }, z.core.$loose>>>;
5176
5222
  invocationId: z.ZodOptional<z.ZodString>;
5177
5223
  code: z.ZodString;
5178
5224
  message: z.ZodString;
@@ -5198,6 +5244,12 @@ declare const TRANSCRIPT_PAYLOADS: {
5198
5244
  cachedTokens: z.ZodOptional<z.ZodNumber>;
5199
5245
  costUsd: z.ZodOptional<z.ZodNumber>;
5200
5246
  }, z.core.$loose>>;
5247
+ attempts: z.ZodOptional<z.ZodNumber>;
5248
+ retries: z.ZodOptional<z.ZodArray<z.ZodObject<{
5249
+ attempt: z.ZodNumber;
5250
+ delayMs: z.ZodNumber;
5251
+ error: z.ZodString;
5252
+ }, z.core.$loose>>>;
5201
5253
  invocationId: z.ZodOptional<z.ZodString>;
5202
5254
  trigger: z.ZodEnum<{
5203
5255
  overflow: "overflow";
@@ -6071,6 +6123,12 @@ export declare const EVENT_CATALOG: {
6071
6123
  cachedTokens: z.ZodOptional<z.ZodNumber>;
6072
6124
  costUsd: z.ZodOptional<z.ZodNumber>;
6073
6125
  }, z.core.$loose>>;
6126
+ attempts: z.ZodOptional<z.ZodNumber>;
6127
+ retries: z.ZodOptional<z.ZodArray<z.ZodObject<{
6128
+ attempt: z.ZodNumber;
6129
+ delayMs: z.ZodNumber;
6130
+ error: z.ZodString;
6131
+ }, z.core.$loose>>>;
6074
6132
  invocationId: z.ZodString;
6075
6133
  text: z.ZodString;
6076
6134
  model: z.ZodOptional<z.ZodObject<{
@@ -6109,6 +6167,12 @@ export declare const EVENT_CATALOG: {
6109
6167
  cachedTokens: z.ZodOptional<z.ZodNumber>;
6110
6168
  costUsd: z.ZodOptional<z.ZodNumber>;
6111
6169
  }, z.core.$loose>>;
6170
+ attempts: z.ZodOptional<z.ZodNumber>;
6171
+ retries: z.ZodOptional<z.ZodArray<z.ZodObject<{
6172
+ attempt: z.ZodNumber;
6173
+ delayMs: z.ZodNumber;
6174
+ error: z.ZodString;
6175
+ }, z.core.$loose>>>;
6112
6176
  invocationId: z.ZodOptional<z.ZodString>;
6113
6177
  code: z.ZodString;
6114
6178
  message: z.ZodString;
@@ -6138,6 +6202,12 @@ export declare const EVENT_CATALOG: {
6138
6202
  cachedTokens: z.ZodOptional<z.ZodNumber>;
6139
6203
  costUsd: z.ZodOptional<z.ZodNumber>;
6140
6204
  }, z.core.$loose>>;
6205
+ attempts: z.ZodOptional<z.ZodNumber>;
6206
+ retries: z.ZodOptional<z.ZodArray<z.ZodObject<{
6207
+ attempt: z.ZodNumber;
6208
+ delayMs: z.ZodNumber;
6209
+ error: z.ZodString;
6210
+ }, z.core.$loose>>>;
6141
6211
  invocationId: z.ZodOptional<z.ZodString>;
6142
6212
  trigger: z.ZodEnum<{
6143
6213
  overflow: "overflow";
package/dist/contracts.js CHANGED
@@ -1199,8 +1199,12 @@ export const AGENT_EVENT_PAYLOADS = {
1199
1199
  .passthrough(),
1200
1200
  /** A pod joined and serves the Agent. */
1201
1201
  "agent.running": z.object({ hostEpoch: z.number().int() }).passthrough(),
1202
- /** Stopped (`POST .../stop`, or idle): the volume is kept; the next turn starts it again. */
1203
- "agent.suspended": z.object({ reason: z.enum(["stop", "idle", "restart"]) }).passthrough(),
1202
+ /**
1203
+ * Stopped (`POST .../stop`, or idle): the volume is kept; the next turn starts it again.
1204
+ * `drain` (Agent Substrate): its worker stopped, so it was suspended with everything it held
1205
+ * and resumed on another worker; nothing was lost.
1206
+ */
1207
+ "agent.suspended": z.object({ reason: z.enum(["stop", "idle", "restart", "drain"]) }).passthrough(),
1204
1208
  /** Its pod was replaced (same volume): the old pod's host token no longer works. */
1205
1209
  "agent.relaunched": z.object({ hostEpoch: z.number().int() }).passthrough(),
1206
1210
  /** Its volume or node is gone: turns are refused until a reset. */
@@ -3159,11 +3163,24 @@ export const MeteredUsageSchema = z
3159
3163
  costUsd: z.number().nonnegative().optional(),
3160
3164
  })
3161
3165
  .passthrough();
3166
+ /**
3167
+ * One retry of a model call (Model Calls §6): the attempt it started, the first counted as 1,
3168
+ * the delay waited before it, and the error that ended the attempt before it, as the provider or
3169
+ * its SDK worded it, cut to 300 characters.
3170
+ */
3171
+ export const ModelRetrySchema = z
3172
+ .object({
3173
+ attempt: z.number().int().min(2),
3174
+ delayMs: z.number().int().nonnegative(),
3175
+ error: z.string(),
3176
+ })
3177
+ .passthrough();
3162
3178
  /**
3163
3179
  * The timing of a model call's outcome, on `message.assistant`, `model.failed` and
3164
3180
  * `context.compacted`. `durationMs` is the journal's window, from the intent to the outcome;
3165
3181
  * `gate`, `firstTokenMs` and `meteredUsage` are the meter's, absent when no gate metered the
3166
- * call.
3182
+ * call. `attempts` and `retries` are the gate's: how many times it called the provider, and why
3183
+ * it called again; absent from a call a Runtime before 0.50 served.
3167
3184
  */
3168
3185
  const modelOutcomeFacts = {
3169
3186
  /** The model call's effect id. */
@@ -3174,6 +3191,10 @@ const modelOutcomeFacts = {
3174
3191
  /** From the gate's start of the call to the provider's first stream event. */
3175
3192
  firstTokenMs: z.number().int().nonnegative().optional(),
3176
3193
  meteredUsage: MeteredUsageSchema.optional(),
3194
+ /** The provider calls the gate made for this one, the first included: more than 1 after a retry. */
3195
+ attempts: z.number().int().positive().optional(),
3196
+ /** Each retry, in order; absent when the first attempt was the last. */
3197
+ retries: z.array(ModelRetrySchema).optional(),
3177
3198
  };
3178
3199
  /**
3179
3200
  * `message.assistant`: one completed model step. `invocationId` is the model call's.
@@ -67,6 +67,14 @@ export interface ModelFailureOutcome {
67
67
  readonly message: string;
68
68
  readonly retryable: boolean;
69
69
  readonly retryAfterMs?: number;
70
+ /** The provider calls the gate made before it gave up, the first included. */
71
+ readonly attempts?: number;
72
+ /** Each retry the gate made before it gave up: the attempt it started, its delay, the error before it. */
73
+ readonly retries?: readonly {
74
+ readonly attempt: number;
75
+ readonly delayMs: number;
76
+ readonly error: string;
77
+ }[];
70
78
  }
71
79
  export interface ModelControls {
72
80
  readonly temperature?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nylorun/core",
3
- "version": "0.42.0-beta",
3
+ "version": "0.44.0-beta",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "description": "Shared agent definitions and wire contracts",
@@ -34,9 +34,9 @@
34
34
  "yaml": "^2.9.1"
35
35
  },
36
36
  "devDependencies": {
37
- "@types/node": "^26.6.5",
37
+ "@types/node": "^26.6.6",
38
38
  "typescript": "npm:@typescript/typescript6@^6.0.2",
39
- "vitest": "^5.0.4"
39
+ "vitest": "^5.1.0"
40
40
  },
41
41
  "exports": {
42
42
  ".": {