@exaudeus/workrail 1.7.4 → 1.7.5
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/manifest.json
CHANGED
|
@@ -694,8 +694,8 @@
|
|
|
694
694
|
"bytes": 471
|
|
695
695
|
},
|
|
696
696
|
"mcp/handlers/v2-resume.js": {
|
|
697
|
-
"sha256": "
|
|
698
|
-
"bytes":
|
|
697
|
+
"sha256": "851690a586328cb61a1aa0f9c2b8cac87b1a158430bab6e9601f63244a4dd69d",
|
|
698
|
+
"bytes": 3385
|
|
699
699
|
},
|
|
700
700
|
"mcp/handlers/v2-state-conversion.d.ts": {
|
|
701
701
|
"sha256": "94bd06904ef58dd210ff17ffb75c2492beea8937eb06d99749e5d860c0e0d96b",
|
|
@@ -1822,8 +1822,8 @@
|
|
|
1822
1822
|
"bytes": 1004
|
|
1823
1823
|
},
|
|
1824
1824
|
"v2/infra/local/session-summary-provider/index.js": {
|
|
1825
|
-
"sha256": "
|
|
1826
|
-
"bytes":
|
|
1825
|
+
"sha256": "a38c877faddb8e14bf1c30e173e4299af5edb4a1f8fb4b036732c6ba6f11ca6f",
|
|
1826
|
+
"bytes": 5933
|
|
1827
1827
|
},
|
|
1828
1828
|
"v2/infra/local/sha256/index.d.ts": {
|
|
1829
1829
|
"sha256": "8a727b7e54a38275ca6f9f1b8730f97cfc0a212df035df1bdc58e716e6824230",
|
|
@@ -2074,12 +2074,12 @@
|
|
|
2074
2074
|
"bytes": 732
|
|
2075
2075
|
},
|
|
2076
2076
|
"v2/projections/resume-ranking.d.ts": {
|
|
2077
|
-
"sha256": "
|
|
2078
|
-
"bytes":
|
|
2077
|
+
"sha256": "ca5cb0701edded54f08395deebfe50161528d36edb74294c26481501391e64bc",
|
|
2078
|
+
"bytes": 2558
|
|
2079
2079
|
},
|
|
2080
2080
|
"v2/projections/resume-ranking.js": {
|
|
2081
|
-
"sha256": "
|
|
2082
|
-
"bytes":
|
|
2081
|
+
"sha256": "aa6ba4b5480caebba3107f86058b9a834cbd89962d0340c89342417f77956e47",
|
|
2082
|
+
"bytes": 4251
|
|
2083
2083
|
},
|
|
2084
2084
|
"v2/projections/run-context.d.ts": {
|
|
2085
2085
|
"sha256": "a4d57470a435ac9860f60b3244d1b828853995027cd510d8da42762d21b2a687",
|
|
@@ -31,8 +31,28 @@ async function handleV2ResumeSession(input, ctx) {
|
|
|
31
31
|
return (0, types_js_1.errNotRetryable)('INTERNAL_ERROR', `Resume failed: ${resumeResult.error.message}`);
|
|
32
32
|
}
|
|
33
33
|
const candidates = resumeResult.value;
|
|
34
|
+
const { outputCandidates, skipped } = mintCandidateTokens(candidates, v2.tokenCodecPorts);
|
|
35
|
+
if (skipped > 0) {
|
|
36
|
+
console.error(`[workrail:resume] ${skipped}/${candidates.length} candidate(s) skipped: token minting failed (workflowHashRef derivation or signing error)`);
|
|
37
|
+
}
|
|
38
|
+
const output = output_schemas_js_1.V2ResumeSessionOutputSchema.parse({
|
|
39
|
+
candidates: outputCandidates,
|
|
40
|
+
totalEligible: candidates.length,
|
|
41
|
+
});
|
|
42
|
+
return {
|
|
43
|
+
type: 'success',
|
|
44
|
+
data: output,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function mintCandidateTokens(candidates, ports) {
|
|
34
48
|
const outputCandidates = [];
|
|
49
|
+
let skipped = 0;
|
|
35
50
|
for (const candidate of candidates) {
|
|
51
|
+
const wfRefRes = (0, index_js_1.deriveWorkflowHashRef)(candidate.workflowHash);
|
|
52
|
+
if (wfRefRes.isErr()) {
|
|
53
|
+
skipped++;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
36
56
|
const stateTokenRes = (0, v2_token_ops_js_1.signTokenOrErr)({
|
|
37
57
|
payload: {
|
|
38
58
|
tokenVersion: 1,
|
|
@@ -40,11 +60,12 @@ async function handleV2ResumeSession(input, ctx) {
|
|
|
40
60
|
sessionId: candidate.sessionId,
|
|
41
61
|
runId: (0, index_js_1.asRunId)(candidate.runId),
|
|
42
62
|
nodeId: (0, index_js_1.asNodeId)(candidate.preferredTipNodeId),
|
|
43
|
-
workflowHashRef:
|
|
63
|
+
workflowHashRef: wfRefRes.value,
|
|
44
64
|
},
|
|
45
|
-
ports
|
|
65
|
+
ports,
|
|
46
66
|
});
|
|
47
67
|
if (stateTokenRes.isErr()) {
|
|
68
|
+
skipped++;
|
|
48
69
|
continue;
|
|
49
70
|
}
|
|
50
71
|
outputCandidates.push({
|
|
@@ -55,12 +76,5 @@ async function handleV2ResumeSession(input, ctx) {
|
|
|
55
76
|
whyMatched: [...candidate.whyMatched],
|
|
56
77
|
});
|
|
57
78
|
}
|
|
58
|
-
|
|
59
|
-
candidates: outputCandidates,
|
|
60
|
-
totalEligible: candidates.length,
|
|
61
|
-
});
|
|
62
|
-
return {
|
|
63
|
-
type: 'success',
|
|
64
|
-
data: output,
|
|
65
|
-
};
|
|
79
|
+
return { outputCandidates, skipped };
|
|
66
80
|
}
|
|
@@ -7,6 +7,7 @@ const enumerate_sessions_js_1 = require("../../../usecases/enumerate-sessions.js
|
|
|
7
7
|
const session_health_js_1 = require("../../../projections/session-health.js");
|
|
8
8
|
const run_dag_js_1 = require("../../../projections/run-dag.js");
|
|
9
9
|
const node_outputs_js_1 = require("../../../projections/node-outputs.js");
|
|
10
|
+
const index_js_1 = require("../../../durable-core/ids/index.js");
|
|
10
11
|
const constants_js_1 = require("../../../durable-core/constants.js");
|
|
11
12
|
const MAX_SESSIONS_TO_SCAN = 50;
|
|
12
13
|
const MAX_RECAP_ANCESTOR_DEPTH = 100;
|
|
@@ -15,10 +16,6 @@ const EMPTY_OBSERVATIONS = {
|
|
|
15
16
|
gitBranch: null,
|
|
16
17
|
repoRootHash: null,
|
|
17
18
|
};
|
|
18
|
-
const UNKNOWN_WORKFLOW = {
|
|
19
|
-
workflowId: null,
|
|
20
|
-
workflowName: null,
|
|
21
|
-
};
|
|
22
19
|
class LocalSessionSummaryProviderV2 {
|
|
23
20
|
constructor(ports) {
|
|
24
21
|
this.ports = ports;
|
|
@@ -55,6 +52,9 @@ function projectSessionSummary(sessionId, truth) {
|
|
|
55
52
|
const bestRun = selectBestRun(Object.values(dag.value.runsById));
|
|
56
53
|
if (!bestRun)
|
|
57
54
|
return null;
|
|
55
|
+
const workflow = extractWorkflowIdentity(truth.events, bestRun.run.runId);
|
|
56
|
+
if (!workflow)
|
|
57
|
+
return null;
|
|
58
58
|
const outputsRes = (0, node_outputs_js_1.projectNodeOutputsV2)(truth.events);
|
|
59
59
|
const recapSnippet = outputsRes.isOk()
|
|
60
60
|
? extractAggregateRecap(outputsRes.value, bestRun.run, bestRun.tipNodeId)
|
|
@@ -68,7 +68,7 @@ function projectSessionSummary(sessionId, truth) {
|
|
|
68
68
|
},
|
|
69
69
|
recapSnippet,
|
|
70
70
|
observations: extractObservations(truth.events),
|
|
71
|
-
workflow
|
|
71
|
+
workflow,
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
function selectBestRun(runs) {
|
|
@@ -99,10 +99,13 @@ function extractWorkflowIdentity(events, runId) {
|
|
|
99
99
|
.filter((e) => e.kind === constants_js_1.EVENT_KIND.RUN_STARTED)
|
|
100
100
|
.find((e) => e.scope.runId === runId);
|
|
101
101
|
if (!event)
|
|
102
|
-
return
|
|
102
|
+
return null;
|
|
103
|
+
if (!constants_js_1.SHA256_DIGEST_PATTERN.test(event.data.workflowHash))
|
|
104
|
+
return null;
|
|
103
105
|
return {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
+
kind: 'identified',
|
|
107
|
+
workflowId: (0, index_js_1.asWorkflowId)(event.data.workflowId),
|
|
108
|
+
workflowHash: (0, index_js_1.asWorkflowHash)((0, index_js_1.asSha256Digest)(event.data.workflowHash)),
|
|
106
109
|
};
|
|
107
110
|
}
|
|
108
111
|
function collectAncestorNodeIds(nodesById, nodeId, remainingDepth) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SessionId } from '../durable-core/ids/index.js';
|
|
1
|
+
import type { SessionId, WorkflowHash, WorkflowId } from '../durable-core/ids/index.js';
|
|
2
2
|
export type RecapSnippet = string & {
|
|
3
3
|
readonly __brand: 'RecapSnippet';
|
|
4
4
|
};
|
|
@@ -8,10 +8,16 @@ export interface SessionObservations {
|
|
|
8
8
|
readonly gitBranch: string | null;
|
|
9
9
|
readonly repoRootHash: string | null;
|
|
10
10
|
}
|
|
11
|
-
export
|
|
12
|
-
readonly
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
export type WorkflowIdentity = {
|
|
12
|
+
readonly kind: 'unknown';
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: 'identified';
|
|
15
|
+
readonly workflowId: WorkflowId;
|
|
16
|
+
readonly workflowHash: WorkflowHash;
|
|
17
|
+
};
|
|
18
|
+
export type IdentifiedWorkflow = Extract<WorkflowIdentity, {
|
|
19
|
+
kind: 'identified';
|
|
20
|
+
}>;
|
|
15
21
|
export interface HealthySessionSummary {
|
|
16
22
|
readonly sessionId: SessionId;
|
|
17
23
|
readonly runId: string;
|
|
@@ -21,7 +27,7 @@ export interface HealthySessionSummary {
|
|
|
21
27
|
};
|
|
22
28
|
readonly recapSnippet: RecapSnippet | null;
|
|
23
29
|
readonly observations: SessionObservations;
|
|
24
|
-
readonly workflow:
|
|
30
|
+
readonly workflow: IdentifiedWorkflow;
|
|
25
31
|
}
|
|
26
32
|
export type WhyMatched = 'matched_head_sha' | 'matched_branch' | 'matched_notes' | 'matched_workflow_id' | 'recency_fallback';
|
|
27
33
|
export type TierAssignment = {
|
|
@@ -57,6 +63,7 @@ export interface RankedResumeCandidate {
|
|
|
57
63
|
readonly whyMatched: readonly WhyMatched[];
|
|
58
64
|
readonly tierAssignment: TierAssignment;
|
|
59
65
|
readonly lastActivityEventIndex: number;
|
|
66
|
+
readonly workflowHash: WorkflowHash;
|
|
60
67
|
}
|
|
61
68
|
export declare const MAX_RESUME_CANDIDATES = 5;
|
|
62
69
|
export declare function rankResumeCandidates(summaries: readonly HealthySessionSummary[], query: ResumeQuery): readonly RankedResumeCandidate[];
|
|
@@ -56,13 +56,9 @@ function assignTier(summary, query) {
|
|
|
56
56
|
return { tier: 3, kind: 'matched_notes' };
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
if (query.freeTextQuery) {
|
|
59
|
+
if (query.freeTextQuery && summary.workflow.kind === 'identified') {
|
|
60
60
|
const queryTokens = normalizeToTokens(query.freeTextQuery);
|
|
61
|
-
const
|
|
62
|
-
summary.workflow.workflowId ?? '',
|
|
63
|
-
summary.workflow.workflowName ?? '',
|
|
64
|
-
].join(' ');
|
|
65
|
-
const workflowTokens = normalizeToTokens(workflowText);
|
|
61
|
+
const workflowTokens = normalizeToTokens(String(summary.workflow.workflowId));
|
|
66
62
|
if (allQueryTokensMatch(queryTokens, workflowTokens)) {
|
|
67
63
|
return { tier: 4, kind: 'matched_workflow_id' };
|
|
68
64
|
}
|
|
@@ -101,5 +97,6 @@ function rankResumeCandidates(summaries, query) {
|
|
|
101
97
|
whyMatched: [tierToWhyMatched(tier)],
|
|
102
98
|
tierAssignment: tier,
|
|
103
99
|
lastActivityEventIndex: summary.preferredTip.lastActivityEventIndex,
|
|
100
|
+
workflowHash: summary.workflow.workflowHash,
|
|
104
101
|
}));
|
|
105
102
|
}
|