@divyacon/piece-google-gemini 0.0.0-stage → 0.1.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.
Files changed (53) hide show
  1. package/LICENSE.MIT-AP +24 -0
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +41 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/lib/actions/chat-gemini.action.d.ts +6 -0
  7. package/dist/lib/actions/chat-gemini.action.d.ts.map +1 -0
  8. package/dist/lib/actions/chat-gemini.action.js +74 -0
  9. package/dist/lib/actions/chat-gemini.action.js.map +1 -0
  10. package/dist/lib/actions/create-video.action.d.ts +11 -0
  11. package/dist/lib/actions/create-video.action.d.ts.map +1 -0
  12. package/dist/lib/actions/create-video.action.js +183 -0
  13. package/dist/lib/actions/create-video.action.js.map +1 -0
  14. package/dist/lib/actions/generate-content-from-image.action.d.ts +6 -0
  15. package/dist/lib/actions/generate-content-from-image.action.d.ts.map +1 -0
  16. package/dist/lib/actions/generate-content-from-image.action.js +66 -0
  17. package/dist/lib/actions/generate-content-from-image.action.js.map +1 -0
  18. package/dist/lib/actions/generate-content-with-file-search.d.ts +7 -0
  19. package/dist/lib/actions/generate-content-with-file-search.d.ts.map +1 -0
  20. package/dist/lib/actions/generate-content-with-file-search.js +83 -0
  21. package/dist/lib/actions/generate-content-with-file-search.js.map +1 -0
  22. package/dist/lib/actions/generate-content.action.d.ts +7 -0
  23. package/dist/lib/actions/generate-content.action.d.ts.map +1 -0
  24. package/dist/lib/actions/generate-content.action.js +192 -0
  25. package/dist/lib/actions/generate-content.action.js.map +1 -0
  26. package/dist/lib/actions/text-to-speech.action.d.ts +7 -0
  27. package/dist/lib/actions/text-to-speech.action.d.ts.map +1 -0
  28. package/dist/lib/actions/text-to-speech.action.js +137 -0
  29. package/dist/lib/actions/text-to-speech.action.js.map +1 -0
  30. package/dist/lib/auth.d.ts +2 -0
  31. package/dist/lib/auth.d.ts.map +1 -0
  32. package/dist/lib/auth.js +42 -0
  33. package/dist/lib/auth.js.map +1 -0
  34. package/dist/lib/common/common.d.ts +49 -0
  35. package/dist/lib/common/common.d.ts.map +1 -0
  36. package/dist/lib/common/common.js +84 -0
  37. package/dist/lib/common/common.js.map +1 -0
  38. package/dist/lib/output-schemas.d.ts +7 -0
  39. package/dist/lib/output-schemas.d.ts.map +1 -0
  40. package/dist/lib/output-schemas.js +129 -0
  41. package/dist/lib/output-schemas.js.map +1 -0
  42. package/package.json +51 -4
  43. package/src/index.ts +35 -0
  44. package/src/lib/actions/chat-gemini.action.ts +78 -0
  45. package/src/lib/actions/create-video.action.ts +206 -0
  46. package/src/lib/actions/generate-content-from-image.action.ts +67 -0
  47. package/src/lib/actions/generate-content-with-file-search.ts +82 -0
  48. package/src/lib/actions/generate-content.action.ts +199 -0
  49. package/src/lib/actions/text-to-speech.action.ts +143 -0
  50. package/src/lib/auth.ts +38 -0
  51. package/src/lib/common/common.ts +121 -0
  52. package/src/lib/output-schemas.ts +131 -0
  53. package/README.md +0 -3
