@agnocon/piece-camb-ai 0.1.7

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 (37) 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 +40 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/lib/actions/create-text-to-sound.d.ts +8 -0
  7. package/dist/lib/actions/create-text-to-sound.d.ts.map +1 -0
  8. package/dist/lib/actions/create-text-to-sound.js +100 -0
  9. package/dist/lib/actions/create-text-to-sound.js.map +1 -0
  10. package/dist/lib/actions/create-text-to-speech.d.ts +11 -0
  11. package/dist/lib/actions/create-text-to-speech.d.ts.map +1 -0
  12. package/dist/lib/actions/create-text-to-speech.js +121 -0
  13. package/dist/lib/actions/create-text-to-speech.js.map +1 -0
  14. package/dist/lib/actions/create-transcription.d.ts +9 -0
  15. package/dist/lib/actions/create-transcription.d.ts.map +1 -0
  16. package/dist/lib/actions/create-transcription.js +134 -0
  17. package/dist/lib/actions/create-transcription.js.map +1 -0
  18. package/dist/lib/actions/create-translation.d.ts +10 -0
  19. package/dist/lib/actions/create-translation.d.ts.map +1 -0
  20. package/dist/lib/actions/create-translation.js +116 -0
  21. package/dist/lib/actions/create-translation.js.map +1 -0
  22. package/dist/lib/auth.d.ts +2 -0
  23. package/dist/lib/auth.d.ts.map +1 -0
  24. package/dist/lib/auth.js +41 -0
  25. package/dist/lib/auth.js.map +1 -0
  26. package/dist/lib/common/index.d.ts +10 -0
  27. package/dist/lib/common/index.d.ts.map +1 -0
  28. package/dist/lib/common/index.js +152 -0
  29. package/dist/lib/common/index.js.map +1 -0
  30. package/package.json +47 -0
  31. package/src/index.ts +34 -0
  32. package/src/lib/actions/create-text-to-sound.ts +104 -0
  33. package/src/lib/actions/create-text-to-speech.ts +121 -0
  34. package/src/lib/actions/create-transcription.ts +132 -0
  35. package/src/lib/actions/create-translation.ts +115 -0
  36. package/src/lib/auth.ts +34 -0
  37. package/src/lib/common/index.ts +165 -0
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 cambAi: 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":"AAYA,eAAO,MAAM,MAAM,yGAuBjB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cambAi = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // Vendored from Activepieces packages/pieces/community/camb-ai/src/index.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 create_text_to_sound_1 = require("./lib/actions/create-text-to-sound");
10
+ const create_text_to_speech_1 = require("./lib/actions/create-text-to-speech");
11
+ const create_translation_1 = require("./lib/actions/create-translation");
12
+ const create_transcription_1 = require("./lib/actions/create-transcription");
13
+ const common_1 = require("./lib/common");
14
+ const pieces_framework_2 = require("@agnocon/pieces-framework");
15
+ const auth_1 = require("./lib/auth");
16
+ exports.cambAi = (0, pieces_framework_1.createPiece)({
17
+ displayName: "Camb.AI",
18
+ auth: auth_1.cambaiAuth,
19
+ minimumSupportedRelease: '0.36.1',
20
+ logoUrl: "https://cdn.activepieces.com/pieces/camb-ai.png",
21
+ authors: ['david-oluwaseun420', 'sanket-a11y'],
22
+ categories: [pieces_framework_2.PieceCategory.ARTIFICIAL_INTELLIGENCE],
23
+ actions: [
24
+ create_text_to_sound_1.createTextToSound,
25
+ create_text_to_speech_1.createTextToSpeech,
26
+ create_translation_1.createTranslation,
27
+ create_transcription_1.createTranscription,
28
+ (0, pieces_common_1.createCustomApiCallAction)({
29
+ auth: auth_1.cambaiAuth,
30
+ baseUrl: () => common_1.API_BASE_URL,
31
+ authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
32
+ return {
33
+ 'x-api-key': auth.secret_text,
34
+ };
35
+ }),
36
+ }),
37
+ ],
38
+ triggers: [],
39
+ });
40
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,mFAAmF;AACnF,qEAAqE;AACrE,gEAAmE;AACnE,0DAA2F;AAC3F,6EAAuE;AACvE,+EAAyE;AACzE,yEAAqE;AACrE,6EAAyE;AACzE,yCAA4C;AAC5C,gEAA0D;AAC1D,qCAAwC;AAE3B,QAAA,MAAM,GAAG,IAAA,8BAAW,EAAC;IAC9B,WAAW,EAAE,SAAS;IACtB,IAAI,EAAE,iBAAU;IAChB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,iDAAiD;IAC1D,OAAO,EAAE,CAAC,oBAAoB,EAAC,aAAa,CAAC;IAC7C,UAAU,EAAC,CAAC,gCAAa,CAAC,uBAAuB,CAAC;IAClD,OAAO,EAAE;QACL,wCAAiB;QACjB,0CAAkB;QAClB,sCAAiB;QACjB,0CAAmB;QACnB,IAAA,yCAAyB,EAAC;YACtB,IAAI,EAAE,iBAAU;YAChB,OAAO,EAAE,GAAG,EAAE,CAAC,qBAAY;YAC3B,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBACxB,OAAO;oBACH,WAAW,EAAE,IAAI,CAAC,WAAW;iBAChC,CAAC;YACN,CAAC,CAAA;SACJ,CAAC;KACL;IACD,QAAQ,EAAE,EAAE;CACf,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare const createTextToSound: import("@agnocon/pieces-framework").IAction<import("@agnocon/pieces-framework").SecretTextProperty<true>, {
2
+ prompt: import("@agnocon/pieces-framework").LongTextProperty<true>;
3
+ duration: import("@agnocon/pieces-framework").NumberProperty<false>;
4
+ project_name: import("@agnocon/pieces-framework").ShortTextProperty<false>;
5
+ project_description: import("@agnocon/pieces-framework").LongTextProperty<false>;
6
+ folder_id: import("@agnocon/pieces-framework").DropdownProperty<number, false, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
7
+ }>;
8
+ //# sourceMappingURL=create-text-to-sound.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-text-to-sound.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/create-text-to-sound.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,iBAAiB;;;;;;EAiG5B,CAAC"}
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTextToSound = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // Vendored from Activepieces packages/pieces/community/camb-ai/src/lib/actions/create-text-to-sound.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");
11
+ const common_2 = require("../common");
12
+ exports.createTextToSound = (0, pieces_framework_1.createAction)({
13
+ auth: auth_1.cambaiAuth,
14
+ name: 'create_text_to_sound',
15
+ displayName: 'Create Text-to-Sound',
16
+ description: 'Convert input text into “sound effects” using an AI model.',
17
+ audience: 'both',
18
+ aiMetadata: { description: 'Generates a sound-effect audio clip from a text prompt describing the desired effect using Camb.AI, polling until the generation task completes and returning the audio. Use to synthesize non-speech sound effects (not spoken voice — use Create Text-to-Speech for that). Duration is capped at 10 seconds (defaults to 8). Not idempotent: each call starts a new generation task and produces fresh audio.', idempotent: false },
19
+ props: {
20
+ prompt: pieces_framework_1.Property.LongText({
21
+ displayName: 'Prompt',
22
+ description: 'A clear, descriptive explanation of the desired audio effect. Concise prompts yield more accurate results.',
23
+ required: true,
24
+ }),
25
+ duration: pieces_framework_1.Property.Number({
26
+ displayName: 'Duration (seconds)',
27
+ description: 'The desired length of the audio in seconds (max 10). Defaults to 8 if not set.',
28
+ required: false,
29
+ }),
30
+ project_name: pieces_framework_1.Property.ShortText({
31
+ displayName: 'Project Name',
32
+ description: 'A memorable name for your project to help organize tasks in your Camb.ai workspace.',
33
+ required: false,
34
+ }),
35
+ project_description: pieces_framework_1.Property.LongText({
36
+ displayName: 'Project Description',
37
+ description: 'Provide details about your project\'s goals and specifications for documentation purposes.',
38
+ required: false,
39
+ }),
40
+ folder_id: common_2.listFoldersDropdown,
41
+ },
42
+ run(context) {
43
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
44
+ var _a;
45
+ const { auth } = context;
46
+ const { prompt, duration, project_name, project_description, folder_id } = context.propsValue;
47
+ const payload = { prompt };
48
+ if (duration)
49
+ payload['duration'] = duration;
50
+ if (project_name)
51
+ payload['project_name'] = project_name;
52
+ if (project_description)
53
+ payload['project_description'] = project_description;
54
+ if (folder_id)
55
+ payload['folder_id'] = folder_id;
56
+ const initialResponse = yield pieces_common_1.httpClient.sendRequest({
57
+ method: pieces_common_1.HttpMethod.POST,
58
+ url: `${common_1.API_BASE_URL}/text-to-sound`,
59
+ headers: {
60
+ 'x-api-key': auth.secret_text,
61
+ 'Content-Type': 'application/json'
62
+ },
63
+ body: payload,
64
+ });
65
+ const taskId = initialResponse.body.task_id;
66
+ let attempts = 0;
67
+ let run_id = null;
68
+ while (attempts < common_1.MAX_POLLING_ATTEMPTS) {
69
+ const statusResponse = yield pieces_common_1.httpClient.sendRequest({
70
+ method: pieces_common_1.HttpMethod.GET,
71
+ url: `${common_1.API_BASE_URL}/text-to-sound/${taskId}`,
72
+ headers: {
73
+ 'x-api-key': auth.secret_text,
74
+ },
75
+ });
76
+ const status = statusResponse.body.status;
77
+ if (status === 'SUCCESS') {
78
+ run_id = (_a = statusResponse.body.run_id) !== null && _a !== void 0 ? _a : null;
79
+ break;
80
+ }
81
+ if (status === 'FAILED') {
82
+ throw new Error(`Sound generation task failed: ${JSON.stringify(statusResponse.body)}`);
83
+ }
84
+ yield new Promise(resolve => setTimeout(resolve, common_1.POLLING_INTERVAL_MS));
85
+ attempts++;
86
+ }
87
+ if (!run_id) {
88
+ throw new Error("Sound generation task timed out or failed to return a run_id.");
89
+ }
90
+ const audioResponse = yield pieces_common_1.httpClient.sendRequest({
91
+ method: pieces_common_1.HttpMethod.GET,
92
+ url: `${common_1.API_BASE_URL}/text-to-sound-result/${run_id}`,
93
+ headers: { 'x-api-key': auth.secret_text },
94
+ responseType: 'arraybuffer',
95
+ });
96
+ return { audio: audioResponse.body };
97
+ });
98
+ },
99
+ });
100
+ //# sourceMappingURL=create-text-to-sound.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-text-to-sound.js","sourceRoot":"","sources":["../../../src/lib/actions/create-text-to-sound.ts"],"names":[],"mappings":";;;;AAAA,8GAA8G;AAC9G,qEAAqE;AACrE,gEAAmE;AACnE,0DAAgE;AAChE,kCAAqC;AACrC,sCAAoF;AACpF,sCAAgD;AAEnC,QAAA,iBAAiB,GAAG,IAAA,+BAAY,EAAC;IAC1C,IAAI,EAAE,iBAAU;IAChB,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,sBAAsB;IACnC,WAAW,EAAE,4DAA4D;IACzE,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,EAAE,WAAW,EAAE,iZAAiZ,EAAE,UAAU,EAAE,KAAK,EAAE;IACjc,KAAK,EAAE;QACH,MAAM,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACtB,WAAW,EAAE,QAAQ;YACrB,WAAW,EAAE,4GAA4G;YACzH,QAAQ,EAAE,IAAI;SACjB,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACtB,WAAW,EAAE,oBAAoB;YACjC,WAAW,EAAE,gFAAgF;YAC7F,QAAQ,EAAE,KAAK;SAClB,CAAC;QACF,YAAY,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC7B,WAAW,EAAE,cAAc;YAC3B,WAAW,EAAE,qFAAqF;YAClG,QAAQ,EAAE,KAAK;SAClB,CAAC;QACF,mBAAmB,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACnC,WAAW,EAAE,qBAAqB;YAClC,WAAW,EAAE,4FAA4F;YACzG,QAAQ,EAAE,KAAK;SAClB,CAAC;QACF,SAAS,EAAE,4BAAmB;KACjC;IACK,GAAG,CAAC,OAAO;;;YACb,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;YACzB,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,mBAAmB,EAAE,SAAS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C;oBAC5C,MAAM;gBACV,CAAC;gBAED,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;oBAEtB,MAAM,IAAI,KAAK,CAAC,iCAAiC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAC5F,CAAC;gBAGD,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,4BAAmB,CAAC,CAAC,CAAC;gBACvE,QAAQ,EAAE,CAAC;YACf,CAAC;YAGD,IAAI,CAAC,MAAM,EAAE,CAAC;gBACV,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;YACrF,CAAC;YACD,MAAM,aAAa,GAAG,MAAM,0BAAU,CAAC,WAAW,CAAC;gBAC/C,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,GAAG,EAAE,GAAG,qBAAY,yBAAyB,MAAM,EAAE;gBACrD,OAAO,EAAE,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE;gBAC1C,YAAY,EAAE,aAAa;aAC9B,CAAC,CAAC;YAEH,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,IAAI,EAAE,CAAC;QAEzC,CAAC;KAAA;CACJ,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ export declare const createTextToSpeech: import("@agnocon/pieces-framework").IAction<import("@agnocon/pieces-framework").SecretTextProperty<true>, {
2
+ text: import("@agnocon/pieces-framework").LongTextProperty<true>;
3
+ language: import("@agnocon/pieces-framework").DropdownProperty<number, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
4
+ voice_id: import("@agnocon/pieces-framework").DropdownProperty<number, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
5
+ gender: import("@agnocon/pieces-framework").StaticDropdownProperty<number, false>;
6
+ age: import("@agnocon/pieces-framework").NumberProperty<false>;
7
+ project_name: import("@agnocon/pieces-framework").ShortTextProperty<false>;
8
+ project_description: import("@agnocon/pieces-framework").LongTextProperty<false>;
9
+ folder_id: import("@agnocon/pieces-framework").DropdownProperty<number, false, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
10
+ }>;
11
+ //# sourceMappingURL=create-text-to-speech.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-text-to-speech.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/create-text-to-speech.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,kBAAkB;;;;;;;;;EAkH7B,CAAC"}
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTextToSpeech = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // Vendored from Activepieces packages/pieces/community/camb-ai/src/lib/actions/create-text-to-speech.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");
11
+ const common_2 = require("../common");
12
+ exports.createTextToSpeech = (0, pieces_framework_1.createAction)({
13
+ auth: auth_1.cambaiAuth,
14
+ name: 'create_text_to_speech',
15
+ displayName: 'Create Text-to-Speech',
16
+ description: 'Convert text into speech using a specified voice, language, gender, and age group.',
17
+ audience: 'both',
18
+ aiMetadata: { description: 'Synthesizes spoken-voice audio from text via Camb.AI text-to-speech, polling until the task completes and writing the resulting WAV to a file. Requires a language and a voice_id (both selected from Camb.AI dropdowns); optionally tune gender and age. Use for spoken narration/dialogue; for non-speech sound effects use Create Text-to-Sound instead. Not idempotent: each call starts a new synthesis task and produces a new audio file.', idempotent: false },
19
+ props: {
20
+ text: pieces_framework_1.Property.LongText({
21
+ displayName: 'Text',
22
+ description: 'The text to be converted to speech.',
23
+ required: true,
24
+ }),
25
+ language: common_1.listSourceLanguagesDropdown,
26
+ voice_id: common_1.listVoicesDropdown,
27
+ gender: pieces_framework_1.Property.StaticDropdown({
28
+ displayName: 'Gender',
29
+ description: 'The gender of the speaker.',
30
+ required: false,
31
+ options: {
32
+ options: [
33
+ { label: 'Male', value: 1 },
34
+ { label: 'Female', value: 2 },
35
+ { label: 'Neutral', value: 0 },
36
+ { label: 'Unspecified', value: 9 },
37
+ ],
38
+ }
39
+ }),
40
+ age: pieces_framework_1.Property.Number({
41
+ displayName: 'Age',
42
+ description: 'The age of the speaker to be generated.',
43
+ required: false,
44
+ }),
45
+ project_name: pieces_framework_1.Property.ShortText({
46
+ displayName: 'Project Name',
47
+ description: 'A memorable name for your project to help organize tasks in your Camb.ai workspace.',
48
+ required: false,
49
+ }),
50
+ project_description: pieces_framework_1.Property.LongText({
51
+ displayName: 'Project Description',
52
+ description: 'Provide details about your project\'s goals and specifications for documentation purposes.',
53
+ required: false,
54
+ }),
55
+ folder_id: common_2.listFoldersDropdown,
56
+ },
57
+ run(context) {
58
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
59
+ var _a;
60
+ const { auth } = context;
61
+ const { text, language, voice_id, gender, age, project_name, project_description, folder_id } = context.propsValue;
62
+ const payload = { text, language: Number(language), voice_id: Number(voice_id) };
63
+ if (gender !== undefined)
64
+ payload['gender'] = gender;
65
+ if (age)
66
+ payload['age'] = age;
67
+ if (project_name)
68
+ payload['project_name'] = project_name;
69
+ if (project_description)
70
+ payload['project_description'] = project_description;
71
+ if (folder_id)
72
+ payload['folder_id'] = folder_id;
73
+ const initialResponse = yield pieces_common_1.httpClient.sendRequest({
74
+ method: pieces_common_1.HttpMethod.POST,
75
+ url: `${common_1.API_BASE_URL}/tts`,
76
+ headers: { 'x-api-key': auth.secret_text, 'Content-Type': 'application/json' },
77
+ body: payload,
78
+ });
79
+ const taskId = initialResponse.body.task_id;
80
+ let attempts = 0;
81
+ let run_id = null;
82
+ while (attempts < common_1.MAX_POLLING_ATTEMPTS) {
83
+ const statusResponse = yield pieces_common_1.httpClient.sendRequest({
84
+ method: pieces_common_1.HttpMethod.GET,
85
+ url: `${common_1.API_BASE_URL}/tts/${taskId}`,
86
+ headers: { 'x-api-key': auth.secret_text },
87
+ });
88
+ if (statusResponse.body.status === 'SUCCESS') {
89
+ run_id = (_a = statusResponse.body.run_id) !== null && _a !== void 0 ? _a : null;
90
+ break;
91
+ }
92
+ if (statusResponse.body.status === 'FAILED') {
93
+ throw new Error(`Text-to-Speech task failed: ${JSON.stringify(statusResponse.body)}`);
94
+ }
95
+ yield new Promise(resolve => setTimeout(resolve, common_1.POLLING_INTERVAL_MS));
96
+ attempts++;
97
+ }
98
+ if (!run_id) {
99
+ throw new Error("Text-to-Speech task timed out or failed to return a run_id.");
100
+ }
101
+ const audioResponse = yield pieces_common_1.httpClient.sendRequest({
102
+ method: pieces_common_1.HttpMethod.GET,
103
+ url: `${common_1.API_BASE_URL}/tts-result/${run_id}`,
104
+ headers: { 'x-api-key': auth.secret_text },
105
+ responseType: 'arraybuffer',
106
+ });
107
+ const fileName = `speech_${run_id}.wav`;
108
+ const fileData = Buffer.from(audioResponse.body);
109
+ const fileUrl = yield context.files.write({
110
+ fileName,
111
+ data: fileData,
112
+ });
113
+ return {
114
+ message: "Speech generated successfully.",
115
+ audio_url: fileUrl,
116
+ run_id: run_id,
117
+ };
118
+ });
119
+ },
120
+ });
121
+ //# sourceMappingURL=create-text-to-speech.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-text-to-speech.js","sourceRoot":"","sources":["../../../src/lib/actions/create-text-to-speech.ts"],"names":[],"mappings":";;;;AAAA,+GAA+G;AAC/G,qEAAqE;AACrE,gEAAmE;AACnE,0DAA8E;AAC9E,kCAAqC;AACrC,sCAAoI;AACpI,sCAAgD;AAEnC,QAAA,kBAAkB,GAAG,IAAA,+BAAY,EAAC;IAC3C,IAAI,EAAE,iBAAU;IAChB,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EAAE,uBAAuB;IACpC,WAAW,EAAE,oFAAoF;IACjG,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,EAAE,WAAW,EAAE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AAE,MAAM;aACjB,CAAC;QACN,CAAC;KAAA;CACJ,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare const createTranscription: import("@agnocon/pieces-framework").IAction<import("@agnocon/pieces-framework").SecretTextProperty<true>, {
2
+ language: import("@agnocon/pieces-framework").DropdownProperty<number, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
3
+ source_type: import("@agnocon/pieces-framework").StaticDropdownProperty<string, true>;
4
+ media: import("@agnocon/pieces-framework").DynamicProperties<true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
5
+ project_name: import("@agnocon/pieces-framework").ShortTextProperty<false>;
6
+ project_description: import("@agnocon/pieces-framework").LongTextProperty<false>;
7
+ folder_id: import("@agnocon/pieces-framework").DropdownProperty<number, false, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
8
+ }>;
9
+ //# sourceMappingURL=create-transcription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-transcription.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/create-transcription.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,mBAAmB;;;;;;;EA4H9B,CAAC"}
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTranscription = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // Vendored from Activepieces packages/pieces/community/camb-ai/src/lib/actions/create-transcription.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");
11
+ const form_data_1 = tslib_1.__importDefault(require("form-data"));
12
+ const common_2 = require("../common");
13
+ exports.createTranscription = (0, pieces_framework_1.createAction)({
14
+ auth: auth_1.cambaiAuth,
15
+ name: 'create_transcription',
16
+ displayName: 'Create Transcription',
17
+ description: 'Creates a task to process speech into readable text.',
18
+ audience: 'both',
19
+ aiMetadata: { description: 'Transcribes speech from an audio/video source into text via Camb.AI, polling until the transcription task completes. The media can be supplied either as an uploaded file (max 20MB) or as a public file URL, selected via the media source mode; you must specify the spoken language. Use to convert recorded speech to text. Not idempotent: each call starts a new transcription task.', idempotent: false },
20
+ props: {
21
+ language: common_1.listSourceLanguagesDropdown,
22
+ source_type: pieces_framework_1.Property.StaticDropdown({
23
+ displayName: 'Media Source',
24
+ description: 'Choose whether to upload a file or provide a URL.',
25
+ required: true,
26
+ defaultValue: 'file',
27
+ options: {
28
+ options: [
29
+ { label: 'Upload File', value: 'file' },
30
+ { label: 'File URL', value: 'url' },
31
+ ]
32
+ },
33
+ }),
34
+ media: pieces_framework_1.Property.DynamicProperties({
35
+ auth: auth_1.cambaiAuth,
36
+ displayName: 'Media',
37
+ required: true,
38
+ refreshers: ['source_type'],
39
+ props: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
40
+ const sourceType = context['source_type'];
41
+ const fields = {};
42
+ if (sourceType === 'file') {
43
+ fields['media_file'] = pieces_framework_1.Property.File({
44
+ displayName: 'Media File',
45
+ description: 'The media file (e.g., MP3, WAV, MP4) to transcribe. Max size: 20MB.',
46
+ required: true,
47
+ });
48
+ }
49
+ else if (sourceType === 'url') {
50
+ fields['media_url'] = pieces_framework_1.Property.ShortText({
51
+ displayName: 'Media URL',
52
+ description: 'A public URL to the media file to transcribe.',
53
+ required: true,
54
+ });
55
+ }
56
+ return fields;
57
+ })
58
+ }),
59
+ project_name: pieces_framework_1.Property.ShortText({
60
+ displayName: 'Project Name',
61
+ description: 'A memorable name for your project to help organize tasks in your Camb.ai workspace.',
62
+ required: false,
63
+ }),
64
+ project_description: pieces_framework_1.Property.LongText({
65
+ displayName: 'Project Description',
66
+ description: 'Provide details about your project\'s goals and specifications for documentation purposes.',
67
+ required: false,
68
+ }),
69
+ folder_id: common_2.listFoldersDropdown,
70
+ },
71
+ run(context) {
72
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
73
+ var _a;
74
+ const { auth } = context;
75
+ const { language, source_type, media, project_name, project_description, folder_id } = context.propsValue;
76
+ const formData = new form_data_1.default();
77
+ formData.append('language', Number(language).toString());
78
+ if (project_name)
79
+ formData.append('project_name', project_name);
80
+ if (project_description)
81
+ formData.append('project_description', project_description);
82
+ if (folder_id)
83
+ formData.append('folder_id', folder_id.toString());
84
+ if (source_type === 'url') {
85
+ if (!media['media_url'])
86
+ throw new Error("Media URL is required when source is 'File URL'.");
87
+ formData.append('media_url', media['media_url']);
88
+ }
89
+ else {
90
+ if (!media['media_file'])
91
+ throw new Error("Media File is required when source is 'Upload File'.");
92
+ const fileData = media['media_file'];
93
+ formData.append('media_file', fileData.data, fileData.filename);
94
+ }
95
+ const requestBody = yield formData.getBuffer();
96
+ const headers = Object.assign({ 'x-api-key': auth.secret_text }, formData.getHeaders());
97
+ const initialResponse = yield pieces_common_1.httpClient.sendRequest({
98
+ method: pieces_common_1.HttpMethod.POST,
99
+ url: `${common_1.API_BASE_URL}/transcribe`,
100
+ headers: headers,
101
+ body: requestBody,
102
+ });
103
+ const taskId = initialResponse.body.task_id;
104
+ let run_id = null;
105
+ let attempts = 0;
106
+ while (attempts < common_1.LONG_MAX_POLLING_ATTEMPTS) {
107
+ const statusResponse = yield pieces_common_1.httpClient.sendRequest({
108
+ method: pieces_common_1.HttpMethod.GET,
109
+ url: `${common_1.API_BASE_URL}/transcribe/${taskId}`,
110
+ headers: { 'x-api-key': auth.secret_text },
111
+ });
112
+ if (statusResponse.body.status === 'SUCCESS') {
113
+ run_id = (_a = statusResponse.body.run_id) !== null && _a !== void 0 ? _a : null;
114
+ break;
115
+ }
116
+ if (statusResponse.body.status === 'FAILED') {
117
+ throw new Error(`Transcription task failed: ${JSON.stringify(statusResponse.body)}`);
118
+ }
119
+ yield new Promise(resolve => setTimeout(resolve, common_1.POLLING_INTERVAL_MS));
120
+ attempts++;
121
+ }
122
+ if (!run_id) {
123
+ throw new Error("Transcription task timed out or failed to return a task_id.");
124
+ }
125
+ const resultResponse = yield pieces_common_1.httpClient.sendRequest({
126
+ method: pieces_common_1.HttpMethod.GET,
127
+ url: `${common_1.API_BASE_URL}/transcription-result/${run_id}`,
128
+ headers: { 'x-api-key': auth.secret_text },
129
+ });
130
+ return resultResponse.body;
131
+ });
132
+ },
133
+ });
134
+ //# sourceMappingURL=create-transcription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-transcription.js","sourceRoot":"","sources":["../../../src/lib/actions/create-transcription.ts"],"names":[],"mappings":";;;;AAAA,8GAA8G;AAC9G,qEAAqE;AACrE,gEAA8F;AAC9F,0DAA8F;AAC9F,kCAAqC;AACrC,sCAAsH;AACtH,kEAAiC;AACjC,sCAAgD;AAEnC,QAAA,mBAAmB,GAAG,IAAA,+BAAY,EAAC;IAC5C,IAAI,EAAE,iBAAU;IAChB,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,sBAAsB;IACnC,WAAW,EAAE,sDAAsD;IACnE,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,EAAE,WAAW,EAAE,4XAA4X,EAAE,UAAU,EAAE,KAAK,EAAE;IAC5a,KAAK,EAAE;QACH,QAAQ,EAAE,oCAA2B;QACrC,WAAW,EAAE,2BAAQ,CAAC,cAAc,CAAC;YACjC,WAAW,EAAE,cAAc;YAC3B,WAAW,EAAE,mDAAmD;YAChE,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,MAAM;YACpB,OAAO,EAAE;gBACL,OAAO,EAAE;oBACL,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE;oBACvC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE;iBACtC;aACJ;SACJ,CAAC;QACF,KAAK,EAAE,2BAAQ,CAAC,iBAAiB,CAAC;YAC9B,IAAI,EAAE,iBAAU;YAChB,WAAW,EAAE,OAAO;YACpB,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,CAAC,aAAa,CAAC;Y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AAC;QAE/B,CAAC;KAAA;CACJ,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ export declare const createTranslation: import("@agnocon/pieces-framework").IAction<import("@agnocon/pieces-framework").SecretTextProperty<true>, {
2
+ texts: import("@agnocon/pieces-framework").LongTextProperty<true>;
3
+ source_language: import("@agnocon/pieces-framework").DropdownProperty<number, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
4
+ target_language: import("@agnocon/pieces-framework").DropdownProperty<number, true, import("@agnocon/pieces-framework").SecretTextProperty<true>>;
5
+ formality: import("@agnocon/pieces-framework").StaticDropdownProperty<number, false>;
6
+ gender: import("@agnocon/pieces-framework").StaticDropdownProperty<number, false>;
7
+ age: import("@agnocon/pieces-framework").NumberProperty<false>;
8
+ project_name: import("@agnocon/pieces-framework").ShortTextProperty<false>;
9
+ }>;
10
+ //# sourceMappingURL=create-translation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-translation.d.ts","sourceRoot":"","sources":["../../../src/lib/actions/create-translation.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,iBAAiB;;;;;;;;EA6G5B,CAAC"}
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTranslation = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // Vendored from Activepieces packages/pieces/community/camb-ai/src/lib/actions/create-translation.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");
11
+ exports.createTranslation = (0, pieces_framework_1.createAction)({
12
+ auth: auth_1.cambaiAuth,
13
+ name: 'create_translation',
14
+ displayName: 'Create Translation',
15
+ description: 'Translate text from a source language to a target language.',
16
+ audience: 'both',
17
+ aiMetadata: { description: 'Translates text from a source language to a target language via Camb.AI, polling until the translation task completes. Each input line is treated as a separate segment to translate, and both languages are chosen from Camb.AI dropdowns; optionally tune formality, gender, and target audience age. Use for text translation only (not audio — use Create Transcription for speech-to-text). Not idempotent: each call starts a new translation task.', idempotent: false },
18
+ props: {
19
+ texts: pieces_framework_1.Property.LongText({
20
+ displayName: 'Text to Translate',
21
+ description: 'The text to be translated. You can enter multiple lines; each line will be treated as a separate text segment.',
22
+ required: true,
23
+ }),
24
+ source_language: common_1.listSourceLanguagesDropdown,
25
+ target_language: common_1.listTargetLanguagesDropdown,
26
+ formality: pieces_framework_1.Property.StaticDropdown({
27
+ displayName: 'Formality',
28
+ description: 'Adjust the formality level to match your context.',
29
+ required: false,
30
+ options: {
31
+ options: [
32
+ { label: 'Formal', value: 1 },
33
+ { label: 'Informal', value: 2 },
34
+ ]
35
+ }
36
+ }),
37
+ gender: pieces_framework_1.Property.StaticDropdown({
38
+ displayName: 'Gender',
39
+ description: 'Specify grammatical gender preferences when relevant in the target language.',
40
+ required: false,
41
+ options: {
42
+ options: [
43
+ { label: 'Male', value: 1 },
44
+ { label: 'Female', value: 2 },
45
+ { label: 'Neutral', value: 0 },
46
+ { label: 'Unspecified', value: 9 },
47
+ ],
48
+ }
49
+ }),
50
+ age: pieces_framework_1.Property.Number({
51
+ displayName: 'Audience Age',
52
+ description: 'Helps adjust vocabulary and expressions to be age-appropriate.',
53
+ required: false,
54
+ }),
55
+ project_name: pieces_framework_1.Property.ShortText({
56
+ displayName: 'Project Name',
57
+ description: 'A memorable name for your project to help organize tasks in your Camb.ai workspace.',
58
+ required: false,
59
+ }),
60
+ },
61
+ run(context) {
62
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
63
+ var _a;
64
+ const { auth } = context;
65
+ const { texts, source_language, target_language, formality, gender, age, project_name } = context.propsValue;
66
+ const payload = {
67
+ texts: texts.split('\n').filter(line => line.trim().length > 0),
68
+ source_language: Number(source_language),
69
+ target_language: Number(target_language),
70
+ };
71
+ if (formality !== undefined)
72
+ payload['formality'] = formality;
73
+ if (gender !== undefined)
74
+ payload['gender'] = gender;
75
+ if (age)
76
+ payload['age'] = age;
77
+ if (project_name)
78
+ payload['project_name'] = project_name;
79
+ const initialResponse = yield pieces_common_1.httpClient.sendRequest({
80
+ method: pieces_common_1.HttpMethod.POST,
81
+ url: `${common_1.API_BASE_URL}/translate`,
82
+ headers: { 'x-api-key': auth.secret_text, 'Content-Type': 'application/json' },
83
+ body: payload,
84
+ });
85
+ const taskId = initialResponse.body.task_id;
86
+ let run_id = null;
87
+ let attempts = 0;
88
+ while (attempts < common_1.MAX_POLLING_ATTEMPTS) {
89
+ const statusResponse = yield pieces_common_1.httpClient.sendRequest({
90
+ method: pieces_common_1.HttpMethod.GET,
91
+ url: `${common_1.API_BASE_URL}/translate/${taskId}`,
92
+ headers: { 'x-api-key': auth.secret_text },
93
+ });
94
+ if (statusResponse.body.status === 'SUCCESS') {
95
+ run_id = (_a = statusResponse.body.run_id) !== null && _a !== void 0 ? _a : null;
96
+ break;
97
+ }
98
+ if (statusResponse.body.status === 'ERROR' || statusResponse.body.status === 'FAILED') {
99
+ throw new Error(`Translation task failed: ${JSON.stringify(statusResponse.body)}`);
100
+ }
101
+ yield new Promise(resolve => setTimeout(resolve, common_1.POLLING_INTERVAL_MS));
102
+ attempts++;
103
+ }
104
+ if (!run_id) {
105
+ throw new Error("Translation task timed out or failed to return a task_id.");
106
+ }
107
+ const resultResponse = yield pieces_common_1.httpClient.sendRequest({
108
+ method: pieces_common_1.HttpMethod.GET,
109
+ url: `${common_1.API_BASE_URL}/translation-result/${run_id}`,
110
+ headers: { 'x-api-key': auth.secret_text },
111
+ });
112
+ return resultResponse.body;
113
+ });
114
+ },
115
+ });
116
+ //# sourceMappingURL=create-translation.js.map