@nylorun/runtime 0.26.0-beta → 0.27.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.
Files changed (321) hide show
  1. package/CHANGELOG.md +130 -0
  2. package/README.md +18 -14
  3. package/dist/adapters/execution/restate.d.ts +15 -18
  4. package/dist/adapters/execution/restate.js +31 -27
  5. package/dist/adapters/replication/pgoutput.d.ts +1 -1
  6. package/dist/adapters/replication/pgoutput.js +3 -2
  7. package/dist/adapters/sandbox/local.js +8 -5
  8. package/dist/adapters/sandbox/virtual.js +2 -2
  9. package/dist/adapters/streams/s2.d.ts +1 -1
  10. package/dist/adapters/streams/s2.js +18 -14
  11. package/dist/api/a2a/card.js +1 -1
  12. package/dist/api/a2a/endpoint.js +3 -4
  13. package/dist/api/a2a/protocol.js +4 -0
  14. package/dist/api/a2a/routes.d.ts +2 -6
  15. package/dist/api/a2a/routes.js +12 -18
  16. package/dist/api/ag-ui/endpoint.js +2 -3
  17. package/dist/api/ag-ui/routes.js +4 -4
  18. package/dist/api/components.d.ts +326 -45
  19. package/dist/api/components.js +5 -1
  20. package/dist/api/gate/keys.js +7 -4
  21. package/dist/api/gate/routes.d.ts +6 -2
  22. package/dist/api/gate/routes.js +15 -11
  23. package/dist/api/http/body.d.ts +15 -3
  24. package/dist/api/http/body.js +15 -7
  25. package/dist/api/http/respond.js +6 -2
  26. package/dist/api/http/routes/access.js +5 -4
  27. package/dist/api/http/routes/artifacts.js +19 -7
  28. package/dist/api/http/routes/coverage.js +1 -1
  29. package/dist/api/http/routes/environment-manifests.js +1 -1
  30. package/dist/api/http/routes/environments.js +6 -6
  31. package/dist/api/http/routes/files.d.ts +2 -1
  32. package/dist/api/http/routes/files.js +31 -5
  33. package/dist/api/http/routes/mcp.js +1 -1
  34. package/dist/api/http/routes/reads.d.ts +35 -0
  35. package/dist/api/http/routes/reads.js +50 -22
  36. package/dist/api/http/routes/sessions.js +11 -10
  37. package/dist/api/http/routes/tenant.d.ts +2 -2
  38. package/dist/api/http/routes/tenant.js +69 -16
  39. package/dist/api/inbound-files.d.ts +3 -9
  40. package/dist/api/inbound-files.js +18 -24
  41. package/dist/api/openapi.js +6 -2
  42. package/dist/artifacts/disk.d.ts +0 -4
  43. package/dist/artifacts/disk.js +77 -73
  44. package/dist/artifacts/files.d.ts +13 -4
  45. package/dist/artifacts/files.js +27 -9
  46. package/dist/artifacts/folder-upload.d.ts +75 -0
  47. package/dist/artifacts/folder-upload.js +263 -0
  48. package/dist/artifacts/folders.d.ts +14 -8
  49. package/dist/artifacts/folders.js +19 -11
  50. package/dist/artifacts/links.js +7 -6
  51. package/dist/artifacts/parts.d.ts +9 -14
  52. package/dist/artifacts/parts.js +11 -9
  53. package/dist/artifacts/pipe.d.ts +15 -0
  54. package/dist/artifacts/pipe.js +71 -0
  55. package/dist/artifacts/quota.d.ts +36 -0
  56. package/dist/artifacts/quota.js +44 -0
  57. package/dist/artifacts/service.d.ts +25 -1
  58. package/dist/artifacts/service.js +70 -25
  59. package/dist/blob/fs.js +2 -1
  60. package/dist/blob/s3.d.ts +6 -2
  61. package/dist/blob/s3.js +9 -7
  62. package/dist/blob/types.d.ts +1 -1
  63. package/dist/blob/types.js +1 -1
  64. package/dist/core/limits.d.ts +11 -35
  65. package/dist/core/limits.js +5 -73
  66. package/dist/core/sandbox-routes.js +0 -1
  67. package/dist/core/turn-manifest.d.ts +1 -2
  68. package/dist/core/turn-manifest.js +4 -28
  69. package/dist/execution/memory.d.ts +8 -5
  70. package/dist/execution/memory.js +8 -6
  71. package/dist/execution/types.d.ts +1 -6
  72. package/dist/execution/types.js +0 -5
  73. package/dist/gates/contract.d.ts +3 -2
  74. package/dist/gates/contract.js +1 -1
  75. package/dist/gates/egress-credentials.js +4 -3
  76. package/dist/gates/egress.d.ts +9 -9
  77. package/dist/gates/egress.js +14 -16
  78. package/dist/gates/fixture-model.js +13 -2
  79. package/dist/gates/handler.d.ts +1 -3
  80. package/dist/gates/handler.js +4 -3
  81. package/dist/gates/http-client.d.ts +4 -3
  82. package/dist/gates/http-client.js +5 -7
  83. package/dist/gates/http-tool.d.ts +24 -4
  84. package/dist/gates/http-tool.js +40 -12
  85. package/dist/gates/in-process.d.ts +2 -1
  86. package/dist/gates/in-process.js +17 -9
  87. package/dist/gates/inflight.d.ts +2 -2
  88. package/dist/gates/inflight.js +3 -2
  89. package/dist/gates/journal.js +5 -7
  90. package/dist/gates/mcp-handler.d.ts +4 -3
  91. package/dist/gates/mcp-handler.js +15 -5
  92. package/dist/gates/model-gate.d.ts +11 -2
  93. package/dist/gates/policy.d.ts +28 -5
  94. package/dist/gates/policy.js +60 -17
  95. package/dist/gates/provider-gate.d.ts +22 -0
  96. package/dist/gates/provider-gate.js +30 -0
  97. package/dist/gates/tool-calls.d.ts +1 -3
  98. package/dist/gates/tool-calls.js +2 -3
  99. package/dist/gates/tool-client.d.ts +1 -1
  100. package/dist/gates/tool-client.js +5 -6
  101. package/dist/gates/tool-contract.d.ts +8 -5
  102. package/dist/gates/tool-contract.js +1 -1
  103. package/dist/gates/tool-gate.d.ts +18 -7
  104. package/dist/gates/tool-gate.js +49 -7
  105. package/dist/harness/calls.d.ts +27 -25
  106. package/dist/harness/calls.js +40 -46
  107. package/dist/harness/executors.d.ts +10 -3
  108. package/dist/harness/executors.js +53 -23
  109. package/dist/harness/main.js +2 -2
  110. package/dist/harness/pod.d.ts +0 -2
  111. package/dist/harness/pod.js +7 -6
  112. package/dist/harness/run-tokens.d.ts +4 -1
  113. package/dist/harness/run-tokens.js +6 -2
  114. package/dist/harness/service.d.ts +17 -14
  115. package/dist/harness/service.js +21 -35
  116. package/dist/harness/setup.d.ts +0 -2
  117. package/dist/harness/setup.js +4 -9
  118. package/dist/harness/ws-client.d.ts +2 -2
  119. package/dist/harness/ws-client.js +7 -5
  120. package/dist/harness/ws-port.d.ts +3 -4
  121. package/dist/harness/ws-port.js +3 -4
  122. package/dist/harness-api/artifacts.d.ts +20 -0
  123. package/dist/harness-api/artifacts.js +478 -0
  124. package/dist/harness-api/in-process.d.ts +2 -2
  125. package/dist/harness-api/in-process.js +18 -16
  126. package/dist/harness-api/record.d.ts +10 -9
  127. package/dist/harness-api/record.js +102 -157
  128. package/dist/harness-api/renew.d.ts +1 -1
  129. package/dist/harness-api/renew.js +2 -2
  130. package/dist/harness-api/server.d.ts +1 -16
  131. package/dist/harness-api/server.js +82 -73
  132. package/dist/harness-api/start.d.ts +20 -2
  133. package/dist/harness-api/start.js +57 -18
  134. package/dist/harness-api/tool-journal.d.ts +15 -10
  135. package/dist/harness-api/tool-journal.js +26 -24
  136. package/dist/harness-api/workspace.d.ts +0 -4
  137. package/dist/harness-api/workspace.js +2 -45
  138. package/dist/harness-api/ws-server.js +10 -10
  139. package/dist/host/create-host.js +2 -3
  140. package/dist/host/execution.js +2 -3
  141. package/dist/host/gates.d.ts +2 -9
  142. package/dist/host/gates.js +15 -12
  143. package/dist/host/http.d.ts +0 -2
  144. package/dist/host/http.js +0 -27
  145. package/dist/host/main.js +10 -3
  146. package/dist/host/operate.js +12 -3
  147. package/dist/host/stack-config.d.ts +11 -0
  148. package/dist/host/stack-config.js +21 -1
  149. package/dist/index.d.ts +0 -1
  150. package/dist/index.js +0 -1
  151. package/dist/infra/index.js +2 -1
  152. package/dist/infra/readiness.d.ts +0 -2
  153. package/dist/infra/readiness.js +4 -3
  154. package/dist/keys/client.d.ts +1 -0
  155. package/dist/keys/client.js +2 -3
  156. package/dist/keys/contract.d.ts +0 -2
  157. package/dist/keys/contract.js +0 -2
  158. package/dist/keys/egress-ca.d.ts +0 -2
  159. package/dist/keys/egress-ca.js +2 -3
  160. package/dist/keys/keys.js +6 -1
  161. package/dist/keys/x509.d.ts +8 -4
  162. package/dist/keys/x509.js +14 -5
  163. package/dist/management-openapi.json +1961 -994
  164. package/dist/mcp/connect.d.ts +35 -26
  165. package/dist/mcp/connect.js +112 -141
  166. package/dist/mcp/pool.d.ts +27 -22
  167. package/dist/mcp/pool.js +34 -48
  168. package/dist/mcp/preview.d.ts +12 -5
  169. package/dist/mcp/preview.js +36 -19
  170. package/dist/mcp/snapshot.d.ts +35 -86
  171. package/dist/mcp/snapshot.js +93 -135
  172. package/dist/model/auth-store.js +5 -3
  173. package/dist/model/capabilities.d.ts +1 -1
  174. package/dist/model/catalog.d.ts +9 -36
  175. package/dist/model/catalog.js +6 -33
  176. package/dist/model/descriptor.d.ts +51 -0
  177. package/dist/model/descriptor.js +83 -0
  178. package/dist/model/models.d.ts +0 -3
  179. package/dist/model/models.js +3 -5
  180. package/dist/model/native-blocks.js +1 -1
  181. package/dist/model/pi-model.d.ts +16 -5
  182. package/dist/model/pi-model.js +86 -105
  183. package/dist/openapi.json +838 -1218
  184. package/dist/reads/cursor.js +3 -1
  185. package/dist/record/append.d.ts +34 -2
  186. package/dist/record/append.js +50 -1
  187. package/dist/record/environment.d.ts +2 -0
  188. package/dist/record/environment.js +2 -0
  189. package/dist/record/index.d.ts +1 -1
  190. package/dist/record/index.js +1 -1
  191. package/dist/redact.d.ts +1 -1
  192. package/dist/redact.js +3 -2
  193. package/dist/sandbox/egress-token.d.ts +3 -3
  194. package/dist/sandbox/egress-token.js +3 -3
  195. package/dist/sandbox/join.js +3 -2
  196. package/dist/sandbox/manager.d.ts +41 -41
  197. package/dist/sandbox/manager.js +112 -44
  198. package/dist/sandbox/placement.d.ts +1 -1
  199. package/dist/sandbox/placement.js +5 -8
  200. package/dist/sandbox/pods/client.d.ts +1 -10
  201. package/dist/sandbox/pods/client.js +8 -4
  202. package/dist/sandbox/pods/lifecycle.d.ts +19 -11
  203. package/dist/sandbox/pods/lifecycle.js +45 -23
  204. package/dist/sandbox/pods/network-gate.d.ts +4 -5
  205. package/dist/sandbox/pods/network-gate.js +7 -7
  206. package/dist/sandbox/pods/reconcile.js +4 -1
  207. package/dist/sandbox/pods/spec.js +8 -5
  208. package/dist/sandbox/policy.d.ts +7 -1
  209. package/dist/sandbox/policy.js +10 -3
  210. package/dist/sandbox/resolve.d.ts +8 -3
  211. package/dist/sandbox/resolve.js +12 -2
  212. package/dist/sandbox/setup.d.ts +3 -1
  213. package/dist/sandbox/setup.js +34 -11
  214. package/dist/sandbox/share.d.ts +5 -14
  215. package/dist/sandbox/share.js +5 -34
  216. package/dist/sandbox/skills.d.ts +7 -13
  217. package/dist/sandbox/skills.js +16 -31
  218. package/dist/sandbox/tenant-config.d.ts +2 -2
  219. package/dist/sandbox/tenant-config.js +4 -3
  220. package/dist/sandbox/tools.d.ts +7 -1
  221. package/dist/sandbox/tools.js +26 -26
  222. package/dist/sandbox/types.d.ts +10 -3
  223. package/dist/sandbox/types.js +9 -0
  224. package/dist/store/postgres/connect.d.ts +6 -5
  225. package/dist/store/postgres/connect.js +14 -11
  226. package/dist/store/postgres/control.js +13 -13
  227. package/dist/store/postgres/drizzle/0028_artifact_write_keys.sql +2 -0
  228. package/dist/store/postgres/drizzle/0029_protocol_15.sql +11 -0
  229. package/dist/store/postgres/drizzle/0030_protocol_15_runtime_block.sql +11 -0
  230. package/dist/store/postgres/drizzle/0031_protocol_15_mcp_snapshot.sql +8 -0
  231. package/dist/store/postgres/drizzle/meta/_journal.json +28 -0
  232. package/dist/store/postgres/reads.js +10 -2
  233. package/dist/store/postgres/schema.d.ts +19 -0
  234. package/dist/store/postgres/schema.js +7 -0
  235. package/dist/store/postgres/store.js +55 -26
  236. package/dist/store/types.d.ts +17 -7
  237. package/dist/streams/relay/core.d.ts +3 -3
  238. package/dist/streams/relay/core.js +9 -10
  239. package/dist/tenant/advance.js +21 -31
  240. package/dist/tenant/commands.js +9 -16
  241. package/dist/tenant/context.d.ts +14 -17
  242. package/dist/tenant/definition-files.d.ts +25 -4
  243. package/dist/tenant/definition-files.js +85 -47
  244. package/dist/tenant/effects.js +9 -36
  245. package/dist/tenant/environment-manifests.js +9 -1
  246. package/dist/tenant/environments.d.ts +0 -2
  247. package/dist/tenant/environments.js +49 -28
  248. package/dist/tenant/ephemeral.js +2 -1
  249. package/dist/tenant/history.d.ts +1 -1
  250. package/dist/tenant/history.js +1 -1
  251. package/dist/tenant/host-token.d.ts +3 -3
  252. package/dist/tenant/host-token.js +11 -10
  253. package/dist/tenant/http.d.ts +5 -8
  254. package/dist/tenant/http.js +9 -0
  255. package/dist/tenant/identity-file.d.ts +23 -0
  256. package/dist/tenant/identity-file.js +34 -6
  257. package/dist/tenant/issuers.d.ts +5 -5
  258. package/dist/tenant/issuers.js +31 -23
  259. package/dist/tenant/jwt.d.ts +8 -2
  260. package/dist/tenant/jwt.js +10 -2
  261. package/dist/tenant/limits.d.ts +90 -0
  262. package/dist/tenant/limits.js +175 -0
  263. package/dist/tenant/module.d.ts +4 -1
  264. package/dist/tenant/module.js +9 -8
  265. package/dist/tenant/outbound.d.ts +11 -14
  266. package/dist/tenant/outbound.js +10 -15
  267. package/dist/tenant/run-grants.js +3 -2
  268. package/dist/tenant/run-token.d.ts +0 -4
  269. package/dist/tenant/run-token.js +6 -11
  270. package/dist/tenant/runtime-limits.d.ts +24 -0
  271. package/dist/tenant/runtime-limits.js +27 -0
  272. package/dist/tenant/runtime.js +30 -43
  273. package/dist/tenant/session-streams.js +7 -6
  274. package/dist/tenant/session.d.ts +1 -1
  275. package/dist/tenant/session.js +1 -1
  276. package/dist/tenant/sessions.js +32 -29
  277. package/dist/tenant/signing-keys.d.ts +1 -1
  278. package/dist/tenant/signing-keys.js +5 -6
  279. package/dist/tenant/status.js +4 -3
  280. package/dist/tenant/streams.js +18 -20
  281. package/dist/tenant/sweep.d.ts +1 -21
  282. package/dist/tenant/sweep.js +39 -48
  283. package/dist/tenant/transcript.d.ts +70 -23
  284. package/dist/tenant/transcript.js +28 -22
  285. package/dist/tenant/types.d.ts +9 -14
  286. package/dist/tenant/worker.d.ts +2 -10
  287. package/dist/tenant/worker.js +5 -14
  288. package/dist/traces/ids.js +5 -1
  289. package/dist/traces/map.d.ts +9 -6
  290. package/dist/traces/map.js +9 -11
  291. package/dist/traces/otlp.d.ts +3 -3
  292. package/dist/traces/otlp.js +5 -3
  293. package/dist/traces/projector.d.ts +9 -4
  294. package/dist/traces/projector.js +13 -7
  295. package/dist/traces/read.js +6 -1
  296. package/dist/tuning.d.ts +383 -0
  297. package/dist/tuning.js +658 -0
  298. package/dist/vault/headers.js +4 -2
  299. package/dist/version.d.ts +1 -1
  300. package/dist/version.js +1 -1
  301. package/package.json +3 -3
  302. package/dist/artifacts/export.d.ts +0 -8
  303. package/dist/artifacts/export.js +0 -204
  304. package/dist/artifacts/media-types.d.ts +0 -30
  305. package/dist/artifacts/media-types.js +0 -137
  306. package/dist/artifacts/workspace.d.ts +0 -60
  307. package/dist/artifacts/workspace.js +0 -45
  308. package/dist/media.d.ts +0 -10
  309. package/dist/media.js +0 -58
  310. package/dist/sandbox/runtime-tools.d.ts +0 -9
  311. package/dist/sandbox/runtime-tools.js +0 -16
  312. package/dist/sandbox/session-sandbox.d.ts +0 -16
  313. package/dist/sandbox/session-sandbox.js +0 -77
  314. package/dist/tenant/artifact-tool.d.ts +0 -13
  315. package/dist/tenant/artifact-tool.js +0 -243
  316. package/dist/tenant/skill-tool.d.ts +0 -20
  317. package/dist/tenant/skill-tool.js +0 -67
  318. package/dist/tenant/tool-results.d.ts +0 -57
  319. package/dist/tenant/tool-results.js +0 -298
  320. package/dist/tenant/tool-search.d.ts +0 -39
  321. package/dist/tenant/tool-search.js +0 -103
