@hasna/switcher 0.2.7 → 0.2.8
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 +117 -6
- package/dist/chatgpt-launch.d.ts +2 -1
- package/dist/cli/index.js +1190 -65
- package/dist/codex-session-discovery.d.ts +24 -0
- package/dist/codex-state-bridge.d.ts +14 -0
- package/dist/codex-state-bridge.js +568 -0
- package/dist/harness-arguments.d.ts +8 -0
- package/dist/harness-types.d.ts +2 -0
- package/dist/launcher.d.ts +3 -0
- package/dist/mcp/index.js +6 -3
- package/dist/native-state-import.d.ts +44 -0
- package/dist/native-state.d.ts +32 -0
- package/package.json +1 -1
package/dist/mcp/index.js
CHANGED
|
@@ -6237,6 +6237,7 @@ import { z as z6 } from "zod";
|
|
|
6237
6237
|
import { createHash as createHash5 } from "crypto";
|
|
6238
6238
|
import { createInterface } from "readline/promises";
|
|
6239
6239
|
var absent = (error) => error instanceof SwitcherError && error.status === 404;
|
|
6240
|
+
var MAX_CREDENTIAL_MATCHES = 256;
|
|
6240
6241
|
var secretMetadataSchema = z6.object({
|
|
6241
6242
|
key: vaultKeySchema,
|
|
6242
6243
|
type: z6.enum(["api_key", "password", "token", "credential", "other"]),
|
|
@@ -6276,7 +6277,7 @@ async function discoverVaultReferences(provider, env = process.env, vaultExecuta
|
|
|
6276
6277
|
const operator2 = await resolveVaultOperatorEnvironment(provisional, env);
|
|
6277
6278
|
const entries = new Map;
|
|
6278
6279
|
for (const query of searchTerms(provider)) {
|
|
6279
|
-
const output = await runVaultCommand(provisional, ["search", query, "--json"], env, {}, {
|
|
6280
|
+
const output = await runVaultCommand(provisional, ["search", query, "--json", "--full", "--limit", String(MAX_CREDENTIAL_MATCHES + 1)], env, {}, {
|
|
6280
6281
|
captureBytes: 256 * 1024,
|
|
6281
6282
|
oversizeCode: "vault_metadata_oversized",
|
|
6282
6283
|
oversizeMessage: "Secrets returned too much credential metadata; narrow the vault naming or bind an exact key explicitly.",
|
|
@@ -6290,12 +6291,14 @@ async function discoverVaultReferences(provider, env = process.env, vaultExecuta
|
|
|
6290
6291
|
} catch {
|
|
6291
6292
|
throw new Fault(422, "vault_metadata_invalid", "Hasna Secrets returned invalid credential metadata JSON.");
|
|
6292
6293
|
}
|
|
6293
|
-
|
|
6294
|
+
if (Array.isArray(parsed) && parsed.length > MAX_CREDENTIAL_MATCHES)
|
|
6295
|
+
throw new Fault(422, "credential_matches_too_many", "More than 256 credential metadata rows matched. Bind an exact vault key explicitly.");
|
|
6296
|
+
const result = secretMetadataSchema.array().max(MAX_CREDENTIAL_MATCHES).safeParse(parsed);
|
|
6294
6297
|
if (!result.success)
|
|
6295
6298
|
throw new Fault(422, "vault_metadata_invalid", "Hasna Secrets returned an unsupported credential metadata shape.");
|
|
6296
6299
|
for (const entry of result.data)
|
|
6297
6300
|
entries.set(entry.key, entry);
|
|
6298
|
-
if (entries.size >
|
|
6301
|
+
if (entries.size > MAX_CREDENTIAL_MATCHES)
|
|
6299
6302
|
throw new Fault(422, "credential_matches_too_many", "More than 256 credential references matched. Bind an exact vault key explicitly.");
|
|
6300
6303
|
}
|
|
6301
6304
|
return [...entries.values()].sort((a, b) => a.key.localeCompare(b.key)).map((entry) => ({ account: operator2.source, key: entry.key, url: operator2.url, executable: vaultExecutable, operator: { kind: "contracts", expectedSource: operator2.source, expectedTier: operator2.tier } }));
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type NativeState } from "./native-state";
|
|
2
|
+
type Identity = {
|
|
3
|
+
dev: number;
|
|
4
|
+
ino: number;
|
|
5
|
+
size: number;
|
|
6
|
+
mtimeMs: number;
|
|
7
|
+
ctimeMs: number;
|
|
8
|
+
};
|
|
9
|
+
type File = {
|
|
10
|
+
path: string;
|
|
11
|
+
bytes: number;
|
|
12
|
+
sha256: string;
|
|
13
|
+
source: Identity;
|
|
14
|
+
existing: boolean;
|
|
15
|
+
sessionId?: string;
|
|
16
|
+
};
|
|
17
|
+
export type NativeStateImport = {
|
|
18
|
+
state: NativeState;
|
|
19
|
+
source: string;
|
|
20
|
+
entries: string[];
|
|
21
|
+
directories: string[];
|
|
22
|
+
files: File[];
|
|
23
|
+
bytes: number;
|
|
24
|
+
};
|
|
25
|
+
/** Entire import is checked before writes. Account/auth/config/SQLite files
|
|
26
|
+
* cannot be selected, including through links. This is a snapshot, not cutover. */
|
|
27
|
+
export declare function planNativeStateImport(state: NativeState, source: string, selection?: string[]): Promise<NativeStateImport>;
|
|
28
|
+
export declare function nativeStateImportDigest(plan: NativeStateImport): string;
|
|
29
|
+
export declare function nativeStateImportSummary(plan: NativeStateImport, applied: boolean): {
|
|
30
|
+
mode: string;
|
|
31
|
+
tool: import("./native-state").SharedNativeTool;
|
|
32
|
+
entries: string[];
|
|
33
|
+
planDigest: string;
|
|
34
|
+
files: number;
|
|
35
|
+
newFiles: number;
|
|
36
|
+
publishedFiles: number;
|
|
37
|
+
bytes: number;
|
|
38
|
+
originalsPreserved: boolean;
|
|
39
|
+
cutoverComplete: boolean;
|
|
40
|
+
sqliteCopied: boolean;
|
|
41
|
+
notice: string;
|
|
42
|
+
};
|
|
43
|
+
export declare function applyNativeStateImport(plan: NativeStateImport): Promise<void>;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type SharedNativeTool = "codex" | "claude";
|
|
2
|
+
export type NativeState = {
|
|
3
|
+
tool: SharedNativeTool;
|
|
4
|
+
home: string;
|
|
5
|
+
sqliteHome?: string;
|
|
6
|
+
marker: string;
|
|
7
|
+
instructions?: Record<string, unknown>;
|
|
8
|
+
};
|
|
9
|
+
export declare function nativeStateRequested(tool: SharedNativeTool, environment?: NodeJS.ProcessEnv, explicit?: boolean): boolean;
|
|
10
|
+
export declare function validateNativeStateVersion(tool: SharedNativeTool, version: string | undefined): void;
|
|
11
|
+
export declare const CODEX_INSTRUCTION_KEYS: readonly ["instructions", "developer_instructions", "model_instructions_file", "compact_prompt", "experimental_compact_prompt_file", "include_permissions_instructions", "include_apps_instructions", "include_collaboration_mode_instructions", "include_environment_context", "project_doc_max_bytes", "project_doc_fallback_filenames"];
|
|
12
|
+
type Entry = {
|
|
13
|
+
name: string;
|
|
14
|
+
kind: "directory" | "file";
|
|
15
|
+
};
|
|
16
|
+
export declare const NATIVE_STATE_ENTRIES: Record<SharedNativeTool, readonly Entry[]>;
|
|
17
|
+
export declare function assertNativeStateDirectory(path: string): Promise<void>;
|
|
18
|
+
export declare function ensureNativeStateDirectory(path: string, create?: boolean): Promise<void>;
|
|
19
|
+
export declare function withNativeStateLock<T>(state: NativeState, operation: () => Promise<T>): Promise<T>;
|
|
20
|
+
/** A nested CLI keeps its authentication home. Refuse conflicting instruction
|
|
21
|
+
* overlays rather than rewriting account config or exposing instructions in argv. */
|
|
22
|
+
export declare function assertNativeInstructionOverlay(state: NativeState, overlayHome: string): Promise<void>;
|
|
23
|
+
/** This marker identifies the corpus, never the selected authentication home. */
|
|
24
|
+
export declare function resolveNativeState(tool: SharedNativeTool, environment?: NodeJS.ProcessEnv, options?: {
|
|
25
|
+
create?: boolean;
|
|
26
|
+
}): Promise<NativeState>;
|
|
27
|
+
export declare function nativeStateEnvironment(state: NativeState): Record<string, string>;
|
|
28
|
+
/** Metadata only. Old data remains visible as pending migration; normal launch
|
|
29
|
+
* never treats starting a fresh shared overlay as completed legacy migration. */
|
|
30
|
+
export declare function legacyNativeStateWarnings(root: string, state: NativeState): Promise<string[]>;
|
|
31
|
+
export declare function projectNativeState(state: NativeState, overlayHome: string): Promise<void>;
|
|
32
|
+
export {};
|
package/package.json
CHANGED