taka-cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -0
- package/dist/api-client.js +100 -0
- package/dist/api-client.js.map +1 -0
- package/dist/cli.js +244 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/login.js +94 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.js +16 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/whoami.js +23 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/config.js +59 -0
- package/dist/config.js.map +1 -0
- package/dist/main.js +55 -0
- package/dist/main.js.map +1 -0
- package/dist/mcp-server.js +18 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/tools/build-email.js +39 -0
- package/dist/tools/build-email.js.map +1 -0
- package/dist/tools/build-flyer.js +24 -0
- package/dist/tools/build-flyer.js.map +1 -0
- package/dist/tools/create-creative.js +64 -0
- package/dist/tools/create-creative.js.map +1 -0
- package/dist/tools/generate-email-image.js +29 -0
- package/dist/tools/generate-email-image.js.map +1 -0
- package/dist/tools/generate-flyer-image.js +18 -0
- package/dist/tools/generate-flyer-image.js.map +1 -0
- package/dist/tools/generate-image.js +30 -0
- package/dist/tools/generate-image.js.map +1 -0
- package/dist/tools/generate-video.js +30 -0
- package/dist/tools/generate-video.js.map +1 -0
- package/dist/tools/get-brand-images.js +20 -0
- package/dist/tools/get-brand-images.js.map +1 -0
- package/dist/tools/index.js +28 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/rename-creative.js +18 -0
- package/dist/tools/rename-creative.js.map +1 -0
- package/dist/tools/update-content.js +18 -0
- package/dist/tools/update-content.js.map +1 -0
- package/dist/tools/web-search.js +18 -0
- package/dist/tools/web-search.js.map +1 -0
- package/package.json +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# @mondaygpt/taka-cli
|
|
2
|
+
|
|
3
|
+
Taka creative tools CLI — generate images, videos, emails, flyers, and more from the command line.
|
|
4
|
+
|
|
5
|
+
## Quickstart
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# 1. Install
|
|
9
|
+
npm install -g @mondaygpt/taka-cli
|
|
10
|
+
|
|
11
|
+
# 2. Authenticate
|
|
12
|
+
taka login
|
|
13
|
+
|
|
14
|
+
# 3. Use
|
|
15
|
+
taka generate-image --prompt "a sunset over the ocean"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Commands
|
|
19
|
+
|
|
20
|
+
### Authentication
|
|
21
|
+
|
|
22
|
+
| Command | Description |
|
|
23
|
+
|---------|-------------|
|
|
24
|
+
| `taka login` | Authenticate via email OTP |
|
|
25
|
+
| `taka logout` | Remove saved credentials |
|
|
26
|
+
| `taka whoami` | Show current authentication status |
|
|
27
|
+
|
|
28
|
+
### Creative Management
|
|
29
|
+
|
|
30
|
+
| Command | Description |
|
|
31
|
+
|---------|-------------|
|
|
32
|
+
| `taka create-creative --name "My Post" --type instagram` | Create a new creative project |
|
|
33
|
+
| `taka create-creative --name "My Post" --type instagram --prompt "..."` | Create and auto-generate an image |
|
|
34
|
+
| `taka list-creatives` | List all your creatives |
|
|
35
|
+
| `taka get-creative --id <id>` | View a specific creative |
|
|
36
|
+
| `taka delete-creative --id <id>` | Delete a creative |
|
|
37
|
+
| `taka rename-creative --creative-id <id> --name "New Name"` | Rename a creative |
|
|
38
|
+
| `taka list-images --creative-id <id>` | List generated images for a creative |
|
|
39
|
+
|
|
40
|
+
### Content Generation
|
|
41
|
+
|
|
42
|
+
| Command | Description |
|
|
43
|
+
|---------|-------------|
|
|
44
|
+
| `taka generate-image --prompt "..." [--aspect-ratio 1:1]` | Generate an image from a text prompt |
|
|
45
|
+
| `taka generate-video --prompt "..." [--duration 7]` | Generate a video from a text prompt |
|
|
46
|
+
| `taka generate-flyer-image --prompt "..."` | Generate a hero image for a flyer |
|
|
47
|
+
| `taka generate-email-image --section-id "..." --prompt "..."` | Generate an image for an email section |
|
|
48
|
+
|
|
49
|
+
### Content Building
|
|
50
|
+
|
|
51
|
+
| Command | Description |
|
|
52
|
+
|---------|-------------|
|
|
53
|
+
| `taka update-content --creative-id "..." --fields '{...}'` | Update creative content fields |
|
|
54
|
+
| `taka build-email --creative-id "..." --subject "..." ...` | Build email structure |
|
|
55
|
+
| `taka build-flyer --creative-id "..." --template-id promo ...` | Build flyer structure |
|
|
56
|
+
|
|
57
|
+
### Discovery
|
|
58
|
+
|
|
59
|
+
| Command | Description |
|
|
60
|
+
|---------|-------------|
|
|
61
|
+
| `taka get-brand-images [--tags products lifestyle]` | Get brand kit images |
|
|
62
|
+
|
|
63
|
+
### Creative Types
|
|
64
|
+
|
|
65
|
+
- `instagram` — Instagram post
|
|
66
|
+
- `email` — Email campaign
|
|
67
|
+
- `flyer` — Printable flyer
|
|
68
|
+
- `blog` — Blog post
|
|
69
|
+
- `logo` — Logo design
|
|
70
|
+
|
|
71
|
+
## Environment Variables
|
|
72
|
+
|
|
73
|
+
| Variable | Description |
|
|
74
|
+
|----------|-------------|
|
|
75
|
+
| `TAKA_SERVER_URL` | Server URL (default: `https://api.mondaygpt.com/v1`) |
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiClient = void 0;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const config_js_1 = require("./config.js");
|
|
6
|
+
class ApiClient {
|
|
7
|
+
config;
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.config = config;
|
|
10
|
+
}
|
|
11
|
+
getAuthHeaders() {
|
|
12
|
+
if (this.config.accessToken) {
|
|
13
|
+
return { Authorization: `Bearer ${this.config.accessToken}` };
|
|
14
|
+
}
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
17
|
+
async refreshAccessToken() {
|
|
18
|
+
if (!this.config.refreshToken)
|
|
19
|
+
return false;
|
|
20
|
+
try {
|
|
21
|
+
const response = await fetch(`${this.config.serverUrl}/authentication/token/refresh`, {
|
|
22
|
+
method: 'POST',
|
|
23
|
+
headers: { 'Content-Type': 'application/json' },
|
|
24
|
+
body: JSON.stringify({
|
|
25
|
+
refreshToken: this.config.refreshToken,
|
|
26
|
+
businessId: this.config.businessId || '-1',
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
29
|
+
if (!response.ok)
|
|
30
|
+
return false;
|
|
31
|
+
const data = (await response.json());
|
|
32
|
+
this.config.accessToken = data.accessToken;
|
|
33
|
+
this.config.refreshToken = data.refreshToken;
|
|
34
|
+
const saved = (0, config_js_1.loadSavedConfig)() || {};
|
|
35
|
+
const updated = {
|
|
36
|
+
...saved,
|
|
37
|
+
accessToken: data.accessToken,
|
|
38
|
+
refreshToken: data.refreshToken,
|
|
39
|
+
};
|
|
40
|
+
(0, node_fs_1.writeFileSync)((0, config_js_1.getConfigPath)(), JSON.stringify(updated, null, 2), { mode: 0o600 });
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async request(method, path, body) {
|
|
48
|
+
const url = `${this.config.serverUrl}/${path}`;
|
|
49
|
+
const doRequest = async () => {
|
|
50
|
+
const headers = {
|
|
51
|
+
Accept: 'application/json',
|
|
52
|
+
...this.getAuthHeaders(),
|
|
53
|
+
};
|
|
54
|
+
if (body) {
|
|
55
|
+
headers['Content-Type'] = 'application/json';
|
|
56
|
+
}
|
|
57
|
+
return fetch(url, {
|
|
58
|
+
method,
|
|
59
|
+
headers,
|
|
60
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
let response = await doRequest();
|
|
64
|
+
if (response.status === 401 && this.config.refreshToken) {
|
|
65
|
+
const refreshed = await this.refreshAccessToken();
|
|
66
|
+
if (refreshed) {
|
|
67
|
+
response = await doRequest();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (!response.ok) {
|
|
71
|
+
if (response.status === 401) {
|
|
72
|
+
throw new Error('Session expired. Run `taka login` to re-authenticate.');
|
|
73
|
+
}
|
|
74
|
+
let errorMessage;
|
|
75
|
+
try {
|
|
76
|
+
const errorBody = await response.json();
|
|
77
|
+
errorMessage =
|
|
78
|
+
errorBody.message ||
|
|
79
|
+
errorBody.error ||
|
|
80
|
+
`HTTP ${response.status}`;
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
errorMessage = `HTTP ${response.status}: ${response.statusText}`;
|
|
84
|
+
}
|
|
85
|
+
throw new Error(errorMessage);
|
|
86
|
+
}
|
|
87
|
+
return (await response.json());
|
|
88
|
+
}
|
|
89
|
+
async post(path, body) {
|
|
90
|
+
return this.request('POST', path, body);
|
|
91
|
+
}
|
|
92
|
+
async get(path) {
|
|
93
|
+
return this.request('GET', path);
|
|
94
|
+
}
|
|
95
|
+
async delete(path) {
|
|
96
|
+
return this.request('DELETE', path);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.ApiClient = ApiClient;
|
|
100
|
+
//# sourceMappingURL=api-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AACvC,2CAA6E;AAE7E,MAAa,SAAS;IACA;IAApB,YAAoB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAElC,cAAc;QACpB,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;YAC5B,OAAO,EAAE,aAAa,EAAE,UAAU,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,CAAA;QAC/D,CAAC;QACD,OAAO,EAAE,CAAA;IACX,CAAC;IAEO,KAAK,CAAC,kBAAkB;QAC9B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY;YAAE,OAAO,KAAK,CAAA;QAE3C,IAAI,CAA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AClE,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAA;QAC/B,CAAC;QAED,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAM,CAAA;IACrC,CAAC;IAED,KAAK,CAAC,IAAI,CAA8B,IAAY,EAAE,IAA8B;QAClF,OAAO,IAAI,CAAC,OAAO,CAAI,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;IAC5C,CAAC;IAED,KAAK,CAAC,GAAG,CAA8B,IAAY;QACjD,OAAO,IAAI,CAAC,OAAO,CAAI,KAAK,EAAE,IAAI,CAAC,CAAA;IACrC,CAAC;IAED,KAAK,CAAC,MAAM,CAA8B,IAAY;QACpD,OAAO,IAAI,CAAC,OAAO,CAAI,QAAQ,EAAE,IAAI,CAAC,CAAA;IACxC,CAAC;CACF;AA5GD,8BA4GC"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCli = createCli;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const api_client_js_1 = require("./api-client.js");
|
|
6
|
+
function parseJson(value, flagName) {
|
|
7
|
+
try {
|
|
8
|
+
return JSON.parse(value);
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
throw new Error(`Invalid JSON for ${flagName}. Make sure the value is valid JSON.\n` +
|
|
12
|
+
` Example: ${flagName} '{"key": "value"}'`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function createCli(config) {
|
|
16
|
+
const apiClient = new api_client_js_1.ApiClient(config);
|
|
17
|
+
const program = new commander_1.Command()
|
|
18
|
+
.name('taka')
|
|
19
|
+
.description('Taka creative tools CLI — generate images, videos, and more.')
|
|
20
|
+
.version('1.0.0');
|
|
21
|
+
program
|
|
22
|
+
.command('create-creative')
|
|
23
|
+
.description('Create a new creative project')
|
|
24
|
+
.requiredOption('--name <name>', 'Name for the creative')
|
|
25
|
+
.requiredOption('--type <type>', 'Type: instagram, email, logo, blog, or flyer')
|
|
26
|
+
.option('--prompt <prompt>', 'Image prompt — auto-generates an image after creation (instagram, logo, flyer)')
|
|
27
|
+
.action(async (opts) => {
|
|
28
|
+
const creativeTypeMap = {
|
|
29
|
+
instagram: 'instagram_post', email: 'email', blog: 'blog_post', logo: 'logo', flyer: 'flyer',
|
|
30
|
+
};
|
|
31
|
+
const defaultContentByType = {
|
|
32
|
+
instagram: { caption: '', hashtags: [], imageUrl: null, imagePrompt: null, format: 'square', altText: '' },
|
|
33
|
+
email: { templateId: 'welcome', subject: '', preheader: '', globalStyle: { backgroundColor: '#f4f4f5', contentWidth: 600, fontFamily: '', fontColor: '#333333' }, sections: [], footer: { businessName: '', showUnsubscribe: true, showViewInBrowser: true } },
|
|
34
|
+
blog: { title: '', body: '', excerpt: '', seoTitle: '', seoDescription: '' },
|
|
35
|
+
logo: { imagePrompt: '', usageGuidelines: '' },
|
|
36
|
+
flyer: { templateId: 'promo', headline: '', subtitle: '', tagline: '' },
|
|
37
|
+
};
|
|
38
|
+
const content = defaultContentByType[opts.type] || {};
|
|
39
|
+
if (opts.prompt) {
|
|
40
|
+
content.imagePrompt = opts.prompt;
|
|
41
|
+
}
|
|
42
|
+
const result = await apiClient.post('creatives', {
|
|
43
|
+
name: opts.name,
|
|
44
|
+
type: opts.type,
|
|
45
|
+
data: {
|
|
46
|
+
creativeType: creativeTypeMap[opts.type] || opts.type,
|
|
47
|
+
status: 'draft',
|
|
48
|
+
content,
|
|
49
|
+
tags: [],
|
|
50
|
+
thumbnailUrl: null,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
console.log(JSON.stringify(result, null, 2));
|
|
54
|
+
const imageGenerationTypes = ['instagram', 'logo', 'flyer'];
|
|
55
|
+
if (opts.prompt && result.creative?.id && imageGenerationTypes.includes(opts.type)) {
|
|
56
|
+
const endpoint = opts.type === 'flyer'
|
|
57
|
+
? 'creative/tools/generate-flyer-image'
|
|
58
|
+
: 'creative/tools/generate-image';
|
|
59
|
+
console.log('\nGenerating image...');
|
|
60
|
+
const imageResult = await apiClient.post(endpoint, {
|
|
61
|
+
prompt: opts.prompt,
|
|
62
|
+
creativeId: result.creative.id,
|
|
63
|
+
});
|
|
64
|
+
console.log(JSON.stringify(imageResult, null, 2));
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
program
|
|
68
|
+
.command('list-creatives')
|
|
69
|
+
.description('List all your creatives')
|
|
70
|
+
.action(async () => {
|
|
71
|
+
const result = await apiClient.get('creatives');
|
|
72
|
+
console.log(JSON.stringify(result, null, 2));
|
|
73
|
+
});
|
|
74
|
+
program
|
|
75
|
+
.command('get-creative')
|
|
76
|
+
.description('Get a creative by ID')
|
|
77
|
+
.requiredOption('--id <id>', 'Creative ID')
|
|
78
|
+
.action(async (opts) => {
|
|
79
|
+
const result = await apiClient.get(`creatives/${opts.id}`);
|
|
80
|
+
console.log(JSON.stringify(result, null, 2));
|
|
81
|
+
});
|
|
82
|
+
program
|
|
83
|
+
.command('delete-creative')
|
|
84
|
+
.description('Delete a creative')
|
|
85
|
+
.requiredOption('--id <id>', 'Creative ID')
|
|
86
|
+
.action(async (opts) => {
|
|
87
|
+
await apiClient.delete(`creatives/${opts.id}`);
|
|
88
|
+
console.log(JSON.stringify({ success: true }, null, 2));
|
|
89
|
+
});
|
|
90
|
+
program
|
|
91
|
+
.command('list-images')
|
|
92
|
+
.description('List all generated images for a creative')
|
|
93
|
+
.requiredOption('--creative-id <id>', 'Creative ID')
|
|
94
|
+
.action(async (opts) => {
|
|
95
|
+
const result = await apiClient.get(`creatives/${opts.creativeId}/images`);
|
|
96
|
+
console.log(JSON.stringify(result, null, 2));
|
|
97
|
+
});
|
|
98
|
+
program
|
|
99
|
+
.command('generate-image')
|
|
100
|
+
.description('Generate an image from a text prompt')
|
|
101
|
+
.requiredOption('--prompt <prompt>', 'Text prompt describing the image')
|
|
102
|
+
.option('--aspect-ratio <ratio>', 'Aspect ratio (1:1, 3:4, 4:3, 9:16, 16:9)')
|
|
103
|
+
.option('--reference-attachment-ids <ids...>', 'Attachment IDs for reference images')
|
|
104
|
+
.option('--reference-mode <mode>', 'Reference mode: inspire or edit')
|
|
105
|
+
.option('--creative-id <id>', 'Creative ID to associate with')
|
|
106
|
+
.action(async (opts) => {
|
|
107
|
+
const result = await apiClient.post('creative/tools/generate-image', {
|
|
108
|
+
prompt: opts.prompt,
|
|
109
|
+
aspectRatio: opts.aspectRatio,
|
|
110
|
+
referenceAttachmentIds: opts.referenceAttachmentIds,
|
|
111
|
+
referenceMode: opts.referenceMode,
|
|
112
|
+
creativeId: opts.creativeId,
|
|
113
|
+
});
|
|
114
|
+
console.log(JSON.stringify(result, null, 2));
|
|
115
|
+
});
|
|
116
|
+
program
|
|
117
|
+
.command('generate-video')
|
|
118
|
+
.description('Generate a video from a text prompt')
|
|
119
|
+
.requiredOption('--prompt <prompt>', 'Text prompt describing the video')
|
|
120
|
+
.option('--duration <duration>', 'Duration in seconds (5, 7, 10)', '7')
|
|
121
|
+
.option('--aspect-ratio <ratio>', 'Aspect ratio (16:9, 9:16, 1:1)')
|
|
122
|
+
.option('--source-image-attachment-id <id>', 'Attachment ID of source image for image-to-video')
|
|
123
|
+
.option('--creative-id <id>', 'Creative ID to associate with')
|
|
124
|
+
.action(async (opts) => {
|
|
125
|
+
const result = await apiClient.post('creative/tools/generate-video', {
|
|
126
|
+
prompt: opts.prompt,
|
|
127
|
+
duration: opts.duration,
|
|
128
|
+
aspectRatio: opts.aspectRatio,
|
|
129
|
+
sourceImageAttachmentId: opts.sourceImageAttachmentId,
|
|
130
|
+
creativeId: opts.creativeId,
|
|
131
|
+
});
|
|
132
|
+
console.log(JSON.stringify(result, null, 2));
|
|
133
|
+
});
|
|
134
|
+
program
|
|
135
|
+
.command('generate-flyer-image')
|
|
136
|
+
.description('Generate a hero image for a flyer')
|
|
137
|
+
.requiredOption('--prompt <prompt>', 'Descriptive prompt for the hero image')
|
|
138
|
+
.option('--creative-id <id>', 'Creative ID to associate with')
|
|
139
|
+
.action(async (opts) => {
|
|
140
|
+
const result = await apiClient.post('creative/tools/generate-flyer-image', {
|
|
141
|
+
prompt: opts.prompt,
|
|
142
|
+
creativeId: opts.creativeId,
|
|
143
|
+
});
|
|
144
|
+
console.log(JSON.stringify(result, null, 2));
|
|
145
|
+
});
|
|
146
|
+
program
|
|
147
|
+
.command('generate-email-image')
|
|
148
|
+
.description('Generate an image for an email section')
|
|
149
|
+
.requiredOption('--section-id <id>', 'Section ID of the email image section')
|
|
150
|
+
.requiredOption('--prompt <prompt>', 'Descriptive prompt for the image')
|
|
151
|
+
.option('--aspect-ratio <ratio>', 'Aspect ratio (16:9, 4:3, 1:1)')
|
|
152
|
+
.option('--cell-index <index>', 'Column cell index (0-based)', parseInt)
|
|
153
|
+
.option('--creative-id <id>', 'Creative ID to associate with')
|
|
154
|
+
.action(async (opts) => {
|
|
155
|
+
const result = await apiClient.post('creative/tools/generate-email-image', {
|
|
156
|
+
sectionId: opts.sectionId,
|
|
157
|
+
prompt: opts.prompt,
|
|
158
|
+
aspectRatio: opts.aspectRatio,
|
|
159
|
+
cellIndex: opts.cellIndex,
|
|
160
|
+
creativeId: opts.creativeId,
|
|
161
|
+
});
|
|
162
|
+
console.log(JSON.stringify(result, null, 2));
|
|
163
|
+
});
|
|
164
|
+
program
|
|
165
|
+
.command('get-brand-images')
|
|
166
|
+
.description('Get brand kit images')
|
|
167
|
+
.option('--tags <tags...>', 'Filter by tags (signature, products, lifestyle, people)')
|
|
168
|
+
.action(async (opts) => {
|
|
169
|
+
const params = opts.tags
|
|
170
|
+
? `?${opts.tags.map((t) => `tags=${encodeURIComponent(t)}`).join('&')}`
|
|
171
|
+
: '';
|
|
172
|
+
const result = await apiClient.get(`creative/tools/brand-images${params}`);
|
|
173
|
+
console.log(JSON.stringify(result, null, 2));
|
|
174
|
+
});
|
|
175
|
+
program
|
|
176
|
+
.command('update-content')
|
|
177
|
+
.description('Update creative content fields')
|
|
178
|
+
.requiredOption('--creative-id <id>', 'Creative ID')
|
|
179
|
+
.requiredOption('--fields <json>', 'JSON object of fields to update')
|
|
180
|
+
.action(async (opts) => {
|
|
181
|
+
const fields = parseJson(opts.fields, '--fields');
|
|
182
|
+
const result = await apiClient.post('creative/tools/update-content', {
|
|
183
|
+
creativeId: opts.creativeId,
|
|
184
|
+
fields,
|
|
185
|
+
});
|
|
186
|
+
console.log(JSON.stringify(result, null, 2));
|
|
187
|
+
});
|
|
188
|
+
program
|
|
189
|
+
.command('build-email')
|
|
190
|
+
.description('Build email structure')
|
|
191
|
+
.requiredOption('--creative-id <id>', 'Creative ID')
|
|
192
|
+
.requiredOption('--subject <subject>', 'Email subject line')
|
|
193
|
+
.requiredOption('--preheader <text>', 'Email preheader / preview text')
|
|
194
|
+
.requiredOption('--global-style <json>', 'Global email styles as JSON (backgroundColor, contentWidth, fontFamily, fontColor)')
|
|
195
|
+
.requiredOption('--sections <json>', 'Ordered array of email sections as JSON')
|
|
196
|
+
.requiredOption('--footer <json>', 'Footer configuration as JSON (businessName, showUnsubscribe, showViewInBrowser)')
|
|
197
|
+
.option('--template-id <id>', 'Template ID (e.g. "promotional", "newsletter", "welcome")')
|
|
198
|
+
.action(async (opts) => {
|
|
199
|
+
const result = await apiClient.post('creative/tools/build-email', {
|
|
200
|
+
creativeId: opts.creativeId,
|
|
201
|
+
templateId: opts.templateId,
|
|
202
|
+
subject: opts.subject,
|
|
203
|
+
preheader: opts.preheader,
|
|
204
|
+
globalStyle: parseJson(opts.globalStyle, '--global-style'),
|
|
205
|
+
sections: parseJson(opts.sections, '--sections'),
|
|
206
|
+
footer: parseJson(opts.footer, '--footer'),
|
|
207
|
+
});
|
|
208
|
+
console.log(JSON.stringify(result, null, 2));
|
|
209
|
+
});
|
|
210
|
+
program
|
|
211
|
+
.command('build-flyer')
|
|
212
|
+
.description('Build flyer structure')
|
|
213
|
+
.requiredOption('--creative-id <id>', 'Creative ID')
|
|
214
|
+
.requiredOption('--template-id <id>', 'Template ID (promo, event, opening, seasonal, minimal, photo-heavy)')
|
|
215
|
+
.requiredOption('--headline <text>', 'Bold headline text')
|
|
216
|
+
.requiredOption('--subtitle <text>', 'Supporting subtitle')
|
|
217
|
+
.option('--tagline <text>', 'Label/CTA text')
|
|
218
|
+
.option('--hero-image-prompt <prompt>', 'Prompt for the hero image')
|
|
219
|
+
.action(async (opts) => {
|
|
220
|
+
const result = await apiClient.post('creative/tools/build-flyer', {
|
|
221
|
+
creativeId: opts.creativeId,
|
|
222
|
+
templateId: opts.templateId,
|
|
223
|
+
headline: opts.headline,
|
|
224
|
+
subtitle: opts.subtitle,
|
|
225
|
+
tagline: opts.tagline,
|
|
226
|
+
heroImagePrompt: opts.heroImagePrompt,
|
|
227
|
+
});
|
|
228
|
+
console.log(JSON.stringify(result, null, 2));
|
|
229
|
+
});
|
|
230
|
+
program
|
|
231
|
+
.command('rename-creative')
|
|
232
|
+
.description('Rename a creative')
|
|
233
|
+
.requiredOption('--creative-id <id>', 'Creative ID')
|
|
234
|
+
.requiredOption('--name <name>', 'New name (max 40 chars)')
|
|
235
|
+
.action(async (opts) => {
|
|
236
|
+
const result = await apiClient.post('creative/tools/rename-creative', {
|
|
237
|
+
creativeId: opts.creativeId,
|
|
238
|
+
name: opts.name,
|
|
239
|
+
});
|
|
240
|
+
console.log(JSON.stringify(result, null, 2));
|
|
241
|
+
});
|
|
242
|
+
return program;
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AAeA,8BAsPC;AArQD,yCAAmC;AACnC,mDAA2C;AAG3C,SAAS,SAAS,CAAI,KAAa,EAAE,QAAgB;IACnD,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAM,CAAA;IAC/B,CAAC;IA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AgB,CAAC;SAC5C,MAAM,CAAC,8BAA8B,EAAE,2BAA2B,CAAC;SACnE,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QACrB,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,4BAA4B,EAAE;YAChE,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,eAAe,EAAE,IAAI,CAAC,eAAe;SACtC,CAAC,CAAA;QACF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;IAC9C,CAAC,CAAC,CAAA;IAEJ,OAAO;SACJ,OAAO,CAAC,iBAAiB,CAAC;SAC1B,WAAW,CAAC,mBAAmB,CAAC;SAChC,cAAc,CAAC,oBAAoB,EAAE,aAAa,CAAC;SACnD,cAAc,CAAC,eAAe,EAAE,yBAAyB,CAAC;SAC1D,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QACrB,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,gCAAgC,EAAE;YACpE,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CAAA;QACF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;IAC9C,CAAC,CAAC,CAAA;IAEJ,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.login = login;
|
|
4
|
+
const promises_1 = require("node:readline/promises");
|
|
5
|
+
const node_process_1 = require("node:process");
|
|
6
|
+
const node_crypto_1 = require("node:crypto");
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const config_js_1 = require("../config.js");
|
|
9
|
+
function prompt(rl, question) {
|
|
10
|
+
return rl.question(question);
|
|
11
|
+
}
|
|
12
|
+
async function fetchJson(url, options, errorPrefix) {
|
|
13
|
+
const res = await fetch(url, options);
|
|
14
|
+
if (!res.ok) {
|
|
15
|
+
const err = await res.json().catch(() => ({}));
|
|
16
|
+
throw new Error(`${errorPrefix}: ${err.message || res.statusText}`);
|
|
17
|
+
}
|
|
18
|
+
return res.json();
|
|
19
|
+
}
|
|
20
|
+
async function login(serverUrl) {
|
|
21
|
+
const rl = (0, promises_1.createInterface)({ input: node_process_1.stdin, output: node_process_1.stdout });
|
|
22
|
+
const deviceId = `taka-cli-${(0, node_crypto_1.randomUUID)()}`;
|
|
23
|
+
try {
|
|
24
|
+
const email = await prompt(rl, 'Email: ');
|
|
25
|
+
if (!email.trim()) {
|
|
26
|
+
console.error('Email is required.');
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
console.log('Sending verification code...');
|
|
30
|
+
await fetchJson(`${serverUrl}/authentication/otp/request`, {
|
|
31
|
+
method: 'POST',
|
|
32
|
+
headers: { 'Content-Type': 'application/json' },
|
|
33
|
+
body: JSON.stringify({ email: email.trim(), deviceId }),
|
|
34
|
+
}, 'Failed to send OTP');
|
|
35
|
+
const code = await prompt(rl, 'Enter verification code: ');
|
|
36
|
+
if (!code.trim()) {
|
|
37
|
+
console.error('Verification code is required.');
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const verifyData = await fetchJson(`${serverUrl}/authentication/otp/verify`, {
|
|
41
|
+
method: 'POST',
|
|
42
|
+
headers: { 'Content-Type': 'application/json' },
|
|
43
|
+
body: JSON.stringify({ email: email.trim(), code: code.trim(), deviceId }),
|
|
44
|
+
}, 'Verification failed');
|
|
45
|
+
if (verifyData.requiresBusinessCreation) {
|
|
46
|
+
console.error('You need to create a business first. Please sign in via the app.');
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
let accessToken = verifyData.tokens.accessToken;
|
|
50
|
+
let refreshToken = verifyData.tokens.refreshToken;
|
|
51
|
+
const businesses = verifyData.businesses || [];
|
|
52
|
+
let businessId = businesses.length === 1 ? businesses[0].businessId : undefined;
|
|
53
|
+
if (businesses.length > 1) {
|
|
54
|
+
console.log('\nAvailable businesses:');
|
|
55
|
+
businesses.forEach((b, i) => console.log(` ${i + 1}. ${b.business?.name || b.businessId}`));
|
|
56
|
+
const choice = await prompt(rl, `Select business (1-${businesses.length}): `);
|
|
57
|
+
const idx = parseInt(choice) - 1;
|
|
58
|
+
if (isNaN(idx) || idx < 0 || idx >= businesses.length) {
|
|
59
|
+
console.error('Invalid selection.');
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const selectData = await fetchJson(`${serverUrl}/authentication/select-business`, {
|
|
63
|
+
method: 'POST',
|
|
64
|
+
headers: {
|
|
65
|
+
'Content-Type': 'application/json',
|
|
66
|
+
Authorization: `Bearer ${accessToken}`,
|
|
67
|
+
},
|
|
68
|
+
body: JSON.stringify({
|
|
69
|
+
businessId: businesses[idx].businessId,
|
|
70
|
+
refreshToken,
|
|
71
|
+
}),
|
|
72
|
+
}, 'Failed to select business');
|
|
73
|
+
accessToken = selectData.accessToken;
|
|
74
|
+
refreshToken = selectData.refreshToken;
|
|
75
|
+
businessId = businesses[idx].businessId;
|
|
76
|
+
}
|
|
77
|
+
const config = {
|
|
78
|
+
accessToken,
|
|
79
|
+
refreshToken,
|
|
80
|
+
businessId,
|
|
81
|
+
serverUrl,
|
|
82
|
+
};
|
|
83
|
+
(0, node_fs_1.mkdirSync)((0, config_js_1.getConfigDir)(), { recursive: true });
|
|
84
|
+
(0, node_fs_1.writeFileSync)((0, config_js_1.getConfigPath)(), JSON.stringify(config, null, 2), { mode: 0o600 });
|
|
85
|
+
console.log(`\nAuthenticated successfully! Config saved to ${(0, config_js_1.getConfigPath)()}`);
|
|
86
|
+
console.log('\nYou can now use taka commands:');
|
|
87
|
+
console.log(' taka generate-image --prompt "a sunset over the ocean"');
|
|
88
|
+
console.log(' taka create-creative --name "My Post" --type instagram');
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
rl.close();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":";;AA4BA,sBA4FC;AAxHD,qDAAwD;AACxD,+CAA4C;AAC5C,6CAAwC;AACxC,qCAAkD;AAClD,4CAA2E;AAE3E,SAAS,MAAM,CAAC,EAAsC,EAAE,QAAgB;IACtE,OAAO,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AAC9B,CAAC;AAED,KAAK,UAAU,SAAS,CAAI,GAAW,EAAE,OAAoB,EAAE,WAAmB;IAChF,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IACrC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAA4B,CAAA;QACzE,MAAM,IAAI,KAAK,CAAC,GAAG,WAAW,KAAM,GAAG,CAAC,OAAkB,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,CAAA;IACjF,CAAC;IACD,OAAO,GAAG,CAAC,IAAI,EAAgB,CAAA;AACjC,CAAC;AAWM,KAAK,UAAU,KAAK,CAAC,SAAiB;IAC3C,MAAM,EAAE,GAAG,IAAA,0BAAe,EAAC,EAAE,KAAK,EAAE,oBAAK,EAAE,MAAM,EAAE,qBAAM,EAAE,CAAC,CAAA;IAC5D,MAAM,QAAQ,GAAG,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AAC,GAAG,CAAC,CAAC,UAAU;oBACtC,YAAY;iBACb,CAAC;aACH,EACD,2BAA2B,CAC5B,CAAA;YACD,WAAW,GAAG,UAAU,CAAC,WAAW,CAAA;YACpC,YAAY,GAAG,UAAU,CAAC,YAAY,CAAA;YACtC,UAAU,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,UAAU,CAAA;QACzC,CAAC;QAGD,MAAM,MAAM,GAAe;YACzB,WAAW;YACX,YAAY;YACZ,UAAU;YACV,SAAS;SACV,CAAA;QAED,IAAA,mBAAS,EAAC,IAAA,wBAAY,GAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QAC9C,IAAA,uBAAa,EAAC,IAAA,yBAAa,GAAE,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;QAEhF,OAAO,CAAC,GAAG,CAAC,iDAAiD,IAAA,yBAAa,GAAE,EAAE,CAAC,CAAA;QAC/E,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAA;QAC/C,OAAO,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAA;QACvE,OAAO,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAA;IACzE,CAAC;YAAS,CAAC;QACT,EAAE,CAAC,KAAK,EAAE,CAAA;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logout = logout;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const config_js_1 = require("../config.js");
|
|
6
|
+
function logout() {
|
|
7
|
+
const configPath = (0, config_js_1.getConfigPath)();
|
|
8
|
+
if ((0, node_fs_1.existsSync)(configPath)) {
|
|
9
|
+
(0, node_fs_1.unlinkSync)(configPath);
|
|
10
|
+
console.log('Logged out. Config removed.');
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
console.log('Not logged in.');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=logout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":";;AAGA,wBAQC;AAXD,qCAAgD;AAChD,4CAA4C;AAE5C,SAAgB,MAAM;IACpB,MAAM,UAAU,GAAG,IAAA,yBAAa,GAAE,CAAA;IAClC,IAAI,IAAA,oBAAU,EAAC,UAAU,CAAC,EAAE,CAAC;QAC3B,IAAA,oBAAU,EAAC,UAAU,CAAC,CAAA;QACtB,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAA;IAC5C,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;IAC/B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.whoami = whoami;
|
|
4
|
+
const config_js_1 = require("../config.js");
|
|
5
|
+
const api_client_js_1 = require("../api-client.js");
|
|
6
|
+
async function whoami() {
|
|
7
|
+
try {
|
|
8
|
+
const config = (0, config_js_1.loadConfig)();
|
|
9
|
+
const apiClient = new api_client_js_1.ApiClient(config);
|
|
10
|
+
const result = await apiClient.get('authentication/me');
|
|
11
|
+
console.log('Authenticated.');
|
|
12
|
+
console.log(`Server: ${config.serverUrl}`);
|
|
13
|
+
console.log(`Auth: JWT`);
|
|
14
|
+
if (result.user) {
|
|
15
|
+
console.log(`User: ${result.user.name || result.user.email}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
console.error(`Not authenticated: ${error instanceof Error ? error.message : String(error)}`);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=whoami.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"names":[],"mappings":";;AAGA,wBAeC;AAlBD,4CAAyC;AACzC,oDAA4C;AAErC,KAAK,UAAU,MAAM;IAC1B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAA,sBAAU,GAAE,CAAA;QAC3B,MAAM,SAAS,GAAG,IAAI,yBAAS,CAAC,MAAM,CAAC,CAAA;QACvC,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,GAAG,CAA4C,mBAAmB,CAAC,CAAA;QAClG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;QAC7B,OAAO,CAAC,GAAG,CAAC,WAAW,MAAM,CAAC,SAAS,EAAE,CAAC,CAAA;QAC1C,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;QACxB,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAChB,OAAO,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAA;QAC/D,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,sBAAsB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAC7F,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_SERVER_URL = void 0;
|
|
4
|
+
exports.getConfigPath = getConfigPath;
|
|
5
|
+
exports.getConfigDir = getConfigDir;
|
|
6
|
+
exports.loadSavedConfig = loadSavedConfig;
|
|
7
|
+
exports.loadConfig = loadConfig;
|
|
8
|
+
const node_fs_1 = require("node:fs");
|
|
9
|
+
const node_path_1 = require("node:path");
|
|
10
|
+
const node_os_1 = require("node:os");
|
|
11
|
+
exports.DEFAULT_SERVER_URL = 'https://api.taka.ai/v1';
|
|
12
|
+
const CONFIG_DIR = (0, node_path_1.join)((0, node_os_1.homedir)(), '.config', 'taka');
|
|
13
|
+
const CONFIG_FILE = (0, node_path_1.join)(CONFIG_DIR, 'config.json');
|
|
14
|
+
function getConfigPath() {
|
|
15
|
+
return CONFIG_FILE;
|
|
16
|
+
}
|
|
17
|
+
function getConfigDir() {
|
|
18
|
+
return CONFIG_DIR;
|
|
19
|
+
}
|
|
20
|
+
function loadSavedConfig() {
|
|
21
|
+
if (!(0, node_fs_1.existsSync)(CONFIG_FILE))
|
|
22
|
+
return null;
|
|
23
|
+
try {
|
|
24
|
+
return JSON.parse((0, node_fs_1.readFileSync)(CONFIG_FILE, 'utf-8'));
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function loadConfig(overrides) {
|
|
31
|
+
const saved = loadSavedConfig();
|
|
32
|
+
const accessToken = saved?.accessToken;
|
|
33
|
+
const refreshToken = saved?.refreshToken;
|
|
34
|
+
const businessId = saved?.businessId;
|
|
35
|
+
if (!accessToken) {
|
|
36
|
+
throw new Error('Not authenticated. Run `taka login` first.');
|
|
37
|
+
}
|
|
38
|
+
const rawUrl = (overrides?.server ||
|
|
39
|
+
process.env.TAKA_SERVER_URL ||
|
|
40
|
+
saved?.serverUrl ||
|
|
41
|
+
exports.DEFAULT_SERVER_URL).replace(/\/$/, '');
|
|
42
|
+
try {
|
|
43
|
+
const parsed = new URL(rawUrl);
|
|
44
|
+
if (!['http:', 'https:'].includes(parsed.protocol)) {
|
|
45
|
+
throw new Error('Only http and https URLs are supported.');
|
|
46
|
+
}
|
|
47
|
+
if (parsed.username || parsed.password) {
|
|
48
|
+
throw new Error('URLs with credentials are not supported.');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
if (err instanceof TypeError) {
|
|
53
|
+
throw new Error(`Invalid server URL: ${rawUrl}`);
|
|
54
|
+
}
|
|
55
|
+
throw err;
|
|
56
|
+
}
|
|
57
|
+
return { accessToken, refreshToken, businessId, serverUrl: rawUrl };
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAgBA,sCAEC;AAED,oCAEC;AAED,0CAOC;AAED,gCAoCC;AArED,qCAAkD;AAClD,yCAAgC;AAChC,qCAAiC;AAEpB,QAAA,kBAAkB,GAAG,wBAAwB,CAAA;AAS1D,MAAM,UAAU,GAAG,IAAA,gBAAI,EAAC,IAAA,iBAAO,GAAE,EAAE,SAAS,EAAE,MAAM,CAAC,CAAA;AACrD,MAAM,WAAW,GAAG,IAAA,gBAAI,EAAC,UAAU,EAAE,aAAa,CAAC,CAAA;AAEnD,SAAgB,aAAa;IAC3B,OAAO,WAAW,CAAA;AACpB,CAAC;AAED,SAAgB,YAAY;IAC1B,OAAO,UAAU,CAAA;AACnB,CAAC;AAED,SAAgB,eAAe;IAC7B,IAAI,CAAC,IAAA,oBAAU,EAAC,WAAW,CAAC;QAAE,OAAO,IAAI,CAAA;IACzC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAA,sBAAY,EAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAA;IACvD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC;AAED,SAAgB,UAAU,CAAC,SAA+B;IACxD,MAAM,KAAK,GAAG,eAAe,EAAE,CAAA;IAE/B,MAAM,WAAW,GAAG,KAAK,EAAE,WAAW,CAAA;IACtC,MAAM,YAAY,GAAG,KAAK,EAAE,YAAY,CAAA;IACxC,MAAM,UAAU,GAAG,KAAK,EAAE,UAAU,CAAA;IAEpC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CACb,4CAA4C,CAC7C,CAAA;IACH,CAAC;IAED,MAAM,MAAM,GAAG,CACb,SAAS,EAAE,MAAM;QACjB,OAAO,CAAC,GAAG,CAAC,eAAe;QAC3B,KAAK,EAAE,SAAS;QAChB,0BAAkB,CACnB,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IAEpB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAA;QAC9B,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnD,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAA;QAC5D,CAAC;QACD,IAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAA;QAC7D,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,SAAS,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,uBAAuB,MAAM,EAAE,CAAC,CAAA;QAClD,CAAC;QACD,MAAM,GAAG,CAAA;IACX,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,CAAA;AACrE,CAAC"}
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const config_js_1 = require("./config.js");
|
|
5
|
+
const args = process.argv.slice(2);
|
|
6
|
+
const isHelpOrVersion = args.includes('--help') || args.includes('-h') || args.includes('--version') || args.includes('-V') || args.length === 0;
|
|
7
|
+
const unauthenticatedCommands = ['login', 'logout', 'whoami'];
|
|
8
|
+
const firstArg = args[0];
|
|
9
|
+
const isUnauthenticatedCommand = firstArg && unauthenticatedCommands.includes(firstArg);
|
|
10
|
+
function addUnauthenticatedCommands(program) {
|
|
11
|
+
program.command('login').description('Authenticate with Taka (OTP flow)');
|
|
12
|
+
program.command('logout').description('Remove saved credentials');
|
|
13
|
+
program.command('whoami').description('Show current authentication status');
|
|
14
|
+
}
|
|
15
|
+
async function main() {
|
|
16
|
+
try {
|
|
17
|
+
if (isUnauthenticatedCommand) {
|
|
18
|
+
const serverUrl = (process.env.TAKA_SERVER_URL || config_js_1.DEFAULT_SERVER_URL).replace(/\/$/, '');
|
|
19
|
+
if (firstArg === 'login') {
|
|
20
|
+
const { login } = await import('./commands/login.js');
|
|
21
|
+
await login(serverUrl);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (firstArg === 'logout') {
|
|
25
|
+
const { logout } = await import('./commands/logout.js');
|
|
26
|
+
logout();
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (firstArg === 'whoami') {
|
|
30
|
+
const { whoami } = await import('./commands/whoami.js');
|
|
31
|
+
await whoami();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (isHelpOrVersion) {
|
|
36
|
+
const { createCli } = await import('./cli.js');
|
|
37
|
+
const dummyConfig = { serverUrl: '' };
|
|
38
|
+
const program = createCli(dummyConfig);
|
|
39
|
+
addUnauthenticatedCommands(program);
|
|
40
|
+
await program.parseAsync(process.argv);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const config = (0, config_js_1.loadConfig)();
|
|
44
|
+
const { createCli } = await import('./cli.js');
|
|
45
|
+
const program = createCli(config);
|
|
46
|
+
addUnauthenticatedCommands(program);
|
|
47
|
+
await program.parseAsync(process.argv);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
main();
|
|
55
|
+
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;AACA,2CAA4D;AAE5D,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAClC,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,CAAA;AAGhJ,MAAM,uBAAuB,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;AAC7D,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;AACxB,MAAM,wBAAwB,GAAG,QAAQ,IAAI,uBAAuB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AAEvF,SAAS,0BAA0B,CAAC,OAAoC;IACtE,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,mCAAmC,CAAC,CAAA;IACzE,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,0BAA0B,CAAC,CAAA;IACjE,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,oCAAoC,CAAC,CAAA;AAC7E,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,IAAI,CAAC;QAEH,IAAI,wBAAwB,E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AAC,CAAA;QACnC,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACxC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,UAAU,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QACjF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.startMcpServer = startMcpServer;
|
|
4
|
+
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
5
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
6
|
+
const api_client_js_1 = require("./api-client.js");
|
|
7
|
+
const index_js_1 = require("./tools/index.js");
|
|
8
|
+
async function startMcpServer(config) {
|
|
9
|
+
const server = new mcp_js_1.McpServer({
|
|
10
|
+
name: 'taka-cli',
|
|
11
|
+
version: '1.0.0',
|
|
12
|
+
});
|
|
13
|
+
const apiClient = new api_client_js_1.ApiClient(config);
|
|
14
|
+
(0, index_js_1.registerAllTools)(server, apiClient);
|
|
15
|
+
const transport = new stdio_js_1.StdioServerTransport();
|
|
16
|
+
await server.connect(transport);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=mcp-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":";;AAMA,wCAWC;AAjBD,oEAAmE;AACnE,wEAAgF;AAChF,mDAA2C;AAE3C,+CAAmD;AAE5C,KAAK,UAAU,cAAc,CAAC,MAAkB;IACrD,MAAM,MAAM,GAAG,IAAI,kBAAS,CAAC;QAC3B,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,OAAO;KACjB,CAAC,CAAA;IAEF,MAAM,SAAS,GAAG,IAAI,yBAAS,CAAC,MAAM,CAAC,CAAA;IACvC,IAAA,2BAAgB,EAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAEnC,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAA;IAC5C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;AACjC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerBuildEmail = registerBuildEmail;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
function registerBuildEmail(server, apiClient) {
|
|
6
|
+
server.registerTool('build-email', {
|
|
7
|
+
title: 'Build Email',
|
|
8
|
+
description: 'Build the full email structure from scratch with template, sections, and footer.',
|
|
9
|
+
inputSchema: {
|
|
10
|
+
creativeId: zod_1.z.string().describe('The creative ID.'),
|
|
11
|
+
templateId: zod_1.z
|
|
12
|
+
.string()
|
|
13
|
+
.optional()
|
|
14
|
+
.describe('Template ID (e.g. "promotional", "newsletter", "welcome").'),
|
|
15
|
+
subject: zod_1.z.string().describe('The email subject line.'),
|
|
16
|
+
preheader: zod_1.z.string().describe('The email preheader / preview text.'),
|
|
17
|
+
globalStyle: zod_1.z.object({
|
|
18
|
+
backgroundColor: zod_1.z.string().describe('Page background color.'),
|
|
19
|
+
contentWidth: zod_1.z.number().describe('Content width in px.'),
|
|
20
|
+
fontFamily: zod_1.z.string().describe('CSS font-family.'),
|
|
21
|
+
fontColor: zod_1.z.string().describe('Default text color.'),
|
|
22
|
+
}),
|
|
23
|
+
sections: zod_1.z.array(zod_1.z.object({
|
|
24
|
+
type: zod_1.z.string().describe('Section type (header, hero, text, image, cta, divider, columns).'),
|
|
25
|
+
content: zod_1.z.record(zod_1.z.unknown()).describe('Section content.'),
|
|
26
|
+
style: zod_1.z.record(zod_1.z.unknown()).optional().describe('Section style.'),
|
|
27
|
+
})),
|
|
28
|
+
footer: zod_1.z.object({
|
|
29
|
+
businessName: zod_1.z.string(),
|
|
30
|
+
showUnsubscribe: zod_1.z.boolean(),
|
|
31
|
+
showViewInBrowser: zod_1.z.boolean(),
|
|
32
|
+
}),
|
|
33
|
+
},
|
|
34
|
+
}, async (input) => {
|
|
35
|
+
const result = await apiClient.post('creative/tools/build-email', input);
|
|
36
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=build-email.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-email.js","sourceRoot":"","sources":["../../src/tools/build-email.ts"],"names":[],"mappings":";;AAIA,gDAuCC;AA1CD,6BAAuB;AAGvB,SAAgB,kBAAkB,CAAC,MAAiB,EAAE,SAAoB;IACxE,MAAM,CAAC,YAAY,CACjB,aAAa,EACb;QACE,KAAK,EAAE,aAAa;QACpB,WAAW,EAAE,kFAAkF;QAC/F,WAAW,EAAE;YACX,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;YACnD,UAAU,EAAE,OAAC;iBACV,MAAM,EAAE;iBACR,QAAQ,EAAE;iBACV,QAAQ,CAAC,4DAA4D,CAAC;YACzE,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,yBAAyB,CAAC;YACvD,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC;YACrE,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC;gBACpB,eAAe,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wBAAwB,CAAC;gBAC9D,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sBAAsB,CAAC;gBACzD,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;gBACnD,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC;aACtD,CAAC;YACF,QAAQ,EAAE,OAAC,CAAC,KAAK,CACf,OAAC,CAAC,MAAM,CAAC;gBACP,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kEAAkE,CAAC;gBAC7F,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC;gBAC3D,KAAK,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC;aACnE,CAAC,CACH;YACD,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC;gBACf,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE;gBACxB,eAAe,EAAE,OAAC,CAAC,OAAO,EAAE;gBAC5B,iBAAiB,EAAE,OAAC,CAAC,OAAO,EAAE;aAC/B,CAAC;SACH;KACF,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;QACd,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,4BAA4B,EAAE,KAAgC,CAAC,CAAA;QACnG,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAA;IAC/E,CAAC,CACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerBuildFlyer = registerBuildFlyer;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
function registerBuildFlyer(server, apiClient) {
|
|
6
|
+
server.registerTool('build-flyer', {
|
|
7
|
+
title: 'Build Flyer',
|
|
8
|
+
description: 'Build a flyer from scratch with a template and text fields.',
|
|
9
|
+
inputSchema: {
|
|
10
|
+
creativeId: zod_1.z.string().describe('The creative ID.'),
|
|
11
|
+
templateId: zod_1.z
|
|
12
|
+
.enum(['promo', 'event', 'opening', 'seasonal', 'minimal', 'photo-heavy'])
|
|
13
|
+
.describe('Template ID.'),
|
|
14
|
+
headline: zod_1.z.string().describe('Bold headline text (2-6 words).'),
|
|
15
|
+
subtitle: zod_1.z.string().describe('Supporting subtitle.'),
|
|
16
|
+
tagline: zod_1.z.string().optional().describe('Label/CTA text.'),
|
|
17
|
+
heroImagePrompt: zod_1.z.string().optional().describe('Prompt for the hero image.'),
|
|
18
|
+
},
|
|
19
|
+
}, async (input) => {
|
|
20
|
+
const result = await apiClient.post('creative/tools/build-flyer', input);
|
|
21
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=build-flyer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-flyer.js","sourceRoot":"","sources":["../../src/tools/build-flyer.ts"],"names":[],"mappings":";;AAIA,gDAsBC;AAzBD,6BAAuB;AAGvB,SAAgB,kBAAkB,CAAC,MAAiB,EAAE,SAAoB;IACxE,MAAM,CAAC,YAAY,CACjB,aAAa,EACb;QACE,KAAK,EAAE,aAAa;QACpB,WAAW,EAAE,6DAA6D;QAC1E,WAAW,EAAE;YACX,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;YACnD,UAAU,EAAE,OAAC;iBACV,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;iBACzE,QAAQ,CAAC,cAAc,CAAC;YAC3B,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;YAChE,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sBAAsB,CAAC;YACrD,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,iBAAiB,CAAC;YAC1D,eAAe,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC;SAC9E;KACF,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;QACd,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,4BAA4B,EAAE,KAAgC,CAAC,CAAA;QACnG,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAA;IAC/E,CAAC,CACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerCreateCreative = registerCreateCreative;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const creativeTypeMap = {
|
|
6
|
+
instagram: 'instagram_post',
|
|
7
|
+
email: 'email',
|
|
8
|
+
blog: 'blog_post',
|
|
9
|
+
logo: 'logo',
|
|
10
|
+
flyer: 'flyer',
|
|
11
|
+
};
|
|
12
|
+
const defaultContentByType = {
|
|
13
|
+
instagram: {
|
|
14
|
+
caption: '',
|
|
15
|
+
hashtags: [],
|
|
16
|
+
imageUrl: null,
|
|
17
|
+
imagePrompt: null,
|
|
18
|
+
format: 'square',
|
|
19
|
+
altText: '',
|
|
20
|
+
},
|
|
21
|
+
email: {
|
|
22
|
+
templateId: 'welcome',
|
|
23
|
+
subject: '',
|
|
24
|
+
preheader: '',
|
|
25
|
+
globalStyle: {
|
|
26
|
+
backgroundColor: '#f4f4f5',
|
|
27
|
+
contentWidth: 600,
|
|
28
|
+
fontFamily: '',
|
|
29
|
+
fontColor: '#333333',
|
|
30
|
+
},
|
|
31
|
+
sections: [],
|
|
32
|
+
footer: { businessName: '', showUnsubscribe: true, showViewInBrowser: true },
|
|
33
|
+
},
|
|
34
|
+
blog: { title: '', body: '', excerpt: '', seoTitle: '', seoDescription: '' },
|
|
35
|
+
logo: { imagePrompt: '', usageGuidelines: '' },
|
|
36
|
+
flyer: { templateId: 'promo', headline: '', subtitle: '', tagline: '' },
|
|
37
|
+
};
|
|
38
|
+
function registerCreateCreative(server, apiClient) {
|
|
39
|
+
server.registerTool('create-creative', {
|
|
40
|
+
title: 'Create Creative',
|
|
41
|
+
description: 'Create a new creative project. Returns the creative ID to use with other tools (generate-image, build-email, etc.).',
|
|
42
|
+
inputSchema: {
|
|
43
|
+
name: zod_1.z.string().min(1).max(200).describe('Name for the creative.'),
|
|
44
|
+
type: zod_1.z
|
|
45
|
+
.enum(['instagram', 'email', 'logo', 'blog', 'flyer'])
|
|
46
|
+
.describe('Type of creative to create.'),
|
|
47
|
+
},
|
|
48
|
+
}, async (input) => {
|
|
49
|
+
const { name, type } = input;
|
|
50
|
+
const result = await apiClient.post('creatives', {
|
|
51
|
+
name,
|
|
52
|
+
type,
|
|
53
|
+
data: {
|
|
54
|
+
creativeType: creativeTypeMap[type] || type,
|
|
55
|
+
status: 'draft',
|
|
56
|
+
content: defaultContentByType[type] || {},
|
|
57
|
+
tags: [],
|
|
58
|
+
thumbnailUrl: null,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=create-creative.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-creative.js","sourceRoot":"","sources":["../../src/tools/create-creative.ts"],"names":[],"mappings":";;A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;YACX,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,wBAAwB,CAAC;YACnE,IAAI,EAAE,OAAC;iBACJ,IAAI,CAAC,CAAC,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;iBACrD,QAAQ,CAAC,6BAA6B,CAAC;SAC3C;KACF,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;QACd,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,KAAuC,CAAA;QAC9D,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,WAAW,EAAE;YAC/C,IAAI;YACJ,IAAI;YACJ,IAAI,EAAE;gBACJ,YAAY,EAAE,eAAe,CAAC,IAAI,CAAC,IAAI,IAAI;gBAC3C,MAAM,EAAE,OAAO;gBACf,OAAO,EAAE,oBAAoB,CAAC,IAAI,CAAC,IAAI,EAAE;gBACzC,IAAI,EAAE,EAAE;gBACR,YAAY,EAAE,IAAI;aACnB;SACF,CAAC,CAAA;QACF,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAA;IAC/E,CAAC,CACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerGenerateEmailImage = registerGenerateEmailImage;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
function registerGenerateEmailImage(server, apiClient) {
|
|
6
|
+
server.registerTool('generate-email-image', {
|
|
7
|
+
title: 'Generate Email Image',
|
|
8
|
+
description: 'Generate an AI image for a specific email section.',
|
|
9
|
+
inputSchema: {
|
|
10
|
+
sectionId: zod_1.z.string().describe('The ID of the email image section to populate.'),
|
|
11
|
+
prompt: zod_1.z.string().min(1).describe('Descriptive prompt for the image.'),
|
|
12
|
+
aspectRatio: zod_1.z
|
|
13
|
+
.enum(['16:9', '4:3', '1:1'])
|
|
14
|
+
.optional()
|
|
15
|
+
.describe('Aspect ratio. Defaults to 16:9.'),
|
|
16
|
+
cellIndex: zod_1.z
|
|
17
|
+
.number()
|
|
18
|
+
.int()
|
|
19
|
+
.min(0)
|
|
20
|
+
.optional()
|
|
21
|
+
.describe('For columns sections: 0-based index of the image cell.'),
|
|
22
|
+
creativeId: zod_1.z.string().optional().describe('Creative ID to associate with this generation.'),
|
|
23
|
+
},
|
|
24
|
+
}, async (input) => {
|
|
25
|
+
const result = await apiClient.post('creative/tools/generate-email-image', input);
|
|
26
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=generate-email-image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-email-image.js","sourceRoot":"","sources":["../../src/tools/generate-email-image.ts"],"names":[],"mappings":";;AAIA,gEA2BC;AA9BD,6BAAuB;AAGvB,SAAgB,0BAA0B,CAAC,MAAiB,EAAE,SAAoB;IAChF,MAAM,CAAC,YAAY,CACjB,sBAAsB,EACtB;QACE,KAAK,EAAE,sBAAsB;QAC7B,WAAW,EAAE,oDAAoD;QACjE,WAAW,EAAE;YACX,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gDAAgD,CAAC;YAChF,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,mCAAmC,CAAC;YACvE,WAAW,EAAE,OAAC;iBACX,IAAI,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;iBAC5B,QAAQ,EAAE;iBACV,QAAQ,CAAC,iCAAiC,CAAC;YAC9C,SAAS,EAAE,OAAC;iBACT,MAAM,EAAE;iBACR,GAAG,EAAE;iBACL,GAAG,CAAC,CAAC,CAAC;iBACN,QAAQ,EAAE;iBACV,QAAQ,CAAC,wDAAwD,CAAC;YACrE,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gDAAgD,CAAC;SAC7F;KACF,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;QACd,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,qCAAqC,EAAE,KAAgC,CAAC,CAAA;QAC5G,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAA;IAC/E,CAAC,CACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerGenerateFlyerImage = registerGenerateFlyerImage;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
function registerGenerateFlyerImage(server, apiClient) {
|
|
6
|
+
server.registerTool('generate-flyer-image', {
|
|
7
|
+
title: 'Generate Flyer Image',
|
|
8
|
+
description: 'Generate an AI hero image for a flyer. Always uses 3:4 portrait aspect ratio.',
|
|
9
|
+
inputSchema: {
|
|
10
|
+
prompt: zod_1.z.string().min(1).describe('Descriptive prompt for the hero image.'),
|
|
11
|
+
creativeId: zod_1.z.string().optional().describe('Creative ID to associate with this generation.'),
|
|
12
|
+
},
|
|
13
|
+
}, async (input) => {
|
|
14
|
+
const result = await apiClient.post('creative/tools/generate-flyer-image', input);
|
|
15
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=generate-flyer-image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-flyer-image.js","sourceRoot":"","sources":["../../src/tools/generate-flyer-image.ts"],"names":[],"mappings":";;AAIA,gEAgBC;AAnBD,6BAAuB;AAGvB,SAAgB,0BAA0B,CAAC,MAAiB,EAAE,SAAoB;IAChF,MAAM,CAAC,YAAY,CACjB,sBAAsB,EACtB;QACE,KAAK,EAAE,sBAAsB;QAC7B,WAAW,EAAE,+EAA+E;QAC5F,WAAW,EAAE;YACX,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,wCAAwC,CAAC;YAC5E,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gDAAgD,CAAC;SAC7F;KACF,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;QACd,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,qCAAqC,EAAE,KAAgC,CAAC,CAAA;QAC5G,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAA;IAC/E,CAAC,CACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerGenerateImage = registerGenerateImage;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
function registerGenerateImage(server, apiClient) {
|
|
6
|
+
server.registerTool('generate-image', {
|
|
7
|
+
title: 'Generate Image',
|
|
8
|
+
description: 'Generate an image from a text prompt using Gemini. Returns an attachment ID and public URL.',
|
|
9
|
+
inputSchema: {
|
|
10
|
+
prompt: zod_1.z.string().min(1).describe('Text prompt describing the image to generate.'),
|
|
11
|
+
referenceAttachmentIds: zod_1.z
|
|
12
|
+
.array(zod_1.z.string())
|
|
13
|
+
.optional()
|
|
14
|
+
.describe('Optional attachment IDs for image-to-image generation.'),
|
|
15
|
+
referenceMode: zod_1.z
|
|
16
|
+
.enum(['inspire', 'edit'])
|
|
17
|
+
.optional()
|
|
18
|
+
.describe('How to use reference images. "inspire" = loose inspiration, "edit" = modify in-place.'),
|
|
19
|
+
aspectRatio: zod_1.z
|
|
20
|
+
.enum(['1:1', '3:4', '4:3', '9:16', '16:9'])
|
|
21
|
+
.optional()
|
|
22
|
+
.describe('Aspect ratio. Use 4:3 for landscape, 3:4 for portrait, 1:1 for square.'),
|
|
23
|
+
creativeId: zod_1.z.string().optional().describe('Creative ID to associate with this generation.'),
|
|
24
|
+
},
|
|
25
|
+
}, async (input) => {
|
|
26
|
+
const result = await apiClient.post('creative/tools/generate-image', input);
|
|
27
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=generate-image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-image.js","sourceRoot":"","sources":["../../src/tools/generate-image.ts"],"names":[],"mappings":";;AAIA,sDA6BC;AAhCD,6BAAuB;AAGvB,SAAgB,qBAAqB,CAAC,MAAiB,EAAE,SAAoB;IAC3E,MAAM,CAAC,YAAY,CACjB,gBAAgB,EAChB;QACE,KAAK,EAAE,gBAAgB;QACvB,WAAW,EACT,6FAA6F;QAC/F,WAAW,EAAE;YACX,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,+CAA+C,CAAC;YACnF,sBAAsB,EAAE,OAAC;iBACtB,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;iBACjB,QAAQ,EAAE;iBACV,QAAQ,CAAC,wDAAwD,CAAC;YACrE,aAAa,EAAE,OAAC;iBACb,IAAI,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;iBACzB,QAAQ,EAAE;iBACV,QAAQ,CAAC,uFAAuF,CAAC;YACpG,WAAW,EAAE,OAAC;iBACX,IAAI,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;iBAC3C,QAAQ,EAAE;iBACV,QAAQ,CAAC,wEAAwE,CAAC;YACrF,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gDAAgD,CAAC;SAC7F;KACF,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;QACd,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,+BAA+B,EAAE,KAAgC,CAAC,CAAA;QACtG,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAA;IAC/E,CAAC,CACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerGenerateVideo = registerGenerateVideo;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
function registerGenerateVideo(server, apiClient) {
|
|
6
|
+
server.registerTool('generate-video', {
|
|
7
|
+
title: 'Generate Video',
|
|
8
|
+
description: 'Generate a short video from a text prompt, optionally animating a source image. Returns an attachment ID and public URL. This may take 1-3 minutes.',
|
|
9
|
+
inputSchema: {
|
|
10
|
+
prompt: zod_1.z.string().min(1).describe('Text prompt describing the video to generate.'),
|
|
11
|
+
sourceImageAttachmentId: zod_1.z
|
|
12
|
+
.string()
|
|
13
|
+
.optional()
|
|
14
|
+
.describe('Optional attachment ID of an image to animate (image-to-video).'),
|
|
15
|
+
duration: zod_1.z
|
|
16
|
+
.enum(['5', '7', '10'])
|
|
17
|
+
.optional()
|
|
18
|
+
.describe('Video duration in seconds. Defaults to 7.'),
|
|
19
|
+
aspectRatio: zod_1.z
|
|
20
|
+
.enum(['16:9', '9:16', '1:1'])
|
|
21
|
+
.optional()
|
|
22
|
+
.describe('Aspect ratio. 9:16 for reels/stories, 16:9 for landscape, 1:1 for square.'),
|
|
23
|
+
creativeId: zod_1.z.string().optional().describe('Creative ID to associate with this generation.'),
|
|
24
|
+
},
|
|
25
|
+
}, async (input) => {
|
|
26
|
+
const result = await apiClient.post('creative/tools/generate-video', input);
|
|
27
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=generate-video.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-video.js","sourceRoot":"","sources":["../../src/tools/generate-video.ts"],"names":[],"mappings":";;AAIA,sDA6BC;AAhCD,6BAAuB;AAGvB,SAAgB,qBAAqB,CAAC,MAAiB,EAAE,SAAoB;IAC3E,MAAM,CAAC,YAAY,CACjB,gBAAgB,EAChB;QACE,KAAK,EAAE,gBAAgB;QACvB,WAAW,EACT,qJAAqJ;QACvJ,WAAW,EAAE;YACX,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,+CAA+C,CAAC;YACnF,uBAAuB,EAAE,OAAC;iBACvB,MAAM,EAAE;iBACR,QAAQ,EAAE;iBACV,QAAQ,CAAC,iEAAiE,CAAC;YAC9E,QAAQ,EAAE,OAAC;iBACR,IAAI,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;iBACtB,QAAQ,EAAE;iBACV,QAAQ,CAAC,2CAA2C,CAAC;YACxD,WAAW,EAAE,OAAC;iBACX,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;iBAC7B,QAAQ,EAAE;iBACV,QAAQ,CAAC,2EAA2E,CAAC;YACxF,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gDAAgD,CAAC;SAC7F;KACF,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;QACd,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,+BAA+B,EAAE,KAAgC,CAAC,CAAA;QACtG,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAA;IAC/E,CAAC,CACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerGetBrandImages = registerGetBrandImages;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
function registerGetBrandImages(server, apiClient) {
|
|
6
|
+
server.registerTool('get-brand-images', {
|
|
7
|
+
title: 'Get Brand Images',
|
|
8
|
+
description: "Retrieve the user's brand images from their brand kit. Returns attachment IDs and URLs.",
|
|
9
|
+
inputSchema: {
|
|
10
|
+
tags: zod_1.z
|
|
11
|
+
.array(zod_1.z.enum(['signature', 'products', 'lifestyle', 'people']))
|
|
12
|
+
.optional()
|
|
13
|
+
.describe('Filter images by tag(s). Omit to get all brand images.'),
|
|
14
|
+
},
|
|
15
|
+
}, async (input) => {
|
|
16
|
+
const result = await apiClient.post('creative/tools/get-brand-images', input);
|
|
17
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=get-brand-images.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-brand-images.js","sourceRoot":"","sources":["../../src/tools/get-brand-images.ts"],"names":[],"mappings":";;AAIA,wDAmBC;AAtBD,6BAAuB;AAGvB,SAAgB,sBAAsB,CAAC,MAAiB,EAAE,SAAoB;IAC5E,MAAM,CAAC,YAAY,CACjB,kBAAkB,EAClB;QACE,KAAK,EAAE,kBAAkB;QACzB,WAAW,EACT,yFAAyF;QAC3F,WAAW,EAAE;YACX,IAAI,EAAE,OAAC;iBACJ,KAAK,CAAC,OAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;iBAC/D,QAAQ,EAAE;iBACV,QAAQ,CAAC,wDAAwD,CAAC;SACtE;KACF,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;QACd,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,iCAAiC,EAAE,KAAgC,CAAC,CAAA;QACxG,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAA;IAC/E,CAAC,CACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerAllTools = registerAllTools;
|
|
4
|
+
const create_creative_js_1 = require("./create-creative.js");
|
|
5
|
+
const generate_image_js_1 = require("./generate-image.js");
|
|
6
|
+
const generate_video_js_1 = require("./generate-video.js");
|
|
7
|
+
const generate_flyer_image_js_1 = require("./generate-flyer-image.js");
|
|
8
|
+
const generate_email_image_js_1 = require("./generate-email-image.js");
|
|
9
|
+
const get_brand_images_js_1 = require("./get-brand-images.js");
|
|
10
|
+
const web_search_js_1 = require("./web-search.js");
|
|
11
|
+
const update_content_js_1 = require("./update-content.js");
|
|
12
|
+
const build_email_js_1 = require("./build-email.js");
|
|
13
|
+
const build_flyer_js_1 = require("./build-flyer.js");
|
|
14
|
+
const rename_creative_js_1 = require("./rename-creative.js");
|
|
15
|
+
function registerAllTools(server, apiClient) {
|
|
16
|
+
(0, create_creative_js_1.registerCreateCreative)(server, apiClient);
|
|
17
|
+
(0, generate_image_js_1.registerGenerateImage)(server, apiClient);
|
|
18
|
+
(0, generate_video_js_1.registerGenerateVideo)(server, apiClient);
|
|
19
|
+
(0, generate_flyer_image_js_1.registerGenerateFlyerImage)(server, apiClient);
|
|
20
|
+
(0, generate_email_image_js_1.registerGenerateEmailImage)(server, apiClient);
|
|
21
|
+
(0, get_brand_images_js_1.registerGetBrandImages)(server, apiClient);
|
|
22
|
+
(0, web_search_js_1.registerWebSearch)(server, apiClient);
|
|
23
|
+
(0, update_content_js_1.registerUpdateContent)(server, apiClient);
|
|
24
|
+
(0, build_email_js_1.registerBuildEmail)(server, apiClient);
|
|
25
|
+
(0, build_flyer_js_1.registerBuildFlyer)(server, apiClient);
|
|
26
|
+
(0, rename_creative_js_1.registerRenameCreative)(server, apiClient);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":";;AAcA,4CAYC;AAxBD,6DAA6D;AAC7D,2DAA2D;AAC3D,2DAA2D;AAC3D,uEAAsE;AACtE,uEAAsE;AACtE,+DAA8D;AAC9D,mDAAmD;AACnD,2DAA2D;AAC3D,qDAAqD;AACrD,qDAAqD;AACrD,6DAA6D;AAE7D,SAAgB,gBAAgB,CAAC,MAAiB,EAAE,SAAoB;IACtE,IAAA,2CAAsB,EAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IACzC,IAAA,yCAAqB,EAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IACxC,IAAA,yCAAqB,EAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IACxC,IAAA,oDAA0B,EAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAC7C,IAAA,oDAA0B,EAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAC7C,IAAA,4CAAsB,EAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IACzC,IAAA,iCAAiB,EAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IACpC,IAAA,yCAAqB,EAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IACxC,IAAA,mCAAkB,EAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IACrC,IAAA,mCAAkB,EAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IACrC,IAAA,2CAAsB,EAAC,MAAM,EAAE,SAAS,CAAC,CAAA;AAC3C,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerRenameCreative = registerRenameCreative;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
function registerRenameCreative(server, apiClient) {
|
|
6
|
+
server.registerTool('rename-creative', {
|
|
7
|
+
title: 'Rename Creative',
|
|
8
|
+
description: 'Set a short, descriptive title for a creative (max 40 characters).',
|
|
9
|
+
inputSchema: {
|
|
10
|
+
creativeId: zod_1.z.string().describe('The creative ID to rename.'),
|
|
11
|
+
name: zod_1.z.string().min(1).max(40).describe('New name for the creative.'),
|
|
12
|
+
},
|
|
13
|
+
}, async (input) => {
|
|
14
|
+
const result = await apiClient.post('creative/tools/rename-creative', input);
|
|
15
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=rename-creative.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-creative.js","sourceRoot":"","sources":["../../src/tools/rename-creative.ts"],"names":[],"mappings":";;AAIA,wDAgBC;AAnBD,6BAAuB;AAGvB,SAAgB,sBAAsB,CAAC,MAAiB,EAAE,SAAoB;IAC5E,MAAM,CAAC,YAAY,CACjB,iBAAiB,EACjB;QACE,KAAK,EAAE,iBAAiB;QACxB,WAAW,EAAE,oEAAoE;QACjF,WAAW,EAAE;YACX,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC;YAC7D,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,4BAA4B,CAAC;SACvE;KACF,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;QACd,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,gCAAgC,EAAE,KAAgC,CAAC,CAAA;QACvG,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAA;IAC/E,CAAC,CACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerUpdateContent = registerUpdateContent;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
function registerUpdateContent(server, apiClient) {
|
|
6
|
+
server.registerTool('update-content', {
|
|
7
|
+
title: 'Update Content',
|
|
8
|
+
description: 'Update creative content fields (caption, hashtags, body, subject, etc.).',
|
|
9
|
+
inputSchema: {
|
|
10
|
+
creativeId: zod_1.z.string().describe('The creative ID to update.'),
|
|
11
|
+
fields: zod_1.z.record(zod_1.z.unknown()).describe('Fields to update as key-value pairs.'),
|
|
12
|
+
},
|
|
13
|
+
}, async (input) => {
|
|
14
|
+
const result = await apiClient.post('creative/tools/update-content', input);
|
|
15
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=update-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-content.js","sourceRoot":"","sources":["../../src/tools/update-content.ts"],"names":[],"mappings":";;AAIA,sDAgBC;AAnBD,6BAAuB;AAGvB,SAAgB,qBAAqB,CAAC,MAAiB,EAAE,SAAoB;IAC3E,MAAM,CAAC,YAAY,CACjB,gBAAgB,EAChB;QACE,KAAK,EAAE,gBAAgB;QACvB,WAAW,EAAE,0EAA0E;QACvF,WAAW,EAAE;YACX,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC;YAC7D,MAAM,EAAE,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,sCAAsC,CAAC;SAC/E;KACF,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;QACd,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,+BAA+B,EAAE,KAAgC,CAAC,CAAA;QACtG,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAA;IAC/E,CAAC,CACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerWebSearch = registerWebSearch;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
function registerWebSearch(server, apiClient) {
|
|
6
|
+
server.registerTool('web-search', {
|
|
7
|
+
title: 'Web Search',
|
|
8
|
+
description: 'Search the web for real-time information. Returns relevant sources and snippets.',
|
|
9
|
+
inputSchema: {
|
|
10
|
+
query: zod_1.z.string().min(1).describe('The search query.'),
|
|
11
|
+
maxResults: zod_1.z.number().int().min(1).max(10).optional().describe('Max results (default 5).'),
|
|
12
|
+
},
|
|
13
|
+
}, async (input) => {
|
|
14
|
+
const result = await apiClient.post('creative/tools/web-search', input);
|
|
15
|
+
return { content: [{ type: 'text', text: JSON.stringify(result) }] };
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=web-search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-search.js","sourceRoot":"","sources":["../../src/tools/web-search.ts"],"names":[],"mappings":";;AAIA,8CAgBC;AAnBD,6BAAuB;AAGvB,SAAgB,iBAAiB,CAAC,MAAiB,EAAE,SAAoB;IACvE,MAAM,CAAC,YAAY,CACjB,YAAY,EACZ;QACE,KAAK,EAAE,YAAY;QACnB,WAAW,EAAE,kFAAkF;QAC/F,WAAW,EAAE;YACX,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,mBAAmB,CAAC;YACtD,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,0BAA0B,CAAC;SAC5F;KACF,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;QACd,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,2BAA2B,EAAE,KAAgC,CAAC,CAAA;QAClG,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAA;IAC/E,CAAC,CACF,CAAA;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "taka-cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Taka creative tools CLI — generate images, videos, emails, flyers, and more from the command line.",
|
|
5
|
+
"bin": {
|
|
6
|
+
"taka": "./dist/main.js"
|
|
7
|
+
},
|
|
8
|
+
"main": "dist/main.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=18"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -p tsconfig.build.json",
|
|
21
|
+
"start": "node ./dist/main.js",
|
|
22
|
+
"start:dev": "tsx watch src/main.ts",
|
|
23
|
+
"lint": "eslint \"{src,test}/**/*.ts\" --fix"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"commander": "^12.0.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^22.0.3",
|
|
30
|
+
"tsx": "^4.20.3",
|
|
31
|
+
"typescript": "^5.8.3"
|
|
32
|
+
}
|
|
33
|
+
}
|