@workglow/ai-provider 0.0.89 → 0.0.91

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.
Files changed (96) hide show
  1. package/README.md +45 -45
  2. package/dist/anthropic/AnthropicProvider.d.ts +39 -0
  3. package/dist/anthropic/AnthropicProvider.d.ts.map +1 -0
  4. package/dist/anthropic/Anthropic_Worker.d.ts +7 -0
  5. package/dist/anthropic/Anthropic_Worker.d.ts.map +1 -0
  6. package/dist/anthropic/common/Anthropic_Constants.d.ts +7 -0
  7. package/dist/anthropic/common/Anthropic_Constants.d.ts.map +1 -0
  8. package/dist/anthropic/common/Anthropic_JobRunFns.d.ts +16 -0
  9. package/dist/anthropic/common/Anthropic_JobRunFns.d.ts.map +1 -0
  10. package/dist/anthropic/common/Anthropic_ModelSchema.d.ts +167 -0
  11. package/dist/anthropic/common/Anthropic_ModelSchema.d.ts.map +1 -0
  12. package/dist/anthropic/index.d.ts +11 -0
  13. package/dist/anthropic/index.d.ts.map +1 -0
  14. package/dist/anthropic/index.js +257 -0
  15. package/dist/anthropic/index.js.map +14 -0
  16. package/dist/google-gemini/Gemini_Worker.d.ts +7 -0
  17. package/dist/google-gemini/Gemini_Worker.d.ts.map +1 -0
  18. package/dist/google-gemini/GoogleGeminiProvider.d.ts +36 -0
  19. package/dist/google-gemini/GoogleGeminiProvider.d.ts.map +1 -0
  20. package/dist/google-gemini/common/Gemini_Constants.d.ts +7 -0
  21. package/dist/google-gemini/common/Gemini_Constants.d.ts.map +1 -0
  22. package/dist/google-gemini/common/Gemini_JobRunFns.d.ts +17 -0
  23. package/dist/google-gemini/common/Gemini_JobRunFns.d.ts.map +1 -0
  24. package/dist/google-gemini/common/Gemini_ModelSchema.d.ts +164 -0
  25. package/dist/google-gemini/common/Gemini_ModelSchema.d.ts.map +1 -0
  26. package/dist/google-gemini/index.d.ts +11 -0
  27. package/dist/google-gemini/index.d.ts.map +1 -0
  28. package/dist/google-gemini/index.js +300 -0
  29. package/dist/google-gemini/index.js.map +14 -0
  30. package/dist/hf-transformers/HFT_Worker.d.ts +7 -0
  31. package/dist/hf-transformers/HFT_Worker.d.ts.map +1 -0
  32. package/dist/hf-transformers/HuggingFaceTransformersProvider.d.ts +41 -0
  33. package/dist/hf-transformers/HuggingFaceTransformersProvider.d.ts.map +1 -0
  34. package/dist/hf-transformers/common/HFT_JobRunFns.d.ts +1218 -1
  35. package/dist/hf-transformers/common/HFT_JobRunFns.d.ts.map +1 -1
  36. package/dist/hf-transformers/index.d.ts +2 -3
  37. package/dist/hf-transformers/index.d.ts.map +1 -1
  38. package/dist/hf-transformers/index.js +1130 -0
  39. package/dist/hf-transformers/index.js.map +15 -0
  40. package/dist/index.d.ts +23 -2
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +729 -865
  43. package/dist/index.js.map +20 -12
  44. package/dist/provider-ollama/OllamaProvider.d.ts +39 -0
  45. package/dist/provider-ollama/OllamaProvider.d.ts.map +1 -0
  46. package/dist/provider-ollama/Ollama_Worker.d.ts +7 -0
  47. package/dist/provider-ollama/Ollama_Worker.d.ts.map +1 -0
  48. package/dist/provider-ollama/common/Ollama_Constants.d.ts +8 -0
  49. package/dist/provider-ollama/common/Ollama_Constants.d.ts.map +1 -0
  50. package/dist/provider-ollama/common/Ollama_JobRunFns.d.ts +17 -0
  51. package/dist/provider-ollama/common/Ollama_JobRunFns.d.ts.map +1 -0
  52. package/dist/provider-ollama/common/Ollama_ModelSchema.d.ts +137 -0
  53. package/dist/provider-ollama/common/Ollama_ModelSchema.d.ts.map +1 -0
  54. package/dist/provider-ollama/index.d.ts +11 -0
  55. package/dist/provider-ollama/index.d.ts.map +1 -0
  56. package/dist/provider-ollama/index.js +274 -0
  57. package/dist/provider-ollama/index.js.map +14 -0
  58. package/dist/provider-openai/OpenAI_Worker.d.ts +7 -0
  59. package/dist/provider-openai/OpenAI_Worker.d.ts.map +1 -0
  60. package/dist/provider-openai/OpenAiProvider.d.ts +40 -0
  61. package/dist/provider-openai/OpenAiProvider.d.ts.map +1 -0
  62. package/dist/provider-openai/common/OpenAI_Constants.d.ts +7 -0
  63. package/dist/provider-openai/common/OpenAI_Constants.d.ts.map +1 -0
  64. package/dist/provider-openai/common/OpenAI_JobRunFns.d.ts +17 -0
  65. package/dist/provider-openai/common/OpenAI_JobRunFns.d.ts.map +1 -0
  66. package/dist/provider-openai/common/OpenAI_ModelSchema.d.ts +161 -0
  67. package/dist/provider-openai/common/OpenAI_ModelSchema.d.ts.map +1 -0
  68. package/dist/provider-openai/index.d.ts +11 -0
  69. package/dist/provider-openai/index.d.ts.map +1 -0
  70. package/dist/provider-openai/index.js +283 -0
  71. package/dist/provider-openai/index.js.map +14 -0
  72. package/dist/tf-mediapipe/TFMP_Worker.d.ts +7 -0
  73. package/dist/tf-mediapipe/TFMP_Worker.d.ts.map +1 -0
  74. package/dist/tf-mediapipe/TensorFlowMediaPipeProvider.d.ts +39 -0
  75. package/dist/tf-mediapipe/TensorFlowMediaPipeProvider.d.ts.map +1 -0
  76. package/dist/tf-mediapipe/common/TFMP_JobRunFns.d.ts +842 -0
  77. package/dist/tf-mediapipe/common/TFMP_JobRunFns.d.ts.map +1 -1
  78. package/dist/tf-mediapipe/index.d.ts +2 -3
  79. package/dist/tf-mediapipe/index.d.ts.map +1 -1
  80. package/dist/tf-mediapipe/index.js +674 -0
  81. package/dist/tf-mediapipe/index.js.map +14 -0
  82. package/package.json +87 -22
  83. package/dist/hf-transformers/registry/HFT_Client_RegisterJobFns.d.ts +0 -17
  84. package/dist/hf-transformers/registry/HFT_Client_RegisterJobFns.d.ts.map +0 -1
  85. package/dist/hf-transformers/registry/HFT_Inline_RegisterJobFns.d.ts +0 -16
  86. package/dist/hf-transformers/registry/HFT_Inline_RegisterJobFns.d.ts.map +0 -1
  87. package/dist/hf-transformers/registry/HFT_Worker_RegisterJobFns.d.ts +0 -8
  88. package/dist/hf-transformers/registry/HFT_Worker_RegisterJobFns.d.ts.map +0 -1
  89. package/dist/openai/provider/OpenAI_TaskRun.d.ts +0 -2
  90. package/dist/openai/provider/OpenAI_TaskRun.d.ts.map +0 -1
  91. package/dist/tf-mediapipe/registry/TFMP_Client_RegisterJobFns.d.ts +0 -17
  92. package/dist/tf-mediapipe/registry/TFMP_Client_RegisterJobFns.d.ts.map +0 -1
  93. package/dist/tf-mediapipe/registry/TFMP_Inline_RegisterJobFns.d.ts +0 -16
  94. package/dist/tf-mediapipe/registry/TFMP_Inline_RegisterJobFns.d.ts.map +0 -1
  95. package/dist/tf-mediapipe/registry/TFMP_Worker_RegisterJobFns.d.ts +0 -8
  96. package/dist/tf-mediapipe/registry/TFMP_Worker_RegisterJobFns.d.ts.map +0 -1