@@ -6,6 +6,8 @@
6
6
  import type { HostEffect } from "@nylorun/harness/run";
7
7
  import type { PluginLabel } from "@nylorun/core/define";
8
8
  import type { TOOL_CALL_KINDS, TOOL_CALL_STATUSES } from "@nylorun/core/contracts";
9
+ import { type CompactionFacts } from "@nylorun/core/harness-api";
10
+ import type { Tx } from "../store/types.js";
9
11
  export type ToolCallStatus = (typeof TOOL_CALL_STATUSES)[number];
10
12
  export type ToolCallKind = (typeof TOOL_CALL_KINDS)[number];
11
13
  /** The model's tool call id and the harness invocation, for tool effects. */
@@ -51,25 +53,52 @@ export declare function assistantMessage(request: HostEffect, value: unknown): {
51
53
  usage?: object | undefined;
52
54
  } | undefined;
53
55
  /**
54
- * `context.compacted` for a model effect that summarized history (Model Calls §8): the
55
- * engine replaced the older transcript with that summary. A partial summary (one call of
56
- * several) is marked `partial: true` (R7.1): only the last call's event replaced the history.
56
+ * `context.compacted` for a compaction a harness reported with its transcript edit (Q4, protocol
57
+ * 15): its facts, the last summary call's step and model facts, and the agent. Every summary
58
+ * effect it names must be a completed, successful model call of turn `turnId` made for a summary
59
+ * (`purpose: "summary"`); otherwise the edit is refused (`invalid`).
57
60
  */
