@gixcopilot/knowledge 0.1.0
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/LICENSE +21 -0
- package/README.md +44 -0
- package/dist/acl.d.ts +16 -0
- package/dist/acl.d.ts.map +1 -0
- package/dist/acl.js +10 -0
- package/dist/acl.js.map +1 -0
- package/dist/document.d.ts +59 -0
- package/dist/document.d.ts.map +1 -0
- package/dist/document.js +29 -0
- package/dist/document.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/loader.d.ts +14 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +6 -0
- package/dist/loader.js.map +1 -0
- package/dist/loaders/api.d.ts +10 -0
- package/dist/loaders/api.d.ts.map +1 -0
- package/dist/loaders/api.js +42 -0
- package/dist/loaders/api.js.map +1 -0
- package/dist/loaders/database.d.ts +12 -0
- package/dist/loaders/database.d.ts.map +1 -0
- package/dist/loaders/database.js +46 -0
- package/dist/loaders/database.js.map +1 -0
- package/dist/loaders/docx.d.ts +9 -0
- package/dist/loaders/docx.d.ts.map +1 -0
- package/dist/loaders/docx.js +58 -0
- package/dist/loaders/docx.js.map +1 -0
- package/dist/loaders/file.d.ts +5 -0
- package/dist/loaders/file.d.ts.map +1 -0
- package/dist/loaders/file.js +56 -0
- package/dist/loaders/file.js.map +1 -0
- package/dist/loaders/html-structure.d.ts +20 -0
- package/dist/loaders/html-structure.d.ts.map +1 -0
- package/dist/loaders/html-structure.js +79 -0
- package/dist/loaders/html-structure.js.map +1 -0
- package/dist/loaders/html.d.ts +5 -0
- package/dist/loaders/html.d.ts.map +1 -0
- package/dist/loaders/html.js +52 -0
- package/dist/loaders/html.js.map +1 -0
- package/dist/loaders/markdown.d.ts +7 -0
- package/dist/loaders/markdown.d.ts.map +1 -0
- package/dist/loaders/markdown.js +28 -0
- package/dist/loaders/markdown.js.map +1 -0
- package/dist/loaders/mcp-resource.d.ts +11 -0
- package/dist/loaders/mcp-resource.d.ts.map +1 -0
- package/dist/loaders/mcp-resource.js +60 -0
- package/dist/loaders/mcp-resource.js.map +1 -0
- package/dist/loaders/object-storage.d.ts +5 -0
- package/dist/loaders/object-storage.d.ts.map +1 -0
- package/dist/loaders/object-storage.js +50 -0
- package/dist/loaders/object-storage.js.map +1 -0
- package/dist/loaders/pdf.d.ts +5 -0
- package/dist/loaders/pdf.d.ts.map +1 -0
- package/dist/loaders/pdf.js +102 -0
- package/dist/loaders/pdf.js.map +1 -0
- package/dist/loaders/text.d.ts +5 -0
- package/dist/loaders/text.d.ts.map +1 -0
- package/dist/loaders/text.js +21 -0
- package/dist/loaders/text.js.map +1 -0
- package/dist/loaders/web.d.ts +9 -0
- package/dist/loaders/web.d.ts.map +1 -0
- package/dist/loaders/web.js +102 -0
- package/dist/loaders/web.js.map +1 -0
- package/dist/net/ssrf-guard.d.ts +13 -0
- package/dist/net/ssrf-guard.d.ts.map +1 -0
- package/dist/net/ssrf-guard.js +88 -0
- package/dist/net/ssrf-guard.js.map +1 -0
- package/dist/normalize.d.ts +7 -0
- package/dist/normalize.d.ts.map +1 -0
- package/dist/normalize.js +14 -0
- package/dist/normalize.js.map +1 -0
- package/dist/registry.d.ts +10 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +27 -0
- package/dist/registry.js.map +1 -0
- package/dist/source.d.ts +136 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +55 -0
- package/dist/source.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { CopilotError } from '@gixcopilot/protocol';
|
|
2
|
+
import { createKnowledgeDocument } from '../document.js';
|
|
3
|
+
import { throwIfAborted } from '../loader.js';
|
|
4
|
+
import { normalizeText } from '../normalize.js';
|
|
5
|
+
import { assertSafeWebUrl, SsrfGuardError } from '../net/ssrf-guard.js';
|
|
6
|
+
import { extractHtmlStructure } from './html-structure.js';
|
|
7
|
+
const DEFAULT_MAX_BYTES = 5_000_000;
|
|
8
|
+
/**
|
|
9
|
+
* Remote web loader (Section 20). Deliberately narrow: no arbitrary model-controlled fetch
|
|
10
|
+
* capability (Section 20's explicit prohibition) - the URL comes from a developer-configured
|
|
11
|
+
* `webSource`, never from model output, and is checked with `assertSafeWebUrl` before fetching.
|
|
12
|
+
*/
|
|
13
|
+
export const webLoader = {
|
|
14
|
+
async *load(source, context) {
|
|
15
|
+
throwIfAborted(context?.signal);
|
|
16
|
+
const maxBytes = source.config.maxBytes ?? DEFAULT_MAX_BYTES;
|
|
17
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 1)
|
|
18
|
+
throw CopilotError.validation('maxBytes must be a positive integer.');
|
|
19
|
+
let url;
|
|
20
|
+
try {
|
|
21
|
+
url = new URL(source.config.url);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
throw CopilotError.sourceLoadFailed(`Invalid URL: "${source.config.url}"`, {
|
|
25
|
+
sourceId: source.id,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
await assertSafeWebUrl(url);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
if (error instanceof SsrfGuardError) {
|
|
33
|
+
throw CopilotError.sourceLoadFailed(error.message, { sourceId: source.id, url: url.href });
|
|
34
|
+
}
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
let response;
|
|
38
|
+
try {
|
|
39
|
+
response = await fetch(url, {
|
|
40
|
+
headers: source.config.headers,
|
|
41
|
+
redirect: 'error',
|
|
42
|
+
signal: context?.signal,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
throw CopilotError.sourceLoadFailed(`Failed to fetch "${url.href}": ${String(error)}`, {
|
|
47
|
+
sourceId: source.id,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
throw CopilotError.sourceLoadFailed(`Fetching "${url.href}" returned HTTP ${response.status}.`, { sourceId: source.id, status: response.status });
|
|
52
|
+
}
|
|
53
|
+
const contentLength = response.headers.get('content-length');
|
|
54
|
+
if (contentLength && Number(contentLength) > maxBytes) {
|
|
55
|
+
throw CopilotError.sourceLoadFailed(`Response for "${url.href}" exceeds the ${maxBytes}-byte limit.`, { sourceId: source.id });
|
|
56
|
+
}
|
|
57
|
+
const parts = [];
|
|
58
|
+
let bytes = 0;
|
|
59
|
+
const reader = response.body?.getReader();
|
|
60
|
+
try {
|
|
61
|
+
if (reader) {
|
|
62
|
+
while (true) {
|
|
63
|
+
throwIfAborted(context?.signal);
|
|
64
|
+
const { done, value } = (await reader.read());
|
|
65
|
+
if (done)
|
|
66
|
+
break;
|
|
67
|
+
bytes += value.byteLength;
|
|
68
|
+
if (bytes > maxBytes)
|
|
69
|
+
throw CopilotError.sourceLoadFailed(`Response exceeds the ${maxBytes}-byte limit.`, { sourceId: source.id });
|
|
70
|
+
parts.push(value);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
await reader?.cancel();
|
|
76
|
+
reader?.releaseLock();
|
|
77
|
+
}
|
|
78
|
+
const body = Buffer.concat(parts).toString('utf8');
|
|
79
|
+
throwIfAborted(context?.signal);
|
|
80
|
+
const contentType = response.headers.get('content-type') ?? '';
|
|
81
|
+
const structure = contentType.includes('html')
|
|
82
|
+
? extractHtmlStructure(body)
|
|
83
|
+
: { text: body };
|
|
84
|
+
const content = normalizeText(structure.text);
|
|
85
|
+
if (content.length === 0)
|
|
86
|
+
return;
|
|
87
|
+
yield createKnowledgeDocument({
|
|
88
|
+
sourceId: source.id,
|
|
89
|
+
content,
|
|
90
|
+
metadata: {
|
|
91
|
+
uri: url.href,
|
|
92
|
+
...(source.name !== undefined || structure.title !== undefined
|
|
93
|
+
? { title: source.name ?? structure.title }
|
|
94
|
+
: {}),
|
|
95
|
+
mimeType: contentType || undefined,
|
|
96
|
+
tenantId: source.tenantId,
|
|
97
|
+
acl: source.acl,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/loaders/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EAAE,cAAc,EAA2C,MAAM,cAAc,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAEpC;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAoC;IACxD,KAAK,CAAC,CAAC,IAAI,CACT,MAAwC,EACxC,OAAuB;QAEvB,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAChC,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,IAAI,iBAAiB,CAAC;QAC7D,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CAAC;YAAE,MAAM,YAAY,CAAC,UAAU,CAAC,sCAAsC,CAAC,CAAC;QAC3H,IAAI,GAAQ,CAAC;QACb,IAAI,CAAC;YACH,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnC,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,YAAY,CAAC,gBAAgB,CAAC,iBAAiB,MAAM,CAAC,MAAM,CAAC,GAAG,GAAG,EAAE;gBACzE,QAAQ,EAA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C,QAAQ,CAAC,MAAM,CAAC;YAC9E,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC;YAC5B,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACnB,MAAM,OAAO,GAAG,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAEjC,MAAM,uBAAuB,CAAC;YAC5B,QAAQ,EAAE,MAAM,CAAC,EAAE;YACnB,OAAO;YACP,QAAQ,EAAE;gBACR,GAAG,EAAE,GAAG,CAAC,IAAI;gBACb,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,SAAS,CAAC,KAAK,KAAK,SAAS;oBAC5D,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,IAAI,SAAS,CAAC,KAAK,EAAE;oBAC3C,CAAC,CAAC,EAAE,CAAC;gBACP,QAAQ,EAAE,WAAW,IAAI,SAAS;gBAClC,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,GAAG,EAAE,MAAM,CAAC,GAAG;aAChB;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class SsrfGuardError extends Error {
|
|
2
|
+
readonly name = "SsrfGuardError";
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Best-effort SSRF guard for the web loader (Section 20/6). Resolves the hostname and rejects
|
|
6
|
+
* loopback/RFC1918/link-local/metadata-service/CGNAT addresses before a fetch is attempted, and
|
|
7
|
+
* restricts to http/https. This is a real, meaningful check, not a complete one: it does not
|
|
8
|
+
* defend against DNS-rebinding between this check and the actual `fetch()` call (a TOCTOU gap
|
|
9
|
+
* that would require pinning the resolved IP into the connection itself, which the platform
|
|
10
|
+
* `fetch()` API does not expose) - documented explicitly rather than claimed as airtight.
|
|
11
|
+
*/
|
|
12
|
+
export declare function assertSafeWebUrl(url: URL): Promise<void>;
|
|
13
|
+
//# sourceMappingURL=ssrf-guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssrf-guard.d.ts","sourceRoot":"","sources":["../../src/net/ssrf-guard.ts"],"names":[],"mappings":"AAGA,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAkB,IAAI,oBAAoB;CAC3C;AAqDD;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAqB9D"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { lookup } from 'node:dns/promises';
|
|
2
|
+
import { isIP } from 'node:net';
|
|
3
|
+
export class SsrfGuardError extends Error {
|
|
4
|
+
name = 'SsrfGuardError';
|
|
5
|
+
}
|
|
6
|
+
function ipv4ToInt(ip) {
|
|
7
|
+
return ip
|
|
8
|
+
.split('.')
|
|
9
|
+
.reduce((acc, octet) => (acc << 8) + Number(octet), 0);
|
|
10
|
+
}
|
|
11
|
+
function inV4Range(ip, base, prefixLength) {
|
|
12
|
+
const mask = prefixLength === 0 ? 0 : (~0 << (32 - prefixLength)) >>> 0;
|
|
13
|
+
return (ipv4ToInt(ip) & mask) === (ipv4ToInt(base) & mask);
|
|
14
|
+
}
|
|
15
|
+
/** RFC 1918 + loopback + link-local (includes the 169.254.169.254 cloud metadata address) + CGNAT + "this network". */
|
|
16
|
+
const BLOCKED_V4_RANGES = [
|
|
17
|
+
['0.0.0.0', 8],
|
|
18
|
+
['10.0.0.0', 8],
|
|
19
|
+
['100.64.0.0', 10],
|
|
20
|
+
['127.0.0.0', 8],
|
|
21
|
+
['169.254.0.0', 16],
|
|
22
|
+
['172.16.0.0', 12],
|
|
23
|
+
['192.0.0.0', 24],
|
|
24
|
+
['192.168.0.0', 16],
|
|
25
|
+
['198.18.0.0', 15],
|
|
26
|
+
['224.0.0.0', 4],
|
|
27
|
+
['240.0.0.0', 4],
|
|
28
|
+
];
|
|
29
|
+
function isPrivateIpv4(ip) {
|
|
30
|
+
return BLOCKED_V4_RANGES.some(([base, prefixLength]) => inV4Range(ip, base, prefixLength));
|
|
31
|
+
}
|
|
32
|
+
function isPrivateIpv6(ip) {
|
|
33
|
+
const normalized = ip.toLowerCase();
|
|
34
|
+
if (normalized === '::1' || normalized === '::')
|
|
35
|
+
return true;
|
|
36
|
+
if (normalized.startsWith('fe8') || normalized.startsWith('fe9') || normalized.startsWith('fea') || normalized.startsWith('feb')) {
|
|
37
|
+
return true; // fe80::/10 link-local
|
|
38
|
+
}
|
|
39
|
+
if (normalized.startsWith('fc') || normalized.startsWith('fd'))
|
|
40
|
+
return true; // fc00::/7 unique local
|
|
41
|
+
if (normalized.startsWith('ff'))
|
|
42
|
+
return true; // multicast
|
|
43
|
+
if (normalized.startsWith('::ffff:'))
|
|
44
|
+
return true; // includes canonical hex IPv4-mapped literals
|
|
45
|
+
const v4Mapped = /^::ffff:(\d+\.\d+\.\d+\.\d+)$/.exec(normalized);
|
|
46
|
+
if (v4Mapped?.[1])
|
|
47
|
+
return isPrivateIpv4(v4Mapped[1]);
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
function isPrivateIp(ip) {
|
|
51
|
+
const version = isIP(ip);
|
|
52
|
+
if (version === 4)
|
|
53
|
+
return isPrivateIpv4(ip);
|
|
54
|
+
if (version === 6)
|
|
55
|
+
return isPrivateIpv6(ip);
|
|
56
|
+
return true; // not a recognizable literal IP - fail closed
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Best-effort SSRF guard for the web loader (Section 20/6). Resolves the hostname and rejects
|
|
60
|
+
* loopback/RFC1918/link-local/metadata-service/CGNAT addresses before a fetch is attempted, and
|
|
61
|
+
* restricts to http/https. This is a real, meaningful check, not a complete one: it does not
|
|
62
|
+
* defend against DNS-rebinding between this check and the actual `fetch()` call (a TOCTOU gap
|
|
63
|
+
* that would require pinning the resolved IP into the connection itself, which the platform
|
|
64
|
+
* `fetch()` API does not expose) - documented explicitly rather than claimed as airtight.
|
|
65
|
+
*/
|
|
66
|
+
export async function assertSafeWebUrl(url) {
|
|
67
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
|
68
|
+
throw new SsrfGuardError(`Unsupported protocol "${url.protocol}" - only http/https are allowed.`);
|
|
69
|
+
}
|
|
70
|
+
if (url.username || url.password)
|
|
71
|
+
throw new SsrfGuardError('Embedded URL credentials are not allowed.');
|
|
72
|
+
const hostname = url.hostname.replace(/^\[|\]$/g, '');
|
|
73
|
+
if (isIP(hostname) && isPrivateIp(hostname)) {
|
|
74
|
+
throw new SsrfGuardError(`"${hostname}" resolves to a disallowed address range.`);
|
|
75
|
+
}
|
|
76
|
+
if (!isIP(hostname)) {
|
|
77
|
+
const records = await lookup(hostname, { all: true }).catch((error) => {
|
|
78
|
+
throw new SsrfGuardError(`Could not resolve host "${hostname}": ${String(error)}`);
|
|
79
|
+
});
|
|
80
|
+
const blocked = records.find((record) => isPrivateIp(record.address));
|
|
81
|
+
if (!records.length)
|
|
82
|
+
throw new SsrfGuardError('Host did not resolve to any address.');
|
|
83
|
+
if (blocked) {
|
|
84
|
+
throw new SsrfGuardError(`"${hostname}" resolves to a disallowed address (${blocked.address}).`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=ssrf-guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssrf-guard.js","sourceRoot":"","sources":["../../src/net/ssrf-guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,MAAM,OAAO,cAAe,SAAQ,KAAK;IACrB,IAAI,GAAG,gBAAgB,CAAC;CAC3C;AAED,SAAS,SAAS,CAAC,EAAU;IAC3B,OAAO,EAAE;SACN,KAAK,CAAC,GAAG,CAAC;SACV,MAAM,C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a KnowledgeDocument is
|
|
3
|
+
* produced: consistent line endings and collapsed excessive blank space, without destroying
|
|
4
|
+
* meaningful structure (paragraph breaks are preserved, not collapsed to nothing).
|
|
5
|
+
*/
|
|
6
|
+
export declare function normalizeText(raw: string): string;
|
|
7
|
+
//# sourceMappingURL=normalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../src/normalize.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOjD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared text normalization (Section 26) applied by every loader before a KnowledgeDocument is
|
|
3
|
+
* produced: consistent line endings and collapsed excessive blank space, without destroying
|
|
4
|
+
* meaningful structure (paragraph breaks are preserved, not collapsed to nothing).
|
|
5
|
+
*/
|
|
6
|
+
export function normalizeText(raw) {
|
|
7
|
+
return raw
|
|
8
|
+
.replace(/\r\n?/g, '\n')
|
|
9
|
+
.replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f]/g, '')
|
|
10
|
+
.replace(/[ \t]+\n/g, '\n')
|
|
11
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
12
|
+
.trim();
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=normalize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalize.js","sourceRoot":"","sources":["../src/normalize.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,OAAO,GAAG;SACP,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC;SACvB,OAAO,CAAC,2CAA2C,EAAE,EAAE,CAAC;SACxD,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC;SAC1B,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC;SAC1B,IAAI,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { KnowledgeSource } from './source.js';
|
|
2
|
+
/** Tracks configured knowledge sources (Section 11). Not a mandatory global singleton - callers create one per application/tenant as needed. */
|
|
3
|
+
export interface KnowledgeSourceRegistry {
|
|
4
|
+
register(source: KnowledgeSource): void;
|
|
5
|
+
get(id: string): KnowledgeSource | undefined;
|
|
6
|
+
list(): readonly KnowledgeSource[];
|
|
7
|
+
remove(id: string): void;
|
|
8
|
+
}
|
|
9
|
+
export declare function createKnowledgeSourceRegistry(initial?: readonly KnowledgeSource[]): KnowledgeSourceRegistry;
|
|
10
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,gJAAgJ;AAChJ,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAAC;IACxC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAAC;IAC7C,IAAI,IAAI,SAAS,eAAe,EAAE,CAAC;IACnC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,GAAE,SAAS,eAAe,EAAO,GACvC,uBAAuB,CAyBzB"}
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CopilotError } from '@gixcopilot/protocol';
|
|
2
|
+
export function createKnowledgeSourceRegistry(initial = []) {
|
|
3
|
+
const sources = new Map();
|
|
4
|
+
for (const source of initial) {
|
|
5
|
+
sources.set(source.id, source);
|
|
6
|
+
}
|
|
7
|
+
return {
|
|
8
|
+
register(source) {
|
|
9
|
+
if (sources.has(source.id)) {
|
|
10
|
+
throw CopilotError.validation(`A knowledge source with id "${source.id}" is already registered.`, {
|
|
11
|
+
sourceId: source.id,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
sources.set(source.id, source);
|
|
15
|
+
},
|
|
16
|
+
get(id) {
|
|
17
|
+
return sources.get(id);
|
|
18
|
+
},
|
|
19
|
+
list() {
|
|
20
|
+
return [...sources.values()];
|
|
21
|
+
},
|
|
22
|
+
remove(id) {
|
|
23
|
+
sources.delete(id);
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAWpD,MAAM,UAAU,6BAA6B,CAC3C,UAAsC,EAAE;IAExC,MAAM,OAAO,GAAG,IAAI,GAAG,EAA2B,CAAC;IACnD,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IACjC,CAAC;IAED,OAAO;QACL,QAAQ,CAAC,MAAM;YACb,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;gBAC3B,MAAM,YAAY,CAAC,UAAU,CAAC,+BAA+B,MAAM,CAAC,EAAE,0BAA0B,EAAE;oBAChG,QAAQ,EAAE,MAAM,CAAC,EAAE;iBACpB,CAAC,CAAC;YACL,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QACjC,CAAC;QACD,GAAG,CAAC,EAAE;YACJ,OAAO,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACzB,CAAC;QACD,IAAI;YACF,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAC/B,CAAC;QACD,MAAM,CAAC,EAAE;YACP,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACrB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/source.d.ts
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { KnowledgeACL } from './acl.js';
|
|
2
|
+
import type { DocumentMetadata } from './document.js';
|
|
3
|
+
/** The knowledge source types the architecture supports (Section 10). */
|
|
4
|
+
export type KnowledgeSourceType = 'file' | 'text' | 'markdown' | 'pdf' | 'docx' | 'html' | 'web' | 'api' | 'database' | 'object-storage' | 'mcp-resource' | 'custom';
|
|
5
|
+
/** Framework-independent knowledge source contract (Section 9). Never coupled to a specific storage system. */
|
|
6
|
+
export interface KnowledgeSource<TConfig = unknown> {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly type: KnowledgeSourceType;
|
|
9
|
+
readonly name?: string;
|
|
10
|
+
readonly tenantId?: string;
|
|
11
|
+
readonly acl?: KnowledgeACL;
|
|
12
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
13
|
+
readonly config: TConfig;
|
|
14
|
+
}
|
|
15
|
+
export interface KnowledgeSourceCommonInput {
|
|
16
|
+
readonly id?: string;
|
|
17
|
+
readonly name?: string;
|
|
18
|
+
readonly tenantId?: string;
|
|
19
|
+
/** Shorthand for `acl.permissions` - merged with an explicit `acl` if both are given. */
|
|
20
|
+
readonly permissions?: readonly string[];
|
|
21
|
+
readonly acl?: KnowledgeACL;
|
|
22
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
23
|
+
}
|
|
24
|
+
export interface TextSourceConfig {
|
|
25
|
+
readonly content: string;
|
|
26
|
+
}
|
|
27
|
+
export type TextSourceInput = KnowledgeSourceCommonInput & TextSourceConfig;
|
|
28
|
+
export declare function textSource(input: TextSourceInput): KnowledgeSource<TextSourceConfig>;
|
|
29
|
+
export type MarkdownSourceInput = KnowledgeSourceCommonInput & TextSourceConfig;
|
|
30
|
+
export declare function markdownSource(input: MarkdownSourceInput): KnowledgeSource<TextSourceConfig>;
|
|
31
|
+
/** Exactly one of `path`/`buffer` must be provided - validated by the corresponding loader. */
|
|
32
|
+
export interface BinarySourceConfig {
|
|
33
|
+
readonly path?: string;
|
|
34
|
+
readonly buffer?: Buffer;
|
|
35
|
+
}
|
|
36
|
+
export type PdfSourceInput = KnowledgeSourceCommonInput & BinarySourceConfig;
|
|
37
|
+
export declare function pdfSource(input: PdfSourceInput): KnowledgeSource<BinarySourceConfig>;
|
|
38
|
+
export type DocxSourceInput = KnowledgeSourceCommonInput & BinarySourceConfig;
|
|
39
|
+
export declare function docxSource(input: DocxSourceInput): KnowledgeSource<BinarySourceConfig>;
|
|
40
|
+
/** Exactly one of `html`/`path` must be provided - validated by the loader. */
|
|
41
|
+
export interface HtmlSourceConfig {
|
|
42
|
+
readonly html?: string;
|
|
43
|
+
readonly path?: string;
|
|
44
|
+
}
|
|
45
|
+
export type HtmlSourceInput = KnowledgeSourceCommonInput & HtmlSourceConfig;
|
|
46
|
+
export declare function htmlSource(input: HtmlSourceInput): KnowledgeSource<HtmlSourceConfig>;
|
|
47
|
+
export interface WebSourceConfig {
|
|
48
|
+
readonly url: string;
|
|
49
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
50
|
+
readonly maxBytes?: number;
|
|
51
|
+
}
|
|
52
|
+
export type WebSourceInput = KnowledgeSourceCommonInput & WebSourceConfig;
|
|
53
|
+
export declare function webSource(input: WebSourceInput): KnowledgeSource<WebSourceConfig>;
|
|
54
|
+
/** One document produced from a non-file source (API/database rows) - Section 21/22. */
|
|
55
|
+
export interface DerivedDocumentInput {
|
|
56
|
+
readonly content: string;
|
|
57
|
+
readonly discriminator?: string | number;
|
|
58
|
+
readonly metadata?: Partial<Omit<DocumentMetadata, 'contentHash'>>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* API knowledge source (Section 21) - deliberately distinct from a Phase 8 API *tool*: this
|
|
62
|
+
* never executes an action, it only turns a response into documents. `request` is the caller's
|
|
63
|
+
* own fetch/HTTP call (so this package never owns HTTP credentials/base-URL policy);
|
|
64
|
+
* `toDocuments` maps the raw response into zero or more documents.
|
|
65
|
+
*/
|
|
66
|
+
export interface ApiSourceConfig {
|
|
67
|
+
readonly request: () => Promise<unknown>;
|
|
68
|
+
readonly toDocuments: (response: unknown) => readonly DerivedDocumentInput[];
|
|
69
|
+
}
|
|
70
|
+
export type ApiSourceInput = KnowledgeSourceCommonInput & ApiSourceConfig;
|
|
71
|
+
export declare function apiSource(input: ApiSourceInput): KnowledgeSource<ApiSourceConfig>;
|
|
72
|
+
/**
|
|
73
|
+
* Database knowledge source (Section 22). `query` is a caller-supplied, already-parameterized
|
|
74
|
+
* async function returning rows - this package never builds or executes SQL/query strings
|
|
75
|
+
* itself, so "unrestricted natural-language-to-SQL access" is impossible by construction.
|
|
76
|
+
*/
|
|
77
|
+
export interface DatabaseSourceConfig<TRow = unknown> {
|
|
78
|
+
readonly query: () => Promise<readonly TRow[]>;
|
|
79
|
+
readonly toDocument: (row: TRow, index: number) => DerivedDocumentInput;
|
|
80
|
+
}
|
|
81
|
+
export type DatabaseSourceInput<TRow = unknown> = KnowledgeSourceCommonInput & DatabaseSourceConfig<TRow>;
|
|
82
|
+
export declare function createDatabaseKnowledgeSource<TRow = unknown>(input: DatabaseSourceInput<TRow>): KnowledgeSource<DatabaseSourceConfig<TRow>>;
|
|
83
|
+
/** Minimal object-storage boundary (Section 23) - no concrete cloud SDK dependency. */
|
|
84
|
+
export interface ObjectStorageObject {
|
|
85
|
+
readonly key: string;
|
|
86
|
+
readonly content: string;
|
|
87
|
+
readonly metadata?: Partial<Omit<DocumentMetadata, 'contentHash'>>;
|
|
88
|
+
}
|
|
89
|
+
export interface ObjectStorageClient {
|
|
90
|
+
list(prefix?: string): Promise<readonly string[]>;
|
|
91
|
+
get(key: string): Promise<ObjectStorageObject>;
|
|
92
|
+
}
|
|
93
|
+
export interface ObjectStorageSourceConfig {
|
|
94
|
+
readonly client: ObjectStorageClient;
|
|
95
|
+
/** Explicit key list, or omit to list everything under `prefix` at load time. */
|
|
96
|
+
readonly keys?: readonly string[];
|
|
97
|
+
readonly prefix?: string;
|
|
98
|
+
}
|
|
99
|
+
export type ObjectStorageSourceInput = KnowledgeSourceCommonInput & ObjectStorageSourceConfig;
|
|
100
|
+
export declare function objectStorageSource(input: ObjectStorageSourceInput): KnowledgeSource<ObjectStorageSourceConfig>;
|
|
101
|
+
/** A structural subset of @gixcopilot/mcp's client/integration resource API (Section 24). */
|
|
102
|
+
export interface McpResourceReader {
|
|
103
|
+
listResources(): Promise<readonly {
|
|
104
|
+
readonly uri: string;
|
|
105
|
+
readonly name: string;
|
|
106
|
+
readonly description?: string;
|
|
107
|
+
readonly mimeType?: string;
|
|
108
|
+
}[]>;
|
|
109
|
+
readResource(uri: string): Promise<{
|
|
110
|
+
readonly uri: string;
|
|
111
|
+
readonly mimeType?: string;
|
|
112
|
+
readonly text?: string;
|
|
113
|
+
}>;
|
|
114
|
+
}
|
|
115
|
+
export interface McpResourceSourceConfig {
|
|
116
|
+
readonly client: McpResourceReader;
|
|
117
|
+
/** Explicit resource URIs, or omit to ingest every resource the server advertises. */
|
|
118
|
+
readonly uris?: readonly string[];
|
|
119
|
+
}
|
|
120
|
+
export type McpResourceSourceInput = KnowledgeSourceCommonInput & McpResourceSourceConfig;
|
|
121
|
+
export declare function mcpResourceSource(input: McpResourceSourceInput): KnowledgeSource<McpResourceSourceConfig>;
|
|
122
|
+
/** Generic local/remote file source that dispatches by extension (Section 10's 'file' type). */
|
|
123
|
+
export interface FileSourceConfig {
|
|
124
|
+
readonly path: string;
|
|
125
|
+
}
|
|
126
|
+
export type FileSourceInput = KnowledgeSourceCommonInput & FileSourceConfig;
|
|
127
|
+
export declare function fileSource(input: FileSourceInput): KnowledgeSource<FileSourceConfig>;
|
|
128
|
+
/**
|
|
129
|
+
* Escape hatch for a source type this package doesn't model - the caller supplies their own
|
|
130
|
+
* `DocumentLoader` for it directly (Section 10). No default loader is registered for `custom`.
|
|
131
|
+
*/
|
|
132
|
+
export type CustomSourceInput = KnowledgeSourceCommonInput & {
|
|
133
|
+
readonly config?: unknown;
|
|
134
|
+
};
|
|
135
|
+
export declare function customSource(input: CustomSourceInput): KnowledgeSource<unknown>;
|
|
136
|
+
//# sourceMappingURL=source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,yEAAyE;AACzE,MAAM,MAAM,mBAAmB,GAC3B,MAAM,GACN,MAAM,GACN,UAAU,GACV,KAAK,GACL,MAAM,GACN,MAAM,GACN,KAAK,GACL,KAAK,GACL,UAAU,GACV,gBAAgB,GAChB,cAAc,GACd,QAAQ,CAAC;AAEb,+GAA+G;AAC/G,MAAM,WAAW,eAAe,CAAC,OAAO,GAAG,OAAO;IAChD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;IACnC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,GAAG,CAAC,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACtD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,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Acl(input) {
|
|
3
|
+
if (!input.permissions || input.permissions.length === 0)
|
|
4
|
+
return input.acl;
|
|
5
|
+
const merged = new Set([...(input.acl?.permissions ?? []), ...input.permissions]);
|
|
6
|
+
return { ...input.acl, permissions: [...merged] };
|
|
7
|
+
}
|
|
8
|
+
function buildSource(type, config, input) {
|
|
9
|
+
return {
|
|
10
|
+
id: input.id ?? randomUUID(),
|
|
11
|
+
type,
|
|
12
|
+
...(input.name !== undefined ? { name: input.name } : {}),
|
|
13
|
+
...(input.tenantId !== undefined ? { tenantId: input.tenantId } : {}),
|
|
14
|
+
...(resolveAcl(input) !== undefined ? { acl: resolveAcl(input) } : {}),
|
|
15
|
+
...(input.metadata !== undefined ? { metadata: input.metadata } : {}),
|
|
16
|
+
config,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function textSource(input) {
|
|
20
|
+
return buildSource('text', { content: input.content }, input);
|
|
21
|
+
}
|
|
22
|
+
export function markdownSource(input) {
|
|
23
|
+
return buildSource('markdown', { content: input.content }, input);
|
|
24
|
+
}
|
|
25
|
+
export function pdfSource(input) {
|
|
26
|
+
return buildSource('pdf', { path: input.path, buffer: input.buffer }, input);
|
|
27
|
+
}
|
|
28
|
+
export function docxSource(input) {
|
|
29
|
+
return buildSource('docx', { path: input.path, buffer: input.buffer }, input);
|
|
30
|
+
}
|
|
31
|
+
export function htmlSource(input) {
|
|
32
|
+
return buildSource('html', { html: input.html, path: input.path }, input);
|
|
33
|
+
}
|
|
34
|
+
export function webSource(input) {
|
|
35
|
+
return buildSource('web', { url: input.url, headers: input.headers, maxBytes: input.maxBytes }, input);
|
|
36
|
+
}
|
|
37
|
+
export function apiSource(input) {
|
|
38
|
+
return buildSource('api', { request: input.request, toDocuments: input.toDocuments }, input);
|
|
39
|
+
}
|
|
40
|
+
export function createDatabaseKnowledgeSource(input) {
|
|
41
|
+
return buildSource('database', { query: input.query, toDocument: input.toDocument }, input);
|
|
42
|
+
}
|
|
43
|
+
export function objectStorageSource(input) {
|
|
44
|
+
return buildSource('object-storage', { client: input.client, keys: input.keys, prefix: input.prefix }, input);
|
|
45
|
+
}
|
|
46
|
+
export function mcpResourceSource(input) {
|
|
47
|
+
return buildSource('mcp-resource', { client: input.client, uris: input.uris }, input);
|
|
48
|
+
}
|
|
49
|
+
export function fileSource(input) {
|
|
50
|
+
return buildSource('file', { path: input.path }, input);
|
|
51
|
+
}
|
|
52
|
+
export function customSource(input) {
|
|
53
|
+
return buildSource('custom', input.config, input);
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source.js","sourceRoot":"","sources":["../src/source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAwCzC,SAAS,UAAU,CAAC,KAAiC;IACnD,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC;IAC3E,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,WAAW,IAAI,EAAE,CAAC,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IAClF,OAAO,EAAE,GAAG,KAAK,CAAC,GAAG,EAAE,WAAW,EAAE,CAAC,GAAG,MAAM,CAAC,EAAE,CAAC;AACpD,CAAC;AAED,SAAS,WAAW,CAClB,IAAyB,EACzB,MAAe,EACf,KAAiC;IAEjC,OAAO;QACL,EAAE,EAAE,KAAK,CAAC,EAAE,IAAI,UAAU,EAAE;QAC5B,IAAI;QACJ,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,GAAG,CAAC,KAAK,CAAC,QAAQ,KAAK,SAA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AAC;AAC1D,CAAC;AAOD,MAAM,UAAU,YAAY,CAAC,KAAwB;IACnD,OAAO,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACpD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gixcopilot/knowledge",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Framework-independent knowledge source, document, and loader contracts for the AI Copilot SDK - the ingestion boundary RAG builds on.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/AfoudaSWE/gix_ai_copilot_nx.git",
|
|
9
|
+
"directory": "packages/knowledge"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/AfoudaSWE/gix_ai_copilot_nx/tree/main/packages/knowledge#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/AfoudaSWE/gix_ai_copilot_nx/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"main": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"default": "./dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./package.json": "./package.json"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"!dist/**/*.spec.*",
|
|
29
|
+
"!dist/**/*.spec-helper.*",
|
|
30
|
+
"!dist/**/*.integration.spec.*",
|
|
31
|
+
"!dist/**/*.tsbuildinfo"
|
|
32
|
+
],
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=22.12.0"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"mammoth": "^1.11.0",
|
|
41
|
+
"node-html-parser": "^7.0.1",
|
|
42
|
+
"pdfjs-dist": "^4.10.38",
|
|
43
|
+
"@gixcopilot/protocol": "0.1.0",
|
|
44
|
+
"@gixcopilot/mcp": "0.1.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"jszip": "^3.10.1",
|
|
48
|
+
"pdf-lib": "^1.17.1",
|
|
49
|
+
"vitest": "5.0.1"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "tsc -b tsconfig.json",
|
|
53
|
+
"typecheck": "tsc -b tsconfig.json",
|
|
54
|
+
"test": "vitest run",
|
|
55
|
+
"lint": "eslint src"
|
|
56
|
+
}
|
|
57
|
+
}
|