@anthonyhaussman/opencode-agy-auth 1.1.13 → 1.1.14-alpha.0

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.
@@ -9,3 +9,4 @@ export { transformAgyResponse } from "./response";
9
9
  export { isGenerativeLanguageRequest, parseGenerativeLanguageRequest } from "./shared";
10
10
  export { initTurnStateTracker, getTurnStateTracker, shutdownTurnStateTracker, TurnStateTracker } from "./turn-state-tracker";
11
11
  export type { TurnState } from "./turn-state-tracker";
12
+ export { ToolMapper, getToolMapper, sanitizeToolName, restoreToolNamesInResponse, clearToolMapper, } from "./tool-mapper";
@@ -6,10 +6,11 @@
6
6
  * Encapsulating this conversion in the SDK completely shields the OpenCode plugin app layer from non-standard API interaction complexities,
7
7
  * allowing the plugin to simply call and forward standard OpenAI formatted requests and response streams.
8
8
  */
9
+ import type { ToolMapper } from "./tool-mapper";
9
10
  /**
10
11
  * Converts OpenAI's `tool_calls` into Gemini's `functionCall` sections.
11
12
  */
12
- export declare function transformOpenAIToolCalls(requestPayload: Record<string, unknown>): void;
13
+ export declare function transformOpenAIToolCalls(requestPayload: Record<string, unknown>, toolMapper?: ToolMapper): void;
13
14
  /**
14
15
  * Adds synthesized thoughtSignature to function calls in the flattened and wrapped payload.
15
16
  */
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Tool Name Schema Mapping for Gemini API
3
+ *
4
+ * Gemini API tool schemas strictly enforce function names matching `^[a-zA-Z_][a-zA-Z0-9_]*$`.
5
+ * Agent frameworks (MCP servers, OpenCode plugins, OpenAI adapters) often use hyphens (-), dots (.),
6
+ * slashes (/), or colons (:) in tool names (e.g. `context7_resolve_library_id`, `atlassian:get-issue`, `my-tool`).
7
+ *
8
+ * This module maintains a bidirectional mapping between original client tool names and Gemini-compliant tool names,
9
+ * resolving collisions deterministically and persisting session mappings across multi-turn tool loops.
10
+ */
11
+ export declare function sanitizeToolName(name: string): string;
12
+ export declare class ToolMapper {
13
+ private originalToSanitized;
14
+ private sanitizedToOriginal;
15
+ /**
16
+ * Register a tool name and get its Gemini-compliant sanitized name.
17
+ * Handles naming collisions by appending a numeric suffix if needed.
18
+ */
19
+ register(originalName: string): string;
20
+ /**
21
+ * Map an original tool name to sanitized Gemini name.
22
+ * If not already registered, registers it on the fly.
23
+ */
24
+ toGemini(originalName: string): string;
25
+ /**
26
+ * Restore a sanitized Gemini tool name back to the original client tool name.
27
+ */
28
+ fromGemini(sanitizedName: string): string;
29
+ /**
30
+ * Register tools from Gemini `tools[].functionDeclarations` array.
31
+ */
32
+ registerFromFunctionDeclarations(tools: unknown): void;
33
+ /**
34
+ * Register tools from OpenAI format `tools[].function.name`.
35
+ */
36
+ registerFromOpenAITools(tools: unknown): void;
37
+ /**
38
+ * Scan contents/messages to register any previously used tool names.
39
+ */
40
+ registerFromContents(contents: unknown): void;
41
+ }
42
+ export declare function getToolMapper(sessionId?: string): ToolMapper;
43
+ export declare function clearToolMapper(sessionId: string): void;
44
+ /**
45
+ * Restores original client tool names inside Gemini candidates/parts functionCall objects.
46
+ */
47
+ export declare function restoreToolNamesInResponse(body: unknown, toolMapper: ToolMapper): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anthonyhaussman/opencode-agy-auth",
3
- "version": "1.1.13",
3
+ "version": "1.1.14-alpha.0",
4
4
  "author": "antigravity",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",