@konneal/engine 0.2.179 → 0.2.182
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/{ask-PWT4B6YE.js → ask-YWYXQ6PE.js} +4 -4
- package/dist/{chunk-CLDMP5YH.js → chunk-4J47P52J.js} +1 -1
- package/dist/{chunk-ROXOL4GF.js → chunk-VRWNS4AI.js} +2 -2
- package/dist/{chunk-KINFFYQH.js → chunk-YGQCVPX6.js} +6 -0
- package/dist/{chunk-LDSGL62W.js → chunk-YVQVT7GD.js} +7 -7
- package/dist/{chunk-MUWO2EV6.js → chunk-ZZGKC6WO.js} +2 -2
- package/dist/{env-CNO44VN2.js → env-BZWHCSCL.js} +1 -1
- package/dist/env.d.ts +2 -0
- package/dist/openapi-surface.gen.d.ts +1 -1
- package/dist/openapi-types.d.ts +160 -0
- package/dist/{search-KNPPTHMG.js → search-N37WULEM.js} +3 -3
- package/dist/{tools-UCUNOJR4.js → tools-HLA7O2ZK.js} +2 -2
- package/dist/userDocuments.d.ts +66 -0
- package/dist/worker_public/src/index.js +268 -7
- package/package.json +1 -1
- package/workers/worker_public/migrations/0020_user_documents.sql +18 -0
- package/workers/worker_public/openapi.yaml +72 -0
- package/workers/worker_public/schema.sql +16 -0
- package/workers/worker_public/src/ask.ts +13 -10
- package/workers/worker_public/src/env.ts +2 -0
- package/workers/worker_public/src/index.ts +48 -1
- package/workers/worker_public/src/openapi-surface.gen.ts +24 -0
- package/workers/worker_public/src/ports/cloudflare/adapters.ts +3 -0
- package/workers/worker_public/src/ports/vector.ts +3 -0
- package/workers/worker_public/src/userDocuments.ts +294 -0
- package/workers/worker_public/wrangler.toml +8 -0
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
handleAsk
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YVQVT7GD.js";
|
|
4
4
|
import "./chunk-IRCDOFP4.js";
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-VRWNS4AI.js";
|
|
6
|
+
import "./chunk-4J47P52J.js";
|
|
7
7
|
import "./chunk-ZHT4456M.js";
|
|
8
8
|
import "./chunk-D7MO4RVQ.js";
|
|
9
9
|
import "./chunk-ETLSWSZ7.js";
|
|
10
10
|
import "./chunk-FNQ7UOEB.js";
|
|
11
11
|
import "./chunk-HWWJAJWM.js";
|
|
12
12
|
import "./chunk-3FYJM7LH.js";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-YGQCVPX6.js";
|
|
14
14
|
export {
|
|
15
15
|
handleAsk
|
|
16
16
|
};
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
portIndex,
|
|
16
16
|
portModelRunner,
|
|
17
17
|
portStore
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-YGQCVPX6.js";
|
|
19
19
|
|
|
20
20
|
// workers/worker_public/src/refs.ts
|
|
21
21
|
var REF = /\[\[(u:(?:u:)?[A-Za-z0-9_-]+)\]\]/g;
|
|
@@ -1509,7 +1509,7 @@ async function runFind(env, args) {
|
|
|
1509
1509
|
};
|
|
1510
1510
|
}
|
|
1511
1511
|
try {
|
|
1512
|
-
const { portStore: portStore2 } = await import("./env-
|
|
1512
|
+
const { portStore: portStore2 } = await import("./env-BZWHCSCL.js");
|
|
1513
1513
|
const res = await portStore2(env).prepare(compiled.sql).bind(...compiled.params).all();
|
|
1514
1514
|
const rows = res?.results ?? [];
|
|
1515
1515
|
const body = rows.length ? rows.map((r) => JSON.stringify(r)).join("\n") : "No rows matched. Either the predicates are too narrow or the data is absent \u2014 state which, and consider widening.";
|
|
@@ -108,6 +108,9 @@ function cfVectorIndex(index) {
|
|
|
108
108
|
async upsert(vectors) {
|
|
109
109
|
for (const group of by20(vectors)) await ix.upsert(group);
|
|
110
110
|
},
|
|
111
|
+
async deleteIds(ids) {
|
|
112
|
+
for (const group of by20(ids)) await ix.deleteByIds(group);
|
|
113
|
+
},
|
|
111
114
|
async getByIds(ids) {
|
|
112
115
|
const out = [];
|
|
113
116
|
for (const group of by20(ids)) {
|
|
@@ -181,7 +184,10 @@ function portRuntime(ctx) {
|
|
|
181
184
|
}
|
|
182
185
|
|
|
183
186
|
export {
|
|
187
|
+
cfModelRunner,
|
|
188
|
+
cfVectorIndex,
|
|
184
189
|
cfBlobs,
|
|
190
|
+
cfStore,
|
|
185
191
|
portModelRunner,
|
|
186
192
|
portIndex,
|
|
187
193
|
portKv,
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
tableRetyped,
|
|
34
34
|
toolNote,
|
|
35
35
|
verdictNote
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-VRWNS4AI.js";
|
|
37
37
|
import {
|
|
38
38
|
NO_CONTEXT,
|
|
39
39
|
STAGE_NAMES,
|
|
@@ -76,7 +76,7 @@ import {
|
|
|
76
76
|
tokenBudget,
|
|
77
77
|
understandQuery,
|
|
78
78
|
usageTotal
|
|
79
|
-
} from "./chunk-
|
|
79
|
+
} from "./chunk-4J47P52J.js";
|
|
80
80
|
import {
|
|
81
81
|
embed,
|
|
82
82
|
generateOnce
|
|
@@ -118,7 +118,7 @@ import {
|
|
|
118
118
|
import {
|
|
119
119
|
portModelRunner,
|
|
120
120
|
portStore
|
|
121
|
-
} from "./chunk-
|
|
121
|
+
} from "./chunk-YGQCVPX6.js";
|
|
122
122
|
|
|
123
123
|
// workers/worker_public/src/internal_gateway.ts
|
|
124
124
|
async function retrieveInternal(service, auth, query) {
|
|
@@ -2967,14 +2967,14 @@ Answer account questions from these records ONLY: name the record when you use i
|
|
|
2967
2967
|
}
|
|
2968
2968
|
const tq2 = await chargeAnswerTokens(env, bucketId, stats, messageChars(messages), full.length, probeTokensUsed);
|
|
2969
2969
|
send({ type: "quota", quota: { ...quota, ...tq2, credits: await creditBudget(env, bucketId), credit_estimate: creditPreview } });
|
|
2970
|
-
if (
|
|
2970
|
+
if (register?.rows?.length && full.includes(refusalAnswer())) {
|
|
2971
2971
|
console.log("blind-answer(stream): regenerating once");
|
|
2972
2972
|
streamRestarts += 1;
|
|
2973
2973
|
mark("Re-answering from the register results");
|
|
2974
2974
|
send({ type: "retry" });
|
|
2975
2975
|
const regen = await generateStream(env, model, [
|
|
2976
2976
|
...messages.slice(0, -1),
|
|
2977
|
-
{ role: "user", content: "The
|
|
2977
|
+
{ role: "user", content: "The certificate register note above lists actual matching certificate rows. Present those rows \u2014 number, holder, model, status, and every document link \u2014 as the answer. Do not claim that nothing was provided." },
|
|
2978
2978
|
messages[messages.length - 1]
|
|
2979
2979
|
], routeEffort(routed.route));
|
|
2980
2980
|
if (regen) {
|
|
@@ -3207,12 +3207,12 @@ Answer account questions from these records ONLY: name the record when you use i
|
|
|
3207
3207
|
if (completionBlocks.length) console.log("contract completion:", completionBlocks.length, "table block(s) attached server-side");
|
|
3208
3208
|
}
|
|
3209
3209
|
completionBlocks.push(...await completeFigures(env.DB, answer, [...c2ns.blocks, ...completionBlocks], used, q2.query));
|
|
3210
|
-
if (
|
|
3210
|
+
if (register?.rows?.length && answer.includes(refusalAnswer())) {
|
|
3211
3211
|
console.log("blind-answer: the register note carried rows but the answer refused \u2014 regenerating once");
|
|
3212
3212
|
mark("Re-answering from the register results");
|
|
3213
3213
|
const regen = await generateOnce(env, model, [
|
|
3214
3214
|
...messages.slice(0, -1),
|
|
3215
|
-
{ role: "user", content: "The
|
|
3215
|
+
{ role: "user", content: "The certificate register note above lists actual matching certificate rows. Present those rows \u2014 number, holder, model, status, and every document link \u2014 as the answer. Do not claim that nothing was provided." },
|
|
3216
3216
|
messages[messages.length - 1]
|
|
3217
3217
|
], effort);
|
|
3218
3218
|
if (regen && !regen.includes(refusalAnswer())) {
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
sessionFrom,
|
|
7
7
|
telemetry,
|
|
8
8
|
understandQuery
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4J47P52J.js";
|
|
10
10
|
import {
|
|
11
11
|
corsHeaders,
|
|
12
12
|
err,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
} from "./chunk-HWWJAJWM.js";
|
|
27
27
|
import {
|
|
28
28
|
portModelRunner
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-YGQCVPX6.js";
|
|
30
30
|
|
|
31
31
|
// workers/worker_public/src/search.ts
|
|
32
32
|
async function handleSearch(env, ctx, req, tier, key) {
|
package/dist/env.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export interface OpenApiRoute {
|
|
|
3
3
|
pattern: string;
|
|
4
4
|
operationId: string;
|
|
5
5
|
}
|
|
6
|
-
export type OpenApiOperationId = "credits" | "creditsAlias" | "askAnonymous" | "askKeyed" | "search" | "searchKeyed" | "verify" | "verifyKeyed" | "research" | "researchKeyed" | "mcp" | "datasets" | "keyUsage" | "health" | "listConversations" | "createConversation" | "getConversation" | "renameConversation" | "deleteConversation" | "appendMessage" | "shareConversation" | "getShared" | "uploadAttachment" | "listAttachments" | "getAttachment" | "deleteAttachment" | "listMemories" | "createMemory" | "deleteMemory" | "listProjects" | "createProject" | "deleteProject" | "listProjectFiles" | "attachProjectFile" | "detachProjectFile" | "laneQuery" | "laneKeyed" | "feedback" | "adminEnrich" | "adminEnrichAlias" | "adminSection" | "adminFamilySummary" | "adminSectionAlias" | "adminFamilySummaryAlias" | "adminVectors" | "adminCaption" | "adminVisionJudge" | "adminJudge" | "adminJudgeAlias" | "adminRevokeKey" | "authMe" | "authLogin" | "authCallback" | "authLogout" | "authLogoutLink" | "adminStats" | "adminListKeys" | "adminCreateKey";
|
|
6
|
+
export type OpenApiOperationId = "credits" | "creditsAlias" | "askAnonymous" | "askKeyed" | "search" | "searchKeyed" | "verify" | "verifyKeyed" | "research" | "researchKeyed" | "mcp" | "datasets" | "keyUsage" | "health" | "listConversations" | "createConversation" | "getConversation" | "renameConversation" | "deleteConversation" | "appendMessage" | "shareConversation" | "getShared" | "uploadAttachment" | "listAttachments" | "getAttachment" | "deleteAttachment" | "listMemories" | "createMemory" | "deleteMemory" | "listUserDocuments" | "createUserDocument" | "getUserDocument" | "deleteUserDocument" | "listProjects" | "createProject" | "deleteProject" | "listProjectFiles" | "attachProjectFile" | "detachProjectFile" | "laneQuery" | "laneKeyed" | "feedback" | "adminEnrich" | "adminEnrichAlias" | "adminSection" | "adminFamilySummary" | "adminSectionAlias" | "adminFamilySummaryAlias" | "adminVectors" | "adminCaption" | "adminVisionJudge" | "adminJudge" | "adminJudgeAlias" | "adminRevokeKey" | "authMe" | "authLogin" | "authCallback" | "authLogout" | "authLogoutLink" | "adminStats" | "adminListKeys" | "adminCreateKey";
|
|
7
7
|
export declare const OPENAPI_SURFACE: readonly (Omit<OpenApiRoute, "operationId"> & {
|
|
8
8
|
operationId: OpenApiOperationId;
|
|
9
9
|
})[];
|
package/dist/openapi-types.d.ts
CHANGED
|
@@ -454,6 +454,48 @@ export interface paths {
|
|
|
454
454
|
patch?: never;
|
|
455
455
|
trace?: never;
|
|
456
456
|
};
|
|
457
|
+
"/api/user-documents": {
|
|
458
|
+
parameters: {
|
|
459
|
+
query?: never;
|
|
460
|
+
header?: never;
|
|
461
|
+
path?: never;
|
|
462
|
+
cookie?: never;
|
|
463
|
+
};
|
|
464
|
+
/** List the member's imported documents */
|
|
465
|
+
get: operations["listUserDocuments"];
|
|
466
|
+
put?: never;
|
|
467
|
+
/**
|
|
468
|
+
* Import a document (a certificate or a test report)
|
|
469
|
+
* @description Member-gated. Upload one PNG/JPEG/WebP image or a PDF (20 MB max, 10 documents held per member until deleted). The import runs asynchronously: the route answers 202 with the importing row, the status endpoint (or a re-list) tells the rest. Images ride the vision lane; a PDF's text layer is extracted (a scanned PDF with no text layer is answered honestly with the no_text_layer status). Retention: held until the member deletes; deletion is immediate and total.
|
|
470
|
+
*/
|
|
471
|
+
post: operations["createUserDocument"];
|
|
472
|
+
delete?: never;
|
|
473
|
+
options?: never;
|
|
474
|
+
head?: never;
|
|
475
|
+
patch?: never;
|
|
476
|
+
trace?: never;
|
|
477
|
+
};
|
|
478
|
+
"/api/user-documents/{id}": {
|
|
479
|
+
parameters: {
|
|
480
|
+
query?: never;
|
|
481
|
+
header?: never;
|
|
482
|
+
path?: never;
|
|
483
|
+
cookie?: never;
|
|
484
|
+
};
|
|
485
|
+
/** One imported document's status and extracted fields */
|
|
486
|
+
get: operations["getUserDocument"];
|
|
487
|
+
put?: never;
|
|
488
|
+
post?: never;
|
|
489
|
+
/**
|
|
490
|
+
* Delete an imported document
|
|
491
|
+
* @description Immediate and total — the stored file, the private-lane vectors and the row go together.
|
|
492
|
+
*/
|
|
493
|
+
delete: operations["deleteUserDocument"];
|
|
494
|
+
options?: never;
|
|
495
|
+
head?: never;
|
|
496
|
+
patch?: never;
|
|
497
|
+
trace?: never;
|
|
498
|
+
};
|
|
457
499
|
"/api/projects": {
|
|
458
500
|
parameters: {
|
|
459
501
|
query?: never;
|
|
@@ -1766,6 +1808,124 @@ export interface operations {
|
|
|
1766
1808
|
};
|
|
1767
1809
|
};
|
|
1768
1810
|
};
|
|
1811
|
+
listUserDocuments: {
|
|
1812
|
+
parameters: {
|
|
1813
|
+
query?: never;
|
|
1814
|
+
header?: never;
|
|
1815
|
+
path?: never;
|
|
1816
|
+
cookie?: never;
|
|
1817
|
+
};
|
|
1818
|
+
requestBody?: never;
|
|
1819
|
+
responses: {
|
|
1820
|
+
/** @description The documents with their import status and the quota. */
|
|
1821
|
+
200: {
|
|
1822
|
+
headers: {
|
|
1823
|
+
[name: string]: unknown;
|
|
1824
|
+
};
|
|
1825
|
+
content?: never;
|
|
1826
|
+
};
|
|
1827
|
+
};
|
|
1828
|
+
};
|
|
1829
|
+
createUserDocument: {
|
|
1830
|
+
parameters: {
|
|
1831
|
+
query?: never;
|
|
1832
|
+
header?: never;
|
|
1833
|
+
path?: never;
|
|
1834
|
+
cookie?: never;
|
|
1835
|
+
};
|
|
1836
|
+
requestBody: {
|
|
1837
|
+
content: {
|
|
1838
|
+
"multipart/form-data": {
|
|
1839
|
+
/** Format: binary */
|
|
1840
|
+
file: string;
|
|
1841
|
+
};
|
|
1842
|
+
};
|
|
1843
|
+
};
|
|
1844
|
+
responses: {
|
|
1845
|
+
/** @description The import is running; the row carries its status. */
|
|
1846
|
+
202: {
|
|
1847
|
+
headers: {
|
|
1848
|
+
[name: string]: unknown;
|
|
1849
|
+
};
|
|
1850
|
+
content?: never;
|
|
1851
|
+
};
|
|
1852
|
+
/** @description The member holds the maximum of 10 documents. */
|
|
1853
|
+
403: {
|
|
1854
|
+
headers: {
|
|
1855
|
+
[name: string]: unknown;
|
|
1856
|
+
};
|
|
1857
|
+
content?: never;
|
|
1858
|
+
};
|
|
1859
|
+
/** @description The document exceeds the 20 MB limit. */
|
|
1860
|
+
413: {
|
|
1861
|
+
headers: {
|
|
1862
|
+
[name: string]: unknown;
|
|
1863
|
+
};
|
|
1864
|
+
content?: never;
|
|
1865
|
+
};
|
|
1866
|
+
/** @description Unsupported media type. */
|
|
1867
|
+
415: {
|
|
1868
|
+
headers: {
|
|
1869
|
+
[name: string]: unknown;
|
|
1870
|
+
};
|
|
1871
|
+
content?: never;
|
|
1872
|
+
};
|
|
1873
|
+
};
|
|
1874
|
+
};
|
|
1875
|
+
getUserDocument: {
|
|
1876
|
+
parameters: {
|
|
1877
|
+
query?: never;
|
|
1878
|
+
header?: never;
|
|
1879
|
+
path: {
|
|
1880
|
+
id: string;
|
|
1881
|
+
};
|
|
1882
|
+
cookie?: never;
|
|
1883
|
+
};
|
|
1884
|
+
requestBody?: never;
|
|
1885
|
+
responses: {
|
|
1886
|
+
/** @description The document row. */
|
|
1887
|
+
200: {
|
|
1888
|
+
headers: {
|
|
1889
|
+
[name: string]: unknown;
|
|
1890
|
+
};
|
|
1891
|
+
content?: never;
|
|
1892
|
+
};
|
|
1893
|
+
/** @description No such document for this member. */
|
|
1894
|
+
404: {
|
|
1895
|
+
headers: {
|
|
1896
|
+
[name: string]: unknown;
|
|
1897
|
+
};
|
|
1898
|
+
content?: never;
|
|
1899
|
+
};
|
|
1900
|
+
};
|
|
1901
|
+
};
|
|
1902
|
+
deleteUserDocument: {
|
|
1903
|
+
parameters: {
|
|
1904
|
+
query?: never;
|
|
1905
|
+
header?: never;
|
|
1906
|
+
path: {
|
|
1907
|
+
id: string;
|
|
1908
|
+
};
|
|
1909
|
+
cookie?: never;
|
|
1910
|
+
};
|
|
1911
|
+
requestBody?: never;
|
|
1912
|
+
responses: {
|
|
1913
|
+
/** @description The document is deleted. */
|
|
1914
|
+
200: {
|
|
1915
|
+
headers: {
|
|
1916
|
+
[name: string]: unknown;
|
|
1917
|
+
};
|
|
1918
|
+
content?: never;
|
|
1919
|
+
};
|
|
1920
|
+
/** @description No such document for this member. */
|
|
1921
|
+
404: {
|
|
1922
|
+
headers: {
|
|
1923
|
+
[name: string]: unknown;
|
|
1924
|
+
};
|
|
1925
|
+
content?: never;
|
|
1926
|
+
};
|
|
1927
|
+
};
|
|
1928
|
+
};
|
|
1769
1929
|
listProjects: {
|
|
1770
1930
|
parameters: {
|
|
1771
1931
|
query?: never;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
handleSearch
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-ZZGKC6WO.js";
|
|
4
|
+
import "./chunk-4J47P52J.js";
|
|
5
5
|
import "./chunk-ZHT4456M.js";
|
|
6
6
|
import "./chunk-D7MO4RVQ.js";
|
|
7
7
|
import "./chunk-ETLSWSZ7.js";
|
|
8
8
|
import "./chunk-FNQ7UOEB.js";
|
|
9
9
|
import "./chunk-HWWJAJWM.js";
|
|
10
10
|
import "./chunk-3FYJM7LH.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-YGQCVPX6.js";
|
|
12
12
|
export {
|
|
13
13
|
handleSearch
|
|
14
14
|
};
|
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
parseToolCall,
|
|
5
5
|
runTool,
|
|
6
6
|
toolNote
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-VRWNS4AI.js";
|
|
8
8
|
import "./chunk-ZHT4456M.js";
|
|
9
9
|
import "./chunk-FNQ7UOEB.js";
|
|
10
10
|
import "./chunk-HWWJAJWM.js";
|
|
11
11
|
import "./chunk-3FYJM7LH.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-YGQCVPX6.js";
|
|
13
13
|
export {
|
|
14
14
|
TOOLS_REGISTRY,
|
|
15
15
|
TOOL_DECLARATION,
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Blobs } from "./ports/blobs.ts";
|
|
2
|
+
import type { StoreQuery } from "./ports/store.ts";
|
|
3
|
+
import type { VectorIndex } from "./ports/vector.ts";
|
|
4
|
+
import type { ModelRunner } from "./ports/model.ts";
|
|
5
|
+
export declare const USER_DOC_LIMIT = 10;
|
|
6
|
+
export declare const USER_DOC_MAX_BYTES: number;
|
|
7
|
+
export interface UserDocumentRow {
|
|
8
|
+
id: string;
|
|
9
|
+
owner_sub: string;
|
|
10
|
+
name: string;
|
|
11
|
+
kind: string | null;
|
|
12
|
+
status: string;
|
|
13
|
+
bytes: number;
|
|
14
|
+
r2_key: string | null;
|
|
15
|
+
fields: string | null;
|
|
16
|
+
error: string | null;
|
|
17
|
+
created_at: string;
|
|
18
|
+
updated_at: string;
|
|
19
|
+
}
|
|
20
|
+
export interface UserDocumentPorts {
|
|
21
|
+
store: StoreQuery;
|
|
22
|
+
blobs: Blobs;
|
|
23
|
+
lane: VectorIndex;
|
|
24
|
+
model: ModelRunner;
|
|
25
|
+
}
|
|
26
|
+
export interface UploadBlob {
|
|
27
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
28
|
+
size: number;
|
|
29
|
+
type: string;
|
|
30
|
+
name: string;
|
|
31
|
+
}
|
|
32
|
+
/** The lane's one chunk id per document — deterministic, so deletion
|
|
33
|
+
* can drop it by id without an index listing round-trip. */
|
|
34
|
+
export declare function userDocumentChunkId(docId: string): string;
|
|
35
|
+
export declare function listUserDocuments(store: StoreQuery, sub: string): Promise<{
|
|
36
|
+
documents: UserDocumentRow[];
|
|
37
|
+
}>;
|
|
38
|
+
export declare function getUserDocument(store: StoreQuery, sub: string, id: string): Promise<UserDocumentRow | null>;
|
|
39
|
+
/** The quota guard: 10 documents per member. Returns the refusal
|
|
40
|
+
* response or null. */
|
|
41
|
+
export declare function quotaRefusal(store: StoreQuery, sub: string): Promise<Response | null>;
|
|
42
|
+
/** The import: validate, store the original, record the row, and run
|
|
43
|
+
* the extraction under the request's waitUntil — the route answers
|
|
44
|
+
* 202 with the importing row and the status endpoint tells the rest.
|
|
45
|
+
* Every quota rule is checked BEFORE anything is stored. */
|
|
46
|
+
export declare function createImport(ports: UserDocumentPorts, waitUntil: (p: Promise<unknown>) => void, sub: string, file: UploadBlob): Promise<{
|
|
47
|
+
document: UserDocumentRow;
|
|
48
|
+
} | {
|
|
49
|
+
error: Response;
|
|
50
|
+
}>;
|
|
51
|
+
/** The worker's half of the extraction: get text (vision for images,
|
|
52
|
+
* the PDF text layer for digital-born PDFs), then one structuring
|
|
53
|
+
* call. Statuses land on the row either way — importing | ready |
|
|
54
|
+
* no_text_layer | failed, never a silent empty import. */
|
|
55
|
+
export declare function processImport(ports: UserDocumentPorts, row: UserDocumentRow, mime: string, bytes: Uint8Array): Promise<void>;
|
|
56
|
+
/** The digital-born PDF's text layer: inflate FlateDecode content
|
|
57
|
+
* streams and scan the text-showing operators (Tj/TJ/'/"). Scanned
|
|
58
|
+
* PDFs have no text layer — the honest no_text_layer status answers
|
|
59
|
+
* them. No external dependency; Workers' DecompressionStream does the
|
|
60
|
+
* inflate. */
|
|
61
|
+
export declare function pdfTextLayer(bytes: Uint8Array): Promise<string>;
|
|
62
|
+
/** Pull the string literals out of one content stream's text ops. */
|
|
63
|
+
export declare function pdfTextOps(content: string): string;
|
|
64
|
+
/** Deletion is immediate and total: the R2 object, the lane vectors,
|
|
65
|
+
* the row. The caller has already checked ownership. */
|
|
66
|
+
export declare function deleteUserDocument(ports: UserDocumentPorts, sub: string, id: string): Promise<UserDocumentRow | null>;
|