@hydraharness/harness-tool-media 0.1.1-rc.6

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.
@@ -0,0 +1,23 @@
1
+ //#region lib/types/invariant.js
2
+ /**
3
+ * Package-owned invariant companion for `@hydraharness/harness-tool-media`.
4
+ * @module @hydraharness/harness-tool-media/invariant
5
+ */
6
+ const PACKAGE_NAME = "@hydraharness/harness-tool-media";
7
+ /** Cordis companion plugin name. */
8
+ const name = "tool-media-invariant";
9
+ /** Service required before the companion can reserve package ownership. */
10
+ const inject = ["invariants"];
11
+ /**
12
+ * No runtime invariant: the tool owns no event stream; the tool registry owns
13
+ * settlement and the attachment service owns durable image and video objects.
14
+ */
15
+ const install = () => {};
16
+ /**
17
+ * Register this package's invariant companion.
18
+ * @param ctx - Cordis context carrying the invariant service.
19
+ * @returns the installed registration's disposer after setup succeeds.
20
+ */
21
+ const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
22
+ //#endregion
23
+ export { apply, inject, name };
@@ -0,0 +1,11 @@
1
+ /** Retrieve a saved Gemini Web task through the selected account and durable attachment store. */
2
+ import type { Context } from '@hydraharness/cordis';
3
+ import type { VideoConfig } from './video.ts';
4
+ import type { GoogleImageConfig } from './image-google.ts';
5
+ /** Register read-only task recovery with the existing media presentation protocol.
6
+ * @param ctx - Tools and attachment services, with optional LLM routes.
7
+ * @param image - Image response and prompt-independent attachment limits.
8
+ * @param video - Video polling, response, and attachment limits.
9
+ */
10
+ export declare function registerGeminiWebRetrieve(ctx: Context, image: GoogleImageConfig, video: VideoConfig): void;
11
+ //# sourceMappingURL=gemini-web-retrieve.d.ts.map
@@ -0,0 +1,23 @@
1
+ /** Durable attachment admission for decoded provider image results. */
2
+ import { admitEncodedImages, type AttachmentStore, type ImageMediaType } from '@hydraharness/harness-attachment';
3
+ /** Describe stored images without loading image bytes into model history.
4
+ * @param images - Durable image references available to later media calls.
5
+ * @returns Attachment ids and image properties in a bounded JSON summary.
6
+ */
7
+ export declare function generatedImageSummary(images: readonly {
8
+ attachmentId: string;
9
+ mediaType: string;
10
+ width: number;
11
+ height: number;
12
+ }[]): string;
13
+ /** Store each generated image using its position and media type as the filename.
14
+ * @param store - session attachment owner.
15
+ * @param images - encoded final provider images.
16
+ * @param jobId - Optional provider job id for recovery after attachment admission fails.
17
+ * @returns admitted references in provider order.
18
+ */
19
+ export declare function admitGeneratedImages(store: AttachmentStore, images: readonly {
20
+ data: string;
21
+ mimeType: ImageMediaType;
22
+ }[], jobId?: string | null): ReturnType<typeof admitEncodedImages>;
23
+ //# sourceMappingURL=generated-images.d.ts.map
@@ -0,0 +1,11 @@
1
+ /** Bounded durable video admission shared by generation and saved-task recovery. */
2
+ import type { AttachmentStore, VideoAttachmentRef } from '@hydraharness/harness-attachment';
3
+ /** Persist a completed video without retaining its stream in the transcript.
4
+ * @param store - Durable attachment owner.
5
+ * @param response - Completed MP4 or WebM response.
6
+ * @param maxBytes - Deployment byte limit.
7
+ * @param signal - Cancellation covering download and storage.
8
+ * @returns A durable video reference after every byte has been stored.
9
+ */
10
+ export declare function admitGeneratedVideo(store: AttachmentStore, response: Response, maxBytes: number, signal: AbortSignal): Promise<VideoAttachmentRef>;
11
+ //# sourceMappingURL=generated-video.d.ts.map
@@ -0,0 +1,36 @@
1
+ /** Google Gemini image generation with durable chat attachments.
2
+ * @module @hydraharness/harness-tool-media
3
+ */
4
+ import type { Context } from '@hydraharness/cordis';
5
+ import z from '@hydraharness/schemastery';
6
+ /** Gemini routing and response limits; credentials hold the secret value. */
7
+ export interface GoogleImageConfig {
8
+ /** Use saved image models before the standalone Gemini route. */
9
+ useProviderModels?: boolean;
10
+ /** Restrict configured-model fallback to this provider route. */
11
+ provider?: string;
12
+ /** Bare Gemini image model id. */
13
+ model?: string;
14
+ /** Gemini REST base URL; HTTP is allowed only on loopback. */
15
+ baseURL?: string;
16
+ /** Environment-style credential reference. */
17
+ apiKeyEnv?: string;
18
+ /** Cooperative request budget in milliseconds. */
19
+ timeoutMs?: number;
20
+ /** Maximum encoded HTTP response bytes, including thought parts. */
21
+ maxResponseBytes?: number;
22
+ /** Maximum prompt characters. */
23
+ maxPromptChars?: number;
24
+ /** Maximum final images admitted from one response. */
25
+ maxImages?: number;
26
+ }
27
+ /** Loader defaults for Gemini image generation. */
28
+ export declare const GoogleImageConfig: z<GoogleImageConfig>;
29
+ /**
30
+ * Register image_generate_google with final images in presentation metadata.
31
+ * Each call makes one stateless generateContent request without automatic retries.
32
+ * @param ctx - Tool, credential, and attachment services.
33
+ * @param config - Loader-validated deployment configuration.
34
+ */
35
+ export declare function registerGoogleImages(ctx: Context, config: GoogleImageConfig): void;
36
+ //# sourceMappingURL=image-google.d.ts.map
@@ -0,0 +1,38 @@
1
+ /** OpenAI image generation with durable attachments and chat presentation.
2
+ * @module @hydraharness/harness-tool-media
3
+ */
4
+ import type { Context } from '@hydraharness/cordis';
5
+ import z from '@hydraharness/schemastery';
6
+ /** OpenAI routing and bounded request configuration; secrets remain in credentials. */
7
+ export interface OpenAIImageConfig {
8
+ /** Use endpoint-compatible models saved on the Models page before the standalone route. */
9
+ useProviderModels?: boolean;
10
+ /** Restrict configured-model fallback to this provider route. */
11
+ provider?: string;
12
+ /** Additional models tried on the standalone route after an explicit HTTP rejection. */
13
+ fallbackModels?: string[];
14
+ /** OpenAI image model id. */
15
+ model?: string;
16
+ /** Images API base URL; HTTP is allowed only on loopback. */
17
+ baseURL?: string;
18
+ /** Environment-style credential reference. */
19
+ apiKeyEnv?: string;
20
+ /** Cooperative request budget in milliseconds. */
21
+ timeoutMs?: number;
22
+ /** Maximum encoded HTTP response bytes. */
23
+ maxResponseBytes?: number;
24
+ /** Maximum prompt characters. */
25
+ maxPromptChars?: number;
26
+ /** Maximum images per call, also bounded by attachment admission. */
27
+ maxImages?: number;
28
+ }
29
+ /** Loader defaults for the Images API. */
30
+ export declare const OpenAIImageConfig: z<OpenAIImageConfig>;
31
+ /**
32
+ * Register image_generate over configured Images API routes. Explicit rejections
33
+ * permit fallback; timeouts and ambiguous failures stop to avoid duplicate billing.
34
+ * @param ctx - Tool, credential, and attachment services.
35
+ * @param config - Loader-validated deployment configuration.
36
+ */
37
+ export declare function registerOpenAIImages(ctx: Context, config: OpenAIImageConfig): void;
38
+ //# sourceMappingURL=image-openai.d.ts.map
@@ -0,0 +1,29 @@
1
+ /** Image and video generation tools under one disposable Cordis plugin.
2
+ * @module @hydraharness/harness-tool-media
3
+ */
4
+ import type { Context } from '@hydraharness/cordis';
5
+ import z from '@hydraharness/schemastery';
6
+ import { OpenAIImageConfig } from './image-openai.ts';
7
+ import { GoogleImageConfig } from './image-google.ts';
8
+ import { VideoConfig } from './video.ts';
9
+ /** Cordis plugin name. */
10
+ export declare const name = "tool-media";
11
+ /** Services consumed by image and video generation. */
12
+ export declare const inject: string[];
13
+ /** Provider settings for the tools controlled by the shared plugin switch. */
14
+ export interface Config {
15
+ /** OpenAI-compatible image routing and admission. */
16
+ openai?: OpenAIImageConfig;
17
+ /** Native Gemini image routing and admission. */
18
+ google?: GoogleImageConfig;
19
+ /** Configured video routing, polling, and storage limits. */
20
+ video?: VideoConfig;
21
+ }
22
+ /** Loader defaults for all media tools. */
23
+ export declare const Config: z<Config>;
24
+ /** Register all media tools in the same fiber so one switch disposes them together.
25
+ * @param ctx - Tool, credential, and attachment services.
26
+ * @param config - Loader-validated settings for each generation API.
27
+ */
28
+ export declare function apply(ctx: Context, config: Config): void;
29
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Package-owned invariant companion for `@hydraharness/harness-tool-media`.
3
+ * @module @hydraharness/harness-tool-media/invariant
4
+ */
5
+ import type { Context } from '@hydraharness/cordis';
6
+ /** Cordis companion plugin name. */
7
+ export declare const name = "tool-media-invariant";
8
+ /** Service required before the companion can reserve package ownership. */
9
+ export declare const inject: string[];
10
+ /**
11
+ * Register this package's invariant companion.
12
+ * @param ctx - Cordis context carrying the invariant service.
13
+ * @returns the installed registration's disposer after setup succeeds.
14
+ */
15
+ export declare const apply: (ctx: Context) => Promise<() => void>;
16
+ //# sourceMappingURL=invariant.d.ts.map
@@ -0,0 +1,7 @@
1
+ /** Non-secret provider job correlation carried by completed media responses. */
2
+ /** Read a validated local recovery id without admitting provider URLs into metadata.
3
+ * @param response - Completed media response.
4
+ * @returns A local UUID, or undefined for providers without saved-task recovery.
5
+ */
6
+ export declare function mediaJobId(response: Response): string | undefined;
7
+ //# sourceMappingURL=media-job.d.ts.map
@@ -0,0 +1,28 @@
1
+ /** Configured video generation with bounded durable file storage. */
2
+ import type { Context } from '@hydraharness/cordis';
3
+ import z from '@hydraharness/schemastery';
4
+ /** Video routing and storage limits; credentials belong to the selected provider. */
5
+ export interface VideoConfig {
6
+ /** Restrict configured-model fallback to this provider route. */
7
+ provider?: string;
8
+ /** Model hint after the saved video model selection. */
9
+ model?: string;
10
+ /** Deadline covering submission, polling, download, and storage. */
11
+ timeoutMs?: number;
12
+ /** Interval between status requests for an accepted video job. */
13
+ pollIntervalMs?: number;
14
+ /** Maximum bytes in each provider job response. */
15
+ maxResponseBytes?: number;
16
+ /** Maximum downloaded video bytes. */
17
+ maxVideoBytes?: number;
18
+ /** Maximum prompt characters. */
19
+ maxPromptChars?: number;
20
+ }
21
+ /** Loader defaults for video polling and storage. */
22
+ export declare const VideoConfig: z<VideoConfig>;
23
+ /** Register video_generate using the saved video provider and model.
24
+ * @param ctx - Tool and attachment services, with optional configured LLM routes.
25
+ * @param config - Loader-validated polling and storage limits.
26
+ */
27
+ export declare function registerVideos(ctx: Context, config: VideoConfig): void;
28
+ //# sourceMappingURL=video.d.ts.map
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@hydraharness/harness-tool-media",
3
+ "description": "Image and video generation with durable chat attachments",
4
+ "hydra": {
5
+ "plugin": {
6
+ "application": "Generate images and videos and show them directly in chat."
7
+ }
8
+ },
9
+ "version": "0.1.1-rc.6",
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/MaiHongPhong1902/Hydra-Harness.git",
16
+ "directory": "packages/media/tool-media"
17
+ },
18
+ "type": "module",
19
+ "main": "lib/index.js",
20
+ "types": "lib/types/index.d.ts",
21
+ "exports": {
22
+ ".": {
23
+ "types": "./lib/types/index.d.ts",
24
+ "default": "./lib/index.js"
25
+ },
26
+ "./invariant": {
27
+ "types": "./lib/types/invariant.d.ts",
28
+ "default": "./lib/invariant.js"
29
+ },
30
+ "./src/*": "./src/*",
31
+ "./package.json": "./package.json"
32
+ },
33
+ "files": [
34
+ "lib/index.js",
35
+ "lib/invariant.js",
36
+ "lib/types/**/*.d.ts"
37
+ ],
38
+ "license": "MIT",
39
+ "peerDependencies": {
40
+ "@hydraharness/harness-credentials": "^0.1.1-rc.6",
41
+ "@hydraharness/harness-llm": "^0.1.1-rc.6",
42
+ "@hydraharness/harness-attachment": "^0.1.1-rc.6",
43
+ "@hydraharness/harness-tools": "^0.1.1-rc.6",
44
+ "@hydraharness/harness-invariants": "^0.1.1-rc.6",
45
+ "@hydraharness/cordis": "^4.0.2"
46
+ },
47
+ "dependencies": {
48
+ "zod": "^4.4.3",
49
+ "@hydraharness/schemastery": "^3.18.2"
50
+ },
51
+ "devDependencies": {
52
+ "@hydraharness/harness-attachment": "^0.1.1-rc.6",
53
+ "@hydraharness/harness-credentials": "^0.1.1-rc.6",
54
+ "@hydraharness/harness-tools": "^0.1.1-rc.6",
55
+ "@hydraharness/harness-invariants": "^0.1.1-rc.6",
56
+ "@hydraharness/cordis": "^4.0.2",
57
+ "@hydraharness/harness-attachment-local": "^0.1.1-rc.6",
58
+ "@hydraharness/harness-llm": "^0.1.1-rc.6",
59
+ "@hydraharness/harness-system-prompt": "^0.1.1-rc.6",
60
+ "@hydraharness/harness-credentials-local": "^0.1.1-rc.6",
61
+ "@hydraharness/harness-session": "^0.1.1-rc.6"
62
+ }
63
+ }