@hasna/switcher 0.1.9 → 0.2.1

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/dist/domain.d.ts CHANGED
@@ -3,7 +3,7 @@ import { type RoutingEvent } from "./model-policy-schema";
3
3
  export { modelPolicySchema, routingEventSchema, routingEventsSchema } from "./model-policy-schema";
4
4
  export type { ModelPolicy, RoutingEvent } from "./model-policy-schema";
5
5
  export type { AuthStyle } from "./auth";
6
- export declare const VERSION = "0.1.9";
6
+ export declare const VERSION = "0.2.1";
7
7
  export declare const harnessSchema: z.ZodEnum<["claude", "codex", "grok", "opencode", "opencode2", "pi", "omp", "dsh", "cline", "hermes", "prime-agent", "gemini", "aider", "kilo"]>;
8
8
  export declare const protocolSchema: z.ZodEnum<["anthropic-messages", "openai-responses", "openai-chat", "gemini-generate-content"]>;
9
9
  export declare const idSchema: z.ZodString;
@@ -1,5 +1,6 @@
1
+ import { type ProviderRequestTiming } from "./provider-request";
1
2
  import type { HarnessLaunchInput } from "./harness-types";
2
- export declare function geminiBridge(input: HarnessLaunchInput): {
3
+ export declare function geminiBridge(input: HarnessLaunchInput, timing?: ProviderRequestTiming): {
3
4
  baseUrl: string;
4
5
  token: string;
5
6
  cleanup: () => Promise<void>;
@@ -1,3 +1,4 @@
1
+ import { type ProviderRequestTiming } from "./provider-request";
1
2
  import { type ReasoningEffort } from "./reasoning";
2
3
  import type { HarnessId, HarnessLaunchInput, PreparedLaunch } from "./harness-types";
3
4
  export declare function detectHarness(harness: HarnessId, override?: string): Promise<{
@@ -48,4 +49,9 @@ export declare function codexModel(model: HarnessLaunchInput["models"][number],
48
49
  instructions_variables: null;
49
50
  };
50
51
  };
52
+ export declare function grokBridge(input: HarnessLaunchInput, timing?: ProviderRequestTiming): {
53
+ baseUrl: string;
54
+ token: string;
55
+ cleanup: () => Promise<void>;
56
+ };
51
57
  export declare function prepareHarnessLaunch(input: HarnessLaunchInput): Promise<PreparedLaunch>;
@@ -1,3 +1,4 @@
1
+ import { type ProviderRequestTiming } from "./provider-request";
1
2
  import type { HarnessLaunchInput, PreparedLaunch } from "./harness-types";
2
3
  /** Hermes' native runtime names for the three Switcher wire contracts. */
3
4
  export declare const hermesApiMode: {
@@ -10,7 +11,7 @@ export declare const hermesApiMode: {
10
11
  * Hermes' custom provider client uses Bearer locally; this bridge translates
11
12
  * that local credential into the provider's declared upstream header style.
12
13
  */
13
- export declare function createHermesBridge(input: Pick<HarnessLaunchInput, "baseUrl" | "protocol" | "authStyle" | "model" | "models" | "credential">): {
14
+ export declare function createHermesBridge(input: Pick<HarnessLaunchInput, "baseUrl" | "protocol" | "authStyle" | "model" | "models" | "credential">, timing?: ProviderRequestTiming): {
14
15
  baseUrl: string;
15
16
  token: string;
16
17
  cleanup: () => Promise<void>;
package/dist/index.js CHANGED
@@ -234,6 +234,11 @@ var preset = (id, name, protocols, sources, alias) => parse(providerPresetSchema
234
234
  verification: "documented"
235
235
  });
236
236
  var providerPresets = [
237
+ ...["opencode", "opencode-go"].map((id) => preset(id, id === "opencode" ? "OpenCode Zen" : "OpenCode Go", ["openai-chat", "openai-responses", "anthropic-messages"].map((protocol) => route(protocol, id === "opencode" ? "https://opencode.ai/zen/v1" : "https://opencode.ai/zen/go/v1", {
238
+ authStyle: protocol === "anthropic-messages" ? "x-api-key" : "bearer",
239
+ catalogAuthStyle: "none",
240
+ notes: ["Discovers the full live catalog. Claude requests are adapted to each model's documented native endpoint. Other harnesses require models compatible with their selected protocol. Go requires an active subscription and coding-agent session headers."]
241
+ })), ["https://opencode.ai/docs/zen/", "https://opencode.ai/docs/go/"], "OPENCODE_API_KEY")),
237
242
  preset("deepseek", "DeepSeek", [
238
243
  route("openai-chat", "https://api.deepseek.com", { catalogBaseUrl: "https://api.deepseek.com" }),
239
244
  route("openai-responses", "https://api.deepseek.com", { catalogBaseUrl: "https://api.deepseek.com" }),
@@ -1,3 +1,4 @@
1
+ import { type ProviderRequestTiming } from "./provider-request";
1
2
  import { type ReasoningEffort } from "./reasoning";
2
3
  import type { HarnessLaunchInput } from "./harness-types";
3
4
  import { type CompiledModelPolicy } from "./model-policy";
@@ -18,7 +19,7 @@ type GatewayInput = HarnessLaunchInput & {
18
19
  onRoutingEvent?: (event: RoutingEvent) => void;
19
20
  };
20
21
  /** A per-launch credential boundary: the native client never receives the provider key. */
21
- export declare function createInferenceGateway(input: GatewayInput): {
22
+ export declare function createInferenceGateway(input: GatewayInput, timing?: ProviderRequestTiming): {
22
23
  baseUrl: string;
23
24
  token: string;
24
25
  cleanup: () => Promise<void>;
@@ -0,0 +1,30 @@
1
+ /** The deliberate unhosted opt-in, canonical name first. */
2
+ export declare const SWITCHER_LOCAL_OPT_IN_ENV_KEYS: readonly ["HASNA_SWITCHER_LOCAL", "SWITCHER_LOCAL"];
3
+ /** The Keychain item the shared resolver reads for this app (account: HASNA_STATION or the short hostname). */
4
+ export declare const SWITCHER_KEYCHAIN_ITEM = "hasna.credentials.switcher.api-key";
5
+ /** The canonical credentials file, as operators know it. */
6
+ export declare const SWITCHER_CREDENTIALS_FILE = "~/.hasna/switcher/config/credentials";
7
+ export type SwitcherLocalOptInEnv = Record<string, string | undefined>;
8
+ /** True when the operator deliberately asked for the unhosted on-box run. */
9
+ export declare function isSwitcherLocalOptIn(env?: SwitcherLocalOptInEnv): boolean;
10
+ /** Every env name that can configure a Switcher authority or credential, resolver-derived. */
11
+ export declare function switcherAuthorityEnvKeys(): string[];
12
+ /**
13
+ * Does the ENVIRONMENT itself declare a Switcher authority or credential?
14
+ *
15
+ * Deliberately narrower than "does a credential resolve": answering it must not
16
+ * touch the Keychain or the filesystem. A DECLARED variable counts even when
17
+ * blank — Switcher has always let Contracts refuse a blank override loudly
18
+ * rather than fall through to another identity or to local data.
19
+ */
20
+ export declare function hasSwitcherEnvAuthorityIntent(env?: SwitcherLocalOptInEnv): boolean;
21
+ /** True when this environment should be served by the on-box local run. */
22
+ export declare function selectsSwitcherLocalMode(env?: SwitcherLocalOptInEnv): boolean;
23
+ /** The credential sources a fail-closed refusal names. Never a value. */
24
+ export declare function switcherCredentialSources(env?: SwitcherLocalOptInEnv): string[];
25
+ /** The one-line refusal for "nothing configured": tiers consulted plus the opt-in, never a value. */
26
+ export declare function remoteConfigMissingMessage(env?: SwitcherLocalOptInEnv): string;
27
+ /** Print the LOCAL-mode notice once per process. `write` is a test seam. */
28
+ export declare function announceSwitcherLocalMode(home: string, write?: (line: string) => void): void;
29
+ /** Test seam. */
30
+ export declare function resetSwitcherLocalModeAnnouncement(): void;