@marktoflow/integrations 2.0.0-alpha.12
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 +1341 -0
- package/dist/adapters/claude-agent-hooks.d.ts.map +1 -0
- package/dist/adapters/claude-agent-hooks.js +339 -0
- package/dist/adapters/claude-agent-hooks.js.map +1 -0
- package/dist/adapters/claude-agent-types.d.ts +426 -0
- package/dist/adapters/claude-agent-types.d.ts.map +1 -0
- package/dist/adapters/claude-agent-types.js +62 -0
- package/dist/adapters/claude-agent-types.js.map +1 -0
- package/dist/adapters/claude-agent-workflow.d.ts +393 -0
- package/dist/adapters/claude-agent-workflow.d.ts.map +1 -0
- package/dist/adapters/claude-agent-workflow.js +445 -0
- package/dist/adapters/claude-agent-workflow.js.map +1 -0
- package/dist/adapters/claude-agent.d.ts +189 -0
- package/dist/adapters/claude-agent.d.ts.map +1 -0
- package/dist/adapters/claude-agent.js +504 -0
- package/dist/adapters/claude-agent.js.map +1 -0
- package/dist/adapters/claude-code.d.ts +34 -0
- package/dist/adapters/claude-code.d.ts.map +1 -0
- package/dist/adapters/claude-code.js +89 -0
- package/dist/adapters/claude-code.js.map +1 -0
- package/dist/adapters/codex-types.d.ts +463 -0
- package/dist/adapters/codex-types.d.ts.map +1 -0
- package/dist/adapters/codex-types.js +53 -0
- package/dist/adapters/codex-types.js.map +1 -0
- package/dist/adapters/codex-workflow.d.ts +414 -0
- package/dist/adapters/codex-workflow.d.ts.map +1 -0
- package/dist/adapters/codex-workflow.js +470 -0
- package/dist/adapters/codex-workflow.js.map +1 -0
- package/dist/adapters/codex.d.ts +154 -0
- package/dist/adapters/codex.d.ts.map +1 -0
- package/dist/adapters/codex.js +416 -0
- package/dist/adapters/codex.js.map +1 -0
- package/dist/adapters/github-copilot-types.d.ts +1012 -0
- package/dist/adapters/github-copilot-types.d.ts.map +1 -0
- package/dist/adapters/github-copilot-types.js +80 -0
- package/dist/adapters/github-copilot-types.js.map +1 -0
- package/dist/adapters/github-copilot-workflow.d.ts +462 -0
- package/dist/adapters/github-copilot-workflow.d.ts.map +1 -0
- package/dist/adapters/github-copilot-workflow.js +473 -0
- package/dist/adapters/github-copilot-workflow.js.map +1 -0
- package/dist/adapters/github-copilot.d.ts +280 -0
- package/dist/adapters/github-copilot.d.ts.map +1 -0
- package/dist/adapters/github-copilot.js +468 -0
- package/dist/adapters/github-copilot.js.map +1 -0
- package/dist/adapters/ollama.d.ts.map +1 -0
- package/dist/adapters/ollama.js +9 -0
- package/dist/adapters/ollama.js.map +1 -0
- package/dist/adapters/opencode.d.ts +41 -0
- package/dist/adapters/opencode.d.ts.map +1 -0
- package/dist/adapters/opencode.js +148 -0
- package/dist/adapters/opencode.js.map +1 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +161 -0
- package/dist/index.js.map +1 -0
- package/dist/services/ai-browser.d.ts +112 -0
- package/dist/services/ai-browser.d.ts.map +1 -0
- package/dist/services/ai-browser.js +363 -0
- package/dist/services/ai-browser.js.map +1 -0
- package/dist/services/airtable.d.ts.map +1 -0
- package/dist/services/airtable.js +295 -0
- package/dist/services/airtable.js.map +1 -0
- package/dist/services/asana.d.ts +159 -0
- package/dist/services/asana.d.ts.map +1 -0
- package/dist/services/asana.js +196 -0
- package/dist/services/asana.js.map +1 -0
- package/dist/services/aws-s3.d.ts +89 -0
- package/dist/services/aws-s3.d.ts.map +1 -0
- package/dist/services/aws-s3.js +154 -0
- package/dist/services/aws-s3.js.map +1 -0
- package/dist/services/confluence.d.ts.map +1 -0
- package/dist/services/confluence.js +356 -0
- package/dist/services/confluence.js.map +1 -0
- package/dist/services/discord.d.ts.map +1 -0
- package/dist/services/discord.js +279 -0
- package/dist/services/discord.js.map +1 -0
- package/dist/services/dropbox.d.ts +134 -0
- package/dist/services/dropbox.d.ts.map +1 -0
- package/dist/services/dropbox.js +190 -0
- package/dist/services/dropbox.js.map +1 -0
- package/dist/services/github.d.ts.map +1 -0
- package/dist/services/github.js +13 -0
- package/dist/services/github.js.map +1 -0
- package/dist/services/gmail-trigger.d.ts.map +1 -0
- package/dist/services/gmail-trigger.js +172 -0
- package/dist/services/gmail-trigger.js.map +1 -0
- package/dist/services/gmail.d.ts.map +1 -0
- package/dist/services/gmail.js +372 -0
- package/dist/services/gmail.js.map +1 -0
- package/dist/services/google-calendar.d.ts.map +1 -0
- package/dist/services/google-calendar.js +357 -0
- package/dist/services/google-calendar.js.map +1 -0
- package/dist/services/google-docs.d.ts.map +1 -0
- package/dist/services/google-docs.js +332 -0
- package/dist/services/google-docs.js.map +1 -0
- package/dist/services/google-drive.d.ts.map +1 -0
- package/dist/services/google-drive.js +327 -0
- package/dist/services/google-drive.js.map +1 -0
- package/dist/services/google-sheets.d.ts.map +1 -0
- package/dist/services/google-sheets.js +391 -0
- package/dist/services/google-sheets.js.map +1 -0
- package/dist/services/http.d.ts.map +1 -0
- package/dist/services/http.js +284 -0
- package/dist/services/http.js.map +1 -0
- package/dist/services/jira.d.ts.map +1 -0
- package/dist/services/jira.js +35 -0
- package/dist/services/jira.js.map +1 -0
- package/dist/services/linear.d.ts.map +1 -0
- package/dist/services/linear.js +326 -0
- package/dist/services/linear.js.map +1 -0
- package/dist/services/mailchimp.d.ts +169 -0
- package/dist/services/mailchimp.d.ts.map +1 -0
- package/dist/services/mailchimp.js +180 -0
- package/dist/services/mailchimp.js.map +1 -0
- package/dist/services/mysql.d.ts.map +1 -0
- package/dist/services/mysql.js +250 -0
- package/dist/services/mysql.js.map +1 -0
- package/dist/services/notion.d.ts.map +1 -0
- package/dist/services/notion.js +358 -0
- package/dist/services/notion.js.map +1 -0
- package/dist/services/outlook-trigger.d.ts.map +1 -0
- package/dist/services/outlook-trigger.js +204 -0
- package/dist/services/outlook-trigger.js.map +1 -0
- package/dist/services/outlook.d.ts.map +1 -0
- package/dist/services/outlook.js +486 -0
- package/dist/services/outlook.js.map +1 -0
- package/dist/services/playwright.d.ts +678 -0
- package/dist/services/playwright.d.ts.map +1 -0
- package/dist/services/playwright.js +1141 -0
- package/dist/services/playwright.js.map +1 -0
- package/dist/services/postgres.d.ts.map +1 -0
- package/dist/services/postgres.js +230 -0
- package/dist/services/postgres.js.map +1 -0
- package/dist/services/sendgrid.d.ts +43 -0
- package/dist/services/sendgrid.d.ts.map +1 -0
- package/dist/services/sendgrid.js +87 -0
- package/dist/services/sendgrid.js.map +1 -0
- package/dist/services/shopify.d.ts +160 -0
- package/dist/services/shopify.d.ts.map +1 -0
- package/dist/services/shopify.js +166 -0
- package/dist/services/shopify.js.map +1 -0
- package/dist/services/slack-socket.d.ts.map +1 -0
- package/dist/services/slack-socket.js +48 -0
- package/dist/services/slack-socket.js.map +1 -0
- package/dist/services/slack.d.ts.map +1 -0
- package/dist/services/slack.js +11 -0
- package/dist/services/slack.js.map +1 -0
- package/dist/services/stripe.d.ts +275 -0
- package/dist/services/stripe.d.ts.map +1 -0
- package/dist/services/stripe.js +229 -0
- package/dist/services/stripe.js.map +1 -0
- package/dist/services/supabase.d.ts.map +1 -0
- package/dist/services/supabase.js +328 -0
- package/dist/services/supabase.js.map +1 -0
- package/dist/services/teams.d.ts +224 -0
- package/dist/services/teams.d.ts.map +1 -0
- package/dist/services/teams.js +229 -0
- package/dist/services/teams.js.map +1 -0
- package/dist/services/telegram.d.ts.map +1 -0
- package/dist/services/telegram.js +247 -0
- package/dist/services/telegram.js.map +1 -0
- package/dist/services/trello.d.ts +160 -0
- package/dist/services/trello.d.ts.map +1 -0
- package/dist/services/trello.js +194 -0
- package/dist/services/trello.js.map +1 -0
- package/dist/services/twilio.d.ts +126 -0
- package/dist/services/twilio.d.ts.map +1 -0
- package/dist/services/twilio.js +153 -0
- package/dist/services/twilio.js.map +1 -0
- package/dist/services/whatsapp.d.ts.map +1 -0
- package/dist/services/whatsapp.js +253 -0
- package/dist/services/whatsapp.js.map +1 -0
- package/dist/services/zendesk.d.ts +134 -0
- package/dist/services/zendesk.d.ts.map +1 -0
- package/dist/services/zendesk.js +148 -0
- package/dist/services/zendesk.js.map +1 -0
- package/dist/tools/script.d.ts +21 -0
- package/dist/tools/script.d.ts.map +1 -0
- package/dist/tools/script.js +136 -0
- package/dist/tools/script.js.map +1 -0
- package/package.json +98 -0
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI Codex Workflow Actions for marktoflow
|
|
3
|
+
*
|
|
4
|
+
* Provides workflow action handlers that expose the full Codex SDK
|
|
5
|
+
* capabilities to markdown workflows, including:
|
|
6
|
+
* - Code generation and modification
|
|
7
|
+
* - Web search and research
|
|
8
|
+
* - Command execution
|
|
9
|
+
* - Structured output
|
|
10
|
+
* - Thread management (resume conversations)
|
|
11
|
+
*/
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import { CodexClient, } from './codex.js';
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// Workflow Action Schemas
|
|
16
|
+
// ============================================================================
|
|
17
|
+
/**
|
|
18
|
+
* Schema for codex.chat action
|
|
19
|
+
*/
|
|
20
|
+
export const CodexChatSchema = z.object({
|
|
21
|
+
prompt: z.string().describe('The message to send to Codex'),
|
|
22
|
+
model: z.string().optional().describe('Model to use'),
|
|
23
|
+
workingDirectory: z.string().optional().describe('Working directory for the agent'),
|
|
24
|
+
reasoningEffort: z
|
|
25
|
+
.enum(['minimal', 'low', 'medium', 'high', 'xhigh'])
|
|
26
|
+
.optional()
|
|
27
|
+
.describe('Model reasoning effort level'),
|
|
28
|
+
sandboxMode: z
|
|
29
|
+
.enum(['read-only', 'workspace-write', 'danger-full-access'])
|
|
30
|
+
.optional()
|
|
31
|
+
.describe('Sandbox mode for file system access'),
|
|
32
|
+
webSearch: z.boolean().optional().describe('Enable web search'),
|
|
33
|
+
threadId: z.string().optional().describe('Thread ID to resume'),
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* Schema for codex.codeModify action
|
|
37
|
+
*/
|
|
38
|
+
export const CodexCodeModifySchema = z.object({
|
|
39
|
+
prompt: z.string().describe('Code modification request'),
|
|
40
|
+
workingDirectory: z.string().optional().describe('Working directory'),
|
|
41
|
+
additionalDirectories: z.array(z.string()).optional().describe('Additional directories to access'),
|
|
42
|
+
excludeFiles: z.array(z.string()).optional().describe('Files to exclude from context'),
|
|
43
|
+
reasoningEffort: z
|
|
44
|
+
.enum(['minimal', 'low', 'medium', 'high', 'xhigh'])
|
|
45
|
+
.optional()
|
|
46
|
+
.describe('Reasoning effort level'),
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* Schema for codex.codeAnalyze action
|
|
50
|
+
*/
|
|
51
|
+
export const CodexCodeAnalyzeSchema = z.object({
|
|
52
|
+
prompt: z.string().describe('Code analysis request'),
|
|
53
|
+
workingDirectory: z.string().optional().describe('Working directory'),
|
|
54
|
+
additionalDirectories: z.array(z.string()).optional().describe('Additional directories to access'),
|
|
55
|
+
excludeFiles: z.array(z.string()).optional().describe('Files to exclude from context'),
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Schema for codex.codeReview action
|
|
59
|
+
*/
|
|
60
|
+
export const CodexCodeReviewSchema = z.object({
|
|
61
|
+
prompt: z.string().describe('Code review request'),
|
|
62
|
+
files: z.array(z.string()).optional().describe('Files to review'),
|
|
63
|
+
focusAreas: z
|
|
64
|
+
.array(z.string())
|
|
65
|
+
.optional()
|
|
66
|
+
.describe('Areas to focus on (security, performance, quality)'),
|
|
67
|
+
workingDirectory: z.string().optional().describe('Working directory'),
|
|
68
|
+
});
|
|
69
|
+
/**
|
|
70
|
+
* Schema for codex.webSearch action
|
|
71
|
+
*/
|
|
72
|
+
export const CodexWebSearchSchema = z.object({
|
|
73
|
+
prompt: z.string().describe('Research query'),
|
|
74
|
+
searchMode: z.enum(['cached', 'live']).optional().describe('Web search mode'),
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* Schema for codex.execute action
|
|
78
|
+
*/
|
|
79
|
+
export const CodexExecuteSchema = z.object({
|
|
80
|
+
prompt: z.string().describe('Command execution request'),
|
|
81
|
+
workingDirectory: z.string().optional().describe('Working directory'),
|
|
82
|
+
approvalPolicy: z
|
|
83
|
+
.enum(['never', 'on-request', 'on-failure', 'untrusted'])
|
|
84
|
+
.optional()
|
|
85
|
+
.describe('Command approval policy'),
|
|
86
|
+
});
|
|
87
|
+
/**
|
|
88
|
+
* Schema for codex.structured action
|
|
89
|
+
*/
|
|
90
|
+
export const CodexStructuredSchema = z.object({
|
|
91
|
+
prompt: z.string().describe('Task for structured output'),
|
|
92
|
+
schema: z.record(z.unknown()).describe('JSON schema for output'),
|
|
93
|
+
workingDirectory: z.string().optional().describe('Working directory'),
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* Schema for codex.resume action
|
|
97
|
+
*/
|
|
98
|
+
export const CodexResumeSchema = z.object({
|
|
99
|
+
threadId: z.string().describe('Thread ID to resume'),
|
|
100
|
+
prompt: z.string().describe('Follow-up message'),
|
|
101
|
+
workingDirectory: z.string().optional().describe('Working directory'),
|
|
102
|
+
});
|
|
103
|
+
/**
|
|
104
|
+
* Schema for codex.withImages action
|
|
105
|
+
*/
|
|
106
|
+
export const CodexWithImagesSchema = z.object({
|
|
107
|
+
prompt: z.string().describe('Task with images'),
|
|
108
|
+
images: z.array(z.string()).describe('Paths to local images'),
|
|
109
|
+
workingDirectory: z.string().optional().describe('Working directory'),
|
|
110
|
+
});
|
|
111
|
+
// ============================================================================
|
|
112
|
+
// Workflow Action Handlers
|
|
113
|
+
// ============================================================================
|
|
114
|
+
/**
|
|
115
|
+
* Create workflow-compatible Codex action handlers
|
|
116
|
+
*
|
|
117
|
+
* Returns an object with methods that can be called from workflow actions:
|
|
118
|
+
* - codex.chat
|
|
119
|
+
* - codex.codeModify
|
|
120
|
+
* - codex.codeAnalyze
|
|
121
|
+
* - codex.codeReview
|
|
122
|
+
* - codex.webSearch
|
|
123
|
+
* - codex.execute
|
|
124
|
+
* - codex.structured
|
|
125
|
+
* - codex.resume
|
|
126
|
+
* - codex.withImages
|
|
127
|
+
*/
|
|
128
|
+
export function createCodexActions(clientConfig) {
|
|
129
|
+
const client = new CodexClient(clientConfig);
|
|
130
|
+
return {
|
|
131
|
+
/**
|
|
132
|
+
* Send a chat message to Codex
|
|
133
|
+
*
|
|
134
|
+
* Usage in workflow:
|
|
135
|
+
* ```yaml
|
|
136
|
+
* action: codex.chat
|
|
137
|
+
* inputs:
|
|
138
|
+
* prompt: "Explain how this codebase works"
|
|
139
|
+
* workingDirectory: ./src
|
|
140
|
+
* reasoningEffort: medium
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
async chat(inputs) {
|
|
144
|
+
const parsed = CodexChatSchema.parse(inputs);
|
|
145
|
+
const threadOptions = {
|
|
146
|
+
model: parsed.model,
|
|
147
|
+
workingDirectory: parsed.workingDirectory || process.cwd(),
|
|
148
|
+
modelReasoningEffort: parsed.reasoningEffort,
|
|
149
|
+
sandboxMode: parsed.sandboxMode || 'workspace-write',
|
|
150
|
+
skipGitRepoCheck: true,
|
|
151
|
+
};
|
|
152
|
+
if (parsed.webSearch) {
|
|
153
|
+
threadOptions.webSearchMode = 'live';
|
|
154
|
+
threadOptions.networkAccessEnabled = true;
|
|
155
|
+
}
|
|
156
|
+
if (parsed.threadId) {
|
|
157
|
+
return client.resumeAndSend(parsed.threadId, parsed.prompt, threadOptions);
|
|
158
|
+
}
|
|
159
|
+
return client.sendWithThread(parsed.prompt, threadOptions);
|
|
160
|
+
},
|
|
161
|
+
/**
|
|
162
|
+
* Modify code with Codex assistance
|
|
163
|
+
*
|
|
164
|
+
* Usage in workflow:
|
|
165
|
+
* ```yaml
|
|
166
|
+
* action: codex.codeModify
|
|
167
|
+
* inputs:
|
|
168
|
+
* prompt: "Add TypeScript types to all functions"
|
|
169
|
+
* workingDirectory: ./src
|
|
170
|
+
* reasoningEffort: high
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
async codeModify(inputs) {
|
|
174
|
+
const parsed = CodexCodeModifySchema.parse(inputs);
|
|
175
|
+
return client.modifyCode({
|
|
176
|
+
prompt: parsed.prompt,
|
|
177
|
+
workingDirectory: parsed.workingDirectory,
|
|
178
|
+
additionalDirectories: parsed.additionalDirectories,
|
|
179
|
+
excludeFiles: parsed.excludeFiles,
|
|
180
|
+
reasoningEffort: parsed.reasoningEffort,
|
|
181
|
+
});
|
|
182
|
+
},
|
|
183
|
+
/**
|
|
184
|
+
* Analyze code without making changes
|
|
185
|
+
*
|
|
186
|
+
* Usage in workflow:
|
|
187
|
+
* ```yaml
|
|
188
|
+
* action: codex.codeAnalyze
|
|
189
|
+
* inputs:
|
|
190
|
+
* prompt: "Explain the architecture of this project"
|
|
191
|
+
* workingDirectory: ./
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
async codeAnalyze(inputs) {
|
|
195
|
+
const parsed = CodexCodeAnalyzeSchema.parse(inputs);
|
|
196
|
+
return client.analyzeCode({
|
|
197
|
+
prompt: parsed.prompt,
|
|
198
|
+
workingDirectory: parsed.workingDirectory,
|
|
199
|
+
additionalDirectories: parsed.additionalDirectories,
|
|
200
|
+
excludeFiles: parsed.excludeFiles,
|
|
201
|
+
});
|
|
202
|
+
},
|
|
203
|
+
/**
|
|
204
|
+
* Perform a code review
|
|
205
|
+
*
|
|
206
|
+
* Usage in workflow:
|
|
207
|
+
* ```yaml
|
|
208
|
+
* action: codex.codeReview
|
|
209
|
+
* inputs:
|
|
210
|
+
* prompt: "Review for security issues"
|
|
211
|
+
* files:
|
|
212
|
+
* - src/auth.ts
|
|
213
|
+
* - src/api.ts
|
|
214
|
+
* focusAreas: [security, performance]
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
async codeReview(inputs) {
|
|
218
|
+
const parsed = CodexCodeReviewSchema.parse(inputs);
|
|
219
|
+
const focusAreas = parsed.focusAreas || [
|
|
220
|
+
'security',
|
|
221
|
+
'performance',
|
|
222
|
+
'quality',
|
|
223
|
+
'maintainability',
|
|
224
|
+
];
|
|
225
|
+
let prompt = parsed.prompt;
|
|
226
|
+
if (parsed.files && parsed.files.length > 0) {
|
|
227
|
+
prompt += `\n\nFiles to review:\n${parsed.files.map((f) => `- ${f}`).join('\n')}`;
|
|
228
|
+
}
|
|
229
|
+
prompt += `\n\nFocus areas: ${focusAreas.join(', ')}`;
|
|
230
|
+
prompt += `\n\nFor each issue found, provide:
|
|
231
|
+
- File path and line number (if applicable)
|
|
232
|
+
- Severity: critical, high, medium, low
|
|
233
|
+
- Category: ${focusAreas.join(', ')}
|
|
234
|
+
- Clear description
|
|
235
|
+
- Suggested fix`;
|
|
236
|
+
return client.analyzeCode({
|
|
237
|
+
prompt,
|
|
238
|
+
workingDirectory: parsed.workingDirectory,
|
|
239
|
+
});
|
|
240
|
+
},
|
|
241
|
+
/**
|
|
242
|
+
* Perform web research
|
|
243
|
+
*
|
|
244
|
+
* Usage in workflow:
|
|
245
|
+
* ```yaml
|
|
246
|
+
* action: codex.webSearch
|
|
247
|
+
* inputs:
|
|
248
|
+
* prompt: "Find best practices for React hooks"
|
|
249
|
+
* searchMode: live
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
async webSearch(inputs) {
|
|
253
|
+
const parsed = CodexWebSearchSchema.parse(inputs);
|
|
254
|
+
return client.webSearch({
|
|
255
|
+
prompt: parsed.prompt,
|
|
256
|
+
searchMode: parsed.searchMode,
|
|
257
|
+
});
|
|
258
|
+
},
|
|
259
|
+
/**
|
|
260
|
+
* Execute commands via the agent
|
|
261
|
+
*
|
|
262
|
+
* Usage in workflow:
|
|
263
|
+
* ```yaml
|
|
264
|
+
* action: codex.execute
|
|
265
|
+
* inputs:
|
|
266
|
+
* prompt: "Run the test suite and fix any failing tests"
|
|
267
|
+
* workingDirectory: ./
|
|
268
|
+
* approvalPolicy: never
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
async execute(inputs) {
|
|
272
|
+
const parsed = CodexExecuteSchema.parse(inputs);
|
|
273
|
+
return client.executeCommands({
|
|
274
|
+
prompt: parsed.prompt,
|
|
275
|
+
workingDirectory: parsed.workingDirectory,
|
|
276
|
+
approvalPolicy: parsed.approvalPolicy,
|
|
277
|
+
});
|
|
278
|
+
},
|
|
279
|
+
/**
|
|
280
|
+
* Get structured JSON output
|
|
281
|
+
*
|
|
282
|
+
* Usage in workflow:
|
|
283
|
+
* ```yaml
|
|
284
|
+
* action: codex.structured
|
|
285
|
+
* inputs:
|
|
286
|
+
* prompt: "List all exported functions in this file"
|
|
287
|
+
* schema:
|
|
288
|
+
* type: object
|
|
289
|
+
* properties:
|
|
290
|
+
* functions:
|
|
291
|
+
* type: array
|
|
292
|
+
* items:
|
|
293
|
+
* type: object
|
|
294
|
+
* properties:
|
|
295
|
+
* name: { type: string }
|
|
296
|
+
* parameters: { type: array, items: { type: string } }
|
|
297
|
+
* returnType: { type: string }
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
300
|
+
async structured(inputs) {
|
|
301
|
+
const parsed = CodexStructuredSchema.parse(inputs);
|
|
302
|
+
return client.sendStructured({
|
|
303
|
+
prompt: parsed.prompt,
|
|
304
|
+
schema: parsed.schema,
|
|
305
|
+
threadOptions: {
|
|
306
|
+
workingDirectory: parsed.workingDirectory,
|
|
307
|
+
skipGitRepoCheck: true,
|
|
308
|
+
},
|
|
309
|
+
});
|
|
310
|
+
},
|
|
311
|
+
/**
|
|
312
|
+
* Resume a previous thread
|
|
313
|
+
*
|
|
314
|
+
* Usage in workflow:
|
|
315
|
+
* ```yaml
|
|
316
|
+
* action: codex.resume
|
|
317
|
+
* inputs:
|
|
318
|
+
* threadId: "{{ previous_result.threadId }}"
|
|
319
|
+
* prompt: "Now add unit tests for those functions"
|
|
320
|
+
* ```
|
|
321
|
+
*/
|
|
322
|
+
async resume(inputs) {
|
|
323
|
+
const parsed = CodexResumeSchema.parse(inputs);
|
|
324
|
+
return client.resumeAndSend(parsed.threadId, parsed.prompt, {
|
|
325
|
+
workingDirectory: parsed.workingDirectory,
|
|
326
|
+
skipGitRepoCheck: true,
|
|
327
|
+
});
|
|
328
|
+
},
|
|
329
|
+
/**
|
|
330
|
+
* Send with local images
|
|
331
|
+
*
|
|
332
|
+
* Usage in workflow:
|
|
333
|
+
* ```yaml
|
|
334
|
+
* action: codex.withImages
|
|
335
|
+
* inputs:
|
|
336
|
+
* prompt: "Implement this UI based on the mockup"
|
|
337
|
+
* images:
|
|
338
|
+
* - ./mockups/dashboard.png
|
|
339
|
+
* - ./mockups/sidebar.png
|
|
340
|
+
* ```
|
|
341
|
+
*/
|
|
342
|
+
async withImages(inputs) {
|
|
343
|
+
const parsed = CodexWithImagesSchema.parse(inputs);
|
|
344
|
+
const input = [
|
|
345
|
+
{ type: 'text', text: parsed.prompt },
|
|
346
|
+
...parsed.images.map((path) => ({
|
|
347
|
+
type: 'local_image',
|
|
348
|
+
path,
|
|
349
|
+
})),
|
|
350
|
+
];
|
|
351
|
+
return client.sendWithThread(input, {
|
|
352
|
+
workingDirectory: parsed.workingDirectory,
|
|
353
|
+
skipGitRepoCheck: true,
|
|
354
|
+
sandboxMode: 'workspace-write',
|
|
355
|
+
});
|
|
356
|
+
},
|
|
357
|
+
/**
|
|
358
|
+
* Stream a response (for use in handlers that support streaming)
|
|
359
|
+
*
|
|
360
|
+
* Usage programmatically:
|
|
361
|
+
* ```typescript
|
|
362
|
+
* const actions = createCodexActions();
|
|
363
|
+
* await actions.stream({
|
|
364
|
+
* prompt: "Explain this code",
|
|
365
|
+
* onChunk: (chunk) => console.log(chunk),
|
|
366
|
+
* });
|
|
367
|
+
* ```
|
|
368
|
+
*/
|
|
369
|
+
async stream(inputs) {
|
|
370
|
+
return client.stream({
|
|
371
|
+
prompt: inputs.prompt,
|
|
372
|
+
threadOptions: inputs.threadOptions,
|
|
373
|
+
turnOptions: inputs.turnOptions,
|
|
374
|
+
onChunk: inputs.onChunk,
|
|
375
|
+
});
|
|
376
|
+
},
|
|
377
|
+
/**
|
|
378
|
+
* Get the last thread ID (for resuming later)
|
|
379
|
+
*/
|
|
380
|
+
getLastThreadId() {
|
|
381
|
+
return client.getLastThreadId();
|
|
382
|
+
},
|
|
383
|
+
/**
|
|
384
|
+
* Get the underlying client for advanced use
|
|
385
|
+
*/
|
|
386
|
+
getClient() {
|
|
387
|
+
return client;
|
|
388
|
+
},
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
// ============================================================================
|
|
392
|
+
// Preset Configurations
|
|
393
|
+
// ============================================================================
|
|
394
|
+
/**
|
|
395
|
+
* Preset thread configurations for common tasks
|
|
396
|
+
*/
|
|
397
|
+
export const CodexPresetConfigs = {
|
|
398
|
+
/**
|
|
399
|
+
* Read-only analysis - safe for reviewing code
|
|
400
|
+
*/
|
|
401
|
+
readOnly: {
|
|
402
|
+
sandboxMode: 'read-only',
|
|
403
|
+
skipGitRepoCheck: true,
|
|
404
|
+
modelReasoningEffort: 'medium',
|
|
405
|
+
},
|
|
406
|
+
/**
|
|
407
|
+
* Code modification - can write to workspace
|
|
408
|
+
*/
|
|
409
|
+
codeModification: {
|
|
410
|
+
sandboxMode: 'workspace-write',
|
|
411
|
+
skipGitRepoCheck: true,
|
|
412
|
+
modelReasoningEffort: 'high',
|
|
413
|
+
},
|
|
414
|
+
/**
|
|
415
|
+
* Full access - can execute commands
|
|
416
|
+
*/
|
|
417
|
+
fullAccess: {
|
|
418
|
+
sandboxMode: 'danger-full-access',
|
|
419
|
+
skipGitRepoCheck: true,
|
|
420
|
+
approvalPolicy: 'never',
|
|
421
|
+
networkAccessEnabled: true,
|
|
422
|
+
},
|
|
423
|
+
/**
|
|
424
|
+
* Research mode - web search enabled
|
|
425
|
+
*/
|
|
426
|
+
research: {
|
|
427
|
+
webSearchMode: 'live',
|
|
428
|
+
networkAccessEnabled: true,
|
|
429
|
+
skipGitRepoCheck: true,
|
|
430
|
+
sandboxMode: 'read-only',
|
|
431
|
+
},
|
|
432
|
+
/**
|
|
433
|
+
* High reasoning - for complex tasks
|
|
434
|
+
*/
|
|
435
|
+
highReasoning: {
|
|
436
|
+
modelReasoningEffort: 'xhigh',
|
|
437
|
+
skipGitRepoCheck: true,
|
|
438
|
+
sandboxMode: 'workspace-write',
|
|
439
|
+
},
|
|
440
|
+
};
|
|
441
|
+
/**
|
|
442
|
+
* Preset prompts for common code review tasks
|
|
443
|
+
*/
|
|
444
|
+
export const CodexReviewPrompts = {
|
|
445
|
+
security: `Review this code for security vulnerabilities including:
|
|
446
|
+
- Injection attacks (SQL, XSS, command injection)
|
|
447
|
+
- Authentication and authorization issues
|
|
448
|
+
- Data exposure and privacy concerns
|
|
449
|
+
- Cryptographic weaknesses
|
|
450
|
+
- OWASP Top 10 vulnerabilities`,
|
|
451
|
+
performance: `Review this code for performance issues including:
|
|
452
|
+
- Algorithm complexity (time and space)
|
|
453
|
+
- Database query optimization
|
|
454
|
+
- Memory leaks
|
|
455
|
+
- Unnecessary computations
|
|
456
|
+
- Caching opportunities`,
|
|
457
|
+
quality: `Review this code for quality issues including:
|
|
458
|
+
- Code duplication
|
|
459
|
+
- Complex functions that should be split
|
|
460
|
+
- Poor naming conventions
|
|
461
|
+
- Missing error handling
|
|
462
|
+
- Lack of documentation`,
|
|
463
|
+
typescript: `Review this TypeScript code for type safety including:
|
|
464
|
+
- Missing type annotations
|
|
465
|
+
- Use of 'any' type
|
|
466
|
+
- Incorrect type assertions
|
|
467
|
+
- Missing null checks
|
|
468
|
+
- Generic type improvements`,
|
|
469
|
+
};
|
|
470
|
+
//# sourceMappingURL=codex-workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-workflow.js","sourceRoot":"","sources":["../../src/adapters/codex-workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,WAAW,GAEZ,MAAM,YAAY,CAAC;AAQpB,+EAA+E;AAC/E,0BAA0B;AAC1B,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe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,WAAW,EAAE,iBAA0B;KACxC;CACF,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,QAAQ,EAAE;;;;;+BAKmB;IAE7B,WAAW,EAAE;;;;;wBAKS;IAEtB,OAAO,EAAE;;;;;wBAKa;IAEtB,UAAU,EAAE;;;;;4BAKc;CAC3B,CAAC"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI Codex SDK Adapter for marktoflow
|
|
3
|
+
*
|
|
4
|
+
* This adapter provides integration with the OpenAI Codex SDK,
|
|
5
|
+
* enabling AI-powered coding workflows with file changes, command execution,
|
|
6
|
+
* web search, structured output, and streaming capabilities.
|
|
7
|
+
*/
|
|
8
|
+
import { Codex, type Thread, type Input } from '@openai/codex-sdk';
|
|
9
|
+
import { SDKInitializer } from '@marktoflow/core';
|
|
10
|
+
import type { CodexClientConfig, CodexThreadOptions, CodexTurnOptions, CodexResult, CodexStreamCallback } from './codex-types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Extended configuration for the CodexClient wrapper
|
|
13
|
+
*/
|
|
14
|
+
export interface CodexClientOptions extends CodexClientConfig {
|
|
15
|
+
/** Default thread options */
|
|
16
|
+
defaultThreadOptions?: CodexThreadOptions;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Client for interacting with OpenAI Codex via the SDK
|
|
20
|
+
*
|
|
21
|
+
* Provides multiple interfaces for different use cases:
|
|
22
|
+
* - send(): Simple prompt-response
|
|
23
|
+
* - stream(): Streaming responses with callbacks
|
|
24
|
+
* - sendWithThread(): Full thread control
|
|
25
|
+
* - resumeThread(): Continue previous conversations
|
|
26
|
+
*/
|
|
27
|
+
export declare class CodexClient {
|
|
28
|
+
private codex;
|
|
29
|
+
private defaultThreadOptions;
|
|
30
|
+
private activeThread;
|
|
31
|
+
private lastThreadId;
|
|
32
|
+
constructor(config?: CodexClientOptions);
|
|
33
|
+
/**
|
|
34
|
+
* Send a message and wait for the complete response
|
|
35
|
+
*/
|
|
36
|
+
send(inputs: {
|
|
37
|
+
prompt: string | Input;
|
|
38
|
+
threadOptions?: CodexThreadOptions;
|
|
39
|
+
turnOptions?: CodexTurnOptions;
|
|
40
|
+
}): Promise<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Send a message and stream the response
|
|
43
|
+
*/
|
|
44
|
+
stream(inputs: {
|
|
45
|
+
prompt: string | Input;
|
|
46
|
+
threadOptions?: CodexThreadOptions;
|
|
47
|
+
turnOptions?: CodexTurnOptions;
|
|
48
|
+
onChunk?: (chunk: string) => void;
|
|
49
|
+
onEvent?: CodexStreamCallback;
|
|
50
|
+
onComplete?: (result: CodexResult) => void;
|
|
51
|
+
}): Promise<CodexResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Send a message with full thread configuration
|
|
54
|
+
*/
|
|
55
|
+
sendWithThread(message: string | Input, threadOptions?: CodexThreadOptions, turnOptions?: CodexTurnOptions): Promise<CodexResult>;
|
|
56
|
+
/**
|
|
57
|
+
* Stream with full thread configuration
|
|
58
|
+
*/
|
|
59
|
+
streamWithThread(message: string | Input, callback: CodexStreamCallback, threadOptions?: CodexThreadOptions, turnOptions?: CodexTurnOptions): Promise<CodexResult>;
|
|
60
|
+
/**
|
|
61
|
+
* Resume a previous thread and send a message
|
|
62
|
+
*/
|
|
63
|
+
resumeAndSend(threadId: string, message: string | Input, threadOptions?: CodexThreadOptions, turnOptions?: CodexTurnOptions): Promise<CodexResult>;
|
|
64
|
+
/**
|
|
65
|
+
* Resume a thread and stream the response
|
|
66
|
+
*/
|
|
67
|
+
resumeAndStream(threadId: string, message: string | Input, callback: CodexStreamCallback, threadOptions?: CodexThreadOptions, turnOptions?: CodexTurnOptions): Promise<CodexResult>;
|
|
68
|
+
/**
|
|
69
|
+
* Create a new thread for multi-turn conversations
|
|
70
|
+
*/
|
|
71
|
+
startThread(options?: CodexThreadOptions): Thread;
|
|
72
|
+
/**
|
|
73
|
+
* Resume an existing thread
|
|
74
|
+
*/
|
|
75
|
+
resumeThread(threadId: string, options?: CodexThreadOptions): Thread;
|
|
76
|
+
/**
|
|
77
|
+
* Get the last thread ID
|
|
78
|
+
*/
|
|
79
|
+
getLastThreadId(): string | null;
|
|
80
|
+
/**
|
|
81
|
+
* Get the active thread
|
|
82
|
+
*/
|
|
83
|
+
getActiveThread(): Thread | null;
|
|
84
|
+
/**
|
|
85
|
+
* Send with structured JSON output
|
|
86
|
+
*/
|
|
87
|
+
sendStructured<T>(inputs: {
|
|
88
|
+
prompt: string | Input;
|
|
89
|
+
schema: unknown;
|
|
90
|
+
threadOptions?: CodexThreadOptions;
|
|
91
|
+
}): Promise<T>;
|
|
92
|
+
/**
|
|
93
|
+
* Execute code modifications
|
|
94
|
+
*/
|
|
95
|
+
modifyCode(inputs: {
|
|
96
|
+
prompt: string;
|
|
97
|
+
workingDirectory?: string;
|
|
98
|
+
additionalDirectories?: string[];
|
|
99
|
+
excludeFiles?: string[];
|
|
100
|
+
reasoningEffort?: 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
|
|
101
|
+
}): Promise<CodexResult>;
|
|
102
|
+
/**
|
|
103
|
+
* Execute shell commands via the agent
|
|
104
|
+
*/
|
|
105
|
+
executeCommands(inputs: {
|
|
106
|
+
prompt: string;
|
|
107
|
+
workingDirectory?: string;
|
|
108
|
+
approvalPolicy?: 'never' | 'on-request' | 'on-failure' | 'untrusted';
|
|
109
|
+
}): Promise<CodexResult>;
|
|
110
|
+
/**
|
|
111
|
+
* Perform web research
|
|
112
|
+
*/
|
|
113
|
+
webSearch(inputs: {
|
|
114
|
+
prompt: string;
|
|
115
|
+
searchMode?: 'cached' | 'live';
|
|
116
|
+
}): Promise<CodexResult>;
|
|
117
|
+
/**
|
|
118
|
+
* Analyze code without making changes
|
|
119
|
+
*/
|
|
120
|
+
analyzeCode(inputs: {
|
|
121
|
+
prompt: string;
|
|
122
|
+
workingDirectory?: string;
|
|
123
|
+
additionalDirectories?: string[];
|
|
124
|
+
excludeFiles?: string[];
|
|
125
|
+
}): Promise<CodexResult>;
|
|
126
|
+
/**
|
|
127
|
+
* Build thread options from configuration
|
|
128
|
+
*/
|
|
129
|
+
private buildThreadOptions;
|
|
130
|
+
/**
|
|
131
|
+
* OpenAI-compatible chat interface for workflow compatibility
|
|
132
|
+
*/
|
|
133
|
+
chat: {
|
|
134
|
+
completions: (inputs: {
|
|
135
|
+
model?: string;
|
|
136
|
+
messages: Array<{
|
|
137
|
+
role: string;
|
|
138
|
+
content: string;
|
|
139
|
+
}>;
|
|
140
|
+
}) => Promise<{
|
|
141
|
+
choices: Array<{
|
|
142
|
+
message: {
|
|
143
|
+
content: string;
|
|
144
|
+
};
|
|
145
|
+
}>;
|
|
146
|
+
}>;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* SDK Initializer for OpenAI Codex
|
|
151
|
+
*/
|
|
152
|
+
export declare const CodexInitializer: SDKInitializer;
|
|
153
|
+
export { Codex, Thread };
|
|
154
|
+
//# sourceMappingURL=codex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../src/adapters/codex.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,KAAK,EACL,KAAK,MAAM,EAKX,KAAK,KAAK,EACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAc,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACX,mBAAmB,EAIpB,MAAM,kBAAkB,CAAC;AAM1B;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,6BAA6B;IAC7B,oBAAoB,CAAC,EAAE,kBAAkB,CAAC;CAC3C;AAMD;;;;;;;;GAQG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,o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