@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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ahmed khaled
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# @gixcopilot/knowledge
|
|
2
|
+
|
|
3
|
+
Framework-independent knowledge source, document, and loader contracts for the AI Copilot SDK —
|
|
4
|
+
files, text, Markdown, PDF, DOCX, HTML/web, APIs, databases, object storage, and MCP resources,
|
|
5
|
+
each normalized into the same `KnowledgeDocument` shape. No chunking, embedding, or vector-store
|
|
6
|
+
concern lives here — see `@gixcopilot/rag`.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @gixcopilot/knowledge
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Requires Node.js >=22.12.0. ESM only.
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { pdfSource, defaultKnowledgeLoaders } from '@gixcopilot/knowledge';
|
|
18
|
+
|
|
19
|
+
const source = pdfSource({ id: 'handbook', path: './handbook.pdf', tenantId: 'tenant-a', acl: { permissions: ['knowledge.hr.read'] } });
|
|
20
|
+
for await (const doc of defaultKnowledgeLoaders.pdf!.load(source)) {
|
|
21
|
+
console.log(doc.metadata.page, doc.content.slice(0, 80));
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Attach `tenantId`/`acl` at the source (or per-document) level — that metadata is what
|
|
26
|
+
`@gixcopilot/rag`'s retriever later enforces against a trusted `SecurityContext`. The `web` loader
|
|
27
|
+
refuses loopback/link-local/private-range/non-HTTP(S) URLs and redirects; it is not a general
|
|
28
|
+
model-controlled fetch tool. `database`/`object-storage`/`mcp-resource` sources take a
|
|
29
|
+
host-supplied client or predefined safe query — never natural-language-to-SQL or an arbitrary
|
|
30
|
+
cloud SDK dependency.
|
|
31
|
+
|
|
32
|
+
See [Phase 9 API](../../docs/phases/phase-09/Phase_9_API.md),
|
|
33
|
+
[architecture](../../docs/phases/phase-09/Phase_9_Architecture.md), and
|
|
34
|
+
[limits](../../docs/phases/phase-09/Phase_9_Issues.md).
|
|
35
|
+
|
|
36
|
+
## Documentation
|
|
37
|
+
|
|
38
|
+
- [rag guide](https://github.com/AfoudaSWE/gix_ai_copilot_nx/blob/main/docs/guides/rag.md)
|
|
39
|
+
- [Getting started](https://github.com/AfoudaSWE/gix_ai_copilot_nx/blob/main/docs/guides/getting-started.md)
|
|
40
|
+
- [Source](https://github.com/AfoudaSWE/gix_ai_copilot_nx/tree/main/packages/knowledge)
|
|
41
|
+
|
|
42
|
+
## License
|
|
43
|
+
|
|
44
|
+
MIT
|
package/dist/acl.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Access-control metadata attached to a knowledge source/document at ingestion time (Section
|
|
3
|
+
* 60). This is *descriptive* metadata only - it participates in deterministic authorization
|
|
4
|
+
* inside @gixcopilot/rag's retriever (query-time, against a trusted SecurityContext), never
|
|
5
|
+
* enforced here. A knowledge/document with no ACL is effectively unrestricted within its
|
|
6
|
+
* tenant - callers that want to restrict a source must say so explicitly.
|
|
7
|
+
*/
|
|
8
|
+
export interface KnowledgeACL {
|
|
9
|
+
readonly users?: readonly string[];
|
|
10
|
+
readonly roles?: readonly string[];
|
|
11
|
+
readonly permissions?: readonly string[];
|
|
12
|
+
readonly groups?: readonly string[];
|
|
13
|
+
}
|
|
14
|
+
/** An ACL with no populated field grants no additional restriction beyond tenant scoping. */
|
|
15
|
+
export declare function isUnrestrictedAcl(acl: KnowledgeACL | undefined): boolean;
|
|
16
|
+
//# sourceMappingURL=acl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acl.d.ts","sourceRoot":"","sources":["../src/acl.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAMD,6FAA6F;AAC7F,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,YAAY,GAAG,SAAS,GAAG,OAAO,CAGxE"}
|
package/dist/acl.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
function isNonEmpty(values) {
|
|
2
|
+
return values !== undefined && values.length > 0;
|
|
3
|
+
}
|
|
4
|
+
/** An ACL with no populated field grants no additional restriction beyond tenant scoping. */
|
|
5
|
+
export function isUnrestrictedAcl(acl) {
|
|
6
|
+
if (!acl)
|
|
7
|
+
return true;
|
|
8
|
+
return !isNonEmpty(acl.users) && !isNonEmpty(acl.roles) && !isNonEmpty(acl.permissions) && !isNonEmpty(acl.groups);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=acl.js.map
|
package/dist/acl.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acl.js","sourceRoot":"","sources":["../src/acl.ts"],"names":[],"mappings":"AAcA,SAAS,UAAU,CAAC,MAAqC;IACvD,OAAO,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;AACnD,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,iBAAiB,CAAC,GAA6B;IAC7D,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACtB,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AACrH,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { KnowledgeACL } from './acl.js';
|
|
2
|
+
/**
|
|
3
|
+
* Descriptive metadata about a KnowledgeDocument (Section 12). Free-form `tags`/business
|
|
4
|
+
* metadata are allowed, but nothing here is implicitly trusted for authorization - only
|
|
5
|
+
* `tenantId`/`acl` participate in the rag package's retrieval-time authorization checks.
|
|
6
|
+
* Arbitrary sensitive metadata reaching the model automatically is avoided by never including
|
|
7
|
+
* this object wholesale in model context - rag's citation/context formatting picks specific
|
|
8
|
+
* fields deliberately (Section 12).
|
|
9
|
+
*/
|
|
10
|
+
export interface DocumentMetadata {
|
|
11
|
+
readonly title?: string;
|
|
12
|
+
/** Where this document originally came from - a file path, URL, or opaque source-specific id. */
|
|
13
|
+
readonly uri?: string;
|
|
14
|
+
readonly mimeType?: string;
|
|
15
|
+
readonly createdAt?: string;
|
|
16
|
+
readonly updatedAt?: string;
|
|
17
|
+
readonly author?: string;
|
|
18
|
+
/** Mandatory for any document that should be tenant-isolated during retrieval (Section 45/59). */
|
|
19
|
+
readonly tenantId?: string;
|
|
20
|
+
readonly acl?: KnowledgeACL;
|
|
21
|
+
readonly tags?: readonly string[];
|
|
22
|
+
/** 1-based page number, when the source is paginated (PDF, etc.) - Section 14/18. */
|
|
23
|
+
readonly page?: number;
|
|
24
|
+
readonly section?: string;
|
|
25
|
+
readonly heading?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Stable digest of `content`, used for change detection/deduplication/idempotent reindexing
|
|
28
|
+
* (Section 132/133) - always populated by `hashContent`, never left to the caller to compute
|
|
29
|
+
* inconsistently.
|
|
30
|
+
*/
|
|
31
|
+
readonly contentHash?: string;
|
|
32
|
+
readonly businessMetadata?: Readonly<Record<string, unknown>>;
|
|
33
|
+
}
|
|
34
|
+
/** Normalized document representation every loader produces (Section 12). */
|
|
35
|
+
export interface KnowledgeDocument {
|
|
36
|
+
readonly id: string;
|
|
37
|
+
readonly sourceId: string;
|
|
38
|
+
readonly content: string;
|
|
39
|
+
readonly metadata: DocumentMetadata;
|
|
40
|
+
}
|
|
41
|
+
/** SHA-256 digest of `content`, used for both `contentHash` and deterministic id derivation. */
|
|
42
|
+
export declare function hashContent(content: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* Deterministic document id: stable across re-ingestion of the *same* source position (so
|
|
45
|
+
* reindex/update/delete/citation all agree - Section 13), but changes when content changes so
|
|
46
|
+
* a content-hash-based `contentHash` can still detect the change (Section 132). `discriminator`
|
|
47
|
+
* disambiguates multiple documents from one source (e.g. a page number, a row id, a resource
|
|
48
|
+
* URI) - omit only when the source itself is single-document.
|
|
49
|
+
*/
|
|
50
|
+
export declare function deriveDocumentId(sourceId: string, discriminator?: string | number): string;
|
|
51
|
+
export interface CreateKnowledgeDocumentInput {
|
|
52
|
+
readonly sourceId: string;
|
|
53
|
+
readonly content: string;
|
|
54
|
+
readonly discriminator?: string | number;
|
|
55
|
+
readonly metadata?: Omit<DocumentMetadata, 'contentHash'>;
|
|
56
|
+
}
|
|
57
|
+
/** Builds a KnowledgeDocument with a deterministic id and a populated contentHash. */
|
|
58
|
+
export declare function createKnowledgeDocument(input: CreateKnowledgeDocumentInput): KnowledgeDocument;
|
|
59
|
+
//# sourceMappingURL=document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,iGAAiG;IACjG,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,kGAAkG;IAClG,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,GAAG,CAAC,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,qFAAqF;IACrF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC/D;AAED,6EAA6E;AAC7E,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;CACrC;AAED,gGAAgG;AAChG,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAG1F;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzC,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;CAC3D;AAED,sFAAsF;AACtF,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,GAAG,iBAAiB,CAU9F"}
|
package/dist/document.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
/** SHA-256 digest of `content`, used for both `contentHash` and deterministic id derivation. */
|
|
3
|
+
export function hashContent(content) {
|
|
4
|
+
return createHash('sha256').update(content, 'utf8').digest('hex');
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Deterministic document id: stable across re-ingestion of the *same* source position (so
|
|
8
|
+
* reindex/update/delete/citation all agree - Section 13), but changes when content changes so
|
|
9
|
+
* a content-hash-based `contentHash` can still detect the change (Section 132). `discriminator`
|
|
10
|
+
* disambiguates multiple documents from one source (e.g. a page number, a row id, a resource
|
|
11
|
+
* URI) - omit only when the source itself is single-document.
|
|
12
|
+
*/
|
|
13
|
+
export function deriveDocumentId(sourceId, discriminator) {
|
|
14
|
+
const key = JSON.stringify([sourceId, discriminator ?? null]);
|
|
15
|
+
return createHash('sha256').update(key, 'utf8').digest('hex').slice(0, 32);
|
|
16
|
+
}
|
|
17
|
+
/** Builds a KnowledgeDocument with a deterministic id and a populated contentHash. */
|
|
18
|
+
export function createKnowledgeDocument(input) {
|
|
19
|
+
return {
|
|
20
|
+
id: deriveDocumentId(input.sourceId, input.discriminator),
|
|
21
|
+
sourceId: input.sourceId,
|
|
22
|
+
content: input.content,
|
|
23
|
+
metadata: {
|
|
24
|
+
...input.metadata,
|
|
25
|
+
contentHash: hashContent(input.content),
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.js","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA4CzC,gGAAgG;AAChG,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACpE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB,EAAE,aAA+B;IAChF,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,aAAa,IAAI,IAAI,CAAC,CAAC,CAAC;IAC9D,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC7E,CAAC;AASD,sFAAsF;AACtF,MAAM,UAAU,uBAAuB,CAAC,KAAmC;IACzE,OAAO;QACL,EAAE,EAAE,gBAAgB,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,aAAa,CAAC;QACzD,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,QAAQ,EAAE;YACR,GAAG,KAAK,CAAC,QAAQ;YACjB,WAAW,EAAE,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC;SACxC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type { KnowledgeACL } from './acl.js';
|
|
2
|
+
export { isUnrestrictedAcl } from './acl.js';
|
|
3
|
+
export type { DocumentMetadata, KnowledgeDocument, CreateKnowledgeDocumentInput } from './document.js';
|
|
4
|
+
export { hashContent, deriveDocumentId, createKnowledgeDocument } from './document.js';
|
|
5
|
+
export type { KnowledgeSourceType, KnowledgeSource, KnowledgeSourceCommonInput, TextSourceConfig, TextSourceInput, MarkdownSourceInput, BinarySourceConfig, PdfSourceInput, DocxSourceInput, HtmlSourceConfig, HtmlSourceInput, WebSourceConfig, WebSourceInput, DerivedDocumentInput, ApiSourceConfig, ApiSourceInput, DatabaseSourceConfig, DatabaseSourceInput, ObjectStorageObject, ObjectStorageClient, ObjectStorageSourceConfig, ObjectStorageSourceInput, McpResourceReader, McpResourceSourceConfig, McpResourceSourceInput, FileSourceConfig, FileSourceInput, CustomSourceInput, } from './source.js';
|
|
6
|
+
export { textSource, markdownSource, pdfSource, docxSource, htmlSource, webSource, apiSource, createDatabaseKnowledgeSource, objectStorageSource, mcpResourceSource, fileSource, customSource, } from './source.js';
|
|
7
|
+
export type { KnowledgeSourceRegistry } from './registry.js';
|
|
8
|
+
export { createKnowledgeSourceRegistry } from './registry.js';
|
|
9
|
+
export { normalizeText } from './normalize.js';
|
|
10
|
+
export type { DocumentLoader, LoaderContext } from './loader.js';
|
|
11
|
+
export { throwIfAborted } from './loader.js';
|
|
12
|
+
export { textLoader } from './loaders/text.js';
|
|
13
|
+
export { markdownLoader, extractMarkdownTitle } from './loaders/markdown.js';
|
|
14
|
+
export { pdfLoader } from './loaders/pdf.js';
|
|
15
|
+
export { docxLoader } from './loaders/docx.js';
|
|
16
|
+
export { htmlLoader } from './loaders/html.js';
|
|
17
|
+
export { fileLoader } from './loaders/file.js';
|
|
18
|
+
export { webLoader } from './loaders/web.js';
|
|
19
|
+
export { apiLoader } from './loaders/api.js';
|
|
20
|
+
export { databaseLoader, createDatabaseLoader } from './loaders/database.js';
|
|
21
|
+
export { objectStorageLoader } from './loaders/object-storage.js';
|
|
22
|
+
export { mcpResourceLoader } from './loaders/mcp-resource.js';
|
|
23
|
+
export { extractHtmlStructure, serializeTable } from './loaders/html-structure.js';
|
|
24
|
+
export { assertSafeWebUrl, SsrfGuardError } from './net/ssrf-guard.js';
|
|
25
|
+
/**
|
|
26
|
+
* Default loader lookup by KnowledgeSourceType - `custom` has no default (Section 10: the
|
|
27
|
+
* caller supplies their own `DocumentLoader` for it).
|
|
28
|
+
*/
|
|
29
|
+
import type { DocumentLoader } from './loader.js';
|
|
30
|
+
import type { KnowledgeSourceType } from './source.js';
|
|
31
|
+
export declare const defaultKnowledgeLoaders: Readonly<Partial<Record<KnowledgeSourceType, DocumentLoader<never>>>>;
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE7C,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC;AACvG,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAEvF,YAAY,EACV,mBAAmB,EACnB,eAAe,EACf,0BAA0B,EAC1B,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,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BAA6B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAEnF,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEvE;;;GAGG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAavD,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAC5C,OAAO,CAAC,MAAM,CAAC,mBAAmB,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAa5D,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export { isUnrestrictedAcl } from './acl.js';
|
|
2
|
+
export { hashContent, deriveDocumentId, createKnowledgeDocument } from './document.js';
|
|
3
|
+
export { textSource, markdownSource, pdfSource, docxSource, htmlSource, webSource, apiSource, createDatabaseKnowledgeSource, objectStorageSource, mcpResourceSource, fileSource, customSource, } from './source.js';
|
|
4
|
+
export { createKnowledgeSourceRegistry } from './registry.js';
|
|
5
|
+
export { normalizeText } from './normalize.js';
|
|
6
|
+
export { throwIfAborted } from './loader.js';
|
|
7
|
+
export { textLoader } from './loaders/text.js';
|
|
8
|
+
export { markdownLoader, extractMarkdownTitle } from './loaders/markdown.js';
|
|
9
|
+
export { pdfLoader } from './loaders/pdf.js';
|
|
10
|
+
export { docxLoader } from './loaders/docx.js';
|
|
11
|
+
export { htmlLoader } from './loaders/html.js';
|
|
12
|
+
export { fileLoader } from './loaders/file.js';
|
|
13
|
+
export { webLoader } from './loaders/web.js';
|
|
14
|
+
export { apiLoader } from './loaders/api.js';
|
|
15
|
+
export { databaseLoader, createDatabaseLoader } from './loaders/database.js';
|
|
16
|
+
export { objectStorageLoader } from './loaders/object-storage.js';
|
|
17
|
+
export { mcpResourceLoader } from './loaders/mcp-resource.js';
|
|
18
|
+
export { extractHtmlStructure, serializeTable } from './loaders/html-structure.js';
|
|
19
|
+
export { assertSafeWebUrl, SsrfGuardError } from './net/ssrf-guard.js';
|
|
20
|
+
import { textLoader as _text } from './loaders/text.js';
|
|
21
|
+
import { markdownLoader as _markdown } from './loaders/markdown.js';
|
|
22
|
+
import { pdfLoader as _pdf } from './loaders/pdf.js';
|
|
23
|
+
import { docxLoader as _docx } from './loaders/docx.js';
|
|
24
|
+
import { htmlLoader as _html } from './loaders/html.js';
|
|
25
|
+
import { fileLoader as _file } from './loaders/file.js';
|
|
26
|
+
import { webLoader as _web } from './loaders/web.js';
|
|
27
|
+
import { apiLoader as _api } from './loaders/api.js';
|
|
28
|
+
import { databaseLoader as _database } from './loaders/database.js';
|
|
29
|
+
import { objectStorageLoader as _objectStorage } from './loaders/object-storage.js';
|
|
30
|
+
import { mcpResourceLoader as _mcpResource } from './loaders/mcp-resource.js';
|
|
31
|
+
export const defaultKnowledgeLoaders = {
|
|
32
|
+
text: _text,
|
|
33
|
+
markdown: _markdown,
|
|
34
|
+
pdf: _pdf,
|
|
35
|
+
docx: _docx,
|
|
36
|
+
html: _html,
|
|
37
|
+
file: _file,
|
|
38
|
+
web: _web,
|
|
39
|
+
api: _api,
|
|
40
|
+
database: _database,
|
|
41
|
+
'object-storage': _objectStorage,
|
|
42
|
+
'mcp-resource': _mcpResource,
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAG7C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAgCvF,OAAO,EACL,UAAU,EACV,cAAc,EACd,SAAS,EACT,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS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D,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,SAAS,IAAI,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,SAAS,IAAI,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,cAAc,IAAI,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,mBAAmB,IAAI,cAAc,EAAE,MAAM,6BAA6B,CAAC;AACpF,OAAO,EAAE,iBAAiB,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9E,MAAM,CAAC,MAAM,uBAAuB,GAEhC;IACF,IAAI,EAAE,KAAK;IACX,QAAQ,EAAE,SAAS;IACnB,GAAG,EAAE,IAAI;IACT,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,KAAK;IACX,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,QAAQ,EAAE,SAAS;IACnB,gBAAgB,EAAE,cAAc;IAChC,cAAc,EAAE,YAAY;CAC7B,CAAC"}
|
package/dist/loader.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { KnowledgeDocument } from './document.js';
|
|
2
|
+
import type { KnowledgeSource } from './source.js';
|
|
3
|
+
export interface LoaderContext {
|
|
4
|
+
readonly signal?: AbortSignal;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Loads documents from a KnowledgeSource (Section 15). Async iteration so a large source never
|
|
8
|
+
* has to be fully materialized in memory before the first document is available.
|
|
9
|
+
*/
|
|
10
|
+
export interface DocumentLoader<TConfig = unknown> {
|
|
11
|
+
load(source: KnowledgeSource<TConfig>, context?: LoaderContext): AsyncIterable<KnowledgeDocument>;
|
|
12
|
+
}
|
|
13
|
+
export declare function throwIfAborted(signal: AbortSignal | undefined): void;
|
|
14
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc,CAAC,OAAO,GAAG,OAAO;IAC/C,IAAI,CAAC,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa,CAAC,iBAAiB,CAAC,CAAC;CACnG;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,IAAI,CAIpE"}
|
package/dist/loader.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAeA,MAAM,UAAU,cAAc,CAAC,MAA+B;IAC5D,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,YAAY,CAAC,uBAAuB,EAAE,YAAY,CAAC,CAAC;IAChE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type DocumentLoader } from '../loader.js';
|
|
2
|
+
import type { ApiSourceConfig } from '../source.js';
|
|
3
|
+
/**
|
|
4
|
+
* API knowledge loader (Section 21) - intentionally distinct from a Phase 8 API *tool*: it only
|
|
5
|
+
* turns an already-fetched response into documents, never performs an action. `request`/
|
|
6
|
+
* `toDocuments` are entirely caller-supplied, so this package owns no HTTP client, base-URL
|
|
7
|
+
* policy, or credentials.
|
|
8
|
+
*/
|
|
9
|
+
export declare const apiLoader: DocumentLoader<ApiSourceConfig>;
|
|
10
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/loaders/api.ts"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,cAAc,EAAsB,MAAM,cAAc,CAAC;AAEvF,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,cAAc,CAAC;AAErE;;;;;GAKG;AACH,eAAO,MAAM,SAAS,EAAE,cAAc,CAAC,eAAe,CAgCrD,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* API knowledge loader (Section 21) - intentionally distinct from a Phase 8 API *tool*: it only
|
|
7
|
+
* turns an already-fetched response into documents, never performs an action. `request`/
|
|
8
|
+
* `toDocuments` are entirely caller-supplied, so this package owns no HTTP client, base-URL
|
|
9
|
+
* policy, or credentials.
|
|
10
|
+
*/
|
|
11
|
+
export const apiLoader = {
|
|
12
|
+
async *load(source, context) {
|
|
13
|
+
throwIfAborted(context?.signal);
|
|
14
|
+
let response;
|
|
15
|
+
try {
|
|
16
|
+
response = await source.config.request();
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
throw CopilotError.sourceLoadFailed(`API request failed: ${String(error)}`, {
|
|
20
|
+
sourceId: source.id,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
throwIfAborted(context?.signal);
|
|
24
|
+
const documents = source.config.toDocuments(response);
|
|
25
|
+
for (const doc of documents) {
|
|
26
|
+
const content = normalizeText(doc.content);
|
|
27
|
+
if (content.length === 0)
|
|
28
|
+
continue;
|
|
29
|
+
yield createKnowledgeDocument({
|
|
30
|
+
sourceId: source.id,
|
|
31
|
+
discriminator: doc.discriminator,
|
|
32
|
+
content,
|
|
33
|
+
metadata: {
|
|
34
|
+
...doc.metadata,
|
|
35
|
+
tenantId: source.tenantId,
|
|
36
|
+
acl: doc.metadata?.acl ?? source.acl,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/loaders/api.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;AAGhD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAoC;IACxD,KAAK,CAAC,CAAC,IAAI,CACT,MAAwC,EACxC,OAAuB;QAEvB,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAChC,IAAI,QAAiB,CAAC;QACtB,IAAI,CAAC;YACH,QAAQ,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QAC3C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,YAAY,CAAC,gBAAgB,CAAC,uBAAuB,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE;gBAC1E,QAAQ,EAAE,MAAM,CAAC,EAAE;aACpB,CAAC,CAAC;QACL,CAAC;QAED,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAChC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QACtD,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;YAC5B,MAAM,OAAO,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAC3C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;gBAAE,SAAS;YACnC,MAAM,uBAAuB,CAAC;gBAC5B,QAAQ,EAAE,MAAM,CAAC,EAAE;gBACnB,aAAa,EAAE,GAAG,CAAC,aAAa;gBAChC,OAAO;gBACP,QAAQ,EAAE;oBACR,GAAG,GAAG,CAAC,QAAQ;oBACf,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE,GAAG,IAAI,MAAM,CAAC,GAAG;iBACrC;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type DocumentLoader } from '../loader.js';
|
|
2
|
+
import type { DatabaseSourceConfig } from '../source.js';
|
|
3
|
+
/**
|
|
4
|
+
* Database knowledge loader (Section 22). `query` is the caller's own already-parameterized
|
|
5
|
+
* data access - this loader never constructs or executes SQL, so unrestricted
|
|
6
|
+
* natural-language-to-SQL access is impossible by construction (Section 22's explicit
|
|
7
|
+
* prohibition).
|
|
8
|
+
*/
|
|
9
|
+
export declare function createDatabaseLoader<TRow = unknown>(): DocumentLoader<DatabaseSourceConfig<TRow>>;
|
|
10
|
+
/** Default-configured database loader for callers not using a custom row type. */
|
|
11
|
+
export declare const databaseLoader: DocumentLoader<DatabaseSourceConfig>;
|
|
12
|
+
//# sourceMappingURL=database.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/loaders/database.ts"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,cAAc,EAAsB,MAAM,cAAc,CAAC;AAEvF,OAAO,KAAK,EAAE,oBAAoB,EAAmB,MAAM,cAAc,CAAC;AAE1E;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,GAAG,OAAO,KAAK,cAAc,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAkCjG;AAED,kFAAkF;AAClF,eAAO,MAAM,cAAc,EAAE,cAAc,CAAC,oBAAoB,CAA0B,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* Database knowledge loader (Section 22). `query` is the caller's own already-parameterized
|
|
7
|
+
* data access - this loader never constructs or executes SQL, so unrestricted
|
|
8
|
+
* natural-language-to-SQL access is impossible by construction (Section 22's explicit
|
|
9
|
+
* prohibition).
|
|
10
|
+
*/
|
|
11
|
+
export function createDatabaseLoader() {
|
|
12
|
+
return {
|
|
13
|
+
async *load(source, context) {
|
|
14
|
+
throwIfAborted(context?.signal);
|
|
15
|
+
let rows;
|
|
16
|
+
try {
|
|
17
|
+
rows = await source.config.query();
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
throw CopilotError.sourceLoadFailed(`Database query failed: ${String(error)}`, {
|
|
21
|
+
sourceId: source.id,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
throwIfAborted(context?.signal);
|
|
25
|
+
for (const [index, row] of rows.entries()) {
|
|
26
|
+
const doc = source.config.toDocument(row, index);
|
|
27
|
+
const content = normalizeText(doc.content);
|
|
28
|
+
if (content.length === 0)
|
|
29
|
+
continue;
|
|
30
|
+
yield createKnowledgeDocument({
|
|
31
|
+
sourceId: source.id,
|
|
32
|
+
discriminator: doc.discriminator ?? index,
|
|
33
|
+
content,
|
|
34
|
+
metadata: {
|
|
35
|
+
...doc.metadata,
|
|
36
|
+
tenantId: source.tenantId,
|
|
37
|
+
acl: doc.metadata?.acl ?? source.acl,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** Default-configured database loader for callers not using a custom row type. */
|
|
45
|
+
export const databaseLoader = createDatabaseLoader();
|
|
46
|
+
//# sourceMappingURL=database.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.js","sourceRoot":"","sources":["../../src/loaders/database.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;AAGhD;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO;QACL,KAAK,CAAC,CAAC,IAAI,CACT,MAAmD,EACnD,OAAuB;YAEvB,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAChC,IAAI,IAAqB,CAAC;YAC1B,IAAI,CAAC;gBACH,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACrC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,YAAY,CAAC,gBAAgB,CAAC,0BAA0B,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE;oBAC7E,QAAQ,EAAE,MAAM,CAAC,EAAE;iBACpB,CAAC,CAAC;YACL,CAAC;YAED,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAChC,KAAK,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;gBAC1C,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;gBACjD,MAAM,OAAO,GAAG,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBAC3C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;oBAAE,SAAS;gBACnC,MAAM,uBAAuB,CAAC;oBAC5B,QAAQ,EAAE,MAAM,CAAC,EAAE;oBACnB,aAAa,EAAE,GAAG,CAAC,aAAa,IAAI,KAAK;oBACzC,OAAO;oBACP,QAAQ,EAAE;wBACR,GAAG,GAAG,CAAC,QAAQ;wBACf,QAAQ,EAAE,MAAM,CAAC,QAAQ;wBACzB,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE,GAAG,IAAI,MAAM,CAAC,GAAG;qBACrC;iBACF,CAAC,CAAC;YACL,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,kFAAkF;AAClF,MAAM,CAAC,MAAM,cAAc,GAAyC,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type DocumentLoader } from '../loader.js';
|
|
2
|
+
import type { BinarySourceConfig } from '../source.js';
|
|
3
|
+
/**
|
|
4
|
+
* DOCX loader (Section 19) - converts to HTML via mammoth, then reuses the HTML structure
|
|
5
|
+
* extractor to preserve headings/paragraphs/tables (Section 20's table serialization applies
|
|
6
|
+
* here too, since mammoth already renders DOCX tables as `<table>`).
|
|
7
|
+
*/
|
|
8
|
+
export declare const docxLoader: DocumentLoader<BinarySourceConfig>;
|
|
9
|
+
//# sourceMappingURL=docx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docx.d.ts","sourceRoot":"","sources":["../../src/loaders/docx.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,KAAK,cAAc,EAAsB,MAAM,cAAc,CAAC;AAEvF,OAAO,KAAK,EAAE,kBAAkB,EAAmB,MAAM,cAAc,CAAC;AASxE;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,cAAc,CAAC,kBAAkB,CAwCzD,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { CopilotError } from '@gixcopilot/protocol';
|
|
3
|
+
import { convertToHtml } from 'mammoth';
|
|
4
|
+
import { createKnowledgeDocument } from '../document.js';
|
|
5
|
+
import { throwIfAborted } from '../loader.js';
|
|
6
|
+
import { normalizeText } from '../normalize.js';
|
|
7
|
+
import { extractHtmlStructure } from './html-structure.js';
|
|
8
|
+
async function readDocxBuffer(config) {
|
|
9
|
+
if (config.buffer)
|
|
10
|
+
return config.buffer;
|
|
11
|
+
if (config.path)
|
|
12
|
+
return readFile(config.path);
|
|
13
|
+
throw CopilotError.sourceLoadFailed('A DOCX source requires either "path" or "buffer".');
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* DOCX loader (Section 19) - converts to HTML via mammoth, then reuses the HTML structure
|
|
17
|
+
* extractor to preserve headings/paragraphs/tables (Section 20's table serialization applies
|
|
18
|
+
* here too, since mammoth already renders DOCX tables as `<table>`).
|
|
19
|
+
*/
|
|
20
|
+
export const docxLoader = {
|
|
21
|
+
async *load(source, context) {
|
|
22
|
+
throwIfAborted(context?.signal);
|
|
23
|
+
const buffer = await readDocxBuffer(source.config).catch((error) => {
|
|
24
|
+
if (CopilotError.isCopilotError(error))
|
|
25
|
+
throw error;
|
|
26
|
+
throw CopilotError.sourceLoadFailed(`Failed to read DOCX source: ${String(error)}`, {
|
|
27
|
+
sourceId: source.id,
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
let html;
|
|
31
|
+
try {
|
|
32
|
+
html = (await convertToHtml({ buffer })).value;
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
throw CopilotError.parseFailed(`Failed to parse DOCX source: ${String(error)}`, {
|
|
36
|
+
sourceId: source.id,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
throwIfAborted(context?.signal);
|
|
40
|
+
const structure = extractHtmlStructure(html);
|
|
41
|
+
const content = normalizeText(structure.text);
|
|
42
|
+
if (content.length === 0)
|
|
43
|
+
return;
|
|
44
|
+
yield createKnowledgeDocument({
|
|
45
|
+
sourceId: source.id,
|
|
46
|
+
content,
|
|
47
|
+
metadata: {
|
|
48
|
+
...(source.name !== undefined || structure.title !== undefined
|
|
49
|
+
? { title: source.name ?? structure.title }
|
|
50
|
+
: {}),
|
|
51
|
+
mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
52
|
+
tenantId: source.tenantId,
|
|
53
|
+
acl: source.acl,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=docx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docx.js","sourceRoot":"","sources":["../../src/loaders/docx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,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,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,KAAK,UAAU,cAAc,CAAC,MAA0B;IACtD,IAAI,MAAM,CAAC,MAAM;QAAE,OAAO,MAAM,CAAC,MAAM,CAAC;IACxC,IAAI,MAAM,CAAC,IAAI;QAAE,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC9C,MAAM,YAAY,CAAC,gBAAgB,CAAC,mDAAmD,CAAC,CAAC;AAC3F,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAuC;IAC5D,KAAK,CAAC,CAAC,IAAI,CACT,MAA2C,EAC3C,OAAuB;QAEvB,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAChC,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC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aAChB;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type DocumentLoader } from '../loader.js';
|
|
2
|
+
import type { FileSourceConfig } from '../source.js';
|
|
3
|
+
/** Generic file source (Section 10's `file` type) - dispatches to the matching typed loader by extension. */
|
|
4
|
+
export declare const fileLoader: DocumentLoader<FileSourceConfig>;
|
|
5
|
+
//# sourceMappingURL=file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/loaders/file.ts"],"names":[],"mappings":"AAIA,OAAO,EAAkB,KAAK,cAAc,EAAsB,MAAM,cAAc,CAAC;AAEvF,OAAO,KAAK,EAAE,gBAAgB,EAAmB,MAAM,cAAc,CAAC;AAQtE,6GAA6G;AAC7G,eAAO,MAAM,UAAU,EAAE,cAAc,CAAC,gBAAgB,CAgDvD,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { extname } from 'node:path';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { createKnowledgeDocument } from '../document.js';
|
|
4
|
+
import { throwIfAborted } from '../loader.js';
|
|
5
|
+
import { normalizeText } from '../normalize.js';
|
|
6
|
+
import { docxLoader } from './docx.js';
|
|
7
|
+
import { htmlLoader } from './html.js';
|
|
8
|
+
import { markdownLoader } from './markdown.js';
|
|
9
|
+
import { pdfLoader } from './pdf.js';
|
|
10
|
+
const EXTENSION_DISPATCH = new Set(['.pdf', '.docx', '.html', '.htm', '.md', '.markdown']);
|
|
11
|
+
/** Generic file source (Section 10's `file` type) - dispatches to the matching typed loader by extension. */
|
|
12
|
+
export const fileLoader = {
|
|
13
|
+
async *load(source, context) {
|
|
14
|
+
throwIfAborted(context?.signal);
|
|
15
|
+
const { path } = source.config;
|
|
16
|
+
const base = {
|
|
17
|
+
id: source.id,
|
|
18
|
+
...(source.name !== undefined ? { name: source.name } : {}),
|
|
19
|
+
...(source.tenantId !== undefined ? { tenantId: source.tenantId } : {}),
|
|
20
|
+
...(source.acl !== undefined ? { acl: source.acl } : {}),
|
|
21
|
+
...(source.metadata !== undefined ? { metadata: source.metadata } : {}),
|
|
22
|
+
};
|
|
23
|
+
const ext = extname(path).toLowerCase();
|
|
24
|
+
if (!EXTENSION_DISPATCH.has(ext)) {
|
|
25
|
+
const content = await readFile(path, 'utf8');
|
|
26
|
+
yield createKnowledgeDocument({
|
|
27
|
+
sourceId: source.id,
|
|
28
|
+
content: normalizeText(content),
|
|
29
|
+
metadata: {
|
|
30
|
+
...(source.name !== undefined ? { title: source.name } : {}),
|
|
31
|
+
uri: path,
|
|
32
|
+
mimeType: 'text/plain',
|
|
33
|
+
tenantId: source.tenantId,
|
|
34
|
+
acl: source.acl,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (ext === '.pdf') {
|
|
40
|
+
yield* pdfLoader.load({ ...base, type: 'pdf', config: { path } }, context);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (ext === '.docx') {
|
|
44
|
+
yield* docxLoader.load({ ...base, type: 'docx', config: { path } }, context);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (ext === '.html' || ext === '.htm') {
|
|
48
|
+
yield* htmlLoader.load({ ...base, type: 'html', config: { path } }, context);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
// .md / .markdown
|
|
52
|
+
const content = await readFile(path, 'utf8');
|
|
53
|
+
yield* markdownLoader.load({ ...base, type: 'markdown', config: { content } }, context);
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/loaders/file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,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