@xiaohhhh1/canvas-agent 0.4.34 → 0.4.35

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.
@@ -34,3 +34,4 @@ export declare class LocalVideoIntelligence {
34
34
  export declare function localVideoAnalysisPrompt(source: LocalVideoLearningSource, durationMs: number, transcript: string, attachments: AgentAttachment[]): string;
35
35
  export declare function assertJointVisualAndSpokenEvidence(analysis: Record<string, unknown>): void;
36
36
  export declare function timedTranscriptFromVtt(value: string): string;
37
+ export declare function resolveLocalCodexEntrypoint(): string;
@@ -1,8 +1,8 @@
1
1
  import { spawn } from "node:child_process";
2
2
  import { mkdtemp, readFile, readdir, rm, writeFile } from "node:fs/promises";
3
+ import { createRequire } from "node:module";
3
4
  import os from "node:os";
4
5
  import path from "node:path";
5
- import { fileURLToPath } from "node:url";
6
6
  const ANALYSIS_TIMEOUT_MS = 10 * 60_000;
7
7
  const TRANSCRIPT_LANGUAGES = "en.*,es.*,zh.*,pt.*,fr.*,de.*,vi.*,th.*,id.*,ms.*,ja.*,ko.*";
8
8
  export class LocalVideoIntelligence {
@@ -173,7 +173,10 @@ function transcriptPreference(file) {
173
173
  }
174
174
  async function runLocalCodexAnalysis(prompt, attachments, workDir) {
175
175
  const outputFile = path.join(workDir, "analysis.json");
176
- const codexEntrypoint = fileURLToPath(new URL("../../node_modules/@openai/codex/bin/codex.js", import.meta.url));
176
+ // npm hoists dependencies next to the installed package in production, while
177
+ // local development may keep them at a different ancestor. Resolve from this
178
+ // module instead of assuming a nested node_modules directory.
179
+ const codexEntrypoint = resolveLocalCodexEntrypoint();
177
180
  const args = [codexEntrypoint, "exec", "--ephemeral", "--skip-git-repo-check", "--sandbox", "read-only", "--color", "never", "--output-last-message", outputFile];
178
181
  for (const attachment of attachments)
179
182
  args.push("--image", path.join(workDir, String(attachment.name)));
@@ -189,6 +192,9 @@ async function runLocalCodexAnalysis(prompt, attachments, workDir) {
189
192
  throw new Error("本机 Codex 没有返回可校验的 JSON 视频分析结果");
190
193
  }
191
194
  }
195
+ export function resolveLocalCodexEntrypoint() {
196
+ return createRequire(import.meta.url).resolve("@openai/codex/bin/codex.js");
197
+ }
192
198
  async function runProcess(command, args, options) {
193
199
  return await new Promise((resolve) => {
194
200
  let stderr = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xiaohhhh1/canvas-agent",
3
- "version": "0.4.34",
3
+ "version": "0.4.35",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",