@krischoichoi/channel-files 0.6.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/README.md +79 -0
- package/lib/attachment-resolver.d.ts +24 -0
- package/lib/attachment-resolver.d.ts.map +1 -0
- package/lib/attachment-resolver.js +38 -0
- package/lib/attachment-resolver.js.map +1 -0
- package/lib/attachments/extractors/docx.d.ts +6 -0
- package/lib/attachments/extractors/docx.d.ts.map +1 -0
- package/lib/attachments/extractors/docx.js +43 -0
- package/lib/attachments/extractors/docx.js.map +1 -0
- package/lib/attachments/extractors/index.d.ts +10 -0
- package/lib/attachments/extractors/index.d.ts.map +1 -0
- package/lib/attachments/extractors/index.js +10 -0
- package/lib/attachments/extractors/index.js.map +1 -0
- package/lib/attachments/extractors/pdf.d.ts +4 -0
- package/lib/attachments/extractors/pdf.d.ts.map +1 -0
- package/lib/attachments/extractors/pdf.js +44 -0
- package/lib/attachments/extractors/pdf.js.map +1 -0
- package/lib/attachments/extractors/registry.d.ts +43 -0
- package/lib/attachments/extractors/registry.d.ts.map +1 -0
- package/lib/attachments/extractors/registry.js +82 -0
- package/lib/attachments/extractors/registry.js.map +1 -0
- package/lib/attachments/extractors/text.d.ts +17 -0
- package/lib/attachments/extractors/text.d.ts.map +1 -0
- package/lib/attachments/extractors/text.js +0 -0
- package/lib/attachments/extractors/text.js.map +1 -0
- package/lib/attachments/extractors/types.d.ts +62 -0
- package/lib/attachments/extractors/types.d.ts.map +1 -0
- package/lib/attachments/extractors/types.js +13 -0
- package/lib/attachments/extractors/types.js.map +1 -0
- package/lib/attachments/extractors/xlsx.d.ts +6 -0
- package/lib/attachments/extractors/xlsx.d.ts.map +1 -0
- package/lib/attachments/extractors/xlsx.js +83 -0
- package/lib/attachments/extractors/xlsx.js.map +1 -0
- package/lib/attachments/filename.d.ts +23 -0
- package/lib/attachments/filename.d.ts.map +1 -0
- package/lib/attachments/filename.js +62 -0
- package/lib/attachments/filename.js.map +1 -0
- package/lib/attachments/hash.d.ts +5 -0
- package/lib/attachments/hash.d.ts.map +1 -0
- package/lib/attachments/hash.js +13 -0
- package/lib/attachments/hash.js.map +1 -0
- package/lib/attachments/index.d.ts +18 -0
- package/lib/attachments/index.d.ts.map +1 -0
- package/lib/attachments/index.js +18 -0
- package/lib/attachments/index.js.map +1 -0
- package/lib/attachments/mime.d.ts +27 -0
- package/lib/attachments/mime.d.ts.map +1 -0
- package/lib/attachments/mime.js +162 -0
- package/lib/attachments/mime.js.map +1 -0
- package/lib/attachments/pipeline-extractor.d.ts +8 -0
- package/lib/attachments/pipeline-extractor.d.ts.map +1 -0
- package/lib/attachments/pipeline-extractor.js +62 -0
- package/lib/attachments/pipeline-extractor.js.map +1 -0
- package/lib/attachments/pipeline.d.ts +29 -0
- package/lib/attachments/pipeline.d.ts.map +1 -0
- package/lib/attachments/pipeline.js +59 -0
- package/lib/attachments/pipeline.js.map +1 -0
- package/lib/attachments/policy.d.ts +25 -0
- package/lib/attachments/policy.d.ts.map +1 -0
- package/lib/attachments/policy.js +21 -0
- package/lib/attachments/policy.js.map +1 -0
- package/lib/attachments/render.d.ts +16 -0
- package/lib/attachments/render.d.ts.map +1 -0
- package/lib/attachments/render.js +28 -0
- package/lib/attachments/render.js.map +1 -0
- package/lib/attachments/schema.d.ts +58 -0
- package/lib/attachments/schema.d.ts.map +1 -0
- package/lib/attachments/schema.js +50 -0
- package/lib/attachments/schema.js.map +1 -0
- package/lib/attachments/store.d.ts +69 -0
- package/lib/attachments/store.d.ts.map +1 -0
- package/lib/attachments/store.js +254 -0
- package/lib/attachments/store.js.map +1 -0
- package/lib/attachments/tool-read.d.ts +34 -0
- package/lib/attachments/tool-read.d.ts.map +1 -0
- package/lib/attachments/tool-read.js +182 -0
- package/lib/attachments/tool-read.js.map +1 -0
- package/lib/attachments/types.d.ts +96 -0
- package/lib/attachments/types.d.ts.map +1 -0
- package/lib/attachments/types.js +18 -0
- package/lib/attachments/types.js.map +1 -0
- package/lib/backends/harness-native.d.ts +45 -0
- package/lib/backends/harness-native.d.ts.map +1 -0
- package/lib/backends/harness-native.js +56 -0
- package/lib/backends/harness-native.js.map +1 -0
- package/lib/catalog/legacy-backfill.d.ts +34 -0
- package/lib/catalog/legacy-backfill.d.ts.map +1 -0
- package/lib/catalog/legacy-backfill.js +49 -0
- package/lib/catalog/legacy-backfill.js.map +1 -0
- package/lib/catalog/store.d.ts +121 -0
- package/lib/catalog/store.d.ts.map +1 -0
- package/lib/catalog/store.js +227 -0
- package/lib/catalog/store.js.map +1 -0
- package/lib/catalog/types.d.ts +83 -0
- package/lib/catalog/types.d.ts.map +1 -0
- package/lib/catalog/types.js +29 -0
- package/lib/catalog/types.js.map +1 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +12 -0
- package/lib/index.js.map +1 -0
- package/lib/migration/migrate-on-read.d.ts +61 -0
- package/lib/migration/migrate-on-read.d.ts.map +1 -0
- package/lib/migration/migrate-on-read.js +61 -0
- package/lib/migration/migrate-on-read.js.map +1 -0
- package/lib/migration/verify.d.ts +20 -0
- package/lib/migration/verify.d.ts.map +1 -0
- package/lib/migration/verify.js +35 -0
- package/lib/migration/verify.js.map +1 -0
- package/lib/paths.d.ts +13 -0
- package/lib/paths.d.ts.map +1 -0
- package/lib/paths.js +23 -0
- package/lib/paths.js.map +1 -0
- package/lib/plugin.d.ts +4 -0
- package/lib/plugin.d.ts.map +1 -0
- package/lib/plugin.js +6 -0
- package/lib/plugin.js.map +1 -0
- package/lib/service.d.ts +27 -0
- package/lib/service.d.ts.map +1 -0
- package/lib/service.js +67 -0
- package/lib/service.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compare the SHA-256 of the given bytes against the expected digest.
|
|
3
|
+
* Returns `false` on any mismatch (also when the digest format differs).
|
|
4
|
+
*/
|
|
5
|
+
export declare function verifyFileIntegrity(data: Uint8Array, expectedSha256: string): boolean;
|
|
6
|
+
export interface ReadBackVerifiedOptions {
|
|
7
|
+
/** Read the (native) bytes back for verification. */
|
|
8
|
+
readBack: () => Promise<Uint8Array>;
|
|
9
|
+
/** Expected SHA-256; verification fails on mismatch. */
|
|
10
|
+
expectedSha256: string;
|
|
11
|
+
/** Expected byte length; a length mismatch also fails verification. */
|
|
12
|
+
expectedBytes?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Read the copied bytes back and verify them: any read-back failure, byte
|
|
16
|
+
* length mismatch (when `expectedBytes` is given) or hash mismatch returns
|
|
17
|
+
* `false` — the migration must then stay legacy-authoritative.
|
|
18
|
+
*/
|
|
19
|
+
export declare function readBackVerified(options: ReadBackVerifiedOptions): Promise<boolean>;
|
|
20
|
+
//# sourceMappingURL=verify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/migration/verify.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,UAAU,EAChB,cAAc,EAAE,MAAM,GACrB,OAAO,CAET;AAED,MAAM,WAAW,uBAAuB;IACtC,qDAAqD;IACrD,QAAQ,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;IACpC,wDAAwD;IACxD,cAAc,EAAE,MAAM,CAAC;IACvB,uEAAuE;IACvE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,OAAO,CAAC,CAWlB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration integrity verification.
|
|
3
|
+
*
|
|
4
|
+
* Lazy migration is COPY + VERIFY, never move: after the legacy bytes are
|
|
5
|
+
* copied into the native backend we read them back and compare the recomputed
|
|
6
|
+
* SHA-256 (and byte length) against the legacy record. Any mismatch means the
|
|
7
|
+
* native copy is NOT trusted and the legacy backend stays authoritative.
|
|
8
|
+
*/
|
|
9
|
+
import { sha256Hex } from '../attachments/hash.js';
|
|
10
|
+
/**
|
|
11
|
+
* Compare the SHA-256 of the given bytes against the expected digest.
|
|
12
|
+
* Returns `false` on any mismatch (also when the digest format differs).
|
|
13
|
+
*/
|
|
14
|
+
export function verifyFileIntegrity(data, expectedSha256) {
|
|
15
|
+
return sha256Hex(data) === expectedSha256;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Read the copied bytes back and verify them: any read-back failure, byte
|
|
19
|
+
* length mismatch (when `expectedBytes` is given) or hash mismatch returns
|
|
20
|
+
* `false` — the migration must then stay legacy-authoritative.
|
|
21
|
+
*/
|
|
22
|
+
export async function readBackVerified(options) {
|
|
23
|
+
let data;
|
|
24
|
+
try {
|
|
25
|
+
data = await options.readBack();
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
if (options.expectedBytes !== undefined && data.byteLength !== options.expectedBytes) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return verifyFileIntegrity(data, options.expectedSha256);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../src/migration/verify.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAgB,EAChB,cAAsB;IAEtB,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,cAAc,CAAC;AAC5C,CAAC;AAWD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAgC;IAEhC,IAAI,IAAgB,CAAC;IACrB,IAAI,CAAC;QACH,IAAI,GAAG,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,OAAO,CAAC,aAAa,KAAK,SAAS,IAAI,IAAI,CAAC,UAAU,KAAK,OAAO,CAAC,aAAa,EAAE,CAAC;QACrF,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;AAC3D,CAAC"}
|
package/lib/paths.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One on-disk directory segment for an attachment id.
|
|
3
|
+
*
|
|
4
|
+
* Raw harness attachment ids may carry characters that are illegal in
|
|
5
|
+
* Windows path segments (the content-addressed `sha256:...` form, issue #7).
|
|
6
|
+
* Only the unsafe set is encoded deterministically - legacy `att-*` ids and
|
|
7
|
+
* every plain id map to themselves, so existing stores keep their on-disk
|
|
8
|
+
* layout. Must stay in sync with every path this store derives from an id.
|
|
9
|
+
*/
|
|
10
|
+
export declare function assetPathSegment(attachmentId: string): string;
|
|
11
|
+
export declare function resolveAttachmentsRoot(): string;
|
|
12
|
+
export declare function resolveAssetDirectory(attachmentId: string, sessionId: string, messageId: string): string;
|
|
13
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAI7D;AAED,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C;AAED,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,MAAM,CAER"}
|
package/lib/paths.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { resolveChannelDataDirectory } from '@krischoichoi/channel-core';
|
|
3
|
+
/**
|
|
4
|
+
* One on-disk directory segment for an attachment id.
|
|
5
|
+
*
|
|
6
|
+
* Raw harness attachment ids may carry characters that are illegal in
|
|
7
|
+
* Windows path segments (the content-addressed `sha256:...` form, issue #7).
|
|
8
|
+
* Only the unsafe set is encoded deterministically - legacy `att-*` ids and
|
|
9
|
+
* every plain id map to themselves, so existing stores keep their on-disk
|
|
10
|
+
* layout. Must stay in sync with every path this store derives from an id.
|
|
11
|
+
*/
|
|
12
|
+
export function assetPathSegment(attachmentId) {
|
|
13
|
+
return attachmentId.replace(/[<>:"/\|?*\u0000-\u001f]/g, (char) => {
|
|
14
|
+
return '_' + char.charCodeAt(0).toString(16).padStart(2, '0') + '_';
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export function resolveAttachmentsRoot() {
|
|
18
|
+
return join(resolveChannelDataDirectory(), 'attachments', 'v1');
|
|
19
|
+
}
|
|
20
|
+
export function resolveAssetDirectory(attachmentId, sessionId, messageId) {
|
|
21
|
+
return join(resolveAttachmentsRoot(), 'sessions', sessionId, messageId, assetPathSegment(attachmentId));
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=paths.js.map
|
package/lib/paths.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAEzE;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,YAAoB;IACnD,OAAO,YAAY,CAAC,OAAO,CAAC,2BAA2B,EAAE,CAAC,IAAI,EAAE,EAAE;QAChE,OAAO,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,sBAAsB;IACpC,OAAO,IAAI,CAAC,2BAA2B,EAAE,EAAE,aAAa,EAAE,IAAI,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,YAAoB,EACpB,SAAiB,EACjB,SAAiB;IAEjB,OAAO,IAAI,CAAC,sBAAsB,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC;AAC1G,CAAC"}
|
package/lib/plugin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAGnD,eAAO,MAAM,IAAI,kBAAkB,CAAC;AAEpC,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAExC"}
|
package/lib/plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,CAAC,MAAM,IAAI,GAAG,eAAe,CAAC;AAEpC,MAAM,UAAU,KAAK,CAAC,GAAY;IAChC,IAAI,kBAAkB,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC"}
|
package/lib/service.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Service, type Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { ChannelAttachmentContext, ChannelAttachmentDescriptor, ChannelAttachmentProvider, ChannelImageStoreInput, ResolvedChannelAttachment, StoredBinaryPart } from '@krischoichoi/channel-harness';
|
|
3
|
+
import { FileChannelInboundAssetStore } from './attachments/store.js';
|
|
4
|
+
declare module '@deepseek-ai/cordis' {
|
|
5
|
+
interface Context {
|
|
6
|
+
channelFiles: ChannelFileService;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export declare class ChannelFileService extends Service implements ChannelAttachmentProvider {
|
|
10
|
+
readonly storeBackend: FileChannelInboundAssetStore;
|
|
11
|
+
private readonly extractor;
|
|
12
|
+
constructor(ctx: Context);
|
|
13
|
+
store(context: ChannelAttachmentContext, part: StoredBinaryPart): Promise<import("./index.js").StoredAssetDescriptor | undefined>;
|
|
14
|
+
/**
|
|
15
|
+
* Mirror one inbound image into the private asset store under the HARNESS
|
|
16
|
+
* attachmentId (the model-visible `sha256:…` ref id) so the outbox can
|
|
17
|
+
* resolve it for outbound sends (issue #7). The harness image seam stays
|
|
18
|
+
* authoritative; images are content assets with no text extraction, so the
|
|
19
|
+
* stored asset is born `readable: false` / `not-needed`.
|
|
20
|
+
*/
|
|
21
|
+
storeImage(context: ChannelAttachmentContext, image: ChannelImageStoreInput): Promise<ChannelAttachmentDescriptor | undefined>;
|
|
22
|
+
installCompatibilityTools(agentContext: Context): Promise<void>;
|
|
23
|
+
/** @deprecated use installCompatibilityTools. */
|
|
24
|
+
installTools(agentContext: Context): Promise<void>;
|
|
25
|
+
resolveAttachment(attachmentId: string, sessionId: string): Promise<ResolvedChannelAttachment>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EACV,wBAAwB,EACxB,2BAA2B,EAC3B,yBAAyB,EACzB,sBAAsB,EACtB,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAQtE,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,OAAO;QACf,YAAY,EAAE,kBAAkB,CAAC;KAClC;CACF;AAED,qBAAa,kBAAmB,SAAQ,OAAQ,YAAW,yBAAyB;IAClF,QAAQ,CAAC,YAAY,EAAE,4BAA4B,CAAC;IACpD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAwD;gBAEtE,GAAG,EAAE,OAAO;IAKxB,KAAK,CAAC,OAAO,EAAE,wBAAwB,EAAE,IAAI,EAAE,gBAAgB;IAM/D;;;;;;OAMG;IACG,UAAU,CACd,OAAO,EAAE,wBAAwB,EACjC,KAAK,EAAE,sBAAsB,GAC5B,OAAO,CAAC,2BAA2B,GAAG,SAAS,CAAC;IAyBnD,yBAAyB,CAAC,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAM/D,iDAAiD;IACjD,YAAY,CAAC,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD,iBAAiB,CACf,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,yBAAyB,CAAC;CAKtC"}
|
package/lib/service.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Service } from '@deepseek-ai/cordis';
|
|
2
|
+
import { FileChannelInboundAssetStore } from './attachments/store.js';
|
|
3
|
+
import { DEFAULT_ATTACHMENT_POLICY } from './attachments/policy.js';
|
|
4
|
+
import { createAttachmentExtractor } from './attachments/pipeline-extractor.js';
|
|
5
|
+
import { storeBinaryPart } from './attachments/pipeline.js';
|
|
6
|
+
import { installReadChannelAttachmentTool } from './attachments/tool-read.js';
|
|
7
|
+
import { resolveAttachment } from './attachment-resolver.js';
|
|
8
|
+
import { sanitizeFilename } from './attachments/filename.js';
|
|
9
|
+
export class ChannelFileService extends Service {
|
|
10
|
+
storeBackend;
|
|
11
|
+
extractor = createAttachmentExtractor(DEFAULT_ATTACHMENT_POLICY);
|
|
12
|
+
constructor(ctx) {
|
|
13
|
+
super(ctx, 'channelFiles');
|
|
14
|
+
this.storeBackend = new FileChannelInboundAssetStore();
|
|
15
|
+
}
|
|
16
|
+
store(context, part) {
|
|
17
|
+
return storeBinaryPart(this.storeBackend, context, part, {
|
|
18
|
+
extractor: this.extractor,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Mirror one inbound image into the private asset store under the HARNESS
|
|
23
|
+
* attachmentId (the model-visible `sha256:…` ref id) so the outbox can
|
|
24
|
+
* resolve it for outbound sends (issue #7). The harness image seam stays
|
|
25
|
+
* authoritative; images are content assets with no text extraction, so the
|
|
26
|
+
* stored asset is born `readable: false` / `not-needed`.
|
|
27
|
+
*/
|
|
28
|
+
async storeImage(context, image) {
|
|
29
|
+
const asset = await this.storeBackend.put({
|
|
30
|
+
attachmentId: image.attachmentId,
|
|
31
|
+
sessionId: context.sessionId,
|
|
32
|
+
channelId: context.channelId,
|
|
33
|
+
accountId: context.accountId,
|
|
34
|
+
conversationId: context.conversationId,
|
|
35
|
+
...(context.conversationType ? { conversationType: context.conversationType } : {}),
|
|
36
|
+
...(context.threadId ? { threadId: context.threadId } : {}),
|
|
37
|
+
messageId: context.messageId,
|
|
38
|
+
kind: 'image',
|
|
39
|
+
name: sanitizeFilename(image.name ?? 'image'),
|
|
40
|
+
...(image.mimeType ? { mimeType: image.mimeType } : {}),
|
|
41
|
+
data: image.data,
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
attachmentId: asset.attachmentId,
|
|
45
|
+
name: asset.name,
|
|
46
|
+
mimeType: asset.mimeType,
|
|
47
|
+
bytes: asset.bytes,
|
|
48
|
+
durable: true,
|
|
49
|
+
readable: false,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
installCompatibilityTools(agentContext) {
|
|
53
|
+
return installReadChannelAttachmentTool(agentContext, {
|
|
54
|
+
store: this.storeBackend,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** @deprecated use installCompatibilityTools. */
|
|
58
|
+
installTools(agentContext) {
|
|
59
|
+
return this.installCompatibilityTools(agentContext);
|
|
60
|
+
}
|
|
61
|
+
resolveAttachment(attachmentId, sessionId) {
|
|
62
|
+
return resolveAttachment(attachmentId, sessionId, this.storeBackend, {
|
|
63
|
+
policy: DEFAULT_ATTACHMENT_POLICY,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@krischoichoi/channel-files",
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/krischoichoi/dsh-channels.git"
|
|
7
|
+
},
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"description": "Optional generic file storage and document extraction for dsh-channels",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./lib/index.js",
|
|
14
|
+
"types": "./lib/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./lib/index.d.ts",
|
|
18
|
+
"default": "./lib/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./package.json": "./package.json"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"lib"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsc -p tsconfig.json",
|
|
27
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
28
|
+
"test": "vitest run",
|
|
29
|
+
"clean": "rimraf lib"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@deepseek-ai/cordis": "^4.0.4",
|
|
33
|
+
"@deepseek-ai/dsh-atomic-write": "0.2.0-rc.2",
|
|
34
|
+
"@deepseek-ai/dsh-home-paths": "0.2.0-rc.2",
|
|
35
|
+
"@deepseek-ai/dsh-llm": "0.2.0-rc.2",
|
|
36
|
+
"@krischoichoi/channel-core": "workspace:*",
|
|
37
|
+
"@krischoichoi/channel-harness": "workspace:*",
|
|
38
|
+
"mammoth": "1.12.1",
|
|
39
|
+
"unpdf": "1.8.1",
|
|
40
|
+
"xlsx": "0.18.5",
|
|
41
|
+
"zod": "^4.4.3"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@deepseek-ai/dsh-session-projection": "0.2.0-rc.2",
|
|
45
|
+
"@deepseek-ai/dsh-timeout": "0.2.0-rc.2",
|
|
46
|
+
"@deepseek-ai/dsh-tools": "0.2.0-rc.2",
|
|
47
|
+
"@deepseek-ai/dsh-user-approval": "0.2.0-rc.2",
|
|
48
|
+
"rimraf": "^6.0.0"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@deepseek-ai/dsh-tools": "0.2.0-rc.2"
|
|
52
|
+
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"@deepseek-ai/dsh-tools": {
|
|
55
|
+
"optional": true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"license": "MIT"
|
|
59
|
+
}
|