@cluesmith/codev-core 3.3.4 → 3.3.6
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/dist/agent-state.d.ts +36 -0
- package/dist/agent-state.d.ts.map +1 -0
- package/dist/agent-state.js +44 -0
- package/dist/agent-state.js.map +1 -0
- package/package.json +9 -3
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { AgentActivity, NeedsInputDetail, ServedAgentState } from '@cluesmith/codev-types';
|
|
2
|
+
/** Tower's liveness verdict for an agent. */
|
|
3
|
+
export interface AgentLivenessFact {
|
|
4
|
+
/** `null` when liveness could not be determined. */
|
|
5
|
+
alive: boolean | null;
|
|
6
|
+
/** ISO time the current `alive` value was first published. */
|
|
7
|
+
since: string;
|
|
8
|
+
}
|
|
9
|
+
/** The latest accepted lifecycle report for an agent. */
|
|
10
|
+
export interface ReportedActivityFact {
|
|
11
|
+
activity: AgentActivity;
|
|
12
|
+
/** ISO time the current activity began. */
|
|
13
|
+
since: string;
|
|
14
|
+
/** ISO hook time of the latest accepted report. */
|
|
15
|
+
at: string;
|
|
16
|
+
backgroundWork: boolean;
|
|
17
|
+
/** Held only while `activity` is `needs-input`. */
|
|
18
|
+
needsInput?: NeedsInputDetail;
|
|
19
|
+
}
|
|
20
|
+
export interface AgentStateFacts {
|
|
21
|
+
/** Whether porch reports a requested, pending gate (the overview's `detectBlocked`). */
|
|
22
|
+
blocked: boolean;
|
|
23
|
+
/** ISO time the gate was requested, when known. */
|
|
24
|
+
blockedSince: string | null;
|
|
25
|
+
/**
|
|
26
|
+
* The builder's display `phase` (the field the sdk predicate reads). Pass `''` for
|
|
27
|
+
* an architect, which has no porch phase.
|
|
28
|
+
*/
|
|
29
|
+
phase: string;
|
|
30
|
+
liveness: AgentLivenessFact | null;
|
|
31
|
+
reported: ReportedActivityFact | null;
|
|
32
|
+
/** ISO time to use when a `since` is otherwise unknown. */
|
|
33
|
+
now: string;
|
|
34
|
+
}
|
|
35
|
+
export declare function projectAgentState(facts: AgentStateFacts): ServedAgentState | null;
|
|
36
|
+
//# sourceMappingURL=agent-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-state.d.ts","sourceRoot":"","sources":["../src/agent-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAqBhC,6CAA6C;AAC7C,MAAM,WAAW,iBAAiB;IAChC,oDAAoD;IACpD,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IACtB,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;CACf;AAED,yDAAyD;AACzD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,aAAa,CAAC;IACxB,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,OAAO,CAAC;IACxB,mDAAmD;IACnD,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AAED,MAAM,WAAW,eAAe;IAC9B,wFAAwF;IACxF,OAAO,EAAE,OAAO,CAAC;IACjB,mDAAmD;IACnD,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACnC,QAAQ,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACtC,2DAA2D;IAC3D,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,eAAe,GAAG,gBAAgB,GAAG,IAAI,CA8BjF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent-state projection (Spec 1595): the one policy that turns Tower's facts about
|
|
3
|
+
* an agent into the `ServedAgentState` served on the overview.
|
|
4
|
+
*
|
|
5
|
+
* Precedence, first match wins:
|
|
6
|
+
* 1. `blocked` — porch reports a requested, pending gate. The caller computes this
|
|
7
|
+
* with the overview's existing `detectBlocked`; nothing here parses `status.yaml`
|
|
8
|
+
* or holds a gate list (Constraint 14).
|
|
9
|
+
* 2. `dead` — the agent process is gone, unless the builder is `complete` or
|
|
10
|
+
* `verified` (the normal end of a lane, not an alert).
|
|
11
|
+
* 3. the reported activity — `needs-input`, `working` or `idle`.
|
|
12
|
+
* 4. otherwise `null` (unknown).
|
|
13
|
+
*
|
|
14
|
+
* Pure: no I/O, no clock reads (the caller passes `now`).
|
|
15
|
+
*/
|
|
16
|
+
/** Porch phases at which a builder's lane is finished. Mirrors the sdk predicate's check. */
|
|
17
|
+
const FINISHED_PHASES = new Set(['complete', 'verified']);
|
|
18
|
+
export function projectAgentState(facts) {
|
|
19
|
+
const alive = facts.liveness?.alive ?? null;
|
|
20
|
+
const reported = facts.reported;
|
|
21
|
+
// The raw inputs ride on every served row, whatever wins precedence, so a consumer
|
|
22
|
+
// (#1672) can build its own chain from the same facts. The needs-input detail is part
|
|
23
|
+
// of them: it follows the raw `activity`, not the served `state`.
|
|
24
|
+
const raw = {
|
|
25
|
+
alive,
|
|
26
|
+
activity: reported?.activity ?? null,
|
|
27
|
+
activityAt: reported?.at ?? null,
|
|
28
|
+
backgroundWork: reported?.backgroundWork ?? false,
|
|
29
|
+
};
|
|
30
|
+
if (reported?.activity === 'needs-input' && reported.needsInput) {
|
|
31
|
+
raw.needsInput = reported.needsInput;
|
|
32
|
+
}
|
|
33
|
+
if (facts.blocked) {
|
|
34
|
+
return { state: 'blocked', since: facts.blockedSince ?? facts.now, source: 'tower', ...raw };
|
|
35
|
+
}
|
|
36
|
+
if (alive === false && !FINISHED_PHASES.has(facts.phase)) {
|
|
37
|
+
return { state: 'dead', since: facts.liveness.since, source: 'tower', ...raw };
|
|
38
|
+
}
|
|
39
|
+
if (reported) {
|
|
40
|
+
return { state: reported.activity, since: reported.since, source: 'harness', ...raw };
|
|
41
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,QAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,EAAE,CAAC;IAClF,CAAC;IAED,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,GAAG,EAAE,CAAC;IACxF,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cluesmith/codev-core",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.6",
|
|
4
4
|
"description": "Server-side runtime for Codev — local-key issuance and homedir-derived paths. Client-side Tower access lives in @cluesmith/codev-sdk; the two packages never import each other.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
"./constants": {
|
|
12
12
|
"types": "./dist/constants.d.ts",
|
|
13
13
|
"default": "./dist/constants.js"
|
|
14
|
+
},
|
|
15
|
+
"./agent-state": {
|
|
16
|
+
"types": "./dist/agent-state.d.ts",
|
|
17
|
+
"default": "./dist/agent-state.js"
|
|
14
18
|
}
|
|
15
19
|
},
|
|
16
20
|
"files": [
|
|
@@ -19,10 +23,12 @@
|
|
|
19
23
|
"devDependencies": {
|
|
20
24
|
"@types/node": "22.x",
|
|
21
25
|
"typescript": "^6.0.3",
|
|
22
|
-
"vitest": "^4.0.15"
|
|
23
|
-
"@cluesmith/codev-types": "3.3.4"
|
|
26
|
+
"vitest": "^4.0.15"
|
|
24
27
|
},
|
|
25
28
|
"license": "Apache-2.0",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@cluesmith/codev-types": "3.3.6"
|
|
31
|
+
},
|
|
26
32
|
"scripts": {
|
|
27
33
|
"build": "tsc",
|
|
28
34
|
"check-types": "tsc --noEmit",
|