@kici-dev/agent 0.0.0 → 0.1.2

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 (50) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +1 -6
  3. package/dist/checkout/git-clone.d.ts +59 -0
  4. package/dist/checkout/ssh-auth.d.ts +34 -0
  5. package/dist/config.d.ts +109 -0
  6. package/dist/execution/console-capture.d.ts +35 -0
  7. package/dist/execution/dep-installer.d.ts +44 -0
  8. package/dist/execution/dep-packer.d.ts +25 -0
  9. package/dist/execution/dep-restore.d.ts +85 -0
  10. package/dist/execution/download.d.ts +29 -0
  11. package/dist/execution/dynamic-job-serializer.d.ts +51 -0
  12. package/dist/execution/hook-executor.d.ts +46 -0
  13. package/dist/execution/init-runner.d.ts +33 -0
  14. package/dist/execution/job-runner.d.ts +266 -0
  15. package/dist/execution/log-streamer.d.ts +126 -0
  16. package/dist/execution/npm-registry-config.d.ts +63 -0
  17. package/dist/execution/npm-resolver.d.ts +40 -0
  18. package/dist/execution/overlay-applier.d.ts +51 -0
  19. package/dist/execution/rule-evaluator.d.ts +11 -0
  20. package/dist/execution/sandbox/bare-metal-sandbox.d.ts +69 -0
  21. package/dist/execution/sandbox/container-sandbox.d.ts +100 -0
  22. package/dist/execution/sandbox/env-sanitizer.d.ts +43 -0
  23. package/dist/execution/sandbox/firecracker-sandbox.d.ts +65 -0
  24. package/dist/execution/sandbox/fork-runner.d.ts +94 -0
  25. package/dist/execution/sandbox/index.d.ts +14 -0
  26. package/dist/execution/sandbox/ipc-protocol.d.ts +311 -0
  27. package/dist/execution/sandbox/log-masker.d.ts +45 -0
  28. package/dist/execution/sandbox/secret-encryption.d.ts +37 -0
  29. package/dist/execution/sandbox/secret-merge.d.ts +18 -0
  30. package/dist/execution/sandbox/step-loop.d.ts +77 -0
  31. package/dist/execution/sandbox/types.d.ts +142 -0
  32. package/dist/execution/sandbox/workflow-runner.d.ts +17 -0
  33. package/dist/execution/source-packer.d.ts +18 -0
  34. package/dist/execution/source-restore.d.ts +23 -0
  35. package/dist/execution/timeout-util.d.ts +11 -0
  36. package/dist/execution/workflow-loader.d.ts +70 -0
  37. package/dist/index.d.ts +2 -0
  38. package/dist/index.js +128 -0
  39. package/dist/metrics/metrics-reporter.d.ts +32 -0
  40. package/dist/metrics/prometheus.d.ts +95 -0
  41. package/dist/routes/health.d.ts +27 -0
  42. package/dist/server.d.ts +20 -0
  43. package/dist/server.js +5347 -0
  44. package/dist/workflow-runner.js +2978 -0
  45. package/dist/ws/event-buffer.d.ts +16 -0
  46. package/dist/ws/log-buffer.d.ts +15 -0
  47. package/dist/ws/orchestrator-client.d.ts +269 -0
  48. package/package.json +59 -7
  49. package/sbom.spdx.json +10125 -0
  50. package/index.js +0 -3
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Total completed jobs.
3
+ * Labels:
4
+ * - status: success | failed | cancelled
5
+ * - scaler: injected by orch-side AgentMetricsAggregator (Phase 5b); `stateful` for static agents, backend name (`container` / `firecracker` / `bare-metal`) for scaler-managed
6
+ */
7
+ export declare const jobsTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
8
+ /**
9
+ * Currently running jobs.
10
+ * Labels:
11
+ * - scaler: injected by orch-side AgentMetricsAggregator (Phase 5b); `stateful` for static agents, backend name (`container` / `firecracker` / `bare-metal`) for scaler-managed
12
+ */
13
+ export declare const jobsActive: import("@opentelemetry/api").UpDownCounter<import("@opentelemetry/api").Attributes>;
14
+ /**
15
+ * Total completed steps.
16
+ * Labels:
17
+ * - status: success | failed | skipped
18
+ * - scaler: injected by orch-side AgentMetricsAggregator (Phase 5b); `stateful` for static agents, backend name (`container` / `firecracker` / `bare-metal`) for scaler-managed
19
+ */
20
+ export declare const stepsTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
21
+ /**
22
+ * Step execution duration in seconds.
23
+ * Advisory boundaries cover sub-second steps through 30-minute long-running steps.
24
+ * Labels:
25
+ * - scaler: injected by orch-side AgentMetricsAggregator (Phase 5b); `stateful` for static agents, backend name (`container` / `firecracker` / `bare-metal`) for scaler-managed
26
+ */
27
+ export declare const stepDurationSeconds: import("@opentelemetry/api").Histogram<import("@opentelemetry/api").Attributes>;
28
+ /**
29
+ * Git clone duration in seconds.
30
+ * Advisory boundaries cover fast shallow clones through large repo clones.
31
+ * Labels:
32
+ * - scaler: injected by orch-side AgentMetricsAggregator (Phase 5b); `stateful` for static agents, backend name (`container` / `firecracker` / `bare-metal`) for scaler-managed
33
+ */
34
+ export declare const cloneDurationSeconds: import("@opentelemetry/api").Histogram<import("@opentelemetry/api").Attributes>;
35
+ /**
36
+ * Total log bytes streamed back to orchestrator.
37
+ * Labels:
38
+ * - scaler: injected by orch-side AgentMetricsAggregator (Phase 5b); `stateful` for static agents, backend name (`container` / `firecracker` / `bare-metal`) for scaler-managed
39
+ */
40
+ export declare const logBytesTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
41
+ /**
42
+ * Rising-edge counter for log-streaming backpressure events.
43
+ *
44
+ * Incremented once each time a LogStreamer transitions from "normal" into
45
+ * a backpressured state. Not incremented again until the streamer
46
+ * recovers and trips again, so the series measures how often operators
47
+ * saw pressure — not how long it lasted. Pair with
48
+ * {@link logBackpressureActive} (current state) and
49
+ * {@link logLinesDroppedTotal} (cumulative loss) for a complete picture.
50
+ *
51
+ * Labels:
52
+ * - mode: `pause` (producer paused, no data loss) | `drop` (lines
53
+ * discarded with a `[N lines dropped due to backpressure]` marker)
54
+ * - scaler: injected by orch-side AgentMetricsAggregator (Phase 5b); `stateful` for static agents, backend name (`container` / `firecracker` / `bare-metal`) for scaler-managed
55
+ */
56
+ export declare const logBackpressureEventsTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
57
+ /**
58
+ * Cumulative log lines dropped by the backpressure "drop" mode.
59
+ *
60
+ * Incremented in batches by the LogStreamer whenever it emits the
61
+ * `[N lines dropped due to backpressure]` marker. Never decremented.
62
+ * A non-zero rate on this series means operators are losing real log
63
+ * content and should either expand the streamer's buffer or shrink the
64
+ * producer.
65
+ *
66
+ * Labels:
67
+ * - scaler: injected by orch-side AgentMetricsAggregator (Phase 5b); `stateful` for static agents, backend name (`container` / `firecracker` / `bare-metal`) for scaler-managed
68
+ */
69
+ export declare const logLinesDroppedTotal: import("@opentelemetry/api").Counter<import("@opentelemetry/api").Attributes>;
70
+ /**
71
+ * Current backpressure state as a 0/1 up/down counter.
72
+ *
73
+ * Toggles to 1 when a LogStreamer enters backpressure and back to 0 on
74
+ * recovery. Exposed as an up/down counter (not an observable gauge) so
75
+ * the existing LogStreamer callbacks can update it imperatively from
76
+ * both the single-job and step-streamer wiring paths.
77
+ *
78
+ * Grafana treats this as a step function: the area under the curve is
79
+ * the total time spent backpressured. Labelled with `mode` so dashboards
80
+ * can distinguish pause-mode from drop-mode pressure.
81
+ *
82
+ * Labels:
83
+ * - mode: `pause` | `drop`
84
+ * - scaler: injected by orch-side AgentMetricsAggregator (Phase 5b); `stateful` for static agents, backend name (`container` / `firecracker` / `bare-metal`) for scaler-managed
85
+ */
86
+ export declare const logBackpressureActive: import("@opentelemetry/api").UpDownCounter<import("@opentelemetry/api").Attributes>;
87
+ /**
88
+ * Orchestrator WebSocket connection status.
89
+ * Use add(1) for connected, add(-1) for disconnected.
90
+ *
91
+ * Labels:
92
+ * - scaler: injected by orch-side AgentMetricsAggregator (Phase 5b); `stateful` for static agents, backend name (`container` / `firecracker` / `bare-metal`) for scaler-managed
93
+ */
94
+ export declare const connectionStatus: import("@opentelemetry/api").UpDownCounter<import("@opentelemetry/api").Attributes>;
95
+ //# sourceMappingURL=prometheus.d.ts.map
@@ -0,0 +1,27 @@
1
+ import { Hono } from 'hono';
2
+ import { type MetricsRoutesDeps } from '@kici-dev/shared';
3
+ /**
4
+ * Health status provided by the agent runtime.
5
+ */
6
+ interface HealthStatus {
7
+ agentId: string;
8
+ connected: boolean;
9
+ activeJobs: number;
10
+ }
11
+ export interface HealthRoutesDeps extends MetricsRoutesDeps {
12
+ /** Function returning current agent health status */
13
+ getStatus: () => HealthStatus;
14
+ }
15
+ /**
16
+ * Create health, readiness, and metrics routes.
17
+ *
18
+ * Delegates liveness and readiness to the shared health route helper,
19
+ * adding agent-specific status info and a /metrics endpoint.
20
+ *
21
+ * - GET /health - Liveness probe (always 200, includes agent status)
22
+ * - GET /ready - Readiness probe (200 if connected, 503 if not)
23
+ * - GET /metrics - Prometheus metrics
24
+ */
25
+ export declare function createHealthRoutes(deps: HealthRoutesDeps): Hono;
26
+ export {};
27
+ //# sourceMappingURL=health.d.ts.map
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Agent entry point.
3
+ *
4
+ * Startup sequence:
5
+ * 1. Load config
6
+ * 2. Create logger
7
+ * 3. Create JobRunner with send/sendDirect callbacks
8
+ * 4. Create OrchestratorClient with dispatch and cancel handlers
9
+ * 5. Add WS log transport (if not scaler-managed)
10
+ * 6. Connect OrchestratorClient
11
+ * 7. Create Hono app with health routes
12
+ * 8. Start HTTP server
13
+ * 9. Register signal handlers
14
+ *
15
+ * Graceful shutdown:
16
+ * - SIGTERM/SIGINT: 10s grace for running jobs, then force-kill
17
+ * - SIGUSR1: Drain mode (stop accepting, finish current, exit)
18
+ */
19
+ export {};
20
+ //# sourceMappingURL=server.d.ts.map