Skip to content

armgit / hypit

Public Imported from GitHub
0

Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.

fix: bridge HypiHub OAuth credentials to reference tools

rpone6d37cc68cb1b
diff --git a/packages/reference-video-tools/package.json b/packages/reference-video-tools/package.json
index 5495b3f8..82c5b7ff 100644
--- a/packages/reference-video-tools/package.json
+++ b/packages/reference-video-tools/package.json
@@ -13,6 +13,7 @@
},
"dependencies": {
"@hypit/composition": "workspace:*",
+ "@hypit/credential-store-os": "workspace:*",
"@hypit/core": "workspace:*",
"@hypit/driver-node": "workspace:*",
"@hypit/estimate": "workspace:*",
@@ -26,6 +27,7 @@
"@hypit/program-space": "workspace:*",
"@hypit/protocol": "workspace:*",
"@hypit/run-markup": "workspace:*",
+ "@hypit/runtime": "workspace:*",
"@hypit/provider-whisperx-local": "workspace:*",
"@hypit/provider-media-local": "workspace:*",
"@hypit/provider-hypihub": "workspace:*",
diff --git a/packages/reference-video-tools/src/tools.ts b/packages/reference-video-tools/src/tools.ts
index 8a0b8041..4405529e 100644
--- a/packages/reference-video-tools/src/tools.ts
+++ b/packages/reference-video-tools/src/tools.ts
@@ -5,6 +5,8 @@ import { createHash } from "node:crypto";
import { deflateSync } from "node:zlib";
import { basename, dirname, join, resolve } from "node:path";
import { loadNodePackageSelection, locateNodePackage, physicalPackageName } from "@hypit/package-loader-node";
+import { OsCredentialStore } from "@hypit/credential-store-os";
+import { credentialRef } from "@hypit/runtime";
import { markupSurfaceHostFacetAbi } from "@hypit/markup";
import type { RegisteredSurface, SurfaceVocabulary } from "@hypit/markup";
import { exactModelHostAbi } from "@hypit/model-kit";
@@ -790,7 +792,7 @@ function positiveInt(value: number, label: string): number {
}
async function defaultGenerate(model: string): Promise<GenerateText> {
- const hypiHubKey = process.env.HYPIHUB_API_KEY?.trim();
+ const hypiHubKey = await resolveHypiHubApiKey();
const backend = process.env.HYPIT_GEMINI_PROVIDER?.trim().toLowerCase() || "auto";
if (backend !== "auto" && backend !== "hypihub" && backend !== "vertex") {
throw new Error("HYPIT_GEMINI_PROVIDER must be auto, hypihub or vertex");
@@ -838,6 +840,18 @@ async function defaultGenerate(model: string): Promise<GenerateText> {
};
}
+/** Resolve the HypiHub credential written by `hypit auth login`, with env fallback. */
+async function resolveHypiHubApiKey(): Promise<string | undefined> {
+ if (process.platform === "darwin" || process.platform === "win32") {
+ const value = await new OsCredentialStore()
+ .resolve(credentialRef("os", "hypihub.oauth"))
+ .catch(() => undefined);
+ const secret = value?.secret?.trim();
+ if (secret) return secret;
+ }
+ return process.env.HYPIHUB_API_KEY?.trim() || undefined;
+}
+
const MIME_TYPES: Readonly<Record<string, string>> = {
jpg: "image/jpeg",
jpeg: "image/jpeg",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b2cab32b..fda9fa02 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -2404,6 +2404,9 @@ importers:
'@hypit/core':
specifier: workspace:*
version: link:../core
+ '@hypit/credential-store-os':
+ specifier: workspace:*
+ version: link:../credential-store-os
'@hypit/driver-node':
specifier: workspace:*
version: link:../driver-node
@@ -2452,6 +2455,9 @@ importers:
'@hypit/run-markup':
specifier: workspace:*
version: link:../run-markup
+ '@hypit/runtime':
+ specifier: workspace:*
+ version: link:../runtime
'@hypit/script':
specifier: workspace:*
version: link:../script