pi-oracle 0.7.11 → 0.7.12

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.
@@ -22,6 +22,9 @@ import { getProjectId } from "./runtime.js";
22
22
  export const ORACLE_PROVIDERS = ["chatgpt", "grok"] as const;
23
23
  export type OracleProvider = (typeof ORACLE_PROVIDERS)[number];
24
24
 
25
+ export { resolveOracleArchiveFormat, resolveOracleProviderArchivePlan } from "./provider-capabilities.js";
26
+ export type { OracleArchiveFormat, OracleProviderArchivePlan } from "./provider-capabilities.js";
27
+
25
28
  export const MODEL_FAMILIES = ["instant", "thinking", "pro", "grok"] as const;
26
29
  export type OracleModelFamily = (typeof MODEL_FAMILIES)[number];
27
30
 
@@ -209,13 +212,19 @@ export function getProviderAuthSeedProfileDir(config: OracleConfig, provider: Or
209
212
  }
210
213
 
211
214
  export function resolveOracleConfigForProvider(config: OracleConfig, provider: OracleProvider): OracleConfig {
212
- if (provider === "chatgpt") return config;
215
+ const defaults = {
216
+ ...config.defaults,
217
+ provider,
218
+ };
219
+ if (provider === "chatgpt") {
220
+ return {
221
+ ...config,
222
+ defaults,
223
+ };
224
+ }
213
225
  return {
214
226
  ...config,
215
- defaults: {
216
- ...config.defaults,
217
- provider,
218
- },
227
+ defaults,
219
228
  browser: {
220
229
  ...config.browser,
221
230
  authSeedProfileDir: getProviderAuthSeedProfileDir(config, provider),
@@ -28,6 +28,7 @@ import type { OracleJobLifecycleEvent as SharedOracleJobLifecycleEvent, OracleJo
28
28
  import { hasDurableWorkerHandoff as sharedHasDurableWorkerHandoff } from "../shared/job-coordination-helpers.mjs";
29
29
  import { isTrackedProcessAlive, readProcessStartedAt, spawnDetachedNodeProcess, terminateTrackedProcess } from "../shared/process-helpers.mjs";
30
30
  import type { OracleConfig, OracleResolvedSelection } from "./config.js";
31
+ import { resolveOracleProviderArchivePlan } from "./provider-capabilities.js";
31
32
  import { withJobLock, withLock } from "./locks.js";
32
33
  import { cleanupRuntimeArtifacts, getProjectId, getSessionId, parseConversationId, requirePersistedSessionFile, type OracleCleanupReport } from "./runtime.js";
33
34
 
@@ -911,7 +912,7 @@ export async function createJob(
911
912
  const logsDir = join(jobDir, "logs");
912
913
  const workerLogPath = join(logsDir, "worker.log");
913
914
  const promptPath = join(jobDir, "prompt.md");
914
- const archivePath = join(jobDir, `context-${id}.tar.zst`);
915
+ const archivePath = join(jobDir, `context-${id}.${resolveOracleProviderArchivePlan(input.selection.provider).archiveExtension}`);
915
916
  const responsePath = join(jobDir, "response.md");
916
917
  const reasoningPath = join(jobDir, "reasoning.md");
917
918
  const artifactsManifestPath = join(jobDir, "artifacts.json");
@@ -0,0 +1,41 @@
1
+ // Purpose: Centralize provider-specific archive capabilities for oracle submissions.
2
+ // Responsibilities: Map each supported provider to archive format, file extension, upload ceiling, and local compression dependencies.
3
+ // Scope: Static provider capability data only; config loading, archive writing, and runtime preflight live in sibling modules.
4
+ // Usage: Imported by config, jobs, tools, runtime, and archive code so provider policy stays in one canonical place.
5
+ // Invariants/Assumptions: Provider ids are defined by config.ts, while this module must not import config values to avoid runtime/config cycles.
6
+ import type { OracleProvider } from "./config.js";
7
+
8
+ export type OracleArchiveFormat = "tar.zst" | "tar.gz";
9
+
10
+ export interface OracleProviderArchivePlan {
11
+ provider: OracleProvider;
12
+ archiveFormat: OracleArchiveFormat;
13
+ archiveExtension: OracleArchiveFormat;
14
+ maxArchiveBytes: number;
15
+ requiresZstd: boolean;
16
+ }
17
+
18
+ const ORACLE_PROVIDER_ARCHIVE_PLANS: Record<OracleProvider, OracleProviderArchivePlan> = {
19
+ chatgpt: {
20
+ provider: "chatgpt",
21
+ archiveFormat: "tar.zst",
22
+ archiveExtension: "tar.zst",
23
+ maxArchiveBytes: 250 * 1024 * 1024,
24
+ requiresZstd: true,
25
+ },
26
+ grok: {
27
+ provider: "grok",
28
+ archiveFormat: "tar.gz",
29
+ archiveExtension: "tar.gz",
30
+ maxArchiveBytes: 200 * 1024 * 1024,
31
+ requiresZstd: false,
32
+ },
33
+ };
34
+
35
+ export function resolveOracleProviderArchivePlan(provider: OracleProvider): OracleProviderArchivePlan {
36
+ return ORACLE_PROVIDER_ARCHIVE_PLANS[provider];
37
+ }
38
+
39
+ export function resolveOracleArchiveFormat(provider: OracleProvider): OracleArchiveFormat {
40
+ return resolveOracleProviderArchivePlan(provider).archiveFormat;
41
+ }
@@ -11,7 +11,8 @@ import { delimiter, dirname, join } from "node:path";
11
11
  import { assertNotKnownBrowserUserDataPath, sweetCookieSafeStoragePasswordScrubbedEnv } from "../shared/browser-profile-helpers.mjs";
12
12
  import { jobBlocksAdmission } from "../shared/job-coordination-helpers.mjs";
13
13
  import { isTrackedProcessAlive } from "../shared/process-helpers.mjs";
14
- import type { OracleConfig } from "./config.js";
14
+ import type { OracleConfig, OracleProvider } from "./config.js";
15
+ import { resolveOracleProviderArchivePlan } from "./provider-capabilities.js";
15
16
  import { createLease, listLeaseMetadata, readLeaseMetadata, releaseLease, withAuthLock } from "./locks.js";
16
17
 
17
18
  const SEED_GENERATION_FILE = ".oracle-seed-generation";
@@ -49,12 +50,15 @@ function cpCommand(): string {
49
50
  return process.env.PI_ORACLE_CP_PATH?.trim() || "cp";
50
51
  }
51
52
 
52
- function requiredOracleDependencies(config: OracleConfig): Array<{ name: string; command: string }> {
53
+ function requiredOracleDependencies(config: OracleConfig, provider = config.defaults.provider): Array<{ name: string; command: string }> {
54
+ const archivePlan = resolveOracleProviderArchivePlan(provider);
53
55
  const dependencies = [
54
56
  { name: "agent-browser", command: AGENT_BROWSER_BIN },
55
57
  { name: "tar", command: "tar" },
56
- { name: "zstd", command: "zstd" },
57
58
  ];
59
+ if (archivePlan.requiresZstd) {
60
+ dependencies.push({ name: "zstd", command: "zstd" });
61
+ }
58
62
  if (config.browser.cloneStrategy === "apfs-clone" && process.platform === "darwin") {
59
63
  dependencies.push({ name: "cp", command: cpCommand() });
60
64
  }
@@ -325,11 +329,11 @@ export async function assertOracleAuthSeedProfileReady(config: OracleConfig): Pr
325
329
  }
326
330
  }
327
331
 
328
- export async function assertOracleSubmitPrerequisites(config: OracleConfig): Promise<void> {
332
+ export async function assertOracleSubmitPrerequisites(config: OracleConfig, provider: OracleProvider = config.defaults.provider): Promise<void> {
329
333
  assertSafeOracleProfilePath(config.browser.runtimeProfilesDir, "runtime profiles", config);
330
334
  await assertOracleAuthSeedProfileReady(config);
331
335
  await assertConfiguredBrowserExecutableReady(config.browser.executablePath);
332
- for (const dependency of requiredOracleDependencies(config)) {
336
+ for (const dependency of requiredOracleDependencies(config, provider)) {
333
337
  await assertRequiredLocalDependencyReady(dependency.name, dependency.command);
334
338
  }
335
339
  await assertWritableDirectory(config.browser.runtimeProfilesDir, "runtime profiles");