@happyvertical/smrt-ingestion 0.55.12 → 0.55.14
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/FEEDBACK.md +6 -0
- package/PROPOSALS.md +8 -0
- package/README.md +26 -1
- package/REVIEW.md +31 -0
- package/agents/execution.md +2 -1
- package/dist/chunks/{execution-C7sTFXFU.js → execution-TWeIv0o-.js} +2 -2
- package/dist/chunks/{execution-C7sTFXFU.js.map → execution-TWeIv0o-.js.map} +1 -1
- package/dist/chunks/{feedback-C3OHD4sA.js → feedback-DmuvGO2o.js} +17 -7
- package/dist/chunks/feedback-DmuvGO2o.js.map +1 -0
- package/dist/chunks/{proposal-errors-z24VKWnQ.js → proposal-errors-BQjFXSOt.js} +15 -2
- package/dist/chunks/proposal-errors-BQjFXSOt.js.map +1 -0
- package/dist/execution.js +1 -1
- package/dist/feedback.d.ts +4 -0
- package/dist/feedback.d.ts.map +1 -1
- package/dist/index.js +2 -16
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +3 -21
- package/dist/models.js +1 -1
- package/dist/models.js.map +1 -1
- package/dist/proposal-dto.d.ts +4 -0
- package/dist/proposal-dto.d.ts.map +1 -1
- package/dist/proposal-limits.d.ts +4 -0
- package/dist/proposal-limits.d.ts.map +1 -0
- package/dist/proposals.d.ts.map +1 -1
- package/dist/proposals.js +18 -22
- package/dist/proposals.js.map +1 -1
- package/dist/recipes.d.ts +2 -16
- package/dist/recipes.d.ts.map +1 -1
- package/dist/review-analysis.d.ts +10 -0
- package/dist/review-analysis.d.ts.map +1 -0
- package/dist/review-host.d.ts +26 -0
- package/dist/review-host.d.ts.map +1 -0
- package/dist/review-summary.d.ts +9 -0
- package/dist/review-summary.d.ts.map +1 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +166 -3
- package/dist/server.js.map +1 -1
- package/dist/smrt-knowledge.json +20 -38
- package/package.json +17 -17
- package/dist/chunks/feedback-C3OHD4sA.js.map +0 -1
- package/dist/chunks/proposal-errors-z24VKWnQ.js.map +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IntakeItemDTO } from './dto.js';
|
|
2
|
+
import type { InboxState, ReviewPage } from './review-dto.js';
|
|
3
|
+
import type { IngestionService } from './server.js';
|
|
4
|
+
/** Whole-item state requires each page's live handler, parent and target gates. */
|
|
5
|
+
export declare function loadReviewSummary(service: IngestionService, item: IntakeItemDTO, requestedCursor?: string): Promise<{
|
|
6
|
+
reviews: ReviewPage;
|
|
7
|
+
state: InboxState;
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=review-summary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review-summary.d.ts","sourceRoot":"","sources":["../src/review-summary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,mFAAmF;AACnF,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,aAAa,EACnB,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC;IAAE,OAAO,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,CAAC,CA2CrD"}
|
package/dist/server.d.ts
CHANGED
|
@@ -220,5 +220,6 @@ export declare class IngestionService {
|
|
|
220
220
|
export * from './extraction.js';
|
|
221
221
|
export type * from './feedback-contracts.js';
|
|
222
222
|
export { GenerationSnapshotStaleError } from './proposal-errors.js';
|
|
223
|
+
export { createIntakeReviewHost, type IntakeReviewHostOptions, } from './review-host.js';
|
|
223
224
|
export * from './sources/index.js';
|
|
224
225
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,KAAK,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAS1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,YAAY,EACZ,aAAa,EACd,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,KAAK,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAS1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EACV,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,YAAY,EACZ,aAAa,EACd,MAAM,UAAU,CAAC;AAGlB,OAAO,aAAa,CAAC;AACrB,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,EACpB,WAAW,EACZ,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EACV,yBAAyB,EACzB,qBAAqB,EACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB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C,gBAAgB,EAAE,MAAM,CAAA;KAAE,CAAC,EAC5D,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,OAAO,CAAC,MAAM,CAAC;IAgDlB,4EAA4E;IACtE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAI7B,cAAc;IAiD5B,uFAAuF;IACjF,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC;IAiFxC,oFAAoF;IAC9E,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC;CAsBxC;AAED,cAAc,iBAAiB,CAAC;AAChC,mBAAmB,yBAAyB,CAAC;AAC7C,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EACL,sBAAsB,EACtB,KAAK,uBAAuB,GAC7B,MAAM,kBAAkB,CAAC;AAC1B,cAAc,oBAAoB,CAAC"}
|
package/dist/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./models.js";
|
|
2
2
|
import { n as generationSnapshotRead } from "./chunks/execution-internal-DWteDHM2.js";
|
|
3
|
-
import { i as proposeDocumentSplits, n as createSDKExtractionAdapter, r as extractAnalysis, t as GenerationSnapshotStaleError } from "./chunks/proposal-errors-
|
|
3
|
+
import { a as assertProposalLimits, i as proposeDocumentSplits, n as createSDKExtractionAdapter, r as extractAnalysis, t as GenerationSnapshotStaleError } from "./chunks/proposal-errors-BQjFXSOt.js";
|
|
4
4
|
import { detectEngine, isEmbeddedDatabase, isTransientDatabaseError, withEmbeddedWriteTransaction } from "@happyvertical/smrt-core";
|
|
5
5
|
import { withTenant } from "@happyvertical/smrt-tenancy";
|
|
6
6
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -9,6 +9,168 @@ import { SmrtJobCollection } from "@happyvertical/smrt-jobs";
|
|
|
9
9
|
import { join } from "node:path";
|
|
10
10
|
import { constants } from "node:fs";
|
|
11
11
|
import { lstat, mkdir, open, readFile, readdir, rename, writeFile } from "node:fs/promises";
|
|
12
|
+
//#region src/review-analysis.ts
|
|
13
|
+
async function loadReviewAnalysis(service, item, reviews, cursor) {
|
|
14
|
+
if (!["completed", "partial"].includes(item.processingState) || reviews.generationStale) return { reviews };
|
|
15
|
+
try {
|
|
16
|
+
return {
|
|
17
|
+
reviews,
|
|
18
|
+
analysis: await service.getCompletedAnalysis(item.id)
|
|
19
|
+
};
|
|
20
|
+
} catch (error) {
|
|
21
|
+
if (!(error instanceof GenerationSnapshotStaleError)) throw error;
|
|
22
|
+
return { reviews: await service.listReviews(item.id, { cursor }) };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/review-summary.ts
|
|
27
|
+
async function loadReviewSummary(service, item, requestedCursor) {
|
|
28
|
+
let requested;
|
|
29
|
+
if (requestedCursor !== void 0) requested = await service.listReviews(item.id, { cursor: requestedCursor });
|
|
30
|
+
let cursor;
|
|
31
|
+
let total = 0, succeeded = 0, deferred = 0, failed = 0;
|
|
32
|
+
const cursors = /* @__PURE__ */ new Set();
|
|
33
|
+
do {
|
|
34
|
+
const page = await service.listReviews(item.id, { cursor });
|
|
35
|
+
if (requestedCursor === void 0 && cursor === void 0) requested = page;
|
|
36
|
+
for (const action of page.actions) {
|
|
37
|
+
total++;
|
|
38
|
+
if (action.review.state === "succeeded") succeeded++;
|
|
39
|
+
if (action.review.state === "deferred") deferred++;
|
|
40
|
+
if (["failed", "outcome_unknown"].includes(action.review.state)) failed++;
|
|
41
|
+
}
|
|
42
|
+
cursor = page.nextCursor;
|
|
43
|
+
if (cursor && cursors.has(cursor)) throw new Error("Repeated review cursor");
|
|
44
|
+
if (cursor) cursors.add(cursor);
|
|
45
|
+
} while (cursor);
|
|
46
|
+
const current = await service.getItem(item.id);
|
|
47
|
+
if (!requested) throw new Error("Review page unavailable");
|
|
48
|
+
const state = total ? succeeded === total ? "completed" : succeeded ? "partially_completed" : deferred ? "deferred" : failed ? "failed" : "waiting" : ["queued", "running"].includes(current.processingState) ? "processing" : current.processingState === "needs_attention" ? "failed" : "unresolved";
|
|
49
|
+
return {
|
|
50
|
+
reviews: requested,
|
|
51
|
+
state
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/review-host.ts
|
|
56
|
+
function createIntakeReviewHost(service, options) {
|
|
57
|
+
const label = options.label ?? ((item) => `Intake ${item.id.slice(0, 8)}`);
|
|
58
|
+
const entry = async (item) => {
|
|
59
|
+
const { state } = await loadReviewSummary(service, item);
|
|
60
|
+
const assignment = await options.assignment(item.id);
|
|
61
|
+
await service.getItem(item.id);
|
|
62
|
+
return {
|
|
63
|
+
item,
|
|
64
|
+
label: label(item),
|
|
65
|
+
state,
|
|
66
|
+
assignment
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
return {
|
|
70
|
+
async list(input) {
|
|
71
|
+
const items = (await service.listItems()).sort((a, b) => a.id.localeCompare(b.id)).filter((item) => !input.cursor || item.id > input.cursor).slice(0, 21);
|
|
72
|
+
const projected = [];
|
|
73
|
+
for (const item of items.slice(0, 20)) {
|
|
74
|
+
const current = await entry(item);
|
|
75
|
+
if ((!input.state || current.state === input.state) && (!input.assigneeId || current.assignment.assigneeId === input.assigneeId)) projected.push(current);
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
items: projected,
|
|
79
|
+
...items.length > 20 ? { nextCursor: items[19].id } : {}
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
async load(itemId, cursor) {
|
|
83
|
+
const item = await service.getItem(itemId);
|
|
84
|
+
const summary = await loadReviewSummary(service, item, cursor);
|
|
85
|
+
const { analysis, reviews } = await loadReviewAnalysis(service, item, summary.reviews, cursor);
|
|
86
|
+
const evidence = [];
|
|
87
|
+
for (const part of await service.getEvidence(itemId)) evidence.push({
|
|
88
|
+
...await options.evidence(part),
|
|
89
|
+
evidence: part
|
|
90
|
+
});
|
|
91
|
+
const assignment = await options.assignment(itemId);
|
|
92
|
+
await service.getItem(itemId);
|
|
93
|
+
return {
|
|
94
|
+
entry: {
|
|
95
|
+
item,
|
|
96
|
+
label: label(item),
|
|
97
|
+
state: summary.state,
|
|
98
|
+
assignment
|
|
99
|
+
},
|
|
100
|
+
evidence,
|
|
101
|
+
analysis,
|
|
102
|
+
reviews,
|
|
103
|
+
availability: "available",
|
|
104
|
+
...analysis?.configuration.stage === "interpret" ? { generation: analysis.result.output.proposals } : {}
|
|
105
|
+
};
|
|
106
|
+
},
|
|
107
|
+
upload: (files, requestId) => options.upload(files, requestId),
|
|
108
|
+
async preview(input) {
|
|
109
|
+
if (!Number.isSafeInteger(input.index) || input.index < 0 || typeof input.attemptId !== "string" || !input.attemptId || typeof input.requestId !== "string" || !input.requestId.trim()) throw new Error("Invalid preview");
|
|
110
|
+
const analysis = await service.getCompletedAnalysis(input.itemId, input.attemptId);
|
|
111
|
+
const generation = analysis.result.output.proposals;
|
|
112
|
+
if (analysis.configuration.stage !== "interpret" || generation?.suggestions[input.index]?.disposition !== "ready_for_review") throw new Error("Preview unavailable");
|
|
113
|
+
const suggestion = generation.suggestions[input.index];
|
|
114
|
+
const handler = generation.offered.find(({ handler: handler2 }) => handler2.id === suggestion.handlerId && handler2.version === suggestion.handlerVersion)?.handler;
|
|
115
|
+
if (!handler) throw new Error("Preview unavailable");
|
|
116
|
+
const intentionKey = `ui:${input.index}`;
|
|
117
|
+
const actionId = handler.kind === "plan" ? void 0 : await service.createAction(input.itemId, intentionKey, {
|
|
118
|
+
origin: "generated-proposal",
|
|
119
|
+
intentionKey
|
|
120
|
+
});
|
|
121
|
+
let cursor;
|
|
122
|
+
let expectedRevision = 0;
|
|
123
|
+
const cursors = /* @__PURE__ */ new Set();
|
|
124
|
+
do {
|
|
125
|
+
const page = await service.listReviews(input.itemId, { cursor });
|
|
126
|
+
const found = page.actions.find((action) => handler.kind === "plan" ? (action.plan?.key ?? action.stalePlan?.key) === intentionKey : action.review.actionId === actionId);
|
|
127
|
+
if (found) {
|
|
128
|
+
const binding = handler.kind === "plan" ? found.plan : found;
|
|
129
|
+
expectedRevision = handler.kind === "plan" ? found.plan?.revision ?? found.stalePlan?.revision ?? 0 : found.review.revision;
|
|
130
|
+
if (binding?.attemptId === input.attemptId && binding.handlerId === suggestion.handlerId && binding.handlerVersion === suggestion.handlerVersion && binding.args) {
|
|
131
|
+
const { intakeBindingDigest } = await import("./execution.js");
|
|
132
|
+
if (intakeBindingDigest(binding.args) === intakeBindingDigest(suggestion.args)) return;
|
|
133
|
+
}
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
cursor = page.nextCursor;
|
|
137
|
+
if (cursor && cursors.has(cursor)) throw new Error("Repeated review cursor");
|
|
138
|
+
if (cursor) cursors.add(cursor);
|
|
139
|
+
} while (cursor);
|
|
140
|
+
await service.previewGeneratedProposals({
|
|
141
|
+
itemId: input.itemId,
|
|
142
|
+
attemptId: input.attemptId,
|
|
143
|
+
selections: [{
|
|
144
|
+
index: input.index,
|
|
145
|
+
intentionKey,
|
|
146
|
+
expectedRevision,
|
|
147
|
+
requestId: input.requestId
|
|
148
|
+
}]
|
|
149
|
+
});
|
|
150
|
+
},
|
|
151
|
+
async decide(input) {
|
|
152
|
+
await service.submitDecision(input);
|
|
153
|
+
},
|
|
154
|
+
apply: (actionId) => service.applyAction(actionId),
|
|
155
|
+
async editPlan(input) {
|
|
156
|
+
await service.previewPlan(input);
|
|
157
|
+
},
|
|
158
|
+
async editAction(input) {
|
|
159
|
+
await service.previewProposal(input);
|
|
160
|
+
},
|
|
161
|
+
candidates: (input) => service.findCandidates(input),
|
|
162
|
+
async assign(input) {
|
|
163
|
+
await service.getItem(input.itemId);
|
|
164
|
+
await options.assign(input);
|
|
165
|
+
},
|
|
166
|
+
async split(input) {
|
|
167
|
+
const result = await service.reviseLogicalSplit(input);
|
|
168
|
+
await options.onSplit?.(input.itemId, result.revision);
|
|
169
|
+
},
|
|
170
|
+
...options.enableFeedback ? { feedback: (input) => service.recordFeedback(input) } : {}
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
//#endregion
|
|
12
174
|
//#region src/sources/common.ts
|
|
13
175
|
var SourceInputError = class extends Error {
|
|
14
176
|
constructor(category) {
|
|
@@ -614,6 +776,7 @@ function date(value) {
|
|
|
614
776
|
var IngestionService = class {
|
|
615
777
|
constructor(options) {
|
|
616
778
|
this.options = options;
|
|
779
|
+
if (options.proposals) assertProposalLimits(options.proposals.limits);
|
|
617
780
|
this.db = options.db;
|
|
618
781
|
this.scope = Object.freeze({ ...options.scope });
|
|
619
782
|
if (!uuid.test(this.scope.tenantId)) throw new Error("Required tenant UUID");
|
|
@@ -681,7 +844,7 @@ var IngestionService = class {
|
|
|
681
844
|
return (await this.proposals()).preview(input);
|
|
682
845
|
}
|
|
683
846
|
async feedback() {
|
|
684
|
-
const { IntakeFeedbackService } = await import("./chunks/feedback-
|
|
847
|
+
const { IntakeFeedbackService } = await import("./chunks/feedback-DmuvGO2o.js").then((n) => n.r);
|
|
685
848
|
return new IntakeFeedbackService(this.options);
|
|
686
849
|
}
|
|
687
850
|
async recordFeedback(input) {
|
|
@@ -1675,6 +1838,6 @@ var IngestionService = class {
|
|
|
1675
1838
|
}
|
|
1676
1839
|
};
|
|
1677
1840
|
//#endregion
|
|
1678
|
-
export { EmailSourceAdapter, GenerationSnapshotStaleError, IngestionService, WatchFolderSourceAdapter, createSDKExtractionAdapter, createSourceDeliveryHandler, createVendorWebhookHandler, extractAnalysis, proposeDocumentSplits };
|
|
1841
|
+
export { EmailSourceAdapter, GenerationSnapshotStaleError, IngestionService, WatchFolderSourceAdapter, createIntakeReviewHost, createSDKExtractionAdapter, createSourceDeliveryHandler, createVendorWebhookHandler, extractAnalysis, proposeDocumentSplits };
|
|
1679
1842
|
|
|
1680
1843
|
//# sourceMappingURL=server.js.map
|