@opengeni/runtime 0.6.1 → 0.7.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.
Files changed (45) hide show
  1. package/dist/{chunk-DYBF7ZEB.js → chunk-RYDCVTMW.js} +1958 -207
  2. package/dist/chunk-RYDCVTMW.js.map +1 -0
  3. package/dist/{index-BTo_bZvN.d.ts → index-DIiiwQY2.d.ts} +689 -52
  4. package/dist/index.d.ts +293 -123
  5. package/dist/index.js +1819 -790
  6. package/dist/index.js.map +1 -1
  7. package/dist/sandbox/index.d.ts +1 -1
  8. package/dist/sandbox/index.js +79 -3
  9. package/package.json +21 -20
  10. package/src/codex-tool-search.ts +185 -31
  11. package/src/context-compaction.ts +78 -243
  12. package/src/history-sanitizer.ts +172 -20
  13. package/src/index.ts +2573 -898
  14. package/src/metrics.ts +28 -2
  15. package/src/sandbox/capabilities.ts +12 -3
  16. package/src/sandbox/channel-a.ts +420 -72
  17. package/src/sandbox/display-stack.ts +18 -4
  18. package/src/sandbox/errors.ts +13 -0
  19. package/src/sandbox/index.ts +398 -112
  20. package/src/sandbox/op-correlation.ts +70 -0
  21. package/src/sandbox/providers/index.ts +9 -3
  22. package/src/sandbox/providers/modal.ts +84 -14
  23. package/src/sandbox/providers/selfhosted.ts +1 -4
  24. package/src/sandbox/recording.ts +146 -90
  25. package/src/sandbox/routing/backend-resolver.ts +144 -10
  26. package/src/sandbox/routing/routing-session.ts +129 -25
  27. package/src/sandbox/select.ts +60 -8
  28. package/src/sandbox/selfhosted/capabilities.ts +59 -25
  29. package/src/sandbox/selfhosted/control-rpc.ts +160 -28
  30. package/src/sandbox/selfhosted/fault-rendering.ts +226 -0
  31. package/src/sandbox/selfhosted/op-observer.ts +54 -0
  32. package/src/sandbox/selfhosted/op-stream.ts +801 -0
  33. package/src/sandbox/selfhosted/op-testing.ts +468 -0
  34. package/src/sandbox/selfhosted/op-transport.ts +151 -0
  35. package/src/sandbox/selfhosted/retry-policy.ts +177 -0
  36. package/src/sandbox/selfhosted/session.ts +498 -55
  37. package/src/sandbox/selfhosted/testing.ts +60 -19
  38. package/src/sandbox/stream-port.ts +17 -5
  39. package/src/sandbox/stream-token.ts +8 -2
  40. package/src/sandbox/terminal-server.ts +18 -4
  41. package/src/sandbox-computer.ts +332 -70
  42. package/src/usage-telemetry.ts +73 -0
  43. package/dist/chunk-DYBF7ZEB.js.map +0 -1
  44. package/src/image-history.ts +0 -149
  45. package/src/screenshot-omitted-card.ts +0 -15
@@ -0,0 +1,54 @@
1
+ // The transport-agnostic per-op observation seam for the Connected Machine
2
+ // (selfhosted) control path — the out-of-band audience of the failure-visibility
3
+ // doctrine (op outcomes + healed faults land in metrics + `machine.*` events so
4
+ // problems are learnable over time).
5
+ //
6
+ // It is DELIBERATELY transport-agnostic (op-shaped, not request/reply-shaped): the
7
+ // op-engine's future op-stream client (ENGINE-INTEGRATION.md step 6) emits through
8
+ // this SAME interface, so the metrics + `machine.*` events keep flowing unchanged
9
+ // across the transport swap. The runtime leaf only INVOKES the observer; the
10
+ // worker/api adapt it to the concrete sinks (a metrics hook, a durable session
11
+ // event), so the leaf stays agent-loop-free and db-free.
12
+
13
+ import type { ErrorCode } from "@opengeni/agent-proto";
14
+ import type { SelfhostedUnavailableReason } from "./control-rpc";
15
+
16
+ /**
17
+ * One completed control-op observation. `outcome` is the terminal result AFTER any
18
+ * in-call retries: `ok` (the op succeeded) or `failed` (a terminal fault surfaced).
19
+ * `healed` marks a success that only landed after ≥1 retry — the doctrine's
20
+ * "healed and invisible in-band, always out-of-band" breadcrumb (drives
21
+ * `machine.op.recovered`). Every field is derivable at the `SelfhostedSession.call`
22
+ * exit points with no extra round-trip.
23
+ */
24
+ export interface SelfhostedOpObservation {
25
+ /** The control-op kind (`ControlRequest["op"].$case`): exec / fsRead / ping / … */
26
+ op: string;
27
+ outcome: "ok" | "failed";
28
+ /** True when `outcome==="ok"` only after ≥1 in-call retry (draining/timeout/never-sent). */
29
+ healed: boolean;
30
+ /** Total in-call retries before this outcome (summed across the retry classes). */
31
+ retries: number;
32
+ /** Wall time from the first attempt to the terminal outcome, in ms. */
33
+ durationMs: number;
34
+ /** The typed wire code — present on `failed`. */
35
+ code?: ErrorCode;
36
+ /** The negotiated capability reason (agent_offline / agent_reconnecting / …), if any. */
37
+ reason?: SelfhostedUnavailableReason | null;
38
+ /** Whether a failed fault provably never reached the machine (a pre-send synthesis). */
39
+ neverSent?: boolean;
40
+ /** The enrolled machine (agent) id the op addressed — for machine-scoped fan-out. */
41
+ machineId?: string;
42
+ /** A stable fault-class string (`selfhostedFaultClass`): the fault class on a
43
+ * `failed` op, or the class of retries that a `healed` op recovered from. Absent
44
+ * on a clean success. Drives the `machine.op.*` event mapping + its infra filter. */
45
+ faultClass?: string;
46
+ /** The reply size in bytes when known — set on a PAYLOAD_TOO_LARGE fault (from the
47
+ * agent's `encoded_bytes` detail). The op-stream client fills the success-reply
48
+ * size once it owns the framed transport; today's request/reply does not surface it. */
49
+ replyBytes?: number;
50
+ }
51
+
52
+ /** A fire-and-forget observer of completed control ops. It MUST NOT throw (the
53
+ * session guards the call) and MUST NOT block the op — it is a telemetry tap. */
54
+ export type SelfhostedOpObserver = (observation: SelfhostedOpObservation) => void;