58
- export declare function contextCompacted(request: HostEffect, value: unknown): {
61
+ export declare function contextCompacted(t: Tx, sessionId: string, turnId: string | null, facts: CompactionFacts): Promise<{
59
62
  agent: import("@nylorun/core/define").AgentRef;
60
63
  invocationId?: string | undefined;
61
64
  trigger: "overflow" | "threshold";
62
65
  tokensBefore: number;
63
66
  tokensAfter: number;
64
- partial?: true | undefined;
67
+ effectId: string;
68
+ durationMs?: number | undefined;
69
+ gate?: {
70
+ startedAt: string;
71
+ endedAt: string;
72
+ } | undefined;
73
+ firstTokenMs?: number | undefined;
74
+ meteredUsage?: {
75
+ inputTokens: number;
76
+ outputTokens: number;
77
+ totalTokens: number;
78
+ cachedTokens?: number | undefined;
79
+ costUsd?: number | undefined;
80
+ } | undefined;
65
81
  } | {
66
82
  agent?: undefined;
67
83
  invocationId?: string | undefined;
68
84
  trigger: "overflow" | "threshold";
69
85
  tokensBefore: number;
70
86
  tokensAfter: number;
71
- partial?: true | undefined;
72
- } | undefined;
87
+ effectId: string;
88
+ durationMs?: number | undefined;
89
+ gate?: {
90
+ startedAt: string;
91
+ endedAt: string;
92
+ } | undefined;
93
+ firstTokenMs?: number | undefined;
94
+ meteredUsage?: {
95
+ inputTokens: number;
96
+ outputTokens: number;
97
+ totalTokens: number;
98
+ cachedTokens?: number | undefined;
99
+ costUsd?: number | undefined;
100
+ } | undefined;
101
+ }>;
73
102
  /** `model.failed` for a model effect that completed with a failure outcome (Model Calls §6.4). */
