@kici-dev/agent 0.1.14 → 0.1.16
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 +13 -1
- package/dist/diagnostics/mini-bundle.d.ts +9 -0
- package/dist/execution/cache/cache-engine.d.ts +62 -0
- package/dist/execution/cache/cache-phase.d.ts +29 -0
- package/dist/execution/cache/index.d.ts +9 -0
- package/dist/execution/dynamic-job-serializer.d.ts +12 -1
- package/dist/execution/env-init/init-phase.d.ts +64 -0
- package/dist/execution/init-runner.d.ts +1 -1
- package/dist/execution/job-runner.d.ts +30 -0
- package/dist/execution/sandbox/env-delta.d.ts +44 -0
- package/dist/execution/sandbox/env-file.d.ts +39 -0
- package/dist/execution/sandbox/index.d.ts +1 -1
- package/dist/execution/sandbox/ipc-protocol.d.ts +111 -3
- package/dist/execution/sandbox/job-deadline.d.ts +13 -0
- package/dist/execution/sandbox/step-loop.d.ts +53 -1
- package/dist/execution/sandbox/types.d.ts +20 -1
- package/dist/execution/sandbox/workflow-runner.d.ts +9 -1
- package/dist/execution/tmp-gc.d.ts +17 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +342 -12
- package/dist/server.js +623 -168
- package/dist/workflow-runner.js +2001 -950
- package/dist/ws/orchestrator-client.d.ts +55 -3
- package/package.json +16 -10
- package/sbom.spdx.json +1923 -148
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { type AgentToOrchestratorMessage, type JobDispatch, type JobCancel } from '@kici-dev/engine';
|
|
1
|
+
import { type AgentToOrchestratorMessage, type JobDispatch, type JobCancel, type FleetLogsRequest } from '@kici-dev/engine';
|
|
2
|
+
import type { CacheRequestIpc, CacheResponseIpc, StepApprovalRequestIpc, StepApprovalResolvedIpc } from '../execution/sandbox/index.js';
|
|
2
3
|
export type ConnectionState = 'disconnected' | 'connecting' | 'authenticating' | 'registering' | 'registered';
|
|
3
|
-
interface OrchestratorClientOptions {
|
|
4
|
+
export interface OrchestratorClientOptions {
|
|
4
5
|
/** WebSocket URL of the orchestrator. */
|
|
5
6
|
url: string;
|
|
6
7
|
/** Agent's unique identifier. */
|
|
@@ -34,6 +35,18 @@ interface OrchestratorClientOptions {
|
|
|
34
35
|
* doesn't have to read process.env directly.
|
|
35
36
|
*/
|
|
36
37
|
scalerManaged?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Supplies the inputs for the agent fleet mini-bundle on a fleet.logs.request.
|
|
40
|
+
* Returns the agent's resolved config (redacted inside the bundle assembler),
|
|
41
|
+
* the log directory, and the current Prometheus metrics text. Omitted in
|
|
42
|
+
* tests / contexts that don't participate in fleet collection — the handler
|
|
43
|
+
* then replies with an empty-config bundle.
|
|
44
|
+
*/
|
|
45
|
+
getFleetBundleInputs?: () => Promise<{
|
|
46
|
+
config: Record<string, unknown>;
|
|
47
|
+
logDir?: string;
|
|
48
|
+
metricsText?: string;
|
|
49
|
+
}>;
|
|
37
50
|
}
|
|
38
51
|
/**
|
|
39
52
|
* WebSocket client that connects the agent to the customer orchestrator.
|
|
@@ -67,6 +80,15 @@ export declare class OrchestratorClient {
|
|
|
67
80
|
private readonly pendingEventEmitRequests;
|
|
68
81
|
/** Pending agent.api.request calls awaiting orchestrator response. */
|
|
69
82
|
private readonly pendingApiRequests;
|
|
83
|
+
/** Pending user-cache restore/save requests awaiting orchestrator response. */
|
|
84
|
+
private readonly pendingUserCacheRequests;
|
|
85
|
+
/**
|
|
86
|
+
* Pending step-approval requests awaiting the orchestrator's resolution.
|
|
87
|
+
* No client-side timeout: the orchestrator owns the (org-/SDK-configured)
|
|
88
|
+
* expiry and sends `step.approval-resolved: expired` when it lapses. The
|
|
89
|
+
* workflow-runner carries an outer safety-net timeout.
|
|
90
|
+
*/
|
|
91
|
+
private readonly pendingStepApprovals;
|
|
70
92
|
/** Pending concurrency report requests awaiting orchestrator ack. */
|
|
71
93
|
private readonly pendingConcurrencyRequests;
|
|
72
94
|
private readonly url;
|
|
@@ -80,6 +102,7 @@ export declare class OrchestratorClient {
|
|
|
80
102
|
private readonly getInFlightJobs?;
|
|
81
103
|
private readonly roles;
|
|
82
104
|
private readonly scalerManaged;
|
|
105
|
+
private readonly getFleetBundleInputs?;
|
|
83
106
|
/** Timestamp when the connection was lost, used for gap marker outage duration. */
|
|
84
107
|
private disconnectedAt;
|
|
85
108
|
/** Set to true when auth.failure is received. Prevents retrying with a bad token. */
|
|
@@ -177,6 +200,12 @@ export declare class OrchestratorClient {
|
|
|
177
200
|
deliveryId?: string;
|
|
178
201
|
error?: string;
|
|
179
202
|
}>;
|
|
203
|
+
/**
|
|
204
|
+
* Build this agent's fleet mini-bundle and stream it back to the orchestrator
|
|
205
|
+
* as ordered fleet.bundle.chunk frames (the WS frame cap forbids one frame).
|
|
206
|
+
* On failure, sends a single fleet.bundle.error. Public for unit testing.
|
|
207
|
+
*/
|
|
208
|
+
streamFleetBundle(req: FleetLogsRequest): Promise<void>;
|
|
180
209
|
/**
|
|
181
210
|
* Send a typed API request to the orchestrator and await the response.
|
|
182
211
|
*
|
|
@@ -184,6 +213,30 @@ export declare class OrchestratorClient {
|
|
|
184
213
|
* KiciApi interface calls this with dot-namespaced method names.
|
|
185
214
|
*/
|
|
186
215
|
sendApiRequest(method: string, params?: Record<string, unknown>): Promise<unknown>;
|
|
216
|
+
/**
|
|
217
|
+
* Relay a user-facing cache request from the sandbox to the orchestrator.
|
|
218
|
+
*
|
|
219
|
+
* Translates the sandbox `cache.request` IPC into the matching `cache.user.*`
|
|
220
|
+
* WS message and resolves with the orchestrator's response mapped onto the
|
|
221
|
+
* IPC response shape:
|
|
222
|
+
*
|
|
223
|
+
* - `restore` -> `cache.user.restore.request`, awaits `cache.user.restore.response`.
|
|
224
|
+
* - `beginSave` -> `cache.user.save.request`, awaits `cache.user.save.response`.
|
|
225
|
+
* - `completeSave` -> `cache.user.save.complete` (fire-and-forget; the
|
|
226
|
+
* orchestrator commits temp -> final without replying), resolves immediately.
|
|
227
|
+
*
|
|
228
|
+
* Times out after 30 seconds for the round-trip ops.
|
|
229
|
+
*/
|
|
230
|
+
requestUserCache(jobId: string, request: CacheRequestIpc): Promise<CacheResponseIpc>;
|
|
231
|
+
/**
|
|
232
|
+
* Relay a step-level approval request to the orchestrator. Sends a
|
|
233
|
+
* `step.approval-request` WS message and resolves with the orchestrator's
|
|
234
|
+
* `step.approval-resolved` mapped onto the IPC response shape. No client-side
|
|
235
|
+
* timeout — the orchestrator owns the approval expiry and replies with an
|
|
236
|
+
* `expired` outcome when it lapses. Rejects only on disconnect (the relay
|
|
237
|
+
* caller treats a rejection as a fail-closed reject).
|
|
238
|
+
*/
|
|
239
|
+
sendStepApproval(runId: string, jobId: string, request: StepApprovalRequestIpc): Promise<StepApprovalResolvedIpc>;
|
|
187
240
|
/**
|
|
188
241
|
* Send a job.context message to the orchestrator.
|
|
189
242
|
*
|
|
@@ -265,5 +318,4 @@ export declare class OrchestratorClient {
|
|
|
265
318
|
private scheduleReconnect;
|
|
266
319
|
private cancelReconnect;
|
|
267
320
|
}
|
|
268
|
-
export {};
|
|
269
321
|
//# sourceMappingURL=orchestrator-client.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kici-dev/agent",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "Customer-deployable agent for the KiCI CI/CD stack. Connects to an orchestrator, clones the workflow repo, executes steps, and streams logs back.",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"kici",
|
|
7
6
|
"ci",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
7
|
+
"cicd",
|
|
8
|
+
"continuous-integration",
|
|
10
9
|
"typescript",
|
|
11
|
-
"
|
|
12
|
-
"devops",
|
|
10
|
+
"workflow",
|
|
13
11
|
"agent",
|
|
14
12
|
"runner"
|
|
15
13
|
],
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/kici-dev/kici-public.git",
|
|
17
|
+
"directory": "packages/agent"
|
|
18
|
+
},
|
|
19
|
+
"bugs": "https://github.com/kici-dev/kici-public/issues",
|
|
16
20
|
"homepage": "https://kici.dev",
|
|
17
21
|
"author": {
|
|
18
22
|
"name": "KiCI",
|
|
@@ -50,6 +54,7 @@
|
|
|
50
54
|
},
|
|
51
55
|
"dependencies": {
|
|
52
56
|
"@hono/node-server": "^2.0.0",
|
|
57
|
+
"archiver": "^7.0.1",
|
|
53
58
|
"dockerode": "^5.0.0",
|
|
54
59
|
"hono": "^4.12.18",
|
|
55
60
|
"tar": "^7.5.13",
|
|
@@ -57,10 +62,10 @@
|
|
|
57
62
|
"ws": "^8.20.0",
|
|
58
63
|
"zod": "^4.3.6",
|
|
59
64
|
"zx": "^8.8.5",
|
|
60
|
-
"@kici-dev/core": "0.1.
|
|
61
|
-
"@kici-dev/engine": "0.1.
|
|
62
|
-
"@kici-dev/
|
|
63
|
-
"@kici-dev/
|
|
65
|
+
"@kici-dev/core": "0.1.16",
|
|
66
|
+
"@kici-dev/engine": "0.1.16",
|
|
67
|
+
"@kici-dev/shared": "0.1.16",
|
|
68
|
+
"@kici-dev/sdk": "0.1.16"
|
|
64
69
|
},
|
|
65
70
|
"kici": {
|
|
66
71
|
"metrics": {
|
|
@@ -69,6 +74,7 @@
|
|
|
69
74
|
}
|
|
70
75
|
},
|
|
71
76
|
"devDependencies": {
|
|
77
|
+
"@types/archiver": "^7.0.0",
|
|
72
78
|
"@types/dockerode": "^4.0.1"
|
|
73
79
|
},
|
|
74
80
|
"scripts": {
|