@@ -0,0 +1,14 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/anthropic/Anthropic_Worker.ts", "../src/anthropic/AnthropicProvider.ts", "../src/anthropic/common/Anthropic_Constants.ts", "../src/anthropic/common/Anthropic_JobRunFns.ts", "../src/anthropic/common/Anthropic_ModelSchema.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { globalServiceRegistry, parentPort, WORKER_SERVER } from \"@workglow/util\";\nimport { AnthropicProvider } from \"./AnthropicProvider\";\nimport { ANTHROPIC_STREAM_TASKS, ANTHROPIC_TASKS } from \"./common/Anthropic_JobRunFns\";\n\nexport function ANTHROPIC_WORKER_JOBRUN_REGISTER() {\n const workerServer = globalServiceRegistry.get(WORKER_SERVER);\n new AnthropicProvider(ANTHROPIC_TASKS, ANTHROPIC_STREAM_TASKS).registerOnWorkerServer(\n workerServer\n );\n parentPort.postMessage({ type: \"ready\" });\n console.log(\"ANTHROPIC_WORKER_JOBRUN registered\");\n}\n",
6
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { AiProvider, type AiProviderRunFn, type AiProviderStreamFn } from \"@workglow/ai\";\nimport { ANTHROPIC } from \"./common/Anthropic_Constants\";\nimport type { AnthropicModelConfig } from \"./common/Anthropic_ModelSchema\";\n\n/**\n * AI provider for Anthropic cloud models.\n *\n * Supports text generation, text rewriting, and text summarization via the\n * Anthropic Messages API using the `@anthropic-ai/sdk` SDK.\n *\n * Note: Anthropic does not offer an embeddings API, so TextEmbeddingTask\n * is not supported by this provider.\n *\n * Task run functions are injected via the constructor so that the SDK\n * is only imported where actually needed (inline mode, worker server), not on\n * the main thread in worker mode.\n *\n * @example\n * ```typescript\n * // Worker mode (main thread) -- lightweight, no SDK import:\n * await new AnthropicProvider().register({\n * mode: \"worker\",\n * worker: new Worker(new URL(\"./worker_anthropic.ts\", import.meta.url), { type: \"module\" }),\n * });\n *\n * // Inline mode -- caller provides the tasks:\n * import { ANTHROPIC_TASKS } from \"@workglow/ai-provider/anthropic\";\n * await new AnthropicProvider(ANTHROPIC_TASKS).register({ mode: \"inline\" });\n * ```\n */\nexport class AnthropicProvider extends AiProvider<AnthropicModelConfig> {\n readonly name = ANTHROPIC;\n\n readonly taskTypes = [\"TextGenerationTask\", \"TextRewriterTask\", \"TextSummaryTask\"] as const;\n\n constructor(\n tasks?: Record<string, AiProviderRunFn<any, any, AnthropicModelConfig>>,\n streamTasks?: Record<string, AiProviderStreamFn<any, any, AnthropicModelConfig>>\n ) {\n super(tasks, streamTasks);\n }\n}\n",
7
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport const ANTHROPIC = \"ANTHROPIC\";\n",
8
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type {\n AiProviderRunFn,\n AiProviderStreamFn,\n TextGenerationTaskInput,\n TextGenerationTaskOutput,\n TextRewriterTaskInput,\n TextRewriterTaskOutput,\n TextSummaryTaskInput,\n TextSummaryTaskOutput,\n} from \"@workglow/ai\";\nimport type { StreamEvent } from \"@workglow/task-graph\";\nimport type { AnthropicModelConfig } from \"./Anthropic_ModelSchema\";\n\nlet _sdk: typeof import(\"@anthropic-ai/sdk\") | undefined;\nasync function loadAnthropicSDK() {\n if (!_sdk) {\n try {\n _sdk = await import(\"@anthropic-ai/sdk\");\n } catch {\n throw new Error(\n \"@anthropic-ai/sdk is required for Anthropic tasks. Install it with: bun add @anthropic-ai/sdk\"\n );\n }\n }\n return _sdk.default;\n}\n\nasync function getClient(model: AnthropicModelConfig | undefined) {\n const Anthropic = await loadAnthropicSDK();\n const apiKey =\n model?.provider_config?.api_key ||\n (typeof process !== \"undefined\" ? process.env?.ANTHROPIC_API_KEY : undefined);\n if (!apiKey) {\n throw new Error(\n \"Missing Anthropic API key: set provider_config.api_key or the ANTHROPIC_API_KEY environment variable.\"\n );\n }\n return new Anthropic({\n apiKey,\n baseURL: model?.provider_config?.base_url || undefined,\n dangerouslyAllowBrowser: true,\n });\n}\n\nfunction getModelName(model: AnthropicModelConfig | undefined): string {\n const name = model?.provider_config?.model_name;\n if (!name) {\n throw new Error(\"Missing model name in provider_config.model_name.\");\n }\n return name;\n}\n\nfunction getMaxTokens(\n input: { maxTokens?: number },\n model: AnthropicModelConfig | undefined\n): number {\n return input.maxTokens ?? model?.provider_config?.max_tokens ?? 1024;\n}\n\nexport const Anthropic_TextGeneration: AiProviderRunFn<\n TextGenerationTaskInput,\n TextGenerationTaskOutput,\n AnthropicModelConfig\n> = async (input, model, update_progress, signal) => {\n update_progress(0, \"Starting Anthropic text generation\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const response = await client.messages.create(\n {\n model: modelName,\n messages: [{ role: \"user\", content: input.prompt }],\n max_tokens: getMaxTokens(input, model),\n temperature: input.temperature,\n top_p: input.topP,\n },\n { signal }\n );\n\n const text = response.content[0]?.type === \"text\" ? response.content[0].text : \"\";\n\n update_progress(100, \"Completed Anthropic text generation\");\n return { text };\n};\n\nexport const Anthropic_TextRewriter: AiProviderRunFn<\n TextRewriterTaskInput,\n TextRewriterTaskOutput,\n AnthropicModelConfig\n> = async (input, model, update_progress, signal) => {\n update_progress(0, \"Starting Anthropic text rewriting\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const response = await client.messages.create(\n {\n model: modelName,\n system: input.prompt,\n messages: [{ role: \"user\", content: input.text }],\n max_tokens: getMaxTokens({}, model),\n },\n { signal }\n );\n\n const text = response.content[0]?.type === \"text\" ? response.content[0].text : \"\";\n\n update_progress(100, \"Completed Anthropic text rewriting\");\n return { text };\n};\n\nexport const Anthropic_TextSummary: AiProviderRunFn<\n TextSummaryTaskInput,\n TextSummaryTaskOutput,\n AnthropicModelConfig\n> = async (input, model, update_progress, signal) => {\n update_progress(0, \"Starting Anthropic text summarization\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const response = await client.messages.create(\n {\n model: modelName,\n system: \"Summarize the following text concisely.\",\n messages: [{ role: \"user\", content: input.text }],\n max_tokens: getMaxTokens({}, model),\n },\n { signal }\n );\n\n const text = response.content[0]?.type === \"text\" ? response.content[0].text : \"\";\n\n update_progress(100, \"Completed Anthropic text summarization\");\n return { text };\n};\n\n// ========================================================================\n// Streaming implementations (append mode)\n// ========================================================================\n\nexport const Anthropic_TextGeneration_Stream: AiProviderStreamFn<\n TextGenerationTaskInput,\n TextGenerationTaskOutput,\n AnthropicModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<TextGenerationTaskOutput>> {\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const stream = client.messages.stream(\n {\n model: modelName,\n messages: [{ role: \"user\", content: input.prompt }],\n max_tokens: getMaxTokens(input, model),\n temperature: input.temperature,\n top_p: input.topP,\n },\n { signal }\n );\n\n for await (const event of stream) {\n if (event.type === \"content_block_delta\" && event.delta.type === \"text_delta\") {\n yield { type: \"text-delta\", textDelta: event.delta.text };\n }\n }\n yield { type: \"finish\", data: {} as TextGenerationTaskOutput };\n};\n\nexport const Anthropic_TextRewriter_Stream: AiProviderStreamFn<\n TextRewriterTaskInput,\n TextRewriterTaskOutput,\n AnthropicModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<TextRewriterTaskOutput>> {\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const stream = client.messages.stream(\n {\n model: modelName,\n system: input.prompt,\n messages: [{ role: \"user\", content: input.text }],\n max_tokens: getMaxTokens({}, model),\n },\n { signal }\n );\n\n for await (const event of stream) {\n if (event.type === \"content_block_delta\" && event.delta.type === \"text_delta\") {\n yield { type: \"text-delta\", textDelta: event.delta.text };\n }\n }\n yield { type: \"finish\", data: {} as TextRewriterTaskOutput };\n};\n\nexport const Anthropic_TextSummary_Stream: AiProviderStreamFn<\n TextSummaryTaskInput,\n TextSummaryTaskOutput,\n AnthropicModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<TextSummaryTaskOutput>> {\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n const stream = client.messages.stream(\n {\n model: modelName,\n system: \"Summarize the following text concisely.\",\n messages: [{ role: \"user\", content: input.text }],\n max_tokens: getMaxTokens({}, model),\n },\n { signal }\n );\n\n for await (const event of stream) {\n if (event.type === \"content_block_delta\" && event.delta.type === \"text_delta\") {\n yield { type: \"text-delta\", textDelta: event.delta.text };\n }\n }\n yield { type: \"finish\", data: {} as TextSummaryTaskOutput };\n};\n\n// ========================================================================\n// Task registries\n// ========================================================================\n\nexport const ANTHROPIC_TASKS: Record<string, AiProviderRunFn<any, any, AnthropicModelConfig>> = {\n TextGenerationTask: Anthropic_TextGeneration,\n TextRewriterTask: Anthropic_TextRewriter,\n TextSummaryTask: Anthropic_TextSummary,\n};\n\nexport const ANTHROPIC_STREAM_TASKS: Record<\n string,\n AiProviderStreamFn<any, any, AnthropicModelConfig>\n> = {\n TextGenerationTask: Anthropic_TextGeneration_Stream,\n TextRewriterTask: Anthropic_TextRewriter_Stream,\n TextSummaryTask: Anthropic_TextSummary_Stream,\n};\n",
9
+ "/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { ModelConfigSchema, ModelRecordSchema } from \"@workglow/ai\";\nimport { DataPortSchemaObject, FromSchema } from \"@workglow/util\";\nimport { ANTHROPIC } from \"./Anthropic_Constants\";\n\nexport const AnthropicModelSchema = {\n type: \"object\",\n properties: {\n provider: {\n const: ANTHROPIC,\n description: \"Discriminator: Anthropic cloud provider.\",\n },\n provider_config: {\n type: \"object\",\n description: \"Anthropic-specific configuration.\",\n properties: {\n model_name: {\n type: \"string\",\n description:\n \"The Anthropic model identifier (e.g., 'claude-sonnet-4-20250514', 'claude-3-5-haiku-20241022').\",\n },\n api_key: {\n type: \"string\",\n description:\n \"Anthropic API key. Falls back to ANTHROPIC_API_KEY environment variable if not set.\",\n \"x-ui-hidden\": true,\n },\n base_url: {\n type: \"string\",\n description: \"Base URL for the Anthropic API (optional).\",\n },\n max_tokens: {\n type: \"integer\",\n description: \"Default max tokens for responses. Anthropic requires this parameter.\",\n default: 1024,\n minimum: 1,\n },\n },\n required: [\"model_name\"],\n additionalProperties: false,\n },\n },\n required: [\"provider\", \"provider_config\"],\n additionalProperties: true,\n} as const satisfies DataPortSchemaObject;\n\nexport const AnthropicModelRecordSchema = {\n type: \"object\",\n properties: {\n ...ModelRecordSchema.properties,\n ...AnthropicModelSchema.properties,\n },\n required: [...ModelRecordSchema.required, ...AnthropicModelSchema.required],\n additionalProperties: false,\n} as const satisfies DataPortSchemaObject;\n\nexport type AnthropicModelRecord = FromSchema<typeof AnthropicModelRecordSchema>;\n\nexport const AnthropicModelConfigSchema = {\n type: \"object\",\n properties: {\n ...ModelConfigSchema.properties,\n ...AnthropicModelSchema.properties,\n },\n required: [...ModelConfigSchema.required, ...AnthropicModelSchema.required],\n additionalProperties: false,\n} as const satisfies DataPortSchemaObject;\n\nexport type AnthropicModelConfig = FromSchema<typeof AnthropicModelConfigSchema>;\n"
10
+ ],
11
+ "mappings": ";;;;;;;;;;;;;;;;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A;;AIVlD;AAIO,IAAM,uBAAuB;AAAA,EAClC,MAAM;AAAA,EACN,YAAY;AAAA,IACV,UAAU;AAAA,MACR,OAAO;AAAA,MACP,aAAa;AAAA,IACf;AAAA,IACA,iBAAiB;AAAA,MACf,MAAM;AAAA,MACN,aAAa;AAAA,MACb,YAAY;AAAA,QACV,YAAY;AAAA,UACV,MAAM;AAAA,UACN,aACE;AAAA,QACJ;AAAA,QACA,SAAS;AAAA,UACP,MAAM;AAAA,UACN,aACE;AAAA,UACF,eAAe;AAAA,QACjB;AAAA,QACA,UAAU;AAAA,UACR,MAAM;AAAA,UACN,aAAa;AAAA,QACf;AAAA,QACA,YAAY;AAAA,UACV,MAAM;AAAA,UACN,aAAa;AAAA,UACb,SAAS;AAAA,UACT,SAAS;AAAA,QACX;AAAA,MACF;AAAA,MACA,UAAU,CAAC,YAAY;AAAA,MACvB,sBAAsB;AAAA,IACxB;AAAA,EACF;AAAA,EACA,UAAU,CAAC,YAAY,iBAAiB;AAAA,EACxC,sBAAsB;AACxB;AAEO,IAAM,6BAA6B;AAAA,EACxC,MAAM;AAAA,EACN,YAAY;AAAA,OACP,kBAAkB;AAAA,OAClB,qBAAqB;AAAA,EAC1B;AAAA,EACA,UAAU,CAAC,GAAG,kBAAkB,UAAU,GAAG,qBAAqB,QAAQ;AAAA,EAC1E,sBAAsB;AACxB;AAIO,IAAM,6BAA6B;AAAA,EACxC,MAAM;AAAA,EACN,YAAY;AAAA,OACP,kBAAkB;AAAA,OAClB,qBAAqB;AAAA,EAC1B;AAAA,EACA,UAAU,CAAC,GAAG,kBAAkB,UAAU,GAAG,qBAAqB,QAAQ;AAAA,EAC1E,sBAAsB;AACxB;",
12
+ "debugId": "EC2382865C58E15164756E2164756E21",
13
+ "names": []
14
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export declare function GEMINI_WORKER_JOBRUN_REGISTER(): void;
7
+ //# sourceMappingURL=Gemini_Worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Gemini_Worker.d.ts","sourceRoot":"","sources":["../../src/google-gemini/Gemini_Worker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,wBAAgB,6BAA6B,SAK5C"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { AiProvider, type AiProviderRunFn, type AiProviderStreamFn } from "@workglow/ai";
7
+ import type { GeminiModelConfig } from "./common/Gemini_ModelSchema";
8
+ /**
9
+ * AI provider for Google Gemini cloud models.
10
+ *
11
+ * Supports text generation, text embedding, text rewriting, and text summarization
12
+ * via the Google Generative AI API using the `@google/generative-ai` SDK.
13
+ *
14
+ * Task run functions are injected via the constructor so that the SDK
15
+ * is only imported where actually needed (inline mode, worker server), not on
16
+ * the main thread in worker mode.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * // Worker mode (main thread) -- lightweight, no SDK import:
21
+ * await new GoogleGeminiProvider().register({
22
+ * mode: "worker",
23
+ * worker: new Worker(new URL("./worker_gemini.ts", import.meta.url), { type: "module" }),
24
+ * });
25
+ *
26
+ * // Inline mode -- caller provides the tasks:
27
+ * import { GEMINI_TASKS } from "@workglow/ai-provider/google-gemini";
28
+ * await new GoogleGeminiProvider(GEMINI_TASKS).register({ mode: "inline" });
29
+ * ```
30
+ */
31
+ export declare class GoogleGeminiProvider extends AiProvider<GeminiModelConfig> {
32
+ readonly name = "GOOGLE_GEMINI";
33
+ readonly taskTypes: readonly ["TextGenerationTask", "TextEmbeddingTask", "TextRewriterTask", "TextSummaryTask"];
34
+ constructor(tasks?: Record<string, AiProviderRunFn<any, any, GeminiModelConfig>>, streamTasks?: Record<string, AiProviderStreamFn<any, any, GeminiModelConfig>>);
35
+ }
36
+ //# sourceMappingURL=GoogleGeminiProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GoogleGeminiProvider.d.ts","sourceRoot":"","sources":["../../src/google-gemini/GoogleGeminiProvider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEzF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,oBAAqB,SAAQ,UAAU,CAAC,iBAAiB,CAAC;IACrE,QAAQ,CAAC,IAAI,mBAAiB;IAE9B,QAAQ,CAAC,SAAS,8FAKP;gBAGT,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAAC,EACpE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAAC;CAIhF"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export declare const GOOGLE_GEMINI = "GOOGLE_GEMINI";
7
+ //# sourceMappingURL=Gemini_Constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Gemini_Constants.d.ts","sourceRoot":"","sources":["../../../src/google-gemini/common/Gemini_Constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,aAAa,kBAAkB,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { AiProviderRunFn, AiProviderStreamFn, TextEmbeddingTaskInput, TextEmbeddingTaskOutput, TextGenerationTaskInput, TextGenerationTaskOutput, TextRewriterTaskInput, TextRewriterTaskOutput, TextSummaryTaskInput, TextSummaryTaskOutput } from "@workglow/ai";
7
+ import type { GeminiModelConfig } from "./Gemini_ModelSchema";
8
+ export declare const Gemini_TextGeneration: AiProviderRunFn<TextGenerationTaskInput, TextGenerationTaskOutput, GeminiModelConfig>;
9
+ export declare const Gemini_TextEmbedding: AiProviderRunFn<TextEmbeddingTaskInput, TextEmbeddingTaskOutput, GeminiModelConfig>;
10
+ export declare const Gemini_TextRewriter: AiProviderRunFn<TextRewriterTaskInput, TextRewriterTaskOutput, GeminiModelConfig>;
11
+ export declare const Gemini_TextSummary: AiProviderRunFn<TextSummaryTaskInput, TextSummaryTaskOutput, GeminiModelConfig>;
12
+ export declare const Gemini_TextGeneration_Stream: AiProviderStreamFn<TextGenerationTaskInput, TextGenerationTaskOutput, GeminiModelConfig>;
13
+ export declare const Gemini_TextRewriter_Stream: AiProviderStreamFn<TextRewriterTaskInput, TextRewriterTaskOutput, GeminiModelConfig>;
14
+ export declare const Gemini_TextSummary_Stream: AiProviderStreamFn<TextSummaryTaskInput, TextSummaryTaskOutput, GeminiModelConfig>;
15
+ export declare const GEMINI_TASKS: Record<string, AiProviderRunFn<any, any, GeminiModelConfig>>;
16
+ export declare const GEMINI_STREAM_TASKS: Record<string, AiProviderStreamFn<any, any, GeminiModelConfig>>;
17
+ //# sourceMappingURL=Gemini_JobRunFns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Gemini_JobRunFns.d.ts","sourceRoot":"","sources":["../../../src/google-gemini/common/Gemini_JobRunFns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAsC9D,eAAO,MAAM,qBAAqB,EAAE,eAAe,CACjD,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,CAqBlB,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,eAAe,CAChD,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,CAgClB,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,eAAe,CAC/C,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,CAiBlB,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAC9C,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,CAiBlB,CAAC;AAMF,eAAO,MAAM,4BAA4B,EAAE,kBAAkB,CAC3D,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,CAwBlB,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,kBAAkB,CACzD,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,CAoBlB,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,kBAAkB,CACxD,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,CAoBlB,CAAC;AAMF,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAKrF,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,MAAM,CACtC,MAAM,EACN,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAKhD,CAAC"}
@@ -0,0 +1,164 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { FromSchema } from "@workglow/util";
7
+ export declare const GeminiModelSchema: {
8
+ readonly type: "object";
9
+ readonly properties: {
10
+ readonly provider: {
11
+ readonly const: "GOOGLE_GEMINI";
12
+ readonly description: "Discriminator: Google Gemini cloud provider.";
13
+ };
14
+ readonly provider_config: {
15
+ readonly type: "object";
16
+ readonly description: "Google Gemini-specific configuration.";
17
+ readonly properties: {
18
+ readonly model_name: {
19
+ readonly type: "string";
20
+ readonly description: "The Gemini model identifier (e.g., 'gemini-2.0-flash', 'text-embedding-004').";
21
+ };
22
+ readonly api_key: {
23
+ readonly type: "string";
24
+ readonly description: "Google AI API key. Falls back to default API key if not set.";
25
+ };
26
+ readonly embedding_task_type: {
27
+ readonly oneOf: readonly [{
28
+ readonly type: "null";
29
+ }, {
30
+ readonly type: "string";
31
+ readonly enum: readonly ["RETRIEVAL_QUERY", "RETRIEVAL_DOCUMENT", "SEMANTIC_SIMILARITY", "CLASSIFICATION", "CLUSTERING"];
32
+ }];
33
+ readonly description: "Task type hint for embedding models.";
34
+ readonly default: null;
35
+ };
36
+ };
37
+ readonly required: readonly ["model_name"];
38
+ readonly additionalProperties: false;
39
+ };
40
+ };
41
+ readonly required: readonly ["provider", "provider_config"];
42
+ readonly additionalProperties: true;
43
+ };
44
+ export declare const GeminiModelRecordSchema: {
45
+ readonly type: "object";
46
+ readonly properties: {
47
+ readonly provider: {
48
+ readonly const: "GOOGLE_GEMINI";
49
+ readonly description: "Discriminator: Google Gemini cloud provider.";
50
+ };
51
+ readonly provider_config: {
52
+ readonly type: "object";
53
+ readonly description: "Google Gemini-specific configuration.";
54
+ readonly properties: {
55
+ readonly model_name: {
56
+ readonly type: "string";
57
+ readonly description: "The Gemini model identifier (e.g., 'gemini-2.0-flash', 'text-embedding-004').";
58
+ };
59
+ readonly api_key: {
60
+ readonly type: "string";
61
+ readonly description: "Google AI API key. Falls back to default API key if not set.";
62
+ };
63
+ readonly embedding_task_type: {
64
+ readonly oneOf: readonly [{
65
+ readonly type: "null";
66
+ }, {
67
+ readonly type: "string";
68
+ readonly enum: readonly ["RETRIEVAL_QUERY", "RETRIEVAL_DOCUMENT", "SEMANTIC_SIMILARITY", "CLASSIFICATION", "CLUSTERING"];
69
+ }];
70
+ readonly description: "Task type hint for embedding models.";
71
+ readonly default: null;
72
+ };
73
+ };
74
+ readonly required: readonly ["model_name"];
75
+ readonly additionalProperties: false;
76
+ };
77
+ readonly model_id: {
78
+ readonly type: "string";
79
+ };
80
+ readonly tasks: {
81
+ readonly type: "array";
82
+ readonly items: {
83
+ readonly type: "string";
84
+ };
85
+ readonly "x-ui-editor": "multiselect";
86
+ };
87
+ readonly title: {
88
+ readonly type: "string";
89
+ };
90
+ readonly description: {
91
+ readonly type: "string";
92
+ readonly "x-ui-editor": "textarea";
93
+ };
94
+ readonly metadata: {
95
+ readonly type: "object";
96
+ readonly default: {};
97
+ readonly "x-ui-hidden": true;
98
+ };
99
+ };
100
+ readonly required: readonly ["model_id", "tasks", "provider", "title", "description", "provider_config", "metadata", "provider", "provider_config"];
101
+ readonly additionalProperties: false;
102
+ };
103
+ export type GeminiModelRecord = FromSchema<typeof GeminiModelRecordSchema>;
104
+ export declare const GeminiModelConfigSchema: {
105
+ readonly type: "object";
106
+ readonly properties: {
107
+ readonly provider: {
108
+ readonly const: "GOOGLE_GEMINI";
109
+ readonly description: "Discriminator: Google Gemini cloud provider.";
110
+ };
111
+ readonly provider_config: {
112
+ readonly type: "object";
113
+ readonly description: "Google Gemini-specific configuration.";
114
+ readonly properties: {
115
+ readonly model_name: {
116
+ readonly type: "string";
117
+ readonly description: "The Gemini model identifier (e.g., 'gemini-2.0-flash', 'text-embedding-004').";
118
+ };
119
+ readonly api_key: {
120
+ readonly type: "string";
121
+ readonly description: "Google AI API key. Falls back to default API key if not set.";
122
+ };
123
+ readonly embedding_task_type: {
124
+ readonly oneOf: readonly [{
125
+ readonly type: "null";
126
+ }, {
127
+ readonly type: "string";
128
+ readonly enum: readonly ["RETRIEVAL_QUERY", "RETRIEVAL_DOCUMENT", "SEMANTIC_SIMILARITY", "CLASSIFICATION", "CLUSTERING"];
129
+ }];
130
+ readonly description: "Task type hint for embedding models.";
131
+ readonly default: null;
132
+ };
133
+ };
134
+ readonly required: readonly ["model_name"];
135
+ readonly additionalProperties: false;
136
+ };
137
+ readonly model_id: {
138
+ readonly type: "string";
139
+ };
140
+ readonly tasks: {
141
+ readonly type: "array";
142
+ readonly items: {
143
+ readonly type: "string";
144
+ };
145
+ readonly "x-ui-editor": "multiselect";
146
+ };
147
+ readonly title: {
148
+ readonly type: "string";
149
+ };
150
+ readonly description: {
151
+ readonly type: "string";
152
+ readonly "x-ui-editor": "textarea";
153
+ };
154
+ readonly metadata: {
155
+ readonly type: "object";
156
+ readonly default: {};
157
+ readonly "x-ui-hidden": true;
158
+ };
159
+ };
160
+ readonly required: readonly ["provider", "provider_config", "provider", "provider_config"];
161
+ readonly additionalProperties: false;
162
+ };
163
+ export type GeminiModelConfig = FromSchema<typeof GeminiModelConfigSchema>;
164
+ //# sourceMappingURL=Gemini_ModelSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Gemini_ModelSchema.d.ts","sourceRoot":"","sources":["../../../src/google-gemini/common/Gemini_ModelSchema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAwB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGlE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CW,CAAC;AAE1C,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAQK,CAAC;AAE1C,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE3E,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAQK,CAAC;AAE1C,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export * from "./common/Gemini_Constants";
7
+ export * from "./common/Gemini_JobRunFns";
8
+ export * from "./common/Gemini_ModelSchema";
9
+ export * from "./Gemini_Worker";
10
+ export * from "./GoogleGeminiProvider";
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/google-gemini/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,300 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, {
5
+ get: all[name],
6
+ enumerable: true,
7
+ configurable: true,
8
+ set: (newValue) => all[name] = () => newValue
9
+ });
10
+ };
11
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
12
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
13
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
14
+ }) : x)(function(x) {
15
+ if (typeof require !== "undefined")
16
+ return require.apply(this, arguments);
17
+ throw Error('Dynamic require of "' + x + '" is not supported');
18
+ });
19
+
20
+ // src/google-gemini/common/Gemini_Constants.ts
21
+ var GOOGLE_GEMINI = "GOOGLE_GEMINI";
22
+ // src/google-gemini/common/Gemini_JobRunFns.ts
23
+ var _sdk;
24
+ async function loadGeminiSDK() {
25
+ if (!_sdk) {
26
+ try {
27
+ _sdk = await import("@google/generative-ai");
28
+ } catch {
29
+ throw new Error("@google/generative-ai is required for Gemini tasks. Install it with: bun add @google/generative-ai");
30
+ }
31
+ }
32
+ return _sdk.GoogleGenerativeAI;
33
+ }
34
+ function getApiKey(model) {
35
+ const apiKey = model?.provider_config?.api_key || (typeof process !== "undefined" ? process.env?.GOOGLE_API_KEY || process.env?.GEMINI_API_KEY : undefined);
36
+ if (!apiKey) {
37
+ throw new Error("Missing Google API key: set provider_config.api_key or the GOOGLE_API_KEY / GEMINI_API_KEY environment variable.");
38
+ }
39
+ return apiKey;
40
+ }
41
+ function getModelName(model) {
42
+ const name = model?.provider_config?.model_name;
43
+ if (!name) {
44
+ throw new Error("Missing model name in provider_config.model_name.");
45
+ }
46
+ return name;
47
+ }
48
+ var Gemini_TextGeneration = async (input, model, update_progress, signal) => {
49
+ update_progress(0, "Starting Gemini text generation");
50
+ const GoogleGenerativeAI = await loadGeminiSDK();
51
+ const genAI = new GoogleGenerativeAI(getApiKey(model));
52
+ const genModel = genAI.getGenerativeModel({
53
+ model: getModelName(model),
54
+ generationConfig: {
55
+ maxOutputTokens: input.maxTokens,
56
+ temperature: input.temperature,
57
+ topP: input.topP
58
+ }
59
+ });
60
+ const result = await genModel.generateContent({
61
+ contents: [{ role: "user", parts: [{ text: input.prompt }] }]
62
+ });
63
+ const text = result.response.text();
64
+ update_progress(100, "Completed Gemini text generation");
65
+ return { text };
66
+ };
67
+ var Gemini_TextEmbedding = async (input, model, update_progress, signal) => {
68
+ update_progress(0, "Starting Gemini text embedding");
69
+ const GoogleGenerativeAI = await loadGeminiSDK();
70
+ const genAI = new GoogleGenerativeAI(getApiKey(model));
71
+ const embeddingModel = genAI.getGenerativeModel({
72
+ model: getModelName(model)
73
+ });
74
+ const taskType = model?.provider_config?.embedding_task_type || "RETRIEVAL_DOCUMENT";
75
+ if (Array.isArray(input.text)) {
76
+ const result2 = await embeddingModel.batchEmbedContents({
77
+ requests: input.text.map((t) => ({
78
+ content: { role: "user", parts: [{ text: t }] },
79
+ taskType
80
+ }))
81
+ });
82
+ update_progress(100, "Completed Gemini text embedding");
83
+ return {
84
+ vector: result2.embeddings.map((e) => new Float32Array(e.values))
85
+ };
86
+ }
87
+ const result = await embeddingModel.embedContent({
88
+ content: { role: "user", parts: [{ text: input.text }] },
89
+ taskType
90
+ });
91
+ update_progress(100, "Completed Gemini text embedding");
92
+ return { vector: new Float32Array(result.embedding.values) };
93
+ };
94
+ var Gemini_TextRewriter = async (input, model, update_progress, signal) => {
95
+ update_progress(0, "Starting Gemini text rewriting");
96
+ const GoogleGenerativeAI = await loadGeminiSDK();
97
+ const genAI = new GoogleGenerativeAI(getApiKey(model));
98
+ const genModel = genAI.getGenerativeModel({
99
+ model: getModelName(model),
100
+ systemInstruction: input.prompt
101
+ });
102
+ const result = await genModel.generateContent({
103
+ contents: [{ role: "user", parts: [{ text: input.text }] }]
104
+ });
105
+ const text = result.response.text();
106
+ update_progress(100, "Completed Gemini text rewriting");
107
+ return { text };
108
+ };
109
+ var Gemini_TextSummary = async (input, model, update_progress, signal) => {
110
+ update_progress(0, "Starting Gemini text summarization");
111
+ const GoogleGenerativeAI = await loadGeminiSDK();
112
+ const genAI = new GoogleGenerativeAI(getApiKey(model));
113
+ const genModel = genAI.getGenerativeModel({
114
+ model: getModelName(model),
115
+ systemInstruction: "Summarize the following text concisely."
116
+ });
117
+ const result = await genModel.generateContent({
118
+ contents: [{ role: "user", parts: [{ text: input.text }] }]
119
+ });
120
+ const text = result.response.text();
121
+ update_progress(100, "Completed Gemini text summarization");
122
+ return { text };
123
+ };
124
+ var Gemini_TextGeneration_Stream = async function* (input, model, signal) {
125
+ const GoogleGenerativeAI = await loadGeminiSDK();
126
+ const genAI = new GoogleGenerativeAI(getApiKey(model));
127
+ const genModel = genAI.getGenerativeModel({
128
+ model: getModelName(model),
129
+ generationConfig: {
130
+ maxOutputTokens: input.maxTokens,
131
+ temperature: input.temperature,
132
+ topP: input.topP
133
+ }
134
+ });
135
+ const result = await genModel.generateContentStream({
136
+ contents: [{ role: "user", parts: [{ text: input.prompt }] }]
137
+ });
138
+ for await (const chunk of result.stream) {
139
+ const text = chunk.text();
140
+ if (text) {
141
+ yield { type: "text-delta", textDelta: text };
142
+ }
143
+ }
144
+ yield { type: "finish", data: {} };
145
+ };
146
+ var Gemini_TextRewriter_Stream = async function* (input, model, signal) {
147
+ const GoogleGenerativeAI = await loadGeminiSDK();
148
+ const genAI = new GoogleGenerativeAI(getApiKey(model));
149
+ const genModel = genAI.getGenerativeModel({
150
+ model: getModelName(model),
151
+ systemInstruction: input.prompt
152
+ });
153
+ const result = await genModel.generateContentStream({
154
+ contents: [{ role: "user", parts: [{ text: input.text }] }]
155
+ });
156
+ for await (const chunk of result.stream) {
157
+ const text = chunk.text();
158
+ if (text) {
159
+ yield { type: "text-delta", textDelta: text };
160
+ }
161
+ }
162
+ yield { type: "finish", data: {} };
163
+ };
164
+ var Gemini_TextSummary_Stream = async function* (input, model, signal) {
165
+ const GoogleGenerativeAI = await loadGeminiSDK();
166
+ const genAI = new GoogleGenerativeAI(getApiKey(model));
167
+ const genModel = genAI.getGenerativeModel({
168
+ model: getModelName(model),
169
+ systemInstruction: "Summarize the following text concisely."
170
+ });
171
+ const result = await genModel.generateContentStream({
172
+ contents: [{ role: "user", parts: [{ text: input.text }] }]
173
+ });
174
+ for await (const chunk of result.stream) {
175
+ const text = chunk.text();
176
+ if (text) {
177
+ yield { type: "text-delta", textDelta: text };
178
+ }
179
+ }
180
+ yield { type: "finish", data: {} };
181
+ };
182
+ var GEMINI_TASKS = {
183
+ TextGenerationTask: Gemini_TextGeneration,
184
+ TextEmbeddingTask: Gemini_TextEmbedding,
185
+ TextRewriterTask: Gemini_TextRewriter,
186
+ TextSummaryTask: Gemini_TextSummary
187
+ };
188
+ var GEMINI_STREAM_TASKS = {
189
+ TextGenerationTask: Gemini_TextGeneration_Stream,
190
+ TextRewriterTask: Gemini_TextRewriter_Stream,
191
+ TextSummaryTask: Gemini_TextSummary_Stream
192
+ };
193
+ // src/google-gemini/common/Gemini_ModelSchema.ts
194
+ import { ModelConfigSchema, ModelRecordSchema } from "@workglow/ai";
195
+ var GeminiModelSchema = {
196
+ type: "object",
197
+ properties: {
198
+ provider: {
199
+ const: GOOGLE_GEMINI,
200
+ description: "Discriminator: Google Gemini cloud provider."
201
+ },
202
+ provider_config: {
203
+ type: "object",
204
+ description: "Google Gemini-specific configuration.",
205
+ properties: {
206
+ model_name: {
207
+ type: "string",
208
+ description: "The Gemini model identifier (e.g., 'gemini-2.0-flash', 'text-embedding-004')."
209
+ },
210
+ api_key: {
211
+ type: "string",
212
+ description: "Google AI API key. Falls back to default API key if not set."
213
+ },
214
+ embedding_task_type: {
215
+ oneOf: [
216
+ { type: "null" },
217
+ {
218
+ type: "string",
219
+ enum: [
220
+ "RETRIEVAL_QUERY",
221
+ "RETRIEVAL_DOCUMENT",
222
+ "SEMANTIC_SIMILARITY",
223
+ "CLASSIFICATION",
224
+ "CLUSTERING"
225
+ ]
226
+ }
227
+ ],
228
+ description: "Task type hint for embedding models.",
229
+ default: null
230
+ }
231
+ },
232
+ required: ["model_name"],
233
+ additionalProperties: false
234
+ }
235
+ },
236
+ required: ["provider", "provider_config"],
237
+ additionalProperties: true
238
+ };
239
+ var GeminiModelRecordSchema = {
240
+ type: "object",
241
+ properties: {
242
+ ...ModelRecordSchema.properties,
243
+ ...GeminiModelSchema.properties
244
+ },
245
+ required: [...ModelRecordSchema.required, ...GeminiModelSchema.required],
246
+ additionalProperties: false
247
+ };
248
+ var GeminiModelConfigSchema = {
249
+ type: "object",
250
+ properties: {
251
+ ...ModelConfigSchema.properties,
252
+ ...GeminiModelSchema.properties
253
+ },
254
+ required: [...ModelConfigSchema.required, ...GeminiModelSchema.required],
255
+ additionalProperties: false
256
+ };
257
+ // src/google-gemini/Gemini_Worker.ts
258
+ import { globalServiceRegistry, parentPort, WORKER_SERVER } from "@workglow/util";
259
+
260
+ // src/google-gemini/GoogleGeminiProvider.ts
261
+ import { AiProvider } from "@workglow/ai";
262
+ class GoogleGeminiProvider extends AiProvider {
263
+ name = GOOGLE_GEMINI;
264
+ taskTypes = [
265
+ "TextGenerationTask",
266
+ "TextEmbeddingTask",
267
+ "TextRewriterTask",
268
+ "TextSummaryTask"
269
+ ];
270
+ constructor(tasks, streamTasks) {
271
+ super(tasks, streamTasks);
272
+ }
273
+ }
274
+
275
+ // src/google-gemini/Gemini_Worker.ts
276
+ function GEMINI_WORKER_JOBRUN_REGISTER() {
277
+ const workerServer = globalServiceRegistry.get(WORKER_SERVER);
278
+ new GoogleGeminiProvider(GEMINI_TASKS, GEMINI_STREAM_TASKS).registerOnWorkerServer(workerServer);
279
+ parentPort.postMessage({ type: "ready" });
280
+ console.log("GEMINI_WORKER_JOBRUN registered");
281
+ }
282
+ export {
283
+ GoogleGeminiProvider,
284
+ Gemini_TextSummary_Stream,
285
+ Gemini_TextSummary,
286
+ Gemini_TextRewriter_Stream,
287
+ Gemini_TextRewriter,
288
+ Gemini_TextGeneration_Stream,
289
+ Gemini_TextGeneration,
290
+ Gemini_TextEmbedding,
291
+ GeminiModelSchema,
292
+ GeminiModelRecordSchema,
293
+ GeminiModelConfigSchema,
294
+ GOOGLE_GEMINI,
295
+ GEMINI_WORKER_JOBRUN_REGISTER,
296
+ GEMINI_TASKS,
297
+ GEMINI_STREAM_TASKS
298
+ };
299
+
300
+ //# debugId=94FDE8B04713DF4C64756E2164756E21