package/LICENSE.MIT-AP ADDED
@@ -0,0 +1,24 @@
1
+ MIT License
2
+
3
+ Copyright (c) Activepieces AB
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ Derived helpers in this folder are adapted from Activepieces (MIT) for use
24
+ inside CX without depending on @activepieces/* packages at runtime.
@@ -0,0 +1,2 @@
1
+ export declare const googleGemini: import("@agnocon/pieces-framework").Piece<import("@agnocon/pieces-framework").SecretTextProperty<true>>;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,YAAY,yGAuBvB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.googleGemini = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // Vendored from Activepieces packages/pieces/community/google-gemini/src/index.ts (MIT).
6
+ // Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
7
+ const pieces_common_1 = require("@agnocon/pieces-common");
8
+ const pieces_framework_1 = require("@agnocon/pieces-framework");
9
+ const pieces_framework_2 = require("@agnocon/pieces-framework");
10
+ const chat_gemini_action_1 = require("./lib/actions/chat-gemini.action");
11
+ const create_video_action_1 = require("./lib/actions/create-video.action");
12
+ const generate_content_from_image_action_1 = require("./lib/actions/generate-content-from-image.action");
13
+ const generate_content_action_1 = require("./lib/actions/generate-content.action");
14
+ const text_to_speech_action_1 = require("./lib/actions/text-to-speech.action");
15
+ const generate_content_with_file_search_1 = require("./lib/actions/generate-content-with-file-search");
16
+ const auth_1 = require("./lib/auth");
17
+ exports.googleGemini = (0, pieces_framework_1.createPiece)({
18
+ displayName: 'Google Gemini',
19
+ auth: auth_1.googleGeminiAuth,
20
+ description: 'Use the new Gemini models from Google',
21
+ minimumSupportedRelease: '0.30.0',
22
+ logoUrl: 'https://cdn.activepieces.com/pieces/google-gemini.png',
23
+ categories: [pieces_framework_2.PieceCategory.ARTIFICIAL_INTELLIGENCE],
24
+ authors: ["pfernandez98", "kishanprmr", "MoShizzle", "AbdulTheActivePiecer", "abuaboud"],
25
+ actions: [
26
+ generate_content_action_1.generateContentAction,
27
+ generate_content_with_file_search_1.generateContentWithFileSearchAction,
28
+ generate_content_from_image_action_1.generateContentFromImageAction,
29
+ chat_gemini_action_1.chatGemini,
30
+ text_to_speech_action_1.textToSpeechAction,
31
+ create_video_action_1.createVideoAction,
32
+ (0, pieces_common_1.createCustomApiCallAction)({
33
+ baseUrl: () => 'https://generativelanguage.googleapis.com/v1beta',
34
+ auth: auth_1.googleGeminiAuth,
35
+ authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return ({ key: auth.secret_text }); }),
36
+ authLocation: 'queryParams',
37
+ }),
38
+ ],
39
+ triggers: [],
40
+ });
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,yFAAyF;AACzF,qEAAqE;AACrE,0DAAmE;AACnE,gEAAwD;AACxD,gEAA0D;AAC1D,yEAA8D;AAC9D,2EAAsE;AACtE,yGAAkG;AAClG,mFAA8E;AAC9E,+EAAyE;AACzE,uGAAsG;AACtG,qCAA8C;AAEjC,QAAA,YAAY,GAAG,IAAA,8BAAW,EAAC;IACtC,WAAW,EAAE,eAAe;IAC5B,IAAI,EAAE,uBAAgB;IACtB,WAAW,EAAE,uCAAuC;IACpD,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,uDAAuD;IAChE,UAAU,EAAE,CAAC,gCAAa,CAAC,uBAAuB,CAAC;IACnD,OAAO,EAAE,CAAC,cAAc,EAAC,YAAY,EAAC,WAAW,EAAC,sBAAsB,EAAC,UAAU,CAAC;IACpF,OAAO,EAAE;QACP,+CAAqB;QACrB,uEAAmC;QACnC,mEAA8B;QAC9B,+BAAU;QACV,0CAAkB;QAClB,uCAAiB;QACjB,IAAA,yCAAyB,EAAC;YACxB,OAAO,EAAE,GAAG,EAAE,CAAC,kDAAkD;YACjE,IAAI,EAAE,uBAAgB;YACtB,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE,0DAAC,OAAA,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAA,GAAA;YACxD,YAAY,EAAE,aAAa;SAC5B,CAAC;KACH;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const chatGemini: import("@agnocon/pieces-framework").IAction<import("@agnocon/pieces-framework").SecretTextProperty<true>, {
2
+ model: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
3
+ prompt: import("@agnocon/pieces-framework").LongTextProperty<true>;
4
+ memoryKey: import("@agnocon/pieces-framework").ShortTextProperty<false>;
5
+ }>;
6
+ //# sourceMappingURL=chat-gemini.action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-gemini.action.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/chat-gemini.action.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,UAAU;;;;EAgErB,CAAC"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.chatGemini = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // Vendored from Activepieces packages/pieces/community/google-gemini/src/lib/actions/chat-gemini.action.ts (MIT).
6
+ // Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
7
+ const generative_ai_1 = require("@google/generative-ai");
8
+ const pieces_framework_1 = require("@agnocon/pieces-framework");
9
+ const z = tslib_1.__importStar(require("zod/mini"));
10
+ const auth_1 = require("../auth");
11
+ const common_1 = require("../common/common");
12
+ const pieces_common_1 = require("@agnocon/pieces-common");
13
+ const output_schemas_1 = require("../output-schemas");
14
+ exports.chatGemini = (0, pieces_framework_1.createAction)({
15
+ audience: 'both',
16
+ auth: auth_1.googleGeminiAuth,
17
+ name: 'chat_gemini',
18
+ displayName: 'Chat Gemini',
19
+ description: 'Chat with Google Gemini',
20
+ aiMetadata: { description: 'Sends a prompt as one turn of a Gemini chat and returns the reply, with two modes: supply a memory key (max 128 characters) to load and persist the conversation history in project storage so later runs remember earlier turns, or leave it empty for a stateless single turn. Pick it over generate_content when the exchange spans multiple runs and must retain context; generate_content is the better choice for one-shot generation or when a built-in tool such as Google Search or File Search is needed. Not idempotent: each call produces a new reply and, when a memory key is set, rewrites the stored history.', idempotent: false },
21
+ props: {
22
+ model: pieces_framework_1.Property.Dropdown({
23
+ displayName: 'Model',
24
+ required: true,
25
+ description: 'The model which will generate the completion',
26
+ refreshers: [],
27
+ auth: auth_1.googleGeminiAuth,
28
+ defaultValue: common_1.defaultLLM,
29
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) { return (0, common_1.getGeminiModelOptions)({ auth }); }),
30
+ }),
31
+ prompt: pieces_framework_1.Property.LongText({
32
+ displayName: 'Prompt',
33
+ required: true,
34
+ description: 'The prompt to generate content from.',
35
+ }),
36
+ memoryKey: pieces_framework_1.Property.ShortText({
37
+ displayName: 'Memory Key',
38
+ description: 'A memory key that will keep the chat history. Keep it empty to leave Gemini without memory of previous messages.',
39
+ required: false,
40
+ }),
41
+ },
42
+ outputSchema: output_schemas_1.chatGeminiActionOutputSchema,
43
+ run(_a) {
44
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue, store }) {
45
+ yield pieces_common_1.propsValidation.validateZod(propsValue, {
46
+ memoryKey: z.optional(z.string().check(z.maxLength(128))),
47
+ });
48
+ const { model, prompt, memoryKey } = propsValue;
49
+ const genAI = new generative_ai_1.GoogleGenerativeAI(auth.secret_text);
50
+ const geminiModel = genAI.getGenerativeModel({ model });
51
+ let history = [];
52
+ if (memoryKey) {
53
+ const storedHistory = yield store.get(memoryKey, pieces_framework_1.StoreScope.PROJECT);
54
+ if (Array.isArray(storedHistory)) {
55
+ history = storedHistory;
56
+ }
57
+ }
58
+ const chat = geminiModel.startChat({
59
+ history: history,
60
+ });
61
+ const result = yield chat.sendMessage(prompt);
62
+ const responseText = result.response.text();
63
+ if (memoryKey) {
64
+ const updatedHistory = yield chat.getHistory();
65
+ yield store.put(memoryKey, updatedHistory, pieces_framework_1.StoreScope.PROJECT);
66
+ }
67
+ return {
68
+ response: responseText,
69
+ history: history,
70
+ };
71
+ });
72
+ },
73
+ });
74
+ //# sourceMappingURL=chat-gemini.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat-gemini.action.js","sourceRoot":"","sources":["../../../src/lib/actions/chat-gemini.action.ts"],"names":[],"mappings":";;;;AAAA,kHAAkH;AAClH,qEAAqE;AACrE,yDAAoE;AACpE,gEAImC;AAEnC,oDAA6B;AAC7B,kCAA2C;AAC3C,6CAAqE;AACrE,0DAAyD;AACzD,sDAAiE;AAEpD,QAAA,UAAU,GAAG,IAAA,+BAAY,EAAC;IACrC,QAAQ,EAAE,MAAM;IAChB,IAAI,EAAE,uBAAgB;IACtB,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,aAAa;IAC1B,WAAW,EAAE,yBAAyB;IACtC,UAAU,EAAE,EAAE,WAAW,EAAE,gmBAAgmB,EAAE,UAAU,EAAE,KAAK,EAAE;IAChpB,KAAK,EAAE;QACL,KAAK,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACvB,WAAW,EAAE,OAAO;YACpB,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,8CAA8C;YAC3D,UAAU,EAAE,EAAE;YACd,IAAI,EAAE,uBAAgB;YACtB,YAAY,EAAE,mBAAU;YACxB,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE,IAAK,OAAA,IAAA,8BAAqB,EAAC,EAAE,IAAI,EAA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AC,WAAW,CAAC,MAAM,CAAC,CAAC;YAC9C,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YAE5C,IAAI,SAAS,EAAE,CAAC;gBACd,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;gBAC/C,MAAM,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,cAAc,EAAE,6BAAU,CAAC,OAAO,CAAC,CAAC;YACjE,CAAC;YAED,OAAO;gBACL,QAAQ,EAAE,YAAY;gBACtB,OAAO,EAAE,OAAO;aACjB,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ export declare const createVideoAction: import("@agnocon/pieces-framework").IAction<import("@agnocon/pieces-framework").SecretTextProperty<true>, {
2
+ model: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
3
+ prompt: import("@agnocon/pieces-framework").LongTextProperty<true>;
4
+ image: import("@agnocon/pieces-framework").FileProperty<false, false>;
5
+ lastFrame: import("@agnocon/pieces-framework").FileProperty<false, false>;
6
+ aspectRatio: import("@agnocon/pieces-framework").StaticDropdownProperty<string, true>;
7
+ durationSeconds: import("@agnocon/pieces-framework").DropdownProperty<number, false, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
8
+ resolution: import("@agnocon/pieces-framework").DropdownProperty<string, false, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
9
+ personGeneration: import("@agnocon/pieces-framework").StaticDropdownProperty<string, false>;
10
+ }>;
11
+ //# sourceMappingURL=create-video.action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-video.action.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/create-video.action.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,iBAAiB;;;;;;;;;EAsM5B,CAAC"}
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createVideoAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // Vendored from Activepieces packages/pieces/community/google-gemini/src/lib/actions/create-video.action.ts (MIT).
6
+ // Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
7
+ const pieces_framework_1 = require("@agnocon/pieces-framework");
8
+ const pieces_common_1 = require("@agnocon/pieces-common");
9
+ const auth_1 = require("../auth");
10
+ const common_1 = require("../common/common");
11
+ const genai_1 = require("@google/genai");
12
+ const mime_types_1 = tslib_1.__importDefault(require("mime-types"));
13
+ exports.createVideoAction = (0, pieces_framework_1.createAction)({
14
+ audience: 'both',
15
+ name: 'create_video',
16
+ auth: auth_1.googleGeminiAuth,
17
+ displayName: 'Create Video',
18
+ description: 'Generate a video from a text prompt using Google Veo models.',
19
+ aiMetadata: { description: 'Generates a short video with a Google Veo model from a text prompt, optionally seeded by a start image (image-to-video) or by both a start and end image (interpolation between those frames), polling the long-running generation job for up to 10 minutes before returning the finished MP4 as a file. Use it whenever the required output is video; text goes through generate_content and speech through text-to-speech. Note the model-dependent limits: 1080p needs Veo 3.0 or newer, 4K needs Veo 3.1, and both require an 8-second duration. Not idempotent: each call renders a new video.', idempotent: false },
20
+ props: {
21
+ model: pieces_framework_1.Property.Dropdown({
22
+ displayName: 'Model',
23
+ required: true,
24
+ auth: auth_1.googleGeminiAuth,
25
+ refreshers: [],
26
+ defaultValue: 'veo-3.1-generate-preview',
27
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) { return (0, common_1.getGeminiVideoModelOptions)({ auth }); }),
28
+ }),
29
+ prompt: pieces_framework_1.Property.LongText({
30
+ displayName: 'Prompt',
31
+ description: 'Describe the video you want to generate. Be specific about the scene, motion, style, and lighting for best results.',
32
+ required: true,
33
+ }),
34
+ image: pieces_framework_1.Property.File({
35
+ displayName: 'Start Image',
36
+ description: 'Optional image to use as the first frame of the video (image-to-video).',
37
+ required: false,
38
+ }),
39
+ lastFrame: pieces_framework_1.Property.File({
40
+ displayName: 'End Image',
41
+ description: 'Optional image to use as the last frame. Use together with Start Image to generate an interpolation video.',
42
+ required: false,
43
+ }),
44
+ aspectRatio: pieces_framework_1.Property.StaticDropdown({
45
+ displayName: 'Aspect Ratio',
46
+ required: true,
47
+ defaultValue: '16:9',
48
+ options: {
49
+ disabled: false,
50
+ options: [
51
+ { label: '16:9 (Landscape)', value: '16:9' },
52
+ { label: '9:16 (Portrait)', value: '9:16' },
53
+ ],
54
+ },
55
+ }),
56
+ durationSeconds: pieces_framework_1.Property.Dropdown({
57
+ displayName: 'Duration (seconds)',
58
+ description: 'Must be 8 when using 1080p, 4K, or reference images.',
59
+ required: false,
60
+ auth: auth_1.googleGeminiAuth,
61
+ refreshers: ['model'],
62
+ defaultValue: 8,
63
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ model }) {
64
+ const isVeo2 = model === null || model === void 0 ? void 0 : model.startsWith('veo-2');
65
+ if (isVeo2) {
66
+ return {
67
+ disabled: false,
68
+ options: [
69
+ { label: '5 seconds', value: 5 },
70
+ { label: '6 seconds', value: 6 },
71
+ { label: '7 seconds', value: 7 },
72
+ { label: '8 seconds', value: 8 },
73
+ ],
74
+ };
75
+ }
76
+ return {
77
+ disabled: false,
78
+ options: [
79
+ { label: '4 seconds', value: 4 },
80
+ { label: '6 seconds', value: 6 },
81
+ { label: '8 seconds', value: 8 },
82
+ ],
83
+ };
84
+ }),
85
+ }),
86
+ resolution: pieces_framework_1.Property.Dropdown({
87
+ displayName: 'Resolution',
88
+ description: '1080p is available on Veo 3.0+ only. 4K is only available on Veo 3.1 models. 1080p and 4K require 8-second duration.',
89
+ required: false,
90
+ auth: auth_1.googleGeminiAuth,
91
+ refreshers: ['model'],
92
+ defaultValue: '720p',
93
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ model }) {
94
+ const modelStr = model;
95
+ const isVeo2 = modelStr === null || modelStr === void 0 ? void 0 : modelStr.startsWith('veo-2');
96
+ const is31 = modelStr === null || modelStr === void 0 ? void 0 : modelStr.startsWith('veo-3.1');
97
+ return {
98
+ disabled: false,
99
+ options: [
100
+ { label: '720p', value: '720p' },
101
+ ...(isVeo2 ? [] : [{ label: '1080p', value: '1080p' }]),
102
+ ...(is31 ? [{ label: '4K', value: '4k' }] : []),
103
+ ],
104
+ };
105
+ }),
106
+ }),
107
+ personGeneration: pieces_framework_1.Property.StaticDropdown({
108
+ displayName: 'Person Generation',
109
+ description: 'Controls whether people or faces can appear in the generated video.',
110
+ required: false,
111
+ defaultValue: 'allow_adult',
112
+ options: {
113
+ disabled: false,
114
+ options: [
115
+ { label: 'Allow Adults Only (default)', value: 'allow_adult' },
116
+ { label: 'Allow All Ages (requires allowlist)', value: 'allow_all' },
117
+ { label: "Don't Allow People", value: 'dont_allow' },
118
+ ],
119
+ },
120
+ }),
121
+ },
122
+ run(context) {
123
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
124
+ var _a, _b, _c;
125
+ const { model, prompt, image, lastFrame, aspectRatio, durationSeconds, resolution, personGeneration, } = context.propsValue;
126
+ // API reference: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/model-reference/veo-video-generation#sample-request
127
+ const ai = new genai_1.GoogleGenAI({ apiKey: context.auth.secret_text });
128
+ let operation = yield ai.models.generateVideos(Object.assign(Object.assign({ model,
129
+ prompt }, (image
130
+ ? {
131
+ image: {
132
+ imageBytes: image.base64,
133
+ mimeType: mime_types_1.default.lookup(image.extension || image.filename) || 'image/jpeg',
134
+ },
135
+ }
136
+ : {})), { config: Object.assign({ aspectRatio, numberOfVideos: 1, durationSeconds,
137
+ resolution,
138
+ personGeneration }, (lastFrame
139
+ ? {
140
+ lastFrame: {
141
+ imageBytes: lastFrame.base64,
142
+ mimeType: mime_types_1.default.lookup(lastFrame.extension || lastFrame.filename) ||
143
+ 'image/jpeg',
144
+ },
145
+ }
146
+ : {})) }));
147
+ const maxWaitMs = 10 * 60 * 1000; // 10 minutes
148
+ const startTime = Date.now();
149
+ while (!operation.done) {
150
+ if (Date.now() - startTime > maxWaitMs) {
151
+ throw new Error('Video generation timed out after 10 minutes.');
152
+ }
153
+ yield new Promise((resolve) => setTimeout(resolve, 5000));
154
+ operation = yield ai.operations.getVideosOperation({ operation });
155
+ }
156
+ const video = (_c = (_b = (_a = operation.response) === null || _a === void 0 ? void 0 : _a.generatedVideos) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.video;
157
+ if (!video) {
158
+ throw new Error('No video data returned from model response.');
159
+ }
160
+ let videoBuffer;
161
+ if (video.videoBytes) {
162
+ videoBuffer = Buffer.from(video.videoBytes, 'base64');
163
+ }
164
+ else if (video.uri) {
165
+ const response = yield pieces_common_1.httpClient.sendRequest({
166
+ method: pieces_common_1.HttpMethod.GET,
167
+ url: video.uri,
168
+ queryParams: { key: context.auth.secret_text },
169
+ responseType: 'arraybuffer',
170
+ });
171
+ videoBuffer = Buffer.from(response.body);
172
+ }
173
+ else {
174
+ throw new Error('No video bytes or URI in model response.');
175
+ }
176
+ return yield context.files.write({
177
+ data: videoBuffer,
178
+ fileName: 'video.mp4',
179
+ });
180
+ });
181
+ },
182
+ });
183
+ //# sourceMappingURL=create-video.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-video.action.js","sourceRoot":"","sources":["../../../src/lib/actions/create-video.action.ts"],"names":[],"mappings":";;;;AAAA,mHAAmH;AACnH,qEAAqE;AACrE,gEAAmE;AACnE,0DAAgE;AAChE,kCAA2C;AAC3C,6CAA8D;AAC9D,yCAA4C;AAC5C,oEAA8B;AAEjB,QAAA,iBAAiB,GAAG,IAAA,+BAAY,EAAC;IAC5C,QAAQ,EAAE,MAAM;IAChB,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE,uBAAgB;IACtB,WAAW,EAAE,cAAc;IAC3B,WAAW,EAAE,8DAA8D;IAC3E,UAAU,EAAE,EAAE,WAAW,EAAE,qkBAAqkB,EAAE,UAAU,EAAE,KAAK,EAAE;IACrnB,KAAK,EAA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A,SAAS,CAAC,QAAQ,0CAAE,eAAe,0CAAG,CAAC,CAAC,0CAAE,KAAK,CAAC;YAE9D,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;YACjE,CAAC;YAED,IAAI,WAAmB,CAAC;YAExB,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;gBACrB,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;YACxD,CAAC;iBAAM,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;gBACrB,MAAM,QAAQ,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAc;oBACzD,MAAM,EAAE,0BAAU,CAAC,GAAG;oBACtB,GAAG,EAAE,KAAK,CAAC,GAAG;oBACd,WAAW,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE;oBAC9C,YAAY,EAAE,aAAa;iBAC5B,CAAC,CAAC;gBACH,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC3C,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;YAC9D,CAAC;YAED,OAAO,MAAM,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;gBAC/B,IAAI,EAAE,WAAW;gBACjB,QAAQ,EAAE,WAAW;aACtB,CAAC,CAAC;QACL,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare const generateContentFromImageAction: import("@agnocon/pieces-framework").IAction<import("@agnocon/pieces-framework").SecretTextProperty<true>, {
2
+ prompt: import("@agnocon/pieces-framework").LongTextProperty<true>;
3
+ image: import("@agnocon/pieces-framework").FileProperty<true, false>;
4
+ model: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
5
+ }>;
6
+ //# sourceMappingURL=generate-content-from-image.action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-content-from-image.action.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/generate-content-from-image.action.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,8BAA8B;;;;EAwDzC,CAAC"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateContentFromImageAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // Vendored from Activepieces packages/pieces/community/google-gemini/src/lib/actions/generate-content-from-image.action.ts (MIT).
6
+ // Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
7
+ const generative_ai_1 = require("@google/generative-ai");
8
+ const mime_types_1 = tslib_1.__importDefault(require("mime-types"));
9
+ const pieces_framework_1 = require("@agnocon/pieces-framework");
10
+ const auth_1 = require("../auth");
11
+ const common_1 = require("../common/common");
12
+ const output_schemas_1 = require("../output-schemas");
13
+ exports.generateContentFromImageAction = (0, pieces_framework_1.createAction)({
14
+ audience: 'both',
15
+ description: 'Generate content using Google Gemini using the "gemini-pro-vision" model',
16
+ aiMetadata: { description: 'Sends an image together with a prompt to a vision-capable Gemini model and returns the generated text describing or answering questions about that image, covering captioning, text extraction, and visual question answering. This is the only Gemini action here that accepts image input, so pick it over generate_content whenever a picture is part of the question; the image is required and is sent inline, so keep it small. Not idempotent: each call produces a fresh completion.', idempotent: false },
17
+ displayName: 'Generate Content from Image',
18
+ name: 'generate_content_from_image',
19
+ auth: auth_1.googleGeminiAuth,
20
+ props: {
21
+ prompt: pieces_framework_1.Property.LongText({
22
+ displayName: 'Prompt',
23
+ required: true,
24
+ description: 'The prompt to generate content from.',
25
+ }),
26
+ image: pieces_framework_1.Property.File({
27
+ displayName: 'Image',
28
+ required: true,
29
+ description: 'The image to generate content from.'
30
+ }),
31
+ model: pieces_framework_1.Property.Dropdown({
32
+ displayName: 'Model',
33
+ auth: auth_1.googleGeminiAuth,
34
+ required: true,
35
+ description: 'The model which will generate the completion',
36
+ refreshers: [],
37
+ defaultValue: common_1.defaultLLM,
38
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) { return (0, common_1.getGeminiModelOptions)({ auth }); }),
39
+ }),
40
+ },
41
+ outputSchema: output_schemas_1.generateContentFromImageActionOutputSchema,
42
+ run(_a) {
43
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
44
+ const { image, model, prompt } = propsValue;
45
+ const mimeType = mime_types_1.default.lookup(image.extension || image.filename) ||
46
+ `image/${image.extension}`;
47
+ const genAI = new generative_ai_1.GoogleGenerativeAI(auth.secret_text);
48
+ const generativeModel = genAI.getGenerativeModel({ model });
49
+ const result = yield generativeModel.generateContent([
50
+ prompt,
51
+ {
52
+ inlineData: {
53
+ data: image.base64,
54
+ mimeType,
55
+ },
56
+ },
57
+ ]);
58
+ const response = yield result.response;
59
+ return {
60
+ text: response.text(),
61
+ raw: response,
62
+ };
63
+ });
64
+ },
65
+ });
66
+ //# sourceMappingURL=generate-content-from-image.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-content-from-image.action.js","sourceRoot":"","sources":["../../../src/lib/actions/generate-content-from-image.action.ts"],"names":[],"mappings":";;;;AAAA,kIAAkI;AAClI,qEAAqE;AACrE,yDAA2D;AAC3D,oEAA8B;AAC9B,gEAGmC;AACnC,kCAA2C;AAC3C,6CAAqE;AACrE,sDAA+E;AAElE,QAAA,8BAA8B,GAAG,IAAA,+BAAY,EAAC;IACzD,QAAQ,EAAE,MAAM;IAChB,WAAW,EACT,0EAA0E;IAC5E,UAAU,EAAE,EAAE,WAAW,EAAE,8dAA8d,EAAE,UAAU,EAAE,KAAK,EAAE;IAC9gB,WAAW,EAAE,6BAA6B;IAC1C,IAAI,EAAE,6BAA6B;IACnC,IAAI,EAAE,uBAAgB;IACtB,KAAK,EAAE;QACL,MAAM,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACxB,WAAW,E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;gBACL,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE;gBACrB,GAAG,EAAE,QAAQ;aACd,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare const generateContentWithFileSearchAction: import("@agnocon/pieces-framework").IAction<import("@agnocon/pieces-framework").SecretTextProperty<true>, {
2
+ prompt: import("@agnocon/pieces-framework").LongTextProperty<true>;
3
+ model: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
4
+ fileStoreName: import("@agnocon/pieces-framework").ShortTextProperty<true>;
5
+ file: import("@agnocon/pieces-framework").FileProperty<true, false>;
6
+ }>;
7
+ //# sourceMappingURL=generate-content-with-file-search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-content-with-file-search.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/generate-content-with-file-search.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,mCAAmC;;;;;EA0E9C,CAAC"}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateContentWithFileSearchAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // Vendored from Activepieces packages/pieces/community/google-gemini/src/lib/actions/generate-content-with-file-search.ts (MIT).
6
+ // Generated by packages/scripts/vendor-ap.mjs - do not edit by hand.
7
+ const auth_1 = require("../auth");
8
+ const pieces_framework_1 = require("@agnocon/pieces-framework");
9
+ const common_1 = require("../common/common");
10
+ const genai_1 = require("@google/genai");
11
+ const mime_types_1 = tslib_1.__importDefault(require("mime-types"));
12
+ const output_schemas_1 = require("../output-schemas");
13
+ exports.generateContentWithFileSearchAction = (0, pieces_framework_1.createAction)({
14
+ audience: 'both',
15
+ description: 'Generate content with file search functionality.',
16
+ aiMetadata: { description: 'Uploads one file to a newly created Gemini File Search store, waits for indexing to finish, then answers the prompt grounded on that document. Use it for one-shot question answering over a document supplied at run time; prefer generate_content when no file grounding is needed or when a different built-in tool such as Google Search or URL Context fits better. Both a file and a store display name are required. Not idempotent: every call creates another file search store and a fresh completion.', idempotent: false },
17
+ displayName: 'Generate Content with File Search',
18
+ name: 'generate_content_with_filesearch',
19
+ auth: auth_1.googleGeminiAuth,
20
+ props: {
21
+ prompt: pieces_framework_1.Property.LongText({
22
+ displayName: 'Prompt',
23
+ required: true,
24
+ description: 'The prompt to generate content from.',
25
+ }),
26
+ model: pieces_framework_1.Property.Dropdown({
27
+ displayName: 'Model',
28
+ auth: auth_1.googleGeminiAuth,
29
+ required: true,
30
+ description: 'The model which will generate the completion',
31
+ refreshers: [],
32
+ defaultValue: common_1.defaultLLM,
33
+ options: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) { return (0, common_1.getGeminiModelOptions)({ auth }); }),
34
+ }),
35
+ fileStoreName: pieces_framework_1.Property.ShortText({
36
+ displayName: 'File Store Name',
37
+ required: true,
38
+ }),
39
+ file: pieces_framework_1.Property.File({
40
+ displayName: 'File',
41
+ required: true,
42
+ }),
43
+ },
44
+ outputSchema: output_schemas_1.generateContentWithFilesearchActionOutputSchema,
45
+ run(_a) {
46
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
47
+ const { file, fileStoreName, model, prompt } = propsValue;
48
+ const fileBlob = new Blob([Buffer.from(file.base64, 'base64')], {
49
+ type: mime_types_1.default.lookup(file.extension || file.filename) || undefined,
50
+ });
51
+ const genAI = new genai_1.GoogleGenAI({ apiKey: auth.secret_text });
52
+ const fileSearchStore = yield genAI.fileSearchStores.create({
53
+ config: { displayName: fileStoreName },
54
+ });
55
+ let operation = yield genAI.fileSearchStores.uploadToFileSearchStore({
56
+ file: fileBlob,
57
+ fileSearchStoreName: fileSearchStore.name,
58
+ config: {
59
+ displayName: file.filename,
60
+ },
61
+ });
62
+ while (!operation.done) {
63
+ yield new Promise((resolve) => setTimeout(resolve, 5000));
64
+ operation = yield genAI.operations.get({ operation });
65
+ }
66
+ const response = yield genAI.models.generateContent({
67
+ model: model,
68
+ contents: prompt,
69
+ config: {
70
+ tools: [
71
+ {
72
+ fileSearch: {
73
+ fileSearchStoreNames: [fileSearchStore.name],
74
+ },
75
+ },
76
+ ],
77
+ },
78
+ });
79
+ return response.text;
80
+ });
81
+ },
82
+ });
83
+ //# sourceMappingURL=generate-content-with-file-search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-content-with-file-search.js","sourceRoot":"","sources":["../../../src/lib/actions/generate-content-with-file-search.ts"],"names":[],"mappings":";;;;AAAA,iIAAiI;AACjI,qEAAqE;AACrE,kCAA2C;AAC3C,gEAAmE;AACnE,6CAAqE;AACrE,yCAA4C;AAC5C,oEAA8B;AAC9B,sDAAoF;AAEvE,QAAA,mCAAmC,GAAG,IAAA,+BAAY,EAAC;IAC9D,QAAQ,EAAE,MAAM;IAChB,WAAW,EAAE,kDAAkD;IAC/D,UAAU,EAAE,EAAE,WAAW,EAAE,kfAAkf,EAAE,UAAU,EAAE,KAAK,EAAE;IACliB,WAAW,EAAE,mCAAmC;IAChD,IAAI,EAAE,kCAAkC;IACxC,IAAI,EAAE,uBAAgB;IACtB,KAAK,EAAE;QACL,MAAM,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACxB,WAAW,EAAE,QAAQ;YACrB,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,sCAAsC;SACpD,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACvB,WAAW,EAAE,OAAO;YACpB,IAAI,EAAE,uBAAgB;YACtB,QAAQ,EAAE,IAAI;YACd,WAAW,EAAE,8CAA8C;YAC3D,UAAU,EAAE,EAAE;YACd,YAAY,EAAE,mBAAU;YACxB,OAAO,EAAE,KAAiB,EAAE,oDAAZ,EAAE,IAAI,EAAE,IAAK,OAAA,IAAA,8BAAqB,EAAC,EAAE,IAAI,EAAE,CAAC,CAAA,GAAA;SAC7D,CAAC;QACF,aAAa,EAAE,2BAAQ,CAA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M,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;YACxD,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC;gBAClD,KAAK,EAAE,KAAK;gBACZ,QAAQ,EAAE,MAAM;gBAChB,MAAM,EAAE;oBACN,KAAK,EAAE;wBACL;4BACE,UAAU,EAAE;gCACV,oBAAoB,EAAE,CAAC,eAAe,CAAC,IAAK,CAAC;6BAC9C;yBACF;qBACF;iBACF;aACF,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare const generateContentAction: import("@agnocon/pieces-framework").IAction<import("@agnocon/pieces-framework").SecretTextProperty<true>, {
2
+ prompt: import("@agnocon/pieces-framework").LongTextProperty<true>;
3
+ model: import("@agnocon/pieces-framework").DropdownProperty<string, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
4
+ toolType: import("@agnocon/pieces-framework").StaticDropdownProperty<string, false>;
5
+ toolProperties: import("@agnocon/pieces-framework").DynamicProperties<false, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
6
+ }>;
7
+ //# sourceMappingURL=generate-content.action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-content.action.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/generate-content.action.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,qBAAqB;;;;;EA6LhC,CAAC"}