74
103
  export declare function modelFailed(request: HostEffect, value: unknown): {
75
104
  agent: import("@nylorun/core/define").AgentRef;
@@ -137,6 +166,8 @@ export interface ToolCallFacts {
137
166
  readonly status: ToolCallStatus;
138
167
  readonly kind?: ToolCallKind;
139
168
  readonly server?: string;
169
+ /** The tool's identity: an MCP tool's name on `server`, an HTTP tool's declared name. */
170
+ readonly tool?: string;
140
171
  readonly skill?: string;
141
172
  readonly plugin?: PluginLabel;
142
173
  readonly attempts?: number;
@@ -161,8 +192,9 @@ export declare function toolCompleted(request: HostEffect, value: unknown, facts
161
192
  redacted: number;
162
193
  toolName: string;
163
194
  status?: "cancelled" | "completed" | "failed" | undefined;
164
- kind?: "harness" | "http" | "mcp" | "platform" | "sandbox" | undefined;
195
+ kind?: "harness" | "http" | "mcp" | "sandbox" | undefined;
165
196
  server?: string | undefined;
197
+ tool?: string | undefined;
166
198
  skill?: string | undefined;
167
199
  plugin?: PluginLabel | undefined;
168
200
  attempts?: number | undefined;
@@ -182,8 +214,9 @@ export declare function toolCompleted(request: HostEffect, value: unknown, facts
182
214
  redacted: number;
183
215
  toolName: string;
184
216
  status?: "cancelled" | "completed" | "failed" | undefined;
185
- kind?: "harness" | "http" | "mcp" | "platform" | "sandbox" | undefined;
217
+ kind?: "harness" | "http" | "mcp" | "sandbox" | undefined;
186
218
  server?: string | undefined;
219
+ tool?: string | undefined;
187
220
  skill?: string | undefined;
188
221
  plugin?: PluginLabel | undefined;
189
222
  attempts?: number | undefined;
@@ -203,8 +236,9 @@ export declare function toolCompleted(request: HostEffect, value: unknown, facts
203
236
  redacted?: undefined;
204
237
  toolName: string;
205
238
  status?: "cancelled" | "completed" | "failed" | undefined;
206
- kind?: "harness" | "http" | "mcp" | "platform" | "sandbox" | undefined;
239
+ kind?: "harness" | "http" | "mcp" | "sandbox" | undefined;
207
240
  server?: string | undefined;
241
+ tool?: string | undefined;
208
242
  skill?: string | undefined;
209
243
  plugin?: PluginLabel | undefined;
210
244
  attempts?: number | undefined;
@@ -224,8 +258,9 @@ export declare function toolCompleted(request: HostEffect, value: unknown, facts
224
258
  redacted?: undefined;
225
259
  toolName: string;
226
260
  status?: "cancelled" | "completed" | "failed" | undefined;
227
- kind?: "harness" | "http" | "mcp" | "platform" | "sandbox" | undefined;
261
+ kind?: "harness" | "http" | "mcp" | "sandbox" | undefined;
228
262
  server?: string | undefined;
263
+ tool?: string | undefined;
229
264
  skill?: string | undefined;
230
265
  plugin?: PluginLabel | undefined;
231
266
  attempts?: number | undefined;
@@ -240,8 +275,9 @@ export declare function toolCompleted(request: HostEffect, value: unknown, facts
240
275
  redacted: number;
241
276
  toolName: string;
242
277
  status?: "cancelled" | "completed" | "failed" | undefined;
243
- kind?: "harness" | "http" | "mcp" | "platform" | "sandbox" | undefined;
278
+ kind?: "harness" | "http" | "mcp" | "sandbox" | undefined;
244
279
  server?: string | undefined;
280
+ tool?: string | undefined;
245
281
  skill?: string | undefined;
246
282
  plugin?: PluginLabel | undefined;
247
283
  attempts?: number | undefined;
@@ -256,8 +292,9 @@ export declare function toolCompleted(request: HostEffect, value: unknown, facts
256
292
  redacted: number;
257
293
  toolName: string;
258
294
  status?: "cancelled" | "completed" | "failed" | undefined;
259
- kind?: "harness" | "http" | "mcp" | "platform" | "sandbox" | undefined;
295
+ kind?: "harness" | "http" | "mcp" | "sandbox" | undefined;
260
296
  server?: string | undefined;
297
+ tool?: string | undefined;
261
298
  skill?: string | undefined;
262
299
  plugin?: PluginLabel | undefined;
263
300
  attempts?: number | undefined;
@@ -272,8 +309,9 @@ export declare function toolCompleted(request: HostEffect, value: unknown, facts
272
309
  redacted?: undefined;
273
310
  toolName: string;
274
311
  status?: "cancelled" | "completed" | "failed" | undefined;
275
- kind?: "harness" | "http" | "mcp" | "platform" | "sandbox" | undefined;
312
+ kind?: "harness" | "http" | "mcp" | "sandbox" | undefined;
276
313
  server?: string | undefined;
314
+ tool?: string | undefined;
277
315
  skill?: string | undefined;
278
316
  plugin?: PluginLabel | undefined;
279
317
  attempts?: number | undefined;
@@ -288,8 +326,9 @@ export declare function toolCompleted(request: HostEffect, value: unknown, facts
288
326
  redacted?: undefined;
289
327
  toolName: string;
290
328
  status?: "cancelled" | "completed" | "failed" | undefined;
291
- kind?: "harness" | "http" | "mcp" | "platform" | "sandbox" | undefined;
329
+ kind?: "harness" | "http" | "mcp" | "sandbox" | undefined;
292
330
  server?: string | undefined;
331
+ tool?: string | undefined;
293
332
  skill?: string | undefined;
294
333
  plugin?: PluginLabel | undefined;
295
334
  attempts?: number | undefined;
@@ -311,8 +350,9 @@ export declare function toolCompleted(request: HostEffect, value: unknown, facts
311
350
  redacted: number;
312
351
  toolName: string;
313
352
  status?: "cancelled" | "completed" | "failed" | undefined;
314
- kind?: "harness" | "http" | "mcp" | "platform" | "sandbox" | undefined;
353
+ kind?: "harness" | "http" | "mcp" | "sandbox" | undefined;
315
354
  server?: string | undefined;
355
+ tool?: string | undefined;
316
356
  skill?: string | undefined;
317
357
  plugin?: PluginLabel | undefined;
318
358
  attempts?: number | undefined;
@@ -334,8 +374,9 @@ export declare function toolCompleted(request: HostEffect, value: unknown, facts
334
374
  redacted: number;
335
375
  toolName: string;
336
376
  status?: "cancelled" | "completed" | "failed" | undefined;
337
- kind?: "harness" | "http" | "mcp" | "platform" | "sandbox" | undefined;
377
+ kind?: "harness" | "http" | "mcp" | "sandbox" | undefined;
338
378
  server?: string | undefined;
379
+ tool?: string | undefined;
339
380
  skill?: string | undefined;
340
381
  plugin?: PluginLabel | undefined;
341
382
  attempts?: number | undefined;
@@ -357,8 +398,9 @@ export declare function toolCompleted(request: HostEffect, value: unknown, facts
357
398
  redacted?: undefined;
358
399
  toolName: string;
359
400
  status?: "cancelled" | "completed" | "failed" | undefined;
360
- kind?: "harness" | "http" | "mcp" | "platform" | "sandbox" | undefined;
401
+ kind?: "harness" | "http" | "mcp" | "sandbox" | undefined;
361
402
  server?: string | undefined;
403
+ tool?: string | undefined;
362
404
  skill?: string | undefined;
363
405
  plugin?: PluginLabel | undefined;
364
406
  attempts?: number | undefined;
@@ -380,8 +422,9 @@ export declare function toolCompleted(request: HostEffect, value: unknown, facts
380
422
  redacted?: undefined;
381
423
  toolName: string;
382
424
  status?: "cancelled" | "completed" | "failed" | undefined;
383
- kind?: "harness" | "http" | "mcp" | "platform" | "sandbox" | undefined;
425
+ kind?: "harness" | "http" | "mcp" | "sandbox" | undefined;
384
426
  server?: string | undefined;
427
+ tool?: string | undefined;
385
428
  skill?: string | undefined;
386
429
  plugin?: PluginLabel | undefined;
387
430
  attempts?: number | undefined;
@@ -398,8 +441,9 @@ export declare function toolCompleted(request: HostEffect, value: unknown, facts
398
441
  redacted: number;
399
442
  toolName: string;
400
443
  status?: "cancelled" | "completed" | "failed" | undefined;
401
- kind?: "harness" | "http" | "mcp" | "platform" | "sandbox" | undefined;
444
+ kind?: "harness" | "http" | "mcp" | "sandbox" | undefined;
402
445
  server?: string | undefined;
446
+ tool?: string | undefined;
403
447
  skill?: string | undefined;
404
448
  plugin?: PluginLabel | undefined;
405
449
  attempts?: number | undefined;
@@ -416,8 +460,9 @@ export declare function toolCompleted(request: HostEffect, value: unknown, facts
416
460
  redacted: number;
417
461
  toolName: string;
418
462
  status?: "cancelled" | "completed" | "failed" | undefined;
419
- kind?: "harness" | "http" | "mcp" | "platform" | "sandbox" | undefined;
463
+ kind?: "harness" | "http" | "mcp" | "sandbox" | undefined;
420
464
  server?: string | undefined;
465
+ tool?: string | undefined;
421
466
  skill?: string | undefined;
422
467
  plugin?: PluginLabel | undefined;
423
468
  attempts?: number | undefined;
@@ -434,8 +479,9 @@ export declare function toolCompleted(request: HostEffect, value: unknown, facts
434
479
  redacted?: undefined;
435
480
  toolName: string;
436
481
  status?: "cancelled" | "completed" | "failed" | undefined;
437
- kind?: "harness" | "http" | "mcp" | "platform" | "sandbox" | undefined;
482
+ kind?: "harness" | "http" | "mcp" | "sandbox" | undefined;
438
483
  server?: string | undefined;
484
+ tool?: string | undefined;
439
485
  skill?: string | undefined;
440
486
  plugin?: PluginLabel | undefined;
441
487
  attempts?: number | undefined;
@@ -452,8 +498,9 @@ export declare function toolCompleted(request: HostEffect, value: unknown, facts
452
498
  redacted?: undefined;
453
499
  toolName: string;
454
500
  status?: "cancelled" | "completed" | "failed" | undefined;
455
- kind?: "harness" | "http" | "mcp" | "platform" | "sandbox" | undefined;
501
+ kind?: "harness" | "http" | "mcp" | "sandbox" | undefined;
456
502
  server?: string | undefined;
503
+ tool?: string | undefined;
457
504
  skill?: string | undefined;
458
505
  plugin?: PluginLabel | undefined;
459
506
  attempts?: number | undefined;
@@ -1,4 +1,5 @@
1
1
  import { isModelFailureOutcome } from "@nylorun/core/define";
2
+ import { HarnessApiError } from "@nylorun/core/harness-api";
2
3
  /** The model's tool call id and the harness invocation, for tool effects. */
3
4
  export function toolIds(context) {
4
5
  const c = context;
@@ -52,31 +53,35 @@ export function assistantMessage(request, value) {
52
53
  };
53
54
  }
54
55
  /**
55
- * `context.compacted` for a model effect that summarized history (Model Calls §8): the
56
- * engine replaced the older transcript with that summary. A partial summary (one call of
57
- * several) is marked `partial: true` (R7.1): only the last call's event replaced the history.
56
+ * `context.compacted` for a compaction a harness reported with its transcript edit (Q4, protocol
57
+ * 15): its facts, the last summary call's step and model facts, and the agent. Every summary
58
+ * effect it names must be a completed, successful model call of turn `turnId` made for a summary
59
+ * (`purpose: "summary"`); otherwise the edit is refused (`invalid`).
58
60
  */
59
- export function contextCompacted(request, value) {
60
- const compaction = request.context?.compaction;
61
- if (!compaction || isModelFailureOutcome(value))
62
- return undefined;
63
- const summary = typeof value === "string"
64
- ? value
65
- : Array.isArray(value?.output)
66
- ? value.output
67
- .map((block) => (block.type === "text" && typeof block.text === "string" ? block.text : ""))
68
- .join("")
69
- : "";
70
- const invocationId = request.context?.invocationId;
71
- const tokensBefore = Number(compaction.tokensBefore) || 0;
72
- const keptTokens = Number(compaction.keptTokens) || 0;
61
+ export async function contextCompacted(t, sessionId, turnId, facts) {
62
+ let last;
63
+ for (const effectId of facts.summaryEffectIds) {
64
+ const row = await t.get("effects", effectId);
65
+ const request = row?.request;
66
+ if (!row ||
67
+ row.status !== "completed" ||
68
+ request?.kind !== "model" ||
69
+ request.sessionId !== sessionId ||
70
+ request.turnId !== turnId ||
71
+ request.purpose !== "summary" ||
72
+ isModelFailureOutcome(row.outcome?.value))
73
+ throw new HarnessApiError("invalid", `The compaction names ${effectId}, which is not a completed summary call of this turn`);
74
+ last = { effectId, row };
75
+ }
76
+ const { effectId, row } = last;
77
+ const invocationId = row.request.context?.invocationId;
73
78
  return {
74
79
  ...(typeof invocationId === "string" ? { invocationId } : {}),
75
- trigger: compaction.trigger === "overflow" ? "overflow" : "threshold",
76
- tokensBefore,
77
- tokensAfter: keptTokens + Math.ceil(summary.trim().length / 4),
78
- ...(compaction.partial ? { partial: true } : {}),
79
- ...agentOf(request),
80
+ trigger: facts.trigger,
81
+ tokensBefore: facts.tokensBefore,
82
+ tokensAfter: facts.tokensAfter,
83
+ ...modelOutcomeFacts(effectId, row, await t.modelUsageOf(effectId)),
84
+ ...agentOf(row.request),
80
85
  };
81
86
  }
82
87
  /** `model.failed` for a model effect that completed with a failure outcome (Model Calls §6.4). */
@@ -164,6 +169,7 @@ export function toolCompleted(request, value, facts) {
164
169
  status: facts.status,
165
170
  ...(facts.kind === undefined ? {} : { kind: facts.kind }),
166
171
  ...(facts.server === undefined ? {} : { server: facts.server }),
172
+ ...(facts.tool === undefined ? {} : { tool: facts.tool }),
167
173
  ...(facts.skill === undefined ? {} : { skill: facts.skill }),
168
174
  ...(facts.plugin === undefined ? {} : { plugin: facts.plugin }),
169
175
  ...(facts.attempts === undefined ? {} : { attempts: facts.attempts }),
@@ -1,7 +1,6 @@
1
1
  import type { IncomingMessage, ServerResponse } from "node:http";
2
2
  import type { HarnessStatus, HostTenant, TenantEnvelope } from "@nylorun/core/contracts";
3
3
  import type { HarnessChannel } from "@nylorun/core/harness-api";
4
- import type { FlowLimits } from "../core/limits.js";
5
4
  import type { HarnessPeer } from "../harness-api/server.js";
6
5
  import type { HostAuthority } from "../sandbox/join.js";
7
6
  import type { SessionStore } from "../store/types.js";
@@ -45,35 +44,31 @@ export interface TenantConfig {
45
44
  /**
46
45
  * Segment rollover (Model Calls §10): a turn ends its segment at a step boundary after this
47
46
  * many steps or milliseconds and continues in a new one, so no advance reaches its
48
- * deadline. Default 50 steps or 20 minutes.
47
+ * deadline. Default the Host tuning's `harnessApi.rolloverSteps` and `rolloverMs` (50 steps,
48
+ * 20 minutes).
49
49
  */
50
50
  rollover?: {
51
51
  steps?: number;
52
52
  ms?: number;
53
53
  };
54
- /** Retries and timeouts for model calls (Model Calls §5, §6). Defaults in `piModel`. */
55
- modelCall?: import("../gates/model-gate.js").ModelCallSettings;
56
54
  /**
57
55
  * How the Runtime may call MCP servers and HTTP tools (Host settings). Default: http and
58
56
  * private addresses allowed.
59
57
  */
60
58
  delivery?: OutboundPolicy;
61
- /** Bounds the default Tenant sweep interval (`sweepIntervalMs`). Default 30 s. */
59
+ /** Bounds the default Tenant sweep interval (`sweepIntervalMs`). Default: no bound. */
62
60
  leaseMs?: number;
63
- /** Ownership lease of an advance (§10.6); renewed every third while it runs. Default 30 s. */
61
+ /**
62
+ * Ownership lease of an advance (§10.6); renewed every third while it runs. Default the Host
63
+ * tuning's `tenant.ownerLeaseMs` (30 s).
64
+ */
64
65
  ownerLeaseMs?: number;
65
66
  /**
66
67
  * Delay between Tenant sweep passes when the Tenant runs its own in-process execution.
67
- * Default `min(leaseMs, 5 s)`. A Host-level execution sets its own.
68
+ * Default `min(leaseMs, sweep.intervalMs)` (Host tuning, 5 s). A Host-level execution sets its
69
+ * own.
68
70
  */
69
71
  sweepIntervalMs?: number;
70
- /** Operator flow limits (`RuntimeOptions.flow` / `workflows.md` §13). */
71
- flow?: Partial<FlowLimits>;
72
- /**
73
- * Optional env snapshot for `NYLORUN_FLOW_*`. Host passes this; the Runtime
74
- * never reads ambient process environment for flow limits.
75
- */
76
- flowEnv?: Readonly<Record<string, string | undefined>>;
77
72
  /**
78
73
  * The trusted issuers whose JWTs the Runtime API accepts (Host feature `trusted-issuers`), from
79
74
  * the identity file (`NYLORUN_IDENTITY_FILE`). Absent: none.
@@ -4,14 +4,6 @@ import type { AdvanceResult, SandboxResult, SandboxTrigger, DurableExecution, St
4
4
  import type { Logger } from "./types.js";
5
5
  /** This process's Worker id: the `owner` it writes on the sessions it advances (§10.6). */
6
6
  export declare const WORKER_ID: string;
7
- /**
8
- * Default advance deadline: 50 minutes, below the one-hour inactivity and abort timeouts the
9
- * Restate adapter sets on the session object, so an advance always ends before Restate gives
10
- * up on it.
11
- */
12
- export declare const DEFAULT_ADVANCE_DEADLINE_MS: number;
13
- /** Default time an aborted advance has to settle before it is abandoned. */
14
- export declare const DEFAULT_ADVANCE_GRACE_MS = 30000;
15
7
  /** Why an advance's signal aborted (see "Abort reasons" above). */
16
8
  export type AdvanceAbortKind = AbortReason;
17
9
  /**
@@ -48,11 +40,11 @@ export interface TenantWorker {
48
40
  export interface TenantWorkersOptions {
49
41
  /** Finds or opens a Tenant that is not registered on this process. */
50
42
  resolve?: (tenantId: string) => Promise<TenantWorker | undefined>;
51
- /** How long one advance may run before its signal aborts. Default `DEFAULT_ADVANCE_DEADLINE_MS`. */
43
+ /** How long one advance may run before its signal aborts. Default `execution.advanceDeadlineMs` (Host tuning, 50 minutes). */
52
44
  advanceDeadlineMs?: number;
53
45
  /**
54
46
  * How long an advance whose signal aborted has to return before it is abandoned.
55
- * Default `DEFAULT_ADVANCE_GRACE_MS`.
47
+ * Default `execution.advanceGraceMs` (Host tuning, 30 s).
56
48
  */
57
49
  advanceGraceMs?: number;
58
50
  /** Receives a warning for each abandoned advance. */
@@ -51,16 +51,9 @@
51
51
  import { hostname } from "node:os";
52
52
  import { randomBytes } from "node:crypto";
53
53
  import { RunAbort } from "@nylorun/harness/api";
54
+ import { hostTuning, MAX_TIMER_MS } from "../tuning.js";
54
55
  /** This process's Worker id: the `owner` it writes on the sessions it advances (§10.6). */
55
56
  export const WORKER_ID = `worker-${hostname()}-${process.pid}-${randomBytes(4).toString("hex")}`;
56
- /**
57
- * Default advance deadline: 50 minutes, below the one-hour inactivity and abort timeouts the
58
- * Restate adapter sets on the session object, so an advance always ends before Restate gives
59
- * up on it.
60
- */
61
- export const DEFAULT_ADVANCE_DEADLINE_MS = 50 * 60_000;
62
- /** Default time an aborted advance has to settle before it is abandoned. */
63
- export const DEFAULT_ADVANCE_GRACE_MS = 30_000;
64
57
  /**
65
58
  * The abort reason of an advance. A harness run's reason (`RunAbort`) has the same kinds, so the
66
59
  * executors read either one.
@@ -109,8 +102,8 @@ export class TenantWorkers {
109
102
  graceMs;
110
103
  constructor(options = {}) {
111
104
  this.options = options;
112
- this.deadlineMs = positive("advanceDeadlineMs", options.advanceDeadlineMs ?? DEFAULT_ADVANCE_DEADLINE_MS);
113
- this.graceMs = positive("advanceGraceMs", options.advanceGraceMs ?? DEFAULT_ADVANCE_GRACE_MS);
105
+ this.deadlineMs = positive("advanceDeadlineMs", options.advanceDeadlineMs ?? hostTuning().execution.advanceDeadlineMs);
106
+ this.graceMs = positive("advanceGraceMs", options.advanceGraceMs ?? hostTuning().execution.advanceGraceMs);
114
107
  }
115
108
  /** Registers an open Tenant's worker; the returned function unregisters exactly it. */
116
109
  register(tenantId, worker) {
@@ -187,10 +180,8 @@ export class TenantWorkers {
187
180
  }
188
181
  }
189
182
  }
190
- /** The longest delay `setTimeout` keeps (about 24.8 days). */
191
- const MAX_TIMEOUT_MS = 2 ** 31 - 1;
192
183
  function positive(name, value) {
193
- if (!Number.isFinite(value) || value <= 0 || value > MAX_TIMEOUT_MS)
194
- throw new Error(`${name} must be positive and at most ${MAX_TIMEOUT_MS}`);
184
+ if (!Number.isFinite(value) || value <= 0 || value > MAX_TIMER_MS)
185
+ throw new Error(`${name} must be positive and at most ${MAX_TIMER_MS}`);
195
186
  return value;
196
187
  }
@@ -45,7 +45,11 @@ export function parseTraceparent(value) {
45
45
  return undefined;
46
46
  return { traceId: traceId, spanId: spanId };
47
47
  }
48
- /** The most `tracestate` the Runtime keeps (W3C: 32 members, 512 characters is enough). */
48
+ /**
49
+ * The most `tracestate` the Runtime keeps: W3C Trace Context (Level 1, section 3.3.1.1) has
50
+ * vendors propagate at least 512 characters of it, and lets one cut what is past that. A
51
+ * standard's constant, not a limit (B15).
52
+ */
49
53
  const TRACESTATE_MAX = 512;
50
54
  /**
51
55
  * The trace context a request's headers carry (R7.4), or undefined without a valid
@@ -25,7 +25,8 @@
25
25
  * never carries a person's id (`ownerUserId`, a subject, who approved), an identity header, an
26
26
  * idempotency key or a credential value (the log holds none). Content (what a person said, the
27
27
  * model's output, tool results and error messages) is left out unless the installation opts in
28
- * per kind (`TraceContent`), each value cut at 8 KiB. Prompts are not in the log, so never here.
28
+ * per kind (`TraceContent`), each value cut at the Tenant's Runtime limit `traceContentBytes`
29
+ * (`SpanSettings.contentBytes`). Prompts are not in the log, so never here.
29
30
  */
30
31
  import type { LiveEvent } from "@nylorun/core/contracts";
31
32
  import { type TraceKey } from "./ids.js";
@@ -39,8 +40,6 @@ export declare const GENAI_SEMCONV = "open-telemetry/semantic-conventions-genai@
39
40
  export declare const TRACE_CONTENT_KINDS: readonly ["user", "outputs", "tool-results", "errors"];
40
41
  export type TraceContentKind = (typeof TRACE_CONTENT_KINDS)[number];
41
42
  export type TraceContent = ReadonlySet<TraceContentKind>;
42
- /** The most bytes of one content attribute or status message. */
43
- export declare const CONTENT_MAX_BYTES: number;
44
43
  /** OTLP span kinds and status codes (opentelemetry-proto `trace.proto`). */
45
44
  export declare const SPAN_KIND: {
46
45
  readonly internal: 1;
@@ -93,10 +92,14 @@ export interface TurnTrace {
93
92
  /** What a person sent, as `gen_ai.input.messages` (only with `user` content). */
94
93
  readonly input?: string;
95
94
  }
96
- /** How spans are made: the trace key and the content the installation exports. */
95
+ /**
96
+ * How spans are made: the trace key, the content the installation exports, and the most UTF-8
97
+ * bytes of one content attribute (the Tenant's Runtime limit `traceContentBytes`).
98
+ */
97
99
  export interface SpanSettings {
98
100
  readonly key: TraceKey;
99
101
  readonly content: TraceContent;
102
+ readonly contentBytes: number;
100
103
  }
101
104
  /**
102
105
  * The trace of turn `turnId` of session `sessionId`, from its `command.message` when the log has
@@ -109,5 +112,5 @@ export declare function turnTraceOf(settings: SpanSettings, ids: {
109
112
  }, message?: Pick<LiveEvent, "payload" | "principal"> | undefined): TurnTrace;
110
113
  /** The span `row` makes in its turn's trace, or undefined when it makes none. */
111
114
  export declare function spanOf(row: LiveEvent, turn: TurnTrace, settings: SpanSettings): OtlpSpan | undefined;
112
- /** `value` cut to `CONTENT_MAX_BYTES` of UTF-8, never in the middle of a character. */
113
- export declare function truncate(value: string): string;
115
+ /** `value` cut to `maxBytes` of UTF-8, never in the middle of a character. */
116
+ export declare function truncate(value: string, maxBytes: number): string;
@@ -7,8 +7,6 @@ export const GENAI_SEMCONV = "open-telemetry/semantic-conventions-genai@6fd0d763
7
7
  * (error messages; their codes are always exported).
8
8
  */
9
9
  export const TRACE_CONTENT_KINDS = ["user", "outputs", "tool-results", "errors"];
10
- /** The most bytes of one content attribute or status message. */
11
- export const CONTENT_MAX_BYTES = 8 * 1024;
12
10
  /** OTLP span kinds and status codes (opentelemetry-proto `trace.proto`). */
13
11
  export const SPAN_KIND = { internal: 1, client: 3 };
14
12
  export const STATUS = { unset: 0, ok: 1, error: 2 };
@@ -19,7 +17,7 @@ export const STATUS = { unset: 0, ok: 1, error: 2 };
19
17
  export function turnTraceOf(settings, ids, message) {
20
18
  const payload = (message?.payload ?? {});
21
19
  const inbound = typeof payload.trace?.traceparent === "string" ? parseTraceparent(payload.trace.traceparent) : undefined;
22
- const input = settings.content.has("user") && message ? userMessages(payload) : undefined;
20
+ const input = settings.content.has("user") && message ? userMessages(payload, settings.contentBytes) : undefined;
23
21
  return {
24
22
  traceId: inbound?.traceId ?? traceIdOf(settings.key, ids.tenantId, ids.sessionId, ids.turnId),
25
23
  spanId: turnSpanOf(settings.key, ids.turnId),
@@ -52,7 +50,7 @@ export function spanOf(row, turn, settings) {
52
50
  const effectSpan = (effectId) => typeof effectId === "string" && effectId.length > 0
53
51
  ? effectSpanOf(settings.key, effectId)
54
52
  : eventSpanOf(settings.key, row.sessionId, row.seq);
55
- const content = (kind, value) => settings.content.has(kind) && value !== undefined ? truncate(typeof value === "string" ? value : JSON.stringify(value)) : undefined;
53
+ const content = (kind, value) => settings.content.has(kind) && value !== undefined ? truncate(typeof value === "string" ? value : JSON.stringify(value), settings.contentBytes) : undefined;
56
54
  switch (row.type) {
57
55
  case "turn.completed":
58
56
  case "turn.failed":
@@ -132,7 +130,6 @@ export function spanOf(row, turn, settings) {
132
130
  .str("nylorun.effect.id", p.effectId)
133
131
  .int("nylorun.effect.window_ms", p.durationMs)
134
132
  .str("nylorun.compaction.trigger", row.type === "context.compacted" ? p.trigger : undefined)
135
- .bool("nylorun.compaction.partial", row.type === "context.compacted" && p.partial === true ? true : undefined)
136
133
  .str("error.type", row.type === "model.failed" ? p.code : undefined)
137
134
  .str("gen_ai.output.messages", output);
138
135
  return {
@@ -158,6 +155,7 @@ export function spanOf(row, turn, settings) {
158
155
  .str("gen_ai.agent.id", p.agent?.id)
159
156
  .str("nylorun.tool.kind", kind)
160
157
  .str("nylorun.tool.server", p.server)
158
+ .str("nylorun.tool.identity", p.tool)
161
159
  .str("nylorun.tool.status", p.status)
162
160
  .int("nylorun.tool.attempts", p.attempts)
163
161
  .int("nylorun.tool.redacted", p.redacted)
@@ -264,7 +262,7 @@ function textPart(value) {
264
262
  return { type: "text", content: typeof value === "string" ? value : JSON.stringify(value) };
265
263
  }
266
264
  /** What a person sent (`command.message`), as `gen_ai.input.messages`. */
267
- function userMessages(payload) {
265
+ function userMessages(payload, maxBytes) {
268
266
  const parts = typeof payload.content === "string"
269
267
  ? [{ type: "text", content: payload.content }]
270
268
  : Array.isArray(payload.parts)
@@ -274,14 +272,14 @@ function userMessages(payload) {
274
272
  : payload.data !== undefined
275
273
  ? [textPart(payload.data)]
276
274
  : undefined;
277
- return parts ? truncate(JSON.stringify([{ role: "user", parts }])) : undefined;
275
+ return parts ? truncate(JSON.stringify([{ role: "user", parts }]), maxBytes) : undefined;
278
276
  }
279
- /** `value` cut to `CONTENT_MAX_BYTES` of UTF-8, never in the middle of a character. */
280
- export function truncate(value) {
277
+ /** `value` cut to `maxBytes` of UTF-8, never in the middle of a character. */
278
+ export function truncate(value, maxBytes) {
281
279
  const bytes = Buffer.from(value, "utf8");
282
- if (bytes.length <= CONTENT_MAX_BYTES)
280
+ if (bytes.length <= maxBytes)
283
281
  return value;
284
- let end = CONTENT_MAX_BYTES;
282
+ let end = maxBytes;
285
283
  // Back up over continuation bytes (10xxxxxx) to the start of the cut character.
286
284
  while (end > 0 && (bytes[end] & 0xc0) === 0x80)
287
285
  end -= 1;
@@ -28,11 +28,11 @@ export interface OtlpPosterOptions {
28
28
  /** `OTEL_EXPORTER_OTLP_HEADERS`. */
29
29
  readonly headers?: Readonly<Record<string, string>>;
30
30
  readonly resource: TraceResource;
31
- /** Tries after the first, for a `429`, a `5xx` or a lost connection. Default 3. */
31
+ /** Tries after the first, for a `429`, a `5xx` or a lost connection. Default `traces.retries` (Host tuning, 3). */
32
32
  readonly retries?: number;
33
- /** The wait before the first retry, doubled for each one after. Default 500 ms. */
33
+ /** The wait before the first retry, doubled for each one after. Default `traces.backoffMs` (500 ms). */
34
34
  readonly backoffMs?: number;
35
- /** How long one request may take. Default 10 s. */
35
+ /** How long one request may take. Default `traces.timeoutMs` (10 s). */
36
36
  readonly timeoutMs?: number;
37
37
  readonly fetch?: typeof fetch;
38
38
  readonly log?: (message: string, fields?: Record<string, unknown>) => void;
@@ -10,6 +10,7 @@
10
10
  */
11
11
  import { RUNTIME_VERSION } from "../version.js";
12
12
  import { GENAI_SEMCONV } from "./map.js";
13
+ import { hostTuning } from "../tuning.js";
13
14
  export const DEFAULT_SERVICE_NAME = "nylorun";
14
15
  /** The instrumentation scope of every span. */
15
16
  const SCOPE = { name: "@nylorun/runtime", version: RUNTIME_VERSION };
@@ -27,9 +28,10 @@ export function resourceSpans(resource, spans) {
27
28
  }
28
29
  export function createOtlpPoster(options) {
29
30
  const send = options.fetch ?? fetch;
30
- const retries = options.retries ?? 3;
31
- const backoffMs = options.backoffMs ?? 500;
32
- const timeoutMs = options.timeoutMs ?? 10_000;
31
+ const tuning = hostTuning().traces;
32
+ const retries = options.retries ?? tuning.retries;
33
+ const backoffMs = options.backoffMs ?? tuning.backoffMs;
34
+ const timeoutMs = options.timeoutMs ?? tuning.timeoutMs;
33
35
  const log = options.log ?? (() => { });
34
36
  return async (spans, signal) => {
35
37
  if (spans.length === 0)
@@ -27,16 +27,21 @@ export interface TraceProjectorOptions {
27
27
  readonly post: OtlpPoster;
28
28
  /** The Tenant's trace key (`traces/key.ts`). */
29
29
  readonly key: () => Promise<TraceKey>;
30
+ /** The Tenant's Runtime limit `traceContentBytes`, read for each transaction mapped. */
31
+ readonly contentBytes: () => Promise<number>;
30
32
  /** The `command.message` that started turn `turnId`, or undefined when the log has none. */
31
33
  readonly turnMessage: (sessionId: string, turnId: string) => Promise<LiveEvent | undefined>;
32
34
  readonly content: TraceContent;
33
- /** Spans per post. Default 512. */
35
+ /** Spans per post. Default `traces.batchSpans` (Host tuning, 512). */
34
36
  readonly maxBatch?: number;
35
- /** How long a span waits for its batch to fill. Default 2 s. */
37
+ /** How long a span waits for its batch to fill. Default `traces.batchDelayMs` (2 s). */
36
38
  readonly maxDelayMs?: number;
37
- /** Spans waiting while a post is out, past which the waiting ones are dropped. Default 8192. */
39
+ /**
40
+ * Spans waiting while a post is out, past which the waiting ones are dropped. Default
41
+ * `traces.queuedSpansMax` (8192).
42
+ */
38
43
  readonly maxQueuedSpans?: number;
39
- /** Turns whose trace is kept. Default 1024. */
44
+ /** Turns whose trace is kept. Default `traces.turnCacheSize` (1024). */
40
45
  readonly turnCacheSize?: number;
41
46
  readonly log?: (message: string, fields?: Record<string, unknown>) => void;
42
47
  }